Compare commits

...

1504 Commits

Author SHA1 Message Date
b24a5e78f2 Merge branch 'bugfix/spi_flash_cs_setup_xiaomi_v4.0' into customer/maintain_v4.0_xiaomi_tsf_issue
See merge request espressif/esp-idf!13893
2021-06-15 12:35:03 +08:00
a212d866f4 spi_flash: fix cs line setup to make the flash driver more stable 2021-06-08 00:59:41 +08:00
b7c8288056 Merge branch 'bugfix/xmc_overerase_xiaomi_v4.0' into customer/maintain_v4.0_xiaomi_tsf_issue
See merge request espressif/esp-idf!13892
2021-06-08 00:21:56 +08:00
e3f975b5a8 spi_flash: fix xm25qh32c flash overerase 2021-06-07 23:19:03 +08:00
937ce5dfd5 Merge branch 'feature/support_eon_flash_qaud_mode_esp_flash_xiaomi' into 'customer/maintain_v4.0_xiaomi_tsf_issue'
esp_flash: support override default chip driver list (backport xm)

See merge request espressif/esp-idf!12568
2021-03-03 20:02:43 +08:00
f2a86c4205 esp_flash: support override default chip driver list 2021-03-03 12:37:21 +08:00
1d0e1409c7 Merge branch 'bugfix/support_eon_flash_qaud_mode_for_xiaomi' into 'customer/maintain_v4.0_xiaomi_tsf_issue'
flash: support EON flash qaud mode

See merge request espressif/esp-idf!12523
2021-02-26 16:35:06 +08:00
acd3c945d2 flash: support EON flash qaud mode 2021-02-26 11:36:23 +08:00
8c9f5876be components/bt: fixed tx_prog insert error. 2021-01-27 20:41:51 +08:00
60b0e9749f don't disconnect AP when timestamp decrease abnormally 2020-12-29 12:22:32 +08:00
1c7607d4a6 Merge branch 'bugfix/assert_no_IRAM_ATTR_v4.0' into 'release/v4.0'
btdm fix cache disable crash, insert the llcp packet to the top of the tx_prog

See merge request espressif/esp-idf!10779
2020-10-13 12:30:59 +08:00
42e380270c Merge branch 'bugfix/pmf_softap_coex_issue_v4.0' into 'release/v4.0'
Fix issues related to PMF and WPA2-Enterprise (Backport v4.0)

See merge request espressif/esp-idf!10698
2020-10-13 12:26:21 +08:00
e9dfea8421 components/bt:btdm fix cache disable crash, insert the llcp packet to the top of the tx_prog 2020-10-11 15:20:40 +08:00
0016d20946 esp_wifi: Update wifi lib
1. Add STA checks during STA PMF operations
2. Fix WPA2-Ent issue with Open AP
3. Skip WPA-TKIP profile if PMF is required
4. Skip & clear Supplicant PMK Cache for mismatching AP config
2020-10-10 10:10:11 +00:00
d4499598e4 Merge branch 'bugfix/fix_ble_hci_desync_deadlock_v4.0' into 'release/v4.0'
components/bt: Backport of the BLE controller fix for hci desync deadlock v4.0

See merge request espressif/esp-idf!10129
2020-10-10 17:50:46 +08:00
7af4c6f840 components/bt: Fix for HCI desync deadlock issue in BLE controller 2020-10-10 16:35:18 +08:00
c783abc2e3 Merge branch 'bugfix/assert_rx_link_v4.0_fix_mr_v4.0' into 'release/v4.0'
fix assert(10,9), when missing evt_end or rx and evt_end come the same time v4.0.

See merge request espressif/esp-idf!10422
2020-10-09 19:54:06 +08:00
3e44ebd3d7 Merge branch 'bugfix/ci_auto_checkout_revision_of_project_used_in_ci_v4.0' into 'release/v4.0'
CI: get git describe from annotated tags (v4.0)

See merge request espressif/esp-idf!10675
2020-10-08 16:44:52 +08:00
893d74f6ef ci: Check version tags are always annotated
Closes https://github.com/espressif/esp-idf/issues/3114
2020-10-07 13:55:53 +11:00
3350a108c3 build system: Also get IDF version from annotated tags only
Builds on previous commit.

Note: Getting the project version still pases --tags so still works with plain
tags, to keep compatibility for existing projects
2020-10-07 13:55:53 +11:00
ac545ce97c CI: get git describe from annotated tags:
we should only parse IDF version from annotated tags
2020-09-30 11:33:52 +08:00
445822104a Merge branch 'bugfix/fix_receiving_packets_from_myself_v4.0' into 'release/v4.0'
esp_wifi: drop receiving packets from myself (backport v4.0)

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

See merge request espressif/esp-idf!10561
2020-09-24 22:35:10 +08:00
e6816163fe Merge branch 'bugfix/wifi_spin_lock_allocation_in_PSRAM_v4.0' into 'release/v4.0'
wifi: Fix spin lock allocation in PSRAM bug(v4.0)

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

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

See merge request espressif/esp-idf!10489
2020-09-23 13:51:15 +08:00
0fe7ac0bd7 ipv6 send multicast data fail when src address is null for 4.0 2020-09-22 17:18:49 +08:00
9039ddb20c Fix spin lock allocation in PSRAM bug 2020-09-22 14:19:56 +08:00
c308562a31 Merge branch 'bugfix/btdm_spp_null_ptr_with_dynamic_memory_v4.0' into 'release/v4.0'
components/bt: Fix SPP using NULL point with dynamic memory

See merge request espressif/esp-idf!10324
2020-09-17 20:28:43 +08:00
293c2d95f6 esp_wifi: update phy v4390(backport v4.0) 2020-09-17 16:08:50 +08:00
374b756f6b coap: update libcoap to fix its broken submodule pointer
Though IDF v4.0 does not have dependency on `tinydtls` repository
within libcoap, it created problem in recursive clone. This commit
picks up change from upstream libcoap release-v4.2.0 to update
`tinydtls` repository pointer.

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

Merges https://github.com/espressif/esp-idf/pull/5626
2020-09-14 10:59:52 +05:30
e3ecb8d073 fix assert(10,9), when missing evt_end or rx and evt_end come the same time 2020-09-14 10:48:59 +08:00
9263b84f37 components/bt: Fix SPP using NULL point with dynamic memory 2020-09-07 15:46:09 +08:00
6093407d78 Merge branch 'feature/toolchain_2020r3_v4.0' into 'release/v4.0'
Update toolchain to esp-2020r3 (backport v4.0)

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

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

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

See merge request espressif/esp-idf!10013
2020-09-04 20:00:41 +08:00
2ba90c8453 component/bt: Fixed the watchdog timeout of btu task during multi-connection 2020-09-04 16:24:23 +08:00
7009d7bcfe Update toolchain to esp-2020r3
Fixup more for PSRAM issue;
    Allow GDB work correctly with Privileged Registers;
    Based on GCC 8.4.0;
    Update a fix of C++ exception crashs from the GCC mainline;
    Fixup strptime_l() and some locale in libc;

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

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

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

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

See merge request espressif/esp-idf!9598
2020-09-03 00:48:43 +08:00
ce1905d6b5 components/bt: Fixed the state not synchronized between controller and host when disconnected. 2020-09-02 21:33:06 +08:00
4d8ba4b4de espnow/pmf: Implement ESPNOW + PMF Co-existance
H/W decryption of Mgmt frames was disabled for PMF and done through
S/W. If ESPNOW packets go through this path, it affects backward
compatibility since method of decrypting Mgmt packets is different in H/W.

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

Co-Authored-By: Nachiket Kukade <nachiket.kukade@espressif.com>
Co-Authored-By: zhangyanjiao <zhangyanjiao@espressif.com>
Co-Authored-By: kapil.gupta <kapil.gupta@espressif.com>
2020-09-02 15:02:45 +05:30
54c2bd7c0c driver(I2S): Fix I2S reset issue for release/v4.0
`i2s_start` reseting I2S in incorrect order causeing the word-order error.
2020-09-02 16:30:03 +08:00
d1fa5c712a Merge branch 'bugfix/freemodbus_fix_long_frame_buffer_failure_backport4_0' into 'release/v4.0'
freemodbus: freemodbus fix long frame buffer failure (backport v4.0)

See merge request espressif/esp-idf!8199
2020-09-02 16:12:28 +08:00
c756f7c4d2 Merge branch 'bugfix/fix_ipv6_nd6_max_queue_num_4.0' into 'release/v4.0'
lw-ip: fix IPv6 ND6 queue too much pkts (Backport 4.0)

See merge request espressif/esp-idf!10090
2020-08-31 14:27:59 +08:00
5ec780d6b5 Merge branch 'bugfix/wifi_deinit_stop_crash_v4.0' into 'release/v4.0'
esp_wifi: fix the crash when wifi stop after deinit (v4.0)

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

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

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

See merge request espressif/esp-idf!10049
2020-08-26 11:38:07 +08:00
98d525c1ea wpa_supplicant: Deinit wpa2 states in wifi deinit 2020-08-20 15:09:55 +05:30
c4107150ee lwip: fix IPv6 ND6 queue too much pkts cause no mem issue and add menuconfig item for this params. 2020-08-19 14:38:32 +08:00
6dde2eb3c5 Fixed assert(9, 10), When rx and evt_end interrupts exist at the same time, use the information of rx to determine the execution order 2020-08-18 16:06:22 +08:00
d9660fcf9c vfs: support vfs uart set line endings with specified uart number (release/v4.0) 2020-08-14 15:39:39 +08:00
45c4fef890 add API esp_spp_stop_srv(), fix the error parameter in esp-idf/examples/bluetooth/bluedroid/classic_bt/bt_spp_initiator/main/example_spp_initiator_demo.c and fix collection of SPP
Closes https://github.com/espressif/esp-idf/issues/5409
Closes https://github.com/espressif/esp-idf/pull/5408

See merge request espressif/esp-idf!9114
2020-08-13 12:01:39 +08:00
93aea71641 esp_wifi: fix the crash when wifi stop after deinit 2020-08-13 10:56:57 +08:00
820621687c Merge branch 'bugfix/fix_udp_tx_performance_issue_v4.0' into 'release/v4.0'
lw-ip: fix udp tx packet loss issue (backport v4.0)

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

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

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

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

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

See merge request espressif/esp-idf!9937
2020-08-07 18:08:26 +08:00
b50bbe3a5b component/bt: Fixed ble memory leak issue, buff_semaphore was not released. 2020-08-07 15:15:49 +08:00
14140e7550 Merge branch 'feature/upgrade_mbedtls_to_v4.0' into 'release/v4.0'
mbedtls: update to mbedtls release v2.16.7 (v4.0)

See merge request espressif/esp-idf!9908
2020-08-06 12:29:00 +08:00
94f4a88c2d wifi, bt: move esp_phy_common_clock_disable into periph_ctrl and put it into IRAM
Replace periph_module_enable/disable by periph_wifi_bt_common_module_enable which are in IRAM.
AddIRAM_ATTR periph_ll_wifi_bt_module_enable_clk_clear_rstandIRAM_ATTR periph_ll_wifi_bt_module_disable_clk_set_rstto fit O0 optimization level.
Delete duplicated spinlock and counter.
2020-08-05 17:41:05 +08:00
7cc07173b2 Merge branch 'bugfix/btdm_blufi_send_longer_custom_data_will_congested_v4.0' into 'release/v4.0'
component/bt: fix Blufi sends longer customer data  will will lead congested(backport v4.0)

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

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

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

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

See merge request espressif/esp-idf!9883
2020-08-04 12:27:52 +08:00
cc0aa104e8 mbedtls: update to mbedtls release v2.16.7
For detailed release notes, please refer to:
https://github.com/ARMmbed/mbedtls/releases/tag/mbedtls-2.16.7
2020-08-03 15:50:34 +05:30
26d7fb7744 Merge branch 'ci/resume_esp_flash_tests_4.0' into 'release/v4.0'
ci: resume esp_flash unit tests (v4.0)

See merge request espressif/esp-idf!9793
2020-08-02 17:15:24 +08:00
4cbb70541c Merge branch 'feature/oocd_ver_backport_v4.0' into 'release/v4.0'
tools: Updates OpenOCD version to 'v0.10.0-esp32-20200709' (backport v4.0)

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

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

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

See merge request espressif/esp-idf!9736
2020-07-31 17:27:21 +08:00
a7fe03dcb0 tools: Updates OpenOCD version to 'v0.10.0-esp32-20200709' 2020-07-31 07:16:19 +00:00
c2d261c88e ci: use the retry script to download 2020-07-31 13:07:07 +07:00
8ed6242e27 ci: add a helper for retrying shell command 2020-07-31 13:04:59 +07:00
f32582b588 Merge branch 'bugfix/fix_hci_max_page_num_v4.0' into 'release/v4.0'
bugfix/Support for more Bluetooth HID devices [backport v4.0]

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

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

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

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

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

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

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

See merge request espressif/esp-idf!9616
2020-07-29 15:30:13 +08:00
4e7d7426aa bugfix: fix softap mode wpa memory leak 2020-07-29 14:17:12 +08:00
818a2f8768 ci: resume esp_flash unit tests 2020-07-29 10:00:23 +08:00
7dfb6adf27 sdmmc: fix the probe issue that forbid sdspi working in highspeed mode
SD cards don't support CMD7 (select_card) in SPI mode. Highspeed probe
of sdspi will fail in this step and stop working in highspeed mode.
Remove the CMD7 in enable_hs_mode_and_check to fix this issue.

Please note that, on ESP32, you have to use the IOMUX pins to use sdspi
in 40MHz, otherwise the initialization process will report reading issue
and fail.
2020-07-28 12:19:51 +08:00
9c82e7c875 docs: add a note about ESP-IDF FreeRTOS version 2020-07-27 20:24:43 +08:00
5fe10f1ff8 Bluedroid: Fixes cases having fallback to link up event.
Signed-off-by: Chinmay Chhajed <chinmay.chhajed@espressif.com>
2020-07-27 14:03:20 +05:30
ebacef4304 component/bt: add connect parameter, fix instant reverse, fix tx default octets, fix assert(1024,0), fix assert(512,0) 2020-07-24 12:05:29 +08:00
9566e4ec19 NimBLE: Add Non-Resolvable private address support and misc bug fixes (Backport v4.0)
- Merges https://github.com/espressif/esp-nimble/pull/12
- Fixes repeated pairing failure in RPA feature

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

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

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

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

See merge request espressif/esp-idf!9637
2020-07-22 17:28:24 +08:00
61bc60213e docs: change redirection link in get-started
This link is supposed to go to Step 3, but it goes to Step 2.
2020-07-22 17:17:38 +08:00
2595326978 components: convert string to bytes to fix TypeError There is a string passed as an argument for function, but a format of a string seemingly refers to bytes therefore it needs to be converted to bytes Solves https://esp32.com/viewtopic.php?f=13&t=16529
(cherry picked from commit cb0bdb8bba)
2020-07-22 11:04:22 +02:00
53605395cf Merge branch 'bugfix/collection_of_confirmed_fixes_from_baidu_project_4.0' into 'release/v4.0'
Backport MR for baidu project for release/v4.0

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

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

See merge request espressif/esp-idf!9665
2020-07-17 16:14:44 +08:00
9a88eef632 fix esp_bt_gap_get_bond_device_list bug
Closes https://github.com/espressif/esp-idf/issues/5395
2020-07-17 15:12:57 +08:00
lly
beda5f0fd4 ble_mesh: stack: Fix recv health current status incorrectly 2020-07-17 14:06:41 +08:00
a1cf4fa871 Support for more Bluetooth HID devices
Some Bluetooth devices - such as an Xbox One S controller (model 1708) - report more than two external features pages and are rejected immediately. Pages 1 and 2 are marked as unhandled in btm_devctl.c anyway, so there is no reason to block devices with more pages.
(IDFGH-3515)

Signed-off-by: liqigan <liqigan@espressif.com>

Merges https://github.com/espressif/esp-idf/pull/5481
Closes https://github.com/espressif/esp-idf/issues/5470
2020-07-17 10:23:52 +08:00
bf1394eeb8 Merge branch 'feature/toolchain_2020r2_v4.0' into 'release/v4.0'
Update toolchain to esp-2020r2  (backport v4.0)

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

See merge request espressif/esp-idf!9642
2020-07-16 14:03:15 +08:00
lly
235cdd2ff0 ble_mesh: ci: Enable friend & low power in build check 2020-07-16 11:04:58 +08:00
lly
f3566fd2af ble_mesh: stack: Only keep func pointer for very common log
Currently only keep func pointer for the followings:
- Invalid parameter (mesh btc & mesh stack)
- Out of memory (mesh btc & mesh stack)
- Unknown act (mesh btc)
- Invalid model user data (mesh stack)
- BT_DBG("%s", __func__) (mesh btc & mesh stack)
- A few other specific situations (buf ref debug, send status check)
2020-07-16 11:04:57 +08:00
lly
f10c62d84d ble_mesh: stack: Make proxy server & client functions clear 2020-07-16 11:04:57 +08:00
775fd14310 Merge branch 'bugfix/ble_mesh_add_misc_check_v4.0' into 'release/v4.0'
Bugfix/ble mesh add misc check (v4.0)

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

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

3. When AP switches from WPA3 to WPA2, device's PMF config in
Supplicant remains enabled. This may cause failures during
4-way handshake. So clear PMF config in when PMF is no longer used.
2020-07-15 13:40:03 +00:00
48ea44f3d1 Merge branch 'feature/light_sleep_reject_v4.0' into 'release/v4.0'
sleep: enable sleep reject when entering light sleep (v4.0)

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

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

See merge request espressif/esp-idf!9171
2020-07-15 16:38:05 +08:00
lly
1df9502301 ble_mesh: stack: Add proxy cfg pdu length check 2020-07-15 16:11:32 +08:00
lly
d04a8da916 ble_mesh: stack: Rework using dev flag to check scan status
Different bluetooth host has different behaviors, so it's better
to maintain a scan check mechanism of BLE Mesh itself.
Fixes an issue when only PB-GATT is enabled for node, which will
output a scan error log when the device is provisioned.
2020-07-15 16:11:31 +08:00
lly
6e79097b4a ble_mesh: example: Add result check during mesh init 2020-07-15 16:11:29 +08:00
lly
c8601fface ble_mesh: stack: Add more checks about input prov bearers 2020-07-15 16:11:27 +08:00
cf98746771 Merge branch 'feat/ble_mesh_use_iram_for_mem_alloc_v4.0' into 'release/v4.0'
Feat/ble mesh use diff ram for mem alloc (v4.0)

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

See merge request espressif/esp-idf!9593
2020-07-14 15:16:59 +08:00
6182c172bf Update toolchain to esp-2020r2
Fixes PSRAM issues, volatile loads with -O2, std::locale, C++ exception crashs, FDE sorting switchable;

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

Closes https://github.com/espressif/esp-idf/issues/5090
Closes https://github.com/espressif/esp-idf/issues/5112
Closes https://github.com/espressif/esp-idf/issues/5150
2020-07-14 14:04:54 +07:00
faae3ceec5 Add fixes for gcc8 psram fix improvement 2020-07-14 14:04:53 +07:00
f7742dd9cc Merge branch 'bugfix/customer_baidu_int_wdt_v4.0' into 'release/v4.0'
backport v4.0: add soft solution for esp32 eco3 live lock issue

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

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

See merge request espressif/esp-idf!9520
2020-07-13 20:41:15 +08:00
6f034e9194 esp-tls: enable TLS renegotiation using explicit API call
mbedTLS stack does not keep TLS renegotiation enabled even if
relevant config option is turned on, it needs explicit API call
`mbedtls_ssl_conf_renegotiation` to do so.

This issue was observed in case of Azure IoT, where keys needs to
be refreshed periodically to keep TLS connection intact.
2020-07-13 15:56:00 +05:30
de438461f5 Backport from baidu proj 2020-07-13 15:03:17 +08:00
cb7c143523 fix bug for ipv6 fragment 2020-07-13 11:30:33 +08:00
0100d70dfd ethernet: insert min assert time for PHY HW reset
Closes https://github.com/espressif/esp-idf/issues/5528
2020-07-13 11:21:30 +08:00
f73cd1d4f1 Merge branch 'docs/fix_event_typo_backport_v4.0' into 'release/v4.0'
docs/fix event typo backport v4.0

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

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

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

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

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

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

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

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

Closes https://github.com/espressif/esp-idf/issues/5300
2020-07-10 09:15:01 +08:00
067d840c76 Fix init MCPWM Fault line via config struct
Signed-off-by: wubowen <wubowen@espressif.com>

Merges https://github.com/espressif/esp-idf/pull/5491
Closes https://github.com/espressif/esp-idf/issues/5433
2020-07-09 19:18:10 +08:00
b9dd8630ee Merge branch 'doc/broken_readme_links_v4.0' into 'release/v4.0'
Docs: Fix broken README links (v4.0)

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

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

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

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

See merge request espressif/esp-idf!9362
2020-07-06 13:19:22 +08:00
d7f251aef3 ci provisioning: Add some experiments to check the runner's STA state
Not clear why sometimes it associates without negotiating a new DHCP lease.
2020-07-03 09:13:46 +00:00
e0fc7b1c48 esp_prov: Extend the timeout for HTTP connection to SoftAP 2020-07-03 09:13:46 +00:00
7358470ae9 ci wifi_tools: Log the wpa_supplicant interface state when trying to connect
Trigger reconnection if wpa_supplicant seems to have dropped the connection.
2020-07-03 09:13:46 +00:00
200fa4abeb legacy provisioning: Always try to reconnect when disconnected
Some APs may fail authentication temporarily if they have too many
associated stations, for example.
2020-07-03 09:13:46 +00:00
822b6986aa esp_prov: Refactor to use new 'wait_wifi_connected' function
Means all provisioning examples will have the same retry behaviour.
2020-07-03 09:13:46 +00:00
6787718e1b ci provisioning: Use strings instead of "magic numbers" for connection state 2020-07-03 09:13:46 +00:00
388522a886 ci: Wait up to 60 seconds for client to connect to DUT in provisioning test 2020-07-03 09:13:46 +00:00
a391a98a02 Merge branch 'bugfix/ble_mesh_fast_prov_misc_update_v4.0' into 'release/v4.0'
Bugfix/ble mesh fast prov misc update (v4.0)

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

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

See merge request espressif/esp-idf!9281
2020-07-02 21:29:18 +08:00
f12b8c7990 coredump: Fixes data length calculation when task stack is corrupted 2020-07-02 14:12:15 +03:00
lly
c4794f761e ble_mesh: ci: Fix failing to compile when using make 2020-07-02 03:35:13 +00:00
lly
4d9af50eba ble_mesh: Mark platform related default RNG as 0 2020-07-02 03:35:13 +00:00
lly
0e028c044d ble_mesh: Remove the previously added redundant aes files 2020-07-02 03:35:13 +00:00
lly
813cf5cc00 ble_mesh: Update CMake and make files for tinycrypt 2020-07-02 03:35:13 +00:00
lly
ac0746aba1 ble_mesh: Update tinycrypt header file include guards
Add BLE_MESH in the macro to make it specific for BLE Mesh.
2020-07-02 03:35:13 +00:00
lly
e5f4ff2b1a ble_mesh: Format source and header files of tinycrypt 2020-07-02 03:35:13 +00:00
lly
4f37a08437 ble_mesh: Port full implementation of tinycrypt [Zephyr]
- Original code is here: https://github.com/zephyrproject-rtos/tinycrypt
- Also this fixes the compile error when NimBLE and ESP BLE Mesh
  both uses the tinycrypt.
2020-07-02 03:35:13 +00:00
d8e590555c Merge branch 'bugfix/ble_mesh_readme_fix_v4.0' into 'release/v4.0'
ble_mesh: example: Fix example README & tutorial link error (v4.0)

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

See merge request espressif/esp-idf!9432
2020-07-02 11:29:06 +08:00
2c45d430da esp_wifi: Update wifi lib
1. Avoid parsing RSN/WPA IE's after connection
2. Remove AUTH_CHANGED reason code logic
2020-07-01 16:24:23 +05:30
671ecd7522 spiram: fix the read id failure
The issue is caused by:
1. The disable_qio_mode inside read_id may have side effects.
2. read_id twice may have side effects.

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

Issue introduced in 3ecbb59c15.
2020-07-01 16:39:16 +08:00
fd475fc9bc psram: fix 16mbit psram id read error 2020-07-01 16:38:29 +08:00
lly
797971e8cc ble_mesh: example: Fix example README & tutorial link error 2020-07-01 14:39:32 +08:00
8309f06378 Merge branch 'bugfix/kconfig_vendor_specific_v4.0' into 'release/v4.0'
Bugfix: bt/Kconfig Vendor specific event data type and default value

See merge request espressif/esp-idf!9416
2020-07-01 13:49:53 +08:00
lly
4fd867616c ble_mesh: ci: Add different proxy configurations 2020-07-01 11:55:13 +08:00
lly
3b6145dc46 ble_mesh: stack: Fix compile error when only proxy enabled
Also remove some redundant CONFIG_BLE_MESH_PROXY checks, because
when the following options are satisfied, the CONFIG_BLE_MESH_PROXY
option will be selected mandatorily.
2020-07-01 11:55:12 +08:00
b823a2a35f Merge branch 'bugfix/ble_mesh_check_subnet_before_update_beacon_sent_v4.0' into 'release/v4.0'
ble_mesh: Check if subnet exists before updating beacon_sent (v4.0)

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

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

See merge request espressif/esp-idf!9338
2020-06-30 15:26:57 +08:00
lly
dfcc8e77dc ble_mesh: Check if subnet exists before updating beacon_sent
- Before updating the "beacon_sent" of a subnet, we need to check
  if the subnet still exists, especially for a Provisioner.
- Fix a bug which will cause Provisioner failed to send Secure
  Network Beacon if no device is provisioned
2020-06-30 09:22:49 +08:00
lly
7f6735fd60 ble_mesh: stack: Copy recv_rssi for other received messages
Follow the commit: 2b80cb6883,
copy the recv_rssi for other mesh messages.
2020-06-30 09:05:51 +08:00
ca5ab9b607 When a generic mesh model message is received "bt_mesh_generic_server_cb_evt_to_btc" copies the
ctx values to cb_params for the mesh stack.

recv_rssi was not copied.

This means the rssi could not be read when receiving generic server messages using ble_mesh.
2020-06-30 09:05:50 +08:00
acb54059be docs:fix event typo
1.In the description of the ESP_API header file, it should be the event that the application layer needs to handle, not the BTA layer.
2.Fix name typo of BTA_GATTS_CREATE_SRVC_EVT event

Closes https://github.com/espressif/esp-idf/issues/5446
2020-06-29 20:59:14 +08:00
3e31c484ba Merge branch 'bugfix/http_server_lru_v4.0' into 'release/v4.0'
esp_http_server: Update LRU counter on accepting a new connection (v4.0)

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

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

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

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

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

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

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

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

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

See merge request espressif/esp-idf!9292
2020-06-26 14:43:02 +08:00
ae177f7077 static analysis: Apply current limits of known defects on v4.0 2020-06-25 06:16:14 +00:00
a9d4ed4a55 Bluedroid: Authentication fixes in Legacy and Secure Connection.
Prevent a remote device from doing a Bluetooth Impersonation Attack
(BIAS) by:

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

- Doing a mutual authentication during Legacy Authentication.

Signed-off-by: Chinmay Chhajed <chinmay.chhajed@espressif.com>
2020-06-24 22:25:20 +05:30
lly
939a3b78e2 ble_mesh: Fix wrong log output with bt_hex
- This issue was introduced in the commit: a788e7cd3d
  which updated the bt_hex() function incorrectly.
- And in bt_hex(), we use 2 for the two-dimensional array, because currently
  at most two bt_hex() will be used at the same time. Also this will save
  some DRAM compared with using 4.
2020-06-24 10:33:58 +00:00
lly
f1c0fee05b ble_mesh: Get node info with pre-configured node name
Also add a function to get the entry of the nodes table.

Closes https://github.com/espressif/esp-idf/issues/5397
2020-06-24 10:31:25 +00:00
lly
268b0e5e3f ble_mesh: Remove boolean type definitions 2020-06-24 09:12:31 +00:00
940fcf0ca9 ble_mesh: Do not #define bool when compiling in C++ 2020-06-24 09:12:31 +00:00
lly
c6ce7d2866 ble_mesh: stack: Check model status with variable length 2020-06-24 09:10:32 +00:00
lly
b4554ca2a6 ble_mesh: Move TAG definition to each example
Move the TAG definition of each example to the corresponding
source file (previously it is defined in the common example
intialization header file), which can avoid the redefinition
of TAG in some situations.
2020-06-24 09:08:18 +00:00
9b3aae1d32 tools: export.sh: fix compatibility with dash shell
* fix constructs invalid in dash
* clean shellcheck warnings and disable false positive ones

Closes https://github.com/espressif/esp-idf/issues/5366
2020-06-24 10:37:51 +02:00
0785d41c93 tools: export.sh: better detection and checking of IDF_PATH
1. detect IDF_PATH in zsh, if it is not set
2. if IDF_PATH is set, check that it is valid
3. make sure IDF_PATH is exported, not just set

Related to https://github.com/espressif/esp-idf/issues/3793
Closes https://github.com/espressif/esp-idf/pull/4418
Closes https://github.com/espressif/esp-idf/issues/4770
2020-06-24 10:37:17 +02:00
9624d9b19b Tools: Mention ESPPORT and ESPBAUD in idf.py --help
Closes https://github.com/espressif/esp-idf/issues/5461
2020-06-24 10:19:37 +02:00
4f22be795d Merge branch 'bugfix/python_lint_v4.0' into 'release/v4.0'
tools: fix python lint (v4.0)

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

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

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

See merge request espressif/esp-idf!9159
2020-06-22 11:45:10 +08:00
26e280c824 ble_hid_device_demo: fix build if building with c++
Signed-off-by: Elvis Dukaj <elvis.dukaj@gmail.com>
Signed-off-by: liminyang <liminyang@example.com>

Merges https://github.com/espressif/esp-idf/pull/5191
2020-06-18 15:49:11 +08:00
3c630c7905 Merge branch 'bugfix/efuse_logs_v4.0' into 'release/v4.0'
esp32: Reduce using ESP_EARLY_LOGx and move some code after the stdout initialization in startup code (v4.0)

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

See merge request espressif/esp-idf!9199
2020-06-18 13:45:17 +08:00
4a6e793322 esp32: Reduce using ESP_EARLY_LOGx and move some code after the stdout initialization
After setting _GLOBAL_REENT, ESP_LOGIx can be used instead of ESP_EARLY_LOGx.

Closes: https://github.com/espressif/esp-idf/issues/5343
2020-06-17 16:30:11 +08:00
458ed4085d feat(lwip): make LWIP TCP rto time configurable 2020-06-17 15:32:59 +08:00
e781279110 blufi: When the format of the received data packet is wrong, reply with an error response 2020-06-17 12:20:53 +08:00
94d97499a3 Merge branch 'bugfix/wpa3_ble_coex_issue_4.0' into 'release/v4.0'
Fix WPA3 Auth timeout issue during BLE coex (Backport v4.0)

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

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

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

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

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

See merge request espressif/esp-idf!9064
2020-06-10 15:57:41 +08:00
f677655fcb protocomm_httpd: Restart security session if request is received on a new session
This commit fixes a bug as well as changes a behaviour.

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

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

Ideally, from a security perspective, all communication related
to secure provisioning must happen on the same socket, and so, this
change is required.
2020-06-10 01:25:53 +05:30
6932b4d1c0 freemodbus: add comments for limitation in current version of freemodbus 2020-06-08 08:39:49 +02:00
ccdd06937f Merge branch 'feature/pin_ethernet_task_to_core_v4.0' into 'release/v4.0'
ethernet: support pin emac task to core (v4.0)

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

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

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

See merge request espressif/esp-idf!9056
2020-06-08 10:24:59 +08:00
d008eba708 esp_wifi: Remove auth_changed event and fix wpa2 authmode threshold
Added following as part of this change
1. Removed auth_changed event
2. Updated doc regarding usage of  WPA/WEP secuiry modes
3. Fixed WPA2 enterprise authmode threshold.
2020-06-07 10:55:02 +05:30
b76773d943 Merge branch 'bugfix/httpd_lru_purge_v4.0' into 'release/v4.0'
esp_http_server: Fixed a bug which could cause issues with LRU purge (v4.0)

See merge request espressif/esp-idf!8833
2020-06-05 18:38:33 +08:00
ad95174a7a esp_http_server: Fixed a bug which could cause issues with LRU purge
LRU counter should be started from 1, and not 0, so that all checks
work fine.

Closes https://github.com/espressif/esp-idf/issues/4753
2020-06-05 09:24:06 +00:00
1ad7e276d9 Merge branch 'workaround/wps_iot_fixes_v4.0' into 'release/v4.0'
wpa_supplicant: WPS Inter operatability Fixes( backport v4.0)

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

See merge request espressif/esp-idf!9014
2020-06-04 18:24:07 +08:00
84d6d48fe0 wpa_supplicant: Allow building with mbedTLS integration but no hardware MPI
Closes https://github.com/espressif/esp-idf/issues/5321
2020-06-04 18:32:58 +10:00
51bb86f0a6 partition_table: Fix parttool.py crashes when retrieving partition info
Closes: IDFGH-3279
Closes: https://github.com/espressif/esp-idf/issues/5271
2020-06-04 16:31:26 +08:00
7eaea6c726 sdmmc: Correctly check function parameters before using them
Closes https://github.com/espressif/esp-idf/pull/5000
2020-06-04 12:01:59 +08:00
9746fa569c wpa_supplicant: WPS Inter operatability Fixes
Add WPS IOT fixes under config option

Current fixes under this flag.
1. Allow NULL-padded WPS attributes.
2. Bypass WPS-Config method validation
2020-06-03 13:33:49 +00:00
40385ea454 wpa_supplicant: Allow NULL-padded WPS attributes
Some AP's keep NULL-padding at the end of some variable length WPS
Attributes. This is not as par the WPS2.0 specs, but to avoid interop
issues, ignore the padding by reducing the attribute length by 1.
2020-06-03 13:33:49 +00:00
d96d68ea38 ethernet: support pin emac task to core 2020-06-03 19:54:22 +08:00
9718338984 Merge branch 'bugfix/ble_mesh_remove_relay_dependency_v4.0' into 'release/v4.0'
ble_mesh: Remove relay option dependency (v4.0)

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

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

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

See merge request espressif/esp-idf!9004
2020-06-03 15:10:52 +08:00
7d6bcf5f5e docs: Fixup format of a command line to build unit tests 2020-06-03 12:17:36 +07:00
f75088d40d bugfix(uart): fix esp32 uart fifo_cnt bug
When using DPort to read fifo, fifo_cnt is not credible, we need to calculate the real cnt based on the fifo read and write pointer. When using AHB to read FIFO, we can use fifo_cnt to indicate the data length in fifo.
2020-06-03 12:29:06 +08:00
lly
19f69333f7 ble_mesh: Remove relay option dependency
When the relay functionality of a node is not enabled, this
issue will cause the node failing to send messages to fixed
group.
2020-06-02 19:18:52 +08:00
695ad84654 Merge branch 'bugfix/fix_some_wifi_bugs_0522_v4.0' into 'release/v4.0'
feature: optimize some wifi API (backport v4.0)

See merge request espressif/esp-idf!8878
2020-06-02 17:39:15 +08:00
lly
1636c2ba6b ble_mesh: Add nvs operations for examples
- Store onoff_client example proper mesh info
- Store vendor_client example proper mesh info

Closes https://github.com/espressif/esp-idf/issues/5359
2020-06-02 14:04:37 +08:00
lly
db2376bb09 ble_mesh: Add mesh example common nvs operations 2020-06-02 14:04:36 +08:00
lly
b55020ad80 ble_mesh: Config and health client btc fixes
Fix an issue which may cause no error code is returned
when sending config client or health client messages
with invalid parameters.
2020-06-02 14:04:35 +08:00
lly
1ac6d48fcf ble_mesh: Add more checks of net_idx & app_idx 2020-06-02 14:04:35 +08:00
lly
268f5ad6c6 ble_mesh: Optimize some send & recv logs 2020-06-02 14:04:34 +08:00
1ab23bfd3d Merge branch 'bugfix/ble_mesh_local_model_sub_v4.0' into 'release/v4.0'
Bugfix/ble mesh local model sub (v4.0)

See merge request espressif/esp-idf!8984
2020-06-02 10:58:40 +08:00
lly
205425b86b ble_mesh: correct the return type [Zephyr] 2020-06-02 10:32:25 +08:00
lly
c2589b0b57 ble_mesh: Add net_buf_simple_init_with_data [Zephyr] 2020-06-02 10:32:24 +08:00
lly
f990d725f4 ble_mesh: Optimize model recv operations [Zephyr]
Previously the model recv operation is a littl fuzzy.
With the changes, the model recv operation is splitted into:
- find op
- check app_idx
- check dst
- check length
- update info & handle message
2020-06-02 10:32:23 +08:00
lly
073b8daa6e ble_mesh: Rework prov pdu length check 2020-06-02 10:14:50 +08:00
6a844f3737 Merge branch 'bugfix/kconfig_hex_values_v4.0' into 'release/v4.0'
kconfig: Fix two cases of hex values being handled incorrectly (v4.0)

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

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

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

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

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

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

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

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

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

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

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

See merge request espressif/esp-idf!8943
2020-05-28 10:13:44 +08:00
9e21c09a11 esp_wifi: Update wifi lib
Fix WPA3 Auth issue in coex scenario
2020-05-27 19:44:39 +05:30
lly
63c83730c2 ble_mesh: Transport tx fields overflow [Zephyr]
The transport segmented TX nack and seg_pending fields must be at least
6 bits to avoid overflow for 32 segment messages. This change rearranges
the seg_tx fields to gather all state flag fields in one byte, while
making the counter fields whole bytes.
2020-05-27 17:45:55 +08:00
lly
f781c6edac ble_mesh: Friend with unknown appkey [Zephyr]
Ensures that friend messages are enqueued, even if the packet is
received with an appkey is unknown to the friend. Previously, sdu_recv
would return EINVAL if the appkey was unknown, which would prevent the
lower transport layer from adding the packet to the friend queue. This
is irrelevant for the logic in lower transport, and should not be
returned as an error.
2020-05-27 17:45:49 +08:00
lly
7078065980 ble_mesh: Not using pre-initialized private key 2020-05-27 17:39:35 +08:00
lly
a8afd951dc ble_mesh: Same func for storing/restoring comp data 2020-05-27 17:31:01 +08:00
652e5352ee Merge branch 'bugfix/ble_mesh_uses_deprecated_config_v4.0' into 'release/v4.0'
ble_mesh: Fix using old config for duplicate scan (v4.0)

See merge request espressif/esp-idf!8901
2020-05-27 17:24:26 +08:00
2ea5f522f3 ci: Don't push to Github or deploy docs on customized pipelines
BOT_TRIGGER_WITH_LABEL must be empty (meaning all tests are running).
2020-05-27 19:06:30 +10:00
20c34cac2d Merge branch 'bugfix/fix_some_wifi_bugs_0427_v4.0' into 'release/v4.0'
Bugfix/fix some wifi bugs 0427 (v4.0)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

See merge request espressif/esp-idf!8867
2020-05-22 19:13:05 +08:00
lly
699270e09e ble_mesh: Fix Provisioner failed to publish 2020-05-22 15:48:49 +08:00
lly
59187b0921 ble_mesh: Fix tutorial links in examples README.md 2020-05-22 14:30:12 +08:00
lly
ec6ebf7d4e ble_mesh: Rename esp_fast_prov_* to ble_mesh_fast_prov_* 2020-05-22 14:30:05 +08:00
lly
bcc1eb916b ble_mesh: Rename the folders ble_mesh_fast_prov_* to fast_prov_* 2020-05-22 14:28:38 +08:00
lly
9891045018 ble_mesh: Rename ble mesh example main & init files
- Rename ble_mesh_demo_main.c to main.c
- Rename ble_mesh_demo_init.* to ble_mesh_example_init.*
2020-05-22 14:22:39 +08:00
lly
009878f02d ble_mesh: Move the example init to the common_components 2020-05-22 14:21:43 +08:00
ee51d336d3 mqtt: clenaup logs and docs, esp_mqtt_abort_connection race condition
esp_mqtt_abort_connection: Fixed an issue which could result in a race condition and subsequent crash

esp_mqtt: Change an error print to use ESP_LOGE instead of ESP_LOGI
Move Sending MQTT connect message log from Info to Debug level
docs: Makes clear that publish API could block
Change the message printed after MQTT connection failure
2020-05-22 06:21:25 +00:00
d7310ae008 esp_mqtt: add option to configure mqtt task priority.
Merges https://github.com/espressif/esp-idf/pull/4947
2020-05-22 06:21:25 +00:00
lly
8bbee15932 ble_mesh: Move the button component to common_components 2020-05-22 14:20:56 +08:00
lly
d15735c71f ble_mesh: Change the EXTRA_COMPONENT_DIRS used by examples 2020-05-22 14:20:41 +08:00
lly
b63abd2069 ble_mesh: Rename common_vendor_models to common_components
Since the scripts of CI will bypass common_components when
trying to get ALL_EXAMPLES, and these BLE Mesh components
will only be used by other mesh examples, i.e. no need to
be compiled as a single example, so we rename the folder
to common_componnets.
2020-05-22 14:20:21 +08:00
acf1478a51 socket-examples: IPv6 related update for examples to set correct scoped id
The scope id must be present when connecting to IPv6 Local Link
address.
2020-05-22 06:19:49 +00:00
55dd3c8b77 ws_client: fix fragmented send setting proper opcodes
Previous implementation violated the RFC by having both the actual opcode and WS_FIN flag set for all fragments of a message.
Fixed by setting the opcode only for the first fragment and WS_FIN for the last one

Closes IDFGH-2938
Closes https://github.com/espressif/esp-idf/issues/4974
2020-05-22 06:11:44 +00:00
7b01509b19 Merge branch 'bugfix/stop_mac_can_be_controlled_by_user_v4.0' into 'release/v4.0'
Bugfix/stop mac can be controlled by user v4.0

See merge request espressif/esp-idf!8762
2020-05-22 14:07:48 +08:00
754f59fba7 spi_flash(new driver): Add a Kconfig option - Bypass a block erase and always do sector erase
Closes: IDF-1561
2020-05-22 05:07:20 +00:00
9926b875d8 spi_flash(LEGACY_IMPL): Add a Kconfig option - Bypass a block erase and always do sector erase
Closes: IDF-1561
2020-05-22 05:07:20 +00:00
79831e64fd spi_flash: Add into sim/stubs the esp_timer 2020-05-22 05:07:20 +00:00
a128eae7b8 spi_flash(new driver): Add vTaskDelay while a long erasing 2020-05-22 05:07:20 +00:00
98ac272a3f spi_flash(LEGACY_IMPL): Add vTaskDelay while a long erasing
Added Kconfig options to enable yield operation during flash erase

Closes: https://github.com/espressif/esp-idf/issues/2083
Closes: https://github.com/espressif/esp-idf/issues/4916
Closes: IDFGH-261
2020-05-22 05:07:20 +00:00
lly
13167a7579 ble_mesh: Clear two more vars during proxy server deinit 2020-05-22 11:39:51 +08:00
lly
acf41f93a9 ble_mesh: Add missing sdkconfig.h 2020-05-22 11:39:51 +08:00
lly
470c959b04 ble_mesh: Init device name during proxy server init
Device name will be reset when deinit mesh stack. If not
initializing device name during the next mesh stack init,
it will fail to set the device name when using bluedroid.
2020-05-22 11:39:50 +08:00
lly
dd7c98d6c2 ble_mesh: Add init flag for friend init/deinit
Since bt_mesh_friend_init() will only be invoked when
a device is provisioned or Provisioner is enabled, so
we add a flag to indicate if the friend functionality
is initialized in case deinit before initialization.
2020-05-22 11:39:49 +08:00
lly
90aa79fd2b ble_mesh: Remove patch for the bug of an App 2020-05-22 11:37:30 +08:00
lly
97c1a4b5c6 ble_mesh: Fix typos 2020-05-22 11:34:07 +08:00
5897354d7f Merge branch 'bugfix/sync_zephyr_bt_mesh_bugfix_v4.0' into 'release/v4.0'
Bugfix/sync zephyr bt mesh bugfix (v4.0)

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

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

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

See merge request espressif/esp-idf!8530
2020-05-21 17:42:02 +08:00
lly
d2bcb5c7ff ble_mesh: A specific fix for compile warning in idf4.0
Compared with the latest idf, idf4.0 defines BIT(nr) in
the "esp_bit_defs.h" without the pre-condition "#ifndef BIT",
which will cause compile warning when using mesh. So we
include the header file "soc/soc.h" in "mesh_util.h",
which can bypass the definition of "BIT" in "mesh_util.h"
when compiling.
2020-05-21 16:50:09 +08:00
lly
2ea69e6df5 ble_mesh: Fix mesh node device role restore
Old version of BLE Mesh has no device role storage, because
previously we only support storing mesh node info.
If the binary of the node is upgraded from old version to a
new version (support storing provisioner info), the mesh info
of the node will not be restored because mesh role does not
exist in the flash.
2020-05-21 15:26:50 +08:00
lly
b5bd1bf67e ble_mesh: Fix not update prov addr in fast prov
When using fast provisioning, the Provisioner functionality
will be enabled. Unicast addresses within the pre-allocated
range will be used for provisioning nodes. And during the
address assignment, the allocated unicast address will be
checked that if it's duplicated with other nodes addresses
and the Provisioner's own addresses.
So before starting using fast provisioning, we need to update
the Provisioner address.
2020-05-21 15:22:21 +08:00
lly
8294055c65 ble_mesh: net_key_status only pull one key idx [Zephyr]
Fixes bug where the config client's net_key_status handler would attempt
to pull two key indexes from a message which only holds one.
2020-05-21 15:22:21 +08:00
lly
11286e35a2 ble_mesh: Update client message timeout calculation
Since the behavior of sending segmented messages has been
changed properly, the calculation of timeout value which
will be used when sending an acknowledged message by a
client model also needs to be updated.
2020-05-21 15:22:20 +08:00
lly
2c5b0a523a ble_mesh: Add lock for segmented msg operations
Add mutex to protect some variables of the mesh segmented
messages.
Currently the timeout handler of mesh will be executed in
the btc task, while the received mesh messages will be
handled in the btu task. In case some variables are set to
NULL when handled in the btu task, meanwhile these variables
are also accessed in the timeout handler, so we add mutex to
protect these variables and related operations.
2020-05-21 15:22:19 +08:00
lly
8c6f6318c0 ble_mesh: Fix dereferencing pointer before checking for NULL [Zephyr]
The publication context is checked for NULL in bt_mesh_model_publish()
however it was dereferenced before that. Move the assignment to
ctx.send_rel to the same place where other ctx members are set.
2020-05-21 15:22:18 +08:00
lly
632d9739b5 ble_mesh: Optimize some mesh log output 2020-05-21 15:22:18 +08:00
lly
34cb56b7aa ble_mesh: Fix restore when revoke keys [Zephyr]
Store keys (NetKey and AppKey) again after revoking.
2020-05-21 15:22:17 +08:00
lly
7c12074801 ble_mesh: Spit mesh_util.h into different header files
Split mesh_util.h into mesh_byteorder.h, mesh_compiler.h,
mesh_ffs.h and mesh_util.h based on the classification of
Zephyr, which will make further porting more clear.
2020-05-21 15:22:16 +08:00
lly
4b21a34675 ble_mesh: Split mesh os related into a separate file 2020-05-21 15:22:13 +08:00
lly
ac51ec11ec ble_mesh: Split mesh mutex into a separate file 2020-05-21 15:19:52 +08:00
lly
7db10be193 ble_mesh: Rename mesh_kernel.* to mesh_timer.* 2020-05-21 15:19:51 +08:00
lly
fde075aec2 ble_mesh: Add and use transport macro definitions [Zephyr] 2020-05-21 15:19:51 +08:00
lly
cbd2bcfbd2 ble_mesh: Friend SeqAuth cleanup [Zephyr]
The Friend queue uses the message SeqAuth to determine whether the
message is already in the queue. To facilitate this, the SeqAuth is
passed around as a pointer throughout the transport modules. In the
bt_mesh_ctl_send functions, this parameter is also exposed in the API,
but the internal usage is inconsistent and buggy. Also, no one actually
uses this parameter.

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

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

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

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

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

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

---

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

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

Mesh Profile Spec 1.0, Section 4.2.11:

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

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

Mesh Profile Spec 1.0, Section 4.2.11.1:

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

Previously, an error return from publish update would cancel periodic
publishing. This can't be recovered from, and as such, no valid model
implementation could return an error from this callback, and there was
no way to skip a periodic publish.
2020-05-21 15:19:36 +08:00
lly
2b6131b5f4 ble_mesh: Enable Segmented Control Messages [Zephyr]
The function bt_mesh_ctl_send() used to support maximum length of
11 bytes. The segmentation complies with the BLE Mesh Standard.
The ack is disabled in case of non unicast address.
2020-05-21 15:19:36 +08:00
793d2b11f1 Merge branch 'bugfix/ble_mesh_not_ignore_msg_in_fast_prov_v4.0' into 'release/v4.0'
ble_mesh: Not ignore msg when fast prov is enabled (v4.0)

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

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

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

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

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

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

See merge request espressif/esp-idf!7996
2020-05-21 11:39:39 +08:00
lly
3e885dc73b ble_mesh: Add bluedroid and nimble example configurations 2020-05-20 11:25:07 +00:00
lly
c85d7dfd5a ble_mesh: Add ble mesh sensor model examples 2020-05-20 10:51:55 +00:00
lly
9a654ec590 ble_mesh: Add some common macros for sensor model 2020-05-20 10:51:55 +00:00
lly
193828f121 ble_mesh: Allow empty sensor series column value 2020-05-20 10:51:55 +00:00
lly
fab2dcb790 ble_mesh: Check if same sensor (settings) property id exists 2020-05-20 10:51:55 +00:00
lly
d3619d0b45 ble_mesh: Allow empty sensor settings exist 2020-05-20 10:51:55 +00:00
5af06f49f5 NimBLE: Include upstream fixes and use macros for log level filtering (backport v4.0)
Change list:
- Reduces the size of the compiled binary, PR: https://github.com/espressif/esp-nimble/pull/6
- Null pointer check, PR: https://github.com/apache/mynewt-nimble/pull/701
- Pairing procedure abort on unexpected req: https://github.com/apache/mynewt-nimble/pull/710
- Fix conn flags after pairing: https://github.com/apache/mynewt-nimble/pull/730
- Remove notification for update process timeout (Vol 6, Part B, section 5.2 ):
  https://github.com/apache/mynewt-nimble/pull/782
- CCCD fix : https://github.com/apache/mynewt-nimble/pull/790 and
  https://github.com/apache/mynewt-nimble/pull/804
- Host based Privacy (RPA) fix: https://github.com/espressif/esp-nimble/pull/7

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

 Closes https://github.com/espressif/esp-idf/issues/4413
2020-05-20 16:19:55 +05:30
e430860df3 wifi changes:
1. fix the bug for softAP update second channel wrong
2. change wifi_scan_time_t from union to struct
3. query country code wrong when policy change from manual to auto
4. fix the timeout issue of EAPOL four-way handshake
5. fix the crash issue when fetch peer after delete the cur_peer
2020-05-20 18:13:07 +08:00
4c81978a3e Merge branch 'bugfix/doc_version_links_v4.0' into 'release/v4.0'
doc: Fix broken Release page links when building a stable version (v4.0)

See merge request espressif/esp-idf!8821
2020-05-20 13:17:23 +08:00
ddc2427385 esp_wifi:Add softap example channel configuration 2020-05-20 10:59:04 +08:00
6153026f22 doc: Fix broken Release page links when building a stable version 2020-05-20 11:32:53 +10:00
18abdd7cb0 confserver: Always store hex values in sdkconfig with 0x prefix
This is not necessary for correct behaviour or to have valid sdkconfig files
(previous commit adds tests for this), but it's useful for consistency with
sdkconfig files generated by menuconfig.

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

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

Closes https://github.com/espressif/vscode-esp-idf-extension/issues/83
2020-05-18 17:02:37 +10:00
fc2199c5d6 Merge branch 'bugfix/wpa3_mixed_mode_authype_v4.0' into 'release/v4.0'
esp_wifi: Add and utilize WPA3/WPA2 Mixed mode Authtype (backport v4.0)

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

See merge request espressif/esp-idf!8755
2020-05-16 19:53:15 +08:00
65d4596a36 wifi_provisioning: Catch the Wi-Fi events even after Connection errors
It was observed that after sending credentials, if the first
Wi-Fi conection attempt fails, the Wi-Fi provisioning managager
ignores subsequent Wi-Fi events. So, even if the device eventually
connects to the AP, the provisioning stays on indefinitely.

Changing a check so that subsequent events are also captured and
provisioning finishes successfully.
2020-05-15 13:50:47 +00:00
748720a466 esp_wifi: Update WiFi lib
Add and utilize WPA3/WPA2 Mixed mode Authtype
2020-05-15 14:58:07 +05:30
8688bd0593 add LINGER to menuconfig 2020-05-15 17:18:50 +08:00
6ee978c6aa add congest direct callback and fix malloc failed when multi_connection notify performance test 2020-05-15 16:18:31 +08:00
d231b25bc4 fix bta_dm_deinit_cb crash 2020-05-15 16:16:26 +08:00
456c8bdbdf master missing BLE_AUTH_CMPL_EVT after restart 2020-05-15 16:16:26 +08:00
94917184be Merge branch 'bugfix/wpa3_pmf_memleak_fix_v4.0' into 'release/v4.0'
WPA3 / PMF memory leak fixes (backport v4.0)

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

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

See merge request espressif/esp-idf!8736
2020-05-14 16:19:36 +08:00
6442184dd8 ethernet: fix potential task watch dog timeout 2020-05-14 14:23:32 +08:00
02c47360f1 Add NimBLE config options in sdkconfig.rename 2020-05-14 11:31:53 +10:00
db5f01429f wpa_supplicant: Fix memory leaks in WPA3 connection
1. Buffers for SAE messages are not freed after the handshake.
   This causes memory leak, free buffers after SAE handshake.
2. SAE global data is not freed until the next WPA3 connection
   takes place, holding up heap space without reason. Free theis
   data after SAE handshake is complete or event fails.
3. Update wifi lib which includes memory leak fix during BIP
   encryption/decryption operations.
2020-05-13 20:45:34 +05:30
b938846de6 wpa_supplicant: Fix formatting of file esp_wpa3.c
Replace tabs with spaces in esp_wpa3.c.
2020-05-13 20:35:56 +05:30
7d295e18bc Merge branch 'bugfix/fix_switch_channel_without_discon_issue_v4.0' into 'release/v4.0'
esp_wifi: Fix AP switch to adjacent channel without disconnect (backport v4.0)

See merge request espressif/esp-idf!8705
2020-05-13 19:58:22 +08:00
lly
b47111c708 ble_mesh: Not ignore msg when fast prov is enabled
When fast provisioning is enabled, Provisioner shall not
ignore messages from the nodes whose addresses are not in
the provisioning database. Because other nodes which are
not provisioned by the Primary Provisioner will send node
address messages to the Primary Provisioner.
2020-05-13 10:09:50 +08:00
6a6de506b1 Merge branch 'bugfix/supplicant_general_fixes_40' into 'release/v4.0'
wpa_supplicant: Fix some memleaks and invalid memory access (backport v4.0)

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

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

See merge request espressif/esp-idf!8451
2020-05-12 20:15:45 +08:00
0863de4a69 esp_wifi: Fix AP switch to adjacent channel without disconnect 2020-05-12 17:20:48 +08:00
db3a1110ec pthread: Use INTERFACE in target_link_libraries for vPortCleanUpTCB wrapper 2020-05-12 10:35:47 +05:30
398dc28a4e wpa_supplicant: Add parsing support for WEP40 key
WEP key is passed as ascii key without "", add parsing support
in supplicant for this.
2020-05-11 11:23:10 +05:30
4011393920 ldgen: determinism in mapping rule order
This MR imposes some determinism in the mapping rule order in the output
file. For each section, the archives are arranged alphabetically
(ascending), and the mapping rules in each archive are arranged by
increasing specificity then alphabetically (ascending). The default
rules remain the very first rule for each section.
2020-05-08 21:10:19 +08:00
a87df25d9e fix(wpa_supplicant): fix memleak in wpa3 feature 2020-05-08 16:25:38 +08:00
lly
814108f9ac ble_mesh: Add length check for some mesh operations 2020-05-07 09:18:15 +00:00
lly
baf0fb3576 ble_mesh: Fix compile error when -O2 (performance) is chosen 2020-05-07 09:18:15 +00:00
lly
a895bb157f ble_mesh: Fix node not erase info completely
Previously only mesh node info is supported to be stored
in flash. So when trying to reset the node, we only need
to judge if the BLE_MESH_VALID flag is set.
Currently we support storing both node & Provisioner info
in flash, when trying to erase the node info from flash,
the BLE_MESH_NODE flag will be checked. So we need to set
bt_mesh.flags to 0 when all the erase operations are done.
2020-05-07 09:16:51 +00:00
b0f053d82d Merge branch 'bugfix/get_started_export_profile_v4.0' into 'release/v4.0'
docs: remove suggestion about running export.sh from .profile script (backport v4.0)

See merge request espressif/esp-idf!8614
2020-05-07 12:07:05 +08:00
4242519894 wpa_supplicant: Fix some memleaks and invalid memory access
Add changes to fix issues reported in clang analyzer
2020-05-06 11:06:51 +00:00
b3c3b4e7f0 ethernet: not using latch register to check link 2020-05-06 17:28:18 +08:00
f09c9b957c timer_group: fix intr_enable
timer group interrupt enable is controled by level_int_ena instead of int_ena

Closes https://github.com/espressif/esp-idf/issues/5103
2020-05-06 17:28:18 +08:00
24c9f56d45 Fix typo with sigmadelta.h #ifdef 2020-05-06 17:28:18 +08:00
08bcb587ec Merge branch 'fix/ci_example_test_prov_v4.0' into 'release/v4.0'
CI: Fix prov example test exception handle (v4.0)

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

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

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

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

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

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

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

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

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

Closes https://github.com/espressif/esp-idf/issues/3889
2020-05-05 21:39:30 +02:00
02b5db37d1 doc: Specify that sleep wakeup source restrictions apply to all current ESP32 revisions
Closes https://github.com/espressif/esp-idf/issues/4681

Discussion https://esp32.com/viewtopic.php?f=13&t=15145
2020-04-30 15:36:04 +10:00
7f4b651434 tools: Make Unicode from subprocess result in the CMake convert script
Fixes an issue with Python 3 in MSYS where it fails while trying to join
paths where one part is Unicode (default string on Python3) and the
second part are bytes (returned by the subprocess call).

Closes https://github.com/espressif/esp-idf/issues/5189
2020-04-28 15:22:27 +02:00
lly
b97d4c617b ble_mesh: Fix time scene wrong macro name 2020-04-27 16:26:23 +08:00
lly
765bd76ba3 ble_mesh: Add missing #ifdef __cplusplus 2020-04-27 15:34:14 +08:00
lly
9370264cac doc: Fix some ble mesh description 2020-04-27 15:25:46 +08:00
07c1d9d9c7 doc: Add warnings about using JTAG debugging with hardware security features
This is related to the following issues but is not a fix, just documentation of a workaround until we can
improve the support:
https://github.com/espressif/esp-idf/issues/4878
https://github.com/espressif/esp-idf/issues/4734
2020-04-27 16:41:16 +10:00
lly
8bfa01cc28 ble_mesh: Fix client local parameters not initialized 2020-04-27 14:39:40 +08:00
lly
90a9444696 ble_mesh: Continue node info restore even if failure happens
During BLE Mesh Provisioner initialization, the stack will restore
the nodes information if settings storage is enabled.
Previously when a failure happens (e.g. found the same uuid) during
the restore procedure, the information of the following nodes will
not be restored and error will be directly returned.
But this will introduce some problem with user experience, because
some newly provisioned nodes information will not be restored and
Provisioner will not be able to control those nodes.
So we change the operation here, when a failure happens during the
restore procedure, Provisioner will only ignore the information of
the current node and continue restoring other nodes information.
2020-04-27 14:39:40 +08:00
lly
b9fd2673a7 ble_mesh: Remove some redundant functions 2020-04-27 14:39:39 +08:00
lly
7595116353 ble_mesh: Notify unprovisioned device beacon to application layer
With this change, if a Provisioner has provisioned the maximum
number of nodes, it can still report the unprovisioned device
beacon from other nodes to the application layer. And this will
be more reasonable compared with the previous implementation.
Previously when the node array of Provisioner is full, no beacon
from unprovisioned devices will be reported, only some warning
logs will be given.
2020-04-27 14:39:38 +08:00
lly
9aae0f2dee ble_mesh: Check if assigned node address is duplicated
Previously only check the node address when it is assigned by the
application layer. Here we also check the address when the address
is allocated internally. And this will be useful when some mesh
internal tests are performed.
2020-04-27 14:39:38 +08:00
lly
f137546a4b ble_mesh: Update next alloc address when node info is added 2020-04-27 14:39:37 +08:00
lly
388043c203 ble_mesh: Fix Provisioner provisioning deadlock 2020-04-27 14:39:37 +08:00
lly
c496fa79de ble_mesh: Remove BLE_MESH_MAX_STORED_NODES option
Previously the BLE_MESH_MAX_STORED_NODES option is added for
internal mesh test, which will be a little confusing for the
users to understand.
Here we remove this option, instead the BLE_MESH_MAX_PROV_NODES
will be used for all the cases. For mesh internal test, when
the test function is called to add some nodes info, the info
will be stored in the array of provisioned nodes directly.
2020-04-27 14:39:36 +08:00
lly
2af16b92e5 ble_mesh: Associate replay protection list size with nodes count
The replay protection list of Provisioner should be at least equal
to the number of nodes with the precondition that each node contains
only one element.
The help information of replay protection list is updated, and the
maximum number of nodes for Provisioner is adjusted based on the
replay protection list size.
2020-04-27 14:39:35 +08:00
8c98f6bdaf heap: Only fill new heaps with FREE_FILL_PATTERN if Comprehensive poisoning is on
Significantly speeds up heap initialization at startup when default "Light" heap
poisoning is enabled.

Tip via reddit user LinkeSeitentasche https://www.reddit.com/r/esp32/comments/fnj51a/a_guide_to_improving_esp32_boot_speed/
2020-04-27 16:34:31 +10:00
c4af9d3e24 CI: Add EOL to sdkconfig.defaults before adding sdkconfig.ci 2020-04-23 16:54:33 +02:00
27da86fb6e fixbug for tcp kill state assert 2020-04-23 16:04:33 +08:00
2d13bfb8fa CI: Fix partition table detection if "partition" is in the project name 2020-04-22 10:05:18 +02:00
81f0744ada test: add a (non-automated) case for backtraces with ROM functions 2020-04-21 11:49:15 +02:00
c3ae910529 heap: recognize 0x40000000 as an address terminating the backtrace
On Xtensa, backtrace can not recover the two most significant bits of
the address, as the window call size is encoded in these bits.
Because of this, __builtin_return_address modifies these MSBs to
match those of the callee, "fixing" the address. An unfortunate side
effect is that the zero return address, which usually terminates the
backtrace, gets converted to 0x40000000. While there is a valid
instruction at this address, its occurrence in the backtrace is
highly unlikely: this is the first instruction of WindowOverflow4
vector, and IDF apps switch VECBASE to an IRAM location very early at
startup.
2020-04-21 11:48:43 +02:00
c955b7d133 Merge branch 'docs/backport_6147' into 'release/v4.0'
backport changes in 6147

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

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

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

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

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

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

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

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

Updated test case to use CONFIG value for expected length.
2020-04-15 21:13:21 +08:00
a78772bbc6 app_update: Fix case when elf file SHA256 should be printed by panic handler while cache is disabled
Closes: IDF-1342
2020-04-15 21:06:43 +08:00
1490256968 efuse: Fix get_coding_scheme() when CONFIG_SECURE_FLASH_ENC_ENABLED and LOG_LEVEL is Debug
Closes: https://github.com/espressif/esp-idf/issues/4862
2020-04-15 20:52:50 +08:00
5209dff76b wpa_supplicant: Fix compilation errors when USE_MBEDTLS is disabled.
This is a regression from earlier commit related to TLSV12 which used
sha functions that are currently declared static.
Solution: Follow upstream code structure and resolve the errors.
2020-04-15 15:34:35 +05:30
b7f163530b fix(transport): Fix a bug of the connection whether be active or not by timeout option when the select function return a correct value. 2020-04-15 09:49:03 +00:00
a2d0fb348b Merge branch 'feature/add_rtc_xtal_cal_retry_option_v4.0' into 'release/v4.0'
esp32: Add a Kconfig option - Number of attempts to repeat 32k XTAL calibration (v4.0)

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

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

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

See merge request espressif/esp-idf!8204
2020-04-15 13:06:49 +08:00
64061541f0 wpa_supplicant: Fix wpa_supplicant TLS 1.2 issues
1) Fixed compilation issues.
2) Added tlsprf.c from upstream
3) Enabled SHA256 in supplicant compilation.
2020-04-13 16:24:26 +00:00
6825d8e0be Merge branch 'bugfix/uart_echo_readme_v4.0' into 'release/v4.0'
example: Remove duplicate commands and invalid serial port information (v4.0)

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

See merge request espressif/esp-idf!8309
2020-04-13 22:38:39 +08:00
14c978b54f example: Remove duplicate commands and invalid serial port information
Closes https://github.com/espressif/esp-idf/issues/5049
2020-04-13 15:26:22 +02:00
a6b08cb025 psram: support psram 2T mode to fix single bit error
1. add enable PSRAM 2T mode function
2. abort when himem and 2T mode are enabled meanwhile
3. set SPIRAM_2T_MODE as "n" by default, enable it when needed
2020-04-13 14:52:33 +08:00
acdba0eb46 Merge branch 'feat/ble_mesh_ble_adv_simultaneously_v4.0' into 'release/v4.0'
ble_mesh: Support BLE advertising simultaneously (v4.0)

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

See merge request espressif/esp-idf!8159
2020-04-10 17:29:07 +08:00
0b4e1ecdec esp_wifi: backport some WiFi bugs
1. Fix WiFi log print level

2. Optimize WiFi/BT coexist sleep
   - If any data tx/rx in WiFi slice, fore wakeup next TBTT
   - Increase active timeout time to coex TBTT interval to avoid sleep in WiFi slice

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

4. Fix esp_wifi_stop() leads to memory leak

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

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

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

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

See merge request espressif/esp-idf!8267
2020-04-06 18:04:11 +08:00
d74995736c esp_ota_ops.c: Fix size calculation to erase partition range for OTA image
Closes https://github.com/espressif/esp-idf/issues/4953
2020-04-06 13:39:51 +05:30
c8a05bae78 Merge branch 'bugfix/nvs_no_throw' into 'release/v4.0'
NVS: Changed all new to new (nothrow) (backport v4.0)

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

See merge request espressif/esp-idf!8227
2020-04-03 13:28:30 +08:00
ccc6363a21 core dump: don't allow core dumps to Flash if PSRAM is used for stacks
It is not possible to write to Flash when the stack is located in
PSRAM, and it is not possible to write PSRAM buffers into Flash when
malloc can not be used.
2020-04-02 23:44:47 +02:00
8ffb38265c driver: fix gpio pin_bit_mask truncation in sdspi_host and others
Closes https://github.com/espressif/esp-idf/issues/4348
2020-04-02 23:38:17 +02:00
17bd6e8fab Add missing extern "C" to rtc_cntl.h
Related: https://github.com/espressif/arduino-esp32/issues/3149
2020-04-02 23:36:14 +02:00
192c20c9f7 clk.h: add extern C guards
Closes https://github.com/espressif/esp-idf/issues/4215
2020-04-02 23:22:41 +02:00
c7ac9a296d Added Cpp compatibility for components/spi_flash/include/esp_flash_spi_init.h
Merges https://github.com/espressif/esp-idf/pull/4260
2020-04-02 23:22:10 +02:00
50073a7e61 Merge branch 'nimble/misc_host_flow_ctrl_changes_v4.0' into 'release/v4.0'
NimBLE: Misc fixes in NimBLE host (backport v4.0)

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

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

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

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

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

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

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

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

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

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

See merge request espressif/esp-idf!8082
2020-03-31 11:52:16 +08:00
dfd197b4c5 Wifi_provisioning_mgr_test: Allow three attempts to connect to AP before concluding provisioning failure (v4.0) 2020-03-30 11:22:48 +05:30
1e2ca78aac Wifi_provisioning_ble: Change service_uuid to non standard 128 bit UUID (v4.0)
- Modifies UUIDs in scheme_ble, manager example and esp_prov tool to custom 128
  bit UUID
2020-03-30 11:22:32 +05:30
lly
1d55af4bb2 ble_mesh: Add ble mesh white list test function
Using the ble mesh white list test functions, a node can choose to
only receive mesh messages from a specific node and relay the
messages for it. Messages from other nodes will be ignored.
2020-03-30 11:03:00 +08:00
b2a3a9041d components/coex: Fix wakeup delay with DFS 2020-03-28 20:49:15 +08:00
286d249239 components/bt: Fix assert when create conntion cancel 2020-03-28 20:44:43 +08:00
9d5d22c458 multi_heap: ensure that malloc(0) return NULL pointer in any poisoning configuration 2020-03-27 14:30:27 -03:00
13f4656d2a tools: Fix flashing encrypted binaries from IDF Monitor 2020-03-27 10:31:37 +01:00
57a5a486ff Merge branch 'feat/ble_mesh_vnd_model_example_v4.0' into 'release/v4.0'
Feat/ble mesh vnd model example (v4.0)

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

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

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

See merge request espressif/esp-idf!8021
2020-03-24 15:25:47 +08:00
d71ac521cf esp_wifi: backport some wifi bugs 0323
1,Reduce WiFi bin size
2,Add TX packets size check
3,Fix scan get rssi error
4,Add wifi stop check at WiFi deinit entry
5,coex adjust scheme when bt is connected status
6,Return fail when setting AP's channel is out of range
7,Fix the bug for setting channel when WiFi in NULL mode
2020-03-24 15:10:31 +08:00
921e56d0c3 Merge branch 'feature/upgrade_mbedtls_to_v4.0' into 'release/v4.0'
mbedtls: upgrade to release v2.16.5 (v4.0)

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

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

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

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

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

See merge request espressif/esp-idf!7153
2020-03-20 14:33:53 +08:00
e1d78a218a bugfix for TCPv6 send ok when sta disconnect 2020-03-19 14:06:40 +08:00
13e3e26065 mbedtls: upgrade to release v2.16.5
For detailed release notes please refer to:
https://tls.mbed.org/tech-updates/releases/mbedtls-2.16.5-and-2.7.14-released

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

Solution:
Initialize mbedtls_ctr_drbg_context in crypto_ec_point_mul.
2020-03-18 11:49:23 +00:00
402e97ea51 esp_https_ota.c: Add errno check for WiFi disconnection while performing OTA 2020-03-18 08:19:56 +00:00
0bdd75a344 OTA: Add fix in case of URL redirection and a test case of URL redirection
Closes https://github.com/espressif/esp-idf/issues/4780
2020-03-18 08:19:56 +00:00
662b39fc1e OTA: Fixed OTA with chunked servers and added example_test with chunked server 2020-03-18 08:19:56 +00:00
8785ac4c2a Bugfix for failing OTA example
example_test.py is added to test advanced_https_ota_example and native ota_example.

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

bootloader_support is added in public requirements of CMake

bootloader_common.h is included in esp_https_ota.h

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

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

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

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

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

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

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

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

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

See merge request espressif/esp-idf!7777
2020-03-17 13:44:23 +08:00
5f7436006f NimBLE: Add Host based privacy (RPA) feature support (v4.0)
- This feature removes dependency on controller to use privacy (RPA)
2020-03-16 07:33:07 +00:00
6ee1947822 NimBLE: Fix check for static random address & add MSYS_1 in menuconfig (v4.0)
Closes BT-290 & BT-440
2020-03-16 07:33:07 +00:00
3aaf6a06dd NimBLE: Use dynamic buffers instead of static memory (v4.0)
The NimBLE host buffers that consume a significant amount of memory are
now allocated dynamically.
The advantage is that, the memory can be reclaimed in cases where BLE
is turned off and not required for the current boot cycle
2020-03-16 07:33:07 +00:00
3ee6dfa4d6 NimBLE: Misc changes in host flow control, ble_gap_unpair, ble_hs_hci_rx_evt & example (v4.0)
- Add menuconfig option for NimBLE host flow control
- Include changes in `blecent` example from upstream PR!702
- add ble_hs_lock in ble_gap_unpair Upstream PR!584
- ble_hs_hci_rx_evt, upstream PR!738

Closes https://github.com/espressif/esp-idf/issues/4243
2020-03-16 07:33:07 +00:00
b6415d9a91 Remove (x2) variable in BCM_STRNCPY_S and BCM_STRCPY_S when performance optimization enabled 2020-03-14 14:45:57 +08:00
ce55956a8f Fix mem_start uninitialized error when compiler optimization performance enabled 2020-03-14 14:45:04 +08:00
7c2f1287ec Bugfix for HFP and some Github issue.
1. Bugfix for AG audio crash (change the return position)
2. Fix the error macro name and error return in hfp_hf demo
3. Fix the annotation error using UTF-8 ' (from Github)
4. Change or remove the log in SCO related code region.
5. Correct error of introduction of a function.
2020-03-14 14:19:54 +08:00
lly
eee8bd4612 ble_mesh: Move dev_role to the end of model_pub 2020-03-13 19:27:55 +08:00
lly
4dde86e45d ble_mesh: Use the right netkey during iv update 2020-03-13 19:27:54 +08:00
lly
e6b4eb60ef ble_mesh: Use the right net_idx & app_idx for publish 2020-03-13 19:27:54 +08:00
lly
c5b2f693b8 ble_mesh: Check buf->ref before unref the buffer 2020-03-13 19:27:54 +08:00
lly
7cf29e0f3f ble_mesh: Fix mesh memory use-after-free issue 2020-03-13 19:27:54 +08:00
lly
cb31c71877 ble_mesh: Add ble mesh deinit in btc task 2020-03-13 19:27:54 +08:00
lly
50040e8e99 ble_mesh: Free beacon timer when deinit mesh 2020-03-13 19:27:53 +08:00
lly
a364541193 ble_mesh: Use lock for mesh timer operations 2020-03-13 19:27:53 +08:00
fdbdf9a0ec Merge branch 'bugfix/unicore_config_prevent_ipc_code_v4.0' into 'release/v4.0'
ipc: prevent code getting pulled in for unicore configuration (v4.0)

See merge request espressif/esp-idf!7943
2020-03-12 13:31:44 +08:00
0ad0507f88 ci: add find job id argument job status:
if we retry failed job, we will have 2 jobs with same name in one pipeline. we need to use status to find the retried job instead of failed job.
2020-03-12 09:59:31 +08:00
40bebcb39b Merge branch 'bugfix/select_waiting_assert_for_v4.0' into 'release/v4.0'
lw-ip:fix bug for after udp close select_waiting assert for v4.0

See merge request espressif/esp-idf!7921
2020-03-11 21:11:23 +08:00
1c12e67c8a lwip: Add to sys_arch_protect() a check that the mutex is created before use if not then creates it
Closes: https://github.com/espressif/esp-idf/issues/944
Closes: https://github.com/espressif/esp-idf/issues/3931
Closes: WIFI-1019
2020-03-11 19:18:09 +08:00
cf77068675 fix bug for after udp close select_waiting assert for v4.0 2020-03-11 10:04:32 +00:00
68b4177f70 Merge branch 'bugfix/ledc_driver_enums_v4.0' into 'release/v4.0'
driver: Avoid possible accidental mismatch between ledc_clk_src_t & ledc_clk_cfg_t enum (v4.0)

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

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

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

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

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

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

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

Noticed when looking into https://github.com/espressif/esp-idf/issues/4476
2020-03-09 11:32:18 +11:00
c38c3ff3f0 spi_flash: Remove 16KB free internal heap limit for esp_flash_read() into PSRAM
Allocation of the temporary internal buffer will now repeat until a small enough buffer can be
allocated, and only fail if less than a 256 byte block of internal RAM is free.

Adds unit test for the same, and generic test utility for creating memory pressure.
2020-03-09 09:59:43 +11:00
376703bf05 Merge branch 'bugfix/cmake_convert_whitespace_v4.0' into 'release/v4.0'
cmake: Minor convert_to_cmake.py fixes (v4.0)

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

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

See merge request espressif/esp-idf!7866
2020-03-05 20:37:51 +08:00
af4c6ac0f3 spi_flash: Fix over-allocation and OOM crash when reading from SPI flash to PSRAM buffers
Previously would try allocate buffer of minimum size 16KB not maximum size 16KB, causing
out of memory errors for any large reads, or if less than 16KB contiguous free heap.

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

Added test for using large buffers in PSRAM.

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

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

split() with no arg will match any whitespace sequence not just
a single space, so takes care of case where two spaces are
inserted in the variable value.
2020-03-05 17:06:38 +11:00
abab19ad4d This MR is intended to fix Bluetooth event scheduling when WiFi is also
enabled. The global interrupts will be disabled before taking current
    time for scheduling further bluetooth events. Earlier disabling
    interrupts was taking some time because of which WiFi events were
    interrupting in current bluetooth scheduling.

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

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

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

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

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

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

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

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

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

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

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

Added local example test for long messages.

Closes IDF-1083
2020-02-28 10:53:08 +08:00
1351e94a0e fix ipv6 bug when input the wrong broadcast for v4.0 2020-02-27 17:15:09 +08:00
lly
6eaeda9cf4 ble_mesh: Calc incomplete timeout based on msg info 2020-02-27 14:42:25 +08:00
lly
f2e5ee5d25 ble_mesh: Start the timer when starting to send the client message 2020-02-27 14:42:25 +08:00
lly
4a3b06dde3 ble_mesh: No timeout for client message to non-unicast address 2020-02-27 14:42:25 +08:00
lly
ef7461ae1d ble_mesh: Unify client application and lower transport layer timeout 2020-02-27 14:42:25 +08:00
lly
bfed4fc90c ble_mesh: Allow maximum 377 octets payload 2020-02-27 14:42:25 +08:00
lly
6d61f6667a ble_mesh: Reset transport info when node is removed 2020-02-27 14:42:25 +08:00
lly
41cef4b1bb ble_mesh: Provisioner ignores msg from removed node 2020-02-27 14:42:25 +08:00
lly
e24641cc89 ble_mesh: Miscellaneous modifications
1. Add an API to set Provisioner static oob value
2. Add an API to deinit BLE Mesh stack
3. Add an API to set Provisioner unicast address
4. Add an API to provision devices with fixed address
5. Add an API to store node composition data
6. Add an API to get node with device uuid
7. Add an API to get node with unicast address
8. Add an API to delete node with device uuid
9. Add an API to delete node with unicast address
10. Add an API for Provisioner to update local AppKey
11. Add an API for Provisioner to update local NetKey
12. Support Provisioner persistent functionality
13. Fix Provisioner entering IV Update procedure
14. Fix an issue which may cause client failing to send msg
15. Use bt_mesh.flags to indicate device role
16. Remove several useless macros
17. Callback RSSI of received mesh provisioning packets
18. Modify the Provisioner disable function
19. Change some log level from debug to info
20. Add parameters to Provisioner bind AppKey completion event
21. Fix node ignoring relay messages issue
22. Support using a specific partition for BLE Mesh
23. Fix compile warning when proxy related macros are disabled
24. Clean up BLE Mesh stack included header files
25. NULL can be input if client message needs no parameters
26. Fix compile warning when BT log is disabled
27. Initilize BLE Mesh stack local variables
28. Support using PSRAM for BLE Mesh mutex, queue and task
29. Add a menuconfig option to enable using memory from PSRAM
30. Clean up sdkconfig.defaults of BLE Mesh examples
2020-02-27 14:42:25 +08:00
280f0effc1 Merge branch 'bugfix/mesh_ie_issues_4.0' into 'release/v4.0'
Bugfix/mesh ie issues (Backport 4.0)

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

See merge request espressif/esp-idf!7783
2020-02-26 20:35:27 +08:00
2236449f47 component/bt: set non-zero initial value for bt sleep clock cycle to avoid div-by-zero error in function "btdm_us_2_lpcycles" when BT modem sleep is not enabled 2020-02-26 16:19:43 +08:00
2a4173e9a6 Docs: Encourage to used Python 3 2020-02-26 09:01:42 +01:00
e2cba84555 Merge branch 'bugfix/add_missing_ledc_set_pin_declaration_v4.0' into 'release/v4.0'
Bugfix: Add missing ledc_set_pin declaration in led.h (v4.0)

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

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

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

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

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

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

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

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

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

Delaying the connection calls helps mitigate the issue.

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

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

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

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

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

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

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

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

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

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

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

See merge request espressif/esp-idf!7584
2020-02-18 20:44:41 +08:00
6f875f2db2 Unified Provisioning - BLE: Fix characteristics read response issue
Fix the issue when number of bytes to be read is an exact multiple of [MTU-1]
2020-02-18 15:09:30 +05:30
6b6d9d7321 confgen.py: Escape special characters for cmake
Closes https://github.com/espressif/esp-idf/issues/4751
2020-02-18 09:55:53 +01:00
477e6355eb Merge branch 'bugfix/legacy_msys2_environment_update_v4.0' into 'release/v4.0'
doc: Update the MSYS2 legacy toolchain zip to same as master branch (v4.0)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

See merge request espressif/esp-idf!7551
2020-02-12 16:54:03 +08:00
7ccf6ebada idf_tools.py: fix install-python-env failure with virtualenv 20.0.0
--no-site-packages is the default behavior since virtualenv 1.7
(released in Nov 2011). This option was removed in virtualenv 20.0.
2020-02-11 09:46:03 +01:00
91dc4d78f8 Merge branch 'bugfix/select_driver_not_installed_v4.0' into 'release/v4.0'
VFS: Check in select() if the UART driver is installed or not (v4.0)

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

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

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

See merge request espressif/esp-idf!7546
2020-02-11 11:57:32 +08:00
f368f69922 idf_tools.py: fix downloading for tools which have "on_request" options for some platforms.
'install' and 'download' options can be used for 'required' or 'all' tools
2020-02-10 20:10:26 +01:00
8df70a1728 cJSON: include only source file objects for cmake build
Test file can cause build issues in some cases, since it has its own main() function
2020-02-10 17:32:26 +05:30
c5d20275dd ci: remove using IDF_XTENSA_TOOLCHAIN_URL because there are idf_tools.json and multi-target support 2020-02-10 18:38:23 +07:00
f2ef0509e3 ci: Use ARTIFACT_DOWNLOAD_ATTEMPTS and others from the project settings 2020-02-10 18:35:12 +07:00
8c88f0f1f6 Fix subtype in PartitionTable.find_by_type
Fix ptype->subtype

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

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

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

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

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

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

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

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

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

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

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

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

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

See merge request espressif/esp-idf!7463
2020-01-30 13:36:52 +08:00
02596a7efa tools: work around usbser.sys bug in idf_monitor
implemented workaround in idf_monitor for known usbser.sys bug which
causes changes in RTS signal to only be sent if DTR signal also changes.
Works by forcing a dummy change in DTR signal (re-assigning its current
value, as it has previously been done in the flashing tool)

Closes https://github.com/espressif/esp-idf/pull/4676
2020-01-29 10:36:43 +01:00
a61fd1e42b Merge branch 'bugfix/esp_timer_stucks_into_esp_timer_impl_set_alarm_v4.0' into 'release/v4.0'
esp_timer/esp32: Fix esp_timer_impl_set_alarm() when CPU and APB freqs are changed (v4.0)

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

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

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

Found while looking into https://github.com/espressif/esp-idf/issues/4474
2020-01-29 09:40:22 +11:00
9a24d95907 esp_timer/esp32: Fix case when alarm_reg > counter_reg but FRC_TIMER_INT_STATUS is not set
Closes: WIFI-1576
Closes: https://github.com/espressif/esp-idf/issues/2954
2020-01-28 21:41:27 +08:00
ead0e6da36 idf.py: add monitor-baud option to monitor command 2020-01-27 18:54:37 +01:00
08219f3cf5 Merge branch 'bugfix/esp_tls_blocking_timeout_v4.0' into 'release/v4.0'
esp-tls: add timeout for blocking connection (v4.0)

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

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

See merge request espressif/esp-idf!7365
2020-01-21 17:58:46 +08:00
642dc19c25 VFS: Check in select() if the UART driver is installed or not
Closes https://github.com/espressif/esp-idf/issues/4627
2020-01-21 10:11:08 +01:00
55834dd001 Merge branch 'bugfix/wa_dport_and_intr_v4.0' into 'release/v4.0'
esp32: Fix for DPORT (v4.0)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Removed  unused event data struct.

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

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

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

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

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

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

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

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

* Closes IDFGH-2432

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

* fix i2s adc data inv issue

* Closes IDFGH-2444

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

This commit:

1. Cancel the dummy phase

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

This commit split the unit test into two parts:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

9c5284e7b verify that IDF_PATH doesn't contain spaces

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

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

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

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

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

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

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

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

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

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

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

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

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

See merge request espressif/esp-idf!6254
2019-10-09 23:50:05 +08:00
34a327791c idf_monitor: Exit with CTRL+X in menu
Currently, the only way of exiting the idf_monitor program is to hit the CTRL+] button, if your keyboard doesn't have that key unless you hit another modifier key, it's not super trivial to exit.

This change adds the option to exit with CTRL+T (for menu) then hitting X (or CTRL+X) for exiting.

Closes https://github.com/espressif/esp-idf/pull/4167
Closes https://github.com/espressif/esp-idf/issues/4129
2019-10-09 10:27:50 +02:00
8bcf5a19d5 Merge branch 'bugfix/esp_tls_add_header_in_esp_tls_h_v4.0' into 'release/v4.0'
ESP32/esp_tls: include esp_err.h in esp_tls.h (v4.0)

See merge request espressif/esp-idf!6264
2019-10-09 13:31:38 +08:00
lly
66a46de2a7 ble_mesh: fix not restoring ble mesh cfg value 2019-10-08 16:37:20 +08:00
bcd496be49 bootloader: shrink bin size
1. write a bootloader version of "getting chip revision" function.
2. reduce wordy log.
2019-10-08 02:45:36 +00:00
79923d0199 Add chip revision into image header
Check chip id and chip revision before boot app image

Closes https://github.com/espressif/esp-idf/issues/4000
2019-10-08 02:45:36 +00:00
858b3d2277 ESP32/esp-tls: include esp_err.h in esp_tls.h
Closes https://github.com/espressif/esp-idf/issues/4100
2019-10-07 17:47:51 +05:30
dedaf624db Handle deprecated values in sdkconfig.defaults
The issue was pointed out also in
https://github.com/espressif/esp-idf/issues/4092
2019-10-03 10:13:42 +02:00
9ca33a260f idf.py: Fix PropertyDict implementation 2019-10-01 17:49:51 +02:00
abdf12dc9e Merge branch 'bugfix/coex_fix_some_bugs_v4.0' into 'release/v4.0'
Coexist: fix some coexist bugs(backport v4.0)

See merge request espressif/esp-idf!6088
2019-09-30 17:01:32 +08:00
10d26549fa Coexist: fix some coexist bugs
1. Fix high beacon and broadcast packets loss ratio of WiFi to
   make MDNS test pass.
2. Improve stability of WiFi performance with a little sacrifice
   of throughput.
3. Improve BLE advertising and connection performance with
   dynamic priority. It sacrifices a little WiFi throughput, but
   achieves balance between WiFi and Bluetooth.
2019-09-30 11:42:05 +08:00
26676c2b8f Merge branch 'bugfix/fix_wifi_stop_leads_to_watchdog_v4.0' into 'release/v4.0'
Fixed the bug that WiFi stop leads to task watchdog (backport v4.0)

See merge request espressif/esp-idf!6228
2019-09-30 11:00:53 +08:00
d9cfb05eb6 esp_wifi:
1. Fixed smartconfig ipc crash
2. Fix the WiFi init sequence bug
3. Fixed the bug that WiFi stop leads to task watchdog
4. Put g_promis_buf to IRAM
2019-09-29 11:38:11 +08:00
4322e89006 Merge branch 'bugfix/ble_mesh_client_invalid_addr_access_4.0' into 'release/v4.0'
ble_mesh: fix client model invalid address access (v4.0)

See merge request espressif/esp-idf!6218
2019-09-29 10:24:04 +08:00
96748f3037 Merge branch 'refactor/update_spi_ethernet_api_v4.0' into 'release/v4.0'
update spi ethernet api (v4.0)

See merge request espressif/esp-idf!6177
2019-09-27 19:43:15 +08:00
lly
5a94142481 ble_mesh: fix client model invalid address access 2019-09-27 15:28:10 +08:00
e5ff431b35 Merge branch 'fix/esp_flash_coredump_4.0' into 'release/v4.0'
esp_flash: fix coredump issues (backport v4.0)

See merge request espressif/esp-idf!6136
2019-09-26 21:26:53 +08:00
c225801b3e Merge branch 'fix/add_parentheses_to_spi_swap_data_tx_4.0' into 'release/v4.0'
spi: Put argument of macro SPI_SWAP_DATA_TX in parentheses (backport v4.0)

See merge request espressif/esp-idf!6107
2019-09-26 21:25:20 +08:00
610e3cac31 Merge branch 'bugfix/gnu_make_windows_paths_v4.0' into 'release/v4.0'
build: In GNU Make, use "cygpath -m" to avoid backslashes (v4.0)

See merge request espressif/esp-idf!6155
2019-09-26 21:24:48 +08:00
c776991233 Merge branch 'bugfix/kconfig_corrections_v4.0' into 'release/v4.0'
Fix Kconfig issues discovered by upstream Kconfiglib (v4.0)

See merge request espressif/esp-idf!6195
2019-09-25 16:26:40 +08:00
041fcceddf Merge branch 'feat/esp_flash_support_encrypt_4.0' into 'release/v4.0'
esp_flash: add support for encrypted read and write (backport v4.0)

See merge request espressif/esp-idf!6106
2019-09-25 16:17:31 +08:00
899957f521 Merge branch 'feature/cmake_check_mconf_version_v4.0' into 'release/v4.0'
cmake: check mconf-idf binary version (backport v4.0)

See merge request espressif/esp-idf!6067
2019-09-25 16:15:26 +08:00
815d7674ef Merge branch 'bugfix/openocd_instructions_v4.0' into 'release/v4.0'
docs: jtag-debugging: update for IDF Tools installation method (backport v4.0)

See merge request espressif/esp-idf!6066
2019-09-25 16:15:07 +08:00
57527ba6f9 Merge branch 'doc/build_system_requirements_v4.0' into 'release/v4.0'
docs: Explain build system REQUIRES & PRIV_REQUIRES in more detail (v4.0)

See merge request espressif/esp-idf!6054
2019-09-25 16:13:48 +08:00
a21eb04cc6 Merge branch 'bugfix/btdm_a2dp_sink_media_suspend_cmd_unack_for_v4.0' into 'release/v4.0'
bugfix/btdm_a2dp_sink_media_suspend_cmd_unack_for_v4.0(backport v4.0)

See merge request espressif/esp-idf!5940
2019-09-25 16:12:43 +08:00
116d0c8145 Merge branch 'bugfix/ble_mesh_queue_task_init_check_v4.0' into 'release/v4.0'
ble_mesh: check ble mesh queue and task init status (v4.0)

See merge request espressif/esp-idf!6193
2019-09-25 15:08:23 +08:00
dda49709fe ethernet: update spi-ethernet api 2019-09-25 06:34:39 +00:00
ebffa5f9f2 ethernet: test apps can build with ethernet disabled 2019-09-25 06:34:39 +00:00
fc738680f8 Fix Kconfig issues discovered by upstream Kconfiglib 2019-09-25 08:25:51 +02:00
1c586ebcfd Merge branch 'feature/bluedroid_min_encr_key_size_backport_v4.0' into 'release/v4.0'
BT/Bluedroid: Add support to set min encryption key size requirement (backport v4.0)

See merge request espressif/esp-idf!6180
2019-09-25 11:57:22 +08:00
499accb652 BT/Bluedroid: Add support to set min encryption key size requirement (backport)
- Backport of IDF MR!6122.
- Modifies `smp_utils.c` to add check on encryption key size received from
  peer.
- Modifies `esp_ble_gap_set_security_param` API to add minimum encryption key
  size requirement.
2019-09-25 11:57:21 +08:00
988147a451 Merge branch 'bugfix/btdm_loop_in_feature_req_ext_v4.0' into 'release/v4.0'
components/bt: Fix sending LMP_features_req_ext in a loop

See merge request espressif/esp-idf!6023
2019-09-25 11:52:10 +08:00
lly
9e6c56f9f2 ble_mesh: check ble mesh queue and task init status 2019-09-25 11:03:18 +08:00
1b6eb69f53 Merge branch 'NimBLE/mbedTLS_option_for_tinycrypty_v4.0' into 'release/v4.0'
NimBLE: Add optional mbedTLS support to NimBLE (backport)

See merge request espressif/esp-idf!6146
2019-09-23 21:37:40 +08:00
daa65b6f91 NimBLE: Add optional mbedTLS support to NimBLE (backport)
- NimBLE: Additional menuconfig option to enable mbedTLS instead of Tinycrypt from
  NimBLE, changes `component.mk` & `CMakeLists.txt` for the same.
- Addition of NimBLE stack size configuration and misc changes.
- mbedTLS: Addition of `CMAC` and `ECP_RESTARTABLE` to mbedTLS menuconfig option and
  `esp_config.h`.
- Example: Minor changes to `app_mesh.c` application.
2019-09-23 21:37:40 +08:00
7f9626d378 Merge branch 'cleanup/make_supp_headers_private_v4.0' into 'release/v4.0'
wpa_supplicant: Make internal crypto headers private (backport v4.0)

See merge request espressif/esp-idf!6061
2019-09-23 18:00:43 +08:00
6cad60f34b bugfix that call of esp_a2d_media_ctrl(ESP_A2D_MEDIA_CTRL_SUSPEND) will not get an ACK from callback on A2DP sink 2019-09-23 03:22:34 +00:00
b4c7ed999c Merge branch 'bugfix/remove_v40_deprecations_v4.0' into 'release/v4.0'
Remove features deprecated before ESP-IDF V4.0 (v4.0)

See merge request espressif/esp-idf!6150
2019-09-20 19:51:51 +08:00
8a5c08df98 Merge branch 'bugfix/fix_the_for_smartconfig_send_broadcast_to_phone_v4.0' into 'release/v4.0'
fix the bug that ESP32 sends broadcast to phone after smartconfig is done (backport v4.0)

See merge request espressif/esp-idf!6072
2019-09-20 14:02:19 +08:00
b1eac64865 build: In GNU Make, use "cygpath -m" to avoid backslashes
Fixes issues where backslashes in KCONFIG paths are later expanded as shell escape sequences.
2019-09-19 21:33:56 +10:00
4e7b559101 Delete extra '/' 2019-09-19 19:22:44 +08:00
43616f6f05 esp_wifi: Update wifi lib 2019-09-19 17:49:18 +08:00
3b9ab9caa6 idf_test: Disable tests for Wi-Fi auto reconnect
Disable one, remove IDF tag from the other
2019-09-19 18:49:37 +10:00
0dc9ddb77c Wi-Fi: remove wifi_fast_scan_threshold_t which is not suitable in name 2019-09-19 18:49:37 +10:00
9ab92331c4 dport: remove clock_en and reset bitname which is not suitable 2019-09-19 18:49:37 +10:00
08416d05ba soc: Remove deprecated LEDC struct register names (bit_num, div_num)
Deprecated since ESP-IDF V3.0
2019-09-19 18:49:37 +10:00
200c82561a soc: remove deprecated io_mux PIN_PULLxxx_yyy macros
Deprecated before ESP-IDF V1.0!
2019-09-19 18:49:37 +10:00
2e05c6020f mbedtls: Remove esp_aes_encrypt/decrypt
Deprecated in ESP-IDF V3.1

Anyone reading this should please include mbedtls/aes.h and use mbedTLS APIs,
not the ESP-specific APIs.
2019-09-19 18:49:37 +10:00
d139c851f3 heap: Remove esp_heap_alloc_caps header
Deprecated in ESP-IDF V3.1
2019-09-19 18:49:37 +10:00
365e3fd685 fatfs: Remove esp_vfs_fat_unregister()
Deprecated in ESP-IDF V2.0
2019-09-19 18:49:37 +10:00
71fad5e2c0 esp_wifi: Remove WIFI_PS_MODEM constant
Deprecated in ESP-IDF V3.1
2019-09-19 18:48:55 +10:00
94ba3a20cb esp_wifi: Remove deprecated auto connect API
Deprecated in ESP-IDF V3.1
2019-09-19 18:48:55 +10:00
5a7d3ef319 ringbuf: Remove deprecated RingbufferType_t
Deprecated in ESP-IDF V3.1
2019-09-19 18:48:55 +10:00
e4a4e6ed81 wdt: Remove deprecated esp_task_wdt_feed() function
Deprecated in ESP-IDF V3.1
2019-09-19 18:48:55 +10:00
8094e880c6 esp32/esp_common: Remove deprecated esp_efuse_read_mac() function
Deprecated since ESP-IDF V2.0
2019-09-19 18:48:30 +10:00
35b9223cf4 esp32/esp_common: Remove deprecated system_* APIs
Mostly deprecated before ESP-IDF V1.0 & V2.0
2019-09-19 18:48:30 +10:00
fe97d14e0f esp_adc_cal: Remove deprecated ADC calibration functions
Deprecated since ESP-IDF V3.1
2019-09-19 18:48:14 +10:00
2c16557ee7 esp32: Remove deprecated system_deep_sleep function
Deprecated since ESP-IDF V3.0
2019-09-19 18:48:14 +10:00
5f8e5db268 esp32/test: fix usage of deprecated fields 2019-09-19 18:48:14 +10:00
a9fe3165c4 soc/pm: Remove deprecated use of rtc_cpu_freq_t enum
Removes deprecated ways of setting/getting CPU freq, light sleep freqs.

Deprecated since ESP-IDF V3.2
2019-09-19 18:48:13 +10:00
b01036e13e driver: Remove features deprecated pre-IDF V4.0 2019-09-19 18:47:15 +10:00
10649ae23b app_update: Remove deprecated "make erase_ota" target
Deprecated in v3.2
2019-09-19 18:45:36 +10:00
c4306f7942 bootloader_support: Remove deprecated partition load/verify functions
Deprecated since v3.2
2019-09-19 18:45:36 +10:00
62be877ada bluetooth: Remove bt.h header (deprecated in v3.1-dev) 2019-09-19 18:45:36 +10:00
546026d018 make psram workaround depend on chip revison
Since ESP32 revision 3, the PSRAM workaround is not needed.
2019-09-19 13:50:53 +08:00
05d3665a14 Merge branch 'bugfix/ble_mesh_get_timer_remaining_time_v4.0' into 'release/v4.0'
ble_mesh: fix ble mesh get timer remaining time (v4.0)

See merge request espressif/esp-idf!6059
2019-09-18 16:38:31 +08:00
0bba92b2a0 esp_flash: put adapter to legacy functions into IRAM to be back-compatible 2019-09-18 15:16:00 +08:00
399477cd10 coredump: use esp_flash api in coredump
Also put esp_flash functions into noflash region, when
ESP32_PANIC_HANDLER_IRAM and coredump are enabled. The option disables
the re-enabling of the CPU-cache when it's disabled during coredump.
This requires all the coredump functions including the flash API to be
in the D/IRAM.
2019-09-18 15:14:53 +08:00
d3b54ec84a esp_flash: fix the coredump issue
During coredump, dangerous-area-checking should be disabled, and cache
disabling should be replaced by a safer version.

Dangerous-area-checking used to be in the HAL, but it seems to be more
fit to os functions. So it's moved to os functions. Interfaces are
provided to switch between os functions during coredump.
2019-09-18 14:30:23 +08:00
e4b44f3488 esp_flash: fix coredump for legacy spi flash API
When legacy mode is used, the coredump still fails during linking
because "esp_flash_init_default_chip", "esp_flash_app_init" and
"esp_flash_default_chip " are not compiled and linked.

Instead of using ``if`` macros in callers, these functions are protected
by ``if`` macros in the header, and also not compiled in the sources.
"esp_flash_default_chip" variable is compiled with safe default value.
2019-09-18 14:28:12 +08:00
ca80b0445d wpa_supplicant: Make internal crypto headers private (backport v4.0)
A lot of internally used crypto headers are publicly includeable
in user projects. This leads to bug reports when these headers
are incorrectly used or the API's are not used as intended.

Move all crypto headers into private crypto src folder, also move
crypto_ops into Supplicant to remove dependecy on crypto headers.

Closes IDF-476
2019-09-17 13:28:30 +00:00
lly
1e01accaa4 ble_mesh: fix duplicate memory free during receiving status message 2019-09-16 17:30:03 +08:00
2ca3735edd spi: Put argument of macro SPI_SWAP_DATA_TX/RX in parentheses
Close https://github.com/espressif/esp-idf/pull/3996
2019-09-16 17:17:42 +08:00
b9a2639ab4 esp_flash: add support for encrypted read and write
Using legacy implementation.
2019-09-16 17:10:08 +08:00
lly
77f186a7b9 ble_mesh: make unicast elem lookup O(1) 2019-09-16 15:06:52 +08:00
lly
89e848c820 ble_mesh: use adv report flow control for ble mesh 2019-09-16 14:44:34 +08:00
5e0cc123ee Merge branch 'bugfix/cmake_sdkconfig_path' into 'release/v4.0'
fix bug for cmake build system

See merge request espressif/esp-idf!6102
2019-09-16 14:20:38 +08:00
536c131114 fix bug for cmake build system
The path of ${SDKCONFIG_H} does not exist, should be replaced by ${sdkconfig_header}.
2019-09-16 11:18:04 +08:00
ef17d8bba1 Merge branch 'bugfix/httpd_sess_close_v4.0' into 'release/v4.0'
httpd_sess_close: Check for session validity before closing (v4.0)

See merge request espressif/esp-idf!5742
2019-09-16 08:21:37 +08:00
3194e12479 Merge branch 'bugfix/uart_select_free_v4.0' into 'release/v4.0'
VFS: Fix memory access after free() in UART select() (v4.0)

See merge request espressif/esp-idf!6085
2019-09-13 14:49:46 +08:00
bb52613bea Merge branch 'bugfix/use_local_kconfiglib_v4.0' into 'release/v4.0'
Use kconfiglib from $IDF_PATH/tools/kconfig_new (v4.0)

See merge request espressif/esp-idf!6079
2019-09-13 14:47:07 +08:00
4ee065df79 httpd_sess_close: Check for session validity before closing
If httpd_sess_trigger_close() gets called twice for the same socket,
the first httpd_sess_close() cb closes the correct socket, but the second
invocation closes the wrong socket which was just accepted and added to
the socket db. Checking for the lru counter will help identify this as the
counter is set only for requests actually served.
2019-09-12 08:41:31 +00:00
63c2834d7b VFS: Fix memory access after free() in UART select()
Closes https://github.com/espressif/esp-idf/issues/4030
2019-09-12 08:38:31 +02:00
dbf2c3d480 Merge branch 'bugfix/btdm_config_msbc_v4.0' into 'release/v4.0'
components/bt: Disable Wide Bond Speech when SCO data path is PCM

See merge request espressif/esp-idf!5979
2019-09-12 13:23:54 +08:00
582d5de497 Merge branch 'bugfix/coex_bb_reset_lock_v4.0' into 'release/v4.0'
fix some coex bugs

See merge request espressif/esp-idf!6056
2019-09-12 11:04:10 +08:00
5a351af83f Merge branch 'bugfix/flash_encryption_disable_plaintext_v4.0' into 'release/v4.0'
flash encryption: Always disable plaintext reflashes in Release mode (v4.0)

See merge request espressif/esp-idf!6070
2019-09-12 10:40:34 +08:00
a6fc9bf246 Use kconfiglib from $IDF_PATH/tools/kconfig_new 2019-09-11 14:28:39 +02:00
d52b244ae8 Merge branch 'bugfix/openocd_ulp_install_instructions_v4.0' into 'release/v4.0'
docs: ulp: update for IDF Tools installation method (backport v4.0)

See merge request espressif/esp-idf!6065
2019-09-11 16:06:52 +08:00
00e3cb672b Merge branch 'bugfix/flash_encryption_regressions_v4.0' into 'release/v4.0'
fix flash encryption regressions, add tests (backport v4.0)

See merge request espressif/esp-idf!6068
2019-09-11 12:06:02 +08:00
67eb732dbe fix the bug that ESP32 sends broadcast to phone after smartconfig is done 2019-09-11 11:37:29 +08:00
c53a5ee427 Merge branch 'bugfix/http_header_parser_resolution_v4.0' into 'release/v4.0'
(backport v4.0) esp_http_server : Bugfix in parsing of empty header values

See merge request espressif/esp-idf!6041
2019-09-11 10:20:36 +08:00
69241907a5 bootloader: Link RTC clock functions to the iram_loader section
As flash encryption & secure boot needs these functions after the app is loaded.

Fixes regression introduced in fb72a6f629
2019-09-11 10:16:43 +10:00
d4ee21bd6d docs: Small cleanup of flash encryption docs 2019-09-11 10:16:43 +10:00
5b69614e32 flash encryption: Ensure flash encryption can't be disabled if Secure Boot is on 2019-09-11 10:16:43 +10:00
3e12967535 bootloader: add definition of esp_clk_apb_freq
Commit 8cd04c80 has added a dependency of efuse component on
esp_clk_apb_freq, however there was no definition of this function in
the bootloader context.

Reported at https://esp32.com/viewtopic.php?f=13&t=12035
2019-09-11 10:16:43 +10:00
d9f1219a21 efuse: set timing configuration before writing 2019-09-11 10:16:43 +10:00
f3fc4916d2 ci: add jobs for flash encryption tests 2019-09-10 17:20:19 +02:00
b17ca9cb38 unit-test-app: add config with flash encryption enabled 2019-09-10 17:20:19 +02:00
801010dac6 spi_flash: fix mmap unit tests for flash encryption 2019-09-10 17:20:19 +02:00
f84394e550 examples/flash_encryption: refactor, add test
1. Clean up the example code
2. Add demonstration of partition read/write operations
3. Add example test
2019-09-10 17:19:44 +02:00
a0256b9e9d flash encryption: add option to require flash encryption to be enabled
In testing environment, to avoid accidentally enabling flash
encryption on a device, CONFIG_SECURE_FLASH_REQUIRE_ALREADY_ENABLED
can be set. If set, the bootloader will refuse to boot if flash
encryption is not enabled, instead of enabling it.
2019-09-10 17:19:08 +02:00
a37694741c tiny-test-fw: support testing apps with flash encryption
If CONFIG_SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT is set, pass
--encrypted flag to esptool.py.
2019-09-10 17:18:51 +02:00
fae124a2c1 esp32: cpu_start: read binary image header via cache
When flash encryption is enabled, reading via cache also decrypts the
data, whereas spi_flash_read does not.

Closes https://github.com/espressif/esp-idf/issues/3907
2019-09-10 17:18:51 +02:00
ad100e497a spi_flash: remove duplicate definition of spi_flash_unlock
The other (static) definition is in flash_ops.c, all references are
also in flash_ops.c.
2019-09-10 17:18:51 +02:00
da8c09c463 cmake: check mconf-idf binary version
Print a warning if an outdated version of mconf-idf is found in
the PATH.
2019-09-10 17:15:15 +02:00
6df148aa54 docs: jtag-debugging: update translation 2019-09-10 17:12:48 +02:00
3fc9b022b6 docs: jtag-debugging: update for IDF Tools installation method
- rely on OPENOCD_SCRIPTS variable in all cases, remove -s flags
- replace installation section with a reference to the Getting Started
  guides
- add Windows-specific commands in a few cases
2019-09-10 17:12:48 +02:00
28ee1c0da2 doc: update translation of ulp install instuctions 2019-09-10 17:10:17 +02:00
05b306bae1 docs: ulp: update for IDF Tools installation method
binutils-esp32ulp is installed automatically by install.sh/install.bat
or the IDF Tools Installer for Windows.
2019-09-10 17:10:17 +02:00
lly
8dbb2083ea ble_mesh: fix ble mesh get timer remaining time 2019-09-10 17:01:03 +08:00
a8590c7e8e fix some coex bugs
1. fix the bug that bb reset lock unhandled may cause assert in vPortCPUReleaseMutexIntsDisabledInternal
2. fix wifi mac reset may blocking then cause wdt timeout
3. fix bug wifi mac reset before coex init
2019-09-10 15:58:42 +08:00
8876cda09b esp_http_server : Bugfix in parsing of empty header values
This MR is intended to fix incorrect parsing of HTTP requests when empty header values are present.

The issue is was due to asymmetric behavior of `http_parser` library, which in case of:

    non-empty header values : invokes callbacks with the pointer to the start of a value
    empty header values : invokes callbacks with pointer to the start of next header or section

Since HTTP server relies on this pointer (along with length of the value) to locate the end of a value, and replace the line terminators (CRLFs) with null characters, the second case needed to be handled correctly.

Closes IDFGH-1539

Closes https://github.com/espressif/esp-idf/issues/3803
2019-09-10 05:58:49 +00:00
cec1c5f856 docs: Explain build system REQUIRES & PRIV_REQUIRES in more detail
Including an example.
2019-09-10 15:10:30 +10:00
a7107d9bbd Merge branch 'bugfix/ble_mesh_related_bugfixes_v4.0' into 'release/v4.0'
Bugfix/ble mesh related bugfixes v4.0

See merge request espressif/esp-idf!6042
2019-09-10 09:48:36 +08:00
850684438b Merge branch 'bugfix/ethernet_rx_length_check_v4.0' into 'release/v4.0'
ethernet: bugfix and optimize (v4.0)

See merge request espressif/esp-idf!6028
2019-09-10 07:58:46 +08:00
9d00f3b420 Merge branch 'deprecate/spi_common_claim_macros_v4.0' into 'release/v4.0'
spi_common: remove deprecated spi_common_periph_claim macros (backport v4.0)

See merge request espressif/esp-idf!6006
2019-09-10 06:42:32 +08:00
72264ca9b9 spi_common: remove deprecated spi_common_periph_claim macros (backport v4.0) 2019-09-10 06:42:31 +08:00
da2025a74a Merge branch 'bugfix/newlib_time_test_v4.0' into 'release/v4.0'
newlib: Fix UT - test time adjustment happens linearly (v4.0)

See merge request espressif/esp-idf!6014
2019-09-10 06:40:09 +08:00
93bad7a0de Merge branch 'bugfix/bootloader_factory_reset_with_wake_up_from_deep_sleep_v4.0' into 'release/v4.0'
bootloader: Blocking the Factory reset during wake up from deep sleep (v4.0)

See merge request espressif/esp-idf!6020
2019-09-10 06:39:19 +08:00
lly
55f687c763 ble_mesh: update ble mesh examples sdkconfig.defaults 2019-09-09 18:10:52 +08:00
lly
329388fa47 ble_mesh: fix ble mesh btc may caused memory leak 2019-09-09 18:10:47 +08:00
lly
0f36dabcaf ble_mesh: fix publication period timestamp initialization 2019-09-09 18:10:42 +08:00
lly
0299e22dd0 ble_mesh: remove useless mesh_opcode 2019-09-09 18:10:34 +08:00
lly
f072c5af4e ble_mesh: fix bt_mesh_net_resend() caused compiling error 2019-09-09 17:47:56 +08:00
lly
6982663380 ble_mesh: fix adhering to the configured Friend Queue size 2019-09-09 17:47:47 +08:00
lly
1d970ad276 ble_mesh: remove useless code bt_mesh_trans_resend() 2019-09-09 17:47:30 +08:00
lly
a73cc70af9 ble_mesh: lpn remove msg from cache on rejection 2019-09-09 17:47:24 +08:00
lly
225ee8e5d1 ble_mesh: introduce a helper for send callback function 2019-09-09 17:47:18 +08:00
lly
fa4cd56d00 ble_mesh: fix heartbeat sending on friendship established/lost 2019-09-09 17:47:07 +08:00
lly
15f8b0fccc ble_mesh: fix checking for active heartbeat publication 2019-09-09 17:46:49 +08:00
lly
97080afba2 ble_mesh: fix starting iv update when not on primary subnet 2019-09-09 17:46:43 +08:00
lly
612822d8c9 ble_mesh: fix canceling publication retransmit timer 2019-09-09 17:46:35 +08:00
lly
ff6cb921c3 ble_mesh: fix resending segments on correct bearer 2019-09-09 17:46:27 +08:00
lly
6f7b7c552d ble_mesh: fix not sending all segments through the Friend Queue 2019-09-09 17:46:19 +08:00
lly
e00186e683 ble_mesh: fix canceled buffer memory leak 2019-09-09 17:46:06 +08:00
lly
a734b3b1bc ble_mesh: remove some useless copy during ecdh calculation 2019-09-09 17:45:59 +08:00
lly
6de637811f ble_mesh: move heartbeat sending to transport layer 2019-09-09 17:45:52 +08:00
lly
6ec0c6743a ble_mesh: fix provisioning send error handling 2019-09-09 17:45:44 +08:00
lly
299c86cc84 ble_mesh: fix rejecting invalid remote public key 2019-09-09 17:45:27 +08:00
lly
d123f6c04b ble_mesh: add error checks for scan start/stop 2019-09-09 17:45:20 +08:00
lly
3c17bf1a6f ble_mesh: rename reset_link() to reset_adv_link() 2019-09-09 17:45:14 +08:00
lly
8fb20e4529 ble_mesh: fix public key mismatch error handling 2019-09-09 17:45:06 +08:00
lly
e020d1055a ble_mesh: update protocol error timeout from zephyr 2019-09-09 17:44:17 +08:00
lly
05e4b28a74 ble_mesh: fix segmented message RPL behavior 2019-09-09 17:44:11 +08:00
lly
27bc688ed8 ble_mesh: clear LPN sent_req on failure 2019-09-09 17:43:59 +08:00
lly
a214fb2821 ble_mesh: update proxy sar operation from zephyr 2019-09-09 17:43:46 +08:00
lly
6b7b9d1550 ble_mesh: fix postponing storage deadline indefinitely 2019-09-09 17:43:40 +08:00
lly
18b873b2e3 ble_mesh: fix RPL storage timeout handling 2019-09-09 17:43:29 +08:00
lly
d1755c1484 ble_mesh: fix output MIC with additional data 2019-09-09 17:43:23 +08:00
lly
152ebb104d ble_mesh: remove non-standard relay opearation 2019-09-09 17:43:13 +08:00
lly
e3b304997f ble_mesh: fix finding netkey/appkey/devkey for tx/rx msg 2019-09-09 17:43:04 +08:00
lly
1e20ed4849 ble_mesh: fix failed to set device role caused mem leak 2019-09-09 17:42:50 +08:00
lly
59b663c43d ble_mesh: ble mesh btc miscellaneous modifications 2019-09-09 17:42:43 +08:00
lly
e9e28c1265 ble_mesh: fix MESH/NODE/FRND/FN/BV-11-C related bug 2019-09-09 17:42:35 +08:00
lly
7030d612e2 ble_mesh: fix MESH/NODE/CFG/GPXY/BV-02-C & MESH/NODE/CFG/NID/BV-02-C related bug 2019-09-09 17:42:20 +08:00
lly
2c852b0d74 ble_mesh: fix MESH/NODE/CFG/HBS/BV-01-C related bug 2019-09-09 17:42:08 +08:00
lly
708bff3b17 ble_mesh: rename ble mesh client model variables and functions 2019-09-09 17:42:00 +08:00
lly
317f4c5ff5 ble_mesh: reorganize ble mesh model files 2019-09-09 17:41:54 +08:00
lly
2c025824d7 ble_mesh: sync zephyr v1.14.0 bt_hex() 2019-09-09 17:41:41 +08:00
lly
9b95064018 ble_mesh: fix provisioner prov auth bug 2019-09-09 17:41:34 +08:00
ecdffe531e Merge branch 'bugfix/reset_periph_modules_v4.0' into 'release/v4.0'
driver: Add a reset before enabling if a module is off (v4.0)

See merge request espressif/esp-idf!6015
2019-09-08 23:06:31 +08:00
31be6be147 Merge branch 'fix/esp_flash_set_get_wp_4.0' into 'release/v4.0'
esp_flash: fix the set/get write protection functions (backport v4.0)

See merge request espressif/esp-idf!5832
2019-09-08 16:34:40 +08:00
305a4a1b57 ethernet: bugfix and optimize
1. check frame length before pass to stack
2. replace semaphore with task notify
2019-09-06 15:46:18 +08:00
e659f1b15a Merge branch 'bugfix/fix_the_bug_for_WPA_WPA2_PSK_connection_fail_v4.0' into 'release/v4.0'
fix the bug for WPA_WPA2_PSK connection fail(backport v4.0)

See merge request espressif/esp-idf!6010
2019-09-06 14:52:58 +08:00
2c49592216 Merge branch 'refactor/move_smartconfig_ack_to_wifi_v4.0' into 'release/v4.0'
smartconfig: move smartconfig_ack to esp_wifi conponent (v4.0)

See merge request espressif/esp-idf!5999
2019-09-06 14:27:29 +08:00
6afb2743e7 components/bt: Fix sending LMP_features_req_ext in a loop
Remove xtensa/xtruntime.h at the same time
2019-09-06 12:04:16 +08:00
f7b458841f app_update: Fix UTs for FACTORY_RESET and APP_TEST 2019-09-06 11:59:03 +08:00
f1e9b8299f bootloader: Factory reset not for deep sleep
Closes: https://github.com/espressif/esp-idf/issues/3800

Closes: IDFGH-1536
2019-09-06 11:59:03 +08:00
9ce1b8986a rmt/driver: Add module reset before enabling 2019-09-06 11:34:53 +08:00
c5bea8dddb pcnt/driver: Add module reset before enabling 2019-09-06 11:34:53 +08:00
ba6b502cc9 sdmmc_host/driver: Add module reset before enabling 2019-09-06 11:34:53 +08:00
3b0b5f92a7 i2s/driver: Add module reset before enabling 2019-09-06 11:34:53 +08:00
d6bc1b3cbc can/driver: Add module reset before enabling 2019-09-06 11:34:53 +08:00
199c4e55f2 uart/driver: Add module reset before enabling
This commit prevents infinite restarts caused due to an interrupt flag
was left uncleared.

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

Closes: IDF-188
2019-09-06 11:34:53 +08:00
61339353e9 newlib: Fix UT - test time adjustment happens linearly
Obtaining accurate and adjustable time occurs closer to each other.
2019-09-06 11:30:01 +08:00
3b2dda5197 1. fix the bug that STA fails to connect WPA_WPA2_PSK Apple AP
2. fix the bug for softAP set authmode
2019-09-05 20:34:34 +08:00
1b8ed9abf0 Merge branch 'bugfix/btdm_crash_in_sket_ist_v4.0' into 'release/v4.0'
Fix 2 bugs in r_ld_fm_sket_isr

See merge request espressif/esp-idf!5947
2019-09-05 12:02:26 +08:00
f9453ef93d Merge branch 'bugfix/btdm_config_but_task_size_fail_v4.0' into 'release/v4.0'
Bugfix/btdm config but task size fail v4.0

See merge request espressif/esp-idf!5962
2019-09-05 11:26:56 +08:00
dcf571c1cd smartconfig: move smartconfig_ack to esp_wifi conponent 2019-09-05 10:44:00 +08:00
538c56426a Merge branch 'bugfix/err_code_collision_v4.0' into 'release/v4.0'
Fix error code collisions and re-enable CI check (v4.0)

See merge request espressif/esp-idf!5984
2019-09-04 09:10:19 +08:00
1402e78844 Fix error code collision and CI check 2019-09-03 08:07:16 +02:00
01f0c8ef16 components/bt: Rename some macros 2019-09-03 10:28:49 +08:00
a774406b91 Use CONFIG value instead of hard-coded value.
Add intermediate defines.

Use CONFIG_BTU_TASK_STACK_SIZE instead of hard-coded value in Bluedroid component
2019-09-03 10:28:12 +08:00
c9bff93080 Merge branch 'feature/enable_cfg_for_tls_asymmetric_content_length_v4.0' into 'release/v4.0'
mbedtls: keep asymmetric tls buffer length option enabled by default (v4.0)

See merge request espressif/esp-idf!5970
2019-09-02 23:25:06 +08:00
4b8e4ff248 Merge branch 'bugfix/btdm_linking_fail_with_toolchain_8.2.0_v4.0' into 'release/v4.0'
components/bt: Fix linking fail with toolchain 8.2.0

See merge request espressif/esp-idf!5967
2019-09-02 22:22:22 +08:00
9dbf979cf3 Merge branch 'bugfix/btdm_remove_unused_macro_in_menuconfig_v4.0' into 'release/v4.0'
components/bt: Remove unused macro in menuconfig

See merge request espressif/esp-idf!5951
2019-09-02 22:21:12 +08:00
ad70ab8957 components/bt: Disable Wide Bond Speech when SCO data path is PCM 2019-09-02 20:55:17 +08:00
cd5dc4d05f Merge branch 'doc/add_ble_mesh_example_description_v4.0' into 'release/v4.0'
ble_mesh: add ble mesh example description(backport v4.0)

See merge request espressif/esp-idf!5948
2019-09-02 14:29:13 +08:00
ebb9384681 Merge branch 'bugfix/various_cmake_fixes_v4.0' into 'release/v4.0'
CMake: Various backports

See merge request espressif/esp-idf!5933
2019-09-02 12:46:40 +08:00
0d3fde04ff Merge branch 'bugfix_kconfig_deps_missing_v4.0' into 'release/v4.0'
kconfig: Add -MP option so .d files include empty targets (v4.0)

See merge request espressif/esp-idf!5845
2019-09-02 12:43:28 +08:00
0552ec5791 Merge branch 'update/cjson_v1_7_12_v4.0' into 'release/v4.0'
Update cJSON to v1.7.12 (v4.0)

See merge request espressif/esp-idf!5850
2019-09-02 12:41:30 +08:00
524eef9225 Merge branch 'test/use_correct_config_for_nvs_compatible_case_v4.0' into 'release/v4.0'
test: fix nvs compatible case error (backport v4.0)

See merge request espressif/esp-idf!5891
2019-09-02 12:40:46 +08:00
955f7e2877 Merge branch 'test/fix_mesh_test_case_4.0' into 'release/v4.0'
test: fix test case MESH_EST_2403 (backport 4.0)

See merge request espressif/esp-idf!5907
2019-09-02 12:38:51 +08:00
lly
e28834aa15 ble_mesh: add ble mesh example description 2019-09-02 12:17:47 +08:00
ac03786412 Merge branch 'bugfix/wps_workaround_for_Telstra_AP_v4.0' into 'release/v4.0'
wps: Relax the check on older config methods in case of WPS2.0 (backport v4.0)

See merge request espressif/esp-idf!5952
2019-09-02 12:04:49 +08:00
a5dae2ff43 mbedtls: keep asymmetric tls buffer length option enabled by default 2019-08-31 10:24:37 +05:30
1d0142d25d components/bt: Fix linking fail with toolchain 8.2.0 2019-08-30 17:56:01 +08:00
65ef597da6 Merge branch 'bugfix/test_esp_efuse_table_on_host_v4.0' into 'release/v4.0'
CI: Fix path in the Efuse table test (v4.0)

See merge request espressif/esp-idf!5953
2019-08-30 16:27:47 +08:00
310beae373 Merge branch 'bugfix/revert_optimize_wifi_rx_v4.0' into 'release/v4.0'
esp_wifi: revert WiFi RX optimization

See merge request espressif/esp-idf!5941
2019-08-30 10:59:20 +08:00
cf0caaec11 esp_wifi: revert WiFi RX optimization
Revert following commit since it has compatibility issue:
commit 45dd6175cd
esp32: optimize wifi rx
2019-08-29 21:26:42 +08:00
4af9504a65 components/bt: Remove unused macro in menuconfig 2019-08-29 19:58:58 +08:00
64bece146c Fix path in the Efuse table test 2019-08-29 09:50:38 +02:00
6b348b94e3 wps: Relax the check on older config methods in case of WPS2.0 (backport
v4.0)

Some APs incorrectly advertize newer WPS2.0 config method bits
without setting bits for the corresponding older methods. This
results in failures during 8-way handshake. Add a workaround to
relax this check so that WPS handshake can proceed.
2019-08-29 13:05:02 +05:30
6222040888 Fix 2 bugs in r_ld_fm_sket_isr
1. When remove two elt in the 1st isr, then assert in then 2nd one.
2. When timestamp of first elt is equal to sket_clkn, then crash.
2019-08-29 11:31:57 +08:00
ea1037742d Merge branch 'bugfix/confgen_msys_path_v4.0' into 'release/v4.0'
Fix sdkconfig.rename paths for confgen.py in MSYS (v4.0)

See merge request espressif/esp-idf!5904
2019-08-29 10:15:21 +08:00
465d46e9dd Merge branch 'bugfix/cmake_src_exclude_issue_v4.0' into 'release/v4.0'
cmake: fix issue with handling of EXCLUDE_SRCS (v4.0)

See merge request espressif/esp-idf!5900
2019-08-28 14:42:20 +08:00
e71e4da388 cmake: check include directories 2019-08-28 10:28:17 +08:00
c711e969cc components: fix incorrect include dir args 2019-08-28 10:28:17 +08:00
3f1ec39a8d cmake: fix issue with checking build process args 2019-08-28 10:28:17 +08:00
f62798cb8b cmake: make default version 1 2019-08-28 10:28:17 +08:00
b6c89984a9 cmake: fix build failure when git repo is initialized but no first commit
Closes https://github.com/espressif/esp-idf/issues/3920
2019-08-28 10:28:17 +08:00
520ecb0c4d ldgen: fix build issue on make when build dir is a symlink
Fixes an issue where build fails if the build directory is a symlink.
The issue is caused by the rule target and the final executable dependency
not matching.

Closes https://github.com/espressif/esp-idf/issues/3626
2019-08-28 10:28:17 +08:00
b669495d97 Make sure ESP_PLATFORM is defined when processing CMake files. 2019-08-28 10:28:17 +08:00
8778c551eb cmake: set build dir for mconf-idf
Fixes an issue where if idf_build_process is called in a CMake
subdirectory, menuconfig looks for the mconf-idf binary in the wrong
place (in the subdirectory build dir instead of root binary dir).
2019-08-28 10:28:17 +08:00
c34d313a86 mbedtls: add source files to appropriate library 2019-08-28 10:28:17 +08:00
ebcb3a22b8 Merge branch 'bugfix/btdm_fix_ble_data_loss_and_send_same_pkt_twice_v4.0' into 'release/v4.0'
Component/bt: fix some BLE bugs (backport v4.0)

See merge request espressif/esp-idf!5909
2019-08-27 18:49:55 +08:00
6781d01e89 cmake: fix encrypted project flash arg file generation 2019-08-27 13:35:39 +08:00
4c9f30a869 cmake: set component properties 2019-08-27 13:35:21 +08:00
61ba1c3026 components/bt: backport 2 BT bugfix about controller
1.Bugfix btdm sleep twice after wakeup request
2.Set the minimum encryption key size to be 7 octects for BR/EDR link for preventing KNOB attack
    This patch is to address the CVE-2019-9506 vulnerability.
2019-08-27 10:42:40 +08:00
90bbea65c1 Component/bt: fix some BLE bugs
- fix data loss and send same pkt twice sometimes
- fix adv data error in air sometimes
- fix adv start/stop crash sometimes
2019-08-26 20:29:01 +08:00
672e9f4abc test: fix test case MESH_EST_2403 2019-08-26 20:26:46 +08:00
cb3d458050 Fix sdkconfig.rename paths for confgen.py in MSYS
Closes https://github.com/espressif/esp-idf/issues/3950
2019-08-26 11:12:44 +02:00
b72ff61899 cmake: fix issue with handling of EXCLUDE_SRCS 2019-08-26 11:49:30 +05:30
83b9727c42 test: fix nvs compatible case error:
nvs compatible test case uses new test env and app. update test config
file.
2019-08-25 20:46:56 +08:00
7bb8b5ba9e Merge branch 'Bugfix/nonblocking_udp_is_zero_for_4.0' into 'release/v4.0'
fix bug for nonblocking udp is zero for v4.0

See merge request espressif/esp-idf!5855
2019-08-23 10:50:45 +08:00
1f5f6adcb6 fix bug for nonblocking udp is zero for v4.0 2019-08-21 17:07:45 +08:00
aa0bb29404 Update cJSON to v1.7.12
Fixes potential DoS in cJSON_Minify, see https://github.com/DaveGamble/cJSON/issues/354
2019-08-21 18:40:50 +10:00
2264ea7714 kconfig: Add -MP option so .d files include empty targets
Prevents make-level errors when switching IDF versions, as headers may be removed.

Similar to some mentioned here:
https://github.com/espressif/esp-idf/issues/712
2019-08-21 18:20:47 +10:00
a626b26cf9 esp_flash: improve the comments a bit 2019-08-20 14:05:35 +08:00
1cc860216e esp_flash: fix the set/get write protection functions
Add support for get write protection support, fixed the duplicated
set_write_protection link.

All the write_protection check in the top layer are removed. The lower
levels (chip) should ensure to disable write protection before the
operation start.
2019-08-20 14:05:35 +08:00
16ee476a77 Merge branch 'bugfix/config_panic_gdbstub_build_issue_v4.0' into 'release/v4.0'
esp32_gdbstub: fix build error with esp32-2019r1 toolchain (v4.0)

See merge request espressif/esp-idf!5764
2019-08-20 13:11:24 +08:00
674ecc3b56 Merge branch 'bugfix/vfs_concurrent_select_v4.0' into 'release/v4.0'
VFS: Support concurrent VFS select calls & improve the documentation (backport v4.0)

See merge request espressif/esp-idf!5797
2019-08-20 12:49:03 +08:00
43efee5232 Merge branch 'bugfix/fix_mbedtls_net_sockets_error_handling_v4.0' into 'release/v4.0'
mbedtls: use `errno` instead of `SO_ERROR` for getting socket errors (v4.0)

See merge request espressif/esp-idf!5768
2019-08-20 12:28:56 +08:00
5dab23ea98 Merge branch 'bugfix/confserver_temporaryfile_windows_v4.0' into 'release/v4.0'
confserver: Fix NamedTemporaryFile use on Windows (v4.0)

See merge request espressif/esp-idf!5818
2019-08-20 12:28:16 +08:00
79afd2d580 confserver: Fix NamedTemporaryFile use on Windows
Can't have the file open twice, so need to close and delete after reopening.
2019-08-19 17:44:18 +10:00
a8e8919bbf tools: Support sdkconfig.rename files from outside IDF in confgen.py 2019-08-19 17:44:18 +10:00
ba0f4f17ed Merge branch 'bugfix/doc_pip_requirements_v4.0' into 'release/v4.0'
Add -r flag to pip install command from file (backport v4.0)

See merge request espressif/esp-idf!5798
2019-08-16 13:16:04 +08:00
a63b3c4fe6 Merge branch 'feature/dport_eco_revision2_v4.0' into 'release/v4.0'
make dport workaround depend on chip revision (v4.0)

See merge request espressif/esp-idf!5765
2019-08-16 13:15:18 +08:00
6b8c75d87c Merge branch 'bugfix/hwcrypt_fault_inj_v4.0' into 'release/v4.0'
AES & SHA fault injection checks (backport v4.0)

See merge request espressif/esp-idf!5748
2019-08-16 05:29:54 +08:00
68d82abe52 Added -r flag to pip install command from file
Closes https://github.com/espressif/esp-idf/pull/3874
Closes https://github.com/espressif/esp-idf/issues/3915
2019-08-15 14:23:49 +02:00
ec31f235e9 docs: Correct and extend the documentation about VFS select() 2019-08-15 14:11:51 +02:00
7e9d90b180 VFS: Support concurrent VFS select calls
Closes https://github.com/espressif/esp-idf/issues/3392
2019-08-15 14:11:37 +02:00
d4fcbe37f3 Merge branch 'bugfix/idf_tool_default_encoding_v4.0' into 'release/v4.0'
idf_tool: fix UnicodeDecodeError (v4.0)

See merge request espressif/esp-idf!5720
2019-08-15 16:35:58 +08:00
b9a5f764ba Merge branch 'bugfix/fix_flash_read_error_in_dio_mode_v4.0' into 'release/v4.0'
bugfix(flash): add spi dio address bitlen configure in psram init (backprot v4.0)

See merge request espressif/esp-idf!5790
2019-08-15 12:08:56 +08:00
764b70d7e6 bugfix(flash): add spi dio address bitlen configure in psram init 2019-08-15 10:52:56 +08:00
a1496b90e5 Merge branch 'bugfix/fix_ledc_clock_select_bug_v4.0' into 'release/v4.0'
driver(ledc): fixed ledc clock selection bug for v4.0

See merge request espressif/esp-idf!5757
2019-08-14 10:44:39 +08:00
622d6d5504 mbedtls: use errno instead of SO_ERROR for getting socket errors
As per upgrade notes of lwIP v2.1.0:
socket API: according to the standard, SO_ERROR now only returns asynchronous errors.
All other/normal/synchronous errors are (and always were) available via 'errno'.
LWIP_SOCKET_SET_ERRNO has been removed - 'errno' is always set - and required!

Refer: https://www.nongnu.org/lwip/2_1_x/upgrading.html

Fixes https://github.com/espressif/esp-azure/issues/51
2019-08-13 13:11:24 +05:30
1b903111b6 efuse: update the scheme of getting chip revision 2019-08-13 14:37:17 +08:00
69ef694178 esp32_gdbstub: fix build error with esp32-2019r1 toolchain
Fixes https://github.com/espressif/esp-idf/issues/3866
Closes https://github.com/espressif/esp-idf/issues/3834
2019-08-13 11:38:28 +05:30
81651b47a4 Merge branch 'ci/disable_nimble_tests_v4.0' into 'release/v4.0'
ci: Temporarily disable NimBLE tests in CI (v4.0)

See merge request espressif/esp-idf!5754
2019-08-13 10:42:38 +08:00
30dc86179c Merge branch 'bugfix/fix_wifi_bugs_for_authmode_and_multi_ssid_v4.0' into 'release/v4.0'
fix wifi bugs for authmode and multi ssid (backport v4.0)

See merge request espressif/esp-idf!5725
2019-08-12 23:34:43 +08:00
eff3ac05b3 driver(ledc): fixed ledc clock selection bug for release/v4.0 2019-08-12 17:16:52 +08:00
e5349d47a8 ci: Temporarily disable NimBLE tests in CI 2019-08-12 17:14:54 +10:00
4253adf42b modify WIFI_CONN_0101 case for wrong authmode of AP 2019-08-12 02:38:44 +00:00
088ed65194 wifi: fix wifi bugs for authmode and multi ssid 2019-08-12 02:38:44 +00:00
0ce94950b7 sha: Add fault injection checks reading hash digest state
Vulnerability reported by LimitedResults under Espressif Bug Bounty Program.
2019-08-11 15:58:48 +10:00
ae8b2684d7 aes: Add fault injection checks when writing key to hardware
Vulnerability reported by LimitedResults under Espressif Bug Bounty Program.
2019-08-11 15:58:48 +10:00
9c51f679a7 Merge branch 'bugfix/update_example_docs_build_instructions_to_cmake_v4.0' into 'release/v4.0'
examples: change default build instructions in docs to CMake (v4.0)

See merge request espressif/esp-idf!5704
2019-08-09 13:20:25 +08:00
5c07acad46 idf_tool: fix unicode decode error
Closes https://github.com/espressif/esp-idf/issues/3841
2019-08-07 21:27:29 +08:00
70af759dd2 examples: change default build instructions in docs to CMake 2019-08-06 17:25:25 +05:30
76191a0f55 Merge branch 'move/ble_example_v4.0' into 'release/v4.0'
examples/bluetooth: Move the demos to the appropriate locations (v4.0)

See merge request espressif/esp-idf!5687
2019-08-06 00:32:26 +08:00
f0c3114f2f examples/bluetooth: Move the demos to the appropriate locations (v4.0) 2019-08-06 00:32:25 +08:00
1549 changed files with 90369 additions and 25909 deletions

View File

@ -15,26 +15,29 @@ variables:
# GitLab-CI environment
# more attempts for more robust
GET_SOURCES_ATTEMPTS: "10"
ARTIFACT_DOWNLOAD_ATTEMPTS: "10"
# XXX_ATTEMPTS variables (https://docs.gitlab.com/ce/ci/yaml/README.html#job-stages-attempts) are not defined here.
# Use values from "CI / CD Settings" - "Variables".
# GIT_STRATEGY is not defined here.
# Use an option from "CI / CD Settings" - "General pipelines".
# "normal" strategy for fetching only top-level submodules since nothing requires the sub-submodules code for building IDF.
# If the "recursive" strategy is used we have a problem with using relative URLs for sub-submodules.
GIT_SUBMODULE_STRATEGY: normal
UNIT_TEST_BUILD_SYSTEM: make
# IDF environment
# we will download archive for each submodule instead of clone.
# we don't do "recursive" when fetch submodule as they're not used in CI now.
GIT_SUBMODULE_STRATEGY: none
SUBMODULE_FETCH_TOOL: "tools/ci/ci_fetch_submodule.py"
# by default we will fetch all submodules
# jobs can overwrite this variable to only fetch submodules they required
# set to "none" if don't need to fetch submodules
SUBMODULES_TO_FETCH: "all"
# tell build system do not check submodule update as we download archive instead of clone
IDF_SKIP_CHECK_SUBMODULES: 1
UNIT_TEST_BUILD_SYSTEM: cmake
IDF_PATH: "$CI_PROJECT_DIR"
BATCH_BUILD: "1"
V: "0"
APPLY_BOT_FILTER_SCRIPT: "$CI_PROJECT_DIR/tools/ci/apply_bot_filter.py"
CHECKOUT_REF_SCRIPT: "$CI_PROJECT_DIR/tools/ci/checkout_project_ref.py"
CUSTOM_TOOLCHAIN_PATH: "/opt/xtensa-custom"
# Docker images
BOT_DOCKER_IMAGE_TAG: ":latest"
@ -42,40 +45,20 @@ variables:
CI_TARGET_TEST_CONFIG_FILE: "$CI_PROJECT_DIR/tools/ci/config/target-test.yml"
# before each job, we need to check if this job is filtered by bot stage/job filter
.apply_bot_filter: &apply_bot_filter
python $APPLY_BOT_FILTER_SCRIPT || exit 0
.setup_custom_toolchain: &setup_custom_toolchain |
if [ "$IDF_XTENSA_TOOLCHAIN_URL" ] ; then
echo "Use a custom toolchain: ${IDF_XTENSA_TOOLCHAIN_URL:-Unknown}"
rm -rf "$CUSTOM_TOOLCHAIN_PATH" &&
mkdir -p -v "$CUSTOM_TOOLCHAIN_PATH" &&
pushd "$CUSTOM_TOOLCHAIN_PATH" &&
curl -sSL -o xtensa-custom.xxx "$IDF_XTENSA_TOOLCHAIN_URL" &&
ls -l xtensa-custom.xxx &&
tar xf xtensa-custom.xxx --strip-components 1 &&
ls -l . &&
popd
PATH=$CUSTOM_TOOLCHAIN_PATH/bin:$PATH
export PATH
fi
.cleanup_custom_toolchain: &cleanup_custom_toolchain |
echo "Cleaning up $CUSTOM_TOOLCHAIN_PATH"
rm -rf "$CUSTOM_TOOLCHAIN_PATH"
.setup_tools_unless_target_test: &setup_tools_unless_target_test |
if [ "$CI_JOB_STAGE" != "target_test" ]; then
tools/idf_tools.py --non-interactive install && eval "$(tools/idf_tools.py --non-interactive export)" || exit 1
fi
.show_submodule_urls: &show_submodule_urls |
git config --get-regexp '^submodule\..*\.url$' || true
.fetch_submodules: &fetch_submodules |
python $SUBMODULE_FETCH_TOOL -s $SUBMODULES_TO_FETCH
before_script:
- echo "Running common script"
- *show_submodule_urls
- source tools/ci/setup_python.sh
# apply bot filter in before script
- *apply_bot_filter
@ -88,10 +71,9 @@ before_script:
- echo -e "Host gitlab.espressif.cn\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
# Set some options and environment for CI
- source tools/ci/configure_ci_environment.sh
- *setup_tools_unless_target_test
- *setup_custom_toolchain
- *fetch_submodules
# used for check scripts which we want to run unconditionally
.before_script_lesser_nofilter:
@ -101,7 +83,6 @@ before_script:
- echo "Not setting up GitLab key, not fetching submodules, not applying bot filter"
- source tools/ci/setup_python.sh
- source tools/ci/configure_ci_environment.sh
- *setup_custom_toolchain
# used for everything else where we want to do no prep, except for bot filter
.before_script_lesser:
@ -113,10 +94,6 @@ before_script:
# apply bot filter in before script
- *apply_bot_filter
- source tools/ci/configure_ci_environment.sh
- *setup_custom_toolchain
after_script:
- *cleanup_custom_toolchain
.check_job_template:
stage: check

View File

@ -1,10 +1,17 @@
cmake_minimum_required(VERSION 3.5)
project(esp-idf C CXX ASM)
if(CMAKE_CURRENT_LIST_DIR STREQUAL CMAKE_SOURCE_DIR)
message(FATAL_ERROR "Current directory '${CMAKE_CURRENT_LIST_DIR}' is not buildable. "
"Change directories to one of the example projects in '${CMAKE_CURRENT_LIST_DIR}/examples' and try "
"again.")
endif()
unset(compile_options)
unset(c_compile_options)
unset(cxx_compile_options)
unset(compile_definitions)
unset(link_options)
# Add the following build specifications here, since these seem to be dependent
# on config values on the root Kconfig.
@ -22,6 +29,13 @@ else()
list(APPEND cxx_compile_options "-fno-exceptions")
endif()
if(CONFIG_COMPILER_CXX_RTTI)
list(APPEND cxx_compile_options "-frtti")
else()
list(APPEND cxx_compile_options "-fno-rtti")
list(APPEND link_options "-fno-rtti") # used to invoke correct multilib variant (no-rtti) during linking
endif()
if(CONFIG_COMPILER_DISABLE_GCC8_WARNINGS)
list(APPEND compile_options "-Wno-parentheses"
"-Wno-sizeof-pointer-memaccess"
@ -54,11 +68,13 @@ elseif(CONFIG_COMPILER_STACK_CHECK_MODE_ALL)
list(APPEND compile_options "-fstack-protector-all")
endif()
list(APPEND link_options "-fno-lto")
idf_build_set_property(COMPILE_OPTIONS "${compile_options}" APPEND)
idf_build_set_property(C_COMPILE_OPTIONS "${c_compile_options}" APPEND)
idf_build_set_property(CXX_COMPILE_OPTIONS "${cxx_compile_options}" APPEND)
idf_build_set_property(COMPILE_DEFINITIONS "${compile_definitions}" APPEND)
idf_build_set_property(LINK_OPTIONS "${link_options}" APPEND)
idf_build_get_property(build_component_targets __BUILD_COMPONENT_TARGETS)

18
Kconfig
View File

@ -29,6 +29,10 @@ mainmenu "Espressif IoT Development Framework Configuration"
default "IDF_TARGET_NOT_SET" if IDF_TARGET_ENV=""
default IDF_TARGET_ENV
config IDF_FIRMWARE_CHIP_ID
hex
default 0x0000 if IDF_TARGET="esp32"
default 0xFFFF
menu "SDK tool configuration"
config SDK_TOOLPREFIX
@ -39,12 +43,11 @@ mainmenu "Espressif IoT Development Framework Configuration"
a crosstool-ng gcc setup that is in your PATH.
config SDK_PYTHON
string "Python 2 interpreter"
string "Python interpreter"
depends on !IDF_CMAKE
default "python"
help
The executable name/path that is used to run python. On some systems Python 2.x
may need to be invoked as python2.
The executable name/path that is used to run python.
(Note: This option is used with the legacy GNU Make build system only.)
@ -145,6 +148,15 @@ mainmenu "Espressif IoT Development Framework Configuration"
Size (in bytes) of the emergency memory pool for C++ exceptions. This pool will be used to allocate
memory for thrown exceptions when there is not enough memory on the heap.
config COMPILER_CXX_RTTI
# Invisible option, until the toolchain with RTTI support is released.
# Use prompt "Enable C++ run-time type info (RTTI)" when updating.
bool
help
Enabling this option compiles all C++ files with RTTI support enabled.
This increases binary size (typically by tens of kB) but allows using
dynamic_cast conversion and typeid operator.
choice COMPILER_STACK_CHECK_MODE
prompt "Stack smashing protection mode"
default COMPILER_STACK_CHECK_MODE_NONE

View File

@ -39,7 +39,7 @@ See the Getting Started guide links above for a detailed setup guide. This is a
* Install host build dependencies mentioned in Getting Started guide.
* Add `tools/` directory to the PATH
* Run `python -m pip install requirements.txt` to install Python dependencies
* Run `python -m pip install -r requirements.txt` to install Python dependencies
## Configuring the Project

66
SUPPORT_POLICY.md Normal file
View File

@ -0,0 +1,66 @@
The latest support policy for ESP-IDF can be found at [https://github.com/espressif/esp-idf/blob/master/SUPPORT_POLICY.md](https://github.com/espressif/esp-idf/blob/master/SUPPORT_POLICY.md)
Support Period Policy
=====================
Each ESP-IDF major and minor release (V4.0, V4.1, etc) is supported for
18 months after the initial stable release date.
Supported means that the ESP-IDF team will continue to apply bug fixes,
security fixes, etc to the release branch on GitHub, and periodically
make new bugfix releases as needed.
Users are encouraged to upgrade to a newer ESP-IDF release before the
support period finishes and the release becomes End of Life (EOL). It is
our policy to not continue fixing bugs in End of Life releases.
Pre-release versions (betas, previews, `-rc` and `-dev` versions, etc)
are not covered by any support period. Sometimes a particular feature is
marked as \"Preview\" in a release, which means it is also not covered
by the support period.
The ESP-IDF Programming Guide has information about the
[different versions of ESP-IDF](https://docs.espressif.com/projects/esp-idf/en/latest/versions.html)
(major, minor, bugfix, etc).
Long Term Support releases
--------------------------
Some releases (starting with ESP-IDF V3.3) are designated Long Term
Support (LTS). LTS releases are supported for 30 months (2.5 years)
after the initial stable release date.
A new LTS release will be made at least every 18 months. This means
there will always be a period of at least 12 months to upgrade from the
previous LTS release to the following LTS release.
Example
-------
ESP-IDF V3.3 was released in September 2019 and is a Long Term Support
(LTS) release, meaning it will be supported for 30 months until February
2022.
- The first V3.3 release was `v3.3` in September 2019.
- The ESP-IDF team continues to backport bug fixes, security fixes,
etc to the release branch `release/v3.3`.
- Periodically stable bugfix releases are created from the release
branch. For example `v3.3.1`, `v3.3.2`, etc. Users are encouraged to
always update to the latest bugfix release.
- V3.3 bugfix releases continue until February 2022, when all V3.3.x
releases become End of Life.
Existing Releases
-----------------
ESP-IDF release V3.3 and all newer releases will follow this support
period policy. The support period for each release will be announced
when the release is made.
For releases made before the support period policy was announced,
the following support periods apply:
- ESP-IDF V3.1.x and V3.2.x will both be supported until October 2020.
- ESP-IDF V3.0.9 (planned for October 2019) will be the last V3.0
bugfix release. ESP-IDF V3.0.x is End of Life from October 2019.
- ESP-IDF versions before V3.0 are already End of Life.

View File

@ -22,4 +22,14 @@ menu "Application manager"
The PROJECT_NAME variable from the build system will not affect the firmware image.
This value will not be contained in the esp_app_desc structure.
config APP_RETRIEVE_LEN_ELF_SHA
int "The length of APP ELF SHA is stored in RAM(chars)"
default 16
range 8 64
help
At startup, the app will read this many hex characters from the embedded APP ELF SHA-256 hash value
and store it in static RAM. This ensures the app ELF SHA-256 value is always available
if it needs to be printed by the panic handler code.
Changing this value will change the size of a static buffer, in bytes.
endmenu # "Application manager"

View File

@ -40,9 +40,6 @@ read_otadata: $(PARTITION_TABLE_CSV_PATH) partition_table_get_info | check_pytho
--partition-table-offset $(partition_table_offset) \
read_otadata
erase_ota: erase_otadata
@echo "WARNING: erase_ota is deprecated. Use erase_otadata instead."
all: blank_ota_data
flash: blank_ota_data
ifdef CONFIG_SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT

View File

@ -72,13 +72,35 @@ static inline char IRAM_ATTR to_hex_digit(unsigned val)
return (val < 10) ? ('0' + val) : ('a' + val - 10);
}
__attribute__((constructor)) void esp_ota_init_app_elf_sha256(void)
{
esp_ota_get_app_elf_sha256(NULL, 0);
}
/* The esp_app_desc.app_elf_sha256 should be possible to print in panic handler during cache is disabled.
* But because the cache is disabled the reading esp_app_desc.app_elf_sha256 is not right and
* can lead to a complete lock-up of the CPU.
* For this reason we do a reading of esp_app_desc.app_elf_sha256 while start up in esp_ota_init_app_elf_sha256()
* and keep it in the static s_app_elf_sha256 value.
*/
int IRAM_ATTR esp_ota_get_app_elf_sha256(char* dst, size_t size)
{
size_t n = MIN((size - 1) / 2, sizeof(esp_app_desc.app_elf_sha256));
const uint8_t* src = esp_app_desc.app_elf_sha256;
static char s_app_elf_sha256[CONFIG_APP_RETRIEVE_LEN_ELF_SHA / 2];
static bool first_call = true;
if (first_call) {
first_call = false;
const uint8_t* src = esp_app_desc.app_elf_sha256;
for (size_t i = 0; i < sizeof(s_app_elf_sha256); ++i) {
s_app_elf_sha256[i] = src[i];
}
}
if (dst == NULL || size == 0) {
return 0;
}
size_t n = MIN((size - 1) / 2, sizeof(s_app_elf_sha256));
for (size_t i = 0; i < n; ++i) {
dst[2*i] = to_hex_digit(src[i] >> 4);
dst[2*i + 1] = to_hex_digit(src[i] & 0xf);
dst[2*i] = to_hex_digit(s_app_elf_sha256[i] >> 4);
dst[2*i + 1] = to_hex_digit(s_app_elf_sha256[i] & 0xf);
}
dst[2*n] = 0;
return 2*n + 1;

View File

@ -42,7 +42,7 @@
#include "esp_efuse.h"
#define SUB_TYPE_ID(i) (i & 0x0F)
#define SUB_TYPE_ID(i) (i & 0x0F)
typedef struct ota_ops_entry_ {
uint32_t handle;
@ -157,7 +157,8 @@ esp_err_t esp_ota_begin(const esp_partition_t *partition, size_t image_size, esp
if ((image_size == 0) || (image_size == OTA_SIZE_UNKNOWN)) {
ret = esp_partition_erase_range(partition, 0, partition->size);
} else {
ret = esp_partition_erase_range(partition, 0, (image_size / SPI_FLASH_SEC_SIZE + 1) * SPI_FLASH_SEC_SIZE);
const int aligned_erase_size = (image_size + SPI_FLASH_SEC_SIZE - 1) & ~(SPI_FLASH_SEC_SIZE - 1);
ret = esp_partition_erase_range(partition, 0, aligned_erase_size);
}
if (ret != ESP_OK) {
@ -200,7 +201,7 @@ esp_err_t esp_ota_write(esp_ota_handle_t handle, const void *data, size_t size)
// must erase the partition before writing to it
assert(it->erased_size > 0 && "must erase the partition before writing to it");
if (it->wrote_size == 0 && it->partial_bytes == 0 && size > 0 && data_bytes[0] != ESP_IMAGE_HEADER_MAGIC) {
ESP_LOGE(TAG, "OTA image has invalid magic byte (expected 0xE9, saw 0x%02x", data_bytes[0]);
ESP_LOGE(TAG, "OTA image has invalid magic byte (expected 0xE9, saw 0x%02x)", data_bytes[0]);
return ESP_ERR_OTA_VALIDATE_FAILED;
}

View File

@ -4,7 +4,7 @@
TEST_CASE("esp_ota_get_app_elf_sha256 test", "[esp_app_desc]")
{
const int sha256_hex_len = 64;
const int sha256_hex_len = CONFIG_APP_RETRIEVE_LEN_ELF_SHA;
char dst[sha256_hex_len + 2];
const char fill = 0xcc;
int res;

View File

@ -444,7 +444,7 @@ static void test_flow4(void)
// 2 Stage: run factory -> check it -> copy factory to OTA0 -> reboot --//--
// 3 Stage: run OTA0 -> check it -> set_pin_factory_reset -> reboot --//--
// 4 Stage: run factory -> check it -> erase OTA_DATA for next tests -> PASS
TEST_CASE_MULTIPLE_STAGES("Switching between factory, OTA0, sets pin_factory_reset, factory", "[app_update][timeout=90][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET]", start_test, test_flow4, test_flow4, test_flow4);
TEST_CASE_MULTIPLE_STAGES("Switching between factory, OTA0, sets pin_factory_reset, factory", "[app_update][timeout=90][ignore][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET]", start_test, test_flow4, test_flow4, test_flow4);
#endif
#ifdef CONFIG_BOOTLOADER_APP_TEST
@ -487,7 +487,7 @@ static void test_flow5(void)
// 2 Stage: run factory -> check it -> copy factory to Test and set pin_test_app -> reboot --//--
// 3 Stage: run test -> check it -> reset pin_test_app -> reboot --//--
// 4 Stage: run factory -> check it -> erase OTA_DATA for next tests -> PASS
TEST_CASE_MULTIPLE_STAGES("Switching between factory, test, factory", "[app_update][timeout=90][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET]", start_test, test_flow5, test_flow5, test_flow5);
TEST_CASE_MULTIPLE_STAGES("Switching between factory, test, factory", "[app_update][timeout=90][ignore][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET]", start_test, test_flow5, test_flow5, test_flow5);
#endif
static const esp_partition_t* app_update(void)

View File

@ -219,6 +219,22 @@ menu "Bootloader config"
It allow to test anti-rollback implemention without permanent write eFuse bits.
In partition table should be exist this partition `emul_efuse, data, 5, , 0x2000`.
choice BOOTLOADER_FLASH_XMC_OVERERASE_PATCH
bool "Patch strategy for XMC over-erase issue"
default BOOTLOADER_FLASH_XMC_OVERERASE_PATCH_DEFAULT
help
Specify the patch strategy for XMC chips. The over-erase issue may exist on
XM25QH16C, XM25QH32C and XM25QH128C.
config BOOTLOADER_FLASH_XMC_OVERERASE_PATCH_ALL
bool "Run the patch for all XMC chips. This can completely avoid over-erase issue. But may cost some time."
config BOOTLOADER_FLASH_XMC_OVERERASE_PATCH_DEFAULT
bool "Run the patch on XMC chips when there are clues indicating the flash is running incorrectly."
config BOOTLOADER_FLASH_XMC_OVERERASE_PATCH_BYPASS
bool "Not using the patch"
endchoice # BOOTLOADER_FLASH_XMC_OVERERASE_PATCH
endmenu # Bootloader
@ -234,12 +250,15 @@ menu "Security features"
config SECURE_SIGNED_ON_UPDATE
bool
default y
select MBEDTLS_ECP_DP_SECP256R1_ENABLED
depends on SECURE_BOOT_ENABLED || SECURE_SIGNED_ON_UPDATE_NO_SECURE_BOOT
config SECURE_SIGNED_APPS
bool
default y
select MBEDTLS_ECP_DP_SECP256R1_ENABLED
select MBEDTLS_ECP_C
select MBEDTLS_ECDH_C
select MBEDTLS_ECDSA_C
depends on SECURE_SIGNED_ON_BOOT || SECURE_SIGNED_ON_UPDATE
@ -338,7 +357,7 @@ menu "Security features"
config SECURE_BOOT_SIGNING_KEY
string "Secure boot private signing key"
depends on SECURE_BOOT_BUILD_SIGNED_BINARIES
default secure_boot_signing_key.pem
default "secure_boot_signing_key.pem"
help
Path to the key file used to sign app images.
@ -354,7 +373,7 @@ menu "Security features"
config SECURE_BOOT_VERIFICATION_KEY
string "Secure boot public signature verification key"
depends on SECURE_SIGNED_APPS && !SECURE_BOOT_BUILD_SIGNED_BINARIES
default signature_verification_key.bin
default "signature_verification_key.bin"
help
Path to a public key file used to verify signed images. This key is compiled into the bootloader and/or
app, to verify app images.
@ -368,7 +387,7 @@ menu "Security features"
choice SECURE_BOOTLOADER_KEY_ENCODING
bool "Hardware Key Encoding"
depends on SECURE_BOOTLOADER_REFLASHABLE
default SECURE_BOOTLOADER_NO_ENCODING
default SECURE_BOOTLOADER_KEY_ENCODING_256BIT
help
In reflashable secure bootloader mode, a hardware key is derived from the signing key (with SHA-256) and
@ -515,6 +534,20 @@ menu "Security features"
Only set this option in testing environments.
config SECURE_FLASH_REQUIRE_ALREADY_ENABLED
bool "Require flash encryption to be already enabled"
depends on SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT
default N
help
If not set (default), and flash encryption is not yet enabled in eFuses, the 2nd stage bootloader
will enable flash encryption: generate the flash encryption key and program eFuses.
If this option is set, and flash encryption is not yet enabled, the bootloader will error out and
reboot.
If flash encryption is enabled in eFuses, this option does not change the bootloader behavior.
Only use this option in testing environments, to avoid accidentally enabling flash encryption on
the wrong device. The device needs to have flash encryption already enabled using espefuse.py.
endmenu # Potentially Insecure
endmenu # Security features

View File

@ -96,11 +96,13 @@ endif()
idf_build_get_property(idf_path IDF_PATH)
idf_build_get_property(idf_target IDF_TARGET)
idf_build_get_property(sdkconfig SDKCONFIG)
idf_build_get_property(python PYTHON)
idf_build_get_property(extra_cmake_args EXTRA_CMAKE_ARGS)
externalproject_add(bootloader
SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/subproject"
BINARY_DIR "${BOOTLOADER_BUILD_DIR}"
CMAKE_ARGS -DSDKCONFIG=${sdkconfig} -DIDF_PATH=${idf_path} -DIDF_TARGET=${idf_target}
CMAKE_ARGS -DSDKCONFIG=${sdkconfig} -DIDF_PATH=${idf_path} -DIDF_TARGET=${idf_target} -DPYTHON=${python}
-DPYTHON_DEPS_CHECKED=1
-DEXTRA_COMPONENT_DIRS=${CMAKE_CURRENT_LIST_DIR}
${sign_key_arg} ${ver_key_arg}
@ -108,6 +110,7 @@ externalproject_add(bootloader
# the bootloader common component requirements depends on this and
# config variables are not available before project() call.
-DLEGACY_INCLUDE_COMMON_HEADERS=${CONFIG_LEGACY_INCLUDE_COMMON_HEADERS}
${extra_cmake_args}
INSTALL_COMMAND ""
BUILD_ALWAYS 1 # no easy way around this...
BUILD_BYPRODUCTS ${bootloader_binary_files}
@ -124,4 +127,4 @@ endif()
# So for now we just have the top-level build remove the final build products...
set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" APPEND PROPERTY
ADDITIONAL_MAKE_CLEAN_FILES
${bootloader_binary_files})
${bootloader_binary_files})

View File

@ -75,7 +75,8 @@ if(CONFIG_SECURE_BOOTLOADER_REFLASHABLE)
add_custom_command(OUTPUT "${bootloader_digest_bin}"
COMMAND ${CMAKE_COMMAND} -E echo "DIGEST ${bootloader_digest_bin}"
COMMAND ${ESPSECUREPY} digest_secure_bootloader --keyfile "${secure_bootloader_key}"
-o "${bootloader_digest_bin}" "${CMAKE_BINARY_DIR}/bootloader.bin"
-o "${bootloader_digest_bin}" "${CMAKE_BINARY_DIR}/bootloader.bin"
MAIN_DEPENDENCY "${CMAKE_BINARY_DIR}/.bin_timestamp"
DEPENDS gen_secure_bootloader_key gen_project_binary
VERBATIM)

View File

@ -24,6 +24,7 @@
#include "bootloader_common.h"
#include "sdkconfig.h"
#include "esp_image_format.h"
#include "esp32/rom/rtc.h"
static const char* TAG = "boot";
@ -74,7 +75,8 @@ static int selected_boot_partition(const bootloader_state_t *bs)
int boot_index = bootloader_utility_get_selected_boot_partition(bs);
if (boot_index == INVALID_INDEX) {
return boot_index; // Unrecoverable failure (not due to corrupt ota data or bad partition contents)
} else {
}
if (rtc_get_reset_reason(0) != DEEPSLEEP_RESET) {
// Factory firmware.
#ifdef CONFIG_BOOTLOADER_FACTORY_RESET
if (bootloader_common_check_long_hold_gpio(CONFIG_BOOTLOADER_NUM_PIN_FACTORY_RESET, CONFIG_BOOTLOADER_HOLD_TIME_GPIO) == 1) {

View File

@ -40,6 +40,7 @@ SECTIONS
*(.iram1 .iram1.*) /* catch stray IRAM_ATTR */
*liblog.a:(.literal .text .literal.* .text.*)
*libgcc.a:(.literal .text .literal.* .text.*)
*libbootloader_support.a:bootloader_clock.*(.literal .text .literal.* .text.*)
*libbootloader_support.a:bootloader_common.*(.literal .text .literal.* .text.*)
*libbootloader_support.a:bootloader_flash.*(.literal .text .literal.* .text.*)
*libbootloader_support.a:bootloader_random.*(.literal .text .literal.* .text.*)
@ -53,6 +54,7 @@ SECTIONS
*libmicro-ecc.a:*.*(.literal .text .literal.* .text.*)
*libspi_flash.a:*.*(.literal .text .literal.* .text.*)
*libsoc.a:rtc_wdt.*(.literal .text .literal.* .text.*)
*libsoc.a:rtc_clk.*(.literal .text .literal.* .text.*)
*libefuse.a:*.*(.literal .text .literal.* .text.*)
*(.fini.literal)
*(.fini)

View File

@ -36,30 +36,60 @@ idf_component_register(SRCS "${srcs}"
REQUIRES "${requires}"
PRIV_REQUIRES "${priv_requires}")
if(BOOTLOADER_BUILD AND CONFIG_SECURE_SIGNED_APPS)
# Whether CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES or not, we need verification key to embed
# in the library.
if(CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES)
# We generate the key from the signing key. The signing key is passed from the main project.
get_filename_component(secure_boot_signing_key
"${SECURE_BOOT_SIGNING_KEY}"
ABSOLUTE BASE_DIR "${project_dir}")
get_filename_component(secure_boot_verification_key
"signature_verification_key.bin"
ABSOLUTE BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}")
add_custom_command(OUTPUT "${secure_boot_verification_key}"
COMMAND ${ESPSECUREPY}
if(CONFIG_SECURE_SIGNED_APPS)
if(BOOTLOADER_BUILD)
# Whether CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES or not, we need verification key to embed
# in the library.
if(CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES)
# We generate the key from the signing key. The signing key is passed from the main project.
get_filename_component(secure_boot_signing_key
"${SECURE_BOOT_SIGNING_KEY}"
ABSOLUTE BASE_DIR "${project_dir}")
get_filename_component(secure_boot_verification_key
"signature_verification_key.bin"
ABSOLUTE BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}")
add_custom_command(OUTPUT "${secure_boot_verification_key}"
COMMAND ${ESPSECUREPY}
extract_public_key --keyfile "${secure_boot_signing_key}"
"${secure_boot_verification_key}"
VERBATIM)
else()
# We expect to 'inherit' the verification key passed from main project.
get_filename_component(secure_boot_verification_key
${SECURE_BOOT_VERIFICATION_KEY}
ABSOLUTE BASE_DIR "${project_dir}")
DEPENDS ${secure_boot_signing_key}
VERBATIM)
else()
# We expect to 'inherit' the verification key passed from main project.
get_filename_component(secure_boot_verification_key
${SECURE_BOOT_VERIFICATION_KEY}
ABSOLUTE BASE_DIR "${project_dir}")
endif()
else() # normal app build
idf_build_get_property(project_dir PROJECT_DIR)
if(CONFIG_SECURE_BOOT_VERIFICATION_KEY)
# verification-only build supplies verification key
set(secure_boot_verification_key ${CONFIG_SECURE_BOOT_VERIFICATION_KEY})
get_filename_component(secure_boot_verification_key
${secure_boot_verification_key}
ABSOLUTE BASE_DIR "${project_dir}")
else()
# sign at build time, extracts key from signing key
set(secure_boot_verification_key "${CMAKE_BINARY_DIR}/signature_verification_key.bin")
get_filename_component(secure_boot_signing_key
${CONFIG_SECURE_BOOT_SIGNING_KEY}
ABSOLUTE BASE_DIR "${project_dir}")
add_custom_command(OUTPUT "${secure_boot_verification_key}"
COMMAND ${ESPSECUREPY}
extract_public_key --keyfile "${secure_boot_signing_key}"
"${secure_boot_verification_key}"
WORKING_DIRECTORY ${project_dir}
DEPENDS ${secure_boot_signing_key}
VERBATIM)
endif()
endif()
target_add_binary_data(${COMPONENT_LIB} "${secure_boot_verification_key}" "BINARY")
# Embed the verification key in the binary (app & bootloader)
#
target_add_binary_data(${COMPONENT_LIB} "${secure_boot_verification_key}" "BINARY"
RENAME_TO signature_verification_key_bin)
set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES
"${secure_boot_verification_key}")

View File

@ -15,6 +15,7 @@
#pragma once
#include "esp_flash_partitions.h"
#include "esp_image_format.h"
#include "esp_app_format.h"
#ifdef __cplusplus
extern "C" {
@ -27,6 +28,11 @@ typedef enum {
GPIO_NOT_HOLD = 0 /*!< If the GPIO input is not low */
} esp_comm_gpio_hold_t;
typedef enum {
ESP_IMAGE_BOOTLOADER,
ESP_IMAGE_APPLICATION
} esp_image_type;
/**
* @brief Calculate crc for the OTA data select.
*
@ -129,7 +135,7 @@ int bootloader_common_select_otadata(const esp_ota_select_entry_t *two_otadata,
/**
* @brief Returns esp_app_desc structure for app partition. This structure includes app version.
*
*
* Returns a description for the requested app partition.
* @param[in] partition App partition description.
* @param[out] app_desc Structure of info about app.
@ -141,6 +147,24 @@ int bootloader_common_select_otadata(const esp_ota_select_entry_t *two_otadata,
*/
esp_err_t bootloader_common_get_partition_description(const esp_partition_pos_t *partition, esp_app_desc_t *app_desc);
/**
* @brief Get chip revision
*
* @return Chip revision number
*/
uint8_t bootloader_common_get_chip_revision(void);
/**
* @brief Check if the image (bootloader and application) has valid chip ID and revision
*
* @param[in] img_hdr: image header
* @param[in] type: image type, bootloader or application
* @return
* - ESP_OK: image and chip are matched well
* - ESP_FAIL: image doesn't match to the chip
*/
esp_err_t bootloader_common_check_chip_validity(const esp_image_header_t* img_hdr, esp_image_type type);
/**
* @brief Configure VDDSDIO, call this API to rise VDDSDIO to 1.9V when VDDSDIO regulator is enabled as 1.8V mode.
*/

View File

@ -13,6 +13,19 @@
// limitations under the License.
#pragma once
/**
* @brief ESP chip ID
*
*/
typedef enum {
ESP_CHIP_ID_ESP32 = 0x0000, /*!< chip ID: ESP32 */
ESP_CHIP_ID_INVALID = 0xFFFF /*!< Invalid chip ID (we defined it to make sure the esp_chip_id_t is 2 bytes size) */
} __attribute__((packed)) esp_chip_id_t;
/** @cond */
_Static_assert(sizeof(esp_chip_id_t) == 2, "esp_chip_id_t should be 16 bit");
/** @endcond */
/**
* @brief SPI flash mode, used in esp_image_header_t
*/
@ -63,7 +76,9 @@ typedef struct {
* the IDF bootloader uses software to configure the WP
* pin and sets this field to 0xEE=disabled) */
uint8_t spi_pin_drv[3]; /*!< Drive settings for the SPI flash pins (read by ROM bootloader) */
uint8_t reserved[11]; /*!< Reserved bytes in ESP32 additional header space, currently unused */
esp_chip_id_t chip_id; /*!< Chip identification number */
uint8_t min_chip_rev; /*!< Minimum chip revision supported by image */
uint8_t reserved[8]; /*!< Reserved bytes in additional header space, currently unused */
uint8_t hash_appended; /*!< If 1, a SHA256 digest "simple hash" (of the entire image) is appended after the checksum.
* Included in image length. This digest
* is separate to secure boot and only used for detecting corruption.

View File

@ -133,6 +133,21 @@ void esp_flash_write_protect_crypt_cnt();
*/
esp_flash_enc_mode_t esp_get_flash_encryption_mode();
/** @brief Check the flash encryption mode during startup
*
* @note This function is called automatically during app startup,
* it doesn't need to be called from the app.
*
* Verifies the flash encryption config during startup:
*
* - Correct any insecure flash encryption settings if hardware
* Secure Boot is enabled.
* - Log warnings if the efuse config doesn't match the project
* config in any way
*/
void esp_flash_encryption_init_checks(void);
#ifdef __cplusplus
}
#endif

View File

@ -98,12 +98,6 @@ typedef struct {
esp_err_t esp_partition_table_verify(const esp_partition_info_t *partition_table, bool log_errors, int *num_partitions);
/* This function is included for compatibility with the ESP-IDF v3.x API */
inline static __attribute__((deprecated)) esp_err_t esp_partition_table_basic_verify(const esp_partition_info_t *partition_table, bool log_errors, int *num_partitions)
{
return esp_partition_table_verify(partition_table, log_errors, num_partitions);
}
/**
* Check whether the region on the main flash is safe to write.
*

View File

@ -51,36 +51,6 @@ typedef enum {
#endif
} esp_image_load_mode_t;
/**
* @brief Verify and (optionally, in bootloader mode) load an app image.
*
* This name is deprecated and is included for compatibility with the ESP-IDF v3.x API.
* It will be removed in V4.0 version.
* Function has been renamed to esp_image_verify().
* Use function esp_image_verify() to verify a image. And use function bootloader_load_image() to load image from a bootloader space.
*
* If encryption is enabled, data will be transparently decrypted.
*
* @param mode Mode of operation (verify, silent verify, or load).
* @param part Partition to load the app from.
* @param[inout] data Pointer to the image metadata structure which is be filled in by this function. 'start_addr' member should be set (to the start address of the image.) Other fields will all be initialised by this function.
*
* Image validation checks:
* - Magic byte.
* - Partition smaller than 16MB.
* - All segments & image fit in partition.
* - 8 bit image checksum is valid.
* - SHA-256 of image is valid (if image has this appended).
* - (Signature) if signature verification is enabled.
*
* @return
* - ESP_OK if verify or load was successful
* - ESP_ERR_IMAGE_FLASH_FAIL if a SPI flash error occurs
* - ESP_ERR_IMAGE_INVALID if the image appears invalid.
* - ESP_ERR_INVALID_ARG if the partition or data pointers are invalid.
*/
esp_err_t esp_image_load(esp_image_load_mode_t mode, const esp_partition_pos_t *part, esp_image_metadata_t *data) __attribute__((deprecated));
/**
* @brief Verify an app image.
*

View File

@ -17,6 +17,8 @@
extern "C" {
#endif
#include "esp_err.h"
/** @brief Enable Quad I/O mode in bootloader (if configured)
*
* Queries attached SPI flash ID and sends correct SPI flash
@ -32,6 +34,8 @@ void bootloader_enable_qio_mode(void);
*/
uint32_t bootloader_read_flash_id();
esp_err_t bootloader_xmc_flash_overerase_fix();
#ifdef __cplusplus
}
#endif

View File

@ -58,3 +58,12 @@ void bootloader_clock_configure()
}
#endif
}
#ifdef BOOTLOADER_BUILD
int esp_clk_apb_freq(void)
{
return rtc_clk_apb_freq_get();
}
#endif // BOOTLOADER_BUILD

View File

@ -25,6 +25,8 @@
#include "bootloader_common.h"
#include "soc/gpio_periph.h"
#include "soc/rtc.h"
#include "soc/efuse_reg.h"
#include "soc/apb_ctrl_reg.h"
#include "esp_image_format.h"
#include "bootloader_sha.h"
#include "sys/param.h"
@ -270,3 +272,51 @@ void bootloader_common_vddsdio_configure()
}
#endif // CONFIG_BOOTLOADER_VDDSDIO_BOOST
}
#ifdef CONFIG_IDF_TARGET_ESP32
uint8_t bootloader_common_get_chip_revision(void)
{
uint8_t eco_bit0, eco_bit1, eco_bit2;
eco_bit0 = (REG_READ(EFUSE_BLK0_RDATA3_REG) & 0xF000) >> 15;
eco_bit1 = (REG_READ(EFUSE_BLK0_RDATA5_REG) & 0x100000) >> 20;
eco_bit2 = (REG_READ(APB_CTRL_DATE_REG) & 0x80000000) >> 31;
uint32_t combine_value = (eco_bit2 << 2) | (eco_bit1 << 1) | eco_bit0;
uint8_t chip_ver = 0;
switch (combine_value) {
case 0:
chip_ver = 0;
break;
case 1:
chip_ver = 1;
break;
case 3:
chip_ver = 2;
break;
case 7:
chip_ver = 3;
break;
default:
chip_ver = 0;
break;
}
return chip_ver;
}
#endif
esp_err_t bootloader_common_check_chip_validity(const esp_image_header_t* img_hdr, esp_image_type type)
{
esp_err_t err = ESP_OK;
esp_chip_id_t chip_id = CONFIG_IDF_FIRMWARE_CHIP_ID;
if (chip_id != img_hdr->chip_id) {
ESP_LOGE(TAG, "mismatch chip ID, expected %d, found %d", chip_id, img_hdr->chip_id);
err = ESP_FAIL;
}
uint8_t revision = bootloader_common_get_chip_revision();
if (revision < img_hdr->min_chip_rev) {
ESP_LOGE(TAG, "can't run on lower chip revision, expected %d, found %d", revision, img_hdr->min_chip_rev);
err = ESP_FAIL;
} else if (revision != img_hdr->min_chip_rev) {
ESP_LOGI(TAG, "chip revision: %d, min. %s chip revision: %d", revision, type == ESP_IMAGE_BOOTLOADER ? "bootloader" : "application", img_hdr->min_chip_rev);
}
return err;
}

View File

@ -62,6 +62,7 @@ void IRAM_ATTR bootloader_flash_clock_config(const esp_image_header_t* pfhdr)
break;
}
esp_rom_spiflash_config_clk(spi_clk_div, 0);
esp_rom_spiflash_config_clk(spi_clk_div, 1);
}
void IRAM_ATTR bootloader_flash_gpio_config(const esp_image_header_t* pfhdr)

View File

@ -120,13 +120,29 @@ esp_err_t bootloader_init()
static esp_err_t bootloader_main()
{
bootloader_common_vddsdio_configure();
/* Read and keep flash ID, for further use. */
g_rom_flashchip.device_id = bootloader_read_flash_id();
#if CONFIG_BOOTLOADER_FLASH_XMC_OVERERASE_PATCH_ALL || CONFIG_BOOTLOADER_FLASH_XMC_OVERERASE_PATCH_DEFAULT
if (bootloader_xmc_flash_overerase_fix() != ESP_OK) {
ESP_LOGE(TAG, "failed to fix XMC flash overerase, reboot!");
return ESP_FAIL;
}
#endif
esp_image_header_t fhdr;
if (bootloader_flash_read(ESP_BOOTLOADER_OFFSET, &fhdr, sizeof(esp_image_header_t), true) != ESP_OK) {
ESP_LOGE(TAG, "failed to load bootloader header!");
return ESP_FAIL;
}
/* Check chip ID and minimum chip revision that supported by this image */
uint8_t revision = bootloader_common_get_chip_revision();
ESP_LOGI(TAG, "Chip Revision: %d", revision);
if (bootloader_common_check_chip_validity(&fhdr, ESP_IMAGE_BOOTLOADER) != ESP_OK) {
return ESP_FAIL;
}
bootloader_init_flash_configure(&fhdr);
#if (CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ == 240)
//Check if ESP32 is rated for a CPU frequency of 160MHz only

View File

@ -114,17 +114,18 @@ void bootloader_random_enable(void)
void bootloader_random_disable(void)
{
/* Disable i2s clock */
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_I2S0_CLK_EN);
/* Reset some i2s configuration (possibly redundant as we reset entire
I2S peripheral further down). */
CLEAR_PERI_REG_MASK(I2S_CONF_REG(0), I2S_RX_START);
SET_PERI_REG_MASK(I2S_CONF_REG(0), I2S_RX_RESET);
CLEAR_PERI_REG_MASK(I2S_CONF_REG(0), I2S_RX_RESET);
CLEAR_PERI_REG_MASK(I2S_CONF2_REG(0), I2S_CAMERA_EN);
CLEAR_PERI_REG_MASK(I2S_CONF2_REG(0), I2S_LCD_EN);
CLEAR_PERI_REG_MASK(I2S_CONF2_REG(0), I2S_DATA_ENABLE_TEST_EN);
CLEAR_PERI_REG_MASK(I2S_CONF2_REG(0), I2S_DATA_ENABLE);
CLEAR_PERI_REG_MASK(I2S_CONF_REG(0), I2S_RX_START);
/* Disable i2s clock */
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_I2S0_CLK_EN);
/* Restore SYSCON mode registers */
CLEAR_PERI_REG_MASK(SENS_SAR_READ_CTRL_REG, SENS_SAR1_DIG_FORCE);

View File

@ -37,7 +37,7 @@ static const char *TAG = "flash_encrypt";
/* Static functions for stages of flash encryption */
static esp_err_t initialise_flash_encryption(void);
static esp_err_t encrypt_flash_contents(uint32_t flash_crypt_cnt, bool flash_crypt_wr_dis);
static esp_err_t encrypt_flash_contents(uint32_t flash_crypt_cnt, bool flash_crypt_wr_dis) __attribute__((unused));
static esp_err_t encrypt_bootloader();
static esp_err_t encrypt_and_load_partition_table(esp_partition_info_t *partition_table, int *num_partitions);
static esp_err_t encrypt_partition(int index, const esp_partition_info_t *partition);
@ -60,8 +60,14 @@ esp_err_t esp_flash_encrypt_check_and_update(void)
return ESP_OK;
}
else {
#ifndef CONFIG_SECURE_FLASH_REQUIRE_ALREADY_ENABLED
/* Flash is not encrypted, so encrypt it! */
return encrypt_flash_contents(flash_crypt_cnt, flash_crypt_wr_dis);
#else
ESP_LOGE(TAG, "flash encryption is not enabled, and SECURE_FLASH_REQUIRE_ALREADY_ENABLED "
"is set, refusing to boot.");
return ESP_ERR_INVALID_STATE;
#endif // CONFIG_SECURE_FLASH_REQUIRE_ALREADY_ENABLED
}
}

View File

@ -24,6 +24,7 @@
#include <bootloader_random.h>
#include <bootloader_sha.h>
#include "bootloader_util.h"
#include "bootloader_common.h"
/* Checking signatures as part of verifying images is necessary:
- Always if secure boot is enabled
@ -268,8 +269,6 @@ esp_err_t esp_image_verify(esp_image_load_mode_t mode, const esp_partition_pos_t
return image_load(mode, part, data);
}
esp_err_t esp_image_load(esp_image_load_mode_t mode, const esp_partition_pos_t *part, esp_image_metadata_t *data) __attribute__((alias("esp_image_verify")));
static esp_err_t verify_image_header(uint32_t src_addr, const esp_image_header_t *image, bool silent)
{
esp_err_t err = ESP_OK;
@ -280,6 +279,9 @@ static esp_err_t verify_image_header(uint32_t src_addr, const esp_image_header_t
}
err = ESP_ERR_IMAGE_INVALID;
}
if (bootloader_common_check_chip_validity(image, ESP_IMAGE_APPLICATION) != ESP_OK) {
err = ESP_ERR_IMAGE_INVALID;
}
if (!silent) {
if (image->spi_mode > ESP_IMAGE_SPI_MODE_SLOW_READ) {
ESP_LOGW(TAG, "image at 0x%x has invalid SPI mode %d", src_addr, image->spi_mode);

View File

@ -13,9 +13,51 @@
// limitations under the License.
#include <strings.h>
#include "sdkconfig.h"
#include "esp_log.h"
#include "esp_efuse.h"
#include "esp_efuse_table.h"
#include "esp_flash_encrypt.h"
#include "esp_secure_boot.h"
#ifndef BOOTLOADER_BUILD
static const char *TAG = "flash_encrypt";
void esp_flash_encryption_init_checks()
{
esp_flash_enc_mode_t mode;
// First check is: if Release mode flash encryption & secure boot are enabled then
// FLASH_CRYPT_CNT *must* be write protected. This will have happened automatically
// if bootloader is IDF V4.0 or newer but may not have happened for previous ESP-IDF bootloaders.
#ifdef CONFIG_SECURE_FLASH_ENCRYPTION_MODE_RELEASE
#ifdef CONFIG_SECURE_BOOT_ENABLED
if (esp_secure_boot_enabled() && esp_flash_encryption_enabled()) {
uint8_t flash_crypt_cnt_wr_dis = 0;
esp_efuse_read_field_blob(ESP_EFUSE_WR_DIS_FLASH_CRYPT_CNT, &flash_crypt_cnt_wr_dis, 1);
if (!flash_crypt_cnt_wr_dis) {
ESP_LOGE(TAG, "Flash encryption & Secure Boot together requires FLASH_CRYPT_CNT efuse to be write protected. Fixing now...");
esp_flash_write_protect_crypt_cnt();
}
}
#endif // CONFIG_SECURE_BOOT_ENABLED
#endif // CONFIG_SECURE_FLASH_ENCRYPTION_MODE_RELEASE
// Second check is to print a warning or error if the current running flash encryption mode
// doesn't match the expectation from project config (due to mismatched bootloader and app, probably)
mode = esp_get_flash_encryption_mode();
if (mode == ESP_FLASH_ENC_MODE_DEVELOPMENT) {
#ifdef CONFIG_SECURE_FLASH_ENCRYPTION_MODE_RELEASE
ESP_LOGE(TAG, "Flash encryption settings error: app is configured for RELEASE but efuses are set for DEVELOPMENT");
ESP_LOGE(TAG, "Mismatch found in security options in bootloader menuconfig and efuse settings. Device is not secure.");
#else
ESP_LOGW(TAG, "Flash encryption mode is DEVELOPMENT (not secure)");
#endif
} else if (mode == ESP_FLASH_ENC_MODE_RELEASE) {
ESP_LOGI(TAG, "Flash encryption mode is RELEASE");
}
}
#endif
void esp_flash_write_protect_crypt_cnt()
{

View File

@ -66,10 +66,10 @@ static void write_status_8b_wrsr2(unsigned new_status);
/* Write 16 bit status using WRSR */
static void write_status_16b_wrsr(unsigned new_status);
/* Read 8 bit status of XM25QU64A */
static unsigned read_status_8b_xmc25qu64a();
/* Write 8 bit status of XM25QU64A */
static void write_status_8b_xmc25qu64a(unsigned new_status);
/* Read 8 bit status using RDSR command in otp mode */
static unsigned read_status_8b_rdsr_otp(void);
/* Write 8 bit status using WRSR command in otp mode */
static void write_status_8b_wrsr_otp(unsigned new_status);
#define ESP32_D2WD_WP_GPIO 7 /* ESP32-D2WD has this GPIO wired to WP pin of flash */
@ -95,7 +95,8 @@ const static qio_info_t chip_data[] = {
{ "ISSI", 0x9D, 0x4000, 0xCF00, read_status_8b_rdsr, write_status_8b_wrsr, 6 }, /* IDs 0x40xx, 0x70xx */
{ "WinBond", 0xEF, 0x4000, 0xFF00, read_status_16b_rdsr_rdsr2, write_status_16b_wrsr, 9 },
{ "GD", 0xC8, 0x6000, 0xFF00, read_status_16b_rdsr_rdsr2, write_status_16b_wrsr, 9 },
{ "XM25QU64A", 0x20, 0x3817, 0xFFFF, read_status_8b_xmc25qu64a, write_status_8b_xmc25qu64a, 6 },
{ "XM25QU64A", 0x20, 0x3817, 0xFFFF, read_status_8b_rdsr_otp, write_status_8b_wrsr_otp, 6 },
{ "EON", 0x1C, 0x7000, 0xFF00, read_status_8b_rdsr_otp, write_status_8b_wrsr_otp, 6 }, /* EN25QH sereils: IDs 0x70xx */
/* Final entry is default entry, if no other IDs have matched.
@ -253,7 +254,7 @@ static void write_status_16b_wrsr(unsigned new_status)
execute_flash_command(CMD_WRSR, new_status, 16, 0);
}
static unsigned read_status_8b_xmc25qu64a()
static unsigned read_status_8b_rdsr_otp(void)
{
execute_flash_command(CMD_OTPEN, 0, 0, 0); /* Enter OTP mode */
esp_rom_spiflash_wait_idle(&g_rom_flashchip);
@ -262,7 +263,7 @@ static unsigned read_status_8b_xmc25qu64a()
return read_status;
}
static void write_status_8b_xmc25qu64a(unsigned new_status)
static void write_status_8b_wrsr_otp(unsigned new_status)
{
execute_flash_command(CMD_OTPEN, 0, 0, 0); /* Enter OTP mode */
esp_rom_spiflash_wait_idle(&g_rom_flashchip);
@ -305,3 +306,111 @@ static uint32_t execute_flash_command(uint8_t command, uint32_t mosi_data, uint8
SPIFLASH.ctrl.val = old_ctrl_reg;
return SPIFLASH.data_buf[0];
}
// cmd(0x5A) + 24bit address + 8 cycles dummy
static uint32_t bootloader_flash_read_sfdp(uint32_t sfdp_addr, unsigned int miso_byte_num)
{
assert(miso_byte_num <= 4);
uint8_t command = 0x5A;
uint8_t miso_len = miso_byte_num * 8;
uint8_t mosi_len = 0;
uint32_t mosi_data = 0;
uint32_t old_ctrl_reg = SPIFLASH.ctrl.val;
SPIFLASH.ctrl.val = SPI_WP_REG_M; // keep WP high while idle, otherwise leave DIO mode
SPIFLASH.user.usr_dummy = 1;
SPIFLASH.user1.usr_dummy_cyclelen = 7 + g_rom_spiflash_dummy_len_plus[1];
SPIFLASH.user.usr_addr = 1;
SPIFLASH.addr = (sfdp_addr<<8);
SPIFLASH.user1.usr_addr_bitlen = 23;
SPIFLASH.user.usr_command = 1;
SPIFLASH.user2.usr_command_bitlen = 7;
SPIFLASH.user2.usr_command_value = command;
SPIFLASH.user.usr_miso = miso_len > 0;
SPIFLASH.miso_dlen.usr_miso_dbitlen = miso_len ? (miso_len - 1) : 0;
SPIFLASH.user.usr_mosi = mosi_len > 0;
SPIFLASH.mosi_dlen.usr_mosi_dbitlen = mosi_len ? (mosi_len - 1) : 0;
SPIFLASH.data_buf[0] = mosi_data;
SPIFLASH.cmd.usr = 1;
while(SPIFLASH.cmd.usr != 0)
{ }
SPIFLASH.ctrl.val = old_ctrl_reg;
uint32_t ret = SPIFLASH.data_buf[0];
if (miso_len < 32) {
//set unused bits to 0
ret &= ~(UINT32_MAX << miso_len);
}
return ret;
}
#define XMC_VENDOR_ID 0x20
//use strict model checking for over-erase issue
static bool is_xmc_chip_strict(uint32_t rdid)
{
uint32_t vendor_id = (rdid >> 16) & 0xFF;
uint32_t mfid = (rdid >> 8) & 0xFF;
uint32_t cpid = rdid & 0xFF;
if (vendor_id != XMC_VENDOR_ID) {
return false;
}
bool matched = false;
if (mfid == 0x40) {
if (cpid >= 0x13 && cpid <= 0x20) {
matched = true;
}
} else if (mfid == 0x41) {
if (cpid >= 0x17 && cpid <= 0x20) {
matched = true;
}
} else if (mfid == 0x50) {
if (cpid >= 0x15 && cpid <= 0x16) {
matched = true;
}
}
return matched;
}
esp_err_t bootloader_xmc_flash_overerase_fix()
{
#if CONFIG_BOOTLOADER_FLASH_XMC_OVERERASE_PATCH_DEFAULT
//correct RDID value means the issue doesn't occur
if (is_xmc_chip_strict(g_rom_flashchip.device_id)) {
return ESP_OK;
}
#endif
// Check vendor ID in SFDP registers. If not XMC chip, no need to run the patch
uint8_t mf_id = (bootloader_flash_read_sfdp(0x10, 1) & 0xff);
if (mf_id != XMC_VENDOR_ID) {
return ESP_OK;
}
ESP_LOGI(TAG, "XM25QHxxC flash overerase fix");
// Enter DPD
execute_flash_command(0xB9, 0, 0, 0);
// Enter UDPD
execute_flash_command(0x79, 0, 0, 0);
// Exit UDPD
execute_flash_command(0xFF, 0, 0, 0);
// Delay tXUDPD
ets_delay_us(2000);
// Release Power-down
execute_flash_command(0xAB, 0, 0, 0);
ets_delay_us(20);
// Read flash ID and check
g_rom_flashchip.device_id = bootloader_read_flash_id();
if (!is_xmc_chip_strict(g_rom_flashchip.device_id)) {
// fail
ESP_LOGE(TAG, "XM25QH32C flash overerase fix fail");
return ESP_FAIL;
}
return ESP_OK;
}

View File

@ -56,6 +56,10 @@ esp_err_t esp_secure_boot_verify_signature(uint32_t src_addr, uint32_t length)
esp_err_t esp_secure_boot_verify_signature_block(const esp_secure_boot_sig_block_t *sig_block, const uint8_t *image_digest)
{
#if !(defined(CONFIG_MBEDTLS_ECDSA_C) && defined(CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED))
ESP_LOGE(TAG, "Signature verification requires ECDSA & SECP256R1 curve enabled");
return ESP_ERR_NOT_SUPPORTED;
#else
ptrdiff_t keylen;
keylen = signature_verification_key_end - signature_verification_key_start;
@ -117,4 +121,5 @@ cleanup:
mbedtls_mpi_free(&s);
mbedtls_ecdsa_free(&ecdsa_context);
return ret == 0 ? ESP_OK : ESP_ERR_IMAGE_INVALID;
#endif // CONFIG_MBEDTLS_ECDSA_C && CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED
}

View File

@ -289,20 +289,30 @@ if(CONFIG_BT_ENABLED)
"host/bluedroid/stack/smp/smp_l2c.c"
"host/bluedroid/stack/smp/smp_main.c"
"host/bluedroid/stack/smp/smp_utils.c")
if(CONFIG_BLE_MESH)
list(APPEND srcs "esp_ble_mesh/mesh_core/bluedroid_host/mesh_bearer_adapt.c")
endif()
endif()
if(CONFIG_BLE_MESH)
list(APPEND include_dirs
"esp_ble_mesh/mesh_common/include"
"esp_ble_mesh/mesh_common/tinycrypt/include"
"esp_ble_mesh/mesh_core"
"esp_ble_mesh/mesh_core/include"
"esp_ble_mesh/mesh_core/settings"
"esp_ble_mesh/mesh_core/storage"
"esp_ble_mesh/btc/include"
"esp_ble_mesh/mesh_models/include"
"esp_ble_mesh/mesh_models/common/include"
"esp_ble_mesh/mesh_models/client/include"
"esp_ble_mesh/mesh_models/server/include"
"esp_ble_mesh/api/core/include"
"esp_ble_mesh/api/models/include"
"esp_ble_mesh/api")
list(APPEND srcs "esp_ble_mesh/api/core/esp_ble_mesh_common_api.c"
list(APPEND srcs "esp_ble_mesh/api/core/esp_ble_mesh_ble_api.c"
"esp_ble_mesh/api/core/esp_ble_mesh_common_api.c"
"esp_ble_mesh/api/core/esp_ble_mesh_local_data_operation_api.c"
"esp_ble_mesh/api/core/esp_ble_mesh_low_power_api.c"
"esp_ble_mesh/api/core/esp_ble_mesh_networking_api.c"
@ -321,41 +331,64 @@ if(CONFIG_BT_ENABLED)
"esp_ble_mesh/btc/btc_ble_mesh_prov.c"
"esp_ble_mesh/btc/btc_ble_mesh_sensor_model.c"
"esp_ble_mesh/btc/btc_ble_mesh_time_scene_model.c"
"esp_ble_mesh/mesh_core/settings/settings_nvs.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/aes_decrypt.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/aes_encrypt.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/cbc_mode.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/ccm_mode.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/cmac_mode.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/ctr_mode.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/ctr_prng.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/ecc_dh.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/ecc_dsa.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/ecc_platform_specific.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/ecc.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/hmac_prng.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/hmac.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/sha256.c"
"esp_ble_mesh/mesh_common/tinycrypt/src/utils.c"
"esp_ble_mesh/mesh_common/mesh_atomic.c"
"esp_ble_mesh/mesh_common/mesh_buf.c"
"esp_ble_mesh/mesh_common/mesh_common.c"
"esp_ble_mesh/mesh_common/mesh_kernel.c"
"esp_ble_mesh/mesh_common/mesh_mutex.c"
"esp_ble_mesh/mesh_common/mesh_timer.c"
"esp_ble_mesh/mesh_common/mesh_util.c"
"esp_ble_mesh/mesh_core/storage/settings_nvs.c"
"esp_ble_mesh/mesh_core/access.c"
"esp_ble_mesh/mesh_core/adv.c"
"esp_ble_mesh/mesh_core/beacon.c"
"esp_ble_mesh/mesh_core/cfg_cli.c"
"esp_ble_mesh/mesh_core/cfg_srv.c"
"esp_ble_mesh/mesh_core/crypto.c"
"esp_ble_mesh/mesh_core/fast_prov.c"
"esp_ble_mesh/mesh_core/friend.c"
"esp_ble_mesh/mesh_core/health_cli.c"
"esp_ble_mesh/mesh_core/health_srv.c"
"esp_ble_mesh/mesh_core/local_operation.c"
"esp_ble_mesh/mesh_core/lpn.c"
"esp_ble_mesh/mesh_core/mesh_aes_encrypt.c"
"esp_ble_mesh/mesh_core/mesh_atomic.c"
"esp_ble_mesh/mesh_core/mesh_bearer_adapt.c"
"esp_ble_mesh/mesh_core/mesh_buf.c"
"esp_ble_mesh/mesh_core/mesh_hci.c"
"esp_ble_mesh/mesh_core/mesh_kernel.c"
"esp_ble_mesh/mesh_core/mesh_main.c"
"esp_ble_mesh/mesh_core/mesh_util.c"
"esp_ble_mesh/mesh_core/main.c"
"esp_ble_mesh/mesh_core/net.c"
"esp_ble_mesh/mesh_core/prov.c"
"esp_ble_mesh/mesh_core/provisioner_beacon.c"
"esp_ble_mesh/mesh_core/provisioner_main.c"
"esp_ble_mesh/mesh_core/provisioner_prov.c"
"esp_ble_mesh/mesh_core/provisioner_proxy.c"
"esp_ble_mesh/mesh_core/proxy.c"
"esp_ble_mesh/mesh_core/proxy_client.c"
"esp_ble_mesh/mesh_core/proxy_server.c"
"esp_ble_mesh/mesh_core/settings.c"
"esp_ble_mesh/mesh_core/test.c"
"esp_ble_mesh/mesh_core/transport.c"
"esp_ble_mesh/mesh_models/generic_client.c"
"esp_ble_mesh/mesh_models/lighting_client.c"
"esp_ble_mesh/mesh_models/mesh_common.c"
"esp_ble_mesh/mesh_models/model_common.c"
"esp_ble_mesh/mesh_models/sensor_client.c"
"esp_ble_mesh/mesh_models/time_scene_client.c")
"esp_ble_mesh/mesh_models/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"
"esp_ble_mesh/mesh_models/server/server_common.c"
"esp_ble_mesh/mesh_models/server/state_binding.c"
"esp_ble_mesh/mesh_models/server/state_transition.c"
"esp_ble_mesh/mesh_models/server/time_scene_server.c")
endif()
if(CONFIG_BT_NIMBLE_ENABLED)
@ -376,9 +409,13 @@ if(CONFIG_BT_ENABLED)
host/nimble/nimble/nimble/host/store/ram/include
host/nimble/nimble/nimble/host/store/config/include
host/nimble/nimble/porting/npl/freertos/include
host/nimble/nimble/ext/tinycrypt/include
host/nimble/esp-hci/include)
if(NOT CONFIG_BT_NIMBLE_CRYPTO_STACK_MBEDTLS)
list(APPEND include_dirs
host/nimble/nimble/ext/tinycrypt/include)
list(APPEND srcs "host/nimble/nimble/ext/tinycrypt/src/utils.c"
"host/nimble/nimble/ext/tinycrypt/src/sha256.c"
"host/nimble/nimble/ext/tinycrypt/src/ecc.c"
@ -393,8 +430,10 @@ if(CONFIG_BT_ENABLED)
"host/nimble/nimble/ext/tinycrypt/src/hmac_prng.c"
"host/nimble/nimble/ext/tinycrypt/src/ecc_platform_specific.c"
"host/nimble/nimble/ext/tinycrypt/src/hmac.c"
"host/nimble/nimble/ext/tinycrypt/src/cbc_mode.c"
"host/nimble/nimble/nimble/host/util/src/addr.c"
"host/nimble/nimble/ext/tinycrypt/src/cbc_mode.c")
endif()
list(APPEND srcs "host/nimble/nimble/nimble/host/util/src/addr.c"
"host/nimble/nimble/nimble/host/services/gatt/src/ble_svc_gatt.c"
"host/nimble/nimble/nimble/host/services/tps/src/ble_svc_tps.c"
"host/nimble/nimble/nimble/host/services/ias/src/ble_svc_ias.c"
@ -445,6 +484,7 @@ if(CONFIG_BT_ENABLED)
"host/nimble/nimble/nimble/host/src/ble_hs_adv.c"
"host/nimble/nimble/nimble/host/src/ble_hs_hci.c"
"host/nimble/nimble/nimble/host/src/ble_hs_hci_util.c"
"host/nimble/nimble/nimble/host/src/ble_hs_resolv.c"
"host/nimble/nimble/nimble/host/store/ram/src/ble_store_ram.c"
"host/nimble/nimble/nimble/host/store/config/src/ble_store_config.c"
"host/nimble/nimble/nimble/host/store/config/src/ble_store_nvs.c"
@ -460,7 +500,12 @@ if(CONFIG_BT_ENABLED)
"host/nimble/nimble/porting/nimble/src/mem.c"
"host/nimble/nimble/porting/nimble/src/os_mbuf.c"
"host/nimble/nimble/porting/nimble/src/os_cputime.c"
"host/nimble/esp-hci/src/esp_nimble_hci.c")
"host/nimble/esp-hci/src/esp_nimble_hci.c"
"host/nimble/port/src/esp_nimble_mem.c")
if (CONFIG_BLE_MESH)
list(APPEND srcs "esp_ble_mesh/mesh_core/nimble_host/mesh_bearer_adapt.c")
endif()
if(CONFIG_BT_NIMBLE_MESH)

View File

@ -1,4 +1,4 @@
menu Bluetooth
menu "Bluetooth"
config BT_ENABLED
bool "Bluetooth"
@ -77,6 +77,33 @@ menu Bluetooth
default 1 if BTDM_CTRL_BR_EDR_SCO_DATA_PATH_PCM
default 0
config BTDM_CTRL_AUTO_LATENCY
bool "Auto latency"
depends on BTDM_CTRL_MODE_BTDM
default n
help
BLE auto latency, used to enhance classic BT performance
while classic BT and BLE are enabled at the same time.
config BTDM_CTRL_AUTO_LATENCY_EFF
bool
default BTDM_CTRL_AUTO_LATENCY if BTDM_CTRL_MODE_BTDM
default n
config BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT
bool "Legacy Authentication Vendor Specific Event Enable"
depends on BTDM_CTRL_MODE_BR_EDR_ONLY || BTDM_CTRL_MODE_BTDM
default y
help
To protect from BIAS attack during Legacy authentication,
Legacy authentication Vendor specific event should be enabled
config BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT_EFF
bool
default BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT if BTDM_CTRL_MODE_BR_EDR_ONLY || BTDM_CTRL_MODE_BTDM
default 0
config BTDM_CTRL_BLE_MAX_CONN_EFF
int
default BTDM_CTRL_BLE_MAX_CONN if BTDM_CTRL_MODE_BLE_ONLY || BTDM_CTRL_MODE_BTDM
@ -318,8 +345,8 @@ menu Bluetooth
config BTDM_CTRL_FULL_SCAN_SUPPORTED
bool "BLE full scan feature supported"
depends on BTDM_CTRL_MODE_BLE_ONLY
default n
depends on BTDM_CTRL_MODE_BLE_ONLY || BTDM_CTRL_MODE_BTDM
default y
help
The full scan function is mainly used to provide BLE scan performance.
This is required for scenes with high scan performance requirements, such as BLE Mesh scenes.
@ -358,6 +385,21 @@ menu Bluetooth
If you set `BTDM_BLE_ADV_REPORT_DISCARD_THRSHOLD` to a small value or printf every adv lost event, it
may cause adv packets lost more.
menuconfig BTDM_COEX_BT_OPTIONS
bool "Coexistence Bluetooth Side Options"
depends on ESP32_WIFI_SW_COEXIST_ENABLE
default n
help
Options of Bluetooth Side of WiFi and bluetooth coexistence.
config BTDM_COEX_BLE_ADV_HIGH_PRIORITY
bool "Improve BLE ADV priority for WiFi & BLE coexistence"
depends on BTDM_COEX_BT_OPTIONS
default n
help
Improve BLE ADV coexistence priority to make it better performance.
For example, BLE mesh need to enable this option to improve BLE adv performance.
endmenu
choice BT_HOST
@ -378,6 +420,13 @@ menu Bluetooth
help
This option is recommended for BLE only usecases to save on memory
config BT_CONTROLLER_ONLY
bool "Controller Only"
help
This option is recommended when you want to communicate directly with the
controller (without any host) or when you are using any other host stack
not supported by Espressif (not mentioned here).
endchoice
menu "Bluedroid Options"
@ -395,7 +444,6 @@ endmenu
menuconfig BLE_MESH
bool "ESP BLE Mesh Support"
depends on BT_BLUEDROID_ENABLED
help
This option enables ESP BLE Mesh support. The specific features that are
available may depend on other features that have been enabled in the

View File

@ -19,6 +19,7 @@
#include "esp_log.h"
#include "bt_common.h"
#include "osi/allocator.h"
#include "btc/btc_alarm.h"
#ifdef CONFIG_BT_BLUEDROID_ENABLED
#include "common/bt_target.h"
@ -32,7 +33,6 @@
#include "btc_blufi_prf.h"
#include "blufi_int.h"
#include "btc/btc_dm.h"
#include "btc/btc_alarm.h"
#include "bta/bta_gatt_api.h"
#if CLASSIC_BT_INCLUDED
#include "btc/btc_profile_queue.h"
@ -94,7 +94,9 @@ static const btc_func_t profile_tab[BTC_PID_NUM] = {
[BTC_PID_BLUFI] = {btc_blufi_call_handler, btc_blufi_cb_handler },
#endif ///GATTS_INCLUDED == TRUE
[BTC_PID_DM_SEC] = {NULL, btc_dm_sec_cb_handler },
#endif
[BTC_PID_ALARM] = {btc_alarm_handler, NULL },
#ifdef CONFIG_BT_BLUEDROID_ENABLED
#if CLASSIC_BT_INCLUDED
#if (BTC_GAP_BT_INCLUDED == TRUE)
[BTC_PID_GAP_BT] = {btc_gap_bt_call_handler, btc_gap_bt_cb_handler },
@ -114,16 +116,20 @@ static const btc_func_t profile_tab[BTC_PID_NUM] = {
#endif /* #if CLASSIC_BT_INCLUDED */
#endif
#if CONFIG_BLE_MESH
[BTC_PID_PROV] = {btc_mesh_prov_call_handler, btc_mesh_prov_cb_handler},
[BTC_PID_MODEL] = {btc_mesh_model_call_handler, btc_mesh_model_cb_handler},
[BTC_PID_HEALTH_CLIENT] = {btc_mesh_health_client_call_handler, btc_mesh_health_client_cb_handler},
[BTC_PID_HEALTH_SERVER] = {btc_mesh_health_server_call_handler, btc_mesh_health_server_cb_handler},
[BTC_PID_CFG_CLIENT] = {btc_mesh_cfg_client_call_handler, btc_mesh_cfg_client_cb_handler},
[BTC_PID_CFG_SERVER] = {NULL , btc_mesh_cfg_server_cb_handler},
[BTC_PID_GENERIC_CLIENT] = {btc_mesh_generic_client_call_handler, btc_mesh_generic_client_cb_handler},
[BTC_PID_LIGHT_CLIENT] = {btc_mesh_light_client_call_handler, btc_mesh_light_client_cb_handler},
[BTC_PID_SENSOR_CLIENT] = {btc_mesh_sensor_client_call_handler, btc_mesh_sensor_client_cb_handler},
[BTC_PID_TIME_SCENE_CLIENT] = {btc_mesh_time_scene_client_call_handler, btc_mesh_time_scene_client_cb_handler},
[BTC_PID_PROV] = {btc_ble_mesh_prov_call_handler, btc_ble_mesh_prov_cb_handler },
[BTC_PID_MODEL] = {btc_ble_mesh_model_call_handler, btc_ble_mesh_model_cb_handler },
[BTC_PID_HEALTH_CLIENT] = {btc_ble_mesh_health_client_call_handler, btc_ble_mesh_health_client_cb_handler },
[BTC_PID_HEALTH_SERVER] = {btc_ble_mesh_health_server_call_handler, btc_ble_mesh_health_server_cb_handler },
[BTC_PID_CONFIG_CLIENT] = {btc_ble_mesh_config_client_call_handler, btc_ble_mesh_config_client_cb_handler },
[BTC_PID_CONFIG_SERVER] = {NULL, btc_ble_mesh_config_server_cb_handler },
[BTC_PID_GENERIC_CLIENT] = {btc_ble_mesh_generic_client_call_handler, btc_ble_mesh_generic_client_cb_handler },
[BTC_PID_LIGHTING_CLIENT] = {btc_ble_mesh_lighting_client_call_handler, btc_ble_mesh_lighting_client_cb_handler },
[BTC_PID_SENSOR_CLIENT] = {btc_ble_mesh_sensor_client_call_handler, btc_ble_mesh_sensor_client_cb_handler },
[BTC_PID_TIME_SCENE_CLIENT] = {btc_ble_mesh_time_scene_client_call_handler, btc_ble_mesh_time_scene_client_cb_handler},
[BTC_PID_GENERIC_SERVER] = {NULL, btc_ble_mesh_generic_server_cb_handler },
[BTC_PID_LIGHTING_SERVER] = {NULL, btc_ble_mesh_lighting_server_cb_handler },
[BTC_PID_SENSOR_SERVER] = {NULL, btc_ble_mesh_sensor_server_cb_handler },
[BTC_PID_TIME_SCENE_SERVER] = {NULL, btc_ble_mesh_time_scene_server_cb_handler},
#endif /* #if CONFIG_BLE_MESH */
};
@ -321,7 +327,7 @@ error_exit:;
int btc_init(void)
{
btc_thread = osi_thread_create("BTC_TASK", BTC_TASK_STACK_SIZE, BTC_TASK_PRIO, BTC_TASK_PINNED_TO_CORE, 3);
btc_thread = osi_thread_create("BTC_TASK", BTC_TASK_STACK_SIZE, BTC_TASK_PRIO, BTC_TASK_PINNED_TO_CORE, 2);
if (btc_thread == NULL) {
return BT_STATUS_NOMEM;
}

View File

@ -15,9 +15,7 @@
#ifndef __BTC_MANAGE_H__
#define __BTC_MANAGE_H__
#include "bta/bta_api.h"
#include "btc/btc_task.h"
#include "esp_bt_defs.h"
#if BTC_DYNAMIC_MEMORY == FALSE
extern void *btc_profile_cb_tab[BTC_PID_NUM];

View File

@ -72,12 +72,16 @@ typedef enum {
BTC_PID_MODEL,
BTC_PID_HEALTH_CLIENT,
BTC_PID_HEALTH_SERVER,
BTC_PID_CFG_CLIENT,
BTC_PID_CFG_SERVER,
BTC_PID_CONFIG_CLIENT,
BTC_PID_CONFIG_SERVER,
BTC_PID_GENERIC_CLIENT,
BTC_PID_LIGHT_CLIENT,
BTC_PID_LIGHTING_CLIENT,
BTC_PID_SENSOR_CLIENT,
BTC_PID_TIME_SCENE_CLIENT,
BTC_PID_GENERIC_SERVER,
BTC_PID_LIGHTING_SERVER,
BTC_PID_SENSOR_SERVER,
BTC_PID_TIME_SCENE_SERVER,
#endif /* CONFIG_BLE_MESH */
BTC_PID_NUM,
} btc_pid_t; //btc profile id

View File

@ -49,7 +49,7 @@
#ifdef CONFIG_BTC_TASK_STACK_SIZE
#define UC_BTC_TASK_STACK_SIZE CONFIG_BTC_TASK_STACK_SIZE
#else
#define UC_BTC_TASK_STACK_SIZE 3072
#define UC_BTC_TASK_STACK_SIZE 4096
#endif
/**********************************************************

View File

@ -267,6 +267,7 @@ bool config_remove_key(config_t *config, const char *section, const char *key)
assert(config != NULL);
assert(section != NULL);
assert(key != NULL);
bool ret;
section_t *sec = section_find(config, section);
entry_t *entry = entry_find(config, section, key);
@ -274,7 +275,12 @@ bool config_remove_key(config_t *config, const char *section, const char *key)
return false;
}
return list_remove(sec->entries, entry);
ret = list_remove(sec->entries, entry);
if (list_length(sec->entries) == 0) {
OSI_TRACE_DEBUG("%s remove section name:%s",__func__, section);
ret &= config_remove_section(config, section);
}
return ret;
}
const config_section_node_t *config_section_begin(const config_t *config)
@ -389,7 +395,7 @@ bool config_save(const config_t *config, const char *filename)
const size_t keyname_bufsz = sizeof(CONFIG_KEY) + 5 + 1; // including log10(sizeof(i))
char *keyname = osi_calloc(keyname_bufsz);
int config_size = get_config_size(config);
char *buf = osi_calloc(config_size + 100);
char *buf = osi_calloc(config_size);
if (!line || !buf || !keyname) {
err_code |= 0x01;
goto error;
@ -409,6 +415,16 @@ bool config_save(const config_t *config, const char *filename)
for (const list_node_t *node = list_begin(config->sections); node != list_end(config->sections); node = list_next(node)) {
const section_t *section = (const section_t *)list_node(node);
w_cnt = snprintf(line, 1024, "[%s]\n", section->name);
if(w_cnt < 0) {
OSI_TRACE_ERROR("snprintf error w_cnt %d.",w_cnt);
err_code |= 0x10;
goto error;
}
if(w_cnt_total + w_cnt > config_size) {
OSI_TRACE_ERROR("%s, memcpy size (w_cnt + w_cnt_total = %d) is larger than buffer size (config_size = %d).", __func__, (w_cnt + w_cnt_total), config_size);
err_code |= 0x20;
goto error;
}
OSI_TRACE_DEBUG("section name: %s, w_cnt + w_cnt_total = %d\n", section->name, w_cnt + w_cnt_total);
memcpy(buf + w_cnt_total, line, w_cnt);
w_cnt_total += w_cnt;
@ -417,6 +433,16 @@ bool config_save(const config_t *config, const char *filename)
const entry_t *entry = (const entry_t *)list_node(enode);
OSI_TRACE_DEBUG("(key, val): (%s, %s)\n", entry->key, entry->value);
w_cnt = snprintf(line, 1024, "%s = %s\n", entry->key, entry->value);
if(w_cnt < 0) {
OSI_TRACE_ERROR("snprintf error w_cnt %d.",w_cnt);
err_code |= 0x10;
goto error;
}
if(w_cnt_total + w_cnt > config_size) {
OSI_TRACE_ERROR("%s, memcpy size (w_cnt + w_cnt_total = %d) is larger than buffer size.(config_size = %d)", __func__, (w_cnt + w_cnt_total), config_size);
err_code |= 0x20;
goto error;
}
OSI_TRACE_DEBUG("%s, w_cnt + w_cnt_total = %d", __func__, w_cnt + w_cnt_total);
memcpy(buf + w_cnt_total, line, w_cnt);
w_cnt_total += w_cnt;
@ -524,7 +550,10 @@ static void config_parse(nvs_handle_t fp, config_t *config)
const size_t keyname_bufsz = sizeof(CONFIG_KEY) + 5 + 1; // including log10(sizeof(i))
char *keyname = osi_calloc(keyname_bufsz);
int buf_size = get_config_size_from_flash(fp);
char *buf = osi_calloc(buf_size + 100);
char *buf = osi_calloc(buf_size);
if(buf_size == 0) { //First use nvs
goto error;
}
if (!line || !section || !buf || !keyname) {
err_code |= 0x01;
goto error;

View File

@ -129,6 +129,8 @@ size_t fixed_queue_capacity(fixed_queue_t *queue)
bool fixed_queue_enqueue(fixed_queue_t *queue, void *data, uint32_t timeout)
{
bool status=false; //Flag whether enqueued success
assert(queue != NULL);
assert(data != NULL);
@ -137,13 +139,13 @@ bool fixed_queue_enqueue(fixed_queue_t *queue, void *data, uint32_t timeout)
}
osi_mutex_lock(&queue->lock, OSI_MUTEX_MAX_TIMEOUT);
list_append(queue->list, data);
status = list_append(queue->list, data); //Check whether enqueued success
osi_mutex_unlock(&queue->lock);
osi_sem_give(&queue->dequeue_sem);
if(status == true )
osi_sem_give(&queue->dequeue_sem);
return true;
return status;
}
void *fixed_queue_dequeue(fixed_queue_t *queue, uint32_t timeout)
@ -152,7 +154,7 @@ void *fixed_queue_dequeue(fixed_queue_t *queue, uint32_t timeout)
assert(queue != NULL);
if (osi_sem_take(queue->dequeue_sem, timeout) != 0) {
if (osi_sem_take(&queue->dequeue_sem, timeout) != 0) {
return NULL;
}
@ -206,14 +208,14 @@ void *fixed_queue_try_remove_from_queue(fixed_queue_t *queue, void *data)
osi_mutex_lock(&queue->lock, OSI_MUTEX_MAX_TIMEOUT);
if (list_contains(queue->list, data) &&
osi_sem_take(queue->dequeue_sem, 0) == 0) {
osi_sem_take(&queue->dequeue_sem, 0) == 0) {
removed = list_remove(queue->list, data);
assert(removed);
}
osi_mutex_unlock(&queue->lock);
if (removed) {
osi_sem_give(queue->enqueue_sem);
osi_sem_give(&queue->enqueue_sem);
return data;
}

View File

@ -102,6 +102,7 @@ bool list_insert_after(list_t *list, list_node_t *prev_node, void *data) {
assert(data != NULL);
list_node_t *node = (list_node_t *)osi_calloc(sizeof(list_node_t));
if (!node) {
OSI_TRACE_ERROR("%s osi_calloc failed.\n", __FUNCTION__ );
return false;
}
node->next = prev_node->next;
@ -120,6 +121,7 @@ bool list_prepend(list_t *list, void *data)
assert(data != NULL);
list_node_t *node = (list_node_t *)osi_calloc(sizeof(list_node_t));
if (!node) {
OSI_TRACE_ERROR("%s osi_calloc failed.\n", __FUNCTION__ );
return false;
}
node->next = list->head;
@ -138,6 +140,7 @@ bool list_append(list_t *list, void *data)
assert(data != NULL);
list_node_t *node = (list_node_t *)osi_calloc(sizeof(list_node_t));
if (!node) {
OSI_TRACE_ERROR("%s osi_calloc failed.\n", __FUNCTION__ );
return false;
}
node->next = NULL;

View File

@ -129,28 +129,41 @@ COMPONENT_PRIV_INCLUDEDIRS += common/btc/include \
COMPONENT_SRCDIRS += common/osi \
common/btc/core
ifdef CONFIG_BLE_MESH
COMPONENT_SRCDIRS += esp_ble_mesh/mesh_core/bluedroid_host
endif
endif
ifdef CONFIG_BLE_MESH
COMPONENT_ADD_INCLUDEDIRS += esp_ble_mesh/mesh_core \
esp_ble_mesh/mesh_core/include \
esp_ble_mesh/mesh_core/settings \
esp_ble_mesh/btc/include \
esp_ble_mesh/mesh_models/include \
esp_ble_mesh/api/core/include \
esp_ble_mesh/api/models/include \
esp_ble_mesh/api
COMPONENT_ADD_INCLUDEDIRS += esp_ble_mesh/mesh_common/include \
esp_ble_mesh/mesh_common/tinycrypt/include \
esp_ble_mesh/mesh_core \
esp_ble_mesh/mesh_core/include \
esp_ble_mesh/mesh_core/storage \
esp_ble_mesh/btc/include \
esp_ble_mesh/mesh_models/common/include \
esp_ble_mesh/mesh_models/client/include \
esp_ble_mesh/mesh_models/server/include \
esp_ble_mesh/api/core/include \
esp_ble_mesh/api/models/include \
esp_ble_mesh/api
COMPONENT_SRCDIRS += esp_ble_mesh/mesh_core \
esp_ble_mesh/mesh_core/settings \
esp_ble_mesh/btc \
esp_ble_mesh/mesh_models \
esp_ble_mesh/api/core \
esp_ble_mesh/api/models
COMPONENT_SRCDIRS += esp_ble_mesh/mesh_common \
esp_ble_mesh/mesh_common/tinycrypt/src \
esp_ble_mesh/mesh_core \
esp_ble_mesh/mesh_core/storage \
esp_ble_mesh/btc \
esp_ble_mesh/mesh_models/client \
esp_ble_mesh/mesh_models/server \
esp_ble_mesh/api/core \
esp_ble_mesh/api/models
endif
ifdef CONFIG_BT_NIMBLE_ENABLED
COMPONENT_ADD_INCLUDEDIRS += host/nimble/nimble/nimble/include \
host/nimble/nimble/nimble/host/include \
host/nimble/nimble/porting/nimble/include \
@ -165,14 +178,16 @@ COMPONENT_ADD_INCLUDEDIRS += host/nimble/nimble/nimble/include
host/nimble/nimble/nimble/host/util/include \
host/nimble/nimble/nimble/host/store/ram/include \
host/nimble/nimble/nimble/host/store/config/include \
host/nimble/nimble/ext/tinycrypt/include \
host/nimble/esp-hci/include \
host/nimble/port/include
ifndef CONFIG_BT_NIMBLE_CRYPTO_STACK_MBEDTLS
COMPONENT_ADD_INCLUDEDIRS += host/nimble/nimble/ext/tinycrypt/include
endif
COMPONENT_SRCDIRS += host/nimble/nimble/nimble/host/src \
host/nimble/nimble/porting/nimble/src \
host/nimble/nimble/porting/npl/freertos/src \
host/nimble/nimble/ext/tinycrypt/src \
host/nimble/nimble/nimble/host/services/ans/src \
host/nimble/nimble/nimble/host/services/bas/src \
host/nimble/nimble/nimble/host/services/gap/src \
@ -183,10 +198,26 @@ COMPONENT_SRCDIRS += host/nimble/nimble/nimble/host/src
host/nimble/nimble/nimble/host/util/src \
host/nimble/nimble/nimble/host/store/ram/src \
host/nimble/nimble/nimble/host/store/config/src \
host/nimble/esp-hci/src
host/nimble/esp-hci/src \
host/nimble/port/src
ifndef CONFIG_BT_NIMBLE_CRYPTO_STACK_MBEDTLS
COMPONENT_SRCDIRS += host/nimble/nimble/ext/tinycrypt/src
endif
COMPONENT_OBJEXCLUDE += host/nimble/nimble/nimble/host/store/config/src/ble_store_config_conf.o
ifdef CONFIG_BLE_MESH
COMPONENT_PRIV_INCLUDEDIRS += common/btc/include \
common/include
COMPONENT_SRCDIRS += common/osi \
common/btc/core \
esp_ble_mesh/mesh_core/nimble_host
COMPONENT_ADD_INCLUDEDIRS += common/osi/include
endif
ifdef CONFIG_BT_NIMBLE_MESH
COMPONENT_ADD_INCLUDEDIRS += host/nimble/nimble/nimble/host/mesh/include

View File

@ -37,13 +37,14 @@
#include "esp_err.h"
#include "esp_log.h"
#include "esp_pm.h"
#include "esp_ipc.h"
#include "driver/periph_ctrl.h"
#include "soc/rtc.h"
#include "soc/soc_memory_layout.h"
#include "esp32/clk.h"
#include "esp_coexist_internal.h"
#if !CONFIG_FREERTOS_UNICORE
#include "esp_ipc.h"
#endif
#if CONFIG_BT_ENABLED
@ -78,14 +79,6 @@
#define BTDM_MIN_SLEEP_DURATION (12) // threshold of interval in slots to allow to fall into modem sleep
#define BTDM_MODEM_WAKE_UP_DELAY (4) // delay in slots of modem wake up procedure, including re-enable PHY/RF
#ifdef CONFIG_PM_ENABLE
#ifndef CONFIG_BTDM_LPCLK_SEL_MAIN_XTAL
#define BTDM_ALLOW_LIGHT_SLEEP 1
#else
#define BTDM_ALLOW_LIGHT_SLEEP 0
#endif
#endif
#define BT_DEBUG(...)
#define BT_API_CALL_CHECK(info, api_call, ret) \
do{\
@ -97,7 +90,7 @@ do{\
} while(0)
#define OSI_FUNCS_TIME_BLOCKING 0xffffffff
#define OSI_VERSION 0x00010001
#define OSI_VERSION 0x00010002
#define OSI_MAGIC_VALUE 0xFADEBEAD
/* SPIRAM Configuration */
@ -174,6 +167,8 @@ struct osi_funcs_t {
void (* _btdm_sleep_exit_phase1)(void); /* called from ISR */
void (* _btdm_sleep_exit_phase2)(void); /* called from ISR */
void (* _btdm_sleep_exit_phase3)(void); /* called from task */
bool (* _coex_bt_wakeup_request)(void);
void (* _coex_bt_wakeup_request_end)(void);
int (* _coex_bt_request)(uint32_t event, uint32_t latency, uint32_t duration);
int (* _coex_bt_release)(uint32_t event);
int (* _coex_register_bt_cb)(coex_func_cb_t cb);
@ -203,7 +198,8 @@ extern void btdm_controller_enable_sleep(bool enable);
extern void btdm_controller_set_sleep_mode(uint8_t mode);
extern uint8_t btdm_controller_get_sleep_mode(void);
extern bool btdm_power_state_active(void);
extern void btdm_wakeup_request(void);
extern void btdm_wakeup_request(bool request_lock);
extern void btdm_wakeup_request_end(void);
/* Low Power Clock */
extern bool btdm_lpclk_select_src(uint32_t sel);
extern bool btdm_lpclk_set_div(uint32_t div);
@ -224,6 +220,7 @@ extern int coex_bt_release_wrapper(uint32_t event);
extern int coex_register_bt_cb_wrapper(coex_func_cb_t cb);
extern uint32_t coex_bb_reset_lock_wrapper(void);
extern void coex_bb_reset_unlock_wrapper(uint32_t restore);
extern void coex_ble_adv_priority_high_set(bool high);
extern char _bss_start_btdm;
extern char _bss_end_btdm;
@ -287,6 +284,8 @@ static void btdm_sleep_enter_phase1_wrapper(uint32_t lpcycles);
static void btdm_sleep_enter_phase2_wrapper(void);
static void IRAM_ATTR btdm_sleep_exit_phase1_wrapper(void);
static void btdm_sleep_exit_phase3_wrapper(void);
static bool coex_bt_wakeup_request(void);
static void coex_bt_wakeup_request_end(void);
/* Local variable definition
***************************************************************************
@ -334,6 +333,8 @@ static const struct osi_funcs_t osi_funcs_ro = {
._btdm_sleep_exit_phase1 = btdm_sleep_exit_phase1_wrapper,
._btdm_sleep_exit_phase2 = NULL,
._btdm_sleep_exit_phase3 = btdm_sleep_exit_phase3_wrapper,
._coex_bt_wakeup_request = coex_bt_wakeup_request,
._coex_bt_wakeup_request_end = coex_bt_wakeup_request_end,
._coex_bt_request = coex_bt_request_wrapper,
._coex_bt_release = coex_bt_release_wrapper,
._coex_register_bt_cb = coex_register_bt_cb_wrapper,
@ -381,16 +382,21 @@ static DRAM_ATTR portMUX_TYPE global_int_mux = portMUX_INITIALIZER_UNLOCKED;
static DRAM_ATTR uint32_t btdm_lpcycle_us = 0;
static DRAM_ATTR uint8_t btdm_lpcycle_us_frac = 0; // number of fractional bit for btdm_lpcycle_us
#if CONFIG_BTDM_MODEM_SLEEP_MODE_ORIG
// used low power clock
static DRAM_ATTR uint8_t btdm_lpclk_sel;
#endif /* #ifdef CONFIG_BTDM_MODEM_SLEEP_MODE_ORIG */
#ifdef CONFIG_PM_ENABLE
static DRAM_ATTR esp_timer_handle_t s_btdm_slp_tmr;
static DRAM_ATTR esp_pm_lock_handle_t s_pm_lock;
static DRAM_ATTR QueueHandle_t s_pm_lock_sem = NULL;
#if !BTDM_ALLOW_LIGHT_SLEEP
static DRAM_ATTR bool s_btdm_allow_light_sleep;
// pm_lock to prevent light sleep when using main crystal as Bluetooth low power clock
static DRAM_ATTR esp_pm_lock_handle_t s_light_sleep_pm_lock;
#endif /* #if !BTDM_ALLOW_LIGHT_SLEEP */
static void btdm_slp_tmr_callback(void *arg);
#endif
#endif /* #ifdef CONFIG_PM_ENABLE */
static inline void btdm_check_and_init_bb(void)
{
@ -740,7 +746,7 @@ static void task_delete_wrapper(void *task_handle)
static bool IRAM_ATTR is_in_isr_wrapper(void)
{
return (bool)xPortInIsrContext();
return !xPortCanYield();
}
static void IRAM_ATTR cause_sw_intr(void *arg)
@ -754,18 +760,21 @@ static int IRAM_ATTR cause_sw_intr_to_core_wrapper(int core_id, int intr_no)
{
esp_err_t err = ESP_OK;
#if CONFIG_FREERTOS_UNICORE
cause_sw_intr((void *)intr_no);
#else /* CONFIG_FREERTOS_UNICORE */
if (xPortGetCoreID() == core_id) {
cause_sw_intr((void *)intr_no);
} else {
err = esp_ipc_call(core_id, cause_sw_intr, (void *)intr_no);
}
#endif /* !CONFIG_FREERTOS_UNICORE */
return err;
}
static void *malloc_internal_wrapper(size_t size)
{
return heap_caps_malloc(size, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL);
return heap_caps_malloc(size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
}
static int32_t IRAM_ATTR read_mac_wrapper(uint8_t mac[6])
@ -886,13 +895,26 @@ static void IRAM_ATTR btdm_slp_tmr_callback(void *arg)
}
#endif
bool esp_vhci_host_check_send_available(void)
{
return API_vhci_host_check_send_available();
}
#define BTDM_ASYNC_WAKEUP_REQ_HCI 0
#define BTDM_ASYNC_WAKEUP_REQ_COEX 1
#define BTDM_ASYNC_WAKEUP_REQMAX 2
void esp_vhci_host_send_packet(uint8_t *data, uint16_t len)
static bool async_wakeup_request(int event)
{
bool request_lock = false;
switch (event) {
case BTDM_ASYNC_WAKEUP_REQ_HCI:
request_lock = true;
break;
case BTDM_ASYNC_WAKEUP_REQ_COEX:
request_lock = false;
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)) {
@ -900,9 +922,59 @@ void esp_vhci_host_send_packet(uint8_t *data, uint16_t len)
}
esp_timer_stop(s_btdm_slp_tmr);
#endif
btdm_wakeup_request();
do_wakeup_request = true;
btdm_wakeup_request(request_lock);
}
return do_wakeup_request;
}
static void async_wakeup_request_end(int event)
{
bool request_lock = false;
switch (event) {
case BTDM_ASYNC_WAKEUP_REQ_HCI:
request_lock = true;
break;
case BTDM_ASYNC_WAKEUP_REQ_COEX:
request_lock = false;
break;
default:
return;
}
if (request_lock) {
btdm_wakeup_request_end();
}
return;
}
static bool coex_bt_wakeup_request(void)
{
return async_wakeup_request(BTDM_ASYNC_WAKEUP_REQ_COEX);
}
static void coex_bt_wakeup_request_end(void)
{
async_wakeup_request_end(BTDM_ASYNC_WAKEUP_REQ_COEX);
return;
}
bool esp_vhci_host_check_send_available(void)
{
return API_vhci_host_check_send_available();
}
void esp_vhci_host_send_packet(uint8_t *data, uint16_t len)
{
bool do_wakeup_request = 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);
}
}
esp_err_t esp_vhci_host_register_callback(const esp_vhci_host_callback_t *callback)
@ -961,7 +1033,7 @@ static esp_err_t try_heap_caps_add_region(intptr_t start, intptr_t end)
esp_err_t esp_bt_controller_mem_release(esp_bt_mode_t mode)
{
bool update = true;
intptr_t mem_start, mem_end;
intptr_t mem_start=(intptr_t) NULL, mem_end=(intptr_t) NULL;
if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
return ESP_ERR_INVALID_STATE;
@ -1119,12 +1191,67 @@ 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
btdm_controller_mem_init();
periph_module_enable(PERIPH_BT_MODULE);
#ifdef CONFIG_PM_ENABLE
#if !BTDM_ALLOW_LIGHT_SLEEP
if ((err = esp_pm_lock_create(ESP_PM_NO_LIGHT_SLEEP, 0, "btLS", &s_light_sleep_pm_lock)) != ESP_OK) {
goto error;
s_btdm_allow_light_sleep = false;
#endif
// set default sleep clock cycle and its fractional bits
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
btdm_lpcycle_us = 2 << (btdm_lpcycle_us_frac);
#if CONFIG_BTDM_MODEM_SLEEP_MODE_ORIG
btdm_lpclk_sel = BTDM_LPCLK_SEL_XTAL; // set default value
#if CONFIG_BTDM_LPCLK_SEL_EXT_32K_XTAL
// check whether or not EXT_CRYS is working
if (rtc_clk_slow_freq_get() == RTC_SLOW_FREQ_32K_XTAL) {
btdm_lpclk_sel = BTDM_LPCLK_SEL_XTAL32K; // set default value
#ifdef CONFIG_PM_ENABLE
s_btdm_allow_light_sleep = true;
#endif
} else {
ESP_LOGW(BTDM_LOG_TAG, "32.768kHz XTAL not detected, fall back to main XTAL as Bluetooth sleep clock\n"
"light sleep mode will not be able to apply when bluetooth is enabled");
btdm_lpclk_sel = BTDM_LPCLK_SEL_XTAL; // set default value
}
#else
btdm_lpclk_sel = BTDM_LPCLK_SEL_XTAL; // set default value
#endif
bool select_src_ret, set_div_ret;
if (btdm_lpclk_sel == BTDM_LPCLK_SEL_XTAL) {
select_src_ret = btdm_lpclk_select_src(BTDM_LPCLK_SEL_XTAL);
set_div_ret = btdm_lpclk_set_div(rtc_clk_xtal_freq_get() * 2 - 1);
assert(select_src_ret && set_div_ret);
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
btdm_lpcycle_us = 2 << (btdm_lpcycle_us_frac);
} else { // btdm_lpclk_sel == BTDM_LPCLK_SEL_XTAL32K
select_src_ret = btdm_lpclk_select_src(BTDM_LPCLK_SEL_XTAL32K);
set_div_ret = btdm_lpclk_set_div(0);
assert(select_src_ret && set_div_ret);
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
btdm_lpcycle_us = (RTC_CLK_CAL_FRACT > 15) ? (1000000 << (RTC_CLK_CAL_FRACT - 15)) :
(1000000 >> (15 - RTC_CLK_CAL_FRACT));
assert(btdm_lpcycle_us != 0);
}
btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_ORIG);
#elif CONFIG_BTDM_MODEM_SLEEP_MODE_EVED
btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_EVED);
#else
btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_NONE);
#endif
#ifdef CONFIG_PM_ENABLE
if (!s_btdm_allow_light_sleep) {
if ((err = esp_pm_lock_create(ESP_PM_NO_LIGHT_SLEEP, 0, "btLS", &s_light_sleep_pm_lock)) != ESP_OK) {
goto error;
}
}
#endif /* #if !BTDM_ALLOW_LIGHT_SLEEP */
if ((err = esp_pm_lock_create(ESP_PM_APB_FREQ_MAX, 0, "bt", &s_pm_lock)) != ESP_OK) {
goto error;
}
@ -1144,37 +1271,6 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
}
#endif
btdm_controller_mem_init();
periph_module_enable(PERIPH_BT_MODULE);
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
btdm_lpcycle_us = 32 << btdm_lpcycle_us_frac;
#if CONFIG_BTDM_MODEM_SLEEP_MODE_ORIG
bool select_src_ret = false;
bool set_div_ret = false;
#if CONFIG_BTDM_LPCLK_SEL_MAIN_XTAL
select_src_ret = btdm_lpclk_select_src(BTDM_LPCLK_SEL_XTAL);
set_div_ret = btdm_lpclk_set_div(rtc_clk_xtal_freq_get() * 2 - 1);
assert(select_src_ret && set_div_ret);
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
btdm_lpcycle_us = 2 << (btdm_lpcycle_us_frac);
#elif CONFIG_BTDM_LPCLK_SEL_EXT_32K_XTAL
select_src_ret = btdm_lpclk_select_src(BTDM_LPCLK_SEL_XTAL32K);
set_div_ret = btdm_lpclk_set_div(0);
assert(select_src_ret && set_div_ret);
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
btdm_lpcycle_us = (RTC_CLK_CAL_FRACT > 15) ? (1000000 << (RTC_CLK_CAL_FRACT - 15)) :
(1000000 >> (15 - RTC_CLK_CAL_FRACT));
assert(btdm_lpcycle_us != 0);
#endif // CONFIG_BTDM_LPCLK_SEL_XX
btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_ORIG);
#elif CONFIG_BTDM_MODEM_SLEEP_MODE_EVED
btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_EVED);
#else
btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_NONE);
#endif
btdm_cfg_mask = btdm_config_mask_load();
if (btdm_controller_init(btdm_cfg_mask, cfg) != 0) {
@ -1182,18 +1278,24 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
goto error;
}
#ifdef CONFIG_BTDM_COEX_BLE_ADV_HIGH_PRIORITY
coex_ble_adv_priority_high_set(true);
#else
coex_ble_adv_priority_high_set(false);
#endif
btdm_controller_status = ESP_BT_CONTROLLER_STATUS_INITED;
return ESP_OK;
error:
#ifdef CONFIG_PM_ENABLE
#if !BTDM_ALLOW_LIGHT_SLEEP
if (s_light_sleep_pm_lock != NULL) {
esp_pm_lock_delete(s_light_sleep_pm_lock);
s_light_sleep_pm_lock = NULL;
if (!s_btdm_allow_light_sleep) {
if (s_light_sleep_pm_lock != NULL) {
esp_pm_lock_delete(s_light_sleep_pm_lock);
s_light_sleep_pm_lock = NULL;
}
}
#endif /* #if !BTDM_ALLOW_LIGHT_SLEEP */
if (s_pm_lock != NULL) {
esp_pm_lock_delete(s_pm_lock);
s_pm_lock = NULL;
@ -1221,10 +1323,10 @@ esp_err_t esp_bt_controller_deinit(void)
periph_module_disable(PERIPH_BT_MODULE);
#ifdef CONFIG_PM_ENABLE
#if !BTDM_ALLOW_LIGHT_SLEEP
esp_pm_lock_delete(s_light_sleep_pm_lock);
s_light_sleep_pm_lock = NULL;
#endif /* #if !BTDM_ALLOW_LIGHT_SLEEP */
if (!s_btdm_allow_light_sleep) {
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);
@ -1265,9 +1367,9 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
}
#ifdef CONFIG_PM_ENABLE
#if !BTDM_ALLOW_LIGHT_SLEEP
esp_pm_lock_acquire(s_light_sleep_pm_lock);
#endif /* #if !BTDM_ALLOW_LIGHT_SLEEP */
if (!s_btdm_allow_light_sleep) {
esp_pm_lock_acquire(s_light_sleep_pm_lock);
}
esp_pm_lock_acquire(s_pm_lock);
#endif
@ -1305,9 +1407,9 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
}
esp_phy_rf_deinit(PHY_BT_MODULE);
#ifdef CONFIG_PM_ENABLE
#if !BTDM_ALLOW_LIGHT_SLEEP
esp_pm_lock_release(s_light_sleep_pm_lock);
#endif /* #if !BTDM_ALLOW_LIGHT_SLEEP */
if (!s_btdm_allow_light_sleep) {
esp_pm_lock_release(s_light_sleep_pm_lock);
}
esp_pm_lock_release(s_pm_lock);
#endif
return ESP_ERR_INVALID_STATE;
@ -1328,7 +1430,7 @@ esp_err_t esp_bt_controller_disable(void)
if (btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_ORIG) {
btdm_controller_enable_sleep(false);
if (!btdm_power_state_active()) {
btdm_wakeup_request();
btdm_wakeup_request(false);
}
while (!btdm_power_state_active()) {
ets_delay_us(1000);
@ -1348,9 +1450,9 @@ esp_err_t esp_bt_controller_disable(void)
btdm_controller_status = ESP_BT_CONTROLLER_STATUS_INITED;
#ifdef CONFIG_PM_ENABLE
#if !BTDM_ALLOW_LIGHT_SLEEP
esp_pm_lock_release(s_light_sleep_pm_lock);
#endif /* #if !BTDM_ALLOW_LIGHT_SLEEP */
if (!s_btdm_allow_light_sleep) {
esp_pm_lock_release(s_light_sleep_pm_lock);
}
esp_pm_lock_release(s_pm_lock);
#endif
@ -1466,7 +1568,7 @@ void esp_bt_controller_wakeup_request(void)
return;
}
btdm_wakeup_request();
btdm_wakeup_request(false);
}
esp_err_t esp_bredr_sco_datapath_set(esp_sco_data_path_t data_path)

View File

@ -8,12 +8,75 @@ if BLE_MESH
config BLE_MESH_USE_DUPLICATE_SCAN
bool "Support Duplicate Scan in BLE Mesh"
select BLE_SCAN_DUPLICATE
select BLE_MESH_SCAN_DUPLICATE_EN
depends on BT_BLUEDROID_ENABLED
select BTDM_BLE_SCAN_DUPL
select BTDM_BLE_MESH_SCAN_DUPL_EN
default y
help
Enable this option to allow using specific duplicate scan filter
in BLE Mesh, and Scan Duplicate Type must be set to 0x02.
in BLE Mesh, and Scan Duplicate Type must be set by choosing the
option in the Bluetooth Controller section in menuconfig, which is
"Scan Duplicate By Device Address and Advertising Data".
choice BLE_MESH_MEM_ALLOC_MODE
prompt "Memory allocation strategy"
default BLE_MESH_MEM_ALLOC_MODE_INTERNAL
help
Allocation strategy for BLE Mesh stack, essentially provides ability to
allocate all required dynamic allocations from,
- Internal DRAM memory only
- External SPIRAM memory only
- Either internal or external memory based on default malloc()
behavior in ESP-IDF
Recommended mode here is always internal, since that is most preferred
from security perspective. But if application requirement does not allow
sufficient free internal memory then alternate mode can be selected.
config BLE_MESH_MEM_ALLOC_MODE_INTERNAL
bool "Internal DRAM"
config BLE_MESH_MEM_ALLOC_MODE_EXTERNAL
bool "External SPIRAM"
depends on ESP32_SPIRAM_SUPPORT
config BLE_MESH_MEM_ALLOC_MODE_DEFAULT
bool "Default alloc mode"
depends on ESP32_SPIRAM_SUPPORT
help
Enable this option to use the default memory allocation strategy when
external SPIRAM is enabled. See the SPIRAM options for more details.
endchoice # BLE_MESH_MEM_ALLOC_MODE
config BLE_MESH_FREERTOS_STATIC_ALLOC
bool "Enable FreeRTOS static allocation"
depends on FREERTOS_SUPPORT_STATIC_ALLOCATION && ESP32_SPIRAM_SUPPORT
default n
help
Enable this option to use FreeRTOS static allocation APIs for BLE Mesh,
which provides the ability to use different dynamic memory (i.e. SPIRAM)
for FreeRTOS objects.
If this option is disabled, the FreeRTOS static allocation APIs will not
be used, and internal DRAM will be allocated for FreeRTOS objects.
choice BLE_MESH_FREERTOS_STATIC_ALLOC_MODE
prompt "Memory allocation for FreeRTOS objects"
depends on BLE_MESH_FREERTOS_STATIC_ALLOC
help
Choose the memory to be used for FreeRTOS objects.
config BLE_MESH_FREERTOS_STATIC_ALLOC_EXTERNAL
bool "External SPIRAM"
depends on ESP32_SPIRAM_SUPPORT
help
If enabled, BLE Mesh allocates dynamic memory from external SPIRAM for
FreeRTOS objects, i.e. mutex, queue, and task stack. External SPIRAM
can only be used for task stack when SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY
is enabled. See the SPIRAM options for more details.
endchoice # BLE_MESH_FREERTOS_STATIC_ALLOC_MODE
config BLE_MESH_FAST_PROV
bool "Enable BLE Mesh Fast Provisioning"
@ -23,75 +86,90 @@ if BLE_MESH
default n
help
Enable this option to allow BLE Mesh fast provisioning solution to be used.
When there are multiple unprovisioned devices around, fast provisioning can
greatly reduce the time consumption of the whole provisioning process.
When this option is enabled, and after an unprovisioned device is provisioned
into a node successfully, it can be changed to a temporary Provisioner.
config BLE_MESH_NODE
bool "Support for BLE Mesh Node"
help
Enable the device to be provisioned into a node.
Enable the device to be provisioned into a node. This option should be
enabled when an unprovisioned device is going to be provisioned into a
node and communicate with other nodes in the BLE Mesh network.
config BLE_MESH_PROVISIONER
bool "Support for BLE Mesh Provisioner"
help
Enable the device to be a provisioner.
Enable the device to be a Provisioner. The option should be enabled when
a device is going to act as a Provisioner and provision unprovisioned
devices into the BLE Mesh network.
if BLE_MESH_PROVISIONER
config BLE_MESH_WAIT_FOR_PROV_MAX_DEV_NUM
int "Maximum number of unprovisioned devices that can be added to device queue"
default 20
default 10
range 1 100
help
This option specifies how may unprovisioned devices can be added to device
queue for provisioning.
config BLE_MESH_MAX_STORED_NODES
int "Maximum number of nodes whose information can be stored"
default 20
range 1 1000
help
This option specifies the maximum number of nodes whose information can be
stored by a provisioner in its upper layer.
This option specifies how many unprovisioned devices can be added to device
queue for provisioning. Users can use this option to define the size of the
queue in the bottom layer which is used to store unprovisioned device
information (e.g. Device UUID, address).
config BLE_MESH_MAX_PROV_NODES
int "Maximum number of devices that can be provisioned by provisioner"
default 20
range 1 100
int "Maximum number of devices that can be provisioned by Provisioner"
default 10
range 1 1000
help
This option specifies how many devices can be provisioned by provisioner.
This option specifies how many devices can be provisioned by a Provisioner.
This value indicates the maximum number of unprovisioned devices which can be
provisioned by a Provisioner. For instance, if the value is 6, it means the
Provisioner can provision up to 6 unprovisioned devices.
Theoretically a Provisioner without the limitation of its memory can provision
up to 32766 unprovisioned devices, here we limit the maximum number to 100
just to limit the memory used by a Provisioner. The bigger the value is, the
more memory it will cost by a Provisioner to store the information of nodes.
if BLE_MESH_PB_ADV
config BLE_MESH_PBA_SAME_TIME
int "Maximum number of PB-ADV running at the same time by provisioner"
int "Maximum number of PB-ADV running at the same time by Provisioner"
default 2
range 1 10
help
This option specifies how many devices can be provisioned at the same
time using PB-ADV.
This option specifies how many devices can be provisioned at the same time
using PB-ADV. For examples, if the value is 2, it means a Provisioner can
provision two unprovisioned devices with PB-ADV at the same time.
endif # BLE_MESH_PB_ADV
if BLE_MESH_PB_GATT
config BLE_MESH_PBG_SAME_TIME
int "Maximum number of PB-GATT running at the same time by provisioner"
int "Maximum number of PB-GATT running at the same time by Provisioner"
default 1
range 1 5
help
This option specifies how many devices can be provisioned at the same
time using PB-GATT.
time using PB-GATT. For example, if the value is 2, it means a Provisioner
can provision two unprovisioned devices with PB-GATT at the same time.
endif # BLE_MESH_PB_GATT
config BLE_MESH_PROVISIONER_SUBNET_COUNT
int "Maximum number of mesh subnets that can be created by provisioner"
int "Maximum number of mesh subnets that can be created by Provisioner"
default 3
range 1 4096
help
This option specifies how many subnets per network a provisioner can create.
This option specifies how many subnets per network a Provisioner can create.
Indeed, this value decides the number of network keys which can be added by a Provisioner.
config BLE_MESH_PROVISIONER_APP_KEY_COUNT
int "Maximum number of application keys that can be owned by provisioner"
default 9
int "Maximum number of application keys that can be owned by Provisioner"
default 3
range 1 4096
help
This option specifies how many application keys the provisioner can have.
This option specifies how many application keys the Provisioner can have.
Indeed, this value decides the number of the application keys which can be added by a Provisioner.
endif # BLE_MESH_PROVISIONER
@ -109,7 +187,8 @@ if BLE_MESH
default y
help
Enable this option to allow the device to be provisioned over the
advertising bearer.
advertising bearer. This option should be enabled if PB-ADV is
going to be used during provisioning procedure.
config BLE_MESH_PB_GATT
bool "Provisioning support using GATT (PB-GATT)"
@ -117,6 +196,8 @@ if BLE_MESH
select BLE_MESH_PROV
help
Enable this option to allow the device to be provisioned over GATT.
This option should be enabled if PB-GATT is going to be used during
provisioning procedure.
# Virtual option enabled whenever any Proxy protocol is needed
config BLE_MESH_PROXY
@ -126,16 +207,19 @@ if BLE_MESH
Enable this option to support BLE Mesh Proxy protocol used by PB-GATT
and other proxy pdu transmission.
config BLE_MESH_GATT_PROXY
bool "BLE Mesh GATT Proxy Service"
config BLE_MESH_GATT_PROXY_SERVER
bool "BLE Mesh GATT Proxy Server"
select BLE_MESH_PROXY
depends on BLE_MESH_NODE
default y
help
This option enables support for Mesh GATT Proxy Service, i.e. the
ability to act as a proxy between a Mesh GATT Client and a Mesh network.
This option should be enabled if a node is going to be a Proxy Server.
config BLE_MESH_NODE_ID_TIMEOUT
int "Node Identity advertising timeout"
depends on BLE_MESH_GATT_PROXY
depends on BLE_MESH_GATT_PROXY_SERVER
range 1 60
default 60
help
@ -143,34 +227,75 @@ if BLE_MESH
Node Identity. The given value is in seconds. The specification limits
this to 60 seconds and lists it as the recommended value as well.
So leaving the default value is the safest option.
When an unprovisioned device is provisioned successfully and becomes a
node, it will start to advertise using Node Identity during the time
set by this option. And after that, Network ID will be advertised.
if BLE_MESH_PROXY
config BLE_MESH_PROXY_FILTER_SIZE
int "Maximum number of filter entries per Proxy Client"
depends on BLE_MESH_GATT_PROXY_SERVER
default 4
range 1 32767
help
This option specifies how many Proxy Filter entries the local node supports.
The entries of Proxy filter (whitelist or blacklist) are used to store a
list of addresses which can be used to decide which messages will be forwarded
to the Proxy Client by the Proxy Server.
config BLE_MESH_PROXY_FILTER_SIZE
int "Maximum number of filter entries per Proxy Client"
default 1
default 3 if BLE_MESH_GATT_PROXY
range 1 32767
help
This option specifies how many Proxy Filter entries the local node supports.
endif # BLE_MESH_PROXY
config BLE_MESH_GATT_PROXY_CLIENT
bool "BLE Mesh GATT Proxy Client"
select BLE_MESH_PROXY
default n
help
This option enables support for Mesh GATT Proxy Client. The Proxy Client
can use the GATT bearer to send mesh messages to a node that supports the
advertising bearer.
config BLE_MESH_NET_BUF_POOL_USAGE
bool "BLE Mesh net buffer pool usage tracking"
default y
help
Enable BLE Mesh net buffer pool tracking.
Enable BLE Mesh net buffer pool tracking. This option is used to introduce another
variable in the bottom layer to record the usage of advertising buffers of BLE Mesh
devices. Recommend to enable this option as default.
config BLE_MESH_SETTINGS
bool "Store BLE Mesh Node configuration persistently"
bool "Store BLE Mesh configuration persistently"
default n
help
When selected, the BLE Mesh stack will take care of storing/restoring the
BLE Mesh configuration persistently in flash. Currently this only supports
storing BLE Mesh node configuration.
When selected, the BLE Mesh stack will take care of storing/restoring the BLE
Mesh configuration persistently in flash.
If the device is a BLE Mesh node, when this option is enabled, the configuration
of the device will be stored persistently, including unicast address, NetKey,
AppKey, etc.
And if the device is a BLE Mesh Provisioner, the information of the device will
be stored persistently, including the information of provisioned nodes, NetKey,
AppKey, etc.
if BLE_MESH_SETTINGS
config BLE_MESH_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
@ -178,11 +303,14 @@ if BLE_MESH
help
This value defines in seconds how soon any pending changes are actually
written into persistent storage (flash) after a change occurs.
The option allows nodes to delay a certain period of time to save proper
information to flash. The default value is 0, which means information
will be stored immediately once there are updates.
config BLE_MESH_SEQ_STORE_RATE
int "How often the sequence number gets updated in storage"
range 0 1000000
default 128
default 6
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
@ -199,16 +327,40 @@ if BLE_MESH
range 0 1000000
default 5
help
This value defines in seconds how soon the RPL(Replay Protection List)
This value defines in seconds how soon the RPL (Replay Protection List)
gets written to persistent storage after a change occurs. If the node
receives messages frequently, then a large value is recommended. If the
node receives messages rarely, then the value can be as low as 0 (which
means the PRL is written into the storage immediately).
means the RPL is written into the storage immediately).
Note that if the node operates in a security-sensitive case, and there is
a risk of sudden power-off, then a value of 0 is strongly recommended.
Otherwise, a power loss before RPL being written into the storage may
introduce message replay attacks and system security will be in a
vulnerable state.
config BLE_MESH_SETTINGS_BACKWARD_COMPATIBILITY
bool "A specific option for settings backward compatibility"
depends on BLE_MESH_NODE
default n
help
This option is created to solve the issue of failure in recovering
node information after mesh stack updates. In the old version mesh
stack, there is no key of "mesh/role" in nvs. In the new version
mesh stack, key of "mesh/role" is added in nvs, recovering node
information needs to check "mesh/role" key in nvs and implements
selective recovery of mesh node information. Therefore, there may
be failure in recovering node information during node restarting
after OTA.
The new version mesh stack adds the option of "mesh/role" because
we have added the support of storing Provisioner information, while
the old version only supports storing node information.
If users are updating their nodes from old version to new version,
we recommend enabling this option, so that system could set the flag
in advance before recovering node information and make sure the node
information recovering could work as expected.
endif # if BLE_MESH_SETTINGS
config BLE_MESH_SUBNET_COUNT
@ -217,6 +369,7 @@ if BLE_MESH
range 1 4096
help
This option specifies how many subnets a Mesh network can have at the same time.
Indeed, this value decides the number of the network keys which can be owned by a node.
config BLE_MESH_APP_KEY_COUNT
int "Maximum number of application keys per network"
@ -224,6 +377,7 @@ if BLE_MESH
range 1 4096
help
This option specifies how many application keys the device can store per network.
Indeed, this value decides the number of the application keys which can be owned by a node.
config BLE_MESH_MODEL_KEY_COUNT
int "Maximum number of application keys per model"
@ -247,6 +401,7 @@ if BLE_MESH
range 0 4096
help
This option specifies how many Label UUIDs can be stored.
Indeed, this value decides the number of the Virtual Addresses can be supported by a node.
config BLE_MESH_CRPL
int "Maximum capacity of the replay protection list"
@ -255,6 +410,14 @@ if BLE_MESH
help
This option specifies the maximum capacity of the replay protection list.
It is similar to Network message cache size, but has a different purpose.
The replay protection list is used to prevent a node from replay attack,
which will store the source address and sequence number of the received
mesh messages.
For Provisioner, the replay protection list size should not be smaller than
the maximum number of nodes whose information can be stored. And the element
number of each node should also be taken into consideration. For example, if
Provisioner can provision up to 20 nodes and each node contains two elements,
then the replay protection list size of Provisioner should be at least 40.
config BLE_MESH_MSG_CACHE_SIZE
int "Network message cache size"
@ -264,6 +427,8 @@ if BLE_MESH
Number of messages that are cached for the network. This helps prevent
unnecessary decryption operations and unnecessary relays. This option
is similar to Replay protection list, but has a different purpose.
A node is not required to cache the entire Network PDU and may cache
only part of it for tracking, such as values for SRC/SEQ or others.
config BLE_MESH_ADV_BUF_COUNT
int "Number of advertising buffers"
@ -277,6 +442,24 @@ 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
@ -309,6 +492,11 @@ if BLE_MESH
range 1 BLE_MESH_ADV_BUF_COUNT
help
Maximum number of simultaneous outgoing multi-segment and/or reliable messages.
The default value is 1, which means the device can only send one segmented
message at a time. And if another segmented message is going to be sent, it
should wait for the completion of the previous one.
If users are going to send multiple segmented messages at the same time, this
value should be configured properly.
config BLE_MESH_RX_SEG_MSG_COUNT
int "Maximum number of simultaneous incoming segmented messages"
@ -316,6 +504,11 @@ if BLE_MESH
range 1 255
help
Maximum number of simultaneous incoming multi-segment and/or reliable messages.
The default value is 1, which means the device can only receive one segmented
message at a time. And if another segmented message is going to be received,
it should wait for the completion of the previous one.
If users are going to receive multiple segmented messages at the same time, this
value should be configured properly.
config BLE_MESH_RX_SDU_MAX
int "Maximum incoming Upper Transport Access PDU length"
@ -327,7 +520,7 @@ if BLE_MESH
config BLE_MESH_TX_SEG_MAX
int "Maximum number of segments in outgoing messages"
default 20
default 32
range 2 32
help
Maximum number of segments supported for outgoing messages.
@ -351,32 +544,69 @@ if BLE_MESH
config BLE_MESH_RELAY
bool "Relay support"
depends on BLE_MESH_NODE
default y
help
Support for acting as a Mesh Relay Node.
Support for acting as a Mesh Relay Node. Enabling this option will allow
a node to support the Relay feature, and the Relay feature can still
be enabled or disabled by proper configuration messages. Disabling this
option will let a node not support the Relay feature.
if BLE_MESH_RELAY
config BLE_MESH_RELAY_ADV_BUF
bool "Use separate advertising buffers for relay packets"
default n
help
When selected, self-send packets will be put in a high-priority
queue and relay packets will be put in a low-priority queue.
if BLE_MESH_RELAY_ADV_BUF
config BLE_MESH_RELAY_ADV_BUF_COUNT
int "Number of advertising buffers for relay packets"
default 60
range 6 256
help
Number of advertising buffers for relay packets available.
endif # BLE_MESH_RELAY_ADV_BUF
endif # BLE_MESH_RELAY
config BLE_MESH_LOW_POWER
bool "Support for Low Power features"
depends on BLE_MESH_NODE
help
Enable this option to operate as a Low Power Node.
Enable this option to operate as a Low Power Node. If low power consumption
is required by a node, this option should be enabled. And once the node
enters the mesh network, it will try to find a Friend node and establish a
friendship.
if BLE_MESH_LOW_POWER
config BLE_MESH_LPN_ESTABLISHMENT
bool "Perform Friendship establishment using low power"
default y
default n
help
Perform the Friendship establishment using low power with the help of a
reduced scan duty cycle. The downside of this is that the node may miss
out on messages intended for it until it has successfully set up Friendship
with a Friend node.
When this option is enabled, the node will stop scanning for a period of
time after a Friend Request or Friend Poll is sent, so as to reduce more
power consumption.
config BLE_MESH_LPN_AUTO
bool "Automatically start looking for Friend nodes once provisioned"
default y
default n
help
Once provisioned, automatically enable LPN functionality and start looking
for Friend nodes. If this option is disabled LPN mode needs to be manually
enabled by calling bt_mesh_lpn_set(true).
When an unprovisioned device is provisioned successfully and becomes a node,
enabling this option will trigger the node starts to send Friend Request at
a certain period until it finds a proper Friend node.
config BLE_MESH_LPN_AUTO_TIMEOUT
int "Time from last received message before going to LPN mode"
@ -389,7 +619,7 @@ if BLE_MESH
config BLE_MESH_LPN_RETRY_TIMEOUT
int "Retry timeout for Friend requests"
default 8
default 6
range 1 3600
help
Time in seconds between Friend Requests, if a previous Friend Request did
@ -402,6 +632,8 @@ if BLE_MESH
help
The contribution of the RSSI, measured by the Friend node, used in Friend
Offer Delay calculations. 0 = 1, 1 = 1.5, 2 = 2, 3 = 2.5.
RSSIFactor, one of the parameters carried by Friend Request sent by Low Power
node, which is used to calculate the Friend Offer Delay.
config BLE_MESH_LPN_RECV_WIN_FACTOR
int "ReceiveWindowFactor, used in Friend Offer Delay calculation"
@ -410,6 +642,8 @@ if BLE_MESH
help
The contribution of the supported Receive Window used in Friend Offer
Delay calculations. 0 = 1, 1 = 1.5, 2 = 2, 3 = 2.5.
ReceiveWindowFactor, one of the parameters carried by Friend Request sent by
Low Power node, which is used to calculate the Friend Offer Delay.
config BLE_MESH_LPN_MIN_QUEUE_SIZE
int "Minimum size of the acceptable friend queue (MinQueueSizeLog)"
@ -440,6 +674,8 @@ if BLE_MESH
the Friend node before the PollTimeout timer expires, then the
friendship is considered terminated. The value is in units of 100
milliseconds, so e.g. a value of 300 means 30 seconds.
The smaller the value, the faster the Low Power node tries to get
messages from corresponding Friend node and vice versa.
config BLE_MESH_LPN_INIT_POLL_TIMEOUT
int "The starting value of the PollTimeout timer"
@ -467,10 +703,11 @@ if BLE_MESH
default 8
help
Maximum number of groups to which the LPN can subscribe.
endif # BLE_MESH_LOW_POWER
config BLE_MESH_FRIEND
bool "Support for acting as a Friend Node"
bool "Support for Friend feature"
help
Enable this option to be able to act as a Friend Node.
@ -489,6 +726,8 @@ if BLE_MESH
default 16
help
Minimum number of buffers available to be stored for each local Friend Queue.
This option decides the size of each buffer which can be used by a Friend node
to store messages for each Low Power node.
config BLE_MESH_FRIEND_SUB_LIST_SIZE
int "Friend Subscription List Size"
@ -496,7 +735,9 @@ if BLE_MESH
default 3
help
Size of the Subscription List that can be supported by a Friend node for a
Low Power node.
Low Power node. And Low Power node can send Friend Subscription List Add or
Friend Subscription List Remove messages to the Friend node to add or remove
subscription addresses.
config BLE_MESH_FRIEND_LPN_COUNT
int "Number of supported LPN nodes"
@ -504,6 +745,9 @@ if BLE_MESH
default 2
help
Number of Low Power Nodes with which a Friend can have Friendship simultaneously.
A Friend node can have friendship with multiple Low Power nodes at the same time,
while a Low Power node can only establish friendship with only one Friend node at
the same time.
config BLE_MESH_FRIEND_SEG_RX
int "Number of incomplete segment lists per LPN"
@ -521,7 +765,8 @@ if BLE_MESH
depends on BLE_MESH
default n
help
Select this to save the BLE Mesh related rodata code size.
Select this to save the BLE Mesh related rodata code size. Enabling this option
will disable the output of BLE Mesh debug log.
menu "BLE Mesh STACK DEBUG LOG LEVEL"
depends on BLE_MESH && !BLE_MESH_NO_LOG
@ -597,12 +842,6 @@ if BLE_MESH
endmenu #BLE Mesh NET BUF DEBUG LOG LEVEL
config BLE_MESH_IRQ_LOCK
bool "Used the IRQ lock instead of task lock"
help
To improve the real-time requirements of bt controller in BLE Mesh,
task lock is used to replace IRQ lock.
config BLE_MESH_CLIENT_MSG_TIMEOUT
int "Timeout(ms) for client message response"
range 100 1200000
@ -610,6 +849,10 @@ if BLE_MESH
help
Timeout value used by the node to get response of the acknowledged
message which is sent by the client model.
This value indicates the maximum time that a client model waits for
the response of the sent acknowledged messages. If a client model
uses 0 as the timeout value when sending acknowledged messages, then
the default value will be used which is four seconds.
menu "Support for BLE Mesh Client Models"
@ -639,9 +882,9 @@ if BLE_MESH
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"
@ -716,6 +959,7 @@ if BLE_MESH
help
This option removes the 96 hour limit of the IV Update Procedure and
lets the state to be changed at any time.
If IV Update test mode is going to be used, this option should be enabled.
menu "BLE Mesh specific test option"
@ -726,6 +970,26 @@ if BLE_MESH
This option adds extra self-tests which are run every time BLE Mesh
networking is initialized.
if BLE_MESH_SELF_TEST
config BLE_MESH_TEST_AUTO_ENTER_NETWORK
bool "Unprovisioned device enters mesh network automatically"
default y
help
With this option enabled, an unprovisioned device can automatically
enters mesh network using a specific test function without the pro-
visioning procedure. And on the Provisioner side, a test function
needs to be invoked to add the node information into the mesh stack.
config BLE_MESH_TEST_USE_WHITE_LIST
bool "Use white list to filter mesh advertising packets"
default n
help
With this option enabled, users can use white list to filter mesh
advertising packets while scanning.
endif # BLE_MESH_SELF_TEST
config BLE_MESH_SHELL
bool "Enable BLE Mesh shell"
default n
@ -801,3 +1065,4 @@ if BLE_MESH
endmenu
endif # BLE_MESH

View File

@ -0,0 +1,21 @@
# ESP-BLE-MESH Component
This is Espressif Bluetooth Low Energy Mesh component folder.
This component is a part of Espressif IoT Development Framework (ESP-IDF). For the latest documentation please refer to [ESP-IDF Programming Guide](https://docs.espressif.com/projects/esp-idf/en/latest/index.html).
The ESP-BLE-MESH networking enables many-to-many (m:m) device communications and is optimized for creating large-scale device networks.
### [ESP-BLE-MESH Documentation](https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/esp_ble_mesh/index.html)
- [Getting Started](https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/esp_ble_mesh/index.html##getting-started-with-ble-mesh)
- [Architecture](https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/esp_ble_mesh/arhitecture.html)
- [Feature List](https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/esp_ble_mesh/ble_mesh-feature-list.html)
- [FAQ](https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/esp_ble_mesh/ble_mesh_faq.html)
- [API Reference](https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/bluetooth/ble_mesh.html)
### [ESP-BLE-MESH Examples](https://github.com/espressif/esp-idf/tree/master/examples/bluetooth/esp_ble_mesh)
- Refer to **ESP-BLE-MESH Examples** of [Getting Started](https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/esp_ble_mesh/index.html##getting-started-with-ble-mesh) for the tutorials of ESP BLE Mesh examples.

View File

@ -0,0 +1,73 @@
// Copyright 2017-2019 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/btc_manage.h"
#include "esp_err.h"
#include "btc_ble_mesh_prov.h"
#include "esp_ble_mesh_defs.h"
#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_msg_t msg = {0};
if (param == NULL) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_START_BLE_ADVERTISING;
memcpy(&arg.start_ble_advertising.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));
}
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_stop_ble_advertising(uint8_t index)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (index >= CONFIG_BLE_MESH_BLE_ADV_BUF_COUNT) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_STOP_BLE_ADVERTISING;
arg.stop_ble_advertising.index = index;
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_SUPPORT_BLE_ADV */

View File

@ -17,12 +17,7 @@
#include "freertos/FreeRTOS.h"
#include "freertos/semphr.h"
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include "esp_err.h"
#include "esp_bt_defs.h"
#include "esp_bt_main.h"
#include "btc_ble_mesh_prov.h"
#include "esp_ble_mesh_defs.h"
@ -32,16 +27,22 @@ esp_err_t esp_ble_mesh_init(esp_ble_mesh_prov_t *prov, esp_ble_mesh_comp_t *comp
btc_ble_mesh_prov_args_t arg = {0};
SemaphoreHandle_t semaphore = NULL;
btc_msg_t msg = {0};
esp_err_t ret = ESP_OK;
if (prov == NULL || comp == NULL) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
ret = bt_mesh_host_init();
if (ret != ESP_OK) {
return ret;
}
// Create a semaphore
if ((semaphore = xSemaphoreCreateCounting(1, 0)) == NULL) {
LOG_ERROR("%s, Failed to allocate memory for the semaphore", __func__);
BT_ERR("Failed to create semaphore");
return ESP_ERR_NO_MEM;
}
@ -56,7 +57,7 @@ esp_err_t esp_ble_mesh_init(esp_ble_mesh_prov_t *prov, esp_ble_mesh_comp_t *comp
if (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL) != BT_STATUS_SUCCESS) {
vSemaphoreDelete(semaphore);
LOG_ERROR("%s, BLE Mesh initialise failed", __func__);
BT_ERR("Failed to start mesh init");
return ESP_FAIL;
}
@ -68,3 +69,24 @@ esp_err_t esp_ble_mesh_init(esp_ble_mesh_prov_t *prov, esp_ble_mesh_comp_t *comp
return ESP_OK;
}
esp_err_t esp_ble_mesh_deinit(esp_ble_mesh_deinit_param_t *param)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (param == NULL) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
arg.mesh_deinit.param.erase_flash = param->erase_flash;
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_DEINIT_MESH;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}

View File

@ -13,14 +13,8 @@
// limitations under the License.
#include <stdint.h>
#include <errno.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include "esp_err.h"
#include "esp_bt_defs.h"
#include "esp_bt_main.h"
#include "btc_ble_mesh_prov.h"
#include "esp_ble_mesh_defs.h"
@ -38,7 +32,8 @@ uint16_t esp_ble_mesh_get_primary_element_address(void)
return btc_ble_mesh_get_primary_addr();
}
uint16_t *esp_ble_mesh_is_model_subscribed_to_group(esp_ble_mesh_model_t *model, uint16_t group_addr)
uint16_t *esp_ble_mesh_is_model_subscribed_to_group(esp_ble_mesh_model_t *model,
uint16_t group_addr)
{
if (model == NULL) {
return NULL;
@ -48,6 +43,9 @@ uint16_t *esp_ble_mesh_is_model_subscribed_to_group(esp_ble_mesh_model_t *model,
esp_ble_mesh_elem_t *esp_ble_mesh_find_element(uint16_t element_addr)
{
if (!ESP_BLE_MESH_ADDR_IS_UNICAST(element_addr)) {
return NULL;
}
return btc_ble_mesh_elem_find(element_addr);
}
@ -57,7 +55,7 @@ uint8_t esp_ble_mesh_get_element_count(void)
}
esp_ble_mesh_model_t *esp_ble_mesh_find_vendor_model(const esp_ble_mesh_elem_t *element,
uint16_t company_id, uint16_t model_id)
uint16_t company_id, uint16_t model_id)
{
if (element == NULL) {
return NULL;
@ -65,7 +63,8 @@ esp_ble_mesh_model_t *esp_ble_mesh_find_vendor_model(const esp_ble_mesh_elem_t *
return btc_ble_mesh_model_find_vnd(element, company_id, model_id);
}
esp_ble_mesh_model_t *esp_ble_mesh_find_sig_model(const esp_ble_mesh_elem_t *element, uint16_t model_id)
esp_ble_mesh_model_t *esp_ble_mesh_find_sig_model(const esp_ble_mesh_elem_t *element,
uint16_t model_id)
{
if (element == NULL) {
return NULL;
@ -78,3 +77,54 @@ 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);
}

View File

@ -14,13 +14,50 @@
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include "esp_err.h"
#include "esp_bt_defs.h"
#include "esp_bt_main.h"
#include "btc_ble_mesh_prov.h"
#include "esp_ble_mesh_defs.h"
esp_err_t esp_ble_mesh_lpn_enable(void)
{
btc_msg_t msg = {0};
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_LPN_ENABLE;
return (btc_transfer_context(&msg, NULL, 0, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_lpn_disable(bool force)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_LPN_DISABLE;
arg.lpn_disable.force = force;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_lpn_poll(void)
{
btc_msg_t msg = {0};
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_LPN_POLL;
return (btc_transfer_context(&msg, NULL, 0, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}

View File

@ -13,37 +13,38 @@
// limitations under the License.
#include <stdint.h>
#include <errno.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include <string.h>
#include "esp_err.h"
#include "esp_bt_defs.h"
#include "esp_bt_main.h"
#include "btc_ble_mesh_prov.h"
#include "esp_ble_mesh_networking_api.h"
#define ESP_BLE_MESH_TX_SDU_MAX ((CONFIG_BLE_MESH_ADV_BUF_COUNT - 3) * 12)
static esp_err_t ble_mesh_send_msg(esp_ble_mesh_model_t *model,
esp_ble_mesh_msg_ctx_t *ctx,
uint32_t opcode,
btc_ble_mesh_model_act_t act,
uint16_t length, uint8_t *data,
int32_t msg_timeout, bool need_rsp,
esp_ble_mesh_dev_role_t device_role)
static esp_err_t ble_mesh_model_send_msg(esp_ble_mesh_model_t *model,
esp_ble_mesh_msg_ctx_t *ctx,
uint32_t opcode,
btc_ble_mesh_model_act_t act,
uint16_t length, uint8_t *data,
int32_t msg_timeout, bool need_rsp,
esp_ble_mesh_dev_role_t device_role)
{
btc_ble_mesh_model_args_t arg = {0};
uint8_t op_len = 0, mic_len = 0;
uint8_t *msg_data = NULL;
btc_msg_t msg = {0};
esp_err_t status;
esp_err_t status = ESP_OK;
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
if (ctx && ctx->addr == ESP_BLE_MESH_ADDR_UNASSIGNED) {
BT_ERR("Invalid destination address 0x0000");
return ESP_ERR_INVALID_ARG;
}
if (device_role > ROLE_FAST_PROV) {
BT_ERR("Invalid device role 0x%02x", device_role);
return ESP_ERR_INVALID_ARG;
}
@ -62,19 +63,19 @@ static esp_err_t ble_mesh_send_msg(esp_ble_mesh_model_t *model,
if (act == BTC_BLE_MESH_ACT_MODEL_PUBLISH) {
if (op_len + length > model->pub->msg->size) {
LOG_ERROR("%s, Model publication msg size %d is too small", __func__, model->pub->msg->size);
BT_ERR("Too small publication msg size %d", model->pub->msg->size);
return ESP_ERR_INVALID_ARG;
}
}
if (act == BTC_BLE_MESH_ACT_MODEL_PUBLISH) {
mic_len = 4;
mic_len = ESP_BLE_MESH_MIC_SHORT;
} else {
mic_len = ctx->send_rel ? 8 : 4;
mic_len = ctx->send_rel ? ESP_BLE_MESH_MIC_LONG : ESP_BLE_MESH_MIC_SHORT;
}
if (op_len + length + mic_len > MIN(ESP_BLE_MESH_SDU_MAX_LEN, ESP_BLE_MESH_TX_SDU_MAX)) {
LOG_ERROR("%s, Data length %d is too large", __func__, length);
BT_ERR("Too large data length %d", length);
return ESP_ERR_INVALID_ARG;
}
@ -82,7 +83,7 @@ static esp_err_t ble_mesh_send_msg(esp_ble_mesh_model_t *model,
bt_mesh_model_msg_init(model->pub->msg, opcode);
net_buf_simple_add_mem(model->pub->msg, data, length);
} else {
msg_data = (uint8_t *)osi_malloc(op_len + length);
msg_data = (uint8_t *)bt_mesh_malloc(op_len + length);
if (msg_data == NULL) {
return ESP_ERR_NO_MEM;
}
@ -108,24 +109,24 @@ static esp_err_t ble_mesh_send_msg(esp_ble_mesh_model_t *model,
arg.model_send.msg_timeout = msg_timeout;
}
status = (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_model_args_t), btc_ble_mesh_prov_arg_deep_copy)
status = (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_model_args_t), btc_ble_mesh_model_arg_deep_copy)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
osi_free(msg_data);
bt_mesh_free(msg_data);
return status;
}
esp_err_t esp_ble_mesh_register_custom_model_callback(esp_ble_mesh_model_cb_t callback)
{
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
return (btc_profile_cb_set(BTC_PID_MODEL, callback) == 0 ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_model_msg_opcode_init(uint8_t *data, uint32_t opcode)
{
uint16_t val;
uint16_t val = 0;
if (data == NULL) {
return ESP_ERR_INVALID_ARG;
@ -157,48 +158,98 @@ esp_err_t esp_ble_mesh_client_model_init(esp_ble_mesh_model_t *model)
if (model == NULL) {
return ESP_ERR_INVALID_ARG;
}
return btc_ble_mesh_client_init(model);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
return btc_ble_mesh_client_model_init(model);
}
esp_err_t esp_ble_mesh_client_model_deinit(esp_ble_mesh_model_t *model)
{
if (model == NULL) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
return btc_ble_mesh_client_model_deinit(model);
}
esp_err_t esp_ble_mesh_server_model_send_msg(esp_ble_mesh_model_t *model,
esp_ble_mesh_msg_ctx_t *ctx, uint32_t opcode,
uint16_t length, uint8_t *data)
esp_ble_mesh_msg_ctx_t *ctx,
uint32_t opcode,
uint16_t length, uint8_t *data)
{
if (!model || !ctx) {
if (model == NULL || ctx == NULL ||
ctx->net_idx == ESP_BLE_MESH_KEY_UNUSED ||
ctx->app_idx == ESP_BLE_MESH_KEY_UNUSED) {
return ESP_ERR_INVALID_ARG;
}
return ble_mesh_send_msg(model, ctx, opcode, BTC_BLE_MESH_ACT_SERVER_MODEL_SEND,
length, data, 0, false, ROLE_NODE);
return ble_mesh_model_send_msg(model, ctx, opcode, BTC_BLE_MESH_ACT_SERVER_MODEL_SEND,
length, data, 0, false, ROLE_NODE);
}
esp_err_t esp_ble_mesh_client_model_send_msg(esp_ble_mesh_model_t *model,
esp_ble_mesh_msg_ctx_t *ctx, uint32_t opcode,
uint16_t length, uint8_t *data, int32_t msg_timeout,
bool need_rsp, esp_ble_mesh_dev_role_t device_role)
esp_ble_mesh_msg_ctx_t *ctx,
uint32_t opcode,
uint16_t length, uint8_t *data,
int32_t msg_timeout, bool need_rsp,
esp_ble_mesh_dev_role_t device_role)
{
if (!model || !ctx) {
if (model == NULL || ctx == NULL ||
ctx->net_idx == ESP_BLE_MESH_KEY_UNUSED ||
ctx->app_idx == ESP_BLE_MESH_KEY_UNUSED) {
return ESP_ERR_INVALID_ARG;
}
return ble_mesh_send_msg(model, ctx, opcode, BTC_BLE_MESH_ACT_CLIENT_MODEL_SEND,
length, data, msg_timeout, need_rsp, device_role);
return ble_mesh_model_send_msg(model, ctx, opcode, BTC_BLE_MESH_ACT_CLIENT_MODEL_SEND,
length, data, msg_timeout, need_rsp, device_role);
}
esp_err_t esp_ble_mesh_model_publish(esp_ble_mesh_model_t *model, uint32_t opcode,
uint16_t length, uint8_t *data,
esp_ble_mesh_dev_role_t device_role)
{
if (!model || !model->pub || !model->pub->msg) {
if (model == NULL || model->pub == NULL || model->pub->msg == NULL ||
model->pub->publish_addr == ESP_BLE_MESH_ADDR_UNASSIGNED) {
return ESP_ERR_INVALID_ARG;
}
return ble_mesh_send_msg(model, NULL, opcode, BTC_BLE_MESH_ACT_MODEL_PUBLISH,
length, data, 0, false, device_role);
return ble_mesh_model_send_msg(model, NULL, opcode, BTC_BLE_MESH_ACT_MODEL_PUBLISH,
length, data, 0, false, device_role);
}
esp_err_t esp_ble_mesh_server_model_update_state(esp_ble_mesh_model_t *model,
esp_ble_mesh_server_state_type_t type,
esp_ble_mesh_server_state_value_t *value)
{
btc_ble_mesh_model_args_t arg = {0};
btc_msg_t msg = {0};
if (!model || !value || type >= ESP_BLE_MESH_SERVER_MODEL_STATE_MAX) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
arg.model_update_state.model = model;
arg.model_update_state.type = type;
arg.model_update_state.value = value;
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_MODEL;
msg.act = BTC_BLE_MESH_ACT_SERVER_MODEL_UPDATE_STATE;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_model_args_t), btc_ble_mesh_model_arg_deep_copy)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_node_local_reset(void)
{
btc_msg_t msg = {0};
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
@ -209,7 +260,7 @@ esp_err_t esp_ble_mesh_node_local_reset(void)
#if (CONFIG_BLE_MESH_PROVISIONER)
esp_err_t esp_ble_mesh_provisioner_set_node_name(int index, const char *name)
esp_err_t esp_ble_mesh_provisioner_set_node_name(uint16_t index, const char *name)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
@ -218,7 +269,7 @@ esp_err_t esp_ble_mesh_provisioner_set_node_name(int index, const char *name)
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
@ -226,36 +277,139 @@ esp_err_t esp_ble_mesh_provisioner_set_node_name(int index, const char *name)
arg.set_node_name.index = index;
memset(arg.set_node_name.name, 0, sizeof(arg.set_node_name.name));
memcpy(arg.set_node_name.name, name, strlen(name));
strncpy(arg.set_node_name.name, name, ESP_BLE_MESH_NODE_NAME_MAX_LEN);
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
const char *esp_ble_mesh_provisioner_get_node_name(int index)
const char *esp_ble_mesh_provisioner_get_node_name(uint16_t index)
{
return bt_mesh_provisioner_get_node_name(index);
}
int esp_ble_mesh_provisioner_get_node_index(const char *name)
uint16_t esp_ble_mesh_provisioner_get_node_index(const char *name)
{
if (!name || (strlen(name) > ESP_BLE_MESH_NODE_NAME_MAX_LEN)) {
return -EINVAL;
return ESP_BLE_MESH_INVALID_NODE_INDEX;
}
return bt_mesh_provisioner_get_node_index(name);
}
esp_err_t esp_ble_mesh_provisioner_add_local_app_key(const uint8_t app_key[16],
uint16_t net_idx, uint16_t app_idx)
esp_err_t esp_ble_mesh_provisioner_store_node_comp_data(uint16_t unicast_addr,
uint8_t *data, uint16_t length)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
if (!ESP_BLE_MESH_ADDR_IS_UNICAST(unicast_addr) || !data || length <= 14) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_SET_LOCAL_APP_KEY;
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_STORE_NODE_COMP_DATA;
arg.store_node_comp_data.unicast_addr = unicast_addr;
arg.store_node_comp_data.length = length;
arg.store_node_comp_data.data = data;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), btc_ble_mesh_prov_arg_deep_copy)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_ble_mesh_node_t *esp_ble_mesh_provisioner_get_node_with_uuid(const uint8_t uuid[16])
{
if (!uuid) {
return NULL;
}
return btc_ble_mesh_provisioner_get_node_with_uuid(uuid);
}
esp_ble_mesh_node_t *esp_ble_mesh_provisioner_get_node_with_addr(uint16_t unicast_addr)
{
if (!ESP_BLE_MESH_ADDR_IS_UNICAST(unicast_addr)) {
return NULL;
}
return btc_ble_mesh_provisioner_get_node_with_addr(unicast_addr);
}
esp_ble_mesh_node_t *esp_ble_mesh_provisioner_get_node_with_name(const char *name)
{
if (!name || (strlen(name) > ESP_BLE_MESH_NODE_NAME_MAX_LEN)) {
return NULL;
}
return btc_ble_mesh_provisioner_get_node_with_name(name);
}
uint16_t esp_ble_mesh_provisioner_get_prov_node_count(void)
{
return btc_ble_mesh_provisioner_get_prov_node_count();
}
const esp_ble_mesh_node_t **esp_ble_mesh_provisioner_get_node_table_entry(void)
{
return btc_ble_mesh_provisioner_get_node_table_entry();
}
esp_err_t esp_ble_mesh_provisioner_delete_node_with_uuid(const uint8_t uuid[16])
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (!uuid) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_DELETE_NODE_WITH_UUID;
memcpy(arg.delete_node_with_uuid.uuid, uuid, 16);
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_provisioner_delete_node_with_addr(uint16_t unicast_addr)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (!ESP_BLE_MESH_ADDR_IS_UNICAST(unicast_addr)) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_DELETE_NODE_WITH_ADDR;
arg.delete_node_with_addr.unicast_addr = unicast_addr;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_provisioner_add_local_app_key(const uint8_t app_key[16],
uint16_t net_idx, uint16_t app_idx)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_ADD_LOCAL_APP_KEY;
arg.add_local_app_key.net_idx = net_idx;
arg.add_local_app_key.app_idx = app_idx;
@ -268,13 +422,36 @@ esp_err_t esp_ble_mesh_provisioner_add_local_app_key(const uint8_t app_key[16],
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_provisioner_update_local_app_key(const uint8_t app_key[16],
uint16_t net_idx, uint16_t app_idx)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (app_key == NULL) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_UPDATE_LOCAL_APP_KEY;
memcpy(arg.update_local_app_key.app_key, app_key, 16);
arg.update_local_app_key.net_idx = net_idx;
arg.update_local_app_key.app_idx = app_idx;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
const uint8_t *esp_ble_mesh_provisioner_get_local_app_key(uint16_t net_idx, uint16_t app_idx)
{
return bt_mesh_provisioner_local_app_key_get(net_idx, app_idx);
}
esp_err_t esp_ble_mesh_provisioner_bind_app_key_to_local_model(uint16_t element_addr, uint16_t app_idx,
uint16_t model_id, uint16_t company_id)
uint16_t model_id, uint16_t company_id)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
@ -283,7 +460,7 @@ esp_err_t esp_ble_mesh_provisioner_bind_app_key_to_local_model(uint16_t element_
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
@ -306,7 +483,7 @@ esp_err_t esp_ble_mesh_provisioner_add_local_net_key(const uint8_t net_key[16],
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
@ -322,11 +499,31 @@ esp_err_t esp_ble_mesh_provisioner_add_local_net_key(const uint8_t net_key[16],
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_provisioner_update_local_net_key(const uint8_t net_key[16], uint16_t net_idx)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (net_key == NULL) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_UPDATE_LOCAL_NET_KEY;
memcpy(arg.update_local_net_key.net_key, net_key, 16);
arg.update_local_net_key.net_idx = net_idx;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
const uint8_t *esp_ble_mesh_provisioner_get_local_net_key(uint16_t net_idx)
{
return bt_mesh_provisioner_local_net_key_get(net_idx);
}
#endif /* CONFIG_BLE_MESH_PROVISIONER */
#if (CONFIG_BLE_MESH_FAST_PROV)

View File

@ -13,13 +13,9 @@
// limitations under the License.
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include <string.h>
#include "esp_err.h"
#include "esp_bt_defs.h"
#include "esp_bt_main.h"
#include "btc_ble_mesh_prov.h"
#include "esp_ble_mesh_provisioning_api.h"
@ -29,7 +25,7 @@
esp_err_t esp_ble_mesh_register_prov_callback(esp_ble_mesh_prov_cb_t callback)
{
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
return (btc_profile_cb_set(BTC_PID_PROV, callback) == 0 ? ESP_OK : ESP_FAIL);
}
@ -39,12 +35,30 @@ bool esp_ble_mesh_node_is_provisioned(void)
return bt_mesh_is_provisioned();
}
static bool prov_bearers_valid(esp_ble_mesh_prov_bearer_t bearers)
{
if ((!(bearers & (ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT))) ||
(IS_ENABLED(CONFIG_BLE_MESH_PB_ADV) &&
!IS_ENABLED(CONFIG_BLE_MESH_PB_GATT) &&
!(bearers & ESP_BLE_MESH_PROV_ADV)) ||
(!IS_ENABLED(CONFIG_BLE_MESH_PB_ADV) &&
IS_ENABLED(CONFIG_BLE_MESH_PB_GATT) &&
!(bearers & ESP_BLE_MESH_PROV_GATT))) {
return false;
}
return true;
}
esp_err_t esp_ble_mesh_node_prov_enable(esp_ble_mesh_prov_bearer_t bearers)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
if (prov_bearers_valid(bearers) == false) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
@ -60,7 +74,11 @@ esp_err_t esp_ble_mesh_node_prov_disable(esp_ble_mesh_prov_bearer_t bearers)
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
if (prov_bearers_valid(bearers) == false) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
@ -72,7 +90,7 @@ esp_err_t esp_ble_mesh_node_prov_disable(esp_ble_mesh_prov_bearer_t bearers)
}
esp_err_t esp_ble_mesh_node_set_oob_pub_key(uint8_t pub_key_x[32], uint8_t pub_key_y[32],
uint8_t private_key[32])
uint8_t private_key[32])
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
@ -81,7 +99,7 @@ esp_err_t esp_ble_mesh_node_set_oob_pub_key(uint8_t pub_key_x[32], uint8_t pub_k
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
@ -104,7 +122,7 @@ esp_err_t esp_ble_mesh_node_input_number(uint32_t number)
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
@ -120,17 +138,18 @@ esp_err_t esp_ble_mesh_node_input_string(const char *string)
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (!string) {
if (!string || strlen(string) > ESP_BLE_MESH_PROV_INPUT_OOB_MAX_LEN) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_INPUT_STRING;
memset(arg.input_string.string, 0, sizeof(arg.input_string.string));
strncpy(arg.input_string.string, string, strlen(string));
strncpy(arg.input_string.string, string,
MIN(strlen(string), sizeof(arg.input_string.string)));
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
@ -145,21 +164,22 @@ esp_err_t esp_ble_mesh_set_unprovisioned_device_name(const char *name)
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_SET_DEVICE_NAME;
memset(arg.set_device_name.name, 0, sizeof(arg.set_device_name.name));
memcpy(arg.set_device_name.name, name, strlen(name));
strncpy(arg.set_device_name.name, name, ESP_BLE_MESH_DEVICE_NAME_MAX_LEN);
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#if (CONFIG_BLE_MESH_PROVISIONER)
esp_err_t esp_ble_mesh_provisioner_read_oob_pub_key(uint8_t link_idx, uint8_t pub_key_x[32],
uint8_t pub_key_y[32])
uint8_t pub_key_y[32])
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
@ -168,7 +188,7 @@ esp_err_t esp_ble_mesh_provisioner_read_oob_pub_key(uint8_t link_idx, uint8_t pu
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
@ -187,18 +207,20 @@ esp_err_t esp_ble_mesh_provisioner_input_string(const char *string, uint8_t link
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (!string || link_idx >= MAX_PROV_LINK_IDX) {
if (!string || strlen(string) > ESP_BLE_MESH_PROV_OUTPUT_OOB_MAX_LEN ||
link_idx >= MAX_PROV_LINK_IDX) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_INPUT_STR;
memset(arg.provisioner_input_str.string, 0, sizeof(arg.provisioner_input_str.string));
strncpy(arg.provisioner_input_str.string, string, strlen(string));
strncpy(arg.provisioner_input_str.string, string,
MIN(strlen(string), sizeof(arg.provisioner_input_str.string)));
arg.provisioner_input_str.link_idx = link_idx;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
@ -214,7 +236,7 @@ esp_err_t esp_ble_mesh_provisioner_input_number(uint32_t number, uint8_t link_id
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
@ -232,7 +254,11 @@ esp_err_t esp_ble_mesh_provisioner_prov_enable(esp_ble_mesh_prov_bearer_t bearer
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
if (prov_bearers_valid(bearers) == false) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
@ -249,7 +275,11 @@ esp_err_t esp_ble_mesh_provisioner_prov_disable(esp_ble_mesh_prov_bearer_t beare
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
if (prov_bearers_valid(bearers) == false) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
@ -262,7 +292,7 @@ esp_err_t esp_ble_mesh_provisioner_prov_disable(esp_ble_mesh_prov_bearer_t beare
}
esp_err_t esp_ble_mesh_provisioner_add_unprov_dev(esp_ble_mesh_unprov_dev_add_t *add_dev,
esp_ble_mesh_dev_add_flag_t flags)
esp_ble_mesh_dev_add_flag_t flags)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
@ -271,7 +301,7 @@ esp_err_t esp_ble_mesh_provisioner_add_unprov_dev(esp_ble_mesh_unprov_dev_add_t
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
@ -280,13 +310,47 @@ esp_err_t esp_ble_mesh_provisioner_add_unprov_dev(esp_ble_mesh_unprov_dev_add_t
arg.provisioner_dev_add.add_dev.addr_type = add_dev->addr_type;
arg.provisioner_dev_add.add_dev.oob_info = add_dev->oob_info;
arg.provisioner_dev_add.add_dev.bearer = add_dev->bearer;
memcpy(arg.provisioner_dev_add.add_dev.addr, add_dev->addr, sizeof(esp_bd_addr_t));
memcpy(arg.provisioner_dev_add.add_dev.addr, add_dev->addr, sizeof(esp_ble_mesh_bd_addr_t));
memcpy(arg.provisioner_dev_add.add_dev.uuid, add_dev->uuid, 16);
arg.provisioner_dev_add.flags = flags;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_provisioner_prov_device_with_addr(const uint8_t uuid[16],
esp_ble_mesh_bd_addr_t addr,
esp_ble_mesh_addr_type_t addr_type,
esp_ble_mesh_prov_bearer_t bearer,
uint16_t oob_info, uint16_t unicast_addr)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (uuid == NULL || (bearer == ESP_BLE_MESH_PROV_GATT && (addr == NULL ||
addr_type > ESP_BLE_MESH_ADDR_TYPE_RANDOM)) ||
(bearer != ESP_BLE_MESH_PROV_ADV && bearer != ESP_BLE_MESH_PROV_GATT) ||
!ESP_BLE_MESH_ADDR_IS_UNICAST(unicast_addr)) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_PROV_DEV_WITH_ADDR;
memcpy(arg.provisioner_prov_dev_with_addr.uuid, uuid, 16);
if (addr) {
memcpy(arg.provisioner_prov_dev_with_addr.addr, addr, BD_ADDR_LEN);
arg.provisioner_prov_dev_with_addr.addr_type = addr_type;
}
arg.provisioner_prov_dev_with_addr.bearer = bearer;
arg.provisioner_prov_dev_with_addr.oob_info = oob_info;
arg.provisioner_prov_dev_with_addr.unicast_addr = unicast_addr;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_provisioner_delete_dev(esp_ble_mesh_device_delete_t *del_dev)
{
uint8_t val = DEL_DEV_ADDR_FLAG | DEL_DEV_UUID_FLAG;
@ -297,7 +361,7 @@ esp_err_t esp_ble_mesh_provisioner_delete_dev(esp_ble_mesh_device_delete_t *del_
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
@ -306,7 +370,7 @@ esp_err_t esp_ble_mesh_provisioner_delete_dev(esp_ble_mesh_device_delete_t *del_
arg.provisioner_dev_del.del_dev.flag = del_dev->flag;
if (del_dev->flag & DEL_DEV_ADDR_FLAG) {
arg.provisioner_dev_del.del_dev.addr_type = del_dev->addr_type;
memcpy(arg.provisioner_dev_del.del_dev.addr, del_dev->addr, sizeof(esp_bd_addr_t));
memcpy(arg.provisioner_dev_del.del_dev.addr, del_dev->addr, sizeof(esp_ble_mesh_bd_addr_t));
} else if (del_dev->flag & DEL_DEV_UUID_FLAG) {
memcpy(arg.provisioner_dev_del.del_dev.uuid, del_dev->uuid, 16);
}
@ -315,12 +379,16 @@ esp_err_t esp_ble_mesh_provisioner_delete_dev(esp_ble_mesh_device_delete_t *del_
}
esp_err_t esp_ble_mesh_provisioner_set_dev_uuid_match(const uint8_t *match_val, uint8_t match_len,
uint8_t offset, bool prov_after_match)
uint8_t offset, bool prov_after_match)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
if (match_len + offset > ESP_BLE_MESH_OCTET16_LEN) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
@ -346,7 +414,7 @@ esp_err_t esp_ble_mesh_provisioner_set_prov_data_info(esp_ble_mesh_prov_data_inf
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
@ -364,6 +432,47 @@ esp_err_t esp_ble_mesh_provisioner_set_prov_data_info(esp_ble_mesh_prov_data_inf
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_provisioner_set_static_oob_value(const uint8_t *value, uint8_t length)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (value == NULL || length == 0 || length > 16) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_SET_STATIC_OOB_VAL;
arg.set_static_oob_val.length = length;
memcpy(arg.set_static_oob_val.value, value, length);
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_provisioner_set_primary_elem_addr(uint16_t addr)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (!ESP_BLE_MESH_ADDR_IS_UNICAST(addr)) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_SET_PRIMARY_ELEM_ADDR;
arg.set_primary_elem_addr.addr = addr;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif /* CONFIG_BLE_MESH_PROVISIONER */
/* The following APIs are for fast provisioning */
@ -375,11 +484,12 @@ esp_err_t esp_ble_mesh_set_fast_prov_info(esp_ble_mesh_fast_prov_info_t *fast_pr
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (fast_prov_info == NULL) {
if (fast_prov_info == NULL || (fast_prov_info->offset +
fast_prov_info->match_len > ESP_BLE_MESH_OCTET16_LEN)) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
@ -408,7 +518,7 @@ esp_err_t esp_ble_mesh_set_fast_prov_action(esp_ble_mesh_fast_prov_action_t acti
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;

View File

@ -13,13 +13,9 @@
// limitations under the License.
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include <string.h>
#include "esp_err.h"
#include "esp_bt_defs.h"
#include "esp_bt_main.h"
#include "btc_ble_mesh_prov.h"
#include "esp_ble_mesh_defs.h"
@ -28,7 +24,7 @@ esp_err_t esp_ble_mesh_proxy_identity_enable(void)
{
btc_msg_t msg = {0};
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
@ -41,7 +37,7 @@ esp_err_t esp_ble_mesh_proxy_gatt_enable(void)
{
btc_msg_t msg = {0};
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
@ -54,7 +50,7 @@ esp_err_t esp_ble_mesh_proxy_gatt_disable(void)
{
btc_msg_t msg = {0};
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
@ -63,3 +59,118 @@ esp_err_t esp_ble_mesh_proxy_gatt_disable(void)
return (btc_transfer_context(&msg, NULL, 0, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_proxy_client_connect(esp_ble_mesh_bd_addr_t addr,
esp_ble_mesh_addr_type_t addr_type,
uint16_t net_idx)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (!addr || addr_type > ESP_BLE_MESH_ADDR_TYPE_RANDOM) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_PROXY_CLIENT_CONNECT;
memcpy(arg.proxy_client_connect.addr, addr, BD_ADDR_LEN);
arg.proxy_client_connect.addr_type = addr_type;
arg.proxy_client_connect.net_idx = net_idx;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_proxy_client_disconnect(uint8_t conn_handle)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_PROXY_CLIENT_DISCONNECT;
arg.proxy_client_disconnect.conn_handle = conn_handle;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_proxy_client_set_filter_type(uint8_t conn_handle, uint16_t net_idx,
esp_ble_mesh_proxy_filter_type_t filter_type)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (filter_type > PROXY_FILTER_BLACKLIST) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_PROXY_CLIENT_SET_FILTER_TYPE;
arg.proxy_client_set_filter_type.conn_handle = conn_handle;
arg.proxy_client_set_filter_type.net_idx = net_idx;
arg.proxy_client_set_filter_type.filter_type = filter_type;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_proxy_client_add_filter_addr(uint8_t conn_handle, uint16_t net_idx,
uint16_t *addr, uint16_t addr_num)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (!addr || addr_num == 0) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_PROXY_CLIENT_ADD_FILTER_ADDR;
arg.proxy_client_add_filter_addr.conn_handle = conn_handle;
arg.proxy_client_add_filter_addr.net_idx = net_idx;
arg.proxy_client_add_filter_addr.addr_num = addr_num;
arg.proxy_client_add_filter_addr.addr = addr;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), btc_ble_mesh_prov_arg_deep_copy)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_proxy_client_remove_filter_addr(uint8_t conn_handle, uint16_t net_idx,
uint16_t *addr, uint16_t addr_num)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (!addr || addr_num == 0) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_PROXY_CLIENT_REMOVE_FILTER_ADDR;
arg.proxy_client_remove_filter_addr.conn_handle = conn_handle;
arg.proxy_client_remove_filter_addr.net_idx = net_idx;
arg.proxy_client_remove_filter_addr.addr_num = addr_num;
arg.proxy_client_remove_filter_addr.addr = addr;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), btc_ble_mesh_prov_arg_deep_copy)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}

View File

@ -0,0 +1,65 @@
// Copyright 2017-2019 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef _ESP_BLE_MESH_BLE_API_H_
#define _ESP_BLE_MESH_BLE_API_H_
#include "esp_ble_mesh_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief This function is called to start BLE advertising with the corresponding data
* and parameters while BLE Mesh is working at the same time.
*
* @note 1. When this function is called, the BLE advertising packet will be posted to
* the BLE mesh adv queue in the mesh stack and waited to be sent.
* 2. In the BLE advertising parameters, the "duration" means the time used for
* sending the BLE advertising packet each time, it shall not be smaller than the
* advertising interval. When the packet is sent successfully, it will be posted
* to the adv queue again after the "period" time if the "count" is bigger than 0.
* The "count" means how many durations the packet will be sent after it is sent
* successfully for the first time. And if the "count" is set to 0xFFFF, which
* means the packet will be sent infinitely.
* 3. The "priority" means the priority of BLE advertising packet compared with
* BLE Mesh packets. Currently two options (i.e. low/high) are provided. If the
* "priority" is high, the BLE advertising packet will be posted to the front of
* adv queue. Otherwise it will be posted to the back of adv queue.
*
* @param[in] param: Pointer to the BLE advertising parameters
* @param[in] data: Pointer to the BLE advertising data and scan response data
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_start_ble_advertising(const esp_ble_mesh_ble_adv_param_t *param,
const esp_ble_mesh_ble_adv_data_t *data);
/**
* @brief This function is called to stop BLE advertising with the corresponding index.
*
* @param[in] index: Index of BLE advertising
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_stop_ble_advertising(uint8_t index);
#ifdef __cplusplus
}
#endif
#endif /* _ESP_BLE_MESH_BLE_API_H_ */

View File

@ -17,6 +17,10 @@
#include "esp_ble_mesh_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initialize BLE Mesh module.
* This API initializes provisioning capabilities and composition data information.
@ -34,4 +38,20 @@
*/
esp_err_t esp_ble_mesh_init(esp_ble_mesh_prov_t *prov, esp_ble_mesh_comp_t *comp);
/**
* @brief De-initialize BLE Mesh module.
*
* @note This function shall be invoked after esp_ble_mesh_client_model_deinit().
*
* @param[in] param: Pointer to the structure of BLE Mesh deinit parameters.
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_deinit(esp_ble_mesh_deinit_param_t *param);
#ifdef __cplusplus
}
#endif
#endif /* _ESP_BLE_MESH_COMMON_API_H_ */

View File

@ -17,6 +17,10 @@
#include "esp_ble_mesh_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Get the model publish period, the unit is ms.
*
@ -51,7 +55,8 @@ uint16_t esp_ble_mesh_get_primary_element_address(void);
* to 0x0000 in order to unsubscribe the model from the group.
*
*/
uint16_t *esp_ble_mesh_is_model_subscribed_to_group(esp_ble_mesh_model_t *model, uint16_t group_addr);
uint16_t *esp_ble_mesh_is_model_subscribed_to_group(esp_ble_mesh_model_t *model,
uint16_t group_addr);
/**
* @brief Find the BLE Mesh element pointer via the element address.
@ -83,7 +88,7 @@ uint8_t esp_ble_mesh_get_element_count(void);
*
*/
esp_ble_mesh_model_t *esp_ble_mesh_find_vendor_model(const esp_ble_mesh_elem_t *element,
uint16_t company_id, uint16_t model_id);
uint16_t company_id, uint16_t model_id);
/**
* @brief Find the SIG model with the given element and Model id.
@ -94,7 +99,8 @@ esp_ble_mesh_model_t *esp_ble_mesh_find_vendor_model(const esp_ble_mesh_elem_t *
* @return Pointer to the SIG Model on success, or NULL on failure which means the SIG Model is not found.
*
*/
esp_ble_mesh_model_t *esp_ble_mesh_find_sig_model(const esp_ble_mesh_elem_t *element, uint16_t model_id);
esp_ble_mesh_model_t *esp_ble_mesh_find_sig_model(const esp_ble_mesh_elem_t *element,
uint16_t model_id);
/**
* @brief Get the Composition data which has been registered.
@ -104,4 +110,40 @@ 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);
#ifdef __cplusplus
}
#endif
#endif /* _ESP_BLE_MESH_LOCAL_DATA_OPERATION_API_H_ */

View File

@ -17,4 +17,53 @@
#include "esp_ble_mesh_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Enable BLE Mesh device LPN functionality.
*
* @note This API enables LPN functionality. Once called, the proper
* Friend Request will be sent.
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_lpn_enable(void);
/**
* @brief Disable BLE Mesh device LPN functionality.
*
* @param[in] force: when disabling LPN functionality, use this flag to indicate
* whether directly clear corresponding information or just
* send friend clear to disable it if friendship has already
* been established.
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_lpn_disable(bool force);
/**
* @brief LPN tries to poll messages from the Friend Node.
*
* @note The Friend Poll message is sent by a Low Power node to ask the Friend
* node to send a message that it has stored for the Low Power node.
* Users can call this API to send Friend Poll message manually. If this
* API is not invoked, the bottom layer of the Low Power node will send
* Friend Poll before the PollTimeout timer expires.
* If the corresponding Friend Update is received and MD is set to 0,
* which means there are no messages for the Low Power node, then the
* Low Power node will stop scanning.
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_lpn_poll(void);
#ifdef __cplusplus
}
#endif
#endif /* _ESP_BLE_MESH_LOW_POWER_API_H_ */

View File

@ -17,9 +17,13 @@
#include "esp_ble_mesh_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @brief: event, event code of user-defined model events; param, parameters of user-defined model events */
typedef void (* esp_ble_mesh_model_cb_t)(esp_ble_mesh_model_cb_event_t event,
esp_ble_mesh_model_cb_param_t *param);
esp_ble_mesh_model_cb_param_t *param);
/**
* @brief Register BLE Mesh callback for user-defined models' operations.
@ -75,6 +79,18 @@ esp_err_t esp_ble_mesh_model_msg_opcode_init(uint8_t *data, uint32_t opcode);
*/
esp_err_t esp_ble_mesh_client_model_init(esp_ble_mesh_model_t *model);
/**
* @brief De-initialize the user-defined client model.
*
* @note This function shall be invoked before esp_ble_mesh_deinit() is called.
*
* @param[in] model: Pointer of the Client model.
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_client_model_deinit(esp_ble_mesh_model_t *model);
/**
* @brief Send server model messages(such as server model status messages).
*
@ -88,8 +104,9 @@ esp_err_t esp_ble_mesh_client_model_init(esp_ble_mesh_model_t *model);
*
*/
esp_err_t esp_ble_mesh_server_model_send_msg(esp_ble_mesh_model_t *model,
esp_ble_mesh_msg_ctx_t *ctx, uint32_t opcode,
uint16_t length, uint8_t *data);
esp_ble_mesh_msg_ctx_t *ctx,
uint32_t opcode,
uint16_t length, uint8_t *data);
/**
* @brief Send client model message (such as model get, set, etc).
@ -107,9 +124,11 @@ esp_err_t esp_ble_mesh_server_model_send_msg(esp_ble_mesh_model_t *model,
*
*/
esp_err_t esp_ble_mesh_client_model_send_msg(esp_ble_mesh_model_t *model,
esp_ble_mesh_msg_ctx_t *ctx, uint32_t opcode,
uint16_t length, uint8_t *data, int32_t msg_timeout,
bool need_rsp, esp_ble_mesh_dev_role_t device_role);
esp_ble_mesh_msg_ctx_t *ctx,
uint32_t opcode,
uint16_t length, uint8_t *data,
int32_t msg_timeout, bool need_rsp,
esp_ble_mesh_dev_role_t device_role);
/**
* @brief Send a model publication message.
@ -134,6 +153,25 @@ esp_err_t esp_ble_mesh_model_publish(esp_ble_mesh_model_t *model, uint32_t opcod
uint16_t length, uint8_t *data,
esp_ble_mesh_dev_role_t device_role);
/**
* @brief Update a server model state value. If the model publication
* state is set properly (e.g. publish address is set to a valid
* address), it will publish corresponding status message.
*
* @note Currently this API is used to update bound state value, not
* for all server model states.
*
* @param[in] model: Server model which is going to update the state.
* @param[in] type: Server model state type.
* @param[in] value: Server model state value.
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_server_model_update_state(esp_ble_mesh_model_t *model,
esp_ble_mesh_server_state_type_t type,
esp_ble_mesh_server_state_value_t *value);
/**
* @brief Reset the provisioning procedure of the local BLE Mesh node.
*
@ -157,7 +195,7 @@ esp_err_t esp_ble_mesh_node_local_reset(void);
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_provisioner_set_node_name(int index, const char *name);
esp_err_t esp_ble_mesh_provisioner_set_node_name(uint16_t index, const char *name);
/**
* @brief This function is called to get the node (provisioned device) name.
@ -169,20 +207,119 @@ esp_err_t esp_ble_mesh_provisioner_set_node_name(int index, const char *name);
* @return Node name on success, or NULL on failure.
*
*/
const char *esp_ble_mesh_provisioner_get_node_name(int index);
const char *esp_ble_mesh_provisioner_get_node_name(uint16_t index);
/**
* @brief This function is called to get the node (provisioned device) index.
*
* @param[in] name: Name of the node (end by '\0').
*
* @return Node index on success, or (negative) error code from errno.h on failure.
* @return Node index on success, or an invalid value (0xFFFF) on failure.
*
*/
int esp_ble_mesh_provisioner_get_node_index(const char *name);
uint16_t esp_ble_mesh_provisioner_get_node_index(const char *name);
/**
* @brief This function is called to set the app key for the local BLE Mesh stack.
* @brief This function is called to store the Composition Data of the node.
*
* @param[in] unicast_addr: Element address of the node
* @param[in] data: Pointer of Composition Data
* @param[in] length: Length of Composition Data
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_provisioner_store_node_comp_data(uint16_t unicast_addr,
uint8_t *data, uint16_t length);
/**
* @brief This function is called to get the provisioned node information
* with the node device uuid.
*
* @param[in] uuid: Device UUID of the node
*
* @return Pointer of the node info struct or NULL on failure.
*
*/
esp_ble_mesh_node_t *esp_ble_mesh_provisioner_get_node_with_uuid(const uint8_t uuid[16]);
/**
* @brief This function is called to get the provisioned node information
* with the node unicast address.
*
* @param[in] unicast_addr: Unicast address of the node
*
* @return Pointer of the node info struct or NULL on failure.
*
*/
esp_ble_mesh_node_t *esp_ble_mesh_provisioner_get_node_with_addr(uint16_t unicast_addr);
/**
* @brief This function is called to get the provisioned node information
* with the node name.
*
* @param[in] name: Name of the node (end by '\0').
*
* @return Pointer of the node info struct or NULL on failure.
*
*/
esp_ble_mesh_node_t *esp_ble_mesh_provisioner_get_node_with_name(const char *name);
/**
* @brief This function is called by Provisioner to get provisioned node count.
*
* @return Number of the provisioned nodes.
*
*/
uint16_t esp_ble_mesh_provisioner_get_prov_node_count(void);
/**
* @brief This function is called by Provisioner to get the entry of the node table.
*
* @note After invoking the function to get the entry of nodes, users can use the "for"
* loop combined with the macro CONFIG_BLE_MESH_MAX_PROV_NODES to get each node's
* information. Before trying to read the node's information, users need to check
* if the node exists, i.e. if the *(esp_ble_mesh_node_t **node) is NULL.
* For example:
* ```
* const esp_ble_mesh_node_t **entry = esp_ble_mesh_provisioner_get_node_table_entry();
* for (int i = 0; i < CONFIG_BLE_MESH_MAX_PROV_NODES; i++) {
* const esp_ble_mesh_node_t *node = entry[i];
* if (node) {
* ......
* }
* }
* ```
*
* @return Pointer to the start of the node table.
*
*/
const esp_ble_mesh_node_t **esp_ble_mesh_provisioner_get_node_table_entry(void);
/**
* @brief This function is called to delete the provisioned node information
* with the node device uuid.
*
* @param[in] uuid: Device UUID of the node
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_provisioner_delete_node_with_uuid(const uint8_t uuid[16]);
/**
* @brief This function is called to delete the provisioned node information
* with the node unicast address.
*
* @param[in] unicast_addr: Unicast address of the node
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_provisioner_delete_node_with_addr(uint16_t unicast_addr);
/**
* @brief This function is called to add a local AppKey for Provisioner.
*
* @param[in] app_key: The app key to be set for the local BLE Mesh stack.
* @param[in] net_idx: The network key index.
@ -196,7 +333,21 @@ int esp_ble_mesh_provisioner_get_node_index(const char *name);
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_provisioner_add_local_app_key(const uint8_t app_key[16], uint16_t net_idx, uint16_t app_idx);
esp_err_t esp_ble_mesh_provisioner_add_local_app_key(const uint8_t app_key[16],
uint16_t net_idx, uint16_t app_idx);
/**
* @brief This function is used to update a local AppKey for Provisioner.
*
* @param[in] app_key: Value of the AppKey.
* @param[in] net_idx: Corresponding NetKey Index.
* @param[in] app_idx: The AppKey Index
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_provisioner_update_local_app_key(const uint8_t app_key[16],
uint16_t net_idx, uint16_t app_idx);
/**
* @brief This function is called by Provisioner to get the local app key value.
@ -224,7 +375,7 @@ const uint8_t *esp_ble_mesh_provisioner_get_local_app_key(uint16_t net_idx, uint
*
*/
esp_err_t esp_ble_mesh_provisioner_bind_app_key_to_local_model(uint16_t element_addr, uint16_t app_idx,
uint16_t model_id, uint16_t company_id);
uint16_t model_id, uint16_t company_id);
/**
* @brief This function is called by Provisioner to add local network key.
@ -241,6 +392,17 @@ esp_err_t esp_ble_mesh_provisioner_bind_app_key_to_local_model(uint16_t element_
*/
esp_err_t esp_ble_mesh_provisioner_add_local_net_key(const uint8_t net_key[16], uint16_t net_idx);
/**
* @brief This function is called by Provisioner to update a local network key.
*
* @param[in] net_key: Value of the NetKey.
* @param[in] net_idx: The NetKey Index.
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_provisioner_update_local_net_key(const uint8_t net_key[16], uint16_t net_idx);
/**
* @brief This function is called by Provisioner to get the local network key value.
*
@ -262,4 +424,8 @@ const uint8_t *esp_ble_mesh_provisioner_get_local_net_key(uint16_t net_idx);
*/
const uint8_t *esp_ble_mesh_get_fast_prov_app_key(uint16_t net_idx, uint16_t app_idx);
#ifdef __cplusplus
}
#endif
#endif /* _ESP_BLE_MESH_NETWORKING_API_H_ */

View File

@ -17,6 +17,10 @@
#include "esp_ble_mesh_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @brief: event, event code of provisioning events; param, parameters of provisioning events */
typedef void (* esp_ble_mesh_prov_cb_t)(esp_ble_mesh_prov_cb_event_t event,
esp_ble_mesh_prov_cb_param_t *param);
@ -72,7 +76,7 @@ esp_err_t esp_ble_mesh_node_prov_disable(esp_ble_mesh_prov_bearer_t bearers);
* @return ESP_OK on success or error code otherwise.
*/
esp_err_t esp_ble_mesh_node_set_oob_pub_key(uint8_t pub_key_x[32], uint8_t pub_key_y[32],
uint8_t private_key[32]);
uint8_t private_key[32]);
/**
* @brief Provide provisioning input OOB number.
@ -124,7 +128,7 @@ esp_err_t esp_ble_mesh_set_unprovisioned_device_name(const char *name);
* @return ESP_OK on success or error code otherwise.
*/
esp_err_t esp_ble_mesh_provisioner_read_oob_pub_key(uint8_t link_idx, uint8_t pub_key_x[32],
uint8_t pub_key_y[32]);
uint8_t pub_key_y[32]);
/**
* @brief Provide provisioning input OOB string.
@ -228,7 +232,35 @@ esp_err_t esp_ble_mesh_provisioner_prov_disable(esp_ble_mesh_prov_bearer_t beare
*
*/
esp_err_t esp_ble_mesh_provisioner_add_unprov_dev(esp_ble_mesh_unprov_dev_add_t *add_dev,
esp_ble_mesh_dev_add_flag_t flags);
esp_ble_mesh_dev_add_flag_t flags);
/** @brief Provision an unprovisioned device and assign a fixed unicast address for it in advance.
*
* @param[in] uuid: Device UUID of the unprovisioned device
* @param[in] addr: Device address of the unprovisioned device
* @param[in] addr_type: Device address type of the unprovisioned device
* @param[in] bearer: Provisioning bearer going to be used by Provisioner
* @param[in] oob_info: OOB info of the unprovisioned device
* @param[in] unicast_addr: Unicast address going to be allocated for the unprovisioned device
*
* @return Zero on success or (negative) error code otherwise.
*
* @note: 1. Currently address type only supports public address and static random address.
* 2. Bearer must be equal to ESP_BLE_MESH_PROV_ADV or ESP_BLE_MESH_PROV_GATT, since
* Provisioner will start to provision a device immediately once this function is
* invoked. And the input bearer must be identical with the one within the parameters
* of the ESP_BLE_MESH_PROVISIONER_RECV_UNPROV_ADV_PKT_EVT event.
* 3. If this function is used by a Provisioner to provision devices, the application
* should take care of the assigned unicast address and avoid overlap of the unicast
* addresses of different nodes.
* 4. Recommend to use only one of the functions "esp_ble_mesh_provisioner_add_unprov_dev"
* and "esp_ble_mesh_provisioner_prov_device_with_addr" by a Provisioner.
*/
esp_err_t esp_ble_mesh_provisioner_prov_device_with_addr(const uint8_t uuid[16],
esp_ble_mesh_bd_addr_t addr,
esp_ble_mesh_addr_type_t addr_type,
esp_ble_mesh_prov_bearer_t bearer,
uint16_t oob_info, uint16_t unicast_addr);
/**
* @brief Delete device from queue, reset current provisioning link and reset the node.
@ -259,9 +291,9 @@ esp_err_t esp_ble_mesh_provisioner_delete_dev(esp_ble_mesh_device_delete_t *del_
* @param[in] bearer: Adv packet received from PB-GATT or PB-ADV bearer.
*
*/
typedef void (*esp_ble_mesh_prov_adv_cb_t)(const esp_bd_addr_t addr, const esp_ble_addr_type_t addr_type,
const uint8_t adv_type, const uint8_t *dev_uuid,
uint16_t oob_info, esp_ble_mesh_prov_bearer_t bearer);
typedef void (*esp_ble_mesh_prov_adv_cb_t)(const esp_ble_mesh_bd_addr_t addr, const esp_ble_mesh_addr_type_t addr_type,
const uint8_t adv_type, const uint8_t *dev_uuid,
uint16_t oob_info, esp_ble_mesh_prov_bearer_t bearer);
/**
* @brief This function is called by Provisioner to set the part of the device UUID
@ -277,7 +309,7 @@ typedef void (*esp_ble_mesh_prov_adv_cb_t)(const esp_bd_addr_t addr, const esp_b
*
*/
esp_err_t esp_ble_mesh_provisioner_set_dev_uuid_match(const uint8_t *match_val, uint8_t match_len,
uint8_t offset, bool prov_after_match);
uint8_t offset, bool prov_after_match);
/**
* @brief This function is called by Provisioner to set provisioning data information
@ -290,6 +322,36 @@ esp_err_t esp_ble_mesh_provisioner_set_dev_uuid_match(const uint8_t *match_val,
*/
esp_err_t esp_ble_mesh_provisioner_set_prov_data_info(esp_ble_mesh_prov_data_info_t *prov_data_info);
/**
* @brief This function is called by Provisioner to set static oob value used for provisioning.
*
* @param[in] value: Pointer to the static oob value.
* @param[in] length: Length of the static oob value.
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_provisioner_set_static_oob_value(const uint8_t *value, uint8_t length);
/**
* @brief This function is called by Provisioner to set own Primary element address.
*
* @note This API must be invoked when BLE Mesh initialization is completed successfully,
* and can be invoked before Provisioner functionality is enabled.
* Once this API is invoked successfully, the prov_unicast_addr value in the struct
* esp_ble_mesh_prov_t will be ignored, and Provisioner will use this address as its
* own primary element address.
* And if the unicast address going to assigned for the next unprovisioned device is
* smaller than the input address + element number of Provisioner, then the address
* for the next unprovisioned device will be recalculated internally.
*
* @param[in] addr: Unicast address of the Primary element of Provisioner.
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_provisioner_set_primary_elem_addr(uint16_t addr);
/**
* @brief This function is called to set provisioning data information before starting
* fast provisioning.
@ -311,4 +373,8 @@ esp_err_t esp_ble_mesh_set_fast_prov_info(esp_ble_mesh_fast_prov_info_t *fast_pr
*/
esp_err_t esp_ble_mesh_set_fast_prov_action(esp_ble_mesh_fast_prov_action_t action);
#ifdef __cplusplus
}
#endif
#endif /* _ESP_BLE_MESH_PROVISIONING_API_H_ */

View File

@ -17,6 +17,10 @@
#include "esp_ble_mesh_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Enable advertising with Node Identity.
*
@ -49,5 +53,75 @@ esp_err_t esp_ble_mesh_proxy_gatt_enable(void);
*/
esp_err_t esp_ble_mesh_proxy_gatt_disable(void);
/**
* @brief Proxy Client creates a connection with the Proxy Server.
*
* @param[in] addr: Device address of the Proxy Server.
* @param[in] addr_type: Device address type(public or static random).
* @param[in] net_idx: NetKey Index related with Network ID in the Mesh Proxy
* advertising packet.
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_proxy_client_connect(esp_ble_mesh_bd_addr_t addr,
esp_ble_mesh_addr_type_t addr_type,
uint16_t net_idx);
/**
* @brief Proxy Client terminates a connection with the Proxy Server.
*
* @param[in] conn_handle: Proxy connection handle.
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_proxy_client_disconnect(uint8_t conn_handle);
/**
* @brief Proxy Client sets the filter type of the Proxy Server.
*
* @param[in] conn_handle: Proxy connection handle.
* @param[in] net_idx: Corresponding NetKey Index.
* @param[in] filter_type: whitelist or blacklist.
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_proxy_client_set_filter_type(uint8_t conn_handle, uint16_t net_idx,
esp_ble_mesh_proxy_filter_type_t filter_type);
/**
* @brief Proxy Client adds address to the Proxy Server filter list.
*
* @param[in] conn_handle: Proxy connection handle.
* @param[in] net_idx: Corresponding NetKey Index.
* @param[in] addr: Pointer to the filter address.
* @param[in] addr_num: Number of the filter address.
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_proxy_client_add_filter_addr(uint8_t conn_handle, uint16_t net_idx,
uint16_t *addr, uint16_t addr_num);
/**
* @brief Proxy Client removes address from the Proxy Server filter list.
*
* @param[in] conn_handle: Proxy connection handle.
* @param[in] net_idx: Corresponding NetKey Index.
* @param[in] addr: Pointer to the filter address.
* @param[in] addr_num: Number of the filter address.
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_proxy_client_remove_filter_addr(uint8_t conn_handle, uint16_t net_idx,
uint16_t *addr, uint16_t addr_num);
#ifdef __cplusplus
}
#endif
#endif /* _ESP_BLE_MESH_PROXY_API_H_ */

File diff suppressed because it is too large Load Diff

View File

@ -14,69 +14,90 @@
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include "esp_bt_defs.h"
#include "esp_bt_main.h"
#include "btc_ble_mesh_config_model.h"
#include "esp_ble_mesh_config_model_api.h"
esp_err_t esp_ble_mesh_register_config_client_callback(esp_ble_mesh_cfg_client_cb_t callback)
{
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
return (btc_profile_cb_set(BTC_PID_CFG_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
return (btc_profile_cb_set(BTC_PID_CONFIG_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_register_config_server_callback(esp_ble_mesh_cfg_server_cb_t callback)
{
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
return (btc_profile_cb_set(BTC_PID_CFG_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
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) {
case ESP_BLE_MESH_MODEL_OP_COMPOSITION_DATA_GET:
case ESP_BLE_MESH_MODEL_OP_MODEL_PUB_GET:
case ESP_BLE_MESH_MODEL_OP_SIG_MODEL_SUB_GET:
case ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_SUB_GET:
case ESP_BLE_MESH_MODEL_OP_APP_KEY_GET:
case ESP_BLE_MESH_MODEL_OP_NODE_IDENTITY_GET:
case ESP_BLE_MESH_MODEL_OP_SIG_MODEL_APP_GET:
case ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_APP_GET:
case ESP_BLE_MESH_MODEL_OP_KEY_REFRESH_PHASE_GET:
case ESP_BLE_MESH_MODEL_OP_LPN_POLLTIMEOUT_GET:
return true;
default:
return false;
}
}
esp_err_t esp_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_cfg_client_get_state_t *get_state)
esp_ble_mesh_cfg_client_get_state_t *get_state)
{
btc_ble_mesh_cfg_client_args_t arg = {0};
btc_ble_mesh_config_client_args_t arg = {0};
btc_msg_t msg = {0};
if (!params || !params->model || !params->ctx.addr || !get_state) {
if (params == NULL || params->model == NULL ||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
!ESP_BLE_MESH_ADDR_IS_UNICAST(params->ctx.addr) ||
(config_client_get_need_param(params->opcode) && get_state == NULL)) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_CFG_CLIENT;
msg.pid = BTC_PID_CONFIG_CLIENT;
msg.act = BTC_BLE_MESH_ACT_CONFIG_CLIENT_GET_STATE;
arg.cfg_client_get_state.params = params;
arg.cfg_client_get_state.get_state = get_state;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_cfg_client_args_t), btc_ble_mesh_cfg_client_arg_deep_copy)
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_config_client_args_t), btc_ble_mesh_config_client_arg_deep_copy)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_cfg_client_set_state_t *set_state)
esp_ble_mesh_cfg_client_set_state_t *set_state)
{
btc_ble_mesh_cfg_client_args_t arg = {0};
btc_ble_mesh_config_client_args_t arg = {0};
btc_msg_t msg = {0};
if (!params || !params->model || !params->ctx.addr || !set_state) {
if (params == NULL || params->model == NULL ||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
!ESP_BLE_MESH_ADDR_IS_UNICAST(params->ctx.addr) ||
(params->opcode != ESP_BLE_MESH_MODEL_OP_NODE_RESET && set_state == NULL)) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_CFG_CLIENT;
msg.pid = BTC_PID_CONFIG_CLIENT;
msg.act = BTC_BLE_MESH_ACT_CONFIG_CLIENT_SET_STATE;
arg.cfg_client_set_state.params = params;
arg.cfg_client_set_state.set_state = set_state;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_cfg_client_args_t), btc_ble_mesh_cfg_client_arg_deep_copy)
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_config_client_args_t), btc_ble_mesh_config_client_arg_deep_copy)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}

View File

@ -14,33 +14,46 @@
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include "esp_bt_defs.h"
#include "esp_bt_main.h"
#include "btc_ble_mesh_generic_model.h"
#include "esp_ble_mesh_generic_model_api.h"
esp_err_t esp_ble_mesh_register_generic_client_callback(esp_ble_mesh_generic_client_cb_t callback)
{
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
return (btc_profile_cb_set(BTC_PID_GENERIC_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
}
static bool generic_client_get_need_param(esp_ble_mesh_opcode_t opcode)
{
switch (opcode) {
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_GET:
case ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_GET:
case ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTY_GET:
case ESP_BLE_MESH_MODEL_OP_GEN_CLIENT_PROPERTIES_GET:
return true;
default:
return false;
}
}
esp_err_t esp_ble_mesh_generic_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_generic_client_get_state_t *get_state)
esp_ble_mesh_generic_client_get_state_t *get_state)
{
btc_ble_mesh_generic_client_args_t arg = {0};
btc_msg_t msg = {0};
if (!params || !params->model || !params->ctx.addr || !get_state) {
if (params == NULL || params->model == NULL ||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED ||
(generic_client_get_need_param(params->opcode) && get_state == NULL)) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GENERIC_CLIENT;
@ -53,16 +66,19 @@ esp_err_t esp_ble_mesh_generic_client_get_state(esp_ble_mesh_client_common_param
}
esp_err_t esp_ble_mesh_generic_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_generic_client_set_state_t *set_state)
esp_ble_mesh_generic_client_set_state_t *set_state)
{
btc_ble_mesh_generic_client_args_t arg = {0};
btc_msg_t msg = {0};
if (!params || !params->model || !params->ctx.addr || !set_state) {
if (params == NULL || params->model == NULL || set_state == NULL ||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GENERIC_CLIENT;
@ -73,3 +89,10 @@ 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);
}
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);
}

View File

@ -14,40 +14,40 @@
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include "esp_bt_defs.h"
#include "esp_bt_main.h"
#include "btc_ble_mesh_health_model.h"
#include "esp_ble_mesh_health_model_api.h"
esp_err_t esp_ble_mesh_register_health_client_callback(esp_ble_mesh_health_client_cb_t callback)
{
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
return (btc_profile_cb_set(BTC_PID_HEALTH_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_register_health_server_callback(esp_ble_mesh_health_server_cb_t callback)
{
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
return (btc_profile_cb_set(BTC_PID_HEALTH_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_health_client_get_state_t *get_state)
esp_ble_mesh_health_client_get_state_t *get_state)
{
btc_ble_mesh_health_client_args_t arg = {0};
btc_msg_t msg = {0};
if (!params || !params->model || !params->ctx.addr || !get_state) {
if (params == NULL || params->model == NULL ||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED ||
(params->opcode == ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET && get_state == NULL)) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_HEALTH_CLIENT;
@ -60,16 +60,19 @@ esp_err_t esp_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_
}
esp_err_t esp_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_health_client_set_state_t *set_state)
esp_ble_mesh_health_client_set_state_t *set_state)
{
btc_ble_mesh_health_client_args_t arg = {0};
btc_msg_t msg = {0};
if (!params || !params->model || !params->ctx.addr || !set_state) {
if (params == NULL || params->model == NULL || set_state == NULL ||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_HEALTH_CLIENT;
@ -86,12 +89,16 @@ esp_err_t esp_ble_mesh_health_server_fault_update(esp_ble_mesh_elem_t *element)
btc_ble_mesh_health_server_args_t arg = {0};
btc_msg_t msg = {0};
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
if (element == NULL) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_HEALTH_SERVER;
msg.act = BTC_BLE_MESH_ACT_HEALTH_SERVER_FAULT_UPDATE;
arg.fault_update.element = element;
arg.health_fault_update.element = element;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_health_server_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);

View File

@ -14,63 +14,72 @@
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include "esp_bt_defs.h"
#include "esp_bt_main.h"
#include "btc_ble_mesh_lighting_model.h"
#include "esp_ble_mesh_lighting_model_api.h"
esp_err_t esp_ble_mesh_register_light_client_callback(esp_ble_mesh_light_client_cb_t callback)
{
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
return (btc_profile_cb_set(BTC_PID_LIGHT_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
return (btc_profile_cb_set(BTC_PID_LIGHTING_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_light_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_light_client_get_state_t *get_state)
esp_ble_mesh_light_client_get_state_t *get_state)
{
btc_ble_mesh_light_client_args_t arg = {0};
btc_ble_mesh_lighting_client_args_t arg = {0};
btc_msg_t msg = {0};
if (!params || !params->model || !params->ctx.addr || !get_state) {
if (params == NULL || params->model == NULL ||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED ||
(params->opcode == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_GET && get_state == NULL)) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_LIGHT_CLIENT;
msg.act = BTC_BLE_MESH_ACT_LIGHT_CLIENT_GET_STATE;
msg.pid = BTC_PID_LIGHTING_CLIENT;
msg.act = BTC_BLE_MESH_ACT_LIGHTING_CLIENT_GET_STATE;
arg.light_client_get_state.params = params;
arg.light_client_get_state.get_state = get_state;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_light_client_args_t), btc_ble_mesh_light_client_arg_deep_copy)
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_lighting_client_args_t), btc_ble_mesh_lighting_client_arg_deep_copy)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_light_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_light_client_set_state_t *set_state)
esp_ble_mesh_light_client_set_state_t *set_state)
{
btc_ble_mesh_light_client_args_t arg = {0};
btc_ble_mesh_lighting_client_args_t arg = {0};
btc_msg_t msg = {0};
if (!params || !params->model || !params->ctx.addr || !set_state) {
if (params == NULL || params->model == NULL || set_state == NULL ||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_LIGHT_CLIENT;
msg.act = BTC_BLE_MESH_ACT_LIGHT_CLIENT_SET_STATE;
msg.pid = BTC_PID_LIGHTING_CLIENT;
msg.act = BTC_BLE_MESH_ACT_LIGHTING_CLIENT_SET_STATE;
arg.light_client_set_state.params = params;
arg.light_client_set_state.set_state = set_state;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_light_client_args_t), btc_ble_mesh_light_client_arg_deep_copy)
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_lighting_client_args_t), btc_ble_mesh_lighting_client_arg_deep_copy)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
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);
}

View File

@ -14,33 +14,32 @@
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include "esp_bt_defs.h"
#include "esp_bt_main.h"
#include "btc_ble_mesh_sensor_model.h"
#include "esp_ble_mesh_sensor_model_api.h"
esp_err_t esp_ble_mesh_register_sensor_client_callback(esp_ble_mesh_sensor_client_cb_t callback)
{
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
return (btc_profile_cb_set(BTC_PID_SENSOR_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_sensor_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_sensor_client_get_state_t *get_state)
esp_ble_mesh_sensor_client_get_state_t *get_state)
{
btc_ble_mesh_sensor_client_args_t arg = {0};
btc_msg_t msg = {0};
if (!params || !params->model || !params->ctx.addr || !get_state) {
if (params == NULL || params->model == NULL || get_state == NULL ||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_SENSOR_CLIENT;
@ -53,16 +52,19 @@ esp_err_t esp_ble_mesh_sensor_client_get_state(esp_ble_mesh_client_common_param_
}
esp_err_t esp_ble_mesh_sensor_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_sensor_client_set_state_t *set_state)
esp_ble_mesh_sensor_client_set_state_t *set_state)
{
btc_ble_mesh_sensor_client_args_t arg = {0};
btc_msg_t msg = {0};
if (!params || !params->model || !params->ctx.addr || !set_state) {
if (params == NULL || params->model == NULL || set_state == NULL ||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_SENSOR_CLIENT;
@ -74,3 +76,11 @@ esp_err_t esp_ble_mesh_sensor_client_set_state(esp_ble_mesh_client_common_param_
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
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);
}

View File

@ -14,33 +14,33 @@
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include "esp_bt_defs.h"
#include "esp_bt_main.h"
#include "btc_ble_mesh_time_scene_model.h"
#include "esp_ble_mesh_time_scene_model_api.h"
esp_err_t esp_ble_mesh_register_time_scene_client_callback(esp_ble_mesh_time_scene_client_cb_t callback)
{
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
return (btc_profile_cb_set(BTC_PID_TIME_SCENE_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_mesh_time_scene_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_time_scene_client_get_state_t *get_state)
esp_ble_mesh_time_scene_client_get_state_t *get_state)
{
btc_ble_mesh_time_scene_client_args_t arg = {0};
btc_msg_t msg = {0};
if (!params || !params->model || !params->ctx.addr || !get_state) {
if (params == NULL || params->model == NULL ||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED ||
(params->opcode == ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_GET && get_state == NULL)) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_TIME_SCENE_CLIENT;
@ -53,16 +53,19 @@ esp_err_t esp_ble_mesh_time_scene_client_get_state(esp_ble_mesh_client_common_pa
}
esp_err_t esp_ble_mesh_time_scene_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_time_scene_client_set_state_t *set_state)
esp_ble_mesh_time_scene_client_set_state_t *set_state)
{
btc_ble_mesh_time_scene_client_args_t arg = {0};
btc_msg_t msg = {0};
if (!params || !params->model || !params->ctx.addr || !set_state) {
if (params == NULL || params->model == NULL || set_state == NULL ||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_TIME_SCENE_CLIENT;
@ -74,3 +77,10 @@ esp_err_t esp_ble_mesh_time_scene_client_set_state(esp_ble_mesh_client_common_pa
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
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);
}

View File

@ -17,6 +17,10 @@
#include "esp_ble_mesh_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @def ESP_BLE_MESH_MODEL_CFG_SRV
*
* @brief Define a new Config Server Model.
@ -79,8 +83,8 @@ typedef struct esp_ble_mesh_cfg_srv {
uint8_t min_hops; /*!< Minimum hops when receiving Heartbeat messages */
uint8_t max_hops; /*!< Maximum hops when receiving Heartbeat messages */
/** Optional subscription tracking function */
void (*func)(uint8_t hops, uint16_t feature);
/** Optional heartbeat subscription tracking function */
esp_ble_mesh_cb_t heartbeat_recv_cb;
} heartbeat_sub;
} esp_ble_mesh_cfg_srv_t;
@ -513,8 +517,8 @@ typedef struct {
/** Parameters of Config Network Transmit Status */
typedef struct {
uint8_t net_trans_count:3; /*!< Number of transmissions for each Network PDU originating from the node */
uint8_t net_trans_step :5; /*!< Maximum hops when receiving Heartbeat messages */
uint8_t net_trans_count: 3; /*!< Number of transmissions for each Network PDU originating from the node */
uint8_t net_trans_step : 5; /*!< Maximum hops when receiving Heartbeat messages */
} esp_ble_mesh_cfg_net_trans_status_cb_t;
/** Parameters of Config SIG/Vendor Subscription List */
@ -610,28 +614,135 @@ typedef enum {
ESP_BLE_MESH_CFG_CLIENT_EVT_MAX,
} esp_ble_mesh_cfg_client_cb_event_t;
/** Parameter of Config AppKey Add */
/**
* @brief Configuration Server model related context.
*/
typedef struct {
uint16_t app_idx; /*!< AppKey Index of the Config AppKey Add */
} esp_ble_mesh_cfg_srv_app_key_add_cb_t;
uint16_t element_addr; /*!< Element Address */
uint16_t pub_addr; /*!< Publish Address */
uint16_t app_idx; /*!< AppKey Index */
bool cred_flag; /*!< Friendship Credential Flag */
uint8_t pub_ttl; /*!< Publish TTL */
uint8_t pub_period; /*!< Publish Period */
uint8_t pub_retransmit; /*!< Publish Retransmit */
uint16_t company_id; /*!< Company ID */
uint16_t model_id; /*!< Model ID */
} esp_ble_mesh_state_change_cfg_mod_pub_set_t;
/** Parameters of Config Model Subscription Add */
typedef struct {
uint16_t element_addr; /*!< Element Address */
uint16_t sub_addr; /*!< Subscription Address */
uint16_t company_id; /*!< Company ID */
uint16_t model_id; /*!< Model ID */
} esp_ble_mesh_state_change_cfg_model_sub_add_t;
/** Parameters of Config Model Subscription Delete */
typedef struct {
uint16_t element_addr; /*!< Element Address */
uint16_t sub_addr; /*!< Subscription Address */
uint16_t company_id; /*!< Company ID */
uint16_t model_id; /*!< Model ID */
} esp_ble_mesh_state_change_cfg_model_sub_delete_t;
/** Parameters of Config NetKey Add */
typedef struct {
uint16_t net_idx; /*!< NetKey Index */
uint8_t net_key[16]; /*!< NetKey */
} esp_ble_mesh_state_change_cfg_netkey_add_t;
/** Parameters of Config NetKey Update */
typedef struct {
uint16_t net_idx; /*!< NetKey Index */
uint8_t net_key[16]; /*!< NetKey */
} esp_ble_mesh_state_change_cfg_netkey_update_t;
/** Parameter of Config NetKey Delete */
typedef struct {
uint16_t net_idx; /*!< NetKey Index */
} esp_ble_mesh_state_change_cfg_netkey_delete_t;
/** Parameters of Config AppKey Add */
typedef struct {
uint16_t net_idx; /*!< NetKey Index */
uint16_t app_idx; /*!< AppKey Index */
uint8_t app_key[16]; /*!< AppKey */
} esp_ble_mesh_state_change_cfg_appkey_add_t;
/** Parameters of Config AppKey Update */
typedef struct {
uint16_t net_idx; /*!< NetKey Index */
uint16_t app_idx; /*!< AppKey Index */
uint8_t app_key[16]; /*!< AppKey */
} esp_ble_mesh_state_change_cfg_appkey_update_t;
/** Parameters of Config AppKey Delete */
typedef struct {
uint16_t net_idx; /*!< NetKey Index */
uint16_t app_idx; /*!< AppKey Index */
} esp_ble_mesh_state_change_cfg_appkey_delete_t;
/** Parameters of Config Model App Bind */
typedef struct {
uint16_t element_addr; /*!< Element Address */
uint16_t app_idx; /*!< AppKey Index */
uint16_t company_id; /*!< Company ID */
uint16_t model_id; /*!< Model ID */
} esp_ble_mesh_state_change_cfg_model_app_bind_t;
/** Parameters of Config Model App Unbind */
typedef struct {
uint16_t element_addr; /*!< Element Address */
uint16_t app_idx; /*!< AppKey Index */
uint16_t company_id; /*!< Company ID */
uint16_t model_id; /*!< Model ID */
} esp_ble_mesh_state_change_cfg_model_app_unbind_t;
/** Parameters of Config Key Refresh Phase Set */
typedef struct {
uint16_t net_idx; /*!< NetKey Index */
uint8_t kr_phase; /*!< New Key Refresh Phase Transition */
} esp_ble_mesh_state_change_cfg_kr_phase_set_t;
/**
* @brief Configuration Server Model received message union
* @brief Configuration Server model state change value union
*/
typedef union {
esp_ble_mesh_cfg_srv_app_key_add_cb_t app_key_add; /*!< The Config AppKey Add event value */
} esp_ble_mesh_cfg_server_common_cb_param_t;
/**
* The recv_op in ctx can be used to decide which state is changed.
*/
esp_ble_mesh_state_change_cfg_mod_pub_set_t mod_pub_set; /*!< Config Model Publication Set */
esp_ble_mesh_state_change_cfg_model_sub_add_t mod_sub_add; /*!< Config Model Subscription Add */
esp_ble_mesh_state_change_cfg_model_sub_delete_t mod_sub_delete; /*!< Config Model Subscription Delete */
esp_ble_mesh_state_change_cfg_netkey_add_t netkey_add; /*!< Config NetKey Add */
esp_ble_mesh_state_change_cfg_netkey_update_t netkey_update; /*!< Config NetKey Update */
esp_ble_mesh_state_change_cfg_netkey_delete_t netkey_delete; /*!< Config NetKey Delete */
esp_ble_mesh_state_change_cfg_appkey_add_t appkey_add; /*!< Config AppKey Add */
esp_ble_mesh_state_change_cfg_appkey_update_t appkey_update; /*!< Config AppKey Update */
esp_ble_mesh_state_change_cfg_appkey_delete_t appkey_delete; /*!< Config AppKey Delete */
esp_ble_mesh_state_change_cfg_model_app_bind_t mod_app_bind; /*!< Config Model App Bind */
esp_ble_mesh_state_change_cfg_model_app_unbind_t mod_app_unbind; /*!< Config Model App Unbind */
esp_ble_mesh_state_change_cfg_kr_phase_set_t kr_phase_set; /*!< Config Key Refresh Phase Set */
} esp_ble_mesh_cfg_server_state_change_t;
/** Configuration Server Model callback parameters */
/**
* @brief Configuration Server model callback value union
*/
typedef union {
esp_ble_mesh_cfg_server_state_change_t state_change; /*!< ESP_BLE_MESH_CFG_SERVER_STATE_CHANGE_EVT */
} esp_ble_mesh_cfg_server_cb_value_t;
/** Configuration Server model callback parameters */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the server model structure */
esp_ble_mesh_msg_ctx_t ctx; /*!< The context of the received message */
esp_ble_mesh_cfg_server_common_cb_param_t status_cb; /*!< The received configuration message callback values */
esp_ble_mesh_model_t *model; /*!< Pointer to the server model structure */
esp_ble_mesh_msg_ctx_t ctx; /*!< Context of the received message */
esp_ble_mesh_cfg_server_cb_value_t value; /*!< Value of the received configuration messages */
} esp_ble_mesh_cfg_server_cb_param_t;
/** This enum value is the event of Configuration Server Model */
/** This enum value is the event of Configuration Server model */
typedef enum {
ESP_BLE_MESH_CFG_SERVER_RECV_MSG_EVT,
ESP_BLE_MESH_CFG_SERVER_STATE_CHANGE_EVT,
ESP_BLE_MESH_CFG_SERVER_EVT_MAX,
} esp_ble_mesh_cfg_server_cb_event_t;
@ -645,7 +756,7 @@ typedef enum {
* @param param: Pointer to callback parameter
*/
typedef void (* esp_ble_mesh_cfg_client_cb_t)(esp_ble_mesh_cfg_client_cb_event_t event,
esp_ble_mesh_cfg_client_cb_param_t *param);
esp_ble_mesh_cfg_client_cb_param_t *param);
/**
* @brief Configuration Server Model callback function type
@ -653,7 +764,7 @@ typedef void (* esp_ble_mesh_cfg_client_cb_t)(esp_ble_mesh_cfg_client_cb_event_t
* @param param: Pointer to callback parameter
*/
typedef void (* esp_ble_mesh_cfg_server_cb_t)(esp_ble_mesh_cfg_server_cb_event_t event,
esp_ble_mesh_cfg_server_cb_param_t *param);
esp_ble_mesh_cfg_server_cb_param_t *param);
/**
* @brief Register BLE Mesh Config Client Model callback.
@ -689,7 +800,7 @@ esp_err_t esp_ble_mesh_register_config_server_callback(esp_ble_mesh_cfg_server_c
*
*/
esp_err_t esp_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_cfg_client_get_state_t *get_state);
esp_ble_mesh_cfg_client_get_state_t *get_state);
/**
* @brief Set the value of the Configuration Server Model states using the Config Client Model set messages.
@ -705,7 +816,11 @@ esp_err_t esp_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param_
*
*/
esp_err_t esp_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_cfg_client_set_state_t *set_state);
esp_ble_mesh_cfg_client_set_state_t *set_state);
#endif /** _ESP_BLE_MESH_CONFIG_MODEL_API_H_ */
#ifdef __cplusplus
}
#endif
#endif /* _ESP_BLE_MESH_CONFIG_MODEL_API_H_ */

View File

@ -19,9 +19,12 @@
#ifndef _ESP_BLE_MESH_GENERIC_MODEL_API_H_
#define _ESP_BLE_MESH_GENERIC_MODEL_API_H_
#include "generic_client.h"
#include "esp_ble_mesh_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @def ESP_BLE_MESH_MODEL_GEN_ONOFF_CLI
*
* @brief Define a new Generic OnOff Client Model.
@ -257,7 +260,7 @@ typedef struct {
/** Parameters of Generic Admin Property Set. */
typedef struct {
uint16_t property_id; /*!< Property ID identifying a Generic Admin Property */
uint8_t user_access; /*!< Enumeration indicating user accessn */
uint8_t user_access; /*!< Enumeration indicating user access */
struct net_buf_simple *property_value; /*!< Raw value for the Admin Property */
} esp_ble_mesh_gen_admin_property_set_t;
@ -480,7 +483,7 @@ typedef enum {
* @param param: Pointer to callback parameter
*/
typedef void (* esp_ble_mesh_generic_client_cb_t)(esp_ble_mesh_generic_client_cb_event_t event,
esp_ble_mesh_generic_client_cb_param_t *param);
esp_ble_mesh_generic_client_cb_param_t *param);
/**
* @brief Register BLE Mesh Generic Client Model callback.
@ -506,7 +509,7 @@ esp_err_t esp_ble_mesh_register_generic_client_callback(esp_ble_mesh_generic_cli
*
*/
esp_err_t esp_ble_mesh_generic_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_generic_client_get_state_t *get_state);
esp_ble_mesh_generic_client_get_state_t *get_state);
/**
* @brief Set the value of Generic Server Model states using the Generic Client Model set messages.
@ -522,8 +525,781 @@ esp_err_t esp_ble_mesh_generic_client_get_state(esp_ble_mesh_client_common_param
*
*/
esp_err_t esp_ble_mesh_generic_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_generic_client_set_state_t *set_state);
esp_ble_mesh_generic_client_set_state_t *set_state);
/**
* @brief Generic Server Models related context.
*/
/** @def ESP_BLE_MESH_MODEL_GEN_ONOFF_SRV
*
* @brief Define a new Generic OnOff Server Model.
*
* @note 1. The Generic OnOff Server Model is a root model.
* 2. This model shall support model publication and model subscription.
*
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
* @param srv_data Pointer to the unique struct esp_ble_mesh_gen_onoff_srv_t.
*
* @return New Generic OnOff Server Model instance.
*/
#define ESP_BLE_MESH_MODEL_GEN_ONOFF_SRV(srv_pub, srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_SRV, \
NULL, srv_pub, srv_data)
/** @def ESP_BLE_MESH_MODEL_GEN_LEVEL_SRV
*
* @brief Define a new Generic Level Server Model.
*
* @note 1. The Generic Level Server Model is a root model.
* 2. This model shall support model publication and model subscription.
*
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
* @param srv_data Pointer to the unique struct esp_ble_mesh_gen_level_srv_t.
*
* @return New Generic Level Server Model instance.
*/
#define ESP_BLE_MESH_MODEL_GEN_LEVEL_SRV(srv_pub, srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_LEVEL_SRV, \
NULL, srv_pub, srv_data)
/** @def ESP_BLE_MESH_MODEL_GEN_DEF_TRANS_TIME_SRV
*
* @brief Define a new Generic Default Transition Time Server Model.
*
* @note 1. The Generic Default Transition Time Server Model is a root model.
* 2. This model shall support model publication and model subscription.
*
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
* @param srv_data Pointer to the unique struct esp_ble_mesh_gen_def_trans_time_srv_t.
*
* @return New Generic Default Transition Time Server Model instance.
*/
#define ESP_BLE_MESH_MODEL_GEN_DEF_TRANS_TIME_SRV(srv_pub, srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_SRV, \
NULL, srv_pub, srv_data)
/** @def ESP_BLE_MESH_MODEL_GEN_POWER_ONOFF_SRV
*
* @brief Define a new Generic Power OnOff Server Model.
*
* @note 1. The Generic Power OnOff Server model extends the Generic OnOff Server
* model. When this model is present on an element, the corresponding
* Generic Power OnOff Setup Server model shall also be present.
* 2. This model may be used to represent a variety of devices that do not
* fit any of the model descriptions that have been defined but support
* the generic properties of On/Off.
* 3. This model shall support model publication and model subscription.
*
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
* @param srv_data Pointer to the unique struct esp_ble_mesh_gen_power_onoff_srv_t.
*
* @return New Generic Power OnOff Server Model instance.
*/
#define ESP_BLE_MESH_MODEL_GEN_POWER_ONOFF_SRV(srv_pub, srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SRV, \
NULL, srv_pub, srv_data)
/** @def ESP_BLE_MESH_MODEL_GEN_POWER_ONOFF_SETUP_SRV
*
* @brief Define a new Generic Power OnOff Setup Server Model.
*
* @note 1. The Generic Power OnOff Setup Server model extends the Generic Power
* OnOff Server model and the Generic Default Transition Time Server model.
* 2. This model shall support model subscription.
*
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
* @param srv_data Pointer to the unique struct esp_ble_mesh_gen_power_onoff_setup_srv_t.
*
* @return New Generic Power OnOff Setup Server Model instance.
*/
#define ESP_BLE_MESH_MODEL_GEN_POWER_ONOFF_SETUP_SRV(srv_pub, srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SETUP_SRV, \
NULL, srv_pub, srv_data)
/** @def ESP_BLE_MESH_MODEL_GEN_POWER_LEVEL_SRV
*
* @brief Define a new Generic Power Level Server Model.
*
* @note 1. The Generic Power Level Server model extends the Generic Power OnOff
* Server model and the Generic Level Server model. When this model is
* present on an Element, the corresponding Generic Power Level Setup
* Server model shall also be present.
* 2. This model shall support model publication and model subscription.
*
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
* @param srv_data Pointer to the unique struct esp_ble_mesh_gen_power_level_srv_t.
*
* @return New Generic Power Level Server Model instance.
*/
#define ESP_BLE_MESH_MODEL_GEN_POWER_LEVEL_SRV(srv_pub, srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SRV, \
NULL, srv_pub, srv_data)
/** @def ESP_BLE_MESH_MODEL_GEN_POWER_LEVEL_SETUP_SRV
*
* @brief Define a new Generic Power Level Setup Server Model.
*
* @note 1. The Generic Power Level Setup Server model extends the Generic Power
* Level Server model and the Generic Power OnOff Setup Server model.
* 2. This model shall support model subscription.
*
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
* @param srv_data Pointer to the unique struct esp_ble_mesh_gen_power_level_setup_srv_t.
*
* @return New Generic Power Level Setup Server Model instance.
*/
#define ESP_BLE_MESH_MODEL_GEN_POWER_LEVEL_SETUP_SRV(srv_pub, srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SETUP_SRV, \
NULL, srv_pub, srv_data)
/** @def ESP_BLE_MESH_MODEL_GEN_BATTERY_SRV
*
* @brief Define a new Generic Battery Server Model.
*
* @note 1. The Generic Battery Server Model is a root model.
* 2. This model shall support model publication and model subscription.
* 3. The model may be used to represent an element that is powered by a battery.
*
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
* @param srv_data Pointer to the unique struct esp_ble_mesh_gen_battery_srv_t.
*
* @return New Generic Battery Server Model instance.
*/
#define ESP_BLE_MESH_MODEL_GEN_BATTERY_SRV(srv_pub, srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_BATTERY_SRV, \
NULL, srv_pub, srv_data)
/** @def ESP_BLE_MESH_MODEL_GEN_LOCATION_SRV
*
* @brief Define a new Generic Location Server Model.
*
* @note 1. The Generic Location Server model is a root model. When this model
* is present on an Element, the corresponding Generic Location Setup
* Server model shall also be present.
* 2. This model shall support model publication and model subscription.
* 3. The model may be used to represent an element that knows its
* location (global or local).
*
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
* @param srv_data Pointer to the unique struct esp_ble_mesh_gen_location_srv_t.
*
* @return New Generic Location Server Model instance.
*/
#define ESP_BLE_MESH_MODEL_GEN_LOCATION_SRV(srv_pub, srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_LOCATION_SRV, \
NULL, srv_pub, srv_data)
/** @def ESP_BLE_MESH_MODEL_GEN_LOCATION_SETUP_SRV
*
* @brief Define a new Generic Location Setup Server Model.
*
* @note 1. The Generic Location Setup Server model extends the Generic Location
* Server model.
* 2. This model shall support model subscription.
*
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
* @param srv_data Pointer to the unique struct esp_ble_mesh_gen_location_setup_srv_t.
*
* @return New Generic Location Setup Server Model instance.
*/
#define ESP_BLE_MESH_MODEL_GEN_LOCATION_SETUP_SRV(srv_pub, srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_LOCATION_SETUP_SRV, \
NULL, srv_pub, srv_data)
/** @def ESP_BLE_MESH_MODEL_GEN_USER_PROP_SRV
*
* @brief Define a new Generic User Property Server Model.
*
* @note 1. The Generic User Property Server model is a root model.
* 2. This model shall support model publication and model subscription.
*
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
* @param srv_data Pointer to the unique struct esp_ble_mesh_gen_user_prop_srv_t.
*
* @return New Generic User Property Server Model instance.
*/
#define ESP_BLE_MESH_MODEL_GEN_USER_PROP_SRV(srv_pub, srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_USER_PROP_SRV, \
NULL, srv_pub, srv_data)
/** @def ESP_BLE_MESH_MODEL_GEN_ADMIN_PROP_SRV
*
* @brief Define a new Generic Admin Property Server Model.
*
* @note 1. The Generic Admin Property Server model extends the Generic User
* Property Server model.
* 2. This model shall support model publication and model subscription.
*
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
* @param srv_data Pointer to the unique struct esp_ble_mesh_gen_admin_prop_srv_t.
*
* @return New Generic Admin Property Server Model instance.
*/
#define ESP_BLE_MESH_MODEL_GEN_ADMIN_PROP_SRV(srv_pub, srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_ADMIN_PROP_SRV, \
NULL, srv_pub, srv_data)
/** @def ESP_BLE_MESH_MODEL_GEN_MANUFACTURER_PROP_SRV
*
* @brief Define a new Generic Manufacturer Property Server Model.
*
* @note 1. The Generic Manufacturer Property Server model extends the Generic
* User Property Server model.
* 2. This model shall support model publication and model subscription.
*
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
* @param srv_data Pointer to the unique struct esp_ble_mesh_gen_manu_prop_srv_t.
*
* @return New Generic Manufacturer Property Server Model instance.
*/
#define ESP_BLE_MESH_MODEL_GEN_MANUFACTURER_PROP_SRV(srv_pub, srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_MANUFACTURER_PROP_SRV, \
NULL, srv_pub, srv_data)
/** @def ESP_BLE_MESH_MODEL_GEN_CLIENT_PROP_SRV
*
* @brief Define a new Generic User Property Server Model.
*
* @note 1. The Generic Client Property Server model is a root model.
* 2. This model shall support model publication and model subscription.
*
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
* @param srv_data Pointer to the unique struct esp_ble_mesh_gen_client_prop_srv_t.
*
* @return New Generic Client Property Server Model instance.
*/
#define ESP_BLE_MESH_MODEL_GEN_CLIENT_PROP_SRV(srv_pub, srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_CLIENT_PROP_SRV, \
NULL, srv_pub, srv_data)
/** Parameters of Generic OnOff state */
typedef struct {
uint8_t onoff; /*!< The present value of the Generic OnOff state */
uint8_t target_onoff; /*!< The target value of the Generic OnOff state */
} esp_ble_mesh_gen_onoff_state_t;
/** User data of Generic OnOff Server Model */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Generic OnOff Server Model. Initialized internally. */
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
esp_ble_mesh_gen_onoff_state_t state; /*!< Parameters of the Generic OnOff state */
esp_ble_mesh_last_msg_info_t last; /*!< Parameters of the last received set message */
esp_ble_mesh_state_transition_t transition; /*!< Parameters of state transition */
} esp_ble_mesh_gen_onoff_srv_t;
/** Parameters of Generic Level state */
typedef struct {
int16_t level; /*!< The present value of the Generic Level state */
int16_t target_level; /*!< The target value of the Generic Level state */
/**
* When a new transaction starts, level should be set to last_last, and use
* "level + incoming delta" to calculate the target level. In another word,
* "last_level" is used to record "level" of the last transaction, and
* "last_delta" is used to record the previously received delta_level value.
*/
int16_t last_level; /*!< The last value of the Generic Level state */
int32_t last_delta; /*!< The last delta change of the Generic Level state */
bool move_start; /*!< Indicate if the transition of the Generic Level state has been started */
bool positive; /*!< Indicate if the transition is positive or negative */
} esp_ble_mesh_gen_level_state_t;
/** User data of Generic Level Server Model */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Level Server Model. Initialized internally. */
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
esp_ble_mesh_gen_level_state_t state; /*!< Parameters of the Generic Level state */
esp_ble_mesh_last_msg_info_t last; /*!< Parameters of the last received set message */
esp_ble_mesh_state_transition_t transition; /*!< Parameters of state transition */
int32_t tt_delta_level; /*!< Delta change value of level state transition */
} esp_ble_mesh_gen_level_srv_t;
/** Parameter of Generic Default Transition Time state */
typedef struct {
uint8_t trans_time; /*!< The value of the Generic Default Transition Time state */
} esp_ble_mesh_gen_def_trans_time_state_t;
/** User data of Generic Default Transition Time Server Model */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Default Transition Time Server Model. Initialized internally. */
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
esp_ble_mesh_gen_def_trans_time_state_t state; /*!< Parameters of the Generic Default Transition Time state */
} esp_ble_mesh_gen_def_trans_time_srv_t;
/** Parameter of Generic OnPowerUp state */
typedef struct {
uint8_t onpowerup; /*!< The value of the Generic OnPowerUp state */
} esp_ble_mesh_gen_onpowerup_state_t;
/** User data of Generic Power OnOff Server Model */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Power OnOff Server Model. Initialized internally. */
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
esp_ble_mesh_gen_onpowerup_state_t *state; /*!< Parameters of the Generic OnPowerUp state */
} esp_ble_mesh_gen_power_onoff_srv_t;
/** User data of Generic Power OnOff Setup Server Model */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Power OnOff Setup Server Model. Initialized internally. */
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
esp_ble_mesh_gen_onpowerup_state_t *state; /*!< Parameters of the Generic OnPowerUp state */
} esp_ble_mesh_gen_power_onoff_setup_srv_t;
/** Parameters of Generic Power Level state */
typedef struct {
uint16_t power_actual; /*!< The present value of the Generic Power Actual state */
uint16_t target_power_actual; /*!< The target value of the Generic Power Actual state */
uint16_t power_last; /*!< The value of the Generic Power Last state */
uint16_t power_default; /*!< The value of the Generic Power Default state */
uint8_t status_code; /*!< The status code of setting Generic Power Range state */
uint16_t power_range_min; /*!< The minimum value of the Generic Power Range state */
uint16_t power_range_max; /*!< The maximum value of the Generic Power Range state */
} esp_ble_mesh_gen_power_level_state_t;
/** User data of Generic Power Level Server Model */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Power Level Server Model. Initialized internally. */
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
esp_ble_mesh_gen_power_level_state_t *state; /*!< Parameters of the Generic Power Level state */
esp_ble_mesh_last_msg_info_t last; /*!< Parameters of the last received set message */
esp_ble_mesh_state_transition_t transition; /*!< Parameters of state transition */
int32_t tt_delta_level; /*!< Delta change value of level state transition */
} esp_ble_mesh_gen_power_level_srv_t;
/** User data of Generic Power Level Setup Server Model */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Power Level Setup Server Model. Initialized internally. */
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
esp_ble_mesh_gen_power_level_state_t *state; /*!< Parameters of the Generic Power Level state */
} esp_ble_mesh_gen_power_level_setup_srv_t;
/** Parameters of Generic Battery state */
typedef struct {
uint32_t battery_level : 8, /*!< The value of the Generic Battery Level state */
time_to_discharge : 24; /*!< The value of the Generic Battery Time to Discharge state */
uint32_t time_to_charge : 24, /*!< The value of the Generic Battery Time to Charge state */
battery_flags : 8; /*!< The value of the Generic Battery Flags state */
} esp_ble_mesh_gen_battery_state_t;
/** User data of Generic Battery Server Model */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Battery Server Model. Initialized internally. */
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
esp_ble_mesh_gen_battery_state_t state; /*!< Parameters of the Generic Battery state */
} esp_ble_mesh_gen_battery_srv_t;
/** Parameters of Generic Location state */
typedef struct {
int32_t global_latitude; /*!< The value of the Global Latitude field */
int32_t global_longitude; /*!< The value of the Global Longitude field */
int16_t global_altitude; /*!< The value of the Global Altitude field */
int16_t local_north; /*!< The value of the Local North field */
int16_t local_east; /*!< The value of the Local East field */
int16_t local_altitude; /*!< The value of the Local Altitude field */
uint8_t floor_number; /*!< The value of the Floor Number field */
uint16_t uncertainty; /*!< The value of the Uncertainty field */
} esp_ble_mesh_gen_location_state_t;
/** User data of Generic Location Server Model */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Location Server Model. Initialized internally. */
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
esp_ble_mesh_gen_location_state_t *state; /*!< Parameters of the Generic Location state */
} esp_ble_mesh_gen_location_srv_t;
/** User data of Generic Location Setup Server Model */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Location Setup Server Model. Initialized internally. */
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
esp_ble_mesh_gen_location_state_t *state; /*!< Parameters of the Generic Location state */
} esp_ble_mesh_gen_location_setup_srv_t;
/** This enum value is the access value of Generic User Property */
typedef enum {
ESP_BLE_MESH_GEN_USER_ACCESS_PROHIBIT,
ESP_BLE_MESH_GEN_USER_ACCESS_READ,
ESP_BLE_MESH_GEN_USER_ACCESS_WRITE,
ESP_BLE_MESH_GEN_USER_ACCESS_READ_WRITE,
} esp_ble_mesh_gen_user_prop_access_t;
/** This enum value is the access value of Generic Admin Property */
typedef enum {
ESP_BLE_MESH_GEN_ADMIN_NOT_USER_PROP,
ESP_BLE_MESH_GEN_ADMIN_ACCESS_READ,
ESP_BLE_MESH_GEN_ADMIN_ACCESS_WRITE,
ESP_BLE_MESH_GEN_ADMIN_ACCESS_READ_WRITE,
} esp_ble_mesh_gen_admin_prop_access_t;
/** This enum value is the access value of Generic Manufacturer Property */
typedef enum {
ESP_BLE_MESH_GEN_MANU_NOT_USER_PROP,
ESP_BLE_MESH_GEN_MANU_ACCESS_READ,
} esp_ble_mesh_gen_manu_prop_access_t;
/** Parameters of Generic Property states */
typedef struct {
uint16_t id; /*!< The value of User/Admin/Manufacturer Property ID */
uint8_t user_access; /*!< The value of User Access field */
uint8_t admin_access; /*!< The value of Admin Access field */
uint8_t manu_access; /*!< The value of Manufacturer Access field */
struct net_buf_simple *val; /*!< The value of User/Admin/Manufacturer Property */
} esp_ble_mesh_generic_property_t;
/** User data of Generic User Property Server Model */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Generic User Property Server Model. Initialized internally. */
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
uint8_t property_count; /*!< Generic User Property count */
esp_ble_mesh_generic_property_t *properties; /*!< Parameters of the Generic User Property state */
} esp_ble_mesh_gen_user_prop_srv_t;
/** User data of Generic Admin Property Server Model */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Admin Property Server Model. Initialized internally. */
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
uint8_t property_count; /*!< Generic Admin Property count */
esp_ble_mesh_generic_property_t *properties; /*!< Parameters of the Generic Admin Property state */
} esp_ble_mesh_gen_admin_prop_srv_t;
/** User data of Generic Manufacturer Property Server Model */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Manufacturer Property Server Model. Initialized internally. */
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
uint8_t property_count; /*!< Generic Manufacturer Property count */
esp_ble_mesh_generic_property_t *properties; /*!< Parameters of the Generic Manufacturer Property state */
} esp_ble_mesh_gen_manu_prop_srv_t;
/** User data of Generic Client Property Server Model */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Client Property Server Model. Initialized internally. */
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
uint8_t id_count; /*!< Generic Client Property ID count */
uint16_t *property_ids; /*!< Parameters of the Generic Client Property state */
} esp_ble_mesh_gen_client_prop_srv_t;
/** Parameter of Generic OnOff Set state change event */
typedef struct {
uint8_t onoff; /*!< The value of Generic OnOff state */
} esp_ble_mesh_state_change_gen_onoff_set_t;
/** Parameter of Generic Level Set state change event */
typedef struct {
int16_t level; /*!< The value of Generic Level state */
} esp_ble_mesh_state_change_gen_level_set_t;
/** Parameter of Generic Delta Set state change event */
typedef struct {
int16_t level; /*!< The value of Generic Level state */
} esp_ble_mesh_state_change_gen_delta_set_t;
/** Parameter of Generic Move Set state change event */
typedef struct {
int16_t level; /*!< The value of Generic Level state */
} esp_ble_mesh_state_change_gen_move_set_t;
/** Parameter of Generic Default Transition Time Set state change event */
typedef struct {
uint8_t trans_time; /*!< The value of Generic Default Transition Time state */
} esp_ble_mesh_state_change_gen_def_trans_time_set_t;
/** Parameter of Generic OnPowerUp Set state change event */
typedef struct {
uint8_t onpowerup; /*!< The value of Generic OnPowerUp state */
} esp_ble_mesh_state_change_gen_onpowerup_set_t;
/** Parameter of Generic Power Level Set state change event */
typedef struct {
uint16_t power; /*!< The value of Generic Power Actual state */
} esp_ble_mesh_state_change_gen_power_level_set_t;
/** Parameter of Generic Power Default Set state change event */
typedef struct {
uint16_t power; /*!< The value of Generic Power Default state */
} esp_ble_mesh_state_change_gen_power_default_set_t;
/** Parameters of Generic Power Range Set state change event */
typedef struct {
uint16_t range_min; /*!< The minimum value of Generic Power Range state */
uint16_t range_max; /*!< The maximum value of Generic Power Range state */
} esp_ble_mesh_state_change_gen_power_range_set_t;
/** Parameters of Generic Location Global Set state change event */
typedef struct {
int32_t latitude; /*!< The Global Latitude value of Generic Location state */
int32_t longitude; /*!< The Global Longitude value of Generic Location state */
int16_t altitude; /*!< The Global Altitude value of Generic Location state */
} esp_ble_mesh_state_change_gen_loc_global_set_t;
/** Parameters of Generic Location Local Set state change event */
typedef struct {
int16_t north; /*!< The Local North value of Generic Location state */
int16_t east; /*!< The Local East value of Generic Location state */
int16_t altitude; /*!< The Local Altitude value of Generic Location state */
uint8_t floor_number; /*!< The Floor Number value of Generic Location state */
uint16_t uncertainty; /*!< The Uncertainty value of Generic Location state */
} esp_ble_mesh_state_change_gen_loc_local_set_t;
/** Parameters of Generic User Property Set state change event */
typedef struct {
uint16_t id; /*!< The property id of Generic User Property state */
struct net_buf_simple *value; /*!< The property value of Generic User Property state */
} esp_ble_mesh_state_change_gen_user_property_set_t;
/** Parameters of Generic Admin Property Set state change event */
typedef struct {
uint16_t id; /*!< The property id of Generic Admin Property state */
uint8_t access; /*!< The property access of Generic Admin Property state */
struct net_buf_simple *value; /*!< The property value of Generic Admin Property state */
} esp_ble_mesh_state_change_gen_admin_property_set_t;
/** Parameters of Generic Manufacturer Property Set state change event */
typedef struct {
uint16_t id; /*!< The property id of Generic Manufacturer Property state */
uint8_t access; /*!< The property value of Generic Manufacturer Property state */
} esp_ble_mesh_state_change_gen_manu_property_set_t;
/**
* @brief Generic Server Model state change value union
*/
typedef union {
/**
* The recv_op in ctx can be used to decide which state is changed.
*/
esp_ble_mesh_state_change_gen_onoff_set_t onoff_set; /*!< Generic OnOff Set */
esp_ble_mesh_state_change_gen_level_set_t level_set; /*!< Generic Level Set */
esp_ble_mesh_state_change_gen_delta_set_t delta_set; /*!< Generic Delta Set */
esp_ble_mesh_state_change_gen_move_set_t move_set; /*!< Generic Move Set */
esp_ble_mesh_state_change_gen_def_trans_time_set_t def_trans_time_set; /*!< Generic Default Transition Time Set */
esp_ble_mesh_state_change_gen_onpowerup_set_t onpowerup_set; /*!< Generic OnPowerUp Set */
esp_ble_mesh_state_change_gen_power_level_set_t power_level_set; /*!< Generic Power Level Set */
esp_ble_mesh_state_change_gen_power_default_set_t power_default_set; /*!< Generic Power Default Set */
esp_ble_mesh_state_change_gen_power_range_set_t power_range_set; /*!< Generic Power Range Set */
esp_ble_mesh_state_change_gen_loc_global_set_t loc_global_set; /*!< Generic Location Global Set */
esp_ble_mesh_state_change_gen_loc_local_set_t loc_local_set; /*!< Generic Location Local Set */
esp_ble_mesh_state_change_gen_user_property_set_t user_property_set; /*!< Generic User Property Set */
esp_ble_mesh_state_change_gen_admin_property_set_t admin_property_set; /*!< Generic Admin Property Set */
esp_ble_mesh_state_change_gen_manu_property_set_t manu_property_set; /*!< Generic Manufacturer Property Set */
} esp_ble_mesh_generic_server_state_change_t;
/** Context of the received Generic User Property Get message */
typedef struct {
uint16_t property_id; /*!< Property ID identifying a Generic User Property */
} esp_ble_mesh_server_recv_gen_user_property_get_t;
/** Context of the received Generic Admin Property Get message */
typedef struct {
uint16_t property_id; /*!< Property ID identifying a Generic Admin Property */
} esp_ble_mesh_server_recv_gen_admin_property_get_t;
/** Context of the received Generic Manufacturer Property message */
typedef struct {
uint16_t property_id; /*!< Property ID identifying a Generic Manufacturer Property */
} esp_ble_mesh_server_recv_gen_manufacturer_property_get_t;
/** Context of the received Generic Client Properties Get message */
typedef struct {
uint16_t property_id; /*!< A starting Client Property ID present within an element */
} esp_ble_mesh_server_recv_gen_client_properties_get_t;
/**
* @brief Generic Server Model received get message union
*/
typedef union {
esp_ble_mesh_server_recv_gen_user_property_get_t user_property; /*!< Generic User Property Get */
esp_ble_mesh_server_recv_gen_admin_property_get_t admin_property; /*!< Generic Admin Property Get */
esp_ble_mesh_server_recv_gen_manufacturer_property_get_t manu_property; /*!< Generic Manufacturer Property Get */
esp_ble_mesh_server_recv_gen_client_properties_get_t client_properties; /*!< Generic Client Properties Get */
} esp_ble_mesh_generic_server_recv_get_msg_t;
/** Context of the received Generic OnOff Set message */
typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */
uint8_t onoff; /*!< Target value of Generic OnOff state */
uint8_t tid; /*!< Transaction ID */
uint8_t trans_time; /*!< Time to complete state transition (optional) */
uint8_t delay; /*!< Indicate message execution delay (C.1) */
} esp_ble_mesh_server_recv_gen_onoff_set_t;
/** Context of the received Generic Level Set message */
typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */
int16_t level; /*!< Target value of Generic Level state */
uint8_t tid; /*!< Transaction ID */
uint8_t trans_time; /*!< Time to complete state transition (optional) */
uint8_t delay; /*!< Indicate message execution delay (C.1) */
} esp_ble_mesh_server_recv_gen_level_set_t;
/** Context of the received Generic Delta Set message */
typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */
int32_t delta_level; /*!< Delta change of Generic Level state */
uint8_t tid; /*!< Transaction ID */
uint8_t trans_time; /*!< Time to complete state transition (optional) */
uint8_t delay; /*!< Indicate message execution delay (C.1) */
} esp_ble_mesh_server_recv_gen_delta_set_t;
/** Context of the received Generic Move Set message */
typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */
int16_t delta_level; /*!< Delta Level step to calculate Move speed for Generic Level state */
uint8_t tid; /*!< Transaction ID */
uint8_t trans_time; /*!< Time to complete state transition (optional) */
uint8_t delay; /*!< Indicate message execution delay (C.1) */
} esp_ble_mesh_server_recv_gen_move_set_t;
/** Context of the received Generic Default Transition Time Set message */
typedef struct {
uint8_t trans_time; /*!< The value of the Generic Default Transition Time state */
} esp_ble_mesh_server_recv_gen_def_trans_time_set_t;
/** Context of the received Generic OnPowerUp Set message */
typedef struct {
uint8_t onpowerup; /*!< The value of the Generic OnPowerUp state */
} esp_ble_mesh_server_recv_gen_onpowerup_set_t;
/** Context of the received Generic Power Level Set message */
typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */
uint16_t power; /*!< Target value of Generic Power Actual state */
uint8_t tid; /*!< Transaction ID */
uint8_t trans_time; /*!< Time to complete state transition (optional) */
uint8_t delay; /*!< Indicate message execution delay (C.1) */
} esp_ble_mesh_server_recv_gen_power_level_set_t;
/** Context of the received Generic Power Default Set message */
typedef struct {
uint16_t power; /*!< The value of the Generic Power Default state */
} esp_ble_mesh_server_recv_gen_power_default_set_t;
/** Context of the received Generic Power Range Set message */
typedef struct {
uint16_t range_min; /*!< Value of Range Min field of Generic Power Range state */
uint16_t range_max; /*!< Value of Range Max field of Generic Power Range state */
} esp_ble_mesh_server_recv_gen_power_range_set_t;
/** Context of the received Generic Location Global Set message */
typedef struct {
int32_t global_latitude; /*!< Global Coordinates (Latitude) */
int32_t global_longitude; /*!< Global Coordinates (Longitude) */
int16_t global_altitude; /*!< Global Altitude */
} esp_ble_mesh_server_recv_gen_loc_global_set_t;
/** Context of the received Generic Location Local Set message */
typedef struct {
int16_t local_north; /*!< Local Coordinates (North) */
int16_t local_east; /*!< Local Coordinates (East) */
int16_t local_altitude; /*!< Local Altitude */
uint8_t floor_number; /*!< Floor Number */
uint16_t uncertainty; /*!< Uncertainty */
} esp_ble_mesh_server_recv_gen_loc_local_set_t;
/** Context of the received Generic User Property Set message */
typedef struct {
uint16_t property_id; /*!< Property ID identifying a Generic User Property */
struct net_buf_simple *property_value; /*!< Raw value for the User Property */
} esp_ble_mesh_server_recv_gen_user_property_set_t;
/** Context of the received Generic Admin Property Set message */
typedef struct {
uint16_t property_id; /*!< Property ID identifying a Generic Admin Property */
uint8_t user_access; /*!< Enumeration indicating user access */
struct net_buf_simple *property_value; /*!< Raw value for the Admin Property */
} esp_ble_mesh_server_recv_gen_admin_property_set_t;
/** Context of the received Generic Manufacturer Property Set message */
typedef struct {
uint16_t property_id; /*!< Property ID identifying a Generic Manufacturer Property */
uint8_t user_access; /*!< Enumeration indicating user access */
} esp_ble_mesh_server_recv_gen_manufacturer_property_set_t;
/**
* @brief Generic Server Model received set message union
*/
typedef union {
esp_ble_mesh_server_recv_gen_onoff_set_t onoff; /*!< Generic OnOff Set/Generic OnOff Set Unack */
esp_ble_mesh_server_recv_gen_level_set_t level; /*!< Generic Level Set/Generic Level Set Unack */
esp_ble_mesh_server_recv_gen_delta_set_t delta; /*!< Generic Delta Set/Generic Delta Set Unack */
esp_ble_mesh_server_recv_gen_move_set_t move; /*!< Generic Move Set/Generic Move Set Unack */
esp_ble_mesh_server_recv_gen_def_trans_time_set_t def_trans_time; /*!< Generic Default Transition Time Set/Generic Default Transition Time Set Unack */
esp_ble_mesh_server_recv_gen_onpowerup_set_t onpowerup; /*!< Generic OnPowerUp Set/Generic OnPowerUp Set Unack */
esp_ble_mesh_server_recv_gen_power_level_set_t power_level; /*!< Generic Power Level Set/Generic Power Level Set Unack */
esp_ble_mesh_server_recv_gen_power_default_set_t power_default; /*!< Generic Power Default Set/Generic Power Default Set Unack */
esp_ble_mesh_server_recv_gen_power_range_set_t power_range; /*!< Generic Power Range Set/Generic Power Range Set Unack */
esp_ble_mesh_server_recv_gen_loc_global_set_t location_global; /*!< Generic Location Global Set/Generic Location Global Set Unack */
esp_ble_mesh_server_recv_gen_loc_local_set_t location_local; /*!< Generic Location Local Set/Generic Location Local Set Unack */
esp_ble_mesh_server_recv_gen_user_property_set_t user_property; /*!< Generic User Property Set/Generic User Property Set Unack */
esp_ble_mesh_server_recv_gen_admin_property_set_t admin_property; /*!< Generic Admin Property Set/Generic Admin Property Set Unack */
esp_ble_mesh_server_recv_gen_manufacturer_property_set_t manu_property; /*!< Generic Manufacturer Property Set/Generic Manufacturer Property Set Unack */
} esp_ble_mesh_generic_server_recv_set_msg_t;
/**
* @brief Generic Server Model callback value union
*/
typedef union {
esp_ble_mesh_generic_server_state_change_t state_change; /*!< ESP_BLE_MESH_GENERIC_SERVER_STATE_CHANGE_EVT */
esp_ble_mesh_generic_server_recv_get_msg_t get; /*!< ESP_BLE_MESH_GENERIC_SERVER_RECV_GET_MSG_EVT */
esp_ble_mesh_generic_server_recv_set_msg_t set; /*!< ESP_BLE_MESH_GENERIC_SERVER_RECV_SET_MSG_EVT */
} esp_ble_mesh_generic_server_cb_value_t;
/** Generic Server Model callback parameters */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to Generic Server Models */
esp_ble_mesh_msg_ctx_t ctx; /*!< Context of the received messages */
esp_ble_mesh_generic_server_cb_value_t value; /*!< Value of the received Generic Messages */
} esp_ble_mesh_generic_server_cb_param_t;
/** This enum value is the event of Generic Server Model */
typedef enum {
/**
* 1. When get_auto_rsp is set to ESP_BLE_MESH_SERVER_AUTO_RSP, no event will be
* callback to the application layer when Generic Get messages are received.
* 2. When set_auto_rsp is set to ESP_BLE_MESH_SERVER_AUTO_RSP, this event will
* be callback to the application layer when Generic Set/Set Unack messages
* are received.
*/
ESP_BLE_MESH_GENERIC_SERVER_STATE_CHANGE_EVT,
/**
* When get_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, this event will be
* callback to the application layer when Generic Get messages are received.
*/
ESP_BLE_MESH_GENERIC_SERVER_RECV_GET_MSG_EVT,
/**
* When set_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, this event will be
* callback to the application layer when Generic Set/Set Unack messages are received.
*/
ESP_BLE_MESH_GENERIC_SERVER_RECV_SET_MSG_EVT,
ESP_BLE_MESH_GENERIC_SERVER_EVT_MAX,
} esp_ble_mesh_generic_server_cb_event_t;
/**
* @brief Bluetooth Mesh Generic Server Model function.
*/
/**
* @brief Generic Server Model callback function type
* @param event: Event type
* @param param: Pointer to callback parameter
*/
typedef void (* esp_ble_mesh_generic_server_cb_t)(esp_ble_mesh_generic_server_cb_event_t event,
esp_ble_mesh_generic_server_cb_param_t *param);
/**
* @brief Register BLE Mesh Generic Server Model callback.
*
* @param[in] callback: Pointer to the callback function.
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_register_generic_server_callback(esp_ble_mesh_generic_server_cb_t callback);
#ifdef __cplusplus
}
#endif
#endif /* _ESP_BLE_MESH_GENERIC_MODEL_API_H_ */

View File

@ -17,6 +17,10 @@
#include "esp_ble_mesh_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @def ESP_BLE_MESH_MODEL_HEALTH_SRV
*
* @brief Define a new Health Server Model.
@ -47,39 +51,123 @@
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_HEALTH_CLI, \
NULL, NULL, cli_data)
/** Health Server Model callbacks */
/** @def ESP_BLE_MESH_HEALTH_PUB_DEFINE
*
* A helper to define a health publication context
*
* @param _name Name given to the publication context variable.
* @param _max Maximum number of faults the element can have.
* @param _role Role of the device which contains the model.
*/
#define ESP_BLE_MESH_HEALTH_PUB_DEFINE(_name, _max, _role) \
ESP_BLE_MESH_MODEL_PUB_DEFINE(_name, (1 + 3 + (_max)), _role)
/**
* SIG identifier of Health Fault Test.
* 0x01 ~ 0xFF: Vendor Specific Test.
*/
#define ESP_BLE_MESH_HEALTH_STANDARD_TEST 0x00
/**
* Fault values of Health Fault Test.
* 0x33 ~ 0x7F: Reserved for Future Use.
* 0x80 ~ 0xFF: Vendor Specific Warning/Error.
*/
#define ESP_BLE_MESH_NO_FAULT 0x00
#define ESP_BLE_MESH_BATTERY_LOW_WARNING 0x01
#define ESP_BLE_MESH_BATTERY_LOW_ERROR 0x02
#define ESP_BLE_MESH_SUPPLY_VOLTAGE_TOO_LOW_WARNING 0x03
#define ESP_BLE_MESH_SUPPLY_VOLTAGE_TOO_LOW_ERROR 0x04
#define ESP_BLE_MESH_SUPPLY_VOLTAGE_TOO_HIGH_WARNING 0x05
#define ESP_BLE_MESH_SUPPLY_VOLTAGE_TOO_HIGH_ERROR 0x06
#define ESP_BLE_MESH_POWER_SUPPLY_INTERRUPTED_WARNING 0x07
#define ESP_BLE_MESH_POWER_SUPPLY_INTERRUPTED_ERROR 0x08
#define ESP_BLE_MESH_NO_LOAD_WARNING 0x09
#define ESP_BLE_MESH_NO_LOAD_ERROR 0x0A
#define ESP_BLE_MESH_OVERLOAD_WARNING 0x0B
#define ESP_BLE_MESH_OVERLOAD_ERROR 0x0C
#define ESP_BLE_MESH_OVERHEAT_WARNING 0x0D
#define ESP_BLE_MESH_OVERHEAT_ERROR 0x0E
#define ESP_BLE_MESH_CONDENSATION_WARNING 0x0F
#define ESP_BLE_MESH_CONDENSATION_ERROR 0x10
#define ESP_BLE_MESH_VIBRATION_WARNING 0x11
#define ESP_BLE_MESH_VIBRATION_ERROR 0x12
#define ESP_BLE_MESH_CONFIGURATION_WARNING 0x13
#define ESP_BLE_MESH_CONFIGURATION_ERROR 0x14
#define ESP_BLE_MESH_ELEMENT_NOT_CALIBRATED_WARNING 0x15
#define ESP_BLE_MESH_ELEMENT_NOT_CALIBRATED_ERROR 0x16
#define ESP_BLE_MESH_MEMORY_WARNING 0x17
#define ESP_BLE_MESH_MEMORY_ERROR 0x18
#define ESP_BLE_MESH_SELF_TEST_WARNING 0x19
#define ESP_BLE_MESH_SELF_TEST_ERROR 0x1A
#define ESP_BLE_MESH_INPUT_TOO_LOW_WARNING 0x1B
#define ESP_BLE_MESH_INPUT_TOO_LOW_ERROR 0x1C
#define ESP_BLE_MESH_INPUT_TOO_HIGH_WARNING 0x1D
#define ESP_BLE_MESH_INPUT_TOO_HIGH_ERROR 0x1E
#define ESP_BLE_MESH_INPUT_NO_CHANGE_WARNING 0x1F
#define ESP_BLE_MESH_INPUT_NO_CHANGE_ERROR 0x20
#define ESP_BLE_MESH_ACTUATOR_BLOCKED_WARNING 0x21
#define ESP_BLE_MESH_ACTUATOR_BLOCKED_ERROR 0x22
#define ESP_BLE_MESH_HOUSING_OPENED_WARNING 0x23
#define ESP_BLE_MESH_HOUSING_OPENED_ERROR 0x24
#define ESP_BLE_MESH_TAMPER_WARNING 0x25
#define ESP_BLE_MESH_TAMPER_ERROR 0x26
#define ESP_BLE_MESH_DEVICE_MOVED_WARNING 0x27
#define ESP_BLE_MESH_DEVICE_MOVED_ERROR 0x28
#define ESP_BLE_MESH_DEVICE_DROPPED_WARNING 0x29
#define ESP_BLE_MESH_DEVICE_DROPPED_ERROR 0x2A
#define ESP_BLE_MESH_OVERFLOW_WARNING 0x2B
#define ESP_BLE_MESH_OVERFLOW_ERROR 0x2C
#define ESP_BLE_MESH_EMPTY_WARNING 0x2D
#define ESP_BLE_MESH_EMPTY_ERROR 0x2E
#define ESP_BLE_MESH_INTERNAL_BUS_WARNING 0x2F
#define ESP_BLE_MESH_INTERNAL_BUS_ERROR 0x30
#define ESP_BLE_MESH_MECHANISM_JAMMED_WARNING 0x31
#define ESP_BLE_MESH_MECHANISM_JAMMED_ERROR 0x32
/** ESP BLE Mesh Health Server callback */
typedef struct {
/** Fetch current faults */
int (*fault_get_cur)(esp_ble_mesh_model_t *model, uint8_t *test_id,
uint16_t *company_id, uint8_t *faults, uint8_t *fault_count);
/** Clear health registered faults. Initialized by the stack. */
esp_ble_mesh_cb_t fault_clear;
/** Fetch registered faults */
int (*fault_get_reg)(esp_ble_mesh_model_t *model, uint16_t company_id,
uint8_t *test_id, uint8_t *faults, uint8_t *fault_count);
/** Run a specific health test. Initialized by the stack. */
esp_ble_mesh_cb_t fault_test;
/** Clear registered faults */
int (*fault_clear)(esp_ble_mesh_model_t *model, uint16_t company_id);
/** Health attention on callback. Initialized by the stack. */
esp_ble_mesh_cb_t attention_on;
/** Run a specific test */
int (*fault_test)(esp_ble_mesh_model_t *model, uint8_t test_id, uint16_t company_id);
/** Attention on */
void (*attn_on)(esp_ble_mesh_model_t *model);
/** Attention off */
void (*attn_off)(esp_ble_mesh_model_t *model);
/** Health attention off callback. Initialized by the stack. */
esp_ble_mesh_cb_t attention_off;
} esp_ble_mesh_health_srv_cb_t;
/** Health Server Model Context */
#define ESP_BLE_MESH_HEALTH_FAULT_ARRAY_SIZE 32
/** ESP BLE Mesh Health Server test Context */
typedef struct {
uint8_t id_count; /*!< Number of Health self-test ID */
const uint8_t *test_ids; /*!< Array of Health self-test IDs */
uint16_t company_id; /*!< Company ID used to identify the Health Fault state */
uint8_t prev_test_id; /*!< Current test ID of the health fault test */
uint8_t current_faults[ESP_BLE_MESH_HEALTH_FAULT_ARRAY_SIZE]; /*!< Array of current faults */
uint8_t registered_faults[ESP_BLE_MESH_HEALTH_FAULT_ARRAY_SIZE]; /*!< Array of registered faults */
} __attribute__((packed)) esp_ble_mesh_health_test_t;
/** ESP BLE Mesh Health Server Model Context */
typedef struct {
/** Pointer to Health Server Model */
esp_ble_mesh_model_t *model;
/** Optional callback struct */
const esp_ble_mesh_health_srv_cb_t *cb;
/** Health callback struct */
esp_ble_mesh_health_srv_cb_t health_cb;
/** Attention Timer state */
struct k_delayed_work attn_timer;
struct k_delayed_work attention_timer;
/** Attention Timer start flag */
bool attention_timer_start;
/** Health Server fault test */
esp_ble_mesh_health_test_t health_test;
} esp_ble_mesh_health_srv_t;
/** Parameter of Health Fault Get */
@ -186,14 +274,54 @@ typedef enum {
ESP_BLE_MESH_HEALTH_CLIENT_EVT_MAX,
} esp_ble_mesh_health_client_cb_event_t;
/** Health Server Model callback parameter */
/** Parameter of publishing Health Current Status completion event */
typedef struct {
int error_code; /*!< Appropriate error code */
int error_code; /*!< The result of publishing Health Current Status */
esp_ble_mesh_elem_t *element; /*!< Pointer to the element which contains the Health Server Model */
} esp_ble_mesh_health_fault_update_comp_cb_t;
/** Parameters of Health Fault Clear event */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Health Server Model */
uint16_t company_id; /*!< Bluetooth assigned 16-bit Company ID */
} esp_ble_mesh_health_fault_clear_cb_t;
/** Parameters of Health Fault Test event */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Health Server Model */
uint8_t test_id; /*!< ID of a specific test to be performed */
uint16_t company_id; /*!< Bluetooth assigned 16-bit Company ID */
} esp_ble_mesh_health_fault_test_cb_t;
/** Parameter of Health Attention On event */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Health Server Model */
uint8_t time; /*!< Duration of attention timer on (in seconds) */
} esp_ble_mesh_health_attention_on_cb_t;
/** Parameter of Health Attention Off event */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Health Server Model */
} esp_ble_mesh_health_attention_off_cb_t;
/**
* @brief Health Server Model callback parameters union
*/
typedef union {
esp_ble_mesh_health_fault_update_comp_cb_t fault_update_comp; /*!< ESP_BLE_MESH_HEALTH_SERVER_FAULT_UPDATE_COMP_EVT */
esp_ble_mesh_health_fault_clear_cb_t fault_clear; /*!< ESP_BLE_MESH_HEALTH_SERVER_FAULT_CLEAR_EVT */
esp_ble_mesh_health_fault_test_cb_t fault_test; /*!< ESP_BLE_MESH_HEALTH_SERVER_FAULT_TEST_EVT */
esp_ble_mesh_health_attention_on_cb_t attention_on; /*!< ESP_BLE_MESH_HEALTH_SERVER_ATTENTION_ON_EVT */
esp_ble_mesh_health_attention_off_cb_t attention_off; /*!< ESP_BLE_MESH_HEALTH_SERVER_ATTENTION_OFF_EVT */
} esp_ble_mesh_health_server_cb_param_t;
/** This enum value is the event of Health Server Model */
typedef enum {
ESP_BLE_MESH_HEALTH_SERVER_FAULT_UPDATE_COMPLETE_EVT,
ESP_BLE_MESH_HEALTH_SERVER_FAULT_UPDATE_COMP_EVT,
ESP_BLE_MESH_HEALTH_SERVER_FAULT_CLEAR_EVT,
ESP_BLE_MESH_HEALTH_SERVER_FAULT_TEST_EVT,
ESP_BLE_MESH_HEALTH_SERVER_ATTENTION_ON_EVT,
ESP_BLE_MESH_HEALTH_SERVER_ATTENTION_OFF_EVT,
ESP_BLE_MESH_HEALTH_SERVER_EVT_MAX,
} esp_ble_mesh_health_server_cb_event_t;
@ -207,7 +335,7 @@ typedef enum {
* @param param: Pointer to callback parameter
*/
typedef void (* esp_ble_mesh_health_client_cb_t)(esp_ble_mesh_health_client_cb_event_t event,
esp_ble_mesh_health_client_cb_param_t *param);
esp_ble_mesh_health_client_cb_param_t *param);
/**
* @brief Health Server Model callback function type
@ -215,7 +343,7 @@ typedef void (* esp_ble_mesh_health_client_cb_t)(esp_ble_mesh_health_client_cb_e
* @param param: Pointer to callback parameter
*/
typedef void (* esp_ble_mesh_health_server_cb_t)(esp_ble_mesh_health_server_cb_event_t event,
esp_ble_mesh_health_server_cb_param_t *param);
esp_ble_mesh_health_server_cb_param_t *param);
/**
* @brief Register BLE Mesh Health Model callback, the callback will report Health Client & Server Model events.
@ -251,7 +379,7 @@ esp_err_t esp_ble_mesh_register_health_server_callback(esp_ble_mesh_health_serve
*
*/
esp_err_t esp_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_health_client_get_state_t *get_state);
esp_ble_mesh_health_client_get_state_t *get_state);
/**
* @brief This function is called to set the Health Server states using the Health Client Model set messages.
@ -267,10 +395,10 @@ esp_err_t esp_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_
*
*/
esp_err_t esp_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_health_client_set_state_t *set_state);
esp_ble_mesh_health_client_set_state_t *set_state);
/**
* @brief This function is called by the Health Server Model to start to publish its Current Health Fault.
* @brief This function is called by the Health Server Model to update the context of its Health Current status.
*
* @param[in] element: The element to which the Health Server Model belongs.
*
@ -279,4 +407,8 @@ esp_err_t esp_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param_
*/
esp_err_t esp_ble_mesh_health_server_fault_update(esp_ble_mesh_elem_t *element);
#endif /** _ESP_BLE_MESH_HEALTH_MODEL_API_H_ */
#ifdef __cplusplus
}
#endif
#endif /* _ESP_BLE_MESH_HEALTH_MODEL_API_H_ */

View File

@ -19,9 +19,12 @@
#ifndef _ESP_BLE_MESH_SENSOR_MODEL_API_H_
#define _ESP_BLE_MESH_SENSOR_MODEL_API_H_
#include "sensor_client.h"
#include "esp_ble_mesh_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @def ESP_BLE_MESH_MODEL_SENSOR_CLI
*
* @brief Define a new Sensor Client Model.
@ -45,60 +48,60 @@
/** Parameters of Sensor Descriptor Get */
typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */
u16_t property_id; /*!< Property ID of a sensor (optional) */
uint16_t property_id; /*!< Property ID of a sensor (optional) */
} esp_ble_mesh_sensor_descriptor_get_t;
/** Parameter of Sensor Cadence Get */
typedef struct {
u16_t property_id; /*!< Property ID of a sensor */
uint16_t property_id; /*!< Property ID of a sensor */
} esp_ble_mesh_sensor_cadence_get_t;
/** Parameters of Sensor Cadence Set */
typedef struct {
u16_t property_id; /*!< Property ID for the sensor */
u8_t fast_cadence_period_divisor : 7, /*!< Divisor for the publish period */
status_trigger_type : 1; /*!< The unit and format of the Status Trigger Delta fields */
uint16_t property_id; /*!< Property ID for the sensor */
uint8_t fast_cadence_period_divisor : 7, /*!< Divisor for the publish period */
status_trigger_type : 1; /*!< The unit and format of the Status Trigger Delta fields */
struct net_buf_simple *status_trigger_delta_down; /*!< Delta down value that triggers a status message */
struct net_buf_simple *status_trigger_delta_up; /*!< Delta up value that triggers a status message */
u8_t status_min_interval; /*!< Minimum interval between two consecutive Status messages */
uint8_t status_min_interval; /*!< Minimum interval between two consecutive Status messages */
struct net_buf_simple *fast_cadence_low; /*!< Low value for the fast cadence range */
struct net_buf_simple *fast_cadence_high; /*!< Fast value for the fast cadence range */
} esp_ble_mesh_sensor_cadence_set_t;
/** Parameter of Sensor Settings Get */
typedef struct {
u16_t sensor_property_id; /*!< Property ID of a sensor */
uint16_t sensor_property_id; /*!< Property ID of a sensor */
} esp_ble_mesh_sensor_settings_get_t;
/** Parameters of Sensor Setting Get */
typedef struct {
u16_t sensor_property_id; /*!< Property ID of a sensor */
u16_t sensor_setting_property_id; /*!< Setting ID identifying a setting within a sensor */
uint16_t sensor_property_id; /*!< Property ID of a sensor */
uint16_t sensor_setting_property_id; /*!< Setting ID identifying a setting within a sensor */
} esp_ble_mesh_sensor_setting_get_t;
/** Parameters of Sensor Setting Set */
typedef struct {
u16_t sensor_property_id; /*!< Property ID identifying a sensor */
u16_t sensor_setting_property_id; /*!< Setting ID identifying a setting within a sensor */
uint16_t sensor_property_id; /*!< Property ID identifying a sensor */
uint16_t sensor_setting_property_id; /*!< Setting ID identifying a setting within a sensor */
struct net_buf_simple *sensor_setting_raw; /*!< Raw value for the setting */
} esp_ble_mesh_sensor_setting_set_t;
/** Parameters of Sensor Get */
typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */
u16_t property_id; /*!< Property ID for the sensor (optional) */
bool op_en; /*!< Indicate if optional parameters are included */
uint16_t property_id; /*!< Property ID for the sensor (optional) */
} esp_ble_mesh_sensor_get_t;
/** Parameters of Sensor Column Get */
typedef struct {
u16_t property_id; /*!< Property identifying a sensor */
uint16_t property_id; /*!< Property identifying a sensor */
struct net_buf_simple *raw_value_x; /*!< Raw value identifying a column */
} esp_ble_mesh_sensor_column_get_t;
/** Parameters of Sensor Series Get */
typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */
u16_t property_id; /*!< Property identifying a sensor */
bool op_en; /*!< Indicate if optional parameters are included */
uint16_t property_id; /*!< Property identifying a sensor */
struct net_buf_simple *raw_value_x1; /*!< Raw value identifying a starting column (optional) */
struct net_buf_simple *raw_value_x2; /*!< Raw value identifying an ending column (C.1) */
} esp_ble_mesh_sensor_series_get_t;
@ -135,22 +138,22 @@ typedef struct {
/** Parameters of Sensor Cadence Status */
typedef struct {
u16_t property_id; /*!< Property for the sensor */
uint16_t property_id; /*!< Property for the sensor */
struct net_buf_simple *sensor_cadence_value; /*!< Value of sensor cadence state */
} esp_ble_mesh_sensor_cadence_status_cb_t;
/** Parameters of Sensor Settings Status */
typedef struct {
u16_t sensor_property_id; /*!< Property ID identifying a sensor */
uint16_t sensor_property_id; /*!< Property ID identifying a sensor */
struct net_buf_simple *sensor_setting_property_ids; /*!< A sequence of N sensor setting property IDs (optional) */
} esp_ble_mesh_sensor_settings_status_cb_t;
/** Parameters of Sensor Setting Status */
typedef struct {
bool op_en; /*!< Indicate id optional parameters are included */
u16_t sensor_property_id; /*!< Property ID identifying a sensor */
u16_t sensor_setting_property_id; /*!< Setting ID identifying a setting within a sensor */
u8_t sensor_setting_access; /*!< Read/Write access rights for the setting (optional) */
bool op_en; /*!< Indicate id optional parameters are included */
uint16_t sensor_property_id; /*!< Property ID identifying a sensor */
uint16_t sensor_setting_property_id; /*!< Setting ID identifying a setting within a sensor */
uint8_t sensor_setting_access; /*!< Read/Write access rights for the setting (optional) */
struct net_buf_simple *sensor_setting_raw; /*!< Raw value for the setting */
} esp_ble_mesh_sensor_setting_status_cb_t;
@ -161,13 +164,13 @@ typedef struct {
/** Parameters of Sensor Column Status */
typedef struct {
u16_t property_id; /*!< Property identifying a sensor and the Y axis */
uint16_t property_id; /*!< Property identifying a sensor and the Y axis */
struct net_buf_simple *sensor_column_value; /*!< Left values of sensor column status */
} esp_ble_mesh_sensor_column_status_cb_t;
/** Parameters of Sensor Series Status */
typedef struct {
u16_t property_id; /*!< Property identifying a sensor and the Y axis */
uint16_t property_id; /*!< Property identifying a sensor and the Y axis */
struct net_buf_simple *sensor_series_value; /*!< Left values of sensor series status */
} esp_ble_mesh_sensor_series_status_cb_t;
@ -212,7 +215,7 @@ typedef enum {
* @param param: Pointer to callback parameter
*/
typedef void (* esp_ble_mesh_sensor_client_cb_t)(esp_ble_mesh_sensor_client_cb_event_t event,
esp_ble_mesh_sensor_client_cb_param_t *param);
esp_ble_mesh_sensor_client_cb_param_t *param);
/**
* @brief Register BLE Mesh Sensor Client Model callback.
@ -238,7 +241,7 @@ esp_err_t esp_ble_mesh_register_sensor_client_callback(esp_ble_mesh_sensor_clien
*
*/
esp_err_t esp_ble_mesh_sensor_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_sensor_client_get_state_t *get_state);
esp_ble_mesh_sensor_client_get_state_t *get_state);
/**
* @brief Set the value of Sensor Server Model states using the Sensor Client Model set messages.
@ -254,7 +257,462 @@ esp_err_t esp_ble_mesh_sensor_client_get_state(esp_ble_mesh_client_common_param_
*
*/
esp_err_t esp_ble_mesh_sensor_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_sensor_client_set_state_t *set_state);
esp_ble_mesh_sensor_client_set_state_t *set_state);
/**
* @brief Sensor Server Models related context.
*/
/** @def ESP_BLE_MESH_MODEL_SENSOR_SRV
*
* @brief Define a new Sensor Server Model.
*
* @note 1. The Sensor Server model is a root model. When this model is present
* on an element, the corresponding Sensor Setup Server model shall
* also be present.
* 2. This model shall support model publication and model subscription.
*
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
* @param srv_data Pointer to the unique struct esp_ble_mesh_sensor_srv_t.
*
* @return New Sensor Server Model instance.
*/
#define ESP_BLE_MESH_MODEL_SENSOR_SRV(srv_pub, srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SENSOR_SRV, \
NULL, srv_pub, srv_data)
/** @def ESP_BLE_MESH_MODEL_SENSOR_SETUP_SRV
*
* @brief Define a new Sensor Setup Server Model.
*
* @note 1. The Sensor Setup Server model extends the Sensor Server model.
* 2. This model shall support model publication and model subscription.
*
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
* @param srv_data Pointer to the unique struct esp_ble_mesh_sensor_setup_srv_t.
*
* @return New Sensor Setup Server Model instance.
*/
#define ESP_BLE_MESH_MODEL_SENSOR_SETUP_SRV(srv_pub, srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SENSOR_SETUP_SRV, \
NULL, srv_pub, srv_data)
#define ESP_BLE_MESH_INVALID_SENSOR_PROPERTY_ID 0x0000 /*!< Invalid Sensor Property ID */
#define ESP_BLE_MESH_SENSOR_PROPERTY_ID_LEN 0x02 /*!< Length of Sensor Property ID */
#define ESP_BLE_MESH_SENSOR_DESCRIPTOR_LEN 0x08 /*!< Length of Sensor Descriptor state */
#define ESP_BLE_MESH_SENSOR_UNSPECIFIED_POS_TOLERANCE 0x000 /*!< Unspecified Sensor Positive Tolerance */
#define ESP_BLE_MESH_SENSOR_UNSPECIFIED_NEG_TOLERANCE 0x000 /*!< Unspecified Sensor Negative Tolerance */
#define ESP_BLE_MESH_SENSOR_NOT_APPL_MEASURE_PERIOD 0x00 /*!< Not applicable Sensor Measurement Period */
#define ESP_BLE_MESH_SENSOR_NOT_APPL_UPDATE_INTERVAL 0x00 /*!< Not applicable Sensor Update Interval */
#define ESP_BLE_MESH_INVALID_SENSOR_SETTING_PROPERTY_ID 0x0000 /*!< Invalid Sensor Setting Property ID */
#define ESP_BLE_MESH_SENSOR_SETTING_PROPERTY_ID_LEN 0x02 /*!< Length of Sensor Setting Property ID */
#define ESP_BLE_MESH_SENSOR_SETTING_ACCESS_LEN 0x01 /*!< Length of Sensor Setting Access */
#define ESP_BLE_MESH_SENSOR_SETTING_ACCESS_READ 0x01 /*!< Sensor Setting Access - Read */
#define ESP_BLE_MESH_SENSOR_SETTING_ACCESS_READ_WRITE 0x03 /*!< Sensor Setting Access - Read & Write */
#define ESP_BLE_MESH_SENSOR_DIVISOR_TRIGGER_TYPE_LEN 0x01 /*!< Length of Sensor Divisor Trigger Type */
#define ESP_BLE_MESH_SENSOR_STATUS_MIN_INTERVAL_LEN 0x01 /*!< Length of Sensor Status Min Interval */
#define ESP_BLE_MESH_SENSOR_PERIOD_DIVISOR_MAX_VALUE 15 /*!< Maximum value of Sensor Period Divisor */
#define ESP_BLE_MESH_SENSOR_STATUS_MIN_INTERVAL_MAX 26 /*!< Maximum value of Sensor Status Min Interval */
/**
* Sensor Status Trigger Type - Format Type of the characteristic
* that the Sensor Property ID state references
*/
#define ESP_BLE_MESH_SENSOR_STATUS_TRIGGER_TYPE_CHAR 0
/** Sensor Status Trigger Type - Format Type "uint16" */
#define ESP_BLE_MESH_SENSOR_STATUS_TRIGGER_TYPE_UINT16 1
#define ESP_BLE_MESH_SENSOR_DATA_FORMAT_A 0x00 /*!< Sensor Data Format A */
#define ESP_BLE_MESH_SENSOR_DATA_FORMAT_B 0x01 /*!< Sensor Data Format B */
#define ESP_BLE_MESH_SENSOR_DATA_FORMAT_A_MPID_LEN 0x02 /*!< MPID length of Sensor Data Format A */
#define ESP_BLE_MESH_SENSOR_DATA_FORMAT_B_MPID_LEN 0x03 /*!< MPID length of Sensor Data Format B */
/**
* Zero length of Sensor Data.
*
* Note:
* The Length field is a 1-based uint7 value (valid range 0x00x7F,
* representing range of 1127). The value 0x7F represents a length
* of zero.
*/
#define ESP_BLE_MESH_SENSOR_DATA_ZERO_LEN 0x7F
/** @def ESP_BLE_MESH_GET_SENSOR_DATA_FORMAT
*
* @brief Get format of the sensor data.
*
* @note Multiple sensor data may be concatenated. Make sure the _data pointer is
* updated before getting the format of the corresponding sensor data.
*
* @param _data Pointer to the start of the sensor data.
*
* @return Format of the sensor data.
*/
#define ESP_BLE_MESH_GET_SENSOR_DATA_FORMAT(_data) (((_data)[0]) & BIT_MASK(1))
/** @def ESP_BLE_MESH_GET_SENSOR_DATA_LENGTH
*
* @brief Get length of the sensor data.
*
* @note Multiple sensor data may be concatenated. Make sure the _data pointer is
* updated before getting the length of the corresponding sensor data.
*
* @param _data Pointer to the start of the sensor data.
* @param _fmt Format of the sensor data.
*
* @return Length (zero-based) of the sensor data.
*/
#define ESP_BLE_MESH_GET_SENSOR_DATA_LENGTH(_data, _fmt) \
(((_fmt) == ESP_BLE_MESH_SENSOR_DATA_FORMAT_A) ? ((((_data)[0]) >> 1) & BIT_MASK(4)) : ((((_data)[0]) >> 1) & BIT_MASK(7)))
/** @def ESP_BLE_MESH_GET_SENSOR_DATA_PROPERTY_ID
*
* @brief Get Sensor Property ID of the sensor data.
*
* @note Multiple sensor data may be concatenated. Make sure the _data pointer is
* updated before getting Sensor Property ID of the corresponding sensor data.
*
* @param _data Pointer to the start of the sensor data.
* @param _fmt Format of the sensor data.
*
* @return Sensor Property ID of the sensor data.
*/
#define ESP_BLE_MESH_GET_SENSOR_DATA_PROPERTY_ID(_data, _fmt) \
(((_fmt) == ESP_BLE_MESH_SENSOR_DATA_FORMAT_A) ? ((((_data)[1]) << 3) | (((_data)[0]) >> 5)) : ((((_data)[2]) << 8) | ((_data)[1])))
/** @def ESP_BLE_MESH_SENSOR_DATA_FORMAT_A_MPID
*
* @brief Generate a MPID value for sensor data with Format A.
*
* @note 1. The Format field is 0b0 and indicates that Format A is used.
* 2. The Length field is a 1-based uint4 value (valid range 0x00xF,
* representing range of 116).
* 3. The Property ID is an 11-bit bit field representing 11 LSb of a Property ID.
* 4. This format may be used for Property Values that are not longer than 16
* octets and for Property IDs less than 0x0800.
*
* @param _len Length of Sensor Raw value.
* @param _id Sensor Property ID.
*
* @return 2-octet MPID value for sensor data with Format A.
*
*/
#define ESP_BLE_MESH_SENSOR_DATA_FORMAT_A_MPID(_len, _id) \
((((_id) & BIT_MASK(11)) << 5) | (((_len) & BIT_MASK(4)) << 1) | ESP_BLE_MESH_SENSOR_DATA_FORMAT_A)
/** @def ESP_BLE_MESH_SENSOR_DATA_FORMAT_B_MPID
*
* @brief Generate a MPID value for sensor data with Format B.
*
* @note 1. The Format field is 0b1 and indicates Format B is used.
* 2. The Length field is a 1-based uint7 value (valid range 0x00x7F, representing
* range of 1127). The value 0x7F represents a length of zero.
* 3. The Property ID is a 16-bit bit field representing a Property ID.
* 4. This format may be used for Property Values not longer than 128 octets and for
* any Property IDs. Property values longer than 128 octets are not supported by
* the Sensor Status message.
* 5. Exclude the generated 1-octet value, the 2-octet Sensor Property ID
*
* @param _len Length of Sensor Raw value.
* @param _id Sensor Property ID.
*
* @return 3-octet MPID value for sensor data with Format B.
*
*/
#define ESP_BLE_MESH_SENSOR_DATA_FORMAT_B_MPID(_len, _id) \
(((_id) << 8) | (((_len) & BIT_MASK(7)) << 1) | ESP_BLE_MESH_SENSOR_DATA_FORMAT_B)
/** This enum value is value of Sensor Sampling Function */
enum esp_ble_mesh_sensor_sample_func {
ESP_BLE_MESH_SAMPLE_FUNC_UNSPECIFIED,
ESP_BLE_MESH_SAMPLE_FUNC_INSTANTANEOUS,
ESP_BLE_MESH_SAMPLE_FUNC_ARITHMETIC_MEAN,
ESP_BLE_MESH_SAMPLE_FUNC_RMS,
ESP_BLE_MESH_SAMPLE_FUNC_MAXIMUM,
ESP_BLE_MESH_SAMPLE_FUNC_MINIMUM,
ESP_BLE_MESH_SAMPLE_FUNC_ACCUMULATED,
ESP_BLE_MESH_SAMPLE_FUNC_COUNT,
};
/** Parameters of Sensor Descriptor state */
typedef struct {
uint32_t positive_tolerance : 12, /*!< The value of Sensor Positive Tolerance field */
negative_tolerance : 12, /*!< The value of Sensor Negative Tolerance field */
sampling_function : 8; /*!< The value of Sensor Sampling Function field */
uint8_t measure_period; /*!< The value of Sensor Measurement Period field */
uint8_t update_interval; /*!< The value of Sensor Update Interval field */
} esp_ble_mesh_sensor_descriptor_t;
/** Parameters of Sensor Setting state */
typedef struct {
uint16_t property_id; /*!< The value of Sensor Setting Property ID field */
uint8_t access; /*!< The value of Sensor Setting Access field */
struct net_buf_simple *raw; /*!< The value of Sensor Setting Raw field */
} esp_ble_mesh_sensor_setting_t;
/** Parameters of Sensor Cadence state */
typedef struct {
uint8_t period_divisor : 7, /*!< The value of Fast Cadence Period Divisor field */
trigger_type : 1; /*!< The value of Status Trigger Type field */
/**
* Note:
* The parameter "size" in trigger_delta_down, trigger_delta_up, fast_cadence_low &
* fast_cadence_high indicates the exact length of these four parameters, and they
* are associated with the Sensor Property ID. Users need to initialize the "size"
* precisely.
*/
struct net_buf_simple *trigger_delta_down; /*!< The value of Status Trigger Delta Down field */
struct net_buf_simple *trigger_delta_up; /*!< The value of Status Trigger Delta Up field */
uint8_t min_interval; /*!< The value of Status Min Interval field */
struct net_buf_simple *fast_cadence_low; /*!< The value of Fast Cadence Low field */
struct net_buf_simple *fast_cadence_high; /*!< The value of Fast Cadence High field */
} esp_ble_mesh_sensor_cadence_t;
/** Parameters of Sensor Data state */
typedef struct {
/**
* Format A: The Length field is a 1-based uint4 value (valid range 0x00xF,
* representing range of 1 16).
* Format B: The Length field is a 1-based uint7 value (valid range 0x00x7F,
* representing range of 1 127). The value 0x7F represents a
* length of zero.
*/
uint8_t format : 1, /*!< The value of the Sensor Data format */
length : 7; /*!< The value of the Sensor Data length */
struct net_buf_simple *raw_value; /*!< The value of Sensor Data raw value */
} esp_ble_mesh_sensor_data_t;
/** Parameters of Sensor Series Column state */
typedef struct {
struct net_buf_simple *raw_value_x; /*!< The value of Sensor Raw Value X field */
struct net_buf_simple *column_width; /*!< The value of Sensor Column Width field */
struct net_buf_simple *raw_value_y; /*!< The value of Sensor Raw Value Y field */
} esp_ble_mesh_sensor_series_column_t;
/** Parameters of Sensor states */
typedef struct {
uint16_t sensor_property_id; /*!< The value of Sensor Property ID field */
/* Constant throughout the lifetime of an element */
esp_ble_mesh_sensor_descriptor_t descriptor; /*!< Parameters of the Sensor Descriptor state */
/**
* Multiple Sensor Setting states may be present for each sensor.
* The Sensor Setting Property ID values shall be unique for each
* Sensor Property ID that identifies a sensor within an element.
*/
const uint8_t setting_count; /*!< */
esp_ble_mesh_sensor_setting_t *settings; /*!< Parameters of the Sensor Setting state */
/**
* The Sensor Cadence state may be not supported by sensors based
* on device properties referencing "non-scalar characteristics"
* such as "histograms" or "composite characteristics".
*/
esp_ble_mesh_sensor_cadence_t *cadence; /*!< Parameters of the Sensor Cadence state */
esp_ble_mesh_sensor_data_t sensor_data; /*!< Parameters of the Sensor Data state */
esp_ble_mesh_sensor_series_column_t series_column; /*!< Parameters of the Sensor Series Column state */
} esp_ble_mesh_sensor_state_t;
/** User data of Sensor Server Model */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Sensor Server Model. Initialized internally. */
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
const uint8_t state_count; /*!< Sensor state count */
esp_ble_mesh_sensor_state_t *states; /*!< Parameters of the Sensor states */
} esp_ble_mesh_sensor_srv_t;
/** User data of Sensor Setup Server Model */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Sensor Setup Server Model. Initialized internally. */
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
const uint8_t state_count; /*!< Sensor state count */
esp_ble_mesh_sensor_state_t *states; /*!< Parameters of the Sensor states */
} esp_ble_mesh_sensor_setup_srv_t;
/** Parameters of Sensor Cadence Set state change event */
typedef struct {
uint16_t property_id; /*!< The value of Sensor Property ID state */
uint8_t period_divisor : 7, /*!< The value of Fast Cadence Period Divisor state */
trigger_type : 1; /*!< The value of Status Trigger Type state */
struct net_buf_simple *trigger_delta_down; /*!< The value of Status Trigger Delta Down state */
struct net_buf_simple *trigger_delta_up; /*!< The value of Status Trigger Delta Up state */
uint8_t min_interval; /*!< The value of Status Min Interval state */
struct net_buf_simple *fast_cadence_low; /*!< The value of Fast Cadence Low state */
struct net_buf_simple *fast_cadence_high; /*!< The value of Fast Cadence High state */
} esp_ble_mesh_state_change_sensor_cadence_set_t;
/** Parameters of Sensor Setting Set state change event */
typedef struct {
uint16_t property_id; /*!< The value of Sensor Property ID state */
uint16_t setting_property_id; /*!< The value of Sensor Setting Property ID state */
struct net_buf_simple *setting_value; /*!< The value of Sensor Property Value state */
} esp_ble_mesh_state_change_sensor_setting_set_t;
/**
* @brief Sensor Server Model state change value union
*/
typedef union {
/**
* The recv_op in ctx can be used to decide which state is changed.
*/
esp_ble_mesh_state_change_sensor_cadence_set_t sensor_cadence_set; /*!< Sensor Cadence Set */
esp_ble_mesh_state_change_sensor_setting_set_t sensor_setting_set; /*!< Sensor Setting Set */
} esp_ble_mesh_sensor_server_state_change_t;
/** Context of the received Sensor Descriptor Get message */
typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */
uint16_t property_id; /*!< Property ID of a sensor (optional) */
} esp_ble_mesh_server_recv_sensor_descriptor_get_t;
/** Context of the received Sensor Cadence Get message */
typedef struct {
uint16_t property_id; /*!< Property ID of a sensor */
} esp_ble_mesh_server_recv_sensor_cadence_get_t;
/** Context of the received Sensor Settings Get message */
typedef struct {
uint16_t property_id; /*!< Property ID of a sensor */
} esp_ble_mesh_server_recv_sensor_settings_get_t;
/** Context of the received Sensor Setting Get message */
typedef struct {
uint16_t property_id; /*!< Property ID of a sensor */
uint16_t setting_property_id; /*!< Setting ID identifying a setting within a sensor */
} esp_ble_mesh_server_recv_sensor_setting_get_t;
/** Context of the received Sensor Get message */
typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */
uint16_t property_id; /*!< Property ID for the sensor (optional) */
} esp_ble_mesh_server_recv_sensor_get_t;
/** Context of the received Sensor Column Get message */
typedef struct {
uint16_t property_id; /*!< Property identifying a sensor */
struct net_buf_simple *raw_value_x; /*!< Raw value identifying a column */
} esp_ble_mesh_server_recv_sensor_column_get_t;
/** Context of the received Sensor Series Get message */
typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */
uint16_t property_id; /*!< Property identifying a sensor */
struct net_buf_simple *raw_value; /*!< Raw value containing X1 and X2 (optional) */
} esp_ble_mesh_server_recv_sensor_series_get_t;
/**
* @brief Sensor Server Model received get message union
*/
typedef union {
esp_ble_mesh_server_recv_sensor_descriptor_get_t sensor_descriptor; /*!< Sensor Descriptor Get */
esp_ble_mesh_server_recv_sensor_cadence_get_t sensor_cadence; /*!< Sensor Cadence Get */
esp_ble_mesh_server_recv_sensor_settings_get_t sensor_settings; /*!< Sensor Settings Get */
esp_ble_mesh_server_recv_sensor_setting_get_t sensor_setting; /*!< Sensor Setting Get */
esp_ble_mesh_server_recv_sensor_get_t sensor_data; /*!< Sensor Get */
esp_ble_mesh_server_recv_sensor_column_get_t sensor_column; /*!< Sensor Column Get */
esp_ble_mesh_server_recv_sensor_series_get_t sensor_series; /*!< Sensor Series Get */
} esp_ble_mesh_sensor_server_recv_get_msg_t;
/** Context of the received Sensor Cadence Set message */
typedef struct {
uint16_t property_id; /*!< Property ID for the sensor */
struct net_buf_simple *cadence; /*!< Value of Sensor Cadence state */
} esp_ble_mesh_server_recv_sensor_cadence_set_t;
/** Context of the received Sensor Setting Set message */
typedef struct {
uint16_t property_id; /*!< Property ID identifying a sensor */
uint16_t setting_property_id; /*!< Setting ID identifying a setting within a sensor */
struct net_buf_simple *setting_raw; /*!< Raw value for the setting */
} esp_ble_mesh_server_recv_sensor_setting_set_t;
/**
* @brief Sensor Server Model received set message union
*/
typedef union {
esp_ble_mesh_server_recv_sensor_cadence_set_t sensor_cadence; /*!< Sensor Cadence Set */
esp_ble_mesh_server_recv_sensor_setting_set_t sensor_setting; /*!< Sensor Setting Set */
} esp_ble_mesh_sensor_server_recv_set_msg_t;
/**
* @brief Sensor Server Model callback value union
*/
typedef union {
esp_ble_mesh_sensor_server_state_change_t state_change; /*!< ESP_BLE_MESH_SENSOR_SERVER_STATE_CHANGE_EVT */
esp_ble_mesh_sensor_server_recv_get_msg_t get; /*!< ESP_BLE_MESH_SENSOR_SERVER_RECV_GET_MSG_EVT */
esp_ble_mesh_sensor_server_recv_set_msg_t set; /*!< ESP_BLE_MESH_SENSOR_SERVER_RECV_SET_MSG_EVT */
} esp_ble_mesh_sensor_server_cb_value_t;
/** Sensor Server Model callback parameters */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to Sensor Server Models */
esp_ble_mesh_msg_ctx_t ctx; /*!< Context of the received messages */
esp_ble_mesh_sensor_server_cb_value_t value; /*!< Value of the received Sensor Messages */
} esp_ble_mesh_sensor_server_cb_param_t;
/** This enum value is the event of Sensor Server Model */
typedef enum {
/**
* 1. When get_auto_rsp is set to ESP_BLE_MESH_SERVER_AUTO_RSP, no event will be
* callback to the application layer when Sensor Get messages are received.
* 2. When set_auto_rsp is set to ESP_BLE_MESH_SERVER_AUTO_RSP, this event will
* be callback to the application layer when Sensor Set/Set Unack messages
* are received.
*/
ESP_BLE_MESH_SENSOR_SERVER_STATE_CHANGE_EVT,
/**
* When get_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, this event will be
* callback to the application layer when Sensor Get messages are received.
*/
ESP_BLE_MESH_SENSOR_SERVER_RECV_GET_MSG_EVT,
/**
* When set_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, this event will be
* callback to the application layer when Sensor Set/Set Unack messages are received.
*/
ESP_BLE_MESH_SENSOR_SERVER_RECV_SET_MSG_EVT,
ESP_BLE_MESH_SENSOR_SERVER_EVT_MAX,
} esp_ble_mesh_sensor_server_cb_event_t;
/**
* @brief Bluetooth Mesh Sensor Server Model function.
*/
/**
* @brief Sensor Server Model callback function type
* @param event: Event type
* @param param: Pointer to callback parameter
*/
typedef void (* esp_ble_mesh_sensor_server_cb_t)(esp_ble_mesh_sensor_server_cb_event_t event,
esp_ble_mesh_sensor_server_cb_param_t *param);
/**
* @brief Register BLE Mesh Sensor Server Model callback.
*
* @param[in] callback: Pointer to the callback function.
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_register_sensor_server_callback(esp_ble_mesh_sensor_server_cb_t callback);
#ifdef __cplusplus
}
#endif
#endif /* _ESP_BLE_MESH_SENSOR_MODEL_API_H_ */

View File

@ -19,9 +19,12 @@
#ifndef _ESP_BLE_MESH_TIME_SCENE_MODEL_API_H_
#define _ESP_BLE_MESH_TIME_SCENE_MODEL_API_H_
#include "time_scene_client.h"
#include "esp_ble_mesh_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @def ESP_BLE_MESH_MODEL_TIME_CLI
*
* @brief Define a new Time Client Model.
@ -76,69 +79,69 @@
/** Parameters of Time Set */
typedef struct {
u8_t tai_seconds[5]; /*!< The current TAI time in seconds */
u8_t sub_second; /*!< The sub-second time in units of 1/256 second */
u8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */
u16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */
u16_t tai_utc_delta : 15; /*!< Current difference between TAI and UTC in seconds */
u8_t time_zone_offset; /*!< The local time zone offset in 15-minute increments */
uint8_t tai_seconds[5]; /*!< The current TAI time in seconds */
uint8_t sub_second; /*!< The sub-second time in units of 1/256 second */
uint8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */
uint16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */
uint16_t tai_utc_delta : 15; /*!< Current difference between TAI and UTC in seconds */
uint8_t time_zone_offset; /*!< The local time zone offset in 15-minute increments */
} esp_ble_mesh_time_set_t;
/** Parameters of Time Zone Set */
typedef struct {
u8_t time_zone_offset_new; /*!< Upcoming local time zone offset */
u8_t tai_zone_change[5]; /*!< TAI Seconds time of the upcoming Time Zone Offset change */
uint8_t time_zone_offset_new; /*!< Upcoming local time zone offset */
uint8_t tai_zone_change[5]; /*!< TAI Seconds time of the upcoming Time Zone Offset change */
} esp_ble_mesh_time_zone_set_t;
/** Parameters of TAI-UTC Delta Set */
typedef struct {
u16_t tai_utc_delta_new : 15; /*!< Upcoming difference between TAI and UTC in seconds */
u16_t padding : 1; /*!< Always 0b0. Other values are Prohibited. */
u8_t tai_delta_change[5]; /*!< TAI Seconds time of the upcoming TAI-UTC Delta change */
uint16_t tai_utc_delta_new : 15; /*!< Upcoming difference between TAI and UTC in seconds */
uint16_t padding : 1; /*!< Always 0b0. Other values are Prohibited. */
uint8_t tai_delta_change[5]; /*!< TAI Seconds time of the upcoming TAI-UTC Delta change */
} esp_ble_mesh_tai_utc_delta_set_t;
/** Parameter of Time Role Set */
typedef struct {
u8_t time_role; /*!< The Time Role for the element */
uint8_t time_role; /*!< The Time Role for the element */
} esp_ble_mesh_time_role_set_t;
/** Parameter of Scene Store */
typedef struct {
u16_t scene_number; /*!< The number of scenes to be stored */
uint16_t scene_number; /*!< The number of scenes to be stored */
} esp_ble_mesh_scene_store_t;
/** Parameters of Scene Recall */
typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */
u16_t scene_number; /*!< The number of scenes to be recalled */
u8_t tid; /*!< Transaction ID */
u8_t trans_time; /*!< Time to complete state transition (optional) */
u8_t delay; /*!< Indicate message execution delay (C.1) */
bool op_en; /*!< Indicate if optional parameters are included */
uint16_t scene_number; /*!< The number of scenes to be recalled */
uint8_t tid; /*!< Transaction ID */
uint8_t trans_time; /*!< Time to complete state transition (optional) */
uint8_t delay; /*!< Indicate message execution delay (C.1) */
} esp_ble_mesh_scene_recall_t;
/** Parameter of Scene Delete */
typedef struct {
u16_t scene_number; /*!< The number of scenes to be deleted */
uint16_t scene_number; /*!< The number of scenes to be deleted */
} esp_ble_mesh_scene_delete_t;
/** Parameter of Scheduler Action Get */
typedef struct {
u8_t index; /*!< Index of the Schedule Register entry to get */
uint8_t index; /*!< Index of the Schedule Register entry to get */
} esp_ble_mesh_scheduler_act_get_t;
/** Parameters of Scheduler Action Set */
typedef struct {
u64_t index : 4; /*!< Index of the Schedule Register entry to set */
u64_t year : 7; /*!< Scheduled year for the action */
u64_t month : 12; /*!< Scheduled month for the action */
u64_t day : 5; /*!< Scheduled day of the month for the action */
u64_t hour : 5; /*!< Scheduled hour for the action */
u64_t minute : 6; /*!< Scheduled minute for the action */
u64_t second : 6; /*!< Scheduled second for the action */
u64_t day_of_week : 7; /*!< Schedule days of the week for the action */
u64_t action : 4; /*!< Action to be performed at the scheduled time */
u64_t trans_time : 8; /*!< Transition time for this action */
u16_t scene_number; /*!< Transition time for this action */
uint64_t index : 4; /*!< Index of the Schedule Register entry to set */
uint64_t year : 7; /*!< Scheduled year for the action */
uint64_t month : 12; /*!< Scheduled month for the action */
uint64_t day : 5; /*!< Scheduled day of the month for the action */
uint64_t hour : 5; /*!< Scheduled hour for the action */
uint64_t minute : 6; /*!< Scheduled minute for the action */
uint64_t second : 6; /*!< Scheduled second for the action */
uint64_t day_of_week : 7; /*!< Schedule days of the week for the action */
uint64_t action : 4; /*!< Action to be performed at the scheduled time */
uint64_t trans_time : 8; /*!< Transition time for this action */
uint16_t scene_number; /*!< Transition time for this action */
} esp_ble_mesh_scheduler_act_set_t;
/**
@ -168,69 +171,69 @@ typedef union {
/** Parameters of Time Status */
typedef struct {
u8_t tai_seconds[5]; /*!< The current TAI time in seconds */
u8_t sub_second; /*!< The sub-second time in units of 1/256 second */
u8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */
u16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */
u16_t tai_utc_delta : 15; /*!< Current difference between TAI and UTC in seconds */
u8_t time_zone_offset; /*!< The local time zone offset in 15-minute increments */
uint8_t tai_seconds[5]; /*!< The current TAI time in seconds */
uint8_t sub_second; /*!< The sub-second time in units of 1/256 second */
uint8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */
uint16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */
uint16_t tai_utc_delta : 15; /*!< Current difference between TAI and UTC in seconds */
uint8_t time_zone_offset; /*!< The local time zone offset in 15-minute increments */
} esp_ble_mesh_time_status_cb_t;
/** Parameters of Time Zone Status */
typedef struct {
u8_t time_zone_offset_curr; /*!< Current local time zone offset */
u8_t time_zone_offset_new; /*!< Upcoming local time zone offset */
u8_t tai_zone_change[5]; /*!< TAI Seconds time of the upcoming Time Zone Offset change */
uint8_t time_zone_offset_curr; /*!< Current local time zone offset */
uint8_t time_zone_offset_new; /*!< Upcoming local time zone offset */
uint8_t tai_zone_change[5]; /*!< TAI Seconds time of the upcoming Time Zone Offset change */
} esp_ble_mesh_time_zone_status_cb_t;
/** Parameters of TAI-UTC Delta Status */
typedef struct {
u16_t tai_utc_delta_curr : 15; /*!< Current difference between TAI and UTC in seconds */
u16_t padding_1 : 1; /*!< Always 0b0. Other values are Prohibited. */
u16_t tai_utc_delta_new : 15; /*!< Upcoming difference between TAI and UTC in seconds */
u16_t padding_2 : 1; /*!< Always 0b0. Other values are Prohibited. */
u8_t tai_delta_change[5]; /*!< TAI Seconds time of the upcoming TAI-UTC Delta change */
uint16_t tai_utc_delta_curr : 15; /*!< Current difference between TAI and UTC in seconds */
uint16_t padding_1 : 1; /*!< Always 0b0. Other values are Prohibited. */
uint16_t tai_utc_delta_new : 15; /*!< Upcoming difference between TAI and UTC in seconds */
uint16_t padding_2 : 1; /*!< Always 0b0. Other values are Prohibited. */
uint8_t tai_delta_change[5]; /*!< TAI Seconds time of the upcoming TAI-UTC Delta change */
} esp_ble_mesh_tai_utc_delta_status_cb_t;
/** Parameter of Time Role Status */
typedef struct {
u8_t time_role; /*!< The Time Role for the element */
uint8_t time_role; /*!< The Time Role for the element */
} esp_ble_mesh_time_role_status_cb_t;
/** Parameters of Scene Status */
typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */
u8_t status_code; /*!< Status code of the last operation */
u16_t current_scene; /*!< Scene Number of the current scene */
u16_t target_scene; /*!< Scene Number of the target scene (optional) */
u8_t remain_time; /*!< Time to complete state transition (C.1) */
bool op_en; /*!< Indicate if optional parameters are included */
uint8_t status_code; /*!< Status code of the last operation */
uint16_t current_scene; /*!< Scene Number of the current scene */
uint16_t target_scene; /*!< Scene Number of the target scene (optional) */
uint8_t remain_time; /*!< Time to complete state transition (C.1) */
} esp_ble_mesh_scene_status_cb_t;
/** Parameters of Scene Register Status */
typedef struct {
u8_t status_code; /*!< Status code for the previous operation */
u16_t current_scene; /*!< Scene Number of the current scene */
uint8_t status_code; /*!< Status code for the previous operation */
uint16_t current_scene; /*!< Scene Number of the current scene */
struct net_buf_simple *scenes; /*!< A list of scenes stored within an element */
} esp_ble_mesh_scene_register_status_cb_t;
/** Parameter of Scheduler Status */
typedef struct {
u16_t schedules; /*!< Bit field indicating defined Actions in the Schedule Register */
uint16_t schedules; /*!< Bit field indicating defined Actions in the Schedule Register */
} esp_ble_mesh_scheduler_status_cb_t;
/** Parameters of Scheduler Action Status */
typedef struct {
u64_t index : 4; /*!< Enumerates (selects) a Schedule Register entry */
u64_t year : 7; /*!< Scheduled year for the action */
u64_t month : 12; /*!< Scheduled month for the action */
u64_t day : 5; /*!< Scheduled day of the month for the action */
u64_t hour : 5; /*!< Scheduled hour for the action */
u64_t minute : 6; /*!< Scheduled minute for the action */
u64_t second : 6; /*!< Scheduled second for the action */
u64_t day_of_week : 7; /*!< Schedule days of the week for the action */
u64_t action : 4; /*!< Action to be performed at the scheduled time */
u64_t trans_time : 8; /*!< Transition time for this action */
u16_t scene_number; /*!< Transition time for this action */
uint64_t index : 4; /*!< Enumerates (selects) a Schedule Register entry */
uint64_t year : 7; /*!< Scheduled year for the action */
uint64_t month : 12; /*!< Scheduled month for the action */
uint64_t day : 5; /*!< Scheduled day of the month for the action */
uint64_t hour : 5; /*!< Scheduled hour for the action */
uint64_t minute : 6; /*!< Scheduled minute for the action */
uint64_t second : 6; /*!< Scheduled second for the action */
uint64_t day_of_week : 7; /*!< Schedule days of the week for the action */
uint64_t action : 4; /*!< Action to be performed at the scheduled time */
uint64_t trans_time : 8; /*!< Transition time for this action */
uint16_t scene_number; /*!< Transition time for this action */
} esp_ble_mesh_scheduler_act_status_cb_t;
/**
@ -273,7 +276,7 @@ typedef enum {
* @param param: Pointer to callback parameter
*/
typedef void (* esp_ble_mesh_time_scene_client_cb_t)(esp_ble_mesh_time_scene_client_cb_event_t event,
esp_ble_mesh_time_scene_client_cb_param_t *param);
esp_ble_mesh_time_scene_client_cb_param_t *param);
/**
* @brief Register BLE Mesh Time Scene Client Model callback.
@ -298,7 +301,7 @@ esp_err_t esp_ble_mesh_register_time_scene_client_callback(esp_ble_mesh_time_sce
* @return ESP_OK on success or error code otherwise.
*/
esp_err_t esp_ble_mesh_time_scene_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_time_scene_client_get_state_t *get_state);
esp_ble_mesh_time_scene_client_get_state_t *get_state);
/**
* @brief Set the value of Time Scene Server Model states using the Time Scene Client Model set messages.
@ -313,7 +316,605 @@ esp_err_t esp_ble_mesh_time_scene_client_get_state(esp_ble_mesh_client_common_pa
* @return ESP_OK on success or error code otherwise.
*/
esp_err_t esp_ble_mesh_time_scene_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_time_scene_client_set_state_t *set_state);
esp_ble_mesh_time_scene_client_set_state_t *set_state);
/**
* @brief Time Scene Server Models related context.
*/
/** @def ESP_BLE_MESH_MODEL_TIME_SRV
*
* @brief Define a new Time Server Model.
*
* @note 1. The Time Server model is a root model. When this model is present on an
* Element, the corresponding Time Setup Server model shall also be present.
* 2. This model shall support model publication and model subscription.
*
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
* @param srv_data Pointer to the unique struct esp_ble_mesh_time_srv_t.
*
* @return New Time Server Model instance.
*/
#define ESP_BLE_MESH_MODEL_TIME_SRV(srv_pub, srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_TIME_SRV, \
NULL, srv_pub, srv_data)
/** @def ESP_BLE_MESH_MODEL_TIME_SETUP_SRV
*
* @brief Define a new Time Setup Server Model.
*
* @note 1. The Time Setup Server model extends the Time Server model. Time is
* sensitive information that is propagated across a mesh network.
* 2. Only an authorized Time Client should be allowed to change the Time
* and Time Role states. A dedicated application key Bluetooth SIG
* Proprietary should be used on the Time Setup Server to restrict
* access to the server to only authorized Time Clients.
* 3. This model does not support subscribing nor publishing.
*
* @param srv_data Pointer to the unique struct esp_ble_mesh_time_setup_srv_t.
*
* @return New Time Setup Server Model instance.
*/
#define ESP_BLE_MESH_MODEL_TIME_SETUP_SRV(srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_TIME_SETUP_SRV, \
NULL, NULL, srv_data)
/** @def ESP_BLE_MESH_MODEL_SCENE_SRV
*
* @brief Define a new Scene Server Model.
*
* @note 1. The Scene Server model is a root model. When this model is present
* on an Element, the corresponding Scene Setup Server model shall
* also be present.
* 2. This model shall support model publication and model subscription.
* 3. The model may be present only on the Primary element of a node.
*
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
* @param srv_data Pointer to the unique struct esp_ble_mesh_scene_srv_t.
*
* @return New Scene Server Model instance.
*/
#define ESP_BLE_MESH_MODEL_SCENE_SRV(srv_pub, srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SCENE_SRV, \
NULL, srv_pub, srv_data)
/** @def ESP_BLE_MESH_MODEL_SCENE_SETUP_SRV
*
* @brief Define a new Scene Setup Server Model.
*
* @note 1. The Scene Setup Server model extends the Scene Server model and
* the Generic Default Transition Time Server model.
* 2. This model shall support model subscription.
* 3. The model may be present only on the Primary element of a node.
*
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
* @param srv_data Pointer to the unique struct esp_ble_mesh_scene_setup_srv_t.
*
* @return New Scene Setup Server Model instance.
*/
#define ESP_BLE_MESH_MODEL_SCENE_SETUP_SRV(srv_pub, srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SCENE_SETUP_SRV, \
NULL, srv_pub, srv_data)
/** @def ESP_BLE_MESH_MODEL_SCHEDULER_SRV
*
* @brief Define a new Scheduler Server Model.
*
* @note 1. The Scheduler Server model extends the Scene Server model. When
* this model is present on an Element, the corresponding Scheduler
* Setup Server model shall also be present.
* 2. This model shall support model publication and model subscription.
* 3. The model may be present only on the Primary element of a node.
* 4. The model requires the Time Server model shall be present on the element.
*
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
* @param srv_data Pointer to the unique struct esp_ble_mesh_scheduler_srv_t.
*
* @return New Scheduler Server Model instance.
*/
#define ESP_BLE_MESH_MODEL_SCHEDULER_SRV(srv_pub, srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SCHEDULER_SRV, \
NULL, srv_pub, srv_data)
/** @def ESP_BLE_MESH_MODEL_SCHEDULER_SETUP_SRV
*
* @brief Define a new Scheduler Setup Server Model.
*
* @note 1. The Scheduler Setup Server model extends the Scheduler Server and
* the Scene Setup Server models.
* 2. This model shall support model subscription.
* 3. The model may be present only on the Primary element of a node.
*
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
* @param srv_data Pointer to the unique struct esp_ble_mesh_scheduler_setup_srv_t.
*
* @return New Scheduler Setup Server Model instance.
*/
#define ESP_BLE_MESH_MODEL_SCHEDULER_SETUP_SRV(srv_pub, srv_data) \
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SCHEDULER_SETUP_SRV, \
NULL, srv_pub, srv_data)
#define ESP_BLE_MESH_UNKNOWN_TAI_SECONDS 0x0000000000 /*!< Unknown TAI Seconds */
#define ESP_BLE_MESH_UNKNOWN_TAI_ZONE_CHANGE 0x0000000000 /*!< Unknown TAI of Zone Change */
#define ESP_BLE_MESH_UNKNOWN_TAI_DELTA_CHANGE 0x0000000000 /*!< Unknown TAI of Delta Change */
#define ESP_BLE_MESH_TAI_UTC_DELTA_MAX_VALUE 0x7FFF /*!< Maximum TAI-UTC Delta value */
#define ESP_BLE_MESH_TAI_SECONDS_LEN 0x05 /*!< Length of TAI Seconds */
#define ESP_BLE_MESH_TAI_OF_ZONE_CHANGE_LEN 0x05 /*!< Length of TAI of Zone Change */
#define ESP_BLE_MESH_TAI_OF_DELTA_CHANGE_LEN 0x05 /*!< Length of TAI of Delta Change */
#define ESP_BLE_MESH_INVALID_SCENE_NUMBER 0x0000 /*!< Invalid Scene Number */
#define ESP_BLE_MESH_SCENE_NUMBER_LEN 0x02 /*!< Length of the Scene Number */
#define ESP_BLE_MESH_SCHEDULE_YEAR_ANY_YEAR 0x64 /*!< Any year of the Scheduled year */
#define ESP_BLE_MESH_SCHEDULE_DAY_ANY_DAY 0x00 /*!< Any day of the Scheduled day */
#define ESP_BLE_MESH_SCHEDULE_HOUR_ANY_HOUR 0x18 /*!< Any hour of the Scheduled hour */
#define ESP_BLE_MESH_SCHEDULE_HOUR_ONCE_A_DAY 0x19 /*!< Any hour of the Scheduled Day */
#define ESP_BLE_MESH_SCHEDULE_SEC_ANY_OF_HOUR 0x3C /*!< Any minute of the Scheduled hour */
#define ESP_BLE_MESH_SCHEDULE_SEC_EVERY_15_MIN 0x3D /*!< Every 15 minutes of the Scheduled hour */
#define ESP_BLE_MESH_SCHEDULE_SEC_EVERY_20_MIN 0x3E /*!< Every 20 minutes of the Scheduled hour */
#define ESP_BLE_MESH_SCHEDULE_SEC_ONCE_AN_HOUR 0x3F /*!< Once of the Scheduled hour */
#define ESP_BLE_MESH_SCHEDULE_SEC_ANY_OF_MIN 0x3C /*!< Any second of the Scheduled minute */
#define ESP_BLE_MESH_SCHEDULE_SEC_EVERY_15_SEC 0x3D /*!< Every 15 seconds of the Scheduled minute */
#define ESP_BLE_MESH_SCHEDULE_SEC_EVERY_20_SEC 0x3E /*!< Every 20 seconds of the Scheduled minute */
#define ESP_BLE_MESH_SCHEDULE_SEC_ONCE_AN_MIN 0x3F /*!< Once of the Scheduled minute */
#define ESP_BLE_MESH_SCHEDULE_ACT_TURN_OFF 0x00 /*!< Scheduled Action - Turn Off */
#define ESP_BLE_MESH_SCHEDULE_ACT_TURN_ON 0x01 /*!< Scheduled Action - Turn On */
#define ESP_BLE_MESH_SCHEDULE_ACT_SCENE_RECALL 0x02 /*!< Scheduled Action - Scene Recall */
#define ESP_BLE_MESH_SCHEDULE_ACT_NO_ACTION 0x0F /*!< Scheduled Action - No Action */
#define ESP_BLE_MESH_SCHEDULE_SCENE_NO_SCENE 0x0000 /*!< Scheduled Scene - No Scene */
#define ESP_BLE_MESH_SCHEDULE_ENTRY_MAX_INDEX 0x0F /*!< Maximum number of Scheduled entries */
#define ESP_BLE_MESH_TIME_NONE 0x00 /*!< Time Role - None */
#define ESP_BLE_MESH_TIME_AUTHORITY 0x01 /*!< Time Role - Mesh Time Authority */
#define ESP_BLE_MESH_TIME_RELAY 0x02 /*!< Time Role - Mesh Time Relay */
#define ESP_BLE_MESH_TIME_CLINET 0x03 /*!< Time Role - Mesh Time Client */
#define ESP_BLE_MESH_SCENE_SUCCESS 0x00 /*!< Scene operation - Success */
#define ESP_BLE_MESH_SCENE_REG_FULL 0x01 /*!< Scene operation - Scene Register Full */
#define ESP_BLE_MESH_SCENE_NOT_FOUND 0x02 /*!< Scene operation - Scene Not Found */
/** Parameters of Time state */
typedef struct {
struct {
uint8_t tai_seconds[5]; /*!< The value of the TAI Seconds state */
uint8_t subsecond; /*!< The value of the Subsecond field */
uint8_t uncertainty; /*!< The value of the Uncertainty field */
uint8_t time_zone_offset_curr; /*!< The value of the Time Zone Offset Current field */
uint8_t time_zone_offset_new; /*!< The value of the Time Zone Offset New state */
uint8_t tai_zone_change[5]; /*!< The value of the TAI of Zone Chaneg field */
uint16_t time_authority : 1, /*!< The value of the Time Authority bit */
tai_utc_delta_curr : 15; /*!< The value of the TAI-UTC Delta Current state */
uint16_t tai_utc_delta_new : 15; /*!< The value of the TAI-UTC Delta New state */
uint8_t tai_delta_change[5]; /*!< The value of the TAI of Delta Change field */
} time; /*!< Parameters of the Time state */
uint8_t time_role; /*!< The value of the Time Role state */
} esp_ble_mesh_time_state_t;
/** User data of Time Server Model */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Time Server Model. Initialized internally. */
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
esp_ble_mesh_time_state_t *state; /*!< Parameters of the Time state */
} esp_ble_mesh_time_srv_t;
/** User data of Time Setup Server Model */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Time Setup Server Model. Initialized internally. */
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
esp_ble_mesh_time_state_t *state; /*!< Parameters of the Time state */
} esp_ble_mesh_time_setup_srv_t;
/**
* 1. Scene Store is an operation of storing values of a present state of an element.
* 2. The structure and meaning of the stored state is determined by a model. States
* to be stored are specified by each model.
* 3. The Scene Store operation shall persistently store all values of all states
* marked as Stored with Scene for all models present on all elements of a node.
* 4. If a model is extending another model, the extending model shall determine the
* Stored with Scene behavior of that model.
*/
/** Parameters of Scene Register state */
typedef struct {
uint16_t scene_number; /*!< The value of the Scene Number */
uint8_t scene_type; /*!< The value of the Scene Type */
/**
* Scene value may use a union to represent later, the union contains
* structures of all the model states which can be stored in a scene.
*/
struct net_buf_simple *scene_value; /*!< The value of the Scene Value */
} esp_ble_mesh_scene_register_t;
/**
* Parameters of Scenes state.
*
* Scenes serve as memory banks for storage of states (e.g., a power level
* or a light level/color). Values of states of an element can be stored
* as a scene and can be recalled later from the scene memory.
*
* A scene is represented by a Scene Number, which is a 16-bit non-zero,
* mesh-wide value. (There can be a maximum of 65535 scenes in a mesh
* network.) The meaning of a scene, as well as the state storage container
* associated with it, are determined by a model.
*
* The Scenes state change may start numerous parallel model transitions.
* In that case, each individual model handles the transition internally.
*
* The scene transition is defined as a group of individual model transitions
* started by a Scene Recall operation. The scene transition is in progress
* when at least one transition from the group of individual model transitions
* is in progress.
*/
typedef struct {
const uint16_t scene_count; /*!< The Scenes state's scene count */
esp_ble_mesh_scene_register_t *scenes; /*!< Parameters of the Scenes state */
/**
* The Current Scene state is a 16-bit value that contains either the Scene
* Number of the currently active scene or a value of 0x0000 when no scene
* is active.
*
* When a Scene Store operation or a Scene Recall operation completes with
* success, the Current Scene state value shall be to the Scene Number used
* during that operation.
*
* When the Current Scene Number is deleted from a Scene Register state as a
* result of Scene Delete operation, the Current Scene state shall be set to
* 0x0000.
*
* When any of the element's state that is marked as “Stored with Scene” has
* changed not as a result of a Scene Recall operation, the value of the
* Current Scene state shall be set to 0x0000.
*
* When a scene transition is in progress, the value of the Current Scene
* state shall be set to 0x0000.
*/
uint16_t current_scene; /*!< The value of the Current Scene state */
/**
* The Target Scene state is a 16-bit value that contains the target Scene
* Number when a scene transition is in progress.
*
* When the scene transition is in progress and the target Scene Number is
* deleted from a Scene Register state as a result of Scene Delete operation,
* the Target Scene state shall be set to 0x0000.
*
* When the scene transition is in progress and a new Scene Number is stored
* in the Scene Register as a result of Scene Store operation, the Target
* Scene state shall be set to the new Scene Number.
*
* When the scene transition is not in progress, the value of the Target Scene
* state shall be set to 0x0000.
*/
uint16_t target_scene; /*!< The value of the Target Scene state */
/* Indicate the status code for the last operation */
uint8_t status_code; /*!< The status code of the last scene operation */
/* Indicate if scene transition is in progress */
bool in_progress; /*!< Indicate if the scene transition is in progress */
} esp_ble_mesh_scenes_state_t;
/** User data of Scene Server Model */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Scene Server Model. Initialized internally. */
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
esp_ble_mesh_scenes_state_t *state; /*!< Parameters of the Scenes state */
esp_ble_mesh_last_msg_info_t last; /*!< Parameters of the last received set message */
esp_ble_mesh_state_transition_t transition; /*!< Parameters of state transition */
} esp_ble_mesh_scene_srv_t;
/** User data of Scene Setup Server Model */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Scene Setup Server Model. Initialized internally. */
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
esp_ble_mesh_scenes_state_t *state; /*!< Parameters of the Scenes state */
} esp_ble_mesh_scene_setup_srv_t;
/** Parameters of Scheduler Register state */
typedef struct {
bool in_use; /*!< Indicate if the registered schedule is in use */
uint64_t year : 7, /*!< The value of Scheduled year for the action */
month : 12, /*!< The value of Scheduled month for the action */
day : 5, /*!< The value of Scheduled day of the month for the action */
hour : 5, /*!< The value of Scheduled hour for the action */
minute : 6, /*!< The value of Scheduled minute for the action */
second : 6, /*!< The value of Scheduled second for the action */
day_of_week : 7, /*!< The value of Schedule days of the week for the action */
action : 4, /*!< The value of Action to be performed at the scheduled time */
trans_time : 8; /*!< The value of Transition time for this action */
uint16_t scene_number; /*!< The value of Scene Number to be used for some actions */
} esp_ble_mesh_schedule_register_t;
/** Parameters of Scheduler state */
typedef struct {
const uint8_t schedule_count; /*!< Scheduler count */
esp_ble_mesh_schedule_register_t *schedules; /*!< Up to 16 scheduled entries */
} esp_ble_mesh_scheduler_state_t;
/** User data of Scheduler Server Model */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Scheduler Server Model. Initialized internally. */
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
esp_ble_mesh_scheduler_state_t *state; /*!< Parameters of the Scheduler state */
} esp_ble_mesh_scheduler_srv_t;
/** User data of Scheduler Setup Server Model */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to the Scheduler Setup Server Model. Initialized internally. */
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
esp_ble_mesh_scheduler_state_t *state; /*!< Parameters of the Scheduler state */
} esp_ble_mesh_scheduler_setup_srv_t;
/** Parameters of Time Set state change event */
typedef struct {
uint8_t tai_seconds[5]; /*!< The current TAI time in seconds */
uint8_t subsecond; /*!< The sub-second time in units of 1/256 second */
uint8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */
uint16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */
uint16_t tai_utc_delta_curr : 15; /*!< Current difference between TAI and UTC in seconds */
uint8_t time_zone_offset_curr; /*!< The local time zone offset in 15-minute increments */
} esp_ble_mesh_state_change_time_set_t;
/** Parameters of Time Status state change event */
typedef struct {
uint8_t tai_seconds[5]; /*!< The current TAI time in seconds */
uint8_t subsecond; /*!< The sub-second time in units of 1/256 second */
uint8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */
uint16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */
uint16_t tai_utc_delta_curr : 15; /*!< Current difference between TAI and UTC in seconds */
uint8_t time_zone_offset_curr; /*!< The local time zone offset in 15-minute increments */
} esp_ble_mesh_state_change_time_status_t;
/** Parameters of Time Zone Set state change event */
typedef struct {
uint8_t time_zone_offset_new; /*!< Upcoming local time zone offset */
uint8_t tai_zone_change[5]; /*!< TAI Seconds time of the upcoming Time Zone Offset change */
} esp_ble_mesh_state_change_time_zone_set_t;
/** Parameters of TAI UTC Delta Set state change event */
typedef struct {
uint16_t tai_utc_delta_new : 15; /*!< Upcoming difference between TAI and UTC in seconds */
uint8_t tai_delta_change[5]; /*!< TAI Seconds time of the upcoming TAI-UTC Delta change */
} esp_ble_mesh_state_change_tai_utc_delta_set_t;
/** Parameter of Time Role Set state change event */
typedef struct {
uint8_t time_role; /*!< The Time Role for the element */
} esp_ble_mesh_state_change_time_role_set_t;
/** Parameter of Scene Store state change event */
typedef struct {
uint16_t scene_number; /*!< The number of scenes to be stored */
} esp_ble_mesh_state_change_scene_store_t;
/** Parameter of Scene Recall state change event */
typedef struct {
uint16_t scene_number; /*!< The number of scenes to be recalled */
} esp_ble_mesh_state_change_scene_recall_t;
/** Parameter of Scene Delete state change event */
typedef struct {
uint16_t scene_number; /*!< The number of scenes to be deleted */
} esp_ble_mesh_state_change_scene_delete_t;
/** Parameter of Scheduler Action Set state change event */
typedef struct {
uint64_t index : 4; /*!< Index of the Schedule Register entry to set */
uint64_t year : 7; /*!< Scheduled year for the action */
uint64_t month : 12; /*!< Scheduled month for the action */
uint64_t day : 5; /*!< Scheduled day of the month for the action */
uint64_t hour : 5; /*!< Scheduled hour for the action */
uint64_t minute : 6; /*!< Scheduled minute for the action */
uint64_t second : 6; /*!< Scheduled second for the action */
uint64_t day_of_week : 7; /*!< Schedule days of the week for the action */
uint64_t action : 4; /*!< Action to be performed at the scheduled time */
uint64_t trans_time : 8; /*!< Transition time for this action */
uint16_t scene_number; /*!< Scene number to be used for some actions */
} esp_ble_mesh_state_change_scheduler_act_set_t;
/**
* @brief Time Scene Server Model state change value union
*/
typedef union {
/**
* The recv_op in ctx can be used to decide which state is changed.
*/
esp_ble_mesh_state_change_time_set_t time_set; /*!< Time Set */
esp_ble_mesh_state_change_time_status_t time_status; /*!< Time Status */
esp_ble_mesh_state_change_time_zone_set_t time_zone_set; /*!< Time Zone Set */
esp_ble_mesh_state_change_tai_utc_delta_set_t tai_utc_delta_set; /*!< TAI UTC Delta Set */
esp_ble_mesh_state_change_time_role_set_t time_role_set; /*!< Time Role Set */
esp_ble_mesh_state_change_scene_store_t scene_store; /*!< Scene Store */
esp_ble_mesh_state_change_scene_recall_t scene_recall; /*!< Scene Recall */
esp_ble_mesh_state_change_scene_delete_t scene_delete; /*!< Scene Delete */
esp_ble_mesh_state_change_scheduler_act_set_t scheduler_act_set; /*!< Scheduler Action Set */
} esp_ble_mesh_time_scene_server_state_change_t;
/** Context of the received Scheduler Action Get message */
typedef struct {
uint8_t index; /*!< Index of the Schedule Register entry to get */
} esp_ble_mesh_server_recv_scheduler_act_get_t;
/**
* @brief Time Scene Server Model received get message union
*/
typedef union {
esp_ble_mesh_server_recv_scheduler_act_get_t scheduler_act; /*!< Scheduler Action Get */
} esp_ble_mesh_time_scene_server_recv_get_msg_t;
/** Context of the received Time Set message */
typedef struct {
uint8_t tai_seconds[5]; /*!< The current TAI time in seconds */
uint8_t subsecond; /*!< The sub-second time in units of 1/256 second */
uint8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */
uint16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */
uint16_t tai_utc_delta : 15; /*!< Current difference between TAI and UTC in seconds */
uint8_t time_zone_offset; /*!< The local time zone offset in 15-minute increments */
} esp_ble_mesh_server_recv_time_set_t;
/** Context of the received Time Zone Set message */
typedef struct {
uint8_t time_zone_offset_new; /*!< Upcoming local time zone offset */
uint8_t tai_zone_change[5]; /*!< TAI Seconds time of the upcoming Time Zone Offset change */
} esp_ble_mesh_server_recv_time_zone_set_t;
/** Context of the received TAI UTC Delta Set message */
typedef struct {
uint16_t tai_utc_delta_new : 15; /*!< Upcoming difference between TAI and UTC in seconds */
uint16_t padding : 1; /*!< Always 0b0. Other values are Prohibited. */
uint8_t tai_delta_change[5]; /*!< TAI Seconds time of the upcoming TAI-UTC Delta change */
} esp_ble_mesh_server_recv_tai_utc_delta_set_t;
/** Context of the received Time Role Set message */
typedef struct {
uint8_t time_role; /*!< The Time Role for the element */
} esp_ble_mesh_server_recv_time_role_set_t;
/** Context of the received Scene Store message */
typedef struct {
uint16_t scene_number; /*!< The number of scenes to be stored */
} esp_ble_mesh_server_recv_scene_store_t;
/** Context of the received Scene Recall message */
typedef struct {
bool op_en; /*!< Indicate if optional parameters are included */
uint16_t scene_number; /*!< The number of scenes to be recalled */
uint8_t tid; /*!< Transaction ID */
uint8_t trans_time; /*!< Time to complete state transition (optional) */
uint8_t delay; /*!< Indicate message execution delay (C.1) */
} esp_ble_mesh_server_recv_scene_recall_t;
/** Context of the received Scene Delete message */
typedef struct {
uint16_t scene_number; /*!< The number of scenes to be deleted */
} esp_ble_mesh_server_recv_scene_delete_t;
/** Context of the received Scheduler Action Set message */
typedef struct {
uint64_t index : 4; /*!< Index of the Schedule Register entry to set */
uint64_t year : 7; /*!< Scheduled year for the action */
uint64_t month : 12; /*!< Scheduled month for the action */
uint64_t day : 5; /*!< Scheduled day of the month for the action */
uint64_t hour : 5; /*!< Scheduled hour for the action */
uint64_t minute : 6; /*!< Scheduled minute for the action */
uint64_t second : 6; /*!< Scheduled second for the action */
uint64_t day_of_week : 7; /*!< Schedule days of the week for the action */
uint64_t action : 4; /*!< Action to be performed at the scheduled time */
uint64_t trans_time : 8; /*!< Transition time for this action */
uint16_t scene_number; /*!< Scene number to be used for some actions */
} esp_ble_mesh_server_recv_scheduler_act_set_t;
/**
* @brief Time Scene Server Model received set message union
*/
typedef union {
esp_ble_mesh_server_recv_time_set_t time; /*!< Time Set */
esp_ble_mesh_server_recv_time_zone_set_t time_zone; /*!< Time Zone Set */
esp_ble_mesh_server_recv_tai_utc_delta_set_t tai_utc_delta; /*!< TAI-UTC Delta Set */
esp_ble_mesh_server_recv_time_role_set_t time_role; /*!< Time Role Set */
esp_ble_mesh_server_recv_scene_store_t scene_store; /*!< Scene Store/Scene Store Unack */
esp_ble_mesh_server_recv_scene_recall_t scene_recall; /*!< Scene Recall/Scene Recall Unack */
esp_ble_mesh_server_recv_scene_delete_t scene_delete; /*!< Scene Delete/Scene Delete Unack */
esp_ble_mesh_server_recv_scheduler_act_set_t scheduler_act; /*!< Scheduler Action Set/Scheduler Action Set Unack */
} esp_ble_mesh_time_scene_server_recv_set_msg_t;
/** Context of the received Time Status message */
typedef struct {
uint8_t tai_seconds[5]; /*!< The current TAI time in seconds */
uint8_t subsecond; /*!< The sub-second time in units of 1/256 second */
uint8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */
uint16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */
uint16_t tai_utc_delta : 15; /*!< Current difference between TAI and UTC in seconds */
uint8_t time_zone_offset; /*!< The local time zone offset in 15-minute increments */
} esp_ble_mesh_server_recv_time_status_t;
/**
* @brief Time Scene Server Model received status message union
*/
typedef union {
esp_ble_mesh_server_recv_time_status_t time_status; /*!< Time Status */
} esp_ble_mesh_time_scene_server_recv_status_msg_t;
/**
* @brief Time Scene Server Model callback value union
*/
typedef union {
esp_ble_mesh_time_scene_server_state_change_t state_change; /*!< ESP_BLE_MESH_TIME_SCENE_SERVER_STATE_CHANGE_EVT */
esp_ble_mesh_time_scene_server_recv_get_msg_t get; /*!< ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_GET_MSG_EVT */
esp_ble_mesh_time_scene_server_recv_set_msg_t set; /*!< ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_SET_MSG_EVT */
esp_ble_mesh_time_scene_server_recv_status_msg_t status; /*!< ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_STATUS_MSG_EVT */
} esp_ble_mesh_time_scene_server_cb_value_t;
/** Time Scene Server Model callback parameters */
typedef struct {
esp_ble_mesh_model_t *model; /*!< Pointer to Time and Scenes Server Models */
esp_ble_mesh_msg_ctx_t ctx; /*!< Context of the received messages */
esp_ble_mesh_time_scene_server_cb_value_t value; /*!< Value of the received Time and Scenes Messages */
} esp_ble_mesh_time_scene_server_cb_param_t;
/** This enum value is the event of Time Scene Server Model */
typedef enum {
/**
* 1. When get_auto_rsp is set to ESP_BLE_MESH_SERVER_AUTO_RSP, no event will be
* callback to the application layer when Time Scene Get messages are received.
* 2. When set_auto_rsp is set to ESP_BLE_MESH_SERVER_AUTO_RSP, this event will
* be callback to the application layer when Time Scene Set/Set Unack messages
* are received.
*/
ESP_BLE_MESH_TIME_SCENE_SERVER_STATE_CHANGE_EVT,
/**
* When get_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, this event will be
* callback to the application layer when Time Scene Get messages are received.
*/
ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_GET_MSG_EVT,
/**
* When set_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, this event will be
* callback to the application layer when Time Scene Set/Set Unack messages are received.
*/
ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_SET_MSG_EVT,
/**
* When status_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, this event will
* be callback to the application layer when TIme Status message is received.
*/
ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_STATUS_MSG_EVT,
ESP_BLE_MESH_TIME_SCENE_SERVER_EVT_MAX,
} esp_ble_mesh_time_scene_server_cb_event_t;
/**
* @brief Bluetooth Mesh Time and Scenes Server Model function.
*/
/**
* @brief Time Scene Server Model callback function type
* @param event: Event type
* @param param: Pointer to callback parameter
*/
typedef void (* esp_ble_mesh_time_scene_server_cb_t)(esp_ble_mesh_time_scene_server_cb_event_t event,
esp_ble_mesh_time_scene_server_cb_param_t *param);
/**
* @brief Register BLE Mesh Time and Scenes Server Model callback.
*
* @param[in] callback: Pointer to the callback function.
*
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_register_time_scene_server_callback(esp_ble_mesh_time_scene_server_cb_t callback);
#ifdef __cplusplus
}
#endif
#endif /* _ESP_BLE_MESH_TIME_SCENE_MODEL_API_H_ */

File diff suppressed because it is too large Load Diff

View File

@ -15,19 +15,19 @@
#include <string.h>
#include <errno.h>
#include "btc/btc_manage.h"
#include "osi/allocator.h"
#include "cfg_cli.h"
#include "btc_ble_mesh_generic_model.h"
#include "generic_client.h"
#include "esp_ble_mesh_generic_model_api.h"
static inline void btc_ble_mesh_cb_to_app(esp_ble_mesh_generic_client_cb_event_t event,
esp_ble_mesh_generic_client_cb_param_t *param)
/* Generic Client Models related functions */
static inline void btc_ble_mesh_generic_client_cb_to_app(esp_ble_mesh_generic_client_cb_event_t event,
esp_ble_mesh_generic_client_cb_param_t *param)
{
esp_ble_mesh_generic_client_cb_t btc_mesh_cb = (esp_ble_mesh_generic_client_cb_t)btc_profile_cb_get(BTC_PID_GENERIC_CLIENT);
if (btc_mesh_cb) {
btc_mesh_cb(event, param);
esp_ble_mesh_generic_client_cb_t btc_ble_mesh_cb =
(esp_ble_mesh_generic_client_cb_t)btc_profile_cb_get(BTC_PID_GENERIC_CLIENT);
if (btc_ble_mesh_cb) {
btc_ble_mesh_cb(event, param);
}
}
@ -35,45 +35,50 @@ void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, voi
{
btc_ble_mesh_generic_client_args_t *dst = (btc_ble_mesh_generic_client_args_t *)p_dest;
btc_ble_mesh_generic_client_args_t *src = (btc_ble_mesh_generic_client_args_t *)p_src;
u32_t opcode;
u16_t length;
u16_t length = 0U;
if (!msg || !dst || !src) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (msg->act) {
case BTC_BLE_MESH_ACT_GENERIC_CLIENT_GET_STATE: {
dst->generic_client_get_state.params = (esp_ble_mesh_client_common_param_t *)osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
dst->generic_client_get_state.get_state = (esp_ble_mesh_generic_client_get_state_t *)osi_malloc(sizeof(esp_ble_mesh_generic_client_get_state_t));
if (dst->generic_client_get_state.params && dst->generic_client_get_state.get_state) {
dst->generic_client_get_state.params = (esp_ble_mesh_client_common_param_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (dst->generic_client_get_state.params) {
memcpy(dst->generic_client_get_state.params, src->generic_client_get_state.params,
sizeof(esp_ble_mesh_client_common_param_t));
memcpy(dst->generic_client_get_state.get_state, src->generic_client_get_state.get_state,
sizeof(esp_ble_mesh_generic_client_get_state_t));
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
break;
}
if (src->generic_client_get_state.get_state) {
dst->generic_client_get_state.get_state = (esp_ble_mesh_generic_client_get_state_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_generic_client_get_state_t));
if (dst->generic_client_get_state.get_state) {
memcpy(dst->generic_client_get_state.get_state, src->generic_client_get_state.get_state,
sizeof(esp_ble_mesh_generic_client_get_state_t));
} else {
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
}
}
break;
}
case BTC_BLE_MESH_ACT_GENERIC_CLIENT_SET_STATE: {
dst->generic_client_set_state.params = (esp_ble_mesh_client_common_param_t *)osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
dst->generic_client_set_state.set_state = (esp_ble_mesh_generic_client_set_state_t *)osi_malloc(sizeof(esp_ble_mesh_generic_client_set_state_t));
dst->generic_client_set_state.params = (esp_ble_mesh_client_common_param_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
dst->generic_client_set_state.set_state = (esp_ble_mesh_generic_client_set_state_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_generic_client_set_state_t));
if (dst->generic_client_set_state.params && dst->generic_client_set_state.set_state) {
memcpy(dst->generic_client_set_state.params, src->generic_client_set_state.params,
sizeof(esp_ble_mesh_client_common_param_t));
memcpy(dst->generic_client_set_state.set_state, src->generic_client_set_state.set_state,
sizeof(esp_ble_mesh_generic_client_set_state_t));
opcode = src->generic_client_set_state.params->opcode;
switch (opcode) {
switch (src->generic_client_set_state.params->opcode) {
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET:
if (src->generic_client_set_state.set_state->user_property_set.property_value) {
length = src->generic_client_set_state.set_state->user_property_set.property_value->len;
dst->generic_client_set_state.set_state->user_property_set.property_value = bt_mesh_alloc_buf(length);
if (!dst->generic_client_set_state.set_state->user_property_set.property_value) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(dst->generic_client_set_state.set_state->user_property_set.property_value,
@ -86,7 +91,7 @@ void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, voi
length = src->generic_client_set_state.set_state->admin_property_set.property_value->len;
dst->generic_client_set_state.set_state->admin_property_set.property_value = bt_mesh_alloc_buf(length);
if (!dst->generic_client_set_state.set_state->admin_property_set.property_value) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(dst->generic_client_set_state.set_state->admin_property_set.property_value,
@ -98,42 +103,95 @@ void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, voi
break;
}
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
}
break;
}
default:
LOG_DEBUG("%s, Unknown deep copy act %d", __func__, msg->act);
BT_DBG("%s, Unknown act %d", __func__, msg->act);
break;
}
}
static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
static void btc_ble_mesh_generic_client_arg_deep_free(btc_msg_t *msg)
{
btc_ble_mesh_generic_client_args_t *arg = NULL;
if (!msg || !msg->arg) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
arg = (btc_ble_mesh_generic_client_args_t *)(msg->arg);
switch (msg->act) {
case BTC_BLE_MESH_ACT_GENERIC_CLIENT_GET_STATE:
if (arg->generic_client_get_state.params) {
bt_mesh_free(arg->generic_client_get_state.params);
}
if (arg->generic_client_get_state.get_state) {
bt_mesh_free(arg->generic_client_get_state.get_state);
}
break;
case BTC_BLE_MESH_ACT_GENERIC_CLIENT_SET_STATE:
if (arg->generic_client_set_state.set_state) {
if (arg->generic_client_set_state.params) {
switch (arg->generic_client_set_state.params->opcode) {
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET:
bt_mesh_free_buf(arg->generic_client_set_state.set_state->user_property_set.property_value);
break;
case ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET:
bt_mesh_free_buf(arg->generic_client_set_state.set_state->admin_property_set.property_value);
break;
default:
break;
}
}
bt_mesh_free(arg->generic_client_set_state.set_state);
}
if (arg->generic_client_set_state.params) {
bt_mesh_free(arg->generic_client_set_state.params);
}
break;
default:
break;
}
}
static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
{
esp_ble_mesh_generic_client_cb_param_t *p_dest_data = (esp_ble_mesh_generic_client_cb_param_t *)p_dest;
esp_ble_mesh_generic_client_cb_param_t *p_src_data = (esp_ble_mesh_generic_client_cb_param_t *)p_src;
u32_t opcode;
u16_t length;
u16_t length = 0U;
if (!msg || !p_src_data || !p_dest_data) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
if (p_src_data->params) {
p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (!p_dest_data->params) {
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
}
switch (msg->act) {
case ESP_BLE_MESH_GENERIC_CLIENT_GET_STATE_EVT:
case ESP_BLE_MESH_GENERIC_CLIENT_SET_STATE_EVT:
case ESP_BLE_MESH_GENERIC_CLIENT_PUBLISH_EVT:
if (p_src_data->params) {
opcode = p_src_data->params->opcode;
switch (opcode) {
switch (p_src_data->params->opcode) {
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_GET:
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_STATUS:
if (p_src_data->status_cb.user_properties_status.property_ids) {
length = p_src_data->status_cb.user_properties_status.property_ids->len;
p_dest_data->status_cb.user_properties_status.property_ids = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.user_properties_status.property_ids) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.user_properties_status.property_ids,
@ -148,7 +206,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
length = p_src_data->status_cb.user_property_status.property_value->len;
p_dest_data->status_cb.user_property_status.property_value = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.user_property_status.property_value) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.user_property_status.property_value,
@ -162,7 +220,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
length = p_src_data->status_cb.admin_properties_status.property_ids->len;
p_dest_data->status_cb.admin_properties_status.property_ids = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.admin_properties_status.property_ids) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.admin_properties_status.property_ids,
@ -177,7 +235,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
length = p_src_data->status_cb.admin_property_status.property_value->len;
p_dest_data->status_cb.admin_property_status.property_value = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.admin_property_status.property_value) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.admin_property_status.property_value,
@ -191,7 +249,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
length = p_src_data->status_cb.manufacturer_properties_status.property_ids->len;
p_dest_data->status_cb.manufacturer_properties_status.property_ids = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.manufacturer_properties_status.property_ids) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.manufacturer_properties_status.property_ids,
@ -206,7 +264,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
length = p_src_data->status_cb.manufacturer_property_status.property_value->len;
p_dest_data->status_cb.manufacturer_property_status.property_value = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.manufacturer_property_status.property_value) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.manufacturer_property_status.property_value,
@ -220,7 +278,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
length = p_src_data->status_cb.client_properties_status.property_ids->len;
p_dest_data->status_cb.client_properties_status.property_ids = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.client_properties_status.property_ids) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.client_properties_status.property_ids,
@ -233,27 +291,18 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
}
}
case ESP_BLE_MESH_GENERIC_CLIENT_TIMEOUT_EVT:
if (p_src_data->params) {
p_dest_data->params = osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (p_dest_data->params) {
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
}
break;
default:
break;
}
}
static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
static void btc_ble_mesh_generic_client_free_req_data(btc_msg_t *msg)
{
esp_ble_mesh_generic_client_cb_param_t *arg = NULL;
u32_t opcode;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -264,8 +313,7 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
case ESP_BLE_MESH_GENERIC_CLIENT_SET_STATE_EVT:
case ESP_BLE_MESH_GENERIC_CLIENT_PUBLISH_EVT:
if (arg->params) {
opcode = arg->params->opcode;
switch (opcode) {
switch (arg->params->opcode) {
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_GET:
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_STATUS:
bt_mesh_free_buf(arg->status_cb.user_properties_status.property_ids);
@ -303,7 +351,7 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
}
case ESP_BLE_MESH_GENERIC_CLIENT_TIMEOUT_EVT:
if (arg->params) {
osi_free(arg->params);
bt_mesh_free(arg->params);
}
break;
default:
@ -311,99 +359,54 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
}
}
void btc_ble_mesh_generic_client_arg_deep_free(btc_msg_t *msg)
{
btc_ble_mesh_generic_client_args_t *arg = NULL;
u32_t opcode = 0;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
arg = (btc_ble_mesh_generic_client_args_t *)(msg->arg);
switch (msg->act) {
case BTC_BLE_MESH_ACT_GENERIC_CLIENT_GET_STATE:
if (arg->generic_client_get_state.params) {
osi_free(arg->generic_client_get_state.params);
}
if (arg->generic_client_get_state.get_state) {
osi_free(arg->generic_client_get_state.get_state);
}
break;
case BTC_BLE_MESH_ACT_GENERIC_CLIENT_SET_STATE:
if (arg->generic_client_set_state.params) {
opcode = arg->generic_client_set_state.params->opcode;
osi_free(arg->generic_client_set_state.params);
}
if (arg->generic_client_set_state.set_state) {
if (opcode) {
switch (opcode) {
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET:
bt_mesh_free_buf(arg->generic_client_set_state.set_state->user_property_set.property_value);
break;
case ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET:
bt_mesh_free_buf(arg->generic_client_set_state.set_state->admin_property_set.property_value);
break;
default:
break;
}
}
osi_free(arg->generic_client_set_state.set_state);
}
break;
default:
break;
}
return;
}
static void btc_mesh_generic_client_callback(esp_ble_mesh_generic_client_cb_param_t *cb_params, uint8_t act)
static void btc_ble_mesh_generic_client_callback(esp_ble_mesh_generic_client_cb_param_t *cb_params, uint8_t act)
{
btc_msg_t msg = {0};
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
/* If corresponding callback is not registered, event will not be posted. */
if (!btc_profile_cb_get(BTC_PID_GENERIC_CLIENT)) {
return;
}
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_GENERIC_CLIENT;
msg.act = act;
btc_transfer_context(&msg, cb_params,
sizeof(esp_ble_mesh_generic_client_cb_param_t), btc_ble_mesh_copy_req_data);
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_generic_client_cb_param_t),
btc_ble_mesh_generic_client_copy_req_data);
}
void bt_mesh_callback_generic_status_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len)
void bt_mesh_generic_client_cb_evt_to_btc(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)
{
esp_ble_mesh_generic_client_cb_param_t cb_params = {0};
esp_ble_mesh_client_common_param_t params = {0};
size_t length;
uint8_t act;
uint8_t act = 0U;
if (!model || !ctx) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (evt_type) {
case 0x00:
case BTC_BLE_MESH_EVT_GENERIC_CLIENT_GET_STATE:
act = ESP_BLE_MESH_GENERIC_CLIENT_GET_STATE_EVT;
break;
case 0x01:
case BTC_BLE_MESH_EVT_GENERIC_CLIENT_SET_STATE:
act = ESP_BLE_MESH_GENERIC_CLIENT_SET_STATE_EVT;
break;
case 0x02:
case BTC_BLE_MESH_EVT_GENERIC_CLIENT_PUBLISH:
act = ESP_BLE_MESH_GENERIC_CLIENT_PUBLISH_EVT;
break;
case 0x03:
case BTC_BLE_MESH_EVT_GENERIC_CLIENT_TIMEOUT:
act = ESP_BLE_MESH_GENERIC_CLIENT_TIMEOUT_EVT;
break;
default:
LOG_ERROR("%s, Unknown generic client event type %d", __func__, evt_type);
BT_ERR("Unknown Generic client event type %d", evt_type);
return;
}
@ -415,39 +418,43 @@ void bt_mesh_callback_generic_status_to_btc(u32_t opcode, u8_t evt_type,
params.ctx.recv_ttl = ctx->recv_ttl;
params.ctx.recv_op = ctx->recv_op;
params.ctx.recv_dst = ctx->recv_dst;
params.ctx.recv_rssi = ctx->recv_rssi;
params.ctx.send_ttl = ctx->send_ttl;
cb_params.error_code = 0;
cb_params.params = &params;
if (val && len) {
length = (len <= sizeof(cb_params.status_cb)) ? len : sizeof(cb_params.status_cb);
memcpy(&cb_params.status_cb, val, length);
memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb)));
}
btc_mesh_generic_client_callback(&cb_params, act);
btc_ble_mesh_generic_client_callback(&cb_params, act);
return;
}
void btc_mesh_generic_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf)
void btc_ble_mesh_generic_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
if (!model || !ctx || !buf) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
bt_mesh_callback_generic_status_to_btc(opcode, 0x02, model, ctx, buf->data, buf->len);
bt_mesh_generic_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_GENERIC_CLIENT_PUBLISH,
model, ctx, buf->data, buf->len);
return;
}
void btc_mesh_generic_client_call_handler(btc_msg_t *msg)
void btc_ble_mesh_generic_client_call_handler(btc_msg_t *msg)
{
esp_ble_mesh_generic_client_cb_param_t generic_client_cb = {0};
esp_ble_mesh_client_common_param_t *params = NULL;
btc_ble_mesh_generic_client_args_t *arg = NULL;
struct bt_mesh_common_param common = {0};
bt_mesh_role_param_t role_param = {0};
esp_ble_mesh_generic_client_cb_param_t cb = {0};
bt_mesh_client_common_param_t common = {0};
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -456,12 +463,6 @@ void btc_mesh_generic_client_call_handler(btc_msg_t *msg)
switch (msg->act) {
case BTC_BLE_MESH_ACT_GENERIC_CLIENT_GET_STATE: {
params = arg->generic_client_get_state.params;
role_param.model = (struct bt_mesh_model *)params->model;
role_param.role = params->msg_role;
if (bt_mesh_set_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
return;
}
common.opcode = params->opcode;
common.model = (struct bt_mesh_model *)params->model;
common.ctx.net_idx = params->ctx.net_idx;
@ -470,27 +471,18 @@ void btc_mesh_generic_client_call_handler(btc_msg_t *msg)
common.ctx.send_rel = params->ctx.send_rel;
common.ctx.send_ttl = params->ctx.send_ttl;
common.msg_timeout = params->msg_timeout;
common.msg_role = params->msg_role;
generic_client_cb.params = arg->generic_client_get_state.params;
generic_client_cb.error_code =
bt_mesh_generic_client_get_state(&common,
(void *)arg->generic_client_get_state.get_state,
(void *)&generic_client_cb.status_cb);
if (generic_client_cb.error_code) {
cb.params = arg->generic_client_get_state.params;
cb.error_code = bt_mesh_generic_client_get_state(&common, arg->generic_client_get_state.get_state);
if (cb.error_code) {
/* If send failed, callback error_code to app layer immediately */
btc_mesh_generic_client_callback(&generic_client_cb,
ESP_BLE_MESH_GENERIC_CLIENT_GET_STATE_EVT);
btc_ble_mesh_generic_client_callback(&cb, ESP_BLE_MESH_GENERIC_CLIENT_GET_STATE_EVT);
}
break;
}
case BTC_BLE_MESH_ACT_GENERIC_CLIENT_SET_STATE: {
params = arg->generic_client_set_state.params;
role_param.model = (struct bt_mesh_model *)params->model;
role_param.role = params->msg_role;
if (bt_mesh_set_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
return;
}
common.opcode = params->opcode;
common.model = (struct bt_mesh_model *)params->model;
common.ctx.net_idx = params->ctx.net_idx;
@ -499,16 +491,13 @@ void btc_mesh_generic_client_call_handler(btc_msg_t *msg)
common.ctx.send_rel = params->ctx.send_rel;
common.ctx.send_ttl = params->ctx.send_ttl;
common.msg_timeout = params->msg_timeout;
common.msg_role = params->msg_role;
generic_client_cb.params = arg->generic_client_set_state.params;
generic_client_cb.error_code =
bt_mesh_generic_client_set_state(&common,
(void *)arg->generic_client_set_state.set_state,
(void *)&generic_client_cb.status_cb);
if (generic_client_cb.error_code) {
cb.params = arg->generic_client_set_state.params;
cb.error_code = bt_mesh_generic_client_set_state(&common, arg->generic_client_set_state.set_state);
if (cb.error_code) {
/* If send failed, callback error_code to app layer immediately */
btc_mesh_generic_client_callback(&generic_client_cb,
ESP_BLE_MESH_GENERIC_CLIENT_SET_STATE_EVT);
btc_ble_mesh_generic_client_callback(&cb, ESP_BLE_MESH_GENERIC_CLIENT_SET_STATE_EVT);
}
break;
}
@ -517,24 +506,253 @@ void btc_mesh_generic_client_call_handler(btc_msg_t *msg)
}
btc_ble_mesh_generic_client_arg_deep_free(msg);
return;
}
void btc_mesh_generic_client_cb_handler(btc_msg_t *msg)
void btc_ble_mesh_generic_client_cb_handler(btc_msg_t *msg)
{
esp_ble_mesh_generic_client_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
param = (esp_ble_mesh_generic_client_cb_param_t *)(msg->arg);
if (msg->act < ESP_BLE_MESH_GENERIC_CLIENT_EVT_MAX) {
btc_ble_mesh_cb_to_app(msg->act, param);
btc_ble_mesh_generic_client_cb_to_app(msg->act, param);
} else {
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
BT_ERR("%s, Unknown act %d", __func__, msg->act);
}
btc_ble_mesh_free_req_data(msg);
btc_ble_mesh_generic_client_free_req_data(msg);
return;
}
/* Generic Server Models related functions */
static inline void btc_ble_mesh_generic_server_cb_to_app(esp_ble_mesh_generic_server_cb_event_t event,
esp_ble_mesh_generic_server_cb_param_t *param)
{
esp_ble_mesh_generic_server_cb_t btc_ble_mesh_cb =
(esp_ble_mesh_generic_server_cb_t)btc_profile_cb_get(BTC_PID_GENERIC_SERVER);
if (btc_ble_mesh_cb) {
btc_ble_mesh_cb(event, param);
}
}
static void btc_ble_mesh_generic_server_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
{
esp_ble_mesh_generic_server_cb_param_t *p_dest_data = (esp_ble_mesh_generic_server_cb_param_t *)p_dest;
esp_ble_mesh_generic_server_cb_param_t *p_src_data = (esp_ble_mesh_generic_server_cb_param_t *)p_src;
u16_t length = 0U;
if (!msg || !p_src_data || !p_dest_data) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (msg->act) {
case ESP_BLE_MESH_GENERIC_SERVER_STATE_CHANGE_EVT:
switch (p_src_data->ctx.recv_op) {
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET:
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET_UNACK:
if (p_src_data->value.state_change.user_property_set.value) {
length = p_src_data->value.state_change.user_property_set.value->len;
p_dest_data->value.state_change.user_property_set.value = bt_mesh_alloc_buf(length);
if (p_dest_data->value.state_change.user_property_set.value == NULL) {
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.state_change.user_property_set.value,
p_src_data->value.state_change.user_property_set.value->data,
p_src_data->value.state_change.user_property_set.value->len);
}
break;
case ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET:
case ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET_UNACK:
if (p_src_data->value.state_change.admin_property_set.value) {
length = p_src_data->value.state_change.admin_property_set.value->len;
p_dest_data->value.state_change.admin_property_set.value = bt_mesh_alloc_buf(length);
if (p_dest_data->value.state_change.admin_property_set.value == NULL) {
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.state_change.admin_property_set.value,
p_src_data->value.state_change.admin_property_set.value->data,
p_src_data->value.state_change.admin_property_set.value->len);
}
break;
default:
break;
}
break;
case ESP_BLE_MESH_GENERIC_SERVER_RECV_SET_MSG_EVT:
switch (p_src_data->ctx.recv_op) {
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET:
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET_UNACK:
if (p_src_data->value.set.user_property.property_value) {
length = p_src_data->value.set.user_property.property_value->len;
p_dest_data->value.set.user_property.property_value = bt_mesh_alloc_buf(length);
if (p_dest_data->value.set.user_property.property_value == NULL) {
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.set.user_property.property_value,
p_src_data->value.set.user_property.property_value->data,
p_src_data->value.set.user_property.property_value->len);
}
break;
case ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET:
case ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET_UNACK:
if (p_src_data->value.set.admin_property.property_value) {
length = p_src_data->value.set.admin_property.property_value->len;
p_dest_data->value.set.admin_property.property_value = bt_mesh_alloc_buf(length);
if (p_dest_data->value.set.admin_property.property_value == NULL) {
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.set.admin_property.property_value,
p_src_data->value.set.admin_property.property_value->data,
p_src_data->value.set.admin_property.property_value->len);
}
break;
default:
break;
}
break;
default:
break;
}
}
static void btc_ble_mesh_generic_server_free_req_data(btc_msg_t *msg)
{
esp_ble_mesh_generic_server_cb_param_t *arg = NULL;
if (!msg || !msg->arg) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
arg = (esp_ble_mesh_generic_server_cb_param_t *)(msg->arg);
switch (msg->act) {
case ESP_BLE_MESH_GENERIC_SERVER_STATE_CHANGE_EVT:
switch (arg->ctx.recv_op) {
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET:
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET_UNACK:
bt_mesh_free_buf(arg->value.state_change.user_property_set.value);
break;
case ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET:
case ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET_UNACK:
bt_mesh_free_buf(arg->value.state_change.admin_property_set.value);
break;
default:
break;
}
break;
case ESP_BLE_MESH_GENERIC_SERVER_RECV_SET_MSG_EVT:
switch (arg->ctx.recv_op) {
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET:
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET_UNACK:
bt_mesh_free_buf(arg->value.set.user_property.property_value);
break;
case ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET:
case ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET_UNACK:
bt_mesh_free_buf(arg->value.set.admin_property.property_value);
break;
default:
break;
}
break;
default:
break;
}
}
static void btc_ble_mesh_generic_server_callback(esp_ble_mesh_generic_server_cb_param_t *cb_params, uint8_t act)
{
btc_msg_t msg = {0};
BT_DBG("%s", __func__);
/* If corresponding callback is not registered, event will not be posted. */
if (!btc_profile_cb_get(BTC_PID_GENERIC_SERVER)) {
return;
}
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_GENERIC_SERVER;
msg.act = act;
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_generic_server_cb_param_t),
btc_ble_mesh_generic_server_copy_req_data);
}
void bt_mesh_generic_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len)
{
esp_ble_mesh_generic_server_cb_param_t cb_params = {0};
uint8_t act = 0U;
if (model == NULL || ctx == NULL) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (evt_type) {
case BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE:
act = ESP_BLE_MESH_GENERIC_SERVER_STATE_CHANGE_EVT;
break;
case BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_GET_MSG:
act = ESP_BLE_MESH_GENERIC_SERVER_RECV_GET_MSG_EVT;
break;
case BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_SET_MSG:
act = ESP_BLE_MESH_GENERIC_SERVER_RECV_SET_MSG_EVT;
break;
default:
BT_ERR("Unknown Generic Server event type %d", evt_type);
return;
}
cb_params.model = (esp_ble_mesh_model_t *)model;
cb_params.ctx.net_idx = ctx->net_idx;
cb_params.ctx.app_idx = ctx->app_idx;
cb_params.ctx.addr = ctx->addr;
cb_params.ctx.recv_ttl = ctx->recv_ttl;
cb_params.ctx.recv_op = ctx->recv_op;
cb_params.ctx.recv_dst = ctx->recv_dst;
cb_params.ctx.recv_rssi = ctx->recv_rssi;
cb_params.ctx.send_ttl = ctx->send_ttl;
if (val && len) {
memcpy(&cb_params.value, val, MIN(len, sizeof(cb_params.value)));
}
btc_ble_mesh_generic_server_callback(&cb_params, act);
return;
}
void btc_ble_mesh_generic_server_cb_handler(btc_msg_t *msg)
{
esp_ble_mesh_generic_server_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
param = (esp_ble_mesh_generic_server_cb_param_t *)(msg->arg);
if (msg->act < ESP_BLE_MESH_GENERIC_SERVER_EVT_MAX) {
btc_ble_mesh_generic_server_cb_to_app(msg->act, param);
} else {
BT_ERR("%s, Unknown act %d", __func__, msg->act);
}
btc_ble_mesh_generic_server_free_req_data(msg);
return;
}

View File

@ -15,34 +15,21 @@
#include <string.h>
#include <errno.h>
#include "btc/btc_manage.h"
#include "btc/btc_task.h"
#include "osi/allocator.h"
#include "btc_ble_mesh_health_model.h"
#include "foundation.h"
#include "health_srv.h"
#include "health_cli.h"
#include "mesh_common.h"
#include "esp_ble_mesh_health_model_api.h"
#include "btc_ble_mesh_health_model.h"
#include "esp_ble_mesh_defs.h"
extern s32_t health_msg_timeout;
/* Health Client Model related functions */
static inline void btc_ble_mesh_health_client_cb_to_app(esp_ble_mesh_health_client_cb_event_t event,
esp_ble_mesh_health_client_cb_param_t *param)
esp_ble_mesh_health_client_cb_param_t *param)
{
esp_ble_mesh_health_client_cb_t btc_mesh_cb = (esp_ble_mesh_health_client_cb_t)btc_profile_cb_get(BTC_PID_HEALTH_CLIENT);
if (btc_mesh_cb) {
btc_mesh_cb(event, param);
}
}
static inline void btc_ble_mesh_health_server_cb_to_app(esp_ble_mesh_health_server_cb_event_t event,
esp_ble_mesh_health_server_cb_param_t *param)
{
esp_ble_mesh_health_server_cb_t btc_mesh_cb = (esp_ble_mesh_health_server_cb_t)btc_profile_cb_get(BTC_PID_HEALTH_SERVER);
if (btc_mesh_cb) {
btc_mesh_cb(event, param);
esp_ble_mesh_health_client_cb_t btc_ble_mesh_cb =
(esp_ble_mesh_health_client_cb_t)btc_profile_cb_get(BTC_PID_HEALTH_CLIENT);
if (btc_ble_mesh_cb) {
btc_ble_mesh_cb(event, param);
}
}
@ -52,39 +39,46 @@ void btc_ble_mesh_health_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
btc_ble_mesh_health_client_args_t *src = (btc_ble_mesh_health_client_args_t *)p_src;
if (!msg || !dst || !src) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (msg->act) {
case BTC_BLE_MESH_ACT_HEALTH_CLIENT_GET_STATE: {
dst->health_client_get_state.params = (esp_ble_mesh_client_common_param_t *)osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
dst->health_client_get_state.get_state = (esp_ble_mesh_health_client_get_state_t *)osi_malloc(sizeof(esp_ble_mesh_health_client_get_state_t));
if (dst->health_client_get_state.params && dst->health_client_get_state.get_state) {
dst->health_client_get_state.params = (esp_ble_mesh_client_common_param_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (dst->health_client_get_state.params) {
memcpy(dst->health_client_get_state.params, src->health_client_get_state.params,
sizeof(esp_ble_mesh_client_common_param_t));
memcpy(dst->health_client_get_state.get_state, src->health_client_get_state.get_state,
sizeof(esp_ble_mesh_health_client_get_state_t));
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
break;
}
if (src->health_client_get_state.get_state) {
dst->health_client_get_state.get_state = (esp_ble_mesh_health_client_get_state_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_health_client_get_state_t));
if (dst->health_client_get_state.get_state) {
memcpy(dst->health_client_get_state.get_state, src->health_client_get_state.get_state,
sizeof(esp_ble_mesh_health_client_get_state_t));
} else {
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
}
}
break;
}
case BTC_BLE_MESH_ACT_HEALTH_CLIENT_SET_STATE: {
dst->health_client_set_state.params = (esp_ble_mesh_client_common_param_t *)osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
dst->health_client_set_state.set_state = (esp_ble_mesh_health_client_set_state_t *)osi_malloc(sizeof(esp_ble_mesh_health_client_set_state_t));
dst->health_client_set_state.params = (esp_ble_mesh_client_common_param_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
dst->health_client_set_state.set_state = (esp_ble_mesh_health_client_set_state_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_health_client_set_state_t));
if (dst->health_client_set_state.params && dst->health_client_set_state.set_state) {
memcpy(dst->health_client_set_state.params, src->health_client_set_state.params,
sizeof(esp_ble_mesh_client_common_param_t));
memcpy(dst->health_client_set_state.set_state, src->health_client_set_state.set_state,
sizeof(esp_ble_mesh_health_client_set_state_t));
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
}
break;
}
default:
LOG_DEBUG("%s, Unknown deep copy act %d", __func__, msg->act);
BT_DBG("%s, Unknown act %d", __func__, msg->act);
break;
}
}
@ -94,7 +88,7 @@ static void btc_ble_mesh_health_client_arg_deep_free(btc_msg_t *msg)
btc_ble_mesh_health_client_args_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -103,82 +97,58 @@ static void btc_ble_mesh_health_client_arg_deep_free(btc_msg_t *msg)
switch (msg->act) {
case BTC_BLE_MESH_ACT_HEALTH_CLIENT_GET_STATE:
if (arg->health_client_get_state.params) {
osi_free(arg->health_client_get_state.params);
bt_mesh_free(arg->health_client_get_state.params);
}
if (arg->health_client_get_state.get_state) {
osi_free(arg->health_client_get_state.get_state);
bt_mesh_free(arg->health_client_get_state.get_state);
}
break;
case BTC_BLE_MESH_ACT_HEALTH_CLIENT_SET_STATE:
if (arg->health_client_set_state.params) {
osi_free(arg->health_client_set_state.params);
bt_mesh_free(arg->health_client_set_state.params);
}
if (arg->health_client_set_state.set_state) {
osi_free(arg->health_client_set_state.set_state);
bt_mesh_free(arg->health_client_set_state.set_state);
}
break;
default:
break;
}
return;
}
void btc_ble_mesh_health_server_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
{
if (!msg) {
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
switch (msg->act) {
case BTC_BLE_MESH_ACT_HEALTH_SERVER_FAULT_UPDATE:
break;
default:
break;
}
}
static void btc_ble_mesh_health_server_arg_deep_free(btc_msg_t *msg)
{
if (!msg) {
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
switch (msg->act) {
case BTC_BLE_MESH_ACT_HEALTH_SERVER_FAULT_UPDATE:
break;
default:
break;
}
}
static void btc_ble_mesh_health_client_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
{
esp_ble_mesh_health_client_cb_param_t *p_dest_data = (esp_ble_mesh_health_client_cb_param_t *)p_dest;
esp_ble_mesh_health_client_cb_param_t *p_src_data = (esp_ble_mesh_health_client_cb_param_t *)p_src;
u32_t opcode;
u16_t length;
u16_t length = 0U;
if (!msg || !p_src_data || !p_dest_data) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
if (p_src_data->params) {
p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (!p_dest_data->params) {
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
}
switch (msg->act) {
case ESP_BLE_MESH_HEALTH_CLIENT_GET_STATE_EVT:
case ESP_BLE_MESH_HEALTH_CLIENT_SET_STATE_EVT:
case ESP_BLE_MESH_HEALTH_CLIENT_PUBLISH_EVT:
if (p_src_data->params) {
opcode = p_src_data->params->opcode;
switch (opcode) {
switch (p_src_data->params->opcode) {
case OP_HEALTH_CURRENT_STATUS:
if (p_src_data->status_cb.current_status.fault_array) {
length = p_src_data->status_cb.current_status.fault_array->len;
p_dest_data->status_cb.current_status.fault_array = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.current_status.fault_array) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.current_status.fault_array,
@ -194,7 +164,7 @@ static void btc_ble_mesh_health_client_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->status_cb.fault_status.fault_array->len;
p_dest_data->status_cb.fault_status.fault_array = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.fault_status.fault_array) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.fault_status.fault_array,
@ -207,14 +177,6 @@ static void btc_ble_mesh_health_client_copy_req_data(btc_msg_t *msg, void *p_des
}
}
case ESP_BLE_MESH_HEALTH_CLIENT_TIMEOUT_EVT:
if (p_src_data->params) {
p_dest_data->params = osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (p_dest_data->params) {
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
}
break;
default:
break;
@ -224,10 +186,9 @@ static void btc_ble_mesh_health_client_copy_req_data(btc_msg_t *msg, void *p_des
static void btc_ble_mesh_health_client_free_req_data(btc_msg_t *msg)
{
esp_ble_mesh_health_client_cb_param_t *arg = NULL;
u32_t opcode;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -238,8 +199,7 @@ static void btc_ble_mesh_health_client_free_req_data(btc_msg_t *msg)
case ESP_BLE_MESH_HEALTH_CLIENT_SET_STATE_EVT:
case ESP_BLE_MESH_HEALTH_CLIENT_PUBLISH_EVT:
if (arg->params) {
opcode = arg->params->opcode;
switch (opcode) {
switch (arg->params->opcode) {
case OP_HEALTH_CURRENT_STATUS:
bt_mesh_free_buf(arg->status_cb.current_status.fault_array);
break;
@ -255,7 +215,7 @@ static void btc_ble_mesh_health_client_free_req_data(btc_msg_t *msg)
}
case ESP_BLE_MESH_HEALTH_CLIENT_TIMEOUT_EVT:
if (arg->params) {
osi_free(arg->params);
bt_mesh_free(arg->params);
}
break;
default:
@ -263,180 +223,54 @@ static void btc_ble_mesh_health_client_free_req_data(btc_msg_t *msg)
}
}
static void btc_ble_mesh_health_server_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
{
if (!msg) {
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
switch (msg->act) {
case ESP_BLE_MESH_HEALTH_SERVER_FAULT_UPDATE_COMPLETE_EVT:
break;
default:
break;
}
}
static void btc_ble_mesh_health_server_free_req_data(btc_msg_t *msg)
{
if (!msg) {
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
switch (msg->act) {
case ESP_BLE_MESH_HEALTH_SERVER_FAULT_UPDATE_COMPLETE_EVT:
break;
default:
break;
}
}
static void btc_mesh_health_client_callback(esp_ble_mesh_health_client_cb_param_t *cb_params, uint8_t act)
static void btc_ble_mesh_health_client_callback(esp_ble_mesh_health_client_cb_param_t *cb_params, uint8_t act)
{
btc_msg_t msg = {0};
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
/* If corresponding callback is not registered, event will not be posted. */
if (!btc_profile_cb_get(BTC_PID_HEALTH_CLIENT)) {
return;
}
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_HEALTH_CLIENT;
msg.act = act;
btc_transfer_context(&msg, cb_params,
sizeof(esp_ble_mesh_health_client_cb_param_t), btc_ble_mesh_health_client_copy_req_data);
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_health_client_cb_param_t),
btc_ble_mesh_health_client_copy_req_data);
}
static void btc_mesh_health_server_callback(esp_ble_mesh_health_server_cb_param_t *cb_params, uint8_t act)
{
btc_msg_t msg = {0};
LOG_DEBUG("%s", __func__);
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_HEALTH_SERVER;
msg.act = act;
btc_transfer_context(&msg, cb_params,
sizeof(esp_ble_mesh_health_server_cb_param_t), btc_ble_mesh_health_server_copy_req_data);
}
int btc_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_health_client_get_state_t *get_state,
esp_ble_mesh_health_client_cb_param_t *client_cb)
{
struct bt_mesh_msg_ctx ctx = {0};
if (!params || !client_cb) {
LOG_ERROR("%s, Invalid parameter", __func__);
return -EINVAL;
}
ctx.net_idx = params->ctx.net_idx;
ctx.app_idx = params->ctx.app_idx;
ctx.addr = params->ctx.addr;
ctx.send_rel = params->ctx.send_rel;
ctx.send_ttl = params->ctx.send_ttl;
health_msg_timeout = params->msg_timeout;
switch (params->opcode) {
case ESP_BLE_MESH_MODEL_OP_ATTENTION_GET:
return (client_cb->error_code = bt_mesh_health_attention_get(&ctx));
case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_GET:
return (client_cb->error_code = bt_mesh_health_period_get(&ctx));
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET:
return (client_cb->error_code = bt_mesh_health_fault_get(&ctx, get_state->fault_get.company_id));
default:
BT_WARN("%s, invalid opcode 0x%x", __func__, params->opcode);
return (client_cb->error_code = -EINVAL);
}
return 0;
}
int btc_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_health_client_set_state_t *set_state,
esp_ble_mesh_health_client_cb_param_t *client_cb)
{
struct bt_mesh_msg_ctx ctx = {0};
if (!params || !set_state || !client_cb) {
LOG_ERROR("%s, Invalid parameter", __func__);
return -EINVAL;
}
ctx.net_idx = params->ctx.net_idx;
ctx.app_idx = params->ctx.app_idx;
ctx.addr = params->ctx.addr;
ctx.send_rel = params->ctx.send_rel;
ctx.send_ttl = params->ctx.send_ttl;
health_msg_timeout = params->msg_timeout;
switch (params->opcode) {
case ESP_BLE_MESH_MODEL_OP_ATTENTION_SET:
return (client_cb->error_code =
bt_mesh_health_attention_set(&ctx, set_state->attention_set.attention, true));
case ESP_BLE_MESH_MODEL_OP_ATTENTION_SET_UNACK:
return (client_cb->error_code =
bt_mesh_health_attention_set(&ctx, set_state->attention_set.attention, false));
case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET:
return (client_cb->error_code =
bt_mesh_health_period_set(&ctx, set_state->period_set.fast_period_divisor, true));
case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET_UNACK:
return (client_cb->error_code =
bt_mesh_health_period_set(&ctx, set_state->period_set.fast_period_divisor, false));
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST:
return (client_cb->error_code =
bt_mesh_health_fault_test(&ctx, set_state->fault_test.company_id, set_state->fault_test.test_id, true));
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST_UNACK:
return (client_cb->error_code =
bt_mesh_health_fault_test(&ctx, set_state->fault_test.company_id, set_state->fault_test.test_id, false));
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR:
return (client_cb->error_code =
bt_mesh_health_fault_clear(&ctx, set_state->fault_clear.company_id, true));
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR_UNACK:
return (client_cb->error_code =
bt_mesh_health_fault_clear(&ctx, set_state->fault_clear.company_id, false));
default:
BT_WARN("%s, Invalid opcode 0x%x", __func__, params->opcode);
return (client_cb->error_code = -EINVAL);
}
return 0;
}
void bt_mesh_callback_health_status_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, u16_t len)
void bt_mesh_health_client_cb_evt_to_btc(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)
{
esp_ble_mesh_health_client_cb_param_t cb_params = {0};
esp_ble_mesh_client_common_param_t params = {0};
size_t length;
uint8_t act;
uint8_t act = 0U;
if (!model || !ctx) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (evt_type) {
case 0x00:
case BTC_BLE_MESH_EVT_HEALTH_CLIENT_GET_STATE:
act = ESP_BLE_MESH_HEALTH_CLIENT_GET_STATE_EVT;
break;
case 0x01:
case BTC_BLE_MESH_EVT_HEALTH_CLIENT_SET_STATE:
act = ESP_BLE_MESH_HEALTH_CLIENT_SET_STATE_EVT;
break;
case 0x02:
case BTC_BLE_MESH_EVT_HEALTH_CLIENT_PUBLISH:
act = ESP_BLE_MESH_HEALTH_CLIENT_PUBLISH_EVT;
break;
case 0x03:
case BTC_BLE_MESH_EVT_HEALTH_CLIENT_TIMEOUT:
act = ESP_BLE_MESH_HEALTH_CLIENT_TIMEOUT_EVT;
break;
default:
LOG_ERROR("%s, Unknown health client event type %d", __func__, evt_type);
BT_ERR("Unknown Health client event type %d", evt_type);
return;
}
@ -448,37 +282,126 @@ void bt_mesh_callback_health_status_to_btc(u32_t opcode, u8_t evt_type,
params.ctx.recv_ttl = ctx->recv_ttl;
params.ctx.recv_op = ctx->recv_op;
params.ctx.recv_dst = ctx->recv_dst;
params.ctx.recv_rssi = ctx->recv_rssi;
params.ctx.send_ttl = ctx->send_ttl;
cb_params.error_code = 0;
cb_params.params = &params;
if (val && len) {
length = (len <= sizeof(cb_params.status_cb)) ? len : sizeof(cb_params.status_cb);
memcpy(&cb_params.status_cb, val, length);
memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb)));
}
btc_mesh_health_client_callback(&cb_params, act);
btc_ble_mesh_health_client_callback(&cb_params, act);
return;
}
void btc_mesh_health_publish_callback(u32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf)
void btc_ble_mesh_health_publish_callback(u32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
if (!model || !ctx || !buf) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
bt_mesh_callback_health_status_to_btc(opcode, 0x02, model, ctx, buf->data, buf->len);
bt_mesh_health_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_HEALTH_CLIENT_PUBLISH,
model, ctx, buf->data, buf->len);
return;
}
void btc_mesh_health_client_call_handler(btc_msg_t *msg)
static int btc_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_health_client_get_state_t *get)
{
bt_mesh_client_common_param_t param = {0};
if (params == NULL) {
BT_ERR("%s, Invalid parameter", __func__);
return -EINVAL;
}
if (params->opcode == ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET && get == NULL) {
BT_ERR("Invalid Health Get");
return -EINVAL;
}
param.opcode = params->opcode;
param.model = (struct bt_mesh_model *)params->model;
param.ctx.net_idx = params->ctx.net_idx;
param.ctx.app_idx = params->ctx.app_idx;
param.ctx.addr = params->ctx.addr;
param.ctx.send_rel = params->ctx.send_rel;
param.ctx.send_ttl = params->ctx.send_ttl;
param.msg_timeout = params->msg_timeout;
param.msg_role = params->msg_role;
switch (param.opcode) {
case ESP_BLE_MESH_MODEL_OP_ATTENTION_GET:
return bt_mesh_health_attention_get(&param);
case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_GET:
return bt_mesh_health_period_get(&param);
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET:
return bt_mesh_health_fault_get(&param, get->fault_get.company_id);
default:
BT_ERR("Invalid Health Get opcode 0x%04x", param.opcode);
return -EINVAL;
}
return 0;
}
static int btc_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_health_client_set_state_t *set)
{
bt_mesh_client_common_param_t param = {0};
if (params == NULL || set == NULL) {
BT_ERR("%s, Invalid parameter", __func__);
return -EINVAL;
}
param.opcode = params->opcode;
param.model = (struct bt_mesh_model *)params->model;
param.ctx.net_idx = params->ctx.net_idx;
param.ctx.app_idx = params->ctx.app_idx;
param.ctx.addr = params->ctx.addr;
param.ctx.send_rel = params->ctx.send_rel;
param.ctx.send_ttl = params->ctx.send_ttl;
param.msg_timeout = params->msg_timeout;
param.msg_role = params->msg_role;
switch (param.opcode) {
case ESP_BLE_MESH_MODEL_OP_ATTENTION_SET:
return bt_mesh_health_attention_set(&param, set->attention_set.attention, true);
case ESP_BLE_MESH_MODEL_OP_ATTENTION_SET_UNACK:
return bt_mesh_health_attention_set(&param, set->attention_set.attention, false);
case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET:
return bt_mesh_health_period_set(&param, set->period_set.fast_period_divisor, true);
case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET_UNACK:
return bt_mesh_health_period_set(&param, set->period_set.fast_period_divisor, false);
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST:
return bt_mesh_health_fault_test(&param, set->fault_test.company_id, set->fault_test.test_id, true);
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST_UNACK:
return bt_mesh_health_fault_test(&param, set->fault_test.company_id, set->fault_test.test_id, false);
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR:
return bt_mesh_health_fault_clear(&param, set->fault_clear.company_id, true);
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR_UNACK:
return bt_mesh_health_fault_clear(&param, set->fault_clear.company_id, false);
default:
BT_ERR("Invalid Health Set opcode 0x%04x", param.opcode);
return -EINVAL;
}
return 0;
}
void btc_ble_mesh_health_client_call_handler(btc_msg_t *msg)
{
btc_ble_mesh_health_client_args_t *arg = NULL;
esp_ble_mesh_health_client_cb_param_t health_client_cb = {0};
bt_mesh_role_param_t role_param = {0};
esp_ble_mesh_health_client_cb_param_t cb = {0};
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -486,36 +409,22 @@ void btc_mesh_health_client_call_handler(btc_msg_t *msg)
switch (msg->act) {
case BTC_BLE_MESH_ACT_HEALTH_CLIENT_GET_STATE: {
health_client_cb.params = arg->health_client_get_state.params;
role_param.model = (struct bt_mesh_model *)health_client_cb.params->model;
role_param.role = health_client_cb.params->msg_role;
if (bt_mesh_set_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
return;
}
btc_ble_mesh_health_client_get_state(arg->health_client_get_state.params,
arg->health_client_get_state.get_state,
&health_client_cb);
if (health_client_cb.error_code) {
cb.params = arg->health_client_get_state.params;
cb.error_code = btc_ble_mesh_health_client_get_state(arg->health_client_get_state.params,
arg->health_client_get_state.get_state);
if (cb.error_code) {
/* If send failed, callback error_code to app layer immediately */
btc_mesh_health_client_callback(&health_client_cb, ESP_BLE_MESH_HEALTH_CLIENT_GET_STATE_EVT);
btc_ble_mesh_health_client_callback(&cb, ESP_BLE_MESH_HEALTH_CLIENT_GET_STATE_EVT);
}
break;
}
case BTC_BLE_MESH_ACT_HEALTH_CLIENT_SET_STATE: {
health_client_cb.params = arg->health_client_set_state.params;
role_param.model = (struct bt_mesh_model *)health_client_cb.params->model;
role_param.role = health_client_cb.params->msg_role;
if (bt_mesh_set_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
return;
}
btc_ble_mesh_health_client_set_state(arg->health_client_set_state.params,
arg->health_client_set_state.set_state,
&health_client_cb);
if (health_client_cb.error_code) {
cb.params = arg->health_client_set_state.params;
cb.error_code = btc_ble_mesh_health_client_set_state(arg->health_client_set_state.params,
arg->health_client_set_state.set_state);
if (cb.error_code) {
/* If send failed, callback error_code to app layer immediately */
btc_mesh_health_client_callback(&health_client_cb, ESP_BLE_MESH_HEALTH_CLIENT_SET_STATE_EVT);
btc_ble_mesh_health_client_callback(&cb, ESP_BLE_MESH_HEALTH_CLIENT_SET_STATE_EVT);
}
break;
}
@ -527,12 +436,12 @@ void btc_mesh_health_client_call_handler(btc_msg_t *msg)
return;
}
void btc_mesh_health_client_cb_handler(btc_msg_t *msg)
void btc_ble_mesh_health_client_cb_handler(btc_msg_t *msg)
{
esp_ble_mesh_health_client_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -541,42 +450,137 @@ void btc_mesh_health_client_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_HEALTH_CLIENT_EVT_MAX) {
btc_ble_mesh_health_client_cb_to_app(msg->act, param);
} else {
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
BT_ERR("%s, Unknown act %d", __func__, msg->act);
}
btc_ble_mesh_health_client_free_req_data(msg);
return;
}
void btc_mesh_health_server_call_handler(btc_msg_t *msg)
/* Health Server Model related functions */
static inline void btc_ble_mesh_health_server_cb_to_app(esp_ble_mesh_health_server_cb_event_t event,
esp_ble_mesh_health_server_cb_param_t *param)
{
esp_ble_mesh_health_server_cb_param_t health_server_cb = {0};
esp_ble_mesh_health_server_cb_t btc_ble_mesh_cb =
(esp_ble_mesh_health_server_cb_t)btc_profile_cb_get(BTC_PID_HEALTH_SERVER);
if (btc_ble_mesh_cb) {
btc_ble_mesh_cb(event, param);
}
}
void btc_ble_mesh_health_server_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
{
if (!msg) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (msg->act) {
case BTC_BLE_MESH_ACT_HEALTH_SERVER_FAULT_UPDATE:
break;
default:
break;
}
}
static void btc_ble_mesh_health_server_arg_deep_free(btc_msg_t *msg)
{
if (!msg) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (msg->act) {
case BTC_BLE_MESH_ACT_HEALTH_SERVER_FAULT_UPDATE:
break;
default:
break;
}
}
static void btc_ble_mesh_health_server_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
{
if (!msg) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (msg->act) {
case ESP_BLE_MESH_HEALTH_SERVER_FAULT_UPDATE_COMP_EVT:
break;
default:
break;
}
}
static void btc_ble_mesh_health_server_free_req_data(btc_msg_t *msg)
{
if (!msg) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (msg->act) {
case ESP_BLE_MESH_HEALTH_SERVER_FAULT_UPDATE_COMP_EVT:
break;
default:
break;
}
}
static void btc_ble_mesh_health_server_callback(esp_ble_mesh_health_server_cb_param_t *cb_params, uint8_t act)
{
btc_msg_t msg = {0};
BT_DBG("%s", __func__);
/* If corresponding callback is not registered, event will not be posted. */
if (!btc_profile_cb_get(BTC_PID_HEALTH_SERVER)) {
return;
}
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_HEALTH_SERVER;
msg.act = act;
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_health_server_cb_param_t),
btc_ble_mesh_health_server_copy_req_data);
}
void btc_ble_mesh_health_server_call_handler(btc_msg_t *msg)
{
esp_ble_mesh_health_server_cb_param_t param = {0};
btc_ble_mesh_health_server_args_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
arg = (btc_ble_mesh_health_server_args_t *)(msg->arg);
switch (msg->act) {
case BTC_BLE_MESH_ACT_HEALTH_SERVER_FAULT_UPDATE: {
health_server_cb.error_code = bt_mesh_fault_update((struct bt_mesh_elem *)arg->fault_update.element);
btc_mesh_health_server_callback(&health_server_cb, ESP_BLE_MESH_HEALTH_SERVER_FAULT_UPDATE_COMPLETE_EVT);
}
case BTC_BLE_MESH_ACT_HEALTH_SERVER_FAULT_UPDATE:
param.fault_update_comp.element = arg->health_fault_update.element;
param.fault_update_comp.error_code =
bt_mesh_fault_update((struct bt_mesh_elem *)arg->health_fault_update.element);
btc_ble_mesh_health_server_callback(&param, ESP_BLE_MESH_HEALTH_SERVER_FAULT_UPDATE_COMP_EVT);
break;
default:
break;
}
btc_ble_mesh_health_server_arg_deep_free(msg);
return;
}
void btc_mesh_health_server_cb_handler(btc_msg_t *msg)
void btc_ble_mesh_health_server_cb_handler(btc_msg_t *msg)
{
esp_ble_mesh_health_server_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -585,8 +589,50 @@ void btc_mesh_health_server_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_HEALTH_SERVER_EVT_MAX) {
btc_ble_mesh_health_server_cb_to_app(msg->act, param);
} else {
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
BT_ERR("%s, Unknown act %d", __func__, msg->act);
}
btc_ble_mesh_health_server_free_req_data(msg);
return;
}
void btc_ble_mesh_health_server_fault_clear(struct bt_mesh_model *model, u16_t company_id)
{
esp_ble_mesh_health_server_cb_param_t param = {0};
param.fault_clear.model = (esp_ble_mesh_model_t *)model;
param.fault_clear.company_id = company_id;
btc_ble_mesh_health_server_callback(&param, ESP_BLE_MESH_HEALTH_SERVER_FAULT_CLEAR_EVT);
}
void btc_ble_mesh_health_server_fault_test(struct bt_mesh_model *model,
u8_t test_id, u16_t company_id)
{
esp_ble_mesh_health_server_cb_param_t param = {0};
param.fault_test.model = (esp_ble_mesh_model_t *)model;
param.fault_test.test_id = test_id;
param.fault_test.company_id = company_id;
btc_ble_mesh_health_server_callback(&param, ESP_BLE_MESH_HEALTH_SERVER_FAULT_TEST_EVT);
}
void btc_ble_mesh_health_server_attention_on(struct bt_mesh_model *model, u8_t time)
{
esp_ble_mesh_health_server_cb_param_t param = {0};
param.attention_on.model = (esp_ble_mesh_model_t *)model;
param.attention_on.time = time;
btc_ble_mesh_health_server_callback(&param, ESP_BLE_MESH_HEALTH_SERVER_ATTENTION_ON_EVT);
}
void btc_ble_mesh_health_server_attention_off(struct bt_mesh_model *model)
{
esp_ble_mesh_health_server_cb_param_t param = {0};
param.attention_off.model = (esp_ble_mesh_model_t *)model;
btc_ble_mesh_health_server_callback(&param, ESP_BLE_MESH_HEALTH_SERVER_ATTENTION_OFF_EVT);
}

View File

@ -15,84 +15,132 @@
#include <string.h>
#include <errno.h>
#include "btc/btc_manage.h"
#include "osi/allocator.h"
#include "lighting_client.h"
#include "btc_ble_mesh_lighting_model.h"
#include "lighting_client.h"
#include "esp_ble_mesh_lighting_model_api.h"
static inline void btc_ble_mesh_cb_to_app(esp_ble_mesh_light_client_cb_event_t event,
esp_ble_mesh_light_client_cb_param_t *param)
/* Lighting Client Models related functions */
static inline void btc_ble_mesh_lighting_client_cb_to_app(esp_ble_mesh_light_client_cb_event_t event,
esp_ble_mesh_light_client_cb_param_t *param)
{
esp_ble_mesh_light_client_cb_t btc_mesh_cb = (esp_ble_mesh_light_client_cb_t)btc_profile_cb_get(BTC_PID_LIGHT_CLIENT);
if (btc_mesh_cb) {
btc_mesh_cb(event, param);
esp_ble_mesh_light_client_cb_t btc_ble_mesh_cb =
(esp_ble_mesh_light_client_cb_t)btc_profile_cb_get(BTC_PID_LIGHTING_CLIENT);
if (btc_ble_mesh_cb) {
btc_ble_mesh_cb(event, param);
}
}
void btc_ble_mesh_light_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
void btc_ble_mesh_lighting_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
{
btc_ble_mesh_light_client_args_t *dst = (btc_ble_mesh_light_client_args_t *)p_dest;
btc_ble_mesh_light_client_args_t *src = (btc_ble_mesh_light_client_args_t *)p_src;
btc_ble_mesh_lighting_client_args_t *dst = (btc_ble_mesh_lighting_client_args_t *)p_dest;
btc_ble_mesh_lighting_client_args_t *src = (btc_ble_mesh_lighting_client_args_t *)p_src;
if (!msg || !dst || !src) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (msg->act) {
case BTC_BLE_MESH_ACT_LIGHT_CLIENT_GET_STATE: {
dst->light_client_get_state.params = (esp_ble_mesh_client_common_param_t *)osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
dst->light_client_get_state.get_state = (esp_ble_mesh_light_client_get_state_t *)osi_malloc(sizeof(esp_ble_mesh_light_client_get_state_t));
if (dst->light_client_get_state.params && dst->light_client_get_state.get_state) {
case BTC_BLE_MESH_ACT_LIGHTING_CLIENT_GET_STATE: {
dst->light_client_get_state.params = (esp_ble_mesh_client_common_param_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (dst->light_client_get_state.params) {
memcpy(dst->light_client_get_state.params, src->light_client_get_state.params,
sizeof(esp_ble_mesh_client_common_param_t));
memcpy(dst->light_client_get_state.get_state, src->light_client_get_state.get_state,
sizeof(esp_ble_mesh_light_client_get_state_t));
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
break;
}
if (src->light_client_get_state.get_state) {
dst->light_client_get_state.get_state = (esp_ble_mesh_light_client_get_state_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_light_client_get_state_t));
if (dst->light_client_get_state.get_state) {
memcpy(dst->light_client_get_state.get_state, src->light_client_get_state.get_state,
sizeof(esp_ble_mesh_light_client_get_state_t));
} else {
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
}
}
break;
}
case BTC_BLE_MESH_ACT_LIGHT_CLIENT_SET_STATE: {
dst->light_client_set_state.params = (esp_ble_mesh_client_common_param_t *)osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
dst->light_client_set_state.set_state = (esp_ble_mesh_light_client_set_state_t *)osi_malloc(sizeof(esp_ble_mesh_light_client_set_state_t));
case BTC_BLE_MESH_ACT_LIGHTING_CLIENT_SET_STATE: {
dst->light_client_set_state.params = (esp_ble_mesh_client_common_param_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
dst->light_client_set_state.set_state = (esp_ble_mesh_light_client_set_state_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_light_client_set_state_t));
if (dst->light_client_set_state.params && dst->light_client_set_state.set_state) {
memcpy(dst->light_client_set_state.params, src->light_client_set_state.params,
sizeof(esp_ble_mesh_client_common_param_t));
memcpy(dst->light_client_set_state.set_state, src->light_client_set_state.set_state,
sizeof(esp_ble_mesh_light_client_set_state_t));
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
}
break;
}
default:
LOG_DEBUG("%s, Unknown deep copy act %d", __func__, msg->act);
BT_DBG("%s, Unknown act %d", __func__, msg->act);
break;
}
}
static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
static void btc_ble_mesh_lighting_client_arg_deep_free(btc_msg_t *msg)
{
btc_ble_mesh_lighting_client_args_t *arg = NULL;
if (!msg || !msg->arg) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
arg = (btc_ble_mesh_lighting_client_args_t *)(msg->arg);
switch (msg->act) {
case BTC_BLE_MESH_ACT_LIGHTING_CLIENT_GET_STATE:
if (arg->light_client_get_state.params) {
bt_mesh_free(arg->light_client_get_state.params);
}
if (arg->light_client_get_state.get_state) {
bt_mesh_free(arg->light_client_get_state.get_state);
}
break;
case BTC_BLE_MESH_ACT_LIGHTING_CLIENT_SET_STATE:
if (arg->light_client_set_state.params) {
bt_mesh_free(arg->light_client_set_state.params);
}
if (arg->light_client_set_state.set_state) {
bt_mesh_free(arg->light_client_set_state.set_state);
}
break;
default:
break;
}
}
static void btc_ble_mesh_lighting_client_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
{
esp_ble_mesh_light_client_cb_param_t *p_dest_data = (esp_ble_mesh_light_client_cb_param_t *)p_dest;
esp_ble_mesh_light_client_cb_param_t *p_src_data = (esp_ble_mesh_light_client_cb_param_t *)p_src;
u32_t opcode;
u16_t length;
u16_t length = 0U;
if (!msg || !p_src_data || !p_dest_data) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
if (p_src_data->params) {
p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (!p_dest_data->params) {
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
}
switch (msg->act) {
case ESP_BLE_MESH_LIGHT_CLIENT_GET_STATE_EVT:
case ESP_BLE_MESH_LIGHT_CLIENT_SET_STATE_EVT:
case ESP_BLE_MESH_LIGHT_CLIENT_PUBLISH_EVT:
if (p_src_data->params) {
opcode = p_src_data->params->opcode;
switch (opcode) {
switch (p_src_data->params->opcode) {
case ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_GET:
case ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET:
case ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_STATUS:
@ -100,7 +148,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
length = p_src_data->status_cb.lc_property_status.property_value->len;
p_dest_data->status_cb.lc_property_status.property_value = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.lc_property_status.property_value) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.lc_property_status.property_value,
@ -113,27 +161,18 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
}
}
case ESP_BLE_MESH_LIGHT_CLIENT_TIMEOUT_EVT:
if (p_src_data->params) {
p_dest_data->params = osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (p_dest_data->params) {
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
}
break;
default:
break;
}
}
static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
static void btc_ble_mesh_lighting_client_free_req_data(btc_msg_t *msg)
{
esp_ble_mesh_light_client_cb_param_t *arg = NULL;
u32_t opcode;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -144,8 +183,7 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
case ESP_BLE_MESH_LIGHT_CLIENT_SET_STATE_EVT:
case ESP_BLE_MESH_LIGHT_CLIENT_PUBLISH_EVT:
if (arg->params) {
opcode = arg->params->opcode;
switch (opcode) {
switch (arg->params->opcode) {
case ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_GET:
case ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET:
case ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_STATUS:
@ -157,7 +195,7 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
}
case ESP_BLE_MESH_LIGHT_CLIENT_TIMEOUT_EVT:
if (arg->params) {
osi_free(arg->params);
bt_mesh_free(arg->params);
}
break;
default:
@ -165,85 +203,54 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
}
}
void btc_ble_mesh_light_client_arg_deep_free(btc_msg_t *msg)
{
btc_ble_mesh_light_client_args_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
arg = (btc_ble_mesh_light_client_args_t *)(msg->arg);
switch (msg->act) {
case BTC_BLE_MESH_ACT_LIGHT_CLIENT_GET_STATE:
if (arg->light_client_get_state.params) {
osi_free(arg->light_client_get_state.params);
}
if (arg->light_client_get_state.get_state) {
osi_free(arg->light_client_get_state.get_state);
}
break;
case BTC_BLE_MESH_ACT_LIGHT_CLIENT_SET_STATE:
if (arg->light_client_set_state.params) {
osi_free(arg->light_client_set_state.params);
}
if (arg->light_client_set_state.set_state) {
osi_free(arg->light_client_set_state.set_state);
}
break;
default:
break;
}
return;
}
static void btc_mesh_light_client_callback(esp_ble_mesh_light_client_cb_param_t *cb_params, uint8_t act)
static void btc_ble_mesh_lighting_client_callback(esp_ble_mesh_light_client_cb_param_t *cb_params, uint8_t act)
{
btc_msg_t msg = {0};
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
/* If corresponding callback is not registered, event will not be posted. */
if (!btc_profile_cb_get(BTC_PID_LIGHTING_CLIENT)) {
return;
}
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_LIGHT_CLIENT;
msg.pid = BTC_PID_LIGHTING_CLIENT;
msg.act = act;
btc_transfer_context(&msg, cb_params,
sizeof(esp_ble_mesh_light_client_cb_param_t), btc_ble_mesh_copy_req_data);
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_light_client_cb_param_t),
btc_ble_mesh_lighting_client_copy_req_data);
}
void bt_mesh_callback_light_status_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len)
void bt_mesh_lighting_client_cb_evt_to_btc(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)
{
esp_ble_mesh_light_client_cb_param_t cb_params = {0};
esp_ble_mesh_client_common_param_t params = {0};
size_t length;
uint8_t act;
uint8_t act = 0U;
if (!model || !ctx) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (evt_type) {
case 0x00:
case BTC_BLE_MESH_EVT_LIGHTING_CLIENT_GET_STATE:
act = ESP_BLE_MESH_LIGHT_CLIENT_GET_STATE_EVT;
break;
case 0x01:
case BTC_BLE_MESH_EVT_LIGHTING_CLIENT_SET_STATE:
act = ESP_BLE_MESH_LIGHT_CLIENT_SET_STATE_EVT;
break;
case 0x02:
case BTC_BLE_MESH_EVT_LIGHTING_CLIENT_PUBLISH:
act = ESP_BLE_MESH_LIGHT_CLIENT_PUBLISH_EVT;
break;
case 0x03:
case BTC_BLE_MESH_EVT_LIGHTING_CLIENT_TIMEOUT:
act = ESP_BLE_MESH_LIGHT_CLIENT_TIMEOUT_EVT;
break;
default:
LOG_ERROR("%s, Unknown lighting client event type", __func__);
BT_ERR("Unknown Lighting client event type %d", evt_type);
return;
}
@ -255,53 +262,51 @@ void bt_mesh_callback_light_status_to_btc(u32_t opcode, u8_t evt_type,
params.ctx.recv_ttl = ctx->recv_ttl;
params.ctx.recv_op = ctx->recv_op;
params.ctx.recv_dst = ctx->recv_dst;
params.ctx.recv_rssi = ctx->recv_rssi;
params.ctx.send_ttl = ctx->send_ttl;
cb_params.error_code = 0;
cb_params.params = &params;
if (val && len) {
length = (len <= sizeof(cb_params.status_cb)) ? len : sizeof(cb_params.status_cb);
memcpy(&cb_params.status_cb, val, length);
memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb)));
}
btc_mesh_light_client_callback(&cb_params, act);
btc_ble_mesh_lighting_client_callback(&cb_params, act);
return;
}
void btc_mesh_light_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf)
void btc_ble_mesh_lighting_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
if (!model || !ctx || !buf) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
bt_mesh_callback_light_status_to_btc(opcode, 0x02, model, ctx, buf->data, buf->len);
bt_mesh_lighting_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_LIGHTING_CLIENT_PUBLISH,
model, ctx, buf->data, buf->len);
return;
}
void btc_mesh_light_client_call_handler(btc_msg_t *msg)
void btc_ble_mesh_lighting_client_call_handler(btc_msg_t *msg)
{
esp_ble_mesh_light_client_cb_param_t light_client_cb = {0};
esp_ble_mesh_client_common_param_t *params = NULL;
btc_ble_mesh_light_client_args_t *arg = NULL;
struct bt_mesh_common_param common = {0};
bt_mesh_role_param_t role_param = {0};
btc_ble_mesh_lighting_client_args_t *arg = NULL;
esp_ble_mesh_light_client_cb_param_t cb = {0};
bt_mesh_client_common_param_t common = {0};
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
arg = (btc_ble_mesh_light_client_args_t *)(msg->arg);
arg = (btc_ble_mesh_lighting_client_args_t *)(msg->arg);
switch (msg->act) {
case BTC_BLE_MESH_ACT_LIGHT_CLIENT_GET_STATE: {
case BTC_BLE_MESH_ACT_LIGHTING_CLIENT_GET_STATE: {
params = arg->light_client_get_state.params;
role_param.model = (struct bt_mesh_model *)params->model;
role_param.role = params->msg_role;
if (bt_mesh_set_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
return;
}
common.opcode = params->opcode;
common.model = (struct bt_mesh_model *)params->model;
common.ctx.net_idx = params->ctx.net_idx;
@ -310,27 +315,18 @@ void btc_mesh_light_client_call_handler(btc_msg_t *msg)
common.ctx.send_rel = params->ctx.send_rel;
common.ctx.send_ttl = params->ctx.send_ttl;
common.msg_timeout = params->msg_timeout;
common.msg_role = params->msg_role;
light_client_cb.params = arg->light_client_get_state.params;
light_client_cb.error_code =
bt_mesh_light_client_get_state(&common,
(void *)arg->light_client_get_state.get_state,
(void *)&light_client_cb.status_cb);
if (light_client_cb.error_code) {
cb.params = arg->light_client_get_state.params;
cb.error_code = bt_mesh_light_client_get_state(&common, arg->light_client_get_state.get_state);
if (cb.error_code) {
/* If send failed, callback error_code to app layer immediately */
btc_mesh_light_client_callback(&light_client_cb,
ESP_BLE_MESH_LIGHT_CLIENT_GET_STATE_EVT);
btc_ble_mesh_lighting_client_callback(&cb, ESP_BLE_MESH_LIGHT_CLIENT_GET_STATE_EVT);
}
break;
}
case BTC_BLE_MESH_ACT_LIGHT_CLIENT_SET_STATE: {
case BTC_BLE_MESH_ACT_LIGHTING_CLIENT_SET_STATE: {
params = arg->light_client_set_state.params;
role_param.model = (struct bt_mesh_model *)params->model;
role_param.role = params->msg_role;
if (bt_mesh_set_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
return;
}
common.opcode = params->opcode;
common.model = (struct bt_mesh_model *)params->model;
common.ctx.net_idx = params->ctx.net_idx;
@ -339,16 +335,13 @@ void btc_mesh_light_client_call_handler(btc_msg_t *msg)
common.ctx.send_rel = params->ctx.send_rel;
common.ctx.send_ttl = params->ctx.send_ttl;
common.msg_timeout = params->msg_timeout;
common.msg_role = params->msg_role;
light_client_cb.params = arg->light_client_set_state.params;
light_client_cb.error_code =
bt_mesh_light_client_set_state(&common,
(void *)arg->light_client_set_state.set_state,
(void *)&light_client_cb.status_cb);
if (light_client_cb.error_code) {
cb.params = arg->light_client_set_state.params;
cb.error_code = bt_mesh_light_client_set_state(&common, arg->light_client_set_state.set_state);
if (cb.error_code) {
/* If send failed, callback error_code to app layer immediately */
btc_mesh_light_client_callback(&light_client_cb,
ESP_BLE_MESH_LIGHT_CLIENT_SET_STATE_EVT);
btc_ble_mesh_lighting_client_callback(&cb, ESP_BLE_MESH_LIGHT_CLIENT_SET_STATE_EVT);
}
break;
}
@ -356,26 +349,225 @@ void btc_mesh_light_client_call_handler(btc_msg_t *msg)
break;
}
btc_ble_mesh_light_client_arg_deep_free(msg);
btc_ble_mesh_lighting_client_arg_deep_free(msg);
return;
}
void btc_mesh_light_client_cb_handler(btc_msg_t *msg)
void btc_ble_mesh_lighting_client_cb_handler(btc_msg_t *msg)
{
esp_ble_mesh_light_client_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
param = (esp_ble_mesh_light_client_cb_param_t *)(msg->arg);
if (msg->act < ESP_BLE_MESH_LIGHT_CLIENT_EVT_MAX) {
btc_ble_mesh_cb_to_app(msg->act, param);
btc_ble_mesh_lighting_client_cb_to_app(msg->act, param);
} else {
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
BT_ERR("%s, Unknown act %d", __func__, msg->act);
}
btc_ble_mesh_free_req_data(msg);
btc_ble_mesh_lighting_client_free_req_data(msg);
return;
}
/* Lighting Server Models related functions */
static inline void btc_ble_mesh_lighting_server_cb_to_app(esp_ble_mesh_lighting_server_cb_event_t event,
esp_ble_mesh_lighting_server_cb_param_t *param)
{
esp_ble_mesh_lighting_server_cb_t btc_ble_mesh_cb =
(esp_ble_mesh_lighting_server_cb_t)btc_profile_cb_get(BTC_PID_LIGHTING_SERVER);
if (btc_ble_mesh_cb) {
btc_ble_mesh_cb(event, param);
}
}
static void btc_ble_mesh_lighting_server_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
{
esp_ble_mesh_lighting_server_cb_param_t *p_dest_data = (esp_ble_mesh_lighting_server_cb_param_t *)p_dest;
esp_ble_mesh_lighting_server_cb_param_t *p_src_data = (esp_ble_mesh_lighting_server_cb_param_t *)p_src;
u16_t length = 0U;
if (!msg || !p_src_data || !p_dest_data) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (msg->act) {
case ESP_BLE_MESH_LIGHTING_SERVER_STATE_CHANGE_EVT:
if (p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET ||
p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET_UNACK) {
if (p_src_data->value.state_change.lc_property_set.property_value) {
length = p_src_data->value.state_change.lc_property_set.property_value->len;
p_dest_data->value.state_change.lc_property_set.property_value = bt_mesh_alloc_buf(length);
if (p_dest_data->value.state_change.lc_property_set.property_value == NULL) {
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.state_change.lc_property_set.property_value,
p_src_data->value.state_change.lc_property_set.property_value->data,
p_src_data->value.state_change.lc_property_set.property_value->len);
}
}
break;
case ESP_BLE_MESH_LIGHTING_SERVER_RECV_SET_MSG_EVT:
if (p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET ||
p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET_UNACK) {
if (p_src_data->value.set.lc_property.property_value) {
length = p_src_data->value.set.lc_property.property_value->len;
p_dest_data->value.set.lc_property.property_value = bt_mesh_alloc_buf(length);
if (p_dest_data->value.set.lc_property.property_value == NULL) {
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.set.lc_property.property_value,
p_src_data->value.set.lc_property.property_value->data,
p_src_data->value.set.lc_property.property_value->len);
}
}
break;
case ESP_BLE_MESH_LIGHTING_SERVER_RECV_STATUS_MSG_EVT:
if (p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_STATUS) {
if (p_src_data->value.status.sensor_status.data) {
length = p_src_data->value.status.sensor_status.data->len;
p_dest_data->value.status.sensor_status.data = bt_mesh_alloc_buf(length);
if (p_dest_data->value.status.sensor_status.data == NULL) {
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.status.sensor_status.data,
p_src_data->value.status.sensor_status.data->data,
p_src_data->value.status.sensor_status.data->len);
}
}
break;
default:
break;
}
}
static void btc_ble_mesh_lighting_server_free_req_data(btc_msg_t *msg)
{
esp_ble_mesh_lighting_server_cb_param_t *arg = NULL;
if (!msg || !msg->arg) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
arg = (esp_ble_mesh_lighting_server_cb_param_t *)(msg->arg);
switch (msg->act) {
case ESP_BLE_MESH_LIGHTING_SERVER_STATE_CHANGE_EVT:
if (arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET ||
arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET_UNACK) {
bt_mesh_free_buf(arg->value.state_change.lc_property_set.property_value);
}
break;
case ESP_BLE_MESH_LIGHTING_SERVER_RECV_SET_MSG_EVT:
if (arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET ||
arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET_UNACK) {
bt_mesh_free_buf(arg->value.set.lc_property.property_value);
}
break;
case ESP_BLE_MESH_LIGHTING_SERVER_RECV_STATUS_MSG_EVT:
if (arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_STATUS) {
bt_mesh_free_buf(arg->value.status.sensor_status.data);
}
break;
default:
break;
}
}
static void btc_ble_mesh_lighting_server_callback(esp_ble_mesh_lighting_server_cb_param_t *cb_params, uint8_t act)
{
btc_msg_t msg = {0};
BT_DBG("%s", __func__);
/* If corresponding callback is not registered, event will not be posted. */
if (!btc_profile_cb_get(BTC_PID_LIGHTING_SERVER)) {
return;
}
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_LIGHTING_SERVER;
msg.act = act;
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_lighting_server_cb_param_t),
btc_ble_mesh_lighting_server_copy_req_data);
}
void bt_mesh_lighting_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len)
{
esp_ble_mesh_lighting_server_cb_param_t cb_params = {0};
uint8_t act = 0U;
if (model == NULL || ctx == NULL) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (evt_type) {
case BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE:
act = ESP_BLE_MESH_LIGHTING_SERVER_STATE_CHANGE_EVT;
break;
case BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_GET_MSG:
act = ESP_BLE_MESH_LIGHTING_SERVER_RECV_GET_MSG_EVT;
break;
case BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG:
act = ESP_BLE_MESH_LIGHTING_SERVER_RECV_SET_MSG_EVT;
break;
case BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_STATUS_MSG:
act = ESP_BLE_MESH_LIGHTING_SERVER_RECV_STATUS_MSG_EVT;
break;
default:
BT_ERR("Unknown Lighting server event type %d", evt_type);
return;
}
cb_params.model = (esp_ble_mesh_model_t *)model;
cb_params.ctx.net_idx = ctx->net_idx;
cb_params.ctx.app_idx = ctx->app_idx;
cb_params.ctx.addr = ctx->addr;
cb_params.ctx.recv_ttl = ctx->recv_ttl;
cb_params.ctx.recv_op = ctx->recv_op;
cb_params.ctx.recv_dst = ctx->recv_dst;
cb_params.ctx.recv_rssi = ctx->recv_rssi;
cb_params.ctx.send_ttl = ctx->send_ttl;
if (val && len) {
memcpy(&cb_params.value, val, MIN(len, sizeof(cb_params.value)));
}
btc_ble_mesh_lighting_server_callback(&cb_params, act);
return;
}
void btc_ble_mesh_lighting_server_cb_handler(btc_msg_t *msg)
{
esp_ble_mesh_lighting_server_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
param = (esp_ble_mesh_lighting_server_cb_param_t *)(msg->arg);
if (msg->act < ESP_BLE_MESH_LIGHTING_SERVER_EVT_MAX) {
btc_ble_mesh_lighting_server_cb_to_app(msg->act, param);
} else {
BT_ERR("%s, Unknown act %d", __func__, msg->act);
}
btc_ble_mesh_lighting_server_free_req_data(msg);
return;
}

File diff suppressed because it is too large Load Diff

View File

@ -15,19 +15,19 @@
#include <string.h>
#include <errno.h>
#include "btc/btc_manage.h"
#include "osi/allocator.h"
#include "sensor_client.h"
#include "btc_ble_mesh_sensor_model.h"
#include "sensor_client.h"
#include "esp_ble_mesh_sensor_model_api.h"
static inline void btc_ble_mesh_cb_to_app(esp_ble_mesh_sensor_client_cb_event_t event,
esp_ble_mesh_sensor_client_cb_param_t *param)
/* Sensor Client Models related functions */
static inline void btc_ble_mesh_sensor_client_cb_to_app(esp_ble_mesh_sensor_client_cb_event_t event,
esp_ble_mesh_sensor_client_cb_param_t *param)
{
esp_ble_mesh_sensor_client_cb_t btc_mesh_cb = (esp_ble_mesh_sensor_client_cb_t)btc_profile_cb_get(BTC_PID_SENSOR_CLIENT);
if (btc_mesh_cb) {
btc_mesh_cb(event, param);
esp_ble_mesh_sensor_client_cb_t btc_ble_mesh_cb =
(esp_ble_mesh_sensor_client_cb_t)btc_profile_cb_get(BTC_PID_SENSOR_CLIENT);
if (btc_ble_mesh_cb) {
btc_ble_mesh_cb(event, param);
}
}
@ -35,32 +35,30 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
{
btc_ble_mesh_sensor_client_args_t *dst = (btc_ble_mesh_sensor_client_args_t *)p_dest;
btc_ble_mesh_sensor_client_args_t *src = (btc_ble_mesh_sensor_client_args_t *)p_src;
u32_t opcode;
u16_t length;
u16_t length = 0U;
if (!msg || !dst || !src) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (msg->act) {
case BTC_BLE_MESH_ACT_SENSOR_CLIENT_GET_STATE: {
dst->sensor_client_get_state.params = (esp_ble_mesh_client_common_param_t *)osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
dst->sensor_client_get_state.get_state = (esp_ble_mesh_sensor_client_get_state_t *)osi_malloc(sizeof(esp_ble_mesh_sensor_client_get_state_t));
dst->sensor_client_get_state.params = (esp_ble_mesh_client_common_param_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
dst->sensor_client_get_state.get_state = (esp_ble_mesh_sensor_client_get_state_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_sensor_client_get_state_t));
if (dst->sensor_client_get_state.params && dst->sensor_client_get_state.get_state) {
memcpy(dst->sensor_client_get_state.params, src->sensor_client_get_state.params,
sizeof(esp_ble_mesh_client_common_param_t));
memcpy(dst->sensor_client_get_state.get_state, src->sensor_client_get_state.get_state,
sizeof(esp_ble_mesh_sensor_client_get_state_t));
opcode = src->sensor_client_get_state.params->opcode;
switch (opcode) {
switch (src->sensor_client_get_state.params->opcode) {
case ESP_BLE_MESH_MODEL_OP_SENSOR_COLUMN_GET:
if (src->sensor_client_get_state.get_state->column_get.raw_value_x) {
length = src->sensor_client_get_state.get_state->column_get.raw_value_x->len;
dst->sensor_client_get_state.get_state->column_get.raw_value_x = bt_mesh_alloc_buf(length);
if (!dst->sensor_client_get_state.get_state->column_get.raw_value_x) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(dst->sensor_client_get_state.get_state->column_get.raw_value_x,
@ -73,7 +71,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
length = src->sensor_client_get_state.get_state->series_get.raw_value_x1->len;
dst->sensor_client_get_state.get_state->series_get.raw_value_x1 = bt_mesh_alloc_buf(length);
if (!dst->sensor_client_get_state.get_state->series_get.raw_value_x1) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(dst->sensor_client_get_state.get_state->series_get.raw_value_x1,
@ -84,7 +82,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
length = src->sensor_client_get_state.get_state->series_get.raw_value_x2->len;
dst->sensor_client_get_state.get_state->series_get.raw_value_x2 = bt_mesh_alloc_buf(length);
if (!dst->sensor_client_get_state.get_state->series_get.raw_value_x2) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(dst->sensor_client_get_state.get_state->series_get.raw_value_x2,
@ -96,27 +94,26 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
break;
}
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
}
break;
}
case BTC_BLE_MESH_ACT_SENSOR_CLIENT_SET_STATE: {
dst->sensor_client_set_state.params = (esp_ble_mesh_client_common_param_t *)osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
dst->sensor_client_set_state.set_state = (esp_ble_mesh_sensor_client_set_state_t *)osi_malloc(sizeof(esp_ble_mesh_sensor_client_set_state_t));
dst->sensor_client_set_state.params = (esp_ble_mesh_client_common_param_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
dst->sensor_client_set_state.set_state = (esp_ble_mesh_sensor_client_set_state_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_sensor_client_set_state_t));
if (dst->sensor_client_set_state.params && dst->sensor_client_set_state.set_state) {
memcpy(dst->sensor_client_set_state.params, src->sensor_client_set_state.params,
sizeof(esp_ble_mesh_client_common_param_t));
memcpy(dst->sensor_client_set_state.set_state, src->sensor_client_set_state.set_state,
sizeof(esp_ble_mesh_sensor_client_set_state_t));
opcode = src->sensor_client_set_state.params->opcode;
switch (opcode) {
switch (src->sensor_client_set_state.params->opcode) {
case ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET:
if (src->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down) {
length = src->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down->len;
dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down = bt_mesh_alloc_buf(length);
if (!dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down,
@ -127,7 +124,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
length = src->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_up->len;
dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_up = bt_mesh_alloc_buf(length);
if (!dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_up) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_up,
@ -138,7 +135,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
length = src->sensor_client_set_state.set_state->cadence_set.fast_cadence_low->len;
dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_low = bt_mesh_alloc_buf(length);
if (!dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_low) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_low,
@ -149,7 +146,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
length = src->sensor_client_set_state.set_state->cadence_set.fast_cadence_high->len;
dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_high = bt_mesh_alloc_buf(length);
if (!dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_high) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_high,
@ -162,7 +159,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
length = src->sensor_client_set_state.set_state->setting_set.sensor_setting_raw->len;
dst->sensor_client_set_state.set_state->setting_set.sensor_setting_raw = bt_mesh_alloc_buf(length);
if (!dst->sensor_client_set_state.set_state->setting_set.sensor_setting_raw) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(dst->sensor_client_set_state.set_state->setting_set.sensor_setting_raw,
@ -174,42 +171,111 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
break;
}
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
}
break;
}
default:
LOG_DEBUG("%s, Unknown deep copy act %d", __func__, msg->act);
BT_DBG("%s, Unknown act %d", __func__, msg->act);
break;
}
}
static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
void btc_ble_mesh_sensor_client_arg_deep_free(btc_msg_t *msg)
{
btc_ble_mesh_sensor_client_args_t *arg = NULL;
if (!msg || !msg->arg) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
arg = (btc_ble_mesh_sensor_client_args_t *)(msg->arg);
switch (msg->act) {
case BTC_BLE_MESH_ACT_SENSOR_CLIENT_GET_STATE:
if (arg->sensor_client_get_state.get_state) {
if (arg->sensor_client_get_state.params) {
switch (arg->sensor_client_get_state.params->opcode) {
case ESP_BLE_MESH_MODEL_OP_SENSOR_COLUMN_GET:
bt_mesh_free_buf(arg->sensor_client_get_state.get_state->column_get.raw_value_x);
break;
case ESP_BLE_MESH_MODEL_OP_SENSOR_SERIES_GET:
bt_mesh_free_buf(arg->sensor_client_get_state.get_state->series_get.raw_value_x1);
bt_mesh_free_buf(arg->sensor_client_get_state.get_state->series_get.raw_value_x2);
break;
default:
break;
}
}
bt_mesh_free(arg->sensor_client_get_state.get_state);
}
if (arg->sensor_client_get_state.params) {
bt_mesh_free(arg->sensor_client_get_state.params);
}
break;
case BTC_BLE_MESH_ACT_SENSOR_CLIENT_SET_STATE:
if (arg->sensor_client_set_state.set_state) {
if (arg->sensor_client_set_state.params) {
switch (arg->sensor_client_set_state.params->opcode) {
case ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET:
bt_mesh_free_buf(arg->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down);
bt_mesh_free_buf(arg->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_up);
bt_mesh_free_buf(arg->sensor_client_set_state.set_state->cadence_set.fast_cadence_low);
bt_mesh_free_buf(arg->sensor_client_set_state.set_state->cadence_set.fast_cadence_high);
break;
case ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET:
bt_mesh_free_buf(arg->sensor_client_set_state.set_state->setting_set.sensor_setting_raw);
break;
default:
break;
}
}
bt_mesh_free(arg->sensor_client_set_state.set_state);
}
if (arg->sensor_client_set_state.params) {
bt_mesh_free(arg->sensor_client_set_state.params);
}
break;
default:
break;
}
}
static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
{
esp_ble_mesh_sensor_client_cb_param_t *p_dest_data = (esp_ble_mesh_sensor_client_cb_param_t *)p_dest;
esp_ble_mesh_sensor_client_cb_param_t *p_src_data = (esp_ble_mesh_sensor_client_cb_param_t *)p_src;
u32_t opcode;
u16_t length;
u16_t length = 0U;
if (!msg || !p_src_data || !p_dest_data) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
if (p_src_data->params) {
p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (!p_dest_data->params) {
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
}
switch (msg->act) {
case ESP_BLE_MESH_SENSOR_CLIENT_GET_STATE_EVT:
case ESP_BLE_MESH_SENSOR_CLIENT_SET_STATE_EVT:
case ESP_BLE_MESH_SENSOR_CLIENT_PUBLISH_EVT:
if (p_src_data->params) {
opcode = p_src_data->params->opcode;
switch (opcode) {
switch (p_src_data->params->opcode) {
case ESP_BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_GET:
case ESP_BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_STATUS:
if (p_src_data->status_cb.descriptor_status.descriptor) {
length = p_src_data->status_cb.descriptor_status.descriptor->len;
p_dest_data->status_cb.descriptor_status.descriptor = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.descriptor_status.descriptor) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.descriptor_status.descriptor,
@ -224,7 +290,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
length = p_src_data->status_cb.cadence_status.sensor_cadence_value->len;
p_dest_data->status_cb.cadence_status.sensor_cadence_value = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.cadence_status.sensor_cadence_value) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.cadence_status.sensor_cadence_value,
@ -238,7 +304,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
length = p_src_data->status_cb.settings_status.sensor_setting_property_ids->len;
p_dest_data->status_cb.settings_status.sensor_setting_property_ids = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.settings_status.sensor_setting_property_ids) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.settings_status.sensor_setting_property_ids,
@ -253,7 +319,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
length = p_src_data->status_cb.setting_status.sensor_setting_raw->len;
p_dest_data->status_cb.setting_status.sensor_setting_raw = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.setting_status.sensor_setting_raw) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.setting_status.sensor_setting_raw,
@ -267,7 +333,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
length = p_src_data->status_cb.sensor_status.marshalled_sensor_data->len;
p_dest_data->status_cb.sensor_status.marshalled_sensor_data = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.sensor_status.marshalled_sensor_data) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.sensor_status.marshalled_sensor_data,
@ -281,7 +347,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
length = p_src_data->status_cb.column_status.sensor_column_value->len;
p_dest_data->status_cb.column_status.sensor_column_value = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.column_status.sensor_column_value) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.column_status.sensor_column_value,
@ -295,7 +361,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
length = p_src_data->status_cb.series_status.sensor_series_value->len;
p_dest_data->status_cb.series_status.sensor_series_value = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.series_status.sensor_series_value) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.series_status.sensor_series_value,
@ -308,27 +374,18 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
}
}
case ESP_BLE_MESH_SENSOR_CLIENT_TIMEOUT_EVT:
if (p_src_data->params) {
p_dest_data->params = osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (p_dest_data->params) {
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
}
break;
default:
break;
}
}
static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
static void btc_ble_mesh_sensor_client_free_req_data(btc_msg_t *msg)
{
esp_ble_mesh_sensor_client_cb_param_t *arg = NULL;
u32_t opcode;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -339,8 +396,7 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
case ESP_BLE_MESH_SENSOR_CLIENT_SET_STATE_EVT:
case ESP_BLE_MESH_SENSOR_CLIENT_PUBLISH_EVT:
if (arg->params) {
opcode = arg->params->opcode;
switch (opcode) {
switch (arg->params->opcode) {
case ESP_BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_GET:
case ESP_BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_STATUS:
bt_mesh_free_buf(arg->status_cb.descriptor_status.descriptor);
@ -377,7 +433,7 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
}
case ESP_BLE_MESH_SENSOR_CLIENT_TIMEOUT_EVT:
if (arg->params) {
osi_free(arg->params);
bt_mesh_free(arg->params);
}
break;
default:
@ -385,116 +441,54 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
}
}
void btc_ble_mesh_sensor_client_arg_deep_free(btc_msg_t *msg)
{
btc_ble_mesh_sensor_client_args_t *arg = NULL;
u32_t opcode = 0;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
arg = (btc_ble_mesh_sensor_client_args_t *)(msg->arg);
switch (msg->act) {
case BTC_BLE_MESH_ACT_SENSOR_CLIENT_GET_STATE:
if (arg->sensor_client_get_state.params) {
opcode = arg->sensor_client_get_state.params->opcode;
osi_free(arg->sensor_client_get_state.params);
}
if (arg->sensor_client_get_state.get_state) {
if (opcode) {
switch (opcode) {
case ESP_BLE_MESH_MODEL_OP_SENSOR_COLUMN_GET:
bt_mesh_free_buf(arg->sensor_client_get_state.get_state->column_get.raw_value_x);
break;
case ESP_BLE_MESH_MODEL_OP_SENSOR_SERIES_GET:
bt_mesh_free_buf(arg->sensor_client_get_state.get_state->series_get.raw_value_x1);
bt_mesh_free_buf(arg->sensor_client_get_state.get_state->series_get.raw_value_x2);
break;
default:
break;
}
}
osi_free(arg->sensor_client_get_state.get_state);
}
break;
case BTC_BLE_MESH_ACT_SENSOR_CLIENT_SET_STATE:
if (arg->sensor_client_set_state.params) {
opcode = arg->sensor_client_set_state.params->opcode;
osi_free(arg->sensor_client_set_state.params);
}
if (arg->sensor_client_set_state.set_state) {
if (opcode) {
switch (opcode) {
case ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET:
bt_mesh_free_buf(arg->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down);
bt_mesh_free_buf(arg->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_up);
bt_mesh_free_buf(arg->sensor_client_set_state.set_state->cadence_set.fast_cadence_low);
bt_mesh_free_buf(arg->sensor_client_set_state.set_state->cadence_set.fast_cadence_high);
break;
case ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET:
bt_mesh_free_buf(arg->sensor_client_set_state.set_state->setting_set.sensor_setting_raw);
break;
default:
break;
}
}
osi_free(arg->sensor_client_set_state.set_state);
}
break;
default:
break;
}
return;
}
static void btc_mesh_sensor_client_callback(esp_ble_mesh_sensor_client_cb_param_t *cb_params, uint8_t act)
static void btc_ble_mesh_sensor_client_callback(esp_ble_mesh_sensor_client_cb_param_t *cb_params, uint8_t act)
{
btc_msg_t msg = {0};
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
/* If corresponding callback is not registered, event will not be posted. */
if (!btc_profile_cb_get(BTC_PID_SENSOR_CLIENT)) {
return;
}
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_SENSOR_CLIENT;
msg.act = act;
btc_transfer_context(&msg, cb_params,
sizeof(esp_ble_mesh_sensor_client_cb_param_t), btc_ble_mesh_copy_req_data);
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_sensor_client_cb_param_t),
btc_ble_mesh_sensor_client_copy_req_data);
}
void bt_mesh_callback_sensor_status_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len)
void bt_mesh_sensor_client_cb_evt_to_btc(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)
{
esp_ble_mesh_sensor_client_cb_param_t cb_params = {0};
esp_ble_mesh_client_common_param_t params = {0};
size_t length;
uint8_t act;
uint8_t act = 0U;
if (!model || !ctx) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (evt_type) {
case 0x00:
case BTC_BLE_MESH_EVT_SENSOR_CLIENT_GET_STATE:
act = ESP_BLE_MESH_SENSOR_CLIENT_GET_STATE_EVT;
break;
case 0x01:
case BTC_BLE_MESH_EVT_SENSOR_CLIENT_SET_STATE:
act = ESP_BLE_MESH_SENSOR_CLIENT_SET_STATE_EVT;
break;
case 0x02:
case BTC_BLE_MESH_EVT_SENSOR_CLIENT_PUBLISH:
act = ESP_BLE_MESH_SENSOR_CLIENT_PUBLISH_EVT;
break;
case 0x03:
case BTC_BLE_MESH_EVT_SENSOR_CLIENT_TIMEOUT:
act = ESP_BLE_MESH_SENSOR_CLIENT_TIMEOUT_EVT;
break;
default:
LOG_ERROR("%s, Unknown sensor client event type %d", __func__, evt_type);
BT_ERR("Unknown Sensor client event type %d", evt_type);
return;
}
@ -506,39 +500,43 @@ void bt_mesh_callback_sensor_status_to_btc(u32_t opcode, u8_t evt_type,
params.ctx.recv_ttl = ctx->recv_ttl;
params.ctx.recv_op = ctx->recv_op;
params.ctx.recv_dst = ctx->recv_dst;
params.ctx.recv_rssi = ctx->recv_rssi;
params.ctx.send_ttl = ctx->send_ttl;
cb_params.error_code = 0;
cb_params.params = &params;
if (val && len) {
length = (len <= sizeof(cb_params.status_cb)) ? len : sizeof(cb_params.status_cb);
memcpy(&cb_params.status_cb, val, length);
memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb)));
}
btc_mesh_sensor_client_callback(&cb_params, act);
btc_ble_mesh_sensor_client_callback(&cb_params, act);
return;
}
void btc_mesh_sensor_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf)
void btc_ble_mesh_sensor_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
if (!model || !ctx || !buf) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
bt_mesh_callback_sensor_status_to_btc(opcode, 0x02, model, ctx, buf->data, buf->len);
bt_mesh_sensor_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_SENSOR_CLIENT_PUBLISH,
model, ctx, buf->data, buf->len);
return;
}
void btc_mesh_sensor_client_call_handler(btc_msg_t *msg)
void btc_ble_mesh_sensor_client_call_handler(btc_msg_t *msg)
{
esp_ble_mesh_sensor_client_cb_param_t sensor_client_cb = {0};
esp_ble_mesh_client_common_param_t *params = NULL;
btc_ble_mesh_sensor_client_args_t *arg = NULL;
struct bt_mesh_common_param common = {0};
bt_mesh_role_param_t role_param = {0};
esp_ble_mesh_sensor_client_cb_param_t cb = {0};
bt_mesh_client_common_param_t common = {0};
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -547,12 +545,6 @@ void btc_mesh_sensor_client_call_handler(btc_msg_t *msg)
switch (msg->act) {
case BTC_BLE_MESH_ACT_SENSOR_CLIENT_GET_STATE: {
params = arg->sensor_client_get_state.params;
role_param.model = (struct bt_mesh_model *)params->model;
role_param.role = params->msg_role;
if (bt_mesh_set_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
return;
}
common.opcode = params->opcode;
common.model = (struct bt_mesh_model *)params->model;
common.ctx.net_idx = params->ctx.net_idx;
@ -561,27 +553,18 @@ void btc_mesh_sensor_client_call_handler(btc_msg_t *msg)
common.ctx.send_rel = params->ctx.send_rel;
common.ctx.send_ttl = params->ctx.send_ttl;
common.msg_timeout = params->msg_timeout;
common.msg_role = params->msg_role;
sensor_client_cb.params = arg->sensor_client_get_state.params;
sensor_client_cb.error_code =
bt_mesh_sensor_client_get_state(&common,
(void *)arg->sensor_client_get_state.get_state,
(void *)&sensor_client_cb.status_cb);
if (sensor_client_cb.error_code) {
cb.params = arg->sensor_client_get_state.params;
cb.error_code = bt_mesh_sensor_client_get_state(&common, arg->sensor_client_get_state.get_state);
if (cb.error_code) {
/* If send failed, callback error_code to app layer immediately */
btc_mesh_sensor_client_callback(&sensor_client_cb,
ESP_BLE_MESH_SENSOR_CLIENT_GET_STATE_EVT);
btc_ble_mesh_sensor_client_callback(&cb, ESP_BLE_MESH_SENSOR_CLIENT_GET_STATE_EVT);
}
break;
}
case BTC_BLE_MESH_ACT_SENSOR_CLIENT_SET_STATE: {
params = arg->sensor_client_set_state.params;
role_param.model = (struct bt_mesh_model *)params->model;
role_param.role = params->msg_role;
if (bt_mesh_set_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
return;
}
common.opcode = params->opcode;
common.model = (struct bt_mesh_model *)params->model;
common.ctx.net_idx = params->ctx.net_idx;
@ -590,16 +573,13 @@ void btc_mesh_sensor_client_call_handler(btc_msg_t *msg)
common.ctx.send_rel = params->ctx.send_rel;
common.ctx.send_ttl = params->ctx.send_ttl;
common.msg_timeout = params->msg_timeout;
common.msg_role = params->msg_role;
sensor_client_cb.params = arg->sensor_client_set_state.params;
sensor_client_cb.error_code =
bt_mesh_sensor_client_set_state(&common,
(void *)arg->sensor_client_set_state.set_state,
(void *)&sensor_client_cb.status_cb);
if (sensor_client_cb.error_code) {
cb.params = arg->sensor_client_set_state.params;
cb.error_code = bt_mesh_sensor_client_set_state(&common, arg->sensor_client_set_state.set_state);
if (cb.error_code) {
/* If send failed, callback error_code to app layer immediately */
btc_mesh_sensor_client_callback(&sensor_client_cb,
ESP_BLE_MESH_SENSOR_CLIENT_SET_STATE_EVT);
btc_ble_mesh_sensor_client_callback(&cb, ESP_BLE_MESH_SENSOR_CLIENT_SET_STATE_EVT);
}
break;
}
@ -608,25 +588,303 @@ void btc_mesh_sensor_client_call_handler(btc_msg_t *msg)
}
btc_ble_mesh_sensor_client_arg_deep_free(msg);
return;
}
void btc_mesh_sensor_client_cb_handler(btc_msg_t *msg)
void btc_ble_mesh_sensor_client_cb_handler(btc_msg_t *msg)
{
esp_ble_mesh_sensor_client_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
param = (esp_ble_mesh_sensor_client_cb_param_t *)(msg->arg);
if (msg->act < ESP_BLE_MESH_SENSOR_CLIENT_EVT_MAX) {
btc_ble_mesh_cb_to_app(msg->act, param);
btc_ble_mesh_sensor_client_cb_to_app(msg->act, param);
} else {
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
BT_ERR("%s, Unknown act %d", __func__, msg->act);
}
btc_ble_mesh_free_req_data(msg);
btc_ble_mesh_sensor_client_free_req_data(msg);
return;
}
/* Sensor Server Models related functions */
static inline void btc_ble_mesh_sensor_server_cb_to_app(esp_ble_mesh_sensor_server_cb_event_t event,
esp_ble_mesh_sensor_server_cb_param_t *param)
{
esp_ble_mesh_sensor_server_cb_t btc_ble_mesh_cb =
(esp_ble_mesh_sensor_server_cb_t)btc_profile_cb_get(BTC_PID_SENSOR_SERVER);
if (btc_ble_mesh_cb) {
btc_ble_mesh_cb(event, param);
}
}
static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
{
esp_ble_mesh_sensor_server_cb_param_t *p_dest_data = (esp_ble_mesh_sensor_server_cb_param_t *)p_dest;
esp_ble_mesh_sensor_server_cb_param_t *p_src_data = (esp_ble_mesh_sensor_server_cb_param_t *)p_src;
u16_t length = 0U;
if (!msg || !p_src_data || !p_dest_data) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (msg->act) {
case ESP_BLE_MESH_SENSOR_SERVER_STATE_CHANGE_EVT:
if (p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET ||
p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET_UNACK) {
if (p_src_data->value.state_change.sensor_cadence_set.trigger_delta_down) {
length = p_src_data->value.state_change.sensor_cadence_set.trigger_delta_down->len;
p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_down = bt_mesh_alloc_buf(length);
if (p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_down == NULL) {
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_down,
p_src_data->value.state_change.sensor_cadence_set.trigger_delta_down->data,
p_src_data->value.state_change.sensor_cadence_set.trigger_delta_down->len);
}
if (p_src_data->value.state_change.sensor_cadence_set.trigger_delta_up) {
length = p_src_data->value.state_change.sensor_cadence_set.trigger_delta_up->len;
p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_up = bt_mesh_alloc_buf(length);
if (p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_up == NULL) {
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_up,
p_src_data->value.state_change.sensor_cadence_set.trigger_delta_up->data,
p_src_data->value.state_change.sensor_cadence_set.trigger_delta_up->len);
}
if (p_src_data->value.state_change.sensor_cadence_set.fast_cadence_low) {
length = p_src_data->value.state_change.sensor_cadence_set.fast_cadence_low->len;
p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_low = bt_mesh_alloc_buf(length);
if (p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_low == NULL) {
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_low,
p_src_data->value.state_change.sensor_cadence_set.fast_cadence_low->data,
p_src_data->value.state_change.sensor_cadence_set.fast_cadence_low->len);
}
if (p_src_data->value.state_change.sensor_cadence_set.fast_cadence_high) {
length = p_src_data->value.state_change.sensor_cadence_set.fast_cadence_high->len;
p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_high = bt_mesh_alloc_buf(length);
if (p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_high == NULL) {
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_high,
p_src_data->value.state_change.sensor_cadence_set.fast_cadence_high->data,
p_src_data->value.state_change.sensor_cadence_set.fast_cadence_high->len);
}
} else if (p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET ||
p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET_UNACK) {
if (p_src_data->value.state_change.sensor_setting_set.setting_value) {
length = p_src_data->value.state_change.sensor_setting_set.setting_value->len;
p_dest_data->value.state_change.sensor_setting_set.setting_value = bt_mesh_alloc_buf(length);
if (p_dest_data->value.state_change.sensor_setting_set.setting_value == NULL) {
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.state_change.sensor_setting_set.setting_value,
p_src_data->value.state_change.sensor_setting_set.setting_value->data,
p_src_data->value.state_change.sensor_setting_set.setting_value->len);
}
}
break;
case ESP_BLE_MESH_SENSOR_SERVER_RECV_GET_MSG_EVT:
if (p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_COLUMN_GET) {
if (p_src_data->value.get.sensor_column.raw_value_x) {
length = p_src_data->value.get.sensor_column.raw_value_x->len;
p_dest_data->value.get.sensor_column.raw_value_x = bt_mesh_alloc_buf(length);
if (p_dest_data->value.get.sensor_column.raw_value_x == NULL) {
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.get.sensor_column.raw_value_x,
p_src_data->value.get.sensor_column.raw_value_x->data,
p_src_data->value.get.sensor_column.raw_value_x->len);
}
} else if (p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_SERIES_GET) {
if (p_src_data->value.get.sensor_series.raw_value) {
length = p_src_data->value.get.sensor_series.raw_value->len;
p_dest_data->value.get.sensor_series.raw_value = bt_mesh_alloc_buf(length);
if (p_dest_data->value.get.sensor_series.raw_value == NULL) {
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.get.sensor_series.raw_value,
p_src_data->value.get.sensor_series.raw_value->data,
p_src_data->value.get.sensor_series.raw_value->len);
}
}
break;
case ESP_BLE_MESH_SENSOR_SERVER_RECV_SET_MSG_EVT:
if (p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET ||
p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET_UNACK) {
if (p_src_data->value.set.sensor_cadence.cadence) {
length = p_src_data->value.set.sensor_cadence.cadence->len;
p_dest_data->value.set.sensor_cadence.cadence = bt_mesh_alloc_buf(length);
if (p_dest_data->value.set.sensor_cadence.cadence == NULL) {
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.set.sensor_cadence.cadence,
p_src_data->value.set.sensor_cadence.cadence->data,
p_src_data->value.set.sensor_cadence.cadence->len);
}
} else if (p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET ||
p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET_UNACK) {
if (p_src_data->value.set.sensor_setting.setting_raw) {
length = p_src_data->value.set.sensor_setting.setting_raw->len;
p_dest_data->value.set.sensor_setting.setting_raw = bt_mesh_alloc_buf(length);
if (p_dest_data->value.set.sensor_setting.setting_raw == NULL) {
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->value.set.sensor_setting.setting_raw,
p_src_data->value.set.sensor_setting.setting_raw->data,
p_src_data->value.set.sensor_setting.setting_raw->len);
}
}
break;
default:
break;
}
}
static void btc_ble_mesh_sensor_server_free_req_data(btc_msg_t *msg)
{
esp_ble_mesh_sensor_server_cb_param_t *arg = NULL;
if (!msg || !msg->arg) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
arg = (esp_ble_mesh_sensor_server_cb_param_t *)(msg->arg);
switch (msg->act) {
case ESP_BLE_MESH_SENSOR_SERVER_STATE_CHANGE_EVT:
if (arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET ||
arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET_UNACK) {
bt_mesh_free_buf(arg->value.state_change.sensor_cadence_set.trigger_delta_down);
bt_mesh_free_buf(arg->value.state_change.sensor_cadence_set.trigger_delta_up);
bt_mesh_free_buf(arg->value.state_change.sensor_cadence_set.fast_cadence_low);
bt_mesh_free_buf(arg->value.state_change.sensor_cadence_set.fast_cadence_high);
} else if (arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET ||
arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET_UNACK) {
bt_mesh_free_buf(arg->value.state_change.sensor_setting_set.setting_value);
}
break;
case ESP_BLE_MESH_SENSOR_SERVER_RECV_GET_MSG_EVT:
if (arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_COLUMN_GET) {
bt_mesh_free_buf(arg->value.get.sensor_column.raw_value_x);
} else if (arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_SERIES_GET) {
bt_mesh_free_buf(arg->value.get.sensor_series.raw_value);
}
break;
case ESP_BLE_MESH_SENSOR_SERVER_RECV_SET_MSG_EVT:
if (arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET ||
arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET_UNACK) {
bt_mesh_free_buf(arg->value.set.sensor_cadence.cadence);
} else if (arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET ||
arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET_UNACK) {
bt_mesh_free_buf(arg->value.set.sensor_setting.setting_raw);
}
break;
default:
break;
}
}
static void btc_ble_mesh_sensor_server_callback(esp_ble_mesh_sensor_server_cb_param_t *cb_params, uint8_t act)
{
btc_msg_t msg = {0};
BT_DBG("%s", __func__);
/* If corresponding callback is not registered, event will not be posted. */
if (!btc_profile_cb_get(BTC_PID_SENSOR_SERVER)) {
return;
}
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_SENSOR_SERVER;
msg.act = act;
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_sensor_server_cb_param_t),
btc_ble_mesh_sensor_server_copy_req_data);
}
void bt_mesh_sensor_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len)
{
esp_ble_mesh_sensor_server_cb_param_t cb_params = {0};
uint8_t act = 0U;
if (model == NULL || ctx == NULL) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (evt_type) {
case BTC_BLE_MESH_EVT_SENSOR_SERVER_STATE_CHANGE:
act = ESP_BLE_MESH_SENSOR_SERVER_STATE_CHANGE_EVT;
break;
case BTC_BLE_MESH_EVT_SENSOR_SERVER_RECV_GET_MSG:
act = ESP_BLE_MESH_SENSOR_SERVER_RECV_GET_MSG_EVT;
break;
case BTC_BLE_MESH_EVT_SENSOR_SERVER_RECV_SET_MSG:
act = ESP_BLE_MESH_SENSOR_SERVER_RECV_SET_MSG_EVT;
break;
default:
BT_ERR("Unknown Sensor server event type %d", evt_type);
return;
}
cb_params.model = (esp_ble_mesh_model_t *)model;
cb_params.ctx.net_idx = ctx->net_idx;
cb_params.ctx.app_idx = ctx->app_idx;
cb_params.ctx.addr = ctx->addr;
cb_params.ctx.recv_ttl = ctx->recv_ttl;
cb_params.ctx.recv_op = ctx->recv_op;
cb_params.ctx.recv_dst = ctx->recv_dst;
cb_params.ctx.recv_rssi = ctx->recv_rssi;
cb_params.ctx.send_ttl = ctx->send_ttl;
if (val && len) {
memcpy(&cb_params.value, val, MIN(len, sizeof(cb_params.value)));
}
btc_ble_mesh_sensor_server_callback(&cb_params, act);
return;
}
void btc_ble_mesh_sensor_server_cb_handler(btc_msg_t *msg)
{
esp_ble_mesh_sensor_server_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
param = (esp_ble_mesh_sensor_server_cb_param_t *)(msg->arg);
if (msg->act < ESP_BLE_MESH_SENSOR_SERVER_EVT_MAX) {
btc_ble_mesh_sensor_server_cb_to_app(msg->act, param);
} else {
BT_ERR("%s, Unknown act %d", __func__, msg->act);
}
btc_ble_mesh_sensor_server_free_req_data(msg);
return;
}

View File

@ -15,19 +15,19 @@
#include <string.h>
#include <errno.h>
#include "btc/btc_manage.h"
#include "osi/allocator.h"
#include "time_scene_client.h"
#include "btc_ble_mesh_time_scene_model.h"
#include "time_scene_client.h"
#include "esp_ble_mesh_time_scene_model_api.h"
static inline void btc_ble_mesh_cb_to_app(esp_ble_mesh_time_scene_client_cb_event_t event,
esp_ble_mesh_time_scene_client_cb_param_t *param)
/* Time and Scenes Client Models related functions */
static inline void btc_ble_mesh_time_scene_client_cb_to_app(esp_ble_mesh_time_scene_client_cb_event_t event,
esp_ble_mesh_time_scene_client_cb_param_t *param)
{
esp_ble_mesh_time_scene_client_cb_t btc_mesh_cb = (esp_ble_mesh_time_scene_client_cb_t)btc_profile_cb_get(BTC_PID_TIME_SCENE_CLIENT);
if (btc_mesh_cb) {
btc_mesh_cb(event, param);
esp_ble_mesh_time_scene_client_cb_t btc_ble_mesh_cb =
(esp_ble_mesh_time_scene_client_cb_t)btc_profile_cb_get(BTC_PID_TIME_SCENE_CLIENT);
if (btc_ble_mesh_cb) {
btc_ble_mesh_cb(event, param);
}
}
@ -37,62 +37,110 @@ void btc_ble_mesh_time_scene_client_arg_deep_copy(btc_msg_t *msg, void *p_dest,
btc_ble_mesh_time_scene_client_args_t *src = (btc_ble_mesh_time_scene_client_args_t *)p_src;
if (!msg || !dst || !src) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (msg->act) {
case BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_GET_STATE: {
dst->time_scene_client_get_state.params = (esp_ble_mesh_client_common_param_t *)osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
dst->time_scene_client_get_state.get_state = (esp_ble_mesh_time_scene_client_get_state_t *)osi_malloc(sizeof(esp_ble_mesh_time_scene_client_get_state_t));
if (dst->time_scene_client_get_state.params && dst->time_scene_client_get_state.get_state) {
dst->time_scene_client_get_state.params = (esp_ble_mesh_client_common_param_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (dst->time_scene_client_get_state.params) {
memcpy(dst->time_scene_client_get_state.params, src->time_scene_client_get_state.params,
sizeof(esp_ble_mesh_client_common_param_t));
memcpy(dst->time_scene_client_get_state.get_state, src->time_scene_client_get_state.get_state,
sizeof(esp_ble_mesh_time_scene_client_get_state_t));
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
break;
}
if (src->time_scene_client_get_state.get_state) {
dst->time_scene_client_get_state.get_state = (esp_ble_mesh_time_scene_client_get_state_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_time_scene_client_get_state_t));
if (dst->time_scene_client_get_state.get_state) {
memcpy(dst->time_scene_client_get_state.get_state, src->time_scene_client_get_state.get_state,
sizeof(esp_ble_mesh_time_scene_client_get_state_t));
} else {
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
}
}
break;
}
case BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_SET_STATE: {
dst->time_scene_client_set_state.params = (esp_ble_mesh_client_common_param_t *)osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
dst->time_scene_client_set_state.set_state = (esp_ble_mesh_time_scene_client_set_state_t *)osi_malloc(sizeof(esp_ble_mesh_time_scene_client_set_state_t));
dst->time_scene_client_set_state.params = (esp_ble_mesh_client_common_param_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
dst->time_scene_client_set_state.set_state = (esp_ble_mesh_time_scene_client_set_state_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_time_scene_client_set_state_t));
if (dst->time_scene_client_set_state.params && dst->time_scene_client_set_state.set_state) {
memcpy(dst->time_scene_client_set_state.params, src->time_scene_client_set_state.params,
sizeof(esp_ble_mesh_client_common_param_t));
memcpy(dst->time_scene_client_set_state.set_state, src->time_scene_client_set_state.set_state,
sizeof(esp_ble_mesh_time_scene_client_set_state_t));
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
}
break;
}
default:
LOG_DEBUG("%s, Unknown deep copy act %d", __func__, msg->act);
BT_DBG("%s, Unknown act %d", __func__, msg->act);
break;
}
}
static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
void btc_ble_mesh_time_scene_client_arg_deep_free(btc_msg_t *msg)
{
btc_ble_mesh_time_scene_client_args_t *arg = NULL;
if (!msg || !msg->arg) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
arg = (btc_ble_mesh_time_scene_client_args_t *)(msg->arg);
switch (msg->act) {
case BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_GET_STATE:
if (arg->time_scene_client_get_state.params) {
bt_mesh_free(arg->time_scene_client_get_state.params);
}
if (arg->time_scene_client_get_state.get_state) {
bt_mesh_free(arg->time_scene_client_get_state.get_state);
}
break;
case BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_SET_STATE:
if (arg->time_scene_client_set_state.params) {
bt_mesh_free(arg->time_scene_client_set_state.params);
}
if (arg->time_scene_client_set_state.set_state) {
bt_mesh_free(arg->time_scene_client_set_state.set_state);
}
break;
default:
break;
}
}
static void btc_ble_mesh_time_scene_client_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
{
esp_ble_mesh_time_scene_client_cb_param_t *p_dest_data = (esp_ble_mesh_time_scene_client_cb_param_t *)p_dest;
esp_ble_mesh_time_scene_client_cb_param_t *p_src_data = (esp_ble_mesh_time_scene_client_cb_param_t *)p_src;
u32_t opcode;
u16_t length;
u16_t length = 0U;
if (!msg || !p_src_data || !p_dest_data) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
if (p_src_data->params) {
p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (!p_dest_data->params) {
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
}
switch (msg->act) {
case ESP_BLE_MESH_TIME_SCENE_CLIENT_GET_STATE_EVT:
case ESP_BLE_MESH_TIME_SCENE_CLIENT_SET_STATE_EVT:
case ESP_BLE_MESH_TIME_SCENE_CLIENT_PUBLISH_EVT:
if (p_src_data->params) {
opcode = p_src_data->params->opcode;
switch (opcode) {
switch (p_src_data->params->opcode) {
case ESP_BLE_MESH_MODEL_OP_SCENE_STORE:
case ESP_BLE_MESH_MODEL_OP_SCENE_REGISTER_GET:
case ESP_BLE_MESH_MODEL_OP_SCENE_DELETE:
@ -101,7 +149,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
length = p_src_data->status_cb.scene_register_status.scenes->len;
p_dest_data->status_cb.scene_register_status.scenes = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.scene_register_status.scenes) {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_add_mem(p_dest_data->status_cb.scene_register_status.scenes,
@ -114,27 +162,18 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
}
}
case ESP_BLE_MESH_TIME_SCENE_CLIENT_TIMEOUT_EVT:
if (p_src_data->params) {
p_dest_data->params = osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
if (p_dest_data->params) {
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
} else {
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
}
break;
default:
break;
}
}
static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
static void btc_ble_mesh_time_scene_client_free_req_data(btc_msg_t *msg)
{
esp_ble_mesh_time_scene_client_cb_param_t *arg = NULL;
u32_t opcode;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -145,8 +184,7 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
case ESP_BLE_MESH_TIME_SCENE_CLIENT_SET_STATE_EVT:
case ESP_BLE_MESH_TIME_SCENE_CLIENT_PUBLISH_EVT:
if (arg->params) {
opcode = arg->params->opcode;
switch (opcode) {
switch (arg->params->opcode) {
case ESP_BLE_MESH_MODEL_OP_SCENE_STORE:
case ESP_BLE_MESH_MODEL_OP_SCENE_REGISTER_GET:
case ESP_BLE_MESH_MODEL_OP_SCENE_DELETE:
@ -159,7 +197,7 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
}
case ESP_BLE_MESH_TIME_SCENE_CLIENT_TIMEOUT_EVT:
if (arg->params) {
osi_free(arg->params);
bt_mesh_free(arg->params);
}
break;
default:
@ -167,85 +205,54 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
}
}
void btc_ble_mesh_time_scene_client_arg_deep_free(btc_msg_t *msg)
{
btc_ble_mesh_time_scene_client_args_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
arg = (btc_ble_mesh_time_scene_client_args_t *)(msg->arg);
switch (msg->act) {
case BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_GET_STATE:
if (arg->time_scene_client_get_state.params) {
osi_free(arg->time_scene_client_get_state.params);
}
if (arg->time_scene_client_get_state.get_state) {
osi_free(arg->time_scene_client_get_state.get_state);
}
break;
case BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_SET_STATE:
if (arg->time_scene_client_set_state.params) {
osi_free(arg->time_scene_client_set_state.params);
}
if (arg->time_scene_client_set_state.set_state) {
osi_free(arg->time_scene_client_set_state.set_state);
}
break;
default:
break;
}
return;
}
static void btc_mesh_time_scene_client_callback(esp_ble_mesh_time_scene_client_cb_param_t *cb_params, uint8_t act)
static void btc_ble_mesh_time_scene_client_callback(esp_ble_mesh_time_scene_client_cb_param_t *cb_params, uint8_t act)
{
btc_msg_t msg = {0};
LOG_DEBUG("%s", __func__);
BT_DBG("%s", __func__);
/* If corresponding callback is not registered, event will not be posted. */
if (!btc_profile_cb_get(BTC_PID_TIME_SCENE_CLIENT)) {
return;
}
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_TIME_SCENE_CLIENT;
msg.act = act;
btc_transfer_context(&msg, cb_params,
sizeof(esp_ble_mesh_time_scene_client_cb_param_t), btc_ble_mesh_copy_req_data);
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_time_scene_client_cb_param_t),
btc_ble_mesh_time_scene_client_copy_req_data);
}
void bt_mesh_callback_time_scene_status_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len)
void bt_mesh_time_scene_client_cb_evt_to_btc(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)
{
esp_ble_mesh_time_scene_client_cb_param_t cb_params = {0};
esp_ble_mesh_client_common_param_t params = {0};
size_t length;
uint8_t act;
uint8_t act = 0U;
if (!model || !ctx) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (evt_type) {
case 0x00:
case BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_GET_STATE:
act = ESP_BLE_MESH_TIME_SCENE_CLIENT_GET_STATE_EVT;
break;
case 0x01:
case BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_SET_STATE:
act = ESP_BLE_MESH_TIME_SCENE_CLIENT_SET_STATE_EVT;
break;
case 0x02:
case BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_PUBLISH:
act = ESP_BLE_MESH_TIME_SCENE_CLIENT_PUBLISH_EVT;
break;
case 0x03:
case BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_TIMEOUT:
act = ESP_BLE_MESH_TIME_SCENE_CLIENT_TIMEOUT_EVT;
break;
default:
LOG_ERROR("%s, Unknown time scene client event type %d", __func__, evt_type);
BT_ERR("Unknown Time Scene client event type %d", evt_type);
return;
}
@ -257,39 +264,43 @@ void bt_mesh_callback_time_scene_status_to_btc(u32_t opcode, u8_t evt_type,
params.ctx.recv_ttl = ctx->recv_ttl;
params.ctx.recv_op = ctx->recv_op;
params.ctx.recv_dst = ctx->recv_dst;
params.ctx.recv_rssi = ctx->recv_rssi;
params.ctx.send_ttl = ctx->send_ttl;
cb_params.error_code = 0;
cb_params.params = &params;
if (val && len) {
length = (len <= sizeof(cb_params.status_cb)) ? len : sizeof(cb_params.status_cb);
memcpy(&cb_params.status_cb, val, length);
memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb)));
}
btc_mesh_time_scene_client_callback(&cb_params, act);
btc_ble_mesh_time_scene_client_callback(&cb_params, act);
return;
}
void btc_mesh_time_scene_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf)
void btc_ble_mesh_time_scene_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf)
{
if (!model || !ctx || !buf) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
bt_mesh_callback_time_scene_status_to_btc(opcode, 0x02, model, ctx, buf->data, buf->len);
bt_mesh_time_scene_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_PUBLISH,
model, ctx, buf->data, buf->len);
return;
}
void btc_mesh_time_scene_client_call_handler(btc_msg_t *msg)
void btc_ble_mesh_time_scene_client_call_handler(btc_msg_t *msg)
{
esp_ble_mesh_time_scene_client_cb_param_t time_scene_client_cb = {0};
btc_ble_mesh_time_scene_client_args_t *arg = NULL;
esp_ble_mesh_client_common_param_t *params = NULL;
struct bt_mesh_common_param common = {0};
bt_mesh_role_param_t role_param = {0};
esp_ble_mesh_time_scene_client_cb_param_t cb = {0};
bt_mesh_client_common_param_t common = {0};
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
@ -298,12 +309,6 @@ void btc_mesh_time_scene_client_call_handler(btc_msg_t *msg)
switch (msg->act) {
case BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_GET_STATE: {
params = arg->time_scene_client_get_state.params;
role_param.model = (struct bt_mesh_model *)params->model;
role_param.role = params->msg_role;
if (bt_mesh_set_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
return;
}
common.opcode = params->opcode;
common.model = (struct bt_mesh_model *)params->model;
common.ctx.net_idx = params->ctx.net_idx;
@ -312,27 +317,18 @@ void btc_mesh_time_scene_client_call_handler(btc_msg_t *msg)
common.ctx.send_rel = params->ctx.send_rel;
common.ctx.send_ttl = params->ctx.send_ttl;
common.msg_timeout = params->msg_timeout;
common.msg_role = params->msg_role;
time_scene_client_cb.params = arg->time_scene_client_get_state.params;
time_scene_client_cb.error_code =
bt_mesh_time_scene_client_get_state(&common,
(void *)arg->time_scene_client_get_state.get_state,
(void *)&time_scene_client_cb.status_cb);
if (time_scene_client_cb.error_code) {
cb.params = arg->time_scene_client_get_state.params;
cb.error_code = bt_mesh_time_scene_client_get_state(&common, arg->time_scene_client_get_state.get_state);
if (cb.error_code) {
/* If send failed, callback error_code to app layer immediately */
btc_mesh_time_scene_client_callback(&time_scene_client_cb,
ESP_BLE_MESH_TIME_SCENE_CLIENT_GET_STATE_EVT);
btc_ble_mesh_time_scene_client_callback(&cb, ESP_BLE_MESH_TIME_SCENE_CLIENT_GET_STATE_EVT);
}
break;
}
case BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_SET_STATE: {
params = arg->time_scene_client_set_state.params;
role_param.model = (struct bt_mesh_model *)params->model;
role_param.role = params->msg_role;
if (bt_mesh_set_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
return;
}
common.opcode = params->opcode;
common.model = (struct bt_mesh_model *)params->model;
common.ctx.net_idx = params->ctx.net_idx;
@ -341,16 +337,13 @@ void btc_mesh_time_scene_client_call_handler(btc_msg_t *msg)
common.ctx.send_rel = params->ctx.send_rel;
common.ctx.send_ttl = params->ctx.send_ttl;
common.msg_timeout = params->msg_timeout;
common.msg_role = params->msg_role;
time_scene_client_cb.params = arg->time_scene_client_set_state.params;
time_scene_client_cb.error_code =
bt_mesh_time_scene_client_set_state(&common,
(void *)arg->time_scene_client_set_state.set_state,
(void *)&time_scene_client_cb.status_cb);
if (time_scene_client_cb.error_code) {
cb.params = arg->time_scene_client_set_state.params;
cb.error_code = bt_mesh_time_scene_client_set_state(&common, arg->time_scene_client_set_state.set_state);
if (cb.error_code) {
/* If send failed, callback error_code to app layer immediately */
btc_mesh_time_scene_client_callback(&time_scene_client_cb,
ESP_BLE_MESH_TIME_SCENE_CLIENT_SET_STATE_EVT);
btc_ble_mesh_time_scene_client_callback(&cb, ESP_BLE_MESH_TIME_SCENE_CLIENT_SET_STATE_EVT);
}
break;
}
@ -359,25 +352,125 @@ void btc_mesh_time_scene_client_call_handler(btc_msg_t *msg)
}
btc_ble_mesh_time_scene_client_arg_deep_free(msg);
return;
}
void btc_mesh_time_scene_client_cb_handler(btc_msg_t *msg)
void btc_ble_mesh_time_scene_client_cb_handler(btc_msg_t *msg)
{
esp_ble_mesh_time_scene_client_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s, Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
param = (esp_ble_mesh_time_scene_client_cb_param_t *)(msg->arg);
if (msg->act < ESP_BLE_MESH_TIME_SCENE_CLIENT_EVT_MAX) {
btc_ble_mesh_cb_to_app(msg->act, param);
btc_ble_mesh_time_scene_client_cb_to_app(msg->act, param);
} else {
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
BT_ERR("%s, Unknown act %d", __func__, msg->act);
}
btc_ble_mesh_free_req_data(msg);
btc_ble_mesh_time_scene_client_free_req_data(msg);
return;
}
/* Time and Scenes Server Models related functions */
static inline void btc_ble_mesh_time_scene_server_cb_to_app(esp_ble_mesh_time_scene_server_cb_event_t event,
esp_ble_mesh_time_scene_server_cb_param_t *param)
{
esp_ble_mesh_time_scene_server_cb_t btc_ble_mesh_cb =
(esp_ble_mesh_time_scene_server_cb_t)btc_profile_cb_get(BTC_PID_TIME_SCENE_SERVER);
if (btc_ble_mesh_cb) {
btc_ble_mesh_cb(event, param);
}
}
static void btc_ble_mesh_time_scene_server_callback(esp_ble_mesh_time_scene_server_cb_param_t *cb_params, uint8_t act)
{
btc_msg_t msg = {0};
BT_DBG("%s", __func__);
/* If corresponding callback is not registered, event will not be posted. */
if (!btc_profile_cb_get(BTC_PID_TIME_SCENE_SERVER)) {
return;
}
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_TIME_SCENE_SERVER;
msg.act = act;
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_time_scene_server_cb_param_t), NULL);
}
void bt_mesh_time_scene_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len)
{
esp_ble_mesh_time_scene_server_cb_param_t cb_params = {0};
uint8_t act = 0U;
if (model == NULL || ctx == NULL) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
switch (evt_type) {
case BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_STATE_CHANGE:
act = ESP_BLE_MESH_TIME_SCENE_SERVER_STATE_CHANGE_EVT;
break;
case BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_GET_MSG:
act = ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_GET_MSG_EVT;
break;
case BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_SET_MSG:
act = ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_SET_MSG_EVT;
break;
case BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_STATUS_MSG:
act = ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_STATUS_MSG_EVT;
break;
default:
BT_ERR("Unknown Time Scene server event type %d", evt_type);
return;
}
cb_params.model = (esp_ble_mesh_model_t *)model;
cb_params.ctx.net_idx = ctx->net_idx;
cb_params.ctx.app_idx = ctx->app_idx;
cb_params.ctx.addr = ctx->addr;
cb_params.ctx.recv_ttl = ctx->recv_ttl;
cb_params.ctx.recv_op = ctx->recv_op;
cb_params.ctx.recv_dst = ctx->recv_dst;
cb_params.ctx.recv_rssi = ctx->recv_rssi;
cb_params.ctx.send_ttl = ctx->send_ttl;
if (val && len) {
memcpy(&cb_params.value, val, MIN(len, sizeof(cb_params.value)));
}
btc_ble_mesh_time_scene_server_callback(&cb_params, act);
return;
}
void btc_ble_mesh_time_scene_server_cb_handler(btc_msg_t *msg)
{
esp_ble_mesh_time_scene_server_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
BT_ERR("%s, Invalid parameter", __func__);
return;
}
param = (esp_ble_mesh_time_scene_server_cb_param_t *)(msg->arg);
if (msg->act < ESP_BLE_MESH_TIME_SCENE_SERVER_EVT_MAX) {
btc_ble_mesh_time_scene_server_cb_to_app(msg->act, param);
} else {
BT_ERR("%s, Unknown act %d", __func__, msg->act);
}
return;
}

View File

@ -15,50 +15,66 @@
#ifndef _BTC_BLE_MESH_CONFIG_MODEL_H_
#define _BTC_BLE_MESH_CONFIG_MODEL_H_
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include "esp_ble_mesh_config_model_api.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
BTC_BLE_MESH_ACT_CONFIG_CLIENT_GET_STATE,
BTC_BLE_MESH_ACT_CONFIG_CLIENT_SET_STATE,
} btc_ble_mesh_cfg_client_act_t;
BTC_BLE_MESH_ACT_CONFIG_CLIENT_MAX,
} btc_ble_mesh_config_client_act_t;
typedef union {
struct ble_mesh_clg_client_get_state_reg_args {
struct ble_mesh_cfg_client_get_state_reg_args {
esp_ble_mesh_client_common_param_t *params;
esp_ble_mesh_cfg_client_get_state_t *get_state;
} cfg_client_get_state;
struct ble_mesh_clg_client_set_state_reg_args {
struct ble_mesh_cfg_client_set_state_reg_args {
esp_ble_mesh_client_common_param_t *params;
esp_ble_mesh_cfg_client_set_state_t *set_state;
} cfg_client_set_state;
} btc_ble_mesh_cfg_client_args_t;
} btc_ble_mesh_config_client_args_t;
void btc_mesh_cfg_client_call_handler(btc_msg_t *msg);
typedef enum {
BTC_BLE_MESH_EVT_CONFIG_CLIENT_GET_STATE,
BTC_BLE_MESH_EVT_CONFIG_CLIENT_SET_STATE,
BTC_BLE_MESH_EVT_CONFIG_CLIENT_PUBLISH,
BTC_BLE_MESH_EVT_CONFIG_CLIENT_TIMEOUT,
BTC_BLE_MESH_EVT_CONFIG_CLIENT_MAX,
} btc_ble_mesh_config_client_evt_t;
void btc_mesh_cfg_client_cb_handler(btc_msg_t *msg);
void btc_ble_mesh_config_client_call_handler(btc_msg_t *msg);
void btc_ble_mesh_cfg_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
void btc_ble_mesh_config_client_cb_handler(btc_msg_t *msg);
int btc_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param_t *params, esp_ble_mesh_cfg_client_get_state_t *get_state,
esp_ble_mesh_cfg_client_cb_param_t *cfg_client_cb);
void btc_ble_mesh_config_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
int btc_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param_t *params, esp_ble_mesh_cfg_client_set_state_t *set_state,
esp_ble_mesh_cfg_client_cb_param_t *cfg_client_cb);
void btc_ble_mesh_config_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf);
void btc_mesh_cfg_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf);
void bt_mesh_config_client_cb_evt_to_btc(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_callback_config_status_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len);
void btc_ble_mesh_config_server_cb_handler(btc_msg_t *msg);
void btc_mesh_cfg_server_cb_handler(btc_msg_t *msg);
typedef enum {
BTC_BLE_MESH_EVT_CONFIG_SERVER_STATE_CHANGE,
BTC_BLE_MESH_EVT_CONFIG_SERVER_MAX,
} btc_ble_mesh_config_server_evt_t;
void bt_mesh_callback_cfg_server_event_to_btc(u8_t evt_type, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len);
void bt_mesh_config_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len);
#ifdef __cplusplus
}
#endif
#endif /* _BTC_BLE_MESH_CONFIG_MODEL_H_ */

View File

@ -15,13 +15,17 @@
#ifndef _BTC_BLE_MESH_GENERIC_MODEL_H_
#define _BTC_BLE_MESH_GENERIC_MODEL_H_
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include "esp_ble_mesh_generic_model_api.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
BTC_BLE_MESH_ACT_GENERIC_CLIENT_GET_STATE,
BTC_BLE_MESH_ACT_GENERIC_CLIENT_SET_STATE,
BTC_BLE_MESH_ACT_GENERIC_CLIENT_MAX,
} btc_ble_mesh_generic_client_act_t;
typedef union {
@ -35,18 +39,44 @@ typedef union {
} generic_client_set_state;
} btc_ble_mesh_generic_client_args_t;
void btc_mesh_generic_client_call_handler(btc_msg_t *msg);
typedef enum {
BTC_BLE_MESH_EVT_GENERIC_CLIENT_GET_STATE,
BTC_BLE_MESH_EVT_GENERIC_CLIENT_SET_STATE,
BTC_BLE_MESH_EVT_GENERIC_CLIENT_PUBLISH,
BTC_BLE_MESH_EVT_GENERIC_CLIENT_TIMEOUT,
BTC_BLE_MESH_EVT_GENERIC_CLIENT_MAX,
} btc_ble_mesh_generic_client_evt_t;
void btc_mesh_generic_client_cb_handler(btc_msg_t *msg);
void btc_ble_mesh_generic_client_call_handler(btc_msg_t *msg);
void btc_ble_mesh_generic_client_cb_handler(btc_msg_t *msg);
void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
void btc_mesh_generic_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf);
void btc_ble_mesh_generic_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf);
void bt_mesh_callback_generic_status_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len);
void bt_mesh_generic_client_cb_evt_to_btc(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);
typedef enum {
BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE,
BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_GET_MSG,
BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_SET_MSG,
BTC_BLE_MESH_EVT_GENERIC_SERVER_MAX,
} btc_ble_mesh_generic_server_evt_t;
void bt_mesh_generic_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len);
void btc_ble_mesh_generic_server_cb_handler(btc_msg_t *msg);
#ifdef __cplusplus
}
#endif
#endif /* _BTC_BLE_MESH_GENERIC_MODEL_H_ */

View File

@ -15,21 +15,19 @@
#ifndef _BTC_BLE_MESH_HEALTH_MODEL_H_
#define _BTC_BLE_MESH_HEALTH_MODEL_H_
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include "esp_ble_mesh_health_model_api.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
BTC_BLE_MESH_ACT_HEALTH_CLIENT_GET_STATE,
BTC_BLE_MESH_ACT_HEALTH_CLIENT_SET_STATE,
BTC_BLE_MESH_ACT_HEALTH_CLIENT_MAX,
} btc_ble_mesh_health_client_act_t;
typedef enum {
BTC_BLE_MESH_ACT_HEALTH_SERVER_FAULT_UPDATE,
BTC_BLE_MESH_ACT_HEALTH_SERVER_MAX,
} btc_ble_mesh_health_server_act_t;
typedef union {
struct ble_mesh_health_client_get_state_reg_args {
esp_ble_mesh_client_common_param_t *params;
@ -41,38 +39,57 @@ typedef union {
} health_client_set_state;
} btc_ble_mesh_health_client_args_t;
typedef union {
struct ble_mesh_health_server_fault_update_args {
esp_ble_mesh_elem_t *element;
} fault_update;
} btc_ble_mesh_health_server_args_t;
void btc_mesh_health_client_call_handler(btc_msg_t *msg);
void btc_mesh_health_client_cb_handler(btc_msg_t *msg);
void btc_mesh_health_server_call_handler(btc_msg_t *msg);
void btc_mesh_health_server_cb_handler(btc_msg_t *msg);
typedef enum {
BTC_BLE_MESH_EVT_HEALTH_CLIENT_GET_STATE,
BTC_BLE_MESH_EVT_HEALTH_CLIENT_SET_STATE,
BTC_BLE_MESH_EVT_HEALTH_CLIENT_PUBLISH,
BTC_BLE_MESH_EVT_HEALTH_CLIENT_TIMEOUT,
BTC_BLE_MESH_EVT_HEALTH_CLIENT_MAX,
} btc_ble_mesh_health_client_evt_t;
void btc_ble_mesh_health_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
void btc_ble_mesh_health_client_call_handler(btc_msg_t *msg);
void btc_ble_mesh_health_client_cb_handler(btc_msg_t *msg);
void btc_ble_mesh_health_publish_callback(u32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf);
void bt_mesh_health_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, u16_t len);
typedef enum {
BTC_BLE_MESH_ACT_HEALTH_SERVER_FAULT_UPDATE,
BTC_BLE_MESH_ACT_HEALTH_SERVER_MAX,
} btc_ble_mesh_health_server_act_t;
typedef union {
struct ble_mesh_health_server_fault_update_args {
esp_ble_mesh_elem_t *element;
} health_fault_update;
} btc_ble_mesh_health_server_args_t;
void btc_ble_mesh_health_server_call_handler(btc_msg_t *msg);
void btc_ble_mesh_health_server_cb_handler(btc_msg_t *msg);
void btc_ble_mesh_health_server_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
int btc_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_health_client_get_state_t *get_state,
esp_ble_mesh_health_client_cb_param_t *client_cb);
void btc_ble_mesh_health_server_fault_clear(struct bt_mesh_model *model, u16_t company_id);
int btc_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_health_client_set_state_t *set_state,
esp_ble_mesh_health_client_cb_param_t *client_cb);
void btc_ble_mesh_health_server_fault_test(struct bt_mesh_model *model,
u8_t test_id, u16_t company_id);
void btc_mesh_health_publish_callback(u32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf);
void btc_ble_mesh_health_server_attention_on(struct bt_mesh_model *model, u8_t time);
void bt_mesh_callback_health_status_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, u16_t len);
void btc_ble_mesh_health_server_attention_off(struct bt_mesh_model *model);
#ifdef __cplusplus
}
#endif
#endif /* _BTC_BLE_MESH_HEALTH_MODEL_H_ */

View File

@ -15,14 +15,18 @@
#ifndef _BTC_BLE_MESH_LIGHTING_MODEL_H_
#define _BTC_BLE_MESH_LIGHTING_MODEL_H_
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include "esp_ble_mesh_lighting_model_api.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
BTC_BLE_MESH_ACT_LIGHT_CLIENT_GET_STATE,
BTC_BLE_MESH_ACT_LIGHT_CLIENT_SET_STATE,
} btc_ble_mesh_light_client_act_t;
BTC_BLE_MESH_ACT_LIGHTING_CLIENT_GET_STATE,
BTC_BLE_MESH_ACT_LIGHTING_CLIENT_SET_STATE,
BTC_BLE_MESH_ACT_LIGHTING_CLIENT_MAX,
} btc_ble_mesh_lighting_client_act_t;
typedef union {
struct ble_mesh_light_client_get_state_reg_args {
@ -33,21 +37,48 @@ typedef union {
esp_ble_mesh_client_common_param_t *params;
esp_ble_mesh_light_client_set_state_t *set_state;
} light_client_set_state;
} btc_ble_mesh_light_client_args_t;
} btc_ble_mesh_lighting_client_args_t;
void btc_mesh_light_client_call_handler(btc_msg_t *msg);
typedef enum {
BTC_BLE_MESH_EVT_LIGHTING_CLIENT_GET_STATE,
BTC_BLE_MESH_EVT_LIGHTING_CLIENT_SET_STATE,
BTC_BLE_MESH_EVT_LIGHTING_CLIENT_PUBLISH,
BTC_BLE_MESH_EVT_LIGHTING_CLIENT_TIMEOUT,
BTC_BLE_MESH_EVT_LIGHTING_CLIENT_MAX,
} btc_ble_mesh_lighting_client_evt_t;
void btc_mesh_light_client_cb_handler(btc_msg_t *msg);
void btc_ble_mesh_lighting_client_call_handler(btc_msg_t *msg);
void btc_ble_mesh_light_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
void btc_ble_mesh_lighting_client_cb_handler(btc_msg_t *msg);
void btc_mesh_light_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf);
void btc_ble_mesh_lighting_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
void bt_mesh_callback_light_status_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len);
void btc_ble_mesh_lighting_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf);
void bt_mesh_lighting_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len);
typedef enum {
BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE,
BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_GET_MSG,
BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG,
BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_STATUS_MSG,
BTC_BLE_MESH_EVT_LIGHTING_SERVER_MAX,
} btc_ble_mesh_lighting_server_evt_t;
void bt_mesh_lighting_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len);
void btc_ble_mesh_lighting_server_cb_handler(btc_msg_t *msg);
#ifdef __cplusplus
}
#endif
#endif /* _BTC_BLE_MESH_LIGHTING_MODEL_H_ */

View File

@ -15,20 +15,17 @@
#ifndef _BTC_BLE_MESH_PROV_H_
#define _BTC_BLE_MESH_PROV_H_
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "freertos/semphr.h"
#include "btc/btc_task.h"
#include "esp_bt_defs.h"
#include "mesh_access.h"
#include "mesh_buf.h"
#include "btc/btc_manage.h"
#include "mesh_byteorder.h"
#include "mesh_main.h"
#include "fast_prov.h"
#include "provisioner_prov.h"
#include "esp_ble_mesh_defs.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
BTC_BLE_MESH_ACT_MESH_INIT = 0,
BTC_BLE_MESH_ACT_PROV_ENABLE,
@ -47,21 +44,43 @@ typedef enum {
BTC_BLE_MESH_ACT_PROVISIONER_ENABLE,
BTC_BLE_MESH_ACT_PROVISIONER_DISABLE,
BTC_BLE_MESH_ACT_PROVISIONER_DEV_ADD,
BTC_BLE_MESH_ACT_PROVISIONER_PROV_DEV_WITH_ADDR,
BTC_BLE_MESH_ACT_PROVISIONER_DEV_DEL,
BTC_BLE_MESH_ACT_PROVISIONER_SET_DEV_UUID_MATCH,
BTC_BLE_MESH_ACT_PROVISIONER_SET_PROV_DATA_INFO,
BTC_BLE_MESH_ACT_PROVISIONER_SET_STATIC_OOB_VAL,
BTC_BLE_MESH_ACT_PROVISIONER_SET_PRIMARY_ELEM_ADDR,
BTC_BLE_MESH_ACT_PROVISIONER_SET_NODE_NAME,
BTC_BLE_MESH_ACT_PROVISIONER_SET_LOCAL_APP_KEY,
BTC_BLE_MESH_ACT_PROVISIONER_ADD_LOCAL_APP_KEY,
BTC_BLE_MESH_ACT_PROVISIONER_UPDATE_LOCAL_APP_KEY,
BTC_BLE_MESH_ACT_PROVISIONER_BIND_LOCAL_MOD_APP,
BTC_BLE_MESH_ACT_PROVISIONER_ADD_LOCAL_NET_KEY,
BTC_BLE_MESH_ACT_PROVISIONER_UPDATE_LOCAL_NET_KEY,
BTC_BLE_MESH_ACT_PROVISIONER_STORE_NODE_COMP_DATA,
BTC_BLE_MESH_ACT_PROVISIONER_DELETE_NODE_WITH_UUID,
BTC_BLE_MESH_ACT_PROVISIONER_DELETE_NODE_WITH_ADDR,
BTC_BLE_MESH_ACT_SET_FAST_PROV_INFO,
BTC_BLE_MESH_ACT_SET_FAST_PROV_ACTION,
BTC_BLE_MESH_ACT_LPN_ENABLE,
BTC_BLE_MESH_ACT_LPN_DISABLE,
BTC_BLE_MESH_ACT_LPN_POLL,
BTC_BLE_MESH_ACT_PROXY_CLIENT_CONNECT,
BTC_BLE_MESH_ACT_PROXY_CLIENT_DISCONNECT,
BTC_BLE_MESH_ACT_PROXY_CLIENT_SET_FILTER_TYPE,
BTC_BLE_MESH_ACT_PROXY_CLIENT_ADD_FILTER_ADDR,
BTC_BLE_MESH_ACT_PROXY_CLIENT_REMOVE_FILTER_ADDR,
BTC_BLE_MESH_ACT_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;
typedef enum {
BTC_BLE_MESH_ACT_MODEL_PUBLISH,
BTC_BLE_MESH_ACT_SERVER_MODEL_SEND,
BTC_BLE_MESH_ACT_CLIENT_MODEL_SEND
BTC_BLE_MESH_ACT_CLIENT_MODEL_SEND,
BTC_BLE_MESH_ACT_SERVER_MODEL_UPDATE_STATE,
} btc_ble_mesh_model_act_t;
typedef union {
@ -88,7 +107,7 @@ typedef union {
char string[8];
} input_string;
struct ble_mesh_set_device_name_args {
char name[ESP_BLE_MESH_DEVICE_NAME_MAX_LEN];
char name[ESP_BLE_MESH_DEVICE_NAME_MAX_LEN + 1];
} set_device_name;
struct ble_mesh_provisioner_read_oob_pub_key_args {
uint8_t link_idx;
@ -113,6 +132,14 @@ typedef union {
esp_ble_mesh_unprov_dev_add_t add_dev;
esp_ble_mesh_dev_add_flag_t flags;
} provisioner_dev_add;
struct ble_mesh_provisioner_prov_dev_with_addr_args {
uint8_t uuid[16];
esp_ble_mesh_bd_addr_t addr;
esp_ble_mesh_addr_type_t addr_type;
esp_ble_mesh_prov_bearer_t bearer;
uint16_t oob_info;
uint16_t unicast_addr;
} provisioner_prov_dev_with_addr;
struct ble_mesh_provisioner_dev_del_args {
esp_ble_mesh_device_delete_t del_dev;
} provisioner_dev_del;
@ -125,15 +152,27 @@ typedef union {
struct ble_mesh_provisioner_set_prov_net_idx_args {
esp_ble_mesh_prov_data_info_t prov_data;
} set_prov_data_info;
struct ble_mesh_provisioner_set_static_oob_val_args {
uint8_t value[16];
uint8_t length;
} set_static_oob_val;
struct ble_mesh_provisioner_set_primary_elem_addr_args {
uint16_t addr;
} set_primary_elem_addr;
struct ble_mesh_provisioner_set_node_name_args {
int index;
char name[ESP_BLE_MESH_NODE_NAME_MAX_LEN];
uint16_t index;
char name[ESP_BLE_MESH_NODE_NAME_MAX_LEN + 1];
} set_node_name;
struct ble_mesh_provisioner_add_local_app_key_args {
uint8_t app_key[16];
uint16_t net_idx;
uint16_t app_idx;
} add_local_app_key;
struct ble_mesh_provisioner_update_local_app_key_args {
uint8_t app_key[16];
uint16_t net_idx;
uint16_t app_idx;
} update_local_app_key;
struct ble_mesh_provisioner_bind_local_mod_app_args {
uint16_t elem_addr;
uint16_t model_id;
@ -144,6 +183,21 @@ typedef union {
uint8_t net_key[16];
uint16_t net_idx;
} add_local_net_key;
struct ble_mesh_provisioner_update_local_net_key_args {
uint8_t net_key[16];
uint16_t net_idx;
} update_local_net_key;
struct ble_mesh_provisioner_store_node_comp_data_args {
uint16_t unicast_addr;
uint16_t length;
uint8_t *data;
} store_node_comp_data;
struct ble_mesh_provisioner_delete_node_with_uuid_args {
uint8_t uuid[16];
} delete_node_with_uuid;
struct ble_mesh_provisioner_delete_node_with_addr_args {
uint16_t unicast_addr;
} delete_node_with_addr;
struct ble_mesh_set_fast_prov_info_args {
uint16_t unicast_min;
uint16_t unicast_max;
@ -157,6 +211,62 @@ typedef union {
struct ble_mesh_set_fast_prov_action_args {
uint8_t action;
} set_fast_prov_action;
struct ble_mesh_lpn_enable_args {
/* RFU */
} lpn_enable;
struct ble_mesh_lpn_disable_args {
bool force;
} lpn_disable;
struct ble_mesh_lpn_poll_args {
/* RFU */
} lpn_poll;
struct ble_mesh_proxy_client_connect_args {
uint8_t addr[6];
uint8_t addr_type;
uint16_t net_idx;
} proxy_client_connect;
struct ble_mesh_proxy_client_disconnect_args {
uint8_t conn_handle;
} proxy_client_disconnect;
struct ble_mesh_proxy_client_set_filter_type_args {
uint8_t conn_handle;
uint16_t net_idx;
uint8_t filter_type;
} proxy_client_set_filter_type;
struct ble_mesh_proxy_client_add_filter_addr_args {
uint8_t conn_handle;
uint16_t net_idx;
uint16_t addr_num;
uint16_t *addr;
} proxy_client_add_filter_addr;
struct ble_mesh_proxy_client_remove_filter_addr_args {
uint8_t conn_handle;
uint16_t net_idx;
uint16_t addr_num;
uint16_t *addr;
} proxy_client_remove_filter_addr;
struct ble_mesh_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;
} btc_ble_mesh_prov_args_t;
typedef union {
@ -174,13 +284,30 @@ typedef union {
uint8_t device_role;
int32_t msg_timeout;
} model_send;
struct ble_mesh_server_model_update_state_args {
esp_ble_mesh_model_t *model;
esp_ble_mesh_server_state_type_t type;
esp_ble_mesh_server_state_value_t *value;
} model_update_state;
} btc_ble_mesh_model_args_t;
void btc_ble_mesh_prov_arg_deep_free(btc_msg_t *msg);
void btc_ble_mesh_prov_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
int btc_ble_mesh_client_init(esp_ble_mesh_model_t *model);
void btc_ble_mesh_model_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
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);
u16_t btc_ble_mesh_provisioner_get_prov_node_count(void);
const esp_ble_mesh_node_t **btc_ble_mesh_provisioner_get_node_table_entry(void);
int btc_ble_mesh_client_model_init(esp_ble_mesh_model_t *model);
int btc_ble_mesh_client_model_deinit(esp_ble_mesh_model_t *model);
int32_t btc_ble_mesh_model_pub_period_get(esp_ble_mesh_model_t *mod);
@ -193,18 +320,20 @@ esp_ble_mesh_elem_t *btc_ble_mesh_elem_find(u16_t addr);
uint8_t btc_ble_mesh_elem_count(void);
esp_ble_mesh_model_t *btc_ble_mesh_model_find_vnd(const esp_ble_mesh_elem_t *elem,
uint16_t company, uint16_t id);
uint16_t company, uint16_t id);
esp_ble_mesh_model_t *btc_ble_mesh_model_find(const esp_ble_mesh_elem_t *elem,
uint16_t id);
esp_ble_mesh_model_t *btc_ble_mesh_model_find(const esp_ble_mesh_elem_t *elem, uint16_t id);
const esp_ble_mesh_comp_t *btc_ble_mesh_comp_get(void);
void btc_mesh_model_call_handler(btc_msg_t *msg);
void btc_mesh_model_cb_handler(btc_msg_t *msg);
void btc_ble_mesh_model_call_handler(btc_msg_t *msg);
void btc_ble_mesh_model_cb_handler(btc_msg_t *msg);
void btc_mesh_prov_call_handler(btc_msg_t *msg);
void btc_ble_mesh_prov_call_handler(btc_msg_t *msg);
void btc_ble_mesh_prov_cb_handler(btc_msg_t *msg);
void btc_mesh_prov_cb_handler(btc_msg_t *msg);
#ifdef __cplusplus
}
#endif
#endif /* _BTC_BLE_MESH_PROV_H_ */

View File

@ -15,13 +15,17 @@
#ifndef _BTC_BLE_MESH_SENSOR_MODEL_H_
#define _BTC_BLE_MESH_SENSOR_MODEL_H_
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include "esp_ble_mesh_sensor_model_api.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
BTC_BLE_MESH_ACT_SENSOR_CLIENT_GET_STATE,
BTC_BLE_MESH_ACT_SENSOR_CLIENT_SET_STATE,
BTC_BLE_MESH_ACT_SENSOR_CLIENT_MAX,
} btc_ble_mesh_sensor_client_act_t;
typedef union {
@ -35,19 +39,45 @@ typedef union {
} sensor_client_set_state;
} btc_ble_mesh_sensor_client_args_t;
void btc_mesh_sensor_client_call_handler(btc_msg_t *msg);
typedef enum {
BTC_BLE_MESH_EVT_SENSOR_CLIENT_GET_STATE,
BTC_BLE_MESH_EVT_SENSOR_CLIENT_SET_STATE,
BTC_BLE_MESH_EVT_SENSOR_CLIENT_PUBLISH,
BTC_BLE_MESH_EVT_SENSOR_CLIENT_TIMEOUT,
BTC_BLE_MESH_EVT_SENSOR_CLIENT_MAX,
} btc_ble_mesh_sensor_client_evt_t;
void btc_mesh_sensor_client_cb_handler(btc_msg_t *msg);
void btc_ble_mesh_sensor_client_call_handler(btc_msg_t *msg);
void btc_ble_mesh_sensor_client_cb_handler(btc_msg_t *msg);
void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
void btc_mesh_sensor_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf);
void btc_ble_mesh_sensor_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf);
void bt_mesh_callback_sensor_status_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len);
void bt_mesh_sensor_client_cb_evt_to_btc(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);
typedef enum {
BTC_BLE_MESH_EVT_SENSOR_SERVER_STATE_CHANGE,
BTC_BLE_MESH_EVT_SENSOR_SERVER_RECV_GET_MSG,
BTC_BLE_MESH_EVT_SENSOR_SERVER_RECV_SET_MSG,
BTC_BLE_MESH_EVT_SENSOR_SERVER_MAX,
} btc_ble_mesh_sensor_server_evt_t;
void bt_mesh_sensor_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len);
void btc_ble_mesh_sensor_server_cb_handler(btc_msg_t *msg);
#ifdef __cplusplus
}
#endif
#endif /* _BTC_BLE_MESH_SENSOR_MODEL_H_ */

View File

@ -15,13 +15,17 @@
#ifndef _BTC_BLE_MESH_TIME_SCENE_MODEL_H_
#define _BTC_BLE_MESH_TIME_SCENE_MODEL_H_
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include "esp_ble_mesh_time_scene_model_api.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_GET_STATE,
BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_SET_STATE,
BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_MAX,
} btc_ble_mesh_time_scene_client_act_t;
typedef union {
@ -35,19 +39,46 @@ typedef union {
} time_scene_client_set_state;
} btc_ble_mesh_time_scene_client_args_t;
void btc_mesh_time_scene_client_call_handler(btc_msg_t *msg);
typedef enum {
BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_GET_STATE,
BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_SET_STATE,
BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_PUBLISH,
BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_TIMEOUT,
BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_MAX,
} btc_ble_mesh_time_scene_client_evt_t;
void btc_mesh_time_scene_client_cb_handler(btc_msg_t *msg);
void btc_ble_mesh_time_scene_client_call_handler(btc_msg_t *msg);
void btc_ble_mesh_time_scene_client_cb_handler(btc_msg_t *msg);
void btc_ble_mesh_time_scene_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
void btc_mesh_time_scene_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf);
void btc_ble_mesh_time_scene_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf);
void bt_mesh_callback_time_scene_status_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len);
void bt_mesh_time_scene_client_cb_evt_to_btc(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);
typedef enum {
BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_STATE_CHANGE,
BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_GET_MSG,
BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_SET_MSG,
BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_STATUS_MSG,
BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_MAX,
} btc_ble_mesh_time_scene_server_evt_t;
void bt_mesh_time_scene_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len);
void btc_ble_mesh_time_scene_server_cb_handler(btc_msg_t *msg);
#ifdef __cplusplus
}
#endif
#endif /* _BTC_BLE_MESH_TIME_SCENE_MODEL_H_ */

View File

@ -11,12 +11,9 @@
#ifndef _BLE_MESH_BUF_H_
#define _BLE_MESH_BUF_H_
#include <stddef.h>
#include "sys/cdefs.h"
#include "mesh_types.h"
#include "sdkconfig.h"
#include "mesh_slist.h"
#include "mesh_kernel.h"
#include "mesh_util.h"
#include "mesh_compiler.h"
#ifdef __cplusplus
extern "C" {
@ -155,6 +152,18 @@ static inline void net_buf_simple_init(struct net_buf_simple *buf,
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
*
@ -168,6 +177,19 @@ static inline void net_buf_simple_reset(struct net_buf_simple *buf)
buf->data = buf->__buf;
}
/**
* Clone buffer state, using the same data buffer.
*
* Initializes a buffer to point to the same data as an existing buffer.
* Allows operations on the same data without altering the length and
* offset of the original.
*
* @param original Buffer to clone.
* @param clone The new clone.
*/
void net_buf_simple_clone(const struct net_buf_simple *original,
struct net_buf_simple *clone);
/**
* @brief Prepare data to be added at the end of the buffer
*
@ -233,6 +255,30 @@ void net_buf_simple_add_le16(struct net_buf_simple *buf, u16_t val);
*/
void net_buf_simple_add_be16(struct net_buf_simple *buf, u16_t val);
/**
* @brief Add 24-bit value at the end of the buffer
*
* Adds 24-bit value in little endian format at the end of buffer.
* Increments the data length of a buffer to account for more data
* at the end.
*
* @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);
/**
* @brief Add 24-bit value at the end of the buffer
*
* Adds 24-bit value in big endian format at the end of buffer.
* Increments the data length of a buffer to account for more data
* at the end.
*
* @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);
/**
* @brief Add 32-bit value at the end of the buffer
*
@ -257,6 +303,54 @@ void net_buf_simple_add_le32(struct net_buf_simple *buf, u32_t val);
*/
void net_buf_simple_add_be32(struct net_buf_simple *buf, u32_t val);
/**
* @brief Add 48-bit value at the end of the buffer
*
* Adds 48-bit value in little endian format at the end of buffer.
* Increments the data length of a buffer to account for more data
* at the end.
*
* @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);
/**
* @brief Add 48-bit value at the end of the buffer
*
* Adds 48-bit value in big endian format at the end of buffer.
* Increments the data length of a buffer to account for more data
* at the end.
*
* @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);
/**
* @brief Add 64-bit value at the end of the buffer
*
* Adds 64-bit value in little endian format at the end of buffer.
* Increments the data length of a buffer to account for more data
* at the end.
*
* @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);
/**
* @brief Add 64-bit value at the end of the buffer
*
* Adds 64-bit value in big endian format at the end of buffer.
* Increments the data length of a buffer to account for more data
* at the end.
*
* @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);
/**
* @brief Push data to the beginning of the buffer.
*
@ -302,6 +396,94 @@ void net_buf_simple_push_be16(struct net_buf_simple *buf, u16_t val);
*/
void net_buf_simple_push_u8(struct net_buf_simple *buf, u8_t val);
/**
* @brief Push 24-bit value to the beginning of the buffer
*
* Adds 24-bit value in little endian format to the beginning of the
* buffer.
*
* @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);
/**
* @brief Push 24-bit value to the beginning of the buffer
*
* Adds 24-bit value in big endian format to the beginning of the
* buffer.
*
* @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);
/**
* @brief Push 32-bit value to the beginning of the buffer
*
* Adds 32-bit value in little endian format to the beginning of the
* buffer.
*
* @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);
/**
* @brief Push 32-bit value to the beginning of the buffer
*
* Adds 32-bit value in big endian format to the beginning of the
* buffer.
*
* @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);
/**
* @brief Push 48-bit value to the beginning of the buffer
*
* Adds 48-bit value in little endian format to the beginning of the
* buffer.
*
* @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);
/**
* @brief Push 48-bit value to the beginning of the buffer
*
* Adds 48-bit value in big endian format to the beginning of the
* buffer.
*
* @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);
/**
* @brief Push 64-bit value to the beginning of the buffer
*
* Adds 64-bit value in little endian format to the beginning of the
* buffer.
*
* @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);
/**
* @brief Push 64-bit value to the beginning of the buffer
*
* Adds 64-bit value in big endian format to the beginning of the
* buffer.
*
* @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);
/**
* @brief Remove data from the beginning of the buffer.
*
@ -364,6 +546,30 @@ u16_t net_buf_simple_pull_le16(struct net_buf_simple *buf);
*/
u16_t net_buf_simple_pull_be16(struct net_buf_simple *buf);
/**
* @brief Remove and convert 24 bits from the beginning of the buffer.
*
* Same idea as with net_buf_simple_pull(), but a helper for operating
* on 24-bit little endian data.
*
* @param buf A valid pointer on a buffer.
*
* @return 24-bit value converted from little endian to host endian.
*/
u32_t net_buf_simple_pull_le24(struct net_buf_simple *buf);
/**
* @brief Remove and convert 24 bits from the beginning of the buffer.
*
* Same idea as with net_buf_simple_pull(), but a helper for operating
* on 24-bit big endian data.
*
* @param buf A valid pointer on a buffer.
*
* @return 24-bit value converted from big endian to host endian.
*/
u32_t net_buf_simple_pull_be24(struct net_buf_simple *buf);
/**
* @brief Remove and convert 32 bits from the beginning of the buffer.
*
@ -388,6 +594,54 @@ u32_t net_buf_simple_pull_le32(struct net_buf_simple *buf);
*/
u32_t net_buf_simple_pull_be32(struct net_buf_simple *buf);
/**
* @brief Remove and convert 48 bits from the beginning of the buffer.
*
* Same idea as with net_buf_simple_pull(), but a helper for operating
* on 48-bit little endian data.
*
* @param buf A valid pointer on a buffer.
*
* @return 48-bit value converted from little endian to host endian.
*/
u64_t net_buf_simple_pull_le48(struct net_buf_simple *buf);
/**
* @brief Remove and convert 48 bits from the beginning of the buffer.
*
* Same idea as with net_buf_simple_pull(), but a helper for operating
* on 48-bit big endian data.
*
* @param buf A valid pointer on a buffer.
*
* @return 48-bit value converted from big endian to host endian.
*/
u64_t net_buf_simple_pull_be48(struct net_buf_simple *buf);
/**
* @brief Remove and convert 64 bits from the beginning of the buffer.
*
* Same idea as with net_buf_simple_pull(), but a helper for operating
* on 64-bit little endian data.
*
* @param buf A valid pointer on a buffer.
*
* @return 64-bit value converted from little endian to host endian.
*/
u64_t net_buf_simple_pull_le64(struct net_buf_simple *buf);
/**
* @brief Remove and convert 64 bits from the beginning of the buffer.
*
* Same idea as with net_buf_simple_pull(), but a helper for operating
* on 64-bit big endian data.
*
* @param buf A valid pointer on a buffer.
*
* @return 64-bit value converted from big endian to host endian.
*/
u64_t net_buf_simple_pull_be64(struct net_buf_simple *buf);
/**
* @brief Get the tail pointer for a buffer.
*
@ -544,8 +798,8 @@ struct net_buf {
};
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);
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);
};
@ -709,7 +963,7 @@ int net_buf_id(struct net_buf *buf);
*/
#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);
const char *func, int line);
#define net_buf_alloc_fixed(_pool, _timeout) \
net_buf_alloc_fixed_debug(_pool, _timeout, __func__, __LINE__)
#else
@ -874,6 +1128,32 @@ static inline void *net_buf_user_data(struct net_buf *buf)
*/
#define net_buf_add_be16(buf, val) net_buf_simple_add_be16(&(buf)->b, val)
/**
* @def net_buf_add_le24
* @brief Add 24-bit value at the end of the buffer
*
* Adds 24-bit value in little endian format at the end of buffer.
* Increments the data length of a buffer to account for more data
* at the end.
*
* @param buf Buffer to update.
* @param val 24-bit value to be added.
*/
#define net_buf_add_le24(buf, val) net_buf_simple_add_le24(&(buf)->b, val)
/**
* @def net_buf_add_be24
* @brief Add 24-bit value at the end of the buffer
*
* Adds 24-bit value in big endian format at the end of buffer.
* Increments the data length of a buffer to account for more data
* at the end.
*
* @param buf Buffer to update.
* @param val 24-bit value to be added.
*/
#define net_buf_add_be24(buf, val) net_buf_simple_add_be24(&(buf)->b, val)
/**
* @def net_buf_add_le32
* @brief Add 32-bit value at the end of the buffer
@ -900,6 +1180,58 @@ static inline void *net_buf_user_data(struct net_buf *buf)
*/
#define net_buf_add_be32(buf, val) net_buf_simple_add_be32(&(buf)->b, val)
/**
* @def net_buf_add_le48
* @brief Add 48-bit value at the end of the buffer
*
* Adds 48-bit value in little endian format at the end of buffer.
* Increments the data length of a buffer to account for more data
* at the end.
*
* @param buf Buffer to update.
* @param val 48-bit value to be added.
*/
#define net_buf_add_le48(buf, val) net_buf_simple_add_le48(&(buf)->b, val)
/**
* @def net_buf_add_be48
* @brief Add 48-bit value at the end of the buffer
*
* Adds 48-bit value in big endian format at the end of buffer.
* Increments the data length of a buffer to account for more data
* at the end.
*
* @param buf Buffer to update.
* @param val 48-bit value to be added.
*/
#define net_buf_add_be48(buf, val) net_buf_simple_add_be48(&(buf)->b, val)
/**
* @def net_buf_add_le64
* @brief Add 64-bit value at the end of the buffer
*
* Adds 64-bit value in little endian format at the end of buffer.
* Increments the data length of a buffer to account for more data
* at the end.
*
* @param buf Buffer to update.
* @param val 64-bit value to be added.
*/
#define net_buf_add_le64(buf, val) net_buf_simple_add_le64(&(buf)->b, val)
/**
* @def net_buf_add_be64
* @brief Add 64-bit value at the end of the buffer
*
* Adds 64-bit value in big endian format at the end of buffer.
* Increments the data length of a buffer to account for more data
* at the end.
*
* @param buf Buffer to update.
* @param val 64-bit value to be added.
*/
#define net_buf_add_be64(buf, val) net_buf_simple_add_be64(&(buf)->b, val)
/**
* @def net_buf_push
* @brief Push data to the beginning of the buffer.
@ -949,6 +1281,102 @@ static inline void *net_buf_user_data(struct net_buf *buf)
*/
#define net_buf_push_u8(buf, val) net_buf_simple_push_u8(&(buf)->b, val)
/**
* @def net_buf_push_le24
* @brief Push 24-bit value to the beginning of the buffer
*
* Adds 24-bit value in little endian format to the beginning of the
* buffer.
*
* @param buf Buffer to update.
* @param val 24-bit value to be pushed to the buffer.
*/
#define net_buf_push_le24(buf, val) net_buf_simple_push_le24(&(buf)->b, val)
/**
* @def net_buf_push_be24
* @brief Push 24-bit value to the beginning of the buffer
*
* Adds 24-bit value in little endian format to the beginning of the
* buffer.
*
* @param buf Buffer to update.
* @param val 24-bit value to be pushed to the buffer.
*/
#define net_buf_push_be24(buf, val) net_buf_simple_push_be24(&(buf)->b, val)
/**
* @def net_buf_push_le32
* @brief Push 32-bit value to the beginning of the buffer
*
* Adds 32-bit value in little endian format to the beginning of the
* buffer.
*
* @param buf Buffer to update.
* @param val 32-bit value to be pushed to the buffer.
*/
#define net_buf_push_le32(buf, val) net_buf_simple_push_le32(&(buf)->b, val)
/**
* @def net_buf_push_be32
* @brief Push 32-bit value to the beginning of the buffer
*
* Adds 32-bit value in little endian format to the beginning of the
* buffer.
*
* @param buf Buffer to update.
* @param val 32-bit value to be pushed to the buffer.
*/
#define net_buf_push_be32(buf, val) net_buf_simple_push_be32(&(buf)->b, val)
/**
* @def net_buf_push_le48
* @brief Push 48-bit value to the beginning of the buffer
*
* Adds 48-bit value in little endian format to the beginning of the
* buffer.
*
* @param buf Buffer to update.
* @param val 48-bit value to be pushed to the buffer.
*/
#define net_buf_push_le48(buf, val) net_buf_simple_push_le48(&(buf)->b, val)
/**
* @def net_buf_push_be48
* @brief Push 48-bit value to the beginning of the buffer
*
* Adds 48-bit value in little endian format to the beginning of the
* buffer.
*
* @param buf Buffer to update.
* @param val 48-bit value to be pushed to the buffer.
*/
#define net_buf_push_be48(buf, val) net_buf_simple_push_be48(&(buf)->b, val)
/**
* @def net_buf_push_le64
* @brief Push 64-bit value to the beginning of the buffer
*
* Adds 64-bit value in little endian format to the beginning of the
* buffer.
*
* @param buf Buffer to update.
* @param val 64-bit value to be pushed to the buffer.
*/
#define net_buf_push_le64(buf, val) net_buf_simple_push_le64(&(buf)->b, val)
/**
* @def net_buf_push_be64
* @brief Push 64-bit value to the beginning of the buffer
*
* Adds 64-bit value in little endian format to the beginning of the
* buffer.
*
* @param buf Buffer to update.
* @param val 64-bit value to be pushed to the buffer.
*/
#define net_buf_push_be64(buf, val) net_buf_simple_push_be64(&(buf)->b, val)
/**
* @def net_buf_pull
* @brief Remove data from the beginning of the buffer.
@ -963,6 +1391,20 @@ static inline void *net_buf_user_data(struct net_buf *buf)
*/
#define net_buf_pull(buf, len) net_buf_simple_pull(&(buf)->b, len)
/**
* @def net_buf_pull_mem
* @brief Remove data from the beginning of the buffer.
*
* Removes data from the beginning of the buffer by modifying the data
* pointer and buffer length.
*
* @param buf Buffer to update.
* @param len Number of bytes to remove.
*
* @return Pointer to the old beginning of the buffer data.
*/
#define net_buf_pull_mem(buf, len) net_buf_simple_pull_mem(&(buf)->b, len)
/**
* @def net_buf_pull_u8
* @brief Remove a 8-bit value from the beginning of the buffer
@ -1002,6 +1444,32 @@ static inline void *net_buf_user_data(struct net_buf *buf)
*/
#define net_buf_pull_be16(buf) net_buf_simple_pull_be16(&(buf)->b)
/**
* @def net_buf_pull_le24
* @brief Remove and convert 24 bits from the beginning of the buffer.
*
* Same idea as with net_buf_pull(), but a helper for operating on
* 24-bit little endian data.
*
* @param buf A valid pointer on a buffer.
*
* @return 24-bit value converted from little endian to host endian.
*/
#define net_buf_pull_le24(buf) net_buf_simple_pull_le24(&(buf)->b)
/**
* @def net_buf_pull_be24
* @brief Remove and convert 24 bits from the beginning of the buffer.
*
* Same idea as with net_buf_pull(), but a helper for operating on
* 24-bit big endian data.
*
* @param buf A valid pointer on a buffer.
*
* @return 24-bit value converted from big endian to host endian.
*/
#define net_buf_pull_be24(buf) net_buf_simple_pull_be24(&(buf)->b)
/**
* @def net_buf_pull_le32
* @brief Remove and convert 32 bits from the beginning of the buffer.
@ -1028,6 +1496,58 @@ static inline void *net_buf_user_data(struct net_buf *buf)
*/
#define net_buf_pull_be32(buf) net_buf_simple_pull_be32(&(buf)->b)
/**
* @def net_buf_pull_le48
* @brief Remove and convert 48 bits from the beginning of the buffer.
*
* Same idea as with net_buf_pull(), but a helper for operating on
* 48-bit little endian data.
*
* @param buf A valid pointer on a buffer.
*
* @return 48-bit value converted from little endian to host endian.
*/
#define net_buf_pull_le48(buf) net_buf_simple_pull_le48(&(buf)->b)
/**
* @def net_buf_pull_be48
* @brief Remove and convert 48 bits from the beginning of the buffer.
*
* Same idea as with net_buf_pull(), but a helper for operating on
* 48-bit big endian data.
*
* @param buf A valid pointer on a buffer
*
* @return 48-bit value converted from big endian to host endian.
*/
#define net_buf_pull_be48(buf) net_buf_simple_pull_be48(&(buf)->b)
/**
* @def net_buf_pull_le64
* @brief Remove and convert 64 bits from the beginning of the buffer.
*
* Same idea as with net_buf_pull(), but a helper for operating on
* 64-bit little endian data.
*
* @param buf A valid pointer on a buffer.
*
* @return 64-bit value converted from little endian to host endian.
*/
#define net_buf_pull_le64(buf) net_buf_simple_pull_le64(&(buf)->b)
/**
* @def net_buf_pull_be64
* @brief Remove and convert 64 bits from the beginning of the buffer.
*
* Same idea as with net_buf_pull(), but a helper for operating on
* 64-bit big endian data.
*
* @param buf A valid pointer on a buffer
*
* @return 64-bit value converted from big endian to host endian.
*/
#define net_buf_pull_be64(buf) net_buf_simple_pull_be64(&(buf)->b)
/**
* @def net_buf_tailroom
* @brief Check buffer tailroom.
@ -1052,6 +1572,180 @@ static inline void *net_buf_user_data(struct net_buf *buf)
*/
#define net_buf_headroom(buf) net_buf_simple_headroom(&(buf)->b)
/**
* @def net_buf_tail
* @brief Get the tail pointer for a buffer.
*
* Get a pointer to the end of the data in a buffer.
*
* @param buf Buffer.
*
* @return Tail pointer for the buffer.
*/
#define net_buf_tail(buf) net_buf_simple_tail(&(buf)->b)
/**
* @brief Find the last fragment in the fragment list.
*
* @return Pointer to last fragment in the list.
*/
struct net_buf *net_buf_frag_last(struct net_buf *frags);
/**
* @brief Insert a new fragment to a chain of bufs.
*
* Insert a new fragment into the buffer fragments list after the parent.
*
* Note: This function takes ownership of the fragment reference so the
* caller is not required to unref.
*
* @param parent Parent buffer/fragment.
* @param frag Fragment to insert.
*/
void net_buf_frag_insert(struct net_buf *parent, struct net_buf *frag);
/**
* @brief Add a new fragment to the end of a chain of bufs.
*
* Append a new fragment into the buffer fragments list.
*
* Note: This function takes ownership of the fragment reference so the
* caller is not required to unref.
*
* @param head Head of the fragment chain.
* @param frag Fragment to add.
*
* @return New head of the fragment chain. Either head (if head
* was non-NULL) or frag (if head was NULL).
*/
struct net_buf *net_buf_frag_add(struct net_buf *head, struct net_buf *frag);
/**
* @brief Delete existing fragment from a chain of bufs.
*
* @param parent Parent buffer/fragment, or NULL if there is no parent.
* @param frag Fragment to delete.
*
* @return Pointer to the buffer following the fragment, or NULL if it
* had no further fragments.
*/
#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);
#define net_buf_frag_del(_parent, _frag) \
net_buf_frag_del_debug(_parent, _frag, __func__, __LINE__)
#else
struct net_buf *net_buf_frag_del(struct net_buf *parent, struct net_buf *frag);
#endif
/**
* @brief Copy bytes from net_buf chain starting at offset to linear buffer
*
* Copy (extract) @a len bytes from @a src net_buf chain, starting from @a
* offset in it, to a linear buffer @a dst. Return number of bytes actually
* copied, which may be less than requested, if net_buf chain doesn't have
* enough data, or destination buffer is too small.
*
* @param dst Destination buffer
* @param dst_len Destination buffer length
* @param src Source net_buf chain
* @param offset Starting offset to copy from
* @param len Number of bytes to copy
* @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);
/**
* @typedef net_buf_allocator_cb
* @brief Network buffer allocator callback.
*
* @details The allocator callback is called when net_buf_append_bytes
* needs to allocate a new net_buf.
*
* @param timeout Affects the action taken should the net buf pool be empty.
* If K_NO_WAIT, then return immediately. If K_FOREVER, then
* wait as long as necessary. Otherwise, wait up to the specified
* number of milliseconds before timing out.
* @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);
/**
* @brief Append data to a list of net_buf
*
* @details Append data to a net_buf. If there is not enough space in the
* net_buf then more net_buf will be added, unless there are no free net_buf
* and timeout occurs.
*
* @param buf Network buffer.
* @param len Total length of input data
* @param value Data to be added
* @param timeout Timeout is passed to the net_buf allocator callback.
* @param allocate_cb When a new net_buf is required, use this callback.
* @param user_data A user data pointer to be supplied to the allocate_cb.
* This pointer is can be anything from a mem_pool or a net_pkt, the
* logic is left up to the allocate_cb function.
*
* @return Length of data actually added. This may be less than input
* length if other timeout than K_FOREVER was used, and there
* 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);
/**
* @brief Skip N number of bytes in a net_buf
*
* @details Skip N number of bytes starting from fragment's offset. If the total
* length of data is placed in multiple fragments, this function will skip from
* all fragments until it reaches N number of bytes. Any fully skipped buffers
* are removed from the net_buf list.
*
* @param buf Network buffer.
* @param len Total length of data to be skipped.
*
* @return Pointer to the fragment or
* NULL and pos is 0 after successful skip,
* NULL and pos is 0xffff otherwise.
*/
static inline struct net_buf *net_buf_skip(struct net_buf *buf, size_t len)
{
while (buf && len--) {
net_buf_pull_u8(buf);
if (!buf->len) {
buf = net_buf_frag_del(NULL, buf);
}
}
return buf;
}
/**
* @brief Calculate amount of bytes stored in fragments.
*
* Calculates the total amount of data stored in the given buffer and the
* fragments linked to it.
*
* @param buf Buffer to start off with.
*
* @return Number of bytes in the buffer and its fragments.
*/
static inline size_t net_buf_frags_len(struct net_buf *buf)
{
size_t bytes = 0;
while (buf) {
bytes += buf->len;
buf = buf->frags;
}
return bytes;
}
/**
* @}
*/

View File

@ -0,0 +1,599 @@
/*
* Copyright (c) 2015-2016, Intel Corporation.
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _BLE_MESH_BYTEORDER_H_
#define _BLE_MESH_BYTEORDER_H_
#include "mesh_types.h"
#include "mesh_trace.h"
#ifdef __cplusplus
extern "C" {
#endif
/* 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)))
#endif
#ifndef __bswap_24
#define __bswap_24(x) ((u32_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)))
#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)))
#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)))
#endif
/** @def sys_le16_to_cpu
* @brief Convert 16-bit integer from little-endian to host endianness.
*
* @param val 16-bit integer in little-endian format.
*
* @return 16-bit integer in host endianness.
*/
/** @def sys_cpu_to_le16
* @brief Convert 16-bit integer from host endianness to little-endian.
*
* @param val 16-bit integer in host endianness.
*
* @return 16-bit integer in little-endian format.
*/
/** @def sys_le24_to_cpu
* @brief Convert 24-bit integer from little-endian to host endianness.
*
* @param val 24-bit integer in little-endian format.
*
* @return 24-bit integer in host endianness.
*/
/** @def sys_cpu_to_le24
* @brief Convert 24-bit integer from host endianness to little-endian.
*
* @param val 24-bit integer in host endianness.
*
* @return 24-bit integer in little-endian format.
*/
/** @def sys_le32_to_cpu
* @brief Convert 32-bit integer from little-endian to host endianness.
*
* @param val 32-bit integer in little-endian format.
*
* @return 32-bit integer in host endianness.
*/
/** @def sys_cpu_to_le32
* @brief Convert 32-bit integer from host endianness to little-endian.
*
* @param val 32-bit integer in host endianness.
*
* @return 32-bit integer in little-endian format.
*/
/** @def sys_le48_to_cpu
* @brief Convert 48-bit integer from little-endian to host endianness.
*
* @param val 48-bit integer in little-endian format.
*
* @return 48-bit integer in host endianness.
*/
/** @def sys_cpu_to_le48
* @brief Convert 48-bit integer from host endianness to little-endian.
*
* @param val 48-bit integer in host endianness.
*
* @return 48-bit integer in little-endian format.
*/
/** @def sys_be16_to_cpu
* @brief Convert 16-bit integer from big-endian to host endianness.
*
* @param val 16-bit integer in big-endian format.
*
* @return 16-bit integer in host endianness.
*/
/** @def sys_cpu_to_be16
* @brief Convert 16-bit integer from host endianness to big-endian.
*
* @param val 16-bit integer in host endianness.
*
* @return 16-bit integer in big-endian format.
*/
/** @def sys_be24_to_cpu
* @brief Convert 24-bit integer from big-endian to host endianness.
*
* @param val 24-bit integer in big-endian format.
*
* @return 24-bit integer in host endianness.
*/
/** @def sys_cpu_to_be24
* @brief Convert 24-bit integer from host endianness to big-endian.
*
* @param val 24-bit integer in host endianness.
*
* @return 24-bit integer in big-endian format.
*/
/** @def sys_be32_to_cpu
* @brief Convert 32-bit integer from big-endian to host endianness.
*
* @param val 32-bit integer in big-endian format.
*
* @return 32-bit integer in host endianness.
*/
/** @def sys_cpu_to_be32
* @brief Convert 32-bit integer from host endianness to big-endian.
*
* @param val 32-bit integer in host endianness.
*
* @return 32-bit integer in big-endian format.
*/
/** @def sys_be48_to_cpu
* @brief Convert 48-bit integer from big-endian to host endianness.
*
* @param val 48-bit integer in big-endian format.
*
* @return 48-bit integer in host endianness.
*/
/** @def sys_cpu_to_be48
* @brief Convert 48-bit integer from host endianness to big-endian.
*
* @param val 48-bit integer in host endianness.
*
* @return 48-bit integer in big-endian format.
*/
#ifndef sys_le16_to_cpu
#define sys_le16_to_cpu(val) (val)
#endif
#ifndef sys_cpu_to_le16
#define sys_cpu_to_le16(val) (val)
#endif
#ifndef sys_le24_to_cpu
#define sys_le24_to_cpu(val) (val)
#endif
#ifndef sys_cpu_to_le24
#define sys_cpu_to_le24(val) (val)
#endif
#ifndef sys_le32_to_cpu
#define sys_le32_to_cpu(val) (val)
#endif
#ifndef sys_cpu_to_le32
#define sys_cpu_to_le32(val) (val)
#endif
#ifndef sys_le48_to_cpu
#define sys_le48_to_cpu(val) (val)
#endif
#ifndef sys_cpu_to_le48
#define sys_cpu_to_le48(val) (val)
#endif
#ifndef sys_le64_to_cpu
#define sys_le64_to_cpu(val) (val)
#endif
#ifndef sys_cpu_to_le64
#define sys_cpu_to_le64(val) (val)
#endif
#ifndef sys_be16_to_cpu
#define sys_be16_to_cpu(val) __bswap_16(val)
#endif
#ifndef sys_cpu_to_be16
#define sys_cpu_to_be16(val) __bswap_16(val)
#endif
#ifndef sys_be24_to_cpu
#define sys_be24_to_cpu(val) __bswap_24(val)
#endif
#ifndef sys_cpu_to_be24
#define sys_cpu_to_be24(val) __bswap_24(val)
#endif
#ifndef sys_be32_to_cpu
#define sys_be32_to_cpu(val) __bswap_32(val)
#endif
#ifndef sys_cpu_to_be32
#define sys_cpu_to_be32(val) __bswap_32(val)
#endif
#ifndef sys_be48_to_cpu
#define sys_be48_to_cpu(val) __bswap_48(val)
#endif
#ifndef sys_cpu_to_be48
#define sys_cpu_to_be48(val) __bswap_48(val)
#endif
#ifndef sys_be64_to_cpu
#define sys_be64_to_cpu(val) __bswap_64(val)
#endif
#ifndef sys_cpu_to_be64
#define sys_cpu_to_be64(val) __bswap_64(val)
#endif
/**
* @brief Put a 16-bit integer as big-endian to arbitrary location.
*
* Put a 16-bit integer, originally in host endianness, to a
* potentially unaligned memory location in big-endian format.
*
* @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])
{
dst[0] = val >> 8;
dst[1] = val;
}
/**
* @brief Put a 24-bit integer as big-endian to arbitrary location.
*
* Put a 24-bit integer, originally in host endianness, to a
* potentially unaligned memory location in big-endian format.
*
* @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])
{
dst[0] = val >> 16;
sys_put_be16(val, &dst[1]);
}
/**
* @brief Put a 32-bit integer as big-endian to arbitrary location.
*
* Put a 32-bit integer, originally in host endianness, to a
* potentially unaligned memory location in big-endian format.
*
* @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])
{
sys_put_be16(val >> 16, dst);
sys_put_be16(val, &dst[2]);
}
/**
* @brief Put a 48-bit integer as big-endian to arbitrary location.
*
* Put a 48-bit integer, originally in host endianness, to a
* potentially unaligned memory location in big-endian format.
*
* @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])
{
sys_put_be16(val >> 32, dst);
sys_put_be32(val, &dst[2]);
}
/**
* @brief Put a 64-bit integer as big-endian to arbitrary location.
*
* Put a 64-bit integer, originally in host endianness, to a
* potentially unaligned memory location in big-endian format.
*
* @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])
{
sys_put_be32(val >> 32, dst);
sys_put_be32(val, &dst[4]);
}
/**
* @brief Put a 16-bit integer as little-endian to arbitrary location.
*
* Put a 16-bit integer, originally in host endianness, to a
* potentially unaligned memory location in little-endian format.
*
* @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])
{
dst[0] = val;
dst[1] = val >> 8;
}
/**
* @brief Put a 24-bit integer as little-endian to arbitrary location.
*
* Put a 24-bit integer, originally in host endianness, to a
* potentially unaligned memory location in littel-endian format.
*
* @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])
{
sys_put_le16(val, dst);
dst[2] = val >> 16;
}
/**
* @brief Put a 32-bit integer as little-endian to arbitrary location.
*
* Put a 32-bit integer, originally in host endianness, to a
* potentially unaligned memory location in little-endian format.
*
* @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])
{
sys_put_le16(val, dst);
sys_put_le16(val >> 16, &dst[2]);
}
/**
* @brief Put a 48-bit integer as little-endian to arbitrary location.
*
* Put a 48-bit integer, originally in host endianness, to a
* potentially unaligned memory location in little-endian format.
*
* @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])
{
sys_put_le32(val, dst);
sys_put_le16(val >> 32, &dst[4]);
}
/**
* @brief Put a 64-bit integer as little-endian to arbitrary location.
*
* Put a 64-bit integer, originally in host endianness, to a
* potentially unaligned memory location in little-endian format.
*
* @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])
{
sys_put_le32(val, dst);
sys_put_le32(val >> 32, &dst[4]);
}
/**
* @brief Get a 16-bit integer stored in big-endian format.
*
* Get a 16-bit integer, stored in big-endian format in a potentially
* unaligned memory location, and convert it to the host endianness.
*
* @param src Location of the big-endian 16-bit integer to get.
*
* @return 16-bit integer in host endianness.
*/
static inline u16_t sys_get_be16(const u8_t src[2])
{
return ((u16_t)src[0] << 8) | src[1];
}
/**
* @brief Get a 24-bit integer stored in big-endian format.
*
* Get a 24-bit integer, stored in big-endian format in a potentially
* unaligned memory location, and convert it to the host endianness.
*
* @param src Location of the big-endian 24-bit integer to get.
*
* @return 24-bit integer in host endianness.
*/
static inline u32_t sys_get_be24(const u8_t src[3])
{
return ((u32_t)src[0] << 16) | sys_get_be16(&src[1]);
}
/**
* @brief Get a 32-bit integer stored in big-endian format.
*
* Get a 32-bit integer, stored in big-endian format in a potentially
* unaligned memory location, and convert it to the host endianness.
*
* @param src Location of the big-endian 32-bit integer to get.
*
* @return 32-bit integer in host endianness.
*/
static inline u32_t sys_get_be32(const u8_t src[4])
{
return ((u32_t)sys_get_be16(&src[0]) << 16) | sys_get_be16(&src[2]);
}
/**
* @brief Get a 48-bit integer stored in big-endian format.
*
* Get a 48-bit integer, stored in big-endian format in a potentially
* unaligned memory location, and convert it to the host endianness.
*
* @param src Location of the big-endian 48-bit integer to get.
*
* @return 48-bit integer in host endianness.
*/
static inline u64_t sys_get_be48(const u8_t src[6])
{
return ((u64_t)sys_get_be32(&src[0]) << 32) | sys_get_be16(&src[4]);
}
/**
* @brief Get a 64-bit integer stored in big-endian format.
*
* Get a 64-bit integer, stored in big-endian format in a potentially
* unaligned memory location, and convert it to the host endianness.
*
* @param src Location of the big-endian 64-bit integer to get.
*
* @return 64-bit integer in host endianness.
*/
static inline u64_t sys_get_be64(const u8_t src[8])
{
return ((u64_t)sys_get_be32(&src[0]) << 32) | sys_get_be32(&src[4]);
}
/**
* @brief Get a 16-bit integer stored in little-endian format.
*
* Get a 16-bit integer, stored in little-endian format in a potentially
* unaligned memory location, and convert it to the host endianness.
*
* @param src Location of the little-endian 16-bit integer to get.
*
* @return 16-bit integer in host endianness.
*/
static inline u16_t sys_get_le16(const u8_t src[2])
{
return ((u16_t)src[1] << 8) | src[0];
}
/**
* @brief Get a 24-bit integer stored in big-endian format.
*
* Get a 24-bit integer, stored in big-endian format in a potentially
* unaligned memory location, and convert it to the host endianness.
*
* @param src Location of the big-endian 24-bit integer to get.
*
* @return 24-bit integer in host endianness.
*/
static inline u32_t sys_get_le24(const u8_t src[3])
{
return ((u32_t)src[2] << 16) | sys_get_le16(&src[0]);
}
/**
* @brief Get a 32-bit integer stored in little-endian format.
*
* Get a 32-bit integer, stored in little-endian format in a potentially
* unaligned memory location, and convert it to the host endianness.
*
* @param src Location of the little-endian 32-bit integer to get.
*
* @return 32-bit integer in host endianness.
*/
static inline u32_t sys_get_le32(const u8_t src[4])
{
return ((u32_t)sys_get_le16(&src[2]) << 16) | sys_get_le16(&src[0]);
}
/**
* @brief Get a 48-bit integer stored in little-endian format.
*
* Get a 48-bit integer, stored in little-endian format in a potentially
* unaligned memory location, and convert it to the host endianness.
*
* @param src Location of the little-endian 48-bit integer to get.
*
* @return 48-bit integer in host endianness.
*/
static inline u64_t sys_get_le48(const u8_t src[6])
{
return ((u64_t)sys_get_le32(&src[2]) << 32) | sys_get_le16(&src[0]);
}
/**
* @brief Get a 64-bit integer stored in little-endian format.
*
* Get a 64-bit integer, stored in little-endian format in a potentially
* unaligned memory location, and convert it to the host endianness.
*
* @param src Location of the little-endian 64-bit integer to get.
*
* @return 64-bit integer in host endianness.
*/
static inline u64_t sys_get_le64(const u8_t src[8])
{
return ((u64_t)sys_get_le32(&src[4]) << 32) | sys_get_le32(&src[0]);
}
/**
* @brief Swap one buffer content into another
*
* Copy the content of src buffer into dst buffer in reversed order,
* i.e.: src[n] will be put in dst[end-n]
* Where n is an index and 'end' the last index in both arrays.
* The 2 memory pointers must be pointing to different areas, and have
* a minimum size of given length.
*
* @param dst A valid pointer on a memory area where to copy the data in
* @param src A valid pointer on a memory area where to copy the data from
* @param length Size of both dst and src memory areas
*/
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;
__ASSERT(((psrc < pdst && (psrc + length) <= pdst) ||
(psrc > pdst && (pdst + length) <= psrc)),
"Source and destination buffers must not overlap");
psrc += length - 1;
for (; length > 0; length--) {
*pdst++ = *psrc--;
}
}
/**
* @brief Swap buffer content
*
* In-place memory swap, where final content will be reversed.
* I.e.: buf[n] will be put in buf[end-n]
* Where n is an index and 'end' the last index of buf.
*
* @param buf A valid pointer on a memory area to swap
* @param length Size of buf memory area
*/
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];
((u8_t *)buf)[i] = ((u8_t *)buf)[length - 1 - i];
((u8_t *)buf)[length - 1 - i] = tmp;
}
}
#ifdef __cplusplus
}
#endif
#endif /* _BLE_MESH_BYTEORDER_H_ */

View File

@ -16,14 +16,30 @@
* @brief Bluetooth Mesh Model Common APIs.
*/
#ifndef _MESH_COMMON_H_
#define _MESH_COMMON_H_
#ifndef _BLE_MESH_COMMON_H_
#define _BLE_MESH_COMMON_H_
#include "osi/allocator.h"
#include <stddef.h>
#include <stdlib.h>
#include "mesh_types.h"
#include "mesh_buf.h"
#include "esp_attr.h"
#include "esp_heap_caps.h"
#include "mesh_byteorder.h"
#include "mesh_ffs.h"
#include "mesh_trace.h"
#include "mesh_mutex.h"
#include "mesh_access.h"
#ifdef __cplusplus
extern "C" {
#endif
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.
@ -43,4 +59,22 @@ struct net_buf_simple *bt_mesh_alloc_buf(u16_t size);
*/
void bt_mesh_free_buf(struct net_buf_simple *buf);
#endif /* _MESH_COMMON_H_ */
/**
* @brief This function gets device role for stack internal use.
*
* @Note Currently Provisioner only support client models, Node supports
* client models and server models. Hence if srv_send is set to be
* TRUE, then role NODE will be returned.
*
* @param[in] model: Pointer to the model structure
* @param[in] srv_send: Indicate if the message is sent by a server model
*
* @return 0 - Node, 1 - Provisioner
*/
u8_t bt_mesh_get_device_role(struct bt_mesh_model *model, bool srv_send);
#ifdef __cplusplus
}
#endif
#endif /* _BLE_MESH_COMMON_H_ */

View File

@ -0,0 +1,80 @@
/*
* Copyright (c) 2010-2014,2017 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _BLE_MESH_COMPILER_H_
#define _BLE_MESH_COMPILER_H_
#ifdef __cplusplus
extern "C" {
#endif
#define ___in_section(a, b, c)
#define __in_section(a, b, c) ___in_section(a, b, c)
#define __in_section_unique(seg) ___in_section(seg, __FILE__, __COUNTER__)
#ifndef __packed
#define __packed __attribute__((__packed__))
#endif
#ifndef __aligned
#define __aligned(x) __attribute__((__aligned__(x)))
#endif
#ifndef __used
#define __used __attribute__((__used__))
#endif
#ifndef ARG_UNUSED
#define ARG_UNUSED(x) (void)(x)
#endif
#ifndef popcount
#define popcount(x) __builtin_popcount(x)
#endif
#ifndef ALWAYS_INLINE
#define ALWAYS_INLINE inline __attribute__((always_inline))
#endif
/*
* This is meant to be used in conjunction with __in_section() and similar
* where scattered structure instances are concatened together by the linker
* and walked by the code at run time just like a contiguous array of such
* structures.
*
* Assemblers and linkers may insert alignment padding by default whose
* size is larger than the natural alignment for those structures when
* gathering various section segments together, messing up the array walk.
* To prevent this, we need to provide an explicit alignment not to rely
* on the default that might just work by luck.
*
* Alignment statements in linker scripts are not sufficient as
* the assembler may add padding by itself to each segment when switching
* between sections within the same file even if it merges many such segments
* into a single section in the end.
*/
#ifndef Z_DECL_ALIGN
#define Z_DECL_ALIGN(type) __aligned(__alignof(type)) type
#endif
/*
* Convenience helper combining __in_section() and Z_DECL_ALIGN().
* The section name is the struct type prepended with an underscore.
* The subsection is "static" and the subsubsection is the variable name.
*/
#ifndef Z_STRUCT_SECTION_ITERABLE
#define Z_STRUCT_SECTION_ITERABLE(struct_type, name) \
Z_DECL_ALIGN(struct struct_type) name
#endif
#ifdef __cplusplus
}
#endif
#endif /* _BLE_MESH_COMPILER_H_ */

View File

@ -0,0 +1,60 @@
/*
* Copyright (c) 2015, Wind River Systems, Inc.
* Copyright (c) 2017, Oticon A/S
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _BLE_MESH_FFS_H_
#define _BLE_MESH_FFS_H_
#include "mesh_types.h"
#include "mesh_compiler.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
*
* @brief find most significant bit set in a 32-bit word
*
* This routine finds the first bit set starting from the most significant bit
* in the argument passed in and returns the index of that bit. Bits are
* numbered starting at 1 from the least significant bit. A return value of
* zero indicates that the value passed is zero.
*
* @return most significant bit set, 0 if @a op is 0
*/
static ALWAYS_INLINE unsigned int find_msb_set(u32_t op)
{
if (op == 0) {
return 0;
}
return 32 - __builtin_clz(op);
}
/**
*
* @brief find least significant bit set in a 32-bit word
*
* This routine finds the first bit set starting from the least significant bit
* in the argument passed in and returns the index of that bit. Bits are
* numbered starting at 1 from the least significant bit. A return value of
* zero indicates that the value passed is zero.
*
* @return least significant bit set, 0 if @a op is 0
*/
static ALWAYS_INLINE unsigned int find_lsb_set(u32_t op)
{
return __builtin_ffs(op);
}
#ifdef __cplusplus
}
#endif
#endif /* _BLE_MESH_FFS_H_ */

View File

@ -0,0 +1,60 @@
/*
* Copyright (c) 2016, Wind River Systems, Inc.
* Additional Copyright (c) 2020 Espressif Systems (Shanghai) PTE LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _BLE_MESH_KERNEL_H_
#define _BLE_MESH_KERNEL_H_
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "freertos/semphr.h"
#include "sdkconfig.h"
#include "mesh_types.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef CONFIG_BT_BLUEDROID_ENABLED
#ifdef CONFIG_BT_BLUEDROID_PINNED_TO_CORE
#define BLE_MESH_ADV_TASK_CORE (CONFIG_BT_BLUEDROID_PINNED_TO_CORE < portNUM_PROCESSORS ? CONFIG_BT_BLUEDROID_PINNED_TO_CORE : tskNO_AFFINITY)
#else
#define BLE_MESH_ADV_TASK_CORE (0)
#endif
#endif
#ifdef CONFIG_BT_NIMBLE_ENABLED
#ifdef CONFIG_BT_NIMBLE_PINNED_TO_CORE
#define BLE_MESH_ADV_TASK_CORE (CONFIG_BT_NIMBLE_PINNED_TO_CORE < portNUM_PROCESSORS ? CONFIG_BT_NIMBLE_PINNED_TO_CORE : tskNO_AFFINITY)
#else
#define BLE_MESH_ADV_TASK_CORE (0)
#endif
#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.
*
* This routine puts the current thread to sleep for @a duration
* milliseconds.
*
* @param duration Number of milliseconds to sleep.
*
* @return N/A
*/
void k_sleep(s32_t duration);
#ifdef __cplusplus
}
#endif
#endif /* _BLE_MESH_KERNEL_H_ */

View File

@ -0,0 +1,58 @@
// Copyright 2017-2020 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef _BLE_MESH_MUTEX_H_
#define _BLE_MESH_MUTEX_H_
#include "mesh_kernel.h"
#include "mesh_slist.h"
#include "mesh_atomic.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
SemaphoreHandle_t mutex;
#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC
StaticQueue_t *buffer;
#endif
} bt_mesh_mutex_t;
void bt_mesh_mutex_create(bt_mesh_mutex_t *mutex);
void bt_mesh_mutex_free(bt_mesh_mutex_t *mutex);
void bt_mesh_mutex_lock(bt_mesh_mutex_t *mutex);
void bt_mesh_mutex_unlock(bt_mesh_mutex_t *mutex);
void bt_mesh_alarm_lock(void);
void bt_mesh_alarm_unlock(void);
void bt_mesh_list_lock(void);
void bt_mesh_list_unlock(void);
void bt_mesh_buf_lock(void);
void bt_mesh_buf_unlock(void);
void bt_mesh_atomic_lock(void);
void bt_mesh_atomic_unlock(void);
void bt_mesh_mutex_init(void);
void bt_mesh_mutex_deinit(void);
#ifdef __cplusplus
}
#endif
#endif /* _BLE_MESH_MUTEX_H_ */

View File

@ -5,14 +5,16 @@
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _BLE_MESH_KERNEL_H_
#define _BLE_MESH_KERNEL_H_
#ifndef _BLE_MESH_TIMER_H_
#define _BLE_MESH_TIMER_H_
#include "osi/mutex.h"
#include "mesh_types.h"
#include "mesh_slist.h"
#include "mesh_atomic.h"
#include "mesh_dlist.h"
#ifdef __cplusplus
extern "C" {
#endif
/* number of nsec per usec */
#define NSEC_PER_USEC 1000
@ -47,8 +49,6 @@ struct k_work;
*/
typedef void (*k_work_handler_t)(struct k_work *work);
typedef sys_dlist_t _wait_q_t;
struct k_work {
void *_reserved;
k_work_handler_t handler;
@ -182,6 +182,8 @@ struct k_delayed_work {
*/
int k_delayed_work_submit(struct k_delayed_work *work, s32_t delay);
int k_delayed_work_submit_periodic(struct k_delayed_work *work, s32_t period);
/**
* @brief Get time remaining before a delayed work gets scheduled.
*
@ -242,7 +244,7 @@ int k_delayed_work_cancel(struct k_delayed_work *work);
int k_delayed_work_free(struct k_delayed_work *work);
void k_delayed_work_init(struct k_delayed_work *work, k_work_handler_t handler);
int k_delayed_work_init(struct k_delayed_work *work, k_work_handler_t handler);
/**
* @brief Get system uptime.
@ -254,22 +256,12 @@ void k_delayed_work_init(struct k_delayed_work *work, k_work_handler_t handler);
*/
s64_t k_uptime_get(void);
/**
* @brief Put the current thread to sleep.
*
* This routine puts the current thread to sleep for @a duration
* milliseconds.
*
* @param duration Number of milliseconds to sleep.
*
* @return N/A
*/
void k_sleep(s32_t duration);
void bt_mesh_timer_init(void);
void bt_mesh_timer_deinit(void);
unsigned int bt_mesh_irq_lock(void);
void bt_mesh_irq_unlock(unsigned int key);
#ifdef __cplusplus
}
#endif
void bt_mesh_k_init(void);
#endif /* _BLE_MESH_KERNEL_H_ */
#endif /* _BLE_MESH_TIMER_H_ */

View File

@ -10,7 +10,11 @@
#define _BLE_MESH_TRACE_H_
#include "esp_log.h"
#include "sdkconfig.h"
#include "mesh_util.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Define common tracing for all */
#ifndef LOG_LEVEL_ERROR
@ -53,10 +57,6 @@
#define BLE_MESH_LOG_LOCAL_LEVEL_MAPPING LOG_LOCAL_LEVEL
#endif
#ifndef MAX
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#endif /* MAX(a, b) */
#define BLE_MESH_LOG_LEVEL_CHECK(LAYER, LEVEL) (MAX(LAYER##_LOG_LEVEL, BLE_MESH_LOG_LOCAL_LEVEL_MAPPING) >= 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__); }
@ -128,4 +128,8 @@
#define NET_BUF_SIMPLE_ASSERT(cond)
#endif
#ifdef __cplusplus
}
#endif
#endif /* _BLE_MESH_TRACE_H_ */

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