Compare commits

...

885 commits

Author SHA1 Message Date
Carsten Schmiemann 25d79ca572 Original project changes: mdns: task stack size configuration (MDNS_TASK_STACK_SIZE) 2022-11-18 23:19:24 +01:00
Michael Balzer 1ff5e24b1b
Merge pull request #6 from leres/master
Allow  pyparsing > 2.4.0
2021-03-07 19:46:50 +01:00
Craig Leres 844922539e Allow pyparsing > 2.4.0 2021-03-07 10:19:41 -08:00
Michael Balzer a5ee881789 pthread: copy priority inheritance fix from espressif
commit 202e6c8984255b551e29e3182e091cf7cd0153b0
2020-12-21 13:55:27 +01:00
Michael Balzer d59ed8bba0 log: fix timestamp output type 2020-11-08 11:24:40 +01:00
Michael Balzer 7124a32fed Merge branch 'release/v3.3' of https://github.com/espressif/esp-idf.git 2020-11-08 11:07:45 +01:00
Jiang Jiang Jian 44ec7972bd Merge branch 'bugfix/fix_16mbit_psram_id_read_error_v3.3' into 'release/v3.3'
psram: fix 16mbit psram id read error (backport v3.3)

See merge request espressif/esp-idf!9441
2020-11-05 23:02:09 +08:00
Michael (XIAO Xufeng) 49ace4968f spiram: fix the read id failure
The issue is caused by:
1. The disable_qio_mode inside read_id may have side effects.
2. read_id twice may have side effects.

Fix this issue by moving disable_qio_mode out of read_id and only do it
once before read_id. And retry read_id only when the first one is
failed.

Issue introduced in 3ecbb59c15.
2020-11-05 06:11:29 +00:00
chenjianqiang 1903c05d53 psram: fix 16mbit psram id read error 2020-11-05 06:11:29 +00:00
Jiang Jiang Jian 5d42f3075e Merge branch 'feature/toolchain_gcc52_revert_PSRAM_fixes_2020r3_v3.3' into 'release/v3.3'
Update toolchain to 1.22.0-97-gc752ad5 (v3.3)

See merge request espressif/esp-idf!10348
2020-11-05 14:08:47 +08:00
Jiang Jiang Jian 8667591004 Merge branch 'bugfix/lwip_netdb_cpp_guards_v3.3' into 'release/v3.3'
lw-IP: Changed to C linkage in netdb.h for fixing bug when using mixed C/C++ code (v3.3)

See merge request espressif/esp-idf!11092
2020-11-05 14:00:42 +08:00
Jiang Jiang Jian e0a8eb60dd Merge branch 'feature/lwip_tcp_isn_hook_v3.3' into 'release/v3.3'
lw-ip: enable TCP ISN hook (v3.3)

See merge request espressif/esp-idf!11065
2020-11-05 12:10:59 +08:00
Jiang Jiang Jian 25781e7c88 Merge branch 'mesh/bugfix_1023_backport_v3.3' into 'release/v3.3'
esp_wifi_mesh: update wifi mesh libs(Backport v3.3)

See merge request espressif/esp-idf!11081
2020-11-05 12:08:19 +08:00
Anton Maklakov 1f78540cbb windows: Update the prebuilt MSYS2 environment to use then new toolchain
No other changes in the environment contents.
2020-11-04 10:08:00 +07:00
Ivan Grokhotkov 843889fd03 pthread: add dummy implementation of pthread_setcancelstate
Used by new versions of newlib in stdio functions.
2020-11-04 10:08:00 +07:00
Anton Maklakov 873aca4c0d newlib: Build psram libc with the new toolchain
Generated from commit 02c81fb7 in the newlib script repo
2020-11-04 10:08:00 +07:00
Anton Maklakov 81da2bae2a Update toolchain to 1.22.0-97-gc752ad5
Revert a part of PSRAM workaround because of regression
    Add a C++ locale fix for multithreading
2020-11-04 10:07:58 +07:00
Ivan Grokhotkov d8456c621e Merge branch 'bugfix/ci_clone_https_v3.3' into 'release/v3.3'
ci: use HTTPS for cloning in IT jobs (v3.3)

See merge request espressif/esp-idf!11098
2020-11-03 21:45:37 +08:00
Ivan Grokhotkov cc8f9cc539 ci: use HTTPS for cloning in IT jobs 2020-11-03 19:33:21 +08:00
mathiasbredholt 737fce72cc lwip: Changed to C linkage for fixing bug when using mixed C/C++ code
Merges https://github.com/espressif/esp-idf/pull/5900
2020-11-03 08:43:09 +01:00
shenjun a15f77e1c7 esp_wifi_mesh: update wifi mesh libs
1. Fix FIX-ROOT does not reconnect to router when disconnect reason is too many
2. Add API esp_mesh_print_scan_result
3. Modify not to reset mesh_xonseq of self and children when flush_upstream_packets
4. Fix not switch to a parent candidate which has the same layer and assoc as current parent
5. Fix not arm parent monitor when a parent candidate is cleared without sending an event to mesh layer
6. Fix the new voted root does not reconnect to router if rssi is weak
2020-11-03 15:23:28 +08:00
Mahavir Jain 652f43d9ee esp_netif: initialize TCP ISN hook if enabled in configuration 2020-11-02 16:01:58 +05:30
Mahavir Jain 516ca4698f lwip: provide configuration option to enable TCP ISN hook 2020-11-02 16:01:53 +05:30
Mahavir Jain 59112bbd76 tcp_isn: use ROM APIs for md5 calculations 2020-11-02 14:32:58 +05:30
Mahavir Jain a4ad6f7547 lwip: add custom TCP ISN hook implementation
Source:
https://git.savannah.nongnu.org/cgit/lwip/lwip-contrib.git/
2020-10-30 16:42:08 +05:30
Angus Gratton 71af965514 Merge branch 'bugfix/err_to_name_paths_windows_v3.3' into 'release/v3.3'
tools: fix path handling errors in gen_esp_err_to_name.py for Windows (v3.3)

See merge request espressif/esp-idf!10898
2020-10-30 15:12:42 +08:00
Angus Gratton 1960d3c700 Merge branch 'bugfix/ldgen_section_windows_line_ending_v3.3' into 'release/v3.3'
tools/ldgen: Fix parsing of section names on Windows (v3.3)

See merge request espressif/esp-idf!11037
2020-10-30 15:12:05 +08:00
Roland Dobai 3280f45259 tools/ldgen: Fix parsing of sections names on Windows 2020-10-29 08:34:57 +01:00
He Yin Ling 66d3783c89 Merge branch 'bugfix/relative_import_error' into 'release/v3.3'
bugfix: import error in example tests

See merge request espressif/esp-idf!11003
2020-10-29 10:42:51 +08:00
Jiang Jiang Jian ec4124676f Merge branch 'bugfix/bredr_bugfix_release_for_qa_dummy_disconnect_3_3' into 'release/v3.3'
Bugfix/bredr bugfix release for qa dummy disconnect 3.3

See merge request espressif/esp-idf!10649
2020-10-28 21:26:29 +08:00
Jiang Jiang Jian 3616ae4da4 Merge branch 'bugfix/add_clear_bond_complete_evt_3_3' into 'release/v3.3'
componenet_bt/bugfix: add remove bond device complete event 3.3

See merge request espressif/esp-idf!10658
2020-10-28 16:58:49 +08:00
Chen Yu Dong 312f100551 bugfix: import error in example tests
relative import error in lib_ble_client
import Queue error in blehr_test
import http server error in ota tests
2020-10-28 14:19:30 +08:00
Jiang Jiang Jian 39f26cce95 Merge branch 'bugfix/fix_dhcp_renew_fail_for_3.3' into 'release/v3.3'
lw-ip: Fix dhcp renew fail in t1 and will renew ip in t2 every 1s

See merge request espressif/esp-idf!10986
2020-10-28 11:21:46 +08:00
Jiang Jiang Jian 4e71047a2a Merge branch 'bugfix/fix_bredr_read_rssi_delta_v3.3' into 'release/v3.3'
Bugfix/Fix Read Rssi Delta Bug in Bredr [backport v3.3]

See merge request espressif/esp-idf!10810
2020-10-26 21:44:39 +08:00
Jiang Jiang Jian e5cf7bc370 Merge branch 'bugfix/fix_tsf_bug_v3.3' into 'release/v3.3'
WiFi: fix tsf bug (backport v3.3)

See merge request espressif/esp-idf!10951
2020-10-26 21:32:56 +08:00
zhangyanjiao 91fca12f6a esp_wifi: Fixed the bug for timestamp check, didn't disconnect AP when AP's timestamp decrease abnormally 2020-10-26 11:16:34 +00:00
xueyunfei 668347e9c1 fix(dhcp): Fix dhcp renew fail in t1 and will renew ip in t2 every 1s util renew successful.(backport 3.3) 2020-10-26 16:35:32 +08:00
Angus Gratton c1b49c419d Merge branch 'bugfix/ldgen_unicode_path_v3.3' into 'release/v3.3'
tools/ldgen: Parse paths with Unicode characters in archives (v3.3)

See merge request espressif/esp-idf!10967
2020-10-26 12:08:28 +08:00
Jiang Jiang Jian cd06c14265 Merge branch 'bugfix/fix_get_bond_device_list_v3.3' into 'release/v3.3'
bugfix/fix esp_bt_gap_get_bond_device_list bug [backport v3.3]

See merge request espressif/esp-idf!9669
2020-10-26 11:47:08 +08:00
Jiang Jiang Jian 410d59d53d Merge branch 'feature/esp_spp_stop_srv_v3.3' into 'release/v3.3'
bugfix/Add API esp_spp_stop_srv and fix collection of SPP [backport v3.3]

See merge request espressif/esp-idf!10010
2020-10-26 11:46:56 +08:00
Jiang Jiang Jian 77486506e3 Merge branch 'bugfix/fix_hci_max_page_num_v3.3' into 'release/v3.3'
bugfix/Support for more Bluetooth HID devices [backport v3.3]

See merge request espressif/esp-idf!9663
2020-10-26 11:46:11 +08:00
Michael (XIAO Xufeng) adaed2c79d Merge branch 'spi_dma_close_before_cpu_reset_v3.3' into 'release/v3.3'
spi: fix issue with closing DMA before CPU reset (3.3)

See merge request espressif/esp-idf!10865
2020-10-25 23:51:21 +08:00
He Yin Ling 4a9f946278 Merge branch 'feature/move_auto_test_script_to_new_repo_3.3' into 'release/v3.3'
ci: move auto_test_script to new repo (backport 3.3)

See merge request espressif/esp-idf!10881
2020-10-24 09:26:11 +08:00
Chen Yu Dong 632530ef3c test: move auto test script to new repo (backport)
known issues +
2020-10-24 09:26:08 +08:00
Roland Dobai ef43198018 tools/ldgen: Parse paths with Unicode characters in archives
Closes https://github.com/espressif/esp-idf/issues/5996
2020-10-23 13:46:19 +02:00
Jiang Jiang Jian 4a3e7bc40d Merge branch 'bugfix/udpv6_fail_to_receive_data_for_the_first_time' into 'release/v3.3'
lw-ip:udpv6 failed to receive data for the first time

See merge request espressif/esp-idf!10942
2020-10-23 15:25:55 +08:00
boblane c5b23a85b8 Some Bluetooth devices - such as an Xbox One S controller (model 1708) - report more than two external features pages and are rejected immediately. Pages 1 and 2 are marked as unhandled in btm_devctl.c anyway, so there is no reason to block devices with more pages.
(IDFGH-3515)
Signed-off-by: liqigan <liqigan@espressif.com>

Merges https://github.com/espressif/esp-idf/pull/5481
Closes https://github.com/espressif/esp-idf/issues/5470
2020-10-23 06:14:24 +00:00
liqigan 35b2eeaa65 add API esp_spp_stop_srv(), fix the error parameter in esp-idf/examples/bluetooth/bluedroid/classic_bt/bt_spp_initiator/main/example_spp_initiator_demo.c and fix collection of SPP
Closes https://github.com/espressif/esp-idf/issues/5409
Closes https://github.com/espressif/esp-idf/pull/5408

See merge request !9114
2020-10-22 08:33:39 +00:00
boblane fc6f480e89 fix esp_bt_gap_get_bond_device_list bug
Closes https://github.com/espressif/esp-idf/issues/5395
2020-10-22 06:32:16 +00:00
Angus Gratton 394d0ecb65 Merge branch 'bugfix/embed_file_symbol_names_v3.3' into 'release/v3.3'
cmake: fix C identifier generation from embedded file (v3.3)

See merge request espressif/esp-idf!10667
2020-10-22 12:16:49 +08:00
xueyunfei 2e3dfd23e7 udpv6 failed to receive data for the first time 2020-10-22 11:40:04 +08:00
Mahavir Jain 83809a37a7 Merge branch 'bugfix/esp_idf_version_v3.3' into 'release/v3.3'
Add __ASSEMBLER__ flag in esp_idf_version.h to fix build failure with assembly files (v3.3)

See merge request espressif/esp-idf!10902
2020-10-21 20:07:54 +08:00
liqigan d61459e692 modify read rssi related function names
Closes https://github.com/espressif/esp-idf/issues/5660
2020-10-20 12:31:50 +00:00
Jiang Jiang Jian 5543b6a85b Merge branch 'bugfix/fix_some_wifi_bugs_0924_v3.3' into 'release/v3.3'
fix some wifi bugs 0924 (v3.3)

See merge request espressif/esp-idf!10615
2020-10-20 20:29:50 +08:00
Island d25b00bd5e Merge branch 'bugfix/ble_mesh_autorsp_description_v3.3' into 'release/v3.3'
esp_ble_mesh: api: fixed comment about autoresp (v3.3)

See merge request espressif/esp-idf!10891
2020-10-19 16:34:26 +08:00
Shubham Kulkarni 5a287c3a31 esp_idf_version.h: Add __ASSEMBLER__ flag to fix build failure with assembly files 2020-10-19 13:23:20 +05:30
Marius Vikhammer a1c57aa022 tools: fix path handling errors in gen_esp_err_to_name.py for Windows
Exclude paths that were specified with slash as a path separator were compared
as strings. This would fail on Windows which uses backslash as a path separator.
2020-10-19 14:44:33 +08:00
andreachiara b097435596 esp_ble_mesh: api: fixed comment about autoresp 2020-10-19 11:32:52 +08:00
Armando 2a0dc304c0 spi: fix issue with closing DMA before CPU reset 2020-10-16 14:13:32 +08:00
Renz Bagaporo b94c309fd9 cmake: fix C identifier generation from embedded file 2020-10-15 21:29:24 +08:00
Island 3901f38de6 Merge branch 'optimize/ble_mesh_make_buf_config_invisible_v3.3' into 'release/v3.3'
ble_mesh: stack: Make mesh buf debug option invisible (v3.3)

See merge request espressif/esp-idf!10797
2020-10-13 19:51:59 +08:00
Island 58c5b7a1bf Merge branch 'feat/ble_mesh_device_properties_v2_v3.3' into 'release/v3.3'
Feat/ble mesh device properties v2 (v3.3)

See merge request espressif/esp-idf!10790
2020-10-13 19:50:17 +08:00
lly 0d92639439 ble_mesh: stack: Make mesh buf debug option invisible 2020-10-13 09:31:47 +00:00
lly 23a21f92be ble_mesh: stack: Add mesh device properties v2 definitions
Also fixes wrong characteristic value length of some device
properties.
2020-10-13 09:30:16 +00:00
lly aa329b08ce ble_mesh: stack: Move device property to model common part 2020-10-13 09:30:16 +00:00
Island 7d8d841659 Merge branch 'bugfix/ble_mesh_proxy_cfg_replay_v3.3' into 'release/v3.3'
Bugfix/ble mesh proxy cfg replay (v3.3)

See merge request espressif/esp-idf!10821
2020-10-13 17:24:11 +08:00
zhangyanjiao a5b5467dca esp_wifi:
1. Optimize some debug logs for probe response
2. Optimize phy and soc files
3. Fix the bug that no event for connect
4. Fix the bug that set_channel doesn't work for softAP
5. Drop receiving packets from myself
2020-10-13 17:22:47 +08:00
lly 18cc96d188 ble_mesh: stack: Store kr phase after value changed [Zephyr] 2020-10-13 14:32:51 +08:00
lly 3e61d519c1 ble_mesh: stack: Fix rpl not check by proxy cfg [Zephyr] 2020-10-13 14:32:36 +08:00
David Čermák ad0b1ac8d7 Merge branch 'feature/mqtt_sub_update_01594bf1_v3.3' into 'release/v3.3'
MQTT: Update submodule reference (Backport v3.3)

See merge request espressif/esp-idf!10234
2020-10-13 14:13:52 +08:00
David Čermák 651dc8788f Merge branch 'bugfix/ws_stop_deadlock_v3.3' into 'release/v3.3'
Websocket client: avoid deadlock if stop called from event handler (Backport v3.3)

See merge request espressif/esp-idf!10229
2020-10-13 14:12:52 +08:00
David Čermák 31d272e460 Merge branch 'bugfix/openss_strict_verify_mode_3.3' into 'release/v3.3'
openssl: made verification mode conversion to mbetls modes more strict (v3.3)

See merge request espressif/esp-idf!10502
2020-10-13 14:10:54 +08:00
Island b4338b61a2 Merge branch 'bugfix/ble_mesh_node_deinit_v3.3' into 'release/v3.3'
ble_mesh: stack: Persistent storage misc fixes (v3.3)

See merge request espressif/esp-idf!10815
2020-10-13 14:06:23 +08:00
Jiang Jiang Jian 5d1da96e3e Merge branch 'bugfix/ipv6_address_get_fail_after_wifi_disconnect_for_3.3' into 'release/v3.3'
lw-ip:ipv6 address get fail after wifi disconnect for 3.3(backport 3.3)

See merge request espressif/esp-idf!10792
2020-10-13 12:28:46 +08:00
lly 542b6bdbc1 ble_mesh: stack: Persistent storage misc fixes
* Fix the issue that deinit node with "erase_flash"
  set to true, but info is not erased from nvs
* Reuse bt_mesh_cfg_reset() when deinit node
* Optimize Provisioner related erase operations
* No store pending timeout will be used when Node
  is not provisioned OR Provisioner is disabled
  and erase operation is performed
* Change the default timeout for settings operation
  to 0, and rpl store rate to 0
2020-10-13 10:55:58 +08:00
Island 733aaa4af0 Merge branch 'bugfix/ble_mesh_settings_fix_v3.3' into 'release/v3.3'
Bugfix/ble mesh settings fix (v3.3)

See merge request espressif/esp-idf!10786
2020-10-13 10:50:07 +08:00
Marius Vikhammer 0b42900063 Websocket client: avoid deadlock if stop called from event handler 2020-10-12 10:15:55 +00:00
Marius Vikhammer 22ce545187 MQTT: Update submodule reference
SSL: add config option for skipping common name check
esp-mqtt commit: 5e8950e681)
Closes https://github.com/espressif/esp-mqtt/issues/158

Websocket: Allow the query part of the uri to be a part of the path
esp-mqtt commit: 40b06deb10)
Closes https://github.com/espressif/esp-mqtt/issues/161

Config: Add check for consistency between config settings
esp-mqtt commit: 8a412c147d)

Add IDF version check for secure element feature
esp-mqtt commit: db4bce01ab)

Fix esp_mqtt_client_stop deadlock
esp-mqtt commit: 5e17dcaeb2)
Closes https://github.com/espressif/esp-mqtt/issues/163

Add dispatch error event for read errors
esp-mqtt commit: d4aaec08ff
Closes https://github.com/espressif/esp-idf/issues/5704

Cleanup expired messages when offline
esp-mqtt commit: bdadd77c6e
Closes https://github.com/espressif/esp-idf/issues/5668

esp_mqtt_client_publish now returns msg id for QoS > 0 when offline
esp-mqtt commit: f7325bfa10
2020-10-12 10:15:19 +00:00
David Cermak 4a1016411b openssl: made verification mode conversion to mbetls modes more strict 2020-10-12 10:14:21 +00:00
xueyunfei a9f6748de9 lw-ip:ipv6 address get fail after wifi disconnect for 3.3 2020-10-12 10:58:50 +08:00
lly b4c3c87c75 ble_mesh: stack: Use settings_core_erase when deinit 2020-10-12 10:02:05 +08:00
lly 3940ab80a3 ble_mesh: stack: Fix storing next net_idx and app_idx 2020-10-12 10:02:05 +08:00
lly d7c2d66d55 ble_mesh: stack: Continue restore even if failure happens
Previously we have used this solution for node info
restore. Here use the same solution for other mesh
information restore.
2020-10-12 10:02:05 +08:00
lly 4fc62b7983 ble_mesh: stack: Split model settings store and clear 2020-10-12 10:02:05 +08:00
lly de15e502a7 ble_mesh: stack: Erase netkey and appkey with key index 2020-10-12 10:02:05 +08:00
lly d51431fff5 ble_mesh: stack: Add clear hb_pub in settings 2020-10-12 10:02:05 +08:00
lly d4651bbb30 ble_mesh: stack: Transport rx reset settings update
When reset the rx info of transport layer, the
rpl list will always cleared, and rpl stored
in the nvs will only be erased when erase flag
is true and BLE_MESH_SETTINGS is enabled.
Compared with the previous solution, it should
be more clear.
2020-10-12 10:02:05 +08:00
lly e202225bd1 ble_mesh: stack: Use erase settings functions 2020-10-12 10:02:05 +08:00
lly 1a3515ab76 ble_mesh: stack: Use mutex for settings operation
Also expose the settings functions with the parameter
bt_mesh_nvs_handle_t, which will be used for further
updates.
2020-10-12 10:02:05 +08:00
lly a662d14a4e ble_mesh: stack: Add role check before enabling device 2020-10-12 10:02:05 +08:00
lly 4dcbe2bd7a ble_mesh: stack: Define a type for mesh nvs handle 2020-10-12 10:01:47 +08:00
lly 22d01ba674 ble_mesh: ci: Enable settings in sdkconfig.ci.xxx 2020-10-12 08:49:52 +08:00
Jiang Jiang Jian 4782dde73a Merge branch 'bugfix/fix_ble_hci_desync_deadlock_v3.3' into 'release/v3.3'
components/bt: Fix for HCI desync deadlock issue in BLE controller.

See merge request espressif/esp-idf!10625
2020-10-09 19:52:42 +08:00
Jiang Jiang Jian 151e4e156f Merge branch 'bugfix/nimble_host_rcv_pkt_length_check_v3.3' into 'release/v3.3'
NimBLE: host_rcv_pkt event buf size check. (v3.3)

See merge request espressif/esp-idf!10761
2020-10-09 15:19:47 +08:00
Chinmay Chhajed 1aa40de934 NimBLE: host_rcv_pkt event buf size check.
Check if the size of HCI event buffer is greater than the received HCI
packet. If not then abort with the error message.
2020-10-09 09:32:37 +05:30
Angus Gratton 471d79edae Merge branch 'bugfix/ci_auto_checkout_revision_of_project_used_in_ci_v3.3' into 'release/v3.3'
CI: get git describe from annotated tags (v3.3)

See merge request espressif/esp-idf!10676
2020-10-08 16:44:49 +08:00
Mahavir Jain 1ffeff5948 Merge branch 'bugfix/bootloader_anti_rollback_mmap_v3.3' into 'release/v3.3'
bootloader_support: fix issue in memory mapping for getting app descriptor (v3.3)

See merge request espressif/esp-idf!10737
2020-10-08 16:31:35 +08:00
Angus Gratton 0f6b7ad3cf Merge branch 'bugfix/bootloader_common_get_sha256_of_partition_v3.3' into 'release/v3.3'
bootloader_support: Fix bootloader_common_get_sha256_of_partition(), can handle a long image (v3.3)

See merge request espressif/esp-idf!9955
2020-10-08 13:11:46 +08:00
Angus Gratton 111e0361c9 ci: Check version tags are always annotated
Closes https://github.com/espressif/esp-idf/issues/3114
2020-10-07 13:53:45 +11:00
Angus Gratton 6c2bffe53c build system: Also get IDF version from annotated tags only
Builds on previous commit.

Note: Getting the project version still pases --tags so still works with plain
tags, to keep compatibility for existing projects
2020-10-07 13:53:45 +11:00
Mahavir Jain 0167a5e96d bootloader_support: fix issue in memory mapping for getting app descriptor
For getting secure_version field in anti rollback case, bootloader tries
to map whole firmware partition but fails for cases where partition size
is beyond available MMU free pages capacity.

Fix here ensures to map only required length upto application descriptor
size in firmware partition.

Closes https://github.com/espressif/esp-idf/issues/5911
2020-10-06 14:43:12 +05:30
Michael (XIAO Xufeng) 021e1189c5 Merge branch 'bugfix/mcpwm_fault_init_copypaste_typo_bp3.3' into 'release/v3.3'
MCPWM: Fix PWM-fault init function that read config incorrectly (backport v3.3)

See merge request espressif/esp-idf!9550
2020-10-02 14:20:12 +08:00
He Yin Ling 936c803ccb CI: get git describe from annotated tags:
we should only parse IDF version from annotated tags
2020-09-30 11:34:28 +08:00
Chinmay Chhajed 02893a2038 components/bt: Fix for HCI desync deadlock issue in BLE controller. 2020-09-29 21:35:15 +05:30
Jiang Jiang Jian cd86bc9d8d Merge branch 'bugfix/confirmed_bugfix_from_baidu_proj_3.3' into 'release/v3.3'
Confirmed bugfix from Baidu Project 3.3

See merge request espressif/esp-idf!10548
2020-09-29 20:48:50 +08:00
Jiang Jiang Jian 9401c59f89 Merge branch 'bugfix/customer_baidu_int_wdt_v3.3' into 'release/v3.3'
backport v3.3: add soft solution for esp32 eco3 live lock issue

See merge request espressif/esp-idf!9217
2020-09-29 14:04:00 +08:00
baohongde 67edd0c10e components/bt: Replace task post with btc_inter_profile_call, when post message from btc_dm to btc_gap 2020-09-28 19:36:23 +08:00
baohongde abf6cecde1 components/bt: Fix clear bond fail when connected without ble included 2020-09-28 16:21:25 +08:00
xiongweichao 67276f5d26 add remove bond device complete event 2020-09-28 16:14:52 +08:00
xiongweichao 3c0aee8595 1.revert dummy command
2.fix send MEDIA_CTRL command in disconnect
2020-09-28 12:00:28 +08:00
xiongweichao 2233b5d25e 1.fix test case dummy
2.fix sink send media control ESP_A2D_MEDIA_CHECK_SRC_RDY
2020-09-28 11:55:46 +08:00
Jiang Jiang Jian a55f0ebbd5 Merge branch 'bugfix/wifi_spin_lock_allocation_in_PSRAM_v3.3' into 'release/v3.3'
wifi: Fix spin lock allocation in PSRAM bug(v3.3)

See merge request espressif/esp-idf!10550
2020-09-27 12:49:32 +08:00
Jiang Jiang Jian e49a6b95ed Merge branch 'bugfix/fix_ipv6_nd6_max_queue_num_v3.3' into 'release/v3.3'
lw-ip: fix IPv6 ND6 queue too much pkts cause no mem issue(backport v3.3)

See merge request espressif/esp-idf!10177
2020-09-27 12:47:30 +08:00
Jiang Jiang Jian 4a037fa911 Merge branch 'bugfix/can_mmap_after_get_enough_free_mmu_pages_v3.3' into 'release/v3.3'
flash_mmap: can mmap after get enough free MMU pages (backport v3.3)

See merge request espressif/esp-idf!10587
2020-09-27 12:46:42 +08:00
Island 0b792c44eb Merge branch 'optimize/ble_mesh_provisioner_delete_dev_v3.3' into 'release/v3.3'
ble_mesh: stack: Optimize Provisioner delete device function (v3.3)

See merge request espressif/esp-idf!10606
2020-09-27 10:53:19 +08:00
lly 81354cf24f ble_mesh: stack: Optimize Provisioner delete device function
Since we have provided separate functions for deleting node
information with node's unicast address, device uuid, etc.
So we update the behavior of this function, which will only
be used to delete device information which is not provisioned
or just under provisioning.
2020-09-25 14:04:58 +08:00
Angus Gratton fcadbaf97c Merge branch 'update/release_v3.3.4' into 'release/v3.3'
v3.3: Update to v3.3.4

See merge request espressif/esp-idf!10520
2020-09-25 10:21:30 +08:00
ChenJianxing 186ad2f6aa lwip: fix IPv6 ND6 queue too much pkts cause no mem issue and add menuconfig item for this params. 2020-09-24 10:43:23 +08:00
jiangguangming 4f3ddbb299 flash_mmap: restore interrupt and cache before err return 2020-09-24 10:06:18 +08:00
jiangguangming 9debc7248a flash_mmap: can mmap after get enough free MMU pages 2020-09-24 10:06:18 +08:00
Jiang Jiang Jian fb18b12efe Merge branch 'bugfix/bt_linkup_fallback_event_v3.3' into 'release/v3.3'
Bluedroid: Fixes cases having fallback to link up event. (v3.3)

See merge request espressif/esp-idf!9805
2020-09-22 16:44:07 +08:00
Jiang Jiang Jian 251676181a Merge branch 'bugfix/backport_some_lwip_bugs_0910_v3.3' into 'release/v3.3'
lw-ip:backport bugfix lw-ip for v3.3

See merge request espressif/esp-idf!10409
2020-09-22 14:18:30 +08:00
dongyou e12593a79f Fix spin lock allocation in PSRAM bug 2020-09-22 14:11:25 +08:00
weitianhua 7f9a4d25ef Confirmed bugfix from Baidu Project 2020-09-22 11:57:00 +08:00
Michael (XIAO Xufeng) 4afc8facde Merge branch 'fixbug/sdmmc_spi_highspeed_v3.3' into 'release/v3.3'
sdmmc: fix the probe issue that forbid sdspi working in highspeed mode(backport v3.3)

See merge request espressif/esp-idf!9838
2020-09-21 11:10:09 +08:00
Angus Gratton c73a00e073 Merge branch 'bugfix/espcoredump_fix_error_reported_for_blank_partition_v33' into 'release/v3.3'
Bugfix/espcoredump fix error reported for blank partition (backport v3.3)

See merge request espressif/esp-idf!9625
2020-09-21 10:45:05 +08:00
Michael (XIAO Xufeng) f2f13eb8e8 Merge branch 'bugfix/spi_master_multiple_dev_with_diff_cs_lvl_3.3' into 'release/v3.3'
spi_master: correctly set cs polarity (3.3)

See merge request espressif/esp-idf!10406
2020-09-21 10:21:22 +08:00
aleks c9f4b0aba8 espcoredump: fix error reported for blank partition 2020-09-21 01:29:24 +00:00
Ivan Grokhotkov 6e284ea84b Merge branch 'bugfix/parttool_example_test_fail_v3.3' into 'release/v3.3'
examples/parttool: fix the test to work on parallel test runner (backport v3.3)

See merge request espressif/esp-idf!10376
2020-09-18 23:30:58 +08:00
Angus Gratton 34961db9c1 Merge branch 'release/v3.3' into update/release_v3.3.4 2020-09-18 19:44:26 +10:00
Angus Gratton b64b375234 version: Update to v3.3.4 2020-09-18 19:42:21 +10:00
xueyunfei 315cbe05cf backport bugfix lwip for v3.3 2020-09-18 02:28:13 +00:00
Island f54f776905 Merge branch 'bugfix/ble_mesh_check_stack_init_v3.3' into 'release/v3.3'
ble_mesh: stack: Check if mesh stack initialized before init vendor client (v3.3)

See merge request espressif/esp-idf!10484
2020-09-18 09:40:14 +08:00
Michael (XIAO Xufeng) c7a9851de0 Merge branch 'bugfix/fix_bugs_in_gpio_unit_test_v3.3' into 'release/v3.3'
bugfix(ut): fix gpio output and input mode test(backport v3.3)

See merge request espressif/esp-idf!10023
2020-09-18 02:17:42 +08:00
lly 1f32a8d95e ble_mesh: stack: Check if mesh stack initialized before init vendor client 2020-09-17 11:28:02 +08:00
Ivan Grokhotkov c3e8fb73c7 Merge branch 'bugfix/missing_regex_error_stub' into 'release/v3.3'
Add missing regex_error stub

See merge request espressif/esp-idf!8852
2020-09-16 04:50:54 +08:00
Ivan Grokhotkov 9dda741a99 Merge branch 'bugfix/nvs_no_throw_v3.3' into 'release/v3.3'
NVS: Changed all new to new (nothrow) (backport v3.3)

See merge request espressif/esp-idf!7858
2020-09-16 02:49:09 +08:00
Jakob Hasse a7e1c144e2 Add missing regex_error stub
Closes IDFGH-3153

* avoids linker error
2020-09-15 18:20:09 +00:00
Angus Gratton 8a79415c2e Merge branch 'bugfix/ulp_as_version_v3.3' into 'release/v3.3'
ulp: fix ULP assembler version detection for localized systems (v3.3)

See merge request espressif/esp-idf!10396
2020-09-15 15:09:30 +08:00
Angus Gratton 1d8bf5356b Merge branch 'bugfix/eclipse_make_py3_v3.3' into 'release/v3.3'
tools: Fix Python 3 incompatibility for building with Eclipse on Windows (v3.3)

See merge request espressif/esp-idf!10401
2020-09-15 15:06:54 +08:00
Angus Gratton d7ea1b0a08 Merge branch 'bugfix/ut_ext_win_open_file_v3.3' into 'release/v3.3'
Tools: Close temporary file before invoking external tools accessing it (v3.3)

See merge request espressif/esp-idf!9858
2020-09-15 14:27:34 +08:00
Ivan Grokhotkov 65d829826e Merge branch 'feature/ci_fix_docker_build_v3.3' into 'release/v3.3'
ci: Use git mirror for docker image (v3.3)

See merge request espressif/esp-idf!10448
2020-09-15 01:47:56 +08:00
Wielebny666 bca1beb3f0 spi_master: correctly set cs polarity
All devices must be added to the same spi line before use.
2020-09-14 11:58:10 +00:00
Sergei Silnov 4f11ecebbc ci: Use git mirror for docker image 2020-09-14 13:11:44 +02:00
Island 64adabfd3a Merge branch 'bugfix/ble_mesh_prov_iv_index_v3.3' into 'release/v3.3'
ble_mesh: stack: Using the latest iv_index for provisioning (v3.3)

See merge request espressif/esp-idf!10419
2020-09-14 14:17:53 +08:00
Michael (XIAO Xufeng) cbcb218418 Merge branch 'bugfix/fix_i2s_reset_issue_v3.3' into 'release/v3.3'
driver(I2S): Fix I2S reset issue for release/v3.3

See merge request espressif/esp-idf!9586
2020-09-14 10:45:50 +08:00
Jiang Jiang Jian cec88e11ed Merge branch 'component/seperate_bta_jv_l2c_3.3' into 'release/v3.3'
Component/seperate bta jv l2c 3.3

See merge request espressif/esp-idf!9651
2020-09-11 19:38:36 +08:00
lly 34f30a878e ble_mesh: stack: Using the latest iv_index for provisioning
Provisioner should always uses the latest IV Index for provisioning.
For example, if the current IV Index is 0x00000001, but prov->iv_index
is still initialized with 0x00000000, and if Provisioner uses prov->
iv_index for provisioning, this will cause the Provisioner failing to
control the node.
So here bt_mesh.iv_index is used instead of prov->iv_index.
2020-09-11 07:58:20 +00:00
Jiang Jiang Jian 908938bc3c Merge branch 'bugfix/fix_some_wifi_bugs_0907_v3.3' into 'release/v3.3'
bugfix: fix some wifi bugs (backport v3.3)

See merge request espressif/esp-idf!10318
2020-09-10 22:33:18 +08:00
Roland Dobai 518e1da637 tools: Fix Python 3 incompatibility for building with Eclipse on Windows 2020-09-10 09:47:29 +02:00
Roland Dobai cccdd13937 ulp: fix ULP assembler version detection for localized systems 2020-09-10 09:36:22 +02:00
Island 6c5fc42114 Merge branch 'feat/ble_mesh_use_model_c_v3.3' into 'release/v3.3'
ble_mesh: stack: Use model callback for operations [Zephyr] (v3.3)

See merge request espressif/esp-idf!10365
2020-09-10 10:40:19 +08:00
Island 7514850962 Merge branch 'bugfix/ble_mesh_remove_assert_v3.3' into 'release/v3.3'
ble_mesh: stack: Avoid using assert in mesh stack (v3.3)

See merge request espressif/esp-idf!10361
2020-09-10 10:39:21 +08:00
Island fa24dd7f6d Merge branch 'bugfix/ble_mesh_nimble_ccc_handle_v3.3' into 'release/v3.3'
ble_mesh: nimble: Fix updating ccc handle with wrong value (v3.3)

See merge request espressif/esp-idf!10357
2020-09-10 10:38:31 +08:00
Ivan Grokhotkov e1fd76a11f examples/parttool: fix the test to work on parallel test runner
Pass the DUT port to parttool_example.py as an argument.
2020-09-09 18:40:53 +02:00
lly 9b70ddbb77 ble_mesh: stack: Use model callback for operations [Zephyr]
- Previously when a model is initialized or deinitialized, in the
  access layer, we need to check the model id with the ids in the
  table in order to find the proper model operation function.
- Currently all the operation functions of each model will be set
  during the mesh initialization. When the model is found, we can
  directly use the corresponding callback for different operations.
- Currently only init/deinit operations are registered, later we
  will add more operations.
2020-09-09 14:01:17 +08:00
lly 1090c12acd ble_mesh: stack: Avoid using assert in mesh stack 2020-09-09 10:58:18 +08:00
lly d79e95e6e0 ble_mesh: nimble: Fix updating ccc handle with wrong value 2020-09-09 10:50:40 +08:00
Michael (XIAO Xufeng) a3ef2bbe33 Merge branch 'feature/vfs_uart_set_line_ending_v3.3' into 'release/v3.3'
feature: support vfs uart set line endings with specified uart number release/v3.3

See merge request espressif/esp-idf!9595
2020-09-09 10:36:59 +08:00
ronghulin a571bc0d0a bugfix: fix some wifi bugs
1. add sta connect again ap sent disconnect event
2. add set/get inactive time api
3. fix connect hidden AP doesn't update information
4. add rf test long short support
2020-09-08 14:18:00 +08:00
He Yin Ling 3b79b6b5da Merge branch 'bugfix/remove_auto_conn_case_v3.3' into 'release/v3.3'
test: remove auto conn case because we do not support this anymore (v3.3)

See merge request espressif/esp-idf!9943
2020-09-07 20:45:52 +08:00
Michael (XIAO Xufeng) 7e6572a34d Merge branch 'bugfix/spi_flash_yield_coredump_v3.3' into 'release/v3.3'
spi_flash: don't call vTaskDelay in non-os context (backport v3.3)

See merge request espressif/esp-idf!10300
2020-09-07 13:26:56 +08:00
Ivan Grokhotkov 93ad53c09d spi_flash: don't call vTaskDelay in non-os context
Fixes regression in core dump, when a crash happens in interrupt
context.
2020-09-04 21:30:01 +02:00
Krzysztof Budzynski 10d40d1448 Merge branch 'bugfix/macos_toolchain_url_v3.3' into 'release/v3.3'
docs: Fix toolchain URL generation for macos (v3.3)

See merge request espressif/esp-idf!10028
2020-09-04 23:08:01 +08:00
Krzysztof Budzynski 0af1da4416 Merge branch 'doc/broken_readme_links_v3.3' into 'release/v3.3'
Docs: Fix broken README links (v3.3)

See merge request espressif/esp-idf!9504
2020-09-04 23:05:57 +08:00
Island 77e3b100eb Merge branch 'bugfix/ble_mesh_sensor_example_fix_v3.3' into 'release/v3.3'
ble_mesh: example: Fix sensor data wrong iteration (v3.3)

See merge request espressif/esp-idf!10276
2020-09-04 16:55:14 +08:00
lly 073542063c ble_mesh: example: Fix sensor data wrong iteration 2020-09-04 11:57:08 +08:00
Mahavir Jain b5ac1871de Merge branch 'feature/upgrade_mbedtls_to_v3.3' into 'release/v3.3'
mbedtls: update to mbedtls release v2.16.7 (v3.3)

See merge request espressif/esp-idf!9909
2020-09-03 18:59:16 +08:00
Mahavir Jain 2ad0565e3a mbedtls: update to mbedtls release v2.16.7
For detailed release notes, please refer to:
https://github.com/ARMmbed/mbedtls/releases/tag/mbedtls-2.16.7
2020-09-03 05:10:30 +00:00
Michael (XIAO Xufeng) ad75a51f43 Merge branch 'ci/test_spi_speed_psram_enabled_3.3' into 'release/v3.3'
driver test: disable the spi master performance test when psram is used (v3.3)

See merge request espressif/esp-idf!9639
2020-09-02 08:53:04 +08:00
Michael (XIAO Xufeng) 6552aef2e7 driver test: disable the spi master performance test when psram is used 2020-09-01 16:41:59 +00:00
Island 468c30843c Merge branch 'bugfix/ble_mesh_example_compile_warn_v3.3' into 'release/v3.3'
Bugfix/ble mesh example compile warn (v3.3)

See merge request espressif/esp-idf!10225
2020-09-01 19:16:23 +08:00
lly f8bf6b1f91 ble_mesh: example: Remove some useless included header files 2020-09-01 14:14:13 +08:00
Carlos Sobrinho 5725cb9342 Fix compilation warnings about portmacro being already define. 2020-09-01 14:13:42 +08:00
Jiang Jiang Jian b2b47b4465 Merge branch 'bugfix/fix_some_wifi_bugs_0703_v3.3' into 'release/v3.3'
fix some wifi bugs 0703 (v3.3)

See merge request espressif/esp-idf!9537
2020-09-01 11:34:29 +08:00
Jiang Jiang Jian ad2a05a391 Merge branch 'doc/add_UUID_description_in_gattc_demo_backport_v3.3' into 'release/v3.3'
docs:add 128-bit UUID description backport v3.3

See merge request espressif/esp-idf!9226
2020-09-01 11:01:06 +08:00
Jiang Jiang Jian fee489e770 Merge branch 'bugfix/fix_build_err_in_cpp_backport_v3.3' into 'release/v3.3'
ble_hid_device_demo: fix build if building with c++ backport v3.3

See merge request espressif/esp-idf!9234
2020-09-01 11:00:21 +08:00
Island 173c76cb04 Merge branch 'bugfix/ble_mesh_client_msg_optimize_v3.3' into 'release/v3.3'
Bugfix/ble mesh client msg optimize (v3.3)

See merge request espressif/esp-idf!10207
2020-09-01 09:33:39 +08:00
Jiang Jiang Jian c30a264d21 Merge branch 'bugfix/put_periph_module_enable/diable_into_iram_v3.3' into 'release/v3.3'
wifi, bt: move esp_phy_common_clock_disable into periph_ctrl and put it into IRAM(v3.3)

See merge request espressif/esp-idf!10109
2020-08-31 19:23:26 +08:00
lly 31060cf42b ble_mesh: stack: Client model related code clean 2020-08-31 13:18:53 +08:00
lly 8a19d03a1c ble_mesh: stack: Rename cfg & health client status recv func 2020-08-31 13:18:48 +08:00
lly d5e9fc092c ble_mesh: stack: Check client msg result in common func 2020-08-31 13:18:42 +08:00
lly 8ae06fde5f ble_mesh: stack: Fix no events for some error conditions 2020-08-31 13:18:37 +08:00
lly 90e2bbe330 ble_mesh: stack: Move client role set to the msg function 2020-08-31 13:18:31 +08:00
lly 9aa33c344a ble_mesh: stack: Remove some not used client parameters 2020-08-31 13:18:25 +08:00
lly 7cb6b85ec9 ble_mesh: stack: Remove some not used variables & functions 2020-08-31 13:18:18 +08:00
lly f11e347e2e ble_mesh: stack: Update client model msg send 2020-08-31 13:18:11 +08:00
Mahavir Jain ba47806b8d Merge branch 'bugfix/http_client_read_v3.3' into 'release/v3.3'
Fix error handling in esp_http_client_read and esp_https_ota_perform (v3.3)

See merge request espressif/esp-idf!9205
2020-08-31 13:04:10 +08:00
Mahavir Jain cfcc189a89 Merge branch 'bugfix/softap_prov_session_v3.3' into 'release/v3.3'
protocomm_httpd: Restart security session if request is received on a new session (v3.3)

See merge request espressif/esp-idf!9118
2020-08-31 13:01:12 +08:00
Island 41debcfbd2 Merge branch 'bugfix/ble_mesh_health_current_status_recv_v3.3' into 'release/v3.3'
ble_mesh: stack: Fix recv health current status incorrectly (v3.3)

See merge request espressif/esp-idf!10196
2020-08-31 11:15:13 +08:00
lly 726c74ff39 ble_mesh: stack: Fix recv health current status incorrectly 2020-08-28 17:40:59 +08:00
Island 6a2652c685 Merge branch 'bugfix/ble_mesh_misc_updates_v3.3' into 'release/v3.3'
Bugfix/ble mesh misc updates (v3.3)

See merge request espressif/esp-idf!10187
2020-08-28 17:32:10 +08:00
lly c7cb56b507 ble_mesh: ci: Enable friend & low power in build check 2020-08-28 10:51:30 +08:00
lly ff1132d2e4 ble_mesh: stack: Only keep func pointer for very common log
Currently only keep func pointer for the followings:
- Invalid parameter (mesh btc & mesh stack)
- Out of memory (mesh btc & mesh stack)
- Unknown act (mesh btc)
- Invalid model user data (mesh stack)
- BT_DBG("%s", __func__) (mesh btc & mesh stack)
- A few other specific situations (buf ref debug, send status check)
2020-08-28 10:51:17 +08:00
lly 6ea6de8d42 ble_mesh: stack: Make proxy server & client functions clear 2020-08-28 10:51:02 +08:00
Island 7e26c8ddda Merge branch 'bugfix/ble_mesh_add_misc_check_v3.3' into 'release/v3.3'
Bugfix/ble mesh add misc check (v3.3)

See merge request espressif/esp-idf!9633
2020-08-28 10:43:55 +08:00
Angus Gratton f043a3da97 Merge branch 'update/release_v3.3.3' into 'release/v3.3'
version: Update to v3.3.3

See merge request espressif/esp-idf!10180
2020-08-27 19:38:21 +08:00
lly f6cc9afaa9 ble_mesh: stack: Add proxy cfg pdu length check 2020-08-27 11:20:50 +00:00
lly 55489bb41a ble_mesh: stack: Rework using dev flag to check scan status
Different bluetooth host has different behaviors, so it's better
to maintain a scan check mechanism of BLE Mesh itself.
Fixes an issue when only PB-GATT is enabled for node, which will
output a scan error log when the device is provisioned.
2020-08-27 11:20:50 +00:00
lly 43ffec0bd7 ble_mesh: example: Add result check during mesh init 2020-08-27 11:20:50 +00:00
lly c1c4990f75 ble_mesh: stack: Add more checks about input prov bearers 2020-08-27 11:20:50 +00:00
Island 72f029abc3 Merge branch 'feat/ble_mesh_use_iram_for_mem_alloc_v3.3' into 'release/v3.3'
Feat/ble mesh use diff ram for mem alloc (v3.3)

See merge request espressif/esp-idf!9619
2020-08-27 19:19:23 +08:00
Island c902b1fa24 Merge branch 'bugfix/ble_mesh_update_send_ttl_v3.3' into 'release/v3.3'
Bugfix/ble mesh update send ttl v3.3

See merge request espressif/esp-idf!9564
2020-08-27 19:19:01 +08:00
Angus Gratton 78003e9437 docs: Fix toolchain URL generation for macos
Didn't backport the new URL scheme when we updated the toolchain version.

Have put a link on the server so in this case the "osx" toolchain URL remains
valid.

Closes https://github.com/espressif/esp-idf/issues/5720
2020-08-27 14:10:35 +10:00
lly 2a6b0d68ce ble_mesh: stack: Rename mesh adv queue and relay queue 2020-08-26 08:24:55 +00:00
lly da068a639f ble_mesh: stack: Use macros for adv task name & prio 2020-08-26 08:24:55 +00:00
lly df8b2c5f3a ble_mesh: stack: Make freertos static allocation visible 2020-08-26 08:24:55 +00:00
lly a194c415a8 ble_mesh: stack: Update option of using DRAM/SPIRAM for memory allocation 2020-08-26 08:24:55 +00:00
weitianhua 33546a0094 Fix tsk watchdog when running spp vfs demo 2020-08-26 15:33:48 +08:00
weitianhua 8fb47ab0c2 Seperate BTA_JV_L2CAP for less bin size 2020-08-26 15:33:48 +08:00
zhangyanjiao 09113e163b esp wifi bugfix:
1. Fix TX DMA buffer issue
2. API esp_wifi_get_config add acquisition sta.listen_interval
3. Configure bandwidth and phy mode to store NVS
4. If AP's tsf has been restarted, STA will disconnect from AP.
5. Do not reset softAP's tsf except it restart
6. Fix the wifi regdomain update bug
7. Fix the bug for airkiss find hidden AP fail
8. Fix addba and first ampdu send bar
9. Fix WiFi fragment issue
10. Fix WiFi fragment issue
2020-08-26 14:43:53 +08:00
zhangyanjiao 85ca89ee4a esp_wifi: Add API to get available internal heap size 2020-08-26 14:43:35 +08:00
dongyou 9825d0004f Add IRAM_ATTR wifi_bt_common_module_enable/disable()
Deleted duplicated spinlock and counter.
2020-08-24 14:00:22 +08:00
houwenxiang c7f33524b4 driver(I2S): Fix I2S reset issue for release/v3.3
`i2s_start` reseting I2S in incorrect order causeing the word-order error.
2020-08-24 01:25:39 +00:00
Chen Yi Qun c2ead692aa bugfix(ut): fix gpio output and input mode test(backport v3.3) 2020-08-20 06:25:40 +00:00
houwenxiang a293dfea7a feature: support vfs uart set line endings with specified uart number release/v3.3 2020-08-14 14:35:44 +08:00
Angus Gratton 9ff108dcd0 Merge branch 'fix/prov_ble_read_offset_v3.3' into 'release/v3.3'
BLE provisioning: Add check for valid ble read offset (v3.3)

See merge request espressif/esp-idf!9747
2020-08-13 16:29:02 +08:00
Michael (XIAO Xufeng) 0a75f2d5f8 Merge branch 'bugfix/fix_adc_dac_conflict_backportv3.3' into 'release/v3.3'
Driver(adc): Disable the synchronization operation function of ADC1 and DAC (backport v3.3)

See merge request espressif/esp-idf!9364
2020-08-13 09:51:25 +08:00
Prasad Alatkar fbdcfc8e4a BLE provisioning: Add check for valid ble read offset 2020-08-12 08:46:01 +00:00
Jiang Jiang Jian 22e3c00b48 Merge branch 'bugfix/fix_udp_tx_performance_issue_v3.3' into 'release/v3.3'
lw-ip: fix udp tx packet loss issue (backport v3.3)

See merge request espressif/esp-idf!10007
2020-08-12 16:16:47 +08:00
xiehang 7952bed766 lwip: fix udp tx packet loss issue 2020-08-12 10:38:42 +08:00
Li Shuai ab63b48f6f add soft solution for esp32 eco3 live lock issue 2020-08-12 02:16:53 +00:00
Jiang Jiang Jian 8ab3cb0b12 Merge branch 'bugfix/fix_IPv6_memory_leak_issue' into 'release/v3.3'
lw-ip: fix IPv6 memory leak issue

See merge request espressif/esp-idf!9933
2020-08-11 22:09:50 +08:00
ronghulin cb78c1083f bugfix: fix IPv6 memory leak issue 2020-08-11 14:19:06 +08:00
Jiang Jiang Jian 7e1c529b00 Merge branch 'bugfix/param_check_instant_tx_octets_adv_ubderrun_v3.3' into 'release/v3.3'
component/bt: add connect parameter, fix instant reverse, fix tx default octets, fix assert(1024,0)

See merge request espressif/esp-idf!9484
2020-08-11 14:11:03 +08:00
Jiang Jiang Jian f538307629 Merge branch 'bugfix/ipv6_fragment_for_3.3' into 'release/v3.3'
lw-ip:fix bug for ipv6 fragment(backport 3.3)

See merge request espressif/esp-idf!9655
2020-08-11 14:09:11 +08:00
xueyunfei 68ecc44d34 fix bug for ipv6 fragment 2020-08-11 09:45:02 +08:00
Jiang Jiang Jian b244afc208 Merge branch 'feature/make_tcp_rto_configurable_v3.3' into 'release/v3.3'
make TCP rto time configurable (backport v3.3)

See merge request espressif/esp-idf!9610
2020-08-10 21:17:45 +08:00
Wang Cheng bfaa14bfdd component/bt: Fix buffer count deinit crash. 2020-08-10 11:43:54 +08:00
wangcheng 12d476427f components/bt: Add api to query the number of available buffers for the current connection 2020-08-10 11:43:54 +08:00
baohongde debda4a63f Fix ble disconnect due to instant of channel map update is too small
Set AFH in time
Fix ble connecting fail in coexist
2020-08-10 11:43:54 +08:00
baohongde b76f5b2ef2 Coexistence: Add coexist API to enable BLE connection dynamic priority 2020-08-10 11:43:54 +08:00
wangcheng d674016d64 component/bt: add connect parameter, fix instant reverse, fix tx default octets, fix assert(1024,0), fix assert(512,0) 2020-08-10 11:43:17 +08:00
KonstantinKondrashov 9ce137139b bootloader: Adds bootloader_sha256_flash_contents() 2020-08-07 23:10:29 +08:00
Piyush Shah 52c089fba7 protocomm_httpd: Restart security session if request is received on a new session
This commit fixes a bug as well as changes a behaviour.

Bugfix: During softap/httpd based provisioning, if a session was closed
midway and a new one started, it would never proceed if the http server
assigns same socket number to the new session (which happens almost always).
Now, if a session is closed, using the http callbacks, the older session
data is cleared so that a new one can be created.

Behavioural change: If a client (mobile app particularly) does not use
persistent http session i.e. all provisioning communication on the same
socket, the provisioning may fail. Earlier, since the session context was
not getting cleared, even if the client closed a session and continued
on a new one, it would go through if the socket number assigned was same
(which happens almost always).

Ideally, from a security perspective, all communication related
to secure provisioning must happen on the same socket, and so, this
change is required.
2020-08-06 18:25:53 +00:00
KonstantinKondrashov 035783039b bootloader_support: Fix bootloader_common_get_sha256_of_partition, can handle a long image
Closes: IDFGH-3594
2020-08-05 23:21:52 +08:00
Hou Chen Yao 2e89f963d7 remove auto conn case because we do not support this anymore 2020-08-05 18:04:34 +08:00
He Yin Ling aa6730f0e2 Merge branch 'bugfix/checkout_ref_auto_test_script' into 'release/v3.3'
CI: IT jobs use incorrect auto test script branch

See merge request espressif/esp-idf!9867
2020-07-31 17:45:04 +08:00
Jiang Jiang Jian 593ca2255c Merge branch 'mesh/bugfix_set_type_v3.3' into 'release/v3.3'
Mesh/bugfix (backport v3.3)

See merge request espressif/esp-idf!9179
2020-07-30 21:17:11 +08:00
Chen Yudong dc5eeb8e4b ci: fix auto test script uses incorrect branch 2020-07-30 20:55:37 +08:00
Roland Dobai 62fea80a01 Tools: Close temporary file before invoking external tools accessing it 2020-07-29 20:24:30 +02:00
Jiang Jiang Jian 44791067ec Merge branch 'nimble/nrpa_support_v3.3' into 'release/v3.3'
NimBLE: Add Non-Resolvable private address support and misc fixes (Backport v3.3)

See merge request espressif/esp-idf!9735
2020-07-29 16:35:25 +08:00
Michael (XIAO Xufeng) 55bb42dc63 sdmmc: fix the probe issue that forbid sdspi working in highspeed mode
SD cards don't support CMD7 (select_card) in SPI mode. Highspeed probe
of sdspi will fail in this step and stop working in highspeed mode.
Remove the CMD7 in enable_hs_mode_and_check to fix this issue.

Please note that, on ESP32, you have to use the IOMUX pins to use sdspi
in 40MHz, otherwise the initialization process will report reading issue
and fail.
2020-07-28 19:09:38 +08:00
Wielebny666 fc8ba15b33 Fix init MCPWM Fault line via config struct
Signed-off-by: wubowen <wubowen@espressif.com>

Merges https://github.com/espressif/esp-idf/pull/5491
Closes https://github.com/espressif/esp-idf/issues/5433
2020-07-28 03:44:36 +00:00
Chinmay Chhajed 6bbb75f219 Bluedroid: Fixes cases having fallback to link up event.
Signed-off-by: Chinmay Chhajed <chinmay.chhajed@espressif.com>
2020-07-27 14:08:03 +05:30
Michael Balzer 22d636b7b0 pthread: fix pthread_mutex_destroy() breaking priority inheritance 2020-07-24 14:45:48 +02:00
Michael Balzer 95e43fc2c4 FreeRTOS: add mutex hold count to task status info 2020-07-24 14:43:32 +02:00
Angus Gratton 4f5577446b Merge branch 'bugfix/rs485_test_temp_disable_v33' into 'release/v3.3'
Bugfix/rs485 test temp disable v33 (backport v3.3)

See merge request espressif/esp-idf!9521
2020-07-24 11:14:57 +08:00
Prasad Alatkar 7aab15f33d NimBLE: Add Non-Resolvable private address support and misc bug fixes (Backport v3.3)
- Merges https://github.com/espressif/esp-nimble/pull/12
- Fixes repeated pairing failure in RPA feature

Closes https://github.com/espressif/esp-idf/issues/5530
2020-07-23 11:28:42 +05:30
aleks b64f4bced8 ci: temporarily disable RS485 related tests 2020-07-22 08:46:57 +00:00
Angus Gratton bf02206096 Merge branch 'ci/workaround_multiple_ci_failures_v3.3' into 'release/v3.3'
CI: workaround multiple ci failures (v3.3)

See merge request espressif/esp-idf!9687
2020-07-22 11:54:45 +08:00
yuanjm e5066c9969 feat(lwip): make LWIP TCP rto time configurable 2020-07-20 07:58:06 +00:00
Angus Gratton 07942e3991 Merge branch 'bugfix/cmake_bugfixes_v3.3' into 'release/v3.3'
CMake-related bugfixes (v3.3)

See merge request espressif/esp-idf!8069
2020-07-20 08:43:52 +08:00
Angus Gratton 62a187b55b Merge branch 'feature/msys2_toolchain_v3.3' into 'release/v3.3'
windows: Update the prebuilt MSYS2 environment to use new toolchain

See merge request espressif/esp-idf!9624
2020-07-20 08:23:08 +08:00
He Yin Ling 858e12a040 CI: do not run cases likely to fail 2020-07-19 15:30:15 +08:00
He Yin Ling bfb7757feb CI: disable cases with test env SSC_T5_1 2020-07-19 15:26:29 +08:00
He Yin Ling de82bd5d19 CI: temp allow mesh job to fail as runner is not stable 2020-07-19 15:24:55 +08:00
He Yin Ling 9a205c654d CI: remove incorrect MTU related cases 2020-07-19 15:23:21 +08:00
Michael Balzer 0137aef471 Merge branch 'release/v3.3' of https://github.com/espressif/esp-idf.git into release/v3.3
# Conflicts:
#	components/bt/include/esp_bt.h
2020-07-15 12:08:17 +02:00
Angus Gratton ff2fef7e91 windows: Update the prebuilt MSYS2 environment to use then new toolchain
No other changes in the environment contents.
2020-07-15 12:04:09 +10:00
Michael Balzer 7ca3bc1e48 Task WDT: add method to retrieve task names for pre-crash storage 2020-07-14 19:44:39 +02:00
chenyudong 83fdac780c mesh/ci: fix MESH_EST_0216 2020-07-10 17:57:36 +08:00
chenyudong 7c95474f6c mesh: backport some bugfixes
1. If the root is specified (FIXED-ROOT) by set type or set parent, change ie.mesh_type to MESH_ROOT before connect to router.
2. Release esp_mesh_recv_toDS when the root becomes non-root.
3. esp_mesh_set_type now supports MESH_IDLE and MESH_STA.
4. Fix ie.rc_rssi is not updated during scan and vote.
5. Fix ie.mesh_type do not match ie.layer caused by parent switch.
6. Fix during root switch, the original root doesn't disconnect from the router after it receives the switch request from the new voted root. (root switch happens by invoking esp_mesh_waive_root).
7. Fix the routing announce timer is not stopped immediately in a new root if the new root is transformed from non-root.
8. Choose the candidate with less ie.assoc when doing parent switch.
2020-07-10 17:57:34 +08:00
lly 28c0673376 ble_mesh: stack: Add two application macros for TTL 2020-07-10 09:15:56 +08:00
lly 9eb66d49e4 ble_mesh: stack: Update send_ttl in btc when recv a msg
Update send_ttl mainly for server models. When a server model
receives a message, and the status is required to be replied
by the application, we need to set send_ttl to the msg context.
If send_ttl is not updated in btc, and the applcation does not
set the TTL either, then the status will be replied with TTL=0,
which may cause the client side (e.g. the phone App) failed to
receive the status.

Closes https://github.com/espressif/esp-idf/issues/5300
2020-07-10 09:15:49 +08:00
Shubham Kulkarni b45e2699b2 Increase receive timeout in sdkconfig.ci to fix CI failures 2020-07-08 10:02:07 +05:30
Shubham Kulkarni e84ad136b9 esp_https_ota.c: Add fix to return failure if (-1) is returned from esp_http_client_read
Closes https://github.com/espressif/esp-idf/issues/4960
2020-07-08 10:00:48 +05:30
Shubham Kulkarni 22926742be esp_http_client.c: In esp_http_client_read, add fix to return (-1) if esp_transport_read fails 2020-07-08 10:00:48 +05:30
Marius Vikhammer a3ef357b8d Docs: fix broken example README links 2020-07-07 18:22:55 +08:00
fuzhibo 44887f5fde Driver(adc): Disable the synchronization operation function of ADC1 and DAC
Closes IDF-1585
2020-07-01 06:16:35 +00:00
Elvis Dukaj 048fd80450 ble_hid_device_demo: fix build if building with c++
Signed-off-by: Elvis Dukaj <elvis.dukaj@gmail.com>
Signed-off-by: liminyang <liminyang@example.com>

Merges https://github.com/espressif/esp-idf/pull/5191
2020-06-18 15:52:56 +08:00
liminyang 6ac7ceef9e docs:perfect 128-bit UUID description
The previous description is not easy for the reader to understand, some changees have been made to perfect it.
Closes https://github.com/espressif/esp-idf/issues/5057
2020-06-18 15:02:44 +08:00
Michael Balzer 7b89c38034 Merge branch 'master' of https://github.com/openvehicles/esp-idf.git 2020-06-13 15:10:04 +02:00
Michael Balzer 9024cd38ec Logging: avoid blocking in timer context 2020-06-13 14:22:21 +02:00
Renz Bagaporo 07830df4d3 examples: split source files for one of the ulp examples 2020-03-23 13:12:49 +08:00
Renz Christian Bagaporo d497c4babd ldgen: fix build issue on make when build dir is a symlink
Fixes an issue where build fails if the build directory is a symlink.
The issue is caused by the rule target and the final executable dependency
not matching.

Closes https://github.com/espressif/esp-idf/issues/3626
2020-03-23 13:12:49 +08:00
Renz Christian Bagaporo 2d28fd2563 cmake: fix build failure when git repo is initialized but no first commit
Closes https://github.com/espressif/esp-idf/issues/3920
2020-03-23 13:12:49 +08:00
Renz Bagaporo 1592f338a6 ci: add test for partition_table target 2020-03-23 13:12:49 +08:00
Renz Christian Bagaporo 0ee287cd32 partition_table: output partition table info for partition_table target 2020-03-23 13:12:49 +08:00
Jakob Hasse 58cf509495 NVS: Changed all new to new (nothrow) 2020-03-04 15:26:34 +08:00
Michael Balzer dc1ca69e5f
Merge pull request #5 from leres/master
FreeBSD doesn't have gcc in the base system, use cc if not cross compling
2020-01-04 09:00:42 +01:00
Craig Leres 5e6bfb77fa FreeBSD doesn't have gcc in the base system, use cc if not cross compiling 2020-01-03 17:32:33 -08:00
Michael Balzer 4195d7c2ee LWIP DHCP server: fix disabling DNS offer
Applying tcpip_adapter_dhcps_option(TCPIP_ADAPTER_OP_SET,
TCPIP_ADAPTER_DOMAIN_NAME_SERVER, …) with option value 0 now disables
the DNS offer. It previously would only switch the DNS offer to sending
the interface IP address instead of the DNS set. If enabled now with an
unset DNS IP (0.0.0.0) it will fallback to the interface IP.
2019-12-17 21:16:36 +01:00
Michael Balzer c3465e05c1
Merge pull request #4 from leres/master
Minor python3 fixes; pick up print_function from futures and
2019-07-27 17:09:58 +02:00
Craig Leres f2c06622b7 Minor python3 fixes; pick up print_function from futures and
convert some print statements to use print()
2019-07-21 13:50:00 -07:00
Michael Balzer e97f72ea24 Merge remote-tracking branch 'upstream/release/v3.3'
# Conflicts:
#	.gitlab-ci.yml
#	components/bootloader/project_include.cmake
#	components/bootloader_support/include/bootloader_common.h
#	components/bootloader_support/src/bootloader_common.c
#	components/bt/Kconfig
#	components/bt/bluedroid/btc/profile/std/include/btc_gap_ble.h
#	components/bt/bluedroid/stack/btm/btm_ble_gap.c
#	components/bt/bluedroid/stack/btm/btm_devctl.c
#	components/bt/bluedroid/stack/include/stack/hcidefs.h
#	components/bt/bluedroid/stack/smp/smp_act.c
#	components/bt/bt.c
#	components/bt/lib
#	components/driver/Kconfig
#	components/driver/include/driver/rmt.h
#	components/driver/test/test_spi_master.c
#	components/driver/uart.c
#	components/esp32/CMakeLists.txt
#	components/esp32/Kconfig
#	components/esp32/ld/esp32.project.ld.in
#	components/esp32/ld/esp32.spiram.rom-functions-dram.ld
#	components/esp32/ld/esp32.spiram.rom-functions-iram.ld
#	components/esp32/lib
#	components/esp32/spiram.c
#	components/esp32/spiram_psram.c
#	components/esp32/test/test_wifi.c
#	components/esp32/wifi_init.c
#	components/esp_http_server/include/esp_http_server.h
#	components/esp_http_server/src/esp_httpd_priv.h
#	components/esp_http_server/src/httpd_parse.c
#	components/esp_http_server/src/httpd_sess.c
#	components/esp_http_server/src/httpd_txrx.c
#	components/esp_http_server/src/httpd_uri.c
#	components/esp_http_server/test/test_http_server.c
#	components/esp_https_ota/src/esp_https_ota.c
#	components/ethernet/emac_main.c
#	components/freemodbus/Kconfig
#	components/idf_test/include/idf_performance.h
#	components/idf_test/integration_test/TC_IT_BLUEDROID_SMP.yml
#	components/lwip/Kconfig
#	components/newlib/test/test_time.c
#	components/nvs_flash/nvs_partition_generator/nvs_partition_gen.py
#	components/spi_flash/Kconfig
#	components/ulp/cmake/CMakeLists.txt
#	components/ulp/component_ulp_common.cmake
#	components/vfs/vfs.c
#	docs/conf_common.py
#	docs/en/api-reference/provisioning/wifi_provisioning.rst
#	examples/mesh/internal_communication/main/Kconfig.projbuild
#	examples/protocols/aws_iot/subscribe_publish/main/CMakeLists.txt
#	examples/protocols/aws_iot/thing_shadow/main/CMakeLists.txt
#	examples/protocols/coap_client/README.md
#	examples/protocols/coap_server/README.md
#	examples/protocols/modbus_slave/main/Kconfig.projbuild
#	examples/protocols/mqtt/ssl/mqtt_ssl_example_test.py
#	examples/protocols/mqtt/tcp/main/Kconfig.projbuild
#	examples/protocols/mqtt/ws/mqtt_ws_example_test.py
#	examples/protocols/mqtt/wss/mqtt_wss_example_test.py
#	examples/wifi/iperf/components/iperf/iperf.c
#	requirements.txt
#	tools/ci/build_examples.sh
#	tools/ci/test_build_system_cmake.sh
#	tools/cmake/idf_functions.cmake
#	tools/cmake/kconfig.cmake
#	tools/cmake/scripts/expand_requirements.cmake
#	tools/esp_prov/README.md
#	tools/esp_prov/esp_prov.py
#	tools/esp_prov/transport/ble_cli.py
#	tools/idf.py
#	tools/kconfig_new/confgen.py
#	tools/mass_mfg/docs/README.rst
#	tools/mass_mfg/samples/sample_config.csv
#	tools/tiny-test-fw/DUT.py
#	tools/tiny-test-fw/IDF/IDFApp.py
#	tools/tiny-test-fw/IDF/IDFDUT.py
#	tools/tiny-test-fw/TinyFW.py
#	tools/unit-test-app/tools/UnitTestParser.py
#	tools/unit-test-app/unit_test.py
2019-07-20 22:11:10 +02:00
Michael Balzer 40f01ec30a Merge remote-tracking branch 'upstream/release/v3.2' 2019-07-20 15:22:14 +02:00
Jiang Jiang Jian 6ba62f7b0b Merge branch 'bugfix/fix_the_watchdog_during_WiFi_scan_BLE_scan_v3.2' into 'release/v3.2'
fix the watchdog bug during WiFi scan and BLE scan (v3.2)

See merge request espressif/esp-idf!5541
2019-07-19 18:08:56 +08:00
Jiang Jiang Jian ed7664d19f Merge branch 'bugfix/fix_flash_read_error_in_dio_26MHz_mode_v3.2' into 'release/v3.2'
bugfix(flash): fix flash read error in DIO/26MHz mode (backport v3.2)

See merge request espressif/esp-idf!5507
2019-07-16 18:41:45 +08:00
zhangyanjiao 3675e3182f fix the watchdog bug during WiFi scan and BLE scan 2019-07-16 14:29:29 +08:00
Angus Gratton 7a79cc4a5e Merge branch 'bugfix/error_on_unknown_component_v3.2' into 'release/v3.2'
cmake: error out when component is not found (backport v3.2)

See merge request espressif/esp-idf!5488
2019-07-12 15:01:40 +08:00
Mahavir Jain 376377ceca Merge branch 'bugfix/i2s_apll_clock_fix_v3.2' into 'release/v3.2'
driver/i2s: fix apll_clock_rate for different sample rates (v3.2)

See merge request espressif/esp-idf!5449
2019-07-12 11:36:01 +08:00
chenjianqiang 490a7e682d bugfix(flash): fix flash read error in DIO/26MHz mode 2019-07-11 21:10:20 +08:00
Angus Gratton 1b9d62ad95 Merge branch 'bugfix/fix_uart_wait_done_bug_v3.2' into 'release/v3.2'
bugfix(UART): fixed two UART issues for release/v3.2

See merge request espressif/esp-idf!5480
2019-07-11 14:56:32 +08:00
Jiang Jiang Jian 21601f00f4 Merge branch 'bugfix/fix_no_disconnect_event_when_rx_disassoc_after_send_auth_v3.2' into 'release/v3.2'
wifi: fix the bug no disconnect event when STA recv disassoc after sending auth (backport v3.2)

See merge request espressif/esp-idf!5099
2019-07-10 15:40:23 +08:00
Renz Christian Bagaporo 81139df91e cmake: error out when component is not found
Closes https://github.com/espressif/esp-idf/issues/3637
2019-07-10 11:56:47 +08:00
Jiang Jiang Jian e5c15c068e Merge branch 'bugfix/btdm_can_not_get_informations_of_song_v3.2' into 'release/v3.2'
components/bt: Fix iphone can't get song's informations

See merge request espressif/esp-idf!5473
2019-07-09 15:17:22 +08:00
kooho 7e2465995f bugfix(UART): fixed two UART issues:
1. uart_wait_tx_done works incorrect when sending a byte of data.
2. uart_set_rx_timeout sets an incorrect rx timeout value when ref_tick is enabled.
2019-07-09 14:47:04 +08:00
baohongde aaa0853572 components/bt: Fix iphone can't get song's informations 2019-07-08 19:46:10 +08:00
Angus Gratton 878d70d9e6 Merge branch 'fix/update_curr_page_state_3.2' into 'release/v3.2'
nvs_util: Set previous page state to FULL before creating new page (v3.2)

See merge request espressif/esp-idf!5326
2019-07-08 14:05:40 +08:00
Angus Gratton a8916daeb2 Merge branch 'fix/nvs_util_keylen_3.2' into 'release/v3.2'
nvs_util: Add check for keylen in input csv (v3.2)

See merge request espressif/esp-idf!5396
2019-07-08 12:59:55 +08:00
zhangyanjiao b7a2516242 wifi bugfix:
1. fix the bug no disconnect event when STA recv disassoc after sending auth
2. fix the bug full scan send multi events when recv deauth/disassoc
2019-07-08 11:42:36 +08:00
Jiang Jiang Jian 4a9f339447 Merge branch 'mesh/bugfix_0628' into 'release/v3.2'
mesh: bugfix (backport3.2)

See merge request espressif/esp-idf!5402
2019-07-05 22:43:16 +08:00
Mahavir Jain c1af728239 Merge branch 'bugfix/prov_examples_strlcpy_backport_v3.2' into 'release/v3.2'
Various bugfixes in Protocomm / Unified Provisioning (backport v3.2)

See merge request espressif/esp-idf!5372
2019-07-05 20:56:35 +08:00
Jiang Jiang Jian 35789eef16 Merge branch 'bugfix/improve_flash_dio_read_timing_v3.2' into 'release/v3.2'
bugfix(flash): fix flash dio read mode configuration error on SPI0 (backport v3.2)

See merge request espressif/esp-idf!5288
2019-07-05 20:42:06 +08:00
Jiang Jiang Jian 4a0d8ef478 Merge branch 'bugfix/btdm_fix_rxwinsz_assert_in_wifi_ble_coex_v3.2' into 'release/v3.2'
component/bt: fix rxwinsz assert in ble and wifi coex(backport v3.2)

See merge request espressif/esp-idf!5450
2019-07-05 20:27:52 +08:00
Shivani Tipnis 23c17c4c0d nvs_util: Add check for keylen in input csv 2019-07-05 11:06:02 +00:00
zhiweijian 2821e99bcc component/bt: fix rxwinsz assert in ble and wifi coex 2019-07-04 21:17:51 +08:00
redchenjs a4f2283384 i2s: fix a bug when calculating i2s apll parameters
Closes https://github.com/espressif/esp-idf/issues/2634
Closes https://github.com/espressif/esp-idf/issues/3380
Fixes https://github.com/espressif/esp-idf/issues/3407
2019-07-04 18:28:18 +05:30
qiyuexia b905f2de4d mesh: bugfix
1. resend eb which are pending in g_ic.tx_buf due to channel switch.
2. add lock for mgmg/xon/bcast to protect send from user flush.
3. softap: add check if secondary offset is correct when start softap.
4. softap: in inactive timer handler, add check if child bss is removed to avoid removing it again.
5. disable A-MPDU for non-root.
6. fix reusing a freed eb.
7. fix when node becomes root, it does not record assoc value to nvs.
8. discard unnecessary forwarded group packets.
9. fix toDS state is not updated in time.
10. fix s_sta_cnx_times is not cleared when deinit causes root sends ADD annoucement.
11. root: increase beacon timeout time from 6 seconds to 15 seconds to delay initiation of reconnection.
12. add esp_mesh_get_tsf_time to return TSF time.
13. send the whole routing table multi-times.
14. clear candidate settings if not receive candidate beacon within 8 seconds.
2019-07-04 11:39:17 +08:00
Shivani Tipnis c517628c77 nvs_util: Set previous page state to FULL before creating new page 2019-07-03 11:09:49 +00:00
Jiang Jiang Jian cbec031c91 Merge branch 'bugfix/btdm_backport_2_bugs_v3.2' into 'release/v3.2'
Bugfix/btdm backport 2 bugs v3.2

See merge request idf/esp-idf!5269
2019-07-02 17:33:53 +08:00
chenjianqiang 90c7885f4d bugfix(flash): improve flash dio read timing
When flash work in DIO Mode, in order to ensure the fast read mode of flash
is a fixed value, we merged the mode bits into address part, and the fast
read mode value is 0 (the default value).
2019-07-02 14:57:13 +08:00
Jiang Jiang Jian 476d4ba1b7 Merge branch 'bugfix/fix_wpa2_vulnerability_and_lwip_window_scale_v3.2' into 'release/v3.2'
esp32/lfix wpa2-enterprise vulnerability and support lwindow scale (backport v3.2)

See merge request idf/esp-idf!5411
2019-07-02 14:26:48 +08:00
Jiang Jiang Jian da80efa8bc Merge branch 'bugfix/pm_isr_exit_lock_v3.2' into 'release/v3.2'
pm: prevent interrupt nesting during esp_pm_impl_isr_hook (backport v3.2)

See merge request idf/esp-idf!4969
2019-07-02 13:55:35 +08:00
Mahavir Jain 725ecf108f Merge branch 'protocomm_ble_128bit_uuid_v3.2' into 'release/v3.2'
protocomm_ble : Fix support for custom service UUIDs (backport v3.2)

See merge request idf/esp-idf!5018
2019-07-01 19:22:28 +08:00
liu zhifu d10dec358d esp32/lwip: fix wpa2-enterprise vulnerability and support lwip window scale
1. Fix WiFi wpa2-enterprise vulnerability bug
2. Support LWIP window scale
2019-07-01 11:34:35 +08:00
Jiang Jiang Jian 7b2ece3ac2 Merge branch 'bugfix/fix_some_wifi_bugs_0508_v3.2' into 'release/v3.2'
esp32: fix some WiFi bugs 0508 (backport v3.2)

See merge request idf/esp-idf!4962
2019-07-01 11:32:26 +08:00
liu zhifu 293a665601 esp32: fix some WiFi bugs
Fix following WiFi bugs:
1. Make smartconfig thread-safe
2. Fix WiFi stop/deinit memory leak
3. Refactor for WiFi init/deinit/ioctl etc
4. Fix the bug that WiFi stop leads to task watchdog
2019-06-30 21:36:38 +08:00
Jiang Jiang Jian c6c1d089cc Merge branch 'bugfix/xTaskIncrementTick_v3.2' into 'release/v3.2'
freertos: Fix xTaskIncrementTick for unwind the Tick for CPU1 (v3.2)

See merge request idf/esp-idf!5035
2019-06-30 18:01:45 +08:00
Anurag Kar e5fe1c0e68 protocomm_ble : Example updated to use custom 128bit service UUID
Also removed old hardcoded UUIDs from README of esp_prov
2019-06-28 10:14:52 +00:00
Anurag Kar 09cf34c9aa esp_prov : Runtime discovery of Service UUID and endpoint name mapping
List of changes:
* Retrieve UUID property from Bluez device object before connecting to retrieve UUID contained in advertisement
* Read Characteristic User Descriptions attribute of each UUID for mapping endpoint names
* To support older implementations with hardcoded Name-UUID map, revert to fallback mode in order if advertisement data has no UUID field
2019-06-28 10:14:52 +00:00
Anurag Kar d76d94549a protocomm_ble : Fixed custom service UUID support
List of changes:
* Use 128 bit characteristic UUIDs when creating GATT table entries
* Change primary service attribute value to 128 bit custom service UUID
* Use raw advertisement data to convey flags and 128 bit primary service UUID
* Use raw scan response to send device name as complete local name
* Increase maximum device name length in relation to maximum scan response length
* Set Characteristic User Description attributes for each characteristic to convey protocomm endpoint names
2019-06-28 10:14:52 +00:00
Angus Gratton f3e22bc23c Merge branch 'feature/backport_component_target_var' into 'release/v3.2'
cmake: make COMPONENT_TARGET available (v3.2)

See merge request idf/esp-idf!5339
2019-06-28 15:35:43 +08:00
Angus Gratton 444ded835d Merge branch 'bugfix/mbedtls_mpi_exp_mod_v3.2' into 'release/v3.2'
mbedtls: Fix mbedtls_mpi_exp_mod() set n and s values (v3.2)

See merge request idf/esp-idf!5355
2019-06-28 08:31:41 +08:00
Anurag Kar 57c7a25bb3 protocomm_ble : Bugfix for unbound memcpy on prepare write buffer
Closes https://github.com/espressif/esp-idf/issues/3633
2019-06-27 18:59:34 +05:30
Jiang Jiang Jian 8c17eb91e2 Merge branch 'feature/config_spi_pins_based_on_efuse_value_v3.2' into 'release/v3.2'
feat(psram): config SPI psram pins based on efuse value (backport v3.2)

See merge request idf/esp-idf!5237
2019-06-27 19:22:34 +08:00
Mahavir Jain 91ec6068e9 Merge branch 'bugfix/httpd_log_purge_v3.2' into 'release/v3.2'
esp_http_server : Logging of purged data to monitor made configurable (backport v3.2)

See merge request idf/esp-idf!5016
2019-06-27 16:16:05 +08:00
Anurag Kar dab432d7ff Protocomm : Minor fixes
List of changes:
* protocomm_httpd : Reset session_id static variable on start and stop
* security1 : Typo in checking failed dynamic allocation
2019-06-27 12:38:20 +05:30
Anurag Kar accef886a9 Provisioning Examples : Bugfix in copying Wi-Fi SSID and Passphrase 2019-06-27 12:38:13 +05:30
Anurag Kar 76719b9c37 Wi-Fi Provisioning : Bugfix in copying SSID and Passphrase
These changes guarantee that the SSID and Passphrase received via protocomm are NULL terminated and size limited to their standard lengths.

List of changes:
* Corrected length of passphrase field in wifi_prov_config_set_data_t structure
* Performing length checks on SSID, passphrase and bssid, when populating wifi_prov_config_set_data_t structure with received credentials
2019-06-27 12:38:07 +05:30
Jiang Jiang Jian da10a5b7e9 Merge branch 'bugfix/btdm_fix_hci_enhance_conn_complete_evt_unpack_error_v3.2' into 'release/v3.2'
component/bt: fix unpack hci enhance connection complete event error(backport v3.2)

See merge request idf/esp-idf!5282
2019-06-27 14:28:49 +08:00
Konstantin Kondrashov 901e8338ac mbedtls: Add UTs for modexp 2019-06-26 14:20:30 +08:00
Konstantin Kondrashov fbe566ac67 mbedtls: Fix Z->s in mbedtls_mpi_exp_mod()
Z->s should never be zero, only 1 or -1.
Added additional checks for X, Y and M args to correctly set Z->s.

Closes: https://github.com/espressif/esp-idf/issues/1681
Closes: https://github.com/espressif/esp-idf/issues/3603
Closes: IDFGH-1313
2019-06-26 14:20:30 +08:00
He Yin Ling 381bd7d785 Merge branch 'feature/add_nimble_ssc_backport_for_3.2' into 'release/v3.2'
test: modified test case for bluedroid (backport v3.2)

See merge request idf/esp-idf!5213
2019-06-25 23:18:47 +08:00
Chen Sheng c0a68466a7 test: modified test case for bluedroid (backport v3.2) 2019-06-25 23:18:47 +08:00
Renz Christian Bagaporo e9786e3038 cmake: make COMPONENT_TARGET available in components 2019-06-25 13:05:46 +08:00
zhiweijian eaf8cfbf8d component/bt: fix unpack hci enhance connection complete event error 2019-06-24 03:23:31 +00:00
Angus Gratton 055943e293 Merge branch 'bugfix/docs_rtd_failure_on_missing_submodule_v3_2_bis' into 'release/v3.2'
docs: Add mqtt submodule to RTD build configuration to correct file and delete...

See merge request idf/esp-idf!5310
2019-06-24 09:12:59 +08:00
Angus Gratton b34a0874b1 Merge branch 'bugfix/spi_concurrency_3.2' into 'release/v3.2'
spi: fix a possible concurrency issue (port to v3.2)

See merge request idf/esp-idf!5278
2019-06-21 13:22:22 +08:00
Krzysztof 0d7f6a54e5 docs: Add mqtt submodule to RTD build configuration to correct file and delete similar file with typo in filename 2019-06-21 11:04:19 +08:00
He Yin Ling 100379c4aa Merge branch 'test/fix_some_error_wifi_cases_v3.2' into 'release/v3.2'
test: fix some wifi case issues (backport v3.2)

See merge request idf/esp-idf!5254
2019-06-20 22:10:44 +08:00
Angus Gratton 5d7d46a76d Merge branch 'bugfix/docs_rtd_failure_on_missing_submodule_v3_2' into 'release/v3.2'
docs: Add mqtt submodule to RTD build configuration. Now any submodule...

See merge request idf/esp-idf!5286
2019-06-20 08:07:51 +08:00
Krzysztof eaaad51f81 docs: Add mqtt submodule to RTD build configuration. Now any submodule included in documentation build by Doxygen should be included in this file 2019-06-19 16:05:03 +08:00
Michael (XIAO Xufeng) f21762eeef spi: fix a possible concurrency issue 2019-06-19 12:38:31 +08:00
baohongde e7f57fef55 component/bt: Allow configuration of default SCO_DATA_PATH in bluetooth controller 2019-06-17 14:12:09 +08:00
baohongde 284362d62d add missing source files to CMakeLists for HFP 2019-06-17 14:06:33 +08:00
wangmengyang 29b009d6fd component/bt: fix some performance issues in A2DP source data flow control
1. modify the limit of frames to send to avoid dropping packet on A2DP source due to TX data queue overflow
2. reduce the A2DP source data queue size in order to achieve faster control respnonse
2019-06-17 14:06:19 +08:00
He Yin Ling 86e8983499 test: fix some wifi case issues:
* remove heap size check cases as we have bg tasks allocate memory
* fix wifi connect to open ap issue
2019-06-14 14:55:09 +08:00
Jiang Jiang Jian fa42f63226 Merge branch 'bugfix/dns_bug_3.2' into 'release/v3.2'
DNS: fix the crash  under static IP address(backport3.2)

See merge request idf/esp-idf!5238
2019-06-14 11:34:50 +08:00
chenjianqiang 93c9c07e22 bugfix(psram): make sure the psram_io struct is initialized and make unknown psram package version more obvious 2019-06-14 10:34:56 +08:00
Jiang Jiang Jian 483fc9be6f Merge branch 'bugfix/btdm_coex_assert_in_lc_lmppdu_v3.2' into 'release/v3.2'
components/bt: Fix assert due to alloc LMP TX buffer failed

See merge request idf/esp-idf!5215
2019-06-13 22:36:58 +08:00
xueyunfei 2ed18dcdd7 lwip:fix dns bug for 3.2 2019-06-13 16:47:50 +08:00
chenjianqiang cb2e328c5f feat(psram): config SPI psram pins based on efuse value 2019-06-13 16:07:21 +08:00
baohongde 267ce80355 components/bt: Fix assert due to alloc LMP TX buffer failed 2019-06-12 19:25:59 +08:00
Angus Gratton 8b54542a88 Merge branch 'bugfix/custom_bootloader_subproject_build_v3.2' into 'release/v3.2'
CMake: Fix custom bootloader does not override original (v3.2)

See merge request idf/esp-idf!5082
2019-06-11 08:26:08 +08:00
Angus Gratton 030f17ae28 Merge branch 'fix/mfg_util_3.2' into 'release/v3.2'
mfg_util: Fix unnecessary csv files creation for values with REPEAT tags (backport 3.2)

See merge request idf/esp-idf!5046
2019-06-10 22:56:27 +08:00
Mahavir Jain a8fe057219 Merge branch 'bugfix/https_doc_api_v3.2' into 'release/v3.2'
esp_http_server : Minor clarification in httpd_req_get_url_query_str() API documentation (backport v3.2)

See merge request idf/esp-idf!5014
2019-06-10 11:49:57 +08:00
Konstantin Kondrashov adc5b2e08f freertos/test: Add unit tests for xTaskIncrementTick 2019-06-07 09:54:03 +00:00
Konstantin Kondrashov 0be4deeb22 freertos: Fix xTaskIncrementTick for unwind the Tick for CPU1
xTaskIncrementTick have to unwind uxPendedTicks on CPU1 and CPU0.

Use case: If an erase operation was run on the CPU1 then it leads
to starving other tasks which waiting time. Waited tasks just skipped.

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

Closes: IDF-183
2019-06-07 09:54:03 +00:00
Angus Gratton 1ffaf8aad9 Merge branch 'bugfix/reset_log_uart_port_v3.2' into 'release/v3.2'
esp32: Add reset CONSOLE_UART port (v3.2)

See merge request idf/esp-idf!5121
2019-06-06 16:19:22 +08:00
Renz Christian Bagaporo 9e7d9ef385 ci: check that custom bootloader overrides original 2019-06-04 23:04:47 +08:00
Renz Christian Bagaporo 88eaa34075 cmake: fix custom bootloader issue
Issue is that when users creates a custom bootloader from
$IDF_PATH/components/bootloader. Parent project build uses the copy but
bootloader subproject build uses the original still. The issue is solved
by passing the custom bootloader as extra component directory so
bootloader build knows to use the new copy (itself) in the build.
2019-06-04 23:04:47 +08:00
Konstantin Kondrashov b434b8f5d2 esp32: Add reset uart
Fixed the case when the first part of log was missed
this was happened when:
 * CONFIG_CONSOLE_UART_CUSTOM option is selected (UART1)
 * The selected CONSOLE_UART port is used also for the console component
 * in code esp_restart() or abort() functions were called.
2019-06-04 20:16:40 +08:00
Anurag Kar 7e6d1ef4bc esp_http_server : Logging of purged data to monitor made configurable
List of changes:
* Kconfig option HTTPD_LOG_PURGE_DATA enables logging of purged data
* Kconfig option HTTPD_PURGE_BUF_LEN sets purge buffer length
* Purged data is logged in hex

Closes https://github.com/espressif/esp-idf/issues/3359
2019-06-03 08:37:41 +00:00
Anurag Kar 92dc6a6dde esp_http_server : Minor clarification in httpd_req_get_url_query_str() API documentation
Closes https://github.com/espressif/esp-idf/issues/3374
2019-06-03 08:36:24 +00:00
Angus Gratton 8e51f7e236 Merge branch 'bugfix/custom_log_uart_rx_pin_v3.2' into 'release/v3.2'
bootloader_support: Fix UART RXD pin for console output (CUSTOM option) (v3.2)

See merge request idf/esp-idf!5032
2019-06-03 14:23:55 +08:00
Shivani Tipnis 492c682dbe mfg_util: Fix unnecessary csv files creation for values with REPEAT tags
(cherry picked from commit 8b96668c9123fbbf8c78b347479215f471b102ed)
2019-05-31 13:53:01 +05:30
Konstantin Kondrashov 3886be23c8 soc: Add some headers into gpio_periph.h 2019-05-29 13:46:37 +08:00
Jiang Jiang Jian ddbce78bff Merge branch 'bugfix/fix_smartconfig_bug' into 'release/v3.2'
esp32: fix a smartconfig bug (backport v3.2)

See merge request idf/esp-idf!5055
2019-05-28 10:54:51 +08:00
Angus Gratton a230075447 Merge branch 'bugfix/docs_build_failure_on_rtd_v3_2' into 'release/v3.2'
Fix Breathe version to avoid docs build failure on ReadTheDocs server. Provide...

See merge request idf/esp-idf!5061
2019-05-27 13:58:33 +08:00
Angus Gratton 4b5be79c0c Merge branch 'feature/esp_http_client_mutual_auth_backport_v3.2' into 'release/v3.2'
esp_http_client: Add support for mutual authentication (backport v3.2)

See merge request idf/esp-idf!5026
2019-05-27 13:16:47 +08:00
Krzysztof b80b5dad32 Fix Breathe version to avoid docs build failure on ReadTheDocs server. Provide RTD project configuration file to be able to select python version for specific esp-idf release. (backport v3.2) 2019-05-23 19:57:43 +08:00
Angus Gratton ee39083d1b Merge branch 'feature/add_promiscuous_control_for_ethernet_v3.2' into 'release/v3.2'
add promiscuous mode control for Ethernet (v3.2)

See merge request idf/esp-idf!4976
2019-05-23 14:23:48 +08:00
liu zhifu 38b4d1d70c esp32: fix a smartconfig bug
Fix a smartconfig bug which leads to deadlock between WiFi task and timer task.
2019-05-22 21:47:02 +08:00
Jiang Jiang Jian 2e85c5b62e Merge branch 'bugfix/fix_softap_crash_when_sta_reset_3.2' into 'release/v3.2'
wifi: fix softap crash when sta reset (backport v3.2)

See merge request idf/esp-idf!5001
2019-05-22 21:02:15 +08:00
xiehang a820787414 wifi: fix softap crash when sta (backport v3.2) 2019-05-20 20:30:41 +08:00
Konstantin Kondrashov cea6908238 bootloader_support: Fix UART RXD pin for console output (CUSTOM option)
The RXD pin is assigned as input (fix for custom uart option).

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

Closes: IDFGH-505
2019-05-20 18:31:13 +08:00
Anders Kalør d81c79d79f esp_http_client: Add support for mutual authentication
Closes https://github.com/espressif/esp-idf/pull/2688
Closes https://github.com/espressif/esp-idf/issues/3438
2019-05-20 11:01:04 +05:30
Angus Gratton 2f8508c7eb Merge branch 'bugfix/http_server_lf_term_hdr_backport_v3d2' into 'release/v3.2'
HTTP Server : Fix for tolerating LF terminated headers (backport v3.2)

See merge request idf/esp-idf!4657
2019-05-13 20:29:03 +08:00
suda-morris fd281c11cc add promiscuous mode control in emac driver
1. add promiscuous mode control in emac driver
2. fix minor bugs in IP101 driver
2019-05-10 12:56:35 +08:00
Ivan Grokhotkov 5328154a01 pm: prevent interrupt nesting during esp_pm_impl_isr_hook
Follows the approach proposed in https://github.com/espressif/esp-idf/pull/3110,
but masks the interrupts during the entire ISR hook, not only during
leave_idle. Interrupt nesting during update_ccompare may also cause
issues.

Closes https://github.com/espressif/esp-idf/issues/3057
2019-05-10 10:20:29 +08:00
Ivan Grokhotkov 6dd653392b Merge branch 'bugfix/core_dump_flash_write_addr_check_v3.2' into 'release/v3.2'
Backport v3.2: Fixes freezing core dump with enabled flash write address checks

See merge request idf/esp-idf!4961
2019-05-09 19:45:48 +08:00
Alexey Gerenkov dd623febf5 esp32: Fixes freezing core dump process when flash write address checks are enabled 2019-05-08 13:55:31 +03:00
Angus Gratton 106c8813ed Merge branch 'bugfix/nvs_fix_erase_any_v3.2' into 'release/v3.2'
nvs_flash: Multi-page blob erased using nvs_erase_key should be cleaned properly (v3.2)

See merge request idf/esp-idf!4817
2019-05-08 09:37:13 +08:00
Jiang Jiang Jian 524308c98d Merge branch 'bugfix/backport_some_wifi_bugs_to_v3.2' into 'release/v3.2'
esp32: backport some WiFi fixes to v3.2 (backport v3.2)

See merge request idf/esp-idf!4937
2019-05-07 22:42:15 +08:00
negativekelvin 553725df84 nvs_flash: Multi-page blob erased using nvs_erase_key should be cleaned properly
Earlier eraseItem function in Storage class would do lazy cleanup of
multi-page blobs if called using type "ANY" instead of "BLOB". It used to
just delete BLOB data and index would remain as is. Any subsequent read
would delete index entry as well. This however would return a valid
length without error if nvs_get_blob API was just used for finding
length and not reading the complete blob. This change fixes this issue.

Closes https://github.com/espressif/esp-idf/issues/3255
2019-05-07 05:53:19 +00:00
liu zhifu 7d3733d255 esp32: backport some WiFi fixes to v3.2
Backport following WiFi fixes to v3.2:
1. Add support for STA HT2040 coexist management
2. Add support for WPA2 improvements
3. Disallow HT rate when unicast/mcast cipher is TKIP/WEP
4. Add support for signal test
5. Fix the bug that WPS fails when AP is encrypted
2019-05-07 10:50:09 +08:00
Jiang Jiang Jian 038f51ffa6 Merge branch 'bugfix/scan_fail_when_no_ap_found_v3.2' into 'release/v3.2'
fix the bug when scan fail after STA failed to connect to a nonexistent AP (backport v3.2)

See merge request idf/esp-idf!4913
2019-05-06 11:39:31 +08:00
zhangyanjiao 4e78900fbf fix the bug when scan fail after STA failed to connect to a nonexistent AP 2019-05-05 11:53:33 +08:00
Anurag Kar 87215ca0c3 HTTP Server : Fix for tolerating LF terminated headers
List of changes:
* When parsing requests, count termination from LF characters only
* Correct memcpy() length parameter in httpd_unrecv() (pointed out by jimparis in GitHub issue thread)
* Use ssize_t to store results of length subtractions during parsing
* Modify some comments to reduce ambiguity

Closes https://github.com/espressif/esp-idf/issues/3182
2019-05-02 05:56:49 +00:00
Jiang Jiang Jian f6bfe13eb3 Merge branch 'bugfix/erase_with_vtaskdelay_v3.2' into 'release/v3.2'
spi_flash: Add vTaskDelay while a long erasing (v3.2)

See merge request idf/esp-idf!4875
2019-04-28 22:14:41 +08:00
Jiang Jiang Jian 294a051538 Merge branch 'bugfix/ci_submodule_paths_v3.2' into 'release/v3.2'
CI - Fix the parsing of submodule paths (backport v3.2)

See merge request idf/esp-idf!4575
2019-04-28 22:13:29 +08:00
Jiang Jiang Jian 4aa1058e8a Merge branch 'feature/himem_readme_backport_v3.2' into 'release/v3.2'
Proper README.md for himem example (backport v3.2)

See merge request idf/esp-idf!4304
2019-04-28 22:13:16 +08:00
Jiang Jiang Jian a08c77ae96 Merge branch 'bugfix/fix_iperf_exit_error_v3.2' into 'release/v3.2'
examples: fix iperf exit error

See merge request idf/esp-idf!4842
2019-04-28 12:00:48 +08:00
Jiang Jiang Jian df874cd070 Merge branch 'bugfix/httpd_accept_conn_v3.2' into 'release/v3.2'
esp_http_server : Only accept new connections if server has capacity to handle more (backport v3.2)

See merge request idf/esp-idf!4722
2019-04-28 11:47:14 +08:00
Anton Maklakov 36fff1d751 ci: Fix the parsing of submodule paths 2019-04-28 03:46:29 +00:00
Konstantin Kondrashov fe0d45d549 spi_flash: Add vTaskDelay while a long erasing
Added Kconfig options to enable yield operation during flash erase.
By default disable.

Closes: https://github.com/espressif/esp-idf/issues/2083
Closes: IDFGH-261
2019-04-28 02:42:31 +00:00
Jiang Jiang Jian 6f19193de6 Merge branch 'bugfix/adjtime_ut_v3.2' into 'release/v3.2'
newlib: Fix adjtime (v3.2)

See merge request idf/esp-idf!4871
2019-04-28 10:36:55 +08:00
Jiang Jiang Jian 8f4e7d2456 Merge branch 'backport/bugfix_url_redirect_v32' into 'release/v3.2'
Fix url redirection issue. (backport v3.2)

See merge request idf/esp-idf!4852
2019-04-28 10:36:09 +08:00
Jiang Jiang Jian 4156c6ddec Merge branch 'bugfix/improve_spi_timing_for_psram_and_flash_v3.2' into 'release/v3.2'
bugfix(psram): improve spi cs timing settings for psram (backport v3.2)

See merge request idf/esp-idf!4846
2019-04-28 10:35:41 +08:00
Jeroen Domburg cb20ba50b1 Proper README.md for himem example 2019-04-28 02:34:48 +00:00
Jiang Jiang Jian 131979e517 Merge branch 'bugfix/doc_ubuntu_packages_v3.2' into 'release/v3.2'
docs: Update package dependencies (backport v3.2)

See merge request idf/esp-idf!4458
2019-04-28 10:27:19 +08:00
Jiang Jiang Jian 9d6cace1fd Merge branch 'test/detect_exception_in_idf_dut_v3.2' into 'release/v3.2'
tiny-test-fw: support detect exception in IDFDUT (backport v3.2)

See merge request idf/esp-idf!4543
2019-04-28 10:26:48 +08:00
Jiang Jiang Jian a5b007f6bb Merge branch 'bugfix/msys_cancel_idfpy_v3.2' into 'release/v3.2'
tools: re-run idf.py in MSYS with winpty (backport v3.2)

See merge request idf/esp-idf!4456
2019-04-28 10:26:10 +08:00
Jiang Jiang Jian 0beb60e8fc Merge branch 'test/fix_unit_test_job_pass_even_no_test_executed_v3.2' into 'release/v3.2'
test: fix CI UT job pass even ut app bootup fail (backport v3.2)

See merge request idf/esp-idf!4388
2019-04-28 10:25:53 +08:00
Jiang Jiang Jian 9294e4d08d Merge branch 'feature/poll_v3.2' into 'release/v3.2'
VFS: Implement poll() based on select() (backport v3.2)

See merge request idf/esp-idf!4350
2019-04-28 10:24:41 +08:00
Jiang Jiang Jian 193b8e93a8 Merge branch 'bugfix/btdm_abort_if_deinit_spp_without_init_v3.2' into 'release/v3.2'
components/bt: Fix abort if call esp_spp_deinit without calling esp_spp_init

See merge request idf/esp-idf!4862
2019-04-26 21:01:35 +08:00
Angus Gratton 8da392aa1d Merge branch 'feature/esp_http_client_global_ca_store_v3.2' into 'release/v3.2'
esp_http_client: add support for using certs from global ca store (backport_v3.2)

See merge request idf/esp-idf!4868
2019-04-26 10:08:23 +08:00
Angus Gratton c3cee5e3de Merge branch 'backport/feature_set_redirect_function_v32' into 'release/v3.2'
Add a `esp_http_client_set_redirection` function. (backport v3.2)

See merge request idf/esp-idf!4867
2019-04-26 10:07:04 +08:00
Jiang Jiang Jian 0c13ae6b45 Merge branch 'feature/btdm_add_ble_link_timeout_config_v3.2' into 'release/v3.2'
Component/bt: add ble link timeout config in menuconfig(backport v3.2)

See merge request idf/esp-idf!4826
2019-04-25 20:05:19 +08:00
Jiang Jiang Jian 306a1173af Merge branch 'feature/wifi_refactor_softap_power_save_v3.2' into 'release/v3.2'
refactor softap power save (backport v3.2)

See merge request idf/esp-idf!4823
2019-04-25 17:05:49 +08:00
Konstantin Kondrashov 592a4295be newlib: Fix adjtime
Fixed adjtime function: While using the adjtime() function,
the time correction accumulated an error
when reading the time frequently (using gettimeofday).
2019-04-24 17:42:38 +08:00
Mahavir Jain 2549951498 esp_http_client: add support for using certs from global ca store
Closes https://github.com/espressif/esp-idf/issues/3062

(cherry picked from commit 27e00cf7aa)
2019-04-24 14:06:33 +05:30
Vikram Dattu b2384dc9ee Add a esp_http_client_set_redirection function When using direct operations instead of esp_http_client_perform, we need a way to set redirection URL when we get 30x response codes. Added the function for the same. User can now check status code and call esp_http_client_set_redirection function to enable redirection. Related change in adf: https://gitlab.espressif.cn:6688/adf/esp-adf-internal/merge_requests/187
Signed-off-by: Vikram Dattu <vikram.dattu@espressif.com>
2019-04-24 13:54:22 +05:30
baohongde f95826144e components/bt: Fix abort if call esp_spp_deinit without calling esp_spp_init 2019-04-24 11:34:06 +08:00
Vikram Dattu 344cb99d34 Fix url redirection issue.
Operation:
In `esp_http_client_set_url`, we check for if old_host is same as new_host.
Delete and open new connection if host is different.

Issue:
We just pointed `client->connection_info.host` to `old_host` and reassigned it.
This made old_host and new_host always point to same location and hence, using old_host with new request.

Fix:
Made a separate copy for old_host using strdup.

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

Signed-off-by: Vikram Dattu <vikram.dattu@espressif.com>
2019-04-23 14:28:21 +05:30
Wangjialin 464df4b788 bugfix: fix bug in flash 80M + sram 40M mode 2019-04-23 02:18:15 +00:00
Wangjialin 8ff0d986b6 bugfix(psram): improve spi cs timing settings for psram
1. remove redundant SPI clock settings, use rom functions to set clock.
2. remove redundant SPI cs setup and hold settings.
3. for old 32Mbit psram, cs hold time must only be 0.5T due to the special driving mode.(cs_setup = 0; cs_hold = 0)
4. for new 64Mbit psram, cs hold time is recommended to be 2.5T. (cs_setup = 1, cs_setup_time = 0;cs_hold = 1, cs_hold_time = 1)
2019-04-23 02:18:15 +00:00
Angus Gratton 225bc0f80a Merge branch 'bugfix/remove_second_sha_enable_v3.2' into 'release/v3.2'
esp32/sha: Remove second enabling in esp_sha_lock_engine_common (backport v3.2)

See merge request idf/esp-idf!4780
2019-04-23 07:38:00 +08:00
zhiweijian 96c8343e46 Component/bt: add ble link timeout config in menuconfig
- add ble link timeout config in menuconfig
- disable background connection when call gatts_open
2019-04-22 21:55:06 +08:00
xiehang d9cdbcdc8b examples: fix iperf exit error 2019-04-22 13:02:42 +08:00
XiaXiaotian 3ee11bcafc refactor softap power save
1. Softap support multicast and broadcast saving and flushing
    when the associated stations enable IEEE80211 legacy power
    save(which is called modem sleep in ESP32).

    2. Improve the frame saving and flushing mechanism of softap power
    save.
2019-04-19 14:14:33 +08:00
Jiang Jiang Jian bcb543eb10 Merge branch 'bugfix/coex_decouple_wifi_and_bt_code_with_coexist_v3.2' into 'release/v3.2'
Decouple WiFi and BT with coexist to reduce bin size (backport v3.2)

See merge request idf/esp-idf!4811
2019-04-19 13:31:06 +08:00
He Yin Ling bb73659c9c Merge branch 'test/modify_mesh_ci_v3.2' into 'release/v3.2'
test: update mesh test cases for ci  (backport v3.2)

See merge request idf/esp-idf!4650
2019-04-18 11:29:43 +08:00
chenyudong 58bc6be4c0 test:update mesh test cases for ci test(v3.2)
add mesh test case in TC_IT_MESH_EST.yml and TC_IT_MESH_COMM.yml

add job form IT_02 to IT_08
2019-04-17 17:25:17 +08:00
XiaXiaotian 5059c7fac3 Decouple WiFi and BT with coexist to reduce bin size
1. Do not link WiFi code when only BT or BLE is used and WiFi is not
used.

2. Do not link coexist code when CONFIG_SW_COEXIST_ENABLE is disabled.
2019-04-17 16:59:24 +08:00
Jiang Jiang Jian cf866f23f2 Merge branch 'bugfix/fix_some_wifi_and_coexist_bugs_0416_v3.2' into 'release/v3.2'
esp32: fix some WiFi and coexist bugs (backport v3.2)

See merge request idf/esp-idf!4803
2019-04-17 14:24:32 +08:00
liu zhifu faec3211bd esp32: fix some WiFi and coexist bugs
Fix following WiFi and coexist bugs:
1. Fix BT disconnecting due to too many reset BB
2. Fix the bug that no TBTT is generated after rx wrong beacon when WiFi/BT coexist
3. Fix a DelBA bug
4. Add out of memory check
5. Fix the bug that STA incorrectly receives packets when scanning in connected status
6. PHY4008: Disable BT TX in force wifi mode, and enable BT TX in un-force wifi mode
2019-04-17 10:02:51 +08:00
Jiang Jiang Jian c7d0df5451 Merge branch 'bugfix/fix_scan_and_connect_bugs_0415_v3.2' into 'release/v3.2'
fix wifi scan and connect bugs (backport v3.2)

See merge request idf/esp-idf!4772
2019-04-16 21:09:15 +08:00
Jiang Jiang Jian 7097cb9c9d Merge branch 'bugfix/fix_deprecated_warning_with_dfs_init_auto_config_v3.2' into 'release/v3.2'
cpu_start: fix warnings with CONFIG_PM_DFS_INIT_AUTO option (v3.2)

See merge request idf/esp-idf!4791
2019-04-16 20:30:09 +08:00
Mahavir Jain 1fcef31195 cpu_start: fix warnings with CONFIG_PM_DFS_INIT_AUTO option
Closes https://github.com/espressif/esp-idf/issues/3297
2019-04-16 11:21:26 +05:30
Jiang Jiang Jian acc882f4dd Merge branch 'bugfix/btdm_bugx_backport_3.2' into 'release/v3.2'
Some bugs backport 3.2

See merge request idf/esp-idf!4773
2019-04-16 10:45:04 +08:00
Angus Gratton e4c1bcddc5 Merge branch 'bugfix/freemodbus_fix_critical_sections' into 'release/v3.2'
freemodbus: fix critical sections to semaphore mutex (backport v3.2)

See merge request idf/esp-idf!4435
2019-04-16 08:53:23 +08:00
Konstantin Kondrashov b2455219cc esp32/sha: Remove second enabling in esp_sha_lock_engine_common 2019-04-15 21:14:38 +08:00
zhangyanjiao de6b7d6520 fix wifi scan and connect bugs:
1. fix the bug block scan tiemout before scan finish
2. make menuconfig can set the WiFi mgmt short buffer num
3. modify wifi reason code
4. fix the bug PMK recal too long
2019-04-15 18:59:52 +08:00
Jiang Jiang Jian fa40e43c8d Merge branch 'bugfix/btdm_fix_warning_when_disable_logs_v3.2' into 'release/v3.2'
components/bt: Fix warning when disable debug logs or in release mode and improve the code structure

See merge request idf/esp-idf!4620
2019-04-15 18:52:09 +08:00
Jiang Jiang Jian 9f29dbf656 Merge branch 'bugfix/btdm_fix_build_warning_when_bluedroid_disable_log_v3.2' into 'release/v3.2'
Component/bt: fix build warning when bluedroid disable log (backport v3.2)

See merge request idf/esp-idf!4566
2019-04-15 18:50:58 +08:00
Jiang Jiang Jian b2d61989f1 Merge branch 'mesh/decouple_addition_v3.2' into 'release/v3.2'
Decouple Wifi and ESP-Mesh to reduce bin size (backport v3.2)

See merge request idf/esp-idf!4523
2019-04-15 17:06:00 +08:00
baohongde bb518afb59 Some bugs backport 3.2
1.Fix memory leak when set txpower
2.Fix some bugs
    Disconnect with apple device
    hci_refresh_enc_key_cmd will be ignore
    hci_refresh_enc_key_cmd will crash
2019-04-15 16:51:29 +08:00
chenyudong 37063ea9b6 Decouple Wifi and ESP-Mesh to reduce bin size
Do not link mesh code when mesh is not used
2019-04-14 20:36:14 +08:00
Jiang Jiang Jian f6837e6117 Merge branch 'bugfix/esp_sha_signing_sha256_v3.2' into 'release/v3.2'
secure boot: Fix esp_sha INT WDT, switch to using mbedTLS API  (backport v3.2)

See merge request idf/esp-idf!4511
2019-04-14 02:57:45 +08:00
Jiang Jiang Jian c4f39094d3 Merge branch 'bugfix/cmake_component_path_v3.2' into 'release/v3.2'
cmake: Set COMPONENT_PATH during early expansion of dependencies (v3.2)

See merge request idf/esp-idf!4594
2019-04-14 02:57:16 +08:00
Jiang Jiang Jian 2da22620f8 Merge branch 'feature/btdm_add_mesh_adv_type_and_srv_uuid_for_dup_scan_except_v3.2' into 'release/v3.2'
Component/bt: add mesh beacon adv and svc uuid for duplicate scan exceptional list (backport v3.2)

See merge request idf/esp-idf!4606
2019-04-14 02:56:43 +08:00
Jiang Jiang Jian f77d0a9cdb Merge branch 'bugfix/ci_tag_for_cmake_linter_v3.2' into 'release/v3.2'
ci: A small CI stabilizing fix (backport v3.2)

See merge request idf/esp-idf!4710
2019-04-14 02:55:38 +08:00
Jiang Jiang Jian ddf4991024 Merge branch 'bugfix/bootloader_flash_crypt_cnt_ff_v3.2' into 'release/v3.2'
flash encryption: reduce FLASH_CRYPT_CNT bit width to 7 bits (v3.2)

See merge request idf/esp-idf!4728
2019-04-14 02:55:21 +08:00
Jiang Jiang Jian f8597be435 Merge branch 'bugfix/wifi_modify_wifi_kconfig_v3.2' into 'release/v3.2'
esp32: modify WiFi Kconfig in order to achieve better compatility and performance (bakcport v3.2)

See merge request idf/esp-idf!4386
2019-04-12 23:11:24 +08:00
Jiang Jiang Jian 6e5e430ef4 Merge branch 'bugfix/mesh_memory_leak_v3.2' into 'release/v3.2'
mesh: fix memory leak and group send (backport v3.2)

See merge request idf/esp-idf!4519
2019-04-12 22:02:08 +08:00
Jiang Jiang Jian 065d451e47 Merge branch 'bugfix/btdm_modify_HCI_GET_CMD_BUF_v3.2' into 'release/v3.2'
Component/bt: modify HCI_GET_CMD_BUF (backport v3.2)

See merge request idf/esp-idf!4599
2019-04-12 21:58:51 +08:00
Jiang Jiang Jian c8990eb39d Merge branch 'bugfix/btdm_add_scan_window_interval_check_v3.2' into 'release/v3.2'
Component/bt: add scan window and interval check when set scan params (backport v3.2)

See merge request idf/esp-idf!4311
2019-04-12 21:57:50 +08:00
Jiang Jiang Jian c90f770599 Merge branch 'bugfix/btdm_fix_blufi_prepare_write_crash_v3.2' into 'release/v3.2'
Component/bt: fix blufi prepare write crash (backport V3.2)

See merge request idf/esp-idf!4563
2019-04-12 21:57:23 +08:00
Jiang Jiang Jian 48978c6f2b Merge branch 'bugfix/btdm_fix_iOS_and_win10_compatibility_error_for_HID_v3.2' into 'release/v3.2'
Component/bt: fix iOS and win10 compatibility error  for HID (backport v3.2)

See merge request idf/esp-idf!4424
2019-04-12 21:56:40 +08:00
Angus Gratton 5bb5670d69 efuse/flash encryption: Reduce FLASH_CRYPT_CNT to a 7 bit efuse field
8th bit is not used by hardware.

As reported https://esp32.com/viewtopic.php?f=2&t=7800&p=40895#p40894
2019-04-12 07:28:57 +00:00
Angus Gratton 7197811861 Merge branch 'bugfix/prov_fix_conn_id_v3.2' into 'release/v3.2'
(backport v3.2) Unified Provisioning: Miscellaneous fixes in BLE

See merge request idf/esp-idf!4734
2019-04-12 13:46:06 +08:00
Angus Gratton 892c2be168 esp32: Chunk input blocks for esp_sha() function performance, add perf test 2019-04-12 05:45:05 +00:00
Angus Gratton 5c6be8380e secure boot: Use mbedtls_sha256() not esp_sha()
Latter is probably compiled into most firmwares already, saves some size.

Ref https://github.com/espressif/esp-idf/issues/3127
2019-04-12 05:45:05 +00:00
Angus Gratton 1d8e1c4ce4 esp32 hwcrypto: Prevent esp_sha() from disabling interrupts for extended period
* Closes https://github.com/espressif/esp-idf/issues/3127
* Closes IDFGH-681

Also reported at https://esp32.com/viewtopic.php?f=13&t=9506
2019-04-12 05:45:05 +00:00
chenyudong 1778573dad mesh: fix memory leak and group send
fix a bug in group send
fix esp_mesh_set_router when router_t not initialized
fix mesh memory leak with invalid option
2019-04-11 20:43:38 +08:00
Jiang Jiang Jian 9778549759 Merge branch 'bugfix/tw28146_make_wifi_iram_optimization_configurable_v3.2' into 'release/v3.2'
esp32: make WiFi IRAM optimization configurable (backport v3.2)

See merge request idf/esp-idf!4040
2019-04-11 18:44:19 +08:00
Angus Gratton e5e226a121 Merge branch 'bugfix/external_rtc_start_fail_v3.2' into 'release/v3.2'
Bugfix/external rtc start fail (v3.2)

See merge request idf/esp-idf!4662
2019-04-10 14:17:41 +08:00
Hrishikesh Dhayagude 71845041e0 Unified Provisioning: Miscellaneous fixes in BLE
1. Pass the correct conn_id to protocomm_req_handle
In transport_simple_ble_write(), passing param->exec_write.conn_id would
be invalid. Instead param->write.conn_id should be passed
Similar change in transport_simple_ble_exec_write() to use
param->exec_write.conn_id

2. simple_ble_start() assumes that the mode is BLE only and enables
Bluetooth controller accordingly. For, cases having BT + BLE like Alexa
(Provisioning over BLE + Audio over classic BT), this assumption should
be removed.
2019-04-09 11:25:42 +05:30
Angus Gratton 54dff92df5 Merge branch 'feature/mfg_util_v3.2' into 'release/v3.2'
Add changes to mfg_util as per changes in nvs_util (backport v3.2)

See merge request idf/esp-idf!4702
2019-04-09 09:19:43 +08:00
Anurag Kar a5bd08a6b6 esp_http_server : Test added to check limit on max_open_sockets config option 2019-04-08 11:36:08 +05:30
Anurag Kar befc74e0f0 esp_http_server : Only accept new connections if server has capacity to handle more
This fix prevents HTTP server from accepting new connections when the total count of connected
sockets has reached the max_open_sockets limit set during configuration. The pending connections
are kept in backlog until atleast one of the connected sockets is closed. The maximum number of
connection requests that can kept in backlog is specified as backlog_conn configuration option.
Note that this modification has no effect when LRU purge is enabled.

Also added sanity check on setting for max_open_sockets during configuration.

Solution suggested by jimparis https://github.com/espressif/esp-idf/issues/3183#issue-421234265

Closes https://github.com/espressif/esp-idf/issues/3183
2019-04-08 11:34:20 +05:30
Angus Gratton 12bf1017de Merge branch 'bugfix/heap_caps_int_overflows_v3.2' into 'release/v3.2'
heap: Add integer overflow checks on MALLOC_CAP_32BIT & MALLOC_CAP_EXEC (v3.2)

See merge request idf/esp-idf!4569
2019-04-05 09:31:03 +08:00
Shivani Tipnis 006442cd9d mfg_util: Add changes to mfg_util as per changes in nvs_util
revert changeson this file

Update README for mfg util

Update to correct coding style of script

(cherry picked from commit a88b40483d)
2019-04-04 18:28:10 +05:30
Anton Maklakov 25a134afdc ci: Fix runner choice for CMake verification job and change .check_job_template tag to host_test 2019-04-04 17:23:20 +07:00
Angus Gratton 70811110fc Merge branch 'fix/spi_on_readonly_pins_v3.2' into 'release/v3.2'
spi: fix the bug of connecting SPI peripheral to read-only pins (backport v3.2)

See merge request idf/esp-idf!4307
2019-04-02 12:29:06 +08:00
Angus Gratton b87e440c69 Merge branch 'update/nvs_part_util_v3.2' into 'release/v3.2'
Update/nvs partition utility v3.2 (backport v3.2)

See merge request idf/esp-idf!4280
2019-04-02 11:58:56 +08:00
maojianxin f85294b058 Fix external start fail 2019-04-02 12:52:58 +11:00
Zhang Jun Yi 413b6487fb soc/rtc: Bypass touchpad current to external 32k crystal oscillator 2019-04-02 12:50:50 +11:00
Angus Gratton f608afbe6b Merge branch 'bugfix/build_fails_when_editor_assoc_with_py_scripts_v3.2' into 'release/v3.2'
Fix issues with CMake builds when python scripts are associated with an editor (backport v3.2)

See merge request idf/esp-idf!4637
2019-04-02 09:40:10 +08:00
Michael (XIAO Xufeng) 325fca94c0 spi: fix the bug of connecting SPI peripheral to read-only pins
The requirements of pin capabilites is different for spi master and
slave.  The master needs CS, SCLK, MOSI to be output-able, while slave
needs MISO to be output-able.

Previous code is for master only.

This commit allows to place other 3 pins than MISO on input-only pins
for slaves. Refactoring for spi_common is also included.

Resolves https://github.com/espressif/esp-idf/issues/2455
2019-04-01 18:39:02 +08:00
zhiweijian 3130b19cf8 Component/bt: add mesh beacon adv and svc uuid for duplicate scan exceptional list 2019-03-28 11:20:51 +08:00
Shivani Tipnis 5d2c23c8ab nvs_util: Add support for creation of unique encryption keys
(cherry picked from commit e1f466e708c2c1b825e955ec28b70dc3058f9262)
2019-03-27 18:24:18 +05:30
Shivani Tipnis 8480e79ae2 nvs_util: Add support for creation of unique encryption keys
(cherry picked from commit 8b88b3303d83f5f03249e7b3410f6ecabaa00396)
2019-03-26 15:52:10 +05:30
Shivani Tipnis 86052eec78 nvs_util: Fix to support write of multiple singlepage big blob data
Closes https://github.com/espressif/esp-idf/issues/3011

(cherry picked from commit 60b5cdde20)
2019-03-26 15:49:25 +05:30
baohongde 5ede49ca4a components/bt: Fix warning when disable debug logs or in release mode and improve the code structure 2019-03-26 15:29:22 +08:00
baohongde bbdb236ab7 components/bt: Fix warning when disable debug logs or in release mode and improve the code structure 2019-03-26 14:59:58 +08:00
Renz Christian Bagaporo 0a0113bcce ci: test full build never runs '/usr/bin/env python' or similar 2019-03-25 11:41:00 +08:00
Renz Christian Bagaporo 84a534a4a0 cmake: Fix for Python files executed directly, not via PYTHON variable 2019-03-25 11:41:00 +08:00
Ivan Grokhotkov 286202caa3 Merge branch 'bugfix/mqtt_fragmented_packed_msg_3.2' into 'release/v3.2'
MQTT support for fragmented and packed messages (Backport 3.2)

See merge request idf/esp-idf!4593
2019-03-25 10:49:56 +08:00
zhiweijian 6b4dcd4f5c Component/bt: modify HCI_GET_CMD_BUF 2019-03-22 15:02:20 +08:00
Angus Gratton 4f62227030 cmake: Set COMPONENT_PATH during early expansion of dependencies
Works around bug where components/soc/CMakeLists.txt was testing "EXISTS
${COMPONENT_PATH}/${SOC_NAME}" and this test could pass during early
expansion if COMPONENT_PATH was empty and a directory /esp32 exists
on Windows.

Closes https://github.com/espressif/esp-idf/issues/3195
2019-03-22 10:12:06 +11:00
David Cermak 9ebaf36c28 tcp_transport: modification of ws to read headers first in order to read the exact payload
closes https://github.com/espressif/esp-mqtt/issues/69
2019-03-21 14:35:59 +01:00
David Cermak 1ece141c52 mqtt: support for BEFORE_CONNECT event in idf
Updated examples to use new event id, idf to use mqtt with fixed retained, oversized messages
2019-03-21 14:35:49 +01:00
Krzysztof Budzynski f49e2afe94 Merge branch 'bugfix/sphinx_build_failure_on_rtd_v3.2' into 'release/v3.2'
docs: Upgraded sphinx package version to prevent build failures on readthedocs…

See merge request idf/esp-idf!4554
2019-03-21 14:24:24 +08:00
Angus Gratton 17b260d05c Merge branch 'bugfix/nvs_api_usage_in_simple_ota_example_v3.2' into 'release/v3.2'
Minor bugfix in simple ota example (backport v3.2)

See merge request idf/esp-idf!4584
2019-03-21 13:06:48 +08:00
InfiniteYuan1 07fc1d181f bugfix(simple_ota): Compatible with V3.1 and V3.2
(cherry picked from commit 0fa31d3e31)
2019-03-21 10:24:09 +08:00
Jiang Jiang Jian beb29bc88a Merge branch 'bugfix/btdm_fix_no_adv_report_when_scaning_with_sleep_enable_v3.2' into 'release/v3.2'
Component/bt: fix no adv report when scanning with sleep enable(backport v3.2)

See merge request idf/esp-idf!4537
2019-03-20 22:03:12 +08:00
Liu Zhi Fu 76c20ab9b3 esp32: make WiFi IRAM optimization configurable
With this feature, the WiFi IRAM optimization can be disabled/enabled via menuconfig.
2019-03-20 13:45:54 +00:00
zhiweijian 241ba1a6bb Component/bt: fix iOS and win10 compatibility error for HID 2019-03-20 19:47:04 +08:00
Angus Gratton 1fac58deb7 heap: Add integer overflow checks on MALLOC_CAP_32BIT & MALLOC_CAP_EXEC 2019-03-20 18:30:17 +11:00
zhiweijian 78d32f2e8b Component/bt: fix build warning when bluedroid disable log 2019-03-20 15:06:17 +08:00
zhiweijian f237b92bc4 Component/bt: fix blufi prepare write crash 2019-03-20 14:27:11 +08:00
krzychb ccc1263ca8 docs: Upgraded sphinx package version to prevent build failures on readthedocs site. Upgraded versions of other packages that are used during documentation build. (backport v3.2) 2019-03-19 20:22:07 +01:00
He Yin Ling 51a44c81de test: handle exception by unit test script:
unit test script will detect exception, we don't need to let test fail
when exception happened.
2019-03-19 21:06:16 +08:00
He Yin Ling 1b96cefaf8 tiny-test-fw: support translate backtrace in IDFDUT 2019-03-19 21:06:16 +08:00
He Yin Ling ef82e8d0bc tiny-test-fw: support detect exception in IDFDUT 2019-03-19 21:03:41 +08:00
zhiweijian d6bdaed141 Component/bt: fix no adv report when scanning with sleep enable 2019-03-18 17:40:19 +08:00
Angus Gratton 13018449fe Merge branch 'bugfix/remove_malloc_ble_prov_v3.2' into 'release/v3.2'
(backport v3.2) Protocomm BLE: Make changes in handling BLE read/write requests

See merge request idf/esp-idf!4495
2019-03-15 14:29:30 +08:00
Jiang Jiang Jian b6687e56ed Merge branch 'bugfix/console_allow_buffered_v3.2' into 'release/v3.2'
console example: use buffered stdout by default (backport v3.2)

See merge request idf/esp-idf!4507
2019-03-15 14:03:29 +08:00
Ivan Grokhotkov 6494927766 examples: don't enable buffering on stdout in console examples
newlib uses significantly more stack space when printing to an
unbuffered stream. To reduce the amount of stack space required to
use the console, don’t disable buffering. linenoise should support
unbuffered stdout instead.
2019-03-15 11:29:56 +08:00
Ivan Grokhotkov 6ce5c7668f console/linenoise: support buffered stdout 2019-03-15 11:29:56 +08:00
Jiang Jiang Jian c97a05c0d5 Merge branch 'feature/btdm_add_update_duplicate_scan_exceptional_list_apis_v3.2' into 'release/v3.2'
Component/bt: add update duplicate scan exceptional list APIs

See merge request idf/esp-idf!4494
2019-03-15 10:46:57 +08:00
zhiweijian fed772641a Component/bt: add update duplicate scan exceptional list APIs 2019-03-14 20:59:38 +08:00
Hrishikesh Dhayagude 39d8a89c80 Protocomm BLE: Make changes in handling BLE read/write requests
1. Remove unwanted malloc during BLE send response
2. Populate the missing parameters in the response - handle, offset, auth_req
2019-03-14 12:50:03 +05:30
Jiang Jiang Jian 62980ae995 Merge branch 'feature/btdm_add_adv_report_flow_control_v3.2' into 'release/v3.2'
component/bt: add vendor hci and adv report flow control (backport v3.2)

See merge request idf/esp-idf!4462
2019-03-14 13:51:52 +08:00
Angus Gratton 029a155a71 Merge branch 'bugfix/mdns_add_remove_multiple_srv_3.2' into 'release/v3.2'
mdns: fix possible crash if tx packet contained answer to removed service (backport 3.2)

See merge request idf/esp-idf!4481
2019-03-14 07:56:40 +08:00
Angus Gratton 4849d7ae90 Merge branch 'bugfix/mdns_incorrect_semaphore_use_v3.2' into 'release/v3.2'
mdns: use binary semaphore instead of mutex when searching (Backport 3.2)

See merge request idf/esp-idf!4478
2019-03-14 06:26:51 +08:00
David Cermak 10b4ddb467 mdns: fix possible crash when probing on particular interface with duplicated service instances due to naming conflicts on network
Issue: MDNS server initially sends probing packets to resolve naming confilicts with already registered service instances. In case of a conflict, instance name is altered and probing restarts. Original instance however wasnnot removed from the structure and upon service removal only one entry was removed and a dangling service might have been kept in the structure to bring about a crash.
Resolution: Keep only one instance of a service in the probing structure.

Closes IDF-438
2019-03-13 16:24:18 +01:00
David Cermak 288bc2bfca mdns: enable pcbs before starting service thread to avoid updating pcb's internal variables from concurent tasks
possible race condition: user task runs mdns_init, which enables pcbs while mdns-task already created could execute enable/disable of the same pcbs if an appropriate system event received
2019-03-13 16:24:03 +01:00
David Cermak 8e4ec90dc4 mdns: fix possible deadlock on mdns deinit calling mdns_free()
mnds_free() initiates stop and delete timer tasks, which after locking the mutex could lead to a dead lock in case timer task executed before deleting the task, as it would wait indefinitelly for unlocking the mutex. This condition is fixed by calling _mdns_stop_timer without locking the mutex, because there's no need to protect any data when stopping and deleting the timer task

Closes https://github.com/espressif/esp-idf/issues/1696
2019-03-13 16:24:03 +01:00
David Cermak 0e06b4d653 mdsn: fix race condition in updating packet data from user task when failed to allocate or queue a new service
Issue: mdns_service_add API allocates and queues an action to be processed in mdns task context; when allocation or queueing fails, allocated structure needs to be freed. Function _mdns_free_service did not only fee all the structures, but also updates packet data.
Resolution: Moved removal of packet data outside of _mdns_free_service function.
2019-03-13 16:24:03 +01:00
David Cermak 8fe4007dfa mdns: fix possible crash when packet scheduled to transmit contained service which might have been already removed
packets scheduled to transmit are pushed to action queue and removed from tx_queue_head structure, which is searched for all remaining services and while service is removed, then service questions/asnwers are also removed from this structure. This update fixes possible crash when packet is pushed to action queue, and when service is removed, its answers are removed from tx_queue_head, but not from action queue. this could lead to a crash when the packet is poped from action queue containing questions/answers to already removed (freed) service

Closes IDF-438
2019-03-13 16:24:03 +01:00
Ivan Grokhotkov 09f4015300 mdns: use binary semaphore instead of mutex when searching
mdns_search_once_t::lock is used to synchronize tasks (taken by one
task and given by the other) so it should not be a mutex.
Convert to semaphore, and rename to indicate its purpose.
2019-03-13 14:55:01 +01:00
Angus Gratton 56918682f9 Merge branch 'bugfix/confgen_expr_value_v3.2' into 'release/v3.2'
confgen: Fix bug with JSON metadata conditional range generation

See merge request idf/esp-idf!4470
2019-03-13 16:54:41 +08:00
Angus Gratton 6b49a355f7 confgen: Fix bug with JSON metadata conditional range generation
When generating JSON metadata for ranges where there are conditional ranges (ie different allowed range
depending on another config setting), the JSON metadata would always have the last named range as
the expression was not evaluated properly.

Thanks to ulfalizer on GitHub for pointing this out.

Closes https://github.com/espressif/esp-idf/issues/2195
2019-03-13 16:50:55 +11:00
zhiweijian 6628fddae6 Component/bt: add BLE adv report flow control 2019-03-12 20:18:30 +08:00
Krzysztof Budzynski ff99e0ea69 Merge branch 'feature/upgrade_sphinx_and_breathe_v3.2' into 'release/v3.2'
docs: Preparation for upgrade of Sphinx and Breathe packages to versions 1.8.4…

See merge request idf/esp-idf!4380
2019-03-12 16:53:11 +08:00
zwj b305a96a74 component/bt: add vendor hci cmd 2019-03-12 11:55:42 +08:00
Roland Dobai fe4e68132f docs: Update package dependencies
Closes https://github.com/espressif/esp-idf/issues/2384
2019-03-11 10:33:15 +01:00
Roland Dobai e870a0f0f1 tools: re-run idf.py in MSYS with winpty
This is done in order to cancel subprocesses on keyboard interrupt
(CTRL+C).
2019-03-11 08:54:44 +01:00
Jiang Jiang Jian 12643e063c Merge branch 'bugfix/autoip_memoey_leak_debug_v3.2' into 'release/v3.2'
fix the bug in auto Ip memory leak (backport v3.2)

See merge request idf/esp-idf!4431
2019-03-08 19:54:34 +08:00
Angus Gratton a7dc804476 Merge branch 'bugfix/httpd_sess_ctx_backportv3.2' into 'release/v3.2'
esp_http_server: Provide apps an option to let http_server ignore sess_ctx changes

See merge request idf/esp-idf!4421
2019-03-08 11:52:17 +08:00
aleks 7342811c37 freemodbus: change critical sections to semaphore mutex
revert changes made in mbrtu.c, mbascii.c
change critical section type to semaphore mutex instead of spin lock

Closes: https://github.com/espressif/esp-idf/issues/3009
2019-03-07 16:01:43 +01:00
xiehang 8e0b0af09b fix the bug in auto Ip memory leak 2019-03-06 20:01:36 +08:00
Jiang Jiang Jian e1e82c8949 Merge branch 'bugfix/lack_of_break_in_tcp_client_v3.2' into 'release/v3.2'
fix the bug in tcp_client (backport v3.2)

See merge request idf/esp-idf!4391
2019-03-06 14:22:59 +08:00
Angus Gratton d99d92e170 Merge branch 'bugfix/fix_dig_gpio_unable_hold_bug_v3.2' into 'release/v3.2'
Bugfix/fix digital gpio unable hold bug  (backport v3.2)

See merge request idf/esp-idf!4355
2019-03-06 12:10:38 +08:00
He Yin Ling 1ca67e98d6 test: fix CI UT job pass even ut app bootup fail 2019-03-05 07:58:39 +00:00
Piyush Shah f8f0c81077 esp_http_server: Provide apps an option to let http_server ignore sess_ctx changes
By default, if a URI handler changes the http session context,
the webserver internally clears the older context after the handler
returns. However, if applications want to change this behavior and
manage the allocation/de-allocation/freeing themselves and let the
server handle only the "socket close" case, this commit provides such
an option.
2019-03-05 13:06:33 +05:30
Angus Gratton 727c2cfa00 Merge branch 'feature/add_api_get_rmt_idle_level_v3.2' into 'release/v3.2'
Bugfix:  Fixed some RMT related issues (backport v3.2)

See merge request idf/esp-idf!4358
2019-03-05 10:51:00 +08:00
Roland Dobai 1d4eeeb464 VFS: Implement poll() based on select()
Closes https://github.com/espressif/esp-idf/issues/2945
2019-03-04 08:02:03 +01:00
Jiang Jiang Jian e9a764d9a5 Merge branch 'bugfix/make_get_coreid_volatile_backport_v3.2' into 'release/v3.2'
freertos: Make xPortGetCoreID() volatile (backport v3.2)

See merge request idf/esp-idf!4379
2019-03-01 18:49:00 +08:00
Jiang Jiang Jian b2e4af4ed0 Merge branch 'bugfix/ble_reconn_rescan_readv_crash_v3.2' into 'release/v3.2'
component/bt : fix bug that there's low ratio crash when BLE do re-connect/re-scan/re-adv

See merge request idf/esp-idf!4325
2019-03-01 18:06:02 +08:00
Darian Leung 66a0b64e54 freertos: Make xPortGetCoreID() volatile
When xPortGetCoreID() is called twice within a function,
it might only be called once after compilation. This
commit makes the inline assembly of the function volatile.

Closes #3093
2019-03-01 02:05:33 +00:00
Ivan Grokhotkov 9d48cdb6f3 Merge branch 'bugfix/multiple_backports_v3.2' into 'release/v3.2'
multiple backports (v3.2)

See merge request idf/esp-idf!4367
2019-02-28 21:42:19 +08:00
Jiang Jiang Jian 258e9c98be Merge branch 'bugfix/cmake_psram_fix_flag_v3.2' into 'release/v3.2'
cmake: Fix psram workaround compiler flag application (backport v3.2)

See merge request idf/esp-idf!4364
2019-02-28 21:06:11 +08:00
Angus Gratton 35e491856e ci: Only use "github_sync" tagged runners to talk to GitHub 2019-02-28 20:38:31 +08:00
Angus Gratton 226c790766 ci: Retry submodule sync 2 more times before failing 2019-02-28 20:38:31 +08:00
Ivan Grokhotkov c0d32f6e48 nvs: add a blob fragmentation test case
Ref. TW12937
2019-02-28 20:38:31 +08:00
Ivan Grokhotkov 203f75223e nvs: do eager cleanup of HashListBlocks
Previously when HashList was removing items, HashListBlocks were
removed lazily. This resulted in empty HashListBlocks dangling around
in full pages, even when all items have been erased. These blocks
would only be deleted when NVS was re-initialized
(nvs_flash_deinit/nvs_flash_init).

This change does eager cleanup instead, based on the code from
@negativekelvin offered in
https://github.com/espressif/esp-idf/issues/1642#issuecomment-367227994.

Closes https://github.com/espressif/esp-idf/issues/1642.
2019-02-28 20:38:31 +08:00
Ivan Grokhotkov 742f8e7f8a esp_timer: fix occasional failures in "monotonic values" test
1. ref_clock used in unit tests occasionally produces time off by ~100
microseconds shortly after being started. Add a delay to let
ref_clock stabilise, until the cause is found.

2. Reduce roundoff error accumulation which would occasionally cause
the test to fail, by choosing an overflow value which can be divided
by APB frequency.

3. Move time sampling part of the test into an IRAM function to
reduce variations due to cache behavior.

4. Remove calculation of "standard deviation" in the test, as what was
calculated was not actually standard deviation, and it did not add any
useful information.
2019-02-28 20:38:31 +08:00
Ivan Grokhotkov 7e16a79cf7 esp_timer: improve unit test robustness
1. call esp_timer_get_time and ref_clock_get in the same order on
   start and in the loop

2. disable interrupts when calculating delta between ref_clock
   and esp_timer

3. ensure both functions are in cache before calculating the delta
2019-02-28 20:38:31 +08:00
Ivan Grokhotkov 22dc4898d9 soc: define named constants for DPORT_CPUPERIOD_SEL values 2019-02-28 20:38:31 +08:00
Ivan Grokhotkov f78c96a3d7 bootloader: check previously used clock frequency at run time
In the situation when bootloader was compiled for 240MHz, and app was
compiled for 160MHz, and the chip is a revision 0 chip, the
bootloader will assume that the application has also been running at
240MHz. This will cause the chip to lock up later. Modify this to use
a run time check of DPORT_CPUPERIOD_SEL, which indicates which of the
PLL frequencies was used.

Closes https://github.com/espressif/esp-idf/issues/2731.
2019-02-28 20:38:31 +08:00
Ivan Grokhotkov b4727a8765 soc/rtc_clk: don’t clear DPORT_CPUPERIOD_SEL when switching to XTAL
This is not necessary since RTC_CNTL_SOC_CLK_SEL is set before this.
2019-02-28 20:38:31 +08:00
Ivan Grokhotkov 8bbd99ad9e make: fix issues related to EXTRA_COMPONENT_DIRS
1. When one of the COMPONENT_DIRS points to a component directory
(i.e. a directory containing component.mk, not a directory of multiple
components), and there is a subdirectory in it which also contains
a component, the subdirectory was mistakenly added to the list of
components and compiled.

For example:

    main/
        component.mk
        main.c
        test/
            component.mk
            test_main.c

Would compile test_main.c and link libtest.a.

2. When one of the COMPONENT_DIRS points to a component directory, and
the parent directory contained a directory with the same name as
another component, that directory would be mistakenly added to the
COMPONENT_PATHS.

For example:

    esp/
        esp-idf/
        esp32/
            (random stuff)
        mycomponent/
            component.mk
            mycomponent.c
        myproject/
            main/
            Makefile

and Makefile sets EXTRA_COMPONENT_DIRS=$(realpath ../mycomponent),
then "esp32" directory which is at the same level as mycomponent
was added to COMPONENT_PATHS.

3. If EXTRA_COMPONENT_DIRS pointed to a directory with a list of
components, and one of the subdirectories was not a component, but
had the same name as another component, than that directory would be
mistakenly added to COMPONENT_PATHS instead of the real esp32
component directory.

For example:

    my_components/
        my_component/
            component.mk
            my_component.c
        esp32/
            (some random stuff)

and EXTRA_COMPONENT_DIRS would point to my_components/, then "esp32"
directory would be added to COMPONENT_PATHS instead of the real esp32
component directory.
2019-02-28 20:38:31 +08:00
Ivan Grokhotkov 5dcdef0639 kconfig: fix compatibility with very old versions of flex
See 4e762e4918

Closes https://github.com/espressif/esp-idf/issues/2703
2019-02-28 20:38:31 +08:00
xiehang d651ee3d28 fix the bug in tcp_client
Closes https://github.com/espressif/esp-idf/issues/3058
2019-02-28 14:25:54 +08:00
XiaXiaotian 34f1c208a8 esp32: modify WiFi Kconfig in order to achieve better compatility
and performance
2019-02-28 10:07:13 +08:00
Angus Gratton 83d7b4591c Merge branch 'esp_http_server/lru_counter_for_timestamp_backportv3.2' into 'release/v3.2'
esp_http_server/lru_counter_for_timestamp:Added LRU counter for timer(backport v3.2)

See merge request idf/esp-idf!4319
2019-02-28 07:03:38 +08:00
krzychb f5096892f9 docs: Preparation for upgrade of Sphinx and Breathe packages to versions 1.8.4 and 4.11.1. Updated check of Sphinx warnings to account for the filename instead of the whole path, that for the same errors may be different between English and Chinese docs. (backport v3.2) 2019-02-27 23:21:47 +01:00
Angus Gratton 56694fb4b6 cmake: Fix psram workaround compiler flag application
Previously, this compiler flag was not being applied
regardless of CONFIG_SPIRAM_CACHE_WORKAROUND setting.

Explanation: add_compile_options() only applies to
source files added after the function is run, or in
subdirectories added after the function is run. In
this case, no new source files were being added after
this function was run.
2019-02-27 16:38:29 +11:00
Paul Abbott 929542d4fa driver(rmt): Fixed some RMT related issues.
1. Add missing get function to RMT API: rmt_get_idle_level().
2. Suppress error message from rmt_wait_tx_done() if wait_time==0 (allows for polling).
3. Remove the blank lines between parameter lists.

Merges https://github.com/espressif/esp-idf/pull/2666
2019-02-26 20:46:23 +08:00
kooho be49c8d841 driver(gpio): fixed digital gpio unable hold bug during deep-sleep for release/v3.2. 2019-02-26 20:20:25 +08:00
Tian Hao 67aefe1011 component/bt : fix bug that there's low ratio crash when BLE do re-connect/re-scan/re-adv
fix 3 bugs:
1. do BLE connect (both of slave and master), it mgiht cause crash due to there's much interrupts happens effect ble code running, for example, wifi run on the same core as bluetooth controller and wifi run throughtput test.
2. do BLE scan stop or adv stop or connection stop, it might cause ASSERT or crash due to memory corrupted in controller memory poll.
3. minor bug fix, not really effect bluetooth.
2019-02-25 13:40:46 +00:00
zhiweijian 46a3c36343 Component/bt: add scan window and interval check when set scan params 2019-02-25 13:22:32 +00:00
Supreet Deshpande 58e49d169c esp_http_server/lru_counter_for_timestamp:Added LRU counter for timer
Replaced the os timer in http server by LRU counter. The timestamp is
unnecessary for LRU.
2019-02-25 09:16:28 +00:00
Ivan Grokhotkov a241f95407 Merge branch 'bugfix/freertos_unused_xSize_backport_v3.2' into 'release/v3.2'
freertos: Fix unused variable warning (backport v3.2)

See merge request idf/esp-idf!4296
2019-02-25 15:44:22 +08:00
Darian Leung aaaa491c42 freertos: Fix unused variable warning
This commit fixes an unused variable warning when
configASSERT is undefined.
2019-02-22 01:06:44 +08:00
Angus Gratton 91aa35e831 Merge branch 'bugfix/mdns_service_memory_leak_3.2' into 'release/v3.2'
mdns: fix memory leak when query for service plus various other fixes (Backport v3.2)

See merge request idf/esp-idf!4287
2019-02-21 17:53:32 +08:00
David Cermak 113e829552 mdns: fix memory leak in pbuf if tcpipadapter failed to get netif 2019-02-21 06:43:23 +00:00
David Cermak 3802fddefb mdns example: fix print result for IPv6 addresses 2019-02-21 06:43:23 +00:00
David Cermak bb2eb9adeb mdns: fix malfuctional query_txt
when running a query for a single txt, result entries were not created and attached to result structure. this issue was introduced when fixing memory leak in txt structure, which worked correctly for PTR queries, but caused trouble for TXT query.
2019-02-21 06:43:23 +00:00
David Cermak 78116afa01 mdns: fix possible crash when mdns_free called while action queue not empty 2019-02-21 06:43:23 +00:00
David Cermak b865e72aec mdns: fix memory leak when query for service receives multiple ptr entries for one instance
fixes redmine issue 27300
2019-02-21 06:43:23 +00:00
Angus Gratton f1b2457b6c Merge branch 'bugfix/psram_move_qsort_setlocale_flash_v3.2' into 'release/v3.2'
psram: Move newlib qsort() and setlocale() functions from IRAM to flash (backport v3.2)

See merge request idf/esp-idf!4322
2019-02-21 14:42:17 +08:00
Jiang Jiang Jian 46fa5654a7 Merge branch 'bugfix/btdm_fix_connection_params_update_issues_v3.2' into 'release/v3.2'
component/bt:fix connection params update issues (backport v3.2)

See merge request idf/esp-idf!4297
2019-02-21 11:49:16 +08:00
Angus Gratton bf28a1a27b psram: Move newlib qsort() and setlocale() functions from IRAM to flash 2019-02-21 10:32:00 +11:00
Angus Gratton b7beefba9e Merge branch 'bugfix/cmake_stack_protector_v3.2' into 'release/v3.2'
esp32: disable stack protector for startup code (CMake) (backport v3.2)

See merge request idf/esp-idf!4250
2019-02-20 15:40:14 +08:00
Angus Gratton 0784c52131 Merge branch 'doc/add_coap_readme' into 'release/v3.2'
doc: add CoAP README.md(backport v3.2)

See merge request idf/esp-idf!4262
2019-02-20 15:38:43 +08:00
Angus Gratton a7f826750b Merge branch 'revert-00d10688' into 'release/v3.2'
Revert "Merge branch 'bugfix/external_rtc_start_fail_3.2' into 'release/v3.2'"

See merge request idf/esp-idf!4293
2019-02-20 15:09:59 +08:00
Angus Gratton 38086ae737 Merge branch 'bugfix/spiram_linker_wildcards_v3.2' into 'release/v3.2'
esp32 psram: Provide library name for ROM libc objects linked as PSRAM workarounds (backport v3.2)

See merge request idf/esp-idf!4153
2019-02-20 14:17:52 +08:00
Jiang Jiang Jian 6173660ff0 Merge branch 'bugfix/coex_lc_protect_v3.2' into 'release/v3.2'
component/esp32 : fix coexist lc protect cause memory corrupted

See merge request idf/esp-idf!4267
2019-02-20 11:14:22 +08:00
Angus Gratton 79b450cfb4 esp32 psram: Provide library name for ROM libc objects linked as PSRAM workarounds
Fixes bug reported on forums where any source file ending in *lock.c or *creat.c
was being linked to IRAM.

https://esp32.com/viewtopic.php?f=13&t=8909&p=37362#p37362
2019-02-20 00:30:25 +00:00
Jiang Jiang Jian c7fbc6dd85 Merge branch 'bugfix/wdt_compability_app_with_old_bootloader_v3.2' into 'release/v3.2'
esp32: Fix wdt settings in esp_restart_noos (backport v3.2)

See merge request idf/esp-idf!4294
2019-02-20 02:17:09 +08:00
Jiang Jiang Jian 3b5bba1812 Merge branch 'bugfix/fix_psram_eid_v3.2' into 'release/v3.2'
bugfix(psram): fix psram size acquisition method, support esp32-pico chips (backport v3.2)

See merge request idf/esp-idf!4254
2019-02-20 02:13:47 +08:00
zwj b4feb67b5f component/bt:fix connection params update issues 2019-02-19 20:26:36 +08:00
Jiang Jiang Jian 578d7902af Merge branch 'bugfix/btdm_crash_when_inquiry_cancel_v3.2' into 'release/v3.2'
Bugfix/btdm crash when inquiry cancel v3.2

See merge request idf/esp-idf!4277
2019-02-19 17:57:00 +08:00
Ivan Grokhotkov 509884c5ac Revert "Merge branch 'bugfix/external_rtc_start_fail_3.2' into 'release/v3.2'"
This reverts merge request !4272
2019-02-19 12:47:44 +08:00
Konstantin Kondrashov 8a656f006e esp32: Fix wdt settings in esp_restart_noos
Fixed compatibility the new apps with the old bootloaders.

Closes: https://github.com/espressif/esp-idf/issues/2927
2019-02-19 12:43:35 +08:00
Angus Gratton 0f79c72704 Merge branch 'bugfix/aws_iot_backport_few_fixes_for_v3.2' into 'release/v3.2'
Bugfix/aws iot backport few fixes for v3.2 (backport_v3.2)

See merge request idf/esp-idf!4247
2019-02-19 11:36:18 +08:00
Tian Hao 6d6f71bbae component/esp32 : fix coexist lc protect cause memory corrupted
The bug will cause memory corrupted (the largest range is from 0x3ffc0000 ~ 0x3ffc8000),
some strange error will happen, like IllegalInstruction, LoadProhibited and .etc.
2019-02-19 03:30:02 +00:00
Angus Gratton 332ccd0925 Merge branch 'feature/provisioning_backport_api_changes' into 'release/v3.2'
(backport v3.2)  Provisioning Framework API changes

See merge request idf/esp-idf!4249
2019-02-19 10:47:47 +08:00
Anurag Kar 2ee1c6fd3e provisioning examples : typos fixed and minor change in timer callback execution
Note : Examples have been updated to prevent invocation of bluedroid/wifi APIs from inside timer callback when stopping provisioning. Workaround is to spawn new task from inside the timer callback.
2019-02-18 08:18:44 +00:00
Anurag Kar 6a328992d7 protocomm : typos fixed and descriptions corrected 2019-02-18 08:18:44 +00:00
Anurag Kar b51f109dd7 protocomm unit_tests : test cases updated
Changes:
* Version endpoint test added
* Memory leak test updated to include corner case exceptions in protocomm
2019-02-18 08:18:44 +00:00
Anurag Kar 85e8dea26a protocomm security : memory leaks fixed
List of changes:
* Corner case exceptions are properly handled to ensure release of memory occupied by security infrastructure
* fixed erroneous cleanup of security instance by protocomm_console
2019-02-18 08:18:44 +00:00
Anurag Kar 093c7b176d protocomm : version endpoint behavior simplified
List of changes:
* Version endpoint now sends the set version string instead of verifying the incoming version string. This simplifies fetching version info from the provisioning application.
* esp_prov script updated to expect version string as response.
2019-02-18 08:18:44 +00:00
Anurag Kar 30e39631db wifi_provisioning : context pointer added to wifi_config_t structure and related examples/docs updated
Closes https://github.com/espressif/esp-idf/issues/2874
2019-02-18 08:18:44 +00:00
Anurag Kar a7ff611b10 provisioning framework : 'extern C' directives added for C++ support 2019-02-18 08:18:44 +00:00
Piyush Shah 2e64d2d56e softap_prov: Changes in the example code as per changes to protocomm_httpd
Signed-off-by: Piyush Shah <piyush@espressif.com>
2019-02-18 08:18:44 +00:00
Piyush Shah 3e6b402756 protocomm_httpd: Allow applications to pass HTTPD handle
This will be useful if a webserver is already running and the application
does not want protocomm to start a new instance.

Signed-off-by: Piyush Shah <piyush@espressif.com>
2019-02-18 08:18:44 +00:00
baohongde 5568ca2855 components/bt: Add precautions for esp_vhci_host_send_packet (backport 3.2) 2019-02-18 08:15:17 +00:00
baohongde 30f2371917 components/bt: Fix crash when inquiry stop (backport v3.2) 2019-02-18 08:15:17 +00:00
He Yin Ling ebaa944a9a Merge branch 'test/disable_sdio_example_ci_v3.2' into 'release/v3.2'
sdio: temporarily disable the sdio example ci

See merge request idf/esp-idf!4284
2019-02-18 16:14:01 +08:00
Michael (XIAO Xufeng) d83598a64a sdio: temporarily disable the sdio example ci, since the runners have
some power issue
2019-02-18 11:02:43 +08:00
Ivan Grokhotkov 00d1068869 Merge branch 'bugfix/external_rtc_start_fail_3.2' into 'release/v3.2'
Bugfix/external rtc start fail (backport 3.2)

See merge request idf/esp-idf!4272
2019-02-15 17:51:49 +08:00
chenwu 49be9fb836 doc: add CoAP README.md 2019-02-15 16:03:54 +08:00
Jiang Jiang Jian 6f0c70daf6 Merge branch 'bugfix/bugfix/mdns_notask_timer_crash_v3.2' into 'release/v3.2'
mdns: fix crash after init if no memory for task (Backport 3.2)

See merge request idf/esp-idf!4237
2019-02-15 13:49:29 +08:00
Jiang Jiang Jian 219c85cf60 Merge branch 'bugfix/btdm_allow_a2dp_codec_dynamic_allocated_for_v3.2' into 'release/v3.2'
bugfix/btdm_allow_a2dp_codec_dynamic_allocated_for_v3.2(backport v3.2)

See merge request idf/esp-idf!4260
2019-02-15 13:42:39 +08:00
Jiang Jiang Jian 524696d59a Merge branch 'bugfix/fix_some_wifi_bugs_0131_v3.2' into 'release/v3.2'
esp32: fix some WiFi bugs (backport v3.2)

See merge request idf/esp-idf!4217
2019-02-15 12:14:54 +08:00
maojianxin 9a229f4077 soc/rtc: fix RTC_TOUCH_TRIG_EN or RTC_ULP_TRIG_EN should keep RTC_PERIPH power on 2019-02-15 10:58:14 +08:00
Zhang Jun Yi 016c8d8b05 soc/rtc: Bypass touchpad current to external 32k crystal oscillator 2019-02-15 10:55:08 +08:00
Angus Gratton 9914b839aa Merge branch 'update/nvs_partition_utility_v3.2' into 'release/v3.2'
Update/nvs partition utility v3.2 (backport v3.2)

See merge request idf/esp-idf!4258
2019-02-15 08:51:17 +08:00
Shivani Tipnis 76e4ea7f68 nvs_util: Fix to support write of multiple singlepage big blob data
Closes https://github.com/espressif/esp-idf/issues/3011

(cherry picked from commit ce4944edf01b2a4c997eafe36b66d71f98f2fe29)
2019-02-14 18:05:59 +05:30
Shivani Tipnis 3ec0f415a5 nvs_util: Fix to support write of multiple singlepage big blob data Closes https://github.com/espressif/esp-idf/issues/3011
(cherry picked from commit 21688e3bffee80ddfbef5364a44dd1821e28c776)
2019-02-14 15:57:23 +05:30
Shivani Tipnis fa40b3d5d0 Update minimum version for cryptography package required
(cherry picked from commit e1774cb6f9)
2019-02-13 17:20:01 +05:30
Shivani Tipnis f742808333 nvs_util: update test case
(cherry picked from commit 0c72b08872)
2019-02-13 17:12:57 +05:30
Shivani Tipnis 51bd64c754 Update README
(cherry picked from commit 582c547191)
2019-02-13 17:12:50 +05:30
Shivani Tipnis b85321be97 Closes https://github.com/espressif/esp-idf/issues/2472
(cherry picked from commit c44f15441f)
2019-02-13 17:12:40 +05:30
Shivani Tipnis dcd63f73f6 nvs_util: Add changes to nvs part gen util
nvs_util: Add changes to nvs part gen util

nvs_host_test: Add test case for keygen and keyfile paratmeters

(cherry picked from commit 9db1987892)
2019-02-13 17:11:59 +05:30
wangmengyang b8f0c32a0a component/bt: allow dynamic allocation of SBC encoder/decoder buffer used in A2DP to save internal DRAM 2019-02-13 19:15:34 +08:00
chenjianqiang 8f2e1471af bugfix(psram): made some modifcations to support the psram driver backport 2019-02-13 16:06:38 +08:00
chenjianqiang a159e58ead feature(psram): add psram support for esp32-pico chip
1. esp32-pico use standard spi driver to access psram
2. for esp32-pico, flash and psram share the clock
3. for esp32-pico, psram cs io can be overwrite via menuconfig
2019-02-13 14:27:44 +08:00
chenjianqiang fe767855df bugfix(psram): fix psram size acquisition method
1. Use BIT[7:5] of EID to determine psram size
2. Add ID support for 16Mbit psram
3. Remove module reset on SPI1
4. Confirmed with the vendor that only the old 32Mbit psram need special clock timing. For other psram chips, we should use standard QPI mode.
2019-02-13 14:24:20 +08:00
Ivan Grokhotkov 1e674fb4ed esp32: disable stack protector for startup code (CMake)
Files where stack protector is initialized should not be compiled with
stack protector enabled. This was done for Make but missing for CMake.

Fixes https://github.com/espressif/esp-idf/issues/2990.
2019-02-13 10:27:22 +08:00
Angus Gratton 3660ccac4c Merge branch 'bugfix/esp-http-client-fixes' into 'release/v3.2'
Minor Bugfixes in esp_http_client, tcp_transport and simple_ota_example. (backport v3.2)

See merge request idf/esp-idf!4248
2019-02-13 07:10:34 +08:00
Jitin George 4f9a4e8ed7 examples/simple_ota_example: Fix incorrect component reference in README 2019-02-12 11:32:54 +05:30
Jitin George 582bf18789 tcp_transport: Fix incorrect error logging in ssl_read and ssl_write APIs
Closes https://github.com/espressif/esp-idf/issues/2805
2019-02-12 11:32:44 +05:30
Jitin George 2e3f06ece8 esp_http_client: Fix for setting incorrect post header length
Closes https://github.com/espressif/esp-idf/issues/2638
2019-02-12 11:32:23 +05:30
Mahavir Jain c62a20f162 ci: remove IDF_CI_BUILD variable, no active users 2019-02-12 11:03:40 +05:30
Mahavir Jain ed4d83af8e examples: aws_iot: fix cmake build issue which used to pick dummy certificates
For CI build now `sdkconfig.ci` file is used which builds examples assuming certificate
stored on SDCard.
2019-02-12 11:03:14 +05:30
Angus Gratton 1444868917 Merge branch 'bugfix/eth_gpio0_output_v3.2' into 'release/v3.2'
ethernet cleanup && support GPIO0 output mode && support IP101(backport v3.2)

See merge request idf/esp-idf!4214
2019-02-12 07:54:57 +08:00
Mahavir Jain 05ba4f15d6 examples: update default root-ca for aws_iot demos 2019-02-08 18:54:01 +05:30
Angus Gratton 37b7153c0e Merge branch 'feature/http_server_backport_api_changes' into 'release/v3.2'
(backport v3.2) HTTP Server API changes

See merge request idf/esp-idf!4232
2019-02-08 11:43:33 +08:00
David Cermak 1a53334843 mdns: fix crash after init if no memory for task
mdns init first starts timer task, then starts service task. if service task failed to be created, timer task needs to be stopped too.
fixed https://ezredmine.espressif.cn:8765/issues/28466
2019-02-05 07:59:38 +01:00
Angus Gratton fd29b0165f Merge branch 'bugfix/event_loop_library_memory_leak_v3.2' into 'release/v3.2'
Fix event loop library memory leak (backport v3.2)

See merge request idf/esp-idf!4221
2019-02-04 16:35:17 +08:00
Anurag Kar 9c3262f80b esp_http_server : APIs renamed and context get/set implementations fixed
* http_sess_set_*_override APIs are now the only ones available to set custom recv/send/pending functions
* Fixed side effects to using http_sess_set/get_context inside URI handlers
2019-02-03 21:50:35 +05:30
Anurag Kar 900dbfd1f6 esp_http_server example tests : updated advanced_tests as per API changes 2019-02-03 21:32:21 +05:30
Ondřej Hruška 13a1f4ed78 esp_http_server improvements to allow adding transport layer encryption
Changes:
- renamed `httpd_free_sess_ctx_fn_t` to `httpd_free_ctx_fn_t`
- added a `httpd_handle_t` argument to `httpd_send_func_t` and `httpd_recv_func_t`
- internal function `httpd_sess_get()` is no longer static, as it's used in other
  files besides httpd_sess.c

Bug fixes:
- removed a trailing semicolon from `HTTPD_DEFAULT_CONFIG()`
- fixed issue with failed `select()`, now it automatically closes invalid sockets
  instead of shutting down the entire server

New features:
- `httpd_resp_send()` and `httpd_resp_send_chunk()` now accept -1 as length to use
  `strlen()` internally
- added `httpd_sess_set_ctx()` to accompany `httpd_sess_get_ctx()`
- added a "transport context" to the session structure (next to user context)
- added `httpd_sess_{get,set}_transport_ctx()` to work with this transport context
- added "global user context" and "global transport context" stored in the server
  config (and then the handle); supports a user-provided free_fn
- added a "pending func" to e.g. check for data in the transport layer receive
  buffer
- added functions `httpd_set_sess_{send,recv,pending}_override()` that target
  a session by ID (i.e. not using a request object)
- added `httpd_set_pending_override()`
- added a "open_fn" and "close_fn" - functions called when creating and closing
  a session. These may be used to set up transport layer encryption or some other
  session-wide feature
2019-02-03 21:32:07 +05:30
Jiang Jiang Jian 8a69ffc36f Merge branch 'bugfix/btdm_add_handle_in_gatts_conf_event_for_indication_v3.2' into 'release/v3.2'
Component/bt: add handle in gatts conf event for indication (backport v3.2)

See merge request idf/esp-idf!4222
2019-02-01 21:34:05 +08:00
Jiang Jiang Jian a437e4dc5c Merge branch 'bugfix/btdm_fix_write_char_crash_after_disconnection_v3.2' into 'release/v3.2'
Component/bt: fix write char crash after disconnection (backport v3.2)

See merge request idf/esp-idf!4210
2019-02-01 21:28:29 +08:00
Liu Zhi Fu 741f97da4e esp32: fix some WiFi bugs
Fix following WiFi bugs:
1. Fix a crash bug which is caused by WiFi static TX buffer alloc/free.
2. Fix the bug that iphone fails to connect to ESP32 AP by enabling AP BAR receiving.
3. Fix the bug that ESP32 station fails to connect some APs, such as Xiaomi hotspot etc,
   after reset.
2019-02-01 11:52:40 +08:00
Renz Christian Bagaporo eae2baa0f1 esp_event: detect leaks in unit test 2019-02-01 10:08:50 +08:00
Renz Christian Bagaporo f49f5ff35a esp_event: fix post data type inconsistency 2019-02-01 10:08:50 +08:00
Renz Christian Bagaporo 020b295f06 esp_event: fix memory leaks
Closes https://github.com/espressif/esp-idf/issues/2886
2019-02-01 10:08:50 +08:00
Jiang Jiang Jian 6e14de0fa8 Merge branch 'mesh/malloc_routing_table_v3.2' into 'release/v3.2'
mesh: modify to malloc routing table (backport v3.2)

See merge request idf/esp-idf!4178
2019-02-01 10:02:24 +08:00
zhiweijian 95c7f45e84 Component/bt: add handle in gatts conf event for indication 2019-01-31 20:30:23 +08:00
zhiweijian 651a08f710 Component/bt: fix write char crash after disconnection 2019-01-31 12:20:16 +00:00
morris 18cb87b4ce ethernet: support new PHY (IP101)
1. Add support for new PHY IP101.
2. Re-enable GPIO0 output mode.
3. Clean up some docs.
2019-01-31 15:02:45 +08:00
He Yin Ling 1fedece94d Merge branch 'feature/add_ipv6_related_change_v3.2' into 'release/v3.2'
modify test case to support ipv6 (backport v3.2)

See merge request idf/esp-idf!4074
2019-01-31 14:31:44 +08:00
qiyuexia 137810915c mesh: modify to malloc routing table 2019-01-31 13:46:50 +08:00
Jiang Jiang Jian bb766355b5 Merge branch 'bugfix/tw28445_wps_thread_safe_v3.2' into 'release/v3.2'
esp32: fix WPS thread-safe (backport v3.2)

See merge request idf/esp-idf!4195
2019-01-30 17:50:33 +08:00
Ivan Grokhotkov 807ef53c38 Merge branch 'bugfix/mdns_crash_free_strdup_3.2_fix' into 'release/v3.2'
mdns: fixed crash on free undefined ptr if strdup is skipped (Backport 3.2 FIX)

See merge request idf/esp-idf!4197
2019-01-30 14:24:12 +08:00
Angus Gratton e585121011 Merge branch 'bugfix/backtrace_from_interrupts_backport_v3.2' into 'release/v3.2'
Make backtrace work across interrupts (backport v3.2)

See merge request idf/esp-idf!4183
2019-01-30 13:11:29 +08:00
Angus Gratton 671be20cc5 Merge branch 'bugfix/regenerate_sdkconfig_fails_v3.2' into 'release/v3.2'
Fix issues with regenerating sdkconfig on modification (backport v3.2)

See merge request idf/esp-idf!4169
2019-01-30 09:27:47 +08:00
Renz Christian Bagaporo 022a9295b0 confgen: disable config override warnings 2019-01-29 20:50:51 +08:00
Renz Christian Bagaporo a34d788a5e kconfiglib: allow disabling of config override warnings
Patches ESP-IDF copy of kconfiglib.py with modifications in commit
b65baa47f69ae4c3993876a7edf0da0075aa70ff from kconfiglib repository.
2019-01-29 20:50:51 +08:00
Liu Zhi Fu 2a47c5c7a4 esp32: fix WPS thread-safe
Fix WPS thread-safe bug
2019-01-29 19:44:24 +08:00
Jiang Jiang Jian cfc4f74b52 Merge branch 'bugfix/coex_update_phy_to_fix_interrupt_wdt_v3.2' into 'release/v3.2'
esp32: update libphy.a to fix interrupt watchdog when WiFi and BT run at the same time and both enable modem sleep (backport v3.2)

See merge request idf/esp-idf!4192
2019-01-29 19:41:36 +08:00
David Cermak 43a722f0de mdns: fixed crash on free undefined ptr after skipped strdup
Shortcircuit evaluation may cause skip of _mdns_strdup_check of any further question field, which after clear_rx_packet freed undefined memory.
Fixes https://ezredmine.espressif.cn:8765/issues/28465
2019-01-29 10:34:04 +01:00
XiaXiaotian eff24857bc esp32: update libphy.a to fix interrupt watchdog when WiFi and BT run at
the same time and both enable modem sleep
2019-01-29 11:05:15 +08:00
Ivan Grokhotkov 18118a6d5c Merge branch 'bugfix/mdns_crash_free_strdup_3.2' into 'release/v3.2'
mdns: fixed crash on free undefined ptr if strdup is skipped (Backport 3.2)

See merge request idf/esp-idf!4190
2019-01-29 10:37:25 +08:00
David Cermak 64757c0228 mdns: fixed crash on free undefined ptr after skipped strdup
Shortcircuit evaluation may cause skip of _mdns_strdup_check of any further question field, which after clear_rx_packet freed undefined memory.
Fixes https://ezredmine.espressif.cn:8765/issues/28465
2019-01-28 20:17:37 +01:00
Darian Leung bab80ad202 freertos: Make backtrace work across interrupts (backport v3.2)
This commit adds the ability for backtracing to trace from the itnerrupt to the
task stack, and across nested interrupts. Test cases have also been added.

See MR !4084
2019-01-29 02:22:04 +08:00
Jiang Jiang Jian 76f0dda3a4 Merge branch 'mesh/bugfix_backport_v3.2' into 'release/v3.2'
Mesh/bugfix backport v3.2

See merge request idf/esp-idf!4117
2019-01-28 14:05:51 +08:00
huchaoru ce9878ce71 modify test case to support ipv6 2019-01-26 13:03:35 +00:00
Renz Christian Bagaporo 403a24ab64 confgen: disable redundant assignment warning 2019-01-25 18:49:55 +08:00
Renz Christian Bagaporo d2cf266762 kconfiglib: allow disabling of redundant definition warnings
Patches ESP-IDF copy of kconfiglib.py with modifications in commit
94c63de77c7a3422347e59e168b05174d0b9e84d from kconfiglib repository.
2019-01-25 18:49:55 +08:00
KonstantinKondrashov cec39b750a tool: Add unit test for Kconfig gen 2019-01-25 14:11:35 +08:00
Renz Christian Bagaporo 0420f290a4 docs: remove invalid arg in confgen invocation on docs generation 2019-01-25 14:11:35 +08:00
Renz Christian Bagaporo eb6dbeb15a cmake: only generate sdkconfig on top level project 2019-01-25 14:11:35 +08:00
Renz Christian Bagaporo 5c9ab21d81 confgen: base config creation on output type args 2019-01-25 14:11:35 +08:00
Jiang Jiang Jian bab379faf8 Merge branch 'bugfix/i2c_master_clear_bus_v3.2' into 'release/v3.2'
i2c/fix i2c_master_clear_bus (backport v3.2)

See merge request idf/esp-idf!4127
2019-01-25 13:52:48 +08:00
Jiang Jiang Jian fb7cd2a7a7 Merge branch 'bugfix/ble_active_scan_not_wait_scan_rsp_v3.2' into 'release/v3.2'
component/bt: add a option to make report adv data and scan response individually (backport v3.2)

See merge request idf/esp-idf!4157
2019-01-25 13:52:16 +08:00
Ivan Grokhotkov c208a6b451 Merge branch 'bugfix/mqtt_tests_local_broker_v3.2' into 'release/v3.2'
MQTT tests: connect to local broker in CI (Backport 3.2)

See merge request idf/esp-idf!4119
2019-01-24 22:00:26 +08:00
Tian Hao 78511c3cc3 component/bt: add a option to make report adv data and scan response individually
Originally, when doing BLE active scan, Bluedroid will not report adv to
application layer until receive scan response. This option is used to
disable the behavior. When enable this option, Bluedroid will report
adv data or scan response to application layer immediately.
2019-01-24 14:43:36 +08:00
Jiang Jiang Jian cd6bbaa727 Merge branch 'bugfix/bootloader_map_size_v3.2' into 'release/v3.2'
bootloader: fix incorrect mapping size (backport v3.2)

See merge request idf/esp-idf!4138
2019-01-24 14:09:35 +08:00
Jiang Jiang Jian 55b8f2ea8c Merge branch 'bugfix/sha_ownership_v3.2' into 'release/v3.2'
hwcrypto sha: Allow SHA contexts to be shared between tasks (backport v3.2)

See merge request idf/esp-idf!4143
2019-01-24 14:08:35 +08:00
qiyueixa ec2f1a6b9a test: modify the reason code from 204 to 15 in WIFI_CONN_0904 2019-01-24 11:33:06 +08:00
qiyueixa 26646b5b31 mesh: bugfix
1. fix network channel switch function.
2. support not configuring the network channel.
3. support not configuring the router BSSID even if the router is hidden.
4. add allow_channel_switch to mesh configuration.
5. add allow_router_switch to mesh router configuration.
6. support handling beacon without IE of DS Parameter Set.
7. fix Wi-Fi RX fails in a specific scenario (update libphy.a).
8. fix STAs can not detect disconnection from AP when encrypt transmission is used.
9. fix can not find hidden APs.
10. for root, modify the active scan time to 120ms.
11. remove all rc when clear parent Wi-Fi configuration.
12. fix memory leak caused by the remove announcement being sent is not released when esp_mesh_stop() is called.
13. fix modify IE encrypt after mesh is started.
14. ignore esp_mesh_connect() if mesh automatic reconnection is enabled.
15. fix reason is cleared before vote is done.
16. fix issues in the example of manual_networking when mesh network is encrypted.
17. detect and fix root conflicts when router BSSID is not set.
18. when root can not connect to the router due to NO_MORE_STAS(reason code:5), root will stop re-connection and perform MESH_NWK_LOOK_FOR_NETWORK.
19. wifi: fix the disconnection caused by receiving a deauth frame from non-parent node during scanning.
20. fix routing table redundant issue due to the remove announcement is not 100% reliable.
21. modify the max routes limitation from 300 to 1000.
22. wifi: fix ap does not deauth the sta which has not yet completed the 4-way handshake but the max replay count is reached.
2019-01-24 11:31:00 +08:00
Jiang Jiang Jian 1ae9a2ae0b Merge branch 'bugfix/wifi_fix_invalid_csi_data_index_v3.2' into 'release/v3.2'
esp32: fix invalid channel state information(CSI) data index (backort v3.2)

See merge request idf/esp-idf!4129
2019-01-23 22:14:04 +08:00
Jiang Jiang Jian 28eb488892 Merge branch 'bugfix/vfs_unregister_nested_v3.2' into 'release/v3.2'
vfs: fix unregister removing top level VFS instead of nested (backport v3.2)

See merge request idf/esp-idf!4137
2019-01-23 21:54:50 +08:00
Jiang Jiang Jian fcf1dba9cd Merge branch 'bugfix/init_memctl_v3.2' into 'release/v3.2'
bootloader, esp32: add workaround for Tensilica erratum 572 (backport v3.2)

See merge request idf/esp-idf!4134
2019-01-23 21:43:58 +08:00
Angus Gratton 94ed7b8298 hwcrypto sha: Use spinlocks instead of semaphores for small state changes
Significant performance improvement and smaller RAM footprint.
2019-01-23 18:18:13 +08:00
Angus Gratton 24fab0b7a9 hwcrypto sha: Allow SHA contexts to be shared between tasks
Previously, hardware SHA engine "locks" were mutex semaphores. This meant that the task which
started a particular SHA session (in hardware) needed to finalise that session, or an invalid
FreeRTOS state was created.

Replace with binary semaphore which can be shared between tasks.

Includes a unit test, but unit test doesn't crash even without this fix
(some other unknown condition is required).
2019-01-23 18:18:13 +08:00
Angus Gratton c4c1af114e Update esptool.py to v2.6 2019-01-23 17:02:02 +08:00
Ivan Grokhotkov b1ee25afde bootloader: account for load address when mapping cache pages
Bootloader used to calculate the number of cache pages assuming that
load address was aligned, while in reality load address for DROM and
IROM was offset by 0x20 bytes from the start of 64kB page. This
caused the bootloader to map one less page if the size of the image
was 0x4..0x1c less than a multiple of 64kB.

Reported in https://esp32.com/viewtopic.php?f=13&t=6952.
2019-01-23 17:02:02 +08:00
Ivan Grokhotkov cccaa68467 bootloader: fix IROM and DROM swapped in log messages 2019-01-23 17:02:02 +08:00
Ivan Grokhotkov 6080767379 vfs: fix unregister removing top level VFS instead of nested
Credits @neoniousTR.

Fixes https://github.com/espressif/esp-idf/pull/2770
2019-01-23 16:28:48 +08:00
Ivan Grokhotkov 42b6c4953d bootloader, esp32: add workaround for Tensilica erratum 572
If zero-overhead loop buffer is enabled, under certain rare conditions
when executing a zero-overhead loop, the CPU may attempt to execute an invalid instruction. Work around by disabling the buffer.
2019-01-23 16:23:56 +08:00
XiaXiaotian 746e831c19 esp32: fix invalid channel state information(CSI) data index
Due to a hardware limitation in ESP32, the first four bytes of some
    CSI data is invalid, not the last four bytes.

    Correct a mistake of CSI sub-carrier index in documentation.
2019-01-22 20:30:05 +08:00
Ivan Grokhotkov 36f9091e03 ci, examples: use sdkconfig.ci as an extra defaults file, if present
- Allows placing CI-specific settings into sdkconfig.ci file
- Allows substituting environment variables in sdkconfig.ci
2019-01-22 10:15:10 +01:00
Wangjialin 553ba51924 bugfix(i2c): reduce speed of I2C master bus reset routine and release SDA
closes https://github.com/espressif/esp-idf/issues/2494
closes https://github.com/espressif/esp-idf/pull/2493
closes https://github.com/espressif/esp-idf/pull/2496

1. Change bus reset to handle interrupted READ sequences.
2. Slow down I2C to 100khz during reset
3. If a SLAVE device was in a read operation when the bus was interrupted, the SLAVE device is controlling SDA.The only bit during the 9 clock cycles of a byte READ the MASTER(ESP32) is guaranteed control over, is during the ACK bit period.
If the SLAVE is sending a stream of ZERO bytes, it will only release SDA during the ACK bit period. The master(ESP32) cannot generate a STOP unless SDA is HIGH. So, this reset code synchronizes the bit stream with, Either, the ACK bit, Or a 1 bit.
2019-01-22 11:43:55 +08:00
chuck todd 929d98538e 1. Slow down I2C to 100khz During Reset
I am stealing this delay coding from @jeremyherbert #2493 pr.

2. Change Bus Reset to handle interrupted READ sequences.

The current code does not handle interrupted READ cycles.

 If a SLAVE device was in a read operation when the bus was interrupted, the SLAVE device is controlling SDA.

The only bit during the 9 clock cycles of a byte READ the MASTER(ESP32) is guaranteed control over, is during the ACK bit period.

If the SLAVE is sending a stream of ZERO bytes, it will only release SDA during the ACK bit period. The master(ESP32) cannot generate a STOP unless SDA is HIGH.

So, this reset code synchronizes the bit stream with, Either, the ACK bit, Or a 1 bit.

3. fix typo

correct `sda_id` to `sda_io` in `i2c_master_clear_bus()` @ryan-ma found it.  This typo was generated when I manually edited this patch on GitHub, I should have done a Copy/Paste operation!
2019-01-22 11:43:40 +08:00
jeremy b810b32675 reduce speed of i2c master bus reset routine and release sda 2019-01-22 11:43:28 +08:00
David Cermak 00bf376bc3 mqtt tests: connect to local broker when running in CI to make the tests more reliable 2019-01-21 06:36:02 +01:00
Jiang Jiang Jian fe19ea977b Merge branch 'bugfix/phy_rtc_cache_disabled_v3.2' into 'release/v3.2'
Fix PHY/RTC functions called in ISR, but stored in flash

See merge request idf/esp-idf!4114
2019-01-18 10:54:03 +08:00
Tian Hao a953f73c64 Fix some bugs in phy
1. fix bug PHY/RTC functions called in ISR (update phy to v4007)
2. add UnitTest to test it
3. fix task watchdog bug when wifi change channel
4. disable/enable agc to mac deinit/init
2019-01-16 22:04:49 +08:00
Jiang Jiang Jian bed50a93f0 Merge branch 'bugfix/wifi_fix_incorrect_tx_complete_state_v3.2' into 'release/v3.2'
esp32: fix the incorrect tx complete state issue (backport v3.2)

See merge request idf/esp-idf!4105
2019-01-13 00:10:50 +08:00
jack a80bfc1dcf esp32: fix the incorrect tx complete state issue 2019-01-12 19:40:52 +08:00
Jiang Jiang Jian 51d846417e Merge branch 'bugfix/fix_ba_hardware_index_deleting_issue_v3.2' into 'release/v3.2'
esp32: fix wrongly deleting hardware BA index bug (backport v3.2)

See merge request idf/esp-idf!4102
2019-01-12 14:23:33 +08:00
Liu Zhi Fu ca54a5ce2a esp32: fix wrongly deleting hardware BA index bug
Fix the bug that hardware BA index will be wrongly removed in
WiFi mode WIFI_MODE_APSTA.
2019-01-11 21:46:28 +08:00
Jiang Jiang Jian 7b1777dd30 Merge branch 'bugfix/wifi_defragmentation_only_for_data_frame_v3.2' into 'release/v3.2'
esp32: do defragmentation only for data and management frame (backport v3.2)

See merge request idf/esp-idf!4090
2019-01-11 21:25:19 +08:00
Ivan Grokhotkov 64b46ff1d9 Merge branch 'bugfix/check_dependencies_msys_v3.2' into 'release/v3.2'
tools: Be more helpful to MSYS32 users with package installation & check if current python is inside virtual environment (backport v3.2)

See merge request idf/esp-idf!4063
2019-01-11 15:42:20 +08:00
Sergei Silnov c355d8a88e python: Add check if current python is inside virtual environment 2019-01-10 09:37:21 +01:00
Roland Dobai 977af32d0f tools: Be more helpful to MSYS32 users with package installation 2019-01-10 09:37:02 +01:00
XiaXiaotian f0a6432717 esp32: do defragmentation only for data and management frame
Check frame type before defragmentation. Only data and management frame
    can do defragmentation.
2019-01-10 14:17:21 +08:00
Jiang Jiang Jian c18e86a826 Merge branch 'bugfix/coex_unforce_wifi_if_no_data_buffered_in_beacon_v3.2' into 'release/v3.2'
esp32: unforce wifi if receiving beacon with no data buffered in dream (backport v3.2)

See merge request idf/esp-idf!4036
2019-01-10 14:11:02 +08:00
Jiang Jiang Jian b5d53a0eff Merge branch 'bugfix/timer_delete_dispatch_race_v3.2' into 'release/v3.2'
esp_timer: do not allow deleting timers while callbacks are dispatched (backport v3.2)

See merge request idf/esp-idf!4062
2019-01-10 13:44:15 +08:00
XiaXiaotian 10afc3de77 esp32: unforce wifi if receiving beacon with no data buffered in dream
state and reduce force receiving broadcast data time

    1. If receiving beacon which indicates that there is no data buffered,
    do not force to receive WiFi data.
    2. If receiving beacon which indicates that there is broadcast data
    buffered, reduce the time to force receiving broadcast data.
2019-01-09 14:13:08 +08:00
Jiang Jiang Jian 545878d4e9 Merge branch 'bugfix/ignore_windows_conf_tools_v32' into 'release/v3.2'
gitignore: Add mconf-idf.exe and conf-idf.exe (v3.2)

See merge request idf/esp-idf!4071
2019-01-09 13:57:54 +08:00
Jiang Jiang Jian ec7909956d Merge branch 'bugfix/fix_mbox_thread_safe_issue_v3.2' into 'release/v3.2'
tcpip: fix mbox thread-safe issue  (backport v3.2)

See merge request idf/esp-idf!4005
2019-01-09 10:21:22 +08:00
Ivan Grokhotkov d9c3a08813 Merge branch 'bugfix/mdns_udp_send_protected_backport3.2' into 'release/v3.2'
mdns networking udp send protected (Backport 3.2)

See merge request idf/esp-idf!4020
2019-01-08 12:04:23 +08:00
Ivan Grokhotkov eb9a93f9b7 Merge branch 'bugfix/mdns_crash_when_query_backport3.2' into 'release/v3.2'
mdns crash when query (backport 3.2)

See merge request idf/esp-idf!3950
2019-01-08 12:03:52 +08:00
Jiang Jiang Jian 710019a47f Merge branch 'bugfix/fix_the_country_code_bug_v3.2' into 'release/v3.2'
wifi: fix the bug that STA can scan the channel out of the country regdomain range (backport v3.2)

See merge request idf/esp-idf!4068
2019-01-07 20:33:02 +08:00
Ivan Grokhotkov 2d27358f61 Merge branch 'feature/i2s_tx_descriptor_auto_clear_backport_v3.2' into 'release/v3.2'
i2s: add (optional) support to clear tx descriptor in underflow case (backport v3.2)

See merge request idf/esp-idf!4056
2019-01-07 16:34:01 +08:00
zhangyanjiao b80eba8d5a wifi: fix the bug that STA can scan the channel out of the country regdomain range 2019-01-04 14:34:36 +08:00
Angus Gratton 7832db7bb3 gitignore: Add mconf-idf.exe and conf-idf.exe
Problem since f6cd55d2ac

Closes https://github.com/espressif/esp-idf/issues/2751
2019-01-04 10:09:35 +11:00
Liu Zhi Fu efa70bc8e3 lwip: fix mbox thread-safe issue
Fix a mbox free thread-safe issue that can lead to crash in sys_arch_mbox_fetch.
2019-01-02 22:48:19 +08:00
Ivan Grokhotkov 31b7db5c38 esp_timer: do not allow deleting timers while callbacks are dispatched
timer_process_alarm function of esp_timer holds a spinlock for the
entire duration of its operation, except for the time when timer
callback function is called. It is possible that when
timer_process_alarm releases the spinlock, a higher priority task may
run and delete the timer. Then the execution will return to
timer_process_alarm, and this will either cause a crash, or undesired
execution of callback after the timer has been stopped or deleted.

To solve this problem, add a mutex which will prevent deletion of timers
while callbacks are being dispatched.
2019-01-02 20:06:06 +11:00
Mahavir Jain 8d02ccd2f7 examples: enable option to auto clear I2S tx descriptor on underflow
Closes: https://github.com/espressif/esp-idf/issues/1945
(cherry picked from commit 1751607adf)
2018-12-31 13:43:34 +05:30
Mahavir Jain 62eb0f4c12 i2s: add (optional) support to clear tx descriptor in underflow case
It has been observed that, in case of underflow (data unavailability) in
I2S transmission, previously filled up tx descriptors continue to get
transmitted on line, causing noise in case of audio use case.

This change adds optional `tx_desc_auto_clear` field during I2S driver intialization
than can zero initialize tx descriptor in case of underflow situation in
interrupt handler itself.

Closes: https://github.com/espressif/esp-idf/issues/1789
(cherry picked from commit 765bf674d0)
2018-12-31 13:42:26 +05:30
Jiang Jiang Jian 155f034b1e Merge branch 'feature/freemodbus_move_rs485_mode_control_v3.2' into 'release/v3.2'
examples: freemodbus port serial slave move uart mode settings into example (backport v3.2)

See merge request idf/esp-idf!4015
2018-12-29 10:28:27 +08:00
Jiang Jiang Jian 47dea73b03 Merge branch 'doc/btdm_modem_sleep_EVED_mode_for_v3.2' into 'release/v3.2'
doc/btdm_modem_sleep_EVED_mode_for_v3.2(backport v3.2)

See merge request idf/esp-idf!4016
2018-12-29 10:27:52 +08:00
Jiang Jiang Jian 28fdf96828 Merge branch 'bugfix/ota_magic_byte_issue_v3.2' into 'release/v3.2'
Bugfix/ota magic byte issue v3.2(backport v3.2)

See merge request idf/esp-idf!4004
2018-12-29 10:24:24 +08:00
Jiang Jiang Jian 3969fe0dad Merge branch 'bugfix/lwip_add_hostname_option_in_dhcp_discover_v3.2' into 'release/v3.2'
add hostname option in dhcp discover (backport v3.2)

See merge request idf/esp-idf!3938
2018-12-29 10:07:50 +08:00
Jiang Jiang Jian c70c25afd0 Merge branch 'mesh/bugfix_v3.2' into 'release/v3.2'
mesh: when no parent is found, send probe request

See merge request idf/esp-idf!3940
2018-12-28 14:02:23 +08:00
Jiang Jiang Jian d59d9eef4f Merge branch 'bugfix/bbpll_wakeup_reset_v3.2' into 'release/v3.2'
BBPLL reset fixes (backport v3.2)

See merge request idf/esp-idf!4011
2018-12-24 18:16:47 +08:00
David Cermak 22514e12d8 mdns: fix networking running udp_sendif from lwip thread 2018-12-21 16:44:15 +01:00
David Cermak f48ffb37f2 mdns: check all mallocs for failure and add default hook to log error with free heap
solves crash about _mdns_result_txt_create when stress test
2018-12-21 16:27:58 +01:00
David Cermak 0f041ee7bb mdns: fixed static memory leak 2018-12-21 16:26:39 +01:00
David Cermak c320a3ee4c mdns: resolve memory leak when txt record received multiple times 2018-12-21 16:26:39 +01:00
David Cermak 1f35716ef4 mdns: skip sending search when finished, not properly locked timer task 2018-12-21 16:26:39 +01:00
wangmengyang 358de85eb3 component/bt: add more information and description for bluetooth modem sleep
Add remark that "EVED" mode for bluetooth modem sleep is only used for internal test
2018-12-21 19:29:47 +08:00
qiyueixa 84277e5887 mesh: when no parent is found, send probe request via broadcast
1. fix error in checking Wi-Fi commit ID.
2018-12-21 17:49:58 +08:00
Jiang Jiang Jian 52a70e0489 Merge branch 'bugfix/ext_ram_bss_align_v3.2' into 'release/v3.2'
Fix ext_ram_bss alignment crash (backport v3.2)

See merge request idf/esp-idf!4014
2018-12-21 17:31:33 +08:00
aleks 6523d912f2 examples: freemodbus port serial slave move uart mode settings into example
Update freemodbus component file esp-idf/components/freemodbus/port/portserial.c to remove UART mode settings;
Move UART mode settings into esp-idf/examples/protocols/modbus_slave/main/freemodbus.c
Move UART pin settings from Component config into example Kconfig.projbuild file
Move setup of UART port pins from freemodbus component into example file

TW#27721
Closes https://github.com/espressif/esp-idf/issues/2784#issuecomment-443600157
2018-12-21 09:54:26 +01:00
Angus Gratton aa0d2078b7 psram: Use 8-bit type for _ext_ram_bss_start/_ext_ram_bss_end
Fixes pointer arithmetic when printing size of remaining heap
2018-12-21 19:03:12 +11:00
Angus Gratton 348d6d5d3f multi_heap: Fix bug when start of heap is unaligned
Alignment was accounted for in one place only.

TW27954
2018-12-21 19:03:12 +11:00
Angus Gratton 46228db9a8 linker external bss: Align end of ext bss to word boundary
TW27954
2018-12-21 19:03:12 +11:00
Jiang Jiang Jian 2cac11f162 Merge branch 'bugfix/btdm_fix_crash_adv_scan_coex_v3.2' into 'release/v3.2'
component/bt: fix crash when adv and scan coex and optimize duplicate scan (backport v3.2)

See merge request idf/esp-idf!3994
2018-12-21 15:59:53 +08:00
Jiang Jiang Jian 64eeee4532 Merge branch 'bugfix/btdm_fix_two_bugs_about_pairing_v3.2' into 'release/v3.2'
components/bt: Fix two bugs about pairing(backport 3.2)

See merge request idf/esp-idf!3995
2018-12-21 14:26:19 +08:00
Jiang Jiang Jian a9eb37e2c8 Merge branch 'bugfix/btdm_prevent_light_sleep_for_v3.2' into 'release/v3.2'
bugfix/btdm_prevent_light_sleep_for_v3.2(backport v3.2)

See merge request idf/esp-idf!3986
2018-12-21 14:25:49 +08:00
Ivan Grokhotkov c7a297195f soc/rtc: reset another BBPLL related register
Follow-up to b21ffc8a: an additional register needs to be reset.

Ref. https://github.com/espressif/esp-idf/issues/2711
2018-12-21 12:40:08 +08:00
Ivan Grokhotkov 19e96add8a soc/rtc: reset BBPLL configuration after enabling it
A workaround to reset BBPLL configuration after light sleep. Fixes the
issue that Wi-Fi can not receive packets after waking up from light
sleep.

Ref. https://github.com/espressif/esp-idf/issues/2711
2018-12-21 12:39:49 +08:00
Ivan Grokhotkov a0a0328e4f Merge branch 'bugfix/idf_monitor_without_toolchain_v3.2' into 'release/v3.2'
tools: Print useful error message from idf_monitor when toolchain isn't available (backport v3.2)

See merge request idf/esp-idf!3949
2018-12-21 12:01:54 +08:00
Supreet Deshpande 04aebc464c bugfix/ota_magic_byte_issue: Fix indent and replace constant by macro
Replace 0xE9 by ESP_IMAGE_HEADER_MAGIC.
2018-12-20 12:29:25 +05:30
Supreet Deshpande 30e01847ad bugfix/ota_magic_byte_issue: Fixes OTA magic byte error
On enabling flash encryption, OTA fails with magic byte error in the second chunk
if the http data is split into two or more chunks and first chunk is less than 16.
2018-12-20 12:29:00 +05:30
zwj 3f6033d8bd fix crash when adv and scan coex and optimize duplicate scan 2018-12-19 19:53:01 +08:00
baohongde 45e59a9f56 components/bt: Fix two bugs about pairing
1. Fix Legacy Pairing failed without remote device name
2. Fix discovery no device after disabling SSP
2018-12-19 19:42:47 +08:00
wangmengyang 587e6ec93f component/bt: use a pm_lock to prevent light sleep when bluetooth is enabled due to current imcompatibility 2018-12-18 14:51:19 +08:00
Jiang Jiang Jian 6d00c7fc49 Merge branch 'bugfix/btdm_assert_ble_65536_v3.2' into 'release/v3.2'
fix bug that there's very low ratio to cause BLE assert(65536, 0) in rwble.c at line 222

See merge request idf/esp-idf!3968
2018-12-18 12:03:21 +08:00
Jiang Jiang Jian c418714ec6 Merge branch 'bugfix/btdm_fix_receive_adv_pkt_when_duplicate_scan_enabled_v3.2' into 'release/v3.2'
Component/bt: fix receive adv pkt when enable duplicate scan (backport v3.2)

See merge request idf/esp-idf!3942
2018-12-18 11:45:28 +08:00
Jiang Jiang Jian 19d8c050cd Merge branch 'bugfix/tw27963_fix_wifi_stop_bug_v3.2' into 'release/v3.2'
esp32: fix WiFi stop bug in WiFi/BT coexist mode (backport v3.2)

See merge request idf/esp-idf!3982
2018-12-18 11:41:03 +08:00
Liu Zhi Fu cb650382ca esp32: fix WiFi stop bug in WiFi/BT coexist mode
This fix includes following changes:
1. Fix the bug that esp_restart()/esp_wifi_stop() sometimes fails in WiFi/BT coexist mode.
2. Add a timer for WiFi stop and stop WiFi forcibly once the timer expires.
2018-12-17 20:52:40 +08:00
Tian Hao e5e592e5b6 fix bug that there's very low ratio to cause BLE assert(65536, 0) in rwble.c at line 222 2018-12-17 20:50:42 +08:00
zhiweijian 28e20e90e3 Component/bt: fix receive adv pkt when enable duplicate scan 2018-12-17 15:51:28 +08:00
Jiang Jiang Jian 1c4d9f2aca Merge branch 'bugfix/btdm_modem_sleep_cowork_with_DFS_for_v3.2' into 'release/v3.2'
Bugfix/btdm modem sleep cowork with dfs for v3.2(backport v3.2)

See merge request idf/esp-idf!3962
2018-12-14 20:28:31 +08:00
Jiang Jiang Jian ded8b0102a Merge branch 'bugfix/btdm_fix_auth_mode_error_when_reconnection_in_smp_v3.2' into 'release/v3.2'
Component/bt: fix auth_mode error when reconnection in SMP (backport v3.2)

See merge request idf/esp-idf!3955
2018-12-14 18:24:01 +08:00
wangmengyang 401970495d component/bt: add DRAM_ATTR attribute to global variables(mostly in bss segment) in bt.c which can be accessed in ISR 2018-12-14 14:59:41 +08:00
Jiang Jiang Jian 5d46bb596d Merge branch 'bufix/btdm_fix_save_key_when_auth_mode_without_bond_v3.2' into 'release/v3.2'
Component/bt: fix save keys when auth mode without bond (backport V3.2)

See merge request idf/esp-idf!3957
2018-12-14 14:59:24 +08:00
wangmengyang 8de9149b11 component/bt: bugfix of bluetooth modem sleep not being able to work with Dynamic Frequency Scaling
1. start an esp_timer on entering sleep to acquire pm_lock before wake up from modem sleep
2. decrease the clock division of XTAL fed to bluetooth low power clock from 32us to 2us period to allow to work under 240MHz Max CPU frequency
3. decrease the minimum sleep duration threshold to allow shorter bluetooth modem sleep period, especially for BLE with short connection interval
4. reconfigure bluetooth baseband(BT-BB) settings after PHY/RF init upon waking up from modem sleep to avoid packet RX/TX performance degradation
2018-12-14 14:56:29 +08:00
Roland Dobai e8b8946e6e tools: Print useful error message from idf_monitor when toolchain isn't available 2018-12-13 22:03:25 +01:00
zhiweijian 2c1e3d1ef2 Component/bt: fix save keys when auth mode without bond 2018-12-13 15:45:53 +08:00
zhiweijian bf608b6709 Component/bt: fix auth_mode error when reconnection in SMP 2018-12-13 15:33:37 +08:00
Jiang Jiang Jian 24ebdbd3f4 Merge branch 'test/add_case_to_detect_ds2ds_issue_v3.2' into 'release/v3.2'
test: add case to detect ds2ds issue (backport v3.2)

See merge request idf/esp-idf!3851
2018-12-13 14:52:58 +08:00
Jiang Jiang Jian fd00d3213b Merge branch 'bugfix/btdm_fix_accept_specified_sec_auth_v3.2' into 'release/v3.2'
Component/bt: fix accept specified sec auth error(backport v3.2)

See merge request idf/esp-idf!3836
2018-12-13 11:20:02 +08:00
Jiang Jiang Jian c921a5bc4b Merge branch 'feature/illegal_instruction_panic_info_v3.2' into 'release/v3.2'
panic: dump some instruction memory on IllegalInstruction exception (backport v3.2)

See merge request idf/esp-idf!3946
2018-12-12 15:58:22 +08:00
Ivan Grokhotkov ade85cc850 panic: dump some instruction memory on IllegalInstruction exception 2018-12-12 11:58:55 +08:00
Xia Xiaotian 5c8d25b795 add hostname option in dhcp discover
Hostname option has been removed from dhcp discover since IDFv3.2.
But it remains in dhcp request due to which ESP32 can not get IPv4 address
from some APs. Re-add hostname option to dhcp discover to solve this issue.
2018-12-10 21:26:24 +08:00
Jiang Jiang Jian ac051f0afc Merge branch 'bugfix/btdm_assert_ble_32768_v3.2' into 'release/v3.2'
fix bug that there's very low ratio to cause BLE assert(32768, 0) in rwble.c at line 222

See merge request idf/esp-idf!3919
2018-12-10 15:04:44 +08:00
Jiang Jiang Jian bb47146710 Merge branch 'fix/spi_callback_in_iram_v3.2' into 'release/v3.2'
spi: fix the crash when callbacks are not in the IRAM (Backports v3.2)

See merge request idf/esp-idf!3884
2018-12-07 10:37:07 +08:00
Jiang Jiang Jian 07cb228f64 Merge branch 'bugfix/win_path_print_v3.2' into 'release/v3.2'
tools: correct printed path on MS Win (backport v3.2)

See merge request idf/esp-idf!3913
2018-12-07 10:36:31 +08:00
Jiang Jiang Jian 3cfe1c89b5 Merge branch 'ci/combine_unit_test_and_integration_test_v3.2' into 'release/v3.2'
ci: combine unit_test and integration_test stage (backport v3.2)

See merge request idf/esp-idf!3845
2018-12-07 10:36:00 +08:00
Jiang Jiang Jian 4f805d558c Merge branch 'bugfix/fix_uart_read_bug_when_using_dual_core_v3.2' into 'release/v3.2'
driver(uart): fixed uart read error bug when using dual core (backport v3.2)

See merge request idf/esp-idf!3813
2018-12-07 10:35:17 +08:00
Jiang Jiang Jian f53716d851 Merge branch 'bugfix/idfpy_monitor_msys_v3.2' into 'release/v3.2'
tools: fix idf.py monitor for MSYS (backport v3.2)

See merge request idf/esp-idf!3898
2018-12-07 10:34:44 +08:00
He Yin Ling f8fd922ca5 unit-test-app: fix the RegEx to detect test case:
tags are not correctly parsed if eol do not contain `\r`
2018-12-07 02:04:55 +00:00
He Yin Ling 61d07ffbfc tiny-test-fw: fix exception when expect RegEx:
match.groups() could return None. We can't do decode on None object.
2018-12-07 02:04:55 +00:00
He Yin Ling 6b5649190f test: add test case to receive ds2ds packet 2018-12-07 02:04:55 +00:00
Tian Hao f44507de53 fix bug that there's very low ratio to cause BLE assert(32768, 0) in rwble.c at line 222 2018-12-06 21:35:19 +08:00
Roland Dobai 88c7a61a63 tools: correct the coding style of check_python_dependencies.py 2018-12-06 08:33:17 +01:00
Roland Dobai 6af90457f7 tools: correct printed path on MS Win 2018-12-06 08:32:45 +01:00
Ivan Grokhotkov 3aafb2cfcf Merge branch 'bugfix/ethernet_enable_second_failure_v3.2' into 'release/v3.2'
fix phy init timeout(backport v3.2)

See merge request idf/esp-idf!3896
2018-12-06 15:22:32 +08:00
Roland Dobai 8ec0c82c3f tools: fix idf.py monitor for MSYS 2018-12-05 10:48:30 +01:00
morris a338c1b712 ethernet: phy init timeout
When ethernet enable again after disable it before, phy init will report timeout.
The cause of this problem is that the enabling of emac clock is too late, and should be placed before phy init.
2018-12-05 16:32:24 +08:00
Jiang Jiang Jian 0b21be508e Merge branch 'bugfix/btdm_bugs_caused_by_coex_v3.2' into 'release/v3.2'
component/bt and esp32:  fix two bluetooth bugs that caused by coexist module

See merge request idf/esp-idf!3861
2018-12-05 14:17:25 +08:00
Ivan Grokhotkov 3b4d51bbfa Merge branch 'doc/security_features_small_fixes_v3.2' into 'release/v3.2'
doc: Small secure boot & flash encryption corrections (v3.2)

See merge request idf/esp-idf!3888
2018-12-05 11:07:41 +08:00
Angus Gratton 60c556eb55 docs: flash encryption: Fix description of behaviour when all bits of FLASH_CRYPT_CNT are set
Correct behaviour is described in section 25.3.3 Flash Decryption Block of the ESP32 TRM
2018-12-05 11:20:05 +11:00
Angus Gratton 9933e37c8b doc: secure boot: Explain output of digest_secure_bootloader command
Mentioned on forum https://esp32.com/viewtopic.php?f=13&t=8162&start=10#p34714
2018-12-05 11:20:05 +11:00
Angus Gratton 67bdc8aaf4 doc: security: Use less ambiguous language about using bot flash encryption & secure boot together 2018-12-05 11:20:05 +11:00
Michael (XIAO Xufeng) 44bd6f72bc spi: fix the crash when callbacks are not in the IRAM
Introduced in 9c23b8e5 and 4f87a62f. To get higher speed, menuconfig
options are added to put ISR and other functions into the IRAM.  The
interrupt flag ESP_INTR_FLAG_IRAM is also mistakenly set when the ISR is
put into the IRAM. However callbacks, which are wrote by the user, are
called in the master and slave ISR. The user may not be aware of that
these callbacks are not disabled during flash operations. Any cache miss
during flash operation will cause panic.

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

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

    4. update libcoexist.a version to v1.1.2
2018-12-03 19:30:28 +08:00
He Yin Ling e85cb6d148 ci: combine unit_test and integration_test stage:
The number of runners of integration test is not bottleneck to CI
pipeline performance now. Combine these 2 stages will make integration
test executed even unit test fails. This could help us to collect more
info about test history.
2018-11-30 13:44:11 +08:00
Angus Gratton 7658b8ab62 Merge branch 'test/enhanced_junit_test_result_v3.2' into 'release/v3.2'
test: enhanced junit test result (backport v3.2)

See merge request idf/esp-idf!3794
2018-11-30 11:39:31 +08:00
Ivan Grokhotkov 7969a566e3 Merge branch 'bugfix/fat_lock_log_v3.2' into 'release/v3.2'
fatfs: Do not log from critical sections (backport v3.2)

See merge request idf/esp-idf!3721
2018-11-29 23:00:55 +08:00
Ivan Grokhotkov be05b1e654 Merge branch 'bugfix/uart_select_buffer_v3.2' into 'release/v3.2'
VFS: select() on UART should return immediately when data is buffered (backport v3.2)

See merge request idf/esp-idf!3829
2018-11-29 23:00:17 +08:00
zhiweijian ca51b60033 Component/bt: fix accept specified sec auth error 2018-11-29 20:46:08 +08:00
Ivan Grokhotkov 9b3ff1bed0 Merge branch 'bugfix/i2c_hardware_filter_default_enable_v3.2' into 'release/v3.2'
driver(i2c): enable I2C master hardware filter by default for release/v3.2

See merge request idf/esp-idf!3815
2018-11-29 19:28:32 +08:00
Roland Dobai f859f9e25b VFS: select() on UART should return immediately when data is buffered 2018-11-29 10:08:26 +01:00
Jiang Jiang Jian f2ae151dab Merge branch 'bugfix/btdm_rf_reg_v3.2' into 'release/v3.2'
fix bug to unsupport rf reg access from hci cmd

See merge request idf/esp-idf!3786
2018-11-28 21:20:05 +08:00
kooho bae0d8a313 driver(i2c): enable I2C master hardware filter by default for release/v3.2 2018-11-28 17:02:04 +08:00
kooho cfcc0edc33 driver(uart): fixed uart read error bug when using dual core for release/v3.2. 2018-11-28 16:37:59 +08:00
He Yin Ling 54e6f0793a ci: split build unit test job:
it takes long time to build with both make and cmake
2018-11-26 21:59:42 +08:00
He Yin Ling e98f4d2751 ci: use artifacts:reports feature of Gitlab CI 2018-11-26 17:06:41 +08:00
He Yin Ling 33cf0faac8 ci: assign unit test cases in sequence of config and name 2018-11-26 17:06:40 +08:00
He Yin Ling 7385e71c84 test: fix unit test script code style warnings 2018-11-26 17:05:04 +08:00
He Yin Ling 7778ce83bd test: generate junit test report according to executed cases 2018-11-26 17:05:04 +08:00
He Yin Ling 0f8070a6fd tiny-test-fw: support capture raw data in DUT:
test cases might want to use `expect` and get raw data from DUT at the same time. New added capture method provides a way to do that.
2018-11-26 17:05:04 +08:00
He Yin Ling 0fcb9056f8 tiny-test-fw: enhanced junit test report support:
1. replace xunitgen with junit_xml, which can log more info
2. allow test cases to handle junit test report by them own
3. allow test cases to log some info into report via `sysout` tag
2018-11-26 17:05:04 +08:00
Roland Dobai 5110d4b303 fatfs: Do not log from critical sections
Logging in the critical section can result in a deadlock when the logger
is redirected to FATFS.

Closes https://github.com/espressif/esp-idf/issues/1693
2018-11-26 09:21:44 +01:00
Angus Gratton fc19954376 Merge branch 'bugfix/adjtime_test2_v3.2' into 'release/v3.2'
Resolve ""test for thread safety adjtime and gettimeofday functions" fails randomly"  (backport v3.2)

See merge request idf/esp-idf!3791
2018-11-26 16:17:05 +08:00
Konstantin Kondrashov 16d32c58e7 newlib: Fix UT adjtime 2018-11-26 15:55:17 +11:00
Angus Gratton 3d926da642 Merge branch 'bugfix/fix_cmake_args_issue_backport_3.2' into 'release/v3.2'
Fix cmake args issue (backport 3.2)

See merge request idf/esp-idf!3789
2018-11-26 09:53:38 +08:00
Tian Hao 9bb719dd68 fix bug to unsupport rf reg access from hci cmd
Always return 0 when read rf register and do nothing when write rf register
2018-11-24 14:21:25 +08:00
Jiang Jiang Jian 536cb0489e Merge branch 'bugfix/fix_some_wifi_bugs_1121_v3.2' into 'release/v3.2'
esp32: fix some wifi bugs (backport v3.2)

See merge request idf/esp-idf!3762
2018-11-23 17:08:31 +08:00
Renz Christian Bagaporo 98c7cb5560 cmake: remove unecessary info passed to bootloader build 2018-11-23 16:12:14 +08:00
Renz Christian Bagaporo 4baf333c79 ulp: fix passing ulp srcs due to cmake_args bug 2018-11-23 16:10:54 +08:00
Jiang Jiang Jian 79401934a1 Merge branch 'bugfix/backports_v3.2' into 'release/v3.2'
Multiple v3.2 backports

See merge request idf/esp-idf!3727
2018-11-23 13:43:24 +08:00
Jiang Jiang Jian ec1daf32e1 Merge branch 'bugfix/btdm_move_func_into_iram_v3.2' into 'release/v3.2'
components/bt: Move function in interrupt into IRAM(backport 3.2)

See merge request idf/esp-idf!3758
2018-11-23 13:39:27 +08:00
Michael Balzer 5afc1b0cbb
Merge pull request #2 from M4GNV5/master
merge all commits from espressif/esp-idf
2018-11-22 20:30:26 +01:00
Liu Zhi Fu 1cac0d2cf2 esp32: fix some wifi bugs
Fix some Wifi bugs:
1. Enable RX BAR
2. Fix the bug that ESP32 AP negotiates with iphone to 11g
3. Fix the bug that ESP32 STA has ap_loss because CMCC AP contains two SSID
2018-11-22 20:27:52 +08:00
baohongde 8d1594c339 components/bt: Move function in interrupt into IRAM
1. Move function in interrupt into IRAM
2. Delete unused code, saving 240B DRAM and some code size
2018-11-22 16:19:21 +08:00
Jiang Jiang Jian a0f516de0b Merge branch 'mesh/bugfix_v3.2_backport' into 'release/v3.2'
mesh: bugfix (backport3.2)

See merge request idf/esp-idf!3771
2018-11-22 10:22:12 +08:00
qiyueixa 802d94aa35 utest: increase IDF_PERFORMANCE_MAX_VFS_OPEN_WRITE_CLOSE_TIME to 50000 2018-11-22 00:39:38 +08:00
qiyueixa 3c3e375d8d mesh: bugfix
1. fix failture of mesh stop caused by block-sending.
2. fix when FIXED_ROOT is set, 2nd layer devices can not receive mesh event ESP_ERR_MESH_NO_PARENT_FOUND.
3. fix when FIXED_ROOT is set and the root turns off mesh function, 2nd layer devices do not look for new parents.
4. add APIs esp_mesh_disconnect() and esp_mesh_connect().
5. disconnect from parent/router when the DSSS channel in received beacon is different from the home channel.
6. remove nvs task to release 3k bytes memory.
2018-11-22 00:39:02 +08:00
Ivan Grokhotkov d57ea422be Merge branch 'bugfix/cmake_utf_decode_v3.2' into 'release/v3.2'
tools: Fix Unicode decode error & indentation error (backport v3.2)

See merge request idf/esp-idf!3733
2018-11-21 11:44:54 +08:00
Ivan Grokhotkov 3b3242cbae freertos: use xTaskQueueMutex to protect tick count
Having two different spinlocks is problematic due to possibly
different order in which the locks will be taken. Changing the order
would require significant restructuring of kernel code which is
undesirable.

An additional place where taking xTickCountMutex was needed was in
vApplicationSleep function. Not taking xTickCountMutex resulted in
other CPU sometimes possibly advancing tick count while light sleep
entry/exit was happening. Taking xTickCountMutex in addition to
xTaskQueueMutex has shown a problem that in different code paths,
these two spinlocks could be taken in different order, leading to
(unlikely, but possible) deadlocks.
2018-11-21 03:42:15 +00:00
Ivan Grokhotkov 96c2b34eb9 pm: prevent entering light sleep again immediately after wakeup
When light sleep is finished on one CPU, it is possible that the other
CPU will enter light sleep again very soon, before interrupts on the
first CPU get a chance to run. To avoid such situation, set a flag
for the other CPU to skip light sleep attempt.
2018-11-21 03:42:15 +00:00
Ivan Grokhotkov 6b3a8acdc3 pm: fix entering light sleep in single core mode
Tickless idle/light sleep procedure had a bug in single core mode.
Consider the flow of events:
1. Idle task runs and calls vApplicationIdleHook
2. This calls esp_vApplicationIdleHook, which calls esp_pm_impl_idle_hook, and pm lock for RTOS on the current core is released.
3. Then esp_vApplicationIdleHook calls esp_pm_impl_waiti, which checks that s_entered_light_sleep[core_id]==false and goes into waiti state.
4. Some interrupt happens, calls esp_pm_impl_isr_hook, which takes pm lock for RTOS. PM state goes back to CPU_FREQ_MAX.
5. Once the interrupt is over, vApplicationIdleHook returns, and Idle task continues to run, finally reaching the call to vApplicationSleep.
6. vApplicationSleep does not enter light sleep, because esp_pm_impl_isr_hook has already changed PM state from IDLE to CPU_FREQ_MAX.

This didn’t happen in dual core mode, because waiti state of one CPU was interrupted by CCOMPARE update interrupt from the other CPU, in which case PM lock for FreeRTOS was not taken.

Fix by inverting the meaning of the flag (for convenience) and only setting it to true when vApplicationSleep actually fails to enter light sleep.
2018-11-21 03:42:15 +00:00
Ivan Grokhotkov a10abd695b freertos: fix compilation warning in single core mode
When tickless idle is enabled
2018-11-21 03:42:15 +00:00
Ivan Grokhotkov 0f28a51996 spiffs: increase timeout in readdir test
Timeout of 15 seconds is not sufficient if SPIFFS partition needs to
be formatted, on some of the boards.
2018-11-21 03:42:15 +00:00
Ivan Grokhotkov 6681096e55 Merge branch 'bugfix/mdns_query_failed_after_init_v3.2' into 'release/v3.2'
Fixed: mdns query failed after init (Backport v3.2)

See merge request idf/esp-idf!3729
2018-11-21 11:41:34 +08:00
Jiang Jiang Jian 18b65dca26 Merge branch 'bugfix/btdm_controller_disable_v3.2' into 'release/v3.2'
Fix two bugs when disable bluetooth controller(backport v3.2)

See merge request idf/esp-idf!3716
2018-11-21 11:26:14 +08:00
Jiang Jiang Jian a398116b1c Merge branch 'bugfix/btdm_add_check_peer_addr_type_in_set_adv_params_v3.2' into 'release/v3.2'
Component/bt: add check peer addr type in set adv params (backport v3.2)

See merge request idf/esp-idf!3734
2018-11-20 20:02:37 +08:00
Tian Hao 331c7c7dc3 Fix two bugs when disable bluetooth controller
1. Fix the bug that disable controller suddenly cause crash when ble is working.
2. Fix the bug that when disable controller, it will cause wifi cannot RX, TX timeout, buffer lack and etc.
2018-11-20 09:01:57 +00:00
Jiang Jiang Jian 7bd9559e7e Merge branch 'bugfix/wifi_sta_sniffer_phy_config_bug_v3.2' into 'release/v3.2'
wifi: fix wifi sta and sniffer phy config bug (backport v3.2)

See merge request idf/esp-idf!3718
2018-11-20 14:20:29 +08:00
Ivan Grokhotkov e84289077c Merge branch 'bugfix/fix_bug_ethernet_v3.2' into 'release/v3.2'
ethernet: fix some bugs in phy&mac driver(backport v3.2)

See merge request idf/esp-idf!3640
2018-11-19 17:54:27 +08:00
zhiweijian c59c40741b Component/bt: add check peer addr type in set adv params 2018-11-19 17:15:41 +08:00
Roland Dobai f3c1903791 tools: Fix UTF decode error 2018-11-19 10:11:34 +01:00
morris 2885ec3831 ethernet: multi-call failure in esp_eth_init
Because of incomplete state machine, ethernet driver will broken if esp_eth_init is called twice.
Detailed information here: https://ezredmine.espressif.cn:8765/issues/27332
2018-11-19 14:55:43 +08:00
morris a7db0e2291 ethernetif: fix potential memory leak
1. If L2_TO_L3_RX_BUF_MODE is not selected, we must assign l2_owner explictly before we call pbuf_free.
2. free intr resource in esp_eth_deinit

Closes https://github.com/espressif/esp-idf/issues/2670
2018-11-19 14:55:43 +08:00
morris cb98f5a814 ethernet: fix some bugs in phy&mac driver
1. Original register mapping for LAN8720 has some registers that doesn't exist/support.
So just remove them, and fix the power and init function for LAN8720.
2. GPIO16 and GPIO17 is occupied by PSRAM, so only ETH_CLOCK_GPIO_IN mode is supported in that case if using PSRAM.
3. Fix bug of OTA failing with Ethernet
4. Fix bug of multicast with Ethernet
5. Fix potential memory leak
2018-11-19 14:55:43 +08:00
Jiang Jiang Jian 8725bce5bc Merge branch 'bugfix/btdm_errors_in_comment_v3.2' into 'release/v3.2'
components/bt: Some errors in comment(backport 3.2)

See merge request idf/esp-idf!3713
2018-11-19 14:36:45 +08:00
David Cermak 174b3b89e4 mdns: sending search packets also in probing and announcing state
mdns queries did not work properly when send imeadiately after set_hostname, which cuased reinit of pcb and therefore restarted probing, so search packets were blocked until probing finished
closes #2507, closes #2593
2018-11-19 04:38:04 +01:00
Mark Webb-Johnson c0b211a480
Merge pull request #3 from leres/master
Add missing typedef keyword and solve unused variable warning.
2018-11-17 16:28:45 +08:00
zhangyanjiao 8d9d8e27ca wifi: fix the bug that if station (sleep is enabled) and sniffer are enabled at the same time,
when disable sniffer, station will never enable phy and rf again.
2018-11-16 19:09:31 +08:00
Jiang Jiang Jian 93f4dc6b32 Merge branch 'bugfix/btdm_fuction_in_isr_is_not_in_iram_v3.2' into 'release/v3.2'
components/bt: Put function in isr into iram(backport 3.2)

See merge request idf/esp-idf!3689
2018-11-16 18:15:01 +08:00
baohongde b021bbdc80 components/bt: Some errors in comment 2018-11-16 15:27:28 +08:00
baohongde c9fe4fa13e components/bt: Put function in isr into iram(backport 3.2) 2018-11-16 07:19:51 +00:00
Ivan Grokhotkov 96252c493a Merge branch 'bugfix/app_template_build_v3.2' into 'release/v3.2'
esp-idf-template app: some fixes for the updated template app  (backport v3.2)

See merge request idf/esp-idf!3700
2018-11-16 15:18:36 +08:00
Mahavir Jain 007a4fcc4e tools: fix cmake build script for sdkconfig test 2018-11-16 02:48:35 +00:00
Anton Maklakov dbeb8ae02a cmake: fix the creation dummy main to avoid rebuilding 2018-11-16 02:48:35 +00:00
Anton Maklakov 9921c8b91f ci: If there is no sdkconfig, we have to generate one 2018-11-16 02:48:35 +00:00
Jiang Jiang Jian e16f65f4e6 Merge branch 'bugfix/tw27096_fix_lwip_mbox_free_crash_v3.2' into 'release/v3.2'
fix the crash caused by sys_mbox_free (backport v3.2)

See merge request idf/esp-idf!3676
2018-11-15 10:31:46 +08:00
Craig Leres 71eff833a1 Add missing typedef keyword and solve unused variable warning. 2018-11-14 09:30:46 -08:00
Jiang Jiang Jian fe0a5b41bf Merge branch 'bugfix/fix_memory_leak_for_v3.2' into 'release/v3.2'
Component/bt: fix memory leak in service change(backport v3.2)

See merge request idf/esp-idf!3685
2018-11-14 15:35:03 +08:00
zhiweijian 1f7c54ae85 Component/bt: fix memory leak in service change 2018-11-12 19:41:19 +08:00
Jiang Jiang Jian 049bd9fe0a Merge branch 'bugfix/mesh_start_stop_v3.2' into 'release/v3.2'
mesh: update libs (backport3.2)

See merge request idf/esp-idf!3648
2018-11-12 15:59:14 +08:00
Ivan Grokhotkov 167fb50a22 Merge branch 'temp/release_v3_2_fastforward' into 'release/v3.2'
release v3.2 fastforward

See merge request idf/esp-idf!3678
2018-11-12 15:31:58 +08:00
Liu Zhi Fu 5f3b532c8d lwip: fix crash caused by sys_mbox_free
Fix lwip crashed bug caused by sys_mbox_free()
2018-11-11 12:17:36 +08:00
qiyuexia 841a6dcd9a mesh: update libs
1. fix ap_loss that occurs when the parent turns off the mesh function and becomes a normal WiFi with a different SSID.
2. add an event MESH_EVENT_NETWORK_STATE that contains information about whether there is a root in the current network.
3. modify the mechanism of mesh IE update.
4. fix a problem in the process of re-voting to select the root, the device that does not meet the conditions of being a root votes for itself.
5. fix an issue that occurs in esp_mesh_recv_toDS() when stopping the mesh.
6. when the user specifies a parent for the device, the device will set the authmode and password of its AP mode to the same value as the specified parent.
7. add two disconnected reason codes MESH_REASON_EMPTY_PASSWORD and MESH_REASON_PARENT_UNENCRYPTED.
2018-11-06 23:00:59 +08:00
Jakob Löw f2fbfeca87 Merge branch 'master' of github.com:espressif/esp-idf 2018-10-20 23:32:01 +02:00
Mark Webb-Johnson 65355d28dd Just warn about CRC errors, don't panic abort 2018-09-26 08:27:41 +08:00
Mark Webb-Johnson 812f959cec
Merge pull request #1 from leres/master
Unbreak building under FreeBSD
2018-07-30 08:56:51 +08:00
Craig Leres 0c627b22f2 When building kconfig set -L and -I flags based on where libintl.a
is found rather than keying off OS/OSNAME.
This unbreaks building on FreeBSD (but is untested for Windows).
2018-07-28 09:19:41 -07:00
Michael Balzer 0fb2019f2b Merge remote-tracking branch 'upstream/master' 2018-07-06 20:45:32 +02:00
Mark Webb-Johnson 55d915e918 esp_ota_begin flash erase: OVMS kludge to give other tasks a chance 2018-06-21 14:11:37 +08:00
Michael Balzer 1a1a544afa Fix vfs_fat_stat() DST time offset 2018-06-07 20:48:36 +02:00
Michael Balzer c49e29f8b9 Fix crash on realloc of block with size 0 2018-06-02 13:43:04 +02:00
Michael Balzer 9cad14b151 Merge branch 'master' of https://github.com/openvehicles/esp-idf 2018-05-22 22:18:04 +02:00
Michael Balzer 5e0d903dfd xtensa_api: added esp_types for common error handler callback (bool) 2018-05-22 21:17:09 +02:00
Mark Webb-Johnson f4905cdf2f Espressif Bluetooth wont compile without stdbool.h being included 2018-05-16 10:32:33 +08:00
Michael Balzer 9d8e44e0f0 Merge branch 'master' of https://github.com/espressif/esp-idf 2018-05-11 08:47:18 +02:00
Michael Balzer daef4b5c11 panic: user callback for common error handler 2018-04-08 14:36:36 +02:00
Mark Webb-Johnson 0f978bcb45 Merge remote-tracking branch 'espressif/master' 2018-03-01 08:49:43 +08:00
Mark Webb-Johnson 78be47aad7 Extension to lwip sntp to provide a weak callback notifying us the time has been set by sntp 2018-03-01 08:48:06 +08:00
Mark Webb-Johnson 751f307e51 Reverse previous implementation of lwip sntp weak callback. Next commit will provide a better implementation. 2018-03-01 08:21:27 +08:00
Mark Webb-Johnson ddeff7d523 Extension to lwip sntp to provide a weak callback notifying us the time has been set by sntp 2018-02-27 15:43:28 +08:00
Stephen Casner 7f6161cd25 Fix stack size returned by uxTaskGetSystemState()
This code used to work, but as part of the toolchain update it looks
like there must have been a compiler change affecting the relative
precedence of '|=' and '-'.  Add parentheses to make the order
explicit.
2018-02-23 23:58:52 -08:00
Stephen Casner 4c532a59b2 Merge remote-tracking branch 'remotes/espressif/master'
Bring in the heap task tracking code accepted from PR 1498.
2018-02-23 21:57:43 -08:00
Stephen Casner 3d5f7b3efd Allow configuring serial port as USB location ID
This is a workaround for the inconsistent device naming pattern
implemented in the device driver for Silicon Labs CP2102 USB to UART
Bridge Controller.  When there are multiple devices installed on one
computer, the second and subsequent devices are given a numeric suffix
that increments every time one of the devices is plugged in.  Thus,
unplugging and reinserting a cable causes the device name to change.

The workaround is to use the device USB location identifier as an
alternative consistent handle for the device, assuming that the cable
is plugged into the same jack each time.  This workaround does not
interfere with using the normal device name as the handle for cases
where only one device is used or when the inconsistent naming is not a
problem.
2018-02-18 16:29:05 -08:00
Mark Webb-Johnson 8d8d62da9e Merge remote-tracking branch 'espressif/master' 2018-02-13 13:27:55 +08:00
Stephen Casner 5bf85d06d8 Merge latest commits from espressif/esp-idf/master 2018-01-12 22:28:04 -08:00
Stephen Casner 59bc8ff062 Temporarily add poisoning header typedef
This is to be replaced an alternate way to obtain the stack block size
by calling one or more multi_heap helper functions.
2018-01-10 17:15:13 -08:00
Stephen Casner ae5a434f76 Return stack block size and current free space in TaskStatus
For some reason, the pxStackBase member is not set in the TaskStatus_t
struct as returned by uxTaskGetSystemState(), so we are expanding its
function by returning the total size of the stack block in the high 16
bits and the current amount of free stack space in the low 16 bits.
2018-01-10 12:51:11 -08:00
Stephen Casner e533523275 Merge branch 'master' of github.com:openvehicles/esp-idf 2018-01-10 09:08:11 -08:00
Stephen Casner a376475c2b Add esp_heap_debug_dump_totals() to monitor heap usage
esp_heap_debug_dump_totals() dumps into a user-provided data structure
a summary of the amound of heap memory in region type that is used by
each task.  Optionally it will also dump into another data structure
the metadata about each allocated block for a given list of tasks or
for all tasks (limited by available space).
2018-01-10 09:06:50 -08:00
Stephen Casner bc56804a49 Add task tracking option for heap usage monitoring
Add back a feature that was available in the old heap implementation
in release/v2.1 and earlier: keep track of which task allocates each
block from the heap. The task handle is conditionally added as
another word in the heap poisoning header under this configuration
option CONFIG_HEAP_TASK_TRACKING.

To allow custom monitoring and debugging code to be added, add helper
functions in multi_heap.c and multi_heap_poisoning.c to provide access
to information in the block headers.
2018-01-10 09:06:50 -08:00
Stephen Casner eee26d4ef7 Correct the sense of a comment 2018-01-10 09:06:50 -08:00
Stephen Casner be6f6993db Add esp_heap_debug_dump_totals() to monitor heap usage
esp_heap_debug_dump_totals() dumps into a user-provided data structure
a summary of the amound of heap memory in region type that is used by
each task.  Optionally it will also dump into another data structure
the metadata about each allocated block for a given list of tasks or
for all tasks (limited by available space).
2018-01-10 01:22:11 -08:00
Stephen Casner a5bfa91217 Add task tracking option for heap usage monitoring
Add back a feature that was available in the old heap implementation
in release/v2.1 and earlier: keep track of which task allocates each
block from the heap. The task handle is conditionally added as
another word in the heap poisoning header under this configuration
option CONFIG_HEAP_TASK_TRACKING.

To allow custom monitoring and debugging code to be added, add helper
functions in multi_heap.c and multi_heap_poisoning.c to provide access
to information in the block headers.
2018-01-10 01:14:47 -08:00
Stephen Casner 96eccb52a5 Correct the sense of a comment 2018-01-09 13:00:54 -08:00
418 changed files with 10095 additions and 41271 deletions

View file

@ -33,8 +33,15 @@ variables:
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"
# Docker images
# Docker images
BOT_DOCKER_IMAGE_TAG: ":latest"
# target test repo parameters
TEST_ENV_CONFIG_REPO: "https://gitlab-ci-token:${BOT_TOKEN}@${CI_SERVER_HOST}:${CI_SERVER_PORT}/qa/ci-test-runner-configs.git"
CI_AUTO_TEST_SCRIPT_REPO_URL: "https://gitlab-ci-token:${BOT_TOKEN}@${CI_SERVER_HOST}:${CI_SERVER_PORT}/qa/auto_test_script.git"
CI_AUTO_TEST_SCRIPT_REPO_BRANCH: "ci/v3.1"
# Versioned esp-idf-doc env image to use for all document building jobs
ESP_IDF_DOC_ENV_IMAGE: "$CI_DOCKER_REGISTRY/esp-idf-doc-env:v5"
# When 'fetch' strategy is used, Gitlab removes untracked files before checking out
# new revision. However if the new revision doesn't include some of the submodules
@ -363,7 +370,11 @@ build_docker:
DOCKER_TMP_IMAGE_NAME: "idf_tmp_image"
before_script: []
script:
- export DOCKER_BUILD_ARGS="--build-arg IDF_CLONE_URL=${CI_REPOSITORY_URL} --build-arg IDF_CLONE_BRANCH_OR_TAG=${CI_COMMIT_REF_NAME} --build-arg IDF_CHECKOUT_REF=${CI_COMMIT_TAG:-$CI_COMMIT_SHA}"
- export LOCAL_CI_REPOSITORY_URL=$CI_REPOSITORY_URL
- if [ -n "$LOCAL_GITLAB_HTTPS_HOST" ]; then export LOCAL_CI_REPOSITORY_URL="https://gitlab-ci-token:${CI_JOB_TOKEN}@${LOCAL_GITLAB_HTTPS_HOST}/${CI_PROJECT_PATH}"; fi
- echo "Using repository at $LOCAL_CI_REPOSITORY_URL"
- export DOCKER_BUILD_ARGS="--build-arg IDF_CLONE_URL=${LOCAL_CI_REPOSITORY_URL} --build-arg IDF_CLONE_BRANCH_OR_TAG=${CI_COMMIT_REF_NAME} --build-arg IDF_CHECKOUT_REF=${CI_COMMIT_TAG:-$CI_COMMIT_SHA}"
# Build
- docker build --tag ${DOCKER_TMP_IMAGE_NAME} ${DOCKER_BUILD_ARGS} tools/docker/
# We can't mount $PWD/examples/get-started/blink into the container, see https://gitlab.com/gitlab-org/gitlab-ce/issues/41227.
@ -792,6 +803,18 @@ check_pipeline_triggered_by_label:
# We want to make sure some jobs are always executed to detect regression.
- test "$BOT_LABEL_REGULAR_TEST" = "true" || exit -1
# For release tag pipelines only, make sure the tag was created with 'git tag -a' so it will update
# the version returned by 'git describe'
check_version_tag:
extends: .check_job_template
only:
refs:
- /^v\d+\.\d+(\.\d+)?($|-)/
variables:
- $BOT_TRIGGER_WITH_LABEL == null
script:
- (git cat-file -t $CI_COMMIT_REF_NAME | grep tag) || echo "ESP-IDF versions must be annotated tags." && exit 1
assign_test:
tags:
- assign_test
@ -806,6 +829,11 @@ assign_test:
variables:
TEST_FW_PATH: "$CI_PROJECT_DIR/tools/tiny-test-fw"
EXAMPLE_CONFIG_OUTPUT_PATH: "$CI_PROJECT_DIR/examples/test_configs"
INTEGRATION_CONFIG_OUTPUT_PATH: "${CI_PROJECT_DIR}/components/idf_test/integration_test/CIConfigs"
TEST_CASE_FILE_PATH: "$CI_PROJECT_DIR/auto_test_script/TestCaseFiles"
ASSIGN_TEST_CASE_SCRIPT: "${CI_PROJECT_DIR}/auto_test_script/bin/CIAssignTestCases.py"
PYTHONPATH: "${CI_PROJECT_DIR}/auto_test_script/packages"
PYTHON_VER: 3.7.7
artifacts:
paths:
- components/idf_test/*/CIConfigs
@ -824,11 +852,11 @@ assign_test:
# assign unit test cases
- python $TEST_FW_PATH/CIAssignUnitTest.py $IDF_PATH/components/idf_test/unit_test/TestCaseAll.yml $IDF_PATH/.gitlab-ci.yml $IDF_PATH/components/idf_test/unit_test/CIConfigs
# clone test script to assign tests
- git clone $TEST_SCRIPT_REPOSITORY
- ./tools/ci/retry_failed.sh git clone ${CI_AUTO_TEST_SCRIPT_REPO_URL} -b empty_branch
- ./tools/ci/retry_failed.sh git -C auto_test_script checkout -f ${CI_AUTO_TEST_SCRIPT_REPO_BRANCH}
- python $CHECKOUT_REF_SCRIPT auto_test_script auto_test_script
- cd auto_test_script
# assgin integration test cases
- python CIAssignTestCases.py -t $IDF_PATH/components/idf_test/integration_test -c $IDF_PATH/.gitlab-ci.yml -b $IDF_PATH/SSC/ssc_bin
- python ${ASSIGN_TEST_CASE_SCRIPT} -t $TEST_CASE_FILE_PATH -c $IDF_PATH/.gitlab-ci.yml -b $IDF_PATH/SSC/ssc_bin -o $INTEGRATION_CONFIG_OUTPUT_PATH
.define_config_file_name: &define_config_file_name |
JOB_NAME_PREFIX=$(echo ${CI_JOB_NAME} | awk '{print $1}')
@ -870,7 +898,7 @@ assign_test:
# first test if config file exists, if not exist, exit 0
- test -e $CONFIG_FILE || exit 0
# clone test env configs
- git clone $TEST_ENV_CONFIG_REPOSITORY
- ./tools/ci/retry_failed.sh git clone $TEST_ENV_CONFIG_REPO
- python $CHECKOUT_REF_SCRIPT ci-test-runner-configs ci-test-runner-configs
- cd $TEST_FW_PATH
# run test
@ -924,24 +952,28 @@ assign_test:
variables:
LOCAL_ENV_CONFIG_PATH: "$CI_PROJECT_DIR/ci-test-runner-configs/$CI_RUNNER_DESCRIPTION/ESP32_IDF"
LOG_PATH: "$CI_PROJECT_DIR/$CI_COMMIT_SHA"
TEST_CASE_FILE_PATH: "$CI_PROJECT_DIR/components/idf_test/integration_test"
TEST_CASE_FILE_PATH: "$CI_PROJECT_DIR/auto_test_script/TestCaseFiles"
MODULE_UPDATE_FILE: "$CI_PROJECT_DIR/components/idf_test/ModuleDefinition.yml"
CONFIG_FILE_PATH: "${CI_PROJECT_DIR}/components/idf_test/integration_test/CIConfigs"
KNOWN_ISSUE_FILE: "${CI_PROJECT_DIR}/components/idf_test/integration_test/KnownIssues"
PYTHONPATH: "${CI_PROJECT_DIR}/auto_test_script/packages"
CI_RUNNER_SCRIPT: "${CI_PROJECT_DIR}/auto_test_script/bin/CIRunner.py"
PYTHON_VER: 3.7.7
before_script: *add_gitlab_key_before
script:
- *define_config_file_name
# first test if config file exists, if not exist, exit 0
- test -e $CONFIG_FILE || exit 0
# clone local test env configs
- git clone $TEST_ENV_CONFIG_REPOSITORY
- ./tools/ci/retry_failed.sh git clone $TEST_ENV_CONFIG_REPO
- python $CHECKOUT_REF_SCRIPT ci-test-runner-configs ci-test-runner-configs
- cd ci-test-runner-configs
# clone test bench
- git clone $TEST_SCRIPT_REPOSITORY
- ./tools/ci/retry_failed.sh git clone ${CI_AUTO_TEST_SCRIPT_REPO_URL} -b empty_branch
- ./tools/ci/retry_failed.sh git -C auto_test_script checkout -f ${CI_AUTO_TEST_SCRIPT_REPO_BRANCH}
- python $CHECKOUT_REF_SCRIPT auto_test_script auto_test_script
- cd auto_test_script
- cat ${KNOWN_ISSUE_FILE} >> ${TEST_CASE_FILE_PATH}/KnownIssues
# run test
- python CIRunner.py -l "$LOG_PATH/$JOG_FULL_NAME" -c $CONFIG_FILE -e $LOCAL_ENV_CONFIG_PATH -t $TEST_CASE_FILE_PATH
- python ${CI_RUNNER_SCRIPT} -l "$LOG_PATH/$JOG_FULL_NAME" -c $CONFIG_FILE -e $LOCAL_ENV_CONFIG_PATH -t $TEST_CASE_FILE_PATH
nvs_compatible_test:
<<: *test_template
@ -959,17 +991,17 @@ nvs_compatible_test:
# first test if config file exists, if not exist, exit 0
- test -e $CONFIG_FILE || exit 0
# clone local test env configs
- git clone $TEST_ENV_CONFIG_REPOSITORY
- ./tools/ci/retry_failed.sh git clone $TEST_ENV_CONFIG_REPO
- python $CHECKOUT_REF_SCRIPT ci-test-runner-configs ci-test-runner-configs
- cd ci-test-runner-configs
# clone test bench
- git clone $TEST_SCRIPT_REPOSITORY
- python $CHECKOUT_REF_SCRIPT auto_test_script auto_test_script
- cd auto_test_script
- ./tools/ci/retry_failed.sh git clone ${CI_AUTO_TEST_SCRIPT_REPO_URL} -b empty_branch
- ./tools/ci/retry_failed.sh git -C auto_test_script checkout -f ${CI_AUTO_TEST_SCRIPT_REPO_BRANCH}
- python $CHECKOUT_REF_SCRIPT auto_test_script "$CI_PROJECT_DIR/auto_test_script/TestCaseFiles"
# prepare nvs bins
- ./Tools/prepare_nvs_bin.sh
- cd auto_test_script
- ./tools/prepare_nvs_bin.sh
# run test
- python CIRunner.py -l "$LOG_PATH/$JOG_FULL_NAME" -c $CONFIG_FILE -e $LOCAL_ENV_CONFIG_PATH -t $TEST_CASE_FILE_PATH
- python ${CI_RUNNER_SCRIPT} -l "$LOG_PATH/$JOG_FULL_NAME" -c $CONFIG_FILE -e $LOCAL_ENV_CONFIG_PATH -t $TEST_CASE_FILE_PATH
example_test_001:
<<: *example_test_template
@ -1324,7 +1356,7 @@ IT_002:
IT_003:
<<: *test_template
parallel: 13
parallel: 14
tags:
- ESP32_IDF
- SSC_T2_5
@ -1344,7 +1376,7 @@ IT_005:
IT_006:
<<: *test_template
parallel: 8
parallel: 13
tags:
- ESP32_IDF
- SSC_T1_6
@ -1368,13 +1400,6 @@ IT_009:
- ESP32_IDF
- SSC_T1_3
IT_010:
<<: *test_template
parallel: 4
tags:
- ESP32_IDF
- SSC_T5_1
IT_011:
<<: *test_template
tags:
@ -1414,6 +1439,7 @@ IT_015:
IT_016:
<<: *test_template
allow_failure: true
tags:
- ESP32_IDF
- SSC_T50_MESH1
@ -1426,7 +1452,6 @@ IT_017:
IT_018:
<<: *test_template
parallel: 2
tags:
- ESP32_IDF
- SSC_T1_9

View file

@ -22,6 +22,7 @@
#define FLASH_SECTOR_SIZE 0x1000
#define FLASH_BLOCK_SIZE 0x10000
#define MMAP_ALIGNED_MASK 0x0000FFFF
/* Provide a Flash API for bootloader_support code,
that can be used from bootloader or app code.
@ -35,7 +36,7 @@
*
* @return Number of free pages
*/
uint32_t bootloader_mmap_get_free_pages();
uint32_t bootloader_mmap_get_free_pages(void);
/**
* @brief Map a region of flash to data memory

View file

@ -26,7 +26,7 @@
typedef void *bootloader_sha256_handle_t;
bootloader_sha256_handle_t bootloader_sha256_start();
bootloader_sha256_handle_t bootloader_sha256_start(void);
void bootloader_sha256_data(bootloader_sha256_handle_t handle, const void *data, size_t data_len);

View file

@ -62,3 +62,17 @@ __attribute__((noreturn)) void bootloader_utility_load_boot_image(const bootload
* It is not recommended to call this function from an app (if called, the app will abort).
*/
__attribute__((noreturn)) void bootloader_reset(void);
/** @brief Generates the digest of the data between offset & offset+length.
*
* This function should be used when the size of the data is larger than 3.2MB.
* The MMU capacity is 3.2MB (50 pages - 64KB each). This function generates the SHA-256
* of the data in chunks of 3.2MB, considering the MMU capacity.
*
* @param[in] flash_offset Offset of the data in flash.
* @param[in] len Length of data in bytes.
* @param[out] digest Pointer to buffer where the digest is written, if ESP_OK is returned.
*
* @return ESP_OK if secure boot digest is generated successfully.
*/
esp_err_t bootloader_sha256_flash_contents(uint32_t flash_offset, uint32_t len, uint8_t *digest);

View file

@ -26,6 +26,8 @@
#include "esp_flash_partitions.h"
#include "bootloader_flash.h"
#include "bootloader_common.h"
#include "bootloader_config.h"
#include "bootloader_utility.h"
#include "soc/gpio_periph.h"
#include "soc/efuse_reg.h"
#include "soc/rtc.h"
@ -186,22 +188,7 @@ esp_err_t bootloader_common_get_sha256_of_partition (uint32_t address, uint32_t
size = data.image_len;
}
// If image is type by data then hash is calculated for entire image.
const void *partition_bin = bootloader_mmap(address, size);
if (partition_bin == NULL) {
ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", address, size);
return ESP_FAIL;
}
bootloader_sha256_handle_t sha_handle = bootloader_sha256_start();
if (sha_handle == NULL) {
bootloader_munmap(partition_bin);
return ESP_ERR_NO_MEM;
}
bootloader_sha256_data(sha_handle, partition_bin, size);
bootloader_sha256_finish(sha_handle, out_sha_256);
bootloader_munmap(partition_bin);
return ESP_OK;
return bootloader_sha256_flash_contents(address, size, out_sha_256);
}
int bootloader_common_select_otadata(const esp_ota_select_entry_t *two_otadata, bool *valid_two_otadata, bool max)
@ -247,13 +234,15 @@ esp_err_t bootloader_common_get_partition_description(const esp_partition_pos_t
return ESP_ERR_INVALID_ARG;
}
const uint8_t *image = bootloader_mmap(partition->offset, partition->size);
const uint32_t app_desc_offset = sizeof(esp_image_header_t) + sizeof(esp_image_segment_header_t);
const uint32_t mmap_size = app_desc_offset + sizeof(esp_app_desc_t);
const uint8_t *image = bootloader_mmap(partition->offset, mmap_size);
if (image == NULL) {
ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", partition->offset, partition->size);
ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", partition->offset, mmap_size);
return ESP_FAIL;
}
memcpy(app_desc, image + sizeof(esp_image_header_t) + sizeof(esp_image_segment_header_t), sizeof(esp_app_desc_t));
memcpy(app_desc, image + app_desc_offset, sizeof(esp_app_desc_t));
bootloader_munmap(image);
if (app_desc->magic_word != ESP_APP_DESC_MAGIC_WORD) {

View file

@ -21,7 +21,7 @@
// App version is a wrapper around mbedTLS SHA API
#include <mbedtls/sha256.h>
bootloader_sha256_handle_t bootloader_sha256_start()
bootloader_sha256_handle_t bootloader_sha256_start(void)
{
mbedtls_sha256_context *ctx = (mbedtls_sha256_context *)malloc(sizeof(mbedtls_sha256_context));
if (!ctx) {
@ -53,6 +53,7 @@ void bootloader_sha256_finish(bootloader_sha256_handle_t handle, uint8_t *digest
}
mbedtls_sha256_free(ctx);
free(handle);
handle = NULL;
}
#else // Bootloader version
@ -70,7 +71,7 @@ static const size_t BLOCK_WORDS = (64/sizeof(uint32_t));
// Words in final SHA256 digest
static const size_t DIGEST_WORDS = (32/sizeof(uint32_t));
bootloader_sha256_handle_t bootloader_sha256_start()
bootloader_sha256_handle_t bootloader_sha256_start(void)
{
// Enable SHA hardware
ets_sha_enable();

View file

@ -703,3 +703,39 @@ void bootloader_reset(void)
abort(); /* This function should really not be called from application code */
#endif
}
esp_err_t bootloader_sha256_flash_contents(uint32_t flash_offset, uint32_t len, uint8_t *digest)
{
if (digest == NULL) {
return ESP_ERR_INVALID_ARG;
}
/* Handling firmware images larger than MMU capacity */
uint32_t mmu_free_pages_count = bootloader_mmap_get_free_pages();
bootloader_sha256_handle_t sha_handle = NULL;
sha_handle = bootloader_sha256_start();
if (sha_handle == NULL) {
return ESP_ERR_NO_MEM;
}
while (len > 0) {
uint32_t mmu_page_offset = ((flash_offset & MMAP_ALIGNED_MASK) != 0) ? 1 : 0; /* Skip 1st MMU Page if it is already populated */
uint32_t partial_image_len = MIN(len, ((mmu_free_pages_count - mmu_page_offset) * SPI_FLASH_MMU_PAGE_SIZE)); /* Read the image that fits in the free MMU pages */
const void * image = bootloader_mmap(flash_offset, partial_image_len);
if (image == NULL) {
bootloader_sha256_finish(sha_handle, NULL);
return ESP_FAIL;
}
bootloader_sha256_data(sha_handle, image, partial_image_len);
bootloader_munmap(image);
flash_offset += partial_image_len;
len -= partial_image_len;
}
bootloader_sha256_finish(sha_handle, digest);
return ESP_OK;
}

View file

@ -371,12 +371,12 @@ if(CONFIG_BT_ENABLED)
"esp_ble_mesh/mesh_core/settings.c"
"esp_ble_mesh/mesh_core/test.c"
"esp_ble_mesh/mesh_core/transport.c"
"esp_ble_mesh/mesh_models/common/device_property.c"
"esp_ble_mesh/mesh_models/client/client_common.c"
"esp_ble_mesh/mesh_models/client/generic_client.c"
"esp_ble_mesh/mesh_models/client/lighting_client.c"
"esp_ble_mesh/mesh_models/client/sensor_client.c"
"esp_ble_mesh/mesh_models/client/time_scene_client.c"
"esp_ble_mesh/mesh_models/server/device_property.c"
"esp_ble_mesh/mesh_models/server/generic_server.c"
"esp_ble_mesh/mesh_models/server/lighting_server.c"
"esp_ble_mesh/mesh_models/server/sensor_server.c"

View file

@ -1738,12 +1738,65 @@ if BLE_MESH
option in the Bluetooth Controller section in menuconfig, which is
"Scan Duplicate By Device Address and Advertising Data".
config BLE_MESH_ALLOC_FROM_PSRAM_FIRST
bool "BLE Mesh will first allocate memory from PSRAM"
choice BLE_MESH_MEM_ALLOC_MODE
prompt "Memory allocation strategy"
default BLE_MESH_MEM_ALLOC_MODE_INTERNAL
help
Allocation strategy for BLE Mesh stack, essentially provides ability to
allocate all required dynamic allocations from,
- Internal DRAM memory only
- External SPIRAM memory only
- Either internal or external memory based on default malloc()
behavior in ESP-IDF
Recommended mode here is always internal, since that is most preferred
from security perspective. But if application requirement does not allow
sufficient free internal memory then alternate mode can be selected.
config BLE_MESH_MEM_ALLOC_MODE_INTERNAL
bool "Internal DRAM"
config BLE_MESH_ALLOC_FROM_PSRAM_FIRST
bool "External SPIRAM"
depends on SPIRAM_SUPPORT
config BLE_MESH_MEM_ALLOC_MODE_DEFAULT
bool "Default alloc mode"
depends on SPIRAM_SUPPORT
help
Enable this option to use the default memory allocation strategy when
external SPIRAM is enabled. See the SPIRAM options for more details.
endchoice # BLE_MESH_MEM_ALLOC_MODE
config BLE_MESH_FREERTOS_STATIC_ALLOC
bool "Enable FreeRTOS static allocation"
depends on SUPPORT_STATIC_ALLOCATION && SPIRAM_SUPPORT
default n
help
When this option is enabled, BLE Mesh stack will try to allocate memory
from PSRAM firstly. This will save the internal RAM if PSRAM exists.
Enable this option to use FreeRTOS static allocation APIs for BLE Mesh,
which provides the ability to use different dynamic memory (i.e. SPIRAM)
for FreeRTOS objects.
If this option is disabled, the FreeRTOS static allocation APIs will not
be used, and internal DRAM will be allocated for FreeRTOS objects.
choice BLE_MESH_FREERTOS_STATIC_ALLOC_MODE
prompt "Memory allocation for FreeRTOS objects"
depends on BLE_MESH_FREERTOS_STATIC_ALLOC
help
Choose the memory to be used for FreeRTOS objects.
config BLE_MESH_FREERTOS_STATIC_ALLOC_EXTERNAL
bool "External SPIRAM"
depends on SPIRAM_SUPPORT
help
If enabled, BLE Mesh allocates dynamic memory from external SPIRAM for
FreeRTOS objects, i.e. mutex, queue, and task stack. External SPIRAM
can only be used for task stack when SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY
is enabled. See the SPIRAM options for more details.
endchoice # BLE_MESH_FREERTOS_STATIC_ALLOC_MODE
config BLE_MESH_FAST_PROV
bool "Enable BLE Mesh Fast Provisioning"
@ -1919,7 +1972,7 @@ if BLE_MESH
advertising bearer.
config BLE_MESH_NET_BUF_POOL_USAGE
bool "BLE Mesh net buffer pool usage tracking"
bool
default y
help
Enable BLE Mesh net buffer pool tracking. This option is used to introduce another
@ -1977,7 +2030,7 @@ if BLE_MESH
config BLE_MESH_SEQ_STORE_RATE
int "How often the sequence number gets updated in storage"
range 0 1000000
default 6
default 0
help
This value defines how often the local sequence number gets updated in
persistent storage (i.e. flash). e.g. a value of 100 means that the
@ -1992,7 +2045,7 @@ if BLE_MESH
config BLE_MESH_RPL_STORE_TIMEOUT
int "Minimum frequency that the RPL gets updated in storage"
range 0 1000000
default 5
default 0
help
This value defines in seconds how soon the RPL (Replay Protection List)
gets written to persistent storage after a change occurs. If the node

View file

@ -213,7 +213,7 @@ esp_err_t esp_bt_gap_remove_bond_device(esp_bd_addr_t bd_addr)
int esp_bt_gap_get_bond_device_num(void)
{
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
return ESP_FAIL;
return ESP_ERR_INVALID_STATE;
}
return btc_storage_get_num_bt_bond_devices();
}
@ -221,7 +221,6 @@ int esp_bt_gap_get_bond_device_num(void)
esp_err_t esp_bt_gap_get_bond_device_list(int *dev_num, esp_bd_addr_t *dev_list)
{
int ret;
int dev_num_total;
if (dev_num == NULL || dev_list == NULL) {
return ESP_ERR_INVALID_ARG;
@ -231,12 +230,7 @@ esp_err_t esp_bt_gap_get_bond_device_list(int *dev_num, esp_bd_addr_t *dev_list)
return ESP_ERR_INVALID_STATE;
}
dev_num_total = btc_storage_get_num_bt_bond_devices();
if (*dev_num > dev_num_total) {
*dev_num = dev_num_total;
}
ret = btc_storage_get_bonded_bt_devices_list((bt_bdaddr_t *)dev_list, *dev_num);
ret = btc_storage_get_bonded_bt_devices_list((bt_bdaddr_t *)dev_list, dev_num);
return (ret == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}

View file

@ -50,9 +50,33 @@ esp_err_t esp_ble_gatt_set_local_mtu (uint16_t mtu)
#if (BLE_INCLUDED == TRUE)
extern uint16_t L2CA_GetFreePktBufferNum_LE(void);
/**
* @brief This function is called to get currently sendable packets number on controller,
* the function is called only in BLE running core and single connection now.
*
* @return
* sendable packets number on controller
*
*/
uint16_t esp_ble_get_sendable_packets_num ()
uint16_t esp_ble_get_sendable_packets_num (void)
{
return L2CA_GetFreePktBufferNum_LE();
}
/**
* @brief This function is used to query the number of available buffers for the current connection.
* When you need to query the current available buffer number, it is recommended to use this API.
* @param[in] conn_id: current connection id.
*
* @return
* Number of available buffers for the current connection
*
*/
extern UINT16 L2CA_GetCurFreePktBufferNum_LE(UINT16 conn_id);
uint16_t esp_ble_get_cur_sendable_packets_num (uint16_t connid)
{
return L2CA_GetCurFreePktBufferNum_LE(connid);
}
#endif

View file

@ -431,6 +431,9 @@ esp_err_t esp_ble_gattc_write_char(esp_gatt_if_t gattc_if,
arg.write_char.value = value;
arg.write_char.write_type = write_type;
arg.write_char.auth_req = auth_req;
if(write_type == ESP_GATT_WRITE_TYPE_NO_RSP){
l2ble_update_att_acl_pkt_num(L2CA_ADD_BTC_NUM, NULL);
}
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), btc_gattc_arg_deep_copy) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
@ -462,6 +465,10 @@ esp_err_t esp_ble_gattc_write_char_descr (esp_gatt_if_t gattc_if,
arg.write_descr.write_type = write_type;
arg.write_descr.auth_req = auth_req;
if(write_type == ESP_GATT_WRITE_TYPE_NO_RSP){
l2ble_update_att_acl_pkt_num(L2CA_ADD_BTC_NUM, NULL);
}
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), btc_gattc_arg_deep_copy) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}

View file

@ -274,6 +274,9 @@ esp_err_t esp_ble_gatts_send_indicate(esp_gatt_if_t gatts_if, uint16_t conn_id,
arg.send_ind.value_len = value_len;
arg.send_ind.value = value;
if(need_confirm == false){
l2ble_update_att_acl_pkt_num(L2CA_ADD_BTC_NUM, NULL);
}
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t),
btc_gatts_arg_deep_copy) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}

View file

@ -154,6 +154,17 @@ esp_err_t esp_spp_start_srv(esp_spp_sec_t sec_mask,
return (btc_transfer_context(&msg, &arg, sizeof(btc_spp_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_spp_stop_srv(void)
{
btc_msg_t msg;
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_SPP;
msg.act = BTC_SPP_ACT_STOP_SRV;
return (btc_transfer_context(&msg, NULL, sizeof(btc_spp_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_spp_write(uint32_t handle, int len, uint8_t *p_data)
{

View file

@ -76,7 +76,7 @@ typedef enum {
/// A2DP media control commands
typedef enum {
ESP_A2D_MEDIA_CTRL_NONE = 0, /*!< dummy command */
ESP_A2D_MEDIA_CTRL_NONE = 0, /*!< Not for application use, use inside stack only. */
ESP_A2D_MEDIA_CTRL_CHECK_SRC_RDY, /*!< check whether AVDTP is connected, only used in A2DP source */
ESP_A2D_MEDIA_CTRL_START, /*!< command to set up media transmission channel */
ESP_A2D_MEDIA_CTRL_STOP, /*!< command to stop media transmission */

View file

@ -174,6 +174,7 @@ typedef enum {
ESP_BT_GAP_KEY_NOTIF_EVT, /*!< Simple Pairing Passkey Notification */
ESP_BT_GAP_KEY_REQ_EVT, /*!< Simple Pairing Passkey request */
ESP_BT_GAP_READ_RSSI_DELTA_EVT, /*!< read rssi event */
ESP_BT_GAP_REMOVE_BOND_DEV_COMPLETE_EVT, /*!< remove bond device complete event */
ESP_BT_GAP_EVT_MAX,
} esp_bt_gap_cb_event_t;
@ -271,6 +272,14 @@ typedef union {
struct key_req_param {
esp_bd_addr_t bda; /*!< remote bluetooth device address*/
} key_req; /*!< passkey request parameter struct */
/**
* @brief ESP_BT_GAP_REMOVE_BOND_DEV_COMPLETE_EVT
*/
struct bt_remove_bond_dev_cmpl_evt_param {
esp_bd_addr_t bda; /*!< remote bluetooth device address*/
esp_bt_status_t status; /*!< Indicate the remove bond device operation success status */
}remove_bond_dev_cmpl; /*!< Event parameter of ESP_BT_GAP_REMOVE_BOND_DEV_COMPLETE_EVT */
} esp_bt_gap_cb_param_t;
/**

View file

@ -46,6 +46,7 @@ extern esp_err_t esp_ble_gatt_set_local_mtu (uint16_t mtu);
#if (BLE_INCLUDED == TRUE)
extern uint16_t esp_ble_get_sendable_packets_num (void);
extern uint16_t esp_ble_get_cur_sendable_packets_num (uint16_t connid);
#endif
#ifdef __cplusplus

View file

@ -57,6 +57,7 @@ typedef enum {
*/
typedef enum {
ESP_SPP_INIT_EVT = 0, /*!< When SPP is inited, the event comes */
ESP_SPP_UNINIT_EVT = 1, /*!< When SPP is uninited, the event comes */
ESP_SPP_DISCOVERY_COMP_EVT = 8, /*!< When SDP discovery complete, the event comes */
ESP_SPP_OPEN_EVT = 26, /*!< When SPP Client connection open, the event comes */
ESP_SPP_CLOSE_EVT = 27, /*!< When SPP connection closed, the event comes */
@ -66,6 +67,7 @@ typedef enum {
ESP_SPP_CONG_EVT = 31, /*!< When SPP connection congestion status changed, the event comes, only for ESP_SPP_MODE_CB */
ESP_SPP_WRITE_EVT = 33, /*!< When SPP write operation completes, the event comes, only for ESP_SPP_MODE_CB */
ESP_SPP_SRV_OPEN_EVT = 34, /*!< When SPP Server connection open, the event comes */
ESP_SPP_SRV_STOP_EVT = 35, /*!< When SPP server stopped, the event comes */
} esp_spp_cb_event_t;
@ -80,6 +82,13 @@ typedef union {
esp_spp_status_t status; /*!< status */
} init; /*!< SPP callback param of SPP_INIT_EVT */
/**
* @brief SPP_UNINIT_EVT
*/
struct spp_uninit_evt_param {
esp_spp_status_t status; /*!< status */
} uninit; /*!< SPP callback param of SPP_UNINIT_EVT */
/**
* @brief SPP_DISCOVERY_COMP_EVT
*/
@ -128,6 +137,14 @@ typedef union {
uint8_t sec_id; /*!< security ID used by this server */
bool use_co; /*!< TRUE to use co_rfc_data */
} start; /*!< SPP callback param of ESP_SPP_START_EVT */
/**
* @brief ESP_SPP_SRV_STOP_EVT
*/
struct spp_srv_stop_evt_param {
esp_spp_status_t status; /*!< status */
} srv_stop; /*!< SPP callback param of ESP_SPP_SRV_STOP_EVT */
/**
* @brief ESP_SPP_CL_INIT_EVT
*/
@ -273,6 +290,16 @@ esp_err_t esp_spp_disconnect(uint32_t handle);
esp_err_t esp_spp_start_srv(esp_spp_sec_t sec_mask,
esp_spp_role_t role, uint8_t local_scn, const char *name);
/**
* @brief This function stops a SPP server
* When the server is stopped successfully, the callback is called
* with ESP_SPP_SRV_STOP_EVT.
*
* @return
* - ESP_OK: success
* - other: failed
*/
esp_err_t esp_spp_stop_srv(void);
/**
* @brief This function is used to write data, only for ESP_SPP_MODE_CB.

View file

@ -610,7 +610,7 @@ void bta_dm_ble_read_adv_tx_power(tBTA_DM_MSG *p_data)
}
}
void bta_dm_ble_read_rssi(tBTA_DM_MSG *p_data)
void bta_dm_read_rssi(tBTA_DM_MSG *p_data)
{
if (p_data->rssi.read_rssi_cb != NULL) {
BTM_ReadRSSI(p_data->rssi.remote_addr, p_data->rssi.transport, p_data->rssi.read_rssi_cb);
@ -756,11 +756,13 @@ void bta_dm_remove_device(tBTA_DM_MSG *p_data)
/* Take the link down first, and mark the device for removal when disconnected */
for (int i = 0; i < bta_dm_cb.device_list.count; i++) {
if (!bdcmp(bta_dm_cb.device_list.peer_device[i].peer_bdaddr, p_dev->bd_addr)
&& bta_dm_cb.device_list.peer_device[i].transport == transport) {
#if BLE_INCLUDED == TRUE
&& bta_dm_cb.device_list.peer_device[i].transport == transport
#endif
) {
bta_dm_cb.device_list.peer_device[i].conn_state = BTA_DM_UNPAIRING;
btm_remove_acl( p_dev->bd_addr, bta_dm_cb.device_list.peer_device[i].transport);
APPL_TRACE_DEBUG("%s:transport = %d", __func__,
bta_dm_cb.device_list.peer_device[i].transport);
btm_remove_acl( p_dev->bd_addr, transport);
APPL_TRACE_DEBUG("%s:transport = %d", __func__, transport);
break;
}
}

View file

@ -206,11 +206,11 @@ void BTA_DmBleReadAdvTxPower(tBTA_CMPL_CB *cmpl_cb)
}
}
void BTA_DmBleReadRSSI(BD_ADDR remote_addr, tBTA_TRANSPORT transport, tBTA_CMPL_CB *cmpl_cb)
void BTA_DmReadRSSI(BD_ADDR remote_addr, tBTA_TRANSPORT transport, tBTA_CMPL_CB *cmpl_cb)
{
tBTA_DM_API_READ_RSSI *p_msg;
if ((p_msg = (tBTA_DM_API_READ_RSSI *)osi_malloc(sizeof(tBTA_DM_API_READ_RSSI))) != NULL) {
p_msg->hdr.event = BTA_DM_API_BLE_READ_RSSI_EVT;
p_msg->hdr.event = BTA_DM_API_READ_RSSI_EVT;
memcpy(p_msg->remote_addr, remote_addr, sizeof(BD_ADDR));
p_msg->transport = transport;
p_msg->read_rssi_cb = cmpl_cb;

View file

@ -159,7 +159,7 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
bta_dm_remove_device, /* BTA_DM_API_REMOVE_DEVICE_EVT */
bta_dm_update_white_list, /* BTA_DM_API_UPDATE_WHITE_LIST_EVT */
bta_dm_ble_read_adv_tx_power, /* BTA_DM_API_BLE_READ_ADV_TX_POWER_EVT */
bta_dm_ble_read_rssi, /* BTA_DM_API_BLE_READ_RSSI_EVT */
bta_dm_read_rssi, /* BTA_DM_API_READ_RSSI_EVT */
bta_dm_ble_update_duplicate_exceptional_list,/* BTA_DM_API_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_EVT */
};

View file

@ -155,7 +155,7 @@ enum {
BTA_DM_API_REMOVE_DEVICE_EVT,
BTA_DM_API_UPDATE_WHITE_LIST_EVT,
BTA_DM_API_BLE_READ_ADV_TX_POWER_EVT,
BTA_DM_API_BLE_READ_RSSI_EVT,
BTA_DM_API_READ_RSSI_EVT,
BTA_DM_API_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_EVT,
BTA_DM_MAX_EVT
};
@ -1226,7 +1226,7 @@ extern void bta_dm_disable (tBTA_DM_MSG *p_data);
extern void bta_dm_set_dev_name (tBTA_DM_MSG *p_data);
extern void bta_dm_update_white_list(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_read_adv_tx_power(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_read_rssi(tBTA_DM_MSG *p_data);
extern void bta_dm_read_rssi(tBTA_DM_MSG *p_data);
extern void bta_dm_set_visibility (tBTA_DM_MSG *p_data);
extern void bta_dm_set_scan_config(tBTA_DM_MSG *p_data);

View file

@ -31,7 +31,7 @@
#include "bta/bta_sys.h"
#include "bta/bta_gatt_api.h"
#include "bta_gattc_int.h"
#include "stack/l2c_api.h"
/*****************************************************************************
** Constants
*****************************************************************************/
@ -603,6 +603,10 @@ void BTA_GATTC_WriteCharValue ( UINT16 conn_id,
memcpy(p_buf->p_value, p_value, len);
}
if(write_type == BTA_GATTC_TYPE_WRITE_NO_RSP){
l2ble_update_att_acl_pkt_num(L2CA_DECREASE_BTC_NUM, NULL);
l2ble_update_att_acl_pkt_num(L2CA_ADD_BTU_NUM, NULL);
}
bta_sys_sendmsg(p_buf);
}
return;
@ -650,6 +654,10 @@ void BTA_GATTC_WriteCharDescr (UINT16 conn_id,
memcpy(p_buf->p_value, p_data->p_value, p_data->len);
}
if(write_type == BTA_GATTC_TYPE_WRITE_NO_RSP){
l2ble_update_att_acl_pkt_num(L2CA_DECREASE_BTC_NUM, NULL);
l2ble_update_att_acl_pkt_num(L2CA_ADD_BTU_NUM, NULL);
}
bta_sys_sendmsg(p_buf);
}
return;

View file

@ -35,6 +35,7 @@
#include "stack/btm_ble_api.h"
#include <string.h>
#include "osi/allocator.h"
#include "stack/l2c_api.h"
static void bta_gatts_nv_save_cback(BOOLEAN is_saved, tGATTS_HNDL_RANGE *p_hndl_range);
static BOOLEAN bta_gatts_nv_srv_chg_cback(tGATTS_SRV_CHG_CMD cmd, tGATTS_SRV_CHG_REQ *p_req,
@ -672,6 +673,7 @@ void bta_gatts_indicate_handle (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
p_msg->api_indicate.len,
p_msg->api_indicate.value);
} else {
l2ble_update_att_acl_pkt_num(L2CA_DECREASE_BTU_NUM, NULL);
status = GATTS_HandleValueNotification (p_msg->api_indicate.hdr.layer_specific,
p_msg->api_indicate.attr_id,
p_msg->api_indicate.len,

View file

@ -31,7 +31,7 @@
#include "bta/bta_gatt_api.h"
#include "bta_gatts_int.h"
#include "osi/allocator.h"
#include "stack/l2c_api.h"
/*****************************************************************************
** Constants
*****************************************************************************/
@ -426,6 +426,11 @@ void BTA_GATTS_HandleValueIndication (UINT16 conn_id, UINT16 attr_id, UINT16 dat
memcpy(p_buf->value, p_data, data_len);
}
if(need_confirm == false){
l2ble_update_att_acl_pkt_num(L2CA_DECREASE_BTC_NUM, NULL);
l2ble_update_att_acl_pkt_num(L2CA_ADD_BTU_NUM, NULL);
}
bta_sys_sendmsg(p_buf);
}
return;

View file

@ -926,7 +926,7 @@ typedef union {
tBTA_DM_PIN_REQ pin_req; /* PIN request. */
tBTA_DM_AUTH_CMPL auth_cmpl; /* Authentication complete indication. */
tBTA_DM_AUTHORIZE authorize; /* Authorization request. */
tBTA_DM_LINK_UP link_up; /* ACL connection down event */
tBTA_DM_LINK_UP link_up; /* ACL connection up event */
tBTA_DM_LINK_DOWN link_down; /* ACL connection down event */
tBTA_DM_BUSY_LEVEL busy_level; /* System busy level */
tBTA_DM_SP_CFM_REQ cfm_req; /* user confirm request */
@ -1457,7 +1457,7 @@ extern void BTA_DmUpdateWhiteList(BOOLEAN add_remove, BD_ADDR remote_addr, tBTA
extern void BTA_DmBleReadAdvTxPower(tBTA_CMPL_CB *cmpl_cb);
extern void BTA_DmBleReadRSSI(BD_ADDR remote_addr, tBTA_TRANSPORT transport, tBTA_CMPL_CB *cmpl_cb);
extern void BTA_DmReadRSSI(BD_ADDR remote_addr, tBTA_TRANSPORT transport, tBTA_CMPL_CB *cmpl_cb);
/*******************************************************************************
**
@ -2296,8 +2296,8 @@ extern void BTA_DmBleSetScanRspRaw (UINT8 *p_raw_scan_rsp, UINT32 raw_scan_rsp_l
** Returns None
**
*******************************************************************************/
extern void BTA_DmUpdateDuplicateExceptionalList(UINT8 subcode, UINT32 type,
BD_ADDR device_info,
extern void BTA_DmUpdateDuplicateExceptionalList(UINT8 subcode, UINT32 type,
BD_ADDR device_info,
tBTA_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK p_update_duplicate_exceptional_list_cback);
/*******************************************************************************

View file

@ -129,11 +129,13 @@ typedef UINT8 tBTA_JV_CONN_STATE;
/* Java I/F callback events */
/* events received by tBTA_JV_DM_CBACK */
#define BTA_JV_ENABLE_EVT 0 /* JV enabled */
#define BTA_JV_DISABLE_EVT 1 /* JV disabled */
#define BTA_JV_GET_SCN_EVT 6 /* Reserved an SCN */
#define BTA_JV_GET_PSM_EVT 7 /* Reserved a PSM */
#define BTA_JV_DISCOVERY_COMP_EVT 8 /* SDP discovery complete */
#define BTA_JV_CREATE_RECORD_EVT 11 /* the result for BTA_JvCreateRecord */
/* events received by tBTA_JV_L2CAP_CBACK */
#if BTA_JV_L2CAP_INCLUDED
#define BTA_JV_L2CAP_OPEN_EVT 16 /* open status of L2CAP connection */
#define BTA_JV_L2CAP_CLOSE_EVT 17 /* L2CAP connection closed */
#define BTA_JV_L2CAP_START_EVT 18 /* L2CAP server started */
@ -144,6 +146,7 @@ typedef UINT8 tBTA_JV_CONN_STATE;
#define BTA_JV_L2CAP_RECEIVE_EVT 23 /* the result for BTA_JvL2capReceive*/
#define BTA_JV_L2CAP_WRITE_EVT 24 /* the result for BTA_JvL2capWrite*/
#define BTA_JV_L2CAP_WRITE_FIXED_EVT 25 /* the result for BTA_JvL2capWriteFixed */
#endif /* BTA_JV_L2CAP_INCLUDED */
/* events received by tBTA_JV_RFCOMM_CBACK */
#define BTA_JV_RFCOMM_OPEN_EVT 26 /* open status of RFCOMM Client connection */
@ -155,7 +158,8 @@ typedef UINT8 tBTA_JV_CONN_STATE;
#define BTA_JV_RFCOMM_READ_EVT 32 /* the result for BTA_JvRfcommRead */
#define BTA_JV_RFCOMM_WRITE_EVT 33 /* the result for BTA_JvRfcommWrite*/
#define BTA_JV_RFCOMM_SRV_OPEN_EVT 34 /* open status of Server RFCOMM connection */
#define BTA_JV_MAX_EVT 35 /* max number of JV events */
#define BTA_JV_FREE_SCN_EVT 35 /* FREE an SCN */
#define BTA_JV_MAX_EVT 36 /* max number of JV events */
typedef UINT16 tBTA_JV_EVT;
@ -178,6 +182,7 @@ typedef struct {
UINT32 handle; /* The SDP handle */
} tBTA_JV_CREATE_RECORD;
#if BTA_JV_L2CAP_INCLUDED
/* data associated with BTA_JV_L2CAP_OPEN_EVT */
typedef struct {
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
@ -186,18 +191,6 @@ typedef struct {
INT32 tx_mtu; /* The transmit MTU */
} tBTA_JV_L2CAP_OPEN;
/* data associated with BTA_JV_L2CAP_OPEN_EVT for LE sockets */
typedef struct {
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
UINT32 handle; /* The connection handle */
BD_ADDR rem_bda; /* The peer address */
INT32 tx_mtu; /* The transmit MTU */
void **p_p_cback; /* set them for new socket */
void **p_user_data;/* set them for new socket */
} tBTA_JV_L2CAP_LE_OPEN;
/* data associated with BTA_JV_L2CAP_CLOSE_EVT */
typedef struct {
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
@ -255,6 +248,22 @@ typedef struct {
BOOLEAN cong; /* congestion status */
} tBTA_JV_L2CAP_WRITE;
/* data associated with BTA_JV_L2CAP_OPEN_EVT for LE sockets */
typedef struct {
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
UINT32 handle; /* The connection handle */
BD_ADDR rem_bda; /* The peer address */
INT32 tx_mtu; /* The transmit MTU */
void **p_p_cback; /* set them for new socket */
void **p_user_data;/* set them for new socket */
} tBTA_JV_L2CAP_LE_OPEN;
/*data associated with BTA_JV_L2CAP_DATA_IND_EVT if used for LE */
typedef struct {
UINT32 handle; /* The connection handle */
BT_HDR *p_buf; /* The incoming data */
} tBTA_JV_LE_DATA_IND;
/* data associated with BTA_JV_L2CAP_WRITE_FIXED_EVT */
typedef struct {
@ -265,6 +274,7 @@ typedef struct {
UINT16 len; /* The length of the data written. */
BOOLEAN cong; /* congestion status */
} tBTA_JV_L2CAP_WRITE_FIXED;
#endif /* BTA_JV_L2CAP_INCLUDED */
/* data associated with BTA_JV_RFCOMM_OPEN_EVT */
typedef struct {
@ -272,6 +282,7 @@ typedef struct {
UINT32 handle; /* The connection handle */
BD_ADDR rem_bda; /* The peer address */
} tBTA_JV_RFCOMM_OPEN;
/* data associated with BTA_JV_RFCOMM_SRV_OPEN_EVT */
typedef struct {
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
@ -280,7 +291,6 @@ typedef struct {
BD_ADDR rem_bda; /* The peer address */
} tBTA_JV_RFCOMM_SRV_OPEN;
/* data associated with BTA_JV_RFCOMM_CLOSE_EVT */
typedef struct {
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
@ -304,19 +314,13 @@ typedef struct {
UINT8 sec_id; /* security ID used by this client */
BOOLEAN use_co; /* TRUE to use co_rfc_data */
} tBTA_JV_RFCOMM_CL_INIT;
/*data associated with BTA_JV_L2CAP_DATA_IND_EVT & BTA_JV_RFCOMM_DATA_IND_EVT */
typedef struct {
UINT32 handle; /* The connection handle */
BT_HDR *p_buf; /* The incoming data */
} tBTA_JV_DATA_IND;
/*data associated with BTA_JV_L2CAP_DATA_IND_EVT if used for LE */
typedef struct {
UINT32 handle; /* The connection handle */
BT_HDR *p_buf; /* The incoming data */
} tBTA_JV_LE_DATA_IND;
/* data associated with BTA_JV_RFCOMM_CONG_EVT */
typedef struct {
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
@ -356,6 +360,23 @@ typedef struct {
tBTA_JV_CONN_STATE state; /* JV connection stata */
} tBTA_JV_NOTIFY_PM_STATE_CHANGE;
/* indicate server at which status */
typedef enum {
BTA_JV_SERVER_START_FAILED,
BTA_JV_SERVER_RUNNING,
BTA_JV_SERVER_STATUS_MAX,
} tBTA_JV_SERVER_STATUS;
typedef struct {
tBTA_JV_SERVER_STATUS server_status;
UINT32 slot_id;
}tBTA_JV_FREE_SCN_USER_DATA;
/* data associated with BTA_JV_FREE_SCN_EVT */
typedef struct {
tBTA_JV_STATUS status; /* Status of the operation */
tBTA_JV_SERVER_STATUS server_status;
} tBTA_JV_FREE_SCN;
/* union of data associated with JV callback */
typedef union {
@ -365,6 +386,7 @@ typedef union {
UINT8 scn; /* BTA_JV_GET_SCN_EVT */
UINT16 psm; /* BTA_JV_GET_PSM_EVT */
tBTA_JV_CREATE_RECORD create_rec; /* BTA_JV_CREATE_RECORD_EVT */
#if BTA_JV_L2CAP_INCLUDED
tBTA_JV_L2CAP_OPEN l2c_open; /* BTA_JV_L2CAP_OPEN_EVT */
tBTA_JV_L2CAP_CLOSE l2c_close; /* BTA_JV_L2CAP_CLOSE_EVT */
tBTA_JV_L2CAP_START l2c_start; /* BTA_JV_L2CAP_START_EVT */
@ -372,6 +394,7 @@ typedef union {
tBTA_JV_L2CAP_CONG l2c_cong; /* BTA_JV_L2CAP_CONG_EVT */
tBTA_JV_L2CAP_READ l2c_read; /* BTA_JV_L2CAP_READ_EVT */
tBTA_JV_L2CAP_WRITE l2c_write; /* BTA_JV_L2CAP_WRITE_EVT */
#endif /* BTA_JV_L2CAP_INCLUDED */
tBTA_JV_RFCOMM_OPEN rfc_open; /* BTA_JV_RFCOMM_OPEN_EVT */
tBTA_JV_RFCOMM_SRV_OPEN rfc_srv_open; /* BTA_JV_RFCOMM_SRV_OPEN_EVT */
tBTA_JV_RFCOMM_CLOSE rfc_close; /* BTA_JV_RFCOMM_CLOSE_EVT */
@ -382,9 +405,12 @@ typedef union {
tBTA_JV_RFCOMM_WRITE rfc_write; /* BTA_JV_RFCOMM_WRITE_EVT */
tBTA_JV_DATA_IND data_ind; /* BTA_JV_L2CAP_DATA_IND_EVT
BTA_JV_RFCOMM_DATA_IND_EVT */
tBTA_JV_LE_DATA_IND le_data_ind; /* BTA_JV_L2CAP_LE_DATA_IND_EVT */
tBTA_JV_FREE_SCN free_scn; /* BTA_JV_FREE_SCN_EVT */
#if BTA_JV_L2CAP_INCLUDED
tBTA_JV_L2CAP_LE_OPEN l2c_le_open; /* BTA_JV_L2CAP_OPEN_EVT */
tBTA_JV_LE_DATA_IND le_data_ind; /* BTA_JV_L2CAP_LE_DATA_IND_EVT */
tBTA_JV_L2CAP_WRITE_FIXED l2c_write_fixed; /* BTA_JV_L2CAP_WRITE_FIXED_EVT */
#endif
} tBTA_JV;
/* JAVA DM Interface callback */
@ -393,8 +419,10 @@ typedef void (tBTA_JV_DM_CBACK)(tBTA_JV_EVT event, tBTA_JV *p_data, void *user_d
/* JAVA RFCOMM interface callback */
typedef void *(tBTA_JV_RFCOMM_CBACK)(tBTA_JV_EVT event, tBTA_JV *p_data, void *user_data);
#if BTA_JV_L2CAP_INCLUDED
/* JAVA L2CAP interface callback */
typedef void (tBTA_JV_L2CAP_CBACK)(tBTA_JV_EVT event, tBTA_JV *p_data, void *user_Data);
#endif /* BTA_JV_L2CAP_INCLUDED */
/* JV configuration structure */
typedef struct {
@ -424,12 +452,25 @@ extern tBTA_JV_STATUS BTA_JvEnable(tBTA_JV_DM_CBACK *p_cback);
**
** Function BTA_JvDisable
**
** Description Disable the Java I/F
** Description Disable the Java I/F. When the enable
** operation is complete the callback function will be
** called with a BTA_JV_DISABLE_EVT.
**
** Returns void
**
*******************************************************************************/
extern void BTA_JvDisable(void);
extern void BTA_JvDisable(tBTA_JV_RFCOMM_CBACK *p_cback);
/*******************************************************************************
**
** Function BTA_JvFree
**
** Description Free JV configuration
**
** Returns void
**
*******************************************************************************/
extern void BTA_JvFree(void);
/*******************************************************************************
**
@ -484,12 +525,17 @@ extern tBTA_JV_STATUS BTA_JvGetChannelId(int conn_type, void *user_data,
**
** Description This function frees a SCN/PSM that was used
** by an application running over RFCOMM or L2CAP.
** Parameters
** channel The channel to free
** conn_type one of BTA_JV_CONN_TYPE_
** p_cback tBTA_JV_RFCOMM_CBACK is called with BTA_JV_FREE_SCN_EVT when server frees a SCN/PSM
** user_data indicate the RFCOMM server status
**
** Returns BTA_JV_SUCCESS, if the request is being processed.
** BTA_JV_FAILURE, otherwise.
**
*******************************************************************************/
extern tBTA_JV_STATUS BTA_JvFreeChannel(UINT16 channel, int conn_type);
extern tBTA_JV_STATUS BTA_JvFreeChannel(UINT16 channel, int conn_type, tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data);
/*******************************************************************************
**
@ -532,6 +578,7 @@ extern tBTA_JV_STATUS BTA_JvCreateRecordByUser(const char *name, UINT32 channel,
*******************************************************************************/
extern tBTA_JV_STATUS BTA_JvDeleteRecord(UINT32 handle);
#if BTA_JV_L2CAP_INCLUDED
/*******************************************************************************
**
** Function BTA_JvL2capConnectLE
@ -739,6 +786,7 @@ extern tBTA_JV_STATUS BTA_JvL2capWrite(UINT32 handle, UINT32 req_id,
extern tBTA_JV_STATUS BTA_JvL2capWriteFixed(UINT16 channel, BD_ADDR *addr, UINT32 req_id,
tBTA_JV_L2CAP_CBACK *p_cback,
UINT8 *p_data, UINT16 len, void *user_data);
#endif /* BTA_JV_L2CAP_INCLUDED */
/*******************************************************************************
**
@ -769,7 +817,7 @@ extern tBTA_JV_STATUS BTA_JvRfcommConnect(tBTA_SEC sec_mask,
** BTA_JV_FAILURE, otherwise.
**
*******************************************************************************/
extern tBTA_JV_STATUS BTA_JvRfcommClose(UINT32 handle, void *user_data);
extern tBTA_JV_STATUS BTA_JvRfcommClose(UINT32 handle, tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data);
/*******************************************************************************
**
@ -786,9 +834,9 @@ extern tBTA_JV_STATUS BTA_JvRfcommClose(UINT32 handle, void *user_data);
** BTA_JV_FAILURE, otherwise.
**
*******************************************************************************/
extern tBTA_JV_STATUS BTA_JvRfcommStartServer(tBTA_SEC sec_mask,
tBTA_JV_ROLE role, UINT8 local_scn, UINT8 max_session,
tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data);
extern tBTA_JV_STATUS BTA_JvRfcommStartServer(tBTA_SEC sec_mask, tBTA_JV_ROLE role,
UINT8 local_scn, UINT8 max_session,
tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data);
/*******************************************************************************
**
@ -815,8 +863,7 @@ extern tBTA_JV_STATUS BTA_JvRfcommStopServer(UINT32 handle, void *user_data);
** BTA_JV_FAILURE, otherwise.
**
*******************************************************************************/
extern tBTA_JV_STATUS BTA_JvRfcommRead(UINT32 handle, UINT32 req_id,
UINT8 *p_data, UINT16 len);
extern tBTA_JV_STATUS BTA_JvRfcommRead(UINT32 handle, UINT32 req_id, UINT8 *p_data, UINT16 len);
/*******************************************************************************
**
@ -843,7 +890,6 @@ extern tBTA_JV_STATUS BTA_JvRfcommReady(UINT32 handle, UINT32 *p_data_size);
** BTA_JV_FAILURE, otherwise.
**
*******************************************************************************/
// extern tBTA_JV_STATUS BTA_JvRfcommWrite(UINT32 handle, UINT32 req_id);
extern tBTA_JV_STATUS BTA_JvRfcommWrite(UINT32 handle, UINT32 req_id, int len, UINT8 *p_data);
/*******************************************************************************
@ -865,8 +911,7 @@ extern tBTA_JV_STATUS BTA_JvRfcommWrite(UINT32 handle, UINT32 req_id, int len, U
** BTA_JV_CONN_CLOSE to remove in case of connection close!
**
*******************************************************************************/
extern tBTA_JV_STATUS BTA_JvSetPmProfile(UINT32 handle, tBTA_JV_PM_ID app_id,
tBTA_JV_CONN_STATE init_st);
extern tBTA_JV_STATUS BTA_JvSetPmProfile(UINT32 handle, tBTA_JV_PM_ID app_id, tBTA_JV_CONN_STATE init_st);
/*******************************************************************************
**

View file

@ -48,6 +48,7 @@
#if (defined BTA_JV_INCLUDED && BTA_JV_INCLUDED == TRUE)
#if BTA_JV_L2CAP_INCLUDED
/* one of these exists for each client */
struct fc_client {
struct fc_client *next_all_list;
@ -92,11 +93,10 @@ static void __attribute__((unused)) fc_init(void)
pthread_once(&fc_init_once, fc_init_work);
}
static void fcchan_conn_chng_cbk(UINT16 chan, BD_ADDR bd_addr, BOOLEAN connected,
UINT16 reason, tBT_TRANSPORT );
static void fcchan_data_cbk(UINT16 chan, BD_ADDR bd_addr, BT_HDR *p_buf);
#endif /* BTA_JV_L2CAP_INCLUDED */
extern void uuid_to_string_legacy(bt_uuid_t *p_uuid, char *str);
static inline void logu(const char *title, const uint8_t *p_uuid)
@ -114,6 +114,10 @@ static void bta_jv_pm_conn_idle(tBTA_JV_PM_CB *p_cb);
static void bta_jv_pm_state_change(tBTA_JV_PM_CB *p_cb, const tBTA_JV_CONN_STATE state);
tBTA_JV_STATUS bta_jv_set_pm_conn_state(tBTA_JV_PM_CB *p_cb, const tBTA_JV_CONN_STATE
new_st);
static int find_rfc_pcb(void *user_data, tBTA_JV_RFC_CB **cb, tBTA_JV_PCB **pcb);
static void bta_jv_port_mgmt_sr_cback(UINT32 code, UINT16 port_handle);
static void bta_jv_port_event_sr_cback(UINT32 code, UINT16 port_handle);
static int bta_jv_port_data_co_cback(UINT16 port_handle, UINT8 *buf, UINT16 len, int type);
/*******************************************************************************
**
@ -288,6 +292,12 @@ static tBTA_JV_STATUS bta_jv_free_rfc_cb(tBTA_JV_RFC_CB *p_cb, tBTA_JV_PCB *p_pc
BOOLEAN remove_server = FALSE;
int close_pending = 0;
UINT8 used = 0, i, listen = 0;
tPORT_STATE port_state;
UINT32 event_mask = BTA_JV_RFC_EV_MASK;
UINT32 scn_num = (UINT32)p_cb->scn;
tBTA_JV evt_data;
if (!p_cb || !p_pcb) {
APPL_TRACE_ERROR("bta_jv_free_sr_rfc_cb, p_cb or p_pcb cannot be null");
return BTA_JV_FAILURE;
@ -363,6 +373,57 @@ static tBTA_JV_STATUS bta_jv_free_rfc_cb(tBTA_JV_RFC_CB *p_cb, tBTA_JV_PCB *p_pc
}
p_pcb->handle = 0;
p_cb->curr_sess--;
if ((p_cb->max_sess > 1) &&
(p_cb->scn != 0) &&
(p_cb->curr_sess == p_cb->max_sess - 1)) {
for (i = 0; i < p_cb->max_sess; i++) {
if (p_cb->rfc_hdl[i] != 0) {
p_pcb = &bta_jv_cb.port_cb[p_cb->rfc_hdl[i] - 1];
if (p_pcb->state == BTA_JV_ST_SR_LISTEN) {
listen++;
}
used++;
}
}
APPL_TRACE_DEBUG("%s max_sess=%d used:%d curr_sess:%d, listen:%d si:%d",
__func__, p_cb->max_sess, used, p_cb->curr_sess, listen, si);
if (used < p_cb->max_sess &&
listen == 0 &&
0 <= si &&
si < BTA_JV_MAX_RFC_SR_SESSION) {
/* make sure the server has a listen port */
if ((RFCOMM_CreateConnection(p_cb->sec_id, p_cb->scn, TRUE,
BTA_JV_DEF_RFC_MTU, (UINT8 *)bd_addr_any, &(p_cb->rfc_hdl[si]), bta_jv_port_mgmt_sr_cback) == PORT_SUCCESS) &&
(p_cb->rfc_hdl[si] != 0)) {
p_cb->curr_sess++;
p_pcb = &bta_jv_cb.port_cb[p_cb->rfc_hdl[si] - 1];
p_pcb->state = BTA_JV_ST_SR_LISTEN;
p_pcb->port_handle = p_cb->rfc_hdl[si];
// p_pcb->user_data = p_pcb_open->user_data;
PORT_ClearKeepHandleFlag(p_pcb->port_handle);
PORT_SetEventCallback(p_pcb->port_handle, bta_jv_port_event_sr_cback);
PORT_SetDataCOCallback(p_pcb->port_handle, bta_jv_port_data_co_cback);
PORT_SetEventMask(p_pcb->port_handle, event_mask);
PORT_GetState(p_pcb->port_handle, &port_state);
port_state.fc_type = (PORT_FC_CTS_ON_INPUT | PORT_FC_CTS_ON_OUTPUT);
PORT_SetState(p_pcb->port_handle, &port_state);
p_pcb->handle = BTA_JV_RFC_H_S_TO_HDL(p_cb->handle, si);
APPL_TRACE_DEBUG("%s: p_pcb->handle:0x%x, curr_sess:%d", __func__,
p_pcb->handle, p_cb->curr_sess);
evt_data.rfc_srv_open.handle = 0;
evt_data.rfc_srv_open.new_listen_handle = p_pcb->handle;
evt_data.rfc_srv_open.status = BTA_JV_SUCCESS;
p_pcb->user_data = p_cb->p_cback(BTA_JV_RFCOMM_SRV_OPEN_EVT, &evt_data, (void *)scn_num);
}
}
}
if (p_cb->curr_sess == 0) {
p_cb->scn = 0;
bta_jv_free_sec_id(&p_cb->sec_id);
@ -377,6 +438,7 @@ static tBTA_JV_STATUS bta_jv_free_rfc_cb(tBTA_JV_RFC_CB *p_cb, tBTA_JV_PCB *p_pc
return status;
}
#if BTA_JV_L2CAP_INCLUDED
/*******************************************************************************
**
** Function bta_jv_free_l2c_cb
@ -402,6 +464,7 @@ tBTA_JV_STATUS bta_jv_free_l2c_cb(tBTA_JV_L2C_CB *p_cb)
p_cb->p_cback = NULL;
return status;
}
#endif /* BTA_JV_L2CAP_INCLUDED */
/*******************************************************************************
**
@ -456,10 +519,9 @@ static tBTA_JV_STATUS bta_jv_free_set_pm_profile_cb(UINT32 jv_handle)
}
}
APPL_TRACE_API("%s(jv_handle: 0x%2x), idx: %d, "
"app_id: 0x%x", __func__, jv_handle, i, bta_jv_cb.pm_cb[i].app_id);
APPL_TRACE_API("%s, bd_counter = %d, "
"appid_counter = %d", __func__, bd_counter, appid_counter);
APPL_TRACE_API("%s(jv_handle: 0x%2x), idx: %d, app_id: 0x%x", __func__, jv_handle, i, bta_jv_cb.pm_cb[i].app_id);
APPL_TRACE_API("%s, bd_counter = %d, appid_counter = %d", __func__, bd_counter, appid_counter);
if (bd_counter > 1) {
bta_jv_pm_conn_idle(&bta_jv_cb.pm_cb[i]);
}
@ -478,14 +540,15 @@ static tBTA_JV_STATUS bta_jv_free_set_pm_profile_cb(UINT32 jv_handle)
tBTA_JV_PCB *p_pcb = bta_jv_rfc_port_to_pcb(bta_jv_cb.rfc_cb[hi].rfc_hdl[si]);
if (p_pcb) {
if (NULL == p_pcb->p_pm_cb) {
APPL_TRACE_WARNING("%s(jv_handle:"
" 0x%x):port_handle: 0x%x, p_pm_cb: %d: no link to "
"pm_cb?", __func__, jv_handle, p_pcb->port_handle, i);
APPL_TRACE_WARNING("%s(jv_handle: 0x%x):port_handle: 0x%x, p_pm_cb: %d: no link to pm_cb?",
__func__, jv_handle, p_pcb->port_handle, i);
}
p_cb = &p_pcb->p_pm_cb;
}
}
} else {
}
#if BTA_JV_L2CAP_INCLUDED
else {
if (jv_handle < BTA_JV_MAX_L2C_CONN) {
tBTA_JV_L2C_CB *p_l2c_cb = &bta_jv_cb.l2c_cb[jv_handle];
if (NULL == p_l2c_cb->p_pm_cb) {
@ -495,6 +558,8 @@ static tBTA_JV_STATUS bta_jv_free_set_pm_profile_cb(UINT32 jv_handle)
p_cb = &p_l2c_cb->p_pm_cb;
}
}
#endif /* BTA_JV_L2CAP_INCLUDED */
if (p_cb) {
*p_cb = NULL;
status = BTA_JV_SUCCESS;
@ -537,7 +602,9 @@ static tBTA_JV_PM_CB *bta_jv_alloc_set_pm_profile_cb(UINT32 jv_handle, tBTA_JV_P
break;
}
}
} else {
}
#if BTA_JV_L2CAP_INCLUDED
else {
/* use jv handle for l2cap bd address retrieval */
for (j = 0; j < BTA_JV_MAX_L2C_CONN; j++) {
if (jv_handle == bta_jv_cb.l2c_cb[j].handle) {
@ -552,6 +619,7 @@ static tBTA_JV_PM_CB *bta_jv_alloc_set_pm_profile_cb(UINT32 jv_handle, tBTA_JV_P
}
}
}
#endif /* BTA_JV_L2CAP_INCLUDED */
APPL_TRACE_API("bta_jv_alloc_set_pm_profile_cb(handle 0x%2x, app_id %d): "
"idx: %d, (BTA_JV_PM_MAX_NUM: %d), pp_cb: %p", jv_handle, app_id,
i, BTA_JV_PM_MAX_NUM, (void *)pp_cb);
@ -634,7 +702,6 @@ BOOLEAN bta_jv_check_psm(UINT16 psm)
}
}
return ret;
}
/*******************************************************************************
@ -673,7 +740,12 @@ void bta_jv_enable(tBTA_JV_MSG *p_data)
*******************************************************************************/
void bta_jv_disable (tBTA_JV_MSG *p_data)
{
UNUSED(p_data);
tBTA_JV_STATUS evt_data;
evt_data = BTA_JV_SUCCESS;
// UNUSED(p_data);
if (p_data->disable.p_cback) {
p_data->disable.p_cback(BTA_JV_DISABLE_EVT, (tBTA_JV *)&evt_data, NULL);
}
}
@ -782,7 +854,16 @@ void bta_jv_get_channel_id(tBTA_JV_MSG *p_data)
*******************************************************************************/
void bta_jv_free_scn(tBTA_JV_MSG *p_data)
{
UINT16 scn = p_data->free_channel.scn;
tBTA_JV_API_FREE_CHANNEL *fc = &(p_data->free_channel);
UINT16 scn = fc->scn;
tBTA_JV_FREE_SCN evt_data = {
.status = BTA_JV_SUCCESS,
.server_status = BTA_JV_SERVER_STATUS_MAX,
};
tBTA_JV_FREE_SCN_USER_DATA *user_data = NULL;
tBTA_JV_RFC_CB *p_cb = NULL;
tBTA_JV_PCB *p_pcb = NULL;
switch (p_data->free_channel.type) {
case BTA_JV_CONN_TYPE_RFCOMM: {
@ -802,6 +883,19 @@ void bta_jv_free_scn(tBTA_JV_MSG *p_data)
default:
break;
}
if (fc->user_data) {
user_data = (tBTA_JV_FREE_SCN_USER_DATA *)fc->user_data;
evt_data.server_status = user_data->server_status;
if (user_data->server_status == BTA_JV_SERVER_RUNNING && find_rfc_pcb((void *)user_data->slot_id, &p_cb, &p_pcb)) {
/* if call bta_jv_rfcomm_stop_server successfully, find_rfc_pcb shall return false */
evt_data.status = BTA_JV_FAILURE;
}
if (fc->p_cback) {
fc->p_cback(BTA_JV_FREE_SCN_EVT, (tBTA_JV *)&evt_data, (void *)user_data);
}
}
}
static inline tBT_UUID shorten_sdp_uuid(const tBT_UUID *u)
{
@ -1092,6 +1186,7 @@ void bta_jv_delete_record(tBTA_JV_MSG *p_data)
}
}
#if BTA_JV_L2CAP_INCLUDED
/*******************************************************************************
**
** Function bta_jv_l2cap_client_cback
@ -1517,6 +1612,7 @@ void bta_jv_l2cap_write_fixed(tBTA_JV_MSG *p_data)
ls->p_cback(BTA_JV_L2CAP_WRITE_FIXED_EVT, (tBTA_JV *)&evt_data, ls->user_data);
}
#endif /* BTA_JV_L2CAP_INCLUDED */
/*******************************************************************************
**
@ -1596,6 +1692,7 @@ static void bta_jv_port_mgmt_cl_cback(UINT32 code, UINT16 port_handle)
evt_data.rfc_close.async = TRUE;
if (p_pcb->state == BTA_JV_ST_CL_CLOSING) {
evt_data.rfc_close.async = FALSE;
evt_data.rfc_close.status = BTA_JV_SUCCESS;
}
//p_pcb->state = BTA_JV_ST_NONE;
//p_pcb->cong = FALSE;
@ -1760,9 +1857,10 @@ void bta_jv_rfcomm_close(tBTA_JV_MSG *p_data)
tBTA_JV_API_RFCOMM_CLOSE *cc = &(p_data->rfcomm_close);
tBTA_JV_RFC_CB *p_cb = NULL;
tBTA_JV_PCB *p_pcb = NULL;
APPL_TRACE_DEBUG("bta_jv_rfcomm_close, rfc handle:%d", cc->handle);
tBTA_JV evt_data;
APPL_TRACE_DEBUG("%s, rfc handle:%d",__func__, cc->handle);
if (!cc->handle) {
APPL_TRACE_ERROR("bta_jv_rfcomm_close, rfc handle is null");
APPL_TRACE_ERROR("%s, rfc handle is null", __func__);
return;
}
@ -1770,9 +1868,21 @@ void bta_jv_rfcomm_close(tBTA_JV_MSG *p_data)
if (!find_rfc_pcb(user_data, &p_cb, &p_pcb)) {
return;
}
if(cc->p_cback) {
evt_data.rfc_close.status = BTA_JV_SUCCESS;
evt_data.rfc_close.port_status = PORT_LOCAL_CLOSED;
evt_data.rfc_close.handle = cc->handle;
evt_data.rfc_close.async = TRUE;
if (p_pcb && (p_pcb->state == BTA_JV_ST_SR_LISTEN ||
p_pcb->state == BTA_JV_ST_SR_OPEN ||
p_pcb->state == BTA_JV_ST_CL_OPEN ||
p_pcb->state == BTA_JV_ST_CL_OPENING)) {
evt_data.rfc_close.async = FALSE;
}
cc->p_cback(BTA_JV_RFCOMM_CLOSE_EVT, (tBTA_JV *)&evt_data, user_data);
}
bta_jv_free_rfc_cb(p_cb, p_pcb);
APPL_TRACE_DEBUG("bta_jv_rfcomm_close: sec id in use:%d, rfc_cb in use:%d",
get_sec_id_used(), get_rfc_cb_used());
APPL_TRACE_DEBUG("%s: sec id in use:%d, rfc_cb in use:%d", __func__, get_sec_id_used(), get_rfc_cb_used());
}
/*******************************************************************************
@ -1976,6 +2086,8 @@ static tBTA_JV_PCB *bta_jv_add_rfc_port(tBTA_JV_RFC_CB *p_cb, tBTA_JV_PCB *p_pcb
p_pcb->handle, p_cb->curr_sess);
}
} else {
/* avoid p_pcb always points to the last element of rfc_hdl */
p_pcb = p_pcb_open;
APPL_TRACE_ERROR("bta_jv_add_rfc_port, cannot create new rfc listen port");
}
}
@ -2351,7 +2463,7 @@ static void bta_jv_pm_state_change(tBTA_JV_PM_CB *p_cb, const tBTA_JV_CONN_STATE
}
/**********************************************************************************************/
#if BTA_JV_L2CAP_INCLUDED
static struct fc_channel *fcchan_get(uint16_t chan, char create)
{
struct fc_channel *t = fc_channels;
@ -2791,6 +2903,6 @@ extern void bta_jv_l2cap_close_fixed (tBTA_JV_MSG *p_data)
fcclient_free(t);
}
}
#endif /* BTA_JV_L2CAP_INCLUDED */
#endif ///defined BTA_JV_INCLUDED && BTA_JV_INCLUDED == TRUE

View file

@ -69,6 +69,16 @@ tBTA_JV_STATUS BTA_JvEnable(tBTA_JV_DM_CBACK *p_cback)
int i;
APPL_TRACE_API( "BTA_JvEnable");
#if BTA_DYNAMIC_MEMORY == TRUE
/* Malloc buffer for JV configuration structure */
p_bta_jv_cfg->p_sdp_raw_data = (UINT8 *)osi_malloc(p_bta_jv_cfg->sdp_raw_size);
p_bta_jv_cfg->p_sdp_db = (tSDP_DISCOVERY_DB *)osi_malloc(p_bta_jv_cfg->sdp_db_size);
if (p_bta_jv_cfg->p_sdp_raw_data == NULL || p_bta_jv_cfg->p_sdp_db == NULL) {
return BTA_JV_NO_DATA;
}
#endif
if (p_cback && FALSE == bta_sys_is_register(BTA_ID_JV)) {
memset(&bta_jv_cb, 0, sizeof(tBTA_JV_CB));
/* set handle to invalid value by default */
@ -100,18 +110,39 @@ tBTA_JV_STATUS BTA_JvEnable(tBTA_JV_DM_CBACK *p_cback)
** Returns void
**
*******************************************************************************/
void BTA_JvDisable(void)
void BTA_JvDisable(tBTA_JV_RFCOMM_CBACK *p_cback)
{
BT_HDR *p_buf;
tBTA_JV_API_DISABLE *p_buf;
APPL_TRACE_API( "BTA_JvDisable");
bta_sys_deregister(BTA_ID_JV);
if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
p_buf->event = BTA_JV_API_DISABLE_EVT;
if ((p_buf = (tBTA_JV_API_DISABLE *) osi_malloc(sizeof(tBTA_JV_API_DISABLE))) != NULL) {
p_buf->hdr.event = BTA_JV_API_DISABLE_EVT;
p_buf->p_cback = p_cback;
bta_sys_sendmsg(p_buf);
}
}
/*******************************************************************************
**
** Function BTA_JvFree
**
** Description Free JV configuration
**
** Returns void
**
*******************************************************************************/
void BTA_JvFree(void)
{
#if BTA_DYNAMIC_MEMORY == TRUE
/* Free buffer for JV configuration structure */
osi_free(p_bta_jv_cfg->p_sdp_raw_data);
osi_free(p_bta_jv_cfg->p_sdp_db);
p_bta_jv_cfg->p_sdp_raw_data = NULL;
p_bta_jv_cfg->p_sdp_db = NULL;
#endif
}
/*******************************************************************************
**
** Function BTA_JvIsEnable
@ -199,12 +230,14 @@ tBTA_JV_STATUS BTA_JvGetChannelId(int conn_type, void *user_data, INT32 channel)
** Parameters
** channel The channel to free
** conn_type one of BTA_JV_CONN_TYPE_
** p_cback tBTA_JV_RFCOMM_CBACK is called with when server
** user_data indicate the RFCOMM server status
**
** Returns BTA_JV_SUCCESS, if the request is being processed.
** BTA_JV_FAILURE, otherwise.
**
*******************************************************************************/
tBTA_JV_STATUS BTA_JvFreeChannel(UINT16 channel, int conn_type)
tBTA_JV_STATUS BTA_JvFreeChannel(UINT16 channel, int conn_type, tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data)
{
tBTA_JV_STATUS status = BTA_JV_FAILURE;
tBTA_JV_API_FREE_CHANNEL *p_msg;
@ -214,6 +247,8 @@ tBTA_JV_STATUS BTA_JvFreeChannel(UINT16 channel, int conn_type)
p_msg->hdr.event = BTA_JV_API_FREE_SCN_EVT;
p_msg->scn = channel;
p_msg->type = conn_type;
p_msg->p_cback = p_cback;
p_msg->user_data = user_data;
bta_sys_sendmsg(p_msg);
status = BTA_JV_SUCCESS;
}
@ -310,6 +345,7 @@ tBTA_JV_STATUS BTA_JvDeleteRecord(UINT32 handle)
return (status);
}
#if BTA_JV_L2CAP_INCLUDED
/*******************************************************************************
**
** Function BTA_JvL2capConnectLE
@ -823,6 +859,7 @@ tBTA_JV_STATUS BTA_JvL2capWriteFixed(UINT16 channel, BD_ADDR *addr, UINT32 req_i
return (status);
}
#endif /* BTA_JV_L2CAP_INCLUDED */
/*******************************************************************************
**
@ -868,19 +905,20 @@ tBTA_JV_STATUS BTA_JvRfcommConnect(tBTA_SEC sec_mask,
** Function BTA_JvRfcommClose
**
** Description This function closes an RFCOMM connection
**
** When the connection is established or failed,
** tBTA_JV_RFCOMM_CBACK is called with BTA_JV_RFCOMM_CLOSE_EVT
** Returns BTA_JV_SUCCESS, if the request is being processed.
** BTA_JV_FAILURE, otherwise.
**
*******************************************************************************/
tBTA_JV_STATUS BTA_JvRfcommClose(UINT32 handle, void *user_data)
tBTA_JV_STATUS BTA_JvRfcommClose(UINT32 handle, tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data)
{
tBTA_JV_STATUS status = BTA_JV_FAILURE;
tBTA_JV_API_RFCOMM_CLOSE *p_msg;
UINT32 hi = ((handle & BTA_JV_RFC_HDL_MASK) & ~BTA_JV_RFCOMM_MASK) - 1;
UINT32 si = BTA_JV_RFC_HDL_TO_SIDX(handle);
APPL_TRACE_API( "BTA_JvRfcommClose");
APPL_TRACE_API( "%s", __func__);
if (hi < BTA_JV_MAX_RFC_CONN && bta_jv_cb.rfc_cb[hi].p_cback &&
si < BTA_JV_MAX_RFC_SR_SESSION && bta_jv_cb.rfc_cb[hi].rfc_hdl[si] &&
(p_msg = (tBTA_JV_API_RFCOMM_CLOSE *)osi_malloc(sizeof(tBTA_JV_API_RFCOMM_CLOSE))) != NULL) {
@ -888,6 +926,7 @@ tBTA_JV_STATUS BTA_JvRfcommClose(UINT32 handle, void *user_data)
p_msg->handle = handle;
p_msg->p_cb = &bta_jv_cb.rfc_cb[hi];
p_msg->p_pcb = &bta_jv_cb.port_cb[p_msg->p_cb->rfc_hdl[si] - 1];
p_msg->p_cback = p_cback;
p_msg->user_data = user_data;
bta_sys_sendmsg(p_msg);
status = BTA_JV_SUCCESS;

View file

@ -52,12 +52,14 @@ const tBTA_JV_ACTION bta_jv_action[] = {
bta_jv_start_discovery, /* BTA_JV_API_START_DISCOVERY_EVT */
bta_jv_create_record, /* BTA_JV_API_CREATE_RECORD_EVT */
bta_jv_delete_record, /* BTA_JV_API_DELETE_RECORD_EVT */
#if BTA_JV_L2CAP_INCLUDED
bta_jv_l2cap_connect, /* BTA_JV_API_L2CAP_CONNECT_EVT */
bta_jv_l2cap_close, /* BTA_JV_API_L2CAP_CLOSE_EVT */
bta_jv_l2cap_start_server, /* BTA_JV_API_L2CAP_START_SERVER_EVT */
bta_jv_l2cap_stop_server, /* BTA_JV_API_L2CAP_STOP_SERVER_EVT */
bta_jv_l2cap_read, /* BTA_JV_API_L2CAP_READ_EVT */
bta_jv_l2cap_write, /* BTA_JV_API_L2CAP_WRITE_EVT */
#endif /* BTA_JV_L2CAP_INCLUDED */
bta_jv_rfcomm_connect, /* BTA_JV_API_RFCOMM_CONNECT_EVT */
bta_jv_rfcomm_close, /* BTA_JV_API_RFCOMM_CLOSE_EVT */
bta_jv_rfcomm_start_server, /* BTA_JV_API_RFCOMM_START_SERVER_EVT */
@ -66,11 +68,13 @@ const tBTA_JV_ACTION bta_jv_action[] = {
bta_jv_rfcomm_write, /* BTA_JV_API_RFCOMM_WRITE_EVT */
bta_jv_set_pm_profile, /* BTA_JV_API_SET_PM_PROFILE_EVT */
bta_jv_change_pm_state, /* BTA_JV_API_PM_STATE_CHANGE_EVT */
#if BTA_JV_L2CAP_INCLUDED
bta_jv_l2cap_connect_le, /* BTA_JV_API_L2CAP_CONNECT_LE_EVT */
bta_jv_l2cap_start_server_le, /* BTA_JV_API_L2CAP_START_SERVER_LE_EVT */
bta_jv_l2cap_stop_server_le, /* BTA_JV_API_L2CAP_STOP_SERVER_LE_EVT */
bta_jv_l2cap_write_fixed, /* BTA_JV_API_L2CAP_WRITE_FIXED_EVT */
bta_jv_l2cap_close_fixed, /* BTA_JV_API_L2CAP_CLOSE_FIXED_EVT */
#endif /* BTA_JV_L2CAP_INCLUDED */
};
/*******************************************************************************

View file

@ -48,12 +48,14 @@ enum {
BTA_JV_API_START_DISCOVERY_EVT,
BTA_JV_API_CREATE_RECORD_EVT,
BTA_JV_API_DELETE_RECORD_EVT,
#if BTA_JV_L2CAP_INCLUDED
BTA_JV_API_L2CAP_CONNECT_EVT,
BTA_JV_API_L2CAP_CLOSE_EVT,
BTA_JV_API_L2CAP_START_SERVER_EVT,
BTA_JV_API_L2CAP_STOP_SERVER_EVT,
BTA_JV_API_L2CAP_READ_EVT,
BTA_JV_API_L2CAP_WRITE_EVT,
#endif /* BTA_JV_L2CAP_INCLUDED */
BTA_JV_API_RFCOMM_CONNECT_EVT,
BTA_JV_API_RFCOMM_CLOSE_EVT,
BTA_JV_API_RFCOMM_START_SERVER_EVT,
@ -62,11 +64,13 @@ enum {
BTA_JV_API_RFCOMM_WRITE_EVT,
BTA_JV_API_SET_PM_PROFILE_EVT,
BTA_JV_API_PM_STATE_CHANGE_EVT,
#if BTA_JV_L2CAP_INCLUDED
BTA_JV_API_L2CAP_CONNECT_LE_EVT,
BTA_JV_API_L2CAP_START_SERVER_LE_EVT,
BTA_JV_API_L2CAP_STOP_SERVER_LE_EVT,
BTA_JV_API_L2CAP_WRITE_FIXED_EVT,
BTA_JV_API_L2CAP_CLOSE_FIXED_EVT,
#endif /* BTA_JV_L2CAP_INCLUDED */
BTA_JV_MAX_INT_EVT
};
@ -80,6 +84,12 @@ typedef struct {
tBTA_JV_DM_CBACK *p_cback;
} tBTA_JV_API_ENABLE;
/* data type for BTA_JV_API_DISABLE_EVT */
typedef struct {
BT_HDR hdr;
tBTA_JV_RFCOMM_CBACK *p_cback;
} tBTA_JV_API_DISABLE;
/* data type for BTA_JV_API_START_DISCOVERY_EVT */
typedef struct {
BT_HDR hdr;
@ -115,6 +125,8 @@ enum {
BTA_JV_ST_SR_CLOSING
} ;
typedef UINT8 tBTA_JV_STATE;
#if BTA_JV_L2CAP_INCLUDED
#define BTA_JV_ST_CL_MAX BTA_JV_ST_CL_CLOSING
/* JV L2CAP control block */
typedef struct {
@ -127,6 +139,7 @@ typedef struct {
tBTA_JV_PM_CB *p_pm_cb; /* ptr to pm control block, NULL: unused */
void *user_data; /* user data for callback from higher layers */
} tBTA_JV_L2C_CB;
#endif /* BTA_JV_L2CAP_INCLUDED */
#define BTA_JV_RFC_HDL_MASK 0xFF
#define BTA_JV_RFCOMM_MASK 0x80
@ -156,6 +169,7 @@ typedef struct {
int curr_sess; /* current sessions count*/
} tBTA_JV_RFC_CB;
#if BTA_JV_L2CAP_INCLUDED
/* data type for BTA_JV_API_L2CAP_CONNECT_EVT & BTA_JV_API_L2CAP_CONNECT_LE_EVT */
typedef struct {
BT_HDR hdr;
@ -233,6 +247,7 @@ typedef struct {
UINT16 len;
void *user_data;
} tBTA_JV_API_L2CAP_WRITE_FIXED;
#endif /* BTA_JV_L2CAP_INCLUDED */
/* data type for BTA_JV_API_RFCOMM_CONNECT_EVT */
typedef struct {
@ -300,6 +315,7 @@ typedef struct {
UINT32 handle;
tBTA_JV_RFC_CB *p_cb;
tBTA_JV_PCB *p_pcb;
tBTA_JV_RFCOMM_CBACK *p_cback;
void *user_data;
} tBTA_JV_API_RFCOMM_CLOSE;
@ -326,6 +342,8 @@ typedef struct {
BT_HDR hdr;
INT32 type; /* One of BTA_JV_CONN_TYPE_ */
UINT16 scn;
tBTA_JV_RFCOMM_CBACK *p_cback;
void *user_data;
} tBTA_JV_API_FREE_CHANNEL;
/* data type for BTA_JV_API_ALLOC_CHANNEL_EVT */
@ -340,16 +358,20 @@ typedef union {
/* GKI event buffer header */
BT_HDR hdr;
tBTA_JV_API_ENABLE enable;
tBTA_JV_API_DISABLE disable;
tBTA_JV_API_START_DISCOVERY start_discovery;
tBTA_JV_API_ALLOC_CHANNEL alloc_channel;
tBTA_JV_API_FREE_CHANNEL free_channel;
tBTA_JV_API_CREATE_RECORD create_record;
tBTA_JV_API_ADD_ATTRIBUTE add_attr;
#if BTA_JV_L2CAP_INCLUDED
tBTA_JV_API_L2CAP_CONNECT l2cap_connect;
tBTA_JV_API_L2CAP_READ l2cap_read;
tBTA_JV_API_L2CAP_WRITE l2cap_write;
tBTA_JV_API_L2CAP_CLOSE l2cap_close;
tBTA_JV_API_L2CAP_SERVER l2cap_server;
tBTA_JV_API_L2CAP_WRITE_FIXED l2cap_write_fixed;
#endif /* BTA_JV_L2CAP_INCLUDED */
tBTA_JV_API_RFCOMM_CONNECT rfcomm_connect;
tBTA_JV_API_RFCOMM_READ rfcomm_read;
tBTA_JV_API_RFCOMM_WRITE rfcomm_write;
@ -357,7 +379,6 @@ typedef union {
tBTA_JV_API_PM_STATE_CHANGE change_pm_state;
tBTA_JV_API_RFCOMM_CLOSE rfcomm_close;
tBTA_JV_API_RFCOMM_SERVER rfcomm_server;
tBTA_JV_API_L2CAP_WRITE_FIXED l2cap_write_fixed;
} tBTA_JV_MSG;
/* JV control block */
@ -368,7 +389,9 @@ typedef struct {
UINT32 sdp_handle[BTA_JV_MAX_SDP_REC]; /* SDP records created */
UINT8 *p_sel_raw_data;/* the raw data of last service select */
tBTA_JV_DM_CBACK *p_dm_cback;
#if BTA_JV_L2CAP_INCLUDED
tBTA_JV_L2C_CB l2c_cb[BTA_JV_MAX_L2C_CONN]; /* index is GAP handle (index) */
#endif /* BTA_JV_L2CAP_INCLUDED */
tBTA_JV_RFC_CB rfc_cb[BTA_JV_MAX_RFC_CONN];
tBTA_JV_PCB port_cb[MAX_RFC_PORTS]; /* index of this array is
the port_handle, */
@ -407,12 +430,14 @@ extern void bta_jv_free_scn (tBTA_JV_MSG *p_data);
extern void bta_jv_start_discovery (tBTA_JV_MSG *p_data);
extern void bta_jv_create_record (tBTA_JV_MSG *p_data);
extern void bta_jv_delete_record (tBTA_JV_MSG *p_data);
#if BTA_JV_L2CAP_INCLUDED
extern void bta_jv_l2cap_connect (tBTA_JV_MSG *p_data);
extern void bta_jv_l2cap_close (tBTA_JV_MSG *p_data);
extern void bta_jv_l2cap_start_server (tBTA_JV_MSG *p_data);
extern void bta_jv_l2cap_stop_server (tBTA_JV_MSG *p_data);
extern void bta_jv_l2cap_read (tBTA_JV_MSG *p_data);
extern void bta_jv_l2cap_write (tBTA_JV_MSG *p_data);
#endif /* BTA_JV_L2CAP_INCLUDED */
extern void bta_jv_rfcomm_connect (tBTA_JV_MSG *p_data);
extern void bta_jv_rfcomm_close (tBTA_JV_MSG *p_data);
extern void bta_jv_rfcomm_start_server (tBTA_JV_MSG *p_data);
@ -421,11 +446,12 @@ extern void bta_jv_rfcomm_read (tBTA_JV_MSG *p_data);
extern void bta_jv_rfcomm_write (tBTA_JV_MSG *p_data);
extern void bta_jv_set_pm_profile (tBTA_JV_MSG *p_data);
extern void bta_jv_change_pm_state(tBTA_JV_MSG *p_data);
#if BTA_JV_L2CAP_INCLUDED
extern void bta_jv_l2cap_connect_le (tBTA_JV_MSG *p_data);
extern void bta_jv_l2cap_start_server_le (tBTA_JV_MSG *p_data);
extern void bta_jv_l2cap_stop_server_le (tBTA_JV_MSG *p_data);
extern void bta_jv_l2cap_write_fixed (tBTA_JV_MSG *p_data);
extern void bta_jv_l2cap_close_fixed (tBTA_JV_MSG *p_data);
#endif /* BTA_JV_L2CAP_INCLUDED */
#endif ///defined BTA_JV_INCLUDED && BTA_JV_INCLUDED == TRUE
#endif /* BTA_JV_INT_H */

View file

@ -22,7 +22,7 @@
#include "common/bt_target.h"
#include "btc/btc_storage.h"
#include "btc/btc_ble_storage.h"
#include "esp_gap_ble_api.h"
#include "btc_gap_ble.h"
#include "btm_int.h"
#include "bta/bta_api.h"
#include "bta/bta_gatt_api.h"
@ -304,11 +304,11 @@ static void btc_dm_link_up_evt(tBTA_DM_LINK_UP *p_link_up)
BD_ADDR bd_addr;
bt_bdaddr_t bt_bdaddr;
memcpy(bd_addr, p_link_up->bd_addr, sizeof(BD_ADDR));
memcpy(bt_bdaddr.address, p_link_up->bd_addr, sizeof(BD_ADDR));
if (p_link_up->sc_downgrade == 1) {
memcpy(bt_bdaddr.address, p_link_up->bd_addr, sizeof(BD_ADDR));
if (btc_storage_remove_bonded_device(&bt_bdaddr) == BT_STATUS_SUCCESS) {
memcpy(bd_addr, p_link_up->bd_addr, sizeof(BD_ADDR));
if (BTA_DmRemoveDevice(bd_addr, BT_TRANSPORT_BR_EDR) == BTA_SUCCESS) {
BTC_TRACE_EVENT(" %s() Bonding information removed.", __FUNCTION__);
} else {
@ -404,11 +404,10 @@ static void btc_dm_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
memcpy(param.auth_cmpl.bda, p_auth_cmpl->bd_addr, ESP_BD_ADDR_LEN);
memcpy(param.auth_cmpl.device_name, p_auth_cmpl->bd_name, ESP_BT_GAP_MAX_BDNAME_LEN + 1);
ret = btc_transfer_context(&msg, &param,
sizeof(esp_bt_gap_cb_param_t), NULL);
ret = btc_inter_profile_call(&msg, &param);
if (ret != BT_STATUS_SUCCESS) {
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
}
#endif /// BTC_GAP_BT_INCLUDED == TRUE
@ -427,11 +426,10 @@ static void btc_dm_pin_req_evt(tBTA_DM_PIN_REQ *p_pin_req)
param.pin_req.min_16_digit = p_pin_req->min_16_digit;
memcpy(param.pin_req.bda, p_pin_req->bd_addr, ESP_BD_ADDR_LEN);
ret = btc_transfer_context(&msg, &param,
sizeof(esp_bt_gap_cb_param_t), NULL);
ret = btc_inter_profile_call(&msg, &param);
if (ret != BT_STATUS_SUCCESS) {
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
}
#endif /// BTC_GAP_BT_INCLUDED == TRUE
}
@ -455,11 +453,10 @@ static void btc_dm_sp_cfm_req_evt(tBTA_DM_SP_CFM_REQ *p_cfm_req)
param.cfm_req.num_val = p_cfm_req->num_val;
memcpy(param.cfm_req.bda, p_cfm_req->bd_addr, ESP_BD_ADDR_LEN);
ret = btc_transfer_context(&msg, &param,
sizeof(esp_bt_gap_cb_param_t), NULL);
ret = btc_inter_profile_call(&msg, &param);
if (ret != BT_STATUS_SUCCESS) {
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
}
#endif /// BTC_GAP_BT_INCLUDED == TRUE
}
@ -476,11 +473,10 @@ static void btc_dm_sp_key_notif_evt(tBTA_DM_SP_KEY_NOTIF *p_key_notif)
param.key_notif.passkey = p_key_notif->passkey;
memcpy(param.key_notif.bda, p_key_notif->bd_addr, ESP_BD_ADDR_LEN);
ret = btc_transfer_context(&msg, &param,
sizeof(esp_bt_gap_cb_param_t), NULL);
ret = btc_inter_profile_call(&msg, &param);
if (ret != BT_STATUS_SUCCESS) {
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
}
#endif /// BTC_GAP_BT_INCLUDED == TRUE
}
@ -496,16 +492,43 @@ static void btc_dm_sp_key_req_evt(tBTA_DM_SP_KEY_REQ *p_key_req)
msg.act = BTC_GAP_BT_KEY_REQ_EVT;
memcpy(param.key_req.bda, p_key_req->bd_addr, ESP_BD_ADDR_LEN);
ret = btc_transfer_context(&msg, &param,
sizeof(esp_bt_gap_cb_param_t), NULL);
ret = btc_inter_profile_call(&msg, &param);
if (ret != BT_STATUS_SUCCESS) {
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
}
#endif /// BTC_GAP_BT_INCLUDED == TRUE
}
#endif /// BT_SSP_INCLUDED == TRUE
static void btc_dm_dev_unpaired_evt(tBTA_DM_LINK_DOWN *p_link_down)
{
esp_bt_gap_cb_param_t param;
BTC_TRACE_DEBUG("%s",__func__);
memcpy(param.remove_bond_dev_cmpl.bda, p_link_down->bd_addr, ESP_BD_ADDR_LEN);
btm_set_bond_type_dev(p_link_down->bd_addr, BOND_TYPE_UNKNOWN);
if (p_link_down->status == HCI_SUCCESS) {
//remove the bonded key in the config and nvs flash.
param.remove_bond_dev_cmpl.status = btc_storage_remove_bonded_device((bt_bdaddr_t *)param.remove_bond_dev_cmpl.bda);
} else {
param.remove_bond_dev_cmpl.status = ESP_BT_STATUS_FAIL;
}
#if (BTC_GAP_BT_INCLUDED == TRUE)
bt_status_t ret;
btc_msg_t msg;
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_GAP_BT;
msg.act = BTC_GAP_BT_REMOVE_BOND_DEV_COMPLETE_EVT;
ret = btc_inter_profile_call(&msg, &param);
if (ret != BT_STATUS_SUCCESS) {
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
}
#endif /// BTC_GAP_BT_INCLUDED == TRUE
}
tBTA_SERVICE_MASK btc_get_enabled_services_mask(void)
{
return btc_enabled_services;
@ -643,16 +666,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
#endif ///BT_SSP_INCLUDED == TRUE
case BTA_DM_DEV_UNPAIRED_EVT: {
#if (SMP_INCLUDED == TRUE)
bt_bdaddr_t bd_addr;
BTC_TRACE_DEBUG("BTA_DM_DEV_UNPAIRED_EVT");
memcpy(bd_addr.address, p_data->link_down.bd_addr, sizeof(BD_ADDR));
btm_set_bond_type_dev(p_data->link_down.bd_addr, BOND_TYPE_UNKNOWN);
if (p_data->link_down.status == HCI_SUCCESS) {
//remove the bonded key in the config and nvs flash.
btc_storage_remove_bonded_device(&bd_addr);
}
#endif /* #if (SMP_INCLUDED == TRUE) */
btc_dm_dev_unpaired_evt(&p_data->link_down);
break;
}
case BTA_DM_BLE_DEV_UNPAIRED_EVT: {
@ -685,13 +699,14 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
break;
}
#endif /* BTC_GAP_BT_INCLUDED == TRUE */
case BTA_DM_LINK_UP_EVT:
btc_dm_link_up_evt(&p_data->link_up);
case BTA_DM_LINK_DOWN_EVT:
case BTA_DM_HW_ERROR_EVT:
BTC_TRACE_DEBUG( "btc_dm_sec_cback : unhandled event (%d)\n", msg->act );
break;
#if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE) && (SMP_INCLUDED == TRUE))
case BTA_DM_LINK_UP_EVT:
btc_dm_link_up_evt(&p_data->link_up);
break;
#if ((BLE_INCLUDED == TRUE) && (SMP_INCLUDED == TRUE))
case BTA_DM_BLE_AUTH_CMPL_EVT: {
rsp_app = true;
ble_msg.act = ESP_GAP_BLE_AUTH_CMPL_EVT;
@ -854,11 +869,10 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
}
if (rsp_app) {
ret = btc_transfer_context(&ble_msg, &param,
sizeof(esp_ble_gap_cb_param_t), NULL);
ret = btc_inter_profile_call(&ble_msg, &param);
if (ret != BT_STATUS_SUCCESS) {
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
}
}
btc_dm_sec_arg_deep_free(msg);

View file

@ -201,7 +201,6 @@ int btc_storage_get_num_bt_bond_devices(void)
}
}
btc_config_unlock();
return num_dev;
}
@ -215,15 +214,17 @@ int btc_storage_get_num_bt_bond_devices(void)
** BT_STATUS_FAIL otherwise
**
*******************************************************************************/
bt_status_t btc_storage_get_bonded_bt_devices_list(bt_bdaddr_t *bond_dev, int dev_num)
bt_status_t btc_storage_get_bonded_bt_devices_list(bt_bdaddr_t *bond_dev, int *dev_num)
{
bt_bdaddr_t bd_addr;
int in_dev_num = *dev_num; /* buffer size */
int out_dev_num = 0; /* bond_dev size */
btc_config_lock();
for (const btc_config_section_iter_t *iter = btc_config_section_begin(); iter != btc_config_section_end();
iter = btc_config_section_next(iter)) {
if (dev_num-- <= 0) {
if (in_dev_num <= 0) {
break;
}
@ -236,9 +237,12 @@ bt_status_t btc_storage_get_bonded_bt_devices_list(bt_bdaddr_t *bond_dev, int de
btc_config_exist(name, BTC_STORAGE_LINK_KEY_STR)) {
string_to_bdaddr(name, &bd_addr);
memcpy(bond_dev, &bd_addr, sizeof(bt_bdaddr_t));
in_dev_num--;
out_dev_num++;
bond_dev++;
}
}
*dev_num = out_dev_num; /* out_dev_num <= in_dev_num */
btc_config_unlock();
return BT_STATUS_SUCCESS;

View file

@ -89,6 +89,6 @@ int btc_storage_get_num_bt_bond_devices(void);
** BT_STATUS_FAIL otherwise
**
*******************************************************************************/
bt_status_t btc_storage_get_bonded_bt_devices_list(bt_bdaddr_t *bond_dev, int dev_num);
bt_status_t btc_storage_get_bonded_bt_devices_list(bt_bdaddr_t *bond_dev, int *dev_num);
#endif /* BTC_STORAGE_H */

View file

@ -127,12 +127,16 @@ void btc_a2dp_control_media_ctrl(esp_a2d_media_ctrl_t ctrl)
switch (ctrl) {
case ESP_A2D_MEDIA_CTRL_CHECK_SRC_RDY:
#if BTC_AV_SRC_INCLUDED
if (btc_a2dp_source_is_task_shutting_down()) {
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE);
} else if ((btc_av_stream_ready() == TRUE) ||
(btc_av_stream_started_ready() == TRUE)) {
/* check whether av is ready to setup a2dp datapath */
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_SUCCESS);
if (btc_av_get_service_id() == BTA_A2DP_SOURCE_SERVICE_ID) {
if (btc_a2dp_source_is_task_shutting_down()) {
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE);
} else if ((btc_av_stream_ready() == TRUE) ||
(btc_av_stream_started_ready() == TRUE)) {
/* check whether av is ready to setup a2dp datapath */
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_SUCCESS);
} else {
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE);
}
} else {
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE);
}
@ -159,6 +163,10 @@ void btc_a2dp_control_media_ctrl(esp_a2d_media_ctrl_t ctrl)
}
break;
case ESP_A2D_MEDIA_CTRL_STOP:
if (btc_av_is_connected() == FALSE) {
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE);
break;
}
#if BTC_AV_SRC_INCLUDED
if (btc_av_get_peer_sep() == AVDT_TSEP_SNK && !btc_a2dp_source_is_streaming() &&
btc_av_get_service_id() == BTA_A2DP_SOURCE_SERVICE_ID) {
@ -174,7 +182,6 @@ void btc_a2dp_control_media_ctrl(esp_a2d_media_ctrl_t ctrl)
}
#endif
break;
case ESP_A2D_MEDIA_CTRL_SUSPEND:
/* local suspend */
if (btc_av_stream_started_ready()) {
@ -184,14 +191,15 @@ void btc_a2dp_control_media_ctrl(esp_a2d_media_ctrl_t ctrl)
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_SUCCESS);
}
#endif
} else {
} else if (btc_av_is_connected() == TRUE) {
/* we are not in started state; just ack back ok. This can happen if we are
remotely suspended; clear REMOTE SUSPEND Flag */
btc_av_clear_remote_suspend_flag();
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_SUCCESS);
} else {
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE);
}
break;
default :
APPL_TRACE_ERROR("### A2DP-MEDIA EVENT %u NOT HANDLED ###", ctrl);
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE);

View file

@ -1120,7 +1120,7 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
BTA_DmUpdateWhiteList(arg->update_white_list.add_remove, arg->update_white_list.remote_bda, btc_add_whitelist_complete_callback);
break;
case BTC_GAP_BLE_ACT_READ_RSSI:
BTA_DmBleReadRSSI(arg->read_rssi.remote_addr, BTA_TRANSPORT_LE, btc_read_ble_rssi_cmpl_callback);
BTA_DmReadRSSI(arg->read_rssi.remote_addr, BTA_TRANSPORT_LE, btc_read_ble_rssi_cmpl_callback);
break;
case BTC_GAP_BLE_ACT_SET_CONN_PARAMS:
BTA_DmSetBlePrefConnParams(arg->set_conn_params.bd_addr, arg->set_conn_params.min_conn_int,

View file

@ -633,7 +633,7 @@ static void btc_gap_bt_read_rssi_delta_cmpl_callback(void *p_data)
static void btc_gap_bt_read_rssi_delta(btc_gap_bt_args_t *arg)
{
BTA_DmBleReadRSSI(arg->read_rssi_delta.bda.address, BTA_TRANSPORT_BR_EDR, btc_gap_bt_read_rssi_delta_cmpl_callback);
BTA_DmReadRSSI(arg->read_rssi_delta.bda.address, BTA_TRANSPORT_BR_EDR, btc_gap_bt_read_rssi_delta_cmpl_callback);
}
static esp_err_t btc_gap_bt_remove_bond_device(btc_gap_bt_args_t *arg)
@ -852,6 +852,7 @@ void btc_gap_bt_cb_deep_free(btc_msg_t *msg)
case BTC_GAP_BT_READ_RSSI_DELTA_EVT:
case BTC_GAP_BT_AUTH_CMPL_EVT:
case BTC_GAP_BT_PIN_REQ_EVT:
case BTC_GAP_BT_REMOVE_BOND_DEV_COMPLETE_EVT:
#if (BT_SSP_INCLUDED == TRUE)
case BTC_GAP_BT_CFM_REQ_EVT:
case BTC_GAP_BT_KEY_NOTIF_EVT:
@ -905,6 +906,10 @@ void btc_gap_bt_cb_handler(btc_msg_t *msg)
break;
}
#endif ///BT_SSP_INCLUDED == TRUE
case BTC_GAP_BT_REMOVE_BOND_DEV_COMPLETE_EVT:{
btc_gap_bt_cb_to_app(ESP_BT_GAP_REMOVE_BOND_DEV_COMPLETE_EVT,(esp_bt_gap_cb_param_t *)msg->arg);
break;
}
default:
BTC_TRACE_ERROR("%s: Unhandled event (%d)!\n", __FUNCTION__, msg->act);
break;

View file

@ -33,6 +33,7 @@ typedef enum {
BTC_GAP_BT_KEY_NOTIF_EVT,
BTC_GAP_BT_KEY_REQ_EVT,
BTC_GAP_BT_READ_RSSI_DELTA_EVT,
BTC_GAP_BT_REMOVE_BOND_DEV_COMPLETE_EVT,
}btc_gap_bt_evt_t;
typedef enum {

View file

@ -35,6 +35,7 @@ typedef enum {
BTC_SPP_ACT_CONNECT,
BTC_SPP_ACT_DISCONNECT,
BTC_SPP_ACT_START_SRV,
BTC_SPP_ACT_STOP_SRV,
BTC_SPP_ACT_WRITE,
} btc_spp_act_t;

View file

@ -29,6 +29,7 @@
#include <sys/fcntl.h>
#include "esp_vfs.h"
#include "esp_vfs_dev.h"
#include "stack/port_api.h"
#if (defined BTC_SPP_INCLUDED && BTC_SPP_INCLUDED == TRUE)
@ -55,13 +56,20 @@ typedef struct {
char service_name[ESP_SPP_SERVER_NAME_MAX + 1];
} spp_slot_t;
static struct spp_local_param_t {
spp_slot_t *spp_slots[BTA_JV_MAX_RFC_SR_SESSION + 1];
typedef struct {
spp_slot_t *spp_slots[MAX_RFC_PORTS + 1];
uint32_t spp_slot_id;
esp_spp_mode_t spp_mode;
osi_mutex_t spp_slot_mutex;
esp_vfs_id_t spp_vfs_id;
} spp_local_param;
} spp_local_param_t;
#if SPP_DYNAMIC_MEMORY == FALSE
static spp_local_param_t spp_local_param;
#else
static spp_local_param_t *spp_local_param_ptr;
#define spp_local_param (*spp_local_param_ptr)
#endif
static void spp_osi_free(void *p)
{
@ -73,7 +81,7 @@ static spp_slot_t *spp_malloc_slot(void)
if (++spp_local_param.spp_slot_id == 0) {
spp_local_param.spp_slot_id = 1;
}
for (size_t i = 1; i <= BTA_JV_MAX_RFC_SR_SESSION; i++) {
for (size_t i = 1; i <= MAX_RFC_PORTS; i++) {
if (spp_local_param.spp_slots[i] == NULL) {
spp_local_param.spp_slots[i] = (spp_slot_t *)osi_malloc(sizeof(spp_slot_t));
if (!spp_local_param.spp_slots[i]) {
@ -81,6 +89,9 @@ static spp_slot_t *spp_malloc_slot(void)
}
spp_local_param.spp_slots[i]->id = spp_local_param.spp_slot_id;
spp_local_param.spp_slots[i]->serial = i;
spp_local_param.spp_slots[i]->sdp_handle = 0;
spp_local_param.spp_slots[i]->rfc_handle = 0;
spp_local_param.spp_slots[i]->rfc_port_handle = 0;
spp_local_param.spp_slots[i]->connected = FALSE;
spp_local_param.spp_slots[i]->write_data = NULL;
spp_local_param.spp_slots[i]->list = list_new(spp_osi_free);
@ -101,7 +112,7 @@ static spp_slot_t *spp_malloc_slot(void)
static spp_slot_t *spp_find_slot_by_id(uint32_t id)
{
for (size_t i = 1; i <= BTA_JV_MAX_RFC_SR_SESSION; i++) {
for (size_t i = 1; i <= MAX_RFC_PORTS; i++) {
if (spp_local_param.spp_slots[i] != NULL && spp_local_param.spp_slots[i]->id == id) {
return spp_local_param.spp_slots[i];
}
@ -111,7 +122,7 @@ static spp_slot_t *spp_find_slot_by_id(uint32_t id)
static spp_slot_t *spp_find_slot_by_handle(uint32_t handle)
{
for (size_t i = 1; i <= BTA_JV_MAX_RFC_SR_SESSION; i++) {
for (size_t i = 1; i <= MAX_RFC_PORTS; i++) {
if (spp_local_param.spp_slots[i] != NULL && spp_local_param.spp_slots[i]->rfc_handle == handle) {
return spp_local_param.spp_slots[i];
}
@ -121,7 +132,7 @@ static spp_slot_t *spp_find_slot_by_handle(uint32_t handle)
static spp_slot_t *spp_find_slot_by_fd(int fd)
{
for (size_t i = 1; i <= BTA_JV_MAX_RFC_SR_SESSION; i++) {
for (size_t i = 1; i <= MAX_RFC_PORTS; i++) {
if (spp_local_param.spp_slots[i] != NULL && spp_local_param.spp_slots[i]->fd == fd) {
return spp_local_param.spp_slots[i];
}
@ -129,6 +140,16 @@ static spp_slot_t *spp_find_slot_by_fd(int fd)
return NULL;
}
static spp_slot_t *spp_find_slot_by_scn(uint32_t scn)
{
for (size_t i = 1; i <= MAX_RFC_PORTS; i++) {
if (spp_local_param.spp_slots[i] != NULL && spp_local_param.spp_slots[i]->scn == (uint8_t)scn) {
return spp_local_param.spp_slots[i];
}
}
return NULL;
}
static void spp_free_slot(spp_slot_t *slot)
{
if (!slot) {
@ -160,15 +181,6 @@ static void btc_create_server_fail_cb(void)
btc_spp_cb_to_app(ESP_SPP_START_EVT, &param);
}
static void btc_disconnect_cb(uint32_t handle)
{
esp_spp_cb_param_t param;
param.close.status = ESP_SPP_SUCCESS;
param.close.handle = handle;
param.close.async = FALSE;
btc_spp_cb_to_app(ESP_SPP_CLOSE_EVT, &param);
}
static void *btc_spp_rfcomm_inter_cb(tBTA_JV_EVT event, tBTA_JV *p_data, void *user_data)
{
bt_status_t status;
@ -177,34 +189,53 @@ static void *btc_spp_rfcomm_inter_cb(tBTA_JV_EVT event, tBTA_JV *p_data, void *u
uint32_t id = (uintptr_t)user_data;
spp_slot_t *slot, *slot_new;
if (!spp_local_param.spp_slot_mutex) {
BTC_TRACE_WARNING("%s SPP have been deinit, incoming events ignore!\n", __func__);
return new_user_data;
}
osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT);
switch (event) {
case BTA_JV_RFCOMM_SRV_OPEN_EVT:
case BTA_JV_RFCOMM_START_EVT:
slot = spp_find_slot_by_id(id);
if (!slot) {
BTC_TRACE_ERROR("%s unable to find RFCOMM slot!", __func__);
break;
}
slot_new = spp_malloc_slot();
if (!slot_new) {
BTC_TRACE_ERROR("%s unable to malloc RFCOMM slot!", __func__);
slot->rfc_handle = p_data->rfc_start.handle;
slot->rfc_port_handle = BTA_JvRfcommGetPortHdl(p_data->rfc_start.handle);
break;
case BTA_JV_RFCOMM_SRV_OPEN_EVT:
slot = p_data->rfc_srv_open.handle ? spp_find_slot_by_id(id) : spp_find_slot_by_scn((uint32_t)user_data);
if (!slot) {
BTC_TRACE_ERROR("%s unable to find RFCOMM slot!", __func__);
break;
}
new_user_data = (void *)(uintptr_t)slot_new->id;
slot_new->security = slot->security;
slot_new->role = slot->role;
slot_new->scn = slot->scn;;
slot_new->max_session = slot->max_session;
strcpy(slot_new->service_name, slot->service_name);
slot_new->sdp_handle = slot->sdp_handle;
slot_new->rfc_handle = p_data->rfc_srv_open.new_listen_handle;
slot_new->rfc_port_handle = BTA_JvRfcommGetPortHdl(p_data->rfc_srv_open.new_listen_handle);
memcpy(slot->addr, p_data->rfc_srv_open.rem_bda, ESP_BD_ADDR_LEN);
slot->connected = TRUE;
slot->rfc_handle = p_data->rfc_srv_open.handle;
slot->rfc_port_handle = BTA_JvRfcommGetPortHdl(p_data->rfc_srv_open.handle);
BTA_JvSetPmProfile(p_data->rfc_srv_open.handle, BTA_JV_PM_ALL, BTA_JV_CONN_OPEN);
if (p_data->rfc_srv_open.handle) {
new_user_data = (void *)(uintptr_t)slot->id;
memcpy(slot->addr, p_data->rfc_srv_open.rem_bda, ESP_BD_ADDR_LEN);
slot->connected = TRUE;
slot->rfc_handle = p_data->rfc_srv_open.handle;
slot->rfc_port_handle = BTA_JvRfcommGetPortHdl(p_data->rfc_srv_open.handle);
BTA_JvSetPmProfile(p_data->rfc_srv_open.handle, BTA_JV_PM_ALL, BTA_JV_CONN_OPEN);
}
if (p_data->rfc_srv_open.handle != p_data->rfc_srv_open.new_listen_handle) {
slot_new = spp_malloc_slot();
if (!slot_new) {
BTC_TRACE_ERROR("%s unable to malloc RFCOMM slot!", __func__);
break;
}
new_user_data = (void *)(uintptr_t)slot_new->id;
slot_new->security = slot->security;
slot_new->role = slot->role;
slot_new->scn = slot->scn;
slot_new->max_session = slot->max_session;
strcpy(slot_new->service_name, slot->service_name);
slot_new->sdp_handle = slot->sdp_handle;
slot_new->rfc_handle = p_data->rfc_srv_open.new_listen_handle;
slot_new->rfc_port_handle = BTA_JvRfcommGetPortHdl(p_data->rfc_srv_open.new_listen_handle);
}
break;
case BTA_JV_RFCOMM_OPEN_EVT:
slot = spp_find_slot_by_id(id);
@ -223,14 +254,26 @@ static void *btc_spp_rfcomm_inter_cb(tBTA_JV_EVT event, tBTA_JV *p_data, void *u
BTC_TRACE_ERROR("%s unable to find RFCOMM slot!", __func__);
break;
}
if (slot->connected) {
BTA_JvRfcommClose(slot->rfc_handle, (void *)slot->id);
if (slot->connected && p_data->rfc_close.port_status != PORT_LOCAL_CLOSED) {
BTA_JvRfcommClose(slot->rfc_handle, NULL, (void *)slot->id);
}
spp_free_slot(slot);
p_data->rfc_close.status = BTA_JV_SUCCESS;
break;
case BTA_JV_RFCOMM_DATA_IND_EVT:
break;
case BTA_JV_FREE_SCN_EVT:
if (user_data) {
id = ((tBTA_JV_FREE_SCN_USER_DATA *)user_data)->slot_id;
slot = spp_find_slot_by_id(id);
if (slot) {
spp_free_slot(slot);
} else {
BTC_TRACE_ERROR("%s unable to find RFCOMM slot!", __func__);
}
osi_free(user_data);
}
break;
default:
break;
}
@ -292,8 +335,15 @@ static void btc_spp_dm_inter_cb(tBTA_JV_EVT event, tBTA_JV *p_data, void *user_d
} else {
BTC_TRACE_ERROR("%s unable to create record, start server fail!", __func__);
btc_create_server_fail_cb();
BTA_JvFreeChannel(slot->scn, BTA_JV_CONN_TYPE_RFCOMM);
spp_free_slot(slot);
tBTA_JV_FREE_SCN_USER_DATA *user_data = osi_malloc(sizeof(tBTA_JV_FREE_SCN_USER_DATA));
if (user_data) {
user_data->server_status = BTA_JV_SERVER_START_FAILED;
user_data->slot_id = slot->id;
} else {
BTC_TRACE_ERROR("%s unable to malloc user data!", __func__);
}
BTA_JvFreeChannel(slot->scn, BTA_JV_CONN_TYPE_RFCOMM,
(tBTA_JV_RFCOMM_CBACK *)btc_spp_rfcomm_inter_cb, (void *)user_data);
}
osi_mutex_unlock(&spp_local_param.spp_slot_mutex);
break;
@ -313,6 +363,22 @@ static void btc_spp_dm_inter_cb(tBTA_JV_EVT event, tBTA_JV *p_data, void *user_d
static void btc_spp_init(btc_spp_args_t *arg)
{
if (spp_local_param.spp_slot_mutex) {
esp_spp_cb_param_t param;
param.init.status = ESP_SPP_FAILURE;
btc_spp_cb_to_app(ESP_SPP_INIT_EVT, &param);
BTC_TRACE_ERROR("%s SPP has been initiated, shall uninit first!", __func__);
return;
}
#if SPP_DYNAMIC_MEMORY == TRUE
if ((spp_local_param_ptr = (spp_local_param_t *)osi_malloc(sizeof(spp_local_param_t))) == NULL) {
BTC_TRACE_ERROR("%s malloc failed\n", __func__);
return;
}
memset((void *)spp_local_param_ptr, 0, sizeof(spp_local_param_t));
#endif
if (osi_mutex_new(&spp_local_param.spp_slot_mutex) != 0) {
BTC_TRACE_ERROR("%s osi_mutex_new failed\n", __func__);
return;
@ -324,40 +390,65 @@ static void btc_spp_init(btc_spp_args_t *arg)
static void btc_spp_uninit(void)
{
esp_spp_cb_param_t param;
if (!spp_local_param.spp_slot_mutex) {
BTC_TRACE_ERROR("%s SPP have not been init\n", __func__);
param.uninit.status = ESP_SPP_FAILURE;
btc_spp_cb_to_app(ESP_SPP_UNINIT_EVT, &param);
BTC_TRACE_ERROR("%s SPP has not been initiated, shall init first!", __func__);
return;
}
osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT);
for (size_t i = 1; i <= BTA_JV_MAX_RFC_SR_SESSION; i++) {
// first, remove all connection
for (size_t i = 1; i <= MAX_RFC_PORTS; i++) {
if (spp_local_param.spp_slots[i] != NULL && spp_local_param.spp_slots[i]->connected) {
BTA_JvRfcommClose(spp_local_param.spp_slots[i]->rfc_handle, (void *)spp_local_param.spp_slots[i]->id);
spp_free_slot(spp_local_param.spp_slots[i]);
spp_local_param.spp_slots[i] = NULL;
}
}
for (size_t i = 1; i <= BTA_JV_MAX_RFC_SR_SESSION; i++) {
if (spp_local_param.spp_slots[i] != NULL && !(spp_local_param.spp_slots[i]->connected)) {
BTA_JvRfcommStopServer(spp_local_param.spp_slots[i]->sdp_handle, (void *)spp_local_param.spp_slots[i]->id);
BTA_JvDeleteRecord(spp_local_param.spp_slots[i]->sdp_handle);
BTA_JvFreeChannel(spp_local_param.spp_slots[i]->scn, BTA_JV_CONN_TYPE_RFCOMM);
spp_free_slot(spp_local_param.spp_slots[i]);
spp_local_param.spp_slots[i] = NULL;
BTA_JvRfcommClose(spp_local_param.spp_slots[i]->rfc_handle,(tBTA_JV_RFCOMM_CBACK *)btc_spp_rfcomm_inter_cb,
(void *)spp_local_param.spp_slots[i]->id);
}
}
// second, remove all server
for (size_t i = 1; i <= MAX_RFC_PORTS; i++) {
if (spp_local_param.spp_slots[i] != NULL && !spp_local_param.spp_slots[i]->connected) {
if (spp_local_param.spp_slots[i]->sdp_handle > 0) {
BTA_JvDeleteRecord(spp_local_param.spp_slots[i]->sdp_handle);
}
BTA_JvDisable();
if (spp_local_param.spp_slots[i]->rfc_handle > 0) {
BTA_JvRfcommStopServer(spp_local_param.spp_slots[i]->rfc_handle,
(void *)spp_local_param.spp_slots[i]->id);
}
tBTA_JV_FREE_SCN_USER_DATA *user_data = osi_malloc(sizeof(tBTA_JV_FREE_SCN_USER_DATA));
if (user_data) {
user_data->server_status = BTA_JV_SERVER_RUNNING;
user_data->slot_id = spp_local_param.spp_slots[i]->id;
} else {
BTC_TRACE_ERROR("%s unable to malloc user data!", __func__);
param.srv_stop.status = ESP_SPP_NO_RESOURCE;
btc_spp_cb_to_app(ESP_SPP_SRV_STOP_EVT, &param);
}
BTA_JvFreeChannel(spp_local_param.spp_slots[i]->scn, BTA_JV_CONN_TYPE_RFCOMM,
(tBTA_JV_RFCOMM_CBACK *)btc_spp_rfcomm_inter_cb, (void *)user_data);
}
}
BTA_JvDisable((tBTA_JV_RFCOMM_CBACK *)btc_spp_rfcomm_inter_cb);
osi_mutex_unlock(&spp_local_param.spp_slot_mutex);
osi_mutex_free(&spp_local_param.spp_slot_mutex);
}
static void btc_spp_start_discovery(btc_spp_args_t *arg)
{
if (!spp_local_param.spp_slot_mutex) {
BTC_TRACE_ERROR("%s SPP have not been init\n", __func__);
return;
}
BTA_JvStartDiscovery(arg->start_discovery.bd_addr, arg->start_discovery.num_uuid, arg->start_discovery.p_uuid_list, NULL);
}
static void btc_spp_connect(btc_spp_args_t *arg)
{
if (!spp_local_param.spp_slot_mutex) {
BTC_TRACE_ERROR("%s SPP have not been init\n", __func__);
return;
}
osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT);
spp_slot_t *slot = spp_malloc_slot();
if (!slot) {
@ -376,6 +467,10 @@ static void btc_spp_connect(btc_spp_args_t *arg)
static void btc_spp_disconnect(btc_spp_args_t *arg)
{
if (!spp_local_param.spp_slot_mutex) {
BTC_TRACE_ERROR("%s SPP have not been init\n", __func__);
return;
}
osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT);
spp_slot_t *slot = spp_find_slot_by_handle(arg->disconnect.handle);
if (!slot) {
@ -383,14 +478,16 @@ static void btc_spp_disconnect(btc_spp_args_t *arg)
osi_mutex_unlock(&spp_local_param.spp_slot_mutex);
return;
}
BTA_JvRfcommClose(arg->disconnect.handle, (void *)slot->id);
btc_disconnect_cb(slot->rfc_handle);
spp_free_slot(slot);
BTA_JvRfcommClose(arg->disconnect.handle, (tBTA_JV_RFCOMM_CBACK *)btc_spp_rfcomm_inter_cb, (void *)slot->id);
osi_mutex_unlock(&spp_local_param.spp_slot_mutex);
}
static void btc_spp_start_srv(btc_spp_args_t *arg)
{
if (!spp_local_param.spp_slot_mutex) {
BTC_TRACE_ERROR("%s SPP have not been init\n", __func__);
return;
}
osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT);
spp_slot_t *slot = spp_malloc_slot();
if (!slot) {
@ -408,8 +505,54 @@ static void btc_spp_start_srv(btc_spp_args_t *arg)
osi_mutex_unlock(&spp_local_param.spp_slot_mutex);
}
static void btc_spp_stop_srv(void) {
if (!spp_local_param.spp_slot_mutex) {
BTC_TRACE_ERROR("%s SPP have not been init\n", __func__);
return;
}
esp_spp_cb_param_t param;
osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT);
// first, remove all connection
for (size_t i = 1; i <= MAX_RFC_PORTS; i++) {
if (spp_local_param.spp_slots[i] != NULL && spp_local_param.spp_slots[i]->connected) {
BTA_JvRfcommClose(spp_local_param.spp_slots[i]->rfc_handle,(tBTA_JV_RFCOMM_CBACK *)btc_spp_rfcomm_inter_cb,
(void *)spp_local_param.spp_slots[i]->id);
}
}
// second, remove all server
for (size_t i = 1; i <= MAX_RFC_PORTS; i++) {
if (spp_local_param.spp_slots[i] != NULL && !spp_local_param.spp_slots[i]->connected) {
if (spp_local_param.spp_slots[i]->sdp_handle > 0) {
BTA_JvDeleteRecord(spp_local_param.spp_slots[i]->sdp_handle);
}
if (spp_local_param.spp_slots[i]->rfc_handle > 0) {
BTA_JvRfcommStopServer(spp_local_param.spp_slots[i]->rfc_handle,
(void *)spp_local_param.spp_slots[i]->id);
}
tBTA_JV_FREE_SCN_USER_DATA *user_data = osi_malloc(sizeof(tBTA_JV_FREE_SCN_USER_DATA));
if (user_data) {
user_data->server_status = BTA_JV_SERVER_RUNNING;
user_data->slot_id = spp_local_param.spp_slots[i]->id;
} else {
BTC_TRACE_ERROR("%s unable to malloc user data!", __func__);
param.srv_stop.status = ESP_SPP_NO_RESOURCE;
btc_spp_cb_to_app(ESP_SPP_SRV_STOP_EVT, &param);
}
BTA_JvFreeChannel(spp_local_param.spp_slots[i]->scn, BTA_JV_CONN_TYPE_RFCOMM,
(tBTA_JV_RFCOMM_CBACK *)btc_spp_rfcomm_inter_cb, (void *)user_data);
}
}
osi_mutex_unlock(&spp_local_param.spp_slot_mutex);
}
static void btc_spp_write(btc_spp_args_t *arg)
{
if (!spp_local_param.spp_slot_mutex) {
BTC_TRACE_ERROR("%s SPP have not been init\n", __func__);
return;
}
osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT);
spp_slot_t *slot = spp_find_slot_by_handle(arg->write.handle);
if (!slot) {
@ -423,7 +566,7 @@ static void btc_spp_write(btc_spp_args_t *arg)
osi_mutex_unlock(&spp_local_param.spp_slot_mutex);
return;
}
uint8_t *data = xRingbufferReceiveUpTo(slot->ringbuf_write, &item_size, 0,990);
uint8_t *data = xRingbufferReceiveUpTo(slot->ringbuf_write, &item_size, 0, BTA_JV_DEF_RFC_MTU);
if (item_size != 0){
slot->write_data = data;
BTA_JvRfcommWrite(arg->write.handle, slot->id, item_size, data);
@ -504,6 +647,9 @@ void btc_spp_call_handler(btc_msg_t *msg)
case BTC_SPP_ACT_START_SRV:
btc_spp_start_srv(arg);
break;
case BTC_SPP_ACT_STOP_SRV:
btc_spp_stop_srv();
break;
case BTC_SPP_ACT_WRITE:
btc_spp_write(arg);
break;
@ -562,22 +708,24 @@ void btc_spp_cb_handler(btc_msg_t *msg)
btc_spp_cb_to_app(ESP_SPP_START_EVT, &param);
break;
case BTA_JV_RFCOMM_SRV_OPEN_EVT:
if (spp_local_param.spp_mode == ESP_SPP_MODE_VFS) {
osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT);
slot = spp_find_slot_by_handle(p_data->rfc_srv_open.handle);
if (!slot) {
BTC_TRACE_ERROR("%s unable to find RFCOMM slot!", __func__);
if (p_data->rfc_srv_open.handle) {
if (spp_local_param.spp_mode == ESP_SPP_MODE_VFS) {
osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT);
slot = spp_find_slot_by_handle(p_data->rfc_srv_open.handle);
if (!slot) {
BTC_TRACE_ERROR("%s unable to find RFCOMM slot!", __func__);
osi_mutex_unlock(&spp_local_param.spp_slot_mutex);
break;
}
param.srv_open.fd = slot->fd;
osi_mutex_unlock(&spp_local_param.spp_slot_mutex);
break;
}
param.srv_open.fd = slot->fd;
osi_mutex_unlock(&spp_local_param.spp_slot_mutex);
param.srv_open.status = p_data->rfc_srv_open.status;
param.srv_open.handle = p_data->rfc_srv_open.handle;
param.srv_open.new_listen_handle = p_data->rfc_srv_open.new_listen_handle;
memcpy(param.srv_open.rem_bda, p_data->rfc_srv_open.rem_bda, ESP_BD_ADDR_LEN);
btc_spp_cb_to_app(ESP_SPP_SRV_OPEN_EVT, &param);
}
param.srv_open.status = p_data->rfc_srv_open.status;
param.srv_open.handle = p_data->rfc_srv_open.handle;
param.srv_open.new_listen_handle = p_data->rfc_srv_open.new_listen_handle;
memcpy(param.srv_open.rem_bda, p_data->rfc_srv_open.rem_bda, ESP_BD_ADDR_LEN);
btc_spp_cb_to_app(ESP_SPP_SRV_OPEN_EVT, &param);
break;
case BTA_JV_RFCOMM_WRITE_EVT:
osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT);
@ -609,7 +757,7 @@ void btc_spp_cb_handler(btc_msg_t *msg)
slot->write_data = NULL;
}
size_t item_size = 0;
uint8_t *data = xRingbufferReceiveUpTo(slot->ringbuf_write, &item_size, 0,990);
uint8_t *data = xRingbufferReceiveUpTo(slot->ringbuf_write, &item_size, 0, BTA_JV_DEF_RFC_MTU);
if (item_size != 0){
slot->write_data = data;
BTA_JvRfcommWrite(slot->rfc_handle, slot->id, item_size, data);
@ -645,7 +793,7 @@ void btc_spp_cb_handler(btc_msg_t *msg)
slot->write_data = NULL;
}
size_t item_size = 0;
uint8_t *data = xRingbufferReceiveUpTo(slot->ringbuf_write, &item_size, 0,990);
uint8_t *data = xRingbufferReceiveUpTo(slot->ringbuf_write, &item_size, 0, BTA_JV_DEF_RFC_MTU);
if (item_size != 0){
slot->write_data = data;
BTA_JvRfcommWrite(slot->rfc_handle, slot->id, item_size, data);
@ -668,6 +816,22 @@ void btc_spp_cb_handler(btc_msg_t *msg)
btc_spp_cb_to_app(ESP_SPP_DATA_IND_EVT, &param);
osi_free (p_data->data_ind.p_buf);
break;
case BTA_JV_FREE_SCN_EVT:
if (p_data->free_scn.server_status == BTA_JV_SERVER_RUNNING) {
param.srv_stop.status = p_data->free_scn.status;
btc_spp_cb_to_app(ESP_SPP_SRV_STOP_EVT, &param);
}
break;
case BTA_JV_DISABLE_EVT:
param.uninit.status = ESP_SPP_SUCCESS;
BTA_JvFree();
osi_mutex_free(&spp_local_param.spp_slot_mutex);
#if SPP_DYNAMIC_MEMORY == TRUE
osi_free(spp_local_param_ptr);
spp_local_param_ptr = NULL;
#endif
btc_spp_cb_to_app(ESP_SPP_UNINIT_EVT, &param);
break;
default:
BTC_TRACE_DEBUG("%s: Unhandled event (%d)!", __FUNCTION__, msg->act);
break;
@ -705,12 +869,16 @@ int bta_co_rfc_data_incoming(void *user_data, BT_HDR *p_buf)
msg.act = BTA_JV_RFCOMM_DATA_IND_EVT;
uint32_t id = (uintptr_t)user_data;
if (!spp_local_param.spp_slot_mutex) {
BTC_TRACE_ERROR("%s SPP have not been init\n", __func__);
return -1;
}
osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT);
spp_slot_t *slot = spp_find_slot_by_id(id);
if (!slot) {
BTC_TRACE_ERROR("%s unable to find RFCOMM slot!", __func__);
osi_mutex_unlock(&spp_local_param.spp_slot_mutex);
return 0;
return -1;
}
p_data.data_ind.handle = slot->rfc_handle;
@ -751,6 +919,10 @@ int bta_co_rfc_data_outgoing(void *user_data, uint8_t *buf, uint16_t size)
static ssize_t spp_vfs_write(int fd, const void * data, size_t size)
{
if (!spp_local_param.spp_slot_mutex) {
BTC_TRACE_ERROR("%s SPP have not been init\n", __func__);
return -1;
}
osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT);
spp_slot_t *slot = spp_find_slot_by_fd(fd);
if (!slot) {
@ -770,6 +942,10 @@ static ssize_t spp_vfs_write(int fd, const void * data, size_t size)
}
static int spp_vfs_close(int fd)
{
if (!spp_local_param.spp_slot_mutex) {
BTC_TRACE_ERROR("%s SPP have not been init\n", __func__);
return -1;
}
osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT);
spp_slot_t *slot = spp_find_slot_by_fd(fd);
if (!slot) {
@ -798,6 +974,10 @@ static bool incoming_list_2_ringbuf_read(spp_slot_t *slot)
static ssize_t spp_vfs_read(int fd, void * dst, size_t size)
{
if (!spp_local_param.spp_slot_mutex) {
BTC_TRACE_ERROR("%s SPP have not been init\n", __func__);
return -1;
}
osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT);
spp_slot_t *slot = spp_find_slot_by_fd(fd);
if (!slot) {

View file

@ -96,6 +96,12 @@
#endif /* #if CONFIG_CLASSIC_BT_ENABLED */
/* This is set to enable use of GAP L2CAP connections. */
#if (VND_BT_JV_BTA_L2CAP == TRUE)
#define BTA_JV_L2CAP_INCLUDED TRUE
#define GAP_CONN_INCLUDED TRUE
#endif /* VND_BT_JV_BTA_L2CAP */
#ifndef CLASSIC_BT_INCLUDED
#define CLASSIC_BT_INCLUDED FALSE
#endif /* CLASSIC_BT_INCLUDED */
@ -293,6 +299,19 @@
#define BTA_SDP_INCLUDED FALSE
#endif
/* This is set to enable use of GAP L2CAP connections. */
#ifndef VND_BT_JV_BTA_L2CAP
#define VND_BT_JV_BTA_L2CAP FALSE
#endif
#ifndef BTA_JV_L2CAP_INCLUDED
#define BTA_JV_L2CAP_INCLUDED FALSE
#endif
#ifndef GAP_CONN_INCLUDED
#define GAP_CONN_INCLUDED FALSE
#endif
/******************************************************************************
**
** Stack-layer components
@ -1341,7 +1360,7 @@
/* The maximum number of ports supported. */
#ifndef MAX_RFC_PORTS
#define MAX_RFC_PORTS 16 /*max is 30*/
#define MAX_RFC_PORTS 8 /*max is 30*/
#endif
/* The maximum simultaneous links to different devices. */
@ -1710,15 +1729,6 @@ Range: 2 octets
#define GAP_INCLUDED TRUE
#endif
/* This is set to enable use of GAP L2CAP connections. */
#ifndef GAP_CONN_INCLUDED
#if (GAP_INCLUDED == TRUE && CLASSIC_BT_INCLUDED == TRUE)
#define GAP_CONN_INCLUDED TRUE
#else
#define GAP_CONN_INCLUDED FALSE
#endif
#endif
/* This is set to enable posting event for data write */
#ifndef GAP_CONN_POST_EVT_INCLUDED
#define GAP_CONN_POST_EVT_INCLUDED FALSE

View file

@ -794,7 +794,7 @@ void btm_acl_encrypt_change (UINT16 handle, UINT8 status, UINT8 encr_enable)
BTM_TRACE_WARNING("btm_acl_encrypt_change -> Issuing delayed HCI_Disconnect!!!\n");
btsnd_hcic_disconnect(p_dev_rec->hci_handle, HCI_ERR_PEER_USER);
}
BTM_TRACE_ERROR("btm_acl_encrypt_change: tBTM_SEC_DEV:0x%x rs_disc_pending=%d\n",
BTM_TRACE_WARNING("btm_acl_encrypt_change: tBTM_SEC_DEV:0x%x rs_disc_pending=%d\n",
(UINT32)p_dev_rec, p_dev_rec->rs_disc_pending);
p_dev_rec->rs_disc_pending = BTM_SEC_RS_NOT_PENDING; /* reset flag */
}
@ -1140,7 +1140,6 @@ void btm_read_remote_ext_features_complete (UINT8 *p)
if (max_page > HCI_EXT_FEATURES_PAGE_MAX) {
BTM_TRACE_ERROR("btm_read_remote_ext_features_complete page=%d unknown", max_page);
return;
}
p_acl_cb = &btm_cb.acl_db[acl_idx];

View file

@ -2257,7 +2257,7 @@ tBTM_STATUS btm_sec_l2cap_access_req (BD_ADDR bd_addr, UINT16 psm, UINT16 handle
}
} else if (!(BTM_SM4_KNOWN & p_dev_rec->sm4)) {
/* the remote features are not known yet */
BTM_TRACE_DEBUG("%s: (%s) remote features unknown!!sec_flags:0x%02x\n", __FUNCTION__,
BTM_TRACE_ERROR("%s: (%s) remote features unknown!!sec_flags:0x%02x\n", __FUNCTION__,
(is_originator) ? "initiator" : "acceptor", p_dev_rec->sec_flags);
p_dev_rec->sm4 |= BTM_SM4_REQ_PEND;

View file

@ -219,6 +219,7 @@ void gatt_act_write (tGATT_CLCB *p_clcb, UINT8 sec_act)
if (p_attr) {
switch (p_clcb->op_subtype) {
case GATT_WRITE_NO_RSP:
l2ble_update_att_acl_pkt_num(L2CA_DECREASE_BTU_NUM, NULL);
p_clcb->s_handle = p_attr->handle;
op_code = (sec_act == GATT_SEC_SIGN_DATA) ? GATT_SIGN_CMD_WRITE : GATT_CMD_WRITE;
rt = gatt_send_write_msg(p_tcb,

View file

@ -29,6 +29,7 @@
#include "common/bt_target.h"
#include "stack/l2cdefs.h"
#include "stack/hcidefs.h"
#include "osi/fixed_queue.h"
/*****************************************************************************
** Constants
@ -1227,6 +1228,21 @@ extern UINT16 L2CA_GetDisconnectReason (BD_ADDR remote_bda, tBT_TRANSPORT transp
extern BOOLEAN L2CA_CheckIsCongest(UINT16 fixed_cid, UINT16 handle);
#define L2CA_GET_ATT_NUM 0
#define L2CA_ADD_BTC_NUM 1
#define L2CA_DECREASE_BTC_NUM 2
#define L2CA_ADD_BTU_NUM 3
#define L2CA_DECREASE_BTU_NUM 4
#define L2CA_BUFF_INI 5
#define L2CA_BUFF_DEINIT 6
typedef struct {
UINT16 conn_id;
UINT16 * get_num;
} tl2c_buff_param_t;
extern void l2ble_update_att_acl_pkt_num(UINT8 type, tl2c_buff_param_t *param);
#endif /* (BLE_INCLUDED == TRUE) */

View file

@ -73,7 +73,7 @@
#define L2CAP_DEFAULT_RETRANS_TOUT 2000 /* 2000 milliseconds */
#define L2CAP_DEFAULT_MONITOR_TOUT 12000 /* 12000 milliseconds */
#define L2CAP_FCR_ACK_TOUT 200 /* 200 milliseconds */
#define L2CAP_CACHE_ATT_ACL_NUM 10
/* Define the possible L2CAP channel states. The names of
** the states may seem a bit strange, but they are taken from
** the Bluetooth specification.
@ -165,6 +165,10 @@ typedef enum {
#define L2CAP_MAX_FCR_CFG_TRIES 2 /* Config attempts before disconnecting */
#ifndef MIN
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#endif
typedef uint8_t tL2C_BLE_FIXED_CHNLS_MASK;
typedef struct {

View file

@ -36,6 +36,8 @@
#include "stack/btu.h"
#include "stack/btm_api.h"
#include "osi/allocator.h"
#include "gatt_int.h"
#include "freertos/semphr.h"
#if (CLASSIC_BT_INCLUDED == TRUE)
/*******************************************************************************
@ -1877,6 +1879,16 @@ UINT16 L2CA_GetFreePktBufferNum_LE(void)
{
return l2cb.controller_le_xmit_window;
}
UINT16 L2CA_GetCurFreePktBufferNum_LE(UINT16 conn_id)
{
uint16_t num = 0;
tl2c_buff_param_t param;
param.conn_id = conn_id;
param.get_num = &num;
l2ble_update_att_acl_pkt_num(L2CA_GET_ATT_NUM, &param);
return num;
}
#endif
/*******************************************************************************
@ -2265,3 +2277,111 @@ UINT16 L2CA_FlushChannel (UINT16 lcid, UINT16 num_to_flush)
return (num_left);
}
/******************************************************************************
**
** Function update_acl_pkt_num
**
** Description Update the number of att acl packets to be sent in xmit_hold_q.
**
** Returns None
**
*******************************************************************************/
#if BLE_INCLUDED == TRUE
void l2ble_update_att_acl_pkt_num(UINT8 type, tl2c_buff_param_t *param)
{
static SemaphoreHandle_t buff_semaphore = NULL ;
static INT16 btc_buf;
static INT16 btu_buf;
if(buff_semaphore == NULL && type != L2CA_BUFF_INI){
L2CAP_TRACE_ERROR("%s buff_semaphore not init", __func__);
return;
}
switch (type)
{
case L2CA_ADD_BTC_NUM:{
xSemaphoreTake(buff_semaphore, portMAX_DELAY);
btc_buf ++;
xSemaphoreGive(buff_semaphore);
break;
}
case L2CA_DECREASE_BTC_NUM:{
xSemaphoreTake(buff_semaphore, portMAX_DELAY);
btc_buf --;
xSemaphoreGive(buff_semaphore);
break;
}
case L2CA_ADD_BTU_NUM:{
xSemaphoreTake(buff_semaphore, portMAX_DELAY);
btu_buf ++;
xSemaphoreGive(buff_semaphore);
break;
}
case L2CA_DECREASE_BTU_NUM:{
xSemaphoreTake(buff_semaphore, portMAX_DELAY);
btu_buf --;
xSemaphoreGive(buff_semaphore);
break;
}
case L2CA_GET_ATT_NUM:{
xSemaphoreTake(buff_semaphore, portMAX_DELAY);
INT16 att_acl_pkt_num = 0;
INT16 att_max_num = 0;
*(param->get_num) = 0;
UINT8 tcb_idx = param->conn_id;
tGATT_TCB * p_tcb = gatt_get_tcb_by_idx(tcb_idx);
if (p_tcb == NULL){
L2CAP_TRACE_ERROR("%s not found p_tcb", __func__);
xSemaphoreGive(buff_semaphore);
break;
}
tL2C_LCB * p_lcb = l2cu_find_lcb_by_bd_addr (p_tcb->peer_bda, BT_TRANSPORT_LE);
if (p_lcb == NULL){
L2CAP_TRACE_ERROR("%s not found p_lcb", __func__);
xSemaphoreGive(buff_semaphore);
break;
}
fixed_queue_t * queue = p_lcb->p_fixed_ccbs[L2CAP_ATT_CID - L2CAP_FIRST_FIXED_CHNL]->xmit_hold_q;
att_max_num = MIN(p_lcb->link_xmit_quota, L2CAP_CACHE_ATT_ACL_NUM);
if (queue == NULL){
L2CAP_TRACE_ERROR("%s not found queue", __func__);
xSemaphoreGive(buff_semaphore);
break;
}
att_acl_pkt_num = fixed_queue_length(queue);
if(att_acl_pkt_num < att_max_num){
if(btc_buf + btu_buf < att_max_num - att_acl_pkt_num){
*(param->get_num) = att_max_num - att_acl_pkt_num - (btc_buf + btu_buf);
}
}
xSemaphoreGive(buff_semaphore);
break;
}
case L2CA_BUFF_INI:{
btc_buf = 0;
btu_buf = 0;
buff_semaphore = xSemaphoreCreateBinary();
if (buff_semaphore == NULL) {
L2CAP_TRACE_ERROR("%s NO MEMORY", __func__);
break;
}
xSemaphoreGive(buff_semaphore);
break;
}
case L2CA_BUFF_DEINIT:{
xSemaphoreTake(buff_semaphore, portMAX_DELAY);
btc_buf = 0;
btu_buf = 0;
xSemaphoreGive(buff_semaphore);
vSemaphoreDelete(buff_semaphore);
buff_semaphore = NULL;
break;
}
default:
break;
}
}
#endif

View file

@ -1127,6 +1127,12 @@ void l2c_link_check_send_pkts (tL2C_LCB *p_lcb, tL2C_CCB *p_ccb, BT_HDR *p_buf)
while ((l2cb.controller_xmit_window != 0) && (p_lcb->sent_not_acked < p_lcb->link_xmit_quota))
#endif
{
//need check flag: partial_segment_being_sent.
if ( (p_lcb->partial_segment_being_sent)
|| (p_lcb->link_state != LST_CONNECTED)
|| (L2C_LINK_CHECK_POWER_MODE (p_lcb)) ) {
break;
}
//L2CAP_TRACE_DEBUG("l2cu_get_next_buffer_to_send = %p",l2cu_get_next_buffer_to_send(p_lcb));
if ((p_buf = l2cu_get_next_buffer_to_send (p_lcb)) == NULL) {
break;

View file

@ -880,6 +880,10 @@ void l2c_init (void)
if (l2cb.rcv_pending_q == NULL) {
L2CAP_TRACE_ERROR("%s unable to allocate memory for link layer control block", __func__);
}
#if BLE_INCLUDED == TRUE
l2ble_update_att_acl_pkt_num(L2CA_BUFF_INI, NULL);
#endif
}
void l2c_free(void)
@ -889,6 +893,9 @@ void l2c_free(void)
#if L2C_DYNAMIC_MEMORY
FREE_AND_RESET(l2c_cb_ptr);
#endif
#if BLE_INCLUDED == TRUE
l2ble_update_att_acl_pkt_num(L2CA_BUFF_DEINIT, NULL);
#endif
}
/*******************************************************************************

View file

@ -3657,7 +3657,7 @@ void l2cu_check_channel_congestion (tL2C_CCB *p_ccb)
} else {
tL2C_LCB *p_lcb = p_ccb->p_lcb;
/* If this channel was not congested but it is congested now, tell the app */
if ((q_count > p_ccb->buff_quota) || (p_lcb && (p_ccb->local_cid == L2CAP_ATT_CID) && (p_lcb->link_xmit_quota > 0) && (p_lcb->link_xmit_quota <= p_lcb->sent_not_acked))) {
if (q_count > p_ccb->buff_quota || (p_lcb && (p_lcb->link_xmit_data_q) && (list_length(p_lcb->link_xmit_data_q) + q_count) > p_ccb->buff_quota)) {
p_ccb->cong_sent = TRUE;
if (p_ccb->p_rcb && p_ccb->p_rcb->api.pL2CA_CongestionStatus_Cb) {
L2CAP_TRACE_DEBUG ("L2CAP - Calling CongestionStatus_Cb (TRUE),CID:0x%04x,XmitQ:%u,Quota:%u",

View file

@ -164,6 +164,15 @@ static bt_status_t btc_task_post(btc_msg_t *msg, task_post_t timeout)
return BT_STATUS_SUCCESS;
}
/**
* transfer an message to another module in the different task.
* @param msg message
* @param arg paramter
* @param arg_len length of paramter
* @param copy_func deep copy function
* @return BT_STATUS_SUCCESS: success
* others: fail
*/
bt_status_t btc_transfer_context(btc_msg_t *msg, void *arg, int arg_len, btc_arg_deep_copy_t copy_func)
{
btc_msg_t lmsg;
@ -192,6 +201,32 @@ bt_status_t btc_transfer_context(btc_msg_t *msg, void *arg, int arg_len, btc_arg
return btc_task_post(&lmsg, TASK_POST_BLOCKING);
}
/**
* transfer an message to another module in tha same task.
* @param msg message
* @param arg paramter
* @return BT_STATUS_SUCCESS: success
* others: fail
*/
bt_status_t btc_inter_profile_call(btc_msg_t *msg, void *arg)
{
if (msg == NULL) {
return BT_STATUS_PARM_INVALID;
}
msg->arg = arg;
switch (msg->sig) {
case BTC_SIG_API_CALL:
profile_tab[msg->pid].btc_call(msg);
break;
case BTC_SIG_API_CB:
profile_tab[msg->pid].btc_cb(msg);
break;
default:
break;
}
return BT_STATUS_SUCCESS;
}
int btc_init(void)
{

View file

@ -92,8 +92,26 @@ typedef struct {
typedef void (* btc_arg_deep_copy_t)(btc_msg_t *msg, void *dst, void *src);
/**
* transfer an message to another module in the different task.
* @param msg message
* @param arg paramter
* @param arg_len length of paramter
* @param copy_func deep copy function
* @return BT_STATUS_SUCCESS: success
* others: fail
*/
bt_status_t btc_transfer_context(btc_msg_t *msg, void *arg, int arg_len, btc_arg_deep_copy_t copy_func);
/**
* transfer an message to another module in tha same task.
* @param msg message
* @param arg paramter
* @return BT_STATUS_SUCCESS: success
* others: fail
*/
bt_status_t btc_inter_profile_call(btc_msg_t *msg, void *arg);
int btc_init(void);
void btc_deinit(void);
bool btc_check_queue_is_congest(void);

View file

@ -267,6 +267,7 @@ bool config_remove_key(config_t *config, const char *section, const char *key)
assert(config != NULL);
assert(section != NULL);
assert(key != NULL);
bool ret;
section_t *sec = section_find(config, section);
entry_t *entry = entry_find(config, section, key);
@ -274,7 +275,12 @@ bool config_remove_key(config_t *config, const char *section, const char *key)
return false;
}
return list_remove(sec->entries, entry);
ret = list_remove(sec->entries, entry);
if (list_length(sec->entries) == 0) {
OSI_TRACE_DEBUG("%s remove section name:%s",__func__, section);
ret &= config_remove_section(config, section);
}
return ret;
}
const config_section_node_t *config_section_begin(const config_t *config)

View file

@ -15,6 +15,7 @@
#ifndef __THREAD_H__
#define __THREAD_H__
#include <stdbool.h>
#include "freertos/xtensa_api.h"
#include "freertos/FreeRTOSConfig.h"
#include "freertos/FreeRTOS.h"

View file

@ -156,6 +156,7 @@ COMPONENT_SRCDIRS += esp_ble_mesh/mesh_common \
esp_ble_mesh/mesh_core \
esp_ble_mesh/mesh_core/storage \
esp_ble_mesh/btc \
esp_ble_mesh/mesh_models/common \
esp_ble_mesh/mesh_models/client \
esp_ble_mesh/mesh_models/server \
esp_ble_mesh/api/core \

View file

@ -42,7 +42,7 @@ esp_err_t esp_ble_mesh_init(esp_ble_mesh_prov_t *prov, esp_ble_mesh_comp_t *comp
// Create a semaphore
if ((semaphore = xSemaphoreCreateCounting(1, 0)) == NULL) {
BT_ERR("%s, Failed to allocate memory for the semaphore", __func__);
BT_ERR("Failed to create semaphore");
return ESP_ERR_NO_MEM;
}
@ -57,7 +57,7 @@ esp_err_t esp_ble_mesh_init(esp_ble_mesh_prov_t *prov, esp_ble_mesh_comp_t *comp
if (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL) != BT_STATUS_SUCCESS) {
vSemaphoreDelete(semaphore);
BT_ERR("%s, BLE Mesh initialise failed", __func__);
BT_ERR("Failed to start mesh init");
return ESP_FAIL;
}

View file

@ -32,7 +32,8 @@ uint16_t esp_ble_mesh_get_primary_element_address(void)
return btc_ble_mesh_get_primary_addr();
}
uint16_t *esp_ble_mesh_is_model_subscribed_to_group(esp_ble_mesh_model_t *model, uint16_t group_addr)
uint16_t *esp_ble_mesh_is_model_subscribed_to_group(esp_ble_mesh_model_t *model,
uint16_t group_addr)
{
if (model == NULL) {
return NULL;
@ -54,7 +55,7 @@ uint8_t esp_ble_mesh_get_element_count(void)
}
esp_ble_mesh_model_t *esp_ble_mesh_find_vendor_model(const esp_ble_mesh_elem_t *element,
uint16_t company_id, uint16_t model_id)
uint16_t company_id, uint16_t model_id)
{
if (element == NULL) {
return NULL;
@ -62,7 +63,8 @@ esp_ble_mesh_model_t *esp_ble_mesh_find_vendor_model(const esp_ble_mesh_elem_t *
return btc_ble_mesh_model_find_vnd(element, company_id, model_id);
}
esp_ble_mesh_model_t *esp_ble_mesh_find_sig_model(const esp_ble_mesh_elem_t *element, uint16_t model_id)
esp_ble_mesh_model_t *esp_ble_mesh_find_sig_model(const esp_ble_mesh_elem_t *element,
uint16_t model_id)
{
if (element == NULL) {
return NULL;

View file

@ -23,12 +23,12 @@
#define ESP_BLE_MESH_TX_SDU_MAX ((CONFIG_BLE_MESH_ADV_BUF_COUNT - 3) * 12)
static esp_err_t ble_mesh_model_send_msg(esp_ble_mesh_model_t *model,
esp_ble_mesh_msg_ctx_t *ctx,
uint32_t opcode,
btc_ble_mesh_model_act_t act,
uint16_t length, uint8_t *data,
int32_t msg_timeout, bool need_rsp,
esp_ble_mesh_dev_role_t device_role)
esp_ble_mesh_msg_ctx_t *ctx,
uint32_t opcode,
btc_ble_mesh_model_act_t act,
uint16_t length, uint8_t *data,
int32_t msg_timeout, bool need_rsp,
esp_ble_mesh_dev_role_t device_role)
{
btc_ble_mesh_model_args_t arg = {0};
uint8_t op_len = 0, mic_len = 0;
@ -39,12 +39,12 @@ static esp_err_t ble_mesh_model_send_msg(esp_ble_mesh_model_t *model,
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
if (ctx && ctx->addr == ESP_BLE_MESH_ADDR_UNASSIGNED) {
BT_ERR("%s, Invalid destination address 0x0000", __func__);
BT_ERR("Invalid destination address 0x0000");
return ESP_ERR_INVALID_ARG;
}
if (device_role > ROLE_FAST_PROV) {
BT_ERR("%s, Invalid device role 0x%02x", __func__, device_role);
BT_ERR("Invalid device role 0x%02x", device_role);
return ESP_ERR_INVALID_ARG;
}
@ -63,7 +63,7 @@ static esp_err_t ble_mesh_model_send_msg(esp_ble_mesh_model_t *model,
if (act == BTC_BLE_MESH_ACT_MODEL_PUBLISH) {
if (op_len + length > model->pub->msg->size) {
BT_ERR("%s, Model publication msg size %d is too small", __func__, model->pub->msg->size);
BT_ERR("Too small publication msg size %d", model->pub->msg->size);
return ESP_ERR_INVALID_ARG;
}
}
@ -75,7 +75,7 @@ static esp_err_t ble_mesh_model_send_msg(esp_ble_mesh_model_t *model,
}
if (op_len + length + mic_len > MIN(ESP_BLE_MESH_SDU_MAX_LEN, ESP_BLE_MESH_TX_SDU_MAX)) {
BT_ERR("%s, Data length %d is too large", __func__, length);
BT_ERR("Too large data length %d", length);
return ESP_ERR_INVALID_ARG;
}
@ -176,8 +176,9 @@ esp_err_t esp_ble_mesh_client_model_deinit(esp_ble_mesh_model_t *model)
}
esp_err_t esp_ble_mesh_server_model_send_msg(esp_ble_mesh_model_t *model,
esp_ble_mesh_msg_ctx_t *ctx, uint32_t opcode,
uint16_t length, uint8_t *data)
esp_ble_mesh_msg_ctx_t *ctx,
uint32_t opcode,
uint16_t length, uint8_t *data)
{
if (model == NULL || ctx == NULL ||
ctx->net_idx == ESP_BLE_MESH_KEY_UNUSED ||
@ -190,9 +191,11 @@ esp_err_t esp_ble_mesh_server_model_send_msg(esp_ble_mesh_model_t *model,
}
esp_err_t esp_ble_mesh_client_model_send_msg(esp_ble_mesh_model_t *model,
esp_ble_mesh_msg_ctx_t *ctx, uint32_t opcode,
uint16_t length, uint8_t *data, int32_t msg_timeout,
bool need_rsp, esp_ble_mesh_dev_role_t device_role)
esp_ble_mesh_msg_ctx_t *ctx,
uint32_t opcode,
uint16_t length, uint8_t *data,
int32_t msg_timeout, bool need_rsp,
esp_ble_mesh_dev_role_t device_role)
{
if (model == NULL || ctx == NULL ||
ctx->net_idx == ESP_BLE_MESH_KEY_UNUSED ||
@ -218,8 +221,8 @@ esp_err_t esp_ble_mesh_model_publish(esp_ble_mesh_model_t *model, uint32_t opcod
}
esp_err_t esp_ble_mesh_server_model_update_state(esp_ble_mesh_model_t *model,
esp_ble_mesh_server_state_type_t type,
esp_ble_mesh_server_state_value_t *value)
esp_ble_mesh_server_state_type_t type,
esp_ble_mesh_server_state_value_t *value)
{
btc_ble_mesh_model_args_t arg = {0};
btc_msg_t msg = {0};
@ -294,7 +297,8 @@ uint16_t esp_ble_mesh_provisioner_get_node_index(const char *name)
return bt_mesh_provisioner_get_node_index(name);
}
esp_err_t esp_ble_mesh_provisioner_store_node_comp_data(uint16_t unicast_addr, uint8_t *data, uint16_t length)
esp_err_t esp_ble_mesh_provisioner_store_node_comp_data(uint16_t unicast_addr,
uint8_t *data, uint16_t length)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
@ -396,7 +400,7 @@ esp_err_t esp_ble_mesh_provisioner_delete_node_with_addr(uint16_t unicast_addr)
}
esp_err_t esp_ble_mesh_provisioner_add_local_app_key(const uint8_t app_key[16],
uint16_t net_idx, uint16_t app_idx)
uint16_t net_idx, uint16_t app_idx)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
@ -419,7 +423,7 @@ esp_err_t esp_ble_mesh_provisioner_add_local_app_key(const uint8_t app_key[16],
}
esp_err_t esp_ble_mesh_provisioner_update_local_app_key(const uint8_t app_key[16],
uint16_t net_idx, uint16_t app_idx)
uint16_t net_idx, uint16_t app_idx)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
@ -447,7 +451,7 @@ const uint8_t *esp_ble_mesh_provisioner_get_local_app_key(uint16_t net_idx, uint
}
esp_err_t esp_ble_mesh_provisioner_bind_app_key_to_local_model(uint16_t element_addr, uint16_t app_idx,
uint16_t model_id, uint16_t company_id)
uint16_t model_id, uint16_t company_id)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};

View file

@ -35,11 +35,29 @@ bool esp_ble_mesh_node_is_provisioned(void)
return bt_mesh_is_provisioned();
}
static bool prov_bearers_valid(esp_ble_mesh_prov_bearer_t bearers)
{
if ((!(bearers & (ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT))) ||
(IS_ENABLED(CONFIG_BLE_MESH_PB_ADV) &&
!IS_ENABLED(CONFIG_BLE_MESH_PB_GATT) &&
!(bearers & ESP_BLE_MESH_PROV_ADV)) ||
(!IS_ENABLED(CONFIG_BLE_MESH_PB_ADV) &&
IS_ENABLED(CONFIG_BLE_MESH_PB_GATT) &&
!(bearers & ESP_BLE_MESH_PROV_GATT))) {
return false;
}
return true;
}
esp_err_t esp_ble_mesh_node_prov_enable(esp_ble_mesh_prov_bearer_t bearers)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (prov_bearers_valid(bearers) == false) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
@ -56,6 +74,10 @@ esp_err_t esp_ble_mesh_node_prov_disable(esp_ble_mesh_prov_bearer_t bearers)
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (prov_bearers_valid(bearers) == false) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
@ -68,7 +90,7 @@ esp_err_t esp_ble_mesh_node_prov_disable(esp_ble_mesh_prov_bearer_t bearers)
}
esp_err_t esp_ble_mesh_node_set_oob_pub_key(uint8_t pub_key_x[32], uint8_t pub_key_y[32],
uint8_t private_key[32])
uint8_t private_key[32])
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
@ -157,7 +179,7 @@ esp_err_t esp_ble_mesh_set_unprovisioned_device_name(const char *name)
#if (CONFIG_BLE_MESH_PROVISIONER)
esp_err_t esp_ble_mesh_provisioner_read_oob_pub_key(uint8_t link_idx, uint8_t pub_key_x[32],
uint8_t pub_key_y[32])
uint8_t pub_key_y[32])
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
@ -232,6 +254,10 @@ esp_err_t esp_ble_mesh_provisioner_prov_enable(esp_ble_mesh_prov_bearer_t bearer
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (prov_bearers_valid(bearers) == false) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
@ -249,6 +275,10 @@ esp_err_t esp_ble_mesh_provisioner_prov_disable(esp_ble_mesh_prov_bearer_t beare
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (prov_bearers_valid(bearers) == false) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
@ -262,7 +292,7 @@ esp_err_t esp_ble_mesh_provisioner_prov_disable(esp_ble_mesh_prov_bearer_t beare
}
esp_err_t esp_ble_mesh_provisioner_add_unprov_dev(esp_ble_mesh_unprov_dev_add_t *add_dev,
esp_ble_mesh_dev_add_flag_t flags)
esp_ble_mesh_dev_add_flag_t flags)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
@ -288,8 +318,10 @@ esp_err_t esp_ble_mesh_provisioner_add_unprov_dev(esp_ble_mesh_unprov_dev_add_t
}
esp_err_t esp_ble_mesh_provisioner_prov_device_with_addr(const uint8_t uuid[16],
esp_ble_mesh_bd_addr_t addr, esp_ble_mesh_addr_type_t addr_type,
esp_ble_mesh_prov_bearer_t bearer, uint16_t oob_info, uint16_t unicast_addr)
esp_ble_mesh_bd_addr_t addr,
esp_ble_mesh_addr_type_t addr_type,
esp_ble_mesh_prov_bearer_t bearer,
uint16_t oob_info, uint16_t unicast_addr)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
@ -347,7 +379,7 @@ esp_err_t esp_ble_mesh_provisioner_delete_dev(esp_ble_mesh_device_delete_t *del_
}
esp_err_t esp_ble_mesh_provisioner_set_dev_uuid_match(const uint8_t *match_val, uint8_t match_len,
uint8_t offset, bool prov_after_match)
uint8_t offset, bool prov_after_match)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};

View file

@ -60,7 +60,8 @@ esp_err_t esp_ble_mesh_proxy_gatt_disable(void)
}
esp_err_t esp_ble_mesh_proxy_client_connect(esp_ble_mesh_bd_addr_t addr,
esp_ble_mesh_addr_type_t addr_type, uint16_t net_idx)
esp_ble_mesh_addr_type_t addr_type,
uint16_t net_idx)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
@ -100,8 +101,8 @@ esp_err_t esp_ble_mesh_proxy_client_disconnect(uint8_t conn_handle)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_proxy_client_set_filter_type(uint8_t conn_handle,
uint16_t net_idx, esp_ble_mesh_proxy_filter_type_t filter_type)
esp_err_t esp_ble_mesh_proxy_client_set_filter_type(uint8_t conn_handle, uint16_t net_idx,
esp_ble_mesh_proxy_filter_type_t filter_type)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
@ -124,8 +125,8 @@ esp_err_t esp_ble_mesh_proxy_client_set_filter_type(uint8_t conn_handle,
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_proxy_client_add_filter_addr(uint8_t conn_handle,
uint16_t net_idx, uint16_t *addr, uint16_t addr_num)
esp_err_t esp_ble_mesh_proxy_client_add_filter_addr(uint8_t conn_handle, uint16_t net_idx,
uint16_t *addr, uint16_t addr_num)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
@ -149,8 +150,8 @@ esp_err_t esp_ble_mesh_proxy_client_add_filter_addr(uint8_t conn_handle,
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_proxy_client_remove_filter_addr(uint8_t conn_handle,
uint16_t net_idx, uint16_t *addr, uint16_t addr_num)
esp_err_t esp_ble_mesh_proxy_client_remove_filter_addr(uint8_t conn_handle, uint16_t net_idx,
uint16_t *addr, uint16_t addr_num)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};

View file

@ -55,7 +55,8 @@ uint16_t esp_ble_mesh_get_primary_element_address(void);
* to 0x0000 in order to unsubscribe the model from the group.
*
*/
uint16_t *esp_ble_mesh_is_model_subscribed_to_group(esp_ble_mesh_model_t *model, uint16_t group_addr);
uint16_t *esp_ble_mesh_is_model_subscribed_to_group(esp_ble_mesh_model_t *model,
uint16_t group_addr);
/**
* @brief Find the BLE Mesh element pointer via the element address.
@ -87,7 +88,7 @@ uint8_t esp_ble_mesh_get_element_count(void);
*
*/
esp_ble_mesh_model_t *esp_ble_mesh_find_vendor_model(const esp_ble_mesh_elem_t *element,
uint16_t company_id, uint16_t model_id);
uint16_t company_id, uint16_t model_id);
/**
* @brief Find the SIG model with the given element and Model id.
@ -98,7 +99,8 @@ esp_ble_mesh_model_t *esp_ble_mesh_find_vendor_model(const esp_ble_mesh_elem_t *
* @return Pointer to the SIG Model on success, or NULL on failure which means the SIG Model is not found.
*
*/
esp_ble_mesh_model_t *esp_ble_mesh_find_sig_model(const esp_ble_mesh_elem_t *element, uint16_t model_id);
esp_ble_mesh_model_t *esp_ble_mesh_find_sig_model(const esp_ble_mesh_elem_t *element,
uint16_t model_id);
/**
* @brief Get the Composition data which has been registered.

View file

@ -23,7 +23,7 @@ extern "C" {
/** @brief: event, event code of user-defined model events; param, parameters of user-defined model events */
typedef void (* esp_ble_mesh_model_cb_t)(esp_ble_mesh_model_cb_event_t event,
esp_ble_mesh_model_cb_param_t *param);
esp_ble_mesh_model_cb_param_t *param);
/**
* @brief Register BLE Mesh callback for user-defined models' operations.
@ -104,8 +104,9 @@ esp_err_t esp_ble_mesh_client_model_deinit(esp_ble_mesh_model_t *model);
*
*/
esp_err_t esp_ble_mesh_server_model_send_msg(esp_ble_mesh_model_t *model,
esp_ble_mesh_msg_ctx_t *ctx, uint32_t opcode,
uint16_t length, uint8_t *data);
esp_ble_mesh_msg_ctx_t *ctx,
uint32_t opcode,
uint16_t length, uint8_t *data);
/**
* @brief Send client model message (such as model get, set, etc).
@ -123,9 +124,11 @@ esp_err_t esp_ble_mesh_server_model_send_msg(esp_ble_mesh_model_t *model,
*
*/
esp_err_t esp_ble_mesh_client_model_send_msg(esp_ble_mesh_model_t *model,
esp_ble_mesh_msg_ctx_t *ctx, uint32_t opcode,
uint16_t length, uint8_t *data, int32_t msg_timeout,
bool need_rsp, esp_ble_mesh_dev_role_t device_role);
esp_ble_mesh_msg_ctx_t *ctx,
uint32_t opcode,
uint16_t length, uint8_t *data,
int32_t msg_timeout, bool need_rsp,
esp_ble_mesh_dev_role_t device_role);
/**
* @brief Send a model publication message.
@ -166,8 +169,8 @@ esp_err_t esp_ble_mesh_model_publish(esp_ble_mesh_model_t *model, uint32_t opcod
*
*/
esp_err_t esp_ble_mesh_server_model_update_state(esp_ble_mesh_model_t *model,
esp_ble_mesh_server_state_type_t type,
esp_ble_mesh_server_state_value_t *value);
esp_ble_mesh_server_state_type_t type,
esp_ble_mesh_server_state_value_t *value);
/**
* @brief Reset the provisioning procedure of the local BLE Mesh node.
@ -226,7 +229,8 @@ uint16_t esp_ble_mesh_provisioner_get_node_index(const char *name);
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_provisioner_store_node_comp_data(uint16_t unicast_addr, uint8_t *data, uint16_t length);
esp_err_t esp_ble_mesh_provisioner_store_node_comp_data(uint16_t unicast_addr,
uint8_t *data, uint16_t length);
/**
* @brief This function is called to get the provisioned node information
@ -329,7 +333,8 @@ esp_err_t esp_ble_mesh_provisioner_delete_node_with_addr(uint16_t unicast_addr);
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_provisioner_add_local_app_key(const uint8_t app_key[16], uint16_t net_idx, uint16_t app_idx);
esp_err_t esp_ble_mesh_provisioner_add_local_app_key(const uint8_t app_key[16],
uint16_t net_idx, uint16_t app_idx);
/**
* @brief This function is used to update a local AppKey for Provisioner.
@ -342,7 +347,7 @@ esp_err_t esp_ble_mesh_provisioner_add_local_app_key(const uint8_t app_key[16],
*
*/
esp_err_t esp_ble_mesh_provisioner_update_local_app_key(const uint8_t app_key[16],
uint16_t net_idx, uint16_t app_idx);
uint16_t net_idx, uint16_t app_idx);
/**
* @brief This function is called by Provisioner to get the local app key value.
@ -370,7 +375,7 @@ const uint8_t *esp_ble_mesh_provisioner_get_local_app_key(uint16_t net_idx, uint
*
*/
esp_err_t esp_ble_mesh_provisioner_bind_app_key_to_local_model(uint16_t element_addr, uint16_t app_idx,
uint16_t model_id, uint16_t company_id);
uint16_t model_id, uint16_t company_id);
/**
* @brief This function is called by Provisioner to add local network key.

View file

@ -76,7 +76,7 @@ esp_err_t esp_ble_mesh_node_prov_disable(esp_ble_mesh_prov_bearer_t bearers);
* @return ESP_OK on success or error code otherwise.
*/
esp_err_t esp_ble_mesh_node_set_oob_pub_key(uint8_t pub_key_x[32], uint8_t pub_key_y[32],
uint8_t private_key[32]);
uint8_t private_key[32]);
/**
* @brief Provide provisioning input OOB number.
@ -128,7 +128,7 @@ esp_err_t esp_ble_mesh_set_unprovisioned_device_name(const char *name);
* @return ESP_OK on success or error code otherwise.
*/
esp_err_t esp_ble_mesh_provisioner_read_oob_pub_key(uint8_t link_idx, uint8_t pub_key_x[32],
uint8_t pub_key_y[32]);
uint8_t pub_key_y[32]);
/**
* @brief Provide provisioning input OOB string.
@ -232,7 +232,7 @@ esp_err_t esp_ble_mesh_provisioner_prov_disable(esp_ble_mesh_prov_bearer_t beare
*
*/
esp_err_t esp_ble_mesh_provisioner_add_unprov_dev(esp_ble_mesh_unprov_dev_add_t *add_dev,
esp_ble_mesh_dev_add_flag_t flags);
esp_ble_mesh_dev_add_flag_t flags);
/** @brief Provision an unprovisioned device with fixed unicast address.
*
@ -257,16 +257,17 @@ esp_err_t esp_ble_mesh_provisioner_add_unprov_dev(esp_ble_mesh_unprov_dev_add_t
* and "esp_ble_mesh_provisioner_prov_device_with_addr" by a Provisioner.
*/
esp_err_t esp_ble_mesh_provisioner_prov_device_with_addr(const uint8_t uuid[16],
esp_ble_mesh_bd_addr_t addr, esp_ble_mesh_addr_type_t addr_type,
esp_ble_mesh_prov_bearer_t bearer, uint16_t oob_info, uint16_t unicast_addr);
esp_ble_mesh_bd_addr_t addr,
esp_ble_mesh_addr_type_t addr_type,
esp_ble_mesh_prov_bearer_t bearer,
uint16_t oob_info, uint16_t unicast_addr);
/**
* @brief Delete device from queue, reset current provisioning link and reset the node.
* @brief Delete device from queue, and reset current provisioning link with the device.
*
* @note If the device is in the queue, remove it from the queue; if the device is being
* provisioned, terminate the provisioning procedure; if the device has already
* been provisioned, reset the device. And either one of the addr or device UUID
* can be input.
* @note If the device is in the queue, remove it from the queue; if the device is
* being provisioned, terminate the provisioning procedure. Either one of the
* device address or device UUID can be used as input.
*
* @param[in] del_dev: Pointer to a struct containing the device information.
*
@ -290,8 +291,8 @@ esp_err_t esp_ble_mesh_provisioner_delete_dev(esp_ble_mesh_device_delete_t *del_
*
*/
typedef void (*esp_ble_mesh_prov_adv_cb_t)(const esp_ble_mesh_bd_addr_t addr, const esp_ble_mesh_addr_type_t addr_type,
const uint8_t adv_type, const uint8_t *dev_uuid,
uint16_t oob_info, esp_ble_mesh_prov_bearer_t bearer);
const uint8_t adv_type, const uint8_t *dev_uuid,
uint16_t oob_info, esp_ble_mesh_prov_bearer_t bearer);
/**
* @brief This function is called by Provisioner to set the part of the device UUID
@ -307,7 +308,7 @@ typedef void (*esp_ble_mesh_prov_adv_cb_t)(const esp_ble_mesh_bd_addr_t addr, co
*
*/
esp_err_t esp_ble_mesh_provisioner_set_dev_uuid_match(const uint8_t *match_val, uint8_t match_len,
uint8_t offset, bool prov_after_match);
uint8_t offset, bool prov_after_match);
/**
* @brief This function is called by Provisioner to set provisioning data information

View file

@ -65,7 +65,8 @@ esp_err_t esp_ble_mesh_proxy_gatt_disable(void);
*
*/
esp_err_t esp_ble_mesh_proxy_client_connect(esp_ble_mesh_bd_addr_t addr,
esp_ble_mesh_addr_type_t addr_type, uint16_t net_idx);
esp_ble_mesh_addr_type_t addr_type,
uint16_t net_idx);
/**
* @brief Proxy Client terminates a connection with the Proxy Server.
@ -87,8 +88,8 @@ esp_err_t esp_ble_mesh_proxy_client_disconnect(uint8_t conn_handle);
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_proxy_client_set_filter_type(uint8_t conn_handle,
uint16_t net_idx, esp_ble_mesh_proxy_filter_type_t filter_type);
esp_err_t esp_ble_mesh_proxy_client_set_filter_type(uint8_t conn_handle, uint16_t net_idx,
esp_ble_mesh_proxy_filter_type_t filter_type);
/**
* @brief Proxy Client adds address to the Proxy Server filter list.
@ -101,8 +102,8 @@ esp_err_t esp_ble_mesh_proxy_client_set_filter_type(uint8_t conn_handle,
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_proxy_client_add_filter_addr(uint8_t conn_handle,
uint16_t net_idx, uint16_t *addr, uint16_t addr_num);
esp_err_t esp_ble_mesh_proxy_client_add_filter_addr(uint8_t conn_handle, uint16_t net_idx,
uint16_t *addr, uint16_t addr_num);
/**
* @brief Proxy Client removes address from the Proxy Server filter list.
@ -115,8 +116,8 @@ esp_err_t esp_ble_mesh_proxy_client_add_filter_addr(uint8_t conn_handle,
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_proxy_client_remove_filter_addr(uint8_t conn_handle,
uint16_t net_idx, uint16_t *addr, uint16_t addr_num);
esp_err_t esp_ble_mesh_proxy_client_remove_filter_addr(uint8_t conn_handle, uint16_t net_idx,
uint16_t *addr, uint16_t addr_num);
#ifdef __cplusplus
}

View file

@ -61,6 +61,12 @@ typedef uint8_t esp_ble_mesh_octet8_t[ESP_BLE_MESH_OCTET8_LEN];
/*!< Invalid Company ID */
#define ESP_BLE_MESH_CID_NVAL 0xFFFF
/*!< Special TTL value to request using configured default TTL */
#define ESP_BLE_MESH_TTL_DEFAULT 0xFF
/*!< Maximum allowed TTL value */
#define ESP_BLE_MESH_TTL_MAX 0x7F
#define ESP_BLE_MESH_ADDR_UNASSIGNED 0x0000
#define ESP_BLE_MESH_ADDR_ALL_NODES 0xFFFF
#define ESP_BLE_MESH_ADDR_PROXIES 0xFFFC
@ -265,7 +271,7 @@ typedef enum {
#define ESP_BLE_MESH_MODEL_OP_2(b0, b1) (((b0) << 8) | (b1))
#define ESP_BLE_MESH_MODEL_OP_3(b0, cid) ((((b0) << 16) | 0xC00000) | (cid))
/*!< This macro is associated with BLE_MESH_MODEL in mesh_access.h */
/*!< This macro is associated with BLE_MESH_MODEL_CB in mesh_access.h */
#define ESP_BLE_MESH_SIG_MODEL(_id, _op, _pub, _user_data) \
{ \
.model_id = (_id), \
@ -278,7 +284,7 @@ typedef enum {
.user_data = _user_data, \
}
/*!< This macro is associated with BLE_MESH_MODEL_VND in mesh_access.h */
/*!< This macro is associated with BLE_MESH_MODEL_VND_CB in mesh_access.h */
#define ESP_BLE_MESH_VENDOR_MODEL(_company, _id, _op, _pub, _user_data) \
{ \
.vnd.company_id = (_company), \
@ -455,6 +461,17 @@ typedef struct {
*/
#define ESP_BLE_MESH_MODEL_OP_END {0, 0, 0}
/** Abstraction that describes a model callback structure.
* This structure is associated with struct bt_mesh_model_cb in mesh_access.h.
*/
typedef struct {
/** Callback used during model initialization. Initialized by the stack. */
esp_ble_mesh_cb_t init_cb;
/** Callback used during model deinitialization. Initialized by the stack. */
esp_ble_mesh_cb_t deinit_cb;
} esp_ble_mesh_model_cbs_t;
/** Abstraction that describes a Mesh Model instance.
* This structure is associated with struct bt_mesh_model in mesh_access.h
*/
@ -488,6 +505,9 @@ struct esp_ble_mesh_model {
/** Model operation context */
esp_ble_mesh_model_op_t *op;
/** Model callback structure */
esp_ble_mesh_model_cbs_t *cb;
/** Model-specific user data */
void *user_data;
};
@ -522,7 +542,7 @@ typedef struct {
/** Force sending reliably by using segment acknowledgement */
uint8_t send_rel: 1;
/** TTL, or BLE_MESH_TTL_DEFAULT for default TTL. */
/** TTL, or ESP_BLE_MESH_TTL_DEFAULT for default TTL. */
uint8_t send_ttl;
/** Opcode of a received message. Not used for sending message. */
@ -809,7 +829,7 @@ typedef enum {
ESP_BLE_MESH_PROVISIONER_PROV_COMPLETE_EVT, /*!< Provisioner provisioning done event */
ESP_BLE_MESH_PROVISIONER_ADD_UNPROV_DEV_COMP_EVT, /*!< Provisioner add a device to the list which contains devices that are waiting/going to be provisioned completion event */
ESP_BLE_MESH_PROVISIONER_PROV_DEV_WITH_ADDR_COMP_EVT, /*!< Provisioner start to provision an unprovisioned device completion event */
ESP_BLE_MESH_PROVISIONER_DELETE_DEV_COMP_EVT, /*!< Provisioner delete a device from the list, close provisioning link with the device if it exists and remove the device from network completion event */
ESP_BLE_MESH_PROVISIONER_DELETE_DEV_COMP_EVT, /*!< Provisioner delete a device from the list, close provisioning link with the device completion event */
ESP_BLE_MESH_PROVISIONER_SET_DEV_UUID_MATCH_COMP_EVT, /*!< Provisioner set the value to be compared with part of the unprovisioned device UUID completion event */
ESP_BLE_MESH_PROVISIONER_SET_PROV_DATA_INFO_COMP_EVT, /*!< Provisioner set net_idx/flags/iv_index used for provisioning completion event */
ESP_BLE_MESH_PROVISIONER_SET_STATIC_OOB_VALUE_COMP_EVT, /*!< Provisioner set static oob value used for provisioning completion event */
@ -1112,6 +1132,7 @@ typedef union {
*/
struct ble_mesh_provisioner_add_local_app_key_comp_param {
int err_code; /*!< Indicate the result of adding local AppKey by the Provisioner */
uint16_t net_idx; /*!< NetKey Index */
uint16_t app_idx; /*!< AppKey Index */
} provisioner_add_app_key_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_ADD_LOCAL_APP_KEY_COMP_EVT */
/**
@ -1156,14 +1177,14 @@ typedef union {
/**
* @brief ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_UUID_COMP_EVT
*/
struct ble_mesh_provisioner_delete_node_with_uuid_comp_data_comp_param {
struct ble_mesh_provisioner_delete_node_with_uuid_comp_param {
int err_code; /*!< Indicate the result of deleting node with uuid by the Provisioner */
uint8_t uuid[16]; /*!< Node device uuid */
} provisioner_delete_node_with_uuid_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_UUID_COMP_EVT */
/**
* @brief ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_ADDR_COMP_EVT
*/
struct ble_mesh_provisioner_delete_node_with_addr_comp_data_comp_param {
struct ble_mesh_provisioner_delete_node_with_addr_comp_param {
int err_code; /*!< Indicate the result of deleting node with unicast address by the Provisioner */
uint16_t unicast_addr; /*!< Node unicast address */
} provisioner_delete_node_with_addr_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_ADDR_COMP_EVT */
@ -1954,8 +1975,8 @@ typedef struct {
int64_t timestamp; /*!< Time when the last message is received */
} esp_ble_mesh_last_msg_info_t;
#define ESP_BLE_MESH_SERVER_RSP_BY_APP 0 /*!< Response will be sent internally */
#define ESP_BLE_MESH_SERVER_AUTO_RSP 1 /*!< Response need to be sent in the application */
#define ESP_BLE_MESH_SERVER_RSP_BY_APP 0 /*!< Response need to be sent in the application */
#define ESP_BLE_MESH_SERVER_AUTO_RSP 1 /*!< Response will be sent internally */
/** Parameters of the Server Model response control */
typedef struct {

View file

@ -53,7 +53,7 @@ static bool config_client_get_need_param(esp_ble_mesh_opcode_t opcode)
}
esp_err_t esp_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_cfg_client_get_state_t *get_state)
esp_ble_mesh_cfg_client_get_state_t *get_state)
{
btc_ble_mesh_config_client_args_t arg = {0};
btc_msg_t msg = {0};
@ -78,7 +78,7 @@ esp_err_t esp_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param_
}
esp_err_t esp_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_cfg_client_set_state_t *set_state)
esp_ble_mesh_cfg_client_set_state_t *set_state)
{
btc_ble_mesh_config_client_args_t arg = {0};
btc_msg_t msg = {0};

View file

@ -40,7 +40,7 @@ static bool generic_client_get_need_param(esp_ble_mesh_opcode_t opcode)
}
esp_err_t esp_ble_mesh_generic_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_generic_client_get_state_t *get_state)
esp_ble_mesh_generic_client_get_state_t *get_state)
{
btc_ble_mesh_generic_client_args_t arg = {0};
btc_msg_t msg = {0};
@ -66,7 +66,7 @@ esp_err_t esp_ble_mesh_generic_client_get_state(esp_ble_mesh_client_common_param
}
esp_err_t esp_ble_mesh_generic_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_generic_client_set_state_t *set_state)
esp_ble_mesh_generic_client_set_state_t *set_state)
{
btc_ble_mesh_generic_client_args_t arg = {0};
btc_msg_t msg = {0};

View file

@ -34,7 +34,7 @@ esp_err_t esp_ble_mesh_register_health_server_callback(esp_ble_mesh_health_serve
}
esp_err_t esp_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_health_client_get_state_t *get_state)
esp_ble_mesh_health_client_get_state_t *get_state)
{
btc_ble_mesh_health_client_args_t arg = {0};
btc_msg_t msg = {0};
@ -60,7 +60,7 @@ esp_err_t esp_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_
}
esp_err_t esp_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_health_client_set_state_t *set_state)
esp_ble_mesh_health_client_set_state_t *set_state)
{
btc_ble_mesh_health_client_args_t arg = {0};
btc_msg_t msg = {0};

View file

@ -27,7 +27,7 @@ esp_err_t esp_ble_mesh_register_light_client_callback(esp_ble_mesh_light_client_
}
esp_err_t esp_ble_mesh_light_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_light_client_get_state_t *get_state)
esp_ble_mesh_light_client_get_state_t *get_state)
{
btc_ble_mesh_lighting_client_args_t arg = {0};
btc_msg_t msg = {0};
@ -53,7 +53,7 @@ esp_err_t esp_ble_mesh_light_client_get_state(esp_ble_mesh_client_common_param_t
}
esp_err_t esp_ble_mesh_light_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_light_client_set_state_t *set_state)
esp_ble_mesh_light_client_set_state_t *set_state)
{
btc_ble_mesh_lighting_client_args_t arg = {0};
btc_msg_t msg = {0};

View file

@ -27,7 +27,7 @@ esp_err_t esp_ble_mesh_register_sensor_client_callback(esp_ble_mesh_sensor_clien
}
esp_err_t esp_ble_mesh_sensor_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_sensor_client_get_state_t *get_state)
esp_ble_mesh_sensor_client_get_state_t *get_state)
{
btc_ble_mesh_sensor_client_args_t arg = {0};
btc_msg_t msg = {0};
@ -52,7 +52,7 @@ esp_err_t esp_ble_mesh_sensor_client_get_state(esp_ble_mesh_client_common_param_
}
esp_err_t esp_ble_mesh_sensor_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_sensor_client_set_state_t *set_state)
esp_ble_mesh_sensor_client_set_state_t *set_state)
{
btc_ble_mesh_sensor_client_args_t arg = {0};
btc_msg_t msg = {0};

View file

@ -27,7 +27,7 @@ esp_err_t esp_ble_mesh_register_time_scene_client_callback(esp_ble_mesh_time_sce
}
esp_err_t esp_ble_mesh_time_scene_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_time_scene_client_get_state_t *get_state)
esp_ble_mesh_time_scene_client_get_state_t *get_state)
{
btc_ble_mesh_time_scene_client_args_t arg = {0};
btc_msg_t msg = {0};
@ -53,7 +53,7 @@ esp_err_t esp_ble_mesh_time_scene_client_get_state(esp_ble_mesh_client_common_pa
}
esp_err_t esp_ble_mesh_time_scene_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_time_scene_client_set_state_t *set_state)
esp_ble_mesh_time_scene_client_set_state_t *set_state)
{
btc_ble_mesh_time_scene_client_args_t arg = {0};
btc_msg_t msg = {0};

View file

@ -756,7 +756,7 @@ typedef enum {
* @param param: Pointer to callback parameter
*/
typedef void (* esp_ble_mesh_cfg_client_cb_t)(esp_ble_mesh_cfg_client_cb_event_t event,
esp_ble_mesh_cfg_client_cb_param_t *param);
esp_ble_mesh_cfg_client_cb_param_t *param);
/**
* @brief Configuration Server Model callback function type
@ -764,7 +764,7 @@ typedef void (* esp_ble_mesh_cfg_client_cb_t)(esp_ble_mesh_cfg_client_cb_event_t
* @param param: Pointer to callback parameter
*/
typedef void (* esp_ble_mesh_cfg_server_cb_t)(esp_ble_mesh_cfg_server_cb_event_t event,
esp_ble_mesh_cfg_server_cb_param_t *param);
esp_ble_mesh_cfg_server_cb_param_t *param);
/**
* @brief Register BLE Mesh Config Client Model callback.
@ -800,7 +800,7 @@ esp_err_t esp_ble_mesh_register_config_server_callback(esp_ble_mesh_cfg_server_c
*
*/
esp_err_t esp_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_cfg_client_get_state_t *get_state);
esp_ble_mesh_cfg_client_get_state_t *get_state);
/**
* @brief Set the value of the Configuration Server Model states using the Config Client Model set messages.
@ -816,7 +816,7 @@ esp_err_t esp_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param_
*
*/
esp_err_t esp_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_cfg_client_set_state_t *set_state);
esp_ble_mesh_cfg_client_set_state_t *set_state);
#ifdef __cplusplus
}

View file

@ -483,7 +483,7 @@ typedef enum {
* @param param: Pointer to callback parameter
*/
typedef void (* esp_ble_mesh_generic_client_cb_t)(esp_ble_mesh_generic_client_cb_event_t event,
esp_ble_mesh_generic_client_cb_param_t *param);
esp_ble_mesh_generic_client_cb_param_t *param);
/**
* @brief Register BLE Mesh Generic Client Model callback.
@ -509,7 +509,7 @@ esp_err_t esp_ble_mesh_register_generic_client_callback(esp_ble_mesh_generic_cli
*
*/
esp_err_t esp_ble_mesh_generic_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_generic_client_get_state_t *get_state);
esp_ble_mesh_generic_client_get_state_t *get_state);
/**
* @brief Set the value of Generic Server Model states using the Generic Client Model set messages.
@ -525,7 +525,7 @@ esp_err_t esp_ble_mesh_generic_client_get_state(esp_ble_mesh_client_common_param
*
*/
esp_err_t esp_ble_mesh_generic_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_generic_client_set_state_t *set_state);
esp_ble_mesh_generic_client_set_state_t *set_state);
/**
* @brief Generic Server Models related context.
@ -1285,7 +1285,7 @@ typedef enum {
* @param param: Pointer to callback parameter
*/
typedef void (* esp_ble_mesh_generic_server_cb_t)(esp_ble_mesh_generic_server_cb_event_t event,
esp_ble_mesh_generic_server_cb_param_t *param);
esp_ble_mesh_generic_server_cb_param_t *param);
/**
* @brief Register BLE Mesh Generic Server Model callback.

View file

@ -335,7 +335,7 @@ typedef enum {
* @param param: Pointer to callback parameter
*/
typedef void (* esp_ble_mesh_health_client_cb_t)(esp_ble_mesh_health_client_cb_event_t event,
esp_ble_mesh_health_client_cb_param_t *param);
esp_ble_mesh_health_client_cb_param_t *param);
/**
* @brief Health Server Model callback function type
@ -343,7 +343,7 @@ typedef void (* esp_ble_mesh_health_client_cb_t)(esp_ble_mesh_health_client_cb_e
* @param param: Pointer to callback parameter
*/
typedef void (* esp_ble_mesh_health_server_cb_t)(esp_ble_mesh_health_server_cb_event_t event,
esp_ble_mesh_health_server_cb_param_t *param);
esp_ble_mesh_health_server_cb_param_t *param);
/**
* @brief Register BLE Mesh Health Model callback, the callback will report Health Client & Server Model events.
@ -379,7 +379,7 @@ esp_err_t esp_ble_mesh_register_health_server_callback(esp_ble_mesh_health_serve
*
*/
esp_err_t esp_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_health_client_get_state_t *get_state);
esp_ble_mesh_health_client_get_state_t *get_state);
/**
* @brief This function is called to set the Health Server states using the Health Client Model set messages.
@ -395,7 +395,7 @@ esp_err_t esp_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_
*
*/
esp_err_t esp_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_health_client_set_state_t *set_state);
esp_ble_mesh_health_client_set_state_t *set_state);
/**
* @brief This function is called by the Health Server Model to update the context of its Health Current status.

View file

@ -539,7 +539,7 @@ typedef enum {
* @param param: Pointer to callback parameter
*/
typedef void (* esp_ble_mesh_light_client_cb_t)(esp_ble_mesh_light_client_cb_event_t event,
esp_ble_mesh_light_client_cb_param_t *param);
esp_ble_mesh_light_client_cb_param_t *param);
/**
* @brief Register BLE Mesh Light Client Model callback.
@ -565,7 +565,7 @@ esp_err_t esp_ble_mesh_register_light_client_callback(esp_ble_mesh_light_client_
*
*/
esp_err_t esp_ble_mesh_light_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_light_client_get_state_t *get_state);
esp_ble_mesh_light_client_get_state_t *get_state);
/**
* @brief Set the value of Light Server Model states using the Light Client Model set messages.
@ -581,7 +581,7 @@ esp_err_t esp_ble_mesh_light_client_get_state(esp_ble_mesh_client_common_param_t
*
*/
esp_err_t esp_ble_mesh_light_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_light_client_set_state_t *set_state);
esp_ble_mesh_light_client_set_state_t *set_state);
/**
* @brief Lighting Server Models related context.
@ -1663,7 +1663,7 @@ typedef enum {
* @param param: Pointer to callback parameter
*/
typedef void (* esp_ble_mesh_lighting_server_cb_t)(esp_ble_mesh_lighting_server_cb_event_t event,
esp_ble_mesh_lighting_server_cb_param_t *param);
esp_ble_mesh_lighting_server_cb_param_t *param);
/**
* @brief Register BLE Mesh Lighting Server Model callback.

View file

@ -215,7 +215,7 @@ typedef enum {
* @param param: Pointer to callback parameter
*/
typedef void (* esp_ble_mesh_sensor_client_cb_t)(esp_ble_mesh_sensor_client_cb_event_t event,
esp_ble_mesh_sensor_client_cb_param_t *param);
esp_ble_mesh_sensor_client_cb_param_t *param);
/**
* @brief Register BLE Mesh Sensor Client Model callback.
@ -241,7 +241,7 @@ esp_err_t esp_ble_mesh_register_sensor_client_callback(esp_ble_mesh_sensor_clien
*
*/
esp_err_t esp_ble_mesh_sensor_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_sensor_client_get_state_t *get_state);
esp_ble_mesh_sensor_client_get_state_t *get_state);
/**
* @brief Set the value of Sensor Server Model states using the Sensor Client Model set messages.
@ -257,7 +257,7 @@ esp_err_t esp_ble_mesh_sensor_client_get_state(esp_ble_mesh_client_common_param_
*
*/
esp_err_t esp_ble_mesh_sensor_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_sensor_client_set_state_t *set_state);
esp_ble_mesh_sensor_client_set_state_t *set_state);
/**
* @brief Sensor Server Models related context.
@ -698,7 +698,7 @@ typedef enum {
* @param param: Pointer to callback parameter
*/
typedef void (* esp_ble_mesh_sensor_server_cb_t)(esp_ble_mesh_sensor_server_cb_event_t event,
esp_ble_mesh_sensor_server_cb_param_t *param);
esp_ble_mesh_sensor_server_cb_param_t *param);
/**
* @brief Register BLE Mesh Sensor Server Model callback.

View file

@ -276,7 +276,7 @@ typedef enum {
* @param param: Pointer to callback parameter
*/
typedef void (* esp_ble_mesh_time_scene_client_cb_t)(esp_ble_mesh_time_scene_client_cb_event_t event,
esp_ble_mesh_time_scene_client_cb_param_t *param);
esp_ble_mesh_time_scene_client_cb_param_t *param);
/**
* @brief Register BLE Mesh Time Scene Client Model callback.
@ -301,7 +301,7 @@ esp_err_t esp_ble_mesh_register_time_scene_client_callback(esp_ble_mesh_time_sce
* @return ESP_OK on success or error code otherwise.
*/
esp_err_t esp_ble_mesh_time_scene_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_time_scene_client_get_state_t *get_state);
esp_ble_mesh_time_scene_client_get_state_t *get_state);
/**
* @brief Set the value of Time Scene Server Model states using the Time Scene Client Model set messages.
@ -316,7 +316,7 @@ esp_err_t esp_ble_mesh_time_scene_client_get_state(esp_ble_mesh_client_common_pa
* @return ESP_OK on success or error code otherwise.
*/
esp_err_t esp_ble_mesh_time_scene_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_time_scene_client_set_state_t *set_state);
esp_ble_mesh_time_scene_client_set_state_t *set_state);
/**
* @brief Time Scene Server Models related context.
@ -900,7 +900,7 @@ typedef enum {
* @param param: Pointer to callback parameter
*/
typedef void (* esp_ble_mesh_time_scene_server_cb_t)(esp_ble_mesh_time_scene_server_cb_event_t event,
esp_ble_mesh_time_scene_server_cb_param_t *param);
esp_ble_mesh_time_scene_server_cb_param_t *param);
/**
* @brief Register BLE Mesh Time and Scenes Server Model callback.

View file

@ -20,12 +20,10 @@
#include "cfg_cli.h"
#include "esp_ble_mesh_config_model_api.h"
extern s32_t config_msg_timeout;
/* Configuration Client Model related functions */
static inline void btc_ble_mesh_config_client_cb_to_app(esp_ble_mesh_cfg_client_cb_event_t event,
esp_ble_mesh_cfg_client_cb_param_t *param)
esp_ble_mesh_cfg_client_cb_param_t *param)
{
esp_ble_mesh_cfg_client_cb_t btc_ble_mesh_cb =
(esp_ble_mesh_cfg_client_cb_t)btc_profile_cb_get(BTC_PID_CONFIG_CLIENT);
@ -51,7 +49,7 @@ void btc_ble_mesh_config_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
memcpy(dst->cfg_client_get_state.params, src->cfg_client_get_state.params,
sizeof(esp_ble_mesh_client_common_param_t));
} else {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
break;
}
if (src->cfg_client_get_state.get_state) {
@ -60,7 +58,7 @@ void btc_ble_mesh_config_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
memcpy(dst->cfg_client_get_state.get_state, src->cfg_client_get_state.get_state,
sizeof(esp_ble_mesh_cfg_client_get_state_t));
} else {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
}
}
break;
@ -71,7 +69,7 @@ void btc_ble_mesh_config_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
memcpy(dst->cfg_client_set_state.params, src->cfg_client_set_state.params,
sizeof(esp_ble_mesh_client_common_param_t));
} else {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
break;
}
if (src->cfg_client_set_state.set_state) {
@ -80,13 +78,13 @@ void btc_ble_mesh_config_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
memcpy(dst->cfg_client_set_state.set_state, src->cfg_client_set_state.set_state,
sizeof(esp_ble_mesh_cfg_client_set_state_t));
} else {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
}
}
break;
}
default:
BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act);
BT_DBG("%s, Unknown act %d", __func__, msg->act);
break;
}
}
@ -138,7 +136,7 @@ static void btc_ble_mesh_config_client_copy_req_data(btc_msg_t *msg, void *p_des
if (p_src_data->params) {
p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (!p_dest_data->params) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
@ -157,7 +155,7 @@ static void btc_ble_mesh_config_client_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->status_cb.comp_data_status.composition_data->len;
p_dest_data->status_cb.comp_data_status.composition_data = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.comp_data_status.composition_data) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.comp_data_status.composition_data,
@ -173,7 +171,7 @@ static void btc_ble_mesh_config_client_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->status_cb.model_sub_list.sub_addr->len;
p_dest_data->status_cb.model_sub_list.sub_addr = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.model_sub_list.sub_addr) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.model_sub_list.sub_addr,
@ -187,7 +185,7 @@ static void btc_ble_mesh_config_client_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->status_cb.netkey_list.net_idx->len;
p_dest_data->status_cb.netkey_list.net_idx = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.netkey_list.net_idx) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.netkey_list.net_idx,
@ -201,7 +199,7 @@ static void btc_ble_mesh_config_client_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->status_cb.appkey_list.app_idx->len;
p_dest_data->status_cb.appkey_list.app_idx = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.appkey_list.app_idx) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.appkey_list.app_idx,
@ -217,7 +215,7 @@ static void btc_ble_mesh_config_client_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->status_cb.model_app_list.app_idx->len;
p_dest_data->status_cb.model_app_list.app_idx = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.model_app_list.app_idx) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.model_app_list.app_idx,
@ -306,18 +304,17 @@ static void btc_ble_mesh_config_client_callback(esp_ble_mesh_cfg_client_cb_param
msg.pid = BTC_PID_CONFIG_CLIENT;
msg.act = act;
btc_transfer_context(&msg, cb_params,
sizeof(esp_ble_mesh_cfg_client_cb_param_t), btc_ble_mesh_config_client_copy_req_data);
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_cfg_client_cb_param_t),
btc_ble_mesh_config_client_copy_req_data);
}
void bt_mesh_config_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len)
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len)
{
esp_ble_mesh_cfg_client_cb_param_t cb_params = {0};
esp_ble_mesh_client_common_param_t params = {0};
size_t length = 0U;
uint8_t act = 0U;
if (!model || !ctx) {
@ -339,7 +336,7 @@ void bt_mesh_config_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
act = ESP_BLE_MESH_CFG_CLIENT_TIMEOUT_EVT;
break;
default:
BT_ERR("%s, Unknown config client event type %d", __func__, evt_type);
BT_ERR("Unknown Config client event type %d", evt_type);
return;
}
@ -352,38 +349,37 @@ void bt_mesh_config_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
params.ctx.recv_op = ctx->recv_op;
params.ctx.recv_dst = ctx->recv_dst;
params.ctx.recv_rssi = ctx->recv_rssi;
params.ctx.send_ttl = ctx->send_ttl;
cb_params.error_code = 0;
cb_params.params = &params;
if (val && len) {
length = (len <= sizeof(cb_params.status_cb)) ? len : sizeof(cb_params.status_cb);
memcpy(&cb_params.status_cb, val, length);
memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb)));
}
btc_ble_mesh_config_client_callback(&cb_params, act);
return;
}
void btc_ble_mesh_config_client_publish_callback(u32_t opcode,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
void btc_ble_mesh_config_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
if (!model || !ctx || !buf) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
bt_mesh_config_client_cb_evt_to_btc(opcode,
BTC_BLE_MESH_EVT_CONFIG_CLIENT_PUBLISH, model, ctx, buf->data, buf->len);
bt_mesh_config_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_CONFIG_CLIENT_PUBLISH,
model, ctx, buf->data, buf->len);
return;
}
static int btc_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_cfg_client_get_state_t *get)
{
struct bt_mesh_msg_ctx ctx = {0};
bt_mesh_client_common_param_t param = {0};
if (params == NULL) {
BT_ERR("%s, Invalid parameter", __func__);
@ -402,7 +398,7 @@ static int btc_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param
case ESP_BLE_MESH_MODEL_OP_KEY_REFRESH_PHASE_GET:
case ESP_BLE_MESH_MODEL_OP_LPN_POLLTIMEOUT_GET:
if (get == NULL) {
BT_ERR("%s, Invalid config client get", __func__);
BT_ERR("Invalid Configuration Get");
return -EINVAL;
}
break;
@ -410,63 +406,65 @@ static int btc_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param
break;
}
ctx.net_idx = params->ctx.net_idx;
ctx.app_idx = BLE_MESH_KEY_DEV;
ctx.addr = params->ctx.addr;
ctx.send_rel = params->ctx.send_rel;
ctx.send_ttl = params->ctx.send_ttl;
param.opcode = params->opcode;
param.model = (struct bt_mesh_model *)params->model;
param.ctx.net_idx = params->ctx.net_idx;
param.ctx.app_idx = BLE_MESH_KEY_DEV;
param.ctx.addr = params->ctx.addr;
param.ctx.send_rel = params->ctx.send_rel;
param.ctx.send_ttl = params->ctx.send_ttl;
param.msg_timeout = params->msg_timeout;
param.msg_role = params->msg_role;
config_msg_timeout = params->msg_timeout;
switch (params->opcode) {
switch (param.opcode) {
case ESP_BLE_MESH_MODEL_OP_BEACON_GET:
return bt_mesh_cfg_beacon_get(&ctx);
return bt_mesh_cfg_beacon_get(&param);
case ESP_BLE_MESH_MODEL_OP_DEFAULT_TTL_GET:
return bt_mesh_cfg_ttl_get(&ctx);
return bt_mesh_cfg_ttl_get(&param);
case ESP_BLE_MESH_MODEL_OP_FRIEND_GET:
return bt_mesh_cfg_friend_get(&ctx);
return bt_mesh_cfg_friend_get(&param);
case ESP_BLE_MESH_MODEL_OP_GATT_PROXY_GET:
return bt_mesh_cfg_gatt_proxy_get(&ctx);
return bt_mesh_cfg_gatt_proxy_get(&param);
case ESP_BLE_MESH_MODEL_OP_RELAY_GET:
return bt_mesh_cfg_relay_get(&ctx);
return bt_mesh_cfg_relay_get(&param);
case ESP_BLE_MESH_MODEL_OP_MODEL_PUB_GET:
return bt_mesh_cfg_mod_pub_get(&ctx, get->model_pub_get.element_addr,
return bt_mesh_cfg_mod_pub_get(&param, get->model_pub_get.element_addr,
get->model_pub_get.model_id,
get->model_pub_get.company_id);
case ESP_BLE_MESH_MODEL_OP_HEARTBEAT_PUB_GET:
return bt_mesh_cfg_hb_pub_get(&ctx);
return bt_mesh_cfg_hb_pub_get(&param);
case ESP_BLE_MESH_MODEL_OP_HEARTBEAT_SUB_GET:
return bt_mesh_cfg_hb_sub_get(&ctx);
return bt_mesh_cfg_hb_sub_get(&param);
case ESP_BLE_MESH_MODEL_OP_COMPOSITION_DATA_GET:
return bt_mesh_cfg_comp_data_get(&ctx, get->comp_data_get.page);
return bt_mesh_cfg_comp_data_get(&param, get->comp_data_get.page);
case ESP_BLE_MESH_MODEL_OP_SIG_MODEL_SUB_GET:
return bt_mesh_cfg_mod_sub_get(&ctx, get->sig_model_sub_get.element_addr,
return bt_mesh_cfg_mod_sub_get(&param, get->sig_model_sub_get.element_addr,
get->sig_model_sub_get.model_id);
case ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_SUB_GET:
return bt_mesh_cfg_mod_sub_get_vnd(&ctx, get->vnd_model_sub_get.element_addr,
return bt_mesh_cfg_mod_sub_get_vnd(&param, get->vnd_model_sub_get.element_addr,
get->vnd_model_sub_get.model_id,
get->vnd_model_sub_get.company_id);
case ESP_BLE_MESH_MODEL_OP_NET_KEY_GET:
return bt_mesh_cfg_net_key_get(&ctx);
return bt_mesh_cfg_net_key_get(&param);
case ESP_BLE_MESH_MODEL_OP_APP_KEY_GET:
return bt_mesh_cfg_app_key_get(&ctx, get->app_key_get.net_idx);
return bt_mesh_cfg_app_key_get(&param, get->app_key_get.net_idx);
case ESP_BLE_MESH_MODEL_OP_NODE_IDENTITY_GET:
return bt_mesh_cfg_node_identity_get(&ctx, get->node_identity_get.net_idx);
return bt_mesh_cfg_node_identity_get(&param, get->node_identity_get.net_idx);
case ESP_BLE_MESH_MODEL_OP_SIG_MODEL_APP_GET:
return bt_mesh_cfg_mod_app_get(&ctx, get->sig_model_app_get.element_addr,
return bt_mesh_cfg_mod_app_get(&param, get->sig_model_app_get.element_addr,
get->sig_model_app_get.model_id);
case ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_APP_GET:
return bt_mesh_cfg_mod_app_get_vnd(&ctx, get->vnd_model_app_get.element_addr,
return bt_mesh_cfg_mod_app_get_vnd(&param, get->vnd_model_app_get.element_addr,
get->vnd_model_app_get.model_id,
get->vnd_model_app_get.company_id);
case ESP_BLE_MESH_MODEL_OP_KEY_REFRESH_PHASE_GET:
return bt_mesh_cfg_kr_phase_get(&ctx, get->kr_phase_get.net_idx);
return bt_mesh_cfg_kr_phase_get(&param, get->kr_phase_get.net_idx);
case ESP_BLE_MESH_MODEL_OP_LPN_POLLTIMEOUT_GET:
return bt_mesh_cfg_lpn_timeout_get(&ctx, get->lpn_pollto_get.lpn_addr);
return bt_mesh_cfg_lpn_timeout_get(&param, get->lpn_pollto_get.lpn_addr);
case ESP_BLE_MESH_MODEL_OP_NETWORK_TRANSMIT_GET:
return bt_mesh_cfg_net_transmit_get(&ctx);
return bt_mesh_cfg_net_transmit_get(&param);
default:
BT_ERR("%s, Invalid opcode 0x%x", __func__, params->opcode);
BT_ERR("Invalid Configuration Get opcode 0x%04x", param.opcode);
return -EINVAL;
}
@ -476,7 +474,7 @@ static int btc_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param
static int btc_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_cfg_client_set_state_t *set)
{
struct bt_mesh_msg_ctx ctx = {0};
bt_mesh_client_common_param_t param = {0};
if (params == NULL) {
BT_ERR("%s, Invalid parameter", __func__);
@ -484,39 +482,41 @@ static int btc_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param
}
if (params->opcode != ESP_BLE_MESH_MODEL_OP_NODE_RESET && set == NULL) {
BT_ERR("%s, Invalid config client set", __func__);
BT_ERR("Invalid Configuration Set");
return -EINVAL;
}
ctx.net_idx = params->ctx.net_idx;
ctx.app_idx = BLE_MESH_KEY_DEV;
ctx.addr = params->ctx.addr;
ctx.send_rel = params->ctx.send_rel;
ctx.send_ttl = params->ctx.send_ttl;
param.opcode = params->opcode;
param.model = (struct bt_mesh_model *)params->model;
param.ctx.net_idx = params->ctx.net_idx;
param.ctx.app_idx = BLE_MESH_KEY_DEV;
param.ctx.addr = params->ctx.addr;
param.ctx.send_rel = params->ctx.send_rel;
param.ctx.send_ttl = params->ctx.send_ttl;
param.msg_timeout = params->msg_timeout;
param.msg_role = params->msg_role;
config_msg_timeout = params->msg_timeout;
switch (params->opcode) {
switch (param.opcode) {
case ESP_BLE_MESH_MODEL_OP_BEACON_SET:
return bt_mesh_cfg_beacon_set(&ctx, set->beacon_set.beacon);
return bt_mesh_cfg_beacon_set(&param, set->beacon_set.beacon);
case ESP_BLE_MESH_MODEL_OP_DEFAULT_TTL_SET:
return bt_mesh_cfg_ttl_set(&ctx, set->default_ttl_set.ttl);
return bt_mesh_cfg_ttl_set(&param, set->default_ttl_set.ttl);
case ESP_BLE_MESH_MODEL_OP_FRIEND_SET:
return bt_mesh_cfg_friend_set(&ctx, set->friend_set.friend_state);
return bt_mesh_cfg_friend_set(&param, set->friend_set.friend_state);
case ESP_BLE_MESH_MODEL_OP_GATT_PROXY_SET:
return bt_mesh_cfg_gatt_proxy_set(&ctx, set->gatt_proxy_set.gatt_proxy);
return bt_mesh_cfg_gatt_proxy_set(&param, set->gatt_proxy_set.gatt_proxy);
case ESP_BLE_MESH_MODEL_OP_RELAY_SET:
return bt_mesh_cfg_relay_set(&ctx, set->relay_set.relay,
return bt_mesh_cfg_relay_set(&param, set->relay_set.relay,
set->relay_set.relay_retransmit);
case ESP_BLE_MESH_MODEL_OP_NET_KEY_ADD:
return bt_mesh_cfg_net_key_add(&ctx, set->net_key_add.net_idx,
return bt_mesh_cfg_net_key_add(&param, set->net_key_add.net_idx,
&set->net_key_add.net_key[0]);
case ESP_BLE_MESH_MODEL_OP_APP_KEY_ADD:
return bt_mesh_cfg_app_key_add(&ctx, set->app_key_add.net_idx,
return bt_mesh_cfg_app_key_add(&param, set->app_key_add.net_idx,
set->app_key_add.app_idx,
&set->app_key_add.app_key[0]);
case ESP_BLE_MESH_MODEL_OP_MODEL_APP_BIND:
return bt_mesh_cfg_mod_app_bind(&ctx, set->model_app_bind.element_addr,
return bt_mesh_cfg_mod_app_bind(&param, set->model_app_bind.element_addr,
set->model_app_bind.model_app_idx,
set->model_app_bind.model_id,
set->model_app_bind.company_id);
@ -529,46 +529,46 @@ static int btc_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param
.period = set->model_pub_set.publish_period,
.transmit = set->model_pub_set.publish_retransmit,
};
return bt_mesh_cfg_mod_pub_set(&ctx, set->model_pub_set.element_addr,
return bt_mesh_cfg_mod_pub_set(&param, set->model_pub_set.element_addr,
set->model_pub_set.model_id,
set->model_pub_set.company_id, &model_pub);
}
case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_ADD:
return bt_mesh_cfg_mod_sub_add(&ctx, set->model_sub_add.element_addr,
return bt_mesh_cfg_mod_sub_add(&param, set->model_sub_add.element_addr,
set->model_sub_add.sub_addr,
set->model_sub_add.model_id,
set->model_sub_add.company_id);
case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_DELETE:
return bt_mesh_cfg_mod_sub_del(&ctx, set->model_sub_delete.element_addr,
return bt_mesh_cfg_mod_sub_del(&param, set->model_sub_delete.element_addr,
set->model_sub_delete.sub_addr,
set->model_sub_delete.model_id,
set->model_sub_delete.company_id);
case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_OVERWRITE:
return bt_mesh_cfg_mod_sub_overwrite(&ctx, set->model_sub_overwrite.element_addr,
return bt_mesh_cfg_mod_sub_overwrite(&param, set->model_sub_overwrite.element_addr,
set->model_sub_overwrite.sub_addr,
set->model_sub_overwrite.model_id,
set->model_sub_overwrite.company_id);
case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_ADD:
return bt_mesh_cfg_mod_sub_va_add(&ctx, set->model_sub_va_add.element_addr,
return bt_mesh_cfg_mod_sub_va_add(&param, set->model_sub_va_add.element_addr,
&set->model_sub_va_add.label_uuid[0],
set->model_sub_va_add.model_id,
set->model_sub_va_add.company_id);
case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_OVERWRITE:
return bt_mesh_cfg_mod_sub_va_overwrite(&ctx, set->model_sub_va_overwrite.element_addr,
return bt_mesh_cfg_mod_sub_va_overwrite(&param, set->model_sub_va_overwrite.element_addr,
&set->model_sub_va_overwrite.label_uuid[0],
set->model_sub_va_overwrite.model_id,
set->model_sub_va_overwrite.company_id);
case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_DELETE:
return bt_mesh_cfg_mod_sub_va_del(&ctx, set->model_sub_va_delete.element_addr,
return bt_mesh_cfg_mod_sub_va_del(&param, set->model_sub_va_delete.element_addr,
&set->model_sub_va_delete.label_uuid[0],
set->model_sub_va_delete.model_id,
set->model_sub_va_delete.company_id);
case ESP_BLE_MESH_MODEL_OP_HEARTBEAT_SUB_SET:
return bt_mesh_cfg_hb_sub_set(&ctx, (struct bt_mesh_cfg_hb_sub *)&set->heartbeat_sub_set);
return bt_mesh_cfg_hb_sub_set(&param, (struct bt_mesh_cfg_hb_sub *)&set->heartbeat_sub_set);
case ESP_BLE_MESH_MODEL_OP_HEARTBEAT_PUB_SET:
return bt_mesh_cfg_hb_pub_set(&ctx, (const struct bt_mesh_cfg_hb_pub *)&set->heartbeat_pub_set);
return bt_mesh_cfg_hb_pub_set(&param, (struct bt_mesh_cfg_hb_pub *)&set->heartbeat_pub_set);
case ESP_BLE_MESH_MODEL_OP_NODE_RESET:
return bt_mesh_cfg_node_reset(&ctx);
return bt_mesh_cfg_node_reset(&param);
case ESP_BLE_MESH_MODEL_OP_MODEL_PUB_VIRTUAL_ADDR_SET: {
struct bt_mesh_cfg_mod_pub model_pub = {
.app_idx = set->model_pub_va_set.publish_app_idx,
@ -577,42 +577,42 @@ static int btc_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param
.period = set->model_pub_va_set.publish_period,
.transmit = set->model_pub_va_set.publish_retransmit,
};
return bt_mesh_cfg_mod_pub_va_set(&ctx, set->model_pub_va_set.element_addr,
return bt_mesh_cfg_mod_pub_va_set(&param, set->model_pub_va_set.element_addr,
set->model_pub_va_set.model_id,
set->model_pub_va_set.company_id,
set->model_pub_va_set.label_uuid, &model_pub);
}
case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_DELETE_ALL:
return bt_mesh_cfg_mod_sub_del_all(&ctx, set->model_sub_delete_all.element_addr,
return bt_mesh_cfg_mod_sub_del_all(&param, set->model_sub_delete_all.element_addr,
set->model_sub_delete_all.model_id,
set->model_sub_delete_all.company_id);
case ESP_BLE_MESH_MODEL_OP_NET_KEY_UPDATE:
return bt_mesh_cfg_net_key_update(&ctx, set->net_key_update.net_idx,
return bt_mesh_cfg_net_key_update(&param, set->net_key_update.net_idx,
set->net_key_update.net_key);
case ESP_BLE_MESH_MODEL_OP_NET_KEY_DELETE:
return bt_mesh_cfg_net_key_delete(&ctx, set->net_key_delete.net_idx);
return bt_mesh_cfg_net_key_delete(&param, set->net_key_delete.net_idx);
case ESP_BLE_MESH_MODEL_OP_APP_KEY_UPDATE:
return bt_mesh_cfg_app_key_update(&ctx, set->app_key_update.net_idx,
return bt_mesh_cfg_app_key_update(&param, set->app_key_update.net_idx,
set->app_key_update.app_idx,
set->app_key_update.app_key);
case ESP_BLE_MESH_MODEL_OP_APP_KEY_DELETE:
return bt_mesh_cfg_app_key_delete(&ctx, set->app_key_delete.net_idx,
return bt_mesh_cfg_app_key_delete(&param, set->app_key_delete.net_idx,
set->app_key_delete.app_idx);
case ESP_BLE_MESH_MODEL_OP_NODE_IDENTITY_SET:
return bt_mesh_cfg_node_identity_set(&ctx, set->node_identity_set.net_idx,
return bt_mesh_cfg_node_identity_set(&param, set->node_identity_set.net_idx,
set->node_identity_set.identity);
case ESP_BLE_MESH_MODEL_OP_MODEL_APP_UNBIND:
return bt_mesh_cfg_mod_app_unbind(&ctx, set->model_app_unbind.element_addr,
return bt_mesh_cfg_mod_app_unbind(&param, set->model_app_unbind.element_addr,
set->model_app_unbind.model_app_idx,
set->model_app_unbind.model_id,
set->model_app_unbind.company_id);
case ESP_BLE_MESH_MODEL_OP_KEY_REFRESH_PHASE_SET:
return bt_mesh_cfg_kr_phase_set(&ctx, set->kr_phase_set.net_idx,
return bt_mesh_cfg_kr_phase_set(&param, set->kr_phase_set.net_idx,
set->kr_phase_set.transition);
case ESP_BLE_MESH_MODEL_OP_NETWORK_TRANSMIT_SET:
return bt_mesh_cfg_net_transmit_set(&ctx, set->net_transmit_set.net_transmit);
return bt_mesh_cfg_net_transmit_set(&param, set->net_transmit_set.net_transmit);
default:
BT_ERR("%s, Invalid opcode 0x%x", __func__, params->opcode);
BT_ERR("Invalid Configuration Set opcode 0x%04x", param.opcode);
return -EINVAL;
}
@ -623,7 +623,6 @@ void btc_ble_mesh_config_client_call_handler(btc_msg_t *msg)
{
btc_ble_mesh_config_client_args_t *arg = NULL;
esp_ble_mesh_cfg_client_cb_param_t cb = {0};
bt_mesh_role_param_t role_param = {0};
if (!msg || !msg->arg) {
BT_ERR("%s, Invalid parameter", __func__);
@ -635,12 +634,6 @@ void btc_ble_mesh_config_client_call_handler(btc_msg_t *msg)
switch (msg->act) {
case BTC_BLE_MESH_ACT_CONFIG_CLIENT_GET_STATE: {
cb.params = arg->cfg_client_get_state.params;
role_param.model = (struct bt_mesh_model *)cb.params->model;
role_param.role = cb.params->msg_role;
if (bt_mesh_set_client_model_role(&role_param)) {
BT_ERR("%s, Failed to set model role", __func__);
break;
}
cb.error_code = btc_ble_mesh_config_client_get_state(arg->cfg_client_get_state.params,
arg->cfg_client_get_state.get_state);
if (cb.error_code) {
@ -650,12 +643,6 @@ void btc_ble_mesh_config_client_call_handler(btc_msg_t *msg)
}
case BTC_BLE_MESH_ACT_CONFIG_CLIENT_SET_STATE: {
cb.params = arg->cfg_client_set_state.params;
role_param.model = (struct bt_mesh_model *)cb.params->model;
role_param.role = cb.params->msg_role;
if (bt_mesh_set_client_model_role(&role_param)) {
BT_ERR("%s, Failed to set model role", __func__);
break;
}
cb.error_code = btc_ble_mesh_config_client_set_state(arg->cfg_client_set_state.params,
arg->cfg_client_set_state.set_state);
if (cb.error_code) {
@ -685,7 +672,7 @@ void btc_ble_mesh_config_client_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_CFG_CLIENT_EVT_MAX) {
btc_ble_mesh_config_client_cb_to_app(msg->act, param);
} else {
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
BT_ERR("%s, Unknown act %d", __func__, msg->act);
}
btc_ble_mesh_config_client_free_req_data(msg);
@ -695,7 +682,7 @@ void btc_ble_mesh_config_client_cb_handler(btc_msg_t *msg)
/* Configuration Server Model related functions */
static inline void btc_ble_mesh_config_server_cb_to_app(esp_ble_mesh_cfg_server_cb_event_t event,
esp_ble_mesh_cfg_server_cb_param_t *param)
esp_ble_mesh_cfg_server_cb_param_t *param)
{
esp_ble_mesh_cfg_server_cb_t btc_ble_mesh_cb =
(esp_ble_mesh_cfg_server_cb_t)btc_profile_cb_get(BTC_PID_CONFIG_SERVER);
@ -722,13 +709,11 @@ static void btc_ble_mesh_config_server_callback(esp_ble_mesh_cfg_server_cb_param
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_cfg_server_cb_param_t), NULL);
}
void bt_mesh_config_server_cb_evt_to_btc(u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len)
void bt_mesh_config_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len)
{
esp_ble_mesh_cfg_server_cb_param_t cb_params = {0};
size_t length = 0U;
uint8_t act = 0U;
if (!model || !ctx) {
@ -741,7 +726,7 @@ void bt_mesh_config_server_cb_evt_to_btc(u8_t evt_type,
act = ESP_BLE_MESH_CFG_SERVER_STATE_CHANGE_EVT;
break;
default:
BT_ERR("%s, Unknown config server event type %d", __func__, evt_type);
BT_ERR("Unknown Config server event type %d", evt_type);
return;
}
@ -753,10 +738,10 @@ void bt_mesh_config_server_cb_evt_to_btc(u8_t evt_type,
cb_params.ctx.recv_op = ctx->recv_op;
cb_params.ctx.recv_dst = ctx->recv_dst;
cb_params.ctx.recv_rssi = ctx->recv_rssi;
cb_params.ctx.send_ttl = ctx->send_ttl;
if (val && len) {
length = (len <= sizeof(cb_params.value)) ? len : sizeof(cb_params.value);
memcpy(&cb_params.value, val, length);
memcpy(&cb_params.value, val, MIN(len, sizeof(cb_params.value)));
}
btc_ble_mesh_config_server_callback(&cb_params, act);
@ -777,6 +762,6 @@ void btc_ble_mesh_config_server_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_CFG_SERVER_EVT_MAX) {
btc_ble_mesh_config_server_cb_to_app(msg->act, param);
} else {
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
BT_ERR("%s, Unknown act %d", __func__, msg->act);
}
}

View file

@ -22,7 +22,7 @@
/* Generic Client Models related functions */
static inline void btc_ble_mesh_generic_client_cb_to_app(esp_ble_mesh_generic_client_cb_event_t event,
esp_ble_mesh_generic_client_cb_param_t *param)
esp_ble_mesh_generic_client_cb_param_t *param)
{
esp_ble_mesh_generic_client_cb_t btc_ble_mesh_cb =
(esp_ble_mesh_generic_client_cb_t)btc_profile_cb_get(BTC_PID_GENERIC_CLIENT);
@ -49,7 +49,7 @@ void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, voi
memcpy(dst->generic_client_get_state.params, src->generic_client_get_state.params,
sizeof(esp_ble_mesh_client_common_param_t));
} else {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
break;
}
if (src->generic_client_get_state.get_state) {
@ -58,7 +58,7 @@ void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, voi
memcpy(dst->generic_client_get_state.get_state, src->generic_client_get_state.get_state,
sizeof(esp_ble_mesh_generic_client_get_state_t));
} else {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
}
}
break;
@ -78,7 +78,7 @@ void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, voi
length = src->generic_client_set_state.set_state->user_property_set.property_value->len;
dst->generic_client_set_state.set_state->user_property_set.property_value = bt_mesh_alloc_buf(length);
if (!dst->generic_client_set_state.set_state->user_property_set.property_value) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(dst->generic_client_set_state.set_state->user_property_set.property_value,
@ -91,7 +91,7 @@ void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, voi
length = src->generic_client_set_state.set_state->admin_property_set.property_value->len;
dst->generic_client_set_state.set_state->admin_property_set.property_value = bt_mesh_alloc_buf(length);
if (!dst->generic_client_set_state.set_state->admin_property_set.property_value) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(dst->generic_client_set_state.set_state->admin_property_set.property_value,
@ -103,12 +103,12 @@ void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, voi
break;
}
} else {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
}
break;
}
default:
BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act);
BT_DBG("%s, Unknown act %d", __func__, msg->act);
break;
}
}
@ -172,7 +172,7 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de
if (p_src_data->params) {
p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (!p_dest_data->params) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
@ -191,7 +191,7 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de
length = p_src_data->status_cb.user_properties_status.property_ids->len;
p_dest_data->status_cb.user_properties_status.property_ids = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.user_properties_status.property_ids) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.user_properties_status.property_ids,
@ -206,7 +206,7 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de
length = p_src_data->status_cb.user_property_status.property_value->len;
p_dest_data->status_cb.user_property_status.property_value = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.user_property_status.property_value) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.user_property_status.property_value,
@ -220,7 +220,7 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de
length = p_src_data->status_cb.admin_properties_status.property_ids->len;
p_dest_data->status_cb.admin_properties_status.property_ids = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.admin_properties_status.property_ids) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.admin_properties_status.property_ids,
@ -235,7 +235,7 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de
length = p_src_data->status_cb.admin_property_status.property_value->len;
p_dest_data->status_cb.admin_property_status.property_value = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.admin_property_status.property_value) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.admin_property_status.property_value,
@ -249,7 +249,7 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de
length = p_src_data->status_cb.manufacturer_properties_status.property_ids->len;
p_dest_data->status_cb.manufacturer_properties_status.property_ids = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.manufacturer_properties_status.property_ids) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.manufacturer_properties_status.property_ids,
@ -264,7 +264,7 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de
length = p_src_data->status_cb.manufacturer_property_status.property_value->len;
p_dest_data->status_cb.manufacturer_property_status.property_value = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.manufacturer_property_status.property_value) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.manufacturer_property_status.property_value,
@ -278,7 +278,7 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de
length = p_src_data->status_cb.client_properties_status.property_ids->len;
p_dest_data->status_cb.client_properties_status.property_ids = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.client_properties_status.property_ids) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.client_properties_status.property_ids,
@ -374,18 +374,17 @@ static void btc_ble_mesh_generic_client_callback(esp_ble_mesh_generic_client_cb_
msg.pid = BTC_PID_GENERIC_CLIENT;
msg.act = act;
btc_transfer_context(&msg, cb_params,
sizeof(esp_ble_mesh_generic_client_cb_param_t), btc_ble_mesh_generic_client_copy_req_data);
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_generic_client_cb_param_t),
btc_ble_mesh_generic_client_copy_req_data);
}
void bt_mesh_generic_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len)
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len)
{
esp_ble_mesh_generic_client_cb_param_t cb_params = {0};
esp_ble_mesh_client_common_param_t params = {0};
size_t length = 0U;
uint8_t act = 0U;
if (!model || !ctx) {
@ -407,7 +406,7 @@ void bt_mesh_generic_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
act = ESP_BLE_MESH_GENERIC_CLIENT_TIMEOUT_EVT;
break;
default:
BT_ERR("%s, Unknown generic client event type %d", __func__, evt_type);
BT_ERR("Unknown Generic client event type %d", evt_type);
return;
}
@ -420,31 +419,30 @@ void bt_mesh_generic_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
params.ctx.recv_op = ctx->recv_op;
params.ctx.recv_dst = ctx->recv_dst;
params.ctx.recv_rssi = ctx->recv_rssi;
params.ctx.send_ttl = ctx->send_ttl;
cb_params.error_code = 0;
cb_params.params = &params;
if (val && len) {
length = (len <= sizeof(cb_params.status_cb)) ? len : sizeof(cb_params.status_cb);
memcpy(&cb_params.status_cb, val, length);
memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb)));
}
btc_ble_mesh_generic_client_callback(&cb_params, act);
return;
}
void btc_ble_mesh_generic_client_publish_callback(u32_t opcode,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
void btc_ble_mesh_generic_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
if (!model || !ctx || !buf) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
bt_mesh_generic_client_cb_evt_to_btc(opcode,
BTC_BLE_MESH_EVT_GENERIC_CLIENT_PUBLISH, model, ctx, buf->data, buf->len);
bt_mesh_generic_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_GENERIC_CLIENT_PUBLISH,
model, ctx, buf->data, buf->len);
return;
}
@ -454,7 +452,6 @@ void btc_ble_mesh_generic_client_call_handler(btc_msg_t *msg)
btc_ble_mesh_generic_client_args_t *arg = NULL;
esp_ble_mesh_generic_client_cb_param_t cb = {0};
bt_mesh_client_common_param_t common = {0};
bt_mesh_role_param_t role_param = {0};
if (!msg || !msg->arg) {
BT_ERR("%s, Invalid parameter", __func__);
@ -466,12 +463,6 @@ void btc_ble_mesh_generic_client_call_handler(btc_msg_t *msg)
switch (msg->act) {
case BTC_BLE_MESH_ACT_GENERIC_CLIENT_GET_STATE: {
params = arg->generic_client_get_state.params;
role_param.model = (struct bt_mesh_model *)params->model;
role_param.role = params->msg_role;
if (bt_mesh_set_client_model_role(&role_param)) {
BT_ERR("%s, Failed to set model role", __func__);
break;
}
common.opcode = params->opcode;
common.model = (struct bt_mesh_model *)params->model;
common.ctx.net_idx = params->ctx.net_idx;
@ -480,10 +471,10 @@ void btc_ble_mesh_generic_client_call_handler(btc_msg_t *msg)
common.ctx.send_rel = params->ctx.send_rel;
common.ctx.send_ttl = params->ctx.send_ttl;
common.msg_timeout = params->msg_timeout;
common.msg_role = params->msg_role;
cb.params = arg->generic_client_get_state.params;
cb.error_code = bt_mesh_generic_client_get_state(&common,
(void *)arg->generic_client_get_state.get_state, (void *)&cb.status_cb);
cb.error_code = bt_mesh_generic_client_get_state(&common, arg->generic_client_get_state.get_state);
if (cb.error_code) {
/* If send failed, callback error_code to app layer immediately */
btc_ble_mesh_generic_client_callback(&cb, ESP_BLE_MESH_GENERIC_CLIENT_GET_STATE_EVT);
@ -492,12 +483,6 @@ void btc_ble_mesh_generic_client_call_handler(btc_msg_t *msg)
}
case BTC_BLE_MESH_ACT_GENERIC_CLIENT_SET_STATE: {
params = arg->generic_client_set_state.params;
role_param.model = (struct bt_mesh_model *)params->model;
role_param.role = params->msg_role;
if (bt_mesh_set_client_model_role(&role_param)) {
BT_ERR("%s, Failed to set model role", __func__);
break;
}
common.opcode = params->opcode;
common.model = (struct bt_mesh_model *)params->model;
common.ctx.net_idx = params->ctx.net_idx;
@ -506,10 +491,10 @@ void btc_ble_mesh_generic_client_call_handler(btc_msg_t *msg)
common.ctx.send_rel = params->ctx.send_rel;
common.ctx.send_ttl = params->ctx.send_ttl;
common.msg_timeout = params->msg_timeout;
common.msg_role = params->msg_role;
cb.params = arg->generic_client_set_state.params;
cb.error_code = bt_mesh_generic_client_set_state(&common,
(void *)arg->generic_client_set_state.set_state, (void *)&cb.status_cb);
cb.error_code = bt_mesh_generic_client_set_state(&common, arg->generic_client_set_state.set_state);
if (cb.error_code) {
/* If send failed, callback error_code to app layer immediately */
btc_ble_mesh_generic_client_callback(&cb, ESP_BLE_MESH_GENERIC_CLIENT_SET_STATE_EVT);
@ -538,7 +523,7 @@ void btc_ble_mesh_generic_client_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_GENERIC_CLIENT_EVT_MAX) {
btc_ble_mesh_generic_client_cb_to_app(msg->act, param);
} else {
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
BT_ERR("%s, Unknown act %d", __func__, msg->act);
}
btc_ble_mesh_generic_client_free_req_data(msg);
@ -547,9 +532,8 @@ void btc_ble_mesh_generic_client_cb_handler(btc_msg_t *msg)
/* Generic Server Models related functions */
static inline void btc_ble_mesh_generic_server_cb_to_app(
esp_ble_mesh_generic_server_cb_event_t event,
esp_ble_mesh_generic_server_cb_param_t *param)
static inline void btc_ble_mesh_generic_server_cb_to_app(esp_ble_mesh_generic_server_cb_event_t event,
esp_ble_mesh_generic_server_cb_param_t *param)
{
esp_ble_mesh_generic_server_cb_t btc_ble_mesh_cb =
(esp_ble_mesh_generic_server_cb_t)btc_profile_cb_get(BTC_PID_GENERIC_SERVER);
@ -578,7 +562,7 @@ static void btc_ble_mesh_generic_server_copy_req_data(btc_msg_t *msg, void *p_de
length = p_src_data->value.state_change.user_property_set.value->len;
p_dest_data->value.state_change.user_property_set.value = bt_mesh_alloc_buf(length);
if (p_dest_data->value.state_change.user_property_set.value == NULL) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.state_change.user_property_set.value,
@ -592,7 +576,7 @@ static void btc_ble_mesh_generic_server_copy_req_data(btc_msg_t *msg, void *p_de
length = p_src_data->value.state_change.admin_property_set.value->len;
p_dest_data->value.state_change.admin_property_set.value = bt_mesh_alloc_buf(length);
if (p_dest_data->value.state_change.admin_property_set.value == NULL) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.state_change.admin_property_set.value,
@ -612,7 +596,7 @@ static void btc_ble_mesh_generic_server_copy_req_data(btc_msg_t *msg, void *p_de
length = p_src_data->value.set.user_property.property_value->len;
p_dest_data->value.set.user_property.property_value = bt_mesh_alloc_buf(length);
if (p_dest_data->value.set.user_property.property_value == NULL) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.set.user_property.property_value,
@ -626,7 +610,7 @@ static void btc_ble_mesh_generic_server_copy_req_data(btc_msg_t *msg, void *p_de
length = p_src_data->value.set.admin_property.property_value->len;
p_dest_data->value.set.admin_property.property_value = bt_mesh_alloc_buf(length);
if (p_dest_data->value.set.admin_property.property_value == NULL) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.set.admin_property.property_value,
@ -703,17 +687,15 @@ static void btc_ble_mesh_generic_server_callback(esp_ble_mesh_generic_server_cb_
msg.pid = BTC_PID_GENERIC_SERVER;
msg.act = act;
btc_transfer_context(&msg, cb_params,
sizeof(esp_ble_mesh_generic_server_cb_param_t), btc_ble_mesh_generic_server_copy_req_data);
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_generic_server_cb_param_t),
btc_ble_mesh_generic_server_copy_req_data);
}
void bt_mesh_generic_server_cb_evt_to_btc(u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len)
void bt_mesh_generic_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len)
{
esp_ble_mesh_generic_server_cb_param_t cb_params = {0};
size_t length = 0U;
uint8_t act = 0U;
if (model == NULL || ctx == NULL) {
@ -732,7 +714,7 @@ void bt_mesh_generic_server_cb_evt_to_btc(u8_t evt_type,
act = ESP_BLE_MESH_GENERIC_SERVER_RECV_SET_MSG_EVT;
break;
default:
BT_ERR("%s, Unknown Generic Server event type", __func__);
BT_ERR("Unknown Generic Server event type %d", evt_type);
return;
}
@ -744,10 +726,10 @@ void bt_mesh_generic_server_cb_evt_to_btc(u8_t evt_type,
cb_params.ctx.recv_op = ctx->recv_op;
cb_params.ctx.recv_dst = ctx->recv_dst;
cb_params.ctx.recv_rssi = ctx->recv_rssi;
cb_params.ctx.send_ttl = ctx->send_ttl;
if (val && len) {
length = (len <= sizeof(cb_params.value)) ? len : sizeof(cb_params.value);
memcpy(&cb_params.value, val, length);
memcpy(&cb_params.value, val, MIN(len, sizeof(cb_params.value)));
}
btc_ble_mesh_generic_server_callback(&cb_params, act);
@ -768,7 +750,7 @@ void btc_ble_mesh_generic_server_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_GENERIC_SERVER_EVT_MAX) {
btc_ble_mesh_generic_server_cb_to_app(msg->act, param);
} else {
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
BT_ERR("%s, Unknown act %d", __func__, msg->act);
}
btc_ble_mesh_generic_server_free_req_data(msg);

View file

@ -21,12 +21,10 @@
#include "health_cli.h"
#include "esp_ble_mesh_health_model_api.h"
extern s32_t health_msg_timeout;
/* Health Client Model related functions */
static inline void btc_ble_mesh_health_client_cb_to_app(esp_ble_mesh_health_client_cb_event_t event,
esp_ble_mesh_health_client_cb_param_t *param)
esp_ble_mesh_health_client_cb_param_t *param)
{
esp_ble_mesh_health_client_cb_t btc_ble_mesh_cb =
(esp_ble_mesh_health_client_cb_t)btc_profile_cb_get(BTC_PID_HEALTH_CLIENT);
@ -52,7 +50,7 @@ void btc_ble_mesh_health_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
memcpy(dst->health_client_get_state.params, src->health_client_get_state.params,
sizeof(esp_ble_mesh_client_common_param_t));
} else {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
break;
}
if (src->health_client_get_state.get_state) {
@ -61,7 +59,7 @@ void btc_ble_mesh_health_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
memcpy(dst->health_client_get_state.get_state, src->health_client_get_state.get_state,
sizeof(esp_ble_mesh_health_client_get_state_t));
} else {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
}
}
break;
@ -75,12 +73,12 @@ void btc_ble_mesh_health_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
memcpy(dst->health_client_set_state.set_state, src->health_client_set_state.set_state,
sizeof(esp_ble_mesh_health_client_set_state_t));
} else {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
}
break;
}
default:
BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act);
BT_DBG("%s, Unknown act %d", __func__, msg->act);
break;
}
}
@ -132,7 +130,7 @@ static void btc_ble_mesh_health_client_copy_req_data(btc_msg_t *msg, void *p_des
if (p_src_data->params) {
p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (!p_dest_data->params) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
@ -150,7 +148,7 @@ static void btc_ble_mesh_health_client_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->status_cb.current_status.fault_array->len;
p_dest_data->status_cb.current_status.fault_array = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.current_status.fault_array) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.current_status.fault_array,
@ -166,7 +164,7 @@ static void btc_ble_mesh_health_client_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->status_cb.fault_status.fault_array->len;
p_dest_data->status_cb.fault_status.fault_array = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.fault_status.fault_array) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.fault_status.fault_array,
@ -240,18 +238,17 @@ static void btc_ble_mesh_health_client_callback(esp_ble_mesh_health_client_cb_pa
msg.pid = BTC_PID_HEALTH_CLIENT;
msg.act = act;
btc_transfer_context(&msg, cb_params,
sizeof(esp_ble_mesh_health_client_cb_param_t), btc_ble_mesh_health_client_copy_req_data);
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_health_client_cb_param_t),
btc_ble_mesh_health_client_copy_req_data);
}
void bt_mesh_health_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, u16_t len)
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, u16_t len)
{
esp_ble_mesh_health_client_cb_param_t cb_params = {0};
esp_ble_mesh_client_common_param_t params = {0};
size_t length = 0U;
uint8_t act = 0U;
if (!model || !ctx) {
@ -273,7 +270,7 @@ void bt_mesh_health_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
act = ESP_BLE_MESH_HEALTH_CLIENT_TIMEOUT_EVT;
break;
default:
BT_ERR("%s, Unknown health client event type %d", __func__, evt_type);
BT_ERR("Unknown Health client event type %d", evt_type);
return;
}
@ -286,38 +283,37 @@ void bt_mesh_health_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
params.ctx.recv_op = ctx->recv_op;
params.ctx.recv_dst = ctx->recv_dst;
params.ctx.recv_rssi = ctx->recv_rssi;
params.ctx.send_ttl = ctx->send_ttl;
cb_params.error_code = 0;
cb_params.params = &params;
if (val && len) {
length = (len <= sizeof(cb_params.status_cb)) ? len : sizeof(cb_params.status_cb);
memcpy(&cb_params.status_cb, val, length);
memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb)));
}
btc_ble_mesh_health_client_callback(&cb_params, act);
return;
}
void btc_ble_mesh_health_publish_callback(u32_t opcode,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
void btc_ble_mesh_health_publish_callback(u32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
if (!model || !ctx || !buf) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
bt_mesh_health_client_cb_evt_to_btc(opcode,
BTC_BLE_MESH_EVT_HEALTH_CLIENT_PUBLISH, model, ctx, buf->data, buf->len);
bt_mesh_health_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_HEALTH_CLIENT_PUBLISH,
model, ctx, buf->data, buf->len);
return;
}
static int btc_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_health_client_get_state_t *get)
{
struct bt_mesh_msg_ctx ctx = {0};
bt_mesh_client_common_param_t param = {0};
if (params == NULL) {
BT_ERR("%s, Invalid parameter", __func__);
@ -325,27 +321,29 @@ static int btc_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param
}
if (params->opcode == ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET && get == NULL) {
BT_ERR("%s, Invalid health client get", __func__);
BT_ERR("Invalid Health Get");
return -EINVAL;
}
ctx.net_idx = params->ctx.net_idx;
ctx.app_idx = params->ctx.app_idx;
ctx.addr = params->ctx.addr;
ctx.send_rel = params->ctx.send_rel;
ctx.send_ttl = params->ctx.send_ttl;
param.opcode = params->opcode;
param.model = (struct bt_mesh_model *)params->model;
param.ctx.net_idx = params->ctx.net_idx;
param.ctx.app_idx = params->ctx.app_idx;
param.ctx.addr = params->ctx.addr;
param.ctx.send_rel = params->ctx.send_rel;
param.ctx.send_ttl = params->ctx.send_ttl;
param.msg_timeout = params->msg_timeout;
param.msg_role = params->msg_role;
health_msg_timeout = params->msg_timeout;
switch (params->opcode) {
switch (param.opcode) {
case ESP_BLE_MESH_MODEL_OP_ATTENTION_GET:
return bt_mesh_health_attention_get(&ctx);
return bt_mesh_health_attention_get(&param);
case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_GET:
return bt_mesh_health_period_get(&ctx);
return bt_mesh_health_period_get(&param);
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET:
return bt_mesh_health_fault_get(&ctx, get->fault_get.company_id);
return bt_mesh_health_fault_get(&param, get->fault_get.company_id);
default:
BT_ERR("%s, Invalid opcode 0x%x", __func__, params->opcode);
BT_ERR("Invalid Health Get opcode 0x%04x", param.opcode);
return -EINVAL;
}
@ -355,40 +353,42 @@ static int btc_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param
static int btc_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_health_client_set_state_t *set)
{
struct bt_mesh_msg_ctx ctx = {0};
bt_mesh_client_common_param_t param = {0};
if (params == NULL || set == NULL) {
BT_ERR("%s, Invalid parameter", __func__);
return -EINVAL;
}
ctx.net_idx = params->ctx.net_idx;
ctx.app_idx = params->ctx.app_idx;
ctx.addr = params->ctx.addr;
ctx.send_rel = params->ctx.send_rel;
ctx.send_ttl = params->ctx.send_ttl;
param.opcode = params->opcode;
param.model = (struct bt_mesh_model *)params->model;
param.ctx.net_idx = params->ctx.net_idx;
param.ctx.app_idx = params->ctx.app_idx;
param.ctx.addr = params->ctx.addr;
param.ctx.send_rel = params->ctx.send_rel;
param.ctx.send_ttl = params->ctx.send_ttl;
param.msg_timeout = params->msg_timeout;
param.msg_role = params->msg_role;
health_msg_timeout = params->msg_timeout;
switch (params->opcode) {
switch (param.opcode) {
case ESP_BLE_MESH_MODEL_OP_ATTENTION_SET:
return bt_mesh_health_attention_set(&ctx, set->attention_set.attention, true);
return bt_mesh_health_attention_set(&param, set->attention_set.attention, true);
case ESP_BLE_MESH_MODEL_OP_ATTENTION_SET_UNACK:
return bt_mesh_health_attention_set(&ctx, set->attention_set.attention, false);
return bt_mesh_health_attention_set(&param, set->attention_set.attention, false);
case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET:
return bt_mesh_health_period_set(&ctx, set->period_set.fast_period_divisor, true);
return bt_mesh_health_period_set(&param, set->period_set.fast_period_divisor, true);
case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET_UNACK:
return bt_mesh_health_period_set(&ctx, set->period_set.fast_period_divisor, false);
return bt_mesh_health_period_set(&param, set->period_set.fast_period_divisor, false);
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST:
return bt_mesh_health_fault_test(&ctx, set->fault_test.company_id, set->fault_test.test_id, true);
return bt_mesh_health_fault_test(&param, set->fault_test.company_id, set->fault_test.test_id, true);
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST_UNACK:
return bt_mesh_health_fault_test(&ctx, set->fault_test.company_id, set->fault_test.test_id, false);
return bt_mesh_health_fault_test(&param, set->fault_test.company_id, set->fault_test.test_id, false);
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR:
return bt_mesh_health_fault_clear(&ctx, set->fault_clear.company_id, true);
return bt_mesh_health_fault_clear(&param, set->fault_clear.company_id, true);
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR_UNACK:
return bt_mesh_health_fault_clear(&ctx, set->fault_clear.company_id, false);
return bt_mesh_health_fault_clear(&param, set->fault_clear.company_id, false);
default:
BT_ERR("%s, Invalid opcode 0x%x", __func__, params->opcode);
BT_ERR("Invalid Health Set opcode 0x%04x", param.opcode);
return -EINVAL;
}
@ -399,7 +399,6 @@ void btc_ble_mesh_health_client_call_handler(btc_msg_t *msg)
{
btc_ble_mesh_health_client_args_t *arg = NULL;
esp_ble_mesh_health_client_cb_param_t cb = {0};
bt_mesh_role_param_t role_param = {0};
if (!msg || !msg->arg) {
BT_ERR("%s, Invalid parameter", __func__);
@ -411,12 +410,6 @@ void btc_ble_mesh_health_client_call_handler(btc_msg_t *msg)
switch (msg->act) {
case BTC_BLE_MESH_ACT_HEALTH_CLIENT_GET_STATE: {
cb.params = arg->health_client_get_state.params;
role_param.model = (struct bt_mesh_model *)cb.params->model;
role_param.role = cb.params->msg_role;
if (bt_mesh_set_client_model_role(&role_param)) {
BT_ERR("%s, Failed to set model role", __func__);
break;
}
cb.error_code = btc_ble_mesh_health_client_get_state(arg->health_client_get_state.params,
arg->health_client_get_state.get_state);
if (cb.error_code) {
@ -427,12 +420,6 @@ void btc_ble_mesh_health_client_call_handler(btc_msg_t *msg)
}
case BTC_BLE_MESH_ACT_HEALTH_CLIENT_SET_STATE: {
cb.params = arg->health_client_set_state.params;
role_param.model = (struct bt_mesh_model *)cb.params->model;
role_param.role = cb.params->msg_role;
if (bt_mesh_set_client_model_role(&role_param)) {
BT_ERR("%s, Failed to set model role", __func__);
break;
}
cb.error_code = btc_ble_mesh_health_client_set_state(arg->health_client_set_state.params,
arg->health_client_set_state.set_state);
if (cb.error_code) {
@ -463,7 +450,7 @@ void btc_ble_mesh_health_client_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_HEALTH_CLIENT_EVT_MAX) {
btc_ble_mesh_health_client_cb_to_app(msg->act, param);
} else {
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
BT_ERR("%s, Unknown act %d", __func__, msg->act);
}
btc_ble_mesh_health_client_free_req_data(msg);
@ -473,7 +460,7 @@ void btc_ble_mesh_health_client_cb_handler(btc_msg_t *msg)
/* Health Server Model related functions */
static inline void btc_ble_mesh_health_server_cb_to_app(esp_ble_mesh_health_server_cb_event_t event,
esp_ble_mesh_health_server_cb_param_t *param)
esp_ble_mesh_health_server_cb_param_t *param)
{
esp_ble_mesh_health_server_cb_t btc_ble_mesh_cb =
(esp_ble_mesh_health_server_cb_t)btc_profile_cb_get(BTC_PID_HEALTH_SERVER);
@ -557,8 +544,8 @@ static void btc_ble_mesh_health_server_callback(esp_ble_mesh_health_server_cb_pa
msg.pid = BTC_PID_HEALTH_SERVER;
msg.act = act;
btc_transfer_context(&msg, cb_params,
sizeof(esp_ble_mesh_health_server_cb_param_t), btc_ble_mesh_health_server_copy_req_data);
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_health_server_cb_param_t),
btc_ble_mesh_health_server_copy_req_data);
}
void btc_ble_mesh_health_server_call_handler(btc_msg_t *msg)
@ -602,7 +589,7 @@ void btc_ble_mesh_health_server_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_HEALTH_SERVER_EVT_MAX) {
btc_ble_mesh_health_server_cb_to_app(msg->act, param);
} else {
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
BT_ERR("%s, Unknown act %d", __func__, msg->act);
}
btc_ble_mesh_health_server_free_req_data(msg);
@ -619,7 +606,8 @@ void btc_ble_mesh_health_server_fault_clear(struct bt_mesh_model *model, u16_t c
btc_ble_mesh_health_server_callback(&param, ESP_BLE_MESH_HEALTH_SERVER_FAULT_CLEAR_EVT);
}
void btc_ble_mesh_health_server_fault_test(struct bt_mesh_model *model, u8_t test_id, u16_t company_id)
void btc_ble_mesh_health_server_fault_test(struct bt_mesh_model *model,
u8_t test_id, u16_t company_id)
{
esp_ble_mesh_health_server_cb_param_t param = {0};

View file

@ -22,7 +22,7 @@
/* Lighting Client Models related functions */
static inline void btc_ble_mesh_lighting_client_cb_to_app(esp_ble_mesh_light_client_cb_event_t event,
esp_ble_mesh_light_client_cb_param_t *param)
esp_ble_mesh_light_client_cb_param_t *param)
{
esp_ble_mesh_light_client_cb_t btc_ble_mesh_cb =
(esp_ble_mesh_light_client_cb_t)btc_profile_cb_get(BTC_PID_LIGHTING_CLIENT);
@ -48,7 +48,7 @@ void btc_ble_mesh_lighting_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, vo
memcpy(dst->light_client_get_state.params, src->light_client_get_state.params,
sizeof(esp_ble_mesh_client_common_param_t));
} else {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
break;
}
if (src->light_client_get_state.get_state) {
@ -57,7 +57,7 @@ void btc_ble_mesh_lighting_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, vo
memcpy(dst->light_client_get_state.get_state, src->light_client_get_state.get_state,
sizeof(esp_ble_mesh_light_client_get_state_t));
} else {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
}
}
break;
@ -71,12 +71,12 @@ void btc_ble_mesh_lighting_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, vo
memcpy(dst->light_client_set_state.set_state, src->light_client_set_state.set_state,
sizeof(esp_ble_mesh_light_client_set_state_t));
} else {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
}
break;
}
default:
BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act);
BT_DBG("%s, Unknown act %d", __func__, msg->act);
break;
}
}
@ -128,7 +128,7 @@ static void btc_ble_mesh_lighting_client_copy_req_data(btc_msg_t *msg, void *p_d
if (p_src_data->params) {
p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (!p_dest_data->params) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
@ -148,7 +148,7 @@ static void btc_ble_mesh_lighting_client_copy_req_data(btc_msg_t *msg, void *p_d
length = p_src_data->status_cb.lc_property_status.property_value->len;
p_dest_data->status_cb.lc_property_status.property_value = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.lc_property_status.property_value) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.lc_property_status.property_value,
@ -218,18 +218,17 @@ static void btc_ble_mesh_lighting_client_callback(esp_ble_mesh_light_client_cb_p
msg.pid = BTC_PID_LIGHTING_CLIENT;
msg.act = act;
btc_transfer_context(&msg, cb_params,
sizeof(esp_ble_mesh_light_client_cb_param_t), btc_ble_mesh_lighting_client_copy_req_data);
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_light_client_cb_param_t),
btc_ble_mesh_lighting_client_copy_req_data);
}
void bt_mesh_lighting_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len)
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len)
{
esp_ble_mesh_light_client_cb_param_t cb_params = {0};
esp_ble_mesh_client_common_param_t params = {0};
size_t length = 0U;
uint8_t act = 0U;
if (!model || !ctx) {
@ -251,7 +250,7 @@ void bt_mesh_lighting_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
act = ESP_BLE_MESH_LIGHT_CLIENT_TIMEOUT_EVT;
break;
default:
BT_ERR("%s, Unknown lighting client event type", __func__);
BT_ERR("Unknown Lighting client event type %d", evt_type);
return;
}
@ -264,31 +263,30 @@ void bt_mesh_lighting_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
params.ctx.recv_op = ctx->recv_op;
params.ctx.recv_dst = ctx->recv_dst;
params.ctx.recv_rssi = ctx->recv_rssi;
params.ctx.send_ttl = ctx->send_ttl;
cb_params.error_code = 0;
cb_params.params = &params;
if (val && len) {
length = (len <= sizeof(cb_params.status_cb)) ? len : sizeof(cb_params.status_cb);
memcpy(&cb_params.status_cb, val, length);
memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb)));
}
btc_ble_mesh_lighting_client_callback(&cb_params, act);
return;
}
void btc_ble_mesh_lighting_client_publish_callback(u32_t opcode,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
void btc_ble_mesh_lighting_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
if (!model || !ctx || !buf) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
bt_mesh_lighting_client_cb_evt_to_btc(opcode,
BTC_BLE_MESH_EVT_LIGHTING_CLIENT_PUBLISH, model, ctx, buf->data, buf->len);
bt_mesh_lighting_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_LIGHTING_CLIENT_PUBLISH,
model, ctx, buf->data, buf->len);
return;
}
@ -298,7 +296,6 @@ void btc_ble_mesh_lighting_client_call_handler(btc_msg_t *msg)
btc_ble_mesh_lighting_client_args_t *arg = NULL;
esp_ble_mesh_light_client_cb_param_t cb = {0};
bt_mesh_client_common_param_t common = {0};
bt_mesh_role_param_t role_param = {0};
if (!msg || !msg->arg) {
BT_ERR("%s, Invalid parameter", __func__);
@ -310,12 +307,6 @@ void btc_ble_mesh_lighting_client_call_handler(btc_msg_t *msg)
switch (msg->act) {
case BTC_BLE_MESH_ACT_LIGHTING_CLIENT_GET_STATE: {
params = arg->light_client_get_state.params;
role_param.model = (struct bt_mesh_model *)params->model;
role_param.role = params->msg_role;
if (bt_mesh_set_client_model_role(&role_param)) {
BT_ERR("%s, Failed to set model role", __func__);
break;
}
common.opcode = params->opcode;
common.model = (struct bt_mesh_model *)params->model;
common.ctx.net_idx = params->ctx.net_idx;
@ -324,10 +315,10 @@ void btc_ble_mesh_lighting_client_call_handler(btc_msg_t *msg)
common.ctx.send_rel = params->ctx.send_rel;
common.ctx.send_ttl = params->ctx.send_ttl;
common.msg_timeout = params->msg_timeout;
common.msg_role = params->msg_role;
cb.params = arg->light_client_get_state.params;
cb.error_code = bt_mesh_light_client_get_state(&common,
(void *)arg->light_client_get_state.get_state, (void *)&cb.status_cb);
cb.error_code = bt_mesh_light_client_get_state(&common, arg->light_client_get_state.get_state);
if (cb.error_code) {
/* If send failed, callback error_code to app layer immediately */
btc_ble_mesh_lighting_client_callback(&cb, ESP_BLE_MESH_LIGHT_CLIENT_GET_STATE_EVT);
@ -336,12 +327,6 @@ void btc_ble_mesh_lighting_client_call_handler(btc_msg_t *msg)
}
case BTC_BLE_MESH_ACT_LIGHTING_CLIENT_SET_STATE: {
params = arg->light_client_set_state.params;
role_param.model = (struct bt_mesh_model *)params->model;
role_param.role = params->msg_role;
if (bt_mesh_set_client_model_role(&role_param)) {
BT_ERR("%s, Failed to set model role", __func__);
break;
}
common.opcode = params->opcode;
common.model = (struct bt_mesh_model *)params->model;
common.ctx.net_idx = params->ctx.net_idx;
@ -350,10 +335,10 @@ void btc_ble_mesh_lighting_client_call_handler(btc_msg_t *msg)
common.ctx.send_rel = params->ctx.send_rel;
common.ctx.send_ttl = params->ctx.send_ttl;
common.msg_timeout = params->msg_timeout;
common.msg_role = params->msg_role;
cb.params = arg->light_client_set_state.params;
cb.error_code = bt_mesh_light_client_set_state(&common,
(void *)arg->light_client_set_state.set_state, (void *)&cb.status_cb);
cb.error_code = bt_mesh_light_client_set_state(&common, arg->light_client_set_state.set_state);
if (cb.error_code) {
/* If send failed, callback error_code to app layer immediately */
btc_ble_mesh_lighting_client_callback(&cb, ESP_BLE_MESH_LIGHT_CLIENT_SET_STATE_EVT);
@ -382,7 +367,7 @@ void btc_ble_mesh_lighting_client_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_LIGHT_CLIENT_EVT_MAX) {
btc_ble_mesh_lighting_client_cb_to_app(msg->act, param);
} else {
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
BT_ERR("%s, Unknown act %d", __func__, msg->act);
}
btc_ble_mesh_lighting_client_free_req_data(msg);
@ -391,9 +376,8 @@ void btc_ble_mesh_lighting_client_cb_handler(btc_msg_t *msg)
/* Lighting Server Models related functions */
static inline void btc_ble_mesh_lighting_server_cb_to_app(
esp_ble_mesh_lighting_server_cb_event_t event,
esp_ble_mesh_lighting_server_cb_param_t *param)
static inline void btc_ble_mesh_lighting_server_cb_to_app(esp_ble_mesh_lighting_server_cb_event_t event,
esp_ble_mesh_lighting_server_cb_param_t *param)
{
esp_ble_mesh_lighting_server_cb_t btc_ble_mesh_cb =
(esp_ble_mesh_lighting_server_cb_t)btc_profile_cb_get(BTC_PID_LIGHTING_SERVER);
@ -421,7 +405,7 @@ static void btc_ble_mesh_lighting_server_copy_req_data(btc_msg_t *msg, void *p_d
length = p_src_data->value.state_change.lc_property_set.property_value->len;
p_dest_data->value.state_change.lc_property_set.property_value = bt_mesh_alloc_buf(length);
if (p_dest_data->value.state_change.lc_property_set.property_value == NULL) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.state_change.lc_property_set.property_value,
@ -437,7 +421,7 @@ static void btc_ble_mesh_lighting_server_copy_req_data(btc_msg_t *msg, void *p_d
length = p_src_data->value.set.lc_property.property_value->len;
p_dest_data->value.set.lc_property.property_value = bt_mesh_alloc_buf(length);
if (p_dest_data->value.set.lc_property.property_value == NULL) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.set.lc_property.property_value,
@ -452,7 +436,7 @@ static void btc_ble_mesh_lighting_server_copy_req_data(btc_msg_t *msg, void *p_d
length = p_src_data->value.status.sensor_status.data->len;
p_dest_data->value.status.sensor_status.data = bt_mesh_alloc_buf(length);
if (p_dest_data->value.status.sensor_status.data == NULL) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.status.sensor_status.data,
@ -515,17 +499,15 @@ static void btc_ble_mesh_lighting_server_callback(esp_ble_mesh_lighting_server_c
msg.pid = BTC_PID_LIGHTING_SERVER;
msg.act = act;
btc_transfer_context(
&msg, cb_params, sizeof(esp_ble_mesh_lighting_server_cb_param_t), btc_ble_mesh_lighting_server_copy_req_data);
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_lighting_server_cb_param_t),
btc_ble_mesh_lighting_server_copy_req_data);
}
void bt_mesh_lighting_server_cb_evt_to_btc(u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len)
void bt_mesh_lighting_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len)
{
esp_ble_mesh_lighting_server_cb_param_t cb_params = {0};
size_t length = 0U;
uint8_t act = 0U;
if (model == NULL || ctx == NULL) {
@ -547,7 +529,7 @@ void bt_mesh_lighting_server_cb_evt_to_btc(u8_t evt_type,
act = ESP_BLE_MESH_LIGHTING_SERVER_RECV_STATUS_MSG_EVT;
break;
default:
BT_ERR("%s, Unknown Lighting Server event type", __func__);
BT_ERR("Unknown Lighting server event type %d", evt_type);
return;
}
@ -559,10 +541,10 @@ void bt_mesh_lighting_server_cb_evt_to_btc(u8_t evt_type,
cb_params.ctx.recv_op = ctx->recv_op;
cb_params.ctx.recv_dst = ctx->recv_dst;
cb_params.ctx.recv_rssi = ctx->recv_rssi;
cb_params.ctx.send_ttl = ctx->send_ttl;
if (val && len) {
length = (len <= sizeof(cb_params.value)) ? len : sizeof(cb_params.value);
memcpy(&cb_params.value, val, length);
memcpy(&cb_params.value, val, MIN(len, sizeof(cb_params.value)));
}
btc_ble_mesh_lighting_server_callback(&cb_params, act);
@ -583,7 +565,7 @@ void btc_ble_mesh_lighting_server_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_LIGHTING_SERVER_EVT_MAX) {
btc_ble_mesh_lighting_server_cb_to_app(msg->act, param);
} else {
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
BT_ERR("%s, Unknown act %d", __func__, msg->act);
}
btc_ble_mesh_lighting_server_free_req_data(msg);

File diff suppressed because it is too large Load diff

View file

@ -22,7 +22,7 @@
/* Sensor Client Models related functions */
static inline void btc_ble_mesh_sensor_client_cb_to_app(esp_ble_mesh_sensor_client_cb_event_t event,
esp_ble_mesh_sensor_client_cb_param_t *param)
esp_ble_mesh_sensor_client_cb_param_t *param)
{
esp_ble_mesh_sensor_client_cb_t btc_ble_mesh_cb =
(esp_ble_mesh_sensor_client_cb_t)btc_profile_cb_get(BTC_PID_SENSOR_CLIENT);
@ -58,7 +58,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
length = src->sensor_client_get_state.get_state->column_get.raw_value_x->len;
dst->sensor_client_get_state.get_state->column_get.raw_value_x = bt_mesh_alloc_buf(length);
if (!dst->sensor_client_get_state.get_state->column_get.raw_value_x) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(dst->sensor_client_get_state.get_state->column_get.raw_value_x,
@ -71,7 +71,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
length = src->sensor_client_get_state.get_state->series_get.raw_value_x1->len;
dst->sensor_client_get_state.get_state->series_get.raw_value_x1 = bt_mesh_alloc_buf(length);
if (!dst->sensor_client_get_state.get_state->series_get.raw_value_x1) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(dst->sensor_client_get_state.get_state->series_get.raw_value_x1,
@ -82,7 +82,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
length = src->sensor_client_get_state.get_state->series_get.raw_value_x2->len;
dst->sensor_client_get_state.get_state->series_get.raw_value_x2 = bt_mesh_alloc_buf(length);
if (!dst->sensor_client_get_state.get_state->series_get.raw_value_x2) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(dst->sensor_client_get_state.get_state->series_get.raw_value_x2,
@ -94,7 +94,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
break;
}
} else {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
}
break;
}
@ -113,7 +113,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
length = src->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down->len;
dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down = bt_mesh_alloc_buf(length);
if (!dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down,
@ -124,7 +124,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
length = src->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_up->len;
dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_up = bt_mesh_alloc_buf(length);
if (!dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_up) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_up,
@ -135,7 +135,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
length = src->sensor_client_set_state.set_state->cadence_set.fast_cadence_low->len;
dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_low = bt_mesh_alloc_buf(length);
if (!dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_low) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_low,
@ -146,7 +146,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
length = src->sensor_client_set_state.set_state->cadence_set.fast_cadence_high->len;
dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_high = bt_mesh_alloc_buf(length);
if (!dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_high) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_high,
@ -159,7 +159,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
length = src->sensor_client_set_state.set_state->setting_set.sensor_setting_raw->len;
dst->sensor_client_set_state.set_state->setting_set.sensor_setting_raw = bt_mesh_alloc_buf(length);
if (!dst->sensor_client_set_state.set_state->setting_set.sensor_setting_raw) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(dst->sensor_client_set_state.set_state->setting_set.sensor_setting_raw,
@ -171,12 +171,12 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
break;
}
} else {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
}
break;
}
default:
BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act);
BT_DBG("%s, Unknown act %d", __func__, msg->act);
break;
}
}
@ -256,7 +256,7 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des
if (p_src_data->params) {
p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (!p_dest_data->params) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
@ -275,7 +275,7 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->status_cb.descriptor_status.descriptor->len;
p_dest_data->status_cb.descriptor_status.descriptor = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.descriptor_status.descriptor) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.descriptor_status.descriptor,
@ -290,7 +290,7 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->status_cb.cadence_status.sensor_cadence_value->len;
p_dest_data->status_cb.cadence_status.sensor_cadence_value = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.cadence_status.sensor_cadence_value) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.cadence_status.sensor_cadence_value,
@ -304,7 +304,7 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->status_cb.settings_status.sensor_setting_property_ids->len;
p_dest_data->status_cb.settings_status.sensor_setting_property_ids = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.settings_status.sensor_setting_property_ids) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.settings_status.sensor_setting_property_ids,
@ -319,7 +319,7 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->status_cb.setting_status.sensor_setting_raw->len;
p_dest_data->status_cb.setting_status.sensor_setting_raw = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.setting_status.sensor_setting_raw) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.setting_status.sensor_setting_raw,
@ -333,7 +333,7 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->status_cb.sensor_status.marshalled_sensor_data->len;
p_dest_data->status_cb.sensor_status.marshalled_sensor_data = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.sensor_status.marshalled_sensor_data) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.sensor_status.marshalled_sensor_data,
@ -347,7 +347,7 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->status_cb.column_status.sensor_column_value->len;
p_dest_data->status_cb.column_status.sensor_column_value = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.column_status.sensor_column_value) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.column_status.sensor_column_value,
@ -361,7 +361,7 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->status_cb.series_status.sensor_series_value->len;
p_dest_data->status_cb.series_status.sensor_series_value = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.series_status.sensor_series_value) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.series_status.sensor_series_value,
@ -456,18 +456,17 @@ static void btc_ble_mesh_sensor_client_callback(esp_ble_mesh_sensor_client_cb_pa
msg.pid = BTC_PID_SENSOR_CLIENT;
msg.act = act;
btc_transfer_context(&msg, cb_params,
sizeof(esp_ble_mesh_sensor_client_cb_param_t), btc_ble_mesh_sensor_client_copy_req_data);
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_sensor_client_cb_param_t),
btc_ble_mesh_sensor_client_copy_req_data);
}
void bt_mesh_sensor_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len)
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len)
{
esp_ble_mesh_sensor_client_cb_param_t cb_params = {0};
esp_ble_mesh_client_common_param_t params = {0};
size_t length = 0U;
uint8_t act = 0U;
if (!model || !ctx) {
@ -489,7 +488,7 @@ void bt_mesh_sensor_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
act = ESP_BLE_MESH_SENSOR_CLIENT_TIMEOUT_EVT;
break;
default:
BT_ERR("%s, Unknown sensor client event type %d", __func__, evt_type);
BT_ERR("Unknown Sensor client event type %d", evt_type);
return;
}
@ -502,31 +501,30 @@ void bt_mesh_sensor_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
params.ctx.recv_op = ctx->recv_op;
params.ctx.recv_dst = ctx->recv_dst;
params.ctx.recv_rssi = ctx->recv_rssi;
params.ctx.send_ttl = ctx->send_ttl;
cb_params.error_code = 0;
cb_params.params = &params;
if (val && len) {
length = (len <= sizeof(cb_params.status_cb)) ? len : sizeof(cb_params.status_cb);
memcpy(&cb_params.status_cb, val, length);
memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb)));
}
btc_ble_mesh_sensor_client_callback(&cb_params, act);
return;
}
void btc_ble_mesh_sensor_client_publish_callback(u32_t opcode,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
void btc_ble_mesh_sensor_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
if (!model || !ctx || !buf) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
bt_mesh_sensor_client_cb_evt_to_btc(opcode,
BTC_BLE_MESH_EVT_SENSOR_CLIENT_PUBLISH, model, ctx, buf->data, buf->len);
bt_mesh_sensor_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_SENSOR_CLIENT_PUBLISH,
model, ctx, buf->data, buf->len);
return;
}
@ -536,7 +534,6 @@ void btc_ble_mesh_sensor_client_call_handler(btc_msg_t *msg)
btc_ble_mesh_sensor_client_args_t *arg = NULL;
esp_ble_mesh_sensor_client_cb_param_t cb = {0};
bt_mesh_client_common_param_t common = {0};
bt_mesh_role_param_t role_param = {0};
if (!msg || !msg->arg) {
BT_ERR("%s, Invalid parameter", __func__);
@ -548,12 +545,6 @@ void btc_ble_mesh_sensor_client_call_handler(btc_msg_t *msg)
switch (msg->act) {
case BTC_BLE_MESH_ACT_SENSOR_CLIENT_GET_STATE: {
params = arg->sensor_client_get_state.params;
role_param.model = (struct bt_mesh_model *)params->model;
role_param.role = params->msg_role;
if (bt_mesh_set_client_model_role(&role_param)) {
BT_ERR("%s, Failed to set model role", __func__);
break;
}
common.opcode = params->opcode;
common.model = (struct bt_mesh_model *)params->model;
common.ctx.net_idx = params->ctx.net_idx;
@ -562,10 +553,10 @@ void btc_ble_mesh_sensor_client_call_handler(btc_msg_t *msg)
common.ctx.send_rel = params->ctx.send_rel;
common.ctx.send_ttl = params->ctx.send_ttl;
common.msg_timeout = params->msg_timeout;
common.msg_role = params->msg_role;
cb.params = arg->sensor_client_get_state.params;
cb.error_code = bt_mesh_sensor_client_get_state(&common,
(void *)arg->sensor_client_get_state.get_state, (void *)&cb.status_cb);
cb.error_code = bt_mesh_sensor_client_get_state(&common, arg->sensor_client_get_state.get_state);
if (cb.error_code) {
/* If send failed, callback error_code to app layer immediately */
btc_ble_mesh_sensor_client_callback(&cb, ESP_BLE_MESH_SENSOR_CLIENT_GET_STATE_EVT);
@ -574,12 +565,6 @@ void btc_ble_mesh_sensor_client_call_handler(btc_msg_t *msg)
}
case BTC_BLE_MESH_ACT_SENSOR_CLIENT_SET_STATE: {
params = arg->sensor_client_set_state.params;
role_param.model = (struct bt_mesh_model *)params->model;
role_param.role = params->msg_role;
if (bt_mesh_set_client_model_role(&role_param)) {
BT_ERR("%s, Failed to set model role", __func__);
break;
}
common.opcode = params->opcode;
common.model = (struct bt_mesh_model *)params->model;
common.ctx.net_idx = params->ctx.net_idx;
@ -588,10 +573,10 @@ void btc_ble_mesh_sensor_client_call_handler(btc_msg_t *msg)
common.ctx.send_rel = params->ctx.send_rel;
common.ctx.send_ttl = params->ctx.send_ttl;
common.msg_timeout = params->msg_timeout;
common.msg_role = params->msg_role;
cb.params = arg->sensor_client_set_state.params;
cb.error_code = bt_mesh_sensor_client_set_state(&common,
(void *)arg->sensor_client_set_state.set_state, (void *)&cb.status_cb);
cb.error_code = bt_mesh_sensor_client_set_state(&common, arg->sensor_client_set_state.set_state);
if (cb.error_code) {
/* If send failed, callback error_code to app layer immediately */
btc_ble_mesh_sensor_client_callback(&cb, ESP_BLE_MESH_SENSOR_CLIENT_SET_STATE_EVT);
@ -620,7 +605,7 @@ void btc_ble_mesh_sensor_client_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_SENSOR_CLIENT_EVT_MAX) {
btc_ble_mesh_sensor_client_cb_to_app(msg->act, param);
} else {
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
BT_ERR("%s, Unknown act %d", __func__, msg->act);
}
btc_ble_mesh_sensor_client_free_req_data(msg);
@ -629,9 +614,8 @@ void btc_ble_mesh_sensor_client_cb_handler(btc_msg_t *msg)
/* Sensor Server Models related functions */
static inline void btc_ble_mesh_sensor_server_cb_to_app(
esp_ble_mesh_sensor_server_cb_event_t event,
esp_ble_mesh_sensor_server_cb_param_t *param)
static inline void btc_ble_mesh_sensor_server_cb_to_app(esp_ble_mesh_sensor_server_cb_event_t event,
esp_ble_mesh_sensor_server_cb_param_t *param)
{
esp_ble_mesh_sensor_server_cb_t btc_ble_mesh_cb =
(esp_ble_mesh_sensor_server_cb_t)btc_profile_cb_get(BTC_PID_SENSOR_SERVER);
@ -659,7 +643,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->value.state_change.sensor_cadence_set.trigger_delta_down->len;
p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_down = bt_mesh_alloc_buf(length);
if (p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_down == NULL) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_down,
@ -670,7 +654,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->value.state_change.sensor_cadence_set.trigger_delta_up->len;
p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_up = bt_mesh_alloc_buf(length);
if (p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_up == NULL) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_up,
@ -681,7 +665,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->value.state_change.sensor_cadence_set.fast_cadence_low->len;
p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_low = bt_mesh_alloc_buf(length);
if (p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_low == NULL) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_low,
@ -692,7 +676,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->value.state_change.sensor_cadence_set.fast_cadence_high->len;
p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_high = bt_mesh_alloc_buf(length);
if (p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_high == NULL) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_high,
@ -705,7 +689,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->value.state_change.sensor_setting_set.setting_value->len;
p_dest_data->value.state_change.sensor_setting_set.setting_value = bt_mesh_alloc_buf(length);
if (p_dest_data->value.state_change.sensor_setting_set.setting_value == NULL) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.state_change.sensor_setting_set.setting_value,
@ -720,7 +704,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->value.get.sensor_column.raw_value_x->len;
p_dest_data->value.get.sensor_column.raw_value_x = bt_mesh_alloc_buf(length);
if (p_dest_data->value.get.sensor_column.raw_value_x == NULL) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.get.sensor_column.raw_value_x,
@ -732,7 +716,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->value.get.sensor_series.raw_value->len;
p_dest_data->value.get.sensor_series.raw_value = bt_mesh_alloc_buf(length);
if (p_dest_data->value.get.sensor_series.raw_value == NULL) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.get.sensor_series.raw_value,
@ -748,7 +732,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->value.set.sensor_cadence.cadence->len;
p_dest_data->value.set.sensor_cadence.cadence = bt_mesh_alloc_buf(length);
if (p_dest_data->value.set.sensor_cadence.cadence == NULL) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.set.sensor_cadence.cadence,
@ -761,7 +745,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->value.set.sensor_setting.setting_raw->len;
p_dest_data->value.set.sensor_setting.setting_raw = bt_mesh_alloc_buf(length);
if (p_dest_data->value.set.sensor_setting.setting_raw == NULL) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.set.sensor_setting.setting_raw,
@ -835,17 +819,15 @@ static void btc_ble_mesh_sensor_server_callback(esp_ble_mesh_sensor_server_cb_pa
msg.pid = BTC_PID_SENSOR_SERVER;
msg.act = act;
btc_transfer_context(
&msg, cb_params, sizeof(esp_ble_mesh_sensor_server_cb_param_t), btc_ble_mesh_sensor_server_copy_req_data);
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_sensor_server_cb_param_t),
btc_ble_mesh_sensor_server_copy_req_data);
}
void bt_mesh_sensor_server_cb_evt_to_btc(u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len)
void bt_mesh_sensor_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len)
{
esp_ble_mesh_sensor_server_cb_param_t cb_params = {0};
size_t length = 0U;
uint8_t act = 0U;
if (model == NULL || ctx == NULL) {
@ -864,7 +846,7 @@ void bt_mesh_sensor_server_cb_evt_to_btc(u8_t evt_type,
act = ESP_BLE_MESH_SENSOR_SERVER_RECV_SET_MSG_EVT;
break;
default:
BT_ERR("%s, Unknown Sensor Server event type", __func__);
BT_ERR("Unknown Sensor server event type %d", evt_type);
return;
}
@ -876,10 +858,10 @@ void bt_mesh_sensor_server_cb_evt_to_btc(u8_t evt_type,
cb_params.ctx.recv_op = ctx->recv_op;
cb_params.ctx.recv_dst = ctx->recv_dst;
cb_params.ctx.recv_rssi = ctx->recv_rssi;
cb_params.ctx.send_ttl = ctx->send_ttl;
if (val && len) {
length = (len <= sizeof(cb_params.value)) ? len : sizeof(cb_params.value);
memcpy(&cb_params.value, val, length);
memcpy(&cb_params.value, val, MIN(len, sizeof(cb_params.value)));
}
btc_ble_mesh_sensor_server_callback(&cb_params, act);
@ -900,7 +882,7 @@ void btc_ble_mesh_sensor_server_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_SENSOR_SERVER_EVT_MAX) {
btc_ble_mesh_sensor_server_cb_to_app(msg->act, param);
} else {
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
BT_ERR("%s, Unknown act %d", __func__, msg->act);
}
btc_ble_mesh_sensor_server_free_req_data(msg);

View file

@ -22,7 +22,7 @@
/* Time and Scenes Client Models related functions */
static inline void btc_ble_mesh_time_scene_client_cb_to_app(esp_ble_mesh_time_scene_client_cb_event_t event,
esp_ble_mesh_time_scene_client_cb_param_t *param)
esp_ble_mesh_time_scene_client_cb_param_t *param)
{
esp_ble_mesh_time_scene_client_cb_t btc_ble_mesh_cb =
(esp_ble_mesh_time_scene_client_cb_t)btc_profile_cb_get(BTC_PID_TIME_SCENE_CLIENT);
@ -48,7 +48,7 @@ void btc_ble_mesh_time_scene_client_arg_deep_copy(btc_msg_t *msg, void *p_dest,
memcpy(dst->time_scene_client_get_state.params, src->time_scene_client_get_state.params,
sizeof(esp_ble_mesh_client_common_param_t));
} else {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
break;
}
if (src->time_scene_client_get_state.get_state) {
@ -57,7 +57,7 @@ void btc_ble_mesh_time_scene_client_arg_deep_copy(btc_msg_t *msg, void *p_dest,
memcpy(dst->time_scene_client_get_state.get_state, src->time_scene_client_get_state.get_state,
sizeof(esp_ble_mesh_time_scene_client_get_state_t));
} else {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
}
}
break;
@ -71,12 +71,12 @@ void btc_ble_mesh_time_scene_client_arg_deep_copy(btc_msg_t *msg, void *p_dest,
memcpy(dst->time_scene_client_set_state.set_state, src->time_scene_client_set_state.set_state,
sizeof(esp_ble_mesh_time_scene_client_set_state_t));
} else {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
}
break;
}
default:
BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act);
BT_DBG("%s, Unknown act %d", __func__, msg->act);
break;
}
}
@ -128,7 +128,7 @@ static void btc_ble_mesh_time_scene_client_copy_req_data(btc_msg_t *msg, void *p
if (p_src_data->params) {
p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (!p_dest_data->params) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
@ -149,7 +149,7 @@ static void btc_ble_mesh_time_scene_client_copy_req_data(btc_msg_t *msg, void *p
length = p_src_data->status_cb.scene_register_status.scenes->len;
p_dest_data->status_cb.scene_register_status.scenes = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.scene_register_status.scenes) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.scene_register_status.scenes,
@ -220,18 +220,17 @@ static void btc_ble_mesh_time_scene_client_callback(esp_ble_mesh_time_scene_clie
msg.pid = BTC_PID_TIME_SCENE_CLIENT;
msg.act = act;
btc_transfer_context(&msg, cb_params,
sizeof(esp_ble_mesh_time_scene_client_cb_param_t), btc_ble_mesh_time_scene_client_copy_req_data);
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_time_scene_client_cb_param_t),
btc_ble_mesh_time_scene_client_copy_req_data);
}
void bt_mesh_time_scene_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len)
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len)
{
esp_ble_mesh_time_scene_client_cb_param_t cb_params = {0};
esp_ble_mesh_client_common_param_t params = {0};
size_t length = 0U;
uint8_t act = 0U;
if (!model || !ctx) {
@ -253,7 +252,7 @@ void bt_mesh_time_scene_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
act = ESP_BLE_MESH_TIME_SCENE_CLIENT_TIMEOUT_EVT;
break;
default:
BT_ERR("%s, Unknown time scene client event type %d", __func__, evt_type);
BT_ERR("Unknown Time Scene client event type %d", evt_type);
return;
}
@ -266,31 +265,30 @@ void bt_mesh_time_scene_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
params.ctx.recv_op = ctx->recv_op;
params.ctx.recv_dst = ctx->recv_dst;
params.ctx.recv_rssi = ctx->recv_rssi;
params.ctx.send_ttl = ctx->send_ttl;
cb_params.error_code = 0;
cb_params.params = &params;
if (val && len) {
length = (len <= sizeof(cb_params.status_cb)) ? len : sizeof(cb_params.status_cb);
memcpy(&cb_params.status_cb, val, length);
memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb)));
}
btc_ble_mesh_time_scene_client_callback(&cb_params, act);
return;
}
void btc_ble_mesh_time_scene_client_publish_callback(u32_t opcode,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
void btc_ble_mesh_time_scene_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
if (!model || !ctx || !buf) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
bt_mesh_time_scene_client_cb_evt_to_btc(opcode,
BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_PUBLISH, model, ctx, buf->data, buf->len);
bt_mesh_time_scene_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_PUBLISH,
model, ctx, buf->data, buf->len);
return;
}
@ -300,7 +298,6 @@ void btc_ble_mesh_time_scene_client_call_handler(btc_msg_t *msg)
esp_ble_mesh_client_common_param_t *params = NULL;
esp_ble_mesh_time_scene_client_cb_param_t cb = {0};
bt_mesh_client_common_param_t common = {0};
bt_mesh_role_param_t role_param = {0};
if (!msg || !msg->arg) {
BT_ERR("%s, Invalid parameter", __func__);
@ -312,12 +309,6 @@ void btc_ble_mesh_time_scene_client_call_handler(btc_msg_t *msg)
switch (msg->act) {
case BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_GET_STATE: {
params = arg->time_scene_client_get_state.params;
role_param.model = (struct bt_mesh_model *)params->model;
role_param.role = params->msg_role;
if (bt_mesh_set_client_model_role(&role_param)) {
BT_ERR("%s, Failed to set model role", __func__);
break;
}
common.opcode = params->opcode;
common.model = (struct bt_mesh_model *)params->model;
common.ctx.net_idx = params->ctx.net_idx;
@ -326,10 +317,10 @@ void btc_ble_mesh_time_scene_client_call_handler(btc_msg_t *msg)
common.ctx.send_rel = params->ctx.send_rel;
common.ctx.send_ttl = params->ctx.send_ttl;
common.msg_timeout = params->msg_timeout;
common.msg_role = params->msg_role;
cb.params = arg->time_scene_client_get_state.params;
cb.error_code = bt_mesh_time_scene_client_get_state(&common,
(void *)arg->time_scene_client_get_state.get_state, (void *)&cb.status_cb);
cb.error_code = bt_mesh_time_scene_client_get_state(&common, arg->time_scene_client_get_state.get_state);
if (cb.error_code) {
/* If send failed, callback error_code to app layer immediately */
btc_ble_mesh_time_scene_client_callback(&cb, ESP_BLE_MESH_TIME_SCENE_CLIENT_GET_STATE_EVT);
@ -338,12 +329,6 @@ void btc_ble_mesh_time_scene_client_call_handler(btc_msg_t *msg)
}
case BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_SET_STATE: {
params = arg->time_scene_client_set_state.params;
role_param.model = (struct bt_mesh_model *)params->model;
role_param.role = params->msg_role;
if (bt_mesh_set_client_model_role(&role_param)) {
BT_ERR("%s, Failed to set model role", __func__);
break;
}
common.opcode = params->opcode;
common.model = (struct bt_mesh_model *)params->model;
common.ctx.net_idx = params->ctx.net_idx;
@ -352,10 +337,10 @@ void btc_ble_mesh_time_scene_client_call_handler(btc_msg_t *msg)
common.ctx.send_rel = params->ctx.send_rel;
common.ctx.send_ttl = params->ctx.send_ttl;
common.msg_timeout = params->msg_timeout;
common.msg_role = params->msg_role;
cb.params = arg->time_scene_client_set_state.params;
cb.error_code = bt_mesh_time_scene_client_set_state(&common,
(void *)arg->time_scene_client_set_state.set_state, (void *)&cb.status_cb);
cb.error_code = bt_mesh_time_scene_client_set_state(&common, arg->time_scene_client_set_state.set_state);
if (cb.error_code) {
/* If send failed, callback error_code to app layer immediately */
btc_ble_mesh_time_scene_client_callback(&cb, ESP_BLE_MESH_TIME_SCENE_CLIENT_SET_STATE_EVT);
@ -384,7 +369,7 @@ void btc_ble_mesh_time_scene_client_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_TIME_SCENE_CLIENT_EVT_MAX) {
btc_ble_mesh_time_scene_client_cb_to_app(msg->act, param);
} else {
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
BT_ERR("%s, Unknown act %d", __func__, msg->act);
}
btc_ble_mesh_time_scene_client_free_req_data(msg);
@ -393,9 +378,8 @@ void btc_ble_mesh_time_scene_client_cb_handler(btc_msg_t *msg)
/* Time and Scenes Server Models related functions */
static inline void btc_ble_mesh_time_scene_server_cb_to_app(
esp_ble_mesh_time_scene_server_cb_event_t event,
esp_ble_mesh_time_scene_server_cb_param_t *param)
static inline void btc_ble_mesh_time_scene_server_cb_to_app(esp_ble_mesh_time_scene_server_cb_event_t event,
esp_ble_mesh_time_scene_server_cb_param_t *param)
{
esp_ble_mesh_time_scene_server_cb_t btc_ble_mesh_cb =
(esp_ble_mesh_time_scene_server_cb_t)btc_profile_cb_get(BTC_PID_TIME_SCENE_SERVER);
@ -419,17 +403,14 @@ static void btc_ble_mesh_time_scene_server_callback(esp_ble_mesh_time_scene_serv
msg.pid = BTC_PID_TIME_SCENE_SERVER;
msg.act = act;
btc_transfer_context(
&msg, cb_params, sizeof(esp_ble_mesh_time_scene_server_cb_param_t), NULL);
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_time_scene_server_cb_param_t), NULL);
}
void bt_mesh_time_scene_server_cb_evt_to_btc(u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len)
void bt_mesh_time_scene_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len)
{
esp_ble_mesh_time_scene_server_cb_param_t cb_params = {0};
size_t length = 0U;
uint8_t act = 0U;
if (model == NULL || ctx == NULL) {
@ -451,7 +432,7 @@ void bt_mesh_time_scene_server_cb_evt_to_btc(u8_t evt_type,
act = ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_STATUS_MSG_EVT;
break;
default:
BT_ERR("%s, Unknown Time Scene Server event type", __func__);
BT_ERR("Unknown Time Scene server event type %d", evt_type);
return;
}
@ -463,10 +444,10 @@ void bt_mesh_time_scene_server_cb_evt_to_btc(u8_t evt_type,
cb_params.ctx.recv_op = ctx->recv_op;
cb_params.ctx.recv_dst = ctx->recv_dst;
cb_params.ctx.recv_rssi = ctx->recv_rssi;
cb_params.ctx.send_ttl = ctx->send_ttl;
if (val && len) {
length = (len <= sizeof(cb_params.value)) ? len : sizeof(cb_params.value);
memcpy(&cb_params.value, val, length);
memcpy(&cb_params.value, val, MIN(len, sizeof(cb_params.value)));
}
btc_ble_mesh_time_scene_server_callback(&cb_params, act);
@ -487,7 +468,7 @@ void btc_ble_mesh_time_scene_server_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_TIME_SCENE_SERVER_EVT_MAX) {
btc_ble_mesh_time_scene_server_cb_to_app(msg->act, param);
} else {
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
BT_ERR("%s, Unknown act %d", __func__, msg->act);
}
return;

View file

@ -53,15 +53,14 @@ void btc_ble_mesh_config_client_cb_handler(btc_msg_t *msg);
void btc_ble_mesh_config_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
void btc_ble_mesh_config_client_publish_callback(u32_t opcode,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf);
void btc_ble_mesh_config_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf);
void bt_mesh_config_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len);
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len);
void btc_ble_mesh_config_server_cb_handler(btc_msg_t *msg);
@ -70,10 +69,9 @@ typedef enum {
BTC_BLE_MESH_EVT_CONFIG_SERVER_MAX,
} btc_ble_mesh_config_server_evt_t;
void bt_mesh_config_server_cb_evt_to_btc(u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len);
void bt_mesh_config_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len);
#ifdef __cplusplus
}

View file

@ -53,15 +53,14 @@ void btc_ble_mesh_generic_client_cb_handler(btc_msg_t *msg);
void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
void btc_ble_mesh_generic_client_publish_callback(u32_t opcode,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf);
void btc_ble_mesh_generic_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf);
void bt_mesh_generic_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len);
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len);
typedef enum {
BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE,
@ -70,10 +69,9 @@ typedef enum {
BTC_BLE_MESH_EVT_GENERIC_SERVER_MAX,
} btc_ble_mesh_generic_server_evt_t;
void bt_mesh_generic_server_cb_evt_to_btc(u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len);
void bt_mesh_generic_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len);
void btc_ble_mesh_generic_server_cb_handler(btc_msg_t *msg);

View file

@ -53,15 +53,14 @@ void btc_ble_mesh_health_client_call_handler(btc_msg_t *msg);
void btc_ble_mesh_health_client_cb_handler(btc_msg_t *msg);
void btc_ble_mesh_health_publish_callback(u32_t opcode,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf);
void btc_ble_mesh_health_publish_callback(u32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf);
void bt_mesh_health_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, u16_t len);
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, u16_t len);
typedef enum {
BTC_BLE_MESH_ACT_HEALTH_SERVER_FAULT_UPDATE,
@ -82,7 +81,8 @@ void btc_ble_mesh_health_server_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
void btc_ble_mesh_health_server_fault_clear(struct bt_mesh_model *model, u16_t company_id);
void btc_ble_mesh_health_server_fault_test(struct bt_mesh_model *model, u8_t test_id, u16_t company_id);
void btc_ble_mesh_health_server_fault_test(struct bt_mesh_model *model,
u8_t test_id, u16_t company_id);
void btc_ble_mesh_health_server_attention_on(struct bt_mesh_model *model, u8_t time);

View file

@ -53,15 +53,14 @@ void btc_ble_mesh_lighting_client_cb_handler(btc_msg_t *msg);
void btc_ble_mesh_lighting_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
void btc_ble_mesh_lighting_client_publish_callback(u32_t opcode,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf);
void btc_ble_mesh_lighting_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf);
void bt_mesh_lighting_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len);
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len);
typedef enum {
BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE,
@ -71,10 +70,9 @@ typedef enum {
BTC_BLE_MESH_EVT_LIGHTING_SERVER_MAX,
} btc_ble_mesh_lighting_server_evt_t;
void bt_mesh_lighting_server_cb_evt_to_btc(u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len);
void bt_mesh_lighting_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len);
void btc_ble_mesh_lighting_server_cb_handler(btc_msg_t *msg);

View file

@ -320,10 +320,9 @@ esp_ble_mesh_elem_t *btc_ble_mesh_elem_find(u16_t addr);
uint8_t btc_ble_mesh_elem_count(void);
esp_ble_mesh_model_t *btc_ble_mesh_model_find_vnd(const esp_ble_mesh_elem_t *elem,
uint16_t company, uint16_t id);
uint16_t company, uint16_t id);
esp_ble_mesh_model_t *btc_ble_mesh_model_find(const esp_ble_mesh_elem_t *elem,
uint16_t id);
esp_ble_mesh_model_t *btc_ble_mesh_model_find(const esp_ble_mesh_elem_t *elem, uint16_t id);
const esp_ble_mesh_comp_t *btc_ble_mesh_comp_get(void);

View file

@ -53,15 +53,14 @@ void btc_ble_mesh_sensor_client_cb_handler(btc_msg_t *msg);
void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
void btc_ble_mesh_sensor_client_publish_callback(u32_t opcode,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf);
void btc_ble_mesh_sensor_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf);
void bt_mesh_sensor_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len);
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len);
typedef enum {
BTC_BLE_MESH_EVT_SENSOR_SERVER_STATE_CHANGE,
@ -70,10 +69,9 @@ typedef enum {
BTC_BLE_MESH_EVT_SENSOR_SERVER_MAX,
} btc_ble_mesh_sensor_server_evt_t;
void bt_mesh_sensor_server_cb_evt_to_btc(u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len);
void bt_mesh_sensor_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len);
void btc_ble_mesh_sensor_server_cb_handler(btc_msg_t *msg);

View file

@ -53,15 +53,14 @@ void btc_ble_mesh_time_scene_client_cb_handler(btc_msg_t *msg);
void btc_ble_mesh_time_scene_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
void btc_ble_mesh_time_scene_client_publish_callback(u32_t opcode,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf);
void btc_ble_mesh_time_scene_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf);
void bt_mesh_time_scene_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len);
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len);
typedef enum {
BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_STATE_CHANGE,
@ -71,10 +70,9 @@ typedef enum {
BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_MAX,
} btc_ble_mesh_time_scene_server_evt_t;
void bt_mesh_time_scene_server_cb_evt_to_btc(u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len);
void bt_mesh_time_scene_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len);
void btc_ble_mesh_time_scene_server_cb_handler(btc_msg_t *msg);

View file

@ -22,6 +22,7 @@
#include <stddef.h>
#include <stdlib.h>
#include "esp_attr.h"
#include "esp_heap_caps.h"
#include "mesh_byteorder.h"
@ -34,14 +35,11 @@
extern "C" {
#endif
#if CONFIG_BLE_MESH_ALLOC_FROM_PSRAM_FIRST
#define bt_mesh_malloc(size) heap_caps_malloc_prefer(size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL)
#define bt_mesh_calloc(size) heap_caps_calloc_prefer(1, size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL)
#else
#define bt_mesh_malloc(size) malloc((size))
#define bt_mesh_calloc(size) calloc(1, (size))
#endif /* CONFIG_BLE_MESH_ALLOC_FROM_PSRAM_FIRST */
#define bt_mesh_free(p) free((p))
IRAM_ATTR void *bt_mesh_malloc(size_t size);
IRAM_ATTR void *bt_mesh_calloc(size_t size);
IRAM_ATTR void bt_mesh_free(void *ptr);
/**
* @brief This function allocates memory to store outgoing message.

View file

@ -13,6 +13,7 @@
#include "freertos/queue.h"
#include "freertos/semphr.h"
#include "sdkconfig.h"
#include "mesh_types.h"
#ifdef __cplusplus
@ -36,6 +37,8 @@ extern "C" {
#endif
#define BLE_MESH_ADV_TASK_STACK_SIZE 3072
#define BLE_MESH_ADV_TASK_NAME "mesh_adv_task"
#define BLE_MESH_ADV_TASK_PRIO (configMAX_PRIORITIES - 5)
/**
* @brief Put the current thread to sleep.

View file

@ -25,7 +25,7 @@ extern "C" {
typedef struct {
SemaphoreHandle_t mutex;
#if CONFIG_SPIRAM_USE_MALLOC
#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC
StaticQueue_t *buffer;
#endif
} bt_mesh_mutex_t;

View file

@ -493,7 +493,7 @@ void net_buf_unref(struct net_buf *buf)
pool->uninit_count++;
#if defined(CONFIG_BLE_MESH_NET_BUF_POOL_USAGE)
pool->avail_count++;
NET_BUF_DBG("%s, pool %p, avail_count %d, uninit_count %d", __func__,
NET_BUF_DBG("Unref, pool %p, avail_count %d, uninit_count %d",
pool, pool->avail_count, pool->uninit_count);
NET_BUF_ASSERT(pool->avail_count <= pool->buf_count);
#endif
@ -546,7 +546,7 @@ struct net_buf *net_buf_alloc_len(struct net_buf_pool *pool, size_t size,
NET_BUF_ASSERT(pool);
NET_BUF_DBG("%s, pool %p, uninit_count %d, buf_count %d", __func__,
NET_BUF_DBG("Alloc, pool %p, uninit_count %d, buf_count %d",
pool, pool->uninit_count, pool->buf_count);
/* We need to lock interrupts temporarily to prevent race conditions
@ -570,7 +570,7 @@ struct net_buf *net_buf_alloc_len(struct net_buf_pool *pool, size_t size,
bt_mesh_buf_unlock();
NET_BUF_ERR("%s, Failed to get free buffer", __func__);
NET_BUF_ERR("Out of free buffer, pool %p", pool);
return NULL;
success:
@ -579,11 +579,11 @@ success:
if (size) {
buf->__buf = data_alloc(buf, &size, timeout);
if (!buf->__buf) {
NET_BUF_ERR("%s, Failed to allocate data", __func__);
NET_BUF_ERR("Out of data, buf %p", buf);
return NULL;
}
} else {
NET_BUF_WARN("%s, Zero data size", __func__);
NET_BUF_WARN("Zero data size, buf %p", buf);
buf->__buf = NULL;
}

View file

@ -19,6 +19,37 @@
#include "client_common.h"
#include "mesh_common.h"
IRAM_ATTR void *bt_mesh_malloc(size_t size)
{
#ifdef CONFIG_BLE_MESH_MEM_ALLOC_MODE_INTERNAL
return heap_caps_malloc(size, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
#elif CONFIG_BLE_MESH_ALLOC_FROM_PSRAM_FIRST
return heap_caps_malloc_prefer(size, 2, MALLOC_CAP_SPIRAM|MALLOC_CAP_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
#elif CONFIG_BLE_MESH_MEM_ALLOC_MODE_IRAM_8BIT
return heap_caps_malloc_prefer(size, 2, MALLOC_CAP_INTERNAL|MALLOC_CAP_IRAM_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
#else
return malloc(size);
#endif
}
IRAM_ATTR void *bt_mesh_calloc(size_t size)
{
#ifdef CONFIG_BLE_MESH_MEM_ALLOC_MODE_INTERNAL
return heap_caps_calloc(1, size, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
#elif CONFIG_BLE_MESH_ALLOC_FROM_PSRAM_FIRST
return heap_caps_calloc_prefer(1, size, 2, MALLOC_CAP_SPIRAM|MALLOC_CAP_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
#elif CONFIG_BLE_MESH_MEM_ALLOC_MODE_IRAM_8BIT
return heap_caps_calloc_prefer(1, size, 2, MALLOC_CAP_INTERNAL|MALLOC_CAP_IRAM_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
#else
return calloc(1, size);
#endif
}
IRAM_ATTR void bt_mesh_free(void *ptr)
{
heap_caps_free(ptr);
}
struct net_buf_simple *bt_mesh_alloc_buf(u16_t size)
{
struct net_buf_simple *buf = NULL;
@ -26,7 +57,7 @@ struct net_buf_simple *bt_mesh_alloc_buf(u16_t size)
buf = (struct net_buf_simple *)bt_mesh_calloc(sizeof(struct net_buf_simple) + size);
if (!buf) {
BT_ERR("%s, Failed to allocate memory", __func__);
BT_ERR("%s, Out of memory", __func__);
return NULL;
}
@ -52,7 +83,7 @@ u8_t bt_mesh_get_device_role(struct bt_mesh_model *model, bool srv_send)
bt_mesh_client_user_data_t *client = NULL;
if (srv_send) {
BT_DBG("%s, Message is sent by a server model", __func__);
BT_DBG("Message is sent by a server model");
return NODE;
}

View file

@ -22,32 +22,36 @@ static bt_mesh_mutex_t atomic_lock;
void bt_mesh_mutex_create(bt_mesh_mutex_t *mutex)
{
if (!mutex) {
BT_ERR("%s, Invalid mutex", __func__);
BT_ERR("Create, invalid mutex");
return;
}
#if CONFIG_SPIRAM_USE_MALLOC
mutex->buffer = heap_caps_calloc(1, sizeof(StaticQueue_t), MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM);
__ASSERT(mutex->buffer, "%s, Failed to create queue buffer", __func__);
mutex->mutex = xSemaphoreCreateMutexStatic(mutex->buffer);
__ASSERT(mutex->mutex, "%s, Failed to create static mutex", __func__);
#else
mutex->mutex = xSemaphoreCreateMutex();
__ASSERT(mutex->mutex, "%s, Failed to create mutex", __func__);
#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC
#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_EXTERNAL
mutex->buffer = heap_caps_calloc_prefer(1, sizeof(StaticQueue_t), 2, MALLOC_CAP_SPIRAM|MALLOC_CAP_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
#elif CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_IRAM_8BIT
mutex->buffer = heap_caps_calloc_prefer(1, sizeof(StaticQueue_t), 2, MALLOC_CAP_INTERNAL|MALLOC_CAP_IRAM_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
#endif
__ASSERT(mutex->buffer, "Failed to create mutex buffer");
mutex->mutex = xSemaphoreCreateMutexStatic(mutex->buffer);
__ASSERT(mutex->mutex, "Failed to create static mutex");
#else /* CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC */
mutex->mutex = xSemaphoreCreateMutex();
__ASSERT(mutex->mutex, "Failed to create mutex");
#endif /* CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC */
}
void bt_mesh_mutex_free(bt_mesh_mutex_t *mutex)
{
if (!mutex) {
BT_ERR("%s, Invalid mutex", __func__);
BT_ERR("Free, invalid mutex");
return;
}
if (mutex->mutex) {
vSemaphoreDelete(mutex->mutex);
mutex->mutex = NULL;
#if CONFIG_SPIRAM_USE_MALLOC
#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC
heap_caps_free(mutex->buffer);
mutex->buffer = NULL;
#endif
@ -57,7 +61,7 @@ void bt_mesh_mutex_free(bt_mesh_mutex_t *mutex)
void bt_mesh_mutex_lock(bt_mesh_mutex_t *mutex)
{
if (!mutex) {
BT_ERR("%s, Invalid mutex", __func__);
BT_ERR("Lock, invalid mutex");
return;
}
@ -69,7 +73,7 @@ void bt_mesh_mutex_lock(bt_mesh_mutex_t *mutex)
void bt_mesh_mutex_unlock(bt_mesh_mutex_t *mutex)
{
if (!mutex) {
BT_ERR("%s, Invalid mutex", __func__);
BT_ERR("Unlock, invalid mutex");
return;
}

View file

@ -48,7 +48,7 @@ void bt_mesh_timer_init(void)
bm_alarm_hash_map = hash_map_new(BLE_MESH_GENERAL_ALARM_HASH_MAP_SIZE,
hash_function_pointer, NULL,
(data_free_fn)osi_alarm_free, NULL);
__ASSERT(bm_alarm_hash_map, "%s, Failed to create hash map", __func__);
__ASSERT(bm_alarm_hash_map, "Failed to create hash map");
}
void bt_mesh_timer_deinit(void)
@ -74,12 +74,12 @@ int k_delayed_work_init(struct k_delayed_work *work, k_work_handler_t handler)
if (!hash_map_has_key(bm_alarm_hash_map, (void *)work)) {
alarm = osi_alarm_new("bt_mesh", (osi_alarm_callback_t)handler, (void *)&work->work, 0);
if (alarm == NULL) {
BT_ERR("%s, Alarm not created", __func__);
BT_ERR("Alarm not created");
bt_mesh_alarm_unlock();
return -EIO;
}
if (!hash_map_set(bm_alarm_hash_map, work, (void *)alarm)) {
BT_ERR("%s, Alarm not set", __func__);
BT_ERR("Alarm not set");
bt_mesh_alarm_unlock();
return -EIO;
}
@ -87,7 +87,7 @@ int k_delayed_work_init(struct k_delayed_work *work, k_work_handler_t handler)
alarm = hash_map_get(bm_alarm_hash_map, work);
if (alarm == NULL) {
BT_ERR("%s, Alarm not found", __func__);
BT_ERR("Init, alarm not found");
bt_mesh_alarm_unlock();
return -ENODEV;
}
@ -108,7 +108,7 @@ int k_delayed_work_submit(struct k_delayed_work *work, s32_t delay)
bt_mesh_alarm_lock();
osi_alarm_t *alarm = hash_map_get(bm_alarm_hash_map, (void *)work);
if (alarm == NULL) {
BT_WARN("%s, Alarm not found", __func__);
BT_WARN("Submit, alarm not found");
bt_mesh_alarm_unlock();
return -EINVAL;
}
@ -130,7 +130,7 @@ int k_delayed_work_submit_periodic(struct k_delayed_work *work, s32_t period)
bt_mesh_alarm_lock();
osi_alarm_t *alarm = hash_map_get(bm_alarm_hash_map, (void *)work);
if (alarm == NULL) {
BT_WARN("%s, Alarm not found", __func__);
BT_WARN("Submit, alarm not found");
bt_mesh_alarm_unlock();
return -EINVAL;
}
@ -152,7 +152,7 @@ int k_delayed_work_cancel(struct k_delayed_work *work)
bt_mesh_alarm_lock();
osi_alarm_t *alarm = hash_map_get(bm_alarm_hash_map, (void *)work);
if (alarm == NULL) {
BT_WARN("%s, Alarm not found", __func__);
BT_WARN("Cancel, alarm not found");
bt_mesh_alarm_unlock();
return -EINVAL;
}
@ -173,7 +173,7 @@ int k_delayed_work_free(struct k_delayed_work *work)
bt_mesh_alarm_lock();
osi_alarm_t *alarm = hash_map_get(bm_alarm_hash_map, work);
if (alarm == NULL) {
BT_WARN("%s, Alarm not found", __func__);
BT_WARN("Free, alarm not found");
bt_mesh_alarm_unlock();
return -EINVAL;
}
@ -196,7 +196,7 @@ s32_t k_delayed_work_remaining_get(struct k_delayed_work *work)
bt_mesh_alarm_lock();
osi_alarm_t *alarm = hash_map_get(bm_alarm_hash_map, (void *)work);
if (alarm == NULL) {
BT_WARN("%s, Alarm not found", __func__);
BT_WARN("Get time, alarm not found");
bt_mesh_alarm_unlock();
return 0;
}

View file

@ -22,221 +22,11 @@
#include "fast_prov.h"
#include "provisioner_main.h"
#include "generic_client.h"
#include "sensor_client.h"
#include "time_scene_client.h"
#include "lighting_client.h"
#include "generic_server.h"
#include "sensor_server.h"
#include "time_scene_server.h"
#include "lighting_server.h"
#define BLE_MESH_SDU_MAX_LEN 384
static const struct bt_mesh_comp *dev_comp;
static u16_t dev_primary_addr;
static const struct {
const u16_t id;
int (*const init)(struct bt_mesh_model *model, bool primary);
} model_init[] = {
{ BLE_MESH_MODEL_ID_CFG_SRV, bt_mesh_cfg_srv_init },
{ BLE_MESH_MODEL_ID_HEALTH_SRV, bt_mesh_health_srv_init },
#if defined(CONFIG_BLE_MESH_CFG_CLI)
{ BLE_MESH_MODEL_ID_CFG_CLI, bt_mesh_cfg_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_HEALTH_CLI)
{ BLE_MESH_MODEL_ID_HEALTH_CLI, bt_mesh_health_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_GENERIC_ONOFF_CLI)
{ BLE_MESH_MODEL_ID_GEN_ONOFF_CLI, bt_mesh_gen_onoff_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_GENERIC_LEVEL_CLI)
{ BLE_MESH_MODEL_ID_GEN_LEVEL_CLI, bt_mesh_gen_level_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_GENERIC_DEF_TRANS_TIME_CLI)
{ BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_CLI, bt_mesh_gen_def_trans_time_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_GENERIC_POWER_ONOFF_CLI)
{ BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_CLI, bt_mesh_gen_pwr_onoff_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_GENERIC_POWER_LEVEL_CLI)
{ BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_CLI, bt_mesh_gen_pwr_level_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_GENERIC_BATTERY_CLI)
{ BLE_MESH_MODEL_ID_GEN_BATTERY_CLI, bt_mesh_gen_battery_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_GENERIC_LOCATION_CLI)
{ BLE_MESH_MODEL_ID_GEN_LOCATION_CLI, bt_mesh_gen_location_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_GENERIC_PROPERTY_CLI)
{ BLE_MESH_MODEL_ID_GEN_PROP_CLI, bt_mesh_gen_property_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_SENSOR_CLI)
{ BLE_MESH_MODEL_ID_SENSOR_CLI, bt_mesh_sensor_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_TIME_CLI)
{ BLE_MESH_MODEL_ID_TIME_CLI, bt_mesh_time_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_SCENE_CLI)
{ BLE_MESH_MODEL_ID_SCENE_CLI, bt_mesh_scene_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_SCHEDULER_CLI)
{ BLE_MESH_MODEL_ID_SCHEDULER_CLI, bt_mesh_scheduler_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_LIGHT_LIGHTNESS_CLI)
{ BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_CLI, bt_mesh_light_lightness_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_LIGHT_CTL_CLI)
{ BLE_MESH_MODEL_ID_LIGHT_CTL_CLI, bt_mesh_light_ctl_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_LIGHT_HSL_CLI)
{ BLE_MESH_MODEL_ID_LIGHT_HSL_CLI, bt_mesh_light_hsl_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_LIGHT_XYL_CLI)
{ BLE_MESH_MODEL_ID_LIGHT_XYL_CLI, bt_mesh_light_xyl_cli_init },
#endif
#if defined(CONFIG_BLE_MESH_LIGHT_LC_CLI)
{ BLE_MESH_MODEL_ID_LIGHT_LC_CLI, bt_mesh_light_lc_cli_init },
#endif
{ BLE_MESH_MODEL_ID_GEN_ONOFF_SRV, bt_mesh_gen_onoff_srv_init },
{ BLE_MESH_MODEL_ID_GEN_LEVEL_SRV, bt_mesh_gen_level_srv_init },
{ BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_SRV, bt_mesh_gen_def_trans_time_srv_init },
{ BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SRV, bt_mesh_gen_power_onoff_srv_init },
{ BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SETUP_SRV, bt_mesh_gen_power_onoff_setup_srv_init },
{ BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SRV, bt_mesh_gen_power_level_srv_init },
{ BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SETUP_SRV, bt_mesh_gen_power_level_setup_srv_init },
{ BLE_MESH_MODEL_ID_GEN_BATTERY_SRV, bt_mesh_gen_battery_srv_init },
{ BLE_MESH_MODEL_ID_GEN_LOCATION_SRV, bt_mesh_gen_location_srv_init },
{ BLE_MESH_MODEL_ID_GEN_LOCATION_SETUP_SRV, bt_mesh_gen_location_setup_srv_init },
{ BLE_MESH_MODEL_ID_GEN_USER_PROP_SRV, bt_mesh_gen_user_prop_srv_init },
{ BLE_MESH_MODEL_ID_GEN_ADMIN_PROP_SRV, bt_mesh_gen_admin_prop_srv_init },
{ BLE_MESH_MODEL_ID_GEN_MANUFACTURER_PROP_SRV, bt_mesh_gen_manu_prop_srv_init },
{ BLE_MESH_MODEL_ID_GEN_CLIENT_PROP_SRV, bt_mesh_gen_client_prop_srv_init },
{ BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SRV, bt_mesh_light_lightness_srv_init },
{ BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SETUP_SRV, bt_mesh_light_lightness_setup_srv_init },
{ BLE_MESH_MODEL_ID_LIGHT_CTL_SRV, bt_mesh_light_ctl_srv_init },
{ BLE_MESH_MODEL_ID_LIGHT_CTL_SETUP_SRV, bt_mesh_light_ctl_setup_srv_init },
{ BLE_MESH_MODEL_ID_LIGHT_CTL_TEMP_SRV, bt_mesh_light_ctl_temp_srv_init },
{ BLE_MESH_MODEL_ID_LIGHT_HSL_SRV, bt_mesh_light_hsl_srv_init },
{ BLE_MESH_MODEL_ID_LIGHT_HSL_HUE_SRV, bt_mesh_light_hsl_hue_srv_init },
{ BLE_MESH_MODEL_ID_LIGHT_HSL_SAT_SRV, bt_mesh_light_hsl_sat_srv_init },
{ BLE_MESH_MODEL_ID_LIGHT_HSL_SETUP_SRV, bt_mesh_light_hsl_setup_srv_init },
{ BLE_MESH_MODEL_ID_LIGHT_XYL_SRV, bt_mesh_light_xyl_srv_init },
{ BLE_MESH_MODEL_ID_LIGHT_XYL_SETUP_SRV, bt_mesh_light_xyl_setup_srv_init },
{ BLE_MESH_MODEL_ID_LIGHT_LC_SRV, bt_mesh_light_lc_srv_init },
{ BLE_MESH_MODEL_ID_LIGHT_LC_SETUP_SRV, bt_mesh_light_lc_setup_srv_init },
{ BLE_MESH_MODEL_ID_TIME_SRV, bt_mesh_time_srv_init },
{ BLE_MESH_MODEL_ID_TIME_SETUP_SRV, bt_mesh_time_setup_srv_init },
{ BLE_MESH_MODEL_ID_SCENE_SRV, bt_mesh_scene_srv_init },
{ BLE_MESH_MODEL_ID_SCENE_SETUP_SRV, bt_mesh_scene_setup_srv_init },
{ BLE_MESH_MODEL_ID_SCHEDULER_SRV, bt_mesh_scheduler_srv_init },
{ BLE_MESH_MODEL_ID_SCHEDULER_SETUP_SRV, bt_mesh_scheduler_setup_srv_init },
{ BLE_MESH_MODEL_ID_SENSOR_SRV, bt_mesh_sensor_srv_init },
{ BLE_MESH_MODEL_ID_SENSOR_SETUP_SRV, bt_mesh_sensor_setup_srv_init },
};
static const struct {
const u16_t id;
int (*const deinit)(struct bt_mesh_model *model, bool primary);
} model_deinit[] = {
{ BLE_MESH_MODEL_ID_CFG_SRV, bt_mesh_cfg_srv_deinit },
{ BLE_MESH_MODEL_ID_HEALTH_SRV, bt_mesh_health_srv_deinit },
#if defined(CONFIG_BLE_MESH_CFG_CLI)
{ BLE_MESH_MODEL_ID_CFG_CLI, bt_mesh_cfg_cli_deinit },
#endif
#if defined(CONFIG_BLE_MESH_HEALTH_CLI)
{ BLE_MESH_MODEL_ID_HEALTH_CLI, bt_mesh_health_cli_deinit },
#endif
#if defined(CONFIG_BLE_MESH_GENERIC_ONOFF_CLI)
{ BLE_MESH_MODEL_ID_GEN_ONOFF_CLI, bt_mesh_gen_onoff_cli_deinit },
#endif
#if defined(CONFIG_BLE_MESH_GENERIC_LEVEL_CLI)
{ BLE_MESH_MODEL_ID_GEN_LEVEL_CLI, bt_mesh_gen_level_cli_deinit },
#endif
#if defined(CONFIG_BLE_MESH_GENERIC_DEF_TRANS_TIME_CLI)
{ BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_CLI, bt_mesh_gen_def_trans_time_cli_deinit },
#endif
#if defined(CONFIG_BLE_MESH_GENERIC_POWER_ONOFF_CLI)
{ BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_CLI, bt_mesh_gen_pwr_onoff_cli_deinit },
#endif
#if defined(CONFIG_BLE_MESH_GENERIC_POWER_LEVEL_CLI)
{ BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_CLI, bt_mesh_gen_pwr_level_cli_deinit },
#endif
#if defined(CONFIG_BLE_MESH_GENERIC_BATTERY_CLI)
{ BLE_MESH_MODEL_ID_GEN_BATTERY_CLI, bt_mesh_gen_battery_cli_deinit },
#endif
#if defined(CONFIG_BLE_MESH_GENERIC_LOCATION_CLI)
{ BLE_MESH_MODEL_ID_GEN_LOCATION_CLI, bt_mesh_gen_location_cli_deinit },
#endif
#if defined(CONFIG_BLE_MESH_GENERIC_PROPERTY_CLI)
{ BLE_MESH_MODEL_ID_GEN_PROP_CLI, bt_mesh_gen_property_cli_deinit },
#endif
#if defined(CONFIG_BLE_MESH_SENSOR_CLI)
{ BLE_MESH_MODEL_ID_SENSOR_CLI, bt_mesh_sensor_cli_deinit },
#endif
#if defined(CONFIG_BLE_MESH_TIME_CLI)
{ BLE_MESH_MODEL_ID_TIME_CLI, bt_mesh_time_cli_deinit },
#endif
#if defined(CONFIG_BLE_MESH_SCENE_CLI)
{ BLE_MESH_MODEL_ID_SCENE_CLI, bt_mesh_scene_cli_deinit },
#endif
#if defined(CONFIG_BLE_MESH_SCHEDULER_CLI)
{ BLE_MESH_MODEL_ID_SCHEDULER_CLI, bt_mesh_scheduler_cli_deinit },
#endif
#if defined(CONFIG_BLE_MESH_LIGHT_LIGHTNESS_CLI)
{ BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_CLI, bt_mesh_light_lightness_cli_deinit },
#endif
#if defined(CONFIG_BLE_MESH_LIGHT_CTL_CLI)
{ BLE_MESH_MODEL_ID_LIGHT_CTL_CLI, bt_mesh_light_ctl_cli_deinit },
#endif
#if defined(CONFIG_BLE_MESH_LIGHT_HSL_CLI)
{ BLE_MESH_MODEL_ID_LIGHT_HSL_CLI, bt_mesh_light_hsl_cli_deinit },
#endif
#if defined(CONFIG_BLE_MESH_LIGHT_XYL_CLI)
{ BLE_MESH_MODEL_ID_LIGHT_XYL_CLI, bt_mesh_light_xyl_cli_deinit },
#endif
#if defined(CONFIG_BLE_MESH_LIGHT_LC_CLI)
{ BLE_MESH_MODEL_ID_LIGHT_LC_CLI, bt_mesh_light_lc_cli_deinit },
#endif
{ BLE_MESH_MODEL_ID_GEN_ONOFF_SRV, bt_mesh_gen_onoff_srv_deinit },
{ BLE_MESH_MODEL_ID_GEN_LEVEL_SRV, bt_mesh_gen_level_srv_deinit },
{ BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_SRV, bt_mesh_gen_def_trans_time_srv_deinit },
{ BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SRV, bt_mesh_gen_power_onoff_srv_deinit },
{ BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SETUP_SRV, bt_mesh_gen_power_onoff_setup_srv_deinit },
{ BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SRV, bt_mesh_gen_power_level_srv_deinit },
{ BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SETUP_SRV, bt_mesh_gen_power_level_setup_srv_deinit },
{ BLE_MESH_MODEL_ID_GEN_BATTERY_SRV, bt_mesh_gen_battery_srv_deinit },
{ BLE_MESH_MODEL_ID_GEN_LOCATION_SRV, bt_mesh_gen_location_srv_deinit },
{ BLE_MESH_MODEL_ID_GEN_LOCATION_SETUP_SRV, bt_mesh_gen_location_setup_srv_deinit },
{ BLE_MESH_MODEL_ID_GEN_USER_PROP_SRV, bt_mesh_gen_user_prop_srv_deinit },
{ BLE_MESH_MODEL_ID_GEN_ADMIN_PROP_SRV, bt_mesh_gen_admin_prop_srv_deinit },
{ BLE_MESH_MODEL_ID_GEN_MANUFACTURER_PROP_SRV, bt_mesh_gen_manu_prop_srv_deinit },
{ BLE_MESH_MODEL_ID_GEN_CLIENT_PROP_SRV, bt_mesh_gen_client_prop_srv_deinit },
{ BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SRV, bt_mesh_light_lightness_srv_deinit },
{ BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SETUP_SRV, bt_mesh_light_lightness_setup_srv_deinit },
{ BLE_MESH_MODEL_ID_LIGHT_CTL_SRV, bt_mesh_light_ctl_srv_deinit },
{ BLE_MESH_MODEL_ID_LIGHT_CTL_SETUP_SRV, bt_mesh_light_ctl_setup_srv_deinit },
{ BLE_MESH_MODEL_ID_LIGHT_CTL_TEMP_SRV, bt_mesh_light_ctl_temp_srv_deinit },
{ BLE_MESH_MODEL_ID_LIGHT_HSL_SRV, bt_mesh_light_hsl_srv_deinit },
{ BLE_MESH_MODEL_ID_LIGHT_HSL_HUE_SRV, bt_mesh_light_hsl_hue_srv_deinit },
{ BLE_MESH_MODEL_ID_LIGHT_HSL_SAT_SRV, bt_mesh_light_hsl_sat_srv_deinit },
{ BLE_MESH_MODEL_ID_LIGHT_HSL_SETUP_SRV, bt_mesh_light_hsl_setup_srv_deinit },
{ BLE_MESH_MODEL_ID_LIGHT_XYL_SRV, bt_mesh_light_xyl_srv_deinit },
{ BLE_MESH_MODEL_ID_LIGHT_XYL_SETUP_SRV, bt_mesh_light_xyl_setup_srv_deinit },
{ BLE_MESH_MODEL_ID_LIGHT_LC_SRV, bt_mesh_light_lc_srv_deinit },
{ BLE_MESH_MODEL_ID_LIGHT_LC_SETUP_SRV, bt_mesh_light_lc_setup_srv_deinit },
{ BLE_MESH_MODEL_ID_TIME_SRV, bt_mesh_time_srv_deinit },
{ BLE_MESH_MODEL_ID_TIME_SETUP_SRV, bt_mesh_time_setup_srv_deinit },
{ BLE_MESH_MODEL_ID_SCENE_SRV, bt_mesh_scene_srv_deinit },
{ BLE_MESH_MODEL_ID_SCENE_SETUP_SRV, bt_mesh_scene_setup_srv_deinit },
{ BLE_MESH_MODEL_ID_SCHEDULER_SRV, bt_mesh_scheduler_srv_deinit },
{ BLE_MESH_MODEL_ID_SCHEDULER_SETUP_SRV, bt_mesh_scheduler_setup_srv_deinit },
{ BLE_MESH_MODEL_ID_SENSOR_SRV, bt_mesh_sensor_srv_deinit },
{ BLE_MESH_MODEL_ID_SENSOR_SETUP_SRV, bt_mesh_sensor_setup_srv_deinit },
};
void bt_mesh_model_foreach(void (*func)(struct bt_mesh_model *mod,
struct bt_mesh_elem *elem,
bool vnd, bool primary,
@ -245,6 +35,11 @@ void bt_mesh_model_foreach(void (*func)(struct bt_mesh_model *mod,
{
int i, j;
if (dev_comp == NULL) {
BT_ERR("Invalid device composition");
return;
}
for (i = 0; i < dev_comp->elem_count; i++) {
struct bt_mesh_elem *elem = &dev_comp->elem[i];
@ -267,7 +62,7 @@ s32_t bt_mesh_model_pub_period_get(struct bt_mesh_model *mod)
int period = 0;
if (!mod->pub) {
BT_ERR("%s, Model has no publication support", __func__);
BT_ERR("Model has no publication support");
return 0;
}
@ -289,7 +84,7 @@ s32_t bt_mesh_model_pub_period_get(struct bt_mesh_model *mod)
period = K_MINUTES((mod->pub->period & BIT_MASK(6)) * 10U);
break;
default:
BT_ERR("%s, Unknown model publication period", __func__);
BT_ERR("Unknown model publication period");
return 0;
}
@ -306,7 +101,7 @@ static s32_t next_period(struct bt_mesh_model *mod)
u32_t elapsed = 0U, period = 0U;
if (!pub) {
BT_ERR("%s, Model has no publication support", __func__);
BT_ERR("Model has no publication support");
return -ENOTSUP;
}
@ -336,7 +131,7 @@ static void publish_sent(int err, void *user_data)
BT_DBG("err %d", err);
if (!mod->pub) {
BT_ERR("%s, Model has no publication support", __func__);
BT_ERR("Model has no publication support");
return;
}
@ -377,7 +172,7 @@ static int publish_retransmit(struct bt_mesh_model *mod)
{
struct bt_mesh_model_pub *pub = mod->pub;
if (!pub) {
BT_ERR("%s, Model has no publication support", __func__);
BT_ERR("Model has no publication support");
return -ENOTSUP;
}
@ -399,13 +194,13 @@ static int publish_retransmit(struct bt_mesh_model *mod)
key = bt_mesh_tx_appkey_get(pub->dev_role, pub->key);
if (!key) {
BT_ERR("%s, AppKey 0x%03x not exists", __func__, pub->key);
BT_ERR("AppKey 0x%03x not exists", pub->key);
return -EADDRNOTAVAIL;
}
tx.sub = bt_mesh_tx_netkey_get(pub->dev_role, key->net_idx);
if (!tx.sub) {
BT_ERR("%s, Subnet 0x%04x not exists", __func__, key->net_idx);
BT_ERR("Subnet 0x%04x not exists", key->net_idx);
return -EADDRNOTAVAIL;
}
@ -414,7 +209,7 @@ static int publish_retransmit(struct bt_mesh_model *mod)
sdu = bt_mesh_alloc_buf(pub->msg->len + BLE_MESH_MIC_SHORT);
if (!sdu) {
BT_ERR("%s, Failed to allocate memory", __func__);
BT_ERR("%s, Out of memory", __func__);
return -ENOMEM;
}
@ -447,12 +242,12 @@ static void mod_publish(struct k_work *work)
BT_DBG("%s", __func__);
period_ms = bt_mesh_model_pub_period_get(pub->mod);
BT_INFO("period %u ms", period_ms);
BT_INFO("Publish period %u ms", period_ms);
if (pub->count) {
err = publish_retransmit(pub->mod);
if (err) {
BT_ERR("%s, Failed to retransmit (err %d)", __func__, err);
BT_ERR("Failed to retransmit (err %d)", err);
pub->count = 0U;
@ -469,14 +264,11 @@ static void mod_publish(struct k_work *work)
return;
}
__ASSERT_NO_MSG(pub->update != NULL);
/* Callback the model publish update event to the application layer.
* In the event, users can update the context of the publish message
* which will be published in the next period.
*/
err = pub->update(pub->mod);
if (err) {
if (pub->update && pub->update(pub->mod)) {
/* Cancel this publish attempt. */
BT_ERR("Update failed, skipping publish (err %d)", err);
pub->period_start = k_uptime_get_32();
@ -486,7 +278,7 @@ static void mod_publish(struct k_work *work)
err = bt_mesh_model_publish(pub->mod);
if (err) {
BT_ERR("%s, Publishing failed (err %d)", __func__, err);
BT_ERR("Publishing failed (err %d)", err);
}
}
@ -500,12 +292,12 @@ struct bt_mesh_model *bt_mesh_model_get(bool vnd, u8_t elem_idx, u8_t mod_idx)
struct bt_mesh_elem *elem = NULL;
if (!dev_comp) {
BT_ERR("%s, dev_comp is not initialized", __func__);
BT_ERR("dev_comp not initialized");
return NULL;
}
if (elem_idx >= dev_comp->elem_count) {
BT_ERR("%s, Invalid element index %u", __func__, elem_idx);
BT_ERR("Invalid element index %u", elem_idx);
return NULL;
}
@ -513,14 +305,14 @@ struct bt_mesh_model *bt_mesh_model_get(bool vnd, u8_t elem_idx, u8_t mod_idx)
if (vnd) {
if (mod_idx >= elem->vnd_model_count) {
BT_ERR("%s, Invalid vendor model index %u", __func__, mod_idx);
BT_ERR("Invalid vendor model index %u", mod_idx);
return NULL;
}
return &elem->vnd_models[mod_idx];
} else {
if (mod_idx >= elem->model_count) {
BT_ERR("%s, Invalid SIG model index %u", __func__, mod_idx);
BT_ERR("Invalid SIG model index %u", mod_idx);
return NULL;
}
@ -531,8 +323,19 @@ struct bt_mesh_model *bt_mesh_model_get(bool vnd, u8_t elem_idx, u8_t mod_idx)
static void mod_init(struct bt_mesh_model *mod, struct bt_mesh_elem *elem,
bool vnd, bool primary, void *user_data)
{
int *err = user_data;
int i;
if (!user_data) {
BT_ERR("Invalid model init user data");
return;
}
if (*err) {
BT_ERR("Model init failed (err %d)", *err);
return;
}
mod->elem = elem;
if (mod->pub) {
@ -556,18 +359,27 @@ static void mod_init(struct bt_mesh_model *mod, struct bt_mesh_elem *elem,
return;
}
for (i = 0; i < ARRAY_SIZE(model_init); i++) {
if (model_init[i].id == mod->id) {
model_init[i].init(mod, primary);
}
if (mod->cb && mod->cb->init) {
*err = mod->cb->init(mod);
}
}
static void mod_deinit(struct bt_mesh_model *mod, struct bt_mesh_elem *elem,
bool vnd, bool primary, void *user_data)
{
int *err = user_data;
int i;
if (!user_data) {
BT_ERR("Invalid model deinit user data");
return;
}
if (*err) {
BT_ERR("Model deinit failed (err %d)", *err);
return;
}
mod->elem = NULL;
if (mod->pub) {
@ -587,15 +399,15 @@ static void mod_deinit(struct bt_mesh_model *mod, struct bt_mesh_elem *elem,
return;
}
for (i = 0; i < ARRAY_SIZE(model_deinit); i++) {
if (model_deinit[i].id == mod->id) {
model_deinit[i].deinit(mod, primary);
}
if (mod->cb && mod->cb->deinit) {
*err = mod->cb->deinit(mod);
}
}
int bt_mesh_comp_register(const struct bt_mesh_comp *comp)
{
int err = 0;
/* There must be at least one element */
if (!comp->elem_count) {
return -EINVAL;
@ -603,23 +415,24 @@ int bt_mesh_comp_register(const struct bt_mesh_comp *comp)
dev_comp = comp;
bt_mesh_model_foreach(mod_init, NULL);
bt_mesh_model_foreach(mod_init, &err);
return 0;
return err;
}
int bt_mesh_comp_deregister(void)
{
int err = 0;
if (dev_comp == NULL) {
return -EINVAL;
}
bt_mesh_model_foreach(mod_deinit, NULL);
bt_mesh_model_foreach(mod_deinit, &err);
dev_primary_addr = BLE_MESH_ADDR_UNASSIGNED;
dev_comp = NULL;
return 0;
return err;
}
void bt_mesh_comp_provision(u16_t addr)
@ -645,8 +458,6 @@ void bt_mesh_comp_unprovision(void)
BT_DBG("%s", __func__);
dev_primary_addr = BLE_MESH_ADDR_UNASSIGNED;
bt_mesh_model_foreach(mod_init, NULL);
}
u16_t bt_mesh_primary_addr(void)
@ -668,7 +479,7 @@ u16_t *bt_mesh_model_find_group(struct bt_mesh_model *mod, u16_t addr)
}
static struct bt_mesh_model *bt_mesh_elem_find_group(struct bt_mesh_elem *elem,
u16_t group_addr)
u16_t group_addr)
{
struct bt_mesh_model *model = NULL;
u16_t *match = NULL;
@ -776,7 +587,7 @@ static int get_opcode(struct net_buf_simple *buf, u32_t *opcode)
case 0x00:
case 0x01:
if (buf->data[0] == 0x7f) {
BT_ERR("%s, Ignoring RFU OpCode", __func__);
BT_ERR("Ignoring RFU OpCode");
return -EINVAL;
}
@ -784,7 +595,7 @@ static int get_opcode(struct net_buf_simple *buf, u32_t *opcode)
return 0;
case 0x02:
if (buf->len < 2) {
BT_ERR("%s, Too short payload for 2-octet OpCode", __func__);
BT_ERR("Too short payload for 2-octet OpCode");
return -EINVAL;
}
@ -792,7 +603,7 @@ static int get_opcode(struct net_buf_simple *buf, u32_t *opcode)
return 0;
case 0x03:
if (buf->len < 3) {
BT_ERR("%s, Too short payload for 3-octet OpCode", __func__);
BT_ERR("Too short payload for 3-octet OpCode");
return -EINVAL;
}
@ -838,7 +649,7 @@ void bt_mesh_model_recv(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
BT_INFO("recv, len %u: %s", buf->len, bt_hex(buf->data, buf->len));
if (get_opcode(buf, &opcode) < 0) {
BT_WARN("%s, Unable to decode OpCode", __func__);
BT_WARN("Unable to decode OpCode");
return;
}
@ -932,7 +743,7 @@ static bool ready_to_send(u8_t role, u16_t dst)
return true;
} else if (IS_ENABLED(CONFIG_BLE_MESH_PROVISIONER) && bt_mesh_is_provisioner_en() && role == PROVISIONER) {
if (!bt_mesh_provisioner_check_msg_dst(dst)) {
BT_ERR("%s, Failed to find DST 0x%04x", __func__, dst);
BT_ERR("Failed to find DST 0x%04x", dst);
return false;
}
return true;
@ -952,7 +763,7 @@ static int model_send(struct bt_mesh_model *model,
role = bt_mesh_get_device_role(model, tx->ctx->srv_send);
if (role == ROLE_NVAL) {
BT_ERR("%s, Failed to get model role", __func__);
BT_ERR("Failed to get model role");
return -EINVAL;
}
@ -961,22 +772,22 @@ static int model_send(struct bt_mesh_model *model,
BT_INFO("send, len %u: %s", msg->len, bt_hex(msg->data, msg->len));
if (!ready_to_send(role, tx->ctx->addr)) {
BT_ERR("%s, Not ready", __func__);
BT_ERR("Not ready to send");
return -EINVAL;
}
if (net_buf_simple_tailroom(msg) < BLE_MESH_MIC_SHORT) {
BT_ERR("%s, Not enough tailroom for TransMIC", __func__);
BT_ERR("Not enough tailroom for TransMIC");
return -EINVAL;
}
if (msg->len > MIN(BLE_MESH_TX_SDU_MAX, BLE_MESH_SDU_MAX_LEN) - BLE_MESH_MIC_SHORT) {
BT_ERR("%s, Too big message", __func__);
BT_ERR("Too big message (len %d)", msg->len);
return -EMSGSIZE;
}
if (!implicit_bind && !model_has_key(model, tx->ctx->app_idx)) {
BT_ERR("%s, Model not bound to AppKey 0x%04x", __func__, tx->ctx->app_idx);
BT_ERR("Model not bound to AppKey 0x%04x", tx->ctx->app_idx);
return -EINVAL;
}
@ -993,13 +804,13 @@ int bt_mesh_model_send(struct bt_mesh_model *model,
role = bt_mesh_get_device_role(model, ctx->srv_send);
if (role == ROLE_NVAL) {
BT_ERR("%s, Failed to get model role", __func__);
BT_ERR("Failed to get model role");
return -EINVAL;
}
sub = bt_mesh_tx_netkey_get(role, ctx->net_idx);
if (!sub) {
BT_ERR("%s, Failed to get subnet", __func__);
BT_ERR("Invalid NetKeyIndex 0x%04x", ctx->net_idx);
return -EINVAL;
}
@ -1035,28 +846,28 @@ int bt_mesh_model_publish(struct bt_mesh_model *model)
BT_DBG("%s", __func__);
if (!pub || !pub->msg) {
BT_ERR("%s, Model has no publication support", __func__);
BT_ERR("Model has no publication support");
return -ENOTSUP;
}
if (pub->addr == BLE_MESH_ADDR_UNASSIGNED) {
BT_WARN("%s, Unassigned model publish address", __func__);
BT_WARN("Unassigned publish address");
return -EADDRNOTAVAIL;
}
key = bt_mesh_tx_appkey_get(pub->dev_role, pub->key);
if (!key) {
BT_ERR("%s, AppKey 0x%03x not exists", __func__, pub->key);
BT_ERR("Invalid AppKeyIndex 0x%03x", pub->key);
return -EADDRNOTAVAIL;
}
if (pub->msg->len + BLE_MESH_MIC_SHORT > MIN(BLE_MESH_TX_SDU_MAX, BLE_MESH_SDU_MAX_LEN)) {
BT_ERR("%s, Message does not fit maximum SDU size", __func__);
BT_ERR("Message does not fit maximum SDU size");
return -EMSGSIZE;
}
if (pub->count) {
BT_WARN("%s, Clearing publish retransmit timer", __func__);
BT_WARN("Clearing publish retransmit timer");
k_delayed_work_cancel(&pub->timer);
}
@ -1071,7 +882,7 @@ int bt_mesh_model_publish(struct bt_mesh_model *model)
tx.sub = bt_mesh_tx_netkey_get(pub->dev_role, ctx.net_idx);
if (!tx.sub) {
BT_ERR("%s, Subnet 0x%04x not exists", __func__, ctx.net_idx);
BT_ERR("Invalid NetKeyIndex 0x%04x", ctx.net_idx);
return -EADDRNOTAVAIL;
}
@ -1082,7 +893,7 @@ int bt_mesh_model_publish(struct bt_mesh_model *model)
sdu = bt_mesh_alloc_buf(pub->msg->len + BLE_MESH_MIC_SHORT);
if (!sdu) {
BT_ERR("%s, Failed to allocate memory", __func__);
BT_ERR("%s, Out of memory", __func__);
return -ENOMEM;
}
@ -1098,7 +909,7 @@ int bt_mesh_model_publish(struct bt_mesh_model *model)
}
struct bt_mesh_model *bt_mesh_model_find_vnd(struct bt_mesh_elem *elem,
u16_t company, u16_t id)
u16_t company, u16_t id)
{
int i;
@ -1112,8 +923,7 @@ struct bt_mesh_model *bt_mesh_model_find_vnd(struct bt_mesh_elem *elem,
return NULL;
}
struct bt_mesh_model *bt_mesh_model_find(struct bt_mesh_elem *elem,
u16_t id)
struct bt_mesh_model *bt_mesh_model_find(struct bt_mesh_elem *elem, u16_t id)
{
int i;

View file

@ -29,11 +29,6 @@ u8_t bt_mesh_elem_count(void);
/* Find local element based on unicast or group address */
struct bt_mesh_elem *bt_mesh_elem_find(u16_t addr);
struct bt_mesh_model *bt_mesh_model_find_vnd(struct bt_mesh_elem *elem,
u16_t company, u16_t id);
struct bt_mesh_model *bt_mesh_model_find(struct bt_mesh_elem *elem,
u16_t id);
u16_t *bt_mesh_model_find_group(struct bt_mesh_model *mod, u16_t addr);
bool bt_mesh_fixed_group_match(u16_t addr);

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