Compare commits

...

2093 Commits

Author SHA1 Message Date
03fc307e21 versions: Update version to 4.0.3 2021-06-24 17:35:06 +08:00
ee8c27e5e3 Merge branch 'bugfix/AuthValue_leak_v4.0' into 'release/v4.0'
ble_mesh: stack: Fix AuthValue Leak and Predictable AuthValue in Bluetooth... (v4.0)

See merge request espressif/esp-idf!14005
2021-06-18 03:47:47 +00:00
6ba3ae339b ble_mesh: stack: Fix AuthValue Leak and Predictable AuthValue in Bluetooth Mesh Provisioning Leads to MITM 2021-06-17 16:53:07 +08:00
3ea9deff82 Merge branch 'bugfix/impersonation_attacks_and_AuthValue_disclosure_v4.0' into 'release/v4.0'
ble_mesh: stack: Add check the value of Provisioning Random & Confirmation... (v4.0)

See merge request espressif/esp-idf!13924
2021-06-17 07:38:45 +00:00
f9b2bba5a4 ble_mesh: stack: Add check the value of Provisioning Random & Confirmation sent and received by provisioner 2021-06-16 21:28:52 +08:00
577aef29ad Merge branch 'bugfix/btdm_enable_gattc_cache_will_crash_v4.0' into 'release/v4.0'
component/bt: fix enable gattc nvs cache lead to crash

See merge request espressif/esp-idf!13916
2021-06-10 02:56:25 +00:00
8ca5068f20 Merge branch 'bugfix/bt_impersonation_passkey_fix_v4.0' into 'release/v4.0'
Bluedroid: Check only x component of passkey to avoid passkey impersonation attack. (v4.0)

See merge request espressif/esp-idf!13898
2021-06-09 06:32:42 +00:00
e42479e129 Bluedroid: Check only x component of passkey to avoid passkey impersonation attack. 2021-06-08 10:09:21 +05:30
3892a92d80 component/bt: fix enable gattc nvs cache lead to crash 2021-06-07 18:03:19 +08:00
bdbfdcdf5c Merge branch 'bugfix/partition_table_integrity_check_v4.0' into 'release/v4.0'
paritition_table: Verify the partition table md5sum when loading in the app (v4.0)

See merge request espressif/esp-idf!13586
2021-06-03 02:14:28 +00:00
c572e0bf5f 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:30:02 +10:00
b23f8e21cd Merge branch 'ci/ttfw_fix_dut_exception_not_added_to_junit_report_v4.0' into 'release/v4.0'
ttfw: fix DUT exception not added to junit report (v4.0)

See merge request espressif/esp-idf!13614
2021-05-26 03:12:41 +00:00
1a415f3e31 Merge branch 'nimble/fix_ble_sm_sc_pub_key_v4.0' into 'release/v4.0'
NimBLE: Fix MITM vulnerability and free AES context (v4.0)

See merge request espressif/esp-idf!13599
2021-05-25 14:27:33 +00:00
fc9f2e8782 NimBLE: Fix MITM vulnerability and free AES context (v4.0) 2021-05-25 14:57:37 +05:30
091681faec ttfw: fix DUT exception not added to junit report 2021-05-20 16:57:06 +08:00
532d0a72c3 Merge branch 'nimble/fix_host_flow_ctrl_v4.0' into 'release/v4.0'
NimBLE: Fix host flow control in NimBLE porting layer and host (release/v4.0)

See merge request espressif/esp-idf!13577
2021-05-19 09:50:27 +00:00
51623fd4ce Merge branch 'feature/oocd_ver_backport_v4.0' into 'release/v4.0'
Feature/oocd ver backport v4.0

See merge request espressif/esp-idf!11378
2021-05-19 07:57:38 +00:00
0242438e9d Merge branch 'bugfix/setjmp_longjmp_4.0' into 'release/v4.0'
[system]: Made longjmp save for context switch (backport v4.0)

See merge request espressif/esp-idf!13503
2021-05-19 01:39:51 +00:00
e123d89625 NimBLE: Update submodule to fix host flow control bugs. 2021-05-18 19:01:28 +05:30
b57b6f1adb NimBLE: Fix host flow control in NimBLE porting layer.
- Register `ble_hs_flow_acl_free` callback in NimBLE porting layer.
2021-05-17 20:01:17 +05:30
4ba4b5780e Merge branch 'bugfix/python3_target_test_4.0' into 'release/v4.0'
ci: using python3 to tun target test (4.0)

See merge request espressif/esp-idf!13241
2021-05-11 09:15:18 +00:00
0d99d2a1a1 tools: Updates OpenOCD version to 'v0.10.0-esp32-20210401' 2021-05-10 16:23:48 +00:00
19eab31660 [system]: Made longjmp save for context switch
* Patched longjmp to be context-switch safe
  longjmp modifies the windowbase and windowstart
  registers, which isn't safe if a context switch
  occurs during the modification. After a context
  switch, windowstart and windowbase will be
  different, leading to a wrongly set windowstart
  bit due to longjmp writing it based on the
  windowbase before the context switch. This
  corrupts the registers at the next window
  overflow reaching that wrongly set bit.

  The solution is to disable interrupts during
  this code. It is only 6 instructions long,
  the impact shouldn't be significant.

  The fix is implemented as a wrapper which
  replaces the original first instructions of
  longjmp which are buggy. Then, it jumps back
  to execute the rest of the original longjmp
  function.

  Added a comparably reliable test to the
  test apps.
2021-05-10 19:21:56 +08:00
fa1f7e112c Merge branch 'feature/twdt_prints_backtrace_v4.0' into 'release/v4.0'
Add Task Watchdog backtrace printing (v4.0)

See merge request espressif/esp-idf!12618
2021-05-10 09:47:28 +00:00
f5c4e5e7d2 Merge branch 'bugfix/gtk_reinstallation_fix_v4.0' into 'release/v4.0'
wpa_supplicant: Prevent reinstallation of an already in-use group key (v4.0)

See merge request espressif/esp-idf!13184
2021-05-10 08:33:46 +00:00
ce99b662c2 Merge branch 'bugfix/freemodbus_fix_event_processing_after_destroy_backport40' into 'release/v4.0'
freemodbus: fix event processing failure after destroy (backport v4.0)

See merge request espressif/esp-idf!9323
2021-05-10 08:30:45 +00:00
940e108c4b freemodbus: fix event processing failure after destroy
Closes https://github.com/espressif/esp-idf/issues/5275
2021-05-10 08:43:42 +02:00
39a3d1df8e wpa_supplicant: Group key reinstallation fixes
This commit reverts previous commit for GTK reinstallation fix
and corrects original fix.
2021-05-10 11:22:01 +05:30
c5f0a609c8 wpa_supplicant: Prevent reinstallation of an already in-use group key 2021-05-10 11:22:01 +05:30
1ce0d7bcf4 Merge branch 'bugfix/scheduler_start_iram_v4.0' into 'release/v4.0'
freertos: move some of the initialization functions out of IRAM (v4.0)

See merge request espressif/esp-idf!11222
2021-05-10 04:36:16 +00:00
dba7cab2d9 Merge branch 'bugfix/spi_fix_duplex_switch_v4.0' into 'release/v4.0'
spi_master: fix duplex mode switch issue for multi devices (4.0)

See merge request espressif/esp-idf!11235
2021-05-10 04:13:28 +00:00
6b294bac4c Merge branch 'bugfix/fix_set_channel_error_after_wifi_stop_v4.0' into 'release/v4.0'
esp_wifi: Fix setting channel error after WiFi stop ( backport v4.0)

See merge request espressif/esp-idf!13452
2021-05-10 03:18:32 +00:00
66b2b5f45c Merge branch 'feature/nvs_allow_custom_part_4.0' into 'release/v4.0'
Feature/nvs allow custom part 4.0

See merge request espressif/esp-idf!9519
2021-05-10 03:13:47 +00:00
29d6823d2f Add Task Watchdog backtrace printing
This commit makes the Task Watchdog print the backtrace of both
cores when it times out.
2021-05-10 03:09:20 +00:00
676905709a Merge branch 'bugfix/fix_uart_module_enable_issue_4.0' into 'release/v4.0'
driver(uart): fix uart module reset issue (release V4.0)

See merge request espressif/esp-idf!11971
2021-05-10 03:07:41 +00:00
b89b1ec022 Merge branch 'bugfix/ble_timeout_disconnected_no_report_v4.0' into 'release/v4.0'
Fix the issue that the controller do not report the timeout disconnect event

See merge request espressif/esp-idf!13468
2021-05-10 03:03:58 +00:00
763aa66036 Merge branch 'bugfix/generate_value_0_when_prov_auth_v4.0' into 'release/v4.0'
ble_mesh: stack: Fix provisioning input or output count number should be at least 1 (v4.0)

See merge request espressif/esp-idf!13482
2021-05-08 12:54:53 +00:00
4a24cb7d8f esp_wifi: fix some wifi bugs
1. Fix setting channel error after WiFi stop
2. Fixed issue of reason code change from 15 to 204 when provide wrong password
3. Fix set config return value error
4. Fix ampdu age timer memory leak
5. Add beacon timeout event
6. Ignore dirtyBuf check when buffer size is larger than 4092
7. Fix SoftAP not initiating 4-way handshake if max length passphrase is set
8. Fix esptouch find hidden AP fail
9. Clear AP Bss when auth timeout happens.
10.Fix not connect to open AP when WPA3 auth fail.
11.Fix esp_wifi_80211_tx when out of memory unlock mutex issue.
12.Fix esp_wifi_80211_tx can't be used in ap mode
13.Fix hidden AP scans after connecting AP
14.Fix watchdog happens when receiving action frame
2021-05-08 19:55:00 +08:00
9ee19a35b8 Merge branch 'bugfix/spp_data_send_delay_v4.0' into 'release/v4.0'
Bugfix/spp data send delay v4.0

See merge request espressif/esp-idf!11774
2021-05-08 09:47:23 +00:00
3907e8a067 Merge branch 'bugfix/bta_hf_client_sco_co_out_data_v4.0' into 'release/v4.0'
bugfix/if bta_hf_client_sco_co_out_data is called, it will crash when sco disconnected [backport v4.0]

See merge request espressif/esp-idf!12558
2021-05-08 07:28:38 +00:00
5c0b14e167 Merge branch 'bugfix/btdm_fix_multi-con_pair_failed_and_cancle_con_state_err_v4.0' into 'release/v4.0'
fix multi con pair failed and cancel con state error (backport v4.0)

See merge request espressif/esp-idf!13477
2021-05-08 07:28:10 +00:00
970dc8cf80 Merge branch 'mesh/esp_mesh_send_block_time_v4.0' into 'release/v4.0'
esp_wifi_mesh: add esp_mesh_send_block_time to set blocking time of esp_mesh_send(backport v4.0)

See merge request espressif/esp-idf!13411
2021-05-08 07:05:53 +00:00
09e665770f components/bt: Add API to config QoS 2021-05-08 06:05:50 +00:00
e1c9aafd46 components/bt: Add QOS for SPP, to decrease the delay from slave to master 2021-05-08 06:05:50 +00:00
6826f9dbba 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 13:13:58 +08:00
zwj
eb9841e769 update con state when getting connection cancle complete 2021-05-08 03:42:02 +00:00
zwj
84df41cdf0 fix multi-connection pair failed 2021-05-08 03:42:02 +00:00
d4970113af Merge branch 'example/aligenie_v4.0' into 'release/v4.0'
ble_mesh: add aligenie ble mesh example (backport V4.0)

See merge request espressif/esp-idf!11402
2021-05-08 03:17:31 +00:00
89bff63443 ble mesh: add aligenie ble mesh example 2021-05-08 01:57:48 +00:00
acbcf13ee5 bugfix/if bta_hf_client_sco_co_out_data is called, it will crash when sco disconnected 2021-05-07 23:23:38 +00:00
522103b43a Merge branch 'bugfix/endianness_in_output_or_input_oob_v4.0' into 'release/v4.0'
ble_mesh: stack: Fix endianness error in output or input oob data of number (v4.0)

See merge request espressif/esp-idf!13257
2021-05-07 23:03:35 +00:00
c0a397e0a2 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 13:32:20 +00:00
269e903f8c Fix the issue that the controller do not report the timeout disconnect event.
This issue is caused by modem sleep.The sleep interrupt will come the second
time before the CLKN interrupt. If we disable the sleep interrupt when it
comes in the first time, the CLKN will never come.
2021-05-07 20:29:32 +08:00
755ae308d1 Merge branch 'bugfix/btdm_incorrectly_spelled_v4.0' into 'release/v4.0'
component/bt: fix Spelling mistakes (release v4.0)

See merge request espressif/esp-idf!12818
2021-05-07 09:35:00 +00:00
1fa03e6b25 Merge branch 'bugfix/backport_some_lwip_bugs_0428_v4.0' into 'release/v4.0'
lw-ip:backport bugfix lwip for v4.0(backport v4.0)

See merge request espressif/esp-idf!13376
2021-05-07 09:16:59 +00:00
1d1368858c component/bt: Modify some ambiguous descriptions (release v4.0) 2021-05-07 08:08:39 +00:00
29b8bf0221 Merge branch 'bugfix/mqtt_examples_certificates_update_v4.0' into 'release/v4.0'
bugfix/mqtt examples: Updates the CA certificates used. (v4.0)

See merge request espressif/esp-idf!13128
2021-05-07 06:45:45 +00:00
6c6e4ca637 freertos: move some of the initialization functions out of IRAM 2021-05-07 04:32:49 +00:00
ebf59642c2 esp_wifi_mesh: update wifi mesh libs
1. Add esp_mesh_send_block_time to set blocking time of esp_mesh_send
2. Fix the issue that tx beacon interval become 1 minute
2021-05-07 11:56:03 +08:00
9e9ebed861 spi: fix duplex mode switch issue for multi devices
Closes https://github.com/espressif/esp-idf/issues/1080
2021-05-06 15:56:33 +08:00
5ba7202cc1 Merge branch 'bugfix/freertos_addition_overflow_v4.0' into 'release/v4.0'
freertos: Fix addition overflow (v4.0)

See merge request espressif/esp-idf!13425
2021-05-05 23:23:01 +00:00
728f0807f4 freertos: Check for arithmetic overflows on queue creation
Addition overflow check is from FreeRTOS kernel commit 47338393f1f79558f6144213409f09f81d7c4837
2021-05-04 18:35:51 +10:00
beed6820f2 Merge branch 'bugfix/espsecure_args_v4.0' into 'release/v4.0'
esptool: Update to fix espsecure.py sign_data default version argument (v4.0)

See merge request espressif/esp-idf!13320
2021-05-03 05:57:27 +00:00
d106141032 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:19:31 +00:00
d12f023a32 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-04-30 12:20:10 +00:00
14c7c49515 Merge branch 'bugfix/remove_redundant_other_core_cache_disable_v4.0' into 'release/v4.0'
[system]: Remove redundant othercore cache disable (backport v4.0)

See merge request espressif/esp-idf!13359
2021-04-30 06:00:35 +00:00
dd26a96a29 Merge branch 'bugfix/wifi_softap_deep_sleep_current_opt_v4.0' into 'release/v4.0'
backport v4.0: optimize deep sleep current in wifi softap mode

See merge request espressif/esp-idf!13397
2021-04-30 02:50:23 +00:00
bc6a98c12c backport bugfix lwip for v4.0 2021-04-29 13:03:39 +00:00
16546a89e5 deep sleep: optimize sleep current in wifi softap mode 2021-04-29 15:13:47 +08:00
b6b44f4b4c Merge branch 'bugfix/esp_http_client_read_v4.0' into 'release/v4.0'
Fix esp_http_client_read for file size aligned to 289 bytes (v4.0)

See merge request espressif/esp-idf!13308
2021-04-29 06:07:56 +00:00
69e1d0d2d6 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-29 05:13:52 +00:00
173e8eb18c Merge branch 'bugfix/freemodbus_fix_mbm_event_processing_v40' into 'release/v4.0'
Bugfix/freemodbus fix mbm event processing v40 (backport v4.0)

See merge request espressif/esp-idf!12827
2021-04-28 15:48:57 +00:00
ef1f74174a ci: run target test with python3 2021-04-28 19:32:59 +08:00
c891be655c Merge branch 'bugfix/put_uart_isr_in_iram_v4.0' into 'release/v4.0'
uart: add option to put ISR in IRAM (v4.0)

See merge request espressif/esp-idf!13143
2021-04-28 07:03:22 +00:00
4740d8e42c driver(uart): fix uart module reset issue (release V4.0) 2021-04-27 10:12:13 +00:00
4be9f15803 remove othercore cache disable 2021-04-27 14:36:23 +08:00
d61d8a6756 Merge branch 'feature/installed_tool_failed_v4.0' into 'release/v4.0'
tools: Warning about tool being installed but failed to run. (v4.0)

See merge request espressif/esp-idf!13233
2021-04-26 14:18:08 +00:00
b0d6b95fc1 Merge branch 'feature/IDF-2612_human_readable_error_v4.0' into 'release/v4.0'
export.bat/install.bat: print human-readable error message if Git or Python are not in PATH (v4.0)

See merge request espressif/esp-idf!13229
2021-04-26 14:17:40 +00:00
d2b0cfc7e4 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:08:37 +02:00
ebbe25ec73 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:48:56 +02:00
9a6f507091 Merge branch 'bugfix/fix_i2s_channals_issue_v4.0' into 'release/v4.0'
i2s: fix i2s left/right channels swapped issue(backport v4.0)

See merge request espressif/esp-idf!12943
2021-04-26 03:39:28 +00:00
28a42ff170 Merge branch 'bugfix/extern_c_decl_4.0' into 'release/v4.0'
[cxx]: fixed extern "C" declarations (backport 4.0)

See merge request espressif/esp-idf!12744
2021-04-23 08:43:21 +00:00
179d20dbc4 Merge branch 'docs/update_CN_tran_build-system_v4.0' into 'release/v4.0'
Backport CN translation for api-guides for v4.0

See merge request espressif/esp-idf!13180
2021-04-23 07:53:07 +00:00
e1a6d45e83 Backport CN translation for api-guides for v4.0 2021-04-23 15:52:58 +08:00
8fcf311e7f Merge branch 'bugfix/calc_8m_freq_test_v4.0' into 'release/v4.0'
rtc: increase CI acceptance range for calc 8M test (v4.0)

See merge request espressif/esp-idf!13088
2021-04-23 07:31:55 +00:00
da3e3b5e28 [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:22:09 +00:00
b2bcb609ad Merge branch 'nimble/add_error_prints_acl_buf_v4.0' into 'release/v4.0'
NimBLE: Add error prints for ACL buffer exhaustion in NPL (v4.0)

See merge request espressif/esp-idf!12971
2021-04-22 06:04:33 +00:00
59fecb2f8f Merge branch 'bugfix/correct_cod_check_v4.0' into 'release/v4.0'
esp-idf: Corrected check of Class of Device for discovered devices (v4.0)

See merge request espressif/esp-idf!13022
2021-04-22 06:03:44 +00:00
48cb46af55 Merge branch 'bugfix/btdm_backport_ble_bugs_21_01_29_v4.0' into 'release/v4.0'
Bugfix/btdm backport ble bugs v4.0

See merge request espressif/esp-idf!12434
2021-04-21 15:17:12 +00:00
zwj
911ce08722 add connection parameter check 2021-04-21 12:21:57 +00:00
zwj
f637a0792d fix ble connection maximum latency is 499 2021-04-21 12:21:57 +00:00
zwj
d0b8d53410 disable bluedroid congest error log print 2021-04-21 12:21:57 +00:00
722035b846 fix read multi char failed(GATT_27001) 2021-04-21 12:21:57 +00:00
fcf36466cd fix add white list failed 2021-04-21 12:21:57 +00:00
zwj
47e5793c73 fix bluedroid repair faild if the two most significant bits of public address is '01' 2021-04-21 12:21:57 +00:00
zwj
d321ee69d5 - fix congest return value
- fix system no rsp when doing disconnect
- fix no congest event when ssc do writing performance
2021-04-21 12:21:57 +00:00
zwj
e0362061a5 fix ble read multi char err when the number of handles is more than 10 2021-04-21 12:21:57 +00:00
zwj
0776318c56 fix scan rsp length err 2021-04-21 12:21:57 +00:00
zwj
712feb1e81 fix vendor hci memory leak 2021-04-21 12:21:57 +00:00
33c4e7f953 Merge branch 'bugfix/broken_virtualenv_v4.0' into 'release/v4.0'
tools: Reinstall virtualenv if it is broken (v4.0)

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

See merge request espressif/esp-idf!13044
2021-04-20 23:34:02 +00:00
5f2a5c1f93 Merge branch 'bugfix/ci/ci_fetch_submodule_fully_match_return_first_v4.0' into 'release/v4.0'
fix(ci): ci_fetch_submodule return full match name first (v4.0)

See merge request espressif/esp-idf!13213
2021-04-20 02:35:49 +00:00
3636d44aa9 fix(ci): ci_fetch_submodule return full match name first 2021-04-19 20:24:20 +08:00
10a0d7b8cf uart: add option to put ISR in IRAM 2021-04-14 17:57:32 +08:00
17500de409 Merge branch 'bugfix/doxygen_input_file_bug_v4.0' into 'release/v4.0'
docs: fix doxygen compile warnings for doxygen 1.9.1 (v4.0)

See merge request espressif/esp-idf!13079
2021-04-12 00:44:08 +00:00
531cab5fc4 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:04 +08:00
915305fe61 rtc: increase CI acceptance range for calc 8M test 2021-04-09 15:06:46 +08:00
4e5805dec3 i2s: fix i2s left/right channels swapped issue, Closes https://github.com/espressif/esp-idf/issues/6625 2021-04-07 12:23:08 +08:00
3d83ce6d7a tools: handle exception in case of logging Unicode characters 2021-04-06 19:17:23 +02:00
5bcc93a213 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:50 +05:30
2045e8c701 NimBLE: Add error prints for ACL buffer exhaustion in NPL 2021-03-31 10:43:52 +05:30
5ca77d9d2c tools: Reinstall virtualenv if it is broken
Closes https://github.com/espressif/esp-idf/issues/6656
2021-03-29 19:28:29 +02:00
acddb8fca2 Merge branch 'bugfix/dport_init_min_stack_size_v4.0' into 'release/v4.0'
freertos: Increase minimum task stack size when stack smashing checker is enabled (v4.0)

See merge request espressif/esp-idf!12801
2021-03-29 06:42:42 +00:00
4d5dba250d Merge branch 'bugfix/remove_readdocs_badge_v4.0' into 'release/v4.0'
docs: remove the read the docs CI badge (v.4.0)

See merge request espressif/esp-idf!12844
2021-03-26 08:31:42 +00:00
36383b0648 Merge branch 'bugfix/translation_link_v4.0' into 'release/v4.0'
docs: fix "link to translation" being broken (v4.0)

See merge request espressif/esp-idf!12828
2021-03-24 11:00:09 +00:00
8d22544abf Merge branch 'bugfix/fix_tx_issue_after_esp_restart_v4.0' into 'release/v4.0'
components/bt: Shutdown Bluetooth before esp_restart.(V4.0)

See merge request espressif/esp-idf!11757
2021-03-24 06:09:04 +00:00
e46a106a89 Merge branch 'bugfix/wpa_supplicant_coverity_issue_fixes_v4.0' into 'release/v4.0'
Bugfix/wpa supplicant coverity issue fixes v4.0

See merge request espressif/esp-idf!12850
2021-03-24 04:18:28 +00:00
a5effa6bf3 Merge branch 'bugfix/revert_refactor_wifi_interface_v4.0' into 'release/v4.0'
Revert "Refactor wifi_interface_t" (v4.0)

See merge request espressif/esp-idf!12504
2021-03-23 16:19:51 +00:00
8719683deb esp_local_ctrl: Fix some memory leak issues by coverity static analyzer. 2021-03-23 12:00:29 +05:30
426e0f3948 esp_http_client: Fix some memory leak issues by coverity static analyzer. 2021-03-23 12:00:01 +05:30
53f5b64887 wifi_provisioning: Fix some memory leak issues by coverity static analyzer. 2021-03-23 11:59:34 +05:30
903f7bb99f wpa_supplicant: Fix some memory leak issues by coverity static analyzer. 2021-03-23 11:59:09 +05:30
a6e44ac881 tcp_transport: Fix some memory leak issues by coverity static analyzer. 2021-03-23 11:58:32 +05:30
3a40b3b349 fatfs: Fix some memory leak issues by coverity static analyzer. 2021-03-23 11:57:50 +05:30
87e56f132b 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:25:17 +08:00
d3fa4c3749 Merge branch 'bugfix/crash_on_enabling_verbose_logs_v4.0' into 'release/v4.0'
esp_wifi: Fixes issue of crashing when verbose logs are enabled (v4.0)

See merge request espressif/esp-idf!12493
2021-03-23 03:05:28 +00:00
33087e3f27 Merge branch 'component_bt/optimize_spp_stop_server_v4.0' into 'release/v4.0'
component_bt/Optimize SPP Stop Server API[backport v4.0]

See merge request espressif/esp-idf!12622
2021-03-22 12:59:10 +00:00
48050c7c64 Revert "Refactor wifi_interface_t"
This reverts commit 9370b74ee0.
2021-03-22 17:44:33 +08:00
0ab7751926 Merge branch 'bugfix/fix_wifi_interface_use_v4.0' into 'release/v4.0'
esp_wifi: Modify ESP_IF_WIFI_STA to WIFI_IF_STA (backport v4.0)

See merge request espressif/esp-idf!12168
2021-03-22 09:06:10 +00:00
6b251820d7 docs: fix "link to translation" being broken
The translation link would link a specifc commit hash instead of
the release name.
2021-03-22 13:55:21 +08:00
63fdd7a03c Merge branch 'bugfix/fix_arp_buffer_error_in_smart_config_v4.0' into 'release/v4.0'
bugfix/fix_arp_buffer_error_in_smart_config_v4.0

See merge request espressif/esp-idf!12256
2021-03-22 04:29:10 +00:00
3ece767fb1 Merge branch 'bugfix/fix_iperf_example_exception_handling_for_no_ap_found_v4.0' into 'release/v4.0'
bugfix/fix_iperf_example_exception_handling_for_no_ap_found_v4.0

See merge request espressif/esp-idf!12273
2021-03-22 04:28:54 +00:00
b8b91f43f1 components/bt: Fix crash in Bluetooth when esp_restart 2021-03-22 02:54:06 +00:00
862f335f05 components/bt: Shutdown Bluetooth before esp_restart. 2021-03-22 02:54:06 +00:00
e7c16f92d0 freemodbuss: fix event processing after merge 2021-03-19 23:00:03 +01:00
0e5d47836b 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:34:07 +08:00
f24e1f5601 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:33:48 +08:00
41efdb0b34 Merge branch 'bugfix/spi_master_multiple_dev_with_diff_cs_lvl_4.0' into 'release/v4.0'
spi_master: correctly set cs polarity (4.0)

See merge request espressif/esp-idf!10403
2021-03-10 15:24:06 +00:00
98c76d46bd Merge branch 'bugfix/freemodbus_fix_parity_propagation_issue_v40' into 'release/v4.0'
Bugfix/freemodbus fix parity propagation issue (backport v4.0)

See merge request espressif/esp-idf!12387
2021-03-10 03:09:38 +00:00
b9ba76ac9f Merge branch 'bugfix/fix_csa_channel_crash_v4.0' into 'release/v4.0'
esp_wifi: fix CSA and BAR crash issue(v4.0)

See merge request espressif/esp-idf!12551
2021-03-05 12:25:19 +00:00
05e3e58ebb Merge branch 'feature/add_init_and_deinit_evt_for_a2dp_4_0' into 'release/v4.0'
feature/ Add A2DP Init and Deinit Complete Evt [backport v4.0]

See merge request espressif/esp-idf!12152
2021-03-05 12:20:11 +00:00
3118147dc7 Merge branch 'bugfix/fix_a2dp_underrun_issue_4_0' into 'release/v4.0'
Fix A2DP Underrun Issue [backport v4.0]

See merge request espressif/esp-idf!12279
2021-03-05 12:17:53 +00:00
772c48041d Merge branch 'fix/esp_tls_typo_v4.0' into 'release/v4.0'
Fix/protocom_null_check(v4.0)

See merge request espressif/esp-idf!12633
2021-03-05 06:22:27 +00:00
2803e6b111 protocomm: Fixed NULL check of allocated memory
Fixes one part of - https://github.com/espressif/esp-idf/issues/6440
2021-03-05 10:21:24 +05:30
75d4004ce6 add API esp_spp_stop_srv_scn to stop a specific server 2021-03-04 15:46:10 +08:00
a0efde0997 Merge branch 'bugfix/ci_stdout_encoding_v4.0' into 'release/v4.0'
ci: Fix missing sys.stdout.encoding in python2 runners (v4.0)

See merge request espressif/esp-idf!12598
2021-03-04 06:52:32 +00:00
570694761e Merge branch 'bugfix/gpio_ci_fix_input_output_mode_v4.0' into 'release/v4.0'
test_gpio: Fix GPIO_MODE_INPUT_OUTPUT test case

See merge request espressif/esp-idf!12608
2021-03-04 06:17:27 +00:00
964bed5c1b test_gpio: Fix GPIO_MODE_INPUT_OUTPUT test case
The case sets one pin as output and the other as INPUT_OUTPUT (so output buffer
is enabled in both), then only changes level of one pin - causing a conflict.

Probably this test should be deleted, as it's not good practice for two output
pins to drive each other, but this fix also seems to work.
2021-03-04 12:20:55 +11:00
f0b32f0b79 ci: Fix missing sys.stdout.encoding in python2 runners
Regression in dad0230776
2021-03-04 09:28:02 +11:00
781b7f21dc Merge branch 'bugfix/esp_wifi_deinit_v4.0' into 'release/v4.0'
esp_wifi_deinit: Return ESP_ERR_WIFI_NOT_STOPPED if wifi is not stopped (v4.0)

See merge request espressif/esp-idf!12543
2021-03-01 05:31:44 +00:00
8f7fb5f126 esp_wifi_deinit: Return ESP_ERR_WIFI_NOT_STOPPED if wifi is not stopped
Add test case to test this workflow
2021-03-01 03:55:01 +00:00
4db922612a Merge branch 'bugfix/ttfw_example_test_fails_port_remains_open_v4.0' into 'release/v4.0'
ci: Fix CI issue if one example test fails, and if serial port returns some noise (v4.0)

See merge request espressif/esp-idf!12383
2021-02-28 23:57:08 +00:00
08828b6fe8 esp_wifi: fix CSA and BAR crash issue 2021-02-27 16:55:20 +08:00
c716d71089 esp_wifi: Fixes issue of crashing when verbose logs are enabled. 2021-02-26 19:09:28 +05:30
756cb17ae0 Merge branch 'feat/spi_flash_override_size_v4.0' into 'release/v4.0'
spi_flash: add config option to override flash size in bootloader header (v4.0)

See merge request espressif/esp-idf!12462
2021-02-26 10:07:18 +00:00
e65ed8c959 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-26 10:12:16 +08:00
8b067e25e2 Merge branch 'revert-983220e2_v4.0' into 'release/v4.0'
ci: enable RS485 related tests again (v4.0)

See merge request espressif/esp-idf!12465
2021-02-25 10:07:43 +00:00
b870f6f43c Revert "ci: temporarily disable RS485 related tests"
This reverts commit 983220e216
2021-02-23 11:06:33 +08:00
7987f7ccae Merge branch 'bugfix/eclipse_make_decode_v4.0' into 'release/v4.0'
tools: Fix Eclipse build: “UnicodeDecodeError: 'ascii' codec can't decode byte” (v4.0)

See merge request espressif/esp-idf!12360
2021-02-19 15:55:52 +00:00
37d3d920bb Merge branch 'feature/prefer_python3_in_installer_v4.0' into 'release/v4.0'
tools: Prefer python3 during install and export (v4.0)

See merge request espressif/esp-idf!12379
2021-02-19 15:54:14 +00:00
32383a6dfe Merge branch 'bugfix/ignore_null_valued_comb_key_4_0' into 'release/v4.0'
Bugfix/ignore null valued comb key 4 0

See merge request espressif/esp-idf!12356
2021-02-18 11:00:21 +00:00
0a36f36016 freemodbus: fix mb controller parity propagation issues 2021-02-17 14:05:14 +01:00
dad0230776 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:44 +11:00
2f196cface ci: Log failure to close any DUT 2021-02-15 10:48:44 +11:00
b086a41569 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:47:14 +01:00
b0f2091e63 Fix eclipse build: “UnicodeDecodeError: 'ascii' codec can't decode byte”
Closes https://github.com/espressif/esp-idf/pull/6505
2021-02-10 12:50:52 +01:00
3c7594f1ff component/bt: Added check for NULL valued combination key. 2021-02-10 15:44:12 +05:30
ce21340dc5 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:41:40 +05:30
c98b72326e 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:41:31 +05:30
857b34cfd8 Merge branch 'bugfix/softap_prov_cookies_v4.0' into 'release/v4.0'
protocomm_httpd: Use HTTP cookies to track session (v4.0)

See merge request espressif/esp-idf!12267
2021-02-09 16:59:24 +08:00
d1c9216602 Merge branch 'bugfix/ble_mesh_server_model_deinit_v4.0' into 'release/v4.0'
ble_mesh: stack: Fix deinit server models with no matching id (v4.0)

See merge request espressif/esp-idf!12315
2021-02-09 16:25:05 +08:00
498aebe38f Merge branch 'feature/self_hosted_v4.0' into 'release/v4.0'
docs: self host docs (v4.0)

See merge request espressif/esp-idf!11595
2021-02-08 14:21:01 +08:00
8e7e0973db docs: self host docs
Move doc hosting from readthedocs to espressif servers

Update CI, Sphinx configs and add IDF Sphinx theme
2021-02-08 11:54:11 +08:00
lly
dbe997ce1b ble_mesh: stack: Fix deinit server models with no matching id 2021-02-07 11:18:49 +08:00
f132cf2b8b 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-05 14:28:45 +05:30
7755d3955f 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-05 14:28:45 +05:30
22688745f6 Merge branch 'bugfix/ble_mesh_mbedtls_aes_fix_v4.0' into 'release/v4.0'
Bugfix/ble mesh mbedtls aes fix (v4.0)

See merge request espressif/esp-idf!12271
2021-02-05 14:46:08 +08:00
lly
d94289c83a ble_mesh: stack: Fix mbedtls aes ctx not deallocated 2021-02-05 03:26:49 +00:00
lly
574958367f ble_mesh: stack: Fix mbedtls aes ctx not initialized 2021-02-05 03:26:49 +00:00
5dd22738d6 Merge branch 'bugfix/esp_pm_dump_critical_v4.0' into 'release/v4.0'
esp_pm: esp_pm_dump_locks: don't print from a critical section, and fix formatting (backport v4.0)

See merge request espressif/esp-idf!12019
2021-02-05 09:52:40 +08:00
2a7aaacec6 Merge branch 'spi_dma_close_before_cpu_reset_v4.0' into 'release/v4.0'
spi: fix issue with closing DMA before CPU reset (4.0)

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

See merge request espressif/esp-idf!12263
2021-02-04 20:51:19 +08:00
ebe344f852 Fix A2DP Underrun Issue 2021-02-04 19:35:19 +08:00
5d83b9c2b0 add exception handling for iperf example's scan when no ap was found 2021-02-04 17:52:37 +08:00
948ec32caf protocomm_httpd: Change an info print to debug print as it isn't really required in the logs 2021-02-04 15:05:22 +05:30
509ff013bd fix smartconfig issue when router reply arp late 2021-02-04 11:40:05 +08:00
43127a5084 Merge branch 'bugfix/ttfw_idf_find_artifacts_inaccurate_with_same_prefix_path_v4.0' into 'release/v4.0'
CI: fix the bug returns wrong artifact path when app_name is a subset of a longer one (v4.0)

See merge request espressif/esp-idf!12230
2021-02-03 11:34:30 +08:00
a6bddd68d2 Merge branch 'feature/support_transport_keepalive_v4.0' into 'release/v4.0'
Feature/support transport keepalive v4.0 [backport v4.0]

See merge request espressif/esp-idf!12155
2021-02-02 22:00:53 +08:00
e454fdb8fc Merge branch 'bugfix/reenable_encrypted_partition_write_v4.0' into 'release/v4.0'
Re-enable encrypted flash read/writes even if flash encryption is disabled (v4.0)

See merge request espressif/esp-idf!12192
2021-02-02 18:30:27 +08:00
f39d69b592 CI: fix the bug returns wrong artifact path when app_name is a subset of a longer one 2021-02-02 11:14:28 +08:00
7b60b944b1 Merge branch 'bugfix/update_howsmyssl_cert_v4.0' into 'release/v4.0'
examples/protocols: update www.howsmyssl.com certificate to fix test failures (v4.0)

See merge request espressif/esp-idf!12213
2021-02-01 18:18:29 +08:00
ae1aef7b9e examples/protocols: update www.howsmyssl.com certificate to fix test failures 2021-02-01 11:10:38 +05:30
544a2a4f4e unit-test-app: disable encrypted flash read/write in psram config to fix build failure 2021-01-29 11:45:51 +05:30
d82adb482b 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-01-29 11:45:50 +05:30
9c169a1812 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-01-29 11:45:50 +05:30
e9de533c81 esp_wifi: Modify WIFI_IF_AP to TCPIP_ADAPTER_IF_AP 2021-01-27 15:00:55 +08:00
041ad04fdd esp_wifi: Modify ESP_IF_WIFI_AP to WIFI_IF_AP 2021-01-27 15:00:51 +08:00
4c68212c8f esp_wifi: Modify ESP_IF_WIFI_STA to WIFI_IF_STA 2021-01-27 14:59:25 +08:00
1ae261dcdd Add init & deinit event for a2dp 2021-01-26 10:54:15 +08:00
9ada8df5c0 Make OTA example support keepalive 2021-01-25 21:01:31 +08:00
985de73e6d Add options for esp_http_client and esp_websocket_client to support keepalive 2021-01-25 21:01:30 +08:00
7201411f49 Modify esp-tls and tcp_transport to support keep alive for tcp and ssl connection 2021-01-25 21:01:25 +08:00
8e8e54737d Merge branch 'bugfix/modbus_fix_slave_id_support_v40' into 'release/v4.0'
Bugfix/modbus fix slave id support v40

See merge request espressif/esp-idf!12096
2021-01-25 12:23:57 +08:00
4b50c99957 Merge branch 'bugfix/httpd_session_close_lru_v4.0' into 'release/v4.0'
esp_http_server: Add flag in sock_db to identify httpd_sess_close is called from httpd_session_close_lru (v4.0)

See merge request espressif/esp-idf!12114
2021-01-22 21:26:29 +08:00
7d677373e1 Merge branch 'bugfix/http_client_buffer_overread_v4.0' into 'release/v4.0'
esp_http_client: Fix buffer overread, update https_request example to use HTTP/1.1 (v4.0)

See merge request espressif/esp-idf!12110
2021-01-22 18:08:49 +08:00
1c10469890 Enable lru_purge_enable in simple HTTP server example 2021-01-22 15:35:46 +05:30
5d490dbc1e Merge branch 'fix/esp_tls_fix_memory_leak_v4.0' into 'release/v4.0'
esp-tls: Fix mem leak when global_ca_store is freed

See merge request espressif/esp-idf!12087
2021-01-22 17:37:32 +08:00
9951421910 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:17:17 +05:30
d0a4d91838 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:04:11 +05:30
4f7f09a64f freemodbus: fix compilation issue when slave id support is enabled
Closes https://github.com/espressif/esp-idf/issues/6003
2021-01-21 18:50:39 +01:00
4df95abb22 esp-tls: Fix mem leak when global_ca_store is freed 2021-01-21 11:31:52 +05:30
38ea44faaf Merge branch 'bugfix/ble_mesh_node_set_name_status_check_v4.0' into 'release/v4.0'
ble_mesh: stack: Remove node set device name return status check (v4.0)

See merge request espressif/esp-idf!12082
2021-01-21 11:08:02 +08:00
9f78bcc36d Merge branch 'bugfix/ble_mesh_proxy_client_net_resend_v4.0' into 'release/v4.0'
ble_mesh: stack: Fix proxy client may fail to resend msg (v4.0)

See merge request espressif/esp-idf!12080
2021-01-21 11:07:41 +08:00
ffc0f59565 Merge branch 'bugfix/ble_mesh_prov_use_diff_rand_v4.0' into 'release/v4.0'
ble_mesh: stack: Use different random for each provisioning (v4.0)

See merge request espressif/esp-idf!12078
2021-01-21 11:07:26 +08:00
lly
9d4abeb907 ble_mesh: stack: Remove node set device name return status check 2021-01-20 21:11:33 +08:00
lly
4c86bec0e9 ble_mesh: stack: Fix proxy client may fail to resend msg 2021-01-20 21:10:30 +08:00
lly
8737392af0 ble_mesh: stack: Use different random for each provisioning 2021-01-20 21:09:28 +08:00
b1178d092e Merge branch 'bugfix/mdns_txt_length_collision_v4.0' into 'release/v4.0'
mDNS: Fix of text length calculation when detecting a collision(Backport v4.0)

See merge request espressif/esp-idf!12027
2021-01-19 22:16:08 +08:00
a61ec41740 Merge branch 'bugfix/btdm_blufi_send_custom_data_will_congested_after_connection_is_broken_v4.0' into 'release/v4.0'
component/bt: fix Blufi sends customer data will congested when connection is broken(backport v4.0)

See merge request espressif/esp-idf!11849
2021-01-19 21:44:35 +08:00
c23c45a12a Merge branch 'bugfix/ble_mesh_log_macro_v4.0' into 'release/v4.0'
ble_mesh: stack: Add prefix for log macros (v4.0)

See merge request espressif/esp-idf!12053
2021-01-19 17:34:26 +08:00
c26e20770d Merge branch 'bugfix/soc_cpu_signed_compare_v4_0_pr5687' into 'release/v4.0'
fix compiler warning: comparison of integer expressions of different...

See merge request espressif/esp-idf!12049
2021-01-19 15:46:30 +08:00
7c204c38dd Merge branch 'bugfix/idf_py_disable_cmake_warnings_default_v4.0' into 'release/v4.0'
idf.py: disable cmake uninitialized variable warnings by default (v4.0)

See merge request espressif/esp-idf!10203
2021-01-19 14:21:50 +08:00
lly
421f044eea ble_mesh: stack: Fix compile warning when log is disabled 2021-01-19 14:05:25 +08:00
lly
3e5d2b9c41 ble_mesh: ci: Add disable log sdkconfig test files 2021-01-19 14:05:25 +08:00
lly
f9152550d2 ble_mesh: stack: Add prefix BLE_MESH_ for log related macros 2021-01-19 14:05:25 +08:00
d7c8dd270f fix compiler warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int'
Merges https://github.com/espressif/esp-idf/pull/5687
Equivalent fix to https://github.com/espressif/esp-idf/issues/6120 for v4.0 branch
2021-01-19 09:15:52 +11:00
a3cee22e7e Merge branch 'bugfix/fix_some_wifi_bugs_0105_v4.0' into 'release/v4.0'
Bugfix/fix some wifi bugs 0105 v4.0 (backport v4.0)

See merge request espressif/esp-idf!11906
2021-01-18 21:22:29 +08:00
822e64d312 Merge branch 'bugfix/fix_iperf_example_crash_issue_v4.0' into 'release/v4.0'
Bugfix/fix iperf example crash issue v4.0 (backport v4.0)

See merge request espressif/esp-idf!12020
2021-01-18 19:18:07 +08:00
ff7db0cdc4 Merge branch 'update/ble_mesh_set_hsl_states_v4.0' into 'release/v4.0'
ble_mesh: stack: Enable updating lighting hsl state (v4.0)

See merge request espressif/esp-idf!12037
2021-01-18 19:10:26 +08:00
173a5fc131 Merge branch 'bugfix/ble_mesh_build_error_c3_merge_master_v4.0' into 'release/v4.0'
Bugfix/ble mesh build error merge master (v4.0)

See merge request espressif/esp-idf!12039
2021-01-18 19:10:01 +08:00
lly
7134ef67cf ble_mesh: stack: Fix compile warning with BIT macro 2021-01-18 14:08:49 +08:00
lly
d42f39dcb4 ble_mesh: stack: Update mesh max conn macro when using bluedroid 2021-01-18 14:08:12 +08:00
lly
5c1e3eabc1 ble_mesh: stack: Enable updating lighting hsl state 2021-01-18 14:02:01 +08:00
3a56233a4d Merge branch 'bugfix/bluedroid_avoid_same_bdaddr_conn_v4.0' into 'release/v4.0'
Bluedroid: Do not connect if peer BD_ADDR is same as own BD_ADDR. (v4.0)

See merge request espressif/esp-idf!11992
2021-01-18 14:01:19 +08:00
52fa88b54e mDNS: Fix of text length calculation when detecting a collision 2021-01-15 16:53:27 +04:00
0f80a4bd47 mDNS: Fix of collision detection during txt length calculation
Closes https://github.com/espressif/esp-idf/issues/6114
2021-01-15 16:53:09 +04:00
eb1a1620fe example: Scan failure should not cause system crash 2021-01-15 20:03:25 +08:00
7778034cba example: do not check the return value of esp_wifi_connect() 2021-01-15 20:00:40 +08:00
9d9d30965f esp_pm: fix formatting issues in esp_pm_dump_locks
- line was truncated because 64 characters were not sufficient
- length passed to snprintf should be full buffer length, not -1
- make the width of lock name field fixed
- fix alignment of lock type column
2021-01-15 12:42:34 +01:00
62da2362a8 esp_pm: esp_pm_dump_locks: don't print from a critical section
Reported in https://github.com/espressif/esp-idf/issues/1917
2021-01-15 12:40:17 +01:00
9370b74ee0 esp_wifi: Update WiFi lib
1. Add check CSA state before CSA timer process
2. Change wifi scan duration from 120ms to 100ms
3. Using deport reg instead of ahb
4. Check TID in ieee80211_recv_bar()
5. Revert to report specific reason code when receiving deauth during 4-way-handshark
6. Fix the bug that tx ampdu parameter is not from peer device
7. Refactor wifi_interface_t
8. Faster WiFi station connect improvement, avoid 100ms passive scan
9. Add FCS failed packets filter
10.Update esp32 phy lib to v4660
11.Fix csa timer issue
12.Fix country code last byte to space instead of NULL
13.Fix softap cannot forward A-MSDU
14.Fix max tx power to 20dBm
15.Fix the issue that the esp_wifi_sta_get_ap_info can't get country
2021-01-15 03:51:36 +00:00
155a7f816d esp_wifi: ESP32 phy add [sections:phy_iram] 2021-01-15 03:51:36 +00:00
9eb34fd153 esp_wifi: optimize phy version log 2021-01-15 03:51:36 +00:00
70777a256a 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-01-15 03:51:36 +00:00
5718652952 Merge branch 'bugfix/ble_mesh_macro_OR_v4.0' into 'release/v4.0'
ble_mesh: stack: Fix using wrong | for OR between macros (v4.0)

See merge request espressif/esp-idf!11995
2021-01-14 19:01:15 +08:00
lly
4902b2745b ble_mesh: stack: Fix using wrong | for OR between macros 2021-01-14 15:59:46 +08:00
a47099b028 Merge branch 'feat/ble_mesh_support_ble_scan_v4.0' into 'release/v4.0'
ble_mesh: stack: Add BLE scan callback when mesh is enabled (v4.0)

See merge request espressif/esp-idf!11965
2021-01-14 15:47:52 +08:00
c4fe4dbf67 Bluedroid: Do not connect if peer BD_ADDR is same as own BD_ADDR. 2021-01-14 12:23:04 +05:30
f2038b959a Merge branch 'bugfix/fix_spp_vfs_dynamic_memory_bugs_v4.0' into 'release/v4.0'
component_bt/fix spp vfs demo crash when use dynamic memory[backport v4.0]

See merge request espressif/esp-idf!11729
2021-01-14 11:19:34 +08:00
5a64638848 Merge branch 'fix/esp_tls_add_warning_if_ca_chain_has_invalid_cert_v4.0' into 'release/v4.0'
esp_tls: Add warning if the CA chain provided contains one/more invalid cert

See merge request espressif/esp-idf!11943
2021-01-12 23:26:55 +08:00
lly
024017e3f2 ble_mesh: ci: Add ble & ble mesh coex sdkconfig test files 2021-01-12 19:15:36 +08:00
lly
f9b53a909b ble_mesh: stack: Support reporting normal ble adv packets 2021-01-12 19:15:36 +08:00
lly
34b5c1cf72 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-01-12 19:15:36 +08:00
lly
88b550ba75 ble_mesh: stack: Move ble scan funcitons to a single file 2021-01-12 19:15:35 +08:00
lly
d1553311a2 ble_mesh: stack: Optimize handling received mesh adv packets 2021-01-12 19:15:35 +08:00
725f882897 Merge branch 'optimize/ble_mesh_miscellaneous_v4.0' into 'release/v4.0'
Optimize/ble mesh miscellaneous (v4.0)

See merge request espressif/esp-idf!11949
2021-01-12 19:13:10 +08:00
lly
73dee43e55 ble_mesh: stack: Move bt_mesh_rand to mesh_common.c 2021-01-11 19:28:36 +08:00
lly
decd6956f3 ble_mesh: stack: Remove useless BT_DBG_ENABLED in a few files 2021-01-11 19:28:31 +08:00
lly
93991bda4a ble_mesh: Replace zephyr integer types with C99 types [Zephyr] 2021-01-11 19:28:25 +08:00
lly
866b6b439c ble_mesh: stack: Update ARRAY_SIZE definition 2021-01-11 19:27:55 +08:00
9172fcaa77 Merge branch 'feat/ble_mesh_multiple_nvs_namespace_v4.0' into 'release/v4.0'
ble_mesh: stack: Provisioner supports multiple nvs namespaces (v4.0)

See merge request espressif/esp-idf!11936
2021-01-11 18:55:37 +08:00
238ac2293b esp_tls: Add warning if the CA chain provided contains one/more invalid cert 2021-01-11 12:41:07 +05:30
0be9d54b90 Merge branch 'feature/upgrade_mbedtls_to_v4.0' into 'release/v4.0'
mbedtls: upgrade to v2.16.9 release (v4.0)

See merge request espressif/esp-idf!11901
2021-01-11 14:01:14 +08:00
lly
63adf8503f ble_mesh: ci: Add settings sdkconfig test files 2021-01-11 10:08:33 +08:00
lly
8c883fd410 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-01-11 10:08:23 +08:00
c97fc5ef8c Merge branch 'feat/ble_mesh_provisioner_recv_hb_support_v4.0' into 'release/v4.0'
Feat/ble mesh provisioner recv hb support (v4.0)

See merge request espressif/esp-idf!11915
2021-01-08 18:30:28 +08:00
lly
f9f29b779c ble_mesh: ci: Add enabling hb recv sdkconfig file 2021-01-08 09:33:04 +08:00
lly
f0af8858da ble_mesh: stack: Provisioner supports receiving heartbeat 2021-01-08 09:33:04 +08:00
2d7eb60491 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:20:30 +05:30
b4261e53d9 Merge branch 'bugfix/ble_mesh_node_id_adv_v4.0' into 'release/v4.0'
ble_mesh: stack: Fix Node ID adv with wrong timeout (v4.0)

See merge request espressif/esp-idf!11879
2021-01-06 17:08:51 +08:00
lly
726225c5f3 ble_mesh: stack: Fix Node ID adv with wrong timeout 2021-01-05 20:15:16 +08:00
d56cca3413 Merge branch 'bugfix/fix_ping_specify_length_issue_v4.0' into 'release/v4.0'
bugfix: fix ICMP specify length issue (backport v4.0)

See merge request espressif/esp-idf!11838
2021-01-05 10:45:16 +08:00
f81bdd933e component/bt: fix Blufi sends customer data will congested when connection is broken 2020-12-31 15:54:09 +08:00
43c9d9c1cd Merge branch 'fix/i2c_pm_lock_v4.0' into 'release/v4.0'
i2c: Acquire PM lock after acquiring mutex (v4.0)

See merge request espressif/esp-idf!11832
2020-12-31 12:33:50 +08:00
4985b77fff bugfix: fix ICMP specify length issue 2020-12-30 18:01:01 +08:00
e78721db05 i2c: Acquire PM lock after acquiring mutex 2020-12-30 13:25:21 +05:30
37317d1f2f Merge branch 'bugfix/bt_bluedroid_same_public_key_attack_v4.0' into 'release/v4.0'
Bluedroid: Fixes for some Bluetooth vulnerabilities. (v4.0)

See merge request espressif/esp-idf!11765
2020-12-28 11:41:14 +08:00
b3d5ed3a03 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:47 +05:30
5a069ea324 Merge branch 'bugfix/fix_wps_examples_issue_v4.0' into 'release/v4.0'
esp_wifi: Fix WPS examples issue (v4.0)

See merge request espressif/esp-idf!11730
2020-12-24 12:34:39 +08:00
e4bd2bebb5 esp_wifi: Add WPS Reason code in all failures 2020-12-23 17:35:06 +08:00
41a4da16d3 esp_wifi: Fix WPS examples issue 2020-12-23 15:43:19 +08:00
d64a19b73c fix spp vfs demo crash when use dynamic memory 2020-12-23 15:26:58 +08:00
64dfa78eed Merge branch 'bugfix/collection_bugfix_backport_for_4_0' into 'release/v4.0'
Bugfix/collection bugfix backport for 4 0

See merge request espressif/esp-idf!11710
2020-12-23 13:55:01 +08:00
711184762b components/bt: Fix waking up fail while sleeping 2020-12-22 21:28:44 +08:00
998a1f9ebb components/bt: Make sleep avaliable in hli(for future use) 2020-12-22 21:23:09 +08:00
b9f79249b8 components/bt: backport need commit to release/v4.0 2020-12-22 19:54:53 +08:00
0f4592eea0 components/bt: fixed memory damage caused by bluetooth memory release 2020-12-22 19:54:53 +08:00
16ff064f68 btdm: Add comments to clarify the two different device names of GAP and ADV in the ble_spp_server_demo example, as the old example might confuse users. 2020-12-22 19:54:53 +08:00
ca66b50481 collection of bugfix backport for release/v4.0 2020-12-22 19:54:53 +08:00
e11820cd5b components/bt: Fixed the problem of early release of pointer(p_ccb) in funcion 2020-12-22 19:54:53 +08:00
5a1a21ed2f Merge branch 'bugfix/revert_wifi_iram_optimization_v4.0' into 'release/v4.0'
esp_wifi: revert wifi iram optimization(v4.0)

See merge request espressif/esp-idf!11514
2020-12-22 19:03:01 +08:00
90e4363f7a Merge branch 'fixbug/baidu_tcp_recv_assert_for_4.0' into 'release/v4.0'
lw-ip:fix bug for tcp recv assert(backport 4.0)

See merge request espressif/esp-idf!11603
2020-12-22 16:19:05 +08:00
ef7aca1a66 Merge branch 'nimble/fix_misc_coverity_issue_v4.0' into 'release/v4.0'
Nimble: Fix misc issues in NimBLE NVS, `ble_eddystone`, recursive call and  L2CAP CoC (v4.0)

See merge request espressif/esp-idf!11392
2020-12-22 15:01:25 +08:00
0859b2a63e fix bug for tcp recv assert 2020-12-22 06:37:02 +00:00
0b540809bc Merge branch 'ci/disable_dev_push_pipelines_v4.0' into 'release/v4.0'
CI: Disable pipelines generated by push on dev branches (v4.0)

See merge request espressif/esp-idf!11594
2020-12-22 13:11:55 +08:00
e2cd3495a1 Merge branch 'bugfix/confirmed_bugfix_from_baidu_proj_4.0' into 'release/v4.0'
Fix BT controller dead issue caused by clk overflow [backport v4.0]

See merge request espressif/esp-idf!10546
2020-12-22 12:47:44 +08:00
f030faa34c Merge branch 'bugfix/fix_crash_caused_by_calling_deinit_directly_4_0' into 'release/v4.0'
Fix crash cause by calling a2dp deinit when connected [backport v4.0]

See merge request espressif/esp-idf!11691
2020-12-21 11:49:00 +08:00
66be657233 Fix crash cause by calling a2dp deinit when connected 2020-12-21 10:27:04 +08:00
cd46129b49 Free ACL RX Buffer in EM when disconnecting 2020-12-17 20:35:57 +08:00
911b90eb21 Confirmed bugfix from Baidu Project 2020-12-17 20:35:57 +08:00
62f781553b Enable PCM config in Host 2020-12-17 20:35:57 +08:00
ce999fe02e 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:19:59 +00:00
80ad3c1337 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:19:59 +00:00
518c4372fa CI: Disable pipelines generated by push on dev branches 2020-12-17 04:59:15 +00:00
4891353122 Merge branch 'optimize/ble_mesh_provision_dev_uuid_check_v4.0' into 'release/v4.0'
ble_mesh: stack: Need uuid when adding device for provisioning (v4.0)

See merge request espressif/esp-idf!11579
2020-12-16 19:25:09 +08:00
3259f7a964 Merge branch 'bugfix/cxx_exception_workarounds_4.0' into 'release/v4.0'
toolchain: C++ exception workarounds (backport 4.0)

See merge request espressif/esp-idf!10289
2020-12-16 16:14:58 +08:00
8329d51fd0 toolchain: C++ exception workaround
* disable C++ exception FDE sorting (saves RAM)

Closes IDF-1128
2020-12-16 09:25:36 +07:00
1797fa7716 Merge branch 'bugfix/docker_gdb_python_v4.0' into 'release/v4.0'
tools/docker: Add libpython2.7 in order to satisfy GDB dependencies (backport v4.0)

See merge request espressif/esp-idf!10309
2020-12-16 10:02:16 +08:00
f7dfee7dcd Merge branch 'test/disable_twai_example_ci_v4.0' into 'release/v4.0'
Temporarily disable TWAI network example test (backport v4.0)

See merge request espressif/esp-idf!11563
2020-12-16 04:22:02 +08:00
c9427ea613 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-12-15 20:09:08 +00:00
65517844f7 Merge branch 'bugfix/phy_xpd_v4.0' into 'release/v4.0'
wifi: add set_xpd_sar override(backport v4.0)

See merge request espressif/esp-idf!11544
2020-12-16 01:04:53 +08:00
lly
b8827d45c6 ble_mesh: ci: Add PB-ADV & PB-GATT sdkconfig test files 2020-12-15 11:59:11 +00:00
lly
85e3b86fd7 ble_mesh: stack: Need uuid when adding device for provisioning 2020-12-15 11:59:11 +00:00
a987a8ade6 Merge branch 'bugfix/ci_py2_warnings_fix_v4.0' into 'release/v4.0'
ci: Python 2 warnings fix (v4.0)

See merge request espressif/esp-idf!11619
2020-12-15 19:06:33 +08:00
9e780a5be9 Merge branch 'feature/ci_fix_docker_build_v4.0' into 'release/v4.0'
ci: Use git mirror for docker image (v4.0)

See merge request espressif/esp-idf!10447
2020-12-15 15:42:39 +08:00
3fc9ab4eb3 tools: Redirect some warnings to stderr 2020-12-15 13:32:49 +07:00
a10d115e84 ci: Ignore Python 2 deprecation warning 2020-12-15 13:32:30 +07:00
db603854a9 Merge branch 'bugfix/redirection_v4.0' into 'release/v4.0'
esp_http_client: Skip check for redirection counter if status code is success, fix issue with digest auth, configurable user agent string. (v4.0)

See merge request espressif/esp-idf!11599
2020-12-14 20:20:40 +08:00
52b069bd03 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
2020-12-14 14:42:17 +05:30
670144ed7c http_auth.c: Fix crash when opaque field is not present in challenge string
Closes: https://github.com/espressif/esp-idf/issues/5888
2020-12-14 14:42:08 +05:30
3194bba14d 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
2020-12-14 14:41:54 +05:30
cad6eda381 Fix ccache documentation: environment variable is IDF_CCACHE_ENABLE
Merges https://github.com/espressif/esp-idf/pull/5753
2020-12-14 07:26:09 +00:00
047480058c 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-12-14 07:26:09 +00:00
7ae3bb3298 Merge branch 'feature/switch_from_external_to_interanl_ram_v4.0' into 'release/v4.0'
esp32: Switch SPIRAM stack in esp_restart_noos() to internal stack (v4.0)

See merge request espressif/esp-idf!9969
2020-12-14 15:24:40 +08:00
4f7eacee75 Merge branch 'bugfix/esptool_version_v4.0' into 'release/v4.0'
esptool: Update esptool to latest v2.x version (backport v4.0)

See merge request espressif/esp-idf!11584
2020-12-14 15:14:32 +08:00
1592e29a71 Changed esptool version to latest v2.x 2020-12-11 13:08:47 +01:00
8822c94ef1 Merge branch 'feature/python2-deprecation-warn_v4.0' into 'release/v4.0'
Tools: Add Python 2 deprecation warning (v4.0)

See merge request espressif/esp-idf!11528
2020-12-11 11:37:47 +08:00
51103377c6 twai: Temporarily disable network example test
Disabling network example test due to issue with synchronizing the
start of each DUT
2020-12-10 21:34:05 +08:00
4c65e031ea add CN translation for adding python2 deprecation warning(MR 11115) 2020-12-09 23:50:19 +01:00
c4f11f7138 adc_i2s: solve the i2s_adc issue when using wifi 2020-12-09 22:41:49 +08:00
b902d6be39 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-12-08 16:55:50 +00:00
c05fcc6a1d Tools: add Python 2 deprecation warning 2020-12-08 15:46:41 +01:00
3cefb0ad8f esp_wifi: revert wifi iram optimization 2020-12-08 14:23:09 +08:00
3467c44ff8 Merge branch 'doc/update_CN_translation_for_relase/v4.0' into 'release/v4.0'
update CN translation for index.rst in get-started folder (v4.0)

See merge request espressif/esp-idf!11457
2020-12-08 10:44:43 +08:00
14de2ba81a update CN translation for index.rst in get-started folder (v4.0) 2020-12-08 10:44:40 +08:00
31760789c3 Merge branch 'bugfix/can_backport_accumulated_fixes_v4.0' into 'release/v4.0'
CAN backport accumulated fixes (backport v4.0)

See merge request espressif/esp-idf!11461
2020-12-04 23:59:12 +08:00
7c8208d903 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.
2020-12-04 19:03:19 +08:00
7428caeb06 Merge branch 'bugfix/fix_some_wifi_bugs_1117_v4.0' into 'release/v4.0'
Fix some wifi bugs 1117 (backport v4.0)

See merge request espressif/esp-idf!11263
2020-12-04 11:57:51 +08:00
3ca0b7a447 Merge branch 'bugfix/fix_partition_table_in_flash_encryption_example_v4.0' into 'release/v4.0'
example/flash_encryption: Fix partition table (v4.0)

See merge request espressif/esp-idf!10853
2020-12-04 11:25:09 +08:00
0182e53431 Merge branch 'feature/btdm_support_some_ble_new_features_v4.0' into 'release/v4.0'
components/bt: backport some new features for Bluedroid BLE(release v4.0)

See merge request espressif/esp-idf!11453
2020-12-03 19:04:02 +08:00
c088c19322 esp_wifi: Fix some wifi bugs 1117
1. Optimize WiFi debug log
2. WiFi IRAM optimization
3. Update WiFi toolchain to 1.22.0-97-gc752ad5
4. Optimize WiFi TX performance
2020-12-03 17:49:22 +08:00
f8581b40fc component/bt: support BLE Read Attribute value by UUID 2020-12-03 16:47:13 +08:00
2505769c0b component/bt: refactor ble random address setting 2020-12-03 16:47:04 +08:00
8db16a50ae component/bt: support BLE Application Layer Encryption key size check 2020-12-03 16:46:53 +08:00
069325a7ed component/bt: support BLE Authorization 2020-12-03 16:44:45 +08:00
b585eccf36 component/bt: fix incorrect encryption flag setting 2020-12-03 16:36:19 +08:00
c2b6a2d24f esp_wifi: optimize WiFi debug log
1. Add esp_wifi_statis_dump()
2. Optimize WiFi related debug log
2020-12-03 16:04:11 +08:00
bcc7d105ba can: Fix critical section ESP_LOG functions
This commit removes any function calls within
the CAN driver that result in a call to ESP_LOG
whilst inside a critical section.

These function calls are either moved outside
critical sections (e.g., intr_alloc and gpio
functions), or substituted (e.g., assert()).
2020-12-02 21:47:35 +08:00
05adedcc72 can: Fix semaphore take in critical section
This commit fixes can_reconfigure_alerts() which
could lead to a call to xSemaphoreTake() whilst
inside a critical section.
2020-12-02 21:45:55 +08:00
4741e6787d 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-12-02 21:35:07 +08:00
6823364442 Merge branch 'bugfix/blufi_config_potential_double_free_v4.0' into 'release/v4.0'
Bugfix/blufi config potential double free v4.0

See merge request espressif/esp-idf!11165
2020-12-02 17:03:27 +08:00
78bbde6b44 Merge branch 'bugfix/blecent_example_test_4.0' into 'release/v4.0'
Fix CI blecent example test (backport v4.0)

See merge request espressif/esp-idf!11321
2020-12-02 15:41:09 +08:00
b3b712c24e Merge branch 'bugfix/fix_some_wifi_bugs_1127_v4.0' into 'release/v4.0'
esp_wifi: fix some wifi bugs 1127 (backport v4.0)

See merge request espressif/esp-idf!11416
2020-12-02 13:20:17 +08:00
160e43a95b esp_wifi: update wifi lib for bugfixs 2020-12-01 20:10:35 +08:00
54c012905f wifi: Fix esp_wifi log levels 2020-12-01 19:36:00 +08:00
2db6b1578e esp_wifi: Update wifi lib
1. Use flag ESP32_WIFI_ENABLE_WPA3_SAE to control WPA3 code, disabling
   it code footprint reduces by 7.7kB in libwpa_supplicant.a
2. Fix handling of multiple AP credentials in WPS, apps need update
   to handle the new event for the fix to work
2020-12-01 19:28:56 +08:00
c15579fd85 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:32:54 +08:00
5686cbb1d7 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 16:49:12 +08:00
b2dec946b6 esp_wifi: Update docs for wifi headers 2020-12-01 16:44:53 +08:00
2c85d3dd62 esp_wifi: remove wifi tx buffer limits 2020-12-01 16:36:59 +08:00
5616dd57da Wi-Fi: set softap beacon DTIM count according to TSF timer 2020-12-01 16:35:38 +08:00
2252c75588 esp_wifi: update description for WiFi APIs
1. Add description for esp_wifi_set_inactive_time()
2. Add documentation to avoid using WiFi modem sleep for WiFi/BT coexistence
3. Remove description of unusable API esp_wifi_restart()
4. Update esp_now_fetch_peer discription
5. Update table format prblm for esp_wifi_set_max_tx_power()
6. Update description for ssid and password
2020-12-01 15:48:59 +08:00
280a342826 esp_wifi: Add support for 802.1x sha256 auth key mode
Closes https://github.com/espressif/esp-idf/issues/5805
2020-12-01 14:47:30 +08:00
52019fdd63 Merge branch 'bugfix/rtc_clk_cal_cycles_add_default_vals_for_all_sources_v4.0' into 'release/v4.0'
esp32xx: Fix default values for all RTC sources in RTC_CLK_CAL_CYCLES option (v4.0)

See merge request espressif/esp-idf!11414
2020-12-01 13:54:19 +08:00
80629a75a2 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:13:44 +08:00
70841722f1 ci: Fix blecent example test
(cherry picked from commit fc146a98e4)
2020-11-30 16:29:54 +05:30
7b4a2560a6 wpa_supplicant: Minor bugfix with wpa_supplicant debug logs. 2020-11-27 15:42:41 +08:00
395fa980d8 wpa_supplicant: Fix configurable debug log feature's warning issue 2020-11-27 15:41:55 +08:00
e5b52ae423 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-27 15:41:34 +08:00
9a7ba5e6fc bugfix: fix TCP timer interval 2020-11-27 15:35:10 +08:00
9253d41b1a fix TCP retransmission interval 2020-11-27 15:33:07 +08:00
d39fc7ca00 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-27 15:27:44 +08:00
7182a65419 WIFI: Iperf example's parameter opt was uninitialized, may leads setsockoption invalide if it equal to 0 2020-11-27 15:25:09 +08:00
dae98ddff7 wpa_supplicant: Replace internal RSA APIs by mbedtls APIs
Curretly wpa_supplicant uses internal APIs for RSA operations
which internally uses lots of big num operations.

Big num operations are CPU expensive and can take a lot of time
which can cause watchdog timer to tigger.

This can be optimize by using mbedtls APIs which uses
hardware blocks for big num operations.

To fix this, write new crypto_mbedtls-rsa.c which has APIs
similar to crypto_internal-rsa.c but uses mbedtls APIs.
2020-11-27 15:22:51 +08:00
5630b17e11 Merge branch 'feat/ble_mesh_node_local_data_func_v4.0' into 'release/v4.0'
ble_mesh: stack: Add node local netkey/appkey func (v4.0)

See merge request espressif/esp-idf!11364
2020-11-25 20:23:01 +08:00
lly
e3ddd91fb7 ble_mesh: stack: Fix wrong declaration of node bind AppKey func 2020-11-25 11:02:00 +08:00
lly
f151771bce ble_mesh: stack: Add node local netkey/appkey func 2020-11-25 11:01:46 +08:00
5220510152 Merge branch 'optimize/ble_mesh_reduce_code_size_v4.0' into 'release/v4.0'
Optimize/ble mesh reduce code size (v4.0)

See merge request espressif/esp-idf!11345
2020-11-25 10:49:46 +08:00
e7375c79b0 component/bt: Add a macro to control the compilation of blufi. 2020-11-24 10:54:39 +08:00
3adfbaeb2f component/bt: Fix a potential double free error. 2020-11-24 10:46:25 +08:00
724d863116 blufi: fix an error caused by incorrect conn_id parameters. 2020-11-24 10:46:22 +08:00
39ca3ee8dc Merge branch 'ci/fix_annotated_tag_check_v4.0' into 'release/v4.0'
ci: Fix annotated tag check (v4.0)

See merge request espressif/esp-idf!11333
2020-11-24 06:32:10 +08:00
37ac9d09f4 Merge branch 'bugfix/fix_some_wifi_bugs_0924_v4.0' into 'release/v4.0'
WiFi: fix some wifi bugs 0924 (backport v4.0)

See merge request espressif/esp-idf!10614
2020-11-23 21:31:05 +08:00
lly
26f7afed46 ble_mesh: example: Update sdkconfig test files for disabling Health Server model 2020-11-23 20:13:06 +08:00
lly
4391a24c2f ble_mesh: stack: Add a Kconfig option to make Health Server model optional 2020-11-23 20:13:06 +08:00
lly
b71b99b7be ble_mesh: stack: Split model Kconfig menu into foundation and others 2020-11-23 20:13:06 +08:00
lly
d8266bd917 ble_mesh: example: Fix fast provisioning compile error 2020-11-23 20:13:06 +08:00
lly
e7a5412cfd ble_mesh: ci: Add disabling mesh model sdkconfig test files 2020-11-23 20:13:05 +08:00
lly
7f411c9cb7 ble_mesh: stack: Add Kconfig options to make server models optional 2020-11-23 20:13:05 +08:00
lly
440b94d272 ble_mesh: stack: Use Kconfig option to make client models optional 2020-11-23 20:13:05 +08:00
lly
bc163f982d ble_mesh: stack: Make some internal static functions inline 2020-11-23 20:13:05 +08:00
lly
342a26bb60 ble_mesh: ci: Add disabling mesh deinit sdkconfig test files 2020-11-23 20:13:05 +08:00
lly
fe86760ff6 ble_mesh: stack: Add a Kconfig option to make deinit optional 2020-11-23 20:13:04 +08:00
lly
58ac97cb4c ble_mesh: stack: Introduce a new header file mesh_config.h 2020-11-23 20:13:04 +08:00
1d771d081b Merge branch 'bugfix/ble_mesh_proxy_cfg_replay_v4.0' into 'release/v4.0'
Bugfix/ble mesh proxy cfg replay (v4.0)

See merge request espressif/esp-idf!11337
2020-11-23 20:08:55 +08:00
ab055d2421 Merge branch 'bugfix/ble_mesh_node_deinit_v4.0' into 'release/v4.0'
ble_mesh: stack: Persistent storage misc fixes (v4.0)

See merge request espressif/esp-idf!11336
2020-11-23 20:01:28 +08:00
7f76f57b29 Merge branch 'fix/protocomm_simple_ble_v4.0' into 'release/v4.0'
Protocomm/simple_ble: Fix gatt table map size to number of handles received (v4.0)

See merge request espressif/esp-idf!11267
2020-11-23 18:44:52 +08:00
1e3eed8265 Merge branch 'bugfix/fix_spp_read_flow_control_v4.0' into 'release/v4.0'
component_bt/fix spp flow control and vfs write [backport 4.0]

See merge request espressif/esp-idf!11074
2020-11-23 15:49:54 +08:00
0a8abf6ffe esp_wifi:
1. Modify LR for esp32
2. Optimize some debug logs for probe response
3. Optimize phy and soc files
4. Fix the bug that no event for connect
5. Fix the bug that set_channel doesn't work for softAP
6. Add sta connect again ap sent disconnect event
7. Add set/get inactive time api
8. Fix connect hidden AP doesn't update information
9. Add rf test long short support
2020-11-23 15:08:40 +08:00
lly
5c7960de0d ble_mesh: stack: Store kr phase after value changed [Zephyr] 2020-11-23 15:07:14 +08:00
lly
613616b445 ble_mesh: stack: Fix rpl not check by proxy cfg [Zephyr] 2020-11-23 15:07:14 +08:00
lly
97a54a9818 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-11-23 15:01:50 +08:00
39d213378c Merge branch 'bugfix/ble_mesh_settings_fix_v4.0' into 'release/v4.0'
Bugfix/ble mesh settings fix (v4.0)

See merge request espressif/esp-idf!11326
2020-11-23 14:42:18 +08:00
5f58e32f34 Merge branch 'optimize/ble_mesh_gattc_conn_param_v4.0' into 'release/v4.0'
ble_mesh: stack: Update connection parameters used by Central (v4.0)

See merge request espressif/esp-idf!11327
2020-11-23 14:42:13 +08:00
42ffc348a6 ci: Fix annotated tag check
Regression in 1612f84
2020-11-23 17:29:46 +11:00
7adfe57302 Protocomm/simple_ble: Make gatt table map size equal to number of handles received (v4.0)
- Fixes memcpy failure observed while adding 2 or more endpoints in
  wifi_provisioning.

 Closes IDF-2250
2020-11-23 05:34:22 +00:00
023f44e348 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-23 12:22:30 +08:00
2765d5b829 move flow control to btc layer
defer free slot in btc layer when receive BTA_JV_RFCOMM_CLOSE_EVT
2020-11-23 12:22:30 +08:00
ba3f69feea add event when calling spp API failed 2020-11-23 12:22:30 +08:00
lly
004393ec5f ble_mesh: stack: Update connection interval to 15ms 2020-11-23 08:53:37 +08:00
lly
b1383f5c0f ble_mesh: stack: Update connection parameters used by Central 2020-11-23 08:53:37 +08:00
lly
4fa39cae98 ble_mesh: stack: Use settings_core_erase when deinit 2020-11-23 08:45:04 +08:00
lly
666488a940 ble_mesh: stack: Fix storing next net_idx and app_idx 2020-11-23 08:45:04 +08:00
lly
3421336d66 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-11-23 08:45:04 +08:00
lly
ad1d5764e2 ble_mesh: stack: Split model settings store and clear 2020-11-23 08:45:04 +08:00
lly
db4a344a33 ble_mesh: stack: Erase netkey and appkey with key index 2020-11-23 08:45:04 +08:00
lly
29c7645093 ble_mesh: stack: Add clear hb_pub in settings 2020-11-23 08:45:04 +08:00
lly
692ccf774b 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-11-23 08:45:04 +08:00
lly
034906c6a8 ble_mesh: stack: Use erase settings functions 2020-11-23 08:45:04 +08:00
lly
69131a11ed 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-11-23 08:45:04 +08:00
lly
8cbc93101e ble_mesh: stack: Add role check before enabling device 2020-11-23 08:45:03 +08:00
lly
c39097a601 ble_mesh: stack: Define a type for mesh nvs handle 2020-11-23 08:45:03 +08:00
lly
b4131cb6a9 ble_mesh: ci: Enable settings in sdkconfig.ci.xxx 2020-11-23 08:45:03 +08:00
a6db1162e8 Merge branch 'feat/ble_mesh_use_model_c_v4.0' into 'release/v4.0'
ble_mesh: stack: Use model callback for operations [Zephyr] (v4.0)

See merge request espressif/esp-idf!10364
2020-11-22 18:57:11 +08:00
e0c22867b9 Merge branch 'bugfix/ble_mesh_sensor_example_fix_v4.0' into 'release/v4.0'
ble_mesh: example: Fix sensor data wrong iteration (v4.0)

See merge request espressif/esp-idf!10275
2020-11-22 18:56:57 +08:00
lly
d9033cfeec ble_mesh: example: Fix sensor data wrong iteration 2020-11-22 09:27:44 +00:00
lly
8d9b0909a3 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-11-22 09:26:41 +00:00
d6f697e113 Merge branch 'bugfix/cxx_flag_operators_v4.0' into 'release/v4.0'
esp_eth: moved extern "C" after includes (v4.0)

See merge request espressif/esp-idf!11219
2020-11-22 15:35:22 +08:00
7a55981dca Merge branch 'feature/esp_tls_for_supplicant_v4.0' into 'release/v4.0'
wpa_supplicant: Support for mbedtls tls handshake(backport v4.0)

See merge request espressif/esp-idf!9860
2020-11-21 22:43:33 +08:00
eb9520fdb0 Merge branch 'bugfix/backport_some_lwip_bugs_1120_v4.0' into 'release/v4.0'
lw-ip:backport bugfix lwip for v4.0(backport 4.0)

See merge request espressif/esp-idf!11309
2020-11-21 22:34:27 +08:00
747f281325 Merge branch 'component/seperate_bta_jv_l2c_4.0' into 'release/v4.0'
component_bt:/ seperate bta jv l2c  [backport v4.0]

See merge request espressif/esp-idf!9646
2020-11-21 22:34:00 +08:00
ba4fc9c803 Merge branch 'bugfix/backport_v4.0_fix_pthread_priority_inheritance' into 'release/v4.0'
bugfix/ pthread priority inheritance(backport v4.0)

See merge request espressif/esp-idf!11256
2020-11-21 22:33:37 +08:00
4e9de58779 Merge branch 'optimize/ble_mesh_provisioner_delete_dev_v4.0' into 'release/v4.0'
ble_mesh: stack: Optimize Provisioner delete device function (v4.0)

See merge request espressif/esp-idf!10605
2020-11-21 17:54:25 +08:00
2fa70c8aed Merge branch 'feat/ble_mesh_device_properties_v2_v4.0' into 'release/v4.0'
Feat/ble mesh device properties v2 (v4.0)

See merge request espressif/esp-idf!10789
2020-11-21 17:54:14 +08:00
2a93a30c42 Merge branch 'bugfix/ble_mesh_check_stack_init_v4.0' into 'release/v4.0'
ble_mesh: stack: Check if mesh stack initialized before init vendor client (v4.0)

See merge request espressif/esp-idf!10483
2020-11-21 17:53:11 +08:00
d101748448 Merge branch 'bugfix/ble_mesh_prov_iv_index_v4.0' into 'release/v4.0'
ble_mesh: stack: Using the latest iv_index for provisioning (v4.0)

See merge request espressif/esp-idf!10418
2020-11-21 17:52:20 +08:00
a353e1d235 Fix tsk watchdog when running spp vfs demo 2020-11-21 09:38:46 +00:00
ca00390174 Seperate BTA_JV_L2CAP for less bin size 2020-11-21 09:38:46 +00:00
940f2bc108 esp_eth: moved extern "C" after includes 2020-11-21 09:37:34 +00:00
b06fe45fde Merge branch 'feature/mqtt_submodule_update_23c8e1ec_v4.0' into 'release/v4.0'
MQTT: Update submodule reference to da850b (config, error flags, minor fixes) (v4.0)

See merge request espressif/esp-idf!11314
2020-11-21 17:32:18 +08:00
d2173ba1e8 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-21 08:21:57 +00:00
c8902cddc7 Merge branch 'bugfix/backport_v4.0_fix_websocket_issue' into 'release/v4.0'
websocket_client : fix some issues for websocket client (backport v4.0)

See merge request espressif/esp-idf!11261
2020-11-20 17:46:35 +08:00
aef8a36c99 Merge branch 'bugfix/backport_v4.0_fix_transport_ssl_blocking' into 'release/v4.0'
transport_ssl: Fix a bug in transport_ssl (backport v4.0)

See merge request espressif/esp-idf!11277
2020-11-20 17:45:03 +08:00
c4e22a3925 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:40 +01:00
df23bbe8e1 backport bugfix lwip for v4.0 2020-11-20 16:36:37 +08:00
31b6b885e6 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-11-20 08:02:28 +00:00
c384d61e53 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-11-20 08:02:28 +00:00
0263a182fc wpa_supplicant: Support for mbedtls tls handshake
Add support for mbedtls based tls handshake, this removes
dependency from internal implementation of EAP client.
2020-11-20 08:02:28 +00:00
6d23d64b18 Merge branch 'bugfix/fix_bredr_read_rssi_delta_v4.0' into 'release/v4.0'
Bugfix/Fix Read Rssi Delta Bug in Bredr [backport v4.0]

See merge request espressif/esp-idf!10805
2020-11-20 15:36:39 +08:00
d31a127db5 Merge branch 'bugfix/wpa3_pmkcache_expiry_workaround_v4.0' into 'release/v4.0'
wpa_supplicant: Increase PMK Lifetime to a very high value (Backport v4.0)

See merge request espressif/esp-idf!11183
2020-11-20 14:39:45 +08:00
00b9f48081 Merge branch 'bugfix/add_clear_bond_complete_evt_4_0' into 'release/v4.0'
componenet_bt/bugfix: add remove bond device complete event 4.0

See merge request espressif/esp-idf!10656
2020-11-20 13:50:13 +08:00
511d3b05cd 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-20 03:46:08 +00:00
4f2a2a8ce4 Merge branch 'fix/esp_local_ctrl_update_expired_cert_v4.0' into 'release/v4.0'
esp_local_ctrl: Updated the expired cacert.pem (v4.0)

See merge request espressif/esp-idf!11208
2020-11-19 15:27:23 +08:00
95d8bbe0e6 esp_local_ctrl: Updated the expired cacert.pem 2020-11-19 05:26:14 +00:00
f3b087a6d1 In SSL mode, if esp_transport_poll_read function is used, the cache data in mebdtls will be blocked 2020-11-18 16:59:22 +08:00
e7b3b75785 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:01:10 +08:00
71eb7604c5 Merge branch 'bugfix/lwip_netdb_cpp_guards_v4.0' into 'release/v4.0'
lw-IP: Changed to C linkage in netdb.h for fixing bug when using mixed C/C++ code (v4.0)

See merge request espressif/esp-idf!11091
2020-11-16 19:42:43 +08:00
e9820687f6 Merge branch 'bugfix/socket_examples_ipv6_scope' into 'release/v4.0'
examples: Fix socket examples to use IPv6 scoped addresses from tcpip_adapter API

See merge request espressif/esp-idf!10689
2020-11-16 19:41:58 +08:00
f42e5745e6 Merge branch 'bugfix/can_mmap_after_get_enough_free_mmu_pages_v4.0' into 'release/v4.0'
flash_mmap: can mmap after get enough free MMU pages (backport v4.0)

See merge request espressif/esp-idf!10586
2020-11-16 19:40:26 +08:00
befde68eea Merge branch 'bugfix/btdm_blufi_data_sequence_not_reset_after_disconnect_v4.0' into 'release/v4.0'
component/bt: fix Blufi sends data after disconnect the seq still increase(backport v4.0)

See merge request espressif/esp-idf!10239
2020-11-16 19:38:22 +08:00
b0ffa66039 Merge branch 'mesh/bugfix_1023_backport_v4.0' into 'release/v4.0'
esp_wifi_mesh: update wifi mesh libs(Backport v4.0)

See merge request espressif/esp-idf!11083
2020-11-16 19:33:47 +08:00
c857045505 Merge branch 'bugfix/cmake_example_sdkconfig_path_v4.0' into 'release/v4.0'
cmake/example: Move idf_as_lib sdkconfig path to project, document configuring project (v4.0)

See merge request espressif/esp-idf!10861
2020-11-16 12:13:44 +08:00
e3db779b95 Merge branch 'bugfix/customer_baidu_psram_stack_backtrace_v4.0' into 'release/v4.0'
backport v4.0: added psram stack check in backtrace

See merge request espressif/esp-idf!8474
2020-11-12 21:00:36 +08:00
8f3fe29deb components/bt: Replace task post with btc_inter_profile_call, when post message from btc_dm to btc_gap 2020-11-12 19:23:10 +08:00
19ef328f8e components/bt: Fix clear bond fail when connected without ble included 2020-11-12 19:18:52 +08:00
e51818f6fc add remove bond device complete event 2020-11-12 19:18:52 +08:00
e9ba0e05f2 Merge branch 'bugfix/nimble_host_rcv_pkt_length_check_v4.0' into 'release/v4.0'
NimBLE: host_rcv_pkt event buf size check. (v4.0)

See merge request espressif/esp-idf!10760
2020-11-12 14:20:29 +08:00
a69ff28c6f Merge branch 'bugfix/bredr_bugfix_release_for_qa_dummy_disconnect_4_0' into 'release/v4.0'
Bugfix/bredr bugfix release for qa dummy disconnect 4.0

See merge request espressif/esp-idf!10647
2020-11-12 14:18:53 +08:00
3c9833eaf9 Merge branch 'bugfix/add_protection_for_spp_api_4.0' into 'release/v4.0'
Bugfix/add protection for spp api [backport v4.0]

See merge request espressif/esp-idf!10283
2020-11-12 14:15:41 +08:00
e547aae7b8 Merge branch 'bugfix/add_disconn_req_action_when_no_link_4.0' into 'release/v4.0'
Bugfix/add disconn req action when no link [backport v4.0]

See merge request espressif/esp-idf!10510
2020-11-12 14:14:55 +08:00
f694f92230 nvs: unit tests for new partition API
* also changed while to for loop
2020-11-12 10:02:05 +08:00
cb6dcb6fc4 nvs: allow to specify custom partition
Closes https://github.com/espressif/esp-idf/pull/5172
2020-11-12 10:01:59 +08:00
aebd7a97c9 Merge branch 'bugfix/wpa_supplicant_link_depth_v4.0' into 'release/v4.0'
wpa_supplicant: Fix failure to link under some circumstances (v4.0)

See merge request espressif/esp-idf!10978
2020-11-11 15:48:15 +08:00
d75888a5df Merge branch 'bugfix/mcpwm_period_error_v4.0' into 'release/v4.0'
bugfix(mcpwm_period_error): fix the issue of wrong period (backport v4.0)

See merge request espressif/esp-idf!8312
2020-11-11 15:07:33 +08:00
9b1f47df1d Merge branch 'bugfix/remove_shortcut_to_build_instructions_v4.0' into 'release/v4.0'
doc: Getting Started Guide, remove shortcuts to 'build toolchain from scratch' instructions (v4.0)

See merge request espressif/esp-idf!10608
2020-11-11 11:02:15 +08:00
8a78522aad Merge branch 'bugfix/ldgen_unicode_path_v4.0' into 'release/v4.0'
tools/ldgen: Parse paths with Unicode characters in archives & fix parsing of section names on Windows (v4.0)

See merge request espressif/esp-idf!10966
2020-11-11 10:50:55 +08:00
7aef4fbec9 Merge branch 'bugfix/adjtime_return_outdelta_before_new_delta_set_v4.0' into 'release/v4.0'
newlib: Fix adjtime, returns the amount of time remaining from any previous adjustment (v4.0)

See merge request espressif/esp-idf!9973
2020-11-11 10:46:38 +08:00
d690e3d1ab Merge branch 'bugfix/get_component_requirements_v4.0' into 'release/v4.0'
cmake: fix getting component requirements (v4.0)

See merge request espressif/esp-idf!10661
2020-11-11 10:44:43 +08:00
74870e7e22 Merge branch 'bugfix/err_to_name_paths_windows_v4.0' into 'release/v4.0'
tools: fix path handling errors in gen_esp_err_to_name.py for Windows (v4.0)

See merge request espressif/esp-idf!10897
2020-11-11 10:44:33 +08:00
a2fe59464e Merge branch 'bugfix/returns_correct_flash_encryption_mode_v4.0' into 'release/v4.0'
bootloader: Fix esp_get_flash_encryption_mode() (v4.0)

See merge request espressif/esp-idf!10714
2020-11-11 10:43:25 +08:00
d5ae1d10d9 Merge branch 'bugfix/embed_file_symbol_names_v4.0' into 'release/v4.0'
cmake: fix C identifier generation from embedded file (v4.0)

See merge request espressif/esp-idf!10666
2020-11-11 10:43:14 +08:00
8acea045a7 Merge branch 'bugfix/bootloader_anti_rollback_mmap_v4.0' into 'release/v4.0'
bootloader_support: fix issue in memory mapping for getting app descriptor (v4.0)

See merge request espressif/esp-idf!10736
2020-11-11 10:42:42 +08:00
36f3845331 Merge branch 'bugfix/bootloader_common_get_sha256_of_partition_v4.0' into 'release/v4.0'
bootloader_support: Fix bootloader_common_get_sha256_of_partition(), can handle a long image (v4.0)

See merge request espressif/esp-idf!9954
2020-11-11 10:42:28 +08:00
134b21c5b2 Merge branch 'bugfix/ble_mesh_autorsp_description_v4.0' into 'release/v4.0'
esp_ble_mesh: api: fixed comment about autoresp (v4.0)

See merge request espressif/esp-idf!10890
2020-11-10 16:42:50 +08:00
1214f343ab Merge branch 'optimize/ble_mesh_make_buf_config_invisible_v4.0' into 'release/v4.0'
ble_mesh: stack: Make mesh buf debug option invisible (v4.0)

See merge request espressif/esp-idf!10796
2020-11-10 16:42:34 +08:00
fb9df6388f Merge branch 'bugfix/fix_node_test_func_not_set_role_v4.0' into 'release/v4.0'
ble_mesh: test: Fix node test function not update role flag (v4.0)

See merge request espressif/esp-idf!11042
2020-11-10 16:42:22 +08:00
2be6197714 Merge branch 'bugfix/example_test_import_error_4.0' into 'release/v4.0'
bugfix: import error in example tests (4.0)

See merge request espressif/esp-idf!11038
2020-11-09 19:18:59 +08:00
31e0866561 Merge branch 'bugfix/ut_ext_win_open_file_v4.0' into 'release/v4.0'
Tools: Close temporary file before invoking external tools accessing it

See merge request espressif/esp-idf!9832
2020-11-09 17:16:25 +08:00
c535031c2f Merge branch 'bugfix/bootloader_skip_verify_jtag_v4.0' into 'release/v4.0'
bootloader_support: don't check signature when JTAG is attached (v4.0)

See merge request espressif/esp-idf!10380
2020-11-09 16:52:13 +08:00
a4d7f15625 Merge branch 'gdb/bt_on_invalid_pc_v4.0' into 'release/v4.0'
gdb: Modify PC in case of invalid PC (v4.0)

See merge request espressif/esp-idf!8980
2020-11-09 16:48:46 +08:00
f02e2c5e09 Merge branch 'init_priority_fix_v4.0' into 'release/v4.0'
CXX: make __attribute__((init_priority(n))) work (v4.0)

See merge request espressif/esp-idf!8445
2020-11-09 16:47:22 +08:00
5738a833fa Merge branch 'bugfix/idf_monitor_baudrate_arg_crash_v4.0' into 'release/v4.0'
idf monitor: fix crash when monitor baudrate argument set (Backport v4.0)

See merge request espressif/esp-idf!9761
2020-11-09 16:47:08 +08:00
34f3403c3a Merge branch 'feature/nvs_erase_check_init_4.0' into 'release/v4.0'
NVS Flash: prevent erasing initialized partition (backport v4.0)

See merge request espressif/esp-idf!10066
2020-11-09 16:44:31 +08:00
f9e85a78f6 Merge branch 'bugfix/mfg_tool_v4.0' into 'release/v4.0'
mfg_util: Update file handling to maintain line endings across various OS (backport v4.0)

See merge request espressif/esp-idf!10173
2020-11-09 16:42:23 +08:00
c705befd58 Merge branch 'bugfix/parttool_example_test_fail_v4.0' into 'release/v4.0'
examples/parttool: fix the test to work on parallel test runner (backport v4.0)

See merge request espressif/esp-idf!10375
2020-11-09 16:42:19 +08:00
927a5cd46b Merge branch 'bugfix/ulp_as_version_v4.0' into 'release/v4.0'
ulp: fix ULP assembler version detection for localized systems (v4.0)

See merge request espressif/esp-idf!10395
2020-11-09 16:41:14 +08:00
11f4a09ce2 Merge branch 'bugfix/eclipse_make_py3_v4.0' into 'release/v4.0'
tools: Fix Python 3 incompatibility for building with Eclipse on Windows (v4.0)

See merge request espressif/esp-idf!10400
2020-11-09 16:40:30 +08:00
10094b3151 Merge branch 'bugfix/log-error-run-esptool_v4.0' into 'release/v4.0'
parttool.py: Add file stream parameter and log stdout and stderr to same stream (v4.0)

See merge request espressif/esp-idf!10518
2020-11-09 16:40:23 +08:00
5e8cb9f734 Merge branch 'bugfix/ci_clone_https_v4.0' into 'release/v4.0'
ci: use HTTPS for cloning in IT jobs (v4.0)

See merge request espressif/esp-idf!11097
2020-11-09 16:38:56 +08:00
8acd6f41aa Merge branch 'feature/lwip_tcp_isn_hook_v4.0' into 'release/v4.0'
lw-ip: enable TCP ISN hook (v4.0)

See merge request espressif/esp-idf!11064
2020-11-09 15:53:34 +08:00
247fffe062 Merge branch 'bugfix/openss_strict_verify_mode_4.0' into 'release/v4.0'
openssl: made verification mode conversion to mbetls modes more strict (v4.0)

See merge request espressif/esp-idf!10501
2020-11-09 15:45:05 +08:00
4effed59cf Merge branch 'feature/mqtt_sub_update_01594bf1_v4.0' into 'release/v4.0'
MQTT: Update submodule reference (Backport v4.0)

See merge request espressif/esp-idf!10233
2020-11-09 15:44:44 +08:00
e8516af6f9 Merge branch 'bugfix/ws_stop_deadlock_v4.0' into 'release/v4.0'
Websocket client: avoid deadlock if stop called from event handler (Backport 4.0)

See merge request espressif/esp-idf!10228
2020-11-09 15:43:51 +08:00
3f5cbe4e30 Merge branch 'bugfix/ethernet_handle_early_rx_interrupt_v4.0' into 'release/v4.0'
Bugfix/ethernet handle early rx interrupt (v4.0)

See merge request espressif/esp-idf!10100
2020-11-09 15:43:09 +08:00
85b71109d0 Merge branch 'bugfix/ble_mesh_nimble_ccc_handle_v4.0' into 'release/v4.0'
ble_mesh: nimble: Fix updating ccc handle with wrong value (v4.0)

See merge request espressif/esp-idf!10356
2020-11-09 14:35:47 +08:00
87ddc09a81 Merge branch 'bugfix/ble_mesh_remove_assert_v4.0' into 'release/v4.0'
ble_mesh: stack: Avoid using assert in mesh stack (v4.0)

See merge request espressif/esp-idf!10360
2020-11-09 14:35:19 +08:00
9b087d3ba4 Merge branch 'bugfix/ble_mesh_example_compile_warn_v4.0' into 'release/v4.0'
Bugfix/ble mesh example compile warn (v4.0)

See merge request espressif/esp-idf!10224
2020-11-09 14:34:37 +08:00
lly
b8470fba75 ble_mesh: stack: Avoid using assert in mesh stack 2020-11-09 02:20:19 +00:00
lly
0f7a42cfbb ble_mesh: nimble: Fix updating ccc handle with wrong value 2020-11-09 02:17:46 +00:00
lly
3bfe5f130b ble_mesh: example: Remove some useless included header files 2020-11-09 02:09:01 +00:00
82bfe2ae5d Fix compilation warnings about portmacro being already define. 2020-11-09 02:09:01 +00:00
8007eb9a31 Merge branch 'bugfix/doc_main_readme_build_v4.0' into 'release/v4.0'
Fix the setup instructions in the main README (v4.0)

See merge request espressif/esp-idf!10339
2020-11-06 08:32:47 +08:00
a6e65a47a8 Merge branch 'feature/guide_change_for_catalina_v4.0' into 'release/v4.0'
docs: Add profile file name used by zsh shell (v4.0)

See merge request espressif/esp-idf!10774
2020-11-06 08:29:45 +08:00
43736e073a Merge branch 'feature/docs-add-python-clean_v4.0' into 'release/v4.0'
docs: Add solution for ImportError in idf.py into the documentation (v4.0)

See merge request espressif/esp-idf!10632
2020-11-06 08:22:53 +08:00
16ccf29a74 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 arm parent monitor when a parent candidate is cleared without sending an event to mesh layer
5. Fix the new voted root does not reconnect to router if rssi is weak
2020-11-05 23:54:45 +08:00
b3c39b2d25 Merge branch 'bugfix/esp_idf_version_v4.0' into 'release/v4.0'
Add __ASSEMBLER__ flag in esp_idf_version.h to fix build failure with assembly files (v4.0)

See merge request espressif/esp-idf!10901
2020-11-05 12:44:50 +08:00
92d755d48c Merge branch 'update/version_4_0_2' into 'release/v4.0'
Update version to 4.0.2

See merge request espressif/esp-idf!11117
2020-11-05 11:58:26 +08:00
e5f754b26c versions: Update version to 4.0.2 2020-11-05 09:38:34 +08:00
b70d209586 ci: use HTTPS for cloning in IT jobs 2020-11-03 19:32:06 +08:00
e9b6d40b97 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:57 +01:00
4904606461 Merge branch 'bugfix/scan_issue_sha256_ap_v4.0' into 'release/v4.0'
scan: Fix scan issue with PSK-SHA256 AP's (Backport v4.0)

See merge request espressif/esp-idf!11070
2020-11-02 22:01:42 +08:00
8265966974 esp_netif: initialize TCP ISN hook if enabled in configuration 2020-11-02 14:30:43 +05:30
4dd7cfbeb7 lwip: provide configuration option to enable TCP ISN hook 2020-11-02 14:30:43 +05:30
6aa24a5de5 tcp_isn: use ROM APIs for md5 calculations 2020-11-02 14:30:39 +05:30
b7ccfb921f esp_wifi: Update wifi lib
AP's with WPA2-PSK-SHA256 key management were incorrectly
categorized as Open. Update WiFi libs with the fix.
2020-11-02 12:03:17 +05:30
5aba396717 lwip: add custom TCP ISN hook implementation
Source:
https://git.savannah.nongnu.org/cgit/lwip/lwip-contrib.git/
2020-10-30 16:33:54 +05:30
5a218fa9c6 bugfix: import error in example tests 2020-10-29 21:05:03 +08:00
lly
037b2fce46 ble_mesh: test: Fix node test function not update role flag 2020-10-29 15:50:44 +08:00
76ea4cb540 tools/ldgen: Fix parsing of sections names on Windows 2020-10-29 08:38:23 +01:00
f6c8c987fe tools/ldgen: Parse paths with Unicode characters in archives
Closes https://github.com/espressif/esp-idf/issues/5996
2020-10-29 08:38:23 +01:00
a11e5b399e 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-28 11:50:47 +00:00
25813ebe2b Merge branch 'bugfix/tx_prog_dram_crash_v4.0_1' into 'release/v4.0'
components/bt: fixed tx_prog insert error(new for ci release/v4.0)

See merge request espressif/esp-idf!10980
2020-10-26 21:34:41 +08:00
db733d7321 Merge branch 'bugfix/fix_tsf_bug_v4.0' into 'release/v4.0'
WiFi: fix tsf bug (backport v4.0)

See merge request espressif/esp-idf!10950
2020-10-26 21:32:44 +08:00
5c64e5090e idf monitor: fix crash when monitor baudrate argument set
Closes IDF-1902
2020-10-26 07:02:29 +00:00
4ae63961cd components/bt: fixed tx_prog insert error 2020-10-26 13:24:17 +08:00
1d224db575 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:12 +11:00
55acc10303 esp_wifi: Fixed the bug for timestamp check, didn't disconnect AP when AP's timestamp decrease abnormally 2020-10-26 02:10:39 +00:00
f28111b6fe Merge branch 'feature/move_auto_test_script_to_new_repo_4.0' into 'release/v4.0'
ci: move auto_test_script to new repo (backport 4.0)

See merge request espressif/esp-idf!10880
2020-10-24 09:25:35 +08:00
dcb5d956d3 test: move auto test script to new repo (backport)
+ known issue
2020-10-24 09:25:33 +08:00
77dc24908c Merge branch 'bugfix/ipv6_ping_error_when_src_ip_miss_for_4.0' into 'release/v4.0'
lw-ip:bugfix ipv6 ping error when src ip miss for 4.0(backport 4.0)

See merge request espressif/esp-idf!10934
2020-10-23 11:28:56 +08:00
17e053930e bugfix ipv6 ping error when src ip miss for 4.0 2020-10-21 20:45:10 +08:00
4b8205edd6 esp_idf_version.h: Add __ASSEMBLER__ flag to fix build failure with assembly files 2020-10-19 13:22:43 +05:30
b6cd033236 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:19:13 +08:00
2270241f55 esp_ble_mesh: api: fixed comment about autoresp 2020-10-19 11:05:56 +08:00
0622073b78 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:12:03 +11:00
97c0204ab9 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:12:03 +11:00
85ca721867 spi: fix issue with closing DMA before CPU reset 2020-10-14 22:05:21 +08:00
7791de6cf8 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-13 07:12:40 +00:00
1c7607d4a6 Merge branch 'bugfix/assert_no_IRAM_ATTR_v4.0' into 'release/v4.0'
btdm fix cache disable crash, insert the llcp packet to the top of the tx_prog

See merge request espressif/esp-idf!10779
2020-10-13 12:30:59 +08:00
49c4947a4c cmake: fix getting component requirements 2020-10-13 12:27:43 +08:00
11a2b77cd4 cmake: fix C identifier generation from embedded file 2020-10-13 12:26:53 +08:00
42e380270c Merge branch 'bugfix/pmf_softap_coex_issue_v4.0' into 'release/v4.0'
Fix issues related to PMF and WPA2-Enterprise (Backport v4.0)

See merge request espressif/esp-idf!10698
2020-10-13 12:26:21 +08:00
def1304b4a examples: Fix socket examples to uses IPv6 scoped addresses from tcpip_adapter API 2020-10-12 13:53:37 +00:00
lly
097075dcc8 ble_mesh: stack: Make mesh buf debug option invisible 2020-10-12 14:17:22 +08:00
lly
88cc674e11 ble_mesh: stack: Add mesh device properties v2 definitions
Also fixes wrong characteristic value length of some device
properties.
2020-10-12 10:17:49 +08:00
lly
da81ff2263 ble_mesh: stack: Move device property to model common part 2020-10-12 10:17:48 +08:00
e9dfea8421 components/bt:btdm fix cache disable crash, insert the llcp packet to the top of the tx_prog 2020-10-11 15:20:40 +08:00
0016d20946 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 for mismatching AP config
2020-10-10 10:10:11 +00:00
d7e5094670 docs: add description of python-clean command 2020-10-10 09:56:04 +00:00
d4499598e4 Merge branch 'bugfix/fix_ble_hci_desync_deadlock_v4.0' into 'release/v4.0'
components/bt: Backport of the BLE controller fix for hci desync deadlock v4.0

See merge request espressif/esp-idf!10129
2020-10-10 17:50:46 +08:00
7af4c6f840 components/bt: Fix for HCI desync deadlock issue in BLE controller 2020-10-10 16:35:18 +08:00
lly
2761b461dc 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-10-10 01:09:04 +00:00
4f00268cfa docs: Add profile file name used by zsh shell 2020-10-09 19:17:15 +02:00
c783abc2e3 Merge branch 'bugfix/assert_rx_link_v4.0_fix_mr_v4.0' into 'release/v4.0'
fix assert(10,9), when missing evt_end or rx and evt_end come the same time v4.0.

See merge request espressif/esp-idf!10422
2020-10-09 19:54:06 +08:00
3b670f1f8b NimBLE: host_rcv_pkt event buf size check.
Check if the size of HCI event buffer is greater than the received HCI
packet. If not then abort with the error message.
2020-10-09 09:32:14 +05:30
0a0f7bbd6c 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-09 03:51:05 +00:00
312504a52f doc: Getting Started Guide, remove shortcuts to 'build toolchain from scratch' instructions 2020-10-09 02:52:09 +00:00
3e44ebd3d7 Merge branch 'bugfix/ci_auto_checkout_revision_of_project_used_in_ci_v4.0' into 'release/v4.0'
CI: get git describe from annotated tags (v4.0)

See merge request espressif/esp-idf!10675
2020-10-08 16:44:52 +08:00
893d74f6ef ci: Check version tags are always annotated
Closes https://github.com/espressif/esp-idf/issues/3114
2020-10-07 13:55:53 +11:00
3350a108c3 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:55:53 +11:00
ac545ce97c CI: get git describe from annotated tags:
we should only parse IDF version from annotated tags
2020-09-30 11:33:52 +08:00
82140dd840 1.revert dummy command
2.fix send MEDIA_CTRL command in disconnect
2020-09-28 11:28:22 +08:00
8e9f4e719d 1.fix test case dummy
2.fix sink send media control ESP_A2D_MEDIA_CHECK_SRC_RDY
2020-09-28 11:28:08 +08:00
445822104a Merge branch 'bugfix/fix_receiving_packets_from_myself_v4.0' into 'release/v4.0'
esp_wifi: drop receiving packets from myself (backport v4.0)

See merge request espressif/esp-idf!10567
2020-09-24 22:35:19 +08:00
dabceb4fe4 Merge branch 'bugfix/ipv6_send_data_error_when_src_ip_miss_for_4.0' into 'release/v4.0'
lw-ip:ipv6 send multicast data fail when src address is null (backport 4.0)

See merge request espressif/esp-idf!10561
2020-09-24 22:35:10 +08:00
0305b4a778 flash_mmap: restore interrupt and cache before err return 2020-09-24 10:02:58 +08:00
e93daa4e81 flash_mmap: can mmap after get enough free MMU pages 2020-09-24 10:02:58 +08:00
e6816163fe Merge branch 'bugfix/wifi_spin_lock_allocation_in_PSRAM_v4.0' into 'release/v4.0'
wifi: Fix spin lock allocation in PSRAM bug(v4.0)

See merge request espressif/esp-idf!10551
2020-09-23 19:01:12 +08:00
daab8014fb Merge branch 'bugfix/libcoap_update_tinydtls_repo' into 'release/v4.0'
coap: update libcoap to fix its broken submodule pointer

See merge request espressif/esp-idf!10440
2020-09-23 18:25:49 +08:00
a1fe8fa851 esp_wifi: drop receiving packets from myself 2020-09-23 14:34:31 +08:00
3687627226 Merge branch 'bugfix/update_esp32_phy_4390_v4.0' into 'release/v4.0'
esp_wifi: update phy v4390(backport v4.0)

See merge request espressif/esp-idf!10489
2020-09-23 13:51:15 +08:00
0fe7ac0bd7 ipv6 send multicast data fail when src address is null for 4.0 2020-09-22 17:18:49 +08:00
9039ddb20c Fix spin lock allocation in PSRAM bug 2020-09-22 14:19:56 +08:00
56a9383552 add file stream parameter and log stdout and stderr to same stream 2020-09-18 10:39:40 +02:00
53c57cf2a3 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:14:40 +08:00
98e9f62dda Add global header and change declaration position 2020-09-18 14:14:34 +08:00
ca2fff3b51 Remove uneccessary macro
Separate AVRC from A2DP when AVRC not Initialized
2020-09-18 14:14:27 +08:00
7f66230e9e Rewrite a2dp clean_up function 2020-09-18 14:14:20 +08:00
a3ca473dd4 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:14:11 +08:00
1a7149ce76 openssl: made verification mode conversion to mbetls modes more strict 2020-09-17 14:38:15 +02:00
c308562a31 Merge branch 'bugfix/btdm_spp_null_ptr_with_dynamic_memory_v4.0' into 'release/v4.0'
components/bt: Fix SPP using NULL point with dynamic memory

See merge request espressif/esp-idf!10324
2020-09-17 20:28:43 +08:00
293c2d95f6 esp_wifi: update phy v4390(backport v4.0) 2020-09-17 16:08:50 +08:00
lly
2b81af52aa ble_mesh: stack: Check if mesh stack initialized before init vendor client 2020-09-17 11:27:00 +08:00
7c9f76db63 ci: Use git mirror for docker image 2020-09-14 12:50:04 +02:00
374b756f6b coap: update libcoap to fix its broken submodule pointer
Though IDF v4.0 does not have dependency on `tinydtls` repository
within libcoap, it created problem in recursive clone. This commit
picks up change from upstream libcoap release-v4.2.0 to update
`tinydtls` repository pointer.

More information at:
https://github.com/obgm/libcoap/pull/531

Merges https://github.com/espressif/esp-idf/pull/5626
2020-09-14 10:59:52 +05:30
e3ecb8d073 fix assert(10,9), when missing evt_end or rx and evt_end come the same time 2020-09-14 10:48:59 +08:00
f97188d2d3 Add protection for rfcomm close API in SPP 2020-09-14 10:06:22 +08:00
f38d93f73c 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-14 10:06:22 +08:00
lly
a92247d461 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 11:01:17 +08:00
fb594f8f5d spi_master: correctly set cs polarity
All devices must be added to the same spi line before use.
2020-09-10 16:07:01 +08:00
2e9561d252 tools: Fix Python 3 incompatibility for building with Eclipse on Windows 2020-09-10 09:46:46 +02:00
9f7be2b7f4 ulp: fix ULP assembler version detection for localized systems 2020-09-10 09:36:03 +02:00
c2b1d3a9d2 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:52:07 +02:00
2ebe7d13f4 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:39:02 +02:00
90fdeb0955 NVS Flash: prevent erasing initialized partition
Closes https://github.com/espressif/esp-idf/issues/4755
Closes https://github.com/espressif/esp-idf/issues/2777

* 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
2020-09-08 19:30:06 +08:00
1cc99eefb7 Fix the setup instructions in the main README 2020-09-08 10:18:27 +02:00
9263b84f37 components/bt: Fix SPP using NULL point with dynamic memory 2020-09-07 15:46:09 +08:00
6093407d78 Merge branch 'feature/toolchain_2020r3_v4.0' into 'release/v4.0'
Update toolchain to esp-2020r3 (backport v4.0)

See merge request espressif/esp-idf!10278
2020-09-07 14:44:52 +08:00
0fda05cc83 Merge branch 'bugfix/l2cap_link_timeout_llcp_prog_btu_wtd_v4.0' into 'release/v4.0'
Bugfix/l2cap link timeout llcp prog btu wtd v4.0

See merge request espressif/esp-idf!10253
2020-09-07 14:18:09 +08:00
df7028dc52 Merge branch 'bugfix/spi_flash_yield_coredump_v4.0' into 'release/v4.0'
spi_flash: don't call vTaskDelay in non-os context (backport v4.0)

See merge request espressif/esp-idf!10299
2020-09-07 13:24:38 +08:00
c928bcc4b8 spi_flash: don't call vTaskDelay in non-os context
Fixes regression in core dump, when a crash happens in interrupt
context.
2020-09-04 21:24:32 +02:00
5812a935ba Merge branch 'feature/esp_spp_stop_srv_v4.0' into 'release/v4.0'
bugfix/Add API esp_spp_stop_srv and fix collection of SPP [backport v4.0]

See merge request espressif/esp-idf!10013
2020-09-04 20:00:41 +08:00
54bc506d26 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-09-04 19:01:20 +08:00
2ba90c8453 component/bt: Fixed the watchdog timeout of btu task during multi-connection 2020-09-04 16:24:23 +08:00
7009d7bcfe 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;

    Closes https://github.com/espressif/esp-idf/issues/5765
2020-09-04 13:20:39 +07:00
06fea3a2f7 Merge branch 'bugfix/update_esp32_phy_4370_v4.0' into 'release/v4.0'
esp_wifi: update esp32 phy v4370(Backport v4.0)

See merge request espressif/esp-idf!10025
2020-09-04 11:29:45 +08:00
e59336337c esp_wifi: update esp32 phy v4370
fix sleep wakeup optimizaion do not cover 480M bbpll configuration,
which cause CPU working in 240M mode RX throughput is low.
2020-09-03 20:15:17 +08:00
749e71e8e2 Merge branch 'feature/pmf_espnow_coexistance_v4.0' into 'release/v4.0'
espnow/pmf: Implement ESPNOW + PMF Co-existance (Backport v4.0)

See merge request espressif/esp-idf!10247
2020-09-03 16:23:41 +08:00
3f96604fda Merge branch 'bugfix/fix_i2s_reset_issue_v4.0' into 'release/v4.0'
Bugfix/fix i2s reset issue v4.0

See merge request espressif/esp-idf!9585
2020-09-03 11:07:38 +08:00
013654cc11 Merge branch 'feature/vfs_uart_set_line_ending_v4.0' into 'release/v4.0'
feature: support vfs uart set line endings with specified uart number release/v4.0

See merge request espressif/esp-idf!9598
2020-09-03 00:48:43 +08:00
ce1905d6b5 components/bt: Fixed the state not synchronized between controller and host when disconnected. 2020-09-02 21:33:06 +08:00
4d8ba4b4de 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-09-02 15:02:45 +05:30
54c2bd7c0c driver(I2S): Fix I2S reset issue for release/v4.0
`i2s_start` reseting I2S in incorrect order causeing the word-order error.
2020-09-02 16:30:03 +08:00
d1fa5c712a Merge branch 'bugfix/freemodbus_fix_long_frame_buffer_failure_backport4_0' into 'release/v4.0'
freemodbus: freemodbus fix long frame buffer failure (backport v4.0)

See merge request espressif/esp-idf!8199
2020-09-02 16:12:28 +08:00
2832f5f6f2 component/bt: fix Blufi sends data after disconnect the seq still increase(backport v4.0) 2020-09-02 11:08:07 +08:00
2efa45b317 MQTT: Update submodule reference
SSL: add config option for skipping common name check
esp-mqtt commit: 5e8950e681)
Closes https://github.com/espressif/esp-mqtt/issues/158

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

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

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

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

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

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

esp_mqtt_client_publish now returns msg id for QoS > 0 when offline
esp-mqtt commit: f7325bfa10
2020-09-01 16:03:20 +08:00
3d952d3f56 Websocket client: avoid deadlock if stop called from event handler 2020-09-01 15:43:49 +08:00
c756f7c4d2 Merge branch 'bugfix/fix_ipv6_nd6_max_queue_num_4.0' into 'release/v4.0'
lw-ip: fix IPv6 ND6 queue too much pkts (Backport 4.0)

See merge request espressif/esp-idf!10090
2020-08-31 14:27:59 +08:00
4b63e016c4 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:38:56 +05:30
5ec780d6b5 Merge branch 'bugfix/wifi_deinit_stop_crash_v4.0' into 'release/v4.0'
esp_wifi: fix the crash when wifi stop after deinit (v4.0)

See merge request espressif/esp-idf!10029
2020-08-27 11:48:30 +08:00
5ad4713362 Merge branch 'bugfix/clean_wpa2_wifi_deinit_v4.0' into 'release/v4.0'
wpa_supplicant: Deinit wpa2 states in wifi deinit(backport v4.0)

See merge request espressif/esp-idf!10104
2020-08-27 11:40:11 +08:00
6dd8569b4b Merge branch 'bugfix/null_ptr_dereference_mgmt_rx' into 'release/v4.0'
esp_wifi: Fix null pointer dereferences in mgmt rx (backport v4.0)

See merge request espressif/esp-idf!10132
2020-08-27 11:22:07 +08:00
df52fb3942 esp_wifi: Fix null pointer dereferences in mgmt rx 2020-08-26 12:23:21 +05:30
e376e8f989 Merge branch 'bugfix/assert_9_10_error_v4.0' into 'release/v4.0'
Fixed assert(9, 10), When rx and evt_end interrupts exist at the same time,...

See merge request espressif/esp-idf!10049
2020-08-26 11:38:07 +08:00
98d525c1ea wpa_supplicant: Deinit wpa2 states in wifi deinit 2020-08-20 15:09:55 +05:30
08eb68f90f ethernet: support power on timeout
Closes https://github.com/espressif/esp-idf/issues/5425
2020-08-20 10:57:42 +08:00
296104a103 ethernet: set DMA owner after all descriptors have configured 2020-08-20 10:57:41 +08:00
c4fe36dd32 ethernet: handle early rx interrupt 2020-08-20 10:57:41 +08:00
c4107150ee lwip: fix IPv6 ND6 queue too much pkts cause no mem issue and add menuconfig item for this params. 2020-08-19 14:38:32 +08:00
98d1736fc6 bugfix(mcpwm_period_error): fix the issue of wrong period (backport v4.0) 2020-08-19 11:05:37 +08:00
6dde2eb3c5 Fixed assert(9, 10), When rx and evt_end interrupts exist at the same time, use the information of rx to determine the execution order 2020-08-18 16:06:22 +08:00
d9660fcf9c vfs: support vfs uart set line endings with specified uart number (release/v4.0) 2020-08-14 15:39:39 +08:00
45c4fef890 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:01:39 +08:00
93aea71641 esp_wifi: fix the crash when wifi stop after deinit 2020-08-13 10:56:57 +08:00
820621687c Merge branch 'bugfix/fix_udp_tx_performance_issue_v4.0' into 'release/v4.0'
lw-ip: fix udp tx packet loss issue (backport v4.0)

See merge request espressif/esp-idf!10005
2020-08-11 22:23:48 +08:00
bb33120756 lwip: fix udp tx packet loss issue 2020-08-11 15:09:44 +08:00
b88dc13ec3 Merge branch 'bugfix/buff_semaphore_not_free_v4.0' into 'release/v4.0'
component/bt: Fixed ble memory leak issue, buff_semaphore was not released.

See merge request espressif/esp-idf!9981
2020-08-10 15:10:24 +08:00
ed0393d707 Merge branch 'bugfix/ble_mesh_client_msg_optimize_v4.0' into 'release/v4.0'
Bugfix/ble mesh client msg optimize (v4.0)

See merge request espressif/esp-idf!9990
2020-08-10 11:02:29 +08:00
03abf3b209 Merge branch 'bugfix/idf_build_process_default_v4.0' into 'release/v4.0'
cmake: fix issue with setting defaults in idf_build_process (v4.0)

See merge request espressif/esp-idf!9713
2020-08-10 09:19:38 +08:00
lly
d3eaf8bdb0 ble_mesh: stack: Client model related code clean 2020-08-07 21:15:11 +08:00
lly
aa8f45e341 ble_mesh: stack: Rename cfg & health client status recv func 2020-08-07 21:15:10 +08:00
lly
dfa6332606 ble_mesh: stack: Check client msg result in common func 2020-08-07 21:15:08 +08:00
lly
ba38c974e6 ble_mesh: stack: Fix no events for some error conditions 2020-08-07 21:15:07 +08:00
lly
3cc07d7969 ble_mesh: stack: Move client role set to the msg function 2020-08-07 21:15:06 +08:00
lly
035a24b468 ble_mesh: stack: Remove some not used client parameters 2020-08-07 21:15:04 +08:00
lly
c3e702da05 ble_mesh: stack: Remove some not used variables & functions 2020-08-07 21:15:03 +08:00
lly
dfd0cd5f3e ble_mesh: stack: Update client model msg send 2020-08-07 21:15:02 +08:00
91cf59981c Merge branch 'bugfix/ipv6_fragment_for_4.0' into 'release/v4.0'
lw-ip:fix bug for ipv6 fragment(backport4.0)

See merge request espressif/esp-idf!9578
2020-08-07 18:09:24 +08:00
b3de361e51 Merge branch 'bugfix/put_periph_module_enable/diable_into_iram_v4.0' into 'release/v4.0'
wifi, bt: move esp_phy_common_clock_disable into periph_ctrl and put it into IRAM(v4.0)

See merge request espressif/esp-idf!9937
2020-08-07 18:08:26 +08:00
a6dc125aec bootloader: Adds bootloader_sha256_flash_contents() 2020-08-07 17:16:21 +08:00
b50bbe3a5b component/bt: Fixed ble memory leak issue, buff_semaphore was not released. 2020-08-07 15:15:49 +08:00
b77c50a063 newlib: Fix UT for adjtime 2020-08-06 20:03:18 +08:00
409355febe 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:03:18 +08:00
14140e7550 Merge branch 'feature/upgrade_mbedtls_to_v4.0' into 'release/v4.0'
mbedtls: update to mbedtls release v2.16.7 (v4.0)

See merge request espressif/esp-idf!9908
2020-08-06 12:29:00 +08:00
e3edc15f94 bootloader_support: Fix bootloader_common_get_sha256_of_partition, can handle a long image
Closes: IDFGH-3594
2020-08-05 23:19:48 +08:00
94f4a88c2d 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 17:41:05 +08:00
7cc07173b2 Merge branch 'bugfix/btdm_blufi_send_longer_custom_data_will_congested_v4.0' into 'release/v4.0'
component/bt: fix Blufi sends longer customer data  will will lead congested(backport v4.0)

See merge request espressif/esp-idf!9918
2020-08-05 14:23:41 +08:00
12e39e9291 Merge branch 'fixbug/sdmmc_spi_highspeed_v4.0' into 'release/v4.0'
sdmmc: fix the probe issue that forbid sdspi working in highspeed mode(backport v4.0)

See merge request espressif/esp-idf!9839
2020-08-04 17:44:37 +08:00
100750ac1b component/bt: fix Blufi sends longer customer data will will lead congested(backport v4.0) 2020-08-04 15:22:18 +08:00
2597e046c5 Merge branch 'bugfix/ci_retries_when_download_v4.0' into 'release/v4.0'
CI: retry shell commands when download (v4.0)

See merge request espressif/esp-idf!9890
2020-08-04 12:48:03 +08:00
2995e78fa1 Merge branch 'bugfix/espcoredump_fix_error_reported_for_blank_partition_v40' into 'release/v4.0'
Bugfix/espcoredump fix error reported for blank partition (Backport v4.0)

See merge request espressif/esp-idf!9626
2020-08-04 12:45:41 +08:00
81e726e3fc Merge branch 'bugfix/fix_fragment_issue_v4.0' into 'release/v4.0'
esp_wifi: Fix WiFi fragment issue (backport v4.0)

See merge request espressif/esp-idf!9883
2020-08-04 12:27:52 +08:00
cc0aa104e8 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:50:34 +05:30
26d7fb7744 Merge branch 'ci/resume_esp_flash_tests_4.0' into 'release/v4.0'
ci: resume esp_flash unit tests (v4.0)

See merge request espressif/esp-idf!9793
2020-08-02 17:15:24 +08:00
374ad7d38f added psram stack check in backtrace 2020-08-02 05:27:41 +00:00
4cbb70541c Merge branch 'feature/oocd_ver_backport_v4.0' into 'release/v4.0'
tools: Updates OpenOCD version to 'v0.10.0-esp32-20200709' (backport v4.0)

See merge request espressif/esp-idf!8425
2020-07-31 21:58:06 +08:00
b1fa527f41 esp_wifi: Fix WiFi fragment issue 2020-07-31 21:42:19 +08:00
9a580242e8 Merge branch 'bugfix/fix_softap_mode_wpa_memory_leak_issue_v4.0' into 'release/v4.0'
bugfix: fix softap mode wpa memory leak (backport v4.0)

See merge request espressif/esp-idf!9847
2020-07-31 17:28:50 +08:00
3f332ef02b Merge branch 'bugfix/bt_linkup_fallback_event_v4.0' into 'release/v4.0'
Bluedroid: Fixes cases having fallback to link up event. (v4.0)

See merge request espressif/esp-idf!9804
2020-07-31 17:27:37 +08:00
2be17377bb Merge branch 'nimble/nrpa_support_v4.0' into 'release/v4.0'
NimBLE: Add Non-Resolvable private address support and misc fixes (Backport v4.0)

See merge request espressif/esp-idf!9736
2020-07-31 17:27:21 +08:00
6618e0c31d gdb: Modify PC in case of invalid PC
Signed-off-by: Sachin Parekh <sachin.parekh@espressif.com>
2020-07-31 07:40:12 +00:00
a7fe03dcb0 tools: Updates OpenOCD version to 'v0.10.0-esp32-20200709' 2020-07-31 07:16:19 +00:00
c2d261c88e ci: use the retry script to download 2020-07-31 13:07:07 +07:00
8ed6242e27 ci: add a helper for retrying shell command 2020-07-31 13:04:59 +07:00
f32582b588 Merge branch 'bugfix/fix_hci_max_page_num_v4.0' into 'release/v4.0'
bugfix/Support for more Bluetooth HID devices [backport v4.0]

See merge request espressif/esp-idf!9662
2020-07-30 21:20:15 +08:00
64c766ee4d Merge branch 'bugfix/fix_get_bond_device_list_v4.0' into 'release/v4.0'
bugfix/fix esp_bt_gap_get_bond_device_list bug [backport v4.0]

See merge request espressif/esp-idf!9668
2020-07-30 21:19:57 +08:00
4f86faa906 Merge branch 'bugfix/param_check_instant_tx_octets_adv_ubderrun_v4.0' into 'release/v4.0'
component/bt: add connect parameter, fix instant reverse, fix tx default octets, fix assert(1024,0)

See merge request espressif/esp-idf!9483
2020-07-30 21:18:43 +08:00
16d68e4dee Merge branch 'doc/freertos_backport_v4.0' into 'release/v4.0'
add a note about ESP-IDF FreeRTOS version (backport v4.0)

See merge request espressif/esp-idf!9820
2020-07-30 17:27:18 +08:00
426f03de5f Merge branch 'fix/prov_ble_read_offset_v4.0' into 'release/v4.0'
BLE provisioning: Add check for valid ble read offset (v4.0)

See merge request espressif/esp-idf!9746
2020-07-30 16:11:21 +08:00
d3034e8172 Merge branch 'bugfix/convert-string-to-bytes_v4.0' into 'release/v4.0'
components: convert string to bytes to fix TypeError (backport v4.0)

See merge request espressif/esp-idf!9732
2020-07-30 16:11:02 +08:00
fcb0206c59 Merge branch 'bugfix/mcpwm_fault_init_copypaste_typo_bp4.0' into 'release/v4.0'
MCPWM: Fix PWM-fault init function that read config incorrectly (backport v4.0)

See merge request espressif/esp-idf!9552
2020-07-30 15:55:11 +08:00
0dc46879c5 Merge branch 'bugfix/esp_flash_write_performance_regression_4.0' into 'release/v4.0'
esp_flash: fix the write performance regression (Backport v4.0)

See merge request espressif/esp-idf!9616
2020-07-29 15:30:13 +08:00
4e7d7426aa bugfix: fix softap mode wpa memory leak 2020-07-29 14:17:12 +08:00
6bec17308c Tools: Close temporary file before invoking external tools accessing it 2020-07-29 07:39:50 +02:00
818a2f8768 ci: resume esp_flash unit tests 2020-07-29 10:00:23 +08:00
7dfb6adf27 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 12:19:51 +08:00
9c82e7c875 docs: add a note about ESP-IDF FreeRTOS version 2020-07-27 20:24:43 +08:00
5fe10f1ff8 Bluedroid: Fixes cases having fallback to link up event.
Signed-off-by: Chinmay Chhajed <chinmay.chhajed@espressif.com>
2020-07-27 14:03:20 +05:30
ebacef4304 component/bt: add connect parameter, fix instant reverse, fix tx default octets, fix assert(1024,0), fix assert(512,0) 2020-07-24 12:05:29 +08:00
9566e4ec19 NimBLE: Add Non-Resolvable private address support and misc bug fixes (Backport v4.0)
- Merges https://github.com/espressif/esp-nimble/pull/12
- Fixes repeated pairing failure in RPA feature

Closes https://github.com/espressif/esp-idf/issues/5530
2020-07-23 11:31:52 +05:30
7abb8e7fc3 Merge branch 'docs/doc138_backport_v4.0' into 'release/v4.0'
Fix incorrect redirect link in getting started guide (backport v4.0)

See merge request espressif/esp-idf!9704
2020-07-23 13:24:20 +08:00
8cfc9f1609 Merge branch 'bugfix/prov_retry_failures_v4.0' into 'release/v4.0'
ci: Add retries for all provisioning methods, some refactors (v4.0)

See merge request espressif/esp-idf!9389
2020-07-23 13:17:21 +08:00
e5526e2953 Merge branch 'bugfix/wpa3_to_wpa2_transition_fix_v4.0' into 'release/v4.0'
Fix WPA3 and WPA2 transition related failures (Backport v4.0)

See merge request espressif/esp-idf!9534
2020-07-23 09:52:46 +08:00
8b5fb43d93 BLE provisioning: Add check for valid ble read offset 2020-07-22 19:42:09 +05:30
3b0a62a752 Merge branch 'ci/test_spi_speed_psram_enabled_4.0' into 'release/v4.0'
driver test: disable the spi master performance test when psram is used (v4.0)

See merge request espressif/esp-idf!9637
2020-07-22 17:28:24 +08:00
61bc60213e 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:17:38 +08:00
2595326978 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:04:22 +02:00
53605395cf Merge branch 'bugfix/collection_of_confirmed_fixes_from_baidu_project_4.0' into 'release/v4.0'
Backport MR for baidu project for release/v4.0

See merge request espressif/esp-idf!8989
2020-07-22 16:34:19 +08:00
b994331b83 Merge branch 'ci/workaround_multiple_ci_failures_v4.0' into 'release/v4.0'
CI: workaround multiple ci failures (v4.0)

See merge request espressif/esp-idf!9686
2020-07-22 11:55:24 +08:00
69059ea2cc driver test: disable the spi master performance test when psram is used 2020-07-21 05:43:45 +00:00
34f4b5a4d3 ci: pushd and cd in one go in idf_build_process defaults test 2020-07-20 18:24:05 +08:00
d30f3b6edd cmake: fix setting defaults in idf_build_process
Closes https://github.com/espressif/esp-idf/issues/5053
2020-07-20 18:24:05 +08:00
948795265d ci: test idf_build_process defaults set properly 2020-07-20 18:24:02 +08:00
ce88e9d3fe CI: do not run cases likely to fail 2020-07-19 14:58:28 +08:00
83895b4e78 CI: disable cases with test env SSC_T5_1 2020-07-19 14:58:28 +08:00
53852b555e CI: temp allow mesh job to fail as runner is not stable 2020-07-19 14:58:27 +08:00
087a1e339e CI: remove incorrect MTU related cases 2020-07-19 14:58:27 +08:00
712aa3daa7 Merge branch 'bugfix/ble_mesh_health_current_status_recv_v4.0' into 'release/v4.0'
ble_mesh: stack: Fix recv health current status incorrectly (v4.0)

See merge request espressif/esp-idf!9665
2020-07-17 16:14:44 +08:00
9a88eef632 fix esp_bt_gap_get_bond_device_list bug
Closes https://github.com/espressif/esp-idf/issues/5395
2020-07-17 15:12:57 +08:00
lly
beda5f0fd4 ble_mesh: stack: Fix recv health current status incorrectly 2020-07-17 14:06:41 +08:00
a1cf4fa871 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:23:52 +08:00
bf1394eeb8 Merge branch 'feature/toolchain_2020r2_v4.0' into 'release/v4.0'
Update toolchain to esp-2020r2  (backport v4.0)

See merge request espressif/esp-idf!9001
2020-07-16 16:22:17 +08:00
0dc0c54acd Merge branch 'bugfix/ble_mesh_misc_updates_v4.0' into 'release/v4.0'
Bugfix/ble mesh misc updates (v4.0)

See merge request espressif/esp-idf!9642
2020-07-16 14:03:15 +08:00
lly
235cdd2ff0 ble_mesh: ci: Enable friend & low power in build check 2020-07-16 11:04:58 +08:00
lly
f3566fd2af 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-07-16 11:04:57 +08:00
lly
f10c62d84d ble_mesh: stack: Make proxy server & client functions clear 2020-07-16 11:04:57 +08:00
775fd14310 Merge branch 'bugfix/ble_mesh_add_misc_check_v4.0' into 'release/v4.0'
Bugfix/ble mesh add misc check (v4.0)

See merge request espressif/esp-idf!9631
2020-07-16 10:51:49 +08:00
e9a07592fc 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-07-15 13:40:03 +00:00
48ea44f3d1 Merge branch 'feature/light_sleep_reject_v4.0' into 'release/v4.0'
sleep: enable sleep reject when entering light sleep (v4.0)

See merge request espressif/esp-idf!9501
2020-07-15 20:08:55 +08:00
009492ca9a Merge branch 'bugfix/fix_static_analysis_rules_v4.0' into 'release/v4.0'
static analysis: Apply current limits of known defects (v4.0)

See merge request espressif/esp-idf!9277
2020-07-15 16:56:22 +08:00
e4501dc0ec Merge branch 'bugfix/ws_send_abort_v4.0' into 'release/v4.0'
websocket client: the client now aborts the connection if send fails. (v4.0)

See merge request espressif/esp-idf!9171
2020-07-15 16:38:05 +08:00
lly
1df9502301 ble_mesh: stack: Add proxy cfg pdu length check 2020-07-15 16:11:32 +08:00
lly
d04a8da916 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-07-15 16:11:31 +08:00
lly
6e79097b4a ble_mesh: example: Add result check during mesh init 2020-07-15 16:11:29 +08:00
lly
c8601fface ble_mesh: stack: Add more checks about input prov bearers 2020-07-15 16:11:27 +08:00
cf98746771 Merge branch 'feat/ble_mesh_use_iram_for_mem_alloc_v4.0' into 'release/v4.0'
Feat/ble mesh use diff ram for mem alloc (v4.0)

See merge request espressif/esp-idf!9618
2020-07-15 16:07:00 +08:00
7f99280b40 spi_flash: add unit test for read/write performance (no performance
check)
2020-07-15 14:41:02 +08:00
59c6afda95 espcoredump: fix error reported for blank partition 2020-07-15 08:30:28 +02:00
lly
1e528fa739 ble_mesh: stack: Rename mesh adv queue and relay queue 2020-07-15 11:10:14 +08:00
lly
a27478b54d ble_mesh: stack: Use macros for adv task name & prio 2020-07-15 11:10:14 +08:00
lly
2ff3c012ea ble_mesh: ci: Add psram configurations 2020-07-15 11:10:14 +08:00
lly
0dc96d19aa ble_mesh: stack: Make freertos static allocation visible 2020-07-15 11:09:58 +08:00
lly
9973f5ef04 ble_mesh: stack: Update option of using DRAM/SPIRAM for memory allocation 2020-07-15 09:41:15 +08:00
ffc46954ae esp_flash: fix the write performance regression
Also changed internal delay unit into microsecond.
2020-07-15 02:20:35 +08:00
ee7b443d28 Merge branch 'bugfix/enable_mbedtls_renegotiation_v4.0' into 'release/v4.0'
esp-tls: enable TLS renegotiation using explicit API call (v4.0)

See merge request espressif/esp-idf!9593
2020-07-14 15:16:59 +08:00
6182c172bf 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-07-14 14:04:54 +07:00
faae3ceec5 Add fixes for gcc8 psram fix improvement 2020-07-14 14:04:53 +07:00
f7742dd9cc Merge branch 'bugfix/customer_baidu_int_wdt_v4.0' into 'release/v4.0'
backport v4.0: add soft solution for esp32 eco3 live lock issue

See merge request espressif/esp-idf!9214
2020-07-14 13:09:03 +08:00
5a99038b1a Merge branch 'bugfix/eth_insert_min_hw_reset_time_v4.0' into 'release/v4.0'
ethernet: insert min assert time for PHY HW reset (v4.0)

See merge request espressif/esp-idf!9581
2020-07-13 22:33:19 +08:00
80e0be6dbd Merge branch 'bugfix/rs485_test_temp_disable_v40' into 'release/v4.0'
ci: temporarily disable RS485 related tests (backport v4.0)

See merge request espressif/esp-idf!9520
2020-07-13 20:41:15 +08:00
6f034e9194 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:56:00 +05:30
de438461f5 Backport from baidu proj 2020-07-13 15:03:17 +08:00
cb7c143523 fix bug for ipv6 fragment 2020-07-13 11:30:33 +08:00
0100d70dfd ethernet: insert min assert time for PHY HW reset
Closes https://github.com/espressif/esp-idf/issues/5528
2020-07-13 11:21:30 +08:00
f73cd1d4f1 Merge branch 'docs/fix_event_typo_backport_v4.0' into 'release/v4.0'
docs/fix event typo backport v4.0

See merge request espressif/esp-idf!9384
2020-07-12 21:23:54 +08:00
0b3954c0c3 Merge branch 'bugfix/fix_some_wifi_bugs_0703_v4.0' into 'release/v4.0'
fix some wifi bugs 0703 (v4.0)

See merge request espressif/esp-idf!9532
2020-07-12 20:30:52 +08:00
bfbbb4d581 Merge branch 'bugfix/fix_event_bug_in_GAP_API_release_v4.0' into 'release/v4.0'
Bugfix/fix event bug in GAP API [backport v4.0]

See merge request espressif/esp-idf!9194
2020-07-10 16:57:37 +08:00
4cb1a2fdc3 Merge branch 'bugfix/fix_16mbit_psram_id_read_error_v4.0' into 'release/v4.0'
psram: fix 16mbit psram id read error (backport v4.0)

See merge request espressif/esp-idf!9439
2020-07-10 16:57:15 +08:00
94dfe1713c Merge branch 'doc/add_UUID_description_in_gattc_demo_backport_v4.0' into 'release/v4.0'
docs:add 128-bit UUID description backport v4.0

See merge request espressif/esp-idf!9227
2020-07-10 16:56:36 +08:00
6a929916b7 Merge branch 'bugfix/fix_build_err_in_cpp_backport_v4.0' into 'release/v4.0'
ble_hid_device_demo: fix build if building with c++ backport v4.0

See merge request espressif/esp-idf!9233
2020-07-10 16:56:16 +08:00
ff6c39376a Merge branch 'feature/make_tcp_rto_configurable_v4.0' into 'release/v4.0'
make TCP rto time configurable (backport v4.0)

See merge request espressif/esp-idf!9213
2020-07-10 16:55:53 +08:00
62e6b6f571 Merge branch 'bugfix/ble_mesh_update_send_ttl_v4.0' into 'release/v4.0'
Bugfix/ble mesh update send ttl v4.0

See merge request espressif/esp-idf!9563
2020-07-10 14:06:23 +08:00
8560d88391 add soft solution for esp32 eco3 live lock issue 2020-07-10 02:14:47 +00:00
lly
724a5baa4e ble_mesh: stack: Add two application macros for TTL 2020-07-10 09:15:02 +08:00
lly
c399b9520b ble_mesh: stack: Update send_ttl in btc when recv a msg
Update send_ttl mainly for server models. When a server model
receives a message, and the status is required to be replied
by the application, we need to set send_ttl to the msg context.
If send_ttl is not updated in btc, and the applcation does not
set the TTL either, then the status will be replied with TTL=0,
which may cause the client side (e.g. the phone App) failed to
receive the status.

Closes https://github.com/espressif/esp-idf/issues/5300
2020-07-10 09:15:01 +08:00
067d840c76 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:18:10 +08:00
b9dd8630ee Merge branch 'doc/broken_readme_links_v4.0' into 'release/v4.0'
Docs: Fix broken README links (v4.0)

See merge request espressif/esp-idf!9503
2020-07-08 23:54:50 +08:00
4e831ac080 esp_wifi: Add API to get available internal heap size. 2020-07-08 17:40:19 +08:00
8ae3c733db esp wifi bugfix:
1. Fix TX DMA buffer issue
2. API esp_wifi_get_config add acquisition sta.listen_interval
3. Configure bandwidth and phy mode to store NVS
4. If AP's tsf has been restarted, STA will disconnect from AP.
5. Do not reset softAP's tsf except it restart
6. fix the wifi regdomain update bug
7. fix the bug for airkiss find hidden AP fail
8. fix addba and first ampdu send bar
2020-07-08 17:27:15 +08:00
576957b17d Merge branch 'bugfix/http_client_read_v4.0' into 'release/v4.0'
Fix error handling in esp_http_client_read and esp_https_ota_perform (v4.0)

See merge request espressif/esp-idf!9204
2020-07-08 17:19:50 +08:00
9e506a921b 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 15:07:05 +08:00
db7f558e34 ci: temporarily disable RS485 related tests 2020-07-08 06:31:29 +02:00
0253a372be Increase receive timeout in sdkconfig.ci to fix CI failures 2020-07-08 09:57:49 +05:30
9fe1380b7f esp_https_ota.c: Add fix to return failure if (-1) is returned from esp_http_client_read
Closes https://github.com/espressif/esp-idf/issues/4960
2020-07-08 09:57:43 +05:30
a9591d1c1f esp_http_client.c: In esp_http_client_read, add fix to return (-1) if esp_transport_read fails 2020-07-08 09:57:42 +05:30
4ff6d873bb Fix broken README links 2020-07-07 18:07:57 +08:00
5da359c253 sleep: enable sleep reject when entering light sleep 2020-07-07 11:21:42 +02:00
9216af8371 Merge branch 'bugfix/coredump_size_inv_stack_v4.0' into 'release/v4.0'
coredump: Fixes data length calculation when task stack is corrupted (v4.0)

See merge request espressif/esp-idf!9458
2020-07-07 16:30:26 +08:00
1e95aba03a Merge branch 'feature/msys2_env_update_v4.0' into 'release/v4.0'
windows: Update MSYS2 pre-compiled legacy build environment (v4.0)

See merge request espressif/esp-idf!9144
2020-07-06 15:16:39 +08:00
8a2c055179 Merge branch 'bugfix/fix_adc_dac_conflict_backportv4.0' into 'release/v4.0'
Driver(adc): Disable the synchronization operation function of ADC1 and DAC (backport v4.0)

See merge request espressif/esp-idf!9362
2020-07-06 13:19:22 +08:00
d7f251aef3 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:13:46 +00:00
e0fc7b1c48 esp_prov: Extend the timeout for HTTP connection to SoftAP 2020-07-03 09:13:46 +00:00
7358470ae9 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:13:46 +00:00
200fa4abeb 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:13:46 +00:00
822b6986aa esp_prov: Refactor to use new 'wait_wifi_connected' function
Means all provisioning examples will have the same retry behaviour.
2020-07-03 09:13:46 +00:00
6787718e1b ci provisioning: Use strings instead of "magic numbers" for connection state 2020-07-03 09:13:46 +00:00
388522a886 ci: Wait up to 60 seconds for client to connect to DUT in provisioning test 2020-07-03 09:13:46 +00:00
a391a98a02 Merge branch 'bugfix/ble_mesh_fast_prov_misc_update_v4.0' into 'release/v4.0'
Bugfix/ble mesh fast prov misc update (v4.0)

See merge request espressif/esp-idf!9463
2020-07-03 11:38:03 +08:00
lly
39705533f1 ble_mesh: stack: Update some fast prov functions 2020-07-03 08:53:56 +08:00
lly
77fe2ced32 ble_mesh: stack: Move fast prov functions to a single file 2020-07-03 08:53:56 +08:00
36ba6be9ae Merge branch 'bugfix/ble_mesh_split_tinycrypt_v4.0' into 'release/v4.0'
Bugfix/ble mesh split tinycrypt (v4.0)

See merge request espressif/esp-idf!9372
2020-07-02 22:46:08 +08:00
68b272f590 Merge branch 'bugfix/beacon_security_downgrade_v4.0' into 'release/v4.0'
Avoid parsing RSN/WPA IE's after connection (Backport v4.0)

See merge request espressif/esp-idf!9281
2020-07-02 21:29:18 +08:00
f12b8c7990 coredump: Fixes data length calculation when task stack is corrupted 2020-07-02 14:12:15 +03:00
lly
c4794f761e ble_mesh: ci: Fix failing to compile when using make 2020-07-02 03:35:13 +00:00
lly
4d9af50eba ble_mesh: Mark platform related default RNG as 0 2020-07-02 03:35:13 +00:00
lly
0e028c044d ble_mesh: Remove the previously added redundant aes files 2020-07-02 03:35:13 +00:00
lly
813cf5cc00 ble_mesh: Update CMake and make files for tinycrypt 2020-07-02 03:35:13 +00:00
lly
ac0746aba1 ble_mesh: Update tinycrypt header file include guards
Add BLE_MESH in the macro to make it specific for BLE Mesh.
2020-07-02 03:35:13 +00:00
lly
e5f4ff2b1a ble_mesh: Format source and header files of tinycrypt 2020-07-02 03:35:13 +00:00
lly
4f37a08437 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-07-02 03:35:13 +00:00
d8e590555c Merge branch 'bugfix/ble_mesh_readme_fix_v4.0' into 'release/v4.0'
ble_mesh: example: Fix example README & tutorial link error (v4.0)

See merge request espressif/esp-idf!9436
2020-07-02 11:29:37 +08:00
c7acaf9b44 Merge branch 'bugfix/ble_mesh_compile_error_v4.0' into 'release/v4.0'
Bugfix/ble mesh compile error (v4.0)

See merge request espressif/esp-idf!9432
2020-07-02 11:29:06 +08:00
2c45d430da esp_wifi: Update wifi lib
1. Avoid parsing RSN/WPA IE's after connection
2. Remove AUTH_CHANGED reason code logic
2020-07-01 16:24:23 +05:30
671ecd7522 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-07-01 16:39:16 +08:00
fd475fc9bc psram: fix 16mbit psram id read error 2020-07-01 16:38:29 +08:00
lly
797971e8cc ble_mesh: example: Fix example README & tutorial link error 2020-07-01 14:39:32 +08:00
8309f06378 Merge branch 'bugfix/kconfig_vendor_specific_v4.0' into 'release/v4.0'
Bugfix: bt/Kconfig Vendor specific event data type and default value

See merge request espressif/esp-idf!9416
2020-07-01 13:49:53 +08:00
lly
4fd867616c ble_mesh: ci: Add different proxy configurations 2020-07-01 11:55:13 +08:00
lly
3b6145dc46 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-07-01 11:55:12 +08:00
b823a2a35f Merge branch 'bugfix/ble_mesh_check_subnet_before_update_beacon_sent_v4.0' into 'release/v4.0'
ble_mesh: Check if subnet exists before updating beacon_sent (v4.0)

See merge request espressif/esp-idf!9397
2020-07-01 11:16:39 +08:00
4802585bfd Merge branch 'bugfix/ble_mesh_set_recv_rssi_v4.0' into 'release/v4.0'
Bugfix/ble mesh set recv rssi (v4.0)

See merge request espressif/esp-idf!9391
2020-07-01 11:15:20 +08:00
b9b31e3c85 bt/Kconfig: Update data type and default value of vendor specific event. 2020-06-30 15:02:22 +05:30
d921a06c1f Merge branch 'feature/bt_secure_conn_downgrade_check_v4.0' into 'release/v4.0'
Bluedroid: Authentication fixes in Legacy and Secure Connection.

See merge request espressif/esp-idf!9338
2020-06-30 15:26:57 +08:00
lly
dfcc8e77dc 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-06-30 09:22:49 +08:00
lly
7f6735fd60 ble_mesh: stack: Copy recv_rssi for other received messages
Follow the commit: 2b80cb6883,
copy the recv_rssi for other mesh messages.
2020-06-30 09:05:51 +08:00
ca5ab9b607 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-06-30 09:05:50 +08:00
acb54059be 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:59:14 +08:00
3e31c484ba Merge branch 'bugfix/http_server_lru_v4.0' into 'release/v4.0'
esp_http_server: Update LRU counter on accepting a new connection (v4.0)

See merge request espressif/esp-idf!9352
2020-06-29 12:57:25 +08:00
fac0b1128f Driver(adc): Disable the synchronization operation function of ADC1 and DAC
Closes IDF-1585
2020-06-29 03:41:26 +00:00
9969ec1de5 Merge branch 'bugfix/esp_flash_revert_qe_clear_4.0' into 'release/v4.0'
esp_flash: fix the regression of non-quad mode by default chip driver, bugs in add_device and deprecate cs_id (4.0)

See merge request espressif/esp-idf!8879
2020-06-28 22:13:25 +08:00
8cb2ad1fe6 Merge branch 'bugfix/ble_mesh_get_node_with_name_v4.0' into 'release/v4.0'
ble_mesh: Get node info with pre-configured node name (v4.0)

See merge request espressif/esp-idf!9303
2020-06-28 20:25:24 +08:00
3f0956bfa0 Merge branch 'bugfix/ble_mesh_example_tag_define_v4.0' into 'release/v4.0'
ble_mesh: Move TAG definition to each example (v4.0)

See merge request espressif/esp-idf!9307
2020-06-28 20:25:06 +08:00
304c40f3ef Merge branch 'bugfix/ble_mesh_bt_hex_v4.0' into 'release/v4.0'
ble_mesh: Fix wrong log output with bt_hex (v4.0)

See merge request espressif/esp-idf!9310
2020-06-28 20:24:12 +08:00
ef136a664c Merge branch 'bugfix/ble_mesh_not_define_bool_v4.0' into 'release/v4.0'
Bugfix/ble mesh not define bool (v4.0)

See merge request espressif/esp-idf!9317
2020-06-28 20:23:03 +08:00
666014447b Merge branch 'bugfix/ble_mesh_check_model_status_v4.0' into 'release/v4.0'
ble_mesh: stack: Check model status with variable length (v4.0)

See merge request espressif/esp-idf!9320
2020-06-28 20:22:26 +08:00
e9dcba0d5d Merge branch 'docs/spi' into 'release/v4.0'
Fixed a typo according to DOC-216

See merge request espressif/esp-idf!9133
2020-06-28 18:22:29 +08:00
1658838efb Fixed a typo according to DOC-216 2020-06-28 18:22:29 +08:00
b88982b666 esp_flash: fix cache exception when CS pin is through IOMUX 2020-06-28 15:52:58 +08:00
59c1bf4d8f esp_flash: fix the cleanup when add device fails 2020-06-28 15:52:58 +08:00
aa5b4fb372 esp_flash: fix the regression of non-quad mode by default chip driver 2020-06-28 15:52:58 +08:00
67d7b60f19 websocket client: the client now aborts the connection if send fails.
Closes IDF-1744
2020-06-28 02:12:35 +00:00
28b4419c4e Merge branch 'bugfix/export_path_checks_v4.0' into 'release/v4.0'
tools: export.sh: better detection and checking of IDF_PATH (backport v4.0)

See merge request espressif/esp-idf!8748
2020-06-26 22:18:06 +08:00
e933077fbc esp_http_server: Update LRU counter on accepting a new connection
Closes https://github.com/espressif/esp-idf/issues/3851
2020-06-26 19:25:15 +05:30
a68b9272c5 Merge branch 'bugfix/idf_py_help_env_var_v4.0' into 'release/v4.0'
Tools: Mention ESPPORT and ESPBAUD in idf.py --help (v4.0)

See merge request espressif/esp-idf!9292
2020-06-26 14:43:02 +08:00
ae177f7077 static analysis: Apply current limits of known defects on v4.0 2020-06-25 06:16:14 +00:00
a9d4ed4a55 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-06-24 22:25:20 +05:30
lly
939a3b78e2 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-24 10:33:58 +00:00
lly
f1c0fee05b 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-06-24 10:31:25 +00:00
lly
268b0e5e3f ble_mesh: Remove boolean type definitions 2020-06-24 09:12:31 +00:00
940fcf0ca9 ble_mesh: Do not #define bool when compiling in C++ 2020-06-24 09:12:31 +00:00
lly
c6ce7d2866 ble_mesh: stack: Check model status with variable length 2020-06-24 09:10:32 +00:00
lly
b4554ca2a6 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-06-24 09:08:18 +00:00
9b3aae1d32 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-24 10:37:51 +02:00
0785d41c93 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
2020-06-24 10:37:17 +02:00
9624d9b19b Tools: Mention ESPPORT and ESPBAUD in idf.py --help
Closes https://github.com/espressif/esp-idf/issues/5461
2020-06-24 10:19:37 +02:00
4f22be795d Merge branch 'bugfix/python_lint_v4.0' into 'release/v4.0'
tools: fix python lint (v4.0)

See merge request espressif/esp-idf!9301
2020-06-24 16:05:54 +08:00
b53c59b7a4 tools: fix python lint 2020-06-24 13:22:21 +08:00
e37cb829f4 Merge branch 'feature/pyc_clean_v4.0' into 'release/v4.0'
tools/idf.py: Clean Python bytecode files (v4.0)

See merge request espressif/esp-idf!9264
2020-06-24 12:30:48 +08:00
2967334138 Merge branch 'bugfix/sleep_comments_v4.0' into 'release/v4.0'
doc: Specify that sleep wakeup source restrictions apply to all current ESP32 revisions (v4.0)

See merge request espressif/esp-idf!8568
2020-06-23 01:45:29 +08:00
0de2507b24 tools/idf.py: Clean Python bytecode files 2020-06-22 10:44:26 +02:00
8c3a3766da Merge branch 'bugfix/att_buffer_count_fixed_v4.0' into 'release/v4.0'
Bugfix/att buffer count fixed v4.0

See merge request espressif/esp-idf!9159
2020-06-22 11:45:10 +08:00
26e280c824 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:49:11 +08:00
3c630c7905 Merge branch 'bugfix/efuse_logs_v4.0' into 'release/v4.0'
esp32: Reduce using ESP_EARLY_LOGx and move some code after the stdout initialization in startup code (v4.0)

See merge request espressif/esp-idf!9207
2020-06-18 15:15:57 +08:00
35f5cbaed4 docs:perfect 128-bit UUID description
The previous description is not easy for the reader to understand, some changees have been made to perfect it.
Closes https://github.com/espressif/esp-idf/issues/5057
2020-06-18 15:08:57 +08:00
b869e69c62 components/bt: Consider link_xmit_data_q in congest events to prevent excessive memory usage 2020-06-18 15:02:02 +08:00
12759b951c components/bt: Fixed the problem of incomplete data packets caused by disordered acl data packets 2020-06-18 15:01:24 +08:00
d875485f89 components/bt: Add a detailed description for the user to distinguish the function of the query buffer api. 2020-06-18 15:01:18 +08:00
ac2e34f611 Update the limited of function esp_ble_get_sendable_packets_num. 2020-06-18 15:01:13 +08:00
211e7bb4c2 components/bt: Add api to query the number of available buffers for the current connection 2020-06-18 15:01:05 +08:00
47fa80f7fe Merge branch 'bugfix/blufi_buffer_overflow_report_v4.0' into 'release/v4.0'
blufi: When the format of the received data packet is wrong, reply with an error response(backport 4.0)

See merge request espressif/esp-idf!9199
2020-06-18 13:45:17 +08:00
4a6e793322 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 16:30:11 +08:00
458ed4085d feat(lwip): make LWIP TCP rto time configurable 2020-06-17 15:32:59 +08:00
e781279110 blufi: When the format of the received data packet is wrong, reply with an error response 2020-06-17 12:20:53 +08:00
94d97499a3 Merge branch 'bugfix/wpa3_ble_coex_issue_4.0' into 'release/v4.0'
Fix WPA3 Auth timeout issue during BLE coex (Backport v4.0)

See merge request espressif/esp-idf!9140
2020-06-16 14:37:55 +08:00
6778712be4 Merge branch 'bugfix/softap_prov_session_v4.0' into 'release/v4.0'
protocomm_httpd: Restart security session if request is received on a new session (v4.0)

See merge request espressif/esp-idf!9117
2020-06-16 12:33:15 +08:00
18d7f27f6c esp_wifi: Update wifi lib
Fix WPA3 Auth timeout issue during BLE coex
2020-06-15 22:49:20 +08:00
e7ac221b42 Merge branch 'bugfix/authmode_degrade_fix_v4.0_1' into 'release/v4.0'
esp_wifi: Update wifi_lib pointer to correct branch

See merge request espressif/esp-idf!9126
2020-06-15 14:33:05 +08:00
b58e777596 Merge branch 'bugfix/fix_dac_driver_self_contained' into 'release/v4.0'
driver(dac): fix dac header file self contained issue

See merge request espressif/esp-idf!8546
2020-06-15 12:15:32 +08:00
0265c63e6c esp_wifi: Update wifi_lib pointer to correct branch
Correct wifi_lib pointer pointing to incorrect branch due to
auth_changed event MR.
2020-06-15 08:57:58 +05:30
4f29dfa969 Merge branch 'bugfix/doc_build_ut_cmdline_v4.0' into 'release/v4.0'
docs: Fixup format of a command line to build unit tests (backport v4.0)

See merge request espressif/esp-idf!9044
2020-06-15 02:43:02 +08:00
8357318945 driver(dac): fix dac header file self contained issue
Closes https://github.com/espressif/esp-idf/issues/2560
2020-06-12 05:36:56 +00:00
83d6ab9b5f msys2: Remove python version consideration in pacman commands 2020-06-12 10:24:29 +10:00
a972d3018c windows: Update MSYS2 pre-compiled legacy build environment
* Bundled with esp2020r2 toolchain
* Built with Python 3 & latest MSYS2 packages
2020-06-12 10:24:29 +10:00
02a53166b6 Merge branch 'bugfix/parttool_get_info_wo_info_option_v4.0' into 'release/v4.0'
partition_table: Fix parttool.py crashes when retrieving partition info (v4.0)

See merge request espressif/esp-idf!9064
2020-06-10 15:57:41 +08:00
f677655fcb 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-10 01:25:53 +05:30
6932b4d1c0 freemodbus: add comments for limitation in current version of freemodbus 2020-06-08 08:39:49 +02:00
ccdd06937f Merge branch 'feature/pin_ethernet_task_to_core_v4.0' into 'release/v4.0'
ethernet: support pin emac task to core (v4.0)

See merge request espressif/esp-idf!9038
2020-06-08 13:47:07 +08:00
f16a37d439 Merge branch 'bugfix/fix_fifo_cnt_bug_v4.0' into 'release/v4.0'
bugfix(uart): fix esp32 uart fifo_cnt bug(backport v4.0)

See merge request espressif/esp-idf!9041
2020-06-08 13:25:58 +08:00
a864e3dcfe Merge branch 'bugfix/authmode_degrade_fix_v4.0' into 'release/v4.0'
esp_wifi: Remove auth_changed event and fix wpa2_ent authmode threshold (backport 4.0)

See merge request espressif/esp-idf!8806
2020-06-08 11:22:10 +08:00
ef8613b7f7 Merge branch 'bugfix/sdmmc_check_slot_before_pullup_4.0' into 'release/v4.0'
sdmmc: Correctly check function parameters before using them (4.0)

See merge request espressif/esp-idf!9056
2020-06-08 10:24:59 +08:00
d008eba708 esp_wifi: Remove auth_changed event and fix wpa2 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-07 10:55:02 +05:30
b76773d943 Merge branch 'bugfix/httpd_lru_purge_v4.0' into 'release/v4.0'
esp_http_server: Fixed a bug which could cause issues with LRU purge (v4.0)

See merge request espressif/esp-idf!8833
2020-06-05 18:38:33 +08:00
ad95174a7a 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-06-05 09:24:06 +00:00
1ad7e276d9 Merge branch 'workaround/wps_iot_fixes_v4.0' into 'release/v4.0'
wpa_supplicant: WPS Inter operatability Fixes( backport v4.0)

See merge request espressif/esp-idf!8951
2020-06-05 13:50:27 +08:00
2f51b520c6 Merge branch 'bugfix/wpa_supplicant_no_hw_mpi_v4.0' into 'release/v4.0'
wpa_supplicant: Allow building with mbedTLS integration but no hardware MPI (v4.0)

See merge request espressif/esp-idf!9014
2020-06-04 18:24:07 +08:00
84d6d48fe0 wpa_supplicant: Allow building with mbedTLS integration but no hardware MPI
Closes https://github.com/espressif/esp-idf/issues/5321
2020-06-04 18:32:58 +10:00
51bb86f0a6 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:26 +08:00
7eaea6c726 sdmmc: Correctly check function parameters before using them
Closes https://github.com/espressif/esp-idf/pull/5000
2020-06-04 12:01:59 +08:00
9746fa569c 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-06-03 13:33:49 +00:00
40385ea454 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-06-03 13:33:49 +00:00
d96d68ea38 ethernet: support pin emac task to core 2020-06-03 19:54:22 +08:00
9718338984 Merge branch 'bugfix/ble_mesh_remove_relay_dependency_v4.0' into 'release/v4.0'
ble_mesh: Remove relay option dependency (v4.0)

See merge request espressif/esp-idf!9027
2020-06-03 15:20:51 +08:00
5a61c4c24c Merge branch 'bugfix/ble_mesh_example_nvs_store_v4.0' into 'release/v4.0'
Bugfix/ble mesh example nvs store (v4.0)

See merge request espressif/esp-idf!9017
2020-06-03 15:12:17 +08:00
ceffc0837e Merge branch 'bugfix/ble_mesh_model_recv_fix_v4.0' into 'release/v4.0'
Bugfix/ble mesh model recv fix (v4.0)

See merge request espressif/esp-idf!9008
2020-06-03 15:11:32 +08:00
ece24128da Merge branch 'bugfix/ble_mesh_rework_prov_pdu_len_check_v4.0' into 'release/v4.0'
ble_mesh: Rework prov pdu length check (v4.0)

See merge request espressif/esp-idf!9004
2020-06-03 15:10:52 +08:00
7d6bcf5f5e docs: Fixup format of a command line to build unit tests 2020-06-03 12:17:36 +07:00
f75088d40d bugfix(uart): fix esp32 uart 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-03 12:29:06 +08:00
lly
19f69333f7 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-06-02 19:18:52 +08:00
695ad84654 Merge branch 'bugfix/fix_some_wifi_bugs_0522_v4.0' into 'release/v4.0'
feature: optimize some wifi API (backport v4.0)

See merge request espressif/esp-idf!8878
2020-06-02 17:39:15 +08:00
lly
1636c2ba6b 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-06-02 14:04:37 +08:00
lly
db2376bb09 ble_mesh: Add mesh example common nvs operations 2020-06-02 14:04:36 +08:00
lly
b55020ad80 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-06-02 14:04:35 +08:00
lly
1ac6d48fcf ble_mesh: Add more checks of net_idx & app_idx 2020-06-02 14:04:35 +08:00
lly
268f5ad6c6 ble_mesh: Optimize some send & recv logs 2020-06-02 14:04:34 +08:00
1ab23bfd3d Merge branch 'bugfix/ble_mesh_local_model_sub_v4.0' into 'release/v4.0'
Bugfix/ble mesh local model sub (v4.0)

See merge request espressif/esp-idf!8984
2020-06-02 10:58:40 +08:00
lly
205425b86b ble_mesh: correct the return type [Zephyr] 2020-06-02 10:32:25 +08:00
lly
c2589b0b57 ble_mesh: Add net_buf_simple_init_with_data [Zephyr] 2020-06-02 10:32:24 +08:00
lly
f990d725f4 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-06-02 10:32:23 +08:00
lly
073b8daa6e ble_mesh: Rework prov pdu length check 2020-06-02 10:14:50 +08:00
6a844f3737 Merge branch 'bugfix/kconfig_hex_values_v4.0' into 'release/v4.0'
kconfig: Fix two cases of hex values being handled incorrectly (v4.0)

See merge request espressif/esp-idf!8788
2020-06-01 14:48:16 +08:00
b571992626 feature: optimize some wifi API
1. optimization esp_wifi_set_max_tx_power description
2. Add API esp_wifi_ap_get_sta_aid
2020-06-01 11:07:49 +08:00
lly
cd40f3ad52 ble_mesh: Local model (un)subscribes group address 2020-06-01 09:11:27 +08:00
lly
11cfb44e58 ble_mesh: Define a macro for invalid company id 2020-06-01 09:11:26 +08:00
c00fe4c53c Merge branch 'bugfix/wpa3_auth_coex_issue_v4.0' into 'release/v4.0'
Fix WPA3 Auth issue in coex scenario (backport v4.0)

See merge request espressif/esp-idf!8838
2020-05-29 18:05:43 +08:00
64114efdaf Merge branch 'bugfix/ci_push_to_github_on_label_v4.0' into 'release/v4.0'
ci: Don't push to Github or deploy docs on customized pipelines (v4.0)

See merge request espressif/esp-idf!8938
2020-05-29 14:04:26 +08:00
569575b404 Merge branch 'bugfix/fix_spi_flash_clock_config_error_v4.0' into 'release/v4.0'
flash: fix spi flash clock config error (backport v4.0)

See merge request espressif/esp-idf!8515
2020-05-29 12:46:04 +08:00
2f15eacdeb Merge branch 'bugfix/heap_psram_fill_v4.0' into 'release/v4.0'
heap: Only fill new heaps with FREE_FILL_PATTERN if Comprehensive poisoning is on (v4.0)

See merge request espressif/esp-idf!8491
2020-05-29 12:43:45 +08:00
193e9c0d5a Merge branch 'bugfix/add_so_linger_to_menuconfig_for_4.0' into 'release/v4.0'
lw-ip:add so linger to menuconfig for 4.0(backport4.0)

See merge request espressif/esp-idf!8759
2020-05-29 11:15:26 +08:00
5c2ed3af0e Merge branch 'bugfix/fix_memleak_in_wpa3_feature_v4.0' into 'release/v4.0'
fix(wpa_supplicant): fix memleak in wpa3 feature (backport v4.0)

See merge request espressif/esp-idf!8655
2020-05-29 11:14:36 +08:00
6b5c89b684 Merge branch 'bugfix/ble_mesh_check_timer_init_v4.0' into 'release/v4.0'
ble_mesh: Check the result of creating timer (v4.0)

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

See merge request espressif/esp-idf!8795
2020-05-28 15:24:45 +08:00
lly
792605e8fd ble_mesh: Check the result of creating timer 2020-05-28 10:27:25 +08:00
59e11421bf Merge branch 'bugfix/ble_mesh_sync_zephyr_fixes_v4.0' into 'release/v4.0'
Bugfix/ble mesh sync zephyr fixes (v4.0)

See merge request espressif/esp-idf!8949
2020-05-28 10:16:52 +08:00
a90e8d67e9 Merge branch 'bugfix/ble_mesh_not_use_same_private_key_v4.0' into 'release/v4.0'
ble_mesh: Not using pre-initialized private key (v4.0)

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

See merge request espressif/esp-idf!8943
2020-05-28 10:13:44 +08:00
9e21c09a11 esp_wifi: Update wifi lib
Fix WPA3 Auth issue in coex scenario
2020-05-27 19:44:39 +05:30
lly
63c83730c2 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:45:55 +08:00
lly
f781c6edac 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:45:49 +08:00
lly
7078065980 ble_mesh: Not using pre-initialized private key 2020-05-27 17:39:35 +08:00
lly
a8afd951dc ble_mesh: Same func for storing/restoring comp data 2020-05-27 17:31:01 +08:00
652e5352ee Merge branch 'bugfix/ble_mesh_uses_deprecated_config_v4.0' into 'release/v4.0'
ble_mesh: Fix using old config for duplicate scan (v4.0)

See merge request espressif/esp-idf!8901
2020-05-27 17:24:26 +08:00
2ea5f522f3 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:06:30 +10:00
20c34cac2d Merge branch 'bugfix/fix_some_wifi_bugs_0427_v4.0' into 'release/v4.0'
Bugfix/fix some wifi bugs 0427 (v4.0)

See merge request espressif/esp-idf!8571
2020-05-27 14:45:04 +08:00
e0a70b0675 flash: fix spi flash clock config error
Closes https://github.com/espressif/esp-idf/issues/5099
2020-05-27 04:38:40 +00:00
90eccf7cba Merge branch 'ci/test_jobs_v4.0' into 'release/v4.0'
ci: Increase target test runnner count

See merge request espressif/esp-idf!8930
2020-05-27 10:10:12 +08:00
d1107a5234 ci: Increase target test runnner count 2020-05-27 11:17:52 +10:00
43c32f878a Merge branch 'bugfix/ci_partition_table_detection_v4.0' into 'release/v4.0'
CI: Fix partition table detection if "partition" is in the project name (v4.0)

See merge request espressif/esp-idf!8432
2020-05-27 07:51:54 +08:00
6059992efd Merge branch 'feature/ldgen_output_determinism_v4.0' into 'release/v4.0'
ldgen: determinism in mapping rule order (v4.0)

See merge request espressif/esp-idf!8663
2020-05-27 07:50:11 +08:00
90f6c9652e Merge branch 'doc/openocd_security_features_v4.0' into 'release/v4.0'
doc: Add caveats about using JTAG debugging with hardware security features (v4.0)

See merge request espressif/esp-idf!8464
2020-05-27 07:49:44 +08:00
fa527dc6b3 Merge branch 'bugfix/make_to_cmake_msys_py3_v4.0' into 'release/v4.0'
tools: Make Unicode from subprocess result in the CMake convert script (v4.0)

See merge request espressif/esp-idf!8544
2020-05-27 07:49:34 +08:00
e93405c3a7 Merge branch 'bugfix/heap_trace_invalid_addr_v4.0' into 'release/v4.0'
heap: fix backtrace termination (v4.0)

See merge request espressif/esp-idf!8420
2020-05-27 07:49:01 +08:00
1d7765eeea Merge branch 'bugfix/ci_unterminated_sdkconfig_defaults_v4.0' into 'release/v4.0'
CI: Add EOL to sdkconfig.defaults before adding sdkconfig.ci (v4.0)

See merge request espressif/esp-idf!8457
2020-05-27 07:48:43 +08:00
798cc4deb7 Merge branch 'bugfix/pthread_tcb_cleanup_wrapper_v4.0' into 'release/v4.0'
Fix linking for vPortCleanUpTCB wrapper (v4.0)

See merge request espressif/esp-idf!8702
2020-05-26 11:48:42 +08:00
254967eea5 Merge branch 'bugfix/wifi_prov_not_stopping_v4.0' into 'release/v4.0'
wifi_provisioning: Catch the Wi-Fi events even after Connection errors (v4.0)

See merge request espressif/esp-idf!8608
2020-05-26 11:48:15 +08:00
457e1160bc Merge branch 'task/update_idf_version_v401' into 'release/v4.0'
version: Update to v4.0.1

See merge request espressif/esp-idf!8887
2020-05-26 07:38:09 +08:00
d6a2f9841d Merge branch 'feature/config_mqtt_task_prio_v4.0' into 'release/v4.0'
esp_mqtt: configure task priority, esp_mqtt_abort_connection race condition, clenaup logs and docs (v4.0)

See merge request espressif/esp-idf!8473
2020-05-26 03:37:13 +08:00
d9f4cb89a4 Merge branch 'bugfix/ws_client_fragmented_send_v4.0' into 'release/v4.0'
ws_client: fix fragmented send setting proper opcodes (v4.0)

See merge request espressif/esp-idf!8691
2020-05-25 17:19:42 +08:00
76d79dff7c Merge branch 'bugfix/ipv6_examples_4.0' into 'release/v4.0'
socket-examples: IPv6 related update for examples to set correct scoped id (v4.0)

See merge request espressif/esp-idf!8582
2020-05-25 17:18:59 +08:00
lly
9d5ea68c61 ble_mesh: Fix using old config for duplicate scan 2020-05-25 16:54:03 +08:00
1ab129891a Merge branch 'bugfix/erase_with_vtaskdelay_v4.0' into 'release/v4.0'
spi_flash: Add vTaskDelay while a long erasing (v4.0)

See merge request espressif/esp-idf!8599
2020-05-25 14:29:26 +08:00
a748457a70 version: Update to v4.0.1 2020-05-25 14:05:55 +10:00
15916dfbec add LINGER to menuconfig 2020-05-25 11:31:38 +08:00
c18ffa8604 Merge branch 'example/ble_mesh_structural_adjust_v4.0' into 'release/v4.0'
Example/ble mesh structural adjust (v4.0)

See merge request espressif/esp-idf!8871
2020-05-22 19:14:58 +08:00
57932baef3 Merge branch 'bugfix/ble_mesh_provisioner_fail_to_pub_v4.0' into 'release/v4.0'
ble_mesh: Fix Provisioner failed to publish (v4.0)

See merge request espressif/esp-idf!8874
2020-05-22 19:14:26 +08:00
4c5fd2be70 Merge branch 'bugfix/ble_mesh_friend_init_flag_v4.0' into 'release/v4.0'
Bugfix/ble mesh friend init flag (v4.0)

See merge request espressif/esp-idf!8869
2020-05-22 19:13:42 +08:00
7a60ae4bc8 Merge branch 'bugfix/ble_mesh_remove_patch_v4.0' into 'release/v4.0'
ble_mesh: Remove patch for the bug of an App (v4.0)

See merge request espressif/esp-idf!8868
2020-05-22 19:13:24 +08:00
7f049cd5dc Merge branch 'bugfix/ble_mesh_fix_typos_v4.0' into 'release/v4.0'
ble_mesh: Fix typos (v4.0)

See merge request espressif/esp-idf!8867
2020-05-22 19:13:05 +08:00
lly
699270e09e ble_mesh: Fix Provisioner failed to publish 2020-05-22 15:48:49 +08:00
lly
59187b0921 ble_mesh: Fix tutorial links in examples README.md 2020-05-22 14:30:12 +08:00
lly
ec6ebf7d4e ble_mesh: Rename esp_fast_prov_* to ble_mesh_fast_prov_* 2020-05-22 14:30:05 +08:00
lly
bcc1eb916b ble_mesh: Rename the folders ble_mesh_fast_prov_* to fast_prov_* 2020-05-22 14:28:38 +08:00
lly
9891045018 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 14:22:39 +08:00
lly
009878f02d ble_mesh: Move the example init to the common_components 2020-05-22 14:21:43 +08:00
ee51d336d3 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-22 06:21:25 +00:00
d7310ae008 esp_mqtt: add option to configure mqtt task priority.
Merges https://github.com/espressif/esp-idf/pull/4947
2020-05-22 06:21:25 +00:00
lly
8bbee15932 ble_mesh: Move the button component to common_components 2020-05-22 14:20:56 +08:00
lly
d15735c71f ble_mesh: Change the EXTRA_COMPONENT_DIRS used by examples 2020-05-22 14:20:41 +08:00
lly
b63abd2069 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 14:20:21 +08:00
acf1478a51 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-22 06:19:49 +00:00
55dd3c8b77 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:11:44 +00:00
7b01509b19 Merge branch 'bugfix/stop_mac_can_be_controlled_by_user_v4.0' into 'release/v4.0'
Bugfix/stop mac can be controlled by user v4.0

See merge request espressif/esp-idf!8762
2020-05-22 14:07:48 +08:00
754f59fba7 spi_flash(new driver): Add a Kconfig option - Bypass a block erase and always do sector erase
Closes: IDF-1561
2020-05-22 05:07:20 +00:00
9926b875d8 spi_flash(LEGACY_IMPL): Add a Kconfig option - Bypass a block erase and always do sector erase
Closes: IDF-1561
2020-05-22 05:07:20 +00:00
79831e64fd spi_flash: Add into sim/stubs the esp_timer 2020-05-22 05:07:20 +00:00
a128eae7b8 spi_flash(new driver): Add vTaskDelay while a long erasing 2020-05-22 05:07:20 +00:00
98ac272a3f 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-22 05:07:20 +00:00
lly
13167a7579 ble_mesh: Clear two more vars during proxy server deinit 2020-05-22 11:39:51 +08:00
lly
acf41f93a9 ble_mesh: Add missing sdkconfig.h 2020-05-22 11:39:51 +08:00
lly
470c959b04 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-22 11:39:50 +08:00
lly
dd7c98d6c2 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-22 11:39:49 +08:00
lly
90aa79fd2b ble_mesh: Remove patch for the bug of an App 2020-05-22 11:37:30 +08:00
lly
97c1a4b5c6 ble_mesh: Fix typos 2020-05-22 11:34:07 +08:00
5897354d7f Merge branch 'bugfix/sync_zephyr_bt_mesh_bugfix_v4.0' into 'release/v4.0'
Bugfix/sync zephyr bt mesh bugfix (v4.0)

See merge request espressif/esp-idf!8853
2020-05-22 10:50:39 +08:00
6c99fdceb2 Merge branch 'bugfix/ble_mesh_node_old_version_to_new_v4.0' into 'release/v4.0'
ble_mesh: Fix mesh node device role restore (v4.0)

See merge request espressif/esp-idf!8854
2020-05-22 10:50:09 +08:00
1340e600c2 Merge branch 'doc/ble_mesh_fix_v4.0' into 'release/v4.0'
ble_mesh: Doc miscellaneous fixes (v4.0)

See merge request espressif/esp-idf!8859
2020-05-22 10:49:39 +08:00
lly
cdd35648b7 ble_mesh: Doc miscellaneous fixes
- Update ble mesh architecture
2020-05-21 17:48:21 +08:00
6fe46c1798 Merge branch 'bugfix/timer_group_intr_enable_v4.0' into 'release/v4.0'
Fix timer group intr enable (backport v4.0)

See merge request espressif/esp-idf!8530
2020-05-21 17:42:02 +08:00
lly
d2bcb5c7ff ble_mesh: A specific fix for compile warning in idf4.0
Compared with the latest idf, idf4.0 defines BIT(nr) in
the "esp_bit_defs.h" without the pre-condition "#ifndef BIT",
which will cause compile warning when using mesh. So we
include the header file "soc/soc.h" in "mesh_util.h",
which can bypass the definition of "BIT" in "mesh_util.h"
when compiling.
2020-05-21 16:50:09 +08:00
lly
2ea69e6df5 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-21 15:26:50 +08:00
lly
b5bd1bf67e 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-21 15:22:21 +08:00
lly
8294055c65 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-21 15:22:21 +08:00
lly
11286e35a2 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-21 15:22:20 +08:00
lly
2c5b0a523a 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-21 15:22:19 +08:00
lly
8c6f6318c0 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-21 15:22:18 +08:00
lly
632d9739b5 ble_mesh: Optimize some mesh log output 2020-05-21 15:22:18 +08:00
lly
34cb56b7aa ble_mesh: Fix restore when revoke keys [Zephyr]
Store keys (NetKey and AppKey) again after revoking.
2020-05-21 15:22:17 +08:00
lly
7c12074801 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-21 15:22:16 +08:00
lly
4b21a34675 ble_mesh: Split mesh os related into a separate file 2020-05-21 15:22:13 +08:00
lly
ac51ec11ec ble_mesh: Split mesh mutex into a separate file 2020-05-21 15:19:52 +08:00
lly
7db10be193 ble_mesh: Rename mesh_kernel.* to mesh_timer.* 2020-05-21 15:19:51 +08:00
lly
fde075aec2 ble_mesh: Add and use transport macro definitions [Zephyr] 2020-05-21 15:19:51 +08:00
lly
cbd2bcfbd2 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-21 15:19:50 +08:00
lly
5c5621790a 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-21 15:19:49 +08:00
lly
fbdb7ff665 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-21 15:19:49 +08:00
lly
bbfaaa2044 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-21 15:19:48 +08:00
lly
ad14507e3f 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-21 15:19:47 +08:00
lly
c9d1255ce4 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-21 15:19:46 +08:00
lly
25569cd9de ble_mesh: Add PRIu64 & PRIx64 in mesh_types.h 2020-05-21 15:19:46 +08:00
lly
416e8958fa ble_mesh: Add push functions for supported bit-variants [Zephyr]
Add push functions for bit-widths supported by add and pull functions.
2020-05-21 15:19:45 +08:00
lly
cde1592bf3 ble_mesh: Add support for 64 bit data type [Zephyr]
This enables pulling and pushing values in 64 bit format.
2020-05-21 15:19:44 +08:00
lly
0af05fdee1 ble_mesh: Add support for 48 bit data type [Zephyr]
This enables pulling and pushing values in 48 bit format.
2020-05-21 15:19:44 +08:00
lly
4536a485be ble_mesh: Add 48 bit variants [Zephyr]
This adds sys_*_*48 functions that operation on a 48 bits values.
2020-05-21 15:19:43 +08:00
lly
e7d37f2d1a ble_mesh: Add support for 24 bit data type [Zephyr]
This enables pulling and pushing values in 24 bit format.
2020-05-21 15:19:42 +08:00
lly
fd17ff2f0b ble_mesh: Add 24 bit variants [Zephyr]
This adds sys_*_*24 functions that operation on a 24 bits values.
2020-05-21 15:19:41 +08:00
lly
e322c5950b 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-21 15:19:41 +08:00
lly
1f96a6f35d 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-21 15:19:40 +08:00
lly
4fddf1156b 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-21 15:19:39 +08:00
lly
833483bb22 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-21 15:19:39 +08:00
lly
3d4948664b ble_mesh: Check device uuid when init provisioning 2020-05-21 15:19:38 +08:00
lly
203f871420 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-21 15:19:37 +08:00
lly
2c6a3f9e5b 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-21 15:19:36 +08:00
lly
2b6131b5f4 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-21 15:19:36 +08:00
793d2b11f1 Merge branch 'bugfix/ble_mesh_not_ignore_msg_in_fast_prov_v4.0' into 'release/v4.0'
ble_mesh: Not ignore msg when fast prov is enabled (v4.0)

See merge request espressif/esp-idf!8711
2020-05-21 15:16:08 +08:00
bbc95d981c Merge branch 'bugfix/ble_mesh_use_sdkconfig_ci_v4.0' into 'release/v4.0'
ble_mesh: Add bluedroid and nimble example configurations (v4.0)

See merge request espressif/esp-idf!8499
2020-05-21 15:14:45 +08:00
471171cb32 Merge branch 'feat/ble_mesh_sensor_model_example_v4.0' into 'release/v4.0'
ble_mesh: Add ble mesh sensor model examples (v4.0)

See merge request espressif/esp-idf!8508
2020-05-21 15:14:22 +08:00
3b4ff12246 Merge branch 'bugfix/ble_mesh_compile_error_o2_v4.0' into 'release/v4.0'
ble_mesh: Fix compile error when -O2 (performance) is chosen (v4.0)

See merge request espressif/esp-idf!8617
2020-05-21 15:13:56 +08:00
351dba9272 Merge branch 'bugfix/ble_mesh_provisioner_check_key_v4.0' into 'release/v4.0'
ble_mesh: Check if appkey exist before deleting it (v4.0)

See merge request espressif/esp-idf!8620
2020-05-21 15:13:31 +08:00
7b6236c2d9 Merge branch 'bugfix/ble_mesh_node_reset_erase_v4.0' into 'release/v4.0'
ble_mesh: Fix node not erase info completely (v4.0)

See merge request espressif/esp-idf!8623
2020-05-21 15:12:21 +08:00
1ce4c20115 Merge branch 'bugfix/fix_gpio_wake_up_disable_invalid_for_rtc_io_v4.0' into 'release/v4.0'
bugfix (GPIO): fixed gpio_wake_up_disable not working for RTC IO (release/4.0)

See merge request espressif/esp-idf!7996
2020-05-21 11:39:39 +08:00
lly
3e885dc73b ble_mesh: Add bluedroid and nimble example configurations 2020-05-20 11:25:07 +00:00
lly
c85d7dfd5a ble_mesh: Add ble mesh sensor model examples 2020-05-20 10:51:55 +00:00
lly
9a654ec590 ble_mesh: Add some common macros for sensor model 2020-05-20 10:51:55 +00:00
lly
193828f121 ble_mesh: Allow empty sensor series column value 2020-05-20 10:51:55 +00:00
lly
fab2dcb790 ble_mesh: Check if same sensor (settings) property id exists 2020-05-20 10:51:55 +00:00
lly
d3619d0b45 ble_mesh: Allow empty sensor settings exist 2020-05-20 10:51:55 +00:00
5af06f49f5 NimBLE: Include upstream fixes and use macros for log level filtering (backport v4.0)
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:19:55 +05:30
e430860df3 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
4. fix the timeout issue of EAPOL four-way handshake
5. fix the crash issue when fetch peer after delete the cur_peer
2020-05-20 18:13:07 +08:00
4c81978a3e Merge branch 'bugfix/doc_version_links_v4.0' into 'release/v4.0'
doc: Fix broken Release page links when building a stable version (v4.0)

See merge request espressif/esp-idf!8821
2020-05-20 13:17:23 +08:00
ddc2427385 esp_wifi:Add softap example channel configuration 2020-05-20 10:59:04 +08:00
6153026f22 doc: Fix broken Release page links when building a stable version 2020-05-20 11:32:53 +10:00
18abdd7cb0 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:37 +10:00
260fe847e2 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:02:37 +10:00
fc2199c5d6 Merge branch 'bugfix/wpa3_mixed_mode_authype_v4.0' into 'release/v4.0'
esp_wifi: Add and utilize WPA3/WPA2 Mixed mode Authtype (backport v4.0)

See merge request espressif/esp-idf!8768
2020-05-17 17:05:15 +08:00
4695eeddee Merge branch 'bufix/fix_v4.0_bluedroid_bugs_mr' into 'release/v4.0'
component/bt: fix notify malloc failed , fix no BLE_AUTH_CMPL_EVT and fix bluedroid btc deinit crash(backport 4.0)

See merge request espressif/esp-idf!8755
2020-05-16 19:53:15 +08:00
65d4596a36 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-15 13:50:47 +00:00
748720a466 esp_wifi: Update WiFi lib
Add and utilize WPA3/WPA2 Mixed mode Authtype
2020-05-15 14:58:07 +05:30
8688bd0593 add LINGER to menuconfig 2020-05-15 17:18:50 +08:00
6ee978c6aa add congest direct callback and fix malloc failed when multi_connection notify performance test 2020-05-15 16:18:31 +08:00
d231b25bc4 fix bta_dm_deinit_cb crash 2020-05-15 16:16:26 +08:00
456c8bdbdf master missing BLE_AUTH_CMPL_EVT after restart 2020-05-15 16:16:26 +08:00
94917184be Merge branch 'bugfix/wpa3_pmf_memleak_fix_v4.0' into 'release/v4.0'
WPA3 / PMF memory leak fixes (backport v4.0)

See merge request espressif/esp-idf!8677
2020-05-15 15:11:44 +08:00
b13d96ae8b ethernet: better control start/stop/uninstall/install 2020-05-14 22:12:42 +08:00
496ab2a83f ethernet: esp_eth_stop API should stop emac hardware 2020-05-14 22:10:37 +08:00
3c882991b5 Merge branch 'bugfix/ethernet_task_watchdog_timeout' into 'release/v4.0'
ethernet: fix potential task watch dog timeout (backport 4.0)

See merge request espressif/esp-idf!8743
2020-05-14 16:21:35 +08:00
4d35a99c12 Merge branch 'nimble/config_option_sdkconfig_rename_v4.0' into 'release/v4.0'
Add NimBLE config options in sdkconfig.rename (v4.0)

See merge request espressif/esp-idf!8736
2020-05-14 16:19:36 +08:00
6442184dd8 ethernet: fix potential task watch dog timeout 2020-05-14 14:23:32 +08:00
02c47360f1 Add NimBLE config options in sdkconfig.rename 2020-05-14 11:31:53 +10:00
db5f01429f 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-13 20:45:34 +05:30
b938846de6 wpa_supplicant: Fix formatting of file esp_wpa3.c
Replace tabs with spaces in esp_wpa3.c.
2020-05-13 20:35:56 +05:30
7d295e18bc Merge branch 'bugfix/fix_switch_channel_without_discon_issue_v4.0' into 'release/v4.0'
esp_wifi: Fix AP switch to adjacent channel without disconnect (backport v4.0)

See merge request espressif/esp-idf!8705
2020-05-13 19:58:22 +08:00
lly
b47111c708 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:50 +08:00
6a6de506b1 Merge branch 'bugfix/supplicant_general_fixes_40' into 'release/v4.0'
wpa_supplicant: Fix some memleaks and invalid memory access (backport v4.0)

See merge request espressif/esp-idf!8553
2020-05-12 20:17:51 +08:00
12a65aaac1 Merge branch 'bugfix/wep40_key_parsing_bug_v4.0' into 'release/v4.0'
wpa_supplicant: Add parsing support for WEP40 key(backport)

See merge request espressif/esp-idf!8684
2020-05-12 20:17:15 +08:00
6bfad8a47d Merge branch 'fixbug/tcp_kill_state_assert_for_v4.0' into 'release/v4.0'
lw-ip:fixbug for tcp kill state assert(backport 4.0)

See merge request espressif/esp-idf!8451
2020-05-12 20:15:45 +08:00
0863de4a69 esp_wifi: Fix AP switch to adjacent channel without disconnect 2020-05-12 17:20:48 +08:00
db3a1110ec pthread: Use INTERFACE in target_link_libraries for vPortCleanUpTCB wrapper 2020-05-12 10:35:47 +05:30
398dc28a4e wpa_supplicant: Add parsing support for WEP40 key
WEP key is passed as ascii key without "", add parsing support
in supplicant for this.
2020-05-11 11:23:10 +05:30
4011393920 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 21:10:19 +08:00
a87df25d9e fix(wpa_supplicant): fix memleak in wpa3 feature 2020-05-08 16:25:38 +08:00
lly
814108f9ac ble_mesh: Add length check for some mesh operations 2020-05-07 09:18:15 +00:00
lly
baf0fb3576 ble_mesh: Fix compile error when -O2 (performance) is chosen 2020-05-07 09:18:15 +00:00
lly
a895bb157f 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-07 09:16:51 +00:00
b0f053d82d Merge branch 'bugfix/get_started_export_profile_v4.0' into 'release/v4.0'
docs: remove suggestion about running export.sh from .profile script (backport v4.0)

See merge request espressif/esp-idf!8614
2020-05-07 12:07:05 +08:00
4242519894 wpa_supplicant: Fix some memleaks and invalid memory access
Add changes to fix issues reported in clang analyzer
2020-05-06 11:06:51 +00:00
b3c3b4e7f0 ethernet: not using latch register to check link 2020-05-06 17:28:18 +08:00
f09c9b957c timer_group: 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-05-06 17:28:18 +08:00
24c9f56d45 Fix typo with sigmadelta.h #ifdef 2020-05-06 17:28:18 +08:00
08bcb587ec Merge branch 'fix/ci_example_test_prov_v4.0' into 'release/v4.0'
CI: Fix prov example test exception handle (v4.0)

See merge request espressif/esp-idf!8440
2020-05-06 16:59:20 +08:00
c5a8dc85b7 Merge branch 'feature/wpa3_pmf_pmk_caching_backport_v4.0' into 'release/v4.0'
WPA3, PMF & PMK caching support (backport v4.0)

See merge request espressif/esp-idf!8625
2020-05-06 15:41:05 +08:00
a7ca14b064 CI: Fix prov example test cryptography package version exception handling 2020-05-06 04:54:59 +00:00
4557c686b8 wpa_supplicant: Fix EAP Re-authentication issue
EAP reauth frames are dropped at various stages due to current
implementation of WPA2 ENT states and EAP SM init/deinit logic.
Route EAPOL frames based on EAP pkt type and maintain EAP SM
to facilitate EAP re-authentication process.
2020-05-06 10:21:45 +05:30
5e33a351f1 esp_wifi: Enable WPA3 & PMF by default 2020-05-06 10:21:41 +05:30
1fc54cfad8 Increase example cmake parallel jobs number 2020-05-06 10:21:29 +05:30
bc7a34b494 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-05-06 10:21:25 +05:30
ab81940982 esp_wifi: Additional changes for WPA3 & PMF testcases
Added WPA3 Testcases support for -
1. Anti-Clogging Token Request support
2. Return correct status from SAE modules for invalid scenarios
3. Add PMK Caching support for WPA3

wifi lib includes fixes for below PMF Certification issues -
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.
2020-05-06 10:20:46 +05:30
6d6b7b09e8 wifi: Add PMF and WPA3 documentation 2020-05-06 10:20:40 +05:30
d36663b798 wpa_supplicant: Support WPA3 4-way handshake, add config option
1. Add changes in 4-way handshake path to allow SAE key mgmt.
2. Support for configuring WAP3 at init time, added Kconfig option.
3. Handle and propagate error conditions properly.
2020-05-06 10:20:35 +05:30
6b76228fcb wpa_supplicant: Add SAE handshake support for WPA3-PSK
Under WPA3-Personal, SAE authentication is used to derive PMK
which is more secure and immune to offline dictionary attacks.
1. Add modules to generate SAE commit/confirm for the handshake
2. Add modules that build and parse SAE data in Auth frames
3. Add WPA3 association and key mgmt definitions
4. Invert y-bit while solving for ECC co-ordinate -
     Once an X co-ordinate is obtained, solving for Y co-ordinate
     using an elliptical curve equation results in 2 possible values,
     Y and (P - Y), where p is the prime number. The co-ordinates are
     used for deriving keys in SAE handshake. As par the 802.11 spec
     if LSB of X is same as LSB of Y then Y is chosen, (P - Y) otherwise.
     This is not what is implemented, so fix this behavior to obtain the
     correct Y co-ordinate.
2020-05-06 10:20:26 +05:30
8f5f828ad6 wpa_supplicant: Adding SAE modules with testcase
This change ports SAE(Simultaneous Authentication of Equals)
feature from wpa_supplicant and makes it work with mbedtls
crypto APIs. Currently only group 19 is supported. A sample
SAE handshake is included in the testcase. Other minor
changes for DH groups are also included.
2020-05-06 10:20:22 +05:30
5c5ae96be2 Add encryption/decryption support for PMF
1. Add CCMP, AES crypto modules for unicast protected Mgmt frames
2. Add support for computing SHA256 MIC on Bcast Mgmt frames
3. Add support for storing iGTK during 4-way handshake.
4. Provide APIs to MLME for utilizing the SW crypto modules
2020-05-06 10:20:16 +05:30
1b7f3fee5c Add support for PMF configuration and negotiation
1. Add APIs for configuring PMF through set config.
2. Map Supplicant and Wifi Cipher types.
3. Add support for PMF negotiation while generating RSN IE.
2020-05-06 10:20:11 +05:30
b7dc47108f wifi: Add code required to backport PMK Caching 2020-05-06 10:19:52 +05:30
8cd210b38b esp_wifi/supplicant: fix some WiFi stop memory leak 2020-05-06 10:15:51 +05:30
19e840aa53 wpa_supplicant: Set assoc_ie_len based on generated RSN/WPA IE 2020-05-06 10:15:46 +05:30
39acf9c4dd wifi: Add PMK caching feature for station WPA2-enterprise
4. Pmksa cache expiry after dot11RSNAConfigPMKLifetime timeout.
2020-05-06 10:15:43 +05:30
2da4ffa2aa wifi: Add PMK caching feature for station WPA2-enterprise
1) Added PMK caching module from wpa_supplicant.
2) Modified wpa_sm to
    a) Add entry to PMK cache when first time associated to an AP.
    b) Maintain entry across the associations.
    c) Clear current PMKSA when deauth happens.
    d) Search for an entry when re-associating to the same AP and
       set it as current PMKSA
    e) Wait for msg 1/4 from AP instead of starting EAP authentication.
    f) Check PMKID in msg 1 with current PMKSA/cache.
    g) Use the cached PMK to complete 4-way handshake.
3) Remove config_bss callback as it was redundant and used to cause
   problems for PMK caching flow.

Closes IDF-969
2020-05-06 10:15:36 +05:30
lly
30c645d9c2 ble_mesh: Check if appkey exist before deleting it 2020-05-06 11:39:02 +08:00
b9fa6b0b1a Merge branch 'bugfix/can_not_get_IP_address_from_China_mobile_v4.0' into 'release/v4.0'
wifi: fix the bug that ESP32 can't get IP address from China Mobile router (v4.0)

See merge request espressif/esp-idf!8401
2020-05-06 11:16:24 +08:00
5f71ec3640 Merge branch 'bugfix/ble_mesh_rpl_list_size_v4.0' into 'release/v4.0'
ble_mesh: Associate replay protection list size with nodes count (v4.0)

See merge request espressif/esp-idf!8495
2020-05-06 11:14:21 +08:00
a44f473d4a Merge branch 'doc/ble_mesh_fixes_v4.0' into 'release/v4.0'
doc: Fix some ble mesh description (v4.0)

See merge request espressif/esp-idf!8503
2020-05-06 11:12:57 +08:00
beb64a1af4 Merge branch 'bugfix/ble_mesh_add_missing_cpp_v4.0' into 'release/v4.0'
ble_mesh: Add missing #ifdef __cplusplus (v4.0)

See merge request espressif/esp-idf!8506
2020-05-06 11:12:25 +08:00
7b8356ee2f Merge branch 'bugfix/ble_mesh_time_scene_wrong_name_v4.0' into 'release/v4.0'
ble_mesh: Fix time scene wrong macro name (v4.0)

See merge request espressif/esp-idf!8511
2020-05-06 11:11:00 +08:00
7fbfb1aa03 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:39:30 +02:00
02b5db37d1 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-04-30 15:36:04 +10:00
7f4b651434 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:27 +02:00
lly
b97d4c617b ble_mesh: Fix time scene wrong macro name 2020-04-27 16:26:23 +08:00
lly
765bd76ba3 ble_mesh: Add missing #ifdef __cplusplus 2020-04-27 15:34:14 +08:00
lly
9370264cac doc: Fix some ble mesh description 2020-04-27 15:25:46 +08:00
07c1d9d9c7 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:41:16 +10:00
lly
8bfa01cc28 ble_mesh: Fix client local parameters not initialized 2020-04-27 14:39:40 +08:00
lly
90a9444696 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-27 14:39:40 +08:00
lly
b9fd2673a7 ble_mesh: Remove some redundant functions 2020-04-27 14:39:39 +08:00
lly
7595116353 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-27 14:39:38 +08:00
lly
9aae0f2dee 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-27 14:39:38 +08:00
lly
f137546a4b ble_mesh: Update next alloc address when node info is added 2020-04-27 14:39:37 +08:00
lly
388043c203 ble_mesh: Fix Provisioner provisioning deadlock 2020-04-27 14:39:37 +08:00
lly
c496fa79de 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-27 14:39:36 +08:00
lly
2af16b92e5 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-27 14:39:35 +08:00
8c98f6bdaf 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:34:31 +10:00
c4af9d3e24 CI: Add EOL to sdkconfig.defaults before adding sdkconfig.ci 2020-04-23 16:54:33 +02:00
27da86fb6e fixbug for tcp kill state assert 2020-04-23 16:04:33 +08:00
2d13bfb8fa CI: Fix partition table detection if "partition" is in the project name 2020-04-22 10:05:18 +02:00
81f0744ada test: add a (non-automated) case for backtraces with ROM functions 2020-04-21 11:49:15 +02:00
c3ae910529 heap: recognize 0x40000000 as an address terminating the backtrace
On Xtensa, backtrace can not recover the two most significant bits of
the address, as the window call size is encoded in these bits.
Because of this, __builtin_return_address modifies these MSBs to
match those of the callee, "fixing" the address. An unfortunate side
effect is that the zero return address, which usually terminates the
backtrace, gets converted to 0x40000000. While there is a valid
instruction at this address, its occurrence in the backtrace is
highly unlikely: this is the first instruction of WindowOverflow4
vector, and IDF apps switch VECBASE to an IRAM location very early at
startup.
2020-04-21 11:48:43 +02:00
c955b7d133 Merge branch 'docs/backport_6147' into 'release/v4.0'
backport changes in 6147

See merge request espressif/esp-idf!8101
2020-04-21 14:34:21 +08:00
4131b51c16 Backport changes made in 6147 to release/4.0 2020-04-20 21:47:26 +08:00
1de273a901 Merge branch 'bugfix/error_on_building_in_idf_path_v4.0' into 'release/v4.0'
cmake: Error out when building in IDF_PATH dir (v4.0)

See merge request espressif/esp-idf!8298
2020-04-20 15:04:25 +08:00
2139d40f5e wifi: fix the bug that ESP32 can't get IP address from China Mobile router 2020-04-20 11:18:07 +08:00
44d653adff Merge branch 'bugfix/btdm_backports_v4.0_0328' into 'release/v4.0'
Bugfix/btdm backports v4.0 0328

See merge request espressif/esp-idf!8151
2020-04-16 22:01:39 +08:00
41eabbefd6 Merge branch 'bugfix/coredump_no_ext_stacks_v4.0' into 'release/v4.0'
core dump: don't allow core dumps to Flash if PSRAM is used for stacks (backport v4.0)

See merge request espressif/esp-idf!8229
2020-04-16 15:24:21 +08:00
8972461611 Merge branch 'bugfix/fix_errors_with_mbedtls_disabled_v4.0' into 'release/v4.0'
wpa_supplicant: Fix compilation errors when USE_MBEDTLS is disabled. (v4.0)

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

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

See merge request espressif/esp-idf!8361
2020-04-16 14:29:39 +08:00
f87df26cf4 Merge branch 'bugfix/transport_connection_active_v4.0' into 'release/v4.0'
fix(transport): Fix a bug of the connection whether be active (v4.0)

See merge request espressif/esp-idf!7743
2020-04-16 14:05:24 +08:00
93b8fcf664 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:13:21 +08:00
a78772bbc6 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:06:43 +08:00
1490256968 efuse: 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 20:52:50 +08:00
5209dff76b 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:34:35 +05:30
b7f163530b fix(transport): Fix a bug of the connection whether be active or not by timeout option when the select function return a correct value. 2020-04-15 09:49:03 +00:00
a2d0fb348b Merge branch 'feature/add_rtc_xtal_cal_retry_option_v4.0' into 'release/v4.0'
esp32: Add a Kconfig option - Number of attempts to repeat 32k XTAL calibration (v4.0)

See merge request espressif/esp-idf!7932
2020-04-15 16:09:59 +08:00
fe67bedee2 Merge branch 'nimble/fix_ble_hs_reset_v4.0' into 'release/v4.0'
NimBLE: Reset master and slave states on host reset and fix build failure (backport v4.0)

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

See merge request espressif/esp-idf!8328
2020-04-15 13:26:02 +08:00
cb466be9d9 Merge branch 'bugfix/fix_supplicant_tlsv12_v4.0' into 'release/v4.0'
wpa_supplicant: Fix wpa_supplicant TLS 1.2 issues (v4.0)

See merge request espressif/esp-idf!8204
2020-04-15 13:06:49 +08:00
64061541f0 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:24:26 +00:00
6825d8e0be Merge branch 'bugfix/uart_echo_readme_v4.0' into 'release/v4.0'
example: Remove duplicate commands and invalid serial port information (v4.0)

See merge request espressif/esp-idf!8336
2020-04-13 23:13:01 +08:00
c4fe416f33 Merge branch 'bugfix/backport_some_wifi_bugs_0326_v4.0' into 'release/v4.0'
Bugfix/backport some wifi bugs 0326 (backport v4.0)

See merge request espressif/esp-idf!8309
2020-04-13 22:38:39 +08:00
14c978b54f example: Remove duplicate commands and invalid serial port information
Closes https://github.com/espressif/esp-idf/issues/5049
2020-04-13 15:26:22 +02:00
a6b08cb025 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:52:33 +08:00
acdba0eb46 Merge branch 'feat/ble_mesh_ble_adv_simultaneously_v4.0' into 'release/v4.0'
ble_mesh: Support BLE advertising simultaneously (v4.0)

See merge request espressif/esp-idf!8316
2020-04-10 21:07:42 +08:00
lly
3b5eb3caf5 ble_mesh: Support BLE advertising simultaneously 2020-04-10 17:36:44 +08:00
967e66bdf6 Merge branch 'bugfix/ble_mesh_add_test_function_v4.0' into 'release/v4.0'
ble_mesh: Add ble mesh white list test function (v4.0)

See merge request espressif/esp-idf!8159
2020-04-10 17:29:07 +08:00
0b4e1ecdec 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

3. Fix esp_wifi_stop() crash
   esp_wifi_stop() crashes if it's called when WiFi is not initialized.

4. Fix esp_wifi_stop() leads to memory leak

5. esp_wifi_sta_get_ap_info() returns actual values of group ciphers
2020-04-10 11:18:44 +08:00
fd58809899 Merge branch 'bugfix/esp_event_bugfixes_v4.0' into 'release/v4.0'
esp_event-related fixes (v4.0)

See merge request espressif/esp-idf!8072
2020-04-09 22:11:16 +08:00
ed3ea95cc2 Merge branch 'bugfix/IDFGH-2910_v4.0' into 'release/v4.0'
NVS: bugfix - iterator skipping version 1 blobs (v4.0)

See merge request espressif/esp-idf!8193
2020-04-09 05:45:21 +08:00
3ba480ba53 cmake: error out on building in IDF_PATH root dir 2020-04-08 19:56:57 +08:00
2628f3ebbd Merge branch 'bugfix/cpp_extern_v4.0' into 'release/v4.0'
Add extern C header guards to some files (backport v4.0)

See merge request espressif/esp-idf!8225
2020-04-07 15:39:48 +08:00
0fc72b58e1 NimBLE: Reset master and slave states on host reset and fix build failure (backport v4.0) 2020-04-07 10:41:35 +05:30
cfb331e71b Merge branch 'bugfix/size_calculation_in_ota_v4.0' into 'release/v4.0'
Fix size calculation to erase partition range for OTA image (v4.0)

See merge request espressif/esp-idf!8267
2020-04-06 18:04:11 +08:00
d74995736c 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:51 +05:30
c8a05bae78 Merge branch 'bugfix/nvs_no_throw' into 'release/v4.0'
NVS: Changed all new to new (nothrow) (backport v4.0)

See merge request espressif/esp-idf!7847
2020-04-03 16:38:01 +08:00
127fa7094a Merge branch 'bugfix/gpio_pin_bit_mask_truncation_v4.0' into 'release/v4.0'
driver: fix gpio pin_bit_mask truncation in sdspi_host and others (backport v4.0)

See merge request espressif/esp-idf!8227
2020-04-03 13:28:30 +08:00
ccc6363a21 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:44:47 +02:00
8ffb38265c driver: fix gpio pin_bit_mask truncation in sdspi_host and others
Closes https://github.com/espressif/esp-idf/issues/4348
2020-04-02 23:38:17 +02:00
17bd6e8fab Add missing extern "C" to rtc_cntl.h
Related: https://github.com/espressif/arduino-esp32/issues/3149
2020-04-02 23:36:14 +02:00
192c20c9f7 clk.h: add extern C guards
Closes https://github.com/espressif/esp-idf/issues/4215
2020-04-02 23:22:41 +02:00
c7ac9a296d Added Cpp compatibility for components/spi_flash/include/esp_flash_spi_init.h
Merges https://github.com/espressif/esp-idf/pull/4260
2020-04-02 23:22:10 +02:00
50073a7e61 Merge branch 'nimble/misc_host_flow_ctrl_changes_v4.0' into 'release/v4.0'
NimBLE: Misc fixes in NimBLE host (backport v4.0)

See merge request espressif/esp-idf!7949
2020-04-02 19:43:52 +08:00
f69f96edab Merge branch 'bugfix/btdm_dont_dequeue_the_command_queue_v4.0' into 'release/v4.0'
component/bt: fix don't dequeue the command queue after process the read_by_type_req(backport v4.0)

See merge request espressif/esp-idf!8182
2020-04-01 17:56:05 +08:00
2ee765ffaf Merge branch 'bugfix/secure_boot_ecdsa_config_v4.0' into 'release/v4.0'
secure boot: Ensure mbedTLS enables ECDSA if signatures are checked in app

See merge request espressif/esp-idf!8196
2020-04-01 16:42:47 +08:00
3ed127709e NVS: bugfix - iterator skipping version 1 blobs
Closes https://github.com/espressif/esp-idf/issues/4954
2020-04-01 15:17:14 +08:00
02c5c8d8ad Merge branch 'backport/malloc_zero_return_null_v4.0' into 'release/v4.0'
backport/malloc_zero_return_null_v4.0

See merge request espressif/esp-idf!8145
2020-04-01 14:42:38 +08:00
bdfba3b88c mbedtls: Make ECDHE-PSK config item depend on ECDHE 2020-04-01 16:43:03 +11:00
904b85e365 secure boot: Ensure mbedTLS enables ECDSA if signatures are checked in app
and all ECDSA to be disabled if secure boot is not enabled

Previously if ECDSA disabled in config then secure_boot_signatures.c would
fail to build (whether or not secure boot was enabled).

To avoid breaking apps that might be using the signature scheme with custom OTA
without enabling secure boot signatures in config, this change just disables
this functionality if unavailable in mbedTLS config.

Possible fix for root cause of https://github.com/espressif/esp-idf/pull/3703

Closes https://github.com/espressif/esp-idf/issues/4758
2020-04-01 16:42:41 +11:00
2cc9d28a35 Merge branch 'fix/wifi_provisioning_uuid_v4.0' into 'release/v4.0'
Wifi_provisioning: Change service_uuid to non standard 128 bit UUID and add retries in test script (backport v4.0)

See merge request espressif/esp-idf!8163
2020-04-01 13:04:26 +08:00
50e83cf374 component/bt: fix don't dequeue the command queue after process the read_by_type_req 2020-03-31 16:29:07 +08:00
a3f3c7bdc3 Merge branch 'bugfix/monitor_encrypted_target_v4.0' into 'release/v4.0'
tools: Fix flashing encrypted binaries from IDF Monitor (v4.0)

See merge request espressif/esp-idf!8128
2020-03-31 13:11:02 +08:00
0b822a9ec7 Merge branch 'bugfix/kconfiglib_open_encoding_v4.0' into 'release/v4.0'
tools: Avoid Unicode error in kconfiglib while opening files

See merge request espressif/esp-idf!8082
2020-03-31 11:52:16 +08:00
dfd197b4c5 Wifi_provisioning_mgr_test: Allow three attempts to connect to AP before concluding provisioning failure (v4.0) 2020-03-30 11:22:48 +05:30
1e2ca78aac Wifi_provisioning_ble: Change service_uuid to non standard 128 bit UUID (v4.0)
- Modifies UUIDs in scheme_ble, manager example and esp_prov tool to custom 128
  bit UUID
2020-03-30 11:22:32 +05:30
lly
1d55af4bb2 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-03-30 11:03:00 +08:00
b2a3a9041d components/coex: Fix wakeup delay with DFS 2020-03-28 20:49:15 +08:00
286d249239 components/bt: Fix assert when create conntion cancel 2020-03-28 20:44:43 +08:00
9d5d22c458 multi_heap: ensure that malloc(0) return NULL pointer in any poisoning configuration 2020-03-27 14:30:27 -03:00
13f4656d2a tools: Fix flashing encrypted binaries from IDF Monitor 2020-03-27 10:31:37 +01:00
57a5a486ff Merge branch 'feat/ble_mesh_vnd_model_example_v4.0' into 'release/v4.0'
Feat/ble mesh vnd model example (v4.0)

See merge request espressif/esp-idf!8002
2020-03-27 14:08:22 +08:00
363f55f618 Merge branch 'bugfix/cmake_bugfixes_v4.0' into 'release/v4.0'
CMake-related bugfixes (v4.0)

See merge request espressif/esp-idf!8066
2020-03-26 16:29:45 +08:00
fb14ab08c8 Merge branch 'bugfix/backport_some_wifi_bugs_0323_v4.0' into 'release/v4.0'
esp_wifi: Backport some wifi bugs 0323 (backport v4.0)

See merge request espressif/esp-idf!8087
2020-03-25 15:01:44 +08:00
6ce172bcae Merge branch 'optimization/TCPv6_connect_for_v4.0' into 'release/v4.0'
lw-ip:optimization TCPv6 connect for v4.0

See merge request espressif/esp-idf!8021
2020-03-24 15:25:47 +08:00
d71ac521cf 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,Add wifi stop check at WiFi deinit entry
5,coex adjust scheme when bt is connected status
6,Return fail when setting AP's channel is out of range
7,Fix the bug for setting channel when WiFi in NULL mode
2020-03-24 15:10:31 +08:00
921e56d0c3 Merge branch 'feature/upgrade_mbedtls_to_v4.0' into 'release/v4.0'
mbedtls: upgrade to release v2.16.5 (v4.0)

See merge request espressif/esp-idf!7987
2020-03-24 13:46:34 +08:00
e9fdc4c7b2 tools: Avoid Unicode error in kconfiglib while opening files
This fix is for IDF v4.0 and earlier versions. The upstream kconfiglib
included since IDF v4.1 doesn't have this issue.

Closes https://github.com/espressif/esp-idf/issues/4977
2020-03-23 11:36:10 +01:00
aed56d4da9 esp_event: remove extra line from source file 2020-03-22 21:46:07 +08:00
39e8e2003a esp_event: test that handlers can unregister themselves 2020-03-22 21:45:58 +08:00
b79062aeec esp_event: iterate loop nodes safely as well 2020-03-22 21:45:50 +08:00
66949e3b54 esp_event: fix crash when unregistering a handler instance in itself
When a handler instance is the last one in the list und unregisters
itself, the handler iterator will be invalidated by entering free'd
memory. Same applies for event base and id, if they become empty.

Merges https://github.com/espressif/esp-idf/pull/4139
2020-03-22 21:45:41 +08:00
cb871f0472 Added semi-colon to esp_event_loop_create(...)
Title sums it up.
2020-03-22 21:45:26 +08:00
fbd12902eb cmake: show error message on encrypted flash targets without proper config 2020-03-22 21:09:35 +08:00
35839232c8 cmake: utility to create a failing target 2020-03-22 21:09:23 +08:00
14d6dad650 examples: split source files for one of the ulp examples 2020-03-22 21:09:14 +08:00
7bdb7ee235 ulp: fix ulp external project args
Closes https://github.com/espressif/esp-idf/issues/4713
2020-03-22 21:09:03 +08:00
0f036b8749 ulp: use quotes when specifying files for embedding ulp binaries 2020-03-22 21:07:58 +08:00
7663928e49 ci: add test for partition_table target 2020-03-22 21:04:13 +08:00
365e6ce181 partition_table: output partition table info for partition_table target 2020-03-22 21:04:03 +08:00
7b8aa11e12 Merge branch 'bugfix/modify_ble_mesh_command_for_v4.0' into 'release/v4.0'
ble mesh: update ble mesh console example(backport v4.0)

See merge request espressif/esp-idf!8047
2020-03-22 18:35:15 +08:00
5cbb726028 ble mesh: update ble mesh console example(backport v4.0) 2020-03-22 18:35:12 +08:00
0e70b783ae Merge branch 'bugfix/send_ok_when_sta_disconnect_for_v4.0' into 'release/v4.0'
lw-ip:bugfix for TCPv6 send ok when sta disconnect for v4.0

See merge request espressif/esp-idf!8024
2020-03-21 15:16:01 +08:00
ac302329d1 optimization TCPv6 connect 2020-03-20 15:02:43 +08:00
08f401b74e Merge branch 'bugfix/advanced_https_ota_example_v4.0' into 'release/v4.0'
esp_https_ota in sync with v4.x (backport v4.0)

See merge request espressif/esp-idf!7153
2020-03-20 14:33:53 +08:00
e1d78a218a bugfix for TCPv6 send ok when sta disconnect 2020-03-19 14:06:40 +08:00
13e3e26065 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-18 11:49:23 +00:00
a8e0b9171b 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-18 11:49:23 +00:00
402e97ea51 esp_https_ota.c: Add errno check for WiFi disconnection while performing OTA 2020-03-18 08:19:56 +00:00
0bdd75a344 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-18 08:19:56 +00:00
662b39fc1e OTA: Fixed OTA with chunked servers and added example_test with chunked server 2020-03-18 08:19:56 +00:00
8785ac4c2a Bugfix for failing OTA example
example_test.py is added to test advanced_https_ota_example and native ota_example.

Closes https://github.com/espressif/esp-idf/issues/4394
2020-03-18 08:19:56 +00:00
6627ca40da esp_http_client: fix issue where http parser was not invoking message_complete callback
https://github.com/espressif/esp-idf/issues/2625
https://github.com/espressif/esp-idf/issues/4209
2020-03-18 08:19:56 +00:00
465d517fbd Merge branch 'bugfix/CMake_esp_https_ota_dependencies' into master
components/esp_https_ota: Changes in public requirement list for CMake and esp_ota_ops.h is included in esp_https_ota.c

bootloader_support is added in public requirements of CMake

bootloader_common.h is included in esp_https_ota.h

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

Closes IDFGH-2066
2020-03-18 08:19:56 +00:00
3bdebe2383 esp_https_ota: Added error checking functionalities.
Current implimentation of esp_http_ota does not perform any error-checking in the data writing phase calls `esp_ota_get_next_update_partition()` irrespetive of the received state of the image. A few additional error checking mechanism have now been added inside the esp_https_ota which returns the control in case an invalid header is received and a wrapper to the function `esp_http_client_is_complete_data_received()` of `esp_http_client` has been added.
2020-03-18 08:19:56 +00:00
be08f6f2bb esp_http_client: Add support to check the binary length of the recieved stream and compare it with the size mentioned in the header.
While downloading OTA firmware, if their is a Origin Respnse Timeout or the binary is only partially downloaded, OTA failure is observed. Checking binary size can also be helpful for simple http client applications.

Closes https://github.com/espressif/esp-idf/issues/3004
2020-03-18 08:19:56 +00:00
718af6ed07 Merge branch 'bugfix/ci_handle_retried_jobs_v4.0' into 'release/v4.0'
ci: add find job id argument job status (backport v4.0)

See merge request espressif/esp-idf!7954
2020-03-18 16:02:23 +08:00
233349c235 Merge branch 'bugfix/ble_mesh_nimble_adapt_deinit_v4.0' into 'release/v4.0'
ble_mesh: Fix ble mesh nimble host deinit (v4.0)

See merge request espressif/esp-idf!8005
2020-03-18 12:31:54 +08:00
982e7b5538 Merge branch 'bugfix/sntp_init_can_run_before_net_connection_v4.0' into 'release/v4.0'
lw_ip: Add to sys_arch_protect() a check that the mutex is created before use if not then creates it (v4.0)

See merge request espressif/esp-idf!7757
2020-03-18 12:06:42 +08:00
9eb7eceeec driver(GPIO): fixed gpio_wake_up_disable not working for RTC IO (release/4.0) 2020-03-18 10:29:18 +08:00
lly
28a9cb5be1 ble_mesh: Fix ble mesh nimble host deinit 2020-03-17 16:22:26 +08:00
lly
47fc70df7f ble_mesh: Add ESP BLE Mesh vendor models example 2020-03-17 16:01:50 +08:00
lly
be9725f8e7 ble_mesh: Rename ble_mesh_vendor_models to common_vendor_models 2020-03-17 16:01:45 +08:00
a8364af83d Merge branch 'bugfix/ble_mesh_miscellaneous_fix_v4.0' into 'release/v4.0'
Bugfix/ble mesh miscellaneous fix (v4.0)

See merge request espressif/esp-idf!7970
2020-03-17 15:35:12 +08:00
75f6bc2de1 Merge branch 'bugfix/compiler_err_when_performance_optimization_enabled_v4.0' into 'release/v4.0'
Bugfix/compiler err when performance optimization enabled v4.0

See merge request espressif/esp-idf!7978
2020-03-17 13:53:54 +08:00
9866b4f17c Merge branch 'bugfix/hfp_github_issues_v4.0' into 'release/v4.0'
Bugfix for HFP and some Github issue. v4.0

See merge request espressif/esp-idf!7976
2020-03-17 13:50:19 +08:00
8df1d1ffab Merge branch 'bugfix/fix_beacon_frame_vendor_ie_issue_v4.0' into 'release/v4.0'
bugfix: Place the Vendor Specific element at the end according to the protocol (backport v4.0)

See merge request espressif/esp-idf!7777
2020-03-17 13:44:23 +08:00
5f7436006f NimBLE: Add Host based privacy (RPA) feature support (v4.0)
- This feature removes dependency on controller to use privacy (RPA)
2020-03-16 07:33:07 +00:00
6ee1947822 NimBLE: Fix check for static random address & add MSYS_1 in menuconfig (v4.0)
Closes BT-290 & BT-440
2020-03-16 07:33:07 +00:00
3aaf6a06dd NimBLE: Use dynamic buffers instead of static memory (v4.0)
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-16 07:33:07 +00:00
3ee6dfa4d6 NimBLE: Misc changes in host flow control, ble_gap_unpair, ble_hs_hci_rx_evt & example (v4.0)
- 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-16 07:33:07 +00:00
b6415d9a91 Remove (x2) variable in BCM_STRNCPY_S and BCM_STRCPY_S when performance optimization enabled 2020-03-14 14:45:57 +08:00
ce55956a8f Fix mem_start uninitialized error when compiler optimization performance enabled 2020-03-14 14:45:04 +08:00
7c2f1287ec 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-14 14:19:54 +08:00
lly
eee8bd4612 ble_mesh: Move dev_role to the end of model_pub 2020-03-13 19:27:55 +08:00
lly
4dde86e45d ble_mesh: Use the right netkey during iv update 2020-03-13 19:27:54 +08:00
lly
e6b4eb60ef ble_mesh: Use the right net_idx & app_idx for publish 2020-03-13 19:27:54 +08:00
lly
c5b2f693b8 ble_mesh: Check buf->ref before unref the buffer 2020-03-13 19:27:54 +08:00
lly
7cf29e0f3f ble_mesh: Fix mesh memory use-after-free issue 2020-03-13 19:27:54 +08:00
lly
cb31c71877 ble_mesh: Add ble mesh deinit in btc task 2020-03-13 19:27:54 +08:00
lly
50040e8e99 ble_mesh: Free beacon timer when deinit mesh 2020-03-13 19:27:53 +08:00
lly
a364541193 ble_mesh: Use lock for mesh timer operations 2020-03-13 19:27:53 +08:00
fdbdf9a0ec Merge branch 'bugfix/unicore_config_prevent_ipc_code_v4.0' into 'release/v4.0'
ipc: prevent code getting pulled in for unicore configuration (v4.0)

See merge request espressif/esp-idf!7943
2020-03-12 13:31:44 +08:00
0ad0507f88 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:59:31 +08:00
40bebcb39b Merge branch 'bugfix/select_waiting_assert_for_v4.0' into 'release/v4.0'
lw-ip:fix bug for after udp close select_waiting assert for v4.0

See merge request espressif/esp-idf!7921
2020-03-11 21:11:23 +08:00
1c12e67c8a 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-03-11 19:18:09 +08:00
cf77068675 fix bug for after udp close select_waiting assert for v4.0 2020-03-11 10:04:32 +00:00
68b4177f70 Merge branch 'bugfix/ledc_driver_enums_v4.0' into 'release/v4.0'
driver: Avoid possible accidental mismatch between ledc_clk_src_t & ledc_clk_cfg_t enum (v4.0)

See merge request espressif/esp-idf!7910
2020-03-11 16:39:11 +08:00
0cc802e6ab ipc: prevent code getting pulled in for unicore configuration 2020-03-11 14:04:45 +05:30
cb10ba5785 esp32: Add a Kconfig option- Number of attempts to repeat 32k XTAL calibration
Closes: IDF-1479
2020-03-10 19:39:56 +08:00
6023d60966 Merge branch 'bugfix/put_spihost_handle_in_sram_v4.0' into 'release/v4.0'
spi: always put spihost handle in SRAM (backport 4.0)

See merge request espressif/esp-idf!7902
2020-03-10 15:32:24 +08:00
2161d09079 Merge branch 'Bugfix/netconn_marked_close_crash_for_v4.0' into 'release/v4.0'
lw-ip:fix bug for netconn marked close crash for v4.0

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

See merge request espressif/esp-idf!7878
2020-03-09 11:10:52 +08:00
8ea128ded5 fix bug for netconn marked close crash for v4.0 2020-03-09 02:49:57 +00:00
c5a5b34ba4 driver: Avoid possible accidental mismatch between ledc_clk_src_t & ledc_clk_cfg_t enum
ledc.h includes two similar enums, ledc_clk_src_t & ledc_clk_cfg_t.

The two enums do different things but there are two similar names: LEDC_REF_TICK / LEDC_USE_REF_TICK
and LEDC_APB_CLK / LEDC_USE_APB_CLK.

Because C will accept any enum or integer value for an enum argument, there's no easy way to check
the correct enum is passed without using static analysis.

To avoid accidental errors, make the numeric values for the two similarly named enums the same.,

Noticed when looking into https://github.com/espressif/esp-idf/issues/4476
2020-03-09 11:32:18 +11:00
c38c3ff3f0 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-09 09:59:43 +11:00
376703bf05 Merge branch 'bugfix/cmake_convert_whitespace_v4.0' into 'release/v4.0'
cmake: Minor convert_to_cmake.py fixes (v4.0)

See merge request espressif/esp-idf!7876
2020-03-09 06:55:19 +08:00
3d887cfff7 Merge branch 'bugfix/docs_ulp_reg_rd_wr_instructions_v4.0' into 'release/v4.0'
Correct ULP REG_WR and REG_RD instruction for ESP32

See merge request espressif/esp-idf!7868
2020-03-06 19:09:44 +08:00
af5adbc18e Correct ULP REG_WR and REG_RD instruction for ESP32 2020-03-06 19:09:43 +08:00
bcedff5a12 spi: always put spihost handle in SRAM
Closes https://github.com/espressif/esp-idf/issues/4635
2020-03-06 17:39:14 +08:00
254b0e9693 Merge branch 'bugfix/bt_interrupt_disable_timing_error_v4.0' into 'release/v4.0'
(backport v4.0)  btController: events scheduling error in case of wifi and bluetooth.

See merge request espressif/esp-idf!7866
2020-03-05 20:37:51 +08:00
af4c6ac0f3 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:11:26 +11:00
3d0ecfdc70 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:38 +11:00
e85c4a65a4 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:38 +11:00
abab19ad4d This MR is intended to fix Bluetooth event scheduling when WiFi is also
enabled. The global interrupts will be disabled before taking current
    time for scheduling further bluetooth events. Earlier disabling
    interrupts was taking some time because of which WiFi events were
    interrupting in current bluetooth scheduling.

    Also fixes ble crash issue triggered by ble event irq miss(0x20000) (819979b9)
2020-03-04 20:30:37 +05:30
cfb6ac13c4 Merge branch 'bugfix/add_hostname_in_discover_packet_for_v4.0' into 'release/v4.0'
lw-ip:add host name in discover packet for v4.0

See merge request espressif/esp-idf!7841
2020-03-04 11:24:22 +08:00
5bcdce8272 add host name in discover packet for v4.0 2020-03-03 12:18:57 +00:00
d5d2d716f6 NVS: Changed all new to new (nothrow) 2020-03-03 17:08:28 +08:00
2a467d17bd Merge branch 'bugfix/ws_rcv_exceed_buf_v4.0' into 'release/v4.0'
tcp_transport/ws_client: websockets now correctly handle messages longer than buffer (backport v4.0)

See merge request espressif/esp-idf!7755
2020-03-03 16:29:10 +08:00
e6a59ac038 Merge branch 'feat/ble_mesh_update_4.0' into 'release/v4.0'
Feat/ble mesh update 4.0

See merge request espressif/esp-idf!7799
2020-03-02 15:33:14 +08:00
a2af518069 Merge branch 'bugfix/ci_weekend_test_update_v4.0' into 'release/v4.0'
ci: a build_system_test(_cmake) fix and some mqtt fixes (backport v4.0)

See merge request espressif/esp-idf!7773
2020-03-02 12:43:34 +08:00
dc193cea49 bugfix: Place the Vendor Specific element at the end according to the protocol 2020-03-02 12:03:32 +08:00
8eb263f9d1 Merge branch 'feature/esp32_5p0_backport_v4p0' into 'release/v4.0'
esp325p0 features support and code optimize changes to release/v4.0(backport v4.0)

See merge request espressif/esp-idf!7563
2020-03-02 11:27:50 +08:00
5b402f8081 Merge branch 'bugfix/doc_remove_cmake_defconfig_v4.0' into 'release/v4.0'
Doc: replace defconfig with reconfigure (v4.0)

See merge request espressif/esp-idf!7688
2020-03-02 05:10:17 +08:00
ea3d70382b backport esp325p0 new features to release/v4.0 2020-02-29 09:11:30 +00:00
2f8af222e9 Merge branch 'bugfix/IPV6_multicast_adress_error_for_v4.0' into 'release/v4.0'
lw-ip:fix ipv6 bug when input the wrong broadcast for v4.0

See merge request espressif/esp-idf!7805
2020-02-29 17:08:32 +08:00
2408dc2671 Merge branch 'feature/doc_feedback_links_v4.0' into 'release/v4.0'
docs: Include feedback link in footer (v4.0)

See merge request espressif/esp-idf!7821
2020-02-29 16:58:07 +08:00
c924da6f0a Include feedback link in footer 2020-02-29 00:32:55 +08:00
198c8333d1 Merge branch 'bugfix/btdm_div_by_zero_in_slp_clk_conversion_v4.0' into 'release/v4.0'
bugfix/btdm_div_by_zero_in_slp_clk_conversion_v4.0(backport v4.0)

See merge request espressif/esp-idf!7787
2020-02-28 17:19:55 +08:00
f542c979e9 tcp_transport/ws_client: websockets now correctly handle messages longer than buffer
transport_ws can now be read multiple times in a row to read frames larger than the buffer.

Added reporting of total payload length and offset to the user in websocket_client.

Added local example test for long messages.

Closes IDF-1083
2020-02-28 10:53:08 +08:00
1351e94a0e fix ipv6 bug when input the wrong broadcast for v4.0 2020-02-27 17:15:09 +08:00
lly
6eaeda9cf4 ble_mesh: Calc incomplete timeout based on msg info 2020-02-27 14:42:25 +08:00
lly
f2e5ee5d25 ble_mesh: Start the timer when starting to send the client message 2020-02-27 14:42:25 +08:00
lly
4a3b06dde3 ble_mesh: No timeout for client message to non-unicast address 2020-02-27 14:42:25 +08:00
lly
ef7461ae1d ble_mesh: Unify client application and lower transport layer timeout 2020-02-27 14:42:25 +08:00
lly
bfed4fc90c ble_mesh: Allow maximum 377 octets payload 2020-02-27 14:42:25 +08:00
lly
6d61f6667a ble_mesh: Reset transport info when node is removed 2020-02-27 14:42:25 +08:00
lly
41cef4b1bb ble_mesh: Provisioner ignores msg from removed node 2020-02-27 14:42:25 +08:00
lly
e24641cc89 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-02-27 14:42:25 +08:00
280f0effc1 Merge branch 'bugfix/mesh_ie_issues_4.0' into 'release/v4.0'
Bugfix/mesh ie issues (Backport 4.0)

See merge request espressif/esp-idf!7308
2020-02-27 14:38:36 +08:00
f9cb434eeb Merge branch 'bugfix/doc_python3_v4.0' into 'release/v4.0'
Docs: Encourage to use Python 3 (v4.0)

See merge request espressif/esp-idf!7783
2020-02-26 20:35:27 +08:00
2236449f47 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-26 16:19:43 +08:00
2a4173e9a6 Docs: Encourage to used Python 3 2020-02-26 09:01:42 +01:00
e2cba84555 Merge branch 'bugfix/add_missing_ledc_set_pin_declaration_v4.0' into 'release/v4.0'
Bugfix: Add missing ledc_set_pin declaration in led.h (v4.0)

See merge request espressif/esp-idf!7371
2020-02-26 15:20:29 +08:00
8a56c31a25 Merge branch 'bugfix/ws_client_sending_race_v4.0' into 'release/v4.0'
websocket_client: fix locking in ws client task (v4.0)

See merge request espressif/esp-idf!7712
2020-02-26 06:11:16 +08:00
daf95803ec websocket_client: fix locking mechanism in ws-client task and when sending data
closes https://github.com/espressif/esp-idf/issues/4169
2020-02-25 20:52:29 +00:00
b006ffa643 mesh: fix mesh ie issues
Fix an error of mesh deinit lock.
Fix mesh send returns TIMEOUT.
Increase root window close time to 120s.
Clear ie.child when the child connected or fully associated.
Update rc_rssi when roots direct/forward.
ix assoc in mesh ie wrong.
Mesh packets use AC_VI instead of AC_BE.
2020-02-25 20:50:22 +08:00
80fd327308 update mqtt weekend test to use mbedtls asymetric buffer 2020-02-25 18:32:27 +07:00
ee8ab79696 ci: fix test build system when using template repository from a
different branch then master
2020-02-25 18:32:22 +07:00
a7f573c3a1 ci: fix weekend test confguration update per latest refactoring of
grouping tests
2020-02-25 18:32:11 +07:00
d292907fb7 Merge branch 'bugfix/btdm_check_EXT_CRYS_state_for_sleep_clk_for_v4.0' into 'release/v4.0'
bugfix/btdm_check_EXT_CRYS_state_for_sleep_clk(backport v4.0)

See merge request espressif/esp-idf!7747
2020-02-25 17:55:59 +08:00
4fa13a8575 Merge branch 'bugfix/softap_prov_disconnect_v4.0' into 'release/v4.0'
Bugfix/softap prov disconnect (v4.0)

See merge request espressif/esp-idf!7684
2020-02-25 15:40:18 +08:00
216b8b4088 Merge branch 'bugfix/child_cmake_uninitialized_vars_v4.0' into 'release/v4.0'
cmake: Set uninitialized variable warnings in ULP & bootloader subprojects (v4.0)

See merge request espressif/esp-idf!7630
2020-02-25 15:27:24 +08:00
2c90bce980 Merge branch 'feature/wifi_redo_scan_example_v4.0' into 'release/v4.0'
esp_wifi: Additional code snippets in esp_wifi_scan_example (backport v4.0)

See merge request espressif/esp-idf!7271
2020-02-25 14:22:59 +08:00
3ed5b73617 esp_wifi: Additional code snippets in esp_wifi_scan_example (backport v4.0) 2020-02-25 14:22:58 +08:00
a8fe083017 cmake: Set uninitialized variable warnings in ULP & bootloader subprojects
Fixes issue where PYTHON was not being expanded when running ulp_mapgen.py,
causing Windows launch setting to be used - reported here:
https://esp32.com/viewtopic.php?f=13&t=12640&p=50283#p50283

Closes https://github.com/espressif/esp-idf/issues/4785
2020-02-25 17:16:42 +11:00
25dfb08435 Merge branch 'bugfix/btdm_role_switch_v4.0' into 'release/v4.0'
Fix bugs about role switch

See merge request espressif/esp-idf!6924
2020-02-25 14:13:58 +08:00
bdeec924a2 Merge branch 'bugfix/nimble_apps_conn_handle_v4.0' into 'release/v4.0'
examples/bluetooth/nimble: Correct the connection handle in update and enc_change event (v4.0)

See merge request espressif/esp-idf!7702
2020-02-24 19:14:17 +08:00
5136605cb1 wifi_prov_manager: Delay the Wi-Fi connect call
For SoftAP provisioning, if we start Wi-Fi connection as soon as the
apply config request is received, it has been observed that the clients
(Phone apps mostly) do not get the response for this as we switch the
Wi-Fi channel, causing a momentary disconnection.

Delaying the connection calls helps mitigate the issue.

Signed-off-by: Piyush Shah <piyush@espressif.com>
2020-02-24 09:25:33 +00:00
63d3fd17f9 wifi_prov_manager: Change the name of an internal timer handle to better reflect the purpose
Signed-off-by: Piyush Shah <piyush@espressif.com>
2020-02-24 09:25:33 +00:00
636195fb29 component/bt: fall back to main XTAL as Bluetooth sleep clock when EXT 32K CRYS is configured but not detected 2020-02-24 12:14:25 +08:00
6c19711778 Merge branch 'feature/dev_security_restore_backport_v4p0' into 'release/v4.0'
feature/dev_security_restore_backport_v4p0(backport release/v4.0)

See merge request espressif/esp-idf!7738
2020-02-24 11:48:27 +08:00
28788e2d66 Merge branch 'bugfix/mbedtls_esp_bignum_v4.0' into 'release/v4.0'
mbedtls: esp bignum fix for 4096 keys (v4.0)

See merge request espressif/esp-idf!7705
2020-02-24 11:44:16 +08:00
9d15ffb573 backport mr !6031 - fix security info restore bug 2020-02-21 20:00:25 +08:00
6fee9da72e Merge branch 'bugfix/enable_ipv6_address_autoconfig_v4.0' into 'release/v4.0'
lw-ip: Enable IPv6 stateless address autoconfiguration (backport v4.0)

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

See merge request espressif/esp-idf!7719
2020-02-20 20:52:33 +08:00
938c291973 Merge branch 'fix/run_esptool_absolute_path_v4.0' into 'release/v4.0'
project_include.cmake: Make esptool_py_custom_target callable from other directories (v4.0)

See merge request espressif/esp-idf!7714
2020-02-20 20:22:11 +08:00
2966f8cb8c log: Check for ISR context and use proper API to get Tick Count 2020-02-20 15:55:22 +05:30
b59bcb88ce project_include.cmake: Make esptool_py_custom_target callable from other directories 2020-02-20 15:17:05 +05:30
f8fc84813c mbedtls: fix hw accelerated big-num mul if operand and result overlap
this issue is mainly exposed when using larger (4096) client key in TLS mutual auth,
since it uses multiplications > 2048 when mbedtls_mpi_mul_mpi is used in recursion,
which works only if both operands point to different location than result since
mpi_mult_mpi_overlong() called mbedtls_mpi_grow() to reallocate buffers used in previous
pointer arithmetics and thus corrupting it. Fixed by growing the mpi buffer before
calling mpi_mult_mpi_overlong()
2020-02-20 10:03:00 +01:00
e29d17fcd0 mbedtls: added mpi multiplication test for large numbers 2020-02-20 10:03:00 +01:00
2c5932e4fd examples/bluetooth/nimble: Correct the connection handle in update and enc_change event 2020-02-20 14:02:12 +05:30
06ff1ceae3 Fix bugs about role switch
Jitter in FHS
Jitter in first PULL
Receive EDR packet fail after role switch
2020-02-20 15:21:28 +08:00
b04e643bd0 Merge branch 'bugfix/coex_schm_v4.0' into 'release/v4.0'
Bugfix/coex schm v4.0

See merge request espressif/esp-idf!7636
2020-02-20 14:49:32 +08:00
e4696f077d lwip: Enable IPv6 stateless address autoconfiguration 2020-02-20 13:53:55 +08:00
8911c52a58 Doc: replace defconfig with reconfigure
Closes https://github.com/espressif/esp-idf/issues/3965
2020-02-19 17:19:19 +01:00
53e355b355 components/coex: Fix misspell in Kconfig 2020-02-19 11:48:45 +08:00
d07b9e97d7 components/coex: Fix a2dp stuck after creating anther connection 2020-02-19 11:48:33 +08:00
024a2755be Merge branch 'bugfix/kconfig_cmake_escape_v4.0' into 'release/v4.0'
confgen.py: Escape special characters for cmake (v4.0)

See merge request espressif/esp-idf!7646
2020-02-19 08:01:00 +08:00
6ad136a49e Merge branch 'doc/secure_boot_ref_v4.0' into 'release/v4.0'
doc: secure boot: Fix relative reference to key generation step (v4.0)

See merge request espressif/esp-idf!7628
2020-02-19 07:59:16 +08:00
615dc00e86 Merge branch 'bugfix/some_host_and_example_bugfix_Backport_to_4v0' into 'release/v4.0'
Bugfix/some host and example bugfix backport to v4.0

See merge request espressif/esp-idf!7360
2020-02-18 21:02:34 +08:00
8dd98715a4 Merge branch 'bugfix/unified_prov_bluedroid_v4.0' into 'release/v4.0'
Unified Provisioning - BLE: Fix characteristics read response issue (backport v4.0)

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

See merge request espressif/esp-idf!7584
2020-02-18 20:44:41 +08:00
6f875f2db2 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:09:30 +05:30
6b6d9d7321 confgen.py: Escape special characters for cmake
Closes https://github.com/espressif/esp-idf/issues/4751
2020-02-18 09:55:53 +01:00
477e6355eb Merge branch 'bugfix/legacy_msys2_environment_update_v4.0' into 'release/v4.0'
doc: Update the MSYS2 legacy toolchain zip to same as master branch (v4.0)

See merge request espressif/esp-idf!7627
2020-02-18 16:26:28 +08:00
008d2db20b Merge branch 'bugfix/win_tools_installer_fixes_v4.0' into 'release/v4.0'
docs: Windows tools installer release v2.3 (v4.0)

See merge request espressif/esp-idf!7561
2020-02-18 16:24:21 +08:00
78ecc043d5 Improve coexistence performance according to specific WiFi/BT/BLE scienario
1. Improve WiFi performance in some Classic BT scienario(idle, inquire scan,
       connecting, connected, sniff, a2dp pause, etc).

    2. Support WiFi + Classic BT + BLE mesh coexistence scienario.

    3. Improve WiFi scan and connect performance in coexistence scienario.
2020-02-18 12:40:48 +08:00
c48a94d4a8 components/mesh: Fix some bugs about mesh
fix send acl pkt after ble have sent terminate ind
modify min adv interval to 10ms
2020-02-18 11:07:16 +08:00
6f4e257601 Increase TCP send buffer and receive window limitation when TCP window scale is enabled 2020-02-18 11:06:15 +08:00
2fdb56e741 Merge branch 'feat/mcpwm_hal_fixes_v4.0' into 'release/v4.0'
mcpwm: add HAL layer support (fix part, backport v4.0)

See merge request espressif/esp-idf!7105
2020-02-18 09:45:13 +08:00
3f6f658532 docs: update version of IDF tools installer for windows to v2.3 2020-02-18 12:23:34 +11:00
0155bce1be doc: secure boot: Fix relative reference to key generation step 2020-02-18 10:48:18 +11:00
ba43d99db9 doc: Update the MSYS2 legacy toolchain zip to same as master branch
This is not required for v4.0 (the previous zip will work for v4.0), but it will be
required if updating to a newer ESP-IDF and there's no downside to requiring it here.
2020-02-18 10:38:14 +11:00
0f64291700 Merge branch 'bugfix/backport_some_wifi_bugs_0107_v4.0' into 'release/v4.0'
backport some Wi-Fi bugs 0107 (backport v4.0)

See merge request espressif/esp-idf!7260
2020-02-17 20:44:50 +08:00
64c1e029fb Merge branch 'bugfix/doc_sphinxcontrib_dep_v4.0' into 'release/v4.0'
Docs: Fix sphinxcontrib dependencies (v4.0)

See merge request espressif/esp-idf!7610
2020-02-17 15:20:23 +08:00
99c9e86b7a Merge branch 'bugfix/update_eclipse_docs' into 'release/v4.0'
docs: Update Eclipse installation instructions, ref....

See merge request espressif/esp-idf!7621
2020-02-17 15:06:02 +08:00
7eeaa62c49 docs: Update Eclipse installation instructions, ref. https://esp32.com/viewtopic.php?f=13&t=14237#p55468 2020-02-15 23:12:59 +08:00
9037b8fb52 mcpwm: decrease test time
cherry-pick 538540ce
2020-02-15 23:10:33 +08:00
0f10d12b81 mcpwm: fix the fault handling and capture issues
1. The fault signal 3 for unit 2 is corrected to the right value

2. Now `mcpwm_fault_set_oneshot_mode` will clear the status before, no
need to reset the peripheral.

3. The capture feature relies on the prescaler, but it's only
initialized in the mcpwm_init funciton, which is used to initialize a
PWM channel. This means, the capture may not work correctly if no PWM
channel is enabled.

   Now the prescaler is also updated when `mcpwm_capture_enable` is
called.
2020-02-15 18:39:28 +08:00
8c148ede22 mcpwm: enable some unit tests again 2020-02-15 18:39:27 +08:00
70d4d32511 Docs: Fix sphinxcontrib dependencies 2020-02-14 10:39:19 +01:00
5826ed0c48 Merge branch 'bugfix/smtp_strict_prototypes_fix_v4.0' into 'release/v4.0'
ci: re-add the lost PEDANTIC_{C,CXX}FLAGS in CMake example builds (backport v4.0)

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

See merge request espressif/esp-idf!7407
2020-02-14 16:41:58 +08:00
d2af36c9fb lwip: Drop packets larger than MTU 2020-02-14 12:03:49 +08:00
5894e049bc esp_wifi: fix some WiFi issues
Fix following WiFi issues:
1. Fix WiFi buffer reload issue
2. Fix AMSDU decrypt issue
3. Fix some WiFi timer issues
4. Fix the crash caused by too big of association request RSN information
5. Fix the crash caused by block scan
6. Fix the bug for getting channel and bandwidth
7. Fix some Sniffer bugs
8. Fix some ESP-NOW issues
   1> fix the bug when modifying the channel info of peer node
   2> fix the crash when modifying peer node between unencrypted and encrypted
   3> fix the bug for fetch peer
   4> modify the esp_wifi_set_channel() function
   5> fix the bug that the channel parameter doesn't work when adding peer node

Closes https://github.com/espressif/esp-idf/issues/2833
Closes https://github.com/espressif/esp-idf/issues/4311
2020-02-14 12:03:18 +08:00
50b686bfb4 Merge branch 'bugfix/fix_performance_issues_new_v4.0' into 'release/v4.0'
esp_wifi: fix WiFi performance issue (backport v4.0)

See merge request espressif/esp-idf!7227
2020-02-14 11:47:06 +08:00
92d8558364 Merge branch 'bugfix/wifi_clear_phy_status_when_cpu_start_v4.0' into 'release/v4.0'
soc: clear PHY status when cpu start (v4.0)

See merge request espressif/esp-idf!7593
2020-02-14 11:34:17 +08:00
45454cd477 ci: re-add the lost PEDANTIC_{C,CXX}FLAGS in CMake example builds 2020-02-13 19:01:43 +01:00
0a2bec85f3 soc: clear PHY status when cpu start 2020-02-13 14:36:11 +08:00
b6bec84c6e Merge branch 'bugfix/ble_mesh_utf_8_comma_4_0' into 'release/v4.0'
ble_mesh: Kconfig included a UTF-8 comma (v4.0)

See merge request espressif/esp-idf!7576
2020-02-13 11:13:02 +08:00
fb924ece79 Merge branch 'bugfix/btdm_fix_multi_open_evt_and_clear_blufi_prepare_write_len' into 'release/v4.0'
component/bt: fix multi open evt and clear blufi prepare write len(backport v4.0)

See merge request espressif/esp-idf!7324
2020-02-13 11:08:41 +08:00
e07a64925b Merge branch 'bugfix/coex_bt_ble_stuck_v4.0' into 'release/v4.0'
components/bt: Fix A2DP stuck when BLE's interval is too small

See merge request espressif/esp-idf!7220
2020-02-13 11:08:20 +08:00
e07ecea868 Merge branch 'hfp_a2dp_iphone_4.1' into 'release/v4.0'
components bt/: Disable sniff mode during (e)SCO connection for HFP. [backport 4.0]

See merge request espressif/esp-idf!7249
2020-02-13 11:08:10 +08:00
5b9cb366c2 Merge branch 'bugfix/fix_airkiss_bug_v4.0' into 'release/v4.0'
fix the bug for Airkiss

See merge request espressif/esp-idf!7346
2020-02-13 11:07:41 +08:00
d5bd2256f4 Merge branch 'bugfix/fix_ble_mesh_memory_leak_v4.0' into 'release/v4.0'
ble_mesh: Fix memory leak when node is reset (v4.0)

See merge request espressif/esp-idf!7278
2020-02-13 10:58:09 +08:00
c235640bf4 Merge branch 'bugfix/ble_mesh_update_lightness_last_v4.0' into 'release/v4.0'
ble_mesh: Update lightness last state when actual state is changed (v4.0)

See merge request espressif/esp-idf!7281
2020-02-13 10:58:06 +08:00
6193a439a3 Merge branch 'bugfix/sync_zephyr_v2.0_ble_mesh_fixes_v4.0' into 'release/v4.0'
ble_mesh: sync Zephyr v2.0 ble mesh fixes (v4.0)

See merge request espressif/esp-idf!7300
2020-02-13 10:58:03 +08:00
a3cd5ab1ae esp_wifi: improve WiFi performance 2020-02-13 10:50:48 +08:00
lly
3bf1b9b8ab ble_mesh: Fix compile error with c++ files 2020-02-13 09:52:10 +08:00
lly
04fc15a4f3 ble_mesh: Fix memory leak when node is reset
When node is being reset, the init functions of each sig-defined
models will be invoked again, this will cause memory leak because
some model internal data will be allocated again.
Hence before trying to allocate memory for them, we add some check
to make sure no memory has been allocated previously.
And for client model, when the init functions are invoked again,
we will clear the list items.
2020-02-12 12:03:31 +00:00
lly
e95b59c089 ble_mesh: Kconfig included a UTF-8 comma 2020-02-12 18:28:06 +08:00
2309313103 Merge branch 'bugfix/ci_no_attempts_no_custom_toolchain_url_v4.0' into 'release/v4.0'
ci: no stage attempts variables, no custom toolchain url (backport v4.0)

See merge request espressif/esp-idf!7542
2020-02-12 17:55:17 +08:00
8cb3cc5154 Merge branch 'bugfix/idf_tools_virtualenv_v4.0' into 'release/v4.0'
idf_tools.py: fix install-python-env failure with virtualenv 20.0.0 (backport v4.0)

See merge request espressif/esp-idf!7553
2020-02-12 17:32:20 +08:00
bbbe6fd449 Merge branch 'bugfix/idf_tools_py_install_required_v4.0' into 'release/v4.0'
Fix Docker image builds on release/v4.0

See merge request espressif/esp-idf!7551
2020-02-12 16:54:03 +08:00
7ccf6ebada 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:46:03 +01:00
91dc4d78f8 Merge branch 'bugfix/select_driver_not_installed_v4.0' into 'release/v4.0'
VFS: Check in select() if the UART driver is installed or not (v4.0)

See merge request espressif/esp-idf!7417
2020-02-11 12:08:48 +08:00
5bf43a854c Merge branch 'bugfix/make_undefined_variable_warning_v4.0' into 'release/v4.0'
make: fix undefined variable warning (IDF_SKIP_CHECK_SUBMODULES) (backport v4.0)

See merge request espressif/esp-idf!7480
2020-02-11 12:07:33 +08:00
2bee223250 Merge branch 'bugfix/part_gen_subtype_fix_v4.0' into 'release/v4.0'
partition_table: Fix subtype in gen_esp32part.py (v4.0)

See merge request espressif/esp-idf!7536
2020-02-11 12:06:25 +08:00
f92a52f275 Merge branch 'bugfix/remove_cjson_test_file_from_cmake_build_v4.0' into 'release/v4.0'
cJSON: include only source file objects for cmake build (v4.0)

See merge request espressif/esp-idf!7546
2020-02-11 11:57:32 +08:00
f368f69922 idf_tools.py: fix downloading for tools which have "on_request" options for some platforms.
'install' and 'download' options can be used for 'required' or 'all' tools
2020-02-10 20:10:26 +01:00
8df70a1728 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:26 +05:30
c5d20275dd ci: remove using IDF_XTENSA_TOOLCHAIN_URL because there are idf_tools.json and multi-target support 2020-02-10 18:38:23 +07:00
f2ef0509e3 ci: Use ARTIFACT_DOWNLOAD_ATTEMPTS and others from the project settings 2020-02-10 18:35:12 +07:00
8c88f0f1f6 Fix subtype in PartitionTable.find_by_type
Fix ptype->subtype

Closes https://github.com/espressif/esp-idf/pull/4723
2020-02-10 12:04:45 +01:00
313c1ed1ba Merge branch 'bugfix/esp_log_from_critical_v4.0' into 'release/v4.0'
intr_alloc: don't call ESP_LOG from a critical section (backport v4.0)

See merge request espressif/esp-idf!7159
2020-02-10 17:34:53 +08:00
c3961fdacb Merge branch 'bugfix/idf_monitor_usbser_sys_v4.0' into 'release/v4.0'
tools: work around usbser.sys bug in IDF monitor (v4.0)

See merge request espressif/esp-idf!7470
2020-02-10 17:34:00 +08:00
c8215756fa Merge branch 'feature/idfpy_add_baud_parameter_to_monitor_v4.0' into 'release/v4.0'
idf.py: add monitor-baud option to monitor command (v4.0)

See merge request espressif/esp-idf!7461
2020-02-10 17:33:32 +08:00
0c2c821f8f Merge branch 'bugfix/esp_ptr_executable_single_core_v4.0' into 'release/v4.0'
soc: Fix esp_ptr_executable() for single core ESP32 config & cache memory (v4.0)

See merge request espressif/esp-idf!7464
2020-02-10 16:30:34 +08:00
f5dc81aaae Merge branch 'bugfix/panic_cache_err_dig_reset_v4.0' into 'release/v4.0'
esp32: panic: do digital reset if cache error interrupt is set (backport v4.0)

See merge request espressif/esp-idf!7484
2020-02-10 16:30:02 +08:00
97ef8fd057 Merge branch 'bugfix/idf_tools_v4.0' into 'release/v4.0'
idf_tools.py bug fixes (backport v4.0)

See merge request espressif/esp-idf!7479
2020-02-10 16:29:27 +08:00
204f19ac0b Merge branch 'bugfix/doc_nwdiag_v4.0' into 'release/v4.0'
docs: Fix nwdiag dependency for documentation build (v4.0)

See merge request espressif/esp-idf!7516
2020-02-07 06:20:35 +08:00
39194136e5 docs: Fix nwdiag dependency for documentation build 2020-02-06 17:51:59 +01:00
3f76083e8c Merge branch 'bugfix/several_ethernet_bugfix_from_4.1' into 'release/v4.0'
Ethenret driver bugfix and optimization (4.0)

See merge request espressif/esp-idf!7426
2020-02-06 14:38:47 +08:00
87eccad969 Merge branch 'bugfix/wps_config_init_v4.0' into 'release/v4.0'
WPS_CONFIG_INIT_DEFAULT(type) error

See merge request espressif/esp-idf!7334
2020-02-06 14:06:40 +08:00
8f0f3e8f88 WPS_CONFIG_INIT_DEFAULT(type) error 2020-02-06 14:06:38 +08:00
c3a3a81b08 Merge branch 'feature/idf_docker_updates_v4.0' into 'release/v4.0'
Enable ccache and use newer CMake in Docker image (backport v4.0)

See merge request espressif/esp-idf!7482
2020-01-31 15:58:50 +08:00
4ce7b666a6 esp32: panic: do digital reset if cache error interrupt is set
Even if frame->exccause != PANIC_RSN_CACHEERR, it is possible that
the cache error interrupt status is set. For example, this may happen
due to an invalid cache access in the panic handler itself.
Check cache error interrupt status instead of frame->exccause to
decide whether to do CPU reset or digital reset.

Also remove unnecessary esp_dport_access_int_pause from
esp_cache_err_get_cpuid, since the panic handler already calls
esp_dport_access_int_abort on entry.
2020-01-30 12:28:22 +01:00
c2bce897b8 idf.py: Add environment variable to enable ccache by default 2020-01-30 12:14:54 +01:00
5140eea3d1 tools/docker: enable ccache by default 2020-01-30 12:10:31 +01:00
1b0473494f 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:10:31 +01:00
e9d3800ad2 make: fix undefined variable warning (IDF_SKIP_CHECK_SUBMODULES) 2020-01-30 12:06:57 +01:00
97242031e7 idf_tools.py: fix typo in __PYVENV_LAUNCHER__ env variable name
Fixes the workaround added in 9279b72a6.
2020-01-30 11:59:29 +01:00
5ab36dc2ec idf_tools.py: fix virtualenv issue for macOS with homebrew 2020-01-30 11:59:16 +01:00
09dd8ca3e9 idf_tools.py: when guessing IDF_PATH, set it in the enviroment
This allows the processes launched from idf_tools.py to use the value
of IDF_PATH. One such example is the installation of Python packages,
when requirements.txt uses IDF_PATH to refer to the esp-windows-curses
package.

Closes https://github.com/espressif/esp-idf/issues/4341
2020-01-30 11:57:51 +01:00
f27a344fc9 Merge branch 'bugfix/parttool_backtraces_v4.0' into 'release/v4.0'
parttool: Avoid unnecessary exception backtrace for legitimate errors (v4.0)

See merge request espressif/esp-idf!7463
2020-01-30 13:36:52 +08:00
02596a7efa 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:36:43 +01:00
a61fd1e42b Merge branch 'bugfix/esp_timer_stucks_into_esp_timer_impl_set_alarm_v4.0' into 'release/v4.0'
esp_timer/esp32: Fix esp_timer_impl_set_alarm() when CPU and APB freqs are changed (v4.0)

See merge request espressif/esp-idf!7304
2020-01-29 14:25:27 +08:00
d897e522af soc: Fix esp_ptr_executable() for single core ESP32 config & cache memory
In single core mode, APP CPU cache region is added to the available range.
2020-01-29 10:03:30 +11:00
59649ea825 parttool: Fix regression when parsing binary partition data
Regression in a91de43537
2020-01-29 09:40:23 +11:00
bdb0851065 parttool: Avoid unnecessary exception backtrace for legitimate errors
Previous version used exception handling for program control flow,
which makes for long and confusing backtrace messages if an error
occurs while parsing the CSV (as it also prints the phony error that
occurred while trying to parse as a binary, then prints
"During handling of the above exception, another exception occurred:",
then prints the real error).

Use the same heuristic that is applied in gen_esp32_part, instead.

Also, avoid printing the entire backtrace if the error is a gen_esp32_part
InputError, same as gen_esp32part does.

Found while looking into https://github.com/espressif/esp-idf/issues/4474
2020-01-29 09:40:22 +11:00
9a24d95907 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-01-28 21:41:27 +08:00
ead0e6da36 idf.py: add monitor-baud option to monitor command 2020-01-27 18:54:37 +01:00
08219f3cf5 Merge branch 'bugfix/esp_tls_blocking_timeout_v4.0' into 'release/v4.0'
esp-tls: add timeout for blocking connection (v4.0)

See merge request espressif/esp-idf!7396
2020-01-22 11:44:48 +08:00
b324ab9c6e Merge branch 'bugfix/mqtt_submodule_ref_update_v4.0' into 'release/v4.0'
mqtt: update submodule to point to latest commit (backport 4.0)

See merge request espressif/esp-idf!7276
2020-01-22 11:29:34 +08:00
93e5a31685 ethernet: always put eth_driver handle in SRAM
Closes https://github.com/espressif/esp-idf/issues/4635
2020-01-21 21:30:34 +08:00
01cc5a38cc ethernet: work with cache disabled 2020-01-21 21:30:18 +08:00
7b128595ac ethernet: optimise tx and rx 2020-01-21 20:51:03 +08:00
f48930a040 Merge branch 'nimble/example_update_doc_v4.0' into 'release/v4.0'
NimBLE: Update the documentation link in the examples (v4.0)

See merge request espressif/esp-idf!7365
2020-01-21 17:58:46 +08:00
642dc19c25 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:11:08 +01:00
55834dd001 Merge branch 'bugfix/wa_dport_and_intr_v4.0' into 'release/v4.0'
esp32: Fix for DPORT (v4.0)

See merge request espressif/esp-idf!7349
2020-01-21 10:49:08 +08:00
e38c080f79 components/bt: Fix error EIR type in config eir event 2020-01-20 21:50:01 +08:00
c7e1416174 esp_tls: added connection timeout to esp_tls_conn_new_sync() 2020-01-20 07:26:51 +01:00
e0c88dbd73 esp_tls: fail connection if esp_tls_conn_new() timeouts 2020-01-20 07:08:40 +01:00
a58fa7665a Bugfix(LEDC): Add missing ledc_set_pin declaration in led.h 2020-01-17 10:22:36 +08:00
d84677493e NimBLE: Update the documentation link in the examples 2020-01-16 17:12:33 +05:30
443ea78e78 bugfix:Fix length check for snprintf in osi config. And remove the error code when there is no file in the nvs in config.c 2020-01-16 16:20:43 +08:00
ef07a315bb Add notes 2020-01-16 16:09:49 +08:00
ed6805625c ble:set a esp api to get size of controller send packets buffer. 2020-01-16 16:09:34 +08:00
74a89774fd bugfix:Fixed throughput wasting memory and packet loss issues. 2020-01-16 16:09:17 +08:00
7dc5c2af59 ble Fix typo and add some comment 2020-01-16 16:05:44 +08:00
e5bd8b1982 add missing gatt descriptors 2020-01-16 16:05:29 +08:00
983f528513 example:ble_hid_device_demo fix the wrong mask value according to HID protocol 2020-01-16 15:27:25 +08:00
5445c80a8e component/bt: Fix the issue with pointer type conversion in gattc. Unified count pointer type in bta and btc, change pointer type in bta from int to uint16_t. 2020-01-16 15:26:37 +08:00
69d341f7f0 Fix some typo in idf 2020-01-16 15:26:37 +08:00
f927957950 esp32: Add UT for DPORT 2020-01-16 13:31:20 +08:00
6fca0e3861 esp32: Fix esp_dport_access_reg_read 2020-01-16 13:31:20 +08:00
5202be013a fix the bug for Airkiss 2020-01-16 11:54:02 +08:00
ed44d25690 example/blufi: Fix the wrong wifi storage mode and check if ble is connected before sending a ble message. 2020-01-16 11:48:46 +08:00
8c980c11aa example/ble_throughput fix the throughput clinet crash bug when open the CONFIG_GATTC_WRITE_THROUTHPUT option 2020-01-16 11:47:52 +08:00
4312c71e71 example/ble_throughput fix the throughput server crash bug when running with throughput client 2020-01-16 11:40:37 +08:00
4900ead609 bugfix:btmd fix the problem that fixed_queue_enqueue may give the wrong semaphore if list_append fail to calloc a new node 2020-01-16 11:32:40 +08:00
386804d407 intr_alloc: don't call ESP_LOG from a critical section
Calling ESP_LOG from a critical section leads to abort() in 4.1, and
may also randomly abort() in earlier versions.

Closes FCS-268
2020-01-15 04:16:24 +00:00
93409bd57e component/bt: fix blufi prepare write buf len invalid 2020-01-14 17:25:54 +08:00
32ba52760f Component/bt: Fix GATTC trigger open event multiple times 2020-01-14 17:24:36 +08:00
158f2d065d mqtt: update submodule to point to latest commit.
Adds bugfixes for:
 - Too early publishing
 - Potential mutex memory leak
 - CI related issues.
 - Wait for entire connack message
 - Event loop not getting cleaned up

Adds support for ALPN, configurable reconnect time, QEMU CI tests and password
protected client key.

MQTT MR: esp-mqtt/merge_requests/46
Closes IDF-1162
Closes https://github.com/espressif/esp-mqtt/issues/137

MQTT MR: esp-mqtt/merge_requests/47
Closes IDF-1126

MQTT MR: esp-mqtt/merge_requests/48
Closes IDFGH-2197
Closes https://github.com/espressif/esp-idf/issues/4349
Closes https://github.com/espressif/esp-mqtt/issues/140

MQTT MR: esp-mqtt/merge_requests/48
Closes IDFGH-2235
Closes https://github.com/espressif/esp-idf/issues/4384

MQTT MR: esp-mqtt/merge_requests/49
Closes https://github.com/espressif/esp-idf/issues/4433
Closes IDFGH-2293

MQTT MR: esp-mqtt/merge_requests/50
Closes FCS-254

MQTT MR: esp-mqtt/merge_requests/53
Closes FCS-267
2020-01-14 10:55:50 +08:00
lly
14a408c478 ble_mesh: Fix PreviousAddress endianess in Friend Request
The upper transport layer is using big endian ordering. The
PreviousAddress field of a Friend Request message should therefore
be converted to native endianess using sys_cpu_to_be16().
2020-01-13 10:40:25 +08:00
lly
92d0d7ad49 ble_mesh: Fix next_period computation
If the duration to publish is roughly the same as the period, we might
end up with elapsed == period, which returns 0 and cancel the periodic
publication. Instead 1 should be returned, just like when the elapsed
time is greater than the period.
2020-01-13 10:40:20 +08:00
lly
19c9ae400b ble_mesh: Make model publication struct more compact
Previously the FastPeriodDivisor value was introduced to the model
publication struct. Based on the way it was grouped it seems the
intention was to fit it within the same octet as other bit fields,
but it actually makes the octet overflow by one bit. This ends up
creating another u8_t variable which in turn adds 24 bits of padding
after it.

To keep the size of the struct as compact as possible, group the flag
together with the key index, since that only requires 12 bits. Some
care is needed here, since the mesh stack does have special internal
key index values that require more than 12 bits such as
BLE_MESH_KEY_UNUSED and BLE_MESH_KEY_DEV. In this case restricting
ourselves to 12 bits is fine since the value in the model publication
struct follows 1:1 the value received in the Config Model Publication
Set message, and there the parameter is defined to be exactly 12 bits.
2020-01-13 10:40:13 +08:00
lly
566fb11a73 ble_mesh: Fix compile error when using release optimization level 2020-01-13 10:40:05 +08:00
lly
928480ada9 ble_mesh: Remove useless CONFIG_BLE_MESH_NODE
For Low Power node and Proxy Server, the two features
depend on BLE_MESH_NODE in Kconfig.in, here in the
stack there is no need to judge if CONFIG_BLE_MESH_NODE
is enabled.
2020-01-13 10:39:57 +08:00
lly
da0205b166 ble_mesh: Fixes Provisioner not support friend feature 2020-01-13 10:39:52 +08:00
lly
610fc8124a ble_mesh: Fixes wrong subnet info used for Friend Clear
When Friend node tries to send Friend Clear message to other
Friend nodes, it should use the subnet information based on
the net_idx from friendship.
2020-01-13 10:39:42 +08:00
lly
21dbee1291 ble_mesh: fix provisioner failed to send msg to 0xFFFF
According to Mesh Spec 3.4.5.3, a node shall implement a local
network interface. And here we limit the situation just based
on the spec, and Provisioner directly sending the msg without
passing through the local network interface.
2020-01-13 10:39:37 +08:00
lly
e5431e55a9 ble_mesh: fix virtual addr wrong return value
Fixes missing return value on `va_del`
Fixes wrong return value on `va_add`
2020-01-13 10:39:28 +08:00
lly
4405560483 ble_mesh: Persistent storage of Virtual Address
The 16-bit format group addresses will be stored,
but we don't store (or restore) the virtual label UUIDs,
i.e. after a power cycle the 16-bit group addresses
would be meaningless.
2020-01-13 10:39:22 +08:00
lly
51616eacee ble_mesh: Proxy forwards ALL_NODES addr
Unless explicitly blacklisted, the Proxy node will forward all messages
for the ALL_NODES address to the GATT proxy client.
2020-01-13 10:39:15 +08:00
lly
4aa7f31f02 ble_mesh: Model message macros
Creates macros for determining model message lengths based on opcode,
payload length and MIC size. Also adds macro wrapping
NET_BUF_SIMPLE_DEFINE to serve the most common use case.
2020-01-13 10:39:10 +08:00
lly
318f83e33a ble_mesh: Use net_buf_simple_clone
Uses net_buf_simple_clone to access the sdu of an unsegmented app packet
for re-encryption.
2020-01-13 10:39:03 +08:00
lly
4bf2ceee4e ble_mesh: Skip local messages in rx
Local messages are already enqueued for the LPN in the tx path, and
don't have to be added again in the rx path.
2020-01-13 10:38:59 +08:00
lly
a9c5092baf ble_mesh: Ensure seqnum match in app/net
Re-encrypts single-segment application messages when the network seqnum
has changed, to avoid encrypting messages with different seqnums in
network and transport. This operation is only required for unsegmented
messages, as segmented messages don't need to use the same seqnum in
network.

Reinstates the special adv data for friend messages to store the app key
index.
2020-01-13 10:38:54 +08:00
lly
9e47e04897 ble_mesh: Expose app key get function 2020-01-13 10:38:48 +08:00
lly
ca0bfb84d0 ble_mesh: Expose header parsing outside net 2020-01-13 10:38:38 +08:00
lly
cc772c1324 ble_mesh: Remove unused macro FRIEND_BUF_SIZE 2020-01-13 10:38:31 +08:00
lly
c344a4a3b9 ble_mesh: Make RSSI value available to mesh applications 2020-01-13 10:38:26 +08:00
lly
32387250bc ble_mesh: Encrypt friend packets on send
Stores friend queue packets unencrypted, removing any out-of-order
issues caused by seqnum allocation. Also moves as much of the metadata
storage as possible into the packet, allowing us to free up some bytes
of net_buf user data for friend packets.
2020-01-13 10:38:21 +08:00
lly
a870460f72 ble_mesh: Expose SeqZero mask
Makes a define for the seqzero 13-bit mask in transport, and exposes it
in the header for use in the friend module.
2020-01-13 10:38:15 +08:00
463a9d8b7f Merge branch 'bugfix/ci_deploy_tags_v4.0' into 'release/v4.0'
ci: fix tags for internal deploy jobs (backport v4.0)

See merge request espressif/esp-idf!7295
2020-01-11 14:08:55 +08:00
ef34e6f6f7 ci: fix tags for internal deploy jobs 2020-01-10 18:33:11 +07:00
lly
cf2c5b8d96 ble_mesh: Update lightness last state when actual state is changed 2020-01-10 15:33:59 +08:00
aa51829ec8 Merge branch 'bugfix/cmake_reflashable_build_targets_v4.0' into 'release/v4.0'
secure boot: Fix bootloader build system target for bootloader digest (v4.0)

See merge request espressif/esp-idf!7229
2020-01-09 15:56:08 +08:00
dcd735759e Merge branch 'bugfix/mdns_deinit_event_crash_v4.0' into 'release/v4.0'
mdns: fixed crash on event during deinit (v4.0)

See merge request espressif/esp-idf!7246
2020-01-09 13:02:28 +08:00
a36bbd4e95 Merge branch 'bugfix/mdns_send_sdptr_answer_v4.0' into 'release/v4.0'
mdns: respond to discovery with the proper pseudo name _services._dns-sd._udp (v4.0)

See merge request espressif/esp-idf!7242
2020-01-09 13:01:11 +08:00
3f8a89504f Merge branch 'feature/ws_local_server_test_v4.0' into 'release/v4.0'
websocket_client: added example_test with a local websocket server (backport v4.0)

See merge request espressif/esp-idf!7200
2020-01-09 08:31:58 +08:00
1d280a0825 Merge branch 'fix/ci_target_test_v4.0' into 'release/v4.0'
ci: Fix target variable default value v4.0

See merge request espressif/esp-idf!7237
2020-01-09 07:24:18 +08:00
3b13eba1b2 Merge branch 'bugfix/wifi_fix_beacon_timeout_and_connect_fail_when_coex_v4.0' into 'release/v4.0'
Fix WiFi beacon timeout and station fails to connect to AP sometimes when WiFi and Bluetooth run togerther.

See merge request espressif/esp-idf!7192
2020-01-08 22:53:30 +08:00
a388eb8806 componnets_bt/:fix hfp/a2dp coex bug with iphone 2020-01-08 19:25:29 +08:00
1f263434a6 mdns: fixed crash on event during deinit
mdns library deinitialization destroys internal structures including action queue. if an event (e.g. network update) received
after some essential stucture is destoyed, an unexpected behavour might be introduced (e.g. crash of adding the event notification
to the action queue which was already destroyed

Closes WIFI-1485
2020-01-08 10:27:30 +01:00
06cc4e888d mdns: respond to discovery with the proper pseudo name _services._dns-sd._udp
Closes https://github.com/espressif/esp-idf/issues/4369
Closes IDFGH-2219
2020-01-08 10:21:28 +01:00
0a2371972a Fix WiFi beacon timeout and station fails to connect to AP sometimes
when WiFi and Bluetooth run togerther.
2020-01-08 16:48:16 +08:00
b7a191a996 ci: Fix target variable default value v4.0 2020-01-07 20:29:06 +05:30
beb73456ee Merge branch 'feature/prebuilt_binary_example_v4.0' into 'release/v4.0'
Import prebuilt binary (v4.0)

See merge request espressif/esp-idf!7208
2020-01-07 14:34:38 +08:00
e3d65c8e3e Merge branch 'bugfix/ws_user_context_v4.0' into 'release/v4.0'
websocket: added missing event data (backport v4.0)

See merge request espressif/esp-idf!7195
2020-01-07 14:34:08 +08:00
d11bca44db Merge branch 'bugfix/sniffer_crash_issue_v4.0' into 'release/v4.0'
esp_wifi: Fix wifi stop bug when sniffer enable (backport v4.0)

See merge request espressif/esp-idf!7207
2020-01-07 10:57:26 +08:00
6da2676a3c secure boot: Fix bootloader build system target for bootloader digest
Closes https://github.com/espressif/esp-idf/issues/4513
2020-01-07 09:38:01 +11:00
15aa9bc041 Merge branch 'bugfix/backport_wifi_event_bits' into 'release/v4.0'
examples: using xEventGroup bits properly (backport v4.0)

See merge request espressif/esp-idf!7209
2020-01-06 23:19:09 +08:00
3ae110b30c components/bt: Fix A2DP stuck when BLE's interval is too small
1. Fix the cumulative time switch from BLE to classic BT
2. Enhance classic BT performance while enable calssic BT and BLE at the same time
2020-01-06 20:31:54 +08:00
509ac2cfc1 examples: using xEventGroup bits properly
Closes IDF-1177

* changed
  ../../wifi/getting_started/station/README.md
  ../../wifi/getting_started/station/main/station_example_main.c
2020-01-06 12:41:00 +08:00
8c23bb4aa9 examples: add import prebuilt example 2020-01-06 09:39:49 +08:00
989dac1e64 cmake: implement utility to import prebuilt libraries 2020-01-06 09:39:49 +08:00
2ea0062fe8 Fix wifi stop bug when sniffer enable 2020-01-04 15:25:09 +08:00
5cb04f3e13 websocket_client: added example_test with a local websocket server
- Added a example test that connects to a local python websocket server.
- Added readme for websocket_client example.

Closes IDF-907
2020-01-03 15:03:27 +08:00
16e102199a Merge branch 'bugfix/backport_nvs_iterator_fix' into 'release/v4.0'
NVS: iterator corrupting entries (backport v4.0)

See merge request espressif/esp-idf!7071
2020-01-03 13:07:20 +08:00
2215aeaad8 websocket: added missing event data
user_context was missing from websocket event data, added. Also added the websocket client handle to the event data.

Removed  unused event data struct.

Closes: IDF-1271
2020-01-03 10:01:10 +08:00
51a1421f65 Merge branch 'bugfix/i2s_timergroup_dev_array_used_by_isr_issue' into 'release/v4.0'
bugfix(driver): fix i2s and timergroup some issues

See merge request espressif/esp-idf!7141
2020-01-02 21:20:21 +08:00
0cefe6df78 Merge branch 'bugfix/fix_a_wifi_rx_bug_v4.0' into 'release/v4.0'
esp_wifi: fix a WiFi receiving bug (backport v4.0)

See merge request espressif/esp-idf!7002
2020-01-02 16:30:04 +08:00
20e75ef87d Merge branch 'feat/spi_internal_header_v4.0' into 'release/v4.0'
spi: move deprecated functions into internal header (backport v4.0)

See merge request espressif/esp-idf!7103
2020-01-02 02:16:18 +08:00
cb1d440cb8 Merge branch 'bugfix/fix_python3_errors_for_ttfw_v4.0' into 'release/v4.0'
test: fix python3 errors for ttfw (backport v4.0)

See merge request espressif/esp-idf!7146
2019-12-31 17:56:37 +08:00
e5d25fb51e Merge branch 'doc/esp_ringbuf_acquire_complete_v4.0' into 'release/v4.0'
esp_ringbuf: add documents for SendAcquire and SendComplete (backport v4.0)

See merge request espressif/esp-idf!7104
2019-12-31 15:01:49 +08:00
8306ddf3c1 Merge branch 'feature/wifi_prov_ext_httpd_v4.0' into 'release/v4.0'
wifi_provisioning_softap: Allow applications to start webserver externally (v4.0)

See merge request espressif/esp-idf!7163
2019-12-31 15:00:59 +08:00
93928a5d11 Merge branch 'nimble/update_doc_link_v4.0' into 'release/v4.0'
NimBLE: Update the link to NimBLE upstream documentation (v4.0)

See merge request espressif/esp-idf!7167
2019-12-31 13:42:30 +08:00
96a5e34d7a bugfix(driver): fix i2s and timergroup some issues
* fix i2s and timergroup dev array used by isr crash issue

* Closes IDFGH-2432

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

* fix i2s adc data inv issue

* Closes IDFGH-2444

* Closes https://github.com/espressif/esp-idf/issues/4557
2019-12-31 11:02:35 +08:00
6bc284f7b7 Merge branch 'feature/tools_installer_v2.2_v4.0' into 'release/v4.0'
docs: update Windows tools installer link (backport v4.0)

See merge request espressif/esp-idf!7158
2019-12-31 09:17:46 +08:00
daa2178f30 WIFI: added log for wifi test, increased timeout 2019-12-31 08:33:11 +08:00
92b10b4ba3 NVS: bugfix nvs_set_str/blob checks write mode 2019-12-31 08:33:11 +08:00
69b0919904 NVS: BUGFIX non-matching type iterator works
Closes IDFGH-2229
2019-12-31 08:33:11 +08:00
4cbbe6cca3 Merge branch 'bugfix/ci_test_idf_monitor_4.0' into 'release/v4.0'
CI: Adjust the test parameters of IDF Monitor (backport v4.0)

See merge request espressif/esp-idf!7165
2019-12-31 06:40:07 +08:00
edcba21b28 NimBLE: Update the link to NimBLE upstream documentation 2019-12-30 19:18:06 +05:30
e8b454e802 CI: Adjust the test parameters of IDF Monitor 2019-12-30 14:28:30 +01:00
84029130cf wifi_provisioning_softap: Allow applications to start webserver externally
If an application wants to use webserver, instead of creating another
webserver instance, the wifi provisioning manager can re-use the same.
The webserver handle can be passed using this new API.

Signed-off-by: Piyush Shah <piyush@espressif.com>
2019-12-30 17:34:05 +05:30
6cbda6bd22 docs: update Windows tools installer link 2019-12-30 11:34:00 +01:00
dae4da07c3 CI: reduce number of unit test jobs 2019-12-30 10:59:47 +08:00
ca3b2a8909 test: fix multiple devices cases fail on python3 2019-12-30 10:55:57 +08:00
95f0553f40 test: let unit test jobs use python3 2019-12-30 10:55:46 +08:00
09935510bd ttfw: fix incorrect relative import for python3 2019-12-30 10:55:32 +08:00
fb81b516da Merge branch 'bugfix/btdm_revert_changes_of_security_mask_v4.0' into 'release/v4.0'
components/bt: Revert changes of security mask

See merge request espressif/esp-idf!7119
2019-12-29 21:38:09 +08:00
d93bff2699 components/bt: Revert changes of security mask 2019-12-29 06:29:23 +00:00
03addfb0c5 Merge branch 'bugfix/legacy_msys2_environment_v4.0' into 'release/v4.0'
doc: Update the legacy MSYS2 environment to use 2019r2 toolchain version (v4.0)

See merge request espressif/esp-idf!7078
2019-12-27 23:29:13 +08:00
0631d185bd esp_wifi: fix a WiFi receiving bug
Support WiFi/BT MAC register writting when the WiFi/BT common clock is disabled.
2019-12-26 19:41:04 +08:00
65cfbbda52 Merge branch 'bugfix/touchpad_interrupt' into 'release/v4.0'
Change critical section API for touch pad interrupt

See merge request espressif/esp-idf!7100
2019-12-24 19:51:49 +08:00
6a18a33bad esp_ringbuf: add documents for SendAcquire and SendComplete 2019-12-24 17:46:53 +08:00
6f6677ac42 spi: move deprecated functions into internal header
Resolves https://github.com/espressif/esp-idf/issues/4132
2019-12-24 17:43:32 +08:00
0e623d4dbf esp32/rtc_module: Fixed critical section API
Application used to abort as portENTER_CRITICAL is used in ISR.
portENTER_CRITICAL is changed to portENTER_CRITICAL_SAFE in touch_pad_clear_status()

https://github.com/aws/amazon-freertos/issues/1651
2019-12-24 14:52:54 +05:30
d41c020649 Merge branch 'bugfix/fix_ble_mesh_adv_buf_unref_v4.0' into 'release/v4.0'
ble_mesh: Fix adv buf unref and link_id in exceptional list (v4.0)

See merge request espressif/esp-idf!7080
2019-12-22 16:02:24 +08:00
b261647835 Merge branch 'bugfix/ble_mesh_client_check_remain_time_v4.0' into 'release/v4.0'
ble_mesh: Client model check timer remaining time (v4.0)

See merge request espressif/esp-idf!7074
2019-12-22 15:59:34 +08:00
lly
53e6eb8467 ble_mesh: Fix using wrong name for PB-GATT 2019-12-20 17:13:20 +08:00
lly
ebaa3e1c3e ble_mesh: Fix adv buf unref and link_id in exceptional list 2019-12-20 17:13:15 +08:00
66889332ce doc: Update the legacy MSYS2 environment to use 2019r2 toolchain version
As reported at https://www.esp32.com/viewtopic.php?p=52805
2019-12-20 19:29:57 +11:00
lly
23770edb43 ble_mesh: Add unlock when failed to create alarm 2019-12-20 15:34:10 +08:00
lly
6ea738eeb0 ble_mesh: Rename ble mesh lock/unlock functions
Rename BLE Mesh internal lock/unlock functions, also seperate
the list, buf and atomic lock/unlock functions
2019-12-20 15:34:06 +08:00
lly
3e6d04fc86 ble_mesh: Use mutex to protect client list operations 2019-12-20 15:34:01 +08:00
lly
9dc45e788d ble_mesh: Remove useless parameters of lock/unlock 2019-12-20 15:33:56 +08:00
lly
bf712e4f91 ble_mesh: Client model check timer remaining time
Before handling status message, client models need check if the
corresponding timer has expired. And if timeout happens, the
status message will be treated as a publish message.
2019-12-20 15:33:50 +08:00
83813f830d Merge branch 'bugfix/menuconfig_confirm_v4.0' into 'release/v4.0'
Menuconfig: Don't ask to save configuration when nothing has changed (backport v4.0)

See merge request espressif/esp-idf!6813
2019-12-20 13:11:00 +08:00
b0d6c01b04 Merge branch 'bugfix/btdm_fix_doc_and_host_bug_backport_v4.0' into 'release/v4.0'
Bugfix/btdm fix doc and host bug backport v4.0

See merge request espressif/esp-idf!6954
2019-12-18 14:19:30 +08:00
f955c49423 Bugfix/btdm fix doc and host bug backport v4.0 2019-12-18 14:19:27 +08:00
1b15e6cf56 Merge branch 'bugfix/nvs_flash_missing_tests' into 'release/v4.0'
nvs: Added nvs tests, minor corrections (backport v4.0)

See merge request espressif/esp-idf!6987
2019-12-18 11:38:08 +08:00
1ad1e70077 Merge branch 'feature/can_support_low_bit_rates_backport_v4.0' into 'release/v4.0'
can: Add support for lower bit rates (backport v4.0)

See merge request espressif/esp-idf!6392
2019-12-18 07:46:06 +08:00
d8665e5343 Merge branch 'bugfix/doc_fix_debian_requirements_v4.0' into 'release/v4.0'
Docs: Update Debian & Ubuntu install prerequisites (v4.0)

See merge request espressif/esp-idf!7036
2019-12-18 07:35:42 +08:00
46cb254f21 Docs: Update Debian & Ubuntu install prerequisites
Latest versions of apt-get don't install as much packages by default
as older ones. This fix adds some missing packages discovered for an OS
derived from the latest stable Debian. These packages exist for older
Debian derivatives as well (tested with Ubuntu 16.04 LTS).

Closes https://github.com/espressif/esp-idf/issues/4480
2019-12-17 13:38:22 +01:00
20e6d46d44 Merge branch 'bugfix/esp_timer_set_alarm_v4.0' into 'release/v4.0'
esp_timer: Fix set_alarm. Case when timestamp < now_time (v4.0)

See merge request espressif/esp-idf!6988
2019-12-16 19:37:59 +08:00
a89decd3c1 Merge branch 'demo-hfp-client-v4.0' into 'release/v4.0'
component_bt/: Add HFP HF Unit Example

See merge request espressif/esp-idf!7023
2019-12-16 19:36:40 +08:00
1e7933049d Add HFP Unit example code. 2019-12-16 17:18:51 +08:00
626c58fc67 Merge branch 'bugfix/btdm_avrc_metadata_length_error_v4.0' into 'release/v4.0'
components/bt: Fix AVRC metadata length error

See merge request espressif/esp-idf!6880
2019-12-16 16:13:32 +08:00
03d5742e11 can: Add support for lower bit rates
This commit adds support for lower bit rates in the CAN Driver for
ESP32 Rev 2 or later chips.
2019-12-16 07:45:38 +00:00
3c081abb32 Merge branch 'feature/hwcrypto_perf_ut_v4.0' into 'release/v4.0'
mbedtls: enable HW SHA by default, add SHA performance test (backport v4.0)

See merge request espressif/esp-idf!6668
2019-12-16 14:24:25 +08:00
482d2f06c3 Merge branch 'ci/artifact_expiry_v4.0' into 'release/v4.0'
ci: Keep build artifacts for 4 days (v4.0)

See merge request espressif/esp-idf!6994
2019-12-16 14:23:44 +08:00
4ffa3dbffb Merge branch 'bugfix/libc_link_issues_v4.0' into 'release/v4.0'
newlib: fix linking issues (fcntl, system, raise) (backport v4.0)

See merge request espressif/esp-idf!7000
2019-12-16 14:16:56 +08:00
bf0863a50a mbedtls: Enable SHA hardware acceleration by default 2019-12-15 20:46:20 +00:00
20d435c561 mbedtls: add SHA performance test
Results with this revision:

SHA256 rate 2.599MB/sec Debug 240MHz SW
SHA256 rate 1.147MB/sec Release 80MHz SW
SHA256 rate 3.469MB/sec Release 240MHz SW
SHA256 rate 2.687MB/sec Release 240MHz SW + PSRAM workaround

SHA256 rate 9.433MB/sec Debug 240MHz HW rev1
SHA256 rate 3.727MB/sec Release 80MHz HW rev1
SHA256 rate 10.961MB/sec Release 240MHz HW rev1
SHA256 rate 9.966MB/sec Release 240MHz HW rev1 + PRAM workaround

SHA256 rate 10.974MB/sec Debug 240MHz HW rev3
SHA256 rate 4.362MB/sec Release 80MHz HW rev3
SHA256 rate 13.207MB/sec Release 240MHz HW rev3

Debug = Og, assertions enabled
Release = O2, assertions disabled
2019-12-15 20:46:20 +00:00
a82215d161 components/bt: Fix AVRC metadata length error 2019-12-14 05:48:26 +00:00
dcbcb5fe58 esp_timer: Add Test case when set_alarm needs set timer < now_time 2019-12-14 04:46:27 +08:00
23e6b47a28 esp-tls: check return value of fcntl 2019-12-13 14:12:36 +00:00
85656ca77d newlib: define fcntl as strong symbol
Closes https://github.com/espressif/esp-idf/issues/3694
Closes https://github.com/espressif/esp-idf/issues/4407
2019-12-13 14:12:36 +00:00
6f0f5d79f9 newlib: add definitions of system, raise
Closes IDF-1220
Closes IDFGH-1811
Closes https://github.com/espressif/esp-idf/pull/4020
2019-12-13 14:12:36 +00:00
314a0443ad nvs: Added nvs tests, minor corrections
* closes IDF-1135:
  same namespace was used in different tests which
  could lead to conflicts when re-running tests
* removes duplicated functions declarations
* correct argument order for test case macros
2019-12-13 17:06:27 +08:00
3ba9eae86c Merge branch 'feature/ci_optimize_artifact_download_v4.0' into 'release/v4.0'
CI: optimize example build and artifact download (backport v4.0)

See merge request espressif/esp-idf!6940
2019-12-13 11:36:04 +08:00
a8e01de0e4 ci: Keep build artifacts for 4 days 2019-12-12 06:30:13 +00:00
0104a24a36 Merge branch 'bugfix/server_down_message_v4.0' into 'release/v4.0'
tools: Produce user friendly error during install when the server is down (v4.0)

See merge request espressif/esp-idf!6958
2019-12-12 08:12:36 +08:00
643757bfad Merge branch 'bugfix/doc_package_versions_v4.0' into 'release/v4.0'
doc: Limit sphinxcontrib versions to <2.0.0 as we use Sphinx 1.8.5 (v4.0)

See merge request espressif/esp-idf!6974
2019-12-12 06:31:07 +08:00
30ac846112 Merge branch 'bugfix/cmake_secure_boot_v4.0' into 'release/v4.0'
secure boot: CMake bug fixes (v4.0)

See merge request espressif/esp-idf!6630
2019-12-12 06:30:37 +08:00
8e54ee3f16 esp_timer: Fix set_alarm. Case when timestamp < now_time
arg1 = MAX(int64_t arg1, uint64_t arg2) gave the wrong result, if arg1 < 0, it was presented as a larger value.
And ALARM_REG = (uin32_t)arg1. This leads to an infinite loop.
Fixed: both args are int64_t.

Closes: WIFI-1511
2019-12-11 19:28:20 +08:00
ba11fed9c1 Merge branch 'bugfix/mesh_stop_recv_crash_4.0' into 'release/v4.0'
Bugfix/mesh stop recv crash 4.0

See merge request espressif/esp-idf!6948
2019-12-11 19:25:36 +08:00
bf01dd61f7 Merge branch 'doc/update_several_ble_mesh_docs_v4.0' into 'release/v4.0'
doc: update ble mesh docs based on the feature and example update (v4.0)

See merge request espressif/esp-idf!6966
2019-12-11 19:00:20 +08:00
ee6ba0eb47 mesh: fix mesh stop recv crash 2019-12-11 05:54:39 +00:00
45a50ed701 test: fix incorrect error type in xunit result 2019-12-11 15:57:49 +11:00
fd481d9cdd ci: fix fetch submodule error on python3 2019-12-11 15:57:49 +11:00
ec8e057e4c ci: remove dependencies from link_check job 2019-12-11 15:57:49 +11:00
510ec904c9 spi_flash tests: Fix exclusion of new API tests in legacy mode 2019-12-11 15:57:49 +11:00
fbdedee4cb ci: reduce number of unit test cases 2019-12-11 15:57:49 +11:00
f8e1ee35e2 soc: fix unit tests not included in the build
Regression from 9eccd7c082
2019-12-11 15:57:49 +11:00
06aa755265 ci: unit test use binary to built by cmake 2019-12-11 15:57:49 +11:00
48786c1da0 CI: remove not exist file from executable-list.txt 2019-12-11 15:57:49 +11:00
e9be102224 CI: build system do not check submodule for CI 2019-12-11 15:57:49 +11:00
3691ebc273 CI: modify fetch submodule method:
download archive for submodules instead of clone
2019-12-11 15:57:49 +11:00
31b9329d36 CI: raise import error instead of exit for ble tools 2019-12-11 15:57:49 +11:00
d00acce7b2 CI: support only download artifacts by request:
use CI dependencies could waste a lot bandwidth for target test jobs, as
example binary artifacts are very large. Now we will parse required
artifacts first, then use API to download required files in artifacts.
2019-12-11 15:57:49 +11:00
6e05a79536 test: update example and unit tests with new import roles:
tiny_test_fw is a python package now. import it using normal way.
2019-12-11 15:57:49 +11:00
978bf09f83 CI: add utility gitlab_api 2019-12-11 15:57:49 +11:00
7a5d17e1b7 tiny-test-fw: move to tools/esp_python_packages:
make `tiny_test_fw` as a package and move to root path of idf python
packages
2019-12-11 15:57:49 +11:00
d3e0301aee tiny-test-fw: only load module from the same file one time:
we should only load one module once.
if we load one module twice, python will regard the same object loaded in the first time and second time as different objects.
it will lead to strange errors like `isinstance(object, type_of_this_object)` return False
2019-12-11 15:57:49 +11:00
69c0e6243e unit-test-app: fix test script error when handling multiple unit test configs in one config file:
If we have multiple configs, we need to flash DUT with different binaries. But if we don't close DUT before apply new config, the old DUT will be reused, so new config name will not be applied.
2019-12-11 15:57:49 +11:00
cffe7bf3a1 ci: use more flexible assign for unit test cases 2019-12-11 15:57:49 +11:00
1041bc800c unit-test-app: print config name in test script 2019-12-11 15:57:49 +11:00
dd74a331c7 tiny-test-fw: print useful debug info when assign test:
* total requirements (number of required jobs vs tags)
* unused CI jobs
* missing jobs (number of missing jobs vs tags)
2019-12-11 15:57:49 +11:00
6ee7492512 ci: optimize unit test assignment:
Currently we use config and test function as filter when assign cases to one CI job. It's not necessary as the runner can run test with different configs / test functions. Now we will try to assign as many cases to a job as possible, to reduce the amount of jobs required.
2019-12-11 15:57:49 +11:00
9bf656e12e examples: fix sdkconfig warnings 2019-12-11 15:57:49 +11:00
6ae4c29191 examples: update wifi/iperf to use the new builder 2019-12-11 15:57:49 +11:00
3fcecdd12e ci: don't add build_examples_make as a target_test dependency 2019-12-11 15:57:49 +11:00
f3c8907cef ci: reimplement build_examples_cmake using {find,build}_apps.py 2019-12-11 15:57:49 +11:00
7db756fbd9 tiny-test-fw: add build config and target options 2019-12-11 15:57:49 +11:00
1d72766f1a tools: add build warnings checking script 2019-12-11 15:57:49 +11:00
5d03ae7428 tools: add {find,build}_apps.py, scripts to build multiple apps
This commit adds a pair of scripts, find_apps.py and build_apps.py.
These scripts are intended to be used in various CI jobs, building
multiple applications with different configurations and targets.

The first script, find_apps.py, is used to prepare the list of builds:
1. It finds apps for the given build system.
2. For each app, it finds configurations (sdkconfig files) which need
   to be built.
3. It filters out the apps and configurations which are not compatible
   with the given target.
4. It outputs the list of builds into stdout or a file. Currently the
   format is a list of lines, each line a JSON string. In the future,
   the tool can be updated to output YAML files.

The lists of builds can be concatenated and processed with standard
command line tools, like sed.

The second script, build_apps.py, executes the builds from the list.
It can execute a subset of builds based on --parallel-count and
--parallel-index arguments.

These two scripts are intended to replace build_examples_make,
build_examples_cmake, and the custom unit-test-app logic (in the
Makefile and idf_ext.py).

Closes IDF-641
2019-12-11 15:57:49 +11:00
bfbc10e2d8 lw-ip: silence a warning related to CONFIG_LWIP_TCP_WND_DEFAULT value 2019-12-11 15:57:49 +11:00
1fd0e6f482 doc: Limit sphinxcontrib versions to <2.0.0 as we use Sphinx 1.8.5 2019-12-11 14:39:09 +11:00
21995978e1 Merge branch 'optimize_tcp_random_close_for_4.0' into 'release/v4.0'
optimize tcp random close for v4.0

See merge request espressif/esp-idf!6949
2019-12-10 16:47:36 +08:00
lly
e0b6ad0d1a doc: update ble mesh docs based on the feature and example update 2019-12-10 14:02:20 +08:00
2b5a8fe5ea optimize tcp random close for v4.0 2019-12-10 11:53:22 +08:00
bb7e52a4a8 tools: Produce user friendly error during install when the server is down
Closes https://github.com/espressif/esp-idf/issues/4329
2019-12-09 15:51:38 +01:00
c0597aaf69 Merge branch 'bugfix/phy_critical_v4.0' into 'release/v4.0'
fix bug that phy_enter_critical cannot effect on dual-core

See merge request espressif/esp-idf!6941
2019-12-09 14:17:54 +08:00
87c30adfed Merge branch 'bugfix/coex_fix_wifi_scan_and_connect_bugs_v4.0' into 'release/v4.0'
esp_wifi: fix WiFi scan and connect bugs when coexist with Bluetooth

See merge request espressif/esp-idf!6939
2019-12-09 13:43:46 +08:00
3636bf5813 Merge branch 'bugfix/update_libexpat_v4.0' into 'release/v4.0'
expat: Update library from 2.2.5 to 2.2.9 (v4.0)

See merge request espressif/esp-idf!6921
2019-12-09 13:21:28 +08:00
ea2959af36 fix bug that phy_enter_critical cannot effect on dual-core
Sometimes, libphy.a call phy_enter_critical() to protect accessing
critical sections, such like operating on I2C, but it may not effect
when both the CPU core call it. It may cause accessing I2C blocking
and cannot recover by esp_restart(), until do HW reboot.
2019-12-09 12:45:52 +08:00
585654388f Merge branch 'bugfix/improve_lwip_performance_v4.0' into 'release/v4.0'
LW-IP: fix bug for performance lose when update lw-ip to 2.1.2

See merge request espressif/esp-idf!6938
2019-12-09 12:42:04 +08:00
939d5a0f6a esp_wifi: fix WiFi scan and connect bugs when coexist with Bluetooth
1. Fix WiFi scan leads to poor performance of Bluetooth.
2. Improve WiFi connect success ratio when coexist with Bluetooth.
3. Check if WiFi is still connected when CSA or beacon timeout happen.
4. add coex pre init
2019-12-09 12:17:16 +08:00
4d3c650b49 Merge branch 'bugfix/macos_link_toomany_open_files_v4.0' into 'release/v4.0'
build system: explicitly disable LTO plugin to reduce the number of simultaneously open files (backport v4.0)

See merge request espressif/esp-idf!6867
2019-12-09 06:19:30 +08:00
2318e6828d Merge branch 'Bugfix/add_netif_assert' into 'release/v4.0'
fix bug for netif add crash

See merge request espressif/esp-idf!6895
2019-12-07 17:33:39 +08:00
262acbc0a8 fix bug for improve performance 2019-12-07 16:16:57 +08:00
2b2f0d0f28 Merge branch 'feature/reorganise_bluetooth-bluedroid-hci_v4.0' into 'release/v4.0'
Moved HCI examples from bluetooth/bluedroid/hci to bluetooth/hci. (v4.0)

See merge request espressif/esp-idf!6915
2019-12-06 12:09:16 +08:00
2887131b39 Changes in menuconfig options to not compile any host when using hci
examples as no host is required there.
2019-12-06 12:09:16 +08:00
104299353d fix bug for netif add crash 2019-12-06 10:54:12 +08:00
19d394a366 Merge branch 'bugfix/ramdom_tcp_crash_for_4.0' into 'release/v4.0'
fix bug for random tcp close for 4.0

See merge request espressif/esp-idf!6841
2019-12-05 20:27:39 +08:00
e4312f8ab5 fix bug for random tcp close for 4.0 2019-12-05 18:41:42 +08:00
1930c56bd2 Merge branch 'bugfix/lwip_rx_buff_free_v4.0' into 'release/v4.0'
lw-IP: Adapted lw-ip port layer to use 2.1.2-esp in 4.0 (v4.0)

See merge request espressif/esp-idf!6857
2019-12-05 18:39:38 +08:00
5e67f9578d lwip: Adapted lwip port layer to use 2.1.2-esp in 4.0 2019-12-05 16:24:04 +08:00
46a172178a expat: Update library from 2.2.5 to 2.2.9 2019-12-05 09:17:39 +01:00
e6006a6bdf Merge branch 'bugfix/remove_mbedtls_would_block_v40' into 'release/v4.0'
Remove check for would_block in mbedtls (Backport v4.0)

See merge request espressif/esp-idf!6913
2019-12-05 07:37:15 +08:00
a5b803540a Merge branch 'bugfix/btdm_allow_start_adv_again_v4.0' into 'release/v4.0'
component/bt: allow to send stop adv again and fix tx prog crash(backport v4.0)

See merge request espressif/esp-idf!6653
2019-12-04 20:24:07 +08:00
673ccaa1e5 Remove check for would_block in mbedtls
Basically, in the portability layer, it is checked if the socket is
NON-block, and if not, then even the EAGAIN and EWOULDBLOCK errors are
diverted to a RECV error. This causes a problem for sockets with
receive timeouts set. When such a timeout is set, the condition for
NON_BLOCK isn't met and hence a hard error is returned.

Searching for EAGAIN and EWOULDBLOCK in lwip returns only 3 results
(accept, recvfrom, close) and all of them look to be genuine cases for
EWOULDBLOCK. So removing this check to make receive timeout with TLS
work.
2019-12-04 17:28:15 +05:30
08e55b8a66 Merge branch 'bugfix/ethernet_add_reference_counter_v4.0' into 'release/v4.0'
ethernet: add reference counter v4.0 (v4.0)

See merge request espressif/esp-idf!6780
2019-12-04 14:59:45 +08:00
0508ad525a ethernet: add pm lock 2019-12-03 17:37:45 +08:00
97defec6cd ethernet:a bunch of bugfix from master 2019-12-03 17:37:35 +08:00
96e6049dab ethernet:add start stop control 2019-12-03 17:36:48 +08:00
37154d4c08 ethernet:add reference counter 2019-12-03 15:53:39 +08:00
14dd44c05f doc: move common Ethernet config explanation into a single file 2019-12-03 15:53:39 +08:00
42a462d584 ethernet: add gpio number into config structure 2019-12-03 15:53:39 +08:00
c68bd605f8 Merge branch 'bugfix/idf_tool_git_worktree_v4.0' into 'release/v4.0'
tools: Don't use git work-tree in idf_tools.py and try to parse IDF version from C header (v4.0)

See merge request espressif/esp-idf!6821
2019-12-03 09:22:29 +08:00
f37837f785 Merge branch 'NimBLE/fix_send_after_controller_ready_v4.0' into 'release/v4.0'
NimBLE: Fix erroneous behaviour of NPL when controller not ready to receive (Backport v4.0)

See merge request espressif/esp-idf!6793
2019-12-01 17:53:50 +08:00
69c86bc37e NimBLE: Fix erroneous behaviour of NPL when controller not ready to receive (Backport v4.0) 2019-12-01 17:53:49 +08:00
14f1a30e38 build system: move -fno-rtti link option next to the compile option
Previous commit has added `link_options` to the root CMakeLists.txt,
can use it to collect such global link options now.
2019-11-28 11:02:30 +01:00
afeed3cc6f build system: explicitly disable LTO plugin
... to reduce the number of simultaneously open files at link time.

When plugin support is enabled in the linker, BFD's (and the
corresponding file handles) are cached for the plugin to use. This
results in quite a large number of simultaneously open files, which
hits the default limit on macOS (256 files).

Since we aren't using LTO now, disable it explicitly when invoking the
linker.

Closes IDF-923
Closes IDFGH-1764
Closes https://github.com/espressif/esp-idf/issues/3989
2019-11-28 11:02:18 +01:00
139913baa2 Merge branch 'bugfix/config_assert_thread_safety_backport_v4.0' into 'release/v4.0'
freertos: Fix configASSERT thread safety (backport v4.0)

See merge request espressif/esp-idf!6662
2019-11-28 11:51:13 +08:00
e324013ed6 Merge branch 'bugfix/hfp_client_indication_v4.0' into 'release/v4.0'
component/bt: Fix bugs in HFP feature v4.0

See merge request espressif/esp-idf!6851
2019-11-27 22:49:03 +08:00
8d189d9fb4 component/bt: allow adv stop again when adv is already stoped and fix crash when tx prog sometimes 2019-11-27 20:15:08 +08:00
e7a6fdca54 component/bt: Fix bugs in HFP feature 2019-11-27 16:48:26 +08:00
48dfbe05a4 Merge branch 'fixed_queue_v4.0' into 'release/v4.0'
component_bt/: Fix_pointer_type_fixed_queue v4.0

See merge request espressif/esp-idf!6846
2019-11-27 16:39:51 +08:00
5d00321d07 fix_pointer_type_fixed_queue 2019-11-27 15:06:15 +08:00
2e8ad19e35 Merge branch 'bugfix/ble_mesh_device_with_wrong_name_on_ios_v4.0' into 'release/v4.0'
ble_mesh: fix ble mesh device with wrong name on iOS (v4.0)

See merge request espressif/esp-idf!6521
2019-11-27 10:31:01 +08:00
c45830d03f tools: Don't use git work-tree in idf_tools.py
Closes https://github.com/espressif/esp-idf/issues/4355
2019-11-26 08:56:34 +01:00
7725ce4999 Merge branch 'fix/esp_flash_no_qe_4.0' into 'release/v4.0'
esp_flash: fix the QE write issue in high freq, and support UT for external chips (backport v4.0)

See merge request espressif/esp-idf!6423
2019-11-26 11:34:14 +08:00
97488fe806 Menuconfig: Don't ask to save configuration when nothing has changed
Closes https://github.com/espressif/esp-idf/issues/4303
2019-11-25 11:29:58 +01:00
e3f0854771 Merge branch 'bugfix/fix_timer_deleted_and_run_broken_callback_v4.0' into 'release/v4.0'
esp_timer: fix the bug that when timeout of timer happens try to run callback(v4.0)

See merge request espressif/esp-idf!6769
2019-11-22 17:38:06 +08:00
b5d04a21fb esp_flash: fix the quad issue for some GD flash chips
The GD flash with product ID 40H, is already used in Wrover-nosufix modules.
2019-11-21 12:26:15 +08:00
337b1df430 esp_flash: add unit test for external flash and QE toggling
Tests for external flash chips used to controlled by macros, one bin for
one chip. And tests are done manually. This commit refactored the test
so that all 3 chips can all run in single test.
2019-11-21 12:26:15 +08:00
41e64bd79c esp_flash: rename internal variables for better readability
chip_drv in HAL are renamed as host
2019-11-21 12:26:14 +08:00
2b7681ec4f esp_flash: fix set qe bit and write command issues
There used to be dummy phase before out phase in common command
transactions. This corrupts the data.

The code before never actually operate (clear) the QE bit, once it finds
the QE bit is set. It's hard to check whether the QE set/disable
functions work well.

This commit:

1. Cancel the dummy phase

2. Set and clear the QE bit according to chip settings, allowing tests
   for QE bits. However for some chips (Winbond for example), it's not
   forced to clear the QE bit if not able to.

3. Also refactor to allow chip_generic and other chips to share the same
   code to read and write qe bit; let common command and read command share
   configure_host_io_mode.

4. Rename read mode to io mode since maybe we will write data with quad
   mode one day.
2019-11-21 12:26:14 +08:00
668c0dfb9b Merge branch 'bugfix/idfpy_before_flash_option_v4.0' into 'release/v4.0'
idf.py: Add --before flag to esptool.py call (v4.0)

See merge request espressif/esp-idf!6625
2019-11-21 06:40:14 +08:00
0b0f8d6d6c Merge branch 'feature/windows_ccache_enable_v4.0' into 'release/v4.0'
tools: export IDF_CCACHE_ENABLE on Windows by default (backport v4.0)

See merge request espressif/esp-idf!6664
2019-11-21 06:39:27 +08:00
a8f956e590 Merge branch 'bugfix/warning_fix_latest_freertos_v4.0' into 'release/v4.0'
Fixed warnings for components driver, esp32 and mbedtls (v4.0)

See merge request espressif/esp-idf!6759
2019-11-20 12:20:02 +08:00
3b879ce8c3 Merge branch 'bugfix/put_more_rx_code_to_iram_v4.0' into 'release/v4.0'
Put some rx code to iram (backport v4.0)

See merge request espressif/esp-idf!6492
2019-11-20 11:19:20 +08:00
5102308b2b esp_timer: fix the bug that when timeout of timer happens try to run callback, and high priority task delete the timer and break the callback 2019-11-19 22:51:28 +08:00
f95a723412 Fixed warnings for components driver, esp32 and mbedtls 2019-11-19 15:02:02 +05:30
88cbc26f4d Merge branch 'bugfix/btdm_run_out_of_frame_element_v4.0' into 'release/v4.0'
components/bt: Fix assert due to no free element form

See merge request espressif/esp-idf!6700
2019-11-19 17:01:32 +08:00
1b53af2e88 freertos: modify configASSERTs around scheduler state check
Regression introduced in commit 79e74e5d5f

It is possible that some FreeRTOS APIs are invoked prior to
scheduler start condition (e.g. flash initialization in unicore mode).
In that condition these asserts should not trigger (scheduler state being yet to be started),
hence changes per this fix.
2019-11-19 04:42:27 +00:00
376107b2ae freertos: Fix configASSERT thread safety
This commit fixes thread safety issues with configASSERT() calls
regarding the value of uxSchedulerSuspended. A false negative
occurs if a context switch to the opposite core occurs in between
the getting the core ID and the assesment.

Closes https://github.com/espressif/esp-idf/issues/4230
2019-11-19 04:42:27 +00:00
c9294aff6f Merge branch 'bugfix/btdm_disable_some_secrity_mask_v4.0' into 'release/v4.0'
components/bt: Disable some unsupported security mask

See merge request espressif/esp-idf!6725
2019-11-19 12:15:36 +08:00
99fb9a3f7c Merge branch 'bugfix/miscellaneous_cmake_fixes' into 'release/v4.0'
CMake bugfixes

See merge request espressif/esp-idf!6654
2019-11-19 06:52:07 +08:00
e5773cc2fe esp_wifi: Put some rx code to iram and update phy4180 2019-11-18 02:54:46 +00:00
4e6c575fed Merge branch 'feature/add_env_tag_for_32khz_xtal_uts_v4.0' into 'release/v4.0'
soc(esp32&esp32s2beta): Add test_env for 32kHz XTAL unit tests (v4.0)

See merge request espressif/esp-idf!6603
2019-11-18 10:44:20 +08:00
8353ecdf36 components/bt: Disable some unsupported security mask 2019-11-17 13:45:32 +08:00
5bb0b39700 ci: Add test configs for 32kHz crystals 2019-11-16 17:06:14 +08:00
9214c887f7 Merge branch 'bugfix/asio_examples_v4.0' into 'release/v4.0'
asio: fix asio test code to start the test after ip address received from common example code (v4.0)

See merge request espressif/esp-idf!6699
2019-11-15 23:50:22 +08:00
ebc2e7bce0 Merge branch 'fix/NimBLE_protocomm_mngr' into 'release/v4.0'
NimBLE: Fix bug in `protocomm_nimble` chararcteristic access callback (release/v4.0)

See merge request espressif/esp-idf!6703
2019-11-15 19:11:19 +08:00
065e386c57 Merge branch 'bugfix/fix_the_bug_in_espnow_example_v4.0' into 'release/v4.0'
espnow: fix the bug for calling esp_wifi_set_channel (backport v4.0)

See merge request espressif/esp-idf!6692
2019-11-14 19:26:29 +08:00
c595b2fa8c NimBLE: Fix bug in protocomm_nimble chararcteristic access callback (release/v4.0)
Fixes bug in `protocomm_nimble` while writing to characteristic with length greater than MTU value.
2019-11-14 15:24:47 +05:30
lly
eb95bc68c4 ble_mesh: fix ble mesh device with wrong name on iOS 2019-11-14 16:56:34 +08:00
2b208eecde Merge branch 'feat/ble_mesh_4_1_new_features_v4.0' into 'release/v4.0'
ESP BLE Mesh new features (v4.0)

See merge request espressif/esp-idf!6698
2019-11-14 16:48:44 +08:00
f9f49107ca components/bt: Fix assert due to no free element form 2019-11-14 15:20:54 +08:00
fae116bb2e soc/esp32: Add test_env for 32kHz XTAL unit tests 2019-11-14 12:26:43 +08:00
8d90156c07 asio: fix asio test code to start the test after ip address received from common example code
Previously set to wait until IP address got from tcpip_adapter, but since common example connect code blocks until both IP4 and IPv6 address received it could happen that test code might have started connection to the ASIO counter-part while ESP32 still waiting for IPv6 address
2019-11-14 12:12:15 +08:00
lly
f22d46515b ble_mesh: miscellaneous modifications
1. Clean up client_common.c
2. Clean up esp_ble_mesh directory
3. Update Kconfig.in
4. Format esp_ble_mesh files
2019-11-14 11:59:21 +08:00
lly
27cb3d7f72 ble_mesh: adapt ble mesh with nimble host 2019-11-14 10:42:30 +08:00
lly
e0e62232e0 ble_mesh: update ble mesh examples 2019-11-14 10:42:16 +08:00
lly
a302d210b9 ble_mesh: add events for configuration server model 2019-11-14 10:39:55 +08:00
lly
a32c72a1b2 ble_mesh: add Generic/Sensor/Time and Scenes/Lighting Server models 2019-11-14 10:39:49 +08:00
lly
f1850b54f3 ble_mesh: add proxy client functionality 2019-11-14 10:39:40 +08:00
lly
c85abf87b5 ble_mesh: add ble mesh friend node event 2019-11-14 10:39:17 +08:00
lly
9029ccd21b ble_mesh: add low power node api and event 2019-11-14 10:39:13 +08:00
lly
eaeb36375a ble_mesh: add heartbeat message recv callback 2019-11-14 10:39:08 +08:00
lly
805bc06127 ble_mesh: modify health server model callbacks 2019-11-14 10:39:04 +08:00
lly
4702cd1b51 ble_mesh: add separate advertising buffers for relay packets 2019-11-14 10:38:59 +08:00
720528ef11 Merge branch 'feature/nimble_host_esp_ble_mesh_v4.0' into 'release/v4.0'
components/bt: Add support of NimBLE host in ESP BLE Mesh (backport v4.0)

See merge request espressif/esp-idf!6619
2019-11-13 21:32:23 +08:00
d934badaa7 espnow: fix the bug for calling esp_wifi_set_channel(), this function only can be called after Wi-Fi started and sniffer enabled. 2019-11-13 17:37:26 +08:00
35b91ebf2d Merge branch 'bugfix/dockerfile_set_idf_branch_v4.0' into 'release/v4.0'
tools/docker: use correct branch and commit of IDF when building (backport v4.0)

See merge request espressif/esp-idf!6665
2019-11-13 16:25:53 +08:00
6c7f72cc1b Merge branch 'bugfix/http_client_buffer_overflow_v4.0' into 'release/v4.0'
Fix HTTP client buffer overflow (v4.0)

See merge request espressif/esp-idf!6666
2019-11-13 16:24:51 +08:00
7061c8aec2 Merge branch 'bugfix/mdns_invalid_hostname_queries_v4.0' into 'release/v4.0'
mdns: fix crash for hostname queries (backport v4.0)

See merge request espressif/esp-idf!6504
2019-11-13 16:19:19 +08:00
3ba8ae7a62 http_client: added comments to http header generation function 2019-11-12 09:59:50 +01:00
2c27c55679 http_client: possible buffer overflow fixed when determining last header item to be written
closes IDF-694
2019-11-12 09:59:50 +01:00
68ad6ad63a tools/docker: use correct branch and commit of IDF when building 2019-11-12 09:57:15 +01:00
981b2496cb tools: export IDF_CCACHE_ENABLE on Windows by default 2019-11-12 09:54:57 +01:00
077b727608 Merge branch 'bugfix/backport_some_wifi_fixes_1009_v4.0' into 'release/v4.0'
esp_wifi: fix some WiFi bugs 1009 (backport v4.0)

See merge request espressif/esp-idf!6299
2019-11-12 11:27:40 +08:00
79f36e85d5 Merge branch 'fix/ci_ut_psram_wroverb_v4.0' into 'release/v4.0'
ci: fix one ut issue when using Wrover-B module with newer ver of PSRAM (backport v4.0)

See merge request espressif/esp-idf!6592
2019-11-11 18:38:53 +08:00
d49077c13b spiffs: fix build issue on clean project
From issue:

I did some poking around in components/spiffs/project_include.cmake and
it looks like what is failing is it isn't getting an offset from
parttool.py. I think what the problem is that the parttool.py cannot
determine the offset of the storage partition as I can't run menuconfig
to set the custom partitions.

I have tested that this problem is solvable by manually setting the
custom partitions in sdkconfig and that is a workaround but there should
be at least a better error message in the configuration when it cannot
find the partition as this would also happen if the partition name was
misspelled.

Closes https://github.com/espressif/esp-idf/issues/4236
2019-11-11 18:11:12 +08:00
0c2202ef3e examples: fix idf as library example build on macOS
GCC prefixes underscore on symbol names on macOS, and so the set
undefined symbol `-u app_main` won't work. However, this is unecessary,
as the source file that defines it is specified directly to the
executable, and not through a static library.

Closes https://github.com/espressif/esp-idf/issues/4168
2019-11-11 18:09:52 +08:00
e4137cc6ca cmake: support git worktree
Use rev-parse to get the HEAD directory instead of manually looking for
it. This method works in the main repository, worktrees and submodules.

Closes https://github.com/espressif/esp-idf/issues/4136
2019-11-11 18:09:15 +08:00
308e4fcce1 cmake: do not check if sdkconfig exists 2019-11-11 18:06:48 +08:00
a6d40e3583 docs: cmake docs fixes 2019-11-11 18:05:35 +08:00
95b5745c3c cmake: treat unregistered components as unresolved 2019-11-11 18:03:26 +08:00
bc3134594d esptool_py: add missing phony build targets for CMake
Adds targets erase_flash and monitor for users not using idf.py.
Closes https://github.com/espressif/esp-idf/issues/2420.
2019-11-11 18:02:32 +08:00
8300945189 cxx: force pthread to appear later in link line 2019-11-11 18:01:45 +08:00
c9ca3a05fc docs: fix typo of build component aliases name 2019-11-11 18:01:00 +08:00
ecce2bc926 cmake: introduce BUILD_COMPONENT_ALIASES
This commit makes it so that BUILD_COMPONENT holds only the component,
and a new property BUILD_COMPONENT_ALIASES hold the full name of the
component.

This also removes erroneous check for duplicate components, as this can
never happen:

(1) if two components have the same name but different prefixes,
the internal names are still unique between them

(2)if two components happen to have the same name and same prefix, the
latter would override the former
2019-11-11 18:01:00 +08:00
b69898257a cmake: make build components available before immediately
Previous implementation only builds list of components included in the
build during component registration.

Since the build components is known as the requirements expansion is
ongoing, update the list here instead.
2019-11-11 18:00:50 +08:00
22548d0ea4 cmake: hide internal targets
Use imported library, which does not create additional rules, but still
allows attaching arbitraty properties instead of custom targets. This
allows the targets to not appear in the target list of IDEs such as
CLion.
2019-11-11 17:58:02 +08:00
088ac409d7 Merge branch 'bugfix/partition_cmake_md5_v4.0' into 'release/v4.0'
cmake: fix partition_table cmake when using md5 checksum (v4.0)

See merge request espressif/esp-idf!6640
2019-11-09 21:17:08 +08:00
14ce4cde2e Merge branch 'bugfix/wifi_internal_memory_v4.0' into 'release/v4.0'
wifi: Include DMA reserved pool when allocating internal-only memory (v4.0)

See merge request espressif/esp-idf!6627
2019-11-09 13:47:33 +08:00
83cd515817 cmake: fix partition_table cmake when using md5 checksum 2019-11-08 18:52:18 +08:00
d48d9a1c88 Merge branch 'bugfix/i2s-bootloader-random-disable_v4.0' into 'release/v4.0'
bugfix(i2s_bootloader_random_disable): fix bug about i2s bootloader_random_disable for release/v4.0

See merge request espressif/esp-idf!6602
2019-11-08 17:12:02 +08:00
f54cab62a2 ci: fix one ut issue when using Wrover-B module with newer ver of PSRAM
The workaround for PSRAM that will occupy an SPI bus is enabled only when:

1. used on 32MBit ver 0 PSRAM.
2. work at 80MHz.

The test used to only check 32MBit by the config option, but for PSRAM
on Wrover-B module seems to use a newer version of 32MBit PSRAM.  So it
expects the workaround to be enabled, but actually not.

This commit split the unit test into two parts:

1. check all SPI buses are available, for all configs except psram_hspi
and psram_vspi, run on regular runners (including Wrover and Wrover-B).
a hidden option is enabled so that the compiler knows it's not building
psram_hspi or psram_vspi.

2. check the specified bus are acquired, for config psram_hspi and
psram_vspi. This only run on special runner (legacy Wrover module).
2019-11-08 08:25:35 +00:00
c64d4236fb secure boot: In Reflashable mode, make sure the bootloader digest updates
... whenever the bootloader.bin is updated
2019-11-08 11:39:01 +08:00
90568fbf00 secure boot: Fix bug where verification key was not embedded in app 2019-11-08 11:39:01 +08:00
475a746e46 bt: Include DMA reserved pool when allocating internal-only memory
Fix for root cause of https://github.com/espressif/esp-idf/issues/3592
2019-11-08 11:37:46 +08:00
947fc14a3f wifi: Include DMA reserved pool when allocating internal-only memory
Fix for root cause of https://github.com/espressif/esp-idf/issues/3592
2019-11-08 11:37:46 +08:00
6f6629e568 idf.py: Add --before flag to esptool.py call
Merges https://github.com/espressif/esp-idf/pull/4125
2019-11-07 17:37:18 +01:00
4c4b1da7e7 Merge branch 'bugfix/ws_client_fixes_v4.0' into 'release/v4.0'
ws_client: various fixes (v4.0)

See merge request espressif/esp-idf!6446
2019-11-07 13:29:50 +08:00
9cc272978c nimble: Miscellaneous changes
1. Update NimBLE submodule as per changes in adv interval and stop port
2. Make changes in ESP BLE Mesh NimBLE host code for the same
2019-11-06 18:27:14 +05:30
5cb6a49c1e components/bt: Add support of NimBLE host in ESP BLE Mesh 2019-11-06 18:26:30 +05:30
56d1e4411e NimBLE: Set the default number of max connections to the controller's value
Also, update the NimBLE submodule to remove unwanted logging stuff
2019-11-06 18:24:56 +05:30
05510e513b Merge branch 'feature/update_toolchain_esp-2019r2_v4.0' into 'release/v4.0'
Introduce esp-2019r2 toolchain  (backport v4.0)

See merge request espressif/esp-idf!6582
2019-11-06 16:15:27 +08:00
5e042803a2 mdns: fix crash for hostname queries
Receiving TXT, PTR, SDPTR and SRV record type queries would crash the application if the hostname
 was used as instance name.

Closes https://github.com/espressif/esp-idf/issues/4224
2019-11-05 11:31:18 +00:00
74d06101b1 bugfix(i2s_bootloader_random_disable): fix bug about i2s bootloader_random_disable for release/v4.0
bootloader_random_disable disables the ADC incorrectly, causing the ADC to sometimes fail to work. Fix this bug
2019-11-05 17:18:13 +08:00
2cd3018c0a Introduce esp-2019r2 toolchain 2019-11-04 16:21:56 +07:00
1a8e5a40d6 ws_client: added subprotocol configuration option to websocket client
closes https://github.com/espressif/esp-idf/issues/3893
2019-11-02 14:12:11 +01:00
b529c6f282 ws_client: fixed path config issue when ws server configured using host and path instead of uri
closes https://github.com/espressif/esp-idf/issues/3892
2019-11-02 14:12:11 +01:00
7a05879024 ws_client: fixed transport config option when server address configured as host, port, transport rather then uri
closes https://github.com/espressif/esp-idf/issues/3891
2019-11-02 14:12:11 +01:00
1611386431 ws_client: fix ping-pong mechanism to use mask, support reception of zero-payload PONG and sending non-zero-payload PING
Closes https://github.com/espressif/esp-idf/issues/3890
Closes https://github.com/espressif/esp-idf/issues/4138
2019-11-02 14:12:11 +01:00
6181686489 Merge branch 'bugfix/ws_client_fix_event_blocking_v4.0' into 'release/v4.0'
ws_client: fixed posting to event loop with websocket timeout (v4.0)

See merge request espressif/esp-idf!6450
2019-11-02 17:29:26 +08:00
0562281353 Merge branch 'bugfix/ws_buffer_overflow_fix_v4.0' into 'release/v4.0'
tcp_transport: fix possible buffer overflow in ws transport connect (v4.0)

See merge request espressif/esp-idf!6447
2019-11-02 17:28:12 +08:00
8bc1f6e2f5 Merge branch 'bugfix/ws_opcodes_fix_v4.0' into 'release/v4.0'
ws_client: fix for not sending ping responses, updated to pass events also for... (v4.0)

See merge request espressif/esp-idf!6451
2019-11-02 17:24:40 +08:00
dd99a6dbe8 Merge branch 'bugfix/ws_client_fixed_path_query_uri_v4.0' into 'release/v4.0'
websocket_client: fix URI parsing to include also query part in websocket connection path (v4.0)

See merge request espressif/esp-idf!6452
2019-11-02 17:19:44 +08:00
5a686d7ad1 Merge branch 'bugfix/mdns_answer_ip6_size_v4.0' into 'release/v4.0'
mdns: use constant size of AAAA answer instead of lw_IP struct size (v4.0)

See merge request espressif/esp-idf!6453
2019-11-02 17:17:45 +08:00
0ca0e7d3cc Merge branch 'bugfix/mdns_BCT_fix_v4.0' into 'release/v4.0'
mdns: fixes to have the BCT passing with latest IDF/lw-IP (v4.0)

See merge request espressif/esp-idf!6454
2019-11-02 17:17:38 +08:00
f06ef95610 Merge branch 'bugfix/bugs_in_a2dp_task_v4.0' into 'release/v4.0'
components/bt: Not post message to a2dp ctrl queue from btc queue, just call it.

See merge request espressif/esp-idf!6532
2019-11-02 17:17:07 +08:00
0078896347 esp_wifi: fix some WiFi bugs
Fix following WiFi bugs:
1. Fix the bug for API_CHECK_ENABLED
2. Fix the bug that wpa2 enterprise sta can connect open AP
3. Fix TKIP/CCMP PN replay attack detection bug
4. Increase buffer number type from uint8_t to uint16_t to support more than 255 buffers
5. Avoid recalculating PMK if esp_wifi_set_config() is not called
6. Fix 5.5M signal test bug
2019-11-01 22:16:30 +08:00
44599d3a84 ws_client: fix for not sending ping responses, updated to pass events also for PING and PONG messages, added interfaces to send both binary and text data
closes https://github.com/espressif/esp-idf/issues/3982
2019-11-01 14:14:15 +00:00
0fa7dcb946 websocket_client: fix URI parsing to include also query part in websocket connection path
closes https://github.com/espressif/esp-idf/issues/4090
2019-11-01 14:07:15 +00:00
d3a8dcb929 tcp_transport: fix possible buffer overflow in ws transport connect
closes IDF-692
2019-11-01 14:05:04 +00:00
4e8c1b91c0 ws_client: fixed posting to event loop with websocket timeout
Executing event loop `esp_event_loop_run()` with timeout causes delays in receiving events from user code. Fixed by removing the timeout to post synchronously.

closes https://github.com/espressif/esp-idf/issues/3957
2019-11-01 14:02:58 +00:00
4ed0d006b4 Merge branch 'bugfix/fix_wifi_deinit_memory_leak_v4.0' into 'release/v4.0'
esp_wifi: fix WiFi deinit memory leak (backport v4.0)

See merge request espressif/esp-idf!6539
2019-11-01 21:39:56 +08:00
e85804824e components/bt: Not post message to a2dp ctrl queue from btc queue, just call it. 2019-11-01 20:12:24 +08:00
304f6a577a Merge branch 'bugfix/btdm_assert_deinit_a2dp_while_playing_v4.0' into 'release/v4.0'
components/bt: Fix assert when deinit A2DP while playing music

See merge request espressif/esp-idf!6534
2019-11-01 18:20:07 +08:00
29690afc57 mdns: use constant size of AAAA answer in mdns packets instead of deriving from lwip struct size, since the struct could contain also zones
closes WIFI-771
2019-11-01 09:50:42 +00:00
98450e80e5 mdns: fix possible race condition when checking DHCP status on WIFI_EVENT_STA_CONNECTED event.
tcpip_adapter_dhcpc_get_status() returns the actual internal value of dhcp client without any locking or TCP/IP stack context call, so when CONNECTED event fired with default settings it started DHCP client in TCP/IP stack context and at the same time mdns event handler checking actual DHCP state, which could still be INIT (not STARTED). Purpose of this check is to enable PCB if DHCP was stopped before setting network interface up (typically static IP settings), so the solutin is to check against TCPIP_ADAPTER_DHCP_STOPPED state
2019-11-01 07:51:49 +00:00
1007473a3b Merge branch 'bugfix/btdm_check_avrc_connected_error_4.0' into 'release/v4.0'
components/bt: Fix error in checking AVRC connected

See merge request espressif/esp-idf!6440
2019-11-01 14:14:13 +08:00
e875f59ed5 Merge branch 'feature/esp-ble-mesh-documentation-v4.0' into 'release/v4.0'
Provide BLE Mesh documentation (v4.0)

See merge request espressif/esp-idf!6560
2019-11-01 14:02:26 +08:00
4f946ea00e Merge branch 'bugfix/can_critical_section_compliance_backport_v4.0' into 'release/v4.0'
CAN: Fix critical section compliance (backport v4.0)

See merge request espressif/esp-idf!6568
2019-11-01 14:01:42 +08:00
666f87109f CAN: Fix critical section compliance
This commit makes the CAN driver ISR use the ISR version
of critical section.
2019-11-01 12:14:39 +08:00
154f315a49 Merge branch 'Bugfix/close_nonblocking_tcp_crash_for_4.0' into 'release/v4.0'
Bugfix/close nonblocking tcp crash for 4.0

See merge request espressif/esp-idf!6517
2019-11-01 11:24:13 +08:00
b175ec77ad Merge branch 'feature/cxx_rtti_preparation_v3_v4.0' into 'release/v4.0'
C++: re-add provisions for optional RTTI support (backport v4.0)

See merge request espressif/esp-idf!6557
2019-10-31 23:27:33 +08:00
f9fa039826 Provide BLE Mesh documentation 2019-10-31 17:08:26 +08:00
b54528696a Merge branch 'doc/support_policy_v4.0' into 'release/v4.0'
docs: Add ESP-IDF support period policy (v4.0)

See merge request espressif/esp-idf!6528
2019-10-31 15:46:43 +08:00
fae64f79bb C++: prepare RTTI support
Ref. https://github.com/espressif/esp-idf/issues/1684

Also, for full RTTI support, libstdc++.a in the toolchain should be built
in both with RTTI and w/o RTTI options. Multilib with -fno-rtti
flag is used for that.

Note that this commit does not actually enable RTTI support.
The respective Kconfig option is hidden, and will be made visible when
the toolchain is updated.
2019-10-31 13:27:39 +07:00
4f297ed3fa Revert "C++: add provisions for optional RTTI support"
This reverts commit 3d0466ccd1.
2019-10-31 13:26:53 +07:00
8eaa440221 Merge branch 'bugfix/jump_time_54_sec_v4.0' into 'release/v4.0'
esp_timer: Fix time jumps back ~ 54sec (v4.0)

See merge request espressif/esp-idf!6456
2019-10-31 12:31:39 +08:00
56d5548747 Merge branch 'bugfix/btdm_backports_v4.0_1028' into 'release/v4.0'
bt: backport btdm controller fixes to v4.0

See merge request espressif/esp-idf!6514
2019-10-30 15:39:11 +08:00
665a341147 fix bug for close nonblocking tcp crash 2019-10-30 10:44:36 +08:00
cab589af9d components/bt: Fix error in checking AVRC connected 2019-10-30 02:34:33 +00:00
19e355e080 esp_wifi: fix WiFi deinit memory leak 2019-10-29 22:32:17 +08:00
1cf2da8d67 components/bt: Fix assert when deinit A2DP while playing music 2019-10-29 19:58:52 +08:00
744625f234 Merge branch 'bugfix/btdm_disable_bt_gatt_v4.0' into 'release/v4.0'
components/bt: Disable BR/EDR GATT

See merge request espressif/esp-idf!6503
2019-10-29 18:15:54 +08:00
5e505898df docs: Add ESP-IDF support period policy 2019-10-29 16:26:13 +11:00
3a1d0e9352 Merge branch 'bugfix/coex_semaphore_take_in_isr_lock_v4.0' into 'release/v4.0'
fix bug that semaphore may schedule out in ISR locking

See merge request espressif/esp-idf!6426
2019-10-28 18:45:17 +08:00
8afd0de501 components/bt: bugfix that bluetooth controller may not be able to enter sleep after end of wake up request 2019-10-28 15:10:23 +08:00
1f7a66a22e components/bt: Fix LMP sniff req timeout 2019-10-28 15:09:49 +08:00
bcc19b7826 components/bt: Disable BR/EDR GATT 2019-10-28 11:21:09 +08:00
0a03a55c1e Merge branch 'bugfix/fix_mesh_proxy_adv_with_wrong_dev_name_v4.0' into 'release/v4.0'
ble_mesh: using bt device name in mesh proxy adv (v4.0)

See merge request espressif/esp-idf!6439
2019-10-26 20:59:28 +08:00
61f26c985e Merge branch 'bugfix/can_reset_mode_entry_v4.0' into 'release/v4.0'
Bugfix/can reset mode entry v4.0

See merge request espressif/esp-idf!6497
2019-10-26 20:57:52 +08:00
165e778d7e ci: Temporarily ignore CAN example test failures
Due to internal CI issue.
2019-10-26 16:45:23 +08:00
859ddcdb63 can: Fix reset mode entry and exit calls
This commit fixes multiple bugs caused by incorrect calls to
can_enter_reset_mode() and can_exit_reset_mode. Example test
scripts also updated to match new runners.
2019-10-26 16:45:10 +08:00
c599d7aa49 fix bug that semaphore may schedule out in Critical Section
1. Since BLE full-scan feature for BLE mesh change the controller code cause this problem,
it cause coex semaphore take in "interrupt disable", then it may cause task schedule
and cause crash in freertos
2. Fix newlib lock ISR context and critical section check
3. Fix bt controller ISR context and critical section check
2019-10-25 12:01:06 +08:00
da636bd4ac Merge branch 'bugfix/msys2_toolchain_path_note_v4.0' into 'release/v4.0'
docs: update windows msys2 installer notes to unzip all-in-one toolchain to path without spaces (v4.0)

See merge request espressif/esp-idf!6455
2019-10-25 11:39:04 +08:00
834893d8e4 Merge branch 'feature/esptool_v2.8_v4.0' into 'release/v4.0'
esptool: Bump to v2.8 release (v4.0)

See merge request espressif/esp-idf!6460
2019-10-25 11:38:09 +08:00
059052acaa Merge branch 'bugfix/select_with_sdmmc_mount_v4.0' into 'release/v4.0'
VFS: Fix bug which occurs when driver is installed during a select() call (v4.0)

See merge request espressif/esp-idf!6429
2019-10-24 10:49:24 +08:00
996db972f0 esptool: Bump to v2.8 release 2019-10-23 09:04:43 +11:00
4ddc6916c3 docs: fix minor parameter description inconsistency for idf_component_set_property 2019-10-22 21:21:31 +02:00
c06519a759 docs: update windows msys2 installer notes to unzip all-in-one toolchain to path without spaces 2019-10-22 21:21:21 +02:00
f1e8a49836 esp_timer: Fix System time jumps back ~54secs
Closes: https://github.com/espressif/esp-idf/issues/2513
2019-10-22 23:43:28 +08:00
09cc922b42 esp32: Add UTs to check the System time does not jump back 2019-10-22 23:43:28 +08:00
lly
34c33f7440 ble_mesh: using bt device name in mesh proxy adv 2019-10-22 15:48:00 +08:00
5464aaac45 VFS: Fix bug which occurs when driver is installed during a select() call
Closes https://github.com/espressif/esp-idf/issues/3554
2019-10-21 14:54:48 +02:00
054e2dbb44 Merge branch 'bugfix/not_restoring_ble_mesh_cfg_val_v4.0' into 'release/v4.0'
ble_mesh: fix not restoring ble mesh cfg value (v4.0)

See merge request espressif/esp-idf!6276
2019-10-21 20:16:50 +08:00
59a186b27e Merge branch 'bugfix/mqtt_example_url_update_v4.0' into 'release/v4.0'
MQTT: update default broker URL for examples (backport v4.0)

See merge request espressif/esp-idf!6410
2019-10-21 10:52:44 +08:00
62a609190d Merge branch 'feature/idf_tools_installer_v2.1_v4.0' into 'release/v4.0'
IDF tools installer: extra fixes, bump version to v2.1 (backport 4.0)

See merge request espressif/esp-idf!6401
2019-10-21 10:49:12 +08:00
9f1d992ef9 Merge branch 'bugfix/idf_py_fix_property_dict_v4.0' into 'release/v4.0'
idf.py: Fix PropertyDict implementation (v4.0)

See merge request espressif/esp-idf!6249
2019-10-21 10:37:31 +08:00
7cb3d5bc4a Merge branch 'bugfix/apps_esp_ble_mesh_v4.0' into 'release/v4.0'
ESP BLE Mesh: Minor fix - Print the address and the on/off value appropriately (v4.0)

See merge request espressif/esp-idf!6374
2019-10-21 10:37:09 +08:00
de27a71a56 Merge branch 'bugfix/freertos_xTaskNotifyGive_v4.0' into 'release/v4.0'
freertos: remove semicolon in xTaskNotifyGive (v4.0)

See merge request espressif/esp-idf!6269
2019-10-21 10:35:56 +08:00
ed8ddf7e76 Merge branch 'bugfix/mqtt_reference_latest_version_4.0' into 'release/v4.0'
mqtt: updated to latest version to include latest fixes, support for global CA (backport 4.0)

See merge request espressif/esp-idf!6386
2019-10-21 10:34:56 +08:00
3860753818 Merge branch 'bugfix/vfs_fat_sdmmc_mount_v4.0' into 'release/v4.0'
Fix memory leak upon failure of esp_vfs_fat_sdmmc_mount() (v4.0)

See merge request espressif/esp-idf!6393
2019-10-21 10:33:50 +08:00
2056b891d3 Merge branch 'bugfix/ext_flash_load_partitions_v4.0' into 'release/v4.0'
spi_flash: ensure partition table loaded when esp_partition_register_external is called (backport v4.0)

See merge request espressif/esp-idf!6402
2019-10-21 10:33:01 +08:00
c6a6740e3f Merge branch 'feature/cxx_rtti_preparation_v2_v4.0' into 'release/v4.0'
C++: add provisions for optional RTTI support (backport v4.0)

See merge request espressif/esp-idf!6403
2019-10-21 10:31:52 +08:00
dd1615d57c Merge branch 'bugfix/can_driver_assertions_v4.0' into 'release/v4.0'
drivers/can: fix skipped function calls when assertions disabled (backport v4.0)

See merge request espressif/esp-idf!6405
2019-10-21 10:27:16 +08:00
106f066254 Merge branch 'bugfix/spi_flash_read_changes_for_less_than_16_bytes_v4.0' into 'release/v4.0'
Bugfix/spi flash read changes for less than 16 bytes v4.0(backport v4.0)

See merge request espressif/esp-idf!6247
2019-10-19 15:00:00 +08:00
32b8b60dc5 flash_ops: fix spi_flash_read with source buffer not from internal memory and size < 16
Closes https://github.com/espressif/esp-idf/issues/4010
2019-10-19 15:00:00 +08:00
4283b59dde MQTT: update default broker URL for examples
The MQTT broker URL used as default in the examples has ceased operation. All examples and documention have been updated to point to the new domain mqtt.eclipse.org.
This also required an update of the python example test scripts to use TLS 1.2
2019-10-18 17:32:33 +08:00
be894757ff drivers/can: fix skipped function calls when assertions disabled
When CONFIG_FREERTOS_ASSERT_DISABLE is set, the function calls wrapped
inside the assertion macros would be removed from the code.

Closes https://github.com/espressif/esp-idf/issues/4143
2019-10-18 11:26:05 +02:00
3d0466ccd1 C++: add provisions for optional RTTI support
Ref. https://github.com/espressif/esp-idf/issues/1684

This change allows RTTI to be enabled in menuconfig. For full RTTI
support, libstdc++.a in the toolchain should be built without
-fno-rtti, as it is done now.

Generally if libstdc++.a is built with RTTI, applications which do not
use RTTI (and build with -fno-rtti) could still include typeinfo
structures referenced from STL classes’ vtables. This change works
around this, by moving all typeinfo structures from libstdc++.a into
a non-loadable section, placed into a non-existent memory region
starting at address 0. This can be done because when the application
is compiled with -fno-rtti, typeinfo structures are not used at run
time. This way, typeinfo structures do not contribute to the
application binary size.

If the application is build with RTTI support, typeinfo structures are
linked into the application .rodata section as usual.

Note that this commit does not actually enable RTTI support.
The respective Kconfig option is hidden, and will be made visible when
the toolchain is updated.
2019-10-18 11:22:39 +02:00
92adc524a2 examples/ext_flash_fatfs: print out data partitions, add CI test 2019-10-18 11:15:10 +02:00
0fc30f4379 spi_flash: load partition table before adding an external partition
esp_partition_register_external did not call load_partitions, so if
it was called before any call to esp_partition_find, then the main
partition table would never be loaded. Introduce new function,
ensure_partitions_loaded, and call it both from esp_partition_find and
esp_partition_register_external.

Closes https://github.com/espressif/esp-idf/issues/4116
2019-10-18 11:14:32 +02:00
905fdbc1ad docs: update get-started to use Tools Installer v2.1 2019-10-18 11:10:41 +02:00
3a115a1ad2 tools: bump windows tools installer version to v2.1
Includes the following changes:

80ad09f23 allow changing the installation path
(a fix for https://github.com/espressif/esp-idf/issues/3806)

9c5284e7b verify that IDF_PATH doesn't contain spaces

aaf3dcbda fix quoting of IDF_TOOLS_PATH
(a fix for https://github.com/espressif/esp-idf/issues/3807)

e6e179294 tools: update idf_exe to 1.0.1
76dc87e9a idf_exe: fix NULL pointer passed to WriteFile
(fixes for https://github.com/espressif/esp-idf/issues/3740)
2019-10-18 11:10:41 +02:00
019c72e4fc tools: update Windows installer build script
Replace the outdated build_installer.sh with the steps used in CI,
call build_installer.sh from CI. Move the signing part into the new
script, sign_installer.sh.
2019-10-18 11:10:41 +02:00
21ecf51a40 idf_tools.py: add workaround for PermissionError in os.rename
Closes https://github.com/espressif/esp-idf/issues/4063
Closes https://github.com/espressif/esp-idf/issues/3819
2019-10-18 11:10:41 +02:00
3c97f7e42e idf_tools.py: pass --work-tree instead of -C option to git
Older versions of git do not support -C option. Use --work-tree option
instead.

Closes https://github.com/espressif/esp-idf/issues/4018
Merges https://github.com/espressif/esp-idf/pull/4019
2019-10-18 11:10:40 +02:00
de9b0b1c56 Fix memory leak upon failure of esp_vfs_fat_sdmmc_mount()
Closes https://github.com/espressif/esp-idf/issues/4165
2019-10-18 10:27:37 +02:00
57a13b09cc Merge branch 'NimBLE/fix_esp_nimble_hci_delay_v4.0' into 'release/v4.0'
NimBLE: Misc changes in NimBLE porting layer and menuconfig option (Backport v4.0)

See merge request espressif/esp-idf!6321
2019-10-18 13:18:09 +08:00
6a60c4a046 NimBLE: Misc changes in NimBLE porting layer and menuconfig option (Backport 4.0)
- Minor fix to remove while loop & delay while transmitting data from
  host to controller.
- Add menuconfig option to enable predefined public-private keypair for
  debugging (Vol. 3, Part H, 2.3.5.6.1)
- Update NimBLE submodule: Fix for #4028, #4012
2019-10-18 13:18:09 +08:00
f96c02adac mqtt: updated to latest version to include latest fixes, support for global CA store, extended error structure to receive mqtt specific errors. updated idf ssl example to use this error struct
backport of 640eac84fa
2019-10-17 16:45:29 +02:00
9351ae7dc9 freertos: remove semicolon in xTaskNotifyGive 2019-10-17 08:06:57 +00:00
2cde888a6d Merge branch 'feature/enable_ethernet_unit_test_4.0' into 'release/v4.0'
ethernet: enable unit test (v4.0)

See merge request espressif/esp-idf!6220
2019-10-17 12:54:53 +08:00
c94434917d Merge branch 'bugfix/ut_adjtime_v4.0' into 'release/v4.0'
newlib: Fix UT - test time adjustment happens linearly (v4.0)

See merge request espressif/esp-idf!6348
2019-10-17 12:51:35 +08:00
fb32429387 ESP BLE Mesh: Minor fix - Print the address and the on/off value appropriately
The new value should be printed in the set function and not the previous
one.
2019-10-16 15:19:14 +08:00
1cc6d2ef62 Merge branch 'docs/update_bootloader_chip_revision_print_v4.0' into 'release/v4.0'
bootloader_support: fix logging prints around chip revision (v4.0)

See merge request espressif/esp-idf!6336
2019-10-14 22:14:25 +08:00
128d650d7d Merge branch 'bugfix/alt_exit_idf_monitor_v4.0' into 'release/v4.0'
idf_monitor: Exit with CTRL+X in menu (v4.0)

See merge request espressif/esp-idf!6289
2019-10-14 21:46:32 +08:00
090dd78355 Merge branch 'bugfix/multi_heap_printf_backport_v4.0' into 'release/v4.0'
heap: Fix printf usage in heap poisoning (backport v4.0)

See merge request espressif/esp-idf!6092
2019-10-14 21:28:36 +08:00
706df7ab12 newlib: Fix UT - test time adjustment happens linearly 2019-10-14 14:52:04 +08:00
cfa355c705 Merge branch 'bugfix/set_url_discards_username_password_v4.0' into 'release/v4.0'
fixes : set_url discards username and password (v4.0)

See merge request espressif/esp-idf!6333
2019-10-14 11:09:10 +08:00
a87e699104 bootloader_support: fix logging prints around chip revision 2019-10-13 11:58:16 +05:30
7566bfb548 fixes : set_url discards username and password 2019-10-12 10:50:11 +05:30
57335cfc26 Merge branch 'feature/add_chip_revision_to_image_header_4.0' into 'release/v4.0'
Add chip revision into image header(v4.0)

See merge request espressif/esp-idf!6127
2019-10-11 13:22:12 +08:00
7a6faa093b Merge branch 'bugfix/fixes_from_kconfiglib_update_v4.0' into 'release/v4.0'
Fix of menuconfig bug for MSYS2 and a couple of cosmetic changes (v4.0)

See merge request espressif/esp-idf!6308
2019-10-11 13:06:46 +08:00
a389312750 heap: Fix printf usage in heap poisoning
This commit fixes the bug where printf() is used in
verify_allocated_region() when ets_printf() should be used.
2019-10-11 03:10:56 +00:00
lly
7d267a340f ble_mesh: fix not callback net_key when device is provisioned 2019-10-11 10:05:12 +08:00
783ef22dd3 Fix cmake typo 2019-10-10 09:11:01 +02:00
4f193dfa71 tools: Fix idf.py menuconfig characters in MSYS2 2019-10-10 09:11:01 +02:00
c875e5698a Cosmetic Kconfig fixes 2019-10-10 09:11:01 +02:00
4cafa3e76e Merge branch 'feature/add_psram_workaround_option_4.0' into 'release/v4.0'
make psram workaround depend on chip revison(v4.0)

See merge request espressif/esp-idf!6115
2019-10-10 11:00:29 +08:00
1e5ea2827c ethernet: fix crash in unit test 2019-10-10 10:43:42 +08:00
cf5331b9f1 ethernet: enable unit test 2019-10-10 10:42:48 +08:00
28a2e6a775 Merge branch 'bugfix/deprecated_sdkconfig_defaults_v4.0' into 'release/v4.0'
Handle deprecated values in sdkconfig.defaults (v4.0)

See merge request espressif/esp-idf!6254
2019-10-09 23:50:05 +08:00
34a327791c idf_monitor: Exit with CTRL+X in menu
Currently, the only way of exiting the idf_monitor program is to hit the CTRL+] button, if your keyboard doesn't have that key unless you hit another modifier key, it's not super trivial to exit.

This change adds the option to exit with CTRL+T (for menu) then hitting X (or CTRL+X) for exiting.

Closes https://github.com/espressif/esp-idf/pull/4167
Closes https://github.com/espressif/esp-idf/issues/4129
2019-10-09 10:27:50 +02:00
8bcf5a19d5 Merge branch 'bugfix/esp_tls_add_header_in_esp_tls_h_v4.0' into 'release/v4.0'
ESP32/esp_tls: include esp_err.h in esp_tls.h (v4.0)

See merge request espressif/esp-idf!6264
2019-10-09 13:31:38 +08:00
lly
66a46de2a7 ble_mesh: fix not restoring ble mesh cfg value 2019-10-08 16:37:20 +08:00
bcd496be49 bootloader: shrink bin size
1. write a bootloader version of "getting chip revision" function.
2. reduce wordy log.
2019-10-08 02:45:36 +00:00
79923d0199 Add chip revision into image header
Check chip id and chip revision before boot app image

Closes https://github.com/espressif/esp-idf/issues/4000
2019-10-08 02:45:36 +00:00
858b3d2277 ESP32/esp-tls: include esp_err.h in esp_tls.h
Closes https://github.com/espressif/esp-idf/issues/4100
2019-10-07 17:47:51 +05:30
dedaf624db Handle deprecated values in sdkconfig.defaults
The issue was pointed out also in
https://github.com/espressif/esp-idf/issues/4092
2019-10-03 10:13:42 +02:00
9ca33a260f idf.py: Fix PropertyDict implementation 2019-10-01 17:49:51 +02:00
abdf12dc9e Merge branch 'bugfix/coex_fix_some_bugs_v4.0' into 'release/v4.0'
Coexist: fix some coexist bugs(backport v4.0)

See merge request espressif/esp-idf!6088
2019-09-30 17:01:32 +08:00
10d26549fa Coexist: fix some coexist bugs
1. Fix high beacon and broadcast packets loss ratio of WiFi to
   make MDNS test pass.
2. Improve stability of WiFi performance with a little sacrifice
   of throughput.
3. Improve BLE advertising and connection performance with
   dynamic priority. It sacrifices a little WiFi throughput, but
   achieves balance between WiFi and Bluetooth.
2019-09-30 11:42:05 +08:00
26676c2b8f Merge branch 'bugfix/fix_wifi_stop_leads_to_watchdog_v4.0' into 'release/v4.0'
Fixed the bug that WiFi stop leads to task watchdog (backport v4.0)

See merge request espressif/esp-idf!6228
2019-09-30 11:00:53 +08:00
d9cfb05eb6 esp_wifi:
1. Fixed smartconfig ipc crash
2. Fix the WiFi init sequence bug
3. Fixed the bug that WiFi stop leads to task watchdog
4. Put g_promis_buf to IRAM
2019-09-29 11:38:11 +08:00
4322e89006 Merge branch 'bugfix/ble_mesh_client_invalid_addr_access_4.0' into 'release/v4.0'
ble_mesh: fix client model invalid address access (v4.0)

See merge request espressif/esp-idf!6218
2019-09-29 10:24:04 +08:00
96748f3037 Merge branch 'refactor/update_spi_ethernet_api_v4.0' into 'release/v4.0'
update spi ethernet api (v4.0)

See merge request espressif/esp-idf!6177
2019-09-27 19:43:15 +08:00
lly
5a94142481 ble_mesh: fix client model invalid address access 2019-09-27 15:28:10 +08:00
e5ff431b35 Merge branch 'fix/esp_flash_coredump_4.0' into 'release/v4.0'
esp_flash: fix coredump issues (backport v4.0)

See merge request espressif/esp-idf!6136
2019-09-26 21:26:53 +08:00
c225801b3e Merge branch 'fix/add_parentheses_to_spi_swap_data_tx_4.0' into 'release/v4.0'
spi: Put argument of macro SPI_SWAP_DATA_TX in parentheses (backport v4.0)

See merge request espressif/esp-idf!6107
2019-09-26 21:25:20 +08:00
610e3cac31 Merge branch 'bugfix/gnu_make_windows_paths_v4.0' into 'release/v4.0'
build: In GNU Make, use "cygpath -m" to avoid backslashes (v4.0)

See merge request espressif/esp-idf!6155
2019-09-26 21:24:48 +08:00
c776991233 Merge branch 'bugfix/kconfig_corrections_v4.0' into 'release/v4.0'
Fix Kconfig issues discovered by upstream Kconfiglib (v4.0)

See merge request espressif/esp-idf!6195
2019-09-25 16:26:40 +08:00
041fcceddf Merge branch 'feat/esp_flash_support_encrypt_4.0' into 'release/v4.0'
esp_flash: add support for encrypted read and write (backport v4.0)

See merge request espressif/esp-idf!6106
2019-09-25 16:17:31 +08:00
899957f521 Merge branch 'feature/cmake_check_mconf_version_v4.0' into 'release/v4.0'
cmake: check mconf-idf binary version (backport v4.0)

See merge request espressif/esp-idf!6067
2019-09-25 16:15:26 +08:00
815d7674ef Merge branch 'bugfix/openocd_instructions_v4.0' into 'release/v4.0'
docs: jtag-debugging: update for IDF Tools installation method (backport v4.0)

See merge request espressif/esp-idf!6066
2019-09-25 16:15:07 +08:00
57527ba6f9 Merge branch 'doc/build_system_requirements_v4.0' into 'release/v4.0'
docs: Explain build system REQUIRES & PRIV_REQUIRES in more detail (v4.0)

See merge request espressif/esp-idf!6054
2019-09-25 16:13:48 +08:00
a21eb04cc6 Merge branch 'bugfix/btdm_a2dp_sink_media_suspend_cmd_unack_for_v4.0' into 'release/v4.0'
bugfix/btdm_a2dp_sink_media_suspend_cmd_unack_for_v4.0(backport v4.0)

See merge request espressif/esp-idf!5940
2019-09-25 16:12:43 +08:00
116d0c8145 Merge branch 'bugfix/ble_mesh_queue_task_init_check_v4.0' into 'release/v4.0'
ble_mesh: check ble mesh queue and task init status (v4.0)

See merge request espressif/esp-idf!6193
2019-09-25 15:08:23 +08:00
dda49709fe ethernet: update spi-ethernet api 2019-09-25 06:34:39 +00:00
ebffa5f9f2 ethernet: test apps can build with ethernet disabled 2019-09-25 06:34:39 +00:00
fc738680f8 Fix Kconfig issues discovered by upstream Kconfiglib 2019-09-25 08:25:51 +02:00
1c586ebcfd Merge branch 'feature/bluedroid_min_encr_key_size_backport_v4.0' into 'release/v4.0'
BT/Bluedroid: Add support to set min encryption key size requirement (backport v4.0)

See merge request espressif/esp-idf!6180
2019-09-25 11:57:22 +08:00
499accb652 BT/Bluedroid: Add support to set min encryption key size requirement (backport)
- Backport of IDF MR!6122.
- Modifies `smp_utils.c` to add check on encryption key size received from
  peer.
- Modifies `esp_ble_gap_set_security_param` API to add minimum encryption key
  size requirement.
2019-09-25 11:57:21 +08:00
988147a451 Merge branch 'bugfix/btdm_loop_in_feature_req_ext_v4.0' into 'release/v4.0'
components/bt: Fix sending LMP_features_req_ext in a loop

See merge request espressif/esp-idf!6023
2019-09-25 11:52:10 +08:00
lly
9e6c56f9f2 ble_mesh: check ble mesh queue and task init status 2019-09-25 11:03:18 +08:00
1b6eb69f53 Merge branch 'NimBLE/mbedTLS_option_for_tinycrypty_v4.0' into 'release/v4.0'
NimBLE: Add optional mbedTLS support to NimBLE (backport)

See merge request espressif/esp-idf!6146
2019-09-23 21:37:40 +08:00
daa65b6f91 NimBLE: Add optional mbedTLS support to NimBLE (backport)
- NimBLE: Additional menuconfig option to enable mbedTLS instead of Tinycrypt from
  NimBLE, changes `component.mk` & `CMakeLists.txt` for the same.
- Addition of NimBLE stack size configuration and misc changes.
- mbedTLS: Addition of `CMAC` and `ECP_RESTARTABLE` to mbedTLS menuconfig option and
  `esp_config.h`.
- Example: Minor changes to `app_mesh.c` application.
2019-09-23 21:37:40 +08:00
7f9626d378 Merge branch 'cleanup/make_supp_headers_private_v4.0' into 'release/v4.0'
wpa_supplicant: Make internal crypto headers private (backport v4.0)

See merge request espressif/esp-idf!6061
2019-09-23 18:00:43 +08:00
6cad60f34b bugfix that call of esp_a2d_media_ctrl(ESP_A2D_MEDIA_CTRL_SUSPEND) will not get an ACK from callback on A2DP sink 2019-09-23 03:22:34 +00:00
b4c7ed999c Merge branch 'bugfix/remove_v40_deprecations_v4.0' into 'release/v4.0'
Remove features deprecated before ESP-IDF V4.0 (v4.0)

See merge request espressif/esp-idf!6150
2019-09-20 19:51:51 +08:00
8a5c08df98 Merge branch 'bugfix/fix_the_for_smartconfig_send_broadcast_to_phone_v4.0' into 'release/v4.0'
fix the bug that ESP32 sends broadcast to phone after smartconfig is done (backport v4.0)

See merge request espressif/esp-idf!6072
2019-09-20 14:02:19 +08:00
b1eac64865 build: In GNU Make, use "cygpath -m" to avoid backslashes
Fixes issues where backslashes in KCONFIG paths are later expanded as shell escape sequences.
2019-09-19 21:33:56 +10:00
4e7b559101 Delete extra '/' 2019-09-19 19:22:44 +08:00
43616f6f05 esp_wifi: Update wifi lib 2019-09-19 17:49:18 +08:00
3b9ab9caa6 idf_test: Disable tests for Wi-Fi auto reconnect
Disable one, remove IDF tag from the other
2019-09-19 18:49:37 +10:00
0dc9ddb77c Wi-Fi: remove wifi_fast_scan_threshold_t which is not suitable in name 2019-09-19 18:49:37 +10:00
9ab92331c4 dport: remove clock_en and reset bitname which is not suitable 2019-09-19 18:49:37 +10:00
08416d05ba soc: Remove deprecated LEDC struct register names (bit_num, div_num)
Deprecated since ESP-IDF V3.0
2019-09-19 18:49:37 +10:00
200c82561a soc: remove deprecated io_mux PIN_PULLxxx_yyy macros
Deprecated before ESP-IDF V1.0!
2019-09-19 18:49:37 +10:00
2e05c6020f mbedtls: Remove esp_aes_encrypt/decrypt
Deprecated in ESP-IDF V3.1

Anyone reading this should please include mbedtls/aes.h and use mbedTLS APIs,
not the ESP-specific APIs.
2019-09-19 18:49:37 +10:00
d139c851f3 heap: Remove esp_heap_alloc_caps header
Deprecated in ESP-IDF V3.1
2019-09-19 18:49:37 +10:00
365e3fd685 fatfs: Remove esp_vfs_fat_unregister()
Deprecated in ESP-IDF V2.0
2019-09-19 18:49:37 +10:00
71fad5e2c0 esp_wifi: Remove WIFI_PS_MODEM constant
Deprecated in ESP-IDF V3.1
2019-09-19 18:48:55 +10:00
94ba3a20cb esp_wifi: Remove deprecated auto connect API
Deprecated in ESP-IDF V3.1
2019-09-19 18:48:55 +10:00
5a7d3ef319 ringbuf: Remove deprecated RingbufferType_t
Deprecated in ESP-IDF V3.1
2019-09-19 18:48:55 +10:00
e4a4e6ed81 wdt: Remove deprecated esp_task_wdt_feed() function
Deprecated in ESP-IDF V3.1
2019-09-19 18:48:55 +10:00
8094e880c6 esp32/esp_common: Remove deprecated esp_efuse_read_mac() function
Deprecated since ESP-IDF V2.0
2019-09-19 18:48:30 +10:00
35b9223cf4 esp32/esp_common: Remove deprecated system_* APIs
Mostly deprecated before ESP-IDF V1.0 & V2.0
2019-09-19 18:48:30 +10:00
fe97d14e0f esp_adc_cal: Remove deprecated ADC calibration functions
Deprecated since ESP-IDF V3.1
2019-09-19 18:48:14 +10:00
2c16557ee7 esp32: Remove deprecated system_deep_sleep function
Deprecated since ESP-IDF V3.0
2019-09-19 18:48:14 +10:00
5f8e5db268 esp32/test: fix usage of deprecated fields 2019-09-19 18:48:14 +10:00
a9fe3165c4 soc/pm: Remove deprecated use of rtc_cpu_freq_t enum
Removes deprecated ways of setting/getting CPU freq, light sleep freqs.

Deprecated since ESP-IDF V3.2
2019-09-19 18:48:13 +10:00
b01036e13e driver: Remove features deprecated pre-IDF V4.0 2019-09-19 18:47:15 +10:00
10649ae23b app_update: Remove deprecated "make erase_ota" target
Deprecated in v3.2
2019-09-19 18:45:36 +10:00
c4306f7942 bootloader_support: Remove deprecated partition load/verify functions
Deprecated since v3.2
2019-09-19 18:45:36 +10:00
62be877ada bluetooth: Remove bt.h header (deprecated in v3.1-dev) 2019-09-19 18:45:36 +10:00
546026d018 make psram workaround depend on chip revison
Since ESP32 revision 3, the PSRAM workaround is not needed.
2019-09-19 13:50:53 +08:00
05d3665a14 Merge branch 'bugfix/ble_mesh_get_timer_remaining_time_v4.0' into 'release/v4.0'
ble_mesh: fix ble mesh get timer remaining time (v4.0)

See merge request espressif/esp-idf!6059
2019-09-18 16:38:31 +08:00
0bba92b2a0 esp_flash: put adapter to legacy functions into IRAM to be back-compatible 2019-09-18 15:16:00 +08:00
399477cd10 coredump: use esp_flash api in coredump
Also put esp_flash functions into noflash region, when
ESP32_PANIC_HANDLER_IRAM and coredump are enabled. The option disables
the re-enabling of the CPU-cache when it's disabled during coredump.
This requires all the coredump functions including the flash API to be
in the D/IRAM.
2019-09-18 15:14:53 +08:00
d3b54ec84a esp_flash: fix the coredump issue
During coredump, dangerous-area-checking should be disabled, and cache
disabling should be replaced by a safer version.

Dangerous-area-checking used to be in the HAL, but it seems to be more
fit to os functions. So it's moved to os functions. Interfaces are
provided to switch between os functions during coredump.
2019-09-18 14:30:23 +08:00
e4b44f3488 esp_flash: fix coredump for legacy spi flash API
When legacy mode is used, the coredump still fails during linking
because "esp_flash_init_default_chip", "esp_flash_app_init" and
"esp_flash_default_chip " are not compiled and linked.

Instead of using ``if`` macros in callers, these functions are protected
by ``if`` macros in the header, and also not compiled in the sources.
"esp_flash_default_chip" variable is compiled with safe default value.
2019-09-18 14:28:12 +08:00
ca80b0445d wpa_supplicant: Make internal crypto headers private (backport v4.0)
A lot of internally used crypto headers are publicly includeable
in user projects. This leads to bug reports when these headers
are incorrectly used or the API's are not used as intended.

Move all crypto headers into private crypto src folder, also move
crypto_ops into Supplicant to remove dependecy on crypto headers.

Closes IDF-476
2019-09-17 13:28:30 +00:00
lly
1e01accaa4 ble_mesh: fix duplicate memory free during receiving status message 2019-09-16 17:30:03 +08:00
2ca3735edd spi: Put argument of macro SPI_SWAP_DATA_TX/RX in parentheses
Close https://github.com/espressif/esp-idf/pull/3996
2019-09-16 17:17:42 +08:00
b9a2639ab4 esp_flash: add support for encrypted read and write
Using legacy implementation.
2019-09-16 17:10:08 +08:00
lly
77f186a7b9 ble_mesh: make unicast elem lookup O(1) 2019-09-16 15:06:52 +08:00
lly
89e848c820 ble_mesh: use adv report flow control for ble mesh 2019-09-16 14:44:34 +08:00
5e0cc123ee Merge branch 'bugfix/cmake_sdkconfig_path' into 'release/v4.0'
fix bug for cmake build system

See merge request espressif/esp-idf!6102
2019-09-16 14:20:38 +08:00
536c131114 fix bug for cmake build system
The path of ${SDKCONFIG_H} does not exist, should be replaced by ${sdkconfig_header}.
2019-09-16 11:18:04 +08:00
ef17d8bba1 Merge branch 'bugfix/httpd_sess_close_v4.0' into 'release/v4.0'
httpd_sess_close: Check for session validity before closing (v4.0)

See merge request espressif/esp-idf!5742
2019-09-16 08:21:37 +08:00
3194e12479 Merge branch 'bugfix/uart_select_free_v4.0' into 'release/v4.0'
VFS: Fix memory access after free() in UART select() (v4.0)

See merge request espressif/esp-idf!6085
2019-09-13 14:49:46 +08:00
bb52613bea Merge branch 'bugfix/use_local_kconfiglib_v4.0' into 'release/v4.0'
Use kconfiglib from $IDF_PATH/tools/kconfig_new (v4.0)

See merge request espressif/esp-idf!6079
2019-09-13 14:47:07 +08:00
4ee065df79 httpd_sess_close: Check for session validity before closing
If httpd_sess_trigger_close() gets called twice for the same socket,
the first httpd_sess_close() cb closes the correct socket, but the second
invocation closes the wrong socket which was just accepted and added to
the socket db. Checking for the lru counter will help identify this as the
counter is set only for requests actually served.
2019-09-12 08:41:31 +00:00
63c2834d7b VFS: Fix memory access after free() in UART select()
Closes https://github.com/espressif/esp-idf/issues/4030
2019-09-12 08:38:31 +02:00
dbf2c3d480 Merge branch 'bugfix/btdm_config_msbc_v4.0' into 'release/v4.0'
components/bt: Disable Wide Bond Speech when SCO data path is PCM

See merge request espressif/esp-idf!5979
2019-09-12 13:23:54 +08:00
582d5de497 Merge branch 'bugfix/coex_bb_reset_lock_v4.0' into 'release/v4.0'
fix some coex bugs

See merge request espressif/esp-idf!6056
2019-09-12 11:04:10 +08:00
5a351af83f Merge branch 'bugfix/flash_encryption_disable_plaintext_v4.0' into 'release/v4.0'
flash encryption: Always disable plaintext reflashes in Release mode (v4.0)

See merge request espressif/esp-idf!6070
2019-09-12 10:40:34 +08:00
a6fc9bf246 Use kconfiglib from $IDF_PATH/tools/kconfig_new 2019-09-11 14:28:39 +02:00
d52b244ae8 Merge branch 'bugfix/openocd_ulp_install_instructions_v4.0' into 'release/v4.0'
docs: ulp: update for IDF Tools installation method (backport v4.0)

See merge request espressif/esp-idf!6065
2019-09-11 16:06:52 +08:00
00e3cb672b Merge branch 'bugfix/flash_encryption_regressions_v4.0' into 'release/v4.0'
fix flash encryption regressions, add tests (backport v4.0)

See merge request espressif/esp-idf!6068
2019-09-11 12:06:02 +08:00
67eb732dbe fix the bug that ESP32 sends broadcast to phone after smartconfig is done 2019-09-11 11:37:29 +08:00
c53a5ee427 Merge branch 'bugfix/http_header_parser_resolution_v4.0' into 'release/v4.0'
(backport v4.0) esp_http_server : Bugfix in parsing of empty header values

See merge request espressif/esp-idf!6041
2019-09-11 10:20:36 +08:00
69241907a5 bootloader: Link RTC clock functions to the iram_loader section
As flash encryption & secure boot needs these functions after the app is loaded.

Fixes regression introduced in fb72a6f629
2019-09-11 10:16:43 +10:00
d4ee21bd6d docs: Small cleanup of flash encryption docs 2019-09-11 10:16:43 +10:00
5b69614e32 flash encryption: Ensure flash encryption can't be disabled if Secure Boot is on 2019-09-11 10:16:43 +10:00
3e12967535 bootloader: add definition of esp_clk_apb_freq
Commit 8cd04c80 has added a dependency of efuse component on
esp_clk_apb_freq, however there was no definition of this function in
the bootloader context.

Reported at https://esp32.com/viewtopic.php?f=13&t=12035
2019-09-11 10:16:43 +10:00
d9f1219a21 efuse: set timing configuration before writing 2019-09-11 10:16:43 +10:00
f3fc4916d2 ci: add jobs for flash encryption tests 2019-09-10 17:20:19 +02:00
b17ca9cb38 unit-test-app: add config with flash encryption enabled 2019-09-10 17:20:19 +02:00
801010dac6 spi_flash: fix mmap unit tests for flash encryption 2019-09-10 17:20:19 +02:00
f84394e550 examples/flash_encryption: refactor, add test
1. Clean up the example code
2. Add demonstration of partition read/write operations
3. Add example test
2019-09-10 17:19:44 +02:00
a0256b9e9d flash encryption: add option to require flash encryption to be enabled
In testing environment, to avoid accidentally enabling flash
encryption on a device, CONFIG_SECURE_FLASH_REQUIRE_ALREADY_ENABLED
can be set. If set, the bootloader will refuse to boot if flash
encryption is not enabled, instead of enabling it.
2019-09-10 17:19:08 +02:00
a37694741c tiny-test-fw: support testing apps with flash encryption
If CONFIG_SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT is set, pass
--encrypted flag to esptool.py.
2019-09-10 17:18:51 +02:00
fae124a2c1 esp32: cpu_start: read binary image header via cache
When flash encryption is enabled, reading via cache also decrypts the
data, whereas spi_flash_read does not.

Closes https://github.com/espressif/esp-idf/issues/3907
2019-09-10 17:18:51 +02:00
ad100e497a spi_flash: remove duplicate definition of spi_flash_unlock
The other (static) definition is in flash_ops.c, all references are
also in flash_ops.c.
2019-09-10 17:18:51 +02:00
da8c09c463 cmake: check mconf-idf binary version
Print a warning if an outdated version of mconf-idf is found in
the PATH.
2019-09-10 17:15:15 +02:00
6df148aa54 docs: jtag-debugging: update translation 2019-09-10 17:12:48 +02:00
3fc9b022b6 docs: jtag-debugging: update for IDF Tools installation method
- rely on OPENOCD_SCRIPTS variable in all cases, remove -s flags
- replace installation section with a reference to the Getting Started
  guides
- add Windows-specific commands in a few cases
2019-09-10 17:12:48 +02:00
28ee1c0da2 doc: update translation of ulp install instuctions 2019-09-10 17:10:17 +02:00
05b306bae1 docs: ulp: update for IDF Tools installation method
binutils-esp32ulp is installed automatically by install.sh/install.bat
or the IDF Tools Installer for Windows.
2019-09-10 17:10:17 +02:00
lly
8dbb2083ea ble_mesh: fix ble mesh get timer remaining time 2019-09-10 17:01:03 +08:00
a8590c7e8e fix some coex bugs
1. fix the bug that bb reset lock unhandled may cause assert in vPortCPUReleaseMutexIntsDisabledInternal
2. fix wifi mac reset may blocking then cause wdt timeout
3. fix bug wifi mac reset before coex init
2019-09-10 15:58:42 +08:00
8876cda09b esp_http_server : Bugfix in parsing of empty header values
This MR is intended to fix incorrect parsing of HTTP requests when empty header values are present.

The issue is was due to asymmetric behavior of `http_parser` library, which in case of:

    non-empty header values : invokes callbacks with the pointer to the start of a value
    empty header values : invokes callbacks with pointer to the start of next header or section

Since HTTP server relies on this pointer (along with length of the value) to locate the end of a value, and replace the line terminators (CRLFs) with null characters, the second case needed to be handled correctly.

Closes IDFGH-1539

Closes https://github.com/espressif/esp-idf/issues/3803
2019-09-10 05:58:49 +00:00
cec1c5f856 docs: Explain build system REQUIRES & PRIV_REQUIRES in more detail
Including an example.
2019-09-10 15:10:30 +10:00
a7107d9bbd Merge branch 'bugfix/ble_mesh_related_bugfixes_v4.0' into 'release/v4.0'
Bugfix/ble mesh related bugfixes v4.0

See merge request espressif/esp-idf!6042
2019-09-10 09:48:36 +08:00
850684438b Merge branch 'bugfix/ethernet_rx_length_check_v4.0' into 'release/v4.0'
ethernet: bugfix and optimize (v4.0)

See merge request espressif/esp-idf!6028
2019-09-10 07:58:46 +08:00
9d00f3b420 Merge branch 'deprecate/spi_common_claim_macros_v4.0' into 'release/v4.0'
spi_common: remove deprecated spi_common_periph_claim macros (backport v4.0)

See merge request espressif/esp-idf!6006
2019-09-10 06:42:32 +08:00
72264ca9b9 spi_common: remove deprecated spi_common_periph_claim macros (backport v4.0) 2019-09-10 06:42:31 +08:00
da2025a74a Merge branch 'bugfix/newlib_time_test_v4.0' into 'release/v4.0'
newlib: Fix UT - test time adjustment happens linearly (v4.0)

See merge request espressif/esp-idf!6014
2019-09-10 06:40:09 +08:00
93bad7a0de Merge branch 'bugfix/bootloader_factory_reset_with_wake_up_from_deep_sleep_v4.0' into 'release/v4.0'
bootloader: Blocking the Factory reset during wake up from deep sleep (v4.0)

See merge request espressif/esp-idf!6020
2019-09-10 06:39:19 +08:00
lly
55f687c763 ble_mesh: update ble mesh examples sdkconfig.defaults 2019-09-09 18:10:52 +08:00
lly
329388fa47 ble_mesh: fix ble mesh btc may caused memory leak 2019-09-09 18:10:47 +08:00
lly
0f36dabcaf ble_mesh: fix publication period timestamp initialization 2019-09-09 18:10:42 +08:00
lly
0299e22dd0 ble_mesh: remove useless mesh_opcode 2019-09-09 18:10:34 +08:00
lly
f072c5af4e ble_mesh: fix bt_mesh_net_resend() caused compiling error 2019-09-09 17:47:56 +08:00
lly
6982663380 ble_mesh: fix adhering to the configured Friend Queue size 2019-09-09 17:47:47 +08:00
lly
1d970ad276 ble_mesh: remove useless code bt_mesh_trans_resend() 2019-09-09 17:47:30 +08:00
lly
a73cc70af9 ble_mesh: lpn remove msg from cache on rejection 2019-09-09 17:47:24 +08:00
lly
225ee8e5d1 ble_mesh: introduce a helper for send callback function 2019-09-09 17:47:18 +08:00
lly
fa4cd56d00 ble_mesh: fix heartbeat sending on friendship established/lost 2019-09-09 17:47:07 +08:00
lly
15f8b0fccc ble_mesh: fix checking for active heartbeat publication 2019-09-09 17:46:49 +08:00
lly
97080afba2 ble_mesh: fix starting iv update when not on primary subnet 2019-09-09 17:46:43 +08:00
lly
612822d8c9 ble_mesh: fix canceling publication retransmit timer 2019-09-09 17:46:35 +08:00
lly
ff6cb921c3 ble_mesh: fix resending segments on correct bearer 2019-09-09 17:46:27 +08:00
lly
6f7b7c552d ble_mesh: fix not sending all segments through the Friend Queue 2019-09-09 17:46:19 +08:00
lly
e00186e683 ble_mesh: fix canceled buffer memory leak 2019-09-09 17:46:06 +08:00
lly
a734b3b1bc ble_mesh: remove some useless copy during ecdh calculation 2019-09-09 17:45:59 +08:00
lly
6de637811f ble_mesh: move heartbeat sending to transport layer 2019-09-09 17:45:52 +08:00
lly
6ec0c6743a ble_mesh: fix provisioning send error handling 2019-09-09 17:45:44 +08:00
lly
299c86cc84 ble_mesh: fix rejecting invalid remote public key 2019-09-09 17:45:27 +08:00
lly
d123f6c04b ble_mesh: add error checks for scan start/stop 2019-09-09 17:45:20 +08:00
lly
3c17bf1a6f ble_mesh: rename reset_link() to reset_adv_link() 2019-09-09 17:45:14 +08:00
lly
8fb20e4529 ble_mesh: fix public key mismatch error handling 2019-09-09 17:45:06 +08:00
lly
e020d1055a ble_mesh: update protocol error timeout from zephyr 2019-09-09 17:44:17 +08:00
lly
05e4b28a74 ble_mesh: fix segmented message RPL behavior 2019-09-09 17:44:11 +08:00
lly
27bc688ed8 ble_mesh: clear LPN sent_req on failure 2019-09-09 17:43:59 +08:00
lly
a214fb2821 ble_mesh: update proxy sar operation from zephyr 2019-09-09 17:43:46 +08:00
lly
6b7b9d1550 ble_mesh: fix postponing storage deadline indefinitely 2019-09-09 17:43:40 +08:00
lly
18b873b2e3 ble_mesh: fix RPL storage timeout handling 2019-09-09 17:43:29 +08:00
lly
d1755c1484 ble_mesh: fix output MIC with additional data 2019-09-09 17:43:23 +08:00
lly
152ebb104d ble_mesh: remove non-standard relay opearation 2019-09-09 17:43:13 +08:00
lly
e3b304997f ble_mesh: fix finding netkey/appkey/devkey for tx/rx msg 2019-09-09 17:43:04 +08:00
lly
1e20ed4849 ble_mesh: fix failed to set device role caused mem leak 2019-09-09 17:42:50 +08:00
lly
59b663c43d ble_mesh: ble mesh btc miscellaneous modifications 2019-09-09 17:42:43 +08:00
lly
e9e28c1265 ble_mesh: fix MESH/NODE/FRND/FN/BV-11-C related bug 2019-09-09 17:42:35 +08:00
lly
7030d612e2 ble_mesh: fix MESH/NODE/CFG/GPXY/BV-02-C & MESH/NODE/CFG/NID/BV-02-C related bug 2019-09-09 17:42:20 +08:00
lly
2c852b0d74 ble_mesh: fix MESH/NODE/CFG/HBS/BV-01-C related bug 2019-09-09 17:42:08 +08:00
lly
708bff3b17 ble_mesh: rename ble mesh client model variables and functions 2019-09-09 17:42:00 +08:00
lly
317f4c5ff5 ble_mesh: reorganize ble mesh model files 2019-09-09 17:41:54 +08:00
lly
2c025824d7 ble_mesh: sync zephyr v1.14.0 bt_hex() 2019-09-09 17:41:41 +08:00
lly
9b95064018 ble_mesh: fix provisioner prov auth bug 2019-09-09 17:41:34 +08:00
ecdffe531e Merge branch 'bugfix/reset_periph_modules_v4.0' into 'release/v4.0'
driver: Add a reset before enabling if a module is off (v4.0)

See merge request espressif/esp-idf!6015
2019-09-08 23:06:31 +08:00
31be6be147 Merge branch 'fix/esp_flash_set_get_wp_4.0' into 'release/v4.0'
esp_flash: fix the set/get write protection functions (backport v4.0)

See merge request espressif/esp-idf!5832
2019-09-08 16:34:40 +08:00
305a4a1b57 ethernet: bugfix and optimize
1. check frame length before pass to stack
2. replace semaphore with task notify
2019-09-06 15:46:18 +08:00
e659f1b15a Merge branch 'bugfix/fix_the_bug_for_WPA_WPA2_PSK_connection_fail_v4.0' into 'release/v4.0'
fix the bug for WPA_WPA2_PSK connection fail(backport v4.0)

See merge request espressif/esp-idf!6010
2019-09-06 14:52:58 +08:00
2c49592216 Merge branch 'refactor/move_smartconfig_ack_to_wifi_v4.0' into 'release/v4.0'
smartconfig: move smartconfig_ack to esp_wifi conponent (v4.0)

See merge request espressif/esp-idf!5999
2019-09-06 14:27:29 +08:00
6afb2743e7 components/bt: Fix sending LMP_features_req_ext in a loop
Remove xtensa/xtruntime.h at the same time
2019-09-06 12:04:16 +08:00
f7b458841f app_update: Fix UTs for FACTORY_RESET and APP_TEST 2019-09-06 11:59:03 +08:00
f1e9b8299f bootloader: Factory reset not for deep sleep
Closes: https://github.com/espressif/esp-idf/issues/3800

Closes: IDFGH-1536
2019-09-06 11:59:03 +08:00
9ce1b8986a rmt/driver: Add module reset before enabling 2019-09-06 11:34:53 +08:00
c5bea8dddb pcnt/driver: Add module reset before enabling 2019-09-06 11:34:53 +08:00
ba6b502cc9 sdmmc_host/driver: Add module reset before enabling 2019-09-06 11:34:53 +08:00
3b0b5f92a7 i2s/driver: Add module reset before enabling 2019-09-06 11:34:53 +08:00
d6bc1b3cbc can/driver: Add module reset before enabling 2019-09-06 11:34:53 +08:00
199c4e55f2 uart/driver: Add module reset before enabling
This commit prevents infinite restarts caused due to an interrupt flag
was left uncleared.

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

Closes: IDF-188
2019-09-06 11:34:53 +08:00
61339353e9 newlib: Fix UT - test time adjustment happens linearly
Obtaining accurate and adjustable time occurs closer to each other.
2019-09-06 11:30:01 +08:00
3b2dda5197 1. fix the bug that STA fails to connect WPA_WPA2_PSK Apple AP
2. fix the bug for softAP set authmode
2019-09-05 20:34:34 +08:00
1b8ed9abf0 Merge branch 'bugfix/btdm_crash_in_sket_ist_v4.0' into 'release/v4.0'
Fix 2 bugs in r_ld_fm_sket_isr

See merge request espressif/esp-idf!5947
2019-09-05 12:02:26 +08:00
f9453ef93d Merge branch 'bugfix/btdm_config_but_task_size_fail_v4.0' into 'release/v4.0'
Bugfix/btdm config but task size fail v4.0

See merge request espressif/esp-idf!5962
2019-09-05 11:26:56 +08:00
dcf571c1cd smartconfig: move smartconfig_ack to esp_wifi conponent 2019-09-05 10:44:00 +08:00
538c56426a Merge branch 'bugfix/err_code_collision_v4.0' into 'release/v4.0'
Fix error code collisions and re-enable CI check (v4.0)

See merge request espressif/esp-idf!5984
2019-09-04 09:10:19 +08:00
1402e78844 Fix error code collision and CI check 2019-09-03 08:07:16 +02:00
01f0c8ef16 components/bt: Rename some macros 2019-09-03 10:28:49 +08:00
a774406b91 Use CONFIG value instead of hard-coded value.
Add intermediate defines.

Use CONFIG_BTU_TASK_STACK_SIZE instead of hard-coded value in Bluedroid component
2019-09-03 10:28:12 +08:00
c9bff93080 Merge branch 'feature/enable_cfg_for_tls_asymmetric_content_length_v4.0' into 'release/v4.0'
mbedtls: keep asymmetric tls buffer length option enabled by default (v4.0)

See merge request espressif/esp-idf!5970
2019-09-02 23:25:06 +08:00
4b8e4ff248 Merge branch 'bugfix/btdm_linking_fail_with_toolchain_8.2.0_v4.0' into 'release/v4.0'
components/bt: Fix linking fail with toolchain 8.2.0

See merge request espressif/esp-idf!5967
2019-09-02 22:22:22 +08:00
9dbf979cf3 Merge branch 'bugfix/btdm_remove_unused_macro_in_menuconfig_v4.0' into 'release/v4.0'
components/bt: Remove unused macro in menuconfig

See merge request espressif/esp-idf!5951
2019-09-02 22:21:12 +08:00
ad70ab8957 components/bt: Disable Wide Bond Speech when SCO data path is PCM 2019-09-02 20:55:17 +08:00
cd5dc4d05f Merge branch 'doc/add_ble_mesh_example_description_v4.0' into 'release/v4.0'
ble_mesh: add ble mesh example description(backport v4.0)

See merge request espressif/esp-idf!5948
2019-09-02 14:29:13 +08:00
ebb9384681 Merge branch 'bugfix/various_cmake_fixes_v4.0' into 'release/v4.0'
CMake: Various backports

See merge request espressif/esp-idf!5933
2019-09-02 12:46:40 +08:00
0d3fde04ff Merge branch 'bugfix_kconfig_deps_missing_v4.0' into 'release/v4.0'
kconfig: Add -MP option so .d files include empty targets (v4.0)

See merge request espressif/esp-idf!5845
2019-09-02 12:43:28 +08:00
0552ec5791 Merge branch 'update/cjson_v1_7_12_v4.0' into 'release/v4.0'
Update cJSON to v1.7.12 (v4.0)

See merge request espressif/esp-idf!5850
2019-09-02 12:41:30 +08:00
524eef9225 Merge branch 'test/use_correct_config_for_nvs_compatible_case_v4.0' into 'release/v4.0'
test: fix nvs compatible case error (backport v4.0)

See merge request espressif/esp-idf!5891
2019-09-02 12:40:46 +08:00
955f7e2877 Merge branch 'test/fix_mesh_test_case_4.0' into 'release/v4.0'
test: fix test case MESH_EST_2403 (backport 4.0)

See merge request espressif/esp-idf!5907
2019-09-02 12:38:51 +08:00
lly
e28834aa15 ble_mesh: add ble mesh example description 2019-09-02 12:17:47 +08:00
ac03786412 Merge branch 'bugfix/wps_workaround_for_Telstra_AP_v4.0' into 'release/v4.0'
wps: Relax the check on older config methods in case of WPS2.0 (backport v4.0)

See merge request espressif/esp-idf!5952
2019-09-02 12:04:49 +08:00
a5dae2ff43 mbedtls: keep asymmetric tls buffer length option enabled by default 2019-08-31 10:24:37 +05:30
1d0142d25d components/bt: Fix linking fail with toolchain 8.2.0 2019-08-30 17:56:01 +08:00
65ef597da6 Merge branch 'bugfix/test_esp_efuse_table_on_host_v4.0' into 'release/v4.0'
CI: Fix path in the Efuse table test (v4.0)

See merge request espressif/esp-idf!5953
2019-08-30 16:27:47 +08:00
310beae373 Merge branch 'bugfix/revert_optimize_wifi_rx_v4.0' into 'release/v4.0'
esp_wifi: revert WiFi RX optimization

See merge request espressif/esp-idf!5941
2019-08-30 10:59:20 +08:00
cf0caaec11 esp_wifi: revert WiFi RX optimization
Revert following commit since it has compatibility issue:
commit 45dd6175cd
esp32: optimize wifi rx
2019-08-29 21:26:42 +08:00
4af9504a65 components/bt: Remove unused macro in menuconfig 2019-08-29 19:58:58 +08:00
64bece146c Fix path in the Efuse table test 2019-08-29 09:50:38 +02:00
6b348b94e3 wps: Relax the check on older config methods in case of WPS2.0 (backport
v4.0)

Some APs incorrectly advertize newer WPS2.0 config method bits
without setting bits for the corresponding older methods. This
results in failures during 8-way handshake. Add a workaround to
relax this check so that WPS handshake can proceed.
2019-08-29 13:05:02 +05:30
6222040888 Fix 2 bugs in r_ld_fm_sket_isr
1. When remove two elt in the 1st isr, then assert in then 2nd one.
2. When timestamp of first elt is equal to sket_clkn, then crash.
2019-08-29 11:31:57 +08:00
ea1037742d Merge branch 'bugfix/confgen_msys_path_v4.0' into 'release/v4.0'
Fix sdkconfig.rename paths for confgen.py in MSYS (v4.0)

See merge request espressif/esp-idf!5904
2019-08-29 10:15:21 +08:00
465d46e9dd Merge branch 'bugfix/cmake_src_exclude_issue_v4.0' into 'release/v4.0'
cmake: fix issue with handling of EXCLUDE_SRCS (v4.0)

See merge request espressif/esp-idf!5900
2019-08-28 14:42:20 +08:00
e71e4da388 cmake: check include directories 2019-08-28 10:28:17 +08:00
c711e969cc components: fix incorrect include dir args 2019-08-28 10:28:17 +08:00
3f1ec39a8d cmake: fix issue with checking build process args 2019-08-28 10:28:17 +08:00
f62798cb8b cmake: make default version 1 2019-08-28 10:28:17 +08:00
b6c89984a9 cmake: fix build failure when git repo is initialized but no first commit
Closes https://github.com/espressif/esp-idf/issues/3920
2019-08-28 10:28:17 +08:00
520ecb0c4d ldgen: fix build issue on make when build dir is a symlink
Fixes an issue where build fails if the build directory is a symlink.
The issue is caused by the rule target and the final executable dependency
not matching.

Closes https://github.com/espressif/esp-idf/issues/3626
2019-08-28 10:28:17 +08:00
b669495d97 Make sure ESP_PLATFORM is defined when processing CMake files. 2019-08-28 10:28:17 +08:00
8778c551eb cmake: set build dir for mconf-idf
Fixes an issue where if idf_build_process is called in a CMake
subdirectory, menuconfig looks for the mconf-idf binary in the wrong
place (in the subdirectory build dir instead of root binary dir).
2019-08-28 10:28:17 +08:00
c34d313a86 mbedtls: add source files to appropriate library 2019-08-28 10:28:17 +08:00
ebcb3a22b8 Merge branch 'bugfix/btdm_fix_ble_data_loss_and_send_same_pkt_twice_v4.0' into 'release/v4.0'
Component/bt: fix some BLE bugs (backport v4.0)

See merge request espressif/esp-idf!5909
2019-08-27 18:49:55 +08:00
6781d01e89 cmake: fix encrypted project flash arg file generation 2019-08-27 13:35:39 +08:00
4c9f30a869 cmake: set component properties 2019-08-27 13:35:21 +08:00
61ba1c3026 components/bt: backport 2 BT bugfix about controller
1.Bugfix btdm sleep twice after wakeup request
2.Set the minimum encryption key size to be 7 octects for BR/EDR link for preventing KNOB attack
    This patch is to address the CVE-2019-9506 vulnerability.
2019-08-27 10:42:40 +08:00
90bbea65c1 Component/bt: fix some BLE bugs
- fix data loss and send same pkt twice sometimes
- fix adv data error in air sometimes
- fix adv start/stop crash sometimes
2019-08-26 20:29:01 +08:00
672e9f4abc test: fix test case MESH_EST_2403 2019-08-26 20:26:46 +08:00
cb3d458050 Fix sdkconfig.rename paths for confgen.py in MSYS
Closes https://github.com/espressif/esp-idf/issues/3950
2019-08-26 11:12:44 +02:00
b72ff61899 cmake: fix issue with handling of EXCLUDE_SRCS 2019-08-26 11:49:30 +05:30
83b9727c42 test: fix nvs compatible case error:
nvs compatible test case uses new test env and app. update test config
file.
2019-08-25 20:46:56 +08:00
7bb8b5ba9e Merge branch 'Bugfix/nonblocking_udp_is_zero_for_4.0' into 'release/v4.0'
fix bug for nonblocking udp is zero for v4.0

See merge request espressif/esp-idf!5855
2019-08-23 10:50:45 +08:00
1f5f6adcb6 fix bug for nonblocking udp is zero for v4.0 2019-08-21 17:07:45 +08:00
aa0bb29404 Update cJSON to v1.7.12
Fixes potential DoS in cJSON_Minify, see https://github.com/DaveGamble/cJSON/issues/354
2019-08-21 18:40:50 +10:00
2264ea7714 kconfig: Add -MP option so .d files include empty targets
Prevents make-level errors when switching IDF versions, as headers may be removed.

Similar to some mentioned here:
https://github.com/espressif/esp-idf/issues/712
2019-08-21 18:20:47 +10:00
a626b26cf9 esp_flash: improve the comments a bit 2019-08-20 14:05:35 +08:00
1cc860216e esp_flash: fix the set/get write protection functions
Add support for get write protection support, fixed the duplicated
set_write_protection link.

All the write_protection check in the top layer are removed. The lower
levels (chip) should ensure to disable write protection before the
operation start.
2019-08-20 14:05:35 +08:00
16ee476a77 Merge branch 'bugfix/config_panic_gdbstub_build_issue_v4.0' into 'release/v4.0'
esp32_gdbstub: fix build error with esp32-2019r1 toolchain (v4.0)

See merge request espressif/esp-idf!5764
2019-08-20 13:11:24 +08:00
674ecc3b56 Merge branch 'bugfix/vfs_concurrent_select_v4.0' into 'release/v4.0'
VFS: Support concurrent VFS select calls & improve the documentation (backport v4.0)

See merge request espressif/esp-idf!5797
2019-08-20 12:49:03 +08:00
43efee5232 Merge branch 'bugfix/fix_mbedtls_net_sockets_error_handling_v4.0' into 'release/v4.0'
mbedtls: use `errno` instead of `SO_ERROR` for getting socket errors (v4.0)

See merge request espressif/esp-idf!5768
2019-08-20 12:28:56 +08:00
5dab23ea98 Merge branch 'bugfix/confserver_temporaryfile_windows_v4.0' into 'release/v4.0'
confserver: Fix NamedTemporaryFile use on Windows (v4.0)

See merge request espressif/esp-idf!5818
2019-08-20 12:28:16 +08:00
79afd2d580 confserver: Fix NamedTemporaryFile use on Windows
Can't have the file open twice, so need to close and delete after reopening.
2019-08-19 17:44:18 +10:00
a8e8919bbf tools: Support sdkconfig.rename files from outside IDF in confgen.py 2019-08-19 17:44:18 +10:00
ba0f4f17ed Merge branch 'bugfix/doc_pip_requirements_v4.0' into 'release/v4.0'
Add -r flag to pip install command from file (backport v4.0)

See merge request espressif/esp-idf!5798
2019-08-16 13:16:04 +08:00
a63b3c4fe6 Merge branch 'feature/dport_eco_revision2_v4.0' into 'release/v4.0'
make dport workaround depend on chip revision (v4.0)

See merge request espressif/esp-idf!5765
2019-08-16 13:15:18 +08:00
6b8c75d87c Merge branch 'bugfix/hwcrypt_fault_inj_v4.0' into 'release/v4.0'
AES & SHA fault injection checks (backport v4.0)

See merge request espressif/esp-idf!5748
2019-08-16 05:29:54 +08:00
68d82abe52 Added -r flag to pip install command from file
Closes https://github.com/espressif/esp-idf/pull/3874
Closes https://github.com/espressif/esp-idf/issues/3915
2019-08-15 14:23:49 +02:00
ec31f235e9 docs: Correct and extend the documentation about VFS select() 2019-08-15 14:11:51 +02:00
7e9d90b180 VFS: Support concurrent VFS select calls
Closes https://github.com/espressif/esp-idf/issues/3392
2019-08-15 14:11:37 +02:00
d4fcbe37f3 Merge branch 'bugfix/idf_tool_default_encoding_v4.0' into 'release/v4.0'
idf_tool: fix UnicodeDecodeError (v4.0)

See merge request espressif/esp-idf!5720
2019-08-15 16:35:58 +08:00
b9a5f764ba Merge branch 'bugfix/fix_flash_read_error_in_dio_mode_v4.0' into 'release/v4.0'
bugfix(flash): add spi dio address bitlen configure in psram init (backprot v4.0)

See merge request espressif/esp-idf!5790
2019-08-15 12:08:56 +08:00
764b70d7e6 bugfix(flash): add spi dio address bitlen configure in psram init 2019-08-15 10:52:56 +08:00
a1496b90e5 Merge branch 'bugfix/fix_ledc_clock_select_bug_v4.0' into 'release/v4.0'
driver(ledc): fixed ledc clock selection bug for v4.0

See merge request espressif/esp-idf!5757
2019-08-14 10:44:39 +08:00
622d6d5504 mbedtls: use errno instead of SO_ERROR for getting socket errors
As per upgrade notes of lwIP v2.1.0:
socket API: according to the standard, SO_ERROR now only returns asynchronous errors.
All other/normal/synchronous errors are (and always were) available via 'errno'.
LWIP_SOCKET_SET_ERRNO has been removed - 'errno' is always set - and required!

Refer: https://www.nongnu.org/lwip/2_1_x/upgrading.html

Fixes https://github.com/espressif/esp-azure/issues/51
2019-08-13 13:11:24 +05:30
1b903111b6 efuse: update the scheme of getting chip revision 2019-08-13 14:37:17 +08:00
69ef694178 esp32_gdbstub: fix build error with esp32-2019r1 toolchain
Fixes https://github.com/espressif/esp-idf/issues/3866
Closes https://github.com/espressif/esp-idf/issues/3834
2019-08-13 11:38:28 +05:30
81651b47a4 Merge branch 'ci/disable_nimble_tests_v4.0' into 'release/v4.0'
ci: Temporarily disable NimBLE tests in CI (v4.0)

See merge request espressif/esp-idf!5754
2019-08-13 10:42:38 +08:00
30dc86179c Merge branch 'bugfix/fix_wifi_bugs_for_authmode_and_multi_ssid_v4.0' into 'release/v4.0'
fix wifi bugs for authmode and multi ssid (backport v4.0)

See merge request espressif/esp-idf!5725
2019-08-12 23:34:43 +08:00
eff3ac05b3 driver(ledc): fixed ledc clock selection bug for release/v4.0 2019-08-12 17:16:52 +08:00
e5349d47a8 ci: Temporarily disable NimBLE tests in CI 2019-08-12 17:14:54 +10:00
4253adf42b modify WIFI_CONN_0101 case for wrong authmode of AP 2019-08-12 02:38:44 +00:00
088ed65194 wifi: fix wifi bugs for authmode and multi ssid 2019-08-12 02:38:44 +00:00
0ce94950b7 sha: Add fault injection checks reading hash digest state
Vulnerability reported by LimitedResults under Espressif Bug Bounty Program.
2019-08-11 15:58:48 +10:00
ae8b2684d7 aes: Add fault injection checks when writing key to hardware
Vulnerability reported by LimitedResults under Espressif Bug Bounty Program.
2019-08-11 15:58:48 +10:00
9c51f679a7 Merge branch 'bugfix/update_example_docs_build_instructions_to_cmake_v4.0' into 'release/v4.0'
examples: change default build instructions in docs to CMake (v4.0)

See merge request espressif/esp-idf!5704
2019-08-09 13:20:25 +08:00
5c07acad46 idf_tool: fix unicode decode error
Closes https://github.com/espressif/esp-idf/issues/3841
2019-08-07 21:27:29 +08:00
70af759dd2 examples: change default build instructions in docs to CMake 2019-08-06 17:25:25 +05:30
76191a0f55 Merge branch 'move/ble_example_v4.0' into 'release/v4.0'
examples/bluetooth: Move the demos to the appropriate locations (v4.0)

See merge request espressif/esp-idf!5687
2019-08-06 00:32:26 +08:00
f0c3114f2f examples/bluetooth: Move the demos to the appropriate locations (v4.0) 2019-08-06 00:32:25 +08:00
1865 changed files with 119925 additions and 68953 deletions

View File

@ -7,6 +7,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
@ -15,67 +27,57 @@ 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".
# "normal" strategy for fetching only top-level submodules since nothing requires the sub-submodules code for building IDF.
# If the "recursive" strategy is used we have a problem with using relative URLs for sub-submodules.
GIT_SUBMODULE_STRATEGY: normal
UNIT_TEST_BUILD_SYSTEM: make
# IDF environment
# we will download archive for each submodule instead of clone.
# we don't do "recursive" when fetch submodule as they're not used in CI now.
GIT_SUBMODULE_STRATEGY: none
SUBMODULE_FETCH_TOOL: "tools/ci/ci_fetch_submodule.py"
# by default we will fetch all submodules
# jobs can overwrite this variable to only fetch submodules they required
# set to "none" if don't need to fetch submodules
SUBMODULES_TO_FETCH: "all"
# tell build system do not check submodule update as we download archive instead of clone
IDF_SKIP_CHECK_SUBMODULES: 1
UNIT_TEST_BUILD_SYSTEM: cmake
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"
# before each job, we need to check if this job is filtered by bot stage/job filter
.apply_bot_filter: &apply_bot_filter
python $APPLY_BOT_FILTER_SCRIPT || exit 0
.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 [ "$CI_JOB_STAGE" != "target_test" ]; then
tools/idf_tools.py --non-interactive install && eval "$(tools/idf_tools.py --non-interactive export)" || exit 1
fi
.show_submodule_urls: &show_submodule_urls |
git config --get-regexp '^submodule\..*\.url$' || true
.fetch_submodules: &fetch_submodules |
python $SUBMODULE_FETCH_TOOL -s $SUBMODULES_TO_FETCH
before_script:
- echo "Running common script"
- *show_submodule_urls
- source tools/ci/setup_python.sh
# apply bot filter in before script
- *apply_bot_filter
@ -88,10 +90,9 @@ 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
- *setup_custom_toolchain
- *fetch_submodules
# used for check scripts which we want to run unconditionally
.before_script_lesser_nofilter:
@ -101,7 +102,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:
@ -113,10 +113,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: check

View File

@ -1,10 +1,17 @@
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)
unset(compile_definitions)
unset(link_options)
# Add the following build specifications here, since these seem to be dependent
# on config values on the root Kconfig.
@ -22,6 +29,13 @@ else()
list(APPEND cxx_compile_options "-fno-exceptions")
endif()
if(CONFIG_COMPILER_CXX_RTTI)
list(APPEND cxx_compile_options "-frtti")
else()
list(APPEND cxx_compile_options "-fno-rtti")
list(APPEND link_options "-fno-rtti") # used to invoke correct multilib variant (no-rtti) during linking
endif()
if(CONFIG_COMPILER_DISABLE_GCC8_WARNINGS)
list(APPEND compile_options "-Wno-parentheses"
"-Wno-sizeof-pointer-memaccess"
@ -54,11 +68,13 @@ elseif(CONFIG_COMPILER_STACK_CHECK_MODE_ALL)
list(APPEND compile_options "-fstack-protector-all")
endif()
list(APPEND link_options "-fno-lto")
idf_build_set_property(COMPILE_OPTIONS "${compile_options}" APPEND)
idf_build_set_property(C_COMPILE_OPTIONS "${c_compile_options}" APPEND)
idf_build_set_property(CXX_COMPILE_OPTIONS "${cxx_compile_options}" APPEND)
idf_build_set_property(COMPILE_DEFINITIONS "${compile_definitions}" APPEND)
idf_build_set_property(LINK_OPTIONS "${link_options}" APPEND)
idf_build_get_property(build_component_targets __BUILD_COMPONENT_TARGETS)

18
Kconfig
View File

@ -29,6 +29,10 @@ mainmenu "Espressif IoT Development Framework Configuration"
default "IDF_TARGET_NOT_SET" if IDF_TARGET_ENV=""
default IDF_TARGET_ENV
config IDF_FIRMWARE_CHIP_ID
hex
default 0x0000 if IDF_TARGET="esp32"
default 0xFFFF
menu "SDK tool configuration"
config SDK_TOOLPREFIX
@ -39,12 +43,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.)
@ -145,6 +148,15 @@ mainmenu "Espressif IoT Development Framework Configuration"
Size (in bytes) of the emergency memory pool for C++ exceptions. This pool will be used to allocate
memory for thrown exceptions when there is not enough memory on the heap.
config COMPILER_CXX_RTTI
# Invisible option, until the toolchain with RTTI support is released.
# Use prompt "Enable C++ run-time type info (RTTI)" when updating.
bool
help
Enabling this option compiles all C++ files with RTTI support enabled.
This increases binary size (typically by tens of kB) but allows using
dynamic_cast conversion and typeid operator.
choice COMPILER_STACK_CHECK_MODE
prompt "Stack smashing protection mode"
default COMPILER_STACK_CHECK_MODE_NONE

View File

@ -1,8 +1,6 @@
# Espressif IoT Development Framework
[![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
@ -35,25 +33,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 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` 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

66
SUPPORT_POLICY.md Normal file
View File

@ -0,0 +1,66 @@
The latest support policy for ESP-IDF can be found at [https://github.com/espressif/esp-idf/blob/master/SUPPORT_POLICY.md](https://github.com/espressif/esp-idf/blob/master/SUPPORT_POLICY.md)
Support Period Policy
=====================
Each ESP-IDF major and minor release (V4.0, V4.1, etc) is supported for
18 months after the initial stable release date.
Supported means that the ESP-IDF team will continue to apply bug fixes,
security fixes, etc to the release branch on GitHub, and periodically
make new bugfix releases as needed.
Users are encouraged to upgrade to a newer ESP-IDF release before the
support period finishes and the release becomes End of Life (EOL). It is
our policy to not continue fixing bugs in End of Life releases.
Pre-release versions (betas, previews, `-rc` and `-dev` versions, etc)
are not covered by any support period. Sometimes a particular feature is
marked as \"Preview\" in a release, which means it is also not covered
by the support period.
The ESP-IDF Programming Guide has information about the
[different versions of ESP-IDF](https://docs.espressif.com/projects/esp-idf/en/latest/versions.html)
(major, minor, bugfix, etc).
Long Term Support releases
--------------------------
Some releases (starting with ESP-IDF V3.3) are designated Long Term
Support (LTS). LTS releases are supported for 30 months (2.5 years)
after the initial stable release date.
A new LTS release will be made at least every 18 months. This means
there will always be a period of at least 12 months to upgrade from the
previous LTS release to the following LTS release.
Example
-------
ESP-IDF V3.3 was released in September 2019 and is a Long Term Support
(LTS) release, meaning it will be supported for 30 months until February
2022.
- The first V3.3 release was `v3.3` in September 2019.
- The ESP-IDF team continues to backport bug fixes, security fixes,
etc to the release branch `release/v3.3`.
- Periodically stable bugfix releases are created from the release
branch. For example `v3.3.1`, `v3.3.2`, etc. Users are encouraged to
always update to the latest bugfix release.
- V3.3 bugfix releases continue until February 2022, when all V3.3.x
releases become End of Life.
Existing Releases
-----------------
ESP-IDF release V3.3 and all newer releases will follow this support
period policy. The support period for each release will be announced
when the release is made.
For releases made before the support period policy was announced,
the following support periods apply:
- ESP-IDF V3.1.x and V3.2.x will both be supported until October 2020.
- ESP-IDF V3.0.9 (planned for October 2019) will be the last V3.0
bugfix release. ESP-IDF V3.0.x is End of Life from October 2019.
- ESP-IDF versions before V3.0 are already End of Life.

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

@ -40,9 +40,6 @@ read_otadata: $(PARTITION_TABLE_CSV_PATH) partition_table_get_info | check_pytho
--partition-table-offset $(partition_table_offset) \
read_otadata
erase_ota: erase_otadata
@echo "WARNING: erase_ota is deprecated. Use erase_otadata instead."
all: blank_ota_data
flash: blank_ota_data
ifdef CONFIG_SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT

View File

@ -72,13 +72,35 @@ 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;
const uint8_t* src = 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

@ -42,7 +42,7 @@
#include "esp_efuse.h"
#define SUB_TYPE_ID(i) (i & 0x0F)
#define SUB_TYPE_ID(i) (i & 0x0F)
typedef struct ota_ops_entry_ {
uint32_t handle;
@ -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) {
@ -200,7 +201,7 @@ esp_err_t esp_ota_write(esp_ota_handle_t handle, const void *data, size_t size)
// must erase the partition before writing to it
assert(it->erased_size > 0 && "must erase the partition before writing to it");
if (it->wrote_size == 0 && it->partial_bytes == 0 && size > 0 && data_bytes[0] != ESP_IMAGE_HEADER_MAGIC) {
ESP_LOGE(TAG, "OTA image has invalid magic byte (expected 0xE9, saw 0x%02x", data_bytes[0]);
ESP_LOGE(TAG, "OTA image has invalid magic byte (expected 0xE9, saw 0x%02x)", data_bytes[0]);
return ESP_ERR_OTA_VALIDATE_FAILED;
}

View File

@ -249,6 +249,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

@ -444,7 +444,7 @@ static void test_flow4(void)
// 2 Stage: run factory -> check it -> copy factory to OTA0 -> reboot --//--
// 3 Stage: run OTA0 -> check it -> set_pin_factory_reset -> reboot --//--
// 4 Stage: run factory -> check it -> erase OTA_DATA for next tests -> PASS
TEST_CASE_MULTIPLE_STAGES("Switching between factory, OTA0, sets pin_factory_reset, factory", "[app_update][timeout=90][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET]", start_test, test_flow4, test_flow4, test_flow4);
TEST_CASE_MULTIPLE_STAGES("Switching between factory, OTA0, sets pin_factory_reset, factory", "[app_update][timeout=90][ignore][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET]", start_test, test_flow4, test_flow4, test_flow4);
#endif
#ifdef CONFIG_BOOTLOADER_APP_TEST
@ -487,7 +487,7 @@ static void test_flow5(void)
// 2 Stage: run factory -> check it -> copy factory to Test and set pin_test_app -> reboot --//--
// 3 Stage: run test -> check it -> reset pin_test_app -> reboot --//--
// 4 Stage: run factory -> check it -> erase OTA_DATA for next tests -> PASS
TEST_CASE_MULTIPLE_STAGES("Switching between factory, test, factory", "[app_update][timeout=90][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET]", start_test, test_flow5, test_flow5, test_flow5);
TEST_CASE_MULTIPLE_STAGES("Switching between factory, test, factory", "[app_update][timeout=90][ignore][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET]", start_test, test_flow5, test_flow5, test_flow5);
#endif
static const esp_partition_t* app_update(void)

View File

@ -234,12 +234,15 @@ menu "Security features"
config SECURE_SIGNED_ON_UPDATE
bool
default y
select MBEDTLS_ECP_DP_SECP256R1_ENABLED
depends on SECURE_BOOT_ENABLED || SECURE_SIGNED_ON_UPDATE_NO_SECURE_BOOT
config SECURE_SIGNED_APPS
bool
default y
select MBEDTLS_ECP_DP_SECP256R1_ENABLED
select MBEDTLS_ECP_C
select MBEDTLS_ECDH_C
select MBEDTLS_ECDSA_C
depends on SECURE_SIGNED_ON_BOOT || SECURE_SIGNED_ON_UPDATE
@ -338,7 +341,7 @@ menu "Security features"
config SECURE_BOOT_SIGNING_KEY
string "Secure boot private signing key"
depends on SECURE_BOOT_BUILD_SIGNED_BINARIES
default secure_boot_signing_key.pem
default "secure_boot_signing_key.pem"
help
Path to the key file used to sign app images.
@ -354,7 +357,7 @@ menu "Security features"
config SECURE_BOOT_VERIFICATION_KEY
string "Secure boot public signature verification key"
depends on SECURE_SIGNED_APPS && !SECURE_BOOT_BUILD_SIGNED_BINARIES
default signature_verification_key.bin
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
app, to verify app images.
@ -368,7 +371,7 @@ menu "Security features"
choice SECURE_BOOTLOADER_KEY_ENCODING
bool "Hardware Key Encoding"
depends on SECURE_BOOTLOADER_REFLASHABLE
default SECURE_BOOTLOADER_NO_ENCODING
default SECURE_BOOTLOADER_KEY_ENCODING_256BIT
help
In reflashable secure bootloader mode, a hardware key is derived from the signing key (with SHA-256) and
@ -403,6 +406,7 @@ menu "Security features"
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.
@ -431,6 +435,7 @@ menu "Security features"
config SECURE_FLASH_ENCRYPTION_MODE_RELEASE
bool "Release"
select PARTITION_TABLE_MD5 if !ESP32_COMPATIBLE_PRE_V3_1_BOOTLOADERS
endchoice
@ -515,6 +520,20 @@ menu "Security features"
Only set this option in testing environments.
config SECURE_FLASH_REQUIRE_ALREADY_ENABLED
bool "Require flash encryption to be already enabled"
depends on SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT
default N
help
If not set (default), and flash encryption is not yet enabled in eFuses, the 2nd stage bootloader
will enable flash encryption: generate the flash encryption key and program eFuses.
If this option is set, and flash encryption is not yet enabled, the bootloader will error out and
reboot.
If flash encryption is enabled in eFuses, this option does not change the bootloader behavior.
Only use this option in testing environments, to avoid accidentally enabling flash encryption on
the wrong device. The device needs to have flash encryption already enabled using espefuse.py.
endmenu # Potentially Insecure
endmenu # Security features

View File

@ -96,11 +96,13 @@ endif()
idf_build_get_property(idf_path IDF_PATH)
idf_build_get_property(idf_target IDF_TARGET)
idf_build_get_property(sdkconfig SDKCONFIG)
idf_build_get_property(python PYTHON)
idf_build_get_property(extra_cmake_args EXTRA_CMAKE_ARGS)
externalproject_add(bootloader
SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/subproject"
BINARY_DIR "${BOOTLOADER_BUILD_DIR}"
CMAKE_ARGS -DSDKCONFIG=${sdkconfig} -DIDF_PATH=${idf_path} -DIDF_TARGET=${idf_target}
CMAKE_ARGS -DSDKCONFIG=${sdkconfig} -DIDF_PATH=${idf_path} -DIDF_TARGET=${idf_target} -DPYTHON=${python}
-DPYTHON_DEPS_CHECKED=1
-DEXTRA_COMPONENT_DIRS=${CMAKE_CURRENT_LIST_DIR}
${sign_key_arg} ${ver_key_arg}
@ -108,6 +110,7 @@ externalproject_add(bootloader
# the bootloader common component requirements depends on this and
# config variables are not available before project() call.
-DLEGACY_INCLUDE_COMMON_HEADERS=${CONFIG_LEGACY_INCLUDE_COMMON_HEADERS}
${extra_cmake_args}
INSTALL_COMMAND ""
BUILD_ALWAYS 1 # no easy way around this...
BUILD_BYPRODUCTS ${bootloader_binary_files}
@ -124,4 +127,4 @@ endif()
# So for now we just have the top-level build remove the final build products...
set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" APPEND PROPERTY
ADDITIONAL_MAKE_CLEAN_FILES
${bootloader_binary_files})
${bootloader_binary_files})

View File

@ -75,7 +75,8 @@ if(CONFIG_SECURE_BOOTLOADER_REFLASHABLE)
add_custom_command(OUTPUT "${bootloader_digest_bin}"
COMMAND ${CMAKE_COMMAND} -E echo "DIGEST ${bootloader_digest_bin}"
COMMAND ${ESPSECUREPY} digest_secure_bootloader --keyfile "${secure_bootloader_key}"
-o "${bootloader_digest_bin}" "${CMAKE_BINARY_DIR}/bootloader.bin"
-o "${bootloader_digest_bin}" "${CMAKE_BINARY_DIR}/bootloader.bin"
MAIN_DEPENDENCY "${CMAKE_BINARY_DIR}/.bin_timestamp"
DEPENDS gen_secure_bootloader_key gen_project_binary
VERBATIM)

View File

@ -32,4 +32,6 @@ CFLAGS += -D BOOTLOADER_BUILD=1
# include the top-level "project" include directory, for sdkconfig.h
CFLAGS += -I$(BUILD_DIR_BASE)/../include
COMPONENT_ADD_LDFLAGS += -l$(COMPONENT_NAME) -Wl,--wrap=longjmp \
include $(IDF_PATH)/make/project.mk

View File

@ -24,6 +24,7 @@
#include "bootloader_common.h"
#include "sdkconfig.h"
#include "esp_image_format.h"
#include "esp32/rom/rtc.h"
static const char* TAG = "boot";
@ -74,7 +75,8 @@ static int selected_boot_partition(const bootloader_state_t *bs)
int boot_index = bootloader_utility_get_selected_boot_partition(bs);
if (boot_index == INVALID_INDEX) {
return boot_index; // Unrecoverable failure (not due to corrupt ota data or bad partition contents)
} else {
}
if (rtc_get_reset_reason(0) != DEEPSLEEP_RESET) {
// Factory firmware.
#ifdef CONFIG_BOOTLOADER_FACTORY_RESET
if (bootloader_common_check_long_hold_gpio(CONFIG_BOOTLOADER_NUM_PIN_FACTORY_RESET, CONFIG_BOOTLOADER_HOLD_TIME_GPIO) == 1) {

View File

@ -40,6 +40,7 @@ SECTIONS
*(.iram1 .iram1.*) /* catch stray IRAM_ATTR */
*liblog.a:(.literal .text .literal.* .text.*)
*libgcc.a:(.literal .text .literal.* .text.*)
*libbootloader_support.a:bootloader_clock.*(.literal .text .literal.* .text.*)
*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.*)
@ -53,6 +54,7 @@ SECTIONS
*libmicro-ecc.a:*.*(.literal .text .literal.* .text.*)
*libspi_flash.a:*.*(.literal .text .literal.* .text.*)
*libsoc.a:rtc_wdt.*(.literal .text .literal.* .text.*)
*libsoc.a:rtc_clk.*(.literal .text .literal.* .text.*)
*libefuse.a:*.*(.literal .text .literal.* .text.*)
*(.fini.literal)
*(.fini)

View File

@ -36,30 +36,60 @@ idf_component_register(SRCS "${srcs}"
REQUIRES "${requires}"
PRIV_REQUIRES "${priv_requires}")
if(BOOTLOADER_BUILD AND CONFIG_SECURE_SIGNED_APPS)
# Whether CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES or not, we need verification key to embed
# in the library.
if(CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES)
# We generate the key from the signing key. The signing key is passed from the main project.
get_filename_component(secure_boot_signing_key
"${SECURE_BOOT_SIGNING_KEY}"
ABSOLUTE BASE_DIR "${project_dir}")
get_filename_component(secure_boot_verification_key
"signature_verification_key.bin"
ABSOLUTE BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}")
add_custom_command(OUTPUT "${secure_boot_verification_key}"
COMMAND ${ESPSECUREPY}
if(CONFIG_SECURE_SIGNED_APPS)
if(BOOTLOADER_BUILD)
# Whether CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES or not, we need verification key to embed
# in the library.
if(CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES)
# We generate the key from the signing key. The signing key is passed from the main project.
get_filename_component(secure_boot_signing_key
"${SECURE_BOOT_SIGNING_KEY}"
ABSOLUTE BASE_DIR "${project_dir}")
get_filename_component(secure_boot_verification_key
"signature_verification_key.bin"
ABSOLUTE BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}")
add_custom_command(OUTPUT "${secure_boot_verification_key}"
COMMAND ${ESPSECUREPY}
extract_public_key --keyfile "${secure_boot_signing_key}"
"${secure_boot_verification_key}"
VERBATIM)
else()
# We expect to 'inherit' the verification key passed from main project.
get_filename_component(secure_boot_verification_key
${SECURE_BOOT_VERIFICATION_KEY}
ABSOLUTE BASE_DIR "${project_dir}")
DEPENDS ${secure_boot_signing_key}
VERBATIM)
else()
# We expect to 'inherit' the verification key passed from main project.
get_filename_component(secure_boot_verification_key
${SECURE_BOOT_VERIFICATION_KEY}
ABSOLUTE BASE_DIR "${project_dir}")
endif()
else() # normal app build
idf_build_get_property(project_dir PROJECT_DIR)
if(CONFIG_SECURE_BOOT_VERIFICATION_KEY)
# verification-only build supplies verification key
set(secure_boot_verification_key ${CONFIG_SECURE_BOOT_VERIFICATION_KEY})
get_filename_component(secure_boot_verification_key
${secure_boot_verification_key}
ABSOLUTE BASE_DIR "${project_dir}")
else()
# sign at build time, extracts key from signing key
set(secure_boot_verification_key "${CMAKE_BINARY_DIR}/signature_verification_key.bin")
get_filename_component(secure_boot_signing_key
${CONFIG_SECURE_BOOT_SIGNING_KEY}
ABSOLUTE BASE_DIR "${project_dir}")
add_custom_command(OUTPUT "${secure_boot_verification_key}"
COMMAND ${ESPSECUREPY}
extract_public_key --keyfile "${secure_boot_signing_key}"
"${secure_boot_verification_key}"
WORKING_DIRECTORY ${project_dir}
DEPENDS ${secure_boot_signing_key}
VERBATIM)
endif()
endif()
target_add_binary_data(${COMPONENT_LIB} "${secure_boot_verification_key}" "BINARY")
# Embed the verification key in the binary (app & bootloader)
#
target_add_binary_data(${COMPONENT_LIB} "${secure_boot_verification_key}" "BINARY"
RENAME_TO signature_verification_key_bin)
set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES
"${secure_boot_verification_key}")

View File

@ -15,6 +15,7 @@
#pragma once
#include "esp_flash_partitions.h"
#include "esp_image_format.h"
#include "esp_app_format.h"
#ifdef __cplusplus
extern "C" {
@ -27,6 +28,11 @@ typedef enum {
GPIO_NOT_HOLD = 0 /*!< If the GPIO input is not low */
} esp_comm_gpio_hold_t;
typedef enum {
ESP_IMAGE_BOOTLOADER,
ESP_IMAGE_APPLICATION
} esp_image_type;
/**
* @brief Calculate crc for the OTA data select.
*
@ -129,7 +135,7 @@ int bootloader_common_select_otadata(const esp_ota_select_entry_t *two_otadata,
/**
* @brief Returns esp_app_desc structure for app partition. This structure includes app version.
*
*
* Returns a description for the requested app partition.
* @param[in] partition App partition description.
* @param[out] app_desc Structure of info about app.
@ -141,6 +147,24 @@ int bootloader_common_select_otadata(const esp_ota_select_entry_t *two_otadata,
*/
esp_err_t bootloader_common_get_partition_description(const esp_partition_pos_t *partition, esp_app_desc_t *app_desc);
/**
* @brief Get chip revision
*
* @return Chip revision number
*/
uint8_t bootloader_common_get_chip_revision(void);
/**
* @brief Check if the image (bootloader and application) has valid chip ID and revision
*
* @param[in] img_hdr: image header
* @param[in] type: image type, bootloader or application
* @return
* - ESP_OK: image and chip are matched well
* - ESP_FAIL: image doesn't match to the chip
*/
esp_err_t bootloader_common_check_chip_validity(const esp_image_header_t* img_hdr, esp_image_type type);
/**
* @brief Configure VDDSDIO, call this API to rise VDDSDIO to 1.9V when VDDSDIO regulator is enabled as 1.8V mode.
*/

View File

@ -27,6 +27,14 @@ extern "C" {
*/
void bootloader_flash_update_id();
/**
* @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

@ -13,6 +13,19 @@
// limitations under the License.
#pragma once
/**
* @brief ESP chip ID
*
*/
typedef enum {
ESP_CHIP_ID_ESP32 = 0x0000, /*!< chip ID: ESP32 */
ESP_CHIP_ID_INVALID = 0xFFFF /*!< Invalid chip ID (we defined it to make sure the esp_chip_id_t is 2 bytes size) */
} __attribute__((packed)) esp_chip_id_t;
/** @cond */
_Static_assert(sizeof(esp_chip_id_t) == 2, "esp_chip_id_t should be 16 bit");
/** @endcond */
/**
* @brief SPI flash mode, used in esp_image_header_t
*/
@ -63,7 +76,9 @@ typedef struct {
* the IDF bootloader uses software to configure the WP
* pin and sets this field to 0xEE=disabled) */
uint8_t spi_pin_drv[3]; /*!< Drive settings for the SPI flash pins (read by ROM bootloader) */
uint8_t reserved[11]; /*!< Reserved bytes in ESP32 additional header space, currently unused */
esp_chip_id_t chip_id; /*!< Chip identification number */
uint8_t min_chip_rev; /*!< Minimum chip revision supported by image */
uint8_t reserved[8]; /*!< Reserved bytes in additional header space, currently unused */
uint8_t hash_appended; /*!< If 1, a SHA256 digest "simple hash" (of the entire image) is appended after the checksum.
* Included in image length. This digest
* is separate to secure boot and only used for detecting corruption.

View File

@ -133,6 +133,21 @@ void esp_flash_write_protect_crypt_cnt();
*/
esp_flash_enc_mode_t esp_get_flash_encryption_mode();
/** @brief Check the flash encryption mode during startup
*
* @note This function is called automatically during app startup,
* it doesn't need to be called from the app.
*
* Verifies the flash encryption config during startup:
*
* - Correct any insecure flash encryption settings if hardware
* Secure Boot is enabled.
* - Log warnings if the efuse config doesn't match the project
* config in any way
*/
void esp_flash_encryption_init_checks(void);
#ifdef __cplusplus
}
#endif

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. */
@ -98,12 +101,6 @@ typedef struct {
esp_err_t esp_partition_table_verify(const esp_partition_info_t *partition_table, bool log_errors, int *num_partitions);
/* This function is included for compatibility with the ESP-IDF v3.x API */
inline static __attribute__((deprecated)) esp_err_t esp_partition_table_basic_verify(const esp_partition_info_t *partition_table, bool log_errors, int *num_partitions)
{
return esp_partition_table_verify(partition_table, log_errors, num_partitions);
}
/**
* Check whether the region on the main flash is safe to write.
*

View File

@ -51,36 +51,6 @@ typedef enum {
#endif
} esp_image_load_mode_t;
/**
* @brief Verify and (optionally, in bootloader mode) load an app image.
*
* This name is deprecated and is included for compatibility with the ESP-IDF v3.x API.
* It will be removed in V4.0 version.
* Function has been renamed to esp_image_verify().
* Use function esp_image_verify() to verify a image. And use function bootloader_load_image() to load image from a bootloader space.
*
* If encryption is enabled, data will be transparently decrypted.
*
* @param mode Mode of operation (verify, silent verify, or load).
* @param part Partition to load the app from.
* @param[inout] data Pointer to the image metadata structure which is be filled in by this function. 'start_addr' member should be set (to the start address of the image.) Other fields will all be initialised by this function.
*
* Image validation checks:
* - Magic byte.
* - Partition smaller than 16MB.
* - All segments & image fit in partition.
* - 8 bit image checksum is valid.
* - SHA-256 of image is valid (if image has this appended).
* - (Signature) if signature verification is enabled.
*
* @return
* - ESP_OK if verify or load was successful
* - ESP_ERR_IMAGE_FLASH_FAIL if a SPI flash error occurs
* - ESP_ERR_IMAGE_INVALID if the image appears invalid.
* - ESP_ERR_INVALID_ARG if the partition or data pointers are invalid.
*/
esp_err_t esp_image_load(esp_image_load_mode_t mode, const esp_partition_pos_t *part, esp_image_metadata_t *data) __attribute__((deprecated));
/**
* @brief Verify an app image.
*
@ -153,6 +123,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

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

View File

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

View File

@ -86,3 +86,17 @@ __attribute__((noreturn)) void bootloader_reset(void);
* ESP_ERR_INVALID_ARG: Error in the passed arguments
*/
esp_err_t bootloader_sha256_hex_to_str(char *out_str, const uint8_t *in_array_hex, size_t len);
/** @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

@ -58,3 +58,12 @@ void bootloader_clock_configure()
}
#endif
}
#ifdef BOOTLOADER_BUILD
int esp_clk_apb_freq(void)
{
return rtc_clk_apb_freq_get();
}
#endif // BOOTLOADER_BUILD

View File

@ -23,8 +23,11 @@
#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"
#include "soc/apb_ctrl_reg.h"
#include "esp_image_format.h"
#include "bootloader_sha.h"
#include "sys/param.h"
@ -179,22 +182,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)
@ -240,13 +228,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) {
@ -270,3 +260,51 @@ void bootloader_common_vddsdio_configure()
}
#endif // CONFIG_BOOTLOADER_VDDSDIO_BOOST
}
#ifdef CONFIG_IDF_TARGET_ESP32
uint8_t bootloader_common_get_chip_revision(void)
{
uint8_t eco_bit0, eco_bit1, eco_bit2;
eco_bit0 = (REG_READ(EFUSE_BLK0_RDATA3_REG) & 0xF000) >> 15;
eco_bit1 = (REG_READ(EFUSE_BLK0_RDATA5_REG) & 0x100000) >> 20;
eco_bit2 = (REG_READ(APB_CTRL_DATE_REG) & 0x80000000) >> 31;
uint32_t combine_value = (eco_bit2 << 2) | (eco_bit1 << 1) | eco_bit0;
uint8_t chip_ver = 0;
switch (combine_value) {
case 0:
chip_ver = 0;
break;
case 1:
chip_ver = 1;
break;
case 3:
chip_ver = 2;
break;
case 7:
chip_ver = 3;
break;
default:
chip_ver = 0;
break;
}
return chip_ver;
}
#endif
esp_err_t bootloader_common_check_chip_validity(const esp_image_header_t* img_hdr, esp_image_type type)
{
esp_err_t err = ESP_OK;
esp_chip_id_t chip_id = CONFIG_IDF_FIRMWARE_CHIP_ID;
if (chip_id != img_hdr->chip_id) {
ESP_LOGE(TAG, "mismatch chip ID, expected %d, found %d", chip_id, img_hdr->chip_id);
err = ESP_FAIL;
}
uint8_t revision = bootloader_common_get_chip_revision();
if (revision < img_hdr->min_chip_rev) {
ESP_LOGE(TAG, "can't run on lower chip revision, expected %d, found %d", revision, img_hdr->min_chip_rev);
err = ESP_FAIL;
} else if (revision != img_hdr->min_chip_rev) {
ESP_LOGI(TAG, "chip revision: %d, min. %s chip revision: %d", revision, type == ESP_IMAGE_BOOTLOADER ? "bootloader" : "application", img_hdr->min_chip_rev);
}
return err;
}

View File

@ -32,6 +32,11 @@ void bootloader_flash_update_id()
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()
{
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

@ -127,6 +127,14 @@ static esp_err_t bootloader_main()
ESP_LOGE(TAG, "failed to load bootloader header!");
return ESP_FAIL;
}
/* Check chip ID and minimum chip revision that supported by this image */
uint8_t revision = bootloader_common_get_chip_revision();
ESP_LOGI(TAG, "Chip Revision: %d", revision);
if (bootloader_common_check_chip_validity(&fhdr, ESP_IMAGE_BOOTLOADER) != ESP_OK) {
return ESP_FAIL;
}
bootloader_init_flash_configure(&fhdr);
#if (CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ == 240)
//Check if ESP32 is rated for a CPU frequency of 160MHz only

View File

@ -114,17 +114,18 @@ void bootloader_random_enable(void)
void bootloader_random_disable(void)
{
/* Disable i2s clock */
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_I2S0_CLK_EN);
/* Reset some i2s configuration (possibly redundant as we reset entire
I2S peripheral further down). */
CLEAR_PERI_REG_MASK(I2S_CONF_REG(0), I2S_RX_START);
SET_PERI_REG_MASK(I2S_CONF_REG(0), I2S_RX_RESET);
CLEAR_PERI_REG_MASK(I2S_CONF_REG(0), I2S_RX_RESET);
CLEAR_PERI_REG_MASK(I2S_CONF2_REG(0), I2S_CAMERA_EN);
CLEAR_PERI_REG_MASK(I2S_CONF2_REG(0), I2S_LCD_EN);
CLEAR_PERI_REG_MASK(I2S_CONF2_REG(0), I2S_DATA_ENABLE_TEST_EN);
CLEAR_PERI_REG_MASK(I2S_CONF2_REG(0), I2S_DATA_ENABLE);
CLEAR_PERI_REG_MASK(I2S_CONF_REG(0), I2S_RX_START);
/* Disable i2s clock */
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_I2S0_CLK_EN);
/* Restore SYSCON mode registers */
CLEAR_PERI_REG_MASK(SENS_SAR_READ_CTRL_REG, SENS_SAR1_DIG_FORCE);

View File

@ -719,3 +719,38 @@ esp_err_t bootloader_sha256_hex_to_str(char *out_str, const uint8_t *in_array_he
}
return ESP_OK;
}
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

@ -27,7 +27,7 @@ static const size_t BLOCK_WORDS = (64 / sizeof(uint32_t));
// Words in final SHA256 digest
static const size_t DIGEST_WORDS = (32 / sizeof(uint32_t));
bootloader_sha256_handle_t bootloader_sha256_start()
bootloader_sha256_handle_t bootloader_sha256_start(void)
{
// Enable SHA hardware
ets_sha_enable();

View File

@ -37,7 +37,7 @@ static const char *TAG = "flash_encrypt";
/* Static functions for stages of flash encryption */
static esp_err_t initialise_flash_encryption(void);
static esp_err_t encrypt_flash_contents(uint32_t flash_crypt_cnt, bool flash_crypt_wr_dis);
static esp_err_t encrypt_flash_contents(uint32_t flash_crypt_cnt, bool flash_crypt_wr_dis) __attribute__((unused));
static esp_err_t encrypt_bootloader();
static esp_err_t encrypt_and_load_partition_table(esp_partition_info_t *partition_table, int *num_partitions);
static esp_err_t encrypt_partition(int index, const esp_partition_info_t *partition);
@ -60,8 +60,14 @@ esp_err_t esp_flash_encrypt_check_and_update(void)
return ESP_OK;
}
else {
#ifndef CONFIG_SECURE_FLASH_REQUIRE_ALREADY_ENABLED
/* Flash is not encrypted, so encrypt it! */
return encrypt_flash_contents(flash_crypt_cnt, flash_crypt_wr_dis);
#else
ESP_LOGE(TAG, "flash encryption is not enabled, and SECURE_FLASH_REQUIRE_ALREADY_ENABLED "
"is set, refusing to boot.");
return ESP_ERR_INVALID_STATE;
#endif // CONFIG_SECURE_FLASH_REQUIRE_ALREADY_ENABLED
}
}

View File

@ -24,6 +24,7 @@
#include <bootloader_random.h>
#include <bootloader_sha.h>
#include "bootloader_util.h"
#include "bootloader_common.h"
/* Checking signatures as part of verifying images is necessary:
- Always if secure boot is enabled
@ -195,8 +196,17 @@ static esp_err_t image_load(esp_image_load_mode_t mode, const esp_partition_pos_
if (!is_bootloader) {
#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);
}
#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);
@ -268,8 +278,6 @@ esp_err_t esp_image_verify(esp_image_load_mode_t mode, const esp_partition_pos_t
return image_load(mode, part, data);
}
esp_err_t esp_image_load(esp_image_load_mode_t mode, const esp_partition_pos_t *part, esp_image_metadata_t *data) __attribute__((alias("esp_image_verify")));
static esp_err_t verify_image_header(uint32_t src_addr, const esp_image_header_t *image, bool silent)
{
esp_err_t err = ESP_OK;
@ -280,6 +288,9 @@ static esp_err_t verify_image_header(uint32_t src_addr, const esp_image_header_t
}
err = ESP_ERR_IMAGE_INVALID;
}
if (bootloader_common_check_chip_validity(image, ESP_IMAGE_APPLICATION) != ESP_OK) {
err = ESP_ERR_IMAGE_INVALID;
}
if (!silent) {
if (image->spi_mode > ESP_IMAGE_SPI_MODE_SLOW_READ) {
ESP_LOGW(TAG, "image at 0x%x has invalid SPI mode %d", src_addr, image->spi_mode);
@ -644,3 +655,21 @@ static void debug_log_hash(const uint8_t *image_hash, const char *label)
ESP_LOGD(TAG, "%s: %s", label, hash_print);
#endif
}
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

@ -13,9 +13,51 @@
// limitations under the License.
#include <strings.h>
#include "sdkconfig.h"
#include "esp_log.h"
#include "esp_efuse.h"
#include "esp_efuse_table.h"
#include "esp_flash_encrypt.h"
#include "esp_secure_boot.h"
#ifndef BOOTLOADER_BUILD
static const char *TAG = "flash_encrypt";
void esp_flash_encryption_init_checks()
{
esp_flash_enc_mode_t mode;
// First check is: if Release mode flash encryption & secure boot are enabled then
// 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
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);
if (!flash_crypt_cnt_wr_dis) {
ESP_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_FLASH_ENCRYPTION_MODE_RELEASE
// Second check is to print a warning or error if the current running flash encryption mode
// doesn't match the expectation from project config (due to mismatched bootloader and app, probably)
mode = esp_get_flash_encryption_mode();
if (mode == ESP_FLASH_ENC_MODE_DEVELOPMENT) {
#ifdef CONFIG_SECURE_FLASH_ENCRYPTION_MODE_RELEASE
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_LOGW(TAG, "Flash encryption mode is DEVELOPMENT (not secure)");
#endif
} else if (mode == ESP_FLASH_ENC_MODE_RELEASE) {
ESP_LOGI(TAG, "Flash encryption mode is RELEASE");
}
}
#endif
void esp_flash_write_protect_crypt_cnt()
{
@ -28,14 +70,23 @@ void esp_flash_write_protect_crypt_cnt()
esp_flash_enc_mode_t esp_get_flash_encryption_mode()
{
uint8_t efuse_flash_crypt_cnt_wr_protected = 0;
uint8_t flash_crypt_cnt_wr_dis = 0;
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);
if (efuse_flash_crypt_cnt_wr_protected) {
esp_efuse_read_field_blob(ESP_EFUSE_WR_DIS_FLASH_CRYPT_CNT, &flash_crypt_cnt_wr_dis, 1);
if (!flash_crypt_cnt_wr_dis) {
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) {
flash_crypt_cnt_wr_dis = 1;
}
}
if (flash_crypt_cnt_wr_dis) {
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);

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

@ -18,7 +18,7 @@
#include <sys/param.h>
#include <mbedtls/sha256.h>
bootloader_sha256_handle_t bootloader_sha256_start()
bootloader_sha256_handle_t bootloader_sha256_start(void)
{
mbedtls_sha256_context *ctx = (mbedtls_sha256_context *)malloc(sizeof(mbedtls_sha256_context));
if (!ctx) {
@ -50,4 +50,5 @@ void bootloader_sha256_finish(bootloader_sha256_handle_t handle, uint8_t *digest
}
mbedtls_sha256_free(ctx);
free(handle);
handle = NULL;
}

View File

@ -56,6 +56,10 @@ 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)
{
#if !(defined(CONFIG_MBEDTLS_ECDSA_C) && defined(CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED))
ESP_LOGE(TAG, "Signature verification requires ECDSA & SECP256R1 curve enabled");
return ESP_ERR_NOT_SUPPORTED;
#else
ptrdiff_t keylen;
keylen = signature_verification_key_end - signature_verification_key_start;
@ -117,4 +121,5 @@ cleanup:
mbedtls_mpi_free(&s);
mbedtls_ecdsa_free(&ecdsa_context);
return ret == 0 ? ESP_OK : ESP_ERR_IMAGE_INVALID;
#endif // CONFIG_MBEDTLS_ECDSA_C && CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED
}

View File

@ -93,6 +93,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"
@ -289,20 +290,30 @@ if(CONFIG_BT_ENABLED)
"host/bluedroid/stack/smp/smp_l2c.c"
"host/bluedroid/stack/smp/smp_main.c"
"host/bluedroid/stack/smp/smp_utils.c")
if(CONFIG_BLE_MESH)
list(APPEND srcs "esp_ble_mesh/mesh_core/bluedroid_host/mesh_bearer_adapt.c")
endif()
endif()
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/settings"
"esp_ble_mesh/mesh_core/storage"
"esp_ble_mesh/btc/include"
"esp_ble_mesh/mesh_models/include"
"esp_ble_mesh/mesh_models/common/include"
"esp_ble_mesh/mesh_models/client/include"
"esp_ble_mesh/mesh_models/server/include"
"esp_ble_mesh/api/core/include"
"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"
@ -314,6 +325,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"
@ -321,41 +333,66 @@ 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_core/settings/settings_nvs.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"
"esp_ble_mesh/mesh_core/adv.c"
"esp_ble_mesh/mesh_core/beacon.c"
"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/mesh_aes_encrypt.c"
"esp_ble_mesh/mesh_core/mesh_atomic.c"
"esp_ble_mesh/mesh_core/mesh_bearer_adapt.c"
"esp_ble_mesh/mesh_core/mesh_buf.c"
"esp_ble_mesh/mesh_core/mesh_hci.c"
"esp_ble_mesh/mesh_core/mesh_kernel.c"
"esp_ble_mesh/mesh_core/mesh_main.c"
"esp_ble_mesh/mesh_core/mesh_util.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/provisioner_proxy.c"
"esp_ble_mesh/mesh_core/proxy.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/generic_client.c"
"esp_ble_mesh/mesh_models/lighting_client.c"
"esp_ble_mesh/mesh_models/mesh_common.c"
"esp_ble_mesh/mesh_models/model_common.c"
"esp_ble_mesh/mesh_models/sensor_client.c"
"esp_ble_mesh/mesh_models/time_scene_client.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/generic_server.c"
"esp_ble_mesh/mesh_models/server/lighting_server.c"
"esp_ble_mesh/mesh_models/server/sensor_server.c"
"esp_ble_mesh/mesh_models/server/server_common.c"
"esp_ble_mesh/mesh_models/server/state_binding.c"
"esp_ble_mesh/mesh_models/server/state_transition.c"
"esp_ble_mesh/mesh_models/server/time_scene_server.c")
endif()
if(CONFIG_BT_NIMBLE_ENABLED)
@ -376,9 +413,13 @@ if(CONFIG_BT_ENABLED)
host/nimble/nimble/nimble/host/store/ram/include
host/nimble/nimble/nimble/host/store/config/include
host/nimble/nimble/porting/npl/freertos/include
host/nimble/nimble/ext/tinycrypt/include
host/nimble/esp-hci/include)
if(NOT CONFIG_BT_NIMBLE_CRYPTO_STACK_MBEDTLS)
list(APPEND include_dirs
host/nimble/nimble/ext/tinycrypt/include)
list(APPEND srcs "host/nimble/nimble/ext/tinycrypt/src/utils.c"
"host/nimble/nimble/ext/tinycrypt/src/sha256.c"
"host/nimble/nimble/ext/tinycrypt/src/ecc.c"
@ -393,8 +434,10 @@ if(CONFIG_BT_ENABLED)
"host/nimble/nimble/ext/tinycrypt/src/hmac_prng.c"
"host/nimble/nimble/ext/tinycrypt/src/ecc_platform_specific.c"
"host/nimble/nimble/ext/tinycrypt/src/hmac.c"
"host/nimble/nimble/ext/tinycrypt/src/cbc_mode.c"
"host/nimble/nimble/nimble/host/util/src/addr.c"
"host/nimble/nimble/ext/tinycrypt/src/cbc_mode.c")
endif()
list(APPEND srcs "host/nimble/nimble/nimble/host/util/src/addr.c"
"host/nimble/nimble/nimble/host/services/gatt/src/ble_svc_gatt.c"
"host/nimble/nimble/nimble/host/services/tps/src/ble_svc_tps.c"
"host/nimble/nimble/nimble/host/services/ias/src/ble_svc_ias.c"
@ -445,6 +488,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"
@ -460,7 +504,12 @@ 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")
endif()
if(CONFIG_BT_NIMBLE_MESH)

View File

@ -1,4 +1,4 @@
menu Bluetooth
menu "Bluetooth"
config BT_ENABLED
bool "Bluetooth"
@ -77,6 +77,74 @@ 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
default n
help
BLE auto latency, used to enhance classic BT performance
while classic BT and BLE are enabled at the same time.
config BTDM_CTRL_AUTO_LATENCY_EFF
bool
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
default BTDM_CTRL_BLE_MAX_CONN if BTDM_CTRL_MODE_BLE_ONLY || BTDM_CTRL_MODE_BTDM
@ -318,8 +386,8 @@ menu Bluetooth
config BTDM_CTRL_FULL_SCAN_SUPPORTED
bool "BLE full scan feature supported"
depends on BTDM_CTRL_MODE_BLE_ONLY
default n
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.
This is required for scenes with high scan performance requirements, such as BLE Mesh scenes.
@ -358,6 +426,21 @@ 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
@ -378,6 +461,13 @@ menu Bluetooth
help
This option is recommended for BLE only usecases to save on memory
config BT_CONTROLLER_ONLY
bool "Controller Only"
help
This option is recommended when you want to communicate directly with the
controller (without any host) or when you are using any other host stack
not supported by Espressif (not mentioned here).
endchoice
menu "Bluedroid Options"
@ -395,7 +485,6 @@ endmenu
menuconfig BLE_MESH
bool "ESP BLE Mesh Support"
depends on BT_BLUEDROID_ENABLED
help
This option enables ESP BLE Mesh support. The specific features that are
available may depend on other features that have been enabled in the

View File

@ -19,6 +19,7 @@
#include "esp_log.h"
#include "bt_common.h"
#include "osi/allocator.h"
#include "btc/btc_alarm.h"
#ifdef CONFIG_BT_BLUEDROID_ENABLED
#include "common/bt_target.h"
@ -32,7 +33,6 @@
#include "btc_blufi_prf.h"
#include "blufi_int.h"
#include "btc/btc_dm.h"
#include "btc/btc_alarm.h"
#include "bta/bta_gatt_api.h"
#if CLASSIC_BT_INCLUDED
#include "btc/btc_profile_queue.h"
@ -54,6 +54,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"
@ -65,7 +66,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;
@ -90,11 +91,13 @@ 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 },
#ifdef CONFIG_BT_BLUEDROID_ENABLED
#if CLASSIC_BT_INCLUDED
#if (BTC_GAP_BT_INCLUDED == TRUE)
[BTC_PID_GAP_BT] = {btc_gap_bt_call_handler, btc_gap_bt_cb_handler },
@ -114,16 +117,45 @@ static const btc_func_t profile_tab[BTC_PID_NUM] = {
#endif /* #if CLASSIC_BT_INCLUDED */
#endif
#if CONFIG_BLE_MESH
[BTC_PID_PROV] = {btc_mesh_prov_call_handler, btc_mesh_prov_cb_handler},
[BTC_PID_MODEL] = {btc_mesh_model_call_handler, btc_mesh_model_cb_handler},
[BTC_PID_HEALTH_CLIENT] = {btc_mesh_health_client_call_handler, btc_mesh_health_client_cb_handler},
[BTC_PID_HEALTH_SERVER] = {btc_mesh_health_server_call_handler, btc_mesh_health_server_cb_handler},
[BTC_PID_CFG_CLIENT] = {btc_mesh_cfg_client_call_handler, btc_mesh_cfg_client_cb_handler},
[BTC_PID_CFG_SERVER] = {NULL , btc_mesh_cfg_server_cb_handler},
[BTC_PID_GENERIC_CLIENT] = {btc_mesh_generic_client_call_handler, btc_mesh_generic_client_cb_handler},
[BTC_PID_LIGHT_CLIENT] = {btc_mesh_light_client_call_handler, btc_mesh_light_client_cb_handler},
[BTC_PID_SENSOR_CLIENT] = {btc_mesh_sensor_client_call_handler, btc_mesh_sensor_client_cb_handler},
[BTC_PID_TIME_SCENE_CLIENT] = {btc_mesh_time_scene_client_call_handler, btc_mesh_time_scene_client_cb_handler},
[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 */
};
@ -173,6 +205,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;
@ -202,6 +243,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) {
@ -232,12 +301,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) {
@ -286,12 +356,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) {
@ -319,9 +390,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, 3);
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;
}
@ -366,3 +437,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

@ -15,9 +15,7 @@
#ifndef __BTC_MANAGE_H__
#define __BTC_MANAGE_H__
#include "bta/bta_api.h"
#include "btc/btc_task.h"
#include "esp_bt_defs.h"
#if BTC_DYNAMIC_MEMORY == FALSE
extern void *btc_profile_cb_tab[BTC_PID_NUM];

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)
@ -72,12 +74,17 @@ typedef enum {
BTC_PID_MODEL,
BTC_PID_HEALTH_CLIENT,
BTC_PID_HEALTH_SERVER,
BTC_PID_CFG_CLIENT,
BTC_PID_CFG_SERVER,
BTC_PID_CONFIG_CLIENT,
BTC_PID_CONFIG_SERVER,
BTC_PID_GENERIC_CLIENT,
BTC_PID_LIGHT_CLIENT,
BTC_PID_LIGHTING_CLIENT,
BTC_PID_SENSOR_CLIENT,
BTC_PID_TIME_SCENE_CLIENT,
BTC_PID_GENERIC_SERVER,
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
@ -89,10 +96,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

@ -49,7 +49,7 @@
#ifdef CONFIG_BTC_TASK_STACK_SIZE
#define UC_BTC_TASK_STACK_SIZE CONFIG_BTC_TASK_STACK_SIZE
#else
#define UC_BTC_TASK_STACK_SIZE 3072
#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)
@ -389,7 +395,7 @@ bool config_save(const config_t *config, const char *filename)
const size_t keyname_bufsz = sizeof(CONFIG_KEY) + 5 + 1; // including log10(sizeof(i))
char *keyname = osi_calloc(keyname_bufsz);
int config_size = get_config_size(config);
char *buf = osi_calloc(config_size + 100);
char *buf = osi_calloc(config_size);
if (!line || !buf || !keyname) {
err_code |= 0x01;
goto error;
@ -409,6 +415,16 @@ bool config_save(const config_t *config, const char *filename)
for (const list_node_t *node = list_begin(config->sections); node != list_end(config->sections); node = list_next(node)) {
const section_t *section = (const section_t *)list_node(node);
w_cnt = snprintf(line, 1024, "[%s]\n", section->name);
if(w_cnt < 0) {
OSI_TRACE_ERROR("snprintf error w_cnt %d.",w_cnt);
err_code |= 0x10;
goto error;
}
if(w_cnt_total + w_cnt > config_size) {
OSI_TRACE_ERROR("%s, memcpy size (w_cnt + w_cnt_total = %d) is larger than buffer size (config_size = %d).", __func__, (w_cnt + w_cnt_total), config_size);
err_code |= 0x20;
goto error;
}
OSI_TRACE_DEBUG("section name: %s, w_cnt + w_cnt_total = %d\n", section->name, w_cnt + w_cnt_total);
memcpy(buf + w_cnt_total, line, w_cnt);
w_cnt_total += w_cnt;
@ -417,6 +433,16 @@ bool config_save(const config_t *config, const char *filename)
const entry_t *entry = (const entry_t *)list_node(enode);
OSI_TRACE_DEBUG("(key, val): (%s, %s)\n", entry->key, entry->value);
w_cnt = snprintf(line, 1024, "%s = %s\n", entry->key, entry->value);
if(w_cnt < 0) {
OSI_TRACE_ERROR("snprintf error w_cnt %d.",w_cnt);
err_code |= 0x10;
goto error;
}
if(w_cnt_total + w_cnt > config_size) {
OSI_TRACE_ERROR("%s, memcpy size (w_cnt + w_cnt_total = %d) is larger than buffer size.(config_size = %d)", __func__, (w_cnt + w_cnt_total), config_size);
err_code |= 0x20;
goto error;
}
OSI_TRACE_DEBUG("%s, w_cnt + w_cnt_total = %d", __func__, w_cnt + w_cnt_total);
memcpy(buf + w_cnt_total, line, w_cnt);
w_cnt_total += w_cnt;
@ -524,7 +550,10 @@ static void config_parse(nvs_handle_t fp, config_t *config)
const size_t keyname_bufsz = sizeof(CONFIG_KEY) + 5 + 1; // including log10(sizeof(i))
char *keyname = osi_calloc(keyname_bufsz);
int buf_size = get_config_size_from_flash(fp);
char *buf = osi_calloc(buf_size + 100);
char *buf = osi_calloc(buf_size);
if(buf_size == 0) { //First use nvs
goto error;
}
if (!line || !section || !buf || !keyname) {
err_code |= 0x01;
goto error;

View File

@ -129,6 +129,8 @@ size_t fixed_queue_capacity(fixed_queue_t *queue)
bool fixed_queue_enqueue(fixed_queue_t *queue, void *data, uint32_t timeout)
{
bool status=false; //Flag whether enqueued success
assert(queue != NULL);
assert(data != NULL);
@ -137,13 +139,13 @@ bool fixed_queue_enqueue(fixed_queue_t *queue, void *data, uint32_t timeout)
}
osi_mutex_lock(&queue->lock, OSI_MUTEX_MAX_TIMEOUT);
list_append(queue->list, data);
status = list_append(queue->list, data); //Check whether enqueued success
osi_mutex_unlock(&queue->lock);
osi_sem_give(&queue->dequeue_sem);
if(status == true )
osi_sem_give(&queue->dequeue_sem);
return true;
return status;
}
void *fixed_queue_dequeue(fixed_queue_t *queue, uint32_t timeout)
@ -152,7 +154,7 @@ void *fixed_queue_dequeue(fixed_queue_t *queue, uint32_t timeout)
assert(queue != NULL);
if (osi_sem_take(queue->dequeue_sem, timeout) != 0) {
if (osi_sem_take(&queue->dequeue_sem, timeout) != 0) {
return NULL;
}
@ -206,14 +208,14 @@ void *fixed_queue_try_remove_from_queue(fixed_queue_t *queue, void *data)
osi_mutex_lock(&queue->lock, OSI_MUTEX_MAX_TIMEOUT);
if (list_contains(queue->list, data) &&
osi_sem_take(queue->dequeue_sem, 0) == 0) {
osi_sem_take(&queue->dequeue_sem, 0) == 0) {
removed = list_remove(queue->list, data);
assert(removed);
}
osi_mutex_unlock(&queue->lock);
if (removed) {
osi_sem_give(queue->enqueue_sem);
osi_sem_give(&queue->enqueue_sem);
return data;
}

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

@ -102,6 +102,7 @@ bool list_insert_after(list_t *list, list_node_t *prev_node, void *data) {
assert(data != NULL);
list_node_t *node = (list_node_t *)osi_calloc(sizeof(list_node_t));
if (!node) {
OSI_TRACE_ERROR("%s osi_calloc failed.\n", __FUNCTION__ );
return false;
}
node->next = prev_node->next;
@ -120,6 +121,7 @@ bool list_prepend(list_t *list, void *data)
assert(data != NULL);
list_node_t *node = (list_node_t *)osi_calloc(sizeof(list_node_t));
if (!node) {
OSI_TRACE_ERROR("%s osi_calloc failed.\n", __FUNCTION__ );
return false;
}
node->next = list->head;
@ -138,6 +140,7 @@ bool list_append(list_t *list, void *data)
assert(data != NULL);
list_node_t *node = (list_node_t *)osi_calloc(sizeof(list_node_t));
if (!node) {
OSI_TRACE_ERROR("%s osi_calloc failed.\n", __FUNCTION__ );
return false;
}
node->next = NULL;
@ -183,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);
@ -248,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

@ -129,28 +129,42 @@ COMPONENT_PRIV_INCLUDEDIRS += common/btc/include \
COMPONENT_SRCDIRS += common/osi \
common/btc/core
ifdef CONFIG_BLE_MESH
COMPONENT_SRCDIRS += esp_ble_mesh/mesh_core/bluedroid_host
endif
endif
ifdef CONFIG_BLE_MESH
COMPONENT_ADD_INCLUDEDIRS += esp_ble_mesh/mesh_core \
esp_ble_mesh/mesh_core/include \
esp_ble_mesh/mesh_core/settings \
esp_ble_mesh/btc/include \
esp_ble_mesh/mesh_models/include \
esp_ble_mesh/api/core/include \
esp_ble_mesh/api/models/include \
esp_ble_mesh/api
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 \
esp_ble_mesh/btc/include \
esp_ble_mesh/mesh_models/common/include \
esp_ble_mesh/mesh_models/client/include \
esp_ble_mesh/mesh_models/server/include \
esp_ble_mesh/api/core/include \
esp_ble_mesh/api/models/include \
esp_ble_mesh/api
COMPONENT_SRCDIRS += esp_ble_mesh/mesh_core \
esp_ble_mesh/mesh_core/settings \
esp_ble_mesh/btc \
esp_ble_mesh/mesh_models \
esp_ble_mesh/api/core \
esp_ble_mesh/api/models
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 \
esp_ble_mesh/api/models
endif
ifdef CONFIG_BT_NIMBLE_ENABLED
COMPONENT_ADD_INCLUDEDIRS += host/nimble/nimble/nimble/include \
host/nimble/nimble/nimble/host/include \
host/nimble/nimble/porting/nimble/include \
@ -165,14 +179,16 @@ COMPONENT_ADD_INCLUDEDIRS += host/nimble/nimble/nimble/include
host/nimble/nimble/nimble/host/util/include \
host/nimble/nimble/nimble/host/store/ram/include \
host/nimble/nimble/nimble/host/store/config/include \
host/nimble/nimble/ext/tinycrypt/include \
host/nimble/esp-hci/include \
host/nimble/port/include
ifndef CONFIG_BT_NIMBLE_CRYPTO_STACK_MBEDTLS
COMPONENT_ADD_INCLUDEDIRS += host/nimble/nimble/ext/tinycrypt/include
endif
COMPONENT_SRCDIRS += host/nimble/nimble/nimble/host/src \
host/nimble/nimble/porting/nimble/src \
host/nimble/nimble/porting/npl/freertos/src \
host/nimble/nimble/ext/tinycrypt/src \
host/nimble/nimble/nimble/host/services/ans/src \
host/nimble/nimble/nimble/host/services/bas/src \
host/nimble/nimble/nimble/host/services/gap/src \
@ -183,10 +199,26 @@ 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
endif
COMPONENT_OBJEXCLUDE += host/nimble/nimble/nimble/host/store/config/src/ble_store_config_conf.o
ifdef CONFIG_BLE_MESH
COMPONENT_PRIV_INCLUDEDIRS += common/btc/include \
common/include
COMPONENT_SRCDIRS += common/osi \
common/btc/core \
esp_ble_mesh/mesh_core/nimble_host
COMPONENT_ADD_INCLUDEDIRS += common/osi/include
endif
ifdef CONFIG_BT_NIMBLE_MESH
COMPONENT_ADD_INCLUDEDIRS += host/nimble/nimble/nimble/host/mesh/include

View File

@ -37,13 +37,14 @@
#include "esp_err.h"
#include "esp_log.h"
#include "esp_pm.h"
#include "esp_ipc.h"
#include "driver/periph_ctrl.h"
#include "soc/rtc.h"
#include "soc/soc_memory_layout.h"
#include "esp32/clk.h"
#include "esp_coexist_internal.h"
#if !CONFIG_FREERTOS_UNICORE
#include "esp_ipc.h"
#endif
#if CONFIG_BT_ENABLED
@ -78,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{\
@ -97,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 */
@ -174,6 +167,8 @@ 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);
@ -182,6 +177,7 @@ struct osi_funcs_t {
uint32_t _magic;
};
typedef void (*workitem_handler_t)(void* arg);
/* External functions or values
************************************************************************
@ -198,12 +194,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(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);
@ -224,6 +222,7 @@ 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 char _bss_start_btdm;
extern char _bss_end_btdm;
@ -285,8 +284,9 @@ 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);
/* Local variable definition
***************************************************************************
@ -331,9 +331,11 @@ 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,
@ -381,16 +383,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)
{
@ -740,7 +748,7 @@ static void task_delete_wrapper(void *task_handle)
static bool IRAM_ATTR is_in_isr_wrapper(void)
{
return (bool)xPortInIsrContext();
return !xPortCanYield();
}
static void IRAM_ATTR cause_sw_intr(void *arg)
@ -754,18 +762,21 @@ static int IRAM_ATTR cause_sw_intr_to_core_wrapper(int core_id, int intr_no)
{
esp_err_t err = ESP_OK;
#if CONFIG_FREERTOS_UNICORE
cause_sw_intr((void *)intr_no);
#else /* CONFIG_FREERTOS_UNICORE */
if (xPortGetCoreID() == core_id) {
cause_sw_intr((void *)intr_no);
} else {
err = esp_ipc_call(core_id, cause_sw_intr, (void *)intr_no);
}
#endif /* !CONFIG_FREERTOS_UNICORE */
return err;
}
static void *malloc_internal_wrapper(size_t size)
{
return heap_caps_malloc(size, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL);
return heap_caps_malloc(size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
}
static int32_t IRAM_ATTR read_mac_wrapper(uint8_t mac[6])
@ -842,8 +853,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);
@ -852,17 +865,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);
@ -878,14 +889,113 @@ 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;
}
bool esp_vhci_host_check_send_available(void)
{
return API_vhci_host_check_send_available();
@ -893,16 +1003,11 @@ bool esp_vhci_host_check_send_available(void)
void esp_vhci_host_send_packet(uint8_t *data, uint16_t len)
{
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
btdm_wakeup_request();
}
async_wakeup_request(BTDM_ASYNC_WAKEUP_REQ_HCI);
API_vhci_host_send_packet(data, len);
async_wakeup_request_end(BTDM_ASYNC_WAKEUP_REQ_HCI);
}
esp_err_t esp_vhci_host_register_callback(const esp_vhci_host_callback_t *callback)
@ -961,7 +1066,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;
@ -1071,6 +1176,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;
@ -1085,11 +1195,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;
}
@ -1119,12 +1224,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;
}
@ -1137,42 +1303,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();
@ -1182,18 +1313,24 @@ 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;
@ -1202,11 +1339,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;
}
@ -1221,18 +1358,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);
@ -1251,6 +1387,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;
@ -1265,9 +1414,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
@ -1305,15 +1454,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;
}
@ -1327,9 +1480,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();
}
async_wakeup_request(BTDM_ASYNC_WAKEUP_REQ_CTRL_DISA);
while (!btdm_power_state_active()) {
ets_delay_us(1000);
}
@ -1346,11 +1497,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
@ -1362,7 +1514,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)
{
@ -1449,26 +1600,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();
}
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

@ -8,12 +8,111 @@ if BLE_MESH
config BLE_MESH_USE_DUPLICATE_SCAN
bool "Support Duplicate Scan in BLE Mesh"
select BLE_SCAN_DUPLICATE
select BLE_MESH_SCAN_DUPLICATE_EN
depends on BT_BLUEDROID_ENABLED
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
in BLE Mesh, and Scan Duplicate Type must be set to 0x02.
in BLE Mesh, and Scan Duplicate Type must be set by choosing the
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"
@ -23,75 +122,112 @@ if BLE_MESH
default n
help
Enable this option to allow BLE Mesh fast provisioning solution to be used.
When there are multiple unprovisioned devices around, fast provisioning can
greatly reduce the time consumption of the whole provisioning process.
When this option is enabled, and after an unprovisioned device is provisioned
into a node successfully, it can be changed to a temporary Provisioner.
config BLE_MESH_NODE
bool "Support for BLE Mesh Node"
help
Enable the device to be provisioned into a node.
Enable the device to be provisioned into a node. This option should be
enabled when an unprovisioned device is going to be provisioned into a
node and communicate with other nodes in the BLE Mesh network.
config BLE_MESH_PROVISIONER
bool "Support for BLE Mesh Provisioner"
help
Enable the device to be a provisioner.
Enable the device to be a Provisioner. The option should be enabled when
a device is going to act as a Provisioner and provision unprovisioned
devices into the BLE Mesh network.
if BLE_MESH_PROVISIONER
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 may unprovisioned devices can be added to device
queue for provisioning.
config BLE_MESH_MAX_STORED_NODES
int "Maximum number of nodes whose information can be stored"
default 20
range 1 1000
help
This option specifies the maximum number of nodes whose information can be
stored by a provisioner in its upper layer.
This option specifies how many unprovisioned devices can be added to device
queue for provisioning. Users can use this option to define the size of the
queue in the bottom layer which is used to store unprovisioned device
information (e.g. Device UUID, address).
config BLE_MESH_MAX_PROV_NODES
int "Maximum number of devices that can be provisioned by provisioner"
default 20
range 1 100
int "Maximum number of devices that can be provisioned by Provisioner"
default 10
range 1 1000
help
This option specifies how many devices can be provisioned by provisioner.
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 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
just to limit the memory used by a Provisioner. The bigger the value is, the
more memory it will cost by a Provisioner to store the information of nodes.
if BLE_MESH_PB_ADV
config BLE_MESH_PBA_SAME_TIME
int "Maximum number of PB-ADV running at the same time by provisioner"
int "Maximum number of PB-ADV running at the same time by Provisioner"
default 2
range 1 10
help
This option specifies how many devices can be provisioned at the same
time using PB-ADV.
This option specifies how many devices can be provisioned at the same time
using PB-ADV. For examples, if the value is 2, it means a Provisioner can
provision two unprovisioned devices with PB-ADV at the same time.
endif # BLE_MESH_PB_ADV
if BLE_MESH_PB_GATT
config BLE_MESH_PBG_SAME_TIME
int "Maximum number of PB-GATT running at the same time by provisioner"
int "Maximum number of PB-GATT running at the same time by Provisioner"
default 1
range 1 5
help
This option specifies how many devices can be provisioned at the same
time using PB-GATT.
time using PB-GATT. For example, if the value is 2, it means a Provisioner
can provision two unprovisioned devices with PB-GATT at the same time.
endif # BLE_MESH_PB_GATT
config BLE_MESH_PROVISIONER_SUBNET_COUNT
int "Maximum number of mesh subnets that can be created by provisioner"
int "Maximum number of mesh subnets that can be created by Provisioner"
default 3
range 1 4096
help
This option specifies how many subnets per network a provisioner can create.
This option specifies how many subnets per network a Provisioner can create.
Indeed, this value decides the number of network keys which can be added by a Provisioner.
config BLE_MESH_PROVISIONER_APP_KEY_COUNT
int "Maximum number of application keys that can be owned by provisioner"
default 9
int "Maximum number of application keys that can be owned by Provisioner"
default 3
range 1 4096
help
This option specifies how many application keys the provisioner can have.
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
@ -109,7 +245,8 @@ if BLE_MESH
default y
help
Enable this option to allow the device to be provisioned over the
advertising bearer.
advertising bearer. This option should be enabled if PB-ADV is
going to be used during provisioning procedure.
config BLE_MESH_PB_GATT
bool "Provisioning support using GATT (PB-GATT)"
@ -117,6 +254,8 @@ if BLE_MESH
select BLE_MESH_PROV
help
Enable this option to allow the device to be provisioned over GATT.
This option should be enabled if PB-GATT is going to be used during
provisioning procedure.
# Virtual option enabled whenever any Proxy protocol is needed
config BLE_MESH_PROXY
@ -126,16 +265,19 @@ if BLE_MESH
Enable this option to support BLE Mesh Proxy protocol used by PB-GATT
and other proxy pdu transmission.
config BLE_MESH_GATT_PROXY
bool "BLE Mesh GATT Proxy Service"
config BLE_MESH_GATT_PROXY_SERVER
bool "BLE Mesh GATT Proxy Server"
select BLE_MESH_PROXY
depends on BLE_MESH_NODE
default y
help
This option enables support for Mesh GATT Proxy Service, i.e. the
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_NODE_ID_TIMEOUT
int "Node Identity advertising timeout"
depends on BLE_MESH_GATT_PROXY
depends on BLE_MESH_GATT_PROXY_SERVER
range 1 60
default 60
help
@ -143,34 +285,53 @@ if BLE_MESH
Node Identity. The given value is in seconds. The specification limits
this to 60 seconds and lists it as the recommended value as well.
So leaving the default value is the safest option.
When an unprovisioned device is provisioned successfully and becomes a
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"
default 1
default 3 if BLE_MESH_GATT_PROXY
range 1 32767
help
This option specifies how many Proxy Filter entries the local node supports.
endif # BLE_MESH_PROXY
config BLE_MESH_NET_BUF_POOL_USAGE
bool "BLE Mesh net buffer pool usage tracking"
default y
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
Enable BLE Mesh net buffer pool tracking.
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_SETTINGS
bool "Store BLE Mesh Node configuration persistently"
config BLE_MESH_GATT_PROXY_CLIENT
bool "BLE Mesh GATT Proxy Client"
select BLE_MESH_PROXY
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.
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
default y
help
Enable BLE Mesh net buffer pool tracking. This option is used to introduce another
variable in the bottom layer to record the usage of advertising buffers of BLE Mesh
devices. Recommend to enable this option as default.
config BLE_MESH_SETTINGS
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.
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
@ -178,11 +339,14 @@ if BLE_MESH
help
This value defines in seconds how soon any pending changes are actually
written into persistent storage (flash) after a change occurs.
The option allows nodes to delay a certain period of time to save proper
information to flash. The default value is 0, which means information
will be stored immediately once there are updates.
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
@ -197,18 +361,86 @@ 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)
This value defines in seconds how soon the RPL (Replay Protection List)
gets written to persistent storage after a change occurs. If the node
receives messages frequently, then a large value is recommended. If the
node receives messages rarely, then the value can be as low as 0 (which
means the PRL is written into the storage immediately).
means the RPL is written into the storage immediately).
Note that if the node operates in a security-sensitive case, and there is
a risk of sudden power-off, then a value of 0 is strongly recommended.
Otherwise, a power loss before RPL being written into the storage may
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
@ -217,6 +449,7 @@ if BLE_MESH
range 1 4096
help
This option specifies how many subnets a Mesh network can have at the same time.
Indeed, this value decides the number of the network keys which can be owned by a node.
config BLE_MESH_APP_KEY_COUNT
int "Maximum number of application keys per network"
@ -224,6 +457,7 @@ if BLE_MESH
range 1 4096
help
This option specifies how many application keys the device can store per network.
Indeed, this value decides the number of the application keys which can be owned by a node.
config BLE_MESH_MODEL_KEY_COUNT
int "Maximum number of application keys per model"
@ -247,6 +481,7 @@ if BLE_MESH
range 0 4096
help
This option specifies how many Label UUIDs can be stored.
Indeed, this value decides the number of the Virtual Addresses can be supported by a node.
config BLE_MESH_CRPL
int "Maximum capacity of the replay protection list"
@ -255,6 +490,14 @@ if BLE_MESH
help
This option specifies the maximum capacity of the replay protection list.
It is similar to Network message cache size, but has a different purpose.
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"
@ -264,6 +507,8 @@ if BLE_MESH
Number of messages that are cached for the network. This helps prevent
unnecessary decryption operations and unnecessary relays. This option
is similar to Replay protection list, but has a different purpose.
A node is not required to cache the entire Network PDU and may cache
only part of it for tracking, such as values for SRC/SEQ or others.
config BLE_MESH_ADV_BUF_COUNT
int "Number of advertising buffers"
@ -309,6 +554,11 @@ if BLE_MESH
range 1 BLE_MESH_ADV_BUF_COUNT
help
Maximum number of simultaneous outgoing multi-segment and/or reliable messages.
The default value is 1, which means the device can only send one segmented
message at a time. And if another segmented message is going to be sent, it
should wait for the completion of the previous one.
If users are going to send multiple segmented messages at the same time, this
value should be configured properly.
config BLE_MESH_RX_SEG_MSG_COUNT
int "Maximum number of simultaneous incoming segmented messages"
@ -316,6 +566,11 @@ if BLE_MESH
range 1 255
help
Maximum number of simultaneous incoming multi-segment and/or reliable messages.
The default value is 1, which means the device can only receive one segmented
message at a time. And if another segmented message is going to be received,
it should wait for the completion of the previous one.
If users are going to receive multiple segmented messages at the same time, this
value should be configured properly.
config BLE_MESH_RX_SDU_MAX
int "Maximum incoming Upper Transport Access PDU length"
@ -327,7 +582,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.
@ -351,32 +606,69 @@ if BLE_MESH
config BLE_MESH_RELAY
bool "Relay support"
depends on BLE_MESH_NODE
default y
help
Support for acting as a Mesh Relay Node.
Support for acting as a Mesh Relay Node. Enabling this option will allow
a node to support the Relay feature, and the Relay feature can still
be enabled or disabled by proper configuration messages. Disabling this
option will let a node not support the Relay feature.
if BLE_MESH_RELAY
config BLE_MESH_RELAY_ADV_BUF
bool "Use separate advertising buffers for relay packets"
default n
help
When selected, self-send packets will be put in a high-priority
queue and relay packets will be put in a low-priority queue.
if BLE_MESH_RELAY_ADV_BUF
config BLE_MESH_RELAY_ADV_BUF_COUNT
int "Number of advertising buffers for relay packets"
default 60
range 6 256
help
Number of advertising buffers for relay packets available.
endif # BLE_MESH_RELAY_ADV_BUF
endif # BLE_MESH_RELAY
config BLE_MESH_LOW_POWER
bool "Support for Low Power features"
depends on BLE_MESH_NODE
help
Enable this option to operate as a Low Power Node.
Enable this option to operate as a Low Power Node. If low power consumption
is required by a node, this option should be enabled. And once the node
enters the mesh network, it will try to find a Friend node and establish a
friendship.
if BLE_MESH_LOW_POWER
config BLE_MESH_LPN_ESTABLISHMENT
bool "Perform Friendship establishment using low power"
default y
default n
help
Perform the Friendship establishment using low power with the help of a
reduced scan duty cycle. The downside of this is that the node may miss
out on messages intended for it until it has successfully set up Friendship
with a Friend node.
When this option is enabled, the node will stop scanning for a period of
time after a Friend Request or Friend Poll is sent, so as to reduce more
power consumption.
config BLE_MESH_LPN_AUTO
bool "Automatically start looking for Friend nodes once provisioned"
default y
default n
help
Once provisioned, automatically enable LPN functionality and start looking
for Friend nodes. If this option is disabled LPN mode needs to be manually
enabled by calling bt_mesh_lpn_set(true).
When an unprovisioned device is provisioned successfully and becomes a node,
enabling this option will trigger the node starts to send Friend Request at
a certain period until it finds a proper Friend node.
config BLE_MESH_LPN_AUTO_TIMEOUT
int "Time from last received message before going to LPN mode"
@ -389,7 +681,7 @@ if BLE_MESH
config BLE_MESH_LPN_RETRY_TIMEOUT
int "Retry timeout for Friend requests"
default 8
default 6
range 1 3600
help
Time in seconds between Friend Requests, if a previous Friend Request did
@ -402,6 +694,8 @@ if BLE_MESH
help
The contribution of the RSSI, measured by the Friend node, used in Friend
Offer Delay calculations. 0 = 1, 1 = 1.5, 2 = 2, 3 = 2.5.
RSSIFactor, one of the parameters carried by Friend Request sent by Low Power
node, which is used to calculate the Friend Offer Delay.
config BLE_MESH_LPN_RECV_WIN_FACTOR
int "ReceiveWindowFactor, used in Friend Offer Delay calculation"
@ -410,6 +704,8 @@ if BLE_MESH
help
The contribution of the supported Receive Window used in Friend Offer
Delay calculations. 0 = 1, 1 = 1.5, 2 = 2, 3 = 2.5.
ReceiveWindowFactor, one of the parameters carried by Friend Request sent by
Low Power node, which is used to calculate the Friend Offer Delay.
config BLE_MESH_LPN_MIN_QUEUE_SIZE
int "Minimum size of the acceptable friend queue (MinQueueSizeLog)"
@ -440,6 +736,8 @@ if BLE_MESH
the Friend node before the PollTimeout timer expires, then the
friendship is considered terminated. The value is in units of 100
milliseconds, so e.g. a value of 300 means 30 seconds.
The smaller the value, the faster the Low Power node tries to get
messages from corresponding Friend node and vice versa.
config BLE_MESH_LPN_INIT_POLL_TIMEOUT
int "The starting value of the PollTimeout timer"
@ -467,10 +765,11 @@ if BLE_MESH
default 8
help
Maximum number of groups to which the LPN can subscribe.
endif # BLE_MESH_LOW_POWER
config BLE_MESH_FRIEND
bool "Support for acting as a Friend Node"
bool "Support for Friend feature"
help
Enable this option to be able to act as a Friend Node.
@ -489,6 +788,8 @@ if BLE_MESH
default 16
help
Minimum number of buffers available to be stored for each local Friend Queue.
This option decides the size of each buffer which can be used by a Friend node
to store messages for each Low Power node.
config BLE_MESH_FRIEND_SUB_LIST_SIZE
int "Friend Subscription List Size"
@ -496,7 +797,9 @@ if BLE_MESH
default 3
help
Size of the Subscription List that can be supported by a Friend node for a
Low Power node.
Low Power node. And Low Power node can send Friend Subscription List Add or
Friend Subscription List Remove messages to the Friend node to add or remove
subscription addresses.
config BLE_MESH_FRIEND_LPN_COUNT
int "Number of supported LPN nodes"
@ -504,6 +807,9 @@ if BLE_MESH
default 2
help
Number of Low Power Nodes with which a Friend can have Friendship simultaneously.
A Friend node can have friendship with multiple Low Power nodes at the same time,
while a Low Power node can only establish friendship with only one Friend node at
the same time.
config BLE_MESH_FRIEND_SEG_RX
int "Number of incomplete segment lists per LPN"
@ -521,7 +827,8 @@ if BLE_MESH
depends on BLE_MESH
default n
help
Select this to save the BLE Mesh related rodata code size.
Select this to save the BLE Mesh related rodata code size. Enabling this option
will disable the output of BLE Mesh debug log.
menu "BLE Mesh STACK DEBUG LOG LEVEL"
depends on BLE_MESH && !BLE_MESH_NO_LOG
@ -597,12 +904,6 @@ if BLE_MESH
endmenu #BLE Mesh NET BUF DEBUG LOG LEVEL
config BLE_MESH_IRQ_LOCK
bool "Used the IRQ lock instead of task lock"
help
To improve the real-time requirements of bt controller in BLE Mesh,
task lock is used to replace IRQ lock.
config BLE_MESH_CLIENT_MSG_TIMEOUT
int "Timeout(ms) for client message response"
range 100 1200000
@ -610,105 +911,143 @@ if BLE_MESH
help
Timeout value used by the node to get response of the acknowledged
message which is sent by the client model.
This value indicates the maximum time that a client model waits for
the response of the sent acknowledged messages. If a client model
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"
@ -716,6 +1055,7 @@ if BLE_MESH
help
This option removes the 96 hour limit of the IV Update Procedure and
lets the state to be changed at any time.
If IV Update test mode is going to be used, this option should be enabled.
menu "BLE Mesh specific test option"
@ -726,6 +1066,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
@ -801,3 +1161,4 @@ if BLE_MESH
endmenu
endif # BLE_MESH

View File

@ -0,0 +1,21 @@
# ESP-BLE-MESH Component
This is Espressif Bluetooth Low Energy Mesh component folder.
This component is a part of Espressif IoT Development Framework (ESP-IDF). For the latest documentation please refer to [ESP-IDF Programming Guide](https://docs.espressif.com/projects/esp-idf/en/latest/index.html).
The ESP-BLE-MESH networking enables many-to-many (m:m) device communications and is optimized for creating large-scale device networks.
### [ESP-BLE-MESH Documentation](https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/esp_ble_mesh/index.html)
- [Getting Started](https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/esp_ble_mesh/index.html##getting-started-with-ble-mesh)
- [Architecture](https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/esp_ble_mesh/arhitecture.html)
- [Feature List](https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/esp_ble_mesh/ble_mesh-feature-list.html)
- [FAQ](https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/esp_ble_mesh/ble_mesh_faq.html)
- [API Reference](https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/bluetooth/ble_mesh.html)
### [ESP-BLE-MESH Examples](https://github.com/espressif/esp-idf/tree/master/examples/bluetooth/esp_ble_mesh)
- Refer to **ESP-BLE-MESH Examples** of [Getting Started](https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/esp_ble_mesh/index.html##getting-started-with-ble-mesh) for the tutorials of ESP BLE Mesh examples.

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,12 +17,7 @@
#include "freertos/FreeRTOS.h"
#include "freertos/semphr.h"
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include "esp_err.h"
#include "esp_bt_defs.h"
#include "esp_bt_main.h"
#include "btc_ble_mesh_prov.h"
#include "esp_ble_mesh_defs.h"
@ -32,16 +27,22 @@ 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_OK;
if (prov == NULL || comp == NULL) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
ret = bt_mesh_host_init();
if (ret != ESP_OK) {
return ret;
}
// 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;
}
@ -56,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;
}
@ -68,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,14 +13,9 @@
// 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"
#include "esp_bt_defs.h"
#include "esp_bt_main.h"
#include "btc_ble_mesh_prov.h"
#include "esp_ble_mesh_defs.h"
@ -38,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;
@ -48,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);
}
@ -57,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;
@ -65,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;
@ -78,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,13 +14,50 @@
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include "esp_err.h"
#include "esp_bt_defs.h"
#include "esp_bt_main.h"
#include "btc_ble_mesh_prov.h"
#include "esp_ble_mesh_defs.h"
esp_err_t esp_ble_mesh_lpn_enable(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_LPN_ENABLE;
return (btc_transfer_context(&msg, NULL, 0, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_lpn_disable(bool force)
{
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_LPN_DISABLE;
arg.lpn_disable.force = force;
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_lpn_poll(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_LPN_POLL;
return (btc_transfer_context(&msg, NULL, 0, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}

View File

@ -13,37 +13,38 @@
// 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"
#include "esp_bt_defs.h"
#include "esp_bt_main.h"
#include "btc_ble_mesh_prov.h"
#include "esp_ble_mesh_networking_api.h"
#define ESP_BLE_MESH_TX_SDU_MAX ((CONFIG_BLE_MESH_ADV_BUF_COUNT - 3) * 12)
static esp_err_t ble_mesh_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)
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)
{
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_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
if (ctx && ctx->addr == ESP_BLE_MESH_ADDR_UNASSIGNED) {
BT_ERR("Invalid destination address 0x0000");
return ESP_ERR_INVALID_ARG;
}
if (device_role > ROLE_FAST_PROV) {
BT_ERR("Invalid device role 0x%02x", device_role);
return ESP_ERR_INVALID_ARG;
}
@ -62,19 +63,19 @@ static esp_err_t ble_mesh_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;
}
@ -82,7 +83,7 @@ static esp_err_t ble_mesh_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;
}
@ -108,24 +109,24 @@ static esp_err_t ble_mesh_send_msg(esp_ble_mesh_model_t *model,
arg.model_send.msg_timeout = msg_timeout;
}
status = (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_model_args_t), btc_ble_mesh_prov_arg_deep_copy)
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;
}
esp_err_t esp_ble_mesh_register_custom_model_callback(esp_ble_mesh_model_cb_t callback)
{
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
return (btc_profile_cb_set(BTC_PID_MODEL, callback) == 0 ? ESP_OK : ESP_FAIL);
}
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;
@ -157,48 +158,102 @@ esp_err_t esp_ble_mesh_client_model_init(esp_ble_mesh_model_t *model)
if (model == NULL) {
return ESP_ERR_INVALID_ARG;
}
return btc_ble_mesh_client_init(model);
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;
}
return ble_mesh_send_msg(model, ctx, opcode, BTC_BLE_MESH_ACT_SERVER_MODEL_SEND,
length, data, 0, false, ROLE_NODE);
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_send_msg(model, ctx, opcode, BTC_BLE_MESH_ACT_CLIENT_MODEL_SEND,
length, data, msg_timeout, need_rsp, device_role);
return ble_mesh_model_send_msg(model, ctx, opcode, BTC_BLE_MESH_ACT_CLIENT_MODEL_SEND,
length, data, msg_timeout, need_rsp, device_role);
}
esp_err_t esp_ble_mesh_model_publish(esp_ble_mesh_model_t *model, uint32_t opcode,
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_send_msg(model, NULL, opcode, BTC_BLE_MESH_ACT_MODEL_PUBLISH,
length, data, 0, false, device_role);
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)
{
btc_ble_mesh_model_args_t arg = {0};
btc_msg_t msg = {0};
if (!model || !value || type >= ESP_BLE_MESH_SERVER_MODEL_STATE_MAX) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
arg.model_update_state.model = model;
arg.model_update_state.type = type;
arg.model_update_state.value = value;
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_MODEL;
msg.act = BTC_BLE_MESH_ACT_SERVER_MODEL_UPDATE_STATE;
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)
{
btc_msg_t msg = {0};
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
@ -209,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};
@ -218,7 +273,7 @@ esp_err_t esp_ble_mesh_provisioner_set_node_name(int index, const char *name)
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
@ -226,36 +281,139 @@ 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_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_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};
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
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_SET_LOCAL_APP_KEY;
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)
{
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_ADD_LOCAL_APP_KEY;
arg.add_local_app_key.net_idx = net_idx;
arg.add_local_app_key.app_idx = app_idx;
@ -268,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};
@ -283,7 +464,7 @@ esp_err_t esp_ble_mesh_provisioner_bind_app_key_to_local_model(uint16_t element_
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
@ -306,7 +487,7 @@ esp_err_t esp_ble_mesh_provisioner_add_local_net_key(const uint8_t net_key[16],
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
@ -322,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,13 +13,9 @@
// limitations under the License.
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include <string.h>
#include "esp_err.h"
#include "esp_bt_defs.h"
#include "esp_bt_main.h"
#include "btc_ble_mesh_prov.h"
#include "esp_ble_mesh_provisioning_api.h"
@ -29,7 +25,7 @@
esp_err_t esp_ble_mesh_register_prov_callback(esp_ble_mesh_prov_cb_t callback)
{
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
return (btc_profile_cb_set(BTC_PID_PROV, callback) == 0 ? ESP_OK : ESP_FAIL);
}
@ -39,12 +35,30 @@ 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};
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
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;
msg.pid = BTC_PID_PROV;
@ -60,7 +74,11 @@ 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};
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
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;
msg.pid = BTC_PID_PROV;
@ -72,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};
@ -81,7 +99,7 @@ esp_err_t esp_ble_mesh_node_set_oob_pub_key(uint8_t pub_key_x[32], uint8_t pub_k
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
@ -104,7 +122,7 @@ esp_err_t esp_ble_mesh_node_input_number(uint32_t number)
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
@ -120,17 +138,18 @@ 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;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
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_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);
@ -145,21 +164,22 @@ esp_err_t esp_ble_mesh_set_unprovisioned_device_name(const char *name)
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
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_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};
@ -168,7 +188,7 @@ esp_err_t esp_ble_mesh_provisioner_read_oob_pub_key(uint8_t link_idx, uint8_t pu
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
@ -187,18 +207,20 @@ 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;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
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_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)
@ -214,7 +236,7 @@ esp_err_t esp_ble_mesh_provisioner_input_number(uint32_t number, uint8_t link_id
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
@ -232,7 +254,11 @@ 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};
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
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;
msg.pid = BTC_PID_PROV;
@ -249,7 +275,11 @@ 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};
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
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;
msg.pid = BTC_PID_PROV;
@ -262,7 +292,7 @@ esp_err_t esp_ble_mesh_provisioner_prov_disable(esp_ble_mesh_prov_bearer_t beare
}
esp_err_t esp_ble_mesh_provisioner_add_unprov_dev(esp_ble_mesh_unprov_dev_add_t *add_dev,
esp_ble_mesh_dev_add_flag_t flags)
esp_ble_mesh_dev_add_flag_t flags)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
@ -271,7 +301,7 @@ esp_err_t esp_ble_mesh_provisioner_add_unprov_dev(esp_ble_mesh_unprov_dev_add_t
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
@ -280,13 +310,47 @@ esp_err_t esp_ble_mesh_provisioner_add_unprov_dev(esp_ble_mesh_unprov_dev_add_t
arg.provisioner_dev_add.add_dev.addr_type = add_dev->addr_type;
arg.provisioner_dev_add.add_dev.oob_info = add_dev->oob_info;
arg.provisioner_dev_add.add_dev.bearer = add_dev->bearer;
memcpy(arg.provisioner_dev_add.add_dev.addr, add_dev->addr, sizeof(esp_bd_addr_t));
memcpy(arg.provisioner_dev_add.add_dev.addr, add_dev->addr, sizeof(esp_ble_mesh_bd_addr_t));
memcpy(arg.provisioner_dev_add.add_dev.uuid, add_dev->uuid, 16);
arg.provisioner_dev_add.flags = flags;
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_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;
@ -297,7 +361,7 @@ esp_err_t esp_ble_mesh_provisioner_delete_dev(esp_ble_mesh_device_delete_t *del_
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
@ -306,7 +370,7 @@ esp_err_t esp_ble_mesh_provisioner_delete_dev(esp_ble_mesh_device_delete_t *del_
arg.provisioner_dev_del.del_dev.flag = del_dev->flag;
if (del_dev->flag & DEL_DEV_ADDR_FLAG) {
arg.provisioner_dev_del.del_dev.addr_type = del_dev->addr_type;
memcpy(arg.provisioner_dev_del.del_dev.addr, del_dev->addr, sizeof(esp_bd_addr_t));
memcpy(arg.provisioner_dev_del.del_dev.addr, del_dev->addr, sizeof(esp_ble_mesh_bd_addr_t));
} else if (del_dev->flag & DEL_DEV_UUID_FLAG) {
memcpy(arg.provisioner_dev_del.del_dev.uuid, del_dev->uuid, 16);
}
@ -315,12 +379,16 @@ 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};
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
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;
msg.pid = BTC_PID_PROV;
@ -346,7 +414,7 @@ esp_err_t esp_ble_mesh_provisioner_set_prov_data_info(esp_ble_mesh_prov_data_inf
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
@ -364,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 */
@ -375,11 +484,12 @@ 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;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
@ -408,7 +518,7 @@ esp_err_t esp_ble_mesh_set_fast_prov_action(esp_ble_mesh_fast_prov_action_t acti
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;

View File

@ -13,13 +13,9 @@
// limitations under the License.
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include <string.h>
#include "esp_err.h"
#include "esp_bt_defs.h"
#include "esp_bt_main.h"
#include "btc_ble_mesh_prov.h"
#include "esp_ble_mesh_defs.h"
@ -28,7 +24,7 @@ esp_err_t esp_ble_mesh_proxy_identity_enable(void)
{
btc_msg_t msg = {0};
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
@ -41,7 +37,7 @@ esp_err_t esp_ble_mesh_proxy_gatt_enable(void)
{
btc_msg_t msg = {0};
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
@ -54,7 +50,7 @@ esp_err_t esp_ble_mesh_proxy_gatt_disable(void)
{
btc_msg_t msg = {0};
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
@ -63,3 +59,118 @@ esp_err_t esp_ble_mesh_proxy_gatt_disable(void)
return (btc_transfer_context(&msg, NULL, 0, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
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)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (!addr || addr_type > ESP_BLE_MESH_ADDR_TYPE_RANDOM) {
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_PROXY_CLIENT_CONNECT;
memcpy(arg.proxy_client_connect.addr, addr, BD_ADDR_LEN);
arg.proxy_client_connect.addr_type = addr_type;
arg.proxy_client_connect.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);
}
esp_err_t esp_ble_mesh_proxy_client_disconnect(uint8_t conn_handle)
{
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_PROXY_CLIENT_DISCONNECT;
arg.proxy_client_disconnect.conn_handle = conn_handle;
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_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};
if (filter_type > PROXY_FILTER_BLACKLIST) {
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_PROXY_CLIENT_SET_FILTER_TYPE;
arg.proxy_client_set_filter_type.conn_handle = conn_handle;
arg.proxy_client_set_filter_type.net_idx = net_idx;
arg.proxy_client_set_filter_type.filter_type = filter_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_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};
if (!addr || addr_num == 0) {
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_PROXY_CLIENT_ADD_FILTER_ADDR;
arg.proxy_client_add_filter_addr.conn_handle = conn_handle;
arg.proxy_client_add_filter_addr.net_idx = net_idx;
arg.proxy_client_add_filter_addr.addr_num = addr_num;
arg.proxy_client_add_filter_addr.addr = addr;
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_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};
if (!addr || addr_num == 0) {
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_PROXY_CLIENT_REMOVE_FILTER_ADDR;
arg.proxy_client_remove_filter_addr.conn_handle = conn_handle;
arg.proxy_client_remove_filter_addr.net_idx = net_idx;
arg.proxy_client_remove_filter_addr.addr_num = addr_num;
arg.proxy_client_remove_filter_addr.addr = addr;
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);
}

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,4 +17,53 @@
#include "esp_ble_mesh_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Enable BLE Mesh device LPN functionality.
*
* @note This API enables LPN functionality. Once called, the proper
* Friend Request will be sent.
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_lpn_enable(void);
/**
* @brief Disable BLE Mesh device LPN functionality.
*
* @param[in] force: when disabling LPN functionality, use this flag to indicate
* whether directly clear corresponding information or just
* send friend clear to disable it if friendship has already
* been established.
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_lpn_disable(bool force);
/**
* @brief LPN tries to poll messages from the Friend Node.
*
* @note The Friend Poll message is sent by a Low Power node to ask the Friend
* node to send a message that it has stored for the Low Power node.
* Users can call this API to send Friend Poll message manually. If this
* API is not invoked, the bottom layer of the Low Power node will send
* Friend Poll before the PollTimeout timer expires.
* If the corresponding Friend Update is received and MD is set to 0,
* which means there are no messages for the Low Power node, then the
* Low Power node will stop scanning.
*
* @return ESP_OK on success or error code otherwise.
*
*/
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.
@ -134,6 +153,25 @@ 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);
/**
* @brief Update a server model state value. If the model publication
* state is set properly (e.g. publish address is set to a valid
* address), it will publish corresponding status message.
*
* @note Currently this API is used to update bound state value, not
* for all server model states.
*
* @param[in] model: Server model which is going to update the state.
* @param[in] type: Server model state type.
* @param[in] value: Server model state value.
*
* @return ESP_OK on success or error code otherwise.
*
*/
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);
/**
* @brief Reset the provisioning procedure of the local BLE Mesh node.
*
@ -157,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.
@ -169,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.
@ -196,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.
@ -224,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.
@ -241,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.
*
@ -251,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.
*
@ -262,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.
*
@ -259,9 +290,9 @@ esp_err_t esp_ble_mesh_provisioner_delete_dev(esp_ble_mesh_device_delete_t *del_
* @param[in] bearer: Adv packet received from PB-GATT or PB-ADV bearer.
*
*/
typedef void (*esp_ble_mesh_prov_adv_cb_t)(const esp_bd_addr_t addr, const esp_ble_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);
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);
/**
* @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_bd_addr_t addr, const esp_b
*
*/
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.
*
@ -49,5 +53,75 @@ esp_err_t esp_ble_mesh_proxy_gatt_enable(void);
*/
esp_err_t esp_ble_mesh_proxy_gatt_disable(void);
/**
* @brief Proxy Client creates a connection with the Proxy Server.
*
* @param[in] addr: Device address of the Proxy Server.
* @param[in] addr_type: Device address type(public or static random).
* @param[in] net_idx: NetKey Index related with Network ID in the Mesh Proxy
* advertising packet.
*
* @return ESP_OK on success or error code otherwise.
*
*/
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);
/**
* @brief Proxy Client terminates a connection with the Proxy Server.
*
* @param[in] conn_handle: Proxy connection handle.
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_proxy_client_disconnect(uint8_t conn_handle);
/**
* @brief Proxy Client sets the filter type of the Proxy Server.
*
* @param[in] conn_handle: Proxy connection handle.
* @param[in] net_idx: Corresponding NetKey Index.
* @param[in] filter_type: whitelist or blacklist.
*
* @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);
/**
* @brief Proxy Client adds address to the Proxy Server filter list.
*
* @param[in] conn_handle: Proxy connection handle.
* @param[in] net_idx: Corresponding NetKey Index.
* @param[in] addr: Pointer to the filter address.
* @param[in] addr_num: Number of the filter address.
*
* @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);
/**
* @brief Proxy Client removes address from the Proxy Server filter list.
*
* @param[in] conn_handle: Proxy connection handle.
* @param[in] net_idx: Corresponding NetKey Index.
* @param[in] addr: Pointer to the filter address.
* @param[in] addr_num: Number of the filter address.
*
* @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);
#ifdef __cplusplus
}
#endif
#endif /* _ESP_BLE_MESH_PROXY_API_H_ */

File diff suppressed because it is too large Load Diff

View File

@ -14,69 +14,92 @@
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include "esp_bt_defs.h"
#include "esp_bt_main.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_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
return (btc_profile_cb_set(BTC_PID_CFG_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
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_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
return (btc_profile_cb_set(BTC_PID_CFG_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_cfg_client_args_t arg = {0};
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;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_CFG_CLIENT;
msg.pid = BTC_PID_CONFIG_CLIENT;
msg.act = BTC_BLE_MESH_ACT_CONFIG_CLIENT_GET_STATE;
arg.cfg_client_get_state.params = params;
arg.cfg_client_get_state.get_state = get_state;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_cfg_client_args_t), btc_ble_mesh_cfg_client_arg_deep_copy)
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);
}
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_cfg_client_args_t arg = {0};
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;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_CFG_CLIENT;
msg.pid = BTC_PID_CONFIG_CLIENT;
msg.act = BTC_BLE_MESH_ACT_CONFIG_CLIENT_SET_STATE;
arg.cfg_client_set_state.params = params;
arg.cfg_client_set_state.set_state = set_state;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_cfg_client_args_t), btc_ble_mesh_cfg_client_arg_deep_copy)
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,33 +14,47 @@
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include "esp_bt_defs.h"
#include "esp_bt_main.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_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
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;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GENERIC_CLIENT;
@ -53,16 +67,19 @@ 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;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GENERIC_CLIENT;
@ -73,3 +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,40 +14,34 @@
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include "esp_bt_defs.h"
#include "esp_bt_main.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_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
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_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_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;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_HEALTH_CLIENT;
@ -60,16 +54,19 @@ 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;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_HEALTH_CLIENT;
@ -80,19 +77,33 @@ 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)
{
btc_ble_mesh_health_server_args_t arg = {0};
btc_msg_t msg = {0};
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
if (element == 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_HEALTH_SERVER;
msg.act = BTC_BLE_MESH_ACT_HEALTH_SERVER_FAULT_UPDATE;
arg.fault_update.element = element;
arg.health_fault_update.element = 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,63 +14,76 @@
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include "esp_bt_defs.h"
#include "esp_bt_main.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_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
return (btc_profile_cb_set(BTC_PID_LIGHT_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
return (btc_profile_cb_set(BTC_PID_LIGHTING_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
}
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_light_client_args_t arg = {0};
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;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_LIGHT_CLIENT;
msg.act = BTC_BLE_MESH_ACT_LIGHT_CLIENT_GET_STATE;
msg.pid = BTC_PID_LIGHTING_CLIENT;
msg.act = BTC_BLE_MESH_ACT_LIGHTING_CLIENT_GET_STATE;
arg.light_client_get_state.params = params;
arg.light_client_get_state.get_state = get_state;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_light_client_args_t), btc_ble_mesh_light_client_arg_deep_copy)
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);
}
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_light_client_args_t arg = {0};
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;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_LIGHT_CLIENT;
msg.act = BTC_BLE_MESH_ACT_LIGHT_CLIENT_SET_STATE;
msg.pid = BTC_PID_LIGHTING_CLIENT;
msg.act = BTC_BLE_MESH_ACT_LIGHTING_CLIENT_SET_STATE;
arg.light_client_set_state.params = params;
arg.light_client_set_state.set_state = set_state;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_light_client_args_t), btc_ble_mesh_light_client_arg_deep_copy)
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,33 +14,33 @@
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include "esp_bt_defs.h"
#include "esp_bt_main.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_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
return (btc_profile_cb_set(BTC_PID_SENSOR_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
}
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;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_SENSOR_CLIENT;
@ -53,16 +53,19 @@ 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;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_SENSOR_CLIENT;
@ -73,4 +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,33 +14,34 @@
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include "esp_bt_defs.h"
#include "esp_bt_main.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_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
return (btc_profile_cb_set(BTC_PID_TIME_SCENE_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
}
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;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_TIME_SCENE_CLIENT;
@ -53,16 +54,19 @@ 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;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_TIME_SCENE_CLIENT;
@ -73,4 +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.
@ -79,8 +83,8 @@ typedef struct esp_ble_mesh_cfg_srv {
uint8_t min_hops; /*!< Minimum hops when receiving Heartbeat messages */
uint8_t max_hops; /*!< Maximum hops when receiving Heartbeat messages */
/** Optional subscription tracking function */
void (*func)(uint8_t hops, uint16_t feature);
/** Optional heartbeat subscription tracking function */
esp_ble_mesh_cb_t heartbeat_recv_cb;
} heartbeat_sub;
} esp_ble_mesh_cfg_srv_t;
@ -513,8 +517,8 @@ typedef struct {
/** Parameters of Config Network Transmit Status */
typedef struct {
uint8_t net_trans_count:3; /*!< Number of transmissions for each Network PDU originating from the node */
uint8_t net_trans_step :5; /*!< Maximum hops when receiving Heartbeat messages */
uint8_t net_trans_count: 3; /*!< Number of transmissions for each Network PDU originating from the node */
uint8_t net_trans_step : 5; /*!< Maximum hops when receiving Heartbeat messages */
} esp_ble_mesh_cfg_net_trans_status_cb_t;
/** Parameters of Config SIG/Vendor Subscription List */
@ -610,28 +614,135 @@ typedef enum {
ESP_BLE_MESH_CFG_CLIENT_EVT_MAX,
} esp_ble_mesh_cfg_client_cb_event_t;
/** Parameter of Config AppKey Add */
/**
* @brief Configuration Server model related context.
*/
typedef struct {
uint16_t app_idx; /*!< AppKey Index of the Config AppKey Add */
} esp_ble_mesh_cfg_srv_app_key_add_cb_t;
uint16_t element_addr; /*!< Element Address */
uint16_t pub_addr; /*!< Publish Address */
uint16_t app_idx; /*!< AppKey Index */
bool cred_flag; /*!< Friendship Credential Flag */
uint8_t pub_ttl; /*!< Publish TTL */
uint8_t pub_period; /*!< Publish Period */
uint8_t pub_retransmit; /*!< Publish Retransmit */
uint16_t company_id; /*!< Company ID */
uint16_t model_id; /*!< Model ID */
} esp_ble_mesh_state_change_cfg_mod_pub_set_t;
/** Parameters of Config Model Subscription Add */
typedef struct {
uint16_t element_addr; /*!< Element Address */
uint16_t sub_addr; /*!< Subscription Address */
uint16_t company_id; /*!< Company ID */
uint16_t model_id; /*!< Model ID */
} esp_ble_mesh_state_change_cfg_model_sub_add_t;
/** Parameters of Config Model Subscription Delete */
typedef struct {
uint16_t element_addr; /*!< Element Address */
uint16_t sub_addr; /*!< Subscription Address */
uint16_t company_id; /*!< Company ID */
uint16_t model_id; /*!< Model ID */
} esp_ble_mesh_state_change_cfg_model_sub_delete_t;
/** Parameters of Config NetKey Add */
typedef struct {
uint16_t net_idx; /*!< NetKey Index */
uint8_t net_key[16]; /*!< NetKey */
} esp_ble_mesh_state_change_cfg_netkey_add_t;
/** Parameters of Config NetKey Update */
typedef struct {
uint16_t net_idx; /*!< NetKey Index */
uint8_t net_key[16]; /*!< NetKey */
} esp_ble_mesh_state_change_cfg_netkey_update_t;
/** Parameter of Config NetKey Delete */
typedef struct {
uint16_t net_idx; /*!< NetKey Index */
} esp_ble_mesh_state_change_cfg_netkey_delete_t;
/** Parameters of Config AppKey Add */
typedef struct {
uint16_t net_idx; /*!< NetKey Index */
uint16_t app_idx; /*!< AppKey Index */
uint8_t app_key[16]; /*!< AppKey */
} esp_ble_mesh_state_change_cfg_appkey_add_t;
/** Parameters of Config AppKey Update */
typedef struct {
uint16_t net_idx; /*!< NetKey Index */
uint16_t app_idx; /*!< AppKey Index */
uint8_t app_key[16]; /*!< AppKey */
} esp_ble_mesh_state_change_cfg_appkey_update_t;
/** Parameters of Config AppKey Delete */
typedef struct {
uint16_t net_idx; /*!< NetKey Index */
uint16_t app_idx; /*!< AppKey Index */
} esp_ble_mesh_state_change_cfg_appkey_delete_t;
/** Parameters of Config Model App Bind */
typedef struct {
uint16_t element_addr; /*!< Element Address */
uint16_t app_idx; /*!< AppKey Index */
uint16_t company_id; /*!< Company ID */
uint16_t model_id; /*!< Model ID */
} esp_ble_mesh_state_change_cfg_model_app_bind_t;
/** Parameters of Config Model App Unbind */
typedef struct {
uint16_t element_addr; /*!< Element Address */
uint16_t app_idx; /*!< AppKey Index */
uint16_t company_id; /*!< Company ID */
uint16_t model_id; /*!< Model ID */
} esp_ble_mesh_state_change_cfg_model_app_unbind_t;
/** Parameters of Config Key Refresh Phase Set */
typedef struct {
uint16_t net_idx; /*!< NetKey Index */
uint8_t kr_phase; /*!< New Key Refresh Phase Transition */
} esp_ble_mesh_state_change_cfg_kr_phase_set_t;
/**
* @brief Configuration Server Model received message union
* @brief Configuration Server model state change value union
*/
typedef union {
esp_ble_mesh_cfg_srv_app_key_add_cb_t app_key_add; /*!< The Config AppKey Add event value */
} esp_ble_mesh_cfg_server_common_cb_param_t;
/**
* The recv_op in ctx can be used to decide which state is changed.
*/
esp_ble_mesh_state_change_cfg_mod_pub_set_t mod_pub_set; /*!< Config Model Publication Set */
esp_ble_mesh_state_change_cfg_model_sub_add_t mod_sub_add; /*!< Config Model Subscription Add */
esp_ble_mesh_state_change_cfg_model_sub_delete_t mod_sub_delete; /*!< Config Model Subscription Delete */
esp_ble_mesh_state_change_cfg_netkey_add_t netkey_add; /*!< Config NetKey Add */
esp_ble_mesh_state_change_cfg_netkey_update_t netkey_update; /*!< Config NetKey Update */
esp_ble_mesh_state_change_cfg_netkey_delete_t netkey_delete; /*!< Config NetKey Delete */
esp_ble_mesh_state_change_cfg_appkey_add_t appkey_add; /*!< Config AppKey Add */
esp_ble_mesh_state_change_cfg_appkey_update_t appkey_update; /*!< Config AppKey Update */
esp_ble_mesh_state_change_cfg_appkey_delete_t appkey_delete; /*!< Config AppKey Delete */
esp_ble_mesh_state_change_cfg_model_app_bind_t mod_app_bind; /*!< Config Model App Bind */
esp_ble_mesh_state_change_cfg_model_app_unbind_t mod_app_unbind; /*!< Config Model App Unbind */
esp_ble_mesh_state_change_cfg_kr_phase_set_t kr_phase_set; /*!< Config Key Refresh Phase Set */
} esp_ble_mesh_cfg_server_state_change_t;
/** Configuration Server Model callback parameters */
/**
* @brief Configuration Server model callback value union
*/
typedef union {
esp_ble_mesh_cfg_server_state_change_t state_change; /*!< ESP_BLE_MESH_CFG_SERVER_STATE_CHANGE_EVT */
} esp_ble_mesh_cfg_server_cb_value_t;
/** Configuration Server model callback parameters */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the server model structure */
esp_ble_mesh_msg_ctx_t ctx; /*!< The context of the received message */
esp_ble_mesh_cfg_server_common_cb_param_t status_cb; /*!< The received configuration message callback values */
esp_ble_mesh_model_t *model; /*!< Pointer to the server model structure */
esp_ble_mesh_msg_ctx_t ctx; /*!< Context of the received message */
esp_ble_mesh_cfg_server_cb_value_t value; /*!< Value of the received configuration messages */
} esp_ble_mesh_cfg_server_cb_param_t;
/** This enum value is the event of Configuration Server Model */
/** This enum value is the event of Configuration Server model */
typedef enum {
ESP_BLE_MESH_CFG_SERVER_RECV_MSG_EVT,
ESP_BLE_MESH_CFG_SERVER_STATE_CHANGE_EVT,
ESP_BLE_MESH_CFG_SERVER_EVT_MAX,
} esp_ble_mesh_cfg_server_cb_event_t;
@ -645,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
@ -653,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.
@ -689,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.
@ -705,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

@ -19,9 +19,12 @@
#ifndef _ESP_BLE_MESH_GENERIC_MODEL_API_H_
#define _ESP_BLE_MESH_GENERIC_MODEL_API_H_
#include "generic_client.h"
#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.
@ -257,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;
@ -364,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. */
@ -480,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.
@ -506,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.
@ -522,8 +525,781 @@ 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.
*/
/** @def ESP_BLE_MESH_MODEL_GEN_ONOFF_SRV
*
* @brief Define a new Generic OnOff Server Model.
*
* @note 1. The Generic OnOff Server Model is a root model.
* 2. This model shall support model publication and model subscription.
*
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
* @param srv_data Pointer to the unique struct esp_ble_mesh_gen_onoff_srv_t.
*
* @return New Generic OnOff Server Model instance.
*/
#define ESP_BLE_MESH_MODEL_GEN_ONOFF_SRV(srv_pub, srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_SRV, \
NULL, srv_pub, srv_data)
/** @def ESP_BLE_MESH_MODEL_GEN_LEVEL_SRV
*
* @brief Define a new Generic Level Server Model.
*
* @note 1. The Generic Level Server Model is a root model.
* 2. This model shall support model publication and model subscription.
*
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
* @param srv_data Pointer to the unique struct esp_ble_mesh_gen_level_srv_t.
*
* @return New Generic Level Server Model instance.
*/
#define ESP_BLE_MESH_MODEL_GEN_LEVEL_SRV(srv_pub, srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_LEVEL_SRV, \
NULL, srv_pub, srv_data)
/** @def ESP_BLE_MESH_MODEL_GEN_DEF_TRANS_TIME_SRV
*
* @brief Define a new Generic Default Transition Time Server Model.
*
* @note 1. The Generic Default Transition Time Server Model is a root model.
* 2. This model shall support model publication and model subscription.
*
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
* @param srv_data Pointer to the unique struct esp_ble_mesh_gen_def_trans_time_srv_t.
*
* @return New Generic Default Transition Time Server Model instance.
*/
#define ESP_BLE_MESH_MODEL_GEN_DEF_TRANS_TIME_SRV(srv_pub, srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_SRV, \
NULL, srv_pub, srv_data)
/** @def ESP_BLE_MESH_MODEL_GEN_POWER_ONOFF_SRV
*
* @brief Define a new Generic Power OnOff Server Model.
*
* @note 1. The Generic Power OnOff Server model extends the Generic OnOff Server
* model. When this model is present on an element, the corresponding
* Generic Power OnOff Setup Server model shall also be present.
* 2. This model may be used to represent a variety of devices that do not
* fit any of the model descriptions that have been defined but support
* the generic properties of On/Off.
* 3. This model shall support model publication and model subscription.
*
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
* @param srv_data Pointer to the unique struct esp_ble_mesh_gen_power_onoff_srv_t.
*
* @return New Generic Power OnOff Server Model instance.
*/
#define ESP_BLE_MESH_MODEL_GEN_POWER_ONOFF_SRV(srv_pub, srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SRV, \
NULL, srv_pub, srv_data)
/** @def ESP_BLE_MESH_MODEL_GEN_POWER_ONOFF_SETUP_SRV
*
* @brief Define a new Generic Power OnOff Setup Server Model.
*
* @note 1. The Generic Power OnOff Setup Server model extends the Generic Power
* OnOff Server model and the Generic Default Transition Time Server model.
* 2. This model shall support model subscription.
*
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
* @param srv_data Pointer to the unique struct esp_ble_mesh_gen_power_onoff_setup_srv_t.
*
* @return New Generic Power OnOff Setup Server Model instance.
*/
#define ESP_BLE_MESH_MODEL_GEN_POWER_ONOFF_SETUP_SRV(srv_pub, srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SETUP_SRV, \
NULL, srv_pub, srv_data)
/** @def ESP_BLE_MESH_MODEL_GEN_POWER_LEVEL_SRV
*
* @brief Define a new Generic Power Level Server Model.
*
* @note 1. The Generic Power Level Server model extends the Generic Power OnOff
* Server model and the Generic Level Server model. When this model is
* present on an Element, the corresponding Generic Power Level Setup
* Server model shall also be present.
* 2. This model shall support model publication and model subscription.
*
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
* @param srv_data Pointer to the unique struct esp_ble_mesh_gen_power_level_srv_t.
*
* @return New Generic Power Level Server Model instance.
*/
#define ESP_BLE_MESH_MODEL_GEN_POWER_LEVEL_SRV(srv_pub, srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SRV, \
NULL, srv_pub, srv_data)
/** @def ESP_BLE_MESH_MODEL_GEN_POWER_LEVEL_SETUP_SRV
*
* @brief Define a new Generic Power Level Setup Server Model.
*
* @note 1. The Generic Power Level Setup Server model extends the Generic Power
* Level Server model and the Generic Power OnOff Setup Server model.
* 2. This model shall support model subscription.
*
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
* @param srv_data Pointer to the unique struct esp_ble_mesh_gen_power_level_setup_srv_t.
*
* @return New Generic Power Level Setup Server Model instance.
*/
#define ESP_BLE_MESH_MODEL_GEN_POWER_LEVEL_SETUP_SRV(srv_pub, srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SETUP_SRV, \
NULL, srv_pub, srv_data)
/** @def ESP_BLE_MESH_MODEL_GEN_BATTERY_SRV
*
* @brief Define a new Generic Battery Server Model.
*
* @note 1. The Generic Battery Server Model is a root model.
* 2. This model shall support model publication and model subscription.
* 3. The model may be used to represent an element that is powered by a battery.
*
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
* @param srv_data Pointer to the unique struct esp_ble_mesh_gen_battery_srv_t.
*
* @return New Generic Battery Server Model instance.
*/
#define ESP_BLE_MESH_MODEL_GEN_BATTERY_SRV(srv_pub, srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_BATTERY_SRV, \
NULL, srv_pub, srv_data)
/** @def ESP_BLE_MESH_MODEL_GEN_LOCATION_SRV
*
* @brief Define a new Generic Location Server Model.
*
* @note 1. The Generic Location Server model is a root model. When this model
* is present on an Element, the corresponding Generic Location Setup
* Server model shall also be present.
* 2. This model shall support model publication and model subscription.
* 3. The model may be used to represent an element that knows its
* location (global or local).
*
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
* @param srv_data Pointer to the unique struct esp_ble_mesh_gen_location_srv_t.
*
* @return New Generic Location Server Model instance.
*/
#define ESP_BLE_MESH_MODEL_GEN_LOCATION_SRV(srv_pub, srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_LOCATION_SRV, \
NULL, srv_pub, srv_data)
/** @def ESP_BLE_MESH_MODEL_GEN_LOCATION_SETUP_SRV
*
* @brief Define a new Generic Location Setup Server Model.
*
* @note 1. The Generic Location Setup Server model extends the Generic Location
* Server model.
* 2. This model shall support model subscription.
*
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
* @param srv_data Pointer to the unique struct esp_ble_mesh_gen_location_setup_srv_t.
*
* @return New Generic Location Setup Server Model instance.
*/
#define ESP_BLE_MESH_MODEL_GEN_LOCATION_SETUP_SRV(srv_pub, srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_LOCATION_SETUP_SRV, \
NULL, srv_pub, srv_data)
/** @def ESP_BLE_MESH_MODEL_GEN_USER_PROP_SRV
*
* @brief Define a new Generic User Property Server Model.
*
* @note 1. The Generic User Property Server model is a root model.
* 2. This model shall support model publication and model subscription.
*
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
* @param srv_data Pointer to the unique struct esp_ble_mesh_gen_user_prop_srv_t.
*
* @return New Generic User Property Server Model instance.
*/
#define ESP_BLE_MESH_MODEL_GEN_USER_PROP_SRV(srv_pub, srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_USER_PROP_SRV, \
NULL, srv_pub, srv_data)
/** @def ESP_BLE_MESH_MODEL_GEN_ADMIN_PROP_SRV
*
* @brief Define a new Generic Admin Property Server Model.
*
* @note 1. The Generic Admin Property Server model extends the Generic User
* Property Server model.
* 2. This model shall support model publication and model subscription.
*
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
* @param srv_data Pointer to the unique struct esp_ble_mesh_gen_admin_prop_srv_t.
*
* @return New Generic Admin Property Server Model instance.
*/
#define ESP_BLE_MESH_MODEL_GEN_ADMIN_PROP_SRV(srv_pub, srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_ADMIN_PROP_SRV, \
NULL, srv_pub, srv_data)
/** @def ESP_BLE_MESH_MODEL_GEN_MANUFACTURER_PROP_SRV
*
* @brief Define a new Generic Manufacturer Property Server Model.
*
* @note 1. The Generic Manufacturer Property Server model extends the Generic
* User Property Server model.
* 2. This model shall support model publication and model subscription.
*
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
* @param srv_data Pointer to the unique struct esp_ble_mesh_gen_manu_prop_srv_t.
*
* @return New Generic Manufacturer Property Server Model instance.
*/
#define ESP_BLE_MESH_MODEL_GEN_MANUFACTURER_PROP_SRV(srv_pub, srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_MANUFACTURER_PROP_SRV, \
NULL, srv_pub, srv_data)
/** @def ESP_BLE_MESH_MODEL_GEN_CLIENT_PROP_SRV
*
* @brief Define a new Generic User Property Server Model.
*
* @note 1. The Generic Client Property Server model is a root model.
* 2. This model shall support model publication and model subscription.
*
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
* @param srv_data Pointer to the unique struct esp_ble_mesh_gen_client_prop_srv_t.
*
* @return New Generic Client Property Server Model instance.
*/
#define ESP_BLE_MESH_MODEL_GEN_CLIENT_PROP_SRV(srv_pub, srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_CLIENT_PROP_SRV, \
NULL, srv_pub, srv_data)
/** Parameters of Generic OnOff state */
typedef struct {
uint8_t onoff; /*!< The present value of the Generic OnOff state */
uint8_t target_onoff; /*!< The target value of the Generic OnOff state */
} esp_ble_mesh_gen_onoff_state_t;
/** User data of Generic OnOff Server Model */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Generic OnOff Server Model. Initialized internally. */
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
esp_ble_mesh_gen_onoff_state_t state; /*!< Parameters of the Generic OnOff state */
esp_ble_mesh_last_msg_info_t last; /*!< Parameters of the last received set message */
esp_ble_mesh_state_transition_t transition; /*!< Parameters of state transition */
} esp_ble_mesh_gen_onoff_srv_t;
/** Parameters of Generic Level state */
typedef struct {
int16_t level; /*!< The present value of the Generic Level state */
int16_t target_level; /*!< The target value of the Generic Level state */
/**
* When a new transaction starts, level should be set to last_last, and use
* "level + incoming delta" to calculate the target level. In another word,
* "last_level" is used to record "level" of the last transaction, and
* "last_delta" is used to record the previously received delta_level value.
*/
int16_t last_level; /*!< The last value of the Generic Level state */
int32_t last_delta; /*!< The last delta change of the Generic Level state */
bool move_start; /*!< Indicate if the transition of the Generic Level state has been started */
bool positive; /*!< Indicate if the transition is positive or negative */
} esp_ble_mesh_gen_level_state_t;
/** User data of Generic Level Server Model */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Level Server Model. Initialized internally. */
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
esp_ble_mesh_gen_level_state_t state; /*!< Parameters of the Generic Level state */
esp_ble_mesh_last_msg_info_t last; /*!< Parameters of the last received set message */
esp_ble_mesh_state_transition_t transition; /*!< Parameters of state transition */
int32_t tt_delta_level; /*!< Delta change value of level state transition */
} esp_ble_mesh_gen_level_srv_t;
/** Parameter of Generic Default Transition Time state */
typedef struct {
uint8_t trans_time; /*!< The value of the Generic Default Transition Time state */
} esp_ble_mesh_gen_def_trans_time_state_t;
/** User data of Generic Default Transition Time Server Model */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Default Transition Time Server Model. Initialized internally. */
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
esp_ble_mesh_gen_def_trans_time_state_t state; /*!< Parameters of the Generic Default Transition Time state */
} esp_ble_mesh_gen_def_trans_time_srv_t;
/** Parameter of Generic OnPowerUp state */
typedef struct {
uint8_t onpowerup; /*!< The value of the Generic OnPowerUp state */
} esp_ble_mesh_gen_onpowerup_state_t;
/** User data of Generic Power OnOff Server Model */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Power OnOff Server Model. Initialized internally. */
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
esp_ble_mesh_gen_onpowerup_state_t *state; /*!< Parameters of the Generic OnPowerUp state */
} esp_ble_mesh_gen_power_onoff_srv_t;
/** User data of Generic Power OnOff Setup Server Model */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Power OnOff Setup Server Model. Initialized internally. */
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
esp_ble_mesh_gen_onpowerup_state_t *state; /*!< Parameters of the Generic OnPowerUp state */
} esp_ble_mesh_gen_power_onoff_setup_srv_t;
/** Parameters of Generic Power Level state */
typedef struct {
uint16_t power_actual; /*!< The present value of the Generic Power Actual state */
uint16_t target_power_actual; /*!< The target value of the Generic Power Actual state */
uint16_t power_last; /*!< The value of the Generic Power Last state */
uint16_t power_default; /*!< The value of the Generic Power Default state */
uint8_t status_code; /*!< The status code of setting Generic Power Range state */
uint16_t power_range_min; /*!< The minimum value of the Generic Power Range state */
uint16_t power_range_max; /*!< The maximum value of the Generic Power Range state */
} esp_ble_mesh_gen_power_level_state_t;
/** User data of Generic Power Level Server Model */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Power Level Server Model. Initialized internally. */
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
esp_ble_mesh_gen_power_level_state_t *state; /*!< Parameters of the Generic Power Level state */
esp_ble_mesh_last_msg_info_t last; /*!< Parameters of the last received set message */
esp_ble_mesh_state_transition_t transition; /*!< Parameters of state transition */
int32_t tt_delta_level; /*!< Delta change value of level state transition */
} esp_ble_mesh_gen_power_level_srv_t;
/** User data of Generic Power Level Setup Server Model */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Power Level Setup Server Model. Initialized internally. */
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
esp_ble_mesh_gen_power_level_state_t *state; /*!< Parameters of the Generic Power Level state */
} esp_ble_mesh_gen_power_level_setup_srv_t;
/** Parameters of Generic Battery state */
typedef struct {
uint32_t battery_level : 8, /*!< The value of the Generic Battery Level state */
time_to_discharge : 24; /*!< The value of the Generic Battery Time to Discharge state */
uint32_t time_to_charge : 24, /*!< The value of the Generic Battery Time to Charge state */
battery_flags : 8; /*!< The value of the Generic Battery Flags state */
} esp_ble_mesh_gen_battery_state_t;
/** User data of Generic Battery Server Model */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Battery Server Model. Initialized internally. */
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
esp_ble_mesh_gen_battery_state_t state; /*!< Parameters of the Generic Battery state */
} esp_ble_mesh_gen_battery_srv_t;
/** Parameters of Generic Location state */
typedef struct {
int32_t global_latitude; /*!< The value of the Global Latitude field */
int32_t global_longitude; /*!< The value of the Global Longitude field */
int16_t global_altitude; /*!< The value of the Global Altitude field */
int16_t local_north; /*!< The value of the Local North field */
int16_t local_east; /*!< The value of the Local East field */
int16_t local_altitude; /*!< The value of the Local Altitude field */
uint8_t floor_number; /*!< The value of the Floor Number field */
uint16_t uncertainty; /*!< The value of the Uncertainty field */
} esp_ble_mesh_gen_location_state_t;
/** User data of Generic Location Server Model */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Location Server Model. Initialized internally. */
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
esp_ble_mesh_gen_location_state_t *state; /*!< Parameters of the Generic Location state */
} esp_ble_mesh_gen_location_srv_t;
/** User data of Generic Location Setup Server Model */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Location Setup Server Model. Initialized internally. */
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
esp_ble_mesh_gen_location_state_t *state; /*!< Parameters of the Generic Location state */
} esp_ble_mesh_gen_location_setup_srv_t;
/** This enum value is the access value of Generic User Property */
typedef enum {
ESP_BLE_MESH_GEN_USER_ACCESS_PROHIBIT,
ESP_BLE_MESH_GEN_USER_ACCESS_READ,
ESP_BLE_MESH_GEN_USER_ACCESS_WRITE,
ESP_BLE_MESH_GEN_USER_ACCESS_READ_WRITE,
} esp_ble_mesh_gen_user_prop_access_t;
/** This enum value is the access value of Generic Admin Property */
typedef enum {
ESP_BLE_MESH_GEN_ADMIN_NOT_USER_PROP,
ESP_BLE_MESH_GEN_ADMIN_ACCESS_READ,
ESP_BLE_MESH_GEN_ADMIN_ACCESS_WRITE,
ESP_BLE_MESH_GEN_ADMIN_ACCESS_READ_WRITE,
} esp_ble_mesh_gen_admin_prop_access_t;
/** This enum value is the access value of Generic Manufacturer Property */
typedef enum {
ESP_BLE_MESH_GEN_MANU_NOT_USER_PROP,
ESP_BLE_MESH_GEN_MANU_ACCESS_READ,
} esp_ble_mesh_gen_manu_prop_access_t;
/** Parameters of Generic Property states */
typedef struct {
uint16_t id; /*!< The value of User/Admin/Manufacturer Property ID */
uint8_t user_access; /*!< The value of User Access field */
uint8_t admin_access; /*!< The value of Admin Access field */
uint8_t manu_access; /*!< The value of Manufacturer Access field */
struct net_buf_simple *val; /*!< The value of User/Admin/Manufacturer Property */
} esp_ble_mesh_generic_property_t;
/** User data of Generic User Property Server Model */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Generic User Property Server Model. Initialized internally. */
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
uint8_t property_count; /*!< Generic User Property count */
esp_ble_mesh_generic_property_t *properties; /*!< Parameters of the Generic User Property state */
} esp_ble_mesh_gen_user_prop_srv_t;
/** User data of Generic Admin Property Server Model */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Admin Property Server Model. Initialized internally. */
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
uint8_t property_count; /*!< Generic Admin Property count */
esp_ble_mesh_generic_property_t *properties; /*!< Parameters of the Generic Admin Property state */
} esp_ble_mesh_gen_admin_prop_srv_t;
/** User data of Generic Manufacturer Property Server Model */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Manufacturer Property Server Model. Initialized internally. */
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
uint8_t property_count; /*!< Generic Manufacturer Property count */
esp_ble_mesh_generic_property_t *properties; /*!< Parameters of the Generic Manufacturer Property state */
} esp_ble_mesh_gen_manu_prop_srv_t;
/** User data of Generic Client Property Server Model */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Client Property Server Model. Initialized internally. */
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
uint8_t id_count; /*!< Generic Client Property ID count */
uint16_t *property_ids; /*!< Parameters of the Generic Client Property state */
} esp_ble_mesh_gen_client_prop_srv_t;
/** Parameter of Generic OnOff Set state change event */
typedef struct {
uint8_t onoff; /*!< The value of Generic OnOff state */
} esp_ble_mesh_state_change_gen_onoff_set_t;
/** Parameter of Generic Level Set state change event */
typedef struct {
int16_t level; /*!< The value of Generic Level state */
} esp_ble_mesh_state_change_gen_level_set_t;
/** Parameter of Generic Delta Set state change event */
typedef struct {
int16_t level; /*!< The value of Generic Level state */
} esp_ble_mesh_state_change_gen_delta_set_t;
/** Parameter of Generic Move Set state change event */
typedef struct {
int16_t level; /*!< The value of Generic Level state */
} esp_ble_mesh_state_change_gen_move_set_t;
/** Parameter of Generic Default Transition Time Set state change event */
typedef struct {
uint8_t trans_time; /*!< The value of Generic Default Transition Time state */
} esp_ble_mesh_state_change_gen_def_trans_time_set_t;
/** Parameter of Generic OnPowerUp Set state change event */
typedef struct {
uint8_t onpowerup; /*!< The value of Generic OnPowerUp state */
} esp_ble_mesh_state_change_gen_onpowerup_set_t;
/** Parameter of Generic Power Level Set state change event */
typedef struct {
uint16_t power; /*!< The value of Generic Power Actual state */
} esp_ble_mesh_state_change_gen_power_level_set_t;
/** Parameter of Generic Power Default Set state change event */
typedef struct {
uint16_t power; /*!< The value of Generic Power Default state */
} esp_ble_mesh_state_change_gen_power_default_set_t;
/** Parameters of Generic Power Range Set state change event */
typedef struct {
uint16_t range_min; /*!< The minimum value of Generic Power Range state */
uint16_t range_max; /*!< The maximum value of Generic Power Range state */
} esp_ble_mesh_state_change_gen_power_range_set_t;
/** Parameters of Generic Location Global Set state change event */
typedef struct {
int32_t latitude; /*!< The Global Latitude value of Generic Location state */
int32_t longitude; /*!< The Global Longitude value of Generic Location state */
int16_t altitude; /*!< The Global Altitude value of Generic Location state */
} esp_ble_mesh_state_change_gen_loc_global_set_t;
/** Parameters of Generic Location Local Set state change event */
typedef struct {
int16_t north; /*!< The Local North value of Generic Location state */
int16_t east; /*!< The Local East value of Generic Location state */
int16_t altitude; /*!< The Local Altitude value of Generic Location state */
uint8_t floor_number; /*!< The Floor Number value of Generic Location state */
uint16_t uncertainty; /*!< The Uncertainty value of Generic Location state */
} esp_ble_mesh_state_change_gen_loc_local_set_t;
/** Parameters of Generic User Property Set state change event */
typedef struct {
uint16_t id; /*!< The property id of Generic User Property state */
struct net_buf_simple *value; /*!< The property value of Generic User Property state */
} esp_ble_mesh_state_change_gen_user_property_set_t;
/** Parameters of Generic Admin Property Set state change event */
typedef struct {
uint16_t id; /*!< The property id of Generic Admin Property state */
uint8_t access; /*!< The property access of Generic Admin Property state */
struct net_buf_simple *value; /*!< The property value of Generic Admin Property state */
} esp_ble_mesh_state_change_gen_admin_property_set_t;
/** Parameters of Generic Manufacturer Property Set state change event */
typedef struct {
uint16_t id; /*!< The property id of Generic Manufacturer Property state */
uint8_t access; /*!< The property value of Generic Manufacturer Property state */
} esp_ble_mesh_state_change_gen_manu_property_set_t;
/**
* @brief Generic Server Model state change value union
*/
typedef union {
/**
* The recv_op in ctx can be used to decide which state is changed.
*/
esp_ble_mesh_state_change_gen_onoff_set_t onoff_set; /*!< Generic OnOff Set */
esp_ble_mesh_state_change_gen_level_set_t level_set; /*!< Generic Level Set */
esp_ble_mesh_state_change_gen_delta_set_t delta_set; /*!< Generic Delta Set */
esp_ble_mesh_state_change_gen_move_set_t move_set; /*!< Generic Move Set */
esp_ble_mesh_state_change_gen_def_trans_time_set_t def_trans_time_set; /*!< Generic Default Transition Time Set */
esp_ble_mesh_state_change_gen_onpowerup_set_t onpowerup_set; /*!< Generic OnPowerUp Set */
esp_ble_mesh_state_change_gen_power_level_set_t power_level_set; /*!< Generic Power Level Set */
esp_ble_mesh_state_change_gen_power_default_set_t power_default_set; /*!< Generic Power Default Set */
esp_ble_mesh_state_change_gen_power_range_set_t power_range_set; /*!< Generic Power Range Set */
esp_ble_mesh_state_change_gen_loc_global_set_t loc_global_set; /*!< Generic Location Global Set */
esp_ble_mesh_state_change_gen_loc_local_set_t loc_local_set; /*!< Generic Location Local Set */
esp_ble_mesh_state_change_gen_user_property_set_t user_property_set; /*!< Generic User Property Set */
esp_ble_mesh_state_change_gen_admin_property_set_t admin_property_set; /*!< Generic Admin Property Set */
esp_ble_mesh_state_change_gen_manu_property_set_t manu_property_set; /*!< Generic Manufacturer Property Set */
} esp_ble_mesh_generic_server_state_change_t;
/** Context of the received Generic User Property Get message */
typedef struct {
uint16_t property_id; /*!< Property ID identifying a Generic User Property */
} esp_ble_mesh_server_recv_gen_user_property_get_t;
/** Context of the received Generic Admin Property Get message */
typedef struct {
uint16_t property_id; /*!< Property ID identifying a Generic Admin Property */
} esp_ble_mesh_server_recv_gen_admin_property_get_t;
/** Context of the received Generic Manufacturer Property message */
typedef struct {
uint16_t property_id; /*!< Property ID identifying a Generic Manufacturer Property */
} esp_ble_mesh_server_recv_gen_manufacturer_property_get_t;
/** Context of the received Generic Client Properties Get message */
typedef struct {
uint16_t property_id; /*!< A starting Client Property ID present within an element */
} esp_ble_mesh_server_recv_gen_client_properties_get_t;
/**
* @brief Generic Server Model received get message union
*/
typedef union {
esp_ble_mesh_server_recv_gen_user_property_get_t user_property; /*!< Generic User Property Get */
esp_ble_mesh_server_recv_gen_admin_property_get_t admin_property; /*!< Generic Admin Property Get */
esp_ble_mesh_server_recv_gen_manufacturer_property_get_t manu_property; /*!< Generic Manufacturer Property Get */
esp_ble_mesh_server_recv_gen_client_properties_get_t client_properties; /*!< Generic Client Properties Get */
} esp_ble_mesh_generic_server_recv_get_msg_t;
/** Context of the received Generic OnOff Set message */
typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */
uint8_t onoff; /*!< Target value of Generic OnOff state */
uint8_t tid; /*!< Transaction ID */
uint8_t trans_time; /*!< Time to complete state transition (optional) */
uint8_t delay; /*!< Indicate message execution delay (C.1) */
} esp_ble_mesh_server_recv_gen_onoff_set_t;
/** Context of the received Generic Level Set message */
typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */
int16_t level; /*!< Target value of Generic Level state */
uint8_t tid; /*!< Transaction ID */
uint8_t trans_time; /*!< Time to complete state transition (optional) */
uint8_t delay; /*!< Indicate message execution delay (C.1) */
} esp_ble_mesh_server_recv_gen_level_set_t;
/** Context of the received Generic Delta Set message */
typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */
int32_t delta_level; /*!< Delta change of Generic Level state */
uint8_t tid; /*!< Transaction ID */
uint8_t trans_time; /*!< Time to complete state transition (optional) */
uint8_t delay; /*!< Indicate message execution delay (C.1) */
} esp_ble_mesh_server_recv_gen_delta_set_t;
/** Context of the received Generic Move Set message */
typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */
int16_t delta_level; /*!< Delta Level step to calculate Move speed for Generic Level state */
uint8_t tid; /*!< Transaction ID */
uint8_t trans_time; /*!< Time to complete state transition (optional) */
uint8_t delay; /*!< Indicate message execution delay (C.1) */
} esp_ble_mesh_server_recv_gen_move_set_t;
/** Context of the received Generic Default Transition Time Set message */
typedef struct {
uint8_t trans_time; /*!< The value of the Generic Default Transition Time state */
} esp_ble_mesh_server_recv_gen_def_trans_time_set_t;
/** Context of the received Generic OnPowerUp Set message */
typedef struct {
uint8_t onpowerup; /*!< The value of the Generic OnPowerUp state */
} esp_ble_mesh_server_recv_gen_onpowerup_set_t;
/** Context of the received Generic Power Level Set message */
typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */
uint16_t power; /*!< Target value of Generic Power Actual state */
uint8_t tid; /*!< Transaction ID */
uint8_t trans_time; /*!< Time to complete state transition (optional) */
uint8_t delay; /*!< Indicate message execution delay (C.1) */
} esp_ble_mesh_server_recv_gen_power_level_set_t;
/** Context of the received Generic Power Default Set message */
typedef struct {
uint16_t power; /*!< The value of the Generic Power Default state */
} esp_ble_mesh_server_recv_gen_power_default_set_t;
/** Context of the received Generic Power Range Set message */
typedef struct {
uint16_t range_min; /*!< Value of Range Min field of Generic Power Range state */
uint16_t range_max; /*!< Value of Range Max field of Generic Power Range state */
} esp_ble_mesh_server_recv_gen_power_range_set_t;
/** Context of the received Generic Location Global Set message */
typedef struct {
int32_t global_latitude; /*!< Global Coordinates (Latitude) */
int32_t global_longitude; /*!< Global Coordinates (Longitude) */
int16_t global_altitude; /*!< Global Altitude */
} esp_ble_mesh_server_recv_gen_loc_global_set_t;
/** Context of the received Generic Location Local Set message */
typedef struct {
int16_t local_north; /*!< Local Coordinates (North) */
int16_t local_east; /*!< Local Coordinates (East) */
int16_t local_altitude; /*!< Local Altitude */
uint8_t floor_number; /*!< Floor Number */
uint16_t uncertainty; /*!< Uncertainty */
} esp_ble_mesh_server_recv_gen_loc_local_set_t;
/** Context of the received Generic User Property Set message */
typedef struct {
uint16_t property_id; /*!< Property ID identifying a Generic User Property */
struct net_buf_simple *property_value; /*!< Raw value for the User Property */
} esp_ble_mesh_server_recv_gen_user_property_set_t;
/** Context of the received Generic Admin Property Set message */
typedef struct {
uint16_t property_id; /*!< Property ID identifying a Generic Admin Property */
uint8_t user_access; /*!< Enumeration indicating user access */
struct net_buf_simple *property_value; /*!< Raw value for the Admin Property */
} esp_ble_mesh_server_recv_gen_admin_property_set_t;
/** Context of the received Generic Manufacturer Property Set message */
typedef struct {
uint16_t property_id; /*!< Property ID identifying a Generic Manufacturer Property */
uint8_t user_access; /*!< Enumeration indicating user access */
} esp_ble_mesh_server_recv_gen_manufacturer_property_set_t;
/**
* @brief Generic Server Model received set message union
*/
typedef union {
esp_ble_mesh_server_recv_gen_onoff_set_t onoff; /*!< Generic OnOff Set/Generic OnOff Set Unack */
esp_ble_mesh_server_recv_gen_level_set_t level; /*!< Generic Level Set/Generic Level Set Unack */
esp_ble_mesh_server_recv_gen_delta_set_t delta; /*!< Generic Delta Set/Generic Delta Set Unack */
esp_ble_mesh_server_recv_gen_move_set_t move; /*!< Generic Move Set/Generic Move Set Unack */
esp_ble_mesh_server_recv_gen_def_trans_time_set_t def_trans_time; /*!< Generic Default Transition Time Set/Generic Default Transition Time Set Unack */
esp_ble_mesh_server_recv_gen_onpowerup_set_t onpowerup; /*!< Generic OnPowerUp Set/Generic OnPowerUp Set Unack */
esp_ble_mesh_server_recv_gen_power_level_set_t power_level; /*!< Generic Power Level Set/Generic Power Level Set Unack */
esp_ble_mesh_server_recv_gen_power_default_set_t power_default; /*!< Generic Power Default Set/Generic Power Default Set Unack */
esp_ble_mesh_server_recv_gen_power_range_set_t power_range; /*!< Generic Power Range Set/Generic Power Range Set Unack */
esp_ble_mesh_server_recv_gen_loc_global_set_t location_global; /*!< Generic Location Global Set/Generic Location Global Set Unack */
esp_ble_mesh_server_recv_gen_loc_local_set_t location_local; /*!< Generic Location Local Set/Generic Location Local Set Unack */
esp_ble_mesh_server_recv_gen_user_property_set_t user_property; /*!< Generic User Property Set/Generic User Property Set Unack */
esp_ble_mesh_server_recv_gen_admin_property_set_t admin_property; /*!< Generic Admin Property Set/Generic Admin Property Set Unack */
esp_ble_mesh_server_recv_gen_manufacturer_property_set_t manu_property; /*!< Generic Manufacturer Property Set/Generic Manufacturer Property Set Unack */
} esp_ble_mesh_generic_server_recv_set_msg_t;
/**
* @brief Generic Server Model callback value union
*/
typedef union {
esp_ble_mesh_generic_server_state_change_t state_change; /*!< ESP_BLE_MESH_GENERIC_SERVER_STATE_CHANGE_EVT */
esp_ble_mesh_generic_server_recv_get_msg_t get; /*!< ESP_BLE_MESH_GENERIC_SERVER_RECV_GET_MSG_EVT */
esp_ble_mesh_generic_server_recv_set_msg_t set; /*!< ESP_BLE_MESH_GENERIC_SERVER_RECV_SET_MSG_EVT */
} esp_ble_mesh_generic_server_cb_value_t;
/** Generic Server Model callback parameters */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to Generic Server Models */
esp_ble_mesh_msg_ctx_t ctx; /*!< Context of the received messages */
esp_ble_mesh_generic_server_cb_value_t value; /*!< Value of the received Generic Messages */
} esp_ble_mesh_generic_server_cb_param_t;
/** This enum value is the event of Generic Server Model */
typedef enum {
/**
* 1. When get_auto_rsp is set to ESP_BLE_MESH_SERVER_AUTO_RSP, no event will be
* callback to the application layer when Generic Get messages are received.
* 2. When set_auto_rsp is set to ESP_BLE_MESH_SERVER_AUTO_RSP, this event will
* be callback to the application layer when Generic Set/Set Unack messages
* are received.
*/
ESP_BLE_MESH_GENERIC_SERVER_STATE_CHANGE_EVT,
/**
* When get_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, this event will be
* callback to the application layer when Generic Get messages are received.
*/
ESP_BLE_MESH_GENERIC_SERVER_RECV_GET_MSG_EVT,
/**
* When set_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, this event will be
* callback to the application layer when Generic Set/Set Unack messages are received.
*/
ESP_BLE_MESH_GENERIC_SERVER_RECV_SET_MSG_EVT,
ESP_BLE_MESH_GENERIC_SERVER_EVT_MAX,
} esp_ble_mesh_generic_server_cb_event_t;
/**
* @brief Bluetooth Mesh Generic Server Model function.
*/
/**
* @brief Generic Server Model callback function type
* @param event: Event type
* @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);
/**
* @brief Register BLE Mesh Generic Server Model callback.
*
* @param[in] callback: Pointer to the callback function.
*
* @return ESP_OK on success or error code otherwise.
*
*/
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.
@ -47,39 +51,123 @@
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_HEALTH_CLI, \
NULL, NULL, cli_data)
/** Health Server Model callbacks */
/** @def ESP_BLE_MESH_HEALTH_PUB_DEFINE
*
* A helper to define a health publication context
*
* @param _name Name given to the publication context variable.
* @param _max Maximum number of faults the element can have.
* @param _role Role of the device which contains the model.
*/
#define ESP_BLE_MESH_HEALTH_PUB_DEFINE(_name, _max, _role) \
ESP_BLE_MESH_MODEL_PUB_DEFINE(_name, (1 + 3 + (_max)), _role)
/**
* SIG identifier of Health Fault Test.
* 0x01 ~ 0xFF: Vendor Specific Test.
*/
#define ESP_BLE_MESH_HEALTH_STANDARD_TEST 0x00
/**
* Fault values of Health Fault Test.
* 0x33 ~ 0x7F: Reserved for Future Use.
* 0x80 ~ 0xFF: Vendor Specific Warning/Error.
*/
#define ESP_BLE_MESH_NO_FAULT 0x00
#define ESP_BLE_MESH_BATTERY_LOW_WARNING 0x01
#define ESP_BLE_MESH_BATTERY_LOW_ERROR 0x02
#define ESP_BLE_MESH_SUPPLY_VOLTAGE_TOO_LOW_WARNING 0x03
#define ESP_BLE_MESH_SUPPLY_VOLTAGE_TOO_LOW_ERROR 0x04
#define ESP_BLE_MESH_SUPPLY_VOLTAGE_TOO_HIGH_WARNING 0x05
#define ESP_BLE_MESH_SUPPLY_VOLTAGE_TOO_HIGH_ERROR 0x06
#define ESP_BLE_MESH_POWER_SUPPLY_INTERRUPTED_WARNING 0x07
#define ESP_BLE_MESH_POWER_SUPPLY_INTERRUPTED_ERROR 0x08
#define ESP_BLE_MESH_NO_LOAD_WARNING 0x09
#define ESP_BLE_MESH_NO_LOAD_ERROR 0x0A
#define ESP_BLE_MESH_OVERLOAD_WARNING 0x0B
#define ESP_BLE_MESH_OVERLOAD_ERROR 0x0C
#define ESP_BLE_MESH_OVERHEAT_WARNING 0x0D
#define ESP_BLE_MESH_OVERHEAT_ERROR 0x0E
#define ESP_BLE_MESH_CONDENSATION_WARNING 0x0F
#define ESP_BLE_MESH_CONDENSATION_ERROR 0x10
#define ESP_BLE_MESH_VIBRATION_WARNING 0x11
#define ESP_BLE_MESH_VIBRATION_ERROR 0x12
#define ESP_BLE_MESH_CONFIGURATION_WARNING 0x13
#define ESP_BLE_MESH_CONFIGURATION_ERROR 0x14
#define ESP_BLE_MESH_ELEMENT_NOT_CALIBRATED_WARNING 0x15
#define ESP_BLE_MESH_ELEMENT_NOT_CALIBRATED_ERROR 0x16
#define ESP_BLE_MESH_MEMORY_WARNING 0x17
#define ESP_BLE_MESH_MEMORY_ERROR 0x18
#define ESP_BLE_MESH_SELF_TEST_WARNING 0x19
#define ESP_BLE_MESH_SELF_TEST_ERROR 0x1A
#define ESP_BLE_MESH_INPUT_TOO_LOW_WARNING 0x1B
#define ESP_BLE_MESH_INPUT_TOO_LOW_ERROR 0x1C
#define ESP_BLE_MESH_INPUT_TOO_HIGH_WARNING 0x1D
#define ESP_BLE_MESH_INPUT_TOO_HIGH_ERROR 0x1E
#define ESP_BLE_MESH_INPUT_NO_CHANGE_WARNING 0x1F
#define ESP_BLE_MESH_INPUT_NO_CHANGE_ERROR 0x20
#define ESP_BLE_MESH_ACTUATOR_BLOCKED_WARNING 0x21
#define ESP_BLE_MESH_ACTUATOR_BLOCKED_ERROR 0x22
#define ESP_BLE_MESH_HOUSING_OPENED_WARNING 0x23
#define ESP_BLE_MESH_HOUSING_OPENED_ERROR 0x24
#define ESP_BLE_MESH_TAMPER_WARNING 0x25
#define ESP_BLE_MESH_TAMPER_ERROR 0x26
#define ESP_BLE_MESH_DEVICE_MOVED_WARNING 0x27
#define ESP_BLE_MESH_DEVICE_MOVED_ERROR 0x28
#define ESP_BLE_MESH_DEVICE_DROPPED_WARNING 0x29
#define ESP_BLE_MESH_DEVICE_DROPPED_ERROR 0x2A
#define ESP_BLE_MESH_OVERFLOW_WARNING 0x2B
#define ESP_BLE_MESH_OVERFLOW_ERROR 0x2C
#define ESP_BLE_MESH_EMPTY_WARNING 0x2D
#define ESP_BLE_MESH_EMPTY_ERROR 0x2E
#define ESP_BLE_MESH_INTERNAL_BUS_WARNING 0x2F
#define ESP_BLE_MESH_INTERNAL_BUS_ERROR 0x30
#define ESP_BLE_MESH_MECHANISM_JAMMED_WARNING 0x31
#define ESP_BLE_MESH_MECHANISM_JAMMED_ERROR 0x32
/** ESP BLE Mesh Health Server callback */
typedef struct {
/** Fetch current faults */
int (*fault_get_cur)(esp_ble_mesh_model_t *model, uint8_t *test_id,
uint16_t *company_id, uint8_t *faults, uint8_t *fault_count);
/** Clear health registered faults. Initialized by the stack. */
esp_ble_mesh_cb_t fault_clear;
/** Fetch registered faults */
int (*fault_get_reg)(esp_ble_mesh_model_t *model, uint16_t company_id,
uint8_t *test_id, uint8_t *faults, uint8_t *fault_count);
/** Run a specific health test. Initialized by the stack. */
esp_ble_mesh_cb_t fault_test;
/** Clear registered faults */
int (*fault_clear)(esp_ble_mesh_model_t *model, uint16_t company_id);
/** Health attention on callback. Initialized by the stack. */
esp_ble_mesh_cb_t attention_on;
/** Run a specific test */
int (*fault_test)(esp_ble_mesh_model_t *model, uint8_t test_id, uint16_t company_id);
/** Attention on */
void (*attn_on)(esp_ble_mesh_model_t *model);
/** Attention off */
void (*attn_off)(esp_ble_mesh_model_t *model);
/** Health attention off callback. Initialized by the stack. */
esp_ble_mesh_cb_t attention_off;
} esp_ble_mesh_health_srv_cb_t;
/** Health Server Model Context */
#define ESP_BLE_MESH_HEALTH_FAULT_ARRAY_SIZE 32
/** ESP BLE Mesh Health Server test Context */
typedef struct {
uint8_t id_count; /*!< Number of Health self-test ID */
const uint8_t *test_ids; /*!< Array of Health self-test IDs */
uint16_t company_id; /*!< Company ID used to identify the Health Fault state */
uint8_t prev_test_id; /*!< Current test ID of the health fault test */
uint8_t current_faults[ESP_BLE_MESH_HEALTH_FAULT_ARRAY_SIZE]; /*!< Array of current faults */
uint8_t registered_faults[ESP_BLE_MESH_HEALTH_FAULT_ARRAY_SIZE]; /*!< Array of registered faults */
} __attribute__((packed)) esp_ble_mesh_health_test_t;
/** ESP BLE Mesh Health Server Model Context */
typedef struct {
/** Pointer to Health Server Model */
esp_ble_mesh_model_t *model;
/** Optional callback struct */
const esp_ble_mesh_health_srv_cb_t *cb;
/** Health callback struct */
esp_ble_mesh_health_srv_cb_t health_cb;
/** Attention Timer state */
struct k_delayed_work attn_timer;
struct k_delayed_work attention_timer;
/** Attention Timer start flag */
bool attention_timer_start;
/** Health Server fault test */
esp_ble_mesh_health_test_t health_test;
} esp_ble_mesh_health_srv_t;
/** Parameter of Health Fault Get */
@ -186,14 +274,54 @@ typedef enum {
ESP_BLE_MESH_HEALTH_CLIENT_EVT_MAX,
} esp_ble_mesh_health_client_cb_event_t;
/** Health Server Model callback parameter */
/** Parameter of publishing Health Current Status completion event */
typedef struct {
int error_code; /*!< Appropriate error code */
int error_code; /*!< The result of publishing Health Current Status */
esp_ble_mesh_elem_t *element; /*!< Pointer to the element which contains the Health Server Model */
} esp_ble_mesh_health_fault_update_comp_cb_t;
/** Parameters of Health Fault Clear event */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Health Server Model */
uint16_t company_id; /*!< Bluetooth assigned 16-bit Company ID */
} esp_ble_mesh_health_fault_clear_cb_t;
/** Parameters of Health Fault Test event */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Health Server Model */
uint8_t test_id; /*!< ID of a specific test to be performed */
uint16_t company_id; /*!< Bluetooth assigned 16-bit Company ID */
} esp_ble_mesh_health_fault_test_cb_t;
/** Parameter of Health Attention On event */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Health Server Model */
uint8_t time; /*!< Duration of attention timer on (in seconds) */
} esp_ble_mesh_health_attention_on_cb_t;
/** Parameter of Health Attention Off event */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Health Server Model */
} esp_ble_mesh_health_attention_off_cb_t;
/**
* @brief Health Server Model callback parameters union
*/
typedef union {
esp_ble_mesh_health_fault_update_comp_cb_t fault_update_comp; /*!< ESP_BLE_MESH_HEALTH_SERVER_FAULT_UPDATE_COMP_EVT */
esp_ble_mesh_health_fault_clear_cb_t fault_clear; /*!< ESP_BLE_MESH_HEALTH_SERVER_FAULT_CLEAR_EVT */
esp_ble_mesh_health_fault_test_cb_t fault_test; /*!< ESP_BLE_MESH_HEALTH_SERVER_FAULT_TEST_EVT */
esp_ble_mesh_health_attention_on_cb_t attention_on; /*!< ESP_BLE_MESH_HEALTH_SERVER_ATTENTION_ON_EVT */
esp_ble_mesh_health_attention_off_cb_t attention_off; /*!< ESP_BLE_MESH_HEALTH_SERVER_ATTENTION_OFF_EVT */
} esp_ble_mesh_health_server_cb_param_t;
/** This enum value is the event of Health Server Model */
typedef enum {
ESP_BLE_MESH_HEALTH_SERVER_FAULT_UPDATE_COMPLETE_EVT,
ESP_BLE_MESH_HEALTH_SERVER_FAULT_UPDATE_COMP_EVT,
ESP_BLE_MESH_HEALTH_SERVER_FAULT_CLEAR_EVT,
ESP_BLE_MESH_HEALTH_SERVER_FAULT_TEST_EVT,
ESP_BLE_MESH_HEALTH_SERVER_ATTENTION_ON_EVT,
ESP_BLE_MESH_HEALTH_SERVER_ATTENTION_OFF_EVT,
ESP_BLE_MESH_HEALTH_SERVER_EVT_MAX,
} esp_ble_mesh_health_server_cb_event_t;
@ -207,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
@ -215,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.
@ -251,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.
@ -267,10 +395,10 @@ 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 start to publish its Current Health Fault.
* @brief This function is called by the Health Server Model to update the context of its Health Current status.
*
* @param[in] element: The element to which the Health Server Model belongs.
*
@ -279,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

@ -19,9 +19,12 @@
#ifndef _ESP_BLE_MESH_SENSOR_MODEL_API_H_
#define _ESP_BLE_MESH_SENSOR_MODEL_API_H_
#include "sensor_client.h"
#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.
@ -45,60 +48,60 @@
/** Parameters of Sensor Descriptor Get */
typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */
u16_t property_id; /*!< Property ID of a sensor (optional) */
uint16_t property_id; /*!< Property ID of a sensor (optional) */
} esp_ble_mesh_sensor_descriptor_get_t;
/** Parameter of Sensor Cadence Get */
typedef struct {
u16_t property_id; /*!< Property ID of a sensor */
uint16_t property_id; /*!< Property ID of a sensor */
} esp_ble_mesh_sensor_cadence_get_t;
/** Parameters of Sensor Cadence Set */
typedef struct {
u16_t property_id; /*!< Property ID for the sensor */
u8_t fast_cadence_period_divisor : 7, /*!< Divisor for the publish period */
status_trigger_type : 1; /*!< The unit and format of the Status Trigger Delta fields */
uint16_t property_id; /*!< Property ID for the sensor */
uint8_t fast_cadence_period_divisor : 7, /*!< Divisor for the publish period */
status_trigger_type : 1; /*!< The unit and format of the Status Trigger Delta fields */
struct net_buf_simple *status_trigger_delta_down; /*!< Delta down value that triggers a status message */
struct net_buf_simple *status_trigger_delta_up; /*!< Delta up value that triggers a status message */
u8_t status_min_interval; /*!< Minimum interval between two consecutive Status messages */
uint8_t status_min_interval; /*!< Minimum interval between two consecutive Status messages */
struct net_buf_simple *fast_cadence_low; /*!< Low value for the fast cadence range */
struct net_buf_simple *fast_cadence_high; /*!< Fast value for the fast cadence range */
} esp_ble_mesh_sensor_cadence_set_t;
/** Parameter of Sensor Settings Get */
typedef struct {
u16_t sensor_property_id; /*!< Property ID of a sensor */
uint16_t sensor_property_id; /*!< Property ID of a sensor */
} esp_ble_mesh_sensor_settings_get_t;
/** Parameters of Sensor Setting Get */
typedef struct {
u16_t sensor_property_id; /*!< Property ID of a sensor */
u16_t sensor_setting_property_id; /*!< Setting ID identifying a setting within a sensor */
uint16_t sensor_property_id; /*!< Property ID of a sensor */
uint16_t sensor_setting_property_id; /*!< Setting ID identifying a setting within a sensor */
} esp_ble_mesh_sensor_setting_get_t;
/** Parameters of Sensor Setting Set */
typedef struct {
u16_t sensor_property_id; /*!< Property ID identifying a sensor */
u16_t sensor_setting_property_id; /*!< Setting ID identifying a setting within a sensor */
uint16_t sensor_property_id; /*!< Property ID identifying a sensor */
uint16_t sensor_setting_property_id; /*!< Setting ID identifying a setting within a sensor */
struct net_buf_simple *sensor_setting_raw; /*!< Raw value for the setting */
} esp_ble_mesh_sensor_setting_set_t;
/** Parameters of Sensor Get */
typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */
u16_t property_id; /*!< Property ID for the sensor (optional) */
bool op_en; /*!< Indicate if optional parameters are included */
uint16_t property_id; /*!< Property ID for the sensor (optional) */
} esp_ble_mesh_sensor_get_t;
/** Parameters of Sensor Column Get */
typedef struct {
u16_t property_id; /*!< Property identifying a sensor */
uint16_t property_id; /*!< Property identifying a sensor */
struct net_buf_simple *raw_value_x; /*!< Raw value identifying a column */
} esp_ble_mesh_sensor_column_get_t;
/** Parameters of Sensor Series Get */
typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */
u16_t property_id; /*!< Property identifying a sensor */
bool op_en; /*!< Indicate if optional parameters are included */
uint16_t property_id; /*!< Property identifying a sensor */
struct net_buf_simple *raw_value_x1; /*!< Raw value identifying a starting column (optional) */
struct net_buf_simple *raw_value_x2; /*!< Raw value identifying an ending column (C.1) */
} esp_ble_mesh_sensor_series_get_t;
@ -135,22 +138,22 @@ typedef struct {
/** Parameters of Sensor Cadence Status */
typedef struct {
u16_t property_id; /*!< Property for the sensor */
uint16_t property_id; /*!< Property for the sensor */
struct net_buf_simple *sensor_cadence_value; /*!< Value of sensor cadence state */
} esp_ble_mesh_sensor_cadence_status_cb_t;
/** Parameters of Sensor Settings Status */
typedef struct {
u16_t sensor_property_id; /*!< Property ID identifying a sensor */
uint16_t sensor_property_id; /*!< Property ID identifying a sensor */
struct net_buf_simple *sensor_setting_property_ids; /*!< A sequence of N sensor setting property IDs (optional) */
} esp_ble_mesh_sensor_settings_status_cb_t;
/** Parameters of Sensor Setting Status */
typedef struct {
bool op_en; /*!< Indicate id optional parameters are included */
u16_t sensor_property_id; /*!< Property ID identifying a sensor */
u16_t sensor_setting_property_id; /*!< Setting ID identifying a setting within a sensor */
u8_t sensor_setting_access; /*!< Read/Write access rights for the setting (optional) */
bool op_en; /*!< Indicate id optional parameters are included */
uint16_t sensor_property_id; /*!< Property ID identifying a sensor */
uint16_t sensor_setting_property_id; /*!< Setting ID identifying a setting within a sensor */
uint8_t sensor_setting_access; /*!< Read/Write access rights for the setting (optional) */
struct net_buf_simple *sensor_setting_raw; /*!< Raw value for the setting */
} esp_ble_mesh_sensor_setting_status_cb_t;
@ -161,13 +164,13 @@ typedef struct {
/** Parameters of Sensor Column Status */
typedef struct {
u16_t property_id; /*!< Property identifying a sensor and the Y axis */
uint16_t property_id; /*!< Property identifying a sensor and the Y axis */
struct net_buf_simple *sensor_column_value; /*!< Left values of sensor column status */
} esp_ble_mesh_sensor_column_status_cb_t;
/** Parameters of Sensor Series Status */
typedef struct {
u16_t property_id; /*!< Property identifying a sensor and the Y axis */
uint16_t property_id; /*!< Property identifying a sensor and the Y axis */
struct net_buf_simple *sensor_series_value; /*!< Left values of sensor series status */
} esp_ble_mesh_sensor_series_status_cb_t;
@ -212,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.
@ -238,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.
@ -254,7 +257,462 @@ 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.
*/
/** @def ESP_BLE_MESH_MODEL_SENSOR_SRV
*
* @brief Define a new Sensor Server Model.
*
* @note 1. The Sensor Server model is a root model. When this model is present
* on an element, the corresponding Sensor Setup Server model shall
* also be present.
* 2. This model shall support model publication and model subscription.
*
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
* @param srv_data Pointer to the unique struct esp_ble_mesh_sensor_srv_t.
*
* @return New Sensor Server Model instance.
*/
#define ESP_BLE_MESH_MODEL_SENSOR_SRV(srv_pub, srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SENSOR_SRV, \
NULL, srv_pub, srv_data)
/** @def ESP_BLE_MESH_MODEL_SENSOR_SETUP_SRV
*
* @brief Define a new Sensor Setup Server Model.
*
* @note 1. The Sensor Setup Server model extends the Sensor Server model.
* 2. This model shall support model publication and model subscription.
*
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
* @param srv_data Pointer to the unique struct esp_ble_mesh_sensor_setup_srv_t.
*
* @return New Sensor Setup Server Model instance.
*/
#define ESP_BLE_MESH_MODEL_SENSOR_SETUP_SRV(srv_pub, srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SENSOR_SETUP_SRV, \
NULL, srv_pub, srv_data)
#define ESP_BLE_MESH_INVALID_SENSOR_PROPERTY_ID 0x0000 /*!< Invalid Sensor Property ID */
#define ESP_BLE_MESH_SENSOR_PROPERTY_ID_LEN 0x02 /*!< Length of Sensor Property ID */
#define ESP_BLE_MESH_SENSOR_DESCRIPTOR_LEN 0x08 /*!< Length of Sensor Descriptor state */
#define ESP_BLE_MESH_SENSOR_UNSPECIFIED_POS_TOLERANCE 0x000 /*!< Unspecified Sensor Positive Tolerance */
#define ESP_BLE_MESH_SENSOR_UNSPECIFIED_NEG_TOLERANCE 0x000 /*!< Unspecified Sensor Negative Tolerance */
#define ESP_BLE_MESH_SENSOR_NOT_APPL_MEASURE_PERIOD 0x00 /*!< Not applicable Sensor Measurement Period */
#define ESP_BLE_MESH_SENSOR_NOT_APPL_UPDATE_INTERVAL 0x00 /*!< Not applicable Sensor Update Interval */
#define ESP_BLE_MESH_INVALID_SENSOR_SETTING_PROPERTY_ID 0x0000 /*!< Invalid Sensor Setting Property ID */
#define ESP_BLE_MESH_SENSOR_SETTING_PROPERTY_ID_LEN 0x02 /*!< Length of Sensor Setting Property ID */
#define ESP_BLE_MESH_SENSOR_SETTING_ACCESS_LEN 0x01 /*!< Length of Sensor Setting Access */
#define ESP_BLE_MESH_SENSOR_SETTING_ACCESS_READ 0x01 /*!< Sensor Setting Access - Read */
#define ESP_BLE_MESH_SENSOR_SETTING_ACCESS_READ_WRITE 0x03 /*!< Sensor Setting Access - Read & Write */
#define ESP_BLE_MESH_SENSOR_DIVISOR_TRIGGER_TYPE_LEN 0x01 /*!< Length of Sensor Divisor Trigger Type */
#define ESP_BLE_MESH_SENSOR_STATUS_MIN_INTERVAL_LEN 0x01 /*!< Length of Sensor Status Min Interval */
#define ESP_BLE_MESH_SENSOR_PERIOD_DIVISOR_MAX_VALUE 15 /*!< Maximum value of Sensor Period Divisor */
#define ESP_BLE_MESH_SENSOR_STATUS_MIN_INTERVAL_MAX 26 /*!< Maximum value of Sensor Status Min Interval */
/**
* Sensor Status Trigger Type - Format Type of the characteristic
* that the Sensor Property ID state references
*/
#define ESP_BLE_MESH_SENSOR_STATUS_TRIGGER_TYPE_CHAR 0
/** Sensor Status Trigger Type - Format Type "uint16" */
#define ESP_BLE_MESH_SENSOR_STATUS_TRIGGER_TYPE_UINT16 1
#define ESP_BLE_MESH_SENSOR_DATA_FORMAT_A 0x00 /*!< Sensor Data Format A */
#define ESP_BLE_MESH_SENSOR_DATA_FORMAT_B 0x01 /*!< Sensor Data Format B */
#define ESP_BLE_MESH_SENSOR_DATA_FORMAT_A_MPID_LEN 0x02 /*!< MPID length of Sensor Data Format A */
#define ESP_BLE_MESH_SENSOR_DATA_FORMAT_B_MPID_LEN 0x03 /*!< MPID length of Sensor Data Format B */
/**
* Zero length of Sensor Data.
*
* Note:
* The Length field is a 1-based uint7 value (valid range 0x00x7F,
* representing range of 1127). The value 0x7F represents a length
* of zero.
*/
#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,
ESP_BLE_MESH_SAMPLE_FUNC_INSTANTANEOUS,
ESP_BLE_MESH_SAMPLE_FUNC_ARITHMETIC_MEAN,
ESP_BLE_MESH_SAMPLE_FUNC_RMS,
ESP_BLE_MESH_SAMPLE_FUNC_MAXIMUM,
ESP_BLE_MESH_SAMPLE_FUNC_MINIMUM,
ESP_BLE_MESH_SAMPLE_FUNC_ACCUMULATED,
ESP_BLE_MESH_SAMPLE_FUNC_COUNT,
};
/** Parameters of Sensor Descriptor state */
typedef struct {
uint32_t positive_tolerance : 12, /*!< The value of Sensor Positive Tolerance field */
negative_tolerance : 12, /*!< The value of Sensor Negative Tolerance field */
sampling_function : 8; /*!< The value of Sensor Sampling Function field */
uint8_t measure_period; /*!< The value of Sensor Measurement Period field */
uint8_t update_interval; /*!< The value of Sensor Update Interval field */
} esp_ble_mesh_sensor_descriptor_t;
/** Parameters of Sensor Setting state */
typedef struct {
uint16_t property_id; /*!< The value of Sensor Setting Property ID field */
uint8_t access; /*!< The value of Sensor Setting Access field */
struct net_buf_simple *raw; /*!< The value of Sensor Setting Raw field */
} esp_ble_mesh_sensor_setting_t;
/** Parameters of Sensor Cadence state */
typedef struct {
uint8_t period_divisor : 7, /*!< The value of Fast Cadence Period Divisor field */
trigger_type : 1; /*!< The value of Status Trigger Type field */
/**
* Note:
* The parameter "size" in trigger_delta_down, trigger_delta_up, fast_cadence_low &
* fast_cadence_high indicates the exact length of these four parameters, and they
* are associated with the Sensor Property ID. Users need to initialize the "size"
* precisely.
*/
struct net_buf_simple *trigger_delta_down; /*!< The value of Status Trigger Delta Down field */
struct net_buf_simple *trigger_delta_up; /*!< The value of Status Trigger Delta Up field */
uint8_t min_interval; /*!< The value of Status Min Interval field */
struct net_buf_simple *fast_cadence_low; /*!< The value of Fast Cadence Low field */
struct net_buf_simple *fast_cadence_high; /*!< The value of Fast Cadence High field */
} esp_ble_mesh_sensor_cadence_t;
/** Parameters of Sensor Data state */
typedef struct {
/**
* Format A: The Length field is a 1-based uint4 value (valid range 0x00xF,
* representing range of 1 16).
* Format B: The Length field is a 1-based uint7 value (valid range 0x00x7F,
* representing range of 1 127). The value 0x7F represents a
* length of zero.
*/
uint8_t format : 1, /*!< The value of the Sensor Data format */
length : 7; /*!< The value of the Sensor Data length */
struct net_buf_simple *raw_value; /*!< The value of Sensor Data raw value */
} esp_ble_mesh_sensor_data_t;
/** Parameters of Sensor Series Column state */
typedef struct {
struct net_buf_simple *raw_value_x; /*!< The value of Sensor Raw Value X field */
struct net_buf_simple *column_width; /*!< The value of Sensor Column Width field */
struct net_buf_simple *raw_value_y; /*!< The value of Sensor Raw Value Y field */
} esp_ble_mesh_sensor_series_column_t;
/** Parameters of Sensor states */
typedef struct {
uint16_t sensor_property_id; /*!< The value of Sensor Property ID field */
/* Constant throughout the lifetime of an element */
esp_ble_mesh_sensor_descriptor_t descriptor; /*!< Parameters of the Sensor Descriptor state */
/**
* Multiple Sensor Setting states may be present for each sensor.
* The Sensor Setting Property ID values shall be unique for each
* Sensor Property ID that identifies a sensor within an element.
*/
const uint8_t setting_count; /*!< */
esp_ble_mesh_sensor_setting_t *settings; /*!< Parameters of the Sensor Setting state */
/**
* The Sensor Cadence state may be not supported by sensors based
* on device properties referencing "non-scalar characteristics"
* such as "histograms" or "composite characteristics".
*/
esp_ble_mesh_sensor_cadence_t *cadence; /*!< Parameters of the Sensor Cadence state */
esp_ble_mesh_sensor_data_t sensor_data; /*!< Parameters of the Sensor Data state */
esp_ble_mesh_sensor_series_column_t series_column; /*!< Parameters of the Sensor Series Column state */
} esp_ble_mesh_sensor_state_t;
/** User data of Sensor Server Model */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Sensor Server Model. Initialized internally. */
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
const uint8_t state_count; /*!< Sensor state count */
esp_ble_mesh_sensor_state_t *states; /*!< Parameters of the Sensor states */
} esp_ble_mesh_sensor_srv_t;
/** User data of Sensor Setup Server Model */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Sensor Setup Server Model. Initialized internally. */
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
const uint8_t state_count; /*!< Sensor state count */
esp_ble_mesh_sensor_state_t *states; /*!< Parameters of the Sensor states */
} esp_ble_mesh_sensor_setup_srv_t;
/** Parameters of Sensor Cadence Set state change event */
typedef struct {
uint16_t property_id; /*!< The value of Sensor Property ID state */
uint8_t period_divisor : 7, /*!< The value of Fast Cadence Period Divisor state */
trigger_type : 1; /*!< The value of Status Trigger Type state */
struct net_buf_simple *trigger_delta_down; /*!< The value of Status Trigger Delta Down state */
struct net_buf_simple *trigger_delta_up; /*!< The value of Status Trigger Delta Up state */
uint8_t min_interval; /*!< The value of Status Min Interval state */
struct net_buf_simple *fast_cadence_low; /*!< The value of Fast Cadence Low state */
struct net_buf_simple *fast_cadence_high; /*!< The value of Fast Cadence High state */
} esp_ble_mesh_state_change_sensor_cadence_set_t;
/** Parameters of Sensor Setting Set state change event */
typedef struct {
uint16_t property_id; /*!< The value of Sensor Property ID state */
uint16_t setting_property_id; /*!< The value of Sensor Setting Property ID state */
struct net_buf_simple *setting_value; /*!< The value of Sensor Property Value state */
} esp_ble_mesh_state_change_sensor_setting_set_t;
/**
* @brief Sensor Server Model state change value union
*/
typedef union {
/**
* The recv_op in ctx can be used to decide which state is changed.
*/
esp_ble_mesh_state_change_sensor_cadence_set_t sensor_cadence_set; /*!< Sensor Cadence Set */
esp_ble_mesh_state_change_sensor_setting_set_t sensor_setting_set; /*!< Sensor Setting Set */
} esp_ble_mesh_sensor_server_state_change_t;
/** Context of the received Sensor Descriptor Get message */
typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */
uint16_t property_id; /*!< Property ID of a sensor (optional) */
} esp_ble_mesh_server_recv_sensor_descriptor_get_t;
/** Context of the received Sensor Cadence Get message */
typedef struct {
uint16_t property_id; /*!< Property ID of a sensor */
} esp_ble_mesh_server_recv_sensor_cadence_get_t;
/** Context of the received Sensor Settings Get message */
typedef struct {
uint16_t property_id; /*!< Property ID of a sensor */
} esp_ble_mesh_server_recv_sensor_settings_get_t;
/** Context of the received Sensor Setting Get message */
typedef struct {
uint16_t property_id; /*!< Property ID of a sensor */
uint16_t setting_property_id; /*!< Setting ID identifying a setting within a sensor */
} esp_ble_mesh_server_recv_sensor_setting_get_t;
/** Context of the received Sensor Get message */
typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */
uint16_t property_id; /*!< Property ID for the sensor (optional) */
} esp_ble_mesh_server_recv_sensor_get_t;
/** Context of the received Sensor Column Get message */
typedef struct {
uint16_t property_id; /*!< Property identifying a sensor */
struct net_buf_simple *raw_value_x; /*!< Raw value identifying a column */
} esp_ble_mesh_server_recv_sensor_column_get_t;
/** Context of the received Sensor Series Get message */
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 containing X1 and X2 (optional) */
} esp_ble_mesh_server_recv_sensor_series_get_t;
/**
* @brief Sensor Server Model received get message union
*/
typedef union {
esp_ble_mesh_server_recv_sensor_descriptor_get_t sensor_descriptor; /*!< Sensor Descriptor Get */
esp_ble_mesh_server_recv_sensor_cadence_get_t sensor_cadence; /*!< Sensor Cadence Get */
esp_ble_mesh_server_recv_sensor_settings_get_t sensor_settings; /*!< Sensor Settings Get */
esp_ble_mesh_server_recv_sensor_setting_get_t sensor_setting; /*!< Sensor Setting Get */
esp_ble_mesh_server_recv_sensor_get_t sensor_data; /*!< Sensor Get */
esp_ble_mesh_server_recv_sensor_column_get_t sensor_column; /*!< Sensor Column Get */
esp_ble_mesh_server_recv_sensor_series_get_t sensor_series; /*!< Sensor Series Get */
} esp_ble_mesh_sensor_server_recv_get_msg_t;
/** Context of the received Sensor Cadence Set message */
typedef struct {
uint16_t property_id; /*!< Property ID for the sensor */
struct net_buf_simple *cadence; /*!< Value of Sensor Cadence state */
} esp_ble_mesh_server_recv_sensor_cadence_set_t;
/** Context of the received Sensor Setting Set message */
typedef struct {
uint16_t property_id; /*!< Property ID identifying a sensor */
uint16_t setting_property_id; /*!< Setting ID identifying a setting within a sensor */
struct net_buf_simple *setting_raw; /*!< Raw value for the setting */
} esp_ble_mesh_server_recv_sensor_setting_set_t;
/**
* @brief Sensor Server Model received set message union
*/
typedef union {
esp_ble_mesh_server_recv_sensor_cadence_set_t sensor_cadence; /*!< Sensor Cadence Set */
esp_ble_mesh_server_recv_sensor_setting_set_t sensor_setting; /*!< Sensor Setting Set */
} esp_ble_mesh_sensor_server_recv_set_msg_t;
/**
* @brief Sensor Server Model callback value union
*/
typedef union {
esp_ble_mesh_sensor_server_state_change_t state_change; /*!< ESP_BLE_MESH_SENSOR_SERVER_STATE_CHANGE_EVT */
esp_ble_mesh_sensor_server_recv_get_msg_t get; /*!< ESP_BLE_MESH_SENSOR_SERVER_RECV_GET_MSG_EVT */
esp_ble_mesh_sensor_server_recv_set_msg_t set; /*!< ESP_BLE_MESH_SENSOR_SERVER_RECV_SET_MSG_EVT */
} esp_ble_mesh_sensor_server_cb_value_t;
/** Sensor Server Model callback parameters */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to Sensor Server Models */
esp_ble_mesh_msg_ctx_t ctx; /*!< Context of the received messages */
esp_ble_mesh_sensor_server_cb_value_t value; /*!< Value of the received Sensor Messages */
} esp_ble_mesh_sensor_server_cb_param_t;
/** This enum value is the event of Sensor Server Model */
typedef enum {
/**
* 1. When get_auto_rsp is set to ESP_BLE_MESH_SERVER_AUTO_RSP, no event will be
* callback to the application layer when Sensor Get messages are received.
* 2. When set_auto_rsp is set to ESP_BLE_MESH_SERVER_AUTO_RSP, this event will
* be callback to the application layer when Sensor Set/Set Unack messages
* are received.
*/
ESP_BLE_MESH_SENSOR_SERVER_STATE_CHANGE_EVT,
/**
* When get_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, this event will be
* callback to the application layer when Sensor Get messages are received.
*/
ESP_BLE_MESH_SENSOR_SERVER_RECV_GET_MSG_EVT,
/**
* When set_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, this event will be
* callback to the application layer when Sensor Set/Set Unack messages are received.
*/
ESP_BLE_MESH_SENSOR_SERVER_RECV_SET_MSG_EVT,
ESP_BLE_MESH_SENSOR_SERVER_EVT_MAX,
} esp_ble_mesh_sensor_server_cb_event_t;
/**
* @brief Bluetooth Mesh Sensor Server Model function.
*/
/**
* @brief Sensor Server Model callback function type
* @param event: Event type
* @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);
/**
* @brief Register BLE Mesh Sensor Server Model callback.
*
* @param[in] callback: Pointer to the callback function.
*
* @return ESP_OK on success or error code otherwise.
*
*/
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

@ -19,9 +19,12 @@
#ifndef _ESP_BLE_MESH_TIME_SCENE_MODEL_API_H_
#define _ESP_BLE_MESH_TIME_SCENE_MODEL_API_H_
#include "time_scene_client.h"
#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.
@ -76,69 +79,69 @@
/** Parameters of Time Set */
typedef struct {
u8_t tai_seconds[5]; /*!< The current TAI time in seconds */
u8_t sub_second; /*!< The sub-second time in units of 1/256 second */
u8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */
u16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */
u16_t tai_utc_delta : 15; /*!< Current difference between TAI and UTC in seconds */
u8_t time_zone_offset; /*!< The local time zone offset in 15-minute increments */
uint8_t tai_seconds[5]; /*!< The current TAI time in seconds */
uint8_t sub_second; /*!< The sub-second time in units of 1/256 second */
uint8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */
uint16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */
uint16_t tai_utc_delta : 15; /*!< Current difference between TAI and UTC in seconds */
uint8_t time_zone_offset; /*!< The local time zone offset in 15-minute increments */
} esp_ble_mesh_time_set_t;
/** Parameters of Time Zone Set */
typedef struct {
u8_t time_zone_offset_new; /*!< Upcoming local time zone offset */
u8_t tai_zone_change[5]; /*!< TAI Seconds time of the upcoming Time Zone Offset change */
uint8_t time_zone_offset_new; /*!< Upcoming local time zone offset */
uint8_t tai_zone_change[5]; /*!< TAI Seconds time of the upcoming Time Zone Offset change */
} esp_ble_mesh_time_zone_set_t;
/** Parameters of TAI-UTC Delta Set */
typedef struct {
u16_t tai_utc_delta_new : 15; /*!< Upcoming difference between TAI and UTC in seconds */
u16_t padding : 1; /*!< Always 0b0. Other values are Prohibited. */
u8_t tai_delta_change[5]; /*!< TAI Seconds time of the upcoming TAI-UTC Delta change */
uint16_t tai_utc_delta_new : 15; /*!< Upcoming difference between TAI and UTC in seconds */
uint16_t padding : 1; /*!< Always 0b0. Other values are Prohibited. */
uint8_t tai_delta_change[5]; /*!< TAI Seconds time of the upcoming TAI-UTC Delta change */
} esp_ble_mesh_tai_utc_delta_set_t;
/** Parameter of Time Role Set */
typedef struct {
u8_t time_role; /*!< The Time Role for the element */
uint8_t time_role; /*!< The Time Role for the element */
} esp_ble_mesh_time_role_set_t;
/** Parameter of Scene Store */
typedef struct {
u16_t scene_number; /*!< The number of scenes to be stored */
uint16_t scene_number; /*!< The number of scenes to be stored */
} esp_ble_mesh_scene_store_t;
/** Parameters of Scene Recall */
typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */
u16_t scene_number; /*!< The number of scenes to be recalled */
u8_t tid; /*!< Transaction ID */
u8_t trans_time; /*!< Time to complete state transition (optional) */
u8_t delay; /*!< Indicate message execution delay (C.1) */
bool op_en; /*!< Indicate if optional parameters are included */
uint16_t scene_number; /*!< The number of scenes to be recalled */
uint8_t tid; /*!< Transaction ID */
uint8_t trans_time; /*!< Time to complete state transition (optional) */
uint8_t delay; /*!< Indicate message execution delay (C.1) */
} esp_ble_mesh_scene_recall_t;
/** Parameter of Scene Delete */
typedef struct {
u16_t scene_number; /*!< The number of scenes to be deleted */
uint16_t scene_number; /*!< The number of scenes to be deleted */
} esp_ble_mesh_scene_delete_t;
/** Parameter of Scheduler Action Get */
typedef struct {
u8_t index; /*!< Index of the Schedule Register entry to get */
uint8_t index; /*!< Index of the Schedule Register entry to get */
} esp_ble_mesh_scheduler_act_get_t;
/** Parameters of Scheduler Action Set */
typedef struct {
u64_t index : 4; /*!< Index of the Schedule Register entry to set */
u64_t year : 7; /*!< Scheduled year for the action */
u64_t month : 12; /*!< Scheduled month for the action */
u64_t day : 5; /*!< Scheduled day of the month for the action */
u64_t hour : 5; /*!< Scheduled hour for the action */
u64_t minute : 6; /*!< Scheduled minute for the action */
u64_t second : 6; /*!< Scheduled second for the action */
u64_t day_of_week : 7; /*!< Schedule days of the week for the action */
u64_t action : 4; /*!< Action to be performed at the scheduled time */
u64_t trans_time : 8; /*!< Transition time for this action */
u16_t scene_number; /*!< Transition time for this action */
uint64_t index : 4; /*!< Index of the Schedule Register entry to set */
uint64_t year : 7; /*!< Scheduled year for the action */
uint64_t month : 12; /*!< Scheduled month for the action */
uint64_t day : 5; /*!< Scheduled day of the month for the action */
uint64_t hour : 5; /*!< Scheduled hour for the action */
uint64_t minute : 6; /*!< Scheduled minute for the action */
uint64_t second : 6; /*!< Scheduled second for the action */
uint64_t day_of_week : 7; /*!< Schedule days of the week for the action */
uint64_t action : 4; /*!< Action to be performed at the scheduled time */
uint64_t trans_time : 8; /*!< Transition time for this action */
uint16_t scene_number; /*!< Transition time for this action */
} esp_ble_mesh_scheduler_act_set_t;
/**
@ -168,69 +171,69 @@ typedef union {
/** Parameters of Time Status */
typedef struct {
u8_t tai_seconds[5]; /*!< The current TAI time in seconds */
u8_t sub_second; /*!< The sub-second time in units of 1/256 second */
u8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */
u16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */
u16_t tai_utc_delta : 15; /*!< Current difference between TAI and UTC in seconds */
u8_t time_zone_offset; /*!< The local time zone offset in 15-minute increments */
uint8_t tai_seconds[5]; /*!< The current TAI time in seconds */
uint8_t sub_second; /*!< The sub-second time in units of 1/256 second */
uint8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */
uint16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */
uint16_t tai_utc_delta : 15; /*!< Current difference between TAI and UTC in seconds */
uint8_t time_zone_offset; /*!< The local time zone offset in 15-minute increments */
} esp_ble_mesh_time_status_cb_t;
/** Parameters of Time Zone Status */
typedef struct {
u8_t time_zone_offset_curr; /*!< Current local time zone offset */
u8_t time_zone_offset_new; /*!< Upcoming local time zone offset */
u8_t tai_zone_change[5]; /*!< TAI Seconds time of the upcoming Time Zone Offset change */
uint8_t time_zone_offset_curr; /*!< Current local time zone offset */
uint8_t time_zone_offset_new; /*!< Upcoming local time zone offset */
uint8_t tai_zone_change[5]; /*!< TAI Seconds time of the upcoming Time Zone Offset change */
} esp_ble_mesh_time_zone_status_cb_t;
/** Parameters of TAI-UTC Delta Status */
typedef struct {
u16_t tai_utc_delta_curr : 15; /*!< Current difference between TAI and UTC in seconds */
u16_t padding_1 : 1; /*!< Always 0b0. Other values are Prohibited. */
u16_t tai_utc_delta_new : 15; /*!< Upcoming difference between TAI and UTC in seconds */
u16_t padding_2 : 1; /*!< Always 0b0. Other values are Prohibited. */
u8_t tai_delta_change[5]; /*!< TAI Seconds time of the upcoming TAI-UTC Delta change */
uint16_t tai_utc_delta_curr : 15; /*!< Current difference between TAI and UTC in seconds */
uint16_t padding_1 : 1; /*!< Always 0b0. Other values are Prohibited. */
uint16_t tai_utc_delta_new : 15; /*!< Upcoming difference between TAI and UTC in seconds */
uint16_t padding_2 : 1; /*!< Always 0b0. Other values are Prohibited. */
uint8_t tai_delta_change[5]; /*!< TAI Seconds time of the upcoming TAI-UTC Delta change */
} esp_ble_mesh_tai_utc_delta_status_cb_t;
/** Parameter of Time Role Status */
typedef struct {
u8_t time_role; /*!< The Time Role for the element */
uint8_t time_role; /*!< The Time Role for the element */
} esp_ble_mesh_time_role_status_cb_t;
/** Parameters of Scene Status */
typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */
u8_t status_code; /*!< Status code of the last operation */
u16_t current_scene; /*!< Scene Number of the current scene */
u16_t target_scene; /*!< Scene Number of the target scene (optional) */
u8_t remain_time; /*!< Time to complete state transition (C.1) */
bool op_en; /*!< Indicate if optional parameters are included */
uint8_t status_code; /*!< Status code of the last operation */
uint16_t current_scene; /*!< Scene Number of the current scene */
uint16_t target_scene; /*!< Scene Number of the target scene (optional) */
uint8_t remain_time; /*!< Time to complete state transition (C.1) */
} esp_ble_mesh_scene_status_cb_t;
/** Parameters of Scene Register Status */
typedef struct {
u8_t status_code; /*!< Status code for the previous operation */
u16_t current_scene; /*!< Scene Number of the current scene */
uint8_t status_code; /*!< Status code for the previous operation */
uint16_t current_scene; /*!< Scene Number of the current scene */
struct net_buf_simple *scenes; /*!< A list of scenes stored within an element */
} esp_ble_mesh_scene_register_status_cb_t;
/** Parameter of Scheduler Status */
typedef struct {
u16_t schedules; /*!< Bit field indicating defined Actions in the Schedule Register */
uint16_t schedules; /*!< Bit field indicating defined Actions in the Schedule Register */
} esp_ble_mesh_scheduler_status_cb_t;
/** Parameters of Scheduler Action Status */
typedef struct {
u64_t index : 4; /*!< Enumerates (selects) a Schedule Register entry */
u64_t year : 7; /*!< Scheduled year for the action */
u64_t month : 12; /*!< Scheduled month for the action */
u64_t day : 5; /*!< Scheduled day of the month for the action */
u64_t hour : 5; /*!< Scheduled hour for the action */
u64_t minute : 6; /*!< Scheduled minute for the action */
u64_t second : 6; /*!< Scheduled second for the action */
u64_t day_of_week : 7; /*!< Schedule days of the week for the action */
u64_t action : 4; /*!< Action to be performed at the scheduled time */
u64_t trans_time : 8; /*!< Transition time for this action */
u16_t scene_number; /*!< Transition time for this action */
uint64_t index : 4; /*!< Enumerates (selects) a Schedule Register entry */
uint64_t year : 7; /*!< Scheduled year for the action */
uint64_t month : 12; /*!< Scheduled month for the action */
uint64_t day : 5; /*!< Scheduled day of the month for the action */
uint64_t hour : 5; /*!< Scheduled hour for the action */
uint64_t minute : 6; /*!< Scheduled minute for the action */
uint64_t second : 6; /*!< Scheduled second for the action */
uint64_t day_of_week : 7; /*!< Schedule days of the week for the action */
uint64_t action : 4; /*!< Action to be performed at the scheduled time */
uint64_t trans_time : 8; /*!< Transition time for this action */
uint16_t scene_number; /*!< Transition time for this action */
} esp_ble_mesh_scheduler_act_status_cb_t;
/**
@ -273,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.
@ -298,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.
@ -313,7 +316,605 @@ 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.
*/
/** @def ESP_BLE_MESH_MODEL_TIME_SRV
*
* @brief Define a new Time Server Model.
*
* @note 1. The Time Server model is a root model. When this model is present on an
* Element, the corresponding Time Setup Server model shall also be present.
* 2. This model shall support model publication and model subscription.
*
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
* @param srv_data Pointer to the unique struct esp_ble_mesh_time_srv_t.
*
* @return New Time Server Model instance.
*/
#define ESP_BLE_MESH_MODEL_TIME_SRV(srv_pub, srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_TIME_SRV, \
NULL, srv_pub, srv_data)
/** @def ESP_BLE_MESH_MODEL_TIME_SETUP_SRV
*
* @brief Define a new Time Setup Server Model.
*
* @note 1. The Time Setup Server model extends the Time Server model. Time is
* sensitive information that is propagated across a mesh network.
* 2. Only an authorized Time Client should be allowed to change the Time
* and Time Role states. A dedicated application key Bluetooth SIG
* Proprietary should be used on the Time Setup Server to restrict
* access to the server to only authorized Time Clients.
* 3. This model does not support subscribing nor publishing.
*
* @param srv_data Pointer to the unique struct esp_ble_mesh_time_setup_srv_t.
*
* @return New Time Setup Server Model instance.
*/
#define ESP_BLE_MESH_MODEL_TIME_SETUP_SRV(srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_TIME_SETUP_SRV, \
NULL, NULL, srv_data)
/** @def ESP_BLE_MESH_MODEL_SCENE_SRV
*
* @brief Define a new Scene Server Model.
*
* @note 1. The Scene Server model is a root model. When this model is present
* on an Element, the corresponding Scene Setup Server model shall
* also be present.
* 2. This model shall support model publication and model subscription.
* 3. The model may be present only on the Primary element of a node.
*
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
* @param srv_data Pointer to the unique struct esp_ble_mesh_scene_srv_t.
*
* @return New Scene Server Model instance.
*/
#define ESP_BLE_MESH_MODEL_SCENE_SRV(srv_pub, srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SCENE_SRV, \
NULL, srv_pub, srv_data)
/** @def ESP_BLE_MESH_MODEL_SCENE_SETUP_SRV
*
* @brief Define a new Scene Setup Server Model.
*
* @note 1. The Scene Setup Server model extends the Scene Server model and
* the Generic Default Transition Time Server model.
* 2. This model shall support model subscription.
* 3. The model may be present only on the Primary element of a node.
*
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
* @param srv_data Pointer to the unique struct esp_ble_mesh_scene_setup_srv_t.
*
* @return New Scene Setup Server Model instance.
*/
#define ESP_BLE_MESH_MODEL_SCENE_SETUP_SRV(srv_pub, srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SCENE_SETUP_SRV, \
NULL, srv_pub, srv_data)
/** @def ESP_BLE_MESH_MODEL_SCHEDULER_SRV
*
* @brief Define a new Scheduler Server Model.
*
* @note 1. The Scheduler Server model extends the Scene Server model. When
* this model is present on an Element, the corresponding Scheduler
* Setup Server model shall also be present.
* 2. This model shall support model publication and model subscription.
* 3. The model may be present only on the Primary element of a node.
* 4. The model requires the Time Server model shall be present on the element.
*
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
* @param srv_data Pointer to the unique struct esp_ble_mesh_scheduler_srv_t.
*
* @return New Scheduler Server Model instance.
*/
#define ESP_BLE_MESH_MODEL_SCHEDULER_SRV(srv_pub, srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SCHEDULER_SRV, \
NULL, srv_pub, srv_data)
/** @def ESP_BLE_MESH_MODEL_SCHEDULER_SETUP_SRV
*
* @brief Define a new Scheduler Setup Server Model.
*
* @note 1. The Scheduler Setup Server model extends the Scheduler Server and
* the Scene Setup Server models.
* 2. This model shall support model subscription.
* 3. The model may be present only on the Primary element of a node.
*
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
* @param srv_data Pointer to the unique struct esp_ble_mesh_scheduler_setup_srv_t.
*
* @return New Scheduler Setup Server Model instance.
*/
#define ESP_BLE_MESH_MODEL_SCHEDULER_SETUP_SRV(srv_pub, srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SCHEDULER_SETUP_SRV, \
NULL, srv_pub, srv_data)
#define ESP_BLE_MESH_UNKNOWN_TAI_SECONDS 0x0000000000 /*!< Unknown TAI Seconds */
#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_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_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 */
#define ESP_BLE_MESH_SCHEDULE_YEAR_ANY_YEAR 0x64 /*!< Any year of the Scheduled year */
#define ESP_BLE_MESH_SCHEDULE_DAY_ANY_DAY 0x00 /*!< Any day of the Scheduled day */
#define ESP_BLE_MESH_SCHEDULE_HOUR_ANY_HOUR 0x18 /*!< Any hour of the Scheduled hour */
#define ESP_BLE_MESH_SCHEDULE_HOUR_ONCE_A_DAY 0x19 /*!< Any hour of the Scheduled Day */
#define ESP_BLE_MESH_SCHEDULE_SEC_ANY_OF_HOUR 0x3C /*!< Any minute of the Scheduled hour */
#define ESP_BLE_MESH_SCHEDULE_SEC_EVERY_15_MIN 0x3D /*!< Every 15 minutes of the Scheduled hour */
#define ESP_BLE_MESH_SCHEDULE_SEC_EVERY_20_MIN 0x3E /*!< Every 20 minutes of the Scheduled hour */
#define ESP_BLE_MESH_SCHEDULE_SEC_ONCE_AN_HOUR 0x3F /*!< Once of the Scheduled hour */
#define ESP_BLE_MESH_SCHEDULE_SEC_ANY_OF_MIN 0x3C /*!< Any second of the Scheduled minute */
#define ESP_BLE_MESH_SCHEDULE_SEC_EVERY_15_SEC 0x3D /*!< Every 15 seconds of the Scheduled minute */
#define ESP_BLE_MESH_SCHEDULE_SEC_EVERY_20_SEC 0x3E /*!< Every 20 seconds of the Scheduled minute */
#define ESP_BLE_MESH_SCHEDULE_SEC_ONCE_AN_MIN 0x3F /*!< Once of the Scheduled minute */
#define ESP_BLE_MESH_SCHEDULE_ACT_TURN_OFF 0x00 /*!< Scheduled Action - Turn Off */
#define ESP_BLE_MESH_SCHEDULE_ACT_TURN_ON 0x01 /*!< Scheduled Action - Turn On */
#define ESP_BLE_MESH_SCHEDULE_ACT_SCENE_RECALL 0x02 /*!< Scheduled Action - Scene Recall */
#define ESP_BLE_MESH_SCHEDULE_ACT_NO_ACTION 0x0F /*!< Scheduled Action - No Action */
#define ESP_BLE_MESH_SCHEDULE_SCENE_NO_SCENE 0x0000 /*!< Scheduled Scene - No Scene */
#define ESP_BLE_MESH_SCHEDULE_ENTRY_MAX_INDEX 0x0F /*!< Maximum number of Scheduled entries */
#define ESP_BLE_MESH_TIME_NONE 0x00 /*!< Time Role - None */
#define ESP_BLE_MESH_TIME_AUTHORITY 0x01 /*!< Time Role - Mesh Time Authority */
#define ESP_BLE_MESH_TIME_RELAY 0x02 /*!< Time Role - Mesh Time Relay */
#define ESP_BLE_MESH_TIME_CLINET 0x03 /*!< Time Role - Mesh Time Client */
#define ESP_BLE_MESH_SCENE_SUCCESS 0x00 /*!< Scene operation - Success */
#define ESP_BLE_MESH_SCENE_REG_FULL 0x01 /*!< Scene operation - Scene Register Full */
#define ESP_BLE_MESH_SCENE_NOT_FOUND 0x02 /*!< Scene operation - Scene Not Found */
/** Parameters of Time state */
typedef struct {
struct {
uint8_t tai_seconds[5]; /*!< The value of the TAI Seconds state */
uint8_t subsecond; /*!< The value of the Subsecond field */
uint8_t uncertainty; /*!< The value of the Uncertainty field */
uint8_t time_zone_offset_curr; /*!< The value of the Time Zone Offset Current field */
uint8_t time_zone_offset_new; /*!< The value of the Time Zone Offset New state */
uint8_t tai_zone_change[5]; /*!< The value of the TAI of Zone Chaneg field */
uint16_t time_authority : 1, /*!< The value of the Time Authority bit */
tai_utc_delta_curr : 15; /*!< The value of the TAI-UTC Delta Current state */
uint16_t tai_utc_delta_new : 15; /*!< The value of the TAI-UTC Delta New state */
uint8_t tai_delta_change[5]; /*!< The value of the TAI of Delta Change field */
} time; /*!< Parameters of the Time state */
uint8_t time_role; /*!< The value of the Time Role state */
} esp_ble_mesh_time_state_t;
/** User data of Time Server Model */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Time Server Model. Initialized internally. */
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
esp_ble_mesh_time_state_t *state; /*!< Parameters of the Time state */
} esp_ble_mesh_time_srv_t;
/** User data of Time Setup Server Model */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Time Setup Server Model. Initialized internally. */
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
esp_ble_mesh_time_state_t *state; /*!< Parameters of the Time state */
} esp_ble_mesh_time_setup_srv_t;
/**
* 1. Scene Store is an operation of storing values of a present state of an element.
* 2. The structure and meaning of the stored state is determined by a model. States
* to be stored are specified by each model.
* 3. The Scene Store operation shall persistently store all values of all states
* marked as Stored with Scene for all models present on all elements of a node.
* 4. If a model is extending another model, the extending model shall determine the
* Stored with Scene behavior of that model.
*/
/** Parameters of Scene Register state */
typedef struct {
uint16_t scene_number; /*!< The value of the Scene Number */
uint8_t scene_type; /*!< The value of the Scene Type */
/**
* Scene value may use a union to represent later, the union contains
* structures of all the model states which can be stored in a scene.
*/
struct net_buf_simple *scene_value; /*!< The value of the Scene Value */
} esp_ble_mesh_scene_register_t;
/**
* Parameters of Scenes state.
*
* Scenes serve as memory banks for storage of states (e.g., a power level
* or a light level/color). Values of states of an element can be stored
* as a scene and can be recalled later from the scene memory.
*
* A scene is represented by a Scene Number, which is a 16-bit non-zero,
* mesh-wide value. (There can be a maximum of 65535 scenes in a mesh
* network.) The meaning of a scene, as well as the state storage container
* associated with it, are determined by a model.
*
* The Scenes state change may start numerous parallel model transitions.
* In that case, each individual model handles the transition internally.
*
* The scene transition is defined as a group of individual model transitions
* started by a Scene Recall operation. The scene transition is in progress
* when at least one transition from the group of individual model transitions
* is in progress.
*/
typedef struct {
const uint16_t scene_count; /*!< The Scenes state's scene count */
esp_ble_mesh_scene_register_t *scenes; /*!< Parameters of the Scenes state */
/**
* The Current Scene state is a 16-bit value that contains either the Scene
* Number of the currently active scene or a value of 0x0000 when no scene
* is active.
*
* When a Scene Store operation or a Scene Recall operation completes with
* success, the Current Scene state value shall be to the Scene Number used
* during that operation.
*
* When the Current Scene Number is deleted from a Scene Register state as a
* result of Scene Delete operation, the Current Scene state shall be set to
* 0x0000.
*
* When any of the element's state that is marked as “Stored with Scene” has
* changed not as a result of a Scene Recall operation, the value of the
* Current Scene state shall be set to 0x0000.
*
* When a scene transition is in progress, the value of the Current Scene
* state shall be set to 0x0000.
*/
uint16_t current_scene; /*!< The value of the Current Scene state */
/**
* The Target Scene state is a 16-bit value that contains the target Scene
* Number when a scene transition is in progress.
*
* When the scene transition is in progress and the target Scene Number is
* deleted from a Scene Register state as a result of Scene Delete operation,
* the Target Scene state shall be set to 0x0000.
*
* When the scene transition is in progress and a new Scene Number is stored
* in the Scene Register as a result of Scene Store operation, the Target
* Scene state shall be set to the new Scene Number.
*
* When the scene transition is not in progress, the value of the Target Scene
* state shall be set to 0x0000.
*/
uint16_t target_scene; /*!< The value of the Target Scene state */
/* Indicate the status code for the last operation */
uint8_t status_code; /*!< The status code of the last scene operation */
/* Indicate if scene transition is in progress */
bool in_progress; /*!< Indicate if the scene transition is in progress */
} esp_ble_mesh_scenes_state_t;
/** User data of Scene Server Model */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Scene Server Model. Initialized internally. */
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
esp_ble_mesh_scenes_state_t *state; /*!< Parameters of the Scenes state */
esp_ble_mesh_last_msg_info_t last; /*!< Parameters of the last received set message */
esp_ble_mesh_state_transition_t transition; /*!< Parameters of state transition */
} esp_ble_mesh_scene_srv_t;
/** User data of Scene Setup Server Model */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Scene Setup Server Model. Initialized internally. */
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
esp_ble_mesh_scenes_state_t *state; /*!< Parameters of the Scenes state */
} esp_ble_mesh_scene_setup_srv_t;
/** Parameters of Scheduler Register state */
typedef struct {
bool in_use; /*!< Indicate if the registered schedule is in use */
uint64_t year : 7, /*!< The value of Scheduled year for the action */
month : 12, /*!< The value of Scheduled month for the action */
day : 5, /*!< The value of Scheduled day of the month for the action */
hour : 5, /*!< The value of Scheduled hour for the action */
minute : 6, /*!< The value of Scheduled minute for the action */
second : 6, /*!< The value of Scheduled second for the action */
day_of_week : 7, /*!< The value of Schedule days of the week for the action */
action : 4, /*!< The value of Action to be performed at the scheduled time */
trans_time : 8; /*!< The value of Transition time for this action */
uint16_t scene_number; /*!< The value of Scene Number to be used for some actions */
} esp_ble_mesh_schedule_register_t;
/** Parameters of Scheduler state */
typedef struct {
const uint8_t schedule_count; /*!< Scheduler count */
esp_ble_mesh_schedule_register_t *schedules; /*!< Up to 16 scheduled entries */
} esp_ble_mesh_scheduler_state_t;
/** User data of Scheduler Server Model */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Scheduler Server Model. Initialized internally. */
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
esp_ble_mesh_scheduler_state_t *state; /*!< Parameters of the Scheduler state */
} esp_ble_mesh_scheduler_srv_t;
/** User data of Scheduler Setup Server Model */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Scheduler Setup Server Model. Initialized internally. */
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
esp_ble_mesh_scheduler_state_t *state; /*!< Parameters of the Scheduler state */
} esp_ble_mesh_scheduler_setup_srv_t;
/** Parameters of Time Set state change event */
typedef struct {
uint8_t tai_seconds[5]; /*!< The current TAI time in seconds */
uint8_t subsecond; /*!< The sub-second time in units of 1/256 second */
uint8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */
uint16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */
uint16_t tai_utc_delta_curr : 15; /*!< Current difference between TAI and UTC in seconds */
uint8_t time_zone_offset_curr; /*!< The local time zone offset in 15-minute increments */
} esp_ble_mesh_state_change_time_set_t;
/** Parameters of Time Status state change event */
typedef struct {
uint8_t tai_seconds[5]; /*!< The current TAI time in seconds */
uint8_t subsecond; /*!< The sub-second time in units of 1/256 second */
uint8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */
uint16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */
uint16_t tai_utc_delta_curr : 15; /*!< Current difference between TAI and UTC in seconds */
uint8_t time_zone_offset_curr; /*!< The local time zone offset in 15-minute increments */
} esp_ble_mesh_state_change_time_status_t;
/** Parameters of Time Zone Set state change event */
typedef struct {
uint8_t time_zone_offset_new; /*!< Upcoming local time zone offset */
uint8_t tai_zone_change[5]; /*!< TAI Seconds time of the upcoming Time Zone Offset change */
} esp_ble_mesh_state_change_time_zone_set_t;
/** Parameters of TAI UTC Delta Set state change event */
typedef struct {
uint16_t tai_utc_delta_new : 15; /*!< Upcoming difference between TAI and UTC in seconds */
uint8_t tai_delta_change[5]; /*!< TAI Seconds time of the upcoming TAI-UTC Delta change */
} esp_ble_mesh_state_change_tai_utc_delta_set_t;
/** Parameter of Time Role Set state change event */
typedef struct {
uint8_t time_role; /*!< The Time Role for the element */
} esp_ble_mesh_state_change_time_role_set_t;
/** Parameter of Scene Store state change event */
typedef struct {
uint16_t scene_number; /*!< The number of scenes to be stored */
} esp_ble_mesh_state_change_scene_store_t;
/** Parameter of Scene Recall state change event */
typedef struct {
uint16_t scene_number; /*!< The number of scenes to be recalled */
} esp_ble_mesh_state_change_scene_recall_t;
/** Parameter of Scene Delete state change event */
typedef struct {
uint16_t scene_number; /*!< The number of scenes to be deleted */
} esp_ble_mesh_state_change_scene_delete_t;
/** Parameter of Scheduler Action Set state change event */
typedef struct {
uint64_t index : 4; /*!< Index of the Schedule Register entry to set */
uint64_t year : 7; /*!< Scheduled year for the action */
uint64_t month : 12; /*!< Scheduled month for the action */
uint64_t day : 5; /*!< Scheduled day of the month for the action */
uint64_t hour : 5; /*!< Scheduled hour for the action */
uint64_t minute : 6; /*!< Scheduled minute for the action */
uint64_t second : 6; /*!< Scheduled second for the action */
uint64_t day_of_week : 7; /*!< Schedule days of the week for the action */
uint64_t action : 4; /*!< Action to be performed at the scheduled time */
uint64_t trans_time : 8; /*!< Transition time for this action */
uint16_t scene_number; /*!< Scene number to be used for some actions */
} esp_ble_mesh_state_change_scheduler_act_set_t;
/**
* @brief Time Scene Server Model state change value union
*/
typedef union {
/**
* The recv_op in ctx can be used to decide which state is changed.
*/
esp_ble_mesh_state_change_time_set_t time_set; /*!< Time Set */
esp_ble_mesh_state_change_time_status_t time_status; /*!< Time Status */
esp_ble_mesh_state_change_time_zone_set_t time_zone_set; /*!< Time Zone Set */
esp_ble_mesh_state_change_tai_utc_delta_set_t tai_utc_delta_set; /*!< TAI UTC Delta Set */
esp_ble_mesh_state_change_time_role_set_t time_role_set; /*!< Time Role Set */
esp_ble_mesh_state_change_scene_store_t scene_store; /*!< Scene Store */
esp_ble_mesh_state_change_scene_recall_t scene_recall; /*!< Scene Recall */
esp_ble_mesh_state_change_scene_delete_t scene_delete; /*!< Scene Delete */
esp_ble_mesh_state_change_scheduler_act_set_t scheduler_act_set; /*!< Scheduler Action Set */
} esp_ble_mesh_time_scene_server_state_change_t;
/** Context of the received Scheduler Action Get message */
typedef struct {
uint8_t index; /*!< Index of the Schedule Register entry to get */
} esp_ble_mesh_server_recv_scheduler_act_get_t;
/**
* @brief Time Scene Server Model received get message union
*/
typedef union {
esp_ble_mesh_server_recv_scheduler_act_get_t scheduler_act; /*!< Scheduler Action Get */
} esp_ble_mesh_time_scene_server_recv_get_msg_t;
/** Context of the received Time Set message */
typedef struct {
uint8_t tai_seconds[5]; /*!< The current TAI time in seconds */
uint8_t subsecond; /*!< The sub-second time in units of 1/256 second */
uint8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */
uint16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */
uint16_t tai_utc_delta : 15; /*!< Current difference between TAI and UTC in seconds */
uint8_t time_zone_offset; /*!< The local time zone offset in 15-minute increments */
} esp_ble_mesh_server_recv_time_set_t;
/** Context of the received Time Zone Set message */
typedef struct {
uint8_t time_zone_offset_new; /*!< Upcoming local time zone offset */
uint8_t tai_zone_change[5]; /*!< TAI Seconds time of the upcoming Time Zone Offset change */
} esp_ble_mesh_server_recv_time_zone_set_t;
/** Context of the received TAI UTC Delta Set message */
typedef struct {
uint16_t tai_utc_delta_new : 15; /*!< Upcoming difference between TAI and UTC in seconds */
uint16_t padding : 1; /*!< Always 0b0. Other values are Prohibited. */
uint8_t tai_delta_change[5]; /*!< TAI Seconds time of the upcoming TAI-UTC Delta change */
} esp_ble_mesh_server_recv_tai_utc_delta_set_t;
/** Context of the received Time Role Set message */
typedef struct {
uint8_t time_role; /*!< The Time Role for the element */
} esp_ble_mesh_server_recv_time_role_set_t;
/** Context of the received Scene Store message */
typedef struct {
uint16_t scene_number; /*!< The number of scenes to be stored */
} esp_ble_mesh_server_recv_scene_store_t;
/** Context of the received Scene Recall message */
typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */
uint16_t scene_number; /*!< The number of scenes to be recalled */
uint8_t tid; /*!< Transaction ID */
uint8_t trans_time; /*!< Time to complete state transition (optional) */
uint8_t delay; /*!< Indicate message execution delay (C.1) */
} esp_ble_mesh_server_recv_scene_recall_t;
/** Context of the received Scene Delete message */
typedef struct {
uint16_t scene_number; /*!< The number of scenes to be deleted */
} esp_ble_mesh_server_recv_scene_delete_t;
/** Context of the received Scheduler Action Set message */
typedef struct {
uint64_t index : 4; /*!< Index of the Schedule Register entry to set */
uint64_t year : 7; /*!< Scheduled year for the action */
uint64_t month : 12; /*!< Scheduled month for the action */
uint64_t day : 5; /*!< Scheduled day of the month for the action */
uint64_t hour : 5; /*!< Scheduled hour for the action */
uint64_t minute : 6; /*!< Scheduled minute for the action */
uint64_t second : 6; /*!< Scheduled second for the action */
uint64_t day_of_week : 7; /*!< Schedule days of the week for the action */
uint64_t action : 4; /*!< Action to be performed at the scheduled time */
uint64_t trans_time : 8; /*!< Transition time for this action */
uint16_t scene_number; /*!< Scene number to be used for some actions */
} esp_ble_mesh_server_recv_scheduler_act_set_t;
/**
* @brief Time Scene Server Model received set message union
*/
typedef union {
esp_ble_mesh_server_recv_time_set_t time; /*!< Time Set */
esp_ble_mesh_server_recv_time_zone_set_t time_zone; /*!< Time Zone Set */
esp_ble_mesh_server_recv_tai_utc_delta_set_t tai_utc_delta; /*!< TAI-UTC Delta Set */
esp_ble_mesh_server_recv_time_role_set_t time_role; /*!< Time Role Set */
esp_ble_mesh_server_recv_scene_store_t scene_store; /*!< Scene Store/Scene Store Unack */
esp_ble_mesh_server_recv_scene_recall_t scene_recall; /*!< Scene Recall/Scene Recall Unack */
esp_ble_mesh_server_recv_scene_delete_t scene_delete; /*!< Scene Delete/Scene Delete Unack */
esp_ble_mesh_server_recv_scheduler_act_set_t scheduler_act; /*!< Scheduler Action Set/Scheduler Action Set Unack */
} esp_ble_mesh_time_scene_server_recv_set_msg_t;
/** Context of the received Time Status message */
typedef struct {
uint8_t tai_seconds[5]; /*!< The current TAI time in seconds */
uint8_t subsecond; /*!< The sub-second time in units of 1/256 second */
uint8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */
uint16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */
uint16_t tai_utc_delta : 15; /*!< Current difference between TAI and UTC in seconds */
uint8_t time_zone_offset; /*!< The local time zone offset in 15-minute increments */
} esp_ble_mesh_server_recv_time_status_t;
/**
* @brief Time Scene Server Model received status message union
*/
typedef union {
esp_ble_mesh_server_recv_time_status_t time_status; /*!< Time Status */
} esp_ble_mesh_time_scene_server_recv_status_msg_t;
/**
* @brief Time Scene Server Model callback value union
*/
typedef union {
esp_ble_mesh_time_scene_server_state_change_t state_change; /*!< ESP_BLE_MESH_TIME_SCENE_SERVER_STATE_CHANGE_EVT */
esp_ble_mesh_time_scene_server_recv_get_msg_t get; /*!< ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_GET_MSG_EVT */
esp_ble_mesh_time_scene_server_recv_set_msg_t set; /*!< ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_SET_MSG_EVT */
esp_ble_mesh_time_scene_server_recv_status_msg_t status; /*!< ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_STATUS_MSG_EVT */
} esp_ble_mesh_time_scene_server_cb_value_t;
/** Time Scene Server Model callback parameters */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to Time and Scenes Server Models */
esp_ble_mesh_msg_ctx_t ctx; /*!< Context of the received messages */
esp_ble_mesh_time_scene_server_cb_value_t value; /*!< Value of the received Time and Scenes Messages */
} esp_ble_mesh_time_scene_server_cb_param_t;
/** This enum value is the event of Time Scene Server Model */
typedef enum {
/**
* 1. When get_auto_rsp is set to ESP_BLE_MESH_SERVER_AUTO_RSP, no event will be
* callback to the application layer when Time Scene Get messages are received.
* 2. When set_auto_rsp is set to ESP_BLE_MESH_SERVER_AUTO_RSP, this event will
* be callback to the application layer when Time Scene Set/Set Unack messages
* are received.
*/
ESP_BLE_MESH_TIME_SCENE_SERVER_STATE_CHANGE_EVT,
/**
* When get_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, this event will be
* callback to the application layer when Time Scene Get messages are received.
*/
ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_GET_MSG_EVT,
/**
* When set_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, this event will be
* callback to the application layer when Time Scene Set/Set Unack messages are received.
*/
ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_SET_MSG_EVT,
/**
* When status_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, this event will
* be callback to the application layer when TIme Status message is received.
*/
ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_STATUS_MSG_EVT,
ESP_BLE_MESH_TIME_SCENE_SERVER_EVT_MAX,
} esp_ble_mesh_time_scene_server_cb_event_t;
/**
* @brief Bluetooth Mesh Time and Scenes Server Model function.
*/
/**
* @brief Time Scene Server Model callback function type
* @param event: Event type
* @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);
/**
* @brief Register BLE Mesh Time and Scenes Server Model callback.
*
* @param[in] callback: Pointer to the callback function.
*
* @return ESP_OK on success or error code otherwise.
*
*/
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 */

File diff suppressed because it is too large Load Diff

View File

@ -15,19 +15,21 @@
#include <string.h>
#include <errno.h>
#include "btc/btc_manage.h"
#include "osi/allocator.h"
#include "cfg_cli.h"
#include "btc_ble_mesh_generic_model.h"
#include "esp_ble_mesh_generic_model_api.h"
static inline void btc_ble_mesh_cb_to_app(esp_ble_mesh_generic_client_cb_event_t event,
esp_ble_mesh_generic_client_cb_param_t *param)
#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_t btc_mesh_cb = (esp_ble_mesh_generic_client_cb_t)btc_profile_cb_get(BTC_PID_GENERIC_CLIENT);
if (btc_mesh_cb) {
btc_mesh_cb(event, 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);
if (btc_ble_mesh_cb) {
btc_ble_mesh_cb(event, param);
}
}
@ -35,45 +37,50 @@ 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;
u32_t opcode;
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));
memcpy(dst->generic_client_set_state.set_state, src->generic_client_set_state.set_state,
sizeof(esp_ble_mesh_generic_client_set_state_t));
opcode = src->generic_client_set_state.params->opcode;
switch (opcode) {
switch (src->generic_client_set_state.params->opcode) {
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET:
if (src->generic_client_set_state.set_state->user_property_set.property_value) {
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,
@ -86,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,
@ -98,42 +105,95 @@ 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;
}
}
static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
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) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
arg = (btc_ble_mesh_generic_client_args_t *)(msg->arg);
switch (msg->act) {
case BTC_BLE_MESH_ACT_GENERIC_CLIENT_GET_STATE:
if (arg->generic_client_get_state.params) {
bt_mesh_free(arg->generic_client_get_state.params);
}
if (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:
if (arg->generic_client_set_state.set_state) {
if (arg->generic_client_set_state.params) {
switch (arg->generic_client_set_state.params->opcode) {
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET:
bt_mesh_free_buf(arg->generic_client_set_state.set_state->user_property_set.property_value);
break;
case ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET:
bt_mesh_free_buf(arg->generic_client_set_state.set_state->admin_property_set.property_value);
break;
default:
break;
}
}
bt_mesh_free(arg->generic_client_set_state.set_state);
}
if (arg->generic_client_set_state.params) {
bt_mesh_free(arg->generic_client_set_state.params);
}
break;
default:
break;
}
}
static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
{
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;
u32_t opcode;
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 = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (!p_dest_data->params) {
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
}
switch (msg->act) {
case ESP_BLE_MESH_GENERIC_CLIENT_GET_STATE_EVT:
case ESP_BLE_MESH_GENERIC_CLIENT_SET_STATE_EVT:
case ESP_BLE_MESH_GENERIC_CLIENT_PUBLISH_EVT:
if (p_src_data->params) {
opcode = p_src_data->params->opcode;
switch (opcode) {
switch (p_src_data->params->opcode) {
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_GET:
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_STATUS:
if (p_src_data->status_cb.user_properties_status.property_ids) {
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,
@ -148,7 +208,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
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,
@ -162,7 +222,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
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,
@ -177,7 +237,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
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,
@ -191,7 +251,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
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,
@ -206,7 +266,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
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,
@ -220,7 +280,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
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,
@ -233,27 +293,18 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
}
}
case ESP_BLE_MESH_GENERIC_CLIENT_TIMEOUT_EVT:
if (p_src_data->params) {
p_dest_data->params = osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (p_dest_data->params) {
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
}
break;
default:
break;
}
}
static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
static void btc_ble_mesh_generic_client_free_req_data(btc_msg_t *msg)
{
esp_ble_mesh_generic_client_cb_param_t *arg = NULL;
u32_t opcode;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -264,8 +315,7 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
case ESP_BLE_MESH_GENERIC_CLIENT_SET_STATE_EVT:
case ESP_BLE_MESH_GENERIC_CLIENT_PUBLISH_EVT:
if (arg->params) {
opcode = arg->params->opcode;
switch (opcode) {
switch (arg->params->opcode) {
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_GET:
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_STATUS:
bt_mesh_free_buf(arg->status_cb.user_properties_status.property_ids);
@ -303,7 +353,7 @@ static void btc_ble_mesh_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:
@ -311,99 +361,54 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
}
}
void btc_ble_mesh_generic_client_arg_deep_free(btc_msg_t *msg)
{
btc_ble_mesh_generic_client_args_t *arg = NULL;
u32_t opcode = 0;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
arg = (btc_ble_mesh_generic_client_args_t *)(msg->arg);
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);
}
if (arg->generic_client_get_state.get_state) {
osi_free(arg->generic_client_get_state.get_state);
}
break;
case BTC_BLE_MESH_ACT_GENERIC_CLIENT_SET_STATE:
if (arg->generic_client_set_state.params) {
opcode = arg->generic_client_set_state.params->opcode;
osi_free(arg->generic_client_set_state.params);
}
if (arg->generic_client_set_state.set_state) {
if (opcode) {
switch (opcode) {
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET:
bt_mesh_free_buf(arg->generic_client_set_state.set_state->user_property_set.property_value);
break;
case ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET:
bt_mesh_free_buf(arg->generic_client_set_state.set_state->admin_property_set.property_value);
break;
default:
break;
}
}
osi_free(arg->generic_client_set_state.set_state);
}
break;
default:
break;
}
return;
}
static void btc_mesh_generic_client_callback(esp_ble_mesh_generic_client_cb_param_t *cb_params, uint8_t act)
static void btc_ble_mesh_generic_client_callback(esp_ble_mesh_generic_client_cb_param_t *cb_params, uint8_t act)
{
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)) {
return;
}
msg.sig = BTC_SIG_API_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_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_callback_generic_status_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;
}
switch (evt_type) {
case 0x00:
case BTC_BLE_MESH_EVT_GENERIC_CLIENT_GET_STATE:
act = ESP_BLE_MESH_GENERIC_CLIENT_GET_STATE_EVT;
break;
case 0x01:
case BTC_BLE_MESH_EVT_GENERIC_CLIENT_SET_STATE:
act = ESP_BLE_MESH_GENERIC_CLIENT_SET_STATE_EVT;
break;
case 0x02:
case BTC_BLE_MESH_EVT_GENERIC_CLIENT_PUBLISH:
act = ESP_BLE_MESH_GENERIC_CLIENT_PUBLISH_EVT;
break;
case 0x03:
case BTC_BLE_MESH_EVT_GENERIC_CLIENT_TIMEOUT:
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,39 +420,43 @@ void bt_mesh_callback_generic_status_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_mesh_generic_client_callback(&cb_params, act);
btc_ble_mesh_generic_client_callback(&cb_params, act);
return;
}
void btc_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_callback_generic_status_to_btc(opcode, 0x02, 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;
}
void btc_mesh_generic_client_call_handler(btc_msg_t *msg)
void btc_ble_mesh_generic_client_call_handler(btc_msg_t *msg)
{
esp_ble_mesh_generic_client_cb_param_t generic_client_cb = {0};
esp_ble_mesh_client_common_param_t *params = NULL;
btc_ble_mesh_generic_client_args_t *arg = NULL;
struct bt_mesh_common_param common = {0};
bt_mesh_role_param_t role_param = {0};
esp_ble_mesh_generic_client_cb_param_t cb = {0};
bt_mesh_client_common_param_t common = {0};
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -456,12 +465,6 @@ void btc_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_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
return;
}
common.opcode = params->opcode;
common.model = (struct bt_mesh_model *)params->model;
common.ctx.net_idx = params->ctx.net_idx;
@ -470,27 +473,18 @@ void btc_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;
generic_client_cb.params = arg->generic_client_get_state.params;
generic_client_cb.error_code =
bt_mesh_generic_client_get_state(&common,
(void *)arg->generic_client_get_state.get_state,
(void *)&generic_client_cb.status_cb);
if (generic_client_cb.error_code) {
cb.params = arg->generic_client_get_state.params;
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_mesh_generic_client_callback(&generic_client_cb,
ESP_BLE_MESH_GENERIC_CLIENT_GET_STATE_EVT);
btc_ble_mesh_generic_client_callback(&cb, ESP_BLE_MESH_GENERIC_CLIENT_GET_STATE_EVT);
}
break;
}
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_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
return;
}
common.opcode = params->opcode;
common.model = (struct bt_mesh_model *)params->model;
common.ctx.net_idx = params->ctx.net_idx;
@ -499,16 +493,13 @@ void btc_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;
generic_client_cb.params = arg->generic_client_set_state.params;
generic_client_cb.error_code =
bt_mesh_generic_client_set_state(&common,
(void *)arg->generic_client_set_state.set_state,
(void *)&generic_client_cb.status_cb);
if (generic_client_cb.error_code) {
cb.params = arg->generic_client_set_state.params;
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_mesh_generic_client_callback(&generic_client_cb,
ESP_BLE_MESH_GENERIC_CLIENT_SET_STATE_EVT);
btc_ble_mesh_generic_client_callback(&cb, ESP_BLE_MESH_GENERIC_CLIENT_SET_STATE_EVT);
}
break;
}
@ -517,24 +508,259 @@ void btc_mesh_generic_client_call_handler(btc_msg_t *msg)
}
btc_ble_mesh_generic_client_arg_deep_free(msg);
return;
}
void btc_mesh_generic_client_cb_handler(btc_msg_t *msg)
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;
}
param = (esp_ble_mesh_generic_client_cb_param_t *)(msg->arg);
if (msg->act < ESP_BLE_MESH_GENERIC_CLIENT_EVT_MAX) {
btc_ble_mesh_cb_to_app(msg->act, param);
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_free_req_data(msg);
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)
{
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);
if (btc_ble_mesh_cb) {
btc_ble_mesh_cb(event, param);
}
}
static void btc_ble_mesh_generic_server_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
{
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;
uint16_t length = 0U;
if (!msg || !p_src_data || !p_dest_data) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (msg->act) {
case ESP_BLE_MESH_GENERIC_SERVER_STATE_CHANGE_EVT:
switch (p_src_data->ctx.recv_op) {
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET:
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET_UNACK:
if (p_src_data->value.state_change.user_property_set.value) {
length = p_src_data->value.state_change.user_property_set.value->len;
p_dest_data->value.state_change.user_property_set.value = bt_mesh_alloc_buf(length);
if (p_dest_data->value.state_change.user_property_set.value == NULL) {
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.state_change.user_property_set.value,
p_src_data->value.state_change.user_property_set.value->data,
p_src_data->value.state_change.user_property_set.value->len);
}
break;
case ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET:
case ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET_UNACK:
if (p_src_data->value.state_change.admin_property_set.value) {
length = p_src_data->value.state_change.admin_property_set.value->len;
p_dest_data->value.state_change.admin_property_set.value = bt_mesh_alloc_buf(length);
if (p_dest_data->value.state_change.admin_property_set.value == NULL) {
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.state_change.admin_property_set.value,
p_src_data->value.state_change.admin_property_set.value->data,
p_src_data->value.state_change.admin_property_set.value->len);
}
break;
default:
break;
}
break;
case ESP_BLE_MESH_GENERIC_SERVER_RECV_SET_MSG_EVT:
switch (p_src_data->ctx.recv_op) {
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET:
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET_UNACK:
if (p_src_data->value.set.user_property.property_value) {
length = p_src_data->value.set.user_property.property_value->len;
p_dest_data->value.set.user_property.property_value = bt_mesh_alloc_buf(length);
if (p_dest_data->value.set.user_property.property_value == NULL) {
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.set.user_property.property_value,
p_src_data->value.set.user_property.property_value->data,
p_src_data->value.set.user_property.property_value->len);
}
break;
case ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET:
case ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET_UNACK:
if (p_src_data->value.set.admin_property.property_value) {
length = p_src_data->value.set.admin_property.property_value->len;
p_dest_data->value.set.admin_property.property_value = bt_mesh_alloc_buf(length);
if (p_dest_data->value.set.admin_property.property_value == NULL) {
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.set.admin_property.property_value,
p_src_data->value.set.admin_property.property_value->data,
p_src_data->value.set.admin_property.property_value->len);
}
break;
default:
break;
}
break;
default:
break;
}
}
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) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
arg = (esp_ble_mesh_generic_server_cb_param_t *)(msg->arg);
switch (msg->act) {
case ESP_BLE_MESH_GENERIC_SERVER_STATE_CHANGE_EVT:
switch (arg->ctx.recv_op) {
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET:
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET_UNACK:
bt_mesh_free_buf(arg->value.state_change.user_property_set.value);
break;
case ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET:
case ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET_UNACK:
bt_mesh_free_buf(arg->value.state_change.admin_property_set.value);
break;
default:
break;
}
break;
case ESP_BLE_MESH_GENERIC_SERVER_RECV_SET_MSG_EVT:
switch (arg->ctx.recv_op) {
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET:
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET_UNACK:
bt_mesh_free_buf(arg->value.set.user_property.property_value);
break;
case ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET:
case ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET_UNACK:
bt_mesh_free_buf(arg->value.set.admin_property.property_value);
break;
default:
break;
}
break;
default:
break;
}
}
static void btc_ble_mesh_generic_server_callback(esp_ble_mesh_generic_server_cb_param_t *cb_params, uint8_t act)
{
btc_msg_t msg = {0};
BT_DBG("%s", __func__);
/* If corresponding callback is not registered, event will not be posted. */
if (!btc_profile_cb_get(BTC_PID_GENERIC_SERVER)) {
return;
}
msg.sig = BTC_SIG_API_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);
}
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};
uint8_t act = 0U;
if (model == NULL || ctx == NULL) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (evt_type) {
case BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE:
act = ESP_BLE_MESH_GENERIC_SERVER_STATE_CHANGE_EVT;
break;
case BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_GET_MSG:
act = ESP_BLE_MESH_GENERIC_SERVER_RECV_GET_MSG_EVT;
break;
case BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_SET_MSG:
act = ESP_BLE_MESH_GENERIC_SERVER_RECV_SET_MSG_EVT;
break;
default:
BT_ERR("Unknown Generic Server event type %d", evt_type);
return;
}
cb_params.model = (esp_ble_mesh_model_t *)model;
cb_params.ctx.net_idx = ctx->net_idx;
cb_params.ctx.app_idx = ctx->app_idx;
cb_params.ctx.addr = ctx->addr;
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) {
memcpy(&cb_params.value, val, MIN(len, sizeof(cb_params.value)));
}
btc_ble_mesh_generic_server_callback(&cb_params, act);
return;
}
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) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
param = (esp_ble_mesh_generic_server_cb_param_t *)(msg->arg);
if (msg->act < ESP_BLE_MESH_GENERIC_SERVER_EVT_MAX) {
btc_ble_mesh_generic_server_cb_to_app(msg->act, param);
} else {
BT_ERR("%s, Unknown act %d", __func__, msg->act);
}
btc_ble_mesh_generic_server_free_req_data(msg);
return;
}
#endif /* CONFIG_BLE_MESH_GENERIC_SERVER */

View File

@ -15,34 +15,22 @@
#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_mesh_cb = (esp_ble_mesh_health_client_cb_t)btc_profile_cb_get(BTC_PID_HEALTH_CLIENT);
if (btc_mesh_cb) {
btc_mesh_cb(event, param);
}
}
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_t btc_mesh_cb = (esp_ble_mesh_health_server_cb_t)btc_profile_cb_get(BTC_PID_HEALTH_SERVER);
if (btc_mesh_cb) {
btc_mesh_cb(event, 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);
if (btc_ble_mesh_cb) {
btc_ble_mesh_cb(event, param);
}
}
@ -52,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;
}
}
@ -94,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;
}
@ -103,82 +98,58 @@ 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:
break;
}
return;
}
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__);
return;
}
switch (msg->act) {
case BTC_BLE_MESH_ACT_HEALTH_SERVER_FAULT_UPDATE:
break;
default:
break;
}
}
static void btc_ble_mesh_health_server_arg_deep_free(btc_msg_t *msg)
{
if (!msg) {
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
switch (msg->act) {
case BTC_BLE_MESH_ACT_HEALTH_SERVER_FAULT_UPDATE:
break;
default:
break;
}
}
static void btc_ble_mesh_health_client_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
{
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;
u32_t opcode;
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 = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (!p_dest_data->params) {
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
}
switch (msg->act) {
case ESP_BLE_MESH_HEALTH_CLIENT_GET_STATE_EVT:
case ESP_BLE_MESH_HEALTH_CLIENT_SET_STATE_EVT:
case ESP_BLE_MESH_HEALTH_CLIENT_PUBLISH_EVT:
if (p_src_data->params) {
opcode = p_src_data->params->opcode;
switch (opcode) {
switch (p_src_data->params->opcode) {
case OP_HEALTH_CURRENT_STATUS:
if (p_src_data->status_cb.current_status.fault_array) {
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,
@ -194,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,
@ -207,14 +178,6 @@ static void btc_ble_mesh_health_client_copy_req_data(btc_msg_t *msg, void *p_des
}
}
case ESP_BLE_MESH_HEALTH_CLIENT_TIMEOUT_EVT:
if (p_src_data->params) {
p_dest_data->params = osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (p_dest_data->params) {
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
}
break;
default:
break;
@ -224,10 +187,9 @@ static void btc_ble_mesh_health_client_copy_req_data(btc_msg_t *msg, void *p_des
static void btc_ble_mesh_health_client_free_req_data(btc_msg_t *msg)
{
esp_ble_mesh_health_client_cb_param_t *arg = NULL;
u32_t opcode;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -238,8 +200,7 @@ static void btc_ble_mesh_health_client_free_req_data(btc_msg_t *msg)
case ESP_BLE_MESH_HEALTH_CLIENT_SET_STATE_EVT:
case ESP_BLE_MESH_HEALTH_CLIENT_PUBLISH_EVT:
if (arg->params) {
opcode = arg->params->opcode;
switch (opcode) {
switch (arg->params->opcode) {
case OP_HEALTH_CURRENT_STATUS:
bt_mesh_free_buf(arg->status_cb.current_status.fault_array);
break;
@ -255,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:
@ -263,180 +224,54 @@ static void btc_ble_mesh_health_client_free_req_data(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__);
return;
}
switch (msg->act) {
case ESP_BLE_MESH_HEALTH_SERVER_FAULT_UPDATE_COMPLETE_EVT:
break;
default:
break;
}
}
static void btc_ble_mesh_health_server_free_req_data(btc_msg_t *msg)
{
if (!msg) {
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
switch (msg->act) {
case ESP_BLE_MESH_HEALTH_SERVER_FAULT_UPDATE_COMPLETE_EVT:
break;
default:
break;
}
}
static void btc_mesh_health_client_callback(esp_ble_mesh_health_client_cb_param_t *cb_params, uint8_t act)
static void btc_ble_mesh_health_client_callback(esp_ble_mesh_health_client_cb_param_t *cb_params, uint8_t act)
{
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)) {
return;
}
msg.sig = BTC_SIG_API_CB;
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);
}
static void btc_mesh_health_server_callback(esp_ble_mesh_health_server_cb_param_t *cb_params, uint8_t act)
{
btc_msg_t msg = {0};
LOG_DEBUG("%s", __func__);
msg.sig = BTC_SIG_API_CB;
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);
}
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_state,
esp_ble_mesh_health_client_cb_param_t *client_cb)
{
struct bt_mesh_msg_ctx ctx = {0};
if (!params || !client_cb) {
LOG_ERROR("%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;
health_msg_timeout = params->msg_timeout;
switch (params->opcode) {
case ESP_BLE_MESH_MODEL_OP_ATTENTION_GET:
return (client_cb->error_code = bt_mesh_health_attention_get(&ctx));
case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_GET:
return (client_cb->error_code = bt_mesh_health_period_get(&ctx));
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET:
return (client_cb->error_code = bt_mesh_health_fault_get(&ctx, get_state->fault_get.company_id));
default:
BT_WARN("%s, invalid opcode 0x%x", __func__, params->opcode);
return (client_cb->error_code = -EINVAL);
}
return 0;
}
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_state,
esp_ble_mesh_health_client_cb_param_t *client_cb)
{
struct bt_mesh_msg_ctx ctx = {0};
if (!params || !set_state || !client_cb) {
LOG_ERROR("%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;
health_msg_timeout = params->msg_timeout;
switch (params->opcode) {
case ESP_BLE_MESH_MODEL_OP_ATTENTION_SET:
return (client_cb->error_code =
bt_mesh_health_attention_set(&ctx, set_state->attention_set.attention, true));
case ESP_BLE_MESH_MODEL_OP_ATTENTION_SET_UNACK:
return (client_cb->error_code =
bt_mesh_health_attention_set(&ctx, set_state->attention_set.attention, false));
case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET:
return (client_cb->error_code =
bt_mesh_health_period_set(&ctx, set_state->period_set.fast_period_divisor, true));
case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET_UNACK:
return (client_cb->error_code =
bt_mesh_health_period_set(&ctx, set_state->period_set.fast_period_divisor, false));
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST:
return (client_cb->error_code =
bt_mesh_health_fault_test(&ctx, set_state->fault_test.company_id, set_state->fault_test.test_id, true));
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST_UNACK:
return (client_cb->error_code =
bt_mesh_health_fault_test(&ctx, set_state->fault_test.company_id, set_state->fault_test.test_id, false));
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR:
return (client_cb->error_code =
bt_mesh_health_fault_clear(&ctx, set_state->fault_clear.company_id, true));
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR_UNACK:
return (client_cb->error_code =
bt_mesh_health_fault_clear(&ctx, set_state->fault_clear.company_id, false));
default:
BT_WARN("%s, Invalid opcode 0x%x", __func__, params->opcode);
return (client_cb->error_code = -EINVAL);
}
return 0;
}
void bt_mesh_callback_health_status_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;
}
switch (evt_type) {
case 0x00:
case BTC_BLE_MESH_EVT_HEALTH_CLIENT_GET_STATE:
act = ESP_BLE_MESH_HEALTH_CLIENT_GET_STATE_EVT;
break;
case 0x01:
case BTC_BLE_MESH_EVT_HEALTH_CLIENT_SET_STATE:
act = ESP_BLE_MESH_HEALTH_CLIENT_SET_STATE_EVT;
break;
case 0x02:
case BTC_BLE_MESH_EVT_HEALTH_CLIENT_PUBLISH:
act = ESP_BLE_MESH_HEALTH_CLIENT_PUBLISH_EVT;
break;
case 0x03:
case BTC_BLE_MESH_EVT_HEALTH_CLIENT_TIMEOUT:
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;
}
@ -448,37 +283,126 @@ void bt_mesh_callback_health_status_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_mesh_health_client_callback(&cb_params, act);
btc_ble_mesh_health_client_callback(&cb_params, act);
return;
}
void btc_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_callback_health_status_to_btc(opcode, 0x02, 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;
}
void btc_mesh_health_client_call_handler(btc_msg_t *msg)
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)
{
bt_mesh_client_common_param_t param = {0};
if (params == NULL) {
BT_ERR("%s, Invalid parameter", __func__);
return -EINVAL;
}
if (params->opcode == ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET && get == NULL) {
BT_ERR("Invalid Health Get");
return -EINVAL;
}
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 (param.opcode) {
case ESP_BLE_MESH_MODEL_OP_ATTENTION_GET:
return bt_mesh_health_attention_get(&param);
case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_GET:
return bt_mesh_health_period_get(&param);
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET:
return bt_mesh_health_fault_get(&param, get->fault_get.company_id);
default:
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)
{
bt_mesh_client_common_param_t param = {0};
if (params == NULL || set == NULL) {
BT_ERR("%s, Invalid parameter", __func__);
return -EINVAL;
}
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 (param.opcode) {
case ESP_BLE_MESH_MODEL_OP_ATTENTION_SET:
return bt_mesh_health_attention_set(&param, set->attention_set.attention, true);
case ESP_BLE_MESH_MODEL_OP_ATTENTION_SET_UNACK:
return bt_mesh_health_attention_set(&param, set->attention_set.attention, false);
case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET:
return bt_mesh_health_period_set(&param, set->period_set.fast_period_divisor, true);
case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET_UNACK:
return bt_mesh_health_period_set(&param, set->period_set.fast_period_divisor, false);
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST:
return bt_mesh_health_fault_test(&param, set->fault_test.company_id, set->fault_test.test_id, true);
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST_UNACK:
return bt_mesh_health_fault_test(&param, set->fault_test.company_id, set->fault_test.test_id, false);
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR:
return bt_mesh_health_fault_clear(&param, set->fault_clear.company_id, true);
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR_UNACK:
return bt_mesh_health_fault_clear(&param, set->fault_clear.company_id, false);
default:
BT_ERR("Invalid Health Set opcode 0x%04x", param.opcode);
return -EINVAL;
}
return 0;
}
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 health_client_cb = {0};
bt_mesh_role_param_t role_param = {0};
esp_ble_mesh_health_client_cb_param_t cb = {0};
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -486,36 +410,22 @@ void btc_mesh_health_client_call_handler(btc_msg_t *msg)
switch (msg->act) {
case BTC_BLE_MESH_ACT_HEALTH_CLIENT_GET_STATE: {
health_client_cb.params = arg->health_client_get_state.params;
role_param.model = (struct bt_mesh_model *)health_client_cb.params->model;
role_param.role = health_client_cb.params->msg_role;
if (bt_mesh_set_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
return;
}
btc_ble_mesh_health_client_get_state(arg->health_client_get_state.params,
arg->health_client_get_state.get_state,
&health_client_cb);
if (health_client_cb.error_code) {
cb.params = arg->health_client_get_state.params;
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_mesh_health_client_callback(&health_client_cb, ESP_BLE_MESH_HEALTH_CLIENT_GET_STATE_EVT);
btc_ble_mesh_health_client_callback(&cb, ESP_BLE_MESH_HEALTH_CLIENT_GET_STATE_EVT);
}
break;
}
case BTC_BLE_MESH_ACT_HEALTH_CLIENT_SET_STATE: {
health_client_cb.params = arg->health_client_set_state.params;
role_param.model = (struct bt_mesh_model *)health_client_cb.params->model;
role_param.role = health_client_cb.params->msg_role;
if (bt_mesh_set_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
return;
}
btc_ble_mesh_health_client_set_state(arg->health_client_set_state.params,
arg->health_client_set_state.set_state,
&health_client_cb);
if (health_client_cb.error_code) {
cb.params = arg->health_client_set_state.params;
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_mesh_health_client_callback(&health_client_cb, ESP_BLE_MESH_HEALTH_CLIENT_SET_STATE_EVT);
btc_ble_mesh_health_client_callback(&cb, ESP_BLE_MESH_HEALTH_CLIENT_SET_STATE_EVT);
}
break;
}
@ -527,12 +437,12 @@ void btc_mesh_health_client_call_handler(btc_msg_t *msg)
return;
}
void btc_mesh_health_client_cb_handler(btc_msg_t *msg)
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;
}
@ -541,42 +451,142 @@ void btc_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;
}
void btc_mesh_health_server_call_handler(btc_msg_t *msg)
#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 health_server_cb = {0};
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);
if (btc_ble_mesh_cb) {
btc_ble_mesh_cb(event, param);
}
}
void btc_ble_mesh_health_server_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
{
if (!msg) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (msg->act) {
case BTC_BLE_MESH_ACT_HEALTH_SERVER_FAULT_UPDATE:
break;
default:
break;
}
}
static void btc_ble_mesh_health_server_arg_deep_free(btc_msg_t *msg)
{
if (!msg) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (msg->act) {
case BTC_BLE_MESH_ACT_HEALTH_SERVER_FAULT_UPDATE:
break;
default:
break;
}
}
static void btc_ble_mesh_health_server_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
{
if (!msg) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (msg->act) {
case ESP_BLE_MESH_HEALTH_SERVER_FAULT_UPDATE_COMP_EVT:
break;
default:
break;
}
}
static void btc_ble_mesh_health_server_free_req_data(btc_msg_t *msg)
{
if (!msg) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (msg->act) {
case ESP_BLE_MESH_HEALTH_SERVER_FAULT_UPDATE_COMP_EVT:
break;
default:
break;
}
}
static void btc_ble_mesh_health_server_callback(esp_ble_mesh_health_server_cb_param_t *cb_params, uint8_t act)
{
btc_msg_t msg = {0};
BT_DBG("%s", __func__);
/* If corresponding callback is not registered, event will not be posted. */
if (!btc_profile_cb_get(BTC_PID_HEALTH_SERVER)) {
return;
}
msg.sig = BTC_SIG_API_CB;
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);
}
void btc_ble_mesh_health_server_call_handler(btc_msg_t *msg)
{
esp_ble_mesh_health_server_cb_param_t param = {0};
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;
}
arg = (btc_ble_mesh_health_server_args_t *)(msg->arg);
switch (msg->act) {
case BTC_BLE_MESH_ACT_HEALTH_SERVER_FAULT_UPDATE: {
health_server_cb.error_code = bt_mesh_fault_update((struct bt_mesh_elem *)arg->fault_update.element);
btc_mesh_health_server_callback(&health_server_cb, ESP_BLE_MESH_HEALTH_SERVER_FAULT_UPDATE_COMPLETE_EVT);
}
case BTC_BLE_MESH_ACT_HEALTH_SERVER_FAULT_UPDATE:
param.fault_update_comp.element = arg->health_fault_update.element;
param.fault_update_comp.error_code =
bt_mesh_fault_update((struct bt_mesh_elem *)arg->health_fault_update.element);
btc_ble_mesh_health_server_callback(&param, ESP_BLE_MESH_HEALTH_SERVER_FAULT_UPDATE_COMP_EVT);
break;
default:
break;
}
btc_ble_mesh_health_server_arg_deep_free(msg);
return;
}
void btc_mesh_health_server_cb_handler(btc_msg_t *msg)
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;
}
@ -585,8 +595,51 @@ void btc_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, uint16_t company_id)
{
esp_ble_mesh_health_server_cb_param_t param = {0};
param.fault_clear.model = (esp_ble_mesh_model_t *)model;
param.fault_clear.company_id = company_id;
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,
uint8_t test_id, uint16_t company_id)
{
esp_ble_mesh_health_server_cb_param_t param = {0};
param.fault_test.model = (esp_ble_mesh_model_t *)model;
param.fault_test.test_id = test_id;
param.fault_test.company_id = company_id;
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, uint8_t time)
{
esp_ble_mesh_health_server_cb_param_t param = {0};
param.attention_on.model = (esp_ble_mesh_model_t *)model;
param.attention_on.time = time;
btc_ble_mesh_health_server_callback(&param, ESP_BLE_MESH_HEALTH_SERVER_ATTENTION_ON_EVT);
}
void btc_ble_mesh_health_server_attention_off(struct bt_mesh_model *model)
{
esp_ble_mesh_health_server_cb_param_t param = {0};
param.attention_off.model = (esp_ble_mesh_model_t *)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,84 +15,134 @@
#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"
static inline void btc_ble_mesh_cb_to_app(esp_ble_mesh_light_client_cb_event_t event,
esp_ble_mesh_light_client_cb_param_t *param)
#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_t btc_mesh_cb = (esp_ble_mesh_light_client_cb_t)btc_profile_cb_get(BTC_PID_LIGHT_CLIENT);
if (btc_mesh_cb) {
btc_mesh_cb(event, 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);
if (btc_ble_mesh_cb) {
btc_ble_mesh_cb(event, param);
}
}
void btc_ble_mesh_light_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
void btc_ble_mesh_lighting_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
{
btc_ble_mesh_light_client_args_t *dst = (btc_ble_mesh_light_client_args_t *)p_dest;
btc_ble_mesh_light_client_args_t *src = (btc_ble_mesh_light_client_args_t *)p_src;
btc_ble_mesh_lighting_client_args_t *dst = (btc_ble_mesh_lighting_client_args_t *)p_dest;
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_LIGHT_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) {
case BTC_BLE_MESH_ACT_LIGHTING_CLIENT_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_LIGHT_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));
case BTC_BLE_MESH_ACT_LIGHTING_CLIENT_SET_STATE: {
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;
}
}
static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
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) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
arg = (btc_ble_mesh_lighting_client_args_t *)(msg->arg);
switch (msg->act) {
case BTC_BLE_MESH_ACT_LIGHTING_CLIENT_GET_STATE:
if (arg->light_client_get_state.params) {
bt_mesh_free(arg->light_client_get_state.params);
}
if (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) {
bt_mesh_free(arg->light_client_set_state.params);
}
if (arg->light_client_set_state.set_state) {
bt_mesh_free(arg->light_client_set_state.set_state);
}
break;
default:
break;
}
}
static void btc_ble_mesh_lighting_client_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
{
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;
u32_t opcode;
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 = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (!p_dest_data->params) {
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
}
switch (msg->act) {
case ESP_BLE_MESH_LIGHT_CLIENT_GET_STATE_EVT:
case ESP_BLE_MESH_LIGHT_CLIENT_SET_STATE_EVT:
case ESP_BLE_MESH_LIGHT_CLIENT_PUBLISH_EVT:
if (p_src_data->params) {
opcode = p_src_data->params->opcode;
switch (opcode) {
switch (p_src_data->params->opcode) {
case ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_GET:
case ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET:
case ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_STATUS:
@ -100,7 +150,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
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,
@ -113,27 +163,18 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
}
}
case ESP_BLE_MESH_LIGHT_CLIENT_TIMEOUT_EVT:
if (p_src_data->params) {
p_dest_data->params = osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (p_dest_data->params) {
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
}
break;
default:
break;
}
}
static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
static void btc_ble_mesh_lighting_client_free_req_data(btc_msg_t *msg)
{
esp_ble_mesh_light_client_cb_param_t *arg = NULL;
u32_t opcode;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -144,8 +185,7 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
case ESP_BLE_MESH_LIGHT_CLIENT_SET_STATE_EVT:
case ESP_BLE_MESH_LIGHT_CLIENT_PUBLISH_EVT:
if (arg->params) {
opcode = arg->params->opcode;
switch (opcode) {
switch (arg->params->opcode) {
case ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_GET:
case ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET:
case ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_STATUS:
@ -157,7 +197,7 @@ static void btc_ble_mesh_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:
@ -165,85 +205,54 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
}
}
void btc_ble_mesh_light_client_arg_deep_free(btc_msg_t *msg)
{
btc_ble_mesh_light_client_args_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
arg = (btc_ble_mesh_light_client_args_t *)(msg->arg);
switch (msg->act) {
case BTC_BLE_MESH_ACT_LIGHT_CLIENT_GET_STATE:
if (arg->light_client_get_state.params) {
osi_free(arg->light_client_get_state.params);
}
if (arg->light_client_get_state.get_state) {
osi_free(arg->light_client_get_state.get_state);
}
break;
case BTC_BLE_MESH_ACT_LIGHT_CLIENT_SET_STATE:
if (arg->light_client_set_state.params) {
osi_free(arg->light_client_set_state.params);
}
if (arg->light_client_set_state.set_state) {
osi_free(arg->light_client_set_state.set_state);
}
break;
default:
break;
}
return;
}
static void btc_mesh_light_client_callback(esp_ble_mesh_light_client_cb_param_t *cb_params, uint8_t act)
static void btc_ble_mesh_lighting_client_callback(esp_ble_mesh_light_client_cb_param_t *cb_params, uint8_t act)
{
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)) {
return;
}
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_LIGHT_CLIENT;
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_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_callback_light_status_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;
}
switch (evt_type) {
case 0x00:
case BTC_BLE_MESH_EVT_LIGHTING_CLIENT_GET_STATE:
act = ESP_BLE_MESH_LIGHT_CLIENT_GET_STATE_EVT;
break;
case 0x01:
case BTC_BLE_MESH_EVT_LIGHTING_CLIENT_SET_STATE:
act = ESP_BLE_MESH_LIGHT_CLIENT_SET_STATE_EVT;
break;
case 0x02:
case BTC_BLE_MESH_EVT_LIGHTING_CLIENT_PUBLISH:
act = ESP_BLE_MESH_LIGHT_CLIENT_PUBLISH_EVT;
break;
case 0x03:
case BTC_BLE_MESH_EVT_LIGHTING_CLIENT_TIMEOUT:
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;
}
@ -255,53 +264,51 @@ void bt_mesh_callback_light_status_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_mesh_light_client_callback(&cb_params, act);
btc_ble_mesh_lighting_client_callback(&cb_params, act);
return;
}
void btc_mesh_light_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_callback_light_status_to_btc(opcode, 0x02, 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;
}
void btc_mesh_light_client_call_handler(btc_msg_t *msg)
void btc_ble_mesh_lighting_client_call_handler(btc_msg_t *msg)
{
esp_ble_mesh_light_client_cb_param_t light_client_cb = {0};
esp_ble_mesh_client_common_param_t *params = NULL;
btc_ble_mesh_light_client_args_t *arg = NULL;
struct bt_mesh_common_param common = {0};
bt_mesh_role_param_t role_param = {0};
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};
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
arg = (btc_ble_mesh_light_client_args_t *)(msg->arg);
arg = (btc_ble_mesh_lighting_client_args_t *)(msg->arg);
switch (msg->act) {
case BTC_BLE_MESH_ACT_LIGHT_CLIENT_GET_STATE: {
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_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
return;
}
common.opcode = params->opcode;
common.model = (struct bt_mesh_model *)params->model;
common.ctx.net_idx = params->ctx.net_idx;
@ -310,27 +317,18 @@ void btc_mesh_light_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;
light_client_cb.params = arg->light_client_get_state.params;
light_client_cb.error_code =
bt_mesh_light_client_get_state(&common,
(void *)arg->light_client_get_state.get_state,
(void *)&light_client_cb.status_cb);
if (light_client_cb.error_code) {
cb.params = arg->light_client_get_state.params;
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_mesh_light_client_callback(&light_client_cb,
ESP_BLE_MESH_LIGHT_CLIENT_GET_STATE_EVT);
btc_ble_mesh_lighting_client_callback(&cb, ESP_BLE_MESH_LIGHT_CLIENT_GET_STATE_EVT);
}
break;
}
case BTC_BLE_MESH_ACT_LIGHT_CLIENT_SET_STATE: {
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_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
return;
}
common.opcode = params->opcode;
common.model = (struct bt_mesh_model *)params->model;
common.ctx.net_idx = params->ctx.net_idx;
@ -339,16 +337,13 @@ void btc_mesh_light_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;
light_client_cb.params = arg->light_client_set_state.params;
light_client_cb.error_code =
bt_mesh_light_client_set_state(&common,
(void *)arg->light_client_set_state.set_state,
(void *)&light_client_cb.status_cb);
if (light_client_cb.error_code) {
cb.params = arg->light_client_set_state.params;
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_mesh_light_client_callback(&light_client_cb,
ESP_BLE_MESH_LIGHT_CLIENT_SET_STATE_EVT);
btc_ble_mesh_lighting_client_callback(&cb, ESP_BLE_MESH_LIGHT_CLIENT_SET_STATE_EVT);
}
break;
}
@ -356,26 +351,231 @@ void btc_mesh_light_client_call_handler(btc_msg_t *msg)
break;
}
btc_ble_mesh_light_client_arg_deep_free(msg);
btc_ble_mesh_lighting_client_arg_deep_free(msg);
return;
}
void btc_mesh_light_client_cb_handler(btc_msg_t *msg)
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;
}
param = (esp_ble_mesh_light_client_cb_param_t *)(msg->arg);
if (msg->act < ESP_BLE_MESH_LIGHT_CLIENT_EVT_MAX) {
btc_ble_mesh_cb_to_app(msg->act, param);
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_free_req_data(msg);
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)
{
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);
if (btc_ble_mesh_cb) {
btc_ble_mesh_cb(event, param);
}
}
static void btc_ble_mesh_lighting_server_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
{
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;
uint16_t length = 0U;
if (!msg || !p_src_data || !p_dest_data) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (msg->act) {
case ESP_BLE_MESH_LIGHTING_SERVER_STATE_CHANGE_EVT:
if (p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET ||
p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET_UNACK) {
if (p_src_data->value.state_change.lc_property_set.property_value) {
length = p_src_data->value.state_change.lc_property_set.property_value->len;
p_dest_data->value.state_change.lc_property_set.property_value = bt_mesh_alloc_buf(length);
if (p_dest_data->value.state_change.lc_property_set.property_value == NULL) {
BT_ERR("%s, 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,
p_src_data->value.state_change.lc_property_set.property_value->data,
p_src_data->value.state_change.lc_property_set.property_value->len);
}
}
break;
case ESP_BLE_MESH_LIGHTING_SERVER_RECV_SET_MSG_EVT:
if (p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET ||
p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET_UNACK) {
if (p_src_data->value.set.lc_property.property_value) {
length = p_src_data->value.set.lc_property.property_value->len;
p_dest_data->value.set.lc_property.property_value = bt_mesh_alloc_buf(length);
if (p_dest_data->value.set.lc_property.property_value == NULL) {
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.set.lc_property.property_value,
p_src_data->value.set.lc_property.property_value->data,
p_src_data->value.set.lc_property.property_value->len);
}
}
break;
case ESP_BLE_MESH_LIGHTING_SERVER_RECV_STATUS_MSG_EVT:
if (p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_STATUS) {
if (p_src_data->value.status.sensor_status.data) {
length = p_src_data->value.status.sensor_status.data->len;
p_dest_data->value.status.sensor_status.data = bt_mesh_alloc_buf(length);
if (p_dest_data->value.status.sensor_status.data == NULL) {
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.status.sensor_status.data,
p_src_data->value.status.sensor_status.data->data,
p_src_data->value.status.sensor_status.data->len);
}
}
break;
default:
break;
}
}
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) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
arg = (esp_ble_mesh_lighting_server_cb_param_t *)(msg->arg);
switch (msg->act) {
case ESP_BLE_MESH_LIGHTING_SERVER_STATE_CHANGE_EVT:
if (arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET ||
arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET_UNACK) {
bt_mesh_free_buf(arg->value.state_change.lc_property_set.property_value);
}
break;
case ESP_BLE_MESH_LIGHTING_SERVER_RECV_SET_MSG_EVT:
if (arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET ||
arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET_UNACK) {
bt_mesh_free_buf(arg->value.set.lc_property.property_value);
}
break;
case ESP_BLE_MESH_LIGHTING_SERVER_RECV_STATUS_MSG_EVT:
if (arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_STATUS) {
bt_mesh_free_buf(arg->value.status.sensor_status.data);
}
break;
default:
break;
}
}
static void btc_ble_mesh_lighting_server_callback(esp_ble_mesh_lighting_server_cb_param_t *cb_params, uint8_t act)
{
btc_msg_t msg = {0};
BT_DBG("%s", __func__);
/* If corresponding callback is not registered, event will not be posted. */
if (!btc_profile_cb_get(BTC_PID_LIGHTING_SERVER)) {
return;
}
msg.sig = BTC_SIG_API_CB;
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);
}
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};
uint8_t act = 0U;
if (model == NULL || ctx == NULL) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (evt_type) {
case BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE:
act = ESP_BLE_MESH_LIGHTING_SERVER_STATE_CHANGE_EVT;
break;
case BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_GET_MSG:
act = ESP_BLE_MESH_LIGHTING_SERVER_RECV_GET_MSG_EVT;
break;
case BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG:
act = ESP_BLE_MESH_LIGHTING_SERVER_RECV_SET_MSG_EVT;
break;
case BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_STATUS_MSG:
act = ESP_BLE_MESH_LIGHTING_SERVER_RECV_STATUS_MSG_EVT;
break;
default:
BT_ERR("Unknown Lighting server event type %d", evt_type);
return;
}
cb_params.model = (esp_ble_mesh_model_t *)model;
cb_params.ctx.net_idx = ctx->net_idx;
cb_params.ctx.app_idx = ctx->app_idx;
cb_params.ctx.addr = ctx->addr;
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) {
memcpy(&cb_params.value, val, MIN(len, sizeof(cb_params.value)));
}
btc_ble_mesh_lighting_server_callback(&cb_params, act);
return;
}
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) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
param = (esp_ble_mesh_lighting_server_cb_param_t *)(msg->arg);
if (msg->act < ESP_BLE_MESH_LIGHTING_SERVER_EVT_MAX) {
btc_ble_mesh_lighting_server_cb_to_app(msg->act, param);
} else {
BT_ERR("%s, Unknown 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,19 +15,21 @@
#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"
static inline void btc_ble_mesh_cb_to_app(esp_ble_mesh_sensor_client_cb_event_t event,
esp_ble_mesh_sensor_client_cb_param_t *param)
#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_t btc_mesh_cb = (esp_ble_mesh_sensor_client_cb_t)btc_profile_cb_get(BTC_PID_SENSOR_CLIENT);
if (btc_mesh_cb) {
btc_mesh_cb(event, 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);
if (btc_ble_mesh_cb) {
btc_ble_mesh_cb(event, param);
}
}
@ -35,32 +37,30 @@ 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;
u32_t opcode;
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));
memcpy(dst->sensor_client_get_state.get_state, src->sensor_client_get_state.get_state,
sizeof(esp_ble_mesh_sensor_client_get_state_t));
opcode = src->sensor_client_get_state.params->opcode;
switch (opcode) {
switch (src->sensor_client_get_state.params->opcode) {
case ESP_BLE_MESH_MODEL_OP_SENSOR_COLUMN_GET:
if (src->sensor_client_get_state.get_state->column_get.raw_value_x) {
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,
@ -73,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,
@ -84,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,
@ -96,27 +96,26 @@ 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));
memcpy(dst->sensor_client_set_state.set_state, src->sensor_client_set_state.set_state,
sizeof(esp_ble_mesh_sensor_client_set_state_t));
opcode = src->sensor_client_set_state.params->opcode;
switch (opcode) {
switch (src->sensor_client_set_state.params->opcode) {
case ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET:
if (src->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down) {
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,42 +173,111 @@ 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;
}
}
static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
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) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
arg = (btc_ble_mesh_sensor_client_args_t *)(msg->arg);
switch (msg->act) {
case BTC_BLE_MESH_ACT_SENSOR_CLIENT_GET_STATE:
if (arg->sensor_client_get_state.get_state) {
if (arg->sensor_client_get_state.params) {
switch (arg->sensor_client_get_state.params->opcode) {
case ESP_BLE_MESH_MODEL_OP_SENSOR_COLUMN_GET:
bt_mesh_free_buf(arg->sensor_client_get_state.get_state->column_get.raw_value_x);
break;
case ESP_BLE_MESH_MODEL_OP_SENSOR_SERIES_GET:
bt_mesh_free_buf(arg->sensor_client_get_state.get_state->series_get.raw_value_x1);
bt_mesh_free_buf(arg->sensor_client_get_state.get_state->series_get.raw_value_x2);
break;
default:
break;
}
}
bt_mesh_free(arg->sensor_client_get_state.get_state);
}
if (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:
if (arg->sensor_client_set_state.set_state) {
if (arg->sensor_client_set_state.params) {
switch (arg->sensor_client_set_state.params->opcode) {
case ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET:
bt_mesh_free_buf(arg->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down);
bt_mesh_free_buf(arg->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_up);
bt_mesh_free_buf(arg->sensor_client_set_state.set_state->cadence_set.fast_cadence_low);
bt_mesh_free_buf(arg->sensor_client_set_state.set_state->cadence_set.fast_cadence_high);
break;
case ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET:
bt_mesh_free_buf(arg->sensor_client_set_state.set_state->setting_set.sensor_setting_raw);
break;
default:
break;
}
}
bt_mesh_free(arg->sensor_client_set_state.set_state);
}
if (arg->sensor_client_set_state.params) {
bt_mesh_free(arg->sensor_client_set_state.params);
}
break;
default:
break;
}
}
static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
{
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;
u32_t opcode;
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 = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (!p_dest_data->params) {
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
}
switch (msg->act) {
case ESP_BLE_MESH_SENSOR_CLIENT_GET_STATE_EVT:
case ESP_BLE_MESH_SENSOR_CLIENT_SET_STATE_EVT:
case ESP_BLE_MESH_SENSOR_CLIENT_PUBLISH_EVT:
if (p_src_data->params) {
opcode = p_src_data->params->opcode;
switch (opcode) {
switch (p_src_data->params->opcode) {
case ESP_BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_GET:
case ESP_BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_STATUS:
if (p_src_data->status_cb.descriptor_status.descriptor) {
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,
@ -224,7 +292,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
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,
@ -238,7 +306,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
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,
@ -253,7 +321,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
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,
@ -267,7 +335,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
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,
@ -281,7 +349,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
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,
@ -295,7 +363,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
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,
@ -308,27 +376,18 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
}
}
case ESP_BLE_MESH_SENSOR_CLIENT_TIMEOUT_EVT:
if (p_src_data->params) {
p_dest_data->params = osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (p_dest_data->params) {
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
}
break;
default:
break;
}
}
static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
static void btc_ble_mesh_sensor_client_free_req_data(btc_msg_t *msg)
{
esp_ble_mesh_sensor_client_cb_param_t *arg = NULL;
u32_t opcode;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -339,8 +398,7 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
case ESP_BLE_MESH_SENSOR_CLIENT_SET_STATE_EVT:
case ESP_BLE_MESH_SENSOR_CLIENT_PUBLISH_EVT:
if (arg->params) {
opcode = arg->params->opcode;
switch (opcode) {
switch (arg->params->opcode) {
case ESP_BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_GET:
case ESP_BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_STATUS:
bt_mesh_free_buf(arg->status_cb.descriptor_status.descriptor);
@ -377,7 +435,7 @@ static void btc_ble_mesh_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:
@ -385,116 +443,54 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
}
}
void btc_ble_mesh_sensor_client_arg_deep_free(btc_msg_t *msg)
{
btc_ble_mesh_sensor_client_args_t *arg = NULL;
u32_t opcode = 0;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
arg = (btc_ble_mesh_sensor_client_args_t *)(msg->arg);
switch (msg->act) {
case BTC_BLE_MESH_ACT_SENSOR_CLIENT_GET_STATE:
if (arg->sensor_client_get_state.params) {
opcode = arg->sensor_client_get_state.params->opcode;
osi_free(arg->sensor_client_get_state.params);
}
if (arg->sensor_client_get_state.get_state) {
if (opcode) {
switch (opcode) {
case ESP_BLE_MESH_MODEL_OP_SENSOR_COLUMN_GET:
bt_mesh_free_buf(arg->sensor_client_get_state.get_state->column_get.raw_value_x);
break;
case ESP_BLE_MESH_MODEL_OP_SENSOR_SERIES_GET:
bt_mesh_free_buf(arg->sensor_client_get_state.get_state->series_get.raw_value_x1);
bt_mesh_free_buf(arg->sensor_client_get_state.get_state->series_get.raw_value_x2);
break;
default:
break;
}
}
osi_free(arg->sensor_client_get_state.get_state);
}
break;
case BTC_BLE_MESH_ACT_SENSOR_CLIENT_SET_STATE:
if (arg->sensor_client_set_state.params) {
opcode = arg->sensor_client_set_state.params->opcode;
osi_free(arg->sensor_client_set_state.params);
}
if (arg->sensor_client_set_state.set_state) {
if (opcode) {
switch (opcode) {
case ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET:
bt_mesh_free_buf(arg->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down);
bt_mesh_free_buf(arg->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_up);
bt_mesh_free_buf(arg->sensor_client_set_state.set_state->cadence_set.fast_cadence_low);
bt_mesh_free_buf(arg->sensor_client_set_state.set_state->cadence_set.fast_cadence_high);
break;
case ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET:
bt_mesh_free_buf(arg->sensor_client_set_state.set_state->setting_set.sensor_setting_raw);
break;
default:
break;
}
}
osi_free(arg->sensor_client_set_state.set_state);
}
break;
default:
break;
}
return;
}
static void btc_mesh_sensor_client_callback(esp_ble_mesh_sensor_client_cb_param_t *cb_params, uint8_t act)
static void btc_ble_mesh_sensor_client_callback(esp_ble_mesh_sensor_client_cb_param_t *cb_params, uint8_t act)
{
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)) {
return;
}
msg.sig = BTC_SIG_API_CB;
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_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_callback_sensor_status_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;
}
switch (evt_type) {
case 0x00:
case BTC_BLE_MESH_EVT_SENSOR_CLIENT_GET_STATE:
act = ESP_BLE_MESH_SENSOR_CLIENT_GET_STATE_EVT;
break;
case 0x01:
case BTC_BLE_MESH_EVT_SENSOR_CLIENT_SET_STATE:
act = ESP_BLE_MESH_SENSOR_CLIENT_SET_STATE_EVT;
break;
case 0x02:
case BTC_BLE_MESH_EVT_SENSOR_CLIENT_PUBLISH:
act = ESP_BLE_MESH_SENSOR_CLIENT_PUBLISH_EVT;
break;
case 0x03:
case BTC_BLE_MESH_EVT_SENSOR_CLIENT_TIMEOUT:
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;
}
@ -506,39 +502,43 @@ void bt_mesh_callback_sensor_status_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_mesh_sensor_client_callback(&cb_params, act);
btc_ble_mesh_sensor_client_callback(&cb_params, act);
return;
}
void btc_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_callback_sensor_status_to_btc(opcode, 0x02, 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;
}
void btc_mesh_sensor_client_call_handler(btc_msg_t *msg)
void btc_ble_mesh_sensor_client_call_handler(btc_msg_t *msg)
{
esp_ble_mesh_sensor_client_cb_param_t sensor_client_cb = {0};
esp_ble_mesh_client_common_param_t *params = NULL;
btc_ble_mesh_sensor_client_args_t *arg = NULL;
struct bt_mesh_common_param common = {0};
bt_mesh_role_param_t role_param = {0};
esp_ble_mesh_sensor_client_cb_param_t cb = {0};
bt_mesh_client_common_param_t common = {0};
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -547,12 +547,6 @@ void btc_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_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
return;
}
common.opcode = params->opcode;
common.model = (struct bt_mesh_model *)params->model;
common.ctx.net_idx = params->ctx.net_idx;
@ -561,27 +555,18 @@ void btc_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;
sensor_client_cb.params = arg->sensor_client_get_state.params;
sensor_client_cb.error_code =
bt_mesh_sensor_client_get_state(&common,
(void *)arg->sensor_client_get_state.get_state,
(void *)&sensor_client_cb.status_cb);
if (sensor_client_cb.error_code) {
cb.params = arg->sensor_client_get_state.params;
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_mesh_sensor_client_callback(&sensor_client_cb,
ESP_BLE_MESH_SENSOR_CLIENT_GET_STATE_EVT);
btc_ble_mesh_sensor_client_callback(&cb, ESP_BLE_MESH_SENSOR_CLIENT_GET_STATE_EVT);
}
break;
}
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_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
return;
}
common.opcode = params->opcode;
common.model = (struct bt_mesh_model *)params->model;
common.ctx.net_idx = params->ctx.net_idx;
@ -590,16 +575,13 @@ void btc_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;
sensor_client_cb.params = arg->sensor_client_set_state.params;
sensor_client_cb.error_code =
bt_mesh_sensor_client_set_state(&common,
(void *)arg->sensor_client_set_state.set_state,
(void *)&sensor_client_cb.status_cb);
if (sensor_client_cb.error_code) {
cb.params = arg->sensor_client_set_state.params;
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_mesh_sensor_client_callback(&sensor_client_cb,
ESP_BLE_MESH_SENSOR_CLIENT_SET_STATE_EVT);
btc_ble_mesh_sensor_client_callback(&cb, ESP_BLE_MESH_SENSOR_CLIENT_SET_STATE_EVT);
}
break;
}
@ -608,25 +590,309 @@ void btc_mesh_sensor_client_call_handler(btc_msg_t *msg)
}
btc_ble_mesh_sensor_client_arg_deep_free(msg);
return;
}
void btc_mesh_sensor_client_cb_handler(btc_msg_t *msg)
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;
}
param = (esp_ble_mesh_sensor_client_cb_param_t *)(msg->arg);
if (msg->act < ESP_BLE_MESH_SENSOR_CLIENT_EVT_MAX) {
btc_ble_mesh_cb_to_app(msg->act, param);
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_free_req_data(msg);
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)
{
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);
if (btc_ble_mesh_cb) {
btc_ble_mesh_cb(event, param);
}
}
static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
{
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;
uint16_t length = 0U;
if (!msg || !p_src_data || !p_dest_data) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (msg->act) {
case ESP_BLE_MESH_SENSOR_SERVER_STATE_CHANGE_EVT:
if (p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET ||
p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET_UNACK) {
if (p_src_data->value.state_change.sensor_cadence_set.trigger_delta_down) {
length = p_src_data->value.state_change.sensor_cadence_set.trigger_delta_down->len;
p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_down = bt_mesh_alloc_buf(length);
if (p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_down == NULL) {
BT_ERR("%s, 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,
p_src_data->value.state_change.sensor_cadence_set.trigger_delta_down->data,
p_src_data->value.state_change.sensor_cadence_set.trigger_delta_down->len);
}
if (p_src_data->value.state_change.sensor_cadence_set.trigger_delta_up) {
length = p_src_data->value.state_change.sensor_cadence_set.trigger_delta_up->len;
p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_up = bt_mesh_alloc_buf(length);
if (p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_up == NULL) {
BT_ERR("%s, 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,
p_src_data->value.state_change.sensor_cadence_set.trigger_delta_up->data,
p_src_data->value.state_change.sensor_cadence_set.trigger_delta_up->len);
}
if (p_src_data->value.state_change.sensor_cadence_set.fast_cadence_low) {
length = p_src_data->value.state_change.sensor_cadence_set.fast_cadence_low->len;
p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_low = bt_mesh_alloc_buf(length);
if (p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_low == NULL) {
BT_ERR("%s, 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,
p_src_data->value.state_change.sensor_cadence_set.fast_cadence_low->data,
p_src_data->value.state_change.sensor_cadence_set.fast_cadence_low->len);
}
if (p_src_data->value.state_change.sensor_cadence_set.fast_cadence_high) {
length = p_src_data->value.state_change.sensor_cadence_set.fast_cadence_high->len;
p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_high = bt_mesh_alloc_buf(length);
if (p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_high == NULL) {
BT_ERR("%s, 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,
p_src_data->value.state_change.sensor_cadence_set.fast_cadence_high->data,
p_src_data->value.state_change.sensor_cadence_set.fast_cadence_high->len);
}
} else if (p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET ||
p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET_UNACK) {
if (p_src_data->value.state_change.sensor_setting_set.setting_value) {
length = p_src_data->value.state_change.sensor_setting_set.setting_value->len;
p_dest_data->value.state_change.sensor_setting_set.setting_value = bt_mesh_alloc_buf(length);
if (p_dest_data->value.state_change.sensor_setting_set.setting_value == NULL) {
BT_ERR("%s, 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,
p_src_data->value.state_change.sensor_setting_set.setting_value->data,
p_src_data->value.state_change.sensor_setting_set.setting_value->len);
}
}
break;
case ESP_BLE_MESH_SENSOR_SERVER_RECV_GET_MSG_EVT:
if (p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_COLUMN_GET) {
if (p_src_data->value.get.sensor_column.raw_value_x) {
length = p_src_data->value.get.sensor_column.raw_value_x->len;
p_dest_data->value.get.sensor_column.raw_value_x = bt_mesh_alloc_buf(length);
if (p_dest_data->value.get.sensor_column.raw_value_x == NULL) {
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.get.sensor_column.raw_value_x,
p_src_data->value.get.sensor_column.raw_value_x->data,
p_src_data->value.get.sensor_column.raw_value_x->len);
}
} else if (p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_SERIES_GET) {
if (p_src_data->value.get.sensor_series.raw_value) {
length = p_src_data->value.get.sensor_series.raw_value->len;
p_dest_data->value.get.sensor_series.raw_value = bt_mesh_alloc_buf(length);
if (p_dest_data->value.get.sensor_series.raw_value == NULL) {
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.get.sensor_series.raw_value,
p_src_data->value.get.sensor_series.raw_value->data,
p_src_data->value.get.sensor_series.raw_value->len);
}
}
break;
case ESP_BLE_MESH_SENSOR_SERVER_RECV_SET_MSG_EVT:
if (p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET ||
p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET_UNACK) {
if (p_src_data->value.set.sensor_cadence.cadence) {
length = p_src_data->value.set.sensor_cadence.cadence->len;
p_dest_data->value.set.sensor_cadence.cadence = bt_mesh_alloc_buf(length);
if (p_dest_data->value.set.sensor_cadence.cadence == NULL) {
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.set.sensor_cadence.cadence,
p_src_data->value.set.sensor_cadence.cadence->data,
p_src_data->value.set.sensor_cadence.cadence->len);
}
} else if (p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET ||
p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET_UNACK) {
if (p_src_data->value.set.sensor_setting.setting_raw) {
length = p_src_data->value.set.sensor_setting.setting_raw->len;
p_dest_data->value.set.sensor_setting.setting_raw = bt_mesh_alloc_buf(length);
if (p_dest_data->value.set.sensor_setting.setting_raw == NULL) {
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.set.sensor_setting.setting_raw,
p_src_data->value.set.sensor_setting.setting_raw->data,
p_src_data->value.set.sensor_setting.setting_raw->len);
}
}
break;
default:
break;
}
}
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) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
arg = (esp_ble_mesh_sensor_server_cb_param_t *)(msg->arg);
switch (msg->act) {
case ESP_BLE_MESH_SENSOR_SERVER_STATE_CHANGE_EVT:
if (arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET ||
arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET_UNACK) {
bt_mesh_free_buf(arg->value.state_change.sensor_cadence_set.trigger_delta_down);
bt_mesh_free_buf(arg->value.state_change.sensor_cadence_set.trigger_delta_up);
bt_mesh_free_buf(arg->value.state_change.sensor_cadence_set.fast_cadence_low);
bt_mesh_free_buf(arg->value.state_change.sensor_cadence_set.fast_cadence_high);
} else if (arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET ||
arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET_UNACK) {
bt_mesh_free_buf(arg->value.state_change.sensor_setting_set.setting_value);
}
break;
case ESP_BLE_MESH_SENSOR_SERVER_RECV_GET_MSG_EVT:
if (arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_COLUMN_GET) {
bt_mesh_free_buf(arg->value.get.sensor_column.raw_value_x);
} else if (arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_SERIES_GET) {
bt_mesh_free_buf(arg->value.get.sensor_series.raw_value);
}
break;
case ESP_BLE_MESH_SENSOR_SERVER_RECV_SET_MSG_EVT:
if (arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET ||
arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET_UNACK) {
bt_mesh_free_buf(arg->value.set.sensor_cadence.cadence);
} else if (arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET ||
arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET_UNACK) {
bt_mesh_free_buf(arg->value.set.sensor_setting.setting_raw);
}
break;
default:
break;
}
}
static void btc_ble_mesh_sensor_server_callback(esp_ble_mesh_sensor_server_cb_param_t *cb_params, uint8_t act)
{
btc_msg_t msg = {0};
BT_DBG("%s", __func__);
/* If corresponding callback is not registered, event will not be posted. */
if (!btc_profile_cb_get(BTC_PID_SENSOR_SERVER)) {
return;
}
msg.sig = BTC_SIG_API_CB;
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);
}
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};
uint8_t act = 0U;
if (model == NULL || ctx == NULL) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (evt_type) {
case BTC_BLE_MESH_EVT_SENSOR_SERVER_STATE_CHANGE:
act = ESP_BLE_MESH_SENSOR_SERVER_STATE_CHANGE_EVT;
break;
case BTC_BLE_MESH_EVT_SENSOR_SERVER_RECV_GET_MSG:
act = ESP_BLE_MESH_SENSOR_SERVER_RECV_GET_MSG_EVT;
break;
case BTC_BLE_MESH_EVT_SENSOR_SERVER_RECV_SET_MSG:
act = ESP_BLE_MESH_SENSOR_SERVER_RECV_SET_MSG_EVT;
break;
default:
BT_ERR("Unknown Sensor server event type %d", evt_type);
return;
}
cb_params.model = (esp_ble_mesh_model_t *)model;
cb_params.ctx.net_idx = ctx->net_idx;
cb_params.ctx.app_idx = ctx->app_idx;
cb_params.ctx.addr = ctx->addr;
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) {
memcpy(&cb_params.value, val, MIN(len, sizeof(cb_params.value)));
}
btc_ble_mesh_sensor_server_callback(&cb_params, act);
return;
}
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) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
param = (esp_ble_mesh_sensor_server_cb_param_t *)(msg->arg);
if (msg->act < ESP_BLE_MESH_SENSOR_SERVER_EVT_MAX) {
btc_ble_mesh_sensor_server_cb_to_app(msg->act, param);
} else {
BT_ERR("%s, Unknown act %d", __func__, msg->act);
}
btc_ble_mesh_sensor_server_free_req_data(msg);
return;
}
#endif /* CONFIG_BLE_MESH_SENSOR_SERVER */

View File

@ -15,19 +15,21 @@
#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"
static inline void btc_ble_mesh_cb_to_app(esp_ble_mesh_time_scene_client_cb_event_t event,
esp_ble_mesh_time_scene_client_cb_param_t *param)
#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_t btc_mesh_cb = (esp_ble_mesh_time_scene_client_cb_t)btc_profile_cb_get(BTC_PID_TIME_SCENE_CLIENT);
if (btc_mesh_cb) {
btc_mesh_cb(event, 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);
if (btc_ble_mesh_cb) {
btc_ble_mesh_cb(event, param);
}
}
@ -37,62 +39,110 @@ 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;
}
}
static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
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) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
arg = (btc_ble_mesh_time_scene_client_args_t *)(msg->arg);
switch (msg->act) {
case BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_GET_STATE:
if (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) {
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) {
bt_mesh_free(arg->time_scene_client_set_state.params);
}
if (arg->time_scene_client_set_state.set_state) {
bt_mesh_free(arg->time_scene_client_set_state.set_state);
}
break;
default:
break;
}
}
static void btc_ble_mesh_time_scene_client_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
{
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;
u32_t opcode;
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 = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (!p_dest_data->params) {
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
}
switch (msg->act) {
case ESP_BLE_MESH_TIME_SCENE_CLIENT_GET_STATE_EVT:
case ESP_BLE_MESH_TIME_SCENE_CLIENT_SET_STATE_EVT:
case ESP_BLE_MESH_TIME_SCENE_CLIENT_PUBLISH_EVT:
if (p_src_data->params) {
opcode = p_src_data->params->opcode;
switch (opcode) {
switch (p_src_data->params->opcode) {
case ESP_BLE_MESH_MODEL_OP_SCENE_STORE:
case ESP_BLE_MESH_MODEL_OP_SCENE_REGISTER_GET:
case ESP_BLE_MESH_MODEL_OP_SCENE_DELETE:
@ -101,7 +151,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
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,
@ -114,27 +164,18 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
}
}
case ESP_BLE_MESH_TIME_SCENE_CLIENT_TIMEOUT_EVT:
if (p_src_data->params) {
p_dest_data->params = osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (p_dest_data->params) {
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
}
break;
default:
break;
}
}
static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
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;
u32_t opcode;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -145,8 +186,7 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
case ESP_BLE_MESH_TIME_SCENE_CLIENT_SET_STATE_EVT:
case ESP_BLE_MESH_TIME_SCENE_CLIENT_PUBLISH_EVT:
if (arg->params) {
opcode = arg->params->opcode;
switch (opcode) {
switch (arg->params->opcode) {
case ESP_BLE_MESH_MODEL_OP_SCENE_STORE:
case ESP_BLE_MESH_MODEL_OP_SCENE_REGISTER_GET:
case ESP_BLE_MESH_MODEL_OP_SCENE_DELETE:
@ -159,7 +199,7 @@ static void btc_ble_mesh_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:
@ -167,85 +207,54 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
}
}
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__);
return;
}
arg = (btc_ble_mesh_time_scene_client_args_t *)(msg->arg);
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);
}
if (arg->time_scene_client_get_state.get_state) {
osi_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);
}
if (arg->time_scene_client_set_state.set_state) {
osi_free(arg->time_scene_client_set_state.set_state);
}
break;
default:
break;
}
return;
}
static void btc_mesh_time_scene_client_callback(esp_ble_mesh_time_scene_client_cb_param_t *cb_params, uint8_t act)
static void btc_ble_mesh_time_scene_client_callback(esp_ble_mesh_time_scene_client_cb_param_t *cb_params, uint8_t act)
{
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)) {
return;
}
msg.sig = BTC_SIG_API_CB;
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_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_callback_time_scene_status_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;
}
switch (evt_type) {
case 0x00:
case BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_GET_STATE:
act = ESP_BLE_MESH_TIME_SCENE_CLIENT_GET_STATE_EVT;
break;
case 0x01:
case BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_SET_STATE:
act = ESP_BLE_MESH_TIME_SCENE_CLIENT_SET_STATE_EVT;
break;
case 0x02:
case BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_PUBLISH:
act = ESP_BLE_MESH_TIME_SCENE_CLIENT_PUBLISH_EVT;
break;
case 0x03:
case BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_TIMEOUT:
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;
}
@ -257,39 +266,43 @@ void bt_mesh_callback_time_scene_status_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_mesh_time_scene_client_callback(&cb_params, act);
btc_ble_mesh_time_scene_client_callback(&cb_params, act);
return;
}
void btc_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_callback_time_scene_status_to_btc(opcode, 0x02, 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;
}
void btc_mesh_time_scene_client_call_handler(btc_msg_t *msg)
void btc_ble_mesh_time_scene_client_call_handler(btc_msg_t *msg)
{
esp_ble_mesh_time_scene_client_cb_param_t time_scene_client_cb = {0};
btc_ble_mesh_time_scene_client_args_t *arg = NULL;
esp_ble_mesh_client_common_param_t *params = NULL;
struct bt_mesh_common_param common = {0};
bt_mesh_role_param_t role_param = {0};
esp_ble_mesh_time_scene_client_cb_param_t cb = {0};
bt_mesh_client_common_param_t common = {0};
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -298,12 +311,6 @@ void btc_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_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
return;
}
common.opcode = params->opcode;
common.model = (struct bt_mesh_model *)params->model;
common.ctx.net_idx = params->ctx.net_idx;
@ -312,27 +319,18 @@ void btc_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;
time_scene_client_cb.params = arg->time_scene_client_get_state.params;
time_scene_client_cb.error_code =
bt_mesh_time_scene_client_get_state(&common,
(void *)arg->time_scene_client_get_state.get_state,
(void *)&time_scene_client_cb.status_cb);
if (time_scene_client_cb.error_code) {
cb.params = arg->time_scene_client_get_state.params;
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_mesh_time_scene_client_callback(&time_scene_client_cb,
ESP_BLE_MESH_TIME_SCENE_CLIENT_GET_STATE_EVT);
btc_ble_mesh_time_scene_client_callback(&cb, ESP_BLE_MESH_TIME_SCENE_CLIENT_GET_STATE_EVT);
}
break;
}
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_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
return;
}
common.opcode = params->opcode;
common.model = (struct bt_mesh_model *)params->model;
common.ctx.net_idx = params->ctx.net_idx;
@ -341,16 +339,13 @@ void btc_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;
time_scene_client_cb.params = arg->time_scene_client_set_state.params;
time_scene_client_cb.error_code =
bt_mesh_time_scene_client_set_state(&common,
(void *)arg->time_scene_client_set_state.set_state,
(void *)&time_scene_client_cb.status_cb);
if (time_scene_client_cb.error_code) {
cb.params = arg->time_scene_client_set_state.params;
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_mesh_time_scene_client_callback(&time_scene_client_cb,
ESP_BLE_MESH_TIME_SCENE_CLIENT_SET_STATE_EVT);
btc_ble_mesh_time_scene_client_callback(&cb, ESP_BLE_MESH_TIME_SCENE_CLIENT_SET_STATE_EVT);
}
break;
}
@ -359,25 +354,130 @@ void btc_mesh_time_scene_client_call_handler(btc_msg_t *msg)
}
btc_ble_mesh_time_scene_client_arg_deep_free(msg);
return;
}
void btc_mesh_time_scene_client_cb_handler(btc_msg_t *msg)
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;
}
param = (esp_ble_mesh_time_scene_client_cb_param_t *)(msg->arg);
if (msg->act < ESP_BLE_MESH_TIME_SCENE_CLIENT_EVT_MAX) {
btc_ble_mesh_cb_to_app(msg->act, param);
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_free_req_data(msg);
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)
{
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);
if (btc_ble_mesh_cb) {
btc_ble_mesh_cb(event, param);
}
}
static void btc_ble_mesh_time_scene_server_callback(esp_ble_mesh_time_scene_server_cb_param_t *cb_params, uint8_t act)
{
btc_msg_t msg = {0};
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)) {
return;
}
msg.sig = BTC_SIG_API_CB;
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);
}
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};
uint8_t act = 0U;
if (model == NULL || ctx == NULL) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (evt_type) {
case BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_STATE_CHANGE:
act = ESP_BLE_MESH_TIME_SCENE_SERVER_STATE_CHANGE_EVT;
break;
case BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_GET_MSG:
act = ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_GET_MSG_EVT;
break;
case BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_SET_MSG:
act = ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_SET_MSG_EVT;
break;
case BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_STATUS_MSG:
act = ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_STATUS_MSG_EVT;
break;
default:
BT_ERR("Unknown Time Scene server event type %d", evt_type);
return;
}
cb_params.model = (esp_ble_mesh_model_t *)model;
cb_params.ctx.net_idx = ctx->net_idx;
cb_params.ctx.app_idx = ctx->app_idx;
cb_params.ctx.addr = ctx->addr;
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) {
memcpy(&cb_params.value, val, MIN(len, sizeof(cb_params.value)));
}
btc_ble_mesh_time_scene_server_callback(&cb_params, act);
return;
}
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) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
param = (esp_ble_mesh_time_scene_server_cb_param_t *)(msg->arg);
if (msg->act < ESP_BLE_MESH_TIME_SCENE_SERVER_EVT_MAX) {
btc_ble_mesh_time_scene_server_cb_to_app(msg->act, param);
} else {
BT_ERR("%s, Unknown 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_ */

View File

@ -15,50 +15,66 @@
#ifndef _BTC_BLE_MESH_CONFIG_MODEL_H_
#define _BTC_BLE_MESH_CONFIG_MODEL_H_
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include "esp_ble_mesh_config_model_api.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
BTC_BLE_MESH_ACT_CONFIG_CLIENT_GET_STATE,
BTC_BLE_MESH_ACT_CONFIG_CLIENT_SET_STATE,
} btc_ble_mesh_cfg_client_act_t;
BTC_BLE_MESH_ACT_CONFIG_CLIENT_MAX,
} btc_ble_mesh_config_client_act_t;
typedef union {
struct ble_mesh_clg_client_get_state_reg_args {
struct ble_mesh_cfg_client_get_state_reg_args {
esp_ble_mesh_client_common_param_t *params;
esp_ble_mesh_cfg_client_get_state_t *get_state;
} cfg_client_get_state;
struct ble_mesh_clg_client_set_state_reg_args {
struct ble_mesh_cfg_client_set_state_reg_args {
esp_ble_mesh_client_common_param_t *params;
esp_ble_mesh_cfg_client_set_state_t *set_state;
} cfg_client_set_state;
} btc_ble_mesh_cfg_client_args_t;
} btc_ble_mesh_config_client_args_t;
void btc_mesh_cfg_client_call_handler(btc_msg_t *msg);
typedef enum {
BTC_BLE_MESH_EVT_CONFIG_CLIENT_GET_STATE,
BTC_BLE_MESH_EVT_CONFIG_CLIENT_SET_STATE,
BTC_BLE_MESH_EVT_CONFIG_CLIENT_PUBLISH,
BTC_BLE_MESH_EVT_CONFIG_CLIENT_TIMEOUT,
BTC_BLE_MESH_EVT_CONFIG_CLIENT_MAX,
} btc_ble_mesh_config_client_evt_t;
void btc_mesh_cfg_client_cb_handler(btc_msg_t *msg);
void btc_ble_mesh_config_client_call_handler(btc_msg_t *msg);
void btc_ble_mesh_cfg_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
void btc_ble_mesh_config_client_cb_handler(btc_msg_t *msg);
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_state,
esp_ble_mesh_cfg_client_cb_param_t *cfg_client_cb);
void btc_ble_mesh_config_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
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_state,
esp_ble_mesh_cfg_client_cb_param_t *cfg_client_cb);
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);
void btc_mesh_cfg_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf);
void bt_mesh_config_client_cb_evt_to_btc(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);
void bt_mesh_callback_config_status_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 btc_ble_mesh_config_server_cb_handler(btc_msg_t *msg);
void btc_mesh_cfg_server_cb_handler(btc_msg_t *msg);
typedef enum {
BTC_BLE_MESH_EVT_CONFIG_SERVER_STATE_CHANGE,
BTC_BLE_MESH_EVT_CONFIG_SERVER_MAX,
} btc_ble_mesh_config_server_evt_t;
void bt_mesh_callback_cfg_server_event_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);
#ifdef __cplusplus
}
#endif
#endif /* _BTC_BLE_MESH_CONFIG_MODEL_H_ */

View File

@ -15,13 +15,17 @@
#ifndef _BTC_BLE_MESH_GENERIC_MODEL_H_
#define _BTC_BLE_MESH_GENERIC_MODEL_H_
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include "esp_ble_mesh_generic_model_api.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
BTC_BLE_MESH_ACT_GENERIC_CLIENT_GET_STATE,
BTC_BLE_MESH_ACT_GENERIC_CLIENT_SET_STATE,
BTC_BLE_MESH_ACT_GENERIC_CLIENT_MAX,
} btc_ble_mesh_generic_client_act_t;
typedef union {
@ -35,18 +39,44 @@ typedef union {
} generic_client_set_state;
} btc_ble_mesh_generic_client_args_t;
void btc_mesh_generic_client_call_handler(btc_msg_t *msg);
typedef enum {
BTC_BLE_MESH_EVT_GENERIC_CLIENT_GET_STATE,
BTC_BLE_MESH_EVT_GENERIC_CLIENT_SET_STATE,
BTC_BLE_MESH_EVT_GENERIC_CLIENT_PUBLISH,
BTC_BLE_MESH_EVT_GENERIC_CLIENT_TIMEOUT,
BTC_BLE_MESH_EVT_GENERIC_CLIENT_MAX,
} btc_ble_mesh_generic_client_evt_t;
void btc_mesh_generic_client_cb_handler(btc_msg_t *msg);
void btc_ble_mesh_generic_client_call_handler(btc_msg_t *msg);
void btc_ble_mesh_generic_client_cb_handler(btc_msg_t *msg);
void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
void btc_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);
void bt_mesh_callback_generic_status_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);
typedef enum {
BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE,
BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_GET_MSG,
BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_SET_MSG,
BTC_BLE_MESH_EVT_GENERIC_SERVER_MAX,
} btc_ble_mesh_generic_server_evt_t;
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);
void btc_ble_mesh_generic_server_cb_handler(btc_msg_t *msg);
#ifdef __cplusplus
}
#endif
#endif /* _BTC_BLE_MESH_GENERIC_MODEL_H_ */

View File

@ -15,21 +15,19 @@
#ifndef _BTC_BLE_MESH_HEALTH_MODEL_H_
#define _BTC_BLE_MESH_HEALTH_MODEL_H_
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include "esp_ble_mesh_health_model_api.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
BTC_BLE_MESH_ACT_HEALTH_CLIENT_GET_STATE,
BTC_BLE_MESH_ACT_HEALTH_CLIENT_SET_STATE,
BTC_BLE_MESH_ACT_HEALTH_CLIENT_MAX,
} btc_ble_mesh_health_client_act_t;
typedef enum {
BTC_BLE_MESH_ACT_HEALTH_SERVER_FAULT_UPDATE,
BTC_BLE_MESH_ACT_HEALTH_SERVER_MAX,
} btc_ble_mesh_health_server_act_t;
typedef union {
struct ble_mesh_health_client_get_state_reg_args {
esp_ble_mesh_client_common_param_t *params;
@ -41,38 +39,57 @@ typedef union {
} health_client_set_state;
} btc_ble_mesh_health_client_args_t;
typedef union {
struct ble_mesh_health_server_fault_update_args {
esp_ble_mesh_elem_t *element;
} fault_update;
} btc_ble_mesh_health_server_args_t;
void btc_mesh_health_client_call_handler(btc_msg_t *msg);
void btc_mesh_health_client_cb_handler(btc_msg_t *msg);
void btc_mesh_health_server_call_handler(btc_msg_t *msg);
void btc_mesh_health_server_cb_handler(btc_msg_t *msg);
typedef enum {
BTC_BLE_MESH_EVT_HEALTH_CLIENT_GET_STATE,
BTC_BLE_MESH_EVT_HEALTH_CLIENT_SET_STATE,
BTC_BLE_MESH_EVT_HEALTH_CLIENT_PUBLISH,
BTC_BLE_MESH_EVT_HEALTH_CLIENT_TIMEOUT,
BTC_BLE_MESH_EVT_HEALTH_CLIENT_MAX,
} btc_ble_mesh_health_client_evt_t;
void btc_ble_mesh_health_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
void btc_ble_mesh_health_client_call_handler(btc_msg_t *msg);
void btc_ble_mesh_health_client_cb_handler(btc_msg_t *msg);
void btc_ble_mesh_health_publish_callback(uint32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf);
void bt_mesh_health_client_cb_evt_to_btc(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);
typedef enum {
BTC_BLE_MESH_ACT_HEALTH_SERVER_FAULT_UPDATE,
BTC_BLE_MESH_ACT_HEALTH_SERVER_MAX,
} btc_ble_mesh_health_server_act_t;
typedef union {
struct ble_mesh_health_server_fault_update_args {
esp_ble_mesh_elem_t *element;
} health_fault_update;
} btc_ble_mesh_health_server_args_t;
void btc_ble_mesh_health_server_call_handler(btc_msg_t *msg);
void btc_ble_mesh_health_server_cb_handler(btc_msg_t *msg);
void btc_ble_mesh_health_server_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
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_state,
esp_ble_mesh_health_client_cb_param_t *client_cb);
void btc_ble_mesh_health_server_fault_clear(struct bt_mesh_model *model, uint16_t company_id);
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_state,
esp_ble_mesh_health_client_cb_param_t *client_cb);
void btc_ble_mesh_health_server_fault_test(struct bt_mesh_model *model,
uint8_t test_id, uint16_t company_id);
void btc_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_server_attention_on(struct bt_mesh_model *model, uint8_t time);
void bt_mesh_callback_health_status_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 btc_ble_mesh_health_server_attention_off(struct bt_mesh_model *model);
#ifdef __cplusplus
}
#endif
#endif /* _BTC_BLE_MESH_HEALTH_MODEL_H_ */

View File

@ -15,14 +15,18 @@
#ifndef _BTC_BLE_MESH_LIGHTING_MODEL_H_
#define _BTC_BLE_MESH_LIGHTING_MODEL_H_
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include "esp_ble_mesh_lighting_model_api.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
BTC_BLE_MESH_ACT_LIGHT_CLIENT_GET_STATE,
BTC_BLE_MESH_ACT_LIGHT_CLIENT_SET_STATE,
} btc_ble_mesh_light_client_act_t;
BTC_BLE_MESH_ACT_LIGHTING_CLIENT_GET_STATE,
BTC_BLE_MESH_ACT_LIGHTING_CLIENT_SET_STATE,
BTC_BLE_MESH_ACT_LIGHTING_CLIENT_MAX,
} btc_ble_mesh_lighting_client_act_t;
typedef union {
struct ble_mesh_light_client_get_state_reg_args {
@ -33,21 +37,48 @@ typedef union {
esp_ble_mesh_client_common_param_t *params;
esp_ble_mesh_light_client_set_state_t *set_state;
} light_client_set_state;
} btc_ble_mesh_light_client_args_t;
} btc_ble_mesh_lighting_client_args_t;
void btc_mesh_light_client_call_handler(btc_msg_t *msg);
typedef enum {
BTC_BLE_MESH_EVT_LIGHTING_CLIENT_GET_STATE,
BTC_BLE_MESH_EVT_LIGHTING_CLIENT_SET_STATE,
BTC_BLE_MESH_EVT_LIGHTING_CLIENT_PUBLISH,
BTC_BLE_MESH_EVT_LIGHTING_CLIENT_TIMEOUT,
BTC_BLE_MESH_EVT_LIGHTING_CLIENT_MAX,
} btc_ble_mesh_lighting_client_evt_t;
void btc_mesh_light_client_cb_handler(btc_msg_t *msg);
void btc_ble_mesh_lighting_client_call_handler(btc_msg_t *msg);
void btc_ble_mesh_light_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
void btc_ble_mesh_lighting_client_cb_handler(btc_msg_t *msg);
void btc_mesh_light_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_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
void bt_mesh_callback_light_status_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 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);
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);
typedef enum {
BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE,
BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_GET_MSG,
BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG,
BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_STATUS_MSG,
BTC_BLE_MESH_EVT_LIGHTING_SERVER_MAX,
} btc_ble_mesh_lighting_server_evt_t;
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);
void btc_ble_mesh_lighting_server_cb_handler(btc_msg_t *msg);
#ifdef __cplusplus
}
#endif
#endif /* _BTC_BLE_MESH_LIGHTING_MODEL_H_ */

View File

@ -15,20 +15,18 @@
#ifndef _BTC_BLE_MESH_PROV_H_
#define _BTC_BLE_MESH_PROV_H_
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "freertos/semphr.h"
#include "btc/btc_task.h"
#include "esp_bt_defs.h"
#include "mesh_access.h"
#include "mesh_buf.h"
#include "btc/btc_manage.h"
#include "mesh_byteorder.h"
#include "mesh_config.h"
#include "mesh_main.h"
#include "fast_prov.h"
#include "provisioner_prov.h"
#include "esp_ble_mesh_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
BTC_BLE_MESH_ACT_MESH_INIT = 0,
BTC_BLE_MESH_ACT_PROV_ENABLE,
@ -41,27 +39,60 @@ typedef enum {
BTC_BLE_MESH_ACT_PROXY_IDENTITY_ENABLE,
BTC_BLE_MESH_ACT_PROXY_GATT_ENABLE,
BTC_BLE_MESH_ACT_PROXY_GATT_DISABLE,
BTC_BLE_MESH_ACT_NODE_ADD_LOCAL_NET_KEY,
BTC_BLE_MESH_ACT_NODE_ADD_LOCAL_APP_KEY,
BTC_BLE_MESH_ACT_NODE_BIND_APP_KEY_TO_MODEL,
BTC_BLE_MESH_ACT_PROVISIONER_READ_OOB_PUB_KEY,
BTC_BLE_MESH_ACT_PROVISIONER_INPUT_STR,
BTC_BLE_MESH_ACT_PROVISIONER_INPUT_NUM,
BTC_BLE_MESH_ACT_PROVISIONER_ENABLE,
BTC_BLE_MESH_ACT_PROVISIONER_DISABLE,
BTC_BLE_MESH_ACT_PROVISIONER_DEV_ADD,
BTC_BLE_MESH_ACT_PROVISIONER_PROV_DEV_WITH_ADDR,
BTC_BLE_MESH_ACT_PROVISIONER_DEV_DEL,
BTC_BLE_MESH_ACT_PROVISIONER_SET_DEV_UUID_MATCH,
BTC_BLE_MESH_ACT_PROVISIONER_SET_PROV_DATA_INFO,
BTC_BLE_MESH_ACT_PROVISIONER_SET_STATIC_OOB_VAL,
BTC_BLE_MESH_ACT_PROVISIONER_SET_PRIMARY_ELEM_ADDR,
BTC_BLE_MESH_ACT_PROVISIONER_SET_NODE_NAME,
BTC_BLE_MESH_ACT_PROVISIONER_SET_LOCAL_APP_KEY,
BTC_BLE_MESH_ACT_PROVISIONER_ADD_LOCAL_APP_KEY,
BTC_BLE_MESH_ACT_PROVISIONER_UPDATE_LOCAL_APP_KEY,
BTC_BLE_MESH_ACT_PROVISIONER_BIND_LOCAL_MOD_APP,
BTC_BLE_MESH_ACT_PROVISIONER_ADD_LOCAL_NET_KEY,
BTC_BLE_MESH_ACT_PROVISIONER_UPDATE_LOCAL_NET_KEY,
BTC_BLE_MESH_ACT_PROVISIONER_STORE_NODE_COMP_DATA,
BTC_BLE_MESH_ACT_PROVISIONER_DELETE_NODE_WITH_UUID,
BTC_BLE_MESH_ACT_PROVISIONER_DELETE_NODE_WITH_ADDR,
BTC_BLE_MESH_ACT_PROVISIONER_ENABLE_HEARTBEAT_RECV,
BTC_BLE_MESH_ACT_PROVISIONER_SET_HEARTBEAT_FILTER_TYPE,
BTC_BLE_MESH_ACT_PROVISIONER_SET_HEARTBEAT_FILTER_INFO,
BTC_BLE_MESH_ACT_PROVISIONER_DIRECT_ERASE_SETTINGS,
BTC_BLE_MESH_ACT_PROVISIONER_OPEN_SETTINGS_WITH_INDEX,
BTC_BLE_MESH_ACT_PROVISIONER_OPEN_SETTINGS_WITH_UID,
BTC_BLE_MESH_ACT_PROVISIONER_CLOSE_SETTINGS_WITH_INDEX,
BTC_BLE_MESH_ACT_PROVISIONER_CLOSE_SETTINGS_WITH_UID,
BTC_BLE_MESH_ACT_PROVISIONER_DELETE_SETTINGS_WITH_INDEX,
BTC_BLE_MESH_ACT_PROVISIONER_DELETE_SETTINGS_WITH_UID,
BTC_BLE_MESH_ACT_SET_FAST_PROV_INFO,
BTC_BLE_MESH_ACT_SET_FAST_PROV_ACTION,
BTC_BLE_MESH_ACT_LPN_ENABLE,
BTC_BLE_MESH_ACT_LPN_DISABLE,
BTC_BLE_MESH_ACT_LPN_POLL,
BTC_BLE_MESH_ACT_PROXY_CLIENT_CONNECT,
BTC_BLE_MESH_ACT_PROXY_CLIENT_DISCONNECT,
BTC_BLE_MESH_ACT_PROXY_CLIENT_SET_FILTER_TYPE,
BTC_BLE_MESH_ACT_PROXY_CLIENT_ADD_FILTER_ADDR,
BTC_BLE_MESH_ACT_PROXY_CLIENT_REMOVE_FILTER_ADDR,
BTC_BLE_MESH_ACT_MODEL_SUBSCRIBE_GROUP_ADDR,
BTC_BLE_MESH_ACT_MODEL_UNSUBSCRIBE_GROUP_ADDR,
BTC_BLE_MESH_ACT_DEINIT_MESH,
} btc_ble_mesh_prov_act_t;
typedef enum {
BTC_BLE_MESH_ACT_MODEL_PUBLISH,
BTC_BLE_MESH_ACT_SERVER_MODEL_SEND,
BTC_BLE_MESH_ACT_CLIENT_MODEL_SEND
BTC_BLE_MESH_ACT_CLIENT_MODEL_SEND,
BTC_BLE_MESH_ACT_SERVER_MODEL_UPDATE_STATE,
} btc_ble_mesh_model_act_t;
typedef union {
@ -88,8 +119,23 @@ typedef union {
char string[8];
} input_string;
struct ble_mesh_set_device_name_args {
char name[ESP_BLE_MESH_DEVICE_NAME_MAX_LEN];
char name[ESP_BLE_MESH_DEVICE_NAME_MAX_LEN + 1];
} set_device_name;
struct ble_mesh_node_add_local_net_key_args {
uint8_t net_key[16];
uint16_t net_idx;
} node_add_local_net_key;
struct ble_mesh_node_add_local_app_key_args {
uint8_t app_key[16];
uint16_t net_idx;
uint16_t app_idx;
} node_add_local_app_key;
struct ble_mesh_node_bind_local_mod_app_args {
uint16_t element_addr;
uint16_t company_id;
uint16_t model_id;
uint16_t app_idx;
} node_local_mod_app_bind;
struct ble_mesh_provisioner_read_oob_pub_key_args {
uint8_t link_idx;
uint8_t pub_key_x[32];
@ -113,6 +159,14 @@ typedef union {
esp_ble_mesh_unprov_dev_add_t add_dev;
esp_ble_mesh_dev_add_flag_t flags;
} provisioner_dev_add;
struct ble_mesh_provisioner_prov_dev_with_addr_args {
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;
} provisioner_prov_dev_with_addr;
struct ble_mesh_provisioner_dev_del_args {
esp_ble_mesh_device_delete_t del_dev;
} provisioner_dev_del;
@ -125,15 +179,27 @@ typedef union {
struct ble_mesh_provisioner_set_prov_net_idx_args {
esp_ble_mesh_prov_data_info_t prov_data;
} set_prov_data_info;
struct ble_mesh_provisioner_set_static_oob_val_args {
uint8_t value[16];
uint8_t length;
} set_static_oob_val;
struct ble_mesh_provisioner_set_primary_elem_addr_args {
uint16_t addr;
} set_primary_elem_addr;
struct ble_mesh_provisioner_set_node_name_args {
int index;
char name[ESP_BLE_MESH_NODE_NAME_MAX_LEN];
uint16_t index;
char name[ESP_BLE_MESH_NODE_NAME_MAX_LEN + 1];
} set_node_name;
struct ble_mesh_provisioner_add_local_app_key_args {
uint8_t app_key[16];
uint16_t net_idx;
uint16_t app_idx;
} add_local_app_key;
struct ble_mesh_provisioner_update_local_app_key_args {
uint8_t app_key[16];
uint16_t net_idx;
uint16_t app_idx;
} update_local_app_key;
struct ble_mesh_provisioner_bind_local_mod_app_args {
uint16_t elem_addr;
uint16_t model_id;
@ -144,6 +210,52 @@ typedef union {
uint8_t net_key[16];
uint16_t net_idx;
} add_local_net_key;
struct ble_mesh_provisioner_update_local_net_key_args {
uint8_t net_key[16];
uint16_t net_idx;
} update_local_net_key;
struct ble_mesh_provisioner_store_node_comp_data_args {
uint16_t unicast_addr;
uint16_t length;
uint8_t *data;
} store_node_comp_data;
struct ble_mesh_provisioner_delete_node_with_uuid_args {
uint8_t uuid[16];
} delete_node_with_uuid;
struct ble_mesh_provisioner_delete_node_with_addr_args {
uint16_t unicast_addr;
} delete_node_with_addr;
struct {
bool enable;
} enable_heartbeat_recv;
struct {
uint8_t type;
} set_heartbeat_filter_type;
struct {
uint8_t op;
uint16_t hb_src;
uint16_t hb_dst;
} set_heartbeat_filter_info;
struct {
uint8_t index;
} open_settings_with_index;
struct {
char uid[ESP_BLE_MESH_SETTINGS_UID_SIZE + 1];
} open_settings_with_uid;
struct {
uint8_t index;
bool erase;
} close_settings_with_index;
struct {
char uid[ESP_BLE_MESH_SETTINGS_UID_SIZE + 1];
bool erase;
} close_settings_with_uid;
struct {
uint8_t index;
} delete_settings_with_index;
struct {
char uid[ESP_BLE_MESH_SETTINGS_UID_SIZE + 1];
} delete_settings_with_uid;
struct ble_mesh_set_fast_prov_info_args {
uint16_t unicast_min;
uint16_t unicast_max;
@ -157,6 +269,55 @@ typedef union {
struct ble_mesh_set_fast_prov_action_args {
uint8_t action;
} set_fast_prov_action;
struct ble_mesh_lpn_enable_args {
/* RFU */
} lpn_enable;
struct ble_mesh_lpn_disable_args {
bool force;
} lpn_disable;
struct ble_mesh_lpn_poll_args {
/* RFU */
} lpn_poll;
struct ble_mesh_proxy_client_connect_args {
uint8_t addr[6];
uint8_t addr_type;
uint16_t net_idx;
} proxy_client_connect;
struct ble_mesh_proxy_client_disconnect_args {
uint8_t conn_handle;
} proxy_client_disconnect;
struct ble_mesh_proxy_client_set_filter_type_args {
uint8_t conn_handle;
uint16_t net_idx;
uint8_t filter_type;
} proxy_client_set_filter_type;
struct ble_mesh_proxy_client_add_filter_addr_args {
uint8_t conn_handle;
uint16_t net_idx;
uint16_t addr_num;
uint16_t *addr;
} proxy_client_add_filter_addr;
struct ble_mesh_proxy_client_remove_filter_addr_args {
uint8_t conn_handle;
uint16_t net_idx;
uint16_t addr_num;
uint16_t *addr;
} proxy_client_remove_filter_addr;
struct ble_mesh_model_sub_group_addr_args {
uint16_t element_addr;
uint16_t company_id;
uint16_t model_id;
uint16_t group_addr;
} model_sub_group_addr;
struct ble_mesh_model_unsub_group_addr_args {
uint16_t element_addr;
uint16_t company_id;
uint16_t model_id;
uint16_t group_addr;
} model_unsub_group_addr;
struct ble_mesh_deinit_args {
esp_ble_mesh_deinit_param_t param;
} mesh_deinit;
} btc_ble_mesh_prov_args_t;
typedef union {
@ -174,13 +335,34 @@ typedef union {
uint8_t device_role;
int32_t msg_timeout;
} model_send;
struct ble_mesh_server_model_update_state_args {
esp_ble_mesh_model_t *model;
esp_ble_mesh_server_state_type_t type;
esp_ble_mesh_server_state_value_t *value;
} model_update_state;
} btc_ble_mesh_model_args_t;
void btc_ble_mesh_prov_arg_deep_free(btc_msg_t *msg);
void btc_ble_mesh_prov_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
int btc_ble_mesh_client_init(esp_ble_mesh_model_t *model);
void btc_ble_mesh_model_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
const uint8_t *btc_ble_mesh_node_get_local_net_key(uint16_t net_idx);
const uint8_t *btc_ble_mesh_node_get_local_app_key(uint16_t app_idx);
esp_ble_mesh_node_t *btc_ble_mesh_provisioner_get_node_with_uuid(const uint8_t uuid[16]);
esp_ble_mesh_node_t *btc_ble_mesh_provisioner_get_node_with_addr(uint16_t unicast_addr);
esp_ble_mesh_node_t *btc_ble_mesh_provisioner_get_node_with_name(const char *name);
uint16_t btc_ble_mesh_provisioner_get_prov_node_count(void);
const esp_ble_mesh_node_t **btc_ble_mesh_provisioner_get_node_table_entry(void);
int btc_ble_mesh_client_model_init(esp_ble_mesh_model_t *model);
int btc_ble_mesh_client_model_deinit(esp_ble_mesh_model_t *model);
int32_t btc_ble_mesh_model_pub_period_get(esp_ble_mesh_model_t *mod);
@ -188,23 +370,31 @@ uint16_t btc_ble_mesh_get_primary_addr(void);
uint16_t *btc_ble_mesh_model_find_group(esp_ble_mesh_model_t *mod, uint16_t addr);
esp_ble_mesh_elem_t *btc_ble_mesh_elem_find(u16_t addr);
esp_ble_mesh_elem_t *btc_ble_mesh_elem_find(uint16_t addr);
uint8_t btc_ble_mesh_elem_count(void);
esp_ble_mesh_model_t *btc_ble_mesh_model_find_vnd(const esp_ble_mesh_elem_t *elem,
uint16_t company, uint16_t id);
uint16_t company, uint16_t id);
esp_ble_mesh_model_t *btc_ble_mesh_model_find(const esp_ble_mesh_elem_t *elem,
uint16_t id);
esp_ble_mesh_model_t *btc_ble_mesh_model_find(const esp_ble_mesh_elem_t *elem, uint16_t id);
const esp_ble_mesh_comp_t *btc_ble_mesh_comp_get(void);
void btc_mesh_model_call_handler(btc_msg_t *msg);
void btc_mesh_model_cb_handler(btc_msg_t *msg);
const char *btc_ble_mesh_provisioner_get_settings_uid(uint8_t index);
void btc_mesh_prov_call_handler(btc_msg_t *msg);
uint8_t btc_ble_mesh_provisioner_get_settings_index(const char *uid);
void btc_mesh_prov_cb_handler(btc_msg_t *msg);
uint8_t btc_ble_mesh_provisioner_get_free_settings_count(void);
void btc_ble_mesh_model_call_handler(btc_msg_t *msg);
void btc_ble_mesh_model_cb_handler(btc_msg_t *msg);
void btc_ble_mesh_prov_call_handler(btc_msg_t *msg);
void btc_ble_mesh_prov_cb_handler(btc_msg_t *msg);
#ifdef __cplusplus
}
#endif
#endif /* _BTC_BLE_MESH_PROV_H_ */

View File

@ -15,13 +15,17 @@
#ifndef _BTC_BLE_MESH_SENSOR_MODEL_H_
#define _BTC_BLE_MESH_SENSOR_MODEL_H_
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include "esp_ble_mesh_sensor_model_api.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
BTC_BLE_MESH_ACT_SENSOR_CLIENT_GET_STATE,
BTC_BLE_MESH_ACT_SENSOR_CLIENT_SET_STATE,
BTC_BLE_MESH_ACT_SENSOR_CLIENT_MAX,
} btc_ble_mesh_sensor_client_act_t;
typedef union {
@ -35,19 +39,45 @@ typedef union {
} sensor_client_set_state;
} btc_ble_mesh_sensor_client_args_t;
void btc_mesh_sensor_client_call_handler(btc_msg_t *msg);
typedef enum {
BTC_BLE_MESH_EVT_SENSOR_CLIENT_GET_STATE,
BTC_BLE_MESH_EVT_SENSOR_CLIENT_SET_STATE,
BTC_BLE_MESH_EVT_SENSOR_CLIENT_PUBLISH,
BTC_BLE_MESH_EVT_SENSOR_CLIENT_TIMEOUT,
BTC_BLE_MESH_EVT_SENSOR_CLIENT_MAX,
} btc_ble_mesh_sensor_client_evt_t;
void btc_mesh_sensor_client_cb_handler(btc_msg_t *msg);
void btc_ble_mesh_sensor_client_call_handler(btc_msg_t *msg);
void btc_ble_mesh_sensor_client_cb_handler(btc_msg_t *msg);
void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
void btc_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);
void bt_mesh_callback_sensor_status_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);
typedef enum {
BTC_BLE_MESH_EVT_SENSOR_SERVER_STATE_CHANGE,
BTC_BLE_MESH_EVT_SENSOR_SERVER_RECV_GET_MSG,
BTC_BLE_MESH_EVT_SENSOR_SERVER_RECV_SET_MSG,
BTC_BLE_MESH_EVT_SENSOR_SERVER_MAX,
} btc_ble_mesh_sensor_server_evt_t;
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);
void btc_ble_mesh_sensor_server_cb_handler(btc_msg_t *msg);
#ifdef __cplusplus
}
#endif
#endif /* _BTC_BLE_MESH_SENSOR_MODEL_H_ */

View File

@ -15,13 +15,17 @@
#ifndef _BTC_BLE_MESH_TIME_SCENE_MODEL_H_
#define _BTC_BLE_MESH_TIME_SCENE_MODEL_H_
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include "esp_ble_mesh_time_scene_model_api.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_GET_STATE,
BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_SET_STATE,
BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_MAX,
} btc_ble_mesh_time_scene_client_act_t;
typedef union {
@ -35,19 +39,46 @@ typedef union {
} time_scene_client_set_state;
} btc_ble_mesh_time_scene_client_args_t;
void btc_mesh_time_scene_client_call_handler(btc_msg_t *msg);
typedef enum {
BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_GET_STATE,
BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_SET_STATE,
BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_PUBLISH,
BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_TIMEOUT,
BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_MAX,
} btc_ble_mesh_time_scene_client_evt_t;
void btc_mesh_time_scene_client_cb_handler(btc_msg_t *msg);
void btc_ble_mesh_time_scene_client_call_handler(btc_msg_t *msg);
void btc_ble_mesh_time_scene_client_cb_handler(btc_msg_t *msg);
void btc_ble_mesh_time_scene_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
void btc_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);
void bt_mesh_callback_time_scene_status_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);
typedef enum {
BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_STATE_CHANGE,
BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_GET_MSG,
BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_SET_MSG,
BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_STATUS_MSG,
BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_MAX,
} btc_ble_mesh_time_scene_server_evt_t;
void bt_mesh_time_scene_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const uint8_t *val, size_t len);
void btc_ble_mesh_time_scene_server_cb_handler(btc_msg_t *msg);
#ifdef __cplusplus
}
#endif
#endif /* _BTC_BLE_MESH_TIME_SCENE_MODEL_H_ */

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