Compare commits

...

1666 Commits

Author SHA1 Message Date
c198f34f48 versions: Update version to 4.1.2 2021-07-28 17:46:16 +08:00
e17cdbf2fb Merge branch 'bugfix/idf_tools_not_found_issue_v4.1' into 'release/v4.1'
tools: Catch OSError which is raised when the tool is not available (v4.1)

See merge request espressif/esp-idf!14135
2021-07-20 08:19:22 +00:00
c7b83717b0 Merge branch 'bugfix/concurrent_mode_sae_crash_fix_v4.1' into 'release/v4.1'
esp_wifi: Fix some wifi bugs(v4.1)

See merge request espressif/esp-idf!14239
2021-07-20 04:11:46 +00:00
31594a0ae5 Merge branch 'bugfix/a2dp_deint_crash_v4.1' into 'release/v4.1'
fix a2dp deinit crash

See merge request espressif/esp-idf!14362
2021-07-20 03:14:34 +00:00
2fd3f8e076 Merge branch 'bugfix/SCO_connect_fail_after_peer_not_accept_sniff_v4.1' into 'release/v4.1'
bugfix/unable to initiate SCO connection when peer device not accept sniff mode (v4.1)

See merge request espressif/esp-idf!14365
2021-07-19 07:30:04 +00:00
865453bbe5 esp_wifi: Fix some wifi bugs
Add station based check for auth frame formation.
    Remove dependency of SHA256 AKM on PMF.
    Fix Block Ack setup issue in PMF scenario(aggregation issue).
2021-07-19 12:38:54 +05:30
b60af85f98 component/bt: Fix some bugs in bluetooth controller(2fcbe897)
1. Fixed BLE ACL tx flush issue during reset.
2. Added remove sniff when peer not accepted sniff mode
3. Fixed crash issue when using scan parameter(window=4 slot, interval=5 slot)
4. Removed duplicated events in lld_evt_end
2021-07-19 07:54:59 +08:00
d75cb43257 bugfix:Set address resolution enable. If not set enable and the filter
policy is 2 or 3, the controller will reply with invalid param error.
2021-07-19 07:54:59 +08:00
e1b0e367f5 Merge branch 'bugfix/rm_esp32s2beta' into 'release/v4.1'
esp_wifi: rm esp32s2beta in release v4.1

See merge request espressif/esp-idf!14154
2021-07-16 10:42:11 +00:00
2be0def9b5 Not initialized or in the process of de-initialization, calling API will return ERR 2021-07-16 16:49:17 +08:00
b681d4e415 fix a2dp deinit crash 2021-07-16 11:58:40 +08:00
8f7f429488 CI: remove ESP32S2Beta related jobs 2021-07-15 11:59:58 +08:00
ab830517bf CI: remove wifi lib md5 test on ESP32S2beta 2021-07-15 11:59:58 +08:00
9c897ef280 esp_wifi: rm esp32s2beta 2021-07-15 11:59:55 +08:00
c69ceefb27 Merge branch 'bugfix/timer_example_crashed_not_calling_timer_group_set_alarm_value_in_isr_v4.1' into 'release/v4.1'
driver/timer: fixed auto reload problem in default isr callback (backport to 4.1)

See merge request espressif/esp-idf!13531
2021-07-06 12:48:31 +00:00
47a5ef0b56 Merge branch 'bugfix/ringbuf_cache_disabled_test_v4.1' into 'release/v4.1'
esp_ringbuf: don't test xRingbufferCreate with cache disabled

See merge request espressif/esp-idf!14204
2021-07-02 05:52:05 +00:00
1f1de86ed9 Merge branch 'docs/windows_installer_2.9_backport_4.1' into 'release/v4.1'
docs: update Windows Tools 2.9 installation - backport 4.1

See merge request espressif/esp-idf!14191
2021-07-01 14:27:02 +00:00
1738f01c10 docs: update Windows Tools 2.9 installation 2021-06-30 12:47:51 +02:00
66e45d143b esp_ringbuf: don't test xRingbufferCreate with cache disabled
Creating a ringbuffer is not an operation that needs to be done when
the cache is disabled.
2021-06-30 12:01:19 +02:00
f8997beb0d Merge branch 'bugfix/fix_data_length_callback_param_err_v4.1' into 'release/v4.1'
Fixed data length update callback parameters error(back port v4.1)

See merge request espressif/esp-idf!14182
2021-06-30 05:57:58 +00:00
1b792c4687 Merge branch 'bugfix/gdbstub_threads_and_tests_v4.1' into 'release/v4.1'
gdbstub: fix thread list generation, add tests (v4.1)

See merge request espressif/esp-idf!14054
2021-06-30 04:28:09 +00:00
zwj
c6897a43ce - fix data length update failed
- fix no callback when the value being used is the same as the value to be set
2021-06-29 14:13:56 +08:00
9d82fc4447 Merge branch 'bugfix/pthread_join_debug_log_v4.1' into 'release/v4.1'
pthread: Fix possible deadlock when using pthread_join() and Debug log level (v4.1)

See merge request espressif/esp-idf!13778
2021-06-28 04:37:34 +00:00
62034d4432 Merge branch 'bugfix/i2s_apll_disable_issue_v4.1' into 'release/v4.1'
backport: Bugfix/i2s apll disable issue to release/v4.1

See merge request espressif/esp-idf!14008
2021-06-27 13:34:39 +00:00
9bd41e2431 Merge branch 'feature/mqtt_intro_new_modes_v4.1' into 'release/v4.1'
MQTT:  Update submodule reference to support new config modes (v4.1)

See merge request espressif/esp-idf!13709
2021-06-24 09:49:34 +00:00
7a8c9d88e9 tools: Catch OSError which is raised when the tool is not available
Closes https://github.com/espressif/esp-idf/issues/7140
2021-06-24 09:28:11 +02:00
da8f10bbac Merge branch 'test/wifi_connect_with_full_scan_in_examples_v4.1' into 'release/v4.1'
example: set example wifi scan method to all channel (v4.1)

See merge request espressif/esp-idf!13914
2021-06-24 06:14:26 +00:00
97c8be7194 Merge branch 'bugfix/fix_amsdu_fragment_vulnerability_v4.1' into 'release/v4.1'
esp_wifi: fix amsdu & fragment vulnerabilities(v4.1)

See merge request espressif/esp-idf!14077
2021-06-24 05:21:59 +00:00
1e9367f48e Merge branch 'bugfix/elf_sha256_first_byte_skip_v4.1' into 'release/v4.1'
app_update: fix incorrect first byte from esp_ota_get_app_elf_sha256 (v4.1)

See merge request espressif/esp-idf!13664
2021-06-24 01:55:30 +00:00
de3a428985 Merge branch 'feature/codeowners_v4.1' into 'release/v4.1'
add simplified CODEOWNERS file for older release branches (v4.1)

See merge request espressif/esp-idf!14092
2021-06-23 08:06:36 +00:00
cd961e7fff Merge branch 'bugfix/http_client_test_memcorupt_v4.1' into 'release/v4.1'
ci/test: Fix esp_http_client test not to use pointer after free (v4.1)

See merge request espressif/esp-idf!13702
2021-06-23 03:29:46 +00:00
f5db736aa6 example: set example wifi scan method to all channel:
in CI example test we could have runners with same SSID in the same lab.
Use scan on all channel will let DUT connect to the AP with best RSSI.
2021-06-23 10:16:48 +08:00
1ea2b57b41 Merge branch 'bugfix/ldgen_ignore_nonexistent_archives_and_obj_v4.1' into 'release/v4.1'
ldgen: check mappings (v4.1)

See merge request espressif/esp-idf!14058
2021-06-22 23:34:31 +00:00
5e2fceafa6 add simplified CODEOWNERS file for older release branches 2021-06-22 09:23:13 +02:00
fb9f140fa5 Merge branch 'bugfix/mqtt_examples_certificates_update_v4.1' into 'release/v4.1'
bugfix/mqtt examples: Updates the CA certificates used. (v4.1)

See merge request espressif/esp-idf!13127
2021-06-22 06:06:30 +00:00
51ee6e482e Merge branch 'feature/oocd_ver_backport_v4.1' into 'release/v4.1'
Feature/oocd ver backport v4.1

See merge request espressif/esp-idf!11379
2021-06-21 16:15:01 +00:00
004ea31cb7 Merge branch 'bugfix/loadable_elf_test_eco3_v4.1' into 'release/v4.1'
tests: gdb_loadable_elf: adjust the breakpoint location for ESP32 ECO3 (v4.1)

See merge request espressif/esp-idf!14041
2021-06-21 15:50:31 +00:00
6980b57a97 ci/test: Fix esp_http_client test not to use pointer after free 2021-06-21 21:47:39 +08:00
e0c2145cc7 bugfix/mqtt examples: Updates the CA certificates used.
- Updates the CA certificates.
- Updates the URI names to reflect the new URI in the service used in
  the examples.

Closes IDFGH-4986
Closes https://github.com/espressif/esp-idf/issues/6776
2021-06-21 21:45:08 +08:00
e2526915b7 esp_wifi: fix amsdu & fragment vulnerabilities 2021-06-21 19:26:43 +08:00
14e6b55923 Merge branch 'feat/ble_mesh_make_unprov_beacon_interval_configurable_v4.1' into 'release/v4.1'
Feat/ble mesh make unprov beacon interval configurable (v4.1)

See merge request espressif/esp-idf!14063
2021-06-21 09:22:28 +00:00
620049646d Merge branch 'bugfix/btdm_set_discoverable_after_create_server_v4.1' into 'release/v4.1'
components/bt: Set discoverable after create server

See merge request espressif/esp-idf!13727
2021-06-21 09:15:48 +00:00
16898897a9 ble_mesh: stack: Fix crash for net_key_del when subnet is NULL 2021-06-21 11:26:10 +08:00
9aecaa6fd0 ble_mesh: stack: Make unprovisioned beacon interval configurable.
Closes https://github.com/espressif/esp-idf/issues/6722
2021-06-21 11:26:03 +08:00
bf341d966c components: fix ldgen check errors 2021-06-21 09:52:03 +10:00
b9d288879d ci: exempt upstream libmbedtls mapping for sha256 2021-06-21 09:45:23 +10:00
23aff378f4 ldgen: fix sections info parsing
Fixes an issure where the first part of an object file name is not
included, due to matching the rule for a section entry previously.

Reduce depedency on matching literal strings in sections which might
change depending on toolchain (ex. matching 'elf32-xtensa-le')

Make sure parsing rule succeeds for the entirety of the sections info
string by adding 'parseAll=True'.

Add test for sections info parsing.
2021-06-21 09:45:23 +10:00
ffefe603ae ci: enabled ldgen mapping check in ci 2021-06-21 09:45:23 +10:00
8c6ec0bd48 ldgen: allow checking mappings 2021-06-21 09:36:26 +10:00
8ef0017662 gdbstub: fix thread list generation
This commit fixes an issue with gdbstub, where it would list threads
with TIDs 1 to N in qfThreadInfo/qsThreadInfo responses, and then
would tell GDB that the current TID is 0 in the qC response. This
caused an assertion failure in GDB, because it couldn't find the
thread structure corresponding to TID 0:

src/gdb/gdb/thread.c:93: internal-error: thread_info* inferior_thread(): Assertion `tp' failed.

The issue was caused by the logic of qfThreadInfo/qsThreadInfo.
If the "paniced" task index was 1, the code would report it in the
response to qfThreadInfo, and then mistakenly skip task with index 0
in qsThreadInfo, due to the use of pre-increment instead of a
post-increment.

With that issue fixed, GDB assertion doesn't happen anymore. However
the code contained a deeper problem, which manifested itself in the
fact that GDB would incorrectly show task index 0 as the current task,
after the above fix.

Previous version of the code assumed that when GDB requests the thread
list, it uses the first thread returned by the target as the "default"
thread, and subsequently shows the user that the program is stopped
in that thread. This assumption was incorrect. In fact, after
connecting to a remote target, GDB obtains information about the
"default" or "current" thread from two sources:
1. the 'thread' special register indicated in the status response
   ($T00thread;00000001#ee)
2. if the target has only sent the plain stop response ($T00#ee), GDB
   would ask for the current thread using a qC packet.
With that in mind, it is not necessary to report the paniced task as
the first task in qfThreadInfo response. We can simply returns the
tasks in their natural order, and then indicate the current task in
the qS packet response.

However even that change does not fully resolve the issues with task
list. The previous version of this code also incorrectly interpreted
the meaning of GDB TIDs -1 and 0. When GDB sends an "Hg0" command
early in the connection process, it doesn't expect the server to set
task 0 as the current task, as the code assumed. Rather, it tells the
server to "set any (arbitrary) task as the current one", and the most
logical thing to do for the server that is already in "stopped" state
is to keep the current task selection.

Since TID 0 has a special meaning in GDB remote protocol, gdbstub code
is now modified to map task indices (which start from 0) to GDB TIDs.
GDB TIDs are arbitrary, and for simplicity we keep the same order and
start counting them from 1.

The summary of all the above changes is:

1. Use "task index + 1" as the TID reported to GDB
2. Report the tasks in natural order; don't complicate the code to
   make the paniced task first in the list.
3. Centralize modification of 'current_task_index' and 'regfile'
   in the new 'set_active_task' function, to improve encapsulation.
2021-06-18 16:04:02 +02:00
0d5ec69adc tests: gdb_loadable_elf: adjust the breakpoint location for ESP32 ECO3
The previous location was the return from the first ets_printf call
that prints ROM sign-on message. Since the main function was patched
in ECO3, the new address no longer works — there is no instruction at
0x40007901 in ECO3 ROM. This could be solved by setting two
breakpoints (one would work for ECO <=2, the other for ECO3), but we
would need to remove the unused breakpoint later.
Fix this by setting the breakpoint at ets_printf. This means that when
debugging a loadable ELF the ROM sign-on message will no longer be
shown, but this doesn't seem to be an issue.
2021-06-18 15:10:06 +02:00
ac5511972f Merge branch 'bugfix/make_docs_ldgen_v4.1' into 'release/v4.1'
docs: remove quotes in ldgen documentation for adding fragment file (v4.1)

See merge request espressif/esp-idf!14002
2021-06-18 08:44:21 +00:00
4dab171c9f Merge branch 'bugfix/AuthValue_leak_v4.1' into 'release/v4.1'
ble_mesh: stack: Fix AuthValue Leak and Predictable AuthValue in Bluetooth... (v4.1)

See merge request espressif/esp-idf!14007
2021-06-18 06:09:37 +00:00
d8ef56e630 Merge branch 'docs/update_docs_for_doc_751_v4.1' into 'release/v4.1'
docs: update the documents based on customer feedbacks (v4.1)

See merge request espressif/esp-idf!13960
2021-06-17 10:14:00 +00:00
27fe437412 app_update: fix incorrect first byte from esp_ota_get_app_elf_sha256
At -O2 optimization level, GCC seems to optimize out the copying of the
first byte of the checksum, assuming it is zero. This "miscompilation"
happens because the esp_app_desc struct is declared const, but then modified
post-compilation. Casting to volatile disables the optimization.

Closes: https://github.com/espressif/esp-idf/pull/6389
2021-06-17 17:32:49 +08:00
bfcaa64b49 ble_mesh: stack: Fix AuthValue Leak and Predictable AuthValue in Bluetooth Mesh Provisioning Leads to MITM 2021-06-17 17:23:49 +08:00
41c82efcb9 i2s: fix driver uninstall issue 2021-06-17 16:37:11 +08:00
cb1a17e7ce Merge branch 'bugfix/impersonation_attacks_and_AuthValue_disclosure_v4.1' into 'release/v4.1'
ble_mesh: stack: Add check the value of Provisioning Random & Confirmation... (v4.1)

See merge request espressif/esp-idf!13930
2021-06-17 07:20:12 +00:00
c97984de99 docs: remove quotes in ldgen documentation for adding fragment file
Closes https://github.com/espressif/esp-idf/issues/5142
2021-06-17 09:13:40 +02:00
45ee699eae driver/timer: only re-enable alarm in callback when auto reload is true
closes https://github.com/espressif/esp-idf/issues/7001
2021-06-17 10:37:32 +08:00
4c453660ae ble_mesh: stack: Add check the value of Provisioning Random & Confirmation sent and received by provisioner 2021-06-16 17:03:38 +08:00
fd1a67dd61 Merge branch 'bugfix/spi_flash_cs_setup_v4.1' into 'release/v4.1'
spi_flash: fix cs line setup to make the flash driver more stable(backport v4.1)

See merge request espressif/esp-idf!13964
2021-06-16 07:36:06 +00:00
1f76c9014b Merge branch 'bugfix/start_emac_after_phy_reset_v4.1' into 'release/v4.1'
esp_eth: restart negotiation in esp_eth_start (v4.1)

See merge request espressif/esp-idf!13700
2021-06-16 06:00:32 +00:00
84f3d3e69a Merge branch 'bugfix/enable_pmf_in_iperf_test_v4.1' into 'release/v4.1'
iperf example: set PMF capable to connect to PMF required APs (v4.1)

See merge request espressif/esp-idf!13871
2021-06-16 04:39:17 +00:00
afb5248ec8 Merge branch 'bugfix/mdns_interface_del_crash_v4.1' into 'release/v4.1'
mdns: Fix of crash when wifi interface get deleted and mdns receives the packets(Backport v4.1)

See merge request espressif/esp-idf!13855
2021-06-15 12:00:10 +00:00
b1e5705bbd mdns: Fix of crash when wifi interface get deleted and mdns receives the packets
Closes https://github.com/espressif/esp-idf/issues/6973
2021-06-15 16:54:44 +08:00
5438706922 Merge branch 'bugfix/example_test_socket_issue_4.1' into 'release/v4.1'
CI: example test socket issue (4.1)

See merge request espressif/esp-idf!13906
2021-06-15 08:48:27 +00:00
cd99f0856c Merge branch 'bugfix/freemodbus_change_max_task_prio_v41' into 'release/v4.1'
Bugfix/freemodbus change max task prio (backport v4.1)

See merge request espressif/esp-idf!13721
2021-06-15 07:55:03 +00:00
7180526645 spi_flash: fix cs line setup to make the flash driver more stable 2021-06-15 15:11:47 +08:00
b9ca1e9b48 docs: update the documents based on customer feedbacks 2021-06-15 14:54:11 +08:00
d7612c14c9 Merge branch 'ci/unify_all_target_test_artifacts_paths_v4.1' into 'release/v4.1'
ci: unify target test artifacts to all .log file and $LOG_PATH (v4.1)

See merge request espressif/esp-idf!13850
2021-06-11 07:32:59 +00:00
a22cd6f542 Merge branch 'bugfix/btdm_enable_gattc_cache_will_crash_v4.1' into 'release/v4.1'
component/bt: fix enable gattc nvs cache lead to crash

See merge request espressif/esp-idf!13917
2021-06-10 02:56:50 +00:00
1f075dc346 Merge branch 'bugfix/btdm_incorrectly_spelled_v4.1' into 'release/v4.1'
component/bt: fix Spelling mistakes (release v4.1)

See merge request espressif/esp-idf!12817
2021-06-09 10:05:53 +00:00
9daeddac0b component/bt: Modify some ambiguous descriptions(release v4.1) 2021-06-09 14:14:18 +08:00
4789575f49 Merge branch 'bugfix/bt_impersonation_passkey_fix_v4.1' into 'release/v4.1'
Bluedroid: Check only x component of passkey to avoid passkey impersonation attack. (v4.1)

See merge request espressif/esp-idf!13760
2021-06-09 02:55:44 +00:00
dc433b50b0 test: fix socket issue in iperf example test 2021-06-08 17:20:32 +08:00
069182853e test: fix iperf example errors:
1. fix TypeError when running with python3
2. fix throughput chart x/y axis label error
3. make test case compatibile with iperf bin on earlier release branches
2021-06-08 17:20:18 +08:00
911cc3710b CI: fix connection failures in asio example tests 2021-06-08 17:18:45 +08:00
a1f743772f component/bt: fix enable gattc nvs cache lead to crash 2021-06-07 17:56:55 +08:00
74b48f1df7 Bluedroid: Check only x component of passkey to avoid passkey impersonation attack. 2021-06-07 07:18:16 +00:00
935deb4082 Merge branch 'bugfix/idfpy_global_action_callbacks_order_v4.1' into 'release/v4.1'
idf.py: Run global_action_callbacks in predictable order (v4.1)

See merge request espressif/esp-idf!13683
2021-06-07 05:09:49 +00:00
1e84e87f7f pthread: Fix possible deadlock when using pthread_join() and Debug log level
Possible for a joined task to be deleted at the moment it is logging,
meaning it might hold the stdout lock. In that case the lock isn't
released and the next task to try and take it (i.e. call printf)
will block indefinitely.
2021-06-07 02:15:36 +00:00
27a3d44f68 Merge branch 'bugfix/invalid_feat_page_exec_v4.1' into 'release/v4.1'
bt controller: Fixed handling for invalid feature page.

See merge request espressif/esp-idf!13573
2021-06-07 01:50:06 +00:00
381f2008ac example: set PMF capable to connect to PMF required APs 2021-06-04 17:59:57 +08:00
3e664c8a80 Merge branch 'bugfix/override_cmake_python_v4.1' into 'release/v4.1'
cmake: Minor Python CMake build fixes (v4.1)

See merge request espressif/esp-idf!13196
2021-06-04 05:27:38 +00:00
7b9f8c0e8c ci: unify target test artifacts to all .log file and $LOG_PATH 2021-06-03 17:45:35 +08:00
90a763b5a8 Merge branch 'bugfix/websocket_example_error_handling_v4.1' into 'release/v4.1'
ci: Fix websocket example test error handling (v4.1)

See merge request espressif/esp-idf!13807
2021-06-03 05:42:15 +00:00
eb36b63e7d bugfix/fix crash when lmp flooding 2021-06-02 09:48:30 +00:00
cf5d810bae components/bt: Delete BLE ADV priority high 2021-06-02 09:48:30 +00:00
a81a6c5471 bt controller: Fixed handling for invalid feature page. 2021-06-02 09:48:30 +00:00
c08d81a91f components/bt: fix PATH of libbtdm_app.a in build script 2021-06-02 09:48:30 +00:00
7e0abf78f9 Merge branch 'bugfix/partition_table_integrity_check_v4.1' into 'release/v4.1'
paritition_table: Verify the partition table md5sum when loading in the app (v4.1)

See merge request espressif/esp-idf!13584
2021-06-02 08:54:01 +00:00
8d1a99e026 paritition_table: Verify the partition table md5sum when loading the app
Additionally, always enable the partition MD5 check if flash encryption is on in
Release mode. This ensures the partition table ciphertext has not been modified
(CVE-2021-27926).

The exception is pre-V3.1 ESP-IDF bootloaders and partition tables, which
don't have support for the MD5 entry.
2021-06-02 16:31:19 +10:00
e836297b55 Merge branch 'feature/idf_tools_github_mirror_v4.1' into 'release/v4.1'
Add GitHub mirror option for IDF tools installs (v4.1)

See merge request espressif/esp-idf!13766
2021-06-01 09:48:12 +00:00
10785bc1e4 ci: Fix websocket example test error handling
If connection fails for websocket test, a second exception was generated in
__exit__
2021-06-01 17:18:56 +10:00
7c6ada7f86 Merge branch 'feature/installed_tool_failed_v4.1' into 'release/v4.1'
tools: Warning about tool being installed but failed to run. (v4.1)

See merge request espressif/esp-idf!13232
2021-05-31 17:25:24 +00:00
931577bc11 Merge branch 'feature/ci_release_zips_v4.1' into 'release/v4.1'
ci: Use GitHub Actions to generate recursive source code zips for releases (v4.1)

See merge request espressif/esp-idf!13200
2021-05-31 17:23:16 +00:00
ee15d4c3af Merge branch 'feature/IDF-2612_human_readable_error_v4.1' into 'release/v4.1'
export.bat/install.bat: print human-readable error message if Git or Python are not in PATH (v4.1)

See merge request espressif/esp-idf!13228
2021-05-31 17:22:22 +00:00
998b67094b freemodbus: increase max priority of modbus tasks
allows to avoid issues with modbus processing when higher priority tasks are used in user application
2021-05-31 12:20:15 +02:00
bb2ce2cb4e Merge branch 'bugfix/lwip_docs_delete_while_select_v4.1' into 'release/v4.1'
lw-IP: Add docs about not supported delete of task while blocked on select (v4.1)

See merge request espressif/esp-idf!13678
2021-05-31 02:36:14 +00:00
97b6b435a8 docs: Remove some uses of IDF_TARGET_NAME accidentally backported 2021-05-31 11:09:05 +10:00
c8906224fd add CN translation for index.rst in get started section for MR10616 2021-05-31 11:08:00 +10:00
fe3fd4d561 tools: windows installer: Modify IDF's archive mirror link 2021-05-31 11:06:19 +10:00
89568b73d6 tools: windows installer: add support for IDF_GITHUB_ASSETS
Adds a checkbox to download tools from dl.espressif.com mirror.
2021-05-31 11:06:19 +10:00
fd91bf4500 tools: Use GitHub download URLs for all files that can be downloaded from GitHub 2021-05-31 11:06:19 +10:00
f99c367e5d idf_tools: Add option to replace all GitHub tools download URLs with dl.espressif.com
Via new IDF_GITHUB_ASSETS environment variable.
2021-05-31 11:06:19 +10:00
fa34265c4b Merge branch 'ci/decrease_flash_performance_thr_4.1' into 'release/v4.1'
ci: decrease the flash performance threshold (4.1)

See merge request espressif/esp-idf!13747
2021-05-28 09:10:29 +00:00
1ddac24b0a ci: decrease the flash performance threshold 2021-05-27 14:07:01 +08:00
c0a586bdea components/bt: Set discoverable after create server 2021-05-26 11:36:08 +08:00
4ae45ff756 Merge branch 'ci/ttfw_fix_dut_exception_not_added_to_junit_report_v4.1' into 'release/v4.1'
ttfw: fix DUT exception not added to junit report (v4.1)

See merge request espressif/esp-idf!13612
2021-05-26 03:12:19 +00:00
3c3eab0bd8 Merge branch 'bugfix/fix_set_channel_error_after_wifi_stop_v4.1' into 'release/v4.1'
esp_wifi: Fix setting channel error after WiFi stop (backport v4.1)

See merge request espressif/esp-idf!13449
2021-05-25 14:53:11 +00:00
2a63d1058e Merge branch 'nimble/fix_ble_sm_sc_pub_key_v4.1' into 'release/v4.1'
NimBLE: Fix MITM vulnerability and free AES context (v4.1)

See merge request espressif/esp-idf!13598
2021-05-25 14:52:59 +00:00
3a12c7ee8d Merge branch 'bugfix/ag_use_dynamic_memory_error_v4.1' into 'release/v4.1'
Fix ag use dynamic memory error

See merge request espressif/esp-idf!13552
2021-05-25 14:28:21 +00:00
3319702355 NimBLE: Fix MITM vulnerability and free AES context (v4.1) 2021-05-25 14:47:22 +05:30
7c53e88b05 Remove btc_hf_idx_by_bdaddr in both btc_hf_init and btc_hf_deinit functions 2021-05-25 09:00:09 +00:00
5b5a36a7b2 fix ag use dynamic memory error 2021-05-25 09:00:09 +00:00
6aa902c509 MQTT: Update submodule reference to support new config modes
* Queueing publish messages to outbox when the client is not connected (default=off -> messages are queued if disconnected)
* Use of incremental msg-id instead of random id (default=off -> msg-id uses platform_random())
* Posting a new event-id if a queued message gets deleted from the outbox (default=off -> events are not posted)

Detailed description of included `esp-mqtt` changes
(da850b0add1e71b3659bfac5d797cc834dc3e89b...9ea804e0ab5368d5ab53ae2301a5fec9d1f12f1a)
* mqtt: Remove unused mqtt_header_state_t
  - esp-mqtt commit: b7158a4aea
  - esp-mqtt MR: espressif/esp-mqtt!84
  - Merges https://github.com/espressif/esp-mqtt/pull/180
* Cleanup public include dirs
  - esp-mqtt commit: f65d5d05db
  - esp-mqtt MR: espressif/esp-mqtt!85
* Config: Add a new option to use incremental message id
  - esp-mqtt commit: 8bb4a26f46
  - esp-mqtt MR: espressif/esp-mqtt!85
  - Closes https://github.com/espressif/esp-mqtt/issues/176
* Publish: Add new API to enqueue qos>0 messages
  - esp-mqtt commit: dc7fd5c0b1
  - esp-mqtt MR: espressif/esp-mqtt!85
  - Closes https://github.com/espressif/esp-mqtt/issues/155
* Config: Add a new option to disable publishing when disconnected
  - esp-mqtt commit: f44dcb1c26
  - esp-mqtt MR: espressif/esp-mqtt!85
  - Related https://github.com/espressif/esp-mqtt/issues/177
* Events: Add new event to report deleted messages from outbox
  - esp-mqtt commit: 2e35d4d4d5
  - esp-mqtt MR: espressif/esp-mqtt!85
* Publish: Allow for qos=0 messages to be stored using esp_mqtt_client_enqueue()
  - esp-mqtt commit: e2de0f3e3e
  - esp-mqtt MR: espressif/esp-mqtt!85
2021-05-25 09:56:29 +02:00
bf9587132b esp_eth: restart negotiation in esp_eth_start 2021-05-25 15:26:09 +08:00
83bda9f63e Run global_action_callbacks in predictable order 2021-05-24 18:20:39 +02:00
bd3de5c295 lwip: Add docs about not supported delete of task while blocked on select 2021-05-24 15:11:09 +02:00
f01bfeddb9 ttfw: fix DUT exception not added to junit report 2021-05-20 16:48:17 +08:00
ba35834ec8 Merge branch 'nimble/fix_host_flow_ctrl_v4.1' into 'release/v4.1'
NimBLE: Fix host flow control in NimBLE porting layer and host (release/v4.1)

See merge request espressif/esp-idf!13576
2021-05-19 09:50:15 +00:00
98116a627e NimBLE: Update submodule to fix host flow control bugs. 2021-05-18 18:46:26 +05:30
842a55cda3 NimBLE: Fix host flow control in NimBLE porting layer.
- Register `ble_hs_flow_acl_free` callback in NimBLE porting layer.
2021-05-17 19:53:37 +05:30
97a0523b34 Merge branch 'bugfix/timer_spinlock_iram_v4.1' into 'release/v4.1'
timer: add IRAM_ATTR to spinlock give/take API (v4.1)

See merge request espressif/esp-idf!13513
2021-05-15 17:21:27 +00:00
5241d68bf4 timer: add IRAM_ATTR to spinlock give/take API
Closes https://github.com/espressif/esp-idf/issues/6824
2021-05-13 16:07:01 +08:00
b1a5c00ee7 Merge branch 'bugfix/gtk_reinstallation_fix_v4.1' into 'release/v4.1'
wpa_supplicant: Prevent reinstallation of an already in-use group key (v4.1)

See merge request espressif/esp-idf!13183
2021-05-13 07:35:05 +00:00
e1af1fe126 wpa_supplicant: Group key reinstallation fixes
This commit reverts previous commit for GTK reinstallation fix
and corrects original fix.
2021-05-13 15:34:58 +08:00
4f06532e80 Merge branch 'bugfix/python3_target_test_4.1' into 'release/v4.1'
ci: using python3 to tun target test (4.1)

See merge request espressif/esp-idf!13017
2021-05-11 09:13:33 +00:00
966e45598b Merge branch 'bugfix/otatool_wrong_switch_ota_partition_slots_v4.1' into 'release/v4.1'
otatool: Fix incorrect using otadata.seq&crc in switch_ota_partition cmd (v4.1)

See merge request espressif/esp-idf!13369
2021-05-11 02:10:07 +00:00
49e26e05e9 tools: Updates OpenOCD version to 'v0.10.0-esp32-20210401' 2021-05-10 16:22:43 +00:00
0f1801d6b4 Merge branch 'bugfix/backport_some_lwip_bugs_0428_v4.1' into 'release/v4.1'
lw-ip:backport bugfix lwip for v4.1(backport 4.1)

See merge request espressif/esp-idf!13377
2021-05-10 05:37:29 +00:00
d3f11b1e9d Merge branch 'bugfix/fix_uart_set_rx_timeout_feature_v41' into 'release/v4.1'
Bugfix/fix uart set rx timeout feature (backport v4.1)

See merge request espressif/esp-idf!11538
2021-05-10 03:41:08 +00:00
538117a904 Bugfix/fix uart set rx timeout feature (backport v4.1) 2021-05-10 11:41:02 +08:00
3a0652602a cmake: Improve the error message if the Python interpreter fails to run
RESULT_VARIABLE will return a string not a number in this case, so display it
for the user.
2021-05-10 03:40:50 +00:00
b79fc8271f cmake: Set IDFTOOL variable using the correct PYTHON interpreter variable 2021-05-10 03:40:50 +00:00
b8afe13b3a cmake: Fix passing PYTHON path via CMake variable if using IDF as library
Closes https://github.com/espressif/esp-idf/issues/6285
2021-05-10 03:40:50 +00:00
099daf7873 Merge branch 'bugfix/fix_gpio_wakeup_light_sleep_backport_v4.1' into 'release/v4.1'
bugfix: gpio can't wakeup light sleep (backport v4.1)

See merge request espressif/esp-idf!12884
2021-05-10 03:37:28 +00:00
932ac7abf1 Merge branch 'nimble/add_error_prints_acl_buf_v4.1' into 'release/v4.1'
NimBLE: Add error prints for ACL buffer exhaustion in NPL (v4.1)

See merge request espressif/esp-idf!12970
2021-05-10 03:28:06 +00:00
2ac583cd12 Merge branch 'bugfix/endianness_in_output_or_input_oob_v4.1' into 'release/v4.1'
ble_mesh: stack: Fix endianness error in output or input oob data of number (v4.1)

See merge request espressif/esp-idf!13256
2021-05-10 03:27:40 +00:00
db84ddc82f Merge branch 'bugfix/btdm_fix_multi-con_pair_failed_and_cancle_con_state_err_v4.1' into 'release/v4.1'
fix multi con pair failed and cancel con state error (backport v4.1)

See merge request espressif/esp-idf!13476
2021-05-08 13:01:33 +00:00
6eb2b46592 Merge branch 'bugfix/generate_value_0_when_prov_auth_v4.1' into 'release/v4.1'
ble_mesh: stack: Fix provisioning input or output count number should be at least 1 (v4.1)

See merge request espressif/esp-idf!13481
2021-05-08 12:53:59 +00:00
f50680310e ble_mesh: stack: Fix provisioning input or output count number should be at least 1
Closes https://github.com/espressif/esp-idf/issues/6863
2021-05-08 12:01:11 +08:00
zwj
3d6b03d98c update con state when getting connection cancle complete 2021-05-07 20:51:55 +08:00
zwj
f4cadc56c0 fix multi-connection pair failed 2021-05-07 20:51:43 +08:00
13756c6a55 NimBLE: Add error prints for ACL buffer exhaustion in NPL 2021-05-07 09:47:01 +00:00
1b3ac526a7 ble_mesh: stack: Fix endianness error in output or input oob data of number
Closes https://github.com/espressif/esp-idf/issues/6862
2021-05-07 03:35:42 +00:00
9a8dbbc281 Merge branch 'bugfix/spi_fix_duplex_switch_v4.1' into 'release/v4.1'
spi_master: fix duplex mode switch issue for multi devices (4.1)

See merge request espressif/esp-idf!11234
2021-05-06 07:45:29 +00:00
b8520d0c9c esp_wifi: Fix setting channel error after WiFi stop 2021-05-06 11:52:26 +08:00
492297339c Merge branch 'bugfix/freertos_addition_overflow_v4.1' into 'release/v4.1'
freertos: Fix addition overflow (v4.1)

See merge request espressif/esp-idf!13424
2021-05-05 23:22:49 +00:00
189c04279c freertos: Check for arithmetic overflows on queue creation
Addition overflow check is from FreeRTOS kernel commit 47338393f1f79558f6144213409f09f81d7c4837
2021-05-04 18:35:38 +10:00
7355493a35 Merge branch 'bugfix/espsecure_args_v4.1' into 'release/v4.1'
esptool: Update to fix espsecure.py sign_data default version argument

See merge request espressif/esp-idf!13319
2021-05-03 05:53:43 +00:00
57ff3f92a5 esptool: Update to fix espsecure.py sign_data default version argument
Regression in Secure Boot signing, reported at https://github.com/espressif/esp-idf/issues/6831
2021-05-03 04:44:50 +00:00
63685a3a40 ci: Use GitHub Actions to generate recursive source code zips for releases
We do this for all ESP-IDF releases, this step automates it.

Uses action added in https://github.com/espressif/github-actions/pull/10
2021-05-03 04:19:58 +00:00
da66ddd4c1 Merge branch 'bugfix/remove_redundant_other_core_cache_disable_v4.1' into 'release/v4.1'
[system]: Remove redundant othercore cache disable (backport v4.1)

See merge request espressif/esp-idf!13358
2021-04-30 09:18:03 +00:00
cc9d0e1e99 Merge branch 'bugfix/wifi_softap_deep_sleep_current_opt_v4.1' into 'release/v4.1'
backport v4.1: optimize deep sleep current in wifi softap mode

See merge request espressif/esp-idf!13396
2021-04-30 02:50:50 +00:00
72b35dec11 backport bugfix lwip for v4.1 2021-04-29 13:03:26 +00:00
ffe4d844bf Merge branch 'bugfix/esp_http_client_read_v4.1' into 'release/v4.1'
Fix esp_http_client_read for file size aligned to 289 bytes (v4.1)

See merge request espressif/esp-idf!13307
2021-04-29 06:59:15 +00:00
f417181e62 deep sleep: optimize sleep current in wifi softap mode 2021-04-29 14:14:15 +08:00
9a29375f7d ci: run target test with python3 2021-04-28 18:10:34 +08:00
22ca7adccb esp_http_client_read: Add check for esp_http_client_is_complete_data_received before returning ESP_FAIL
Closes: https://github.com/espressif/esp-idf/issues/6772
2021-04-28 05:00:33 +00:00
f9ec761215 Merge branch 'docs/update_CN_trans_buildsystem_v4.1' into 'release/v4.1'
update CN translation for build-system,ulp,unit-tests,and idf-monitor for v4.1

See merge request espressif/esp-idf!13252
2021-04-28 02:47:08 +00:00
544fa05bd1 otatool: Fix incorrect using otadata.seq&crc in switch_ota_partition cmd
Closes: https://github.com/espressif/esp-idf/issues/6773
2021-04-27 19:41:17 +08:00
9fe035e4f5 docs:update CN translation for build-system,ulp,unit-tests,and idf-monitor for v4.1 2021-04-27 09:39:01 +00:00
dcd6e82826 remove othercore cache disable 2021-04-27 14:37:45 +08:00
97631de46c Human-readable error if Git or Python are missing.
When user forgot to add git.exe or python to the PATH, there was a not
very helpful error message.
This improves the error with which tool is misssing and shows a link to
the espressif installer tool.
2021-04-26 14:11:08 +02:00
2a82c353d9 tools: Warning about tool beiing installed but failed to run.
idf_tool.py runs "<tool> --version" which returns the error message but it is not used
This improves the error printing.
2021-04-26 13:55:45 +02:00
e17a8e1904 Merge branch 'bugfix/extern_c_decl_4.1' into 'release/v4.1'
[cxx]: fixed extern "C" declarations (backport 4.1)

See merge request espressif/esp-idf!12743
2021-04-23 09:59:51 +00:00
b63bbedc65 Merge branch 'bugfix/fix_partition_table_in_flash_encryption_example_v4.1' into 'release/v4.1'
example/flash_encryption: Fix partition table (v4.1)

See merge request espressif/esp-idf!10852
2021-04-23 08:08:58 +00:00
13b0633e8d [cxx]: fixed extern "C" declarations
* Moving #includes above
  #ifdef __cplusplus extern "C" { #endif
  So that we can compile with CPP.

Signed-off-by: Jakob Hasse <jakob.hasse@espressif.com>

Merges https://github.com/espressif/esp-idf/pull/6634
2021-04-23 07:35:47 +00:00
fe5c9bb03e Merge branch 'bugfix/calc_8m_freq_test_v4.1' into 'release/v4.1'
rtc: increase CI acceptance range for calc 8M test (v4.1)

See merge request espressif/esp-idf!13087
2021-04-23 07:32:03 +00:00
a418a52ea1 Merge branch 'bugfix/correct_cod_check_v4.1' into 'release/v4.1'
esp-idf: Corrected check of Class of Device for discovered devices (v4.1)

See merge request espressif/esp-idf!13021
2021-04-22 06:06:57 +00:00
75b10c80ff Merge branch 'bugfix/e8192_and_assert_param_v4.1' into 'release/v4.1'
Modify E8192 ELx200 ELx40 log level to LOGD

See merge request espressif/esp-idf!13149
2021-04-22 06:05:38 +00:00
12b6656d90 Synchronize multiple branch of bt-lib 2021-04-21 05:29:48 +00:00
c1215f27ed Modify E8192 ELx200 ELx40 log level to LOGD 2021-04-21 05:29:48 +00:00
92f41b098b Merge branch 'bugfix/broken_virtualenv_v4.1' into 'release/v4.1'
tools: Reinstall virtualenv if it is broken (v4.1)

See merge request espressif/esp-idf!12953
2021-04-20 23:34:20 +00:00
92aed6c759 Merge branch 'bugfix/fix_idf_monitor_unicode_path_crash_v4.1' into 'release/v4.1'
tools: handle exception in case of logging Unicode characters (v4.1)

See merge request espressif/esp-idf!13043
2021-04-20 23:33:38 +00:00
c6db3a426a Merge branch 'bugfix/ci/ci_fetch_submodule_fully_match_return_first_v4.1' into 'release/v4.1'
fix(ci): ci_fetch_submodule return full match name first (v4.1)

See merge request espressif/esp-idf!13212
2021-04-20 02:36:03 +00:00
97649c45eb fix(ci): ci_fetch_submodule return full match name first 2021-04-19 20:24:13 +08:00
6d5bb47512 Merge branch 'bugfix/doxygen_input_file_bug_v4.1' into 'release/v4.1'
docs: fix doxygen compile warnings for doxygen 1.9.1 (v4.1)

See merge request espressif/esp-idf!13078
2021-04-12 00:44:10 +00:00
7e839a82de docs: fix doxygen compile warnings for doxygen 1.9.1
Newer versions of doxygen will give warnings for comments in
INPUT lists

Delete all comment lines to fix these warnings, our folder structure
stil gives an OK overview of what we are including
2021-04-12 08:44:06 +08:00
02ce0744f0 rtc: increase CI acceptance range for calc 8M test 2021-04-09 15:06:37 +08:00
f60c8c8164 tools: handle exception in case of logging Unicode characters 2021-04-06 19:17:01 +02:00
c3f3dda7df esp-idf: Corrected check of Class of Device for discovered devices
Current code stopped inquiry if major class is not Phone. Modified the
condition to consider for both Phone and Audio to cover majority of real
world devices.

Closes https://github.com/espressif/esp-idf/issues/6548
2021-04-05 15:29:41 +05:30
a92185263e Merge branch 'bugfix/esp_netif_ppp_event_data_v4.1' into 'release/v4.1'
esp-netif: Fix PPP netif event posting to include esp_netif data (v4.1)

See merge request espressif/esp-idf!11869
2021-03-31 14:25:04 +00:00
3a535daa8c Merge branch 'feature/support_transport_keepalive_v4.1' into 'release/v4.1'
Feature/support transport keepalive v4.1 [backport v4.1]

See merge request espressif/esp-idf!12156
2021-03-31 09:37:03 +00:00
9ed4215787 Merge branch 'bugfix/ppp_netif_free_v4.1' into 'release/v4.1'
esp-modem: Remove esp-netif destroy from modem network glue code (v4.1)

See merge request espressif/esp-idf!11873
2021-03-31 09:36:41 +00:00
3826b80f3a Make OTA example support keepalive 2021-03-31 05:44:48 +00:00
9933037c0d Add options for esp_http_client and esp_websocket_client to support keepalive 2021-03-31 05:44:48 +00:00
f946e296a2 Modify esp-tls and tcp_transport to support keep alive for tcp and ssl connection 2021-03-31 05:44:48 +00:00
90cdceac39 esp-modem: Remove esp-netif destroy from modem network glue code
To be in line with other interfaces, when deleting the driver and it's glue layer to esp-netif, we DO NOT delete the related esp-netif (since is was allocated and created outside of the glue code and it works the same way in esp-eth and esp-wifi driver/glue layers).

Closes https://github.com/espressif/esp-idf/issues/5486
2021-03-31 05:44:39 +00:00
2da1f2059e esp-netif: Fix PPP netif event posting to include esp_netif data
Closes https://github.com/espressif/esp-idf/issues/6009
2021-03-31 05:43:39 +00:00
7638d92400 tools: Reinstall virtualenv if it is broken
Closes https://github.com/espressif/esp-idf/issues/6656
2021-03-29 19:25:59 +02:00
a395f3592b Merge branch 'bugfix/dport_init_min_stack_size_v4.1' into 'release/v4.1'
freertos: Increase minimum task stack size when stack smashing checker is enabled (v4.1)

See merge request espressif/esp-idf!12800
2021-03-29 06:26:36 +00:00
e71033b6ee Merge branch 'bugfix/remove_readdocs_badge_v4.1' into 'release/v4.1'
docs: remove read the docs badge (v4.1)

See merge request espressif/esp-idf!12843
2021-03-26 08:31:33 +00:00
44b47f79e1 Merge branch 'bugfix/btdm_controller_task_watchdog_in_wifi_test_v4.1' into 'release/v4.1'
Fix controller task watchdog in Wi-Fi test

See merge request espressif/esp-idf!12709
2021-03-25 06:32:21 +00:00
b7c4925d0b driver(gpio): fix gpio can't wakeup light sleep 2021-03-24 16:39:16 +08:00
69084bafec Merge branch 'bugfix/btdm_assert_without_sw_coex_enable_v4.1' into 'release/v4.1'
components/bt: Fix assert without sw coexist enabled

See merge request espressif/esp-idf!12528
2021-03-24 03:25:08 +00:00
056890a41a Merge branch 'bugfix/fix_some_wifi_bugs_0105_v4.1' into 'release/v4.1'
Bugfix/fix some wifi bugs 0105 v4.1 (backport v4.1)

See merge request espressif/esp-idf!11881
2021-03-23 16:36:07 +00:00
0d1da69fb3 docs: remove the read the docs CI badge
Docs are built and hosted on our server, so this badge is
no longer needed.
2021-03-23 12:21:14 +08:00
997ac7e166 Merge branch 'bugfix/spp_data_send_delay_v4.1' into 'release/v4.1'
Bugfix/spp data send delay v4.1

See merge request espressif/esp-idf!11773
2021-03-23 03:33:46 +00:00
21d2fa6934 Merge branch 'bugfix/mdns_txt_length_collision_v4.1' into 'release/v4.1'
mDNS: Fix of text length calculation when detecting a collision(Backport v4.1)

See merge request espressif/esp-idf!12028
2021-03-23 03:28:36 +00:00
645b200d73 Merge branch 'bugfix/wpa_supplicant_coverity_issue_fixes_v4.1' into 'release/v4.1'
Fix some issues raised by Coverity static Analyzer.(backport_v4.1)

See merge request espressif/esp-idf!11920
2021-03-23 03:27:44 +00:00
a38bbe46d0 Merge branch 'bugfix/btdm_blufi_send_custom_data_will_congested_after_connection_is_broken_v4.1' into 'release/v4.1'
component/bt: fix Blufi sends customer data will congested when connection is broken(backport v4.1)

See merge request espressif/esp-idf!11848
2021-03-23 03:20:27 +00:00
6f788a81dd Merge branch 'bugfix/ppp_deinit_failure_v4.1' into 'release/v4.1'
esp_modem: Fixed race condition on exiting PPP mode (v4.1)

See merge request espressif/esp-idf!11871
2021-03-23 03:14:07 +00:00
2750bb8e16 Merge branch 'bugfix/rtc_clk_cal_cycles_add_default_vals_for_all_sources_v4.1' into 'release/v4.1'
esp32xx: Fix default values for all RTC sources in RTC_CLK_CAL_CYCLES option (v4.1)

See merge request espressif/esp-idf!11413
2021-03-23 03:08:38 +00:00
150910ccd8 Merge branch 'bugfix/esp_netif_hostname_v4.1' into 'release/v4.1'
esp_netif: fix get/set hostname API to reflect user settings (v4.1)

See merge request espressif/esp-idf!11360
2021-03-23 03:08:21 +00:00
450f99f0f9 Merge branch 'bugfix/crash_on_enabling_verbose_logs_v4.1' into 'release/v4.1'
esp_wifi: Fixes issue of crashing when verbose logs are enabled (v4.1)

See merge request espressif/esp-idf!12494
2021-03-23 03:07:04 +00:00
8dabab4e36 Merge branch 'bugfix/fix_wifi_interface_use_v4.1' into 'release/v4.1'
esp_wifi: Modify ESP_IF_WIFI_STA to WIFI_IF_STA (backport v4.1)

See merge request espressif/esp-idf!12167
2021-03-23 03:06:42 +00:00
fe3ec246c0 Merge branch 'bugfix/ping_zero_interval_cause_to_assert_reset_v4.1' into 'release/v4.1'
lw-ip: Fixed ping assert reset when ping interval is 0 (v4.1)

See merge request espressif/esp-idf!12175
2021-03-22 12:59:36 +00:00
c277240dc6 esp_wifi: Modify ESP_IF_WIFI_AP to WIFI_IF_AP 2021-03-22 17:19:47 +08:00
4403af7267 esp_wifi: Modify ESP_IF_WIFI_STA to WIFI_IF_STA 2021-03-22 17:18:58 +08:00
d6d7a2ad12 Merge branch 'bugfix/fix_iperf_example_crash_issue_v4.1' into 'release/v4.1'
Bugfix/fix iperf example crash issue v4.1 (backport v4.1)

See merge request espressif/esp-idf!12021
2021-03-22 09:05:49 +00:00
cffcac6106 lwip: Fixed ping assert reset when ping interval is 0 2021-03-22 08:00:30 +00:00
6bd7cadc7b Merge branch 'bugfix/fatfs_v4.1' into 'release/v4.1'
spi_flash: fix the issue of ext_flash_fatfs_example(backport v4.1)

See merge request espressif/esp-idf!12666
2021-03-22 07:44:12 +00:00
c10fd0edb2 Merge branch 'bugfix/uart_read_o2_v4.1' into 'release/v4.1'
hal: workaround for UART FIFO read on ESP32 with -O2 optimization (backport v4.1)

See merge request espressif/esp-idf!12660
2021-03-22 07:41:40 +00:00
29422884d8 Merge branch 'bugfix/flash_encryption_v4.1' into 'release/v4.1'
ota: fix ota with flash encryption(backport v4.1)

See merge request espressif/esp-idf!12702
2021-03-22 06:13:38 +00:00
efcb1959bc Merge branch 'bugfix/fix_arp_buffer_error_in_smart_config_v4.1' into 'release/v4.1'
bugfix/fix_arp_buffer_error_in_smart_config_v4.1

See merge request espressif/esp-idf!12255
2021-03-22 06:10:40 +00:00
396cc61bab Merge branch 'bugfix/fix_iperf_example_exception_handling_for_no_ap_found_v4.1' into 'release/v4.1'
bugfix/fix_iperf_example_exception_handling_for_no_ap_found_v4.1

See merge request espressif/esp-idf!12272
2021-03-22 06:10:13 +00:00
b8c1824e37 Merge branch 'bugfix/spiram_reserve_size_pr5373_v4.1' into 'release/v4.1'
SPIRAM reserved memory size fixes (v4.1)

See merge request espressif/esp-idf!11517
2021-03-22 04:33:53 +00:00
1750acfa17 Merge branch 'bufix/ag_deep_copy_crash_v_4_1' into 'release/v4.1'
components/bt: Fix crash in btc_hf_arg_deep_copy when name or number is NULL

See merge request espressif/esp-idf!12793
2021-03-22 04:32:06 +00:00
bf86c59ec4 Merge branch 'component_bt/optimize_spp_stop_server_v4.1' into 'release/v4.1'
component_bt/Optimize SPP Stop Server API[backport v4.1]

See merge request espressif/esp-idf!12621
2021-03-22 04:31:28 +00:00
ff084d86b2 Merge branch 'bugfix/translation_link' into 'release/v4.1'
docs: fix "link to translation" being broken (v4.1)

See merge request espressif/esp-idf!12689
2021-03-19 07:47:00 +00:00
4afdc394c9 freertos: Add a small additional stack when optimization set to None
Fix for occasional crash on startup when DPORT task overwrites its stack during
context switch, otherwise.
2021-03-19 13:22:24 +08:00
280baea4f7 freertos: Increase minimum task stack size when stack smashing checker is enabled
Fixes issue with DPORT init task, this task uses minimum stack size and may not be
enough if stack smashing detection is set to Overall mode.

Also reworks the way we calculate minimum stack to allow for adding multiple
contributing factors.

Closes https://github.com/espressif/esp-idf/issues/6403
2021-03-19 13:22:10 +08:00
f8946dc471 components/bt: Fix crash in btc_hf_arg_deep_copy when name or number is NULL 2021-03-18 20:35:13 +08:00
4628a37435 Merge branch 'bugfix/bta_hf_client_sco_co_out_data_v4.1' into 'release/v4.1'
bugfix/if bta_hf_client_sco_co_out_data is called, it will crash when sco disconnected [backport v4.1]

See merge request espressif/esp-idf!12559
2021-03-18 04:05:14 +00:00
d70f854edb Merge branch 'bugfix/avrc_set_player_value_cmd_event_unhandle_v_4_1' into 'release/v4.1'
bugfix/fix unhandle RC vendor PDU when tg receive set_player_app_value cmd[backport v4.1]

See merge request espressif/esp-idf!12100
2021-03-18 04:04:49 +00:00
961f79612a Merge branch 'bugfix/btdm_backport_ble_bugs_21_01_29_v4.1' into 'release/v4.1'
Bugfix/btdm backport ble bugs v4.1

See merge request espressif/esp-idf!12433
2021-03-18 03:55:49 +00:00
a630e1317d add API esp_spp_stop_srv_scn to stop a specific server 2021-03-18 11:48:25 +08:00
e67d29b4e8 esp_wifi: Update WiFi lib
1. Change wifi scan duration from 120ms to 100ms
2. Using deport reg instead of ahb
3. Revert to report specific reason code when receiving deauth during 4-way-handshark
4. Fix the bug that tx ampdu parameter is not from peer device
5. Faster WiFi station connect improvement, avoid 100ms passive scan
6. Add FCS failed packets filter
7.Update esp32 phy lib to v4660
8.Fix country code last byte to space instead of NULL
9.Fix softap cannot forward A-MSDU
10.Fix some typos in esp_wifi.h
11.Fix max tx power to 20dBm
12.Fix the issue that the esp_wifi_sta_get_ap_info can't get country
13.Add support for 802.1x sha256 auth key mode
2021-03-17 15:30:09 +08:00
40f124b0d0 esp_wifi: Add macro control for phy log 2021-03-17 15:27:39 +08:00
c907da0656 esp_wifi: Add support for 802.1x sha256 auth key mode 2021-03-17 15:27:39 +08:00
37ce175bb5 esp_wifi: ESP32 phy add [sections:phy_iram] 2021-03-17 15:27:39 +08:00
f4bb2b466c esp_wifi: optimize phy version log 2021-03-17 15:27:39 +08:00
18b6ed65f1 bugfix: fix some wifi bugs
1. fix max tx power to 20dBm
2. fix the issue that the esp_wifi_sta_get_ap_info can't get country

Closes https://github.com/espressif/esp-idf/issues/6267
2021-03-17 15:27:39 +08:00
87968f8406 esp_wifi: Add documentation to avoid using WiFi modem sleep for WiFi/BT coexistence
Remove description of unusable API esp_wifi_restart()
Update esp_now_fetch_peer discription
Update description for ssid and password
2021-03-17 15:27:25 +08:00
2333667cb5 ota: fix ota with flash encryption 2021-03-12 16:44:06 +08:00
fa8d8de05e Merge branch 'bugfix/can_backport_accumulated_fixes_v4.1' into 'release/v4.1'
CAN backport accumulated fixes (backport v4.1)

See merge request espressif/esp-idf!11460
2021-03-11 14:01:18 +00:00
43ee2976f2 Fix controller task watchdog in Wi-Fi test 2021-03-11 17:21:01 +08:00
63e4510e9e flash_encryption: Quick fixed the issue that block when flash_encryption_write, Related https://github.com/espressif/esp-idf/issues/6322, Related https://github.com/espressif/esp-idf/issues/6254 2021-03-11 14:11:01 +08:00
e4af49ca23 docs: fix "link to translation" being broken
The translation link would link a specifc commit hash instead of
the release name.
2021-03-10 18:55:43 +08:00
98c4c98840 spi_flash: fix flash issue of ext_flash_fatfs_example 2021-03-09 18:34:47 +08:00
8db219c292 hal: workaround for UART FIFO read on ESP32 with -O2 optimization 2021-03-09 14:18:28 +08:00
fb2d6a44eb CAN: ISR runs when cache is disabled
This commit adds the feature where the CAN ISR will continue to
run even if the cache is disabled. Whilst cache is disabled, any
received messages will go into the RX queue, and any pending TX
messages in the TX queue will be transmitted. This feature should
be enabled using the CONFIG_CAN_ISR_IN_IRAM option.
2021-03-09 08:47:58 +08:00
c2afe02507 CAN: Fix BRP field initialization onf ESP32 ECO3
This commit zero initializes the brp_div field on ESP32 ECO3
to prevent incorrect timing configuration.
2021-03-09 08:47:58 +08:00
5311a60af2 CAN: Simplify caps header
This commit simplifies the defines made in the _caps.h header. Kconfig
option dependencies were moved into the LL, and the check for a
valid BRP has bee simplified.
2021-03-09 08:47:57 +08:00
da1ed49a65 Merge branch 'docs/fix_broken_example_links_for_releasev4.1' into 'release/v4.1'
docs: fix broken example links for release v4.1

See merge request espressif/esp-idf!12503
2021-03-08 08:22:04 +00:00
356bf67443 Merge branch 'bugfix/fix_tx_issue_after_esp_restart_v4.1' into 'release/v4.1'
components/bt: Shutdown Bluetooth before esp_restart.(V4.1)

See merge request espressif/esp-idf!11756
2021-03-05 12:29:27 +00:00
8cfb4a2426 Merge branch 'bugfix/fix_csa_channel_crash_v4.1' into 'release/v4.1'
esp_wifi: fix CSA and BAR crash issue(v4.1)

See merge request espressif/esp-idf!12550
2021-03-05 12:24:18 +00:00
f71577afe0 Merge branch 'feature/add_init_and_deinit_evt_for_a2dp_4_1' into 'release/v4.1'
feature/ Add A2DP Init and Deinit Complete Evt [backport v4.1]

See merge request espressif/esp-idf!12151
2021-03-05 12:21:12 +00:00
34e1d1d69f Merge branch 'bugfix/fix_a2dp_underrun_issue_4_1' into 'release/v4.1'
Fix A2DP Underrun Issue [backport v4.1]

See merge request espressif/esp-idf!12278
2021-03-05 12:18:45 +00:00
4567b6e866 Merge branch 'bugfix/correct_logging_timestamp_format_v4.1' into 'release/v4.1'
log: correct timestamp formatting to unsigned integer type (v4.1)

See merge request espressif/esp-idf!12612
2021-03-05 09:27:04 +00:00
08333362e3 Merge branch 'fix/esp_tls_typo_v4.1' into 'release/v4.1'
Fix/esp_tls_mispaced_paranthesis (v4.1)

See merge request espressif/esp-idf!12632
2021-03-05 08:51:50 +00:00
5b215dbc9e protocomm: Fixed NULL check of allocated memory
Fixes one part of - https://github.com/espressif/esp-idf/issues/6440
2021-03-05 10:10:55 +05:30
b8274496f9 esp_tls: Fix misplaced paranthesis in esp_tls_mbedtls.c
Fixes one part of -  https://github.com/espressif/esp-idf/issues/6440
2021-03-05 10:10:55 +05:30
188eb221aa log: correct timestamp formatting to unsigned integer type
Closes https://github.com/espressif/esp-idf/issues/6226

Closes IDFGH-4393
2021-03-04 11:54:47 +05:30
ca9ff949a1 Merge branch 'bugfix/ci_stdout_encoding_v4.1' into 'release/v4.1'
ci: Fix missing sys.stdout.encoding in python2 runners (v4.1)

See merge request espressif/esp-idf!12597
2021-03-04 04:05:37 +00:00
d481781180 Merge branch 'bugfix/fix_spp_vfs_dynamic_memory_bugs_v4.1' into 'release/v4.1'
component_bt/fix spp vfs demo crash when use dynamic memory[backport v4.1]

See merge request espressif/esp-idf!11728
2021-03-04 03:34:43 +00:00
2c4f90dab2 ci: Fix missing sys.stdout.encoding in python2 runners
Regression in fed98cd6ad
2021-03-04 09:27:26 +11:00
a7302a6880 esp_wifi: fix CSA and BAR crash issue 2021-03-02 11:32:46 +08:00
cc49472ea4 components/bt: Fix crash in Bluetooth when esp_restart 2021-03-01 14:46:26 +08:00
fdfc95812c components/bt: Shutdown Bluetooth before esp_restart. 2021-03-01 14:46:05 +08:00
ad93815681 Merge branch 'bugfix/esp_wifi_deinit_v4.1' into 'release/v4.1'
esp_wifi_deinit: Return ESP_ERR_WIFI_NOT_STOPPED if wifi is not stopped (v4.1)

See merge request espressif/esp-idf!12541
2021-03-01 03:53:42 +00:00
195160af94 bugfix/if bta_hf_client_sco_co_out_data is called, it will crash when sco disconnected 2021-03-01 11:38:35 +08:00
1f79b580f9 Merge branch 'bugfix/ttfw_example_test_fails_port_remains_open_v4.1' into 'release/v4.1'
ci: Fix CI issue if one example test fails, and if serial port returns some noise (v4.1)

See merge request espressif/esp-idf!12382
2021-02-28 23:57:04 +00:00
b68f07dbc7 esp_wifi: Fixes issue of crashing when verbose logs are enabled. 2021-02-26 19:11:17 +05:30
761a3cdeae esp_wifi_deinit: Return ESP_ERR_WIFI_NOT_STOPPED if wifi is not stopped
Add test case to test this workflow
2021-02-26 14:56:42 +05:30
54c71781a9 components/bt: Fix assert without sw coexist enabled 2021-02-26 14:33:01 +08:00
657ae5e11e Merge branch 'feat/spi_flash_override_size_v4.1' into 'release/v4.1'
spi_flash: add config option to override flash size in bootloader header (v4.1)

See merge request espressif/esp-idf!12457
2021-02-26 02:08:39 +00:00
8ed7a899d7 Merge branch 'bugfix/ble_mesh_server_model_deinit_v4.1' into 'release/v4.1'
ble_mesh: stack: Fix deinit server models with no matching id (v4.1)

See merge request espressif/esp-idf!12316
2021-02-25 11:09:48 +00:00
90118531a7 docs: fix broken example links for release v4.1 2021-02-25 13:41:04 +08:00
fcef475989 Merge branch 'bugfix/esptool_version_v4.1' into 'release/v4.1'
esptool: Update esptool to latest v2.x version

See merge request espressif/esp-idf!11487
2021-02-24 22:30:37 +00:00
b6bc7e9df8 Merge branch 'revert-983220e2_v4.1' into 'release/v4.1'
ci: enable RS485 related tests again (v4.1)

See merge request espressif/esp-idf!12464
2021-02-24 06:45:13 +00:00
0503b02312 Merge branch 'docs/remove_rtd_pdf_link_v4.1' into 'release/v4.1'
docs: remove rtd pdf link (v4.1)

See merge request espressif/esp-idf!12467
2021-02-23 10:46:30 +00:00
10311644e4 docs: remove RTD download PDF links
PDF download is available from the version selector menu.
Read the docs links are out of date.
2021-02-23 11:46:06 +08:00
46d8dad2e1 Revert "ci: temporarily disable RS485 related tests"
This reverts commit 983220e216
2021-02-23 11:02:10 +08:00
f6da7f3305 spi_flash: add config option to override flash size in bootloader header
Sometimes the flash size read from bootloader is not correct. This may
forbid SPI Flash driver from reading the the area larger than the size
in bootloader header.

When the new config option is enabled, the latest configured
ESPTOOLPY_FLAHSIZE in the app header will be used to override the value
read from bootloader header.
2021-02-23 01:23:53 +08:00
52496189d9 Merge branch 'bugfix/freemodbus_fix_parity_propagation_issue_v41' into 'release/v4.1'
Bugfix/freemodbus fix parity propagation issue (Backport v4.1)

See merge request espressif/esp-idf!12388
2021-02-22 05:26:31 +00:00
zwj
ed04398a8c add connection parameter check 2021-02-22 11:29:06 +08:00
zwj
62396e3b23 fix ble connection maximum latency is 499 2021-02-22 11:28:55 +08:00
zwj
37c2b7e9b7 disable bluedroid congest error log print 2021-02-22 11:28:42 +08:00
490af40be5 fix read multi char failed(GATT_27001) 2021-02-22 11:28:25 +08:00
89a1f8e7a9 fix add white list failed 2021-02-22 11:28:07 +08:00
zwj
c1f23ada19 fix bluedroid repair faild if the two most significant bits of public address is '01' 2021-02-22 11:27:54 +08:00
zwj
1b6572ec9f - fix congest return value
- fix system no rsp when doing disconnect
- fix no congest event when ssc do writing performance
2021-02-22 11:27:39 +08:00
zwj
0e2236a2f1 fix ble read multi char err when the number of handles is more than 10 2021-02-22 11:27:22 +08:00
zwj
e109c9980c fix scan rsp length err 2021-02-22 11:27:09 +08:00
zwj
a2eec8a1e2 fix vendor hci memory leak 2021-02-22 11:26:56 +08:00
b1c383211c Merge branch 'bugfix/eclipse_make_decode_v4.1' into 'release/v4.1'
tools: Fix Eclipse build: “UnicodeDecodeError: 'ascii' codec can't decode byte” (v4.1)

See merge request espressif/esp-idf!12359
2021-02-19 15:55:47 +00:00
dc70cd1304 Merge branch 'feature/prefer_python3_in_installer_v4.1' into 'release/v4.1'
tools: Prefer python3 during install and export (v4.1)

See merge request espressif/esp-idf!12378
2021-02-19 15:53:29 +00:00
e7e776a535 Merge branch 'bugfix/fix_enable_reset_provision_cause_device_crash_v4.1' into 'release/v4.1'
provisioning: Fix enable CONFIG_EXAMPLE_RESET_PROVISIONED will cause device crash [backport v4.1]

See merge request espressif/esp-idf!12351
2021-02-19 12:39:43 +00:00
lly
6b6a883824 ble_mesh: stack: Fix deinit server models with no matching id 2021-02-19 01:03:55 +00:00
77feee975e Merge branch 'bugfix/ignore_null_valued_comb_key_4_1' into 'release/v4.1'
Bugfix/ignore null valued comb key 4 1

See merge request espressif/esp-idf!12408
2021-02-18 13:58:52 +00:00
a585bb54e4 bt: NULL combkey check and fixed divide by zero error.
- Added check for NULL valued combination key. (cbc69c8b9)
- Fix divided by zero err & clear timer after remote reject when respond the parameters update (d886f91)
2021-02-18 15:37:20 +05:30
471237dab6 freemodbus: fix mb controller parity propagation issues
Closes https://github.com/espressif/esp-idf/issues/6377
2021-02-17 12:34:00 +01:00
8938eed1c4 Merge branch 'bugfix/softap_prov_cookies_v4.1' into 'release/v4.1'
protocomm_httpd: Use HTTP cookies to track session (v4.1)

See merge request espressif/esp-idf!12266
2021-02-15 04:45:14 +00:00
fed98cd6ad ci: ttfw: Encode serial port data to whatever the console encoding is
This is a bit of a hack, but gives us a way to always log it
2021-02-15 10:48:30 +11:00
65fb2ead1a ci: Log failure to close any DUT 2021-02-15 10:48:30 +11:00
52ecfeb337 tools: Prefer python3 during install and export
Install and export script should work on systems without "python"
executable.

Closes https://github.com/espressif/esp-idf/pull/6471

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

Related to https://github.com/espressif/esp-idf/issues/6421 and
https://github.com/espressif/arduino-esp32/issues/4717
2021-02-14 19:46:28 +01:00
3a5be7ce26 protocomm security1: Restart security session if SESSION_STATE_CMD0 is received
With the introduction of cookies to track a session, it is possible that the
clients restart the provisioning on the same session, specifically when a user
cancels a current provisioning attempt. This can result in an error as the state
on the device side and client side will go out of sync.

This has now been changed such that if SESSION_STATE_CMD0 is received on
an existing session, the state is reset and flow allowed to continue.
2021-02-12 05:53:00 +00:00
c13fe0be6e protocomm_httpd: Use HTTP cookies to track session
Earlier, a "socket connection" was being considered as a protocomm "session".
However, for HTTP, we cannot expect clients to necessarily use the same
socket for all requests of a given transaction. This was indeed causing
some failures for Wi-Fi provisioning from Android phones.

So, we have introduced http cookies to track a session even if the socket
connection does not stay intact throughout the transaction.
This change is backward compatible. If the client does not use cookies, the
socket connection will be considered as the session.

Closes: https://github.com/espressif/esp-idf/issues/6316
Reference: https://github.com/espressif/esp-idf/pull/6330
2021-02-12 05:53:00 +00:00
ba17e97665 Merge branch 'bugfix/get_component_requirements_v4.1' into 'release/v4.1'
cmake: fix getting component requirements (v4.1)

See merge request espressif/esp-idf!9714
2021-02-11 07:56:19 +08:00
85b96879f2 Fix eclipse build: “UnicodeDecodeError: 'ascii' codec can't decode byte”
Closes https://github.com/espressif/esp-idf/pull/6505
2021-02-10 12:50:39 +01:00
428e9b008c Bluedroid: Do not initiate/accept connection with device having same BDADDR.
Added BD_ADDR comparison in l2cu_lcp_allocate and removed check from
security connection request handler as it's handled in l2cu_lcp_allocate
for both connection request and create connection.
2021-02-10 15:13:10 +05:30
1c6c6998bc bt: removed esp_bt_get_mac()
There was no need for this function as there is already a way present to
fetch own mac address. Own mac addr can be fetched by calling
controller_get_interface().
2021-02-10 15:13:02 +05:30
b497628ef6 provisioning: Fix enable CONFIG_EXAMPLE_RESET_PROVISIONED will cause device crash 2021-02-10 16:05:26 +08:00
131bfd90a4 Merge branch 'bugfix/ble_mesh_mbedtls_aes_fix_v4.1' into 'release/v4.1'
Bugfix/ble mesh mbedtls aes fix (v4.1)

See merge request espressif/esp-idf!12326
2021-02-09 16:24:54 +08:00
42b126e4dd Merge branch 'bugfix/sign_compare_warning_in_soc_component' into 'release/v4.1'
fix sign compare warning in soc component

See merge request espressif/esp-idf!11434
2021-02-09 11:05:12 +08:00
e508a64ae9 Merge branch 'bugfix/mcpwm_can_set_two_falut_signal_v4.1' into 'release/v4.1'
mcpwm: fix second fault line broken issue (v4.1)

See merge request espressif/esp-idf!12172
2021-02-08 14:21:43 +08:00
261d107abd Merge branch 'bugfix/ble_mesh_log_macro_v4.1' into 'release/v4.1'
ble_mesh: stack: Add prefix for log macros (v4.1)

See merge request espressif/esp-idf!12325
2021-02-07 16:39:38 +08:00
528e9b2818 Merge branch 'bugfix/ble_mesh_prov_use_diff_rand_v4.1' into 'release/v4.1'
ble_mesh: stack: Use different random for each provisioning (v4.1)

See merge request espressif/esp-idf!12323
2021-02-07 16:38:42 +08:00
47d859b2a4 Merge branch 'bugfix/ble_mesh_proxy_client_net_resend_v4.1' into 'release/v4.1'
ble_mesh: stack: Fix proxy client may fail to resend msg (v4.1)

See merge request espressif/esp-idf!12322
2021-02-07 16:38:36 +08:00
9ef16af05e Merge branch 'bugfix/ble_mesh_node_set_name_status_check_v4.1' into 'release/v4.1'
ble_mesh: stack: Remove node set device name return status check (v4.1)

See merge request espressif/esp-idf!12321
2021-02-07 16:38:25 +08:00
3a06fa4bd9 Merge branch 'update/ble_mesh_set_hsl_states_v4.1' into 'release/v4.1'
ble_mesh: stack: Enable updating lighting hsl state (v4.1)

See merge request espressif/esp-idf!12320
2021-02-07 16:38:13 +08:00
afcbf0d311 Merge branch 'bugfix/ble_mesh_macro_OR_v4.1' into 'release/v4.1'
ble_mesh: stack: Fix using wrong | for OR between macros (v4.1)

See merge request espressif/esp-idf!12319
2021-02-07 16:37:58 +08:00
47d6b3f2b3 Merge branch 'bugfix/ble_mesh_build_error_c3_merge_master_v4.1' into 'release/v4.1'
Bugfix/ble mesh build error merge master (v4.1)

See merge request espressif/esp-idf!12318
2021-02-07 16:37:49 +08:00
lly
10b5436cc9 ble_mesh: stack: Fix mbedtls aes ctx not deallocated 2021-02-07 12:06:49 +08:00
lly
5e8695d7be ble_mesh: stack: Fix mbedtls aes ctx not initialized 2021-02-07 12:06:49 +08:00
lly
829b16a997 ble_mesh: stack: Fix compile warning when log is disabled 2021-02-07 12:03:24 +08:00
lly
7b5a3b50f0 ble_mesh: ci: Add disable log sdkconfig test files 2021-02-07 12:03:24 +08:00
lly
cb918dcd2f ble_mesh: stack: Add prefix BLE_MESH_ for log related macros 2021-02-07 12:03:24 +08:00
lly
638b36cc6b ble_mesh: stack: Use different random for each provisioning 2021-02-07 11:46:20 +08:00
lly
59443eca02 ble_mesh: stack: Fix proxy client may fail to resend msg 2021-02-07 11:44:13 +08:00
lly
7799954d99 ble_mesh: stack: Remove node set device name return status check 2021-02-07 11:41:57 +08:00
lly
fc27117299 ble_mesh: stack: Enable updating lighting hsl state 2021-02-07 11:39:53 +08:00
lly
eb52b1da96 ble_mesh: stack: Fix using wrong | for OR between macros 2021-02-07 11:36:45 +08:00
lly
4e8a53aec2 ble_mesh: stack: Fix compile warning with BIT macro 2021-02-07 11:33:00 +08:00
lly
938530b193 ble_mesh: stack: Update mesh max conn macro when using bluedroid 2021-02-07 11:32:55 +08:00
c6f7abbe94 Merge branch 'feat/ble_mesh_support_ble_scan_v4.1' into 'release/v4.1'
ble_mesh: stack: Add BLE scan callback when mesh is enabled (v4.1)

See merge request espressif/esp-idf!12304
2021-02-07 11:22:50 +08:00
e2886115dc mcpwm: fix second fault line broken
Closes: https://github.com/espressif/esp-idf/issues/6053
2021-02-06 21:45:51 +08:00
e85a444cd0 mcpwm: fix wrong capture edge 2021-02-06 21:45:51 +08:00
lly
2d04130ce0 ble_mesh: ci: Add ble & ble mesh coex sdkconfig test files 2021-02-05 21:22:52 +08:00
lly
bdf6d3e8cb ble_mesh: stack: Support reporting normal ble adv packets 2021-02-05 21:22:52 +08:00
lly
e06a5587c7 ble_mesh: stack: Add a btc file for ble coex functions
Previously if starting/stopping BLE advertising when BLE Mesh
is enabled, the corresponding events will be notified through
the callback registered by esp_ble_mesh_register_prov_callback().

With this commit, the func esp_ble_mesh_register_ble_callback()
needs to be invoked for resgitering the callback used for BLE
coexistence related functionalities (i.e. ADV/SCAN).
2021-02-05 21:22:52 +08:00
lly
228ab398b9 ble_mesh: stack: Move ble scan funcitons to a single file 2021-02-05 21:22:52 +08:00
lly
9cff5797a1 ble_mesh: stack: Optimize handling received mesh adv packets 2021-02-05 21:22:52 +08:00
53317da676 Merge branch 'optimize/ble_mesh_miscellaneous_v4.1' into 'release/v4.1'
Optimize/ble mesh miscellaneous (v4.1)

See merge request espressif/esp-idf!12293
2021-02-05 21:00:35 +08:00
lly
1cdd2b0609 ble_mesh: stack: Move bt_mesh_rand to mesh_common.c 2021-02-05 14:55:38 +08:00
lly
a0da80fe89 ble_mesh: stack: Remove useless BT_DBG_ENABLED in a few files 2021-02-05 14:55:33 +08:00
lly
f3ff34d818 ble_mesh: Replace zephyr integer types with C99 types [Zephyr] 2021-02-05 14:55:11 +08:00
lly
392fb4b916 ble_mesh: stack: Update ARRAY_SIZE definition 2021-02-05 14:54:17 +08:00
8812365c6f Merge branch 'feat/ble_mesh_multiple_nvs_namespace_v4.1' into 'release/v4.1'
ble_mesh: stack: Provisioner supports multiple nvs namespaces (v4.1)

See merge request espressif/esp-idf!12264
2021-02-05 14:49:32 +08:00
9d76fd62d7 Merge branch 'test/disable_twai_example_ci_v4.1' into 'release/v4.1'
Temporarily disable TWAI network example test (backport v4.1)

See merge request espressif/esp-idf!11562
2021-02-05 13:00:02 +08:00
a60e9c136b Merge branch 'fix/wolfssl_domain_name_check_v4.1' into 'release/v4.1'
esp_tls_wolfssl : Add domain name check (v4.1)

See merge request espressif/esp-idf!11817
2021-02-05 12:07:11 +08:00
lly
968d0fbb13 ble_mesh: ci: Add settings sdkconfig test files 2021-02-05 03:10:47 +00:00
lly
c1f3b20273 ble_mesh: stack: Provisioner supports multiple nvs namespaces
Now Provisioner can use different NVS namespaces to store
different instances of mesh information, for example, for
different user accounts.
2021-02-05 03:10:47 +00:00
b91448aa03 Merge branch 'ci/increase_cmake_build_parallel_count_v4.1' into 'release/v4.1'
ci: Increase cmake build parallel count

See merge request espressif/esp-idf!12282
2021-02-05 10:46:57 +08:00
fb63cf75ad Merge branch 'bugfix/idf_monitor_baudrate_arg_crash_v4.1' into 'release/v4.1'
idf monitor: fix crash when monitor baudrate argument set (Backport 4.1)

See merge request espressif/esp-idf!9759
2021-02-05 10:08:13 +08:00
834089c4b2 Merge branch 'bugfix/protocomm_http_print_v4.1' into 'release/v4.1'
protocomm_httpd: Change an info print to debug print as it isn't really required in the logs (v4.1)

See merge request espressif/esp-idf!12262
2021-02-04 21:28:26 +08:00
lly
a47f4ae9fe ci: Increase cmake build parallel count 2021-02-04 20:48:22 +08:00
e2dd35e6f6 Fix A2DP Underrun Issue 2021-02-04 19:33:50 +08:00
bebd1b4106 add exception handling for iperf example's scan when no ap was found 2021-02-04 17:49:13 +08:00
6ebb73df7c protocomm_httpd: Change an info print to debug print as it isn't really required in the logs 2021-02-04 15:04:43 +05:30
52f661fa41 Merge branch 'feat/ble_mesh_provisioner_recv_hb_support_v4.1' into 'release/v4.1'
Feat/ble mesh provisioner recv hb support (v4.1)

See merge request espressif/esp-idf!11914
2021-02-04 17:13:20 +08:00
lly
45e0d59b3b ble_mesh: ci: Add enabling hb recv sdkconfig file 2021-02-04 03:33:45 +00:00
lly
ad718c53cd ble_mesh: stack: Provisioner supports receiving heartbeat 2021-02-04 03:33:45 +00:00
53398c646a fix smartconfig issue when router reply arp late 2021-02-04 11:33:23 +08:00
8ba74ad9f7 Merge branch 'optimize/ble_mesh_provision_dev_uuid_check_v4.1' into 'release/v4.1'
ble_mesh: stack: Need uuid when adding device for provisioning (v4.1)

See merge request espressif/esp-idf!11578
2021-02-04 10:57:01 +08:00
lly
1b2748e00f ble_mesh: ci: Add PB-ADV & PB-GATT sdkconfig test files 2021-02-03 08:45:18 +00:00
lly
ecf8427b1e ble_mesh: stack: Need uuid when adding device for provisioning 2021-02-03 08:45:18 +00:00
62acc8734f Merge branch 'bugfix/ttfw_idf_find_artifacts_inaccurate_with_same_prefix_path_v4.1' into 'release/v4.1'
CI: fix the bug returns wrong artifact path when app_name is a subset of a longer one (v4.1)

See merge request espressif/esp-idf!12229
2021-02-03 11:34:42 +08:00
d6a07efed5 Merge branch 'bugfix/ble_mesh_node_id_adv_v4.1' into 'release/v4.1'
ble_mesh: stack: Fix Node ID adv with wrong timeout (v4.1)

See merge request espressif/esp-idf!11878
2021-02-03 10:48:35 +08:00
83aaee86d8 Merge branch 'bugfix/reenable_encrypted_partition_write_v4.1' into 'release/v4.1'
Re-enable encrypted flash read/writes even if flash encryption is disabled (v4.1)

See merge request espressif/esp-idf!12191
2021-02-02 18:31:04 +08:00
6317ef13f8 unit-test-app: disable encrypted flash read/write in psram config to fix build failure 2021-02-02 05:10:34 +00:00
e032384c7f spi_flash: add config option to enable encrypted partition read/write
This feature can be disabled to save some IRAM (approx 1KB) for cases
where flash encryption feature is not required.
2021-02-02 05:10:34 +00:00
0715c86211 Revert "esp_partition: disable encrypted reads/writes if flash encryption is disabled"
This reverts commit bf35ef1ce7.

It has been noticed that there are scenarios where even though firmware is not enabled
with flash encryption config feature, it should be able to write to encrypted partitions.

This revert adds the feature back which was removed around v4.0 timelines, and same
change will be backported to all releases (upto v4.0) for consistency.
2021-02-02 05:10:34 +00:00
aa2400f5f0 CI: fix the bug returns wrong artifact path when app_name is a subset of a longer one 2021-02-02 11:14:18 +08:00
9468af050b Merge branch 'bugfix/redirection_v4.1' into 'release/v4.1'
esp_http_client: Skip check for redirection counter if status code is success, fix issue with digest auth, configurable user agent string. (v4.1)

See merge request espressif/esp-idf!11598
2021-02-01 20:50:03 +08:00
dec0bca0ba Merge branch 'bugfix/httpd_session_close_lru_v4.1' into 'release/v4.1'
esp_http_server: Add flag in sock_db to identify httpd_sess_close is called from httpd_session_close_lru (v4.1)

See merge request espressif/esp-idf!12113
2021-02-01 17:21:55 +08:00
0d2ab9459d Merge branch 'bugfix/http_client_buffer_overread_v4.1' into 'release/v4.1'
esp_http_client: Fix buffer overread, update https_request example to use HTTP/1.1 (v4.1)

See merge request espressif/esp-idf!12109
2021-02-01 17:20:02 +08:00
3f32d1020d Make the UserAgent string in esp-http-client configurable
Signed-off-by: Shubham Kulkarni <shubham.kulkarni@espressif.com>

Merges https://github.com/espressif/esp-idf/pull/6044
2021-02-01 09:17:43 +00:00
34b845e484 http_auth.c: Fix crash when opaque field is not present in challenge string
Closes: https://github.com/espressif/esp-idf/issues/5888
2021-02-01 09:17:43 +00:00
bffeb8705c esp_http_client: Skip check for redirection counter if status code is success.
Set disable_auto_redirect in esp_http_client example to validate this condition in CI
2021-02-01 09:17:43 +00:00
64be5f1010 Merge branch 'bugfix/update_howsmyssl_cert_v4.1' into 'release/v4.1'
examples/protocols: update www.howsmyssl.com certificate to fix test failures (v4.1)

See merge request espressif/esp-idf!12212
2021-02-01 17:14:39 +08:00
b35c3dd84f examples/protocols: update www.howsmyssl.com certificate to fix test failures 2021-02-01 11:08:05 +05:30
8b53ac9056 Merge branch 'fix/esp_tls_add_warning_if_ca_chain_has_invalid_cert_v4.1' into 'release/v4.1'
esp_tls: Add warning if the CA chain provided contains invalid cert (v4.1)

See merge request espressif/esp-idf!11940
2021-02-01 13:27:31 +08:00
9760595f2f Merge branch 'bugfix/auto_test_script_only_use_given_branch_v4.1' into 'release/v4.1'
CI: limit switching branches for auto_test_script (v4.1)

See merge request espressif/esp-idf!11147
2021-01-30 22:20:31 +08:00
1fec915bdb Merge branch 'feature/upgrade_mbedtls_to_v4.1' into 'release/v4.1'
mbedtls: upgrade to v2.16.9 release (v4.1)

See merge request espressif/esp-idf!11900
2021-01-29 20:35:13 +08:00
744948e189 Merge branch 'fix/esp_tls_fix_memory_leak_v4.1' into 'release/v4.1'
esp-tls: Fix mem leak when global_ca_store is freed

See merge request espressif/esp-idf!12086
2021-01-29 20:34:11 +08:00
5f7f2cc70b Merge branch 'fix/i2c_pm_lock_v4.1' into 'release/v4.1'
i2c: Acquire PM lock after acquiring mutex (v4.1)

See merge request espressif/esp-idf!11831
2021-01-29 20:30:46 +08:00
fa0f3dc13c Merge branch 'fix/update_tls_sockfd_after_freeing_internally_v4.1' into 'release/v4.1'
esp-tls : (Fix) update tls->sockfd value after socket is freed internally (v4.1)

See merge request espressif/esp-idf!11696
2021-01-29 17:23:12 +08:00
f74bb4e5a9 Merge branch 'feature/nvs_erase_check_init_4.1' into 'release/v4.1'
NVS Flash: prevent erasing initialized partition, nvs partition deinit bug (backport v4.1)

See merge request espressif/esp-idf!10063
2021-01-29 17:12:25 +08:00
0fcd502613 Merge branch 'bugfix/tools_python_subprocess_capture_output_v4.1' into 'release/v4.1'
tools: Avoid subprocess.run(capture_output) argument for Python <3.7 compatibility (v4.1)

See merge request espressif/esp-idf!11507
2021-01-29 17:10:43 +08:00
2d7b596c9e Merge branch 'bugfix/phy_xpd_v4.1' into 'release/v4.1'
wifi: add set_xpd_sar override(backport v4.1)

See merge request espressif/esp-idf!11545
2021-01-29 17:10:03 +08:00
38b0243807 Merge branch 'bugfix/ci_retries_when_download_v4.1' into 'release/v4.1'
CI: retry shell commands when download (v4.1)

See merge request espressif/esp-idf!9889
2021-01-29 16:55:03 +08:00
75b33a1072 Merge branch 'feature/ci_fix_docker_build_v4.1' into 'release/v4.1'
ci: Use git mirror for docker image (v4.1)

See merge request espressif/esp-idf!10446
2021-01-29 16:48:57 +08:00
b691ef7e69 Merge branch 'bugfix/blecent_example_test_4.1' into 'release/v4.1'
Fix CI blecent example test (backport v4.1)

See merge request espressif/esp-idf!11322
2021-01-29 16:47:36 +08:00
7e2e162653 Merge branch 'ci/disable_dev_push_pipelines_v4.1' into 'release/v4.1'
CI: Disable pipelines generated by push on dev branches (v4.1)

See merge request espressif/esp-idf!11593
2021-01-29 16:46:49 +08:00
44d6bbea8b Merge branch 'bugfix/driver_spi_poll_test_stack_v41' into 'release/v4.1'
driver test: Increase stack for the "spi poll tasks" test

See merge request espressif/esp-idf!12117
2021-01-29 16:45:53 +08:00
6713bade96 Merge branch 'update/version_4_1_1' into 'release/v4.1'
Update version to 4.1.1

See merge request espressif/esp-idf!12106
2021-01-29 16:45:32 +08:00
432b4c8863 Add init & deinit event for a2dp 2021-01-26 10:52:39 +08:00
f74dbafbbe Enable lru_purge_enable in simple HTTP server example 2021-01-22 15:34:50 +05:30
e48e6aa9df driver test: Increase stack for the "spi poll tasks" test
Current stack usage gets very close to overflowing
2021-01-22 18:03:45 +11:00
03a09c1f51 esp_http_server: Add lru_socket flag in sock_db to indicate httpd_sess_close is called from httpd_sess_close_lru 2021-01-22 11:16:50 +05:30
a819237722 esp_http_client.c: Clear raw_len for response buffer after dispatching HTTP_EVENT_ON_FINISH event
Closes: https://github.com/espressif/esp-idf/issues/6146
2021-01-22 11:03:48 +05:30
4ebe0d8a2f versions: Update version to 4.1.1 2021-01-22 11:08:17 +08:00
c4c18c79a0 bugfix:unhandle event when tg receive set_player_app_value cmd 2021-01-21 21:37:14 +08:00
6282936f19 esp-tls: Fix mem leak when global_ca_store is freed 2021-01-21 10:58:40 +05:30
6f7c750f0d Merge branch 'bugfix/mdns_revert_nonstrict_mode' into 'release/v4.1'
mdns: Revert support for queries in responses, mDNS non-strict mode (v4.1)

See merge request espressif/esp-idf!12044
2021-01-20 16:42:58 +08:00
faa740028c Merge branch 'bugfix/bt_bluedroid_same_public_key_attack_v4.1' into 'release/v4.1'
Bluedroid: Fixes for some Bluetooth vulnerabilities. (v4.1)

See merge request espressif/esp-idf!11764
2021-01-19 20:49:25 +08:00
2d7508bd58 Merge branch 'bugfix/bluedroid_avoid_same_bdaddr_conn_v4.1' into 'release/v4.1'
Bluedroid: Do not connect if peer BD_ADDR is same as own BD_ADDR. (v4.1)

See merge request espressif/esp-idf!11991
2021-01-18 19:15:36 +08:00
31ecdcd3f6 mdns: Revert support for queries in responses, mDNS non-strict mode
This reverts backporting commits to v4.1 related to mDNS non-strict mode
and the related fix for resolving the non-strict mode:
* Revert "mdns: Allow resolve its own non-strict answers"
  This reverts commit 0182a84c2b.
* Revert "mdns: Support queries in responses in mDNS non-strict mode"
  This reverts commit 12e86a7c1b.
2021-01-18 07:53:54 +01:00
620e747355 esp_http_client: Fix some memory leak issues by coverity static analyzer. 2021-01-18 11:38:46 +05:30
d6bf822ab8 wifi_provisioning: Fix some memory leak issues by coverity static analyzer. 2021-01-18 11:38:24 +05:30
85d2d2fcf8 esp_local_ctrl: Fix some memory leak issues by coverity static analyzer. 2021-01-18 11:38:00 +05:30
ce1e71c0de esp_netif: Fix some memory leak issues by coverity static analyzer. 2021-01-18 11:37:10 +05:30
a9f6042d41 fatfs: Fix some memory leak issues by coverity static analyzer. 2021-01-18 11:36:53 +05:30
de3421718d tcp_transport: Fix some memory leak issues by coverity static analyzer. 2021-01-18 11:36:22 +05:30
8668c11a12 wpa_supplicant: Fix some memory leak issues by coverity static analyzer. 2021-01-18 11:35:48 +05:30
3b862da384 mDNS: Fix of text length calculation when detecting a collision 2021-01-15 17:03:32 +04:00
a02ac1ffd3 mDNS: Fix of collision detection during txt length calculation
Closes https://github.com/espressif/esp-idf/issues/6114
2021-01-15 17:03:17 +04:00
025e2b0439 example: Scan failure should not cause system crash 2021-01-15 20:14:59 +08:00
43a328a7c3 example: do not check the return value of esp_wifi_connect() 2021-01-15 20:10:35 +08:00
fbb5ada91d idf monitor: fix crash when monitor baudrate argument set
Closes IDF-1902
2021-01-15 09:10:05 +00:00
53e93c0a10 Bluedroid: Do not connect if peer BD_ADDR is same as own BD_ADDR. 2021-01-14 12:22:47 +05:30
22c82a4e28 Merge branch 'bugfix/mdns_resolve_nonstrict_answers_v4.1' into 'release/v4.1'
mdns: Allow resolve (it's own) non-strict answers (v4.1)

See merge request espressif/esp-idf!11819
2021-01-13 16:54:02 +08:00
976c3787c3 esp_tls: Add warning if the CA chain provided contains one/more invalid
cert
2021-01-11 12:05:45 +05:30
1c89992335 mbedtls: upgrade to v2.16.9 release
For details release notes please refer to:
https://github.com/ARMmbed/mbedtls/releases/tag/v2.16.9
2021-01-07 11:16:35 +05:30
7720cd9c34 spi: fix duplex mode switch issue for multi devices 2021-01-07 12:05:14 +08:00
fe7ebf75a0 NVS Flash: prevent erasing initialized partition
Closes https://github.com/espressif/esp-idf/issues/4755
Closes https://github.com/espressif/esp-idf/issues/2777
Closes FCS-533

* nvs_flash_erase_partition() checks whether
  the parition in question is initialized
  already and will return an error if so
* reflect changes in the documentation

* nvs host unit tests now clean up after each
  test case

nvs_flash: fixed deinit other partition's handles

* When deinitializing or erasing a partition,
  nvs used to close all handles instead of only
  the current partition's handles.
  This is fixed now
* Added a unit test for that case
2021-01-07 11:32:29 +08:00
lly
5c4d7e61c2 ble_mesh: stack: Fix Node ID adv with wrong timeout 2021-01-05 20:14:57 +08:00
427aeec530 esp_modem: Fixed race condition on exiting PPP mode (v4.1)
esp_modem_stop_ppp() stops both ppp netif and switches the modem back to
command mode. IF these two actions are not synchronised, we might
experience issues of
* active PPP session trying to send/receive uart-data
* command mode already active before modem switched to it
both resulting in crashes.
Fixed by introducing the transition mode and running these actions in sequence
* set esp-modem to transition mode
* enter command mode, wait for the reply or re-sync
* close the PPP netif
* wait until the netif closes
Other fixes include ignoring certain events if modem component not ready
or not in appropriate mode:
* ignoring all UART events comming from DTE with no DCE attached
* ignore pattern detection in PPP mode
2021-01-05 12:32:30 +01:00
b7e6c18f8c components/bt: Add API to config QoS 2021-01-04 11:56:00 +08:00
382fa9072d Merge branch 'bugfix/misc_secure_boot_v4.1' into 'release/v4.1'
Bugfix/misc secure boot v2 (v4.1)

See merge request espressif/esp-idf!11744
2020-12-31 18:35:58 +08:00
cca370df47 secure boot v2: Fix crash if signature verification fails in app
sha_handle is "finished" when verify_secure_boot_signature() returns and
should be nulled out.

Alternative version of fix submitted in https://github.com/espressif/esp-idf/pull/6210

Closes https://github.com/espressif/esp-idf/pull/6210

Signed-off-by: Angus Gratton <angus@espressif.com>
2020-12-31 14:34:25 +05:30
ddfc19d531 component/bt: fix Blufi sends customer data will congested when connection is broken 2020-12-31 15:44:38 +08:00
c8a4ad9c3b i2c: Acquire PM lock after acquiring mutex 2020-12-30 13:25:02 +05:30
0182a84c2b mdns: Allow resolve its own non-strict answers
the mDNS responder should not repeat questions when replying, however resolvers
must ignore these questions field if they are present. esp-idf mDNS
library does include questions in answering packets (thus not strictly
following the RFC6762) so the resolver did not correctly resolved
another instance host name.

Closes https://github.com/espressif/esp-idf/issues/6190
2020-12-29 19:05:32 +01:00
52d9d07422 esp_tls_wolfssl : Add domain name check 2020-12-29 21:28:51 +05:30
5dd8bf4fe5 Bluedroid: Fixes for some vulnerabilities.
This commit fixes 'Impersonation in Passkey entry protocol'
(CVE-2020-26558) and suggests fixes for other vulnerabilites like
'Impersonation in the Pin Pairing Protocol' (CVE-2020-26555) and
'Authentication of the LE Legacy Pairing Protocol'

CVE-2020-26558 can be easily implemented if the peer device can
impersonate our public key. This commit adds a check by comparing our
and received public key and returns failed pairing if keys are same.

This commit also adds comments suggesting to use secure connection when
supported by all devices.
2020-12-25 16:01:30 +05:30
edb2a4af41 components/bt: Add QOS for SPP, to decrease the delay from slave to master 2020-12-25 14:56:35 +08:00
801bbcc7ad Secure boot v2: Fixes the issue of passing the flash calculated digest for ota verification. 2020-12-24 14:25:28 +05:30
2427847229 Secure Boot v2: Fix the double padding of the image length during flash encryption
Fixes https://github.com/espressif/esp-idf/issues/6236
2020-12-24 14:22:08 +05:30
bf7435d80d fix spp vfs demo crash when use dynamic memory 2020-12-23 15:13:37 +08:00
ebaf8ae461 esp-tls : (Fix) update tls->sockfd value after socket is freed internally
Closes https://github.com/espressif/esp-idf/issues/6163
2020-12-21 11:23:45 +05:30
64c2f8605a Merge branch 'nimble/fix_misc_coverity_issue_v4.1' into 'release/v4.1'
Nimble: Fix misc issues in NimBLE NVS, `ble_eddystone`, recursive call and  L2CAP CoC (v4.1)

See merge request espressif/esp-idf!11391
2020-12-21 12:07:37 +08:00
6710148748 Merge branch 'bugfix/fix_crash_caused_by_calling_deinit_directly_4_1' into 'release/v4.1'
Fix crash cause by calling a2dp deinit when connected [backport v4.1]

See merge request espressif/esp-idf!11690
2020-12-21 12:05:40 +08:00
be2d72b660 Merge branch 'bugfix/blufi_config_potential_double_free_v4.1' into 'release/v4.1'
Bugfix/blufi config potential double free v4.1

See merge request espressif/esp-idf!11164
2020-12-21 12:05:33 +08:00
aee941a087 Fix crash cause by calling a2dp deinit when connected 2020-12-21 10:23:46 +08:00
73f601554b Merge branch 'bugfix/eap_client_crash_4.1' into 'release/v4.1'
wpa_supplicant: Fix null pointer dereference if eap init failed

See merge request espressif/esp-idf!11642
2020-12-20 15:58:29 +08:00
aff13c0fbc Merge branch 'fixbug/baidu_tcp_recv_assert_for_4.1' into 'release/v4.1'
lw-ip:fix bug for tcp recv assert(backport 4.1)

See merge request espressif/esp-idf!11602
2020-12-20 15:52:44 +08:00
5f3f5f15b2 fix bug for tcp recv assert 2020-12-18 14:00:48 +00:00
286f8c76b6 Merge branch 'bugfix/exl200_reset_and_adv_v4.1' into 'release/v4.1'
Bugfix/exl200 reset and adv v4.1

See merge request espressif/esp-idf!11672
2020-12-18 21:59:32 +08:00
b5e93053e5 components/bt:fix exl200, add btdm_disable_adv_delay, fix RPA addr update error. 2020-12-18 12:25:19 +00:00
c6d2c43661 components/bt: Fixed the problem of early release of pointer(p_ccb) in funcion 2020-12-18 12:25:19 +00:00
bd9025f817 Merge branch 'bugfix/revert_tx_optimization_v4.1' into 'release/v4.1'
Revert "esp_wifi: optimize WiFi TX performance" (v4.1)

See merge request espressif/esp-idf!11675
2020-12-18 20:22:41 +08:00
7bdef15e85 CI: Disable pipelines generated by push on dev branches 2020-12-18 08:43:22 +00:00
20dc46ca49 Revert "esp_wifi: optimize WiFi TX performance"
This reverts commit 5de5eb5676.
2020-12-18 08:38:01 +00:00
592645f0c0 Merge branch 'bugfix/ci_py2_warnings_fix_v4.1' into 'release/v4.1'
ci: Python 2 warnings fix (v4.1)

See merge request espressif/esp-idf!11618
2020-12-18 16:33:44 +08:00
a582fbdfdc Added missing MYNEWT_VAL_BLE_L2CAP_COC_MPS definition
Signed-off-by: Prasad Alatkar <prasad.alatkar@espressif.com>

Merges https://github.com/espressif/esp-idf/pull/5825
2020-12-17 07:20:35 +00:00
30c89dc11d NimBLE: Fix misc coverity issues in NimBLE host
- NimBLE NVS : Additional check to account for NVS operation failure
- NimBLE host: Fix minor bug in ble_eddystone_set_adv_data_gen
- NimBLE host: remove recursive call, upstream PR: https://github.com/apache/mynewt-nimble/pull/857
2020-12-17 07:20:35 +00:00
9d21d0a671 Merge branch 'feature/dis_uart_dl_mode_v4.1' into 'release/v4.1'
feature: Disable UART download mode (v4.1)

See merge request espressif/esp-idf!10765
2020-12-16 16:24:25 +08:00
45370f4fae wpa_supplicant: Fix null pointer dereference if eap init failed 2020-12-16 11:57:08 +05:30
5b3734a04a efuse: Add ESP32 V3 'disable Download Mode' functionality 2020-12-16 17:08:04 +11:00
cabe0a44b7 adc_i2s: solve the i2s_adc issue when using wifi 2020-12-15 20:57:02 +08:00
b766dc00eb tools: Redirect some warnings to stderr 2020-12-15 13:27:00 +07:00
d3c35e1c5f ci: Ignore Python 2 deprecation warning 2020-12-15 13:26:18 +07:00
fca2d78459 efuse: Add new esp_efuse_read_field_bit() convenience function 2020-12-15 15:53:26 +11:00
1ef020f0a6 efuse: Add new esp_efuse_write_field_bit() convenience function 2020-12-15 15:53:26 +11:00
9b31bd54da efuse: Don't need to burn WR_CRYPT_CNT if CRYPT_CNT is already max
Reduces write cycles, and useful on ESP32 ECO3 as UART_DIS_DL is protected by
the same efuse.

Also fixes accidental macro definition introduced in 7635dce502
2020-12-15 15:53:26 +11:00
c9307cb16e secure boot: Fix regression enabling secure boot v2
Regression in 18b4ae2a65 - write-protecting BLK2 caused write
registers to be cleared, so key digest was all zeroes.
2020-12-15 15:53:26 +11:00
f4739d69ab Merge branch 'bugfix/verify-directory-exists_v4.1' into 'release/v4.1'
Bugfix: add check for existence build directory (v4.1)

See merge request espressif/esp-idf!11583
2020-12-12 01:43:28 +08:00
a303b53209 Add checking if the build directory exists and move expression after docstring 2020-12-11 13:26:45 +01:00
99a6072824 Changed esptool version to latest v2.x 2020-12-11 10:42:50 +01:00
77be96fd87 Merge branch 'bugfix/log-error-run-esptool_v4.1' into 'release/v4.1'
parttool.py: Add file stream parameter and log stdout and stderr to same stream (v4.1)

See merge request espressif/esp-idf!10517
2020-12-11 16:55:09 +08:00
3217cd4734 Merge branch 'doc/update_CN_translation_for_relase/v4.1' into 'release/v4.1'
update get-started/index.rst for release/v4.1

See merge request espressif/esp-idf!11513
2020-12-11 11:38:41 +08:00
37d8033906 update get-started/index.rst for release/v4.1 2020-12-11 11:38:37 +08:00
6daf14a031 Merge branch 'feature/python2-deprecation-warn_v4.1' into 'release/v4.1'
Tools: Add Python 2 deprecation warning (v4.1)

See merge request espressif/esp-idf!11527
2020-12-11 11:28:56 +08:00
bb20c40fd8 Merge branch 'bugfix/decouple_wifi_bt_with_coex_v4.1' into 'release/v4.1'
esp_wifi: decouple Wi-Fi and bluetooth with coexist to reduce binary file size

See merge request espressif/esp-idf!11534
2020-12-10 22:33:23 +08:00
4256b1098c twai: Temporarily disable network example test
Disabling network example test due to issue with synchronizing the
start of each DUT
2020-12-10 21:31:56 +08:00
649d834c16 esp_wifi: decouple Wi-Fi and bluetooth with coexist to reduce binary file size
close https://github.com/espressif/esp-idf/issues/5970
2020-12-10 17:07:49 +08:00
026accbb91 add CN translation for adding python2 deprecation warning(MR 11115) 2020-12-09 14:41:33 +01:00
f75acede24 Tools: add Python 2 deprecation warning 2020-12-09 14:41:33 +01:00
69beb55bbd Merge branch 'bugfix/revert_iram_optimizaion_v4.1' into 'release/v4.1'
esp_wifi: revert wifi iram optimization(v4.1)

See merge request espressif/esp-idf!11512
2020-12-09 17:39:28 +08:00
161569e3f9 Fix reserved psram region
Closes https://github.com/espressif/esp-idf/pull/5373

Closes https://github.com/espressif/esp-idf/issues/5821
2020-12-08 17:43:49 +11:00
f5cee05010 esp_wifi: revert wifi iram optimization(v4.1) 2020-12-08 14:03:20 +08:00
e7f40fca68 tools: Avoid subprocess.run(capture_output) argument for Python <3.7 compatibility
In Python 3.5 and 3.6 the equivalent to capture_output=True is to set stdout
and stderr arguments to subprocess.PIPE
2020-12-08 09:44:44 +11:00
6a9b351b67 Merge branch 'bugfix/pmf_tx_rx_routine_v4.1' into 'release/v4.1'
esp_wifi: Always register pmf tx/rx routines (backport v4.1)

See merge request espressif/esp-idf!11449
2020-12-03 18:10:00 +08:00
1ae727bbc2 esp_wifi: Always register pmf tx/rx routines
Fixes the issue when PMF packets are not sent after mode change.
2020-12-03 15:31:30 +08:00
369222f811 Merge branch 'feature/btdm_support_some_ble_new_features_v4.1' into 'release/v4.1'
components/bt: backport some new features for Bluedroid BLE(release v4.1)

See merge request espressif/esp-idf!11441
2020-12-03 14:38:53 +08:00
0499dfdd0c Merge branch 'bugfix/update_release_v4.1_bt_lib' into 'release/v4.1'
components/bt: backport requires commit to release v4.1

See merge request espressif/esp-idf!11425
2020-12-03 11:21:53 +08:00
1273982045 component/bt: support BLE Read Attribute value by UUID 2020-12-02 20:20:03 +08:00
5da4c0f125 component/bt: refactor ble random address setting 2020-12-02 20:19:54 +08:00
8e08156141 component/bt: support BLE Application Layer Encryption key size check 2020-12-02 20:19:45 +08:00
a6ea010898 component/bt: support BLE Authorization 2020-12-02 20:19:35 +08:00
217e90ec5c component/bt: fix incorrect encryption flag setting 2020-12-02 20:19:21 +08:00
ec2817a285 soc: fix comparison error in soc component
Closes https://github.com/espressif/esp-idf/issues/6120
2020-12-02 12:23:17 +08:00
ee4fb9b182 components/bt: backport requires commit to release v4.1 2020-12-01 19:36:39 +08:00
29d5a4dcc3 examples: fix flash encryption example test
Commit 5e8795eebe has changed the partition table offset, which
has resulted in the ciphertext not matching the one expected in the
example test.
Fix by calculating the ciphertext using espsecure.py.
2020-12-01 18:30:11 +08:00
f124c30b6f example/flash_encryption: Fix partition table and sdkconfig.defaults
When the flash encryption is enabled then we do not need to change the partition table.
The partition_example.csv should not have fixed offsets for partitions because we want to move the whole table.
The fixed offsets in the table were cleared.
2020-12-01 17:01:45 +08:00
38b15816b4 ci: Fix blecent example test
(cherry picked from commit fc146a98e4)
2020-11-30 22:41:12 +05:30
3dddf0c81d esp32xx: Fix default values for all RTC sources in RTC_CLK_CAL_CYCLES option
Closes: https://github.com/espressif/esp-idf/issues/6037
2020-11-30 23:33:48 +08:00
ea28da9b61 Merge branch 'docs/self_hosted' into 'release/v4.1'
docs: self host docs

See merge request espressif/esp-idf!10191
2020-11-26 13:45:21 +08:00
de6d8c6521 Merge branch 'bugfix/ble_mesh_wifi_coexit_example_v4.1' into 'release/v4.1'
bugfix: Delete local variables to avoid null global variables (backport v4.1)

See merge request espressif/esp-idf!11371
2020-11-26 10:38:00 +08:00
30e4f83127 bugfix: Delete local variables to avoid null global variables 2020-11-25 20:51:24 +08:00
3d4d56727a ESP-NETIF: fix get/set hostname API to reflect user settings
On startup of the common interface (ethernet, wifi), the lwip netif hostname was assigned to confg value .
Fixed to assign to esp-netif hostname if it exists

Closes https://github.com/espressif/esp-idf/issues/4737
2020-11-24 14:00:05 +01:00
611160e90e Merge branch 'bugfix/secure_boot_v2_manual_enablement_v4.1' into 'release/v4.1'
Secure Boot V2: Fix an issue leading to manual enablement of Secure Boot v2. (v4.1)

See merge request espressif/esp-idf!11229
2020-11-24 15:46:12 +08:00
bb3bec200c Merge branch 'bugfix/coredump_memregion_size_v4.1' into 'release/v4.1'
coredump: Fixes size of memory region used by espcoredump.py (backport v4.1)

See merge request espressif/esp-idf!8976
2020-11-24 13:18:51 +08:00
87669b23da component/bt: Add a macro to control the compilation of blufi. 2020-11-24 10:45:36 +08:00
f7e870e45d component/bt: Fix a potential double free error. 2020-11-24 10:45:36 +08:00
7765b07898 blufi: fix an error caused by incorrect conn_id parameters. 2020-11-24 10:45:36 +08:00
329ae0a987 docs: self host docs
Move doc hosting from readthedocs to espressif servers

Update CI, Sphinx configs and add IDF Sphinx theme
2020-11-24 02:16:02 +00:00
50efa84dc4 Merge branch 'docs/fix_a_broken_link_to_temp_sensor_esp32s2' into 'release/v4.1'
docs: fix a broken link for v4.1

See merge request espressif/esp-idf!11339
2020-11-23 19:11:43 +08:00
c57de0d6ca Merge branch 'ci/fix_annotated_tag_check_v4.1' into 'release/v4.1'
ci: Fix annotated tag check (v4.1)

See merge request espressif/esp-idf!11332
2020-11-23 17:34:41 +08:00
753eaa03a6 docs: fix a broken link for v4.1 2020-11-23 15:46:01 +08:00
f59d1dfab9 Merge branch 'bugfix/freemodbus_fix_event_processing_after_destroy_v4.1' into 'release/v4.1'
freemodbus: fix event processing failure after destroy (backport v4.1)

See merge request espressif/esp-idf!9326
2020-11-23 14:33:47 +08:00
9a141cc0ce ci: Fix annotated tag check
Regression in 1612f84
2020-11-23 17:28:21 +11:00
a4c72cfa28 Merge branch 'bugfix/fix_iram_handler_call_inline_func' into 'release/v4.1'
Bugfix/fix iram handler call inline function uart_ll_is_tx_idle in flash (v4.1)

See merge request espressif/esp-idf!9951
2020-11-23 12:16:57 +08:00
40636d6a49 uart: fix uart_ll_is_tx_idle to inline into handler correctly when opt for size
Closes https://github.com/espressif/esp-idf/issues/5694
2020-11-23 12:16:57 +08:00
62c44408c2 freemodbus: fix event processing failure after destroy
Closes https://github.com/espressif/esp-idf/issues/5275
2020-11-23 04:08:03 +00:00
e87d95f895 Merge branch 'bugfix/backport_master_to_v4.1' into 'release/v4.1'
Bugfix/backport master to v4.1

See merge request espressif/esp-idf!11316
2020-11-23 00:44:21 +08:00
6956d43f29 components/bt: Point the btlib to the latest branch. 2020-11-22 23:26:22 +08:00
d09d5479a8 Merge branch 'feature/light_sleep_reject_v4.1' into 'release/v4.1'
sleep: enable sleep reject when entering light sleep (backport v4.1)

See merge request espressif/esp-idf!9500
2020-11-22 20:48:39 +08:00
f69fe10e7e components/coex: Some bugfix about ble dynamic prio
Rewrite ble dynamic prio to fix ble disconn in conn_param_update/channel_map_update
Rewrite ble dynamic prio in connection establishment
Fix ble dynamic prio with latency
Fix status bit set error when conn fail
2020-11-22 20:37:10 +08:00
9b274cc989 components/bt: Fix waking up fail while sleeping 2020-11-22 20:37:10 +08:00
a64acef06f components/bt: Make sleep avaliable in hli(for future use) 2020-11-22 20:37:10 +08:00
c33dc7afd1 components/bt: Fix BT controller dead issue caused by clk overflow
components/bt: Fix assert(10, 9), when the AFPM happens
2020-11-22 20:37:10 +08:00
2b19bc9efa components/bt: fixed memory damage caused by bluetooth memory release 2020-11-22 20:37:10 +08:00
a8035d21ef ble_mesh: add ble mesh coex test example 2020-11-22 20:37:10 +08:00
5b73ec939c Merge branch 'bugfix/fix_some_wifi_bugs_1120_v4.1' into 'release/v4.1'
WiFi: fix some wifi bugs 1120 (backport v4.1)

See merge request espressif/esp-idf!11317
2020-11-22 20:07:37 +08:00
d950d3b6b0 WIFI: Iperf example's parameter opt was uninitialized, may leads setsockoption invalide if it equal to 0 2020-11-22 18:05:12 +08:00
5a2445bb96 bugfix: fix TCP timer interval 2020-11-22 18:03:57 +08:00
f835edbf5c fix TCP retransmission interval 2020-11-22 18:03:06 +08:00
87bd31983c Fixed links to example directories for fast_scan and scan
Signed-off-by: ronghulin <ronghulin@espressif.com>

https://github.com/espressif/esp-idf/pull/5186
2020-11-22 17:55:09 +08:00
fc18d7972e wpa_supplicant: Minor bugfix with wpa_supplicant debug logs. 2020-11-22 17:47:20 +08:00
8171579a5c Merge branch 'feature/switch_from_external_to_interanl_ram_v4.1' into 'release/v4.1'
esp32: Switch SPIRAM stack in esp_restart_noos() to internal stack (v4.1)

See merge request espressif/esp-idf!9968
2020-11-22 15:17:41 +08:00
4dd4a1a2e0 Merge branch 'bugfix/backport_some_lwip_bugs_1120_v4.1' into 'release/v4.1'
lw-ip:backport bugfix lwip for v4.1(backport 4.1)

See merge request espressif/esp-idf!11305
2020-11-21 15:28:00 +08:00
d925b564cd esp32: Switch SPIRAM stack in esp_restart_noos() to internal stack
If esp_restart_noos() is run and the stack address points to external memory (SPIRAM)
then Cache_Read_Disable() raises up the error "Cache disabled but cached memory region accessed"
to fix this we switch stack to internal RAM before disable cache.

Added unit tests.

Closes: https://github.com/espressif/esp-idf/issues/5107
2020-11-21 07:14:38 +00:00
941e7771d9 Merge branch 'feature/mqtt_submodule_update_23c8e1ec_v4.1' into 'release/v4.1'
MQTT: Update submodule reference to da850b (config, error flags, minor fixes) (v4.1)

See merge request espressif/esp-idf!11313
2020-11-21 15:13:18 +08:00
552baf659c Merge branch 'bugfix/mdns_src_addr_cpy_v4.1' into 'release/v4.1'
mdns: Fix wrong mdns source address if lwIP IPv6 zoning disabled (v4.1)

See merge request espressif/esp-idf!11311
2020-11-21 15:11:05 +08:00
fee376dcdc Merge branch 'bugfix/customer_baidu_psram_stack_backtrace_v4.1' into 'release/v4.1'
backport v4.1: added psram stack check in backtrace

See merge request espressif/esp-idf!8479
2020-11-20 22:33:26 +08:00
7eada9f4d3 wpa_supplicant: Fix configurable debug log feature's warning issue 2020-11-20 22:26:44 +08:00
3dc7dc9e97 esp_wifi: optimize WiFi debug log
1. Add esp_wifi_statis_dump()
2. Optimize WiFi related debug log
2020-11-20 22:13:19 +08:00
2c85e830e0 esp_wifi: update wifi lib 2020-11-20 20:14:07 +08:00
5de5eb5676 esp_wifi: optimize WiFi TX performance 2020-11-20 19:47:01 +08:00
ffc87ab7d9 esp_wifi: Update wifi lib
1. Add STA checks during STA PMF operations
2. Fix WPA2-Ent issue with Open AP
3. Skip WPA-TKIP profile if PMF is required
4. Skip & clear Supplicant PMK Cache with mismatching AP config
5. Use flag ESP32_WIFI_ENABLE_WPA3_SAE to control WPA3 code, disabling
   it code footprint reduces by 7.7kB in libwpa_supplicant.a
6. Fix handling of multiple AP credentials in WPS, apps need update
   to handle the new event for the fix to work

Closes https://github.com/espressif/esp-idf/issues/5971
2020-11-20 19:45:21 +08:00
b8991833ca esp_wifi: remove wifi tx buffer limits 2020-11-20 19:43:28 +08:00
3dbff1638c Wi-Fi: set softap beacon DTIM count according to TSF timer 2020-11-20 19:42:13 +08:00
77e7b15190 Reduce log level of hexdumps to verbose
Revert "Reduce log level of hexdumps to verbose"

Add a menuconfig option to enable or disable the logging in wpa_supplicant

Clarify help message
2020-11-20 19:40:48 +08:00
5707296aff wifi: Fix esp_wifi log levels 2020-11-20 19:38:34 +08:00
2c995da190 ESP-WIFI: Optimize 4way handshake failure time
In case of wrong passpharse, AP will keep on sending 1/4 multiple
times which may take around 10 secs to disconnect and detect
wrong password event.

Add changes to reject EAPOL1 after 3 consecutive reception
2020-11-20 19:33:43 +08:00
0bd483bbf5 espnow/pmf: Implement ESPNOW + PMF Co-existance
H/W decryption of Mgmt frames was disabled for PMF and done through
S/W. If ESPNOW packets go through this path, it affects backward
compatibility since method of decrypting Mgmt packets is different in H/W.

To address PMF + ESPNOW Co-existance, CCMP decryption method is modified
for ESPNOW packets so that they can be decrypted correctly. Since Tx
of ESPNOW packets can still be done in H/W alongside PMF, no change
required in encryption method in S/W.

Co-Authored-By: Nachiket Kukade <nachiket.kukade@espressif.com>
Co-Authored-By: zhangyanjiao <zhangyanjiao@espressif.com>
Co-Authored-By: kapil.gupta <kapil.gupta@espressif.com>
2020-11-20 19:00:55 +08:00
05314b6ce0 MQTT: Update submodule reference: config, error handle, minor fixes
Updates esp-mqtt reference to include fixes below related mainly to:
* configuration update (disable keepalive, network timeout)
* minor fixes (size_t for all sizes, unbalanced lock, api for
  outbox-size)
* extended error handle to include socket's errno

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

Config: Added config value to disable keepalive mechanism
esp-mqtt commit: 8562437c8a
Related https://github.com/espressif/esp-mqtt/issues/179

Added esp_mqtt_client_get_outbox_size API
esp-mqtt commit: 0a1d9d0300
Related https://github.com/espressif/esp-mqtt/pull/178

mqtt_outbox: Removed unused retry_count field from outbox_item_t
esp-mqtt commit: 673086e13a

config: Fixed typo for configuring OUTBOX_EXPIRED_TIMEOUT_MS
esp-mqtt commit: 259baaec96

Fixed missing MQTT_API_UNLOCK in esp_mqtt_client_stop error path
esp-mqtt commit: 845c2a3a1e
Related https://github.com/espressif/esp-mqtt/issues/173
Related https://github.com/espressif/esp-mqtt/pull/174

Extended mqtt error handle to capture transport's socket errno (IDF
v4.3+)
esp-mqtt commit: 23c8e1ecf5

Config: Added configuration value to set network timeout
esp-mqtt commit: a03228ac46
Related https://github.com/espressif/esp-mqtt/pull/166

Used size_t for all lengths to allow for other architectures
esp-mqtt commit: b9db8d9020
2020-11-20 10:25:25 +01:00
eec0934081 mdns: Fix wrong mdns source address if lwIP IPv6 zones disabled
The struct definition of ip6_addr_t in lwip and esp_ip6_addr_t
differs since zone could be possibly disabled in lwip. Using memcpy to copy the
address will cause wrong source address. Copy the entries manually
instead.

Merges https://github.com/espressif/esp-idf/pull/6055
2020-11-20 10:16:01 +01:00
ab63824600 added psram stack check in backtrace 2020-11-20 07:13:11 +00:00
62d1f3f9ba backport bugfix lwip for v4.1 2020-11-20 14:40:26 +08:00
ae5603381d Merge branch 'bugfix/backport_v4.1_fix_websocket_issue' into 'release/v4.1'
websocket_client: fix some issues for websocket client(backport v4.1)

See merge request espressif/esp-idf!11274
2020-11-20 14:02:32 +08:00
c3324a82a3 Merge branch 'bugfix/wpa3_pmkcache_expiry_workaround_v4.1' into 'release/v4.1'
wpa_supplicant: Increase PMK Lifetime to a very high value

See merge request espressif/esp-idf!11275
2020-11-19 16:27:45 +08:00
be7b859198 Merge branch 'feat/ble_mesh_node_local_data_func_v4.1' into 'release/v4.1'
ble_mesh: stack: Add node local netkey/appkey func (v4.1)

See merge request espressif/esp-idf!11281
2020-11-19 11:22:55 +08:00
c2167f137a Merge branch 'fix/protocomm_simple_ble_v4.1' into 'release/v4.1'
Protocomm/simple_ble: Fix gatt table map size to number of handles received (v4.1)

See merge request espressif/esp-idf!11266
2020-11-19 11:21:04 +08:00
b21f42b279 Merge branch 'optimize/ble_mesh_gattc_conn_param_v4.1' into 'release/v4.1'
ble_mesh: stack: Update connection parameters used by Central (v4.1)

See merge request espressif/esp-idf!11284
2020-11-19 11:17:44 +08:00
lly
3873c9e260 ble_mesh: stack: Update connection interval to 15ms 2020-11-18 20:24:22 +08:00
lly
1fb0861b9c ble_mesh: stack: Update connection parameters used by Central 2020-11-18 20:24:22 +08:00
lly
e989d59a4e ble_mesh: stack: Fix wrong declaration of node bind AppKey func 2020-11-18 20:15:12 +08:00
lly
7b9c04b773 ble_mesh: stack: Add node local netkey/appkey func 2020-11-18 20:14:56 +08:00
9798f2c9b0 Merge branch 'optimize/ble_mesh_reduce_code_size_v4.1' into 'release/v4.1'
ble_mesh: stack: Optimization introduced to reduce code size (v4.1)

See merge request espressif/esp-idf!11249
2020-11-18 20:08:29 +08:00
0a8fd1d44b Merge branch 'bugfix/backport_v4.1_fix_pthread_priority_inheritance' into 'release/v4.1'
pthread: fix the priority inheritance(backport v4.1)

See merge request espressif/esp-idf!11259
2020-11-18 17:28:35 +08:00
50cf0c2d24 wpa_supplicant: Increase PMK Lifetime to a very high value
For WPA3 connection nearing PMK lifetime expiry, PMK Cache
needs a re-authentication or the cache will expire. After
current expiry of 12 hours Station ends up sending a deauth
to the AP. An SAE re-authentication also cannot occur without
a disconnection with current implementation. So increase the
PMK lifetime to 100 days for now.
2020-11-18 12:36:52 +05:30
ae202d81ec Merge branch 'bugfix/fix_ag_outging_callback_not_triggered_v4.1' into 'release/v4.1'
Bugfix/Fix Ag Example Outgoing Callback Not Triggered [backport v4.1]

See merge request espressif/esp-idf!11019
2020-11-18 11:40:07 +08:00
e645e2e5d6 Merge branch 'bugfix/fix_spp_read_flow_control_v4.1' into 'release/v4.1'
component_bt/fix spp flow control and vfs write [backport 4.1]

See merge request espressif/esp-idf!11073
2020-11-18 11:39:35 +08:00
c78f5cde40 coredump: Fixes size of memory region used by espcoredump.py 2020-11-17 20:25:56 +03:00
f39b02f299 Protocomm/simple_ble: Make gatt table map size equal to number of handles received (v4.1)
- Fixes memcpy failure observed while adding 2 or more endpoints in
  wifi_provisioning.

 Closes IDF-2250
2020-11-17 15:59:06 +05:30
8eff4e7a47 Merge branch 'optimization/AP_STAIPASSIGNED_passes_IP_send_through_event_data_for_4.1' into 'release/v4.1'
esp-event:AP_STAIPASSIGNED now passes the IP through 'event_data'(backport 4.1)

See merge request espressif/esp-idf!11240
2020-11-17 17:45:56 +08:00
88ddddbd3f websocket_client: fix some issues for websocket client
1. will post twice disconnect event when read error
    2. will block `timeout` times when set disable_auto_connect
    3. When `esp_websocket_client_stop` before `esp_websocket_client_send*`,
    if the `esp_websocket_client_send*` fails, the status will change to
     'WEBSOCKET_STATE_WAIT_TIMEOUT', and the next `esp_websocket_client_start` will fail forever
2020-11-17 15:53:19 +08:00
61807f6e52 pthread: fix the priority inheritance
When `pthread_mutex_destroy` is used to release mutex, `pthread_mutex_lock_internal` is used,
     which results in the increase of `uxmutexehold` and no recovery base priority
2020-11-17 14:46:09 +08:00
lly
c53fe053e7 ble_mesh: example: Update sdkconfig test files for disabling Health Server model 2020-11-17 11:06:34 +08:00
lly
230e8f5c92 ble_mesh: stack: Add a Kconfig option to make Health Server model optional 2020-11-17 11:06:34 +08:00
lly
c94d7fe982 ble_mesh: stack: Split model Kconfig menu into foundation and others 2020-11-17 11:06:34 +08:00
lly
ea1c51639f ble_mesh: example: Fix fast provisioning compile error 2020-11-17 11:06:34 +08:00
lly
447d19776c ble_mesh: ci: Add disabling mesh model sdkconfig test files 2020-11-17 11:06:34 +08:00
lly
dad5cc4aeb ble_mesh: stack: Add Kconfig options to make server models optional 2020-11-17 11:06:33 +08:00
lly
e44307504a ble_mesh: stack: Use Kconfig option to make client models optional 2020-11-17 11:06:33 +08:00
lly
a67d205468 ble_mesh: stack: Make some internal static functions inline 2020-11-17 11:06:33 +08:00
lly
22cfa7ea6a ble_mesh: ci: Add disabling mesh deinit sdkconfig test files 2020-11-17 11:06:33 +08:00
lly
bc5ba60ceb ble_mesh: stack: Add a Kconfig option to make deinit optional 2020-11-17 11:06:33 +08:00
lly
73733396cd ble_mesh: stack: Introduce a new header file mesh_config.h 2020-11-17 11:06:32 +08:00
4f74fd9e95 Merge branch 'bugfix/sleep_comments_v4.1' into 'release/v4.1'
doc: Specify that sleep wakeup source restrictions apply to all current ESP32 revisions (v4.1)

See merge request espressif/esp-idf!8567
2020-11-17 08:59:22 +08:00
09e669dba2 Merge branch 'bugfix/secure_boot_v2_key_gen_py3_v4.1' into 'release/v4.1'
esptool: Update submodule fixing Py3 keygen in Secure boot v2

See merge request espressif/esp-idf!11230
2020-11-17 07:38:43 +08:00
467bf2f53f AP_STAIPASSIGNED now passes the IP through 'event_data'
Signed-off-by: xueyunfei <xueyunfei@espressif.com>
2020-11-16 17:32:14 +08:00
3a5457efe4 ci: use the retry script to download 2020-11-16 11:36:35 +07:00
5bb72ea5cc Merge branch 'bugfix/cmake_example_sdkconfig_path_v4.1' into 'release/v4.1'
cmake/example: Move idf_as_lib sdkconfig path to project, document configuring project (v4.1)

See merge request espressif/esp-idf!10860
2020-11-16 12:14:00 +08:00
573f5de99a Merge branch 'bugfix/window_spill_a0_corruption_v4.1' into 'release/v4.1'
freertos: don't clobber a4 while spilling register windows (backport v4.1)

See merge request espressif/esp-idf!10306
2020-11-13 16:27:45 +08:00
5b1a3b801f esptool: Update submodule fixing Py3 keygen in Secure boot v2 2020-11-13 12:10:19 +05:30
18b4ae2a65 Secure Boot V2: Fix an issue leading to manual enablement of Secure Boot v2.
Fixes https://github.com/espressif/esp-idf/issues/6050
2020-11-13 11:36:29 +05:30
00fb496eda Merge branch 'fix/esp_local_ctrl_update_expired_cert_v4.1' into 'release/v4.1'
esp_local_ctrl: Updated the expired cacert.pem (v4.1)

See merge request espressif/esp-idf!11207
2020-11-12 23:20:37 +08:00
ad7f8ed0ff Merge branch 'feature/pppos_client_test_v4.1' into 'release/v4.1'
PPPoS client fixes for UART: REF_TICK, driver install after config (v4.1)

See merge request espressif/esp-idf!11197
2020-11-12 20:31:45 +08:00
5468184381 Merge branch 'bugfix/update_toolchain_5.2.0_psram_final_v4.1' into 'release/v4.1'
esp_wifi: Update WiFi toolchain to 1.22.0-97-gc752ad5 (backport v4.1)

See merge request espressif/esp-idf!11101
2020-11-12 14:26:21 +08:00
21dc6d1bf1 esp_modem: Ensure uart_param_config and uart pins are set before uart_driver_install
Fixes Guru Meditation Error: Core 0 panic'ed (LoadProhibited) when config with
CONFIG_PM_ENABLE=y && CONFIG_PM_DFS_INIT_AUTO=y.

Signed-off-by: Axel Lin <axel.lin@gmail.com>

Merges https://github.com/espressif/esp-idf/pull/4904
2020-11-12 07:15:39 +01:00
e4575b20a1 esp_modem: pppos_client modem to use uart with REF_TICK
pppos_client example used the UART default clock configuration which might
cause issues if power management enabled. Settings updated to UART_SCLK_REF_TICK
Also need to explicitly disable RX interrupts in UART pattern detection
mode.

Closes https://github.com/espressif/esp-idf/issues/4801
2020-11-12 07:13:13 +01:00
86dd11f176 Merge branch 'bugfix/esp_netif_ppp_setdefault_fix_v4.1' into 'release/v4.1'
ESP-NETIF: Set default interface for ppp netif must be called from lw_ip context (v4.1)

See merge request espressif/esp-idf!11196
2020-11-12 14:05:50 +08:00
29a995dd78 Merge branch 'bugfix/pppos_ignored_modem_start_return_v4.1' into 'release/v4.1'
pppos client: modem netif fix ignoring potential modem-start error (v4.1)

See merge request espressif/esp-idf!11199
2020-11-12 14:03:54 +08:00
d397767f5d Merge branch 'bugfix/fix_esp_modem_mode_switch_timeout_v4.1' into 'release/v4.1'
fix esp_modem switch mode timeout (v4.1)

See merge request espressif/esp-idf!11198
2020-11-12 14:03:15 +08:00
2357d05427 esp_local_ctrl: Updated the expired cacert.pem 2020-11-12 10:16:54 +05:30
b6b1cf216b Revert "CXX: removed exception windowspill test"
This reverts commit f3e180de72.
2020-11-11 14:43:15 +00:00
cf5ef7f0e1 freertos: don't clobber a4 while spilling register windows
Commit 891eb3b0 was fixing an issue with PS and EPC1 not being
preserved after the window spill procedure. It did so by saving PS in
a2 and EPC1 in a4. However the a4 register may be a live register of
another window in the call stack, and if it is overwritten and then
spilled to the stack, then the corresponding register value will end
up being corrupted. In practice the problem would show up as an
IllegalInstruction exception, when trying to return from a function
when a0 value was 0x40020.
Fix by using a0 register instead of a4 as scratch. Also fix a comment
about xthal_save_extra_nw, as this function in fact doesn't clobber
a4 or a5 because XCHAL_NCP_NUM_ATMPS is defined as 1.

Closes https://github.com/espressif/esp-idf/issues/5758
2020-11-11 14:43:15 +00:00
07c41378fb pppos client: modem netif fix ignoring potential modem-start error
esp-modem netif glue layer implements esp-netif attach callback to setup corresponding driver functions and start the modem. The error code of esp_modem_start_ppp() was ignored and ESP_OK returned in all cases. Fixed by passing esp_modem_start_ppp()'s error code to post_attach callback.

Closes https://github.com/espressif/esp-idf/issues/5430
2020-11-11 14:25:05 +01:00
e8834b66c5 fix esp_modem switch mode timeout
Closes https://github.com/espressif/esp-idf/issues/3506
Closes https://github.com/espressif/esp-idf/issues/4324
2020-11-11 14:19:23 +01:00
4c1ad38f79 esp-netif-ppp: support for setting ppp netif up and down
calling esp_netif_up() and esp_netif_down() was not supported if the
underlying netif wos of ppp type. Updated the code to enable setting
these interfaces up/down and registered actions in moden_netif glue for
connection/disconnection events to set the netif up/down.
2020-11-11 13:29:13 +01:00
b9d1afdb86 esp-netif: set default interface for ppp netif must be called from lwip context
On update of any interface (set up/down) a routing preference is updated calling esp_netif_update_default_netif() that is called from
lwip context. But if the related netif was ppp type, the set_default api used user-mode, thus causing a dead lock.

Closes https://github.com/espressif/esp-idf/issues/4746
2020-11-11 13:29:13 +01:00
f1d98671d2 doc: Specify that sleep wakeup source restrictions apply to all current ESP32 revisions
Closes https://github.com/espressif/esp-idf/issues/4681

Discussion https://esp32.com/viewtopic.php?f=13&t=15145
2020-11-11 17:34:42 +11:00
2178f319c4 esp_wifi: Update WiFi toolchain to 1.22.0-97-gc752ad5 2020-11-10 20:15:13 +08:00
a59a8edfc0 Merge branch 'bugfix/example_test_import_error_4.1' into 'release/v4.1'
bugfix: import error in example tests (4.1)

See merge request espressif/esp-idf!11047
2020-11-09 19:19:37 +08:00
fd10a095dd ci: limit switching branches for auto_test_script 2020-11-06 17:19:54 +08:00
538b04bf14 Merge branch 'bugfix/fix_16mbit_psram_id_read_error_v4.1' into 'release/v4.1'
psram: fix 16mbit psram id read error (backport v4.1)

See merge request espressif/esp-idf!9426
2020-11-05 14:10:39 +08:00
534b8a7940 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 04:13:39 +00:00
cbf4d51ddb psram: fix 16mbit psram id read error 2020-11-05 04:13:39 +00:00
91e435d662 Merge branch 'feature/lwip_tcp_isn_hook_v4.1' into 'release/v4.1'
lw-ip: enable TCP ISN hook (v4.1)

See merge request espressif/esp-idf!11063
2020-11-05 12:10:17 +08:00
ab1f6299ff Merge branch 'bugfix/fix_uart_module_enable_issue_v4.1' into 'release/v4.1'
Bugfix (uart):  fix uart module reset issue (release/v4.1)

See merge request espressif/esp-idf!8592
2020-11-05 10:32:28 +08:00
7cbf4c4330 Merge branch 'bugfix/fix_i2s_reset_issue_v4.1' into 'release/v4.1'
driver(I2S): Fix I2S reset issue for release/v4.1

See merge request espressif/esp-idf!9584
2020-11-05 09:05:50 +08:00
32c3db089b Merge branch 'bugfix/fix_i2c_slave_rxfifo_full_interrupt_bug_v.4.1' into 'release/v4.1'
Bugfix (I2C): fix I2C slave rxfifo_full interrupt enabled incorrectly bug (release/v4.1)

See merge request espressif/esp-idf!7679
2020-11-05 02:27:03 +08:00
c8289caa23 Merge branch 'mesh/bugfix_1023_backport_v4.1' into 'release/v4.1'
esp_wifi_mesh: update wifi mesh libs(Backport v4.1)

See merge request espressif/esp-idf!11080
2020-11-04 22:49:47 +08:00
73381b5582 Merge branch 'bugfix/pcnt_interrupt_clear_v4.1' into 'release/v4.1'
pcnt: fix bug in clear interrupt status (v4.1)

See merge request espressif/esp-idf!10693
2020-11-04 19:43:01 +08:00
5ca047ac9b Merge branch 'bugfix/rmt_memory_write_multiple_blocks_v4.1' into 'release/v4.1'
rmt: fix TX data truncated issue (v4.1)

See merge request espressif/esp-idf!10904
2020-11-04 18:44:51 +08:00
eda943b7c5 driver(uart): fix uart module reset issue (release/v4.1)
On ESP32, due to fifo reset issue, UART2 will work incorrectly if reset the fifo of UART1(TX fifo and RX fifo). The software can workaround the RX fifo reset issue,

  while the TX fifo reset issue can not. When UART2 is used and UART1 is used as the log output port, a software reset can reproduce this issue. So we should reset the UART memory

  before the software reset to solve this problem.
2020-11-04 18:41:43 +08:00
e76038ed76 driver(I2C): fix I2C slave rxfifo_full interrupt enabled incorrectly bug (release/v4.1) 2020-11-04 08:25:59 +00:00
9f6f510ce2 driver(I2S): Fix I2S reset issue for release/v4.1
`i2s_start` reseting I2S in incorrect order causeing the word-order error.
2020-11-04 08:18:20 +00:00
f68b6e6c60 Merge branch 'bugfix/lwip_netdb_cpp_guards_v4.1' into 'release/v4.1'
lw-IP: Changed to C linkage in netdb.h for fixing bug when using mixed C/C++ code (v4.1)

See merge request espressif/esp-idf!11090
2020-11-04 15:18:14 +08:00
718efee074 Merge branch 'cherry-pick-65bee988' into 'release/v4.1'
esp_wifi: Add Failures Reason code in all WPS failure send event(backport v4.1)

See merge request espressif/esp-idf!11087
2020-11-04 15:07:55 +08:00
db2eec2096 Merge branch 'bugfix/ci_clone_https_v4.1' into 'release/v4.1'
ci: use HTTPS for cloning in IT jobs (v4.1)

See merge request espressif/esp-idf!11096
2020-11-03 21:45:47 +08:00
e552ea0d9c ci: use HTTPS for cloning in IT jobs 2020-11-03 19:30:30 +08:00
10526ca207 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:42:02 +01:00
55bb405583 Merge branch 'bugfix/wps_fail_reason_code' into 'master'
esp_wifi: Add Failures Reason code in all WPS failure send event

Closes WIFI-2947

See merge request espressif/esp-idf!10924

(cherry picked from commit 65bee98861)

474c38a5 esp_wifi: Add WPS Reason code in all failures
2020-11-03 13:48:21 +08:00
246e97c721 esp_netif: initialize TCP ISN hook if enabled in configuration 2020-11-02 14:27:33 +05:30
3689b94882 lwip: provide configuration option to enable TCP ISN hook 2020-11-02 14:27:33 +05:30
591606ba59 tcp_isn: use ROM APIs for md5 calculations 2020-11-02 14:27:26 +05:30
2b351a936c lwip: add custom TCP ISN hook implementation
Source:
https://git.savannah.nongnu.org/cgit/lwip/lwip-contrib.git/
2020-11-02 14:26:19 +05:30
caee4c24a9 replace list and ringbuffer with fixed queue
use eventgroup to sync spp_vfs_write

each connection has a switch_delay_timer not sharing a one

revert functions like spp_find_slot_by_xxx

fix vfs read bug when peer close
2020-11-02 10:33:19 +08:00
c3171252ec move flow control to btc layer
defer free slot in btc layer when receive BTA_JV_RFCOMM_CLOSE_EVT
2020-11-02 10:33:19 +08:00
8171702293 add event when calling spp API failed 2020-11-02 10:33:19 +08:00
572ccd503f Merge branch 'bugfix/fix_node_test_func_not_set_role_v4.1' into 'release/v4.1'
ble_mesh: test: Fix node test function not update role flag (v4.1)

See merge request espressif/esp-idf!11041
2020-10-30 21:05:40 +08:00
176f146678 Merge branch 'bugfix/err_to_name_paths_windows_v4.1' into 'release/v4.1'
tools: fix path handling errors in gen_esp_err_to_name.py for Windows (v4.1)

See merge request espressif/esp-idf!10896
2020-10-30 15:12:43 +08:00
0cad7edf40 Merge branch 'bugfix/ldgen_section_windows_line_ending_v4.1' into 'release/v4.1'
tools/ldgen: Fix parsing of section names on Windows (v4.1)

See merge request espressif/esp-idf!11036
2020-10-30 03:55:20 +08:00
96a650169a bugfix: import error in example tests 2020-10-29 21:14:54 +08:00
a281b667bb 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-10-29 20:26:49 +08:00
lly
02c3881b7e ble_mesh: test: Fix node test function not update role flag 2020-10-29 15:49:35 +08:00
1bc0f5ac0a tools/ldgen: Fix parsing of sections names on Windows 2020-10-29 08:34:33 +01:00
c89640103f fix ag example outgoing callback not triggered
Closes https://github.com/espressif/esp-idf/issues/4967
2020-10-28 20:13:40 +08:00
e365d1ff60 Merge branch 'feature/esp_tls_for_supplicant_v4.1' into 'release/v4.1'
wpa_supplicant: Support for mbedtls tls handshake(backport v4.1)

See merge request espressif/esp-idf!9856
2020-10-28 19:29:55 +08:00
77eb201241 Merge branch 'bugfix/add_clear_bond_complete_evt_4_1' into 'release/v4.1'
componenet_bt/bugfix: add remove bond device complete event 4.1

See merge request espressif/esp-idf!10653
2020-10-28 16:03:35 +08:00
447708ef05 Merge branch 'bugfix/bredr_bugfix_release_for_qa_dummy_disconnect_4_1' into 'release/v4.1'
Bugfix/bredr bugfix release for qa dummy disconnect 4.1

See merge request espressif/esp-idf!10646
2020-10-28 16:03:21 +08:00
b6615a6c5a Merge branch 'bugfix/wpa_supplicant_link_depth_v4.1' into 'release/v4.1'
wpa_supplicant: Fix failure to link under some circumstances (v4.1)

See merge request espressif/esp-idf!10977
2020-10-28 15:59:22 +08:00
634a5e9355 Merge branch 'bugfix/add_disconn_req_action_when_no_link_4.1' into 'release/v4.1'
Bugfix/add disconn req action when no link 4.1

See merge request espressif/esp-idf!10509
2020-10-28 14:27:10 +08:00
353826cacc rmt: fix RMT data trancate issue
Closes https://github.com/espressif/esp-idf/issues/5992
2020-10-27 19:43:11 +08:00
abc2b2c968 Merge branch 'bugfix/fix_adc_dac_driver_ut_backport_v4.1' into 'release/v4.1'
bugfix(adc): add io init in adc dma driver for esp32  (backport v4.1)

See merge request espressif/esp-idf!10638
2020-10-26 22:04:29 +08:00
153c1f991d Merge branch 'bugfix/fix_tsf_bug_v4.1' into 'release/v4.1'
WiFi: fix tsf bug (backport v4.1)

See merge request espressif/esp-idf!10948
2020-10-26 21:31:57 +08:00
976dc42931 Merge branch 'bugfix/wpa3_to_wpa2_transition_fix_v4.1' into 'release/v4.1'
wpa_supplicant: Fix WPA3 and WPA2 transition related failures (Backport v4.1)

See merge request espressif/esp-idf!9864
2020-10-26 15:09:13 +08:00
865c1dd3dc wpa_supplicant: Fix failure to link under some circumstances
Depending on CMake internals, the wpa_supplicant library may need to be repeated
multiple times in the linker command line.

Closes https://github.com/espressif/esp-idf/issues/5641
2020-10-26 15:13:01 +11:00
c92efa0ae3 Merge branch 'bugfix/ldgen_unicode_path_v4.1' into 'release/v4.1'
tools/ldgen: Parse paths with Unicode characters in archives (v4.1)

See merge request espressif/esp-idf!10965
2020-10-26 12:08:07 +08:00
1e0bb9c4d3 Merge branch 'bugfix/fix_bredr_read_rssi_delta_v4.1' into 'release/v4.1'
Bugfix/Fix Read Rssi Delta Bug in Bredr [backport v4.1]

See merge request espressif/esp-idf!10802
2020-10-26 11:47:45 +08:00
d1d5de9aa5 esp_wifi: Fixed the bug for timestamp check, didn't disconnect AP when AP's timestamp decrease abnormally 2020-10-26 02:10:25 +00:00
de8a512228 Merge branch 'feature/move_auto_test_script_to_new_repo_4.1' into 'release/v4.1'
ci: move auto_test_script to new repo (backport 4.1)

See merge request espressif/esp-idf!10879
2020-10-24 09:25:00 +08:00
52c3aa87b5 ci: move auto_test_script to new repo (backport 4.1) 2020-10-24 09:24:59 +08:00
4836d295a8 tools/ldgen: Parse paths with Unicode characters in archives
Closes https://github.com/espressif/esp-idf/issues/5996
2020-10-23 13:43:55 +02:00
f4e6607e7e Merge branch 'bugfix/ipv6_ping_error_when_src_ip_miss_for_4.1' into 'release/v4.1'
lw-ip:bugfix ipv6 ping error when src ip miss for 4.1(backport 4.1)

See merge request espressif/esp-idf!10933
2020-10-23 15:26:27 +08:00
af66eab249 wpa_supplicant: Fix WPA3 and WPA2 transition related failures
1. If Device is connected to AP in WPA3-PSK mode, AP switching
security to WPA2-PSK causes connection failures even after reset.
Fix is to not store WPA3's PMK in NVS for caching.

2. AP switching back to WPA3 causes even more connection failures.
This is due to device not clearing Supplicant level PMK Cache when
it is no longer valid. Fix is to clear the Cache when 4-way handshake
fails and to check Key Mgmt of Cache before using.

3. When AP switches from WPA3 to WPA2, device's PMF config in
Supplicant remains enabled. This may cause failures during
4-way handshake. So clear PMF config in when PMF is no longer used.
2020-10-22 10:05:02 +00:00
16dd05981b bugfix ipv6 ping error when src ip miss for 4.1 2020-10-21 20:46:39 +08:00
da7eaade68 Merge branch 'bugfix/esp_idf_version_v4.1' into 'release/v4.1'
Add __ASSEMBLER__ flag in esp_idf_version.h to fix build failure with assembly files (v4.1)

See merge request espressif/esp-idf!10900
2020-10-21 20:08:22 +08:00
365cc0c1c8 bugfix(adc): add io init in adc dma driver for esp32 2020-10-20 12:58:26 +00:00
5a0124a103 Merge branch 'bugfix/fix_some_wifi_bugs_0924_v4.1' into 'release/v4.1'
fix some wifi bugs 0924 (v4.1)

See merge request espressif/esp-idf!10613
2020-10-20 20:30:21 +08:00
163bffd0c4 Merge branch 'bugfix/ble_mesh_autorsp_description_v4.1' into 'release/v4.1'
esp_ble_mesh: api: fixed comment about autoresp (v4.1)

See merge request espressif/esp-idf!10889
2020-10-19 16:34:03 +08:00
20fd302201 esp_idf_version.h: Add __ASSEMBLER__ flag to fix build failure with assembly files 2020-10-19 13:21:52 +05:30
a20c4a79e6 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:38:57 +08:00
68961436f1 Merge branch 'spi_dma_close_before_cpu_reset_v4.1' into 'release/v4.1'
spi: fix issue with closing DMA before CPU reset (4.1)

See merge request espressif/esp-idf!10824
2020-10-19 14:30:40 +08:00
dcde5626ad esp_ble_mesh: api: fixed comment about autoresp 2020-10-19 11:00:30 +08:00
65f1be59ad Merge branch 'bugfix/idf_py_disable_cmake_warnings_default_v4.1' into 'release/v4.1'
idf.py: disable cmake uninitialized variable warnings by default (v4.1)

See merge request espressif/esp-idf!10202
2020-10-19 06:34:15 +08:00
961af7f903 spi: fix issue with closing DMA before CPU reset 2020-10-16 06:39:01 +00:00
157ce5953a cmake: Log the project sdkconfig path as part of normal CMake status output
As discussed in footnote to https://github.com/espressif/esp-idf/issues/5251#issuecomment-625563782
2020-10-16 10:11:52 +11:00
bdd7461235 examples: Move idf_as_lib sdkconfig file to the project directory
Also add some explanation about configuring the project in the README

Previously with the default build-esp32.sh script, the build directory was
deleted and recreated so the project would always be built with default config.
2020-10-16 10:11:52 +11:00
d1c78c72d9 Merge branch 'bugfix/mdns_query_id_v4.1' into 'release/v4.1'
mdns: Responding: Fix query ID, add questions if not strict mode (v4.1)

See merge request espressif/esp-idf!10807
2020-10-15 22:43:58 +08:00
96469ad3dd Merge branch 'bugfix/docker_gdb_python_v4.1' into 'release/v4.1'
tools/docker: Add libpython2.7 in order to satisfy GDB dependencies (backport v4.1)

See merge request espressif/esp-idf!10308
2020-10-15 16:01:44 +08:00
3932df3966 tools/docker: Add libpython2.7 in order to satisfy GDB dependencies
It was not possible to run xtensa-esp32-elf-gdb from container due to
missing libpython2.7 library.

Merges https://github.com/espressif/esp-idf/pull/5817
Closes https://github.com/espressif/esp-idf/issues/5284
2020-10-14 19:07:34 +00:00
ad78c86936 Merge branch 'feature/oocd_ver_backport_v4.1' into 'release/v4.1'
tools: Updates OpenOCD version to 'v0.10.0-esp32-20200709' (backport v4.1)

See merge request espressif/esp-idf!8435
2020-10-15 02:53:28 +08:00
e810e4f036 Merge branch 'optimize/ble_mesh_make_buf_config_invisible_v4.1' into 'release/v4.1'
ble_mesh: stack: Make mesh buf debug option invisible (v4.1)

See merge request espressif/esp-idf!10795
2020-10-13 19:51:38 +08:00
27a6550800 Merge branch 'feat/ble_mesh_device_properties_v2_v4.1' into 'release/v4.1'
Feat/ble mesh device properties v2 (v4.1)

See merge request espressif/esp-idf!10788
2020-10-13 19:50:03 +08:00
lly
18c753ba67 ble_mesh: stack: Make mesh buf debug option invisible 2020-10-13 09:31:32 +00:00
lly
1b1139ed55 ble_mesh: stack: Add mesh device properties v2 definitions
Also fixes wrong characteristic value length of some device
properties.
2020-10-13 09:29:50 +00:00
lly
10a618e7b2 ble_mesh: stack: Move device property to model common part 2020-10-13 09:29:50 +00:00
e877d96ee2 Merge branch 'bugfix/ble_mesh_proxy_cfg_replay_v4.1' into 'release/v4.1'
Bugfix/ble mesh proxy cfg replay (v4.1)

See merge request espressif/esp-idf!10820
2020-10-13 17:24:04 +08:00
4c1903a83e esp_wifi:
1. Modify LR for esp32 and esp32s2
2. Fix esp32s2 RTS rate
3. Optimize some debug logs for probe response
4. Optimize phy and soc files
5. Fix the bug that no event for connect
6. drop receiving packets from myself
2020-10-13 16:22:22 +08:00
d9fa1f6436 wpa_supplicant: Fix IOT issue with latest freeradius
Fix inter operability issue with freeradius version 3.0.21
and openssl 1.1.1f when internal tls client is used which
requires extension elements in client hello.

closes https://github.com/espressif/esp-idf/issues/5273
closes https://github.com/espressif/esp-idf/issues/5627
2020-10-13 08:09:00 +00:00
1d59af5c84 wpa_supplicant: Fix invalid pointer deference and memleak
Add following changes as part of this:

1. EAP client will crash during validation of key size when CA
certs and keys not present. Add changes to validate it first.
2. Free memory allocated in TLS context
2020-10-13 08:09:00 +00:00
70fb594873 wpa_supplicant: Support for mbedtls tls handshake
Add support for mbedtls based tls handshake, this removes
dependency from internal implementation of EAP client.
2020-10-13 08:09:00 +00:00
lly
6dadc60c8e ble_mesh: stack: Store kr phase after value changed [Zephyr] 2020-10-13 14:28:44 +08:00
lly
79d7cb2751 ble_mesh: stack: Fix rpl not check by proxy cfg [Zephyr] 2020-10-13 14:28:44 +08:00
d363fafb0b Merge branch 'bugfix/ble_mesh_node_deinit_v4.1' into 'release/v4.1'
ble_mesh: stack: Persistent storage misc fixes (v4.1)

See merge request espressif/esp-idf!10814
2020-10-13 14:07:04 +08:00
lly
0c136620d9 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:54:18 +08:00
c01f0a08fc Merge branch 'bugfix/ble_mesh_settings_fix_v4.1' into 'release/v4.1'
Bugfix/ble mesh settings fix (v4.1)

See merge request espressif/esp-idf!10785
2020-10-13 10:50:03 +08:00
d94867aaac Merge branch 'bugfix/fix_transport_ssl_blocking_v4.1' into 'release/v4.1'
transport: fix transport ssl blocking (v4.1)

See merge request espressif/esp-idf!10692
2020-10-12 21:42:16 +08:00
fcfc04c42a mdns test: Add test to resolve esp32 hostname with DiG 2020-10-12 13:26:27 +02:00
2afcd77874 examples: Common connect component: Unregister shutdown handler on disconnection
To be able to connect smoothly after disconnecting, we have to unregister all handlers including shutdown handler on disconnection
2020-10-12 13:26:27 +02:00
12e86a7c1b mdns: Support queries in responses in mDNS non-strict mode
By default adds original queries to responses in order to be resolved by some resolvers, such as lwIP mdns library. This functionality however is discouraged by the RFC6762, so it could be disabled in menuconfig if MDNS_STRICT_MODE configured

Closes https://github.com/espressif/esp-idf/issues/5521
2020-10-12 13:24:30 +02:00
e2b314522e mdns: Fix include query ID in reponses
Closes https://github.com/espressif/esp-idf/issues/5574
2020-10-12 13:24:30 +02:00
87bcb95180 transport: fix transport ssl blocking
In SSL mode, if `esp_transport_poll_read` function is used, the cache data in mebdtls will be blocked
2020-10-12 10:11:22 +00:00
ca42c8ec5c 1. fix read rssi delta bug in bredr
2. modify read rssi related function names

Closes https://github.com/espressif/esp-idf/issues/5660
2020-10-12 17:55:53 +08:00
lly
d48b719e66 ble_mesh: stack: Use settings_core_erase when deinit 2020-10-12 08:47:49 +08:00
lly
cf500b3f47 ble_mesh: stack: Fix storing next net_idx and app_idx 2020-10-12 08:47:49 +08:00
lly
ff88343a10 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 08:47:49 +08:00
lly
66a798dbf2 ble_mesh: stack: Split model settings store and clear 2020-10-12 08:47:49 +08:00
lly
2598844423 ble_mesh: stack: Erase netkey and appkey with key index 2020-10-12 08:47:49 +08:00
lly
402fe837c1 ble_mesh: stack: Add clear hb_pub in settings 2020-10-12 08:47:49 +08:00
lly
e05d42d910 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 08:47:48 +08:00
lly
895dd44f8e ble_mesh: stack: Use erase settings functions 2020-10-12 08:47:47 +08:00
lly
ecf065e2a6 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 08:47:46 +08:00
lly
5444c8a462 ble_mesh: stack: Add role check before enabling device 2020-10-12 08:47:45 +08:00
lly
4b27c84095 ble_mesh: stack: Define a type for mesh nvs handle 2020-10-12 08:47:45 +08:00
lly
53d7b12c29 ble_mesh: ci: Enable settings in sdkconfig.ci.xxx 2020-10-12 08:47:44 +08:00
5d258af93c Merge branch 'feature/guide_change_for_catalina_v4.1' into 'release/v4.1'
docs: Add profile file name used by zsh shell (v4.1)

See merge request espressif/esp-idf!10773
2020-10-10 18:02:51 +08:00
3bca931923 docs: Add profile file name used by zsh shell 2020-10-09 19:16:59 +02:00
751e0d205d Merge branch 'bugfix/nimble_host_rcv_pkt_length_check_v4.1' into 'release/v4.1'
NimBLE: host_rcv_pkt event buf size check. (v4.1)

See merge request espressif/esp-idf!10759
2020-10-09 15:19:41 +08:00
0d25a9cff8 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:29:57 +05:30
580246d6ff Merge branch 'gdb/bt_on_invalid_pc_v4.1' into 'release/v4.1'
gdb: Modify PC in case of invalid PC (v4.1)

See merge request espressif/esp-idf!10748
2020-10-08 17:42:53 +08:00
7caa230cf9 Merge branch 'bugfix/ci_auto_checkout_revision_of_project_used_in_ci_v4.1' into 'release/v4.1'
CI: get git describe from annotated tags (v4.1)

See merge request espressif/esp-idf!10674
2020-10-08 16:44:18 +08:00
e957cfe0eb Merge branch 'bugfix/bootloader_anti_rollback_mmap_v4.1' into 'release/v4.1'
bootloader_support: fix issue in memory mapping for getting app descriptor (v4.1)

See merge request espressif/esp-idf!10735
2020-10-08 16:31:54 +08:00
63c006ac91 gdb: Modify PC in case of invalid PC
Incase the PC is invalid, GDB will fail to translate addresses to
function names. To fix this, replace the invalid PC with a placeholder
address
2020-10-08 11:13:17 +05:30
c48760e2d1 Merge branch 'bugfix/embed_file_symbol_names_v4.1' into 'release/v4.1'
cmake: fix C identifier generation from embedded file (v4.1)

See merge request espressif/esp-idf!10665
2020-10-08 11:59:50 +08:00
9f49a27c12 ci: Check version tags are always annotated
Closes https://github.com/espressif/esp-idf/issues/3114
2020-10-07 13:57:19 +11:00
df61488e54 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:57:19 +11:00
f7f81c33f7 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:42:45 +05:30
dc66bcb5ac Merge branch 'bugfix/efuse_test_stackoverflow_v4.1' into 'release/v4.1'
CI: Increase stack size for efuse unit test (Backport v4.1)

See merge request espressif/esp-idf!10547
2020-10-06 16:20:17 +08:00
15edb0d4b5 Merge branch 'bugfix/returns_correct_flash_encryption_mode_v4.1' into 'release/v4.1'
bootloader: Fix esp_get_flash_encryption_mode() (v4.1)

See merge request espressif/esp-idf!10713
2020-10-05 13:50:48 +08:00
ccfe70872e Fix ccache documentation: environment variable is IDF_CCACHE_ENABLE
Merges https://github.com/espressif/esp-idf/pull/5753
2020-10-05 05:35:02 +00:00
aecb2bd8ee idf.py: Disable CMake --warn-uninitialized option by default
Can still be enabled by passing --cmake-warn-uninitialized on the command line

Prevents CMake warnings printed by default if IDF_PATH is underneath the CMake
project directory.

The reason for this is that CMake --warn-uninitialized only enables checks
inside the project directory (ie top-level CMakeLists.txt directory and
subdirectories), it doesn't enable for files included from other directories.

(The only way to enable warnings in other directories is to pass
--check-system-dirs and this looks like it's only useful for CMake's own
developers as it prints a lot of warnings from inside CMake otherwise - see
https://gitlab.kitware.com/cmake/cmake/-/issues/19645 )

Plan to follow up with a later commit to clean up most of the warnings (which
aren't problems for CMake execution), but we'll also disable this option by
default to avoid this unexpected triggering of IDF warnings.
2020-10-05 05:35:02 +00:00
37fb85b998 Merge branch 'bugfix/spi_flash_yield_coredump_v4.1' into 'release/v4.1'
spi_flash: don't call vTaskDelay in non-os context (v4.1)

See merge request espressif/esp-idf!10298
2020-10-03 14:52:55 +08:00
66acb32665 bootloader: Fix esp_get_flash_encryption_mode(). RELEASE = (CRYPT_CNT == max) or (CRYPT_CNT.write_protect == true)
If the CRYPT_CNT efuse is max it means the same as a write protection bit for this efuse.

Closes: https://github.com/espressif/esp-idf/issues/5747
2020-10-01 14:29:43 +08:00
52baa25aa1 CI: get git describe from annotated tags:
we should only parse IDF version from annotated tags
2020-09-30 11:33:04 +08:00
73a4063163 pcnt: fix bug in clear interrupt status 2020-09-30 11:12:33 +08:00
ef1d0b3d2e cmake: fix C identifier generation from embedded file 2020-09-28 21:16:20 +08:00
e0ee809d7d cmake: fix getting component requirements 2020-09-28 18:56:18 +08:00
684ffdfe70 components/bt: Replace task post with btc_inter_profile_call, when post message from btc_dm to btc_gap 2020-09-28 15:27:24 +08:00
98e7bc3375 components/bt: Fix clear bond fail when connected without ble included 2020-09-28 15:26:56 +08:00
9c4e79dafa add remove bond device complete event 2020-09-28 15:26:48 +08:00
09e48edd87 1.revert dummy command
2.fix send MEDIA_CTRL command in disconnect
2020-09-28 11:11:12 +08:00
3db75c4e9d 1.fix test case dummy
2.fix sink send media control ESP_A2D_MEDIA_CHECK_SRC_RDY
2020-09-28 11:10:54 +08:00
7b7c641076 Merge branch 'feature/docs-add-python-clean_v4.1' into 'release/v4.1'
docs: Add solution for ImportError in idf.py into the documentation (v4.1)

See merge request espressif/esp-idf!10631
2020-09-27 14:28:07 +08:00
49ee45e89b Merge branch 'optimize/ble_mesh_provisioner_delete_dev_v4.1' into 'release/v4.1'
ble_mesh: stack: Optimize Provisioner delete device function (v4.1)

See merge request espressif/esp-idf!10604
2020-09-27 10:53:20 +08:00
c44bc3752f docs: add description of python-clean command 2020-09-27 00:03:56 +02:00
5a0ee17ae2 Merge branch 'bugfix/remove_shortcut_to_build_instructions_v4.1' into 'release/v4.1'
doc: Getting Started Guide, remove shortcuts to 'build toolchain from scratch' instructions (v4.1)

See merge request espressif/esp-idf!10607
2020-09-25 21:04:49 +08:00
83482b8912 doc: Getting Started Guide, remove shortcuts to 'build toolchain from scratch' instructions 2020-09-25 16:05:49 +08:00
7b60e83fd0 Merge branch 'doc/remove_lts_versions_v4.1' into 'release/v4.1'
docs: Update Versions file in line with the latest Support Policy document (v4.1)

See merge request espressif/esp-idf!10601
2020-09-25 14:16:57 +08:00
lly
0e83f4b960 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:03:52 +08:00
dab3d1750e docs: Update Versions file in line with the latest Support Policy document 2020-09-25 10:12:56 +10:00
4a1cfff12c Merge branch 'bugfix/update_esp32_phy_4390_v4.1' into 'release/v4.1'
esp_wifi: update phy v4390.(backport v4.1)

See merge request espressif/esp-idf!10487
2020-09-24 14:14:10 +08:00
df7fc6c452 Merge branch 'bugfix/can_mmap_after_get_enough_free_mmu_pages_v4.1' into 'release/v4.1'
flash_mmap: can mmap after get enough free MMU pages (backport v4.1)

See merge request espressif/esp-idf!10585
2020-09-24 14:13:46 +08:00
d5d05b053a Merge branch 'bugfix/fix_build_err_in_cpp_backport_v4.1' into 'release/v4.1'
ble_hid_device_demo: fix build if building with c++ backport v4.1

See merge request espressif/esp-idf!9232
2020-09-24 13:05:10 +08:00
46238b6ef0 Merge branch 'doc/add_UUID_description_in_gattc_demo_backport_v4.1' into 'release/v4.1'
docs:add 128-bit UUID description backport v4.1

See merge request espressif/esp-idf!9225
2020-09-24 13:05:01 +08:00
1cffedd6d2 Merge branch 'cherry-pick-4dcaa0e6-2' into 'release/v4.1'
wpa_supplicant: Deinit wpa2 states in wifi deinit(backport v4.1)

See merge request espressif/esp-idf!10162
2020-09-24 13:04:18 +08:00
e14f4d3fdb Merge branch 'bugfix/confirmed_bugfix_from_baidu_proj_4.1' into 'release/v4.1'
Confirmed bugfix from Baidu project 4.1

See merge request espressif/esp-idf!10545
2020-09-24 13:01:16 +08:00
d4e9953212 Merge branch 'bugfix/cpp_header_rom_secure_boot_v4.1' into 'release/v4.1'
Secure Boot: Fixes the cpp macro in esp32 secure boot rom functions.

See merge request espressif/esp-idf!10572
2020-09-24 12:25:22 +08:00
387905a4ad flash_mmap: restore interrupt and cache before err return 2020-09-24 09:59:06 +08:00
0ff3ceba32 flash_mmap: can mmap after get enough free MMU pages 2020-09-24 09:59:06 +08:00
b29209e3db Merge branch 'bugfix/ipv6_send_data_error_when_src_ip_miss_for_4.1' into 'release/v4.1'
lw-ip:ipv6 send multicast data fail when src address is null ( backport 4.1)

See merge request espressif/esp-idf!10559
2020-09-23 22:29:52 +08:00
805ee815d0 Merge branch 'bugfix/wifi_spin_lock_allocation_in_PSRAM_v4.1' into 'release/v4.1'
wifi: Fix spin lock allocation in PSRAM bug(v4.1)

See merge request espressif/esp-idf!10552
2020-09-23 18:58:27 +08:00
8a849b29f2 Merge branch 'bugfix/panic_instr_fetch_prohibited_v4.1' into 'release/v4.1'
panic: skip over the first invalid PC in case of InstrFetchProhibited (v4.1)

See merge request espressif/esp-idf!10294
2020-09-23 17:00:16 +08:00
66315e71fe Secure Boot: Fixes the cpp macro in esp32 secure boot rom functions.
Closes https://github.com/espressif/esp-idf/issues/5878
2020-09-23 02:57:30 +05:30
e55af6c8a5 ipv6 send multicast data fail when src address is null for 4.1 2020-09-22 17:21:10 +08:00
b7fb9be045 Merge branch 'bugfix/openss_strict_verify_mode_4.1' into 'release/v4.1'
openssl: made verification mode conversion to mbetls modes more strict (v4.1)

See merge request espressif/esp-idf!10500
2020-09-22 16:33:02 +08:00
59ff505809 Merge branch 'bugfix/adjtime_return_outdelta_before_new_delta_set_v4.1' into 'release/v4.1'
newlib: Fix adjtime, returns the amount of time remaining from any previous adjustment (v4.1)

See merge request espressif/esp-idf!9972
2020-09-22 15:34:27 +08:00
d95e91b344 Fix spin lock allocation in PSRAM bug 2020-09-22 14:28:18 +08:00
67b87e1bd8 Merge branch 'bugfix/fix_udp_tx_performance_issue_v4.1' into 'release/v4.1'
lw-ip: fix udp tx packet loss issue (backport v4.1)

See merge request espressif/esp-idf!10018
2020-09-22 14:16:12 +08:00
890a62b53e CI: Increase stack size for efuse unit test
"Batch mode is thread-safe" case would occasionally cause a stackoverflow.
Increased stack size.
2020-09-22 12:00:33 +08:00
754c91f9e1 Confirmed bugfix from Baidu project 2020-09-22 11:46:01 +08:00
8350f2fb6e openssl: made verification mode conversion to mbetls modes more strict 2020-09-21 13:21:41 +00:00
d83520060c Merge branch 'bugfix/esp32s2_o2_op_v4.1' into 'release/v4.1'
freertos: fix build error at -O2 optimization level (v4.1)

See merge request espressif/esp-idf!10304
2020-09-21 15:15:16 +08:00
4b11a05391 lwip: fix IPv6 ND6 queue too much pkts cause no mem issue and add menuconfig item for this params. 2020-09-21 11:08:47 +08:00
4b662d1a22 lw-ip: fix udp tx packet loss issue 2020-09-21 10:58:43 +08:00
214cc69fc1 Merge branch 'bugfix/spi_master_multiple_dev_with_diff_cs_lvl_4.1' into 'release/v4.1'
spi_master: correctly set cs polarity (4.1)

See merge request espressif/esp-idf!10392
2020-09-21 10:19:33 +08:00
1e526a5d7d Merge branch 'bugfix/wifi_create_and_start_ap_v4.1' into 'release/v4.1'
Set default AP handlers in wifi_create_and_start_ap() v4.1

See merge request espressif/esp-idf!10457
2020-09-20 16:36:16 +08:00
167966380b Merge branch 'docs/fix_event_typo_backport_v4.1' into 'release/v4.1'
docs/fix event typo backport v4.1

See merge request espressif/esp-idf!9383
2020-09-20 16:29:33 +08:00
e348a291ad spi_flash: don't call vTaskDelay in non-os context
Fixes regression in core dump, when a crash happens in interrupt
context.
2020-09-18 15:34:32 +00:00
ecd9d2515f Merge branch 'bugfix/parttool_example_test_fail_v4.1' into 'release/v4.1'
examples/parttool: fix the test to work on parallel test runner (backport v4.1)

See merge request espressif/esp-idf!10374
2020-09-18 23:30:45 +08:00
88a3f963c4 Merge branch 'bugfix/provisioning_example_warning_with_O2_optimization_v4.1' into 'release/v4.1'
provisioning: use memcpy instead of strncpy for copying SSID (v4.1)

See merge request espressif/esp-idf!10495
2020-09-18 17:25:59 +08:00
6870c87aac add file stream parameter and log stdout and stderr to same stream 2020-09-18 10:39:07 +02:00
f78c8cc0db Redesign separating AVRC & A2DP
1. Add g_av_with_rc to avrc_tg_init function
2. Remove g_av_open_fail
3. Add comment in API files
4. Add a2dp init & deinit state variable to inidcate a2dp statement
2020-09-18 14:11:27 +08:00
e797e742f8 Add global header and change declaration position 2020-09-18 14:11:18 +08:00
627b5a4cae Remove uneccessary macro
Separate AVRC from A2DP when AVRC not Initialized
2020-09-18 14:11:10 +08:00
3c88fa5a1e Rewrite a2dp clean_up function 2020-09-18 14:11:00 +08:00
8ad40cecb4 Add bda_addr for esp_bt_a2dp_disconn_req API
1. Add reaction for a2dp snk & src disconn req when no link up
  2. Change state machine set before EVT upto APP layer in some cases
  3. Add bool open_fail to choose whether post disconnection evt to app layer
2020-09-18 14:10:48 +08:00
98b6fe8f30 Merge branch 'bugfix/ble_mesh_check_stack_init_v4.1' into 'release/v4.1'
ble_mesh: stack: Check if mesh stack initialized before init vendor client (v4.1)

See merge request espressif/esp-idf!10482
2020-09-18 09:40:01 +08:00
5f5a398662 Merge branch 'backport/shared_stack_4.1' into 'release/v4.1'
Backport/shared stack 4.1

See merge request espressif/esp-idf!10302
2020-09-18 05:15:30 +08:00
04b8564249 provisioning: use memcpy instead of strncpy for copying SSID
Per WiFi library requirement, SSID can be non-null terminated string
if its length goes to 32 bytes (maximum). Use of strncpy in this case,
along with compiler optimization level -O2 results in some warnings
for potential use of non-null terminated strings.

Fix here ensures use of memcpy to copy SSID string upto appropriate
desired length. This helps to avoid compiler specific workaround
flags added earlier.

Closes https://github.com/espressif/esp-idf/issues/5866
Closes IDFGH-3983
2020-09-17 15:54:23 +05:30
c2f46eb802 Merge branch 'feature/toolchain_2020r3_v4.1' into 'release/v4.1'
Update toolchain to esp-2020r3 (backport v4.1)

See merge request espressif/esp-idf!10389
2020-09-17 18:07:10 +08:00
bee6612ab9 Merge branch 'bugfix/doc_build_ut_cmdline_v4.1' into 'release/v4.1'
docs: Fixup format of a command line to build unit tests (backport v4.1)

See merge request espressif/esp-idf!9043
2020-09-17 17:43:35 +08:00
2c87065521 esp_wifi: update phy v4390.(backport v4.1) 2020-09-17 15:51:09 +08:00
f280be4a86 Merge branch 'bugfix/clean_wpa2_wifi_deinit' into 'master'
wpa_supplicant: Deinit wpa2 states in wifi deinit

See merge request espressif/esp-idf!10103

(cherry picked from commit 4dcaa0e6f4)

06bc7f1d wpa_supplicant: Deinit wpa2 states in wifi deinit
2020-09-17 06:06:40 +00:00
89523af91f toolchain: C++ exception workaround
* disable C++ exception FDE sorting (saves RAM)

Closes IDF-1128
2020-09-17 10:51:39 +07:00
c7ba54ed73 Update toolchain to esp-2020r3
Fixup more for PSRAM issue;
    Allow GDB work correctly with Privileged Registers;
    Based on GCC 8.4.0;
    Update a fix of C++ exception crashs from the GCC mainline;
    Fixup strptime_l() and some locale in libc;
2020-09-17 10:49:14 +07:00
lly
d1311d1e23 ble_mesh: stack: Check if mesh stack initialized before init vendor client 2020-09-17 11:26:40 +08:00
94cb7e8b8f Merge branch 'bugfix/cxx_flag_operators_v4.1' into 'release/v4.1'
esp_eth: moved extern "C" after includes (v4.1)

See merge request espressif/esp-idf!10352
2020-09-15 16:13:06 +08:00
01db565aef Merge branch 'bugfix/ulp_as_version_v4.1' into 'release/v4.1'
ulp: fix ULP assembler version detection for localized systems (v4.1)

See merge request espressif/esp-idf!10394
2020-09-15 15:23:18 +08:00
e7b34b921d Merge branch 'bugfix/eclipse_make_py3_v4.1' into 'release/v4.1'
tools: Fix Python 3 incompatibility for building with Eclipse on Windows (v4.1)

See merge request espressif/esp-idf!10399
2020-09-15 15:08:12 +08:00
ab98baff14 Merge branch 'bugfix/bootloader_skip_verify_jtag_v4.1' into 'release/v4.1'
bootloader_support: don't check signature when JTAG is attached (v4.1)

See merge request espressif/esp-idf!10379
2020-09-15 15:06:17 +08:00
26bfb1cf10 Set default AP handlers in wifi_create_and_start_ap() 2020-09-15 14:53:11 +08:00
b022bb2770 Merge branch 'feature/portmux_debug_bump_timeout' into 'release/v4.1'
bugfix/freertos: increase portmux timeouts to avoid crashing when using debug feature

See merge request espressif/esp-idf!9957
2020-09-15 14:29:19 +08:00
e1ad627a0f docs: Fixup format of a command line to build unit tests 2020-09-15 16:21:44 +10:00
9d359b814f ci: Use git mirror for docker image 2020-09-14 12:49:29 +02:00
1ced3f9750 Merge branch 'bugfix/add_return_in_uart_wait_tx_done_bp4.1' into 'release/v4.1'
bugfix(UART): Add return in uart_wait_tx_done(backport v4.1)

See merge request espressif/esp-idf!10336
2020-09-14 14:25:05 +08:00
edb19cd748 Merge branch 'bugfix/fix_rtcio_adc_driver_for_esp32' into 'release/v4.1'
rtc(adc/rtcio): fix adc rtcio driver for esp32

See merge request espressif/esp-idf!8347
2020-09-14 10:57:26 +08:00
9e8b44e353 Merge branch 'bugfix/ble_mesh_prov_iv_index_v4.1' into 'release/v4.1'
ble_mesh: stack: Using the latest iv_index for provisioning (v4.1)

See merge request espressif/esp-idf!10417
2020-09-11 20:09:01 +08:00
df3aef80c0 Merge branch 'component/seperate_bta_jv_l2c_4.1' into 'release/v4.1'
Component/seperate bta jv l2c 4.1

See merge request espressif/esp-idf!9645
2020-09-11 19:38:00 +08:00
b204bc1bd6 Merge branch 'bugfix/change_pcm_config_position_4.1' into 'release/v4.1'
Bugfix/ Change PCM config position 4.1

See merge request espressif/esp-idf!10314
2020-09-11 19:35:55 +08:00
b131fffa84 Merge branch 'bugfix/add_protection_for_spp_api_4.1' into 'release/v4.1'
Bugfix/add protection for spp api 4.1

See merge request espressif/esp-idf!10282
2020-09-11 19:33:49 +08:00
lly
bca0b85fc3 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 10:56:06 +08:00
445635fe45 Merge branch 'bugfix/fix_some_wifi_bugs_0907_v4.1' into 'release/v4.1'
bugfix: fix some wifi bugs (backport v4.1)

See merge request espressif/esp-idf!10315
2020-09-10 22:33:05 +08:00
10c498ae7d expression_with_stack: added a tweak on TCB stackpointers to avoid false trigger of stack overflow 2020-09-10 10:00:32 -03:00
723c8d9899 Merge branch 'bugfix/btdm_spp_null_ptr_with_dynamic_memory_v4.1' into 'release/v4.1'
components/bt: Fix SPP using NULL point with dynamic memory

See merge request espressif/esp-idf!10323
2020-09-10 18:24:11 +08:00
97b1f0f60c Merge branch 'init_priority_fix_v4.1' into 'release/v4.1'
CXX: make __attribute__((init_priority(n))) work (v4.1)

See merge request espressif/esp-idf!8444
2020-09-10 16:10:10 +08:00
b695152d43 Merge branch 'feature/nvs_allow_custom_part_4.1' into 'release/v4.1'
Feature/nvs allow custom part 4.1

See merge request espressif/esp-idf!9515
2020-09-10 16:08:36 +08:00
31f9c88269 tools: Fix Python 3 incompatibility for building with Eclipse on Windows 2020-09-10 09:46:10 +02:00
28e393c062 ulp: fix ULP assembler version detection for localized systems 2020-09-10 09:35:45 +02:00
67d7fad764 spi_master: correctly set cs polarity
All devices must be added to the same spi line before use.
2020-09-10 14:48:37 +08:00
ae72c7d417 Merge branch 'bugfix/secure_boot_v2_sign_cmake_copy_v4.1' into 'release/v4.1'
Add platform independent CMake copy during signing (v4.1)

See merge request espressif/esp-idf!9545
2020-09-10 14:41:26 +08:00
e42c8d2f1f Merge branch 'feat/ble_mesh_use_model_c_v4.1' into 'release/v4.1'
ble_mesh: stack: Use model callback for operations [Zephyr] (v4.1)

See merge request espressif/esp-idf!10363
2020-09-10 10:39:54 +08:00
b5df4843b2 Merge branch 'bugfix/ble_mesh_remove_assert_v4.1' into 'release/v4.1'
ble_mesh: stack: Avoid using assert in mesh stack (v4.1)

See merge request espressif/esp-idf!10359
2020-09-10 10:39:00 +08:00
33ddc213ad Merge branch 'bugfix/ble_mesh_nimble_ccc_handle_v4.1' into 'release/v4.1'
ble_mesh: nimble: Fix updating ccc handle with wrong value (v4.1)

See merge request espressif/esp-idf!10355
2020-09-10 10:38:19 +08:00
42e694bb8f bootloader_support: don't check signature when JTAG is attached
If an insecure configuration is enabled (no hardware secure boot, just
software signature check), skip the signature check in bootloader if
JTAG debugger is attached. This allows the debugger to set breakpoints
in Flash before the application runs.

Closes https://github.com/espressif/esp-idf/issues/4734
Closes https://github.com/espressif/esp-idf/issues/4878
2020-09-09 23:42:24 +02:00
48fda05b3e 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:37:06 +02:00
146c714541 Merge branch 'bugfix/remove_auto_conn_case_v4.1' into 'release/v4.1'
test: remove auto conn case because we do not support this anymore (v4.1)

See merge request espressif/esp-idf!9941
2020-09-09 15:55:05 +08:00
e9ece1255a 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-09 07:34:40 +00:00
lly
c570f51b53 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:00:21 +08:00
lly
67055161c1 ble_mesh: stack: Avoid using assert in mesh stack 2020-09-09 10:57:25 +08:00
5c223e17cb esp_eth: moved extern "C" after includes 2020-09-09 10:19:10 +08:00
aa8fffcd73 Merge branch 'bugfix/doc_main_readme_build_v4.1' into 'release/v4.1'
Fix the setup instructions in the main README (v4.1)

See merge request espressif/esp-idf!10338
2020-09-09 02:45:49 +08:00
lly
67ed9b5799 ble_mesh: nimble: Fix updating ccc handle with wrong value 2020-09-08 21:02:34 +08:00
7da1603a1c Fix the setup instructions in the main README 2020-09-08 10:15:15 +02:00
824c358097 UART: Add return in uart_wait_tx_done
uart_wait_tx_done quit due to timeout but without return ESP_ERR_TIMEOUT.
2020-09-08 15:10:30 +08:00
5123c80060 Merge branch 'bugfix/ipv6_fragment_for_4.1' into 'release/v4.1'
lw-ip:fix bug for ipv6 fragment(backport4.1)

See merge request espressif/esp-idf!9648
2020-09-08 12:21:10 +08:00
86cd54117e components/bt: Fix SPP using NULL point with dynamic memory 2020-09-07 15:45:33 +08:00
d425a25875 Merge branch 'feature/mqtt_sub_update_01594bf1_v4.1' into 'release/v4.1'
MQTT: Update submodule reference (Backport v4.1)

See merge request espressif/esp-idf!10231
2020-09-07 14:58:56 +08:00
217e95d4db Merge branch 'bugfix/ws_stop_deadlock_v4.1' into 'release/v4.1'
Websocket client: avoid deadlock if stop called from event handler (Backport 4.1)

See merge request espressif/esp-idf!10227
2020-09-07 14:58:25 +08:00
7891ba1e24 Merge branch 'bugfix/l2cap_link_timeout_llcp_prog_btu_wtd_v4.1' into 'release/v4.1'
Bugfix/l2cap link timeout llcp prog btu wtd v4.1

See merge request espressif/esp-idf!10254
2020-09-07 14:11:57 +08:00
585120da0d Change PCM config position 2020-09-07 10:34:34 +08:00
420d436199 freertos: fix compilation warning at -O2 level
Closes https://github.com/espressif/esp-idf/issues/5525
2020-09-04 21:39:10 +02:00
124ec431e6 test/shared_stack_printf: improved printf with shared stack function test 2020-09-04 16:03:51 -03:00
3a96d07e11 panic: skip over the first invalid PC in case of InstrFetchProhibited
InstrFetchProhibited usually occurs because of a jump to an invalid
pointer. In this case, PC in the exception frame is the address of
the jump destination. 'esp_ptr_executable' check in print_backtrace
function recognizes the first frame as invalid, and the backtrace is
interrupted. This prevents the user from finding the location where
the invalid pointer is dereferenced.

Bypass the 'esp_ptr_executable' check if the exception cause is
InstrFetchProhibited. Update the test case to no longer ignore this
issue.
2020-09-04 20:56:03 +02:00
245047e82d Merge branch 'feature/enable_pcm_config_v4.1' into 'release/v4.1'
Feature/enable pcm config v4.1

See merge request espressif/esp-idf!9654
2020-09-04 20:07:27 +08:00
4e8ebc2463 Merge branch 'bugfix/ble_mesh_sensor_example_fix_v4.1' into 'release/v4.1'
ble_mesh: example: Fix sensor data wrong iteration (v4.1)

See merge request espressif/esp-idf!10274
2020-09-04 16:54:51 +08:00
e963390324 component/bt: Fixed the watchdog timeout of btu task during multi-connection 2020-09-04 16:25:49 +08:00
febabaa55a Merge branch 'ci/test_spi_speed_psram_enabled_4.1' into 'release/v4.1'
driver test: disable the spi master performance test when psram is used (v4.1)

See merge request espressif/esp-idf!9638
2020-09-04 15:55:01 +08:00
b4dc11a409 Add protection for rfcomm close API in SPP 2020-09-04 14:41:34 +08:00
15111210a1 Add some debug log for bt:
1. Add logs for SPP not enabled successfully
2. Add information to Applicatioin layer that the A2DP is connecting to peer device

Regular BTC and BTU Task name & Add BTC Init protection

1. Regular the BTC Task Name to Close a Github issue

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

2. Add BTC Init failure protection

3. Regular BTU Task Name with BTC

4. Correct the comment of
   a. SDP_ServiceSearchRequest and SDP_ServiceSearchRequest2
   b. l2cu_create_conn_after_switch

5. Correct comment of esp_bt_hf_vra();

6. Fix cpp compilier region
2020-09-04 14:41:26 +08:00
lly
eff8dedb2b ble_mesh: example: Fix sensor data wrong iteration 2020-09-04 11:55:14 +08:00
aefe9e0b03 remove auto conn case because we do not support this anymore 2020-09-04 03:32:19 +00:00
da530f01dc Merge branch 'bugfix/http_client_read_v4.1' into 'release/v4.1'
Fix error handling in esp_http_client_read and esp_https_ota_perform (v4.1)

See merge request espressif/esp-idf!9203
2020-09-03 19:58:33 +08:00
8acffd2931 components/bt: Fixed the state not synchronized between controller and host when disconnected. 2020-09-02 21:45:26 +08:00
39ef55261c Increase receive timeout in sdkconfig.ci to fix CI failures 2020-09-02 12:30:51 +00:00
101c1a953a 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-09-02 12:30:51 +00:00
b9edf4783c esp_http_client.c: In esp_http_client_read, add fix to return (-1) if esp_transport_read fails 2020-09-02 12:30:51 +00:00
da669efa0c Merge branch 'bugfix/btdm_blufi_data_sequence_not_reset_after_disconnect_v4.1' into 'release/v4.1'
component/bt: fix Blufi sends data after disconnect the seq still increase(backport v4.1)

See merge request espressif/esp-idf!10240
2020-09-02 14:20:44 +08:00
1f54e90bb4 component/bt: fix Blufi sends data after disconnect the seq still increase(backport v4.1) 2020-09-02 11:15:27 +08:00
444b5582a7 driver test: disable the spi master performance test when psram is used 2020-09-02 00:58:20 +08:00
eca90124fb Merge branch 'bugfix/ble_mesh_example_compile_warn_v4.1' into 'release/v4.1'
Bugfix/ble mesh example compile warn (v4.1)

See merge request espressif/esp-idf!10223
2020-09-01 20:39:39 +08:00
645715c1b0 Enable PCM config in controller 2020-09-01 16:35:07 +08:00
887f5040da Enable PCM config in host 2020-09-01 16:35:07 +08:00
1d4b8a742d 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

SSL: add support for tls with secure element (ATECC608A)
esp-mqtt commit: a7ff9afa3f)
Closes https://github.com/espressif/esp-mqtt/issues/156

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-09-01 16:00:49 +08:00
d28f1682fc Websocket client: avoid deadlock if stop called from event handler 2020-09-01 15:38:12 +08:00
lly
41a3759314 ble_mesh: example: Remove some useless included header files 2020-09-01 14:11:39 +08:00
3adfa1ac78 Fix compilation warnings about portmacro being already define. 2020-09-01 14:11:06 +08:00
85e3c733ff Merge branch 'bugfix/ble_mesh_client_msg_optimize_v4.1' into 'release/v4.1'
Bugfix/ble mesh client msg optimize (v4.1)

See merge request espressif/esp-idf!10214
2020-09-01 09:34:09 +08:00
f6517cf4e7 Merge branch 'bugfix/ppp_netif_up_after_new_v4.1' into 'release/v4.1'
esp-netif: ppp netif to use netif_is_link_up() to update interface state (v4.1)

See merge request espressif/esp-idf!9425
2020-08-31 21:14:04 +08:00
636a719f4d Merge branch 'feature/pin_ethernet_task_to_core_v4.1' into 'release/v4.1'
ethernet: support pin emac task to core (v4.1)

See merge request espressif/esp-idf!9037
2020-08-31 21:13:39 +08:00
lly
92ce5c1f23 ble_mesh: stack: Client model related code clean 2020-08-31 17:33:12 +08:00
lly
df1c6fd95c ble_mesh: stack: Rename cfg & health client status recv func 2020-08-31 17:33:11 +08:00
lly
bbe75af7a3 ble_mesh: stack: Check client msg result in common func 2020-08-31 17:33:11 +08:00
lly
4634ad6fa4 ble_mesh: stack: Fix no events for some error conditions 2020-08-31 17:33:10 +08:00
lly
5ccf6cd381 ble_mesh: stack: Move client role set to the msg function 2020-08-31 17:33:10 +08:00
lly
259d1924cb ble_mesh: stack: Remove some not used client parameters 2020-08-31 17:33:09 +08:00
lly
1bd4fe1f50 ble_mesh: stack: Remove some not used variables & functions 2020-08-31 17:33:09 +08:00
lly
62458dbb90 ble_mesh: stack: Update client model msg send 2020-08-31 17:33:08 +08:00
d81dbd48ed Merge branch 'bugfix/ble_mesh_health_current_status_recv_v4.1' into 'release/v4.1'
ble_mesh: stack: Fix recv health current status incorrectly (v4.1)

See merge request espressif/esp-idf!10208
2020-08-31 17:30:10 +08:00
0dea1b38cb sleep: enable sleep reject when entering light sleep 2020-08-31 08:58:51 +00:00
e1115c951e Merge branch 'bugfix/fix_static_analysis_rules_v4.1' into 'release/v4.1'
static analysis: Apply current limits of known defects (v4.1)

See merge request espressif/esp-idf!9282
2020-08-31 14:42:36 +08:00
2973114938 Merge branch 'bugfix/eth_insert_min_hw_reset_time_v4.1' into 'release/v4.1'
ethernet: insert min assert time for PHY HW reset (v4.1)

See merge request espressif/esp-idf!9580
2020-08-31 14:41:10 +08:00
2222f842d6 Merge branch 'bugfix/esp_netif_restart_dhcpc_v4.1' into 'release/v4.1'
esp_netif: Remove restarting DHCP client/server if it has already been started (backport v4.1)

See merge request espressif/esp-idf!10000
2020-08-31 14:40:14 +08:00
8b89fbe88b Merge branch 'bugfix/ws_send_abort_v4.1' into 'release/v4.1'
websocket client: the client now aborts the connection if send fails.  (v4.1)

See merge request espressif/esp-idf!9170
2020-08-31 14:38:40 +08:00
2c1bf3ec3b esp-netif: ppp netif to use netif_is_link_up() to update interface state
Closes https://github.com/espressif/esp-idf/issues/5069
2020-08-31 06:38:17 +00:00
aaa7476456 ethernet: support pin emac task to core 2020-08-31 06:36:23 +00:00
b72ab0b1f8 Merge branch 'bugfix/ethernet_handle_early_rx_interrupt_v4.1' into 'release/v4.1'
Bugfix/ethernet handle early rx interrupt (v4.1)

See merge request espressif/esp-idf!10099
2020-08-31 14:34:36 +08:00
lly
5704b13bc9 ble_mesh: stack: Fix recv health current status incorrectly 2020-08-31 13:57:12 +08:00
32fa7c6c6c Merge branch 'bugfix/ble_mesh_misc_updates_v4.1' into 'release/v4.1'
Bugfix/ble mesh misc updates (v4.1)

See merge request espressif/esp-idf!10206
2020-08-31 13:42:06 +08:00
lly
d4348656ec ble_mesh: ci: Enable friend & low power in build check 2020-08-31 11:23:36 +08:00
lly
c3b300064b 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-31 11:23:35 +08:00
lly
bbd9a8a44d ble_mesh: stack: Make proxy server & client functions clear 2020-08-31 11:23:34 +08:00
72f43489a5 rtc(adc/rtcio): fix adc rtcio driver for esp32 2020-08-31 03:19:58 +00:00
5f9a48c352 Merge branch 'bugfix/ble_mesh_add_misc_check_v4.1' into 'release/v4.1'
Bugfix/ble mesh add misc check (v4.1)

See merge request espressif/esp-idf!10198
2020-08-31 11:15:01 +08:00
5b97931527 Merge branch 'feature/vfs_uart_set_line_ending_v4.1' into 'release/v4.1'
vfs: support vfs uart set line endings with specified uart number release/v4.1

See merge request espressif/esp-idf!9597
2020-08-30 22:33:11 +08:00
89d9b2ac27 Merge branch 'bugfix/mfg_tool_v4.1' into 'release/v4.1'
mfg_util: Update file handling to maintain line endings across various OS (backport v4.1)

See merge request espressif/esp-idf!10175
2020-08-28 18:23:14 +08:00
lly
72ce618f9a ble_mesh: stack: Add proxy cfg pdu length check 2020-08-28 17:45:09 +08:00
lly
36dc7ae71e 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-28 17:45:08 +08:00
lly
7fa85d9a6a ble_mesh: example: Add result check during mesh init 2020-08-28 17:45:08 +08:00
lly
7b57311a0e ble_mesh: stack: Add more checks about input prov bearers 2020-08-28 17:45:07 +08:00
6e52afaa2b Merge branch 'feat/ble_mesh_use_iram_for_mem_alloc_v4.1' into 'release/v4.1'
Feat/ble mesh use iram for mem alloc (v4.1)

See merge request espressif/esp-idf!10186
2020-08-28 17:32:26 +08:00
lly
ad412850d0 ble_mesh: stack: Rename mesh adv queue and relay queue 2020-08-28 06:07:17 +00:00
lly
20d33f27d6 ble_mesh: stack: Use macros for adv task name & prio 2020-08-28 06:07:17 +00:00
lly
34690034e6 ble_mesh: ci: Add psram configurations 2020-08-28 06:07:17 +00:00
lly
84012fa82f ble_mesh: stack: Make freertos static allocation visible 2020-08-28 06:07:17 +00:00
lly
ffcd55bbf2 ble_mesh: stack: Update option of using DRAM/SPIRAM for memory allocation 2020-08-28 06:07:17 +00:00
e1e082072c Merge branch 'bugfix/ble_mesh_fast_prov_misc_update_v4.1' into 'release/v4.1'
Bugfix/ble mesh fast prov misc update (v4.1)

See merge request espressif/esp-idf!9465
2020-08-28 14:03:10 +08:00
329f7f8210 Merge branch 'bugfix/btdm_blufi_send_longer_custom_data_will_congested_v4.1' into 'release/v4.1'
component/bt: fix Blufi sends longer customer data  will will lead congested(backport v4.1)

See merge request espressif/esp-idf!9947
2020-08-28 13:55:28 +08:00
0cc8639e2f Merge branch 'bugfix/ble_mesh_update_send_ttl_v4.1' into 'release/v4.1'
Bugfix/ble mesh update send ttl (v4.1)

See merge request espressif/esp-idf!10159
2020-08-28 10:43:43 +08:00
a88420c860 component/bt: fix Blufi sends longer customer data will will lead congested(backport v4.1) 2020-08-28 07:10:11 +08:00
21ef71fa2b Merge branch 'bugfix/customer_baidu_int_wdt_v4.1' into 'release/v4.1'
backport v4.1: add soft solution for esp32 eco3 live lock issue

See merge request espressif/esp-idf!9209
2020-08-27 22:44:56 +08:00
346f09bf1c Merge branch 'bugfix/fix_some_wifi_bugs_0703_v4.1' into 'release/v4.1'
fix some wifi bugs 0703 (v4.1)

See merge request espressif/esp-idf!9517
2020-08-27 22:44:25 +08:00
lly
ce4a8af3c7 ble_mesh: stack: Update some fast prov functions 2020-08-27 14:36:58 +00:00
lly
e3a7fb2fd4 ble_mesh: stack: Move fast prov functions to a single file 2020-08-27 14:36:58 +00:00
9b9ff7b183 Merge branch 'bugfix/ble_mesh_split_tinycrypt_v4.1' into 'release/v4.1'
Bugfix/ble mesh split tinycrypt (v4.1)

See merge request espressif/esp-idf!10160
2020-08-27 22:26:38 +08:00
lly
7308f60a74 ble_mesh: ci: Fix failing to compile when using make 2020-08-27 10:57:51 +00:00
lly
50fc403018 ble_mesh: Mark platform related default RNG as 0 2020-08-27 10:57:51 +00:00
lly
0b65005ffd ble_mesh: Remove the previously added redundant aes files 2020-08-27 10:57:51 +00:00
lly
60ba33afa9 ble_mesh: Update CMake and make files for tinycrypt 2020-08-27 10:57:51 +00:00
lly
d90f3f9119 ble_mesh: Update tinycrypt header file include guards
Add BLE_MESH in the macro to make it specific for BLE Mesh.
2020-08-27 10:57:51 +00:00
lly
7d40d308bb ble_mesh: Format source and header files of tinycrypt 2020-08-27 10:57:51 +00:00
lly
0dda8869cd ble_mesh: Port full implementation of tinycrypt [Zephyr]
- Original code is here: https://github.com/zephyrproject-rtos/tinycrypt
- Also this fixes the compile error when NimBLE and ESP BLE Mesh
  both uses the tinycrypt.
2020-08-27 10:57:51 +00:00
8a0ae62a03 Merge branch 'bugfix/ble_mesh_compile_error_v4.1' into 'release/v4.1'
Bugfix/ble mesh proxy compile error (v4.1)

See merge request espressif/esp-idf!9431
2020-08-27 18:03:01 +08:00
6c15b3c44e Merge branch 'bugfix/ble_mesh_example_tag_define_v4.1' into 'release/v4.1'
ble_mesh: Move TAG definition to each example (v4.1)

See merge request espressif/esp-idf!10171
2020-08-27 18:02:49 +08:00
4680bae94d mfg_util: Update file handling to maintain line endings across various OS
Fixes: https://github.com/espressif/esp-idf/issues/4888
2020-08-27 11:55:32 +05:30
ce0189dd5a Merge branch 'bugfix/ble_mesh_readme_fix_v4.1' into 'release/v4.1'
ble_mesh: example: Fix example README & tutorial link error (v4.1)

See merge request espressif/esp-idf!9435
2020-08-27 14:24:27 +08:00
lly
90403c658c ble_mesh: Move TAG definition to each example
Move the TAG definition of each example to the corresponding
source file (previously it is defined in the common example
intialization header file), which can avoid the redefinition
of TAG in some situations.
2020-08-27 06:00:01 +00:00
c4c3696d9b Merge branch 'bugfix/ble_mesh_example_nvs_store_v4.1' into 'release/v4.1'
Bugfix/ble mesh example nvs store (v4.1)

See merge request espressif/esp-idf!9016
2020-08-27 13:58:45 +08:00
ca5c632b38 Merge branch 'workaround/wps_iot_fixes_v4.1' into 'release/v4.1'
wpa_supplicant: WPS Inter operatability Fixes( backport v4.1)

See merge request espressif/esp-idf!8952
2020-08-27 11:42:21 +08:00
a7bd982556 Merge branch 'bugfix/espcoredump_fix_error_reported_for_blank_partition_v41' into 'release/v4.1'
Bugfix/espcoredump fix error reported for blank partition (Backport v4.1)

See merge request espressif/esp-idf!9628
2020-08-27 08:46:59 +08:00
8647e5a839 Bugfix/espcoredump fix error reported for blank partition (Backport v4.1) 2020-08-27 08:46:58 +08:00
065d64555d Merge branch 'bugfix/idf_py_help_env_var_v4.1' into 'release/v4.1'
Tools: Mention ESPPORT and ESPBAUD in idf.py --help (v4.1)

See merge request espressif/esp-idf!9291
2020-08-27 08:46:43 +08:00
2a3ecaa926 Merge branch 'feature/pyc_clean_v4.1' into 'release/v4.1'
tools/idf.py: Clean Python bytecode files (v4.1)

See merge request espressif/esp-idf!9263
2020-08-27 08:46:38 +08:00
b76c3afa3a Merge branch 'bugfix/no_pyc_files_v4.1' into 'release/v4.1'
tools: Don't generate pyc files (v4.1)

See merge request espressif/esp-idf!8970
2020-08-27 08:46:30 +08:00
ab7eafa3b8 wpa_supplicant: WPS Inter operatability Fixes
Add WPS IOT fixes under config option

Current fixes under this flag.
1. Allow NULL-padded WPS attributes.
2. Bypass WPS-Config method validation
2020-08-26 08:49:43 +00:00
367397385e wpa_supplicant: Allow NULL-padded WPS attributes
Some AP's keep NULL-padding at the end of some variable length WPS
Attributes. This is not as par the WPS2.0 specs, but to avoid interop
issues, ignore the padding by reducing the attribute length by 1.
2020-08-26 08:49:43 +00:00
lly
632cfa5a82 ble_mesh: Add nvs operations for examples
- Store onoff_client example proper mesh info
- Store vendor_client example proper mesh info

Closes https://github.com/espressif/esp-idf/issues/5359
2020-08-26 08:28:12 +00:00
lly
6dddeaec5b ble_mesh: Add mesh example common nvs operations 2020-08-26 08:28:12 +00:00
lly
8988fb9b8d ble_mesh: Config and health client btc fixes
Fix an issue which may cause no error code is returned
when sending config client or health client messages
with invalid parameters.
2020-08-26 08:28:12 +00:00
lly
bd187b022f ble_mesh: Add more checks of net_idx & app_idx 2020-08-26 08:28:12 +00:00
lly
7ba69e5439 ble_mesh: Optimize some send & recv logs 2020-08-26 08:28:12 +00:00
lly
75af20e687 ble_mesh: stack: Add two application macros for TTL 2020-08-26 16:12:26 +08:00
lly
5952694160 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-08-26 16:12:26 +08:00
lly
1c87f1df05 ble_mesh: example: Fix example README & tutorial link error 2020-08-26 16:03:36 +08:00
e40e694cf9 Merge branch 'bugfix/ble_mesh_set_recv_rssi_v4.1' into 'release/v4.1'
Bugfix/ble mesh set recv rssi (v4.1)

See merge request espressif/esp-idf!9400
2020-08-26 15:56:02 +08:00
lly
476a54886f ble_mesh: ci: Add different proxy configurations 2020-08-26 07:50:10 +00:00
lly
45f7edd4f2 ble_mesh: stack: Fix compile error when only proxy enabled
Also remove some redundant CONFIG_BLE_MESH_PROXY checks, because
when the following options are satisfied, the CONFIG_BLE_MESH_PROXY
option will be selected mandatorily.
2020-08-26 07:50:10 +00:00
fea61290d3 Fix tsk watchdog when running spp vfs demo 2020-08-26 15:30:26 +08:00
899ef49272 Seperate BTA_JV_L2CAP for less bin size 2020-08-26 15:30:26 +08:00
ade43317ca Merge branch 'bugfix/ble_mesh_get_node_with_name_v4.1' into 'release/v4.1'
ble_mesh: Get node info with pre-configured node name (v4.1)

See merge request espressif/esp-idf!10145
2020-08-26 15:28:15 +08:00
58d37de620 esp_wifi: Add API to get available internal heap size. 2020-08-26 12:06:26 +08:00
1e8f68f829 esp_wifi:
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 WiFi fragment issue
2020-08-26 12:05:50 +08:00
a27ea5a6c8 Merge branch 'feature/bt_secure_conn_downgrade_check_v4.1' into 'release/v4.1'
Bluedroid: Authentication fixes in Legacy and Secure Connection.

See merge request espressif/esp-idf!9339
2020-08-26 11:33:12 +08:00
d54f4bd691 Merge branch 'bugfix/idf_build_process_default_v4.1' into 'release/v4.1'
cmake: fix issue with setting defaults in idf_build_process (v4.1)

See merge request espressif/esp-idf!9712
2020-08-26 07:58:54 +08:00
84c0fde0e8 fix bug for ipv6 fragment 2020-08-25 17:43:13 +08:00
lly
292333a27c ble_mesh: Get node info with pre-configured node name
Also add a function to get the entry of the nodes table.

Closes https://github.com/espressif/esp-idf/issues/5397
2020-08-25 09:35:34 +08:00
1c8ce47465 Merge branch 'bugfix/ble_mesh_check_subnet_before_update_beacon_sent_v4.1' into 'release/v4.1'
ble_mesh: Check if subnet exists before updating beacon_sent (v4.1)

See merge request espressif/esp-idf!9396
2020-08-24 17:20:12 +08:00
lly
bd59c89540 ble_mesh: stack: Copy recv_rssi for other received messages
Follow the commit: 2b80cb6883,
copy the recv_rssi for other mesh messages.
2020-08-24 08:52:05 +00:00
c3fe42250c When a generic mesh model message is received "bt_mesh_generic_server_cb_evt_to_btc" copies the
ctx values to cb_params for the mesh stack.

recv_rssi was not copied.

This means the rssi could not be read when receiving generic server messages using ble_mesh.
2020-08-24 08:52:05 +00:00
f664527eb4 vfs: support vfs uart set line endings with specified uart number (release/v4.1) 2020-08-24 15:37:44 +08:00
9b7dca3769 Merge branch 'bugfix/bootloader_common_get_sha256_of_partition_v4.1' into 'release/v4.1'
bootloader_support: Fix bootloader_common_get_sha256_of_partition(), can handle a long image (v4.1)

See merge request espressif/esp-idf!9953
2020-08-24 13:37:27 +08:00
24efb6308d Merge branch 'bugfix/mbedtls_mpi_exp_mod_v4.1' into 'release/v4.1'
mbedtls: Fix a case for mpi_montgomery_exp_calc() when Z is not init (v4.1)

See merge request espressif/esp-idf!9495
2020-08-24 13:36:51 +08:00
6f22d7590e Bluedroid: Authentication fixes in Legacy and Secure Connection.
Prevent a remote device from doing a Bluetooth Impersonation Attack
(BIAS) by:

- Preventing remote device to downgrade secure connection
feature mask. Secure connection feature mask should remain same or
increase to enabled in link key generation and authentication.

- Doing a mutual authentication during Legacy Authentication.

Signed-off-by: Chinmay Chhajed <chinmay.chhajed@espressif.com>
2020-08-24 10:27:04 +05:30
91903234a9 Merge branch 'bugfix/fix_event_bug_in_GAP_API_release_v4.1' into 'release/v4.1'
Bugfix/fix event bug in GAP API [backport v4.1]

See merge request espressif/esp-idf!9192
2020-08-24 12:34:30 +08:00
294a00c15d Merge branch 'feature/esp_spp_stop_srv_v4.1' into 'release/v4.1'
bugfix/Add API esp_spp_stop_srv and fix collection of SPP [backport v4.1]

See merge request espressif/esp-idf!10011
2020-08-24 12:34:04 +08:00
55203e9c09 Merge branch 'bugfix/wifi_deinit_stop_crash_v4.1' into 'release/v4.1'
esp_wifi: fix the crash when wifi stop after deinit (v4.1)

See merge request espressif/esp-idf!10030
2020-08-24 12:32:58 +08:00
a40a5405b7 Merge branch 'feature/make_tcp_rto_configurable_v4.1' into 'release/v4.1'
make TCP rto time configurable (backport v4.1)

See merge request espressif/esp-idf!9212
2020-08-24 12:32:23 +08:00
c547044f28 Merge branch 'bugfix/fix_error_in_ag_api_4.1' into 'release/v4.1'
Fix error of AG API return line v4.1

See merge request espressif/esp-idf!9604
2020-08-24 12:32:21 +08:00
d4af9d1ce4 Merge branch 'bugfix/fix_hci_max_page_num_v4.1' into 'release/v4.1'
bugfix/Support for more Bluetooth HID devices [backport v4.1]

See merge request espressif/esp-idf!9661
2020-08-24 12:31:22 +08:00
bb0fe3785f Merge branch 'bugfix/fix_softap_mode_wpa_memory_leak_issue_v4.1' into 'release/v4.1'
bugfix: fix softap mode wpa memory leak (backport v4.1)

See merge request espressif/esp-idf!9846
2020-08-24 12:30:37 +08:00
84b9ce81bb Merge branch 'bugfix/fix_get_bond_device_list_v4.1' into 'release/v4.1'
bugfix/fix esp_bt_gap_get_bond_device_list bug [backport v4.1]

See merge request espressif/esp-idf!9667
2020-08-24 12:30:07 +08:00
6b1473e084 Merge branch 'bugfix/fix_ping_specify_length_issue_v4.1' into 'release/v4.1'
bugfix: fix ICMP specify length issue (backport v4.1)

See merge request espressif/esp-idf!9402
2020-08-24 12:29:41 +08:00
975b8d228f Merge branch 'bugfix/put_periph_module_enable/diable_into_iram_v4.1' into 'release/v4.1'
wifi, bt: move esp_phy_common_clock_disable into periph_ctrl and put it into IRAM(v4.1)

See merge request espressif/esp-idf!9936
2020-08-24 12:28:25 +08:00
a36a020657 Merge branch 'bugfix/connect_param_check_and_channel_map_bugs_v4.1' into 'release/v4.1'
components/bt:Fix channel map instant reverse and add ble connect paramter check.(backport 4.1)

See merge request espressif/esp-idf!9235
2020-08-24 12:27:59 +08:00
788fe71b6b Merge branch 'nimble/nrpa_support_v4.1' into 'release/v4.1'
NimBLE: Add Non-Resolvable private address support and misc fixes (Backport v4.1)

See merge request espressif/esp-idf!9740
2020-08-24 12:27:03 +08:00
9c96e4554c Merge branch 'mesh/bugfix_set_type_4.1' into 'release/v4.1'
mesh/bugfix (backport 4.1)

See merge request espressif/esp-idf!9111
2020-08-24 12:25:26 +08:00
c9ca1fbe78 Merge branch 'bugfix/fix_touch_sensor_api_backport_v4.1' into 'release/v4.1'
(High priority) driver(touch): fix touch sensor driver redundancy (backport v4.1)

See merge request espressif/esp-idf!9872
2020-08-23 16:08:49 +08:00
e3e5a41bc9 Merge branch 'doc/broken_readme_links_v4.1' into 'release/v4.1'
Docs: Fix broken README links (v4.1)

See merge request espressif/esp-idf!9502
2020-08-22 00:40:19 +08:00
c47cbe8139 Merge branch 'docs/doc138_backport_v4.1' into 'release/v4.1'
Fix incorrect redirect link in getting started guide (backport v4.1)

See merge request espressif/esp-idf!9719
2020-08-22 00:38:37 +08:00
d2fd9c10b3 Merge branch 'doc/freertos_backport_v4.1' into 'release/v4.1'
add a note about ESP-IDF FreeRTOS version (backport v4.1)

See merge request espressif/esp-idf!9811
2020-08-22 00:18:25 +08:00
lly
3d888ca777 ble_mesh: Check if subnet exists before updating beacon_sent
- Before updating the "beacon_sent" of a subnet, we need to check
  if the subnet still exists, especially for a Provisioner.
- Fix a bug which will cause Provisioner failed to send Secure
  Network Beacon if no device is provisioned
2020-08-21 12:58:34 +00:00
2a5679c253 Merge branch 'bugfix/ble_mesh_model_recv_fix_v4.1' into 'release/v4.1'
Bugfix/ble mesh model recv fix (v4.1)

See merge request espressif/esp-idf!9007
2020-08-21 20:37:53 +08:00
b7259bab36 Merge branch 'bugfix/ble_mesh_local_model_sub_v4.1' into 'release/v4.1'
Bugfix/ble mesh local model sub (v4.1)

See merge request espressif/esp-idf!8983
2020-08-21 20:37:37 +08:00
a3f71eeeb4 Merge branch 'test/merge_ble_mesh_node_and_provioner_in_console_v4.1' into 'release/v4.1'
Test:merge ble mesh node and provioner in console (backport v4.1)

See merge request espressif/esp-idf!9912
2020-08-21 20:00:34 +08:00
3512a775bc Test:merge ble mesh node and provioner in console 2020-08-21 20:00:32 +08:00
869742de00 Merge branch 'bugfix/freemodbus_fix_long_frame_buffer_failure_backport4_1' into 'release/v4.1'
freemodbus: freemodbus fix long frame buffer failure (backport v4.1)

See merge request espressif/esp-idf!8197
2020-08-21 18:59:45 +08:00
2a4e91553d Merge branch 'bugfix/mcpwm_fault_init_copypaste_typo_bp4.1' into 'release/v4.1'
MCPWM: Fix PWM-fault init function that read config incorrectly (backport v4.1)

See merge request espressif/esp-idf!9553
2020-08-21 18:58:25 +08:00
fc1f1902a8 Merge branch 'bugfix/gpio_hold_function_for_esp32' into 'release/v4.1'
Bugfix/gpio hold function for esp32 (backport v4.1)

See merge request espressif/esp-idf!9175
2020-08-21 18:50:23 +08:00
lly
9ba5899206 ble_mesh: correct the return type [Zephyr] 2020-08-21 07:21:15 +00:00
lly
6b6cf151cf ble_mesh: Add net_buf_simple_init_with_data [Zephyr] 2020-08-21 07:21:15 +00:00
lly
897acd6a1d ble_mesh: Optimize model recv operations [Zephyr]
Previously the model recv operation is a littl fuzzy.
With the changes, the model recv operation is splitted into:
- find op
- check app_idx
- check dst
- check length
- update info & handle message
2020-08-21 07:21:15 +00:00
lly
cc36e415c0 ble_mesh: Local model (un)subscribes group address 2020-08-21 07:18:44 +00:00
lly
a43e5feee8 ble_mesh: Define a macro for invalid company id 2020-08-21 07:18:44 +00:00
ab6139b9df Merge branch 'bugfix/ble_mesh_check_model_status_v4.1' into 'release/v4.1'
ble_mesh: stack: Check model status with variable length (v4.1)

See merge request espressif/esp-idf!9399
2020-08-21 14:57:03 +08:00
6e42afb45b Merge branch 'bugfix/ble_mesh_not_define_bool_v4.1' into 'release/v4.1'
Bugfix/ble mesh not define bool (v4.1)

See merge request espressif/esp-idf!9394
2020-08-21 14:56:46 +08:00
252aaf2ab7 Merge branch 'bugfix/ble_mesh_bt_hex_v4.1' into 'release/v4.1'
ble_mesh: Fix wrong log output with bt_hex (v4.1)

See merge request espressif/esp-idf!9393
2020-08-21 14:56:34 +08:00
9ff30e81c5 Merge branch 'bugfix/ble_mesh_remove_relay_dependency_v4.1' into 'release/v4.1'
ble_mesh: Remove relay option dependency (v4.1)

See merge request espressif/esp-idf!9026
2020-08-21 14:56:23 +08:00
7bc32cb773 Merge branch 'bugfix/ble_mesh_rework_prov_pdu_len_check_v4.1' into 'release/v4.1'
ble_mesh: Rework prov pdu length check (v4.1)

See merge request espressif/esp-idf!9003
2020-08-21 14:56:07 +08:00
12cb99e815 Merge branch 'bugfix/enable_mbedtls_renegotiation_v4.1' into 'release/v4.1'
esp-tls: enable TLS renegotiation using explicit API call (v4.1)

See merge request espressif/esp-idf!9592
2020-08-21 12:30:45 +08:00
866dde5025 Merge branch 'bugfix/sdmmc_check_slot_before_pullup_4.1' into 'release/v4.1'
sdmmc: Correctly check function parameters before using them (4.1)

See merge request espressif/esp-idf!9055
2020-08-20 21:59:31 +08:00
829080e10e Merge branch 'bugfix/convert-string-to-bytes_v4.1' into 'release/v4.1'
components: convert string to bytes to fix TypeError (backport v4.1)

See merge request espressif/esp-idf!9733
2020-08-20 21:54:21 +08:00
67504984c1 Merge branch 'feature/upgrade_mbedtls_to_v4.1' into 'release/v4.1'
mbedtls: update to mbedtls release v2.16.7 (v4.1)

See merge request espressif/esp-idf!9907
2020-08-20 21:52:51 +08:00
29c40aa784 Merge branch 'bugfix/mbedtls_disable_sha_mpi_v4.1' into 'release/v4.1'
mbedtls: Don't compile hardware MPI & SHA files if disabled in config (v4.1)

See merge request espressif/esp-idf!9403
2020-08-20 21:50:36 +08:00
6e22f6bae9 Merge branch 'fix/esp_tls_wolfssl_fix_cert_verify_v4.1' into 'release/v4.1'
esp_tls_wolfssl : fix incorrect error message after handshake fails (v4.1)

See merge request espressif/esp-idf!9231
2020-08-20 21:48:50 +08:00
23a36bdd77 Merge branch 'bugfix/http_server_lru_v4.1' into 'release/v4.1'
esp_http_server: Update LRU counter on accepting a new connection (v4.1)

See merge request espressif/esp-idf!9351
2020-08-20 21:47:56 +08:00
b3af5fb2c3 Merge branch 'bugfix/softap_prov_session_v4.1' into 'release/v4.1'
protocomm_httpd: Restart security session if request is received on a new session (v4.1)

See merge request espressif/esp-idf!9116
2020-08-20 21:47:34 +08:00
a603bf9e02 Merge branch 'bugfix/httpd_lru_purge_v4.1' into 'release/v4.1'
esp_http_server: Fixed a bug which could cause issues with LRU purge (v4.1)

See merge request espressif/esp-idf!8830
2020-08-20 21:46:45 +08:00
9ff88e9f0e Merge branch 'fixbug/sdmmc_spi_highspeed_v4.1' into 'release/v4.1'
sdmmc: fix the probe issue that forbid sdspi working in highspeed mode(backport v4.1)

See merge request espressif/esp-idf!9840
2020-08-20 19:14:30 +08:00
c83a8c4cc7 Merge branch 'bugfix/fix_fifo_cnt_bug_v4.1' into 'release/v4.1'
bugfix(uart): fix esp32 fifo_cnt bug(backport v4.1)

See merge request espressif/esp-idf!9040
2020-08-20 19:13:57 +08:00
000c0b4b8a Merge branch 'bugfix/fix_adc_dac_conflict_backportv4.1' into 'release/v4.1'
Driver(adc): Disable the synchronization operation function of ADC1 and DAC (backport v4.1)

See merge request espressif/esp-idf!9361
2020-08-20 19:12:35 +08:00
d8061fa8d9 Merge branch 'bugfix/esp_flash_revert_qe_clear_4.1' into 'release/v4.1'
esp_flash: fix the regression of non-quad mode by default chip driver, bugs in add_device and deprecate cs_id (4.1)

See merge request espressif/esp-idf!8836
2020-08-20 19:11:00 +08:00
6e148c0051 Merge branch 'bugfix/esp_flash_write_performance_regression_4.1' into 'release/v4.1'
esp_flash: fix the write performance regression (Backport v4.1)

See merge request espressif/esp-idf!8800
2020-08-20 19:09:59 +08:00
612d8f173f ethernet: support power on timeout
Closes https://github.com/espressif/esp-idf/issues/5425
2020-08-20 10:54:50 +08:00
221e89cf59 ethernet: set DMA owner after all descriptors have configured 2020-08-20 10:54:50 +08:00
f5dde8b17e ethernet: handle early rx interrupt 2020-08-20 10:54:49 +08:00
4fc12259dd Driver(adc): Disable the synchronization operation function of ADC1 and DAC
Closes IDF-1585
2020-08-14 06:49:35 +00:00
40bc362809 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 espressif/esp-idf!9114
2020-08-13 12:15:33 +08:00
5ef1b39002 Merge branch 'fix/prov_ble_read_offset_v4.1' into 'release/v4.1'
BLE provisioning: Add check for valid ble read offset (v4.1)

See merge request espressif/esp-idf!9745
2020-08-13 07:54:36 +08:00
c519d78e00 mbedtls: Fix a case for mpi_montgomery_exp_calc() when Z is not init
Closes: IDF-1870

Closes: IDFGH-3671

Closes: https://github.com/espressif/esp-idf/issues/5605
2020-08-12 14:59:01 +08:00
fe6bc06366 freertos/portmux: increase portmux timeouts to avoid crashing when using debug feature
Closes: https://github.com/espressif/esp-idf/issues/3629#
2020-08-11 11:34:05 -03:00
535fa9615c esp_wifi: fix the crash when wifi stop after deinit 2020-08-10 20:37:38 +08:00
c4f38c361e esp_netif tests: Add manual DHCP state transision tests
Extended test cases for DHCP server and DHCP client state transitions to include also manual transitions using esp_netif_dhcps_start/stop() esp_netif_dhcpc_start/stop()
2020-08-10 18:52:34 +08:00
75c82c5bc7 esp_netif: Remove restarting DHCP client and server if it has already been started
To be in line with previous behaviour in tcpip_adapter, do nothing and return appropriate error if the DHCP client/server has already been started
2020-08-10 18:52:27 +08:00
b57953efdf fix esp_bt_gap_get_bond_device_list bug
Closes https://github.com/espressif/esp-idf/issues/5395
2020-08-10 10:06:42 +08:00
b89a2bb266 add soft solution for esp32 eco3 live lock issue 2020-08-07 06:42:35 +00:00
4d735d8279 newlib: Fix UT for adjtime 2020-08-06 20:02:30 +08:00
c370a8f7ce newlib: Fix adjtime, returns the amount of time remaining from any previous adjustment
If the olddelta argument is not a null pointer, the adjtime function returns information
about any previous time adjustment that has not yet completed.

Closes: https://github.com/espressif/esp-idf/issues/5194
2020-08-06 20:02:30 +08:00
55fafa887c bootloader_support: Fix bootloader_common_get_sha256_of_partition, can handle a long image
Closes: IDFGH-3594
2020-08-05 22:09:15 +08:00
46691df851 wifi, bt: move esp_phy_common_clock_disable into periph_ctrl and put it into IRAM
Replace periph_module_enable/disable by periph_wifi_bt_common_module_enable which are in IRAM.
AddIRAM_ATTR periph_ll_wifi_bt_module_enable_clk_clear_rstandIRAM_ATTR periph_ll_wifi_bt_module_disable_clk_set_rstto fit O0 optimization level.
Delete duplicated spinlock and counter.
2020-08-05 16:30:16 +08:00
ac0731e977 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-08-03 15:46:55 +05:30
bd72a9ab2b Merge branch 'bugfix/can_multiple_fixes_backport_v4.1' into 'release/v4.1'
CAN multiple bug fixes (backport v4.1)

See merge request espressif/esp-idf!9886
2020-08-03 13:04:51 +08:00
f1b651af7e CAN: Remove asserts used for program logic
This commit fixes the bug where CAN driver program logic was being
called in assert(), thus leading to the logic being omitted in
release builds.
2020-07-31 00:19:53 +08:00
550ed39ea3 CAN: Fix size of RX msg count field on the esp32
This commit fixes the size of the RX message count register field
on the esp32.
2020-07-30 23:59:42 +08:00
67a48580fa driver(touch): fix touch sensor driver redundancy 2020-07-30 16:42:48 +08:00
5e536a3f43 CXX: make __attribute__((init_priority(n))) work
* Added corresponding test case
* Moved all C++ init tests to separate file

Closes https://github.com/espressif/esp-idf/issues/5038
2020-07-30 15:40:33 +08:00
lly
7f7397e67f ble_mesh: Remove relay option dependency
When the relay functionality of a node is not enabled, this
issue will cause the node failing to send messages to fixed
group.
2020-07-30 03:58:27 +00:00
59680bbaff nvs: unit tests for new partition API 2020-07-29 16:40:13 +00:00
07a88fbb7c nvs: allow to specify custom partition
Closes https://github.com/espressif/esp-idf/pull/5172
2020-07-29 16:40:13 +00:00
828cc1318b bugfix: fix softap mode wpa memory leak 2020-07-29 14:15:56 +08:00
19fcd9cc19 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 17:38:37 +08:00
ba01132b41 add a note about ESP-IDF FreeRTOS version 2020-07-27 19:05:59 +08:00
9587b53b2f NimBLE: Add Non-Resolvable private address support and misc bug fixes (Backport v4.1)
- 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-24 06:48:14 +00:00
95083233c5 Merge branch 'bugfix/prov_retry_failures_v4.1' into 'release/v4.1'
ci: Add retries for all provisioning methods, some refactors (v4.1)

See merge request espressif/esp-idf!9388
2020-07-23 13:19:30 +08:00
ceeee9036c Merge branch 'ci/fix_uart_read_write_priorities_v4.1' into 'release/v4.1'
driver test: Ensure uart write task can't overflow buffer of read task (v4.1)

See merge request espressif/esp-idf!9570
2020-07-23 13:15:27 +08:00
7e2f701a3c tools: Updates OpenOCD version to 'v0.10.0-esp32-20200709' 2020-07-22 23:37:46 +03:00
be13513378 BLE provisioning: Add check for valid ble read offset 2020-07-22 19:40:49 +05:30
ca38f1eb0a docs: change redirection link in get-started
This link is supposed to go to Step 3, but it goes to Step 2.
2020-07-22 17:44:06 +08:00
36edd91060 Merge branch 'bugfix/rs485_test_temp_disable_v41' into 'release/v4.1'
Bugfix/rs485 test temp disable v41 (backport v4.1)

See merge request espressif/esp-idf!9524
2020-07-22 17:20:00 +08:00
b41752b95c components: convert string to bytes to fix TypeError There is a string passed as an argument for function, but a format of a string seemingly refers to bytes therefore it needs to be converted to bytes Solves https://esp32.com/viewtopic.php?f=13&t=16529
(cherry picked from commit cb0bdb8bba)
2020-07-22 11:19:10 +02:00
b3b7fcf51c Merge branch 'ci/workaround_multiple_ci_failures_v4.1' into 'release/v4.1'
CI: workaround multiple ci failures (v4.1)

See merge request espressif/esp-idf!9685
2020-07-22 11:54:04 +08:00
b8c893774f ci: pushd and cd in one go in idf_build_process defaults test 2020-07-20 18:29:19 +08:00
d101da4ca4 cmake: fix setting defaults in idf_build_process
Closes https://github.com/espressif/esp-idf/issues/5053
2020-07-20 18:29:19 +08:00
a716442c72 ci: test idf_build_process defaults set properly 2020-07-20 18:29:19 +08:00
103503ba56 CI: do not run cases likely to fail 2020-07-19 14:58:06 +08:00
50b5b3184e CI: disable cases with test env SSC_T5_1 2020-07-19 14:58:05 +08:00
69ce0cea68 CI: temp allow mesh job to fail as runner is not stable 2020-07-19 14:58:03 +08:00
77fd8095e0 CI: remove incorrect MTU related cases 2020-07-19 14:58:02 +08:00
16e33e3e33 Support for more Bluetooth HID devices
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-07-17 10:14:34 +08:00
491d564f5a Fix error of AG API return line
Closes https://github.com/espressif/esp-idf/issues/5554
2020-07-14 14:44:20 +08:00
4c01c1a034 esp-tls: enable TLS renegotiation using explicit API call
mbedTLS stack does not keep TLS renegotiation enabled even if
relevant config option is turned on, it needs explicit API call
`mbedtls_ssl_conf_renegotiation` to do so.

This issue was observed in case of Azure IoT, where keys needs to
be refreshed periodically to keep TLS connection intact.
2020-07-13 15:35:57 +05:30
ee6ff6bdd2 ethernet: insert min assert time for PHY HW reset
Closes https://github.com/espressif/esp-idf/issues/5528
2020-07-13 11:13:31 +08:00
907e206dff mesh/ci: fix MESH_EST_0216 2020-07-10 18:04:52 +08:00
b20943ad43 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 18:04:50 +08:00
839893cfce Merge branch 'bugfix/buff_semaphore_not_free_v4.1' into 'release/v4.1'
component/bt: Fixed ble memory leak issue, buff_semaphore was not released..(backport 4.1)

See merge request espressif/esp-idf!9508
2020-07-10 16:49:35 +08:00
5cf858bee3 driver test: Ensure uart write task can't overflow buffer of read task
Previously both tasks had equal priority, possible for write task and another
internal task to be scheduled at the same time - starving read task and
causing data loss.

Related to IDFCI-59
2020-07-10 16:00:39 +10:00
b6e69b5014 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-09 19:13:56 +08:00
f8874e6940 Add platform independent CMake signing 2020-07-09 11:55:21 +05:30
f5a7c9635f Merge branch 'feature/msys2_env_update_v4.1' into 'release/v4.1'
windows: Update MSYS2 pre-compiled legacy build environment (v4.1)

See merge request espressif/esp-idf!9143
2020-07-08 17:34:33 +08:00
f5d37dd416 components/bt: Adjust the description of esp_bt_gap_start_discovery and esp_bt_gap_cancel_discovery.
Add some comments to explain why `ESP_BT_GAP_DISC_STATE_CHANGED_EVT` is not reported.
2020-07-08 14:22:19 +08:00
1ecd5ab91d ci: temporarily disable RS485 related tests 2020-07-08 06:44:07 +02:00
9c9b64ee17 component/bt: Fixed ble memory leak issue, buff_semaphore was not released. 2020-07-07 21:02:49 +08:00
7ab64c5345 Fix broken README links 2020-07-07 17:35:35 +08:00
0116d5d096 Merge branch 'bugfix/esp32_encrypted_flash_write_v4.1' into 'release/v4.1'
spi_flash: esp32: fix regression in encrypted flash write (v4.1)

See merge request espressif/esp-idf!9378
2020-07-06 08:18:23 +08:00
6db66c96d6 Merge branch 'bugfix/ci_fixes_v4.1' into 'release/v4.1'
ci: multiple minor fixes (backport v4.1)

See merge request espressif/esp-idf!8226
2020-07-06 07:23:46 +08:00
8d54933e10 Merge branch 'mesh/bugfix_coexist_warning_4.1' into 'release/v4.1'
mesh: remove coexist warnings in ESP_WIFI_MESH (backport 4.1)

See merge request espressif/esp-idf!9414
2020-07-03 20:10:09 +08:00
b1e907ccf1 ci: consider sdkconfig.defaults.TARGET_NAME in examples and test apps 2020-07-03 09:45:03 +00:00
370aa39045 efuse: don't include esp_efuse_utility_debug_dump_blocks in bootloader 2020-07-03 09:45:03 +00:00
9b19b21073 ci: generate separate log files for each example config
Otherwise the build log gets overwritten, and warnings in earlier
builds may be masked.
2020-07-03 09:45:03 +00:00
88baff4cbb ci: do fetch submodules in test_build_system_cmake_macos
Also install Python packages required by the CI scripts, and install
build tools (CMake, ninja).
2020-07-03 09:45:03 +00:00
4ea2935b1a ci provisioning: Add some experiments to check the runner's STA state
Not clear why sometimes it associates without negotiating a new DHCP lease.
2020-07-03 09:02:04 +00:00
a1cd7d0ef5 esp_prov: Extend the timeout for HTTP connection to SoftAP 2020-07-03 09:02:04 +00:00
113721f8fc ci wifi_tools: Log the wpa_supplicant interface state when trying to connect
Trigger reconnection if wpa_supplicant seems to have dropped the connection.
2020-07-03 09:02:04 +00:00
5cc9ef901e legacy provisioning: Always try to reconnect when disconnected
Some APs may fail authentication temporarily if they have too many
associated stations, for example.
2020-07-03 09:02:04 +00:00
ea8fae9ded esp_prov: Refactor to use new 'wait_wifi_connected' function
Means all provisioning examples will have the same retry behaviour.
2020-07-03 09:02:04 +00:00
9d38b0ab9b ci provisioning: Use strings instead of "magic numbers" for connection state 2020-07-03 09:02:04 +00:00
faaf08c441 ci: Wait up to 60 seconds for client to connect to DUT in provisioning test 2020-07-03 09:02:04 +00:00
f9e22b627e mesh: remove coexist warnings in ESP_WIFI_MESH
1. remove warning log when mesh is started:
Error! Should use default passive scan time parameter for WiFi scan when Bluetooth is enabled!!!!!!
2. remove abort when mesh is started:
Error! Should enable WiFi modem sleep when both WiFi and Bluetooth are enabled!!!!!!
2020-07-03 14:54:20 +08:00
b6e2163e5e Merge branch 'bugfix/beacon_security_downgrade_v4.1' into 'release/v4.1'
Avoid parsing RSN/WPA IE's after connection (Backport v4.1)

See merge request espressif/esp-idf!9284
2020-07-03 14:33:18 +08:00
40c9f0599c mbedtls: Don't compile hardware MPI & SHA files if disabled in config
Fixes bug where hardware accelerated mbedtls_mpi API was always used, even when
disabled in config.
2020-07-03 10:37:15 +10:00
aceb46efc2 esp_wifi: Update wifi lib
1. Avoid parsing RSN/WPA IE's after connection
2. Remove AUTH_CHANGED reason code logic
2020-07-01 11:49:02 +00:00
15c8337424 bugfix: fix ICMP specify length issue 2020-06-30 10:53:48 +08:00
lly
bf35465658 ble_mesh: stack: Check model status with variable length 2020-06-30 09:31:27 +08:00
lly
289b8bcea7 ble_mesh: Remove boolean type definitions 2020-06-30 09:18:42 +08:00
0d5eb50ce2 ble_mesh: Do not #define bool when compiling in C++ 2020-06-30 09:18:42 +08:00
lly
353f893d95 ble_mesh: Fix wrong log output with bt_hex
- This issue was introduced in the commit: a788e7cd3d
  which updated the bt_hex() function incorrectly.
- And in bt_hex(), we use 2 for the two-dimensional array, because currently
  at most two bt_hex() will be used at the same time. Also this will save
  some DRAM compared with using 4.
2020-06-30 09:16:29 +08:00
a55bd7339c docs:fix event typo
1.In the description of the ESP_API header file, it should be the event that the application layer needs to handle, not the BTA layer.
2.Fix name typo of BTA_GATTS_CREATE_SRVC_EVT event

Closes https://github.com/espressif/esp-idf/issues/5446
2020-06-29 20:56:08 +08:00
56accfe4c4 spi_flash: esp32: fix regression in encrypted flash write
In commit 309376f51a, it seems like regression
was added to use ROM level API for disabling flash write protection. This
started random firmware crashes (on specific modules) with exception
`IllegalInstruction` during encrypted flash writes.

Fix here removes relevant ROM API call, since disabling flash write protection
is already ensured by caller of this API.

Closes https://github.com/espressif/esp-idf/issues/5467
2020-06-29 14:51:58 +05:30
7ab2ffb45f spi_flash: Use per-chip flash_ops files for legacy API
Looks like when ESP32-S2 Beta support was merged, the separate files
were dropped by accident.
2020-06-29 14:49:28 +05:30
6cbc7dc2cd Merge branch 'bugfix/fix_adc_io_init_bug_for_idfv4.1' into 'release/v4.1'
driver(adc): fix adc io init bug for idfv4.1 (backport v4.1)

See merge request espressif/esp-idf!8714
2020-06-29 15:00:22 +08:00
c711a048bb driver(gpio): Solve gpio hold problems caused by code refactoring.
Closes https://github.com/espressif/esp-idf/issues/4600
2020-06-28 14:12:29 +00:00
5eb5b1148a websocket client: the client now aborts the connection if send fails.
Closes IDF-1744
2020-06-28 02:10:18 +00:00
4b41f19a01 esp_http_server: Update LRU counter on accepting a new connection
Closes https://github.com/espressif/esp-idf/issues/3851
2020-06-26 19:24:49 +05:30
c735e7edf5 Merge branch 'bugfix/export_path_checks_v4.1' into 'release/v4.1'
tools: export.sh: better detection and checking of IDF_PATH (backport v4.1)

See merge request espressif/esp-idf!8747
2020-06-26 21:24:11 +08:00
f31a804c1e Merge branch 'ci/http_client_remove_httpbin_redirect_v4.1' into 'release/v4.1'
ci: Temporarily remove the esp_http_client httpbin redirect tests (v4.1)

See merge request espressif/esp-idf!9341
2020-06-26 21:23:04 +08:00
d168611bbf ci: Temporarily remove the esp_http_client httpbin redirect tests
Need to host httpbin ourselves or wait for
postmanlabs/httpbin/issues/617 to be resolved
2020-06-25 09:35:20 +00:00
b85f877817 tools: export.sh: fix compatibility with dash shell
* fix constructs invalid in dash
* clean shellcheck warnings and disable false positive ones

Closes https://github.com/espressif/esp-idf/issues/5366
2020-06-25 09:19:58 +00:00
6ae54e7fd2 tools: export.sh: better detection and checking of IDF_PATH
1. detect IDF_PATH in zsh, if it is not set
2. if IDF_PATH is set, check that it is valid
3. make sure IDF_PATH is exported, not just set

Related to https://github.com/espressif/esp-idf/issues/3793
Closes https://github.com/espressif/esp-idf/pull/4418
Closes https://github.com/espressif/esp-idf/issues/4770
Closes https://github.com/espressif/esp-idf/issues/5288
2020-06-25 09:19:58 +00:00
0ff9b0a812 Tools: Mention ESPPORT and ESPBAUD in idf.py --help
Closes https://github.com/espressif/esp-idf/issues/5461
2020-06-25 08:17:55 +02:00
a19fa857ad static analysis: Apply current limits of known defects on v4.1 2020-06-25 05:45:16 +00:00
dd99fc77cb Merge branch 'bugfix/python_lint_v4.1' into 'release/v4.1'
tools: fix python lint (4.1)

See merge request espressif/esp-idf!9294
2020-06-25 12:35:07 +08:00
4daa605bd3 gh_action: fix python lint 2020-06-24 13:17:29 +08:00
43aafb0d86 tools/idf.py: Clean Python bytecode files 2020-06-22 10:24:12 +02:00
6aba4efca0 esp_tls_wolfssl: fix incorrect error message after handshake fails 2020-06-18 13:58:07 +05:30
5cff7b1d55 components/bt:Fix instant reverse and add ble connect paramter check. 2020-06-18 15:52:34 +08:00
5925f6458a 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:44:25 +08:00
97f10f6509 Merge branch 'bugfix/wpa3_ble_coex_issue_v4.1' into 'release/v4.1'
Fix WPA3 Auth timeout during BLE coex (Backport 4.1)

See merge request espressif/esp-idf!9208
2020-06-18 14:44:38 +08:00
be80b6f270 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 14:44:28 +08:00
ee70736a03 esp_wifi: Update wifi lib
1. Fix WPA3 Auth timeout during BLE coex by increasing CNX timeout
2. Extend Coex phase for SAE Handshake
3. Define and utilize WPA3 Mixed Authmode, update esp_wifi_types.h
2020-06-18 05:19:26 +00:00
9e55345c43 Merge branch 'bugfix/efuse_logs_v4.1' into 'release/v4.1'
esp32: Reduce using ESP_EARLY_LOGx and move some code after the stdout initialization in startup code (v4.1)

See merge request espressif/esp-idf!9206
2020-06-18 07:11:42 +08:00
6b66850dc1 Merge branch 'bugfix/ble_conn_fail_v4.1' into 'release/v4.1'
Fix bugs from coex test v4.1

See merge request espressif/esp-idf!9136
2020-06-17 18:17:15 +08:00
e0e391dce3 esp32s2: Move some code after the stdout initialization 2020-06-17 15:53:45 +08:00
0a1919abff esp32: Reduce using ESP_EARLY_LOGx and move some code after the stdout initialization
After setting _GLOBAL_REENT, ESP_LOGIx can be used instead of ESP_EARLY_LOGx.

Closes: https://github.com/espressif/esp-idf/issues/5343
2020-06-17 15:53:45 +08:00
af82516cfb feat(lwip): make LWIP TCP rto time configurable 2020-06-17 15:29:25 +08:00
6baa5f0d7b 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-06-17 05:34:11 +00:00
c5bbe87425 Merge branch 'bugfix/airkiss_find_hidden_ap_fail_v4.1' into 'release/v4.1'
fix the bug that airkiss find hidden AP fail (backport v4.1)

See merge request espressif/esp-idf!9176
2020-06-17 12:26:56 +08:00
5e52e5f6f5 Merge branch 'bugfix/blufi_buffer_overflow_report_v4.1' into 'release/v4.1'
Bugfix/blufi buffer overflow report v4.1

See merge request espressif/esp-idf!9178
2020-06-16 15:59:49 +08:00
f82010fa6a Merge branch 'bugfix/att_buffer_count_fixed_v4.1' into 'release/v4.1'
Bugfix/att buffer count fixed v4.1

See merge request espressif/esp-idf!9160
2020-06-16 15:59:34 +08:00
cf3b2df4a4 bugfix(uart): fix esp32 fifo_cnt bug
When using DPort to read fifo, fifo_cnt is not credible, we need to calculate the real cnt based on the fifo read and write pointer. When using AHB to read FIFO, we can use fifo_cnt to indicate the data length in fifo.
2020-06-16 14:48:02 +08:00
08e7bce4ea esp_wifi:
1. fix the bug that airkiss find hidden AP fail
2. addba fix and send bar in first ampdu
2020-06-16 10:48:48 +08:00
a945ae8a9d Merge branch 'bugfix/add_return_task_awoken_for_timer_callback_v4.1' into 'release/v4.1'
timer: add return task awoken for timer callback (backport v4.1)

See merge request espressif/esp-idf!9148
2020-06-16 10:38:43 +08:00
b33828e254 Merge branch 'bugfix/authmode_degrade_fix_v4.1' into 'release/v4.1'
esp_wifi: Remove auth_changed event and fix wpa2_ent authmode threshold (backport v4.1)

See merge request espressif/esp-idf!8804
2020-06-15 23:18:55 +08:00
ae64d9e738 blufi: When the format of the received data packet is wrong, reply with an error response 2020-06-15 19:37:38 +08:00
6861f7d5d8 components/bt: Add a detailed description for the user to distinguish the function of the query buffer api. 2020-06-15 19:19:14 +08:00
c5a6fc9c7e Update the limited of function esp_ble_get_sendable_packets_num. 2020-06-15 19:17:27 +08:00
3b8b057894 components/bt: Consider link_xmit_data_q in congest events to prevent excessive memory usage 2020-06-13 15:07:28 +08:00
e69ee31e1a components/bt: Fixed the problem of incomplete data packets caused by disordered acl data packets 2020-06-13 15:06:28 +08:00
846a2f95f4 components/bt: Add api to query the number of available buffers for the current connection 2020-06-13 15:06:14 +08:00
74623ac9d5 timer: add return task awoken for timer callback 2020-06-12 14:33:21 +08:00
37c155c359 msys2: Remove python version consideration in pacman commands 2020-06-12 10:22:10 +10:00
194a3b09dc windows: Update MSYS2 pre-compiled legacy build environment
* Bundled with esp2020r2 toolchain
* Built with Python 3 & latest MSYS2 packages
2020-06-12 10:22:10 +10:00
1b8905e544 components/bt: Fix ble disconnect due to instant of channel map update is too small 2020-06-11 16:55:36 +08:00
d0093c7675 Set AFH in time(075dd35)
Send LMP_channelClassification immediately
Fix first LMP_set_AFH not using host value
2020-06-11 16:55:26 +08:00
de6f21936f components/coex: Fix ble connecting fail in coexist 2020-06-11 16:55:12 +08:00
46486a863c esp_wifi: Remove auth_changed event and fix wpa2-ent authmode threshold
Added following as part of this change
1. Removed auth_changed event
2. Updated doc regarding usage of  WPA/WEP secuiry modes
3. Fixed WPA2 enterprise authmode threshold.
2020-06-11 13:40:58 +05:30
29bc65e719 Merge branch 'feature/toolchain_2020r2_v4.1' into 'release/v4.1'
Update toolchain to esp-2020r2  (backport v4.1)

See merge request espressif/esp-idf!9000
2020-06-11 15:44:47 +08:00
7de0c391ac Merge branch 'bugfix/fix_some_wifi_bugs_0522_v4.1' into 'release/v4.1'
bugfix: fix some wifi bugs (backport v4.1)

See merge request espressif/esp-idf!8880
2020-06-11 15:41:06 +08:00
326b42560d Merge branch 'bugfix/collection_of_confirmed_fixes_from_baidu_project_4.1' into 'release/v4.1'
Backport MR for baidu project for release/v4.1

See merge request espressif/esp-idf!8987
2020-06-11 14:46:22 +08:00
6f768b74e4 Merge branch 'bugfix/parttool_get_info_wo_info_option_v4.1' into 'release/v4.1'
partition_table: Fix parttool.py crashes when retrieving partition info (v4.1)

See merge request espressif/esp-idf!9063
2020-06-10 16:02:03 +08:00
aa6481837f Merge branch 'bugfix/bootloader_header_align_v4.1' into 'release/v4.1'
bootloader: Force bootloader_image_hdr to be word aligned (v4.1)

See merge request espressif/esp-idf!9068
2020-06-05 07:28:35 +08:00
bd3caffdcd bootloader_support: force alignment of flash_read argument 2020-06-04 21:01:56 +10:00
a5b4fda207 bootloader: Force bootloader_image_hdr to be word aligned
Possible due to linker order for this file to be placed unaligned,
causing failure from bootloader_flash_read() function.
2020-06-04 20:53:46 +10:00
7070fea6e4 partition_table: Fix parttool.py crashes when retrieving partition info
Closes: IDFGH-3279
Closes: https://github.com/espressif/esp-idf/issues/5271
2020-06-04 16:31:05 +08:00
d35226c656 Merge branch 'bugfix/wpa_supplicant_no_hw_mpi_v4.1' into 'release/v4.1'
wpa_supplicant: Allow building with mbedTLS integration but no hardware MPI (v4.1)

See merge request espressif/esp-idf!9013
2020-06-04 16:22:14 +08:00
4be2170250 freemodbus: add comments for limitation in current version of freemodbus 2020-06-04 09:46:04 +02:00
29d3c40a25 sdmmc: Correctly check function parameters before using them
Closes https://github.com/espressif/esp-idf/pull/5000
2020-06-04 11:49:40 +08:00
7cdc2f2b81 Backport MR for baidu proj 2020-06-04 11:07:30 +08:00
50319bb03c wpa_supplicant: Allow building with mbedTLS integration but no hardware MPI
Also disable the relevant function in bignum.h based on config, so fails at
compile not link time.

Closes https://github.com/espressif/esp-idf/issues/5321
2020-06-03 15:11:21 +10:00
0ea6d39686 Merge branch 'bugfix/secure_boot_v2_fixes_v4.1' into 'release/v4.1'
Small secure boot v2 fixes (v4.1)

See merge request espressif/esp-idf!9019
2020-06-03 12:34:55 +08:00
298f23c958 Update toolchain to esp-2020r2
Fixes PSRAM issues, volatile loads with -O2, std::locale, C++ exception crashs, FDE sorting switchable;

Includes a 64-bit toolchain for Windows (win64);

Closes https://github.com/espressif/esp-idf/issues/5090
Closes https://github.com/espressif/esp-idf/issues/5112
Closes https://github.com/espressif/esp-idf/issues/5150
2020-06-02 13:19:00 +07:00
1e12199832 esp32: use ccomp_timer in SHA test 2020-06-02 13:15:14 +07:00
36a66a7243 newlib: use --specs=nano.specs to enable "nano" version of C library
esp2020r1 toolchain includes a nano.specs file, which instructs GCC to
substitute libc.a with libc_nano.a.

In the build system, this simplifies handling of the nano formatting
option, eliminating LIBC and LIBM global variables.
2020-06-02 13:15:08 +07:00
4eec4fbc99 Add fixes for gcc8 psram fix improvement 2020-06-02 13:14:29 +07:00
b00f38f91c secure boot v2: Add anti-FI check that secure boot not enabled yet
Prevent a fault from causing bootloader to trust the provided signature incorrectly.
2020-06-02 16:14:01 +10:00
3c6b1b4c0a secure boot v2: Don't check efuse BLK2 if only boot-time signature verification is enabled 2020-06-02 16:14:01 +10:00
2c531d5bb3 secure boot v2: Don't log warnings when BLK2 is empty as expected
If BLK2 is empty then it's OK to continue with a warning (otherwise it may spook users into thinking
something this is wrong, but this is the expected workflow.)

If BLK2 is not empty and doesn't match then we need to fail because it won't be possible to
trust the signature.
2020-06-02 16:14:01 +10:00
lly
1bd7944316 ble_mesh: Rework prov pdu length check 2020-06-02 10:13:51 +08:00
75dd9835f6 esp_flash: fix cache exception when CS pin is through IOMUX 2020-06-01 15:29:30 +08:00
bda0c84552 esp_flash: fix the cleanup when add device fails 2020-06-01 15:29:30 +08:00
eacefba1c6 esp_flash: fix the regression of non-quad mode by default chip driver 2020-06-01 15:29:30 +08:00
69895387ee Merge branch 'bugfix/kconfig_hex_values_v4.1' into 'release/v4.1'
kconfig: Fix two cases of hex values being handled incorrectly (v4.1)

See merge request espressif/esp-idf!8787
2020-06-01 14:48:37 +08:00
c89d045322 tools: Don't generate pyc files 2020-05-29 10:08:51 +02:00
7708bf6158 Merge branch 'bugfix/ci_push_to_github_on_label_v4.1' into 'release/v4.1'
ci: Don't push to Github or deploy docs on customized pipelines (v4.1)

See merge request espressif/esp-idf!8937
2020-05-29 12:43:11 +08:00
10f3d92f6c Merge branch 'bugfix/add_so_linger_to_menuconfig_for_4.1' into 'release/v4.1'
lw-ip:add LINGER to menuconfig for 4.1(backport4.1)

See merge request espressif/esp-idf!8758
2020-05-29 11:13:52 +08:00
5fb93a14ae Merge branch 'bufix/fix_v4.1_bluedroid_bugs_mr' into 'release/v4.1'
component/bt: fix notify malloc failed , fix no BLE_AUTH_CMPL_EVT and fix bluedroid btc deinit crash(backport 4.1)

See merge request espressif/esp-idf!8756
2020-05-29 11:13:20 +08:00
63592b667c Merge branch 'nimble/config_option_sdkconfig_rename_v4.1' into 'release/v4.1'
Add NimBLE config options in sdkconfig.rename (v4.1)

See merge request espressif/esp-idf!8735
2020-05-29 11:12:44 +08:00
ba06ecf96d bugfix: fix some wifi bugs
1. optimization esp_wifi_set_max_tx_power description
2. Add API esp_wifi_ap_get_sta_aid
3. Fix the timeout issue of EAPOL four-way handshake
4. esp_wifi:Add softap example channel configuration
2020-05-29 11:04:26 +08:00
8793aab0e3 add congest direct callback and fix malloc failed when multi_connection notify performance test 2020-05-28 12:07:58 +00:00
d32ee233af fix bta_dm_deinit_cb crash 2020-05-28 12:07:58 +00:00
049402ae8d master missing BLE_AUTH_CMPL_EVT after restart 2020-05-28 12:07:58 +00:00
977d98cb6d Merge branch 'bugfix/ble_mesh_check_timer_init_v4.1' into 'release/v4.1'
ble_mesh: Check the result of creating timer (v4.1)

See merge request espressif/esp-idf!8958
2020-05-28 15:27:42 +08:00
983a4be42e Merge branch 'nimble/update_nimble_submodule_v4.1' into 'release/v4.1'
NimBLE: Include upstream fixes and use macros for log level filtering (backport v4.1)

See merge request espressif/esp-idf!8794
2020-05-28 15:25:12 +08:00
lly
0c87b1c12d ble_mesh: Check the result of creating timer 2020-05-28 10:27:06 +08:00
5ea193115b Merge branch 'bugfix/ble_mesh_sync_zephyr_fixes_v4.1' into 'release/v4.1'
Bugfix/ble mesh sync zephyr fixes (v4.1)

See merge request espressif/esp-idf!8948
2020-05-28 10:15:53 +08:00
6971cdbad5 Merge branch 'bugfix/ble_mesh_not_use_same_private_key_v4.1' into 'release/v4.1'
ble_mesh: Not using pre-initialized private key (v4.1)

See merge request espressif/esp-idf!8945
2020-05-28 10:14:21 +08:00
0af793f6ef Merge branch 'bugfix/ble_mesh_comp_data_store_restore_v4.1' into 'release/v4.1'
ble_mesh: Same func for storing/restoring comp data (v4.1)

See merge request espressif/esp-idf!8942
2020-05-28 10:12:12 +08:00
e1ce31483d Merge branch 'bugfix/ws_client_fragmented_send_v4.1' into 'release/v4.1'
ws_client: fix fragmented send setting proper opcodes (v4.1)

See merge request espressif/esp-idf!8690
2020-05-28 01:27:41 +08:00
492cece316 esp_http_server: Fixed a bug which could cause issues with LRU purge
LRU counter should be started from 1, and not 0, so that all checks
work fine.

Closes https://github.com/espressif/esp-idf/issues/4753
2020-05-27 10:56:22 +00:00
55b56a1557 Merge branch 'bugfix/coap_component_build_issue_v4.1' into 'release/v4.1'
coap: move mbedTLS config options from component to examples (v4.1)

See merge request espressif/esp-idf!8929
2020-05-27 18:41:53 +08:00
lly
2f73d76768 ble_mesh: Transport tx fields overflow [Zephyr]
The transport segmented TX nack and seg_pending fields must be at least
6 bits to avoid overflow for 32 segment messages. This change rearranges
the seg_tx fields to gather all state flag fields in one byte, while
making the counter fields whole bytes.
2020-05-27 17:46:29 +08:00
lly
63c8dd2981 ble_mesh: Friend with unknown appkey [Zephyr]
Ensures that friend messages are enqueued, even if the packet is
received with an appkey is unknown to the friend. Previously, sdu_recv
would return EINVAL if the appkey was unknown, which would prevent the
lower transport layer from adding the packet to the friend queue. This
is irrelevant for the logic in lower transport, and should not be
returned as an error.
2020-05-27 17:46:23 +08:00
a02a782ee9 Merge branch 'doc/add_types_api_ref_v4.1' into 'release/v4.1'
doc: add peripheral_types.h as API reference for peripheral docs (v4.1)

See merge request espressif/esp-idf!8895
2020-05-27 17:44:30 +08:00
lly
0c06be9bcd ble_mesh: Not using pre-initialized private key 2020-05-27 17:39:50 +08:00
lly
d3921346a9 ble_mesh: Same func for storing/restoring comp data 2020-05-27 17:30:31 +08:00
c3d33f4232 Merge branch 'bugfix/ble_mesh_uses_deprecated_config_v4.1' into 'release/v4.1'
ble_mesh: Fix using old config for duplicate scan (v4.1)

See merge request espressif/esp-idf!8900
2020-05-27 17:24:13 +08:00
ad4dfed632 ci: Don't push to Github or deploy docs on customized pipelines
BOT_TRIGGER_WITH_LABEL must be empty (meaning all tests are running).
2020-05-27 19:05:02 +10:00
4a8effcbb9 ci: increase unit test job count 2020-05-27 15:09:50 +08:00
d2666545d1 spi: simplify the caps header 2020-05-27 15:09:50 +08:00
6f410cb7c4 spi_flash: add unit test for read/write performance 2020-05-27 15:09:49 +08:00
8df1369d0a esp_flash: fix the write performance regression
Also changed internal delay unit into microsecond.
2020-05-27 15:09:49 +08:00
7d3d56ff9a doc: add peripheral_types.h as API reference for peripheral docs
Closes DOC-136
Closes IDF-1673
2020-05-27 12:38:38 +08:00
edb84c19dd coap: move mbedTLS config options from component to examples
CoAP component relies on some mbedTLS crypto configuration
options, e.g. DTLS and PSK. These configuration options if
selected, have footprint impact on generic TLS examples like
https_request or https_ota as well.

Footprint of https_request example with/without change is per below:

$ ./tools/idf_size.py new_https_request.map --diff old_https_request.map

<CURRENT> MAP file: new_https_request.map
<REFERENCE> MAP file: old_https_request.map
Difference is counted as <CURRENT> - <REFERENCE>, i.e. a positive number means that <CURRENT> is larger.
Total sizes of <CURRENT>:                                                 <REFERENCE>     Difference
 DRAM .data size:   14796 bytes                                                 14796
 DRAM .bss  size:   23560 bytes                                                 23680           -120
Used static DRAM:   38356 bytes ( 142380 available, 21.2% used)                 38476           -120 (   +120 available,      +0 total)
Used static IRAM:   89045 bytes (  42027 available, 67.9% used)                 89045                (     +0 available,      +0 total)
      Flash code:  554231 bytes                                                563823          -9592
    Flash rodata:  179000 bytes                                                181224          -2224
Total image size:~ 860632 bytes (.bin may be padded larger)                    872568         -11936

This commit moves relevant config options to CoAP specific examples
and also adds some run time warnings if they are kept disabled.

Closes https://github.com/espressif/esp-idf/issues/5262
2020-05-26 20:05:33 +05:30
lly
3b89497b39 ble_mesh: Fix using old config for duplicate scan 2020-05-25 16:53:30 +08:00
841aba8948 add LINGER to menuconfig 2020-05-25 11:36:05 +08:00
84b51781c8 Merge branch 'bugfix/espnow_fetch_peer_crash_v4.1' into 'release/v4.1'
wifi: fix the crash issue when fetch peer after delete cur_peer (backport v4.1)

See merge request espressif/esp-idf!8824
2020-05-22 23:10:48 +08:00
58f0a94cdf Merge branch 'bugfix/fix_memleak_in_wpa3_feature_v4.1' into 'release/v4.1'
fix(wpa_supplicant): fix memleak in wpa3 feature(backport v4.1)

See merge request espressif/esp-idf!8656
2020-05-22 21:23:43 +08:00
3cfd7eebd1 Merge branch 'example/ble_mesh_structural_adjust_v4.1' into 'release/v4.1'
Example/ble mesh structural adjust (v4.1)

See merge request espressif/esp-idf!8856
2020-05-22 19:15:57 +08:00
4775176d7f Merge branch 'bugfix/ble_mesh_provisioner_fail_to_pub_v4.1' into 'release/v4.1'
ble_mesh: Fix Provisioner failed to publish (v4.1)

See merge request espressif/esp-idf!8873
2020-05-22 19:14:14 +08:00
lly
eeff638c97 ble_mesh: Fix Provisioner failed to publish 2020-05-22 15:47:40 +08:00
ca01e8698f ws_client: fix fragmented send setting proper opcodes
Previous implementation violated the RFC by having both the actual opcode and WS_FIN flag set for all fragments of a message.
Fixed by setting the opcode only for the first fragment and WS_FIN for the last one

Closes IDFGH-2938
Closes https://github.com/espressif/esp-idf/issues/4974
2020-05-22 06:14:48 +00:00
db7e28b8c7 Merge branch 'bugfix/doc_version_links_v4.1' into 'release/v4.1'
doc: Fix broken Release page links when building a stable version (v4.1)

See merge request espressif/esp-idf!8820
2020-05-22 13:59:27 +08:00
lly
13537ce279 ble_mesh: Fix tutorial links in examples README.md 2020-05-22 05:43:57 +00:00
lly
cc187a43b3 ble_mesh: Rename esp_fast_prov_* to ble_mesh_fast_prov_* 2020-05-22 05:43:57 +00:00
lly
b4588f7d92 ble_mesh: Rename the folders ble_mesh_fast_prov_* to fast_prov_* 2020-05-22 05:43:57 +00:00
lly
59b313fdcf ble_mesh: Rename ble mesh example main & init files
- Rename ble_mesh_demo_main.c to main.c
- Rename ble_mesh_demo_init.* to ble_mesh_example_init.*
2020-05-22 05:43:57 +00:00
lly
74056dea91 ble_mesh: Move the example init to the common_components 2020-05-22 05:43:57 +00:00
lly
2eadacbf29 ble_mesh: Move the button component to common_components 2020-05-22 05:43:57 +00:00
lly
3c32f5a726 ble_mesh: Change the EXTRA_COMPONENT_DIRS used by examples 2020-05-22 05:43:57 +00:00
lly
55cd9206d5 ble_mesh: Rename common_vendor_models to common_components
Since the scripts of CI will bypass common_components when
trying to get ALL_EXAMPLES, and these BLE Mesh components
will only be used by other mesh examples, i.e. no need to
be compiled as a single example, so we rename the folder
to common_componnets.
2020-05-22 05:43:57 +00:00
80412dfbb8 wifi: fix the crash issue when fetch peer after delete cur_peer 2020-05-22 11:04:46 +08:00
502a2aed2a Merge branch 'bugfix/ble_mesh_friend_init_flag_v4.1' into 'release/v4.1'
Bugfix/ble mesh friend init flag (v4.1)

See merge request espressif/esp-idf!8848
2020-05-22 10:51:13 +08:00
d075bcab98 Merge branch 'doc/ble_mesh_fix_v4.1' into 'release/v4.1'
ble_mesh: Doc miscellaneous fixes (v4.1)

See merge request espressif/esp-idf!8858
2020-05-22 10:49:53 +08:00
lly
88f6e2b60d ble_mesh: Doc miscellaneous fixes
- Update ble mesh architecture
2020-05-21 17:46:28 +08:00
e789d85e69 Merge branch 'bugfix/ble_mesh_node_old_version_to_new_v4.1' into 'release/v4.1'
ble_mesh: Fix mesh node device role restore (v4.1)

See merge request espressif/esp-idf!8724
2020-05-21 15:10:48 +08:00
eb8f6f942a Merge branch 'bugfix/ble_mesh_fix_typos_v4.1' into 'release/v4.1'
ble_mesh: Fix typos (v4.1)

See merge request espressif/esp-idf!8726
2020-05-21 15:10:10 +08:00
lly
715cb64288 ble_mesh: Clear two more vars during proxy server deinit 2020-05-21 14:26:05 +08:00
lly
52fa4c7f96 ble_mesh: Add missing sdkconfig.h 2020-05-21 14:26:05 +08:00
lly
f02d095ff1 ble_mesh: Init device name during proxy server init
Device name will be reset when deinit mesh stack. If not
initializing device name during the next mesh stack init,
it will fail to set the device name when using bluedroid.
2020-05-21 14:26:04 +08:00
lly
ab73b3fd8e ble_mesh: Add init flag for friend init/deinit
Since bt_mesh_friend_init() will only be invoked when
a device is provisioned or Provisioner is enabled, so
we add a flag to indicate if the friend functionality
is initialized in case deinit before initialization.
2020-05-21 14:26:04 +08:00
dc4cd3ae7c Merge branch 'bugfix/ble_mesh_remove_patch_v4.1' into 'release/v4.1'
ble_mesh: Remove patch for the bug of an App (v4.1)

See merge request espressif/esp-idf!8779
2020-05-21 11:47:06 +08:00
3db186d5d1 NimBLE: Include upstream fixes and use macros for log level filtering (backport v4.1)
Change list:
- Reduces the size of the compiled binary, PR: https://github.com/espressif/esp-nimble/pull/6
- Null pointer check, PR: https://github.com/apache/mynewt-nimble/pull/701
- Pairing procedure abort on unexpected req: https://github.com/apache/mynewt-nimble/pull/710
- Fix conn flags after pairing: https://github.com/apache/mynewt-nimble/pull/730
- Remove notification for update process timeout (Vol 6, Part B, section 5.2 ):
  https://github.com/apache/mynewt-nimble/pull/782
- CCCD fix : https://github.com/apache/mynewt-nimble/pull/790 and
  https://github.com/apache/mynewt-nimble/pull/804
- Host based Privacy (RPA) fix: https://github.com/espressif/esp-nimble/pull/7

 Closes https://github.com/espressif/esp-nimble/issues/10

 Closes https://github.com/espressif/esp-idf/issues/4413
2020-05-20 16:09:02 +05:30
db3d03f9ac Merge branch 'bugfix/wpa3_pmf_memleak_fix_v4.1' into 'release/v4.1'
WPA3 / PMF memory leak fixes (backport v4.1)

See merge request espressif/esp-idf!8695
2020-05-20 11:36:41 +08:00
4a42368603 doc: Fix broken Release page links when building a stable version 2020-05-20 11:30:17 +10:00
db0897705f Merge branch 'ci/disable_esp32s2beta_jobs' into 'release/v4.1'
CI: disable esp32s2beta jobs

See merge request espressif/esp-idf!8489
2020-05-20 02:06:00 +08:00
276cbb69f3 wpa_supplicant: Fix memory leaks in WPA3 connection
1. Buffers for SAE messages are not freed after the handshake.
   This causes memory leak, free buffers after SAE handshake.
2. SAE global data is not freed until the next WPA3 connection
   takes place, holding up heap space without reason. Free theis
   data after SAE handshake is complete or event fails.
3. Update wifi lib which includes memory leak fix during BIP
   encryption/decryption operations.
2020-05-18 15:46:32 +05:30
c973bea7d1 wpa_supplicant: Fix formatting of file esp_wpa3.c
Replace tabs with spaces in esp_wpa3.c.
2020-05-18 15:45:34 +05:30
6191429df5 confserver: Always store hex values in sdkconfig with 0x prefix
This is not necessary for correct behaviour or to have valid sdkconfig files
(previous commit adds tests for this), but it's useful for consistency with
sdkconfig files generated by menuconfig.

As reported in https://github.com/espressif/vscode-esp-idf-extension/issues/83
2020-05-18 17:02:15 +10:00
5a1848a5a6 kconfig: Fix generation of hex outputs for Make & CMake
And add tests for hex output formatting in all output formats.

Previously, Make & CMake outputs only formatted hex values with the 0x prefix
if they had the 0x prefix in the sdkconfig file. Now this prefix is always
applied.

Closes https://github.com/espressif/vscode-esp-idf-extension/issues/83
2020-05-18 17:01:45 +10:00
e9d4659175 Merge branch 'bugfix/erase_with_vtaskdelay_v4.1' into 'release/v4.1'
spi_flash: Add vTaskDelay while a long erasing (v4.1)

See merge request espressif/esp-idf!8598
2020-05-18 11:01:50 +08:00
0266ad95d7 Merge branch 'bugfix/fix_switch_channel_without_discon_issue_v4.1' into 'release/v4.1'
esp_wifi: Fix AP switch to adjacent channel without disconnect (backport v4.1)

See merge request espressif/esp-idf!8723
2020-05-17 15:01:23 +08:00
19163393a9 Merge branch 'bugfix/stop_mac_can_be_controlled_by_user_v4.1' into 'release/v4.1'
Bugfix/stop mac can be controlled by user v4.1

See merge request espressif/esp-idf!8761
2020-05-16 03:28:33 +08:00
lly
9d587eb8fd ble_mesh: Remove patch for the bug of an App 2020-05-15 20:23:48 +08:00
32e20304a7 Merge branch 'bugfix/ipv6_examples_4.1' into 'release/v4.1'
socket-examples: IPv6 related update for examples to set correct scoped id (v4.1)

See merge request espressif/esp-idf!8583
2020-05-15 13:58:42 +08:00
1cfeb8be7f Merge branch 'feature/enable_wpa3_pmf_by_default_v4.1' into 'release/v4.1'
Enable WPA3 & PMF by default (backport v4.1)

See merge request espressif/esp-idf!8601
2020-05-15 11:46:20 +08:00
222ac1dd60 ethernet: fix potential task watch dog timeout 2020-05-14 22:07:06 +08:00
63dae58176 ethernet: better control start/stop/uninstall/install 2020-05-14 22:07:00 +08:00
e07023b9c7 ethernet: esp_eth_stop API should stop emac hardware 2020-05-14 22:06:54 +08:00
ddae67f50f esp_wifi: Fix AP switch to adjacent channel without disconnect 2020-05-14 03:55:09 +00:00
c595429db0 Add NimBLE config options in sdkconfig.rename 2020-05-14 11:30:35 +10:00
lly
b929611d5d ble_mesh: Fix typos 2020-05-13 18:30:52 +08:00
lly
e9f64eb1c3 ble_mesh: Fix mesh node device role restore
Old version of BLE Mesh has no device role storage, because
previously we only support storing mesh node info.
If the binary of the node is upgraded from old version to a
new version (support storing provisioner info), the mesh info
of the node will not be restored because mesh role does not
exist in the flash.
2020-05-13 18:25:53 +08:00
56c1646e2a Merge branch 'bugfix/sync_zephyr_bt_mesh_bugfix_v4.1' into 'release/v4.1'
Bugfix/sync zephyr bt mesh bugfix (v4.1)

See merge request espressif/esp-idf!8688
2020-05-13 18:15:37 +08:00
204553ec6c Merge branch 'bugfix/ble_mesh_not_ignore_msg_in_fast_prov_v4.1' into 'release/v4.1'
ble_mesh: Not ignore msg when fast prov is enabled (v4.1)

See merge request espressif/esp-idf!8710
2020-05-13 18:15:06 +08:00
87141efd1e socket-examples: IPv6 related update for examples to set correct scoped id
The scope id must be present when connecting to IPv6 Local Link
address.
2020-05-13 08:18:03 +00:00
260d6f83b7 driver(adc): fix adc io init bug 2020-05-13 11:48:55 +08:00
8860c1b94c Merge branch 'feature/ldgen_output_determinism_v4.1' into 'release/v4.1'
ldgen: determinism in mapping rule order (v4.1)

See merge request espressif/esp-idf!8661
2020-05-13 11:30:32 +08:00
lly
31b164ccb1 ble_mesh: Not ignore msg when fast prov is enabled
When fast provisioning is enabled, Provisioner shall not
ignore messages from the nodes whose addresses are not in
the provisioning database. Because other nodes which are
not provisioned by the Primary Provisioner will send node
address messages to the Primary Provisioner.
2020-05-13 10:09:04 +08:00
c96ce01d87 Merge branch 'bugfix/supplicant_general_fixes_41' into 'release/v4.1'
wpa_supplicant: Fix some memleaks and invalid memory access (backport v4.1)

See merge request espressif/esp-idf!8555
2020-05-12 20:28:45 +08:00
97f72da56e Merge branch 'bugfix/pthread_tcb_cleanup_wrapper_v4.1' into 'release/v4.1'
Fix linking for vPortCleanUpTCB wrapper (v4.1)

See merge request espressif/esp-idf!8701
2020-05-12 14:18:13 +08:00
3e93b8fed9 pthread: Use INTERFACE in target_link_libraries for vPortCleanUpTCB wrapper 2020-05-12 10:35:27 +05:30
lly
295a9eea82 ble_mesh: Fix not update prov addr in fast prov
When using fast provisioning, the Provisioner functionality
will be enabled. Unicast addresses within the pre-allocated
range will be used for provisioning nodes. And during the
address assignment, the allocated unicast address will be
checked that if it's duplicated with other nodes addresses
and the Provisioner's own addresses.
So before starting using fast provisioning, we need to update
the Provisioner address.
2020-05-11 15:42:58 +08:00
lly
06d445759a ble_mesh: net_key_status only pull one key idx [Zephyr]
Fixes bug where the config client's net_key_status handler would attempt
to pull two key indexes from a message which only holds one.
2020-05-11 15:42:57 +08:00
lly
b1efdd5eb1 ble_mesh: Update client message timeout calculation
Since the behavior of sending segmented messages has been
changed properly, the calculation of timeout value which
will be used when sending an acknowledged message by a
client model also needs to be updated.
2020-05-11 15:42:57 +08:00
lly
42ccb7277f ble_mesh: Add lock for segmented msg operations
Add mutex to protect some variables of the mesh segmented
messages.
Currently the timeout handler of mesh will be executed in
the btc task, while the received mesh messages will be
handled in the btu task. In case some variables are set to
NULL when handled in the btu task, meanwhile these variables
are also accessed in the timeout handler, so we add mutex to
protect these variables and related operations.
2020-05-11 15:42:57 +08:00
lly
cffbc32253 ble_mesh: Fix dereferencing pointer before checking for NULL [Zephyr]
The publication context is checked for NULL in bt_mesh_model_publish()
however it was dereferenced before that. Move the assignment to
ctx.send_rel to the same place where other ctx members are set.
2020-05-11 15:42:56 +08:00
lly
8f5564af84 ble_mesh: Optimize some mesh log output 2020-05-11 15:42:56 +08:00
lly
6a6bac2c62 ble_mesh: Fix restore when revoke keys [Zephyr]
Store keys (NetKey and AppKey) again after revoking.
2020-05-11 15:42:55 +08:00
lly
526f253b2e ble_mesh: Spit mesh_util.h into different header files
Split mesh_util.h into mesh_byteorder.h, mesh_compiler.h,
mesh_ffs.h and mesh_util.h based on the classification of
Zephyr, which will make further porting more clear.
2020-05-11 15:42:55 +08:00
lly
2f40c4449f ble_mesh: Split mesh os related into a separate file 2020-05-11 15:42:54 +08:00
lly
8ab29292ab ble_mesh: Split mesh mutex into a separate file 2020-05-11 15:42:54 +08:00
lly
9af8947e55 ble_mesh: Rename mesh_kernel.* to mesh_timer.* 2020-05-11 15:42:53 +08:00
lly
800cb0fff8 ble_mesh: Add and use transport macro definitions [Zephyr] 2020-05-11 15:42:53 +08:00
lly
362e8e0a1f ble_mesh: Friend SeqAuth cleanup [Zephyr]
The Friend queue uses the message SeqAuth to determine whether the
message is already in the queue. To facilitate this, the SeqAuth is
passed around as a pointer throughout the transport modules. In the
bt_mesh_ctl_send functions, this parameter is also exposed in the API,
but the internal usage is inconsistent and buggy. Also, no one actually
uses this parameter.

- Removes seq_auth param from bt_mesh_ctl_send, instead passing NULL
  directly to the friend module, to enforce its addition to the queue.
- Makes the seq_auth pointer const throughout the friend module.
2020-05-11 15:42:52 +08:00
lly
de648753b0 ble_mesh: Rework msg_cache [Zephyr]
Changes the behavior of the message cache to optimize for cache
capacity. Previously, the message cache's primary function was to avoid
decrypting messages multiple times, although the cache's main function
in the spec is to avoid message rebroadcasting. Optimizing for minimal
decryption causes us to fill the network cache faster, which in turn
causes more cache misses, potentially outweighing the advantage.

Now stores src + seq in message cache instead of field hash value. This
cuts cache size in two, while including more of the sequence number than
before.

Adds messages to the cache only after the packet is successfully
decrypted. This reduces noise in the cache, and ensures that no
invalid deobfuscations are added.

Additionally, this fixes a bug where multiple calls to net_decrypt with
the same packet failed, as the message cache found its own entry from
the previous call.
2020-05-11 15:42:52 +08:00
lly
aed5dc63b7 ble_mesh: Segmented TX to groups [Zephyr]
Implements several changes to the transport layer segmented tx to
improve group message performance:
- Moves retransmit counter to tx context instead of per packet. As every
  unacked packet is sent every retransmit, the retransmit counters would
  be the same in each segment. This makes it easier to control progress.
- Delays the scheduling of the retransmit until the completion of the
  last segment by adding a seg_pending counter. This is essentially the
  same as the old behavior, except that the old behavior might retrigger
  the sending before all segments are finished if the advertising is
  slow.
- Allows the group transmits to stop as soon as all retransmits have
  been exhausted, instead of timing out waiting for acks that won't
  come. This allows group tx to finish without error.
- Fixes a bug where a failed TX would block IV update.
- Cancels any pending transmissions of acked segments.
- Reduces log level for several common group tx scenarios that aren't
  erronous.
2020-05-11 15:42:51 +08:00
lly
21c5be311c ble_mesh: Add comment explaining use of byte order [Zephyr]
Add comment that explains why a different byte order is used for the
3-byte opcode on the CID part of the opcode.
2020-05-11 15:42:51 +08:00
lly
0a41241e10 ble_mesh: Use 24-bit functions [Zephyr]
Use 24-bit functions for byteorder and net_buf in order to make the
byteorder used more readable.
2020-05-11 15:42:50 +08:00
lly
e3472c1c99 ble_mesh: Optimize net_buf_simple routines [Zephyr]
Use sys_put_xyz() helpers instead of memcpy() whenever possible. This
brings in straight-line inline code for pushes and adds of known,
small sizes.
2020-05-11 15:42:50 +08:00
lly
175109d196 ble_mesh: Add PRIu64 & PRIx64 in mesh_types.h 2020-05-11 15:42:49 +08:00
lly
61d376109c ble_mesh: Add push functions for supported bit-variants [Zephyr]
Add push functions for bit-widths supported by add and pull functions.
2020-05-11 15:42:49 +08:00
lly
fd4b6fd47e ble_mesh: Add support for 64 bit data type [Zephyr]
This enables pulling and pushing values in 64 bit format.
2020-05-11 15:42:48 +08:00
lly
b348b55d1e ble_mesh: Add support for 48 bit data type [Zephyr]
This enables pulling and pushing values in 48 bit format.
2020-05-11 15:42:48 +08:00
lly
82a5b05948 ble_mesh: Add 48 bit variants [Zephyr]
This adds sys_*_*48 functions that operation on a 48 bits values.
2020-05-11 15:42:46 +08:00
lly
95718d9ef9 ble_mesh: Add support for 24 bit data type [Zephyr]
This enables pulling and pushing values in 24 bit format.
2020-05-11 15:42:46 +08:00
lly
33c0ddce40 ble_mesh: Add 24 bit variants [Zephyr]
This adds sys_*_*24 functions that operation on a 24 bits values.
2020-05-11 15:42:45 +08:00
lly
bf4b513e83 ble_mesh: Group resends in proxy nodes [Zephyr]
Resend transport segments for groups on the advertiser interface, even
if a connected proxy node holds the group.
2020-05-11 15:42:45 +08:00
lly
91fff8c897 ble_mesh: Typo in condition in comp_add_elem of cfg_srv [Zephyr]
Vendor model IDs take up four (not two) bytes in the composition
2020-05-11 15:42:45 +08:00
lly
7ea60199a6 ble_mesh: GATT Proxy Spec 1.0.1 changes [Zephyr]
Backport of https://github.com/apache/mynewt-nimble/pull/724

Mesh spec 1.0.1 changes proxy disabling behavior to only affect the
relaying from proxy nodes. Previously, disabling proxy would shut down
all proxy and node activity.

Tweaks from the original commit:
- Removed redundant call to bt_mesh_adv_update() in gatt_proxy_set()
- Removed invalid ref to 4.2.11.1 in node_identity_set()

---

According to Mesh Profile Spec 1.0.1, Section 4.2.11:
"If the Proxy feature is disabled, a GATT client device can connect
over GATT to that node for configuration and control. Messages from
the GATT bearer are not relayed to the advertising bearer."

Moreover some notes have been removed from the spec compared to
version 1.0:

Mesh Profile Spec 1.0, Section 4.2.11:

"Upon transition from GATT Proxy state 0x01 to GATT Proxy state 0x00
the GATT Bearer Server shall disconnect all GATT Bearer Clients."

"The Configuration Client should turn off the Proxy state as the last
step in the configuration process."

Mesh Profile Spec 1.0, Section 4.2.11.1:

"When the GATT Proxy state is set to 0x00, the Node Identity state
for all subnets shall be set to 0x00 and shall not be changed."
2020-05-11 15:42:44 +08:00
lly
2b84b673bf ble_mesh: Support reliable sending when publishing [Zephyr]
Until now the choice of reliable sending (segmented messages with
acks) was implicitly dependent on the size of the payload. Add a new
member to the bt_mesh_model_pub to force using segment acks even when
the payload would fit a single unsegmented message.
2020-05-11 15:42:44 +08:00
lly
c2e24e306f ble_mesh: Check device uuid when init provisioning 2020-05-11 15:42:43 +08:00
lly
a85459e245 ble_mesh: Fix provisioning buffer initialization [Zephyr]
When PB-GATT support has been enabled the provisioning code "borrows"
the buffer from the proxy code. However, the way that initialization
was happening the proxy buffers were initialized only after
provisioning initialization, resulting in a corrupted buffer with
buf->data pointing to NULL. Reorder the initialization calls so that
proxy is done first and provisioning only after it.
2020-05-11 15:42:43 +08:00
lly
a0434371b0 ble_mesh: Skip publish if update fails [Zephyr]
Allow models to skip a periodic publish interval by returning an error
from the publish update callback.

Previously, an error return from publish update would cancel periodic
publishing. This can't be recovered from, and as such, no valid model
implementation could return an error from this callback, and there was
no way to skip a periodic publish.
2020-05-11 15:42:42 +08:00
lly
1717c2face ble_mesh: Enable Segmented Control Messages [Zephyr]
The function bt_mesh_ctl_send() used to support maximum length of
11 bytes. The segmentation complies with the BLE Mesh Standard.
The ack is disabled in case of non unicast address.
2020-05-11 15:42:42 +08:00
ee0f8adaed ldgen: determinism in mapping rule order
This MR imposes some determinism in the mapping rule order in the output
file. For each section, the archives are arranged alphabetically
(ascending), and the mapping rules in each archive are arranged by
increasing specificity then alphabetically (ascending). The default
rules remain the very first rule for each section.
2020-05-08 20:48:43 +08:00
949e7c6f85 fix(wpa_supplicant): fix memleak in wpa3 feature 2020-05-08 16:30:16 +08:00
f14cdd5d3a Merge branch 'bugfix/timer_group_intr_enable_v4.1' into 'release/v4.1'
fix timer group intr enable (backport v4.1)

See merge request espressif/esp-idf!8529
2020-05-08 14:57:20 +08:00
15daee9a0f Merge branch 'bugfix/wifi_prov_not_stopping_v4.1' into 'release/v4.1'
wifi_provisioning: Catch the Wi-Fi events even after Connection errors (v4.1)

See merge request espressif/esp-idf!8607
2020-05-06 22:28:06 +08:00
de85de7c51 wpa_supplicant: Fix some memleaks and invalid memory access
Add changes to fix issues reported in clang analyzer
2020-05-06 11:05:30 +00:00
27ae9d3e2c Merge branch 'bugfix/ble_mesh_provisioner_check_key_v4.1' into 'release/v4.1'
ble_mesh: Check if appkey exist before deleting it (v4.1)

See merge request espressif/esp-idf!8621
2020-05-06 18:17:02 +08:00
7db21de3b3 Merge branch 'bugfix/ble_mesh_compile_error_o2_v4.1' into 'release/v4.1'
ble_mesh: Fix compile error when -O2 (performance) is chosen (v4.1)

See merge request espressif/esp-idf!8616
2020-05-06 18:15:53 +08:00
cec0f25484 Merge branch 'bugfix/ble_mesh_node_reset_erase_v4.1' into 'release/v4.1'
ble_mesh: Fix node not erase info completely (v4.1)

See merge request espressif/esp-idf!8622
2020-05-06 18:14:41 +08:00
f232b07e4e Merge branch 'feature/config_mqtt_task_prio_v4.1' into 'release/v4.1'
esp_mqtt:  configure task priority, esp_mqtt_abort_connection race condition, clenaup logs and docs (v4.1)

See merge request espressif/esp-idf!8472
2020-05-06 16:23:19 +08:00
lly
78b13034ef ble_mesh: Fix node not erase info completely
Previously only mesh node info is supported to be stored
in flash. So when trying to reset the node, we only need
to judge if the BLE_MESH_VALID flag is set.
Currently we support storing both node & Provisioner info
in flash, when trying to erase the node info from flash,
the BLE_MESH_NODE flag will be checked. So we need to set
bt_mesh.flags to 0 when all the erase operations are done.
2020-05-06 11:43:43 +08:00
lly
099bf88b2e ble_mesh: Check if appkey exist before deleting it 2020-05-06 11:40:20 +08:00
lly
466d450b4b ble_mesh: Add length check for some mesh operations 2020-05-06 11:26:33 +08:00
lly
a742255f8e ble_mesh: Fix compile error when -O2 (performance) is chosen 2020-05-06 11:26:25 +08:00
dd89b2dc0d Merge branch 'bugfix/ble_mesh_rpl_list_size_v4.1' into 'release/v4.1'
ble_mesh: Associate replay protection list size with nodes count (v4.1)

See merge request espressif/esp-idf!8493
2020-05-06 11:15:21 +08:00
654a3913eb Merge branch 'bugfix/ble_mesh_use_sdkconfig_ci_v4.1' into 'release/v4.1'
ble_mesh: Add bluedroid and nimble example configurations (v4.1)

See merge request espressif/esp-idf!8498
2020-05-06 11:13:43 +08:00
fefa9b7fe9 Merge branch 'doc/ble_mesh_fixes_v4.1' into 'release/v4.1'
doc: Fix some ble mesh description (v4.1)

See merge request espressif/esp-idf!8502
2020-05-06 11:13:16 +08:00
547fd926a9 Merge branch 'bugfix/ble_mesh_add_missing_cpp_v4.1' into 'release/v4.1'
ble_mesh: Add missing #ifdef __cplusplus (v4.1)

See merge request espressif/esp-idf!8505
2020-05-06 11:12:13 +08:00
d6cbfc7f19 Merge branch 'feat/ble_mesh_sensor_model_example_v4.1' into 'release/v4.1'
ble_mesh: Add ble mesh sensor model examples (v4.1)

See merge request espressif/esp-idf!8507
2020-05-06 11:11:59 +08:00
61405472e4 Merge branch 'bugfix/ble_mesh_time_scene_wrong_name_v4.1' into 'release/v4.1'
ble_mesh: Fix time scene wrong macro name (v4.1)

See merge request espressif/esp-idf!8510
2020-05-06 11:11:24 +08:00
541d8aef37 Merge branch 'bugfix/get_started_export_profile_v4.1' into 'release/v4.1'
docs: remove suggestion about running export.sh from .profile script (backport v4.1)

See merge request espressif/esp-idf!8613
2020-05-06 05:14:56 +08:00
f9bfc83295 docs: remove suggestion about running export.sh from .profile script
This was quite obviously a bad suggestion, and it seems that some
users have actually read the docs attentively enough to have followed
it. Replace be recommendation to create an alias.

Closes https://github.com/espressif/esp-idf/issues/3889
2020-05-05 21:34:00 +02:00
3fa198b8a2 wifi_provisioning: Catch the Wi-Fi events even after Connection errors
It was observed that after sending credentials, if the first
Wi-Fi conection attempt fails, the Wi-Fi provisioning managager
ignores subsequent Wi-Fi events. So, even if the device eventually
connects to the AP, the provisioning stays on indefinitely.

Changing a check so that subsequent events are also captured and
provisioning finishes successfully.
2020-05-05 22:09:18 +05:30
9778b163b1 Merge branch 'bugfix/fix_spi_flash_clock_config_error_v4.1' into 'release/v4.1'
flash: fix spi flash clock config error (backport v4.1)

See merge request espressif/esp-idf!8513
2020-05-05 11:31:11 +08:00
e006d21419 esp_wifi: Enable WPA3 & PMF by default
In wifi station example, set PMF(Protected Management Frames)
configuration to capable. Set WPA3 Feature in menuconfig enabled
by default. This will allow device to establish more secured
connection with AP's that support these protocols.
2020-05-04 17:37:56 +05:30
4214179de1 spi_flash(new driver): Add a Kconfig option - Bypass a block erase and always do sector erase
Closes: IDF-1561
2020-05-04 17:16:33 +08:00
5c98ff015e spi_flash(LEGACY_IMPL): Add a Kconfig option - Bypass a block erase and always do sector erase
Closes: IDF-1561
2020-05-04 17:16:33 +08:00
b56c7d9066 spi_flash: Add into sim/stubs the esp_timer 2020-05-04 17:16:33 +08:00
d67e764ef6 spi_flash(new driver): Add vTaskDelay while a long erasing 2020-05-04 17:16:33 +08:00
1554fd3d8a spi_flash(LEGACY_IMPL): Add vTaskDelay while a long erasing
Added Kconfig options to enable yield operation during flash erase

Closes: https://github.com/espressif/esp-idf/issues/2083
Closes: https://github.com/espressif/esp-idf/issues/4916
Closes: IDFGH-261
2020-05-04 15:48:22 +08:00
0cd5e28bce mqtt: clenaup logs and docs, esp_mqtt_abort_connection race condition
esp_mqtt_abort_connection: Fixed an issue which could result in a race condition and subsequent crash

esp_mqtt: Change an error print to use ESP_LOGE instead of ESP_LOGI
Move Sending MQTT connect message log from Info to Debug level
docs: Makes clear that publish API could block
Change the message printed after MQTT connection failure
2020-05-04 07:48:20 +02:00
c1cd396b95 esp_mqtt: add option to configure mqtt task priority.
Merges https://github.com/espressif/esp-idf/pull/4947
2020-05-04 07:45:24 +02:00
f7a2bfc873 Merge branch 'doc/openocd_security_features_v4.1' into 'release/v4.1'
doc: Add caveats about using JTAG debugging with hardware security features (v4.1)

See merge request espressif/esp-idf!8463
2020-05-04 03:10:02 +08:00
lly
4b1cbe87b3 ble_mesh: Fix client local parameters not initialized 2020-04-30 11:50:15 +00:00
lly
8b2291a718 ble_mesh: Continue node info restore even if failure happens
During BLE Mesh Provisioner initialization, the stack will restore
the nodes information if settings storage is enabled.
Previously when a failure happens (e.g. found the same uuid) during
the restore procedure, the information of the following nodes will
not be restored and error will be directly returned.
But this will introduce some problem with user experience, because
some newly provisioned nodes information will not be restored and
Provisioner will not be able to control those nodes.
So we change the operation here, when a failure happens during the
restore procedure, Provisioner will only ignore the information of
the current node and continue restoring other nodes information.
2020-04-30 11:50:15 +00:00
lly
fca4124f70 ble_mesh: Remove some redundant functions 2020-04-30 11:50:15 +00:00
lly
d35d765395 ble_mesh: Notify unprovisioned device beacon to application layer
With this change, if a Provisioner has provisioned the maximum
number of nodes, it can still report the unprovisioned device
beacon from other nodes to the application layer. And this will
be more reasonable compared with the previous implementation.
Previously when the node array of Provisioner is full, no beacon
from unprovisioned devices will be reported, only some warning
logs will be given.
2020-04-30 11:50:15 +00:00
lly
94092a148c ble_mesh: Check if assigned node address is duplicated
Previously only check the node address when it is assigned by the
application layer. Here we also check the address when the address
is allocated internally. And this will be useful when some mesh
internal tests are performed.
2020-04-30 11:50:15 +00:00
lly
68e8a7e0ba ble_mesh: Update next alloc address when node info is added 2020-04-30 11:50:15 +00:00
lly
62ac50f9d7 ble_mesh: Fix Provisioner provisioning deadlock 2020-04-30 11:50:15 +00:00
lly
fefd52f093 ble_mesh: Remove BLE_MESH_MAX_STORED_NODES option
Previously the BLE_MESH_MAX_STORED_NODES option is added for
internal mesh test, which will be a little confusing for the
users to understand.
Here we remove this option, instead the BLE_MESH_MAX_PROV_NODES
will be used for all the cases. For mesh internal test, when
the test function is called to add some nodes info, the info
will be stored in the array of provisioned nodes directly.
2020-04-30 11:50:15 +00:00
lly
7c379f8a65 ble_mesh: Associate replay protection list size with nodes count
The replay protection list of Provisioner should be at least equal
to the number of nodes with the precondition that each node contains
only one element.
The help information of replay protection list is updated, and the
maximum number of nodes for Provisioner is adjusted based on the
replay protection list size.
2020-04-30 11:50:15 +00:00
lly
fca858dd58 ble_mesh: Add bluedroid and nimble example configurations 2020-04-30 11:45:22 +00:00
lly
c28828d255 doc: Fix some ble mesh description 2020-04-30 11:43:26 +00:00
lly
d595793caa ble_mesh: Add ble mesh sensor model examples 2020-04-30 11:35:11 +00:00
lly
67eef52822 ble_mesh: Add some common macros for sensor model 2020-04-30 11:35:11 +00:00
lly
6f7acf6a21 ble_mesh: Allow empty sensor series column value 2020-04-30 11:35:11 +00:00
lly
df96c73471 ble_mesh: Check if same sensor (settings) property id exists 2020-04-30 11:35:11 +00:00
lly
3ceb5b3718 ble_mesh: Allow empty sensor settings exist 2020-04-30 11:35:11 +00:00
lly
d51bd36142 ble_mesh: Add missing #ifdef __cplusplus 2020-04-30 08:45:55 +00:00
bd01c359bd Merge branch 'bugfix/heap_psram_fill_v4.1' into 'release/v4.1'
heap: Only fill new heaps with FREE_FILL_PATTERN if Comprehensive poisoning is on (v4.1)

See merge request espressif/esp-idf!8490
2020-04-30 13:45:07 +08:00
c5cb44d813 Merge branch 'bugfix/fix_some_wifi_bugs_0427_v4.1' into 'release/v4.1'
wifi: backport some wifi fixes 0427 (v4.1)

See merge request espressif/esp-idf!8496
2020-04-29 23:39:58 +08:00
43d8950682 wifi changes:
1. fix the bug for softAP update second channel wrong
2. change wifi_scan_time_t from union to struct
3. query country code wrong when policy change from manual to auto
2020-04-29 17:27:00 +08:00
d4e700e744 Merge branch 'bugfix/coex_fix_wifi_performance_when_ble_conn_v4.1' into 'release/v4.1'
Coexistence: Add coexist API to enable BLE connection dynamic priority

See merge request espressif/esp-idf!8467
2020-04-29 17:24:30 +08:00
ddaa9d4523 Coexistence: Add coexist API to enable BLE connection dynamic priority 2020-04-29 13:57:59 +08:00
fadbfdadf4 Merge branch 'bugfix/make_to_cmake_msys_py3_v4.1' into 'release/v4.1'
tools: Make Unicode from subprocess result in the CMake convert script (v4.1)

See merge request espressif/esp-idf!8543
2020-04-29 13:44:10 +08:00
58044063dd Fix typo with sigmadelta.h #ifdef 2020-04-29 12:20:46 +08:00
67f9448e71 fix broken CONFIG_LEGACY_INCLUDE_COMMON_HEADERS 2020-04-29 12:19:25 +08:00
5b516b107a timer_group: update hal api && fix intr_enable
timer group interrupt enable is controled by level_int_ena instead of int_ena

Closes https://github.com/espressif/esp-idf/issues/5103
2020-04-29 12:19:25 +08:00
6366c20858 Merge branch 'bugfix/pmf_cert_fixes_backport_v4.1' into 'release/v4.1'
PMF cert fixes (backport v4.1)

See merge request espressif/esp-idf!8469
2020-04-29 11:58:49 +08:00
27ec86cd8e esp_wifi: Update wifi lib
Backports PMF Certification fixes -
1. Check return status of decrypt operation. Fixes 5.3.3.1.
2. Allow PMF negotiation for WPA2-Enterprise. Fixes 5.3.3.2, 5.3.3.4.
3. Add NULL check on key before encrypting PMF, fixes crash.

Closes WIFI-2251
2020-04-29 01:47:32 +00:00
3b3050b09f tools: Make Unicode from subprocess result in the CMake convert script
Fixes an issue with Python 3 in MSYS where it fails while trying to join
paths where one part is Unicode (default string on Python3) and the
second part are bytes (returned by the subprocess call).

Closes https://github.com/espressif/esp-idf/issues/5189
2020-04-28 15:22:07 +02:00
69c8d9211f Merge branch 'bugfix/supplicant_disable_tls_v1.2_backport_v4.1' into 'release/v4.1'
Disable TLS v1.2 (backport v4.1)

See merge request espressif/esp-idf!8536
2020-04-28 16:22:26 +08:00
6254bf443e wpa_supplicant: Disable TLSv1.2 by default
Some Enterprise Authentication Servers do not support TLS v1.2.
Move this option to Menuconfig and disable by default.
2020-04-28 10:46:59 +05:30
198953df8f Merge branch 'fixbug/tcp_kill_state_assert_for_v4.1' into 'release/v4.1'
lw-ip:fixbug for tcp kill state assert(backport 4.1)

See merge request espressif/esp-idf!8452
2020-04-28 11:43:37 +08:00
87fa7af6b7 Merge branch 'bugfix/pm_dump_locks_v4.1' into 'release/v4.1'
esp_pm: esp_pm_dump_locks: don't print from a critical section (backport v4.1)

See merge request espressif/esp-idf!8353
2020-04-28 11:41:21 +08:00
e558b2237d Merge branch 'bugfix/mcpwm_period_error_v4.1' into 'release/v4.1'
bugfix(mcpwm_period_error): fix the issue of wrong period (backport v4.1)

See merge request espressif/esp-idf!7735
2020-04-27 18:06:15 +08:00
eb5bafeb65 flash: fix spi flash clock config error
Closes https://github.com/espressif/esp-idf/issues/5099
2020-04-27 16:56:58 +08:00
9a389162ab Merge branch 'fixbug/set_dhcp_time_fail_for_v4.1' into 'release/v4.1'
lw-ip:fixbug for set dhcp time fail for 4.1(backport4.1)

See merge request espressif/esp-idf!8426
2020-04-27 16:48:58 +08:00
lly
e6fc2a7bc8 ble_mesh: Fix time scene wrong macro name 2020-04-27 16:24:13 +08:00
2fb9cad1b4 doc: Add warnings about using JTAG debugging with hardware security features
This is related to the following issues but is not a fix, just documentation of a workaround until we can
improve the support:
https://github.com/espressif/esp-idf/issues/4878
https://github.com/espressif/esp-idf/issues/4734
2020-04-27 16:40:06 +10:00
13ef9cf4bc heap: Only fill new heaps with FREE_FILL_PATTERN if Comprehensive poisoning is on
Significantly speeds up heap initialization at startup when default "Light" heap
poisoning is enabled.

Tip via reddit user LinkeSeitentasche https://www.reddit.com/r/esp32/comments/fnj51a/a_guide_to_improving_esp32_boot_speed/
2020-04-27 16:32:24 +10:00
1229590a2c CI: disable unit test for ESP32S2Beta
* remove ESP32S2Beta UT configs
* remove ESP32S2Beta UT CI jobs
2020-04-27 14:02:47 +08:00
7d934dafb8 mcpwm: fix the issue of wrong period (backport v4.1) 2020-04-24 21:10:14 +08:00
6c9864ce86 Merge branch 'fix/ci_example_test_prov_v4.1' into 'release/v4.1'
CI: Fix prov example test exception handle (v4.1)

See merge request espressif/esp-idf!8439
2020-04-24 16:13:02 +08:00
4952b3baed Merge branch 'bugfix/ci_unterminated_sdkconfig_defaults_v4.1' into 'release/v4.1'
CI: Add EOL to sdkconfig.defaults before adding sdkconfig.ci (v4.1)

See merge request espressif/esp-idf!8456
2020-04-24 16:12:31 +08:00
ee234472c1 CI: Add EOL to sdkconfig.defaults before adding sdkconfig.ci 2020-04-23 16:54:16 +02:00
c50952ebaf fixbug for tcp kill state assert 2020-04-23 15:58:29 +08:00
20085a0fcd Merge branch 'bugfix/ci_partition_table_detection_v4.1' into 'release/v4.1'
CI: Fix partition table detection if "partition" is in the project name (v4.1)

See merge request espressif/esp-idf!8431
2020-04-23 11:36:58 +08:00
19449289d0 CI: Fix prov example test cryptography package version exception handling 2020-04-23 00:47:41 +05:30
f5645cc9d8 CI: Fix partition table detection if "partition" is in the project name 2020-04-22 10:04:36 +02:00
0c92ca5175 fixbug for set dhcp time fail for 4.1 2020-04-22 11:13:01 +08:00
a41bcacf31 Merge branch 'bugfix/ppp_enable_ipv6_v4.1' into 'release/v4.1'
esp-netif: make the IPv6 configurable for PPP netifs (v4.1)

See merge request espressif/esp-idf!8200
2020-04-21 12:36:00 +08:00
f4243de752 Merge branch 'bugfix/error_on_building_in_idf_path_v4.1' into 'release/v4.1'
cmake: Error out when building in IDF_PATH dir (v4.1)

See merge request espressif/esp-idf!8297
2020-04-20 15:04:33 +08:00
e9c6f119de Merge branch 'bugfix/make_system_using_rom_time_funcs_v4.1' into 'release/v4.1'
esp_rom: Fix esp32.rom.newlib-time.ld should includes all time ROM functions/data (v4.1)

See merge request espressif/esp-idf!8365
2020-04-17 14:14:13 +08:00
1ea008d22e Merge branch 'feature/add_rtc_xtal_cal_retry_option_v4.1' into 'release/v4.1'
esp32: Add a Kconfig option - Number of attempts to repeat 32k XTAL calibration (v4.1)

See merge request espressif/esp-idf!7931
2020-04-16 15:25:03 +08:00
585d53dfa8 Merge branch 'bugfix/fix_errors_with_mbedtls_disabled_v4.1' into 'release/v4.1'
wpa_supplicant: Fix compilation errors when USE_MBEDTLS is disabled. (v4.1)

See merge request espressif/esp-idf!8356
2020-04-16 14:59:35 +08:00
1f480f4570 Merge branch 'bugfix/fix_API_esp_wifi_stop_crash_issue_v4.1' into 'release/v4.1'
bugfix: fix esp_wifi_stop crash issue (backport v4.1)

See merge request espressif/esp-idf!8329
2020-04-16 14:58:00 +08:00
d10ad9a4b1 Merge branch 'bufgix/esp_ota_get_app_elf_sha256_v4.1' into 'release/v4.1'
app_update: Fix case when elf file SHA256 should be printed by panic handler while cache is disabled (v4.1)

See merge request espressif/esp-idf!8366
2020-04-16 14:32:21 +08:00
0effd9b257 Merge branch 'bugfix/efuse_get_coding_scheme_and_ut_v4.1' into 'release/v4.1'
efuse: Fix get_coding_scheme() using ESP_EARLY_LOG* instead of ESP_LOG* (v4.1)

See merge request espressif/esp-idf!8360
2020-04-16 14:29:12 +08:00
0c4e55e3bd app_update: fix test failure for get_app_elf_sha256 test
Commit fc03161f updated esp_ota_get_app_elf_sha256 to store and return
X number of bytes of the hash, but the test case still expected 64 bytes.

Updated test case to use CONFIG value for expected length.
2020-04-15 21:09:57 +08:00
a2a71fc68f app_update: Fix case when elf file SHA256 should be printed by panic handler while cache is disabled
Closes: IDF-1342
2020-04-15 21:05:58 +08:00
ae063d96c2 esp_rom: Fix esp32.rom.newlib-time.ld should includes all time ROM functions/data
- Added UT
Closes: https://github.com/espressif/esp-idf/issues/4925
2020-04-15 20:59:24 +08:00
3948065c24 efuse: Using IDF_ENV_FPGA in UTs 2020-04-15 19:43:07 +08:00
33eab40f2a efuse/esp32s2: Fix get_coding_scheme() when CONFIG_SECURE_FLASH_ENC_ENABLED and LOG_LEVEL is Debug 2020-04-15 19:36:47 +08:00
f59ef5e6ef efuse/esp32: Fix get_coding_scheme() when CONFIG_SECURE_FLASH_ENC_ENABLED and LOG_LEVEL is Debug
Closes: https://github.com/espressif/esp-idf/issues/4862
2020-04-15 19:36:45 +08:00
b7ae3ff9bd wpa_supplicant: Fix compilation errors when USE_MBEDTLS is disabled.
This is a regression from earlier commit related to TLSV12 which used
sha functions that are currently declared static.
Solution: Follow upstream code structure and resolve the errors.
2020-04-15 15:33:59 +05:30
a2a89fb95d esp32: Add a Kconfig option- Number of attempts to repeat 32k XTAL calibration
Closes: IDF-1479
2020-04-15 16:34:57 +08:00
ffe0cca423 esp_pm: esp_pm_dump_locks: don't print from a critical section
Closes https://github.com/espressif/esp-idf/issues/1917
2020-04-15 08:47:37 +02:00
b3410b9210 Merge branch 'bugfix/coredump_no_ext_stacks_v4.1' into 'release/v4.1'
core dump: don't allow core dumps to Flash if PSRAM is used for stacks (backport v4.1)

See merge request espressif/esp-idf!8228
2020-04-15 13:25:26 +08:00
b08b0f0949 Merge branch 'bugfix/psram_single_bit_error_v4.1' into 'release/v4.1'
psram: support psram 2T mode to fix single bit error (backport v4.1)

See merge request espressif/esp-idf!8327
2020-04-15 13:24:21 +08:00
f646cdd6a8 Merge branch 'nimble/fix_ble_hs_reset_v4.1' into 'release/v4.1'
NimBLE: Reset master and slave states on host reset and few minor fixes  (backport v4.1)

See merge request espressif/esp-idf!8216
2020-04-15 13:23:59 +08:00
445f727e7a Merge branch 'bugfix/fix_supplicant_tlsv12_v4.1' into 'release/v4.1'
wpa_supplicant: Fix wpa_supplicant TLS 1.2 issues (v4.1)

See merge request espressif/esp-idf!8202
2020-04-15 13:06:42 +08:00
e1562311bf Merge branch 'bugfix/logging_compilation_fix_anti_rollback_v4.1' into 'release/v4.1'
Minor fix logging issue hindering compilation on anti rollback. (v4.1)

See merge request espressif/esp-idf!8302
2020-04-14 16:36:29 +08:00
afc1362ea6 wpa_supplicant: Fix wpa_supplicant TLS 1.2 issues
1) Fixed compilation issues.
2) Added tlsprf.c from upstream
3) Enabled SHA256 in supplicant compilation.
2020-04-13 16:39:59 +00:00
5a09cfe70a Merge branch 'bugfix/uart_echo_readme_v4.1' into 'release/v4.1'
example: Remove duplicate commands and invalid serial port information (v4.1)

See merge request espressif/esp-idf!8335
2020-04-14 00:33:50 +08:00
858f4745fd example: Remove duplicate commands and invalid serial port information
Closes https://github.com/espressif/esp-idf/issues/5049
2020-04-13 15:16:11 +02:00
d880672076 bugfix: fix esp_wifi_stop crash issue 2020-04-13 16:05:48 +08:00
90a8945930 psram: support psram 2T mode to fix single bit error
1. add enable PSRAM 2T mode function
2. abort when himem and 2T mode are enabled meanwhile
3. set SPIRAM_2T_MODE as "n" by default, enable it when needed
2020-04-13 14:26:45 +08:00
34b9e6c677 Merge branch 'feat/ble_mesh_ble_adv_simultaneously_v4.1' into 'release/v4.1'
ble_mesh: Support BLE advertising simultaneously (v4.1)

See merge request espressif/esp-idf!8315
2020-04-10 21:07:19 +08:00
lly
1ac44aa202 ble_mesh: Support BLE advertising simultaneously 2020-04-10 17:34:06 +08:00
7053737110 Merge branch 'bugfix/ble_mesh_add_test_function_v4.1' into 'release/v4.1'
ble_mesh: Add ble mesh white list test function (v4.1)

See merge request espressif/esp-idf!8158
2020-04-10 17:29:38 +08:00
acb92c225f NimBLE: Minor fix in esp_nimble_cfg and bleprph README (backport v4.1) 2020-04-09 16:05:14 +05:30
072d01da2f NimBLE: Reset master and slave states on host reset and fix build failure (backport v4.1) 2020-04-09 16:05:04 +05:30
87d68ebb98 Fixes logging issue hindering compilation on anti rollback. 2020-04-09 12:04:20 +05:30
lly
89f7e62011 ble_mesh: Add ble mesh white list test function
Using the ble mesh white list test functions, a node can choose to
only receive mesh messages from a specific node and relay the
messages for it. Messages from other nodes will be ignored.
2020-04-09 06:03:59 +00:00
4fe18a9258 Merge branch 'bugfix/IDFGH-2910_v4.1' into 'release/v4.1'
NVS: bugfix - iterator skipping version 1 blobs (v4.1)

See merge request espressif/esp-idf!8191
2020-04-09 05:45:49 +08:00
51c32997b1 Merge branch 'feature/idfpy_add_baud_parameter_to_monitor_v4.1' into 'release/v4.1'
idf.py: add monitor-baud option to monitor command (v4.1)

See merge request espressif/esp-idf!7458
2020-04-09 05:44:41 +08:00
40af109144 cmake: error out on building in IDF_PATH root dir 2020-04-08 19:51:35 +08:00
ec5c123ef7 Merge branch 'bugfix/size_calculation_in_ota_v4.1' into 'release/v4.1'
Fix size calculation to erase partition range for OTA image (v4.1)

See merge request espressif/esp-idf!8266
2020-04-06 18:03:41 +08:00
4573688862 esp_ota_ops.c: Fix size calculation to erase partition range for OTA image
Closes https://github.com/espressif/esp-idf/issues/4953
2020-04-06 13:39:01 +05:30
cd301cc324 core dump: don't allow core dumps to Flash if PSRAM is used for stacks
It is not possible to write to Flash when the stack is located in
PSRAM, and it is not possible to write PSRAM buffers into Flash when
malloc can not be used.
2020-04-02 23:43:20 +02:00
9a1c5a903f Merge branch 'bugfix/btdm_backports_v4.1_0328' into 'release/v4.1'
Bugfix/btdm backports v4.1 0328

See merge request espressif/esp-idf!8150
2020-04-02 22:47:49 +08:00
655e201b1c idf.py: add monitor-baud option to monitor command 2020-04-01 15:11:20 +02:00
5e09d473c7 Merge branch 'bugfix/btdm_dont_dequeue_the_command_queue_v4.1' into 'release/v4.1'
component/bt: fix don't dequeue the command queue after process the read_by_type_req(backport v4.1)

See merge request espressif/esp-idf!8181
2020-04-01 19:06:55 +08:00
bf7f40007a Merge branch 'ci/build_bootloader_configs_v4.1' into 'release/v4.1'
ci: Fix CI testing of bootloader configs (v4.1)

See merge request espressif/esp-idf!8195
2020-04-01 15:07:48 +08:00
a2c55e2c37 examples: common connect code to ignore GOT_IP6_EVENT if comes from unrelated netif 2020-04-01 08:52:55 +02:00
4b59f7e2c7 mdns: limit the GOT_IP6_EVENT to only known network interfaces 2020-04-01 08:52:54 +02:00
716298f8e3 esp-netif-ppp: support for posting GOT_IP event for IPv6 2020-04-01 08:52:54 +02:00
38060c0b58 examples: pppos_client: update sdkconfig.defaults
As per discussion in #4782, IPV6 link local negotiation by default is
disabled.

Signed-off-by: Francesco Giancane <francesco.giancane@accenture.com>
2020-04-01 08:52:54 +02:00
3c01f68a78 lwip: make IPV6 link-local support over PPP configurable
Make the link local negotiation for IPV6 in PPP optional and
configurable.
This is because some modems do not support the IPV6 negotiation and
sending IPV6CP frames would in some cases break the network
configuration phase, resulting in a timeout during the Phase Network.

Please note that this does not disable the IPV6 support for the outgoing
communication (IPV6 is still enabled even if this option is not
selected) but just for the local link between lwIP and modem.

Signed-off-by: Francesco Giancane <francesco.giancane@accenture.com>

Merges https://github.com/espressif/esp-idf/pull/4782
Closes https://github.com/espressif/esp-idf/issues/1065
2020-04-01 08:52:54 +02:00
a5bf353e3f Merge branch 'backport/malloc_zero_return_null_v4.1' into 'release/v4.1'
backport/malloc_zero_return_null_v4.1

See merge request espressif/esp-idf!8146
2020-04-01 14:41:33 +08:00
51b7247033 unit test app: Use the new config names for DEBUG/RELEASE configs
Also build the bootloader to the same config level as the app
2020-04-01 16:30:22 +11:00
52dcf1c180 ci: Build all bootloader configs when building the bootloader app
CI regression in 26efc5a6d0
2020-04-01 16:22:20 +11:00
26379f7d3e NVS: bugfix - iterator skipping version 1 blobs
Closes https://github.com/espressif/esp-idf/issues/4954
2020-04-01 11:16:28 +08:00
8dc421c7e1 Merge branch 'bugfix/secure_boot_v2_wrdis_v4.1' into 'release/v4.1'
secure boot v2: esp32: Prevent read disabling additional efuses (v4.1)

See merge request espressif/esp-idf!8179
2020-04-01 10:53:06 +08:00
79590d2e21 component/bt: fix don't dequeue the command queue after process the read_by_type_req 2020-03-31 16:27:08 +08:00
c17d55eb9b esp32: Enable flash encryption by setting FLASH_CRYPT_CNT to max
Previous method was to write-protect this efuse, however on ECO3
the write protect field also covers the UART_DOWNLOAD_DIS efuse.

Doing it this way keeps the possibility of disabling UART download
mode, later.
2020-03-31 17:31:59 +11:00
7c34711c07 docs: secure boot v2: Add a note about maximum bootloader size 2020-03-31 17:31:58 +11:00
cf8dd62fc4 secure boot v2: esp32: Prevent read disabling additional efuses
Also reduce the number of eFuse write cycles during first boot when
Secure Boot and/or Flash Encryption are enabled.
2020-03-31 17:31:56 +11:00
f96d28172b Merge branch 'bugfix/monitor_encrypted_target_v4.1' into 'release/v4.1'
tools: Fix flashing encrypted binaries from IDF Monitor (v4.1)

See merge request espressif/esp-idf!8126
2020-03-31 13:09:55 +08:00
f538b63458 Merge branch 'bugfix/fix_airkiss_bug_v4.1' into 'release/v4.1'
fix the bug for Airkiss (backport  v4.1)

See merge request espressif/esp-idf!8121
2020-03-31 00:07:51 +08:00
6c7895fbac Merge branch 'bugfix/backport_some_wifi_bugs_0326_v4.1' into 'release/v4.1'
esp_wifi: backport some WiFi bugs 0326 (backport v4.1)

See merge request espressif/esp-idf!8149
2020-03-31 00:03:25 +08:00
a8494b68e1 components/coex: Fix wakeup delay with DFS 2020-03-28 20:12:21 +08:00
8367bc4571 esp_wifi: backport some WiFi bugs
1. Fix WiFi log print level
2. Optimize WiFi/BT coexist sleep
   - If any data tx/rx in WiFi slice, fore wakeup next TBTT
   - Increase active timeout time to coex TBTT interval to avoid sleep in WiFi slice
2020-03-28 18:13:31 +08:00
374e9b32d4 bugfix/fix_controller_disable_re_enable_crash 2020-03-28 17:14:37 +08:00
7fdc9571ba multi_heap: ensure that malloc(0) return NULL pointer in any poisoning configuration 2020-03-27 14:27:45 -03:00
f9f42a9d90 Merge branch 'fix/wifi_provisioning_uuid_v4.1' into 'release/v4.1'
Wifi_provisioning: Change service_uuid to non standard 128 bit UUID and add retries in test script (backport v4.1)

See merge request espressif/esp-idf!8081
2020-03-27 22:54:10 +08:00
820ed5c7f1 tools: Fix flashing encrypted binaries from IDF Monitor 2020-03-27 09:43:26 +01:00
69147fc4ec Merge branch 'feat/ble_mesh_vnd_model_example_v4.1' into 'release/v4.1'
Feat/ble mesh vnd model example (v4.1)

See merge request espressif/esp-idf!8001
2020-03-27 14:08:13 +08:00
88f8f91d40 fix the bug for Airkiss
Closes https://github.com/espressif/esp-idf/issues/3362
2020-03-26 21:12:52 +08:00
06337f1034 Merge branch 'bugfix/cmake_bugfixes_v4.1' into 'release/v4.1'
CMake-related bugfixes (v4.1)

See merge request espressif/esp-idf!8067
2020-03-26 16:29:55 +08:00
40f66c3117 Wifi_provisioning_mgr_test: Allow three attempts to connect to AP before concluding provisioning failure 2020-03-26 05:04:52 +00:00
db1111ef79 Wifi_provisioning_ble: Change service_uuid to non standard 128 bit UUID
- Modifies UUIDs in scheme_ble, manager example and esp_prov tool to custom 128
  bit UUID
2020-03-26 05:04:52 +00:00
dbaf0f1e93 Merge branch 'bugfix/backport_some_wifi_bugs_0323_v4.1' into 'release/v4.1'
esp_wifi: Backport some wifi bugs 0323 (backport v4.1)

See merge request espressif/esp-idf!8086
2020-03-25 15:11:32 +08:00
906280e767 Merge branch 'optimization/TCPv6_connect_for_v4.1' into 'release/v4.1'
lw-ip:optimization TCPv6 connect for 4.1

See merge request espressif/esp-idf!8048
2020-03-24 15:25:27 +08:00
55abe2eba8 esp_wifi: Fix ESP32S2 wifi log not printing 2020-03-24 15:05:05 +08:00
fbe215f3c0 esp_wifi: backport some wifi bugs 0323
1.Reduce wifi bin size
2.Add TX packets size check
3.Fix scan get rssi error
4.Return fail when setting AP's channel out of range
2020-03-24 15:05:00 +08:00
6e0b8af978 Merge branch 'feature/upgrade_mbedtls_to_v4.1' into 'release/v4.1'
mbedtls: upgrade to release v2.16.5 (v4.1)

See merge request espressif/esp-idf!7986
2020-03-24 13:46:00 +08:00
b8fe1fdf27 bootloader_support: initialize mbedtls_ctr_drbg_context per mbedtls v2.16.5 requirement
In commit 02d2903e39, mbedtls was
updated to release v2.16.5, where it was made mandatory to initialize
mbedtls_ctr_drbg_context before using same. It was fixed in wpa supplicant
but missed out in secure boot v2 verification code. This commit
fixes that.
2020-03-23 11:22:20 +05:30
355a210a38 mbedtls: upgrade to release v2.16.5
For detailed release notes please refer to:
https://tls.mbed.org/tech-updates/releases/mbedtls-2.16.5-and-2.7.14-released

Closes: IDFGH-2638
Closes: https://github.com/espressif/esp-idf/issues/4716
2020-03-23 11:22:02 +05:30
5c4f7948d4 wpa_supplicant: Fix SAE test-case failure on mbedtls version udpate
Problem:
mbedtls_ctr_drbg_context was initialized in crypto_ec_point_mul. This
was okay in releases before 2.16.4 as entropy_len used to get set to
MBEDTLS_CTR_DRBG_ENTROPY_LEN in function mbedtls_ctr_drbg_seed. The
function is now changed to set the length to
MBEDTLS_CTR_DRBG_ENTROPY_LEN if previous length is 0 and hence the bug.

Solution:
Initialize mbedtls_ctr_drbg_context in crypto_ec_point_mul.
2020-03-23 11:22:02 +05:30
bc81db3676 cmake: show error message on encrypted flash targets without proper config 2020-03-22 20:44:23 +08:00
737215c50f cmake: utility to create a failing target 2020-03-22 20:01:33 +08:00
2925b5f42b examples: split source files for one of the ulp examples 2020-03-22 20:00:21 +08:00
cc95d14d80 ulp: fix ulp external project args
Closes https://github.com/espressif/esp-idf/issues/4713
2020-03-22 20:00:21 +08:00
1717232f11 ulp: use quotes when specifying files for embedding ulp binaries 2020-03-22 19:59:50 +08:00
98742664e8 ci: add test for partition_table target 2020-03-22 19:58:48 +08:00
2aba19e00d partition_table: output partition table info for partition_table target 2020-03-22 19:58:48 +08:00
9f024df9e5 Merge branch 'bugfix/modify_ble_mesh_command_for_v4.1' into 'release/v4.1'
ble mesh: update ble mesh console example  (backport v4.1)

See merge request espressif/esp-idf!8042
2020-03-22 18:36:29 +08:00
af3c81b68a ble mesh: update ble mesh console example (backport v4.1) 2020-03-22 18:36:26 +08:00
bac92d579f Merge branch 'bugfix/send_ok_when_sta_disconnect_for_v4.1' into 'release/v4.1'
lw-ip:bugfix for TCPv6 send ok when sta disconnect for v4.1

See merge request espressif/esp-idf!8025
2020-03-21 15:15:49 +08:00
b445b59c5e Merge branch 'bugfix/wep40_key_parsing_bug_v4.1' into 'release/v4.1'
Bugfix/wep40 key parsing bug v4.1

See merge request espressif/esp-idf!7990
2020-03-20 17:33:50 +08:00
9b31a2e7f9 optimization TCPv6 connect for 4.1 2020-03-20 15:04:31 +08:00
71ffae5d6e Merge branch 'bugfix/hfp_github_issues_v4.1' into 'release/v4.1'
Bugfix for HFP and some Github issue. v4.1

See merge request espressif/esp-idf!7975
2020-03-20 13:21:33 +08:00
c092f9b881 bugfix for TCPv6 send ok when sta disconnect 2020-03-19 14:14:13 +08:00
582a493739 wpa_supplicant: Add parsing support for WEP40 key
WEP key is passed as ascii key without "", add parsing support
in supplicant for this.
2020-03-18 13:40:05 +00:00
2976f5daea Merge branch 'bugfix/ci_handle_retried_jobs_v4.1' into 'release/v4.1'
ci: add find job id argument job status (backport v4.1)

See merge request espressif/esp-idf!7953
2020-03-18 16:03:18 +08:00
4414e829de Merge branch 'backport/feat/secure_boot_v2_v41' into 'release/v4.1'
Backport/feat/secure boot v2 v41

See merge request espressif/esp-idf!7854
2020-03-18 15:35:53 +08:00
e4704e0875 Merge branch 'bugfix/ble_mesh_nimble_adapt_deinit_v4.1' into 'release/v4.1'
ble_mesh: Fix ble mesh nimble host deinit (v4.1)

See merge request espressif/esp-idf!8004
2020-03-18 12:32:21 +08:00
f5fc735711 Bugfix for HFP and some Github issue.
1. Bugfix for AG audio crash (change the return position)
2. Fix the error macro name and error return in hfp_hf demo
3. Fix the annotation error using UTF-8 ' (from Github)
4. Change or remove the log in SCO related code region.
5. Correct error of introduction of a function.
2020-03-18 04:06:24 +00:00
lly
7815cd9ff4 ble_mesh: Fix ble mesh nimble host deinit 2020-03-17 16:18:50 +08:00
lly
da113cdfa8 ble_mesh: Add ESP BLE Mesh vendor models example 2020-03-17 15:54:53 +08:00
lly
48e6195506 ble_mesh: Rename ble_mesh_vendor_models to common_vendor_models 2020-03-17 15:54:40 +08:00
1cdea40bba Merge branch 'bugfix/ble_mesh_miscellaneous_fix_v4.1' into 'release/v4.1'
Bugfix/ble mesh miscellaneous fix (v4.1)

See merge request espressif/esp-idf!7969
2020-03-17 15:34:19 +08:00
3d462d7d81 Merge branch 'bugfix/compiler_err_when_performance_optimization_enabled_v4.1' into 'release/v4.1'
Bugfix/compiler err when performance optimization enabled v4.1

See merge request espressif/esp-idf!7977
2020-03-17 13:54:06 +08:00
aa6347339c Remove (x2) variable in BCM_STRNCPY_S and BCM_STRCPY_S when performance optimization enabled 2020-03-14 14:41:16 +08:00
8488f292c2 Fix mem_start uninitialized error when compiler optimization performance enabled 2020-03-14 14:41:06 +08:00
lly
6431a5e185 ble_mesh: Move dev_role to the end of model_pub 2020-03-13 19:24:49 +08:00
lly
27b28c0249 ble_mesh: Use the right netkey during iv update 2020-03-13 19:24:45 +08:00
lly
b29bc240a7 ble_mesh: Use the right net_idx & app_idx for publish 2020-03-13 19:24:37 +08:00
lly
940e87c0da ble_mesh: Check buf->ref before unref the buffer 2020-03-13 19:24:32 +08:00
lly
60eaca9637 ble_mesh: Fix mesh memory use-after-free issue 2020-03-13 19:24:27 +08:00
lly
e01333514d ble_mesh: Add ble mesh deinit in btc task 2020-03-13 19:24:23 +08:00
lly
f0519c674f ble_mesh: Free beacon timer when deinit mesh 2020-03-13 19:24:18 +08:00
lly
de9186b908 ble_mesh: Use lock for mesh timer operations 2020-03-13 19:24:12 +08:00
5cd45a6d80 secure boot: Fix anti-fault value if hash is shorter than curve
(Not actually a problem with SBV1 anti-fault as hash size == curve size in this case.)
2020-03-13 14:01:45 +05:30
1fa6db757d ci: add find job id argument job status:
if we retry failed job, we will have 2 jobs with same name in one pipeline. we need to use status to find the retried job instead of failed job.
2020-03-12 09:56:33 +08:00
7f84669054 Merge branch 'bugfix/from_github_v4.1' into 'release/v4.1'
Fixes from Github (backport v4.1)

See merge request espressif/esp-idf!7920
2020-03-11 21:49:19 +08:00
e82ac041cd Merge branch 'bugfix/select_waiting_assert_for_v4.1' into 'release/v4.1'
lw-ip:fix bug for after udp close select_waiting assert for v4.1

See merge request espressif/esp-idf!7919
2020-03-11 20:45:35 +08:00
47f9c0e301 fix bug for after udp close select_waiting assert for v4.1 2020-03-11 10:06:43 +00:00
d09a43fc1e Merge branch 'bugfix/ota_with_redirection_v4.1' into 'release/v4.1'
esp_https_ota in sync with master (v4.1)

See merge request espressif/esp-idf!7914
2020-03-11 14:46:25 +08:00
a003bcde29 Merge branch 'bugfix/idfpygenerator_v4.1' into 'release/v4.1'
tools: fix idf.py to be able to select a generator for build (v4.1)

See merge request espressif/esp-idf!7917
2020-03-10 22:22:47 +08:00
492065463d Merge branch 'bugfix/put_spihost_handle_in_sram_v4.1' into 'release/v4.1'
spi: always put spihost handle in SRAM (backport v4.1)

See merge request espressif/esp-idf!7901
2020-03-10 14:22:32 +08:00
85c15812c9 fix markdown table formatting
fixed markdown for a table in
`examples/peripherals/temp_sensor_esp32s2/README.md`

Merges https://github.com/espressif/esp-idf/pull/4609
2020-03-09 11:25:54 +01:00
ba43902fb8 Fixes compilation error on verbose level (IDFGH-2439)
Closes #4552

Merges https://github.com/espressif/esp-idf/pull/4786
2020-03-09 11:25:54 +01:00
eda9d8ffa8 Added semi-colon to esp_event_loop_create(...)
Title sums it up.

Merges https://github.com/espressif/esp-idf/pull/4711
2020-03-09 11:17:08 +01:00
f4c84ea2b2 Fix typo
Merges https://github.com/espressif/esp-idf/pull/4752
2020-03-09 11:17:08 +01:00
fefd64fa83 Merge branch 'Bugfix/netconn_marked_close_crash_for_v4.1' into 'release/v4.1'
lw-ip:fix bug for netconn marked close crash for v4.1

See merge request espressif/esp-idf!7896
2020-03-09 16:36:39 +08:00
70b1ab76e8 esp_https_ota.c: Add errno check for WiFi disconnection while performing OTA 2020-03-09 13:26:36 +05:30
6bc77d79a6 OTA: Add fix in case of URL redirection and a test case of URL redirection
Closes https://github.com/espressif/esp-idf/issues/4780
2020-03-09 13:26:36 +05:30
4c09dc6270 OTA: Fixed OTA with chunked servers and added example_test with chunked server 2020-03-09 13:26:36 +05:30
570653bc7b tools: fix idf.py to be able to select a generator for build 2020-03-09 08:42:14 +01:00
2241dda536 Merge branch 'feature/netif_ppp_authtype_none_v4.1' into 'release/v4.1'
esp-netif: PPPoS fixes (v4.1)

See merge request espressif/esp-idf!7849
2020-03-09 13:34:16 +08:00
a559d55379 Merge branch 'bugfix/spiflash_read_psram_v4.1' into 'release/v4.1'
spi_flash: Fix over-allocation and OOM crash when reading from SPI flash to PSRAM buffers (v4.1)

See merge request espressif/esp-idf!7877
2020-03-09 11:13:29 +08:00
c99eac2f0b Merge branch 'bugfix/aligned_alloc_without_poisoning_v4.1' into 'release/v4.1'
bugfix/heap: Make aligned alloc and aligned free available to all heap poisoning configurations (v4.1)

See merge request espressif/esp-idf!7898
2020-03-09 11:05:24 +08:00
a1764ec5b0 fix bug for netconn marked close crash for v4.1 2020-03-09 02:54:20 +00:00
5ce7ec848c heap: pushed down all the aligned_alloc / free implementation 2020-03-08 23:17:05 +00:00
15cdd2859a heap: added aligned alloc implementation on multi_heap layer 2020-03-08 23:17:05 +00:00
a0abb4dfdc Merge branch 'bugfix/docs_ulp_reg_rd_wr_instructions_v4.1' into 'release/v4.1'
Correct ULP REG_WR and REG_RD instruction for ESP32

See merge request espressif/esp-idf!7869
2020-03-06 19:08:30 +08:00
f5b678f7ba Correct ULP REG_WR and REG_RD instruction for ESP32 2020-03-06 19:08:29 +08:00
1af819d19b spi: always put spihost handle in SRAM
Closes https://github.com/espressif/esp-idf/issues/4635
2020-03-06 17:36:44 +08:00
408d1d9f93 Merge branch 'bugfix/cmake_convert_whitespace_v4.1' into 'release/v4.1'
cmake: Minor convert_to_cmake.py fixes (v4.1)

See merge request espressif/esp-idf!7875
2020-03-06 14:58:14 +08:00
f70dcd9ab5 Merge branch 'bugfix/modem_ppp_close_fix_4.1' into 'release/v4.1'
esp_modem.c: post PPP stop event when requested (v4.1)

See merge request espressif/esp-idf!7882
2020-03-06 14:31:06 +08:00
a251485359 Merge branch 'bugfix/clean_pcnt_i2s_public_header_v4.1' into 'release/v4.1'
driver: clean pcnt.h i2s.h (backport v4.1)

See merge request espressif/esp-idf!7839
2020-03-06 14:05:33 +08:00
ee86ee0094 Merge branch 'feature/wpa3_testcases_support_v4.1' into 'release/v4.1'
esp_wifi: Support for additional WPA3 testcases (Backport v4.1)

See merge request espressif/esp-idf!7880
2020-03-06 12:23:43 +08:00
5dbabae9dc Merge branch 'nimble/host_based_rpa_v4.1' into 'release/v4.1'
NimBLE: Support Host based privacy (RPA) feature in NimBLE host (backport v4.1)

See merge request espressif/esp-idf!7887
2020-03-06 11:02:22 +08:00
48fe9dfce7 NimBLE: Add Host based privacy (RPA) feature support (v4.1)
- This feature removes dependency on controller to use privacy (RPA)

Closes BT-519
2020-03-06 11:02:22 +08:00
5f2d918437 bootloader: Set the bootloader optimization level separately to the app
Change the default bootloader config to -Os to save size.

This is a useful feature because it allows switching between debug
and release configs in the app without also needing to account for a
size change in the bootloader.
2020-03-06 01:16:04 +05:30
32756b165e bootloader: Add fault injection resistance to Secure Boot bootloader verification
Goal is that multiple faults would be required to bypass a boot-time signature check.

- Also strengthens some address range checks for safe app memory addresses
- Change pre-enable logic to also check the bootloader signature before enabling SBV2 on ESP32

Add some additional checks for invalid sections:

- Sections only partially in DRAM or IRAM are invalid
- If a section is in D/IRAM, allow the possibility only some is in D/IRAM
- Only pass sections that are entirely in the same type of RTC memory region
2020-03-06 01:16:04 +05:30
74b299c4c7 secure boot: Encrypt the bootloader signature when enabling flash encryption + secure boot v2 2020-03-06 01:16:04 +05:30
27e9cb785a feat/secure_boot_v2: Adding docs for secure boot v2 ESP32-ECO3 2020-03-06 01:16:04 +05:30
60fed38c0f feat/secure_boot_v2: Adding secure boot v2 support for ESP32-ECO3 2020-03-06 01:16:04 +05:30
a66955b36a Merge branch 'bugfix/cmake_generators_v4.1' into 'release/v4.1'
tools: Force the order of cmake generators (v4.1)

See merge request espressif/esp-idf!7848
2020-03-05 20:17:32 +08:00
535b378869 Merge branch 'nimble/make_msys_1_configurable_v4.1' into 'release/v4.1'
NimBLE: Fix check for static random address & add MSYS_1 in menuconfig (backport v4.1)

See merge request espressif/esp-idf!7864
2020-03-05 18:00:28 +08:00
e36b3e0d04 NimBLE: Fix check for static random address & add MSYS_1 in menuconfig (v4.1)
Closes BT-522 & BT-523
2020-03-05 18:00:27 +08:00
2afafe890a esp_modem.c: post PPP stop event when requested
When library users call esp_stop_ppp(), it is expected that the PPP link
is closed and the DCE is moved into command mode.

If the STOP event is not posted into the event loop, then the PPP stack
would not be turned off, resulting in the impossibility to switch into
command mode, as the modem is still sending PPP binary data.

Signed-off-by: Francesco Giancane <francesco.giancane@accenture.com>

Merges https://github.com/espressif/esp-idf/pull/4642
2020-03-05 09:23:21 +01:00
e7c8a36d46 Merge branch 'bugfix/esp_tls_blocking_timeout_v4.1' into 'release/v4.1'
esp-tls: add timeout for blocking connection (v4.1)

See merge request espressif/esp-idf!7395
2020-03-05 16:06:35 +08:00
0e21d1e372 Merge branch 'nimble/misc_host_flow_ctrl_changes_v4.1' into 'release/v4.1'
NimBLE: Misc changes in host flow control, ble_gap_unpair, ble_hs_hci_rx_evt, memory management & example (backport v4.1)

See merge request espressif/esp-idf!7857
2020-03-05 14:54:39 +08:00
96cd373265 Merge branch 'bugfix/btdm_assert_when_create_connection_cancel_v4.1' into 'release/v4.1'
components/bt: Fix assert when create conntion cancel

See merge request espressif/esp-idf!7817
2020-03-05 14:53:18 +08:00
00f0cdcc92 esp_wifi: Support for additional WPA3 testcases
1. Anti-Clogging Token Request support
2. Return correct status from SAE modules for invalid scenarios
3. Add PMK Caching support for WPA3
2020-03-05 12:15:03 +05:30
425486223e spi_flash: Remove 16KB free internal heap limit for esp_flash_read() into PSRAM
Allocation of the temporary internal buffer will now repeat until a small enough buffer can be
allocated, and only fail if less than a 256 byte block of internal RAM is free.

Adds unit test for the same, and generic test utility for creating memory pressure.
2020-03-05 17:10:22 +11:00
d6026823fa spi_flash: Fix over-allocation and OOM crash when reading from SPI flash to PSRAM buffers
Previously would try allocate buffer of minimum size 16KB not maximum size 16KB, causing
out of memory errors for any large reads, or if less than 16KB contiguous free heap.

Also, if using legacy API and internal allocation failed then implementation would abort()
instead of returning the error to the caller.

Added test for using large buffers in PSRAM.

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

Also reported on forum: https://esp32.com/viewtopic.php?f=13&t=14304&p=55972
2020-03-05 17:10:22 +11:00
c57ba38d67 cmake: Add warnings that convert_to_cmake.py doesn't calculate component requirements
Any component which requires another component will need this manually
added to its CMakeLists.txt file.
2020-03-05 17:06:13 +11:00
250e219279 cmake: convert_to_cmake: Fix possible whitespace issues
As reported on forum:
https://esp32.com/viewtopic.php?f=2&t=13565&p=53476#p53453

split() with no arg will match any whitespace sequence not just
a single space, so takes care of case where two spaces are
inserted in the variable value.
2020-03-05 17:06:13 +11:00
233d4b94bd esp_tls: fail connection if esp_tls_conn_new() timeouts 2020-03-04 15:15:40 +00:00
d19c1c4b3c esp_tls: added connection timeout to esp_tls_conn_new_sync() 2020-03-04 15:15:40 +00:00
e7a33878bb Merge branch 'bugfix/backport_some_wifi_issues_0302' into 'release/v4.1'
esp_wifi: backport some wifi issues 0302 (backport v4.1)

See merge request espressif/esp-idf!7826
2020-03-04 15:36:31 +08:00
74c528d836 NimBLE: Use dynamic buffers instead of static memory.
The NimBLE host buffers that consume a significant amount of memory are
now allocated dynamically.
The advantage is that, the memory can be reclaimed in cases where BLE
is turned off and not required for the current boot cycle
2020-03-04 12:01:53 +05:30
c55689ca18 NimBLE: Misc changes in host flow control, ble_gap_unpair, ble_hs_hci_rx_evt & example (v4.1)
- Add menuconfig option for NimBLE host flow control
- Include changes in `blecent` example from upstream PR!702
- add ble_hs_lock in ble_gap_unpair Upstream PR!584
- ble_hs_hci_rx_evt, upstream PR!738

Closes https://github.com/espressif/esp-idf/issues/4243
2020-03-04 11:35:47 +05:30
b8c2fedec9 Merge branch 'bugfix/add_hostname_in_discover_packet_for_v4.1' into 'release/v4.1'
lw-ip:add host name in discover packet for v4.1

See merge request espressif/esp-idf!7842
2020-03-04 11:24:42 +08:00
23c5770156 esp_netif_lwip_ppp: fix posting ip-event data
Closes https://github.com/espressif/esp-idf/issues/4634
2020-03-03 15:00:37 +01:00
4c668ff3d3 esp_netif_lwip_ppp: Allow esp_netif_ppp_set_auth set auth_type with NETIF_PPP_AUTHTYPE_NONE
The ppp_set_auth() is guard by #if PPP_AUTH_SUPPORT in lwIP, so
make it consistent. This also simplify the code a bit because the code
in #if PAP_SUPPORT guard and #if CHAP_SUPPORT guard are exactly the same.

Once NETIF_PPP_AUTHTYPE_NONE added to esp_netif_auth_type_t, it also allows
setting NETIF_PPP_AUTHTYPE_NONE with this change.

Signed-off-by: Axel Lin <axel.lin@gmail.com>

Merges https://github.com/espressif/esp-idf/pull/4639
2020-03-03 15:00:37 +01:00
4a623798f1 esp_netif_ppp: Add NETIF_PPP_AUTHTYPE_NONE to esp_netif_auth_type_t
To allow setting auth_type to PPPAUTHTYPE_NONE, add NETIF_PPP_AUTHTYPE_NONE
to esp_netif_auth_type_t.
So even PAP/CHAP are enabled in lwIP, the application still can set
auth_type to PPPAUTHTYPE_NONE.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
2020-03-03 15:00:37 +01:00
0f191c3366 tools: Force the order of cmake generators 2020-03-03 11:39:59 +01:00
077d68c752 driver: clean pcnt.h i2s.h 2020-03-03 18:12:11 +08:00
4d10eb20db esp_wifi: fix some WiFi bugs
Fix following WiFi bugs:
1. Fix crashing during shared WEP connection
2. Remove log "age_bss: null bss
3. Add WiFi stop checking at the beginning of wifi deinit api
4. Fix espnow crash
5. Fix the bug for setting channel when WiFi is no NULL mode
6. Adjust scheme percent when BT is in connected status
7. Fix WiFi stop leads to memory leak
8. Place the Vendor Specific Element at the end of WiFi packet
2020-03-03 14:49:36 +08:00
94327c10ed add host name in discover packet for v4.1 2020-03-03 14:25:47 +08:00
328c659cd3 Merge branch 'feat/ble_mesh_update_4.1' into 'release/v4.1'
Feat/ble mesh update 4.1

See merge request espressif/esp-idf!7798
2020-03-02 15:33:05 +08:00
lly
8e34adb94c ble_mesh: Calc incomplete timeout based on msg info 2020-03-02 02:08:13 +00:00
lly
7d41eb6f52 ble_mesh: Start the timer when starting to send the client message 2020-03-02 02:08:13 +00:00
lly
2a014db549 ble_mesh: No timeout for client message to non-unicast address 2020-03-02 02:08:13 +00:00
lly
6c207ea6d2 ble_mesh: Unify client application and lower transport layer timeout 2020-03-02 02:08:13 +00:00
lly
2611e23bd2 ble_mesh: Allow maximum 377 octets payload 2020-03-02 02:08:13 +00:00
lly
4b2ef7303e ble_mesh: Reset transport info when node is removed 2020-03-02 02:08:13 +00:00
lly
21af266a11 ble_mesh: Provisioner ignores msg from removed node 2020-03-02 02:08:13 +00:00
lly
711c8472fc ble_mesh: Miscellaneous modifications
1. Add an API to set Provisioner static oob value
2. Add an API to deinit BLE Mesh stack
3. Add an API to set Provisioner unicast address
4. Add an API to provision devices with fixed address
5. Add an API to store node composition data
6. Add an API to get node with device uuid
7. Add an API to get node with unicast address
8. Add an API to delete node with device uuid
9. Add an API to delete node with unicast address
10. Add an API for Provisioner to update local AppKey
11. Add an API for Provisioner to update local NetKey
12. Support Provisioner persistent functionality
13. Fix Provisioner entering IV Update procedure
14. Fix an issue which may cause client failing to send msg
15. Use bt_mesh.flags to indicate device role
16. Remove several useless macros
17. Callback RSSI of received mesh provisioning packets
18. Modify the Provisioner disable function
19. Change some log level from debug to info
20. Add parameters to Provisioner bind AppKey completion event
21. Fix node ignoring relay messages issue
22. Support using a specific partition for BLE Mesh
23. Fix compile warning when proxy related macros are disabled
24. Clean up BLE Mesh stack included header files
25. NULL can be input if client message needs no parameters
26. Fix compile warning when BT log is disabled
27. Initilize BLE Mesh stack local variables
28. Support using PSRAM for BLE Mesh mutex, queue and task
29. Add a menuconfig option to enable using memory from PSRAM
30. Clean up sdkconfig.defaults of BLE Mesh examples
2020-03-02 02:08:13 +00:00
df06f7d715 Merge branch 'bugfix/doc_remove_cmake_defconfig_v4.1' into 'release/v4.1'
Doc: replace defconfig with reconfigure (v4.1)

See merge request espressif/esp-idf!7687
2020-03-02 05:09:38 +08:00
a280f0a9ba Merge branch 'bugfix/IPV6_multicast_adress_error_for_v4.1' into 'release/v4.1'
lw-ip:fix ipv6 bug when input the wrong broadcast for v4.1

See merge request espressif/esp-idf!7804
2020-02-29 17:06:56 +08:00
9177f5d32e Merge branch 'feature/doc_feedback_links_v4.1' into 'release/v4.1'
docs: Include feedback link in footer (v4.1)

See merge request espressif/esp-idf!7820
2020-02-29 16:57:49 +08:00
4045dc8508 Merge branch 'bugfix/nec_example_v4.1' into 'release/v4.1'
bugfix in NEC example and low level function  (v4.1)

See merge request espressif/esp-idf!7635
2020-02-29 02:56:12 +08:00
f4f2724a4e Include feedback link in footer 2020-02-29 00:32:35 +08:00
dbc0a9b3f4 components/bt: Fix assert when create conntion cancel 2020-02-28 20:23:39 +08:00
83fc174310 Merge branch 'bugfix/btdm_div_by_zero_in_slp_clk_conversion_for_v4.1' into 'release/v4.1'
bugfix/btdm_div_by_zero_in_slp_clk_conversion_for_v4.1(backport v4.1)

See merge request espressif/esp-idf!7786
2020-02-28 17:19:41 +08:00
6fad6eb9f1 component/bt: set non-zero initial value for bt sleep clock cycle to avoid div-by-zero error in function "btdm_us_2_lpcycles" when BT modem sleep is not enabled 2020-02-28 14:08:47 +08:00
9c5067a998 fix ipv6 bug when input the wrong broadcast for v4.1 2020-02-27 17:13:03 +08:00
3b16089cb2 Merge branch 'bugfix/doc_python3_v4.1' into 'release/v4.1'
Docs: Encourage to use Python 3 (v4.1)

See merge request espressif/esp-idf!7782
2020-02-27 01:48:23 +08:00
de3eed647f Docs: Encourage to used Python 3 2020-02-26 09:11:13 +01:00
c4654298ce Merge branch 'bugfix/add_missing_ledc_set_pin_declaration_v4.1' into 'release/v4.1'
Bugfix: Add missing ledc_set_pin declaration in led.h (v4.1)

See merge request espressif/esp-idf!7372
2020-02-26 15:20:40 +08:00
9c8c6b5cd5 Merge branch 'bugfix/sntp_init_can_run_before_net_connection_v4.1' into 'release/v4.1'
lw_ip: Add to sys_arch_protect() a check that the mutex is created before use if not then creates it (v4.1)

See merge request espressif/esp-idf!7756
2020-02-26 11:30:09 +08:00
dc8701601d Merge branch 'bugfix/esp_netif_pppos_dce_off_v4.1' into 'release/v4.1'
pppos_client: Fix power_down dce immediately after got IP (v4.1)

See merge request espressif/esp-idf!7398
2020-02-26 11:29:18 +08:00
402a118299 Merge branch 'bugfix/btdm_check_EXT_CRYS_state_for_sleep_clk_for_v4.1' into 'release/v4.1'
bugfix/btdm_check_EXT_CRYS_state_for_sleep_clk(backport v4.1)

See merge request espressif/esp-idf!7748
2020-02-25 17:55:31 +08:00
5487700bf1 lwip: Add to sys_arch_protect() a check that the mutex is created before use if not then creates it
Closes: https://github.com/espressif/esp-idf/issues/944
Closes: https://github.com/espressif/esp-idf/issues/3931
Closes: WIFI-1019
2020-02-24 15:48:27 +08:00
cd492747e1 component/bt: fall back to main XTAL as Bluetooth sleep clock when EXT 32K CRYS is configured but not detected 2020-02-24 12:22:35 +08:00
9cdbda325a Merge branch 'bugfix/btdm_backports_v4.1_0220' into 'release/v4.1'
components/bt: backports to release/v4.1

See merge request espressif/esp-idf!7716
2020-02-21 14:57:16 +08:00
9bf147515c Merge branch 'bugfix/fix_sniffer_bug_caused_by_mode_switch_v4.1' into 'release/v4.1'
Fix sniffer bug caused by mode switch  (backport v4.1)

See merge request espressif/esp-idf!7690
2020-02-21 14:53:56 +08:00
3a9750746f Merge branch 'bugfix/add_option_to_ipv6_stateless_address_configuration_v4.1' into 'release/v4.1'
lw-ip: Add option to ipv6 stateless address configuration (backport v4.1)

See merge request espressif/esp-idf!7699
2020-02-21 14:53:32 +08:00
0809136836 Merge branch 'bugfix/esp_log_timestamp_v4.1' into 'release/v4.1'
Use proper API to get Tick Count is esp_log_timestamp (v4.1)

See merge request espressif/esp-idf!7717
2020-02-20 21:11:10 +08:00
124b735ac5 log: Check for ISR context and use proper API to get Tick Count 2020-02-20 15:38:08 +05:30
a74d85945a components/bt: backports to release/v4.1
Fix bugs about role switch
Fix watchdog timeout when sleep enabled and crash without enabling sw coex
Fix ble crash issue triggered by ble event irq miss(0x20000)
Future events scheduling error in case of wifi and bluetooth.
2020-02-20 17:53:40 +08:00
ce4334f4bf lwip: Enable IPv6 stateless address autoconfiguration 2020-02-20 14:44:49 +08:00
5c217d8bb6 Merge branch 'bugfix/coex_a2dp_stuck_after_creating_another_connection_v4.1' into 'release/v4.1'
components/coex: Fix a2dp stuck after creating another connection

See merge request espressif/esp-idf!7662
2020-02-20 14:16:53 +08:00
0664f82431 Merge branch 'bugfix/coex_fix_misspell_in_kconfig_v4.1' into 'release/v4.1'
components/coex: Fix misspell in Kconfig

See merge request espressif/esp-idf!7671
2020-02-20 14:15:53 +08:00
0350ea5744 esp_wifi: Small refactor for ic_set_vif 2020-02-20 12:22:52 +08:00
145682b854 Doc: replace defconfig with reconfigure
Closes https://github.com/espressif/esp-idf/issues/3965
2020-02-19 17:06:43 +01:00
1e54e5ddef components/coex: Fix misspell in Kconfig 2020-02-19 11:43:53 +08:00
3f4da83520 Merge branch 'bugfix/kconfig_cmake_escape_v4.1' into 'release/v4.1'
confgen.py: Escape special characters for cmake (v4.1)

See merge request espressif/esp-idf!7645
2020-02-19 08:00:53 +08:00
8609b3730d Merge branch 'bugfix/unified_prov_bluedroid_v4.1' into 'release/v4.1'
Unified Provisioning - BLE: Fix characteristics read response issue (backport v4.1)

See merge request espressif/esp-idf!7652
2020-02-18 20:57:22 +08:00
e8d33e4faf Merge branch 'bugfix/ble_mesh_fix_compile_error_with_cpp_4.1' into 'release/v4.1'
ble_mesh: Fix compile error with c++ files (v4.1)

See merge request espressif/esp-idf!7583
2020-02-18 20:43:51 +08:00
8908d52efa components/coex: Fix a2dp stuck after creating another connection 2020-02-18 20:13:41 +08:00
5a244bc935 Unified Provisioning - BLE: Fix characteristics read response issue
Fix the issue when number of bytes to be read is an exact multiple of [MTU-1]
2020-02-18 15:11:51 +05:30
ea35218d2a confgen.py: Escape special characters for cmake
Closes https://github.com/espressif/esp-idf/issues/4751
2020-02-18 09:55:30 +01:00
d01af529f6 Merge branch 'bugfix/idf_tools_pylauncher_v4.1' into 'release/v4.1'
idf_tools.py: fix typo in __PYVENV_LAUNCHER__ env variable name (backport v4.1)

See merge request espressif/esp-idf!7478
2020-02-18 16:24:56 +08:00
3b86e7e099 Merge branch 'bugfix/change_hci_task_size_back_v4.1' into 'release/v4.1'
components/bt: change HCI task size back

See merge request espressif/esp-idf!7568
2020-02-18 12:52:10 +08:00
bd8baba0dc rmt: fix missing 0x in rmt_ll.h
Closes https://github.com/espressif/esp-idf/issues/4760
2020-02-18 10:54:03 +08:00
8954c989f4 Update ir_builder_rmt_nec.c
fixes standard protocol mode wich would fail due to integer promotion in inversion

Merges https://github.com/espressif/esp-idf/pull/4750
2020-02-18 10:53:49 +08:00
f6c90adb42 Update ir_protocols_main.c
RMT write should be non-blocking to wait the correct time for sending the repeat frame
2020-02-18 10:53:37 +08:00
a0ebe4d18c Merge branch 'bugfix/ulp_s2_linux_32bit_v4.1' into 'release/v4.1'
tools: mark ULP toolchain as not available on 32-bit Linux (backport v4.1)

See merge request espressif/esp-idf!7476
2020-02-15 00:53:04 +08:00
eb11a748e7 Merge branch 'feature/idf_docker_updates_v4.1' into 'release/v4.1'
Enable ccache and use newer CMake in Docker image (backport v4.1)

See merge request espressif/esp-idf!7481
2020-02-15 00:52:47 +08:00
c8e605cd71 Merge branch 'bugfix/idf_fullclean_loses_target_v4.1' into 'release/v4.1'
idf.py: guess IDF_TARGET from sdkconfig/sdkconfig.defaults, error out if IDF_TARGET is inconsistent (backport v4.1)

See merge request espressif/esp-idf!7601
2020-02-15 00:52:22 +08:00
0f9e14de9a Merge branch 'bugfix/smtp_strict_prototypes_fix_v4.1' into 'release/v4.1'
ci: re-add the lost PEDANTIC_{C,CXX}FLAGS in CMake example builds (backport v4.1)

See merge request espressif/esp-idf!7599
2020-02-15 00:52:02 +08:00
73fd009d40 Merge branch 'bugfix/btdm_hfp_ag_crash_in_unknown_at_cmd_v4.1' into 'release/v4.1'
components/bt: Fix connection fail and crash when receive unknown AT cmd

See merge request espressif/esp-idf!7405
2020-02-14 19:46:49 +08:00
17afd49e01 Merge branch 'bugfix/doc_sphinxcontrib_dep_v4.1' into 'release/v4.1'
Docs: Fix sphinxcontrib dependencies

See merge request espressif/esp-idf!7598
2020-02-14 17:21:07 +08:00
8cdb2538d3 Merge branch 'bugfix/win_tools_installer_fixes_v4.1' into 'release/v4.1'
docs: Windows tools installer release v2.3 (v4.1)

See merge request espressif/esp-idf!7560
2020-02-14 17:16:02 +08:00
cbd24259b2 Merge branch 'bugfix/btdm_error_type_in_config_eir_evt_v4.1' into 'release/v4.1'
components/bt: Fix error EIR type in config eir event

See merge request espressif/esp-idf!7406
2020-02-14 16:38:25 +08:00
9aa61d634b Merge branch 'bugfix/wifi_clear_phy_status_when_cpu_start_v4.1' into 'release/v4.1'
soc: clear PHY status when cpu start (backport v4.1)

See merge request espressif/esp-idf!7590
2020-02-14 11:34:38 +08:00
e547329935 ci: fix build system test on macOS
Replaces ${var^^} expansion supported with Bash >= 4 with 'tr'
2020-02-13 19:11:17 +01:00
6ae3311f48 idf.py: fail and show instructions on IDF_TARGET mismatch
Closes IDF-869
2020-02-13 19:10:41 +01:00
1adf837577 docs: update build system guide on setting IDF_TARGET 2020-02-13 19:10:41 +01:00
b76a10dd4f idf.py: guess IDF_TARGET from sdkconfig if CMakeCache doesn't exist
This solves the issue that target is changed to the default one after
idf.py fullclean.

Also allow setting the default target using sdkconfig.defaults, e.g.
CONFIG_IDF_TARGET="esp32s2"

Closes IDF-1040
2020-02-13 19:05:10 +01:00
911f931ccb ci: re-add the lost PEDANTIC_{C,CXX}FLAGS in CMake example builds 2020-02-13 18:51:56 +01:00
c74521f06d Docs: Fix sphinxcontrib dependencies 2020-02-13 14:50:31 +01:00
317f0d496a soc: clear PHY status when cpu start 2020-02-13 14:25:32 +08:00
ca735340f9 Merge branch 'bugfix/ble_mesh_utf_8_comma_4.1' into 'release/v4.1'
ble_mesh: Kconfig included a UTF-8 comma (v4.1)

See merge request espressif/esp-idf!7575
2020-02-13 11:12:17 +08:00
lly
45af9bf3ec ble_mesh: Fix compile error with c++ files 2020-02-13 09:46:54 +08:00
cdd3f6e8e7 Merge branch 'bugfix/spiffs_case_when_use_mtime_is_not_set_v4.1' into 'release/v4.1'
spiffs: Fix for case when CONFIG_SPIFFS_USE_MTIME is not defined (v4.1)

See merge request espressif/esp-idf!7573
2020-02-13 07:04:44 +08:00
lly
7acdc2f7fc ble_mesh: Kconfig included a UTF-8 comma 2020-02-12 18:25:43 +08:00
c6c18ef2e8 spiffs: Fix for case when CONFIG_SPIFFS_USE_MTIME is not defined
Closes: 2c793cef06
2020-02-12 18:12:58 +08:00
9eec899f49 Merge branch 'bugfix/ci_no_attempts_no_custom_toolchain_url_v4.1' into 'release/v4.1'
ci: no stage attempts variables, no custom toolchain url (backport v4.1)

See merge request espressif/esp-idf!7543
2020-02-12 17:55:37 +08:00
549d026dc3 Merge branch 'bugfix/idf_tools_virtualenv_v4.1' into 'release/v4.1'
idf_tools.py: fix install-python-env failure with virtualenv 20.0.0 (backport v4.1)

See merge request espressif/esp-idf!7552
2020-02-12 17:32:15 +08:00
9ebdcf5b37 components/bt: change HCI task size back 2020-02-12 16:32:56 +08:00
a0d7dd770c Merge branch 'feature/esp32_5p0_backport_v4p1' into 'release/v4.1'
code optimize backport to v4.1

See merge request espressif/esp-idf!7558
2020-02-12 15:20:18 +08:00
21c1682a7a backport code optimize, mr !7409 2020-02-12 11:50:52 +08:00
4541e065e4 docs: update version of IDF tools installer for windows to v2.3 2020-02-12 10:26:34 +11:00
81298c3f70 idf_tools.py: fix install-python-env failure with virtualenv 20.0.0
--no-site-packages is the default behavior since virtualenv 1.7
(released in Nov 2011). This option was removed in virtualenv 20.0.
2020-02-11 09:43:27 +01:00
33069f3133 Merge branch 'bugfix/part_gen_subtype_fix_v4.1' into 'release/v4.1'
partition_table: Fix subtype in gen_esp32part.py (v4.1)

See merge request espressif/esp-idf!7535
2020-02-11 12:06:41 +08:00
04f589b1c7 Merge branch 'bugfix/remove_cjson_test_file_from_cmake_build_v4.1' into 'release/v4.1'
cJSON: include only source file objects for cmake build (v4.1)

See merge request espressif/esp-idf!7545
2020-02-11 11:57:26 +08:00
901ae4d11c Merge branch 'bugfix/newlib_nano_lib_linking_v4.1' into 'release/v4.1'
esp_rom: link newlib nano from ROM only if SPIRAM cache workaround is disabled (v4.1)

See merge request espressif/esp-idf!7544
2020-02-11 11:56:11 +08:00
bdf8df61c0 Merge branch 'bugfix/stage_two_bootloader_linking_v4.1' into 'release/v4.1'
Fixes accessing some files from 2nd part of the bootloader. (v4.1)

See merge request espressif/esp-idf!7541
2020-02-10 20:54:34 +08:00
d41f3cc759 cJSON: include only source file objects for cmake build
Test file can cause build issues in some cases, since it has its own main() function
2020-02-10 17:32:14 +05:30
1ae9541176 esp_rom: link newlib nano from ROM only if SPIRAM cache workaround is disabled 2020-02-10 17:30:25 +05:30
224c221ddd ci: remove using IDF_XTENSA_TOOLCHAIN_URL because there are idf_tools.json and multi-target support 2020-02-10 18:46:42 +07:00
2ad0e78210 ci: Use ARTIFACT_DOWNLOAD_ATTEMPTS and others from the project settings 2020-02-10 18:46:37 +07:00
546cf10c5d Fixes accessing some files from 2nd part of the bootloader. 2020-02-10 16:33:02 +05:30
994e632a59 Fix subtype in PartitionTable.find_by_type
Fix ptype->subtype

Closes https://github.com/espressif/esp-idf/pull/4723
2020-02-10 08:37:10 +01:00
5799999e41 Merge branch 'bugfix/esp_timer_stucks_into_esp_timer_impl_set_alarm_v4.1' into 'release/v4.1'
esp_timer/esp32: Fix esp_timer_impl_set_alarm() when CPU and APB freqs are changed (v4.1)

See merge request espressif/esp-idf!7507
2020-02-10 13:43:05 +08:00
4e1c41c7e1 Merge branch 'bugfix/doc_nwdiag_v4.1' into 'release/v4.1'
docs: Fix nwdiag dependency for documentation build (v4.1)

See merge request espressif/esp-idf!7515
2020-02-07 06:29:23 +08:00
371565be3e docs: Fix nwdiag dependency for documentation build 2020-02-06 17:51:47 +01:00
12353ff3d8 esp_timer/esp32: Fix case when alarm_reg > counter_reg but FRC_TIMER_INT_STATUS is not set
Closes: WIFI-1576
Closes: https://github.com/espressif/esp-idf/issues/2954
2020-02-06 14:43:40 +08:00
fc1119331a Merge branch 'bugfix/wps_config_init_v4.1' into 'release/v4.1'
WPS_CONFIG_INIT_DEFAULT(type) error

See merge request espressif/esp-idf!7443
2020-02-06 14:07:19 +08:00
7d30c6d799 WPS_CONFIG_INIT_DEFAULT(type) error 2020-02-06 14:07:14 +08:00
73384c1b52 Merge branch 'bugfix/idf_monitor_usbser_sys_v4.1' into 'release/v4.1'
tools: work around usbser.sys bug in IDF monitor (v4.1)

See merge request espressif/esp-idf!7469
2020-01-31 15:59:59 +08:00
c67c3aa14e pppos_client: Fix power_down dce immediately after got IP
This was accidently commited bug when convert to use esp-netif, fix it.

Fixes: 25913af2cc ("pppos_client: udated example code to use esp-netif in PPP configuration")
Signed-off-by: Axel Lin <axel.lin@gmail.com>

Merges https://github.com/espressif/esp-idf/pull/4618
2020-01-30 12:00:23 +00:00
70dee9f4bb tools/docker: enable ccache by default 2020-01-30 12:09:08 +01:00
bf6e745ac0 tools/docker: install CMake version provided in tools.json
Closes https://github.com/espressif/esp-idf/issues/4644
Closes IDFGH-2559
2020-01-30 12:09:08 +01:00
e89392596c idf_tools.py: fix typo in __PYVENV_LAUNCHER__ env variable name
Fixes the workaround added in 9279b72a6.
2020-01-30 11:51:59 +01:00
a8bec381bc tools: mark ULP toolchain as not available on 32-bit Linux
Also install ULP toolchain by default on ARM Linux.

Closes https://github.com/espressif/esp-idf/issues/4621
2020-01-30 11:49:39 +01:00
4f46828464 Merge branch 'bugfix/http_client_chunked_test_v4.1' into 'release/v4.1'
http_client: fix example test to expect -1 as content-len for chunked transfer (v4.1)

See merge request espressif/esp-idf!7456
2020-01-30 18:35:49 +08:00
15011e0d16 tools: work around usbser.sys bug in idf_monitor
implemented workaround in idf_monitor for known usbser.sys bug which
causes changes in RTS signal to only be sent if DTR signal also changes.
Works by forcing a dummy change in DTR signal (re-assigning its current
value, as it has previously been done in the flashing tool)

Closes https://github.com/espressif/esp-idf/pull/4676
2020-01-29 10:23:24 +01:00
7261e72ef7 http_client: fix example test to expect -1 as content-len for chunked transfer 2020-01-27 10:36:32 +01:00
aedf89237f Merge branch 'bugfix/select_driver_not_installed_v4.1' into 'release/v4.1'
VFS: Check in select() if the UART driver is installed or not (v4.1)

See merge request espressif/esp-idf!7416
2020-01-22 11:55:09 +08:00
7848dd949f Merge branch 'bugfix/backport_several_ethernet_bugfix' into 'release/v4.1'
Ethenret driver bugfix and optimization (4.1)

See merge request espressif/esp-idf!7427
2020-01-22 11:54:51 +08:00
ba26fdba4c Merge branch 'fix/ci_target_test_v4.1' into 'release/v4.1'
ci: Fix target variable default value (backport v4.1)

See merge request espressif/esp-idf!7425
2020-01-22 11:48:30 +08:00
1a3bb06916 ethernet: always put eth_driver handle in SRAM
Closes https://github.com/espressif/esp-idf/issues/4635
2020-01-21 21:45:24 +08:00
274b0b8d8a ethernet: work with cache disabled
add ETH_MAC_FLAG_WORK_WITH_CACHE_DISABLE flag, make ethenret driver
possible to work when cache disabled

Closes https://github.com/espressif/esp-idf/issues/4406
2020-01-21 21:45:04 +08:00
9dcb48b86b ci: Fix target variable default value
(cherry picked from commit 3748e06108bd3067b36c3b605feb6aaf438d98eb)
2020-01-21 17:55:23 +05:30
ee42e3d714 Merge branch 'nimble/example_update_doc_v4.1' into 'release/v4.1'
NimBLE: Update the documentation link in the examples (v4.1)

See merge request espressif/esp-idf!7367
2020-01-21 17:56:32 +08:00
c2a4dd0c68 VFS: Check in select() if the UART driver is installed or not
Closes https://github.com/espressif/esp-idf/issues/4627
2020-01-21 10:04:38 +01:00
3733c9f8e5 Merge branch 'bugfix/btdm_hci_timeout_v4.1' into 'release/v4.1'
Bugfix/btdm hci timeout v4.1

See merge request espressif/esp-idf!7339
2020-01-21 10:33:46 +08:00
38ff669727 components/bt: Fix error EIR type in config eir event 2020-01-20 21:47:23 +08:00
c324e7a435 components/bt: Fix connection fail and crash when receive unknown AT cmd 2020-01-20 21:43:23 +08:00
c62d5e942e Merge branch 'bugfix/enable_ipv6_address_autoconfig_v4.1' into 'release/v4.1'
lw-ip: Enable IPv6 stateless address autoconfiguration (backport v4.1)

See merge request espressif/esp-idf!7381
2020-01-20 21:09:19 +08:00
3e4e538087 fix bug sleep may cause HCI timeout
When Host run different cpu and sleep enable, it may cause hci
timeout about 10s.
2020-01-20 17:41:28 +08:00
b99a39535b lwip: Enable IPv6 stateless address autoconfiguration 2020-01-20 08:26:00 +00:00
f6523748fc fix Kconfig use mistake cause some config not effect
1. Fix bluedroid task pinned_to_core un-effected
2. other minor sdkconfig bugs
2020-01-20 15:24:41 +08:00
09b4bb5eba Merge branch 'bugfix/backport_some_wifi_bugs_0120_v4.1' into 'release/v4.1'
Bugfix/backport some wifi bugs 0120 v4.1

See merge request espressif/esp-idf!7390
2020-01-20 13:56:00 +08:00
e751c59d5d Merge branch 'bugfix/backport_some_controller_bugs_0120_v4.1' into 'release/v4.1'
Bugfix/backport some controller bugs 0120 v4.1

See merge request espressif/esp-idf!7391
2020-01-20 13:55:40 +08:00
c0e1f83a91 esp32 5p0 new features support 2020-01-20 12:18:55 +08:00
fd61f75db9 hfp disconn issue for bridgera 2020-01-20 12:18:26 +08:00
abe0225ef5 esp_wifi:Fix double recycle bar crash issue 2020-01-20 12:10:48 +08:00
b530b26e1b esp_wifi: esp_wifi_sta_get_ap_info function returns actual values of group cipher and pairwise cipher 2020-01-20 12:10:06 +08:00
51e208533e Merge branch 'bugfix/update_kconfiglib_v4.1' into 'release/v4.1'
tools: Update kconfiglib to 13.7.1 (v4.1)

See merge request espressif/esp-idf!7340
2020-01-20 09:23:10 +08:00
c014d32193 Bugfix(LEDC): Add missing ledc_set_pin declaration in led.h 2020-01-17 10:19:15 +08:00
19980ace1f NimBLE: Update the documentation link in the examples 2020-01-16 18:00:18 +05:30
1542 changed files with 64258 additions and 62087 deletions

View File

@ -38,7 +38,7 @@ If the issue cannot be solved after the steps before, please follow these instru
- Development Kit: [ESP32-Wrover-Kit|ESP32-DevKitC|ESP32-PICO-Kit|ESP32-LyraT|ESP32-LyraTD-MSC|none]
- Kit version (for WroverKit/PicoKit/DevKitC): [v1|v2|v3|v4]
- Module or chip used: [ESP32-WROOM-32|ESP32-WROOM-32D|ESP32-WROOM-32U|ESP32-WROVER|ESP32-WROVER-I|ESP32-WROVER-B|ESP32-WROVER-IB|ESP32-SOLO-1|ESP32-PICO-D4|ESP32]
- IDF version (run ``git describe --tags`` to find it):
- IDF version (run ``git describe`` to find it):
// v3.2-dev-1148-g96cd3b75c
- Build System: [Make|CMake|idf.py]
- Compiler version (run ``xtensa-esp32-elf-gcc --version`` to find it):

17
.github/workflows/release_zips.yml vendored Normal file
View File

@ -0,0 +1,17 @@
name: Create zip file with recursive source clone for release
on:
push:
tags:
- v*
jobs:
release_zips:
name: Create release zip file
runs-on: ubuntu-20.04
steps:
- name: Create a recursive clone source zip
uses: espressif/github-actions/release_zips@master
env:
RELEASE_PROJECT_NAME: ESP-IDF
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -8,6 +8,18 @@ stages:
- deploy
- post_check
# pipelines will not be created in such two cases:
# 1. MR push
# 2. push not on "master/release" branches, and not tagged
# This behavior could be changed after the `rules: changes` feature is implemented
workflow:
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: never
- if: '$CI_COMMIT_REF_NAME != "master" && $CI_COMMIT_BRANCH !~ /^release\/v/ && $CI_COMMIT_TAG !~ /^v\d+\.\d+(\.\d+)?($|-)/ && $CI_PIPELINE_SOURCE == "push"'
when: never
- when: always
variables:
# System environment
@ -16,9 +28,8 @@ variables:
# GitLab-CI environment
# more attempts for more robust
GET_SOURCES_ATTEMPTS: "10"
ARTIFACT_DOWNLOAD_ATTEMPTS: "10"
# XXX_ATTEMPTS variables (https://docs.gitlab.com/ce/ci/yaml/README.html#job-stages-attempts) are not defined here.
# Use values from "CI / CD Settings" - "Variables".
# GIT_STRATEGY is not defined here.
# Use an option from "CI / CD Settings" - "General pipelines".
@ -36,19 +47,23 @@ variables:
UNIT_TEST_BUILD_SYSTEM: cmake
EXAMPLE_TEST_BUILD_SYSTEM: cmake
# IDF environment
IDF_PATH: "$CI_PROJECT_DIR"
BATCH_BUILD: "1"
V: "0"
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"
CUSTOM_TOOLCHAIN_PATH: "/opt/xtensa-custom"
# Docker images
# Docker images
BOT_DOCKER_IMAGE_TAG: ":latest"
# target test config file, used by assign test job
# target test config file, used by assign test job
CI_TARGET_TEST_CONFIG_FILE: "$CI_PROJECT_DIR/tools/ci/config/target-test.yml"
# 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:v7"
@ -56,25 +71,6 @@ variables:
.apply_bot_filter: &apply_bot_filter
python $APPLY_BOT_FILTER_SCRIPT || exit 0
.setup_custom_toolchain: &setup_custom_toolchain |
if [ "$IDF_XTENSA_TOOLCHAIN_URL" ] ; then
echo "Use a custom toolchain: ${IDF_XTENSA_TOOLCHAIN_URL:-Unknown}"
rm -rf "$CUSTOM_TOOLCHAIN_PATH" &&
mkdir -p -v "$CUSTOM_TOOLCHAIN_PATH" &&
pushd "$CUSTOM_TOOLCHAIN_PATH" &&
curl -sSL -o xtensa-custom.xxx "$IDF_XTENSA_TOOLCHAIN_URL" &&
ls -l xtensa-custom.xxx &&
tar xf xtensa-custom.xxx --strip-components 1 &&
ls -l . &&
popd
PATH=$CUSTOM_TOOLCHAIN_PATH/bin:$PATH
export PATH
fi
.cleanup_custom_toolchain: &cleanup_custom_toolchain |
echo "Cleaning up $CUSTOM_TOOLCHAIN_PATH"
rm -rf "$CUSTOM_TOOLCHAIN_PATH"
.setup_tools_unless_target_test: &setup_tools_unless_target_test |
if [[ "$SETUP_TOOLS" == "1" || "$CI_JOB_STAGE" != "target_test" ]]; then
tools/idf_tools.py --non-interactive install && eval "$(tools/idf_tools.py --non-interactive export)" || exit 1
@ -96,13 +92,10 @@ before_script:
- echo -e "Host gitlab.espressif.cn\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
# Set some options and environment for CI
- source tools/ci/configure_ci_environment.sh
- *setup_tools_unless_target_test
- *fetch_submodules
- *setup_custom_toolchain
# used for check scripts which we want to run unconditionally
.before_script_lesser_nofilter:
variables:
@ -111,7 +104,6 @@ before_script:
- echo "Not setting up GitLab key, not fetching submodules, not applying bot filter"
- source tools/ci/setup_python.sh
- source tools/ci/configure_ci_environment.sh
- *setup_custom_toolchain
# used for everything else where we want to do no prep, except for bot filter
.before_script_lesser:
@ -123,10 +115,6 @@ before_script:
# apply bot filter in before script
- *apply_bot_filter
- source tools/ci/configure_ci_environment.sh
- *setup_custom_toolchain
after_script:
- *cleanup_custom_toolchain
.check_job_template:
stage: pre_check
@ -151,9 +139,17 @@ after_script:
dependencies: []
before_script:
- *apply_bot_filter
- $IDF_PATH/tools/idf_tools.py install-python-env
# On macOS, these tools need to be installed
- $IDF_PATH/tools/idf_tools.py --non-interactive install cmake ninja
# This adds tools (compilers) and the version-specific Python environment to PATH
- *setup_tools_unless_target_test
- *setup_custom_toolchain
# Install packages required by CI scripts into IDF Python environment
- pip install -r $IDF_PATH/tools/ci/python_packages/ttfw_idf/requirements.txt
- source tools/ci/configure_ci_environment.sh
# Part of tools/ci/setup_python.sh; we don't use pyenv on macOS, so can't run the rest of the script.
- export PYTHONPATH="$IDF_PATH/tools:$IDF_PATH/tools/ci/python_packages:$PYTHONPATH"
- *fetch_submodules
include:
- '/tools/ci/config/pre_check.yml'

6
.gitlab/CODEOWNERS Normal file
View File

@ -0,0 +1,6 @@
# For the syntax of this file, see:
#
# https://docs.gitlab.com/ee/user/project/code_owners.html#the-syntax-of-code-owners-files
#
* @esp-idf-codeowners/all-maintainers

View File

@ -1,6 +1,12 @@
cmake_minimum_required(VERSION 3.5)
project(esp-idf C CXX ASM)
if(CMAKE_CURRENT_LIST_DIR STREQUAL CMAKE_SOURCE_DIR)
message(FATAL_ERROR "Current directory '${CMAKE_CURRENT_LIST_DIR}' is not buildable. "
"Change directories to one of the example projects in '${CMAKE_CURRENT_LIST_DIR}/examples' and try "
"again.")
endif()
unset(compile_options)
unset(c_compile_options)
unset(cxx_compile_options)
@ -10,15 +16,31 @@ unset(link_options)
# Add the following build specifications here, since these seem to be dependent
# on config values on the root Kconfig.
if(CONFIG_COMPILER_OPTIMIZATION_SIZE)
list(APPEND compile_options "-Os")
list(APPEND compile_options "-freorder-blocks")
elseif(CONFIG_COMPILER_OPTIMIZATION_DEFAULT)
list(APPEND compile_options "-Og")
elseif(CONFIG_COMPILER_OPTIMIZATION_NONE)
list(APPEND compile_options "-O0")
elseif(CONFIG_COMPILER_OPTIMIZATION_PERF)
list(APPEND compile_options "-O2")
if(NOT BOOTLOADER_BUILD)
if(CONFIG_COMPILER_OPTIMIZATION_SIZE)
list(APPEND compile_options "-Os")
list(APPEND compile_options "-freorder-blocks")
elseif(CONFIG_COMPILER_OPTIMIZATION_DEFAULT)
list(APPEND compile_options "-Og")
elseif(CONFIG_COMPILER_OPTIMIZATION_NONE)
list(APPEND compile_options "-O0")
elseif(CONFIG_COMPILER_OPTIMIZATION_PERF)
list(APPEND compile_options "-O2")
endif()
else() # BOOTLOADER_BUILD
if(CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE)
list(APPEND compile_options "-Os")
list(APPEND compile_options "-freorder-blocks")
elseif(CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_DEBUG)
list(APPEND compile_options "-Og")
elseif(CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_NONE)
list(APPEND compile_options "-O0")
elseif(CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_PERF)
list(APPEND compile_options "-O2")
endif()
endif()

12
Kconfig
View File

@ -46,12 +46,11 @@ mainmenu "Espressif IoT Development Framework Configuration"
a crosstool-ng gcc setup that is in your PATH.
config SDK_PYTHON
string "Python 2 interpreter"
string "Python interpreter"
depends on !IDF_CMAKE
default "python"
help
The executable name/path that is used to run python. On some systems Python 2.x
may need to be invoked as python2.
The executable name/path that is used to run python.
(Note: This option is used with the legacy GNU Make build system only.)
@ -116,7 +115,7 @@ mainmenu "Espressif IoT Development Framework Configuration"
mon reset halt
# Run to a specific point in ROM code,
# where most of initialization is complete.
thb *0x40007901
thb *0x40007d54
c
# Load the application into RAM
load
@ -172,7 +171,7 @@ mainmenu "Espressif IoT Development Framework Configuration"
prompt "Optimization Level"
default COMPILER_OPTIMIZATION_DEFAULT
help
This option sets compiler optimization level (gcc -O argument).
This option sets compiler optimization level (gcc -O argument) for the app.
- The "Default" setting will add the -0g flag to CFLAGS.
- The "Size" setting will add the -0s flag to CFLAGS.
@ -190,6 +189,9 @@ mainmenu "Espressif IoT Development Framework Configuration"
Note that custom optimization levels may be unsupported.
Compiler optimization for the IDF bootloader is set separately,
see the BOOTLOADER_COMPILER_OPTIMIZATION setting.
config COMPILER_OPTIMIZATION_DEFAULT
bool "Debug (-Og)"
config COMPILER_OPTIMIZATION_SIZE

View File

@ -2,9 +2,7 @@
* [中文版](./README_CN.md)
[![Documentation Status](https://readthedocs.com/projects/espressif-esp-idf/badge/?version=latest)](https://docs.espressif.com/projects/esp-idf/en/latest/?badge=latest)
ESP-IDF is the official development framework for the [ESP32](https://espressif.com/en/products/hardware/esp32/overview) chip.
ESP-IDF is the official development framework for the [ESP32](https://espressif.com/en/products/hardware/esp32/overview) chip provided for Windows, Linux and macOS.
# Developing With ESP-IDF
@ -37,25 +35,15 @@ See the Getting Started guide links above for a detailed setup guide. This is a
## Setup Build Environment
(See Getting Started guide for a full list of required steps with details.)
(See the Getting Started guide listed above for a full list of required steps with more details.)
* Install host build dependencies mentioned in Getting Started guide.
* Add `tools/` directory to the PATH
* Run `python -m pip install -r requirements.txt` to install Python dependencies
* Install host build dependencies mentioned in the Getting Started guide.
* Run the install script to set up the build environment. The options include `install.bat` or `install.ps1` for Windows, and `install.sh` for Unix shells.
* Run the export script on Windows (`export.bat`) or source it on Unix (`source export.sh`) in every shell environment before using ESP-IDF.
## Configuring the Project
`idf.py menuconfig`
* Opens a text-based configuration menu for the project.
* Use up & down arrow keys to navigate the menu.
* Use Enter key to go into a submenu, Escape key to go out or to exit.
* Type `?` to see a help screen. Enter key exits the help screen.
* Use Space key, or `Y` and `N` keys to enable (Yes) and disable (No) configuration items with checkboxes "`[*]`"
* Pressing `?` while highlighting a configuration item displays help about that item.
* Type `/` to search the configuration items.
Once done configuring, press Escape multiple times to exit and say "Yes" to save the new configuration when prompted.
`idf.py menuconfig` opens a text-based configuration menu where you can configure the project.
## Compiling the Project

View File

@ -39,4 +39,4 @@ target_compile_options(${COMPONENT_LIB} PRIVATE "-fno-profile-arcs" "-fno-test-c
# Force app_trace to also appear later than gcov in link line
idf_component_get_property(app_trace app_trace COMPONENT_LIB)
target_link_libraries(${COMPONENT_LIB} INTERFACE $<TARGET_FILE:${app_trace}> gcov $<TARGET_FILE:${app_trace}> ${LIBC})
target_link_libraries(${COMPONENT_LIB} INTERFACE $<TARGET_FILE:${app_trace}> gcov $<TARGET_FILE:${app_trace}> c)

View File

@ -3,10 +3,11 @@ archive: libapp_trace.a
entries:
app_trace (noflash)
app_trace_util (noflash)
SEGGER_SYSVIEW (noflash)
SEGGER_RTT_esp32 (noflash)
SEGGER_SYSVIEW_Config_FreeRTOS (noflash)
SEGGER_SYSVIEW_FreeRTOS (noflash)
if SYSVIEW_ENABLE = y:
SEGGER_SYSVIEW (noflash)
SEGGER_RTT_esp32 (noflash)
SEGGER_SYSVIEW_Config_FreeRTOS (noflash)
SEGGER_SYSVIEW_FreeRTOS (noflash)
[mapping:driver]
archive: libdriver.a

View File

@ -22,4 +22,14 @@ menu "Application manager"
The PROJECT_NAME variable from the build system will not affect the firmware image.
This value will not be contained in the esp_app_desc structure.
config APP_RETRIEVE_LEN_ELF_SHA
int "The length of APP ELF SHA is stored in RAM(chars)"
default 16
range 8 64
help
At startup, the app will read this many hex characters from the embedded APP ELF SHA-256 hash value
and store it in static RAM. This ensures the app ELF SHA-256 value is always available
if it needs to be printed by the panic handler code.
Changing this value will change the size of a static buffer, in bytes.
endmenu # "Application manager"

View File

@ -72,13 +72,38 @@ static inline char IRAM_ATTR to_hex_digit(unsigned val)
return (val < 10) ? ('0' + val) : ('a' + val - 10);
}
__attribute__((constructor)) void esp_ota_init_app_elf_sha256(void)
{
esp_ota_get_app_elf_sha256(NULL, 0);
}
/* The esp_app_desc.app_elf_sha256 should be possible to print in panic handler during cache is disabled.
* But because the cache is disabled the reading esp_app_desc.app_elf_sha256 is not right and
* can lead to a complete lock-up of the CPU.
* For this reason we do a reading of esp_app_desc.app_elf_sha256 while start up in esp_ota_init_app_elf_sha256()
* and keep it in the static s_app_elf_sha256 value.
*/
int IRAM_ATTR esp_ota_get_app_elf_sha256(char* dst, size_t size)
{
size_t n = MIN((size - 1) / 2, sizeof(esp_app_desc.app_elf_sha256));
const uint8_t* src = esp_app_desc.app_elf_sha256;
static char s_app_elf_sha256[CONFIG_APP_RETRIEVE_LEN_ELF_SHA / 2];
static bool first_call = true;
if (first_call) {
first_call = false;
// At -O2 optimization level, GCC optimizes out the copying of the first byte of the app_elf_sha256,
// because it is zero at compile time, and only modified afterwards by esptool.
// Casting to volatile disables the optimization.
const volatile uint8_t* src = (const volatile uint8_t*)esp_app_desc.app_elf_sha256;
for (size_t i = 0; i < sizeof(s_app_elf_sha256); ++i) {
s_app_elf_sha256[i] = src[i];
}
}
if (dst == NULL || size == 0) {
return 0;
}
size_t n = MIN((size - 1) / 2, sizeof(s_app_elf_sha256));
for (size_t i = 0; i < n; ++i) {
dst[2*i] = to_hex_digit(src[i] >> 4);
dst[2*i + 1] = to_hex_digit(src[i] & 0xf);
dst[2*i] = to_hex_digit(s_app_elf_sha256[i] >> 4);
dst[2*i + 1] = to_hex_digit(s_app_elf_sha256[i] & 0xf);
}
dst[2*n] = 0;
return 2*n + 1;

View File

@ -157,7 +157,8 @@ esp_err_t esp_ota_begin(const esp_partition_t *partition, size_t image_size, esp
if ((image_size == 0) || (image_size == OTA_SIZE_UNKNOWN)) {
ret = esp_partition_erase_range(partition, 0, partition->size);
} else {
ret = esp_partition_erase_range(partition, 0, (image_size / SPI_FLASH_SEC_SIZE + 1) * SPI_FLASH_SEC_SIZE);
const int aligned_erase_size = (image_size + SPI_FLASH_SEC_SIZE - 1) & ~(SPI_FLASH_SEC_SIZE - 1);
ret = esp_partition_erase_range(partition, 0, aligned_erase_size);
}
if (ret != ESP_OK) {

View File

@ -87,9 +87,8 @@ class OtatoolTarget():
seq = bytearray(self.otadata[start:start + 4])
crc = bytearray(self.otadata[start + 28:start + 32])
seq = struct.unpack('>I', seq)
crc = struct.unpack('>I', crc)
seq = struct.unpack('I', seq)
crc = struct.unpack('I', crc)
info.append(otadata_info(seq[0], crc[0]))
return info
@ -108,7 +107,7 @@ class OtatoolTarget():
def is_otadata_info_valid(status):
seq = status.seq % (1 << 32)
crc = hex(binascii.crc32(struct.pack("I", seq), 0xFFFFFFFF) % (1 << 32))
crc = binascii.crc32(struct.pack('I', seq), 0xFFFFFFFF) % (1 << 32)
return seq < (int('0xFFFFFFFF', 16) % (1 << 32)) and status.crc == crc
partition_table = self.target.partition_table
@ -219,8 +218,8 @@ def _read_otadata(target):
otadata_info = target._get_otadata_info()
print(" {:8s} \t {:8s} | \t {:8s} \t {:8s}".format("OTA_SEQ", "CRC", "OTA_SEQ", "CRC"))
print("Firmware: 0x{:8x} \t0x{:8x} | \t0x{:8x} \t 0x{:8x}".format(otadata_info[0].seq, otadata_info[0].crc,
print(' {:8s} \t {:8s} | \t {:8s} \t {:8s}'.format('OTA_SEQ', 'CRC', 'OTA_SEQ', 'CRC'))
print('Firmware: 0x{:08x} \t0x{:08x} | \t0x{:08x} \t 0x{:08x}'.format(otadata_info[0].seq, otadata_info[0].crc,
otadata_info[1].seq, otadata_info[1].crc))
@ -249,6 +248,10 @@ def _erase_ota_partition(target, ota_id):
def main():
if sys.version_info[0] < 3:
print("WARNING: Support for Python 2 is deprecated and will be removed in future versions.", file=sys.stderr)
elif sys.version_info[0] == 3 and sys.version_info[1] < 6:
print("WARNING: Python 3 versions older than 3.6 are not supported.", file=sys.stderr)
global quiet
parser = argparse.ArgumentParser("ESP-IDF OTA Partitions Tool")

View File

@ -4,7 +4,7 @@
TEST_CASE("esp_ota_get_app_elf_sha256 test", "[esp_app_desc]")
{
const int sha256_hex_len = 64;
const int sha256_hex_len = CONFIG_APP_RETRIEVE_LEN_ELF_SHA;
char dst[sha256_hex_len + 2];
const char fill = 0xcc;
int res;

View File

@ -6,7 +6,7 @@ if(BOOTLOADER_BUILD OR NOT CONFIG_APP_BUILD_BOOTLOADER)
endif()
# When secure boot is enabled, do not flash bootloader along with invocation of `idf.py flash`
if(NOT CONFIG_SECURE_BOOT_ENABLED)
if(NOT CONFIG_SECURE_BOOT)
set(flash_bootloader FLASH_IN_PROJECT)
endif()

View File

@ -1,4 +1,29 @@
menu "Bootloader config"
choice BOOTLOADER_COMPILER_OPTIMIZATION
prompt "Bootloader optimization Level"
default BOOTLOADER_COMPILER_OPTIMIZATION_SIZE
help
This option sets compiler optimization level (gcc -O argument)
for the bootloader.
- The default "Size" setting will add the -0s flag to CFLAGS.
- The "Debug" setting will add the -Og flag to CFLAGS.
- The "Performance" setting will add the -O2 flag to CFLAGS.
- The "None" setting will add the -O0 flag to CFLAGS.
Note that custom optimization levels may be unsupported.
config BOOTLOADER_COMPILER_OPTIMIZATION_SIZE
bool "Size (-Os)"
config BOOTLOADER_COMPILER_OPTIMIZATION_DEBUG
bool "Debug (-Og)"
config BOOTLOADER_COMPILER_OPTIMIZATION_PERF
bool "Optimize for performance (-O2)"
config BOOTLOADER_COMPILER_OPTIMIZATION_NONE
bool "Debug without optimization (-O0)"
endchoice
choice BOOTLOADER_LOG_LEVEL
bool "Bootloader log verbosity"
default BOOTLOADER_LOG_LEVEL_INFO
@ -224,7 +249,7 @@ menu "Bootloader config"
config BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP
bool "Skip image validation when exiting deep sleep"
depends on (SECURE_BOOT_ENABLED && SECURE_BOOT_INSECURE) || !SECURE_BOOT_ENABLED
depends on (SECURE_BOOT && SECURE_BOOT_INSECURE) || !SECURE_BOOT
default n
help
This option disables the normal validation of an image coming out of
@ -279,12 +304,12 @@ menu "Security features"
config SECURE_SIGNED_ON_BOOT
bool
default y
depends on SECURE_BOOT_ENABLED || SECURE_SIGNED_ON_BOOT_NO_SECURE_BOOT
depends on SECURE_BOOT || SECURE_SIGNED_ON_BOOT_NO_SECURE_BOOT
config SECURE_SIGNED_ON_UPDATE
bool
default y
depends on SECURE_BOOT_ENABLED || SECURE_SIGNED_ON_UPDATE_NO_SECURE_BOOT
depends on SECURE_BOOT || SECURE_SIGNED_ON_UPDATE_NO_SECURE_BOOT
config SECURE_SIGNED_APPS
bool
@ -298,8 +323,7 @@ menu "Security features"
config SECURE_SIGNED_APPS_NO_SECURE_BOOT
bool "Require signed app images"
default n
depends on !SECURE_BOOT_ENABLED
depends on !SECURE_BOOT
help
Require apps to be signed to verify their integrity.
@ -308,6 +332,35 @@ menu "Security features"
against remote network access, but not physical access. Compared to using hardware Secure Boot this option
is much simpler to implement.
choice SECURE_SIGNED_APPS_SCHEME
bool "App Signing Scheme"
depends on SECURE_BOOT || SECURE_SIGNED_APPS_NO_SECURE_BOOT
default SECURE_SIGNED_APPS_ECDSA_SCHEME if SECURE_BOOT_V1_ENABLED
default SECURE_SIGNED_APPS_RSA_SCHEME if SECURE_BOOT_V2_ENABLED
help
Select the Secure App signing scheme. Depends on the Chip Revision.
There are two options:
1. ECDSA based secure boot scheme. (Only choice for Secure Boot V1)
Supported in ESP32 and ESP32-ECO3.
2. The RSA based secure boot scheme. (Only choice for Secure Boot V2)
Supported in ESP32-ECO3. (ESP32 Chip Revision 3 onwards)
config SECURE_SIGNED_APPS_ECDSA_SCHEME
bool "ECDSA"
depends on IDF_TARGET_ESP32 && (SECURE_SIGNED_APPS_NO_SECURE_BOOT || SECURE_BOOT_V1_ENABLED)
help
Embeds the ECDSA public key in the bootloader and signs the application with an ECDSA key.
Refer to the documentation before enabling.
config SECURE_SIGNED_APPS_RSA_SCHEME
bool "RSA"
depends on ESP32_REV_MIN_3 && SECURE_BOOT_V2_ENABLED
help
Appends the RSA-3072 based Signature block to the application.
Refer to <Secure Boot Version 2 documentation link> before enabling.
endchoice
config SECURE_SIGNED_ON_BOOT_NO_SECURE_BOOT
bool "Bootloader verifies app signatures"
default n
@ -334,23 +387,48 @@ menu "Security features"
If hardware secure boot is not enabled, this option still adds significant security against network-based
attackers by preventing spoofing of OTA updates.
config SECURE_BOOT_ENABLED
bool "Enable hardware secure boot in bootloader (READ DOCS FIRST)"
config SECURE_BOOT
bool "Enable hardware Secure Boot in bootloader (READ DOCS FIRST)"
default n
help
Build a bootloader which enables secure boot on first boot.
Build a bootloader which enables Secure Boot on first boot.
Once enabled, secure boot will not boot a modified bootloader. The bootloader will only load a partition
Once enabled, Secure Boot will not boot a modified bootloader. The bootloader will only load a partition
table or boot an app if the data has a verified digital signature. There are implications for reflashing
updated apps once secure boot is enabled.
When enabling secure boot, JTAG and ROM BASIC Interpreter are permanently disabled by default.
Refer to https://docs.espressif.com/projects/esp-idf/en/latest/security/secure-boot.html before enabling.
choice SECURE_BOOT_VERSION
bool "Select secure boot version"
default SECURE_BOOT_V2_ENABLED if ESP32_REV_MIN_3
depends on SECURE_BOOT
help
Select the Secure Boot Version. Depends on the Chip Revision.
Secure Boot V2 is the new RSA based secure boot scheme.
Supported in ESP32-ECO3. (ESP32 Chip Revision 3 onwards)
Secure Boot V1 is the AES based secure boot scheme.
Supported in ESP32 and ESP32-ECO3.
config SECURE_BOOT_V1_ENABLED
bool "Enable Secure Boot version 1"
depends on IDF_TARGET_ESP32
help
Build a bootloader which enables secure boot version 1 on first boot.
Refer to the Secure Boot section of the ESP-IDF Programmer's Guide for this version before enabling.
config SECURE_BOOT_V2_ENABLED
bool "Enable Secure Boot version 2"
depends on ESP32_REV_MIN_3
help
Build a bootloader which enables Secure Boot version 2 on first boot.
Refer to Secure Boot V2 section of the ESP-IDF Programmer's Guide for this version before enabling.
endchoice
choice SECURE_BOOTLOADER_MODE
bool "Secure bootloader mode"
depends on SECURE_BOOT_ENABLED
depends on SECURE_BOOT_V1_ENABLED
default SECURE_BOOTLOADER_ONE_TIME_FLASH
config SECURE_BOOTLOADER_ONE_TIME_FLASH
@ -385,7 +463,8 @@ menu "Security features"
If enabled (default), these binary files are signed as part of the build process. The file named in
"Secure boot private signing key" will be used to sign the image.
If disabled, unsigned app/partition data will be built. They must be signed manually using espsecure.py
If disabled, unsigned app/partition data will be built. They must be signed manually using espsecure.py.
Version 1 to enable ECDSA Based Secure Boot and Version 2 to enable RSA based Secure Boot.
(for example, on a remote signing server.)
config SECURE_BOOT_SIGNING_KEY
@ -395,28 +474,32 @@ menu "Security features"
help
Path to the key file used to sign app images.
Key file is an ECDSA private key (NIST256p curve) in PEM format.
Key file is an ECDSA private key (NIST256p curve) in PEM format for Secure Boot V1.
Key file is an RSA private key in PEM format for Secure Boot V2.
Path is evaluated relative to the project directory.
You can generate a new signing key by running the following command:
espsecure.py generate_signing_key secure_boot_signing_key.pem
See https://docs.espressif.com/projects/esp-idf/en/latest/security/secure-boot.html for details.
See the Secure Boot section of the ESP-IDF Programmer's Guide for this version for details.
config SECURE_BOOT_VERIFICATION_KEY
string "Secure boot public signature verification key"
depends on SECURE_SIGNED_APPS && !SECURE_BOOT_BUILD_SIGNED_BINARIES
depends on SECURE_SIGNED_APPS && !SECURE_BOOT_BUILD_SIGNED_BINARIES && !SECURE_SIGNED_APPS_RSA_SCHEME
default "signature_verification_key.bin"
help
Path to a public key file used to verify signed images. This key is compiled into the bootloader and/or
Path to a public key file used to verify signed images.
Secure Boot V1: This ECDSA public key is compiled into the bootloader and/or
app, to verify app images.
Secure Boot V2: This RSA public key is compiled into the signature block at
the end of the bootloader/app.
Key file is in raw binary format, and can be extracted from a
PEM formatted private key using the espsecure.py
extract_public_key command.
Refer to https://docs.espressif.com/projects/esp-idf/en/latest/security/secure-boot.html before enabling.
Refer to the Secure Boot section of the ESP-IDF Programmer's Guide for this version before enabling.
choice SECURE_BOOTLOADER_KEY_ENCODING
bool "Hardware Key Encoding"
@ -443,7 +526,7 @@ menu "Security features"
config SECURE_BOOT_INSECURE
bool "Allow potentially insecure options"
depends on SECURE_BOOT_ENABLED
depends on SECURE_BOOT
default N
help
You can disable some of the default protections offered by secure boot, in order to enable testing or a
@ -451,11 +534,12 @@ menu "Security features"
Only enable these options if you are very sure.
Refer to https://docs.espressif.com/projects/esp-idf/en/latest/security/secure-boot.html before enabling.
Refer to the Secure Boot section of the ESP-IDF Programmer's Guide for this version before enabling.
config SECURE_FLASH_ENC_ENABLED
bool "Enable flash encryption on boot (READ DOCS FIRST)"
default N
select SPI_FLASH_ENABLE_ENCRYPTED_READ_WRITE
help
If this option is set, flash contents will be encrypted by the bootloader on first boot.
@ -495,7 +579,7 @@ menu "Security features"
Select Release mode only for production or manufacturing. Once enabled you can not reflash using UART
bootloader
Refer to https://docs.espressif.com/projects/esp-idf/en/latest/security/secure-boot.html and
Refer to the Secure Boot section of the ESP-IDF Programmer's Guide for this version and
https://docs.espressif.com/projects/esp-idf/en/latest/security/flash-encryption.html for details.
config SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT
@ -504,6 +588,7 @@ menu "Security features"
config SECURE_FLASH_ENCRYPTION_MODE_RELEASE
bool "Release"
select PARTITION_TABLE_MD5 if !ESP32_COMPATIBLE_PRE_V3_1_BOOTLOADERS
endchoice
@ -557,6 +642,18 @@ menu "Security features"
image to this length. It is generally not recommended to set this option, unless you have a legacy
partitioning scheme which doesn't support 64KB aligned partition lengths.
config SECURE_BOOT_V2_ALLOW_EFUSE_RD_DIS
bool "Allow additional read protecting of efuses"
depends on SECURE_BOOT_INSECURE && SECURE_BOOT_V2_ENABLED
help
If not set (default, recommended), on first boot the bootloader will burn the WR_DIS_RD_DIS
efuse when Secure Boot is enabled. This prevents any more efuses from being read protected.
If this option is set, it will remain possible to write the EFUSE_RD_DIS efuse field after Secure
Boot is enabled. This may allow an attacker to read-protect the BLK2 efuse holding the public
key digest, causing an immediate denial of service and possibly allowing an additional fault
injection attack to bypass the signature protection.
config SECURE_FLASH_UART_BOOTLOADER_ALLOW_ENC
bool "Leave UART bootloader encryption enabled"
depends on SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT
@ -603,5 +700,23 @@ menu "Security features"
the wrong device. The device needs to have flash encryption already enabled using espefuse.py.
endmenu # Potentially Insecure
config SECURE_DISABLE_ROM_DL_MODE
bool "Permanently disable ROM Download Mode"
depends on ESP32_REV_MIN_3
default n
help
If set, during startup the app will burn an eFuse bit to permanently disable the UART ROM
Download Mode. This prevents any future use of esptool.py, espefuse.py and similar tools.
Once disabled, if the SoC is booted with strapping pins set for ROM Download Mode
then an error is printed instead.
It is recommended to enable this option in any production application where Flash
Encryption and/or Secure Boot is enabled and access to Download Mode is not required.
It is also possible to permanently disable Download Mode by calling
esp_efuse_disable_rom_download_mode() at runtime.
endmenu # Security features

View File

@ -45,7 +45,7 @@ clean: bootloader-clean
bootloader-list-components:
$(BOOTLOADER_MAKE) list-components
ifndef CONFIG_SECURE_BOOT_ENABLED
ifndef CONFIG_SECURE_BOOT
# If secure boot disabled, bootloader flashing is integrated
# with 'make flash' and no warnings are printed.
@ -115,13 +115,35 @@ $(BOOTLOADER_DIGEST_BIN): $(BOOTLOADER_BIN) $(SECURE_BOOTLOADER_KEY) | check_pyt
@echo "DIGEST $(notdir $@)"
$(ESPSECUREPY) digest_secure_bootloader -k $(SECURE_BOOTLOADER_KEY) -o $@ $<
else # CONFIG_SECURE_BOOT_ENABLED && !CONFIG_SECURE_BOOTLOADER_REFLASHABLE && !CONFIG_SECURE_BOOTLOADER_ONE_TIME_FLASH
else ifdef CONFIG_SECURE_BOOT_V2_ENABLED
BOOTLOADER_SIGNED_BIN := $(BOOTLOADER_BUILD_DIR)/bootloader-signed.bin
ifdef CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES
bootloader: $(BOOTLOADER_BIN) $(SDKCONFIG_MAKEFILE) | check_python_dependencies
$(ESPSECUREPY) sign_data --keyfile $(SECURE_BOOT_SIGNING_KEY) --version 2 \
-o $(BOOTLOADER_SIGNED_BIN) $(BOOTLOADER_BIN)
else
bootloader: $(BOOTLOADER_BIN) $(SDKCONFIG_MAKEFILE) | check_python_dependencies
@echo "Bootloader not signed. Sign the bootloader before flashing."
@echo "To sign the bootloader, you can use this command:"
@echo "espsecure.py sign_data --keyfile SECURE_BOOT_SIGNING_KEY --version 2 $(BOOTLOADER_BIN)"
endif
@echo $(SEPARATOR)
@echo "Use the following command to flash the bootloader:"
ifdef CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES
@echo "$(ESPTOOLPY_WRITE_FLASH) $(BOOTLOADER_OFFSET) $(BOOTLOADER_SIGNED_BIN)"
else
@echo "$(ESPTOOLPY_WRITE_FLASH) $(BOOTLOADER_OFFSET) $(BOOTLOADER_BIN)"
endif
@echo $(SEPARATOR)
else # CONFIG_SECURE_BOOT && !CONFIG_SECURE_BOOTLOADER_REFLASHABLE \
&& !CONFIG_SECURE_BOOTLOADER_ONE_TIME_FLASH && !CONFIG_SECURE_SIGNED_APPS_RSA_SCHEME
bootloader:
@echo "Invalid bootloader target: bad sdkconfig?"
@exit 1
endif
ifndef CONFIG_SECURE_BOOT_ENABLED
ifndef CONFIG_SECURE_BOOT
# don't build bootloader by default if secure boot is enabled
all_binaries: $(BOOTLOADER_BIN)
endif
@ -131,3 +153,8 @@ bootloader-clean: $(SDKCONFIG_MAKEFILE)
ifdef CONFIG_SECURE_BOOTLOADER_REFLASHABLE
rm -f $(SECURE_BOOTLOADER_KEY) $(BOOTLOADER_DIGEST_BIN)
endif
ifdef CONFIG_SECURE_SIGNED_APPS_RSA_SCHEME
ifdef CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES
rm -f $(BOOTLOADER_SIGNED_BIN)
endif
endif

View File

@ -19,8 +19,8 @@ set(bootloader_binary_files
idf_build_get_property(project_dir PROJECT_DIR)
# There are some additional processing when CONFIG_CONFIG_SECURE_SIGNED_APPS. This happens
# when either CONFIG_SECURE_BOOT_ENABLED or SECURE_BOOT_BUILD_SIGNED_BINARIES.
# There are some additional processing when CONFIG_SECURE_SIGNED_APPS. This happens
# when either CONFIG_SECURE_BOOT_V1_ENABLED or CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES.
# For both cases, the user either sets binaries to be signed during build or not
# using CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES.
#
@ -29,7 +29,13 @@ idf_build_get_property(project_dir PROJECT_DIR)
if(CONFIG_SECURE_SIGNED_APPS)
add_custom_target(gen_secure_boot_keys)
if(CONFIG_SECURE_BOOT_ENABLED)
if(CONFIG_SECURE_SIGNED_APPS_ECDSA_SCHEME)
set(secure_apps_signing_scheme "1")
elseif(CONFIG_SECURE_SIGNED_APPS_RSA_SCHEME)
set(secure_apps_signing_scheme "2")
endif()
if(CONFIG_SECURE_BOOT_V1_ENABLED)
# Check that the configuration is sane
if((CONFIG_SECURE_BOOTLOADER_REFLASHABLE AND CONFIG_SECURE_BOOTLOADER_ONE_TIME_FLASH) OR
(NOT CONFIG_SECURE_BOOTLOADER_REFLASHABLE AND NOT CONFIG_SECURE_BOOTLOADER_ONE_TIME_FLASH))
@ -60,7 +66,8 @@ if(CONFIG_SECURE_SIGNED_APPS)
# (to pick up a new signing key if one exists, etc.)
fail_at_build_time(gen_secure_boot_signing_key
"Secure Boot Signing Key ${CONFIG_SECURE_BOOT_SIGNING_KEY} does not exist. Generate using:"
"\tespsecure.py generate_signing_key ${CONFIG_SECURE_BOOT_SIGNING_KEY}")
"\tespsecure.py generate_signing_key --version ${secure_apps_signing_scheme} \
${CONFIG_SECURE_BOOT_SIGNING_KEY}")
else()
add_custom_target(gen_secure_boot_signing_key)
endif()
@ -70,7 +77,7 @@ if(CONFIG_SECURE_SIGNED_APPS)
set(ver_key_arg)
add_dependencies(gen_secure_boot_keys gen_secure_boot_signing_key)
else()
elseif(CONFIG_SECURE_SIGNED_APPS_ECDSA_SCHEME)
get_filename_component(secure_boot_verification_key
${CONFIG_SECURE_BOOT_VERIFICATION_KEY}
@ -83,7 +90,7 @@ if(CONFIG_SECURE_SIGNED_APPS)
fail_at_build_time(gen_secure_boot_verification_key
"Secure Boot Verification Public Key ${CONFIG_SECURE_BOOT_VERIFICATION_KEY} does not exist."
"\tThis can be extracted from the private signing key."
"\tSee docs/security/secure-boot.rst for details.")
"\tSee docs/security/secure-boot-v1.rst for details.")
else()
add_custom_target(gen_secure_boot_verification_key)
endif()

View File

@ -20,3 +20,6 @@ CONFIG_FLASH_ENCRYPTION_INSECURE CONFIG_SECURE_FLASH_
CONFIG_FLASH_ENCRYPTION_UART_BOOTLOADER_ALLOW_ENCRYPT CONFIG_SECURE_FLASH_UART_BOOTLOADER_ALLOW_ENC
CONFIG_FLASH_ENCRYPTION_UART_BOOTLOADER_ALLOW_DECRYPT CONFIG_SECURE_FLASH_UART_BOOTLOADER_ALLOW_DEC
CONFIG_FLASH_ENCRYPTION_UART_BOOTLOADER_ALLOW_CACHE CONFIG_SECURE_FLASH_UART_BOOTLOADER_ALLOW_CACHE
# Secure Boot Scheme
CONFIG_SECURE_BOOT_ENABLED CONFIG_SECURE_BOOT_V1_ENABLED

View File

@ -83,6 +83,39 @@ if(CONFIG_SECURE_BOOTLOADER_REFLASHABLE)
add_custom_target (gen_bootloader_digest_bin ALL DEPENDS "${bootloader_digest_bin}")
endif()
if(CONFIG_SECURE_BOOT_V2_ENABLED)
if(CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES)
get_filename_component(secure_boot_signing_key
"${SECURE_BOOT_SIGNING_KEY}" ABSOLUTE BASE_DIR "${project_dir}")
if(NOT EXISTS "${secure_boot_signing_key}")
message(FATAL_ERROR
"Secure Boot Signing Key Not found."
"\nGenerate the Secure Boot V2 RSA-PSS 3072 Key."
"\nTo generate one, you can use this command:"
"\n\t${espsecurepy} generate_signing_key --version 2 ${SECURE_BOOT_SIGNING_KEY}")
endif()
set(bootloader_unsigned_bin "bootloader-unsigned.bin")
add_custom_command(OUTPUT ".signed_bin_timestamp"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/${PROJECT_BIN}" "${CMAKE_BINARY_DIR}/${bootloader_unsigned_bin}"
COMMAND ${ESPSECUREPY} sign_data --version 2 --keyfile "${secure_boot_signing_key}"
-o "${CMAKE_BINARY_DIR}/${PROJECT_BIN}" "${CMAKE_BINARY_DIR}/${bootloader_unsigned_bin}"
COMMAND ${CMAKE_COMMAND} -E echo "Generated signed binary image ${build_dir}/${PROJECT_BIN}"
"from ${CMAKE_BINARY_DIR}/${bootloader_unsigned_bin}"
COMMAND ${CMAKE_COMMAND} -E md5sum "${CMAKE_BINARY_DIR}/${PROJECT_BIN}" > "${CMAKE_BINARY_DIR}/.signed_bin_timestamp"
DEPENDS "${build_dir}/.bin_timestamp"
VERBATIM
COMMENT "Generated the signed Bootloader")
else()
add_custom_command(OUTPUT ".signed_bin_timestamp"
VERBATIM
COMMENT "Bootloader generated but not signed")
endif()
add_custom_target (gen_signed_bootloader ALL DEPENDS "${build_dir}/.signed_bin_timestamp")
endif()
if(CONFIG_SECURE_BOOTLOADER_ONE_TIME_FLASH)
add_custom_command(TARGET bootloader.elf POST_BUILD
COMMAND ${CMAKE_COMMAND} -E echo
@ -126,4 +159,18 @@ elseif(CONFIG_SECURE_BOOTLOADER_REFLASHABLE)
"* Not recommended to re-use the same secure boot keyfile on multiple production devices."
DEPENDS gen_secure_bootloader_key gen_bootloader_digest_bin
VERBATIM)
elseif(CONFIG_SECURE_BOOT_V2_ENABLED)
add_custom_command(TARGET bootloader.elf POST_BUILD
COMMAND ${CMAKE_COMMAND} -E echo
"=============================================================================="
COMMAND ${CMAKE_COMMAND} -E echo
"Bootloader built. Secure boot enabled, so bootloader not flashed automatically."
COMMAND ${CMAKE_COMMAND} -E echo
"Secure boot enabled, so bootloader not flashed automatically."
COMMAND ${CMAKE_COMMAND} -E echo
"\t${esptoolpy_write_flash} ${BOOTLOADER_OFFSET} ${CMAKE_BINARY_DIR}/bootloader.bin"
COMMAND ${CMAKE_COMMAND} -E echo
"=============================================================================="
DEPENDS gen_signed_bootloader
VERBATIM)
endif()

View File

@ -1,3 +1,3 @@
# only compile the "micro-ecc/uECC.c" source file
idf_component_register(SRCS "micro-ecc/uECC.c"
INCLUDE_DIRS micro-ecc)
# only compile the "uECC_verify_antifault.c" file which includes the "micro-ecc/uECC.c" source file
idf_component_register(SRCS "uECC_verify_antifault.c"
INCLUDE_DIRS . micro-ecc)

View File

@ -1,8 +1,6 @@
# only compile the micro-ecc/uECC.c source file
# (SRCDIRS is needed so build system can find the source file)
COMPONENT_SRCDIRS := micro-ecc
COMPONENT_OBJS := micro-ecc/uECC.o
# only compile the "uECC_verify_antifault.c" file which includes the "micro-ecc/uECC.c" source file
COMPONENT_SRCDIRS := .
COMPONENT_ADD_INCLUDEDIRS := micro-ecc
COMPONENT_ADD_INCLUDEDIRS := . micro-ecc
COMPONENT_SUBMODULES := micro-ecc

View File

@ -0,0 +1,141 @@
/* Copyright 2014, Kenneth MacKay. Licensed under the BSD 2-clause license.
Modifications Copyright 2020, Espressif Systems (Shanghai) PTE LTD. Licensed under the BSD
2-clause license.
*/
/* uECC_verify() calls a number of static functions form here and
uses other definitions, so we just build that whole source file here and then append
our modified version uECC_verify_antifault(). */
#include "micro-ecc/uECC.c"
/* Version of uECC_verify() which also copies message_hash into verified_hash,
but only if the signature is valid. Does this in an FI resistant way.
*/
int uECC_verify_antifault(const uint8_t *public_key,
const uint8_t *message_hash,
unsigned hash_size,
const uint8_t *signature,
uECC_Curve curve,
uint8_t *verified_hash) {
uECC_word_t u1[uECC_MAX_WORDS], u2[uECC_MAX_WORDS];
uECC_word_t z[uECC_MAX_WORDS];
uECC_word_t sum[uECC_MAX_WORDS * 2];
uECC_word_t rx[uECC_MAX_WORDS];
uECC_word_t ry[uECC_MAX_WORDS];
uECC_word_t tx[uECC_MAX_WORDS];
uECC_word_t ty[uECC_MAX_WORDS];
uECC_word_t tz[uECC_MAX_WORDS];
const uECC_word_t *points[4];
const uECC_word_t *point;
bitcount_t num_bits;
bitcount_t i;
#if uECC_VLI_NATIVE_LITTLE_ENDIAN
uECC_word_t *_public = (uECC_word_t *)public_key;
#else
uECC_word_t _public[uECC_MAX_WORDS * 2];
#endif
uECC_word_t r[uECC_MAX_WORDS], s[uECC_MAX_WORDS];
wordcount_t num_words = curve->num_words;
wordcount_t num_n_words = BITS_TO_WORDS(curve->num_n_bits);
rx[num_n_words - 1] = 0;
r[num_n_words - 1] = 0;
s[num_n_words - 1] = 0;
#if uECC_VLI_NATIVE_LITTLE_ENDIAN
bcopy((uint8_t *) r, signature, curve->num_bytes);
bcopy((uint8_t *) s, signature + curve->num_bytes, curve->num_bytes);
#else
uECC_vli_bytesToNative(_public, public_key, curve->num_bytes);
uECC_vli_bytesToNative(
_public + num_words, public_key + curve->num_bytes, curve->num_bytes);
uECC_vli_bytesToNative(r, signature, curve->num_bytes);
uECC_vli_bytesToNative(s, signature + curve->num_bytes, curve->num_bytes);
#endif
/* r, s must not be 0. */
if (uECC_vli_isZero(r, num_words) || uECC_vli_isZero(s, num_words)) {
return 0;
}
/* r, s must be < n. */
if (uECC_vli_cmp(curve->n, r, num_n_words) != 1 ||
uECC_vli_cmp(curve->n, s, num_n_words) != 1) {
return 0;
}
/* Calculate u1 and u2. */
uECC_vli_modInv(z, s, curve->n, num_n_words); /* z = 1/s */
u1[num_n_words - 1] = 0;
bits2int(u1, message_hash, hash_size, curve);
uECC_vli_modMult(u1, u1, z, curve->n, num_n_words); /* u1 = e/s */
uECC_vli_modMult(u2, r, z, curve->n, num_n_words); /* u2 = r/s */
/* Calculate sum = G + Q. */
uECC_vli_set(sum, _public, num_words);
uECC_vli_set(sum + num_words, _public + num_words, num_words);
uECC_vli_set(tx, curve->G, num_words);
uECC_vli_set(ty, curve->G + num_words, num_words);
uECC_vli_modSub(z, sum, tx, curve->p, num_words); /* z = x2 - x1 */
XYcZ_add(tx, ty, sum, sum + num_words, curve);
uECC_vli_modInv(z, z, curve->p, num_words); /* z = 1/z */
apply_z(sum, sum + num_words, z, curve);
/* Use Shamir's trick to calculate u1*G + u2*Q */
points[0] = 0;
points[1] = curve->G;
points[2] = _public;
points[3] = sum;
num_bits = smax(uECC_vli_numBits(u1, num_n_words),
uECC_vli_numBits(u2, num_n_words));
point = points[(!!uECC_vli_testBit(u1, num_bits - 1)) |
((!!uECC_vli_testBit(u2, num_bits - 1)) << 1)];
uECC_vli_set(rx, point, num_words);
uECC_vli_set(ry, point + num_words, num_words);
uECC_vli_clear(z, num_words);
z[0] = 1;
for (i = num_bits - 2; i >= 0; --i) {
uECC_word_t index;
curve->double_jacobian(rx, ry, z, curve);
index = (!!uECC_vli_testBit(u1, i)) | ((!!uECC_vli_testBit(u2, i)) << 1);
point = points[index];
if (point) {
uECC_vli_set(tx, point, num_words);
uECC_vli_set(ty, point + num_words, num_words);
apply_z(tx, ty, z, curve);
uECC_vli_modSub(tz, rx, tx, curve->p, num_words); /* Z = x2 - x1 */
XYcZ_add(tx, ty, rx, ry, curve);
uECC_vli_modMult_fast(z, z, tz, curve);
}
}
uECC_vli_modInv(z, z, curve->p, num_words); /* Z = 1/Z */
apply_z(rx, ry, z, curve);
/* v = x1 (mod n) */
if (uECC_vli_cmp(curve->n, rx, num_n_words) != 1) {
uECC_vli_sub(rx, rx, curve->n, num_n_words);
}
/* Anti-FI addition. Copy message_hash into verified_hash, but do it in a
way that it will only happen if v == r (ie, rx == r)
*/
const uECC_word_t *mhash_words = (const uECC_word_t *)message_hash;
uECC_word_t *vhash_words = (uECC_word_t *)verified_hash;
unsigned hash_words = hash_size / sizeof(uECC_word_t);
for (int w = 0; w < hash_words; w++) {
/* note: using curve->num_words here to encourage compiler to re-read this variable */
vhash_words[w] = mhash_words[w] ^ rx[w % curve->num_words] ^ r[w % curve->num_words];
}
/* Curve may be longer than hash, in which case keep reading the rest of the bytes */
for (int w = hash_words; w < curve->num_words; w++) {
vhash_words[w % hash_words] |= rx[w] ^ r[w];
}
/* Accept only if v == r. */
return (int)(uECC_vli_equal(rx, r, num_words));
}

View File

@ -0,0 +1,18 @@
/* Copyright 2014, Kenneth MacKay. Licensed under the BSD 2-clause license.
Modifications Copyright 2020, Espressif Systems (Shanghai) PTE LTD. Licensed under the BSD
2-clause license.
*/
#pragma once
#include "uECC.h"
/* Version uECC_verify() that also copies message_hash to verified_hash
if the signature is valid, and does it in a way that is harder to attack
with fault injection.
*/
int uECC_verify_antifault(const uint8_t *public_key,
const uint8_t *message_hash,
unsigned hash_size,
const uint8_t *signature,
uECC_Curve curve,
uint8_t *verified_hash);

View File

@ -17,6 +17,9 @@ ifdef CONFIG_IDF_TARGET_ESP32
ifndef CONFIG_SPI_FLASH_ROM_DRIVER_PATCH
LINKER_SCRIPTS += $(IDF_PATH)/components/esp_rom/$(IDF_TARGET)/ld/$(IDF_TARGET).rom.spiflash.ld
endif
ifdef CONFIG_ESP32_REV_MIN_3
LINKER_SCRIPTS += $(IDF_PATH)/components/esp_rom/$(IDF_TARGET)/ld/$(IDF_TARGET).rom.eco3.ld
endif
endif
COMPONENT_ADD_LDFLAGS += -L $(COMPONENT_PATH) $(addprefix -T ,$(LINKER_SCRIPTS))

View File

@ -44,6 +44,7 @@ SECTIONS
*libbootloader_support.a:bootloader_common.*(.literal .text .literal.* .text.*)
*libbootloader_support.a:bootloader_flash.*(.literal .text .literal.* .text.*)
*libbootloader_support.a:bootloader_random.*(.literal .text .literal.* .text.*)
*libbootloader_support.a:bootloader_efuse_esp32.*(.literal .text .literal.* .text.*)
*libbootloader_support.a:bootloader_utility.*(.literal .text .literal.* .text.*)
*libbootloader_support.a:bootloader_sha.*(.literal .text .literal.* .text.*)
*libbootloader_support.a:esp_image_format.*(.literal .text .literal.* .text.*)
@ -75,6 +76,7 @@ SECTIONS
.dram0.bss (NOLOAD) :
{
. = ALIGN (8);
_dram_start = ABSOLUTE(.);
_bss_start = ABSOLUTE(.);
*(.dynsbss)
*(.sbss)
@ -151,6 +153,7 @@ SECTIONS
*(.gnu.linkonce.lit4.*)
_lit4_end = ABSOLUTE(.);
. = ALIGN(4);
_dram_end = ABSOLUTE(.);
} >dram_seg
.iram.text :

View File

@ -37,6 +37,7 @@ SECTIONS
*libbootloader_support.a:bootloader_common.*(.literal .text .literal.* .text.*)
*libbootloader_support.a:bootloader_flash.*(.literal .text .literal.* .text.*)
*libbootloader_support.a:bootloader_random.*(.literal .text .literal.* .text.*)
*libbootloader_support.a:bootloader_efuse_esp32s2.*(.literal .text .literal.* .text.*)
*libbootloader_support.a:bootloader_utility.*(.literal .text .literal.* .text.*)
*libbootloader_support.a:bootloader_sha.*(.literal .text .literal.* .text.*)
*libbootloader_support.a:esp_image_format.*(.literal .text .literal.* .text.*)
@ -67,6 +68,7 @@ SECTIONS
.dram0.bss (NOLOAD) :
{
. = ALIGN (8);
_dram_start = ABSOLUTE(.);
_bss_start = ABSOLUTE(.);
*(.dynsbss)
*(.sbss)
@ -143,7 +145,7 @@ SECTIONS
*(.gnu.linkonce.lit4.*)
_lit4_end = ABSOLUTE(.);
. = ALIGN(4);
_heap_start = ABSOLUTE(.);
_dram_end = ABSOLUTE(.);
} >dram_seg
.iram.text :

View File

@ -20,22 +20,34 @@ if(BOOTLOADER_BUILD)
set(include_dirs "include" "include_bootloader")
set(priv_requires micro-ecc spi_flash efuse)
list(APPEND srcs
"src/bootloader_init.c"
"src/${IDF_TARGET}/bootloader_sha.c"
"src/${IDF_TARGET}/flash_encrypt.c"
"src/${IDF_TARGET}/secure_boot_signatures.c"
"src/${IDF_TARGET}/secure_boot.c"
"src/${IDF_TARGET}/bootloader_${IDF_TARGET}.c"
)
"src/bootloader_init.c"
"src/${IDF_TARGET}/bootloader_sha.c"
"src/${IDF_TARGET}/flash_encrypt.c"
"src/${IDF_TARGET}/bootloader_${IDF_TARGET}.c"
)
else()
list(APPEND srcs
"src/idf/bootloader_sha.c"
"src/idf/secure_boot_signatures.c")
"src/idf/bootloader_sha.c")
set(include_dirs "include")
set(priv_include_dirs "include_bootloader")
set(priv_requires spi_flash mbedtls efuse)
endif()
if(CONFIG_SECURE_SIGNED_APPS_ECDSA_SCHEME OR CONFIG_SECURE_SIGNED_APPS_RSA_SCHEME)
if(BOOTLOADER_BUILD)
list(APPEND srcs
"src/${IDF_TARGET}/secure_boot_signatures.c")
else()
list(APPEND srcs
"src/idf/secure_boot_signatures.c")
endif()
endif()
if(CONFIG_SECURE_BOOT AND BOOTLOADER_BUILD)
list(APPEND srcs
"src/${IDF_TARGET}/secure_boot.c")
endif()
set(requires soc) #unfortunately the header directly uses SOC registers
idf_component_register(SRCS "${srcs}"
@ -44,7 +56,7 @@ idf_component_register(SRCS "${srcs}"
REQUIRES "${requires}"
PRIV_REQUIRES "${priv_requires}")
if(CONFIG_SECURE_SIGNED_APPS)
if(CONFIG_SECURE_SIGNED_APPS AND (CONFIG_SECURE_BOOT_V1_ENABLED OR CONFIG_SECURE_SIGNED_APPS_ECDSA_SCHEME))
if(BOOTLOADER_BUILD)
# Whether CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES or not, we need verification key to embed
# in the library.

View File

@ -22,11 +22,23 @@ endif
COMPONENT_OBJEXCLUDE += src/bootloader_flash_config_esp32s2beta.o \
src/bootloader_efuse_esp32s2beta.o
ifndef CONFIG_SECURE_SIGNED_APPS_ECDSA_SCHEME
ifndef CONFIG_SECURE_SIGNED_APPS_RSA_SCHEME
COMPONENT_OBJEXCLUDE += src/$(IDF_TARGET)/secure_boot_signatures.o \
src/idf/secure_boot_signatures.o
endif
endif
ifndef CONFIG_SECURE_BOOT
COMPONENT_OBJEXCLUDE += src/$(IDF_TARGET)/secure_boot.o
endif
#
# Secure boot signing key support
#
ifdef CONFIG_SECURE_SIGNED_APPS
ifdef CONFIG_SECURE_SIGNED_APPS_ECDSA_SCHEME
# this path is created relative to the component build directory
SECURE_BOOT_VERIFICATION_KEY := $(abspath signature_verification_key.bin)
@ -41,7 +53,7 @@ ORIG_SECURE_BOOT_VERIFICATION_KEY := $(call resolvepath,$(call dequote,$(CONFIG_
$(ORIG_SECURE_BOOT_VERIFICATION_KEY):
@echo "Secure boot verification public key '$@' missing."
@echo "This can be extracted from the private signing key, see"
@echo "docs/security/secure-boot.rst for details."
@echo "docs/security/secure-boot-v1.rst for details."
exit 1
# copy it into the build dir, so the secure boot verification key has
@ -55,4 +67,5 @@ COMPONENT_EXTRA_CLEAN += $(SECURE_BOOT_VERIFICATION_KEY)
COMPONENT_EMBED_FILES := $(SECURE_BOOT_VERIFICATION_KEY)
endif #CONFIG_SECURE_SIGNED_APPS_ECDSA_SCHEME
endif #CONFIG_SECURE_SIGNED_APPS

View File

@ -27,6 +27,14 @@ extern "C" {
*/
void bootloader_flash_update_id(void);
/**
* @brief Update the flash size in g_rom_flashchip (global esp_rom_spiflash_chip_t structure).
*
* @param size The size to store, in bytes.
* @return None
*/
void bootloader_flash_update_size(uint32_t size);
/**
* @brief Set the flash CS setup and hold time.
*

View File

@ -128,6 +128,10 @@ esp_err_t esp_flash_encrypt_region(uint32_t src_addr, size_t data_length);
* is enabled but secure boot is not used. This should protect against
* serial re-flashing of an unauthorised code in absence of secure boot.
*
* @note On ESP32 V3 only, write protecting FLASH_CRYPT_CNT will also prevent
* disabling UART Download Mode. If both are wanted, call
* esp_efuse_disable_rom_download_mode() before calling this function.
*
*/
void esp_flash_write_protect_crypt_cnt(void);

View File

@ -42,6 +42,9 @@ extern "C" {
#define PART_FLAG_ENCRYPTED (1<<0)
/* The md5sum value is found this many bytes after the ESP_PARTITION_MAGIC_MD5 offset */
#define ESP_PARTITION_MD5_OFFSET 16
/* Pre-partition table fixed flash offsets */
#define ESP_BOOTLOADER_DIGEST_OFFSET 0x0
#define ESP_BOOTLOADER_OFFSET 0x1000 /* Offset of bootloader image. Has matching value in bootloader KConfig.projbuild file. */

View File

@ -169,6 +169,14 @@ esp_err_t esp_image_verify_bootloader(uint32_t *length);
*/
esp_err_t esp_image_verify_bootloader_data(esp_image_metadata_t *data);
/**
* @brief Get the flash size of the image
*
* @param app_flash_size The value configured in the image header
* @return Actual size, in bytes.
*/
int esp_image_get_flash_size(esp_image_flash_size_t app_flash_size);
typedef struct {
uint32_t drom_addr;

View File

@ -16,13 +16,18 @@
#include <stdbool.h>
#include <esp_err.h>
#include "soc/efuse_periph.h"
#include "esp_image_format.h"
#include "sdkconfig.h"
#if CONFIG_IDF_TARGET_ESP32S2BETA
#include "esp32s2beta/rom/efuse.h"
#else
#include "esp32/rom/secure_boot.h"
#endif
#ifdef CONFIG_SECURE_BOOT_ENABLED
typedef struct ets_secure_boot_signature ets_secure_boot_signature_t;
#ifdef CONFIG_SECURE_BOOT_V1_ENABLED
#if !defined(CONFIG_SECURE_SIGNED_ON_BOOT) || !defined(CONFIG_SECURE_SIGNED_ON_UPDATE) || !defined(CONFIG_SECURE_SIGNED_APPS)
#error "internal sdkconfig error, secure boot should always enable all signature options"
#endif
@ -47,16 +52,23 @@ extern "C" {
static inline bool esp_secure_boot_enabled(void)
{
#if CONFIG_IDF_TARGET_ESP32
return REG_READ(EFUSE_BLK0_RDATA6_REG) & EFUSE_RD_ABS_DONE_0;
#ifdef CONFIG_SECURE_BOOT_V1_ENABLED
return REG_READ(EFUSE_BLK0_RDATA6_REG) & EFUSE_RD_ABS_DONE_0;
#elif CONFIG_SECURE_BOOT_V2_ENABLED
return ets_use_secure_boot_v2();
#endif
#elif CONFIG_IDF_TARGET_ESP32S2BETA
return ets_efuse_secure_boot_enabled();
#endif
return false; /* Secure Boot not enabled in menuconfig */
}
/** @brief Generate secure digest from bootloader image
*
* @important This function is intended to be called from bootloader code only.
*
* This function is only used in the context of the Secure Boot V1 scheme.
*
* If secure boot is not yet enabled for bootloader, this will:
* 1) generate the secure boot key and burn it on EFUSE
* (without enabling R/W protection)
@ -73,18 +85,17 @@ static inline bool esp_secure_boot_enabled(void)
*/
esp_err_t esp_secure_boot_generate_digest(void);
/** @brief Enable secure boot if it is not already enabled.
/** @brief Enable secure boot V1 if it is not already enabled.
*
* @important If this function succeeds, secure boot is permanently
* @important If this function succeeds, secure boot V1 is permanently
* enabled on the chip via efuse.
*
* @important This function is intended to be called from bootloader code only.
*
* @important This will enable r/w protection of secure boot key on EFUSE,
* therefore it is to be ensured that esp_secure_boot_generate_digest()
* is called before this
*
* If secure boot is not yet enabled for bootloader, this will
* @important In case of Secure Boot V1, this will enable r/w protection
* of secure boot key on EFUSE, therefore it is to be ensured that
* esp_secure_boot_generate_digest() is called before this .If secure boot is not
* yet enabled for bootloader, this will
* 1) enable R/W protection of secure boot key on EFUSE
* 2) enable secure boot by blowing the EFUSE_RD_ABS_DONE_0 efuse.
*
@ -100,35 +111,97 @@ esp_err_t esp_secure_boot_generate_digest(void);
*/
esp_err_t esp_secure_boot_permanently_enable(void);
/** @brief Verify the secure boot signature (determinstic ECDSA w/ SHA256) appended to some binary data in flash.
/** @brief Enables secure boot V2 if it is not already enabled.
*
* Public key is compiled into the calling program. See docs/security/secure-boot.rst for details.
* @important If this function succeeds, secure boot V2 is permanently
* enabled on the chip via efuse.
*
* @important This function is intended to be called from bootloader code only.
*
* @important In case of Secure Boot V2, this will enable write protection
* of secure boot key on EFUSE in BLK2. .If secure boot is not
* yet enabled for bootloader, this will
* 1) enable W protection of secure boot key on EFUSE
* 2) enable secure boot by blowing the EFUSE_RD_ABS_DONE_1 efuse.
*
* This function does not verify secure boot of the bootloader (the
* ROM bootloader does this.)
*
* @param image_data Image metadata of the application to be loaded.
*
* Will fail if efuses have been part-burned in a way that indicates
* secure boot should not or could not be correctly enabled.
*
* @return ESP_ERR_INVALID_STATE if efuse state doesn't allow
* secure boot to be enabled cleanly. ESP_OK if secure boot
* is enabled on this chip from now on.
*/
esp_err_t esp_secure_boot_v2_permanently_enable(const esp_image_metadata_t *image_data);
/** @brief Verify the secure boot signature appended to some binary data in flash.
*
* For ECDSA Scheme (Secure Boot V1) - deterministic ECDSA w/ SHA256 image
* For RSA Scheme (Secure Boot V2) - RSA-PSS Verification of the SHA-256 image
*
* Public key is compiled into the calling program in the ECDSA Scheme.
* See the apt docs/security/secure-boot-v1.rst or docs/security/secure-boot-v2.rst for details.
*
* @param src_addr Starting offset of the data in flash.
* @param length Length of data in bytes. Signature is appended -after- length bytes.
*
* If flash encryption is enabled, the image will be transparently decrypted while being verified.
*
* @note This function doesn't have any fault injection resistance so should not be called
* during a secure boot itself (but can be called when verifying an update, etc.)
*
* @return ESP_OK if signature is valid, ESP_ERR_INVALID_STATE if
* signature fails, ESP_FAIL for other failures (ie can't read flash).
*/
esp_err_t esp_secure_boot_verify_signature(uint32_t src_addr, uint32_t length);
/** @brief Verify the secure boot signature block (deterministic ECDSA w/ SHA256) based on the SHA256 hash of some data.
*
* Similar to esp_secure_boot_verify_signature(), but can be used when the digest is precalculated.
* @param sig_block Pointer to signature block data
* @param image_digest Pointer to 32 byte buffer holding SHA-256 hash.
*
*/
/** @brief Secure boot verification block, on-flash data format. */
typedef struct {
uint32_t version;
uint8_t signature[64];
} esp_secure_boot_sig_block_t;
esp_err_t esp_secure_boot_verify_signature_block(const esp_secure_boot_sig_block_t *sig_block, const uint8_t *image_digest);
/** @brief Verify the ECDSA secure boot signature block for Secure Boot V1.
*
* Calculates Deterministic ECDSA w/ SHA256 based on the SHA256 hash of the image. ECDSA signature
* verification must be enabled in project configuration to use this function.
*
* Similar to esp_secure_boot_verify_signature(), but can be used when the digest is precalculated.
* @param sig_block Pointer to ECDSA signature block data
* @param image_digest Pointer to 32 byte buffer holding SHA-256 hash.
* @param verified_digest Pointer to 32 byte buffer that will receive verified digest if verification completes. (Used during bootloader implementation only, result is invalid otherwise.)
*
*/
esp_err_t esp_secure_boot_verify_ecdsa_signature_block(const esp_secure_boot_sig_block_t *sig_block, const uint8_t *image_digest, uint8_t *verified_digest);
/** @brief Verify the RSA secure boot signature block for Secure Boot V2.
*
* Performs RSA-PSS Verification of the SHA-256 image based on the public key
* in the signature block, compared against the public key digest stored in efuse.
*
* Similar to esp_secure_boot_verify_signature(), but can be used when the digest is precalculated.
* @param sig_block Pointer to RSA signature block data
* @param image_digest Pointer to 32 byte buffer holding SHA-256 hash.
* @param verified_digest Pointer to 32 byte buffer that will receive verified digest if verification completes. (Used during bootloader implementation only, result is invalid otherwise.)
*
*/
esp_err_t esp_secure_boot_verify_rsa_signature_block(const ets_secure_boot_signature_t *sig_block, const uint8_t *image_digest, uint8_t *verified_digest);
/** @brief Legacy ECDSA verification function
*
* @note Deprecated, call either esp_secure_boot_verify_ecdsa_signature_block() or esp_secure_boot_verify_rsa_signature_block() instead.
*
* @param sig_block Pointer to ECDSA signature block data
* @param image_digest Pointer to 32 byte buffer holding SHA-256 hash.
*/
esp_err_t esp_secure_boot_verify_signature_block(const esp_secure_boot_sig_block_t *sig_block, const uint8_t *image_digest)
__attribute__((deprecated("use esp_secure_boot_verify_ecdsa_signature_block instead")));
#define FLASH_OFFS_SECURE_BOOT_IV_DIGEST 0

View File

@ -18,9 +18,11 @@
#include <stdbool.h>
#include <stdint.h>
#include <esp_err.h>
#include <esp_spi_flash.h> /* including in bootloader for error values */
#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.

View File

@ -108,3 +108,17 @@ esp_err_t bootloader_sha256_hex_to_str(char *out_str, const uint8_t *in_array_he
* @param label Label to print at beginning of log line.
*/
void bootloader_debug_buffer(const void *buffer, size_t length, const char *label);
/** @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

@ -30,6 +30,7 @@
#include "esp_flash_partitions.h"
#include "bootloader_flash.h"
#include "bootloader_common.h"
#include "bootloader_utility.h"
#include "soc/gpio_periph.h"
#include "soc/rtc.h"
#include "soc/efuse_reg.h"
@ -187,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)
@ -248,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

@ -15,7 +15,6 @@
#include <bootloader_flash.h>
#include <esp_log.h>
#include <esp_spi_flash.h> /* including in bootloader for error values */
#include <esp_flash_encrypt.h>
#if CONFIG_IDF_TARGET_ESP32S2BETA
#include "esp32s2beta/rom/spi_flash.h"

View File

@ -32,6 +32,11 @@ void bootloader_flash_update_id(void)
g_rom_flashchip.device_id = bootloader_read_flash_id();
}
void bootloader_flash_update_size(uint32_t size)
{
g_rom_flashchip.chip_size = size;
}
void IRAM_ATTR bootloader_flash_cs_timing_config(void)
{
SET_PERI_REG_MASK(SPI_USER_REG(0), SPI_CS_HOLD_M | SPI_CS_SETUP_M);
@ -62,6 +67,7 @@ void IRAM_ATTR bootloader_flash_clock_config(const esp_image_header_t* pfhdr)
break;
}
esp_rom_spiflash_config_clk(spi_clk_div, 0);
esp_rom_spiflash_config_clk(spi_clk_div, 1);
}
void IRAM_ATTR bootloader_flash_gpio_config(const esp_image_header_t* pfhdr)

View File

@ -14,6 +14,7 @@
#include <string.h>
#include <stdint.h>
#include "sdkconfig.h"
#include "esp_attr.h"
#include "esp_log.h"
#include "bootloader_init.h"
#include "bootloader_flash.h"
@ -30,7 +31,7 @@
static const char *TAG = "boot";
esp_image_header_t bootloader_image_hdr;
esp_image_header_t WORD_ALIGNED_ATTR bootloader_image_hdr;
void bootloader_clear_bss_section(void)
{

View File

@ -555,11 +555,19 @@ static void load_image(const esp_image_metadata_t *image_data)
* then Step 6 enables secure boot.
*/
#if defined(CONFIG_SECURE_BOOT_ENABLED) || defined(CONFIG_SECURE_FLASH_ENC_ENABLED)
#if defined(CONFIG_SECURE_BOOT) || defined(CONFIG_SECURE_FLASH_ENC_ENABLED)
esp_err_t err;
#endif
#ifdef CONFIG_SECURE_BOOT_ENABLED
#ifdef CONFIG_SECURE_BOOT_V2_ENABLED
err = esp_secure_boot_v2_permanently_enable(image_data);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Secure Boot v2 failed (%d)", err);
return;
}
#endif
#ifdef CONFIG_SECURE_BOOT_V1_ENABLED
/* Steps 1 & 2 (see above for full description):
* 1) Generate secure boot EFUSE key
* 2) Compute digest of plaintext bootloader
@ -586,7 +594,7 @@ static void load_image(const esp_image_metadata_t *image_data)
}
#endif
#ifdef CONFIG_SECURE_BOOT_ENABLED
#ifdef CONFIG_SECURE_BOOT_V1_ENABLED
/* Step 6 (see above for full description):
* 6) Burn EFUSE to enable secure boot
*/
@ -816,3 +824,37 @@ void bootloader_debug_buffer(const void *buffer, size_t length, const char *labe
ESP_LOGD(TAG, "%s: %s", label, hexbuf);
#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

@ -73,6 +73,10 @@ esp_err_t esp_flash_encrypt_check_and_update(void)
static esp_err_t initialise_flash_encryption(void)
{
uint32_t new_wdata0 = 0;
uint32_t new_wdata5 = 0;
uint32_t new_wdata6 = 0;
uint32_t coding_scheme = REG_GET_FIELD(EFUSE_BLK0_RDATA6_REG, EFUSE_CODING_SCHEME);
if (coding_scheme != EFUSE_CODING_SCHEME_VAL_NONE && coding_scheme != EFUSE_CODING_SCHEME_VAL_34) {
ESP_LOGE(TAG, "Unknown/unsupported CODING_SCHEME value 0x%x", coding_scheme);
@ -97,11 +101,10 @@ static esp_err_t initialise_flash_encryption(void)
&& REG_READ(EFUSE_BLK1_RDATA7_REG) == 0) {
ESP_LOGI(TAG, "Generating new flash encryption key...");
esp_efuse_write_random_key(EFUSE_BLK1_WDATA0_REG);
esp_efuse_burn_new_values();
// defer efuse programming step to the end
ESP_LOGI(TAG, "Read & write protecting new key...");
REG_WRITE(EFUSE_BLK0_WDATA0_REG, EFUSE_WR_DIS_BLK1 | EFUSE_RD_DIS_BLK1);
esp_efuse_burn_new_values();
new_wdata0 |= EFUSE_WR_DIS_BLK1 | EFUSE_RD_DIS_BLK1;
} else {
if(!(efuse_key_read_protected && efuse_key_write_protected)) {
@ -122,34 +125,36 @@ static esp_err_t initialise_flash_encryption(void)
operation does nothing. Please note this is not recommended!
*/
ESP_LOGI(TAG, "Setting CRYPT_CONFIG efuse to 0xF");
REG_WRITE(EFUSE_BLK0_WDATA5_REG, EFUSE_FLASH_CRYPT_CONFIG_M);
esp_efuse_burn_new_values();
new_wdata5 |= EFUSE_FLASH_CRYPT_CONFIG_M;
uint32_t new_wdata6 = 0;
#ifndef CONFIG_SECURE_FLASH_UART_BOOTLOADER_ALLOW_ENC
ESP_LOGI(TAG, "Disable UART bootloader encryption...");
new_wdata6 |= EFUSE_DISABLE_DL_ENCRYPT;
#else
ESP_LOGW(TAG, "Not disabling UART bootloader encryption");
#endif
#ifndef CONFIG_SECURE_FLASH_UART_BOOTLOADER_ALLOW_DEC
ESP_LOGI(TAG, "Disable UART bootloader decryption...");
new_wdata6 |= EFUSE_DISABLE_DL_DECRYPT;
#else
ESP_LOGW(TAG, "Not disabling UART bootloader decryption - SECURITY COMPROMISED");
#endif
#ifndef CONFIG_SECURE_FLASH_UART_BOOTLOADER_ALLOW_CACHE
ESP_LOGI(TAG, "Disable UART bootloader MMU cache...");
new_wdata6 |= EFUSE_DISABLE_DL_CACHE;
#else
ESP_LOGW(TAG, "Not disabling UART bootloader MMU cache - SECURITY COMPROMISED");
#endif
#ifndef CONFIG_SECURE_BOOT_ALLOW_JTAG
ESP_LOGI(TAG, "Disable JTAG...");
new_wdata6 |= EFUSE_RD_DISABLE_JTAG;
#else
ESP_LOGW(TAG, "Not disabling JTAG - SECURITY COMPROMISED");
#endif
#ifndef CONFIG_SECURE_BOOT_ALLOW_ROM_BASIC
ESP_LOGI(TAG, "Disable ROM BASIC interpreter fallback...");
new_wdata6 |= EFUSE_RD_CONSOLE_DEBUG_DISABLE;
@ -157,10 +162,16 @@ static esp_err_t initialise_flash_encryption(void)
ESP_LOGW(TAG, "Not disabling ROM BASIC fallback - SECURITY COMPROMISED");
#endif
if (new_wdata6 != 0) {
REG_WRITE(EFUSE_BLK0_WDATA6_REG, new_wdata6);
esp_efuse_burn_new_values();
}
#if defined(CONFIG_SECURE_BOOT_V2_ENABLED) && !defined(CONFIG_SECURE_BOOT_V2_ALLOW_EFUSE_RD_DIS)
// This bit is set when enabling Secure Boot V2, but we can't enable it until this later point in the first boot
// otherwise the Flash Encryption key cannot be read protected
new_wdata0 |= EFUSE_WR_DIS_RD_DIS;
#endif
REG_WRITE(EFUSE_BLK0_WDATA0_REG, new_wdata0);
REG_WRITE(EFUSE_BLK0_WDATA5_REG, new_wdata5);
REG_WRITE(EFUSE_BLK0_WDATA6_REG, new_wdata6);
esp_efuse_burn_new_values();
return ESP_OK;
}
@ -210,16 +221,19 @@ static esp_err_t encrypt_flash_contents(uint32_t flash_crypt_cnt, bool flash_cry
ESP_LOGD(TAG, "All flash regions checked for encryption pass");
uint32_t new_flash_crypt_cnt;
#ifdef CONFIG_SECURE_FLASH_ENCRYPTION_MODE_RELEASE
// Go straight to max, permanently enabled
ESP_LOGI(TAG, "Setting FLASH_CRYPT_CNT for permanent encryption");
new_flash_crypt_cnt = EFUSE_FLASH_CRYPT_CNT;
#else
/* Set least significant 0-bit in flash_crypt_cnt */
int ffs_inv = __builtin_ffs((~flash_crypt_cnt) & EFUSE_RD_FLASH_CRYPT_CNT);
/* ffs_inv shouldn't be zero, as zero implies flash_crypt_cnt == EFUSE_RD_FLASH_CRYPT_CNT (0x7F) */
uint32_t new_flash_crypt_cnt = flash_crypt_cnt + (1 << (ffs_inv - 1));
new_flash_crypt_cnt = flash_crypt_cnt + (1 << (ffs_inv - 1));
#endif
ESP_LOGD(TAG, "FLASH_CRYPT_CNT 0x%x -> 0x%x", flash_crypt_cnt, new_flash_crypt_cnt);
uint32_t wdata0_reg = ((new_flash_crypt_cnt & EFUSE_FLASH_CRYPT_CNT) << EFUSE_FLASH_CRYPT_CNT_S);
#ifdef CONFIG_SECURE_FLASH_ENCRYPTION_MODE_RELEASE
ESP_LOGI(TAG, "Write protecting FLASH_CRYPT_CNT eFuse");
wdata0_reg |= EFUSE_WR_DIS_FLASH_CRYPT_CNT;
#endif
REG_WRITE(EFUSE_BLK0_WDATA0_REG, wdata0_reg);
esp_efuse_burn_new_values();
@ -236,13 +250,22 @@ static esp_err_t encrypt_bootloader(void)
/* Check for plaintext bootloader (verification will fail if it's already encrypted) */
if (esp_image_verify_bootloader(&image_length) == ESP_OK) {
ESP_LOGD(TAG, "bootloader is plaintext. Encrypting...");
#if CONFIG_SECURE_BOOT_V2_ENABLED
/* The image length obtained from esp_image_verify_bootloader includes the sector boundary padding and the signature block lengths */
if (ESP_BOOTLOADER_OFFSET + image_length > ESP_PARTITION_TABLE_OFFSET) {
ESP_LOGE(TAG, "Bootloader is too large to fit Secure Boot V2 signature sector and partition table (configured offset 0x%x)", ESP_PARTITION_TABLE_OFFSET);
return ESP_ERR_INVALID_STATE;
}
#endif // CONFIG_SECURE_BOOT_V2_ENABLED
err = esp_flash_encrypt_region(ESP_BOOTLOADER_OFFSET, image_length);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Failed to encrypt bootloader in place: 0x%x", err);
return err;
}
#ifdef CONFIG_SECURE_BOOT_ENABLED
#ifdef CONFIG_SECURE_BOOT_V1_ENABLED
/* If secure boot is enabled and bootloader was plaintext, also
* need to encrypt secure boot IV+digest.
*/
@ -355,4 +378,4 @@ esp_err_t esp_flash_encrypt_region(uint32_t src_addr, size_t data_length)
flash_failed:
ESP_LOGE(TAG, "flash operation failed: 0x%x", err);
return err;
}
}

View File

@ -20,10 +20,12 @@
#include "esp32/rom/cache.h"
#include "esp32/rom/ets_sys.h"
#include "esp32/rom/secure_boot.h"
#include "esp32/rom/crc.h"
#include "soc/efuse_periph.h"
#include "soc/rtc_periph.h"
#include "bootloader_sha.h"
#include "bootloader_utility.h"
#include "sdkconfig.h"
@ -38,8 +40,8 @@
* from the bootloader code.
*/
static const char* TAG = "secure_boot";
#ifdef CONFIG_SECURE_BOOT_V1_ENABLED
static const char *TAG = "secure_boot_v1";
/**
* @function : secure_boot_generate
* @description: generate boot digest (aka "abstract") & iv
@ -94,12 +96,6 @@ static bool secure_boot_generate(uint32_t image_len){
return true;
}
/* Burn values written to the efuse write registers */
static inline void burn_efuses(void)
{
esp_efuse_burn_new_values();
}
esp_err_t esp_secure_boot_generate_digest(void)
{
esp_err_t err;
@ -139,7 +135,7 @@ esp_err_t esp_secure_boot_generate_digest(void)
&& REG_READ(EFUSE_BLK2_RDATA7_REG) == 0) {
ESP_LOGI(TAG, "Generating new secure boot key...");
esp_efuse_write_random_key(EFUSE_BLK2_WDATA0_REG);
burn_efuses();
esp_efuse_burn_new_values();
} else {
ESP_LOGW(TAG, "Using pre-loaded secure boot key in EFUSE block 2");
}
@ -162,6 +158,9 @@ esp_err_t esp_secure_boot_generate_digest(void)
esp_err_t esp_secure_boot_permanently_enable(void)
{
uint32_t new_wdata0 = 0;
uint32_t new_wdata6 = 0;
if (esp_secure_boot_enabled()) {
ESP_LOGI(TAG, "bootloader secure boot is already enabled, continuing..");
return ESP_OK;
@ -173,8 +172,7 @@ esp_err_t esp_secure_boot_permanently_enable(void)
if (efuse_key_read_protected == false
&& efuse_key_write_protected == false) {
ESP_LOGI(TAG, "Read & write protecting new key...");
REG_WRITE(EFUSE_BLK0_WDATA0_REG, EFUSE_WR_DIS_BLK2 | EFUSE_RD_DIS_BLK2);
burn_efuses();
new_wdata0 = EFUSE_WR_DIS_BLK2 | EFUSE_RD_DIS_BLK2;
efuse_key_read_protected = true;
efuse_key_write_protected = true;
}
@ -191,7 +189,7 @@ esp_err_t esp_secure_boot_permanently_enable(void)
ESP_LOGI(TAG, "blowing secure boot efuse...");
ESP_LOGD(TAG, "before updating, EFUSE_BLK0_RDATA6 %x", REG_READ(EFUSE_BLK0_RDATA6_REG));
uint32_t new_wdata6 = EFUSE_RD_ABS_DONE_0;
new_wdata6 |= EFUSE_RD_ABS_DONE_0;
#ifndef CONFIG_SECURE_BOOT_ALLOW_JTAG
ESP_LOGI(TAG, "Disable JTAG...");
@ -207,8 +205,9 @@ esp_err_t esp_secure_boot_permanently_enable(void)
ESP_LOGW(TAG, "Not disabling ROM BASIC fallback - SECURITY COMPROMISED");
#endif
REG_WRITE(EFUSE_BLK0_WDATA0_REG, new_wdata0);
REG_WRITE(EFUSE_BLK0_WDATA6_REG, new_wdata6);
burn_efuses();
esp_efuse_burn_new_values();
uint32_t after = REG_READ(EFUSE_BLK0_RDATA6_REG);
ESP_LOGD(TAG, "after updating, EFUSE_BLK0_RDATA6 %x", after);
if (after & EFUSE_RD_ABS_DONE_0) {
@ -219,3 +218,228 @@ esp_err_t esp_secure_boot_permanently_enable(void)
return ESP_ERR_INVALID_STATE;
}
}
#elif CONFIG_SECURE_BOOT_V2_ENABLED
#define ALIGN_UP(num, align) (((num) + ((align) - 1)) & ~((align) - 1))
static const char *TAG = "secure_boot_v2";
#define SIG_BLOCK_MAGIC_BYTE 0xe7
#define CRC_SIGN_BLOCK_LEN 1196
#define SIG_BLOCK_PADDING 4096
#define DIGEST_LEN 32
static esp_err_t validate_signature_block(const ets_secure_boot_signature_t *sig_block, uint8_t *digest)
{
uint32_t crc = crc32_le(0, (uint8_t *)sig_block, CRC_SIGN_BLOCK_LEN);
if (sig_block->block[0].magic_byte == SIG_BLOCK_MAGIC_BYTE && sig_block->block[0].block_crc == crc && !memcmp(digest, sig_block->block[0].image_digest, DIGEST_LEN)) {
ESP_LOGI(TAG, "valid signature block found");
return ESP_OK;
}
return ESP_FAIL;
}
static esp_err_t secure_boot_v2_digest_generate(uint32_t flash_offset, uint32_t flash_size, uint8_t *public_key_digest)
{
esp_err_t ret = ESP_FAIL;
uint8_t image_digest[DIGEST_LEN] = {0};
size_t sig_block_addr = flash_offset + ALIGN_UP(flash_size, FLASH_SECTOR_SIZE);
ret = bootloader_sha256_flash_contents(flash_offset, sig_block_addr - flash_offset, image_digest);
if (ret != ESP_OK) {
ESP_LOGE(TAG, "error generating image digest, %d", ret);
return ret;
}
ESP_LOGD(TAG, "reading signature block");
const ets_secure_boot_signature_t *sig_block = bootloader_mmap(sig_block_addr, sizeof(ets_secure_boot_signature_t));
if (sig_block == NULL) {
ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", sig_block_addr, sizeof(ets_secure_boot_signature_t));
return ret;
}
/* Validating Signature block */
ret = validate_signature_block(sig_block, image_digest);
if (ret != ESP_OK) {
ESP_LOGE(TAG, "signature block (address 0x%x) validation failed %d", sig_block_addr, ret);
goto done;
}
/* Verifying Signature block */
uint8_t verified_digest[DIGEST_LEN] = {0};
/* Generating the SHA of the public key components in the signature block */
bootloader_sha256_handle_t sig_block_sha;
sig_block_sha = bootloader_sha256_start();
bootloader_sha256_data(sig_block_sha, &sig_block->block[0].key, sizeof(sig_block->block[0].key));
bootloader_sha256_finish(sig_block_sha, public_key_digest);
secure_boot_v2_status_t error;
error = ets_secure_boot_verify_signature(sig_block, image_digest, public_key_digest, verified_digest);
if (error != SBV2_SUCCESS) {
ESP_LOGE(TAG, "secure boot v2 verification failed %d", error);
ret = ESP_FAIL;
goto done;
} else {
ret = ESP_OK;
}
done:
bootloader_munmap(sig_block);
return ret;
}
esp_err_t esp_secure_boot_v2_permanently_enable(const esp_image_metadata_t *image_data)
{
uint32_t new_wdata0 = 0;
uint32_t new_wdata6 = 0;
ESP_LOGI(TAG, "enabling secure boot v2...");
esp_err_t ret;
if (esp_secure_boot_enabled()) {
ESP_LOGI(TAG, "secure boot v2 is already enabled. Continuing..");
return ESP_OK;
}
uint32_t coding_scheme = REG_GET_FIELD(EFUSE_BLK0_RDATA6_REG, EFUSE_CODING_SCHEME);
if (coding_scheme != EFUSE_CODING_SCHEME_VAL_NONE) {
ESP_LOGE(TAG, "No coding schemes are supported in secure boot v2.(Detected scheme: 0x%x)", coding_scheme);
return ESP_ERR_NOT_SUPPORTED;
}
/* Verify the bootloader */
esp_image_metadata_t bootloader_data = { 0 };
ret = esp_image_verify_bootloader_data(&bootloader_data);
if (ret != ESP_OK) {
ESP_LOGE(TAG, "bootloader image appears invalid! error %d", ret);
return ret;
}
uint8_t boot_pub_key_digest[DIGEST_LEN];
uint32_t dis_reg = REG_READ(EFUSE_BLK0_RDATA0_REG);
bool efuse_key_read_protected = dis_reg & EFUSE_RD_DIS_BLK2;
bool efuse_key_write_protected = dis_reg & EFUSE_WR_DIS_BLK2;
uint32_t efuse_blk2_r0, efuse_blk2_r1, efuse_blk2_r2, efuse_blk2_r3, efuse_blk2_r4, efuse_blk2_r5, efuse_blk2_r6, efuse_blk2_r7;
efuse_blk2_r0 = REG_READ(EFUSE_BLK2_RDATA0_REG);
efuse_blk2_r1 = REG_READ(EFUSE_BLK2_RDATA1_REG);
efuse_blk2_r2 = REG_READ(EFUSE_BLK2_RDATA2_REG);
efuse_blk2_r3 = REG_READ(EFUSE_BLK2_RDATA3_REG);
efuse_blk2_r4 = REG_READ(EFUSE_BLK2_RDATA4_REG);
efuse_blk2_r5 = REG_READ(EFUSE_BLK2_RDATA5_REG);
efuse_blk2_r6 = REG_READ(EFUSE_BLK2_RDATA6_REG);
efuse_blk2_r7 = REG_READ(EFUSE_BLK2_RDATA7_REG);
if (efuse_key_read_protected == true) {
ESP_LOGE(TAG, "Secure Boot v2 digest(BLK2) read protected, aborting....");
return ESP_FAIL;
}
if (efuse_key_write_protected == false
&& efuse_blk2_r0 == 0 && efuse_blk2_r1 == 0
&& efuse_blk2_r2 == 0 && efuse_blk2_r3 == 0
&& efuse_blk2_r4 == 0 && efuse_blk2_r5 == 0
&& efuse_blk2_r6 == 0 && efuse_blk2_r7 == 0) {
/* Verifies the signature block appended to the image matches with the signature block of the app to be loaded */
ret = secure_boot_v2_digest_generate(bootloader_data.start_addr, bootloader_data.image_len - SIG_BLOCK_PADDING, boot_pub_key_digest);
if (ret != ESP_OK) {
ESP_LOGE(TAG, "Public key digest generation failed");
return ret;
}
ESP_LOGI(TAG, "Burning public key hash to efuse.");
uint32_t *boot_public_key_digest_ptr = (uint32_t *) boot_pub_key_digest;
for (int i = 0; i < 8 ; i++) {
REG_WRITE(EFUSE_BLK2_WDATA0_REG + 4 * i, boot_public_key_digest_ptr[i]);
ESP_LOGD(TAG, "EFUSE_BLKx_WDATA%d_REG = 0x%08x", i, boot_public_key_digest_ptr[i]);
}
// delay burning until second half of this function
} else {
uint32_t efuse_blk2_digest[8];
efuse_blk2_digest[0] = efuse_blk2_r0;
efuse_blk2_digest[1] = efuse_blk2_r1;
efuse_blk2_digest[2] = efuse_blk2_r2;
efuse_blk2_digest[3] = efuse_blk2_r3;
efuse_blk2_digest[4] = efuse_blk2_r4;
efuse_blk2_digest[5] = efuse_blk2_r5;
efuse_blk2_digest[6] = efuse_blk2_r6;
efuse_blk2_digest[7] = efuse_blk2_r7;
memcpy(boot_pub_key_digest, efuse_blk2_digest, DIGEST_LEN);
ESP_LOGW(TAG, "Using pre-loaded secure boot v2 public key digest in EFUSE block 2");
}
// This case is needed either if a pre-burned digest is present but not write-protected,
// or if we are burning the digest now
if (efuse_key_write_protected == false) {
ESP_LOGI(TAG, "Write protecting public key digest...");
new_wdata0 |= EFUSE_WR_DIS_BLK2; // delay burning until second half of this function
}
uint8_t app_pub_key_digest[DIGEST_LEN];
ret = secure_boot_v2_digest_generate(image_data->start_addr, image_data->image_len - SIG_BLOCK_PADDING, app_pub_key_digest);
if (ret != ESP_OK) {
ESP_LOGE(TAG, "Application signature block is invalid.");
return ret;
}
/* Confirming if the public key in the bootloader's signature block matches with the one in the application's signature block */
if (memcmp(boot_pub_key_digest, app_pub_key_digest, DIGEST_LEN) != 0) {
ESP_LOGE(TAG, "Application not signed with a valid private key.");
return ESP_FAIL;
}
if (efuse_key_read_protected) {
ESP_LOGE(TAG, "Efuse BLK2 (public key digest) is read protected. Refusing to blow secure boot efuse.");
return ESP_ERR_INVALID_STATE;
}
ESP_LOGI(TAG, "blowing secure boot efuse...");
ESP_LOGD(TAG, "before updating, EFUSE_BLK0_RDATA6 %x", REG_READ(EFUSE_BLK0_RDATA6_REG));
new_wdata6 |= EFUSE_RD_ABS_DONE_1;
#ifndef CONFIG_SECURE_BOOT_ALLOW_JTAG
ESP_LOGI(TAG, "Disable JTAG...");
new_wdata6 |= EFUSE_RD_DISABLE_JTAG;
#else
ESP_LOGW(TAG, "Not disabling JTAG - SECURITY COMPROMISED");
#endif
#ifndef CONFIG_SECURE_BOOT_ALLOW_ROM_BASIC
ESP_LOGI(TAG, "Disable ROM BASIC interpreter fallback...");
new_wdata6 |= EFUSE_RD_CONSOLE_DEBUG_DISABLE;
#else
ESP_LOGW(TAG, "Not disabling ROM BASIC fallback - SECURITY COMPROMISED");
#endif
#ifndef CONFIG_SECURE_BOOT_V2_ALLOW_EFUSE_RD_DIS
bool rd_dis_now = true;
#ifdef CONFIG_SECURE_FLASH_ENC_ENABLED
/* If flash encryption is not enabled yet then don't read-disable efuses yet, do it later in the boot
when Flash Encryption is being enabled */
rd_dis_now = esp_flash_encryption_enabled();
#endif
if (rd_dis_now) {
ESP_LOGI(TAG, "Prevent read disabling of additional efuses...");
new_wdata0 |= EFUSE_WR_DIS_RD_DIS;
}
#else
ESP_LOGW(TAG, "Allowing read disabling of additional efuses - SECURITY COMPROMISED");
#endif
REG_WRITE(EFUSE_BLK0_WDATA0_REG, new_wdata0);
REG_WRITE(EFUSE_BLK0_WDATA6_REG, new_wdata6);
esp_efuse_burn_new_values();
uint32_t after = REG_READ(EFUSE_BLK0_RDATA6_REG);
ESP_LOGD(TAG, "after updating, EFUSE_BLK0_RDATA0 0x%08x EFUSE_BLK0_RDATA6 0x%08x",
REG_READ(EFUSE_BLK0_RDATA0_REG), after);
if (after & EFUSE_RD_ABS_DONE_1) {
ESP_LOGI(TAG, "secure boot v2 is now enabled.");
return ESP_OK;
} else {
ESP_LOGE(TAG, " secure boot v2 not enabled, EFUSE_RD_ABS_DONE_1 is probably write protected!");
return ESP_ERR_INVALID_STATE;
}
}
#endif // CONFIG_SECURE_BOOT_V2_ENABLED

View File

@ -15,62 +15,40 @@
#include "bootloader_flash.h"
#include "bootloader_sha.h"
#include "bootloader_utility.h"
#include "esp_log.h"
#include "esp_image_format.h"
#include "esp_secure_boot.h"
#include "esp_spi_flash.h"
#include "esp_fault.h"
#include "esp32/rom/sha.h"
#include "uECC.h"
#include "uECC_verify_antifault.h"
#include <sys/param.h>
#include <string.h>
static const char *TAG = "secure_boot";
#define DIGEST_LEN 32
#ifdef CONFIG_SECURE_SIGNED_APPS_ECDSA_SCHEME
extern const uint8_t signature_verification_key_start[] asm("_binary_signature_verification_key_bin_start");
extern const uint8_t signature_verification_key_end[] asm("_binary_signature_verification_key_bin_end");
#define SIGNATURE_VERIFICATION_KEYLEN 64
#define DIGEST_LEN 32
/* Mmap source address mask */
#define MMAP_ALIGNED_MASK 0x0000FFFF
esp_err_t esp_secure_boot_verify_signature(uint32_t src_addr, uint32_t length)
{
uint8_t digest[DIGEST_LEN];
const uint8_t *data;
uint8_t verified_digest[DIGEST_LEN] = { 0 }; /* ignored in this function */
const esp_secure_boot_sig_block_t *sigblock;
ESP_LOGD(TAG, "verifying signature src_addr 0x%x length 0x%x", src_addr, length);
bootloader_sha256_handle_t handle = bootloader_sha256_start();
uint32_t free_page_count = bootloader_mmap_get_free_pages();
ESP_LOGD(TAG, "free data page_count 0x%08x", free_page_count);
int32_t data_len_remain = length;
uint32_t data_addr = src_addr;
while (data_len_remain > 0) {
uint32_t offset_page = ((data_addr & MMAP_ALIGNED_MASK) != 0) ? 1 : 0;
/* Data we could map in case we are not aligned to PAGE boundary is one page size lesser. */
uint32_t data_len = MIN(data_len_remain, ((free_page_count - offset_page) * SPI_FLASH_MMU_PAGE_SIZE));
data = (const uint8_t *) bootloader_mmap(data_addr, data_len);
if(!data) {
ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", data_addr, data_len);
bootloader_sha256_finish(handle, NULL);
return ESP_FAIL;
}
bootloader_sha256_data(handle, data, data_len);
bootloader_munmap(data);
data_addr += data_len;
data_len_remain -= data_len;
esp_err_t err = bootloader_sha256_flash_contents(src_addr, length, digest);
if (err != ESP_OK) {
return err;
}
/* Done! Get the digest */
bootloader_sha256_finish(handle, digest);
// Map the signature block
sigblock = (const esp_secure_boot_sig_block_t *) bootloader_mmap(src_addr + length, sizeof(esp_secure_boot_sig_block_t));
if(!sigblock) {
@ -78,7 +56,7 @@ esp_err_t esp_secure_boot_verify_signature(uint32_t src_addr, uint32_t length)
return ESP_FAIL;
}
// Verify the signature
esp_err_t err = esp_secure_boot_verify_signature_block(sigblock, digest);
err = esp_secure_boot_verify_ecdsa_signature_block(sigblock, digest, verified_digest);
// Unmap
bootloader_munmap(sigblock);
@ -86,6 +64,12 @@ esp_err_t esp_secure_boot_verify_signature(uint32_t src_addr, uint32_t length)
}
esp_err_t esp_secure_boot_verify_signature_block(const esp_secure_boot_sig_block_t *sig_block, const uint8_t *image_digest)
{
uint8_t verified_digest[DIGEST_LEN] = { 0 };
return esp_secure_boot_verify_ecdsa_signature_block(sig_block, image_digest, verified_digest);
}
esp_err_t esp_secure_boot_verify_ecdsa_signature_block(const esp_secure_boot_sig_block_t *sig_block, const uint8_t *image_digest, uint8_t *verified_digest)
{
ptrdiff_t keylen;
@ -103,11 +87,98 @@ esp_err_t esp_secure_boot_verify_signature_block(const esp_secure_boot_sig_block
ESP_LOGD(TAG, "Verifying secure boot signature");
bool is_valid;
is_valid = uECC_verify(signature_verification_key_start,
is_valid = uECC_verify_antifault(signature_verification_key_start,
image_digest,
DIGEST_LEN,
sig_block->signature,
uECC_secp256r1());
uECC_secp256r1(),
verified_digest);
ESP_LOGD(TAG, "Verification result %d", is_valid);
return is_valid ? ESP_OK : ESP_ERR_IMAGE_INVALID;
}
#elif CONFIG_SECURE_SIGNED_APPS_RSA_SCHEME
#define ALIGN_UP(num, align) (((num) + ((align) - 1)) & ~((align) - 1))
esp_err_t esp_secure_boot_verify_signature(uint32_t src_addr, uint32_t length)
{
uint8_t digest[DIGEST_LEN] = {0};
uint8_t verified_digest[DIGEST_LEN] = {0}; // ignored in this function
const uint8_t *data;
/* Padding to round off the input to the nearest 4k boundary */
int padded_length = ALIGN_UP(length, FLASH_SECTOR_SIZE);
ESP_LOGD(TAG, "verifying src_addr 0x%x length", src_addr, padded_length);
data = bootloader_mmap(src_addr, padded_length + sizeof(ets_secure_boot_signature_t));
if (data == NULL) {
ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", src_addr, padded_length);
return ESP_FAIL;
}
/* Calculate digest of main image */
esp_err_t err = bootloader_sha256_flash_contents(src_addr, padded_length, digest);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Digest calculation failed 0x%x, 0x%x", src_addr, padded_length);
bootloader_munmap(data);
return err;
}
const ets_secure_boot_signature_t *sig_block = (const ets_secure_boot_signature_t *)(data + padded_length);
err = esp_secure_boot_verify_rsa_signature_block(sig_block, digest, verified_digest);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Secure Boot V2 verification failed.");
}
bootloader_munmap(data);
return err;
}
esp_err_t esp_secure_boot_verify_rsa_signature_block(const ets_secure_boot_signature_t *sig_block, const uint8_t *image_digest, uint8_t *verified_digest)
{
secure_boot_v2_status_t r;
uint8_t efuse_trusted_digest[DIGEST_LEN] = {0}, sig_block_trusted_digest[DIGEST_LEN] = {0};
memcpy(efuse_trusted_digest, (uint8_t *)EFUSE_BLK2_RDATA0_REG, DIGEST_LEN); /* EFUSE_BLK2_RDATA0_REG - Stores the Secure Boot Public Key Digest */
if (!ets_use_secure_boot_v2()) {
ESP_LOGI(TAG, "Secure Boot eFuse bit(ABS_DONE_1) not yet programmed.");
/* Generating the SHA of the public key components in the signature block */
bootloader_sha256_handle_t sig_block_sha;
sig_block_sha = bootloader_sha256_start();
bootloader_sha256_data(sig_block_sha, &sig_block->block[0].key, sizeof(sig_block->block[0].key));
bootloader_sha256_finish(sig_block_sha, (unsigned char *)sig_block_trusted_digest);
#if CONFIG_SECURE_BOOT_V2_ENABLED
if (memcmp(efuse_trusted_digest, sig_block_trusted_digest, DIGEST_LEN) != 0) {
/* Most likely explanation for this is that BLK2 is empty, and we're going to burn it
after we verify that the signature is valid. However, if BLK2 is not empty then we need to
fail here.
*/
bool all_zeroes = true;
for (int i = 0; i < DIGEST_LEN; i++) {
all_zeroes = all_zeroes && (efuse_trusted_digest[i] == 0);
}
if (!all_zeroes) {
ESP_LOGE(TAG, "Different public key digest burned to eFuse BLK2");
return ESP_ERR_INVALID_STATE;
}
}
ESP_FAULT_ASSERT(!ets_use_secure_boot_v2());
#endif
memcpy(efuse_trusted_digest, sig_block_trusted_digest, DIGEST_LEN);
}
ESP_LOGI(TAG, "Verifying with RSA-PSS...");
r = ets_secure_boot_verify_signature(sig_block, image_digest, efuse_trusted_digest, verified_digest);
if (r != SBV2_SUCCESS) {
ESP_LOGE(TAG, "Secure Boot V2 verification failed.");
}
return (r == SBV2_SUCCESS) ? ESP_OK : ESP_ERR_IMAGE_INVALID;
}
#endif

View File

@ -191,6 +191,15 @@ static esp_err_t encrypt_bootloader(void)
/* Check for plaintext bootloader (verification will fail if it's already encrypted) */
if (esp_image_verify_bootloader(&image_length) == ESP_OK) {
ESP_LOGD(TAG, "bootloader is plaintext. Encrypting...");
#if CONFIG_SECURE_BOOT_V2_ENABLED
/* The image length obtained from esp_image_verify_bootloader includes the sector boundary padding and the signature block lengths */
if (ESP_BOOTLOADER_OFFSET + image_length > ESP_PARTITION_TABLE_OFFSET) {
ESP_LOGE(TAG, "Bootloader is too large to fit Secure Boot V2 signature sector and partition table (configured offset 0x%x)", ESP_PARTITION_TABLE_OFFSET);
return ESP_ERR_INVALID_SIZE;
}
#endif // CONFIG_SECURE_BOOT_V2_ENABLED
err = esp_flash_encrypt_region(ESP_BOOTLOADER_OFFSET, image_length);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Failed to encrypt bootloader in place: 0x%x", err);

View File

@ -15,7 +15,7 @@
#include "esp_log.h"
#include "esp32s2beta/rom/secure_boot.h"
#define TAG "secure_boot"
static const char *TAG = "secure_boot";
esp_err_t esp_secure_boot_permanently_enable(void)
{

View File

@ -27,6 +27,7 @@ esp_err_t esp_secure_boot_verify_signature(uint32_t src_addr, uint32_t length)
{
ets_secure_boot_key_digests_t trusted_keys = { 0 };
uint8_t digest[DIGEST_LEN];
uint8_t verified_digest[DIGEST_LEN] = { 0 }; /* Note: this function doesn't do any anti-FI checks on this buffer */
const uint8_t *data;
ESP_LOGD(TAG, "verifying signature src_addr 0x%x length 0x%x", src_addr, length);
@ -37,7 +38,7 @@ esp_err_t esp_secure_boot_verify_signature(uint32_t src_addr, uint32_t length)
}
data = bootloader_mmap(src_addr, length + sizeof(struct ets_secure_boot_sig_block));
if(data == NULL) {
if (data == NULL) {
ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", src_addr, length+sizeof(ets_secure_boot_signature_t));
return ESP_FAIL;
}
@ -57,36 +58,25 @@ esp_err_t esp_secure_boot_verify_signature(uint32_t src_addr, uint32_t length)
if (r == ETS_OK) {
const ets_secure_boot_signature_t *sig = (const ets_secure_boot_signature_t *)(data + length);
// TODO: calling this function in IDF app context is unsafe
r = ets_secure_boot_verify_signature(sig, digest, &trusted_keys);
r = ets_secure_boot_verify_signature(sig, digest, &trusted_keys, verified_digest);
}
bootloader_munmap(data);
return (r == ETS_OK) ? ESP_OK : ESP_FAIL;
}
esp_err_t esp_secure_boot_verify_signature_block(uint32_t sig_block_flash_offs, const uint8_t *image_digest)
esp_err_t esp_secure_boot_verify_rsa_signature_block(const ets_secure_boot_signature_t *sig_block, const uint8_t *image_digest, uint8_t *verified_digest)
{
ets_secure_boot_key_digests_t trusted_keys;
assert(sig_block_flash_offs % 4096 == 0); // TODO: enforce this in a better way
const ets_secure_boot_signature_t *sig = bootloader_mmap(sig_block_flash_offs, sizeof(ets_secure_boot_signature_t));
if (sig == NULL) {
ESP_LOGE(TAG, "Failed to mmap data at offset 0x%x", sig_block_flash_offs);
return ESP_FAIL;
}
int r = ets_secure_boot_read_key_digests(&trusted_keys);
if (r != 0) {
ESP_LOGE(TAG, "No trusted key digests were found in efuse!");
} else {
ESP_LOGD(TAG, "Verifying with RSA-PSS...");
// TODO: calling this function in IDF app context is unsafe
r = ets_secure_boot_verify_signature(sig, image_digest, &trusted_keys);
r = ets_secure_boot_verify_signature(sig_block, image_digest, &trusted_keys, verified_digest);
}
bootloader_munmap(sig);
return (r == 0) ? ESP_OK : ESP_ERR_IMAGE_INVALID;
}

View File

@ -16,13 +16,16 @@
#include <soc/cpu.h>
#include <bootloader_utility.h>
#include <esp_secure_boot.h>
#include <esp_fault.h>
#include <esp_log.h>
#include <esp_attr.h>
#include <esp_spi_flash.h>
#include <bootloader_flash.h>
#include <bootloader_random.h>
#include <bootloader_sha.h>
#include "bootloader_util.h"
#include "bootloader_common.h"
#include "soc/soc_memory_layout.h"
#if CONFIG_IDF_TARGET_ESP32
#include <esp32/rom/rtc.h>
#include <esp32/rom/secure_boot.h>
@ -37,11 +40,11 @@
*/
#ifdef BOOTLOADER_BUILD
#ifdef CONFIG_SECURE_SIGNED_ON_BOOT
#define SECURE_BOOT_CHECK_SIGNATURE
#define SECURE_BOOT_CHECK_SIGNATURE 1
#endif
#else /* !BOOTLOADER_BUILD */
#ifdef CONFIG_SECURE_SIGNED_ON_UPDATE
#define SECURE_BOOT_CHECK_SIGNATURE
#define SECURE_BOOT_CHECK_SIGNATURE 1
#endif
#endif
@ -55,18 +58,12 @@ static const char *TAG = "esp_image";
/* Headroom to ensure between stack SP (at time of checking) and data loaded from flash */
#define STACK_LOAD_HEADROOM 32768
/* Mmap source address mask */
#define MMAP_ALIGNED_MASK 0x0000FFFF
#ifdef BOOTLOADER_BUILD
/* 64 bits of random data to obfuscate loaded RAM with, until verification is complete
(Means loaded code isn't executable until after the secure boot check.)
*/
static uint32_t ram_obfs_value[2];
/* Range of IRAM used by the loader, defined in ld script */
extern int _loader_text_start;
extern int _loader_text_end;
#endif
/* Return true if load_addr is an address the bootloader should load into */
@ -97,7 +94,7 @@ static esp_err_t verify_segment_header(int index, const esp_image_segment_header
static esp_err_t verify_checksum(bootloader_sha256_handle_t sha_handle, uint32_t checksum_word, esp_image_metadata_t *data);
static esp_err_t __attribute__((unused)) verify_secure_boot_signature(bootloader_sha256_handle_t sha_handle, esp_image_metadata_t *data);
static esp_err_t __attribute__((unused)) verify_secure_boot_signature(bootloader_sha256_handle_t sha_handle, esp_image_metadata_t *data, uint8_t *image_digest, uint8_t *verified_digest);
static esp_err_t __attribute__((unused)) verify_simple_hash(bootloader_sha256_handle_t sha_handle, esp_image_metadata_t *data);
static esp_err_t image_load(esp_image_load_mode_t mode, const esp_partition_pos_t *part, esp_image_metadata_t *data)
@ -115,6 +112,11 @@ static esp_err_t image_load(esp_image_load_mode_t mode, const esp_partition_pos_
uint32_t checksum_word = ESP_ROM_CHECKSUM_INITIAL;
uint32_t *checksum = NULL;
bootloader_sha256_handle_t sha_handle = NULL;
#if SECURE_BOOT_CHECK_SIGNATURE
/* used for anti-FI checks */
uint8_t image_digest[HASH_LEN] = { [ 0 ... 31] = 0xEE };
uint8_t verified_digest[HASH_LEN] = { [ 0 ... 31 ] = 0x01 };
#endif
if (data == NULL || part == NULL) {
return ESP_ERR_INVALID_ARG;
@ -172,6 +174,7 @@ static esp_err_t image_load(esp_image_load_mode_t mode, const esp_partition_pos_
for (int i = 0; i < data->image.segment_count; i++) {
esp_image_segment_header_t *header = &data->segments[i];
ESP_LOGV(TAG, "loading segment header %d at offset 0x%x", i, next_addr);
err = process_segment(i, next_addr, header, silent, do_load, sha_handle, checksum);
if (err != ESP_OK) {
goto err;
@ -197,14 +200,14 @@ static esp_err_t image_load(esp_image_load_mode_t mode, const esp_partition_pos_
}
}
/* For secure boot on ESP32, we don't calculate SHA or verify signautre on bootloaders.
For ESP32S2, we do verify signature on botoloaders which includes the SHA calculation.
/* For secure boot V1 on ESP32, we don't calculate SHA or verify signature on bootloaders.
For Secure Boot V2, we do verify signature on bootloader which includes the SHA calculation.
(For non-secure boot, we don't verify any SHA-256 hash appended to the bootloader because
esptool.py may have rewritten the header - rely on esptool.py having verified the bootloader at flashing time, instead.)
*/
bool verify_sha;
#if defined(CONFIG_SECURE_BOOT_ENABLED) && defined(CONFIG_IDF_TARGET_ESP32S2BETA)
#if CONFIG_SECURE_BOOT_V2_ENABLED
verify_sha = true;
#else // ESP32, or ESP32S2 without secure boot enabled
verify_sha = (data->start_addr != ESP_BOOTLOADER_OFFSET);
@ -217,8 +220,18 @@ static esp_err_t image_load(esp_image_load_mode_t mode, const esp_partition_pos_
#ifdef SECURE_BOOT_CHECK_SIGNATURE
// secure boot images have a signature appended
err = verify_secure_boot_signature(sha_handle, data);
#else
#if defined(BOOTLOADER_BUILD) && !defined(CONFIG_SECURE_BOOT)
// If secure boot is not enabled in hardware, then
// skip the signature check in bootloader when the debugger is attached.
// This is done to allow for breakpoints in Flash.
if (!esp_cpu_in_ocd_debug_mode()) {
#else // CONFIG_SECURE_BOOT
if (true) {
#endif // end checking for JTAG
err = verify_secure_boot_signature(sha_handle, data, image_digest, verified_digest);
sha_handle = NULL; // verify_secure_boot_signature finishes sha_handle
}
#else // SECURE_BOOT_CHECK_SIGNATURE
// No secure boot, but SHA-256 can be appended for basic corruption detection
if (sha_handle != NULL && !esp_cpu_in_ocd_debug_mode()) {
err = verify_simple_hash(sha_handle, data);
@ -250,7 +263,28 @@ static esp_err_t image_load(esp_image_load_mode_t mode, const esp_partition_pos_
}
#ifdef BOOTLOADER_BUILD
if (do_load && ram_obfs_value[0] != 0 && ram_obfs_value[1] != 0) { // Need to deobfuscate RAM
#ifdef SECURE_BOOT_CHECK_SIGNATURE
/* If signature was checked in bootloader build, verified_digest should equal image_digest
This is to detect any fault injection that caused signature verification to not complete normally.
Any attack which bypasses this check should be of limited use as the RAM contents are still obfuscated, therefore we do the check
immediately before we deobfuscate.
Note: the conditions for making this check are the same as for setting verify_sha above, but on ESP32 SB V1 we move the test for
"only verify signature in bootloader" into the macro so it's tested multiple times.
*/
#if CONFIG_SECURE_BOOT_V2_ENABLED
ESP_FAULT_ASSERT(memcmp(image_digest, verified_digest, HASH_LEN) == 0);
#else // Secure Boot V1 on ESP32, only verify signatures for apps not bootloaders
ESP_FAULT_ASSERT(data->start_addr == ESP_BOOTLOADER_OFFSET || memcmp(image_digest, verified_digest, HASH_LEN) == 0);
#endif
#endif // SECURE_BOOT_CHECK_SIGNATURE
// Deobfuscate RAM
if (do_load && ram_obfs_value[0] != 0 && ram_obfs_value[1] != 0) {
for (int i = 0; i < data->image.segment_count; i++) {
uint32_t load_addr = data->segments[i].load_addr;
if (should_load(load_addr)) {
@ -336,6 +370,127 @@ static esp_err_t verify_image_header(uint32_t src_addr, const esp_image_header_t
return err;
}
#ifdef BOOTLOADER_BUILD
/* Check the region load_addr - load_end doesn't overlap any memory used by the bootloader, registers, or other invalid memory
*/
static bool verify_load_addresses(int segment_index, intptr_t load_addr, intptr_t load_end, bool print_error, bool no_recurse)
{
/* Addresses of static data and the "loader" section of bootloader IRAM, all defined in ld script */
const char *reason = NULL;
extern int _dram_start, _dram_end, _loader_text_start, _loader_text_end;
void *load_addr_p = (void *)load_addr;
void *load_end_p = (void *)load_end;
if (load_end == load_addr) {
return true; // zero-length segments are fine
}
assert(load_end > load_addr); // data_len<16MB is checked in verify_segment_header() which is called before this, so this should always be true
if (esp_ptr_in_dram(load_addr_p) && esp_ptr_in_dram(load_end_p)) { /* Writing to DRAM */
/* Check if we're clobbering the stack */
intptr_t sp = (intptr_t)get_sp();
if (bootloader_util_regions_overlap(sp - STACK_LOAD_HEADROOM, SOC_ROM_STACK_START,
load_addr, load_end)) {
reason = "overlaps bootloader stack";
goto invalid;
}
/* Check if we're clobbering static data
(_dram_start.._dram_end includes bss, data, rodata sections in DRAM)
*/
if (bootloader_util_regions_overlap((intptr_t)&_dram_start, (intptr_t)&_dram_end, load_addr, load_end)) {
reason = "overlaps bootloader data";
goto invalid;
}
/* LAST DRAM CHECK (recursive): for D/IRAM, check the equivalent IRAM addresses if needed
Allow for the possibility that even though both pointers are IRAM, only part of the region is in a D/IRAM
section. In which case we recurse to check the part which falls in D/IRAM.
Note: We start with SOC_DIRAM_DRAM_LOW/HIGH and convert that address to IRAM to account for any reversing of word order
(chip-specific).
*/
if (!no_recurse && bootloader_util_regions_overlap(SOC_DIRAM_DRAM_LOW, SOC_DIRAM_DRAM_HIGH, load_addr, load_end)) {
intptr_t iram_load_addr, iram_load_end;
if (esp_ptr_in_diram_dram(load_addr_p)) {
iram_load_addr = (intptr_t)esp_ptr_diram_dram_to_iram(load_addr_p);
} else {
iram_load_addr = (intptr_t)esp_ptr_diram_dram_to_iram((void *)SOC_DIRAM_DRAM_LOW);
}
if (esp_ptr_in_diram_dram(load_end_p)) {
iram_load_end = (intptr_t)esp_ptr_diram_dram_to_iram(load_end_p);
} else {
iram_load_end = (intptr_t)esp_ptr_diram_dram_to_iram((void *)SOC_DIRAM_DRAM_HIGH);
}
if (iram_load_end < iram_load_addr) {
return verify_load_addresses(segment_index, iram_load_end, iram_load_addr, print_error, true);
} else {
return verify_load_addresses(segment_index, iram_load_addr, iram_load_end, print_error, true);
}
}
}
else if (esp_ptr_in_iram(load_addr_p) && esp_ptr_in_iram(load_end_p)) { /* Writing to IRAM */
/* Check for overlap of 'loader' section of IRAM */
if (bootloader_util_regions_overlap((intptr_t)&_loader_text_start, (intptr_t)&_loader_text_end,
load_addr, load_end)) {
reason = "overlaps loader IRAM";
goto invalid;
}
/* LAST IRAM CHECK (recursive): for D/IRAM, check the equivalent DRAM address if needed
Allow for the possibility that even though both pointers are IRAM, only part of the region is in a D/IRAM
section. In which case we recurse to check the part which falls in D/IRAM.
Note: We start with SOC_DIRAM_IRAM_LOW/HIGH and convert that address to DRAM to account for any reversing of word order
(chip-specific).
*/
if (!no_recurse && bootloader_util_regions_overlap(SOC_DIRAM_IRAM_LOW, SOC_DIRAM_IRAM_HIGH, load_addr, load_end)) {
intptr_t dram_load_addr, dram_load_end;
if (esp_ptr_in_diram_iram(load_addr_p)) {
dram_load_addr = (intptr_t)esp_ptr_diram_iram_to_dram(load_addr_p);
} else {
dram_load_addr = (intptr_t)esp_ptr_diram_iram_to_dram((void *)SOC_DIRAM_IRAM_LOW);
}
if (esp_ptr_in_diram_iram(load_end_p)) {
dram_load_end = (intptr_t)esp_ptr_diram_iram_to_dram(load_end_p);
} else {
dram_load_end = (intptr_t)esp_ptr_diram_iram_to_dram((void *)SOC_DIRAM_IRAM_HIGH);
}
if (dram_load_end < dram_load_addr) {
return verify_load_addresses(segment_index, dram_load_end, dram_load_addr, print_error, true);
} else {
return verify_load_addresses(segment_index, dram_load_addr, dram_load_end, print_error, true);
}
}
/* Sections entirely in RTC memory won't overlap with a vanilla bootloader but are valid load addresses, thus skipping them from the check */
} else if (esp_ptr_in_rtc_iram_fast(load_addr_p) && esp_ptr_in_rtc_iram_fast(load_end_p)){
return true;
} else if (esp_ptr_in_rtc_dram_fast(load_addr_p) && esp_ptr_in_rtc_dram_fast(load_end_p)){
return true;
} else if (esp_ptr_in_rtc_slow(load_addr_p) && esp_ptr_in_rtc_slow(load_end_p)) {
return true;
} else { /* Not a DRAM or an IRAM or RTC Fast IRAM, RTC Fast DRAM or RTC Slow address */
reason = "bad load address range";
goto invalid;
}
return true;
invalid:
if (print_error) {
ESP_LOGE(TAG, "Segment %d 0x%08x-0x%08x invalid: %s", segment_index, load_addr, load_end, reason);
}
return false;
}
#endif // BOOTLOADER_BUILD
static esp_err_t process_segment(int index, uint32_t flash_addr, esp_image_segment_header_t *header, bool silent, bool do_load, bootloader_sha256_handle_t sha_handle, uint32_t *checksum)
{
esp_err_t err;
@ -378,34 +533,9 @@ static esp_err_t process_segment(int index, uint32_t flash_addr, esp_image_segme
#ifdef BOOTLOADER_BUILD
/* Before loading segment, check it doesn't clobber bootloader RAM. */
if (do_load) {
const intptr_t load_end = load_addr + data_len;
if (load_end < (intptr_t) SOC_DRAM_HIGH) {
/* Writing to DRAM */
intptr_t sp = (intptr_t)get_sp();
if (load_end > sp - STACK_LOAD_HEADROOM) {
/* Bootloader .data/.rodata/.bss is above the stack, so this
* also checks that we aren't overwriting these segments.
*
* TODO: This assumes specific arrangement of sections we have
* in the ESP32. Rewrite this in a generic way to support other
* layouts.
*/
ESP_LOGE(TAG, "Segment %d end address 0x%08x too high (bootloader stack 0x%08x limit 0x%08x)",
index, load_end, sp, sp - STACK_LOAD_HEADROOM);
return ESP_ERR_IMAGE_INVALID;
}
} else {
/* Writing to IRAM */
const intptr_t loader_iram_start = (intptr_t) &_loader_text_start;
const intptr_t loader_iram_end = (intptr_t) &_loader_text_end;
if (bootloader_util_regions_overlap(loader_iram_start, loader_iram_end,
load_addr, load_end)) {
ESP_LOGE(TAG, "Segment %d (0x%08x-0x%08x) overlaps bootloader IRAM (0x%08x-0x%08x)",
index, load_addr, load_end, loader_iram_start, loader_iram_end);
return ESP_ERR_IMAGE_INVALID;
}
if (do_load && data_len > 0) {
if (!verify_load_addresses(index, load_addr, load_addr + data_len, true, false)) {
return ESP_ERR_IMAGE_INVALID;
}
}
#endif // BOOTLOADER_BUILD
@ -415,6 +545,10 @@ static esp_err_t process_segment(int index, uint32_t flash_addr, esp_image_segme
int32_t data_len_remain = data_len;
while (data_len_remain > 0) {
#if SECURE_BOOT_CHECK_SIGNATURE && defined(BOOTLOADER_BUILD)
/* Double check the address verification done above */
ESP_FAULT_ASSERT(!do_load || verify_load_addresses(0, load_addr, load_addr + data_len_remain, false, false));
#endif
uint32_t offset_page = ((data_addr & MMAP_ALIGNED_MASK) != 0) ? 1 : 0;
/* Data we could map in case we are not aligned to PAGE boundary is one page size lesser. */
data_len = MIN(data_len_remain, ((free_page_count - offset_page) * SPI_FLASH_MMU_PAGE_SIZE));
@ -440,7 +574,7 @@ static esp_err_t process_segment_data(intptr_t load_addr, uint32_t data_addr, ui
{
// If we are not loading, and the checksum is empty, skip processing this
// segment for data
if(!do_load && checksum == NULL) {
if (!do_load && checksum == NULL) {
ESP_LOGD(TAG, "skipping checksum for segment");
return ESP_OK;
}
@ -599,7 +733,7 @@ static esp_err_t verify_checksum(bootloader_sha256_handle_t sha_handle, uint32_t
length = (length + 15) & ~15; // Pad to next full 16 byte block
// Verify checksum
uint8_t buf[16];
WORD_ALIGNED_ATTR uint8_t buf[16];
esp_err_t err = bootloader_flash_read(data->start_addr + unpadded_length, buf, length - unpadded_length, true);
uint8_t calc = buf[length - unpadded_length - 1];
uint8_t checksum = (checksum_word >> 24)
@ -623,9 +757,9 @@ static esp_err_t verify_checksum(bootloader_sha256_handle_t sha_handle, uint32_t
return ESP_OK;
}
static esp_err_t verify_secure_boot_signature(bootloader_sha256_handle_t sha_handle, esp_image_metadata_t *data)
static esp_err_t verify_secure_boot_signature(bootloader_sha256_handle_t sha_handle, esp_image_metadata_t *data, uint8_t *image_digest, uint8_t *verified_digest)
{
uint8_t image_hash[HASH_LEN] = { 0 };
#ifdef SECURE_BOOT_CHECK_SIGNATURE
uint32_t end = data->start_addr + data->image_len;
ESP_LOGI(TAG, "Verifying image signature...");
@ -638,25 +772,36 @@ static esp_err_t verify_secure_boot_signature(bootloader_sha256_handle_t sha_han
bootloader_munmap(simple_hash);
}
#ifdef CONFIG_IDF_TARGET_ESP32S2BETA
// Pad to 4096 byte sector boundary
if (end % FLASH_SECTOR_SIZE != 0) {
uint32_t pad_len = FLASH_SECTOR_SIZE - (end % FLASH_SECTOR_SIZE);
const void *padding = bootloader_mmap(end, pad_len);
bootloader_sha256_data(sha_handle, padding, pad_len);
#if CONFIG_SECURE_SIGNED_APPS_RSA_SCHEME
// End of the image needs to be padded all the way to a 4KB boundary, after the simple hash
// (for apps they are usually already padded due to --secure-pad-v2, only a problem if this option was not used.)
uint32_t padded_end = (end + FLASH_SECTOR_SIZE - 1) & ~(FLASH_SECTOR_SIZE-1);
if (padded_end > end) {
const void *padding = bootloader_mmap(end, padded_end - end);
bootloader_sha256_data(sha_handle, padding, padded_end - end);
bootloader_munmap(padding);
end += pad_len;
end = padded_end;
}
#endif
bootloader_sha256_finish(sha_handle, image_hash);
bootloader_sha256_finish(sha_handle, image_digest);
// Log the hash for debugging
bootloader_debug_buffer(image_hash, HASH_LEN, "Calculated secure boot hash");
bootloader_debug_buffer(image_digest, HASH_LEN, "Calculated secure boot hash");
// Use hash to verify signature block
const esp_secure_boot_sig_block_t *sig_block = bootloader_mmap(data->start_addr + data->image_len, sizeof(esp_secure_boot_sig_block_t));
esp_err_t err = esp_secure_boot_verify_signature_block(sig_block, image_hash);
esp_err_t err = ESP_ERR_IMAGE_INVALID;
const void *sig_block;
#ifdef CONFIG_SECURE_SIGNED_APPS_ECDSA_SCHEME
ESP_FAULT_ASSERT(memcmp(image_digest, verified_digest, HASH_LEN) != 0); /* sanity check that these values start differently */
sig_block = bootloader_mmap(data->start_addr + data->image_len, sizeof(esp_secure_boot_sig_block_t));
err = esp_secure_boot_verify_ecdsa_signature_block(sig_block, image_digest, verified_digest);
#elif CONFIG_SECURE_SIGNED_APPS_RSA_SCHEME
ESP_FAULT_ASSERT(memcmp(image_digest, verified_digest, HASH_LEN) != 0); /* sanity check that these values start differently */
sig_block = bootloader_mmap(end, sizeof(ets_secure_boot_signature_t));
err = esp_secure_boot_verify_rsa_signature_block(sig_block, image_digest, verified_digest);
#endif
bootloader_munmap(sig_block);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Secure boot signature verification failed");
@ -677,11 +822,12 @@ static esp_err_t verify_secure_boot_signature(bootloader_sha256_handle_t sha_han
return ESP_ERR_IMAGE_INVALID;
}
#if CONFIG_IDF_TARGET_ESP32S2BETA
#if CONFIG_SECURE_SIGNED_APPS_RSA_SCHEME
// Adjust image length result to include the appended signature
data->image_len = end - data->start_addr + sizeof(ets_secure_boot_signature_t);
#endif
#endif // SECURE_BOOT_CHECK_SIGNATURE
return ESP_OK;
}
@ -705,3 +851,21 @@ static esp_err_t verify_simple_hash(bootloader_sha256_handle_t sha_handle, esp_i
bootloader_munmap(hash);
return ESP_OK;
}
int esp_image_get_flash_size(esp_image_flash_size_t app_flash_size)
{
switch (app_flash_size) {
case ESP_IMAGE_FLASH_SIZE_1MB:
return 1 * 1024 * 1024;
case ESP_IMAGE_FLASH_SIZE_2MB:
return 2 * 1024 * 1024;
case ESP_IMAGE_FLASH_SIZE_4MB:
return 4 * 1024 * 1024;
case ESP_IMAGE_FLASH_SIZE_8MB:
return 8 * 1024 * 1024;
case ESP_IMAGE_FLASH_SIZE_16MB:
return 16 * 1024 * 1024;
default:
return 0;
}
}

View File

@ -31,16 +31,25 @@ void esp_flash_encryption_init_checks()
// FLASH_CRYPT_CNT *must* be write protected. This will have happened automatically
// if bootloader is IDF V4.0 or newer but may not have happened for previous ESP-IDF bootloaders.
#ifdef CONFIG_SECURE_FLASH_ENCRYPTION_MODE_RELEASE
#ifdef CONFIG_SECURE_BOOT_ENABLED
#ifdef CONFIG_SECURE_BOOT
if (esp_secure_boot_enabled() && esp_flash_encryption_enabled()) {
uint8_t flash_crypt_cnt_wr_dis = 0;
esp_efuse_read_field_blob(ESP_EFUSE_WR_DIS_FLASH_CRYPT_CNT, &flash_crypt_cnt_wr_dis, 1);
bool flash_crypt_cnt_wr_dis = esp_efuse_read_field_bit(ESP_EFUSE_WR_DIS_FLASH_CRYPT_CNT);
if (!flash_crypt_cnt_wr_dis) {
ESP_EARLY_LOGE(TAG, "Flash encryption & Secure Boot together requires FLASH_CRYPT_CNT efuse to be write protected. Fixing now...");
esp_flash_write_protect_crypt_cnt();
uint8_t flash_crypt_cnt = 0;
esp_efuse_read_field_blob(ESP_EFUSE_FLASH_CRYPT_CNT, &flash_crypt_cnt,
ESP_EFUSE_FLASH_CRYPT_CNT[0]->bit_count);
if (flash_crypt_cnt == (1<<(ESP_EFUSE_FLASH_CRYPT_CNT[0]->bit_count))-1) {
// If encryption counter is already max, no need to write protect it
// (this distinction is important on ESP32 ECO3 where write-protecting FLASH_CRYPT_CNT also write-protects UART_DL_DIS)
flash_crypt_cnt_wr_dis = true;
}
if (!flash_crypt_cnt_wr_dis) {
ESP_EARLY_LOGE(TAG, "Flash encryption & Secure Boot together requires FLASH_CRYPT_CNT efuse to be write protected. Fixing now...");
esp_flash_write_protect_crypt_cnt();
}
}
}
#endif // CONFIG_SECURE_BOOT_ENABLED
#endif // CONFIG_SECURE_BOOT
#endif // CONFIG_SECURE_FLASH_ENCRYPTION_MODE_RELEASE
// Second check is to print a warning or error if the current running flash encryption mode
@ -48,39 +57,44 @@ void esp_flash_encryption_init_checks()
mode = esp_get_flash_encryption_mode();
if (mode == ESP_FLASH_ENC_MODE_DEVELOPMENT) {
#ifdef CONFIG_SECURE_FLASH_ENCRYPTION_MODE_RELEASE
ESP_EARLY_LOGE(TAG, "Flash encryption settings error: app is configured for RELEASE but efuses are set for DEVELOPMENT");
ESP_EARLY_LOGE(TAG, "Mismatch found in security options in bootloader menuconfig and efuse settings. Device is not secure.");
ESP_LOGE(TAG, "Flash encryption settings error: app is configured for RELEASE but efuses are set for DEVELOPMENT");
ESP_LOGE(TAG, "Mismatch found in security options in bootloader menuconfig and efuse settings. Device is not secure.");
#else
ESP_EARLY_LOGW(TAG, "Flash encryption mode is DEVELOPMENT (not secure)");
ESP_LOGW(TAG, "Flash encryption mode is DEVELOPMENT (not secure)");
#endif
} else if (mode == ESP_FLASH_ENC_MODE_RELEASE) {
ESP_EARLY_LOGI(TAG, "Flash encryption mode is RELEASE");
ESP_LOGI(TAG, "Flash encryption mode is RELEASE");
}
}
#endif
void esp_flash_write_protect_crypt_cnt(void)
{
uint8_t flash_crypt_cnt_wr_dis = 0;
esp_efuse_read_field_blob(ESP_EFUSE_WR_DIS_FLASH_CRYPT_CNT, &flash_crypt_cnt_wr_dis, 1);
if (!flash_crypt_cnt_wr_dis) {
esp_efuse_write_field_cnt(ESP_EFUSE_WR_DIS_FLASH_CRYPT_CNT, 1);
}
esp_efuse_write_field_bit(ESP_EFUSE_WR_DIS_FLASH_CRYPT_CNT);
}
esp_flash_enc_mode_t esp_get_flash_encryption_mode(void)
{
uint8_t efuse_flash_crypt_cnt_wr_protected = 0;
bool efuse_flash_crypt_cnt_wr_protected;
uint8_t dis_dl_enc = 0, dis_dl_dec = 0, dis_dl_cache = 0;
esp_flash_enc_mode_t mode = ESP_FLASH_ENC_MODE_DEVELOPMENT;
if (esp_flash_encryption_enabled()) {
/* Check if FLASH CRYPT CNT is write protected */
esp_efuse_read_field_blob(ESP_EFUSE_WR_DIS_FLASH_CRYPT_CNT, &efuse_flash_crypt_cnt_wr_protected, 1);
efuse_flash_crypt_cnt_wr_protected = esp_efuse_read_field_bit(ESP_EFUSE_WR_DIS_FLASH_CRYPT_CNT);
if (!efuse_flash_crypt_cnt_wr_protected) {
uint8_t flash_crypt_cnt = 0;
esp_efuse_read_field_blob(ESP_EFUSE_FLASH_CRYPT_CNT, &flash_crypt_cnt, ESP_EFUSE_FLASH_CRYPT_CNT[0]->bit_count);
if (flash_crypt_cnt == (1 << (ESP_EFUSE_FLASH_CRYPT_CNT[0]->bit_count)) - 1) {
efuse_flash_crypt_cnt_wr_protected = true; // CRYPT_CNT at max is same as write protected
}
}
if (efuse_flash_crypt_cnt_wr_protected) {
esp_efuse_read_field_blob(ESP_EFUSE_DISABLE_DL_CACHE, &dis_dl_cache, 1);
esp_efuse_read_field_blob(ESP_EFUSE_DISABLE_DL_ENCRYPT, &dis_dl_enc, 1);
esp_efuse_read_field_blob(ESP_EFUSE_DISABLE_DL_DECRYPT, &dis_dl_dec, 1);
dis_dl_cache = esp_efuse_read_field_bit(ESP_EFUSE_DISABLE_DL_CACHE);
dis_dl_enc = esp_efuse_read_field_bit(ESP_EFUSE_DISABLE_DL_ENCRYPT);
dis_dl_dec = esp_efuse_read_field_bit(ESP_EFUSE_DISABLE_DL_DECRYPT);
/* Check if DISABLE_DL_DECRYPT, DISABLE_DL_ENCRYPT & DISABLE_DL_CACHE are set */
if ( dis_dl_cache && dis_dl_enc && dis_dl_dec ) {
mode = ESP_FLASH_ENC_MODE_RELEASE;

View File

@ -52,7 +52,7 @@ esp_err_t esp_partition_table_verify(const esp_partition_info_t *partition_table
MD5Update(&context, (unsigned char *) partition_table, num_parts * sizeof(esp_partition_info_t));
MD5Final(digest, &context);
unsigned char *md5sum = ((unsigned char *) part) + 16; // skip the 2B magic number and the 14B fillup bytes
unsigned char *md5sum = ((unsigned char *) part) + ESP_PARTITION_MD5_OFFSET;
if (memcmp(md5sum, digest, sizeof(digest)) != 0) {
if (log_errors) {

View File

@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "bootloader_sha.h"
#include "bootloader_flash.h"
#include <stdbool.h>
#include <string.h>
#include <assert.h>

View File

@ -15,46 +15,55 @@
#include "bootloader_flash.h"
#include "bootloader_sha.h"
#include "bootloader_utility.h"
#include "esp_log.h"
#include "esp_image_format.h"
#include "esp_secure_boot.h"
#include "mbedtls/sha256.h"
#include "mbedtls/x509.h"
#include "mbedtls/md.h"
#include "mbedtls/platform.h"
#include "mbedtls/entropy.h"
#include "mbedtls/ctr_drbg.h"
#include <string.h>
#include <sys/param.h>
static const char *TAG = "secure_boot";
#define DIGEST_LEN 32
#ifdef CONFIG_SECURE_SIGNED_APPS_ECDSA_SCHEME
static const char *TAG = "secure_boot_v1";
extern const uint8_t signature_verification_key_start[] asm("_binary_signature_verification_key_bin_start");
extern const uint8_t signature_verification_key_end[] asm("_binary_signature_verification_key_bin_end");
#define SIGNATURE_VERIFICATION_KEYLEN 64
#define DIGEST_LEN 32
esp_err_t esp_secure_boot_verify_signature(uint32_t src_addr, uint32_t length)
{
uint8_t digest[DIGEST_LEN];
const uint8_t *data;
uint8_t verified_digest[DIGEST_LEN];
const esp_secure_boot_sig_block_t *sigblock;
ESP_LOGD(TAG, "verifying signature src_addr 0x%x length 0x%x", src_addr, length);
data = bootloader_mmap(src_addr, length + sizeof(esp_secure_boot_sig_block_t));
if (data == NULL) {
ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", src_addr, length + sizeof(esp_secure_boot_sig_block_t));
return ESP_FAIL;
esp_err_t err = bootloader_sha256_flash_contents(src_addr, length, digest);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Digest calculation failed 0x%x, 0x%x", src_addr, length);
return err;
}
// Calculate digest of main image
mbedtls_sha256_ret(data, length, digest, 0);
// Map the signature block and verify the signature
sigblock = (const esp_secure_boot_sig_block_t *)(data + length);
esp_err_t err = esp_secure_boot_verify_signature_block(sigblock, digest);
bootloader_munmap(data);
sigblock = (const esp_secure_boot_sig_block_t *)bootloader_mmap(src_addr + length, sizeof(esp_secure_boot_sig_block_t));
if (sigblock == NULL) {
ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", src_addr + length, sizeof(esp_secure_boot_sig_block_t));
return ESP_FAIL;
}
err = esp_secure_boot_verify_ecdsa_signature_block(sigblock, digest, verified_digest);
bootloader_munmap(sigblock);
return err;
}
esp_err_t esp_secure_boot_verify_signature_block(const esp_secure_boot_sig_block_t *sig_block, const uint8_t *image_digest)
esp_err_t esp_secure_boot_verify_ecdsa_signature_block(const esp_secure_boot_sig_block_t *sig_block, const uint8_t *image_digest, uint8_t *verified_digest)
{
#if !(defined(CONFIG_MBEDTLS_ECDSA_C) && defined(CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED))
ESP_LOGE(TAG, "Signature verification requires ECDSA & SECP256R1 curve enabled");
@ -62,6 +71,9 @@ esp_err_t esp_secure_boot_verify_signature_block(const esp_secure_boot_sig_block
#else
ptrdiff_t keylen;
/* Note: in IDF app image verification we don't add any fault injection resistance, boot-time checks only */
memset(verified_digest, 0, DIGEST_LEN);
keylen = signature_verification_key_end - signature_verification_key_start;
if (keylen != SIGNATURE_VERIFICATION_KEYLEN) {
ESP_LOGE(TAG, "Embedded public verification key has wrong length %d", keylen);
@ -123,3 +135,147 @@ cleanup:
return ret == 0 ? ESP_OK : ESP_ERR_IMAGE_INVALID;
#endif // CONFIG_MBEDTLS_ECDSA_C && CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED
}
#elif CONFIG_SECURE_SIGNED_APPS_RSA_SCHEME
static const char *TAG = "secure_boot_v2";
#define ALIGN_UP(num, align) (((num) + ((align) - 1)) & ~((align) - 1))
#define RSA_KEY_SIZE 384 /* RSA 3072 Bits */
esp_err_t esp_secure_boot_verify_signature(uint32_t src_addr, uint32_t length)
{
uint8_t digest[DIGEST_LEN] = {0};
uint8_t verified_digest[DIGEST_LEN] = {0};
/* Rounding off length to the upper 4k boundary */
uint32_t padded_length = ALIGN_UP(length, FLASH_SECTOR_SIZE);
ESP_LOGD(TAG, "verifying signature src_addr 0x%x length 0x%x", src_addr, length);
esp_err_t err = bootloader_sha256_flash_contents(src_addr, padded_length, digest);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Digest calculation failed 0x%x, 0x%x", src_addr, padded_length);
return err;
}
const ets_secure_boot_signature_t *sig_block = bootloader_mmap(src_addr + padded_length, sizeof(ets_secure_boot_signature_t));
if (sig_block == NULL) {
ESP_LOGE(TAG, "Failed to mmap data at offset 0x%x", src_addr + padded_length);
return ESP_FAIL;
}
err = esp_secure_boot_verify_rsa_signature_block(sig_block, digest, verified_digest);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Secure Boot V2 verification failed.");
}
bootloader_munmap(sig_block);
return err;
}
esp_err_t esp_secure_boot_verify_rsa_signature_block(const ets_secure_boot_signature_t *sig_block, const uint8_t *image_digest, uint8_t *verified_digest)
{
int i = 0;
#if CONFIG_SECURE_BOOT_V2_ENABLED /* Verify key against efuse block */
uint8_t efuse_trusted_digest[DIGEST_LEN] = {0}, sig_block_trusted_digest[DIGEST_LEN] = {0};
memcpy(efuse_trusted_digest, (uint8_t *) EFUSE_BLK2_RDATA0_REG, sizeof(efuse_trusted_digest));
/* Note: in IDF verification we don't add any fault injection resistance, as we don't expect this to be called
during boot-time verification. */
memset(verified_digest, 0, DIGEST_LEN);
/* Generating the SHA of the public key components in the signature block */
bootloader_sha256_handle_t sig_block_sha;
sig_block_sha = bootloader_sha256_start();
bootloader_sha256_data(sig_block_sha, &sig_block->block[0].key, sizeof(sig_block->block[0].key));
bootloader_sha256_finish(sig_block_sha, (unsigned char *)sig_block_trusted_digest);
if (memcmp(efuse_trusted_digest, sig_block_trusted_digest, DIGEST_LEN) != 0) {
const uint8_t zeroes[DIGEST_LEN] = {0};
/* Can't continue if secure boot is enabled, OR if a different digest is already written in efuse BLK2
(If BLK2 is empty and Secure Boot is disabled then we assume that it will be enabled later.)
*/
if (esp_secure_boot_enabled() || memcmp(efuse_trusted_digest, zeroes, DIGEST_LEN) != 0) {
ESP_LOGE(TAG, "Public key digest in eFuse BLK2 and the signature block don't match.");
return ESP_FAIL;
}
}
#endif
ESP_LOGI(TAG, "Verifying with RSA-PSS...");
int ret = 0;
mbedtls_rsa_context pk;
mbedtls_entropy_context entropy;
mbedtls_ctr_drbg_context ctr_drbg;
unsigned char *sig_be = calloc(1, RSA_KEY_SIZE);
unsigned char *buf = calloc(1, RSA_KEY_SIZE);
if (sig_be == NULL || buf == NULL) {
return ESP_ERR_NO_MEM;
}
mbedtls_entropy_init(&entropy);
mbedtls_ctr_drbg_init(&ctr_drbg);
ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, NULL, 0);
if (ret != 0) {
ESP_LOGE(TAG, "mbedtls_ctr_drbg_seed returned -0x%04x\n", ret);
goto exit;
}
for (i = 0; i < SECURE_BOOT_NUM_BLOCKS; i++) {
const mbedtls_mpi N = { .s = 1,
.n = sizeof(sig_block->block[i].key.n)/sizeof(mbedtls_mpi_uint),
.p = (void *)sig_block->block[i].key.n,
};
const mbedtls_mpi e = { .s = 1,
.n = sizeof(sig_block->block[i].key.e)/sizeof(mbedtls_mpi_uint), // 1
.p = (void *)&sig_block->block[i].key.e,
};
mbedtls_rsa_init(&pk, MBEDTLS_RSA_PKCS_V21, MBEDTLS_MD_SHA256);
ret = mbedtls_rsa_import(&pk, &N, NULL, NULL, NULL, &e);
if (ret != 0) {
ESP_LOGE(TAG, "Failed mbedtls_rsa_import, err: %d", ret);
goto exit;
}
ret = mbedtls_rsa_complete(&pk);
if (ret != 0) {
ESP_LOGE(TAG, "Failed mbedtls_rsa_complete, err: %d", ret);
goto exit;
}
ret = mbedtls_rsa_check_pubkey(&pk);
if (ret != 0) {
ESP_LOGI(TAG, "Key is not an RSA key -%0x", -ret);
goto exit;
}
/* Signature needs to be byte swapped into BE representation */
for (int j = 0; j < RSA_KEY_SIZE; j++) {
sig_be[RSA_KEY_SIZE- j - 1] = sig_block->block[i].signature[j];
}
ret = mbedtls_rsa_public( &pk, sig_be, buf);
if (ret != 0) {
ESP_LOGE(TAG, "mbedtls_rsa_public failed, err: %d", ret);
goto exit;
}
ret = mbedtls_rsa_rsassa_pss_verify( &pk, mbedtls_ctr_drbg_random, &ctr_drbg, MBEDTLS_RSA_PUBLIC, MBEDTLS_MD_SHA256, DIGEST_LEN,
image_digest, sig_be);
if (ret != 0) {
ESP_LOGE(TAG, "Failed mbedtls_rsa_rsassa_pss_verify, err: %d", ret);
} else {
ESP_LOGI(TAG, "Signature verified successfully!");
}
exit:
mbedtls_rsa_free(&pk);
if (ret == 0) {
break;
}
}
free(sig_be);
free(buf);
return (!ret) ? ESP_OK : ESP_ERR_IMAGE_INVALID;
}
#endif

View File

@ -95,6 +95,7 @@ if(CONFIG_BT_ENABLED)
"host/bluedroid/bta/dm/bta_dm_main.c"
"host/bluedroid/bta/dm/bta_dm_pm.c"
"host/bluedroid/bta/dm/bta_dm_sco.c"
"host/bluedroid/bta/dm/bta_dm_qos.c"
"host/bluedroid/bta/gatt/bta_gatt_common.c"
"host/bluedroid/bta/gatt/bta_gattc_act.c"
"host/bluedroid/bta/gatt/bta_gattc_api.c"
@ -312,6 +313,7 @@ if(CONFIG_BT_ENABLED)
if(CONFIG_BLE_MESH)
list(APPEND include_dirs
"esp_ble_mesh/mesh_common/include"
"esp_ble_mesh/mesh_common/tinycrypt/include"
"esp_ble_mesh/mesh_core"
"esp_ble_mesh/mesh_core/include"
"esp_ble_mesh/mesh_core/storage"
@ -323,7 +325,8 @@ if(CONFIG_BT_ENABLED)
"esp_ble_mesh/api/models/include"
"esp_ble_mesh/api")
list(APPEND srcs "esp_ble_mesh/api/core/esp_ble_mesh_common_api.c"
list(APPEND srcs "esp_ble_mesh/api/core/esp_ble_mesh_ble_api.c"
"esp_ble_mesh/api/core/esp_ble_mesh_common_api.c"
"esp_ble_mesh/api/core/esp_ble_mesh_local_data_operation_api.c"
"esp_ble_mesh/api/core/esp_ble_mesh_low_power_api.c"
"esp_ble_mesh/api/core/esp_ble_mesh_networking_api.c"
@ -335,6 +338,7 @@ if(CONFIG_BT_ENABLED)
"esp_ble_mesh/api/models/esp_ble_mesh_lighting_model_api.c"
"esp_ble_mesh/api/models/esp_ble_mesh_sensor_model_api.c"
"esp_ble_mesh/api/models/esp_ble_mesh_time_scene_model_api.c"
"esp_ble_mesh/btc/btc_ble_mesh_ble.c"
"esp_ble_mesh/btc/btc_ble_mesh_config_model.c"
"esp_ble_mesh/btc/btc_ble_mesh_generic_model.c"
"esp_ble_mesh/btc/btc_ble_mesh_health_model.c"
@ -342,11 +346,27 @@ if(CONFIG_BT_ENABLED)
"esp_ble_mesh/btc/btc_ble_mesh_prov.c"
"esp_ble_mesh/btc/btc_ble_mesh_sensor_model.c"
"esp_ble_mesh/btc/btc_ble_mesh_time_scene_model.c"
"esp_ble_mesh/mesh_common/mesh_aes_encrypt.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/aes_decrypt.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/aes_encrypt.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/cbc_mode.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/ccm_mode.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/cmac_mode.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/ctr_mode.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/ctr_prng.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/ecc_dh.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/ecc_dsa.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/ecc_platform_specific.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/ecc.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/hmac_prng.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/hmac.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/sha256.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/utils.c"
"esp_ble_mesh/mesh_common/mesh_atomic.c"
"esp_ble_mesh/mesh_common/mesh_buf.c"
"esp_ble_mesh/mesh_common/mesh_common.c"
"esp_ble_mesh/mesh_common/mesh_kernel.c"
"esp_ble_mesh/mesh_common/mesh_mutex.c"
"esp_ble_mesh/mesh_common/mesh_timer.c"
"esp_ble_mesh/mesh_common/mesh_util.c"
"esp_ble_mesh/mesh_core/storage/settings_nvs.c"
"esp_ble_mesh/mesh_core/access.c"
@ -355,27 +375,30 @@ if(CONFIG_BT_ENABLED)
"esp_ble_mesh/mesh_core/cfg_cli.c"
"esp_ble_mesh/mesh_core/cfg_srv.c"
"esp_ble_mesh/mesh_core/crypto.c"
"esp_ble_mesh/mesh_core/fast_prov.c"
"esp_ble_mesh/mesh_core/friend.c"
"esp_ble_mesh/mesh_core/health_cli.c"
"esp_ble_mesh/mesh_core/health_srv.c"
"esp_ble_mesh/mesh_core/local_operation.c"
"esp_ble_mesh/mesh_core/lpn.c"
"esp_ble_mesh/mesh_core/main.c"
"esp_ble_mesh/mesh_core/net.c"
"esp_ble_mesh/mesh_core/prov.c"
"esp_ble_mesh/mesh_core/provisioner_beacon.c"
"esp_ble_mesh/mesh_core/provisioner_main.c"
"esp_ble_mesh/mesh_core/provisioner_prov.c"
"esp_ble_mesh/mesh_core/proxy_client.c"
"esp_ble_mesh/mesh_core/proxy_server.c"
"esp_ble_mesh/mesh_core/settings_uid.c"
"esp_ble_mesh/mesh_core/settings.c"
"esp_ble_mesh/mesh_core/scan.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"
@ -481,6 +504,7 @@ if(CONFIG_BT_ENABLED)
"host/nimble/nimble/nimble/host/src/ble_hs_adv.c"
"host/nimble/nimble/nimble/host/src/ble_hs_hci.c"
"host/nimble/nimble/nimble/host/src/ble_hs_hci_util.c"
"host/nimble/nimble/nimble/host/src/ble_hs_resolv.c"
"host/nimble/nimble/nimble/host/store/ram/src/ble_store_ram.c"
"host/nimble/nimble/nimble/host/store/config/src/ble_store_config.c"
"host/nimble/nimble/nimble/host/store/config/src/ble_store_nvs.c"
@ -496,7 +520,8 @@ if(CONFIG_BT_ENABLED)
"host/nimble/nimble/porting/nimble/src/mem.c"
"host/nimble/nimble/porting/nimble/src/os_mbuf.c"
"host/nimble/nimble/porting/nimble/src/os_cputime.c"
"host/nimble/esp-hci/src/esp_nimble_hci.c")
"host/nimble/esp-hci/src/esp_nimble_hci.c"
"host/nimble/port/src/esp_nimble_mem.c")
if (CONFIG_BLE_MESH)
list(APPEND srcs "esp_ble_mesh/mesh_core/nimble_host/mesh_bearer_adapt.c")
@ -543,6 +568,6 @@ idf_component_register(SRCS "${srcs}"
if(CONFIG_BT_ENABLED)
target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-implicit-fallthrough -Wno-unused-const-variable)
target_link_libraries(${COMPONENT_LIB} INTERFACE "-L${CMAKE_CURRENT_LIST_DIR}/controller/lib")
target_link_libraries(${COMPONENT_LIB} INTERFACE "-L${CMAKE_CURRENT_LIST_DIR}/controller/lib/esp32")
target_link_libraries(${COMPONENT_LIB} PUBLIC btdm_app)
endif()

View File

@ -78,6 +78,47 @@ menu "Bluetooth"
default 1 if BTDM_CTRL_BR_EDR_SCO_DATA_PATH_PCM
default 0
menuconfig BTDM_CTRL_PCM_ROLE_EDGE_CONFIG
bool "PCM Signal Config (Role and Polar)"
depends on BTDM_CTRL_BR_EDR_SCO_DATA_PATH_PCM
default y
choice BTDM_CTRL_PCM_ROLE
prompt "PCM Role"
depends on BTDM_CTRL_PCM_ROLE_EDGE_CONFIG
help
PCM role can be configured as PCM master or PCM slave
config BTDM_CTRL_PCM_ROLE_MASTER
bool "PCM Master"
config BTDM_CTRL_PCM_ROLE_SLAVE
bool "PCM Slave"
endchoice
choice BTDM_CTRL_PCM_POLAR
prompt "PCM Polar"
depends on BTDM_CTRL_PCM_ROLE_EDGE_CONFIG
help
PCM polarity can be configured as Falling Edge or Rising Edge
config BTDM_CTRL_PCM_POLAR_FALLING_EDGE
bool "Falling Edge"
config BTDM_CTRL_PCM_POLAR_RISING_EDGE
bool "Rising Edge"
endchoice
config BTDM_CTRL_PCM_ROLE_EFF
int
default 0 if BTDM_CTRL_PCM_ROLE_MASTER
default 1 if BTDM_CTRL_PCM_ROLE_SLAVE
default 0
config BTDM_CTRL_PCM_POLAR_EFF
int
default 0 if BTDM_CTRL_PCM_POLAR_FALLING_EDGE
default 1 if BTDM_CTRL_PCM_POLAR_RISING_EDGE
default 0
config BTDM_CTRL_AUTO_LATENCY
bool "Auto latency"
depends on BTDM_CTRL_MODE_BTDM
@ -91,6 +132,19 @@ menu "Bluetooth"
default BTDM_CTRL_AUTO_LATENCY if BTDM_CTRL_MODE_BTDM
default n
config BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT
bool "Legacy Authentication Vendor Specific Event Enable"
depends on BTDM_CTRL_MODE_BR_EDR_ONLY || BTDM_CTRL_MODE_BTDM
default y
help
To protect from BIAS attack during Legacy authentication,
Legacy authentication Vendor specific event should be enabled
config BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT_EFF
bool
default BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT if BTDM_CTRL_MODE_BR_EDR_ONLY || BTDM_CTRL_MODE_BTDM
default 0
config BTDM_CTRL_BLE_MAX_CONN_EFF
int
@ -333,7 +387,7 @@ menu "Bluetooth"
config BTDM_CTRL_FULL_SCAN_SUPPORTED
bool "BLE full scan feature supported"
depends on BTDM_CONTROLLER_MODE_BLE_ONLY || BTDM_CONTROLLER_MODE_BTDM
depends on BTDM_CTRL_MODE_BLE_ONLY || BTDM_CTRL_MODE_BTDM
default y
help
The full scan function is mainly used to provide BLE scan performance.
@ -373,21 +427,6 @@ menu "Bluetooth"
If you set `BTDM_BLE_ADV_REPORT_DISCARD_THRSHOLD` to a small value or printf every adv lost event, it
may cause adv packets lost more.
menuconfig BTDM_COEX_BT_OPTIONS
bool "Coexistence Bluetooth Side Options"
depends on ESP32_WIFI_SW_COEXIST_ENABLE
default n
help
Options of Bluetooth Side of WiFi and bluetooth coexistence.
config BTDM_COEX_BLE_ADV_HIGH_PRIORITY
bool "Improve BLE ADV priority for WiFi & BLE coexistence"
depends on BTDM_COEX_BT_OPTIONS
default n
help
Improve BLE ADV coexistence priority to make it better performance.
For example, BLE mesh need to enable this option to improve BLE adv performance.
endmenu
choice BT_HOST

View File

@ -57,6 +57,7 @@
#endif
#if CONFIG_BLE_MESH
#include "btc_ble_mesh_ble.h"
#include "btc_ble_mesh_prov.h"
#include "btc_ble_mesh_health_model.h"
#include "btc_ble_mesh_config_model.h"
@ -68,7 +69,7 @@
#define BTC_TASK_PINNED_TO_CORE (TASK_PINNED_TO_CORE)
#define BTC_TASK_STACK_SIZE (BT_BTC_TASK_STACK_SIZE + BT_TASK_EXTRA_STACK_SIZE) //by menuconfig
#define BTC_TASK_NAME "btcT"
#define BTC_TASK_NAME "BTC_TASK"
#define BTC_TASK_PRIO (BT_TASK_MAX_PRIORITIES - 6)
osi_thread_t *btc_thread;
@ -93,9 +94,9 @@ static const btc_func_t profile_tab[BTC_PID_NUM] = {
#endif ///BLE_INCLUDED == TRUE
[BTC_PID_BLE_HID] = {NULL, NULL},
[BTC_PID_SPPLIKE] = {NULL, NULL},
#if (GATTS_INCLUDED == TRUE)
#if (BLUFI_INCLUDED == TRUE)
[BTC_PID_BLUFI] = {btc_blufi_call_handler, btc_blufi_cb_handler },
#endif ///GATTS_INCLUDED == TRUE
#endif ///BLUFI_INCLUDED == TRUE
[BTC_PID_DM_SEC] = {NULL, btc_dm_sec_cb_handler },
#endif
[BTC_PID_ALARM] = {btc_alarm_handler, NULL },
@ -124,18 +125,43 @@ static const btc_func_t profile_tab[BTC_PID_NUM] = {
#if CONFIG_BLE_MESH
[BTC_PID_PROV] = {btc_ble_mesh_prov_call_handler, btc_ble_mesh_prov_cb_handler },
[BTC_PID_MODEL] = {btc_ble_mesh_model_call_handler, btc_ble_mesh_model_cb_handler },
#if CONFIG_BLE_MESH_HEALTH_CLI
[BTC_PID_HEALTH_CLIENT] = {btc_ble_mesh_health_client_call_handler, btc_ble_mesh_health_client_cb_handler },
#endif /* CONFIG_BLE_MESH_HEALTH_CLI */
#if CONFIG_BLE_MESH_HEALTH_SRV
[BTC_PID_HEALTH_SERVER] = {btc_ble_mesh_health_server_call_handler, btc_ble_mesh_health_server_cb_handler },
#endif /* CONFIG_BLE_MESH_HEALTH_SRV */
#if CONFIG_BLE_MESH_CFG_CLI
[BTC_PID_CONFIG_CLIENT] = {btc_ble_mesh_config_client_call_handler, btc_ble_mesh_config_client_cb_handler },
#endif /* CONFIG_BLE_MESH_CFG_CLI */
[BTC_PID_CONFIG_SERVER] = {NULL, btc_ble_mesh_config_server_cb_handler },
#if CONFIG_BLE_MESH_GENERIC_CLIENT
[BTC_PID_GENERIC_CLIENT] = {btc_ble_mesh_generic_client_call_handler, btc_ble_mesh_generic_client_cb_handler },
#endif /* CONFIG_BLE_MESH_GENERIC_CLIENT */
#if CONFIG_BLE_MESH_LIGHTING_CLIENT
[BTC_PID_LIGHTING_CLIENT] = {btc_ble_mesh_lighting_client_call_handler, btc_ble_mesh_lighting_client_cb_handler },
#endif /* CONFIG_BLE_MESH_LIGHTING_CLIENT */
#if CONFIG_BLE_MESH_SENSOR_CLI
[BTC_PID_SENSOR_CLIENT] = {btc_ble_mesh_sensor_client_call_handler, btc_ble_mesh_sensor_client_cb_handler },
#endif /* CONFIG_BLE_MESH_SENSOR_CLI */
#if CONFIG_BLE_MESH_TIME_SCENE_CLIENT
[BTC_PID_TIME_SCENE_CLIENT] = {btc_ble_mesh_time_scene_client_call_handler, btc_ble_mesh_time_scene_client_cb_handler},
#endif /* CONFIG_BLE_MESH_TIME_SCENE_CLIENT */
#if CONFIG_BLE_MESH_GENERIC_SERVER
[BTC_PID_GENERIC_SERVER] = {NULL, btc_ble_mesh_generic_server_cb_handler },
#endif /* CONFIG_BLE_MESH_GENERIC_SERVER */
#if CONFIG_BLE_MESH_LIGHTING_SERVER
[BTC_PID_LIGHTING_SERVER] = {NULL, btc_ble_mesh_lighting_server_cb_handler },
#endif /* CONFIG_BLE_MESH_LIGHTING_SERVER */
#if CONFIG_BLE_MESH_SENSOR_SERVER
[BTC_PID_SENSOR_SERVER] = {NULL, btc_ble_mesh_sensor_server_cb_handler },
#endif /* CONFIG_BLE_MESH_SENSOR_SERVER */
#if CONFIG_BLE_MESH_TIME_SCENE_SERVER
[BTC_PID_TIME_SCENE_SERVER] = {NULL, btc_ble_mesh_time_scene_server_cb_handler},
#endif /* CONFIG_BLE_MESH_TIME_SCENE_SERVER */
#if CONFIG_BLE_MESH_BLE_COEX_SUPPORT
[BTC_PID_BLE_MESH_BLE_COEX] = {btc_ble_mesh_ble_call_handler, btc_ble_mesh_ble_cb_handler },
#endif /* CONFIG_BLE_MESH_BLE_COEX_SUPPORT */
#endif /* #if CONFIG_BLE_MESH */
};
@ -185,6 +211,15 @@ static bt_status_t btc_task_post(btc_msg_t *msg, uint32_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;
@ -214,6 +249,34 @@ bt_status_t btc_transfer_context(btc_msg_t *msg, void *arg, int arg_len, btc_arg
}
/**
* 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;
}
#if BTC_DYNAMIC_MEMORY
static void btc_deinit_mem(void) {
@ -244,12 +307,13 @@ static void btc_deinit_mem(void) {
osi_free(btc_creat_tab_env_ptr);
btc_creat_tab_env_ptr = NULL;
}
#if (BLUFI_INCLUDED == TRUE)
if (blufi_env_ptr) {
osi_free(blufi_env_ptr);
blufi_env_ptr = NULL;
}
#endif
#endif
#if BTC_HF_CLIENT_INCLUDED == TRUE && HFP_DYNAMIC_MEMORY == TRUE
if (hf_client_local_param_ptr) {
@ -298,12 +362,13 @@ static bt_status_t btc_init_mem(void) {
goto error_exit;
}
memset((void *)btc_creat_tab_env_ptr, 0, sizeof(esp_btc_creat_tab_t));
#if (BLUFI_INCLUDED == TRUE)
if ((blufi_env_ptr = (tBLUFI_ENV *)osi_malloc(sizeof(tBLUFI_ENV))) == NULL) {
goto error_exit;
}
memset((void *)blufi_env_ptr, 0, sizeof(tBLUFI_ENV));
#endif
#endif
#if BTC_HF_CLIENT_INCLUDED == TRUE && HFP_DYNAMIC_MEMORY == TRUE
if ((hf_client_local_param_ptr = (hf_client_local_param_t *)osi_malloc(sizeof(hf_client_local_param_t))) == NULL) {
@ -331,9 +396,9 @@ error_exit:;
}
#endif ///BTC_DYNAMIC_MEMORY
int btc_init(void)
bt_status_t btc_init(void)
{
btc_thread = osi_thread_create("BTC_TASK", BTC_TASK_STACK_SIZE, BTC_TASK_PRIO, BTC_TASK_PINNED_TO_CORE, 2);
btc_thread = osi_thread_create(BTC_TASK_NAME, BTC_TASK_STACK_SIZE, BTC_TASK_PRIO, BTC_TASK_PINNED_TO_CORE, 2);
if (btc_thread == NULL) {
return BT_STATUS_NOMEM;
}
@ -378,3 +443,8 @@ bool btc_check_queue_is_congest(void)
return false;
}
int get_btc_work_queue_size(void)
{
return osi_thread_queue_wait_size(btc_thread, 0);
}

View File

@ -53,7 +53,9 @@ typedef enum {
BTC_PID_GAP_BLE,
BTC_PID_BLE_HID,
BTC_PID_SPPLIKE,
#if (BLUFI_INCLUDED == TRUE)
BTC_PID_BLUFI,
#endif ///BLUFI_INCLUDED == TRUE
BTC_PID_DM_SEC,
BTC_PID_ALARM,
#if (CLASSIC_BT_INCLUDED == TRUE)
@ -85,6 +87,7 @@ typedef enum {
BTC_PID_LIGHTING_SERVER,
BTC_PID_SENSOR_SERVER,
BTC_PID_TIME_SCENE_SERVER,
BTC_PID_BLE_MESH_BLE_COEX,
#endif /* CONFIG_BLE_MESH */
BTC_PID_NUM,
} btc_pid_t; //btc profile id
@ -96,10 +99,29 @@ 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);
int btc_init(void);
/**
* 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);
bt_status_t btc_init(void);
void btc_deinit(void);
bool btc_check_queue_is_congest(void);
int get_btc_work_queue_size(void);
#endif /* __BTC_TASK_H__ */

View File

@ -40,14 +40,14 @@
/**********************************************************
* Thread/Task reference
**********************************************************/
#ifdef CONFIG_BLUEDROID_PINNED_TO_CORE
#define UC_TASK_PINNED_TO_CORE (CONFIG_BLUEDROID_PINNED_TO_CORE < portNUM_PROCESSORS ? CONFIG_BLUEDROID_PINNED_TO_CORE : tskNO_AFFINITY)
#ifdef CONFIG_BT_BLUEDROID_PINNED_TO_CORE
#define UC_TASK_PINNED_TO_CORE (CONFIG_BT_BLUEDROID_PINNED_TO_CORE < portNUM_PROCESSORS ? CONFIG_BT_BLUEDROID_PINNED_TO_CORE : tskNO_AFFINITY)
#else
#define UC_TASK_PINNED_TO_CORE (0)
#endif
#ifdef CONFIG_BTC_TASK_STACK_SIZE
#define UC_BTC_TASK_STACK_SIZE CONFIG_BTC_TASK_STACK_SIZE
#ifdef CONFIG_BT_BTC_TASK_STACK_SIZE
#define UC_BTC_TASK_STACK_SIZE CONFIG_BT_BTC_TASK_STACK_SIZE
#else
#define UC_BTC_TASK_STACK_SIZE 4096
#endif

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

@ -22,6 +22,10 @@ list_t *list_new(list_free_cb callback);
list_node_t *list_free_node(list_t *list, list_node_t *node);
// similar with list_free_node, this function doesn't free the node data
list_node_t *list_delete_node(list_t *list, list_node_t *node);
// Frees the list. This function accepts NULL as an argument, in which case it
// behaves like a no-op.
void list_free(list_t *list);
@ -75,6 +79,9 @@ bool list_append(list_t *list, void *data);
bool list_remove(list_t *list, void *data);
// similar with list_remove, but do not free the node data
bool list_delete(list_t *list, void *data);
// Removes all elements in the list. Calling this function will return the list to the
// same state it was in after |list_new|. |list| may not be NULL.
void list_clear(list_t *list);

View File

@ -186,6 +186,36 @@ bool list_remove(list_t *list, void *data)
return false;
}
bool list_delete(list_t *list, void *data)
{
assert(list != NULL);
assert(data != NULL);
if (list_is_empty(list)) {
return false;
}
if (list->head->data == data) {
list_node_t *next = list_delete_node(list, list->head);
if (list->tail == list->head) {
list->tail = next;
}
list->head = next;
return true;
}
for (list_node_t *prev = list->head, *node = list->head->next; node; prev = node, node = node->next)
if (node->data == data) {
prev->next = list_delete_node(list, node);
if (list->tail == node) {
list->tail = prev;
}
return true;
}
return false;
}
void list_clear(list_t *list)
{
assert(list != NULL);
@ -251,3 +281,17 @@ list_node_t *list_free_node(list_t *list, list_node_t *node)
return next;
}
// remove the element from list but do not free the node data
list_node_t *list_delete_node(list_t *list, list_node_t *node)
{
assert(list != NULL);
assert(node != NULL);
list_node_t *next = node->next;
osi_free(node);
--list->length;
return next;
}

View File

@ -9,11 +9,11 @@ COMPONENT_ADD_INCLUDEDIRS := include
LIBS := btdm_app
COMPONENT_ADD_LDFLAGS := -lbt -L $(COMPONENT_PATH)/controller/lib \
COMPONENT_ADD_LDFLAGS := -lbt -L $(COMPONENT_PATH)/controller/lib/esp32 \
$(addprefix -l,$(LIBS))
# re-link program if BT binary libs change
COMPONENT_ADD_LINKER_DEPS := $(patsubst %,$(COMPONENT_PATH)/controller/lib/lib%.a,$(LIBS))
COMPONENT_ADD_LINKER_DEPS := $(patsubst %,$(COMPONENT_PATH)/controller/lib/esp32/lib%.a,$(LIBS))
COMPONENT_SUBMODULES += controller/lib
@ -137,6 +137,7 @@ endif
ifdef CONFIG_BLE_MESH
COMPONENT_ADD_INCLUDEDIRS += esp_ble_mesh/mesh_common/include \
esp_ble_mesh/mesh_common/tinycrypt/include \
esp_ble_mesh/mesh_core \
esp_ble_mesh/mesh_core/include \
esp_ble_mesh/mesh_core/storage \
@ -149,9 +150,11 @@ COMPONENT_ADD_INCLUDEDIRS += esp_ble_mesh/mesh_common/include \
esp_ble_mesh/api
COMPONENT_SRCDIRS += esp_ble_mesh/mesh_common \
esp_ble_mesh/mesh_common/tinycrypt/src \
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 \
@ -197,7 +200,8 @@ COMPONENT_SRCDIRS += host/nimble/nimble/nimble/host/src
host/nimble/nimble/nimble/host/util/src \
host/nimble/nimble/nimble/host/store/ram/src \
host/nimble/nimble/nimble/host/store/config/src \
host/nimble/esp-hci/src
host/nimble/esp-hci/src \
host/nimble/port/src
ifndef CONFIG_BT_NIMBLE_CRYPTO_STACK_MBEDTLS
COMPONENT_SRCDIRS += host/nimble/nimble/ext/tinycrypt/src

View File

@ -79,14 +79,6 @@
#define BTDM_MIN_SLEEP_DURATION (12) // threshold of interval in slots to allow to fall into modem sleep
#define BTDM_MODEM_WAKE_UP_DELAY (4) // delay in slots of modem wake up procedure, including re-enable PHY/RF
#ifdef CONFIG_PM_ENABLE
#ifndef CONFIG_BTDM_LPCLK_SEL_MAIN_XTAL
#define BTDM_ALLOW_LIGHT_SLEEP 1
#else
#define BTDM_ALLOW_LIGHT_SLEEP 0
#endif
#endif
#define BT_DEBUG(...)
#define BT_API_CALL_CHECK(info, api_call, ret) \
do{\
@ -98,7 +90,7 @@ do{\
} while(0)
#define OSI_FUNCS_TIME_BLOCKING 0xffffffff
#define OSI_VERSION 0x00010001
#define OSI_VERSION 0x00010002
#define OSI_MAGIC_VALUE 0xFADEBEAD
/* SPIRAM Configuration */
@ -175,14 +167,25 @@ struct osi_funcs_t {
void (* _btdm_sleep_exit_phase1)(void); /* called from ISR */
void (* _btdm_sleep_exit_phase2)(void); /* called from ISR */
void (* _btdm_sleep_exit_phase3)(void); /* called from task */
bool (* _coex_bt_wakeup_request)(void);
void (* _coex_bt_wakeup_request_end)(void);
int (* _coex_bt_request)(uint32_t event, uint32_t latency, uint32_t duration);
int (* _coex_bt_release)(uint32_t event);
int (* _coex_register_bt_cb)(coex_func_cb_t cb);
uint32_t (* _coex_bb_reset_lock)(void);
void (* _coex_bb_reset_unlock)(uint32_t restore);
int (* _coex_schm_register_btdm_callback)(void *callback);
void (* _coex_schm_status_bit_clear)(uint32_t type, uint32_t status);
void (* _coex_schm_status_bit_set)(uint32_t type, uint32_t status);
uint32_t (* _coex_schm_interval_get)(void);
uint8_t (* _coex_schm_curr_period_get)(void);
void *(* _coex_schm_curr_phase_get)(void);
int (* _coex_wifi_channel_get)(uint8_t *primary, uint8_t *secondary);
int (* _coex_register_wifi_channel_change_callback)(void *cb);
uint32_t _magic;
};
typedef void (*workitem_handler_t)(void* arg);
/* External functions or values
************************************************************************
@ -199,13 +202,14 @@ extern void btdm_controller_disable(void);
extern uint8_t btdm_controller_get_mode(void);
extern const char *btdm_controller_get_compile_version(void);
extern void btdm_rf_bb_init_phase2(void); // shall be called after PHY/RF is enabled
extern int btdm_dispatch_work_to_controller(workitem_handler_t callback, void *arg, bool blocking);
/* Sleep */
extern void btdm_controller_enable_sleep(bool enable);
extern void btdm_controller_set_sleep_mode(uint8_t mode);
extern uint8_t btdm_controller_get_sleep_mode(void);
extern bool btdm_power_state_active(void);
extern void btdm_wakeup_request(bool request_lock);
extern void btdm_wakeup_request_end(void);
extern void btdm_wakeup_request(void);
extern void btdm_in_wakeup_requesting_set(bool in_wakeup_requesting);
/* Low Power Clock */
extern bool btdm_lpclk_select_src(uint32_t sel);
extern bool btdm_lpclk_set_div(uint32_t div);
@ -221,12 +225,19 @@ extern int bredr_txpwr_get(int *min_power_level, int *max_power_level);
extern void bredr_sco_datapath_set(uint8_t data_path);
extern void btdm_controller_scan_duplicate_list_clear(void);
/* Coexistence */
extern int coex_bt_request_wrapper(uint32_t event, uint32_t latency, uint32_t duration);
extern int coex_bt_release_wrapper(uint32_t event);
extern int coex_register_bt_cb_wrapper(coex_func_cb_t cb);
extern uint32_t coex_bb_reset_lock_wrapper(void);
extern void coex_bb_reset_unlock_wrapper(uint32_t restore);
extern void coex_ble_adv_priority_high_set(bool high);
extern int coex_bt_request(uint32_t event, uint32_t latency, uint32_t duration);
extern int coex_bt_release(uint32_t event);
extern int coex_register_bt_cb(coex_func_cb_t cb);
extern uint32_t coex_bb_reset_lock(void);
extern void coex_bb_reset_unlock(uint32_t restore);
extern int coex_schm_register_btdm_callback(void *callback);
extern void coex_schm_status_bit_clear(uint32_t type, uint32_t status);
extern void coex_schm_status_bit_set(uint32_t type, uint32_t status);
extern uint32_t coex_schm_interval_get(void);
extern uint8_t coex_schm_curr_period_get(void);
extern void * coex_schm_curr_phase_get(void);
extern int coex_wifi_channel_get(uint8_t *primary, uint8_t *secondary);
extern int coex_register_wifi_channel_change_callback(void *cb);
extern char _bss_start_btdm;
extern char _bss_end_btdm;
@ -288,8 +299,22 @@ static uint32_t IRAM_ATTR btdm_us_2_lpcycles(uint32_t us);
static bool IRAM_ATTR btdm_sleep_check_duration(uint32_t *slot_cnt);
static void btdm_sleep_enter_phase1_wrapper(uint32_t lpcycles);
static void btdm_sleep_enter_phase2_wrapper(void);
static void IRAM_ATTR btdm_sleep_exit_phase1_wrapper(void);
static void btdm_sleep_exit_phase3_wrapper(void);
static bool coex_bt_wakeup_request(void);
static void coex_bt_wakeup_request_end(void);
static int coex_bt_request_wrapper(uint32_t event, uint32_t latency, uint32_t duration);
static int coex_bt_release_wrapper(uint32_t event);
static int coex_register_bt_cb_wrapper(coex_func_cb_t cb);
static uint32_t coex_bb_reset_lock_wrapper(void);
static void coex_bb_reset_unlock_wrapper(uint32_t restore);
static int coex_schm_register_btdm_callback_wrapper(void *callback);
static void coex_schm_status_bit_clear_wrapper(uint32_t type, uint32_t status);
static void coex_schm_status_bit_set_wrapper(uint32_t type, uint32_t status);
static uint32_t coex_schm_interval_get_wrapper(void);
static uint8_t coex_schm_curr_period_get_wrapper(void);
static void * coex_schm_curr_phase_get_wrapper(void);
static int coex_wifi_channel_get_wrapper(uint8_t *primary, uint8_t *secondary);
static int coex_register_wifi_channel_change_callback_wrapper(void *cb);
/* Local variable definition
***************************************************************************
@ -334,14 +359,24 @@ static const struct osi_funcs_t osi_funcs_ro = {
._btdm_sleep_check_duration = btdm_sleep_check_duration,
._btdm_sleep_enter_phase1 = btdm_sleep_enter_phase1_wrapper,
._btdm_sleep_enter_phase2 = btdm_sleep_enter_phase2_wrapper,
._btdm_sleep_exit_phase1 = btdm_sleep_exit_phase1_wrapper,
._btdm_sleep_exit_phase1 = NULL,
._btdm_sleep_exit_phase2 = NULL,
._btdm_sleep_exit_phase3 = btdm_sleep_exit_phase3_wrapper,
._coex_bt_wakeup_request = coex_bt_wakeup_request,
._coex_bt_wakeup_request_end = coex_bt_wakeup_request_end,
._coex_bt_request = coex_bt_request_wrapper,
._coex_bt_release = coex_bt_release_wrapper,
._coex_register_bt_cb = coex_register_bt_cb_wrapper,
._coex_bb_reset_lock = coex_bb_reset_lock_wrapper,
._coex_bb_reset_unlock = coex_bb_reset_unlock_wrapper,
._coex_schm_register_btdm_callback = coex_schm_register_btdm_callback_wrapper,
._coex_schm_status_bit_clear = coex_schm_status_bit_clear_wrapper,
._coex_schm_status_bit_set = coex_schm_status_bit_set_wrapper,
._coex_schm_interval_get = coex_schm_interval_get_wrapper,
._coex_schm_curr_period_get = coex_schm_curr_period_get_wrapper,
._coex_schm_curr_phase_get = coex_schm_curr_phase_get_wrapper,
._coex_wifi_channel_get = coex_wifi_channel_get_wrapper,
._coex_register_wifi_channel_change_callback = coex_register_wifi_channel_change_callback_wrapper,
._magic = OSI_MAGIC_VALUE,
};
@ -384,16 +419,22 @@ static DRAM_ATTR portMUX_TYPE global_int_mux = portMUX_INITIALIZER_UNLOCKED;
static DRAM_ATTR uint32_t btdm_lpcycle_us = 0;
static DRAM_ATTR uint8_t btdm_lpcycle_us_frac = 0; // number of fractional bit for btdm_lpcycle_us
#if CONFIG_BTDM_MODEM_SLEEP_MODE_ORIG
// used low power clock
static DRAM_ATTR uint8_t btdm_lpclk_sel;
#endif /* #ifdef CONFIG_BTDM_MODEM_SLEEP_MODE_ORIG */
static DRAM_ATTR QueueHandle_t s_wakeup_req_sem = NULL;
#ifdef CONFIG_PM_ENABLE
static DRAM_ATTR esp_timer_handle_t s_btdm_slp_tmr;
static DRAM_ATTR esp_pm_lock_handle_t s_pm_lock;
static DRAM_ATTR QueueHandle_t s_pm_lock_sem = NULL;
#if !BTDM_ALLOW_LIGHT_SLEEP
static bool s_pm_lock_acquired = true;
static DRAM_ATTR bool s_btdm_allow_light_sleep;
// pm_lock to prevent light sleep when using main crystal as Bluetooth low power clock
static DRAM_ATTR esp_pm_lock_handle_t s_light_sleep_pm_lock;
#endif /* #if !BTDM_ALLOW_LIGHT_SLEEP */
static void btdm_slp_tmr_callback(void *arg);
#endif
#endif /* #ifdef CONFIG_PM_ENABLE */
static inline void btdm_check_and_init_bb(void)
{
@ -848,8 +889,10 @@ static void btdm_sleep_enter_phase2_wrapper(void)
esp_modem_sleep_enter(MODEM_BLE_MODULE);
esp_modem_sleep_enter(MODEM_CLASSIC_BT_MODULE);
#ifdef CONFIG_PM_ENABLE
esp_pm_lock_release(s_pm_lock);
semphr_give_wrapper(s_pm_lock_sem);
if (s_pm_lock_acquired) {
esp_pm_lock_release(s_pm_lock);
s_pm_lock_acquired = false;
}
#endif
} else if (btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_EVED) {
esp_modem_sleep_enter(MODEM_BLE_MODULE);
@ -858,17 +901,15 @@ static void btdm_sleep_enter_phase2_wrapper(void)
}
}
static void IRAM_ATTR btdm_sleep_exit_phase1_wrapper(void)
static void btdm_sleep_exit_phase3_wrapper(void)
{
#ifdef CONFIG_PM_ENABLE
if (semphr_take_from_isr_wrapper(s_pm_lock_sem, NULL) == pdTRUE) {
if (!s_pm_lock_acquired) {
s_pm_lock_acquired = true;
esp_pm_lock_acquire(s_pm_lock);
}
#endif
}
static void btdm_sleep_exit_phase3_wrapper(void)
{
if (btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_ORIG) {
esp_modem_sleep_exit(MODEM_BLE_MODULE);
esp_modem_sleep_exit(MODEM_CLASSIC_BT_MODULE);
@ -884,14 +925,224 @@ static void btdm_sleep_exit_phase3_wrapper(void)
}
#ifdef CONFIG_PM_ENABLE
static void IRAM_ATTR btdm_slp_tmr_callback(void *arg)
static void btdm_slp_tmr_customer_callback(void * arg)
{
if (semphr_take_wrapper(s_pm_lock_sem, 0) == pdTRUE) {
(void)(arg);
if (!s_pm_lock_acquired) {
s_pm_lock_acquired = true;
esp_pm_lock_acquire(s_pm_lock);
}
}
static void IRAM_ATTR btdm_slp_tmr_callback(void *arg)
{
(void)(arg);
btdm_dispatch_work_to_controller(btdm_slp_tmr_customer_callback, NULL, true);
}
#endif
#define BTDM_ASYNC_WAKEUP_REQ_HCI 0
#define BTDM_ASYNC_WAKEUP_REQ_COEX 1
#define BTDM_ASYNC_WAKEUP_REQ_CTRL_DISA 2
#define BTDM_ASYNC_WAKEUP_REQMAX 3
static void btdm_wakeup_request_callback(void * arg)
{
(void)(arg);
#if CONFIG_PM_ENABLE
if (!s_pm_lock_acquired) {
s_pm_lock_acquired = true;
esp_pm_lock_acquire(s_pm_lock);
}
esp_timer_stop(s_btdm_slp_tmr);
#endif
btdm_wakeup_request();
semphr_give_wrapper(s_wakeup_req_sem);
}
static bool async_wakeup_request(int event)
{
bool do_wakeup_request = false;
switch (event) {
case BTDM_ASYNC_WAKEUP_REQ_HCI:
btdm_in_wakeup_requesting_set(true);
// NO break
case BTDM_ASYNC_WAKEUP_REQ_CTRL_DISA:
if (!btdm_power_state_active()) {
do_wakeup_request = true;
btdm_dispatch_work_to_controller(btdm_wakeup_request_callback, NULL, true);
semphr_take_wrapper(s_wakeup_req_sem, OSI_FUNCS_TIME_BLOCKING);
}
break;
case BTDM_ASYNC_WAKEUP_REQ_COEX:
if (!btdm_power_state_active()) {
do_wakeup_request = true;
#if CONFIG_PM_ENABLE
if (!s_pm_lock_acquired) {
s_pm_lock_acquired = true;
esp_pm_lock_acquire(s_pm_lock);
}
esp_timer_stop(s_btdm_slp_tmr);
#endif
btdm_wakeup_request();
}
break;
default:
return false;
}
return do_wakeup_request;
}
static void async_wakeup_request_end(int event)
{
bool request_lock = false;
switch (event) {
case BTDM_ASYNC_WAKEUP_REQ_HCI:
request_lock = true;
break;
case BTDM_ASYNC_WAKEUP_REQ_COEX:
case BTDM_ASYNC_WAKEUP_REQ_CTRL_DISA:
request_lock = false;
break;
default:
return;
}
if (request_lock) {
btdm_in_wakeup_requesting_set(false);
}
return;
}
static bool coex_bt_wakeup_request(void)
{
return async_wakeup_request(BTDM_ASYNC_WAKEUP_REQ_COEX);
}
static void coex_bt_wakeup_request_end(void)
{
async_wakeup_request_end(BTDM_ASYNC_WAKEUP_REQ_COEX);
return;
}
static int IRAM_ATTR coex_bt_request_wrapper(uint32_t event, uint32_t latency, uint32_t duration)
{
#if CONFIG_SW_COEXIST_ENABLE
return coex_bt_request(event, latency, duration);
#else
return 0;
#endif
}
static int IRAM_ATTR coex_bt_release_wrapper(uint32_t event)
{
#if CONFIG_SW_COEXIST_ENABLE
return coex_bt_release(event);
#else
return 0;
#endif
}
static int coex_register_bt_cb_wrapper(coex_func_cb_t cb)
{
#if CONFIG_SW_COEXIST_ENABLE
return coex_register_bt_cb(cb);
#else
return 0;
#endif
}
static uint32_t IRAM_ATTR coex_bb_reset_lock_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
return coex_bb_reset_lock();
#else
return 0;
#endif
}
static void IRAM_ATTR coex_bb_reset_unlock_wrapper(uint32_t restore)
{
#if CONFIG_SW_COEXIST_ENABLE
coex_bb_reset_unlock(restore);
#endif
}
static int coex_schm_register_btdm_callback_wrapper(void *callback)
{
#if CONFIG_SW_COEXIST_ENABLE
return coex_schm_register_btdm_callback(callback);
#else
return 0;
#endif
}
static void coex_schm_status_bit_clear_wrapper(uint32_t type, uint32_t status)
{
#if CONFIG_SW_COEXIST_ENABLE
coex_schm_status_bit_clear(type, status);
#endif
}
static void coex_schm_status_bit_set_wrapper(uint32_t type, uint32_t status)
{
#if CONFIG_SW_COEXIST_ENABLE
coex_schm_status_bit_set(type, status);
#endif
}
static uint32_t coex_schm_interval_get_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
return coex_schm_interval_get();
#else
return 0;
#endif
}
static uint8_t coex_schm_curr_period_get_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
return coex_schm_curr_period_get();
#else
return 1;
#endif
}
static void * coex_schm_curr_phase_get_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
return coex_schm_curr_phase_get();
#else
return NULL;
#endif
}
static int coex_wifi_channel_get_wrapper(uint8_t *primary, uint8_t *secondary)
{
#if CONFIG_SW_COEXIST_ENABLE
return coex_wifi_channel_get(primary, secondary);
#else
return -1;
#endif
}
static int coex_register_wifi_channel_change_callback_wrapper(void *cb)
{
#if CONFIG_SW_COEXIST_ENABLE
return coex_register_wifi_channel_change_callback(cb);
#else
return -1;
#endif
}
bool esp_vhci_host_check_send_available(void)
{
return API_vhci_host_check_send_available();
@ -899,24 +1150,11 @@ bool esp_vhci_host_check_send_available(void)
void esp_vhci_host_send_packet(uint8_t *data, uint16_t len)
{
bool do_wakeup_request = false;
if (!btdm_power_state_active()) {
#if CONFIG_PM_ENABLE
if (semphr_take_wrapper(s_pm_lock_sem, 0)) {
esp_pm_lock_acquire(s_pm_lock);
}
esp_timer_stop(s_btdm_slp_tmr);
#endif
do_wakeup_request = true;
btdm_wakeup_request(true);
}
async_wakeup_request(BTDM_ASYNC_WAKEUP_REQ_HCI);
API_vhci_host_send_packet(data, len);
if (do_wakeup_request) {
btdm_wakeup_request_end();
}
async_wakeup_request_end(BTDM_ASYNC_WAKEUP_REQ_HCI);
}
esp_err_t esp_vhci_host_register_callback(const esp_vhci_host_callback_t *callback)
@ -975,7 +1213,7 @@ static esp_err_t try_heap_caps_add_region(intptr_t start, intptr_t end)
esp_err_t esp_bt_controller_mem_release(esp_bt_mode_t mode)
{
bool update = true;
intptr_t mem_start, mem_end;
intptr_t mem_start=(intptr_t) NULL, mem_end=(intptr_t) NULL;
if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
return ESP_ERR_INVALID_STATE;
@ -1085,6 +1323,11 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
esp_err_t err;
uint32_t btdm_cfg_mask = 0;
//if all the bt available memory was already released, cannot initialize bluetooth controller
if (btdm_dram_available_region[0].mode == ESP_BT_MODE_IDLE) {
return ESP_ERR_INVALID_STATE;
}
osi_funcs_p = (struct osi_funcs_t *)malloc_internal_wrapper(sizeof(struct osi_funcs_t));
if (osi_funcs_p == NULL) {
return ESP_ERR_NO_MEM;
@ -1099,11 +1342,6 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
return ESP_ERR_INVALID_STATE;
}
//if all the bt available memory was already released, cannot initialize bluetooth controller
if (btdm_dram_available_region[0].mode == ESP_BT_MODE_IDLE) {
return ESP_ERR_INVALID_STATE;
}
if (cfg == NULL) {
return ESP_ERR_INVALID_ARG;
}
@ -1133,12 +1371,73 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
memset(btdm_queue_table, 0, sizeof(btdm_queue_item_t) * BTDM_MAX_QUEUE_NUM);
#endif
#ifdef CONFIG_PM_ENABLE
#if !BTDM_ALLOW_LIGHT_SLEEP
if ((err = esp_pm_lock_create(ESP_PM_NO_LIGHT_SLEEP, 0, "btLS", &s_light_sleep_pm_lock)) != ESP_OK) {
s_wakeup_req_sem = semphr_create_wrapper(1, 0);
if (s_wakeup_req_sem == NULL) {
err = ESP_ERR_NO_MEM;
goto error;
}
#endif /* #if !BTDM_ALLOW_LIGHT_SLEEP */
btdm_controller_mem_init();
periph_module_enable(PERIPH_BT_MODULE);
#ifdef CONFIG_PM_ENABLE
s_btdm_allow_light_sleep = false;
#endif
// set default sleep clock cycle and its fractional bits
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
btdm_lpcycle_us = 2 << (btdm_lpcycle_us_frac);
#if CONFIG_BTDM_MODEM_SLEEP_MODE_ORIG
btdm_lpclk_sel = BTDM_LPCLK_SEL_XTAL; // set default value
#if CONFIG_BTDM_LPCLK_SEL_EXT_32K_XTAL
// check whether or not EXT_CRYS is working
if (rtc_clk_slow_freq_get() == RTC_SLOW_FREQ_32K_XTAL) {
btdm_lpclk_sel = BTDM_LPCLK_SEL_XTAL32K; // set default value
#ifdef CONFIG_PM_ENABLE
s_btdm_allow_light_sleep = true;
#endif
} else {
ESP_LOGW(BTDM_LOG_TAG, "32.768kHz XTAL not detected, fall back to main XTAL as Bluetooth sleep clock\n"
"light sleep mode will not be able to apply when bluetooth is enabled");
btdm_lpclk_sel = BTDM_LPCLK_SEL_XTAL; // set default value
}
#else
btdm_lpclk_sel = BTDM_LPCLK_SEL_XTAL; // set default value
#endif
bool select_src_ret, set_div_ret;
if (btdm_lpclk_sel == BTDM_LPCLK_SEL_XTAL) {
select_src_ret = btdm_lpclk_select_src(BTDM_LPCLK_SEL_XTAL);
set_div_ret = btdm_lpclk_set_div(rtc_clk_xtal_freq_get() * 2 - 1);
assert(select_src_ret && set_div_ret);
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
btdm_lpcycle_us = 2 << (btdm_lpcycle_us_frac);
} else { // btdm_lpclk_sel == BTDM_LPCLK_SEL_XTAL32K
select_src_ret = btdm_lpclk_select_src(BTDM_LPCLK_SEL_XTAL32K);
set_div_ret = btdm_lpclk_set_div(0);
assert(select_src_ret && set_div_ret);
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
btdm_lpcycle_us = (RTC_CLK_CAL_FRACT > 15) ? (1000000 << (RTC_CLK_CAL_FRACT - 15)) :
(1000000 >> (15 - RTC_CLK_CAL_FRACT));
assert(btdm_lpcycle_us != 0);
}
btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_ORIG);
#elif CONFIG_BTDM_MODEM_SLEEP_MODE_EVED
btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_EVED);
#else
btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_NONE);
#endif
#ifdef CONFIG_PM_ENABLE
if (!s_btdm_allow_light_sleep) {
if ((err = esp_pm_lock_create(ESP_PM_NO_LIGHT_SLEEP, 0, "btLS", &s_light_sleep_pm_lock)) != ESP_OK) {
goto error;
}
}
if ((err = esp_pm_lock_create(ESP_PM_APB_FREQ_MAX, 0, "bt", &s_pm_lock)) != ESP_OK) {
goto error;
}
@ -1151,42 +1450,7 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
goto error;
}
s_pm_lock_sem = semphr_create_wrapper(1, 0);
if (s_pm_lock_sem == NULL) {
err = ESP_ERR_NO_MEM;
goto error;
}
#endif
btdm_controller_mem_init();
periph_module_enable(PERIPH_BT_MODULE);
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
btdm_lpcycle_us = 32 << btdm_lpcycle_us_frac;
#if CONFIG_BTDM_MODEM_SLEEP_MODE_ORIG
bool select_src_ret = false;
bool set_div_ret = false;
#if CONFIG_BTDM_LPCLK_SEL_MAIN_XTAL
select_src_ret = btdm_lpclk_select_src(BTDM_LPCLK_SEL_XTAL);
set_div_ret = btdm_lpclk_set_div(rtc_clk_xtal_freq_get() * 2 - 1);
assert(select_src_ret && set_div_ret);
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
btdm_lpcycle_us = 2 << (btdm_lpcycle_us_frac);
#elif CONFIG_BTDM_LPCLK_SEL_EXT_32K_XTAL
select_src_ret = btdm_lpclk_select_src(BTDM_LPCLK_SEL_XTAL32K);
set_div_ret = btdm_lpclk_set_div(0);
assert(select_src_ret && set_div_ret);
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
btdm_lpcycle_us = (RTC_CLK_CAL_FRACT > 15) ? (1000000 << (RTC_CLK_CAL_FRACT - 15)) :
(1000000 >> (15 - RTC_CLK_CAL_FRACT));
assert(btdm_lpcycle_us != 0);
#endif // CONFIG_BTDM_LPCLK_SEL_XX
btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_ORIG);
#elif CONFIG_BTDM_MODEM_SLEEP_MODE_EVED
btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_EVED);
#else
btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_NONE);
s_pm_lock_acquired = true;
#endif
btdm_cfg_mask = btdm_config_mask_load();
@ -1196,24 +1460,18 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
goto error;
}
#ifdef CONFIG_BTDM_COEX_BLE_ADV_HIGH_PRIORITY
coex_ble_adv_priority_high_set(true);
#else
coex_ble_adv_priority_high_set(false);
#endif
btdm_controller_status = ESP_BT_CONTROLLER_STATUS_INITED;
return ESP_OK;
error:
#ifdef CONFIG_PM_ENABLE
#if !BTDM_ALLOW_LIGHT_SLEEP
if (s_light_sleep_pm_lock != NULL) {
esp_pm_lock_delete(s_light_sleep_pm_lock);
s_light_sleep_pm_lock = NULL;
if (!s_btdm_allow_light_sleep) {
if (s_light_sleep_pm_lock != NULL) {
esp_pm_lock_delete(s_light_sleep_pm_lock);
s_light_sleep_pm_lock = NULL;
}
}
#endif /* #if !BTDM_ALLOW_LIGHT_SLEEP */
if (s_pm_lock != NULL) {
esp_pm_lock_delete(s_pm_lock);
s_pm_lock = NULL;
@ -1222,11 +1480,11 @@ error:
esp_timer_delete(s_btdm_slp_tmr);
s_btdm_slp_tmr = NULL;
}
if (s_pm_lock_sem) {
semphr_delete_wrapper(s_pm_lock_sem);
s_pm_lock_sem = NULL;
}
#endif
if (s_wakeup_req_sem) {
semphr_delete_wrapper(s_wakeup_req_sem);
s_wakeup_req_sem = NULL;
}
return err;
}
@ -1241,18 +1499,17 @@ esp_err_t esp_bt_controller_deinit(void)
periph_module_disable(PERIPH_BT_MODULE);
#ifdef CONFIG_PM_ENABLE
#if !BTDM_ALLOW_LIGHT_SLEEP
esp_pm_lock_delete(s_light_sleep_pm_lock);
s_light_sleep_pm_lock = NULL;
#endif /* #if !BTDM_ALLOW_LIGHT_SLEEP */
esp_pm_lock_delete(s_pm_lock);
s_pm_lock = NULL;
if (!s_btdm_allow_light_sleep) {
esp_pm_lock_delete(s_light_sleep_pm_lock);
s_light_sleep_pm_lock = NULL;
}
esp_timer_stop(s_btdm_slp_tmr);
esp_timer_delete(s_btdm_slp_tmr);
s_btdm_slp_tmr = NULL;
semphr_delete_wrapper(s_pm_lock_sem);
s_pm_lock_sem = NULL;
s_pm_lock_acquired = false;
#endif
semphr_delete_wrapper(s_wakeup_req_sem);
s_wakeup_req_sem = NULL;
#if CONFIG_SPIRAM_USE_MALLOC
vSemaphoreDelete(btdm_queue_table_mux);
@ -1271,6 +1528,19 @@ esp_err_t esp_bt_controller_deinit(void)
return ESP_OK;
}
static void bt_shutdown(void)
{
esp_err_t ret = ESP_OK;
ESP_LOGD(BTDM_LOG_TAG, "stop Bluetooth");
ret = esp_bt_controller_disable();
if (ESP_OK != ret) {
ESP_LOGW(BTDM_LOG_TAG, "controller disable ret=%d", ret);
}
return;
}
esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
{
int ret;
@ -1285,9 +1555,9 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
}
#ifdef CONFIG_PM_ENABLE
#if !BTDM_ALLOW_LIGHT_SLEEP
esp_pm_lock_acquire(s_light_sleep_pm_lock);
#endif /* #if !BTDM_ALLOW_LIGHT_SLEEP */
if (!s_btdm_allow_light_sleep) {
esp_pm_lock_acquire(s_light_sleep_pm_lock);
}
esp_pm_lock_acquire(s_pm_lock);
#endif
@ -1325,15 +1595,19 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
}
esp_phy_rf_deinit(PHY_BT_MODULE);
#ifdef CONFIG_PM_ENABLE
#if !BTDM_ALLOW_LIGHT_SLEEP
esp_pm_lock_release(s_light_sleep_pm_lock);
#endif /* #if !BTDM_ALLOW_LIGHT_SLEEP */
if (!s_btdm_allow_light_sleep) {
esp_pm_lock_release(s_light_sleep_pm_lock);
}
esp_pm_lock_release(s_pm_lock);
#endif
return ESP_ERR_INVALID_STATE;
}
btdm_controller_status = ESP_BT_CONTROLLER_STATUS_ENABLED;
ret = esp_register_shutdown_handler(bt_shutdown);
if (ret != ESP_OK) {
ESP_LOGW(BTDM_LOG_TAG, "Register shutdown handler failed, ret = 0x%x", ret);
}
return ESP_OK;
}
@ -1347,9 +1621,7 @@ esp_err_t esp_bt_controller_disable(void)
// disable modem sleep and wake up from sleep mode
if (btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_ORIG) {
btdm_controller_enable_sleep(false);
if (!btdm_power_state_active()) {
btdm_wakeup_request(false);
}
async_wakeup_request(BTDM_ASYNC_WAKEUP_REQ_CTRL_DISA);
while (!btdm_power_state_active()) {
ets_delay_us(1000);
}
@ -1366,11 +1638,12 @@ esp_err_t esp_bt_controller_disable(void)
}
esp_phy_rf_deinit(PHY_BT_MODULE);
btdm_controller_status = ESP_BT_CONTROLLER_STATUS_INITED;
esp_unregister_shutdown_handler(bt_shutdown);
#ifdef CONFIG_PM_ENABLE
#if !BTDM_ALLOW_LIGHT_SLEEP
esp_pm_lock_release(s_light_sleep_pm_lock);
#endif /* #if !BTDM_ALLOW_LIGHT_SLEEP */
if (!s_btdm_allow_light_sleep) {
esp_pm_lock_release(s_light_sleep_pm_lock);
}
esp_pm_lock_release(s_pm_lock);
#endif
@ -1382,7 +1655,6 @@ esp_bt_controller_status_t esp_bt_controller_get_status(void)
return btdm_controller_status;
}
/* extra functions */
esp_err_t esp_ble_tx_power_set(esp_ble_power_type_t power_type, esp_power_level_t power_level)
{
@ -1469,26 +1741,6 @@ esp_err_t esp_bt_sleep_disable (void)
return status;
}
bool esp_bt_controller_is_sleeping(void)
{
if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_ENABLED ||
btdm_controller_get_sleep_mode() != BTDM_MODEM_SLEEP_MODE_ORIG) {
return false;
}
return !btdm_power_state_active();
}
void esp_bt_controller_wakeup_request(void)
{
if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_ENABLED ||
btdm_controller_get_sleep_mode() != BTDM_MODEM_SLEEP_MODE_ORIG) {
return;
}
btdm_wakeup_request(false);
}
esp_err_t esp_bredr_sco_datapath_set(esp_sco_data_path_t data_path)
{
if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_ENABLED) {

View File

@ -9,8 +9,8 @@ if BLE_MESH
config BLE_MESH_USE_DUPLICATE_SCAN
bool "Support Duplicate Scan in BLE Mesh"
depends on BT_BLUEDROID_ENABLED
select BLE_SCAN_DUPLICATE
select BLE_MESH_SCAN_DUPLICATE_EN
select BTDM_BLE_SCAN_DUPL
select BTDM_BLE_MESH_SCAN_DUPL_EN
default y
help
Enable this option to allow using specific duplicate scan filter
@ -18,6 +18,102 @@ if BLE_MESH
option in the Bluetooth Controller section in menuconfig, which is
"Scan Duplicate By Device Address and Advertising Data".
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_MEM_ALLOC_MODE_EXTERNAL
bool "External SPIRAM"
depends on ESP32_SPIRAM_SUPPORT
config BLE_MESH_MEM_ALLOC_MODE_DEFAULT
bool "Default alloc mode"
depends on ESP32_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 FREERTOS_SUPPORT_STATIC_ALLOCATION && ESP32_SPIRAM_SUPPORT
default n
help
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 ESP32_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_DEINIT
bool "Support de-initialize BLE Mesh stack"
default y
help
If enabled, users can use the function esp_ble_mesh_deinit() to de-initialize
the whole BLE Mesh stack.
menu "BLE Mesh and BLE coexistence support"
config BLE_MESH_SUPPORT_BLE_ADV
bool "Support sending normal BLE advertising packets"
default n
help
When selected, users can send normal BLE advertising packets
with specific API.
if BLE_MESH_SUPPORT_BLE_ADV
config BLE_MESH_BLE_ADV_BUF_COUNT
int "Number of advertising buffers for BLE advertising packets"
default 3
range 1 255
help
Number of advertising buffers for BLE packets available.
endif # BLE_MESH_SUPPORT_BLE_ADV
config BLE_MESH_SUPPORT_BLE_SCAN
bool "Support scanning normal BLE advertising packets"
default n
help
When selected, users can register a callback and receive normal BLE
advertising packets in the application layer.
endmenu # BLE Mesh and BLE coexistence support
config BLE_MESH_FAST_PROV
bool "Enable BLE Mesh Fast Provisioning"
select BLE_MESH_NODE
@ -49,7 +145,7 @@ if BLE_MESH
config BLE_MESH_WAIT_FOR_PROV_MAX_DEV_NUM
int "Maximum number of unprovisioned devices that can be added to device queue"
default 20
default 10
range 1 100
help
This option specifies how many unprovisioned devices can be added to device
@ -57,25 +153,14 @@ if BLE_MESH
queue in the bottom layer which is used to store unprovisioned device
information (e.g. Device UUID, address).
config BLE_MESH_MAX_STORED_NODES
int "Maximum number of nodes whose information can be stored"
default 20
range BLE_MESH_MAX_PROV_NODES 1000
help
This option specifies the maximum number of nodes whose information can be
stored by a Provisioner in its upper layer.
Users can change this value according to the number of nodes whose information
(e.g. Device UUID, unicast address, element number) are going to be stored by
a Provisioner. And the nodes include the provisioned ones and user-added ones.
config BLE_MESH_MAX_PROV_NODES
int "Maximum number of devices that can be provisioned by Provisioner"
default 20
default 10
range 1 1000
help
This option specifies how many devices can be provisioned by a Provisioner.
This value indicates the maximum number of unprovisioned devices which can be
provisioned by a Provisioner. For instanceif the value is 6, it means the
provisioned by a Provisioner. For instance, if the value is 6, it means the
Provisioner can provision up to 6 unprovisioned devices.
Theoretically a Provisioner without the limitation of its memory can provision
up to 32766 unprovisioned devices, here we limit the maximum number to 100
@ -116,12 +201,34 @@ if BLE_MESH
config BLE_MESH_PROVISIONER_APP_KEY_COUNT
int "Maximum number of application keys that can be owned by Provisioner"
default 9
default 3
range 1 4096
help
This option specifies how many application keys the Provisioner can have.
Indeed, this value decides the number of the application keys which can be added by a Provisioner.
config BLE_MESH_PROVISIONER_RECV_HB
bool "Support receiving Heartbeat messages"
default n
help
When this option is enabled, Provisioner can call specific functions to enable
or disable receiving Heartbeat messages and notify them to the application layer.
if BLE_MESH_PROVISIONER_RECV_HB
config BLE_MESH_PROVISIONER_RECV_HB_FILTER_SIZE
int "Maximum number of filter entries for receiving Heartbeat messages"
default 3
range 1 1000
help
This option specifies how many heartbeat filter entries Provisioner supports.
The heartbeat filter (acceptlist or rejectlist) entries are used to store a
list of SRC and DST which can be used to decide if a heartbeat message will
be processed and notified to the application layer by Provisioner.
Note: The filter is an empty rejectlist by default.
endif # BLE_MESH_PROVISIONER_RECV_HB
endif # BLE_MESH_PROVISIONER
# Virtual option enabled whenever Generic Provisioning layer is needed
@ -141,6 +248,19 @@ if BLE_MESH
advertising bearer. This option should be enabled if PB-ADV is
going to be used during provisioning procedure.
config BLE_MESH_UNPROVISIONED_BEACON_INTERVAL
int "Interval between two consecutive Unprovisioned Device Beacon"
depends on BLE_MESH_NODE && BLE_MESH_PB_ADV
default 5
default 3 if BLE_MESH_FAST_PROV
range 1 100
help
This option specifies the interval of sending two consecutive unprovisioned
device beacon, users can use this option to change the frequency of sending
unprovisioned device beacon. For example, if the value is 5, it means the
unprovisioned device beacon will send every 5 seconds. When the option of
BLE_MESH_FAST_PROV is selected, the value is better to be 3 seconds, or less.
config BLE_MESH_PB_GATT
bool "Provisioning support using GATT (PB-GATT)"
select BLE_MESH_PROXY
@ -168,15 +288,6 @@ if BLE_MESH
ability to act as a proxy between a Mesh GATT Client and a Mesh network.
This option should be enabled if a node is going to be a Proxy Server.
config BLE_MESH_GATT_PROXY_CLIENT
bool "BLE Mesh GATT Proxy Client"
select BLE_MESH_PROXY
default n
help
This option enables support for Mesh GATT Proxy Client. The Proxy Client
can use the GATT bearer to send mesh messages to a node that supports the
advertising bearer.
config BLE_MESH_NODE_ID_TIMEOUT
int "Node Identity advertising timeout"
depends on BLE_MESH_GATT_PROXY_SERVER
@ -191,23 +302,28 @@ if BLE_MESH
node, it will start to advertise using Node Identity during the time
set by this option. And after that, Network ID will be advertised.
if BLE_MESH_PROXY
config BLE_MESH_PROXY_FILTER_SIZE
int "Maximum number of filter entries per Proxy Client"
depends on BLE_MESH_GATT_PROXY_SERVER
default 4
range 1 32767
help
This option specifies how many Proxy Filter entries the local node supports.
The entries of Proxy filter (whitelist or blacklist) are used to store a
list of addresses which can be used to decide which messages will be forwarded
to the Proxy Client by the Proxy Server.
config BLE_MESH_PROXY_FILTER_SIZE
int "Maximum number of filter entries per Proxy Client"
default 1
default 3 if BLE_MESH_GATT_PROXY_SERVER
range 1 32767
help
This option specifies how many Proxy Filter entries the local node supports.
The entries of Proxy filter (whitelist or blacklist) are used to store a
list of addresses which can be used to decide which messages will be forwarded
to the Proxy Client by the Proxy Server.
endif # BLE_MESH_PROXY
config BLE_MESH_GATT_PROXY_CLIENT
bool "BLE Mesh GATT Proxy Client"
select BLE_MESH_PROXY
default n
help
This option enables support for Mesh GATT Proxy Client. The Proxy Client
can use the GATT bearer to send mesh messages to a node that supports the
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
@ -215,16 +331,20 @@ if BLE_MESH
devices. Recommend to enable this option as default.
config BLE_MESH_SETTINGS
bool "Store BLE Mesh Node configuration persistently"
bool "Store BLE Mesh configuration persistently"
default n
help
When selected, the BLE Mesh stack will take care of storing/restoring the
BLE Mesh configuration persistently in flash. Currently this only supports
storing BLE Mesh node configuration.
Currently enabling this option will only store BLE Mesh nodes' information
in the flash.
When selected, the BLE Mesh stack will take care of storing/restoring the BLE
Mesh configuration persistently in flash.
If the device is a BLE Mesh node, when this option is enabled, the configuration
of the device will be stored persistently, including unicast address, NetKey,
AppKey, etc.
And if the device is a BLE Mesh Provisioner, the information of the device will
be stored persistently, including the information of provisioned nodes, NetKey,
AppKey, etc.
if BLE_MESH_SETTINGS
config BLE_MESH_STORE_TIMEOUT
int "Delay (in seconds) before storing anything persistently"
range 0 1000000
@ -239,7 +359,7 @@ if BLE_MESH
config BLE_MESH_SEQ_STORE_RATE
int "How often the sequence number gets updated in storage"
range 0 1000000
default 128
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
@ -254,7 +374,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
@ -267,6 +387,73 @@ if BLE_MESH
introduce message replay attacks and system security will be in a
vulnerable state.
config BLE_MESH_SETTINGS_BACKWARD_COMPATIBILITY
bool "A specific option for settings backward compatibility"
depends on BLE_MESH_NODE
default n
help
This option is created to solve the issue of failure in recovering
node information after mesh stack updates. In the old version mesh
stack, there is no key of "mesh/role" in nvs. In the new version
mesh stack, key of "mesh/role" is added in nvs, recovering node
information needs to check "mesh/role" key in nvs and implements
selective recovery of mesh node information. Therefore, there may
be failure in recovering node information during node restarting
after OTA.
The new version mesh stack adds the option of "mesh/role" because
we have added the support of storing Provisioner information, while
the old version only supports storing node information.
If users are updating their nodes from old version to new version,
we recommend enabling this option, so that system could set the flag
in advance before recovering node information and make sure the node
information recovering could work as expected.
config BLE_MESH_SPECIFIC_PARTITION
bool "Use a specific NVS partition for BLE Mesh"
default n
help
When selected, the mesh stack will use a specified NVS partition instead of
default NVS partition. Note that the specified partition must be registered
with NVS using nvs_flash_init_partition() API, and the partition must exists
in the csv file.
When Provisioner needs to store a large amount of nodes' information in the
flash (e.g. more than 20), this option is recommended to be enabled.
config BLE_MESH_PARTITION_NAME
string "Name of the NVS partition for BLE Mesh"
depends on BLE_MESH_SPECIFIC_PARTITION
default "ble_mesh"
help
This value defines the name of the specified NVS partition used by the
mesh stack.
config BLE_MESH_USE_MULTIPLE_NAMESPACE
bool "Support using multiple NVS namespaces by Provisioner"
depends on BLE_MESH_PROVISIONER
default n
help
When selected, Provisioner can use different NVS namespaces to store
different instances of mesh information.
For example, if in the first room, Provisioner uses NetKey A, AppKey
A and provisions three devices, these information will be treated as
mesh information instance A. When the Provisioner moves to the second
room, it uses NetKey B, AppKey B and provisions two devices, then the
information will be treated as mesh information instance B.
Here instance A and instance B will be stored in different namespaces.
With this option enabled, Provisioner needs to use specific functions
to open the corresponding NVS namespace, restore the mesh information,
release the mesh information or erase the mesh information.
config BLE_MESH_MAX_NVS_NAMESPACE
int "Maximum number of NVS namespaces"
depends on BLE_MESH_USE_MULTIPLE_NAMESPACE
default 2
range 1 255
help
This option specifies the maximum NVS namespaces supported by Provisioner.
endif # if BLE_MESH_SETTINGS
config BLE_MESH_SUBNET_COUNT
@ -319,6 +506,11 @@ if BLE_MESH
The replay protection list is used to prevent a node from replay attack,
which will store the source address and sequence number of the received
mesh messages.
For Provisioner, the replay protection list size should not be smaller than
the maximum number of nodes whose information can be stored. And the element
number of each node should also be taken into consideration. For example, if
Provisioner can provision up to 20 nodes and each node contains two elements,
then the replay protection list size of Provisioner should be at least 40.
config BLE_MESH_MSG_CACHE_SIZE
int "Network message cache size"
@ -403,7 +595,7 @@ if BLE_MESH
config BLE_MESH_TX_SEG_MAX
int "Maximum number of segments in outgoing messages"
default 20
default 32
range 2 32
help
Maximum number of segments supported for outgoing messages.
@ -737,104 +929,138 @@ if BLE_MESH
uses 0 as the timeout value when sending acknowledged messages, then
the default value will be used which is four seconds.
menu "Support for BLE Mesh Client Models"
menu "Support for BLE Mesh Foundation models"
config BLE_MESH_CFG_CLI
bool "Configuration Client Model"
bool "Configuration Client model"
help
Enable support for Configuration client model.
Enable support for Configuration Client model.
config BLE_MESH_HEALTH_CLI
bool "Health Client Model"
bool "Health Client model"
help
Enable support for Health client model.
Enable support for Health Client model.
config BLE_MESH_HEALTH_SRV
bool "Health Server model"
default y
help
Enable support for Health Server model.
endmenu #Support for BLE Mesh Foundation models
menu "Support for BLE Mesh Client/Server models"
config BLE_MESH_GENERIC_ONOFF_CLI
bool "Generic OnOff Client Model"
bool "Generic OnOff Client model"
help
Enable support for Generic OnOff client model.
Enable support for Generic OnOff Client model.
config BLE_MESH_GENERIC_LEVEL_CLI
bool "Generic Level Client Model"
bool "Generic Level Client model"
help
Enable support for Generic Level client model.
Enable support for Generic Level Client model.
config BLE_MESH_GENERIC_DEF_TRANS_TIME_CLI
bool "Generic Default Transition Time Client Model"
bool "Generic Default Transition Time Client model"
help
Enable support for Generic Default Transition Time client model.
Enable support for Generic Default Transition Time Client model.
config BLE_MESH_GENERIC_POWER_ONOFF_CLI
bool "Generic Power Onoff Client Model"
bool "Generic Power OnOff Client model"
help
Enable support for Generic Power Onoff client model.
Enable support for Generic Power OnOff Client model.
config BLE_MESH_GENERIC_POWER_LEVEL_CLI
bool "Generic Power Level Client Model"
bool "Generic Power Level Client model"
help
Enable support for Generic Power Level client model.
Enable support for Generic Power Level Client model.
config BLE_MESH_GENERIC_BATTERY_CLI
bool "Generic Battery Client Model"
bool "Generic Battery Client model"
help
Enable support for Generic Battery client model.
Enable support for Generic Battery Client model.
config BLE_MESH_GENERIC_LOCATION_CLI
bool "Generic Location Client Model"
bool "Generic Location Client model"
help
Enable support for Generic Location client model.
Enable support for Generic Location Client model.
config BLE_MESH_GENERIC_PROPERTY_CLI
bool "Generic Property Client Model"
bool "Generic Property Client model"
help
Enable support for Generic Property client model.
Enable support for Generic Property Client model.
config BLE_MESH_SENSOR_CLI
bool "Sensor Client Model"
bool "Sensor Client model"
help
Enable support for Sensor client model.
Enable support for Sensor Client model.
config BLE_MESH_TIME_CLI
bool "Time Client Model"
bool "Time Client model"
help
Enable support for Time client model.
Enable support for Time Client model.
config BLE_MESH_SCENE_CLI
bool "Scene Client Model"
bool "Scene Client model"
help
Enable support for Scene client model.
Enable support for Scene Client model.
config BLE_MESH_SCHEDULER_CLI
bool "Scheduler Client Model"
bool "Scheduler Client model"
help
Enable support for Scheduler client model.
Enable support for Scheduler Client model.
config BLE_MESH_LIGHT_LIGHTNESS_CLI
bool "Light Lightness Client Model"
bool "Light Lightness Client model"
help
Enable support for Light Lightness client model.
Enable support for Light Lightness Client model.
config BLE_MESH_LIGHT_CTL_CLI
bool "Light CTL Client Model"
bool "Light CTL Client model"
help
Enable support for Light CTL client model.
Enable support for Light CTL Client model.
config BLE_MESH_LIGHT_HSL_CLI
bool "Light HSL Client Model"
bool "Light HSL Client model"
help
Enable support for Light HSL client model.
Enable support for Light HSL Client model.
config BLE_MESH_LIGHT_XYL_CLI
bool "Light XYL Client Model"
bool "Light XYL Client model"
help
Enable support for Light XYL client model.
Enable support for Light XYL Client model.
config BLE_MESH_LIGHT_LC_CLI
bool "Light LC Client Model"
bool "Light LC Client model"
help
Enable support for Light LC client model.
Enable support for Light LC Client model.
endmenu
config BLE_MESH_GENERIC_SERVER
bool "Generic server models"
default y
help
Enable support for Generic server models.
config BLE_MESH_SENSOR_SERVER
bool "Sensor server models"
default y
help
Enable support for Sensor server models.
config BLE_MESH_TIME_SCENE_SERVER
bool "Time and Scenes server models"
default y
help
Enable support for Time and Scenes server models.
config BLE_MESH_LIGHTING_SERVER
bool "Lighting server models"
default y
help
Enable support for Lighting server models.
endmenu #Support for BLE Mesh Client/Server models
config BLE_MESH_IV_UPDATE_TEST
bool "Test the IV Update Procedure"
@ -853,6 +1079,26 @@ if BLE_MESH
This option adds extra self-tests which are run every time BLE Mesh
networking is initialized.
if BLE_MESH_SELF_TEST
config BLE_MESH_TEST_AUTO_ENTER_NETWORK
bool "Unprovisioned device enters mesh network automatically"
default y
help
With this option enabled, an unprovisioned device can automatically
enters mesh network using a specific test function without the pro-
visioning procedure. And on the Provisioner side, a test function
needs to be invoked to add the node information into the mesh stack.
config BLE_MESH_TEST_USE_WHITE_LIST
bool "Use white list to filter mesh advertising packets"
default n
help
With this option enabled, users can use white list to filter mesh
advertising packets while scanning.
endif # BLE_MESH_SELF_TEST
config BLE_MESH_SHELL
bool "Enable BLE Mesh shell"
default n

View File

@ -0,0 +1,110 @@
// Copyright 2017-2020 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <stdint.h>
#include <string.h>
#include "esp_err.h"
#include "btc_ble_mesh_ble.h"
#include "esp_ble_mesh_ble_api.h"
#if CONFIG_BLE_MESH_BLE_COEX_SUPPORT
esp_err_t esp_ble_mesh_register_ble_callback(esp_ble_mesh_ble_cb_t callback)
{
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
return (btc_profile_cb_set(BTC_PID_BLE_MESH_BLE_COEX, callback) == 0 ? ESP_OK : ESP_FAIL);
}
#endif /* CONFIG_BLE_MESH_BLE_COEX_SUPPORT */
#if CONFIG_BLE_MESH_SUPPORT_BLE_ADV
esp_err_t esp_ble_mesh_start_ble_advertising(const esp_ble_mesh_ble_adv_param_t *param,
const esp_ble_mesh_ble_adv_data_t *data)
{
btc_ble_mesh_ble_args_t arg = {0};
btc_msg_t msg = {0};
if (param == NULL) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_BLE_MESH_BLE_COEX;
msg.act = BTC_BLE_MESH_ACT_START_BLE_ADV;
memcpy(&arg.start_ble_adv.param, param, sizeof(esp_ble_mesh_ble_adv_param_t));
if (data) {
memcpy(&arg.start_ble_adv.data, data, sizeof(esp_ble_mesh_ble_adv_data_t));
}
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_ble_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_stop_ble_advertising(uint8_t index)
{
btc_ble_mesh_ble_args_t arg = {0};
btc_msg_t msg = {0};
if (index >= CONFIG_BLE_MESH_BLE_ADV_BUF_COUNT) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_BLE_MESH_BLE_COEX;
msg.act = BTC_BLE_MESH_ACT_STOP_BLE_ADV;
arg.stop_ble_adv.index = index;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_ble_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif /* CONFIG_BLE_MESH_SUPPORT_BLE_ADV */
#if CONFIG_BLE_MESH_SUPPORT_BLE_SCAN
esp_err_t esp_ble_mesh_start_ble_scanning(esp_ble_mesh_ble_scan_param_t *param)
{
btc_ble_mesh_ble_args_t arg = {0};
btc_msg_t msg = {0};
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_BLE_MESH_BLE_COEX;
msg.act = BTC_BLE_MESH_ACT_START_BLE_SCAN;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_ble_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_stop_ble_scanning(void)
{
btc_ble_mesh_ble_args_t arg = {0};
btc_msg_t msg = {0};
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_BLE_MESH_BLE_COEX;
msg.act = BTC_BLE_MESH_ACT_STOP_BLE_SCAN;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_ble_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif /* CONFIG_BLE_MESH_SUPPORT_BLE_SCAN */

View File

@ -17,10 +17,6 @@
#include "freertos/FreeRTOS.h"
#include "freertos/semphr.h"
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include "osi/alarm.h"
#include "esp_err.h"
#include "btc_ble_mesh_prov.h"
@ -31,7 +27,7 @@ esp_err_t esp_ble_mesh_init(esp_ble_mesh_prov_t *prov, esp_ble_mesh_comp_t *comp
btc_ble_mesh_prov_args_t arg = {0};
SemaphoreHandle_t semaphore = NULL;
btc_msg_t msg = {0};
esp_err_t ret;
esp_err_t ret = ESP_OK;
if (prov == NULL || comp == NULL) {
return ESP_ERR_INVALID_ARG;
@ -46,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) {
LOG_ERROR("%s, Failed to allocate memory for the semaphore", __func__);
BT_ERR("Failed to create semaphore");
return ESP_ERR_NO_MEM;
}
@ -61,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);
LOG_ERROR("%s, BLE Mesh initialise failed", __func__);
BT_ERR("Failed to start mesh init");
return ESP_FAIL;
}
@ -73,3 +69,25 @@ esp_err_t esp_ble_mesh_init(esp_ble_mesh_prov_t *prov, esp_ble_mesh_comp_t *comp
return ESP_OK;
}
#if CONFIG_BLE_MESH_DEINIT
esp_err_t esp_ble_mesh_deinit(esp_ble_mesh_deinit_param_t *param)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (param == NULL) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
arg.mesh_deinit.param.erase_flash = param->erase_flash;
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_DEINIT_MESH;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif /* CONFIG_BLE_MESH_DEINIT */

View File

@ -13,10 +13,7 @@
// limitations under the License.
#include <stdint.h>
#include <errno.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include <string.h>
#include "esp_err.h"
@ -36,7 +33,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;
@ -46,6 +44,9 @@ uint16_t *esp_ble_mesh_is_model_subscribed_to_group(esp_ble_mesh_model_t *model,
esp_ble_mesh_elem_t *esp_ble_mesh_find_element(uint16_t element_addr)
{
if (!ESP_BLE_MESH_ADDR_IS_UNICAST(element_addr)) {
return NULL;
}
return btc_ble_mesh_elem_find(element_addr);
}
@ -55,7 +56,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;
@ -63,7 +64,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;
@ -76,3 +78,138 @@ const esp_ble_mesh_comp_t *esp_ble_mesh_get_composition_data(void)
return btc_ble_mesh_comp_get();
}
esp_err_t esp_ble_mesh_model_subscribe_group_addr(uint16_t element_addr, uint16_t company_id,
uint16_t model_id, uint16_t group_addr)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (!ESP_BLE_MESH_ADDR_IS_UNICAST(element_addr) ||
!ESP_BLE_MESH_ADDR_IS_GROUP(group_addr)) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_MODEL_SUBSCRIBE_GROUP_ADDR;
arg.model_sub_group_addr.element_addr = element_addr;
arg.model_sub_group_addr.company_id = company_id;
arg.model_sub_group_addr.model_id = model_id;
arg.model_sub_group_addr.group_addr = group_addr;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_model_unsubscribe_group_addr(uint16_t element_addr, uint16_t company_id,
uint16_t model_id, uint16_t group_addr)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (!ESP_BLE_MESH_ADDR_IS_UNICAST(element_addr) ||
!ESP_BLE_MESH_ADDR_IS_GROUP(group_addr)) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_MODEL_UNSUBSCRIBE_GROUP_ADDR;
arg.model_unsub_group_addr.element_addr = element_addr;
arg.model_unsub_group_addr.company_id = company_id;
arg.model_unsub_group_addr.model_id = model_id;
arg.model_unsub_group_addr.group_addr = group_addr;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#if CONFIG_BLE_MESH_NODE
const uint8_t *esp_ble_mesh_node_get_local_net_key(uint16_t net_idx)
{
return btc_ble_mesh_node_get_local_net_key(net_idx);
}
const uint8_t *esp_ble_mesh_node_get_local_app_key(uint16_t app_idx)
{
return btc_ble_mesh_node_get_local_app_key(app_idx);
}
esp_err_t esp_ble_mesh_node_add_local_net_key(const uint8_t net_key[16], uint16_t net_idx)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (net_key == NULL || net_idx > 0xFFF) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_NODE_ADD_LOCAL_NET_KEY;
arg.node_add_local_net_key.net_idx = net_idx;
memcpy(arg.node_add_local_net_key.net_key, net_key, 16);
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_node_add_local_app_key(const uint8_t app_key[16], uint16_t net_idx, uint16_t app_idx)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (app_key == NULL || net_idx > 0xFFF || app_idx > 0xFFF) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_NODE_ADD_LOCAL_APP_KEY;
arg.node_add_local_app_key.net_idx = net_idx;
arg.node_add_local_app_key.app_idx = app_idx;
memcpy(arg.node_add_local_app_key.app_key, app_key, 16);
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_node_bind_app_key_to_local_model(uint16_t element_addr, uint16_t company_id,
uint16_t model_id, uint16_t app_idx)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (!ESP_BLE_MESH_ADDR_IS_UNICAST(element_addr) || app_idx > 0xFFF) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_NODE_BIND_APP_KEY_TO_MODEL;
arg.node_local_mod_app_bind.element_addr = element_addr;
arg.node_local_mod_app_bind.model_id = model_id;
arg.node_local_mod_app_bind.company_id = company_id;
arg.node_local_mod_app_bind.app_idx = app_idx;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif /* CONFIG_BLE_MESH_NODE */

View File

@ -14,8 +14,6 @@
#include <stdint.h>
#include "btc/btc_task.h"
#include "esp_err.h"
#include "btc_ble_mesh_prov.h"

View File

@ -13,10 +13,7 @@
// limitations under the License.
#include <stdint.h>
#include <errno.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include <string.h>
#include "esp_err.h"
@ -26,28 +23,28 @@
#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;
uint8_t *msg_data = NULL;
btc_msg_t msg = {0};
esp_err_t status;
esp_err_t status = ESP_OK;
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
if (ctx && ctx->addr == ESP_BLE_MESH_ADDR_UNASSIGNED) {
LOG_ERROR("%s, Invalid destination address 0x0000", __func__);
BT_ERR("Invalid destination address 0x0000");
return ESP_ERR_INVALID_ARG;
}
if (device_role > ROLE_FAST_PROV) {
LOG_ERROR("%s, Invalid device role 0x%02x", __func__, device_role);
BT_ERR("Invalid device role 0x%02x", device_role);
return ESP_ERR_INVALID_ARG;
}
@ -66,19 +63,19 @@ 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) {
LOG_ERROR("%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;
}
}
if (act == BTC_BLE_MESH_ACT_MODEL_PUBLISH) {
mic_len = 4;
mic_len = ESP_BLE_MESH_MIC_SHORT;
} else {
mic_len = ctx->send_rel ? 8 : 4;
mic_len = ctx->send_rel ? ESP_BLE_MESH_MIC_LONG : ESP_BLE_MESH_MIC_SHORT;
}
if (op_len + length + mic_len > MIN(ESP_BLE_MESH_SDU_MAX_LEN, ESP_BLE_MESH_TX_SDU_MAX)) {
LOG_ERROR("%s, Data length %d is too large", __func__, length);
BT_ERR("Too large data length %d", length);
return ESP_ERR_INVALID_ARG;
}
@ -86,7 +83,7 @@ static esp_err_t ble_mesh_model_send_msg(esp_ble_mesh_model_t *model,
bt_mesh_model_msg_init(model->pub->msg, opcode);
net_buf_simple_add_mem(model->pub->msg, data, length);
} else {
msg_data = (uint8_t *)osi_malloc(op_len + length);
msg_data = (uint8_t *)bt_mesh_malloc(op_len + length);
if (msg_data == NULL) {
return ESP_ERR_NO_MEM;
}
@ -115,7 +112,7 @@ static esp_err_t ble_mesh_model_send_msg(esp_ble_mesh_model_t *model,
status = (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_model_args_t), btc_ble_mesh_model_arg_deep_copy)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
osi_free(msg_data);
bt_mesh_free(msg_data);
return status;
}
@ -129,7 +126,7 @@ esp_err_t esp_ble_mesh_register_custom_model_callback(esp_ble_mesh_model_cb_t ca
esp_err_t esp_ble_mesh_model_msg_opcode_init(uint8_t *data, uint32_t opcode)
{
uint16_t val;
uint16_t val = 0;
if (data == NULL) {
return ESP_ERR_INVALID_ARG;
@ -161,28 +158,53 @@ esp_err_t esp_ble_mesh_client_model_init(esp_ble_mesh_model_t *model)
if (model == NULL) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
return btc_ble_mesh_client_model_init(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)
#if CONFIG_BLE_MESH_DEINIT
esp_err_t esp_ble_mesh_client_model_deinit(esp_ble_mesh_model_t *model)
{
if (!model || !ctx) {
if (model == NULL) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
return btc_ble_mesh_client_model_deinit(model);
}
#endif /* CONFIG_BLE_MESH_DEINIT */
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)
{
if (model == NULL || ctx == NULL ||
ctx->net_idx == ESP_BLE_MESH_KEY_UNUSED ||
ctx->app_idx == ESP_BLE_MESH_KEY_UNUSED) {
return ESP_ERR_INVALID_ARG;
}
return ble_mesh_model_send_msg(model, ctx, opcode, BTC_BLE_MESH_ACT_SERVER_MODEL_SEND,
length, data, 0, false, ROLE_NODE);
}
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 || !ctx) {
if (model == NULL || ctx == NULL ||
ctx->net_idx == ESP_BLE_MESH_KEY_UNUSED ||
ctx->app_idx == ESP_BLE_MESH_KEY_UNUSED) {
return ESP_ERR_INVALID_ARG;
}
return ble_mesh_model_send_msg(model, ctx, opcode, BTC_BLE_MESH_ACT_CLIENT_MODEL_SEND,
length, data, msg_timeout, need_rsp, device_role);
}
@ -191,16 +213,19 @@ esp_err_t esp_ble_mesh_model_publish(esp_ble_mesh_model_t *model, uint32_t opcod
uint16_t length, uint8_t *data,
esp_ble_mesh_dev_role_t device_role)
{
if (!model || !model->pub || !model->pub->msg) {
if (model == NULL || model->pub == NULL || model->pub->msg == NULL ||
model->pub->publish_addr == ESP_BLE_MESH_ADDR_UNASSIGNED) {
return ESP_ERR_INVALID_ARG;
}
return ble_mesh_model_send_msg(model, NULL, opcode, BTC_BLE_MESH_ACT_MODEL_PUBLISH,
length, data, 0, false, device_role);
}
#if CONFIG_BLE_MESH_SERVER_MODEL
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};
@ -222,6 +247,7 @@ esp_err_t esp_ble_mesh_server_model_update_state(esp_ble_mesh_model_t *model,
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_model_args_t), btc_ble_mesh_model_arg_deep_copy)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif /* CONFIG_BLE_MESH_SERVER_MODEL */
esp_err_t esp_ble_mesh_node_local_reset(void)
{
@ -238,7 +264,7 @@ esp_err_t esp_ble_mesh_node_local_reset(void)
#if (CONFIG_BLE_MESH_PROVISIONER)
esp_err_t esp_ble_mesh_provisioner_set_node_name(int index, const char *name)
esp_err_t esp_ble_mesh_provisioner_set_node_name(uint16_t index, const char *name)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
@ -255,27 +281,130 @@ esp_err_t esp_ble_mesh_provisioner_set_node_name(int index, const char *name)
arg.set_node_name.index = index;
memset(arg.set_node_name.name, 0, sizeof(arg.set_node_name.name));
memcpy(arg.set_node_name.name, name, strlen(name));
strncpy(arg.set_node_name.name, name, ESP_BLE_MESH_NODE_NAME_MAX_LEN);
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
const char *esp_ble_mesh_provisioner_get_node_name(int index)
const char *esp_ble_mesh_provisioner_get_node_name(uint16_t index)
{
return bt_mesh_provisioner_get_node_name(index);
}
int esp_ble_mesh_provisioner_get_node_index(const char *name)
uint16_t esp_ble_mesh_provisioner_get_node_index(const char *name)
{
if (!name || (strlen(name) > ESP_BLE_MESH_NODE_NAME_MAX_LEN)) {
return -EINVAL;
return ESP_BLE_MESH_INVALID_NODE_INDEX;
}
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)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (!ESP_BLE_MESH_ADDR_IS_UNICAST(unicast_addr) || !data || length <= 14) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_STORE_NODE_COMP_DATA;
arg.store_node_comp_data.unicast_addr = unicast_addr;
arg.store_node_comp_data.length = length;
arg.store_node_comp_data.data = data;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), btc_ble_mesh_prov_arg_deep_copy)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_ble_mesh_node_t *esp_ble_mesh_provisioner_get_node_with_uuid(const uint8_t uuid[16])
{
if (!uuid) {
return NULL;
}
return btc_ble_mesh_provisioner_get_node_with_uuid(uuid);
}
esp_ble_mesh_node_t *esp_ble_mesh_provisioner_get_node_with_addr(uint16_t unicast_addr)
{
if (!ESP_BLE_MESH_ADDR_IS_UNICAST(unicast_addr)) {
return NULL;
}
return btc_ble_mesh_provisioner_get_node_with_addr(unicast_addr);
}
esp_ble_mesh_node_t *esp_ble_mesh_provisioner_get_node_with_name(const char *name)
{
if (!name || (strlen(name) > ESP_BLE_MESH_NODE_NAME_MAX_LEN)) {
return NULL;
}
return btc_ble_mesh_provisioner_get_node_with_name(name);
}
uint16_t esp_ble_mesh_provisioner_get_prov_node_count(void)
{
return btc_ble_mesh_provisioner_get_prov_node_count();
}
const esp_ble_mesh_node_t **esp_ble_mesh_provisioner_get_node_table_entry(void)
{
return btc_ble_mesh_provisioner_get_node_table_entry();
}
esp_err_t esp_ble_mesh_provisioner_delete_node_with_uuid(const uint8_t uuid[16])
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (!uuid) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_DELETE_NODE_WITH_UUID;
memcpy(arg.delete_node_with_uuid.uuid, uuid, 16);
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_provisioner_delete_node_with_addr(uint16_t unicast_addr)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (!ESP_BLE_MESH_ADDR_IS_UNICAST(unicast_addr)) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_DELETE_NODE_WITH_ADDR;
arg.delete_node_with_addr.unicast_addr = unicast_addr;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
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};
@ -284,7 +413,7 @@ esp_err_t esp_ble_mesh_provisioner_add_local_app_key(const uint8_t app_key[16],
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_SET_LOCAL_APP_KEY;
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_ADD_LOCAL_APP_KEY;
arg.add_local_app_key.net_idx = net_idx;
arg.add_local_app_key.app_idx = app_idx;
@ -297,13 +426,36 @@ esp_err_t esp_ble_mesh_provisioner_add_local_app_key(const uint8_t app_key[16],
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
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)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (app_key == NULL) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_UPDATE_LOCAL_APP_KEY;
memcpy(arg.update_local_app_key.app_key, app_key, 16);
arg.update_local_app_key.net_idx = net_idx;
arg.update_local_app_key.app_idx = app_idx;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
const uint8_t *esp_ble_mesh_provisioner_get_local_app_key(uint16_t net_idx, uint16_t app_idx)
{
return bt_mesh_provisioner_local_app_key_get(net_idx, app_idx);
}
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};
@ -351,11 +503,271 @@ esp_err_t esp_ble_mesh_provisioner_add_local_net_key(const uint8_t net_key[16],
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_provisioner_update_local_net_key(const uint8_t net_key[16], uint16_t net_idx)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (net_key == NULL) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_UPDATE_LOCAL_NET_KEY;
memcpy(arg.update_local_net_key.net_key, net_key, 16);
arg.update_local_net_key.net_idx = net_idx;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
const uint8_t *esp_ble_mesh_provisioner_get_local_net_key(uint16_t net_idx)
{
return bt_mesh_provisioner_local_net_key_get(net_idx);
}
#if CONFIG_BLE_MESH_PROVISIONER_RECV_HB
esp_err_t esp_ble_mesh_provisioner_recv_heartbeat(bool enable)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_ENABLE_HEARTBEAT_RECV;
arg.enable_heartbeat_recv.enable = enable;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_provisioner_set_heartbeat_filter_type(uint8_t type)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (type > ESP_BLE_MESH_HEARTBEAT_FILTER_REJECTLIST) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_SET_HEARTBEAT_FILTER_TYPE;
arg.set_heartbeat_filter_type.type = type;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_provisioner_set_heartbeat_filter_info(uint8_t op, esp_ble_mesh_heartbeat_filter_info_t *info)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (op > ESP_BLE_MESH_HEARTBEAT_FILTER_REMOVE || info == NULL) {
return ESP_ERR_INVALID_ARG;
}
if (!ESP_BLE_MESH_ADDR_IS_UNICAST(info->hb_src) &&
!ESP_BLE_MESH_ADDR_IS_UNICAST(info->hb_dst) &&
!ESP_BLE_MESH_ADDR_IS_GROUP(info->hb_dst)) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_SET_HEARTBEAT_FILTER_INFO;
arg.set_heartbeat_filter_info.op = op;
arg.set_heartbeat_filter_info.hb_src = info->hb_src;
arg.set_heartbeat_filter_info.hb_dst = info->hb_dst;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif /* CONFIG_BLE_MESH_PROVISIONER_RECV_HB */
#if CONFIG_BLE_MESH_SETTINGS
esp_err_t esp_ble_mesh_provisioner_direct_erase_settings(void)
{
btc_msg_t msg = {0};
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_DIRECT_ERASE_SETTINGS;
return (btc_transfer_context(&msg, NULL, 0, NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif /* CONFIG_BLE_MESH_SETTINGS */
#if CONFIG_BLE_MESH_USE_MULTIPLE_NAMESPACE
esp_err_t esp_ble_mesh_provisioner_open_settings_with_index(uint8_t index)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (index >= CONFIG_BLE_MESH_MAX_NVS_NAMESPACE) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_OPEN_SETTINGS_WITH_INDEX;
arg.open_settings_with_index.index = index;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_provisioner_open_settings_with_uid(const char *uid)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (!uid || strlen(uid) > ESP_BLE_MESH_SETTINGS_UID_SIZE) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_OPEN_SETTINGS_WITH_UID;
strncpy(arg.open_settings_with_uid.uid, uid, ESP_BLE_MESH_SETTINGS_UID_SIZE);
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_provisioner_close_settings_with_index(uint8_t index, bool erase)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (index >= CONFIG_BLE_MESH_MAX_NVS_NAMESPACE) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_CLOSE_SETTINGS_WITH_INDEX;
arg.close_settings_with_index.index = index;
arg.close_settings_with_index.erase = erase;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_provisioner_close_settings_with_uid(const char *uid, bool erase)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (!uid || strlen(uid) > ESP_BLE_MESH_SETTINGS_UID_SIZE) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_CLOSE_SETTINGS_WITH_UID;
strncpy(arg.close_settings_with_uid.uid, uid, ESP_BLE_MESH_SETTINGS_UID_SIZE);
arg.close_settings_with_uid.erase = erase;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_provisioner_delete_settings_with_index(uint8_t index)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (index >= CONFIG_BLE_MESH_MAX_NVS_NAMESPACE) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_DELETE_SETTINGS_WITH_INDEX;
arg.delete_settings_with_index.index = index;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_provisioner_delete_settings_with_uid(const char *uid)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (!uid || strlen(uid) > ESP_BLE_MESH_SETTINGS_UID_SIZE) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_DELETE_SETTINGS_WITH_UID;
strncpy(arg.delete_settings_with_uid.uid, uid, ESP_BLE_MESH_SETTINGS_UID_SIZE);
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
const char *esp_ble_mesh_provisioner_get_settings_uid(uint8_t index)
{
if (index >= CONFIG_BLE_MESH_MAX_NVS_NAMESPACE) {
return NULL;
}
return btc_ble_mesh_provisioner_get_settings_uid(index);
}
uint8_t esp_ble_mesh_provisioner_get_settings_index(const char *uid)
{
if (!uid || strlen(uid) > ESP_BLE_MESH_SETTINGS_UID_SIZE) {
return ESP_BLE_MESH_INVALID_SETTINGS_IDX;
}
return btc_ble_mesh_provisioner_get_settings_index(uid);
}
uint8_t esp_ble_mesh_provisioner_get_free_settings_count(void)
{
return btc_ble_mesh_provisioner_get_free_settings_count();
}
#endif /* CONFIG_BLE_MESH_USE_MULTIPLE_NAMESPACE */
#endif /* CONFIG_BLE_MESH_PROVISIONER */
#if (CONFIG_BLE_MESH_FAST_PROV)

View File

@ -13,9 +13,7 @@
// limitations under the License.
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include <string.h>
#include "esp_err.h"
@ -37,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;
@ -58,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;
@ -70,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};
@ -118,7 +138,7 @@ esp_err_t esp_ble_mesh_node_input_string(const char *string)
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (!string) {
if (!string || strlen(string) > ESP_BLE_MESH_PROV_INPUT_OOB_MAX_LEN) {
return ESP_ERR_INVALID_ARG;
}
@ -128,7 +148,8 @@ esp_err_t esp_ble_mesh_node_input_string(const char *string)
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_INPUT_STRING;
memset(arg.input_string.string, 0, sizeof(arg.input_string.string));
strncpy(arg.input_string.string, string, strlen(string));
strncpy(arg.input_string.string, string,
MIN(strlen(string), sizeof(arg.input_string.string)));
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
@ -150,14 +171,15 @@ esp_err_t esp_ble_mesh_set_unprovisioned_device_name(const char *name)
msg.act = BTC_BLE_MESH_ACT_SET_DEVICE_NAME;
memset(arg.set_device_name.name, 0, sizeof(arg.set_device_name.name));
memcpy(arg.set_device_name.name, name, strlen(name));
strncpy(arg.set_device_name.name, name, ESP_BLE_MESH_DEVICE_NAME_MAX_LEN);
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#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};
@ -185,7 +207,8 @@ esp_err_t esp_ble_mesh_provisioner_input_string(const char *string, uint8_t link
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (!string || link_idx >= MAX_PROV_LINK_IDX) {
if (!string || strlen(string) > ESP_BLE_MESH_PROV_OUTPUT_OOB_MAX_LEN ||
link_idx >= MAX_PROV_LINK_IDX) {
return ESP_ERR_INVALID_ARG;
}
@ -196,7 +219,8 @@ esp_err_t esp_ble_mesh_provisioner_input_string(const char *string, uint8_t link
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_INPUT_STR;
memset(arg.provisioner_input_str.string, 0, sizeof(arg.provisioner_input_str.string));
strncpy(arg.provisioner_input_str.string, string, strlen(string));
strncpy(arg.provisioner_input_str.string, string,
MIN(strlen(string), sizeof(arg.provisioner_input_str.string)));
arg.provisioner_input_str.link_idx = link_idx;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
@ -230,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;
@ -247,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;
@ -260,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};
@ -285,6 +317,40 @@ esp_err_t esp_ble_mesh_provisioner_add_unprov_dev(esp_ble_mesh_unprov_dev_add_t
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
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)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (uuid == NULL || (bearer == ESP_BLE_MESH_PROV_GATT && (addr == NULL ||
addr_type > ESP_BLE_MESH_ADDR_TYPE_RANDOM)) ||
(bearer != ESP_BLE_MESH_PROV_ADV && bearer != ESP_BLE_MESH_PROV_GATT) ||
!ESP_BLE_MESH_ADDR_IS_UNICAST(unicast_addr)) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_PROV_DEV_WITH_ADDR;
memcpy(arg.provisioner_prov_dev_with_addr.uuid, uuid, 16);
if (addr) {
memcpy(arg.provisioner_prov_dev_with_addr.addr, addr, BD_ADDR_LEN);
arg.provisioner_prov_dev_with_addr.addr_type = addr_type;
}
arg.provisioner_prov_dev_with_addr.bearer = bearer;
arg.provisioner_prov_dev_with_addr.oob_info = oob_info;
arg.provisioner_prov_dev_with_addr.unicast_addr = unicast_addr;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_provisioner_delete_dev(esp_ble_mesh_device_delete_t *del_dev)
{
uint8_t val = DEL_DEV_ADDR_FLAG | DEL_DEV_UUID_FLAG;
@ -313,11 +379,15 @@ 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};
if (match_len + offset > ESP_BLE_MESH_OCTET16_LEN) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
@ -362,6 +432,47 @@ esp_err_t esp_ble_mesh_provisioner_set_prov_data_info(esp_ble_mesh_prov_data_inf
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_provisioner_set_static_oob_value(const uint8_t *value, uint8_t length)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (value == NULL || length == 0 || length > 16) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_SET_STATIC_OOB_VAL;
arg.set_static_oob_val.length = length;
memcpy(arg.set_static_oob_val.value, value, length);
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_provisioner_set_primary_elem_addr(uint16_t addr)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (!ESP_BLE_MESH_ADDR_IS_UNICAST(addr)) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_SET_PRIMARY_ELEM_ADDR;
arg.set_primary_elem_addr.addr = addr;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif /* CONFIG_BLE_MESH_PROVISIONER */
/* The following APIs are for fast provisioning */
@ -373,7 +484,8 @@ esp_err_t esp_ble_mesh_set_fast_prov_info(esp_ble_mesh_fast_prov_info_t *fast_pr
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (fast_prov_info == NULL) {
if (fast_prov_info == NULL || (fast_prov_info->offset +
fast_prov_info->match_len > ESP_BLE_MESH_OCTET16_LEN)) {
return ESP_ERR_INVALID_ARG;
}

View File

@ -13,9 +13,7 @@
// limitations under the License.
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include <string.h>
#include "esp_err.h"
@ -62,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};
@ -102,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};
@ -126,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};
@ -151,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

@ -0,0 +1,190 @@
// Copyright 2017-2020 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef _ESP_BLE_MESH_BLE_API_H_
#define _ESP_BLE_MESH_BLE_API_H_
#include "esp_ble_mesh_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
/** This enum value is the event of BLE operations */
typedef enum {
ESP_BLE_MESH_START_BLE_ADVERTISING_COMP_EVT, /*!< Start BLE advertising completion event */
ESP_BLE_MESH_STOP_BLE_ADVERTISING_COMP_EVT, /*!< Stop BLE advertising completion event */
ESP_BLE_MESH_START_BLE_SCANNING_COMP_EVT, /*!< Start BLE scanning completion event */
ESP_BLE_MESH_STOP_BLE_SCANNING_COMP_EVT, /*!< Stop BLE scanning completion event */
ESP_BLE_MESH_SCAN_BLE_ADVERTISING_PKT_EVT, /*!< Scanning BLE advertising packets event */
ESP_BLE_MESH_BLE_EVT_MAX,
} esp_ble_mesh_ble_cb_event_t;
/** BLE operation callback parameters */
typedef union {
/**
* @brief ESP_BLE_MESH_START_BLE_ADVERTISING_COMP_EVT
*/
struct {
int err_code; /*!< Indicate the result of starting BLE advertising */
uint8_t index; /*!< Index of the BLE advertising */
} start_ble_advertising_comp; /*!< Event parameters of ESP_BLE_MESH_START_BLE_ADVERTISING_COMP_EVT */
/**
* @brief ESP_BLE_MESH_STOP_BLE_ADVERTISING_COMP_EVT
*/
struct {
int err_code; /*!< Indicate the result of stopping BLE advertising */
uint8_t index; /*!< Index of the BLE advertising */
} stop_ble_advertising_comp; /*!< Event parameters of ESP_BLE_MESH_STOP_BLE_ADVERTISING_COMP_EVT */
/**
* @brief ESP_BLE_MESH_START_BLE_SCANNING_COMP_EVT
*/
struct {
int err_code; /*!< Indicate the result of starting BLE scanning */
} start_ble_scan_comp; /*!< Event parameters of ESP_BLE_MESH_START_BLE_SCANNING_COMP_EVT */
/**
* @brief ESP_BLE_MESH_STOP_BLE_SCANNING_COMP_EVT
*/
struct {
int err_code; /*!< Indicate the result of stopping BLE scanning */
} stop_ble_scan_comp; /*!< Event parameters of ESP_BLE_MESH_STOP_BLE_SCANNING_COMP_EVT */
/**
* @brief ESP_BLE_MESH_SCAN_BLE_ADVERTISING_PKT_EVT
*/
struct {
uint8_t addr[6]; /*!< Device address */
uint8_t addr_type; /*!< Device address type */
uint8_t adv_type; /*!< Advertising data type */
uint8_t *data; /*!< Advertising data */
uint16_t length; /*!< Advertising data length */
int8_t rssi; /*!< RSSI of the advertising packet */
} scan_ble_adv_pkt; /*!< Event parameters of ESP_BLE_MESH_SCAN_BLE_ADVERTISING_PKT_EVT */
} esp_ble_mesh_ble_cb_param_t;
/**
* @brief BLE scanning callback function type
*
* @param event: BLE scanning callback event type
* @param param: BLE scanning callback parameter
*/
typedef void (* esp_ble_mesh_ble_cb_t)(esp_ble_mesh_ble_cb_event_t event,
esp_ble_mesh_ble_cb_param_t *param);
/**
* @brief Register BLE scanning callback.
*
* @param[in] callback: Pointer to the BLE scaning callback function.
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_register_ble_callback(esp_ble_mesh_ble_cb_t callback);
/** Count for sending BLE advertising packet infinitely */
#define ESP_BLE_MESH_BLE_ADV_INFINITE 0xFFFF
/*!< This enum value is the priority of BLE advertising packet */
typedef enum {
ESP_BLE_MESH_BLE_ADV_PRIO_LOW,
ESP_BLE_MESH_BLE_ADV_PRIO_HIGH,
} esp_ble_mesh_ble_adv_priority_t;
/** Context of BLE advertising parameters. */
typedef struct {
uint16_t interval; /*!< BLE advertising interval */
uint8_t adv_type; /*!< BLE advertising type */
uint8_t own_addr_type; /*!< Own address type */
uint8_t peer_addr_type; /*!< Peer address type */
uint8_t peer_addr[BD_ADDR_LEN]; /*!< Peer address */
uint16_t duration; /*!< Duration is milliseconds */
uint16_t period; /*!< Period in milliseconds */
uint16_t count; /*!< Number of advertising duration */
uint8_t priority:2; /*!< Priority of BLE advertising packet */
} esp_ble_mesh_ble_adv_param_t;
/** Context of BLE advertising data. */
typedef struct {
uint8_t adv_data_len; /*!< Advertising data length */
uint8_t adv_data[31]; /*!< Advertising data */
uint8_t scan_rsp_data_len; /*!< Scan response data length */
uint8_t scan_rsp_data[31]; /*!< Scan response data */
} esp_ble_mesh_ble_adv_data_t;
/**
* @brief This function is called to start BLE advertising with the corresponding data
* and parameters while BLE Mesh is working at the same time.
*
* @note 1. When this function is called, the BLE advertising packet will be posted to
* the BLE mesh adv queue in the mesh stack and waited to be sent.
* 2. In the BLE advertising parameters, the "duration" means the time used for
* sending the BLE advertising packet each time, it shall not be smaller than the
* advertising interval. When the packet is sent successfully, it will be posted
* to the adv queue again after the "period" time if the "count" is bigger than 0.
* The "count" means how many durations the packet will be sent after it is sent
* successfully for the first time. And if the "count" is set to 0xFFFF, which
* means the packet will be sent infinitely.
* 3. The "priority" means the priority of BLE advertising packet compared with
* BLE Mesh packets. Currently two options (i.e. low/high) are provided. If the
* "priority" is high, the BLE advertising packet will be posted to the front of
* adv queue. Otherwise it will be posted to the back of adv queue.
*
* @param[in] param: Pointer to the BLE advertising parameters
* @param[in] data: Pointer to the BLE advertising data and scan response data
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_start_ble_advertising(const esp_ble_mesh_ble_adv_param_t *param,
const esp_ble_mesh_ble_adv_data_t *data);
/**
* @brief This function is called to stop BLE advertising with the corresponding index.
*
* @param[in] index: Index of BLE advertising
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_stop_ble_advertising(uint8_t index);
/** Context of BLE scanning parameters. */
typedef struct {
uint32_t duration; /*!< Duration used to scan normal BLE advertising packets */
} esp_ble_mesh_ble_scan_param_t;
/**
* @brief This function is called to start scanning normal BLE advertising packets
* and notifying the packets to the application layer.
*
* @param[in] param: Pointer to the BLE scanning parameters
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_start_ble_scanning(esp_ble_mesh_ble_scan_param_t *param);
/**
* @brief This function is called to stop notifying normal BLE advertising packets
* to the application layer.
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_stop_ble_scanning(void);
#ifdef __cplusplus
}
#endif
#endif /* _ESP_BLE_MESH_BLE_API_H_ */

View File

@ -17,6 +17,10 @@
#include "esp_ble_mesh_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initialize BLE Mesh module.
* This API initializes provisioning capabilities and composition data information.
@ -34,4 +38,20 @@
*/
esp_err_t esp_ble_mesh_init(esp_ble_mesh_prov_t *prov, esp_ble_mesh_comp_t *comp);
/**
* @brief De-initialize BLE Mesh module.
*
* @note This function shall be invoked after esp_ble_mesh_client_model_deinit().
*
* @param[in] param: Pointer to the structure of BLE Mesh deinit parameters.
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_deinit(esp_ble_mesh_deinit_param_t *param);
#ifdef __cplusplus
}
#endif
#endif /* _ESP_BLE_MESH_COMMON_API_H_ */

View File

@ -17,6 +17,10 @@
#include "esp_ble_mesh_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Get the model publish period, the unit is ms.
*
@ -51,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.
@ -83,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.
@ -94,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.
@ -104,4 +110,106 @@ esp_ble_mesh_model_t *esp_ble_mesh_find_sig_model(const esp_ble_mesh_elem_t *ele
*/
const esp_ble_mesh_comp_t *esp_ble_mesh_get_composition_data(void);
/**
* @brief A local model of node or Provisioner subscribes a group address.
*
* @note This function shall not be invoked before node is provisioned or Provisioner is enabled.
*
* @param[in] element_addr: Unicast address of the element to which the model belongs.
* @param[in] company_id: A 16-bit company identifier.
* @param[in] model_id: A 16-bit model identifier.
* @param[in] group_addr: The group address to be subscribed.
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_model_subscribe_group_addr(uint16_t element_addr, uint16_t company_id,
uint16_t model_id, uint16_t group_addr);
/**
* @brief A local model of node or Provisioner unsubscribes a group address.
*
* @note This function shall not be invoked before node is provisioned or Provisioner is enabled.
*
* @param[in] element_addr: Unicast address of the element to which the model belongs.
* @param[in] company_id: A 16-bit company identifier.
* @param[in] model_id: A 16-bit model identifier.
* @param[in] group_addr: The subscribed group address.
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_model_unsubscribe_group_addr(uint16_t element_addr, uint16_t company_id,
uint16_t model_id, uint16_t group_addr);
/**
* @brief This function is called by Node to get the local NetKey.
*
* @param[in] net_idx: NetKey index.
*
* @return NetKey on success, or NULL on failure.
*
*/
const uint8_t *esp_ble_mesh_node_get_local_net_key(uint16_t net_idx);
/**
* @brief This function is called by Node to get the local AppKey.
*
* @param[in] app_idx: AppKey index.
*
* @return AppKey on success, or NULL on failure.
*
*/
const uint8_t *esp_ble_mesh_node_get_local_app_key(uint16_t app_idx);
/**
* @brief This function is called by Node to add a local NetKey.
*
* @param[in] net_key: NetKey to be added.
* @param[in] net_idx: NetKey Index.
*
* @note This function can only be called after the device is provisioned.
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_node_add_local_net_key(const uint8_t net_key[16], uint16_t net_idx);
/**
* @brief This function is called by Node to add a local AppKey.
*
* @param[in] app_key: AppKey to be added.
* @param[in] net_idx: NetKey Index.
* @param[in] app_idx: AppKey Index.
*
* @note The net_idx must be an existing one.
* This function can only be called after the device is provisioned.
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_node_add_local_app_key(const uint8_t app_key[16], uint16_t net_idx, uint16_t app_idx);
/**
* @brief This function is called by Node to bind AppKey to model locally.
*
* @param[in] element_addr: Node local element address
* @param[in] company_id: Node local company id
* @param[in] model_id: Node local model id
* @param[in] app_idx: Node local appkey index
*
* @note If going to bind app_key with local vendor model, the company_id
* shall be set to 0xFFFF.
* This function can only be called after the device is provisioned.
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_node_bind_app_key_to_local_model(uint16_t element_addr, uint16_t company_id,
uint16_t model_id, uint16_t app_idx);
#ifdef __cplusplus
}
#endif
#endif /* _ESP_BLE_MESH_LOCAL_DATA_OPERATION_API_H_ */

View File

@ -17,6 +17,10 @@
#include "esp_ble_mesh_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Enable BLE Mesh device LPN functionality.
*
@ -58,4 +62,8 @@ esp_err_t esp_ble_mesh_lpn_disable(bool force);
*/
esp_err_t esp_ble_mesh_lpn_poll(void);
#ifdef __cplusplus
}
#endif
#endif /* _ESP_BLE_MESH_LOW_POWER_API_H_ */

View File

@ -17,9 +17,13 @@
#include "esp_ble_mesh_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @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.
@ -75,6 +79,18 @@ esp_err_t esp_ble_mesh_model_msg_opcode_init(uint8_t *data, uint32_t opcode);
*/
esp_err_t esp_ble_mesh_client_model_init(esp_ble_mesh_model_t *model);
/**
* @brief De-initialize the user-defined client model.
*
* @note This function shall be invoked before esp_ble_mesh_deinit() is called.
*
* @param[in] model: Pointer of the Client model.
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_client_model_deinit(esp_ble_mesh_model_t *model);
/**
* @brief Send server model messages(such as server model status messages).
*
@ -88,8 +104,9 @@ esp_err_t esp_ble_mesh_client_model_init(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).
@ -107,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.
@ -150,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.
@ -176,7 +195,7 @@ esp_err_t esp_ble_mesh_node_local_reset(void);
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_provisioner_set_node_name(int index, const char *name);
esp_err_t esp_ble_mesh_provisioner_set_node_name(uint16_t index, const char *name);
/**
* @brief This function is called to get the node (provisioned device) name.
@ -188,20 +207,119 @@ esp_err_t esp_ble_mesh_provisioner_set_node_name(int index, const char *name);
* @return Node name on success, or NULL on failure.
*
*/
const char *esp_ble_mesh_provisioner_get_node_name(int index);
const char *esp_ble_mesh_provisioner_get_node_name(uint16_t index);
/**
* @brief This function is called to get the node (provisioned device) index.
*
* @param[in] name: Name of the node (end by '\0').
*
* @return Node index on success, or (negative) error code from errno.h on failure.
* @return Node index on success, or an invalid value (0xFFFF) on failure.
*
*/
int esp_ble_mesh_provisioner_get_node_index(const char *name);
uint16_t esp_ble_mesh_provisioner_get_node_index(const char *name);
/**
* @brief This function is called to set the app key for the local BLE Mesh stack.
* @brief This function is called to store the Composition Data of the node.
*
* @param[in] unicast_addr: Element address of the node
* @param[in] data: Pointer of Composition Data
* @param[in] length: Length of Composition Data
*
* @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);
/**
* @brief This function is called to get the provisioned node information
* with the node device uuid.
*
* @param[in] uuid: Device UUID of the node
*
* @return Pointer of the node info struct or NULL on failure.
*
*/
esp_ble_mesh_node_t *esp_ble_mesh_provisioner_get_node_with_uuid(const uint8_t uuid[16]);
/**
* @brief This function is called to get the provisioned node information
* with the node unicast address.
*
* @param[in] unicast_addr: Unicast address of the node
*
* @return Pointer of the node info struct or NULL on failure.
*
*/
esp_ble_mesh_node_t *esp_ble_mesh_provisioner_get_node_with_addr(uint16_t unicast_addr);
/**
* @brief This function is called to get the provisioned node information
* with the node name.
*
* @param[in] name: Name of the node (end by '\0').
*
* @return Pointer of the node info struct or NULL on failure.
*
*/
esp_ble_mesh_node_t *esp_ble_mesh_provisioner_get_node_with_name(const char *name);
/**
* @brief This function is called by Provisioner to get provisioned node count.
*
* @return Number of the provisioned nodes.
*
*/
uint16_t esp_ble_mesh_provisioner_get_prov_node_count(void);
/**
* @brief This function is called by Provisioner to get the entry of the node table.
*
* @note After invoking the function to get the entry of nodes, users can use the "for"
* loop combined with the macro CONFIG_BLE_MESH_MAX_PROV_NODES to get each node's
* information. Before trying to read the node's information, users need to check
* if the node exists, i.e. if the *(esp_ble_mesh_node_t **node) is NULL.
* For example:
* ```
* const esp_ble_mesh_node_t **entry = esp_ble_mesh_provisioner_get_node_table_entry();
* for (int i = 0; i < CONFIG_BLE_MESH_MAX_PROV_NODES; i++) {
* const esp_ble_mesh_node_t *node = entry[i];
* if (node) {
* ......
* }
* }
* ```
*
* @return Pointer to the start of the node table.
*
*/
const esp_ble_mesh_node_t **esp_ble_mesh_provisioner_get_node_table_entry(void);
/**
* @brief This function is called to delete the provisioned node information
* with the node device uuid.
*
* @param[in] uuid: Device UUID of the node
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_provisioner_delete_node_with_uuid(const uint8_t uuid[16]);
/**
* @brief This function is called to delete the provisioned node information
* with the node unicast address.
*
* @param[in] unicast_addr: Unicast address of the node
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_provisioner_delete_node_with_addr(uint16_t unicast_addr);
/**
* @brief This function is called to add a local AppKey for Provisioner.
*
* @param[in] app_key: The app key to be set for the local BLE Mesh stack.
* @param[in] net_idx: The network key index.
@ -215,7 +333,21 @@ int 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_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.
*
* @param[in] app_key: Value of the AppKey.
* @param[in] net_idx: Corresponding NetKey Index.
* @param[in] app_idx: The AppKey Index
*
* @return ESP_OK on success or error code otherwise.
*
*/
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);
/**
* @brief This function is called by Provisioner to get the local app key value.
@ -243,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.
@ -260,6 +392,17 @@ esp_err_t esp_ble_mesh_provisioner_bind_app_key_to_local_model(uint16_t element_
*/
esp_err_t esp_ble_mesh_provisioner_add_local_net_key(const uint8_t net_key[16], uint16_t net_idx);
/**
* @brief This function is called by Provisioner to update a local network key.
*
* @param[in] net_key: Value of the NetKey.
* @param[in] net_idx: The NetKey Index.
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_provisioner_update_local_net_key(const uint8_t net_key[16], uint16_t net_idx);
/**
* @brief This function is called by Provisioner to get the local network key value.
*
@ -270,6 +413,231 @@ esp_err_t esp_ble_mesh_provisioner_add_local_net_key(const uint8_t net_key[16],
*/
const uint8_t *esp_ble_mesh_provisioner_get_local_net_key(uint16_t net_idx);
/**
* @brief This function is called by Provisioner to enable or disable receiving
* heartbeat messages.
*
* @note If enabling receiving heartbeat message successfully, the filter will
* be an empty rejectlist by default, which means all heartbeat messages
* received by the Provisioner will be reported to the application layer.
*
* @param[in] enable: Enable or disable receiving heartbeat messages.
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_provisioner_recv_heartbeat(bool enable);
/**
* @brief This function is called by Provisioner to set the heartbeat filter type.
*
* @note 1. If the filter type is not the same with the current value, then all the
* filter entries will be cleaned.
* 2. If the previous type is rejectlist, and changed to acceptlist, then the
* filter will be an empty acceptlist, which means no heartbeat messages
* will be reported. Users need to add SRC or DST into the filter entry,
* then heartbeat messages from the SRC or to the DST will be reported.
*
* @param[in] type: Heartbeat filter type (acceptlist or rejectlist).
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_provisioner_set_heartbeat_filter_type(uint8_t type);
/**
* @brief This function is called by Provisioner to add or remove a heartbeat filter entry.
*
* @note 1. If the operation is "ADD", the "hb_src" can be set to the SRC (can only be a
* unicast address) of heartbeat messages, and the "hb_dst" can be set to the
* DST (unicast address or group address), at least one of them needs to be set.
* - If only one of them is set, the filter entry will only use the configured
* SRC or DST to filter heartbeat messages.
* - If both of them are set, the SRC and DST will both be used to decide if a
* heartbeat message will be handled.
* - If SRC or DST already exists in some filter entry, then the corresponding
* entry will be cleaned firstly, then a new entry will be allocated to store
* the information.
* 2. If the operation is "REMOVE", the "hb_src" can be set to the SRC (can only be
* a unicast address) of heartbeat messages, and the "hb_dst" can be set to the
* DST (unicast address or group address), at least one of them needs to be set.
* - The filter entry with the same SRC or DST will be removed.
*
* @param[in] op: Add or REMOVE
* @param[in] info: Heartbeat filter entry information, including:
* hb_src - Heartbeat source address;
* hb_dst - Heartbeat destination address;
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_provisioner_set_heartbeat_filter_info(uint8_t op, esp_ble_mesh_heartbeat_filter_info_t *info);
/**
* @brief This function is called by Provisioner to directly erase the mesh
* information from nvs namespace.
*
* @note This function can be invoked when the mesh stack is not initialized
* or has been de-initialized.
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_provisioner_direct_erase_settings(void);
/**
* @brief This function is called by Provisioner to open a nvs namespace
* for storing mesh information.
*
* @note Before open another nvs namespace, the previously opened nvs
* namespace must be closed firstly.
*
* @param[in] index: Settings index.
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_provisioner_open_settings_with_index(uint8_t index);
/**
* @brief This function is called by Provisioner to open a nvs namespace
* for storing mesh information.
*
* @note Before open another nvs namespace, the previously opened nvs
* namespace must be closed firstly.
*
* @param[in] uid: Settings user id.
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_provisioner_open_settings_with_uid(const char *uid);
/**
* @brief This function is called by Provisioner to close a nvs namespace
* which is opened previously for storing mesh information.
*
* @note 1. Before closing the nvs namespace, it must be open.
* 2. When the function is invoked, the Provisioner functionality
* will be disabled firstly, and:
* a) If the "erase" flag is set to false, the mesh information
* will be cleaned (e.g. removing NetKey, AppKey, nodes, etc)
* from the mesh stack.
* b) If the "erase" flag is set to true, the mesh information
* stored in the nvs namespace will also be erased besides
* been cleaned from the mesh stack.
* 3. If Provisioner tries to work properly again, we can invoke the
* open function to open a new nvs namespace or a previously added
* one, and restore the mesh information from it if not erased.
* 4. The working process shall be as following:
* a) Open settings A
* b) Start to provision and control nodes
* c) Close settings A
* d) Open settings B
* e) Start to provision and control other nodes
* f) Close settings B
* g) ......
*
* @param[in] index: Settings index.
* @param[in] erase: Indicate if erasing mesh information.
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_provisioner_close_settings_with_index(uint8_t index, bool erase);
/**
* @brief This function is called by Provisioner to close a nvs namespace
* which is opened previously for storing mesh information.
*
* @note 1. Before closing the nvs namespace, it must be open.
* 2. When the function is invoked, the Provisioner functionality
* will be disabled firstly, and:
* a) If the "erase" flag is set to false, the mesh information
* will be cleaned (e.g. removing NetKey, AppKey, nodes, etc)
* from the mesh stack.
* b) If the "erase" flag is set to true, the mesh information
* stored in the nvs namespace will also be erased besides
* been cleaned from the mesh stack.
* 3. If Provisioner tries to work properly again, we can invoke the
* open function to open a new nvs namespace or a previously added
* one, and restore the mesh information from it if not erased.
* 4. The working process shall be as following:
* a) Open settings A
* b) Start to provision and control nodes
* c) Close settings A
* d) Open settings B
* e) Start to provision and control other nodes
* f) Close settings B
* g) ......
*
* @param[in] uid: Settings user id.
* @param[in] erase: Indicate if erasing mesh information.
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_provisioner_close_settings_with_uid(const char *uid, bool erase);
/**
* @brief This function is called by Provisioner to erase the mesh information
* and settings user id from a nvs namespace.
*
* @note When this function is called, the nvs namespace must not be open.
* This function is used to erase the mesh information and settings
* user id which are not used currently.
*
* @param[in] index: Settings index.
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_provisioner_delete_settings_with_index(uint8_t index);
/**
* @brief This function is called by Provisioner to erase the mesh information
* and settings user id from a nvs namespace.
*
* @note When this function is called, the nvs namespace must not be open.
* This function is used to erase the mesh information and settings
* user id which are not used currently.
*
* @param[in] uid: Settings user id.
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_provisioner_delete_settings_with_uid(const char *uid);
/**
* @brief This function is called by Provisioner to get settings user id.
*
* @param[in] index: Settings index.
*
* @return Setting user id on success or NULL on failure.
*
*/
const char *esp_ble_mesh_provisioner_get_settings_uid(uint8_t index);
/**
* @brief This function is called by Provisioner to get settings index.
*
* @param[in] uid: Settings user id.
*
* @return Settings index.
*
*/
uint8_t esp_ble_mesh_provisioner_get_settings_index(const char *uid);
/**
* @brief This function is called by Provisioner to get the number of free
* settings user id.
*
* @return Number of free settings user id.
*
*/
uint8_t esp_ble_mesh_provisioner_get_free_settings_count(void);
/**
* @brief This function is called to get fast provisioning application key.
*
@ -281,4 +649,8 @@ const uint8_t *esp_ble_mesh_provisioner_get_local_net_key(uint16_t net_idx);
*/
const uint8_t *esp_ble_mesh_get_fast_prov_app_key(uint16_t net_idx, uint16_t app_idx);
#ifdef __cplusplus
}
#endif
#endif /* _ESP_BLE_MESH_NETWORKING_API_H_ */

View File

@ -17,6 +17,10 @@
#include "esp_ble_mesh_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @brief: event, event code of provisioning events; param, parameters of provisioning events */
typedef void (* esp_ble_mesh_prov_cb_t)(esp_ble_mesh_prov_cb_event_t event,
esp_ble_mesh_prov_cb_param_t *param);
@ -72,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.
@ -124,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.
@ -228,15 +232,42 @@ 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 and assign a fixed unicast address for it in advance.
*
* @param[in] uuid: Device UUID of the unprovisioned device
* @param[in] addr: Device address of the unprovisioned device
* @param[in] addr_type: Device address type of the unprovisioned device
* @param[in] bearer: Provisioning bearer going to be used by Provisioner
* @param[in] oob_info: OOB info of the unprovisioned device
* @param[in] unicast_addr: Unicast address going to be allocated for the unprovisioned device
*
* @return Zero on success or (negative) error code otherwise.
*
* @note: 1. Currently address type only supports public address and static random address.
* 2. Bearer must be equal to ESP_BLE_MESH_PROV_ADV or ESP_BLE_MESH_PROV_GATT, since
* Provisioner will start to provision a device immediately once this function is
* invoked. And the input bearer must be identical with the one within the parameters
* of the ESP_BLE_MESH_PROVISIONER_RECV_UNPROV_ADV_PKT_EVT event.
* 3. If this function is used by a Provisioner to provision devices, the application
* should take care of the assigned unicast address and avoid overlap of the unicast
* addresses of different nodes.
* 4. Recommend to use only one of the functions "esp_ble_mesh_provisioner_add_unprov_dev"
* 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);
/**
* @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.
*
@ -260,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
@ -277,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
@ -290,6 +321,41 @@ esp_err_t esp_ble_mesh_provisioner_set_dev_uuid_match(const uint8_t *match_val,
*/
esp_err_t esp_ble_mesh_provisioner_set_prov_data_info(esp_ble_mesh_prov_data_info_t *prov_data_info);
/**
* @brief This function is called by Provisioner to set static oob value used for provisioning.
*
* @note The Bluetooth SIG recommends that mesh implementations enforce a randomly selected
* AuthValue using all of the available bits, where permitted by the implementation.
* A large entropy helps ensure that a brute-force of the AuthValue, even a static
* AuthValue, cannot normally be completed in a reasonable time (CVE-2020-26557).
*
* @param[in] value: Pointer to the static oob value.
* @param[in] length: Length of the static oob value.
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_provisioner_set_static_oob_value(const uint8_t *value, uint8_t length);
/**
* @brief This function is called by Provisioner to set own Primary element address.
*
* @note This API must be invoked when BLE Mesh initialization is completed successfully,
* and can be invoked before Provisioner functionality is enabled.
* Once this API is invoked successfully, the prov_unicast_addr value in the struct
* esp_ble_mesh_prov_t will be ignored, and Provisioner will use this address as its
* own primary element address.
* And if the unicast address going to assigned for the next unprovisioned device is
* smaller than the input address + element number of Provisioner, then the address
* for the next unprovisioned device will be recalculated internally.
*
* @param[in] addr: Unicast address of the Primary element of Provisioner.
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_provisioner_set_primary_elem_addr(uint16_t addr);
/**
* @brief This function is called to set provisioning data information before starting
* fast provisioning.
@ -311,4 +377,8 @@ esp_err_t esp_ble_mesh_set_fast_prov_info(esp_ble_mesh_fast_prov_info_t *fast_pr
*/
esp_err_t esp_ble_mesh_set_fast_prov_action(esp_ble_mesh_fast_prov_action_t action);
#ifdef __cplusplus
}
#endif
#endif /* _ESP_BLE_MESH_PROVISIONING_API_H_ */

View File

@ -17,6 +17,10 @@
#include "esp_ble_mesh_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Enable advertising with Node Identity.
*
@ -61,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.
@ -83,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.
@ -97,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.
@ -111,8 +116,12 @@ 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
}
#endif
#endif /* _ESP_BLE_MESH_PROXY_API_H_ */

File diff suppressed because it is too large Load Diff

View File

@ -14,12 +14,12 @@
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include "btc_ble_mesh_config_model.h"
#include "esp_ble_mesh_config_model_api.h"
#if CONFIG_BLE_MESH_CFG_CLI
esp_err_t esp_ble_mesh_register_config_client_callback(esp_ble_mesh_cfg_client_cb_t callback)
{
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
@ -27,20 +27,35 @@ esp_err_t esp_ble_mesh_register_config_client_callback(esp_ble_mesh_cfg_client_c
return (btc_profile_cb_set(BTC_PID_CONFIG_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_register_config_server_callback(esp_ble_mesh_cfg_server_cb_t callback)
static bool config_client_get_need_param(esp_ble_mesh_opcode_t opcode)
{
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
return (btc_profile_cb_set(BTC_PID_CONFIG_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
switch (opcode) {
case ESP_BLE_MESH_MODEL_OP_COMPOSITION_DATA_GET:
case ESP_BLE_MESH_MODEL_OP_MODEL_PUB_GET:
case ESP_BLE_MESH_MODEL_OP_SIG_MODEL_SUB_GET:
case ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_SUB_GET:
case ESP_BLE_MESH_MODEL_OP_APP_KEY_GET:
case ESP_BLE_MESH_MODEL_OP_NODE_IDENTITY_GET:
case ESP_BLE_MESH_MODEL_OP_SIG_MODEL_APP_GET:
case ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_APP_GET:
case ESP_BLE_MESH_MODEL_OP_KEY_REFRESH_PHASE_GET:
case ESP_BLE_MESH_MODEL_OP_LPN_POLLTIMEOUT_GET:
return true;
default:
return false;
}
}
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};
if (!params || !params->model || !params->ctx.addr || !get_state) {
if (params == NULL || params->model == NULL ||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
!ESP_BLE_MESH_ADDR_IS_UNICAST(params->ctx.addr) ||
(config_client_get_need_param(params->opcode) && get_state == NULL)) {
return ESP_ERR_INVALID_ARG;
}
@ -57,12 +72,15 @@ 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};
if (!params || !params->model || !params->ctx.addr || !set_state) {
if (params == NULL || params->model == NULL ||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
!ESP_BLE_MESH_ADDR_IS_UNICAST(params->ctx.addr) ||
(params->opcode != ESP_BLE_MESH_MODEL_OP_NODE_RESET && set_state == NULL)) {
return ESP_ERR_INVALID_ARG;
}
@ -77,3 +95,11 @@ esp_err_t esp_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param_
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_config_client_args_t), btc_ble_mesh_config_client_arg_deep_copy)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif /* CONFIG_BLE_MESH_CFG_CLI */
esp_err_t esp_ble_mesh_register_config_server_callback(esp_ble_mesh_cfg_server_cb_t callback)
{
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
return (btc_profile_cb_set(BTC_PID_CONFIG_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
}

View File

@ -14,12 +14,12 @@
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include "btc_ble_mesh_generic_model.h"
#include "esp_ble_mesh_generic_model_api.h"
#if CONFIG_BLE_MESH_GENERIC_CLIENT
esp_err_t esp_ble_mesh_register_generic_client_callback(esp_ble_mesh_generic_client_cb_t callback)
{
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
@ -27,13 +27,30 @@ esp_err_t esp_ble_mesh_register_generic_client_callback(esp_ble_mesh_generic_cli
return (btc_profile_cb_set(BTC_PID_GENERIC_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
}
static bool generic_client_get_need_param(esp_ble_mesh_opcode_t opcode)
{
switch (opcode) {
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_GET:
case ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_GET:
case ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTY_GET:
case ESP_BLE_MESH_MODEL_OP_GEN_CLIENT_PROPERTIES_GET:
return true;
default:
return false;
}
}
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};
if (!params || !params->model || !params->ctx.addr || !get_state) {
if (params == NULL || params->model == NULL ||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED ||
(generic_client_get_need_param(params->opcode) && get_state == NULL)) {
return ESP_ERR_INVALID_ARG;
}
@ -50,12 +67,15 @@ 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};
if (!params || !params->model || !params->ctx.addr || !set_state) {
if (params == NULL || params->model == NULL || set_state == NULL ||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED) {
return ESP_ERR_INVALID_ARG;
}
@ -70,10 +90,13 @@ esp_err_t esp_ble_mesh_generic_client_set_state(esp_ble_mesh_client_common_param
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_generic_client_args_t), btc_ble_mesh_generic_client_arg_deep_copy)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif /* CONFIG_BLE_MESH_GENERIC_CLIENT */
#if CONFIG_BLE_MESH_GENERIC_SERVER
esp_err_t esp_ble_mesh_register_generic_server_callback(esp_ble_mesh_generic_server_cb_t callback)
{
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
return (btc_profile_cb_set(BTC_PID_GENERIC_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
}
#endif /* CONFIG_BLE_MESH_GENERIC_SERVER */

View File

@ -14,12 +14,12 @@
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include "btc_ble_mesh_health_model.h"
#include "esp_ble_mesh_health_model_api.h"
#if CONFIG_BLE_MESH_HEALTH_CLI
esp_err_t esp_ble_mesh_register_health_client_callback(esp_ble_mesh_health_client_cb_t callback)
{
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
@ -27,20 +27,17 @@ esp_err_t esp_ble_mesh_register_health_client_callback(esp_ble_mesh_health_clien
return (btc_profile_cb_set(BTC_PID_HEALTH_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_register_health_server_callback(esp_ble_mesh_health_server_cb_t callback)
{
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
return (btc_profile_cb_set(BTC_PID_HEALTH_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
}
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};
if (!params || !params->model || !params->ctx.addr || !get_state) {
if (params == NULL || params->model == NULL ||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED ||
(params->opcode == ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET && get_state == NULL)) {
return ESP_ERR_INVALID_ARG;
}
@ -57,12 +54,15 @@ 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};
if (!params || !params->model || !params->ctx.addr || !set_state) {
if (params == NULL || params->model == NULL || set_state == NULL ||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED) {
return ESP_ERR_INVALID_ARG;
}
@ -77,6 +77,15 @@ esp_err_t esp_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param_
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_health_client_args_t), btc_ble_mesh_health_client_arg_deep_copy)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif /* CONFIG_BLE_MESH_HEALTH_CLI */
#if CONFIG_BLE_MESH_HEALTH_SRV
esp_err_t esp_ble_mesh_register_health_server_callback(esp_ble_mesh_health_server_cb_t callback)
{
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
return (btc_profile_cb_set(BTC_PID_HEALTH_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_health_server_fault_update(esp_ble_mesh_elem_t *element)
{
@ -97,3 +106,4 @@ esp_err_t esp_ble_mesh_health_server_fault_update(esp_ble_mesh_elem_t *element)
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_health_server_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif /* CONFIG_BLE_MESH_HEALTH_SRV */

View File

@ -14,12 +14,12 @@
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include "btc_ble_mesh_lighting_model.h"
#include "esp_ble_mesh_lighting_model_api.h"
#if CONFIG_BLE_MESH_LIGHTING_CLIENT
esp_err_t esp_ble_mesh_register_light_client_callback(esp_ble_mesh_light_client_cb_t callback)
{
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
@ -28,12 +28,16 @@ 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};
if (!params || !params->model || !params->ctx.addr || !get_state) {
if (params == NULL || params->model == NULL ||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED ||
(params->opcode == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_GET && get_state == NULL)) {
return ESP_ERR_INVALID_ARG;
}
@ -50,12 +54,15 @@ 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};
if (!params || !params->model || !params->ctx.addr || !set_state) {
if (params == NULL || params->model == NULL || set_state == NULL ||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED) {
return ESP_ERR_INVALID_ARG;
}
@ -70,10 +77,13 @@ esp_err_t esp_ble_mesh_light_client_set_state(esp_ble_mesh_client_common_param_t
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_lighting_client_args_t), btc_ble_mesh_lighting_client_arg_deep_copy)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif /* CONFIG_BLE_MESH_LIGHTING_CLIENT */
#if CONFIG_BLE_MESH_LIGHTING_SERVER
esp_err_t esp_ble_mesh_register_lighting_server_callback(esp_ble_mesh_lighting_server_cb_t callback)
{
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
return (btc_profile_cb_set(BTC_PID_LIGHTING_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
}
#endif /* CONFIG_BLE_MESH_LIGHTING_SERVER */

View File

@ -14,12 +14,12 @@
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include "btc_ble_mesh_sensor_model.h"
#include "esp_ble_mesh_sensor_model_api.h"
#if CONFIG_BLE_MESH_SENSOR_CLI
esp_err_t esp_ble_mesh_register_sensor_client_callback(esp_ble_mesh_sensor_client_cb_t callback)
{
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
@ -28,12 +28,15 @@ 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};
if (!params || !params->model || !params->ctx.addr || !get_state) {
if (params == NULL || params->model == NULL || get_state == NULL ||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED) {
return ESP_ERR_INVALID_ARG;
}
@ -50,12 +53,15 @@ 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};
if (!params || !params->model || !params->ctx.addr || !set_state) {
if (params == NULL || params->model == NULL || set_state == NULL ||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED) {
return ESP_ERR_INVALID_ARG;
}
@ -70,12 +76,13 @@ esp_err_t esp_ble_mesh_sensor_client_set_state(esp_ble_mesh_client_common_param_
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_sensor_client_args_t), btc_ble_mesh_sensor_client_arg_deep_copy)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif /* CONFIG_BLE_MESH_SENSOR_CLI */
#if CONFIG_BLE_MESH_SENSOR_SERVER
esp_err_t esp_ble_mesh_register_sensor_server_callback(esp_ble_mesh_sensor_server_cb_t callback)
{
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
return (btc_profile_cb_set(BTC_PID_SENSOR_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
}
#endif /* CONFIG_BLE_MESH_SENSOR_SERVER */

View File

@ -14,12 +14,12 @@
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include "btc_ble_mesh_time_scene_model.h"
#include "esp_ble_mesh_time_scene_model_api.h"
#if CONFIG_BLE_MESH_TIME_SCENE_CLIENT
esp_err_t esp_ble_mesh_register_time_scene_client_callback(esp_ble_mesh_time_scene_client_cb_t callback)
{
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
@ -28,12 +28,16 @@ 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};
if (!params || !params->model || !params->ctx.addr || !get_state) {
if (params == NULL || params->model == NULL ||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED ||
(params->opcode == ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_GET && get_state == NULL)) {
return ESP_ERR_INVALID_ARG;
}
@ -50,12 +54,15 @@ 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};
if (!params || !params->model || !params->ctx.addr || !set_state) {
if (params == NULL || params->model == NULL || set_state == NULL ||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED) {
return ESP_ERR_INVALID_ARG;
}
@ -70,11 +77,13 @@ esp_err_t esp_ble_mesh_time_scene_client_set_state(esp_ble_mesh_client_common_pa
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_time_scene_client_args_t), btc_ble_mesh_time_scene_client_arg_deep_copy)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif /* CONFIG_BLE_MESH_TIME_SCENE_CLIENT */
#if CONFIG_BLE_MESH_TIME_SCENE_SERVER
esp_err_t esp_ble_mesh_register_time_scene_server_callback(esp_ble_mesh_time_scene_server_cb_t callback)
{
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
return (btc_profile_cb_set(BTC_PID_TIME_SCENE_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
}
#endif /* CONFIG_BLE_MESH_TIME_SCENE_SERVER */

View File

@ -17,6 +17,10 @@
#include "esp_ble_mesh_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @def ESP_BLE_MESH_MODEL_CFG_SRV
*
* @brief Define a new Config Server Model.
@ -752,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
@ -760,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.
@ -796,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.
@ -812,7 +816,11 @@ 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);
#endif /** _ESP_BLE_MESH_CONFIG_MODEL_API_H_ */
#ifdef __cplusplus
}
#endif
#endif /* _ESP_BLE_MESH_CONFIG_MODEL_API_H_ */

View File

@ -21,6 +21,10 @@
#include "esp_ble_mesh_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @def ESP_BLE_MESH_MODEL_GEN_ONOFF_CLI
*
* @brief Define a new Generic OnOff Client Model.
@ -256,7 +260,7 @@ typedef struct {
/** Parameters of Generic Admin Property Set. */
typedef struct {
uint16_t property_id; /*!< Property ID identifying a Generic Admin Property */
uint8_t user_access; /*!< Enumeration indicating user accessn */
uint8_t user_access; /*!< Enumeration indicating user access */
struct net_buf_simple *property_value; /*!< Raw value for the Admin Property */
} esp_ble_mesh_gen_admin_property_set_t;
@ -363,10 +367,10 @@ typedef struct {
/** Parameters of Generic Battery Status. */
typedef struct {
u32_t battery_level : 8; /*!< Value of Generic Battery Level state */
u32_t time_to_discharge : 24; /*!< Value of Generic Battery Time to Discharge state */
u32_t time_to_charge : 24; /*!< Value of Generic Battery Time to Charge state */
u32_t flags : 8; /*!< Value of Generic Battery Flags state */
uint32_t battery_level : 8; /*!< Value of Generic Battery Level state */
uint32_t time_to_discharge : 24; /*!< Value of Generic Battery Time to Discharge state */
uint32_t time_to_charge : 24; /*!< Value of Generic Battery Time to Charge state */
uint32_t flags : 8; /*!< Value of Generic Battery Flags state */
} esp_ble_mesh_gen_battery_status_cb_t;
/** Parameters of Generic Location Global Status. */
@ -479,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.
@ -505,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.
@ -521,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.
@ -1281,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.
@ -1293,5 +1297,9 @@ typedef void (* esp_ble_mesh_generic_server_cb_t)(esp_ble_mesh_generic_server_cb
*/
esp_err_t esp_ble_mesh_register_generic_server_callback(esp_ble_mesh_generic_server_cb_t callback);
#ifdef __cplusplus
}
#endif
#endif /* _ESP_BLE_MESH_GENERIC_MODEL_API_H_ */

View File

@ -17,6 +17,10 @@
#include "esp_ble_mesh_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @def ESP_BLE_MESH_MODEL_HEALTH_SRV
*
* @brief Define a new Health Server Model.
@ -331,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
@ -339,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.
@ -375,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.
@ -391,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.
@ -403,4 +407,8 @@ esp_err_t esp_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param_
*/
esp_err_t esp_ble_mesh_health_server_fault_update(esp_ble_mesh_elem_t *element);
#endif /** _ESP_BLE_MESH_HEALTH_MODEL_API_H_ */
#ifdef __cplusplus
}
#endif
#endif /* _ESP_BLE_MESH_HEALTH_MODEL_API_H_ */

View File

@ -21,6 +21,10 @@
#include "esp_ble_mesh_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @def ESP_BLE_MESH_MODEL_LIGHT_LIGHTNESS_CLI
*
* @brief Define a new Light Lightness Client Model.
@ -535,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.
@ -561,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.
@ -577,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.
@ -1061,7 +1065,7 @@ typedef struct {
* Occupancy state upon receiving a Sensor Status message from an
* occupancy sensor.
*/
uint32_t time_occupancy_delay; /*!< The value of Light LC Time Occupany Delay state */
uint32_t time_occupancy_delay; /*!< The value of Light LC Time Occupancy Delay state */
/**
* A timing state that determines the time the controlled lights fade
* to the level determined by the Light LC Lightness On state.
@ -1341,7 +1345,7 @@ typedef struct {
/** Parameter of Light LC Occupancy Mode state change event */
typedef struct {
uint8_t mode; /*!< The value of Light LC Occupany Mode state */
uint8_t mode; /*!< The value of Light LC Occupancy Mode state */
} esp_ble_mesh_state_change_light_lc_om_set_t;
/** Parameter of Light LC Light OnOff state change event */
@ -1659,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.
@ -1671,5 +1675,9 @@ typedef void (* esp_ble_mesh_lighting_server_cb_t)(esp_ble_mesh_lighting_server_
*/
esp_err_t esp_ble_mesh_register_lighting_server_callback(esp_ble_mesh_lighting_server_cb_t callback);
#ifdef __cplusplus
}
#endif
#endif /* _ESP_BLE_MESH_LIGHTING_MODEL_API_H_ */

View File

@ -21,6 +21,10 @@
#include "esp_ble_mesh_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @def ESP_BLE_MESH_MODEL_SENSOR_CLI
*
* @brief Define a new Sensor Client Model.
@ -211,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.
@ -237,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.
@ -253,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.
@ -345,6 +349,91 @@ esp_err_t esp_ble_mesh_sensor_client_set_state(esp_ble_mesh_client_common_param_
*/
#define ESP_BLE_MESH_SENSOR_DATA_ZERO_LEN 0x7F
/** @def ESP_BLE_MESH_GET_SENSOR_DATA_FORMAT
*
* @brief Get format of the sensor data.
*
* @note Multiple sensor data may be concatenated. Make sure the _data pointer is
* updated before getting the format of the corresponding sensor data.
*
* @param _data Pointer to the start of the sensor data.
*
* @return Format of the sensor data.
*/
#define ESP_BLE_MESH_GET_SENSOR_DATA_FORMAT(_data) (((_data)[0]) & BIT_MASK(1))
/** @def ESP_BLE_MESH_GET_SENSOR_DATA_LENGTH
*
* @brief Get length of the sensor data.
*
* @note Multiple sensor data may be concatenated. Make sure the _data pointer is
* updated before getting the length of the corresponding sensor data.
*
* @param _data Pointer to the start of the sensor data.
* @param _fmt Format of the sensor data.
*
* @return Length (zero-based) of the sensor data.
*/
#define ESP_BLE_MESH_GET_SENSOR_DATA_LENGTH(_data, _fmt) \
(((_fmt) == ESP_BLE_MESH_SENSOR_DATA_FORMAT_A) ? ((((_data)[0]) >> 1) & BIT_MASK(4)) : ((((_data)[0]) >> 1) & BIT_MASK(7)))
/** @def ESP_BLE_MESH_GET_SENSOR_DATA_PROPERTY_ID
*
* @brief Get Sensor Property ID of the sensor data.
*
* @note Multiple sensor data may be concatenated. Make sure the _data pointer is
* updated before getting Sensor Property ID of the corresponding sensor data.
*
* @param _data Pointer to the start of the sensor data.
* @param _fmt Format of the sensor data.
*
* @return Sensor Property ID of the sensor data.
*/
#define ESP_BLE_MESH_GET_SENSOR_DATA_PROPERTY_ID(_data, _fmt) \
(((_fmt) == ESP_BLE_MESH_SENSOR_DATA_FORMAT_A) ? ((((_data)[1]) << 3) | (((_data)[0]) >> 5)) : ((((_data)[2]) << 8) | ((_data)[1])))
/** @def ESP_BLE_MESH_SENSOR_DATA_FORMAT_A_MPID
*
* @brief Generate a MPID value for sensor data with Format A.
*
* @note 1. The Format field is 0b0 and indicates that Format A is used.
* 2. The Length field is a 1-based uint4 value (valid range 0x00xF,
* representing range of 116).
* 3. The Property ID is an 11-bit bit field representing 11 LSb of a Property ID.
* 4. This format may be used for Property Values that are not longer than 16
* octets and for Property IDs less than 0x0800.
*
* @param _len Length of Sensor Raw value.
* @param _id Sensor Property ID.
*
* @return 2-octet MPID value for sensor data with Format A.
*
*/
#define ESP_BLE_MESH_SENSOR_DATA_FORMAT_A_MPID(_len, _id) \
((((_id) & BIT_MASK(11)) << 5) | (((_len) & BIT_MASK(4)) << 1) | ESP_BLE_MESH_SENSOR_DATA_FORMAT_A)
/** @def ESP_BLE_MESH_SENSOR_DATA_FORMAT_B_MPID
*
* @brief Generate a MPID value for sensor data with Format B.
*
* @note 1. The Format field is 0b1 and indicates Format B is used.
* 2. The Length field is a 1-based uint7 value (valid range 0x00x7F, representing
* range of 1127). The value 0x7F represents a length of zero.
* 3. The Property ID is a 16-bit bit field representing a Property ID.
* 4. This format may be used for Property Values not longer than 128 octets and for
* any Property IDs. Property values longer than 128 octets are not supported by
* the Sensor Status message.
* 5. Exclude the generated 1-octet value, the 2-octet Sensor Property ID
*
* @param _len Length of Sensor Raw value.
* @param _id Sensor Property ID.
*
* @return 3-octet MPID value for sensor data with Format B.
*
*/
#define ESP_BLE_MESH_SENSOR_DATA_FORMAT_B_MPID(_len, _id) \
(((_id) << 8) | (((_len) & BIT_MASK(7)) << 1) | ESP_BLE_MESH_SENSOR_DATA_FORMAT_B)
/** This enum value is value of Sensor Sampling Function */
enum esp_ble_mesh_sensor_sample_func {
ESP_BLE_MESH_SAMPLE_FUNC_UNSPECIFIED,
@ -523,7 +612,7 @@ typedef struct {
typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */
uint16_t property_id; /*!< Property identifying a sensor */
struct net_buf_simple *raw_value; /*!< Raw value containg X1 and X2 (optional) */
struct net_buf_simple *raw_value; /*!< Raw value containing X1 and X2 (optional) */
} esp_ble_mesh_server_recv_sensor_series_get_t;
/**
@ -609,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.
@ -621,6 +710,10 @@ typedef void (* esp_ble_mesh_sensor_server_cb_t)(esp_ble_mesh_sensor_server_cb_e
*/
esp_err_t esp_ble_mesh_register_sensor_server_callback(esp_ble_mesh_sensor_server_cb_t callback);
#ifdef __cplusplus
}
#endif
#endif /* _ESP_BLE_MESH_SENSOR_MODEL_API_H_ */

View File

@ -21,6 +21,10 @@
#include "esp_ble_mesh_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @def ESP_BLE_MESH_MODEL_TIME_CLI
*
* @brief Define a new Time Client Model.
@ -272,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.
@ -297,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.
@ -312,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.
@ -434,11 +438,11 @@ esp_err_t esp_ble_mesh_time_scene_client_set_state(esp_ble_mesh_client_common_pa
#define ESP_BLE_MESH_UNKNOWN_TAI_ZONE_CHANGE 0x0000000000 /*!< Unknown TAI of Zone Change */
#define ESP_BLE_MESH_UNKNOWN_TAI_DELTA_CHANGE 0x0000000000 /*!< Unknown TAI of Delta Change */
#define ESP_BLE_MESH_TAI_UTC_DELAT_MAX_VALUE 0x7FFF /*!< Maximum TAI-UTC Delta value */
#define ESP_BLE_MESH_TAI_UTC_DELTA_MAX_VALUE 0x7FFF /*!< Maximum TAI-UTC Delta value */
#define ESP_BLE_MESH_TAI_SECONDS_LEN 0x05 /*!< Length of TAI Seconds */
#define ESP_BLE_MESH_TAI_OF_ZONE_CHANGE_LEN 0x05 /*!< Length of TAI of Zone Change */
#define ESP_BLE_MESH_TAI_OF_DELAT_CHANGE_LEN 0x05 /*!< Length of TAI of Delta Change */
#define ESP_BLE_MESH_TAI_OF_DELTA_CHANGE_LEN 0x05 /*!< Length of TAI of Delta Change */
#define ESP_BLE_MESH_INVALID_SCENE_NUMBER 0x0000 /*!< Invalid Scene Number */
#define ESP_BLE_MESH_SCENE_NUMBER_LEN 0x02 /*!< Length of the Scene Number */
@ -896,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.
@ -908,5 +912,9 @@ typedef void (* esp_ble_mesh_time_scene_server_cb_t)(esp_ble_mesh_time_scene_ser
*/
esp_err_t esp_ble_mesh_register_time_scene_server_callback(esp_ble_mesh_time_scene_server_cb_t callback);
#ifdef __cplusplus
}
#endif
#endif /* _ESP_BLE_MESH_TIME_SCENE_MODEL_API_H_ */

View File

@ -0,0 +1,203 @@
// Copyright 2020 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <stdint.h>
#include <string.h>
#include "btc_ble_mesh_ble.h"
#include "adv.h"
#include "scan.h"
#include "mesh_bearer_adapt.h"
#include "esp_ble_mesh_ble_api.h"
#if CONFIG_BLE_MESH_BLE_COEX_SUPPORT
static void btc_ble_mesh_ble_copy_req_data(btc_msg_t *msg, void *p_dst, void *p_src)
{
#if CONFIG_BLE_MESH_SUPPORT_BLE_SCAN
esp_ble_mesh_ble_cb_param_t *p_dst_data = (esp_ble_mesh_ble_cb_param_t *)p_dst;
esp_ble_mesh_ble_cb_param_t *p_src_data = (esp_ble_mesh_ble_cb_param_t *)p_src;
if (!msg || !p_src_data || !p_dst_data) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (msg->act) {
case ESP_BLE_MESH_SCAN_BLE_ADVERTISING_PKT_EVT:
if (p_src_data->scan_ble_adv_pkt.data && p_src_data->scan_ble_adv_pkt.length) {
p_dst_data->scan_ble_adv_pkt.length = p_src_data->scan_ble_adv_pkt.length;
p_dst_data->scan_ble_adv_pkt.data = bt_mesh_calloc(p_src_data->scan_ble_adv_pkt.length);
if (p_dst_data->scan_ble_adv_pkt.data) {
memcpy(p_dst_data->scan_ble_adv_pkt.data, p_src_data->scan_ble_adv_pkt.data,
p_src_data->scan_ble_adv_pkt.length);
} else {
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
}
}
break;
default:
break;
}
#endif /* CONFIG_BLE_MESH_SUPPORT_BLE_SCAN */
}
static void btc_ble_mesh_ble_free_req_data(btc_msg_t *msg)
{
#if CONFIG_BLE_MESH_SUPPORT_BLE_SCAN
esp_ble_mesh_ble_cb_param_t *arg = NULL;
if (!msg || !msg->arg) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
arg = (esp_ble_mesh_ble_cb_param_t *)msg->arg;
switch (msg->act) {
case ESP_BLE_MESH_SCAN_BLE_ADVERTISING_PKT_EVT:
if (arg->scan_ble_adv_pkt.data) {
bt_mesh_free(arg->scan_ble_adv_pkt.data);
}
break;
default:
break;
}
#endif /* CONFIG_BLE_MESH_SUPPORT_BLE_SCAN */
}
static void btc_ble_mesh_ble_callback(esp_ble_mesh_ble_cb_param_t *cb_params, uint8_t act)
{
btc_msg_t msg = {0};
/* If corresponding callback is not registered, event will not be posted. */
if (!btc_profile_cb_get(BTC_PID_BLE_MESH_BLE_COEX)) {
return;
}
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_BLE_MESH_BLE_COEX;
msg.act = act;
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_ble_cb_param_t),
btc_ble_mesh_ble_copy_req_data);
}
#if CONFIG_BLE_MESH_SUPPORT_BLE_SCAN
void bt_mesh_ble_scan_cb_evt_to_btc(const bt_mesh_addr_t *addr,
uint8_t adv_type, uint8_t data[],
uint16_t length, int8_t rssi)
{
esp_ble_mesh_ble_cb_param_t param = {0};
if (addr == NULL) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
memcpy(param.scan_ble_adv_pkt.addr, addr->val, sizeof(addr->val));
param.scan_ble_adv_pkt.addr_type = addr->type;
if (data && length) {
param.scan_ble_adv_pkt.data = data;
param.scan_ble_adv_pkt.length = length;
}
param.scan_ble_adv_pkt.adv_type = adv_type;
param.scan_ble_adv_pkt.rssi = rssi;
btc_ble_mesh_ble_callback(&param, ESP_BLE_MESH_SCAN_BLE_ADVERTISING_PKT_EVT);
}
#endif /* CONFIG_BLE_MESH_SUPPORT_BLE_SCAN */
void btc_ble_mesh_ble_call_handler(btc_msg_t *msg)
{
esp_ble_mesh_ble_cb_param_t param = {0};
btc_ble_mesh_ble_args_t *arg = NULL;
if (!msg || !msg->arg) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
arg = (btc_ble_mesh_ble_args_t *)msg->arg;
switch (msg->act) {
#if CONFIG_BLE_MESH_SUPPORT_BLE_ADV
case BTC_BLE_MESH_ACT_START_BLE_ADV: {
struct bt_mesh_ble_adv_param *set = (struct bt_mesh_ble_adv_param *)&arg->start_ble_adv.param;
struct bt_mesh_ble_adv_data *data = NULL;
if (arg->start_ble_adv.data.adv_data_len || arg->start_ble_adv.data.scan_rsp_data_len) {
data = (struct bt_mesh_ble_adv_data *)&arg->start_ble_adv.data;
}
param.start_ble_advertising_comp.err_code =
bt_mesh_start_ble_advertising(set, data, &param.start_ble_advertising_comp.index);
btc_ble_mesh_ble_callback(&param, ESP_BLE_MESH_START_BLE_ADVERTISING_COMP_EVT);
break;
}
case BTC_BLE_MESH_ACT_STOP_BLE_ADV:
param.stop_ble_advertising_comp.index = arg->stop_ble_adv.index;
param.stop_ble_advertising_comp.err_code =
bt_mesh_stop_ble_advertising(arg->stop_ble_adv.index);
btc_ble_mesh_ble_callback(&param, ESP_BLE_MESH_STOP_BLE_ADVERTISING_COMP_EVT);
break;
#endif /* CONFIG_BLE_MESH_SUPPORT_BLE_ADV */
#if CONFIG_BLE_MESH_SUPPORT_BLE_SCAN
case BTC_BLE_MESH_ACT_START_BLE_SCAN:
param.start_ble_scan_comp.err_code =
bt_mesh_start_ble_scan((struct bt_mesh_ble_scan_param *)&arg->start_ble_scan.param);
btc_ble_mesh_ble_callback(&param, ESP_BLE_MESH_START_BLE_SCANNING_COMP_EVT);
break;
case BTC_BLE_MESH_ACT_STOP_BLE_SCAN:
param.stop_ble_scan_comp.err_code = bt_mesh_stop_ble_scan();
btc_ble_mesh_ble_callback(&param, ESP_BLE_MESH_STOP_BLE_SCANNING_COMP_EVT);
break;
#endif /* CONFIG_BLE_MESH_SUPPORT_BLE_SCAN */
default:
return;
}
}
static inline void btc_ble_mesh_ble_cb_to_app(esp_ble_mesh_ble_cb_event_t event,
esp_ble_mesh_ble_cb_param_t *param)
{
esp_ble_mesh_ble_cb_t btc_ble_mesh_cb =
(esp_ble_mesh_ble_cb_t)btc_profile_cb_get(BTC_PID_BLE_MESH_BLE_COEX);
if (btc_ble_mesh_cb) {
btc_ble_mesh_cb(event, param);
}
}
void btc_ble_mesh_ble_cb_handler(btc_msg_t *msg)
{
esp_ble_mesh_ble_cb_param_t *param = NULL;
if (!msg) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
param = (esp_ble_mesh_ble_cb_param_t *)msg->arg;
if (msg->act < ESP_BLE_MESH_BLE_EVT_MAX) {
btc_ble_mesh_ble_cb_to_app(msg->act, param);
} else {
BT_ERR("%s, Unknown act %d", __func__, msg->act);
}
btc_ble_mesh_ble_free_req_data(msg);
}
#endif /* CONFIG_BLE_MESH_BLE_COEX_SUPPORT */

View File

@ -15,22 +15,17 @@
#include <string.h>
#include <errno.h>
#include "btc/btc_manage.h"
#include "osi/allocator.h"
#include "cfg_cli.h"
#include "mesh_common.h"
#include "btc_ble_mesh_config_model.h"
#include "foundation.h"
#include "esp_ble_mesh_config_model_api.h"
#define CID_NVAL 0xffff
extern s32_t config_msg_timeout;
#if CONFIG_BLE_MESH_CFG_CLI
#include "cfg_cli.h"
/* 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);
@ -45,39 +40,53 @@ void btc_ble_mesh_config_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
btc_ble_mesh_config_client_args_t *src = (btc_ble_mesh_config_client_args_t *)p_src;
if (!msg || !dst || !src) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (msg->act) {
case BTC_BLE_MESH_ACT_CONFIG_CLIENT_GET_STATE: {
dst->cfg_client_get_state.params = (esp_ble_mesh_client_common_param_t *)osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
dst->cfg_client_get_state.get_state = (esp_ble_mesh_cfg_client_get_state_t *)osi_malloc(sizeof(esp_ble_mesh_cfg_client_get_state_t));
if (dst->cfg_client_get_state.params && dst->cfg_client_get_state.get_state) {
dst->cfg_client_get_state.params = (esp_ble_mesh_client_common_param_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (dst->cfg_client_get_state.params) {
memcpy(dst->cfg_client_get_state.params, src->cfg_client_get_state.params,
sizeof(esp_ble_mesh_client_common_param_t));
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 {
LOG_ERROR("%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) {
dst->cfg_client_get_state.get_state = (esp_ble_mesh_cfg_client_get_state_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_cfg_client_get_state_t));
if (dst->cfg_client_get_state.get_state) {
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, Out of memory, act %d", __func__, msg->act);
}
}
break;
}
case BTC_BLE_MESH_ACT_CONFIG_CLIENT_SET_STATE: {
dst->cfg_client_set_state.params = (esp_ble_mesh_client_common_param_t *)osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
dst->cfg_client_set_state.set_state = (esp_ble_mesh_cfg_client_set_state_t *)osi_malloc(sizeof(esp_ble_mesh_cfg_client_set_state_t));
if (dst->cfg_client_set_state.params && dst->cfg_client_set_state.set_state) {
dst->cfg_client_set_state.params = (esp_ble_mesh_client_common_param_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (dst->cfg_client_set_state.params) {
memcpy(dst->cfg_client_set_state.params, src->cfg_client_set_state.params,
sizeof(esp_ble_mesh_client_common_param_t));
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 {
LOG_ERROR("%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) {
dst->cfg_client_set_state.set_state = (esp_ble_mesh_cfg_client_set_state_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_cfg_client_set_state_t));
if (dst->cfg_client_set_state.set_state) {
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, Out of memory, act %d", __func__, msg->act);
}
}
break;
}
default:
LOG_DEBUG("%s, Unknown deep copy act %d", __func__, msg->act);
BT_DBG("%s, Unknown act %d", __func__, msg->act);
break;
}
}
@ -87,7 +96,7 @@ static void btc_ble_mesh_config_client_arg_deep_free(btc_msg_t *msg)
btc_ble_mesh_config_client_args_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -96,18 +105,18 @@ static void btc_ble_mesh_config_client_arg_deep_free(btc_msg_t *msg)
switch (msg->act) {
case BTC_BLE_MESH_ACT_CONFIG_CLIENT_GET_STATE:
if (arg->cfg_client_get_state.params) {
osi_free(arg->cfg_client_get_state.params);
bt_mesh_free(arg->cfg_client_get_state.params);
}
if (arg->cfg_client_get_state.get_state) {
osi_free(arg->cfg_client_get_state.get_state);
bt_mesh_free(arg->cfg_client_get_state.get_state);
}
break;
case BTC_BLE_MESH_ACT_CONFIG_CLIENT_SET_STATE:
if (arg->cfg_client_set_state.params) {
osi_free(arg->cfg_client_set_state.params);
bt_mesh_free(arg->cfg_client_set_state.params);
}
if (arg->cfg_client_set_state.set_state) {
osi_free(arg->cfg_client_set_state.set_state);
bt_mesh_free(arg->cfg_client_set_state.set_state);
}
break;
default:
@ -119,17 +128,17 @@ static void btc_ble_mesh_config_client_copy_req_data(btc_msg_t *msg, void *p_des
{
esp_ble_mesh_cfg_client_cb_param_t *p_dest_data = (esp_ble_mesh_cfg_client_cb_param_t *)p_dest;
esp_ble_mesh_cfg_client_cb_param_t *p_src_data = (esp_ble_mesh_cfg_client_cb_param_t *)p_src;
u16_t length;
uint16_t length = 0U;
if (!msg || !p_src_data || !p_dest_data) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
if (p_src_data->params) {
p_dest_data->params = osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (!p_dest_data->params) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
@ -148,7 +157,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) {
LOG_ERROR("%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,
@ -164,7 +173,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) {
LOG_ERROR("%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,
@ -178,7 +187,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) {
LOG_ERROR("%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,
@ -192,7 +201,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) {
LOG_ERROR("%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,
@ -208,7 +217,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) {
LOG_ERROR("%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,
@ -232,7 +241,7 @@ static void btc_ble_mesh_config_client_free_req_data(btc_msg_t *msg)
esp_ble_mesh_cfg_client_cb_param_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -274,7 +283,7 @@ static void btc_ble_mesh_config_client_free_req_data(btc_msg_t *msg)
}
case ESP_BLE_MESH_CFG_CLIENT_TIMEOUT_EVT:
if (arg->params) {
osi_free(arg->params);
bt_mesh_free(arg->params);
}
break;
default:
@ -286,7 +295,7 @@ static void btc_ble_mesh_config_client_callback(esp_ble_mesh_cfg_client_cb_param
{
btc_msg_t msg = {0};
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
/* If corresponding callback is not registered, event will not be posted. */
if (!btc_profile_cb_get(BTC_PID_CONFIG_CLIENT)) {
@ -297,22 +306,21 @@ 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)
void bt_mesh_config_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const uint8_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;
uint8_t act;
uint8_t act = 0U;
if (!model || !ctx) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -330,7 +338,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:
LOG_ERROR("%s, Unknown config client event type %d", __func__, evt_type);
BT_ERR("Unknown Config client event type %d", evt_type);
return;
}
@ -342,154 +350,178 @@ void bt_mesh_config_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
params.ctx.recv_ttl = ctx->recv_ttl;
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(uint32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
if (!model || !ctx || !buf) {
LOG_ERROR("%s, Invalid parameter", __func__);
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,
esp_ble_mesh_cfg_client_cb_param_t *cb)
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 || !cb) {
LOG_ERROR("%s, Invalid parameter", __func__);
if (params == NULL) {
BT_ERR("%s, Invalid parameter", __func__);
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;
config_msg_timeout = params->msg_timeout;
switch (params->opcode) {
case ESP_BLE_MESH_MODEL_OP_BEACON_GET:
return (cb->error_code = bt_mesh_cfg_beacon_get(&ctx));
case ESP_BLE_MESH_MODEL_OP_DEFAULT_TTL_GET:
return (cb->error_code = bt_mesh_cfg_ttl_get(&ctx));
case ESP_BLE_MESH_MODEL_OP_FRIEND_GET:
return (cb->error_code = bt_mesh_cfg_friend_get(&ctx));
case ESP_BLE_MESH_MODEL_OP_GATT_PROXY_GET:
return (cb->error_code = bt_mesh_cfg_gatt_proxy_get(&ctx));
case ESP_BLE_MESH_MODEL_OP_RELAY_GET:
return (cb->error_code = bt_mesh_cfg_relay_get(&ctx));
case ESP_BLE_MESH_MODEL_OP_MODEL_PUB_GET:
return (cb->error_code =
bt_mesh_cfg_mod_pub_get(&ctx, 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 (cb->error_code = bt_mesh_cfg_hb_pub_get(&ctx));
case ESP_BLE_MESH_MODEL_OP_HEARTBEAT_SUB_GET:
return (cb->error_code = bt_mesh_cfg_hb_sub_get(&ctx));
case ESP_BLE_MESH_MODEL_OP_COMPOSITION_DATA_GET:
return (cb->error_code = bt_mesh_cfg_comp_data_get(&ctx, get->comp_data_get.page));
case ESP_BLE_MESH_MODEL_OP_MODEL_PUB_GET:
case ESP_BLE_MESH_MODEL_OP_SIG_MODEL_SUB_GET:
return (cb->error_code =
bt_mesh_cfg_mod_sub_get(&ctx, 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 (cb->error_code =
bt_mesh_cfg_mod_sub_get_vnd(&ctx, 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 (cb->error_code = bt_mesh_cfg_net_key_get(&ctx));
case ESP_BLE_MESH_MODEL_OP_APP_KEY_GET:
return (cb->error_code = bt_mesh_cfg_app_key_get(&ctx, get->app_key_get.net_idx));
case ESP_BLE_MESH_MODEL_OP_NODE_IDENTITY_GET:
return (cb->error_code = bt_mesh_cfg_node_identity_get(&ctx, get->node_identity_get.net_idx));
case ESP_BLE_MESH_MODEL_OP_SIG_MODEL_APP_GET:
return (cb->error_code =
bt_mesh_cfg_mod_app_get(&ctx, 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 (cb->error_code =
bt_mesh_cfg_mod_app_get_vnd(&ctx, 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 (cb->error_code = bt_mesh_cfg_kr_phase_get(&ctx, get->kr_phase_get.net_idx));
case ESP_BLE_MESH_MODEL_OP_LPN_POLLTIMEOUT_GET:
return (cb->error_code = bt_mesh_cfg_lpn_timeout_get(&ctx, get->lpn_pollto_get.lpn_addr));
case ESP_BLE_MESH_MODEL_OP_NETWORK_TRANSMIT_GET:
return (cb->error_code = bt_mesh_cfg_net_transmit_get(&ctx));
if (get == NULL) {
BT_ERR("Invalid Configuration Get");
return -EINVAL;
}
break;
default:
LOG_ERROR("%s, Invalid opcode 0x%x", __func__, params->opcode);
return (cb->error_code = -EINVAL);
break;
}
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;
switch (param.opcode) {
case ESP_BLE_MESH_MODEL_OP_BEACON_GET:
return bt_mesh_cfg_beacon_get(&param);
case ESP_BLE_MESH_MODEL_OP_DEFAULT_TTL_GET:
return bt_mesh_cfg_ttl_get(&param);
case ESP_BLE_MESH_MODEL_OP_FRIEND_GET:
return bt_mesh_cfg_friend_get(&param);
case ESP_BLE_MESH_MODEL_OP_GATT_PROXY_GET:
return bt_mesh_cfg_gatt_proxy_get(&param);
case ESP_BLE_MESH_MODEL_OP_RELAY_GET:
return bt_mesh_cfg_relay_get(&param);
case ESP_BLE_MESH_MODEL_OP_MODEL_PUB_GET:
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(&param);
case ESP_BLE_MESH_MODEL_OP_HEARTBEAT_SUB_GET:
return bt_mesh_cfg_hb_sub_get(&param);
case ESP_BLE_MESH_MODEL_OP_COMPOSITION_DATA_GET:
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(&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(&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(&param);
case ESP_BLE_MESH_MODEL_OP_APP_KEY_GET:
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(&param, get->node_identity_get.net_idx);
case ESP_BLE_MESH_MODEL_OP_SIG_MODEL_APP_GET:
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(&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(&param, get->kr_phase_get.net_idx);
case ESP_BLE_MESH_MODEL_OP_LPN_POLLTIMEOUT_GET:
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(&param);
default:
BT_ERR("Invalid Configuration Get opcode 0x%04x", param.opcode);
return -EINVAL;
}
return 0;
}
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,
esp_ble_mesh_cfg_client_cb_param_t *cb)
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 || !set || !cb) {
LOG_ERROR("%s, Invalid parameter", __func__);
if (params == NULL) {
BT_ERR("%s, Invalid parameter", __func__);
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;
if (params->opcode != ESP_BLE_MESH_MODEL_OP_NODE_RESET && set == NULL) {
BT_ERR("Invalid Configuration Set");
return -EINVAL;
}
config_msg_timeout = params->msg_timeout;
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;
switch (params->opcode) {
switch (param.opcode) {
case ESP_BLE_MESH_MODEL_OP_BEACON_SET:
return (cb->error_code = 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 (cb->error_code = 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 (cb->error_code = 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 (cb->error_code = 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 (cb->error_code =
bt_mesh_cfg_relay_set(&ctx, set->relay_set.relay, set->relay_set.relay_retransmit));
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 (cb->error_code =
bt_mesh_cfg_net_key_add(&ctx, set->net_key_add.net_idx,
&set->net_key_add.net_key[0]));
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 (cb->error_code =
bt_mesh_cfg_app_key_add(&ctx, set->app_key_add.net_idx,
set->app_key_add.app_idx, &set->app_key_add.app_key[0]));
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 (cb->error_code =
bt_mesh_cfg_mod_app_bind(&ctx, 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));
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);
case ESP_BLE_MESH_MODEL_OP_MODEL_PUB_SET: {
struct bt_mesh_cfg_mod_pub model_pub = {
.addr = set->model_pub_set.publish_addr,
@ -499,50 +531,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 (cb->error_code =
bt_mesh_cfg_mod_pub_set(&ctx, set->model_pub_set.element_addr,
set->model_pub_set.model_id, set->model_pub_set.company_id, &model_pub));
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 (cb->error_code =
bt_mesh_cfg_mod_sub_add(&ctx, set->model_sub_add.element_addr,
set->model_sub_add.sub_addr, set->model_sub_add.model_id,
set->model_sub_add.company_id));
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 (cb->error_code =
bt_mesh_cfg_mod_sub_del(&ctx, set->model_sub_delete.element_addr,
set->model_sub_delete.sub_addr, set->model_sub_delete.model_id,
set->model_sub_delete.company_id));
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 (cb->error_code =
bt_mesh_cfg_mod_sub_overwrite(&ctx, set->model_sub_overwrite.element_addr,
set->model_sub_overwrite.sub_addr, set->model_sub_overwrite.model_id,
set->model_sub_overwrite.company_id));
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 (cb->error_code =
bt_mesh_cfg_mod_sub_va_add(&ctx, 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));
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 (cb->error_code =
bt_mesh_cfg_mod_sub_va_overwrite(&ctx, 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));
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 (cb->error_code =
bt_mesh_cfg_mod_sub_va_del(&ctx, 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));
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 (cb->error_code =
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 (cb->error_code =
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 (cb->error_code = 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,
@ -551,49 +579,43 @@ 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 (cb->error_code =
bt_mesh_cfg_mod_pub_va_set(&ctx, 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));
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 (cb->error_code =
bt_mesh_cfg_mod_sub_del_all(&ctx, set->model_sub_delete_all.element_addr,
set->model_sub_delete_all.model_id, set->model_sub_delete_all.company_id));
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 (cb->error_code =
bt_mesh_cfg_net_key_update(&ctx, set->net_key_update.net_idx,
set->net_key_update.net_key));
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 (cb->error_code =
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 (cb->error_code =
bt_mesh_cfg_app_key_update(&ctx, set->app_key_update.net_idx,
set->app_key_update.app_idx, set->app_key_update.app_key));
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 (cb->error_code =
bt_mesh_cfg_app_key_delete(&ctx, set->app_key_delete.net_idx,
set->app_key_delete.app_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 (cb->error_code =
bt_mesh_cfg_node_identity_set(&ctx, set->node_identity_set.net_idx,
set->node_identity_set.identity));
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 (cb->error_code =
bt_mesh_cfg_mod_app_unbind(&ctx, 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));
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 (cb->error_code =
bt_mesh_cfg_kr_phase_set(&ctx, set->kr_phase_set.net_idx,
set->kr_phase_set.transition));
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 (cb->error_code =
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:
LOG_ERROR("%s, Invalid opcode 0x%x", __func__, params->opcode);
return (cb->error_code = -EINVAL);
BT_ERR("Invalid Configuration Set opcode 0x%04x", param.opcode);
return -EINVAL;
}
return 0;
@ -603,10 +625,9 @@ 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) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -615,15 +636,8 @@ 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)) {
LOG_ERROR("%s, Failed to set model role", __func__);
break;
}
btc_ble_mesh_config_client_get_state(arg->cfg_client_get_state.params,
arg->cfg_client_get_state.get_state,
&cb);
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) {
btc_ble_mesh_config_client_callback(&cb, ESP_BLE_MESH_CFG_CLIENT_GET_STATE_EVT);
}
@ -631,15 +645,8 @@ 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)) {
LOG_ERROR("%s, Failed to set model role", __func__);
break;
}
btc_ble_mesh_config_client_set_state(arg->cfg_client_set_state.params,
arg->cfg_client_set_state.set_state,
&cb);
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) {
btc_ble_mesh_config_client_callback(&cb, ESP_BLE_MESH_CFG_CLIENT_SET_STATE_EVT);
}
@ -658,7 +665,7 @@ void btc_ble_mesh_config_client_cb_handler(btc_msg_t *msg)
esp_ble_mesh_cfg_client_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -667,17 +674,19 @@ 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 {
LOG_ERROR("%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);
return;
}
#endif /* CONFIG_BLE_MESH_CFG_CLI */
/* 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);
@ -690,7 +699,7 @@ static void btc_ble_mesh_config_server_callback(esp_ble_mesh_cfg_server_cb_param
{
btc_msg_t msg = {0};
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
/* If corresponding callback is not registered, event will not be posted. */
if (!btc_profile_cb_get(BTC_PID_CONFIG_SERVER)) {
@ -704,17 +713,15 @@ 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(uint8_t evt_type, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const uint8_t *val, size_t len)
{
esp_ble_mesh_cfg_server_cb_param_t cb_params = {0};
size_t length;
uint8_t act;
uint8_t act = 0U;
if (!model || !ctx) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -723,7 +730,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:
LOG_ERROR("%s, Unknown config server event type %d", __func__, evt_type);
BT_ERR("Unknown Config server event type %d", evt_type);
return;
}
@ -734,10 +741,11 @@ void bt_mesh_config_server_cb_evt_to_btc(u8_t evt_type,
cb_params.ctx.recv_ttl = ctx->recv_ttl;
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);
@ -749,7 +757,7 @@ void btc_ble_mesh_config_server_cb_handler(btc_msg_t *msg)
esp_ble_mesh_cfg_server_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -758,6 +766,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 {
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
BT_ERR("%s, Unknown act %d", __func__, msg->act);
}
}

View File

@ -15,17 +15,16 @@
#include <string.h>
#include <errno.h>
#include "btc/btc_manage.h"
#include "osi/allocator.h"
#include "generic_client.h"
#include "btc_ble_mesh_generic_model.h"
#include "esp_ble_mesh_generic_model_api.h"
#if CONFIG_BLE_MESH_GENERIC_CLIENT
#include "generic_client.h"
/* 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);
@ -38,30 +37,37 @@ void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, voi
{
btc_ble_mesh_generic_client_args_t *dst = (btc_ble_mesh_generic_client_args_t *)p_dest;
btc_ble_mesh_generic_client_args_t *src = (btc_ble_mesh_generic_client_args_t *)p_src;
u16_t length;
uint16_t length = 0U;
if (!msg || !dst || !src) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (msg->act) {
case BTC_BLE_MESH_ACT_GENERIC_CLIENT_GET_STATE: {
dst->generic_client_get_state.params = (esp_ble_mesh_client_common_param_t *)osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
dst->generic_client_get_state.get_state = (esp_ble_mesh_generic_client_get_state_t *)osi_malloc(sizeof(esp_ble_mesh_generic_client_get_state_t));
if (dst->generic_client_get_state.params && dst->generic_client_get_state.get_state) {
dst->generic_client_get_state.params = (esp_ble_mesh_client_common_param_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (dst->generic_client_get_state.params) {
memcpy(dst->generic_client_get_state.params, src->generic_client_get_state.params,
sizeof(esp_ble_mesh_client_common_param_t));
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 {
LOG_ERROR("%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) {
dst->generic_client_get_state.get_state = (esp_ble_mesh_generic_client_get_state_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_generic_client_get_state_t));
if (dst->generic_client_get_state.get_state) {
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, Out of memory, act %d", __func__, msg->act);
}
}
break;
}
case BTC_BLE_MESH_ACT_GENERIC_CLIENT_SET_STATE: {
dst->generic_client_set_state.params = (esp_ble_mesh_client_common_param_t *)osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
dst->generic_client_set_state.set_state = (esp_ble_mesh_generic_client_set_state_t *)osi_malloc(sizeof(esp_ble_mesh_generic_client_set_state_t));
dst->generic_client_set_state.params = (esp_ble_mesh_client_common_param_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
dst->generic_client_set_state.set_state = (esp_ble_mesh_generic_client_set_state_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_generic_client_set_state_t));
if (dst->generic_client_set_state.params && dst->generic_client_set_state.set_state) {
memcpy(dst->generic_client_set_state.params, src->generic_client_set_state.params,
sizeof(esp_ble_mesh_client_common_param_t));
@ -74,7 +80,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) {
LOG_ERROR("%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,
@ -87,7 +93,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) {
LOG_ERROR("%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,
@ -99,12 +105,12 @@ void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, voi
break;
}
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
}
break;
}
default:
LOG_DEBUG("%s, Unknown deep copy act %d", __func__, msg->act);
BT_DBG("%s, Unknown act %d", __func__, msg->act);
break;
}
}
@ -114,7 +120,7 @@ static void btc_ble_mesh_generic_client_arg_deep_free(btc_msg_t *msg)
btc_ble_mesh_generic_client_args_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -123,10 +129,10 @@ static void btc_ble_mesh_generic_client_arg_deep_free(btc_msg_t *msg)
switch (msg->act) {
case BTC_BLE_MESH_ACT_GENERIC_CLIENT_GET_STATE:
if (arg->generic_client_get_state.params) {
osi_free(arg->generic_client_get_state.params);
bt_mesh_free(arg->generic_client_get_state.params);
}
if (arg->generic_client_get_state.get_state) {
osi_free(arg->generic_client_get_state.get_state);
bt_mesh_free(arg->generic_client_get_state.get_state);
}
break;
case BTC_BLE_MESH_ACT_GENERIC_CLIENT_SET_STATE:
@ -143,10 +149,10 @@ static void btc_ble_mesh_generic_client_arg_deep_free(btc_msg_t *msg)
break;
}
}
osi_free(arg->generic_client_set_state.set_state);
bt_mesh_free(arg->generic_client_set_state.set_state);
}
if (arg->generic_client_set_state.params) {
osi_free(arg->generic_client_set_state.params);
bt_mesh_free(arg->generic_client_set_state.params);
}
break;
default:
@ -158,17 +164,17 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de
{
esp_ble_mesh_generic_client_cb_param_t *p_dest_data = (esp_ble_mesh_generic_client_cb_param_t *)p_dest;
esp_ble_mesh_generic_client_cb_param_t *p_src_data = (esp_ble_mesh_generic_client_cb_param_t *)p_src;
u16_t length;
uint16_t length = 0U;
if (!msg || !p_src_data || !p_dest_data) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
if (p_src_data->params) {
p_dest_data->params = osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (!p_dest_data->params) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
@ -187,7 +193,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) {
LOG_ERROR("%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,
@ -202,7 +208,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) {
LOG_ERROR("%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,
@ -216,7 +222,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) {
LOG_ERROR("%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,
@ -231,7 +237,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) {
LOG_ERROR("%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,
@ -245,7 +251,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) {
LOG_ERROR("%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,
@ -260,7 +266,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) {
LOG_ERROR("%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,
@ -274,7 +280,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) {
LOG_ERROR("%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,
@ -298,7 +304,7 @@ static void btc_ble_mesh_generic_client_free_req_data(btc_msg_t *msg)
esp_ble_mesh_generic_client_cb_param_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -347,7 +353,7 @@ static void btc_ble_mesh_generic_client_free_req_data(btc_msg_t *msg)
}
case ESP_BLE_MESH_GENERIC_CLIENT_TIMEOUT_EVT:
if (arg->params) {
osi_free(arg->params);
bt_mesh_free(arg->params);
}
break;
default:
@ -359,7 +365,7 @@ static void btc_ble_mesh_generic_client_callback(esp_ble_mesh_generic_client_cb_
{
btc_msg_t msg = {0};
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
/* If corresponding callback is not registered, event will not be posted. */
if (!btc_profile_cb_get(BTC_PID_GENERIC_CLIENT)) {
@ -370,22 +376,21 @@ 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)
void bt_mesh_generic_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const uint8_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;
uint8_t act;
uint8_t act = 0U;
if (!model || !ctx) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -403,7 +408,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:
LOG_ERROR("%s, Unknown generic client event type %d", __func__, evt_type);
BT_ERR("Unknown Generic client event type %d", evt_type);
return;
}
@ -415,31 +420,31 @@ void bt_mesh_generic_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
params.ctx.recv_ttl = ctx->recv_ttl;
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(uint32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
if (!model || !ctx || !buf) {
LOG_ERROR("%s, Invalid parameter", __func__);
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;
}
@ -449,10 +454,9 @@ 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) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -461,12 +465,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)) {
LOG_ERROR("%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;
@ -475,10 +473,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);
@ -487,12 +485,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)) {
LOG_ERROR("%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;
@ -501,10 +493,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);
@ -524,7 +516,7 @@ void btc_ble_mesh_generic_client_cb_handler(btc_msg_t *msg)
esp_ble_mesh_generic_client_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -533,18 +525,21 @@ 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 {
LOG_ERROR("%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);
return;
}
#endif /* CONFIG_BLE_MESH_GENERIC_CLIENT */
#if CONFIG_BLE_MESH_GENERIC_SERVER
/* 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);
@ -557,10 +552,10 @@ static void btc_ble_mesh_generic_server_copy_req_data(btc_msg_t *msg, void *p_de
{
esp_ble_mesh_generic_server_cb_param_t *p_dest_data = (esp_ble_mesh_generic_server_cb_param_t *)p_dest;
esp_ble_mesh_generic_server_cb_param_t *p_src_data = (esp_ble_mesh_generic_server_cb_param_t *)p_src;
u16_t length;
uint16_t length = 0U;
if (!msg || !p_src_data || !p_dest_data) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -573,7 +568,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) {
LOG_ERROR("%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,
@ -587,7 +582,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) {
LOG_ERROR("%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,
@ -607,7 +602,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) {
LOG_ERROR("%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,
@ -621,7 +616,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) {
LOG_ERROR("%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,
@ -643,7 +638,7 @@ static void btc_ble_mesh_generic_server_free_req_data(btc_msg_t *msg)
esp_ble_mesh_generic_server_cb_param_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -687,7 +682,7 @@ static void btc_ble_mesh_generic_server_callback(esp_ble_mesh_generic_server_cb_
{
btc_msg_t msg = {0};
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
/* If corresponding callback is not registered, event will not be posted. */
if (!btc_profile_cb_get(BTC_PID_GENERIC_SERVER)) {
@ -698,21 +693,19 @@ 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(uint8_t evt_type, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const uint8_t *val, size_t len)
{
esp_ble_mesh_generic_server_cb_param_t cb_params = {0};
size_t length;
uint8_t act;
uint8_t act = 0U;
if (model == NULL || ctx == NULL) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -727,7 +720,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:
LOG_ERROR("%s, Unknown Generic Server event type", __func__);
BT_ERR("Unknown Generic Server event type %d", evt_type);
return;
}
@ -738,10 +731,11 @@ void bt_mesh_generic_server_cb_evt_to_btc(u8_t evt_type,
cb_params.ctx.recv_ttl = ctx->recv_ttl;
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);
@ -753,7 +747,7 @@ void btc_ble_mesh_generic_server_cb_handler(btc_msg_t *msg)
esp_ble_mesh_generic_server_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -762,9 +756,11 @@ 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 {
LOG_ERROR("%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);
return;
}
#endif /* CONFIG_BLE_MESH_GENERIC_SERVER */

View File

@ -15,23 +15,17 @@
#include <string.h>
#include <errno.h>
#include "btc/btc_manage.h"
#include "btc/btc_task.h"
#include "osi/allocator.h"
#include "health_srv.h"
#include "health_cli.h"
#include "mesh_common.h"
#include "btc_ble_mesh_health_model.h"
#include "esp_ble_mesh_defs.h"
#include "foundation.h"
#include "esp_ble_mesh_health_model_api.h"
extern s32_t health_msg_timeout;
#if CONFIG_BLE_MESH_HEALTH_CLI
#include "health_cli.h"
/* 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);
@ -46,39 +40,46 @@ void btc_ble_mesh_health_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
btc_ble_mesh_health_client_args_t *src = (btc_ble_mesh_health_client_args_t *)p_src;
if (!msg || !dst || !src) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (msg->act) {
case BTC_BLE_MESH_ACT_HEALTH_CLIENT_GET_STATE: {
dst->health_client_get_state.params = (esp_ble_mesh_client_common_param_t *)osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
dst->health_client_get_state.get_state = (esp_ble_mesh_health_client_get_state_t *)osi_malloc(sizeof(esp_ble_mesh_health_client_get_state_t));
if (dst->health_client_get_state.params && dst->health_client_get_state.get_state) {
dst->health_client_get_state.params = (esp_ble_mesh_client_common_param_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (dst->health_client_get_state.params) {
memcpy(dst->health_client_get_state.params, src->health_client_get_state.params,
sizeof(esp_ble_mesh_client_common_param_t));
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 {
LOG_ERROR("%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) {
dst->health_client_get_state.get_state = (esp_ble_mesh_health_client_get_state_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_health_client_get_state_t));
if (dst->health_client_get_state.get_state) {
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, Out of memory, act %d", __func__, msg->act);
}
}
break;
}
case BTC_BLE_MESH_ACT_HEALTH_CLIENT_SET_STATE: {
dst->health_client_set_state.params = (esp_ble_mesh_client_common_param_t *)osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
dst->health_client_set_state.set_state = (esp_ble_mesh_health_client_set_state_t *)osi_malloc(sizeof(esp_ble_mesh_health_client_set_state_t));
dst->health_client_set_state.params = (esp_ble_mesh_client_common_param_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
dst->health_client_set_state.set_state = (esp_ble_mesh_health_client_set_state_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_health_client_set_state_t));
if (dst->health_client_set_state.params && dst->health_client_set_state.set_state) {
memcpy(dst->health_client_set_state.params, src->health_client_set_state.params,
sizeof(esp_ble_mesh_client_common_param_t));
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 {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
}
break;
}
default:
LOG_DEBUG("%s, Unknown deep copy act %d", __func__, msg->act);
BT_DBG("%s, Unknown act %d", __func__, msg->act);
break;
}
}
@ -88,7 +89,7 @@ static void btc_ble_mesh_health_client_arg_deep_free(btc_msg_t *msg)
btc_ble_mesh_health_client_args_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -97,18 +98,18 @@ static void btc_ble_mesh_health_client_arg_deep_free(btc_msg_t *msg)
switch (msg->act) {
case BTC_BLE_MESH_ACT_HEALTH_CLIENT_GET_STATE:
if (arg->health_client_get_state.params) {
osi_free(arg->health_client_get_state.params);
bt_mesh_free(arg->health_client_get_state.params);
}
if (arg->health_client_get_state.get_state) {
osi_free(arg->health_client_get_state.get_state);
bt_mesh_free(arg->health_client_get_state.get_state);
}
break;
case BTC_BLE_MESH_ACT_HEALTH_CLIENT_SET_STATE:
if (arg->health_client_set_state.params) {
osi_free(arg->health_client_set_state.params);
bt_mesh_free(arg->health_client_set_state.params);
}
if (arg->health_client_set_state.set_state) {
osi_free(arg->health_client_set_state.set_state);
bt_mesh_free(arg->health_client_set_state.set_state);
}
break;
default:
@ -120,17 +121,17 @@ static void btc_ble_mesh_health_client_copy_req_data(btc_msg_t *msg, void *p_des
{
esp_ble_mesh_health_client_cb_param_t *p_dest_data = (esp_ble_mesh_health_client_cb_param_t *)p_dest;
esp_ble_mesh_health_client_cb_param_t *p_src_data = (esp_ble_mesh_health_client_cb_param_t *)p_src;
u16_t length;
uint16_t length = 0U;
if (!msg || !p_src_data || !p_dest_data) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
if (p_src_data->params) {
p_dest_data->params = osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (!p_dest_data->params) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
@ -148,7 +149,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) {
LOG_ERROR("%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,
@ -164,7 +165,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) {
LOG_ERROR("%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,
@ -188,7 +189,7 @@ static void btc_ble_mesh_health_client_free_req_data(btc_msg_t *msg)
esp_ble_mesh_health_client_cb_param_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -215,7 +216,7 @@ static void btc_ble_mesh_health_client_free_req_data(btc_msg_t *msg)
}
case ESP_BLE_MESH_HEALTH_CLIENT_TIMEOUT_EVT:
if (arg->params) {
osi_free(arg->params);
bt_mesh_free(arg->params);
}
break;
default:
@ -227,7 +228,7 @@ static void btc_ble_mesh_health_client_callback(esp_ble_mesh_health_client_cb_pa
{
btc_msg_t msg = {0};
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
/* If corresponding callback is not registered, event will not be posted. */
if (!btc_profile_cb_get(BTC_PID_HEALTH_CLIENT)) {
@ -238,22 +239,21 @@ 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)
void bt_mesh_health_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const uint8_t *val, uint16_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;
uint8_t act;
uint8_t act = 0U;
if (!model || !ctx) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -271,7 +271,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:
LOG_ERROR("%s, Unknown health client event type %d", __func__, evt_type);
BT_ERR("Unknown Health client event type %d", evt_type);
return;
}
@ -283,115 +283,114 @@ void bt_mesh_health_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
params.ctx.recv_ttl = ctx->recv_ttl;
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(uint32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
if (!model || !ctx || !buf) {
LOG_ERROR("%s, Invalid parameter", __func__);
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,
esp_ble_mesh_health_client_cb_param_t *cb)
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 || !cb) {
LOG_ERROR("%s, Invalid parameter", __func__);
if (params == 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;
if (params->opcode == ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET && get == NULL) {
BT_ERR("Invalid Health Get");
return -EINVAL;
}
health_msg_timeout = params->msg_timeout;
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;
switch (params->opcode) {
switch (param.opcode) {
case ESP_BLE_MESH_MODEL_OP_ATTENTION_GET:
return (cb->error_code = bt_mesh_health_attention_get(&ctx));
return bt_mesh_health_attention_get(&param);
case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_GET:
return (cb->error_code = bt_mesh_health_period_get(&ctx));
return bt_mesh_health_period_get(&param);
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET:
return (cb->error_code = bt_mesh_health_fault_get(&ctx, get->fault_get.company_id));
return bt_mesh_health_fault_get(&param, get->fault_get.company_id);
default:
LOG_ERROR("%s, Invalid opcode 0x%x", __func__, params->opcode);
return (cb->error_code = -EINVAL);
BT_ERR("Invalid Health Get opcode 0x%04x", param.opcode);
return -EINVAL;
}
return 0;
}
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,
esp_ble_mesh_health_client_cb_param_t *cb)
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 || !set || !cb) {
LOG_ERROR("%s, Invalid parameter", __func__);
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 (cb->error_code =
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 (cb->error_code =
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 (cb->error_code =
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 (cb->error_code =
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 (cb->error_code =
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 (cb->error_code =
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 (cb->error_code =
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 (cb->error_code =
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:
LOG_ERROR("%s, Invalid opcode 0x%x", __func__, params->opcode);
return (cb->error_code = -EINVAL);
BT_ERR("Invalid Health Set opcode 0x%04x", param.opcode);
return -EINVAL;
}
return 0;
@ -401,10 +400,9 @@ 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) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -413,14 +411,8 @@ 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)) {
LOG_ERROR("%s, Failed to set model role", __func__);
break;
}
btc_ble_mesh_health_client_get_state(arg->health_client_get_state.params,
arg->health_client_get_state.get_state, &cb);
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) {
/* If send failed, callback error_code to app layer immediately */
btc_ble_mesh_health_client_callback(&cb, ESP_BLE_MESH_HEALTH_CLIENT_GET_STATE_EVT);
@ -429,14 +421,8 @@ 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)) {
LOG_ERROR("%s, Failed to set model role", __func__);
break;
}
btc_ble_mesh_health_client_set_state(arg->health_client_set_state.params,
arg->health_client_set_state.set_state, &cb);
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) {
/* If send failed, callback error_code to app layer immediately */
btc_ble_mesh_health_client_callback(&cb, ESP_BLE_MESH_HEALTH_CLIENT_SET_STATE_EVT);
@ -456,7 +442,7 @@ void btc_ble_mesh_health_client_cb_handler(btc_msg_t *msg)
esp_ble_mesh_health_client_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -465,17 +451,22 @@ 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 {
LOG_ERROR("%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);
return;
}
#endif /* CONFIG_BLE_MESH_HEALTH_CLI */
#if CONFIG_BLE_MESH_HEALTH_SRV
#include "health_srv.h"
/* 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);
@ -487,7 +478,7 @@ static inline void btc_ble_mesh_health_server_cb_to_app(esp_ble_mesh_health_serv
void btc_ble_mesh_health_server_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
{
if (!msg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -502,7 +493,7 @@ void btc_ble_mesh_health_server_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
static void btc_ble_mesh_health_server_arg_deep_free(btc_msg_t *msg)
{
if (!msg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -517,7 +508,7 @@ static void btc_ble_mesh_health_server_arg_deep_free(btc_msg_t *msg)
static void btc_ble_mesh_health_server_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
{
if (!msg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -532,7 +523,7 @@ static void btc_ble_mesh_health_server_copy_req_data(btc_msg_t *msg, void *p_des
static void btc_ble_mesh_health_server_free_req_data(btc_msg_t *msg)
{
if (!msg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -548,7 +539,7 @@ static void btc_ble_mesh_health_server_callback(esp_ble_mesh_health_server_cb_pa
{
btc_msg_t msg = {0};
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
/* If corresponding callback is not registered, event will not be posted. */
if (!btc_profile_cb_get(BTC_PID_HEALTH_SERVER)) {
@ -559,8 +550,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)
@ -569,7 +560,7 @@ void btc_ble_mesh_health_server_call_handler(btc_msg_t *msg)
btc_ble_mesh_health_server_args_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -595,7 +586,7 @@ void btc_ble_mesh_health_server_cb_handler(btc_msg_t *msg)
esp_ble_mesh_health_server_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -604,14 +595,14 @@ 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 {
LOG_ERROR("%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);
return;
}
void btc_ble_mesh_health_server_fault_clear(struct bt_mesh_model *model, u16_t company_id)
void btc_ble_mesh_health_server_fault_clear(struct bt_mesh_model *model, uint16_t company_id)
{
esp_ble_mesh_health_server_cb_param_t param = {0};
@ -621,7 +612,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,
uint8_t test_id, uint16_t company_id)
{
esp_ble_mesh_health_server_cb_param_t param = {0};
@ -632,7 +624,7 @@ void btc_ble_mesh_health_server_fault_test(struct bt_mesh_model *model, u8_t tes
btc_ble_mesh_health_server_callback(&param, ESP_BLE_MESH_HEALTH_SERVER_FAULT_TEST_EVT);
}
void btc_ble_mesh_health_server_attention_on(struct bt_mesh_model *model, u8_t time)
void btc_ble_mesh_health_server_attention_on(struct bt_mesh_model *model, uint8_t time)
{
esp_ble_mesh_health_server_cb_param_t param = {0};
@ -650,3 +642,4 @@ void btc_ble_mesh_health_server_attention_off(struct bt_mesh_model *model)
btc_ble_mesh_health_server_callback(&param, ESP_BLE_MESH_HEALTH_SERVER_ATTENTION_OFF_EVT);
}
#endif /* CONFIG_BLE_MESH_HEALTH_SRV */

View File

@ -15,17 +15,16 @@
#include <string.h>
#include <errno.h>
#include "btc/btc_manage.h"
#include "osi/allocator.h"
#include "lighting_client.h"
#include "btc_ble_mesh_lighting_model.h"
#include "esp_ble_mesh_lighting_model_api.h"
#if CONFIG_BLE_MESH_LIGHTING_CLIENT
#include "lighting_client.h"
/* 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);
@ -40,39 +39,46 @@ void btc_ble_mesh_lighting_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, vo
btc_ble_mesh_lighting_client_args_t *src = (btc_ble_mesh_lighting_client_args_t *)p_src;
if (!msg || !dst || !src) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (msg->act) {
case BTC_BLE_MESH_ACT_LIGHTING_CLIENT_GET_STATE: {
dst->light_client_get_state.params = (esp_ble_mesh_client_common_param_t *)osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
dst->light_client_get_state.get_state = (esp_ble_mesh_light_client_get_state_t *)osi_malloc(sizeof(esp_ble_mesh_light_client_get_state_t));
if (dst->light_client_get_state.params && dst->light_client_get_state.get_state) {
dst->light_client_get_state.params = (esp_ble_mesh_client_common_param_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (dst->light_client_get_state.params) {
memcpy(dst->light_client_get_state.params, src->light_client_get_state.params,
sizeof(esp_ble_mesh_client_common_param_t));
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 {
LOG_ERROR("%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) {
dst->light_client_get_state.get_state = (esp_ble_mesh_light_client_get_state_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_light_client_get_state_t));
if (dst->light_client_get_state.get_state) {
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, Out of memory, act %d", __func__, msg->act);
}
}
break;
}
case BTC_BLE_MESH_ACT_LIGHTING_CLIENT_SET_STATE: {
dst->light_client_set_state.params = (esp_ble_mesh_client_common_param_t *)osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
dst->light_client_set_state.set_state = (esp_ble_mesh_light_client_set_state_t *)osi_malloc(sizeof(esp_ble_mesh_light_client_set_state_t));
dst->light_client_set_state.params = (esp_ble_mesh_client_common_param_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
dst->light_client_set_state.set_state = (esp_ble_mesh_light_client_set_state_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_light_client_set_state_t));
if (dst->light_client_set_state.params && dst->light_client_set_state.set_state) {
memcpy(dst->light_client_set_state.params, src->light_client_set_state.params,
sizeof(esp_ble_mesh_client_common_param_t));
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 {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
}
break;
}
default:
LOG_DEBUG("%s, Unknown deep copy act %d", __func__, msg->act);
BT_DBG("%s, Unknown act %d", __func__, msg->act);
break;
}
}
@ -82,7 +88,7 @@ static void btc_ble_mesh_lighting_client_arg_deep_free(btc_msg_t *msg)
btc_ble_mesh_lighting_client_args_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -91,18 +97,18 @@ static void btc_ble_mesh_lighting_client_arg_deep_free(btc_msg_t *msg)
switch (msg->act) {
case BTC_BLE_MESH_ACT_LIGHTING_CLIENT_GET_STATE:
if (arg->light_client_get_state.params) {
osi_free(arg->light_client_get_state.params);
bt_mesh_free(arg->light_client_get_state.params);
}
if (arg->light_client_get_state.get_state) {
osi_free(arg->light_client_get_state.get_state);
bt_mesh_free(arg->light_client_get_state.get_state);
}
break;
case BTC_BLE_MESH_ACT_LIGHTING_CLIENT_SET_STATE:
if (arg->light_client_set_state.params) {
osi_free(arg->light_client_set_state.params);
bt_mesh_free(arg->light_client_set_state.params);
}
if (arg->light_client_set_state.set_state) {
osi_free(arg->light_client_set_state.set_state);
bt_mesh_free(arg->light_client_set_state.set_state);
}
break;
default:
@ -114,17 +120,17 @@ static void btc_ble_mesh_lighting_client_copy_req_data(btc_msg_t *msg, void *p_d
{
esp_ble_mesh_light_client_cb_param_t *p_dest_data = (esp_ble_mesh_light_client_cb_param_t *)p_dest;
esp_ble_mesh_light_client_cb_param_t *p_src_data = (esp_ble_mesh_light_client_cb_param_t *)p_src;
u16_t length;
uint16_t length = 0U;
if (!msg || !p_src_data || !p_dest_data) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
if (p_src_data->params) {
p_dest_data->params = osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (!p_dest_data->params) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
@ -144,7 +150,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) {
LOG_ERROR("%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,
@ -168,7 +174,7 @@ static void btc_ble_mesh_lighting_client_free_req_data(btc_msg_t *msg)
esp_ble_mesh_light_client_cb_param_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -191,7 +197,7 @@ static void btc_ble_mesh_lighting_client_free_req_data(btc_msg_t *msg)
}
case ESP_BLE_MESH_LIGHT_CLIENT_TIMEOUT_EVT:
if (arg->params) {
osi_free(arg->params);
bt_mesh_free(arg->params);
}
break;
default:
@ -203,7 +209,7 @@ static void btc_ble_mesh_lighting_client_callback(esp_ble_mesh_light_client_cb_p
{
btc_msg_t msg = {0};
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
/* If corresponding callback is not registered, event will not be posted. */
if (!btc_profile_cb_get(BTC_PID_LIGHTING_CLIENT)) {
@ -214,22 +220,21 @@ 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)
void bt_mesh_lighting_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const uint8_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;
uint8_t act;
uint8_t act = 0U;
if (!model || !ctx) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -247,7 +252,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:
LOG_ERROR("%s, Unknown lighting client event type", __func__);
BT_ERR("Unknown Lighting client event type %d", evt_type);
return;
}
@ -259,31 +264,31 @@ void bt_mesh_lighting_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
params.ctx.recv_ttl = ctx->recv_ttl;
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(uint32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
if (!model || !ctx || !buf) {
LOG_ERROR("%s, Invalid parameter", __func__);
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;
}
@ -293,10 +298,9 @@ 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) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -305,12 +309,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)) {
LOG_ERROR("%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;
@ -319,10 +317,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);
@ -331,12 +329,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)) {
LOG_ERROR("%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;
@ -345,10 +337,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);
@ -368,7 +360,7 @@ void btc_ble_mesh_lighting_client_cb_handler(btc_msg_t *msg)
esp_ble_mesh_light_client_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -377,18 +369,21 @@ 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 {
LOG_ERROR("%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);
return;
}
#endif /* CONFIG_BLE_MESH_LIGHTING_CLIENT */
#if CONFIG_BLE_MESH_LIGHTING_SERVER
/* 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);
@ -401,10 +396,10 @@ static void btc_ble_mesh_lighting_server_copy_req_data(btc_msg_t *msg, void *p_d
{
esp_ble_mesh_lighting_server_cb_param_t *p_dest_data = (esp_ble_mesh_lighting_server_cb_param_t *)p_dest;
esp_ble_mesh_lighting_server_cb_param_t *p_src_data = (esp_ble_mesh_lighting_server_cb_param_t *)p_src;
u16_t length;
uint16_t length = 0U;
if (!msg || !p_src_data || !p_dest_data) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -416,7 +411,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) {
LOG_ERROR("%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,
@ -432,7 +427,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) {
LOG_ERROR("%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,
@ -447,7 +442,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) {
LOG_ERROR("%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,
@ -466,7 +461,7 @@ static void btc_ble_mesh_lighting_server_free_req_data(btc_msg_t *msg)
esp_ble_mesh_lighting_server_cb_param_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -499,7 +494,7 @@ static void btc_ble_mesh_lighting_server_callback(esp_ble_mesh_lighting_server_c
{
btc_msg_t msg = {0};
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
/* If corresponding callback is not registered, event will not be posted. */
if (!btc_profile_cb_get(BTC_PID_LIGHTING_SERVER)) {
@ -510,21 +505,19 @@ 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(uint8_t evt_type, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const uint8_t *val, size_t len)
{
esp_ble_mesh_lighting_server_cb_param_t cb_params = {0};
size_t length;
uint8_t act;
uint8_t act = 0U;
if (model == NULL || ctx == NULL) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -542,7 +535,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:
LOG_ERROR("%s, Unknown Lighting Server event type", __func__);
BT_ERR("Unknown Lighting server event type %d", evt_type);
return;
}
@ -553,10 +546,11 @@ void bt_mesh_lighting_server_cb_evt_to_btc(u8_t evt_type,
cb_params.ctx.recv_ttl = ctx->recv_ttl;
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);
@ -568,7 +562,7 @@ void btc_ble_mesh_lighting_server_cb_handler(btc_msg_t *msg)
esp_ble_mesh_lighting_server_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -577,9 +571,11 @@ 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 {
LOG_ERROR("%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);
return;
}
}
#endif /* CONFIG_BLE_MESH_LIGHTING_SERVER */

File diff suppressed because it is too large Load Diff

View File

@ -15,17 +15,16 @@
#include <string.h>
#include <errno.h>
#include "btc/btc_manage.h"
#include "osi/allocator.h"
#include "sensor_client.h"
#include "btc_ble_mesh_sensor_model.h"
#include "esp_ble_mesh_sensor_model_api.h"
#if CONFIG_BLE_MESH_SENSOR_CLI
#include "sensor_client.h"
/* 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);
@ -38,17 +37,17 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
{
btc_ble_mesh_sensor_client_args_t *dst = (btc_ble_mesh_sensor_client_args_t *)p_dest;
btc_ble_mesh_sensor_client_args_t *src = (btc_ble_mesh_sensor_client_args_t *)p_src;
u16_t length;
uint16_t length = 0U;
if (!msg || !dst || !src) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (msg->act) {
case BTC_BLE_MESH_ACT_SENSOR_CLIENT_GET_STATE: {
dst->sensor_client_get_state.params = (esp_ble_mesh_client_common_param_t *)osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
dst->sensor_client_get_state.get_state = (esp_ble_mesh_sensor_client_get_state_t *)osi_malloc(sizeof(esp_ble_mesh_sensor_client_get_state_t));
dst->sensor_client_get_state.params = (esp_ble_mesh_client_common_param_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
dst->sensor_client_get_state.get_state = (esp_ble_mesh_sensor_client_get_state_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_sensor_client_get_state_t));
if (dst->sensor_client_get_state.params && dst->sensor_client_get_state.get_state) {
memcpy(dst->sensor_client_get_state.params, src->sensor_client_get_state.params,
sizeof(esp_ble_mesh_client_common_param_t));
@ -61,7 +60,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) {
LOG_ERROR("%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,
@ -74,7 +73,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) {
LOG_ERROR("%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,
@ -85,7 +84,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) {
LOG_ERROR("%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,
@ -97,13 +96,13 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
break;
}
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
}
break;
}
case BTC_BLE_MESH_ACT_SENSOR_CLIENT_SET_STATE: {
dst->sensor_client_set_state.params = (esp_ble_mesh_client_common_param_t *)osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
dst->sensor_client_set_state.set_state = (esp_ble_mesh_sensor_client_set_state_t *)osi_malloc(sizeof(esp_ble_mesh_sensor_client_set_state_t));
dst->sensor_client_set_state.params = (esp_ble_mesh_client_common_param_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
dst->sensor_client_set_state.set_state = (esp_ble_mesh_sensor_client_set_state_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_sensor_client_set_state_t));
if (dst->sensor_client_set_state.params && dst->sensor_client_set_state.set_state) {
memcpy(dst->sensor_client_set_state.params, src->sensor_client_set_state.params,
sizeof(esp_ble_mesh_client_common_param_t));
@ -116,7 +115,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) {
LOG_ERROR("%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,
@ -127,7 +126,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) {
LOG_ERROR("%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,
@ -138,7 +137,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) {
LOG_ERROR("%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,
@ -149,7 +148,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) {
LOG_ERROR("%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,
@ -162,7 +161,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) {
LOG_ERROR("%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,
@ -174,12 +173,12 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
break;
}
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
}
break;
}
default:
LOG_DEBUG("%s, Unknown deep copy act %d", __func__, msg->act);
BT_DBG("%s, Unknown act %d", __func__, msg->act);
break;
}
}
@ -189,7 +188,7 @@ void btc_ble_mesh_sensor_client_arg_deep_free(btc_msg_t *msg)
btc_ble_mesh_sensor_client_args_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -211,10 +210,10 @@ void btc_ble_mesh_sensor_client_arg_deep_free(btc_msg_t *msg)
break;
}
}
osi_free(arg->sensor_client_get_state.get_state);
bt_mesh_free(arg->sensor_client_get_state.get_state);
}
if (arg->sensor_client_get_state.params) {
osi_free(arg->sensor_client_get_state.params);
bt_mesh_free(arg->sensor_client_get_state.params);
}
break;
case BTC_BLE_MESH_ACT_SENSOR_CLIENT_SET_STATE:
@ -234,10 +233,10 @@ void btc_ble_mesh_sensor_client_arg_deep_free(btc_msg_t *msg)
break;
}
}
osi_free(arg->sensor_client_set_state.set_state);
bt_mesh_free(arg->sensor_client_set_state.set_state);
}
if (arg->sensor_client_set_state.params) {
osi_free(arg->sensor_client_set_state.params);
bt_mesh_free(arg->sensor_client_set_state.params);
}
break;
default:
@ -249,17 +248,17 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des
{
esp_ble_mesh_sensor_client_cb_param_t *p_dest_data = (esp_ble_mesh_sensor_client_cb_param_t *)p_dest;
esp_ble_mesh_sensor_client_cb_param_t *p_src_data = (esp_ble_mesh_sensor_client_cb_param_t *)p_src;
u16_t length;
uint16_t length = 0U;
if (!msg || !p_src_data || !p_dest_data) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
if (p_src_data->params) {
p_dest_data->params = osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (!p_dest_data->params) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
@ -278,7 +277,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) {
LOG_ERROR("%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,
@ -293,7 +292,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) {
LOG_ERROR("%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,
@ -307,7 +306,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) {
LOG_ERROR("%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,
@ -322,7 +321,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) {
LOG_ERROR("%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,
@ -336,7 +335,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) {
LOG_ERROR("%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,
@ -350,7 +349,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) {
LOG_ERROR("%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,
@ -364,7 +363,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) {
LOG_ERROR("%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,
@ -388,7 +387,7 @@ static void btc_ble_mesh_sensor_client_free_req_data(btc_msg_t *msg)
esp_ble_mesh_sensor_client_cb_param_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -436,7 +435,7 @@ static void btc_ble_mesh_sensor_client_free_req_data(btc_msg_t *msg)
}
case ESP_BLE_MESH_SENSOR_CLIENT_TIMEOUT_EVT:
if (arg->params) {
osi_free(arg->params);
bt_mesh_free(arg->params);
}
break;
default:
@ -448,7 +447,7 @@ static void btc_ble_mesh_sensor_client_callback(esp_ble_mesh_sensor_client_cb_pa
{
btc_msg_t msg = {0};
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
/* If corresponding callback is not registered, event will not be posted. */
if (!btc_profile_cb_get(BTC_PID_SENSOR_CLIENT)) {
@ -459,22 +458,21 @@ 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)
void bt_mesh_sensor_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const uint8_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;
uint8_t act;
uint8_t act = 0U;
if (!model || !ctx) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -492,7 +490,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:
LOG_ERROR("%s, Unknown sensor client event type %d", __func__, evt_type);
BT_ERR("Unknown Sensor client event type %d", evt_type);
return;
}
@ -504,31 +502,31 @@ void bt_mesh_sensor_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
params.ctx.recv_ttl = ctx->recv_ttl;
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(uint32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
if (!model || !ctx || !buf) {
LOG_ERROR("%s, Invalid parameter", __func__);
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;
}
@ -538,10 +536,9 @@ 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) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -550,12 +547,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)) {
LOG_ERROR("%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;
@ -564,10 +555,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);
@ -576,12 +567,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)) {
LOG_ERROR("%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;
@ -590,10 +575,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);
@ -613,7 +598,7 @@ void btc_ble_mesh_sensor_client_cb_handler(btc_msg_t *msg)
esp_ble_mesh_sensor_client_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -622,18 +607,21 @@ 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 {
LOG_ERROR("%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);
return;
}
#endif /* CONFIG_BLE_MESH_SENSOR_CLI */
#if CONFIG_BLE_MESH_SENSOR_SERVER
/* 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);
@ -646,10 +634,10 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des
{
esp_ble_mesh_sensor_server_cb_param_t *p_dest_data = (esp_ble_mesh_sensor_server_cb_param_t *)p_dest;
esp_ble_mesh_sensor_server_cb_param_t *p_src_data = (esp_ble_mesh_sensor_server_cb_param_t *)p_src;
u16_t length;
uint16_t length = 0U;
if (!msg || !p_src_data || !p_dest_data) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -661,7 +649,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) {
LOG_ERROR("%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,
@ -672,7 +660,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) {
LOG_ERROR("%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,
@ -683,7 +671,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) {
LOG_ERROR("%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,
@ -694,7 +682,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) {
LOG_ERROR("%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,
@ -707,7 +695,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) {
LOG_ERROR("%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,
@ -722,7 +710,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) {
LOG_ERROR("%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,
@ -734,7 +722,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) {
LOG_ERROR("%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,
@ -750,7 +738,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) {
LOG_ERROR("%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,
@ -763,7 +751,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) {
LOG_ERROR("%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,
@ -782,7 +770,7 @@ static void btc_ble_mesh_sensor_server_free_req_data(btc_msg_t *msg)
esp_ble_mesh_sensor_server_cb_param_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -826,7 +814,7 @@ static void btc_ble_mesh_sensor_server_callback(esp_ble_mesh_sensor_server_cb_pa
{
btc_msg_t msg = {0};
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
/* If corresponding callback is not registered, event will not be posted. */
if (!btc_profile_cb_get(BTC_PID_SENSOR_SERVER)) {
@ -837,21 +825,19 @@ 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(uint8_t evt_type, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const uint8_t *val, size_t len)
{
esp_ble_mesh_sensor_server_cb_param_t cb_params = {0};
size_t length;
uint8_t act;
uint8_t act = 0U;
if (model == NULL || ctx == NULL) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -866,7 +852,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:
LOG_ERROR("%s, Unknown Sensor Server event type", __func__);
BT_ERR("Unknown Sensor server event type %d", evt_type);
return;
}
@ -877,10 +863,11 @@ void bt_mesh_sensor_server_cb_evt_to_btc(u8_t evt_type,
cb_params.ctx.recv_ttl = ctx->recv_ttl;
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);
@ -892,7 +879,7 @@ void btc_ble_mesh_sensor_server_cb_handler(btc_msg_t *msg)
esp_ble_mesh_sensor_server_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -901,9 +888,11 @@ 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 {
LOG_ERROR("%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);
return;
}
#endif /* CONFIG_BLE_MESH_SENSOR_SERVER */

View File

@ -15,17 +15,16 @@
#include <string.h>
#include <errno.h>
#include "btc/btc_manage.h"
#include "osi/allocator.h"
#include "time_scene_client.h"
#include "btc_ble_mesh_time_scene_model.h"
#include "esp_ble_mesh_time_scene_model_api.h"
#if CONFIG_BLE_MESH_TIME_SCENE_CLIENT
#include "time_scene_client.h"
/* 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);
@ -40,39 +39,46 @@ void btc_ble_mesh_time_scene_client_arg_deep_copy(btc_msg_t *msg, void *p_dest,
btc_ble_mesh_time_scene_client_args_t *src = (btc_ble_mesh_time_scene_client_args_t *)p_src;
if (!msg || !dst || !src) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (msg->act) {
case BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_GET_STATE: {
dst->time_scene_client_get_state.params = (esp_ble_mesh_client_common_param_t *)osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
dst->time_scene_client_get_state.get_state = (esp_ble_mesh_time_scene_client_get_state_t *)osi_malloc(sizeof(esp_ble_mesh_time_scene_client_get_state_t));
if (dst->time_scene_client_get_state.params && dst->time_scene_client_get_state.get_state) {
dst->time_scene_client_get_state.params = (esp_ble_mesh_client_common_param_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (dst->time_scene_client_get_state.params) {
memcpy(dst->time_scene_client_get_state.params, src->time_scene_client_get_state.params,
sizeof(esp_ble_mesh_client_common_param_t));
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 {
LOG_ERROR("%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) {
dst->time_scene_client_get_state.get_state = (esp_ble_mesh_time_scene_client_get_state_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_time_scene_client_get_state_t));
if (dst->time_scene_client_get_state.get_state) {
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, Out of memory, act %d", __func__, msg->act);
}
}
break;
}
case BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_SET_STATE: {
dst->time_scene_client_set_state.params = (esp_ble_mesh_client_common_param_t *)osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
dst->time_scene_client_set_state.set_state = (esp_ble_mesh_time_scene_client_set_state_t *)osi_malloc(sizeof(esp_ble_mesh_time_scene_client_set_state_t));
dst->time_scene_client_set_state.params = (esp_ble_mesh_client_common_param_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
dst->time_scene_client_set_state.set_state = (esp_ble_mesh_time_scene_client_set_state_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_time_scene_client_set_state_t));
if (dst->time_scene_client_set_state.params && dst->time_scene_client_set_state.set_state) {
memcpy(dst->time_scene_client_set_state.params, src->time_scene_client_set_state.params,
sizeof(esp_ble_mesh_client_common_param_t));
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 {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
}
break;
}
default:
LOG_DEBUG("%s, Unknown deep copy act %d", __func__, msg->act);
BT_DBG("%s, Unknown act %d", __func__, msg->act);
break;
}
}
@ -82,7 +88,7 @@ void btc_ble_mesh_time_scene_client_arg_deep_free(btc_msg_t *msg)
btc_ble_mesh_time_scene_client_args_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -91,18 +97,18 @@ void btc_ble_mesh_time_scene_client_arg_deep_free(btc_msg_t *msg)
switch (msg->act) {
case BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_GET_STATE:
if (arg->time_scene_client_get_state.params) {
osi_free(arg->time_scene_client_get_state.params);
bt_mesh_free(arg->time_scene_client_get_state.params);
}
if (arg->time_scene_client_get_state.get_state) {
osi_free(arg->time_scene_client_get_state.get_state);
bt_mesh_free(arg->time_scene_client_get_state.get_state);
}
break;
case BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_SET_STATE:
if (arg->time_scene_client_set_state.params) {
osi_free(arg->time_scene_client_set_state.params);
bt_mesh_free(arg->time_scene_client_set_state.params);
}
if (arg->time_scene_client_set_state.set_state) {
osi_free(arg->time_scene_client_set_state.set_state);
bt_mesh_free(arg->time_scene_client_set_state.set_state);
}
break;
default:
@ -114,17 +120,17 @@ static void btc_ble_mesh_time_scene_client_copy_req_data(btc_msg_t *msg, void *p
{
esp_ble_mesh_time_scene_client_cb_param_t *p_dest_data = (esp_ble_mesh_time_scene_client_cb_param_t *)p_dest;
esp_ble_mesh_time_scene_client_cb_param_t *p_src_data = (esp_ble_mesh_time_scene_client_cb_param_t *)p_src;
u16_t length;
uint16_t length = 0U;
if (!msg || !p_src_data || !p_dest_data) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
if (p_src_data->params) {
p_dest_data->params = osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (!p_dest_data->params) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
@ -145,7 +151,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) {
LOG_ERROR("%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,
@ -169,7 +175,7 @@ static void btc_ble_mesh_time_scene_client_free_req_data(btc_msg_t *msg)
esp_ble_mesh_time_scene_client_cb_param_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -193,7 +199,7 @@ static void btc_ble_mesh_time_scene_client_free_req_data(btc_msg_t *msg)
}
case ESP_BLE_MESH_TIME_SCENE_CLIENT_TIMEOUT_EVT:
if (arg->params) {
osi_free(arg->params);
bt_mesh_free(arg->params);
}
break;
default:
@ -205,7 +211,7 @@ static void btc_ble_mesh_time_scene_client_callback(esp_ble_mesh_time_scene_clie
{
btc_msg_t msg = {0};
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
/* If corresponding callback is not registered, event will not be posted. */
if (!btc_profile_cb_get(BTC_PID_TIME_SCENE_CLIENT)) {
@ -216,22 +222,21 @@ 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)
void bt_mesh_time_scene_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const uint8_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;
uint8_t act;
uint8_t act = 0U;
if (!model || !ctx) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -249,7 +254,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:
LOG_ERROR("%s, Unknown time scene client event type %d", __func__, evt_type);
BT_ERR("Unknown Time Scene client event type %d", evt_type);
return;
}
@ -261,31 +266,31 @@ void bt_mesh_time_scene_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
params.ctx.recv_ttl = ctx->recv_ttl;
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(uint32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
if (!model || !ctx || !buf) {
LOG_ERROR("%s, Invalid parameter", __func__);
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;
}
@ -295,10 +300,9 @@ 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) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -307,12 +311,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)) {
LOG_ERROR("%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;
@ -321,10 +319,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);
@ -333,12 +331,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)) {
LOG_ERROR("%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;
@ -347,10 +339,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);
@ -370,7 +362,7 @@ void btc_ble_mesh_time_scene_client_cb_handler(btc_msg_t *msg)
esp_ble_mesh_time_scene_client_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -379,18 +371,21 @@ 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 {
LOG_ERROR("%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);
return;
}
#endif /* CONFIG_BLE_MESH_TIME_SCENE_CLIENT */
#if CONFIG_BLE_MESH_TIME_SCENE_SERVER
/* 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);
@ -403,7 +398,7 @@ static void btc_ble_mesh_time_scene_server_callback(esp_ble_mesh_time_scene_serv
{
btc_msg_t msg = {0};
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
/* If corresponding callback is not registered, event will not be posted. */
if (!btc_profile_cb_get(BTC_PID_TIME_SCENE_SERVER)) {
@ -414,21 +409,18 @@ 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(uint8_t evt_type, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const uint8_t *val, size_t len)
{
esp_ble_mesh_time_scene_server_cb_param_t cb_params = {0};
size_t length;
uint8_t act;
uint8_t act = 0U;
if (model == NULL || ctx == NULL) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -446,7 +438,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:
LOG_ERROR("%s, Unknown Time Scene Server event type", __func__);
BT_ERR("Unknown Time Scene server event type %d", evt_type);
return;
}
@ -457,10 +449,11 @@ void bt_mesh_time_scene_server_cb_evt_to_btc(u8_t evt_type,
cb_params.ctx.recv_ttl = ctx->recv_ttl;
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);
@ -472,7 +465,7 @@ void btc_ble_mesh_time_scene_server_cb_handler(btc_msg_t *msg)
esp_ble_mesh_time_scene_server_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -481,9 +474,10 @@ 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 {
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
BT_ERR("%s, Unknown act %d", __func__, msg->act);
}
return;
}
#endif /* CONFIG_BLE_MESH_TIME_SCENE_SERVER */

View File

@ -0,0 +1,62 @@
// Copyright 2020 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef _BTC_BLE_MESH_BLE_H_
#define _BTC_BLE_MESH_BLE_H_
#include <stdint.h>
#include "btc/btc_manage.h"
#include "mesh_bearer_adapt.h"
#include "esp_ble_mesh_ble_api.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef union {
struct {
esp_ble_mesh_ble_adv_param_t param;
esp_ble_mesh_ble_adv_data_t data;
} start_ble_adv;
struct {
uint8_t index;
} stop_ble_adv;
struct {
esp_ble_mesh_ble_scan_param_t param;
} start_ble_scan;
struct {
/* RFU */
} stop_ble_scan;
} btc_ble_mesh_ble_args_t;
typedef enum {
BTC_BLE_MESH_ACT_START_BLE_ADV,
BTC_BLE_MESH_ACT_STOP_BLE_ADV,
BTC_BLE_MESH_ACT_START_BLE_SCAN,
BTC_BLE_MESH_ACT_STOP_BLE_SCAN,
} btc_ble_mesh_ble_act_t;
void bt_mesh_ble_scan_cb_evt_to_btc(const bt_mesh_addr_t *addr,
uint8_t adv_type, uint8_t data[],
uint16_t length, int8_t rssi);
void btc_ble_mesh_ble_call_handler(btc_msg_t *msg);
void btc_ble_mesh_ble_cb_handler(btc_msg_t *msg);
#ifdef __cplusplus
}
#endif
#endif /* _BTC_BLE_MESH_BLE_H_ */

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