Compare commits

...

1140 Commits

Author SHA1 Message Date
21ecef5c56 versions: Update version to 4.2.1 2021-04-29 10:13:07 +08:00
deaad551c4 Merge branch 'bugfix/mdns_configure_strict_mode_v4.2' into 'release/v4.2'
mdns: Fix mdns to correctly answer non-strict queries (+ additional fixes) (v4.2)

See merge request espressif/esp-idf!13122
2021-04-22 11:09:58 +00:00
19634e34e9 mdns: Fixed the ip header TTL to be correctly set to 255
Defined in https://tools.ietf.org/html/rfc6762#section-11: All Multicast DNS responses (including responses sent via unicast)
   SHOULD be sent with IP TTL set to 255
2021-04-22 08:32:43 +00:00
4f4640b1df mdns: Fix parsing answers with questions when instance name not set
mdns resolver didn't correctly resolved queries when host name wasn't
assigned. Fixed by allowing processing also if some answer present
(non-strict mode)

Closes https://github.com/espressif/esp-idf/issues/6598
2021-04-22 08:32:43 +00:00
92e511a5b6 mdns: Fix the resolver to correctly parse it's own non-strict answers
The resolver was able to respond correctly, but would also resolve its
own queries and cause issues with BCT 1.5.2, specifically
* MULTIPLE QUESTIONS - DUPLICATE SUPPRESSION
* MULTIPLE QUESTIONS - DISTRIBUTED DUPLICATE SUPPRESSION
tests failed.
2021-04-22 08:32:43 +00:00
7064eb9729 mdns: Add MDNS_STRICT_MODE config option
Strict mode was hardcoded in private header file, but it's useful for
users to enable/disable it depending on the mdns library they are using.
e.g. Avahi might not resolve the non-strict answers.
2021-04-22 08:32:43 +00:00
a7b419b652 Merge branch 'bugfix/e8192_and_assert_param_v4.2' into 'release/v4.2'
Modify E8192 ELx200 ELx40 log level to LOGD

See merge request espressif/esp-idf!13148
2021-04-21 08:48:00 +00:00
6ed64c2a2d Synchronize multiple branch of bt lib(release/v4.1 ~ master) 2021-04-21 04:07:59 +00:00
ac179dcd99 Modify E8192 ELx200 ELx40 log level to LOGD 2021-04-21 04:07:59 +00:00
82801321e8 Merge branch 'bugfix/secure_boot_v2_had_zeros_blk2_after_en' into 'release/v4.2'
secure_boot_v2: Fix case when BLOCK2 is left blank

See merge request espressif/esp-idf!13243
2021-04-21 01:15:40 +00:00
4200af3e26 secure_boot_v2: Fix case when BLOCK2 is left blank
Closes: https://github.com/espressif/esp-idf/issues/6886
2021-04-20 23:23:32 +00:00
46560be284 Merge branch 'bugfix/ci/ci_fetch_submodule_fully_match_return_first_v4.2' into 'release/v4.2'
fix(ci): ci_fetch_submodule return full match name first (v4.2)

See merge request espressif/esp-idf!13211
2021-04-20 23:22:21 +00:00
bbc05c5095 fix(ci): ci_fetch_submodule return full match name first 2021-04-19 20:21:07 +08:00
cf53feff6f Merge branch 'bugfix/touch_sensor_reading_error_in_light_sleep_process_backport_v4.2' into 'release/v4.2'
Bugfix/touch sensor reading error in light sleep process (backport v4.2)

See merge request espressif/esp-idf!12880
2021-03-26 16:01:47 +00:00
2f5eba9263 driver(touch): fix touch sensor false trigger in sleep mode 2021-03-26 10:57:50 +08:00
f4e11dce34 Merge branch 'bugfix/clear_interrupt_in_touch_sensor_initialization_backport_v4.2' into 'release/v4.2'
Bugfix/clear interrupt in touch sensor initialization (backport v4.2)

See merge request espressif/esp-idf!12883
2021-03-25 11:04:44 +00:00
a866f0d8f6 fix: clear interrupt in touch sensor initialization 2021-03-25 11:14:24 +08:00
dd56e9523b Merge branch 'bugfix/fix_driver_dac_ci_fail_backport_v4.2' into 'release/v4.2'
bugfix(dac): fix testcase fail for dac (backport v4.2)

See merge request espressif/esp-idf!12882
2021-03-25 01:21:54 +00:00
e66ac8b2e5 Merge branch 'bugfix/freemodbus_fix_mbm_event_processing_v42' into 'release/v4.2'
Bugfix/freemodbus fix mbm event processing (backport v4.2)

See merge request espressif/esp-idf!12823
2021-03-25 01:18:45 +00:00
a607e0651c Merge branch 'bugfix/uart_read_o2_v4.2' into 'release/v4.2'
hal: workaround for UART FIFO read on ESP32 with -O2 optimization (backport v4.2)

See merge request espressif/esp-idf!12658
2021-03-25 01:17:14 +00:00
b06b8273ee Merge branch 'bugfix/fix_rtc_wdt_in_light_sleep_process_backport_v4.2' into 'release/v4.2'
bugfix: rtc: compile the regi2c_ctrl.c code to iram (backport v4.2)

See merge request espressif/esp-idf!12881
2021-03-24 16:06:50 +00:00
7dbd5e1855 Merge branch 'bugfix/fix_uart_module_enable_issue_v4.2' into 'release/v4.2'
driver(uart): fix uart module reset issue (release V4.2)

See merge request espressif/esp-idf!11969
2021-03-24 11:05:00 +00:00
dbaee379ba Merge branch 'bugfix/fix_coex_reset_last_wait_lose_iram_attr_4_2' into 'release/v4.2'
bugfix/btdm:Fix IRAM_ATTR missing. Backports v4.2

See merge request espressif/esp-idf!12073
2021-03-24 10:27:24 +00:00
4fb18da50b bugfix(dac): fix testcase fail for dac 2021-03-24 15:50:31 +08:00
60b604ae6d rtc: compile the regi2c_ctrl.c code to iram 2021-03-24 15:43:47 +08:00
f2f42c4bfc Merge branch 'bugfix/fix_some_wifi_bugs_0323_v4.2' into 'release/v4.2'
esp_wifi: Fix some WiFi bugs (backport v4.2)

See merge request espressif/esp-idf!12859
2021-03-24 07:39:29 +00:00
74649219f4 Merge branch 'bugfix/adc_full_scale_voltages_v4.2' into 'release/v4.2'
docs: Update full-scale voltages for ESP32-S2 chip (v4.2)

See merge request espressif/esp-idf!12208
2021-03-24 04:14:44 +00:00
1c6ab10a70 hal: workaround for UART FIFO read on ESP32 with -O2 optimization 2021-03-24 04:12:42 +00:00
c8ef66abad driver(uart): fix uart module reset issue (release V4.2) 2021-03-24 04:10:39 +00:00
c04489cede Merge branch 'bugfix/dport_init_min_stack_size_v4.2' into 'release/v4.2'
freertos: Increase minimum task stack size when stack smashing checker is enabled (v4.2)

See merge request espressif/esp-idf!12799
2021-03-24 04:06:45 +00:00
8507f1f777 esp_wifi: Fix some WiFi bugs
1. Unlock mutex for esp_wifi_80211_tx when out of memory.
2. Fix issue that esp_wifi_80211_tx can't be used in ap mode.
3. Clear hotspot bss when auth timeout happens.
4. Fix PMK not saved in NVS for SoftAP for PSK mode.
5. Fix the bug for esptouch find hidden AP fail.
6. Fix not connect to open AP when WPA3 auth fail.
7. Fix issue with hidden AP scans after connecting AP.
8. Fix the watchdog issue when receiving action frame.
9. Fix the issue that the parameters obtained form RAM cannot be saved to NVS.
10.Modify not to store the default value in NVS.
11.Delete interface STATIONAP_IF.
12.Modify the _do_wifi_start and _do_wifi_stop parameters to mode.
13.Fixed issue of reason code change from 15 to 204 when provide wrong password.
14.Fix set config return value error.
15.Fix ampdu age timer memory leak.
2021-03-24 03:40:01 +00:00
bb067c0883 Merge branch 'bugfix/btdm_assert_without_sw_coex_enable_v4.2' into 'release/v4.2'
components/bt: Fix assert without sw coexist enabled

See merge request espressif/esp-idf!12527
2021-03-24 03:23:58 +00:00
0c1ff94823 Merge branch 'bugfix/wpa_supplicant_coverity_issue_fixes_v4.2' into 'release/v4.2'
Bugfix/wpa supplicant coverity issue fixes v4.2

See merge request espressif/esp-idf!12849
2021-03-23 16:04:03 +00:00
def9153200 Merge branch 'mesh/ps_duty_signaling_backport_v4.2' into 'release/v4.2'
mesh/ps: network duty signaling (backport v4.2)

See merge request espressif/esp-idf!12810
2021-03-23 16:02:56 +00:00
f8307bcd4e Merge branch 'bugfix/spp_data_send_delay_v4.2' into 'release/v4.2'
Bugfix/spp data send delay v4.2

See merge request espressif/esp-idf!11772
2021-03-23 08:42:05 +00:00
1d227bbb2e Merge branch 'bugfix/crash_on_enabling_verbose_logs_v4.2' into 'release/v4.2'
Fixes issue of crashing when verbose logs are enabled.(v4.2)

See merge request espressif/esp-idf!12845
2021-03-23 08:41:41 +00:00
d7ea6266b7 Fix coex IRAM missing and Fix C2H flow control issue 2021-03-23 15:47:50 +08:00
ad5ef10343 mesh/ps: network duty signaling 2021-03-23 14:57:17 +08:00
20256c5dfd Merge branch 'bugfix/btdm_controller_task_watchdog_in_wifi_test_v4.2' into 'release/v4.2'
Fix controller task watchdog in Wi-Fi test

See merge request espressif/esp-idf!12708
2021-03-23 06:54:00 +00:00
c083d7278d esp_http_client: Fix some memory leak issues by coverity static analyzer. 2021-03-23 11:11:20 +05:30
d417ba0c11 esp_local_ctrl: Fix some memory leak issues by coverity static analyzer. 2021-03-23 11:10:58 +05:30
d734c533a5 wifi_provisioning: Fix some memory leak issues by coverity static analyzer. 2021-03-23 11:10:36 +05:30
c9f2790474 wpa_supplicant: Fix some memory leak issues by coverity static analyzer. 2021-03-23 11:09:52 +05:30
98d19efe6f tcp_transport: Fix some memory leak issues by coverity static analyzer. 2021-03-23 11:09:21 +05:30
4407c9eb83 fatfs: Fix some memory leak issues by coverity static analyzer. 2021-03-23 11:08:12 +05:30
f8c691faaf esp_wifi: Fixes issue of crashing when verbose logs are enabled. 2021-03-23 10:30:32 +05:30
5151fb52ec Merge branch 'bugfix/test_sha_psram' into 'release/v4.2'
CI: disable performance check for PSRAM config

See merge request espressif/esp-idf!12829
2021-03-23 03:53:59 +00:00
399ab25967 Merge branch 'bugfix/fix_wifi_interface_use_v4.2' into 'release/v4.2'
esp_wifi: Modify ESP_IF_WIFI_STA to WIFI_IF_STA (backport v4.2)

See merge request espressif/esp-idf!12166
2021-03-22 14:34:24 +00:00
f90b14175c esp_wifi: Modify ESP_IF_WIFI_AP to WIFI_IF_AP 2021-03-22 09:09:58 +00:00
1ef10dc284 esp_wifi: Modify ESP_IF_WIFI_STA to WIFI_IF_STA 2021-03-22 09:09:58 +00:00
59d3116e41 Merge branch 'bufix/ag_deep_copy_crash_v_4_2' into 'release/v4.2'
components/bt: Fix crash in btc_hf_arg_deep_copy when name or number is NULL

See merge request espressif/esp-idf!12789
2021-03-22 08:01:23 +00:00
b58d888b77 Merge branch 'bugfix/ping_zero_interval_cause_to_assert_reset_v4.2' into 'release/v4.2'
lw-ip: Fixed ping assert reset when ping interval is 0 (v4.2)

See merge request espressif/esp-idf!12174
2021-03-22 07:59:16 +00:00
e4c021757c Merge branch 'ci/ignore_check_link_result_v4.2' into 'release/v4.2'
CI: ignore result from check_doc_links (v4.2)

See merge request espressif/esp-idf!12783
2021-03-22 03:40:17 +00:00
fa62dfd5f9 CI: disable performance check for PSRAM config
The cache compensated timer performance check ocasionally
wrong result for psram_2 config. Disabled CI test for now.
2021-03-22 11:39:49 +08:00
fd032425f1 Merge branch 'mesh/support_for_chain_topology_backport_v4.2' into 'release/v4.2'
mesh: support for chain topology (backport v4.2)

See merge request espressif/esp-idf!12806
2021-03-22 03:27:49 +00:00
c8f8def780 lwip: Fixed ping assert reset when ping interval is 0 2021-03-22 03:26:42 +00:00
d340fa68aa freemodbus: fix event processing after merge 2021-03-19 15:05:27 +01:00
c9cf7bcb0e Merge branch 'bugfix/fix_some_wifi_bugs_0105_v4.2' into 'release/v4.2'
Bugfix/fix some wifi bugs 0105 v4.2 (backport v4.2)

See merge request espressif/esp-idf!11921
2021-03-19 12:09:01 +00:00
98e703340b Merge branch 'feature/update_wifi_provisioning_readme_v4.2' into 'release/v4.2'
provisioning: Update README.md to explain QR code format [backport v4.2]

See merge request espressif/esp-idf!12803
2021-03-19 10:33:56 +00:00
9ca4799b20 provisioning: update README.md 2021-03-19 06:08:12 +00:00
66c533b3d5 provisioning: Update README.md to explain QR code format
Add examples of how to create a QR code that will be recognised by the iOS or Android app

Signed-off-by: yuanjm <yuanjianmin@espressif.com>

Merges https://github.com/espressif/esp-idf/pull/6629
2021-03-19 06:08:12 +00:00
9bd9e939ba 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 12:21:14 +08:00
7fc2f91841 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 12:19:58 +08:00
eedcb8c97f Merge branch 'bugfix/fix_iperf_example_exception_handling_for_no_ap_found_v4.2' into 'release/v4.2'
bugfix/fix_iperf_example_exception_handling_for_no_ap_found_v4.2

See merge request espressif/esp-idf!12268
2021-03-19 04:04:00 +00:00
e305c09b12 Merge branch 'bugfix/pm_dump_format_v4.2' into 'release/v4.2'
esp_pm: fix formatting issues in esp_pm_dump_locks (backport v4.2)

See merge request espressif/esp-idf!12022
2021-03-19 04:01:46 +00:00
0d5286471a Merge branch 'component_bt/optimize_spp_stop_server_v4.2' into 'release/v4.2'
component_bt/Optimize SPP Stop Server API[backport v4.2]

See merge request espressif/esp-idf!12620
2021-03-19 04:01:17 +00:00
42fc36ef17 mesh: support for chain topology 2021-03-19 11:37:20 +08:00
50bc7db63a esp_wifi: Update WiFi lib
1. Change wifi scan duration from 120ms to 100ms
2. Using deport reg instead of ahb
3. Revert to report specific reason code when receiving deauth during 4-way-handshark
4. Fix the bug that tx ampdu parameter is not from peer device
5. Faster WiFi station connect improvement, avoid 100ms passive scan
6. Add FCS failed packets filter
7. Fix country code last byte to space instead of NULL
8. Fix softap cannot forward A-MSDU
9. Fix max tx power to 20dBm
10. Fix the issue that the esp_wifi_sta_get_ap_info can't get country
11. Update esp32 phy lib to v4660
12. Update esp32s2 phy lib to v1300
13. Fix the bug that esp32s2 can't get CSI info
2021-03-19 03:02:26 +00:00
07ca98b5f0 esp_wifi: ESP32 phy add [sections:phy_iram] 2021-03-19 03:02:26 +00:00
4650db0841 esp_wifi: optimize phy version log 2021-03-19 03:02:26 +00:00
349b0b5ec5 bugfix: fix some wifi bugs
1. fix max tx power to 20dBm
2. fix the issue that the esp_wifi_sta_get_ap_info can't get country

Closes https://github.com/espressif/esp-idf/issues/6267
2021-03-19 03:02:26 +00:00
f6f644bf81 components/bt: Fix crash in btc_hf_arg_deep_copy when name or number is NULL 2021-03-18 20:20:19 +08:00
8b0ac7f81e Merge branch 'bugfix/extern_c_decl_4.2' into 'release/v4.2'
[cxx]: fixed extern "C" declarations (backport v4.2)

See merge request espressif/esp-idf!12742
2021-03-18 07:29:20 +00:00
7aeaf604c2 CI: ignore result from check_doc_links
check_doc_links will always fail due to:
 * No rate limitation for requests
 * Not being able to handle github links with anchors
2021-03-18 13:17:46 +08:00
747ecb27d0 Merge branch 'bugfix/idf_size_total_size_without_bss_v4.2' into 'release/v4.2'
tools: Don't count BSS into the total image size (v4.2)

See merge request espressif/esp-idf!12576
2021-03-18 04:32:42 +00:00
359784f0b6 Merge branch 'bugfix/fix_arp_buffer_error_in_smart_config_v4.2' into 'release/v4.2'
bugfix/fix_arp_buffer_error_in_smart_config_v4.2

See merge request espressif/esp-idf!12254
2021-03-18 04:17:36 +00:00
1e1fc92fc2 Merge branch 'bugfix/fatfs_v4.2' into 'release/v4.2'
spi_flash: fix the issue of ext_flash_fatfs_example(backport v4.2)

See merge request espressif/esp-idf!12667
2021-03-18 04:15:35 +00:00
8a26bc72be Merge branch 'bugfix/ip_mesh_transmit_wrap_v4.2' into 'release/v4.2'
esp_mesh: Fix internal ip mesh example to use transmit wrap function (v4.2)

See merge request espressif/esp-idf!12530
2021-03-18 04:14:33 +00:00
caa7dc187d Merge branch 'bugfix/fix_i2s_pdm_config_4.2' into 'release/v4.2'
fix PDM Fp and Fs config error (4.2)

See merge request espressif/esp-idf!10687
2021-03-18 04:13:36 +00:00
2e03275406 Merge branch 'bugfix/freemodbus_fix_event_processing_after_destroy_v4.2' into 'release/v4.2'
freemodbus: fix event processing failure after destroy (backport v4.2)

See merge request espressif/esp-idf!9327
2021-03-18 04:12:03 +00:00
b517b64a30 Merge branch 'bugfix/fix_deepsleep_x32k_wakeup_bug_v4.2' into 'release/v4.2'
Fix esp_hw_support bug (backport v4.2)

See merge request espressif/esp-idf!11835
2021-03-18 04:11:18 +00:00
c4c500e241 Merge branch 'bugfix/deep_sleep_stub_heap_rtc_fast_mem_v4.2' into 'release/v4.2'
deep sleep: Calculate RTC CRC without using any stack or other RTC heap memory (v4.2)

See merge request espressif/esp-idf!10883
2021-03-18 04:09:50 +00:00
aafcc2ca60 Merge branch 'bugfix/flash_encryption_v4.2' into 'release/v4.2'
ota: fix ota with flash encryption(backport v4.2)

See merge request espressif/esp-idf!12701
2021-03-18 04:09:45 +00:00
e027f962df Merge branch 'bugfix/bta_hf_client_sco_co_out_data_v4.2' into 'release/v4.2'
bugfix/if bta_hf_client_sco_co_out_data is called, it will crash when sco disconnected [backport v4.2]

See merge request espressif/esp-idf!12560
2021-03-18 04:04:17 +00:00
4f4cd08aad Merge branch 'bugfix/avrc_set_player_value_cmd_event_unhandle_v_4_2' into 'release/v4.2'
bugfix/fix unhandle RC vendor PDU when tg receive set_player_app_value cmd[backport v4.2]

See merge request espressif/esp-idf!12099
2021-03-18 04:03:49 +00:00
9f3750cee7 Merge branch 'bugfix/btdm_backport_ble_bugs_21_01_29_v4.2' into 'release/v4.2'
Bugfix/btdm backport ble bugs  for v4.2

See merge request espressif/esp-idf!12197
2021-03-18 03:55:04 +00:00
f4c56216e5 Merge branch 'doc/embed_example_v4.2' into 'release/v4.2'
doc: Update the link to an example that embeds a file (v4.2)

See merge request espressif/esp-idf!12656
2021-03-16 08:31:47 +00:00
be3fc35533 [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-03-15 18:42:19 +08:00
068dfcf1ba ota: fix ota with flash encryption 2021-03-12 16:45:43 +08:00
ce2c615bb3 Merge branch 'bugfix/deepsleep_disable_brownout_s2_v4.2' into 'release/v4.2'
deep_sleep: on S2 disable the brown out detector before deep sleeping (v4.2)

See merge request espressif/esp-idf!12500
2021-03-11 10:49:30 +00:00
6c2489682f Fix controller task watchdog in Wi-Fi test 2021-03-11 17:19:16 +08:00
f80f4cbf2d ci: move freerom/sdmmc repo to psram3 for saving ram 2021-03-11 13:54:15 +08:00
54b817a59e flash_encryption: Quick fixed the issue that block when flash_encryption_write, Related https://github.com/espressif/esp-idf/issues/6322, Related https://github.com/espressif/esp-idf/issues/6254 2021-03-11 13:52:28 +08:00
fa2c4fe622 Merge branch 'bugfix/fix_a2dp_underrun_issue_4_2' into 'release/v4.2'
Fix A2DP Underrun Issue [backport v4.2]

See merge request espressif/esp-idf!12277
2021-03-10 14:30:28 +00:00
00e2f2e880 Merge branch 'feat/spi_flash_override_size_v4.2' into 'release/v4.2'
spi_flash: add config option to override flash size in bootloader header (v4.2)

See merge request espressif/esp-idf!12452
2021-03-10 10:13:39 +00:00
e5830907ca spi_flash: fix flash issue of ext_flash_fatfs_example 2021-03-09 18:33:30 +08:00
32b0264529 Merge branch 'doc/flash_enc_update_v4.2' into 'release/v4.2'
docs: update flash encryption docs for S2

See merge request espressif/esp-idf!12324
2021-03-09 06:41:53 +00:00
5b6e62d2c4 update CN translation based on reviewers' comments 2021-03-09 10:34:29 +11:00
fdfef114ae api-guides: update CN translation for build-system and build-system-legacy,and fix line break in the EN version 2021-03-09 10:33:44 +11:00
c8900823d8 doc: Update the link to an example that embeds a file
Since we have the CA Certificate Store feature, https_request no longer needs to
embed any certs.
2021-03-09 10:33:44 +11:00
37a8c8ce6c Merge branch 'bugfix/btdm_crash_when_esp_restart_v4.2' into 'release/v4.2'
components/bt: Fix crash in Bluetooth when esp_restart

See merge request espressif/esp-idf!12567
2021-03-05 12:27:43 +00:00
2289d4fcc0 Merge branch 'bugfix/fix_csa_channel_crash_v4.2' into 'release/v4.2'
esp_wifi: fix CSA and BAR crash issue(v4.2)

See merge request espressif/esp-idf!12549
2021-03-05 12:24:33 +00:00
e1f1d11b76 Merge branch 'feature/add_init_and_deinit_evt_for_a2dp_4_2' into 'release/v4.2'
feature/ Add A2DP Init and Deinit Complete Evt [backport v4.2]

See merge request espressif/esp-idf!12150
2021-03-05 12:19:18 +00:00
24157cc60a Merge branch 'fix/esp_tls_prevent_freeing_global_CA_store_after_each_request_v4.2' into 'release/v4.2'
fix(esp_tls): prevent freeing global CA store after each request (v4.2)

See merge request espressif/esp-idf!12631
2021-03-05 08:52:38 +00:00
a2ccb3c0ac protocomm: Fixed NULL check of allocated memory
Fixes one part of - https://github.com/espressif/esp-idf/issues/6440
2021-03-05 10:06:18 +05:30
a2e6db19e6 esp_tls: Fix misplaced paranthesis in esp_tls_mbedtls.c
Fixes one part of -  https://github.com/espressif/esp-idf/issues/6440
2021-03-05 10:06:10 +05:30
d66ad18853 Fix esp_tls: Prevent freeing of global ca store after each connection
when dynamic ssl buffers are enabled
2021-03-05 09:55:10 +05:30
e7435a75f5 Merge branch 'bugfix/phy_xpd_v4.2' into 'release/v4.2'
wifi: add set_xpd_sar override(backport v4.2)

See merge request espressif/esp-idf!11540
2021-03-04 08:41:17 +00:00
10d40bd526 Merge branch 'bugfix/correct_logging_timestamp_format_v4.2' into 'release/v4.2'
log: correct timestamp formatting to unsigned integer type (v4.2)

See merge request espressif/esp-idf!12611
2021-03-04 07:39:33 +00:00
60b6968e80 add API esp_spp_stop_srv_scn to stop a specific server 2021-03-04 15:33:47 +08:00
a177897f4d log: correct timestamp formatting to unsigned integer type
Closes https://github.com/espressif/esp-idf/issues/6226

Closes IDFGH-4393
2021-03-04 11:54:30 +05:30
1f3b6b2e6d esp_wifi: fix CSA and BAR crash issue. 2021-03-02 11:51:01 +08:00
2c85d01603 tools: Don't count BSS into the total image size 2021-03-01 14:39:42 +01:00
33236c9593 doc: update S2 flash encryption & secure boot docs 2021-03-01 17:48:17 +08:00
70de8f5158 components/bt: Fix crash in Bluetooth when esp_restart 2021-03-01 14:43:45 +08:00
77a78a22f6 Merge branch 'bugfix/esp_wifi_deinit_v4.2' into 'release/v4.2'
esp_wifi_deinit: Return ESP_ERR_WIFI_NOT_STOPPED if wifi is not stopped (v4.2)

See merge request espressif/esp-idf!12540
2021-03-01 05:32:08 +00:00
8375bb94a4 bugfix/if bta_hf_client_sco_co_out_data is called, it will crash when sco disconnected 2021-03-01 11:34:15 +08:00
9689f87887 esp_wifi_deinit: Return ESP_ERR_WIFI_NOT_STOPPED if wifi is not stopped
Add test case to test this workflow
2021-02-26 14:53:59 +05:30
66c89f1093 examples, esp_mesh: Fix internal ip mesh example to use transmit wrap function
Fixed regression caused by recent refactoring of WiFi Tx. If  wasn't defined all transmits end up in a crash.

Closes https://github.com/espressif/esp-idf/issues/6067
2021-02-26 07:50:00 +01:00
76b0097103 components/bt: Fix assert without sw coexist enabled 2021-02-26 14:29:34 +08:00
da809e92b7 docs: update S2 flash encryption docs 2021-02-26 01:42:04 +08:00
cf87e114cb deep_sleep: on S2 disable the brown out detector before deep sleeping
On S2 the brown out detector would occasionally trigger erroneously during deep sleep.

Disable it before sleeping to circumvent this issue.

Closes https://github.com/espressif/esp-idf/issues/6179
2021-02-25 14:58:50 +08:00
af8bc4c436 Merge branch 'bugfix/SECURE_DISABLE_ROM_DL_MODE_does_not_work_v4.2' into 'release/v4.2'
bootloader: SECURE_ENABLE_SECURE_ROM_DL_MODE cannot be y when SECURE_DISABLE_ROM_DL_MODE=y (v4.2)

See merge request espressif/esp-idf!12341
2021-02-24 09:40:44 +00:00
bfb14130ac bugfix:unhandle event when tg receive set_player_app_value cmd 2021-02-24 07:47:08 +00:00
807e864d7d Merge branch 'revert-983220e2_v4.2' into 'release/v4.2'
ci: enable RS485 related tests again (v4.2)

See merge request espressif/esp-idf!12463
2021-02-24 06:45:58 +00:00
d960752cd9 Merge branch 'docs/remove_rtd_pdf_link_v4.2' into 'release/v4.2'
docs: remove rtd pdf link (v4.2)

See merge request espressif/esp-idf!12466
2021-02-23 10:45:37 +00:00
c0ae1f03a4 docs: remove RTD download PDF links
PDF download is available from the version selector menu.
Read the docs links are out of date.
2021-02-23 11:39:33 +08:00
c4fe55d42a Revert "ci: temporarily disable RS485 related tests"
This reverts commit 983220e216
2021-02-23 11:00:37 +08:00
15f406ddb7 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-22 23:18:17 +08:00
e511dd58b3 Merge branch 'bugfix/freemodbus_fix_parity_propagation_issue_v42' into 'release/v4.2'
Bugfix/freemodbus fix parity propagation issue (Backport v4.2)

See merge request espressif/esp-idf!12389
2021-02-22 05:23:02 +00:00
af1ebd7e01 Merge branch 'bugfix/eclipse_make_decode_v4.2' into 'release/v4.2'
tools: Fix Eclipse build: “UnicodeDecodeError: 'ascii' codec can't decode byte” (v4.2)

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

See merge request espressif/esp-idf!12377
2021-02-19 15:52:45 +00:00
cbe966135e Merge branch 'bugfix/fix_enable_reset_provision_cause_device_crash_v4.2' into 'release/v4.2'
provisioning: Fix enable CONFIG_EXAMPLE_RESET_PROVISIONED will cause device crash [backport v4.2]

See merge request espressif/esp-idf!12352
2021-02-19 12:57:27 +00:00
9240750bf4 provisioning: Fix enable CONFIG_EXAMPLE_RESET_PROVISIONED will cause device crash 2021-02-19 11:31:51 +00:00
cd9237f871 Merge branch 'bugfix/ignore_null_valued_comb_key_4_2' into 'release/v4.2'
Bugfix/ignore null valued comb key 4 2

See merge request espressif/esp-idf!12346
2021-02-18 13:58:25 +00:00
zwj
1b1c917321 add connection parameter check 2021-02-18 09:39:01 +00:00
zwj
171e2c5b1e fix ble connection maximum latency is 499 2021-02-18 09:39:01 +00:00
zwj
6d8a3f0d94 disable bluedroid congest error log print 2021-02-18 09:39:01 +00:00
c759dade01 fix read multi char failed(GATT_27001) 2021-02-18 09:39:01 +00:00
2e949ca9ac fix add white list failed 2021-02-18 09:39:01 +00:00
zwj
5d514fdb35 fix bluedroid repair faild if the two most significant bits of public address is '01' 2021-02-18 09:39:01 +00:00
zwj
d5951d3c9e - fix congest return value
- fix system no rsp when doing disconnect
- fix no congest event when ssc do writing performance
2021-02-18 09:39:01 +00:00
zwj
70589fc49d fix ble read multi char err when the number of handles is more than 10 2021-02-18 09:39:01 +00:00
zwj
66b1f37c8b fix scan rsp length err 2021-02-18 09:39:01 +00:00
zwj
c5afe0ea2d fix vendor hci memory leak 2021-02-18 09:39:01 +00:00
8455518127 component/bt: Added check for NULL valued combination key. 2021-02-18 06:12:17 +00:00
24291f7a3b 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-18 06:12:17 +00:00
359509ccdc 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-18 06:12:17 +00:00
ceb11fd543 Merge branch 'bugfix/cmake_example_sdkconfig_path_v4.2' into 'release/v4.2'
cmake/example: Move idf_as_lib sdkconfig path to project, document configuring project (v4.2)

See merge request espressif/esp-idf!10859
2021-02-17 22:45:21 +00:00
be68c0e8d8 freemodbus: fix mb controller parity propagation issues
Closes https://github.com/espressif/esp-idf/issues/6377
2021-02-17 12:40:34 +01:00
2c66dfc089 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:05:33 +01:00
391b2ebcf0 Merge branch 'bugfix/softap_prov_cookies_v4.2' into 'release/v4.2'
protocomm_httpd: Use HTTP cookies to track session (v4.2)

See merge request espressif/esp-idf!12265
2021-02-11 10:42:42 +08:00
3b5b61f402 Fix eclipse build: “UnicodeDecodeError: 'ascii' codec can't decode byte”
Closes https://github.com/espressif/esp-idf/pull/6505
2021-02-10 12:49:56 +01:00
d228fc826c 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-10 15:47:29 +05:30
328254c631 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-10 15:47:28 +05:30
2dd5a87cf1 Merge branch 'bugfix/websocket_example_error_handling_v4.2' into 'release/v4.2'
ci: Fix websocket example test error handling

See merge request espressif/esp-idf!11657
2021-02-10 15:51:32 +08:00
4abc541d6f bootloader: SECURE_ENABLE_SECURE_ROM_DL_MODE cannot be y when SECURE_DISABLE_ROM_DL_MODE=y
Closes: https://github.com/espressif/esp-idf/pull/6442
2021-02-09 16:34:30 +08:00
1df0c17b98 Merge branch 'bugfix/ble_mesh_server_model_deinit_v4.2' into 'release/v4.2'
ble_mesh: stack: Fix deinit server models with no matching id (v4.2)

See merge request espressif/esp-idf!12314
2021-02-09 16:25:39 +08:00
660f41772c ci: Fix websocket example test error handling
If connection fails for websocket test, a second exception was generated in
__exit__
2021-02-09 06:59:56 +00:00
ea476f1731 Merge branch 'bugfix/SECURE_ENABLE_SECURE_ROM_DL_MODE_v4.2' into 'release/v4.2'
bootloader: Fix warnings caused by security features (v4.2)

See merge request espressif/esp-idf!12286
2021-02-09 11:06:50 +08:00
6514009b8a soc esp32: Removes parentheses from RTC_MEM_xyz macros that expand directly to single numbers
Not necessary in these cases, and prevents parens from expanding into the
assembly code added in the parent commit - a pattern which is accepted
by GCC assembler but illegal syntax for LLVM assembler.
2021-02-08 09:59:22 +11:00
7c5afa262d deep sleep: Calculate RTC CRC immediately before deep sleep, without using RAM
Fix for issues where RTC FAST memory is updated as part of going into deep
sleep. Very high risk if heaps are in RTC memory - in particular task stacks
may be in RTC memory, but also other variables.

Also fixes potential concurrency problems as RTC FAST memory is not accessible
by CPU during the CRC calculation itself.

Method:
- Disable interrupts (currently for single core only, will need update for S3)
- Load all registers before calculating CRC or going to sleep
2021-02-08 09:59:22 +11:00
bf9b9c5a97 esp_system: Add test case for using deep sleep wake stub when stack is in RTC memory
This test currently fails on ESP32 & ESP32-S2, fix will be in next commit.
2021-02-08 09:59:22 +11:00
lly
4070a6dc70 ble_mesh: stack: Fix deinit server models with no matching id 2021-02-07 11:18:31 +08:00
0ab739f72c Merge branch 'bugfix/ble_mesh_wifi_coexit_example_v4.2' into 'release/v4.2'
bugfix: Delete local variables to avoid null global variables (backport v4.2)

See merge request espressif/esp-idf!11372
2021-02-05 20:21:58 +08:00
3f46cb9789 Merge branch 'bugfix/ble_mesh_mbedtls_aes_fix_v4.2' into 'release/v4.2'
Bugfix/ble mesh mbedtls aes fix (v4.2)

See merge request espressif/esp-idf!12270
2021-02-05 14:46:00 +08:00
lly
c74c7fdb5a ble_mesh: stack: Fix mbedtls aes ctx not deallocated 2021-02-05 03:26:26 +00:00
lly
02d3d358b5 ble_mesh: stack: Fix mbedtls aes ctx not initialized 2021-02-05 03:26:26 +00:00
74e1613b17 Merge branch 'bugfix/nvs_close_nukes_all_handles_v4.2' into 'release/v4.2'
NVS: fixed deinit other partition's handles (v4.2)

See merge request espressif/esp-idf!11497
2021-02-05 10:06:37 +08:00
89cab3140d Merge branch 'bugfix/idf_monitor_baudrate_arg_crash_v4.2' into 'release/v4.2'
idf monitor: fix crash when monitor baudrate argument set (Backport v4.2)

See merge request espressif/esp-idf!9758
2021-02-05 10:06:07 +08:00
040f5c8e0a Merge branch 'bugfix/reenable_encrypted_partition_write_v4.2' into 'release/v4.2'
Re-enable encrypted flash read/writes even if flash encryption is disabled (v4.2)

See merge request espressif/esp-idf!12190
2021-02-05 01:05:04 +08:00
aa3efa6cf1 Merge branch 'bugfix/protocomm_http_print_v4.2' into 'release/v4.2'
protocomm_httpd: Change an info print to debug print as it isn't really required in the logs (v4.2)

See merge request espressif/esp-idf!12261
2021-02-04 23:09:28 +08:00
a8df2af065 bootloader: Fix warnings caused by security features
Closes: https://github.com/espressif/esp-idf/issues/6198
2021-02-04 22:24:25 +08:00
d254804a62 Fix A2DP Underrun Issue 2021-02-04 19:33:14 +08:00
7da388e52a add exception handling for iperf example's scan when no ap was found 2021-02-04 17:37:43 +08:00
5c6b9d0625 protocomm_httpd: Change an info print to debug print as it isn't really required in the logs 2021-02-04 15:02:52 +05:30
024aaeb201 fix smartconfig issue when router reply arp late 2021-02-04 11:23:06 +08:00
79aa9636b9 unit-test-app: disable encrypted flash read/write in psram config to fix build failure 2021-02-03 09:07:36 +00:00
19b7705b8d spi_flash: add config option to enable encrypted partition read/write
This feature can be disabled to save some IRAM (approx 1KB) for cases
where flash encryption feature is not required.
2021-02-03 09:07:36 +00:00
294fe8238c Revert "esp_partition: disable encrypted reads/writes if flash encryption is disabled"
This reverts commit bf35ef1ce7.

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

This revert adds the feature back which was removed around v4.0 timelines, and same
change will be backported to all releases (upto v4.0) for consistency.
2021-02-03 09:07:36 +00:00
0382c2e04e Merge branch 'bugfix/mcpwm_can_set_two_falut_signal_v4.2' into 'release/v4.2'
mcpwm: fix second fault line broken issue (v4.2)

See merge request espressif/esp-idf!12171
2021-02-03 14:49:16 +08:00
81680a633f Merge branch 'bugfix/ttfw_idf_find_artifacts_inaccurate_with_same_prefix_path_v4.2' into 'release/v4.2'
CI: fix the bug returns wrong artifact path when app_name is a subset of a longer one (v4.2)

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

See merge request espressif/esp-idf!12157
2021-02-03 03:46:24 +08:00
f697f475e5 Merge branch 'doc/uart_num_fix_v4.2' into 'release/v4.2'
docs: fix uart number naming error (v4.2)

See merge request espressif/esp-idf!12068
2021-02-02 16:08:33 +08:00
d9455d8587 CI: fix the bug returns wrong artifact path when app_name is a subset of a longer one 2021-02-02 11:14:06 +08:00
2ea3519964 Merge branch 'bugfix/update_howsmyssl_cert_v4.2' into 'release/v4.2'
examples/protocols: update www.howsmyssl.com certificate to fix test failures (v4.2)

See merge request espressif/esp-idf!12211
2021-02-01 20:25:00 +08:00
0dedf0e1f5 examples/protocols: update www.howsmyssl.com certificate to fix test failures 2021-02-01 11:01:35 +05:30
250805d991 docs: Update full-scale voltages for ESP32-S2 chip 2021-02-01 11:22:49 +08:00
48dc6e9347 mcpwm: fix second fault line broken
Closes: https://github.com/espressif/esp-idf/issues/6053
2021-01-27 14:56:33 +08:00
87b051c87a mcpwm: fix wrong capture edge 2021-01-27 14:56:33 +08:00
10f16c5d72 Merge branch 'bugfix/soc_caps_implicit_inc_v4.2' into 'release/v4.2'
HAL: explicitly include soc_caps.h  (v4.2)

See merge request espressif/esp-idf!11896
2021-01-27 10:33:42 +08:00
fd5f65a2d4 Make OTA example support keepalive 2021-01-26 14:09:13 +08:00
90218b4e9b Add options for esp_http_client and esp_websocket_client to support keepalive 2021-01-26 14:09:01 +08:00
cbca521e28 Modify esp-tls and tcp_transport to support keep alive for tcp and ssl connection 2021-01-26 14:08:45 +08:00
186ebc61e7 Add init & deinit event for a2dp 2021-01-26 10:51:47 +08:00
c4d0a384b0 Merge branch 'fix/esp_tls_fix_memory_leak_v4.2' into 'release/v4.2'
Fix/esp tls fix memory leak v4.2

See merge request espressif/esp-idf!12085
2021-01-22 21:37:58 +08:00
be26d45d78 Merge branch 'bugfix/httpd_session_close_lru_v4.2' into 'release/v4.2'
esp_http_server: Add flag in sock_db to identify httpd_sess_close is called from httpd_session_close_lru (v4.2)

See merge request espressif/esp-idf!12112
2021-01-22 21:22:11 +08:00
6b054fb4a6 Enable lru_purge_enable in simple HTTP server example 2021-01-22 15:33:57 +05:30
ecbf436de4 Merge branch 'bugfix/http_client_buffer_overread_v4.2' into 'release/v4.2'
esp_http_client: Fix buffer overread, update https_request example to use HTTP/1.1 (v4.2)

See merge request espressif/esp-idf!12108
2021-01-22 17:45:31 +08:00
4d1ada8ab5 Merge branch 'bugfix/misc_secure_boot_v4.2' into 'release/v4.2'
Bugfix/misc secure boot v2 (v4.2)

See merge request espressif/esp-idf!11743
2021-01-22 16:27:10 +08:00
1c732d7556 esp_http_server: Add lru_socket flag in sock_db to indicate httpd_sess_close is called from httpd_sess_close_lru 2021-01-22 11:16:10 +05:30
29feb17636 esp_http_client.c: Clear raw_len for response buffer after dispatching HTTP_EVENT_ON_FINISH event
Closes: https://github.com/espressif/esp-idf/issues/6146
2021-01-22 11:03:23 +05:30
7ceaac64bf Merge branch 'bugfix/secure_boot_sig_failed_crash_v4.2' into 'release/v4.2'
secure boot: Fix crash if signature verification fails in app (v4.2)

See merge request espressif/esp-idf!11924
2021-01-22 07:58:24 +08:00
84219fe844 esp_tls_wolfssl: Move order of crt_bundle check to match that in
esp_tls_mbedtls
2021-01-21 10:45:42 +05:30
a5cf243ea0 esp-tls: Fix mem leak when global_ca_store is freed 2021-01-21 10:45:18 +05:30
56de4bbc4d Merge branch 'bugfix/ble_mesh_node_set_name_status_check_v4.2' into 'release/v4.2'
ble_mesh: stack: Remove node set device name return status check (v4.2)

See merge request espressif/esp-idf!12081
2021-01-21 11:07:58 +08:00
7c9be015aa Merge branch 'bugfix/ble_mesh_proxy_client_net_resend_v4.2' into 'release/v4.2'
ble_mesh: stack: Fix proxy client may fail to resend msg (v4.2)

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

See merge request espressif/esp-idf!12077
2021-01-21 11:07:02 +08:00
lly
4510332e96 ble_mesh: stack: Remove node set device name return status check 2021-01-20 21:11:21 +08:00
lly
370e65ec8a ble_mesh: stack: Fix proxy client may fail to resend msg 2021-01-20 21:10:18 +08:00
lly
962b14d653 ble_mesh: stack: Use different random for each provisioning 2021-01-20 21:09:09 +08:00
d8ba0f9b0e docs: fix uart number naming error 2021-01-20 17:55:07 +08:00
967c07b6ae Merge branch 'bugfix/nvs_check_external_partition' into 'release/v4.2'
NVS: ensuring default partition

See merge request espressif/esp-idf!8934
2021-01-20 07:44:28 +08:00
ad47ed5ef1 Merge branch 'bugfix/mdns_txt_length_collision_v4.2' into 'release/v4.2'
mDNS: Fix of text length calculation when detecting a collision(Backport v4.2)

See merge request espressif/esp-idf!12029
2021-01-19 22:15:05 +08:00
db2ddebc23 Merge branch 'bugfix/ble_mesh_log_macro_v4.2' into 'release/v4.2'
ble_mesh: stack: Add prefix for log macros (v4.2)

See merge request espressif/esp-idf!12052
2021-01-19 17:34:05 +08:00
lly
f56fe3f877 ble_mesh: stack: Fix compile warning when log is disabled 2021-01-19 14:04:45 +08:00
lly
571da869f5 ble_mesh: ci: Add disable log sdkconfig test files 2021-01-19 14:04:45 +08:00
lly
d545f1223f ble_mesh: stack: Add prefix BLE_MESH_ for log related macros 2021-01-19 14:04:44 +08:00
8cd16b60f5 Merge branch 'bugfix/ppp_deinit_failure_v4.2' into 'release/v4.2'
esp_modem: Fixed race condition on exiting PPP mode (v4.2)

See merge request espressif/esp-idf!11870
2021-01-19 02:42:50 +08:00
a4525284bd Merge branch 'update/ble_mesh_set_hsl_states_v4.2' into 'release/v4.2'
ble_mesh: stack: Enable updating lighting hsl state (v4.2)

See merge request espressif/esp-idf!12036
2021-01-18 19:10:31 +08:00
e36282787e Merge branch 'bugfix/ble_mesh_build_error_c3_merge_master_v4.2' into 'release/v4.2'
Bugfix/ble mesh build error merge master (v4.2)

See merge request espressif/esp-idf!12038
2021-01-18 19:10:21 +08:00
b24ccd8a20 Merge branch 'bugfix/fix_iperf_example_crash_issue_v4.2' into 'release/v4.2'
Bugfix/fix iperf example crash issue v4.2 (backport v4.2)

See merge request espressif/esp-idf!12024
2021-01-18 19:09:37 +08:00
lly
c44dc1f262 ble_mesh: stack: Fix compile warning with BIT macro 2021-01-18 14:07:30 +08:00
lly
de166facd7 ble_mesh: stack: Update mesh max conn macro when using bluedroid 2021-01-18 14:07:24 +08:00
lly
71f4c476cb ble_mesh: stack: Enable updating lighting hsl state 2021-01-18 14:01:39 +08:00
b4735859d6 Merge branch 'bugfix/bluedroid_avoid_same_bdaddr_conn_v4.2' into 'release/v4.2'
Bluedroid: Do not connect if peer BD_ADDR is same as own BD_ADDR. (v4.2)

See merge request espressif/esp-idf!11990
2021-01-18 14:01:31 +08:00
28371f45a4 Merge branch 'bugfix/ppp_netif_free_v4.2' into 'release/v4.2'
esp-modem: Remove esp-netif destroy from modem network glue code (v4.2)

See merge request espressif/esp-idf!11872
2021-01-16 00:57:15 +08:00
84039dc77d esp_modem: Fixed race condition on exiting PPP mode
esp_modem_stop_ppp() stops both ppp netif and switches the modem back to
command mode. IF these two actions are not synchronised, we might
experience issues of
* active PPP session trying to send/receive uart-data
* command mode already active before modem switched to it
both resulting in crashes.
Fixed by introducing the transition mode and running these actions in sequence
* set esp-modem to transition mode
* enter command mode, wait for the reply or re-sync
* close the PPP netif
* wait until the netif closes
Other fixes include ignoring certain events if modem component not ready
or not in appropriate mode:
* ignoring all UART events comming from DTE with no DCE attached
* ignore pattern detection in PPP mode
2021-01-15 17:38:30 +01:00
67a3ff8a4b Merge branch 'bugfix/esp_netif_ppp_event_data_v4.2' into 'release/v4.2'
esp-netif: Fix PPP netif event posting to include esp_netif data (v4.2)

See merge request espressif/esp-idf!11868
2021-01-15 23:48:27 +08:00
500edd412a mDNS: Fix of text length calculation when detecting a collision 2021-01-15 17:11:14 +04:00
cc0ad534e9 mDNS: Fix of collision detection during txt length calculation
Closes https://github.com/espressif/esp-idf/issues/6114
2021-01-15 17:10:35 +04:00
b78fbdab12 example: Scan failure should not cause system crash 2021-01-15 20:21:35 +08:00
30becdfaab example: do not check the return value of esp_wifi_connect() 2021-01-15 20:20:17 +08:00
95c360fcbd 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 13:18:06 +01:00
7ff123562b Merge branch 'bugfix/mdns_resolve_nonstrict_answers_v4.2' into 'release/v4.2'
mdns: Allow resolve (it's own) non-strict answers (v4.2)

See merge request espressif/esp-idf!11818
2021-01-15 19:51:04 +08:00
53fc156adb esp-modem: Remove esp-netif destroy from modem network glue code
To be in line with other interfaces, when deleting the driver and it's glue layer to esp-netif, we DO NOT delete the related esp-netif (since is was allocated and created outside of the glue code and it works the same way in esp-eth and esp-wifi driver/glue layers).

Closes https://github.com/espressif/esp-idf/issues/5486
2021-01-15 11:48:26 +00:00
cf7bea6dff idf monitor: fix crash when monitor baudrate argument set
Closes IDF-1902
2021-01-15 09:09:49 +00:00
67fb958b8c Merge branch 'bugfix/ble_mesh_macro_OR_v4.2' into 'release/v4.2'
ble_mesh: stack: Fix using wrong | for OR between macros (v4.2)

See merge request espressif/esp-idf!11997
2021-01-15 11:04:47 +08:00
lly
cd1fbfdee1 ble_mesh: stack: Fix using wrong | for OR between macros 2021-01-14 19:03:00 +08:00
8911c29122 Merge branch 'feat/ble_mesh_support_ble_scan_v4.2' into 'release/v4.2'
ble_mesh: stack: Add BLE scan callback when mesh is enabled (v4.2)

See merge request espressif/esp-idf!11963
2021-01-14 19:01:05 +08:00
lly
a3fa7dda33 ble_mesh: ci: Add ble & ble mesh coex sdkconfig test files 2021-01-14 07:30:47 +00:00
lly
c8890a40e4 ble_mesh: stack: Support reporting normal ble adv packets 2021-01-14 07:30:47 +00:00
lly
a91addb716 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-14 07:30:47 +00:00
lly
396c6a3bc5 ble_mesh: stack: Move ble scan funcitons to a single file 2021-01-14 07:30:47 +00:00
lly
96182bdc43 ble_mesh: stack: Optimize handling received mesh adv packets 2021-01-14 07:30:47 +00:00
4cfece437d Bluedroid: Do not connect if peer BD_ADDR is same as own BD_ADDR. 2021-01-14 12:22:30 +05:30
73023f7ff7 Merge branch 'ci/increase_build_example_parallel_count' into 'release/v4.2'
ci: Add 1 parallel count for building example

See merge request espressif/esp-idf!11976
2021-01-14 14:33:26 +08:00
lly
bd0f520a95 ci: Add 1 parallel count for building example 2021-01-13 16:21:15 +08:00
e5553b964d Merge branch 'fix/esp_tls_add_warning_if_ca_chain_has_invalid_cert_v4.2' into 'release/v4.2'
esp_tls: Add warning if the CA chain provided contains invalid cert (v4.2)

See merge request espressif/esp-idf!11939
2021-01-12 23:26:32 +08:00
7453507d93 Secure boot v2: Fixes the issue of passing the flash calculated digest for ota verification. 2021-01-12 11:16:23 +00:00
b979dacc6c Secure Boot v2: Fix the double padding of the image length during flash encryption
Fixes https://github.com/espressif/esp-idf/issues/6236
2021-01-12 11:16:23 +00:00
21eac48ea0 Merge branch 'optimize/ble_mesh_miscellaneous_v4.2' into 'release/v4.2'
Optimize/ble mesh miscellaneous (v4.2)

See merge request espressif/esp-idf!11948
2021-01-12 19:13:08 +08:00
lly
fe6103c088 ble_mesh: stack: Move bt_mesh_rand to mesh_common.c 2021-01-11 19:26:49 +08:00
lly
f031dc6d29 ble_mesh: stack: Remove useless BT_DBG_ENABLED in a few files 2021-01-11 19:26:49 +08:00
lly
85de3a84e1 ble_mesh: Replace zephyr integer types with C99 types [Zephyr] 2021-01-11 19:26:46 +08:00
lly
3f361cc262 ble_mesh: stack: Update ARRAY_SIZE definition 2021-01-11 19:25:52 +08:00
8f20b9dc8a Merge branch 'feat/ble_mesh_multiple_nvs_namespace_v4.2' into 'release/v4.2'
ble_mesh: stack: Provisioner supports multiple nvs namespaces (v4.2)

See merge request espressif/esp-idf!11935
2021-01-11 18:55:22 +08:00
e33cfbaef9 esp_tls: Add warning if the CA chain provided contains one/more invalid
cert
2021-01-11 12:02:30 +05:30
60a808372e Merge branch 'feature/upgrade_mbedtls_to_v4.2' into 'release/v4.2'
mbedtls: upgrade to v2.16.9 release (v4.2)

See merge request espressif/esp-idf!11899
2021-01-11 14:01:11 +08:00
lly
3a1018f603 ble_mesh: ci: Add settings sdkconfig test files 2021-01-11 10:08:00 +08:00
lly
c5d9601e69 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:07:55 +08:00
2aafcd9b1f Merge branch 'feat/ble_mesh_provisioner_recv_hb_support_v4.2' into 'release/v4.2'
Feat/ble mesh provisioner recv hb support (v4.2)

See merge request espressif/esp-idf!11913
2021-01-08 18:30:35 +08:00
0e4f43ddde secure boot v2: Fix crash if signature verification fails in app
sha_handle is "finished" when verify_secure_boot_signature() returns and
should be nulled out.

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

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

Signed-off-by: Angus Gratton <angus@espressif.com>
2021-01-08 18:45:49 +11:00
0c3c09e7ef Merge branch 'bugfix/icmp_echo_test_v4.2' into 'release/v4.2'
CI: change icmp example test address to ci.espressif.cn (v4.2)

See merge request espressif/esp-idf!11903
2021-01-08 11:16:15 +08:00
lly
1efa401884 ble_mesh: ci: Add enabling hb recv sdkconfig file 2021-01-08 09:32:23 +08:00
lly
0432d11509 ble_mesh: stack: Provisioner supports receiving heartbeat 2021-01-08 09:32:23 +08:00
8c4839e9e6 CI: change icmp example test address
Use a server that is inside the great firewall of china for CI test.
This avoid issues due to proxies, network configs etc.
2021-01-07 14:49:29 +08:00
ce72deea7f 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:15:42 +05:30
5e9783f4a6 hal: include pcnt_caps.h
Some HAL files depend on x_caps.h, but didnt explicitly include it

Fixes issue where only 4 PCNT (out of 8) could be used on ESP32

Closes https://github.com/espressif/esp-idf/issues/6366
2021-01-07 03:01:55 +00:00
474224d668 Merge branch 'bugfix/ble_mesh_node_id_adv_v4.2' into 'release/v4.2'
ble_mesh: stack: Fix Node ID adv with wrong timeout (v4.2)

See merge request espressif/esp-idf!11877
2021-01-06 17:08:21 +08:00
lly
53935d5933 ble_mesh: stack: Fix Node ID adv with wrong timeout 2021-01-06 05:33:41 +00:00
47aa7408f5 Merge branch 'bugfix/fix_tx_issue_after_esp_restart_v4.2' into 'release/v4.2'
components/bt: Shutdown Bluetooth before esp_restart. (V4.2)

See merge request espressif/esp-idf!11755
2021-01-06 12:32:33 +08:00
70ecd0e92c Merge branch 'bugfix/btdm_blufi_send_custom_data_will_congested_after_connection_is_broken_v4.2' into 'release/v4.2'
component/bt: fix Blufi sends customer data will congested when connection is broken(backport v4.2)

See merge request espressif/esp-idf!11847
2021-01-06 12:29:44 +08:00
caddd5d9fa Merge branch 'bugfix/fix_spp_vfs_dynamic_memory_bugs_v4.2' into 'release/v4.2'
component_bt/fix spp vfs demo crash when use dynamic memory[backport v4.2]

See merge request espressif/esp-idf!11726
2021-01-06 12:20:22 +08:00
c5b2252e03 esp-netif: Fix PPP netif event posting to include esp_netif data
Closes https://github.com/espressif/esp-idf/issues/6009
2021-01-04 16:41:25 +01:00
f3c9a71138 components/bt: Add API to config QoS 2021-01-04 11:53:04 +08:00
5da8c3f8de component/bt: fix Blufi sends customer data will congested when connection is broken 2020-12-31 15:38:49 +08:00
248857bf91 Merge branch 'fix/i2c_pm_lock_v4.2' into 'release/v4.2'
i2c: Acquire PM lock after acquiring mutex (v4.2)

See merge request espressif/esp-idf!11830
2020-12-31 12:33:36 +08:00
6216f99265 Merge branch 'fix/wolfssl_domain_name_check_v4.2' into 'release/v4.2'
esp_tls_wolfssl : Add domain name check (v4.2)

See merge request espressif/esp-idf!11816
2020-12-30 21:48:31 +08:00
6d6fbc3860 1. Optimize 32k xtal configure param to get optimal startup time for ESP32S2;
2. Solve bug of wakeup fail when pd peripheral for ESP32S2;
3. clear rtc force pu configuration when goto deepsleep after lightsleep.
2020-12-30 16:47:41 +08:00
14587e7e73 i2c: Acquire PM lock after acquiring mutex 2020-12-30 13:24:38 +05:30
9f9013c8c3 mdns: Allow resolve its own non-strict answers
the mDNS responder should not repeat questions when replying, however resolvers
must ignore these questions field if they are present. esp-idf mDNS
library does include questions in answering packets (thus not strictly
following the RFC6762) so the resolver did not correctly resolved
another instance host name.

Closes https://github.com/espressif/esp-idf/issues/6190
2020-12-29 19:05:11 +01:00
076ad543fb esp_tls_wolfssl : Add domain name check 2020-12-29 21:11:08 +05:30
24f98bf80b Merge branch 'bugfix/crt_bundle_bad_md_v4.2' into 'release/v4.2'
esp_crt_bundle: allow weak hash algorithm for trusted certificate (backport v4.2)

See merge request espressif/esp-idf!11655
2020-12-28 22:30:16 +08:00
4360410107 Merge branch 'bugfix/tools_python_subprocess_capture_output_v4.2' into 'release/v4.2'
tools: Avoid subprocess.run(capture_output) argument for Python <3.7 compatibility (v4.2)

See merge request espressif/esp-idf!11506
2020-12-28 07:45:51 +08:00
68095a65ac Merge branch 'bugfix/bt_bluedroid_same_public_key_attack_v4.2' into 'release/v4.2'
Bluedroid: Fixes for some Bluetooth vulnerabilities. (v4.2)

See merge request espressif/esp-idf!11763
2020-12-25 23:35:15 +08:00
235628355f 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:11 +05:30
567562a0fb components/bt: Add QOS for SPP, to decrease the delay from slave to master 2020-12-25 14:51:15 +08:00
d694036789 components/bt: Shutdown Bluetooth before esp_restart. 2020-12-25 14:06:22 +08:00
26ba5e1b51 nvs_flash: fixed deinit other partition's handles
* When deinitializing or erasing a partition,
  nvs used to close all handles instead of only
  the current partition's handles.
  This is fixed now
* Added a unit test for that case
* Unit tests clean up after each test case now

Closes FCS-533
2020-12-24 19:20:04 +08:00
ecc2dd4b23 Merge branch 'bugfix/ci_retries_when_download_v4.2' into 'release/v4.2'
CI: retry shell commands when download (v4.2)

See merge request espressif/esp-idf!9888
2020-12-24 16:20:12 +08:00
774fb48f9e Merge branch 'bugfix/spiram_reserve_size_pr5373_v4.2' into 'release/v4.2'
SPIRAM reserved memory size fixes (v4.2)

See merge request espressif/esp-idf!11516
2020-12-24 13:55:35 +08:00
40873d2026 fix spp vfs demo crash when use dynamic memory 2020-12-23 15:06:34 +08:00
ac5b7be7c2 Merge branch 'bugfix/fix_some_wifi_bugs_1222_v4.2' into 'release/v4.2'
esp_wifi: fix some wifi bugs 1222 (backport v4.2)

See merge request espressif/esp-idf!11711
2020-12-23 12:04:22 +08:00
c09a265f32 Merge branch 'bugfix/fix_crash_of_divide_zero_4_2' into 'release/v4.2'
Fix crash caused by dividing zero [backport v4.2]

See merge request espressif/esp-idf!11418
2020-12-23 11:20:48 +08:00
ef84e386e4 Fix divided by zero err & clear timer after remote reject when respond the parameters update 2020-12-22 16:37:31 +08:00
44b1c3b307 esp_wifi: update wifi lib 2020-12-22 16:05:39 +08:00
3acd9861bf wpa_supplicant: Use WPA3 flag to reduce code size
Flag ESP32_WIFI_ENABLE_WPA3_SAE from Menuconfig is used to
control the stack size required by WPA3. Use the same flag
to compile out the WPA3 code and control the code size.
With this flag disabled code footprint reduces by about 7.7kB
in libwpa_supplicant.a
Update WiFi libs with added checks to cleanly handle disabling
of WPA3 callbacks.
2020-12-22 15:50:52 +08:00
0bd758c0b1 WIFI: Iperf example's parameter opt was uninitialized, may leads setsockoption invalide if it equal to 0 2020-12-22 15:46:36 +08:00
12eb9d6d80 esp_wifi:
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-22 15:44:07 +08:00
33c296b78e 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-12-22 15:37:38 +08:00
e6d74b2d7e Merge branch 'ci/disable_dev_push_pipelines_v4.2' into 'release/v4.2'
CI: Disable pipelines generated by push on dev branches (v4.2)

See merge request espressif/esp-idf!11592
2020-12-22 13:11:49 +08:00
866399cbf7 Merge branch 'bugfix/pmf_tx_rx_routine_v4.2' into 'release/v4.2'
esp_wifi: Always register pmf tx/rx routines (backport v4.2)

See merge request espressif/esp-idf!11447
2020-12-22 00:02:31 +08:00
573708ea1e Merge branch 'fix/update_tls_sockfd_after_freeing_internally_v4.2' into 'release/v4.2'
esp-tls : (Fix) update tls->sockfd value after socket is freed internally (v4.2)

See merge request espressif/esp-idf!11695
2020-12-21 15:59:44 +08:00
4c66d146eb esp-tls : (Fix) update tls->sockfd value after socket is freed internally
Closes https://github.com/espressif/esp-idf/issues/6163
2020-12-21 11:23:22 +05:30
cfd234da3a Merge branch 'bugfix/exl200_reset_and_adv_v4.2' into 'release/v4.2'
Bugfix/exl200 reset and adv v4.2

See merge request espressif/esp-idf!11671
2020-12-18 21:54:06 +08:00
fd68c06824 Merge branch 'bugfix/doxygen_warnings_v4.2' into 'release/v4.2'
Docs: fix doxygen warnings (backport v4.2)

See merge request espressif/esp-idf!11674
2020-12-18 15:59:39 +08:00
d9cea5dfdb Docs: fix doxygen warnings 2020-12-18 14:27:17 +08:00
98a536894d components/bt:fix exl200, add btdm_disable_adv_delay, fix RPA addr update error. 2020-12-18 11:34:34 +08:00
9ca6aee845 components/bt: Fixed the problem of early release of pointer(p_ccb) in funcion 2020-12-18 11:32:31 +08:00
b1b673eaa2 Merge branch 'feature/lwip_tcp_isn_hook_v4.2' into 'release/v4.2'
lw-ip: enable TCP ISN hook (v4.2)

See merge request espressif/esp-idf!11062
2020-12-18 00:18:36 +08:00
a57576cec4 esp_netif: initialize TCP ISN hook if enabled in configuration 2020-12-17 13:42:01 +00:00
7d226ce542 lwip: provide configuration option to enable TCP ISN hook 2020-12-17 13:42:01 +00:00
4fb4178f06 tcp_isn: use ROM APIs for md5 calculations 2020-12-17 13:42:01 +00:00
aa416a377b lwip: add custom TCP ISN hook implementation
Source:
https://git.savannah.nongnu.org/cgit/lwip/lwip-contrib.git/
2020-12-17 13:42:01 +00:00
2b88ed8827 Merge branch 'bugfix/idf_gdb_no_openocd_crash_v4.2' into 'release/v4.2'
idf.py: Fixed gdb target to exit cleanly when no openocd watch task (v4.2)

See merge request espressif/esp-idf!10808
2020-12-17 18:40:31 +08:00
0386b19d8b Merge branch 'bugfix/mdns_query_id_v4.2' into 'release/v4.2'
mdns: Responding: Fix query ID, add questions if not strict mode (v4.2)

See merge request espressif/esp-idf!10806
2020-12-17 18:37:18 +08:00
683d0f4edb Merge branch 'nimble/fix_misc_coverity_issue_v4.2' into 'release/v4.2'
Nimble: Fix misc issues in NimBLE NVS, `ble_eddystone`, recursive call and  L2CAP CoC (v4.2)

See merge request espressif/esp-idf!11390
2020-12-17 16:53:46 +08:00
4bca971865 Merge branch 'bugfix/free_acl_rx_buf_in_em_4_2' into 'release/v4.2'
Free ACL RX Buf in EM when disconnection [backport v4.2]

See merge request espressif/esp-idf!11612
2020-12-17 16:47:46 +08:00
c1d5ad61b5 Free ACL RX Buf in EM when disconnection [backport v4.2] 2020-12-17 16:47:43 +08:00
d315bf722f 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:21:02 +00:00
210bd3787d 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:21:02 +00:00
dceb9b4a22 esp_crt_bundle: add additional unit tests
Add unit test for:
 * Trusted certificate with weak hash algorithm signature
 * Certificate with wrong signature

Merges https://github.com/espressif/esp-idf/pull/6117
2020-12-17 02:41:59 +00:00
a1d5fcfece esp_crt_bundle: Allow verify_callback to correct BADCERT_BAD_MD 2020-12-17 02:41:59 +00:00
211a2a9957 Merge branch 'fixbug/baidu_tcp_recv_assert_for_4.2' into 'release/v4.2'
lw-ip:fix bug for tcp recv assert(backport 4.2)

See merge request espressif/esp-idf!11601
2020-12-16 17:31:42 +08:00
b1b19495a1 Merge branch 'test/disable_twai_example_ci_v4.2' into 'release/v4.2'
Temporarily disable TWAI network example test (backport v4.2)

See merge request espressif/esp-idf!11561
2020-12-16 04:20:26 +08:00
6a723ad1e7 Merge branch 'bugfix/lwip_netdb_cpp_guards_v4.2' into 'release/v4.2'
lw-IP: Changed to C linkage in netdb.h for fixing bug when using mixed C/C++ code (v4.2)

See merge request espressif/esp-idf!11089
2020-12-16 04:13:12 +08:00
a82d0cf9f1 Merge branch 'bugfix/panic_instr_fetch_prohibited_v4.2' into 'release/v4.2'
panic: don't interrupt the backtrace for InstrFetchProhibited exceptions (v4.2)

See merge request espressif/esp-idf!10293
2020-12-16 04:09:37 +08:00
8224c75211 Merge branch 'bugfix/parttool_example_test_fail_v4.2' into 'release/v4.2'
examples/parttool: fix the test to work on parallel test runner (backport v4.2)

See merge request espressif/esp-idf!10373
2020-12-16 04:09:03 +08:00
e64934be6b Merge branch 'bugfix/docker_gdb_python_v4.2' into 'release/v4.2'
tools/docker: Add libpython2.7 in order to satisfy GDB dependencies (backport v4.2)

See merge request espressif/esp-idf!10307
2020-12-16 04:07:40 +08:00
e95f97d40e mdns test: Add test to resolve esp32 hostname with DiG 2020-12-15 19:01:33 +00:00
05211963ee examples: Common connect component: Unregister shutdown handler on disconnection
To be able to connect smoothly after disconnecting, we have to unregister all handlers including shutdown handler on disconnection
2020-12-15 19:01:33 +00:00
e1e481f438 mdns: Support queries in responses in mDNS non-strict mode
By default adds original queries to responses in order to be resolved by some resolvers, such as lwIP mdns library. This functionality however is discouraged by the RFC6762, so it could be disabled in menuconfig if MDNS_STRICT_MODE configured

Closes https://github.com/espressif/esp-idf/issues/5521
2020-12-15 19:01:33 +00:00
faef936581 mdns: Fix include query ID in reponses
Closes https://github.com/espressif/esp-idf/issues/5574
2020-12-15 19:01:33 +00:00
26bca96029 Merge branch 'bugfix/fix_transport_ssl_blocking_v4.2' into 'release/v4.2'
transport: fix transport ssl blocking (v4.2)

See merge request espressif/esp-idf!10691
2020-12-16 02:59:03 +08:00
a1e1470447 Merge branch 'bugfix/fix_esp_modem_mode_switch_timeout_v4.2' into 'release/v4.2'
fix esp_modem switch mode timeout (v4.2)

See merge request espressif/esp-idf!11395
2020-12-16 02:57:44 +08:00
9fb05897db Merge branch 'bugfix/ci_py2_warnings_fix_v4.2' into 'release/v4.2'
ci: Python 2 warnings fix (v4.2)

See merge request espressif/esp-idf!11617
2020-12-15 19:06:33 +08:00
c8d1b18a3c Merge branch 'bugfix/py2_socketio_v4.2' into 'release/v4.2'
tools: Fix requirements incompatible with Python 2 (v4.2)

See merge request espressif/esp-idf!11604
2020-12-15 18:38:43 +08:00
99cb0f25eb Merge branch 'bugfix/pppos_ignored_modem_start_return_v4.2' into 'release/v4.2'
pppos client: modem netif fix ignoring potential modem-start error (v4.2)

See merge request espressif/esp-idf!11394
2020-12-15 16:15:27 +08:00
99be1aca73 Merge branch 'bugfix/fix_netsuite_tx_wrap_v4.2' into 'release/v4.2'
CI: esp_netif tests: Fix netsuite driver layer per wifi optimization changes (v4.2)

See merge request espressif/esp-idf!11388
2020-12-15 16:14:45 +08:00
7fcb8ffe0a Merge branch 'feature/mqtt_submodule_update_23c8e1ec_v4.2' into 'release/v4.2'
MQTT: Update submodule reference to da850b (config, error flags, minor fixes) (v4.2)

See merge request espressif/esp-idf!11312
2020-12-15 16:13:03 +08:00
cbd0af7217 Merge branch 'bugfix/mdns_src_addr_cpy_v4.2' into 'release/v4.2'
mdns: Fix wrong mdns source address if lwIP IPv6 zoning disabled (v4.2)

See merge request espressif/esp-idf!11310
2020-12-15 16:10:55 +08:00
3b63476e31 Merge branch 'bugfix/backport_v4.2_fix_websocket_issue' into 'release/v4.2'
websocket_client: fix some issues for websocket client (backport v4.2)

See merge request espressif/esp-idf!11276
2020-12-15 16:10:12 +08:00
440b5f6e7b lwip: Changed to C linkage for fixing bug when using mixed C/C++ code
Merges https://github.com/espressif/esp-idf/pull/5900
2020-12-15 08:09:14 +00:00
97cd07007d ci: define ESP_PLATFORM macro during public header check 2020-12-15 08:09:14 +00:00
c0e3aa1ef8 transport: fix transport ssl blocking
In SSL mode, if `esp_transport_poll_read` function is used, the cache data in mebdtls will be blocked
2020-12-15 08:07:18 +00:00
e1d62cda5f Merge branch 'feature/ci_fix_docker_build_v4.2' into 'release/v4.2'
ci: Use git mirror for docker image (v4.2)

See merge request espressif/esp-idf!10445
2020-12-15 14:55:07 +08:00
8c3526d91f Merge branch 'bugfix/build_docs_pdf_job_v4.2' into 'release/v4.2'
docs: seperate build_docs html and pdf CI jobs (Backport v4.2)

See merge request espressif/esp-idf!10549
2020-12-15 14:54:00 +08:00
f5f91a4d05 tools: Redirect some warnings to stderr 2020-12-15 13:16:50 +07:00
3a5de540f1 ci: Ignore Python 2 deprecation warning 2020-12-15 13:16:03 +07:00
48cd4d65e6 Merge branch 'bugfix/redirection_v4.2' into 'release/v4.2'
esp_http_client: Skip check for redirection counter if status code is success, fix issue with digest auth, configurable user agent string. (v4.2)

See merge request espressif/esp-idf!11597
2020-12-14 20:03:03 +08:00
12a0f93f87 adc_i2s: solve the i2s_adc issue when using wifi 2020-12-14 19:33:35 +08:00
9ff5f94233 tools: Fix requirements incompatible with Python 2 2020-12-14 10:48:00 +01:00
72dbf03b6c fix bug for tcp recv assert 2020-12-14 17:42:51 +08:00
fad8a27cf7 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:02:50 +05:30
465d911052 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 13:58:29 +05:30
b951b5adec 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 13:58:28 +05:30
9fce81f9af esp_wifi: Update WiFi lib
1. Fixes the issue when PMF packets are not sent after mode change.
2. Add support for 802.1x sha256 auth key mode
2020-12-14 14:51:52 +08:00
4167401a00 CI: Disable pipelines generated by push on dev branches 2020-12-14 14:01:44 +08:00
18a1bc9e7f Merge branch 'bugfix/decouple_wifi_bt_with_coex_v4.2' into 'release/v4.2'
esp_wifi: decouple Wi-Fi and bluetooth with coexist to reduce binary file size(backport v4.2)

See merge request espressif/esp-idf!11542
2020-12-14 12:17:23 +08:00
a23449ee23 Merge branch 'optimize/ble_mesh_provision_dev_uuid_check_v4.2' into 'release/v4.2'
ble_mesh: stack: Need uuid when adding device for provisioning (v4.2)

See merge request espressif/esp-idf!11577
2020-12-14 10:15:44 +08:00
a46d8b2831 Merge branch 'bugfix/verify-directory-exists_v4.2' into 'release/v4.2'
Bugfix: add check for existence build directory (v4.2)

See merge request espressif/esp-idf!11581
2020-12-12 01:43:15 +08:00
lly
6510fbb66d ble_mesh: ci: Add PB-ADV & PB-GATT sdkconfig test files 2020-12-11 13:15:54 +00:00
lly
5f2a5cdcab ble_mesh: stack: Need uuid when adding device for provisioning 2020-12-11 13:15:54 +00:00
938b9f3098 Merge branch 'feat/ble_mesh_node_local_data_func_v4.2' into 'release/v4.2'
ble_mesh: stack: Add node local netkey/appkey func (v4.2)

See merge request espressif/esp-idf!11575
2020-12-11 21:13:57 +08:00
5bb0237860 Add checking if the build directory exists and move expression after docstring 2020-12-11 13:13:50 +01:00
c923c99f09 Merge branch 'feature/python2-deprecation-warn_v4.2' into 'release/v4.2'
Tools: Add Python 2 deprecation warning (v4.2)

See merge request espressif/esp-idf!11524
2020-12-11 17:26:06 +08:00
lly
7505e1458f ble_mesh: stack: Fix wrong declaration of node bind AppKey func 2020-12-11 17:19:02 +08:00
lly
d4575ccfe9 ble_mesh: stack: Add node local netkey/appkey func 2020-12-11 17:18:22 +08:00
71e7f000c4 Merge branch 'bugfix/log-error-run-esptool_v4.2' into 'release/v4.2'
parttool.py: Add file stream parameter and log stdout and stderr to same stream (v4.2)

See merge request espressif/esp-idf!10516
2020-12-11 16:51:48 +08:00
58afa32a1a Merge branch 'optimize/ble_mesh_reduce_code_size_v4.2' into 'release/v4.2'
Optimize/ble mesh reduce code size (v4.2)

See merge request espressif/esp-idf!11518
2020-12-11 16:50:51 +08:00
81eb9f280f add CN translation for adding python2 deprecation warning(MR 11115) 2020-12-11 09:16:18 +01:00
d0d7c53ee1 Tools: add Python 2 deprecation warning 2020-12-11 09:14:57 +01:00
19e6434f37 twai: Temporarily disable network example test
Disabling network example test due to issue with synchronizing the
start of each DUT
2020-12-10 21:27:46 +08:00
lly
6f104362c7 ble_mesh: example: Update sdkconfig test files for disabling Health Server model 2020-12-10 09:32:10 +00:00
lly
da8a577408 ble_mesh: stack: Add a Kconfig option to make Health Server model optional 2020-12-10 09:32:10 +00:00
lly
2b2abcd6f9 ble_mesh: stack: Split model Kconfig menu into foundation and others 2020-12-10 09:32:10 +00:00
lly
5fd4d53922 ble_mesh: example: Fix fast provisioning compile error 2020-12-10 09:32:10 +00:00
lly
7f1a0e1552 ble_mesh: ci: Add disabling mesh model sdkconfig test files 2020-12-10 09:32:10 +00:00
lly
e4451376f3 ble_mesh: stack: Add Kconfig options to make server models optional 2020-12-10 09:32:10 +00:00
lly
2602f26753 ble_mesh: stack: Use Kconfig option to make client models optional 2020-12-10 09:32:10 +00:00
lly
9c8c56f081 ble_mesh: stack: Make some internal static functions inline 2020-12-10 09:32:10 +00:00
lly
7e945e5fa8 ble_mesh: ci: Add disabling mesh deinit sdkconfig test files 2020-12-10 09:32:10 +00:00
lly
f27a151478 ble_mesh: stack: Add a Kconfig option to make deinit optional 2020-12-10 09:32:10 +00:00
lly
01d0843c4d ble_mesh: stack: Introduce a new header file mesh_config.h 2020-12-10 09:32:10 +00:00
1771aea076 Merge branch 'bugfix/increase_ci_build_example_parallel' into 'release/v4.2'
ci: Add 1 parallel count for building example

See merge request espressif/esp-idf!11554
2020-12-10 17:09:47 +08:00
lly
c3c0ca0aff ci: Add 1 parallel count for building example 2020-12-10 13:59:36 +08:00
22b33adb2f Merge branch 'optimization/AP_STAIPASSIGNED_passes_IP_send_through_event_data_for_4.2' into 'release/v4.2'
esp-event:AP_STAIPASSIGNED now passes the IP through 'event_data'(backport 4.2)

See merge request espressif/esp-idf!11241
2020-12-09 22:32:19 +08:00
e287e3ef9d Merge branch 'bugfix/backport_some_lwip_bugs_1120_v4.2' into 'release/v4.2'
lw-ip:backport bugfix lwip for v4.2(backport 4.2)

See merge request espressif/esp-idf!11307
2020-12-09 22:31:32 +08:00
f03d543139 Merge branch 'bugfix/blufi_config_potential_double_free_v4.2' into 'release/v4.2'
Bugfix/blufi config potential double free v4.2

See merge request espressif/esp-idf!11163
2020-12-09 22:26:19 +08:00
5a17387c3d esp_wifi: decouple Wi-Fi and bluetooth with coexist to reduce binary file size 2020-12-09 20:42:35 +08:00
996e270f90 Merge branch 'doc/update_CN_translation_for_relase/v4.2' into 'release/v4.2'
update CN translation for index.rst and vscode-setup.rst in get-started folder (v4.2)

See merge request espressif/esp-idf!11522
2020-12-09 19:13:25 +08:00
4ff9a93490 update CN translation for index.rst and add CN translation for vscode-setup.rst in get-started folder 2020-12-09 19:13:25 +08:00
f5c45576cf Merge branch 'feature/btdm_support_some_ble_new_features_v4.2' into 'release/v4.2'
components/bt: backport some new features for Bluedroid BLE(release v4.2)

See merge request espressif/esp-idf!11448
2020-12-09 10:28:56 +08:00
2532ddd9f4 Merge branch 'bugfix/ble_mesh_proxy_cfg_replay_v4.2' into 'release/v4.2'
Bugfix/ble mesh proxy cfg replay (v4.2)

See merge request espressif/esp-idf!11509
2020-12-08 15:00:51 +08:00
d1a9f9ec74 Fix reserved psram region
Closes https://github.com/espressif/esp-idf/pull/5373

Closes https://github.com/espressif/esp-idf/issues/5821
2020-12-08 17:42:36 +11:00
lly
e2cb5ee379 ble_mesh: stack: Store kr phase after value changed [Zephyr] 2020-12-08 11:51:28 +08:00
lly
0c8cf83131 ble_mesh: stack: Fix rpl not check by proxy cfg [Zephyr] 2020-12-08 11:51:23 +08:00
2ef417df5f Merge branch 'docs/update_rtc_clock_source_description_in_api_references_backport_v4.2' into 'release/v4.2'
docs: update the description for RTC Clock Sources for esp32 and esp32s2 (backport/v4.2)

See merge request espressif/esp-idf!11329
2020-12-08 10:47:42 +08:00
452992bcd5 Merge branch 'bugfix/remove_shortcut_to_build_instructions_v4.2' into 'release/v4.2'
doc: Getting Started Guide, remove shortcuts to 'build toolchain from scratch' instructions (v4.2)

See merge request espressif/esp-idf!10597
2020-12-08 10:46:42 +08:00
c2f08b3e35 Merge branch 'bugfix/ble_mesh_node_deinit_v4.2' into 'release/v4.2'
ble_mesh: stack: Persistent storage misc fixes (v4.2)

See merge request espressif/esp-idf!11503
2020-12-08 10:28:46 +08:00
49dde3ca91 Merge branch 'bugfix/cast_int_to_size_t_in_cpu_ll_v4.2' into 'release/v4.2'
soc: cast int to size_t in cpu_ll (v4.2)

See merge request espressif/esp-idf!11135
2020-12-08 09:10:19 +08:00
cf644d4de3 Merge branch 'bugfix/check_doc_links_no_deploy_v4.2' into 'release/v4.2'
CI: Only run check_doc_links if we actually deployed (v4.2)

See merge request espressif/esp-idf!10955
2020-12-08 09:08:03 +08:00
fb81c46999 Merge branch 'bugfix/esp_idf_version_v4.2' into 'release/v4.2'
Add __ASSEMBLER__ flag in esp_idf_version.h to fix build failure with assembly files (v4.2)

See merge request espressif/esp-idf!10899
2020-12-08 09:07:51 +08:00
addabc392d Merge branch 'bugfix/ldgen_unicode_path_v4.2' into 'release/v4.2'
tools/ldgen: Parse paths with Unicode characters in archives & fix parsing of section names on Windows (v4.2)

See merge request espressif/esp-idf!10964
2020-12-08 09:07:47 +08:00
8a47006b72 Merge branch 'bugfix/backport_v4.2_fix_pthread_priority_inheritance' into 'release/v4.2'
pthread: fix the priority inheritance (backport v4.2)

See merge request espressif/esp-idf!11260
2020-12-08 09:07:23 +08:00
1591141237 Merge branch 'bugfix/err_to_name_paths_windows_v4.2' into 'release/v4.2'
tools: fix path handling errors in gen_esp_err_to_name.py for Windows (v4.2)

See merge request espressif/esp-idf!10895
2020-12-08 09:06:59 +08:00
74c7a84c4c Merge branch 'bugfix/secure_boot_v2_manual_enablement_v4.2' into 'release/v4.2'
Secure Boot V2: Fix an issue leading to manual enablement of Secure Boot v2. (v4.2)

See merge request espressif/esp-idf!11228
2020-12-08 09:06:29 +08:00
5cc8660a32 Merge branch 'bugfix/rtc_clk_cal_cycles_add_default_vals_for_all_sources_v4.2' into 'release/v4.2'
esp32xx: Fix default values for all RTC sources in RTC_CLK_CAL_CYCLES option (v4.2)

See merge request espressif/esp-idf!11412
2020-12-08 09:06:21 +08:00
82bcdcaeaf Merge branch 'bugfix/fix_partition_table_in_flash_encryption_example_v4.2' into 'release/v4.2'
example/flash_encryption: Fix partition table (v4.2)

See merge request espressif/esp-idf!10851
2020-12-08 09:06:07 +08:00
117be7a870 Merge branch 'bugfix/blecent_example_test_4.2' into 'release/v4.2'
Fix CI blecent example test (backport v4.2)

See merge request espressif/esp-idf!11271
2020-12-08 09:01:45 +08:00
244922a3e3 tools: Avoid subprocess.run(capture_output) argument for Python <3.7 compatibility
In Python 3.5 and 3.6 the equivalent to capture_output=True is to set stdout
and stderr arguments to subprocess.PIPE
2020-12-08 09:44:31 +11:00
lly
922abdc51b 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-12-07 12:05:56 +00:00
59ad2b48ee Merge branch 'bugfix/fix_node_test_func_not_set_role_v4.2' into 'release/v4.2'
ble_mesh: test: Fix node test function not update role flag (v4.2)

See merge request espressif/esp-idf!11040
2020-12-07 19:56:55 +08:00
0c75a3a8e7 Merge branch 'bugfix/ble_mesh_autorsp_description_v4.2' into 'release/v4.2'
esp_ble_mesh: api: fixed comment about autoresp (v4.2)

See merge request espressif/esp-idf!10888
2020-12-07 19:56:52 +08:00
c667af2683 Merge branch 'optimize/ble_mesh_gattc_conn_param_v4.2' into 'release/v4.2'
ble_mesh: stack: Update connection parameters used by Central (v4.2)

See merge request espressif/esp-idf!11328
2020-12-07 19:55:51 +08:00
305bc4983f Merge branch 'fix/protocomm_simple_ble_v4.2' into 'release/v4.2'
Protocomm/simple_ble: Fix gatt table map size to number of handles received (v4.2)

See merge request espressif/esp-idf!11264
2020-12-07 16:18:07 +08:00
171eddcd01 Merge branch 'feature/esp_cryptoauthlib_sub_update_v4.2' into 'release/v4.2'
esp-cryptoauthlib: Update submodule pointer to add a new feature. (v4.2)

See merge request espressif/esp-idf!10830
2020-12-07 16:15:13 +08:00
7dc03f16e7 Merge branch 'bugfix/twai_backport_accumulated_fixes_v4.2' into 'release/v4.2'
TWAI backport accumulated fixes (backport v4.2)

See merge request espressif/esp-idf!11459
2020-12-07 15:52:04 +08:00
c40f2590bf Merge branch 'featrue/remove_esp32-S2_preview_v4.2' into 'release/v4.2'
docs: ESP-IDF v4.2 fully supports ESP32-S2, remove documentation that describe preview support (v4.2)

See merge request espressif/esp-idf!11467
2020-12-04 08:33:44 +08:00
1f3d8588ae docs: ESP-IDF v4.2 fully supports ESP32-S2, remove documentation that describe preview support 2020-12-04 10:09:07 +11:00
a0bb9b2f57 TWAI: ISR runs when cache is disabled
This commit adds the feature where the TWAI 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_TWAI_ISR_IN_IRAM option.
2020-12-03 19:41:59 +08:00
9dbf59af9c component/bt: support BLE Read Attribute value by UUID 2020-12-03 15:19:44 +08:00
4e8d383d01 component/bt: refactor ble random address setting 2020-12-03 15:19:35 +08:00
8533c452a1 component/bt: support BLE Application Layer Encryption key size check 2020-12-03 15:19:27 +08:00
82b65d5de0 component/bt: support BLE Authorization 2020-12-03 15:19:17 +08:00
0740090682 component/bt: fix incorrect encryption flag setting 2020-12-03 15:19:02 +08:00
901dce43d0 Merge branch 'bugfix/update_release_v4.2_bt_lib' into 'release/v4.2'
components/bt: backport requires commit to release v4.2

See merge request espressif/esp-idf!11426
2020-12-03 11:22:13 +08:00
fa7c5fcd42 TWAI: Fix BRP field initialization onf ESP32 ECO3
This commit zero initializes the brp_div field on ESP32 ECO3
to prevent incorrect timing configuration.
2020-12-02 21:27:12 +08:00
1160da7fdf TWAI: Fix ESP32-S2 register field name 2020-12-02 21:27:12 +08:00
e1b7a02786 TWAI: Simplify caps header
This commit simplifies the defines made in the _caps.h header. Kconfig
option dependencies were moved into the LL, and the check for a
valid BRP has bee simplified.
2020-12-02 21:26:33 +08:00
d780e5b31d components/bt: backport requires commit to release v4.2 2020-12-01 19:29:05 +08:00
4c533a1e53 ci: Fix blecent example test
(cherry picked from commit fc146a98e4)
2020-11-30 22:44:52 +05:30
3d03264b0a 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:09:13 +08:00
6270de58ad fix esp_modem switch mode timeout
Closes https://github.com/espressif/esp-idf/issues/3506
Closes https://github.com/espressif/esp-idf/issues/4324
2020-11-27 20:11:38 +01:00
99cb5a7c8d pppos client: modem netif fix ignoring potential modem-start error
esp-modem netif glue layer implements esp-netif attach callback to setup corresponding driver functions and start the modem. The error code of esp_modem_start_ppp() was ignored and ESP_OK returned in all cases. Fixed by passing esp_modem_start_ppp()'s error code to post_attach callback.

Closes https://github.com/espressif/esp-idf/issues/5430
2020-11-27 20:10:06 +01:00
bdc914bbf4 CI: esp_netif tests: Fix netsuite driver layer per wifi optimization changes
esp-wifi introcuded wifi tx optimization in !9147 . Update needed in netsuite to pass the tx data using  function

Closes https://github.com/espressif/esp-idf/issues/6161
2020-11-27 12:00:07 +01:00
cd045c60d9 bugfix: Delete local variables to avoid null global variables 2020-11-25 20:52:27 +08:00
1be101f342 component/bt: Add a macro to control the compilation of blufi. 2020-11-24 10:44:57 +08:00
7097ff286c component/bt: Fix a potential double free error. 2020-11-24 10:44:56 +08:00
65c5a57033 blufi: fix an error caused by incorrect conn_id parameters. 2020-11-24 10:44:54 +08:00
f3ff3b3073 Merge branch 'ci/fix_annotated_tag_check_v4.2' into 'release/v4.2'
ci: Fix annotated tag check (v4.2)

See merge request espressif/esp-idf!11331
2020-11-23 17:30:21 +08:00
19bc67e146 ci: Fix annotated tag check
Regression in 1612f84
2020-11-23 17:27:12 +11:00
e9dae152cd docs: update the description for RTC Clock Sources for esp32 and esp32s2 2020-11-23 11:37:15 +08:00
lly
e2b6ab00dc ble_mesh: stack: Update connection interval to 15ms 2020-11-23 08:59:23 +08:00
lly
92eebb885c ble_mesh: stack: Update connection parameters used by Central 2020-11-23 08:59:22 +08:00
c4e4a05002 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:24:18 +01:00
405f2ee995 mdns: Fix wrong mdns source address if lwIP IPv6 zones disabled
The struct definition of ip6_addr_t in lwip and esp_ip6_addr_t
differs since zone could be possibly disabled in lwip. Using memcpy to copy the
address will cause wrong source address. Copy the entries manually
instead.

Merges https://github.com/espressif/esp-idf/pull/6055
2020-11-20 10:15:33 +01:00
501fce7fdd backport bugfix lwip for v4.2 2020-11-20 14:44:13 +08:00
3c2367d158 i2s: fix i2s ll layer pdm config 2020-11-19 11:42:53 +00:00
2a4c338ac4 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-19 15:59:47 +08:00
6928e6b5b0 Protocomm/simple_ble: Make gatt table map size equal to number of handles received (v4.2)
- Fixes memcpy failure observed while adding 2 or more endpoints in
  wifi_provisioning.

 Closes IDF-2250
2020-11-17 14:59:46 +05:30
511965b269 Merge branch 'fix/esp_local_ctrl_update_expired_cert_v4.2' into 'release/v4.2'
esp_local_ctrl: Updated the expired cacert.pem (v4.2)

See merge request espressif/esp-idf!11206
2020-11-17 15:14:57 +08:00
cc10f1943c pthread: fix the priority inheritance
When `pthread_mutex_destroy` is used to release mutex, `pthread_mutex_lock_internal` is used,
     which results in the increase of `uxmutexehold` and no recovery base priority
2020-11-17 14:48:43 +08:00
e0a02c1a7c AP_STAIPASSIGNED now passes the IP through 'event_data'
Signed-off-by: xueyunfei <xueyunfei@espressif.com>
2020-11-16 17:43:51 +08:00
eae8933b85 ci: use the retry script to download 2020-11-16 11:30:47 +07:00
dd6405fcef Secure Boot V2: Fix an issue leading to manual enablement of Secure Boot v2.
Fixes https://github.com/espressif/esp-idf/issues/6050
2020-11-13 11:33:29 +05:30
c2fbda0e6d esp_local_ctrl: Updated the expired cacert.pem 2020-11-12 10:16:22 +05:30
c688828362 Merge branch 'bugfix/efuse_change_burn_order_for_s2_s3_v4.2' into 'release/v4.2'
efuse: Fix the order of writing in batch mode (v4.2)

See merge request espressif/esp-idf!11123
2020-11-11 14:50:53 +08:00
9c239b9f77 Merge branch 'bugfix/fix_assert_in_passkey_reply_4_2' into 'release/v4.2'
Bugfix/fix assert in passkey reply [backport v4.2]

See merge request espressif/esp-idf!10974
2020-11-11 11:35:41 +08:00
5de9174ade Merge branch 'bugfix/fix_crash_caused_by_calling_deinit_directly_4_2' into 'release/v4.2'
Fix crash caused by calling a2dp_deinit directly [backport v4.2]

See merge request espressif/esp-idf!11130
2020-11-11 11:35:06 +08:00
abb7c529dc Merge branch 'bugfix/wpa3_pmkcache_expiry_workaround_v4.2' into 'release/v4.2'
wpa_supplicant: Increase PMK Lifetime to a very high value (Backport v4.2)

See merge request espressif/esp-idf!11170
2020-11-11 11:29:36 +08:00
fe78f2cf3b Merge branch 'bugfix/wifi_fix_beacon_dtim_count_error_v4.2' into 'release/v4.2'
Wi-Fi: set softap beacon DTIM count according to TSF timer(backport v4.2)

See merge request espressif/esp-idf!11155
2020-11-11 11:28:43 +08:00
ad31451594 Fix crash caused by calling deinit directly 2020-11-10 11:18:39 +00:00
0b51df615c Remove dummy assert when receive passkey request 2020-11-10 16:06:11 +08:00
bff3192080 Merge branch 'feature/update_key_name_of_secure_boot_v4.2' into 'release/v4.2'
bootloader: Secure_boot name replaced by secure_boot_v1 & secure_boot_v2 (v4.2)

See merge request espressif/esp-idf!10850
2020-11-10 15:56:26 +08:00
4e80dc2a77 Merge branch 'bugfix/fix_coex_ble_disconnect_issues_1105_v4_2' into 'release/v4.2'
bluetooth: Fix ble disconnect issue in coex mode backport v4.2

See merge request espressif/esp-idf!11146
2020-11-10 15:21:39 +08:00
8e4b919391 Merge branch 'bugfix/fix_spp_read_flow_control_v4.2' into 'release/v4.2'
component_bt/fix spp flow control and vfs write [backport 4.2]

See merge request espressif/esp-idf!11071
2020-11-10 15:19:48 +08:00
5ca0f50231 Fix two bugs:
1.Fix supervision timeout in LLC DISC busy statue can not disconnect issue.
 2.Solve the problem that the ble terminate ack packet may lose with a high probability in coex mode.
2020-11-10 03:00:43 +00:00
0df8024219 Wi-Fi: set softap beacon DTIM count according to TSF timer 2020-11-09 19:33:27 +08:00
e31dd41e00 Merge branch 'bugfix/example_test_import_error_4.2' into 'release/v4.2'
bugfix: import error in example tests (4.2)

See merge request espressif/esp-idf!11048
2020-11-09 19:21:10 +08:00
2343aab4da 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-09 15:40:08 +05:30
f936adf451 Merge branch 'high/fix_ble_scan_irq_by_timer_v4.2' into 'release/v4.2'
components/bt: fix hci timeout, add timer to monitor scan evt

See merge request espressif/esp-idf!11108
2020-11-06 17:45:27 +08:00
ffb4ff0e4b components/bt: fix hci timeout, add timer to monitor scan evt 2020-11-06 14:17:11 +08:00
03c72909a3 esptool: Update to v3.0 release version 2020-11-06 17:11:29 +11:00
e5aa2b1d73 Merge branch 'bugfix/esp32s2_define_correct_size_for_rtc_fast_mem_v4.2' into 'release/v4.2'
esp32s2: Fix missed features CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP and... (v4.2)

See merge request espressif/esp-idf!9965
2020-11-06 12:49:24 +08:00
640083c8cb 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-06 03:38:52 +00:00
94093debab move flow control to btc layer
defer free slot in btc layer when receive BTA_JV_RFCOMM_CLOSE_EVT
2020-11-06 03:38:52 +00:00
76f41cc5e0 add event when calling spp API failed 2020-11-06 03:38:52 +00:00
778fe654aa Merge branch 'bugfix/fix_ag_outging_callback_not_triggered_v4.2' into 'release/v4.2'
Bugfix/Fix Ag Example Outgoing Callback Not Triggered [backport v4.2]

See merge request espressif/esp-idf!11020
2020-11-06 11:08:26 +08:00
cd7bfd6d85 Merge branch 'bugfix/fix_TCP_timer_interval_v4.2' into 'release/v4.2'
lw-ip: fix TCP timer interval (backport v4.2)

See merge request espressif/esp-idf!11086
2020-11-06 11:06:52 +08:00
34665cb9f9 Merge branch 'bugfix/fix_clkn_overflow_issue_4_2' into 'release/v4.2'
Fix controller dead when clkn overflow [backport v4.2]

See merge request espressif/esp-idf!11035
2020-11-06 11:06:32 +08:00
57571ae908 Bugfix: Casting int to size_t 2020-11-05 20:32:43 +05:30
b336cb954c esp32s2: Disable ADC calibration routine if running on FPGA 2020-11-05 15:06:33 +08:00
ac04213299 efuse: Fix the order of writing in batch mode for esp32s2 and s3 2020-11-05 15:05:55 +08:00
4bb9bb95d0 Merge branch 'bugfix/ci_clone_https_v4.2' into 'release/v4.2'
ci: use HTTPS for cloning in IT jobs (v4.2)

See merge request espressif/esp-idf!11095
2020-11-05 09:55:58 +08:00
e07d2df67e ci: use HTTPS for cloning in IT jobs 2020-11-03 19:26:28 +08:00
a55db686b9 bugfix: fix TCP timer interval 2020-11-03 10:38:48 +08:00
5e49f0b565 Merge branch 'bugfix/fix_spi_flash_clock_config_error_s2_4.2' into 'release/v4.2'
bootloader_support: fix fix spi flash clock config error (v4.2)

See merge request espressif/esp-idf!10892
2020-11-02 13:21:37 +08:00
9cf81750b9 bugfix: import error in example tests 2020-10-30 16:24:08 +08:00
lly
b2bd4d1cb7 ble_mesh: test: Fix node test function not update role flag 2020-10-29 15:50:00 +08:00
707dde46a8 tools/ldgen: Fix parsing of sections names on Windows 2020-10-29 08:46:03 +01:00
c09d3c6bac tools/ldgen: Parse paths with Unicode characters in archives
Closes https://github.com/espressif/esp-idf/issues/5996
2020-10-29 08:46:03 +01:00
000a533eaa Fix controller dead when clkn overflow 2020-10-29 14:54:20 +08:00
2b4124bced Merge branch 'bugfix/fix_crash_or_reboot_on_esp32s2_v4.2' into 'release/v4.2'
fix reboot or crash when enable lightsleep on esp32s2

See merge request espressif/esp-idf!11026
2020-10-29 00:31:10 +08:00
73e4a15889 Merge branch 'bugfix/resolve_esp32s2_rtc_gpio_reject_lightsleep_v4.2' into 'release/v4.2'
set clk_gate_en when enable rtc gpio wake up _backport_to_v4.2

See merge request espressif/esp-idf!11009
2020-10-28 22:20:44 +08:00
a6467d7683 fix reboot or crash when enable lightsleep on esp32s2 2020-10-28 22:20:41 +08:00
c5e75cb396 Merge branch 'bugfix/assert_10_9_when_AFPM_occur_v4.2' into 'release/v4.2'
Bugfix/assert 10 9 when afpm occur v4.2, Changed the check order for esp_bt_controller_init(release/v4.2)

See merge request espressif/esp-idf!10984
2020-10-28 22:15:59 +08:00
cd482f5e4b Merge branch 'mesh/bugfix_1023_backport_v4.2' into 'release/v4.2'
esp_wifi_mesh: update wifi mesh libs (backport v4.2)

See merge request espressif/esp-idf!11010
2020-10-28 22:14:43 +08:00
783c5ecee2 fix ag example outgoing callback not triggered
Closes https://github.com/espressif/esp-idf/issues/4967
2020-10-28 20:25:43 +08:00
138e1319b1 components/bt: fixed memory damage caused by bluetooth memory release 2020-10-28 19:05:22 +08:00
44e40500da components/bt: fix assert(10, 9), when the AFPM happens. fix tx_prog insert error. 2020-10-28 19:05:12 +08:00
6a0e8cc83a esp_wifi_mesh: update wifi mesh libs
1. Fix FIX-ROOT does not reconnect to router when disconnect reason is too many
2. Add API esp_mesh_print_scan_result
3. Modify not to reset mesh_xonseq of self and children when flush_upstream_packets
4. Fix not switch to a parent candidate which has the same layer and assoc as current parent
5. Fix not arm parent monitor when a parent candidate is cleared without sending an event to mesh layer
6. Fix the new voted root does not reconnect to router if rssi is weak
2020-10-28 15:02:29 +08:00
3d8f16e05d Merge branch 'bugfix/btdm_bluedroid_enable_takes_long_time_v4.2' into 'release/v4.2'
Bugfix/btdm bluedroid enable takes long time v4.2

See merge request espressif/esp-idf!10701
2020-10-28 13:38:51 +08:00
62aade0671 set clk_gate_en when enable rtc gpio wake up 2020-10-28 11:55:49 +08:00
ff52533260 Merge branch 'bugfix/update_toolchain_5.2.0_psram_final_v4.2' into 'release/v4.2'
esp_wifi: Update WiFi toolchain to 1.22.0-97-gc752ad5  (backport v4.2)

See merge request espressif/esp-idf!10640
2020-10-28 11:14:57 +08:00
c245db59b6 bootloader_support: fix fix spi flash clock config error
Relates to: https://github.com/espressif/esp-idf/issues/5099
2020-10-28 01:38:14 +00:00
c97d4cde56 Merge branch 'feature/add_ipv6_ping_for_4.2' into 'release/v4.2'
lw-ip:add feature for ipv6 ping(backport 4.2)

See merge request espressif/esp-idf!10995
2020-10-27 22:36:57 +08:00
e8cee449ea Merge branch 'bugfix/nimble_host_rcv_pkt_length_check_v4.2' into 'release/v4.2'
NimBLE: host_rcv_pkt event buf size check. (v4.2)

See merge request espressif/esp-idf!10758
2020-10-27 18:49:43 +08:00
e40d3bb05d Merge branch 'optimize/ble_mesh_make_buf_config_invisible_v4.2' into 'release/v4.2'
ble_mesh: stack: Make mesh buf debug option invisible (v4.2)

See merge request espressif/esp-idf!10794
2020-10-27 18:48:37 +08:00
22f49e0fa9 Merge branch 'bugfix/ble_mesh_settings_fix_v4.2' into 'release/v4.2'
Bugfix/ble mesh settings fix (v4.2)

See merge request espressif/esp-idf!10784
2020-10-27 18:48:06 +08:00
dd3f1e346a Merge branch 'feat/ble_mesh_device_properties_v2_v4.2' into 'release/v4.2'
Feat/ble mesh device properties v2 (v4.2)

See merge request espressif/esp-idf!10787
2020-10-27 18:47:34 +08:00
a5c3bd3d04 Merge branch 'bugfix/wpa_supplicant_link_depth_v4.2' into 'release/v4.2'
wpa_supplicant: Fix failure to link under some circumstances (v4.2)

See merge request espressif/esp-idf!10976
2020-10-27 18:45:17 +08:00
2454ffc912 Merge branch 'bugfix/fix_bredr_read_rssi_delta_v4.2' into 'release/v4.2'
Bugfix/Fix Read Rssi Delta Bug in Bredr [backport v4.2]

See merge request espressif/esp-idf!10801
2020-10-27 18:44:50 +08:00
e4e46b8384 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-27 06:57:20 +00:00
1d1b4f09b0 esp_wifi: Update WiFi toolchain to 1.22.0-97-gc752ad5 2020-10-27 14:43:57 +08:00
99fbd8a6e1 Merge branch 'doc/add_user_guide_kaluga_1.3_v4.2' into 'release/v4.2'
Add user guide kaluga 1.3 (backport v4.2)

See merge request espressif/esp-idf!10642
2020-10-27 12:40:58 +08:00
fd95013d77 Add user guide kaluga 1.3 (backport v4.2) 2020-10-27 12:40:53 +08:00
a5ddeef60b Merge branch 'feature/explain_hello_world_files_v4.2' into 'release/v4.2'
docs: Add explanation of hello_world folder contents (v4.2)

See merge request espressif/esp-idf!10775
2020-10-27 12:39:13 +08:00
bd5332d368 Merge branch 'feature/guide_change_for_catalina_v4.2' into 'release/v4.2'
docs: Add profile file name used by zsh shell (v4.2)

See merge request espressif/esp-idf!10772
2020-10-27 12:37:40 +08:00
48ea5b465d Merge branch 'bugfix/pmf_softap_coex_issue_v4.2' into 'release/v4.2'
Fix issues related to PMF and WPA2-Enterprise (Backport v4.2)

See merge request espressif/esp-idf!10706
2020-10-27 10:58:11 +08:00
e7e5884a77 lwip:add feature for ipv6 ping 2020-10-27 10:27:30 +08:00
c59eb27698 esp_wifi: Update wifi lib
1. Add STA checks during STA PMF operations
2. Fix WPA2-Ent issue with Open AP
3. Skip WPA-TKIP profile if PMF is required
4. Skip & clear Supplicant PMK Cache with mismatching AP config
2020-10-26 15:55:54 +08:00
5170ead2e6 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:12:48 +11:00
8d213150c5 Merge branch 'bugfix/fix_TCP_retransmission_interval_v4.2' into 'release/v4.2'
fix TCP retransmission interval (backport v4.2)

See merge request espressif/esp-idf!10953
2020-10-26 11:25:15 +08:00
d85d336c86 Merge branch 'bugfix/wps_fail_reason_code_v4.2' into 'release/v4.2'
esp_wifi: Add Failures Reason code in all WPS failure send event(backport v4.2)

See merge request espressif/esp-idf!10928
2020-10-26 11:24:30 +08:00
e10e25981b Merge branch 'bugfix/fix_tsf_bug_v4.2' into 'release/v4.2'
WiFi: fix tsf bug (backport v4.2)

See merge request espressif/esp-idf!10947
2020-10-26 11:21:11 +08:00
4fbfac2670 Merge branch 'feature/move_auto_test_script_to_new_repo_4.2' into 'release/v4.2'
ci: move auto_test_script to new repo (backport 4.2)

See merge request espressif/esp-idf!10877
2020-10-24 09:24:38 +08:00
f12808533d ci: move auto_test_script to new repo (backport 4.2) 2020-10-24 09:24:38 +08:00
d5871e9602 Merge branch 'bugfix/ipv6_ping_error_when_src_ip_miss_for_4.2' into 'release/v4.2'
lw-ip:bugfix ipv6 ping error when src ip miss for 4.2(backport 4.2)

See merge request espressif/esp-idf!10932
2020-10-23 11:28:42 +08:00
489c0b9aac Merge branch 'feature/esp32s2_bootloader_random_v4.2' into 'release/v4.2'
bootloader_support: Enable RNG entropy source for ESP32-S2 (v4.2)

See merge request espressif/esp-idf!10882
2020-10-22 23:08:11 +08:00
e05164cb4f CI: Only run check_doc_links if we actually deployed
Update the check_doc_links job run conditions to match
github/doc deploy as a lot of the links link to github files.
2020-10-22 18:26:46 +08:00
84e5aef540 fix TCP retransmission interval 2020-10-22 16:53:00 +08:00
3c3bff6ebb esp_wifi: Fixed the bug for timestamp check, didn't disconnect AP when AP's timestamp decrease abnormally 2020-10-22 15:12:50 +08:00
2592a0534d bootloader: Secure_boot name replaced by secure_boot_v1 & secure_boot_v2
- espefuse.py burn_key secure_boot is no longer used.
- Secure boot V1: espefuse.py burn_key secure_boot_v1 file.bin
- Secure boot V2: espefuse.py burn_key secure_boot_v2 file.bin
2020-10-22 05:57:46 +00:00
6692f4119e bugfix ipv6 ping error when src ip miss for 4.2 2020-10-21 20:52:06 +08:00
379624de53 esp_wifi: Add WPS Reason code in all failures 2020-10-21 17:09:36 +05:30
b34c658554 esp32s2: Use regi2c registers to enable bootloader RNG 2020-10-21 15:09:22 +11:00
87247d5672 Merge branch 'bugfix/adc_dma_test_value_4.2' into 'release/v4.2'
adc_test: fix the failure caused by low expected middle value (v4.2)

See merge request espressif/esp-idf!10887
2020-10-20 11:03:15 +08:00
c0a9ef0e1d esp_idf_version.h: Add __ASSEMBLER__ flag to fix build failure with assembly files 2020-10-19 13:21:26 +05:30
9f0f753a48 Merge branch 'bugfix/fix_i2s_reset_issue_v4.2' into 'release/v4.2'
driver(I2S): Fix I2S reset issue for release/v4.2

See merge request espressif/esp-idf!9582
2020-10-19 15:40:03 +08:00
978b54796f 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:17:19 +08:00
68141a8844 adc_test: fix the failure caused by low expected middle value 2020-10-19 11:11:34 +08:00
882e924629 esp_ble_mesh: api: fixed comment about autoresp 2020-10-19 11:00:55 +08:00
3cdf0aa18a esp32s2: Enable 8M clock source for RNG also
Either of these options is sufficient to pass dieharder test suite with
bootloader random output, having both enabled is a bonus.
2020-10-19 10:24:37 +11:00
0c320bfb0e esp32s2: Support bootloader_random_enable() 2020-10-19 10:24:37 +11:00
f0e87c933a Merge branch 'spi_dma_close_before_cpu_reset_v4.2' into 'release/v4.2'
spi: fix issue with closing DMA before CPU reset (4.2)

See merge request espressif/esp-idf!10811
2020-10-17 23:37:29 +08:00
33443d80af Merge branch 'bugfix/spi_master_multiple_dev_with_diff_cs_lvl_4.2' into 'release/v4.2'
spi_master: correctly set cs polarity (4.2)

See merge request espressif/esp-idf!10391
2020-10-17 09:27:24 +08:00
ae0bec8de0 Merge branch 'bugfix/fix_adc-dma_reading_gap_for_esp32_backport_v4.2' into 'release/v4.2'
bugfix(adc): missing ranges of ADC-DMA codes in ESP32 (backport v4.2)

See merge request espressif/esp-idf!10670
2020-10-17 09:21:38 +08:00
eb540e3efa Merge branch 'bugfix/pcnt_interrupt_clear_v4.2' into 'release/v4.2'
pcnt: fix bug in clear interrupt status (v4.2)

See merge request espressif/esp-idf!10694
2020-10-16 14:51:17 +08:00
189a2991b7 Merge branch 'doc/adc_grammar_stuff_backport_v4.2' into 'release/v4.2'
Bugfix(doc): minor modifications in the adc section  (backport v4.2)

See merge request espressif/esp-idf!10657
2020-10-16 14:42:36 +08:00
95f353949a bugfix(adc): missing ranges of ADC codes in ESP32 2020-10-16 06:34:46 +00:00
3fa779b463 driver(I2S): Fix I2S reset issue for release/v4.2
`i2s_start` reseting I2S in incorrect order causeing the word-order error.
2020-10-16 06:32:13 +00:00
4c7dca7105 spi: fix issue with closing DMA before CPU reset 2020-10-16 06:00:18 +00:00
3dd5b574ee spi_master: correctly set cs polarity
All devices must be added to the same spi line before use.
2020-10-16 05:53:24 +00:00
a88c479160 cmake: Log the project sdkconfig path as part of normal CMake status output
As discussed in footnote to https://github.com/espressif/esp-idf/issues/5251#issuecomment-625563782
2020-10-16 10:11:39 +11:00
2a7dfb2320 examples: Move idf_as_lib sdkconfig file to the project directory
Also add some explanation about configuring the project in the README

Previously with the default build-esp32.sh script, the build directory was
deleted and recreated so the project would always be built with default config.
2020-10-16 10:11:39 +11:00
df5399cfb5 esp32s2: Fix missed features CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP and CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC
Defines the correct size for RTC fast memory (the same as for ESP32).

Closes: IDF-1800
2020-10-15 22:33:12 +00:00
e5fe4ffb08 Merge branch 'feature/support_access_internal_i2c_register_backport_v4.2' into 'release/v4.2'
feature(rtc): add new APIs support access internal i2c register (backport v4.2)

See merge request espressif/esp-idf!10662
2020-10-16 06:32:04 +08:00
lly
2724e02faf ble_mesh: stack: Add mesh device properties v2 definitions
Also fixes wrong characteristic value length of some device
properties.
2020-10-15 12:17:54 +00:00
lly
3c1922864d ble_mesh: stack: Move device property to model common part 2020-10-15 12:17:54 +00:00
lly
86af10c529 ble_mesh: stack: Make mesh buf debug option invisible 2020-10-15 11:48:59 +00:00
lly
c0678d65da ble_mesh: stack: Use settings_core_erase when deinit 2020-10-15 11:48:14 +00:00
lly
2c8fc5f5d6 ble_mesh: stack: Fix storing next net_idx and app_idx 2020-10-15 11:48:14 +00:00
lly
5708d4a4e1 ble_mesh: stack: Continue restore even if failure happens
Previously we have used this solution for node info
restore. Here use the same solution for other mesh
information restore.
2020-10-15 11:48:14 +00:00
lly
094eeaf346 ble_mesh: stack: Split model settings store and clear 2020-10-15 11:48:14 +00:00
lly
c06ce57687 ble_mesh: stack: Erase netkey and appkey with key index 2020-10-15 11:48:14 +00:00
lly
ea0ff4e6d1 ble_mesh: stack: Add clear hb_pub in settings 2020-10-15 11:48:14 +00:00
lly
365c17614b ble_mesh: stack: Transport rx reset settings update
When reset the rx info of transport layer, the
rpl list will always cleared, and rpl stored
in the nvs will only be erased when erase flag
is true and BLE_MESH_SETTINGS is enabled.
Compared with the previous solution, it should
be more clear.
2020-10-15 11:48:14 +00:00
lly
3b9057311b ble_mesh: stack: Use erase settings functions 2020-10-15 11:48:14 +00:00
lly
2459b625f1 ble_mesh: stack: Use mutex for settings operation
Also expose the settings functions with the parameter
bt_mesh_nvs_handle_t, which will be used for further
updates.
2020-10-15 11:48:14 +00:00
lly
a47e89c4e4 ble_mesh: stack: Add role check before enabling device 2020-10-15 11:48:14 +00:00
lly
4b70056966 ble_mesh: stack: Define a type for mesh nvs handle 2020-10-15 11:48:14 +00:00
lly
147db2f700 ble_mesh: ci: Enable settings in sdkconfig.ci.xxx 2020-10-15 11:48:14 +00:00
514389681c 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-10-15 18:39:45 +08:00
f5475db6e1 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-10-15 18:36:17 +08:00
9fe1469c70 components/bt: Fix waking up fail while sleeping 2020-10-15 09:13:22 +00:00
f64d0ec873 components/bt: Make sleep avaliable in hli(for future use) 2020-10-15 09:13:22 +00:00
292e396846 Merge branch 'bugfix/spi_flash_yield_coredump_v4.2' into 'release/v4.2'
spi_flash: don't call vTaskDelay in non-os context (v4.2)

See merge request espressif/esp-idf!10297
2020-10-15 15:10:51 +08:00
747c9a4e44 Merge branch 'bugfix/returns_correct_flash_encryption_mode_v4.2' into 'release/v4.2'
bootloader: Fix esp_get_flash_encryption_mode() (v4.2)

See merge request espressif/esp-idf!10712
2020-10-15 15:06:42 +08:00
9316961219 esp-cryptoauthlib: Update submodule pointer to add a new feature. 2020-10-15 05:16:38 +00:00
bbef823a20 feature(rtc): rename i2c_xxx to regi2c_xxx 2020-10-15 03:34:59 +00:00
d337559a17 rtc: support access internal i2c register 2020-10-15 03:34:59 +00:00
af7d6f4d89 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-15 02:36:04 +00:00
7d8d2b982e Merge branch 'feature/oocd_ver_backport_v4.2' into 'release/v4.2'
tools: Updates OpenOCD version to 'v0.10.0-esp32-20200709' (backport v4.2)

See merge request espressif/esp-idf!8971
2020-10-15 02:55:08 +08:00
eabd01e2ab docs: Add profile file name used by zsh shell 2020-10-14 07:31:34 +00:00
3f011513b8 VSCode Extension Setup Guide 2020-10-14 07:22:09 +00:00
b25f3cd524 docs: Add explanation of hello_world folder contents (v4.2) 2020-10-14 07:22:09 +00:00
57ce9c2f06 Merge branch 'bugfix/bootloader_anti_rollback_mmap_v4.2' into 'release/v4.2'
bootloader_support: fix issue in memory mapping for getting app descriptor (v4.2)

See merge request espressif/esp-idf!10734
2020-10-14 10:44:00 +08:00
4b5146a4ad test_apps: add build test for !CONFIG_SPI_FLASH_YIELD_DURING_ERASE 2020-10-14 02:42:46 +00:00
7092be7422 test_apps: add coredump tests for int_wdt 2020-10-14 02:42:46 +00:00
4baf399f10 spi_flash: don't call vTaskDelay in non-os context
Fixes regression in core dump, when a crash happens in interrupt
context.
2020-10-14 02:42:46 +00:00
489f5c38b4 Merge branch 'bugfix/deepsleep_flush_uarts_correct_v4.2' into 'release/v4.2'
esp32s2/soc: Fix periph_ll_periph_enabled (v4.2)

See merge request espressif/esp-idf!10711
2020-10-14 10:42:13 +08:00
805a4d9b3f Merge branch 'bugfix/prov_retry_failures_v4.2' into 'release/v4.2'
ci: Add retries for all provisioning methods, some refactors (v4.2)

See merge request espressif/esp-idf!9387
2020-10-14 10:41:42 +08:00
8c7a8f146b Merge branch 'bugfix/embed_file_symbol_names_v4.2' into 'release/v4.2'
cmake: fix C identifier generation from embedded file (v4.2)

See merge request espressif/esp-idf!10664
2020-10-14 10:41:12 +08:00
359b6af07c Merge branch 'bugfix/UT_001-parallel-count' into 'release/v4.2'
Increase count of parallel jobs to get UT_001 run through CI

See merge request espressif/esp-idf!10799
2020-10-14 10:40:40 +08:00
304ed67982 tools/docker: Add libpython2.7 in order to satisfy GDB dependencies
It was not possible to run xtensa-esp32-elf-gdb from container due to
missing libpython2.7 library.

Merges https://github.com/espressif/esp-idf/pull/5817
Closes https://github.com/espressif/esp-idf/issues/5284
2020-10-13 16:12:21 +00:00
09714a4f11 ci: add job for unit tests 2020-10-12 16:25:17 +02:00
f871186da3 idf.py: Fixed gdb target to exit cleanly when no openocd watch task
When idf.py gdb starts, it expects openocd was started in the background
and creates a thread to watch for openocd errors. when gdb target exits,
the debug_ext.py aims to cleanup all threads and processes, but fails
with traceback if openocd-watch thread not available, which could happen
if openocd started separately.
2020-10-12 13:30:15 +02:00
e5d252f7cf Increase count of parallel jobs to get UT_001 run through CI 2020-10-12 15:13:28 +08:00
d67e284c8d 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:28:51 +05:30
e849a77675 Merge branch 'bugfix/ci_auto_checkout_revision_of_project_used_in_ci_v4.2' into 'release/v4.2'
CI: get git describe from annotated tags (v4.2)

See merge request espressif/esp-idf!10673
2020-10-08 16:44:55 +08:00
22a6e2160f Merge branch 'bugfix/secure_boot_v2_ota_verification_v4.2' into 'release/v4.2'
Secure Boot V2: Fixes the OTA regression with secure boot in ESP32-V3 (v4.2)

See merge request espressif/esp-idf!10612
2020-10-08 11:22:59 +08:00
16ed6a4574 Merge branch 'feature/switch_from_external_to_interanl_ram_v4.2' into 'release/v4.2'
esp32: Switch SPIRAM stack in esp_restart_noos() to internal stack (v4.2)

See merge request espressif/esp-idf!9966
2020-10-08 11:22:55 +08:00
144f459c81 ci: Check version tags are always annotated
Closes https://github.com/espressif/esp-idf/issues/3114
2020-10-07 13:58:21 +11:00
2e469b52ae 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:58:21 +11:00
93aeac9728 bootloader_support: fix issue in memory mapping for getting app descriptor
For getting secure_version field in anti rollback case, bootloader tries
to map whole firmware partition but fails for cases where partition size
is beyond available MMU free pages capacity.

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

Closes https://github.com/espressif/esp-idf/issues/5911
2020-10-06 08:49:49 +05:30
be0444bf54 esp32s2/soc: Fix periph_ll_periph_enabled
Logs, before to go the deepsleep, were not completely flushed.
2020-10-01 03:58:23 +08:00
fcda778a11 CI: get git describe from annotated tags:
we should only parse IDF version from annotated tags
2020-09-30 11:32:25 +08:00
dcb23c0bc8 pcnt: fix bug in clear interrupt status 2020-09-30 11:13:17 +08:00
8223278050 Merge branch 'bugfix/ble_mesh_check_stack_init_v4.2' into 'release/v4.2'
ble_mesh: stack: Check if mesh stack initialized before init vendor client (v4.2)

See merge request espressif/esp-idf!10481
2020-09-30 10:53:56 +08:00
8e62a6992e Merge branch 'optimize/ble_mesh_provisioner_delete_dev_v4.2' into 'release/v4.2'
ble_mesh: stack: Optimize Provisioner delete device function (v4.2)

See merge request espressif/esp-idf!10603
2020-09-30 10:52:48 +08:00
f1e43b274f Merge branch 'bugfix/coex_some_bugfix_about_ble_dyn_prio_v4.2' into 'release/v4.2'
components/coex: Some bugfix about ble dynamic prio v4.2

See merge request espressif/esp-idf!10596
2020-09-30 10:50:15 +08:00
d101b15942 components/coex: Some bugfix about ble dynamic prio
Rewrite ble dynamic prio to fix ble disconn in conn_param_update/channel_map_update
Rewrite ble dynamic prio in connection establishment
Fix ble dynamic prio with latency
Fix status bit set error when conn fail
2020-09-29 14:12:39 +08:00
c5bb6c467f Merge branch 'bugfix/update_esp32_phy_v4500_v4.2' into 'release/v4.2'
esp_wifi: update esp32 phy v4500 (v4.2)

See merge request espressif/esp-idf!10624
2020-09-29 13:59:45 +08:00
lly
11108393f1 ble_mesh: stack: Optimize Provisioner delete device function
Since we have provided separate functions for deleting node
information with node's unicast address, device uuid, etc.
So we update the behavior of this function, which will only
be used to delete device information which is not provisioned
or just under provisioning.
2020-09-29 03:41:29 +00:00
lly
d312651c5c ble_mesh: stack: Check if mesh stack initialized before init vendor client 2020-09-29 03:41:19 +00:00
17fca6235b Merge branch 'bugfix/add_clear_bond_complete_evt_4_2' into 'release/v4.2'
componenet_bt/bugfix: add remove bond device complete event 4.2

See merge request espressif/esp-idf!10651
2020-09-29 11:15:55 +08:00
61e6e718e4 Merge branch 'bugfix/bredr_bugfix_release_for_qa_dummy_disconnect_4_2' into 'release/v4.2'
Bugfix/bredr bugfix release for qa dummy disconnect 4.2

See merge request espressif/esp-idf!10645
2020-09-29 11:15:30 +08:00
d7317eaae1 Merge branch 'bugfix/channel_map_send_time_v4.2' into 'release/v4.2'
component/bt: Insert the llcp packet to the top of the tx_preg linked list.(backport 4.2)

See merge request espressif/esp-idf!10178
2020-09-29 10:40:26 +08:00
cb6299200c doc/adc: modifications in the adc documentation and adc headers 2020-09-28 21:55:42 +08:00
a63bdf782f Merge branch 'bugfix/fix_dac_dma_driver_and_ut_backport_v4.2' into 'release/v4.2'
Driver(dac): fix DAC-DMA driver and unit test (backport v4.2)

See merge request espressif/esp-idf!10216
2020-09-28 21:43:11 +08:00
cf16ae573c Merge branch 'cherry-pick-7876d7f5' into 'release/v4.2'
driver(adc): add adc-dma code for esp32   (backport v4.2)

See merge request espressif/esp-idf!10212
2020-09-28 21:11:11 +08:00
d41f856576 cmake: fix C identifier generation from embedded file 2020-09-28 21:08:56 +08:00
847a697c93 Driver(dac): fix DAC-DMA driver and unit test 2020-09-28 19:35:07 +08:00
2d90885e09 components/bt: Replace task post with btc_inter_profile_call, when post message from btc_dm to btc_gap 2020-09-28 15:09:37 +08:00
2b4fae912c components/bt: Fix clear bond fail when connected without ble included 2020-09-28 14:57:27 +08:00
fba62f5e2e add remove bond device complete event 2020-09-28 14:56:42 +08:00
cfa6db0fee esp_wifi: update esp32 phy v4500 (v4.2)
improve frequence offset feature.
2020-09-28 14:27:34 +08:00
0aaa7ffc28 Merge branch 'bugfix/fix_some_wifi_bugs_0924_v4.2' into 'release/v4.2'
esp_wifi: fix some wifi bugs 0924 (v4.2)

See merge request espressif/esp-idf!10648
2020-09-28 14:23:23 +08:00
5bdded29a1 Merge branch 'bugfix/provisioning_example_warning_with_O2_optimization_v4.2' into 'release/v4.2'
provisioning: use memcpy instead of strncpy for copying SSID (v4.2)

See merge request espressif/esp-idf!10494
2020-09-28 12:44:41 +08:00
7f8c121791 1.revert dummy command
2.fix send MEDIA_CTRL command in disconnect
2020-09-28 10:42:02 +08:00
a6cdf4ed1e 1.fix test case dummy
2.fix sink send media control ESP_A2D_MEDIA_CHECK_SRC_RDY
2020-09-28 10:41:53 +08:00
314960ae31 Merge branch 'bugfix/window_spill_a0_corruption_v4.2' into 'release/v4.2'
freertos: don't clobber a4 while spilling register windows (backport v4.2)

See merge request espressif/esp-idf!10305
2020-09-28 09:15:14 +08:00
466cd7ba22 esp_wifi:
1. Modify LR for esp32 and esp32s2
2. Fix esp32s2 RTS rate
3. Optimize some debug logs for probe response
4. Optimize phy and soc files
5. Add IPv6 DSCP
6. Fix classify AC to TID
7. Fix the bug that no event for connect
2020-09-27 19:50:58 +08:00
81bbc8c88d Merge branch 'doc/esp32s2_jtag_guide_v4.2' into 'release/v4.2'
docs: update JTAG debugging guide for ESP32-S2 (backport v4.2)

See merge request espressif/esp-idf!10311
2020-09-27 14:37:40 +08:00
4b10685fcc Merge branch 'doc/remove_lts_versions_v4.2' into 'release/v4.2'
docs: Update Versions file in line with the latest Support Policy document (v4.2)

See merge request espressif/esp-idf!10599
2020-09-27 14:31:31 +08:00
34209a30bd Merge branch 'feature/docs-add-python-clean_v4.2' into 'release/v4.2'
docs: Add solution for ImportError in idf.py into the documentation (v4.2)

See merge request espressif/esp-idf!10630
2020-09-27 14:27:11 +08:00
123aaf2280 Merge branch 'bugfix/fix_some_wifi_bugs_0916_v4.2' into 'release/v4.2'
eps_wifi: Fix some wifi bugs (backport v4.2)

See merge request espressif/esp-idf!10475
2020-09-27 11:17:53 +08:00
2db55a3b90 Merge branch 'bugfix/add_disconn_req_action_when_no_link_4.2' into 'release/v4.2'
Bugfix/add disconn req action when no link 4.2

See merge request espressif/esp-idf!10508
2020-09-27 11:17:43 +08:00
50e2d0b32d docs: add description of python-clean command 2020-09-27 00:03:38 +02:00
60e4c02963 ci: add unit test job 2020-09-25 16:29:58 +00:00
e2cb7ed9ca Revert "CXX: removed exception windowspill test"
This reverts commit f3e180de72.
2020-09-25 16:29:58 +00:00
f4ab2beaa8 freertos: don't clobber a4 while spilling register windows
Commit 891eb3b0 was fixing an issue with PS and EPC1 not being
preserved after the window spill procedure. It did so by saving PS in
a2 and EPC1 in a4. However the a4 register may be a live register of
another window in the call stack, and if it is overwritten and then
spilled to the stack, then the corresponding register value will end
up being corrupted. In practice the problem would show up as an
IllegalInstruction exception, when trying to return from a function
when a0 value was 0x40020.
Fix by using a0 register instead of a4 as scratch. Also fix a comment
about xthal_save_extra_nw, as this function in fact doesn't clobber
a4 or a5 because XCHAL_NCP_NUM_ATMPS is defined as 1.

Closes https://github.com/espressif/esp-idf/issues/5758
2020-09-25 16:29:58 +00:00
df301b89ec component/bt: Fix assert(9, 10), Insert the llcp packet to the top of the tx_preg linked list 2020-09-25 18:43:14 +08:00
a04d6e7f63 Secure Boot V2: Fixes the OTA regression with secure boot in ESP32-V3
Closes https://github.com/espressif/esp-idf/issues/5905
2020-09-25 14:21:07 +05:30
c7d602cc62 Merge branch 'bugfix/adjtime_return_outdelta_before_new_delta_set_v4.2' into 'release/v4.2'
newlib: Fix adjtime, returns the amount of time remaining from any previous adjustment (v4.2)

See merge request espressif/esp-idf!9971
2020-09-25 08:03:11 +08:00
6443a96834 Merge branch 'backport/shared_stack4.2' into 'release/v4.2'
Backport/shared stack4.2

See merge request espressif/esp-idf!10303
2020-09-25 08:02:55 +08:00
f817747727 Merge branch 'bugfix/efuse_test_stackoverflow_v4.2' into 'release/v4.2'
CI: Increase stack size for efuse unit test (Backport v4.2)

See merge request espressif/esp-idf!10543
2020-09-25 08:02:31 +08:00
dbdb1c1c23 docs: Update Versions file in line with the latest Support Policy document 2020-09-25 09:59:56 +10:00
7402e17838 Merge branch 'bugfix/openss_strict_verify_mode' into 'release/v4.2'
openssl: made verification mode conversion to mbetls modes more strict (v4.2)

See merge request espressif/esp-idf!10499
2020-09-25 07:40:52 +08:00
e610df5870 Merge branch 'bugfix/esp32s2_panic_handler_iram_v4.2' into 'release/v4.2'
esp_common: allow placing panic handler into IRAM on ESP32-S2 (v4.2)

See merge request espressif/esp-idf!10295
2020-09-25 07:40:06 +08:00
6a711671c6 Merge branch 'bugfix/spinlock_coredump_regressions_v4.2' into 'release/v4.2'
Revert "Merge branch 'feature/gdb_stub_task_state' into 'master'" (backport v4.2)

See merge request espressif/esp-idf!10296
2020-09-25 07:33:05 +08:00
3b400767f3 Merge branch 'bugfix/idf_py_disable_cmake_warnings_default_v4.2' into 'release/v4.2'
idf.py: disable cmake uninitialized variable warnings by default (v4.2)

See merge request espressif/esp-idf!10201
2020-09-25 07:32:22 +08:00
4ffe6c096a Merge branch 'bugfix/esp32s2_o2_op_v4.2' into 'release/v4.2'
freertos: fix build error at -O2 optimization level (v4.2)

See merge request espressif/esp-idf!10301
2020-09-25 07:31:58 +08:00
f536db1782 Merge branch 'feature/secure_boot_esp32s2_v4.2' into 'release/v4.2'
Feature/secure boot esp32s2 v4.2

See merge request espressif/esp-idf!9958
2020-09-25 07:31:45 +08:00
dd29046e88 Merge branch 'bugfix/can_mmap_after_get_enough_free_mmu_pages_v4.2' into 'release/v4.2'
flash_mmap: can mmap after get enough free MMU pages (backport v4.2)

See merge request espressif/esp-idf!10584
2020-09-24 22:36:51 +08:00
fd2e2ac34f doc: Getting Started Guide, remove shortcuts to 'build toolchain from scratch' instructions 2020-09-24 18:32:50 +08:00
0831d06dee Fix ccache documentation: environment variable is IDF_CCACHE_ENABLE
Merges https://github.com/espressif/esp-idf/pull/5753
2020-09-24 05:20:33 +00:00
722d67ea36 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-09-24 05:20:33 +00:00
3c2fd749f0 Merge branch 'bugfix/wifi_create_and_start_ap_v4.2' into 'release/v4.2'
Set default AP handlers in wifi_create_and_start_ap() v4.2

See merge request espressif/esp-idf!10458
2020-09-24 12:36:50 +08:00
7b30e467b4 Merge branch 'bugfix/confirmed_bugfix_from_baidu_proj_4.2' into 'release/v4.2'
Confirmed bugfix from Baidu project 4.2

See merge request espressif/esp-idf!10544
2020-09-24 12:31:52 +08:00
009956c5a7 Merge branch 'bugfix/wifi_spin_lock_allocation_in_PSRAM_v4.2' into 'release/v4.2'
wifi: Fix spin lock allocation in PSRAM bug(v4.2)

See merge request espressif/esp-idf!10553
2020-09-24 12:31:14 +08:00
88faf37a59 Merge branch 'bugfix/ipv6_send_data_error_when_src_ip_miss_for_4.2' into 'release/v4.2'
lw-ip:ipv6 send multicast data fail when src address is null (backport 4.2)

See merge request espressif/esp-idf!10558
2020-09-24 12:30:35 +08:00
03a749a60e flash_mmap: restore interrupt and cache before err return 2020-09-24 09:49:39 +08:00
98ce1fa080 flash_mmap: can mmap after get enough free MMU pages 2020-09-24 09:49:39 +08:00
9f0c564de4 Merge branch 'feature/toolchain_2020r3_v4.2' into 'release/v4.2'
Update toolchain to esp-2020r3 (backport v4.2)

See merge request espressif/esp-idf!10388
2020-09-23 20:26:24 +08:00
07bfb7cac9 freemodbus: fix event processing failure after destroy
Closes https://github.com/espressif/esp-idf/issues/5275
2020-09-23 07:04:52 +00:00
2d63354ec8 Secure Boot: Fixes the cpp macro in esp32 secure boot rom functions.
Closes https://github.com/espressif/esp-idf/issues/5878
2020-09-23 03:01:51 +05:30
fd083f1e44 ipv6 send multicast data fail when src address is null for 4.2 2020-09-22 17:33:02 +08:00
c06f0738c9 Fix spin lock allocation in PSRAM bug 2020-09-22 14:36:36 +08:00
311d43d021 eps_wifi: Fix some wifi bugs
1. Drop receiving packets from myself
2. scan: Fix scan issue with WPA2-PSK-SHA256 AP
2020-09-22 14:23:43 +08:00
190f310ed1 docs: seperate build_docs html and pdf CI jobs
Due to eager_exclude, Sphinx jobs cannot use the doc cache (doctrees).

PDF and HTML building are now seperate CI jobs to avoid this issue.
PDF building will only be ran on deploy branches and when started
with build_docs tag to reduce CI load
2020-09-22 14:04:12 +08:00
d12eb31f42 CI: Increase stack size for efuse unit test
"Batch mode is thread-safe" case would occasionally cause a stackoverflow.
Increased stack size.
2020-09-22 11:54:08 +08:00
b7d4868a70 Confirmed bugfix from Baidu project 2020-09-22 11:44:09 +08:00
071dc73954 NVS: ensuring default partition
* Also added encryption keys to CMakeLists.txt

Closes https://github.com/espressif/esp-idf/issues/5347
Closes IDFGH-3372
2020-09-21 12:44:57 +08:00
8749c46284 esp_common: allow placing panic handler into IRAM on ESP32-S2 2020-09-18 15:35:48 +00:00
278030ff3e add file stream parameter and log stdout and stderr to same stream 2020-09-18 10:38:33 +02:00
84cda60478 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:09:27 +08:00
e940e1d72a Add global header and change declaration position 2020-09-18 14:09:19 +08:00
b16deb4473 Remove uneccessary macro
Separate AVRC from A2DP when AVRC not Initialized
2020-09-18 14:09:10 +08:00
306c978195 Rewrite a2dp clean_up function 2020-09-18 14:09:02 +08:00
59234501dd 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:08:53 +08:00
26481c4a9d toolchain: C++ exception workaround
* disable C++ exception FDE sorting (saves RAM)

Closes IDF-1128
2020-09-18 12:32:34 +07:00
88a62e8ae5 Update toolchain to esp-2020r3
Fixup more for PSRAM issue;
    Allow GDB work correctly with Privileged Registers;
    Based on GCC 8.4.0;
    Update a fix of C++ exception crashs from the GCC mainline;
    Fixup strptime_l() and some locale in libc;
2020-09-18 12:32:34 +07:00
83ec35f185 tool: Fix 'idf.py bootloader' error if Secure Boot is enabled
If Secure Boot is enabled, there's no bootloader flasher arguments in the
project (to encourage careful manual flashing), so this command would
fail with a KeyError.
2020-09-18 04:05:28 +05:30
223f800dd7 expression_with_stack: added a tweak on TCB stackpointers to avoid false trigger of stack overflow 2020-09-17 20:46:02 +00:00
3e9637a893 test/shared_stack_printf: improved printf with shared stack function test 2020-09-17 20:46:02 +00:00
a6f0b15d3e Revert "Merge branch 'feature/gdb_stub_task_state' into 'master'"
This reverts commit c41a0c1907, reversing
changes made to 5c1d317766.
2020-09-17 17:04:48 +00:00
521eee7384 openssl: made verification mode conversion to mbetls modes more strict 2020-09-17 13:22:36 +02:00
6d37ad39aa provisioning: use memcpy instead of strncpy for copying SSID
Per WiFi library requirement, SSID can be non-null terminated string
if its length goes to 32 bytes (maximum). Use of strncpy in this case,
along with compiler optimization level -O2 results in some warnings
for potential use of non-null terminated strings.

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

Closes https://github.com/espressif/esp-idf/issues/5866
Closes IDFGH-3983
2020-09-17 15:51:32 +05:30
dddcc2ede8 Merge branch 'bugfix/add_protection_for_spp_api_4.2' into 'release/v4.2'
Bugfix/add protection for spp api 4.2

See merge request espressif/esp-idf!10281
2020-09-16 14:06:28 +08:00
21b02a9302 Merge branch 'bugfix/update_esp32_phy_4390_v4.2' into 'release/v4.2'
update esp32 phy 4390.(backport v4.2)

See merge request espressif/esp-idf!10456
2020-09-16 11:57:47 +08:00
17525d6035 Merge branch 'bugfix/cxx_flag_operators_v4.2' into 'release/v4.2'
esp_eth: moved extern "C" after includes (v4.2)

See merge request espressif/esp-idf!10351
2020-09-15 16:12:42 +08:00
a4c3aebc3d Merge branch 'bugfix/ulp_as_version_v4.2' into 'release/v4.2'
ulp: fix ULP assembler version detection for localized systems (v4.2)

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

See merge request espressif/esp-idf!10398
2020-09-15 15:08:26 +08:00
86b07ef098 Merge branch 'bugfix/fix_ipv6_nd6_max_queue_num_4.2' into 'release/v4.2'
lw-ip IPv6 ND6 queue too much pkts(Backport v4.2)

See merge request espressif/esp-idf!10091
2020-09-15 15:07:03 +08:00
ac016da8ab Merge branch 'bugfix/bootloader_skip_verify_jtag_v4.2' into 'release/v4.2'
bootloader_support: don't check signature when JTAG is attached, fix signed partition table generation (v4.2)

See merge request espressif/esp-idf!10378
2020-09-15 14:58:01 +08:00
ddedf25ca8 Set default AP handlers in wifi_create_and_start_ap() v4.2 2020-09-15 14:54:46 +08:00
7d57165922 Update to compatible crc & SBv2 enable check api's 2020-09-15 11:29:26 +05:30
d72350c0ce ci: Add test apps for ESP32-S2 Secure Boot 2020-09-15 11:23:51 +05:30
1c6c6eceb5 secure boot: Fixes for ESP32-S2 first boot logic 2020-09-15 11:23:51 +05:30
e7b1640c77 Split unit test configs to fit into ESP32s2's memory 2020-09-15 11:23:51 +05:30
762e8d5f84 bootloader esp32s2: Fix return type of ROM function signature verification 2020-09-15 11:23:51 +05:30
9856198112 bootloader esp32s2: Increase bootloader DRAM & IRAM allowance
Bootloader DRAM now ends at 0x3FFEAB00 which is the start of ROM
static RAM (reclaimable after app is running).

IRAM loader segment increased by 8KB.

Available total static RAM for the app is now reduced by 16KB.
2020-09-15 11:23:51 +05:30
b05213c327 Docs: Secure boot v2 support for ESP32-S2 2020-09-15 11:23:51 +05:30
0f82fe105c Secure boot v2 support for ESP32-S2 2020-09-15 11:23:51 +05:30
c4f4e15cc7 Merge branch 'cherry-pick-4dcaa0e6-3' into 'release/v4.2'
wpa_supplicant: Deinit wpa2 states in wifi deinit(backport v4.2)

See merge request espressif/esp-idf!10163
2020-09-15 12:06:49 +08:00
2cf032a4b6 update esp32 phy 4390.(backport v4.2) 2020-09-15 10:54:41 +08:00
a5907ee3fe lwip: fix IPv6 ND6 queue too much pkts cause no mem issue and add menuconfig item for this params. 2020-09-14 21:06:38 +08:00
ef0db6f034 ci: Use git mirror for docker image 2020-09-14 12:49:05 +02:00
b132ab2091 Merge branch 'bugfix/add_return_in_uart_wait_tx_done_bp4.2' into 'release/v4.2'
bugfix(UART): Add return in uart_wait_tx_done(backport v4.2)

See merge request espressif/esp-idf!10335
2020-09-14 14:26:00 +08:00
ced340a1a3 Merge branch 'bugfix/ci_ulp_adc_more_info_v4.2' into 'release/v4.2'
CI: Fix regex in ulp_adc example test (v4.2)

See merge request espressif/esp-idf!10431
2020-09-13 17:26:53 +08:00
4e27122ee5 CI: Fix regex in ulp_adc example test 2020-09-12 08:01:53 +02:00
bec2dbcb84 Merge branch 'bugfix/ble_mesh_prov_iv_index_v4.2' into 'release/v4.2'
ble_mesh: stack: Using the latest iv_index for provisioning (v4.2)

See merge request espressif/esp-idf!10416
2020-09-11 20:08:39 +08:00
07acd74b04 Merge branch 'bugfix/get_started_inconsistency_backport_v4.2' into 'release/v4.2'
docs: Add missing target setting in step 7 of Getting Started documentation (Backport v4.2)

See merge request espressif/esp-idf!10405
2020-09-11 19:15:17 +08:00
lly
0fff4d46ec ble_mesh: stack: Using the latest iv_index for provisioning
Provisioner should always uses the latest IV Index for provisioning.
For example, if the current IV Index is 0x00000001, but prov->iv_index
is still initialized with 0x00000000, and if Provisioner uses prov->
iv_index for provisioning, this will cause the Provisioner failing to
control the node.
So here bt_mesh.iv_index is used instead of prov->iv_index.
2020-09-11 10:55:47 +08:00
073e855c73 Merge branch 'bugfix/btdm_spp_null_ptr_with_dynamic_memory_v4.2' into 'release/v4.2'
components/bt: Fix SPP using NULL point with dynamic memory

See merge request espressif/esp-idf!10322
2020-09-10 17:39:14 +08:00
0514496744 Merge branch 'feature/vs_allow_custom_part_4.2' into 'release/v4.2'
Feature/vs allow custom part 4.2

See merge request espressif/esp-idf!9514
2020-09-10 16:09:00 +08:00
d212c4673d tools: Fix Python 3 incompatibility for building with Eclipse on Windows 2020-09-10 09:45:37 +02:00
92ef27223d ulp: fix ULP assembler version detection for localized systems 2020-09-10 09:34:40 +02:00
ef19aac267 docs: Add missing target setting in step 7 of Getting Started documentation 2020-09-10 15:33:08 +08:00
156afc0c05 Merge branch 'bugfix/secure_boot_v2_sign_cmake_copy_v4.2' into 'release/v4.2'
Add platform independent CMake copy during signing (v4.2)

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

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

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

See merge request espressif/esp-idf!10354
2020-09-10 10:37:59 +08:00
6f2e465ec9 partition_table: fix generation of signed partition table
Fixes the issue that signed partition table was not generated when
CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES was on, because
partition_table_bin depended on unsigned_partition_bin twice.
Regression from acb7a211.

Also use final_partition_bin variable in esptool_py_flash_target_image
arguments, to avoid issues in the future if final_partition_bin is
changed.
2020-09-09 23:39:51 +02:00
93a3beafb8 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:39:51 +02:00
0e191cf70e 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:35:07 +02:00
96ad552245 Merge branch 'feature/mqtt_sub_update_01594bf1_v4.2' into 'release/v4.2'
MQTT: Update submodule reference (Backport v4.2)

See merge request espressif/esp-idf!10230
2020-09-09 20:41:14 +08:00
5a23447452 Merge branch 'bugfix/remove_auto_conn_case_v4.2' into 'release/v4.2'
test: remove auto conn case because we do not support this anymore (v4.2)

See merge request espressif/esp-idf!9940
2020-09-09 15:54:42 +08:00
lly
61bb586244 ble_mesh: stack: Use model callback for operations [Zephyr]
- Previously when a model is initialized or deinitialized, in the
  access layer, we need to check the model id with the ids in the
  table in order to find the proper model operation function.
- Currently all the operation functions of each model will be set
  during the mesh initialization. When the model is found, we can
  directly use the corresponding callback for different operations.
- Currently only init/deinit operations are registered, later we
  will add more operations.
2020-09-09 13:59:32 +08:00
lly
1f9d289ee0 ble_mesh: stack: Avoid using assert in mesh stack 2020-09-09 10:57:07 +08:00
a1c8b21928 esp_eth: moved extern "C" after includes 2020-09-09 10:19:03 +08:00
8b1e3c01a0 Merge branch 'bugfix/doc_main_readme_build_v4.2' into 'release/v4.2'
Fix the setup instructions in the main README (v4.2)

See merge request espressif/esp-idf!10337
2020-09-09 02:44:34 +08:00
lly
4eec2c64ee ble_mesh: nimble: Fix updating ccc handle with wrong value 2020-09-08 21:01:32 +08:00
b356d41bb1 Merge branch 'bugfix/fix_some_wifi_bugs_0902_v4.2' into 'release/v4.2'
Bugfix/fix some wifi bugs 0902 v4.2 (backport v4.2)

See merge request espressif/esp-idf!10246
2020-09-08 18:30:31 +08:00
4663b16779 Fix the setup instructions in the main README 2020-09-08 09:54:46 +02:00
a8a2ea7b38 UART: Add return in uart_wait_tx_done
uart_wait_tx_done quit due to timeout but without return ESP_ERR_TIMEOUT.
2020-09-08 15:00:53 +08:00
2854050835 Merge branch 'bugfix/pip_gdbgui_v4.2' into 'release/v4.2'
fix windows incompatibility with gdbgui>=0.14 (v4.2)

See merge request espressif/esp-idf!10326
2020-09-08 00:07:09 +08:00
1fef76cbce tools: fix windows incompatibility with gdbgui>=0.14
gdbgui intentionally (https://github.com/cs01/gdbgui/pull/346) introduced dependencies that are incompatible with windows, and don't seem to have plans to resolve them anytime soon

Closes https://github.com/espressif/esp-idf/issues/5782
Closes https://github.com/espressif/esp-idf/issues/5787
Merges https://github.com/espressif/esp-idf/pull/5794
2020-09-07 07:55:45 +00:00
ad8b3e4274 components/bt: Fix SPP using NULL point with dynamic memory 2020-09-07 15:44:28 +08:00
ecab1d9b2e Merge branch 'bugfix/l2cap_link_timeout_llcp_prog_btu_wtd_v4.2' into 'release/v4.2'
Bugfix/l2cap link timeout llcp prog btu wtd v4.2

See merge request espressif/esp-idf!10255
2020-09-07 14:11:08 +08:00
1f011c3b2a docs: translate idf.py debug target 2020-09-04 21:59:05 +02:00
8f78db8073 docs: jtag-debugging: update Chinese version 2020-09-04 21:59:05 +02:00
7ae490d908 docs: jtag-debugging: fix ups in English version 2020-09-04 21:59:05 +02:00
b58d74da45 docs: add placeholders for {esp32,esp32s2}.inc in JTAG debugging guide 2020-09-04 21:59:05 +02:00
ead33e155d docs: repurpose WROVER-KIT debugging guide for Kaluga-1 2020-09-04 21:59:05 +02:00
964f041269 tools: idf.py: default to board/esp32s2-kaluga-1.cfg for ESP32-S2
NFC. Kaluga-1 config is same as devkitj + esp32s2.
2020-09-04 21:59:05 +02:00
b7760cf269 docs: minor typos in JTAG debugging section 2020-09-04 21:59:05 +02:00
cfbd2566c1 docs: formatting fix in idf.py debugging section 2020-09-04 21:59:05 +02:00
b513dd11ce docs: move target-specific parts of JTAG guide into include files
{esp32,esp32s2}.inc files contain most of the bits and code snippets
which are different between targets. These bits are included from the
rest of the source files.

Also included is an update to the section about OpenOCD configuration
variables and files. This section wasn't updated when some of the
files and variables got renamed.
2020-09-04 21:59:05 +02:00
b181623d9b freertos: fix compilation warning at -O2 level
Closes https://github.com/espressif/esp-idf/issues/5525
2020-09-04 21:33:49 +02:00
acfe648367 ci: add startup test with -O2 optimization level 2020-09-04 21:33:49 +02:00
73813c6bac freertos: ensure the interrupt stack is aligned
CONFIG_FREERTOS_ISR_STACKSIZE was set to 2100 when ELF core dump was
enabled, which resulted in a non-16-byte-aligned interrupt stack
offset. This triggered "is SP corrupted" check in the backtrace,
terminating the backtrace early.

Fix the default value, and make sure that the stack is always aligned,
regardless of the value of CONFIG_FREERTOS_ISR_STACKSIZE.
2020-09-04 20:45:38 +02:00
c3d2942675 panic: skip over the first invalid PC in case of InstrFetchProhibited
InstrFetchProhibited usually occurs because of a jump to an invalid
pointer. In this case, PC in the exception frame is the address of
the jump destination. 'esp_ptr_executable' check in print_backtrace
function recognizes the first frame as invalid, and the backtrace is
interrupted. This prevents the user from finding the location where
the invalid pointer is dereferenced.

Bypass the 'esp_ptr_executable' check if the exception cause is
InstrFetchProhibited. Update the test case to no longer ignore this
issue.
2020-09-04 20:45:38 +02:00
87d96b2c29 Merge branch 'bugfix/ws_stop_deadlock_v4.2' into 'release/v4.2'
Websocket client: avoid deadlock if stop called from event handler (Backport 4.2)

See merge request espressif/esp-idf!10226
2020-09-04 22:51:46 +08:00
5c8a85e839 Merge branch 'bugfix/ble_mesh_sensor_example_fix_v4.2' into 'release/v4.2'
ble_mesh: example: Fix sensor data wrong iteration (v4.2)

See merge request espressif/esp-idf!10273
2020-09-04 16:54:38 +08:00
a7d52dafa6 component/bt: Fixed the watchdog timeout of btu task during multi-connection 2020-09-04 16:27:03 +08:00
a7ddc9c125 Add protection for rfcomm close API in SPP 2020-09-04 14:40:27 +08:00
07e2d3ab0f Add some debug log for bt:
1. Add logs for SPP not enabled successfully
2. Add information to Applicatioin layer that the A2DP is connecting to peer device

Regular BTC and BTU Task name & Add BTC Init protection

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

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

2. Add BTC Init failure protection

3. Regular BTU Task Name with BTC

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

5. Correct comment of esp_bt_hf_vra();

6. Fix cpp compilier region
2020-09-04 14:40:19 +08:00
lly
8fe75ff3ce ble_mesh: example: Fix sensor data wrong iteration 2020-09-04 11:54:52 +08:00
b9f0500641 Merge branch 'bugfix/ws_server_async_send_fin_v4.2' into 'release/v4.2'
http_server example: WebSocket server to set final flag in async messages (v4.2)

See merge request espressif/esp-idf!10087
2020-09-03 14:11:13 +08:00
12633717f7 components/bt: Fixed the state not synchronized between controller and host when disconnected. 2020-09-02 21:43:57 +08:00
ec2262e5a4 http_server: WebSocket server to set flag in transmitted messages by default
Add logic to set `FIN` flag automatically for transmitted WS frames, but
if `fragmented` option set indicating an expert/manual mode, then the
`FIN` flag is set according to the `final` option.
2020-09-02 07:54:29 +00:00
4da38b6769 http_server example: WebSocket server to set final flag in async messages
Closes https://github.com/espressif/esp-idf/issues/5405
2020-09-02 07:54:29 +00:00
a0a0d34da6 Merge branch 'bugfix/ethernet_handle_early_rx_interrupt' into 'release/v4.2'
Bugfix/ethernet handle early rx interrupt (v4.2)

See merge request espressif/esp-idf!10098
2020-09-02 15:52:18 +08:00
d17e6a75e0 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:06:51 +08:00
089b78b916 esp_wifi:
1. get primary channel from HT info
2. fix the bug that set_channel doesn't work for softAP when STA connects
2020-09-02 15:04:26 +08:00
ddfb11e1c5 wifi: Fix esp_wifi log levels
Closes https://github.com/espressif/esp-idf/issues/5721
2020-09-02 15:02:52 +08:00
594a196364 esp_wifi: Fix null pointer dereferences in mgmt rx 2020-09-02 14:55:10 +08:00
8757cefeec esp_wifi: add rf test long short support 2020-09-02 14:54:23 +08:00
627a05d80e esp_wifi: optimize WiFi debug log
1. Add esp_wifi_statis_dump()
2. Optimize WiFi related debug log
2020-09-02 14:52:49 +08:00
368d623e1a esp_wifi: optimize WiFi TX performance 2020-09-02 14:44:45 +08:00
9cd0e2fd1a Merge branch 'bugfix/btdm_blufi_data_sequence_not_reset_after_disconnect_v4.2' into 'release/v4.2'
component/bt: fix Blufi sends data after disconnect the seq still increase(backport v4.2)

See merge request espressif/esp-idf!10241
2020-09-02 14:20:49 +08:00
82deea84eb component/bt: fix Blufi sends data after disconnect the seq still increase(backport v4.2) 2020-09-02 11:18:25 +08:00
fb4a75110a Merge branch 'bugfix/touch_sensor_denoise_ci_for_esp32s2_backport_v4.2' into 'release/v4.2'
[High priority] Bugfix/touch sensor denoise ci for esp32s2 (backport v4.2)

See merge request espressif/esp-idf!10211
2020-09-01 21:50:59 +08:00
73fd3608e0 Merge branch 'bugfix/ble_mesh_example_compile_warn_v4.2' into 'release/v4.2'
Bugfix/ble mesh example compile warn (v4.2)

See merge request espressif/esp-idf!10222
2020-09-01 19:16:43 +08:00
86d8f15a9a MQTT: Update submodule reference
SSL: add config option for skipping common name check
esp-mqtt commit: 5e8950e681)
Closes https://github.com/espressif/esp-mqtt/issues/158

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

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

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

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

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

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

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

esp_mqtt_client_publish now returns msg id for QoS > 0 when offline
esp-mqtt commit: f7325bfa10
2020-09-01 15:57:47 +08:00
70a67439bc Websocket client: avoid deadlock if stop called from event handler 2020-09-01 15:30:40 +08:00
lly
528747ac4c ble_mesh: example: Remove some useless included header files 2020-09-01 14:10:27 +08:00
840b7f2de7 Fix compilation warnings about portmacro being already define. 2020-09-01 14:09:41 +08:00
a35ce7f959 Merge branch 'doc/local_build_version_note_v4.2' into 'release/v4.2'
docs: fix version specific note on local build (backport v4.2)

See merge request espressif/esp-idf!10148
2020-08-31 21:13:53 +08:00
f3705832fd Merge branch 'bugfix/add_adc-dma_for_esp32' into 'master'
driver(adc): add adc-dma code for esp32

Closes IDF-1407

See merge request espressif/esp-idf!9139

(cherry picked from commit 7876d7f5a6)

bd92e951 driver(adc): add adc-dma code for esp32
2020-08-31 16:29:51 +08:00
0f5bb06920 ut: fix touch sensor denoise ci fail 2020-08-31 16:01:50 +08:00
06d1f69d84 Merge branch 'feature/vfs_uart_set_line_ending_v4.2' into 'release/v4.2'
feature: support vfs uart set line endings with specified uart number release/v4.2

See merge request espressif/esp-idf!9596
2020-08-30 22:34:47 +08:00
1b0691f29a Merge branch 'feature/esp32s2_adc_calib_V1_bp4.2' into 'release/v4.2'
driver/adc: support for esp32s2 adc calibration scheme (backport 4.2)

See merge request espressif/esp-idf!10064
2020-08-29 23:22:47 +08:00
73040c3223 Merge branch 'bugfix/mfg_tool_v4.2' into 'release/v4.2'
mfg_util: Update file handling to maintain line endings across various OS (backport v4.2)

See merge request espressif/esp-idf!10174
2020-08-28 18:22:28 +08:00
7d79d9f312 Merge branch 'bugfix/btdm_blufi_send_longer_custom_data_will_congested_v4.2' into 'release/v4.2'
component/bt: fix Blufi sends longer customer data  will will lead congested(backport v4.2)

See merge request espressif/esp-idf!9948
2020-08-28 13:55:46 +08:00
51ff44d96e component/bt: fix Blufi sends longer customer data will will lead congested(backport v4.2) 2020-08-28 10:20:19 +08:00
e42742891e 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:52:33 +05:30
e050feeb26 Merge branch 'bugfix/clean_wpa2_wifi_deinit' into 'master'
wpa_supplicant: Deinit wpa2 states in wifi deinit

See merge request espressif/esp-idf!10103

(cherry picked from commit 4dcaa0e6f4)

06bc7f1d wpa_supplicant: Deinit wpa2 states in wifi deinit
2020-08-26 16:55:04 +08:00
5f56329f00 Merge branch 'bugfix/fix_udp_tx_performance_issue_v4.2' into 'release/v4.2'
lw-ip: fix udp tx packet loss issue (backport v4.2)

See merge request espressif/esp-idf!10017
2020-08-26 12:38:37 +08:00
b498f0aebe Merge branch 'bugfix/buff_semaphore_not_free_v4.2' into 'release/v4.2'
component/bt: Fixed ble memory leak issue, buff_semaphore was not released.

See merge request espressif/esp-idf!9983
2020-08-24 17:30:54 +08:00
5f09ffce96 docs: fix version specific note on local build 2020-08-24 16:10:28 +08:00
a2d20f9412 Merge branch 'bugfix/bootloader_common_get_sha256_of_partition_v4.2' into 'release/v4.2'
bootloader_support: Fix bootloader_common_get_sha256_of_partition(), can handle a long image (v4.2)

See merge request espressif/esp-idf!9952
2020-08-24 13:36:09 +08:00
22221b073b Merge branch 'test/merge_ble_mesh_node_and_provioner_in_console_v4.2' into 'release/v4.2'
Test:merge ble mesh node and provioner in console

See merge request espressif/esp-idf!9913
2020-08-21 19:59:21 +08:00
63d2a19925 Test: merge ble mesh node and provioner in console 2020-08-21 19:59:20 +08:00
2d19e56877 ethernet: support power on timeout
Closes https://github.com/espressif/esp-idf/issues/5425
2020-08-20 10:48:04 +08:00
c54d599d0d ethernet: set DMA owner after all descriptors have configured 2020-08-20 10:47:08 +08:00
d918e7ad8a ethernet: handle early rx interrupt 2020-08-20 10:47:08 +08:00
4cbed9b364 driver/adc: support for esp32s2 adc calibration scheme
ESP32 lets the user choose from using Vref, Lookup Table, and Two-Point Calibration. In ESP32S2 only two-point calibration is supported. This commit support these changes in idf.

Closes https://github.com/espressif/esp-idf/issues/5455
2020-08-17 14:43:41 +08:00
a8b8a1531e Merge branch 'feature/efuse_esp32s2_add_fields_in_table_v4.2' into 'release/v4.2'
efuse: Add some fields in efuse_table and update esp_efuse_get_pkg_ver() (v4.2)

See merge request espressif/esp-idf!9994
2020-08-17 12:50:49 +08:00
8a3ad87821 Merge branch 'bugfix/docs_building_on_windows_v4.2' into 'release/v4.2'
Docs building: added encoding check suitable for windows (v4.2)

See merge request espressif/esp-idf!10020
2020-08-17 12:12:18 +08:00
98d5b5dfd9 Merge branch 'feature/esp_spp_stop_srv_v4.2' into 'release/v4.2'
bugfix/Add API esp_spp_stop_srv and fix collection of SPP [backport v4.2]

See merge request espressif/esp-idf!9993
2020-08-15 15:46:54 +08:00
d0dae54263 Merge branch 'bugfix/update_esp32_phy_4370_v4.2' into 'release/v4.2'
esp_wifi: backport some wifi fix to v4.2

See merge request espressif/esp-idf!10024
2020-08-14 17:45:22 +08:00
a557746cdd component/bt: Fixed ble memory leak issue, buff_semaphore was not released. 2020-08-14 17:16:23 +08:00
3967e1b6d2 vfs: support vfs uart set line endings with specified uart number (release/v4.2) 2020-08-14 16:01:14 +08:00
e169226d3b Merge branch 'bugfix/wifi_deinit_stop_crash_v4.2' into 'release/v4.2'
esp_wifi: fix the crash when wifi stop after deinit (v4.2)

See merge request espressif/esp-idf!10031
2020-08-13 13:47:49 +08:00
6e94f6f9f4 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:08:28 +08:00
a57fb727e7 esp_wifi: backport some wifi fix to v4.2
1.Fix WiFi fragment issue
2.fix the bug for softAP power save buffer issue
3.fix softap mode event issue
4.fix connect hidden AP doesn't update information
5.update esp32 phy v4370
2020-08-12 21:59:37 +08:00
0e24eacc81 bugfix: fix softap mode event issue
1. add sta connect again ap sent disconnect event
2. add set/get inactive time api

Closes https://github.com/espressif/esp-idf/issues/4401
Closes https://github.com/espressif/esp-idf/issues/4987
Closes https://github.com/espressif/esp-idf/issues/2375
2020-08-12 21:58:48 +08:00
010a825f48 docs: adds to build_docs.py an encoding check suitable for windows 2020-08-12 11:17:35 +02:00
c91ca054c3 lwip: fix udp tx packet loss issue 2020-08-12 15:02:29 +08:00
7dfe4b4684 Merge branch 'bugfix/mbedtls_mpi_exp_mod_v4.2' into 'release/v4.2'
mbedtls: Fix a case for mpi_montgomery_exp_calc() when Z is not init (v4.2)

See merge request espressif/esp-idf!9497
2020-08-11 10:00:07 +08:00
202dbaffa7 Merge branch 'bugfix/wpa3_to_wpa2_transition_fix_v4.2' into 'release/v4.2'
wpa_supplicant: Fix WPA3 and WPA2 transition related failures (Backport v4.2)

See merge request espressif/esp-idf!9865
2020-08-10 23:25:42 +08:00
f4a7ee3db3 esp_wifi: fix the crash when wifi stop after deinit 2020-08-10 20:34:50 +08:00
76cd5c8793 Merge branch 'feature/tinyusb_config_cleanup_v4.2' into 'release/v4.2'
Feature/tinyusb config cleanup (v4.2)

See merge request espressif/esp-idf!9824
2020-08-10 18:17:42 +08:00
94597fc8e3 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-08-10 09:41:35 +00:00
21dc9fcb5d 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-08-10 09:05:48 +00:00
d87d9a714e efuse: Add some fields in efuse_table and update esp_efuse_get_pkg_ver()
Closes: IDF-1077
2020-08-10 15:59:02 +08:00
e01cab4a71 Merge branch 'doc/version_specific_inc_bugfix_v4.2' into 'release/v4.2'
doc: fall back to CI_COMMIT_REF_NAME as a branch name (v4.2)

See merge request espressif/esp-idf!9863
2020-08-10 13:35:55 +08:00
b9535ed91b Merge branch 'bugfix/ble_mesh_client_msg_optimize_v4.2' into 'release/v4.2'
Bugfix/ble mesh client msg optimize (v4.2)

See merge request espressif/esp-idf!9989
2020-08-10 11:02:43 +08:00
lly
c24de8dc10 ble_mesh: stack: Client model related code clean 2020-08-07 21:11:34 +08:00
lly
59a590fb25 ble_mesh: stack: Rename cfg & health client status recv func 2020-08-07 21:11:34 +08:00
lly
f0b89688c9 ble_mesh: stack: Check client msg result in common func 2020-08-07 21:11:34 +08:00
lly
41aea8e528 ble_mesh: stack: Fix no events for some error conditions 2020-08-07 21:11:34 +08:00
lly
bc19eb2506 ble_mesh: stack: Move client role set to the msg function 2020-08-07 21:11:33 +08:00
lly
964f372d58 ble_mesh: stack: Remove some not used client parameters 2020-08-07 21:11:33 +08:00
lly
29749b9dae ble_mesh: stack: Remove some not used variables & functions 2020-08-07 21:11:33 +08:00
lly
c058f3594f ble_mesh: stack: Update client model msg send 2020-08-07 21:11:33 +08:00
c72ae1281e Merge branch 'bugfix/put_periph_module_enable/diable_into_iram_v4.2' into 'release/v4.2'
wifi, bt: move esp_phy_common_clock_disable into periph_ctrl and put it into IRAM(v4.2)

See merge request espressif/esp-idf!9934
2020-08-07 18:10:01 +08:00
2620942568 bootloader_support: Fix bootloader_common_get_sha256_of_partition, can handle a long image
Closes: IDFGH-3594
2020-08-07 08:49:18 +00:00
229dbd70c9 mbedtls: Fix a case for mpi_montgomery_exp_calc() when Z is not init
Closes: IDF-1870
2020-08-07 08:43:12 +00:00
7162964776 Merge branch 'feature/enable_pcm_config_v4.2' into 'release/v4.2'
Feature/enable pcm config v4.2

See merge request espressif/esp-idf!9652
2020-08-07 14:19:03 +08:00
4382ec4b8d Merge branch 'component/seperate_bta_jv_l2c_4.2' into 'release/v4.2'
Component/seperate bta jv l2c 4.2

See merge request espressif/esp-idf!9644
2020-08-07 14:18:02 +08:00
0db87821f1 Merge branch 'bugfix/customer_baidu_int_wdt_v4.2' into 'release/v4.2'
backport v4.2: add soft solution for esp32 eco3 live lock issue

See merge request espressif/esp-idf!9223
2020-08-07 14:12:00 +08:00
501ca00178 Merge branch 'feature/esp_tls_for_supplicant_v4.2' into 'release/v4.2'
wpa_supplicant: Support for mbedtls tls handshake(backport v4.2)

See merge request espressif/esp-idf!9821
2020-08-07 14:01:54 +08:00
04e31d2f81 Merge branch 'test/esp_flash_rw_performance_thr_4.2' into 'release/v4.2'
esp_flash: decrease some of the performance threshold (4.2)

See merge request espressif/esp-idf!9959
2020-08-07 11:58:21 +08:00
15e408d070 newlib: Fix UT for adjtime 2020-08-06 20:01:52 +08:00
39e318977d 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:01:52 +08:00
5f0eb04684 esp_flash: decrease some of the performance threshold 2020-08-06 12:04:22 +08:00
dd3c032972 Merge branch 'bugfix/esp_netif_restart_dhcpc_v4.2' into 'release/v4.2'
esp_netif: Remove restarting DHCP client/server if it has already been started (backport v4.2)

See merge request espressif/esp-idf!9919
2020-08-06 11:19:30 +08:00
96bc7761f5 Merge branch 'feature/upgrade_mbedtls_to_v4.2' into 'release/v4.2'
mbedtls: update to mbedtls release v2.16.7 (v4.2)

See merge request espressif/esp-idf!9906
2020-08-05 20:13:40 +08:00
caa21fdc67 remove auto conn case because we do not support this anymore 2020-08-05 18:03:12 +08:00
0b1ef494a7 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 14:08:46 +08:00
789119262b Merge branch 'fixbug/sdmmc_spi_highspeed_v4.2' into 'release/v4.2'
sdmmc: fix the probe issue that forbid sdspi working in highspeed mode(backport v4.2)

See merge request espressif/esp-idf!9841
2020-08-04 17:45:37 +08:00
9409b2ecb7 Merge branch 'feature/support_for_esp32_pico_v3_02_v4.2' into 'release/v4.2'
psram: support for esp32-pico-v3-02 (backport v4.2)

See merge request espressif/esp-idf!9787
2020-08-04 14:30:14 +08:00
e911826340 add soft solution for esp32 eco3 live lock issue 2020-08-04 05:50:18 +00:00
706bc799fa Merge branch 'bugfix/fix_fragment_issue_v4.2' into 'release/v4.2'
esp_wifi: Fix WiFi fragment issue (backport v4.2)

See merge request espressif/esp-idf!9896
2020-08-04 12:26:04 +08:00
0e6777f78b esp_netif tests: Add manual DHCP state transision tests
Extended test cases for DHCP server and DHCP client state transitions to include also manual transitions using esp_netif_dhcps_start/stop() esp_netif_dhcpc_start/stop()
2020-08-04 12:07:57 +08:00
39f804ae07 esp_netif: Remove restarting DHCP client and server if it has already been started
To be in line with previous behaviour in tcpip_adapter, do nothing and return appropriate error if the DHCP client/server has already been started
2020-08-04 12:07:49 +08:00
8796a53132 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 14:14:10 +05:30
9dbff45229 Merge branch 'feature/twai_backport_v4.2' into 'release/v4.2'
TWAI: esp32s2 support and multiple bugfixes (backport v4.2)

See merge request espressif/esp-idf!9884
2020-08-03 11:13:20 +08:00
2f96a1a3bf Merge branch 'bugfix/add_api_adc2_vref_to_gpio_for_esp32s2_backport_v4.2' into 'release/v4.2'
driver(adc): esp32s2 support API `adc2_vref_to_gpio`  (backport v4.2)

See merge request espressif/esp-idf!9875
2020-08-01 23:50:13 +08:00
a32fc5a2bb Fix tsk watchdog when running spp vfs demo 2020-08-01 16:40:43 +08:00
8de78c2b3b Seperate BTA_JV_L2CAP for less bin size 2020-08-01 16:40:43 +08:00
64eab16847 Enable PCM config in controller 2020-08-01 16:37:34 +08:00
0952b9de8a Enable PCM Config in Host 2020-08-01 16:36:36 +08:00
ad8a873dff esp_wifi: Fix WiFi fragment issue 2020-07-31 20:17:45 +08:00
885f8ce484 driver(adc): esp32s2 support API adc2_vref_to_gpio 2020-07-31 17:52:41 +08:00
934fe37c48 Merge branch 'bugfix/fix_adc_dac_driver_ut_backport' into 'release/v4.2'
Driver(adc): fix adc driver and UT  (backport v4.2)

See merge request espressif/esp-idf!9359
2020-07-31 17:09:24 +08:00
33dab9d165 Merge branch 'bugfix/fix_softap_mode_wpa_memory_leak_issue_v4.2' into 'release/v4.2'
bugfix: fix softap mode wpa memory leak (backport v4.2)

See merge request espressif/esp-idf!9845
2020-07-31 16:45:38 +08:00
9f4f7aa8b1 Merge branch 'feature/export_ps1_tools_v4.2' into 'release/v4.2'
scripts: updates export.ps1 to export tools' paths (v4.2)

See merge request espressif/esp-idf!9876
2020-07-31 05:05:39 +08:00
21e2f02962 TWAI: Remove asserts used for program logic
This commit fixes the bug where TWAI driver program logic was being
called in assert(), thus leading to the logic being omitted in
release builds.
2020-07-30 22:17:41 +08:00
519b8898b3 twai: Fix size of RX msg count field on the esp32
This commit fixes the size of the RX message count register field
on the esp32.
2020-07-30 22:17:14 +08:00
e6db25af9d TWAI: Add ESP32-S2 support
This commit adds TWAI driver support for the
ESP32-S2. The following features were added:

- Expanded BRP support
- Expanded CLKOUT Divider Support
- Updated example READMEs
2020-07-30 22:09:39 +08:00
74df8746a3 scripts: updates export.ps1 to export tools' paths 2020-07-30 13:55:03 +02:00
f444d4d2dc driver(adc): fix unit test for ADC-DMA (test_esp32s2.c); fix unit test for ADC-DMA (test_esp32s2.c); fix commit in adc dirver. 2020-07-30 19:38:23 +08:00
4726076da5 Merge branch 'bugfix/fix_touch_sensor_api_backport_v4.2' into 'release/v4.2'
driver(touch): fix touch sensor driver redundancy  (backport v4.2)

See merge request espressif/esp-idf!9861
2020-07-30 16:17:51 +08:00
2802136595 doc: fall back to CI_COMMIT_REF_NAME as a branch name
In some cases gen_version_specific_includes.py would fail to find a branch/tag name for a commit
and would fall back to using commit SHA-1.

This should never happen in docs that should be published as we use the branch/tag name to generate
example commands for our users. E.g. "git clone -b $branch_name"

Closes https://github.com/espressif/esp-idf/issues/5657
2020-07-30 12:25:59 +08:00
9bc72d5732 driver(touch): fix touch sensor driver redundancy 2020-07-30 11:41:11 +08:00
f06ce4832d Merge branch 'bugfix/update_esp32_phy_4350_v4.2' into 'release/v4.2'
esp_wifi: update phy lib(Backport v4.2)

See merge request espressif/esp-idf!9823
2020-07-30 01:59:04 +08:00
e5b242a3cb usb: removes non-integrated features 2020-07-29 15:50:56 +02:00
e7179db204 Merge branch 'nimble/nrpa_support_v4.2' into 'release/v4.2'
NimBLE: Add Non-Resolvable private address support and misc bug fixes (Backport v4.2)

See merge request espressif/esp-idf!9741
2020-07-29 19:05:01 +08:00
10e59593f6 Merge branch 'bugfix/bt_linkup_fallback_event_v4.2' into 'release/v4.2'
Bluedroid: Fixes cases having fallback to link up event. (v4.2)

See merge request espressif/esp-idf!9801
2020-07-29 19:04:41 +08:00
157ecfaf43 bugfix: fix softap mode wpa memory leak 2020-07-29 14:14:35 +08:00
293d7f34b8 Merge branch 'fix/prov_ble_read_offset_v4.2' into 'release/v4.2'
BLE provisioning: Add check for valid ble read offset (v4.2)

See merge request espressif/esp-idf!9744
2020-07-28 16:42:09 +08:00
2d9325db1e Merge branch 'bugfix/build_docs_check_link_v4.2' into 'release/v4.2'
build_docs: fix incorrect arguments for linkcheck (Backport v4.2)

See merge request espressif/esp-idf!9798
2020-07-28 14:00:55 +08:00
19ae66dfa2 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:36:03 +08:00
12dd6e5a85 Merge branch 'doc/freertos_backport_v4.2' into 'release/v4.2'
add a note about ESP-IDF FreeRTOS version (backport v4.2)

See merge request espressif/esp-idf!9810
2020-07-27 23:00:47 +08:00
02e7e9c417 esp_wifi: update phy lib
1. esp32 phy lib v4350
2. esp32s2 phy lib v603
2020-07-27 21:42:44 +08:00
8bb287bae8 esp_wifi: Add esp_wifi_get_tsf_time() API to get the tsf time of
specified interface.

Closes https://github.com/espressif/esp-idf/issues/5533
2020-07-27 21:41:36 +08:00
3af4b51a5c Fix handling of multiple AP credentials in WPS
WPS can send multiple AP credentials, while existing implementation
will only use the first credentials which could be for the 5G band.
Fix this by passing these credentials to the App and attempting
to connect using each of those. Older Apps will remain compatible
without breaking WPS, but the issue will remain.
2020-07-27 21:41:20 +08:00
875642fedd Merge branch 'doc/update_chip_features_v4.2' into 'release/v4.2'
doc: update chip features in getting started (Backport v4.2)

See merge request espressif/esp-idf!9797
2020-07-27 21:26:53 +08:00
ebd1bb9a12 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-07-27 18:49:47 +05:30
89ef69cbd0 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-07-27 18:49:07 +05:30
4b7c8d4a2d wpa_supplicant: Support for mbedtls tls handshake
Add support for mbedtls based tls handshake, this removes
dependency from internal implementation of EAP client.
2020-07-27 18:47:27 +05:30
76e7fcf0e4 update a link in the note 2020-07-27 17:27:31 +08:00
9cf4dd20e0 Bluedroid: Fixes cases having fallback to link up event.
Signed-off-by: Chinmay Chhajed <chinmay.chhajed@espressif.com>
2020-07-27 13:52:58 +05:30
b284c48854 Merge branch 'bugfix/esp32s2_lightsleep_uart_suspend_v4.2' into 'release/v4.2'
esp32s2: suspend UART output using XOFF before entering light sleep (backport v4.2)

See merge request espressif/esp-idf!9293
2020-07-27 15:55:33 +08:00
851b4e9576 BLE provisioning: Add check for valid ble read offset 2020-07-27 07:21:07 +00:00
b081292e8e build_docs: fix incorrect arguments for linkcheck 2020-07-27 15:14:59 +08:00
207cbabc51 doc: update chip features in getting started
Fixed number of cores for ESP32 and ESP32S2 being wrong.

Updated S2 to reflect that we have to ULP coprocessors

Closes IDFGH-3616
Closes https://github.com/espressif/esp-idf/issues/5556
2020-07-27 15:12:31 +08:00
636b964c8c Merge branch 'bugfix/ws_send_abort_v4.2' into 'release/v4.2'
websocket client: the client now aborts the connection if send fails. (backport v4.2)

See merge request espressif/esp-idf!9169
2020-07-24 23:15:08 +08:00
3191a8cbc7 esp32s2: Always use eFuse config for WP pin
No reason to override just this pin in software.
2020-07-24 21:45:59 +08:00
a94685a222 esp32: Use package identifier to look up SPI flash/PSRAM WP Pin, unless overridden
Allows booting in QIO/QOUT mode or with PSRAM on ESP32-PICO-V3 and
ESP32-PICO-V3-O2 without any config changes.

Custom WP pins (needed for fully custom circuit boards) should still be compatible.
2020-07-24 21:45:31 +08:00
55a1bd0fb6 feat(esp32): support for esp32-pico-v3-02 2020-07-24 21:20:27 +08:00
c945cb59d8 feat(psram): support 16Mbit PSRAM for esp32 2020-07-24 21:19:45 +08:00
6a253e8809 bugfix(psram): configure MMU after PSRAM initialization 2020-07-24 21:10:37 +08:00
ce7affe81c Merge branch 'docs/doc138_backport_v4.2' into 'release/v4.2'
Fix incorrect redirect link in getting started guide (backport v4.2)

See merge request espressif/esp-idf!9703
2020-07-24 18:04:00 +08:00
a4e8e56288 NimBLE: Add Non-Resolvable private address support and misc bug fixes (Backport v4.2)
- Merges https://github.com/espressif/esp-nimble/pull/12
- Fixes repeated pairing failure in RPA feature

Closes https://github.com/espressif/esp-idf/issues/5530
2020-07-24 06:55:22 +00:00
23beab8a98 Merge branch 'feature/update_cryptoauthlib_submodule_pointer_v4.2' into 'release/v4.2'
esp32/secure_element: update esp-cryptoauthlib submodule pointer (v4.2)

See merge request espressif/esp-idf!9768
2020-07-24 14:45:24 +08:00
04e5b16f74 esp32/secure_element: update esp-cryptoauthlib submodule pointer 2020-07-24 09:45:00 +05:30
6b80aebc87 Merge branch 'bugfix/convert-string-to-bytes_v4.2' into 'release/v4.2'
components: convert string to bytes to fix TypeError (backport v4.2)

See merge request espressif/esp-idf!9734
2020-07-23 16:36:57 +08:00
e6e4fe45c6 Merge branch 'ci/fix_uart_read_write_priorities_v4.2' into 'release/v4.2'
driver test: Ensure uart write task can't overflow buffer of read task (v4.2)

See merge request espressif/esp-idf!9569
2020-07-23 13:15:45 +08:00
16eeb3b432 tools: Updates OpenOCD version to 'v0.10.0-esp32-20200709' 2020-07-22 23:15:40 +03:00
51b5c7a079 Merge branch 'bugfix/mcpwm_fault_init_copypaste_typo_bp4.2' into 'release/v4.2'
MCPWM: Fix PWM-fault init function that read config incorrectly (backport v4.2)

See merge request espressif/esp-idf!9554
2020-07-22 21:12:16 +08:00
5feeb744e1 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:23:12 +02:00
dc06fd3c20 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 16:49:00 +08:00
ccdfbb865e Merge branch 'bugfix/add_return_task_awoken_for_timer_callback_v4.2' into 'release/v4.2'
timer: add return task awoken for timer callback (backport v4.2)

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

See merge request espressif/esp-idf!9684
2020-07-22 11:52:43 +08:00
441308fc16 websocket client: the client now aborts the connection if send fails.
Closes IDF-1744
2020-07-21 07:51:01 +00:00
53e8857849 Merge branch 'bugfix/ipv6_fragment_for_4.2' into 'release/v4.2'
lw-ip:fix bug for ipv6 fragment(backport 4.2)

See merge request espressif/esp-idf!9583
2020-07-21 12:11:34 +08:00
0bcd26a610 Merge branch 'bugfix/fix_hci_max_page_num_v4.2' into 'release/v4.2'
bugfix/Support for more Bluetooth HID devices [backport v4.2]

See merge request espressif/esp-idf!9660
2020-07-21 12:10:59 +08:00
15e40f909f Merge branch 'bugfix/fix_get_bond_device_list_v4.2' into 'release/v4.2'
bugfix/fix esp_bt_gap_get_bond_device_list bug [backport v4.2]

See merge request espressif/esp-idf!9666
2020-07-21 12:10:24 +08:00
e1635edc47 Merge branch 'bugfix/espcoredump_fix_error_reported_for_blank_partition_v42' into 'release/v4.2'
Bugfix/espcoredump fix error reported for blank partition (Backport v4.2)

See merge request espressif/esp-idf!9629
2020-07-21 01:05:57 +08:00
5f1e61498e Bugfix/espcoredump fix error reported for blank partition (Backport v4.2) 2020-07-21 01:05:54 +08:00
e1b03f08af Merge branch 'bugfix/doc_macro_definitions_v4.2' into 'release/v4.2'
doc: Fix macro definitions for different targets (v4.2)

See merge request espressif/esp-idf!9566
2020-07-20 08:25:33 +08:00
b3692aba5e CI: do not run cases likely to fail 2020-07-19 14:52:57 +08:00
468bd6f854 CI: disable cases with test env SSC_T5_1 2020-07-19 14:52:57 +08:00
9d215de21d CI: temp allow mesh job to fail as runner is not stable 2020-07-19 14:52:56 +08:00
fb7e3c508b CI: remove incorrect MTU related cases 2020-07-19 14:52:56 +08:00
73ec4d0c1d Merge branch 'bugfix/ble_mesh_health_current_status_recv_v4.2' into 'release/v4.2'
ble_mesh: stack: Fix recv health current status incorrectly (v4.2)

See merge request espressif/esp-idf!9664
2020-07-17 16:14:25 +08:00
e14906f073 fix esp_bt_gap_get_bond_device_list bug
Closes https://github.com/espressif/esp-idf/issues/5395
2020-07-17 15:06:39 +08:00
lly
b39eaf61b5 ble_mesh: stack: Fix recv health current status incorrectly 2020-07-17 14:05:18 +08:00
d1506fdae0 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:07:41 +08:00
d26405df96 Merge branch 'bugfix/ble_mesh_misc_updates_v4.2' into 'release/v4.2'
Bugfix/ble mesh misc updates (v4.2)

See merge request espressif/esp-idf!9641
2020-07-16 14:03:27 +08:00
lly
49145856a2 ble_mesh: ci: Enable friend & low power in build check 2020-07-16 11:02:25 +08:00
lly
2e01297603 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:02:24 +08:00
lly
5fceac92ee ble_mesh: stack: Make proxy server & client functions clear 2020-07-16 11:02:24 +08:00
d8c657c6f0 Merge branch 'bugfix/ble_mesh_add_misc_check_v4.2' into 'release/v4.2'
Bugfix/ble mesh add misc check (v4.2)

See merge request espressif/esp-idf!9630
2020-07-16 10:52:26 +08:00
a60bfb8cdc Merge branch 'feature/reassign_example_test_runners_v4.2' into 'release/v4.2'
ci: Modify some dut-unrelated example tests env tag from Example_WIFI to Example_GENERIC (backport v4.2)

See merge request espressif/esp-idf!9634
2020-07-16 03:29:31 +08:00
a73b0c3eb6 ci: Modify some dut-unrelated example tests env tag from Example_WIFI to Example_GENERIC 2020-07-15 16:54:03 +08:00
001c673f4e Merge branch 'bugfix/eth_insert_min_hw_reset_time_v4.2' into 'release/v4.2'
ethernet: insert min assert time for PHY HW reset (v4.2)

See merge request espressif/esp-idf!9579
2020-07-15 16:35:46 +08:00
lly
fc99963376 ble_mesh: stack: Add proxy cfg pdu length check 2020-07-15 16:10:48 +08:00
lly
1846def7ac 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:10:48 +08:00
lly
cf5b69389e ble_mesh: example: Add result check during mesh init 2020-07-15 16:10:48 +08:00
lly
37322ce93f ble_mesh: stack: Add more checks about input prov bearers 2020-07-15 16:10:48 +08:00
daf8098a00 Merge branch 'feat/ble_mesh_use_iram_for_mem_alloc_v4.2' into 'release/v4.2'
Feat/ble mesh use iram for mem alloc (v4.2)

See merge request espressif/esp-idf!9614
2020-07-15 16:06:47 +08:00
c59b27b417 Merge branch 'bugfix/cleanup_bt_reference_from_esp32s2_ld_v4.2' into 'release/v4.2'
esp32s2: cleanup bt reference from esp32s2 ld (v4.2)

See merge request espressif/esp-idf!9613
2020-07-14 22:52:11 +08:00
lly
a6dcfb4a5a ble_mesh: stack: Rename mesh adv queue and relay queue 2020-07-14 21:19:32 +08:00
lly
efcd9ee4a8 ble_mesh: stack: Use macros for adv task name & prio 2020-07-14 21:19:32 +08:00
lly
e58d982903 ble_mesh: ci: Add iram & psram configurations 2020-07-14 21:19:32 +08:00
lly
6abfc2a8f7 ble_mesh: stack: Make freertos static allocation visible 2020-07-14 21:19:32 +08:00
lly
c0db196464 ble_mesh: stack: Add a option of using IRAM for memory allocation 2020-07-14 21:19:32 +08:00
a9d8d8ea99 esp32s2: remove bt references from esp32s2 ld script 2020-07-14 18:04:28 +05:30
452ce608fe Merge branch 'bugfix/fix_erro_in_ag_api_4.2' into 'release/v4.2'
Fix error of AG API return line v4.2

See merge request espressif/esp-idf!9605
2020-07-14 19:54:17 +08:00
b716800000 Fix error of AG API return line
Closes https://github.com/espressif/esp-idf/issues/5554
2020-07-14 14:43:15 +08:00
38e75dca1d Merge branch 'bugfix/enable_mbedtls_renegotiation_v4.2' into 'release/v4.2'
esp-tls: enable TLS renegotiation using explicit API call (v4.2)

See merge request espressif/esp-idf!9590
2020-07-14 12:05:02 +08:00
c57f9b76cb Merge branch 'bugfix/ota_ci_failures_v4.2' into 'release/v4.2'
Increse receive timeout in OTA Example tests to fix CI failures (v4.2)

See merge request espressif/esp-idf!9588
2020-07-13 23:01:23 +08:00
31121e5af1 Merge branch 'bugfix/rs485_test_temp_disable_v42' into 'release/v4.2'
Bugfix/rs485 test temp disable (backport v4.2)

See merge request espressif/esp-idf!9525
2020-07-13 20:41:42 +08:00
40a29866f6 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:32:41 +05:30
4ed889dfa2 esp32s2: sleep_modes: remove dependency on driver/uart.h 2020-07-13 09:52:29 +02:00
3a88ac7900 soc: add periph_ll_periph_enabled to clk_gate_ll.h 2020-07-13 09:52:29 +02:00
31cd3f1294 esp32s2: suspend UART output using XOFF before entering light sleep
Same logic as for the ESP32, except two changes:

* need to set UART_SW_FLOW_CON_EN bit for UART_FORCE_XOFF to take
  effect
* need to check if the peripheral is not clockgated and out of reset
2020-07-13 09:52:29 +02:00
1f16f5cf22 Increse receive timeout in sdkconfig.ci to fix CI failures 2020-07-13 10:15:01 +05:30
74396ae2cc fix bug for ipv6 fragment 2020-07-13 11:49:52 +08:00
49c1d40b2d ethernet: insert min assert time for PHY HW reset
Closes https://github.com/espressif/esp-idf/issues/5528
2020-07-13 11:05:38 +08:00
1f8c5b2b64 Merge branch 'docs/fix_event_typo_backport_v4.2' into 'release/v4.2'
docs/fix event typo backport v4.2

See merge request espressif/esp-idf!9382
2020-07-12 21:24:03 +08:00
9274339fb5 timer: add return task awoken for timer callback 2020-07-12 11:01:47 +00:00
d6553232cb Merge branch 'bugfix/issues_with_vanilla_freertos_v4.2' into 'release/v4.2'
Fix build issues with Vanilla FreeRTOS (v4.2)

See merge request espressif/esp-idf!9576
2020-07-12 16:39:20 +08:00
07abd9092a Include header file soc/cpu.h in memprot.c and system_api.c
This fixes build issues with Vanilla FreeRTOS
2020-07-10 18:21:20 +05:30
897e950e21 Merge branch 'bugfix/add_api_to_get_internal_heap_v4.2' into 'release/v4.2'
esp_wifi: Add API to get available internal heap size (backport v4.2)

See merge request espressif/esp-idf!9516
2020-07-10 16:54:38 +08:00
86c197a8db Merge branch 'bugfix/ble_mesh_update_send_ttl_v4.2' into 'release/v4.2'
Bugfix/ble mesh update send ttl v4.2

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

Related to IDFCI-59
2020-07-10 15:59:48 +10:00
21b123a925 Merge branch 'feature/sphinx_idf_theme_pip_v4.2' into 'release/v4.2'
docs: update build system to use sphinx_idf_theme pip package (v4.2)

See merge request espressif/esp-idf!9478
2020-07-10 12:56:43 +08:00
c44a433b8b driver: Fix some doxygen warnings 2020-07-10 14:53:16 +10:00
e3664e297b docs: Redirect all of Doxygen stderr to the warnings log
Some errors (for example the errors caused by macro values, as fixed in previous
commit) get logged to stderr even if WARN_LOGFILE is set, but Doxygen succeeds.
2020-07-10 14:53:16 +10:00
db5d659762 docs: Log the full list of macros, remove code-style macros to prevent Doxygen errors 2020-07-10 14:53:15 +10:00
2b270bccbf doc: Fix passing of build macros to Doxygen
Regression in fbb54184ef, the dictionary
passed to generate_doxygen function was still the project_description
structure.
2020-07-10 14:53:15 +10:00
b39a0be9d2 Merge branch 'bugfix/fix_adc_dac_conflict_backportv4.2' into 'release/v4.2'
Driver(adc): Disable the synchronization operation function of ADC1 and DAC (backport v4.2)

See merge request espressif/esp-idf!9360
2020-07-10 11:05:00 +08:00
lly
615d64b6f9 ble_mesh: stack: Add two application macros for TTL 2020-07-10 09:13:53 +08:00
lly
1ec2f98691 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:13:53 +08:00
e64d1378b4 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:19:23 +08:00
f52c35258c Merge branch 'bugfix/fix_16mbit_psram_id_read_error_v4.2' into 'release/v4.2'
psram: fix 16mbit psram id read error (backport v4.2)

See merge request espressif/esp-idf!9424
2020-07-09 15:27:23 +08:00
d58bb32f95 Merge branch 'bugfix/fix_build_err_in_cpp_backport_v4.2' into 'release/v4.2'
ble_hid_device_demo: fix build if building with c++ backport v4.2

See merge request espressif/esp-idf!9230
2020-07-09 15:25:51 +08:00
d1c4791dad Add platform independent CMake signing 2020-07-09 11:54:53 +05:30
89fa339732 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-09 04:56:44 +00:00
de17289461 esp_prov: Extend the timeout for HTTP connection to SoftAP 2020-07-09 04:56:44 +00:00
6d5dc5def3 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-09 04:56:44 +00:00
9c6c6e6885 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-09 04:56:44 +00:00
130c97ad69 esp_prov: Refactor to use new 'wait_wifi_connected' function
Means all provisioning examples will have the same retry behaviour.
2020-07-09 04:56:44 +00:00
ae586deeeb ci provisioning: Use strings instead of "magic numbers" for connection state 2020-07-09 04:56:44 +00:00
5e0e4a5f01 ci: Wait up to 60 seconds for client to connect to DUT in provisioning test 2020-07-09 04:56:44 +00:00
9eab094658 Merge branch 'doc/broken_readme_links_v4.2' into 'release/v4.2'
Docs: Fix broken README links (v4.2)

See merge request espressif/esp-idf!9499
2020-07-08 23:53:03 +08:00
f7c5e49504 Merge branch 'doc/check_docs_multi_builder_v4.2' into 'release/v4.2'
docs: fix check_docs not working for multiple builders (v4.2)

See merge request espressif/esp-idf!9480
2020-07-08 23:50:36 +08:00
ccc4f1337b Merge branch 'doc/add_UUID_description_in_gattc_demo_backport_v4.2' into 'release/v4.2'
docs:add 128-bit UUID description backport v4.2

See merge request espressif/esp-idf!9224
2020-07-08 16:14:45 +08:00
0cb87f67da Merge branch 'feature/console_repl_over_uart_v4.2' into 'release/v4.2'
console_repl over UART (v4.2)

See merge request espressif/esp-idf!9422
2020-07-08 16:10:37 +08:00
aec1353ffe ci: temporarily disable RS485 related tests 2020-07-08 06:54:24 +02:00
8efabd1307 esp_wifi: Add API to get available internal heap size. 2020-07-08 10:46:34 +08:00
4911dde551 nvs: unit tests for new partition API 2020-07-08 08:59:12 +08:00
051dff88e4 nvs: allow to specify custom partition
Closes https://github.com/espressif/esp-idf/pull/5172
2020-07-08 08:59:03 +08:00
e4e5b18c61 Fix broken README links 2020-07-07 17:11:32 +08:00
ad5c4eb3f5 Merge branch 'mesh/bugfix_for_tbtt_update_v4.2' into 'release/v4.2'
fix the bug for tsf check (backport v4.2)

See merge request espressif/esp-idf!9279
2020-07-07 14:40:35 +08:00
59541071fb Merge branch 'bugfix/gen_crt_py3_utf_v4.2' into 'release/v4.2'
Fixes issues encoding issues python3 scripts for unicode chars (v4.2)

See merge request espressif/esp-idf!9174
2020-07-07 11:04:59 +08:00
9b21973363 Merge branch 'feature/msys2_env_update_v4.2' into 'release/v4.2'
windows: Update MSYS2 pre-compiled legacy build environment (v4.2)

See merge request espressif/esp-idf!9142
2020-07-06 15:14:45 +08:00
302a43562d docs: fix check_docs not working for multiple builders
Closes IDF-1659
2020-07-06 12:27:02 +08:00
61904135b3 docs: update sphinx_idf_theme documentation
Bump CI doc-env docker image to v5
2020-07-06 10:55:32 +08:00
a3a22d4af5 Merge branch 'bugfix/fix_ci_about_touch_sensor_denoise_ut_backport_v4.2' into 'release/v4.2'
driver(touch): fix touch sensor denoise unit test case (backport v4.2)

See merge request espressif/esp-idf!9451
2020-07-06 10:21:32 +08:00
0e8f630711 Merge branch 'bugfix/esp32_encrypted_flash_write_v4.2' into 'release/v4.2'
spi_flash: esp32: fix regression in encrypted flash write (v4.2)

See merge request espressif/esp-idf!9349
2020-07-06 08:18:56 +08:00
4761c4059a esp_wifi:
1. Avoid parsing RSN/WPA IE's after connection
2. Remove AUTH_CHANGED reason code logic
3. fix the bug when calculating the PMK, the local rx beacon time increment is 0
4. mesh: don't disconnect when tbtt update
2020-07-03 14:18:39 +08:00
a1c11b3f9e Merge branch 'bugfix/ble_mesh_fast_prov_misc_update_v4.2' into 'release/v4.2'
Bugfix/ble mesh fast prov misc update (v4.2)

See merge request espressif/esp-idf!9462
2020-07-03 11:11:37 +08:00
lly
dd6de08bea ble_mesh: stack: Update some fast prov functions 2020-07-03 08:53:16 +08:00
lly
661e1f2500 ble_mesh: stack: Move fast prov functions to a single file 2020-07-03 08:53:16 +08:00
f9cee602fb Merge branch 'bugfix/ble_mesh_split_tinycrypt_v4.2' into 'release/v4.2'
Bugfix/ble mesh split tinycrypt (v4.2)

See merge request espressif/esp-idf!9371
2020-07-02 22:46:21 +08:00
34fc02f5db driver(touch): fix touch sensor denoise unit test case 2020-07-02 13:04:46 +08:00
lly
76baeba6b7 ble_mesh: ci: Fix failing to compile when using make 2020-07-02 03:53:50 +00:00
lly
7e7d2ae401 ble_mesh: Mark platform related default RNG as 0 2020-07-02 03:53:50 +00:00
lly
d9e8508981 ble_mesh: Remove the previously added redundant aes files 2020-07-02 03:53:50 +00:00
lly
11406d7ee8 ble_mesh: Update CMake and make files for tinycrypt 2020-07-02 03:53:50 +00:00
lly
80837bd936 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:53:50 +00:00
lly
3c0584f013 ble_mesh: Format source and header files of tinycrypt 2020-07-02 03:53:50 +00:00
lly
f1f3c7afd6 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:53:50 +00:00
de5d145c9b Merge branch 'bugfix/ble_mesh_readme_fix_v4.2' into 'release/v4.2'
ble_mesh: example: Fix example README & tutorial link error (v4.2)

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

See merge request espressif/esp-idf!9430
2020-07-02 11:28:55 +08:00
69b0761114 Merge branch 'bugfix/sntp_example_test_v4.2' into 'release/v4.2'
Fix SNTP example test to match pattern (v4.2)

See merge request espressif/esp-idf!9447
2020-07-02 10:28:52 +08:00
6e7a091e39 Fix SNTP example test to match pattern 2020-07-01 14:37:06 +02:00
68ed940668 Driver(adc): Disable the synchronization operation function of ADC1 and DAC
Closes IDF-1585
2020-07-01 09:29:34 +00:00
ce60660c7c Merge branch 'bugfix/fix_ping_specify_length_issue_v4.2' into 'release/v4.2'
bugfix: fix ICMP specify length issue (backport v4.2)

See merge request espressif/esp-idf!9401
2020-07-01 17:25:26 +08:00
68fae8b48f Merge branch 'doc/restore_missing_zh_eth_guide_v4.2' into 'release/v4.2'
docs: restore chinese get-started-ethernet-kit guide (v4.2)

See merge request espressif/esp-idf!9375
2020-07-01 16:25:02 +08:00
lly
f14a71e8b7 ble_mesh: example: Fix example README & tutorial link error 2020-07-01 14:36:30 +08:00
e5fed6d67d Merge branch 'mesh/bugfix_coexist_warning_4.2' into 'release/v4.2'
mesh: remove coexist warnings in ESP_WIFI_MESH (backport 4.2)

See merge request espressif/esp-idf!9412
2020-07-01 13:51:30 +08:00
655772ec23 Merge branch 'feature/bt_secure_conn_downgrade_check_v4.2' into 'release/v4.2'
Bluedroid: Authentication fixes in Legacy and Secure Connection.

See merge request espressif/esp-idf!9336
2020-07-01 13:48:46 +08:00
lly
f0518dfba5 ble_mesh: ci: Add different proxy configurations 2020-07-01 11:54:32 +08:00
lly
b239677c97 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:54:32 +08:00
f1642bfaaf Merge branch 'bugfix/ble_mesh_set_recv_rssi_v4.2' into 'release/v4.2'
Bugfix/ble mesh set recv rssi (v4.2)

See merge request espressif/esp-idf!9390
2020-07-01 11:31:47 +08:00
e9f21b096f Merge branch 'bugfix/ble_mesh_check_subnet_before_update_beacon_sent_v4.2' into 'release/v4.2'
ble_mesh: Check if subnet exists before updating beacon_sent (v4.2)

See merge request espressif/esp-idf!9395
2020-07-01 11:16:16 +08:00
76c1be0d94 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-06-30 21:45:31 +08:00
a3a4c828e9 psram: fix 16mbit psram id read error 2020-06-30 21:44:39 +08:00
404a5994e6 bugfix: fix ICMP specify length issue 2020-06-30 13:42:19 +00:00
98d7f13c24 console_repl: change config structure to support different devices 2020-06-30 20:18:27 +08:00
ec043aac06 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-30 14:41:46 +05:30
334052194e mesh: remove coexist warnings in ESP_WIFI_MESH
1. remove warning log when mesh is started:
Error! Should use default passive scan time parameter for WiFi scan when Bluetooth is enabled!!!!!!
2. remove abort when mesh is started:
Error! Should enable WiFi modem sleep when both WiFi and Bluetooth are enabled!!!!!!
2020-06-30 16:33:08 +08:00
6938c615d8 Merge branch 'bugfix/connect_param_check_and_channel_map_bugs_v4.2' into 'release/v4.2'
components/bt:Fix channel map instant reverse and add ble connect paramter check.(backport 4.2)

See merge request espressif/esp-idf!9236
2020-06-30 15:11:56 +08:00
lly
6f715c4472 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:21 +08:00
lly
3fa5daf0ba 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:23 +08:00
4b3bb6c8fd 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:23 +08:00
5bf8bb6d3a 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:48:48 +08:00
a664a80d73 docs: restore chinese get-started-ethernet-kit guide
The chinese translation of get-started-ethernet-kit guide were erroneously
removed in commit 1a90470f02
2020-06-29 13:32:45 +08:00
c0a40cf7e8 Merge branch 'fix/esp_tls_wolfssl_fix_cert_verify_v4.2' into 'release/v4.2'
esp_tls_wolfssl : fix incorrect error message after handshake fails (v4.2)

See merge request espressif/esp-idf!9229
2020-06-29 13:00:49 +08:00
3d68e92a58 Merge branch 'bugfix/http_server_lru_v4.2' into 'release/v4.2'
esp_http_server: Update LRU counter on accepting a new connection (v4.2)

See merge request espressif/esp-idf!9350
2020-06-29 12:57:02 +08:00
00148cd0c6 Merge branch 'bugfix/ble_mesh_get_node_with_name_v4.2' into 'release/v4.2'
ble_mesh: Get node info with pre-configured node name (v4.2)

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

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

See merge request espressif/esp-idf!9309
2020-06-28 20:24:31 +08:00
257384ea75 Merge branch 'bugfix/ble_mesh_not_define_bool_v4.2' into 'release/v4.2'
Bugfix/ble mesh not define bool (v4.2)

See merge request espressif/esp-idf!9316
2020-06-28 20:23:21 +08:00
6d20c836ff Merge branch 'bugfix/ble_mesh_check_model_status_v4.2' into 'release/v4.2'
ble_mesh: stack: Check model status with variable length (v4.2)

See merge request espressif/esp-idf!9319
2020-06-28 20:22:40 +08:00
e538b2a2ed Merge branch 'doc/ds_S2_4.2' into 'release/v4.2'
Doc: DS documentation for S2

See merge request espressif/esp-idf!9358
2020-06-28 20:20:49 +08:00
36ee7d706a Doc: DS documentation for S2 2020-06-28 09:42:02 +08:00
f97751712f esp_http_server: Update LRU counter on accepting a new connection
Closes https://github.com/espressif/esp-idf/issues/3851
2020-06-26 19:24:23 +05:30
e8c8286387 Merge branch 'bugfix/check_python_deps_diagnostic_v4.2' into 'release/v4.2'
tools: fix diagnostic output in check_python_dependencies.py (backport v4.2)

See merge request espressif/esp-idf!9295
2020-06-26 21:16:55 +08:00
390a34f660 Merge branch 'bugfix/export_sh_in_dash_v4.2' into 'release/v4.2'
tools: export.sh: fix compatibility with dash shell (backport v4.2)

See merge request espressif/esp-idf!9296
2020-06-26 21:16:40 +08:00
939a7ada04 spi_flash: esp32: fix regression in encrypted flash write
In commit 309376f51a, it seems like regression
was added to use ROM level API for disabling flash write protection. This
started random firmware crashes (on specific modules) with exception
`IllegalInstruction` during encrypted flash writes.

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

Closes https://github.com/espressif/esp-idf/issues/5467
2020-06-26 18:20:06 +05:30
156bd313d2 Merge branch 'ci/http_client_remove_httpbin_redirect_v4.2' into 'release/v4.2'
ci: Temporarily remove the esp_http_client httpbin redirect tests (v4.2)

See merge request espressif/esp-idf!9340
2020-06-26 01:35:46 +08:00
b53daeecee ci: Temporarily remove the esp_http_client httpbin redirect tests
Need to host httpbin ourselves or wait for
postmanlabs/httpbin/issues/617 to be resolved
2020-06-25 07:57:57 +10:00
ae35b6abcd Merge branch 'bugfix/bootloader_header_align_v4.2' into 'release/v4.2'
bootloader: Force bootloader_image_hdr to be word aligned (v4.2)

See merge request espressif/esp-idf!9069
2020-06-24 20:33:47 +08:00
8bf1d3118a Merge branch 'doc/fix_broken_links_v4.2' into 'release/v4.2'
Doc/fix broken links (backport v4.2)

See merge request espressif/esp-idf!9265
2020-06-24 20:16:20 +08:00
lly
698fe7dd99 ble_mesh: stack: Check model status with variable length 2020-06-24 14:12:53 +08:00
lly
bd5ef62253 ble_mesh: Remove boolean type definitions 2020-06-24 14:05:58 +08:00
5bacf6b23d ble_mesh: Do not #define bool when compiling in C++ 2020-06-24 14:05:58 +08:00
24d455f826 Merge branch 'feature/pyc_clean_v4.2' into 'release/v4.2'
tools/idf.py: Clean Python bytecode files (v4.2)

See merge request espressif/esp-idf!9262
2020-06-24 12:30:15 +08:00
lly
55f48877a4 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 12:29:33 +08:00
ac2698ecb7 Merge branch 'bugfix/idf_py_help_env_var_v4.2' into 'release/v4.2'
Tools: Mention ESPPORT and ESPBAUD in idf.py --help (v4.2)

See merge request espressif/esp-idf!9290
2020-06-24 12:28:29 +08:00
lly
a2e14140b3 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 12:19:06 +08:00
lly
b4b2cd19f7 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:58:36 +08:00
4913cbed6a 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-23 16:34:19 +02:00
387dfd977a tools: fix diagnostic output in check_python_dependencies.py
If IDF_PYTHON_ENV_PATH was not set, an exception occurred:

Traceback (most recent call last):
  File "/home/user/esp/esp-idf/tools/check_python_dependencies.py", line 108, in <module>
    if idf_python_env_path not in sys.executable:
TypeError: 'in <string>' requires string as left operand, not NoneType

and the final line in the diagnostic message was not printed.
Fix to print the PATH if IDF_PYTHON_ENV_PATH is not set.
2020-06-23 16:32:47 +02:00
647d01dbc6 Tools: Mention ESPPORT and ESPBAUD in idf.py --help
Closes https://github.com/espressif/esp-idf/issues/5461
2020-06-23 15:21:44 +02:00
820e0ead52 Merge branch 'bugfix/wifi_update_tbtt_when_ap_reset_tsf_v4.2' into 'release/v4.2'
esp_wifi: Add TBTT update when AP reset TSF (v4.2)

See merge request espressif/esp-idf!9270
2020-06-23 12:14:27 +08:00
cdc0374448 esp_wifi:
1. Add TBTT update when AP reset TSF
2. fix the bug for regdomian update
3. update ESP32S2 phy lib to 601,5b0f7cd
4. Fix TX DMA buffer issue
2020-06-22 19:33:08 +08:00
c185d924e1 docs: fixed broken platform.io link 2020-06-22 17:17:57 +08:00
35c3a51c17 docs: fix link_roles not linking correctly for certain files
Link_roles could link incorrectly if the name of a file matched the name of a submodule
2020-06-22 17:17:46 +08:00
1c49cf1a09 tools/idf.py: Clean Python bytecode files 2020-06-22 10:23:59 +02:00
ee126bc154 Merge branch 'bugfix/wpa_supplicant_no_hw_mpi_v4.2' into 'release/v4.2'
wpa_supplicant: Allow building with mbedTLS integration but no hardware MPI (v4.2)

See merge request espressif/esp-idf!9011
2020-06-22 13:06:01 +08:00
aaeb2ba733 Merge branch 'bugfix/att_buffer_count_fixed_v4.2' into 'release/v4.2'
Bugfix/att buffer count fixed v4.2

See merge request espressif/esp-idf!9161
2020-06-22 11:44:54 +08:00
12d39f9faa components/bt:Fix instant reverse and add ble connect paramter check. 2020-06-18 15:54:53 +08:00
41f178f5eb 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:32:52 +08:00
f6b0307e1a esp_tls_wolfssl: fix incorrect error message after handshake fails 2020-06-18 12:58:40 +05:30
710249c86a Merge branch 'bugfix/blufi_buffer_overflow_report_v4.2' into 'release/v4.2'
blufi: When the format of the received data packet is wrong, reply with an error response(backport 4.2)

See merge request espressif/esp-idf!9201
2020-06-18 13:44:52 +08:00
920273e619 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 11:57:47 +08:00
82c4ed30b6 Merge branch 'bugfix/fix_fifo_cnt_bug_v4.2' into 'release/v4.2'
bugfix(uart): fix esp32 fifo_cnt bug(backport v4.2)

See merge request espressif/esp-idf!9039
2020-06-18 01:47:51 +08:00
1f074d313b Merge branch 'bugfix/fix_some_wifi_bugs_0617_v4.2' into 'release/v4.2'
fix some wifi bugs 0617 (backport v4.2)

See merge request espressif/esp-idf!9210
2020-06-17 18:27:37 +08:00
a406885360 Merge branch 'feature/make_tcp_rto_configurable_v4.2' into 'release/v4.2'
make  TCP rto time configurable (backport v4.2)

See merge request espressif/esp-idf!9211
2020-06-17 18:23:34 +08:00
a6f2205cdb Merge branch 'bugfix/ble_conn_fail_v4.2' into 'release/v4.2'
Fix bugs from coex test

See merge request espressif/esp-idf!9099
2020-06-17 18:16:37 +08:00
0ea0d2ba3c Merge branch 'bugfix/efuse_logs_v4.2' into 'release/v4.2'
esp32/esp32s2: Reduce using ESP_EARLY_LOGx and move some code after the stdout initialization in startup code (v4.2)

See merge request espressif/esp-idf!9202
2020-06-17 16:54:34 +08:00
c5768c019e feat(lwip): make LWIP TCP rto time configurable 2020-06-17 15:20:00 +08:00
783cd1bb08 components/bt: Fix ble disconnect due to instant of channel map update is too small 2020-06-17 07:15:46 +00:00
d4b232590a Set AFH in time(075dd35)
Send LMP_channelClassification immediately
Fix first LMP_set_AFH not using host value
2020-06-17 07:15:46 +00:00
ef92a22b0c components/coex: Fix ble connecting fail in coexist 2020-06-17 07:15:46 +00:00
f5a6ae7e93 esp_wifi:
1. Fix WPA3 Auth timeout during BLE coex
2. fix addba ssn and send bar for first ampdu
3. fix the bug that airkiss find hidden AP fail
4. update mesh lib
5. fix interrupt handle param variable error
2020-06-17 14:55:45 +08:00
7cbb970b50 esp32s2: disable sdmmc api 2020-06-17 14:53:17 +08:00
ba67a9518e fix esp32s2 do not have crc*_be func 2020-06-17 14:53:08 +08:00
835186b3b9 esp_wifi: re-enable build wifi example 2020-06-17 14:52:58 +08:00
49c9f69eae esp32s2: Move some code after the stdout initialization 2020-06-17 13:40:42 +08:00
a6ac0e8a51 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 13:40:42 +08:00
21ff2f84ce components/bt: Add a detailed description for the user to distinguish the function of the query buffer api. 2020-06-17 12:52:28 +08:00
02cd178115 Update the limited of function esp_ble_get_sendable_packets_num. 2020-06-17 12:52:18 +08:00
17609cbb02 blufi: When the format of the received data packet is wrong, reply with an error response 2020-06-17 12:19:00 +08:00
e7d046cfdd Merge branch 'bugfix/fix_event_bug_in_GAP_API_release_v4.2' into 'release/v4.2'
Bugfix/fix event bug in GAP API [backport v4.2]

See merge request espressif/esp-idf!9190
2020-06-17 11:51:38 +08:00
4dd29dac94 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-06-16 22:18:21 +08:00
27e6e8c485 bugfix(uart): fix esp32 fifo_cnt bug
When using DPort to read fifo, fifo_cnt is not credible, we need to calculate the real cnt based on the fifo read and write pointer. When using AHB to read FIFO, we can use fifo_cnt to indicate the data length in fifo.
2020-06-16 14:34:23 +08:00
1d1e4497ba ci: fix find_build_apps.py failure with py3 due to non ascii chars
find_build_apps.py would fail when reading non-ascii chars on systems where
the default encoding was ascii.
2020-06-15 15:20:43 +08:00
1531f2db2a ci: fix check_public_headers.py failure with python3 due to non ascii chars
check_public_headers.py would fail when reading non-ascii chars on systems where
the default encoding was ascii.

Also fixes error handling issues, as any uncaught exeception would cause the program
to run indefinitely.
2020-06-15 15:20:43 +08:00
1358734b3f Fixes issues with gen_crt_bundle.py for unicode chars
gen_crt_bundle.py could fail to parse the certificates if it contained a non-ascii character.
2020-06-15 15:20:43 +08:00
7f299d9d60 components/bt: Consider link_xmit_data_q in congest events to prevent excessive memory usage 2020-06-13 15:10:30 +08:00
d53a2719b9 components/bt: Fixed the problem of incomplete data packets caused by disordered acl data packets 2020-06-13 15:09:45 +08:00
f9b0cd1847 components/bt: Add api to query the number of available buffers for the current connection 2020-06-13 15:09:36 +08:00
9b62609499 msys2: Remove python version consideration in pacman commands 2020-06-12 10:20:03 +10:00
036848a375 windows: Update MSYS2 pre-compiled legacy build environment
* Bundled with esp2020r2 toolchain
* Built with Python 3 & latest MSYS2 packages
2020-06-12 10:20:03 +10:00
1504fe5358 Merge branch 'bugfix/esp32_can_not_scan_ap_after_restart_v4.2' into 'release/v4.2'
esp_wifi: upadte esp32 phy lib to 4182 (v4.2)

See merge request espressif/esp-idf!9113
2020-06-11 11:54:24 +08:00
5054cd05fc Merge branch 'bugfix/intr_alloc_no_log_from_critical_section_v4.2' into 'release/v4.2'
intr_alloc: don't call ESP_LOG from critical section (v4.2)

See merge request espressif/esp-idf!9088
2020-06-10 15:58:23 +08:00
c9769e535e esp_wifi: upadte esp32 phy lib to 4182 2020-06-09 17:33:55 +08:00
21a9c9b653 Merge branch 'bugfix/authmode_degrade_fix_v4.2' into 'release/v4.2'
esp_wifi: Remove auth_changed event and fix wpa2_ent authmode threshold(backport v4.2)

See merge request espressif/esp-idf!9090
2020-06-09 17:30:50 +08:00
f74729c3bc 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-08 12:53:22 +05:30
cc99cac782 Merge branch 'feature/pin_ethernet_task_to_core_v4.2' into 'release/v4.2'
ethernet: support pin emac task to core (v4.2)

See merge request espressif/esp-idf!9036
2020-06-08 13:52:01 +08:00
9773f79e6e intr_alloc: using isr version of critical section 2020-06-08 12:52:25 +08:00
b2fb2429dd Merge branch 'bugfix/esp32s2_airkiss_fail_v4.2' into 'release/v4.2'
wifi: fix the bug that ESP32S2 can't receive AMPDU when airkiss (v4.2)

See merge request espressif/esp-idf!9029
2020-06-05 15:34:42 +08:00
8643d7acb9 wifi:
1. Fix the bug that ESP32S2 can't receive AMPDU when airkiss
2. Fix WPA3 Auth issue in coex scenario
2020-06-05 06:00:37 +00:00
e7ab7ce3af bootloader: Force bootloader_image_hdr to be word aligned
Possible due to linker order for this file to be placed unaligned,
causing failure from bootloader_flash_read() function.
2020-06-04 20:56:26 +10:00
a8f40b7095 Merge branch 'bugfix/ble_mesh_remove_relay_dependency_v4.2' into 'release/v4.2'
ble_mesh: Remove relay option dependency (v4.2)

See merge request espressif/esp-idf!9025
2020-06-03 15:20:35 +08:00
9bdaa64d80 Merge branch 'bugfix/ble_mesh_example_nvs_store_v4.2' into 'release/v4.2'
Bugfix/ble mesh example nvs store (v4.2)

See merge request espressif/esp-idf!9015
2020-06-03 15:11:54 +08:00
55cd09578f Merge branch 'bugfix/ble_mesh_model_recv_fix_v4.2' into 'release/v4.2'
Bugfix/ble mesh model recv fix (v4.2)

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

See merge request espressif/esp-idf!9002
2020-06-03 15:10:33 +08:00
b16c20fa30 ethernet: support pin emac task to core 2020-06-03 11:06:41 +08:00
lly
eeb44e7dd6 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:18 +08:00
lly
5b256c1cb5 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:02:54 +08:00
lly
c906bcaf40 ble_mesh: Add mesh example common nvs operations 2020-06-02 14:02:54 +08:00
lly
adf785a1b0 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:02:54 +08:00
lly
b25cffd4d5 ble_mesh: Add more checks of net_idx & app_idx 2020-06-02 14:02:54 +08:00
lly
4919d17ad1 ble_mesh: Optimize some send & recv logs 2020-06-02 14:02:53 +08:00
c69210c0f2 wpa_supplicant: Allow building with mbedTLS integration but no hardware MPI
Also disable the relevant function in bignum.h based on config, so fails at
compile not link time.

Closes https://github.com/espressif/esp-idf/issues/5321
2020-06-02 13:35:48 +10:00
6fa8df519d Merge branch 'bugfix/ble_mesh_local_model_sub_v4.2' into 'release/v4.2'
Bugfix/ble mesh local model sub (v4.2)

See merge request espressif/esp-idf!8982
2020-06-02 10:58:05 +08:00
lly
1a3c315d2f ble_mesh: correct the return type [Zephyr] 2020-06-02 10:31:08 +08:00
lly
8271ae4a1e ble_mesh: Add net_buf_simple_init_with_data [Zephyr] 2020-06-02 10:31:08 +08:00
lly
d6a247f7e4 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:31:07 +08:00
lly
4fbc29616c ble_mesh: Rework prov pdu length check 2020-06-02 10:13:21 +08:00
6b36ce95a2 Merge branch 'bugfix/coredump_memregion_size_v4.2' into 'release/v4.2'
coredump: Fixes size of memory region used by espcoredump.py (backport v4.2)

See merge request espressif/esp-idf!8977
2020-06-02 01:11:12 +08:00
lly
067d94e88f ble_mesh: Local model (un)subscribes group address 2020-06-01 09:10:17 +08:00
lly
6bc4f5802d ble_mesh: Define a macro for invalid company id 2020-06-01 09:10:17 +08:00
29b03b2999 coredump: Fixes size of memory region used by espcoredump.py 2020-05-29 21:09:21 +03:00
1366 changed files with 50242 additions and 61051 deletions

View File

@ -38,7 +38,7 @@ If the issue cannot be solved after the steps before, please follow these instru
- Development Kit: [ESP32-Wrover-Kit|ESP32-DevKitC|ESP32-PICO-Kit|ESP32-LyraT|ESP32-LyraTD-MSC|none]
- Kit version (for WroverKit/PicoKit/DevKitC): [v1|v2|v3|v4]
- Module or chip used: [ESP32-WROOM-32|ESP32-WROOM-32D|ESP32-WROOM-32U|ESP32-WROVER|ESP32-WROVER-I|ESP32-WROVER-B|ESP32-WROVER-IB|ESP32-SOLO-1|ESP32-PICO-D4|ESP32]
- IDF version (run ``git describe --tags`` to find it):
- IDF version (run ``git describe`` to find it):
// v3.2-dev-1148-g96cd3b75c
- Build System: [Make|CMake|idf.py]
- Compiler version (run ``xtensa-esp32-elf-gcc --version`` to find it):

View File

@ -8,6 +8,18 @@ stages:
- deploy
- post_deploy
# 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
@ -39,13 +51,17 @@ variables:
APPLY_BOT_FILTER_SCRIPT: "$CI_PROJECT_DIR/tools/ci/apply_bot_filter.py"
CHECKOUT_REF_SCRIPT: "$CI_PROJECT_DIR/tools/ci/checkout_project_ref.py"
# Docker images
# Docker images
BOT_DOCKER_IMAGE_TAG: ":latest"
# target test 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:v4"
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

View File

@ -2,7 +2,7 @@
* [中文版](./README_CN.md)
ESP-IDF is the official development framework for the **ESP32** and **ESP32-S** Series SoCs.
ESP-IDF is the official development framework for the **ESP32** and **ESP32-S** Series SoCs provided for Windows, Linux and macOS.
# Developing With ESP-IDF
@ -39,25 +39,16 @@ See the Getting Started guide links above for a detailed setup guide. This is a
## Setup Build Environment
(See Getting Started guide for a full list of required steps with details.)
(See the Getting Started guide listed above for a full list of required steps with more details.)
* Install host build dependencies mentioned in Getting Started guide.
* Add `tools/` directory to the PATH
* Run `python -m pip install -r requirements.txt` to install Python dependencies
* Install host build dependencies mentioned in the Getting Started guide.
* Run the install script to set up the build environment. The options include `install.bat` or `install.ps1` for Windows, and `install.sh` or `install.fish` 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 set-target <chip_name>` sets the target of the project to `<chip_name>`. Run `idf.py set-target` without any arguments to see a list of supported targets.
* `idf.py menuconfig` opens a text-based configuration menu where you can configure the project.
## Compiling the Project

View File

@ -41,6 +41,12 @@
#include "esp_system.h"
#include "esp_efuse.h"
#ifdef CONFIG_IDF_TARGET_ESP32
#include "esp32/rom/crc.h"
#elif CONFIG_IDF_TARGET_ESP32S2
#include "esp32s2/rom/crc.h"
#include "esp32s2/rom/secure_boot.h"
#endif
#define SUB_TYPE_ID(i) (i & 0x0F)
@ -858,3 +864,24 @@ esp_err_t esp_ota_erase_last_boot_app_partition(void)
return ESP_OK;
}
#if CONFIG_IDF_TARGET_ESP32S2 && CONFIG_SECURE_BOOT_V2_ENABLED
esp_err_t esp_ota_revoke_secure_boot_public_key(esp_ota_secure_boot_public_key_index_t index) {
if (!esp_secure_boot_enabled()) {
ESP_LOGE(TAG, "Secure boot v2 has not been enabled.");
return ESP_FAIL;
}
if (index != SECURE_BOOT_PUBLIC_KEY_INDEX_0 &&
index != SECURE_BOOT_PUBLIC_KEY_INDEX_1 &&
index != SECURE_BOOT_PUBLIC_KEY_INDEX_2) {
ESP_LOGE(TAG, "Invalid Index found for public key revocation %d.", index);
return ESP_ERR_INVALID_ARG;
}
ets_secure_boot_revoke_public_key_digest(index);
ESP_LOGI(TAG, "Revoked signature block %d.", index);
return ESP_OK;
}
#endif

View File

@ -299,6 +299,34 @@ esp_err_t esp_ota_erase_last_boot_app_partition(void);
*/
bool esp_ota_check_rollback_is_possible(void);
#if CONFIG_IDF_TARGET_ESP32S2 && (CONFIG_SECURE_BOOT_V2_ENABLED || __DOXYGEN__)
/**
* Secure Boot V2 public key indexes.
*/
typedef enum {
SECURE_BOOT_PUBLIC_KEY_INDEX_0, /*!< Points to the 0th index of the Secure Boot v2 public key */
SECURE_BOOT_PUBLIC_KEY_INDEX_1, /*!< Points to the 1st index of the Secure Boot v2 public key */
SECURE_BOOT_PUBLIC_KEY_INDEX_2 /*!< Points to the 2nd index of the Secure Boot v2 public key */
} esp_ota_secure_boot_public_key_index_t;
/**
* @brief Revokes the old signature digest. To be called in the application after the rollback logic.
*
* Relevant for Secure boot v2 on ESP32-S2 where upto 3 key digests can be stored (Key #N-1, Key #N, Key #N+1).
* When key #N-1 used to sign an app is invalidated, an OTA update is to be sent with an app signed with key #N-1 & Key #N.
* After successfully booting the OTA app should call this function to revoke Key #N-1.
*
* @param index - The index of the signature block to be revoked
*
* @return
* - ESP_OK: If revocation is successful.
* - ESP_ERR_INVALID_ARG: If the index of the public key to be revoked is incorrect.
* - ESP_FAIL: If secure boot v2 has not been enabled.
*/
esp_err_t esp_ota_revoke_secure_boot_public_key(esp_ota_secure_boot_public_key_index_t index);
#endif /* CONFIG_IDF_TARGET_ESP32S2 */
#ifdef __cplusplus
}
#endif

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

@ -53,20 +53,34 @@ menu "Bootloader config"
default 4 if BOOTLOADER_LOG_LEVEL_DEBUG
default 5 if BOOTLOADER_LOG_LEVEL_VERBOSE
config BOOTLOADER_SPI_CUSTOM_WP_PIN
bool "Use custom SPI Flash WP Pin when flash pins set in eFuse (read help)"
depends on IDF_TARGET_ESP32 && (ESPTOOLPY_FLASHMODE_QIO || ESPTOOLPY_FLASHMODE_QOUT)
default y if BOOTLOADER_SPI_WP_PIN != 7 # backwards compatibility, can remove in IDF 5
default n
help
This setting is only used if the SPI flash pins have been overridden by setting the eFuses
SPI_PAD_CONFIG_xxx, and the SPI flash mode is QIO or QOUT.
When this is the case, the eFuse config only defines 3 of the 4 Quad I/O data pins. The WP pin (aka
ESP32 pin "SD_DATA_3" or SPI flash pin "IO2") is not specified in eFuse. The same pin is also used
for external SPIRAM if it is enabled.
If this config item is set to N (default), the correct WP pin will be automatically used for any
Espressif chip or module with integrated flash. If a custom setting is needed, set this config item to
Y and specify the GPIO number connected to the WP.
config BOOTLOADER_SPI_WP_PIN
int "SPI Flash WP Pin when customising pins via eFuse (read help)"
int "Custom SPI Flash WP Pin"
range 0 33
default 7
depends on ESPTOOLPY_FLASHMODE_QIO || ESPTOOLPY_FLASHMODE_QOUT
depends on IDF_TARGET_ESP32 && (ESPTOOLPY_FLASHMODE_QIO || ESPTOOLPY_FLASHMODE_QOUT)
#depends on BOOTLOADER_SPI_CUSTOM_WP_PIN # backwards compatibility, can uncomment in IDF 5
help
This value is ignored unless flash mode is set to QIO or QOUT *and* the SPI flash pins have been
overriden by setting the eFuses SPI_PAD_CONFIG_xxx.
The option "Use custom SPI Flash WP Pin" must be set or this value is ignored
When this is the case, the eFuse config only defines 3 of the 4 Quad I/O data pins. The WP pin (aka ESP32
pin "SD_DATA_3" or SPI flash pin "IO2") is not specified in eFuse. That pin number is compiled into the
bootloader instead.
The default value (GPIO 7) is correct for WP pin on ESP32-D2WD integrated flash.
If burning a customized set of SPI flash pins in eFuse and using QIO or QOUT mode for flash, set this
value to the GPIO number of the SPI flash WP pin.
choice BOOTLOADER_VDDSDIO_BOOST
bool "VDDSDIO LDO voltage"
@ -320,6 +334,16 @@ menu "Security features"
select MBEDTLS_ECDSA_C
depends on SECURE_SIGNED_ON_BOOT || SECURE_SIGNED_ON_UPDATE
config SECURE_BOOT_SUPPORTS_RSA
bool
default y
depends on ESP32_REV_MIN_3 || IDF_TARGET_ESP32S2
config SECURE_TARGET_HAS_SECURE_ROM_DL_MODE
bool
default y
depends on IDF_TARGET_ESP32S2
config SECURE_SIGNED_APPS_NO_SECURE_BOOT
bool "Require signed app images"
@ -355,7 +379,7 @@ menu "Security features"
config SECURE_SIGNED_APPS_RSA_SCHEME
bool "RSA"
depends on ESP32_REV_MIN_3 && SECURE_BOOT_V2_ENABLED
depends on SECURE_BOOT_SUPPORTS_RSA && SECURE_BOOT_V2_ENABLED
help
Appends the RSA-3072 based Signature block to the application.
Refer to <Secure Boot Version 2 documentation link> before enabling.
@ -419,7 +443,9 @@ menu "Security features"
config SECURE_BOOT_V2_ENABLED
bool "Enable Secure Boot version 2"
depends on ESP32_REV_MIN_3
depends on SECURE_BOOT_SUPPORTS_RSA
select SECURE_ENABLE_SECURE_ROM_DL_MODE if !IDF_TARGET_ESP32 && !SECURE_INSECURE_ALLOW_DL_MODE && !SECURE_DISABLE_ROM_DL_MODE # NOERROR
select SECURE_DISABLE_ROM_DL_MODE if ESP32_REV_MIN_3 && !SECURE_INSECURE_ALLOW_DL_MODE
help
Build a bootloader which enables Secure Boot version 2 on first boot.
Refer to Secure Boot V2 section of the ESP-IDF Programmer's Guide for this version before enabling.
@ -539,6 +565,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.
@ -587,7 +614,7 @@ menu "Security features"
config SECURE_FLASH_ENCRYPTION_MODE_RELEASE
bool "Release"
select SECURE_ENABLE_SECURE_ROM_DL_MODE
select SECURE_ENABLE_SECURE_ROM_DL_MODE if SECURE_TARGET_HAS_SECURE_ROM_DL_MODE && !SECURE_DISABLE_ROM_DL_MODE # NOERROR
endchoice
@ -653,6 +680,19 @@ menu "Security features"
key digest, causing an immediate denial of service and possibly allowing an additional fault
injection attack to bypass the signature protection.
config SECURE_INSECURE_ALLOW_DL_MODE
bool "Don't automatically restrict UART download mode"
depends on SECURE_BOOT_INSECURE && SECURE_BOOT_V2_ENABLED
default N
help
By default, enabling either flash encryption in release mode or secure boot will automatically
disable UART download mode on ESP32 ECO3, or enable secure download mode on newer chips.
This is recommended to reduce the attack surface of the chip.
To allow the full UART download mode to stay enabled, enable this option and ensure
the options SECURE_DISABLE_ROM_DL_MODE and SECURE_ENABLE_SECURE_ROM_DL_MODE are disabled as applicable.
This is not recommended.
config SECURE_FLASH_UART_BOOTLOADER_ALLOW_ENC
bool "Leave UART bootloader encryption enabled"
depends on SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT
@ -719,7 +759,7 @@ menu "Security features"
config SECURE_ENABLE_SECURE_ROM_DL_MODE
bool "Permanently switch to ROM UART Secure Download mode"
depends on IDF_TARGET_ESP32S2 && !SECURE_DISABLE_ROM_DL_MODE
depends on SECURE_TARGET_HAS_SECURE_ROM_DL_MODE && !SECURE_DISABLE_ROM_DL_MODE
help
If set, during startup the app will burn an eFuse bit to permanently switch the UART ROM
Download Mode into a separate Secure Download mode. This option can only work if

View File

@ -102,7 +102,7 @@ endif
bootloader: $(BOOTLOADER_DIGEST_BIN)
@echo $(SEPARATOR)
@echo "Bootloader built and secure digest generated. First time flash command is:"
@echo "$(ESPEFUSEPY) burn_key secure_boot $(SECURE_BOOTLOADER_KEY)"
@echo "$(ESPEFUSEPY) burn_key secure_boot_v1 $(SECURE_BOOTLOADER_KEY)"
@echo "$(ESPTOOLPY_WRITE_FLASH) $(BOOTLOADER_OFFSET) $(BOOTLOADER_BIN)"
@echo $(SEPARATOR)
@echo "To reflash the bootloader after initial flash:"

View File

@ -92,20 +92,20 @@ endif()
if(CONFIG_SECURE_BOOT_V2_ENABLED)
if(CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES)
get_filename_component(secure_boot_signing_key
get_filename_component(secure_boot_signing_key
"${SECURE_BOOT_SIGNING_KEY}" ABSOLUTE BASE_DIR "${project_dir}")
if(NOT EXISTS "${secure_boot_signing_key}")
message(FATAL_ERROR
"Secure Boot Signing Key Not found."
"\nGenerate the Secure Boot V2 RSA-PSS 3072 Key."
"\nTo generate one, you can use this command:"
"\n\t${espsecurepy} generate_signing_key --version 2 ${SECURE_BOOT_SIGNING_KEY}")
message(FATAL_ERROR
"Secure Boot Signing Key Not found."
"\nGenerate the Secure Boot V2 RSA-PSS 3072 Key."
"\nTo generate one, you can use this command:"
"\n\t${espsecurepy} generate_signing_key --version 2 ${SECURE_BOOT_SIGNING_KEY}")
endif()
set(bootloader_unsigned_bin "bootloader-unsigned.bin")
add_custom_command(OUTPUT ".signed_bin_timestamp"
COMMAND cp "${CMAKE_BINARY_DIR}/${PROJECT_BIN}" "${CMAKE_BINARY_DIR}/${bootloader_unsigned_bin}"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/${PROJECT_BIN}" "${CMAKE_BINARY_DIR}/${bootloader_unsigned_bin}"
COMMAND ${ESPSECUREPY} sign_data --version 2 --keyfile "${secure_boot_signing_key}"
-o "${CMAKE_BINARY_DIR}/${PROJECT_BIN}" "${CMAKE_BINARY_DIR}/${bootloader_unsigned_bin}"
COMMAND ${CMAKE_COMMAND} -E echo "Generated signed binary image ${build_dir}/${PROJECT_BIN}"
@ -117,7 +117,7 @@ if(CONFIG_SECURE_BOOT_V2_ENABLED)
else()
add_custom_command(OUTPUT ".signed_bin_timestamp"
VERBATIM
COMMENT "Bootloader generated but not signed")
COMMENT "Bootloader generated but not signed")
endif()
add_custom_target (gen_signed_bootloader ALL DEPENDS "${build_dir}/.signed_bin_timestamp")
@ -147,7 +147,7 @@ elseif(CONFIG_SECURE_BOOTLOADER_REFLASHABLE)
COMMAND ${CMAKE_COMMAND} -E echo
"Burn secure boot key to efuse using:"
COMMAND ${CMAKE_COMMAND} -E echo
"\t${espefusepy} burn_key secure_boot ${secure_bootloader_key}"
"\t${espefusepy} burn_key secure_boot_v1 ${secure_bootloader_key}"
COMMAND ${CMAKE_COMMAND} -E echo
"First time flash command is:"
COMMAND ${CMAKE_COMMAND} -E echo
@ -166,6 +166,24 @@ elseif(CONFIG_SECURE_BOOTLOADER_REFLASHABLE)
"* Not recommended to re-use the same secure boot keyfile on multiple production devices."
DEPENDS gen_secure_bootloader_key gen_bootloader_digest_bin
VERBATIM)
elseif(CONFIG_SECURE_BOOT_V2_ENABLED AND CONFIG_IDF_TARGET_ESP32S2)
add_custom_command(TARGET bootloader.elf POST_BUILD
COMMAND ${CMAKE_COMMAND} -E echo
"=============================================================================="
COMMAND ${CMAKE_COMMAND} -E echo
"Bootloader built. Secure boot enabled, so bootloader not flashed automatically."
COMMAND ${CMAKE_COMMAND} -E echo
"To sign the bootloader with additional private keys."
COMMAND ${CMAKE_COMMAND} -E echo
"\t${espsecurepy} sign_data -k secure_boot_signing_key2.pem -v 2 --append_signatures -o signed_bootloader.bin build/bootloader/bootloader.bin"
COMMAND ${CMAKE_COMMAND} -E echo
"Secure boot enabled, so bootloader not flashed automatically."
COMMAND ${CMAKE_COMMAND} -E echo
"\t${esptoolpy_write_flash} ${BOOTLOADER_OFFSET} ${CMAKE_BINARY_DIR}/bootloader.bin"
COMMAND ${CMAKE_COMMAND} -E echo
"=============================================================================="
DEPENDS gen_signed_bootloader
VERBATIM)
elseif(CONFIG_SECURE_BOOT_V2_ENABLED)
add_custom_command(TARGET bootloader.elf POST_BUILD
COMMAND ${CMAKE_COMMAND} -E echo

View File

@ -42,6 +42,7 @@ SECTIONS
*libbootloader_support.a:bootloader_common.*(.literal .text .literal.* .text.*)
*libbootloader_support.a:bootloader_flash.*(.literal .text .literal.* .text.*)
*libbootloader_support.a:bootloader_random.*(.literal .text .literal.* .text.*)
*libbootloader_support.a:bootloader_random*.*(.literal.bootloader_random_disable .text.bootloader_random_disable)
*libbootloader_support.a:bootloader_efuse_esp32.*(.literal .text .literal.* .text.*)
*libbootloader_support.a:bootloader_utility.*(.literal .text .literal.* .text.*)
*libbootloader_support.a:bootloader_sha.*(.literal .text .literal.* .text.*)

View File

@ -5,9 +5,9 @@
MEMORY
{
iram_seg (RWX) : org = 0x40050000, len = 0x4000 /* 16KB, SRAM Block_14 */
iram_loader_seg (RWX) : org = 0x40054000, len = 0x4000 /* 16KB, SRAM Block_15 */
dram_seg (RW) : org = 0x3FFE8000, len = 0x2800 /* 10KB, Top of SRAM Block_16, and before ROM data and stack */
iram_seg (RWX) : org = 0x4004c000, len = 0x4000 /* SRAM Block 13 */
iram_loader_seg (RWX) : org = 0x40050000, len = 0x6000 /* SRAM Block 14 & part of 15 */
dram_seg (RW) : org = 0x3FFE6000, len = 0x4B00 /* Part SRAM Blocks 15 & 16, ROM static buffer starts at end of this region (reclaimed after app runs) */
}
/* Default entry point: */
@ -28,6 +28,7 @@ SECTIONS
*libbootloader_support.a:bootloader_common.*(.literal .text .literal.* .text.*)
*libbootloader_support.a:bootloader_flash.*(.literal .text .literal.* .text.*)
*libbootloader_support.a:bootloader_random.*(.literal .text .literal.* .text.*)
*libbootloader_support.a:bootloader_random*.*(.literal.bootloader_random_disable .text.bootloader_random_disable)
*libbootloader_support.a:bootloader_efuse_esp32s2.*(.literal .text .literal.* .text.*)
*libbootloader_support.a:bootloader_utility.*(.literal .text .literal.* .text.*)
*libbootloader_support.a:bootloader_sha.*(.literal .text .literal.* .text.*)
@ -39,6 +40,7 @@ SECTIONS
*libmicro-ecc.a:*.*(.literal .text .literal.* .text.*)
*libspi_flash.a:*.*(.literal .text .literal.* .text.*)
*libsoc.a:wdt_hal_iram.*(.literal .text .literal.* .text.*)
*libsoc.a:regi2c_ctrl.*(.literal .text .literal.* .text.*)
*libefuse.a:*.*(.literal .text .literal.* .text.*)
*(.fini.literal)
*(.fini)

View File

@ -4,6 +4,7 @@ set(srcs
"src/bootloader_flash.c"
"src/bootloader_mem.c"
"src/bootloader_random.c"
"src/bootloader_random_${IDF_TARGET}.c"
"src/bootloader_utility.c"
"src/esp_image_format.c"
"src/flash_encrypt.c"

View File

@ -20,7 +20,8 @@ COMPONENT_OBJEXCLUDE := src/bootloader_init.o
endif
COMPONENT_OBJEXCLUDE += src/bootloader_flash_config_esp32s2.o \
src/bootloader_efuse_esp32s2.o
src/bootloader_efuse_esp32s2.o \
src/bootloader_random_esp32s2.o
ifndef CONFIG_SECURE_SIGNED_APPS_ECDSA_SCHEME
ifndef CONFIG_SECURE_SIGNED_APPS_RSA_SCHEME

View File

@ -14,6 +14,7 @@
#pragma once
#include "sdkconfig.h"
#include "esp_image_format.h"
#ifdef __cplusplus
@ -27,6 +28,14 @@ extern "C" {
*/
void bootloader_flash_update_id(void);
/**
* @brief Update the flash size in g_rom_flashchip (global esp_rom_spiflash_chip_t structure).
*
* @param size The size to store, in bytes.
* @return None
*/
void bootloader_flash_update_size(uint32_t size);
/**
* @brief Set the flash CS setup and hold time.
*
@ -66,6 +75,22 @@ void bootloader_flash_gpio_config(const esp_image_header_t* pfhdr);
*/
void bootloader_flash_dummy_config(const esp_image_header_t* pfhdr);
#ifdef CONFIG_IDF_TARGET_ESP32
/**
* @brief Return the pin number used for custom SPI flash and/or SPIRAM WP pin
*
* Can be determined by eFuse values in most cases, or overriden in configuration
*
* This value is only meaningful if the other SPI flash pins are overriden via eFuse.
*
* This value is only meaningful if flash is set to QIO or QOUT mode, or if
* SPIRAM is enabled.
*
* @return Pin number to use, or -1 if the default should be kept
*/
int bootloader_flash_get_wp_pin(void);
#endif
#ifdef __cplusplus
}
#endif

View File

@ -169,6 +169,14 @@ esp_err_t esp_image_verify_bootloader(uint32_t *length);
*/
esp_err_t esp_image_verify_bootloader_data(esp_image_metadata_t *data);
/**
* @brief Get the flash size of the image
*
* @param app_flash_size The value configured in the image header
* @return Actual size, in bytes.
*/
int esp_image_get_flash_size(esp_image_flash_size_t app_flash_size);
typedef struct {
uint32_t drom_addr;

View File

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

View File

@ -18,6 +18,7 @@
uint8_t bootloader_common_get_chip_revision(void)
{
// should return the same value as esp_efuse_get_chip_ver()
/* No other revisions for ESP32-S2 */
return 0;
}

View File

@ -25,6 +25,7 @@
#include "soc/spi_reg.h"
#include "soc/spi_caps.h"
#include "flash_qio_mode.h"
#include "bootloader_common.h"
#include "bootloader_flash_config.h"
void bootloader_flash_update_id(void)
@ -32,6 +33,11 @@ void bootloader_flash_update_id(void)
g_rom_flashchip.device_id = bootloader_read_flash_id();
}
void bootloader_flash_update_size(uint32_t size)
{
g_rom_flashchip.chip_size = size;
}
void IRAM_ATTR bootloader_flash_cs_timing_config(void)
{
SET_PERI_REG_MASK(SPI_USER_REG(0), SPI_CS_HOLD_M | SPI_CS_SETUP_M);
@ -75,18 +81,11 @@ void IRAM_ATTR bootloader_flash_gpio_config(const esp_image_header_t* pfhdr)
uint32_t chip_ver = REG_GET_FIELD(EFUSE_BLK0_RDATA3_REG, EFUSE_RD_CHIP_VER_PKG);
uint32_t pkg_ver = chip_ver & 0x7;
if (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32D2WDQ5) {
// For ESP32D2WD the SPI pins are already configured
// flash clock signal should come from IO MUX.
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CLK_U, FUNC_SD_CLK_SPICLK);
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_CLK_U, FUN_DRV, drv, FUN_DRV_S);
} else if (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD2) {
// For ESP32PICOD2 the SPI pins are already configured
// flash clock signal should come from IO MUX.
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CLK_U, FUNC_SD_CLK_SPICLK);
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_CLK_U, FUN_DRV, drv, FUN_DRV_S);
} else if (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD4) {
// For ESP32PICOD4 the SPI pins are already configured
if (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32D2WDQ5 ||
pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD2 ||
pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD4 ||
pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOV302) {
// For ESP32D2WD or ESP32-PICO series,the SPI pins are already configured
// flash clock signal should come from IO MUX.
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CLK_U, FUNC_SD_CLK_SPICLK);
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_CLK_U, FUN_DRV, drv, FUN_DRV_S);
@ -163,4 +162,33 @@ void IRAM_ATTR bootloader_flash_dummy_config(const esp_image_header_t* pfhdr)
SET_PERI_REG_BITS(SPI_USER1_REG(0), SPI_USR_DUMMY_CYCLELEN_V, spi_cache_dummy + g_rom_spiflash_dummy_len_plus[0],
SPI_USR_DUMMY_CYCLELEN_S);
}
}
#define ESP32_D2WD_WP_GPIO 7 /* ESP32-D2WD & ESP32-PICO-D4 has this GPIO wired to WP pin of flash */
#define ESP32_PICO_V3_GPIO 18 /* ESP32-PICO-V3* use this GPIO for WP pin of flash */
int bootloader_flash_get_wp_pin(void)
{
#if CONFIG_BOOTLOADER_SPI_CUSTOM_WP_PIN
return CONFIG_BOOTLOADER_SPI_WP_PIN; // can be set for bootloader when QIO or QOUT config in use
#elif CONFIG_SPIRAM_CUSTOM_SPIWP_SD3_PIN
return CONFIG_SPIRAM_SPIWP_SD3_PIN; // can be set for app when DIO or DOUT config used for PSRAM only
#else
// no custom value, find it based on the package eFuse value
uint8_t chip_ver;
uint32_t pkg_ver = REG_GET_FIELD(EFUSE_BLK0_RDATA3_REG, EFUSE_RD_CHIP_VER_PKG);
switch(pkg_ver) {
case EFUSE_RD_CHIP_VER_PKG_ESP32D2WDQ5:
return ESP32_D2WD_WP_GPIO;
case EFUSE_RD_CHIP_VER_PKG_ESP32PICOD2:
case EFUSE_RD_CHIP_VER_PKG_ESP32PICOD4:
/* Same package IDs are used for ESP32-PICO-V3 and ESP32-PICO-D4, silicon version differentiates */
chip_ver = bootloader_common_get_chip_revision();
return (chip_ver < 3) ? ESP32_D2WD_WP_GPIO : ESP32_PICO_V3_GPIO;
case EFUSE_RD_CHIP_VER_PKG_ESP32PICOV302:
return ESP32_PICO_V3_GPIO;
default:
return SPI_WP_GPIO_NUM;
}
#endif
}

View File

@ -39,6 +39,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_MEM_USER_REG(0), SPI_MEM_CS_HOLD_M | SPI_MEM_CS_SETUP_M);
@ -69,6 +74,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_set_dummy_out(void)

View File

@ -14,6 +14,7 @@
#include <string.h>
#include <stdint.h>
#include "sdkconfig.h"
#include "esp_attr.h"
#include "esp_log.h"
#include "bootloader_init.h"
#include "bootloader_flash.h"
@ -28,7 +29,7 @@
static const char *TAG = "boot";
esp_image_header_t bootloader_image_hdr;
esp_image_header_t WORD_ALIGNED_ATTR bootloader_image_hdr;
void bootloader_clear_bss_section(void)
{

View File

@ -1,4 +1,4 @@
// Copyright 2010-2016 Espressif Systems (Shanghai) PTE LTD
// Copyright 2010-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.
@ -15,16 +15,6 @@
#include "bootloader_random.h"
#include "soc/cpu.h"
#include "soc/wdev_reg.h"
#include "soc/rtc_periph.h"
#include "soc/sens_periph.h"
#include "soc/syscon_periph.h"
#include "soc/dport_reg.h"
#include "soc/i2s_periph.h"
#include "esp_log.h"
#include "soc/io_mux_reg.h"
#if CONFIG_IDF_TARGET_ESP32S2
#include "soc/apb_saradc_reg.h"
#endif
#ifndef BOOTLOADER_BUILD
#include "esp_system.h"
@ -64,150 +54,3 @@ void bootloader_fill_random(void *buffer, size_t length)
}
}
#endif // BOOTLOADER_BUILD
void bootloader_random_enable(void)
{
/* Ensure the hardware RNG is enabled following a soft reset. This should always be the case already (this clock is
never disabled while the CPU is running), this is a "belts and braces" type check.
*/
#ifdef BOOTLOADER_BUILD
DPORT_SET_PERI_REG_MASK(DPORT_WIFI_CLK_EN_REG, DPORT_WIFI_CLK_RNG_EN);
#else
periph_module_enable(PERIPH_RNG_MODULE);
#endif // BOOTLOADER_BUILD
/* Enable SAR ADC in test mode to feed ADC readings of the 1.1V
reference via I2S into the RNG entropy input.
Note: I2S requires the PLL to be running, so the call to rtc_set_cpu_freq(CPU_80M)
in early bootloader startup must have been made.
*/
#if CONFIG_IDF_TARGET_ESP32
SET_PERI_REG_BITS(RTC_CNTL_TEST_MUX_REG, RTC_CNTL_DTEST_RTC, 2, RTC_CNTL_DTEST_RTC_S);
SET_PERI_REG_MASK(RTC_CNTL_TEST_MUX_REG, RTC_CNTL_ENT_RTC);
SET_PERI_REG_MASK(SENS_SAR_START_FORCE_REG, SENS_SAR2_EN_TEST);
#ifdef BOOTLOADER_BUILD
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_I2S0_CLK_EN);
#else
periph_module_enable(PERIPH_I2S0_MODULE);
#endif // BOOTLOADER_BUILD
CLEAR_PERI_REG_MASK(SENS_SAR_START_FORCE_REG, SENS_ULP_CP_FORCE_START_TOP);
CLEAR_PERI_REG_MASK(SENS_SAR_START_FORCE_REG, SENS_ULP_CP_START_TOP);
#elif CONFIG_IDF_TARGET_ESP32S2
/* Disable IO1 digital function for random function. */
PIN_INPUT_DISABLE(PERIPHS_IO_MUX_GPIO1_U);
PIN_PULLDWN_DIS(PERIPHS_IO_MUX_GPIO1_U);
PIN_PULLUP_DIS(PERIPHS_IO_MUX_GPIO1_U);
WRITE_PERI_REG(APB_SARADC_SAR1_PATT_TAB1_REG, 0xFFFFFFFF);
SET_PERI_REG_MASK(SENS_SAR_MEAS2_CTRL1_REG, SENS_SAR2_EN_TEST);
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_I2S0_CLK_EN);
CLEAR_PERI_REG_MASK(RTC_CNTL_ULP_CP_CTRL_REG, RTC_CNTL_ULP_CP_FORCE_START_TOP);
CLEAR_PERI_REG_MASK(RTC_CNTL_ULP_CP_CTRL_REG, RTC_CNTL_ULP_CP_START_TOP);
#endif
// Test pattern configuration byte 0xAD:
//--[7:4] channel_sel: 10-->en_test
//--[3:2] bit_width : 3-->12bit
//--[1:0] atten : 1-->3dB attenuation
#if CONFIG_IDF_TARGET_ESP32
WRITE_PERI_REG(SYSCON_SARADC_SAR2_PATT_TAB1_REG, 0xADADADAD);
WRITE_PERI_REG(SYSCON_SARADC_SAR2_PATT_TAB2_REG, 0xADADADAD);
WRITE_PERI_REG(SYSCON_SARADC_SAR2_PATT_TAB3_REG, 0xADADADAD);
WRITE_PERI_REG(SYSCON_SARADC_SAR2_PATT_TAB4_REG, 0xADADADAD);
SET_PERI_REG_BITS(SENS_SAR_MEAS_WAIT2_REG, SENS_FORCE_XPD_SAR, 3, SENS_FORCE_XPD_SAR_S);
SET_PERI_REG_MASK(SENS_SAR_READ_CTRL_REG, SENS_SAR1_DIG_FORCE);
SET_PERI_REG_MASK(SENS_SAR_READ_CTRL2_REG, SENS_SAR2_DIG_FORCE);
#elif CONFIG_IDF_TARGET_ESP32S2
WRITE_PERI_REG(APB_SARADC_SAR2_PATT_TAB1_REG, 0xADADADAD);
WRITE_PERI_REG(APB_SARADC_SAR2_PATT_TAB2_REG, 0xADADADAD);
WRITE_PERI_REG(APB_SARADC_SAR2_PATT_TAB3_REG, 0xADADADAD);
WRITE_PERI_REG(APB_SARADC_SAR2_PATT_TAB4_REG, 0xADADADAD);
SET_PERI_REG_BITS(SENS_SAR_POWER_XPD_SAR_REG, SENS_FORCE_XPD_SAR, 3, SENS_FORCE_XPD_SAR_S);
SET_PERI_REG_MASK(SENS_SAR_MEAS1_MUX_REG, SENS_SAR1_DIG_FORCE);
#endif
#if CONFIG_IDF_TARGET_ESP32
SET_PERI_REG_MASK(SYSCON_SARADC_CTRL_REG, SYSCON_SARADC_SAR2_MUX);
SET_PERI_REG_BITS(SYSCON_SARADC_CTRL_REG, SYSCON_SARADC_SAR_CLK_DIV, 4, SYSCON_SARADC_SAR_CLK_DIV_S);
SET_PERI_REG_BITS(SYSCON_SARADC_FSM_REG, SYSCON_SARADC_RSTB_WAIT, 8, SYSCON_SARADC_RSTB_WAIT_S); /* was 1 */
SET_PERI_REG_BITS(SYSCON_SARADC_FSM_REG, SYSCON_SARADC_START_WAIT, 10, SYSCON_SARADC_START_WAIT_S);
SET_PERI_REG_BITS(SYSCON_SARADC_CTRL_REG, SYSCON_SARADC_WORK_MODE, 0, SYSCON_SARADC_WORK_MODE_S);
SET_PERI_REG_MASK(SYSCON_SARADC_CTRL_REG, SYSCON_SARADC_SAR_SEL);
CLEAR_PERI_REG_MASK(SYSCON_SARADC_CTRL_REG, SYSCON_SARADC_DATA_SAR_SEL);
SET_PERI_REG_BITS(I2S_SAMPLE_RATE_CONF_REG(0), I2S_RX_BCK_DIV_NUM, 20, I2S_RX_BCK_DIV_NUM_S);
SET_PERI_REG_MASK(SYSCON_SARADC_CTRL_REG, SYSCON_SARADC_DATA_TO_I2S);
#elif CONFIG_IDF_TARGET_ESP32S2
SET_PERI_REG_BITS(APB_SARADC_CTRL_REG, APB_SARADC_SAR_CLK_DIV, 4, APB_SARADC_SAR_CLK_DIV_S);
SET_PERI_REG_BITS(APB_SARADC_FSM_REG, APB_SARADC_RSTB_WAIT, 8, APB_SARADC_RSTB_WAIT_S); /* was 1 */
SET_PERI_REG_BITS(APB_SARADC_CTRL_REG, APB_SARADC_WORK_MODE, 0, APB_SARADC_WORK_MODE_S);
SET_PERI_REG_MASK(APB_SARADC_CTRL_REG, APB_SARADC_SAR_SEL);
CLEAR_PERI_REG_MASK(APB_SARADC_CTRL_REG, APB_SARADC_DATA_SAR_SEL);
SET_PERI_REG_BITS(I2S_SAMPLE_RATE_CONF_REG(0), I2S_RX_BCK_DIV_NUM, 20, I2S_RX_BCK_DIV_NUM_S);
SET_PERI_REG_MASK(APB_SARADC_CTRL_REG, APB_SARADC_DATA_TO_I2S);
#endif
CLEAR_PERI_REG_MASK(I2S_CONF2_REG(0), I2S_CAMERA_EN);
SET_PERI_REG_MASK(I2S_CONF2_REG(0), I2S_LCD_EN);
SET_PERI_REG_MASK(I2S_CONF2_REG(0), I2S_DATA_ENABLE);
SET_PERI_REG_MASK(I2S_CONF2_REG(0), I2S_DATA_ENABLE_TEST_EN);
SET_PERI_REG_MASK(I2S_CONF_REG(0), I2S_RX_START);
}
void bootloader_random_disable(void)
{
/* 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);
/* Disable i2s clock */
#ifdef BOOTLOADER_BUILD
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_I2S0_CLK_EN);
#else
periph_module_disable(PERIPH_I2S0_MODULE);
#endif // BOOTLOADER_BUILD
/* Restore SYSCON mode registers */
#if CONFIG_IDF_TARGET_ESP32
CLEAR_PERI_REG_MASK(SENS_SAR_READ_CTRL_REG, SENS_SAR1_DIG_FORCE);
CLEAR_PERI_REG_MASK(SENS_SAR_READ_CTRL2_REG, SENS_SAR2_DIG_FORCE);
#elif CONFIG_IDF_TARGET_ESP32S2
CLEAR_PERI_REG_MASK(SENS_SAR_MEAS1_MUX_REG, SENS_SAR1_DIG_FORCE);
#endif
#if CONFIG_IDF_TARGET_ESP32
/* Restore SAR ADC mode */
CLEAR_PERI_REG_MASK(SENS_SAR_START_FORCE_REG, SENS_SAR2_EN_TEST);
CLEAR_PERI_REG_MASK(SYSCON_SARADC_CTRL_REG, SYSCON_SARADC_SAR2_MUX
| SYSCON_SARADC_SAR_SEL | SYSCON_SARADC_DATA_TO_I2S);
SET_PERI_REG_BITS(SENS_SAR_MEAS_WAIT2_REG, SENS_FORCE_XPD_SAR, 0, SENS_FORCE_XPD_SAR_S);
#elif CONFIG_IDF_TARGET_ESP32S2
CLEAR_PERI_REG_MASK(SENS_SAR_MEAS2_CTRL1_REG, SENS_SAR2_EN_TEST);
CLEAR_PERI_REG_MASK(APB_SARADC_CTRL_REG, APB_SARADC_SAR_SEL | APB_SARADC_DATA_TO_I2S);
SET_PERI_REG_BITS(SENS_SAR_POWER_XPD_SAR_REG, SENS_FORCE_XPD_SAR, 0, SENS_FORCE_XPD_SAR_S);
#endif
#if CONFIG_IDF_TARGET_ESP32
SET_PERI_REG_BITS(SYSCON_SARADC_FSM_REG, SYSCON_SARADC_START_WAIT, 8, SYSCON_SARADC_START_WAIT_S);
#endif
/* Reset i2s peripheral */
#ifdef BOOTLOADER_BUILD
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_I2S0_RST);
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_I2S0_RST);
#else
periph_module_reset(PERIPH_I2S0_MODULE);
#endif
#if CONFIG_IDF_TARGET_ESP32
/* Disable pull supply voltage to SAR ADC */
CLEAR_PERI_REG_MASK(RTC_CNTL_TEST_MUX_REG, RTC_CNTL_ENT_RTC);
SET_PERI_REG_BITS(RTC_CNTL_TEST_MUX_REG, RTC_CNTL_DTEST_RTC, 0, RTC_CNTL_DTEST_RTC_S);
#endif
}

View File

@ -0,0 +1,128 @@
// Copyright 2016-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 "sdkconfig.h"
#include "bootloader_random.h"
#include "soc/rtc_periph.h"
#include "soc/sens_periph.h"
#include "soc/syscon_periph.h"
#include "soc/dport_reg.h"
#include "soc/i2s_periph.h"
#include "esp_log.h"
#include "soc/io_mux_reg.h"
#ifndef BOOTLOADER_BUILD
#include "driver/periph_ctrl.h"
#endif
void bootloader_random_enable(void)
{
/* Ensure the hardware RNG is enabled following a soft reset. This should always be the case already (this clock is
never disabled while the CPU is running), this is a "belts and braces" type check.
*/
#ifdef BOOTLOADER_BUILD
DPORT_SET_PERI_REG_MASK(DPORT_WIFI_CLK_EN_REG, DPORT_WIFI_CLK_RNG_EN);
#else
periph_module_enable(PERIPH_RNG_MODULE);
#endif // BOOTLOADER_BUILD
/* Enable SAR ADC in test mode to feed ADC readings of the 1.1V
reference via I2S into the RNG entropy input.
Note: I2S requires the PLL to be running, so the call to rtc_set_cpu_freq(CPU_80M)
in early bootloader startup must have been made.
*/
SET_PERI_REG_BITS(RTC_CNTL_TEST_MUX_REG, RTC_CNTL_DTEST_RTC, 2, RTC_CNTL_DTEST_RTC_S);
SET_PERI_REG_MASK(RTC_CNTL_TEST_MUX_REG, RTC_CNTL_ENT_RTC);
SET_PERI_REG_MASK(SENS_SAR_START_FORCE_REG, SENS_SAR2_EN_TEST);
#ifdef BOOTLOADER_BUILD
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_I2S0_CLK_EN);
#else
periph_module_enable(PERIPH_I2S0_MODULE);
#endif // BOOTLOADER_BUILD
CLEAR_PERI_REG_MASK(SENS_SAR_START_FORCE_REG, SENS_ULP_CP_FORCE_START_TOP);
CLEAR_PERI_REG_MASK(SENS_SAR_START_FORCE_REG, SENS_ULP_CP_START_TOP);
// Test pattern configuration byte 0xAD:
//--[7:4] channel_sel: 10-->en_test
//--[3:2] bit_width : 3-->12bit
//--[1:0] atten : 1-->3dB attenuation
WRITE_PERI_REG(SYSCON_SARADC_SAR2_PATT_TAB1_REG, 0xADADADAD);
WRITE_PERI_REG(SYSCON_SARADC_SAR2_PATT_TAB2_REG, 0xADADADAD);
WRITE_PERI_REG(SYSCON_SARADC_SAR2_PATT_TAB3_REG, 0xADADADAD);
WRITE_PERI_REG(SYSCON_SARADC_SAR2_PATT_TAB4_REG, 0xADADADAD);
SET_PERI_REG_BITS(SENS_SAR_MEAS_WAIT2_REG, SENS_FORCE_XPD_SAR, 3, SENS_FORCE_XPD_SAR_S);
SET_PERI_REG_MASK(SENS_SAR_READ_CTRL_REG, SENS_SAR1_DIG_FORCE);
SET_PERI_REG_MASK(SENS_SAR_READ_CTRL2_REG, SENS_SAR2_DIG_FORCE);
SET_PERI_REG_MASK(SYSCON_SARADC_CTRL_REG, SYSCON_SARADC_SAR2_MUX);
SET_PERI_REG_BITS(SYSCON_SARADC_CTRL_REG, SYSCON_SARADC_SAR_CLK_DIV, 4, SYSCON_SARADC_SAR_CLK_DIV_S);
SET_PERI_REG_BITS(SYSCON_SARADC_FSM_REG, SYSCON_SARADC_RSTB_WAIT, 8, SYSCON_SARADC_RSTB_WAIT_S); /* was 1 */
SET_PERI_REG_BITS(SYSCON_SARADC_FSM_REG, SYSCON_SARADC_START_WAIT, 10, SYSCON_SARADC_START_WAIT_S);
SET_PERI_REG_BITS(SYSCON_SARADC_CTRL_REG, SYSCON_SARADC_WORK_MODE, 0, SYSCON_SARADC_WORK_MODE_S);
SET_PERI_REG_MASK(SYSCON_SARADC_CTRL_REG, SYSCON_SARADC_SAR_SEL);
CLEAR_PERI_REG_MASK(SYSCON_SARADC_CTRL_REG, SYSCON_SARADC_DATA_SAR_SEL);
SET_PERI_REG_BITS(I2S_SAMPLE_RATE_CONF_REG(0), I2S_RX_BCK_DIV_NUM, 20, I2S_RX_BCK_DIV_NUM_S);
SET_PERI_REG_MASK(SYSCON_SARADC_CTRL_REG, SYSCON_SARADC_DATA_TO_I2S);
CLEAR_PERI_REG_MASK(I2S_CONF2_REG(0), I2S_CAMERA_EN);
SET_PERI_REG_MASK(I2S_CONF2_REG(0), I2S_LCD_EN);
SET_PERI_REG_MASK(I2S_CONF2_REG(0), I2S_DATA_ENABLE);
SET_PERI_REG_MASK(I2S_CONF2_REG(0), I2S_DATA_ENABLE_TEST_EN);
SET_PERI_REG_MASK(I2S_CONF_REG(0), I2S_RX_START);
}
void bootloader_random_disable(void)
{
/* 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);
/* Disable i2s clock */
#ifdef BOOTLOADER_BUILD
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_I2S0_CLK_EN);
#else
periph_module_disable(PERIPH_I2S0_MODULE);
#endif // BOOTLOADER_BUILD
/* Restore SYSCON mode registers */
CLEAR_PERI_REG_MASK(SENS_SAR_READ_CTRL_REG, SENS_SAR1_DIG_FORCE);
CLEAR_PERI_REG_MASK(SENS_SAR_READ_CTRL2_REG, SENS_SAR2_DIG_FORCE);
/* Restore SAR ADC mode */
CLEAR_PERI_REG_MASK(SENS_SAR_START_FORCE_REG, SENS_SAR2_EN_TEST);
CLEAR_PERI_REG_MASK(SYSCON_SARADC_CTRL_REG, SYSCON_SARADC_SAR2_MUX
| SYSCON_SARADC_SAR_SEL | SYSCON_SARADC_DATA_TO_I2S);
SET_PERI_REG_BITS(SENS_SAR_MEAS_WAIT2_REG, SENS_FORCE_XPD_SAR, 0, SENS_FORCE_XPD_SAR_S);
SET_PERI_REG_BITS(SYSCON_SARADC_FSM_REG, SYSCON_SARADC_START_WAIT, 8, SYSCON_SARADC_START_WAIT_S);
/* Reset i2s peripheral */
#ifdef BOOTLOADER_BUILD
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_I2S0_RST);
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_I2S0_RST);
#else
periph_module_reset(PERIPH_I2S0_MODULE);
#endif
/* Disable pull supply voltage to SAR ADC */
CLEAR_PERI_REG_MASK(RTC_CNTL_TEST_MUX_REG, RTC_CNTL_ENT_RTC);
SET_PERI_REG_BITS(RTC_CNTL_TEST_MUX_REG, RTC_CNTL_DTEST_RTC, 0, RTC_CNTL_DTEST_RTC_S);
}

View File

@ -0,0 +1,106 @@
// Copyright 2019-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 "sdkconfig.h"
#include "bootloader_random.h"
#include "soc/rtc_periph.h"
#include "soc/sens_periph.h"
#include "soc/syscon_periph.h"
#include "soc/dport_reg.h"
#include "soc/i2s_periph.h"
#include "esp_log.h"
#include "soc/io_mux_reg.h"
#include "soc/apb_saradc_reg.h"
#include "regi2c_ctrl.h"
#include "hal/adc_ll.h"
#ifndef BOOTLOADER_BUILD
#include "driver/periph_ctrl.h"
#endif
void bootloader_random_enable(void)
{
/* Ensure the Wifi clock for RNG modiule is enabled following a soft reset. This should always be the case already
(this clock is never disabled while the CPU is running), this is a "belt and braces" type check.
*/
#ifdef BOOTLOADER_BUILD
DPORT_SET_PERI_REG_MASK(DPORT_WIFI_CLK_EN_REG, DPORT_WIFI_CLK_RNG_EN);
#else
periph_module_enable(PERIPH_RNG_MODULE);
#endif // BOOTLOADER_BUILD
// Enable 8M clock source for RNG (this is actually enough to produce strong random results,
// but enabling the SAR ADC as well adds some insurance.)
REG_SET_BIT(RTC_CNTL_CLK_CONF_REG, RTC_CNTL_DIG_CLK8M_EN);
// Enable SAR ADC to read a disconnected input for additional entropy
SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN0_REG,DPORT_APB_SARADC_CLK_EN);
REG_SET_FIELD(APB_SARADC_APB_ADC_CLKM_CONF_REG, APB_SARADC_CLK_SEL, 2);
CLEAR_PERI_REG_MASK(RTC_CNTL_ANA_CONF_REG, RTC_CNTL_SAR_I2C_FORCE_PD_M);
SET_PERI_REG_MASK(RTC_CNTL_ANA_CONF_REG, RTC_CNTL_SAR_I2C_FORCE_PU_M);
CLEAR_PERI_REG_MASK(ANA_CONFIG_REG, BIT(18));
SET_PERI_REG_MASK(ANA_CONFIG2_REG, BIT(16));
REGI2C_WRITE_MASK(I2C_SAR_ADC, ADC_SAR1_DREF_ADDR, 0x4);
REGI2C_WRITE_MASK(I2C_SAR_ADC, ADC_SAR2_DREF_ADDR, 0x4);
REGI2C_WRITE_MASK(I2C_SAR_ADC, ADC_SARADC_ENCAL_REF_ADDR, 1);
REGI2C_WRITE_MASK(I2C_SAR_ADC, ADC_SARADC_ENT_TSENS_ADDR, 1);
REGI2C_WRITE_MASK(I2C_SAR_ADC, ADC_SARADC_ENT_RTC_ADDR, 0);
REG_SET_FIELD(APB_SARADC_CTRL_REG, APB_SARADC_SAR1_PATT_LEN, 0);
WRITE_PERI_REG(APB_SARADC_SAR1_PATT_TAB1_REG,0xafffffff); // set adc1 channel & bitwidth & atten
REG_SET_FIELD(APB_SARADC_CTRL_REG, APB_SARADC_SAR2_PATT_LEN, 0);
WRITE_PERI_REG(APB_SARADC_SAR2_PATT_TAB1_REG,0xafffffff); //set adc2 channel & bitwidth & atten
SET_PERI_REG_MASK(SENS_SAR_MEAS1_MUX_REG,SENS_SAR1_DIG_FORCE);
REG_SET_FIELD(APB_SARADC_CTRL_REG,APB_SARADC_WORK_MODE, 1);
CLEAR_PERI_REG_MASK(APB_SARADC_CTRL2_REG,APB_SARADC_MEAS_NUM_LIMIT);
REG_SET_FIELD(SENS_SAR_POWER_XPD_SAR_REG, SENS_FORCE_XPD_SAR, 3);
SET_PERI_REG_MASK(APB_SARADC_CTRL2_REG,APB_SARADC_TIMER_SEL);
REG_SET_FIELD(APB_SARADC_CTRL2_REG, APB_SARADC_TIMER_TARGET, 100);
CLEAR_PERI_REG_MASK(APB_SARADC_CTRL_REG,APB_SARADC_START_FORCE);
SET_PERI_REG_MASK(APB_SARADC_CTRL2_REG,APB_SARADC_TIMER_EN);
}
void bootloader_random_disable(void)
{
/* Restore internal I2C bus state */
REGI2C_WRITE_MASK(I2C_SAR_ADC, ADC_SAR1_DREF_ADDR, 0x1);
REGI2C_WRITE_MASK(I2C_SAR_ADC, ADC_SAR2_DREF_ADDR, 0x1);
REGI2C_WRITE_MASK(I2C_SAR_ADC, ADC_SARADC_ENCAL_REF_ADDR, 0);
REGI2C_WRITE_MASK(I2C_SAR_ADC, ADC_SARADC_ENT_TSENS_ADDR, 0);
REGI2C_WRITE_MASK(I2C_SAR_ADC, ADC_SARADC_ENT_RTC_ADDR, 0);
/* Restore SARADC to default mode */
CLEAR_PERI_REG_MASK(SENS_SAR_MEAS1_MUX_REG, SENS_SAR1_DIG_FORCE);
SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN0_REG, DPORT_APB_SARADC_CLK_EN);
SET_PERI_REG_BITS(SENS_SAR_POWER_XPD_SAR_REG, SENS_FORCE_XPD_SAR, 0, SENS_FORCE_XPD_SAR_S);
CLEAR_PERI_REG_MASK(APB_SARADC_CTRL2_REG, APB_SARADC_TIMER_EN);
/* Note: the 8M CLK entropy source continues running even after this function is called,
but as mentioned above it's better to enable Wi-Fi or BT or call bootloader_random_enable()
in order to get a secondary entropy source.
*/
}

View File

@ -821,6 +821,7 @@ void bootloader_debug_buffer(const void *buffer, size_t length, const char *labe
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;
}
@ -837,7 +838,7 @@ esp_err_t bootloader_sha256_flash_contents(uint32_t flash_offset, uint32_t len,
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);

View File

@ -55,18 +55,11 @@ void bootloader_configure_spi_pins(int drv)
uint32_t chip_ver = REG_GET_FIELD(EFUSE_BLK0_RDATA3_REG, EFUSE_RD_CHIP_VER_PKG);
uint32_t pkg_ver = chip_ver & 0x7;
if (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32D2WDQ5) {
// For ESP32D2WD the SPI pins are already configured
// flash clock signal should come from IO MUX.
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CLK_U, FUNC_SD_CLK_SPICLK);
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_CLK_U, FUN_DRV, drv, FUN_DRV_S);
} else if (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD2) {
// For ESP32PICOD2 the SPI pins are already configured
// flash clock signal should come from IO MUX.
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CLK_U, FUNC_SD_CLK_SPICLK);
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_CLK_U, FUN_DRV, drv, FUN_DRV_S);
} else if (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD4) {
// For ESP32PICOD4 the SPI pins are already configured
if (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32D2WDQ5 ||
pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD2 ||
pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD4 ||
pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOV302) {
// For ESP32D2WD or ESP32-PICO series,the SPI pins are already configured
// flash clock signal should come from IO MUX.
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CLK_U, FUNC_SD_CLK_SPICLK);
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_CLK_U, FUN_DRV, drv, FUN_DRV_S);

View File

@ -252,9 +252,7 @@ static esp_err_t encrypt_bootloader(void)
ESP_LOGD(TAG, "bootloader is plaintext. Encrypting...");
#if CONFIG_SECURE_BOOT_V2_ENABLED
// Account for the signature sector after the bootloader
image_length = (image_length + FLASH_SECTOR_SIZE - 1) & ~(FLASH_SECTOR_SIZE - 1);
image_length += FLASH_SECTOR_SIZE;
/* The image length obtained from esp_image_verify_bootloader includes the sector boundary padding and the signature block lengths */
if (ESP_BOOTLOADER_OFFSET + image_length > ESP_PARTITION_TABLE_OFFSET) {
ESP_LOGE(TAG, "Bootloader is too large to fit Secure Boot V2 signature sector and partition table (configured offset 0x%x)", ESP_PARTITION_TABLE_OFFSET);
return ESP_ERR_INVALID_STATE;

View File

@ -319,16 +319,26 @@ esp_err_t esp_secure_boot_v2_permanently_enable(const esp_image_metadata_t *imag
uint32_t dis_reg = REG_READ(EFUSE_BLK0_RDATA0_REG);
bool efuse_key_read_protected = dis_reg & EFUSE_RD_DIS_BLK2;
bool efuse_key_write_protected = dis_reg & EFUSE_WR_DIS_BLK2;
if (efuse_key_write_protected == false
&& efuse_key_read_protected == false
&& REG_READ(EFUSE_BLK2_RDATA0_REG) == 0
&& REG_READ(EFUSE_BLK2_RDATA1_REG) == 0
&& REG_READ(EFUSE_BLK2_RDATA2_REG) == 0
&& REG_READ(EFUSE_BLK2_RDATA3_REG) == 0
&& REG_READ(EFUSE_BLK2_RDATA4_REG) == 0
&& REG_READ(EFUSE_BLK2_RDATA5_REG) == 0
&& REG_READ(EFUSE_BLK2_RDATA6_REG) == 0
&& REG_READ(EFUSE_BLK2_RDATA7_REG) == 0) {
uint32_t efuse_blk2_r0, efuse_blk2_r1, efuse_blk2_r2, efuse_blk2_r3, efuse_blk2_r4, efuse_blk2_r5, efuse_blk2_r6, efuse_blk2_r7;
efuse_blk2_r0 = REG_READ(EFUSE_BLK2_RDATA0_REG);
efuse_blk2_r1 = REG_READ(EFUSE_BLK2_RDATA1_REG);
efuse_blk2_r2 = REG_READ(EFUSE_BLK2_RDATA2_REG);
efuse_blk2_r3 = REG_READ(EFUSE_BLK2_RDATA3_REG);
efuse_blk2_r4 = REG_READ(EFUSE_BLK2_RDATA4_REG);
efuse_blk2_r5 = REG_READ(EFUSE_BLK2_RDATA5_REG);
efuse_blk2_r6 = REG_READ(EFUSE_BLK2_RDATA6_REG);
efuse_blk2_r7 = REG_READ(EFUSE_BLK2_RDATA7_REG);
if (efuse_key_read_protected == true) {
ESP_LOGE(TAG, "Secure Boot v2 digest(BLK2) read protected, aborting....");
return ESP_FAIL;
}
if (efuse_key_write_protected == false
&& efuse_blk2_r0 == 0 && efuse_blk2_r1 == 0
&& efuse_blk2_r2 == 0 && efuse_blk2_r3 == 0
&& efuse_blk2_r4 == 0 && efuse_blk2_r5 == 0
&& efuse_blk2_r6 == 0 && efuse_blk2_r7 == 0) {
/* Verifies the signature block appended to the image matches with the signature block of the app to be loaded */
ret = secure_boot_v2_digest_generate(bootloader_data.start_addr, bootloader_data.image_len - SIG_BLOCK_PADDING, boot_pub_key_digest);
if (ret != ESP_OK) {
@ -343,14 +353,26 @@ esp_err_t esp_secure_boot_v2_permanently_enable(const esp_image_metadata_t *imag
ESP_LOGD(TAG, "EFUSE_BLKx_WDATA%d_REG = 0x%08x", i, boot_public_key_digest_ptr[i]);
}
ESP_LOGI(TAG, "Write protecting public key digest...");
new_wdata0 |= EFUSE_WR_DIS_BLK2;
efuse_key_write_protected = true;
efuse_key_read_protected = false;
} else {
uint32_t efuse_blk2_digest[8];
efuse_blk2_digest[0] = efuse_blk2_r0;
efuse_blk2_digest[1] = efuse_blk2_r1;
efuse_blk2_digest[2] = efuse_blk2_r2;
efuse_blk2_digest[3] = efuse_blk2_r3;
efuse_blk2_digest[4] = efuse_blk2_r4;
efuse_blk2_digest[5] = efuse_blk2_r5;
efuse_blk2_digest[6] = efuse_blk2_r6;
efuse_blk2_digest[7] = efuse_blk2_r7;
memcpy(boot_pub_key_digest, efuse_blk2_digest, DIGEST_LEN);
ESP_LOGW(TAG, "Using pre-loaded secure boot v2 public key digest in EFUSE block 2");
}
if (efuse_key_write_protected == false) {
ESP_LOGI(TAG, "Write protecting public key digest...");
new_wdata0 |= EFUSE_WR_DIS_BLK2; // delay burning until second half of this function
efuse_key_write_protected = true;
}
uint8_t app_pub_key_digest[DIGEST_LEN];
ret = secure_boot_v2_digest_generate(image_data->start_addr, image_data->image_len - SIG_BLOCK_PADDING, app_pub_key_digest);
if (ret != ESP_OK) {

View File

@ -286,9 +286,7 @@ static esp_err_t encrypt_bootloader(void)
ESP_LOGD(TAG, "bootloader is plaintext. Encrypting...");
#if CONFIG_SECURE_BOOT_V2_ENABLED
// Account for the signature sector after the bootloader
image_length = (image_length + FLASH_SECTOR_SIZE - 1) & ~(FLASH_SECTOR_SIZE - 1);
image_length += FLASH_SECTOR_SIZE;
/* The image length obtained from esp_image_verify_bootloader includes the sector boundary padding and the signature block lengths */
if (ESP_BOOTLOADER_OFFSET + image_length > ESP_PARTITION_TABLE_OFFSET) {
ESP_LOGE(TAG, "Bootloader is too large to fit Secure Boot V2 signature sector and partition table (configured offset 0x%x)", ESP_PARTITION_TABLE_OFFSET);
return ESP_ERR_INVALID_SIZE;

View File

@ -11,43 +11,315 @@
// 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 "esp_secure_boot.h"
#include <string.h>
#include "esp_log.h"
#include "esp_secure_boot.h"
#include "soc/efuse_reg.h"
#include "bootloader_flash.h"
#include "bootloader_sha.h"
#include "bootloader_utility.h"
#include "esp32s2/rom/crc.h"
#include "esp_efuse.h"
#include "esp_efuse_table.h"
#include "esp32s2/rom/efuse.h"
#include "esp32s2/rom/secure_boot.h"
static const char *TAG = "secure_boot";
static const char *TAG = "secure_boot_v2";
#define ALIGN_UP(num, align) (((num) + ((align) - 1)) & ~((align) - 1))
esp_err_t esp_secure_boot_permanently_enable(void)
#define SIG_BLOCK_MAGIC_BYTE 0xe7
#define CRC_SIGN_BLOCK_LEN 1196
#define SIG_BLOCK_PADDING 4096
#define DIGEST_LEN 32
/* A signature block is valid when it has correct magic byte, crc and image digest. */
static esp_err_t validate_signature_block(const ets_secure_boot_sig_block_t *block, int block_num, const uint8_t *image_digest)
{
uint8_t hash[32];
if (ets_efuse_secure_boot_enabled())
{
ESP_LOGI(TAG, "secure boot is already enabled, continuing..");
uint32_t crc = crc32_le(0, (uint8_t *)block, CRC_SIGN_BLOCK_LEN);
if (block->magic_byte != SIG_BLOCK_MAGIC_BYTE) {
// All signature blocks have been parsed, no new signature block present.
ESP_LOGD(TAG, "Signature block(%d) invalid/absent.", block_num);
return ESP_FAIL;
}
if (block->block_crc != crc) {
ESP_LOGE(TAG, "Magic byte correct but incorrect crc.");
return ESP_FAIL;
}
if (memcmp(image_digest, block->image_digest, DIGEST_LEN)) {
ESP_LOGE(TAG, "Magic byte & CRC correct but incorrect image digest.");
return ESP_FAIL;
} else {
ESP_LOGD(TAG, "valid signature block(%d) found", block_num);
return ESP_OK;
}
ESP_LOGI(TAG, "Verifying bootloader signature...\n");
int r = ets_secure_boot_verify_bootloader(hash, false);
if (r != ESP_OK) {
ESP_LOGE(TAG, "Failed to verify bootloader signature");
return r;
return ESP_FAIL;
}
/* Structure to hold public key digests calculated from the signature blocks of a single image.
Each image can have one or more signature blocks (up to SECURE_BOOT_NUM_BLOCKS). Each signature block
includes a public key.
Different to the ROM ets_secure_boot_key_digests_t structure which holds pointers to eFuse data with digests,
in this data structure the digest data is included.
*/
typedef struct {
uint8_t key_digests[SECURE_BOOT_NUM_BLOCKS][DIGEST_LEN];
unsigned num_digests; /* Number of valid digests, starting at index 0 */
} image_sig_public_key_digests_t;
/* Generates the public key digests of the valid public keys in an image's
signature block, verifies each signature, and stores the key digests in the
public_key_digests structure.
@param flash_offset Image offset in flash
@param flash_size Image size in flash (not including signature block)
@param[out] public_key_digests Pointer to structure to hold the key digests for valid sig blocks
Note that this function doesn't read any eFuses, so it doesn't know if the
keys are ultimately trusted by the hardware or not
@return - ESP_OK if no signatures failed to verify, or if no valid signature blocks are found at all.
- ESP_FAIL if there's a valid signature block that doesn't verify using the included public key (unexpected!)
*/
static esp_err_t s_calculate_image_public_key_digests(uint32_t flash_offset, uint32_t flash_size, image_sig_public_key_digests_t *public_key_digests)
{
esp_err_t ret;
uint8_t image_digest[DIGEST_LEN] = {0};
uint8_t __attribute__((aligned(4))) key_digest[DIGEST_LEN] = {0};
size_t sig_block_addr = flash_offset + ALIGN_UP(flash_size, FLASH_SECTOR_SIZE);
ESP_LOGD(TAG, "calculating public key digests for sig blocks of image offset 0x%x (sig block offset 0x%x)", flash_offset, sig_block_addr);
bzero(public_key_digests, sizeof(image_sig_public_key_digests_t));
ret = bootloader_sha256_flash_contents(flash_offset, sig_block_addr - flash_offset, image_digest);
if (ret != ESP_OK) {
ESP_LOGE(TAG, "error generating image digest, %d", ret);
return ret;
}
esp_efuse_batch_write_begin(); /* Batch all efuse writes at the end of this function */
ESP_LOGD(TAG, "reading signatures");
const ets_secure_boot_signature_t *signatures = bootloader_mmap(sig_block_addr, sizeof(ets_secure_boot_signature_t));
if (signatures == NULL) {
ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", sig_block_addr, sizeof(ets_secure_boot_signature_t));
return ESP_FAIL;
}
for (int i = 0; i < SECURE_BOOT_NUM_BLOCKS; i++) {
const ets_secure_boot_sig_block_t *block = &signatures->block[i];
ret = validate_signature_block(block, i, image_digest);
if (ret != ESP_OK) {
ret = ESP_OK; // past the last valid signature block
break;
}
/* Generating the SHA of the public key components in the signature block */
bootloader_sha256_handle_t sig_block_sha;
sig_block_sha = bootloader_sha256_start();
bootloader_sha256_data(sig_block_sha, &block->key, sizeof(block->key));
bootloader_sha256_finish(sig_block_sha, key_digest);
// Check we can verify the image using this signature and this key
uint8_t temp_verified_digest[DIGEST_LEN];
bool verified = ets_rsa_pss_verify(&block->key, block->signature, image_digest, temp_verified_digest);
if (!verified) {
/* We don't expect this: the signature blocks before we enable secure boot should all be verifiable or invalid,
so this is a fatal error
*/
ret = ESP_FAIL;
ESP_LOGE(TAG, "Secure boot key (%d) verification failed.", i);
break;
}
ESP_LOGD(TAG, "Signature block (%d) is verified", i);
/* Copy the key digest to the buffer provided by the caller */
memcpy((void *)public_key_digests->key_digests[i], key_digest, DIGEST_LEN);
public_key_digests->num_digests++;
}
if (ret == ESP_OK && public_key_digests->num_digests > 0) {
ESP_LOGI(TAG, "Digests successfully calculated, %d valid signatures (image offset 0x%x)",
public_key_digests->num_digests, flash_offset);
}
bootloader_munmap(signatures);
return ret;
}
esp_err_t esp_secure_boot_v2_permanently_enable(const esp_image_metadata_t *image_data)
{
ESP_LOGI(TAG, "enabling secure boot v2 - ESP32-S2...");
if (esp_secure_boot_enabled()) {
ESP_LOGI(TAG, "secure boot v2 is already enabled, continuing..");
return ESP_OK;
}
esp_err_t ret;
/* Verify the bootloader */
esp_image_metadata_t bootloader_data = { 0 };
ret = esp_image_verify_bootloader_data(&bootloader_data);
if (ret != ESP_OK) {
ESP_LOGE(TAG, "bootloader image appears invalid! error %d", ret);
return ret;
}
/* Check if secure boot digests are present */
bool has_secure_boot_digest = ets_efuse_find_purpose(ETS_EFUSE_KEY_PURPOSE_SECURE_BOOT_DIGEST0, NULL);
has_secure_boot_digest |= ets_efuse_find_purpose(ETS_EFUSE_KEY_PURPOSE_SECURE_BOOT_DIGEST1, NULL);
has_secure_boot_digest |= ets_efuse_find_purpose(ETS_EFUSE_KEY_PURPOSE_SECURE_BOOT_DIGEST2, NULL);
ESP_LOGI(TAG, "Secure boot digests %s", has_secure_boot_digest ? "already present":"absent, generating..");
ets_efuse_clear_program_registers();
if (!has_secure_boot_digest) {
image_sig_public_key_digests_t boot_key_digests = {0};
image_sig_public_key_digests_t app_key_digests = {0};
/* Generate the bootloader public key digests */
ret = s_calculate_image_public_key_digests(bootloader_data.start_addr, bootloader_data.image_len - SIG_BLOCK_PADDING, &boot_key_digests);
if (ret != ESP_OK) {
ESP_LOGE(TAG, "Bootloader signature block is invalid");
return ret;
}
if (boot_key_digests.num_digests == 0) {
ESP_LOGE(TAG, "No valid bootloader signature blocks found.");
return ESP_FAIL;
}
ESP_LOGI(TAG, "%d signature block(s) found appended to the bootloader.", boot_key_digests.num_digests);
int unused_key_slots = ets_efuse_count_unused_key_blocks();
if (boot_key_digests.num_digests > unused_key_slots) {
ESP_LOGE(TAG, "Bootloader signatures(%d) more than available key slots(%d).", boot_key_digests.num_digests, unused_key_slots);
return ESP_FAIL;
}
for (int i = 0; i < boot_key_digests.num_digests; i++) {
ets_efuse_block_t block;
const uint32_t secure_boot_key_purpose[SECURE_BOOT_NUM_BLOCKS] = { ETS_EFUSE_KEY_PURPOSE_SECURE_BOOT_DIGEST0,
ETS_EFUSE_KEY_PURPOSE_SECURE_BOOT_DIGEST1, ETS_EFUSE_KEY_PURPOSE_SECURE_BOOT_DIGEST2 };
block = ets_efuse_find_unused_key_block();
if (block == ETS_EFUSE_BLOCK_MAX) {
ESP_LOGE(TAG, "No more unused key blocks available.");
return ESP_FAIL;
}
int r = ets_efuse_write_key(block, secure_boot_key_purpose[i], boot_key_digests.key_digests[i], DIGEST_LEN);
if (r != 0) {
ESP_LOGE(TAG, "Failed to write efuse block %d with purpose %d. Can't continue.", block, secure_boot_key_purpose[i]);
return ESP_FAIL;
}
// Note: write key will write protect both the block and the purpose eFuse, always
}
/* Generate the application public key digests */
ret = s_calculate_image_public_key_digests(image_data->start_addr, image_data->image_len - SIG_BLOCK_PADDING, &app_key_digests);
if (ret != ESP_OK) {
ESP_LOGE(TAG, "App signature block is invalid.");
return ret;
}
if (app_key_digests.num_digests == 0) {
ESP_LOGE(TAG, "No valid applications signature blocks found.");
return ESP_FAIL;
}
ESP_LOGI(TAG, "%d signature block(s) found appended to the app.", app_key_digests.num_digests);
if (app_key_digests.num_digests > boot_key_digests.num_digests) {
ESP_LOGW(TAG, "App has %d signature blocks but bootloader only has %d. Some keys missing from bootloader?");
}
/* Confirm if at least one public key from the application matches a public key in the bootloader
(Also, ensure if that public revoke bit is not set for the matched key) */
bool match = false;
const uint32_t revoke_bits[SECURE_BOOT_NUM_BLOCKS] = { EFUSE_SECURE_BOOT_KEY_REVOKE0,
EFUSE_SECURE_BOOT_KEY_REVOKE1, EFUSE_SECURE_BOOT_KEY_REVOKE2 };
for (int i = 0; i < boot_key_digests.num_digests; i++) {
if (REG_GET_BIT(EFUSE_RD_REPEAT_DATA1_REG, revoke_bits[i])) {
ESP_LOGI(TAG, "Key block(%d) has been revoked.", i);
continue; // skip if the key block is revoked
}
for (int j = 0; j < app_key_digests.num_digests; j++) {
if (!memcmp(boot_key_digests.key_digests[i], app_key_digests.key_digests[j], DIGEST_LEN)) {
ESP_LOGI(TAG, "Application key(%d) matches with bootloader key(%d).", j, i);
match = true;
}
}
}
if (match == false) {
ESP_LOGE(TAG, "No application key digest matches the bootloader key digest.");
return ESP_FAIL;
}
/* Revoke the empty signature blocks */
if (boot_key_digests.num_digests < SECURE_BOOT_NUM_BLOCKS) {
/* The revocation index can be 0, 1, 2. Bootloader count can be 1,2,3. */
for (uint8_t i = boot_key_digests.num_digests; i < SECURE_BOOT_NUM_BLOCKS; i++) {
ESP_LOGI(TAG, "Revoking empty key digest slot (%d)...", i);
ets_secure_boot_revoke_public_key_digest(i);
}
}
}
esp_err_t err = esp_efuse_batch_write_begin();
if (err != ESP_OK) {
ESP_LOGI(TAG, "Error batch programming security eFuses.");
return err;
}
__attribute__((unused)) static const uint8_t enable = 1;
esp_efuse_write_field_bit(ESP_EFUSE_SECURE_BOOT_EN);
esp_efuse_write_field_bit(ESP_EFUSE_DIS_BOOT_REMAP);
esp_efuse_write_field_bit(ESP_EFUSE_DIS_LEGACY_SPI_BOOT);
// TODO: also disable JTAG here, etc
#ifdef CONFIG_SECURE_ENABLE_SECURE_ROM_DL_MODE
ESP_LOGI(TAG, "Enabling Security download mode...");
esp_efuse_write_field_bit(ESP_EFUSE_ENABLE_SECURITY_DOWNLOAD);
#else
ESP_LOGW(TAG, "Not enabling Security download mode - SECURITY COMPROMISED");
#endif
esp_err_t err = esp_efuse_batch_write_commit();
#ifndef CONFIG_SECURE_BOOT_ALLOW_JTAG
ESP_LOGI(TAG, "Disable hardware & software JTAG...");
esp_efuse_write_field_bit(ESP_EFUSE_HARD_DIS_JTAG);
esp_efuse_write_field_bit(ESP_EFUSE_SOFT_DIS_JTAG);
#else
ESP_LOGW(TAG, "Not disabling JTAG - SECURITY COMPROMISED");
#endif
if (err == ESP_OK) {
assert(ets_efuse_secure_boot_enabled());
ESP_LOGI(TAG, "Secure boot permanently enabled");
#ifdef CONFIG_SECURE_BOOT_ENABLE_AGGRESSIVE_KEY_REVOKE
esp_efuse_write_field_bit(ESP_EFUSE_SECURE_BOOT_AGGRESSIVE_REVOKE);
#endif
esp_efuse_write_field_bit(ESP_EFUSE_SECURE_BOOT_EN);
err = esp_efuse_batch_write_commit();
if (err != ESP_OK) {
ESP_LOGI(TAG, "Error programming security eFuses.");
return err;
}
#ifdef CONFIG_SECURE_BOOT_ENABLE_AGGRESSIVE_KEY_REVOKE
assert(ets_efuse_secure_boot_aggressive_revoke_enabled());
#endif
assert(ets_efuse_secure_boot_enabled());
ESP_LOGI(TAG, "Secure boot permanently enabled");
return ESP_OK;
}

View File

@ -13,29 +13,32 @@
// limitations under the License.
#include "sdkconfig.h"
#include <string.h>
#include "esp_fault.h"
#include "bootloader_flash.h"
#include "bootloader_sha.h"
#include "bootloader_utility.h"
#include "esp_log.h"
#include "esp_image_format.h"
#include "esp_secure_boot.h"
#include "esp32s2/rom/secure_boot.h"
static const char* TAG = "secure_boot";
#define DIGEST_LEN 32
#define ALIGN_UP(num, align) (((num) + ((align) - 1)) & ~((align) - 1))
esp_err_t esp_secure_boot_verify_signature(uint32_t src_addr, uint32_t length)
{
ets_secure_boot_key_digests_t trusted_keys = { 0 };
uint8_t digest[DIGEST_LEN];
uint8_t verified_digest[DIGEST_LEN] = { 0 }; /* Note: this function doesn't do any anti-FI checks on this buffer */
const uint8_t *data;
ESP_LOGD(TAG, "verifying signature src_addr 0x%x length 0x%x", src_addr, length);
if ((src_addr + length) % 4096 != 0) {
ESP_LOGE(TAG, "addr 0x%x length 0x%x doesn't end on a sector boundary", src_addr, length);
return ESP_ERR_INVALID_ARG;
}
/* Padding to round off the input to the nearest 4k boundary */
int padded_length = ALIGN_UP(length, FLASH_SECTOR_SIZE);
ESP_LOGD(TAG, "verifying src_addr 0x%x length", src_addr, padded_length);
data = bootloader_mmap(src_addr, length + sizeof(struct ets_secure_boot_sig_block));
if (data == NULL) {
@ -43,23 +46,16 @@ esp_err_t esp_secure_boot_verify_signature(uint32_t src_addr, uint32_t length)
return ESP_FAIL;
}
// Calculate digest of main image
#ifdef BOOTLOADER_BUILD
bootloader_sha256_handle_t handle = bootloader_sha256_start();
bootloader_sha256_data(handle, data, length);
bootloader_sha256_finish(handle, digest);
#else
/* Use thread-safe esp-idf SHA function */
esp_sha(SHA2_256, data, length, digest);
#endif
int r = ets_secure_boot_read_key_digests(&trusted_keys);
if (r == ETS_OK) {
const ets_secure_boot_signature_t *sig = (const ets_secure_boot_signature_t *)(data + length);
// TODO: calling this function in IDF app context is unsafe
r = ets_secure_boot_verify_signature(sig, digest, &trusted_keys, verified_digest);
/* Calculate digest of main image */
esp_err_t err = bootloader_sha256_flash_contents(src_addr, padded_length, digest);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Digest calculation failed 0x%x, 0x%x", src_addr, padded_length);
bootloader_munmap(data);
return err;
}
const ets_secure_boot_signature_t *sig = (const ets_secure_boot_signature_t *)(data + length);
int r = esp_secure_boot_verify_rsa_signature_block(sig, digest, verified_digest);
bootloader_munmap(data);
return (r == ETS_OK) ? ESP_OK : ESP_FAIL;
@ -68,15 +64,30 @@ esp_err_t esp_secure_boot_verify_signature(uint32_t src_addr, uint32_t length)
esp_err_t esp_secure_boot_verify_rsa_signature_block(const ets_secure_boot_signature_t *sig_block, const uint8_t *image_digest, uint8_t *verified_digest)
{
ets_secure_boot_key_digests_t trusted_keys;
ets_secure_boot_key_digests_t trusted_key_copies[2];
ETS_STATUS r;
ets_secure_boot_status_t sb_result;
int r = ets_secure_boot_read_key_digests(&trusted_keys);
if (r != 0) {
ESP_LOGE(TAG, "No trusted key digests were found in efuse!");
} else {
ESP_LOGD(TAG, "Verifying with RSA-PSS...");
// TODO: calling this function in IDF app context is unsafe
r = ets_secure_boot_verify_signature(sig_block, image_digest, &trusted_keys, verified_digest);
memset(&trusted_keys, 0, sizeof(ets_secure_boot_key_digests_t));
memset(trusted_key_copies, 0, 2 * sizeof(ets_secure_boot_key_digests_t));
if (!esp_secure_boot_enabled()) {
return ESP_OK;
}
return (r == 0) ? ESP_OK : ESP_ERR_IMAGE_INVALID;
r = ets_secure_boot_read_key_digests(&trusted_keys);
if (r != ETS_OK) {
ESP_LOGI(TAG, "Could not read secure boot digests!");
return ESP_FAIL;
}
// Create the copies for FI checks (assuming result is ETS_OK, if it's not then it'll fail the fault check anyhow)
ets_secure_boot_read_key_digests(&trusted_key_copies[0]);
ets_secure_boot_read_key_digests(&trusted_key_copies[1]);
ESP_FAULT_ASSERT(memcmp(&trusted_keys, &trusted_key_copies[0], sizeof(ets_secure_boot_key_digests_t)) == 0);
ESP_FAULT_ASSERT(memcmp(&trusted_keys, &trusted_key_copies[1], sizeof(ets_secure_boot_key_digests_t)) == 0);
ESP_LOGI(TAG, "Verifying with RSA-PSS boot...");
sb_result = ets_secure_boot_verify_signature(sig_block, image_digest, &trusted_keys, verified_digest);
return (sb_result == SB_SUCCESS) ? ESP_OK : ESP_FAIL;
}

View File

@ -220,8 +220,18 @@ static esp_err_t image_load(esp_image_load_mode_t mode, const esp_partition_pos_
#ifdef SECURE_BOOT_CHECK_SIGNATURE
// secure boot images have a signature appended
err = verify_secure_boot_signature(sha_handle, data, image_digest, verified_digest);
#else
#if defined(BOOTLOADER_BUILD) && !defined(CONFIG_SECURE_BOOT)
// If secure boot is not enabled in hardware, then
// skip the signature check in bootloader when the debugger is attached.
// This is done to allow for breakpoints in Flash.
if (!esp_cpu_in_ocd_debug_mode()) {
#else // CONFIG_SECURE_BOOT
if (true) {
#endif // end checking for JTAG
err = verify_secure_boot_signature(sha_handle, data, image_digest, verified_digest);
sha_handle = NULL; // verify_secure_boot_signature finishes sha_handle
}
#else // SECURE_BOOT_CHECK_SIGNATURE
// No secure boot, but SHA-256 can be appended for basic corruption detection
if (sha_handle != NULL && !esp_cpu_in_ocd_debug_mode()) {
err = verify_simple_hash(sha_handle, data);
@ -266,7 +276,7 @@ static esp_err_t image_load(esp_image_load_mode_t mode, const esp_partition_pos_
"only verify signature in bootloader" into the macro so it's tested multiple times.
*/
#if CONFIG_SECURE_BOOT_V2_ENABLED
ESP_FAULT_ASSERT(memcmp(image_digest, verified_digest, HASH_LEN) == 0);
ESP_FAULT_ASSERT(!esp_secure_boot_enabled() || memcmp(image_digest, verified_digest, HASH_LEN) == 0);
#else // Secure Boot V1 on ESP32, only verify signatures for apps not bootloaders
ESP_FAULT_ASSERT(data->start_addr == ESP_BOOTLOADER_OFFSET || memcmp(image_digest, verified_digest, HASH_LEN) == 0);
#endif
@ -301,7 +311,7 @@ err:
// Prevent invalid/incomplete data leaking out
bzero(data, sizeof(esp_image_metadata_t));
return err;
}
}
esp_err_t bootloader_load_image(const esp_partition_pos_t *part, esp_image_metadata_t *data)
{
@ -841,3 +851,21 @@ static esp_err_t verify_simple_hash(bootloader_sha256_handle_t sha_handle, esp_i
bootloader_munmap(hash);
return ESP_OK;
}
int esp_image_get_flash_size(esp_image_flash_size_t app_flash_size)
{
switch (app_flash_size) {
case ESP_IMAGE_FLASH_SIZE_1MB:
return 1 * 1024 * 1024;
case ESP_IMAGE_FLASH_SIZE_2MB:
return 2 * 1024 * 1024;
case ESP_IMAGE_FLASH_SIZE_4MB:
return 4 * 1024 * 1024;
case ESP_IMAGE_FLASH_SIZE_8MB:
return 8 * 1024 * 1024;
case ESP_IMAGE_FLASH_SIZE_16MB:
return 16 * 1024 * 1024;
default:
return 0;
}
}

View File

@ -50,7 +50,7 @@ void esp_flash_encryption_init_checks()
// (this distinction is important on ESP32 ECO3 where write-procted FLASH_CRYPT_CNT also write-protects UART_DL_DIS)
return;
}
ESP_EARLY_LOGE(TAG, "Flash encryption & Secure Boot together requires FLASH_CRYPT_CNT efuse to be write protected. Fixing now...");
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();
}
}
@ -62,13 +62,13 @@ void esp_flash_encryption_init_checks()
mode = esp_get_flash_encryption_mode();
if (mode == ESP_FLASH_ENC_MODE_DEVELOPMENT) {
#ifdef CONFIG_SECURE_FLASH_ENCRYPTION_MODE_RELEASE
ESP_EARLY_LOGE(TAG, "Flash encryption settings error: app is configured for RELEASE but efuses are set for DEVELOPMENT");
ESP_EARLY_LOGE(TAG, "Mismatch found in security options in bootloader menuconfig and efuse settings. Device is not secure.");
ESP_LOGE(TAG, "Flash encryption settings error: app is configured for RELEASE but efuses are set for DEVELOPMENT");
ESP_LOGE(TAG, "Mismatch found in security options in bootloader menuconfig and efuse settings. Device is not secure.");
#else
ESP_EARLY_LOGW(TAG, "Flash encryption mode is DEVELOPMENT (not secure)");
ESP_LOGW(TAG, "Flash encryption mode is DEVELOPMENT (not secure)");
#endif
} else if (mode == ESP_FLASH_ENC_MODE_RELEASE) {
ESP_EARLY_LOGI(TAG, "Flash encryption mode is RELEASE");
ESP_LOGI(TAG, "Flash encryption mode is RELEASE");
}
}
#endif
@ -80,7 +80,7 @@ void esp_flash_write_protect_crypt_cnt(void)
esp_flash_enc_mode_t esp_get_flash_encryption_mode(void)
{
uint8_t efuse_flash_crypt_cnt_wr_protected = 0;
bool flash_crypt_cnt_wr_dis = false;
#if CONFIG_IDF_TARGET_ESP32
uint8_t dis_dl_enc = 0, dis_dl_dec = 0, dis_dl_cache = 0;
#elif CONFIG_IDF_TARGET_ESP32S2
@ -94,9 +94,17 @@ esp_flash_enc_mode_t esp_get_flash_encryption_mode(void)
if (esp_flash_encryption_enabled()) {
/* Check if FLASH CRYPT CNT is write protected */
efuse_flash_crypt_cnt_wr_protected = esp_efuse_read_field_bit(WR_DIS_CRYPT_CNT);
if (efuse_flash_crypt_cnt_wr_protected) {
flash_crypt_cnt_wr_dis = esp_efuse_read_field_bit(WR_DIS_CRYPT_CNT);
if (!flash_crypt_cnt_wr_dis) {
uint8_t flash_crypt_cnt = 0;
esp_efuse_read_field_blob(CRYPT_CNT, &flash_crypt_cnt, CRYPT_CNT[0]->bit_count);
if (flash_crypt_cnt == (1 << (CRYPT_CNT[0]->bit_count)) - 1) {
flash_crypt_cnt_wr_dis = true;
}
}
if (flash_crypt_cnt_wr_dis) {
#if CONFIG_IDF_TARGET_ESP32
dis_dl_cache = esp_efuse_read_field_bit(ESP_EFUSE_DISABLE_DL_CACHE);

View File

@ -13,6 +13,7 @@
// limitations under the License.
#include <stddef.h>
#include <stdint.h>
#include "bootloader_flash_config.h"
#include "flash_qio_mode.h"
#include "esp_log.h"
#include "esp_err.h"
@ -84,12 +85,6 @@ static unsigned read_status_8b_xmc25qu64a(void);
/* Write 8 bit status of XM25QU64A */
static void write_status_8b_xmc25qu64a(unsigned new_status);
#define ESP32_D2WD_WP_GPIO 7 /* ESP32-D2WD has this GPIO wired to WP pin of flash */
#ifndef CONFIG_BOOTLOADER_SPI_WP_PIN // Set in menuconfig if SPI flasher config is set to a quad mode
#define CONFIG_BOOTLOADER_SPI_WP_PIN ESP32_D2WD_WP_GPIO
#endif
/* Array of known flash chips and data to enable Quad I/O mode
Manufacturer & flash ID can be tested by running "esptool.py
@ -224,24 +219,6 @@ static esp_err_t enable_qio_mode(read_status_fn_t read_status_fn,
uint32_t status;
const uint32_t spiconfig = ets_efuse_get_spiconfig();
#if CONFIG_IDF_TARGET_ESP32
if (spiconfig != EFUSE_SPICONFIG_SPI_DEFAULTS && spiconfig != EFUSE_SPICONFIG_HSPI_DEFAULTS) {
// spiconfig specifies a custom efuse pin configuration. This config defines all pins -except- WP,
// which is compiled into the bootloader instead.
//
// Most commonly an overriden pin mapping means ESP32-D2WD or ESP32-PICOD4.
//Warn if chip is ESP32-D2WD/ESP32-PICOD4 but someone has changed the WP pin
//assignment from that chip's WP pin.
uint32_t pkg_ver = REG_GET_FIELD(EFUSE_BLK0_RDATA3_REG, EFUSE_RD_CHIP_VER_PKG);
if (CONFIG_BOOTLOADER_SPI_WP_PIN != ESP32_D2WD_WP_GPIO &&
(pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32D2WDQ5 ||
pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD2 ||
pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD4)) {
ESP_LOGW(TAG, "Chip is ESP32-D2WD/ESP32-PICOD4 but flash WP pin is different value to internal flash");
}
}
#endif
esp_rom_spiflash_wait_idle(&g_rom_flashchip);
status = read_status_fn();
@ -276,13 +253,10 @@ static esp_err_t enable_qio_mode(read_status_fn_t read_status_fn,
esp_rom_spiflash_config_readmode(mode);
#if CONFIG_IDF_TARGET_ESP32
esp_rom_spiflash_select_qio_pins(CONFIG_BOOTLOADER_SPI_WP_PIN, spiconfig);
int wp_pin = bootloader_flash_get_wp_pin();
esp_rom_spiflash_select_qio_pins(wp_pin, spiconfig);
#elif CONFIG_IDF_TARGET_ESP32S2
if (ets_efuse_get_wp_pad() <= MAX_PAD_GPIO_NUM) {
esp_rom_spiflash_select_qio_pins(ets_efuse_get_wp_pad(), spiconfig);
} else {
esp_rom_spiflash_select_qio_pins(CONFIG_BOOTLOADER_SPI_WP_PIN, spiconfig);
}
esp_rom_spiflash_select_qio_pins(ets_efuse_get_wp_pad(), spiconfig);
#endif
return ESP_OK;
}

View File

@ -51,4 +51,5 @@ void bootloader_sha256_finish(bootloader_sha256_handle_t handle, uint8_t *digest
}
mbedtls_sha256_free(ctx);
free(handle);
handle = NULL;
}

View File

@ -27,6 +27,11 @@
#include "mbedtls/ctr_drbg.h"
#include <string.h>
#include <sys/param.h>
#include "esp_secure_boot.h"
#ifdef CONFIG_IDF_TARGET_ESP32S2
#include <esp32s2/rom/secure_boot.h>
#endif
#define DIGEST_LEN 32
@ -142,6 +147,26 @@ static const char *TAG = "secure_boot_v2";
#define ALIGN_UP(num, align) (((num) + ((align) - 1)) & ~((align) - 1))
#define RSA_KEY_SIZE 384 /* RSA 3072 Bits */
#if CONFIG_IDF_TARGET_ESP32S2
inline static bool digest_matches(const void *trusted, const void *computed)
{
if (trusted == NULL) {
return false;
}
// 'trusted' is probably a pointer to read-only efuse registers,
// which only support word reads. memcmp() cannot be guaranteed
// to do word reads, so we make a local copy here (we know that
// memcpy() will do word operations if it can).
uint8_t __attribute__((aligned(4))) trusted_local[ETS_DIGEST_LEN];
uint8_t __attribute__((aligned(4))) computed_local[ETS_DIGEST_LEN];
memcpy(trusted_local, trusted, ETS_DIGEST_LEN);
memcpy(computed_local, computed, ETS_DIGEST_LEN);
return memcmp(trusted_local, computed_local, ETS_DIGEST_LEN) == 0;
}
#endif /* CONFIG_IDF_TARGET_ESP32S2 */
esp_err_t esp_secure_boot_verify_signature(uint32_t src_addr, uint32_t length)
{
uint8_t digest[DIGEST_LEN] = {0};
@ -173,23 +198,27 @@ esp_err_t esp_secure_boot_verify_signature(uint32_t src_addr, uint32_t length)
esp_err_t esp_secure_boot_verify_rsa_signature_block(const ets_secure_boot_signature_t *sig_block, const uint8_t *image_digest, uint8_t *verified_digest)
{
int i = 0;
uint8_t i = 0;
#if CONFIG_SECURE_BOOT_V2_ENABLED /* Verify key against efuse block */
uint8_t efuse_trusted_digest[DIGEST_LEN] = {0}, sig_block_trusted_digest[DIGEST_LEN] = {0};
memcpy(efuse_trusted_digest, (uint8_t *) EFUSE_BLK2_RDATA0_REG, sizeof(efuse_trusted_digest));
uint8_t sig_block_key_digest[SECURE_BOOT_NUM_BLOCKS][DIGEST_LEN] = {0};
/* Note: in IDF verification we don't add any fault injection resistance, as we don't expect this to be called
during boot-time verification. */
memset(verified_digest, 0, DIGEST_LEN);
/* Generating the SHA of the public key components in the signature block */
bootloader_sha256_handle_t sig_block_sha;
sig_block_sha = bootloader_sha256_start();
bootloader_sha256_data(sig_block_sha, &sig_block->block[0].key, sizeof(sig_block->block[0].key));
bootloader_sha256_finish(sig_block_sha, (unsigned char *)sig_block_trusted_digest);
for (i = 0; i < SECURE_BOOT_NUM_BLOCKS; i++) {
bootloader_sha256_handle_t sig_block_sha;
sig_block_sha = bootloader_sha256_start();
bootloader_sha256_data(sig_block_sha, &sig_block->block[i].key, sizeof(sig_block->block[i].key));
bootloader_sha256_finish(sig_block_sha, (unsigned char *)sig_block_key_digest[i]);
}
if (memcmp(efuse_trusted_digest, sig_block_trusted_digest, DIGEST_LEN) != 0) {
#if CONFIG_IDF_TARGET_ESP32
uint8_t efuse_trusted_digest[DIGEST_LEN] = {0};
memcpy(efuse_trusted_digest, (uint8_t *) EFUSE_BLK2_RDATA0_REG, sizeof(efuse_trusted_digest));
if (memcmp(efuse_trusted_digest, sig_block_key_digest[0], DIGEST_LEN) != 0) {
const uint8_t zeroes[DIGEST_LEN] = {0};
/* Can't continue if secure boot is enabled, OR if a different digest is already written in efuse BLK2
@ -200,7 +229,17 @@ esp_err_t esp_secure_boot_verify_rsa_signature_block(const ets_secure_boot_signa
return ESP_FAIL;
}
}
#endif
#elif CONFIG_IDF_TARGET_ESP32S2
bool match = false;
ets_secure_boot_key_digests_t efuse_trusted_digest;
ETS_STATUS r;
r = ets_secure_boot_read_key_digests(&efuse_trusted_digest);
if (r != 0) {
ESP_LOGI(TAG, "Could not read secure boot digests!");
return ESP_FAIL;
}
#endif /* CONFIG_IDF_TARGET_ESP32 */
#endif /* CONFIG_SECURE_BOOT_V2_ENABLED */
ESP_LOGI(TAG, "Verifying with RSA-PSS...");
int ret = 0;
@ -222,6 +261,19 @@ esp_err_t esp_secure_boot_verify_rsa_signature_block(const ets_secure_boot_signa
}
for (i = 0; i < SECURE_BOOT_NUM_BLOCKS; i++) {
#if CONFIG_IDF_TARGET_ESP32S2
for (uint8_t j = 0; j < SECURE_BOOT_NUM_BLOCKS; j++) {
if (digest_matches(efuse_trusted_digest.key_digests[j], sig_block_key_digest[i])) {
ESP_LOGI(TAG, "eFuse key matches(%d) matches the application key(%d).", j, i);
match = true;
break;
}
}
if (match == false) {
continue; // Skip the public keys whose digests don't match.
}
# endif
const mbedtls_mpi N = { .s = 1,
.n = sizeof(sig_block->block[i].key.n)/sizeof(mbedtls_mpi_uint),
.p = (void *)sig_block->block[i].key.n,
@ -260,8 +312,8 @@ esp_err_t esp_secure_boot_verify_rsa_signature_block(const ets_secure_boot_signa
goto exit;
}
ret = mbedtls_rsa_rsassa_pss_verify( &pk, mbedtls_ctr_drbg_random, &ctr_drbg, MBEDTLS_RSA_PUBLIC, MBEDTLS_MD_SHA256, 32,
sig_block->block[i].image_digest, sig_be);
ret = mbedtls_rsa_rsassa_pss_verify( &pk, mbedtls_ctr_drbg_random, &ctr_drbg, MBEDTLS_RSA_PUBLIC, MBEDTLS_MD_SHA256, DIGEST_LEN,
image_digest, sig_be);
if (ret != 0) {
ESP_LOGE(TAG, "Failed mbedtls_rsa_rsassa_pss_verify, err: %d", ret);
} else {
@ -276,6 +328,10 @@ esp_err_t esp_secure_boot_verify_rsa_signature_block(const ets_secure_boot_signa
free(sig_be);
free(buf);
return (!ret) ? ESP_OK : ESP_ERR_IMAGE_INVALID;
#if CONFIG_IDF_TARGET_ESP32
return (ret != 0) ? ESP_ERR_IMAGE_INVALID: ESP_OK;
#elif CONFIG_IDF_TARGET_ESP32S2
return (ret != 0 || match == false) ? ESP_ERR_IMAGE_INVALID: ESP_OK;
#endif /* CONFIG_IDF_TARGET_ESP32 */
}
#endif

View File

@ -96,6 +96,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"
@ -315,6 +316,7 @@ if(CONFIG_BT_ENABLED)
if(CONFIG_BLE_MESH)
list(APPEND include_dirs
"esp_ble_mesh/mesh_common/include"
"esp_ble_mesh/mesh_common/tinycrypt/include"
"esp_ble_mesh/mesh_core"
"esp_ble_mesh/mesh_core/include"
"esp_ble_mesh/mesh_core/storage"
@ -339,6 +341,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"
@ -346,7 +349,21 @@ if(CONFIG_BT_ENABLED)
"esp_ble_mesh/btc/btc_ble_mesh_prov.c"
"esp_ble_mesh/btc/btc_ble_mesh_sensor_model.c"
"esp_ble_mesh/btc/btc_ble_mesh_time_scene_model.c"
"esp_ble_mesh/mesh_common/mesh_aes_encrypt.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/aes_decrypt.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/aes_encrypt.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/cbc_mode.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/ccm_mode.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/cmac_mode.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/ctr_mode.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/ctr_prng.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/ecc_dh.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/ecc_dsa.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/ecc_platform_specific.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/ecc.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/hmac_prng.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/hmac.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/sha256.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/utils.c"
"esp_ble_mesh/mesh_common/mesh_atomic.c"
"esp_ble_mesh/mesh_common/mesh_buf.c"
"esp_ble_mesh/mesh_common/mesh_common.c"
@ -361,9 +378,11 @@ if(CONFIG_BT_ENABLED)
"esp_ble_mesh/mesh_core/cfg_cli.c"
"esp_ble_mesh/mesh_core/cfg_srv.c"
"esp_ble_mesh/mesh_core/crypto.c"
"esp_ble_mesh/mesh_core/fast_prov.c"
"esp_ble_mesh/mesh_core/friend.c"
"esp_ble_mesh/mesh_core/health_cli.c"
"esp_ble_mesh/mesh_core/health_srv.c"
"esp_ble_mesh/mesh_core/local_operation.c"
"esp_ble_mesh/mesh_core/lpn.c"
"esp_ble_mesh/mesh_core/main.c"
"esp_ble_mesh/mesh_core/net.c"
@ -372,15 +391,17 @@ if(CONFIG_BT_ENABLED)
"esp_ble_mesh/mesh_core/provisioner_prov.c"
"esp_ble_mesh/mesh_core/proxy_client.c"
"esp_ble_mesh/mesh_core/proxy_server.c"
"esp_ble_mesh/mesh_core/settings_uid.c"
"esp_ble_mesh/mesh_core/settings.c"
"esp_ble_mesh/mesh_core/scan.c"
"esp_ble_mesh/mesh_core/test.c"
"esp_ble_mesh/mesh_core/transport.c"
"esp_ble_mesh/mesh_models/common/device_property.c"
"esp_ble_mesh/mesh_models/client/client_common.c"
"esp_ble_mesh/mesh_models/client/generic_client.c"
"esp_ble_mesh/mesh_models/client/lighting_client.c"
"esp_ble_mesh/mesh_models/client/sensor_client.c"
"esp_ble_mesh/mesh_models/client/time_scene_client.c"
"esp_ble_mesh/mesh_models/server/device_property.c"
"esp_ble_mesh/mesh_models/server/generic_server.c"
"esp_ble_mesh/mesh_models/server/lighting_server.c"
"esp_ble_mesh/mesh_models/server/sensor_server.c"

View File

@ -79,6 +79,47 @@ menu "Bluetooth"
default 1 if BTDM_CTRL_BR_EDR_SCO_DATA_PATH_PCM
default 0
menuconfig BTDM_CTRL_PCM_ROLE_EDGE_CONFIG
bool "PCM Signal Config (Role and Polar)"
depends on BTDM_CTRL_BR_EDR_SCO_DATA_PATH_PCM
default y
choice BTDM_CTRL_PCM_ROLE
prompt "PCM Role"
depends on BTDM_CTRL_PCM_ROLE_EDGE_CONFIG
help
PCM role can be configured as PCM master or PCM slave
config BTDM_CTRL_PCM_ROLE_MASTER
bool "PCM Master"
config BTDM_CTRL_PCM_ROLE_SLAVE
bool "PCM Slave"
endchoice
choice BTDM_CTRL_PCM_POLAR
prompt "PCM Polar"
depends on BTDM_CTRL_PCM_ROLE_EDGE_CONFIG
help
PCM polarity can be configured as Falling Edge or Rising Edge
config BTDM_CTRL_PCM_POLAR_FALLING_EDGE
bool "Falling Edge"
config BTDM_CTRL_PCM_POLAR_RISING_EDGE
bool "Rising Edge"
endchoice
config BTDM_CTRL_PCM_ROLE_EFF
int
default 0 if BTDM_CTRL_PCM_ROLE_MASTER
default 1 if BTDM_CTRL_PCM_ROLE_SLAVE
default 0
config BTDM_CTRL_PCM_POLAR_EFF
int
default 0 if BTDM_CTRL_PCM_POLAR_FALLING_EDGE
default 1 if BTDM_CTRL_PCM_POLAR_RISING_EDGE
default 0
config BTDM_CTRL_AUTO_LATENCY
bool "Auto latency"
depends on BTDM_CTRL_MODE_BTDM
@ -92,6 +133,19 @@ menu "Bluetooth"
default BTDM_CTRL_AUTO_LATENCY if BTDM_CTRL_MODE_BTDM
default n
config BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT
bool "Legacy Authentication Vendor Specific Event Enable"
depends on BTDM_CTRL_MODE_BR_EDR_ONLY || BTDM_CTRL_MODE_BTDM
default y
help
To protect from BIAS attack during Legacy authentication,
Legacy authentication Vendor specific event should be enabled
config BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT_EFF
bool
default BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT if BTDM_CTRL_MODE_BR_EDR_ONLY || BTDM_CTRL_MODE_BTDM
default 0
config BTDM_CTRL_BLE_MAX_CONN_EFF
int

View File

@ -57,6 +57,7 @@
#endif
#if CONFIG_BLE_MESH
#include "btc_ble_mesh_ble.h"
#include "btc_ble_mesh_prov.h"
#include "btc_ble_mesh_health_model.h"
#include "btc_ble_mesh_config_model.h"
@ -68,7 +69,7 @@
#define BTC_TASK_PINNED_TO_CORE (TASK_PINNED_TO_CORE)
#define BTC_TASK_STACK_SIZE (BT_BTC_TASK_STACK_SIZE + BT_TASK_EXTRA_STACK_SIZE) //by menuconfig
#define BTC_TASK_NAME "btcT"
#define BTC_TASK_NAME "BTC_TASK"
#define BTC_TASK_PRIO (BT_TASK_MAX_PRIORITIES - 6)
osi_thread_t *btc_thread;
@ -93,9 +94,9 @@ static const btc_func_t profile_tab[BTC_PID_NUM] = {
#endif ///BLE_INCLUDED == TRUE
[BTC_PID_BLE_HID] = {NULL, NULL},
[BTC_PID_SPPLIKE] = {NULL, NULL},
#if (GATTS_INCLUDED == TRUE)
#if (BLUFI_INCLUDED == TRUE)
[BTC_PID_BLUFI] = {btc_blufi_call_handler, btc_blufi_cb_handler },
#endif ///GATTS_INCLUDED == TRUE
#endif ///BLUFI_INCLUDED == TRUE
[BTC_PID_DM_SEC] = {NULL, btc_dm_sec_cb_handler },
#endif
[BTC_PID_ALARM] = {btc_alarm_handler, NULL },
@ -124,18 +125,43 @@ static const btc_func_t profile_tab[BTC_PID_NUM] = {
#if CONFIG_BLE_MESH
[BTC_PID_PROV] = {btc_ble_mesh_prov_call_handler, btc_ble_mesh_prov_cb_handler },
[BTC_PID_MODEL] = {btc_ble_mesh_model_call_handler, btc_ble_mesh_model_cb_handler },
#if CONFIG_BLE_MESH_HEALTH_CLI
[BTC_PID_HEALTH_CLIENT] = {btc_ble_mesh_health_client_call_handler, btc_ble_mesh_health_client_cb_handler },
#endif /* CONFIG_BLE_MESH_HEALTH_CLI */
#if CONFIG_BLE_MESH_HEALTH_SRV
[BTC_PID_HEALTH_SERVER] = {btc_ble_mesh_health_server_call_handler, btc_ble_mesh_health_server_cb_handler },
#endif /* CONFIG_BLE_MESH_HEALTH_SRV */
#if CONFIG_BLE_MESH_CFG_CLI
[BTC_PID_CONFIG_CLIENT] = {btc_ble_mesh_config_client_call_handler, btc_ble_mesh_config_client_cb_handler },
#endif /* CONFIG_BLE_MESH_CFG_CLI */
[BTC_PID_CONFIG_SERVER] = {NULL, btc_ble_mesh_config_server_cb_handler },
#if CONFIG_BLE_MESH_GENERIC_CLIENT
[BTC_PID_GENERIC_CLIENT] = {btc_ble_mesh_generic_client_call_handler, btc_ble_mesh_generic_client_cb_handler },
#endif /* CONFIG_BLE_MESH_GENERIC_CLIENT */
#if CONFIG_BLE_MESH_LIGHTING_CLIENT
[BTC_PID_LIGHTING_CLIENT] = {btc_ble_mesh_lighting_client_call_handler, btc_ble_mesh_lighting_client_cb_handler },
#endif /* CONFIG_BLE_MESH_LIGHTING_CLIENT */
#if CONFIG_BLE_MESH_SENSOR_CLI
[BTC_PID_SENSOR_CLIENT] = {btc_ble_mesh_sensor_client_call_handler, btc_ble_mesh_sensor_client_cb_handler },
#endif /* CONFIG_BLE_MESH_SENSOR_CLI */
#if CONFIG_BLE_MESH_TIME_SCENE_CLIENT
[BTC_PID_TIME_SCENE_CLIENT] = {btc_ble_mesh_time_scene_client_call_handler, btc_ble_mesh_time_scene_client_cb_handler},
#endif /* CONFIG_BLE_MESH_TIME_SCENE_CLIENT */
#if CONFIG_BLE_MESH_GENERIC_SERVER
[BTC_PID_GENERIC_SERVER] = {NULL, btc_ble_mesh_generic_server_cb_handler },
#endif /* CONFIG_BLE_MESH_GENERIC_SERVER */
#if CONFIG_BLE_MESH_LIGHTING_SERVER
[BTC_PID_LIGHTING_SERVER] = {NULL, btc_ble_mesh_lighting_server_cb_handler },
#endif /* CONFIG_BLE_MESH_LIGHTING_SERVER */
#if CONFIG_BLE_MESH_SENSOR_SERVER
[BTC_PID_SENSOR_SERVER] = {NULL, btc_ble_mesh_sensor_server_cb_handler },
#endif /* CONFIG_BLE_MESH_SENSOR_SERVER */
#if CONFIG_BLE_MESH_TIME_SCENE_SERVER
[BTC_PID_TIME_SCENE_SERVER] = {NULL, btc_ble_mesh_time_scene_server_cb_handler},
#endif /* CONFIG_BLE_MESH_TIME_SCENE_SERVER */
#if CONFIG_BLE_MESH_BLE_COEX_SUPPORT
[BTC_PID_BLE_MESH_BLE_COEX] = {btc_ble_mesh_ble_call_handler, btc_ble_mesh_ble_cb_handler },
#endif /* CONFIG_BLE_MESH_BLE_COEX_SUPPORT */
#endif /* #if CONFIG_BLE_MESH */
};
@ -185,6 +211,15 @@ static bt_status_t btc_task_post(btc_msg_t *msg, uint32_t timeout)
return BT_STATUS_SUCCESS;
}
/**
* transfer an message to another module in the different task.
* @param msg message
* @param arg paramter
* @param arg_len length of paramter
* @param copy_func deep copy function
* @return BT_STATUS_SUCCESS: success
* others: fail
*/
bt_status_t btc_transfer_context(btc_msg_t *msg, void *arg, int arg_len, btc_arg_deep_copy_t copy_func)
{
btc_msg_t lmsg;
@ -214,6 +249,34 @@ bt_status_t btc_transfer_context(btc_msg_t *msg, void *arg, int arg_len, btc_arg
}
/**
* transfer an message to another module in tha same task.
* @param msg message
* @param arg paramter
* @return BT_STATUS_SUCCESS: success
* others: fail
*/
bt_status_t btc_inter_profile_call(btc_msg_t *msg, void *arg)
{
if (msg == NULL) {
return BT_STATUS_PARM_INVALID;
}
msg->arg = arg;
switch (msg->sig) {
case BTC_SIG_API_CALL:
profile_tab[msg->pid].btc_call(msg);
break;
case BTC_SIG_API_CB:
profile_tab[msg->pid].btc_cb(msg);
break;
default:
break;
}
return BT_STATUS_SUCCESS;
}
#if BTC_DYNAMIC_MEMORY
static void btc_deinit_mem(void) {
@ -244,12 +307,13 @@ static void btc_deinit_mem(void) {
osi_free(btc_creat_tab_env_ptr);
btc_creat_tab_env_ptr = NULL;
}
#if (BLUFI_INCLUDED == TRUE)
if (blufi_env_ptr) {
osi_free(blufi_env_ptr);
blufi_env_ptr = NULL;
}
#endif
#endif
#if BTC_HF_CLIENT_INCLUDED == TRUE && HFP_DYNAMIC_MEMORY == TRUE
if (hf_client_local_param_ptr) {
@ -298,12 +362,13 @@ static bt_status_t btc_init_mem(void) {
goto error_exit;
}
memset((void *)btc_creat_tab_env_ptr, 0, sizeof(esp_btc_creat_tab_t));
#if (BLUFI_INCLUDED == TRUE)
if ((blufi_env_ptr = (tBLUFI_ENV *)osi_malloc(sizeof(tBLUFI_ENV))) == NULL) {
goto error_exit;
}
memset((void *)blufi_env_ptr, 0, sizeof(tBLUFI_ENV));
#endif
#endif
#if BTC_HF_CLIENT_INCLUDED == TRUE && HFP_DYNAMIC_MEMORY == TRUE
if ((hf_client_local_param_ptr = (hf_client_local_param_t *)osi_malloc(sizeof(hf_client_local_param_t))) == NULL) {
@ -331,9 +396,9 @@ error_exit:;
}
#endif ///BTC_DYNAMIC_MEMORY
int btc_init(void)
bt_status_t btc_init(void)
{
btc_thread = osi_thread_create("BTC_TASK", BTC_TASK_STACK_SIZE, BTC_TASK_PRIO, BTC_TASK_PINNED_TO_CORE, 2);
btc_thread = osi_thread_create(BTC_TASK_NAME, BTC_TASK_STACK_SIZE, BTC_TASK_PRIO, BTC_TASK_PINNED_TO_CORE, 2);
if (btc_thread == NULL) {
return BT_STATUS_NOMEM;
}
@ -378,3 +443,8 @@ bool btc_check_queue_is_congest(void)
return false;
}
int get_btc_work_queue_size(void)
{
return osi_thread_queue_wait_size(btc_thread, 0);
}

View File

@ -53,7 +53,9 @@ typedef enum {
BTC_PID_GAP_BLE,
BTC_PID_BLE_HID,
BTC_PID_SPPLIKE,
#if (BLUFI_INCLUDED == TRUE)
BTC_PID_BLUFI,
#endif ///BLUFI_INCLUDED == TRUE
BTC_PID_DM_SEC,
BTC_PID_ALARM,
#if (CLASSIC_BT_INCLUDED == TRUE)
@ -85,6 +87,7 @@ typedef enum {
BTC_PID_LIGHTING_SERVER,
BTC_PID_SENSOR_SERVER,
BTC_PID_TIME_SCENE_SERVER,
BTC_PID_BLE_MESH_BLE_COEX,
#endif /* CONFIG_BLE_MESH */
BTC_PID_NUM,
} btc_pid_t; //btc profile id
@ -96,10 +99,29 @@ typedef struct {
typedef void (* btc_arg_deep_copy_t)(btc_msg_t *msg, void *dst, void *src);
/**
* transfer an message to another module in the different task.
* @param msg message
* @param arg paramter
* @param arg_len length of paramter
* @param copy_func deep copy function
* @return BT_STATUS_SUCCESS: success
* others: fail
*/
bt_status_t btc_transfer_context(btc_msg_t *msg, void *arg, int arg_len, btc_arg_deep_copy_t copy_func);
int btc_init(void);
/**
* transfer an message to another module in tha same task.
* @param msg message
* @param arg paramter
* @return BT_STATUS_SUCCESS: success
* others: fail
*/
bt_status_t btc_inter_profile_call(btc_msg_t *msg, void *arg);
bt_status_t btc_init(void);
void btc_deinit(void);
bool btc_check_queue_is_congest(void);
int get_btc_work_queue_size(void);
#endif /* __BTC_TASK_H__ */

View File

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

View File

@ -22,6 +22,10 @@ list_t *list_new(list_free_cb callback);
list_node_t *list_free_node(list_t *list, list_node_t *node);
// similar with list_free_node, this function doesn't free the node data
list_node_t *list_delete_node(list_t *list, list_node_t *node);
// Frees the list. This function accepts NULL as an argument, in which case it
// behaves like a no-op.
void list_free(list_t *list);
@ -75,6 +79,9 @@ bool list_append(list_t *list, void *data);
bool list_remove(list_t *list, void *data);
// similar with list_remove, but do not free the node data
bool list_delete(list_t *list, void *data);
// Removes all elements in the list. Calling this function will return the list to the
// same state it was in after |list_new|. |list| may not be NULL.
void list_clear(list_t *list);

View File

@ -186,6 +186,36 @@ bool list_remove(list_t *list, void *data)
return false;
}
bool list_delete(list_t *list, void *data)
{
assert(list != NULL);
assert(data != NULL);
if (list_is_empty(list)) {
return false;
}
if (list->head->data == data) {
list_node_t *next = list_delete_node(list, list->head);
if (list->tail == list->head) {
list->tail = next;
}
list->head = next;
return true;
}
for (list_node_t *prev = list->head, *node = list->head->next; node; prev = node, node = node->next)
if (node->data == data) {
prev->next = list_delete_node(list, node);
if (list->tail == node) {
list->tail = prev;
}
return true;
}
return false;
}
void list_clear(list_t *list)
{
assert(list != NULL);
@ -251,3 +281,17 @@ list_node_t *list_free_node(list_t *list, list_node_t *node)
return next;
}
// remove the element from list but do not free the node data
list_node_t *list_delete_node(list_t *list, list_node_t *node)
{
assert(list != NULL);
assert(node != NULL);
list_node_t *next = node->next;
osi_free(node);
--list->length;
return next;
}

View File

@ -139,6 +139,7 @@ endif
ifdef CONFIG_BLE_MESH
COMPONENT_ADD_INCLUDEDIRS += esp_ble_mesh/mesh_common/include \
esp_ble_mesh/mesh_common/tinycrypt/include \
esp_ble_mesh/mesh_core \
esp_ble_mesh/mesh_core/include \
esp_ble_mesh/mesh_core/storage \
@ -151,9 +152,11 @@ COMPONENT_ADD_INCLUDEDIRS += esp_ble_mesh/mesh_common/include \
esp_ble_mesh/api
COMPONENT_SRCDIRS += esp_ble_mesh/mesh_common \
esp_ble_mesh/mesh_common/tinycrypt/src \
esp_ble_mesh/mesh_core \
esp_ble_mesh/mesh_core/storage \
esp_ble_mesh/btc \
esp_ble_mesh/mesh_models/common \
esp_ble_mesh/mesh_models/client \
esp_ble_mesh/mesh_models/server \
esp_ble_mesh/api/core \

View File

@ -174,9 +174,18 @@ struct osi_funcs_t {
int (* _coex_register_bt_cb)(coex_func_cb_t cb);
uint32_t (* _coex_bb_reset_lock)(void);
void (* _coex_bb_reset_unlock)(uint32_t restore);
int (* _coex_schm_register_btdm_callback)(void *callback);
void (* _coex_schm_status_bit_clear)(uint32_t type, uint32_t status);
void (* _coex_schm_status_bit_set)(uint32_t type, uint32_t status);
uint32_t (* _coex_schm_interval_get)(void);
uint8_t (* _coex_schm_curr_period_get)(void);
void *(* _coex_schm_curr_phase_get)(void);
int (* _coex_wifi_channel_get)(uint8_t *primary, uint8_t *secondary);
int (* _coex_register_wifi_channel_change_callback)(void *cb);
uint32_t _magic;
};
typedef void (*workitem_handler_t)(void* arg);
/* External functions or values
************************************************************************
@ -193,13 +202,14 @@ extern void btdm_controller_disable(void);
extern uint8_t btdm_controller_get_mode(void);
extern const char *btdm_controller_get_compile_version(void);
extern void btdm_rf_bb_init_phase2(void); // shall be called after PHY/RF is enabled
extern int btdm_dispatch_work_to_controller(workitem_handler_t callback, void *arg, bool blocking);
/* Sleep */
extern void btdm_controller_enable_sleep(bool enable);
extern void btdm_controller_set_sleep_mode(uint8_t mode);
extern uint8_t btdm_controller_get_sleep_mode(void);
extern bool btdm_power_state_active(void);
extern void btdm_wakeup_request(bool request_lock);
extern void btdm_wakeup_request_end(void);
extern void btdm_wakeup_request(void);
extern void btdm_in_wakeup_requesting_set(bool in_wakeup_requesting);
/* Low Power Clock */
extern bool btdm_lpclk_select_src(uint32_t sel);
extern bool btdm_lpclk_set_div(uint32_t div);
@ -215,11 +225,19 @@ extern int bredr_txpwr_get(int *min_power_level, int *max_power_level);
extern void bredr_sco_datapath_set(uint8_t data_path);
extern void btdm_controller_scan_duplicate_list_clear(void);
/* Coexistence */
extern int coex_bt_request_wrapper(uint32_t event, uint32_t latency, uint32_t duration);
extern int coex_bt_release_wrapper(uint32_t event);
extern int coex_register_bt_cb_wrapper(coex_func_cb_t cb);
extern uint32_t coex_bb_reset_lock_wrapper(void);
extern void coex_bb_reset_unlock_wrapper(uint32_t restore);
extern int coex_bt_request(uint32_t event, uint32_t latency, uint32_t duration);
extern int coex_bt_release(uint32_t event);
extern int coex_register_bt_cb(coex_func_cb_t cb);
extern uint32_t coex_bb_reset_lock(void);
extern void coex_bb_reset_unlock(uint32_t restore);
extern int coex_schm_register_btdm_callback(void *callback);
extern void coex_schm_status_bit_clear(uint32_t type, uint32_t status);
extern void coex_schm_status_bit_set(uint32_t type, uint32_t status);
extern uint32_t coex_schm_interval_get(void);
extern uint8_t coex_schm_curr_period_get(void);
extern void * coex_schm_curr_phase_get(void);
extern int coex_wifi_channel_get(uint8_t *primary, uint8_t *secondary);
extern int coex_register_wifi_channel_change_callback(void *cb);
extern void coex_ble_adv_priority_high_set(bool high);
extern char _bss_start_btdm;
@ -282,10 +300,22 @@ static uint32_t IRAM_ATTR btdm_us_2_lpcycles(uint32_t us);
static bool IRAM_ATTR btdm_sleep_check_duration(uint32_t *slot_cnt);
static void btdm_sleep_enter_phase1_wrapper(uint32_t lpcycles);
static void btdm_sleep_enter_phase2_wrapper(void);
static void IRAM_ATTR btdm_sleep_exit_phase1_wrapper(void);
static void btdm_sleep_exit_phase3_wrapper(void);
static bool coex_bt_wakeup_request(void);
static void coex_bt_wakeup_request_end(void);
static int coex_bt_request_wrapper(uint32_t event, uint32_t latency, uint32_t duration);
static int coex_bt_release_wrapper(uint32_t event);
static int coex_register_bt_cb_wrapper(coex_func_cb_t cb);
static uint32_t coex_bb_reset_lock_wrapper(void);
static void coex_bb_reset_unlock_wrapper(uint32_t restore);
static int coex_schm_register_btdm_callback_wrapper(void *callback);
static void coex_schm_status_bit_clear_wrapper(uint32_t type, uint32_t status);
static void coex_schm_status_bit_set_wrapper(uint32_t type, uint32_t status);
static uint32_t coex_schm_interval_get_wrapper(void);
static uint8_t coex_schm_curr_period_get_wrapper(void);
static void * coex_schm_curr_phase_get_wrapper(void);
static int coex_wifi_channel_get_wrapper(uint8_t *primary, uint8_t *secondary);
static int coex_register_wifi_channel_change_callback_wrapper(void *cb);
/* Local variable definition
***************************************************************************
@ -330,7 +360,7 @@ 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,
@ -340,6 +370,14 @@ static const struct osi_funcs_t osi_funcs_ro = {
._coex_register_bt_cb = coex_register_bt_cb_wrapper,
._coex_bb_reset_lock = coex_bb_reset_lock_wrapper,
._coex_bb_reset_unlock = coex_bb_reset_unlock_wrapper,
._coex_schm_register_btdm_callback = coex_schm_register_btdm_callback_wrapper,
._coex_schm_status_bit_clear = coex_schm_status_bit_clear_wrapper,
._coex_schm_status_bit_set = coex_schm_status_bit_set_wrapper,
._coex_schm_interval_get = coex_schm_interval_get_wrapper,
._coex_schm_curr_period_get = coex_schm_curr_period_get_wrapper,
._coex_schm_curr_phase_get = coex_schm_curr_phase_get_wrapper,
._coex_wifi_channel_get = coex_wifi_channel_get_wrapper,
._coex_register_wifi_channel_change_callback = coex_register_wifi_channel_change_callback_wrapper,
._magic = OSI_MAGIC_VALUE,
};
@ -387,10 +425,11 @@ static DRAM_ATTR uint8_t btdm_lpcycle_us_frac = 0; // number of fractional bit f
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;
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;
@ -851,8 +890,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);
@ -861,17 +902,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);
@ -887,45 +926,77 @@ 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_REQMAX 2
#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 request_lock = false;
bool do_wakeup_request = false;
switch (event) {
case BTDM_ASYNC_WAKEUP_REQ_HCI:
request_lock = true;
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:
request_lock = false;
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;
}
bool do_wakeup_request = false;
if (!btdm_power_state_active()) {
#if CONFIG_PM_ENABLE
if (semphr_take_wrapper(s_pm_lock_sem, 0)) {
esp_pm_lock_acquire(s_pm_lock);
}
esp_timer_stop(s_btdm_slp_tmr);
#endif
do_wakeup_request = true;
btdm_wakeup_request(request_lock);
}
return do_wakeup_request;
}
@ -937,6 +1008,7 @@ static void async_wakeup_request_end(int event)
request_lock = true;
break;
case BTDM_ASYNC_WAKEUP_REQ_COEX:
case BTDM_ASYNC_WAKEUP_REQ_CTRL_DISA:
request_lock = false;
break;
default:
@ -944,7 +1016,7 @@ static void async_wakeup_request_end(int event)
}
if (request_lock) {
btdm_wakeup_request_end();
btdm_in_wakeup_requesting_set(false);
}
return;
@ -961,6 +1033,117 @@ static void coex_bt_wakeup_request_end(void)
return;
}
static int IRAM_ATTR coex_bt_request_wrapper(uint32_t event, uint32_t latency, uint32_t duration)
{
#if CONFIG_SW_COEXIST_ENABLE
return coex_bt_request(event, latency, duration);
#else
return 0;
#endif
}
static int IRAM_ATTR coex_bt_release_wrapper(uint32_t event)
{
#if CONFIG_SW_COEXIST_ENABLE
return coex_bt_release(event);
#else
return 0;
#endif
}
static int coex_register_bt_cb_wrapper(coex_func_cb_t cb)
{
#if CONFIG_SW_COEXIST_ENABLE
return coex_register_bt_cb(cb);
#else
return 0;
#endif
}
static uint32_t IRAM_ATTR coex_bb_reset_lock_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
return coex_bb_reset_lock();
#else
return 0;
#endif
}
static void IRAM_ATTR coex_bb_reset_unlock_wrapper(uint32_t restore)
{
#if CONFIG_SW_COEXIST_ENABLE
coex_bb_reset_unlock(restore);
#endif
}
static int coex_schm_register_btdm_callback_wrapper(void *callback)
{
#if CONFIG_SW_COEXIST_ENABLE
return coex_schm_register_btdm_callback(callback);
#else
return 0;
#endif
}
static void coex_schm_status_bit_clear_wrapper(uint32_t type, uint32_t status)
{
#if CONFIG_SW_COEXIST_ENABLE
coex_schm_status_bit_clear(type, status);
#endif
}
static void coex_schm_status_bit_set_wrapper(uint32_t type, uint32_t status)
{
#if CONFIG_SW_COEXIST_ENABLE
coex_schm_status_bit_set(type, status);
#endif
}
static uint32_t coex_schm_interval_get_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
return coex_schm_interval_get();
#else
return 0;
#endif
}
static uint8_t coex_schm_curr_period_get_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
return coex_schm_curr_period_get();
#else
return 1;
#endif
}
static void * coex_schm_curr_phase_get_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
return coex_schm_curr_phase_get();
#else
return NULL;
#endif
}
static int coex_wifi_channel_get_wrapper(uint8_t *primary, uint8_t *secondary)
{
#if CONFIG_SW_COEXIST_ENABLE
return coex_wifi_channel_get(primary, secondary);
#else
return -1;
#endif
}
static int coex_register_wifi_channel_change_callback_wrapper(void *cb)
{
#if CONFIG_SW_COEXIST_ENABLE
return coex_register_wifi_channel_change_callback(cb);
#else
return -1;
#endif
}
bool esp_vhci_host_check_send_available(void)
{
return API_vhci_host_check_send_available();
@ -968,13 +1151,11 @@ bool esp_vhci_host_check_send_available(void)
void esp_vhci_host_send_packet(uint8_t *data, uint16_t len)
{
bool do_wakeup_request = async_wakeup_request(BTDM_ASYNC_WAKEUP_REQ_HCI);
async_wakeup_request(BTDM_ASYNC_WAKEUP_REQ_HCI);
API_vhci_host_send_packet(data, len);
if (do_wakeup_request) {
async_wakeup_request_end(BTDM_ASYNC_WAKEUP_REQ_HCI);
}
async_wakeup_request_end(BTDM_ASYNC_WAKEUP_REQ_HCI);
}
esp_err_t esp_vhci_host_register_callback(const esp_vhci_host_callback_t *callback)
@ -1143,6 +1324,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;
@ -1157,11 +1343,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;
}
@ -1191,6 +1372,12 @@ 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
s_wakeup_req_sem = semphr_create_wrapper(1, 0);
if (s_wakeup_req_sem == NULL) {
err = ESP_ERR_NO_MEM;
goto error;
}
btdm_controller_mem_init();
periph_module_enable(PERIPH_BT_MODULE);
@ -1264,11 +1451,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;
}
s_pm_lock_acquired = true;
#endif
btdm_cfg_mask = btdm_config_mask_load();
@ -1304,11 +1487,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;
}
@ -1327,14 +1510,13 @@ esp_err_t esp_bt_controller_deinit(void)
esp_pm_lock_delete(s_light_sleep_pm_lock);
s_light_sleep_pm_lock = NULL;
}
esp_pm_lock_delete(s_pm_lock);
s_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);
@ -1353,6 +1535,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;
@ -1416,6 +1611,10 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
}
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;
}
@ -1429,9 +1628,7 @@ esp_err_t esp_bt_controller_disable(void)
// disable modem sleep and wake up from sleep mode
if (btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_ORIG) {
btdm_controller_enable_sleep(false);
if (!btdm_power_state_active()) {
btdm_wakeup_request(false);
}
async_wakeup_request(BTDM_ASYNC_WAKEUP_REQ_CTRL_DISA);
while (!btdm_power_state_active()) {
ets_delay_us(1000);
}
@ -1448,6 +1645,7 @@ 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 (!s_btdm_allow_light_sleep) {
@ -1464,7 +1662,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)
{
@ -1551,26 +1748,6 @@ esp_err_t esp_bt_sleep_disable (void)
return status;
}
bool esp_bt_controller_is_sleeping(void)
{
if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_ENABLED ||
btdm_controller_get_sleep_mode() != BTDM_MODEM_SLEEP_MODE_ORIG) {
return false;
}
return !btdm_power_state_active();
}
void esp_bt_controller_wakeup_request(void)
{
if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_ENABLED ||
btdm_controller_get_sleep_mode() != BTDM_MODEM_SLEEP_MODE_ORIG) {
return;
}
btdm_wakeup_request(false);
}
esp_err_t esp_bredr_sco_datapath_set(esp_sco_data_path_t data_path)
{
if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_ENABLED) {

View File

@ -18,12 +18,118 @@ if BLE_MESH
option in the Bluetooth Controller section in menuconfig, which is
"Scan Duplicate By Device Address and Advertising Data".
config BLE_MESH_ALLOC_FROM_PSRAM_FIRST
bool "BLE Mesh will first allocate memory from PSRAM"
choice BLE_MESH_MEM_ALLOC_MODE
prompt "Memory allocation strategy"
default BLE_MESH_MEM_ALLOC_MODE_INTERNAL
help
Allocation strategy for BLE Mesh stack, essentially provides ability to
allocate all required dynamic allocations from,
- Internal DRAM memory only
- External SPIRAM memory only
- Either internal or external memory based on default malloc()
behavior in ESP-IDF
- Internal IRAM memory wherever applicable else internal DRAM
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.
config BLE_MESH_MEM_ALLOC_MODE_IRAM_8BIT
bool "Internal IRAM"
depends on ESP32_IRAM_AS_8BIT_ACCESSIBLE_MEMORY
help
Allows to use IRAM memory region as 8bit accessible region. Every
unaligned (8bit or 16bit) access will result in an exception and
incur penalty of certain clock cycles per unaligned read/write.
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 || ESP32_IRAM_AS_8BIT_ACCESSIBLE_MEMORY)
default n
help
When this option is enabled, BLE Mesh stack will try to allocate memory
from PSRAM firstly. This will save the internal RAM if PSRAM exists.
Enable this option to use FreeRTOS static allocation APIs for BLE Mesh,
which provides the ability to use different dynamic memory (i.e. SPIRAM
or IRAM) 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.
config BLE_MESH_FREERTOS_STATIC_ALLOC_IRAM_8BIT
bool "Internal IRAM"
depends on ESP32_IRAM_AS_8BIT_ACCESSIBLE_MEMORY
help
If enabled, BLE Mesh allocates dynamic memory from internal IRAM for
FreeRTOS objects, i.e. mutex, queue. Note: IRAM region cannot be used
as task stack.
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"
@ -118,6 +224,28 @@ if BLE_MESH
This option specifies how many application keys the Provisioner can have.
Indeed, this value decides the number of the application keys which can be added by a Provisioner.
config BLE_MESH_PROVISIONER_RECV_HB
bool "Support receiving Heartbeat messages"
default n
help
When this option is enabled, Provisioner can call specific functions to enable
or disable receiving Heartbeat messages and notify them to the application layer.
if BLE_MESH_PROVISIONER_RECV_HB
config BLE_MESH_PROVISIONER_RECV_HB_FILTER_SIZE
int "Maximum number of filter entries for receiving Heartbeat messages"
default 3
range 1 1000
help
This option specifies how many heartbeat filter entries Provisioner supports.
The heartbeat filter (acceptlist or rejectlist) entries are used to store a
list of SRC and DST which can be used to decide if a heartbeat message will
be processed and notified to the application layer by Provisioner.
Note: The filter is an empty rejectlist by default.
endif # BLE_MESH_PROVISIONER_RECV_HB
endif # BLE_MESH_PROVISIONER
# Virtual option enabled whenever Generic Provisioning layer is needed
@ -199,7 +327,7 @@ if BLE_MESH
advertising bearer.
config BLE_MESH_NET_BUF_POOL_USAGE
bool "BLE Mesh net buffer pool usage tracking"
bool
default y
help
Enable BLE Mesh net buffer pool tracking. This option is used to introduce another
@ -221,28 +349,6 @@ if BLE_MESH
if BLE_MESH_SETTINGS
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.
if BLE_MESH_SPECIFIC_PARTITION
config BLE_MESH_PARTITION_NAME
string "Name of the NVS partition for BLE Mesh"
default "ble_mesh"
help
This value defines the name of the specified NVS partition used by the
mesh stack.
endif # BLE_MESH_SPECIFIC_PARTITION
config BLE_MESH_STORE_TIMEOUT
int "Delay (in seconds) before storing anything persistently"
range 0 1000000
@ -257,7 +363,7 @@ if BLE_MESH
config BLE_MESH_SEQ_STORE_RATE
int "How often the sequence number gets updated in storage"
range 0 1000000
default 6
default 0
help
This value defines how often the local sequence number gets updated in
persistent storage (i.e. flash). e.g. a value of 100 means that the
@ -272,7 +378,7 @@ if BLE_MESH
config BLE_MESH_RPL_STORE_TIMEOUT
int "Minimum frequency that the RPL gets updated in storage"
range 0 1000000
default 5
default 0
help
This value defines in seconds how soon the RPL (Replay Protection List)
gets written to persistent storage after a change occurs. If the node
@ -308,6 +414,50 @@ if BLE_MESH
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
@ -389,24 +539,6 @@ if BLE_MESH
SDU size is 60 bytes, which leaves 56 bytes for application layer data
using a 4-byte MIC, or 52 bytes using an 8-byte MIC.
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_IVU_DIVIDER
int "Divider for IV Update state refresh timer"
default 4
@ -801,104 +933,138 @@ if BLE_MESH
uses 0 as the timeout value when sending acknowledged messages, then
the default value will be used which is four seconds.
menu "Support for BLE Mesh Client Models"
menu "Support for BLE Mesh Foundation models"
config BLE_MESH_CFG_CLI
bool "Configuration Client Model"
bool "Configuration Client model"
help
Enable support for Configuration client model.
Enable support for Configuration Client model.
config BLE_MESH_HEALTH_CLI
bool "Health Client Model"
bool "Health Client model"
help
Enable support for Health client model.
Enable support for Health Client model.
config BLE_MESH_HEALTH_SRV
bool "Health Server model"
default y
help
Enable support for Health Server model.
endmenu #Support for BLE Mesh Foundation models
menu "Support for BLE Mesh Client/Server models"
config BLE_MESH_GENERIC_ONOFF_CLI
bool "Generic OnOff Client Model"
bool "Generic OnOff Client model"
help
Enable support for Generic OnOff client model.
Enable support for Generic OnOff Client model.
config BLE_MESH_GENERIC_LEVEL_CLI
bool "Generic Level Client Model"
bool "Generic Level Client model"
help
Enable support for Generic Level client model.
Enable support for Generic Level Client model.
config BLE_MESH_GENERIC_DEF_TRANS_TIME_CLI
bool "Generic Default Transition Time Client Model"
bool "Generic Default Transition Time Client model"
help
Enable support for Generic Default Transition Time client model.
Enable support for Generic Default Transition Time Client model.
config BLE_MESH_GENERIC_POWER_ONOFF_CLI
bool "Generic Power OnOff Client Model"
bool "Generic Power OnOff Client model"
help
Enable support for Generic Power OnOff client model.
Enable support for Generic Power OnOff Client model.
config BLE_MESH_GENERIC_POWER_LEVEL_CLI
bool "Generic Power Level Client Model"
bool "Generic Power Level Client model"
help
Enable support for Generic Power Level client model.
Enable support for Generic Power Level Client model.
config BLE_MESH_GENERIC_BATTERY_CLI
bool "Generic Battery Client Model"
bool "Generic Battery Client model"
help
Enable support for Generic Battery client model.
Enable support for Generic Battery Client model.
config BLE_MESH_GENERIC_LOCATION_CLI
bool "Generic Location Client Model"
bool "Generic Location Client model"
help
Enable support for Generic Location client model.
Enable support for Generic Location Client model.
config BLE_MESH_GENERIC_PROPERTY_CLI
bool "Generic Property Client Model"
bool "Generic Property Client model"
help
Enable support for Generic Property client model.
Enable support for Generic Property Client model.
config BLE_MESH_SENSOR_CLI
bool "Sensor Client Model"
bool "Sensor Client model"
help
Enable support for Sensor client model.
Enable support for Sensor Client model.
config BLE_MESH_TIME_CLI
bool "Time Client Model"
bool "Time Client model"
help
Enable support for Time client model.
Enable support for Time Client model.
config BLE_MESH_SCENE_CLI
bool "Scene Client Model"
bool "Scene Client model"
help
Enable support for Scene client model.
Enable support for Scene Client model.
config BLE_MESH_SCHEDULER_CLI
bool "Scheduler Client Model"
bool "Scheduler Client model"
help
Enable support for Scheduler client model.
Enable support for Scheduler Client model.
config BLE_MESH_LIGHT_LIGHTNESS_CLI
bool "Light Lightness Client Model"
bool "Light Lightness Client model"
help
Enable support for Light Lightness client model.
Enable support for Light Lightness Client model.
config BLE_MESH_LIGHT_CTL_CLI
bool "Light CTL Client Model"
bool "Light CTL Client model"
help
Enable support for Light CTL client model.
Enable support for Light CTL Client model.
config BLE_MESH_LIGHT_HSL_CLI
bool "Light HSL Client Model"
bool "Light HSL Client model"
help
Enable support for Light HSL client model.
Enable support for Light HSL Client model.
config BLE_MESH_LIGHT_XYL_CLI
bool "Light XYL Client Model"
bool "Light XYL Client model"
help
Enable support for Light XYL client model.
Enable support for Light XYL Client model.
config BLE_MESH_LIGHT_LC_CLI
bool "Light LC Client Model"
bool "Light LC Client model"
help
Enable support for Light LC client model.
Enable support for Light LC Client model.
endmenu
config BLE_MESH_GENERIC_SERVER
bool "Generic server models"
default y
help
Enable support for Generic server models.
config BLE_MESH_SENSOR_SERVER
bool "Sensor server models"
default y
help
Enable support for Sensor server models.
config BLE_MESH_TIME_SCENE_SERVER
bool "Time and Scenes server models"
default y
help
Enable support for Time and Scenes server models.
config BLE_MESH_LIGHTING_SERVER
bool "Lighting server models"
default y
help
Enable support for Lighting server models.
endmenu #Support for BLE Mesh Client/Server models
config BLE_MESH_IV_UPDATE_TEST
bool "Test the IV Update Procedure"

View File

@ -1,4 +1,4 @@
// Copyright 2017-2019 Espressif Systems (Shanghai) PTE LTD
// 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.
@ -15,19 +15,25 @@
#include <stdint.h>
#include <string.h>
#include "btc/btc_manage.h"
#include "esp_err.h"
#include "btc_ble_mesh_prov.h"
#include "esp_ble_mesh_defs.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_prov_args_t arg = {0};
btc_ble_mesh_ble_args_t arg = {0};
btc_msg_t msg = {0};
if (param == NULL) {
@ -37,21 +43,21 @@ esp_err_t esp_ble_mesh_start_ble_advertising(const esp_ble_mesh_ble_adv_param_t
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_START_BLE_ADVERTISING;
msg.pid = BTC_PID_BLE_MESH_BLE_COEX;
msg.act = BTC_BLE_MESH_ACT_START_BLE_ADV;
memcpy(&arg.start_ble_advertising.param, param, sizeof(esp_ble_mesh_ble_adv_param_t));
memcpy(&arg.start_ble_adv.param, param, sizeof(esp_ble_mesh_ble_adv_param_t));
if (data) {
memcpy(&arg.start_ble_advertising.data, data, sizeof(esp_ble_mesh_ble_adv_data_t));
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_prov_args_t), NULL)
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_prov_args_t arg = {0};
btc_ble_mesh_ble_args_t arg = {0};
btc_msg_t msg = {0};
if (index >= CONFIG_BLE_MESH_BLE_ADV_BUF_COUNT) {
@ -61,13 +67,44 @@ esp_err_t esp_ble_mesh_stop_ble_advertising(uint8_t index)
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_STOP_BLE_ADVERTISING;
msg.pid = BTC_PID_BLE_MESH_BLE_COEX;
msg.act = BTC_BLE_MESH_ACT_STOP_BLE_ADV;
arg.stop_ble_advertising.index = index;
arg.stop_ble_adv.index = index;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
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);
}
#endif /* CONFIG_BLE_MESH_SUPPORT_BLE_ADV */
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

@ -42,7 +42,7 @@ esp_err_t esp_ble_mesh_init(esp_ble_mesh_prov_t *prov, esp_ble_mesh_comp_t *comp
// Create a semaphore
if ((semaphore = xSemaphoreCreateCounting(1, 0)) == NULL) {
BT_ERR("%s, Failed to allocate memory for the semaphore", __func__);
BT_ERR("Failed to create semaphore");
return ESP_ERR_NO_MEM;
}
@ -57,7 +57,7 @@ esp_err_t esp_ble_mesh_init(esp_ble_mesh_prov_t *prov, esp_ble_mesh_comp_t *comp
if (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL) != BT_STATUS_SUCCESS) {
vSemaphoreDelete(semaphore);
BT_ERR("%s, BLE Mesh initialise failed", __func__);
BT_ERR("Failed to start mesh init");
return ESP_FAIL;
}
@ -69,6 +69,7 @@ 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};
@ -89,4 +90,4 @@ esp_err_t esp_ble_mesh_deinit(esp_ble_mesh_deinit_param_t *param)
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,6 +13,7 @@
// limitations under the License.
#include <stdint.h>
#include <string.h>
#include "esp_err.h"
@ -32,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;
@ -54,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;
@ -62,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;
@ -75,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

@ -23,12 +23,12 @@
#define ESP_BLE_MESH_TX_SDU_MAX ((CONFIG_BLE_MESH_ADV_BUF_COUNT - 3) * 12)
static esp_err_t ble_mesh_model_send_msg(esp_ble_mesh_model_t *model,
esp_ble_mesh_msg_ctx_t *ctx,
uint32_t opcode,
btc_ble_mesh_model_act_t act,
uint16_t length, uint8_t *data,
int32_t msg_timeout, bool need_rsp,
esp_ble_mesh_dev_role_t device_role)
esp_ble_mesh_msg_ctx_t *ctx,
uint32_t opcode,
btc_ble_mesh_model_act_t act,
uint16_t length, uint8_t *data,
int32_t msg_timeout, bool need_rsp,
esp_ble_mesh_dev_role_t device_role)
{
btc_ble_mesh_model_args_t arg = {0};
uint8_t op_len = 0, mic_len = 0;
@ -39,12 +39,12 @@ static esp_err_t ble_mesh_model_send_msg(esp_ble_mesh_model_t *model,
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
if (ctx && ctx->addr == ESP_BLE_MESH_ADDR_UNASSIGNED) {
BT_ERR("%s, Invalid destination address 0x0000", __func__);
BT_ERR("Invalid destination address 0x0000");
return ESP_ERR_INVALID_ARG;
}
if (device_role > ROLE_FAST_PROV) {
BT_ERR("%s, Invalid device role 0x%02x", __func__, device_role);
BT_ERR("Invalid device role 0x%02x", device_role);
return ESP_ERR_INVALID_ARG;
}
@ -63,7 +63,7 @@ static esp_err_t ble_mesh_model_send_msg(esp_ble_mesh_model_t *model,
if (act == BTC_BLE_MESH_ACT_MODEL_PUBLISH) {
if (op_len + length > model->pub->msg->size) {
BT_ERR("%s, Model publication msg size %d is too small", __func__, model->pub->msg->size);
BT_ERR("Too small publication msg size %d", model->pub->msg->size);
return ESP_ERR_INVALID_ARG;
}
}
@ -75,7 +75,7 @@ static esp_err_t ble_mesh_model_send_msg(esp_ble_mesh_model_t *model,
}
if (op_len + length + mic_len > MIN(ESP_BLE_MESH_SDU_MAX_LEN, ESP_BLE_MESH_TX_SDU_MAX)) {
BT_ERR("%s, Data length %d is too large", __func__, length);
BT_ERR("Too large data length %d", length);
return ESP_ERR_INVALID_ARG;
}
@ -164,6 +164,7 @@ esp_err_t esp_ble_mesh_client_model_init(esp_ble_mesh_model_t *model)
return btc_ble_mesh_client_model_init(model);
}
#if CONFIG_BLE_MESH_DEINIT
esp_err_t esp_ble_mesh_client_model_deinit(esp_ble_mesh_model_t *model)
{
if (model == NULL) {
@ -174,26 +175,36 @@ esp_err_t esp_ble_mesh_client_model_deinit(esp_ble_mesh_model_t *model)
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)
esp_ble_mesh_msg_ctx_t *ctx,
uint32_t opcode,
uint16_t length, uint8_t *data)
{
if (!model || !ctx) {
if (model == NULL || ctx == NULL ||
ctx->net_idx == ESP_BLE_MESH_KEY_UNUSED ||
ctx->app_idx == ESP_BLE_MESH_KEY_UNUSED) {
return ESP_ERR_INVALID_ARG;
}
return ble_mesh_model_send_msg(model, ctx, opcode, BTC_BLE_MESH_ACT_SERVER_MODEL_SEND,
length, data, 0, false, ROLE_NODE);
}
esp_err_t esp_ble_mesh_client_model_send_msg(esp_ble_mesh_model_t *model,
esp_ble_mesh_msg_ctx_t *ctx, uint32_t opcode,
uint16_t length, uint8_t *data, int32_t msg_timeout,
bool need_rsp, esp_ble_mesh_dev_role_t device_role)
esp_ble_mesh_msg_ctx_t *ctx,
uint32_t opcode,
uint16_t length, uint8_t *data,
int32_t msg_timeout, bool need_rsp,
esp_ble_mesh_dev_role_t device_role)
{
if (!model || !ctx) {
if (model == NULL || ctx == NULL ||
ctx->net_idx == ESP_BLE_MESH_KEY_UNUSED ||
ctx->app_idx == ESP_BLE_MESH_KEY_UNUSED) {
return ESP_ERR_INVALID_ARG;
}
return ble_mesh_model_send_msg(model, ctx, opcode, BTC_BLE_MESH_ACT_CLIENT_MODEL_SEND,
length, data, msg_timeout, need_rsp, device_role);
}
@ -202,16 +213,19 @@ esp_err_t esp_ble_mesh_model_publish(esp_ble_mesh_model_t *model, uint32_t opcod
uint16_t length, uint8_t *data,
esp_ble_mesh_dev_role_t device_role)
{
if (!model || !model->pub || !model->pub->msg) {
if (model == NULL || model->pub == NULL || model->pub->msg == NULL ||
model->pub->publish_addr == ESP_BLE_MESH_ADDR_UNASSIGNED) {
return ESP_ERR_INVALID_ARG;
}
return ble_mesh_model_send_msg(model, NULL, opcode, BTC_BLE_MESH_ACT_MODEL_PUBLISH,
length, data, 0, false, device_role);
}
#if CONFIG_BLE_MESH_SERVER_MODEL
esp_err_t esp_ble_mesh_server_model_update_state(esp_ble_mesh_model_t *model,
esp_ble_mesh_server_state_type_t type,
esp_ble_mesh_server_state_value_t *value)
esp_ble_mesh_server_state_type_t type,
esp_ble_mesh_server_state_value_t *value)
{
btc_ble_mesh_model_args_t arg = {0};
btc_msg_t msg = {0};
@ -233,6 +247,7 @@ esp_err_t esp_ble_mesh_server_model_update_state(esp_ble_mesh_model_t *model,
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_model_args_t), btc_ble_mesh_model_arg_deep_copy)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif /* CONFIG_BLE_MESH_SERVER_MODEL */
esp_err_t esp_ble_mesh_node_local_reset(void)
{
@ -286,7 +301,8 @@ uint16_t esp_ble_mesh_provisioner_get_node_index(const char *name)
return bt_mesh_provisioner_get_node_index(name);
}
esp_err_t esp_ble_mesh_provisioner_store_node_comp_data(uint16_t unicast_addr, uint8_t *data, uint16_t length)
esp_err_t esp_ble_mesh_provisioner_store_node_comp_data(uint16_t unicast_addr,
uint8_t *data, uint16_t length)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
@ -326,6 +342,25 @@ esp_ble_mesh_node_t *esp_ble_mesh_provisioner_get_node_with_addr(uint16_t unicas
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};
@ -369,7 +404,7 @@ esp_err_t esp_ble_mesh_provisioner_delete_node_with_addr(uint16_t unicast_addr)
}
esp_err_t esp_ble_mesh_provisioner_add_local_app_key(const uint8_t app_key[16],
uint16_t net_idx, uint16_t app_idx)
uint16_t net_idx, uint16_t app_idx)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
@ -392,7 +427,7 @@ esp_err_t esp_ble_mesh_provisioner_add_local_app_key(const uint8_t app_key[16],
}
esp_err_t esp_ble_mesh_provisioner_update_local_app_key(const uint8_t app_key[16],
uint16_t net_idx, uint16_t app_idx)
uint16_t net_idx, uint16_t app_idx)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
@ -420,7 +455,7 @@ const uint8_t *esp_ble_mesh_provisioner_get_local_app_key(uint16_t net_idx, uint
}
esp_err_t esp_ble_mesh_provisioner_bind_app_key_to_local_model(uint16_t element_addr, uint16_t app_idx,
uint16_t model_id, uint16_t company_id)
uint16_t model_id, uint16_t company_id)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
@ -494,11 +529,245 @@ 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);
}
uint16_t esp_ble_mesh_provisioner_get_prov_node_count(void)
#if CONFIG_BLE_MESH_PROVISIONER_RECV_HB
esp_err_t esp_ble_mesh_provisioner_recv_heartbeat(bool enable)
{
return btc_ble_mesh_provisioner_get_prov_node_count();
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

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

View File

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

View File

@ -1,4 +1,4 @@
// Copyright 2017-2019 Espressif Systems (Shanghai) PTE LTD
// 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.
@ -21,6 +21,106 @@
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.
@ -58,6 +158,31 @@ esp_err_t esp_ble_mesh_start_ble_advertising(const esp_ble_mesh_ble_adv_param_t
*/
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

View File

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

View File

@ -23,7 +23,7 @@ extern "C" {
/** @brief: event, event code of user-defined model events; param, parameters of user-defined model events */
typedef void (* esp_ble_mesh_model_cb_t)(esp_ble_mesh_model_cb_event_t event,
esp_ble_mesh_model_cb_param_t *param);
esp_ble_mesh_model_cb_param_t *param);
/**
* @brief Register BLE Mesh callback for user-defined models' operations.
@ -104,8 +104,9 @@ esp_err_t esp_ble_mesh_client_model_deinit(esp_ble_mesh_model_t *model);
*
*/
esp_err_t esp_ble_mesh_server_model_send_msg(esp_ble_mesh_model_t *model,
esp_ble_mesh_msg_ctx_t *ctx, uint32_t opcode,
uint16_t length, uint8_t *data);
esp_ble_mesh_msg_ctx_t *ctx,
uint32_t opcode,
uint16_t length, uint8_t *data);
/**
* @brief Send client model message (such as model get, set, etc).
@ -123,9 +124,11 @@ esp_err_t esp_ble_mesh_server_model_send_msg(esp_ble_mesh_model_t *model,
*
*/
esp_err_t esp_ble_mesh_client_model_send_msg(esp_ble_mesh_model_t *model,
esp_ble_mesh_msg_ctx_t *ctx, uint32_t opcode,
uint16_t length, uint8_t *data, int32_t msg_timeout,
bool need_rsp, esp_ble_mesh_dev_role_t device_role);
esp_ble_mesh_msg_ctx_t *ctx,
uint32_t opcode,
uint16_t length, uint8_t *data,
int32_t msg_timeout, bool need_rsp,
esp_ble_mesh_dev_role_t device_role);
/**
* @brief Send a model publication message.
@ -166,8 +169,8 @@ esp_err_t esp_ble_mesh_model_publish(esp_ble_mesh_model_t *model, uint32_t opcod
*
*/
esp_err_t esp_ble_mesh_server_model_update_state(esp_ble_mesh_model_t *model,
esp_ble_mesh_server_state_type_t type,
esp_ble_mesh_server_state_value_t *value);
esp_ble_mesh_server_state_type_t type,
esp_ble_mesh_server_state_value_t *value);
/**
* @brief Reset the provisioning procedure of the local BLE Mesh node.
@ -226,7 +229,8 @@ uint16_t esp_ble_mesh_provisioner_get_node_index(const char *name);
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_provisioner_store_node_comp_data(uint16_t unicast_addr, uint8_t *data, uint16_t length);
esp_err_t esp_ble_mesh_provisioner_store_node_comp_data(uint16_t unicast_addr,
uint8_t *data, uint16_t length);
/**
* @brief This function is called to get the provisioned node information
@ -250,6 +254,48 @@ esp_ble_mesh_node_t *esp_ble_mesh_provisioner_get_node_with_uuid(const uint8_t u
*/
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.
@ -287,7 +333,8 @@ esp_err_t esp_ble_mesh_provisioner_delete_node_with_addr(uint16_t unicast_addr);
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_provisioner_add_local_app_key(const uint8_t app_key[16], uint16_t net_idx, uint16_t app_idx);
esp_err_t esp_ble_mesh_provisioner_add_local_app_key(const uint8_t app_key[16],
uint16_t net_idx, uint16_t app_idx);
/**
* @brief This function is used to update a local AppKey for Provisioner.
@ -300,7 +347,7 @@ esp_err_t esp_ble_mesh_provisioner_add_local_app_key(const uint8_t app_key[16],
*
*/
esp_err_t esp_ble_mesh_provisioner_update_local_app_key(const uint8_t app_key[16],
uint16_t net_idx, uint16_t app_idx);
uint16_t net_idx, uint16_t app_idx);
/**
* @brief This function is called by Provisioner to get the local app key value.
@ -328,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.
@ -367,12 +414,229 @@ esp_err_t esp_ble_mesh_provisioner_update_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 get provisioned node count.
* @brief This function is called by Provisioner to enable or disable receiving
* heartbeat messages.
*
* @return Number of the provisioned nodes.
* @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.
*
*/
uint16_t esp_ble_mesh_provisioner_get_prov_node_count(void);
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.

View File

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

View File

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

View File

@ -17,6 +17,7 @@
#include <stdint.h>
#include "mesh_config.h"
#include "mesh_common.h"
#include "proxy_server.h"
#include "provisioner_main.h"
@ -50,6 +51,12 @@ extern "C" {
/*!< The maximum length of a BLE Mesh unprovisioned device name */
#define ESP_BLE_MESH_DEVICE_NAME_MAX_LEN DEVICE_NAME_SIZE
/*!< The maximum length of settings user id */
#define ESP_BLE_MESH_SETTINGS_UID_SIZE 20
/*!< Invalid settings index */
#define ESP_BLE_MESH_INVALID_SETTINGS_IDX 0xFF
/*!< Define the BLE Mesh octet 16 bytes size */
#define ESP_BLE_MESH_OCTET16_LEN 16
typedef uint8_t esp_ble_mesh_octet16_t[ESP_BLE_MESH_OCTET16_LEN];
@ -58,6 +65,15 @@ typedef uint8_t esp_ble_mesh_octet16_t[ESP_BLE_MESH_OCTET16_LEN];
#define ESP_BLE_MESH_OCTET8_LEN 8
typedef uint8_t esp_ble_mesh_octet8_t[ESP_BLE_MESH_OCTET8_LEN];
/*!< Invalid Company ID */
#define ESP_BLE_MESH_CID_NVAL 0xFFFF
/*!< Special TTL value to request using configured default TTL */
#define ESP_BLE_MESH_TTL_DEFAULT 0xFF
/*!< Maximum allowed TTL value */
#define ESP_BLE_MESH_TTL_MAX 0x7F
#define ESP_BLE_MESH_ADDR_UNASSIGNED 0x0000
#define ESP_BLE_MESH_ADDR_ALL_NODES 0xFFFF
#define ESP_BLE_MESH_ADDR_PROXIES 0xFFFC
@ -262,7 +278,7 @@ typedef enum {
#define ESP_BLE_MESH_MODEL_OP_2(b0, b1) (((b0) << 8) | (b1))
#define ESP_BLE_MESH_MODEL_OP_3(b0, cid) ((((b0) << 16) | 0xC00000) | (cid))
/*!< This macro is associated with BLE_MESH_MODEL in mesh_access.h */
/*!< This macro is associated with BLE_MESH_MODEL_CB in mesh_access.h */
#define ESP_BLE_MESH_SIG_MODEL(_id, _op, _pub, _user_data) \
{ \
.model_id = (_id), \
@ -275,7 +291,7 @@ typedef enum {
.user_data = _user_data, \
}
/*!< This macro is associated with BLE_MESH_MODEL_VND in mesh_access.h */
/*!< This macro is associated with BLE_MESH_MODEL_VND_CB in mesh_access.h */
#define ESP_BLE_MESH_VENDOR_MODEL(_company, _id, _op, _pub, _user_data) \
{ \
.vnd.company_id = (_company), \
@ -452,6 +468,19 @@ typedef struct {
*/
#define ESP_BLE_MESH_MODEL_OP_END {0, 0, 0}
/** Abstraction that describes a model callback structure.
* This structure is associated with struct bt_mesh_model_cb in mesh_access.h.
*/
typedef struct {
/** Callback used during model initialization. Initialized by the stack. */
esp_ble_mesh_cb_t init_cb;
#if CONFIG_BLE_MESH_DEINIT
/** Callback used during model deinitialization. Initialized by the stack. */
esp_ble_mesh_cb_t deinit_cb;
#endif /* CONFIG_BLE_MESH_DEINIT */
} esp_ble_mesh_model_cbs_t;
/** Abstraction that describes a Mesh Model instance.
* This structure is associated with struct bt_mesh_model in mesh_access.h
*/
@ -485,6 +514,9 @@ struct esp_ble_mesh_model {
/** Model operation context */
esp_ble_mesh_model_op_t *op;
/** Model callback structure */
esp_ble_mesh_model_cbs_t *cb;
/** Model-specific user data */
void *user_data;
};
@ -519,7 +551,7 @@ typedef struct {
/** Force sending reliably by using segment acknowledgement */
uint8_t send_rel: 1;
/** TTL, or BLE_MESH_TTL_DEFAULT for default TTL. */
/** TTL, or ESP_BLE_MESH_TTL_DEFAULT for default TTL. */
uint8_t send_ttl;
/** Opcode of a received message. Not used for sending message. */
@ -745,35 +777,19 @@ typedef enum {
PROXY_FILTER_BLACKLIST,
} esp_ble_mesh_proxy_filter_type_t;
/** Count for sending BLE advertising packet infinitely */
#define ESP_BLE_MESH_BLE_ADV_INFINITE 0xFFFF
/*!< Provisioner heartbeat filter type */
#define ESP_BLE_MESH_HEARTBEAT_FILTER_ACCEPTLIST 0x00
#define ESP_BLE_MESH_HEARTBEAT_FILTER_REJECTLIST 0x01
/*!< 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;
/*!< Provisioner heartbeat filter operation */
#define ESP_BLE_MESH_HEARTBEAT_FILTER_ADD 0x00
#define ESP_BLE_MESH_HEARTBEAT_FILTER_REMOVE 0x01
/** Context of BLE advertising parameters. */
/** Context of Provisioner heartbeat filter information to be set */
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;
uint16_t hb_src; /*!< Heartbeat source address (unicast address) */
uint16_t hb_dst; /*!< Heartbeat destination address (unicast address or group address) */
} esp_ble_mesh_heartbeat_filter_info_t;
/*!< This enum value is the event of node/provisioner/fast provisioning */
typedef enum {
@ -795,6 +811,9 @@ typedef enum {
ESP_BLE_MESH_NODE_PROXY_IDENTITY_ENABLE_COMP_EVT, /*!< Enable BLE Mesh Proxy Identity advertising completion event */
ESP_BLE_MESH_NODE_PROXY_GATT_ENABLE_COMP_EVT, /*!< Enable BLE Mesh GATT Proxy Service completion event */
ESP_BLE_MESH_NODE_PROXY_GATT_DISABLE_COMP_EVT, /*!< Disable BLE Mesh GATT Proxy Service completion event */
ESP_BLE_MESH_NODE_ADD_LOCAL_NET_KEY_COMP_EVT, /*!< Node add NetKey locally completion event */
ESP_BLE_MESH_NODE_ADD_LOCAL_APP_KEY_COMP_EVT, /*!< Node add AppKey locally completion event */
ESP_BLE_MESH_NODE_BIND_APP_KEY_TO_MODEL_COMP_EVT, /*!< Node bind AppKey to model locally completion event */
ESP_BLE_MESH_PROVISIONER_PROV_ENABLE_COMP_EVT, /*!< Provisioner enable provisioning functionality completion event */
ESP_BLE_MESH_PROVISIONER_PROV_DISABLE_COMP_EVT, /*!< Provisioner disable provisioning functionality completion event */
ESP_BLE_MESH_PROVISIONER_RECV_UNPROV_ADV_PKT_EVT, /*!< Provisioner receives unprovisioned device beacon event */
@ -806,7 +825,7 @@ typedef enum {
ESP_BLE_MESH_PROVISIONER_PROV_COMPLETE_EVT, /*!< Provisioner provisioning done event */
ESP_BLE_MESH_PROVISIONER_ADD_UNPROV_DEV_COMP_EVT, /*!< Provisioner add a device to the list which contains devices that are waiting/going to be provisioned completion event */
ESP_BLE_MESH_PROVISIONER_PROV_DEV_WITH_ADDR_COMP_EVT, /*!< Provisioner start to provision an unprovisioned device completion event */
ESP_BLE_MESH_PROVISIONER_DELETE_DEV_COMP_EVT, /*!< Provisioner delete a device from the list, close provisioning link with the device if it exists and remove the device from network completion event */
ESP_BLE_MESH_PROVISIONER_DELETE_DEV_COMP_EVT, /*!< Provisioner delete a device from the list, close provisioning link with the device completion event */
ESP_BLE_MESH_PROVISIONER_SET_DEV_UUID_MATCH_COMP_EVT, /*!< Provisioner set the value to be compared with part of the unprovisioned device UUID completion event */
ESP_BLE_MESH_PROVISIONER_SET_PROV_DATA_INFO_COMP_EVT, /*!< Provisioner set net_idx/flags/iv_index used for provisioning completion event */
ESP_BLE_MESH_PROVISIONER_SET_STATIC_OOB_VALUE_COMP_EVT, /*!< Provisioner set static oob value used for provisioning completion event */
@ -823,6 +842,17 @@ typedef enum {
ESP_BLE_MESH_PROVISIONER_STORE_NODE_COMP_DATA_COMP_EVT, /*!< Provisioner store node composition data completion event */
ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_UUID_COMP_EVT, /*!< Provisioner delete node with uuid completion event */
ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_ADDR_COMP_EVT, /*!< Provisioner delete node with unicast address completion event */
ESP_BLE_MESH_PROVISIONER_ENABLE_HEARTBEAT_RECV_COMP_EVT, /*!< Provisioner start to receive heartbeat message completion event */
ESP_BLE_MESH_PROVISIONER_SET_HEARTBEAT_FILTER_TYPE_COMP_EVT, /*!< Provisioner set the heartbeat filter type completion event */
ESP_BLE_MESH_PROVISIONER_SET_HEARTBEAT_FILTER_INFO_COMP_EVT, /*!< Provisioner set the heartbeat filter information completion event */
ESP_BLE_MESH_PROVISIONER_RECV_HEARTBEAT_MESSAGE_EVT, /*!< Provisioner receive heartbeat message event */
ESP_BLE_MESH_PROVISIONER_DRIECT_ERASE_SETTINGS_COMP_EVT, /*!< Provisioner directly erase settings completion event */
ESP_BLE_MESH_PROVISIONER_OPEN_SETTINGS_WITH_INDEX_COMP_EVT, /*!< Provisioner open settings with index completion event */
ESP_BLE_MESH_PROVISIONER_OPEN_SETTINGS_WITH_UID_COMP_EVT, /*!< Provisioner open settings with user id completion event */
ESP_BLE_MESH_PROVISIONER_CLOSE_SETTINGS_WITH_INDEX_COMP_EVT, /*!< Provisioner close settings with index completion event */
ESP_BLE_MESH_PROVISIONER_CLOSE_SETTINGS_WITH_UID_COMP_EVT, /*!< Provisioner close settings with user id completion event */
ESP_BLE_MESH_PROVISIONER_DELETE_SETTINGS_WITH_INDEX_COMP_EVT, /*!< Provisioner delete settings with index completion event */
ESP_BLE_MESH_PROVISIONER_DELETE_SETTINGS_WITH_UID_COMP_EVT, /*!< Provisioner delete settings with user id completion event */
ESP_BLE_MESH_SET_FAST_PROV_INFO_COMP_EVT, /*!< Set fast provisioning information (e.g. unicast address range, net_idx, etc.) completion event */
ESP_BLE_MESH_SET_FAST_PROV_ACTION_COMP_EVT, /*!< Set fast provisioning action completion event */
ESP_BLE_MESH_HEARTBEAT_MESSAGE_RECV_EVT, /*!< Receive Heartbeat message event */
@ -842,8 +872,8 @@ typedef enum {
ESP_BLE_MESH_PROXY_CLIENT_SET_FILTER_TYPE_COMP_EVT, /*!< Proxy Client set filter type completion event */
ESP_BLE_MESH_PROXY_CLIENT_ADD_FILTER_ADDR_COMP_EVT, /*!< Proxy Client add filter address completion event */
ESP_BLE_MESH_PROXY_CLIENT_REMOVE_FILTER_ADDR_COMP_EVT, /*!< Proxy Client remove filter address completion event */
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_MODEL_SUBSCRIBE_GROUP_ADDR_COMP_EVT, /*!< Local model subscribes group address completion event */
ESP_BLE_MESH_MODEL_UNSUBSCRIBE_GROUP_ADDR_COMP_EVT, /*!< Local model unsubscribes group address completion event */
ESP_BLE_MESH_DEINIT_MESH_COMP_EVT, /*!< De-initialize BLE Mesh stack completion event */
ESP_BLE_MESH_PROV_EVT_MAX,
} esp_ble_mesh_prov_cb_event_t;
@ -960,6 +990,31 @@ typedef union {
struct ble_mesh_proxy_gatt_disable_comp_param {
int err_code; /*!< Indicate the result of disabling Mesh Proxy Service */
} node_proxy_gatt_disable_comp; /*!< Event parameter of ESP_BLE_MESH_NODE_PROXY_GATT_DISABLE_COMP_EVT */
/**
* @brief ESP_BLE_MESH_NODE_ADD_LOCAL_NET_KEY_COMP_EVT
*/
struct ble_mesh_node_add_local_net_key_comp_param {
int err_code; /*!< Indicate the result of adding local NetKey by the node */
uint16_t net_idx; /*!< NetKey Index */
} node_add_net_key_comp; /*!< Event parameter of ESP_BLE_MESH_NODE_ADD_LOCAL_NET_KEY_COMP_EVT */
/**
* @brief ESP_BLE_MESH_NODE_ADD_LOCAL_APP_KEY_COMP_EVT
*/
struct ble_mesh_node_add_local_app_key_comp_param {
int err_code; /*!< Indicate the result of adding local AppKey by the node */
uint16_t net_idx; /*!< NetKey Index */
uint16_t app_idx; /*!< AppKey Index */
} node_add_app_key_comp; /*!< Event parameter of ESP_BLE_MESH_NODE_ADD_LOCAL_APP_KEY_COMP_EVT */
/**
* @brief ESP_BLE_MESH_NODE_BIND_APP_KEY_TO_MODEL_COMP_EVT
*/
struct ble_mesh_node_bind_local_mod_app_comp_param {
int err_code; /*!< Indicate the result of binding AppKey with model by the node */
uint16_t element_addr; /*!< Element address */
uint16_t app_idx; /*!< AppKey Index */
uint16_t company_id; /*!< Company ID */
uint16_t model_id; /*!< Model ID */
} node_bind_app_key_to_model_comp; /*!< Event parameter of ESP_BLE_MESH_NODE_BIND_APP_KEY_TO_MODEL_COMP_EVT */
/**
* @brief ESP_BLE_MESH_PROVISIONER_RECV_UNPROV_ADV_PKT_EVT
*/
@ -1107,6 +1162,7 @@ typedef union {
*/
struct ble_mesh_provisioner_add_local_app_key_comp_param {
int err_code; /*!< Indicate the result of adding local AppKey by the Provisioner */
uint16_t net_idx; /*!< NetKey Index */
uint16_t app_idx; /*!< AppKey Index */
} provisioner_add_app_key_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_ADD_LOCAL_APP_KEY_COMP_EVT */
/**
@ -1151,17 +1207,103 @@ typedef union {
/**
* @brief ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_UUID_COMP_EVT
*/
struct ble_mesh_provisioner_delete_node_with_uuid_comp_data_comp_param {
struct ble_mesh_provisioner_delete_node_with_uuid_comp_param {
int err_code; /*!< Indicate the result of deleting node with uuid by the Provisioner */
uint8_t uuid[16]; /*!< Node device uuid */
} provisioner_delete_node_with_uuid_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_UUID_COMP_EVT */
/**
* @brief ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_ADDR_COMP_EVT
*/
struct ble_mesh_provisioner_delete_node_with_addr_comp_data_comp_param {
struct ble_mesh_provisioner_delete_node_with_addr_comp_param {
int err_code; /*!< Indicate the result of deleting node with unicast address by the Provisioner */
uint16_t unicast_addr; /*!< Node unicast address */
} provisioner_delete_node_with_addr_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_ADDR_COMP_EVT */
/**
* @brief ESP_BLE_MESH_PROVISIONER_ENABLE_HEARTBEAT_RECV_COMP_EVT
*/
struct {
int err_code; /*!< Indicate the result of enabling/disabling to receive heartbeat messages by the Provisioner */
bool enable; /*!< Indicate enabling or disabling receiving heartbeat messages */
} provisioner_enable_heartbeat_recv_comp; /*!< Event parameters of ESP_BLE_MESH_PROVISIONER_ENABLE_HEARTBEAT_RECV_COMP_EVT */
/**
* @brief ESP_BLE_MESH_PROVISIONER_SET_HEARTBEAT_FILTER_TYPE_COMP_EVT
*/
struct {
int err_code; /*!< Indicate the result of setting the heartbeat filter type by the Provisioner */
uint8_t type; /*!< Type of the filter used for receiving heartbeat messages */
} provisioner_set_heartbeat_filter_type_comp; /*!< Event parameters of ESP_BLE_MESH_PROVISIONER_SET_HEARTBEAT_FILTER_TYPE_COMP_EVT */
/**
* @brief ESP_BLE_MESH_PROVISIONER_SET_HEARTBEAT_FILTER_INFO_COMP_EVT
*/
struct {
int err_code; /*!< Indicate the result of setting the heartbeat filter address by the Provisioner */
uint8_t op; /*!< Operation (add, remove, clean) */
uint16_t hb_src; /*!< Heartbeat source address */
uint16_t hb_dst; /*!< Heartbeat destination address */
} provisioner_set_heartbeat_filter_info_comp; /*!< Event parameters of ESP_BLE_MESH_PROVISIONER_SET_HEARTBEAT_FILTER_INFO_COMP_EVT */
/**
* @brief ESP_BLE_MESH_PROVISIONER_RECV_HEARTBEAT_MESSAGE_EVT
*/
struct {
uint16_t hb_src; /*!< Heartbeat source address */
uint16_t hb_dst; /*!< Heartbeat destination address */
uint8_t init_ttl; /*!< Heartbeat InitTTL */
uint8_t rx_ttl; /*!< Heartbeat RxTTL */
uint8_t hops; /*!< Heartbeat hops (InitTTL - RxTTL + 1) */
uint16_t feature; /*!< Bit field of currently active features of the node */
int8_t rssi; /*!< RSSI of the heartbeat message */
} provisioner_recv_heartbeat; /*!< Event parameters of ESP_BLE_MESH_PROVISIONER_RECV_HEARTBEAT_MESSAGE_EVT */
/**
* @brief ESP_BLE_MESH_PROVISIONER_DRIECT_ERASE_SETTINGS_COMP_EVT
*/
struct {
int err_code; /*!< Indicate the result of directly erasing settings by the Provisioner */
} provisioner_direct_erase_settings_comp; /*!< Event parameters of ESP_BLE_MESH_PROVISIONER_DRIECT_ERASE_SETTINGS_COMP_EVT */
/**
* @brief ESP_BLE_MESH_PROVISIONER_OPEN_SETTINGS_WITH_INDEX_COMP_EVT
*/
struct {
int err_code; /*!< Indicate the result of opening settings with index by the Provisioner */
uint8_t index; /*!< Index of Provisioner settings */
} provisioner_open_settings_with_index_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_OPEN_SETTINGS_WITH_INDEX_COMP_EVT */
/**
* @brief ESP_BLE_MESH_PROVISIONER_OPEN_SETTINGS_WITH_UID_COMP_EVT
*/
struct {
int err_code; /*!< Indicate the result of opening settings with user id by the Provisioner */
uint8_t index; /*!< Index of Provisioner settings */
char uid[ESP_BLE_MESH_SETTINGS_UID_SIZE + 1]; /*!< Provisioner settings user id */
} provisioner_open_settings_with_uid_comp; /*!< Event parameters of ESP_BLE_MESH_PROVISIONER_OPEN_SETTINGS_WITH_UID_COMP_EVT */
/**
* @brief ESP_BLE_MESH_PROVISIONER_CLOSE_SETTINGS_WITH_INDEX_COMP_EVT
*/
struct {
int err_code; /*!< Indicate the result of closing settings with index by the Provisioner */
uint8_t index; /*!< Index of Provisioner settings */
} provisioner_close_settings_with_index_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_CLOSE_SETTINGS_WITH_INDEX_COMP_EVT */
/**
* @brief ESP_BLE_MESH_PROVISIONER_CLOSE_SETTINGS_WITH_UID_COMP_EVT
*/
struct {
int err_code; /*!< Indicate the result of closing settings with user id by the Provisioner */
uint8_t index; /*!< Index of Provisioner settings */
char uid[ESP_BLE_MESH_SETTINGS_UID_SIZE + 1]; /*!< Provisioner settings user id */
} provisioner_close_settings_with_uid_comp; /*!< Event parameters of ESP_BLE_MESH_PROVISIONER_CLOSE_SETTINGS_WITH_UID_COMP_EVT */
/**
* @brief ESP_BLE_MESH_PROVISIONER_DELETE_SETTINGS_WITH_INDEX_COMP_EVT
*/
struct {
int err_code; /*!< Indicate the result of deleting settings with index by the Provisioner */
uint8_t index; /*!< Index of Provisioner settings */
} provisioner_delete_settings_with_index_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_DELETE_SETTINGS_WITH_INDEX_COMP_EVT */
/**
* @brief ESP_BLE_MESH_PROVISIONER_DELETE_SETTINGS_WITH_UID_COMP_EVT
*/
struct {
int err_code; /*!< Indicate the result of deleting settings with user id by the Provisioner */
uint8_t index; /*!< Index of Provisioner settings */
char uid[ESP_BLE_MESH_SETTINGS_UID_SIZE + 1]; /*!< Provisioner settings user id */
} provisioner_delete_settings_with_uid_comp; /*!< Event parameters of ESP_BLE_MESH_PROVISIONER_DELETE_SETTINGS_WITH_UID_COMP_EVT */
/**
* @brief ESP_BLE_MESH_SET_FAST_PROV_INFO_COMP_EVT
*/
@ -1313,19 +1455,25 @@ typedef union {
uint16_t net_idx; /*!< Corresponding NetKey Index */
} proxy_client_remove_filter_addr_comp; /*!< Event parameter of ESP_BLE_MESH_PROXY_CLIENT_REMOVE_FILTER_ADDR_COMP_EVT */
/**
* @brief ESP_BLE_MESH_START_BLE_ADVERTISING_COMP_EVT
* @brief ESP_BLE_MESH_MODEL_SUBSCRIBE_GROUP_ADDR_COMP_EVT
*/
struct ble_mesh_start_ble_advertising_comp_param {
int err_code; /*!< Indicate the result of starting BLE advertising */
uint8_t index; /*!< Index of the BLE advertising */
} start_ble_advertising_comp; /*!< Event parameter of ESP_BLE_MESH_START_BLE_ADVERTISING_COMP_EVT */
struct ble_mesh_model_sub_group_addr_comp_param {
int err_code; /*!< Indicate the result of local model subscribing group address */
uint16_t element_addr; /*!< Element address */
uint16_t company_id; /*!< Company ID */
uint16_t model_id; /*!< Model ID */
uint16_t group_addr; /*!< Group Address */
} model_sub_group_addr_comp; /*!< Event parameters of ESP_BLE_MESH_MODEL_SUBSCRIBE_GROUP_ADDR_COMP_EVT */
/**
* @brief ESP_BLE_MESH_STOP_BLE_ADVERTISING_COMP_EVT
* @brief ESP_BLE_MESH_MODEL_UNSUBSCRIBE_GROUP_ADDR_COMP_EVT
*/
struct ble_mesh_stop_ble_advertising_comp_param {
int err_code; /*!< Indicate the result of stopping BLE advertising */
uint8_t index; /*!< Index of the BLE advertising */
} stop_ble_advertising_comp; /*!< Event parameter of ESP_BLE_MESH_STOP_BLE_ADVERTISING_COMP_EVT */
struct ble_mesh_model_unsub_group_addr_comp_param {
int err_code; /*!< Indicate the result of local model unsubscribing group address */
uint16_t element_addr; /*!< Element address */
uint16_t company_id; /*!< Company ID */
uint16_t model_id; /*!< Model ID */
uint16_t group_addr; /*!< Group Address */
} model_unsub_group_addr_comp; /*!< Event parameters of ESP_BLE_MESH_MODEL_UNSUBSCRIBE_GROUP_ADDR_COMP_EVT */
/**
* @brief ESP_BLE_MESH_DEINIT_MESH_COMP_EVT
*/
@ -1929,8 +2077,8 @@ typedef struct {
int64_t timestamp; /*!< Time when the last message is received */
} esp_ble_mesh_last_msg_info_t;
#define ESP_BLE_MESH_SERVER_RSP_BY_APP 0 /*!< Response will be sent internally */
#define ESP_BLE_MESH_SERVER_AUTO_RSP 1 /*!< Response need to be sent in the application */
#define ESP_BLE_MESH_SERVER_RSP_BY_APP 0 /*!< Response need to be sent in the application */
#define ESP_BLE_MESH_SERVER_AUTO_RSP 1 /*!< Response will be sent internally */
/** Parameters of the Server Model response control */
typedef struct {
@ -1983,6 +2131,11 @@ typedef union {
uint16_t temperature; /*!< The value of the Light CTL Temperature state */
int16_t delta_uv; /*!< The value of the Light CTL Delta UV state */
} light_ctl_temp_delta_uv; /*!< The Light CTL Temperature & Delta UV states */
struct {
uint16_t lightness; /*!< The value of the Light HSL Lightness state */
uint16_t hue; /*!< The value of the Light HSL Hue state */
uint16_t saturation; /*!< The value of the Light HSL Saturation state */
} light_hsl; /*!< The Light HSL composite state */
struct {
uint16_t lightness; /*!< The value of the Light HSL Lightness state */
} light_hsl_lightness; /*!< The Light HSL Lightness state */
@ -2010,6 +2163,7 @@ typedef enum {
ESP_BLE_MESH_LIGHT_LIGHTNESS_LINEAR_STATE,
ESP_BLE_MESH_LIGHT_CTL_LIGHTNESS_STATE,
ESP_BLE_MESH_LIGHT_CTL_TEMP_DELTA_UV_STATE,
ESP_BLE_MESH_LIGHT_HSL_STATE,
ESP_BLE_MESH_LIGHT_HSL_LIGHTNESS_STATE,
ESP_BLE_MESH_LIGHT_HSL_HUE_STATE,
ESP_BLE_MESH_LIGHT_HSL_SATURATION_STATE,

View File

@ -19,6 +19,7 @@
#include "btc_ble_mesh_config_model.h"
#include "esp_ble_mesh_config_model_api.h"
#if CONFIG_BLE_MESH_CFG_CLI
esp_err_t esp_ble_mesh_register_config_client_callback(esp_ble_mesh_cfg_client_cb_t callback)
{
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
@ -26,13 +27,6 @@ esp_err_t esp_ble_mesh_register_config_client_callback(esp_ble_mesh_cfg_client_c
return (btc_profile_cb_set(BTC_PID_CONFIG_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_register_config_server_callback(esp_ble_mesh_cfg_server_cb_t callback)
{
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);
}
static bool config_client_get_need_param(esp_ble_mesh_opcode_t opcode)
{
switch (opcode) {
@ -53,13 +47,15 @@ static bool config_client_get_need_param(esp_ble_mesh_opcode_t opcode)
}
esp_err_t esp_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_cfg_client_get_state_t *get_state)
esp_ble_mesh_cfg_client_get_state_t *get_state)
{
btc_ble_mesh_config_client_args_t arg = {0};
btc_msg_t msg = {0};
if (!params || !params->model || !ESP_BLE_MESH_ADDR_IS_UNICAST(params->ctx.addr) ||
(config_client_get_need_param(params->opcode) && !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;
}
@ -76,13 +72,15 @@ esp_err_t esp_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param_
}
esp_err_t esp_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_cfg_client_set_state_t *set_state)
esp_ble_mesh_cfg_client_set_state_t *set_state)
{
btc_ble_mesh_config_client_args_t arg = {0};
btc_msg_t msg = {0};
if (!params || !params->model || !ESP_BLE_MESH_ADDR_IS_UNICAST(params->ctx.addr) ||
(params->opcode != ESP_BLE_MESH_MODEL_OP_NODE_RESET && !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;
}
@ -97,3 +95,11 @@ esp_err_t esp_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param_
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_config_client_args_t), btc_ble_mesh_config_client_arg_deep_copy)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif /* CONFIG_BLE_MESH_CFG_CLI */
esp_err_t esp_ble_mesh_register_config_server_callback(esp_ble_mesh_cfg_server_cb_t callback)
{
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
return (btc_profile_cb_set(BTC_PID_CONFIG_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
}

View File

@ -19,6 +19,7 @@
#include "btc_ble_mesh_generic_model.h"
#include "esp_ble_mesh_generic_model_api.h"
#if CONFIG_BLE_MESH_GENERIC_CLIENT
esp_err_t esp_ble_mesh_register_generic_client_callback(esp_ble_mesh_generic_client_cb_t callback)
{
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
@ -40,13 +41,16 @@ static bool generic_client_get_need_param(esp_ble_mesh_opcode_t opcode)
}
esp_err_t esp_ble_mesh_generic_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_generic_client_get_state_t *get_state)
esp_ble_mesh_generic_client_get_state_t *get_state)
{
btc_ble_mesh_generic_client_args_t arg = {0};
btc_msg_t msg = {0};
if (!params || !params->model || !params->ctx.addr ||
(generic_client_get_need_param(params->opcode) && !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;
}
@ -63,12 +67,15 @@ esp_err_t esp_ble_mesh_generic_client_get_state(esp_ble_mesh_client_common_param
}
esp_err_t esp_ble_mesh_generic_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_generic_client_set_state_t *set_state)
esp_ble_mesh_generic_client_set_state_t *set_state)
{
btc_ble_mesh_generic_client_args_t arg = {0};
btc_msg_t msg = {0};
if (!params || !params->model || !params->ctx.addr || !set_state) {
if (params == NULL || params->model == NULL || set_state == NULL ||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED) {
return ESP_ERR_INVALID_ARG;
}
@ -83,10 +90,13 @@ esp_err_t esp_ble_mesh_generic_client_set_state(esp_ble_mesh_client_common_param
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_generic_client_args_t), btc_ble_mesh_generic_client_arg_deep_copy)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif /* CONFIG_BLE_MESH_GENERIC_CLIENT */
#if CONFIG_BLE_MESH_GENERIC_SERVER
esp_err_t esp_ble_mesh_register_generic_server_callback(esp_ble_mesh_generic_server_cb_t callback)
{
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
return (btc_profile_cb_set(BTC_PID_GENERIC_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
}
#endif /* CONFIG_BLE_MESH_GENERIC_SERVER */

View File

@ -19,6 +19,7 @@
#include "btc_ble_mesh_health_model.h"
#include "esp_ble_mesh_health_model_api.h"
#if CONFIG_BLE_MESH_HEALTH_CLI
esp_err_t esp_ble_mesh_register_health_client_callback(esp_ble_mesh_health_client_cb_t callback)
{
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
@ -26,21 +27,17 @@ esp_err_t esp_ble_mesh_register_health_client_callback(esp_ble_mesh_health_clien
return (btc_profile_cb_set(BTC_PID_HEALTH_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_register_health_server_callback(esp_ble_mesh_health_server_cb_t callback)
{
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
return (btc_profile_cb_set(BTC_PID_HEALTH_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_health_client_get_state_t *get_state)
esp_ble_mesh_health_client_get_state_t *get_state)
{
btc_ble_mesh_health_client_args_t arg = {0};
btc_msg_t msg = {0};
if (!params || !params->model || !params->ctx.addr || (!get_state &&
params->opcode == ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET)) {
if (params == NULL || params->model == NULL ||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED ||
(params->opcode == ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET && get_state == NULL)) {
return ESP_ERR_INVALID_ARG;
}
@ -57,12 +54,15 @@ esp_err_t esp_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_
}
esp_err_t esp_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_health_client_set_state_t *set_state)
esp_ble_mesh_health_client_set_state_t *set_state)
{
btc_ble_mesh_health_client_args_t arg = {0};
btc_msg_t msg = {0};
if (!params || !params->model || !params->ctx.addr || !set_state) {
if (params == NULL || params->model == NULL || set_state == NULL ||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED) {
return ESP_ERR_INVALID_ARG;
}
@ -77,6 +77,15 @@ esp_err_t esp_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param_
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_health_client_args_t), btc_ble_mesh_health_client_arg_deep_copy)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif /* CONFIG_BLE_MESH_HEALTH_CLI */
#if CONFIG_BLE_MESH_HEALTH_SRV
esp_err_t esp_ble_mesh_register_health_server_callback(esp_ble_mesh_health_server_cb_t callback)
{
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
return (btc_profile_cb_set(BTC_PID_HEALTH_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_health_server_fault_update(esp_ble_mesh_elem_t *element)
{
@ -97,3 +106,4 @@ esp_err_t esp_ble_mesh_health_server_fault_update(esp_ble_mesh_elem_t *element)
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_health_server_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif /* CONFIG_BLE_MESH_HEALTH_SRV */

View File

@ -19,6 +19,7 @@
#include "btc_ble_mesh_lighting_model.h"
#include "esp_ble_mesh_lighting_model_api.h"
#if CONFIG_BLE_MESH_LIGHTING_CLIENT
esp_err_t esp_ble_mesh_register_light_client_callback(esp_ble_mesh_light_client_cb_t callback)
{
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
@ -27,13 +28,16 @@ esp_err_t esp_ble_mesh_register_light_client_callback(esp_ble_mesh_light_client_
}
esp_err_t esp_ble_mesh_light_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_light_client_get_state_t *get_state)
esp_ble_mesh_light_client_get_state_t *get_state)
{
btc_ble_mesh_lighting_client_args_t arg = {0};
btc_msg_t msg = {0};
if (!params || !params->model || !params->ctx.addr || (!get_state &&
params->opcode == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_GET)) {
if (params == NULL || params->model == NULL ||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED ||
(params->opcode == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_GET && get_state == NULL)) {
return ESP_ERR_INVALID_ARG;
}
@ -50,12 +54,15 @@ esp_err_t esp_ble_mesh_light_client_get_state(esp_ble_mesh_client_common_param_t
}
esp_err_t esp_ble_mesh_light_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_light_client_set_state_t *set_state)
esp_ble_mesh_light_client_set_state_t *set_state)
{
btc_ble_mesh_lighting_client_args_t arg = {0};
btc_msg_t msg = {0};
if (!params || !params->model || !params->ctx.addr || !set_state) {
if (params == NULL || params->model == NULL || set_state == NULL ||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED) {
return ESP_ERR_INVALID_ARG;
}
@ -70,10 +77,13 @@ esp_err_t esp_ble_mesh_light_client_set_state(esp_ble_mesh_client_common_param_t
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_lighting_client_args_t), btc_ble_mesh_lighting_client_arg_deep_copy)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif /* CONFIG_BLE_MESH_LIGHTING_CLIENT */
#if CONFIG_BLE_MESH_LIGHTING_SERVER
esp_err_t esp_ble_mesh_register_lighting_server_callback(esp_ble_mesh_lighting_server_cb_t callback)
{
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
return (btc_profile_cb_set(BTC_PID_LIGHTING_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
}
#endif /* CONFIG_BLE_MESH_LIGHTING_SERVER */

View File

@ -19,6 +19,7 @@
#include "btc_ble_mesh_sensor_model.h"
#include "esp_ble_mesh_sensor_model_api.h"
#if CONFIG_BLE_MESH_SENSOR_CLI
esp_err_t esp_ble_mesh_register_sensor_client_callback(esp_ble_mesh_sensor_client_cb_t callback)
{
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
@ -27,12 +28,15 @@ esp_err_t esp_ble_mesh_register_sensor_client_callback(esp_ble_mesh_sensor_clien
}
esp_err_t esp_ble_mesh_sensor_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_sensor_client_get_state_t *get_state)
esp_ble_mesh_sensor_client_get_state_t *get_state)
{
btc_ble_mesh_sensor_client_args_t arg = {0};
btc_msg_t msg = {0};
if (!params || !params->model || !params->ctx.addr || !get_state) {
if (params == NULL || params->model == NULL || get_state == NULL ||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED) {
return ESP_ERR_INVALID_ARG;
}
@ -49,12 +53,15 @@ esp_err_t esp_ble_mesh_sensor_client_get_state(esp_ble_mesh_client_common_param_
}
esp_err_t esp_ble_mesh_sensor_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_sensor_client_set_state_t *set_state)
esp_ble_mesh_sensor_client_set_state_t *set_state)
{
btc_ble_mesh_sensor_client_args_t arg = {0};
btc_msg_t msg = {0};
if (!params || !params->model || !params->ctx.addr || !set_state) {
if (params == NULL || params->model == NULL || set_state == NULL ||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED) {
return ESP_ERR_INVALID_ARG;
}
@ -69,12 +76,13 @@ esp_err_t esp_ble_mesh_sensor_client_set_state(esp_ble_mesh_client_common_param_
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_sensor_client_args_t), btc_ble_mesh_sensor_client_arg_deep_copy)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif /* CONFIG_BLE_MESH_SENSOR_CLI */
#if CONFIG_BLE_MESH_SENSOR_SERVER
esp_err_t esp_ble_mesh_register_sensor_server_callback(esp_ble_mesh_sensor_server_cb_t callback)
{
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
return (btc_profile_cb_set(BTC_PID_SENSOR_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
}
#endif /* CONFIG_BLE_MESH_SENSOR_SERVER */

View File

@ -19,6 +19,7 @@
#include "btc_ble_mesh_time_scene_model.h"
#include "esp_ble_mesh_time_scene_model_api.h"
#if CONFIG_BLE_MESH_TIME_SCENE_CLIENT
esp_err_t esp_ble_mesh_register_time_scene_client_callback(esp_ble_mesh_time_scene_client_cb_t callback)
{
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
@ -27,13 +28,16 @@ esp_err_t esp_ble_mesh_register_time_scene_client_callback(esp_ble_mesh_time_sce
}
esp_err_t esp_ble_mesh_time_scene_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_time_scene_client_get_state_t *get_state)
esp_ble_mesh_time_scene_client_get_state_t *get_state)
{
btc_ble_mesh_time_scene_client_args_t arg = {0};
btc_msg_t msg = {0};
if (!params || !params->model || !params->ctx.addr || (!get_state &&
params->opcode == ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_GET)) {
if (params == NULL || params->model == NULL ||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED ||
(params->opcode == ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_GET && get_state == NULL)) {
return ESP_ERR_INVALID_ARG;
}
@ -50,12 +54,15 @@ esp_err_t esp_ble_mesh_time_scene_client_get_state(esp_ble_mesh_client_common_pa
}
esp_err_t esp_ble_mesh_time_scene_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_time_scene_client_set_state_t *set_state)
esp_ble_mesh_time_scene_client_set_state_t *set_state)
{
btc_ble_mesh_time_scene_client_args_t arg = {0};
btc_msg_t msg = {0};
if (!params || !params->model || !params->ctx.addr || !set_state) {
if (params == NULL || params->model == NULL || set_state == NULL ||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED) {
return ESP_ERR_INVALID_ARG;
}
@ -70,11 +77,13 @@ esp_err_t esp_ble_mesh_time_scene_client_set_state(esp_ble_mesh_client_common_pa
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_time_scene_client_args_t), btc_ble_mesh_time_scene_client_arg_deep_copy)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif /* CONFIG_BLE_MESH_TIME_SCENE_CLIENT */
#if CONFIG_BLE_MESH_TIME_SCENE_SERVER
esp_err_t esp_ble_mesh_register_time_scene_server_callback(esp_ble_mesh_time_scene_server_cb_t callback)
{
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
return (btc_profile_cb_set(BTC_PID_TIME_SCENE_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
}
#endif /* CONFIG_BLE_MESH_TIME_SCENE_SERVER */

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1,203 @@
// Copyright 2020 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <stdint.h>
#include <string.h>
#include "btc_ble_mesh_ble.h"
#include "adv.h"
#include "scan.h"
#include "mesh_bearer_adapt.h"
#include "esp_ble_mesh_ble_api.h"
#if CONFIG_BLE_MESH_BLE_COEX_SUPPORT
static void btc_ble_mesh_ble_copy_req_data(btc_msg_t *msg, void *p_dst, void *p_src)
{
#if CONFIG_BLE_MESH_SUPPORT_BLE_SCAN
esp_ble_mesh_ble_cb_param_t *p_dst_data = (esp_ble_mesh_ble_cb_param_t *)p_dst;
esp_ble_mesh_ble_cb_param_t *p_src_data = (esp_ble_mesh_ble_cb_param_t *)p_src;
if (!msg || !p_src_data || !p_dst_data) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (msg->act) {
case ESP_BLE_MESH_SCAN_BLE_ADVERTISING_PKT_EVT:
if (p_src_data->scan_ble_adv_pkt.data && p_src_data->scan_ble_adv_pkt.length) {
p_dst_data->scan_ble_adv_pkt.length = p_src_data->scan_ble_adv_pkt.length;
p_dst_data->scan_ble_adv_pkt.data = bt_mesh_calloc(p_src_data->scan_ble_adv_pkt.length);
if (p_dst_data->scan_ble_adv_pkt.data) {
memcpy(p_dst_data->scan_ble_adv_pkt.data, p_src_data->scan_ble_adv_pkt.data,
p_src_data->scan_ble_adv_pkt.length);
} else {
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
}
}
break;
default:
break;
}
#endif /* CONFIG_BLE_MESH_SUPPORT_BLE_SCAN */
}
static void btc_ble_mesh_ble_free_req_data(btc_msg_t *msg)
{
#if CONFIG_BLE_MESH_SUPPORT_BLE_SCAN
esp_ble_mesh_ble_cb_param_t *arg = NULL;
if (!msg || !msg->arg) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
arg = (esp_ble_mesh_ble_cb_param_t *)msg->arg;
switch (msg->act) {
case ESP_BLE_MESH_SCAN_BLE_ADVERTISING_PKT_EVT:
if (arg->scan_ble_adv_pkt.data) {
bt_mesh_free(arg->scan_ble_adv_pkt.data);
}
break;
default:
break;
}
#endif /* CONFIG_BLE_MESH_SUPPORT_BLE_SCAN */
}
static void btc_ble_mesh_ble_callback(esp_ble_mesh_ble_cb_param_t *cb_params, uint8_t act)
{
btc_msg_t msg = {0};
/* If corresponding callback is not registered, event will not be posted. */
if (!btc_profile_cb_get(BTC_PID_BLE_MESH_BLE_COEX)) {
return;
}
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_BLE_MESH_BLE_COEX;
msg.act = act;
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_ble_cb_param_t),
btc_ble_mesh_ble_copy_req_data);
}
#if CONFIG_BLE_MESH_SUPPORT_BLE_SCAN
void bt_mesh_ble_scan_cb_evt_to_btc(const bt_mesh_addr_t *addr,
uint8_t adv_type, uint8_t data[],
uint16_t length, int8_t rssi)
{
esp_ble_mesh_ble_cb_param_t param = {0};
if (addr == NULL) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
memcpy(param.scan_ble_adv_pkt.addr, addr->val, sizeof(addr->val));
param.scan_ble_adv_pkt.addr_type = addr->type;
if (data && length) {
param.scan_ble_adv_pkt.data = data;
param.scan_ble_adv_pkt.length = length;
}
param.scan_ble_adv_pkt.adv_type = adv_type;
param.scan_ble_adv_pkt.rssi = rssi;
btc_ble_mesh_ble_callback(&param, ESP_BLE_MESH_SCAN_BLE_ADVERTISING_PKT_EVT);
}
#endif /* CONFIG_BLE_MESH_SUPPORT_BLE_SCAN */
void btc_ble_mesh_ble_call_handler(btc_msg_t *msg)
{
esp_ble_mesh_ble_cb_param_t param = {0};
btc_ble_mesh_ble_args_t *arg = NULL;
if (!msg || !msg->arg) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
arg = (btc_ble_mesh_ble_args_t *)msg->arg;
switch (msg->act) {
#if CONFIG_BLE_MESH_SUPPORT_BLE_ADV
case BTC_BLE_MESH_ACT_START_BLE_ADV: {
struct bt_mesh_ble_adv_param *set = (struct bt_mesh_ble_adv_param *)&arg->start_ble_adv.param;
struct bt_mesh_ble_adv_data *data = NULL;
if (arg->start_ble_adv.data.adv_data_len || arg->start_ble_adv.data.scan_rsp_data_len) {
data = (struct bt_mesh_ble_adv_data *)&arg->start_ble_adv.data;
}
param.start_ble_advertising_comp.err_code =
bt_mesh_start_ble_advertising(set, data, &param.start_ble_advertising_comp.index);
btc_ble_mesh_ble_callback(&param, ESP_BLE_MESH_START_BLE_ADVERTISING_COMP_EVT);
break;
}
case BTC_BLE_MESH_ACT_STOP_BLE_ADV:
param.stop_ble_advertising_comp.index = arg->stop_ble_adv.index;
param.stop_ble_advertising_comp.err_code =
bt_mesh_stop_ble_advertising(arg->stop_ble_adv.index);
btc_ble_mesh_ble_callback(&param, ESP_BLE_MESH_STOP_BLE_ADVERTISING_COMP_EVT);
break;
#endif /* CONFIG_BLE_MESH_SUPPORT_BLE_ADV */
#if CONFIG_BLE_MESH_SUPPORT_BLE_SCAN
case BTC_BLE_MESH_ACT_START_BLE_SCAN:
param.start_ble_scan_comp.err_code =
bt_mesh_start_ble_scan((struct bt_mesh_ble_scan_param *)&arg->start_ble_scan.param);
btc_ble_mesh_ble_callback(&param, ESP_BLE_MESH_START_BLE_SCANNING_COMP_EVT);
break;
case BTC_BLE_MESH_ACT_STOP_BLE_SCAN:
param.stop_ble_scan_comp.err_code = bt_mesh_stop_ble_scan();
btc_ble_mesh_ble_callback(&param, ESP_BLE_MESH_STOP_BLE_SCANNING_COMP_EVT);
break;
#endif /* CONFIG_BLE_MESH_SUPPORT_BLE_SCAN */
default:
return;
}
}
static inline void btc_ble_mesh_ble_cb_to_app(esp_ble_mesh_ble_cb_event_t event,
esp_ble_mesh_ble_cb_param_t *param)
{
esp_ble_mesh_ble_cb_t btc_ble_mesh_cb =
(esp_ble_mesh_ble_cb_t)btc_profile_cb_get(BTC_PID_BLE_MESH_BLE_COEX);
if (btc_ble_mesh_cb) {
btc_ble_mesh_cb(event, param);
}
}
void btc_ble_mesh_ble_cb_handler(btc_msg_t *msg)
{
esp_ble_mesh_ble_cb_param_t *param = NULL;
if (!msg) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
param = (esp_ble_mesh_ble_cb_param_t *)msg->arg;
if (msg->act < ESP_BLE_MESH_BLE_EVT_MAX) {
btc_ble_mesh_ble_cb_to_app(msg->act, param);
} else {
BT_ERR("%s, Unknown act %d", __func__, msg->act);
}
btc_ble_mesh_ble_free_req_data(msg);
}
#endif /* CONFIG_BLE_MESH_BLE_COEX_SUPPORT */

View File

@ -17,17 +17,15 @@
#include "btc_ble_mesh_config_model.h"
#include "foundation.h"
#include "cfg_cli.h"
#include "esp_ble_mesh_config_model_api.h"
#define CID_NVAL 0xffff
extern s32_t config_msg_timeout;
#if CONFIG_BLE_MESH_CFG_CLI
#include "cfg_cli.h"
/* Configuration Client Model related functions */
static inline void btc_ble_mesh_config_client_cb_to_app(esp_ble_mesh_cfg_client_cb_event_t event,
esp_ble_mesh_cfg_client_cb_param_t *param)
esp_ble_mesh_cfg_client_cb_param_t *param)
{
esp_ble_mesh_cfg_client_cb_t btc_ble_mesh_cb =
(esp_ble_mesh_cfg_client_cb_t)btc_profile_cb_get(BTC_PID_CONFIG_CLIENT);
@ -53,7 +51,7 @@ void btc_ble_mesh_config_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
memcpy(dst->cfg_client_get_state.params, src->cfg_client_get_state.params,
sizeof(esp_ble_mesh_client_common_param_t));
} else {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
break;
}
if (src->cfg_client_get_state.get_state) {
@ -62,7 +60,7 @@ void btc_ble_mesh_config_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
memcpy(dst->cfg_client_get_state.get_state, src->cfg_client_get_state.get_state,
sizeof(esp_ble_mesh_cfg_client_get_state_t));
} else {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
}
}
break;
@ -73,7 +71,7 @@ void btc_ble_mesh_config_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
memcpy(dst->cfg_client_set_state.params, src->cfg_client_set_state.params,
sizeof(esp_ble_mesh_client_common_param_t));
} else {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
break;
}
if (src->cfg_client_set_state.set_state) {
@ -82,13 +80,13 @@ void btc_ble_mesh_config_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
memcpy(dst->cfg_client_set_state.set_state, src->cfg_client_set_state.set_state,
sizeof(esp_ble_mesh_cfg_client_set_state_t));
} else {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
}
}
break;
}
default:
BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act);
BT_DBG("%s, Unknown act %d", __func__, msg->act);
break;
}
}
@ -130,7 +128,7 @@ static void btc_ble_mesh_config_client_copy_req_data(btc_msg_t *msg, void *p_des
{
esp_ble_mesh_cfg_client_cb_param_t *p_dest_data = (esp_ble_mesh_cfg_client_cb_param_t *)p_dest;
esp_ble_mesh_cfg_client_cb_param_t *p_src_data = (esp_ble_mesh_cfg_client_cb_param_t *)p_src;
u16_t length = 0U;
uint16_t length = 0U;
if (!msg || !p_src_data || !p_dest_data) {
BT_ERR("%s, Invalid parameter", __func__);
@ -140,7 +138,7 @@ static void btc_ble_mesh_config_client_copy_req_data(btc_msg_t *msg, void *p_des
if (p_src_data->params) {
p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (!p_dest_data->params) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
@ -159,7 +157,7 @@ static void btc_ble_mesh_config_client_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->status_cb.comp_data_status.composition_data->len;
p_dest_data->status_cb.comp_data_status.composition_data = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.comp_data_status.composition_data) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.comp_data_status.composition_data,
@ -175,7 +173,7 @@ static void btc_ble_mesh_config_client_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->status_cb.model_sub_list.sub_addr->len;
p_dest_data->status_cb.model_sub_list.sub_addr = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.model_sub_list.sub_addr) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.model_sub_list.sub_addr,
@ -189,7 +187,7 @@ static void btc_ble_mesh_config_client_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->status_cb.netkey_list.net_idx->len;
p_dest_data->status_cb.netkey_list.net_idx = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.netkey_list.net_idx) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.netkey_list.net_idx,
@ -203,7 +201,7 @@ static void btc_ble_mesh_config_client_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->status_cb.appkey_list.app_idx->len;
p_dest_data->status_cb.appkey_list.app_idx = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.appkey_list.app_idx) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.appkey_list.app_idx,
@ -219,7 +217,7 @@ static void btc_ble_mesh_config_client_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->status_cb.model_app_list.app_idx->len;
p_dest_data->status_cb.model_app_list.app_idx = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.model_app_list.app_idx) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.model_app_list.app_idx,
@ -308,18 +306,17 @@ static void btc_ble_mesh_config_client_callback(esp_ble_mesh_cfg_client_cb_param
msg.pid = BTC_PID_CONFIG_CLIENT;
msg.act = act;
btc_transfer_context(&msg, cb_params,
sizeof(esp_ble_mesh_cfg_client_cb_param_t), btc_ble_mesh_config_client_copy_req_data);
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_cfg_client_cb_param_t),
btc_ble_mesh_config_client_copy_req_data);
}
void bt_mesh_config_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len)
void bt_mesh_config_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const uint8_t *val, size_t len)
{
esp_ble_mesh_cfg_client_cb_param_t cb_params = {0};
esp_ble_mesh_client_common_param_t params = {0};
size_t length = 0U;
uint8_t act = 0U;
if (!model || !ctx) {
@ -341,7 +338,7 @@ void bt_mesh_config_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
act = ESP_BLE_MESH_CFG_CLIENT_TIMEOUT_EVT;
break;
default:
BT_ERR("%s, Unknown config client event type %d", __func__, evt_type);
BT_ERR("Unknown Config client event type %d", evt_type);
return;
}
@ -353,41 +350,40 @@ void bt_mesh_config_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
params.ctx.recv_ttl = ctx->recv_ttl;
params.ctx.recv_op = ctx->recv_op;
params.ctx.recv_dst = ctx->recv_dst;
params.ctx.recv_rssi = ctx->recv_rssi;
params.ctx.send_ttl = ctx->send_ttl;
cb_params.error_code = 0;
cb_params.params = &params;
if (val && len) {
length = (len <= sizeof(cb_params.status_cb)) ? len : sizeof(cb_params.status_cb);
memcpy(&cb_params.status_cb, val, length);
memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb)));
}
btc_ble_mesh_config_client_callback(&cb_params, act);
return;
}
void btc_ble_mesh_config_client_publish_callback(u32_t opcode,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
void btc_ble_mesh_config_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
if (!model || !ctx || !buf) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
bt_mesh_config_client_cb_evt_to_btc(opcode,
BTC_BLE_MESH_EVT_CONFIG_CLIENT_PUBLISH, model, ctx, buf->data, buf->len);
bt_mesh_config_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_CONFIG_CLIENT_PUBLISH,
model, ctx, buf->data, buf->len);
return;
}
static int btc_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_cfg_client_get_state_t *get,
esp_ble_mesh_cfg_client_cb_param_t *cb)
esp_ble_mesh_cfg_client_get_state_t *get)
{
struct bt_mesh_msg_ctx ctx = {0};
bt_mesh_client_common_param_t param = {0};
if (!params || !cb) {
if (params == NULL) {
BT_ERR("%s, Invalid parameter", __func__);
return -EINVAL;
}
@ -404,7 +400,7 @@ static int btc_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param
case ESP_BLE_MESH_MODEL_OP_KEY_REFRESH_PHASE_GET:
case ESP_BLE_MESH_MODEL_OP_LPN_POLLTIMEOUT_GET:
if (get == NULL) {
BT_ERR("%s, Invalid config client get", __func__);
BT_ERR("Invalid Configuration Get");
return -EINVAL;
}
break;
@ -412,120 +408,120 @@ static int btc_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param
break;
}
ctx.net_idx = params->ctx.net_idx;
ctx.app_idx = BLE_MESH_KEY_DEV;
ctx.addr = params->ctx.addr;
ctx.send_rel = params->ctx.send_rel;
ctx.send_ttl = params->ctx.send_ttl;
param.opcode = params->opcode;
param.model = (struct bt_mesh_model *)params->model;
param.ctx.net_idx = params->ctx.net_idx;
param.ctx.app_idx = BLE_MESH_KEY_DEV;
param.ctx.addr = params->ctx.addr;
param.ctx.send_rel = params->ctx.send_rel;
param.ctx.send_ttl = params->ctx.send_ttl;
param.msg_timeout = params->msg_timeout;
param.msg_role = params->msg_role;
config_msg_timeout = params->msg_timeout;
switch (params->opcode) {
switch (param.opcode) {
case ESP_BLE_MESH_MODEL_OP_BEACON_GET:
return (cb->error_code = bt_mesh_cfg_beacon_get(&ctx));
return bt_mesh_cfg_beacon_get(&param);
case ESP_BLE_MESH_MODEL_OP_DEFAULT_TTL_GET:
return (cb->error_code = bt_mesh_cfg_ttl_get(&ctx));
return bt_mesh_cfg_ttl_get(&param);
case ESP_BLE_MESH_MODEL_OP_FRIEND_GET:
return (cb->error_code = bt_mesh_cfg_friend_get(&ctx));
return bt_mesh_cfg_friend_get(&param);
case ESP_BLE_MESH_MODEL_OP_GATT_PROXY_GET:
return (cb->error_code = bt_mesh_cfg_gatt_proxy_get(&ctx));
return bt_mesh_cfg_gatt_proxy_get(&param);
case ESP_BLE_MESH_MODEL_OP_RELAY_GET:
return (cb->error_code = bt_mesh_cfg_relay_get(&ctx));
return bt_mesh_cfg_relay_get(&param);
case ESP_BLE_MESH_MODEL_OP_MODEL_PUB_GET:
return (cb->error_code =
bt_mesh_cfg_mod_pub_get(&ctx, get->model_pub_get.element_addr,
get->model_pub_get.model_id, get->model_pub_get.company_id));
return bt_mesh_cfg_mod_pub_get(&param, get->model_pub_get.element_addr,
get->model_pub_get.model_id,
get->model_pub_get.company_id);
case ESP_BLE_MESH_MODEL_OP_HEARTBEAT_PUB_GET:
return (cb->error_code = bt_mesh_cfg_hb_pub_get(&ctx));
return bt_mesh_cfg_hb_pub_get(&param);
case ESP_BLE_MESH_MODEL_OP_HEARTBEAT_SUB_GET:
return (cb->error_code = bt_mesh_cfg_hb_sub_get(&ctx));
return bt_mesh_cfg_hb_sub_get(&param);
case ESP_BLE_MESH_MODEL_OP_COMPOSITION_DATA_GET:
return (cb->error_code = bt_mesh_cfg_comp_data_get(&ctx, get->comp_data_get.page));
return bt_mesh_cfg_comp_data_get(&param, get->comp_data_get.page);
case ESP_BLE_MESH_MODEL_OP_SIG_MODEL_SUB_GET:
return (cb->error_code =
bt_mesh_cfg_mod_sub_get(&ctx, get->sig_model_sub_get.element_addr,
get->sig_model_sub_get.model_id));
return bt_mesh_cfg_mod_sub_get(&param, get->sig_model_sub_get.element_addr,
get->sig_model_sub_get.model_id);
case ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_SUB_GET:
return (cb->error_code =
bt_mesh_cfg_mod_sub_get_vnd(&ctx, get->vnd_model_sub_get.element_addr,
get->vnd_model_sub_get.model_id, get->vnd_model_sub_get.company_id));
return bt_mesh_cfg_mod_sub_get_vnd(&param, get->vnd_model_sub_get.element_addr,
get->vnd_model_sub_get.model_id,
get->vnd_model_sub_get.company_id);
case ESP_BLE_MESH_MODEL_OP_NET_KEY_GET:
return (cb->error_code = bt_mesh_cfg_net_key_get(&ctx));
return bt_mesh_cfg_net_key_get(&param);
case ESP_BLE_MESH_MODEL_OP_APP_KEY_GET:
return (cb->error_code = bt_mesh_cfg_app_key_get(&ctx, get->app_key_get.net_idx));
return bt_mesh_cfg_app_key_get(&param, get->app_key_get.net_idx);
case ESP_BLE_MESH_MODEL_OP_NODE_IDENTITY_GET:
return (cb->error_code = bt_mesh_cfg_node_identity_get(&ctx, get->node_identity_get.net_idx));
return bt_mesh_cfg_node_identity_get(&param, get->node_identity_get.net_idx);
case ESP_BLE_MESH_MODEL_OP_SIG_MODEL_APP_GET:
return (cb->error_code =
bt_mesh_cfg_mod_app_get(&ctx, get->sig_model_app_get.element_addr,
get->sig_model_app_get.model_id));
return bt_mesh_cfg_mod_app_get(&param, get->sig_model_app_get.element_addr,
get->sig_model_app_get.model_id);
case ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_APP_GET:
return (cb->error_code =
bt_mesh_cfg_mod_app_get_vnd(&ctx, get->vnd_model_app_get.element_addr,
get->vnd_model_app_get.model_id, get->vnd_model_app_get.company_id));
return bt_mesh_cfg_mod_app_get_vnd(&param, get->vnd_model_app_get.element_addr,
get->vnd_model_app_get.model_id,
get->vnd_model_app_get.company_id);
case ESP_BLE_MESH_MODEL_OP_KEY_REFRESH_PHASE_GET:
return (cb->error_code = bt_mesh_cfg_kr_phase_get(&ctx, get->kr_phase_get.net_idx));
return bt_mesh_cfg_kr_phase_get(&param, get->kr_phase_get.net_idx);
case ESP_BLE_MESH_MODEL_OP_LPN_POLLTIMEOUT_GET:
return (cb->error_code = bt_mesh_cfg_lpn_timeout_get(&ctx, get->lpn_pollto_get.lpn_addr));
return bt_mesh_cfg_lpn_timeout_get(&param, get->lpn_pollto_get.lpn_addr);
case ESP_BLE_MESH_MODEL_OP_NETWORK_TRANSMIT_GET:
return (cb->error_code = bt_mesh_cfg_net_transmit_get(&ctx));
return bt_mesh_cfg_net_transmit_get(&param);
default:
BT_ERR("%s, Invalid opcode 0x%x", __func__, params->opcode);
return (cb->error_code = -EINVAL);
BT_ERR("Invalid Configuration Get opcode 0x%04x", param.opcode);
return -EINVAL;
}
return 0;
}
static int btc_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_cfg_client_set_state_t *set,
esp_ble_mesh_cfg_client_cb_param_t *cb)
esp_ble_mesh_cfg_client_set_state_t *set)
{
struct bt_mesh_msg_ctx ctx = {0};
bt_mesh_client_common_param_t param = {0};
if (!params || !cb) {
if (params == NULL) {
BT_ERR("%s, Invalid parameter", __func__);
return -EINVAL;
}
if (params->opcode != ESP_BLE_MESH_MODEL_OP_NODE_RESET && set == NULL) {
BT_ERR("%s, Invalid config client set", __func__);
BT_ERR("Invalid Configuration Set");
return -EINVAL;
}
ctx.net_idx = params->ctx.net_idx;
ctx.app_idx = BLE_MESH_KEY_DEV;
ctx.addr = params->ctx.addr;
ctx.send_rel = params->ctx.send_rel;
ctx.send_ttl = params->ctx.send_ttl;
param.opcode = params->opcode;
param.model = (struct bt_mesh_model *)params->model;
param.ctx.net_idx = params->ctx.net_idx;
param.ctx.app_idx = BLE_MESH_KEY_DEV;
param.ctx.addr = params->ctx.addr;
param.ctx.send_rel = params->ctx.send_rel;
param.ctx.send_ttl = params->ctx.send_ttl;
param.msg_timeout = params->msg_timeout;
param.msg_role = params->msg_role;
config_msg_timeout = params->msg_timeout;
switch (params->opcode) {
switch (param.opcode) {
case ESP_BLE_MESH_MODEL_OP_BEACON_SET:
return (cb->error_code = bt_mesh_cfg_beacon_set(&ctx, set->beacon_set.beacon));
return bt_mesh_cfg_beacon_set(&param, set->beacon_set.beacon);
case ESP_BLE_MESH_MODEL_OP_DEFAULT_TTL_SET:
return (cb->error_code = bt_mesh_cfg_ttl_set(&ctx, set->default_ttl_set.ttl));
return bt_mesh_cfg_ttl_set(&param, set->default_ttl_set.ttl);
case ESP_BLE_MESH_MODEL_OP_FRIEND_SET:
return (cb->error_code = bt_mesh_cfg_friend_set(&ctx, set->friend_set.friend_state));
return bt_mesh_cfg_friend_set(&param, set->friend_set.friend_state);
case ESP_BLE_MESH_MODEL_OP_GATT_PROXY_SET:
return (cb->error_code = bt_mesh_cfg_gatt_proxy_set(&ctx, set->gatt_proxy_set.gatt_proxy));
return bt_mesh_cfg_gatt_proxy_set(&param, set->gatt_proxy_set.gatt_proxy);
case ESP_BLE_MESH_MODEL_OP_RELAY_SET:
return (cb->error_code =
bt_mesh_cfg_relay_set(&ctx, set->relay_set.relay, set->relay_set.relay_retransmit));
return bt_mesh_cfg_relay_set(&param, set->relay_set.relay,
set->relay_set.relay_retransmit);
case ESP_BLE_MESH_MODEL_OP_NET_KEY_ADD:
return (cb->error_code =
bt_mesh_cfg_net_key_add(&ctx, set->net_key_add.net_idx,
&set->net_key_add.net_key[0]));
return bt_mesh_cfg_net_key_add(&param, set->net_key_add.net_idx,
&set->net_key_add.net_key[0]);
case ESP_BLE_MESH_MODEL_OP_APP_KEY_ADD:
return (cb->error_code =
bt_mesh_cfg_app_key_add(&ctx, set->app_key_add.net_idx,
set->app_key_add.app_idx, &set->app_key_add.app_key[0]));
return bt_mesh_cfg_app_key_add(&param, set->app_key_add.net_idx,
set->app_key_add.app_idx,
&set->app_key_add.app_key[0]);
case ESP_BLE_MESH_MODEL_OP_MODEL_APP_BIND:
return (cb->error_code =
bt_mesh_cfg_mod_app_bind(&ctx, set->model_app_bind.element_addr,
set->model_app_bind.model_app_idx, set->model_app_bind.model_id,
set->model_app_bind.company_id));
return bt_mesh_cfg_mod_app_bind(&param, set->model_app_bind.element_addr,
set->model_app_bind.model_app_idx,
set->model_app_bind.model_id,
set->model_app_bind.company_id);
case ESP_BLE_MESH_MODEL_OP_MODEL_PUB_SET: {
struct bt_mesh_cfg_mod_pub model_pub = {
.addr = set->model_pub_set.publish_addr,
@ -535,50 +531,46 @@ static int btc_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param
.period = set->model_pub_set.publish_period,
.transmit = set->model_pub_set.publish_retransmit,
};
return (cb->error_code =
bt_mesh_cfg_mod_pub_set(&ctx, set->model_pub_set.element_addr,
set->model_pub_set.model_id, set->model_pub_set.company_id, &model_pub));
return bt_mesh_cfg_mod_pub_set(&param, set->model_pub_set.element_addr,
set->model_pub_set.model_id,
set->model_pub_set.company_id, &model_pub);
}
case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_ADD:
return (cb->error_code =
bt_mesh_cfg_mod_sub_add(&ctx, set->model_sub_add.element_addr,
set->model_sub_add.sub_addr, set->model_sub_add.model_id,
set->model_sub_add.company_id));
return bt_mesh_cfg_mod_sub_add(&param, set->model_sub_add.element_addr,
set->model_sub_add.sub_addr,
set->model_sub_add.model_id,
set->model_sub_add.company_id);
case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_DELETE:
return (cb->error_code =
bt_mesh_cfg_mod_sub_del(&ctx, set->model_sub_delete.element_addr,
set->model_sub_delete.sub_addr, set->model_sub_delete.model_id,
set->model_sub_delete.company_id));
return bt_mesh_cfg_mod_sub_del(&param, set->model_sub_delete.element_addr,
set->model_sub_delete.sub_addr,
set->model_sub_delete.model_id,
set->model_sub_delete.company_id);
case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_OVERWRITE:
return (cb->error_code =
bt_mesh_cfg_mod_sub_overwrite(&ctx, set->model_sub_overwrite.element_addr,
set->model_sub_overwrite.sub_addr, set->model_sub_overwrite.model_id,
set->model_sub_overwrite.company_id));
return bt_mesh_cfg_mod_sub_overwrite(&param, set->model_sub_overwrite.element_addr,
set->model_sub_overwrite.sub_addr,
set->model_sub_overwrite.model_id,
set->model_sub_overwrite.company_id);
case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_ADD:
return (cb->error_code =
bt_mesh_cfg_mod_sub_va_add(&ctx, set->model_sub_va_add.element_addr,
&set->model_sub_va_add.label_uuid[0], set->model_sub_va_add.model_id,
set->model_sub_va_add.company_id));
return bt_mesh_cfg_mod_sub_va_add(&param, set->model_sub_va_add.element_addr,
&set->model_sub_va_add.label_uuid[0],
set->model_sub_va_add.model_id,
set->model_sub_va_add.company_id);
case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_OVERWRITE:
return (cb->error_code =
bt_mesh_cfg_mod_sub_va_overwrite(&ctx, set->model_sub_va_overwrite.element_addr,
&set->model_sub_va_overwrite.label_uuid[0], set->model_sub_va_overwrite.model_id,
set->model_sub_va_overwrite.company_id));
return bt_mesh_cfg_mod_sub_va_overwrite(&param, set->model_sub_va_overwrite.element_addr,
&set->model_sub_va_overwrite.label_uuid[0],
set->model_sub_va_overwrite.model_id,
set->model_sub_va_overwrite.company_id);
case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_DELETE:
return (cb->error_code =
bt_mesh_cfg_mod_sub_va_del(&ctx, set->model_sub_va_delete.element_addr,
&set->model_sub_va_delete.label_uuid[0], set->model_sub_va_delete.model_id,
set->model_sub_va_delete.company_id));
return bt_mesh_cfg_mod_sub_va_del(&param, set->model_sub_va_delete.element_addr,
&set->model_sub_va_delete.label_uuid[0],
set->model_sub_va_delete.model_id,
set->model_sub_va_delete.company_id);
case ESP_BLE_MESH_MODEL_OP_HEARTBEAT_SUB_SET:
return (cb->error_code =
bt_mesh_cfg_hb_sub_set(&ctx,
(struct bt_mesh_cfg_hb_sub *)&set->heartbeat_sub_set));
return bt_mesh_cfg_hb_sub_set(&param, (struct bt_mesh_cfg_hb_sub *)&set->heartbeat_sub_set);
case ESP_BLE_MESH_MODEL_OP_HEARTBEAT_PUB_SET:
return (cb->error_code =
bt_mesh_cfg_hb_pub_set(&ctx,
(const struct bt_mesh_cfg_hb_pub *)&set->heartbeat_pub_set));
return bt_mesh_cfg_hb_pub_set(&param, (struct bt_mesh_cfg_hb_pub *)&set->heartbeat_pub_set);
case ESP_BLE_MESH_MODEL_OP_NODE_RESET:
return (cb->error_code = bt_mesh_cfg_node_reset(&ctx));
return bt_mesh_cfg_node_reset(&param);
case ESP_BLE_MESH_MODEL_OP_MODEL_PUB_VIRTUAL_ADDR_SET: {
struct bt_mesh_cfg_mod_pub model_pub = {
.app_idx = set->model_pub_va_set.publish_app_idx,
@ -587,49 +579,43 @@ static int btc_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param
.period = set->model_pub_va_set.publish_period,
.transmit = set->model_pub_va_set.publish_retransmit,
};
return (cb->error_code =
bt_mesh_cfg_mod_pub_va_set(&ctx, set->model_pub_va_set.element_addr,
set->model_pub_va_set.model_id, set->model_pub_va_set.company_id,
set->model_pub_va_set.label_uuid, &model_pub));
return bt_mesh_cfg_mod_pub_va_set(&param, set->model_pub_va_set.element_addr,
set->model_pub_va_set.model_id,
set->model_pub_va_set.company_id,
set->model_pub_va_set.label_uuid, &model_pub);
}
case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_DELETE_ALL:
return (cb->error_code =
bt_mesh_cfg_mod_sub_del_all(&ctx, set->model_sub_delete_all.element_addr,
set->model_sub_delete_all.model_id, set->model_sub_delete_all.company_id));
return bt_mesh_cfg_mod_sub_del_all(&param, set->model_sub_delete_all.element_addr,
set->model_sub_delete_all.model_id,
set->model_sub_delete_all.company_id);
case ESP_BLE_MESH_MODEL_OP_NET_KEY_UPDATE:
return (cb->error_code =
bt_mesh_cfg_net_key_update(&ctx, set->net_key_update.net_idx,
set->net_key_update.net_key));
return bt_mesh_cfg_net_key_update(&param, set->net_key_update.net_idx,
set->net_key_update.net_key);
case ESP_BLE_MESH_MODEL_OP_NET_KEY_DELETE:
return (cb->error_code =
bt_mesh_cfg_net_key_delete(&ctx, set->net_key_delete.net_idx));
return bt_mesh_cfg_net_key_delete(&param, set->net_key_delete.net_idx);
case ESP_BLE_MESH_MODEL_OP_APP_KEY_UPDATE:
return (cb->error_code =
bt_mesh_cfg_app_key_update(&ctx, set->app_key_update.net_idx,
set->app_key_update.app_idx, set->app_key_update.app_key));
return bt_mesh_cfg_app_key_update(&param, set->app_key_update.net_idx,
set->app_key_update.app_idx,
set->app_key_update.app_key);
case ESP_BLE_MESH_MODEL_OP_APP_KEY_DELETE:
return (cb->error_code =
bt_mesh_cfg_app_key_delete(&ctx, set->app_key_delete.net_idx,
set->app_key_delete.app_idx));
return bt_mesh_cfg_app_key_delete(&param, set->app_key_delete.net_idx,
set->app_key_delete.app_idx);
case ESP_BLE_MESH_MODEL_OP_NODE_IDENTITY_SET:
return (cb->error_code =
bt_mesh_cfg_node_identity_set(&ctx, set->node_identity_set.net_idx,
set->node_identity_set.identity));
return bt_mesh_cfg_node_identity_set(&param, set->node_identity_set.net_idx,
set->node_identity_set.identity);
case ESP_BLE_MESH_MODEL_OP_MODEL_APP_UNBIND:
return (cb->error_code =
bt_mesh_cfg_mod_app_unbind(&ctx, set->model_app_unbind.element_addr,
set->model_app_unbind.model_app_idx, set->model_app_unbind.model_id,
set->model_app_unbind.company_id));
return bt_mesh_cfg_mod_app_unbind(&param, set->model_app_unbind.element_addr,
set->model_app_unbind.model_app_idx,
set->model_app_unbind.model_id,
set->model_app_unbind.company_id);
case ESP_BLE_MESH_MODEL_OP_KEY_REFRESH_PHASE_SET:
return (cb->error_code =
bt_mesh_cfg_kr_phase_set(&ctx, set->kr_phase_set.net_idx,
set->kr_phase_set.transition));
return bt_mesh_cfg_kr_phase_set(&param, set->kr_phase_set.net_idx,
set->kr_phase_set.transition);
case ESP_BLE_MESH_MODEL_OP_NETWORK_TRANSMIT_SET:
return (cb->error_code =
bt_mesh_cfg_net_transmit_set(&ctx, set->net_transmit_set.net_transmit));
return bt_mesh_cfg_net_transmit_set(&param, set->net_transmit_set.net_transmit);
default:
BT_ERR("%s, Invalid opcode 0x%x", __func__, params->opcode);
return (cb->error_code = -EINVAL);
BT_ERR("Invalid Configuration Set opcode 0x%04x", param.opcode);
return -EINVAL;
}
return 0;
@ -639,7 +625,6 @@ void btc_ble_mesh_config_client_call_handler(btc_msg_t *msg)
{
btc_ble_mesh_config_client_args_t *arg = NULL;
esp_ble_mesh_cfg_client_cb_param_t cb = {0};
bt_mesh_role_param_t role_param = {0};
if (!msg || !msg->arg) {
BT_ERR("%s, Invalid parameter", __func__);
@ -651,15 +636,8 @@ void btc_ble_mesh_config_client_call_handler(btc_msg_t *msg)
switch (msg->act) {
case BTC_BLE_MESH_ACT_CONFIG_CLIENT_GET_STATE: {
cb.params = arg->cfg_client_get_state.params;
role_param.model = (struct bt_mesh_model *)cb.params->model;
role_param.role = cb.params->msg_role;
if (bt_mesh_set_client_model_role(&role_param)) {
BT_ERR("%s, Failed to set model role", __func__);
break;
}
btc_ble_mesh_config_client_get_state(arg->cfg_client_get_state.params,
arg->cfg_client_get_state.get_state,
&cb);
cb.error_code = btc_ble_mesh_config_client_get_state(arg->cfg_client_get_state.params,
arg->cfg_client_get_state.get_state);
if (cb.error_code) {
btc_ble_mesh_config_client_callback(&cb, ESP_BLE_MESH_CFG_CLIENT_GET_STATE_EVT);
}
@ -667,15 +645,8 @@ void btc_ble_mesh_config_client_call_handler(btc_msg_t *msg)
}
case BTC_BLE_MESH_ACT_CONFIG_CLIENT_SET_STATE: {
cb.params = arg->cfg_client_set_state.params;
role_param.model = (struct bt_mesh_model *)cb.params->model;
role_param.role = cb.params->msg_role;
if (bt_mesh_set_client_model_role(&role_param)) {
BT_ERR("%s, Failed to set model role", __func__);
break;
}
btc_ble_mesh_config_client_set_state(arg->cfg_client_set_state.params,
arg->cfg_client_set_state.set_state,
&cb);
cb.error_code = btc_ble_mesh_config_client_set_state(arg->cfg_client_set_state.params,
arg->cfg_client_set_state.set_state);
if (cb.error_code) {
btc_ble_mesh_config_client_callback(&cb, ESP_BLE_MESH_CFG_CLIENT_SET_STATE_EVT);
}
@ -703,17 +674,19 @@ void btc_ble_mesh_config_client_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_CFG_CLIENT_EVT_MAX) {
btc_ble_mesh_config_client_cb_to_app(msg->act, param);
} else {
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
BT_ERR("%s, Unknown act %d", __func__, msg->act);
}
btc_ble_mesh_config_client_free_req_data(msg);
return;
}
#endif /* CONFIG_BLE_MESH_CFG_CLI */
/* Configuration Server Model related functions */
static inline void btc_ble_mesh_config_server_cb_to_app(esp_ble_mesh_cfg_server_cb_event_t event,
esp_ble_mesh_cfg_server_cb_param_t *param)
esp_ble_mesh_cfg_server_cb_param_t *param)
{
esp_ble_mesh_cfg_server_cb_t btc_ble_mesh_cb =
(esp_ble_mesh_cfg_server_cb_t)btc_profile_cb_get(BTC_PID_CONFIG_SERVER);
@ -740,13 +713,11 @@ static void btc_ble_mesh_config_server_callback(esp_ble_mesh_cfg_server_cb_param
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_cfg_server_cb_param_t), NULL);
}
void bt_mesh_config_server_cb_evt_to_btc(u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len)
void bt_mesh_config_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const uint8_t *val, size_t len)
{
esp_ble_mesh_cfg_server_cb_param_t cb_params = {0};
size_t length = 0U;
uint8_t act = 0U;
if (!model || !ctx) {
@ -759,7 +730,7 @@ void bt_mesh_config_server_cb_evt_to_btc(u8_t evt_type,
act = ESP_BLE_MESH_CFG_SERVER_STATE_CHANGE_EVT;
break;
default:
BT_ERR("%s, Unknown config server event type %d", __func__, evt_type);
BT_ERR("Unknown Config server event type %d", evt_type);
return;
}
@ -770,10 +741,11 @@ void bt_mesh_config_server_cb_evt_to_btc(u8_t evt_type,
cb_params.ctx.recv_ttl = ctx->recv_ttl;
cb_params.ctx.recv_op = ctx->recv_op;
cb_params.ctx.recv_dst = ctx->recv_dst;
cb_params.ctx.recv_rssi = ctx->recv_rssi;
cb_params.ctx.send_ttl = ctx->send_ttl;
if (val && len) {
length = (len <= sizeof(cb_params.value)) ? len : sizeof(cb_params.value);
memcpy(&cb_params.value, val, length);
memcpy(&cb_params.value, val, MIN(len, sizeof(cb_params.value)));
}
btc_ble_mesh_config_server_callback(&cb_params, act);
@ -794,6 +766,6 @@ void btc_ble_mesh_config_server_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_CFG_SERVER_EVT_MAX) {
btc_ble_mesh_config_server_cb_to_app(msg->act, param);
} else {
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
BT_ERR("%s, Unknown act %d", __func__, msg->act);
}
}

View File

@ -16,13 +16,15 @@
#include <errno.h>
#include "btc_ble_mesh_generic_model.h"
#include "generic_client.h"
#include "esp_ble_mesh_generic_model_api.h"
#if CONFIG_BLE_MESH_GENERIC_CLIENT
#include "generic_client.h"
/* Generic Client Models related functions */
static inline void btc_ble_mesh_generic_client_cb_to_app(esp_ble_mesh_generic_client_cb_event_t event,
esp_ble_mesh_generic_client_cb_param_t *param)
esp_ble_mesh_generic_client_cb_param_t *param)
{
esp_ble_mesh_generic_client_cb_t btc_ble_mesh_cb =
(esp_ble_mesh_generic_client_cb_t)btc_profile_cb_get(BTC_PID_GENERIC_CLIENT);
@ -35,7 +37,7 @@ void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, voi
{
btc_ble_mesh_generic_client_args_t *dst = (btc_ble_mesh_generic_client_args_t *)p_dest;
btc_ble_mesh_generic_client_args_t *src = (btc_ble_mesh_generic_client_args_t *)p_src;
u16_t length = 0U;
uint16_t length = 0U;
if (!msg || !dst || !src) {
BT_ERR("%s, Invalid parameter", __func__);
@ -49,7 +51,7 @@ void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, voi
memcpy(dst->generic_client_get_state.params, src->generic_client_get_state.params,
sizeof(esp_ble_mesh_client_common_param_t));
} else {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
break;
}
if (src->generic_client_get_state.get_state) {
@ -58,7 +60,7 @@ void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, voi
memcpy(dst->generic_client_get_state.get_state, src->generic_client_get_state.get_state,
sizeof(esp_ble_mesh_generic_client_get_state_t));
} else {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
}
}
break;
@ -78,7 +80,7 @@ void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, voi
length = src->generic_client_set_state.set_state->user_property_set.property_value->len;
dst->generic_client_set_state.set_state->user_property_set.property_value = bt_mesh_alloc_buf(length);
if (!dst->generic_client_set_state.set_state->user_property_set.property_value) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(dst->generic_client_set_state.set_state->user_property_set.property_value,
@ -91,7 +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) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(dst->generic_client_set_state.set_state->admin_property_set.property_value,
@ -103,12 +105,12 @@ void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, voi
break;
}
} else {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
}
break;
}
default:
BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act);
BT_DBG("%s, Unknown act %d", __func__, msg->act);
break;
}
}
@ -162,7 +164,7 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de
{
esp_ble_mesh_generic_client_cb_param_t *p_dest_data = (esp_ble_mesh_generic_client_cb_param_t *)p_dest;
esp_ble_mesh_generic_client_cb_param_t *p_src_data = (esp_ble_mesh_generic_client_cb_param_t *)p_src;
u16_t length = 0U;
uint16_t length = 0U;
if (!msg || !p_src_data || !p_dest_data) {
BT_ERR("%s, Invalid parameter", __func__);
@ -172,7 +174,7 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de
if (p_src_data->params) {
p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (!p_dest_data->params) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
@ -191,7 +193,7 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de
length = p_src_data->status_cb.user_properties_status.property_ids->len;
p_dest_data->status_cb.user_properties_status.property_ids = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.user_properties_status.property_ids) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.user_properties_status.property_ids,
@ -206,7 +208,7 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de
length = p_src_data->status_cb.user_property_status.property_value->len;
p_dest_data->status_cb.user_property_status.property_value = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.user_property_status.property_value) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.user_property_status.property_value,
@ -220,7 +222,7 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de
length = p_src_data->status_cb.admin_properties_status.property_ids->len;
p_dest_data->status_cb.admin_properties_status.property_ids = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.admin_properties_status.property_ids) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.admin_properties_status.property_ids,
@ -235,7 +237,7 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de
length = p_src_data->status_cb.admin_property_status.property_value->len;
p_dest_data->status_cb.admin_property_status.property_value = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.admin_property_status.property_value) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.admin_property_status.property_value,
@ -249,7 +251,7 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de
length = p_src_data->status_cb.manufacturer_properties_status.property_ids->len;
p_dest_data->status_cb.manufacturer_properties_status.property_ids = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.manufacturer_properties_status.property_ids) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.manufacturer_properties_status.property_ids,
@ -264,7 +266,7 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de
length = p_src_data->status_cb.manufacturer_property_status.property_value->len;
p_dest_data->status_cb.manufacturer_property_status.property_value = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.manufacturer_property_status.property_value) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.manufacturer_property_status.property_value,
@ -278,7 +280,7 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de
length = p_src_data->status_cb.client_properties_status.property_ids->len;
p_dest_data->status_cb.client_properties_status.property_ids = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.client_properties_status.property_ids) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.client_properties_status.property_ids,
@ -374,18 +376,17 @@ static void btc_ble_mesh_generic_client_callback(esp_ble_mesh_generic_client_cb_
msg.pid = BTC_PID_GENERIC_CLIENT;
msg.act = act;
btc_transfer_context(&msg, cb_params,
sizeof(esp_ble_mesh_generic_client_cb_param_t), btc_ble_mesh_generic_client_copy_req_data);
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_generic_client_cb_param_t),
btc_ble_mesh_generic_client_copy_req_data);
}
void bt_mesh_generic_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len)
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 = 0U;
uint8_t act = 0U;
if (!model || !ctx) {
@ -407,7 +408,7 @@ void bt_mesh_generic_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
act = ESP_BLE_MESH_GENERIC_CLIENT_TIMEOUT_EVT;
break;
default:
BT_ERR("%s, Unknown generic client event type %d", __func__, evt_type);
BT_ERR("Unknown Generic client event type %d", evt_type);
return;
}
@ -419,31 +420,31 @@ void bt_mesh_generic_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
params.ctx.recv_ttl = ctx->recv_ttl;
params.ctx.recv_op = ctx->recv_op;
params.ctx.recv_dst = ctx->recv_dst;
params.ctx.recv_rssi = ctx->recv_rssi;
params.ctx.send_ttl = ctx->send_ttl;
cb_params.error_code = 0;
cb_params.params = &params;
if (val && len) {
length = (len <= sizeof(cb_params.status_cb)) ? len : sizeof(cb_params.status_cb);
memcpy(&cb_params.status_cb, val, length);
memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb)));
}
btc_ble_mesh_generic_client_callback(&cb_params, act);
return;
}
void btc_ble_mesh_generic_client_publish_callback(u32_t opcode,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
void btc_ble_mesh_generic_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
if (!model || !ctx || !buf) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
bt_mesh_generic_client_cb_evt_to_btc(opcode,
BTC_BLE_MESH_EVT_GENERIC_CLIENT_PUBLISH, model, ctx, buf->data, buf->len);
bt_mesh_generic_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_GENERIC_CLIENT_PUBLISH,
model, ctx, buf->data, buf->len);
return;
}
@ -453,7 +454,6 @@ void btc_ble_mesh_generic_client_call_handler(btc_msg_t *msg)
btc_ble_mesh_generic_client_args_t *arg = NULL;
esp_ble_mesh_generic_client_cb_param_t cb = {0};
bt_mesh_client_common_param_t common = {0};
bt_mesh_role_param_t role_param = {0};
if (!msg || !msg->arg) {
BT_ERR("%s, Invalid parameter", __func__);
@ -465,12 +465,6 @@ void btc_ble_mesh_generic_client_call_handler(btc_msg_t *msg)
switch (msg->act) {
case BTC_BLE_MESH_ACT_GENERIC_CLIENT_GET_STATE: {
params = arg->generic_client_get_state.params;
role_param.model = (struct bt_mesh_model *)params->model;
role_param.role = params->msg_role;
if (bt_mesh_set_client_model_role(&role_param)) {
BT_ERR("%s, Failed to set model role", __func__);
break;
}
common.opcode = params->opcode;
common.model = (struct bt_mesh_model *)params->model;
common.ctx.net_idx = params->ctx.net_idx;
@ -479,10 +473,10 @@ void btc_ble_mesh_generic_client_call_handler(btc_msg_t *msg)
common.ctx.send_rel = params->ctx.send_rel;
common.ctx.send_ttl = params->ctx.send_ttl;
common.msg_timeout = params->msg_timeout;
common.msg_role = params->msg_role;
cb.params = arg->generic_client_get_state.params;
cb.error_code = bt_mesh_generic_client_get_state(&common,
(void *)arg->generic_client_get_state.get_state, (void *)&cb.status_cb);
cb.error_code = bt_mesh_generic_client_get_state(&common, arg->generic_client_get_state.get_state);
if (cb.error_code) {
/* If send failed, callback error_code to app layer immediately */
btc_ble_mesh_generic_client_callback(&cb, ESP_BLE_MESH_GENERIC_CLIENT_GET_STATE_EVT);
@ -491,12 +485,6 @@ void btc_ble_mesh_generic_client_call_handler(btc_msg_t *msg)
}
case BTC_BLE_MESH_ACT_GENERIC_CLIENT_SET_STATE: {
params = arg->generic_client_set_state.params;
role_param.model = (struct bt_mesh_model *)params->model;
role_param.role = params->msg_role;
if (bt_mesh_set_client_model_role(&role_param)) {
BT_ERR("%s, Failed to set model role", __func__);
break;
}
common.opcode = params->opcode;
common.model = (struct bt_mesh_model *)params->model;
common.ctx.net_idx = params->ctx.net_idx;
@ -505,10 +493,10 @@ void btc_ble_mesh_generic_client_call_handler(btc_msg_t *msg)
common.ctx.send_rel = params->ctx.send_rel;
common.ctx.send_ttl = params->ctx.send_ttl;
common.msg_timeout = params->msg_timeout;
common.msg_role = params->msg_role;
cb.params = arg->generic_client_set_state.params;
cb.error_code = bt_mesh_generic_client_set_state(&common,
(void *)arg->generic_client_set_state.set_state, (void *)&cb.status_cb);
cb.error_code = bt_mesh_generic_client_set_state(&common, arg->generic_client_set_state.set_state);
if (cb.error_code) {
/* If send failed, callback error_code to app layer immediately */
btc_ble_mesh_generic_client_callback(&cb, ESP_BLE_MESH_GENERIC_CLIENT_SET_STATE_EVT);
@ -537,18 +525,21 @@ void btc_ble_mesh_generic_client_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_GENERIC_CLIENT_EVT_MAX) {
btc_ble_mesh_generic_client_cb_to_app(msg->act, param);
} else {
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
BT_ERR("%s, Unknown act %d", __func__, msg->act);
}
btc_ble_mesh_generic_client_free_req_data(msg);
return;
}
#endif /* CONFIG_BLE_MESH_GENERIC_CLIENT */
#if CONFIG_BLE_MESH_GENERIC_SERVER
/* Generic Server Models related functions */
static inline void btc_ble_mesh_generic_server_cb_to_app(
esp_ble_mesh_generic_server_cb_event_t event,
esp_ble_mesh_generic_server_cb_param_t *param)
static inline void btc_ble_mesh_generic_server_cb_to_app(esp_ble_mesh_generic_server_cb_event_t event,
esp_ble_mesh_generic_server_cb_param_t *param)
{
esp_ble_mesh_generic_server_cb_t btc_ble_mesh_cb =
(esp_ble_mesh_generic_server_cb_t)btc_profile_cb_get(BTC_PID_GENERIC_SERVER);
@ -561,7 +552,7 @@ static void btc_ble_mesh_generic_server_copy_req_data(btc_msg_t *msg, void *p_de
{
esp_ble_mesh_generic_server_cb_param_t *p_dest_data = (esp_ble_mesh_generic_server_cb_param_t *)p_dest;
esp_ble_mesh_generic_server_cb_param_t *p_src_data = (esp_ble_mesh_generic_server_cb_param_t *)p_src;
u16_t length = 0U;
uint16_t length = 0U;
if (!msg || !p_src_data || !p_dest_data) {
BT_ERR("%s, Invalid parameter", __func__);
@ -577,7 +568,7 @@ static void btc_ble_mesh_generic_server_copy_req_data(btc_msg_t *msg, void *p_de
length = p_src_data->value.state_change.user_property_set.value->len;
p_dest_data->value.state_change.user_property_set.value = bt_mesh_alloc_buf(length);
if (p_dest_data->value.state_change.user_property_set.value == NULL) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.state_change.user_property_set.value,
@ -591,7 +582,7 @@ static void btc_ble_mesh_generic_server_copy_req_data(btc_msg_t *msg, void *p_de
length = p_src_data->value.state_change.admin_property_set.value->len;
p_dest_data->value.state_change.admin_property_set.value = bt_mesh_alloc_buf(length);
if (p_dest_data->value.state_change.admin_property_set.value == NULL) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.state_change.admin_property_set.value,
@ -611,7 +602,7 @@ static void btc_ble_mesh_generic_server_copy_req_data(btc_msg_t *msg, void *p_de
length = p_src_data->value.set.user_property.property_value->len;
p_dest_data->value.set.user_property.property_value = bt_mesh_alloc_buf(length);
if (p_dest_data->value.set.user_property.property_value == NULL) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.set.user_property.property_value,
@ -625,7 +616,7 @@ static void btc_ble_mesh_generic_server_copy_req_data(btc_msg_t *msg, void *p_de
length = p_src_data->value.set.admin_property.property_value->len;
p_dest_data->value.set.admin_property.property_value = bt_mesh_alloc_buf(length);
if (p_dest_data->value.set.admin_property.property_value == NULL) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.set.admin_property.property_value,
@ -702,17 +693,15 @@ static void btc_ble_mesh_generic_server_callback(esp_ble_mesh_generic_server_cb_
msg.pid = BTC_PID_GENERIC_SERVER;
msg.act = act;
btc_transfer_context(&msg, cb_params,
sizeof(esp_ble_mesh_generic_server_cb_param_t), btc_ble_mesh_generic_server_copy_req_data);
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_generic_server_cb_param_t),
btc_ble_mesh_generic_server_copy_req_data);
}
void bt_mesh_generic_server_cb_evt_to_btc(u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len)
void bt_mesh_generic_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const uint8_t *val, size_t len)
{
esp_ble_mesh_generic_server_cb_param_t cb_params = {0};
size_t length = 0U;
uint8_t act = 0U;
if (model == NULL || ctx == NULL) {
@ -731,7 +720,7 @@ void bt_mesh_generic_server_cb_evt_to_btc(u8_t evt_type,
act = ESP_BLE_MESH_GENERIC_SERVER_RECV_SET_MSG_EVT;
break;
default:
BT_ERR("%s, Unknown Generic Server event type", __func__);
BT_ERR("Unknown Generic Server event type %d", evt_type);
return;
}
@ -742,10 +731,11 @@ void bt_mesh_generic_server_cb_evt_to_btc(u8_t evt_type,
cb_params.ctx.recv_ttl = ctx->recv_ttl;
cb_params.ctx.recv_op = ctx->recv_op;
cb_params.ctx.recv_dst = ctx->recv_dst;
cb_params.ctx.recv_rssi = ctx->recv_rssi;
cb_params.ctx.send_ttl = ctx->send_ttl;
if (val && len) {
length = (len <= sizeof(cb_params.value)) ? len : sizeof(cb_params.value);
memcpy(&cb_params.value, val, length);
memcpy(&cb_params.value, val, MIN(len, sizeof(cb_params.value)));
}
btc_ble_mesh_generic_server_callback(&cb_params, act);
@ -766,9 +756,11 @@ void btc_ble_mesh_generic_server_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_GENERIC_SERVER_EVT_MAX) {
btc_ble_mesh_generic_server_cb_to_app(msg->act, param);
} else {
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
BT_ERR("%s, Unknown act %d", __func__, msg->act);
}
btc_ble_mesh_generic_server_free_req_data(msg);
return;
}
#endif /* CONFIG_BLE_MESH_GENERIC_SERVER */

View File

@ -17,16 +17,15 @@
#include "btc_ble_mesh_health_model.h"
#include "foundation.h"
#include "health_srv.h"
#include "health_cli.h"
#include "esp_ble_mesh_health_model_api.h"
extern s32_t health_msg_timeout;
#if CONFIG_BLE_MESH_HEALTH_CLI
#include "health_cli.h"
/* Health Client Model related functions */
static inline void btc_ble_mesh_health_client_cb_to_app(esp_ble_mesh_health_client_cb_event_t event,
esp_ble_mesh_health_client_cb_param_t *param)
esp_ble_mesh_health_client_cb_param_t *param)
{
esp_ble_mesh_health_client_cb_t btc_ble_mesh_cb =
(esp_ble_mesh_health_client_cb_t)btc_profile_cb_get(BTC_PID_HEALTH_CLIENT);
@ -52,7 +51,7 @@ void btc_ble_mesh_health_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
memcpy(dst->health_client_get_state.params, src->health_client_get_state.params,
sizeof(esp_ble_mesh_client_common_param_t));
} else {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
break;
}
if (src->health_client_get_state.get_state) {
@ -61,7 +60,7 @@ void btc_ble_mesh_health_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
memcpy(dst->health_client_get_state.get_state, src->health_client_get_state.get_state,
sizeof(esp_ble_mesh_health_client_get_state_t));
} else {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
}
}
break;
@ -75,12 +74,12 @@ void btc_ble_mesh_health_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
memcpy(dst->health_client_set_state.set_state, src->health_client_set_state.set_state,
sizeof(esp_ble_mesh_health_client_set_state_t));
} else {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
}
break;
}
default:
BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act);
BT_DBG("%s, Unknown act %d", __func__, msg->act);
break;
}
}
@ -122,7 +121,7 @@ static void btc_ble_mesh_health_client_copy_req_data(btc_msg_t *msg, void *p_des
{
esp_ble_mesh_health_client_cb_param_t *p_dest_data = (esp_ble_mesh_health_client_cb_param_t *)p_dest;
esp_ble_mesh_health_client_cb_param_t *p_src_data = (esp_ble_mesh_health_client_cb_param_t *)p_src;
u16_t length = 0U;
uint16_t length = 0U;
if (!msg || !p_src_data || !p_dest_data) {
BT_ERR("%s, Invalid parameter", __func__);
@ -132,7 +131,7 @@ static void btc_ble_mesh_health_client_copy_req_data(btc_msg_t *msg, void *p_des
if (p_src_data->params) {
p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (!p_dest_data->params) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
@ -150,7 +149,7 @@ static void btc_ble_mesh_health_client_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->status_cb.current_status.fault_array->len;
p_dest_data->status_cb.current_status.fault_array = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.current_status.fault_array) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.current_status.fault_array,
@ -166,7 +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) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.fault_status.fault_array,
@ -240,18 +239,17 @@ static void btc_ble_mesh_health_client_callback(esp_ble_mesh_health_client_cb_pa
msg.pid = BTC_PID_HEALTH_CLIENT;
msg.act = act;
btc_transfer_context(&msg, cb_params,
sizeof(esp_ble_mesh_health_client_cb_param_t), btc_ble_mesh_health_client_copy_req_data);
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_health_client_cb_param_t),
btc_ble_mesh_health_client_copy_req_data);
}
void bt_mesh_health_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, u16_t len)
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 = 0U;
uint8_t act = 0U;
if (!model || !ctx) {
@ -273,7 +271,7 @@ void bt_mesh_health_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
act = ESP_BLE_MESH_HEALTH_CLIENT_TIMEOUT_EVT;
break;
default:
BT_ERR("%s, Unknown health client event type %d", __func__, evt_type);
BT_ERR("Unknown Health client event type %d", evt_type);
return;
}
@ -285,120 +283,114 @@ void bt_mesh_health_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
params.ctx.recv_ttl = ctx->recv_ttl;
params.ctx.recv_op = ctx->recv_op;
params.ctx.recv_dst = ctx->recv_dst;
params.ctx.recv_rssi = ctx->recv_rssi;
params.ctx.send_ttl = ctx->send_ttl;
cb_params.error_code = 0;
cb_params.params = &params;
if (val && len) {
length = (len <= sizeof(cb_params.status_cb)) ? len : sizeof(cb_params.status_cb);
memcpy(&cb_params.status_cb, val, length);
memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb)));
}
btc_ble_mesh_health_client_callback(&cb_params, act);
return;
}
void btc_ble_mesh_health_publish_callback(u32_t opcode,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
void btc_ble_mesh_health_publish_callback(uint32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
if (!model || !ctx || !buf) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
bt_mesh_health_client_cb_evt_to_btc(opcode,
BTC_BLE_MESH_EVT_HEALTH_CLIENT_PUBLISH, model, ctx, buf->data, buf->len);
bt_mesh_health_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_HEALTH_CLIENT_PUBLISH,
model, ctx, buf->data, buf->len);
return;
}
static int btc_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_health_client_get_state_t *get,
esp_ble_mesh_health_client_cb_param_t *cb)
esp_ble_mesh_health_client_get_state_t *get)
{
struct bt_mesh_msg_ctx ctx = {0};
bt_mesh_client_common_param_t param = {0};
if (!params || !cb) {
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("%s, Invalid health client get", __func__);
BT_ERR("Invalid Health Get");
return -EINVAL;
}
ctx.net_idx = params->ctx.net_idx;
ctx.app_idx = params->ctx.app_idx;
ctx.addr = params->ctx.addr;
ctx.send_rel = params->ctx.send_rel;
ctx.send_ttl = params->ctx.send_ttl;
param.opcode = params->opcode;
param.model = (struct bt_mesh_model *)params->model;
param.ctx.net_idx = params->ctx.net_idx;
param.ctx.app_idx = params->ctx.app_idx;
param.ctx.addr = params->ctx.addr;
param.ctx.send_rel = params->ctx.send_rel;
param.ctx.send_ttl = params->ctx.send_ttl;
param.msg_timeout = params->msg_timeout;
param.msg_role = params->msg_role;
health_msg_timeout = params->msg_timeout;
switch (params->opcode) {
switch (param.opcode) {
case ESP_BLE_MESH_MODEL_OP_ATTENTION_GET:
return (cb->error_code = bt_mesh_health_attention_get(&ctx));
return bt_mesh_health_attention_get(&param);
case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_GET:
return (cb->error_code = bt_mesh_health_period_get(&ctx));
return bt_mesh_health_period_get(&param);
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET:
return (cb->error_code = bt_mesh_health_fault_get(&ctx, get->fault_get.company_id));
return bt_mesh_health_fault_get(&param, get->fault_get.company_id);
default:
BT_ERR("%s, Invalid opcode 0x%x", __func__, params->opcode);
return (cb->error_code = -EINVAL);
BT_ERR("Invalid Health Get opcode 0x%04x", param.opcode);
return -EINVAL;
}
return 0;
}
static int btc_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_health_client_set_state_t *set,
esp_ble_mesh_health_client_cb_param_t *cb)
esp_ble_mesh_health_client_set_state_t *set)
{
struct bt_mesh_msg_ctx ctx = {0};
bt_mesh_client_common_param_t param = {0};
if (!params || !set || !cb) {
if (params == NULL || set == NULL) {
BT_ERR("%s, Invalid parameter", __func__);
return -EINVAL;
}
ctx.net_idx = params->ctx.net_idx;
ctx.app_idx = params->ctx.app_idx;
ctx.addr = params->ctx.addr;
ctx.send_rel = params->ctx.send_rel;
ctx.send_ttl = params->ctx.send_ttl;
param.opcode = params->opcode;
param.model = (struct bt_mesh_model *)params->model;
param.ctx.net_idx = params->ctx.net_idx;
param.ctx.app_idx = params->ctx.app_idx;
param.ctx.addr = params->ctx.addr;
param.ctx.send_rel = params->ctx.send_rel;
param.ctx.send_ttl = params->ctx.send_ttl;
param.msg_timeout = params->msg_timeout;
param.msg_role = params->msg_role;
health_msg_timeout = params->msg_timeout;
switch (params->opcode) {
switch (param.opcode) {
case ESP_BLE_MESH_MODEL_OP_ATTENTION_SET:
return (cb->error_code =
bt_mesh_health_attention_set(&ctx, set->attention_set.attention, true));
return bt_mesh_health_attention_set(&param, set->attention_set.attention, true);
case ESP_BLE_MESH_MODEL_OP_ATTENTION_SET_UNACK:
return (cb->error_code =
bt_mesh_health_attention_set(&ctx, set->attention_set.attention, false));
return bt_mesh_health_attention_set(&param, set->attention_set.attention, false);
case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET:
return (cb->error_code =
bt_mesh_health_period_set(&ctx, set->period_set.fast_period_divisor, true));
return bt_mesh_health_period_set(&param, set->period_set.fast_period_divisor, true);
case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET_UNACK:
return (cb->error_code =
bt_mesh_health_period_set(&ctx, set->period_set.fast_period_divisor, false));
return bt_mesh_health_period_set(&param, set->period_set.fast_period_divisor, false);
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST:
return (cb->error_code =
bt_mesh_health_fault_test(&ctx, set->fault_test.company_id, set->fault_test.test_id, true));
return bt_mesh_health_fault_test(&param, set->fault_test.company_id, set->fault_test.test_id, true);
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST_UNACK:
return (cb->error_code =
bt_mesh_health_fault_test(&ctx, set->fault_test.company_id, set->fault_test.test_id, false));
return bt_mesh_health_fault_test(&param, set->fault_test.company_id, set->fault_test.test_id, false);
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR:
return (cb->error_code =
bt_mesh_health_fault_clear(&ctx, set->fault_clear.company_id, true));
return bt_mesh_health_fault_clear(&param, set->fault_clear.company_id, true);
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR_UNACK:
return (cb->error_code =
bt_mesh_health_fault_clear(&ctx, set->fault_clear.company_id, false));
return bt_mesh_health_fault_clear(&param, set->fault_clear.company_id, false);
default:
BT_ERR("%s, Invalid opcode 0x%x", __func__, params->opcode);
return (cb->error_code = -EINVAL);
BT_ERR("Invalid Health Set opcode 0x%04x", param.opcode);
return -EINVAL;
}
return 0;
@ -408,7 +400,6 @@ void btc_ble_mesh_health_client_call_handler(btc_msg_t *msg)
{
btc_ble_mesh_health_client_args_t *arg = NULL;
esp_ble_mesh_health_client_cb_param_t cb = {0};
bt_mesh_role_param_t role_param = {0};
if (!msg || !msg->arg) {
BT_ERR("%s, Invalid parameter", __func__);
@ -420,14 +411,8 @@ void btc_ble_mesh_health_client_call_handler(btc_msg_t *msg)
switch (msg->act) {
case BTC_BLE_MESH_ACT_HEALTH_CLIENT_GET_STATE: {
cb.params = arg->health_client_get_state.params;
role_param.model = (struct bt_mesh_model *)cb.params->model;
role_param.role = cb.params->msg_role;
if (bt_mesh_set_client_model_role(&role_param)) {
BT_ERR("%s, Failed to set model role", __func__);
break;
}
btc_ble_mesh_health_client_get_state(arg->health_client_get_state.params,
arg->health_client_get_state.get_state, &cb);
cb.error_code = btc_ble_mesh_health_client_get_state(arg->health_client_get_state.params,
arg->health_client_get_state.get_state);
if (cb.error_code) {
/* If send failed, callback error_code to app layer immediately */
btc_ble_mesh_health_client_callback(&cb, ESP_BLE_MESH_HEALTH_CLIENT_GET_STATE_EVT);
@ -436,14 +421,8 @@ void btc_ble_mesh_health_client_call_handler(btc_msg_t *msg)
}
case BTC_BLE_MESH_ACT_HEALTH_CLIENT_SET_STATE: {
cb.params = arg->health_client_set_state.params;
role_param.model = (struct bt_mesh_model *)cb.params->model;
role_param.role = cb.params->msg_role;
if (bt_mesh_set_client_model_role(&role_param)) {
BT_ERR("%s, Failed to set model role", __func__);
break;
}
btc_ble_mesh_health_client_set_state(arg->health_client_set_state.params,
arg->health_client_set_state.set_state, &cb);
cb.error_code = btc_ble_mesh_health_client_set_state(arg->health_client_set_state.params,
arg->health_client_set_state.set_state);
if (cb.error_code) {
/* If send failed, callback error_code to app layer immediately */
btc_ble_mesh_health_client_callback(&cb, ESP_BLE_MESH_HEALTH_CLIENT_SET_STATE_EVT);
@ -472,17 +451,22 @@ void btc_ble_mesh_health_client_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_HEALTH_CLIENT_EVT_MAX) {
btc_ble_mesh_health_client_cb_to_app(msg->act, param);
} else {
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
BT_ERR("%s, Unknown act %d", __func__, msg->act);
}
btc_ble_mesh_health_client_free_req_data(msg);
return;
}
#endif /* CONFIG_BLE_MESH_HEALTH_CLI */
#if CONFIG_BLE_MESH_HEALTH_SRV
#include "health_srv.h"
/* Health Server Model related functions */
static inline void btc_ble_mesh_health_server_cb_to_app(esp_ble_mesh_health_server_cb_event_t event,
esp_ble_mesh_health_server_cb_param_t *param)
esp_ble_mesh_health_server_cb_param_t *param)
{
esp_ble_mesh_health_server_cb_t btc_ble_mesh_cb =
(esp_ble_mesh_health_server_cb_t)btc_profile_cb_get(BTC_PID_HEALTH_SERVER);
@ -566,8 +550,8 @@ static void btc_ble_mesh_health_server_callback(esp_ble_mesh_health_server_cb_pa
msg.pid = BTC_PID_HEALTH_SERVER;
msg.act = act;
btc_transfer_context(&msg, cb_params,
sizeof(esp_ble_mesh_health_server_cb_param_t), btc_ble_mesh_health_server_copy_req_data);
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_health_server_cb_param_t),
btc_ble_mesh_health_server_copy_req_data);
}
void btc_ble_mesh_health_server_call_handler(btc_msg_t *msg)
@ -611,14 +595,14 @@ void btc_ble_mesh_health_server_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_HEALTH_SERVER_EVT_MAX) {
btc_ble_mesh_health_server_cb_to_app(msg->act, param);
} else {
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
BT_ERR("%s, Unknown act %d", __func__, msg->act);
}
btc_ble_mesh_health_server_free_req_data(msg);
return;
}
void btc_ble_mesh_health_server_fault_clear(struct bt_mesh_model *model, u16_t company_id)
void btc_ble_mesh_health_server_fault_clear(struct bt_mesh_model *model, uint16_t company_id)
{
esp_ble_mesh_health_server_cb_param_t param = {0};
@ -628,7 +612,8 @@ void btc_ble_mesh_health_server_fault_clear(struct bt_mesh_model *model, u16_t c
btc_ble_mesh_health_server_callback(&param, ESP_BLE_MESH_HEALTH_SERVER_FAULT_CLEAR_EVT);
}
void btc_ble_mesh_health_server_fault_test(struct bt_mesh_model *model, u8_t test_id, u16_t company_id)
void btc_ble_mesh_health_server_fault_test(struct bt_mesh_model *model,
uint8_t test_id, uint16_t company_id)
{
esp_ble_mesh_health_server_cb_param_t param = {0};
@ -639,7 +624,7 @@ void btc_ble_mesh_health_server_fault_test(struct bt_mesh_model *model, u8_t tes
btc_ble_mesh_health_server_callback(&param, ESP_BLE_MESH_HEALTH_SERVER_FAULT_TEST_EVT);
}
void btc_ble_mesh_health_server_attention_on(struct bt_mesh_model *model, u8_t time)
void btc_ble_mesh_health_server_attention_on(struct bt_mesh_model *model, uint8_t time)
{
esp_ble_mesh_health_server_cb_param_t param = {0};
@ -657,3 +642,4 @@ void btc_ble_mesh_health_server_attention_off(struct bt_mesh_model *model)
btc_ble_mesh_health_server_callback(&param, ESP_BLE_MESH_HEALTH_SERVER_ATTENTION_OFF_EVT);
}
#endif /* CONFIG_BLE_MESH_HEALTH_SRV */

View File

@ -16,13 +16,15 @@
#include <errno.h>
#include "btc_ble_mesh_lighting_model.h"
#include "lighting_client.h"
#include "esp_ble_mesh_lighting_model_api.h"
#if CONFIG_BLE_MESH_LIGHTING_CLIENT
#include "lighting_client.h"
/* Lighting Client Models related functions */
static inline void btc_ble_mesh_lighting_client_cb_to_app(esp_ble_mesh_light_client_cb_event_t event,
esp_ble_mesh_light_client_cb_param_t *param)
esp_ble_mesh_light_client_cb_param_t *param)
{
esp_ble_mesh_light_client_cb_t btc_ble_mesh_cb =
(esp_ble_mesh_light_client_cb_t)btc_profile_cb_get(BTC_PID_LIGHTING_CLIENT);
@ -48,7 +50,7 @@ void btc_ble_mesh_lighting_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, vo
memcpy(dst->light_client_get_state.params, src->light_client_get_state.params,
sizeof(esp_ble_mesh_client_common_param_t));
} else {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
break;
}
if (src->light_client_get_state.get_state) {
@ -57,7 +59,7 @@ void btc_ble_mesh_lighting_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, vo
memcpy(dst->light_client_get_state.get_state, src->light_client_get_state.get_state,
sizeof(esp_ble_mesh_light_client_get_state_t));
} else {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
}
}
break;
@ -71,12 +73,12 @@ void btc_ble_mesh_lighting_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, vo
memcpy(dst->light_client_set_state.set_state, src->light_client_set_state.set_state,
sizeof(esp_ble_mesh_light_client_set_state_t));
} else {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
}
break;
}
default:
BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act);
BT_DBG("%s, Unknown act %d", __func__, msg->act);
break;
}
}
@ -118,7 +120,7 @@ static void btc_ble_mesh_lighting_client_copy_req_data(btc_msg_t *msg, void *p_d
{
esp_ble_mesh_light_client_cb_param_t *p_dest_data = (esp_ble_mesh_light_client_cb_param_t *)p_dest;
esp_ble_mesh_light_client_cb_param_t *p_src_data = (esp_ble_mesh_light_client_cb_param_t *)p_src;
u16_t length = 0U;
uint16_t length = 0U;
if (!msg || !p_src_data || !p_dest_data) {
BT_ERR("%s, Invalid parameter", __func__);
@ -128,7 +130,7 @@ static void btc_ble_mesh_lighting_client_copy_req_data(btc_msg_t *msg, void *p_d
if (p_src_data->params) {
p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (!p_dest_data->params) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
@ -148,7 +150,7 @@ static void btc_ble_mesh_lighting_client_copy_req_data(btc_msg_t *msg, void *p_d
length = p_src_data->status_cb.lc_property_status.property_value->len;
p_dest_data->status_cb.lc_property_status.property_value = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.lc_property_status.property_value) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.lc_property_status.property_value,
@ -218,18 +220,17 @@ static void btc_ble_mesh_lighting_client_callback(esp_ble_mesh_light_client_cb_p
msg.pid = BTC_PID_LIGHTING_CLIENT;
msg.act = act;
btc_transfer_context(&msg, cb_params,
sizeof(esp_ble_mesh_light_client_cb_param_t), btc_ble_mesh_lighting_client_copy_req_data);
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_light_client_cb_param_t),
btc_ble_mesh_lighting_client_copy_req_data);
}
void bt_mesh_lighting_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len)
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 = 0U;
uint8_t act = 0U;
if (!model || !ctx) {
@ -251,7 +252,7 @@ void bt_mesh_lighting_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
act = ESP_BLE_MESH_LIGHT_CLIENT_TIMEOUT_EVT;
break;
default:
BT_ERR("%s, Unknown lighting client event type", __func__);
BT_ERR("Unknown Lighting client event type %d", evt_type);
return;
}
@ -263,31 +264,31 @@ void bt_mesh_lighting_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
params.ctx.recv_ttl = ctx->recv_ttl;
params.ctx.recv_op = ctx->recv_op;
params.ctx.recv_dst = ctx->recv_dst;
params.ctx.recv_rssi = ctx->recv_rssi;
params.ctx.send_ttl = ctx->send_ttl;
cb_params.error_code = 0;
cb_params.params = &params;
if (val && len) {
length = (len <= sizeof(cb_params.status_cb)) ? len : sizeof(cb_params.status_cb);
memcpy(&cb_params.status_cb, val, length);
memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb)));
}
btc_ble_mesh_lighting_client_callback(&cb_params, act);
return;
}
void btc_ble_mesh_lighting_client_publish_callback(u32_t opcode,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
void btc_ble_mesh_lighting_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
if (!model || !ctx || !buf) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
bt_mesh_lighting_client_cb_evt_to_btc(opcode,
BTC_BLE_MESH_EVT_LIGHTING_CLIENT_PUBLISH, model, ctx, buf->data, buf->len);
bt_mesh_lighting_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_LIGHTING_CLIENT_PUBLISH,
model, ctx, buf->data, buf->len);
return;
}
@ -297,7 +298,6 @@ void btc_ble_mesh_lighting_client_call_handler(btc_msg_t *msg)
btc_ble_mesh_lighting_client_args_t *arg = NULL;
esp_ble_mesh_light_client_cb_param_t cb = {0};
bt_mesh_client_common_param_t common = {0};
bt_mesh_role_param_t role_param = {0};
if (!msg || !msg->arg) {
BT_ERR("%s, Invalid parameter", __func__);
@ -309,12 +309,6 @@ void btc_ble_mesh_lighting_client_call_handler(btc_msg_t *msg)
switch (msg->act) {
case BTC_BLE_MESH_ACT_LIGHTING_CLIENT_GET_STATE: {
params = arg->light_client_get_state.params;
role_param.model = (struct bt_mesh_model *)params->model;
role_param.role = params->msg_role;
if (bt_mesh_set_client_model_role(&role_param)) {
BT_ERR("%s, Failed to set model role", __func__);
break;
}
common.opcode = params->opcode;
common.model = (struct bt_mesh_model *)params->model;
common.ctx.net_idx = params->ctx.net_idx;
@ -323,10 +317,10 @@ void btc_ble_mesh_lighting_client_call_handler(btc_msg_t *msg)
common.ctx.send_rel = params->ctx.send_rel;
common.ctx.send_ttl = params->ctx.send_ttl;
common.msg_timeout = params->msg_timeout;
common.msg_role = params->msg_role;
cb.params = arg->light_client_get_state.params;
cb.error_code = bt_mesh_light_client_get_state(&common,
(void *)arg->light_client_get_state.get_state, (void *)&cb.status_cb);
cb.error_code = bt_mesh_light_client_get_state(&common, arg->light_client_get_state.get_state);
if (cb.error_code) {
/* If send failed, callback error_code to app layer immediately */
btc_ble_mesh_lighting_client_callback(&cb, ESP_BLE_MESH_LIGHT_CLIENT_GET_STATE_EVT);
@ -335,12 +329,6 @@ void btc_ble_mesh_lighting_client_call_handler(btc_msg_t *msg)
}
case BTC_BLE_MESH_ACT_LIGHTING_CLIENT_SET_STATE: {
params = arg->light_client_set_state.params;
role_param.model = (struct bt_mesh_model *)params->model;
role_param.role = params->msg_role;
if (bt_mesh_set_client_model_role(&role_param)) {
BT_ERR("%s, Failed to set model role", __func__);
break;
}
common.opcode = params->opcode;
common.model = (struct bt_mesh_model *)params->model;
common.ctx.net_idx = params->ctx.net_idx;
@ -349,10 +337,10 @@ void btc_ble_mesh_lighting_client_call_handler(btc_msg_t *msg)
common.ctx.send_rel = params->ctx.send_rel;
common.ctx.send_ttl = params->ctx.send_ttl;
common.msg_timeout = params->msg_timeout;
common.msg_role = params->msg_role;
cb.params = arg->light_client_set_state.params;
cb.error_code = bt_mesh_light_client_set_state(&common,
(void *)arg->light_client_set_state.set_state, (void *)&cb.status_cb);
cb.error_code = bt_mesh_light_client_set_state(&common, arg->light_client_set_state.set_state);
if (cb.error_code) {
/* If send failed, callback error_code to app layer immediately */
btc_ble_mesh_lighting_client_callback(&cb, ESP_BLE_MESH_LIGHT_CLIENT_SET_STATE_EVT);
@ -381,18 +369,21 @@ void btc_ble_mesh_lighting_client_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_LIGHT_CLIENT_EVT_MAX) {
btc_ble_mesh_lighting_client_cb_to_app(msg->act, param);
} else {
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
BT_ERR("%s, Unknown act %d", __func__, msg->act);
}
btc_ble_mesh_lighting_client_free_req_data(msg);
return;
}
#endif /* CONFIG_BLE_MESH_LIGHTING_CLIENT */
#if CONFIG_BLE_MESH_LIGHTING_SERVER
/* Lighting Server Models related functions */
static inline void btc_ble_mesh_lighting_server_cb_to_app(
esp_ble_mesh_lighting_server_cb_event_t event,
esp_ble_mesh_lighting_server_cb_param_t *param)
static inline void btc_ble_mesh_lighting_server_cb_to_app(esp_ble_mesh_lighting_server_cb_event_t event,
esp_ble_mesh_lighting_server_cb_param_t *param)
{
esp_ble_mesh_lighting_server_cb_t btc_ble_mesh_cb =
(esp_ble_mesh_lighting_server_cb_t)btc_profile_cb_get(BTC_PID_LIGHTING_SERVER);
@ -405,7 +396,7 @@ static void btc_ble_mesh_lighting_server_copy_req_data(btc_msg_t *msg, void *p_d
{
esp_ble_mesh_lighting_server_cb_param_t *p_dest_data = (esp_ble_mesh_lighting_server_cb_param_t *)p_dest;
esp_ble_mesh_lighting_server_cb_param_t *p_src_data = (esp_ble_mesh_lighting_server_cb_param_t *)p_src;
u16_t length = 0U;
uint16_t length = 0U;
if (!msg || !p_src_data || !p_dest_data) {
BT_ERR("%s, Invalid parameter", __func__);
@ -420,7 +411,7 @@ static void btc_ble_mesh_lighting_server_copy_req_data(btc_msg_t *msg, void *p_d
length = p_src_data->value.state_change.lc_property_set.property_value->len;
p_dest_data->value.state_change.lc_property_set.property_value = bt_mesh_alloc_buf(length);
if (p_dest_data->value.state_change.lc_property_set.property_value == NULL) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.state_change.lc_property_set.property_value,
@ -436,7 +427,7 @@ static void btc_ble_mesh_lighting_server_copy_req_data(btc_msg_t *msg, void *p_d
length = p_src_data->value.set.lc_property.property_value->len;
p_dest_data->value.set.lc_property.property_value = bt_mesh_alloc_buf(length);
if (p_dest_data->value.set.lc_property.property_value == NULL) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.set.lc_property.property_value,
@ -451,7 +442,7 @@ static void btc_ble_mesh_lighting_server_copy_req_data(btc_msg_t *msg, void *p_d
length = p_src_data->value.status.sensor_status.data->len;
p_dest_data->value.status.sensor_status.data = bt_mesh_alloc_buf(length);
if (p_dest_data->value.status.sensor_status.data == NULL) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.status.sensor_status.data,
@ -514,17 +505,15 @@ static void btc_ble_mesh_lighting_server_callback(esp_ble_mesh_lighting_server_c
msg.pid = BTC_PID_LIGHTING_SERVER;
msg.act = act;
btc_transfer_context(
&msg, cb_params, sizeof(esp_ble_mesh_lighting_server_cb_param_t), btc_ble_mesh_lighting_server_copy_req_data);
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_lighting_server_cb_param_t),
btc_ble_mesh_lighting_server_copy_req_data);
}
void bt_mesh_lighting_server_cb_evt_to_btc(u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len)
void bt_mesh_lighting_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const uint8_t *val, size_t len)
{
esp_ble_mesh_lighting_server_cb_param_t cb_params = {0};
size_t length = 0U;
uint8_t act = 0U;
if (model == NULL || ctx == NULL) {
@ -546,7 +535,7 @@ void bt_mesh_lighting_server_cb_evt_to_btc(u8_t evt_type,
act = ESP_BLE_MESH_LIGHTING_SERVER_RECV_STATUS_MSG_EVT;
break;
default:
BT_ERR("%s, Unknown Lighting Server event type", __func__);
BT_ERR("Unknown Lighting server event type %d", evt_type);
return;
}
@ -557,10 +546,11 @@ void bt_mesh_lighting_server_cb_evt_to_btc(u8_t evt_type,
cb_params.ctx.recv_ttl = ctx->recv_ttl;
cb_params.ctx.recv_op = ctx->recv_op;
cb_params.ctx.recv_dst = ctx->recv_dst;
cb_params.ctx.recv_rssi = ctx->recv_rssi;
cb_params.ctx.send_ttl = ctx->send_ttl;
if (val && len) {
length = (len <= sizeof(cb_params.value)) ? len : sizeof(cb_params.value);
memcpy(&cb_params.value, val, length);
memcpy(&cb_params.value, val, MIN(len, sizeof(cb_params.value)));
}
btc_ble_mesh_lighting_server_callback(&cb_params, act);
@ -581,9 +571,11 @@ void btc_ble_mesh_lighting_server_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_LIGHTING_SERVER_EVT_MAX) {
btc_ble_mesh_lighting_server_cb_to_app(msg->act, param);
} else {
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
BT_ERR("%s, Unknown act %d", __func__, msg->act);
}
btc_ble_mesh_lighting_server_free_req_data(msg);
return;
}
}
#endif /* CONFIG_BLE_MESH_LIGHTING_SERVER */

File diff suppressed because it is too large Load Diff

View File

@ -16,13 +16,15 @@
#include <errno.h>
#include "btc_ble_mesh_sensor_model.h"
#include "sensor_client.h"
#include "esp_ble_mesh_sensor_model_api.h"
#if CONFIG_BLE_MESH_SENSOR_CLI
#include "sensor_client.h"
/* Sensor Client Models related functions */
static inline void btc_ble_mesh_sensor_client_cb_to_app(esp_ble_mesh_sensor_client_cb_event_t event,
esp_ble_mesh_sensor_client_cb_param_t *param)
esp_ble_mesh_sensor_client_cb_param_t *param)
{
esp_ble_mesh_sensor_client_cb_t btc_ble_mesh_cb =
(esp_ble_mesh_sensor_client_cb_t)btc_profile_cb_get(BTC_PID_SENSOR_CLIENT);
@ -35,7 +37,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
{
btc_ble_mesh_sensor_client_args_t *dst = (btc_ble_mesh_sensor_client_args_t *)p_dest;
btc_ble_mesh_sensor_client_args_t *src = (btc_ble_mesh_sensor_client_args_t *)p_src;
u16_t length = 0U;
uint16_t length = 0U;
if (!msg || !dst || !src) {
BT_ERR("%s, Invalid parameter", __func__);
@ -58,7 +60,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
length = src->sensor_client_get_state.get_state->column_get.raw_value_x->len;
dst->sensor_client_get_state.get_state->column_get.raw_value_x = bt_mesh_alloc_buf(length);
if (!dst->sensor_client_get_state.get_state->column_get.raw_value_x) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(dst->sensor_client_get_state.get_state->column_get.raw_value_x,
@ -71,7 +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) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(dst->sensor_client_get_state.get_state->series_get.raw_value_x1,
@ -82,7 +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) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(dst->sensor_client_get_state.get_state->series_get.raw_value_x2,
@ -94,7 +96,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
break;
}
} else {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
}
break;
}
@ -113,7 +115,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
length = src->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down->len;
dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down = bt_mesh_alloc_buf(length);
if (!dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down,
@ -124,7 +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) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_up,
@ -135,7 +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) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_low,
@ -146,7 +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) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_high,
@ -159,7 +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) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(dst->sensor_client_set_state.set_state->setting_set.sensor_setting_raw,
@ -171,12 +173,12 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
break;
}
} else {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
}
break;
}
default:
BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act);
BT_DBG("%s, Unknown act %d", __func__, msg->act);
break;
}
}
@ -246,7 +248,7 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des
{
esp_ble_mesh_sensor_client_cb_param_t *p_dest_data = (esp_ble_mesh_sensor_client_cb_param_t *)p_dest;
esp_ble_mesh_sensor_client_cb_param_t *p_src_data = (esp_ble_mesh_sensor_client_cb_param_t *)p_src;
u16_t length = 0U;
uint16_t length = 0U;
if (!msg || !p_src_data || !p_dest_data) {
BT_ERR("%s, Invalid parameter", __func__);
@ -256,7 +258,7 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des
if (p_src_data->params) {
p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (!p_dest_data->params) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
@ -275,7 +277,7 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->status_cb.descriptor_status.descriptor->len;
p_dest_data->status_cb.descriptor_status.descriptor = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.descriptor_status.descriptor) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.descriptor_status.descriptor,
@ -290,7 +292,7 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->status_cb.cadence_status.sensor_cadence_value->len;
p_dest_data->status_cb.cadence_status.sensor_cadence_value = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.cadence_status.sensor_cadence_value) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.cadence_status.sensor_cadence_value,
@ -304,7 +306,7 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->status_cb.settings_status.sensor_setting_property_ids->len;
p_dest_data->status_cb.settings_status.sensor_setting_property_ids = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.settings_status.sensor_setting_property_ids) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.settings_status.sensor_setting_property_ids,
@ -319,7 +321,7 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->status_cb.setting_status.sensor_setting_raw->len;
p_dest_data->status_cb.setting_status.sensor_setting_raw = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.setting_status.sensor_setting_raw) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.setting_status.sensor_setting_raw,
@ -333,7 +335,7 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->status_cb.sensor_status.marshalled_sensor_data->len;
p_dest_data->status_cb.sensor_status.marshalled_sensor_data = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.sensor_status.marshalled_sensor_data) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.sensor_status.marshalled_sensor_data,
@ -347,7 +349,7 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->status_cb.column_status.sensor_column_value->len;
p_dest_data->status_cb.column_status.sensor_column_value = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.column_status.sensor_column_value) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.column_status.sensor_column_value,
@ -361,7 +363,7 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->status_cb.series_status.sensor_series_value->len;
p_dest_data->status_cb.series_status.sensor_series_value = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.series_status.sensor_series_value) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.series_status.sensor_series_value,
@ -456,18 +458,17 @@ static void btc_ble_mesh_sensor_client_callback(esp_ble_mesh_sensor_client_cb_pa
msg.pid = BTC_PID_SENSOR_CLIENT;
msg.act = act;
btc_transfer_context(&msg, cb_params,
sizeof(esp_ble_mesh_sensor_client_cb_param_t), btc_ble_mesh_sensor_client_copy_req_data);
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_sensor_client_cb_param_t),
btc_ble_mesh_sensor_client_copy_req_data);
}
void bt_mesh_sensor_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len)
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 = 0U;
uint8_t act = 0U;
if (!model || !ctx) {
@ -489,7 +490,7 @@ void bt_mesh_sensor_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
act = ESP_BLE_MESH_SENSOR_CLIENT_TIMEOUT_EVT;
break;
default:
BT_ERR("%s, Unknown sensor client event type %d", __func__, evt_type);
BT_ERR("Unknown Sensor client event type %d", evt_type);
return;
}
@ -501,31 +502,31 @@ void bt_mesh_sensor_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
params.ctx.recv_ttl = ctx->recv_ttl;
params.ctx.recv_op = ctx->recv_op;
params.ctx.recv_dst = ctx->recv_dst;
params.ctx.recv_rssi = ctx->recv_rssi;
params.ctx.send_ttl = ctx->send_ttl;
cb_params.error_code = 0;
cb_params.params = &params;
if (val && len) {
length = (len <= sizeof(cb_params.status_cb)) ? len : sizeof(cb_params.status_cb);
memcpy(&cb_params.status_cb, val, length);
memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb)));
}
btc_ble_mesh_sensor_client_callback(&cb_params, act);
return;
}
void btc_ble_mesh_sensor_client_publish_callback(u32_t opcode,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
void btc_ble_mesh_sensor_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
if (!model || !ctx || !buf) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
bt_mesh_sensor_client_cb_evt_to_btc(opcode,
BTC_BLE_MESH_EVT_SENSOR_CLIENT_PUBLISH, model, ctx, buf->data, buf->len);
bt_mesh_sensor_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_SENSOR_CLIENT_PUBLISH,
model, ctx, buf->data, buf->len);
return;
}
@ -535,7 +536,6 @@ void btc_ble_mesh_sensor_client_call_handler(btc_msg_t *msg)
btc_ble_mesh_sensor_client_args_t *arg = NULL;
esp_ble_mesh_sensor_client_cb_param_t cb = {0};
bt_mesh_client_common_param_t common = {0};
bt_mesh_role_param_t role_param = {0};
if (!msg || !msg->arg) {
BT_ERR("%s, Invalid parameter", __func__);
@ -547,12 +547,6 @@ void btc_ble_mesh_sensor_client_call_handler(btc_msg_t *msg)
switch (msg->act) {
case BTC_BLE_MESH_ACT_SENSOR_CLIENT_GET_STATE: {
params = arg->sensor_client_get_state.params;
role_param.model = (struct bt_mesh_model *)params->model;
role_param.role = params->msg_role;
if (bt_mesh_set_client_model_role(&role_param)) {
BT_ERR("%s, Failed to set model role", __func__);
break;
}
common.opcode = params->opcode;
common.model = (struct bt_mesh_model *)params->model;
common.ctx.net_idx = params->ctx.net_idx;
@ -561,10 +555,10 @@ void btc_ble_mesh_sensor_client_call_handler(btc_msg_t *msg)
common.ctx.send_rel = params->ctx.send_rel;
common.ctx.send_ttl = params->ctx.send_ttl;
common.msg_timeout = params->msg_timeout;
common.msg_role = params->msg_role;
cb.params = arg->sensor_client_get_state.params;
cb.error_code = bt_mesh_sensor_client_get_state(&common,
(void *)arg->sensor_client_get_state.get_state, (void *)&cb.status_cb);
cb.error_code = bt_mesh_sensor_client_get_state(&common, arg->sensor_client_get_state.get_state);
if (cb.error_code) {
/* If send failed, callback error_code to app layer immediately */
btc_ble_mesh_sensor_client_callback(&cb, ESP_BLE_MESH_SENSOR_CLIENT_GET_STATE_EVT);
@ -573,12 +567,6 @@ void btc_ble_mesh_sensor_client_call_handler(btc_msg_t *msg)
}
case BTC_BLE_MESH_ACT_SENSOR_CLIENT_SET_STATE: {
params = arg->sensor_client_set_state.params;
role_param.model = (struct bt_mesh_model *)params->model;
role_param.role = params->msg_role;
if (bt_mesh_set_client_model_role(&role_param)) {
BT_ERR("%s, Failed to set model role", __func__);
break;
}
common.opcode = params->opcode;
common.model = (struct bt_mesh_model *)params->model;
common.ctx.net_idx = params->ctx.net_idx;
@ -587,10 +575,10 @@ void btc_ble_mesh_sensor_client_call_handler(btc_msg_t *msg)
common.ctx.send_rel = params->ctx.send_rel;
common.ctx.send_ttl = params->ctx.send_ttl;
common.msg_timeout = params->msg_timeout;
common.msg_role = params->msg_role;
cb.params = arg->sensor_client_set_state.params;
cb.error_code = bt_mesh_sensor_client_set_state(&common,
(void *)arg->sensor_client_set_state.set_state, (void *)&cb.status_cb);
cb.error_code = bt_mesh_sensor_client_set_state(&common, arg->sensor_client_set_state.set_state);
if (cb.error_code) {
/* If send failed, callback error_code to app layer immediately */
btc_ble_mesh_sensor_client_callback(&cb, ESP_BLE_MESH_SENSOR_CLIENT_SET_STATE_EVT);
@ -619,18 +607,21 @@ void btc_ble_mesh_sensor_client_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_SENSOR_CLIENT_EVT_MAX) {
btc_ble_mesh_sensor_client_cb_to_app(msg->act, param);
} else {
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
BT_ERR("%s, Unknown act %d", __func__, msg->act);
}
btc_ble_mesh_sensor_client_free_req_data(msg);
return;
}
#endif /* CONFIG_BLE_MESH_SENSOR_CLI */
#if CONFIG_BLE_MESH_SENSOR_SERVER
/* Sensor Server Models related functions */
static inline void btc_ble_mesh_sensor_server_cb_to_app(
esp_ble_mesh_sensor_server_cb_event_t event,
esp_ble_mesh_sensor_server_cb_param_t *param)
static inline void btc_ble_mesh_sensor_server_cb_to_app(esp_ble_mesh_sensor_server_cb_event_t event,
esp_ble_mesh_sensor_server_cb_param_t *param)
{
esp_ble_mesh_sensor_server_cb_t btc_ble_mesh_cb =
(esp_ble_mesh_sensor_server_cb_t)btc_profile_cb_get(BTC_PID_SENSOR_SERVER);
@ -643,7 +634,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des
{
esp_ble_mesh_sensor_server_cb_param_t *p_dest_data = (esp_ble_mesh_sensor_server_cb_param_t *)p_dest;
esp_ble_mesh_sensor_server_cb_param_t *p_src_data = (esp_ble_mesh_sensor_server_cb_param_t *)p_src;
u16_t length = 0U;
uint16_t length = 0U;
if (!msg || !p_src_data || !p_dest_data) {
BT_ERR("%s, Invalid parameter", __func__);
@ -658,7 +649,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->value.state_change.sensor_cadence_set.trigger_delta_down->len;
p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_down = bt_mesh_alloc_buf(length);
if (p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_down == NULL) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_down,
@ -669,7 +660,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->value.state_change.sensor_cadence_set.trigger_delta_up->len;
p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_up = bt_mesh_alloc_buf(length);
if (p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_up == NULL) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_up,
@ -680,7 +671,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->value.state_change.sensor_cadence_set.fast_cadence_low->len;
p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_low = bt_mesh_alloc_buf(length);
if (p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_low == NULL) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_low,
@ -691,7 +682,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->value.state_change.sensor_cadence_set.fast_cadence_high->len;
p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_high = bt_mesh_alloc_buf(length);
if (p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_high == NULL) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_high,
@ -704,7 +695,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->value.state_change.sensor_setting_set.setting_value->len;
p_dest_data->value.state_change.sensor_setting_set.setting_value = bt_mesh_alloc_buf(length);
if (p_dest_data->value.state_change.sensor_setting_set.setting_value == NULL) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.state_change.sensor_setting_set.setting_value,
@ -719,7 +710,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->value.get.sensor_column.raw_value_x->len;
p_dest_data->value.get.sensor_column.raw_value_x = bt_mesh_alloc_buf(length);
if (p_dest_data->value.get.sensor_column.raw_value_x == NULL) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.get.sensor_column.raw_value_x,
@ -731,7 +722,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->value.get.sensor_series.raw_value->len;
p_dest_data->value.get.sensor_series.raw_value = bt_mesh_alloc_buf(length);
if (p_dest_data->value.get.sensor_series.raw_value == NULL) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.get.sensor_series.raw_value,
@ -747,7 +738,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->value.set.sensor_cadence.cadence->len;
p_dest_data->value.set.sensor_cadence.cadence = bt_mesh_alloc_buf(length);
if (p_dest_data->value.set.sensor_cadence.cadence == NULL) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.set.sensor_cadence.cadence,
@ -760,7 +751,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->value.set.sensor_setting.setting_raw->len;
p_dest_data->value.set.sensor_setting.setting_raw = bt_mesh_alloc_buf(length);
if (p_dest_data->value.set.sensor_setting.setting_raw == NULL) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.set.sensor_setting.setting_raw,
@ -834,17 +825,15 @@ static void btc_ble_mesh_sensor_server_callback(esp_ble_mesh_sensor_server_cb_pa
msg.pid = BTC_PID_SENSOR_SERVER;
msg.act = act;
btc_transfer_context(
&msg, cb_params, sizeof(esp_ble_mesh_sensor_server_cb_param_t), btc_ble_mesh_sensor_server_copy_req_data);
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_sensor_server_cb_param_t),
btc_ble_mesh_sensor_server_copy_req_data);
}
void bt_mesh_sensor_server_cb_evt_to_btc(u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len)
void bt_mesh_sensor_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const uint8_t *val, size_t len)
{
esp_ble_mesh_sensor_server_cb_param_t cb_params = {0};
size_t length = 0U;
uint8_t act = 0U;
if (model == NULL || ctx == NULL) {
@ -863,7 +852,7 @@ void bt_mesh_sensor_server_cb_evt_to_btc(u8_t evt_type,
act = ESP_BLE_MESH_SENSOR_SERVER_RECV_SET_MSG_EVT;
break;
default:
BT_ERR("%s, Unknown Sensor Server event type", __func__);
BT_ERR("Unknown Sensor server event type %d", evt_type);
return;
}
@ -874,10 +863,11 @@ void bt_mesh_sensor_server_cb_evt_to_btc(u8_t evt_type,
cb_params.ctx.recv_ttl = ctx->recv_ttl;
cb_params.ctx.recv_op = ctx->recv_op;
cb_params.ctx.recv_dst = ctx->recv_dst;
cb_params.ctx.recv_rssi = ctx->recv_rssi;
cb_params.ctx.send_ttl = ctx->send_ttl;
if (val && len) {
length = (len <= sizeof(cb_params.value)) ? len : sizeof(cb_params.value);
memcpy(&cb_params.value, val, length);
memcpy(&cb_params.value, val, MIN(len, sizeof(cb_params.value)));
}
btc_ble_mesh_sensor_server_callback(&cb_params, act);
@ -898,9 +888,11 @@ void btc_ble_mesh_sensor_server_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_SENSOR_SERVER_EVT_MAX) {
btc_ble_mesh_sensor_server_cb_to_app(msg->act, param);
} else {
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
BT_ERR("%s, Unknown act %d", __func__, msg->act);
}
btc_ble_mesh_sensor_server_free_req_data(msg);
return;
}
#endif /* CONFIG_BLE_MESH_SENSOR_SERVER */

View File

@ -16,13 +16,15 @@
#include <errno.h>
#include "btc_ble_mesh_time_scene_model.h"
#include "time_scene_client.h"
#include "esp_ble_mesh_time_scene_model_api.h"
#if CONFIG_BLE_MESH_TIME_SCENE_CLIENT
#include "time_scene_client.h"
/* Time and Scenes Client Models related functions */
static inline void btc_ble_mesh_time_scene_client_cb_to_app(esp_ble_mesh_time_scene_client_cb_event_t event,
esp_ble_mesh_time_scene_client_cb_param_t *param)
esp_ble_mesh_time_scene_client_cb_param_t *param)
{
esp_ble_mesh_time_scene_client_cb_t btc_ble_mesh_cb =
(esp_ble_mesh_time_scene_client_cb_t)btc_profile_cb_get(BTC_PID_TIME_SCENE_CLIENT);
@ -48,7 +50,7 @@ void btc_ble_mesh_time_scene_client_arg_deep_copy(btc_msg_t *msg, void *p_dest,
memcpy(dst->time_scene_client_get_state.params, src->time_scene_client_get_state.params,
sizeof(esp_ble_mesh_client_common_param_t));
} else {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
break;
}
if (src->time_scene_client_get_state.get_state) {
@ -57,7 +59,7 @@ void btc_ble_mesh_time_scene_client_arg_deep_copy(btc_msg_t *msg, void *p_dest,
memcpy(dst->time_scene_client_get_state.get_state, src->time_scene_client_get_state.get_state,
sizeof(esp_ble_mesh_time_scene_client_get_state_t));
} else {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
}
}
break;
@ -71,12 +73,12 @@ void btc_ble_mesh_time_scene_client_arg_deep_copy(btc_msg_t *msg, void *p_dest,
memcpy(dst->time_scene_client_set_state.set_state, src->time_scene_client_set_state.set_state,
sizeof(esp_ble_mesh_time_scene_client_set_state_t));
} else {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
}
break;
}
default:
BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act);
BT_DBG("%s, Unknown act %d", __func__, msg->act);
break;
}
}
@ -118,7 +120,7 @@ static void btc_ble_mesh_time_scene_client_copy_req_data(btc_msg_t *msg, void *p
{
esp_ble_mesh_time_scene_client_cb_param_t *p_dest_data = (esp_ble_mesh_time_scene_client_cb_param_t *)p_dest;
esp_ble_mesh_time_scene_client_cb_param_t *p_src_data = (esp_ble_mesh_time_scene_client_cb_param_t *)p_src;
u16_t length = 0U;
uint16_t length = 0U;
if (!msg || !p_src_data || !p_dest_data) {
BT_ERR("%s, Invalid parameter", __func__);
@ -128,7 +130,7 @@ static void btc_ble_mesh_time_scene_client_copy_req_data(btc_msg_t *msg, void *p
if (p_src_data->params) {
p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (!p_dest_data->params) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
@ -149,7 +151,7 @@ static void btc_ble_mesh_time_scene_client_copy_req_data(btc_msg_t *msg, void *p
length = p_src_data->status_cb.scene_register_status.scenes->len;
p_dest_data->status_cb.scene_register_status.scenes = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.scene_register_status.scenes) {
BT_ERR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.scene_register_status.scenes,
@ -220,18 +222,17 @@ static void btc_ble_mesh_time_scene_client_callback(esp_ble_mesh_time_scene_clie
msg.pid = BTC_PID_TIME_SCENE_CLIENT;
msg.act = act;
btc_transfer_context(&msg, cb_params,
sizeof(esp_ble_mesh_time_scene_client_cb_param_t), btc_ble_mesh_time_scene_client_copy_req_data);
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_time_scene_client_cb_param_t),
btc_ble_mesh_time_scene_client_copy_req_data);
}
void bt_mesh_time_scene_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len)
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 = 0U;
uint8_t act = 0U;
if (!model || !ctx) {
@ -253,7 +254,7 @@ void bt_mesh_time_scene_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
act = ESP_BLE_MESH_TIME_SCENE_CLIENT_TIMEOUT_EVT;
break;
default:
BT_ERR("%s, Unknown time scene client event type %d", __func__, evt_type);
BT_ERR("Unknown Time Scene client event type %d", evt_type);
return;
}
@ -265,31 +266,31 @@ void bt_mesh_time_scene_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
params.ctx.recv_ttl = ctx->recv_ttl;
params.ctx.recv_op = ctx->recv_op;
params.ctx.recv_dst = ctx->recv_dst;
params.ctx.recv_rssi = ctx->recv_rssi;
params.ctx.send_ttl = ctx->send_ttl;
cb_params.error_code = 0;
cb_params.params = &params;
if (val && len) {
length = (len <= sizeof(cb_params.status_cb)) ? len : sizeof(cb_params.status_cb);
memcpy(&cb_params.status_cb, val, length);
memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb)));
}
btc_ble_mesh_time_scene_client_callback(&cb_params, act);
return;
}
void btc_ble_mesh_time_scene_client_publish_callback(u32_t opcode,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
void btc_ble_mesh_time_scene_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
if (!model || !ctx || !buf) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
bt_mesh_time_scene_client_cb_evt_to_btc(opcode,
BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_PUBLISH, model, ctx, buf->data, buf->len);
bt_mesh_time_scene_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_PUBLISH,
model, ctx, buf->data, buf->len);
return;
}
@ -299,7 +300,6 @@ void btc_ble_mesh_time_scene_client_call_handler(btc_msg_t *msg)
esp_ble_mesh_client_common_param_t *params = NULL;
esp_ble_mesh_time_scene_client_cb_param_t cb = {0};
bt_mesh_client_common_param_t common = {0};
bt_mesh_role_param_t role_param = {0};
if (!msg || !msg->arg) {
BT_ERR("%s, Invalid parameter", __func__);
@ -311,12 +311,6 @@ void btc_ble_mesh_time_scene_client_call_handler(btc_msg_t *msg)
switch (msg->act) {
case BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_GET_STATE: {
params = arg->time_scene_client_get_state.params;
role_param.model = (struct bt_mesh_model *)params->model;
role_param.role = params->msg_role;
if (bt_mesh_set_client_model_role(&role_param)) {
BT_ERR("%s, Failed to set model role", __func__);
break;
}
common.opcode = params->opcode;
common.model = (struct bt_mesh_model *)params->model;
common.ctx.net_idx = params->ctx.net_idx;
@ -325,10 +319,10 @@ void btc_ble_mesh_time_scene_client_call_handler(btc_msg_t *msg)
common.ctx.send_rel = params->ctx.send_rel;
common.ctx.send_ttl = params->ctx.send_ttl;
common.msg_timeout = params->msg_timeout;
common.msg_role = params->msg_role;
cb.params = arg->time_scene_client_get_state.params;
cb.error_code = bt_mesh_time_scene_client_get_state(&common,
(void *)arg->time_scene_client_get_state.get_state, (void *)&cb.status_cb);
cb.error_code = bt_mesh_time_scene_client_get_state(&common, arg->time_scene_client_get_state.get_state);
if (cb.error_code) {
/* If send failed, callback error_code to app layer immediately */
btc_ble_mesh_time_scene_client_callback(&cb, ESP_BLE_MESH_TIME_SCENE_CLIENT_GET_STATE_EVT);
@ -337,12 +331,6 @@ void btc_ble_mesh_time_scene_client_call_handler(btc_msg_t *msg)
}
case BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_SET_STATE: {
params = arg->time_scene_client_set_state.params;
role_param.model = (struct bt_mesh_model *)params->model;
role_param.role = params->msg_role;
if (bt_mesh_set_client_model_role(&role_param)) {
BT_ERR("%s, Failed to set model role", __func__);
break;
}
common.opcode = params->opcode;
common.model = (struct bt_mesh_model *)params->model;
common.ctx.net_idx = params->ctx.net_idx;
@ -351,10 +339,10 @@ void btc_ble_mesh_time_scene_client_call_handler(btc_msg_t *msg)
common.ctx.send_rel = params->ctx.send_rel;
common.ctx.send_ttl = params->ctx.send_ttl;
common.msg_timeout = params->msg_timeout;
common.msg_role = params->msg_role;
cb.params = arg->time_scene_client_set_state.params;
cb.error_code = bt_mesh_time_scene_client_set_state(&common,
(void *)arg->time_scene_client_set_state.set_state, (void *)&cb.status_cb);
cb.error_code = bt_mesh_time_scene_client_set_state(&common, arg->time_scene_client_set_state.set_state);
if (cb.error_code) {
/* If send failed, callback error_code to app layer immediately */
btc_ble_mesh_time_scene_client_callback(&cb, ESP_BLE_MESH_TIME_SCENE_CLIENT_SET_STATE_EVT);
@ -383,18 +371,21 @@ void btc_ble_mesh_time_scene_client_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_TIME_SCENE_CLIENT_EVT_MAX) {
btc_ble_mesh_time_scene_client_cb_to_app(msg->act, param);
} else {
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
BT_ERR("%s, Unknown act %d", __func__, msg->act);
}
btc_ble_mesh_time_scene_client_free_req_data(msg);
return;
}
#endif /* CONFIG_BLE_MESH_TIME_SCENE_CLIENT */
#if CONFIG_BLE_MESH_TIME_SCENE_SERVER
/* Time and Scenes Server Models related functions */
static inline void btc_ble_mesh_time_scene_server_cb_to_app(
esp_ble_mesh_time_scene_server_cb_event_t event,
esp_ble_mesh_time_scene_server_cb_param_t *param)
static inline void btc_ble_mesh_time_scene_server_cb_to_app(esp_ble_mesh_time_scene_server_cb_event_t event,
esp_ble_mesh_time_scene_server_cb_param_t *param)
{
esp_ble_mesh_time_scene_server_cb_t btc_ble_mesh_cb =
(esp_ble_mesh_time_scene_server_cb_t)btc_profile_cb_get(BTC_PID_TIME_SCENE_SERVER);
@ -418,17 +409,14 @@ static void btc_ble_mesh_time_scene_server_callback(esp_ble_mesh_time_scene_serv
msg.pid = BTC_PID_TIME_SCENE_SERVER;
msg.act = act;
btc_transfer_context(
&msg, cb_params, sizeof(esp_ble_mesh_time_scene_server_cb_param_t), NULL);
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_time_scene_server_cb_param_t), NULL);
}
void bt_mesh_time_scene_server_cb_evt_to_btc(u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len)
void bt_mesh_time_scene_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const uint8_t *val, size_t len)
{
esp_ble_mesh_time_scene_server_cb_param_t cb_params = {0};
size_t length = 0U;
uint8_t act = 0U;
if (model == NULL || ctx == NULL) {
@ -450,7 +438,7 @@ void bt_mesh_time_scene_server_cb_evt_to_btc(u8_t evt_type,
act = ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_STATUS_MSG_EVT;
break;
default:
BT_ERR("%s, Unknown Time Scene Server event type", __func__);
BT_ERR("Unknown Time Scene server event type %d", evt_type);
return;
}
@ -461,10 +449,11 @@ void bt_mesh_time_scene_server_cb_evt_to_btc(u8_t evt_type,
cb_params.ctx.recv_ttl = ctx->recv_ttl;
cb_params.ctx.recv_op = ctx->recv_op;
cb_params.ctx.recv_dst = ctx->recv_dst;
cb_params.ctx.recv_rssi = ctx->recv_rssi;
cb_params.ctx.send_ttl = ctx->send_ttl;
if (val && len) {
length = (len <= sizeof(cb_params.value)) ? len : sizeof(cb_params.value);
memcpy(&cb_params.value, val, length);
memcpy(&cb_params.value, val, MIN(len, sizeof(cb_params.value)));
}
btc_ble_mesh_time_scene_server_callback(&cb_params, act);
@ -485,9 +474,10 @@ void btc_ble_mesh_time_scene_server_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_TIME_SCENE_SERVER_EVT_MAX) {
btc_ble_mesh_time_scene_server_cb_to_app(msg->act, param);
} else {
BT_ERR("%s, Unknown msg->act = %d", __func__, msg->act);
BT_ERR("%s, Unknown act %d", __func__, msg->act);
}
return;
}
#endif /* CONFIG_BLE_MESH_TIME_SCENE_SERVER */

View File

@ -0,0 +1,62 @@
// Copyright 2020 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef _BTC_BLE_MESH_BLE_H_
#define _BTC_BLE_MESH_BLE_H_
#include <stdint.h>
#include "btc/btc_manage.h"
#include "mesh_bearer_adapt.h"
#include "esp_ble_mesh_ble_api.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef union {
struct {
esp_ble_mesh_ble_adv_param_t param;
esp_ble_mesh_ble_adv_data_t data;
} start_ble_adv;
struct {
uint8_t index;
} stop_ble_adv;
struct {
esp_ble_mesh_ble_scan_param_t param;
} start_ble_scan;
struct {
/* RFU */
} stop_ble_scan;
} btc_ble_mesh_ble_args_t;
typedef enum {
BTC_BLE_MESH_ACT_START_BLE_ADV,
BTC_BLE_MESH_ACT_STOP_BLE_ADV,
BTC_BLE_MESH_ACT_START_BLE_SCAN,
BTC_BLE_MESH_ACT_STOP_BLE_SCAN,
} btc_ble_mesh_ble_act_t;
void bt_mesh_ble_scan_cb_evt_to_btc(const bt_mesh_addr_t *addr,
uint8_t adv_type, uint8_t data[],
uint16_t length, int8_t rssi);
void btc_ble_mesh_ble_call_handler(btc_msg_t *msg);
void btc_ble_mesh_ble_cb_handler(btc_msg_t *msg);
#ifdef __cplusplus
}
#endif
#endif /* _BTC_BLE_MESH_BLE_H_ */

View File

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

View File

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

View File

@ -53,15 +53,14 @@ void btc_ble_mesh_health_client_call_handler(btc_msg_t *msg);
void btc_ble_mesh_health_client_cb_handler(btc_msg_t *msg);
void btc_ble_mesh_health_publish_callback(u32_t opcode,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf);
void btc_ble_mesh_health_publish_callback(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(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);
typedef enum {
BTC_BLE_MESH_ACT_HEALTH_SERVER_FAULT_UPDATE,
@ -80,11 +79,12 @@ 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);
void btc_ble_mesh_health_server_fault_clear(struct bt_mesh_model *model, u16_t company_id);
void btc_ble_mesh_health_server_fault_clear(struct bt_mesh_model *model, uint16_t company_id);
void btc_ble_mesh_health_server_fault_test(struct bt_mesh_model *model, u8_t test_id, u16_t company_id);
void btc_ble_mesh_health_server_fault_test(struct bt_mesh_model *model,
uint8_t test_id, uint16_t company_id);
void btc_ble_mesh_health_server_attention_on(struct bt_mesh_model *model, u8_t time);
void btc_ble_mesh_health_server_attention_on(struct bt_mesh_model *model, uint8_t time);
void btc_ble_mesh_health_server_attention_off(struct bt_mesh_model *model);

View File

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

View File

@ -17,7 +17,9 @@
#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"
@ -37,6 +39,9 @@ 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,
@ -58,6 +63,16 @@ typedef enum {
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,
@ -68,8 +83,8 @@ typedef enum {
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_START_BLE_ADVERTISING,
BTC_BLE_MESH_ACT_STOP_BLE_ADVERTISING,
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;
@ -106,6 +121,21 @@ typedef union {
struct ble_mesh_set_device_name_args {
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];
@ -195,6 +225,37 @@ typedef union {
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;
@ -242,13 +303,18 @@ typedef union {
uint16_t addr_num;
uint16_t *addr;
} proxy_client_remove_filter_addr;
struct ble_mesh_start_ble_advertising_args {
esp_ble_mesh_ble_adv_param_t param;
esp_ble_mesh_ble_adv_data_t data;
} start_ble_advertising;
struct ble_mesh_stop_ble_advertising_args {
uint8_t index;
} stop_ble_advertising;
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;
@ -280,10 +346,20 @@ void btc_ble_mesh_prov_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
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);
@ -294,19 +370,22 @@ 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);
u16_t btc_ble_mesh_provisioner_get_prov_node_count(void);
const char *btc_ble_mesh_provisioner_get_settings_uid(uint8_t index);
uint8_t btc_ble_mesh_provisioner_get_settings_index(const char *uid);
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);

View File

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

View File

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

View File

@ -11,7 +11,8 @@
#ifndef _BLE_MESH_BUF_H_
#define _BLE_MESH_BUF_H_
#include "sdkconfig.h"
#include "mesh_config.h"
#include "mesh_types.h"
#include "mesh_slist.h"
#include "mesh_compiler.h"
@ -51,7 +52,7 @@ __extension__ ({ \
* @param _size Maximum data storage for the buffer.
*/
#define NET_BUF_SIMPLE_DEFINE(_name, _size) \
u8_t net_buf_data_##_name[_size]; \
uint8_t net_buf_data_##_name[_size]; \
struct net_buf_simple _name = { \
.data = net_buf_data_##_name, \
.len = 0, \
@ -70,7 +71,7 @@ __extension__ ({ \
* @param _size Maximum data storage for the buffer.
*/
#define NET_BUF_SIMPLE_DEFINE_STATIC(_name, _size) \
static u8_t net_buf_data_##_name[_size]; \
static uint8_t net_buf_data_##_name[_size]; \
static struct net_buf_simple _name = { \
.data = net_buf_data_##_name, \
.len = 0, \
@ -93,18 +94,18 @@ __extension__ ({ \
*/
struct net_buf_simple {
/** Pointer to the start of data in the buffer. */
u8_t *data;
uint8_t *data;
/** Length of the data behind the data pointer. */
u16_t len;
uint16_t len;
/** Amount of data that this buffer can store. */
u16_t size;
uint16_t size;
/** Start of the data storage. Not to be accessed directly
* (the data pointer should be used instead).
*/
u8_t *__buf;
uint8_t *__buf;
};
/**
@ -123,13 +124,13 @@ struct net_buf_simple {
*
* @return Pointer to stack-allocated net_buf_simple object.
*/
#define NET_BUF_SIMPLE(_size) \
((struct net_buf_simple *)(&(struct { \
struct net_buf_simple buf; \
u8_t data[_size] __net_buf_align; \
}) { \
.buf.size = _size, \
.buf.__buf = NULL, \
#define NET_BUF_SIMPLE(_size) \
((struct net_buf_simple *)(&(struct { \
struct net_buf_simple buf; \
uint8_t data[_size] __net_buf_align; \
}) { \
.buf.size = _size, \
.buf.__buf = NULL, \
}))
/**
@ -145,13 +146,25 @@ static inline void net_buf_simple_init(struct net_buf_simple *buf,
size_t reserve_head)
{
if (!buf->__buf) {
buf->__buf = (u8_t *)buf + sizeof(*buf);
buf->__buf = (uint8_t *)buf + sizeof(*buf);
}
buf->data = buf->__buf + reserve_head;
buf->len = 0;
}
/**
* @brief Initialize a net_buf_simple object with data.
*
* Initialized buffer object with external data.
*
* @param buf Buffer to initialize.
* @param data External data pointer
* @param size Amount of data the pointed data buffer if able to fit.
*/
void net_buf_simple_init_with_data(struct net_buf_simple *buf,
void *data, size_t size);
/**
* @brief Reset buffer
*
@ -217,7 +230,7 @@ void *net_buf_simple_add_mem(struct net_buf_simple *buf, const void *mem,
*
* @return Pointer to the value added
*/
u8_t *net_buf_simple_add_u8(struct net_buf_simple *buf, u8_t val);
uint8_t *net_buf_simple_add_u8(struct net_buf_simple *buf, uint8_t val);
/**
* @brief Add 16-bit value at the end of the buffer
@ -229,7 +242,7 @@ u8_t *net_buf_simple_add_u8(struct net_buf_simple *buf, u8_t val);
* @param buf Buffer to update.
* @param val 16-bit value to be added.
*/
void net_buf_simple_add_le16(struct net_buf_simple *buf, u16_t val);
void net_buf_simple_add_le16(struct net_buf_simple *buf, uint16_t val);
/**
* @brief Add 16-bit value at the end of the buffer
@ -241,7 +254,7 @@ void net_buf_simple_add_le16(struct net_buf_simple *buf, u16_t val);
* @param buf Buffer to update.
* @param val 16-bit value to be added.
*/
void net_buf_simple_add_be16(struct net_buf_simple *buf, u16_t val);
void net_buf_simple_add_be16(struct net_buf_simple *buf, uint16_t val);
/**
* @brief Add 24-bit value at the end of the buffer
@ -253,7 +266,7 @@ void net_buf_simple_add_be16(struct net_buf_simple *buf, u16_t val);
* @param buf Buffer to update.
* @param val 24-bit value to be added.
*/
void net_buf_simple_add_le24(struct net_buf_simple *buf, u32_t val);
void net_buf_simple_add_le24(struct net_buf_simple *buf, uint32_t val);
/**
* @brief Add 24-bit value at the end of the buffer
@ -265,7 +278,7 @@ void net_buf_simple_add_le24(struct net_buf_simple *buf, u32_t val);
* @param buf Buffer to update.
* @param val 24-bit value to be added.
*/
void net_buf_simple_add_be24(struct net_buf_simple *buf, u32_t val);
void net_buf_simple_add_be24(struct net_buf_simple *buf, uint32_t val);
/**
* @brief Add 32-bit value at the end of the buffer
@ -277,7 +290,7 @@ void net_buf_simple_add_be24(struct net_buf_simple *buf, u32_t val);
* @param buf Buffer to update.
* @param val 32-bit value to be added.
*/
void net_buf_simple_add_le32(struct net_buf_simple *buf, u32_t val);
void net_buf_simple_add_le32(struct net_buf_simple *buf, uint32_t val);
/**
* @brief Add 32-bit value at the end of the buffer
@ -289,7 +302,7 @@ void net_buf_simple_add_le32(struct net_buf_simple *buf, u32_t val);
* @param buf Buffer to update.
* @param val 32-bit value to be added.
*/
void net_buf_simple_add_be32(struct net_buf_simple *buf, u32_t val);
void net_buf_simple_add_be32(struct net_buf_simple *buf, uint32_t val);
/**
* @brief Add 48-bit value at the end of the buffer
@ -301,7 +314,7 @@ void net_buf_simple_add_be32(struct net_buf_simple *buf, u32_t val);
* @param buf Buffer to update.
* @param val 48-bit value to be added.
*/
void net_buf_simple_add_le48(struct net_buf_simple *buf, u64_t val);
void net_buf_simple_add_le48(struct net_buf_simple *buf, uint64_t val);
/**
* @brief Add 48-bit value at the end of the buffer
@ -313,7 +326,7 @@ void net_buf_simple_add_le48(struct net_buf_simple *buf, u64_t val);
* @param buf Buffer to update.
* @param val 48-bit value to be added.
*/
void net_buf_simple_add_be48(struct net_buf_simple *buf, u64_t val);
void net_buf_simple_add_be48(struct net_buf_simple *buf, uint64_t val);
/**
* @brief Add 64-bit value at the end of the buffer
@ -325,7 +338,7 @@ void net_buf_simple_add_be48(struct net_buf_simple *buf, u64_t val);
* @param buf Buffer to update.
* @param val 64-bit value to be added.
*/
void net_buf_simple_add_le64(struct net_buf_simple *buf, u64_t val);
void net_buf_simple_add_le64(struct net_buf_simple *buf, uint64_t val);
/**
* @brief Add 64-bit value at the end of the buffer
@ -337,7 +350,7 @@ void net_buf_simple_add_le64(struct net_buf_simple *buf, u64_t val);
* @param buf Buffer to update.
* @param val 64-bit value to be added.
*/
void net_buf_simple_add_be64(struct net_buf_simple *buf, u64_t val);
void net_buf_simple_add_be64(struct net_buf_simple *buf, uint64_t val);
/**
* @brief Push data to the beginning of the buffer.
@ -361,7 +374,7 @@ void *net_buf_simple_push(struct net_buf_simple *buf, size_t len);
* @param buf Buffer to update.
* @param val 16-bit value to be pushed to the buffer.
*/
void net_buf_simple_push_le16(struct net_buf_simple *buf, u16_t val);
void net_buf_simple_push_le16(struct net_buf_simple *buf, uint16_t val);
/**
* @brief Push 16-bit value to the beginning of the buffer
@ -372,7 +385,7 @@ void net_buf_simple_push_le16(struct net_buf_simple *buf, u16_t val);
* @param buf Buffer to update.
* @param val 16-bit value to be pushed to the buffer.
*/
void net_buf_simple_push_be16(struct net_buf_simple *buf, u16_t val);
void net_buf_simple_push_be16(struct net_buf_simple *buf, uint16_t val);
/**
* @brief Push 8-bit value to the beginning of the buffer
@ -382,7 +395,7 @@ void net_buf_simple_push_be16(struct net_buf_simple *buf, u16_t val);
* @param buf Buffer to update.
* @param val 8-bit value to be pushed to the buffer.
*/
void net_buf_simple_push_u8(struct net_buf_simple *buf, u8_t val);
void net_buf_simple_push_u8(struct net_buf_simple *buf, uint8_t val);
/**
* @brief Push 24-bit value to the beginning of the buffer
@ -393,7 +406,7 @@ void net_buf_simple_push_u8(struct net_buf_simple *buf, u8_t val);
* @param buf Buffer to update.
* @param val 24-bit value to be pushed to the buffer.
*/
void net_buf_simple_push_le24(struct net_buf_simple *buf, u32_t val);
void net_buf_simple_push_le24(struct net_buf_simple *buf, uint32_t val);
/**
* @brief Push 24-bit value to the beginning of the buffer
@ -404,7 +417,7 @@ void net_buf_simple_push_le24(struct net_buf_simple *buf, u32_t val);
* @param buf Buffer to update.
* @param val 24-bit value to be pushed to the buffer.
*/
void net_buf_simple_push_be24(struct net_buf_simple *buf, u32_t val);
void net_buf_simple_push_be24(struct net_buf_simple *buf, uint32_t val);
/**
* @brief Push 32-bit value to the beginning of the buffer
@ -415,7 +428,7 @@ void net_buf_simple_push_be24(struct net_buf_simple *buf, u32_t val);
* @param buf Buffer to update.
* @param val 32-bit value to be pushed to the buffer.
*/
void net_buf_simple_push_le32(struct net_buf_simple *buf, u32_t val);
void net_buf_simple_push_le32(struct net_buf_simple *buf, uint32_t val);
/**
* @brief Push 32-bit value to the beginning of the buffer
@ -426,7 +439,7 @@ void net_buf_simple_push_le32(struct net_buf_simple *buf, u32_t val);
* @param buf Buffer to update.
* @param val 32-bit value to be pushed to the buffer.
*/
void net_buf_simple_push_be32(struct net_buf_simple *buf, u32_t val);
void net_buf_simple_push_be32(struct net_buf_simple *buf, uint32_t val);
/**
* @brief Push 48-bit value to the beginning of the buffer
@ -437,7 +450,7 @@ void net_buf_simple_push_be32(struct net_buf_simple *buf, u32_t val);
* @param buf Buffer to update.
* @param val 48-bit value to be pushed to the buffer.
*/
void net_buf_simple_push_le48(struct net_buf_simple *buf, u64_t val);
void net_buf_simple_push_le48(struct net_buf_simple *buf, uint64_t val);
/**
* @brief Push 48-bit value to the beginning of the buffer
@ -448,7 +461,7 @@ void net_buf_simple_push_le48(struct net_buf_simple *buf, u64_t val);
* @param buf Buffer to update.
* @param val 48-bit value to be pushed to the buffer.
*/
void net_buf_simple_push_be48(struct net_buf_simple *buf, u64_t val);
void net_buf_simple_push_be48(struct net_buf_simple *buf, uint64_t val);
/**
* @brief Push 64-bit value to the beginning of the buffer
@ -459,7 +472,7 @@ void net_buf_simple_push_be48(struct net_buf_simple *buf, u64_t val);
* @param buf Buffer to update.
* @param val 64-bit value to be pushed to the buffer.
*/
void net_buf_simple_push_le64(struct net_buf_simple *buf, u64_t val);
void net_buf_simple_push_le64(struct net_buf_simple *buf, uint64_t val);
/**
* @brief Push 64-bit value to the beginning of the buffer
@ -470,7 +483,7 @@ void net_buf_simple_push_le64(struct net_buf_simple *buf, u64_t val);
* @param buf Buffer to update.
* @param val 64-bit value to be pushed to the buffer.
*/
void net_buf_simple_push_be64(struct net_buf_simple *buf, u64_t val);
void net_buf_simple_push_be64(struct net_buf_simple *buf, uint64_t val);
/**
* @brief Remove data from the beginning of the buffer.
@ -508,7 +521,7 @@ void *net_buf_simple_pull_mem(struct net_buf_simple *buf, size_t len);
*
* @return The 8-bit removed value
*/
u8_t net_buf_simple_pull_u8(struct net_buf_simple *buf);
uint8_t net_buf_simple_pull_u8(struct net_buf_simple *buf);
/**
* @brief Remove and convert 16 bits from the beginning of the buffer.
@ -520,7 +533,7 @@ u8_t net_buf_simple_pull_u8(struct net_buf_simple *buf);
*
* @return 16-bit value converted from little endian to host endian.
*/
u16_t net_buf_simple_pull_le16(struct net_buf_simple *buf);
uint16_t net_buf_simple_pull_le16(struct net_buf_simple *buf);
/**
* @brief Remove and convert 16 bits from the beginning of the buffer.
@ -532,7 +545,7 @@ u16_t net_buf_simple_pull_le16(struct net_buf_simple *buf);
*
* @return 16-bit value converted from big endian to host endian.
*/
u16_t net_buf_simple_pull_be16(struct net_buf_simple *buf);
uint16_t net_buf_simple_pull_be16(struct net_buf_simple *buf);
/**
* @brief Remove and convert 24 bits from the beginning of the buffer.
@ -544,7 +557,7 @@ u16_t net_buf_simple_pull_be16(struct net_buf_simple *buf);
*
* @return 24-bit value converted from little endian to host endian.
*/
u32_t net_buf_simple_pull_le24(struct net_buf_simple *buf);
uint32_t net_buf_simple_pull_le24(struct net_buf_simple *buf);
/**
* @brief Remove and convert 24 bits from the beginning of the buffer.
@ -556,7 +569,7 @@ u32_t net_buf_simple_pull_le24(struct net_buf_simple *buf);
*
* @return 24-bit value converted from big endian to host endian.
*/
u32_t net_buf_simple_pull_be24(struct net_buf_simple *buf);
uint32_t net_buf_simple_pull_be24(struct net_buf_simple *buf);
/**
* @brief Remove and convert 32 bits from the beginning of the buffer.
@ -568,7 +581,7 @@ u32_t net_buf_simple_pull_be24(struct net_buf_simple *buf);
*
* @return 32-bit value converted from little endian to host endian.
*/
u32_t net_buf_simple_pull_le32(struct net_buf_simple *buf);
uint32_t net_buf_simple_pull_le32(struct net_buf_simple *buf);
/**
* @brief Remove and convert 32 bits from the beginning of the buffer.
@ -580,7 +593,7 @@ u32_t net_buf_simple_pull_le32(struct net_buf_simple *buf);
*
* @return 32-bit value converted from big endian to host endian.
*/
u32_t net_buf_simple_pull_be32(struct net_buf_simple *buf);
uint32_t net_buf_simple_pull_be32(struct net_buf_simple *buf);
/**
* @brief Remove and convert 48 bits from the beginning of the buffer.
@ -592,7 +605,7 @@ u32_t net_buf_simple_pull_be32(struct net_buf_simple *buf);
*
* @return 48-bit value converted from little endian to host endian.
*/
u64_t net_buf_simple_pull_le48(struct net_buf_simple *buf);
uint64_t net_buf_simple_pull_le48(struct net_buf_simple *buf);
/**
* @brief Remove and convert 48 bits from the beginning of the buffer.
@ -604,7 +617,7 @@ u64_t net_buf_simple_pull_le48(struct net_buf_simple *buf);
*
* @return 48-bit value converted from big endian to host endian.
*/
u64_t net_buf_simple_pull_be48(struct net_buf_simple *buf);
uint64_t net_buf_simple_pull_be48(struct net_buf_simple *buf);
/**
* @brief Remove and convert 64 bits from the beginning of the buffer.
@ -616,7 +629,7 @@ u64_t net_buf_simple_pull_be48(struct net_buf_simple *buf);
*
* @return 64-bit value converted from little endian to host endian.
*/
u64_t net_buf_simple_pull_le64(struct net_buf_simple *buf);
uint64_t net_buf_simple_pull_le64(struct net_buf_simple *buf);
/**
* @brief Remove and convert 64 bits from the beginning of the buffer.
@ -628,7 +641,7 @@ u64_t net_buf_simple_pull_le64(struct net_buf_simple *buf);
*
* @return 64-bit value converted from big endian to host endian.
*/
u64_t net_buf_simple_pull_be64(struct net_buf_simple *buf);
uint64_t net_buf_simple_pull_be64(struct net_buf_simple *buf);
/**
* @brief Get the tail pointer for a buffer.
@ -639,7 +652,7 @@ u64_t net_buf_simple_pull_be64(struct net_buf_simple *buf);
*
* @return Tail pointer for the buffer.
*/
static inline u8_t *net_buf_simple_tail(struct net_buf_simple *buf)
static inline uint8_t *net_buf_simple_tail(struct net_buf_simple *buf)
{
return buf->data + buf->len;
}
@ -675,9 +688,9 @@ size_t net_buf_simple_tailroom(struct net_buf_simple *buf);
*/
struct net_buf_simple_state {
/** Offset of the data pointer from the beginning of the storage */
u16_t offset;
uint16_t offset;
/** Length of data */
u16_t len;
uint16_t len;
};
/**
@ -705,7 +718,7 @@ static inline void net_buf_simple_save(struct net_buf_simple *buf,
* @param state Stored state.
*/
static inline void net_buf_simple_restore(struct net_buf_simple *buf,
struct net_buf_simple_state *state)
struct net_buf_simple_state *state)
{
buf->data = buf->__buf + state->offset;
buf->len = state->len;
@ -748,10 +761,10 @@ struct net_buf {
};
/** Reference count. */
u8_t ref;
uint8_t ref;
/** Bit-field of buffer flags. */
u8_t flags;
uint8_t flags;
/** Where the buffer should go when freed up. */
struct net_buf_pool *pool;
@ -763,32 +776,32 @@ struct net_buf {
/* The ABI of this struct must match net_buf_simple */
struct {
/** Pointer to the start of data in the buffer. */
u8_t *data;
uint8_t *data;
/** Length of the data behind the data pointer. */
u16_t len;
uint16_t len;
/** Amount of data that this buffer can store. */
u16_t size;
uint16_t size;
/** Start of the data storage. Not to be accessed
* directly (the data pointer should be used
* instead).
*/
u8_t *__buf;
uint8_t *__buf;
};
struct net_buf_simple b;
};
/** System metadata for this buffer. */
u8_t user_data[BLE_MESH_NET_BUF_USER_DATA_SIZE] __net_buf_align;
uint8_t user_data[BLE_MESH_NET_BUF_USER_DATA_SIZE] __net_buf_align;
};
struct net_buf_data_cb {
u8_t *(*alloc)(struct net_buf *buf, size_t *size, s32_t timeout);
u8_t *(*ref)(struct net_buf *buf, u8_t *data);
void (*unref)(struct net_buf *buf, u8_t *data);
uint8_t *(*alloc)(struct net_buf *buf, size_t *size, int32_t timeout);
uint8_t *(*ref)(struct net_buf *buf, uint8_t *data);
void (*unref)(struct net_buf *buf, uint8_t *data);
};
struct net_buf_data_alloc {
@ -798,17 +811,17 @@ struct net_buf_data_alloc {
struct net_buf_pool {
/** Number of buffers in pool */
const u16_t buf_count;
const uint16_t buf_count;
/** Number of uninitialized buffers */
u16_t uninit_count;
uint16_t uninit_count;
#if defined(CONFIG_BLE_MESH_NET_BUF_POOL_USAGE)
/** Amount of available buffers in the pool. */
s16_t avail_count;
int16_t avail_count;
/** Total size of the pool. */
const u16_t pool_size;
const uint16_t pool_size;
/** Name of the pool. Used when printing pool information. */
const char *name;
@ -848,7 +861,7 @@ struct net_buf_pool {
struct net_buf_pool_fixed {
size_t data_size;
u8_t *data_pool;
uint8_t *data_pool;
};
/** @cond INTERNAL_HIDDEN */
@ -883,10 +896,10 @@ extern const struct net_buf_data_cb net_buf_fixed_cb;
*/
#define NET_BUF_POOL_FIXED_DEFINE(_name, _count, _data_size, _destroy) \
static struct net_buf net_buf_##_name[_count]; \
static u8_t net_buf_data_##_name[_count][_data_size]; \
static uint8_t net_buf_data_##_name[_count][_data_size]; \
static const struct net_buf_pool_fixed net_buf_fixed_##_name = { \
.data_size = _data_size, \
.data_pool = (u8_t *)net_buf_data_##_name, \
.data_pool = (uint8_t *)net_buf_data_##_name, \
}; \
static const struct net_buf_data_alloc net_buf_fixed_alloc_##_name = { \
.cb = &net_buf_fixed_cb, \
@ -950,12 +963,12 @@ int net_buf_id(struct net_buf *buf);
* @return New buffer or NULL if out of buffers.
*/
#if defined(CONFIG_BLE_MESH_NET_BUF_LOG)
struct net_buf *net_buf_alloc_fixed_debug(struct net_buf_pool *pool, s32_t timeout,
const char *func, int line);
struct net_buf *net_buf_alloc_fixed_debug(struct net_buf_pool *pool, int32_t timeout,
const char *func, int line);
#define net_buf_alloc_fixed(_pool, _timeout) \
net_buf_alloc_fixed_debug(_pool, _timeout, __func__, __LINE__)
#else
struct net_buf *net_buf_alloc_fixed(struct net_buf_pool *pool, s32_t timeout);
struct net_buf *net_buf_alloc_fixed(struct net_buf_pool *pool, int32_t timeout);
#endif
/**
@ -1619,8 +1632,8 @@ struct net_buf *net_buf_frag_add(struct net_buf *head, struct net_buf *frag);
*/
#if defined(CONFIG_BLE_MESH_NET_BUF_LOG)
struct net_buf *net_buf_frag_del_debug(struct net_buf *parent,
struct net_buf *frag,
const char *func, int line);
struct net_buf *frag,
const char *func, int line);
#define net_buf_frag_del(_parent, _frag) \
net_buf_frag_del_debug(_parent, _frag, __func__, __LINE__)
#else
@ -1643,7 +1656,7 @@ struct net_buf *net_buf_frag_del(struct net_buf *parent, struct net_buf *frag);
* @return number of bytes actually copied
*/
size_t net_buf_linearize(void *dst, size_t dst_len,
struct net_buf *src, size_t offset, size_t len);
struct net_buf *src, size_t offset, size_t len);
/**
* @typedef net_buf_allocator_cb
@ -1659,7 +1672,7 @@ size_t net_buf_linearize(void *dst, size_t dst_len,
* @param user_data The user data given in net_buf_append_bytes call.
* @return pointer to allocated net_buf or NULL on error.
*/
typedef struct net_buf *(*net_buf_allocator_cb)(s32_t timeout, void *user_data);
typedef struct net_buf *(*net_buf_allocator_cb)(int32_t timeout, void *user_data);
/**
* @brief Append data to a list of net_buf
@ -1682,8 +1695,8 @@ typedef struct net_buf *(*net_buf_allocator_cb)(s32_t timeout, void *user_data);
* were no free fragments in a pool to accommodate all data.
*/
size_t net_buf_append_bytes(struct net_buf *buf, size_t len,
const void *value, s32_t timeout,
net_buf_allocator_cb allocate_cb, void *user_data);
const void *value, int32_t timeout,
net_buf_allocator_cb allocate_cb, void *user_data);
/**
* @brief Skip N number of bytes in a net_buf

View File

@ -16,40 +16,40 @@ extern "C" {
/* Internal helpers only used by the sys_* APIs further below */
#ifndef __bswap_16
#define __bswap_16(x) ((u16_t) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8)))
#define __bswap_16(x) ((uint16_t) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8)))
#endif
#ifndef __bswap_24
#define __bswap_24(x) ((u32_t) ((((x) >> 16) & 0xff) | \
(((x)) & 0xff00) | \
(((x) & 0xff) << 16)))
#define __bswap_24(x) ((uint32_t) ((((x) >> 16) & 0xff) | \
(((x)) & 0xff00) | \
(((x) & 0xff) << 16)))
#endif
#ifndef __bswap_32
#define __bswap_32(x) ((u32_t) ((((x) >> 24) & 0xff) | \
(((x) >> 8) & 0xff00) | \
(((x) & 0xff00) << 8) | \
(((x) & 0xff) << 24)))
#define __bswap_32(x) ((uint32_t) ((((x) >> 24) & 0xff) | \
(((x) >> 8) & 0xff00) | \
(((x) & 0xff00) << 8) | \
(((x) & 0xff) << 24)))
#endif
#ifndef __bswap_48
#define __bswap_48(x) ((u64_t) ((((x) >> 40) & 0xff) | \
(((x) >> 24) & 0xff00) | \
(((x) >> 8) & 0xff0000) | \
(((x) & 0xff0000) << 8) | \
(((x) & 0xff00) << 24) | \
(((x) & 0xff) << 40)))
#define __bswap_48(x) ((uint64_t) ((((x) >> 40) & 0xff) | \
(((x) >> 24) & 0xff00) | \
(((x) >> 8) & 0xff0000) | \
(((x) & 0xff0000) << 8) | \
(((x) & 0xff00) << 24) | \
(((x) & 0xff) << 40)))
#endif
#ifndef __bswap_64
#define __bswap_64(x) ((u64_t) ((((x) >> 56) & 0xff) | \
(((x) >> 40) & 0xff00) | \
(((x) >> 24) & 0xff0000) | \
(((x) >> 8) & 0xff000000) | \
(((x) & 0xff000000) << 8) | \
(((x) & 0xff0000) << 24) | \
(((x) & 0xff00) << 40) | \
(((x) & 0xff) << 56)))
#define __bswap_64(x) ((uint64_t) ((((x) >> 56) & 0xff) | \
(((x) >> 40) & 0xff00) | \
(((x) >> 24) & 0xff0000) | \
(((x) >> 8) & 0xff000000) | \
(((x) & 0xff000000) << 8) | \
(((x) & 0xff0000) << 24) | \
(((x) & 0xff00) << 40) | \
(((x) & 0xff) << 56)))
#endif
/** @def sys_le16_to_cpu
@ -250,7 +250,7 @@ extern "C" {
* @param val 16-bit integer in host endianness.
* @param dst Destination memory address to store the result.
*/
static inline void sys_put_be16(u16_t val, u8_t dst[2])
static inline void sys_put_be16(uint16_t val, uint8_t dst[2])
{
dst[0] = val >> 8;
dst[1] = val;
@ -265,7 +265,7 @@ static inline void sys_put_be16(u16_t val, u8_t dst[2])
* @param val 24-bit integer in host endianness.
* @param dst Destination memory address to store the result.
*/
static inline void sys_put_be24(u32_t val, u8_t dst[3])
static inline void sys_put_be24(uint32_t val, uint8_t dst[3])
{
dst[0] = val >> 16;
sys_put_be16(val, &dst[1]);
@ -280,7 +280,7 @@ static inline void sys_put_be24(u32_t val, u8_t dst[3])
* @param val 32-bit integer in host endianness.
* @param dst Destination memory address to store the result.
*/
static inline void sys_put_be32(u32_t val, u8_t dst[4])
static inline void sys_put_be32(uint32_t val, uint8_t dst[4])
{
sys_put_be16(val >> 16, dst);
sys_put_be16(val, &dst[2]);
@ -295,7 +295,7 @@ static inline void sys_put_be32(u32_t val, u8_t dst[4])
* @param val 48-bit integer in host endianness.
* @param dst Destination memory address to store the result.
*/
static inline void sys_put_be48(u64_t val, u8_t dst[6])
static inline void sys_put_be48(uint64_t val, uint8_t dst[6])
{
sys_put_be16(val >> 32, dst);
sys_put_be32(val, &dst[2]);
@ -310,7 +310,7 @@ static inline void sys_put_be48(u64_t val, u8_t dst[6])
* @param val 64-bit integer in host endianness.
* @param dst Destination memory address to store the result.
*/
static inline void sys_put_be64(u64_t val, u8_t dst[8])
static inline void sys_put_be64(uint64_t val, uint8_t dst[8])
{
sys_put_be32(val >> 32, dst);
sys_put_be32(val, &dst[4]);
@ -325,7 +325,7 @@ static inline void sys_put_be64(u64_t val, u8_t dst[8])
* @param val 16-bit integer in host endianness.
* @param dst Destination memory address to store the result.
*/
static inline void sys_put_le16(u16_t val, u8_t dst[2])
static inline void sys_put_le16(uint16_t val, uint8_t dst[2])
{
dst[0] = val;
dst[1] = val >> 8;
@ -340,7 +340,7 @@ static inline void sys_put_le16(u16_t val, u8_t dst[2])
* @param val 24-bit integer in host endianness.
* @param dst Destination memory address to store the result.
*/
static inline void sys_put_le24(u32_t val, u8_t dst[3])
static inline void sys_put_le24(uint32_t val, uint8_t dst[3])
{
sys_put_le16(val, dst);
dst[2] = val >> 16;
@ -355,7 +355,7 @@ static inline void sys_put_le24(u32_t val, u8_t dst[3])
* @param val 32-bit integer in host endianness.
* @param dst Destination memory address to store the result.
*/
static inline void sys_put_le32(u32_t val, u8_t dst[4])
static inline void sys_put_le32(uint32_t val, uint8_t dst[4])
{
sys_put_le16(val, dst);
sys_put_le16(val >> 16, &dst[2]);
@ -370,7 +370,7 @@ static inline void sys_put_le32(u32_t val, u8_t dst[4])
* @param val 48-bit integer in host endianness.
* @param dst Destination memory address to store the result.
*/
static inline void sys_put_le48(u64_t val, u8_t dst[6])
static inline void sys_put_le48(uint64_t val, uint8_t dst[6])
{
sys_put_le32(val, dst);
sys_put_le16(val >> 32, &dst[4]);
@ -385,7 +385,7 @@ static inline void sys_put_le48(u64_t val, u8_t dst[6])
* @param val 64-bit integer in host endianness.
* @param dst Destination memory address to store the result.
*/
static inline void sys_put_le64(u64_t val, u8_t dst[8])
static inline void sys_put_le64(uint64_t val, uint8_t dst[8])
{
sys_put_le32(val, dst);
sys_put_le32(val >> 32, &dst[4]);
@ -401,9 +401,9 @@ static inline void sys_put_le64(u64_t val, u8_t dst[8])
*
* @return 16-bit integer in host endianness.
*/
static inline u16_t sys_get_be16(const u8_t src[2])
static inline uint16_t sys_get_be16(const uint8_t src[2])
{
return ((u16_t)src[0] << 8) | src[1];
return ((uint16_t)src[0] << 8) | src[1];
}
/**
@ -416,9 +416,9 @@ static inline u16_t sys_get_be16(const u8_t src[2])
*
* @return 24-bit integer in host endianness.
*/
static inline u32_t sys_get_be24(const u8_t src[3])
static inline uint32_t sys_get_be24(const uint8_t src[3])
{
return ((u32_t)src[0] << 16) | sys_get_be16(&src[1]);
return ((uint32_t)src[0] << 16) | sys_get_be16(&src[1]);
}
/**
@ -431,9 +431,9 @@ static inline u32_t sys_get_be24(const u8_t src[3])
*
* @return 32-bit integer in host endianness.
*/
static inline u32_t sys_get_be32(const u8_t src[4])
static inline uint32_t sys_get_be32(const uint8_t src[4])
{
return ((u32_t)sys_get_be16(&src[0]) << 16) | sys_get_be16(&src[2]);
return ((uint32_t)sys_get_be16(&src[0]) << 16) | sys_get_be16(&src[2]);
}
/**
@ -446,9 +446,9 @@ static inline u32_t sys_get_be32(const u8_t src[4])
*
* @return 48-bit integer in host endianness.
*/
static inline u64_t sys_get_be48(const u8_t src[6])
static inline uint64_t sys_get_be48(const uint8_t src[6])
{
return ((u64_t)sys_get_be32(&src[0]) << 32) | sys_get_be16(&src[4]);
return ((uint64_t)sys_get_be32(&src[0]) << 32) | sys_get_be16(&src[4]);
}
/**
@ -461,9 +461,9 @@ static inline u64_t sys_get_be48(const u8_t src[6])
*
* @return 64-bit integer in host endianness.
*/
static inline u64_t sys_get_be64(const u8_t src[8])
static inline uint64_t sys_get_be64(const uint8_t src[8])
{
return ((u64_t)sys_get_be32(&src[0]) << 32) | sys_get_be32(&src[4]);
return ((uint64_t)sys_get_be32(&src[0]) << 32) | sys_get_be32(&src[4]);
}
/**
@ -476,9 +476,9 @@ static inline u64_t sys_get_be64(const u8_t src[8])
*
* @return 16-bit integer in host endianness.
*/
static inline u16_t sys_get_le16(const u8_t src[2])
static inline uint16_t sys_get_le16(const uint8_t src[2])
{
return ((u16_t)src[1] << 8) | src[0];
return ((uint16_t)src[1] << 8) | src[0];
}
/**
@ -491,9 +491,9 @@ static inline u16_t sys_get_le16(const u8_t src[2])
*
* @return 24-bit integer in host endianness.
*/
static inline u32_t sys_get_le24(const u8_t src[3])
static inline uint32_t sys_get_le24(const uint8_t src[3])
{
return ((u32_t)src[2] << 16) | sys_get_le16(&src[0]);
return ((uint32_t)src[2] << 16) | sys_get_le16(&src[0]);
}
/**
@ -506,9 +506,9 @@ static inline u32_t sys_get_le24(const u8_t src[3])
*
* @return 32-bit integer in host endianness.
*/
static inline u32_t sys_get_le32(const u8_t src[4])
static inline uint32_t sys_get_le32(const uint8_t src[4])
{
return ((u32_t)sys_get_le16(&src[2]) << 16) | sys_get_le16(&src[0]);
return ((uint32_t)sys_get_le16(&src[2]) << 16) | sys_get_le16(&src[0]);
}
/**
@ -521,9 +521,9 @@ static inline u32_t sys_get_le32(const u8_t src[4])
*
* @return 48-bit integer in host endianness.
*/
static inline u64_t sys_get_le48(const u8_t src[6])
static inline uint64_t sys_get_le48(const uint8_t src[6])
{
return ((u64_t)sys_get_le32(&src[2]) << 32) | sys_get_le16(&src[0]);
return ((uint64_t)sys_get_le32(&src[2]) << 32) | sys_get_le16(&src[0]);
}
/**
@ -536,9 +536,9 @@ static inline u64_t sys_get_le48(const u8_t src[6])
*
* @return 64-bit integer in host endianness.
*/
static inline u64_t sys_get_le64(const u8_t src[8])
static inline uint64_t sys_get_le64(const uint8_t src[8])
{
return ((u64_t)sys_get_le32(&src[4]) << 32) | sys_get_le32(&src[0]);
return ((uint64_t)sys_get_le32(&src[4]) << 32) | sys_get_le32(&src[0]);
}
/**
@ -556,8 +556,8 @@ static inline u64_t sys_get_le64(const u8_t src[8])
*/
static inline void sys_memcpy_swap(void *dst, const void *src, size_t length)
{
u8_t *pdst = (u8_t *)dst;
const u8_t *psrc = (const u8_t *)src;
uint8_t *pdst = (uint8_t *)dst;
const uint8_t *psrc = (const uint8_t *)src;
__ASSERT(((psrc < pdst && (psrc + length) <= pdst) ||
(psrc > pdst && (pdst + length) <= psrc)),
@ -585,10 +585,10 @@ static inline void sys_mem_swap(void *buf, size_t length)
size_t i;
for (i = 0; i < (length / 2); i++) {
u8_t tmp = ((u8_t *)buf)[i];
uint8_t tmp = ((uint8_t *)buf)[i];
((u8_t *)buf)[i] = ((u8_t *)buf)[length - 1 - i];
((u8_t *)buf)[length - 1 - i] = tmp;
((uint8_t *)buf)[i] = ((uint8_t *)buf)[length - 1 - i];
((uint8_t *)buf)[length - 1 - i] = tmp;
}
}

View File

@ -22,6 +22,7 @@
#include <stddef.h>
#include <stdlib.h>
#include "esp_attr.h"
#include "esp_heap_caps.h"
#include "mesh_byteorder.h"
@ -34,14 +35,11 @@
extern "C" {
#endif
#if CONFIG_BLE_MESH_ALLOC_FROM_PSRAM_FIRST
#define bt_mesh_malloc(size) heap_caps_malloc_prefer(size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL)
#define bt_mesh_calloc(size) heap_caps_calloc_prefer(1, size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL)
#else
#define bt_mesh_malloc(size) malloc((size))
#define bt_mesh_calloc(size) calloc(1, (size))
#endif /* CONFIG_BLE_MESH_ALLOC_FROM_PSRAM_FIRST */
#define bt_mesh_free(p) free((p))
IRAM_ATTR void *bt_mesh_malloc(size_t size);
IRAM_ATTR void *bt_mesh_calloc(size_t size);
IRAM_ATTR void bt_mesh_free(void *ptr);
/**
* @brief This function allocates memory to store outgoing message.
@ -50,7 +48,7 @@ extern "C" {
*
* @return NULL-fail, pointer of a net_buf_simple structure-success
*/
struct net_buf_simple *bt_mesh_alloc_buf(u16_t size);
struct net_buf_simple *bt_mesh_alloc_buf(uint16_t size);
/**
* @brief This function releases the memory allocated for the outgoing message.
@ -73,7 +71,9 @@ void bt_mesh_free_buf(struct net_buf_simple *buf);
*
* @return 0 - Node, 1 - Provisioner
*/
u8_t bt_mesh_get_device_role(struct bt_mesh_model *model, bool srv_send);
uint8_t bt_mesh_get_device_role(struct bt_mesh_model *model, bool srv_send);
int bt_mesh_rand(void *buf, size_t len);
#ifdef __cplusplus
}

View File

@ -0,0 +1,55 @@
// Copyright 2020-2021 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 _BLE_MESH_CONFIG_H_
#define _BLE_MESH_CONFIG_H_
#include "sdkconfig.h"
#ifdef __cplusplus
extern "C" {
#endif
#define CONFIG_BLE_MESH_GENERIC_CLIENT (CONFIG_BLE_MESH_GENERIC_ONOFF_CLI || \
CONFIG_BLE_MESH_GENERIC_LEVEL_CLI || \
CONFIG_BLE_MESH_GENERIC_DEF_TRANS_TIME_CLI || \
CONFIG_BLE_MESH_GENERIC_POWER_ONOFF_CLI || \
CONFIG_BLE_MESH_GENERIC_POWER_LEVEL_CLI || \
CONFIG_BLE_MESH_GENERIC_BATTERY_CLI || \
CONFIG_BLE_MESH_GENERIC_LOCATION_CLI || \
CONFIG_BLE_MESH_GENERIC_PROPERTY_CLI)
#define CONFIG_BLE_MESH_TIME_SCENE_CLIENT (CONFIG_BLE_MESH_TIME_CLI || \
CONFIG_BLE_MESH_SCENE_CLI || \
CONFIG_BLE_MESH_SCHEDULER_CLI)
#define CONFIG_BLE_MESH_LIGHTING_CLIENT (CONFIG_BLE_MESH_LIGHT_LIGHTNESS_CLI || \
CONFIG_BLE_MESH_LIGHT_CTL_CLI || \
CONFIG_BLE_MESH_LIGHT_HSL_CLI || \
CONFIG_BLE_MESH_LIGHT_XYL_CLI || \
CONFIG_BLE_MESH_LIGHT_LC_CLI)
#define CONFIG_BLE_MESH_SERVER_MODEL (CONFIG_BLE_MESH_GENERIC_SERVER || \
CONFIG_BLE_MESH_SENSOR_SERVER || \
CONFIG_BLE_MESH_TIME_SCENE_SERVER || \
CONFIG_BLE_MESH_LIGHTING_SERVER)
#define CONFIG_BLE_MESH_BLE_COEX_SUPPORT (CONFIG_BLE_MESH_SUPPORT_BLE_ADV || \
CONFIG_BLE_MESH_SUPPORT_BLE_SCAN)
#ifdef __cplusplus
}
#endif
#endif /* _BLE_MESH_CONFIG_H_ */

View File

@ -291,7 +291,7 @@ static inline sys_dnode_t *sys_dlist_peek_head_not_empty(sys_dlist_t *list)
*/
static inline sys_dnode_t *sys_dlist_peek_next_no_check(sys_dlist_t *list,
sys_dnode_t *node)
sys_dnode_t *node)
{
return (node == list->tail) ? NULL : node->next;
}
@ -307,7 +307,7 @@ static inline sys_dnode_t *sys_dlist_peek_next_no_check(sys_dlist_t *list,
*/
static inline sys_dnode_t *sys_dlist_peek_next(sys_dlist_t *list,
sys_dnode_t *node)
sys_dnode_t *node)
{
return node ? sys_dlist_peek_next_no_check(list, node) : NULL;
}
@ -379,7 +379,8 @@ static inline void sys_dlist_prepend(sys_dlist_t *list, sys_dnode_t *node)
*/
static inline void sys_dlist_insert_after(sys_dlist_t *list,
sys_dnode_t *insert_point, sys_dnode_t *node)
sys_dnode_t *insert_point,
sys_dnode_t *node)
{
if (!insert_point) {
sys_dlist_prepend(list, node);
@ -405,7 +406,8 @@ static inline void sys_dlist_insert_after(sys_dlist_t *list,
*/
static inline void sys_dlist_insert_before(sys_dlist_t *list,
sys_dnode_t *insert_point, sys_dnode_t *node)
sys_dnode_t *insert_point,
sys_dnode_t *node)
{
if (!insert_point) {
sys_dlist_append(list, node);

View File

@ -27,7 +27,7 @@ extern "C" {
* @return most significant bit set, 0 if @a op is 0
*/
static ALWAYS_INLINE unsigned int find_msb_set(u32_t op)
static ALWAYS_INLINE unsigned int find_msb_set(uint32_t op)
{
if (op == 0) {
return 0;
@ -48,7 +48,7 @@ static ALWAYS_INLINE unsigned int find_msb_set(u32_t op)
* @return least significant bit set, 0 if @a op is 0
*/
static ALWAYS_INLINE unsigned int find_lsb_set(u32_t op)
static ALWAYS_INLINE unsigned int find_lsb_set(uint32_t op)
{
return __builtin_ffs(op);
}

View File

@ -13,6 +13,7 @@
#include "freertos/queue.h"
#include "freertos/semphr.h"
#include "mesh_config.h"
#include "mesh_types.h"
#ifdef __cplusplus
@ -36,6 +37,8 @@ extern "C" {
#endif
#define BLE_MESH_ADV_TASK_STACK_SIZE 3072
#define BLE_MESH_ADV_TASK_NAME "mesh_adv_task"
#define BLE_MESH_ADV_TASK_PRIO (configMAX_PRIORITIES - 5)
/**
* @brief Put the current thread to sleep.
@ -47,7 +50,7 @@ extern "C" {
*
* @return N/A
*/
void k_sleep(s32_t duration);
void k_sleep(int32_t duration);
#ifdef __cplusplus
}

View File

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

View File

@ -312,7 +312,7 @@ static inline void sys_slist_append(sys_slist_t *list,
* @param tail A pointer to the last element of the list to append
*/
static inline void sys_slist_append_list(sys_slist_t *list,
void *head, void *tail)
void *head, void *tail)
{
if (!list->tail) {
list->head = (sys_snode_t *)head;
@ -333,7 +333,7 @@ static inline void sys_slist_append_list(sys_slist_t *list,
* @param list_to_append A pointer to the list to append.
*/
static inline void sys_slist_merge_slist(sys_slist_t *list,
sys_slist_t *list_to_append)
sys_slist_t *list_to_append)
{
sys_slist_append_list(list, list_to_append->head,
list_to_append->tail);
@ -443,7 +443,7 @@ static inline void sys_slist_remove(sys_slist_t *list,
* @return true if node was removed
*/
static inline bool sys_slist_find_and_remove(sys_slist_t *list,
sys_snode_t *node)
sys_snode_t *node)
{
sys_snode_t *prev = NULL;
sys_snode_t *test;

View File

@ -142,7 +142,7 @@ struct k_work {
*
* @return Current uptime.
*/
u32_t k_uptime_get_32(void);
uint32_t k_uptime_get_32(void);
struct k_delayed_work {
struct k_work work;
@ -180,9 +180,9 @@ struct k_delayed_work {
* @retval -EINVAL Work item is being processed or has completed its work.
* @retval -EADDRINUSE Work item is pending on a different workqueue.
*/
int k_delayed_work_submit(struct k_delayed_work *work, s32_t delay);
int k_delayed_work_submit(struct k_delayed_work *work, int32_t delay);
int k_delayed_work_submit_periodic(struct k_delayed_work *work, s32_t period);
int k_delayed_work_submit_periodic(struct k_delayed_work *work, int32_t period);
/**
* @brief Get time remaining before a delayed work gets scheduled.
@ -195,7 +195,7 @@ int k_delayed_work_submit_periodic(struct k_delayed_work *work, s32_t period);
*
* @return Remaining time (in milliseconds).
*/
s32_t k_delayed_work_remaining_get(struct k_delayed_work *work);
int32_t k_delayed_work_remaining_get(struct k_delayed_work *work);
/**
* @brief Submit a work item to the system workqueue.
@ -254,7 +254,7 @@ int k_delayed_work_init(struct k_delayed_work *work, k_work_handler_t handler);
*
* @return Current uptime.
*/
s64_t k_uptime_get(void);
int64_t k_uptime_get(void);
void bt_mesh_timer_init(void);
void bt_mesh_timer_deinit(void);

View File

@ -17,39 +17,39 @@ extern "C" {
#endif
/* Define common tracing for all */
#ifndef LOG_LEVEL_ERROR
#define LOG_LEVEL_ERROR 1
#endif /* LOG_LEVEL_ERROR */
#ifndef BLE_MESH_LOG_LEVEL_ERROR
#define BLE_MESH_LOG_LEVEL_ERROR 1
#endif /* BLE_MESH_LOG_LEVEL_ERROR */
#ifndef LOG_LEVEL_WARN
#define LOG_LEVEL_WARN 2
#endif /* LOG_LEVEL_WARN */
#ifndef BLE_MESH_LOG_LEVEL_WARN
#define BLE_MESH_LOG_LEVEL_WARN 2
#endif /* BLE_MESH_LOG_LEVEL_WARN */
#ifndef LOG_LEVEL_INFO
#define LOG_LEVEL_INFO 3
#endif /* LOG_LEVEL_INFO */
#ifndef BLE_MESH_LOG_LEVEL_INFO
#define BLE_MESH_LOG_LEVEL_INFO 3
#endif /* BLE_MESH_LOG_LEVEL_INFO */
#ifndef LOG_LEVEL_DEBUG
#define LOG_LEVEL_DEBUG 4
#endif /* LOG_LEVEL_DEBUG */
#ifndef BLE_MESH_LOG_LEVEL_DEBUG
#define BLE_MESH_LOG_LEVEL_DEBUG 4
#endif /* BLE_MESH_LOG_LEVEL_DEBUG */
#ifndef LOG_LEVEL_VERBOSE
#define LOG_LEVEL_VERBOSE 5
#endif /*LOG_LEVEL_VERBOSE */
#ifndef BLE_MESH_LOG_LEVEL_VERBOSE
#define BLE_MESH_LOG_LEVEL_VERBOSE 5
#endif /*BLE_MESH_LOG_LEVEL_VERBOSE */
#ifdef CONFIG_BLE_MESH_STACK_TRACE_LEVEL
#define MESH_LOG_LEVEL CONFIG_BLE_MESH_STACK_TRACE_LEVEL
#define BLE_MESH_LOG_LEVEL CONFIG_BLE_MESH_STACK_TRACE_LEVEL
#else
#define MESH_LOG_LEVEL LOG_LEVEL_WARN
#define BLE_MESH_LOG_LEVEL BLE_MESH_LOG_LEVEL_WARN
#endif
#ifdef CONFIG_BLE_MESH_NET_BUF_TRACE_LEVEL
#define NET_BUF_LOG_LEVEL CONFIG_BLE_MESH_NET_BUF_TRACE_LEVEL
#define BLE_MESH_NET_BUF_LOG_LEVEL CONFIG_BLE_MESH_NET_BUF_TRACE_LEVEL
#else
#define NET_BUF_LOG_LEVEL LOG_LEVEL_WARN
#define BLE_MESH_NET_BUF_LOG_LEVEL BLE_MESH_LOG_LEVEL_WARN
#endif
#define MESH_TRACE_TAG "BLE_MESH"
#define BLE_MESH_TRACE_TAG "BLE_MESH"
#if (LOG_LOCAL_LEVEL >= 4)
#define BLE_MESH_LOG_LOCAL_LEVEL_MAPPING (LOG_LOCAL_LEVEL + 1)
@ -57,13 +57,13 @@ extern "C" {
#define BLE_MESH_LOG_LOCAL_LEVEL_MAPPING LOG_LOCAL_LEVEL
#endif
#define BLE_MESH_LOG_LEVEL_CHECK(LAYER, LEVEL) (MAX(LAYER##_LOG_LEVEL, BLE_MESH_LOG_LOCAL_LEVEL_MAPPING) >= LOG_LEVEL_##LEVEL)
#define BLE_MESH_LOG_LEVEL_CHECK(LAYER, LEVEL) (MAX(LAYER##_LOG_LEVEL, BLE_MESH_LOG_LOCAL_LEVEL_MAPPING) >= BLE_MESH_LOG_LEVEL_##LEVEL)
#define BLE_MESH_PRINT_E(tag, format, ...) {esp_log_write(ESP_LOG_ERROR, tag, LOG_FORMAT(E, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
#define BLE_MESH_PRINT_W(tag, format, ...) {esp_log_write(ESP_LOG_WARN, tag, LOG_FORMAT(W, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
#define BLE_MESH_PRINT_I(tag, format, ...) {esp_log_write(ESP_LOG_INFO, tag, LOG_FORMAT(I, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
#define BLE_MESH_PRINT_D(tag, format, ...) {esp_log_write(ESP_LOG_DEBUG, tag, LOG_FORMAT(D, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
#define BLE_MESH_PRINT_V(tag, format, ...) {esp_log_write(ESP_LOG_VERBOSE, tag, LOG_FORMAT(V, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
#define BLE_MESH_PRINT_E(tag, format, ...) {esp_log_write(ESP_LOG_ERROR, tag, LOG_FORMAT(E, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
#define BLE_MESH_PRINT_W(tag, format, ...) {esp_log_write(ESP_LOG_WARN, tag, LOG_FORMAT(W, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
#define BLE_MESH_PRINT_I(tag, format, ...) {esp_log_write(ESP_LOG_INFO, tag, LOG_FORMAT(I, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
#define BLE_MESH_PRINT_D(tag, format, ...) {esp_log_write(ESP_LOG_DEBUG, tag, LOG_FORMAT(D, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
#define BLE_MESH_PRINT_V(tag, format, ...) {esp_log_write(ESP_LOG_VERBOSE, tag, LOG_FORMAT(V, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
#define printk ets_printf
@ -85,14 +85,14 @@ extern "C" {
#endif
#ifndef __ASSERT_NO_MSG
#define __ASSERT_NO_MSG(x) do { if (!(x)) BLE_MESH_PRINT_E(MESH_TRACE_TAG, "error %s %u", __FILE__, __LINE__); } while (0)
#define __ASSERT_NO_MSG(x) do { if (!(x)) BLE_MESH_PRINT_E(BLE_MESH_TRACE_TAG, "error %s %u", __FILE__, __LINE__); } while (0)
#endif
#if !CONFIG_BLE_MESH_NO_LOG
#define BT_ERR(fmt, args...) do {if ((MESH_LOG_LEVEL >= LOG_LEVEL_ERROR) && BLE_MESH_LOG_LEVEL_CHECK(MESH, ERROR)) BLE_MESH_PRINT_E(MESH_TRACE_TAG, fmt, ## args);} while(0)
#define BT_WARN(fmt, args...) do {if ((MESH_LOG_LEVEL >= LOG_LEVEL_WARN) && BLE_MESH_LOG_LEVEL_CHECK(MESH, WARN)) BLE_MESH_PRINT_W(MESH_TRACE_TAG, fmt, ## args);} while(0)
#define BT_INFO(fmt, args...) do {if ((MESH_LOG_LEVEL >= LOG_LEVEL_INFO) && BLE_MESH_LOG_LEVEL_CHECK(MESH, INFO)) BLE_MESH_PRINT_I(MESH_TRACE_TAG, fmt, ## args);} while(0)
#define BT_DBG(fmt, args...) do {if ((MESH_LOG_LEVEL >= LOG_LEVEL_DEBUG) && BLE_MESH_LOG_LEVEL_CHECK(MESH, DEBUG)) BLE_MESH_PRINT_D(MESH_TRACE_TAG, fmt, ## args);} while(0)
#define BT_ERR(fmt, args...) do {if ((BLE_MESH_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_ERROR) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH, ERROR)) BLE_MESH_PRINT_E(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0)
#define BT_WARN(fmt, args...) do {if ((BLE_MESH_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_WARN) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH, WARN)) BLE_MESH_PRINT_W(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0)
#define BT_INFO(fmt, args...) do {if ((BLE_MESH_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_INFO) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH, INFO)) BLE_MESH_PRINT_I(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0)
#define BT_DBG(fmt, args...) do {if ((BLE_MESH_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_DEBUG) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH, DEBUG)) BLE_MESH_PRINT_D(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0)
#else
#define BT_ERR(fmt, args...)
#define BT_WARN(fmt, args...)
@ -101,10 +101,10 @@ extern "C" {
#endif
#if defined(CONFIG_BLE_MESH_NET_BUF_LOG) && (!CONFIG_BLE_MESH_NO_LOG)
#define NET_BUF_ERR(fmt, args...) do {if ((NET_BUF_LOG_LEVEL >= LOG_LEVEL_ERROR) && BLE_MESH_LOG_LEVEL_CHECK(NET_BUF, ERROR)) BLE_MESH_PRINT_E(MESH_TRACE_TAG, fmt, ## args);} while(0)
#define NET_BUF_WARN(fmt, args...) do {if ((NET_BUF_LOG_LEVEL >= LOG_LEVEL_WARN) && BLE_MESH_LOG_LEVEL_CHECK(NET_BUF, WARN)) BLE_MESH_PRINT_W(MESH_TRACE_TAG, fmt, ## args);} while(0)
#define NET_BUF_INFO(fmt, args...) do {if ((NET_BUF_LOG_LEVEL >= LOG_LEVEL_INFO) && BLE_MESH_LOG_LEVEL_CHECK(NET_BUF, INFO)) BLE_MESH_PRINT_I(MESH_TRACE_TAG, fmt, ## args);} while(0)
#define NET_BUF_DBG(fmt, args...) do {if ((NET_BUF_LOG_LEVEL >= LOG_LEVEL_DEBUG) && BLE_MESH_LOG_LEVEL_CHECK(NET_BUF, DEBUG)) BLE_MESH_PRINT_D(MESH_TRACE_TAG, fmt, ## args);} while(0)
#define NET_BUF_ERR(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_ERROR) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, ERROR)) BLE_MESH_PRINT_E(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0)
#define NET_BUF_WARN(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_WARN) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, WARN)) BLE_MESH_PRINT_W(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0)
#define NET_BUF_INFO(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_INFO) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, INFO)) BLE_MESH_PRINT_I(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0)
#define NET_BUF_DBG(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_DEBUG) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, DEBUG)) BLE_MESH_PRINT_D(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0)
#define NET_BUF_ASSERT(cond) __ASSERT_NO_MSG(cond)
#else
#define NET_BUF_ERR(fmt, args...)
@ -115,10 +115,10 @@ extern "C" {
#endif
#if defined(CONFIG_BLE_MESH_NET_BUF_SIMPLE_LOG) && (!CONFIG_BLE_MESH_NO_LOG)
#define NET_BUF_SIMPLE_ERR(fmt, args...) do {if ((NET_BUF_LOG_LEVEL >= LOG_LEVEL_ERROR) && BLE_MESH_LOG_LEVEL_CHECK(NET_BUF, ERROR)) BLE_MESH_PRINT_E(MESH_TRACE_TAG, fmt, ## args);} while(0)
#define NET_BUF_SIMPLE_WARN(fmt, args...) do {if ((NET_BUF_LOG_LEVEL >= LOG_LEVEL_WARN) && BLE_MESH_LOG_LEVEL_CHECK(NET_BUF, WARN)) BLE_MESH_PRINT_W(MESH_TRACE_TAG, fmt, ## args);} while(0)
#define NET_BUF_SIMPLE_INFO(fmt, args...) do {if ((NET_BUF_LOG_LEVEL >= LOG_LEVEL_INFO) && BLE_MESH_LOG_LEVEL_CHECK(NET_BUF, INFO)) BLE_MESH_PRINT_I(MESH_TRACE_TAG, fmt, ## args);} while(0)
#define NET_BUF_SIMPLE_DBG(fmt, args...) do {if ((NET_BUF_LOG_LEVEL >= LOG_LEVEL_DEBUG) && BLE_MESH_LOG_LEVEL_CHECK(NET_BUF, DEBUG)) BLE_MESH_PRINT_D(MESH_TRACE_TAG, fmt, ## args);} while(0)
#define NET_BUF_SIMPLE_ERR(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_ERROR) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, ERROR)) BLE_MESH_PRINT_E(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0)
#define NET_BUF_SIMPLE_WARN(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_WARN) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, WARN)) BLE_MESH_PRINT_W(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0)
#define NET_BUF_SIMPLE_INFO(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_INFO) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, INFO)) BLE_MESH_PRINT_I(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0)
#define NET_BUF_SIMPLE_DBG(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_DEBUG) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, DEBUG)) BLE_MESH_PRINT_D(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0)
#define NET_BUF_SIMPLE_ASSERT(cond) __ASSERT_NO_MSG(cond)
#else
#define NET_BUF_SIMPLE_ERR(fmt, args...)

View File

@ -16,30 +16,8 @@
extern "C" {
#endif
typedef signed char s8_t;
typedef signed short s16_t;
typedef signed int s32_t;
typedef signed long long s64_t;
typedef unsigned char u8_t;
typedef unsigned short u16_t;
typedef unsigned int u32_t;
typedef unsigned long long u64_t;
typedef int bt_mesh_atomic_t;
#ifndef bool
#define bool int8_t
#endif
#ifndef false
#define false 0
#endif
#ifndef true
#define true 1
#endif
#ifndef PRIu64
#define PRIu64 "llu"
#endif

View File

@ -15,6 +15,7 @@
#define _BLE_MESH_UTIL_H_
#include <stddef.h>
#include "esp_bit_defs.h"
#include "mesh_types.h"
#ifdef __cplusplus
@ -25,13 +26,13 @@ extern "C" {
* Those are available for 32 bits architectures:
*/
#ifndef POINTER_TO_UINT
#define POINTER_TO_UINT(x) ((u32_t) (x))
#define POINTER_TO_UINT(x) ((uint32_t) (x))
#endif
#ifndef UINT_TO_POINTER
#define UINT_TO_POINTER(x) ((void *) (x))
#endif
#ifndef POINTER_TO_INT
#define POINTER_TO_INT(x) ((s32_t) (x))
#define POINTER_TO_INT(x) ((int32_t) (x))
#endif
#ifndef INT_TO_POINTER
#define INT_TO_POINTER(x) ((void *) (x))
@ -56,9 +57,7 @@ extern "C" {
* an array (e.g. pointer)
*/
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(array) \
((unsigned long) (IS_ARRAY(array) + \
(sizeof(array) / sizeof((array)[0]))))
#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
#endif
/* Evaluates to 1 if ptr is part of array, 0 otherwise; compile error if
@ -183,16 +182,7 @@ extern "C" {
const char *bt_hex(const void *buf, size_t len);
void mem_rcopy(u8_t *dst, u8_t const *src, u16_t len);
unsigned int _copy(uint8_t *to, unsigned int to_len,
const uint8_t *from, unsigned int from_len);
void _set(void *to, uint8_t val, unsigned int len);
uint8_t _double_byte(uint8_t a);
int _compare(const uint8_t *a, const uint8_t *b, size_t size);
void mem_rcopy(uint8_t *dst, uint8_t const *src, uint16_t len);
#ifdef __cplusplus
}

View File

@ -16,7 +16,7 @@ int net_buf_id(struct net_buf *buf)
}
static inline struct net_buf *pool_get_uninit(struct net_buf_pool *pool,
u16_t uninit_count)
uint16_t uninit_count)
{
struct net_buf *buf = NULL;
@ -35,7 +35,7 @@ void net_buf_simple_clone(const struct net_buf_simple *original,
void *net_buf_simple_add(struct net_buf_simple *buf, size_t len)
{
u8_t *tail = net_buf_simple_tail(buf);
uint8_t *tail = net_buf_simple_tail(buf);
NET_BUF_SIMPLE_DBG("buf %p len %u", buf, len);
@ -53,9 +53,9 @@ void *net_buf_simple_add_mem(struct net_buf_simple *buf, const void *mem,
return memcpy(net_buf_simple_add(buf, len), mem, len);
}
u8_t *net_buf_simple_add_u8(struct net_buf_simple *buf, u8_t val)
uint8_t *net_buf_simple_add_u8(struct net_buf_simple *buf, uint8_t val)
{
u8_t *u8 = NULL;
uint8_t *u8 = NULL;
NET_BUF_SIMPLE_DBG("buf %p val 0x%02x", buf, val);
@ -65,70 +65,70 @@ u8_t *net_buf_simple_add_u8(struct net_buf_simple *buf, u8_t val)
return u8;
}
void net_buf_simple_add_le16(struct net_buf_simple *buf, u16_t val)
void net_buf_simple_add_le16(struct net_buf_simple *buf, uint16_t val)
{
NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val);
sys_put_le16(val, net_buf_simple_add(buf, sizeof(val)));
}
void net_buf_simple_add_be16(struct net_buf_simple *buf, u16_t val)
void net_buf_simple_add_be16(struct net_buf_simple *buf, uint16_t val)
{
NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val);
sys_put_be16(val, net_buf_simple_add(buf, sizeof(val)));
}
void net_buf_simple_add_le24(struct net_buf_simple *buf, u32_t val)
void net_buf_simple_add_le24(struct net_buf_simple *buf, uint32_t val)
{
NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val);
sys_put_le24(val, net_buf_simple_add(buf, 3));
}
void net_buf_simple_add_be24(struct net_buf_simple *buf, u32_t val)
void net_buf_simple_add_be24(struct net_buf_simple *buf, uint32_t val)
{
NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val);
sys_put_be24(val, net_buf_simple_add(buf, 3));
}
void net_buf_simple_add_le32(struct net_buf_simple *buf, u32_t val)
void net_buf_simple_add_le32(struct net_buf_simple *buf, uint32_t val)
{
NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val);
sys_put_le32(val, net_buf_simple_add(buf, sizeof(val)));
}
void net_buf_simple_add_be32(struct net_buf_simple *buf, u32_t val)
void net_buf_simple_add_be32(struct net_buf_simple *buf, uint32_t val)
{
NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val);
sys_put_be32(val, net_buf_simple_add(buf, sizeof(val)));
}
void net_buf_simple_add_le48(struct net_buf_simple *buf, u64_t val)
void net_buf_simple_add_le48(struct net_buf_simple *buf, uint64_t val)
{
NET_BUF_SIMPLE_DBG("buf %p val %" PRIu64, buf, val);
sys_put_le48(val, net_buf_simple_add(buf, 6));
}
void net_buf_simple_add_be48(struct net_buf_simple *buf, u64_t val)
void net_buf_simple_add_be48(struct net_buf_simple *buf, uint64_t val)
{
NET_BUF_SIMPLE_DBG("buf %p val %" PRIu64, buf, val);
sys_put_be48(val, net_buf_simple_add(buf, 6));
}
void net_buf_simple_add_le64(struct net_buf_simple *buf, u64_t val)
void net_buf_simple_add_le64(struct net_buf_simple *buf, uint64_t val)
{
NET_BUF_SIMPLE_DBG("buf %p val %" PRIu64, buf, val);
sys_put_le64(val, net_buf_simple_add(buf, sizeof(val)));
}
void net_buf_simple_add_be64(struct net_buf_simple *buf, u64_t val)
void net_buf_simple_add_be64(struct net_buf_simple *buf, uint64_t val)
{
NET_BUF_SIMPLE_DBG("buf %p val %" PRIu64, buf, val);
@ -146,77 +146,77 @@ void *net_buf_simple_push(struct net_buf_simple *buf, size_t len)
return buf->data;
}
void net_buf_simple_push_le16(struct net_buf_simple *buf, u16_t val)
void net_buf_simple_push_le16(struct net_buf_simple *buf, uint16_t val)
{
NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val);
sys_put_le16(val, net_buf_simple_push(buf, sizeof(val)));
}
void net_buf_simple_push_be16(struct net_buf_simple *buf, u16_t val)
void net_buf_simple_push_be16(struct net_buf_simple *buf, uint16_t val)
{
NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val);
sys_put_be16(val, net_buf_simple_push(buf, sizeof(val)));
}
void net_buf_simple_push_u8(struct net_buf_simple *buf, u8_t val)
void net_buf_simple_push_u8(struct net_buf_simple *buf, uint8_t val)
{
u8_t *data = net_buf_simple_push(buf, 1);
uint8_t *data = net_buf_simple_push(buf, 1);
*data = val;
}
void net_buf_simple_push_le24(struct net_buf_simple *buf, u32_t val)
void net_buf_simple_push_le24(struct net_buf_simple *buf, uint32_t val)
{
NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val);
sys_put_le24(val, net_buf_simple_push(buf, 3));
}
void net_buf_simple_push_be24(struct net_buf_simple *buf, u32_t val)
void net_buf_simple_push_be24(struct net_buf_simple *buf, uint32_t val)
{
NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val);
sys_put_be24(val, net_buf_simple_push(buf, 3));
}
void net_buf_simple_push_le32(struct net_buf_simple *buf, u32_t val)
void net_buf_simple_push_le32(struct net_buf_simple *buf, uint32_t val)
{
NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val);
sys_put_le32(val, net_buf_simple_push(buf, sizeof(val)));
}
void net_buf_simple_push_be32(struct net_buf_simple *buf, u32_t val)
void net_buf_simple_push_be32(struct net_buf_simple *buf, uint32_t val)
{
NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val);
sys_put_be32(val, net_buf_simple_push(buf, sizeof(val)));
}
void net_buf_simple_push_le48(struct net_buf_simple *buf, u64_t val)
void net_buf_simple_push_le48(struct net_buf_simple *buf, uint64_t val)
{
NET_BUF_SIMPLE_DBG("buf %p val %" PRIu64, buf, val);
sys_put_le48(val, net_buf_simple_push(buf, 6));
}
void net_buf_simple_push_be48(struct net_buf_simple *buf, u64_t val)
void net_buf_simple_push_be48(struct net_buf_simple *buf, uint64_t val)
{
NET_BUF_SIMPLE_DBG("buf %p val %" PRIu64, buf, val);
sys_put_be48(val, net_buf_simple_push(buf, 6));
}
void net_buf_simple_push_le64(struct net_buf_simple *buf, u64_t val)
void net_buf_simple_push_le64(struct net_buf_simple *buf, uint64_t val)
{
NET_BUF_SIMPLE_DBG("buf %p val %" PRIu64, buf, val);
sys_put_le64(val, net_buf_simple_push(buf, sizeof(val)));
}
void net_buf_simple_push_be64(struct net_buf_simple *buf, u64_t val)
void net_buf_simple_push_be64(struct net_buf_simple *buf, uint64_t val)
{
NET_BUF_SIMPLE_DBG("buf %p val %" PRIu64, buf, val);
@ -247,9 +247,9 @@ void *net_buf_simple_pull_mem(struct net_buf_simple *buf, size_t len)
return data;
}
u8_t net_buf_simple_pull_u8(struct net_buf_simple *buf)
uint8_t net_buf_simple_pull_u8(struct net_buf_simple *buf)
{
u8_t val = 0U;
uint8_t val = 0U;
val = buf->data[0];
net_buf_simple_pull(buf, 1);
@ -257,30 +257,30 @@ u8_t net_buf_simple_pull_u8(struct net_buf_simple *buf)
return val;
}
u16_t net_buf_simple_pull_le16(struct net_buf_simple *buf)
uint16_t net_buf_simple_pull_le16(struct net_buf_simple *buf)
{
u16_t val = 0U;
uint16_t val = 0U;
val = UNALIGNED_GET((u16_t *)buf->data);
val = UNALIGNED_GET((uint16_t *)buf->data);
net_buf_simple_pull(buf, sizeof(val));
return sys_le16_to_cpu(val);
}
u16_t net_buf_simple_pull_be16(struct net_buf_simple *buf)
uint16_t net_buf_simple_pull_be16(struct net_buf_simple *buf)
{
u16_t val = 0U;
uint16_t val = 0U;
val = UNALIGNED_GET((u16_t *)buf->data);
val = UNALIGNED_GET((uint16_t *)buf->data);
net_buf_simple_pull(buf, sizeof(val));
return sys_be16_to_cpu(val);
}
u32_t net_buf_simple_pull_le24(struct net_buf_simple *buf)
uint32_t net_buf_simple_pull_le24(struct net_buf_simple *buf)
{
struct uint24 {
u32_t u24:24;
uint32_t u24:24;
} __packed val;
val = UNALIGNED_GET((struct uint24 *)buf->data);
@ -289,10 +289,10 @@ u32_t net_buf_simple_pull_le24(struct net_buf_simple *buf)
return sys_le24_to_cpu(val.u24);
}
u32_t net_buf_simple_pull_be24(struct net_buf_simple *buf)
uint32_t net_buf_simple_pull_be24(struct net_buf_simple *buf)
{
struct uint24 {
u32_t u24:24;
uint32_t u24:24;
} __packed val;
val = UNALIGNED_GET((struct uint24 *)buf->data);
@ -301,30 +301,30 @@ u32_t net_buf_simple_pull_be24(struct net_buf_simple *buf)
return sys_be24_to_cpu(val.u24);
}
u32_t net_buf_simple_pull_le32(struct net_buf_simple *buf)
uint32_t net_buf_simple_pull_le32(struct net_buf_simple *buf)
{
u32_t val = 0U;
uint32_t val = 0U;
val = UNALIGNED_GET((u32_t *)buf->data);
val = UNALIGNED_GET((uint32_t *)buf->data);
net_buf_simple_pull(buf, sizeof(val));
return sys_le32_to_cpu(val);
}
u32_t net_buf_simple_pull_be32(struct net_buf_simple *buf)
uint32_t net_buf_simple_pull_be32(struct net_buf_simple *buf)
{
u32_t val = 0U;
uint32_t val = 0U;
val = UNALIGNED_GET((u32_t *)buf->data);
val = UNALIGNED_GET((uint32_t *)buf->data);
net_buf_simple_pull(buf, sizeof(val));
return sys_be32_to_cpu(val);
}
u64_t net_buf_simple_pull_le48(struct net_buf_simple *buf)
uint64_t net_buf_simple_pull_le48(struct net_buf_simple *buf)
{
struct uint48 {
u64_t u48:48;
uint64_t u48:48;
} __packed val;
val = UNALIGNED_GET((struct uint48 *)buf->data);
@ -333,10 +333,10 @@ u64_t net_buf_simple_pull_le48(struct net_buf_simple *buf)
return sys_le48_to_cpu(val.u48);
}
u64_t net_buf_simple_pull_be48(struct net_buf_simple *buf)
uint64_t net_buf_simple_pull_be48(struct net_buf_simple *buf)
{
struct uint48 {
u64_t u48:48;
uint64_t u48:48;
} __packed val;
val = UNALIGNED_GET((struct uint48 *)buf->data);
@ -345,21 +345,21 @@ u64_t net_buf_simple_pull_be48(struct net_buf_simple *buf)
return sys_be48_to_cpu(val.u48);
}
u64_t net_buf_simple_pull_le64(struct net_buf_simple *buf)
uint64_t net_buf_simple_pull_le64(struct net_buf_simple *buf)
{
u64_t val;
uint64_t val;
val = UNALIGNED_GET((u64_t *)buf->data);
val = UNALIGNED_GET((uint64_t *)buf->data);
net_buf_simple_pull(buf, sizeof(val));
return sys_le64_to_cpu(val);
}
u64_t net_buf_simple_pull_be64(struct net_buf_simple *buf)
uint64_t net_buf_simple_pull_be64(struct net_buf_simple *buf)
{
u64_t val;
uint64_t val;
val = UNALIGNED_GET((u64_t *)buf->data);
val = UNALIGNED_GET((uint64_t *)buf->data);
net_buf_simple_pull(buf, sizeof(val));
return sys_be64_to_cpu(val);
@ -383,6 +383,15 @@ void net_buf_reset(struct net_buf *buf)
net_buf_simple_reset(&buf->b);
}
void net_buf_simple_init_with_data(struct net_buf_simple *buf,
void *data, size_t size)
{
buf->__buf = data;
buf->data = data;
buf->size = size;
buf->len = size;
}
void net_buf_simple_reserve(struct net_buf_simple *buf, size_t reserve)
{
NET_BUF_ASSERT(buf);
@ -484,7 +493,7 @@ void net_buf_unref(struct net_buf *buf)
pool->uninit_count++;
#if defined(CONFIG_BLE_MESH_NET_BUF_POOL_USAGE)
pool->avail_count++;
NET_BUF_DBG("%s, pool %p, avail_count %d, uninit_count %d", __func__,
NET_BUF_DBG("Unref, pool %p, avail_count %d, uninit_count %d",
pool, pool->avail_count, pool->uninit_count);
NET_BUF_ASSERT(pool->avail_count <= pool->buf_count);
#endif
@ -497,7 +506,7 @@ void net_buf_unref(struct net_buf *buf)
}
}
static u8_t *fixed_data_alloc(struct net_buf *buf, size_t *size, s32_t timeout)
static uint8_t *fixed_data_alloc(struct net_buf *buf, size_t *size, int32_t timeout)
{
struct net_buf_pool *pool = buf->pool;
const struct net_buf_pool_fixed *fixed = pool->alloc->alloc_data;
@ -507,7 +516,7 @@ static u8_t *fixed_data_alloc(struct net_buf *buf, size_t *size, s32_t timeout)
return fixed->data_pool + fixed->data_size * net_buf_id(buf);
}
static void fixed_data_unref(struct net_buf *buf, u8_t *data)
static void fixed_data_unref(struct net_buf *buf, uint8_t *data)
{
/* Nothing needed for fixed-size data pools */
}
@ -517,7 +526,7 @@ const struct net_buf_data_cb net_buf_fixed_cb = {
.unref = fixed_data_unref,
};
static u8_t *data_alloc(struct net_buf *buf, size_t *size, s32_t timeout)
static uint8_t *data_alloc(struct net_buf *buf, size_t *size, int32_t timeout)
{
struct net_buf_pool *pool = buf->pool;
@ -526,10 +535,10 @@ static u8_t *data_alloc(struct net_buf *buf, size_t *size, s32_t timeout)
#if defined(CONFIG_BLE_MESH_NET_BUF_LOG)
struct net_buf *net_buf_alloc_len_debug(struct net_buf_pool *pool, size_t size,
s32_t timeout, const char *func, int line)
int32_t timeout, const char *func, int line)
#else
struct net_buf *net_buf_alloc_len(struct net_buf_pool *pool, size_t size,
s32_t timeout)
int32_t timeout)
#endif
{
struct net_buf *buf = NULL;
@ -537,7 +546,7 @@ struct net_buf *net_buf_alloc_len(struct net_buf_pool *pool, size_t size,
NET_BUF_ASSERT(pool);
NET_BUF_DBG("%s, pool %p, uninit_count %d, buf_count %d", __func__,
NET_BUF_DBG("Alloc, pool %p, uninit_count %d, buf_count %d",
pool, pool->uninit_count, pool->buf_count);
/* We need to lock interrupts temporarily to prevent race conditions
@ -561,7 +570,7 @@ struct net_buf *net_buf_alloc_len(struct net_buf_pool *pool, size_t size,
bt_mesh_buf_unlock();
NET_BUF_ERR("%s, Failed to get free buffer", __func__);
NET_BUF_ERR("Out of free buffer, pool %p", pool);
return NULL;
success:
@ -570,11 +579,11 @@ success:
if (size) {
buf->__buf = data_alloc(buf, &size, timeout);
if (!buf->__buf) {
NET_BUF_ERR("%s, Failed to allocate data", __func__);
NET_BUF_ERR("Out of data, buf %p", buf);
return NULL;
}
} else {
NET_BUF_WARN("%s, Zero data size", __func__);
NET_BUF_WARN("Zero data size, buf %p", buf);
buf->__buf = NULL;
}
@ -595,15 +604,15 @@ success:
#if defined(CONFIG_BLE_MESH_NET_BUF_LOG)
struct net_buf *net_buf_alloc_fixed_debug(struct net_buf_pool *pool,
s32_t timeout, const char *func,
int line)
int32_t timeout, const char *func,
int line)
{
const struct net_buf_pool_fixed *fixed = pool->alloc->alloc_data;
return net_buf_alloc_len_debug(pool, fixed->data_size, timeout, func, line);
}
#else
struct net_buf *net_buf_alloc_fixed(struct net_buf_pool *pool, s32_t timeout)
struct net_buf *net_buf_alloc_fixed(struct net_buf_pool *pool, int32_t timeout)
{
const struct net_buf_pool_fixed *fixed = pool->alloc->alloc_data;
@ -699,7 +708,7 @@ size_t net_buf_linearize(void *dst, size_t dst_len, struct net_buf *src,
copied = 0;
while (frag && len > 0) {
to_copy = MIN(len, frag->len - offset);
memcpy((u8_t *)dst + copied, frag->data + offset, to_copy);
memcpy((uint8_t *)dst + copied, frag->data + offset, to_copy);
copied += to_copy;
@ -719,15 +728,15 @@ size_t net_buf_linearize(void *dst, size_t dst_len, struct net_buf *src,
* the buffer. It assumes that the buffer has at least one fragment.
*/
size_t net_buf_append_bytes(struct net_buf *buf, size_t len,
const void *value, s32_t timeout,
net_buf_allocator_cb allocate_cb, void *user_data)
const void *value, int32_t timeout,
net_buf_allocator_cb allocate_cb, void *user_data)
{
struct net_buf *frag = net_buf_frag_last(buf);
size_t added_len = 0U;
const u8_t *value8 = value;
const uint8_t *value8 = value;
do {
u16_t count = MIN(len, net_buf_tailroom(frag));
uint16_t count = MIN(len, net_buf_tailroom(frag));
net_buf_add_mem(frag, value8, count);
len -= count;

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