diff --git a/platform.txt b/platform.txt index 239710c135d..de98d5641fc 100644 --- a/platform.txt +++ b/platform.txt @@ -27,8 +27,8 @@ compiler.prefix={build.tarch}-{build.target}-elf- # # ESP32 Support Start # -compiler.cpreprocessor.flags.esp32=-DHAVE_CONFIG_H -DMBEDTLS_CONFIG_FILE="mbedtls/esp_config.h" -DUNITY_INCLUDE_CONFIG_H -DWITH_POSIX -D_GNU_SOURCE -DIDF_VER="v4.4.1-1-gb8050b365e" -DESP_PLATFORM -D_POSIX_READER_WRITER_LOCKS "-I{compiler.sdk.path}/include/config" "-I{compiler.sdk.path}/include/newlib/platform_include" "-I{compiler.sdk.path}/include/freertos/include" "-I{compiler.sdk.path}/include/freertos/include/esp_additions/freertos" "-I{compiler.sdk.path}/include/freertos/port/xtensa/include" "-I{compiler.sdk.path}/include/freertos/include/esp_additions" "-I{compiler.sdk.path}/include/esp_hw_support/include" "-I{compiler.sdk.path}/include/esp_hw_support/include/soc" "-I{compiler.sdk.path}/include/esp_hw_support/include/soc/esp32" "-I{compiler.sdk.path}/include/esp_hw_support/port/esp32" "-I{compiler.sdk.path}/include/esp_hw_support/port/esp32/private_include" "-I{compiler.sdk.path}/include/heap/include" "-I{compiler.sdk.path}/include/log/include" "-I{compiler.sdk.path}/include/lwip/include/apps" "-I{compiler.sdk.path}/include/lwip/include/apps/sntp" "-I{compiler.sdk.path}/include/lwip/lwip/src/include" "-I{compiler.sdk.path}/include/lwip/port/esp32/include" "-I{compiler.sdk.path}/include/lwip/port/esp32/include/arch" "-I{compiler.sdk.path}/include/soc/include" "-I{compiler.sdk.path}/include/soc/esp32" "-I{compiler.sdk.path}/include/soc/esp32/include" "-I{compiler.sdk.path}/include/hal/esp32/include" "-I{compiler.sdk.path}/include/hal/include" "-I{compiler.sdk.path}/include/hal/platform_port/include" "-I{compiler.sdk.path}/include/esp_rom/include" "-I{compiler.sdk.path}/include/esp_rom/include/esp32" "-I{compiler.sdk.path}/include/esp_rom/esp32" "-I{compiler.sdk.path}/include/esp_common/include" "-I{compiler.sdk.path}/include/esp_system/include" "-I{compiler.sdk.path}/include/esp_system/port/soc" "-I{compiler.sdk.path}/include/esp_system/port/public_compat" "-I{compiler.sdk.path}/include/esp32/include" "-I{compiler.sdk.path}/include/xtensa/include" "-I{compiler.sdk.path}/include/xtensa/esp32/include" "-I{compiler.sdk.path}/include/driver/include" "-I{compiler.sdk.path}/include/driver/esp32/include" "-I{compiler.sdk.path}/include/esp_pm/include" "-I{compiler.sdk.path}/include/esp_ringbuf/include" "-I{compiler.sdk.path}/include/efuse/include" "-I{compiler.sdk.path}/include/efuse/esp32/include" "-I{compiler.sdk.path}/include/vfs/include" "-I{compiler.sdk.path}/include/esp_wifi/include" "-I{compiler.sdk.path}/include/esp_event/include" "-I{compiler.sdk.path}/include/esp_netif/include" "-I{compiler.sdk.path}/include/esp_eth/include" "-I{compiler.sdk.path}/include/tcpip_adapter/include" "-I{compiler.sdk.path}/include/esp_phy/include" "-I{compiler.sdk.path}/include/esp_phy/esp32/include" "-I{compiler.sdk.path}/include/esp_ipc/include" "-I{compiler.sdk.path}/include/app_trace/include" "-I{compiler.sdk.path}/include/esp_timer/include" "-I{compiler.sdk.path}/include/mbedtls/port/include" "-I{compiler.sdk.path}/include/mbedtls/mbedtls/include" "-I{compiler.sdk.path}/include/mbedtls/esp_crt_bundle/include" "-I{compiler.sdk.path}/include/app_update/include" "-I{compiler.sdk.path}/include/spi_flash/include" "-I{compiler.sdk.path}/include/bootloader_support/include" "-I{compiler.sdk.path}/include/nvs_flash/include" "-I{compiler.sdk.path}/include/pthread/include" "-I{compiler.sdk.path}/include/esp_gdbstub/include" "-I{compiler.sdk.path}/include/esp_gdbstub/xtensa" "-I{compiler.sdk.path}/include/esp_gdbstub/esp32" "-I{compiler.sdk.path}/include/espcoredump/include" "-I{compiler.sdk.path}/include/espcoredump/include/port/xtensa" "-I{compiler.sdk.path}/include/wpa_supplicant/include" "-I{compiler.sdk.path}/include/wpa_supplicant/port/include" "-I{compiler.sdk.path}/include/wpa_supplicant/esp_supplicant/include" "-I{compiler.sdk.path}/include/ieee802154/include" "-I{compiler.sdk.path}/include/console" "-I{compiler.sdk.path}/include/asio/asio/asio/include" "-I{compiler.sdk.path}/include/asio/port/include" "-I{compiler.sdk.path}/include/bt/common/osi/include" "-I{compiler.sdk.path}/include/bt/include/esp32/include" "-I{compiler.sdk.path}/include/bt/common/api/include/api" "-I{compiler.sdk.path}/include/bt/common/btc/profile/esp/blufi/include" "-I{compiler.sdk.path}/include/bt/common/btc/profile/esp/include" "-I{compiler.sdk.path}/include/bt/host/bluedroid/api/include/api" "-I{compiler.sdk.path}/include/cbor/port/include" "-I{compiler.sdk.path}/include/unity/include" "-I{compiler.sdk.path}/include/unity/unity/src" "-I{compiler.sdk.path}/include/cmock/CMock/src" "-I{compiler.sdk.path}/include/coap/port/include" "-I{compiler.sdk.path}/include/coap/libcoap/include" "-I{compiler.sdk.path}/include/nghttp/port/include" "-I{compiler.sdk.path}/include/nghttp/nghttp2/lib/includes" "-I{compiler.sdk.path}/include/esp-tls" "-I{compiler.sdk.path}/include/esp-tls/esp-tls-crypto" "-I{compiler.sdk.path}/include/esp_adc_cal/include" "-I{compiler.sdk.path}/include/esp_hid/include" "-I{compiler.sdk.path}/include/tcp_transport/include" "-I{compiler.sdk.path}/include/esp_http_client/include" "-I{compiler.sdk.path}/include/esp_http_server/include" "-I{compiler.sdk.path}/include/esp_https_ota/include" "-I{compiler.sdk.path}/include/esp_lcd/include" "-I{compiler.sdk.path}/include/esp_lcd/interface" "-I{compiler.sdk.path}/include/protobuf-c/protobuf-c" "-I{compiler.sdk.path}/include/protocomm/include/common" "-I{compiler.sdk.path}/include/protocomm/include/security" "-I{compiler.sdk.path}/include/protocomm/include/transports" "-I{compiler.sdk.path}/include/mdns/include" "-I{compiler.sdk.path}/include/esp_local_ctrl/include" "-I{compiler.sdk.path}/include/sdmmc/include" "-I{compiler.sdk.path}/include/esp_serial_slave_link/include" "-I{compiler.sdk.path}/include/esp_websocket_client/include" "-I{compiler.sdk.path}/include/expat/expat/expat/lib" "-I{compiler.sdk.path}/include/expat/port/include" "-I{compiler.sdk.path}/include/wear_levelling/include" "-I{compiler.sdk.path}/include/fatfs/diskio" "-I{compiler.sdk.path}/include/fatfs/vfs" "-I{compiler.sdk.path}/include/fatfs/src" "-I{compiler.sdk.path}/include/freemodbus/common/include" "-I{compiler.sdk.path}/include/idf_test/include" "-I{compiler.sdk.path}/include/idf_test/include/esp32" "-I{compiler.sdk.path}/include/jsmn/include" "-I{compiler.sdk.path}/include/json/cJSON" "-I{compiler.sdk.path}/include/libsodium/libsodium/src/libsodium/include" "-I{compiler.sdk.path}/include/libsodium/port_include" "-I{compiler.sdk.path}/include/mqtt/esp-mqtt/include" "-I{compiler.sdk.path}/include/openssl/include" "-I{compiler.sdk.path}/include/perfmon/include" "-I{compiler.sdk.path}/include/spiffs/include" "-I{compiler.sdk.path}/include/ulp/include" "-I{compiler.sdk.path}/include/wifi_provisioning/include" "-I{compiler.sdk.path}/include/button/button/include" "-I{compiler.sdk.path}/include/rmaker_common/include" "-I{compiler.sdk.path}/include/json_parser/upstream/include" "-I{compiler.sdk.path}/include/json_parser/upstream" "-I{compiler.sdk.path}/include/json_generator/upstream" "-I{compiler.sdk.path}/include/esp_schedule/include" "-I{compiler.sdk.path}/include/esp_rainmaker/include" "-I{compiler.sdk.path}/include/qrcode/include" "-I{compiler.sdk.path}/include/ws2812_led" "-I{compiler.sdk.path}/include/esp-dsp/modules/dotprod/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/support/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/hann/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/blackman/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/blackman_harris/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/blackman_nuttall/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/nuttall/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/flat_top/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/iir/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/fir/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/add/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/sub/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/mul/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/addc/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/mulc/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/sqrt/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/matrix/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/fft/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/dct/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/conv/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/common/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/kalman/ekf/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/kalman/ekf_imu13states/include" "-I{compiler.sdk.path}/include/esp_littlefs/src" "-I{compiler.sdk.path}/include/esp_littlefs/include" "-I{compiler.sdk.path}/include/esp-dl/include" "-I{compiler.sdk.path}/include/esp-dl/include/tool" "-I{compiler.sdk.path}/include/esp-dl/include/typedef" "-I{compiler.sdk.path}/include/esp-dl/include/image" "-I{compiler.sdk.path}/include/esp-dl/include/math" "-I{compiler.sdk.path}/include/esp-dl/include/nn" "-I{compiler.sdk.path}/include/esp-dl/include/layer" "-I{compiler.sdk.path}/include/esp-dl/include/detect" "-I{compiler.sdk.path}/include/esp-dl/include/model_zoo" "-I{compiler.sdk.path}/include/esp-sr/esp-tts/esp_tts_chinese/include" "-I{compiler.sdk.path}/include/esp-sr/include/esp32" "-I{compiler.sdk.path}/include/esp32-camera/driver/include" "-I{compiler.sdk.path}/include/esp32-camera/conversions/include" "-I{compiler.sdk.path}/include/fb_gfx/include" -compiler.c.elf.libs.esp32=-lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lasio -lbt -lcbor -lunity -lcmock -lcoap -lnghttp -lesp-tls -lesp_adc_cal -lesp_hid -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lesp_lcd -lprotobuf-c -lprotocomm -lmdns -lesp_local_ctrl -lsdmmc -lesp_serial_slave_link -lesp_websocket_client -lexpat -lwear_levelling -lfatfs -lfreemodbus -ljsmn -ljson -llibsodium -lmqtt -lopenssl -lperfmon -lspiffs -lulp -lwifi_provisioning -lbutton -lrmaker_common -ljson_parser -ljson_generator -lesp_schedule -lesp_rainmaker -lqrcode -lws2812_led -lesp-dsp -lesp-sr -lesp32-camera -lesp_littlefs -lfb_gfx -lasio -lcbor -lcmock -lunity -lcoap -lesp_lcd -lesp_websocket_client -lexpat -lfreemodbus -ljsmn -llibsodium -lperfmon -lesp_adc_cal -lesp_hid -lfatfs -lwear_levelling -lopenssl -lesp_rainmaker -lesp_local_ctrl -lwifi_provisioning -lprotocomm -lbt -lbtdm_app -lprotobuf-c -lmdns -lrmaker_common -lmqtt -ljson_parser -ljson_generator -lesp_schedule -lqrcode -lcat_face_detect -lhuman_face_detect -lcolor_detect -lmfn -ldl -lwakenet -lmultinet -lesp_audio_processor -lesp_audio_front_end -lesp-sr -lwakenet -lmultinet -lesp_audio_processor -lesp_audio_front_end -ljson -lspiffs -ldl_lib -lc_speech_features -lhilexin_wn5 -lhilexin_wn5X2 -lhilexin_wn5X3 -lnihaoxiaozhi_wn5 -lnihaoxiaozhi_wn5X2 -lnihaoxiaozhi_wn5X3 -lnihaoxiaoxin_wn5X3 -lcustomized_word_wn5 -lmultinet2_ch -lesp_tts_chinese -lvoice_set_xiaole -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lphy -lrtc -lesp_phy -lphy -lrtc -lesp_phy -lphy -lrtc -lxt_hal -lm -lnewlib -lstdc++ -lpthread -lgcc -lcxx -lapp_trace -lgcov -lapp_trace -lgcov -lc +compiler.cpreprocessor.flags.esp32=-DHAVE_CONFIG_H -DMBEDTLS_CONFIG_FILE="mbedtls/esp_config.h" -DUNITY_INCLUDE_CONFIG_H -DWITH_POSIX -D_GNU_SOURCE -DIDF_VER="v4.4.1-405-g6c5fb29c2c" -DESP_PLATFORM -D_POSIX_READER_WRITER_LOCKS "-I{compiler.sdk.path}/include/newlib/platform_include" "-I{compiler.sdk.path}/include/freertos/include" "-I{compiler.sdk.path}/include/freertos/include/esp_additions/freertos" "-I{compiler.sdk.path}/include/freertos/port/xtensa/include" "-I{compiler.sdk.path}/include/freertos/include/esp_additions" "-I{compiler.sdk.path}/include/esp_hw_support/include" "-I{compiler.sdk.path}/include/esp_hw_support/include/soc" "-I{compiler.sdk.path}/include/esp_hw_support/include/soc/esp32" "-I{compiler.sdk.path}/include/esp_hw_support/port/esp32" "-I{compiler.sdk.path}/include/esp_hw_support/port/esp32/private_include" "-I{compiler.sdk.path}/include/heap/include" "-I{compiler.sdk.path}/include/log/include" "-I{compiler.sdk.path}/include/lwip/include/apps" "-I{compiler.sdk.path}/include/lwip/include/apps/sntp" "-I{compiler.sdk.path}/include/lwip/lwip/src/include" "-I{compiler.sdk.path}/include/lwip/port/esp32/include" "-I{compiler.sdk.path}/include/lwip/port/esp32/include/arch" "-I{compiler.sdk.path}/include/soc/include" "-I{compiler.sdk.path}/include/soc/esp32" "-I{compiler.sdk.path}/include/soc/esp32/include" "-I{compiler.sdk.path}/include/hal/esp32/include" "-I{compiler.sdk.path}/include/hal/include" "-I{compiler.sdk.path}/include/hal/platform_port/include" "-I{compiler.sdk.path}/include/esp_rom/include" "-I{compiler.sdk.path}/include/esp_rom/include/esp32" "-I{compiler.sdk.path}/include/esp_rom/esp32" "-I{compiler.sdk.path}/include/esp_common/include" "-I{compiler.sdk.path}/include/esp_system/include" "-I{compiler.sdk.path}/include/esp_system/port/soc" "-I{compiler.sdk.path}/include/esp_system/port/public_compat" "-I{compiler.sdk.path}/include/esp32/include" "-I{compiler.sdk.path}/include/xtensa/include" "-I{compiler.sdk.path}/include/xtensa/esp32/include" "-I{compiler.sdk.path}/include/driver/include" "-I{compiler.sdk.path}/include/driver/esp32/include" "-I{compiler.sdk.path}/include/esp_pm/include" "-I{compiler.sdk.path}/include/esp_ringbuf/include" "-I{compiler.sdk.path}/include/efuse/include" "-I{compiler.sdk.path}/include/efuse/esp32/include" "-I{compiler.sdk.path}/include/vfs/include" "-I{compiler.sdk.path}/include/esp_wifi/include" "-I{compiler.sdk.path}/include/esp_event/include" "-I{compiler.sdk.path}/include/esp_netif/include" "-I{compiler.sdk.path}/include/esp_eth/include" "-I{compiler.sdk.path}/include/tcpip_adapter/include" "-I{compiler.sdk.path}/include/esp_phy/include" "-I{compiler.sdk.path}/include/esp_phy/esp32/include" "-I{compiler.sdk.path}/include/esp_ipc/include" "-I{compiler.sdk.path}/include/app_trace/include" "-I{compiler.sdk.path}/include/esp_timer/include" "-I{compiler.sdk.path}/include/mbedtls/port/include" "-I{compiler.sdk.path}/include/mbedtls/mbedtls/include" "-I{compiler.sdk.path}/include/mbedtls/esp_crt_bundle/include" "-I{compiler.sdk.path}/include/app_update/include" "-I{compiler.sdk.path}/include/spi_flash/include" "-I{compiler.sdk.path}/include/bootloader_support/include" "-I{compiler.sdk.path}/include/nvs_flash/include" "-I{compiler.sdk.path}/include/pthread/include" "-I{compiler.sdk.path}/include/esp_gdbstub/include" "-I{compiler.sdk.path}/include/esp_gdbstub/xtensa" "-I{compiler.sdk.path}/include/esp_gdbstub/esp32" "-I{compiler.sdk.path}/include/espcoredump/include" "-I{compiler.sdk.path}/include/espcoredump/include/port/xtensa" "-I{compiler.sdk.path}/include/wpa_supplicant/include" "-I{compiler.sdk.path}/include/wpa_supplicant/port/include" "-I{compiler.sdk.path}/include/wpa_supplicant/esp_supplicant/include" "-I{compiler.sdk.path}/include/ieee802154/include" "-I{compiler.sdk.path}/include/console" "-I{compiler.sdk.path}/include/asio/asio/asio/include" "-I{compiler.sdk.path}/include/asio/port/include" "-I{compiler.sdk.path}/include/bt/common/osi/include" "-I{compiler.sdk.path}/include/bt/include/esp32/include" "-I{compiler.sdk.path}/include/bt/common/api/include/api" "-I{compiler.sdk.path}/include/bt/common/btc/profile/esp/blufi/include" "-I{compiler.sdk.path}/include/bt/common/btc/profile/esp/include" "-I{compiler.sdk.path}/include/bt/host/bluedroid/api/include/api" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/mesh_common/include" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/mesh_core" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/mesh_core/include" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/mesh_core/storage" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/btc/include" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/mesh_models/common/include" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/mesh_models/client/include" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/mesh_models/server/include" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/api/core/include" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/api/models/include" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/api" "-I{compiler.sdk.path}/include/cbor/port/include" "-I{compiler.sdk.path}/include/unity/include" "-I{compiler.sdk.path}/include/unity/unity/src" "-I{compiler.sdk.path}/include/cmock/CMock/src" "-I{compiler.sdk.path}/include/coap/port/include" "-I{compiler.sdk.path}/include/coap/libcoap/include" "-I{compiler.sdk.path}/include/nghttp/port/include" "-I{compiler.sdk.path}/include/nghttp/nghttp2/lib/includes" "-I{compiler.sdk.path}/include/esp-tls" "-I{compiler.sdk.path}/include/esp-tls/esp-tls-crypto" "-I{compiler.sdk.path}/include/esp_adc_cal/include" "-I{compiler.sdk.path}/include/esp_hid/include" "-I{compiler.sdk.path}/include/tcp_transport/include" "-I{compiler.sdk.path}/include/esp_http_client/include" "-I{compiler.sdk.path}/include/esp_http_server/include" "-I{compiler.sdk.path}/include/esp_https_ota/include" "-I{compiler.sdk.path}/include/esp_https_server/include" "-I{compiler.sdk.path}/include/esp_lcd/include" "-I{compiler.sdk.path}/include/esp_lcd/interface" "-I{compiler.sdk.path}/include/protobuf-c/protobuf-c" "-I{compiler.sdk.path}/include/protocomm/include/common" "-I{compiler.sdk.path}/include/protocomm/include/security" "-I{compiler.sdk.path}/include/protocomm/include/transports" "-I{compiler.sdk.path}/include/mdns/include" "-I{compiler.sdk.path}/include/esp_local_ctrl/include" "-I{compiler.sdk.path}/include/sdmmc/include" "-I{compiler.sdk.path}/include/esp_serial_slave_link/include" "-I{compiler.sdk.path}/include/esp_websocket_client/include" "-I{compiler.sdk.path}/include/expat/expat/expat/lib" "-I{compiler.sdk.path}/include/expat/port/include" "-I{compiler.sdk.path}/include/wear_levelling/include" "-I{compiler.sdk.path}/include/fatfs/diskio" "-I{compiler.sdk.path}/include/fatfs/vfs" "-I{compiler.sdk.path}/include/fatfs/src" "-I{compiler.sdk.path}/include/freemodbus/common/include" "-I{compiler.sdk.path}/include/idf_test/include" "-I{compiler.sdk.path}/include/idf_test/include/esp32" "-I{compiler.sdk.path}/include/jsmn/include" "-I{compiler.sdk.path}/include/json/cJSON" "-I{compiler.sdk.path}/include/libsodium/libsodium/src/libsodium/include" "-I{compiler.sdk.path}/include/libsodium/port_include" "-I{compiler.sdk.path}/include/mqtt/esp-mqtt/include" "-I{compiler.sdk.path}/include/openssl/include" "-I{compiler.sdk.path}/include/perfmon/include" "-I{compiler.sdk.path}/include/spiffs/include" "-I{compiler.sdk.path}/include/ulp/include" "-I{compiler.sdk.path}/include/wifi_provisioning/include" "-I{compiler.sdk.path}/include/button/button/include" "-I{compiler.sdk.path}/include/rmaker_common/include" "-I{compiler.sdk.path}/include/json_parser/upstream/include" "-I{compiler.sdk.path}/include/json_parser/upstream" "-I{compiler.sdk.path}/include/json_generator/upstream" "-I{compiler.sdk.path}/include/esp_schedule/include" "-I{compiler.sdk.path}/include/esp_rainmaker/include" "-I{compiler.sdk.path}/include/qrcode/include" "-I{compiler.sdk.path}/include/ws2812_led" "-I{compiler.sdk.path}/include/esp-dsp/modules/dotprod/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/support/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/hann/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/blackman/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/blackman_harris/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/blackman_nuttall/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/nuttall/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/flat_top/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/iir/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/fir/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/add/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/sub/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/mul/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/addc/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/mulc/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/sqrt/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/matrix/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/fft/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/dct/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/conv/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/common/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/kalman/ekf/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/kalman/ekf_imu13states/include" "-I{compiler.sdk.path}/include/esp_littlefs/src" "-I{compiler.sdk.path}/include/esp_littlefs/include" "-I{compiler.sdk.path}/include/esp-dl/include" "-I{compiler.sdk.path}/include/esp-dl/include/tool" "-I{compiler.sdk.path}/include/esp-dl/include/typedef" "-I{compiler.sdk.path}/include/esp-dl/include/image" "-I{compiler.sdk.path}/include/esp-dl/include/math" "-I{compiler.sdk.path}/include/esp-dl/include/nn" "-I{compiler.sdk.path}/include/esp-dl/include/layer" "-I{compiler.sdk.path}/include/esp-dl/include/detect" "-I{compiler.sdk.path}/include/esp-dl/include/model_zoo" "-I{compiler.sdk.path}/include/esp-sr/esp-tts/esp_tts_chinese/include" "-I{compiler.sdk.path}/include/esp-sr/include/esp32" "-I{compiler.sdk.path}/include/esp32-camera/driver/include" "-I{compiler.sdk.path}/include/esp32-camera/conversions/include" "-I{compiler.sdk.path}/include/fb_gfx/include" +compiler.c.elf.libs.esp32=-lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lasio -lbt -lcbor -lunity -lcmock -lcoap -lnghttp -lesp-tls -lesp_adc_cal -lesp_hid -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lesp_https_server -lesp_lcd -lprotobuf-c -lprotocomm -lmdns -lesp_local_ctrl -lsdmmc -lesp_serial_slave_link -lesp_websocket_client -lexpat -lwear_levelling -lfatfs -lfreemodbus -ljsmn -ljson -llibsodium -lmqtt -lopenssl -lperfmon -lspiffs -lulp -lwifi_provisioning -lbutton -lrmaker_common -ljson_parser -ljson_generator -lesp_schedule -lesp_rainmaker -lqrcode -lws2812_led -lesp-dsp -lesp-sr -lesp32-camera -lesp_littlefs -lfb_gfx -lasio -lcbor -lcmock -lunity -lcoap -lesp_lcd -lesp_websocket_client -lexpat -lfreemodbus -ljsmn -llibsodium -lperfmon -lesp_adc_cal -lesp_hid -lfatfs -lwear_levelling -lopenssl -lesp_rainmaker -lesp_local_ctrl -lesp_https_server -lwifi_provisioning -lprotocomm -lbt -lbtdm_app -lprotobuf-c -lmdns -lrmaker_common -lmqtt -ljson_parser -ljson_generator -lesp_schedule -lqrcode -lcat_face_detect -lhuman_face_detect -lcolor_detect -lmfn -ldl -lwakenet -lmultinet -lesp_audio_processor -lesp_audio_front_end -lesp-sr -lwakenet -lmultinet -lesp_audio_processor -lesp_audio_front_end -ljson -lspiffs -ldl_lib -lc_speech_features -lhilexin_wn5 -lhilexin_wn5X2 -lhilexin_wn5X3 -lnihaoxiaozhi_wn5 -lnihaoxiaozhi_wn5X2 -lnihaoxiaozhi_wn5X3 -lnihaoxiaoxin_wn5X3 -lcustomized_word_wn5 -lmultinet2_ch -lesp_tts_chinese -lvoice_set_xiaole -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls_2 -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls_2 -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls_2 -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls_2 -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls_2 -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lphy -lrtc -lesp_phy -lphy -lrtc -lesp_phy -lphy -lrtc -lxt_hal -lm -lnewlib -lstdc++ -lpthread -lgcc -lcxx -lapp_trace -lgcov -lapp_trace -lgcov -lc compiler.c.flags.esp32=-mlongcalls -Wno-frame-address -ffunction-sections -fdata-sections -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-sign-compare -ggdb -Os -freorder-blocks -Wwrite-strings -fstack-protector -fstrict-volatile-bitfields -Wno-error=unused-but-set-variable -fno-jump-tables -fno-tree-switch-conversion -std=gnu99 -Wno-old-style-declaration -MMD -c compiler.cpp.flags.esp32=-mlongcalls -Wno-frame-address -ffunction-sections -fdata-sections -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-sign-compare -ggdb -Os -freorder-blocks -Wwrite-strings -fstack-protector -fstrict-volatile-bitfields -Wno-error=unused-but-set-variable -fno-jump-tables -fno-tree-switch-conversion -std=gnu++11 -fexceptions -fno-rtti -MMD -c compiler.S.flags.esp32=-ffunction-sections -fdata-sections -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-sign-compare -ggdb -Os -freorder-blocks -Wwrite-strings -fstack-protector -fstrict-volatile-bitfields -Wno-error=unused-but-set-variable -fno-jump-tables -fno-tree-switch-conversion -x assembler-with-cpp -MMD -c @@ -42,8 +42,8 @@ build.extra_flags.esp32=-DARDUINO_USB_CDC_ON_BOOT=0 # # ESP32S3 Support Start # -compiler.cpreprocessor.flags.esp32s3=-DHAVE_CONFIG_H -DMBEDTLS_CONFIG_FILE="mbedtls/esp_config.h" -DUNITY_INCLUDE_CONFIG_H -DWITH_POSIX -D_GNU_SOURCE -DIDF_VER="v4.4.1-1-gb8050b365e" -DESP_PLATFORM -D_POSIX_READER_WRITER_LOCKS "-I{compiler.sdk.path}/include/config" "-I{compiler.sdk.path}/include/newlib/platform_include" "-I{compiler.sdk.path}/include/freertos/include" "-I{compiler.sdk.path}/include/freertos/include/esp_additions/freertos" "-I{compiler.sdk.path}/include/freertos/port/xtensa/include" "-I{compiler.sdk.path}/include/freertos/include/esp_additions" "-I{compiler.sdk.path}/include/esp_hw_support/include" "-I{compiler.sdk.path}/include/esp_hw_support/include/soc" "-I{compiler.sdk.path}/include/esp_hw_support/include/soc/esp32s3" "-I{compiler.sdk.path}/include/esp_hw_support/port/esp32s3" "-I{compiler.sdk.path}/include/esp_hw_support/port/esp32s3/private_include" "-I{compiler.sdk.path}/include/heap/include" "-I{compiler.sdk.path}/include/log/include" "-I{compiler.sdk.path}/include/lwip/include/apps" "-I{compiler.sdk.path}/include/lwip/include/apps/sntp" "-I{compiler.sdk.path}/include/lwip/lwip/src/include" "-I{compiler.sdk.path}/include/lwip/port/esp32/include" "-I{compiler.sdk.path}/include/lwip/port/esp32/include/arch" "-I{compiler.sdk.path}/include/soc/include" "-I{compiler.sdk.path}/include/soc/esp32s3" "-I{compiler.sdk.path}/include/soc/esp32s3/include" "-I{compiler.sdk.path}/include/hal/esp32s3/include" "-I{compiler.sdk.path}/include/hal/include" "-I{compiler.sdk.path}/include/hal/platform_port/include" "-I{compiler.sdk.path}/include/esp_rom/include" "-I{compiler.sdk.path}/include/esp_rom/include/esp32s3" "-I{compiler.sdk.path}/include/esp_rom/esp32s3" "-I{compiler.sdk.path}/include/esp_common/include" "-I{compiler.sdk.path}/include/esp_system/include" "-I{compiler.sdk.path}/include/esp_system/port/soc" "-I{compiler.sdk.path}/include/esp_system/port/public_compat" "-I{compiler.sdk.path}/include/xtensa/include" "-I{compiler.sdk.path}/include/xtensa/esp32s3/include" "-I{compiler.sdk.path}/include/driver/include" "-I{compiler.sdk.path}/include/driver/esp32s3/include" "-I{compiler.sdk.path}/include/esp_pm/include" "-I{compiler.sdk.path}/include/esp_ringbuf/include" "-I{compiler.sdk.path}/include/efuse/include" "-I{compiler.sdk.path}/include/efuse/esp32s3/include" "-I{compiler.sdk.path}/include/vfs/include" "-I{compiler.sdk.path}/include/esp_wifi/include" "-I{compiler.sdk.path}/include/esp_event/include" "-I{compiler.sdk.path}/include/esp_netif/include" "-I{compiler.sdk.path}/include/esp_eth/include" "-I{compiler.sdk.path}/include/tcpip_adapter/include" "-I{compiler.sdk.path}/include/esp_phy/include" "-I{compiler.sdk.path}/include/esp_phy/esp32s3/include" "-I{compiler.sdk.path}/include/esp_ipc/include" "-I{compiler.sdk.path}/include/app_trace/include" "-I{compiler.sdk.path}/include/esp_timer/include" "-I{compiler.sdk.path}/include/mbedtls/port/include" "-I{compiler.sdk.path}/include/mbedtls/mbedtls/include" "-I{compiler.sdk.path}/include/mbedtls/esp_crt_bundle/include" "-I{compiler.sdk.path}/include/app_update/include" "-I{compiler.sdk.path}/include/spi_flash/include" "-I{compiler.sdk.path}/include/bootloader_support/include" "-I{compiler.sdk.path}/include/nvs_flash/include" "-I{compiler.sdk.path}/include/pthread/include" "-I{compiler.sdk.path}/include/esp_gdbstub/include" "-I{compiler.sdk.path}/include/esp_gdbstub/xtensa" "-I{compiler.sdk.path}/include/esp_gdbstub/esp32s3" "-I{compiler.sdk.path}/include/espcoredump/include" "-I{compiler.sdk.path}/include/espcoredump/include/port/xtensa" "-I{compiler.sdk.path}/include/wpa_supplicant/include" "-I{compiler.sdk.path}/include/wpa_supplicant/port/include" "-I{compiler.sdk.path}/include/wpa_supplicant/esp_supplicant/include" "-I{compiler.sdk.path}/include/ieee802154/include" "-I{compiler.sdk.path}/include/console" "-I{compiler.sdk.path}/include/asio/asio/asio/include" "-I{compiler.sdk.path}/include/asio/port/include" "-I{compiler.sdk.path}/include/bt/common/osi/include" "-I{compiler.sdk.path}/include/bt/include/esp32s3/include" "-I{compiler.sdk.path}/include/bt/common/api/include/api" "-I{compiler.sdk.path}/include/bt/common/btc/profile/esp/blufi/include" "-I{compiler.sdk.path}/include/bt/common/btc/profile/esp/include" "-I{compiler.sdk.path}/include/bt/host/bluedroid/api/include/api" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/mesh_common/include" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/mesh_core" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/mesh_core/include" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/mesh_core/storage" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/btc/include" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/mesh_models/common/include" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/mesh_models/client/include" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/mesh_models/server/include" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/api/core/include" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/api/models/include" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/api" "-I{compiler.sdk.path}/include/cbor/port/include" "-I{compiler.sdk.path}/include/unity/include" "-I{compiler.sdk.path}/include/unity/unity/src" "-I{compiler.sdk.path}/include/cmock/CMock/src" "-I{compiler.sdk.path}/include/coap/port/include" "-I{compiler.sdk.path}/include/coap/libcoap/include" "-I{compiler.sdk.path}/include/nghttp/port/include" "-I{compiler.sdk.path}/include/nghttp/nghttp2/lib/includes" "-I{compiler.sdk.path}/include/esp-tls" "-I{compiler.sdk.path}/include/esp-tls/esp-tls-crypto" "-I{compiler.sdk.path}/include/esp_adc_cal/include" "-I{compiler.sdk.path}/include/esp_hid/include" "-I{compiler.sdk.path}/include/tcp_transport/include" "-I{compiler.sdk.path}/include/esp_http_client/include" "-I{compiler.sdk.path}/include/esp_http_server/include" "-I{compiler.sdk.path}/include/esp_https_ota/include" "-I{compiler.sdk.path}/include/esp_https_server/include" "-I{compiler.sdk.path}/include/esp_lcd/include" "-I{compiler.sdk.path}/include/esp_lcd/interface" "-I{compiler.sdk.path}/include/protobuf-c/protobuf-c" "-I{compiler.sdk.path}/include/protocomm/include/common" "-I{compiler.sdk.path}/include/protocomm/include/security" "-I{compiler.sdk.path}/include/protocomm/include/transports" "-I{compiler.sdk.path}/include/mdns/include" "-I{compiler.sdk.path}/include/esp_local_ctrl/include" "-I{compiler.sdk.path}/include/sdmmc/include" "-I{compiler.sdk.path}/include/esp_serial_slave_link/include" "-I{compiler.sdk.path}/include/esp_websocket_client/include" "-I{compiler.sdk.path}/include/expat/expat/expat/lib" "-I{compiler.sdk.path}/include/expat/port/include" "-I{compiler.sdk.path}/include/wear_levelling/include" "-I{compiler.sdk.path}/include/fatfs/diskio" "-I{compiler.sdk.path}/include/fatfs/vfs" "-I{compiler.sdk.path}/include/fatfs/src" "-I{compiler.sdk.path}/include/freemodbus/common/include" "-I{compiler.sdk.path}/include/idf_test/include" "-I{compiler.sdk.path}/include/idf_test/include/esp32s3" "-I{compiler.sdk.path}/include/jsmn/include" "-I{compiler.sdk.path}/include/json/cJSON" "-I{compiler.sdk.path}/include/libsodium/libsodium/src/libsodium/include" "-I{compiler.sdk.path}/include/libsodium/port_include" "-I{compiler.sdk.path}/include/mqtt/esp-mqtt/include" "-I{compiler.sdk.path}/include/openssl/include" "-I{compiler.sdk.path}/include/perfmon/include" "-I{compiler.sdk.path}/include/spiffs/include" "-I{compiler.sdk.path}/include/usb/include" "-I{compiler.sdk.path}/include/ulp/include" "-I{compiler.sdk.path}/include/wifi_provisioning/include" "-I{compiler.sdk.path}/include/button/button/include" "-I{compiler.sdk.path}/include/rmaker_common/include" "-I{compiler.sdk.path}/include/json_parser/upstream/include" "-I{compiler.sdk.path}/include/json_parser/upstream" "-I{compiler.sdk.path}/include/json_generator/upstream" "-I{compiler.sdk.path}/include/esp_schedule/include" "-I{compiler.sdk.path}/include/esp_rainmaker/include" "-I{compiler.sdk.path}/include/qrcode/include" "-I{compiler.sdk.path}/include/ws2812_led" "-I{compiler.sdk.path}/include/esp-dsp/modules/dotprod/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/support/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/hann/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/blackman/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/blackman_harris/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/blackman_nuttall/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/nuttall/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/flat_top/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/iir/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/fir/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/add/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/sub/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/mul/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/addc/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/mulc/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/sqrt/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/matrix/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/fft/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/dct/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/conv/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/common/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/kalman/ekf/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/kalman/ekf_imu13states/include" "-I{compiler.sdk.path}/include/freertos/include/freertos" "-I{compiler.sdk.path}/include/arduino_tinyusb/tinyusb/src" "-I{compiler.sdk.path}/include/arduino_tinyusb/include" "-I{compiler.sdk.path}/include/esp_littlefs/src" "-I{compiler.sdk.path}/include/esp_littlefs/include" "-I{compiler.sdk.path}/include/esp-dl/include" "-I{compiler.sdk.path}/include/esp-dl/include/tool" "-I{compiler.sdk.path}/include/esp-dl/include/typedef" "-I{compiler.sdk.path}/include/esp-dl/include/image" "-I{compiler.sdk.path}/include/esp-dl/include/math" "-I{compiler.sdk.path}/include/esp-dl/include/nn" "-I{compiler.sdk.path}/include/esp-dl/include/layer" "-I{compiler.sdk.path}/include/esp-dl/include/detect" "-I{compiler.sdk.path}/include/esp-dl/include/model_zoo" "-I{compiler.sdk.path}/include/esp-sr/esp-tts/esp_tts_chinese/include" "-I{compiler.sdk.path}/include/esp-sr/include/esp32s3" "-I{compiler.sdk.path}/include/esp32-camera/driver/include" "-I{compiler.sdk.path}/include/esp32-camera/conversions/include" "-I{compiler.sdk.path}/include/fb_gfx/include" -compiler.c.elf.libs.esp32s3=-lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lasio -lbt -lcbor -lunity -lcmock -lcoap -lnghttp -lesp-tls -lesp_adc_cal -lesp_hid -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lesp_https_server -lesp_lcd -lprotobuf-c -lprotocomm -lmdns -lesp_local_ctrl -lsdmmc -lesp_serial_slave_link -lesp_websocket_client -lexpat -lwear_levelling -lfatfs -lfreemodbus -ljsmn -ljson -llibsodium -lmqtt -lopenssl -lperfmon -lspiffs -lusb -lulp -lwifi_provisioning -lbutton -lrmaker_common -ljson_parser -ljson_generator -lesp_schedule -lesp_rainmaker -lqrcode -lws2812_led -lesp-dsp -lesp-sr -lesp32-camera -lesp_littlefs -lfb_gfx -lasio -lcbor -lcmock -lunity -lcoap -lesp_lcd -lesp_websocket_client -lexpat -lfreemodbus -ljsmn -llibsodium -lperfmon -lusb -lesp_adc_cal -lesp_hid -lfatfs -lwear_levelling -lopenssl -lesp_rainmaker -lesp_local_ctrl -lesp_https_server -lwifi_provisioning -lprotocomm -lbt -lbtdm_app -lprotobuf-c -lmdns -lrmaker_common -lmqtt -ljson_parser -ljson_generator -lesp_schedule -lqrcode -larduino_tinyusb -lcat_face_detect -lhuman_face_detect -lcolor_detect -lmfn -ldl -lwakenet -lhufzip -lesp_audio_front_end -lesp_audio_processor -lmultinet -lesp-sr -lwakenet -lhufzip -lesp_audio_front_end -lesp_audio_processor -lmultinet -ljson -lspiffs -ldl_lib -lc_speech_features -lesp_tts_chinese -lvoice_set_xiaole -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lphy -lbtbb -lesp_phy -lphy -lbtbb -lesp_phy -lphy -lbtbb -lxt_hal -lm -lnewlib -lstdc++ -lpthread -lgcc -lcxx -lapp_trace -lgcov -lapp_trace -lgcov -lc +compiler.cpreprocessor.flags.esp32s3=-DHAVE_CONFIG_H -DMBEDTLS_CONFIG_FILE="mbedtls/esp_config.h" -DUNITY_INCLUDE_CONFIG_H -DWITH_POSIX -D_GNU_SOURCE -DIDF_VER="v4.4.1-405-g6c5fb29c2c" -DESP_PLATFORM -D_POSIX_READER_WRITER_LOCKS "-I{compiler.sdk.path}/include/newlib/platform_include" "-I{compiler.sdk.path}/include/freertos/include" "-I{compiler.sdk.path}/include/freertos/include/esp_additions/freertos" "-I{compiler.sdk.path}/include/freertos/port/xtensa/include" "-I{compiler.sdk.path}/include/freertos/include/esp_additions" "-I{compiler.sdk.path}/include/esp_hw_support/include" "-I{compiler.sdk.path}/include/esp_hw_support/include/soc" "-I{compiler.sdk.path}/include/esp_hw_support/include/soc/esp32s3" "-I{compiler.sdk.path}/include/esp_hw_support/port/esp32s3" "-I{compiler.sdk.path}/include/esp_hw_support/port/esp32s3/private_include" "-I{compiler.sdk.path}/include/heap/include" "-I{compiler.sdk.path}/include/log/include" "-I{compiler.sdk.path}/include/lwip/include/apps" "-I{compiler.sdk.path}/include/lwip/include/apps/sntp" "-I{compiler.sdk.path}/include/lwip/lwip/src/include" "-I{compiler.sdk.path}/include/lwip/port/esp32/include" "-I{compiler.sdk.path}/include/lwip/port/esp32/include/arch" "-I{compiler.sdk.path}/include/soc/include" "-I{compiler.sdk.path}/include/soc/esp32s3" "-I{compiler.sdk.path}/include/soc/esp32s3/include" "-I{compiler.sdk.path}/include/hal/esp32s3/include" "-I{compiler.sdk.path}/include/hal/include" "-I{compiler.sdk.path}/include/hal/platform_port/include" "-I{compiler.sdk.path}/include/esp_rom/include" "-I{compiler.sdk.path}/include/esp_rom/include/esp32s3" "-I{compiler.sdk.path}/include/esp_rom/esp32s3" "-I{compiler.sdk.path}/include/esp_common/include" "-I{compiler.sdk.path}/include/esp_system/include" "-I{compiler.sdk.path}/include/esp_system/port/soc" "-I{compiler.sdk.path}/include/esp_system/port/public_compat" "-I{compiler.sdk.path}/include/xtensa/include" "-I{compiler.sdk.path}/include/xtensa/esp32s3/include" "-I{compiler.sdk.path}/include/driver/include" "-I{compiler.sdk.path}/include/driver/esp32s3/include" "-I{compiler.sdk.path}/include/esp_pm/include" "-I{compiler.sdk.path}/include/esp_ringbuf/include" "-I{compiler.sdk.path}/include/efuse/include" "-I{compiler.sdk.path}/include/efuse/esp32s3/include" "-I{compiler.sdk.path}/include/vfs/include" "-I{compiler.sdk.path}/include/esp_wifi/include" "-I{compiler.sdk.path}/include/esp_event/include" "-I{compiler.sdk.path}/include/esp_netif/include" "-I{compiler.sdk.path}/include/esp_eth/include" "-I{compiler.sdk.path}/include/tcpip_adapter/include" "-I{compiler.sdk.path}/include/esp_phy/include" "-I{compiler.sdk.path}/include/esp_phy/esp32s3/include" "-I{compiler.sdk.path}/include/esp_ipc/include" "-I{compiler.sdk.path}/include/app_trace/include" "-I{compiler.sdk.path}/include/esp_timer/include" "-I{compiler.sdk.path}/include/mbedtls/port/include" "-I{compiler.sdk.path}/include/mbedtls/mbedtls/include" "-I{compiler.sdk.path}/include/mbedtls/esp_crt_bundle/include" "-I{compiler.sdk.path}/include/app_update/include" "-I{compiler.sdk.path}/include/spi_flash/include" "-I{compiler.sdk.path}/include/bootloader_support/include" "-I{compiler.sdk.path}/include/nvs_flash/include" "-I{compiler.sdk.path}/include/pthread/include" "-I{compiler.sdk.path}/include/esp_gdbstub/include" "-I{compiler.sdk.path}/include/esp_gdbstub/xtensa" "-I{compiler.sdk.path}/include/esp_gdbstub/esp32s3" "-I{compiler.sdk.path}/include/espcoredump/include" "-I{compiler.sdk.path}/include/espcoredump/include/port/xtensa" "-I{compiler.sdk.path}/include/wpa_supplicant/include" "-I{compiler.sdk.path}/include/wpa_supplicant/port/include" "-I{compiler.sdk.path}/include/wpa_supplicant/esp_supplicant/include" "-I{compiler.sdk.path}/include/ieee802154/include" "-I{compiler.sdk.path}/include/console" "-I{compiler.sdk.path}/include/asio/asio/asio/include" "-I{compiler.sdk.path}/include/asio/port/include" "-I{compiler.sdk.path}/include/bt/common/osi/include" "-I{compiler.sdk.path}/include/bt/include/esp32s3/include" "-I{compiler.sdk.path}/include/bt/common/api/include/api" "-I{compiler.sdk.path}/include/bt/common/btc/profile/esp/blufi/include" "-I{compiler.sdk.path}/include/bt/common/btc/profile/esp/include" "-I{compiler.sdk.path}/include/bt/host/bluedroid/api/include/api" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/mesh_common/include" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/mesh_core" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/mesh_core/include" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/mesh_core/storage" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/btc/include" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/mesh_models/common/include" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/mesh_models/client/include" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/mesh_models/server/include" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/api/core/include" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/api/models/include" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/api" "-I{compiler.sdk.path}/include/cbor/port/include" "-I{compiler.sdk.path}/include/unity/include" "-I{compiler.sdk.path}/include/unity/unity/src" "-I{compiler.sdk.path}/include/cmock/CMock/src" "-I{compiler.sdk.path}/include/coap/port/include" "-I{compiler.sdk.path}/include/coap/libcoap/include" "-I{compiler.sdk.path}/include/nghttp/port/include" "-I{compiler.sdk.path}/include/nghttp/nghttp2/lib/includes" "-I{compiler.sdk.path}/include/esp-tls" "-I{compiler.sdk.path}/include/esp-tls/esp-tls-crypto" "-I{compiler.sdk.path}/include/esp_adc_cal/include" "-I{compiler.sdk.path}/include/esp_hid/include" "-I{compiler.sdk.path}/include/tcp_transport/include" "-I{compiler.sdk.path}/include/esp_http_client/include" "-I{compiler.sdk.path}/include/esp_http_server/include" "-I{compiler.sdk.path}/include/esp_https_ota/include" "-I{compiler.sdk.path}/include/esp_https_server/include" "-I{compiler.sdk.path}/include/esp_lcd/include" "-I{compiler.sdk.path}/include/esp_lcd/interface" "-I{compiler.sdk.path}/include/protobuf-c/protobuf-c" "-I{compiler.sdk.path}/include/protocomm/include/common" "-I{compiler.sdk.path}/include/protocomm/include/security" "-I{compiler.sdk.path}/include/protocomm/include/transports" "-I{compiler.sdk.path}/include/mdns/include" "-I{compiler.sdk.path}/include/esp_local_ctrl/include" "-I{compiler.sdk.path}/include/sdmmc/include" "-I{compiler.sdk.path}/include/esp_serial_slave_link/include" "-I{compiler.sdk.path}/include/esp_websocket_client/include" "-I{compiler.sdk.path}/include/expat/expat/expat/lib" "-I{compiler.sdk.path}/include/expat/port/include" "-I{compiler.sdk.path}/include/wear_levelling/include" "-I{compiler.sdk.path}/include/fatfs/diskio" "-I{compiler.sdk.path}/include/fatfs/vfs" "-I{compiler.sdk.path}/include/fatfs/src" "-I{compiler.sdk.path}/include/freemodbus/common/include" "-I{compiler.sdk.path}/include/idf_test/include" "-I{compiler.sdk.path}/include/idf_test/include/esp32s3" "-I{compiler.sdk.path}/include/jsmn/include" "-I{compiler.sdk.path}/include/json/cJSON" "-I{compiler.sdk.path}/include/libsodium/libsodium/src/libsodium/include" "-I{compiler.sdk.path}/include/libsodium/port_include" "-I{compiler.sdk.path}/include/mqtt/esp-mqtt/include" "-I{compiler.sdk.path}/include/openssl/include" "-I{compiler.sdk.path}/include/perfmon/include" "-I{compiler.sdk.path}/include/spiffs/include" "-I{compiler.sdk.path}/include/usb/include" "-I{compiler.sdk.path}/include/ulp/include" "-I{compiler.sdk.path}/include/wifi_provisioning/include" "-I{compiler.sdk.path}/include/button/button/include" "-I{compiler.sdk.path}/include/rmaker_common/include" "-I{compiler.sdk.path}/include/json_parser/upstream/include" "-I{compiler.sdk.path}/include/json_parser/upstream" "-I{compiler.sdk.path}/include/json_generator/upstream" "-I{compiler.sdk.path}/include/esp_schedule/include" "-I{compiler.sdk.path}/include/esp_rainmaker/include" "-I{compiler.sdk.path}/include/qrcode/include" "-I{compiler.sdk.path}/include/ws2812_led" "-I{compiler.sdk.path}/include/esp-dsp/modules/dotprod/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/support/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/hann/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/blackman/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/blackman_harris/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/blackman_nuttall/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/nuttall/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/flat_top/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/iir/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/fir/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/add/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/sub/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/mul/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/addc/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/mulc/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/sqrt/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/matrix/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/fft/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/dct/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/conv/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/common/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/kalman/ekf/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/kalman/ekf_imu13states/include" "-I{compiler.sdk.path}/include/freertos/include/freertos" "-I{compiler.sdk.path}/include/arduino_tinyusb/tinyusb/src" "-I{compiler.sdk.path}/include/arduino_tinyusb/include" "-I{compiler.sdk.path}/include/esp_littlefs/src" "-I{compiler.sdk.path}/include/esp_littlefs/include" "-I{compiler.sdk.path}/include/esp-dl/include" "-I{compiler.sdk.path}/include/esp-dl/include/tool" "-I{compiler.sdk.path}/include/esp-dl/include/typedef" "-I{compiler.sdk.path}/include/esp-dl/include/image" "-I{compiler.sdk.path}/include/esp-dl/include/math" "-I{compiler.sdk.path}/include/esp-dl/include/nn" "-I{compiler.sdk.path}/include/esp-dl/include/layer" "-I{compiler.sdk.path}/include/esp-dl/include/detect" "-I{compiler.sdk.path}/include/esp-dl/include/model_zoo" "-I{compiler.sdk.path}/include/esp-sr/esp-tts/esp_tts_chinese/include" "-I{compiler.sdk.path}/include/esp-sr/include/esp32s3" "-I{compiler.sdk.path}/include/esp32-camera/driver/include" "-I{compiler.sdk.path}/include/esp32-camera/conversions/include" "-I{compiler.sdk.path}/include/fb_gfx/include" +compiler.c.elf.libs.esp32s3=-lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lasio -lbt -lcbor -lunity -lcmock -lcoap -lnghttp -lesp-tls -lesp_adc_cal -lesp_hid -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lesp_https_server -lesp_lcd -lprotobuf-c -lprotocomm -lmdns -lesp_local_ctrl -lsdmmc -lesp_serial_slave_link -lesp_websocket_client -lexpat -lwear_levelling -lfatfs -lfreemodbus -ljsmn -ljson -llibsodium -lmqtt -lopenssl -lperfmon -lspiffs -lusb -lulp -lwifi_provisioning -lbutton -lrmaker_common -ljson_parser -ljson_generator -lesp_schedule -lesp_rainmaker -lqrcode -lws2812_led -lesp-dsp -lesp-sr -lesp32-camera -lesp_littlefs -lfb_gfx -lasio -lcbor -lcmock -lunity -lcoap -lesp_lcd -lesp_websocket_client -lexpat -lfreemodbus -ljsmn -llibsodium -lperfmon -lusb -lesp_adc_cal -lesp_hid -lfatfs -lwear_levelling -lopenssl -lesp_rainmaker -lesp_local_ctrl -lesp_https_server -lwifi_provisioning -lprotocomm -lbt -lbtdm_app -lprotobuf-c -lmdns -lrmaker_common -lmqtt -ljson_parser -ljson_generator -lesp_schedule -lqrcode -larduino_tinyusb -lcat_face_detect -lhuman_face_detect -lcolor_detect -lmfn -ldl -lwakenet -lhufzip -lesp_audio_front_end -lesp_audio_processor -lmultinet -lesp-sr -lwakenet -lhufzip -lesp_audio_front_end -lesp_audio_processor -lmultinet -ljson -lspiffs -ldl_lib -lc_speech_features -lesp_tts_chinese -lvoice_set_xiaole -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls_2 -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls_2 -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls_2 -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls_2 -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls_2 -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls_2 -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lphy -lbtbb -lesp_phy -lphy -lbtbb -lesp_phy -lphy -lbtbb -lxt_hal -lm -lnewlib -lstdc++ -lpthread -lgcc -lcxx -lapp_trace -lgcov -lapp_trace -lgcov -lc compiler.c.flags.esp32s3=-mlongcalls -ffunction-sections -fdata-sections -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-sign-compare -ggdb -Os -freorder-blocks -Wwrite-strings -fstack-protector -fstrict-volatile-bitfields -Wno-error=unused-but-set-variable -fno-jump-tables -fno-tree-switch-conversion -std=gnu99 -Wno-old-style-declaration -MMD -c compiler.cpp.flags.esp32s3=-mlongcalls -ffunction-sections -fdata-sections -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-sign-compare -ggdb -Os -freorder-blocks -Wwrite-strings -fstack-protector -fstrict-volatile-bitfields -Wno-error=unused-but-set-variable -fno-jump-tables -fno-tree-switch-conversion -std=gnu++11 -fexceptions -fno-rtti -MMD -c compiler.S.flags.esp32s3=-ffunction-sections -fdata-sections -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-sign-compare -ggdb -Os -freorder-blocks -Wwrite-strings -fstack-protector -fstrict-volatile-bitfields -Wno-error=unused-but-set-variable -fno-jump-tables -fno-tree-switch-conversion -x assembler-with-cpp -MMD -c @@ -57,8 +57,8 @@ build.extra_flags.esp32s3=-DARDUINO_USB_MODE={build.usb_mode} -DARDUINO_USB_CDC_ # # ESP32S2 Support Start # -compiler.cpreprocessor.flags.esp32s2=-DHAVE_CONFIG_H -DMBEDTLS_CONFIG_FILE="mbedtls/esp_config.h" -DUNITY_INCLUDE_CONFIG_H -DWITH_POSIX -D_GNU_SOURCE -DIDF_VER="v4.4.1-1-gb8050b365e" -DESP_PLATFORM -D_POSIX_READER_WRITER_LOCKS "-I{compiler.sdk.path}/include/config" "-I{compiler.sdk.path}/include/newlib/platform_include" "-I{compiler.sdk.path}/include/freertos/include" "-I{compiler.sdk.path}/include/freertos/include/esp_additions/freertos" "-I{compiler.sdk.path}/include/freertos/port/xtensa/include" "-I{compiler.sdk.path}/include/freertos/include/esp_additions" "-I{compiler.sdk.path}/include/esp_hw_support/include" "-I{compiler.sdk.path}/include/esp_hw_support/include/soc" "-I{compiler.sdk.path}/include/esp_hw_support/include/soc/esp32s2" "-I{compiler.sdk.path}/include/esp_hw_support/port/esp32s2" "-I{compiler.sdk.path}/include/esp_hw_support/port/esp32s2/private_include" "-I{compiler.sdk.path}/include/heap/include" "-I{compiler.sdk.path}/include/log/include" "-I{compiler.sdk.path}/include/lwip/include/apps" "-I{compiler.sdk.path}/include/lwip/include/apps/sntp" "-I{compiler.sdk.path}/include/lwip/lwip/src/include" "-I{compiler.sdk.path}/include/lwip/port/esp32/include" "-I{compiler.sdk.path}/include/lwip/port/esp32/include/arch" "-I{compiler.sdk.path}/include/soc/include" "-I{compiler.sdk.path}/include/soc/esp32s2" "-I{compiler.sdk.path}/include/soc/esp32s2/include" "-I{compiler.sdk.path}/include/hal/esp32s2/include" "-I{compiler.sdk.path}/include/hal/include" "-I{compiler.sdk.path}/include/hal/platform_port/include" "-I{compiler.sdk.path}/include/esp_rom/include" "-I{compiler.sdk.path}/include/esp_rom/include/esp32s2" "-I{compiler.sdk.path}/include/esp_rom/esp32s2" "-I{compiler.sdk.path}/include/esp_common/include" "-I{compiler.sdk.path}/include/esp_system/include" "-I{compiler.sdk.path}/include/esp_system/port/soc" "-I{compiler.sdk.path}/include/esp_system/port/public_compat" "-I{compiler.sdk.path}/include/xtensa/include" "-I{compiler.sdk.path}/include/xtensa/esp32s2/include" "-I{compiler.sdk.path}/include/driver/include" "-I{compiler.sdk.path}/include/driver/esp32s2/include" "-I{compiler.sdk.path}/include/esp_pm/include" "-I{compiler.sdk.path}/include/esp_ringbuf/include" "-I{compiler.sdk.path}/include/efuse/include" "-I{compiler.sdk.path}/include/efuse/esp32s2/include" "-I{compiler.sdk.path}/include/vfs/include" "-I{compiler.sdk.path}/include/esp_wifi/include" "-I{compiler.sdk.path}/include/esp_event/include" "-I{compiler.sdk.path}/include/esp_netif/include" "-I{compiler.sdk.path}/include/esp_eth/include" "-I{compiler.sdk.path}/include/tcpip_adapter/include" "-I{compiler.sdk.path}/include/esp_phy/include" "-I{compiler.sdk.path}/include/esp_phy/esp32s2/include" "-I{compiler.sdk.path}/include/esp_ipc/include" "-I{compiler.sdk.path}/include/app_trace/include" "-I{compiler.sdk.path}/include/esp_timer/include" "-I{compiler.sdk.path}/include/mbedtls/port/include" "-I{compiler.sdk.path}/include/mbedtls/mbedtls/include" "-I{compiler.sdk.path}/include/mbedtls/esp_crt_bundle/include" "-I{compiler.sdk.path}/include/app_update/include" "-I{compiler.sdk.path}/include/spi_flash/include" "-I{compiler.sdk.path}/include/bootloader_support/include" "-I{compiler.sdk.path}/include/nvs_flash/include" "-I{compiler.sdk.path}/include/pthread/include" "-I{compiler.sdk.path}/include/esp_gdbstub/include" "-I{compiler.sdk.path}/include/esp_gdbstub/xtensa" "-I{compiler.sdk.path}/include/esp_gdbstub/esp32s2" "-I{compiler.sdk.path}/include/espcoredump/include" "-I{compiler.sdk.path}/include/espcoredump/include/port/xtensa" "-I{compiler.sdk.path}/include/wpa_supplicant/include" "-I{compiler.sdk.path}/include/wpa_supplicant/port/include" "-I{compiler.sdk.path}/include/wpa_supplicant/esp_supplicant/include" "-I{compiler.sdk.path}/include/ieee802154/include" "-I{compiler.sdk.path}/include/console" "-I{compiler.sdk.path}/include/asio/asio/asio/include" "-I{compiler.sdk.path}/include/asio/port/include" "-I{compiler.sdk.path}/include/cbor/port/include" "-I{compiler.sdk.path}/include/unity/include" "-I{compiler.sdk.path}/include/unity/unity/src" "-I{compiler.sdk.path}/include/cmock/CMock/src" "-I{compiler.sdk.path}/include/coap/port/include" "-I{compiler.sdk.path}/include/coap/libcoap/include" "-I{compiler.sdk.path}/include/nghttp/port/include" "-I{compiler.sdk.path}/include/nghttp/nghttp2/lib/includes" "-I{compiler.sdk.path}/include/esp-tls" "-I{compiler.sdk.path}/include/esp-tls/esp-tls-crypto" "-I{compiler.sdk.path}/include/esp_adc_cal/include" "-I{compiler.sdk.path}/include/esp_hid/include" "-I{compiler.sdk.path}/include/tcp_transport/include" "-I{compiler.sdk.path}/include/esp_http_client/include" "-I{compiler.sdk.path}/include/esp_http_server/include" "-I{compiler.sdk.path}/include/esp_https_ota/include" "-I{compiler.sdk.path}/include/esp_https_server/include" "-I{compiler.sdk.path}/include/esp_lcd/include" "-I{compiler.sdk.path}/include/esp_lcd/interface" "-I{compiler.sdk.path}/include/protobuf-c/protobuf-c" "-I{compiler.sdk.path}/include/protocomm/include/common" "-I{compiler.sdk.path}/include/protocomm/include/security" "-I{compiler.sdk.path}/include/protocomm/include/transports" "-I{compiler.sdk.path}/include/mdns/include" "-I{compiler.sdk.path}/include/esp_local_ctrl/include" "-I{compiler.sdk.path}/include/sdmmc/include" "-I{compiler.sdk.path}/include/esp_serial_slave_link/include" "-I{compiler.sdk.path}/include/esp_websocket_client/include" "-I{compiler.sdk.path}/include/expat/expat/expat/lib" "-I{compiler.sdk.path}/include/expat/port/include" "-I{compiler.sdk.path}/include/wear_levelling/include" "-I{compiler.sdk.path}/include/fatfs/diskio" "-I{compiler.sdk.path}/include/fatfs/vfs" "-I{compiler.sdk.path}/include/fatfs/src" "-I{compiler.sdk.path}/include/freemodbus/common/include" "-I{compiler.sdk.path}/include/idf_test/include" "-I{compiler.sdk.path}/include/idf_test/include/esp32s2" "-I{compiler.sdk.path}/include/jsmn/include" "-I{compiler.sdk.path}/include/json/cJSON" "-I{compiler.sdk.path}/include/libsodium/libsodium/src/libsodium/include" "-I{compiler.sdk.path}/include/libsodium/port_include" "-I{compiler.sdk.path}/include/mqtt/esp-mqtt/include" "-I{compiler.sdk.path}/include/openssl/include" "-I{compiler.sdk.path}/include/perfmon/include" "-I{compiler.sdk.path}/include/spiffs/include" "-I{compiler.sdk.path}/include/usb/include" "-I{compiler.sdk.path}/include/touch_element/include" "-I{compiler.sdk.path}/include/ulp/include" "-I{compiler.sdk.path}/include/wifi_provisioning/include" "-I{compiler.sdk.path}/include/button/button/include" "-I{compiler.sdk.path}/include/rmaker_common/include" "-I{compiler.sdk.path}/include/json_parser/upstream/include" "-I{compiler.sdk.path}/include/json_parser/upstream" "-I{compiler.sdk.path}/include/json_generator/upstream" "-I{compiler.sdk.path}/include/esp_schedule/include" "-I{compiler.sdk.path}/include/esp_rainmaker/include" "-I{compiler.sdk.path}/include/qrcode/include" "-I{compiler.sdk.path}/include/ws2812_led" "-I{compiler.sdk.path}/include/esp-dsp/modules/dotprod/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/support/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/hann/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/blackman/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/blackman_harris/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/blackman_nuttall/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/nuttall/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/flat_top/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/iir/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/fir/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/add/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/sub/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/mul/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/addc/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/mulc/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/sqrt/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/matrix/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/fft/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/dct/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/conv/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/common/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/kalman/ekf/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/kalman/ekf_imu13states/include" "-I{compiler.sdk.path}/include/freertos/include/freertos" "-I{compiler.sdk.path}/include/arduino_tinyusb/tinyusb/src" "-I{compiler.sdk.path}/include/arduino_tinyusb/include" "-I{compiler.sdk.path}/include/esp_littlefs/src" "-I{compiler.sdk.path}/include/esp_littlefs/include" "-I{compiler.sdk.path}/include/esp-dl/include" "-I{compiler.sdk.path}/include/esp-dl/include/tool" "-I{compiler.sdk.path}/include/esp-dl/include/typedef" "-I{compiler.sdk.path}/include/esp-dl/include/image" "-I{compiler.sdk.path}/include/esp-dl/include/math" "-I{compiler.sdk.path}/include/esp-dl/include/nn" "-I{compiler.sdk.path}/include/esp-dl/include/layer" "-I{compiler.sdk.path}/include/esp-dl/include/detect" "-I{compiler.sdk.path}/include/esp-dl/include/model_zoo" "-I{compiler.sdk.path}/include/esp-sr/esp-tts/esp_tts_chinese/include" "-I{compiler.sdk.path}/include/esp-sr/include/esp32" "-I{compiler.sdk.path}/include/esp32-camera/driver/include" "-I{compiler.sdk.path}/include/esp32-camera/conversions/include" "-I{compiler.sdk.path}/include/fb_gfx/include" -compiler.c.elf.libs.esp32s2=-lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lasio -lcbor -lunity -lcmock -lcoap -lnghttp -lesp-tls -lesp_adc_cal -lesp_hid -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lesp_https_server -lesp_lcd -lprotobuf-c -lprotocomm -lmdns -lesp_local_ctrl -lsdmmc -lesp_serial_slave_link -lesp_websocket_client -lexpat -lwear_levelling -lfatfs -lfreemodbus -ljsmn -ljson -llibsodium -lmqtt -lopenssl -lperfmon -lspiffs -lusb -ltouch_element -lulp -lwifi_provisioning -lbutton -lrmaker_common -ljson_parser -ljson_generator -lesp_schedule -lesp_rainmaker -lqrcode -lws2812_led -lesp-dsp -lesp-sr -lesp32-camera -lesp_littlefs -lfb_gfx -lasio -lcbor -lcmock -lunity -lcoap -lesp_lcd -lesp_websocket_client -lexpat -lfreemodbus -ljsmn -llibsodium -lperfmon -lusb -ltouch_element -lesp_adc_cal -lesp_hid -lfatfs -lwear_levelling -lopenssl -lesp_rainmaker -lesp_local_ctrl -lesp_https_server -lwifi_provisioning -lprotocomm -lprotobuf-c -lmdns -lrmaker_common -lmqtt -ljson_parser -ljson_generator -lesp_schedule -lqrcode -larduino_tinyusb -lcat_face_detect -lhuman_face_detect -lcolor_detect -lmfn -ldl -ljson -lspiffs -lesp_tts_chinese -lvoice_set_xiaole -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lphy -lesp_phy -lphy -lesp_phy -lphy -lxt_hal -lm -lnewlib -lstdc++ -lpthread -lgcc -lcxx -lapp_trace -lgcov -lapp_trace -lgcov -lc +compiler.cpreprocessor.flags.esp32s2=-DHAVE_CONFIG_H -DMBEDTLS_CONFIG_FILE="mbedtls/esp_config.h" -DUNITY_INCLUDE_CONFIG_H -DWITH_POSIX -D_GNU_SOURCE -DIDF_VER="v4.4.1-405-g6c5fb29c2c" -DESP_PLATFORM -D_POSIX_READER_WRITER_LOCKS "-I{compiler.sdk.path}/include/newlib/platform_include" "-I{compiler.sdk.path}/include/freertos/include" "-I{compiler.sdk.path}/include/freertos/include/esp_additions/freertos" "-I{compiler.sdk.path}/include/freertos/port/xtensa/include" "-I{compiler.sdk.path}/include/freertos/include/esp_additions" "-I{compiler.sdk.path}/include/esp_hw_support/include" "-I{compiler.sdk.path}/include/esp_hw_support/include/soc" "-I{compiler.sdk.path}/include/esp_hw_support/include/soc/esp32s2" "-I{compiler.sdk.path}/include/esp_hw_support/port/esp32s2" "-I{compiler.sdk.path}/include/esp_hw_support/port/esp32s2/private_include" "-I{compiler.sdk.path}/include/heap/include" "-I{compiler.sdk.path}/include/log/include" "-I{compiler.sdk.path}/include/lwip/include/apps" "-I{compiler.sdk.path}/include/lwip/include/apps/sntp" "-I{compiler.sdk.path}/include/lwip/lwip/src/include" "-I{compiler.sdk.path}/include/lwip/port/esp32/include" "-I{compiler.sdk.path}/include/lwip/port/esp32/include/arch" "-I{compiler.sdk.path}/include/soc/include" "-I{compiler.sdk.path}/include/soc/esp32s2" "-I{compiler.sdk.path}/include/soc/esp32s2/include" "-I{compiler.sdk.path}/include/hal/esp32s2/include" "-I{compiler.sdk.path}/include/hal/include" "-I{compiler.sdk.path}/include/hal/platform_port/include" "-I{compiler.sdk.path}/include/esp_rom/include" "-I{compiler.sdk.path}/include/esp_rom/include/esp32s2" "-I{compiler.sdk.path}/include/esp_rom/esp32s2" "-I{compiler.sdk.path}/include/esp_common/include" "-I{compiler.sdk.path}/include/esp_system/include" "-I{compiler.sdk.path}/include/esp_system/port/soc" "-I{compiler.sdk.path}/include/esp_system/port/public_compat" "-I{compiler.sdk.path}/include/xtensa/include" "-I{compiler.sdk.path}/include/xtensa/esp32s2/include" "-I{compiler.sdk.path}/include/driver/include" "-I{compiler.sdk.path}/include/driver/esp32s2/include" "-I{compiler.sdk.path}/include/esp_pm/include" "-I{compiler.sdk.path}/include/esp_ringbuf/include" "-I{compiler.sdk.path}/include/efuse/include" "-I{compiler.sdk.path}/include/efuse/esp32s2/include" "-I{compiler.sdk.path}/include/vfs/include" "-I{compiler.sdk.path}/include/esp_wifi/include" "-I{compiler.sdk.path}/include/esp_event/include" "-I{compiler.sdk.path}/include/esp_netif/include" "-I{compiler.sdk.path}/include/esp_eth/include" "-I{compiler.sdk.path}/include/tcpip_adapter/include" "-I{compiler.sdk.path}/include/esp_phy/include" "-I{compiler.sdk.path}/include/esp_phy/esp32s2/include" "-I{compiler.sdk.path}/include/esp_ipc/include" "-I{compiler.sdk.path}/include/app_trace/include" "-I{compiler.sdk.path}/include/esp_timer/include" "-I{compiler.sdk.path}/include/mbedtls/port/include" "-I{compiler.sdk.path}/include/mbedtls/mbedtls/include" "-I{compiler.sdk.path}/include/mbedtls/esp_crt_bundle/include" "-I{compiler.sdk.path}/include/app_update/include" "-I{compiler.sdk.path}/include/spi_flash/include" "-I{compiler.sdk.path}/include/bootloader_support/include" "-I{compiler.sdk.path}/include/nvs_flash/include" "-I{compiler.sdk.path}/include/pthread/include" "-I{compiler.sdk.path}/include/esp_gdbstub/include" "-I{compiler.sdk.path}/include/esp_gdbstub/xtensa" "-I{compiler.sdk.path}/include/esp_gdbstub/esp32s2" "-I{compiler.sdk.path}/include/espcoredump/include" "-I{compiler.sdk.path}/include/espcoredump/include/port/xtensa" "-I{compiler.sdk.path}/include/wpa_supplicant/include" "-I{compiler.sdk.path}/include/wpa_supplicant/port/include" "-I{compiler.sdk.path}/include/wpa_supplicant/esp_supplicant/include" "-I{compiler.sdk.path}/include/ieee802154/include" "-I{compiler.sdk.path}/include/console" "-I{compiler.sdk.path}/include/asio/asio/asio/include" "-I{compiler.sdk.path}/include/asio/port/include" "-I{compiler.sdk.path}/include/cbor/port/include" "-I{compiler.sdk.path}/include/unity/include" "-I{compiler.sdk.path}/include/unity/unity/src" "-I{compiler.sdk.path}/include/cmock/CMock/src" "-I{compiler.sdk.path}/include/coap/port/include" "-I{compiler.sdk.path}/include/coap/libcoap/include" "-I{compiler.sdk.path}/include/nghttp/port/include" "-I{compiler.sdk.path}/include/nghttp/nghttp2/lib/includes" "-I{compiler.sdk.path}/include/esp-tls" "-I{compiler.sdk.path}/include/esp-tls/esp-tls-crypto" "-I{compiler.sdk.path}/include/esp_adc_cal/include" "-I{compiler.sdk.path}/include/esp_hid/include" "-I{compiler.sdk.path}/include/tcp_transport/include" "-I{compiler.sdk.path}/include/esp_http_client/include" "-I{compiler.sdk.path}/include/esp_http_server/include" "-I{compiler.sdk.path}/include/esp_https_ota/include" "-I{compiler.sdk.path}/include/esp_https_server/include" "-I{compiler.sdk.path}/include/esp_lcd/include" "-I{compiler.sdk.path}/include/esp_lcd/interface" "-I{compiler.sdk.path}/include/protobuf-c/protobuf-c" "-I{compiler.sdk.path}/include/protocomm/include/common" "-I{compiler.sdk.path}/include/protocomm/include/security" "-I{compiler.sdk.path}/include/protocomm/include/transports" "-I{compiler.sdk.path}/include/mdns/include" "-I{compiler.sdk.path}/include/esp_local_ctrl/include" "-I{compiler.sdk.path}/include/sdmmc/include" "-I{compiler.sdk.path}/include/esp_serial_slave_link/include" "-I{compiler.sdk.path}/include/esp_websocket_client/include" "-I{compiler.sdk.path}/include/expat/expat/expat/lib" "-I{compiler.sdk.path}/include/expat/port/include" "-I{compiler.sdk.path}/include/wear_levelling/include" "-I{compiler.sdk.path}/include/fatfs/diskio" "-I{compiler.sdk.path}/include/fatfs/vfs" "-I{compiler.sdk.path}/include/fatfs/src" "-I{compiler.sdk.path}/include/freemodbus/common/include" "-I{compiler.sdk.path}/include/idf_test/include" "-I{compiler.sdk.path}/include/idf_test/include/esp32s2" "-I{compiler.sdk.path}/include/jsmn/include" "-I{compiler.sdk.path}/include/json/cJSON" "-I{compiler.sdk.path}/include/libsodium/libsodium/src/libsodium/include" "-I{compiler.sdk.path}/include/libsodium/port_include" "-I{compiler.sdk.path}/include/mqtt/esp-mqtt/include" "-I{compiler.sdk.path}/include/openssl/include" "-I{compiler.sdk.path}/include/perfmon/include" "-I{compiler.sdk.path}/include/spiffs/include" "-I{compiler.sdk.path}/include/usb/include" "-I{compiler.sdk.path}/include/touch_element/include" "-I{compiler.sdk.path}/include/ulp/include" "-I{compiler.sdk.path}/include/wifi_provisioning/include" "-I{compiler.sdk.path}/include/button/button/include" "-I{compiler.sdk.path}/include/rmaker_common/include" "-I{compiler.sdk.path}/include/json_parser/upstream/include" "-I{compiler.sdk.path}/include/json_parser/upstream" "-I{compiler.sdk.path}/include/json_generator/upstream" "-I{compiler.sdk.path}/include/esp_schedule/include" "-I{compiler.sdk.path}/include/esp_rainmaker/include" "-I{compiler.sdk.path}/include/qrcode/include" "-I{compiler.sdk.path}/include/ws2812_led" "-I{compiler.sdk.path}/include/esp-dsp/modules/dotprod/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/support/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/hann/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/blackman/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/blackman_harris/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/blackman_nuttall/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/nuttall/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/flat_top/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/iir/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/fir/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/add/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/sub/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/mul/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/addc/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/mulc/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/sqrt/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/matrix/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/fft/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/dct/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/conv/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/common/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/kalman/ekf/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/kalman/ekf_imu13states/include" "-I{compiler.sdk.path}/include/freertos/include/freertos" "-I{compiler.sdk.path}/include/arduino_tinyusb/tinyusb/src" "-I{compiler.sdk.path}/include/arduino_tinyusb/include" "-I{compiler.sdk.path}/include/esp_littlefs/src" "-I{compiler.sdk.path}/include/esp_littlefs/include" "-I{compiler.sdk.path}/include/esp-dl/include" "-I{compiler.sdk.path}/include/esp-dl/include/tool" "-I{compiler.sdk.path}/include/esp-dl/include/typedef" "-I{compiler.sdk.path}/include/esp-dl/include/image" "-I{compiler.sdk.path}/include/esp-dl/include/math" "-I{compiler.sdk.path}/include/esp-dl/include/nn" "-I{compiler.sdk.path}/include/esp-dl/include/layer" "-I{compiler.sdk.path}/include/esp-dl/include/detect" "-I{compiler.sdk.path}/include/esp-dl/include/model_zoo" "-I{compiler.sdk.path}/include/esp-sr/esp-tts/esp_tts_chinese/include" "-I{compiler.sdk.path}/include/esp-sr/include/esp32" "-I{compiler.sdk.path}/include/esp32-camera/driver/include" "-I{compiler.sdk.path}/include/esp32-camera/conversions/include" "-I{compiler.sdk.path}/include/fb_gfx/include" +compiler.c.elf.libs.esp32s2=-lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lasio -lcbor -lunity -lcmock -lcoap -lnghttp -lesp-tls -lesp_adc_cal -lesp_hid -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lesp_https_server -lesp_lcd -lprotobuf-c -lprotocomm -lmdns -lesp_local_ctrl -lsdmmc -lesp_serial_slave_link -lesp_websocket_client -lexpat -lwear_levelling -lfatfs -lfreemodbus -ljsmn -ljson -llibsodium -lmqtt -lopenssl -lperfmon -lspiffs -lusb -ltouch_element -lulp -lwifi_provisioning -lbutton -lrmaker_common -ljson_parser -ljson_generator -lesp_schedule -lesp_rainmaker -lqrcode -lws2812_led -lesp-dsp -lesp-sr -lesp32-camera -lesp_littlefs -lfb_gfx -lasio -lcbor -lcmock -lunity -lcoap -lesp_lcd -lesp_websocket_client -lexpat -lfreemodbus -ljsmn -llibsodium -lperfmon -lusb -ltouch_element -lesp_adc_cal -lesp_hid -lfatfs -lwear_levelling -lopenssl -lesp_rainmaker -lesp_local_ctrl -lesp_https_server -lwifi_provisioning -lprotocomm -lprotobuf-c -lmdns -lrmaker_common -lmqtt -ljson_parser -ljson_generator -lesp_schedule -lqrcode -larduino_tinyusb -lcat_face_detect -lhuman_face_detect -lcolor_detect -lmfn -ldl -ljson -lspiffs -lesp_tts_chinese -lvoice_set_xiaole -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls_2 -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls_2 -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls_2 -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls_2 -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls_2 -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lxtensa -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lulp -lmbedtls_2 -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lphy -lesp_phy -lphy -lesp_phy -lphy -lxt_hal -lm -lnewlib -lstdc++ -lpthread -lgcc -lcxx -lapp_trace -lgcov -lapp_trace -lgcov -lc compiler.c.flags.esp32s2=-mlongcalls -ffunction-sections -fdata-sections -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-sign-compare -ggdb -Os -freorder-blocks -Wwrite-strings -fstack-protector -fstrict-volatile-bitfields -Wno-error=unused-but-set-variable -fno-jump-tables -fno-tree-switch-conversion -std=gnu99 -Wno-old-style-declaration -MMD -c compiler.cpp.flags.esp32s2=-mlongcalls -ffunction-sections -fdata-sections -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-sign-compare -ggdb -Os -freorder-blocks -Wwrite-strings -fstack-protector -fstrict-volatile-bitfields -Wno-error=unused-but-set-variable -fno-jump-tables -fno-tree-switch-conversion -std=gnu++11 -fexceptions -fno-rtti -MMD -c compiler.S.flags.esp32s2=-ffunction-sections -fdata-sections -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-sign-compare -ggdb -Os -freorder-blocks -Wwrite-strings -fstack-protector -fstrict-volatile-bitfields -Wno-error=unused-but-set-variable -fno-jump-tables -fno-tree-switch-conversion -x assembler-with-cpp -MMD -c @@ -72,8 +72,8 @@ build.extra_flags.esp32s2=-DARDUINO_USB_MODE=0 -DARDUINO_USB_CDC_ON_BOOT={build. # # ESP32C3 Support Start # -compiler.cpreprocessor.flags.esp32c3=-DHAVE_CONFIG_H -DMBEDTLS_CONFIG_FILE="mbedtls/esp_config.h" -DUNITY_INCLUDE_CONFIG_H -DWITH_POSIX -D_GNU_SOURCE -DIDF_VER="v4.4.1-1-gb8050b365e" -DESP_PLATFORM -D_POSIX_READER_WRITER_LOCKS "-I{compiler.sdk.path}/include/config" "-I{compiler.sdk.path}/include/newlib/platform_include" "-I{compiler.sdk.path}/include/freertos/include" "-I{compiler.sdk.path}/include/freertos/include/esp_additions/freertos" "-I{compiler.sdk.path}/include/freertos/port/riscv/include" "-I{compiler.sdk.path}/include/freertos/include/esp_additions" "-I{compiler.sdk.path}/include/esp_hw_support/include" "-I{compiler.sdk.path}/include/esp_hw_support/include/soc" "-I{compiler.sdk.path}/include/esp_hw_support/include/soc/esp32c3" "-I{compiler.sdk.path}/include/esp_hw_support/port/esp32c3" "-I{compiler.sdk.path}/include/esp_hw_support/port/esp32c3/private_include" "-I{compiler.sdk.path}/include/heap/include" "-I{compiler.sdk.path}/include/log/include" "-I{compiler.sdk.path}/include/lwip/include/apps" "-I{compiler.sdk.path}/include/lwip/include/apps/sntp" "-I{compiler.sdk.path}/include/lwip/lwip/src/include" "-I{compiler.sdk.path}/include/lwip/port/esp32/include" "-I{compiler.sdk.path}/include/lwip/port/esp32/include/arch" "-I{compiler.sdk.path}/include/soc/include" "-I{compiler.sdk.path}/include/soc/esp32c3" "-I{compiler.sdk.path}/include/soc/esp32c3/include" "-I{compiler.sdk.path}/include/hal/esp32c3/include" "-I{compiler.sdk.path}/include/hal/include" "-I{compiler.sdk.path}/include/hal/platform_port/include" "-I{compiler.sdk.path}/include/esp_rom/include" "-I{compiler.sdk.path}/include/esp_rom/include/esp32c3" "-I{compiler.sdk.path}/include/esp_rom/esp32c3" "-I{compiler.sdk.path}/include/esp_common/include" "-I{compiler.sdk.path}/include/esp_system/include" "-I{compiler.sdk.path}/include/esp_system/port/soc" "-I{compiler.sdk.path}/include/esp_system/port/include/riscv" "-I{compiler.sdk.path}/include/esp_system/port/public_compat" "-I{compiler.sdk.path}/include/riscv/include" "-I{compiler.sdk.path}/include/driver/include" "-I{compiler.sdk.path}/include/driver/esp32c3/include" "-I{compiler.sdk.path}/include/esp_pm/include" "-I{compiler.sdk.path}/include/esp_ringbuf/include" "-I{compiler.sdk.path}/include/efuse/include" "-I{compiler.sdk.path}/include/efuse/esp32c3/include" "-I{compiler.sdk.path}/include/vfs/include" "-I{compiler.sdk.path}/include/esp_wifi/include" "-I{compiler.sdk.path}/include/esp_event/include" "-I{compiler.sdk.path}/include/esp_netif/include" "-I{compiler.sdk.path}/include/esp_eth/include" "-I{compiler.sdk.path}/include/tcpip_adapter/include" "-I{compiler.sdk.path}/include/esp_phy/include" "-I{compiler.sdk.path}/include/esp_phy/esp32c3/include" "-I{compiler.sdk.path}/include/esp_ipc/include" "-I{compiler.sdk.path}/include/app_trace/include" "-I{compiler.sdk.path}/include/esp_timer/include" "-I{compiler.sdk.path}/include/mbedtls/port/include" "-I{compiler.sdk.path}/include/mbedtls/mbedtls/include" "-I{compiler.sdk.path}/include/mbedtls/esp_crt_bundle/include" "-I{compiler.sdk.path}/include/app_update/include" "-I{compiler.sdk.path}/include/spi_flash/include" "-I{compiler.sdk.path}/include/bootloader_support/include" "-I{compiler.sdk.path}/include/nvs_flash/include" "-I{compiler.sdk.path}/include/pthread/include" "-I{compiler.sdk.path}/include/esp_gdbstub/include" "-I{compiler.sdk.path}/include/esp_gdbstub/riscv" "-I{compiler.sdk.path}/include/esp_gdbstub/esp32c3" "-I{compiler.sdk.path}/include/espcoredump/include" "-I{compiler.sdk.path}/include/espcoredump/include/port/riscv" "-I{compiler.sdk.path}/include/wpa_supplicant/include" "-I{compiler.sdk.path}/include/wpa_supplicant/port/include" "-I{compiler.sdk.path}/include/wpa_supplicant/esp_supplicant/include" "-I{compiler.sdk.path}/include/ieee802154/include" "-I{compiler.sdk.path}/include/console" "-I{compiler.sdk.path}/include/asio/asio/asio/include" "-I{compiler.sdk.path}/include/asio/port/include" "-I{compiler.sdk.path}/include/bt/common/osi/include" "-I{compiler.sdk.path}/include/bt/include/esp32c3/include" "-I{compiler.sdk.path}/include/bt/common/api/include/api" "-I{compiler.sdk.path}/include/bt/common/btc/profile/esp/blufi/include" "-I{compiler.sdk.path}/include/bt/common/btc/profile/esp/include" "-I{compiler.sdk.path}/include/bt/host/bluedroid/api/include/api" "-I{compiler.sdk.path}/include/cbor/port/include" "-I{compiler.sdk.path}/include/unity/include" "-I{compiler.sdk.path}/include/unity/unity/src" "-I{compiler.sdk.path}/include/cmock/CMock/src" "-I{compiler.sdk.path}/include/coap/port/include" "-I{compiler.sdk.path}/include/coap/libcoap/include" "-I{compiler.sdk.path}/include/nghttp/port/include" "-I{compiler.sdk.path}/include/nghttp/nghttp2/lib/includes" "-I{compiler.sdk.path}/include/esp-tls" "-I{compiler.sdk.path}/include/esp-tls/esp-tls-crypto" "-I{compiler.sdk.path}/include/esp_adc_cal/include" "-I{compiler.sdk.path}/include/esp_hid/include" "-I{compiler.sdk.path}/include/tcp_transport/include" "-I{compiler.sdk.path}/include/esp_http_client/include" "-I{compiler.sdk.path}/include/esp_http_server/include" "-I{compiler.sdk.path}/include/esp_https_ota/include" "-I{compiler.sdk.path}/include/esp_https_server/include" "-I{compiler.sdk.path}/include/esp_lcd/include" "-I{compiler.sdk.path}/include/esp_lcd/interface" "-I{compiler.sdk.path}/include/protobuf-c/protobuf-c" "-I{compiler.sdk.path}/include/protocomm/include/common" "-I{compiler.sdk.path}/include/protocomm/include/security" "-I{compiler.sdk.path}/include/protocomm/include/transports" "-I{compiler.sdk.path}/include/mdns/include" "-I{compiler.sdk.path}/include/esp_local_ctrl/include" "-I{compiler.sdk.path}/include/sdmmc/include" "-I{compiler.sdk.path}/include/esp_serial_slave_link/include" "-I{compiler.sdk.path}/include/esp_websocket_client/include" "-I{compiler.sdk.path}/include/expat/expat/expat/lib" "-I{compiler.sdk.path}/include/expat/port/include" "-I{compiler.sdk.path}/include/wear_levelling/include" "-I{compiler.sdk.path}/include/fatfs/diskio" "-I{compiler.sdk.path}/include/fatfs/vfs" "-I{compiler.sdk.path}/include/fatfs/src" "-I{compiler.sdk.path}/include/freemodbus/common/include" "-I{compiler.sdk.path}/include/idf_test/include" "-I{compiler.sdk.path}/include/idf_test/include/esp32c3" "-I{compiler.sdk.path}/include/jsmn/include" "-I{compiler.sdk.path}/include/json/cJSON" "-I{compiler.sdk.path}/include/libsodium/libsodium/src/libsodium/include" "-I{compiler.sdk.path}/include/libsodium/port_include" "-I{compiler.sdk.path}/include/mqtt/esp-mqtt/include" "-I{compiler.sdk.path}/include/openssl/include" "-I{compiler.sdk.path}/include/spiffs/include" "-I{compiler.sdk.path}/include/wifi_provisioning/include" "-I{compiler.sdk.path}/include/button/button/include" "-I{compiler.sdk.path}/include/rmaker_common/include" "-I{compiler.sdk.path}/include/json_parser/upstream/include" "-I{compiler.sdk.path}/include/json_parser/upstream" "-I{compiler.sdk.path}/include/json_generator/upstream" "-I{compiler.sdk.path}/include/esp_schedule/include" "-I{compiler.sdk.path}/include/esp_rainmaker/include" "-I{compiler.sdk.path}/include/qrcode/include" "-I{compiler.sdk.path}/include/ws2812_led" "-I{compiler.sdk.path}/include/esp-dsp/modules/dotprod/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/support/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/hann/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/blackman/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/blackman_harris/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/blackman_nuttall/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/nuttall/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/flat_top/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/iir/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/fir/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/add/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/sub/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/mul/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/addc/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/mulc/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/sqrt/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/matrix/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/fft/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/dct/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/conv/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/common/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/kalman/ekf/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/kalman/ekf_imu13states/include" "-I{compiler.sdk.path}/include/esp_littlefs/src" "-I{compiler.sdk.path}/include/esp_littlefs/include" "-I{compiler.sdk.path}/include/esp-dl/include" "-I{compiler.sdk.path}/include/esp-dl/include/tool" "-I{compiler.sdk.path}/include/esp-dl/include/typedef" "-I{compiler.sdk.path}/include/esp-dl/include/image" "-I{compiler.sdk.path}/include/esp-dl/include/math" "-I{compiler.sdk.path}/include/esp-dl/include/nn" "-I{compiler.sdk.path}/include/esp-dl/include/layer" "-I{compiler.sdk.path}/include/esp-dl/include/detect" "-I{compiler.sdk.path}/include/esp-dl/include/model_zoo" "-I{compiler.sdk.path}/include/fb_gfx/include" -compiler.c.elf.libs.esp32c3=-lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lriscv -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lasio -lbt -lcbor -lunity -lcmock -lcoap -lnghttp -lesp-tls -lesp_adc_cal -lesp_hid -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lesp_https_server -lesp_lcd -lprotobuf-c -lprotocomm -lmdns -lesp_local_ctrl -lsdmmc -lesp_serial_slave_link -lesp_websocket_client -lexpat -lwear_levelling -lfatfs -lfreemodbus -ljsmn -ljson -llibsodium -lmqtt -lopenssl -lspiffs -lwifi_provisioning -lbutton -lrmaker_common -ljson_parser -ljson_generator -lesp_schedule -lesp_rainmaker -lqrcode -lws2812_led -lesp-dsp -lesp_littlefs -lfb_gfx -lasio -lcbor -lcmock -lunity -lcoap -lesp_lcd -lesp_websocket_client -lexpat -lfreemodbus -ljsmn -llibsodium -lesp_adc_cal -lesp_hid -lfatfs -lwear_levelling -lopenssl -lspiffs -lesp_rainmaker -lesp_local_ctrl -lesp_https_server -lwifi_provisioning -lprotocomm -lbt -lbtdm_app -lprotobuf-c -lmdns -ljson -lrmaker_common -lmqtt -ljson_parser -ljson_generator -lesp_schedule -lqrcode -lcat_face_detect -lhuman_face_detect -lcolor_detect -lmfn -ldl -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lriscv -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lriscv -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lriscv -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lriscv -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lriscv -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lriscv -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lmbedtls -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lphy -lbtbb -lesp_phy -lphy -lbtbb -lesp_phy -lphy -lbtbb -lm -lnewlib -lstdc++ -lpthread -lgcc -lcxx -lapp_trace -lgcov -lapp_trace -lgcov -lc +compiler.cpreprocessor.flags.esp32c3=-DHAVE_CONFIG_H -DMBEDTLS_CONFIG_FILE="mbedtls/esp_config.h" -DUNITY_INCLUDE_CONFIG_H -DWITH_POSIX -D_GNU_SOURCE -DIDF_VER="v4.4.1-405-g6c5fb29c2c" -DESP_PLATFORM -D_POSIX_READER_WRITER_LOCKS "-I{compiler.sdk.path}/include/newlib/platform_include" "-I{compiler.sdk.path}/include/freertos/include" "-I{compiler.sdk.path}/include/freertos/include/esp_additions/freertos" "-I{compiler.sdk.path}/include/freertos/port/riscv/include" "-I{compiler.sdk.path}/include/freertos/include/esp_additions" "-I{compiler.sdk.path}/include/esp_hw_support/include" "-I{compiler.sdk.path}/include/esp_hw_support/include/soc" "-I{compiler.sdk.path}/include/esp_hw_support/include/soc/esp32c3" "-I{compiler.sdk.path}/include/esp_hw_support/port/esp32c3" "-I{compiler.sdk.path}/include/esp_hw_support/port/esp32c3/private_include" "-I{compiler.sdk.path}/include/heap/include" "-I{compiler.sdk.path}/include/log/include" "-I{compiler.sdk.path}/include/lwip/include/apps" "-I{compiler.sdk.path}/include/lwip/include/apps/sntp" "-I{compiler.sdk.path}/include/lwip/lwip/src/include" "-I{compiler.sdk.path}/include/lwip/port/esp32/include" "-I{compiler.sdk.path}/include/lwip/port/esp32/include/arch" "-I{compiler.sdk.path}/include/soc/include" "-I{compiler.sdk.path}/include/soc/esp32c3" "-I{compiler.sdk.path}/include/soc/esp32c3/include" "-I{compiler.sdk.path}/include/hal/esp32c3/include" "-I{compiler.sdk.path}/include/hal/include" "-I{compiler.sdk.path}/include/hal/platform_port/include" "-I{compiler.sdk.path}/include/esp_rom/include" "-I{compiler.sdk.path}/include/esp_rom/include/esp32c3" "-I{compiler.sdk.path}/include/esp_rom/esp32c3" "-I{compiler.sdk.path}/include/esp_common/include" "-I{compiler.sdk.path}/include/esp_system/include" "-I{compiler.sdk.path}/include/esp_system/port/soc" "-I{compiler.sdk.path}/include/esp_system/port/include/riscv" "-I{compiler.sdk.path}/include/esp_system/port/public_compat" "-I{compiler.sdk.path}/include/riscv/include" "-I{compiler.sdk.path}/include/driver/include" "-I{compiler.sdk.path}/include/driver/esp32c3/include" "-I{compiler.sdk.path}/include/esp_pm/include" "-I{compiler.sdk.path}/include/esp_ringbuf/include" "-I{compiler.sdk.path}/include/efuse/include" "-I{compiler.sdk.path}/include/efuse/esp32c3/include" "-I{compiler.sdk.path}/include/vfs/include" "-I{compiler.sdk.path}/include/esp_wifi/include" "-I{compiler.sdk.path}/include/esp_event/include" "-I{compiler.sdk.path}/include/esp_netif/include" "-I{compiler.sdk.path}/include/esp_eth/include" "-I{compiler.sdk.path}/include/tcpip_adapter/include" "-I{compiler.sdk.path}/include/esp_phy/include" "-I{compiler.sdk.path}/include/esp_phy/esp32c3/include" "-I{compiler.sdk.path}/include/esp_ipc/include" "-I{compiler.sdk.path}/include/app_trace/include" "-I{compiler.sdk.path}/include/esp_timer/include" "-I{compiler.sdk.path}/include/mbedtls/port/include" "-I{compiler.sdk.path}/include/mbedtls/mbedtls/include" "-I{compiler.sdk.path}/include/mbedtls/esp_crt_bundle/include" "-I{compiler.sdk.path}/include/app_update/include" "-I{compiler.sdk.path}/include/spi_flash/include" "-I{compiler.sdk.path}/include/bootloader_support/include" "-I{compiler.sdk.path}/include/nvs_flash/include" "-I{compiler.sdk.path}/include/pthread/include" "-I{compiler.sdk.path}/include/esp_gdbstub/include" "-I{compiler.sdk.path}/include/esp_gdbstub/riscv" "-I{compiler.sdk.path}/include/esp_gdbstub/esp32c3" "-I{compiler.sdk.path}/include/espcoredump/include" "-I{compiler.sdk.path}/include/espcoredump/include/port/riscv" "-I{compiler.sdk.path}/include/wpa_supplicant/include" "-I{compiler.sdk.path}/include/wpa_supplicant/port/include" "-I{compiler.sdk.path}/include/wpa_supplicant/esp_supplicant/include" "-I{compiler.sdk.path}/include/ieee802154/include" "-I{compiler.sdk.path}/include/console" "-I{compiler.sdk.path}/include/asio/asio/asio/include" "-I{compiler.sdk.path}/include/asio/port/include" "-I{compiler.sdk.path}/include/bt/common/osi/include" "-I{compiler.sdk.path}/include/bt/include/esp32c3/include" "-I{compiler.sdk.path}/include/bt/common/api/include/api" "-I{compiler.sdk.path}/include/bt/common/btc/profile/esp/blufi/include" "-I{compiler.sdk.path}/include/bt/common/btc/profile/esp/include" "-I{compiler.sdk.path}/include/bt/host/bluedroid/api/include/api" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/mesh_common/include" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/mesh_core" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/mesh_core/include" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/mesh_core/storage" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/btc/include" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/mesh_models/common/include" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/mesh_models/client/include" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/mesh_models/server/include" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/api/core/include" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/api/models/include" "-I{compiler.sdk.path}/include/bt/esp_ble_mesh/api" "-I{compiler.sdk.path}/include/cbor/port/include" "-I{compiler.sdk.path}/include/unity/include" "-I{compiler.sdk.path}/include/unity/unity/src" "-I{compiler.sdk.path}/include/cmock/CMock/src" "-I{compiler.sdk.path}/include/coap/port/include" "-I{compiler.sdk.path}/include/coap/libcoap/include" "-I{compiler.sdk.path}/include/nghttp/port/include" "-I{compiler.sdk.path}/include/nghttp/nghttp2/lib/includes" "-I{compiler.sdk.path}/include/esp-tls" "-I{compiler.sdk.path}/include/esp-tls/esp-tls-crypto" "-I{compiler.sdk.path}/include/esp_adc_cal/include" "-I{compiler.sdk.path}/include/esp_hid/include" "-I{compiler.sdk.path}/include/tcp_transport/include" "-I{compiler.sdk.path}/include/esp_http_client/include" "-I{compiler.sdk.path}/include/esp_http_server/include" "-I{compiler.sdk.path}/include/esp_https_ota/include" "-I{compiler.sdk.path}/include/esp_https_server/include" "-I{compiler.sdk.path}/include/esp_lcd/include" "-I{compiler.sdk.path}/include/esp_lcd/interface" "-I{compiler.sdk.path}/include/protobuf-c/protobuf-c" "-I{compiler.sdk.path}/include/protocomm/include/common" "-I{compiler.sdk.path}/include/protocomm/include/security" "-I{compiler.sdk.path}/include/protocomm/include/transports" "-I{compiler.sdk.path}/include/mdns/include" "-I{compiler.sdk.path}/include/esp_local_ctrl/include" "-I{compiler.sdk.path}/include/sdmmc/include" "-I{compiler.sdk.path}/include/esp_serial_slave_link/include" "-I{compiler.sdk.path}/include/esp_websocket_client/include" "-I{compiler.sdk.path}/include/expat/expat/expat/lib" "-I{compiler.sdk.path}/include/expat/port/include" "-I{compiler.sdk.path}/include/wear_levelling/include" "-I{compiler.sdk.path}/include/fatfs/diskio" "-I{compiler.sdk.path}/include/fatfs/vfs" "-I{compiler.sdk.path}/include/fatfs/src" "-I{compiler.sdk.path}/include/freemodbus/common/include" "-I{compiler.sdk.path}/include/idf_test/include" "-I{compiler.sdk.path}/include/idf_test/include/esp32c3" "-I{compiler.sdk.path}/include/jsmn/include" "-I{compiler.sdk.path}/include/json/cJSON" "-I{compiler.sdk.path}/include/libsodium/libsodium/src/libsodium/include" "-I{compiler.sdk.path}/include/libsodium/port_include" "-I{compiler.sdk.path}/include/mqtt/esp-mqtt/include" "-I{compiler.sdk.path}/include/openssl/include" "-I{compiler.sdk.path}/include/spiffs/include" "-I{compiler.sdk.path}/include/wifi_provisioning/include" "-I{compiler.sdk.path}/include/button/button/include" "-I{compiler.sdk.path}/include/rmaker_common/include" "-I{compiler.sdk.path}/include/json_parser/upstream/include" "-I{compiler.sdk.path}/include/json_parser/upstream" "-I{compiler.sdk.path}/include/json_generator/upstream" "-I{compiler.sdk.path}/include/esp_schedule/include" "-I{compiler.sdk.path}/include/esp_rainmaker/include" "-I{compiler.sdk.path}/include/qrcode/include" "-I{compiler.sdk.path}/include/ws2812_led" "-I{compiler.sdk.path}/include/esp-dsp/modules/dotprod/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/support/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/hann/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/blackman/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/blackman_harris/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/blackman_nuttall/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/nuttall/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/windows/flat_top/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/iir/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/fir/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/add/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/sub/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/mul/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/addc/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/mulc/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/math/sqrt/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/matrix/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/fft/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/dct/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/conv/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/common/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/kalman/ekf/include" "-I{compiler.sdk.path}/include/esp-dsp/modules/kalman/ekf_imu13states/include" "-I{compiler.sdk.path}/include/esp_littlefs/src" "-I{compiler.sdk.path}/include/esp_littlefs/include" "-I{compiler.sdk.path}/include/esp-dl/include" "-I{compiler.sdk.path}/include/esp-dl/include/tool" "-I{compiler.sdk.path}/include/esp-dl/include/typedef" "-I{compiler.sdk.path}/include/esp-dl/include/image" "-I{compiler.sdk.path}/include/esp-dl/include/math" "-I{compiler.sdk.path}/include/esp-dl/include/nn" "-I{compiler.sdk.path}/include/esp-dl/include/layer" "-I{compiler.sdk.path}/include/esp-dl/include/detect" "-I{compiler.sdk.path}/include/esp-dl/include/model_zoo" "-I{compiler.sdk.path}/include/esp32-camera/driver/include" "-I{compiler.sdk.path}/include/esp32-camera/conversions/include" "-I{compiler.sdk.path}/include/fb_gfx/include" +compiler.c.elf.libs.esp32c3=-lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lriscv -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lasio -lbt -lcbor -lunity -lcmock -lcoap -lnghttp -lesp-tls -lesp_adc_cal -lesp_hid -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lesp_https_server -lesp_lcd -lprotobuf-c -lprotocomm -lmdns -lesp_local_ctrl -lsdmmc -lesp_serial_slave_link -lesp_websocket_client -lexpat -lwear_levelling -lfatfs -lfreemodbus -ljsmn -ljson -llibsodium -lmqtt -lopenssl -lspiffs -lwifi_provisioning -lbutton -lrmaker_common -ljson_parser -ljson_generator -lesp_schedule -lesp_rainmaker -lqrcode -lws2812_led -lesp-dsp -lesp32-camera -lesp_littlefs -lfb_gfx -lasio -lcbor -lcmock -lunity -lcoap -lesp_lcd -lesp_websocket_client -lexpat -lfreemodbus -ljsmn -llibsodium -lesp_adc_cal -lesp_hid -lfatfs -lwear_levelling -lopenssl -lspiffs -lesp_rainmaker -lesp_local_ctrl -lesp_https_server -lwifi_provisioning -lprotocomm -lbt -lbtdm_app -lprotobuf-c -lmdns -ljson -lrmaker_common -lmqtt -ljson_parser -ljson_generator -lesp_schedule -lqrcode -lcat_face_detect -lhuman_face_detect -lcolor_detect -lmfn -ldl -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lriscv -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lmbedtls_2 -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lriscv -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lmbedtls_2 -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lriscv -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lmbedtls_2 -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lriscv -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lmbedtls_2 -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lriscv -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lmbedtls_2 -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lesp_ringbuf -lefuse -lesp_ipc -ldriver -lesp_pm -lmbedtls -lapp_update -lbootloader_support -lspi_flash -lnvs_flash -lpthread -lesp_gdbstub -lespcoredump -lesp_phy -lesp_system -lesp_rom -lhal -lvfs -lesp_eth -ltcpip_adapter -lesp_netif -lesp_event -lwpa_supplicant -lesp_wifi -lconsole -llwip -llog -lheap -lsoc -lesp_hw_support -lriscv -lesp_common -lesp_timer -lfreertos -lnewlib -lcxx -lapp_trace -lnghttp -lesp-tls -ltcp_transport -lesp_http_client -lesp_http_server -lesp_https_ota -lsdmmc -lesp_serial_slave_link -lmbedtls_2 -lmbedcrypto -lmbedx509 -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lphy -lbtbb -lesp_phy -lphy -lbtbb -lesp_phy -lphy -lbtbb -lm -lnewlib -lstdc++ -lpthread -lgcc -lcxx -lapp_trace -lgcov -lapp_trace -lgcov -lc compiler.c.flags.esp32c3=-march=rv32imc -ffunction-sections -fdata-sections -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-sign-compare -ggdb -Wno-error=format= -nostartfiles -Wno-format -Os -freorder-blocks -Wwrite-strings -fstack-protector -fstrict-volatile-bitfields -Wno-error=unused-but-set-variable -fno-jump-tables -fno-tree-switch-conversion -std=gnu99 -Wno-old-style-declaration -MMD -c compiler.cpp.flags.esp32c3=-march=rv32imc -ffunction-sections -fdata-sections -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-sign-compare -ggdb -Wno-error=format= -nostartfiles -Wno-format -Os -freorder-blocks -Wwrite-strings -fstack-protector -fstrict-volatile-bitfields -Wno-error=unused-but-set-variable -fno-jump-tables -fno-tree-switch-conversion -std=gnu++11 -fexceptions -fno-rtti -MMD -c compiler.S.flags.esp32c3=-ffunction-sections -fdata-sections -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-sign-compare -ggdb -Wno-error=format= -nostartfiles -Wno-format -Os -freorder-blocks -Wwrite-strings -fstack-protector -fstrict-volatile-bitfields -Wno-error=unused-but-set-variable -fno-jump-tables -fno-tree-switch-conversion -x assembler-with-cpp -MMD -c diff --git a/tools/esptool.py b/tools/esptool.py index beb06a3098d..629f4c1dcba 100755 --- a/tools/esptool.py +++ b/tools/esptool.py @@ -57,7 +57,7 @@ raise -__version__ = "3.3-dev" +__version__ = "3.3.2-dev" MAX_UINT32 = 0xffffffff MAX_UINT24 = 0xffffff @@ -861,6 +861,14 @@ def parse_flash_size_arg(cls, arg): raise FatalError("Flash size '%s' is not supported by this chip type. Supported sizes: %s" % (arg, ", ".join(cls.FLASH_SIZES.keys()))) + @classmethod + def parse_flash_freq_arg(cls, arg): + try: + return cls.FLASH_FREQUENCY[arg] + except KeyError: + raise FatalError("Flash frequency '%s' is not supported by this chip type. Supported frequencies: %s" + % (arg, ", ".join(cls.FLASH_FREQUENCY.keys()))) + def run_stub(self, stub=None): if stub is None: stub = self.STUB_CODE @@ -1312,6 +1320,13 @@ class ESP8266ROM(ESPLoader): '16MB': 0x90, } + FLASH_FREQUENCY = { + '80m': 0xf, + '40m': 0x0, + '26m': 0x1, + '20m': 0x2, + } + BOOTLOADER_FLASH_OFFSET = 0 MEMORY_MAP = [[0x3FF00000, 0x3FF00010, "DPORT"], @@ -1492,6 +1507,13 @@ class ESP32ROM(ESPLoader): '128MB': 0x70 } + FLASH_FREQUENCY = { + '80m': 0xf, + '40m': 0x0, + '26m': 0x1, + '20m': 0x2, + } + BOOTLOADER_FLASH_OFFSET = 0x1000 OVERRIDE_VDDSDIO_CHOICES = ["1.8V", "1.9V", "OFF"] @@ -1604,6 +1626,7 @@ def get_chip_description(self): 4: "ESP32-U4WDH", 5: "ESP32-PICO-V3" if rev3 else "ESP32-PICO-D4", 6: "ESP32-PICO-V3-02", + 7: "ESP32-D0WDR2-V3", }.get(pkg_version, "unknown ESP32") # ESP32-D0WD-V3, ESP32-D0WDQ6-V3 @@ -1956,6 +1979,8 @@ class ESP32S3ROM(ESP32ROM): CHIP_DETECT_MAGIC_VALUE = [0x9] + BOOTLOADER_FLASH_OFFSET = 0x0 + FPGA_SLOW_BOOT = False IROM_MAP_START = 0x42000000 @@ -2309,6 +2334,13 @@ class ESP32H2BETA1ROM(ESP32ROM): MEMORY_MAP = [] + FLASH_FREQUENCY = { + '48m': 0xf, + '24m': 0x0, + '16m': 0x1, + '12m': 0x2, + } + def get_pkg_version(self): num_word = 3 block1_addr = self.EFUSE_BASE + 0x044 @@ -2385,11 +2417,19 @@ class ESP32C2ROM(ESP32C3ROM): DROM_MAP_START = 0x3c000000 DROM_MAP_END = 0x3c400000 - CHIP_DETECT_MAGIC_VALUE = [0x6f51306f] + # Magic value for ESP32C2 ECO0 and ECO1 respectively + CHIP_DETECT_MAGIC_VALUE = [0x6F51306F, 0x7c41a06f] EFUSE_BASE = 0x60008800 MAC_EFUSE_REG = EFUSE_BASE + 0x040 + FLASH_FREQUENCY = { + '60m': 0xf, + '30m': 0x0, + '20m': 0x1, + '15m': 0x2, + } + def get_pkg_version(self): num_word = 3 block1_addr = self.EFUSE_BASE + 0x044 @@ -2405,6 +2445,16 @@ def get_chip_description(self): return "%s (revision %d)" % (chip_name, chip_revision) + def get_chip_revision(self): + si = self.get_security_info() + return si["api_version"] + + def _post_connect(self): + # ESP32C2 ECO0 is no longer supported by the flasher stub + if self.get_chip_revision() == 0: + self.stub_is_disabled = True + self.IS_STUB = False + class ESP32C6BETAROM(ESP32C3ROM): CHIP_NAME = "ESP32-C6(beta)" @@ -2606,7 +2656,7 @@ def LoadFirmwareImage(chip, filename): Returns a BaseFirmwareImage subclass, either ESP8266ROMFirmwareImage (v1) or ESP8266V2FirmwareImage (v2). """ - chip = chip.lower().replace("-", "") + chip = re.sub(r"[-()]", "", chip.lower()) with open(filename, 'rb') as f: if chip == 'esp32': return ESP32FirmwareImage(f) @@ -3818,7 +3868,7 @@ def _update_image_flash_params(esp, address, args, image): flash_freq = flash_size_freq & 0x0F if args.flash_freq != 'keep': - flash_freq = {'40m': 0, '26m': 1, '20m': 2, '80m': 0xf}[args.flash_freq] + flash_freq = esp.parse_flash_freq_arg(args.flash_freq) flash_size = flash_size_freq & 0xF0 if args.flash_size != 'keep': @@ -4042,6 +4092,8 @@ def write_flash(esp, args): def image_info(args): + if args.chip == "auto": + print("WARNING: --chip not specified, defaulting to ESP8266.") image = LoadFirmwareImage(args.chip, args.filename) print('Image version: %d' % image.version) print('Entry point: %08x' % image.entrypoint if image.entrypoint != 0 else 'Entry point not set') @@ -4144,8 +4196,8 @@ def elf2image(args): # ELFSection is a subclass of ImageSegment, so can use interchangeably image.segments = e.segments if args.use_segments else e.sections - image.flash_size_freq = image.ROM_LOADER.FLASH_SIZES[args.flash_size] - image.flash_size_freq += {'40m': 0, '26m': 1, '20m': 2, '80m': 0xf}[args.flash_freq] + image.flash_size_freq = image.ROM_LOADER.parse_flash_size_arg(args.flash_size) + image.flash_size_freq += image.ROM_LOADER.parse_flash_freq_arg(args.flash_freq) if args.elf_sha256_offset: image.elf_sha256 = e.sha256() @@ -4446,7 +4498,7 @@ def add_spi_flash_subparsers(parent, allow_keep, auto_detect): extra_fs_message = "" parent.add_argument('--flash_freq', '-ff', help='SPI Flash frequency', - choices=extra_keep_args + ['40m', '26m', '20m', '80m'], + choices=extra_keep_args + ['80m', '60m', '48m', '40m', '30m', '26m', '24m', '20m', '16m', '15m', '12m'], default=os.environ.get('ESPTOOL_FF', 'keep' if allow_keep else '40m')) parent.add_argument('--flash_mode', '-fm', help='SPI Flash mode', choices=extra_keep_args + ['qio', 'qout', 'dio', 'dout'], @@ -5075,92 +5127,92 @@ def __call__(self, parser, namespace, values, option_string=None): +rqe/Hebvj3Y4S8jQkWaGpP//j8geRE3\ """))) ESP32S3BETA2ROM.STUB_CODE = eval(zlib.decompress(base64.b64decode(b""" -eNqVW3t33Lax/yqrlWU9bLcEd5cEnDaWkliWk+ZWThzFcXVODYKknRxfHVne3JVcu5+9nBcwfMg3/UMSCeIxM5jHbwbQv3bXzfV69+Gs2j2/Nsvza5udX2eLV92vTL34cO/8OlSPutfUpzjiXub8uq26n7Z7D0+7\ -jtmMvjjX/bVdQ0EDoS2OsDQidvaWOuPHkj56aM/WXSN/bDL6m2VbXY9iMAX2ys87Vhro201k6q5LllbO4nj46TgzQb2kXvAlvRCnW4lNXhGX6761vte8B9zOukfX8ey6BZq8awEZrPQaR4kD4LlZTQlkmXiPwmg0\ -E9W8Raavm05mFuZbwjxArOlN6KhbXyLP8dOr55rPjmYYWY+Fu6a9t9mdsxP6ij39H+k53on7syj22WgDgEMhByUThKuoaaxbcVVm0Cl1RF1yA/Jc/oYeUgtK+OxmUp0+dq05sDLPYE9hRya1KjskehshtuvXbYfz\ -aotrJbUwJMsNGOpTNVzT8V+ySkvyDv6RCF5Z21K/Hx7K0wmsxWPcMs4mUq+ikc5Y73y3DwZUufviOtYaTyqNUi4Ua8XAeh1zY7XQq3xfaduCh7PYez0dqK1NbMMPaLnpdjk45oLb4qCQv+ARHZWu0naVPx3uv1oA\ -98knamQxkSo+l7Bdx9x5mTgXG/aGXBC2e2I+UYbmUamhOF+nDwbmBB3Oso80AXwxHnzZMQzSCqcV/0LL1Z2v4zT99ov+qDURXStCUeUDfFHCYUH2NfA+i2x1uI5P5JrMCl8KEg/2Dt+RwQIrOlwkT9ZNl5XkJc2t\ -o+xw1OXzr5MnwK7d+BqIXtE8YHEgCeuO4Bcortty9A0dhoGF2Z3YGuLBfV7Zw9DiV//rM97ndrh6r2Nfc1Knl4uX89NvSEGbgoJsVTLVI3/8OaE1izEBGL4K/gm9CDYSje+Lhjh2PSF1Xbx7BkJCcW2RkKB3PRRW\ -CEyi5a990ohlYD6xHerb2O5EwqEyWx72cEUznHgOWmyEJzcHS6doRczOiGa7eEAjBvLVc5d/cO7wx+ZWP2h7p+TWQvOIbMy1yN7JCf4h6+e25yc9ztGNsCb58FsMYkeJaBvAgzJIWNzGECvnEhVk3W/BEauJEXrG\ -5fD7seq4SsE1RTegKZuR87cL/sFpZxwQc+Vom/H6gGEy0weLY7NKwm8zwaZVfIJ+rlEy3UoBF+cTaESAMWLPSsGZaT+VbMr2ANUpx+vBJuYJCHivVI/bbb7HjYEUL0GdJgVFGG28rP7tbc5QSJkNSGlYTjjTt7S5\ -TgUoK4HY5ywRA25AwkNTRsDVWYeFaObmHEEtjwhGbIY329HGoxIAAgBvAbEFlvDtIUhjHq2JLN/ZncTVGC0zTPT57HbVAekJxjLFgVJTOwWiojPIidIg1pFzSAZNbZjo7ltd8Qax0sf2cNzPb6LqqoFxQkuphTGz\ -Pm1xtnrn8wQ/lGwiTyvBYHk31XxHtIgXbZe38e4V78jbarywt2JXfklPz6PnOoxPBDRhLtA8zyAGtKMn08UDQ0PQ/gbbLL4HdQk8XE3aeJt3i3kT75L4jXG6OPBrE6G0YSura6TrQm8lcLi4y7a/4EiGOn8v9593\ -Z84mFsjiEDyeX4nXadm4scMwo/X51/3sYBhy7FT4MbyspAdtm36ww1ISLsfAoMNrb+IT6UZ0hfNtznoKhP9rEnnVJOdUeXaJljEHWIhEeth18AdgSTbf5iSNN8kw+vZMts32wSPMZpxuBHZcuCKbXWW32TMhS6B4\ -FSO6EnrdZ38Cel/dg7DAoRIV62/iRw/5C6c6PaRV3YK08mPiI0oap9Mj7XTAMN1IpVEIu8UGAmVV2Nao/MEM01EE8FaGNv9F7oiIHukQDOMEw3R7NqO9CLjG1/CyfbC3v52UrZEahhh2pyA1kvdiebpg2O1AvNUL\ -gHovfzw9Pz/iUI4s7wiWeNPhQl/QiGz55s5rdoJ516NaDNPma5itewpo+9nPoCDdr6r4X97SjB2v2oIsjLKE0zVrGbqH01+B19e0HkqtJquu2E+hv+JkBE0fLCUUkP1X+eyy61DOfugkwK7SIUR++NMOxcG2PX1x\ -pKC3cnGg9cGBuMVrOIbXqN+sEOi8ILetGQnBsyTFGE1hd435DQh5RYLoxILuDggF/wRKKhY6zqOWpD4j1KU88W0yQfVbTqDGWKkLD+ccUpb7z/dgAx/O9+HP3hImClnOU/dd2SWpWOsfMdJWBSEsWXSaVZMOXscn\ -0kZw/kiSqvYYNOsZULVgxNCOQOT3aJNsf6DklaTAhhUmTxsn7orSRlJbb1XVI0+2K8+DkhjCIeBtkIVXArrqFKKm0k2f3SG8NIwCuM3tVJJjRUmVk3U5pBvIVziSeliui3nYYvZtzMz8/GCR/UXUOt9/4U4aQSkP\ -0C2hfsnOr6Zzo1RSfaFfYND/AeeH5A0h0UVAEbj5cIN/iq0t2hLwPSa7bVdZmaObfqarUxdooF+HhwxeORkioBHxZUnRJiuVVwqDvCRiefMZa2jDwXCRMQtj2PDt/BCt+GybgJxXOLxSo8GivYQeN0GHKjJhAKtk\ -zA6JGnaPENeIO9zLMLWRb/XmvdEvl/rlWr+s+xsOuQ4GLUhStnzKtIxvf1HljFUlzJ6Cxc1+wC7g3FCv30kcesJFFYTGj1SiywWVOpsGj2So75K5oY+0H8gY0vnFAwwc7zlHMJCIt5frnhaVCq6W6ErWok/g3X2p\ -MhuN3AUcG/CYn1ElF16q5DPHOPmJ3pyuJRoaL8wAD5C0+ZjUddZxJes3FC86ZkCAMybHNBLKiPYg7oz5ZOcKB0MFO9dqhM4/zD/8VNJGBS4SU8S8ukuUGXa2BNYvf2cEUpbkTcCImzDwXggXj98yWsqSr3eSeUoy\ -i/Ic+dCzbpSn6Aegzxcp98qKt0RTVTXJ8wNah+qDASkVT5LRBqsVRrj4QME5lphNtTkWF/GRbNSVhG5CBlqbWRJHKQq8IZFB9cKzCrYtRHmQNCyO9s5EuBFQbSiISSByq+Q0fKadRkNhBzsqcE04YYdR2cS5Q/CP\ -/n5y9BRQBOWC3wApJeSBGLXDK9o+T9b9HNJC+BrRsIUOUJDBrijODDqYdOD4XNpSSfOVPWRI0EtkBlnPqG2J8+6qojWVVwdnTZZLMLYXrA7HE6bFJz7iSYrUAfDFLNWBYpv1iRcBJtngmEof7LT2exSjpQLhXkyw\ -oTAYU++3D7kN81iDL5eUTULB0fBXsJeK2u5zOkRPToYvz8/5EY85KlWp5GmvYyZArPLLG1I1bAbA0FIBCqaDAB2X5/b7zzncN+EfFAR4AdCLkE74LuYwOHyVrF9nyb3D4FAwAgylitc4Cmwx/25eghezDfEbgTEW\ -vQxiyDJ5PAJ2R+xK6y15MJKSHtyJKA6n36IEqMU6OSQztonYyFA1odh6zGkbGGbNVQuuQMZshkOBa4cYXTnZSj0byeC5Sp1KBy6ByTAFJs1DWOIHlXybL8eJAa7FmivE4pT+ltIxfi/GE/UGj6IFOONqdIq+OJ0n\ -tLyfkIqxKrG0LqWNeCSZm+S+pL4FSVal2lWFJaiMh+mr3BR9RtTmcZ9I+DQHhqepXSdBupBORoOfJfLkGNW3EwtTLvwD569mtDiV3CcWhxmNn0j2DIWRkRG5fLQFOQFFCCqgamEBwNBkcjYihyWQZHku92eMNHGZ\ -iUobWKnlza5Vxh5Ue6Wem5i6xyq0oQg5YsDiVM/+DTwffAPgcXXvmKsNw+Ks+UevipLLNARWi/fk4Lzchahjz/mJApD8qW9ZnxIWc2YaeY7b330QlGB7N0ygfma4kmMxcc56lzo4K7fV9EJ2tNG6jG4nsgZ9jYVl\ -l7MfD7Seom6ZMmhuvYHW+dGdOVsA7vDeDVrJEdhr/ozwlAnlBkaCQoUnG5rECN4zrUywuOIHuoYBxnw5n7VfgST2tvvaus+qotIZE+ZzXLFJQsLDz0q8/50mCQIcMa1K2J4W3nop8gd8yNVGEHA1g7KQXAqAwcb0\ -q+rgceyy742aZkc1rgg94vyFFAGvtPSw4LFL2BGLkFgayjb5L+1ryXr4VBfvX2y2W+npWfUBvF60CIW4u5UjpeJer9b9hCVdcBKctT/zXI24yuKuroHifkXqKPKiN+0IhD1qN6kdz5ozvvPQTbotNMwG9fbEapvW\ -qfpSqFZ8JAkVMtrqrzQhttgnKv7McXJEpm0SmeyI8v4MLdNTxVH/SkUGk1RMjwLpCmAxQdPcigA1tuWqST1Y2UfSltIj668y16NNn7c7clq71J0WihZIHo18WPZnvlZnnSX3kewVChHqFtfTQTfQeZgIYzRqDahx\ -Bhl0ecPWGTbkg5q13C+iNPk9vO5cp98KGNlorRBdNtD9d+hyxkdD9fHjgUAzcwZJzorNFkvfchIdcoo3ks6ZqZPo+vzi7IMUbkpZnwflmBXuvE9o0w+zElS5s71F7M1rFRNrAYKEDqE4g5a7nFFq91oIqL3e3sOi\ -ZjlL95Kq5Rlf5WkIwiIcbc8+UAuWxCqFoaFnDbXscLShVNBQBeNi6lijHEc5nHHB4oZ6bJt1PqvG8sCxfOJ8a6KugTd1GJuIY9BpXVBcY2oBxSW6jHX2C1XFtBXFi0zIE3Rbbch/wc4SW0GdGHh96GTIoQ45HF5b\ -dVJaabAiyouW0rDhEep+w1SlPZ5uMOO1upeAYmzOdwEArA7AJNNJJOJmN9614tZdwxJFPby9gfsytVPZMMWaILxhwsEPcFLBfqPOjjcTTiNETeaQ4ha61wPGEwUJE/UeyxJQNSp+7Rkzf5KJbC33CLcFB/PhImi/\ -bVNATRd+p+bCUGjTDlecmdFZ5fJKXLkwlKv6sAxnJansj+BetvsxHbdE3fjy5MUXnejL9nOUheKjOAc+gnWcxbTN/0dWIBcOvkeomu3BTI2cCbzj8lGtr7S8RsW4t484gS3QA7Kyi+PLJCNXqIHkGNeamGJDOk57\ -9RYp+QUqRNvk0FEz+fDV8Q1OfQvDwZKgKVL4a2QrY+X0A18tkisVFott5Asd+IkuYO9COBcgtVJ4Du9zbgTGbWbqU5FuEHQw81p/Ktnb4mnNJR/l2CkWTBJNZMUWL8S+ID2oo6zSvZAs+3SOucdTukXp+DqmMie7\ -oVs2tMfPpCSKGcnei+O/p8Nq6xIRspUpLsNoPgpv7XuIBwAyQVMCHOJXeHsHtguThHroDT7xydnF5QHtQygeTwW/uyey2FdSBdjuJ4h2wkVmxVa/NuclDiq/suG6R378F1XEWx4RsHeLjsSPdK4QinQ65vHKkURj\ -hw9YfvGsDebDmB6HwTmPUXpvn8oZsBEh3p7i2zRYHMd+YMsZ3yGK9YY6v4852D3Ec5hLA/7xs2HpJrBCg3KA3zdSHK/4zqfDqNqeKN+aq7vxSVLHd3pboh0MynnrBXs8++P1tlxs2/oZGm+Yg6CyDPa7wfzIsYCV\ -rLYRpEcDF8WzjKBqthJQmQr9oF3M5Gy15z0s+AvzPSwh7Q5hC5yXll/+DzkPLO0stU44//hBPNZt40Xog/fXr7+b32DxAGhpZ/+GAQd04lFBbRAQCF7Us3QJiHbhBi9DF2uFTpAnPqg3/h0Wzfb4ZKSHyYOVggXO\ -Vb5zXPRzyizx1IVuRgndWSlX7pvVF3w60702X0jC+IiBL+AF36hUUTyQZFim/HIDVK4kq8sofZG0EXMgNLS7KivCI89mkJWNcpzfOT+5mEqusuJLBhy+VntIOY4pn/XyDlP+TgrsWUAdQMGgThF9Z4vZpfvJlEMY\ -vvZlzf50gQtoQmCmntO5u1y8jMdvCKH5xhE5/8GxP2X7l2Q9NudCAMbdKRI83zhqrEowJi5duFJYBulsU6AKEvATuCFU8VtKw9wiDUxFi7kulUitAi6uVDO2zIosE3MZKMLY5iSlMFg/az5feGF+7JCfdwzig9QG\ -UXoYNOd4R4jLeJZzDag/2FwOX46GAV42il11s3oo11U5U3L2Cd8lciQ1qkJkHOfAjBu8A8NKpf8bx1NXg5mgSGZBXGHGYqfw77dcJ6TbLe5nZORgAc657JIxLEXtczkuy6fi2qXs2VzWgxMOk11NFZ0GIOWK6+bi\ -gtxxr2ayxf8hUEt2V/E1sPyGi894czFzR/auzCCnjohXXIyHO/LfOBT3DN1gBcDn+PILBbiMVsp4YzGdqyW3vk+n65Iv1/puSxgnWw5zmApo83wT28oiXoxNjj+hg4OeIJ+QpYjm7VG6Peo9DSMXDMYMZ2YYehhB\ -kXalU3a1Tgi/kX/Fy7tUfInjESx5uVwUUYRflT3B5Zhww2lQxoPQ0YNat8q9wHJ1scfn07iJkBcWNzqUlPs/HSuzgP+zxP8BQMx6qNRKAk8IAOaKvw4/uf2fwNS+wKi1fUaowXLRwKhLTJ7TRytJUT12spSQDrV8\ -lTwT/UAaAuaH3jLskE7HgqjyknitYzBfk6mkuvjTcO7bbjY78ewxr+DzEvrvLYqRIeQJpCD2L1V6itBu8ZFOINKlorvcfXV3zke8hap36DvfGdyipPVg8TCXCVuOtLScBMOAEdSlW2nY/YG6SLi85YJ5Lf+lKLwV\ -vSnmiaa+sHbvz/A/gP/5fu2v4P+ATVaWi9JlZd59aS7WVzfSaM3SFV1j7dee/2FYnVvv8hc9UZaXrijsp/8AQ2z1qA==\ +eNqNW3t31Eay/yozY4wfmF21ZkbqJrnBDslgks1dQ4gxrM9ZWi0pJIf1MWayY3thP/tVvdSlh7n5w/aM1I+q6nr8qqr9n511db3eeTQpds6vzeL82ibn18n8bfMrUV98eHB+HYrHzdc4JjviUeb8ui6an7r5Hp41\ +A5MJvXGu+WubBxlNhGftDEsz2sHe0mB8mdNLD8+TdfOQX1YJ/U2SaTMi6y2Bo9LzhpUKxjYLmbIZksSdk3Y+/DScmaC+xFHwJn4hTqeRTd4Rt2ve1b7zeBe4nTQfXcOzazao0uYJyGCp9ziKHADP1XJMIIvIeyuM\ +SjNRzGpk+rpqZGZhvQWsA8SazoKOhnUl8hJfvX2p+WxohpnlULhrOnub3Ds9prc40v+ZkcOTOJi0Yp8MDgA4FHJQMkG4ajWNdavdlRl0Sh1Rl1yPPJe+ow/xCUr49GZUnT41T1NgZZbAmcKJjGpVckj0VkJsM645\ +DufVEZdKaqFPlusx1KWqv6fjv2SVluQd/GMRvLK2hf5+eCifjmEvnuMW7Woi9aI10gnrnW/Owcybt80b17BWeVJplHKmWMt61uuYG6uFXqR7StvmPJ3F3hnpQG1tZBt+QMtNc8rBMRf8rJ0U0jOe0VDpCm1X6bP+\ ++asN8Jx8pEY2E6ni5xyOa8WDF5FzsWFvyAXhc0/MR8rQPAo1Fddr9MHAmqDDSfKJFoA3xoMvW8EkrXBa8S+0XN35ul2m+/yiO2tNRJeKUFT5AG+UcFiQXQ08YJEtD9ftJ3JNZolfMhIPjg4/ksECKzpcRE/WLJfk\ +5CXNnbNsf9blyyfRE+DQZn4JRC9pHbA4kIR1R/ALFNdNHb1Dh2FgY3YntoR4cMA7e5ia/eZ/e87nXPd37wzsak4c9Gb+ZnbyHSlolVGQLXKmeuCPvyS0aj4kAMNXxj+hE8EGovFd0RDHriOkZoh3z0FIKK4pCQlG\ +l31hhcAkWn7bJY1YBuYj26G8i+1mlQBbg3tlNwpOJ53wwZcjnPcWKDjWtgvw1Ko/dQZmYEQobgaugrYgaU2IaTt/SDN6B6TXzv/k2uHPra1+0HhPyC+G6jEZqauRveNj/EPug5+9PO5wjn6IVdGH39soeBSJBoEX\ +KaOM+V0MsXYvUMPW3Sc4YzkyQ6+46L9fqYHLGJ1jeASa8PRBynP+wWUnHFFT5amr4f4AghLTRZtDu4zCrxMBt0X7Cca5Ssl0GiM2rifYihBnC14LhYfGHV00SttBZCcc8HuHmEYk4b1SPX5u091oP6B4EStVMarC\ +bONl9x/u8qZCyqRHSsVywpV+oMN1KsJZieQ+ZYkYNGaOL1XeIrbGOiyEQzfjEGx5RjBiM3zYjg4elQAgBLgbCE6wha8PQRqz1prI8p3djlwN4XbfqYypDkhPQJrJ9pWa2jEU1jqDlCgNYh0px/T0/IpJbt6UBR8P\ +q3z7PKxIpppWqybxUshPpYhpFyirL1P4SPKPNG4Ak+W7KWYtauW96sVdzPqW2e0I9fRQb8WK/II+vWz91GH7iXApLAR65hnzgC50JDh/aGgUWlvvUMXToOaAPytJ9+7yZa3lVsy/UUDffsGLjUTeim2qLJGuC318\ +wOH8Plv6nAMfaviD1H/ZeTkbWSD7QqyJeoRU1mzKOKCfAPv0STeZGITZsWBjeFvJJuo6/uCAheRnjnFEA+/etZ9IMVrHN9viJAkElIITAJ0tyuiKCs8O0DJEAYsQYACnjkCgAiPY4pyOD8kwWPdMtk32wP4nE85O\ +CsFo8JkNorBb7IfwJShewQAwB1R8wN4DlL54AEGAAyMq1t/Eax7yG86MOsCsuAOYpSvio5U0Lqdn2vHwYJqZSqMQpTNrAV/zs0qlG6afvSLeR3RWkMr/6VQTEwCkQxCLE8TSnNmEziLgHk/gy9b+7t5WVLZKSh5i\ +2I2ClEje2eJkzijdgXiLM0CGb34+OT8/4sCNLG8LcnjXwEif0Yxk8e7er+yO0206pG6WfQ2rNZ8C2n7yChSk+VVk/+IjTRjLqCNIhknFyZq1DN3DyW/Aa7NxMWeplWTVBfsp9Fecu6Dpg6WEDIoFRTq5bAbkkxeN\ +BBgqOUTUj37Z5qS1Pjk7UkhduTjQ+uBA3OI1HKNx1G8+fHRekAqXjHvgs+TQGDvhdI35HQh5S4JoxILuDggF/wRKKhY6TLsSUp8BxlKe+C6ZoPotRjBiW9gLj2YcTxZ7L3fhAB/N9uDP7gIWCknKS3dd2SWpWO0f\ +M65W9SOscDSaVZIOXrefSBsrsu26VsUhg2Y9AarmknQMIONPaJNsf6DkhWTMhhUmjQcn7oqyTFJbn6siSRptVz73KmgIfoC3XtJeCMQqY4gay059co/QUT8K4DHXYymNFSVVTtalkFwgX+FIymeprv3hE7Nn2zzM\ +z/bnydei1unemTtuIcpDdEuoX3Lyy/FMKFZgz/QXmPRv4PyQvCHkxQgoAj8+3OCfbDqlIwHfY5K7TpWVuXXTz3Ux6wIN9El4xFCVUx8CGi2axDgCCq+8UuhlIS1yN1+whjrs9zcZsjCEDT/MDtGKT7cIxXmFugs1\ +GyzaS+hxI3SomhQGsELmbJOo4fQIcQ24w7MMYwf5Xh/eO/3lUn+51l/W3QOHzMZJdWDqY15lfP1aVT+WhTB7AhY3ecFoCbEBqvYHCUVPuQyD0Pixymy5BFMm4/iRbPVDtDh0k/aW7CF2PB5i7PjISYGBzLu+XHcU\ +KVeINUdvshaVAgfvM5XKaOQu+NiA0/yCNrnwRmWbKYbKz/TN6eqjofnCDPAAWZpvs7jGQK5k/4pCRsMMCHDC5JiKcjgBX0GsgPlk/wqtpIz9azEA6Lez219yOqjAZWUKmlf3iTLD/pbw+uUfDELynBwK2HEVeg4M\ +EePqPQOmJLp7J6mmZK8oz4EbPW1meQqAgPvkUNDVZ++JpqKoovMHwA7lBqiU19nTaLfBaoURLm4pPrdFaVNsVuIlPpGZupwATkhAaxNL4shFgTckMihXeFbBuoZAD5KGzdHkmQg3wKoVxTGJRW4Z/YZPtN+oIqZG\ +e3KxEWPgpV+OdyqCf/z346NnAOkoHfwOSMkhFcTAHd5yqEvzwxLSQnjVomH7Foif8jiUZQIDTOxPvpRnsQL61h4yJOgkMr2sZ/BsgevuqBo3VWN7rSnLBRfbCVaHwwXj5iMvsfEibVH8Yhaq/1gnXeJFelE2OKfQ\ +faDa/oRO0lI5cLdNsKEM2Kbe7x/xM8xjDX65pGwSyouG34KxFPTsgNMh+uRk+uL8nD9iV6RQdUle9rrNBIhV/vKO9AwfA2CoqdwEy0GAbrfn5wcvOdxX4R8UBHgD0IsQG4IXM5gcvo2mr7PkTu84ZIwAQ67iNc4C\ +Q0x/nOXgwmxF/LbAGEtcBjFkHt2dt1xdLcH9lFP5YATj799rURwuD5V1OFssq6eQ6lYtNjJUTcimK07bwCpLrlpwvbHNZjgOwMl2MbrysIX6bCSD55p0LB24CCbDGJg0X8EWL1TybR4PEwPcizVXiMUl/R2FYnyf\ +DxfqTB6ECvDExaDpPj+ZRbS8F5GKsSp6WRfTRuxgpib6LiluQZJVqOeqwhJUxsP0FW6MPiNq832XSHgFQK0ap3YdBelCbKQGP4nkSdfV1yMbUy78gvNXM9icCuwjm1tOHgfJnqEYMjAilw6OICWgCBEFVC3MARia\ +RDoh0hqBJMtzcT9hpInbjFTawEotH3bJpRfcVT0v1OeqTd3bmrOh8DhgwOJSz/8LPO9/B+Bx+WDF1Yakj93/0amipLIMgdXsIzk4Lz2nsh05O+61o8q+ZX2OQMyZcdg5fP7hViCC7VxIgfqZ4UqOxcQ56dwB4azc\ +FuMb2cFB66K5Hcka9K0Xll3KfjzQfoq6Rcyg+ekNPJ0d3ZuxBeAJ794AF7OjbYAFzwlMmZBvYCYoVHi6oUWMgD1TywLzK/5AtzbAmC9nk/pbkMTuVldb91hVVDpjwmyGO1ZRSNgrLcT731NeBBwx7UrAnjaevhH5\ +AzjkaiMIuJhAWUjuEMBkY3RJncKJXXS9UQUpX/twSdAR18+kCHilpYcFjx0CjliExNJQsklf179KysNNYLyusdmqZaRn1QfkelEjFOLhVhpI2YNOrfspz8QMOKlf8ddK/GR2XxdA8bBa0ijsoittqIMDqjfxOfal\ +E74f0Sy6JQRMesX2yGcd9ym6IiiW3H0ED0fn/K0mxGZ7RMVfOUgOyLRVJJO9UNpdoWZ6inbWf2KFwUT96q/sanmlaa5FgBrYcsmk7O3sW9IWMiLpjpjq2ab77p40Zhd60FzRAmmjkRcLPTvJrlVbM5/Fbg0oDVQh\ +1I2vZ71hoPCwEAZo1Bpsg0HunN+waYaNOCC/XMt1pHSyjZ+3r+NvhYpsa6oQWjZgVX/AkFPuC5Wr73sCTcwppDdLtlmse0vTOaQUbCSRM2NN5/L84vRWqja57M+TUswHtz9GqOlrXe0/PZ63o3iPsfYVwEYzX70S\ +2u9zEqmcKgg9oNCvt3axlJlP4uWlYnHK930q8jQO4+3pLYe2jCJxp3MOo0uoYoejDWWAhgoXF2MNjXwY37C8NmdZQyW2ThpvVWJVQHU+MdMaKWfglR7OwG0W+7NtGiXhJOOkAspKdGvr9DXVw7QJtTeekCcYttyQ\ +8zKVsBVUr8DrdpMhV9rnsH+/1UlFpcJaKG+ay4MNz1D3GLDbUQ0Zd4rxUt0/QDFW5zsQ+pf7YI+xB4mI2Q1PLbvz1LAyUfZvaeC5jJ1U0k+uRgivfFSpQPbCTqNMVpsRjxFabU6JXTfXox4ykshImKj7WI2AYlH2\ +W8eS+ZUsZEu5cLglCJjbihhr6xhK483gsbUwCNp4wgXnZNSlXFxJ1ikMpaoyLNNZSQr7M/iWrW40xyNRV8M8ufB5I/q8/hJlIfskHoKbr47zl7r6/8gK5L9355GqyS6sVEk34ANXjUp9deVXVIwHe4gQ2AI9YCo7\ +X11GGblMTSSvuNbEZBvScTqr90jJaygMbZE3R83ktqvjq576toWDLUFTpN5X1e3dx1u+O8RIHWKMgVhgca0Ew/QOBHHBTksF4fDG50aQ22aiXmXx0kCDLK/1q5xdLTZoLrl7Y8doN1EmLQ8hOxPDgoykbIXE1z9Q\ +9z6fY7rxmu5ZOr6wqezIbugaDencCymBYhKyewZi/ruqWgXuUDEtcpQxKMP+3ASv7UeIBwAvQVMCtO8LvKUDx4XpQdn3Bp+5Z3ZxuU/HEbLve8kVbnn/WDb7VvL/rW5qaEdcZEKwJlblvMRC5Vc2XPFIV1+r8t3i\ +iCC9mzckfqKOQshiX8zj1SIJyQ4/YOHFs1KY2yE9DiN02obq3T0qZMB5hPaWFF+iwZo4jgNbxuPSTfoyPcDs6wGCOcyiAfn4Sb9oE1ivQUfA7xupiRd8OdRhVK2PlW9N1SX6KKnVvc6RaAeDcp6escezP19vyQW2\ +6St4eMMcBJVfsN8N5meaJkpW2hahtwYuimcZPpVsLKAyBfpBO59IV7XjPSz4C/MTbCHPHcIW6JTm3/wvOQ8s6iy0Tjj//cO2oRu9xv7H619/nN1g2QBoqSf/hQn71OgooCoICAQv5Fm6/kOncIO3prO1QifIE7fo\ +jf/wDdC4yw2RbKb9oJVSBa6Vf3Bc7nPKLLHZQneihO4kp7v5219zR4bv6X8lqeJjRr2AF3ylkkRxRJJemfybDVC5oHwOThBzF0kYMQEi0KkSF7gSgScrKVknuVn9wVnJxTClWn0TwaEv1eFRZmPyF51sw+T/ZtzM\ +kiGjv8KITuG8mjKvdIuZsgfwkaixZm+8rgV0ISpTn2O7XW5Xti03xNBL9uWWPEGn209J/iWZjk05/8egO0aC54tGlVWpxchdC5dHtkvkF5tsHO0jsiFI8XtMwNw8Toy1ipmukEiJAu6rFBM2y4LMErMYqL3Y6jgm\ +L1g2q75cb2F+bJ+fD4zgg5QEUXoYOGd4NYird5YTDSg72FR6LnJLKO3flmQ/XS0fyZ3UKXtu+5SvEDmSGtUfEg5yYMNVIZcTqu7/7HgaajAHFMnMiav27tAA/P7A5UG61OJeISP7c/DMeZONYQVqj6twSToW1C7l\ +zGayHzQ2THI1VmvqAZUrLpeL/3GrTrVkyv9HUEoDuODbX+kN15zxwmLijux9WUE6jYhZXBsMt+V/dijoyUWzkrvgRqJbQuqd8MFiLldKVn1AHXXJlEt9pSUMMy2HCUwBtHm+bm1lEy/GJi1PGOBgJMgnJDGceXsU\ +L416T9PI/4IxQ6sM4w6jKNKu2FlX+4TwOzlXvKdLZZd2PiIlL3eKWgjhl3lHcClm3HCjLeFJ6OVBrWvlXmC7MtvlnjQeIiSF2Y2OI/neLyv9TxXPeEHErYdKrSTqhPAEbPp/OuFz7xd49pUM3906Jchgq23ua3Oz\ +2HPiaCUdKocellLRvoovtRuXBARsD10lZIzGqCKocpF4j6O3XpWodDr7S3/tu64yO3HrbUbBPRL6By+KjiGk3fJKkqvEFEHd/BN1HeJFovs8fHl/xm3dTFU69N3uBG5O0n6weZjJgjXHWNpOomHAEOriTTQc/lBd\ +HlzccZG8lH9kFN6yzhKzSFNXWDsHE/wn4X9+XPsr+Fdhk+T5PHdJnjZvqov11Y08tGZp4GHp157/p1j1qnf4jV4oSXOXZfbz/wH6hAMl\ """))) ESP32S3ROM.STUB_CODE = eval(zlib.decompress(base64.b64decode(b""" -eNqVW3t31Eay/yrj8QPbwF21ZkbqJnuDnQTjJPuAhDiE63MurZYEyWF9jJmcsb2wn31Vr+7Sw2z2D8OM1I/qev6quuaf99bN9freo1l17/zaLM+vbXZ+nS1ed/9k6osP98+vQ/W4+5rGFMc8ypxft1X313bfw7fd\ -wGxGb5zr/rfdg4ImwrM4w9KMONhbGowvS3rp4Xm27h7yyyaj/7NsqxtRDJbAUfl5d5QGxnYLmbobkqWdszgf/rqTmaC+pFHwJn2hk26lY/KOuF33rvW9x/tw2ln30XVndt0GTd49AR6s9B7H6QRw5mY1xZBlOntk\ -RqMPUc1bPPR10/HMwnpLWAeINb0FHQ3rc+QFvnr9Qp+zoxlm1mPmrkn2Nts5O6W3ONL/kZFjSTyYRbbPRgKAEwo5yJkgp4qaxroVd+UDOqWOqEtuQJ7L39KH9AQ5fHYzqU4fu6c5HGWegUxBIpNalR0RvY0Q243r\ -xOG8EnGtuBaGZLnBgfpUDfd0/D9ZpSV+B/9YGK+sbam/Hx3Jp1PYi+e4ZVxNuF5FI52x3vlODgZUuXvjuqM1nlQauVyooxUD63V8GquZXuUHStsWPJ3Z3hvpQG1tOjb8gZabTsrB8Sn4WZwU8pc8o6PSVdqu8m+H\ -8lcboJx8okY2E67i5xLEdcKDl+nkYsPekAvC554OnyhD86jUVFyv0wcDa4IOZ9lHWgDeGA++7AQmaYXTin+h+erO13GZ/vOL/qw1EV0rQlHlA7xRzGFGDjWwseKGjogt8UuV3hTEJJwTviezhQPpoJH82YPun5J8\ -pblzlh3OunzxdfIHOLSbXwPpK1oH7A74Yd0x/APq67YcvUO3YWBjdiq2hqjwgHf2MLX41f/6nKXdDnfvDezrTxr0avFq/uwbUtOmoFBblUz1yCt/jmnNYkwABrGC/0Ivjo1Y4/usoRO7HpO6Id49ByYhu7aISTC6\ -HjIrBCbR8ts+aXRkOHw6dqjvOvb5OYtfXCkLvBkuOwdNNnIiNwdrp4hFR50RxXbxkGYMuKvXLv/g2uGPra3+2P4q8fMNuGa7xyZi2X/hF7eUx+Bt+HEv+rFC+fBbjGjHiXobwJ0yYljcdTLW0SXqybr/BGesJmbo\ -FZfD9ydq4CpF2hTqgKZsRpHALvgPl51xdMyV123G+wOgyUwfOY6tK0mhzQSoVvxpf09xcyvFXVxJEBLhxghBK4Vqph1VMio7wFUYl4uxBPMECbxXCsjPbb7PDwOpXwI9TQqPMNt4IeC7uxyiUHM6IKVhJuFK35Fk\ -nQpVVkKyz5kpBlyBBIqmjNCrsxELcc3NOZZanhGMWA5L2pHUUQMAC4DHgCgDW/j2CLgxjzZFYdDZ3XSqMW5mwOjz2d16A9wTtGWKQ6WjdgpORZeQE6VBTCPn4Axq2jDR3bu6YgGxxsfn4aSf6US9VRPjgpaSDGNm\ -fdriavXu5wl+JHlFnnaCyfLdVPNd0SLetF3edXavzo5nW4039lbMyy/p0xGZV3Rgdcb25hnFgFL0WLl4CPGXw2gYSFf8DaoQeLWalPAujxYTJxaO+IpxvjjwZRNRtGHjqmuk60JLEBRxscdWv+Aghqp+P/efd2HO\ -piOQoSF6PL8Sf9OyTeOAYUrr86/76cEw3tip2GN4W8kP2jb94YBlzLgChQLKCtbKWUQfON/mrKdA+L8mjldNckmVZ19oGW2AXUiMB6GDFwD7sfk2J2ksI8Po2zPVNjsAPzCbcboR2F3hjmxsld1mf4QngmBaMZYr\ -YdQD9iKg7dV9iAQcHVGv/iLe84jfcKrTw1jVHRgrP6FzREbjcnqmnY4UppupFApht5hAoKwKnzUqfzDDdBQBvJWpzX+RO5KQMbKwr3WCXzqZzUgWAff4Gr5sH+4fbCdd62DbhbLqTj1qJO7l8tmC4bYD5lYvYeyr\ -H5+dnx9z7MYD7wp4eNvhQV/QjGz5ducNO768G1EthknzNazWfQpo+NnPoB7dP1XxDxZoxs5WCSALo+zg2Zp1DH3Ds1/hpG9oP+RZTSZdsZNCZ8VJCNo9mEkoIPev8tllN6Cc/dBxgN2jQ2j86Kddin1t++zlsYLc\ -yr+BzgcHzBaX4RhWo3azOqDnAghYM/SBz5ISYwQF2RrzGxDymhjRsQV9HRAKzglUVOxznD8tSXlGMEu54bt4gsq3nICJsU4XHs05jCwPXuyDAB/ND+C//SUsFLKcl+77sUsqkrX+MWNsVQ46ikD6gr92MUXrI/h+\ -JEpVewya9QzoWjBOaEe48a+4DNtfE8iRWfbXqDJ5Ep24K0oYSXG9VVWPPNmufB6UxBAEwekGWXglUKtOEWoq0fTZDqGkYRBAQbdTCY4VNVVO1uUADPFc4VjqYbku5uETc2CR71DE9PPDRfZnUez84KU7bQSbPES3\ -hBomsl9N50WppPpSf4G8j+qwRzMW7Nv4ZB0/FVtbJBFwPia7S6iszdFLP9fFqQu00K/DI0asnP4QzIigsqRgk5XKLYVBJhIBvPmMObThcLjJ+Ahj0PDd/AjN+Gyb0JtX4LtSs8GkvUQeN0GHqjEhEyuZs0txB4RH\ -eGt0OhRlmJLjOy27t/rLpf5yrb+se/V0lZZs+ZReGd/+oooYq0pO+gysbfYDDgHXhjr9XqLQUy6lIBh+rPJaLqPU2TRuJCN9n0wNPaS9JUNIdxcPMWx84KzAQN7dXq57KlQqpFqiG1mLMoFv96XKZTRWF1xswF9+\ -Ro9ceKUyzhyj5Cf65nQd0dB8OQycAdI0H9O4zjSuZP+GokV3GGDgjMkxjQQyoj2IK+NzsmOFS6GCHWs1Aua389ufShJU4AIxxcurPaLMsKMlnH75O6OPsiRPAhbchIHnQqh48o6RUpb8vJNcU9JX5OfIf551szzF\ -PgB8vkjZVla8I5qqqkleH4A6FBsMcKl4miw2WK0wcopbCs2xvGyqzYn4h49koK4kbBMy0NrMEjtKUeANscw1JDKHJg0xHjgNm6OxMxFuBFIbCmAShNwqeQyfaY/RUMjBgQpYE0rYZUw2cecQ/OO/nx5/CxiCsr9v\ -gJQS6lYYs8NrjPRo2i+gxgWvIgy2r4H4LRmHcAYGmHTT+EKepSrma3vEPqOXwAyyndGzJa57L941SUV1cMlkueJie1HqaLxg2nziJV6hSNqPX8xSObs26xMv3Eu8wTmVvtFBgqgWeq0qhRUXEOu9GByFqEbw0bOI\ -k7JUi4IAgNZxtENcQcnsy9xlHLhmTi2PMI2S5LBVeaKNG3irNrBLHvIuDnWSUu6r24E6TSoozcHCXEgXexdzwHXhq2T4Ojfu3QGHgoFfKFWcxllghvn38xIcmG0oCY2IGCtcBqFjmZwd4blj9qL1lnwwkoke7kTw\ -hstvUebTYmEcshjbREhkqIZQbD3hbA1ssuZaBVccYxrDUcC1Q3Cu/GulPhtG9BkXplPBwCUMGaYwpHkEW/ygcm7z5TgjwL1Yb4VYXNLfUSTG98V4od7kUaAAP1yNLs8Xz+YJJB8khGKsyiitS/ki3kTmJnkuKWZB\ -dlWp56quElSqw/RVboo+I2rzpE8kvJrDgaepXSdGupAuRIOfJfLk9tS3ExtTEvwDJ65mtDkV1yc2hxWNn8jyDEWQkRG5fCSCnAAixBNQtbAAQGgyuQ6R+xHIrTwX9jNGmLjNRH0NrNSysGuVqgf1vFKfm5izx5Kz\ -oeA4OoDFpZ7/C858+A3gxtX9Ey4zDCux5v96xZNcliGQWnwgT+6lBaKOI+enCjvyq75lfUowzJlp0Dl+/v5WAILtNZZA2cxwAcdixpz1ejk4HbfV9EZ2JGhdM7cT2YLuXmHe5ZRgoWTLHnXLlDjz0xt4Oj/embMF\ -oIT3b9BKjsFe8+cEpUwoNzATFCo83dAiRqCeaWWBxRV/oO4LMObL+az9Cjixv93X1gNWFZXGmDCf445NYhLedlbi/XeaxAhwxLQrwXraeOuV8B+gIRcZgcHVDOpB0gsAk43pl9DB49hl3xs1za56uCLgiOsXUvu7\ -0tzrHmI3kyu59og1oWyT/9K+kYSHr3Gx7WKz3cpIz6oPuPWixZDPw63cHxX3exXup8zpgpPfrP2Z12rEVRZ7uvSJ8orUUeRFb9oRCDJqN+k5Xi5n3OrQLbotNMwGVfZ01DbtU/W5UK348pFgEYj6K02ILQ6Iij9x\ -nByRaZtEJjuivL9Cy/RUcdY/U3HBJBXTs4C7AlhM0DS3wkCNbLlYUg929pG0pYzI+rvM9WzTP9uO3Msu9aCFogXyRiMvlv2Vr9XdZsljJHFtyl7z1reDYaDzsBDGaNQaUOMMkufyhq0zbMgHNWtpK6IM+QN83b1O\ -/ypgZKO1QnTZwPDfYcgZXwjVJ08GDM3MGQDlFZstVrzlzjnkFG8kkzNTd871+cXZrRRsStmfJ+WYEO5+SGjTD3MSVLmz/UUczXsVE3sBgoQBoTiDJ3ucTGr3Wgiovd7ex1pmOUvtSNXyjDt4GoKwCEfbs1t6gqWw\ -SmFoGFlDETscbygLNFS8uJi6zSjHUQ5XXDC7awgQWeezaqwMnMgrySEmrlGKlIWLY9BJXVCndisuKlEP1tkvVA3TVhT7l/BMMGy1If8FkqVjBXVV4PVdkyGHOjzhsFvVSVWlwUIob1rKgw3PUJ0MUyX2eK3BB69V\ -HwKysTm/BwBgdQgmme4fETe7sdSKO6WG1Yl62KeBcpmSVDZMsSYIb5hw8AOcVLDfqLOTzYTTCFGTOaS4hR71kPFEQcxEvceKBBSMil97xsyvZCFbS/vgtuBgvlME7bdtCqipz3dqLQyFNkm44syMriiXV+LK5UC5\ -qgvLdFaSyv4I7mW7H9NRJKrFy5MXX3SsL9vPURaKj+Ic+ObVcRbTNv+JrEAuHHyPUDXbh5UauQp4z5WjWrewvEHFuH+AOIEt0AOysouTy8QjV6iJ5BjXmphiQzpOsnqHlPwCxaFtcuiomXzn6rhxU7dcONgSNEVq\ -fo2IMhZNb7mJSPonLNbZyBc68BNdwL4H4VyA1ErhOWzj3AiM28zUqyL1DXQw81q/Ktnb4iXNJd/g2KkjmMSaeBRbvBT7gvSgjrxKTSBZ9ukcc48uphpw4dyFqczJbqilhmT8XKqhmJHsvzz5e7qjti4RIaJMcRlm\ -8w14az9APACQCZoS4O6+wlYdEBcmCfXQG3ziC7OLy0OSQyieTAW/vVPZ7CupAmz3E0Q74SKzYqtfmfMSB5Vf2XDdIz/5syrhLY8J2LtFR+JHulIIRboU89hfJNHY4Qcsv3jWBnM7psdhcM5jlN4/oHIGCCLEVilu\ -ncG6OI4DW864YSjWG+r8AeZg9xHPYS4N+MfPhqWbwAoNygF+30hdvOImT4dRtT1VvjVXLfGJUyc7PZFoB4N83nrJHs/+eL0tjWxbP8PDGz5BUFkG+91gfuRYwEpW2wjSo4GL4llGUDVbCahMhX7QLmZypdrzHhb8\ -hfkrbCHPHcIWuCYtv/wbOQ8s7Sy1Tjj/5GG8zW1j//Phh+s3389vsHgAtLSzf8GEQ7rsqKA2CAgEu/Istf6QFG6wB7pYK3SCZ+IbeuPfY9Fsny9Fepg8WClY4Frle8dFP6fMEi9cqB9K6M5K6bRvVl/wxUz3tflC\ -EsbHDHwBL/hGpYrigSTDMuWXG6ByJVldRumLpI2YA6Gh7amsCK86m0FWNspxfuf85GIqucqKLxlw+FrJkHIcUz7v5R2m/J0U2DODOoCCQZ0i+u4WH5cakimHMNzsZc3BdIELaEJgpj6n63bpsow3bwihudGInP/g\ -tp+y/UuyHptzIQDj7hQJnhuNGqsSjIluC1fKkYE72xSoggT8BG4IVfyW0jC3SBNT0WKuSyVSq4COlWrGllmRZWIuA0UY25ymFAbrZ83nCy98Hjs8z3sG8UFqg8g9DJpzbA7iMp7lXAPqDzaXq5fjYYAXQbGrblaP\ -pDeVMyVnn3ITkSOuURUi4zgHZtxg8wsrlf4RjqehBjNB4cyCToUZi53Cv99xnZDaWtzPeJDDBTjnskvGsBR1wOW4LJ+Ka5cis7nsBzccJruaKjoNQMoV183FBbmTXs1ki38SUEt2V3H3V37DxWfsV8zcsd2TFeTC\ -EfGKi/FwV36EQ3HPULsqAD7HPS8U4OS3HyxYTOdqya0f0MW65Mu1bmkJ42TLYQ6D11qeO6+tbOLF2OTmEwY4GAn8CVmKaN4ep55R72kauWAwZh849DCCIu1KF+xqnxB+I/+KnbpUfInzESx56SmKKMKvyh7jcky4\ -4TYo40no6EGtW+VeYLu62OeraRQi5IXFjQ4l5cFPJ8os4OeV2O2PmPVIqZUEnhAAzBX/O3zlDn4CU/sCo9b2GaEGy0UDo3qXPKePVpKieuxkKSEdavkqeSb6gzQEzA+9ZdglnY4FUeUlsaNjsF6jfkRhi/8Zrn1X\ -G7MTzx7zCr4voR9tUYwMIU8gBbF/qdJThHaLj3QDkZqJ9nj4am/OF7yFqnfoBu8MmidpP9g8zGXBliMtbSfBMGAEdakZDYc/VB2Eyzu6yWv5caKcregtMU809Zl178EMf/j7/x/W/gp+/muyslyULivz7k1zsb66\ -kYfWLF3RPaz92vPvhNWt9T1+oxfK8tIVhf30bx8B7is=\ +eNqNW3t31MaS/yrjMTa2gb1qzYzUTbLBDsngJHv3AiGGsD5nabWkkBzWx5jJjs2F+9lX9eouPczmD8OM1I/qev6qquefdzfN9ebuw1l19/zaLM+vbXZ+nS3edP9k6osP986vQ/Wo+5rGFCc8ypxft1X313bfww/d\ +wGxGb5zr/rfdg4ImwrM4w9KMONhbGowvS3rp4Xm26R7yyyaj/7NspxtRDJbAUfl5d5QGxnYLmbobkqWdszgf/rqTmaC+pFHwJn2hk+6kY/KOuF33rvW9xwdw2ln30XVndt0GTd49AR6s9B4n6QRw5mY1xZBlOntk\ +RqMPUc1bPPR10/HMwnpLWAeINb0FHQ3rc+QFvnrzQp+zoxlm1mPmbkj2NrtzdkpvcaT/KyPHkrg/i2yfjQQAJxRykDNBThU1jXUr7soHdEodUZfcgDyXv6UP6Qly+OxmUp0+dU9zOMo8A5mCRCa1KjsmehshthvX\ +icN5JeJacS0MyXKDA/WpGu7p+H+ySkv8Dv6RMF5Z21J/Pz6WT6ewF89xy7iacL2KRjpjvfOdHMyie9u9cd3RGk8qjVwu1NGKgfU6Po3VTK/yQ6VtC57ObO+NdKC2Nh0b/kDLTSfl4PgU/CxOCvkrntFR6SptV/kP\ +Q/mrDVBOPlEjmwlX8XMJ4lrz4GU6udiwN+SC8LmnwyfK0DwqNRXX6/TBwJqgw1n2iRaAN8aDL1vDJK1wWvEvNF/d+SYu039+0Z+1IaJrRSiqfIA3ijnMyKEGNlbc0DGxJX6p0puCmIRzwk9ktnAgHTSSP7vf/VOS\ +rzS3zrLDWZcvHid/gEO7+TWQvqJ1wO6AH9adwD+gvm7H0Tt0GwY2Zqdia4gK93lnD1OL3/3vz1ja7XD33sC+/qRBrxev50+/IzVtCgq1VclUj7zyl5jWLMYEYBAr+C/04tiINb7PGjqx6zGpG+LdM2ASsmuHmASj\ +6yGzQmASLb/tk0ZHhsOnY4f6tmPD+wPlScHv5DOWej1x7P7sc1Yemc4Tm+HEOdiBEX64OfgK2oAYNaPz2sUDmjGQjV67/Itrh7+2tvpj660kSjTg2O0+G5hl74df3FIeg6/ix73Yyerowx8xHp4k6m0AZ8x4Y3Hb\ +yVjDl6hlm/4TnLGamKFXXA7fr9XAVYrTKVACTagEwO4F/+GyM46tufLZzXh/gEOZ6ePOsW0mKbSZwNyKPx3sK27upKiNKwm+ItQZAWylMNG0m0smaQeoDKN6MZZgngCF90oB+bnND/hhIPVLkKlJwRVmGy8E/Hib\ +OxVqTgekNMwkXOlHkqxTgc5KQPc5M8WAI5Ew05QRuHU2YiEqujlHYsszghHLYUk7kjpqACAJ8DcQo2AL3x4DN+bRpiiIOruXTjVG3UPHMqU3wD3BaqY4Ujpqp8BYdAk5URrENHIO7fn5FZPcvakrFg/re3we1sRT\ +TatVk3gpPE+jiIkL1M2XKXwoaUieNoDJ8t1U8wheea92edthfTzsXkJ8eqi3Ykx+SZ+OyZiiu6ozti7PiAdUoMe4xQNDu6CdDWQp3gUVBnxYTSp3m/+KNtvwsY2C+fYLnmsi4jZsSnWNdF1oqYHaLfbZxhcc8FCx\ +7+X+yw7L2XQEMitEmqg+SGXLFowDhumvzx/3U4lhdLFTkcbwtpJLtG36wwHLmJ0FcvyUQWyUa4geb77LGRLwJ4cxoKlVnRxQ5dnzWUYmYAeCB0DoYPPga2y+ywkdy8gwUvdMtc0OwepnM05NKoFmK0Kg8Lmyu+x9\ +8CWEzopxXwmQ+D77DFD16h74fY6FqFf/Ib7ymN9wWtTDY9UteCxf0zkio3E5PdNOxwXTzVQKhRCdjxbwNT9rVK5hhqkrgn0EZRVp/F/OM0nIGEfYszpBK53MZiSLgHs8hi+7RweHu0nXOoh3oay6U48aiXu1fLpg\ +aO6AudUrGPv656fn5yccqfHAewIV3nbY0Rc0I1u+vfMbu+B8j0TUT7CvYbXuU0DDz16CenT/VMX/sEAzBi9KANk4k3i6YR1D3/D0dzhpt3G1YJ7VZNIVOyl0VpywoN2DmYQC6gRVPrvsBpSz5x0HGBs5hNEPf9nj\ +fLV9+upEwXPl30DngwNmi8twDMFRu1n06LkA8NUMdOCzpM8YL0G2xvwBhLwhRnRsQV8HhIJzAhUV+xznWhkpzwhUKTd8G09Q+ZYToDDW9MLDOceQ5eGLAxDgw/khJgFLWChkOS/d92OXVFBr/SNG1Kp0dBxh8wV/\ +7WKK1seGbLttVWXIoFnPgK6FpBsjlPh3XIbtrwnkyCz7a1SZPIlO3BUll6S4vlQVkjzZrnwelM8Q8sDpBhl7JcCqThFqKin12R3CRMMggIJup9IZK2qqnKzLAQbiucKJ1M5yXfjDJ+bQIt+h4OnnR4vsa1Hs/PCV\ +O43A5AG6JdQwkf1qOgtK5ddX+gtkeVSzPZ6xYN/GJ5v4qdjZIYmA8zHZbUJlbY5e+pkuZF2ghT4ODxmfcrJDMCNCSAwjoPHKLYVB3hHhuvmCObThaLjJ+Ahj0PDj/BjN+GyXoJtXULtSs8GkvUQeN0GHqkchEyuZ\ +s0dxB4RHeGt0OhRlmJLjOy27t/rLpf5yrb9serV3lYTs+JRMGd/+qgoeq0pO+hSsbfacgRLiAlTr9xKInnDlBcHwI5XIctWlzqahI9np+2Rt6CTtR7KF1Op4gJHjA6cBBhLt9nLT06JSgdUSPclG9Ancuy9U8qKx\ +ukBjAy7zC6rkwmuVYuYYKD/TN6fLjobmy2HgDJCX+Zi3ddZxJfs3FDC6wwADZ0yOaShrE+AVxAT4nOxboYdUsG+tRtj84/zjLyUJKnA9mULm1T5RZtjXElS//JMBSFmSMwEjbsLAeSFaXL9jsJQlV+8kuZR8Ffk5\ +cqFn3SxP4Q8wnwgF3XzxjmiqqiY5fsDqUF2AEnlbPElGG6xWGDnFR4rOsRptqu1aXMQnslFXErwJGWhtZokdpSjwlljmGhKZQ6uGMA+chs3R3pkIN8KpDcUwiUNulZyGz7TTaBKeRntyqQNj4KVfTbcogn/0j9OT\ +HwDQUQL4HZBSQqEKw3Z4w2EuL49rKGrBq4iE7RsgfofHIS8zGGBSY/KFPEtFzzf2mN1GL4cZJDyjZ0tc925sTUkBdtCTslxisb1AdTxeMG0+8RI7LtIPxS9mqfxdm/WJF+4l3uCcSjeAkCAqfl6r0mDFFcN6P8ZH\ +IaoRiPQ0QqUsFZ8gBqB1HN8hrqBkDmTuMg7cMKeWx5hJSX7YqlTRxg28VRvYJQ95F4c6ySoPVDOhTpMKynSwEhdSH/BiDtAufJsMX6fHvZZxKBj7hVKFapwFZpj/NC/BgdmG8tAIirGkZRA9lsnZecul1BqcT70j\ +H4zg+6M7Eb/h8lBKB8liHT2HJLeJqMhQGaHYWXPCBjZZc7mCS4wxk+Eo4NohPlf+tVKfDYP6jCvRqWbgEowMUzDSfAVbPFdpt3k0TgpwL9ZbIRaX9LdUhfF9OV6oN3kUKMAPV6Ne++LpPOHkwwRSjFWxy7qUMmLj\ +MjfJc0kxCxKsSj1XpZWgsh2mr3JT9BlRm+/7RMIrwGjNNLWbxEgXUv80+FkiT5qtvp3YmPLg55y7mtHmVE2f2Nxy4jhK9AxFkJERuXwkgpwwIsQTULWwAExoMul/SEME0ivPlfyMQSZuM1FiAyu1LOyaiy64q3pe\ +qc9NTNtjjdlQcBwdwOJSz/4FZz76DqDj6t6aKw3ZELb/V69+kssyhFOLD+TJvXSa6jhyfjpoQtVDy/qcYJgz06Bz/Pz9RwEItncPBSpnhms4FpPmrHf1gzNyW01vZEeC1kVyO5Ew6MsuzLucciyUbNmjbplyZ356\ +A0/nJ3fmbAEo4YMbOMX8ZA9AwTOCUiaUW5gJChWebGkRI1DPtLLA4oo/0GUNMObL+az9FjhxsNvX1kNWFZXJmDCf445NYhI2Ryvx/neUFwFHTLsSrKeNd14L/wEacp0RGFzNoCQkVwdgsjG6hE7hxC773qiBbC8+\ +XBFwxPULKf9dae51D/Hykyu5/IhloWyb/9r+JgkPd33xlsZ2t5WRnlUfcOtFiyGfh1tpGBX3ekXuJzwTk9+sfclfG/GTxb4ufaKwImkUdtGVdtSBgNpteo6N6IyvRXSL7goBs0GVPZ2zTftUfRZUK241EiYCOX+r\ +CbHFIVHxNw6SIzJtk8hkL5T3V2iZnirO+mcqLpikX8OVXSuvNM2tMFDDWi6W1IOdfSRtKSOy/ogdPdv0392RLuxSD1ooWiBpNPJiqWdnxbXqZJbz1KYBpWnK3kWvHwbDQOFhIQzQqDXY9oLMubxh0wxbcUB+tZFb\ +SPlsDz/vXad/FSqy0VQhtGzBqv6EIWfcEKrX3w8YmpkzQMkrtlmseEuHOeQUbCSNM1Md5vr84uyjFGxK2Z8n5ZgN7n1IUNO3us5/drqIo3iPqb4VwEazWL8U2vc5hVROFZgekOnXuwdYxCxn6c5StTzjaz4NeRqH\ +8fbsI4e2giJxr00Oo2uoYIeTLeV/hsoWF1OtjHIc37CytmBe1xAass5b1VgTUJ1Oyh4meihFyr9tkfqxMYmScFJQ6ooVJbqsdfYrlcK0CcWLTngmGLbakvMyjRwrqD6B140mQ650eMLhtVYn9ZQGq6C8aSkPtjxD\ +XVrATkczPrhTB6/VlQNkY3N+F0L/6gjsMTUfETG7sdSKW6WGdYl6eCUD5TIlqWyYXE0Q3vikUoHshZ1Gna23Ex4jRG3O6bhuoUc9YCRREDNR97EWAaWi4veeJfMrWcjWcs9wVxAwNxQx1rYplKYLwVNrYRC0ScIV\ +52TUn1xeSdYpB8pVUVims5JU9mfwLbv9aI4iUXfBPLnwRcf6sv0SZaH4JB6C266O85e2+f/ICuS/DxaJqtkBrNRIH+A914xqfVvlN1SMe4eIENgCPWAqu1hfJh65Qk0kr7jRxBRb0nGS1Tuk5FcoC+2SN0fN5Iar\ +4xue+naFgy1BU6Ta17TxyuNHvijESB1ijIFYYHGtDMP0XQjigp1WCsLhRc+tILftTL0q0m2BDlle61clu1pszVxy38ZO0W4ST+IZQvFKDAsykjoyia97oO59Psd0o2OSAf/N9zSVHdktXZshnXsuBVBMQg5eAZv/\ +oWpWgXtTTIuIMgVl2J/b3639APEA4CVoSoDGfYW3ckBcmB7UQ2/wmbtlF5dHJI5QfD9IrnDL/VPZ7FvJ/3f7qaGdcJEZwZpUk/MSC5Vf2XLFI19/rYp3yxOC9G7RkfiJ+gmhSB0xj1eJJCQ7/ICFF89KYT6O6XEY\ +ofMYqg8OqZAB8gjxVhRfmsGKOI4DW0Zx6fZ8nd/H7OsegjnMogH5+NmwaBNYr0FHwO8bqYhXfBvUYVRtT5VvzdXd+cSp9Z2eSLSDQT7vvGKPZ3++3pU7azsv4eENnyCo/IL9bjA/0zRRstpGhB4NXBTPMnyq2VhA\ +ZSr0g3Yxk35qz3tY8Bfm77CFPHcIW6BHWn7zn+Q8sKiz1Drh/PcPYis3eY2jD9e//TS/wbIB0NLO/gUTjqjNUUFVEBAIXsCzdO+HpHCDl6WLjUIneCZuzxv//hug8YDbIcVc+0ErpQpcq3zvuNznlFliq4UuQwnd\ +WUlX8ve+5n4MX8//SlLFR4x6AS/4RiWJ4ogkvTLlN1ugckn5HEgQcxdJGDEBItCpEhe4DoGSlZSsl9ys/+Ss5GKcUq2/SeDQ10p4lNmY8nkv2zDl/zJuZs6Q0V9hRKdw3uzwWenaMmUP4CNRY83hdF0L6EJUpj6n\ +RrvcpowNN8TQK/blljxBr89PSf4lmY7NOf/HoDtFgucrRo1VqcXEPQtXpmPXeF5ssXG0T8iGIMUfKQFzizQx1SrmukIiJQq4q1LN2CwrMkvMYqD2YpvTlLxg2az5cr2Fz2OH53nPCD5ISRC5h4FzjteCuHpnOdGA\ +soPNpeMiN4Ty4e1I9tPN6qHcQd1hz22f8PUhR1yj+kPGQQ5suKnkWkLT/6mOp6EGc0DhzIJOFe8NjcDvj1wepAst7iUe5GgBnrnssjGsQB1yFS7Lp4LapchsLvtBY8NkV1O1pgFQueJyufgft+5VS3b4hwO1tH8r\ +vveV33DNGW8qZu7E7ssK0mdEzOJiMNyTn+pQ0JMrZjX3wI1EN/mFCAsWc7lasur71E+XTLnWl1nCONNymMBgN8vzDWsrm3gxNml4wgAHI4E/IUvhzNuTdFvUe5pG/heM2QeOO4yiSLtSX13tE8If5FzxXi6VXeJ8\ +REpebhNFCOFXZY9xOWbccJst40no5UGtW+VeYLu6OOCONAoRksLiRseR8vCXtTIL+BEmLoi49ViplUSdEB6DTf97L3we/gLPvpLhB7tnBBlss8ddbW4Ve04craRD9djDUio6VPGVduOSgIDtoauEjNEYVQRVLhJv\ +cQzWa9QvJWzxb8O1b7u67MStx4yCeyT0uy6KjiHk/fJKVqrEFEHd4hN1HdIdon0evtqfc1O3UJUOfZc7gzuTtB9sHuayYMsxlraTaBgwhLp0Bw2HP1AXB5e3XByv5feLcrait8Q80dRn1t37M/xt8H9/2Pgr+IWw\ +ycpyUbqszLs3zcXm6kYeWrMy8LD2G88/JVad6rv8Ri+U5aUrCvv5/wDWE/uZ\ """))) ESP32C3ROM.STUB_CODE = eval(zlib.decompress(base64.b64decode(b""" eNqVWmt7EzcW/itpEkjhaXcley4aaINNbZwLsNCHkg1rtsxoZlJomy3BLGG3+e+r91xGYwcb9kNiW9LoHJ3re47mv3uL5nKxd2er2hvPL63dnl/65Gb4N5hfmix8hr8qz8OP5BXmZ/PL2oXhKk9krMon4be7N5+P\ @@ -5300,38 +5352,38 @@ def __call__(self, parser, namespace, values, option_string=None): ro758Wd5BnYp7TYXfRQkJ6/30EJPUMkkaKIn0xpN9OTkCO6enO6hnE5e4DLa6L2LqtNGJxow+3/cohcuf3w/z2/w2qU1aRpZm0UmXKmu5jcfm8F+v5eFwTKf5/p+JjAVPGlfhrtSjE0iZ6LF/wCAbuTq\ """))) ESP32C2ROM.STUB_CODE = eval(zlib.decompress(base64.b64decode(b""" -eNq1Wmt7E8cV/iuObXBC8/SZ0V4HgpFARrbBFFKCCxUNuzO7LklwYyMH00b/vfOei3YlWyb90A+ypdmZM2fO5T2X2f/szJrL2c7djXpnemns9NLGT13E7/iYd4fTS1/Gb8n0snLTy5JGb8fB6ln8k38f/6RxKI//\ -m834x8vqlFZPL9vwugCN6kH8Y55G+sksjqYPpufTy8bEr4NhPd6K1MttZqAeHEwvw2D88GAzLjRZFXcdxE+cW5bD+CeZ7kxPQR7ELiKFLP5oeZYr5nE0bt5Ehq2LX9r4xEfO67aY7hBTvz+J80KcX/Pati2KNQ90\ -6xHLhY4ZPyEUdEymB+ZzEdhgIbn4iXJz8eMT/H80F17KY5xxCOb3un1M/F+6EYvg+k3dg7lszTsMezzoTt1v6x9B+kw97neVNNSVFuP4t47KcQnTjeqMCnL+ie4MZcdFVVzs27eFZXHahJXM0225HzcJk0jbjqMJ\ -hLiyUTGkYzyD9niXOmUVGXOEfbMHYHbcF5xl+g7701gkWcRjNDlPIAvL2Sbw2zm2JR1nIiqL56wCbIn/dXF7IbKHpJRR5NtZJmGyCabiOBXMCbyxjWOTshE6Jcl0M57MDcZLohXR6FE8ZDmKf200qibj0dKyeEps\ +eNq1Wmt7E8cV/iuObXBC8/SZ0V4HgpFARrbBFFKCCxVNdmd2XUhwYyMH00b/vfOei3YlWyb90A+WpdmZM2fO5T2X2f/szJrL2c7djXpnemns9NLGv7qI3/FnfjqcXvoyfkuml5WbXpY0ejsOVs/iR/59/EjjUB7/\ +N5vxw8vqlFZPL9vwugCN6kH8ME8j/WQWR9MH0/PpZWPi18GwHm9F6uU2M1APDqaXYTB+eLAZF5qsirsO4l+cW5bD+JFMd6anIA9iF5FCFn+0PMsV8zgaN28iw9bFL2184iPndVtMd4ip35/EeSHOr3lt2xbFmge6\ +9YjlQseMfyEUdEymB+ZzEdhgIbn4F+Xm4p9P8P/RXHgpj3HGIZjf6/Yx8X/pRiyC6zd1D+ayNe8w7PGgO3W/rX8E6TP1uN9V0lBXWozjZx2V4xKmG9UZFeT8E90Zyo6LqrjYt28Ly+K0CSuZp9tyP24SJpG2HUcT\ +CHFlo2JIx3gG7fEudcoqMuYI+2YPwOy4LzjL9B32p7FIsojHaHKeQBaWs03gt3NsSzrORFQWz1kF2BL/6+L2QmQPSSmjyLezTMJkE0zFcSqYE3hjG8cmZSN0SpLpZjyZG4yXRCui0aN4yHIUP200qibj0dKyeEps\ 5kDffgUPgCUZtgVMa93xLiZ1pCN3np1QpVu6xxiJ4g0y0oZjVjykAXnbQkjajrfawP+8FWIJmxr4axsQnajT9AwjLsE5cvE4IzZnuyl64tZ2u0MfgXYjxmireJqArfxVEmDsA29cF3tkm+IHmFFmezA3NswXD/yB\ nCzH7EnPknEqryJKeg4qWBYwGz96CPIQU0Y83wrnJDuDJzmeDLagcCFd5jCQLd6k0uP3iTt70rFD26fdJpBllHWrsAGaBJOqI+W/AhW1RrNyGDV5Ovl6GdBvARKTYuuFOwl88ZHEAoP+wGF5q6/4SbRJVqIRO4AS\ -V+FFSIY+yUYYDmKZHGsoZFyLQRRj8HWi4YVC0TM+Qx9+YHBACzHKCgYcH9WObDZK7JuxPEEocbfZlW3ymm2c4ojf9z9EMkZ/jv2POCtUgzhyn5B3f3hbpNiwWzqRLuAAMEs+beS8YSU84cA+00MOyVOmtHY6ZHlF\ -clPieQrETPgYrhiOGYAoUkpolDDZj47nWcN+o1G8F5Qv7klM9s2DXzR0YvmYGV93EMiv8QJUNmOEqAcTPgWZbrGxyypp7L1+9JmobQ6v2Q/eX7aCrfD6wd46JiKxpoI4CgFHzRkEGnsiGGn2ol5AYM5gscXgrVbY\ -848Z8wZj9X1cI9Q8mTMGIK9B8PDyBKZRhrtsdbAr/K8tQ3uJyfUWP2BcHCGQOIY6lsRzhsprI3MX9JdjCfzWSBgZKCEF85t0GHqzPc3u9rWCKrzuRIhAIlfiBYF32cWJG7c03ZaM/5BuXXSphyQWfNQ74rTi13Um\ -YR/cuVTC/rqIa5BJGZlFASHdK9gF6+LiDMBh5x/x6D12zm6LMuMRQsPSCZK1hEo4KuYwjIozAwGmGQuj1MxAmAXjbbXLjDLIbLJxKha5AlKpr0EJv0rcZD91OxAIVJMRoxnnJye9eEuf+UWPlUxskwgIS8vTV/jP\ -ZFEcqyDObJeN2QGiVlmmJEsP5+0evsDP8M1kvhNYXQ3vQFXVeHoacarNX7dvIOA3BwtvBZY6/xGTVHHvDxlfoYgye3YTyL5To15B2CYs0dhUGmsOU3kOM4gIjLjbo/eMXCwd8JX/wMCq8tI051rPQfbg7dnZ/OMr\ -bPkGQeYfsKda8IUC4yYwMEogJIdwNES1FrVUQIWQ/MRA0Yh9kklVnXCX+Bj8mQuWGkKtc0YfoIMf3BSgKPs88Rj6xBTLLMDkF+lK+kVjXwjXXC/cEOb/Xk+QrNLfZXutG06EVyfHXc95SWfVUPTBrpRq2WqGVax4\ -D+UPVrLAgPiDfdo0Jpmm9mfsWQQg8McqKzS8wz6zEblH8YxtqvqiTXG+xiQcSmTn/G/v2UxqxVKHeqAdCNOLJ38asbpLYjD5JOUwjSwx8OrL2Ydf9o0jzrv+qLS22DGghLZETDtAtItEKsxx+qT9Mh/1YC55FNwi\ -S/kHAjpWNm7X/6WzZYSXZnBfCu/1vNIgmcH3nIGfcv5NvGYAUi1AFtkqijbNVq2d8CAk2jgYw/8TVwVPGVzXmA0Cpmt+yDpkvbh3dn/V09eLujHbVwD4+Z2XsMGX09PXYOPgJyBNdXj4BA+f3HmKh0+np0dA57dH\ -vS5LXRyPDpCunHUKQKoHz49IvysOkgs4SfCsJHgCTUMpwTWX4Jr2vlecG2At5jQDzq5QjGAtbAPHA/j5/OYco6o126seAMaWSh9NmzSFwVgNs26kGrHpLejD7v2Tc8KSpZ2x6SzKseVS6quTXbK5DUl/tQTLyqH2\ -zfDN2MfLnFhNOjPV6KItZrM9Iidh8PoDb0C1XVtuOp2sWkfxpCcAOl9B6eKUWV9vOswcyZFy97L8EcLYw9gh0TyD11dcAdgk4y838lohjqFuRSPCFsuJLHLYMmtHrcqua/tQJhEPMCMfmQF2fi6eqibW7laJcMX+\ -RO2n2iYkNK415LC9LToDhawpGSEQgWk87cZj+cMl7akUtPBFYAz+U8AvtKU1nWEqTtvIc2Bmf74hhziiRk4tFUn+gn46/fkNfrqm1+ahTdKux+CLbYk2UqEHJyWVpbVZt9Z5ZGL+0S454vk9RKi9fVZDBawwfeJl\ -n7iz7SbIv2XaC4NG4wC1W6ss/k/ViLtSjaybbVZmUwa8tvAYMvT5zHHDsS60oaaSwGGLD/zUO9UUa+aCrXFZnRl112DMxbewhjZnuVluuwGjipzQPCdTOafhTEiU/hd5kk5n9AQ8F19TBtMFF2o7tBqwsW/7Ptef\ -iJ3ti/zISiAzsuaK5d3vLGrsPwCecrUGIHdTvATbE+GvKV5NzyUOOgHEVtWfXWcLVtCLw4AYXiaJRZDSlgA1lT4B/aBjo+8DOi57LFtmXHED9Dziscn2PK9vGbbYbEO5v7Wt2Li1yeHBmAvevspUqKG4DWRvRdwI\ -lYGeoayDwCurO7eyc95vxQy8mELBXTkjUcsiY2RQusGgISeaFMJ3kLmbzlznZXQjcSufi6KheWPHEqZb+GDXwt1GkqqcDoRTyJP0iOCuHAaPCF4+BZ/70OE+cG0MYY9vRvuyQbHtgOPcUJHa20rkC7aTKtzNcyUt\ -dhytgx4v+nuelaJyr0Once4W+4XohSSJIRv3G6DUJoe07In/GWMo0Q0aXxiNR5JuGKHPIPuOM9SZ9i9TqYEMOzNlwCzVusfHQrDCXOMXxjfujO+0k2PzHcqCUhvZG9QAXxxtILnEwuKSxe3DuaB56LWbDEPH+bJy\ -IbqKlGvqLqWI3iBKqbI+B0IZ6RSapjw4XNBMhSZCVjLhECr4tchBPJonWrlW6YEgOUNEL2NKuzq3tJPuCKS8RoIorWg0grzso8ZYg/pBP4LwsyDGObjyZCaVwEpQawR7IOom7Ti0yqGTllE2hlE07a+SZVBjQt0X\ -9ufDUhfhHk0HGFEaiDUhuysOClc9XxD+0LVKWyNdwKVq53OS9lqU4kwk5SCoacSo6+SEHV6l7Sj5sre4k90GdBHbMEK3yoU5tw7bMNe6Igx5CIqm09VU70j78XoOh5dAM5A5ZUtphMM6+XSLEZ0KpGL0vtvGn0q9\ -Z+afu9HPwOUbN8M5L4Rtd8j7tdr+u2kZQXuTdBG/NaTq7ZH0CQpyF7mCsOwxTboSUNlw0TWrxcOh9rrt3L2782o1Fvj9fgRpOuhBkWhYX3UhZWO7SMUe8wC1GDIp8C2nBnTi0PNFNgXf9jJPuYAAwDbJlnhT3V1U\ -iYfe10sTavrvsSo5wE5kZFHmCqoQ56Xa/jUGcc5X+nxR90nAxzBPLaUjbye90J92RkxstOEtNr1gKiHsj9ertaEyxPrx32C56XAOt5abTL0Mcrhmc5LStEIAaF62mn6Wghmxxh+xpoNeUkIMlfwok1uH1HSX9rHc\ -bNIFTLtkKu+kHgiiNLxaQFUE9Z4bTaIpVfikSaQgiEm+1rlS70WcVKulalBtRXvZjeswluxXr0dzZDaBc5xtuTYwcp56xeKseaaJrCAaSeQxk6d8YtkkjJgEWet2x7KV+7FFi4OcJu5/KrkW/UeWoJk4Xd0lSwLc\ -kFuMTPpofS8s9f77uofO9Fbag375Y73XUJjuaYoqLxTU5U210JKd2qu1EdUvgcf4pYuDVVfk9Pi8e6/AJ36M4tv6Y37TQWvZX0lcrK3GdVpF945QoNch4tO+Zo54uSQTWgF6He+iubwkADp0yvRqVo7Qmr7lNHd9\ -YDru3t/hQ8IxUv+RXrjZFMEnVIPMOInqkMcQelt5/4ZFNaOc4VV3X6oi5FDhn5O1ngqaGvY6X12wBRHtTGmXedcXUbVdf5KNv1JXYPkGVeTfuj4jB4JjldzPQ+jLM1QQ3M7cGVF1/81Nu797IW9ExEqu6bVesrOe\ -cFVB5gYoLM2jpResEEufrL66ItUUyeZYGtiWjPmCLbmW15TUsmuuzHcEVCgnSOSeteh6h9eca9zrV5rdtcIfMvDV/vp6QzUNXrAKaSsMl8f/xXorrb7Y8Zte0Krh5PyGww2NN3kBp92Vqx1dSWk/3vqKBE8X147n\ -BOp6nZF2O5hs32uWxan6/kM0Gu+y+vQcDeUKm5PBvryEog3c36U4FejWTpLVTyLQixi+PsmB2AbsljuSWUB4XqMG5WlDjvJ0ZCRQ9eAY0YFuNalm03uTTK6cTe8NCt8FK0I8efmA3iUhdKk4MDW5dPH15OjchUQa\ -J049UrINCiiEEmjXNnobUHSXN6ZYRJJl16RIPZCyXvFNV5r1aQq1Sq/63BozTdY+KT6zAVAC3pCFUBwqv7B7adI/5CGgrF36VPpPVBY/b1/CZF8+jvBf569vv0E0ewPz+TseP2lRwudPHx/h8dF01uvEE0Gz8+0G\ -vaT548dZdY5XNa0pitTaMjXxSXM6O/+8GEySQRkHQzWr9J1OGFX0px0Z7lMxA5e5Ip//FwVa/vk=\ +V+FFSIY+yUYYDmKZHGsoZFyLQRRj8HWi4YVC0TM+Qx9+YHBACzHKCgYcH9WObDZK7JuxPEEocbfZlW3ymm2c4ojf9z9EMkZ/jv2POCtUgzhyn5B3f3hbpNiwWzqRLuAAMEs+bRhImrASnnBgn+khh+QpU1o7HbK8\ +Irkp8TwFYiZ8DFcMxwxAFCklNEqY7EfH86xhv9Eo3gvKF/ckJvvmwS8aOrF8zIyvO4iRgxBQ2YwRoh5M+BRkusXGLquksff60Weitjm8Zj94f9kKtsLrB3vrmSDrqSCRQvBR0wZBx54URprAqCMQnjNebDF+qyH2\ +XGTG7MFefR/aCDhP5gwDSG0QP7w8gXWU4S4bHkwL/2vL6F5icr3FDxgaR4gljtGOhfGc0fLa4NzF/eVwAtc1EkkGSkjxfJ0E4QahN9vT7G5fK8DC606ECCRyJWQQfpddqLhxS9NtySEA0q2LLvuQ3IKPekf8Vly7\ +ziTygzuXSuRfF3QNkikjsygmpHsFG29dXJwBO+z8Ix69w87ZbVFmPEJoWDpBEpdQCUfFHIZRcXIg2DRjYZSaHAizYLytdplRxplNNk6FI1esMW2Em2XiJnvf7UA4UE1GDGicopz0Qi79zS96rGRim0RAWFqevsJ/\ +JoviWAVxZrtszNeyDA5KI4fzdg9f4Gf4ZjLfCayuhnegqmo8PY1Q1eav2zcQ8JuDhbcCTp3/iEmquHeHDLFQRJk9uxlnq4Vdr+BsE5bIbCqZjVUaG79zmEFEYMTdHr1j5GLRgKn8BwZWFZamOde6DdTp7dnZ/OMr\ +QMAbBJl/wJhqARcKjJvAwHj8kBzCyxDVWtRSARVC8p5RohHjJHuqOsku8TH4MxcsNSRa5ww9gAY/uClAUfZ54jH0iSmWWYC9L9KV9IuWvl6s2GE2//d6amSP/i5bat1wFrw6OW55zks6e4Z+D3alTstW06tixW8o\ +ebCSAgYEH+zTpjHDNLU/Y58i6IApVVmhsR2WmY3IMYpnbErVF0xp+CsvdqiMnfO/vWPrqBU/HcqAdiDsLp78acRaLom15JNUwTSytPWrLycdftkZjjjd+qNyQrjyLP62RBw7QISLRCrMcfqk/bJT1oO5pE/whizl\ +HwjiWNm4Xf+XzoQRUprBfam31/NKg2QA33PifcppN/GaATy17lgkqajVNEm1dsKDkGjjYAb/TywVDGVAXeMk3jQ/ZB2UXtw7u7/q3evkvHHrCtw+v/MS1vdyevoaDBy8B7RUh4dP8PDJnad4+HR6egQsfnvUa6vU\ +xfHoAMnJWSd65HZw9Yjru+IUuaCRhMpKQiXgM5QSSnMJpWnve8WZANZiTjPgXArVB9bCKnA2oJ3Pb85FK6+5XfUAuLVU62iSpAkLxmqsaKT8sOktaMLu/ZMzwJJFnbHRLOqv5drpq5NdsrYNyXe15srKoTbK8M3Y\ +x8ucWE0xM1Xnog9msz0iJ0Hv+gMjia66Ptx0Olk1jeJJTwB0voKSwymzvsZuOAklIVKmXpY/QhJ7GDskgmdw9orzfZtk/OVGRitELVSpaDvYYjlnRbpaZu2oVcF1TR5KGiL3M+yLzzL8XDxVNazdrRLJivGJzk+1\ +KUggXGuMYWNb9AEKWVMyMCDe0njajcdihwvYUylf4YWAFvyn8F5oA2s6w1SctpHngMr+fEPecERtm1qKj/wF/XT68xv8dE2vqUObpF1HwRfb4gBSjwcnBZSltVm31nkkXf7RLnnh+T30D/b2WQ0VgML0iZd94s62\ +myD/lmkvrBltAlRqrbL4PxUe7krhcZOH92dTsru2xhgy7vnMcXuxLrR9ppLAYYsP/NQ71RRr5oKtcVmdGfXSYMzFt7CGNme5WW6yAaCK3Nf8IJrKOQ1nQqL0v8iTdDqjJ+C5+JpSli6mUJOh1TiNfdt3uf5EyGxf\ +5EdW4peRNVcs735nUWP/AdiUqzUAtpviJdieCH9N8Wp6LuHPCRq2qv7sOluwAl0cA8TwMsknglSxhKapdAXoBx0bXR7Qcdlj2TLj4hqI5xGGTbbneX3LmMVmG8r9rW0Fxq1Njg3GXPD2VaZCDcVtwHor4kaQDPQM\ +FRwEXlnduZWd837jZeDFFAruwRkJWRYpIoPSDQYNOdGkEL6DzN105jovo/uHW/lcFA3NGzuWGN3CB7uG7TayUuV0IJxCnqRHRHblMHiE7/Ip+NyHDveBa2MIe3wD1JctimoHEOfGidTYVmJesJ1I4WueK2Yx4mga\ +9HjRyvOsERV6HTp1c2PYL+QuJEkG2bjf66SOOERlT/zPGEMpbtDjwmg8jzS+CHoG2Xeclc60VZlKuWPYk3EszyKte3wspCrMNX5heePO8k47ITbfoQgotWe9Qb3uxdEGkkUszC1ZXDScC5SHXlvJMG6cL2sWoqtI\ +s6bukonoCqKUKutzIJSRSKE/yoPDBc1UaCJeJROOnwJei+zDo0miRWqVHgiMMz70cqW0K2lLO+mOQMprJILSikbDx8s+ZIw1oh/0wwc/C2KZgytPZpL9r0S0RoAHom7SjkOrHDppDWVjGEXT/iopBjUg1HdbI026\ +nu+WEUhmDFaBckAsC9ldcVC46vmC9oeuMXodrcZ8TtJeN1L8iQQdBDWN2HWdnLDDq8AdJV/2Fvet24CGYRtGaEy5MOcErQ1zLSfCkIegazpgTWWOdBrXn/YSgAZKp2wvjTBZJ59uMahTaVSM3nU7+VOp9Mz8czf6\ +GdD8hf2M+U04d4e8X6vNvvXLhhcS52Sv1pC2t0fSGCjIY+TCwbLTNOlKQGXbRYOsFif3gbFWPb674Wo1Fvj9fgRpOvRBbWhYX3Uh1WK7SMUe8wD1FDKp6y2nBnTc0HNHNgXf9jJP17XUm2RLHKrurqXESe/rFQm1\ ++PdYjxxgJzKyqG4FWIjz8mbzP+c7fL6Z+yQQZJitljKSt5Ne9E87OyZO2vAW+14wlRD2x+s223hLdyh/g+GmwzkcW64t9ebH4U7NSUbTymLgedlq9lkKasTKfsSKDnojCSlU8qNMbh1Se10axXKNSbct7ZKl/CTl\ +QBCd4T0CKiKoy9xoDk2ZwifNIeUC3SRf61yp9SJSqtFSJaimol3rxnUoS+ard6E5EpvAKc62XBAYOU+9YnDWPNM8lmMqS+Qxk6d0YtkijFgEGet2x7KVy7BFY4N8Ju5/KqkW/UeeoIk43dMlSwLckPuKTPpmfScs\ +9bL7uofO9Fbag371Y73XYJjuaYYqbw/U5U2l0JKN2qulEZUvgcf4DYuDVU/k7Pi8e4nAJ36MCtn6Y36tQUvZX0lcrK3GdVpFz45AoNcX4tO+Zo54uaQTWgB6He/iubwRADp0yvRqUo7gmr7lLHd9XDruXtbhQ8Ix\ +Uv+R3q7ZFMEnVILMOI3qgMcQclvBCxbVjLKGV93lqIqQw4R/TtZ6KmBq2Ot8dcEWRLQzpV3mXU9E1Xb9SX76KzUFlq9LRf6t6zNyIBhWyWU8hL48QwXBTcydERX339y0OwL7C3kDItZyTa/zkp315Ks6MuP1lLx5\ +tPRCFULpk9VXVaSeIvEcS8/akj1fsDHX8lqSGnfNtfmO4AplBYncqxZd3/AawY57jUqzu3bakLGv9tdXHKps8IJVyF1huzz+L1ZdafVFjt/0NlZtJ+c3Gm7ou8kLN+2uXOLoSsr98ZZXJHi6uGM8J1zX64u028Fk\ ++17zLM7X9x+iz3iX1afnaChb2JwM9uWlE+3c/i7lqaC39pKs/iWCvojia3IcyGzAbrkjiQUk5zVqUI425CBP50XyVA+OER3o/pKqNr0nyeRy2fRel/BdsCLEkzcN6MURQpeKA1OTS+9ej43GXUikb+LUIyXZoIBC\ +KIFWbaN3AEV3WWOKRSRZdk2K1AOp6hXfdOWNSbrBNeiqw62x0WRt/lF8Zu1T/t2QeVAcKr9YIqR/yD3ApzT4SFmBt2vz5+1L2OvLxxH+6/z17TeIZm9gO3/H4yctKvj86eMjPD6aznpdeEICs/PtBr2R+ePHWXWO\ +9zKtKYrU2jI18UlzOjv/vBhMkkEZB0M1q/QFThhVdKYdGe5TMQOXuSKf/xdxa/YZ\ """))) diff --git a/tools/gen_esp32part.py b/tools/gen_esp32part.py index f1423a310e9..ba6ba6c5da6 100755 --- a/tools/gen_esp32part.py +++ b/tools/gen_esp32part.py @@ -7,19 +7,9 @@ # See https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/partition-tables.html # for explanation of partition table structure and uses. # -# Copyright 2015-2016 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. +# SPDX-FileCopyrightText: 2016-2021 Espressif Systems (Shanghai) CO LTD +# SPDX-License-Identifier: Apache-2.0 + from __future__ import division, print_function, unicode_literals import argparse @@ -261,6 +251,17 @@ def flash_size(self): return 0 # empty table! return last.offset + last.size + def verify_size_fits(self, flash_size_bytes: int) -> None: + """ Check that partition table fits into the given flash size. + Raises InputError otherwise. + """ + table_size = self.flash_size() + if flash_size_bytes < table_size: + mb = 1024 * 1024 + raise InputError('Partitions tables occupies %.1fMB of flash (%d bytes) which does not fit in configured ' + "flash size %dMB. Change the flash size in menuconfig under the 'Serial Flasher Config' menu." % + (table_size / mb, table_size, flash_size_bytes / mb)) + @classmethod def from_binary(cls, b): md5 = hashlib.md5() @@ -505,7 +506,7 @@ def main(): parser = argparse.ArgumentParser(description='ESP32 partition table utility') parser.add_argument('--flash-size', help='Optional flash size limit, checks partition table fits in flash', - nargs='?', choices=['1MB', '2MB', '4MB', '8MB', '16MB']) + nargs='?', choices=['1MB', '2MB', '4MB', '8MB', '16MB', '32MB', '64MB', '128MB']) parser.add_argument('--disable-md5sum', help='Disable md5 checksum for the partition table', default=False, action='store_true') parser.add_argument('--no-verify', help="Don't verify partition table fields", action='store_true') parser.add_argument('--verify', '-v', help='Verify partition table fields (deprecated, this behaviour is ' @@ -531,12 +532,7 @@ def main(): if args.flash_size: size_mb = int(args.flash_size.replace('MB', '')) - size = size_mb * 1024 * 1024 # flash memory uses honest megabytes! - table_size = table.flash_size() - if size < table_size: - raise InputError("Partitions defined in '%s' occupy %.1fMB of flash (%d bytes) which does not fit in configured " - "flash size %dMB. Change the flash size in menuconfig under the 'Serial Flasher Config' menu." % - (args.input.name, table_size / 1024.0 / 1024.0, table_size, size_mb)) + table.verify_size_fits(size_mb * 1024 * 1024) # Make sure that the output directory is created output_dir = os.path.abspath(os.path.dirname(args.output)) diff --git a/tools/platformio-build-esp32.py b/tools/platformio-build-esp32.py index 6c82fce96ef..2035041ce0c 100644 --- a/tools/platformio-build-esp32.py +++ b/tools/platformio-build-esp32.py @@ -36,6 +36,10 @@ env.Append( ASFLAGS=[ + "-mlongcalls" + ], + + ASPPFLAGS=[ "-x", "assembler-with-cpp" ], @@ -193,6 +197,18 @@ join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "bt", "common", "btc", "profile", "esp", "blufi", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "bt", "common", "btc", "profile", "esp", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "bt", "host", "bluedroid", "api", "include", "api"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "bt", "esp_ble_mesh", "mesh_common", "include"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "bt", "esp_ble_mesh", "mesh_common", "tinycrypt", "include"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "bt", "esp_ble_mesh", "mesh_core"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "bt", "esp_ble_mesh", "mesh_core", "include"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "bt", "esp_ble_mesh", "mesh_core", "storage"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "bt", "esp_ble_mesh", "btc", "include"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "bt", "esp_ble_mesh", "mesh_models", "common", "include"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "bt", "esp_ble_mesh", "mesh_models", "client", "include"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "bt", "esp_ble_mesh", "mesh_models", "server", "include"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "bt", "esp_ble_mesh", "api", "core", "include"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "bt", "esp_ble_mesh", "api", "models", "include"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "bt", "esp_ble_mesh", "api"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "cbor", "port", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "unity", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "unity", "unity", "src"), @@ -209,6 +225,7 @@ join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "esp_http_client", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "esp_http_server", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "esp_https_ota", "include"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "esp_https_server", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "esp_lcd", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "esp_lcd", "interface"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32", "include", "protobuf-c", "protobuf-c"), @@ -300,7 +317,7 @@ ], LIBS=[ - "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lasio", "-lbt", "-lcbor", "-lunity", "-lcmock", "-lcoap", "-lnghttp", "-lesp-tls", "-lesp_adc_cal", "-lesp_hid", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lesp_lcd", "-lprotobuf-c", "-lprotocomm", "-lmdns", "-lesp_local_ctrl", "-lsdmmc", "-lesp_serial_slave_link", "-lesp_websocket_client", "-lexpat", "-lwear_levelling", "-lfatfs", "-lfreemodbus", "-ljsmn", "-ljson", "-llibsodium", "-lmqtt", "-lopenssl", "-lperfmon", "-lspiffs", "-lulp", "-lwifi_provisioning", "-lbutton", "-lrmaker_common", "-ljson_parser", "-ljson_generator", "-lesp_schedule", "-lesp_rainmaker", "-lqrcode", "-lws2812_led", "-lesp-dsp", "-lesp-sr", "-lesp32-camera", "-lesp_littlefs", "-lfb_gfx", "-lasio", "-lcbor", "-lcmock", "-lunity", "-lcoap", "-lesp_lcd", "-lesp_websocket_client", "-lexpat", "-lfreemodbus", "-ljsmn", "-llibsodium", "-lperfmon", "-lesp_adc_cal", "-lesp_hid", "-lfatfs", "-lwear_levelling", "-lopenssl", "-lesp_rainmaker", "-lesp_local_ctrl", "-lwifi_provisioning", "-lprotocomm", "-lbt", "-lbtdm_app", "-lprotobuf-c", "-lmdns", "-lrmaker_common", "-lmqtt", "-ljson_parser", "-ljson_generator", "-lesp_schedule", "-lqrcode", "-lcat_face_detect", "-lhuman_face_detect", "-lcolor_detect", "-lmfn", "-ldl", "-lwakenet", "-lmultinet", "-lesp_audio_processor", "-lesp_audio_front_end", "-lesp-sr", "-lwakenet", "-lmultinet", "-lesp_audio_processor", "-lesp_audio_front_end", "-ljson", "-lspiffs", "-ldl_lib", "-lc_speech_features", "-lhilexin_wn5", "-lhilexin_wn5X2", "-lhilexin_wn5X3", "-lnihaoxiaozhi_wn5", "-lnihaoxiaozhi_wn5X2", "-lnihaoxiaozhi_wn5X3", "-lnihaoxiaoxin_wn5X3", "-lcustomized_word_wn5", "-lmultinet2_ch", "-lesp_tts_chinese", "-lvoice_set_xiaole", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lphy", "-lrtc", "-lesp_phy", "-lphy", "-lrtc", "-lesp_phy", "-lphy", "-lrtc", "-lxt_hal", "-lm", "-lnewlib", "-lstdc++", "-lpthread", "-lgcc", "-lcxx", "-lapp_trace", "-lgcov", "-lapp_trace", "-lgcov", "-lc" + "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lasio", "-lbt", "-lcbor", "-lunity", "-lcmock", "-lcoap", "-lnghttp", "-lesp-tls", "-lesp_adc_cal", "-lesp_hid", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lesp_https_server", "-lesp_lcd", "-lprotobuf-c", "-lprotocomm", "-lmdns", "-lesp_local_ctrl", "-lsdmmc", "-lesp_serial_slave_link", "-lesp_websocket_client", "-lexpat", "-lwear_levelling", "-lfatfs", "-lfreemodbus", "-ljsmn", "-ljson", "-llibsodium", "-lmqtt", "-lopenssl", "-lperfmon", "-lspiffs", "-lulp", "-lwifi_provisioning", "-lbutton", "-lrmaker_common", "-ljson_parser", "-ljson_generator", "-lesp_schedule", "-lesp_rainmaker", "-lqrcode", "-lws2812_led", "-lesp-dsp", "-lesp-sr", "-lesp32-camera", "-lesp_littlefs", "-lfb_gfx", "-lasio", "-lcbor", "-lcmock", "-lunity", "-lcoap", "-lesp_lcd", "-lesp_websocket_client", "-lexpat", "-lfreemodbus", "-ljsmn", "-llibsodium", "-lperfmon", "-lesp_adc_cal", "-lesp_hid", "-lfatfs", "-lwear_levelling", "-lopenssl", "-lesp_rainmaker", "-lesp_local_ctrl", "-lesp_https_server", "-lwifi_provisioning", "-lprotocomm", "-lbt", "-lbtdm_app", "-lprotobuf-c", "-lmdns", "-lrmaker_common", "-lmqtt", "-ljson_parser", "-ljson_generator", "-lesp_schedule", "-lqrcode", "-lcat_face_detect", "-lhuman_face_detect", "-lcolor_detect", "-lmfn", "-ldl", "-lwakenet", "-lmultinet", "-lesp_audio_processor", "-lesp_audio_front_end", "-lesp-sr", "-lwakenet", "-lmultinet", "-lesp_audio_processor", "-lesp_audio_front_end", "-ljson", "-lspiffs", "-ldl_lib", "-lc_speech_features", "-lhilexin_wn5", "-lhilexin_wn5X2", "-lhilexin_wn5X3", "-lnihaoxiaozhi_wn5", "-lnihaoxiaozhi_wn5X2", "-lnihaoxiaozhi_wn5X3", "-lnihaoxiaoxin_wn5X3", "-lcustomized_word_wn5", "-lmultinet2_ch", "-lesp_tts_chinese", "-lvoice_set_xiaole", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls_2", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls_2", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls_2", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls_2", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls_2", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lphy", "-lrtc", "-lesp_phy", "-lphy", "-lrtc", "-lesp_phy", "-lphy", "-lrtc", "-lxt_hal", "-lm", "-lnewlib", "-lstdc++", "-lpthread", "-lgcc", "-lcxx", "-lapp_trace", "-lgcov", "-lapp_trace", "-lgcov", "-lc" ], CPPDEFINES=[ @@ -309,7 +326,7 @@ "UNITY_INCLUDE_CONFIG_H", "WITH_POSIX", "_GNU_SOURCE", - ("IDF_VER", '\\"v4.4.1-1-gb8050b365e\\"'), + ("IDF_VER", '\\"v4.4.1-405-g6c5fb29c2c\\"'), "ESP_PLATFORM", "_POSIX_READER_WRITER_LOCKS", "ARDUINO_ARCH_ESP32", diff --git a/tools/platformio-build-esp32c3.py b/tools/platformio-build-esp32c3.py index 26a85a4a879..f35c683e5ce 100644 --- a/tools/platformio-build-esp32c3.py +++ b/tools/platformio-build-esp32c3.py @@ -36,6 +36,10 @@ env.Append( ASFLAGS=[ + "-march=rv32imc" + ], + + ASPPFLAGS=[ "-x", "assembler-with-cpp" ], @@ -191,6 +195,18 @@ join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "bt", "common", "btc", "profile", "esp", "blufi", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "bt", "common", "btc", "profile", "esp", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "bt", "host", "bluedroid", "api", "include", "api"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "bt", "esp_ble_mesh", "mesh_common", "include"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "bt", "esp_ble_mesh", "mesh_common", "tinycrypt", "include"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "bt", "esp_ble_mesh", "mesh_core"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "bt", "esp_ble_mesh", "mesh_core", "include"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "bt", "esp_ble_mesh", "mesh_core", "storage"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "bt", "esp_ble_mesh", "btc", "include"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "bt", "esp_ble_mesh", "mesh_models", "common", "include"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "bt", "esp_ble_mesh", "mesh_models", "client", "include"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "bt", "esp_ble_mesh", "mesh_models", "server", "include"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "bt", "esp_ble_mesh", "api", "core", "include"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "bt", "esp_ble_mesh", "api", "models", "include"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "bt", "esp_ble_mesh", "api"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "cbor", "port", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "unity", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "unity", "unity", "src"), @@ -281,6 +297,8 @@ join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "esp-dl", "include", "layer"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "esp-dl", "include", "detect"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "esp-dl", "include", "model_zoo"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "esp32-camera", "driver", "include"), + join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "esp32-camera", "conversions", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", "include", "fb_gfx", "include"), join(FRAMEWORK_DIR, "tools", "sdk", "esp32c3", env.BoardConfig().get("build.arduino.memory_type", "qspi_qspi"), "include"), join(FRAMEWORK_DIR, "cores", env.BoardConfig().get("build.core")) @@ -293,7 +311,7 @@ ], LIBS=[ - "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lriscv", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lasio", "-lbt", "-lcbor", "-lunity", "-lcmock", "-lcoap", "-lnghttp", "-lesp-tls", "-lesp_adc_cal", "-lesp_hid", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lesp_https_server", "-lesp_lcd", "-lprotobuf-c", "-lprotocomm", "-lmdns", "-lesp_local_ctrl", "-lsdmmc", "-lesp_serial_slave_link", "-lesp_websocket_client", "-lexpat", "-lwear_levelling", "-lfatfs", "-lfreemodbus", "-ljsmn", "-ljson", "-llibsodium", "-lmqtt", "-lopenssl", "-lspiffs", "-lwifi_provisioning", "-lbutton", "-lrmaker_common", "-ljson_parser", "-ljson_generator", "-lesp_schedule", "-lesp_rainmaker", "-lqrcode", "-lws2812_led", "-lesp-dsp", "-lesp_littlefs", "-lfb_gfx", "-lasio", "-lcbor", "-lcmock", "-lunity", "-lcoap", "-lesp_lcd", "-lesp_websocket_client", "-lexpat", "-lfreemodbus", "-ljsmn", "-llibsodium", "-lesp_adc_cal", "-lesp_hid", "-lfatfs", "-lwear_levelling", "-lopenssl", "-lspiffs", "-lesp_rainmaker", "-lesp_local_ctrl", "-lesp_https_server", "-lwifi_provisioning", "-lprotocomm", "-lbt", "-lbtdm_app", "-lprotobuf-c", "-lmdns", "-ljson", "-lrmaker_common", "-lmqtt", "-ljson_parser", "-ljson_generator", "-lesp_schedule", "-lqrcode", "-lcat_face_detect", "-lhuman_face_detect", "-lcolor_detect", "-lmfn", "-ldl", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lriscv", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lriscv", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lriscv", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lriscv", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lriscv", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lriscv", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lphy", "-lbtbb", "-lesp_phy", "-lphy", "-lbtbb", "-lesp_phy", "-lphy", "-lbtbb", "-lm", "-lnewlib", "-lstdc++", "-lpthread", "-lgcc", "-lcxx", "-lapp_trace", "-lgcov", "-lapp_trace", "-lgcov", "-lc" + "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lriscv", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lasio", "-lbt", "-lcbor", "-lunity", "-lcmock", "-lcoap", "-lnghttp", "-lesp-tls", "-lesp_adc_cal", "-lesp_hid", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lesp_https_server", "-lesp_lcd", "-lprotobuf-c", "-lprotocomm", "-lmdns", "-lesp_local_ctrl", "-lsdmmc", "-lesp_serial_slave_link", "-lesp_websocket_client", "-lexpat", "-lwear_levelling", "-lfatfs", "-lfreemodbus", "-ljsmn", "-ljson", "-llibsodium", "-lmqtt", "-lopenssl", "-lspiffs", "-lwifi_provisioning", "-lbutton", "-lrmaker_common", "-ljson_parser", "-ljson_generator", "-lesp_schedule", "-lesp_rainmaker", "-lqrcode", "-lws2812_led", "-lesp-dsp", "-lesp32-camera", "-lesp_littlefs", "-lfb_gfx", "-lasio", "-lcbor", "-lcmock", "-lunity", "-lcoap", "-lesp_lcd", "-lesp_websocket_client", "-lexpat", "-lfreemodbus", "-ljsmn", "-llibsodium", "-lesp_adc_cal", "-lesp_hid", "-lfatfs", "-lwear_levelling", "-lopenssl", "-lspiffs", "-lesp_rainmaker", "-lesp_local_ctrl", "-lesp_https_server", "-lwifi_provisioning", "-lprotocomm", "-lbt", "-lbtdm_app", "-lprotobuf-c", "-lmdns", "-ljson", "-lrmaker_common", "-lmqtt", "-ljson_parser", "-ljson_generator", "-lesp_schedule", "-lqrcode", "-lcat_face_detect", "-lhuman_face_detect", "-lcolor_detect", "-lmfn", "-ldl", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lriscv", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lmbedtls_2", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lriscv", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lmbedtls_2", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lriscv", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lmbedtls_2", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lriscv", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lmbedtls_2", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lriscv", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lmbedtls_2", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lriscv", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lmbedtls_2", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lphy", "-lbtbb", "-lesp_phy", "-lphy", "-lbtbb", "-lesp_phy", "-lphy", "-lbtbb", "-lm", "-lnewlib", "-lstdc++", "-lpthread", "-lgcc", "-lcxx", "-lapp_trace", "-lgcov", "-lapp_trace", "-lgcov", "-lc" ], CPPDEFINES=[ @@ -302,7 +320,7 @@ "UNITY_INCLUDE_CONFIG_H", "WITH_POSIX", "_GNU_SOURCE", - ("IDF_VER", '\\"v4.4.1-1-gb8050b365e\\"'), + ("IDF_VER", '\\"v4.4.1-405-g6c5fb29c2c\\"'), "ESP_PLATFORM", "_POSIX_READER_WRITER_LOCKS", "ARDUINO_ARCH_ESP32", diff --git a/tools/platformio-build-esp32s2.py b/tools/platformio-build-esp32s2.py index 7fa190bc51b..895020c4ab9 100644 --- a/tools/platformio-build-esp32s2.py +++ b/tools/platformio-build-esp32s2.py @@ -36,6 +36,10 @@ env.Append( ASFLAGS=[ + "-mlongcalls" + ], + + ASPPFLAGS=[ "-x", "assembler-with-cpp" ], @@ -295,7 +299,7 @@ ], LIBS=[ - "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lasio", "-lcbor", "-lunity", "-lcmock", "-lcoap", "-lnghttp", "-lesp-tls", "-lesp_adc_cal", "-lesp_hid", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lesp_https_server", "-lesp_lcd", "-lprotobuf-c", "-lprotocomm", "-lmdns", "-lesp_local_ctrl", "-lsdmmc", "-lesp_serial_slave_link", "-lesp_websocket_client", "-lexpat", "-lwear_levelling", "-lfatfs", "-lfreemodbus", "-ljsmn", "-ljson", "-llibsodium", "-lmqtt", "-lopenssl", "-lperfmon", "-lspiffs", "-lusb", "-ltouch_element", "-lulp", "-lwifi_provisioning", "-lbutton", "-lrmaker_common", "-ljson_parser", "-ljson_generator", "-lesp_schedule", "-lesp_rainmaker", "-lqrcode", "-lws2812_led", "-lesp-dsp", "-lesp-sr", "-lesp32-camera", "-lesp_littlefs", "-lfb_gfx", "-lasio", "-lcbor", "-lcmock", "-lunity", "-lcoap", "-lesp_lcd", "-lesp_websocket_client", "-lexpat", "-lfreemodbus", "-ljsmn", "-llibsodium", "-lperfmon", "-lusb", "-ltouch_element", "-lesp_adc_cal", "-lesp_hid", "-lfatfs", "-lwear_levelling", "-lopenssl", "-lesp_rainmaker", "-lesp_local_ctrl", "-lesp_https_server", "-lwifi_provisioning", "-lprotocomm", "-lprotobuf-c", "-lmdns", "-lrmaker_common", "-lmqtt", "-ljson_parser", "-ljson_generator", "-lesp_schedule", "-lqrcode", "-larduino_tinyusb", "-lcat_face_detect", "-lhuman_face_detect", "-lcolor_detect", "-lmfn", "-ldl", "-ljson", "-lspiffs", "-lesp_tts_chinese", "-lvoice_set_xiaole", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lphy", "-lesp_phy", "-lphy", "-lesp_phy", "-lphy", "-lxt_hal", "-lm", "-lnewlib", "-lstdc++", "-lpthread", "-lgcc", "-lcxx", "-lapp_trace", "-lgcov", "-lapp_trace", "-lgcov", "-lc" + "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lasio", "-lcbor", "-lunity", "-lcmock", "-lcoap", "-lnghttp", "-lesp-tls", "-lesp_adc_cal", "-lesp_hid", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lesp_https_server", "-lesp_lcd", "-lprotobuf-c", "-lprotocomm", "-lmdns", "-lesp_local_ctrl", "-lsdmmc", "-lesp_serial_slave_link", "-lesp_websocket_client", "-lexpat", "-lwear_levelling", "-lfatfs", "-lfreemodbus", "-ljsmn", "-ljson", "-llibsodium", "-lmqtt", "-lopenssl", "-lperfmon", "-lspiffs", "-lusb", "-ltouch_element", "-lulp", "-lwifi_provisioning", "-lbutton", "-lrmaker_common", "-ljson_parser", "-ljson_generator", "-lesp_schedule", "-lesp_rainmaker", "-lqrcode", "-lws2812_led", "-lesp-dsp", "-lesp-sr", "-lesp32-camera", "-lesp_littlefs", "-lfb_gfx", "-lasio", "-lcbor", "-lcmock", "-lunity", "-lcoap", "-lesp_lcd", "-lesp_websocket_client", "-lexpat", "-lfreemodbus", "-ljsmn", "-llibsodium", "-lperfmon", "-lusb", "-ltouch_element", "-lesp_adc_cal", "-lesp_hid", "-lfatfs", "-lwear_levelling", "-lopenssl", "-lesp_rainmaker", "-lesp_local_ctrl", "-lesp_https_server", "-lwifi_provisioning", "-lprotocomm", "-lprotobuf-c", "-lmdns", "-lrmaker_common", "-lmqtt", "-ljson_parser", "-ljson_generator", "-lesp_schedule", "-lqrcode", "-larduino_tinyusb", "-lcat_face_detect", "-lhuman_face_detect", "-lcolor_detect", "-lmfn", "-ldl", "-ljson", "-lspiffs", "-lesp_tts_chinese", "-lvoice_set_xiaole", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls_2", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls_2", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls_2", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls_2", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls_2", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls_2", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lphy", "-lesp_phy", "-lphy", "-lesp_phy", "-lphy", "-lxt_hal", "-lm", "-lnewlib", "-lstdc++", "-lpthread", "-lgcc", "-lcxx", "-lapp_trace", "-lgcov", "-lapp_trace", "-lgcov", "-lc" ], CPPDEFINES=[ @@ -304,7 +308,7 @@ "UNITY_INCLUDE_CONFIG_H", "WITH_POSIX", "_GNU_SOURCE", - ("IDF_VER", '\\"v4.4.1-1-gb8050b365e\\"'), + ("IDF_VER", '\\"v4.4.1-405-g6c5fb29c2c\\"'), "ESP_PLATFORM", "_POSIX_READER_WRITER_LOCKS", "ARDUINO_ARCH_ESP32", diff --git a/tools/platformio-build-esp32s3.py b/tools/platformio-build-esp32s3.py index ca9d6b78740..0f11237a18d 100644 --- a/tools/platformio-build-esp32s3.py +++ b/tools/platformio-build-esp32s3.py @@ -36,6 +36,10 @@ env.Append( ASFLAGS=[ + "-mlongcalls" + ], + + ASPPFLAGS=[ "-x", "assembler-with-cpp" ], @@ -312,7 +316,7 @@ ], LIBS=[ - "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lasio", "-lbt", "-lcbor", "-lunity", "-lcmock", "-lcoap", "-lnghttp", "-lesp-tls", "-lesp_adc_cal", "-lesp_hid", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lesp_https_server", "-lesp_lcd", "-lprotobuf-c", "-lprotocomm", "-lmdns", "-lesp_local_ctrl", "-lsdmmc", "-lesp_serial_slave_link", "-lesp_websocket_client", "-lexpat", "-lwear_levelling", "-lfatfs", "-lfreemodbus", "-ljsmn", "-ljson", "-llibsodium", "-lmqtt", "-lopenssl", "-lperfmon", "-lspiffs", "-lusb", "-lulp", "-lwifi_provisioning", "-lbutton", "-lrmaker_common", "-ljson_parser", "-ljson_generator", "-lesp_schedule", "-lesp_rainmaker", "-lqrcode", "-lws2812_led", "-lesp-dsp", "-lesp-sr", "-lesp32-camera", "-lesp_littlefs", "-lfb_gfx", "-lasio", "-lcbor", "-lcmock", "-lunity", "-lcoap", "-lesp_lcd", "-lesp_websocket_client", "-lexpat", "-lfreemodbus", "-ljsmn", "-llibsodium", "-lperfmon", "-lusb", "-lesp_adc_cal", "-lesp_hid", "-lfatfs", "-lwear_levelling", "-lopenssl", "-lesp_rainmaker", "-lesp_local_ctrl", "-lesp_https_server", "-lwifi_provisioning", "-lprotocomm", "-lbt", "-lbtdm_app", "-lprotobuf-c", "-lmdns", "-lrmaker_common", "-lmqtt", "-ljson_parser", "-ljson_generator", "-lesp_schedule", "-lqrcode", "-larduino_tinyusb", "-lcat_face_detect", "-lhuman_face_detect", "-lcolor_detect", "-lmfn", "-ldl", "-lwakenet", "-lhufzip", "-lesp_audio_front_end", "-lesp_audio_processor", "-lmultinet", "-lesp-sr", "-lwakenet", "-lhufzip", "-lesp_audio_front_end", "-lesp_audio_processor", "-lmultinet", "-ljson", "-lspiffs", "-ldl_lib", "-lc_speech_features", "-lesp_tts_chinese", "-lvoice_set_xiaole", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lphy", "-lbtbb", "-lesp_phy", "-lphy", "-lbtbb", "-lesp_phy", "-lphy", "-lbtbb", "-lxt_hal", "-lm", "-lnewlib", "-lstdc++", "-lpthread", "-lgcc", "-lcxx", "-lapp_trace", "-lgcov", "-lapp_trace", "-lgcov", "-lc" + "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lasio", "-lbt", "-lcbor", "-lunity", "-lcmock", "-lcoap", "-lnghttp", "-lesp-tls", "-lesp_adc_cal", "-lesp_hid", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lesp_https_server", "-lesp_lcd", "-lprotobuf-c", "-lprotocomm", "-lmdns", "-lesp_local_ctrl", "-lsdmmc", "-lesp_serial_slave_link", "-lesp_websocket_client", "-lexpat", "-lwear_levelling", "-lfatfs", "-lfreemodbus", "-ljsmn", "-ljson", "-llibsodium", "-lmqtt", "-lopenssl", "-lperfmon", "-lspiffs", "-lusb", "-lulp", "-lwifi_provisioning", "-lbutton", "-lrmaker_common", "-ljson_parser", "-ljson_generator", "-lesp_schedule", "-lesp_rainmaker", "-lqrcode", "-lws2812_led", "-lesp-dsp", "-lesp-sr", "-lesp32-camera", "-lesp_littlefs", "-lfb_gfx", "-lasio", "-lcbor", "-lcmock", "-lunity", "-lcoap", "-lesp_lcd", "-lesp_websocket_client", "-lexpat", "-lfreemodbus", "-ljsmn", "-llibsodium", "-lperfmon", "-lusb", "-lesp_adc_cal", "-lesp_hid", "-lfatfs", "-lwear_levelling", "-lopenssl", "-lesp_rainmaker", "-lesp_local_ctrl", "-lesp_https_server", "-lwifi_provisioning", "-lprotocomm", "-lbt", "-lbtdm_app", "-lprotobuf-c", "-lmdns", "-lrmaker_common", "-lmqtt", "-ljson_parser", "-ljson_generator", "-lesp_schedule", "-lqrcode", "-larduino_tinyusb", "-lcat_face_detect", "-lhuman_face_detect", "-lcolor_detect", "-lmfn", "-ldl", "-lwakenet", "-lhufzip", "-lesp_audio_front_end", "-lesp_audio_processor", "-lmultinet", "-lesp-sr", "-lwakenet", "-lhufzip", "-lesp_audio_front_end", "-lesp_audio_processor", "-lmultinet", "-ljson", "-lspiffs", "-ldl_lib", "-lc_speech_features", "-lesp_tts_chinese", "-lvoice_set_xiaole", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls_2", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls_2", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls_2", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls_2", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls_2", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lesp_ringbuf", "-lefuse", "-lesp_ipc", "-ldriver", "-lesp_pm", "-lmbedtls", "-lapp_update", "-lbootloader_support", "-lspi_flash", "-lnvs_flash", "-lpthread", "-lesp_gdbstub", "-lespcoredump", "-lesp_phy", "-lesp_system", "-lesp_rom", "-lhal", "-lvfs", "-lesp_eth", "-ltcpip_adapter", "-lesp_netif", "-lesp_event", "-lwpa_supplicant", "-lesp_wifi", "-lconsole", "-llwip", "-llog", "-lheap", "-lsoc", "-lesp_hw_support", "-lxtensa", "-lesp_common", "-lesp_timer", "-lfreertos", "-lnewlib", "-lcxx", "-lapp_trace", "-lnghttp", "-lesp-tls", "-ltcp_transport", "-lesp_http_client", "-lesp_http_server", "-lesp_https_ota", "-lsdmmc", "-lesp_serial_slave_link", "-lulp", "-lmbedtls_2", "-lmbedcrypto", "-lmbedx509", "-lcoexist", "-lcore", "-lespnow", "-lmesh", "-lnet80211", "-lpp", "-lsmartconfig", "-lwapi", "-lphy", "-lbtbb", "-lesp_phy", "-lphy", "-lbtbb", "-lesp_phy", "-lphy", "-lbtbb", "-lxt_hal", "-lm", "-lnewlib", "-lstdc++", "-lpthread", "-lgcc", "-lcxx", "-lapp_trace", "-lgcov", "-lapp_trace", "-lgcov", "-lc" ], CPPDEFINES=[ @@ -321,7 +325,7 @@ "UNITY_INCLUDE_CONFIG_H", "WITH_POSIX", "_GNU_SOURCE", - ("IDF_VER", '\\"v4.4.1-1-gb8050b365e\\"'), + ("IDF_VER", '\\"v4.4.1-405-g6c5fb29c2c\\"'), "ESP_PLATFORM", "_POSIX_READER_WRITER_LOCKS", "ARDUINO_ARCH_ESP32", diff --git a/tools/sdk/esp32/bin/bootloader_dio_40m.bin b/tools/sdk/esp32/bin/bootloader_dio_40m.bin index cf5faf1d4f0..d3f36c534e5 100644 Binary files a/tools/sdk/esp32/bin/bootloader_dio_40m.bin and b/tools/sdk/esp32/bin/bootloader_dio_40m.bin differ diff --git a/tools/sdk/esp32/bin/bootloader_dio_80m.bin b/tools/sdk/esp32/bin/bootloader_dio_80m.bin index bb67d790066..d9e6620955c 100644 Binary files a/tools/sdk/esp32/bin/bootloader_dio_80m.bin and b/tools/sdk/esp32/bin/bootloader_dio_80m.bin differ diff --git a/tools/sdk/esp32/bin/bootloader_dout_40m.bin b/tools/sdk/esp32/bin/bootloader_dout_40m.bin index cf5faf1d4f0..d3f36c534e5 100644 Binary files a/tools/sdk/esp32/bin/bootloader_dout_40m.bin and b/tools/sdk/esp32/bin/bootloader_dout_40m.bin differ diff --git a/tools/sdk/esp32/bin/bootloader_dout_80m.bin b/tools/sdk/esp32/bin/bootloader_dout_80m.bin index bb67d790066..d9e6620955c 100644 Binary files a/tools/sdk/esp32/bin/bootloader_dout_80m.bin and b/tools/sdk/esp32/bin/bootloader_dout_80m.bin differ diff --git a/tools/sdk/esp32/bin/bootloader_qio_40m.bin b/tools/sdk/esp32/bin/bootloader_qio_40m.bin index 16bfaaee0e8..3b6e924f0fe 100644 Binary files a/tools/sdk/esp32/bin/bootloader_qio_40m.bin and b/tools/sdk/esp32/bin/bootloader_qio_40m.bin differ diff --git a/tools/sdk/esp32/bin/bootloader_qio_80m.bin b/tools/sdk/esp32/bin/bootloader_qio_80m.bin index 47c9ea18c61..15a954573d8 100644 Binary files a/tools/sdk/esp32/bin/bootloader_qio_80m.bin and b/tools/sdk/esp32/bin/bootloader_qio_80m.bin differ diff --git a/tools/sdk/esp32/bin/bootloader_qout_40m.bin b/tools/sdk/esp32/bin/bootloader_qout_40m.bin index d8c72eee953..07874fe249a 100644 Binary files a/tools/sdk/esp32/bin/bootloader_qout_40m.bin and b/tools/sdk/esp32/bin/bootloader_qout_40m.bin differ diff --git a/tools/sdk/esp32/bin/bootloader_qout_80m.bin b/tools/sdk/esp32/bin/bootloader_qout_80m.bin index f2c8b059658..b181d8040fc 100644 Binary files a/tools/sdk/esp32/bin/bootloader_qout_80m.bin and b/tools/sdk/esp32/bin/bootloader_qout_80m.bin differ diff --git a/tools/sdk/esp32/include/bootloader_support/include/bootloader_flash.h b/tools/sdk/esp32/include/bootloader_support/include/bootloader_flash.h index 49e457f372e..90865e234d6 100644 --- a/tools/sdk/esp32/include/bootloader_support/include/bootloader_flash.h +++ b/tools/sdk/esp32/include/bootloader_support/include/bootloader_flash.h @@ -9,6 +9,7 @@ #include /* including in bootloader for error values */ #include "sdkconfig.h" #include "soc/soc_caps.h" +#include "bootloader_flash_override.h" #ifdef __cplusplus extern "C" { @@ -32,20 +33,21 @@ uint32_t bootloader_read_flash_id(void); esp_err_t bootloader_flash_wrap_set(spi_flash_wrap_mode_t mode); #endif +/** + * @brief Startup flow recommended by XMC. Call at startup before any erase/write operation. + * + * @return ESP_OK When startup successfully, otherwise ESP_FAIL (indiciating you should reboot before erase/write). + */ +esp_err_t bootloader_flash_xmc_startup(void); + /** * @brief Unlock Flash write protect. * Please do not call this function in SDK. * * @note This can be overridden because it's attribute weak. */ -esp_err_t bootloader_flash_unlock(void); +esp_err_t IRAM_ATTR __attribute__((weak)) bootloader_flash_unlock(void); -/** - * @brief Startup flow recommended by XMC. Call at startup before any erase/write operation. - * - * @return ESP_OK When startup successfully, otherwise ESP_FAIL (indiciating you should reboot before erase/write). - */ -esp_err_t bootloader_flash_xmc_startup(void); #ifdef __cplusplus } diff --git a/tools/sdk/esp32/include/bootloader_support/include/bootloader_flash_override.h b/tools/sdk/esp32/include/bootloader_support/include/bootloader_flash_override.h new file mode 100644 index 00000000000..ae29f004344 --- /dev/null +++ b/tools/sdk/esp32/include/bootloader_support/include/bootloader_flash_override.h @@ -0,0 +1,101 @@ +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#pragma once + +#include "esp_err.h" +#include "esp_attr.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef unsigned (*bootloader_flash_read_status_fn_t)(void); +typedef void (*bootloader_flash_write_status_fn_t)(unsigned); + +typedef struct __attribute__((packed)) +{ + const char *manufacturer; + uint8_t mfg_id; /* 8-bit JEDEC manufacturer ID */ + uint16_t flash_id; /* 16-bit JEDEC flash chip ID */ + uint16_t id_mask; /* Bits to match on in flash chip ID */ + bootloader_flash_read_status_fn_t read_status_fn; + bootloader_flash_write_status_fn_t write_status_fn; + uint8_t status_qio_bit; +} bootloader_qio_info_t; + +/** + * @brief Read 8 bit status using RDSR command + * + * @return Value of SR1. + */ +unsigned bootloader_read_status_8b_rdsr(void); + +/** + * @brief Read 8 bit status (second byte) using RDSR2 command + * + * @return Value of SR2 + */ +unsigned bootloader_read_status_8b_rdsr2(void); + +/** + * @brief Read 16 bit status using RDSR & RDSR2 (low and high bytes) + * + * @return Value of SR2#SR1. + */ +unsigned bootloader_read_status_16b_rdsr_rdsr2(void); + +/** + * @brief Write 8 bit status using WRSR + */ +void bootloader_write_status_8b_wrsr(unsigned new_status); + +/** + * @brief Write 8 bit status (second byte) using WRSR2. + */ +void bootloader_write_status_8b_wrsr2(unsigned new_status); + +/** + * @brief Write 16 bit status using WRSR, (both write SR1 and SR2) + */ +void bootloader_write_status_16b_wrsr(unsigned new_status); + +/** + * @brief Read 8 bit status of XM25QU64A. + * + * @return Value of 8 bit SR. + */ +unsigned bootloader_read_status_8b_xmc25qu64a(void); + +/** + * @brief Write 8 bit status for XM25QU64A + */ +void bootloader_write_status_8b_xmc25qu64a(unsigned new_status); + +/* Array of known flash chips and data to enable Quad I/O mode + + Manufacturer & flash ID can be tested by running "esptool.py + flash_id" + + If manufacturer ID matches, and flash ID ORed with flash ID mask + matches, enable_qio_mode() will execute "Read Cmd", test if bit + number "QIE Bit" is set, and if not set it will call "Write Cmd" + with this bit set. + + Searching of this table stops when the first match is found. + */ +extern const bootloader_qio_info_t __attribute__((weak)) bootloader_flash_qe_support_list[]; + +/** + * @brief Unlock Flash write protect. + * Please do not call this function in SDK. + * + * @note This can be overridden because it's attribute weak. + */ +esp_err_t IRAM_ATTR __attribute__((weak)) bootloader_flash_unlock(void); + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32/include/bootloader_support/include/esp_app_format.h b/tools/sdk/esp32/include/bootloader_support/include/esp_app_format.h index 64744fdfe5a..ef4f7f4f48f 100644 --- a/tools/sdk/esp32/include/bootloader_support/include/esp_app_format.h +++ b/tools/sdk/esp32/include/bootloader_support/include/esp_app_format.h @@ -55,6 +55,9 @@ typedef enum { ESP_IMAGE_FLASH_SIZE_4MB, /*!< SPI flash size 4 MB */ ESP_IMAGE_FLASH_SIZE_8MB, /*!< SPI flash size 8 MB */ ESP_IMAGE_FLASH_SIZE_16MB, /*!< SPI flash size 16 MB */ + ESP_IMAGE_FLASH_SIZE_32MB, /*!< SPI flash size 32 MB */ + ESP_IMAGE_FLASH_SIZE_64MB, /*!< SPI flash size 64 MB */ + ESP_IMAGE_FLASH_SIZE_128MB, /*!< SPI flash size 128 MB */ ESP_IMAGE_FLASH_SIZE_MAX /*!< SPI flash size MAX */ } esp_image_flash_size_t; diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_ble_api.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_ble_api.h new file mode 100644 index 00000000000..80ab5707dc0 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_ble_api.h @@ -0,0 +1,182 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _ESP_BLE_MESH_BLE_API_H_ +#define _ESP_BLE_MESH_BLE_API_H_ + +#include "esp_ble_mesh_defs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** This enum value is the event of BLE operations */ +typedef enum { + ESP_BLE_MESH_START_BLE_ADVERTISING_COMP_EVT, /*!< Start BLE advertising completion event */ + ESP_BLE_MESH_STOP_BLE_ADVERTISING_COMP_EVT, /*!< Stop BLE advertising completion event */ + ESP_BLE_MESH_START_BLE_SCANNING_COMP_EVT, /*!< Start BLE scanning completion event */ + ESP_BLE_MESH_STOP_BLE_SCANNING_COMP_EVT, /*!< Stop BLE scanning completion event */ + ESP_BLE_MESH_SCAN_BLE_ADVERTISING_PKT_EVT, /*!< Scanning BLE advertising packets event */ + ESP_BLE_MESH_BLE_EVT_MAX, +} esp_ble_mesh_ble_cb_event_t; + +/** BLE operation callback parameters */ +typedef union { + /** + * @brief ESP_BLE_MESH_START_BLE_ADVERTISING_COMP_EVT + */ + struct { + int err_code; /*!< Indicate the result of starting BLE advertising */ + uint8_t index; /*!< Index of the BLE advertising */ + } start_ble_advertising_comp; /*!< Event parameters of ESP_BLE_MESH_START_BLE_ADVERTISING_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_STOP_BLE_ADVERTISING_COMP_EVT + */ + struct { + int err_code; /*!< Indicate the result of stopping BLE advertising */ + uint8_t index; /*!< Index of the BLE advertising */ + } stop_ble_advertising_comp; /*!< Event parameters of ESP_BLE_MESH_STOP_BLE_ADVERTISING_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_START_BLE_SCANNING_COMP_EVT + */ + struct { + int err_code; /*!< Indicate the result of starting BLE scanning */ + } start_ble_scan_comp; /*!< Event parameters of ESP_BLE_MESH_START_BLE_SCANNING_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_STOP_BLE_SCANNING_COMP_EVT + */ + struct { + int err_code; /*!< Indicate the result of stopping BLE scanning */ + } stop_ble_scan_comp; /*!< Event parameters of ESP_BLE_MESH_STOP_BLE_SCANNING_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_SCAN_BLE_ADVERTISING_PKT_EVT + */ + struct { + uint8_t addr[6]; /*!< Device address */ + uint8_t addr_type; /*!< Device address type */ + uint8_t adv_type; /*!< Advertising data type */ + uint8_t *data; /*!< Advertising data */ + uint16_t length; /*!< Advertising data length */ + int8_t rssi; /*!< RSSI of the advertising packet */ + } scan_ble_adv_pkt; /*!< Event parameters of ESP_BLE_MESH_SCAN_BLE_ADVERTISING_PKT_EVT */ +} esp_ble_mesh_ble_cb_param_t; + +/** + * @brief BLE scanning callback function type + * + * @param event: BLE scanning callback event type + * @param param: BLE scanning callback parameter + */ +typedef void (* esp_ble_mesh_ble_cb_t)(esp_ble_mesh_ble_cb_event_t event, + esp_ble_mesh_ble_cb_param_t *param); + +/** + * @brief Register BLE scanning callback. + * + * @param[in] callback: Pointer to the BLE scaning callback function. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_register_ble_callback(esp_ble_mesh_ble_cb_t callback); + +/** Count for sending BLE advertising packet infinitely */ +#define ESP_BLE_MESH_BLE_ADV_INFINITE 0xFFFF + +/*!< This enum value is the priority of BLE advertising packet */ +typedef enum { + ESP_BLE_MESH_BLE_ADV_PRIO_LOW, + ESP_BLE_MESH_BLE_ADV_PRIO_HIGH, +} esp_ble_mesh_ble_adv_priority_t; + +/** Context of BLE advertising parameters. */ +typedef struct { + uint16_t interval; /*!< BLE advertising interval */ + uint8_t adv_type; /*!< BLE advertising type */ + uint8_t own_addr_type; /*!< Own address type */ + uint8_t peer_addr_type; /*!< Peer address type */ + uint8_t peer_addr[BD_ADDR_LEN]; /*!< Peer address */ + uint16_t duration; /*!< Duration is milliseconds */ + uint16_t period; /*!< Period in milliseconds */ + uint16_t count; /*!< Number of advertising duration */ + uint8_t priority:2; /*!< Priority of BLE advertising packet */ +} esp_ble_mesh_ble_adv_param_t; + +/** Context of BLE advertising data. */ +typedef struct { + uint8_t adv_data_len; /*!< Advertising data length */ + uint8_t adv_data[31]; /*!< Advertising data */ + uint8_t scan_rsp_data_len; /*!< Scan response data length */ + uint8_t scan_rsp_data[31]; /*!< Scan response data */ +} esp_ble_mesh_ble_adv_data_t; + +/** + * @brief This function is called to start BLE advertising with the corresponding data + * and parameters while BLE Mesh is working at the same time. + * + * @note 1. When this function is called, the BLE advertising packet will be posted to + * the BLE mesh adv queue in the mesh stack and waited to be sent. + * 2. In the BLE advertising parameters, the "duration" means the time used for + * sending the BLE advertising packet each time, it shall not be smaller than the + * advertising interval. When the packet is sent successfully, it will be posted + * to the adv queue again after the "period" time if the "count" is bigger than 0. + * The "count" means how many durations the packet will be sent after it is sent + * successfully for the first time. And if the "count" is set to 0xFFFF, which + * means the packet will be sent infinitely. + * 3. The "priority" means the priority of BLE advertising packet compared with + * BLE Mesh packets. Currently two options (i.e. low/high) are provided. If the + * "priority" is high, the BLE advertising packet will be posted to the front of + * adv queue. Otherwise it will be posted to the back of adv queue. + * + * @param[in] param: Pointer to the BLE advertising parameters + * @param[in] data: Pointer to the BLE advertising data and scan response data + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_start_ble_advertising(const esp_ble_mesh_ble_adv_param_t *param, + const esp_ble_mesh_ble_adv_data_t *data); + +/** + * @brief This function is called to stop BLE advertising with the corresponding index. + * + * @param[in] index: Index of BLE advertising + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_stop_ble_advertising(uint8_t index); + +/** Context of BLE scanning parameters. */ +typedef struct { + uint32_t duration; /*!< Duration used to scan normal BLE advertising packets */ +} esp_ble_mesh_ble_scan_param_t; + +/** + * @brief This function is called to start scanning normal BLE advertising packets + * and notifying the packets to the application layer. + * + * @param[in] param: Pointer to the BLE scanning parameters + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_start_ble_scanning(esp_ble_mesh_ble_scan_param_t *param); + +/** + * @brief This function is called to stop notifying normal BLE advertising packets + * to the application layer. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_stop_ble_scanning(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _ESP_BLE_MESH_BLE_API_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_common_api.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_common_api.h new file mode 100644 index 00000000000..f7209d8e5fe --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_common_api.h @@ -0,0 +1,49 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _ESP_BLE_MESH_COMMON_API_H_ +#define _ESP_BLE_MESH_COMMON_API_H_ + +#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. + * + * @note After calling this API, the device needs to call esp_ble_mesh_prov_enable() + * to enable provisioning functionality again. + * + * @param[in] prov: Pointer to the device provisioning capabilities. This pointer must + * remain valid during the lifetime of the BLE Mesh device. + * @param[in] comp: Pointer to the device composition data information. This pointer + * must remain valid during the lifetime of the BLE Mesh device. + * + * @return ESP_OK on success or error code otherwise. + * + */ +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_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_local_data_operation_api.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_local_data_operation_api.h new file mode 100644 index 00000000000..80078681267 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_local_data_operation_api.h @@ -0,0 +1,207 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _ESP_BLE_MESH_LOCAL_DATA_OPERATION_API_H_ +#define _ESP_BLE_MESH_LOCAL_DATA_OPERATION_API_H_ + +#include "esp_ble_mesh_defs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Get the model publish period, the unit is ms. + * + * @param[in] model: Model instance pointer. + * + * @return Publish period value on success, 0 or (negative) error code from errno.h on failure. + * + */ +int32_t esp_ble_mesh_get_model_publish_period(esp_ble_mesh_model_t *model); + +/** + * @brief Get the address of the primary element. + * + * @return Address of the primary element on success, or + * ESP_BLE_MESH_ADDR_UNASSIGNED on failure which means the device has not been provisioned. + * + */ +uint16_t esp_ble_mesh_get_primary_element_address(void); + +/** + * @brief Check if the model has subscribed to the given group address. + * Note: E.g., once a status message is received and the destination address + * is a group address, the model uses this API to check if it is successfully subscribed + * to the given group address. + * + * @param[in] model: Pointer to the model. + * @param[in] group_addr: Group address. + * + * @return Pointer to the group address within the Subscription List of the model on success, or + * NULL on failure which means the model has not subscribed to the given group address. + * Note: With the pointer to the group address returned, you can reset the group address + * 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); + +/** + * @brief Find the BLE Mesh element pointer via the element address. + * + * @param[in] element_addr: Element address. + * + * @return Pointer to the element on success, or NULL on failure. + * + */ +esp_ble_mesh_elem_t *esp_ble_mesh_find_element(uint16_t element_addr); + +/** + * @brief Get the number of elements that have been registered. + * + * @return Number of elements. + * + */ +uint8_t esp_ble_mesh_get_element_count(void); + +/** + * @brief Find the Vendor specific model with the given element, + * the company ID and the Vendor Model ID. + * + * @param[in] element: Element to which the model belongs. + * @param[in] company_id: A 16-bit company identifier assigned by the Bluetooth SIG. + * @param[in] model_id: A 16-bit vendor-assigned model identifier. + * + * @return Pointer to the Vendor Model on success, or NULL on failure which means the Vendor Model is not found. + * + */ +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); + +/** + * @brief Find the SIG model with the given element and Model id. + * + * @param[in] element: Element to which the model belongs. + * @param[in] model_id: SIG model identifier. + * + * @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); + +/** + * @brief Get the Composition data which has been registered. + * + * @return Pointer to the Composition data on success, or NULL on failure which means the Composition data is not initialized. + * + */ +const esp_ble_mesh_comp_t *esp_ble_mesh_get_composition_data(void); + +/** + * @brief A local model of node or Provisioner subscribes a group address. + * + * @note This function shall not be invoked before node is provisioned or Provisioner is enabled. + * + * @param[in] element_addr: Unicast address of the element to which the model belongs. + * @param[in] company_id: A 16-bit company identifier. + * @param[in] model_id: A 16-bit model identifier. + * @param[in] group_addr: The group address to be subscribed. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_model_subscribe_group_addr(uint16_t element_addr, uint16_t company_id, + uint16_t model_id, uint16_t group_addr); + +/** + * @brief A local model of node or Provisioner unsubscribes a group address. + * + * @note This function shall not be invoked before node is provisioned or Provisioner is enabled. + * + * @param[in] element_addr: Unicast address of the element to which the model belongs. + * @param[in] company_id: A 16-bit company identifier. + * @param[in] model_id: A 16-bit model identifier. + * @param[in] group_addr: The subscribed group address. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_model_unsubscribe_group_addr(uint16_t element_addr, uint16_t company_id, + uint16_t model_id, uint16_t group_addr); + +/** + * @brief This function is called by Node to get the local NetKey. + * + * @param[in] net_idx: NetKey index. + * + * @return NetKey on success, or NULL on failure. + * + */ +const uint8_t *esp_ble_mesh_node_get_local_net_key(uint16_t net_idx); + +/** + * @brief This function is called by Node to get the local AppKey. + * + * @param[in] app_idx: AppKey index. + * + * @return AppKey on success, or NULL on failure. + * + */ +const uint8_t *esp_ble_mesh_node_get_local_app_key(uint16_t app_idx); + +/** + * @brief This function is called by Node to add a local NetKey. + * + * @param[in] net_key: NetKey to be added. + * @param[in] net_idx: NetKey Index. + * + * @note This function can only be called after the device is provisioned. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_node_add_local_net_key(const uint8_t net_key[16], uint16_t net_idx); + +/** + * @brief This function is called by Node to add a local AppKey. + * + * @param[in] app_key: AppKey to be added. + * @param[in] net_idx: NetKey Index. + * @param[in] app_idx: AppKey Index. + * + * @note The net_idx must be an existing one. + * This function can only be called after the device is provisioned. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_node_add_local_app_key(const uint8_t app_key[16], uint16_t net_idx, uint16_t app_idx); + +/** + * @brief This function is called by Node to bind AppKey to model locally. + * + * @param[in] element_addr: Node local element address + * @param[in] company_id: Node local company id + * @param[in] model_id: Node local model id + * @param[in] app_idx: Node local appkey index + * + * @note If going to bind app_key with local vendor model, the company_id + * shall be set to 0xFFFF. + * This function can only be called after the device is provisioned. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_node_bind_app_key_to_local_model(uint16_t element_addr, uint16_t company_id, + uint16_t model_id, uint16_t app_idx); + +#ifdef __cplusplus +} +#endif + +#endif /* _ESP_BLE_MESH_LOCAL_DATA_OPERATION_API_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_low_power_api.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_low_power_api.h new file mode 100644 index 00000000000..e55c6a71788 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_low_power_api.h @@ -0,0 +1,61 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _ESP_BLE_MESH_LOW_POWER_API_H_ +#define _ESP_BLE_MESH_LOW_POWER_API_H_ + +#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_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_networking_api.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_networking_api.h new file mode 100644 index 00000000000..01af7951382 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_networking_api.h @@ -0,0 +1,648 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _ESP_BLE_MESH_NETWORKING_API_H_ +#define _ESP_BLE_MESH_NETWORKING_API_H_ + +#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); + +/** + * @brief Register BLE Mesh callback for user-defined models' operations. + * This callback can report the following events generated for the user-defined models: + * - Call back the messages received by user-defined client and server models to the + * application layer; + * - If users call esp_ble_mesh_server/client_model_send, this callback notifies the + * application layer of the send_complete event; + * - If user-defined client model sends a message that requires response, and the response + * message is received after the timer expires, the response message will be reported + * to the application layer as published by a peer device; + * - If the user-defined client model fails to receive the response message during a specified + * period of time, a timeout event will be reported to the application layer. + * + * @note The client models (i.e. Config Client model, Health Client model, Generic + * Client models, Sensor Client model, Scene Client model and Lighting Client models) + * that have been realized internally have their specific register functions. + * For example, esp_ble_mesh_register_config_client_callback is the register + * function for Config Client Model. + * + * @param[in] callback: Pointer to the callback function. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_register_custom_model_callback(esp_ble_mesh_model_cb_t callback); + +/** + * @brief Add the message opcode to the beginning of the model message + * before sending or publishing the model message. + * + * @note This API is only used to set the opcode of the message. + * + * @param[in] data: Pointer to the message data. + * @param[in] opcode: The message opcode. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_model_msg_opcode_init(uint8_t *data, uint32_t opcode); + +/** + * @brief Initialize the user-defined client model. All user-defined client models + * shall call this function to initialize the client model internal data. + * Node: Before calling this API, the op_pair_size and op_pair variabled within + * the user_data(defined using esp_ble_mesh_client_t_) of the client model + * need to be initialized. + * + * @param[in] model: BLE Mesh Client model to which the message belongs. + * + * @return ESP_OK on success or error code otherwise. + * + */ +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). + * + * @param[in] model: BLE Mesh Server Model to which the message belongs. + * @param[in] ctx: Message context, includes keys, TTL, etc. + * @param[in] opcode: Message opcode. + * @param[in] length: Message length (exclude the message opcode). + * @param[in] data: Parameters of Access Payload (exclude the message opcode) to be sent. + * + * @return ESP_OK on success or error code otherwise. + * + */ +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); + +/** + * @brief Send client model message (such as model get, set, etc). + * + * @param[in] model: BLE Mesh Client Model to which the message belongs. + * @param[in] ctx: Message context, includes keys, TTL, etc. + * @param[in] opcode: Message opcode. + * @param[in] length: Message length (exclude the message opcode). + * @param[in] data: Parameters of the Access Payload (exclude the message opcode) to be sent. + * @param[in] msg_timeout: Time to get response to the message (in milliseconds). + * @param[in] need_rsp: TRUE if the opcode requires the peer device to reply, FALSE otherwise. + * @param[in] device_role: Role of the device (Node/Provisioner) that sends the message. + * + * @return ESP_OK on success or error code otherwise. + * + */ +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); + +/** + * @brief Send a model publication message. + * + * @note Before calling this function, the user needs to ensure that the model + * publication message (@ref esp_ble_mesh_model_pub_t.msg) contains a valid + * message to be sent. And if users want to update the publishing message, + * this API should be called in ESP_BLE_MESH_MODEL_PUBLISH_UPDATE_EVT + * with the message updated. + * + * + * @param[in] model: Mesh (client) Model publishing the message. + * @param[in] opcode: Message opcode. + * @param[in] length: Message length (exclude the message opcode). + * @param[in] data: Parameters of the Access Payload (exclude the message opcode) to be sent. + * @param[in] device_role: Role of the device (node/provisioner) publishing the message of the type esp_ble_mesh_dev_role_t. + * + * @return ESP_OK on success or error code otherwise. + * + */ +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); + +/** + * @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. + * + * @note All provisioning information in this node will be deleted and the node + * needs to be reprovisioned. The API function esp_ble_mesh_node_prov_enable() + * needs to be called to start a new provisioning procedure. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_node_local_reset(void); + +/** + * @brief This function is called to set the node (provisioned device) name. + * + * @param[in] index: Index of the node in the node queue. + * @param[in] name: Name (end by '\0') to be set for the node. + * + * @note index is obtained from the parameters of ESP_BLE_MESH_PROVISIONER_PROV_COMPLETE_EVT. + * + * @return ESP_OK on success or error code otherwise. + * + */ +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. + * + * @param[in] index: Index of the node in the node queue. + * + * @note index is obtained from the parameters of ESP_BLE_MESH_PROVISIONER_PROV_COMPLETE_EVT. + * + * @return Node name on success, or NULL on failure. + * + */ +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 an invalid value (0xFFFF) on failure. + * + */ +uint16_t esp_ble_mesh_provisioner_get_node_index(const char *name); + +/** + * @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. + * @param[in] app_idx: The app key index. + * + * @note app_key: If set to NULL, app_key will be generated internally. + * net_idx: Should be an existing one. + * app_idx: If it is going to be generated internally, it should be set to + * 0xFFFF, and the new app_idx will be reported via an event. + * + * @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); + +/** + * @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. + * + * @param[in] net_idx: Network key index. + * @param[in] app_idx: Application key index. + * + * @return App key on success, or NULL on failure. + * + */ +const uint8_t *esp_ble_mesh_provisioner_get_local_app_key(uint16_t net_idx, uint16_t app_idx); + +/** + * @brief This function is called by Provisioner to bind own model with proper app key. + * + * @param[in] element_addr: Provisioner local element address + * @param[in] app_idx: Provisioner local appkey index + * @param[in] model_id: Provisioner local model id + * @param[in] company_id: Provisioner local company id + * + * @note company_id: If going to bind app_key with local vendor model, company_id + * should be set to 0xFFFF. + * + * @return ESP_OK on success or error code otherwise. + * + */ +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); + +/** + * @brief This function is called by Provisioner to add local network key. + * + * @param[in] net_key: The network key to be added to the Provisioner local BLE Mesh stack. + * @param[in] net_idx: The network key index. + * + * @note net_key: If set to NULL, net_key will be generated internally. + * net_idx: If it is going to be generated internally, it should be set to + * 0xFFFF, and the new net_idx will be reported via an event. + * + * @return ESP_OK on success or error code otherwise. + * + */ +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. + * + * @param[in] net_idx: Network key index. + * + * @return Network key on success, or NULL on failure. + * + */ +const uint8_t *esp_ble_mesh_provisioner_get_local_net_key(uint16_t net_idx); + +/** + * @brief This function is called by Provisioner to enable or disable receiving + * heartbeat messages. + * + * @note If enabling receiving heartbeat message successfully, the filter will + * be an empty rejectlist by default, which means all heartbeat messages + * received by the Provisioner will be reported to the application layer. + * + * @param[in] enable: Enable or disable receiving heartbeat messages. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_provisioner_recv_heartbeat(bool enable); + +/** + * @brief This function is called by Provisioner to set the heartbeat filter type. + * + * @note 1. If the filter type is not the same with the current value, then all the + * filter entries will be cleaned. + * 2. If the previous type is rejectlist, and changed to acceptlist, then the + * filter will be an empty acceptlist, which means no heartbeat messages + * will be reported. Users need to add SRC or DST into the filter entry, + * then heartbeat messages from the SRC or to the DST will be reported. + * + * @param[in] type: Heartbeat filter type (acceptlist or rejectlist). + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_provisioner_set_heartbeat_filter_type(uint8_t type); + +/** + * @brief This function is called by Provisioner to add or remove a heartbeat filter entry. + * + * @note 1. If the operation is "ADD", the "hb_src" can be set to the SRC (can only be a + * unicast address) of heartbeat messages, and the "hb_dst" can be set to the + * DST (unicast address or group address), at least one of them needs to be set. + * - If only one of them is set, the filter entry will only use the configured + * SRC or DST to filter heartbeat messages. + * - If both of them are set, the SRC and DST will both be used to decide if a + * heartbeat message will be handled. + * - If SRC or DST already exists in some filter entry, then the corresponding + * entry will be cleaned firstly, then a new entry will be allocated to store + * the information. + * 2. If the operation is "REMOVE", the "hb_src" can be set to the SRC (can only be + * a unicast address) of heartbeat messages, and the "hb_dst" can be set to the + * DST (unicast address or group address), at least one of them needs to be set. + * - The filter entry with the same SRC or DST will be removed. + * + * @param[in] op: Add or REMOVE + * @param[in] info: Heartbeat filter entry information, including: + * hb_src - Heartbeat source address; + * hb_dst - Heartbeat destination address; + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_provisioner_set_heartbeat_filter_info(uint8_t op, esp_ble_mesh_heartbeat_filter_info_t *info); + +/** + * @brief This function is called by Provisioner to directly erase the mesh + * information from nvs namespace. + * + * @note This function can be invoked when the mesh stack is not initialized + * or has been de-initialized. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_provisioner_direct_erase_settings(void); + +/** + * @brief This function is called by Provisioner to open a nvs namespace + * for storing mesh information. + * + * @note Before open another nvs namespace, the previously opened nvs + * namespace must be closed firstly. + * + * @param[in] index: Settings index. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_provisioner_open_settings_with_index(uint8_t index); + +/** + * @brief This function is called by Provisioner to open a nvs namespace + * for storing mesh information. + * + * @note Before open another nvs namespace, the previously opened nvs + * namespace must be closed firstly. + * + * @param[in] uid: Settings user id. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_provisioner_open_settings_with_uid(const char *uid); + +/** + * @brief This function is called by Provisioner to close a nvs namespace + * which is opened previously for storing mesh information. + * + * @note 1. Before closing the nvs namespace, it must be open. + * 2. When the function is invoked, the Provisioner functionality + * will be disabled firstly, and: + * a) If the "erase" flag is set to false, the mesh information + * will be cleaned (e.g. removing NetKey, AppKey, nodes, etc) + * from the mesh stack. + * b) If the "erase" flag is set to true, the mesh information + * stored in the nvs namespace will also be erased besides + * been cleaned from the mesh stack. + * 3. If Provisioner tries to work properly again, we can invoke the + * open function to open a new nvs namespace or a previously added + * one, and restore the mesh information from it if not erased. + * 4. The working process shall be as following: + * a) Open settings A + * b) Start to provision and control nodes + * c) Close settings A + * d) Open settings B + * e) Start to provision and control other nodes + * f) Close settings B + * g) ...... + * + * @param[in] index: Settings index. + * @param[in] erase: Indicate if erasing mesh information. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_provisioner_close_settings_with_index(uint8_t index, bool erase); + +/** + * @brief This function is called by Provisioner to close a nvs namespace + * which is opened previously for storing mesh information. + * + * @note 1. Before closing the nvs namespace, it must be open. + * 2. When the function is invoked, the Provisioner functionality + * will be disabled firstly, and: + * a) If the "erase" flag is set to false, the mesh information + * will be cleaned (e.g. removing NetKey, AppKey, nodes, etc) + * from the mesh stack. + * b) If the "erase" flag is set to true, the mesh information + * stored in the nvs namespace will also be erased besides + * been cleaned from the mesh stack. + * 3. If Provisioner tries to work properly again, we can invoke the + * open function to open a new nvs namespace or a previously added + * one, and restore the mesh information from it if not erased. + * 4. The working process shall be as following: + * a) Open settings A + * b) Start to provision and control nodes + * c) Close settings A + * d) Open settings B + * e) Start to provision and control other nodes + * f) Close settings B + * g) ...... + * + * @param[in] uid: Settings user id. + * @param[in] erase: Indicate if erasing mesh information. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_provisioner_close_settings_with_uid(const char *uid, bool erase); + +/** + * @brief This function is called by Provisioner to erase the mesh information + * and settings user id from a nvs namespace. + * + * @note When this function is called, the nvs namespace must not be open. + * This function is used to erase the mesh information and settings + * user id which are not used currently. + * + * @param[in] index: Settings index. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_provisioner_delete_settings_with_index(uint8_t index); + +/** + * @brief This function is called by Provisioner to erase the mesh information + * and settings user id from a nvs namespace. + * + * @note When this function is called, the nvs namespace must not be open. + * This function is used to erase the mesh information and settings + * user id which are not used currently. + * + * @param[in] uid: Settings user id. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_provisioner_delete_settings_with_uid(const char *uid); + +/** + * @brief This function is called by Provisioner to get settings user id. + * + * @param[in] index: Settings index. + * + * @return Setting user id on success or NULL on failure. + * + */ +const char *esp_ble_mesh_provisioner_get_settings_uid(uint8_t index); + +/** + * @brief This function is called by Provisioner to get settings index. + * + * @param[in] uid: Settings user id. + * + * @return Settings index. + * + */ +uint8_t esp_ble_mesh_provisioner_get_settings_index(const char *uid); + +/** + * @brief This function is called by Provisioner to get the number of free + * settings user id. + * + * @return Number of free settings user id. + * + */ +uint8_t esp_ble_mesh_provisioner_get_free_settings_count(void); + +/** + * @brief This function is called to get fast provisioning application key. + * + * @param[in] net_idx: Network key index. + * @param[in] app_idx: Application key index. + * + * @return Application key on success, or NULL on failure. + * + */ +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_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_provisioning_api.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_provisioning_api.h new file mode 100644 index 00000000000..58ad280468f --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_provisioning_api.h @@ -0,0 +1,394 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _ESP_BLE_MESH_PROVISIONING_API_H_ +#define _ESP_BLE_MESH_PROVISIONING_API_H_ + +#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); + +/** + * @brief Register BLE Mesh provisioning 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_prov_callback(esp_ble_mesh_prov_cb_t callback); + +/** + * @brief Check if a device has been provisioned. + * + * @return TRUE if the device is provisioned, FALSE if the device is unprovisioned. + * + */ +bool esp_ble_mesh_node_is_provisioned(void); + +/** + * @brief Enable specific provisioning bearers to get the device ready for provisioning. + * + * @note PB-ADV: send unprovisioned device beacon. + * PB-GATT: send connectable advertising packets. + * + * @param bearers: Bit-wise OR of provisioning bearers. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_node_prov_enable(esp_ble_mesh_prov_bearer_t bearers); + +/** + * @brief Disable specific provisioning bearers to make a device inaccessible for provisioning. + * + * @param bearers: Bit-wise OR of provisioning bearers. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_node_prov_disable(esp_ble_mesh_prov_bearer_t bearers); + +/** + * @brief Unprovisioned device set own oob public key & private key pair. + * + * @note In order to avoid suffering brute-forcing attack (CVE-2020-26559). + * The Bluetooth SIG recommends that potentially vulnerable mesh provisioners + * use an out-of-band mechanism to exchange the public keys. + * So as an unprovisioned device, it should use this function to input + * the Public Key exchanged through the out-of-band mechanism. + * + * @param[in] pub_key_x: Unprovisioned device's Public Key X + * @param[in] pub_key_y: Unprovisioned device's Public Key Y + * @param[in] private_key: Unprovisioned device's Private Key + * + * @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]); + +/** + * @brief Provide provisioning input OOB number. + * + * @note This is intended to be called if the user has received ESP_BLE_MESH_NODE_PROV_INPUT_EVT + * with ESP_BLE_MESH_ENTER_NUMBER as the action. + * + * @param[in] number: Number input by device. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_node_input_number(uint32_t number); + +/** + * @brief Provide provisioning input OOB string. + * + * @note This is intended to be called if the user has received ESP_BLE_MESH_NODE_PROV_INPUT_EVT + * with ESP_BLE_MESH_ENTER_STRING as the action. + * + * @param[in] string: String input by device. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_node_input_string(const char *string); + +/** + * @brief Using this function, an unprovisioned device can set its own device name, + * which will be broadcasted in its advertising data. + * + * @param[in] name: Unprovisioned device name + * + * @note This API applicable to PB-GATT mode only by setting the name to the scan response data, + * it doesn't apply to PB-ADV mode. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_set_unprovisioned_device_name(const char *name); + +/** + * @brief Provisioner inputs unprovisioned device's oob public key. + * + * @note In order to avoid suffering brute-forcing attack (CVE-2020-26559). + * The Bluetooth SIG recommends that potentially vulnerable mesh provisioners + * use an out-of-band mechanism to exchange the public keys. + * + * @param[in] link_idx: The provisioning link index + * @param[in] pub_key_x: Unprovisioned device's Public Key X + * @param[in] pub_key_y: Unprovisioned device's Public Key Y + * + * @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]); + +/** + * @brief Provide provisioning input OOB string. + * + * This is intended to be called after the esp_ble_mesh_prov_t prov_input_num + * callback has been called with ESP_BLE_MESH_ENTER_STRING as the action. + * + * @param[in] string: String input by Provisioner. + * @param[in] link_idx: The provisioning link index. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_provisioner_input_string(const char *string, uint8_t link_idx); + +/** + * @brief Provide provisioning input OOB number. + * + * This is intended to be called after the esp_ble_mesh_prov_t prov_input_num + * callback has been called with ESP_BLE_MESH_ENTER_NUMBER as the action. + * + * @param[in] number: Number input by Provisioner. + * @param[in] link_idx: The provisioning link index. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_provisioner_input_number(uint32_t number, uint8_t link_idx); + +/** + * @brief Enable one or more provisioning bearers. + * + * @param[in] bearers: Bit-wise OR of provisioning bearers. + * + * @note PB-ADV: Enable BLE scan. + * PB-GATT: Initialize corresponding BLE Mesh Proxy info. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_provisioner_prov_enable(esp_ble_mesh_prov_bearer_t bearers); + +/** + * @brief Disable one or more provisioning bearers. + * + * @param[in] bearers: Bit-wise OR of provisioning bearers. + * + * @note PB-ADV: Disable BLE scan. + * PB-GATT: Break any existing BLE Mesh Provisioning connections. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_provisioner_prov_disable(esp_ble_mesh_prov_bearer_t bearers); + +/** + * @brief Add unprovisioned device info to the unprov_dev queue. + * + * @param[in] add_dev: Pointer to a struct containing the device information + * @param[in] flags: Flags indicate several operations on the device information + * - Remove device information from queue after device has been provisioned (BIT0) + * - Start provisioning immediately after device is added to queue (BIT1) + * - Device can be removed if device queue is full (BIT2) + * + * @return ESP_OK on success or error code otherwise. + * + * @note: 1. Currently address type only supports public address and static random address. + * 2. If device UUID and/or device address as well as address type already exist in the + * device queue, but the bearer is different from the existing one, add operation + * will also be successful and it will update the provision bearer supported by + * the device. + * 3. For example, if the Provisioner wants to add an unprovisioned device info before + * receiving its unprovisioned device beacon or Mesh Provisioning advertising packets, + * the Provisioner can use this API to add the device info with each one or both of + * device UUID and device address added. When the Provisioner gets the device's + * advertising packets, it will start provisioning the device internally. + * - In this situation, the Provisioner can set bearers with each one or both of + * ESP_BLE_MESH_PROV_ADV and ESP_BLE_MESH_PROV_GATT enabled, and cannot set flags + * with ADD_DEV_START_PROV_NOW_FLAG enabled. + * 4. Another example is when the Provisioner receives the unprovisioned device's beacon or + * Mesh Provisioning advertising packets, the advertising packets will be reported on to + * the application layer using the callback registered by the function + * esp_ble_mesh_register_prov_callback. And in the callback, the Provisioner + * can call this API to start provisioning the device. + * - If the Provisioner uses PB-ADV to provision, either one or both of device UUID and + * device address can be added, bearers shall be set with ESP_BLE_MESH_PROV_ADV + * enabled and the flags shall be set with ADD_DEV_START_PROV_NOW_FLAG enabled. + * - If the Provisioner uses PB-GATT to provision, both the device UUID and device + * address need to be added, bearers shall be set with ESP_BLE_MESH_PROV_GATT enabled, + * and the flags shall be set with ADD_DEV_START_PROV_NOW_FLAG enabled. + * - If the Provisioner just wants to store the unprovisioned device info when receiving + * its advertising packets and start to provision it the next time (e.g. after receiving + * its advertising packets again), then it can add the device info with either one or both + * of device UUID and device address included. Bearers can be set with either one or both + * of ESP_BLE_MESH_PROV_ADV and ESP_BLE_MESH_PROV_GATT enabled (recommend to enable the + * bearer which will receive its advertising packets, because if the other bearer is + * enabled, the Provisioner is not aware if the device supports the bearer), and flags + * cannot be set with ADD_DEV_START_PROV_NOW_FLAG enabled. + * - Note: ESP_BLE_MESH_PROV_ADV, ESP_BLE_MESH_PROV_GATT and ADD_DEV_START_PROV_NOW_FLAG + * can not be enabled at the same time. + * + */ +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); + +/** @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, and reset current provisioning link with the device. + * + * @note If the device is in the queue, remove it from the queue; if the device is + * being provisioned, terminate the provisioning procedure. Either one of the + * device address or device UUID can be used as input. + * + * @param[in] del_dev: Pointer to a struct containing the device information. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_provisioner_delete_dev(esp_ble_mesh_device_delete_t *del_dev); + +/** + * @brief Callback for Provisioner that received advertising packets from unprovisioned devices which are + * not in the unprovisioned device queue. + * + * Report on the unprovisioned device beacon and mesh provisioning service adv data to application. + * + * @param[in] addr: Pointer to the unprovisioned device address. + * @param[in] addr_type: Unprovisioned device address type. + * @param[in] adv_type: Adv packet type(ADV_IND or ADV_NONCONN_IND). + * @param[in] dev_uuid: Unprovisioned device UUID pointer. + * @param[in] oob_info: OOB information of the unprovisioned device. + * @param[in] bearer: Adv packet received from PB-GATT or PB-ADV 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 + * to be compared before starting to provision. + * + * @param[in] match_val: Value to be compared with the part of the device UUID. + * @param[in] match_len: Length of the compared match value. + * @param[in] offset: Offset of the device UUID to be compared (based on zero). + * @param[in] prov_after_match: Flag used to indicate whether provisioner should start to provision + * the device immediately if the part of the UUID matches. + * + * @return ESP_OK on success or error code otherwise. + * + */ +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); + +/** + * @brief This function is called by Provisioner to set provisioning data information + * before starting to provision. + * + * @param[in] prov_data_info: Pointer to a struct containing net_idx or flags or iv_index. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_provisioner_set_prov_data_info(esp_ble_mesh_prov_data_info_t *prov_data_info); + +/** + * @brief This function is called by Provisioner to set static oob value used for provisioning. + * + * @note The Bluetooth SIG recommends that mesh implementations enforce a randomly selected + * AuthValue using all of the available bits, where permitted by the implementation. + * A large entropy helps ensure that a brute-force of the AuthValue, even a static + * AuthValue, cannot normally be completed in a reasonable time (CVE-2020-26557). + * + * AuthValues selected using a cryptographically secure random or pseudorandom number + * generator and having the maximum permitted entropy (128-bits) will be most difficult + * to brute-force. AuthValues with reduced entropy or generated in a predictable manner + * will not grant the same level of protection against this vulnerability. Selecting a + * new AuthValue with each provisioning attempt can also make it more difficult to launch + * a brute-force attack by requiring the attacker to restart the search with each + * provisioning attempt (CVE-2020-26556). + * + * @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. + * + * @param[in] fast_prov_info: Pointer to a struct containing unicast address range, net_idx, etc. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_set_fast_prov_info(esp_ble_mesh_fast_prov_info_t *fast_prov_info); + +/** + * @brief This function is called to start/suspend/exit fast provisioning. + * + * @param[in] action: fast provisioning action (i.e. enter, suspend, exit). + * + * @return ESP_OK on success or error code otherwise. + * + */ +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_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_proxy_api.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_proxy_api.h new file mode 100644 index 00000000000..c29e284481e --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_proxy_api.h @@ -0,0 +1,118 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _ESP_BLE_MESH_PROXY_API_H_ +#define _ESP_BLE_MESH_PROXY_API_H_ + +#include "esp_ble_mesh_defs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Enable advertising with Node Identity. + * + * @note This API requires that GATT Proxy support be enabled. Once called, + * each subnet starts advertising using Node Identity for the next 60 + * seconds, and after 60s Network ID will be advertised. + * Under normal conditions, the BLE Mesh Proxy Node Identity and + * Network ID advertising will be enabled automatically by BLE Mesh + * stack after the device is provisioned. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_proxy_identity_enable(void); + +/** + * @brief Enable BLE Mesh GATT Proxy Service. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_proxy_gatt_enable(void); + +/** + * @brief Disconnect the BLE Mesh GATT Proxy connection if there is any, and + * disable the BLE Mesh GATT Proxy Service. + * + * @return ESP_OK on success or error code otherwise. + * + */ +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_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/api/esp_ble_mesh_defs.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/api/esp_ble_mesh_defs.h new file mode 100644 index 00000000000..3fff33363be --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/api/esp_ble_mesh_defs.h @@ -0,0 +1,2275 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _ESP_BLE_MESH_DEFS_H_ +#define _ESP_BLE_MESH_DEFS_H_ + +#include + +#include "mesh_config.h" +#include "mesh_common.h" +#include "proxy_server.h" +#include "provisioner_main.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*!< The maximum length of a BLE Mesh message, including Opcode, Payload and TransMIC */ +#define ESP_BLE_MESH_SDU_MAX_LEN 384 + +/*!< Length of a short Mesh MIC. */ +#define ESP_BLE_MESH_MIC_SHORT 4 + +/*!< Length of a long Mesh MIC. */ +#define ESP_BLE_MESH_MIC_LONG 8 + +/*!< The maximum length of a BLE Mesh provisioned node name */ +#define ESP_BLE_MESH_NODE_NAME_MAX_LEN 31 + +/*!< The maximum length of a BLE Mesh unprovisioned device name */ +#define ESP_BLE_MESH_DEVICE_NAME_MAX_LEN DEVICE_NAME_SIZE + +/*!< The maximum length of settings user id */ +#define ESP_BLE_MESH_SETTINGS_UID_SIZE 20 + +/*!< Invalid settings index */ +#define ESP_BLE_MESH_INVALID_SETTINGS_IDX 0xFF + +/*!< Define the BLE Mesh octet 16 bytes size */ +#define ESP_BLE_MESH_OCTET16_LEN 16 +typedef uint8_t esp_ble_mesh_octet16_t[ESP_BLE_MESH_OCTET16_LEN]; + +/*!< Define the BLE Mesh octet 8 bytes size */ +#define ESP_BLE_MESH_OCTET8_LEN 8 +typedef uint8_t esp_ble_mesh_octet8_t[ESP_BLE_MESH_OCTET8_LEN]; + +/*!< Invalid Company ID */ +#define ESP_BLE_MESH_CID_NVAL 0xFFFF + +/*!< Special TTL value to request using configured default TTL */ +#define ESP_BLE_MESH_TTL_DEFAULT 0xFF + +/*!< Maximum allowed TTL value */ +#define ESP_BLE_MESH_TTL_MAX 0x7F + +#define ESP_BLE_MESH_ADDR_UNASSIGNED 0x0000 +#define ESP_BLE_MESH_ADDR_ALL_NODES 0xFFFF +#define ESP_BLE_MESH_ADDR_PROXIES 0xFFFC +#define ESP_BLE_MESH_ADDR_FRIENDS 0xFFFD +#define ESP_BLE_MESH_ADDR_RELAYS 0xFFFE + +#define ESP_BLE_MESH_KEY_UNUSED 0xFFFF +#define ESP_BLE_MESH_KEY_DEV 0xFFFE + +#define ESP_BLE_MESH_KEY_PRIMARY 0x0000 +#define ESP_BLE_MESH_KEY_ANY 0xFFFF + +/*!< Primary Network Key index */ +#define ESP_BLE_MESH_NET_PRIMARY 0x000 + +/*!< Relay state value */ +#define ESP_BLE_MESH_RELAY_DISABLED 0x00 +#define ESP_BLE_MESH_RELAY_ENABLED 0x01 +#define ESP_BLE_MESH_RELAY_NOT_SUPPORTED 0x02 + +/*!< Beacon state value */ +#define ESP_BLE_MESH_BEACON_DISABLED 0x00 +#define ESP_BLE_MESH_BEACON_ENABLED 0x01 + +/*!< GATT Proxy state value */ +#define ESP_BLE_MESH_GATT_PROXY_DISABLED 0x00 +#define ESP_BLE_MESH_GATT_PROXY_ENABLED 0x01 +#define ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED 0x02 + +/*!< Friend state value */ +#define ESP_BLE_MESH_FRIEND_DISABLED 0x00 +#define ESP_BLE_MESH_FRIEND_ENABLED 0x01 +#define ESP_BLE_MESH_FRIEND_NOT_SUPPORTED 0x02 + +/*!< Node identity state value */ +#define ESP_BLE_MESH_NODE_IDENTITY_STOPPED 0x00 +#define ESP_BLE_MESH_NODE_IDENTITY_RUNNING 0x01 +#define ESP_BLE_MESH_NODE_IDENTITY_NOT_SUPPORTED 0x02 + +/*!< Supported features */ +#define ESP_BLE_MESH_FEATURE_RELAY BIT(0) +#define ESP_BLE_MESH_FEATURE_PROXY BIT(1) +#define ESP_BLE_MESH_FEATURE_FRIEND BIT(2) +#define ESP_BLE_MESH_FEATURE_LOW_POWER BIT(3) +#define ESP_BLE_MESH_FEATURE_ALL_SUPPORTED (ESP_BLE_MESH_FEATURE_RELAY | \ + ESP_BLE_MESH_FEATURE_PROXY | \ + ESP_BLE_MESH_FEATURE_FRIEND | \ + ESP_BLE_MESH_FEATURE_LOW_POWER) + +#define ESP_BLE_MESH_ADDR_IS_UNICAST(addr) ((addr) && (addr) < 0x8000) +#define ESP_BLE_MESH_ADDR_IS_GROUP(addr) ((addr) >= 0xC000 && (addr) <= 0xFF00) +#define ESP_BLE_MESH_ADDR_IS_VIRTUAL(addr) ((addr) >= 0x8000 && (addr) < 0xC000) +#define ESP_BLE_MESH_ADDR_IS_RFU(addr) ((addr) >= 0xFF00 && (addr) <= 0xFFFB) + +#define ESP_BLE_MESH_INVALID_NODE_INDEX 0xFFFF + +/** @def ESP_BLE_MESH_TRANSMIT + * + * @brief Encode transmission count & interval steps. + * + * @note For example, ESP_BLE_MESH_TRANSMIT(2, 20) means that the message + * will be sent about 90ms(count is 3, step is 1, interval is 30 ms + * which includes 10ms of advertising interval random delay). + * + * @param count Number of retransmissions (first transmission is excluded). + * @param int_ms Interval steps in milliseconds. Must be greater than 0 + * and a multiple of 10. + * + * @return BLE Mesh transmit value that can be used e.g. for the default + * values of the Configuration Model data. + */ +#define ESP_BLE_MESH_TRANSMIT(count, int_ms) ((count) | (((int_ms / 10) - 1) << 3)) + +/** @def ESP_BLE_MESH_GET_TRANSMIT_COUNT + * + * @brief Decode transmit count from a transmit value. + * + * @param transmit Encoded transmit count & interval value. + * + * @return Transmission count (actual transmissions equal to N + 1). + */ +#define ESP_BLE_MESH_GET_TRANSMIT_COUNT(transmit) (((transmit) & (uint8_t)BIT_MASK(3))) + +/** @def ESP_BLE_MESH_GET_TRANSMIT_INTERVAL + * + * @brief Decode transmit interval from a transmit value. + * + * @param transmit Encoded transmit count & interval value. + * + * @return Transmission interval in milliseconds. + */ +#define ESP_BLE_MESH_GET_TRANSMIT_INTERVAL(transmit) ((((transmit) >> 3) + 1) * 10) + +/** @def ESP_BLE_MESH_PUBLISH_TRANSMIT + * + * @brief Encode Publish Retransmit count & interval steps. + * + * @param count Number of retransmissions (first transmission is excluded). + * @param int_ms Interval steps in milliseconds. Must be greater than 0 + * and a multiple of 50. + * + * @return BLE Mesh transmit value that can be used e.g. for the default + * values of the Configuration Model data. + */ +#define ESP_BLE_MESH_PUBLISH_TRANSMIT(count, int_ms) ESP_BLE_MESH_TRANSMIT(count, (int_ms) / 5) + +/** @def ESP_BLE_MESH_GET_PUBLISH_TRANSMIT_COUNT + * + * @brief Decode Publish Retransmit count from a given value. + * + * @param transmit Encoded Publish Retransmit count & interval value. + * + * @return Retransmission count (actual transmissions equal to N + 1). + */ +#define ESP_BLE_MESH_GET_PUBLISH_TRANSMIT_COUNT(transmit) ESP_BLE_MESH_GET_TRANSMIT_COUNT(transmit) + +/** @def ESP_BLE_MESH_GET_PUBLISH_TRANSMIT_INTERVAL + * + * @brief Decode Publish Retransmit interval from a given value. + * + * @param transmit Encoded Publish Retransmit count & interval value. + * + * @return Transmission interval in milliseconds. + */ +#define ESP_BLE_MESH_GET_PUBLISH_TRANSMIT_INTERVAL(transmit) ((((transmit) >> 3) + 1) * 50) + +/*!< Callbacks which are not needed to be initialized by users (set with 0 and will be initialized internally) */ +typedef uint32_t esp_ble_mesh_cb_t; + +typedef enum { + ESP_BLE_MESH_TYPE_PROV_CB, + ESP_BLE_MESH_TYPE_OUTPUT_NUM_CB, + ESP_BLE_MESH_TYPE_OUTPUT_STR_CB, + ESP_BLE_MESH_TYPE_INTPUT_CB, + ESP_BLE_MESH_TYPE_LINK_OPEN_CB, + ESP_BLE_MESH_TYPE_LINK_CLOSE_CB, + ESP_BLE_MESH_TYPE_COMPLETE_CB, + ESP_BLE_MESH_TYPE_RESET_CB, +} esp_ble_mesh_cb_type_t; + +/*!< This enum value is provisioning authentication oob method */ +typedef enum { + ESP_BLE_MESH_NO_OOB, + ESP_BLE_MESH_STATIC_OOB, + ESP_BLE_MESH_OUTPUT_OOB, + ESP_BLE_MESH_INPUT_OOB, +} esp_ble_mesh_oob_method_t; + +/*!< This enum value is associated with bt_mesh_output_action_t in mesh_main.h */ +typedef enum { + ESP_BLE_MESH_NO_OUTPUT = 0, + ESP_BLE_MESH_BLINK = BIT(0), + ESP_BLE_MESH_BEEP = BIT(1), + ESP_BLE_MESH_VIBRATE = BIT(2), + ESP_BLE_MESH_DISPLAY_NUMBER = BIT(3), + ESP_BLE_MESH_DISPLAY_STRING = BIT(4), +} esp_ble_mesh_output_action_t; + +/*!< This enum value is associated with bt_mesh_input_action_t in mesh_main.h */ +typedef enum { + ESP_BLE_MESH_NO_INPUT = 0, + ESP_BLE_MESH_PUSH = BIT(0), + ESP_BLE_MESH_TWIST = BIT(1), + ESP_BLE_MESH_ENTER_NUMBER = BIT(2), + ESP_BLE_MESH_ENTER_STRING = BIT(3), +} esp_ble_mesh_input_action_t; + +/*!< This enum value is associated with bt_mesh_prov_bearer_t in mesh_main.h */ +typedef enum { + ESP_BLE_MESH_PROV_ADV = BIT(0), + ESP_BLE_MESH_PROV_GATT = BIT(1), +} esp_ble_mesh_prov_bearer_t; + +/*!< This enum value is associated with bt_mesh_prov_oob_info_t in mesh_main.h */ +typedef enum { + ESP_BLE_MESH_PROV_OOB_OTHER = BIT(0), + ESP_BLE_MESH_PROV_OOB_URI = BIT(1), + ESP_BLE_MESH_PROV_OOB_2D_CODE = BIT(2), + ESP_BLE_MESH_PROV_OOB_BAR_CODE = BIT(3), + ESP_BLE_MESH_PROV_OOB_NFC = BIT(4), + ESP_BLE_MESH_PROV_OOB_NUMBER = BIT(5), + ESP_BLE_MESH_PROV_OOB_STRING = BIT(6), + /* 7 - 10 are reserved */ + ESP_BLE_MESH_PROV_OOB_ON_BOX = BIT(11), + ESP_BLE_MESH_PROV_OOB_IN_BOX = BIT(12), + ESP_BLE_MESH_PROV_OOB_ON_PAPER = BIT(13), + ESP_BLE_MESH_PROV_OOB_IN_MANUAL = BIT(14), + ESP_BLE_MESH_PROV_OOB_ON_DEV = BIT(15), +} esp_ble_mesh_prov_oob_info_t; + +/*!< Maximum length of value used by Static OOB authentication */ +#define ESP_BLE_MESH_PROV_STATIC_OOB_MAX_LEN 16 + +/*!< Maximum length of string used by Output OOB authentication */ +#define ESP_BLE_MESH_PROV_OUTPUT_OOB_MAX_LEN 8 + +/*!< Maximum length of string used by Output OOB authentication */ +#define ESP_BLE_MESH_PROV_INPUT_OOB_MAX_LEN 8 + +/*!< Macros used to define message opcode */ +#define ESP_BLE_MESH_MODEL_OP_1(b0) (b0) +#define ESP_BLE_MESH_MODEL_OP_2(b0, b1) (((b0) << 8) | (b1)) +#define ESP_BLE_MESH_MODEL_OP_3(b0, cid) ((((b0) << 16) | 0xC00000) | (cid)) + +/*!< This macro is associated with BLE_MESH_MODEL_CB in mesh_access.h */ +#define ESP_BLE_MESH_SIG_MODEL(_id, _op, _pub, _user_data) \ +{ \ + .model_id = (_id), \ + .op = _op, \ + .keys = { [0 ... (CONFIG_BLE_MESH_MODEL_KEY_COUNT - 1)] = \ + ESP_BLE_MESH_KEY_UNUSED }, \ + .pub = _pub, \ + .groups = { [0 ... (CONFIG_BLE_MESH_MODEL_GROUP_COUNT - 1)] = \ + ESP_BLE_MESH_ADDR_UNASSIGNED }, \ + .user_data = _user_data, \ +} + +/*!< This macro is associated with BLE_MESH_MODEL_VND_CB in mesh_access.h */ +#define ESP_BLE_MESH_VENDOR_MODEL(_company, _id, _op, _pub, _user_data) \ +{ \ + .vnd.company_id = (_company), \ + .vnd.model_id = (_id), \ + .op = _op, \ + .pub = _pub, \ + .keys = { [0 ... (CONFIG_BLE_MESH_MODEL_KEY_COUNT - 1)] = \ + ESP_BLE_MESH_KEY_UNUSED }, \ + .groups = { [0 ... (CONFIG_BLE_MESH_MODEL_GROUP_COUNT - 1)] = \ + ESP_BLE_MESH_ADDR_UNASSIGNED }, \ + .user_data = _user_data, \ +} + +/** @brief Helper to define a BLE Mesh element within an array. + * + * In case the element has no SIG or Vendor models, the helper + * macro ESP_BLE_MESH_MODEL_NONE can be given instead. + * + * @note This macro is associated with BLE_MESH_ELEM in mesh_access.h + * + * @param _loc Location Descriptor. + * @param _mods Array of SIG models. + * @param _vnd_mods Array of vendor models. + */ +#define ESP_BLE_MESH_ELEMENT(_loc, _mods, _vnd_mods) \ +{ \ + .location = (_loc), \ + .sig_model_count = ARRAY_SIZE(_mods), \ + .sig_models = (_mods), \ + .vnd_model_count = ARRAY_SIZE(_vnd_mods), \ + .vnd_models = (_vnd_mods), \ +} + +#define ESP_BLE_MESH_PROV(uuid, sta_val, sta_val_len, out_size, out_act, in_size, in_act) { \ + .uuid = uuid, \ + .static_val = sta_val, \ + .static_val_len = sta_val_len, \ + .output_size = out_size, \ + .output_action = out_act, \ + .input_size = in_size, \ + .input_action = in_act, \ +} + +typedef uint8_t UINT8; +typedef uint16_t UINT16; +typedef uint32_t UINT32; +typedef uint64_t UINT64; + +#define BT_OCTET32_LEN 32 +typedef UINT8 BT_OCTET32[BT_OCTET32_LEN]; /* octet array: size 32 */ + + +#ifndef BD_ADDR_LEN +#define BD_ADDR_LEN 6 +typedef uint8_t BD_ADDR[BD_ADDR_LEN]; +#endif + +typedef uint8_t esp_ble_mesh_bd_addr_t[BD_ADDR_LEN]; + +#define ESP_BLE_MESH_ADDR_TYPE_PUBLIC 0x00 +#define ESP_BLE_MESH_ADDR_TYPE_RANDOM 0x01 +#define ESP_BLE_MESH_ADDR_TYPE_RPA_PUBLIC 0x02 +#define ESP_BLE_MESH_ADDR_TYPE_RPA_RANDOM 0x03 +/// BLE device address type +typedef uint8_t esp_ble_mesh_addr_type_t; + +/** BLE Mesh deinit parameters */ +typedef struct { + bool erase_flash; /*!< Indicate if erasing flash when deinit mesh stack */ +} esp_ble_mesh_deinit_param_t; + +typedef struct esp_ble_mesh_model esp_ble_mesh_model_t; + +/** Abstraction that describes a BLE Mesh Element. + * This structure is associated with struct bt_mesh_elem in mesh_access.h + */ +typedef struct { + /** Element Address, assigned during provisioning. */ + uint16_t element_addr; + + /** Location Descriptor (GATT Bluetooth Namespace Descriptors) */ + const uint16_t location; + + const uint8_t sig_model_count; /*!< SIG Model count */ + const uint8_t vnd_model_count; /*!< Vendor Model count */ + + esp_ble_mesh_model_t *sig_models; /*!< SIG Models */ + esp_ble_mesh_model_t *vnd_models; /*!< Vendor Models */ +} esp_ble_mesh_elem_t; + +/** Abstraction that describes a model publication context. + * This structure is associated with struct bt_mesh_model_pub in mesh_access.h + */ +typedef struct { + /** Pointer to the model to which the context belongs. Initialized by the stack. */ + esp_ble_mesh_model_t *model; + + uint16_t publish_addr; /*!< Publish Address. */ + uint16_t app_idx:12, /*!< Publish AppKey Index. */ + cred:1, /*!< Friendship Credentials Flag. */ + send_rel:1; /*!< Force reliable sending (segment acks) */ + + uint8_t ttl; /*!< Publish Time to Live. */ + uint8_t retransmit; /*!< Retransmit Count & Interval Steps. */ + + uint8_t period; /*!< Publish Period. */ + uint8_t period_div:4, /*!< Divisor for the Period. */ + fast_period:1, /*!< Use FastPeriodDivisor */ + count:3; /*!< Retransmissions left. */ + + uint32_t period_start; /*!< Start of the current period. */ + + /** @brief Publication buffer, containing the publication message. + * + * This will get correctly created when the publication context + * has been defined using the ESP_BLE_MESH_MODEL_PUB_DEFINE macro. + * + * ESP_BLE_MESH_MODEL_PUB_DEFINE(name, size); + */ + struct net_buf_simple *msg; + + /** Callback used to update publish message. Initialized by the stack. */ + esp_ble_mesh_cb_t update; + + /** Publish Period Timer. Initialized by the stack. */ + struct k_delayed_work timer; + + /** Role of the device that is going to publish messages */ + uint8_t dev_role; +} esp_ble_mesh_model_pub_t; + +/** @def ESP_BLE_MESH_MODEL_PUB_DEFINE + * + * Define a model publication context. + * + * @param _name Variable name given to the context. + * @param _msg_len Length of the publication message. + * @param _role Role of the device which contains the model. + */ +#define ESP_BLE_MESH_MODEL_PUB_DEFINE(_name, _msg_len, _role) \ + NET_BUF_SIMPLE_DEFINE_STATIC(bt_mesh_pub_msg_##_name, _msg_len); \ + static esp_ble_mesh_model_pub_t _name = { \ + .update = (uint32_t)NULL, \ + .msg = &bt_mesh_pub_msg_##_name, \ + .dev_role = _role, \ + } + +/** @def ESP_BLE_MESH_MODEL_OP + * + * Define a model operation context. + * + * @param _opcode Message opcode. + * @param _min_len Message minimum length. + */ +#define ESP_BLE_MESH_MODEL_OP(_opcode, _min_len) \ +{ \ + .opcode = _opcode, \ + .min_len = _min_len, \ + .param_cb = (uint32_t)NULL, \ +} + +/** Abstraction that describes a model operation context. + * This structure is associated with struct bt_mesh_model_op in mesh_access.h + */ +typedef struct { + const uint32_t opcode; /*!< Message opcode */ + const size_t min_len; /*!< Message minimum length */ + esp_ble_mesh_cb_t param_cb; /*!< Callback used to handle message. Initialized by the stack. */ +} esp_ble_mesh_model_op_t; + +/** Define the terminator for the model operation table. + * Each model operation struct array must use this terminator as + * the end tag of the operation unit. + */ +#define ESP_BLE_MESH_MODEL_OP_END {0, 0, 0} + +/** Abstraction that describes a model callback structure. + * This structure is associated with struct bt_mesh_model_cb in mesh_access.h. + */ +typedef struct { + /** Callback used during model initialization. Initialized by the stack. */ + esp_ble_mesh_cb_t init_cb; + +#if CONFIG_BLE_MESH_DEINIT + /** Callback used during model deinitialization. Initialized by the stack. */ + esp_ble_mesh_cb_t deinit_cb; +#endif /* CONFIG_BLE_MESH_DEINIT */ +} esp_ble_mesh_model_cbs_t; + +/** Abstraction that describes a Mesh Model instance. + * This structure is associated with struct bt_mesh_model in mesh_access.h + */ +struct esp_ble_mesh_model { + /** Model ID */ + union { + const uint16_t model_id; /*!< 16-bit model identifier */ + struct { + uint16_t company_id; /*!< 16-bit company identifier */ + uint16_t model_id; /*!< 16-bit model identifier */ + } vnd; /*!< Structure encapsulating a model ID with a company ID */ + }; + + /** Internal information, mainly for persistent storage */ + uint8_t element_idx; /*!< Belongs to Nth element */ + uint8_t model_idx; /*!< Is the Nth model in the element */ + uint16_t flags; /*!< Information about what has changed */ + + /** The Element to which this Model belongs */ + esp_ble_mesh_elem_t *element; + + /** Model Publication */ + esp_ble_mesh_model_pub_t *const pub; + + /** AppKey List */ + uint16_t keys[CONFIG_BLE_MESH_MODEL_KEY_COUNT]; + + /** Subscription List (group or virtual addresses) */ + uint16_t groups[CONFIG_BLE_MESH_MODEL_GROUP_COUNT]; + + /** Model operation context */ + esp_ble_mesh_model_op_t *op; + + /** Model callback structure */ + esp_ble_mesh_model_cbs_t *cb; + + /** Model-specific user data */ + void *user_data; +}; + +/** Helper to define an empty model array. + * This structure is associated with BLE_MESH_MODEL_NONE in mesh_access.h + */ +#define ESP_BLE_MESH_MODEL_NONE ((esp_ble_mesh_model_t []){}) + +/** Message sending context. + * This structure is associated with struct bt_mesh_msg_ctx in mesh_access.h + */ +typedef struct { + /** NetKey Index of the subnet through which to send the message. */ + uint16_t net_idx; + + /** AppKey Index for message encryption. */ + uint16_t app_idx; + + /** Remote address. */ + uint16_t addr; + + /** Destination address of a received message. Not used for sending. */ + uint16_t recv_dst; + + /** RSSI of received packet. Not used for sending. */ + int8_t recv_rssi; + + /** Received TTL value. Not used for sending. */ + uint8_t recv_ttl: 7; + + /** Force sending reliably by using segment acknowledgement */ + uint8_t send_rel: 1; + + /** TTL, or ESP_BLE_MESH_TTL_DEFAULT for default TTL. */ + uint8_t send_ttl; + + /** Opcode of a received message. Not used for sending message. */ + uint32_t recv_op; + + /** Model corresponding to the message, no need to be initialized before sending message */ + esp_ble_mesh_model_t *model; + + /** Indicate if the message is sent by a node server model, no need to be initialized before sending message */ + bool srv_send; +} esp_ble_mesh_msg_ctx_t; + +/** Provisioning properties & capabilities. + * This structure is associated with struct bt_mesh_prov in mesh_access.h + */ +typedef struct { +#if CONFIG_BLE_MESH_NODE + /** The UUID that is used when advertising as an unprovisioned device */ + const uint8_t *uuid; + + /** Optional URI. This will be advertised separately from the + * unprovisioned beacon, however the unprovisioned beacon will + * contain a hash of it so the two can be associated by the + * provisioner. + */ + const char *uri; + + /** Out of Band information field. */ + esp_ble_mesh_prov_oob_info_t oob_info; + + /* NOTE: In order to avoid suffering brute-forcing attack (CVE-2020-26559). + * The Bluetooth SIG recommends that potentially vulnerable mesh provisioners + * support an out-of-band mechanism to exchange the public keys. + * So as an unprovisioned device, it should enable this flag to support + * using an out-of-band mechanism to exchange Public Key. + */ + /** Flag indicates whether unprovisioned devices support OOB public key */ + bool oob_pub_key; + + /** Callback used to notify to set OOB Public Key. Initialized by the stack. */ + esp_ble_mesh_cb_t oob_pub_key_cb; + + /** Static OOB value */ + const uint8_t *static_val; + /** Static OOB value length */ + uint8_t static_val_len; + + /** Maximum size of Output OOB supported */ + uint8_t output_size; + /** Supported Output OOB Actions */ + uint16_t output_actions; + + /** Maximum size of Input OOB supported */ + uint8_t input_size; + /** Supported Input OOB Actions */ + uint16_t input_actions; + + /** Callback used to output the number. Initialized by the stack. */ + esp_ble_mesh_cb_t output_num_cb; + /** Callback used to output the string. Initialized by the stack. */ + esp_ble_mesh_cb_t output_str_cb; + /** Callback used to notify to input number/string. Initialized by the stack. */ + esp_ble_mesh_cb_t input_cb; + /** Callback used to indicate that link is opened. Initialized by the stack. */ + esp_ble_mesh_cb_t link_open_cb; + /** Callback used to indicate that link is closed. Initialized by the stack. */ + esp_ble_mesh_cb_t link_close_cb; + /** Callback used to indicate that provisioning is completed. Initialized by the stack. */ + esp_ble_mesh_cb_t complete_cb; + /** Callback used to indicate that node has been reset. Initialized by the stack. */ + esp_ble_mesh_cb_t reset_cb; +#endif /* CONFIG_BLE_MESH_NODE */ + +#ifdef CONFIG_BLE_MESH_PROVISIONER + /** Provisioner device UUID */ + const uint8_t *prov_uuid; + + /** Primary element address of the provisioner */ + const uint16_t prov_unicast_addr; + + /** Pre-incremental unicast address value to be assigned to the first device */ + uint16_t prov_start_address; + + /** Attention timer contained in Provisioning Invite PDU */ + uint8_t prov_attention; + + /** Provisioning Algorithm for the Provisioner */ + uint8_t prov_algorithm; + + /* NOTE: In order to avoid suffering brute-forcing attack (CVE-2020-26559). + * The Bluetooth SIG recommends that potentially vulnerable mesh provisioners + * use an out-of-band mechanism to exchange the public keys. + */ + /** Provisioner public key oob */ + uint8_t prov_pub_key_oob; + + /** Callback used to notify to set device OOB Public Key. Initialized by the stack. */ + esp_ble_mesh_cb_t provisioner_prov_read_oob_pub_key; + + /* NOTE: The Bluetooth SIG recommends that mesh implementations enforce a randomly + * selected AuthValue using all of the available bits, where permitted by the + * implementation. A large entropy helps ensure that a brute-force of the AuthValue, + * even a static AuthValue, cannot normally be completed in a reasonable time (CVE-2020-26557). + * + * AuthValues selected using a cryptographically secure random or pseudorandom number + * generator and having the maximum permitted entropy (128-bits) will be most difficult + * to brute-force. AuthValues with reduced entropy or generated in a predictable manner + * will not grant the same level of protection against this vulnerability. Selecting a + * new AuthValue with each provisioning attempt can also make it more difficult to launch + * a brute-force attack by requiring the attacker to restart the search with each + * provisioning attempt (CVE-2020-26556). + */ + /** Provisioner static oob value */ + uint8_t *prov_static_oob_val; + /** Provisioner static oob value length */ + uint8_t prov_static_oob_len; + + /** Callback used to notify to input number/string. Initialized by the stack. */ + esp_ble_mesh_cb_t provisioner_prov_input; + /** Callback used to output number/string. Initialized by the stack. */ + esp_ble_mesh_cb_t provisioner_prov_output; + + /** Key refresh and IV update flag */ + uint8_t flags; + + /** IV index */ + uint32_t iv_index; + + /** Callback used to indicate that link is opened. Initialized by the stack. */ + esp_ble_mesh_cb_t provisioner_link_open; + /** Callback used to indicate that link is closed. Initialized by the stack. */ + esp_ble_mesh_cb_t provisioner_link_close; + /** Callback used to indicate that a device is provisioned. Initialized by the stack. */ + esp_ble_mesh_cb_t provisioner_prov_comp; +#endif /* CONFIG_BLE_MESH_PROVISIONER */ +} esp_ble_mesh_prov_t; + +/** Node Composition data context. + * This structure is associated with struct bt_mesh_comp in mesh_access.h + */ +typedef struct { + uint16_t cid; /*!< 16-bit SIG-assigned company identifier */ + uint16_t pid; /*!< 16-bit vendor-assigned product identifier */ + uint16_t vid; /*!< 16-bit vendor-assigned product version identifier */ + + size_t element_count; /*!< Element count */ + esp_ble_mesh_elem_t *elements; /*!< A sequence of elements */ +} esp_ble_mesh_comp_t; + +/*!< This enum value is the role of the device */ +typedef enum { + ROLE_NODE = 0, + ROLE_PROVISIONER, + ROLE_FAST_PROV, +} esp_ble_mesh_dev_role_t; + +/*!< Flag which will be set when device is going to be added. */ +typedef uint8_t esp_ble_mesh_dev_add_flag_t; +#define ADD_DEV_RM_AFTER_PROV_FLAG BIT(0) /*!< Device will be removed from queue after provisioned successfully */ +#define ADD_DEV_START_PROV_NOW_FLAG BIT(1) /*!< Start provisioning device immediately */ +#define ADD_DEV_FLUSHABLE_DEV_FLAG BIT(2) /*!< Device can be remove when queue is full and new device is going to added */ + +/** Information of the device which is going to be added for provisioning. */ +typedef struct { + esp_ble_mesh_bd_addr_t addr; /*!< Device address */ + esp_ble_mesh_addr_type_t addr_type; /*!< Device address type */ + uint8_t uuid[16]; /*!< Device UUID */ + uint16_t oob_info; /*!< Device OOB Info */ + /*!< ADD_DEV_START_PROV_NOW_FLAG shall not be set if the bearer has both PB-ADV and PB-GATT enabled */ + esp_ble_mesh_prov_bearer_t bearer; /*!< Provisioning Bearer */ +} esp_ble_mesh_unprov_dev_add_t; + +#define DEL_DEV_ADDR_FLAG BIT(0) +#define DEL_DEV_UUID_FLAG BIT(1) +/** Information of the device which is going to be deleted. */ +typedef struct { + union { + struct { + esp_ble_mesh_bd_addr_t addr; /*!< Device address */ + esp_ble_mesh_addr_type_t addr_type; /*!< Device address type */ + }; + uint8_t uuid[16]; /*!< Device UUID */ + }; + uint8_t flag; /*!< BIT0: device address; BIT1: device UUID */ +} esp_ble_mesh_device_delete_t; + +#define PROV_DATA_NET_IDX_FLAG BIT(0) +#define PROV_DATA_FLAGS_FLAG BIT(1) +#define PROV_DATA_IV_INDEX_FLAG BIT(2) +/** Information of the provisioner which is going to be updated. */ +typedef struct { + union { + uint16_t net_idx; /*!< NetKey Index */ + uint8_t flags; /*!< Flags */ + uint32_t iv_index; /*!< IV Index */ + }; + uint8_t flag; /*!< BIT0: net_idx; BIT1: flags; BIT2: iv_index */ +} esp_ble_mesh_prov_data_info_t; + +/** Information of the provisioned node */ +typedef struct { + /* Device information */ + esp_ble_mesh_bd_addr_t addr; /*!< Node device address */ + esp_ble_mesh_addr_type_t addr_type; /*!< Node device address type */ + uint8_t dev_uuid[16]; /*!< Device UUID */ + uint16_t oob_info; /*!< Node OOB information */ + + /* Provisioning information */ + uint16_t unicast_addr; /*!< Node unicast address */ + uint8_t element_num; /*!< Node element number */ + uint16_t net_idx; /*!< Node NetKey Index */ + uint8_t flags; /*!< Node key refresh flag and iv update flag */ + uint32_t iv_index; /*!< Node IV Index */ + uint8_t dev_key[16]; /*!< Node device key */ + + /* Additional information */ + char name[ESP_BLE_MESH_NODE_NAME_MAX_LEN + 1]; /*!< Node name */ + uint16_t comp_length; /*!< Length of Composition Data */ + uint8_t *comp_data; /*!< Value of Composition Data */ +} __attribute__((packed)) esp_ble_mesh_node_t; + +/** Context of fast provisioning which need to be set. */ +typedef struct { + uint16_t unicast_min; /*!< Minimum unicast address used for fast provisioning */ + uint16_t unicast_max; /*!< Maximum unicast address used for fast provisioning */ + uint16_t net_idx; /*!< Netkey index used for fast provisioning */ + uint8_t flags; /*!< Flags used for fast provisioning */ + uint32_t iv_index; /*!< IV Index used for fast provisioning */ + uint8_t offset; /*!< Offset of the UUID to be compared */ + uint8_t match_len; /*!< Length of the UUID to be compared */ + uint8_t match_val[16]; /*!< Value of UUID to be compared */ +} esp_ble_mesh_fast_prov_info_t; + +/*!< This enum value is the action of fast provisioning */ +typedef enum { + FAST_PROV_ACT_NONE, + FAST_PROV_ACT_ENTER, + FAST_PROV_ACT_SUSPEND, + FAST_PROV_ACT_EXIT, + FAST_PROV_ACT_MAX, +} esp_ble_mesh_fast_prov_action_t; + +/*!< This enum value is the type of proxy filter */ +typedef enum { + PROXY_FILTER_WHITELIST, + PROXY_FILTER_BLACKLIST, +} esp_ble_mesh_proxy_filter_type_t; + +/*!< Provisioner heartbeat filter type */ +#define ESP_BLE_MESH_HEARTBEAT_FILTER_ACCEPTLIST 0x00 +#define ESP_BLE_MESH_HEARTBEAT_FILTER_REJECTLIST 0x01 + +/*!< Provisioner heartbeat filter operation */ +#define ESP_BLE_MESH_HEARTBEAT_FILTER_ADD 0x00 +#define ESP_BLE_MESH_HEARTBEAT_FILTER_REMOVE 0x01 + +/** Context of Provisioner heartbeat filter information to be set */ +typedef struct { + uint16_t hb_src; /*!< Heartbeat source address (unicast address) */ + uint16_t hb_dst; /*!< Heartbeat destination address (unicast address or group address) */ +} esp_ble_mesh_heartbeat_filter_info_t; + +/*!< This enum value is the event of node/provisioner/fast provisioning */ +typedef enum { + ESP_BLE_MESH_PROV_REGISTER_COMP_EVT, /*!< Initialize BLE Mesh provisioning capabilities and internal data information completion event */ + ESP_BLE_MESH_NODE_SET_UNPROV_DEV_NAME_COMP_EVT, /*!< Set the unprovisioned device name completion event */ + ESP_BLE_MESH_NODE_PROV_ENABLE_COMP_EVT, /*!< Enable node provisioning functionality completion event */ + ESP_BLE_MESH_NODE_PROV_DISABLE_COMP_EVT, /*!< Disable node provisioning functionality completion event */ + ESP_BLE_MESH_NODE_PROV_LINK_OPEN_EVT, /*!< Establish a BLE Mesh link event */ + ESP_BLE_MESH_NODE_PROV_LINK_CLOSE_EVT, /*!< Close a BLE Mesh link event */ + ESP_BLE_MESH_NODE_PROV_OOB_PUB_KEY_EVT, /*!< Generate Node input OOB public key event */ + ESP_BLE_MESH_NODE_PROV_OUTPUT_NUMBER_EVT, /*!< Generate Node Output Number event */ + ESP_BLE_MESH_NODE_PROV_OUTPUT_STRING_EVT, /*!< Generate Node Output String event */ + ESP_BLE_MESH_NODE_PROV_INPUT_EVT, /*!< Event requiring the user to input a number or string */ + ESP_BLE_MESH_NODE_PROV_COMPLETE_EVT, /*!< Provisioning done event */ + ESP_BLE_MESH_NODE_PROV_RESET_EVT, /*!< Provisioning reset event */ + ESP_BLE_MESH_NODE_PROV_SET_OOB_PUB_KEY_COMP_EVT, /*!< Node set oob public key completion event */ + ESP_BLE_MESH_NODE_PROV_INPUT_NUMBER_COMP_EVT, /*!< Node input number completion event */ + ESP_BLE_MESH_NODE_PROV_INPUT_STRING_COMP_EVT, /*!< Node input string completion event */ + ESP_BLE_MESH_NODE_PROXY_IDENTITY_ENABLE_COMP_EVT, /*!< Enable BLE Mesh Proxy Identity advertising completion event */ + ESP_BLE_MESH_NODE_PROXY_GATT_ENABLE_COMP_EVT, /*!< Enable BLE Mesh GATT Proxy Service completion event */ + ESP_BLE_MESH_NODE_PROXY_GATT_DISABLE_COMP_EVT, /*!< Disable BLE Mesh GATT Proxy Service completion event */ + ESP_BLE_MESH_NODE_ADD_LOCAL_NET_KEY_COMP_EVT, /*!< Node add NetKey locally completion event */ + ESP_BLE_MESH_NODE_ADD_LOCAL_APP_KEY_COMP_EVT, /*!< Node add AppKey locally completion event */ + ESP_BLE_MESH_NODE_BIND_APP_KEY_TO_MODEL_COMP_EVT, /*!< Node bind AppKey to model locally completion event */ + ESP_BLE_MESH_PROVISIONER_PROV_ENABLE_COMP_EVT, /*!< Provisioner enable provisioning functionality completion event */ + ESP_BLE_MESH_PROVISIONER_PROV_DISABLE_COMP_EVT, /*!< Provisioner disable provisioning functionality completion event */ + ESP_BLE_MESH_PROVISIONER_RECV_UNPROV_ADV_PKT_EVT, /*!< Provisioner receives unprovisioned device beacon event */ + ESP_BLE_MESH_PROVISIONER_PROV_READ_OOB_PUB_KEY_EVT, /*!< Provisioner read unprovisioned device OOB public key event */ + ESP_BLE_MESH_PROVISIONER_PROV_INPUT_EVT, /*!< Provisioner input value for provisioning procedure event */ + ESP_BLE_MESH_PROVISIONER_PROV_OUTPUT_EVT, /*!< Provisioner output value for provisioning procedure event */ + ESP_BLE_MESH_PROVISIONER_PROV_LINK_OPEN_EVT, /*!< Provisioner establish a BLE Mesh link event */ + ESP_BLE_MESH_PROVISIONER_PROV_LINK_CLOSE_EVT, /*!< Provisioner close a BLE Mesh link event */ + ESP_BLE_MESH_PROVISIONER_PROV_COMPLETE_EVT, /*!< Provisioner provisioning done event */ + ESP_BLE_MESH_PROVISIONER_ADD_UNPROV_DEV_COMP_EVT, /*!< Provisioner add a device to the list which contains devices that are waiting/going to be provisioned completion event */ + ESP_BLE_MESH_PROVISIONER_PROV_DEV_WITH_ADDR_COMP_EVT, /*!< Provisioner start to provision an unprovisioned device completion event */ + ESP_BLE_MESH_PROVISIONER_DELETE_DEV_COMP_EVT, /*!< Provisioner delete a device from the list, close provisioning link with the device completion event */ + ESP_BLE_MESH_PROVISIONER_SET_DEV_UUID_MATCH_COMP_EVT, /*!< Provisioner set the value to be compared with part of the unprovisioned device UUID completion event */ + ESP_BLE_MESH_PROVISIONER_SET_PROV_DATA_INFO_COMP_EVT, /*!< Provisioner set net_idx/flags/iv_index used for provisioning completion event */ + ESP_BLE_MESH_PROVISIONER_SET_STATIC_OOB_VALUE_COMP_EVT, /*!< Provisioner set static oob value used for provisioning completion event */ + ESP_BLE_MESH_PROVISIONER_SET_PRIMARY_ELEM_ADDR_COMP_EVT, /*!< Provisioner set unicast address of primary element completion event */ + ESP_BLE_MESH_PROVISIONER_PROV_READ_OOB_PUB_KEY_COMP_EVT, /*!< Provisioner read unprovisioned device OOB public key completion event */ + ESP_BLE_MESH_PROVISIONER_PROV_INPUT_NUMBER_COMP_EVT, /*!< Provisioner input number completion event */ + ESP_BLE_MESH_PROVISIONER_PROV_INPUT_STRING_COMP_EVT, /*!< Provisioner input string completion event */ + ESP_BLE_MESH_PROVISIONER_SET_NODE_NAME_COMP_EVT, /*!< Provisioner set node name completion event */ + ESP_BLE_MESH_PROVISIONER_ADD_LOCAL_APP_KEY_COMP_EVT, /*!< Provisioner add local app key completion event */ + ESP_BLE_MESH_PROVISIONER_UPDATE_LOCAL_APP_KEY_COMP_EVT, /*!< Provisioner update local app key completion event */ + ESP_BLE_MESH_PROVISIONER_BIND_APP_KEY_TO_MODEL_COMP_EVT, /*!< Provisioner bind local model with local app key completion event */ + ESP_BLE_MESH_PROVISIONER_ADD_LOCAL_NET_KEY_COMP_EVT, /*!< Provisioner add local network key completion event */ + ESP_BLE_MESH_PROVISIONER_UPDATE_LOCAL_NET_KEY_COMP_EVT, /*!< Provisioner update local network key completion event */ + ESP_BLE_MESH_PROVISIONER_STORE_NODE_COMP_DATA_COMP_EVT, /*!< Provisioner store node composition data completion event */ + ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_UUID_COMP_EVT, /*!< Provisioner delete node with uuid completion event */ + ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_ADDR_COMP_EVT, /*!< Provisioner delete node with unicast address completion event */ + ESP_BLE_MESH_PROVISIONER_ENABLE_HEARTBEAT_RECV_COMP_EVT, /*!< Provisioner start to receive heartbeat message completion event */ + ESP_BLE_MESH_PROVISIONER_SET_HEARTBEAT_FILTER_TYPE_COMP_EVT, /*!< Provisioner set the heartbeat filter type completion event */ + ESP_BLE_MESH_PROVISIONER_SET_HEARTBEAT_FILTER_INFO_COMP_EVT, /*!< Provisioner set the heartbeat filter information completion event */ + ESP_BLE_MESH_PROVISIONER_RECV_HEARTBEAT_MESSAGE_EVT, /*!< Provisioner receive heartbeat message event */ + ESP_BLE_MESH_PROVISIONER_DRIECT_ERASE_SETTINGS_COMP_EVT, /*!< Provisioner directly erase settings completion event */ + ESP_BLE_MESH_PROVISIONER_OPEN_SETTINGS_WITH_INDEX_COMP_EVT, /*!< Provisioner open settings with index completion event */ + ESP_BLE_MESH_PROVISIONER_OPEN_SETTINGS_WITH_UID_COMP_EVT, /*!< Provisioner open settings with user id completion event */ + ESP_BLE_MESH_PROVISIONER_CLOSE_SETTINGS_WITH_INDEX_COMP_EVT, /*!< Provisioner close settings with index completion event */ + ESP_BLE_MESH_PROVISIONER_CLOSE_SETTINGS_WITH_UID_COMP_EVT, /*!< Provisioner close settings with user id completion event */ + ESP_BLE_MESH_PROVISIONER_DELETE_SETTINGS_WITH_INDEX_COMP_EVT, /*!< Provisioner delete settings with index completion event */ + ESP_BLE_MESH_PROVISIONER_DELETE_SETTINGS_WITH_UID_COMP_EVT, /*!< Provisioner delete settings with user id completion event */ + ESP_BLE_MESH_SET_FAST_PROV_INFO_COMP_EVT, /*!< Set fast provisioning information (e.g. unicast address range, net_idx, etc.) completion event */ + ESP_BLE_MESH_SET_FAST_PROV_ACTION_COMP_EVT, /*!< Set fast provisioning action completion event */ + ESP_BLE_MESH_HEARTBEAT_MESSAGE_RECV_EVT, /*!< Receive Heartbeat message event */ + ESP_BLE_MESH_LPN_ENABLE_COMP_EVT, /*!< Enable Low Power Node completion event */ + ESP_BLE_MESH_LPN_DISABLE_COMP_EVT, /*!< Disable Low Power Node completion event */ + ESP_BLE_MESH_LPN_POLL_COMP_EVT, /*!< Low Power Node send Friend Poll completion event */ + ESP_BLE_MESH_LPN_FRIENDSHIP_ESTABLISH_EVT, /*!< Low Power Node establishes friendship event */ + ESP_BLE_MESH_LPN_FRIENDSHIP_TERMINATE_EVT, /*!< Low Power Node terminates friendship event */ + ESP_BLE_MESH_FRIEND_FRIENDSHIP_ESTABLISH_EVT, /*!< Friend Node establishes friendship event */ + ESP_BLE_MESH_FRIEND_FRIENDSHIP_TERMINATE_EVT, /*!< Friend Node terminates friendship event */ + ESP_BLE_MESH_PROXY_CLIENT_RECV_ADV_PKT_EVT, /*!< Proxy Client receives Network ID advertising packet event */ + ESP_BLE_MESH_PROXY_CLIENT_CONNECTED_EVT, /*!< Proxy Client establishes connection successfully event */ + ESP_BLE_MESH_PROXY_CLIENT_DISCONNECTED_EVT, /*!< Proxy Client terminates connection successfully event */ + ESP_BLE_MESH_PROXY_CLIENT_RECV_FILTER_STATUS_EVT, /*!< Proxy Client receives Proxy Filter Status event */ + ESP_BLE_MESH_PROXY_CLIENT_CONNECT_COMP_EVT, /*!< Proxy Client connect completion event */ + ESP_BLE_MESH_PROXY_CLIENT_DISCONNECT_COMP_EVT, /*!< Proxy Client disconnect completion event */ + ESP_BLE_MESH_PROXY_CLIENT_SET_FILTER_TYPE_COMP_EVT, /*!< Proxy Client set filter type completion event */ + ESP_BLE_MESH_PROXY_CLIENT_ADD_FILTER_ADDR_COMP_EVT, /*!< Proxy Client add filter address completion event */ + ESP_BLE_MESH_PROXY_CLIENT_REMOVE_FILTER_ADDR_COMP_EVT, /*!< Proxy Client remove filter address completion event */ + ESP_BLE_MESH_PROXY_SERVER_CONNECTED_EVT, /*!< Proxy Server establishes connection successfully event */ + ESP_BLE_MESH_PROXY_SERVER_DISCONNECTED_EVT, /*!< Proxy Server terminates connection successfully event */ + ESP_BLE_MESH_MODEL_SUBSCRIBE_GROUP_ADDR_COMP_EVT, /*!< Local model subscribes group address completion event */ + ESP_BLE_MESH_MODEL_UNSUBSCRIBE_GROUP_ADDR_COMP_EVT, /*!< Local model unsubscribes group address completion event */ + ESP_BLE_MESH_DEINIT_MESH_COMP_EVT, /*!< De-initialize BLE Mesh stack completion event */ + ESP_BLE_MESH_PROV_EVT_MAX, +} esp_ble_mesh_prov_cb_event_t; + +/** + * @brief BLE Mesh Node/Provisioner callback parameters union + */ +typedef union { + /** + * @brief ESP_BLE_MESH_PROV_REGISTER_COMP_EVT + */ + struct ble_mesh_prov_register_comp_param { + int err_code; /*!< Indicate the result of BLE Mesh initialization */ + } prov_register_comp; /*!< Event parameter of ESP_BLE_MESH_PROV_REGISTER_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_NODE_SET_UNPROV_DEV_NAME_COMP_EVT + */ + struct ble_mesh_set_unprov_dev_name_comp_param { + int err_code; /*!< Indicate the result of setting BLE Mesh device name */ + } node_set_unprov_dev_name_comp; /*!< Event parameter of ESP_BLE_MESH_NODE_SET_UNPROV_DEV_NAME_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_NODE_PROV_ENABLE_COMP_EVT + */ + struct ble_mesh_prov_enable_comp_param { + int err_code; /*!< Indicate the result of enabling BLE Mesh device */ + } node_prov_enable_comp; /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_ENABLE_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_NODE_PROV_DISABLE_COMP_EVT + */ + struct ble_mesh_prov_disable_comp_param { + int err_code; /*!< Indicate the result of disabling BLE Mesh device */ + } node_prov_disable_comp; /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_DISABLE_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_NODE_PROV_LINK_OPEN_EVT + */ + struct ble_mesh_link_open_evt_param { + esp_ble_mesh_prov_bearer_t bearer; /*!< Type of the bearer used when device link is open */ + } node_prov_link_open; /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_LINK_OPEN_EVT */ + /** + * @brief ESP_BLE_MESH_NODE_PROV_LINK_CLOSE_EVT + */ + struct ble_mesh_link_close_evt_param { + esp_ble_mesh_prov_bearer_t bearer; /*!< Type of the bearer used when device link is closed */ + } node_prov_link_close; /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_LINK_CLOSE_EVT */ + /** + * @brief ESP_BLE_MESH_NODE_PROV_OUTPUT_NUMBER_EVT + */ + struct ble_mesh_output_num_evt_param { + esp_ble_mesh_output_action_t action; /*!< Action of Output OOB Authentication */ + uint32_t number; /*!< Number of Output OOB Authentication */ + } node_prov_output_num; /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_OUTPUT_NUMBER_EVT */ + /** + * @brief ESP_BLE_MESH_NODE_PROV_OUTPUT_STRING_EVT + */ + struct ble_mesh_output_str_evt_param { + char string[8]; /*!< String of Output OOB Authentication */ + } node_prov_output_str; /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_OUTPUT_STRING_EVT */ + /** + * @brief ESP_BLE_MESH_NODE_PROV_INPUT_EVT + */ + struct ble_mesh_input_evt_param { + esp_ble_mesh_input_action_t action; /*!< Action of Input OOB Authentication */ + uint8_t size; /*!< Size of Input OOB Authentication */ + } node_prov_input; /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_INPUT_EVT */ + /** + * @brief ESP_BLE_MESH_NODE_PROV_COMPLETE_EVT + */ + struct ble_mesh_provision_complete_evt_param { + uint16_t net_idx; /*!< NetKey Index */ + uint8_t net_key[16]; /*!< NetKey */ + uint16_t addr; /*!< Primary address */ + uint8_t flags; /*!< Flags */ + uint32_t iv_index; /*!< IV Index */ + } node_prov_complete; /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_COMPLETE_EVT */ + /** + * @brief ESP_BLE_MESH_NODE_PROV_RESET_EVT + */ + struct ble_mesh_provision_reset_param { + + } node_prov_reset; /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_RESET_EVT */ + /** + * @brief ESP_BLE_MESH_NODE_PROV_SET_OOB_PUB_KEY_COMP_EVT + */ + struct ble_mesh_set_oob_pub_key_comp_param { + int err_code; /*!< Indicate the result of setting OOB Public Key */ + } node_prov_set_oob_pub_key_comp; /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_SET_OOB_PUB_KEY_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_NODE_PROV_INPUT_NUM_COMP_EVT + */ + struct ble_mesh_input_number_comp_param { + int err_code; /*!< Indicate the result of inputting number */ + } node_prov_input_num_comp; /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_INPUT_NUM_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_NODE_PROV_INPUT_STR_COMP_EVT + */ + struct ble_mesh_input_string_comp_param { + int err_code; /*!< Indicate the result of inputting string */ + } node_prov_input_str_comp; /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_INPUT_STR_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_NODE_PROXY_IDENTITY_ENABLE_COMP_EVT + */ + struct ble_mesh_proxy_identity_enable_comp_param { + int err_code; /*!< Indicate the result of enabling Mesh Proxy advertising */ + } node_proxy_identity_enable_comp; /*!< Event parameter of ESP_BLE_MESH_NODE_PROXY_IDENTITY_ENABLE_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_NODE_PROXY_GATT_ENABLE_COMP_EVT + */ + struct ble_mesh_proxy_gatt_enable_comp_param { + int err_code; /*!< Indicate the result of enabling Mesh Proxy Service */ + } node_proxy_gatt_enable_comp; /*!< Event parameter of ESP_BLE_MESH_NODE_PROXY_GATT_ENABLE_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_NODE_PROXY_GATT_DISABLE_COMP_EVT + */ + struct ble_mesh_proxy_gatt_disable_comp_param { + int err_code; /*!< Indicate the result of disabling Mesh Proxy Service */ + } node_proxy_gatt_disable_comp; /*!< Event parameter of ESP_BLE_MESH_NODE_PROXY_GATT_DISABLE_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_NODE_ADD_LOCAL_NET_KEY_COMP_EVT + */ + struct ble_mesh_node_add_local_net_key_comp_param { + int err_code; /*!< Indicate the result of adding local NetKey by the node */ + uint16_t net_idx; /*!< NetKey Index */ + } node_add_net_key_comp; /*!< Event parameter of ESP_BLE_MESH_NODE_ADD_LOCAL_NET_KEY_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_NODE_ADD_LOCAL_APP_KEY_COMP_EVT + */ + struct ble_mesh_node_add_local_app_key_comp_param { + int err_code; /*!< Indicate the result of adding local AppKey by the node */ + uint16_t net_idx; /*!< NetKey Index */ + uint16_t app_idx; /*!< AppKey Index */ + } node_add_app_key_comp; /*!< Event parameter of ESP_BLE_MESH_NODE_ADD_LOCAL_APP_KEY_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_NODE_BIND_APP_KEY_TO_MODEL_COMP_EVT + */ + struct ble_mesh_node_bind_local_mod_app_comp_param { + int err_code; /*!< Indicate the result of binding AppKey with model by the node */ + uint16_t element_addr; /*!< Element address */ + uint16_t app_idx; /*!< AppKey Index */ + uint16_t company_id; /*!< Company ID */ + uint16_t model_id; /*!< Model ID */ + } node_bind_app_key_to_model_comp; /*!< Event parameter of ESP_BLE_MESH_NODE_BIND_APP_KEY_TO_MODEL_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_RECV_UNPROV_ADV_PKT_EVT + */ + struct ble_mesh_provisioner_recv_unprov_adv_pkt_param { + uint8_t dev_uuid[16]; /*!< Device UUID of the unprovisioned device */ + esp_ble_mesh_bd_addr_t addr; /*!< Device address of the unprovisioned device */ + esp_ble_mesh_addr_type_t addr_type; /*!< Device address type */ + uint16_t oob_info; /*!< OOB Info of the unprovisioned device */ + uint8_t adv_type; /*!< Avertising type of the unprovisioned device */ + esp_ble_mesh_prov_bearer_t bearer; /*!< Bearer of the unprovisioned device */ + int8_t rssi; /*!< RSSI of the received advertising packet */ + } provisioner_recv_unprov_adv_pkt; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_RECV_UNPROV_ADV_PKT_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_PROV_ENABLE_COMP_EVT + */ + struct ble_mesh_provisioner_prov_enable_comp_param { + int err_code; /*!< Indicate the result of enabling BLE Mesh Provisioner */ + } provisioner_prov_enable_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_PROV_ENABLE_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_PROV_DISABLE_COMP_EVT + */ + struct ble_mesh_provisioner_prov_disable_comp_param { + int err_code; /*!< Indicate the result of disabling BLE Mesh Provisioner */ + } provisioner_prov_disable_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_PROV_DISABLE_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_PROV_LINK_OPEN_EVT + */ + struct ble_mesh_provisioner_link_open_evt_param { + esp_ble_mesh_prov_bearer_t bearer; /*!< Type of the bearer used when Provisioner link is opened */ + } provisioner_prov_link_open; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_PROV_LINK_OPEN_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_PROV_READ_OOB_PUB_KEY_EVT + */ + struct ble_mesh_provisioner_prov_read_oob_pub_key_evt_param { + uint8_t link_idx; /*!< Index of the provisioning link */ + } provisioner_prov_read_oob_pub_key; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_PROV_READ_OOB_PUB_KEY_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_PROV_INPUT_EVT + */ + struct ble_mesh_provisioner_prov_input_evt_param { + esp_ble_mesh_oob_method_t method; /*!< Method of device Output OOB Authentication */ + esp_ble_mesh_output_action_t action; /*!< Action of device Output OOB Authentication */ + uint8_t size; /*!< Size of device Output OOB Authentication */ + uint8_t link_idx; /*!< Index of the provisioning link */ + } provisioner_prov_input; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_PROV_INPUT_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_PROV_OUTPUT_EVT + */ + struct ble_mesh_provisioner_prov_output_evt_param { + esp_ble_mesh_oob_method_t method; /*!< Method of device Input OOB Authentication */ + esp_ble_mesh_input_action_t action; /*!< Action of device Input OOB Authentication */ + uint8_t size; /*!< Size of device Input OOB Authentication */ + uint8_t link_idx; /*!< Index of the provisioning link */ + union { + char string[8]; /*!< String output by the Provisioner */ + uint32_t number; /*!< Number output by the Provisioner */ + }; + } provisioner_prov_output; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_PROV_OUTPUT_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_PROV_LINK_CLOSE_EVT + */ + struct ble_mesh_provisioner_link_close_evt_param { + esp_ble_mesh_prov_bearer_t bearer; /*!< Type of the bearer used when Provisioner link is closed */ + uint8_t reason; /*!< Reason of the closed provisioning link */ + } provisioner_prov_link_close; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_PROV_LINK_CLOSE_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_PROV_COMPLETE_EVT + */ + struct ble_mesh_provisioner_prov_comp_param { + uint16_t node_idx; /*!< Index of the provisioned device */ + esp_ble_mesh_octet16_t device_uuid; /*!< Device UUID of the provisioned device */ + uint16_t unicast_addr; /*!< Primary address of the provisioned device */ + uint8_t element_num; /*!< Element count of the provisioned device */ + uint16_t netkey_idx; /*!< NetKey Index of the provisioned device */ + } provisioner_prov_complete; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_PROV_COMPLETE_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_ADD_UNPROV_DEV_COMP_EVT + */ + struct ble_mesh_provisioner_add_unprov_dev_comp_param { + int err_code; /*!< Indicate the result of adding device into queue by the Provisioner */ + } provisioner_add_unprov_dev_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_ADD_UNPROV_DEV_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_PROV_DEV_WITH_ADDR_COMP_EVT + */ + struct ble_mesh_provisioner_prov_dev_with_addr_comp_param { + int err_code; /*!< Indicate the result of Provisioner starting to provision a device */ + } provisioner_prov_dev_with_addr_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_PROV_DEV_WITH_ADDR_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_DELETE_DEV_COMP_EVT + */ + struct ble_mesh_provisioner_delete_dev_comp_param { + int err_code; /*!< Indicate the result of deleting device by the Provisioner */ + } provisioner_delete_dev_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_DELETE_DEV_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_SET_DEV_UUID_MATCH_COMP_EVT + */ + struct ble_mesh_provisioner_set_dev_uuid_match_comp_param { + int err_code; /*!< Indicate the result of setting Device UUID match value by the Provisioner */ + } provisioner_set_dev_uuid_match_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_SET_DEV_UUID_MATCH_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_SET_PROV_DATA_INFO_COMP_EVT + */ + struct ble_mesh_provisioner_set_prov_data_info_comp_param { + int err_code; /*!< Indicate the result of setting provisioning info by the Provisioner */ + } provisioner_set_prov_data_info_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_SET_PROV_DATA_INFO_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_SET_STATIC_OOB_VALUE_COMP_EVT + */ + struct ble_mesh_provisioner_set_static_oob_val_comp_param { + int err_code; /*!< Indicate the result of setting static oob value by the Provisioner */ + } provisioner_set_static_oob_val_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_SET_STATIC_OOB_VALUE_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_SET_PRIMARY_ELEM_ADDR_COMP_EVT + */ + struct ble_mesh_provisioner_set_primary_elem_addr_comp_param { + int err_code; /*!< Indicate the result of setting unicast address of primary element by the Provisioner */ + } provisioner_set_primary_elem_addr_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_SET_PRIMARY_ELEM_ADDR_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_PROV_READ_OOB_PUB_KEY_COMP_EVT + */ + struct ble_mesh_provisioner_prov_read_oob_pub_key_comp_param { + int err_code; /*!< Indicate the result of setting OOB Public Key by the Provisioner */ + } provisioner_prov_read_oob_pub_key_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_PROV_READ_OOB_PUB_KEY_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_PROV_INPUT_NUMBER_COMP_EVT + */ + struct ble_mesh_provisioner_prov_input_num_comp_param { + int err_code; /*!< Indicate the result of inputting number by the Provisioner */ + } provisioner_prov_input_num_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_PROV_INPUT_NUMBER_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_PROV_INPUT_STRING_COMP_EVT + */ + struct ble_mesh_provisioner_prov_input_str_comp_param { + int err_code; /*!< Indicate the result of inputting string by the Provisioner */ + } provisioner_prov_input_str_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_PROV_INPUT_STRING_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_SET_NODE_NAME_COMP_EVT + */ + struct ble_mesh_provisioner_set_node_name_comp_param { + int err_code; /*!< Indicate the result of setting provisioned device name by the Provisioner */ + uint16_t node_index; /*!< Index of the provisioned device */ + } provisioner_set_node_name_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_SET_NODE_NAME_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_ADD_LOCAL_APP_KEY_COMP_EVT + */ + struct ble_mesh_provisioner_add_local_app_key_comp_param { + int err_code; /*!< Indicate the result of adding local AppKey by the Provisioner */ + uint16_t net_idx; /*!< NetKey Index */ + uint16_t app_idx; /*!< AppKey Index */ + } provisioner_add_app_key_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_ADD_LOCAL_APP_KEY_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_UPDATE_LOCAL_APP_KEY_COMP_EVT + */ + struct ble_mesh_provisioner_update_local_app_key_comp_param { + int err_code; /*!< Indicate the result of updating local AppKey by the Provisioner */ + uint16_t net_idx; /*!< NetKey Index */ + uint16_t app_idx; /*!< AppKey Index */ + } provisioner_update_app_key_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_UPDATE_LOCAL_APP_KEY_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_BIND_APP_KEY_TO_MODEL_COMP_EVT + */ + struct ble_mesh_provisioner_bind_local_mod_app_comp_param { + int err_code; /*!< Indicate the result of binding AppKey with model by the Provisioner */ + uint16_t element_addr; /*!< Element address */ + uint16_t app_idx; /*!< AppKey Index */ + uint16_t company_id; /*!< Company ID */ + uint16_t model_id; /*!< Model ID */ + } provisioner_bind_app_key_to_model_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_BIND_APP_KEY_TO_MODEL_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_ADD_LOCAL_NET_KEY_COMP_EVT + */ + struct ble_mesh_provisioner_add_local_net_key_comp_param { + int err_code; /*!< Indicate the result of adding local NetKey by the Provisioner */ + uint16_t net_idx; /*!< NetKey Index */ + } provisioner_add_net_key_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_ADD_LOCAL_NET_KEY_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_UPDATE_LOCAL_NET_KEY_COMP_EVT + */ + struct ble_mesh_provisioner_update_local_net_key_comp_param { + int err_code; /*!< Indicate the result of updating local NetKey by the Provisioner */ + uint16_t net_idx; /*!< NetKey Index */ + } provisioner_update_net_key_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_UPDATE_LOCAL_NET_KEY_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_STORE_NODE_COMP_DATA_COMP_EVT + */ + struct ble_mesh_provisioner_store_node_comp_data_comp_param { + int err_code; /*!< Indicate the result of storing node composition data by the Provisioner */ + uint16_t addr; /*!< Node element address */ + } provisioner_store_node_comp_data_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_STORE_NODE_COMP_DATA_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_UUID_COMP_EVT + */ + struct ble_mesh_provisioner_delete_node_with_uuid_comp_param { + int err_code; /*!< Indicate the result of deleting node with uuid by the Provisioner */ + uint8_t uuid[16]; /*!< Node device uuid */ + } provisioner_delete_node_with_uuid_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_UUID_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_ADDR_COMP_EVT + */ + struct ble_mesh_provisioner_delete_node_with_addr_comp_param { + int err_code; /*!< Indicate the result of deleting node with unicast address by the Provisioner */ + uint16_t unicast_addr; /*!< Node unicast address */ + } provisioner_delete_node_with_addr_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_ADDR_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_ENABLE_HEARTBEAT_RECV_COMP_EVT + */ + struct { + int err_code; /*!< Indicate the result of enabling/disabling to receive heartbeat messages by the Provisioner */ + bool enable; /*!< Indicate enabling or disabling receiving heartbeat messages */ + } provisioner_enable_heartbeat_recv_comp; /*!< Event parameters of ESP_BLE_MESH_PROVISIONER_ENABLE_HEARTBEAT_RECV_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_SET_HEARTBEAT_FILTER_TYPE_COMP_EVT + */ + struct { + int err_code; /*!< Indicate the result of setting the heartbeat filter type by the Provisioner */ + uint8_t type; /*!< Type of the filter used for receiving heartbeat messages */ + } provisioner_set_heartbeat_filter_type_comp; /*!< Event parameters of ESP_BLE_MESH_PROVISIONER_SET_HEARTBEAT_FILTER_TYPE_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_SET_HEARTBEAT_FILTER_INFO_COMP_EVT + */ + struct { + int err_code; /*!< Indicate the result of setting the heartbeat filter address by the Provisioner */ + uint8_t op; /*!< Operation (add, remove, clean) */ + uint16_t hb_src; /*!< Heartbeat source address */ + uint16_t hb_dst; /*!< Heartbeat destination address */ + } provisioner_set_heartbeat_filter_info_comp; /*!< Event parameters of ESP_BLE_MESH_PROVISIONER_SET_HEARTBEAT_FILTER_INFO_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_RECV_HEARTBEAT_MESSAGE_EVT + */ + struct { + uint16_t hb_src; /*!< Heartbeat source address */ + uint16_t hb_dst; /*!< Heartbeat destination address */ + uint8_t init_ttl; /*!< Heartbeat InitTTL */ + uint8_t rx_ttl; /*!< Heartbeat RxTTL */ + uint8_t hops; /*!< Heartbeat hops (InitTTL - RxTTL + 1) */ + uint16_t feature; /*!< Bit field of currently active features of the node */ + int8_t rssi; /*!< RSSI of the heartbeat message */ + } provisioner_recv_heartbeat; /*!< Event parameters of ESP_BLE_MESH_PROVISIONER_RECV_HEARTBEAT_MESSAGE_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_DRIECT_ERASE_SETTINGS_COMP_EVT + */ + struct { + int err_code; /*!< Indicate the result of directly erasing settings by the Provisioner */ + } provisioner_direct_erase_settings_comp; /*!< Event parameters of ESP_BLE_MESH_PROVISIONER_DRIECT_ERASE_SETTINGS_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_OPEN_SETTINGS_WITH_INDEX_COMP_EVT + */ + struct { + int err_code; /*!< Indicate the result of opening settings with index by the Provisioner */ + uint8_t index; /*!< Index of Provisioner settings */ + } provisioner_open_settings_with_index_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_OPEN_SETTINGS_WITH_INDEX_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_OPEN_SETTINGS_WITH_UID_COMP_EVT + */ + struct { + int err_code; /*!< Indicate the result of opening settings with user id by the Provisioner */ + uint8_t index; /*!< Index of Provisioner settings */ + char uid[ESP_BLE_MESH_SETTINGS_UID_SIZE + 1]; /*!< Provisioner settings user id */ + } provisioner_open_settings_with_uid_comp; /*!< Event parameters of ESP_BLE_MESH_PROVISIONER_OPEN_SETTINGS_WITH_UID_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_CLOSE_SETTINGS_WITH_INDEX_COMP_EVT + */ + struct { + int err_code; /*!< Indicate the result of closing settings with index by the Provisioner */ + uint8_t index; /*!< Index of Provisioner settings */ + } provisioner_close_settings_with_index_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_CLOSE_SETTINGS_WITH_INDEX_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_CLOSE_SETTINGS_WITH_UID_COMP_EVT + */ + struct { + int err_code; /*!< Indicate the result of closing settings with user id by the Provisioner */ + uint8_t index; /*!< Index of Provisioner settings */ + char uid[ESP_BLE_MESH_SETTINGS_UID_SIZE + 1]; /*!< Provisioner settings user id */ + } provisioner_close_settings_with_uid_comp; /*!< Event parameters of ESP_BLE_MESH_PROVISIONER_CLOSE_SETTINGS_WITH_UID_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_DELETE_SETTINGS_WITH_INDEX_COMP_EVT + */ + struct { + int err_code; /*!< Indicate the result of deleting settings with index by the Provisioner */ + uint8_t index; /*!< Index of Provisioner settings */ + } provisioner_delete_settings_with_index_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_DELETE_SETTINGS_WITH_INDEX_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_DELETE_SETTINGS_WITH_UID_COMP_EVT + */ + struct { + int err_code; /*!< Indicate the result of deleting settings with user id by the Provisioner */ + uint8_t index; /*!< Index of Provisioner settings */ + char uid[ESP_BLE_MESH_SETTINGS_UID_SIZE + 1]; /*!< Provisioner settings user id */ + } provisioner_delete_settings_with_uid_comp; /*!< Event parameters of ESP_BLE_MESH_PROVISIONER_DELETE_SETTINGS_WITH_UID_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_SET_FAST_PROV_INFO_COMP_EVT + */ + struct ble_mesh_set_fast_prov_info_comp_param { + uint8_t status_unicast; /*!< Indicate the result of setting unicast address range of fast provisioning */ + uint8_t status_net_idx; /*!< Indicate the result of setting NetKey Index of fast provisioning */ + uint8_t status_match; /*!< Indicate the result of setting matching Device UUID of fast provisioning */ + } set_fast_prov_info_comp; /*!< Event parameter of ESP_BLE_MESH_SET_FAST_PROV_INFO_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_SET_FAST_PROV_ACTION_COMP_EVT + */ + struct ble_mesh_set_fast_prov_action_comp_param { + uint8_t status_action; /*!< Indicate the result of setting action of fast provisioning */ + } set_fast_prov_action_comp; /*!< Event parameter of ESP_BLE_MESH_SET_FAST_PROV_ACTION_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_HEARTBEAT_MESSAGE_RECV_EVT + */ + struct ble_mesh_heartbeat_msg_recv_param { + uint8_t hops; /*!< Heartbeat hops (InitTTL - RxTTL + 1) */ + uint16_t feature; /*!< Bit field of currently active features of the node */ + } heartbeat_msg_recv; /*!< Event parameter of ESP_BLE_MESH_HEARTBEAT_MESSAGE_RECV_EVT */ + /** + * @brief ESP_BLE_MESH_LPN_ENABLE_COMP_EVT + */ + struct ble_mesh_lpn_enable_comp_param { + int err_code; /*!< Indicate the result of enabling LPN functionality */ + } lpn_enable_comp; /*!< Event parameter of ESP_BLE_MESH_LPN_ENABLE_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_LPN_DISABLE_COMP_EVT + */ + struct ble_mesh_lpn_disable_comp_param { + int err_code; /*!< Indicate the result of disabling LPN functionality */ + } lpn_disable_comp; /*!< Event parameter of ESP_BLE_MESH_LPN_DISABLE_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_LPN_POLL_COMP_EVT + */ + struct ble_mesh_lpn_poll_comp_param { + int err_code; /*!< Indicate the result of sending Friend Poll */ + } lpn_poll_comp; /*!< Event parameter of ESP_BLE_MESH_LPN_POLL_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_LPN_FRIENDSHIP_ESTABLISH_EVT + */ + struct ble_mesh_lpn_friendship_establish_param { + uint16_t friend_addr; /*!< Friend Node unicast address */ + } lpn_friendship_establish; /*!< Event parameter of ESP_BLE_MESH_LPN_FRIENDSHIP_ESTABLISH_EVT */ + /** + * @brief ESP_BLE_MESH_LPN_FRIENDSHIP_TERMINATE_EVT + */ + struct ble_mesh_lpn_friendship_terminate_param { + uint16_t friend_addr; /*!< Friend Node unicast address */ + } lpn_friendship_terminate; /*!< Event parameter of ESP_BLE_MESH_LPN_FRIENDSHIP_TERMINATE_EVT */ + /** + * @brief ESP_BLE_MESH_FRIEND_FRIENDSHIP_ESTABLISH_EVT + */ + struct ble_mesh_friend_friendship_establish_param { + uint16_t lpn_addr; /*!< Low Power Node unicast address */ + } frnd_friendship_establish; /*!< Event parameter of ESP_BLE_MESH_FRIEND_FRIENDSHIP_ESTABLISH_EVT */ + /** + * @brief ESP_BLE_MESH_FRIEND_FRIENDSHIP_TERMINATE_EVT + */ + struct ble_mesh_friend_friendship_terminate_param { + uint16_t lpn_addr; /*!< Low Power Node unicast address */ + /** This enum value is the reason of friendship termination on the friend node side */ + enum { + ESP_BLE_MESH_FRND_FRIENDSHIP_TERMINATE_ESTABLISH_FAIL, /*!< Friend Offer has been sent, but Friend Offer is not received within 1 second, friendship fails to be established */ + ESP_BLE_MESH_FRND_FRIENDSHIP_TERMINATE_POLL_TIMEOUT, /*!< Friendship is established, PollTimeout timer expires and no Friend Poll/Sub Add/Sub Remove is received */ + ESP_BLE_MESH_FRND_FRIENDSHIP_TERMINATE_RECV_FRND_REQ, /*!< Receive Friend Request from existing Low Power Node */ + ESP_BLE_MESH_FRND_FRIENDSHIP_TERMINATE_RECV_FRND_CLEAR, /*!< Receive Friend Clear from other friend node */ + ESP_BLE_MESH_FRND_FRIENDSHIP_TERMINATE_DISABLE, /*!< Friend feature disabled or corresponding NetKey is deleted */ + } reason; /*!< Friendship terminated reason */ + } frnd_friendship_terminate; /*!< Event parameter of ESP_BLE_MESH_FRIEND_FRIENDSHIP_TERMINATE_EVT */ + /** + * @brief ESP_BLE_MESH_PROXY_CLIENT_RECV_ADV_PKT_EVT + */ + struct ble_mesh_proxy_client_recv_adv_pkt_param { + esp_ble_mesh_bd_addr_t addr; /*!< Device address */ + esp_ble_mesh_addr_type_t addr_type; /*!< Device address type */ + uint16_t net_idx; /*!< Network ID related NetKey Index */ + uint8_t net_id[8]; /*!< Network ID contained in the advertising packet */ + int8_t rssi; /*!< RSSI of the received advertising packet */ + } proxy_client_recv_adv_pkt; /*!< Event parameter of ESP_BLE_MESH_PROXY_CLIENT_RECV_ADV_PKT_EVT */ + /** + * @brief ESP_BLE_MESH_PROXY_CLIENT_CONNECTED_EVT + */ + struct ble_mesh_proxy_client_connected_param { + esp_ble_mesh_bd_addr_t addr; /*!< Device address of the Proxy Server */ + esp_ble_mesh_addr_type_t addr_type; /*!< Device address type */ + uint8_t conn_handle; /*!< Proxy connection handle */ + uint16_t net_idx; /*!< Corresponding NetKey Index */ + } proxy_client_connected; /*!< Event parameter of ESP_BLE_MESH_PROXY_CLIENT_CONNECTED_EVT */ + /** + * @brief ESP_BLE_MESH_PROXY_CLIENT_DISCONNECTED_EVT + */ + struct ble_mesh_proxy_client_disconnected_param { + esp_ble_mesh_bd_addr_t addr; /*!< Device address of the Proxy Server */ + esp_ble_mesh_addr_type_t addr_type; /*!< Device address type */ + uint8_t conn_handle; /*!< Proxy connection handle */ + uint16_t net_idx; /*!< Corresponding NetKey Index */ + uint8_t reason; /*!< Proxy disconnect reason */ + } proxy_client_disconnected; /*!< Event parameter of ESP_BLE_MESH_PROXY_CLIENT_DISCONNECTED_EVT */ + /** + * @brief ESP_BLE_MESH_PROXY_CLIENT_RECV_FILTER_STATUS_EVT + */ + struct ble_mesh_proxy_client_recv_filter_status_param { + uint8_t conn_handle; /*!< Proxy connection handle */ + uint16_t server_addr; /*!< Proxy Server primary element address */ + uint16_t net_idx; /*!< Corresponding NetKey Index */ + uint8_t filter_type; /*!< Proxy Server filter type(whitelist or blacklist) */ + uint16_t list_size; /*!< Number of addresses in the Proxy Server filter list */ + } proxy_client_recv_filter_status; /*!< Event parameter of ESP_BLE_MESH_PROXY_CLIENT_RECV_FILTER_STATUS_EVT */ + /** + * @brief ESP_BLE_MESH_PROXY_CLIENT_CONNECT_COMP_EVT + */ + struct ble_mesh_proxy_client_connect_comp_param { + int err_code; /*!< Indicate the result of Proxy Client connect */ + esp_ble_mesh_bd_addr_t addr; /*!< Device address of the Proxy Server */ + esp_ble_mesh_addr_type_t addr_type; /*!< Device address type */ + uint16_t net_idx; /*!< Corresponding NetKey Index */ + } proxy_client_connect_comp; /*!< Event parameter of ESP_BLE_MESH_PROXY_CLIENT_CONNECT_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROXY_CLIENT_DISCONNECT_COMP_EVT + */ + struct ble_mesh_proxy_client_disconnect_comp_param { + int err_code; /*!< Indicate the result of Proxy Client disconnect */ + uint8_t conn_handle; /*!< Proxy connection handle */ + } proxy_client_disconnect_comp; /*!< Event parameter of ESP_BLE_MESH_PROXY_CLIENT_DISCONNECT_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROXY_CLIENT_SET_FILTER_TYPE_COMP_EVT + */ + struct ble_mesh_proxy_client_set_filter_type_comp_param { + int err_code; /*!< Indicate the result of Proxy Client set filter type */ + uint8_t conn_handle; /*!< Proxy connection handle */ + uint16_t net_idx; /*!< Corresponding NetKey Index */ + } proxy_client_set_filter_type_comp; /*!< Event parameter of ESP_BLE_MESH_PROXY_CLIENT_SET_FILTER_TYPE_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROXY_CLIENT_ADD_FILTER_ADDR_COMP_EVT + */ + struct ble_mesh_proxy_client_add_filter_addr_comp_param { + int err_code; /*!< Indicate the result of Proxy Client add filter address */ + uint8_t conn_handle; /*!< Proxy connection handle */ + uint16_t net_idx; /*!< Corresponding NetKey Index */ + } proxy_client_add_filter_addr_comp; /*!< Event parameter of ESP_BLE_MESH_PROXY_CLIENT_ADD_FILTER_ADDR_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROXY_CLIENT_REMOVE_FILTER_ADDR_COMP_EVT + */ + struct ble_mesh_proxy_client_remove_filter_addr_comp_param { + int err_code; /*!< Indicate the result of Proxy Client remove filter address */ + uint8_t conn_handle; /*!< Proxy connection handle */ + uint16_t net_idx; /*!< Corresponding NetKey Index */ + } proxy_client_remove_filter_addr_comp; /*!< Event parameter of ESP_BLE_MESH_PROXY_CLIENT_REMOVE_FILTER_ADDR_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROXY_SERVER_CONNECTED_EVT + */ + struct ble_mesh_proxy_server_connected_param { + uint8_t conn_handle; /*!< Proxy connection handle */ + } proxy_server_connected; /*!< Event parameter of ESP_BLE_MESH_PROXY_SERVER_CONNECTED_EVT */ + /** + * @brief ESP_BLE_MESH_PROXY_SERVER_DISCONNECTED_EVT + */ + struct ble_mesh_proxy_server_disconnected_param { + uint8_t conn_handle; /*!< Proxy connection handle */ + uint8_t reason; /*!< Proxy disconnect reason */ + } proxy_server_disconnected; /*!< Event parameter of ESP_BLE_MESH_PROXY_SERVER_DISCONNECTED_EVT */ + /** + * @brief ESP_BLE_MESH_MODEL_SUBSCRIBE_GROUP_ADDR_COMP_EVT + */ + struct ble_mesh_model_sub_group_addr_comp_param { + int err_code; /*!< Indicate the result of local model subscribing group address */ + uint16_t element_addr; /*!< Element address */ + uint16_t company_id; /*!< Company ID */ + uint16_t model_id; /*!< Model ID */ + uint16_t group_addr; /*!< Group Address */ + } model_sub_group_addr_comp; /*!< Event parameters of ESP_BLE_MESH_MODEL_SUBSCRIBE_GROUP_ADDR_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_MODEL_UNSUBSCRIBE_GROUP_ADDR_COMP_EVT + */ + struct ble_mesh_model_unsub_group_addr_comp_param { + int err_code; /*!< Indicate the result of local model unsubscribing group address */ + uint16_t element_addr; /*!< Element address */ + uint16_t company_id; /*!< Company ID */ + uint16_t model_id; /*!< Model ID */ + uint16_t group_addr; /*!< Group Address */ + } model_unsub_group_addr_comp; /*!< Event parameters of ESP_BLE_MESH_MODEL_UNSUBSCRIBE_GROUP_ADDR_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_DEINIT_MESH_COMP_EVT + */ + struct ble_mesh_deinit_mesh_comp_param { + int err_code; /*!< Indicate the result of BLE Mesh deinitialization */ + } deinit_mesh_comp; /*!< Event parameter of ESP_BLE_MESH_DEINIT_MESH_COMP_EVT */ +} esp_ble_mesh_prov_cb_param_t; + +/** + * @brief BLE Mesh models related Model ID and Opcode definitions + */ + +/*!< Foundation Models */ +#define ESP_BLE_MESH_MODEL_ID_CONFIG_SRV 0x0000 +#define ESP_BLE_MESH_MODEL_ID_CONFIG_CLI 0x0001 +#define ESP_BLE_MESH_MODEL_ID_HEALTH_SRV 0x0002 +#define ESP_BLE_MESH_MODEL_ID_HEALTH_CLI 0x0003 + +/*!< Models from the Mesh Model Specification */ +#define ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_SRV 0x1000 +#define ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_CLI 0x1001 +#define ESP_BLE_MESH_MODEL_ID_GEN_LEVEL_SRV 0x1002 +#define ESP_BLE_MESH_MODEL_ID_GEN_LEVEL_CLI 0x1003 +#define ESP_BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_SRV 0x1004 +#define ESP_BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_CLI 0x1005 +#define ESP_BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SRV 0x1006 +#define ESP_BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SETUP_SRV 0x1007 +#define ESP_BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_CLI 0x1008 +#define ESP_BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SRV 0x1009 +#define ESP_BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SETUP_SRV 0x100a +#define ESP_BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_CLI 0x100b +#define ESP_BLE_MESH_MODEL_ID_GEN_BATTERY_SRV 0x100c +#define ESP_BLE_MESH_MODEL_ID_GEN_BATTERY_CLI 0x100d +#define ESP_BLE_MESH_MODEL_ID_GEN_LOCATION_SRV 0x100e +#define ESP_BLE_MESH_MODEL_ID_GEN_LOCATION_SETUP_SRV 0x100f +#define ESP_BLE_MESH_MODEL_ID_GEN_LOCATION_CLI 0x1010 +#define ESP_BLE_MESH_MODEL_ID_GEN_ADMIN_PROP_SRV 0x1011 +#define ESP_BLE_MESH_MODEL_ID_GEN_MANUFACTURER_PROP_SRV 0x1012 +#define ESP_BLE_MESH_MODEL_ID_GEN_USER_PROP_SRV 0x1013 +#define ESP_BLE_MESH_MODEL_ID_GEN_CLIENT_PROP_SRV 0x1014 +#define ESP_BLE_MESH_MODEL_ID_GEN_PROP_CLI 0x1015 +#define ESP_BLE_MESH_MODEL_ID_SENSOR_SRV 0x1100 +#define ESP_BLE_MESH_MODEL_ID_SENSOR_SETUP_SRV 0x1101 +#define ESP_BLE_MESH_MODEL_ID_SENSOR_CLI 0x1102 +#define ESP_BLE_MESH_MODEL_ID_TIME_SRV 0x1200 +#define ESP_BLE_MESH_MODEL_ID_TIME_SETUP_SRV 0x1201 +#define ESP_BLE_MESH_MODEL_ID_TIME_CLI 0x1202 +#define ESP_BLE_MESH_MODEL_ID_SCENE_SRV 0x1203 +#define ESP_BLE_MESH_MODEL_ID_SCENE_SETUP_SRV 0x1204 +#define ESP_BLE_MESH_MODEL_ID_SCENE_CLI 0x1205 +#define ESP_BLE_MESH_MODEL_ID_SCHEDULER_SRV 0x1206 +#define ESP_BLE_MESH_MODEL_ID_SCHEDULER_SETUP_SRV 0x1207 +#define ESP_BLE_MESH_MODEL_ID_SCHEDULER_CLI 0x1208 +#define ESP_BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SRV 0x1300 +#define ESP_BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SETUP_SRV 0x1301 +#define ESP_BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_CLI 0x1302 +#define ESP_BLE_MESH_MODEL_ID_LIGHT_CTL_SRV 0x1303 +#define ESP_BLE_MESH_MODEL_ID_LIGHT_CTL_SETUP_SRV 0x1304 +#define ESP_BLE_MESH_MODEL_ID_LIGHT_CTL_CLI 0x1305 +#define ESP_BLE_MESH_MODEL_ID_LIGHT_CTL_TEMP_SRV 0x1306 +#define ESP_BLE_MESH_MODEL_ID_LIGHT_HSL_SRV 0x1307 +#define ESP_BLE_MESH_MODEL_ID_LIGHT_HSL_SETUP_SRV 0x1308 +#define ESP_BLE_MESH_MODEL_ID_LIGHT_HSL_CLI 0x1309 +#define ESP_BLE_MESH_MODEL_ID_LIGHT_HSL_HUE_SRV 0x130a +#define ESP_BLE_MESH_MODEL_ID_LIGHT_HSL_SAT_SRV 0x130b +#define ESP_BLE_MESH_MODEL_ID_LIGHT_XYL_SRV 0x130c +#define ESP_BLE_MESH_MODEL_ID_LIGHT_XYL_SETUP_SRV 0x130d +#define ESP_BLE_MESH_MODEL_ID_LIGHT_XYL_CLI 0x130e +#define ESP_BLE_MESH_MODEL_ID_LIGHT_LC_SRV 0x130f +#define ESP_BLE_MESH_MODEL_ID_LIGHT_LC_SETUP_SRV 0x1310 +#define ESP_BLE_MESH_MODEL_ID_LIGHT_LC_CLI 0x1311 + +/** + * esp_ble_mesh_opcode_config_client_get_t belongs to esp_ble_mesh_opcode_t, this typedef is only + * used to locate the opcodes used by esp_ble_mesh_config_client_get_state. + * The following opcodes will only be used in the esp_ble_mesh_config_client_get_state function. + */ +typedef uint32_t esp_ble_mesh_opcode_config_client_get_t; + +#define ESP_BLE_MESH_MODEL_OP_BEACON_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x09) /*!< Config Beacon Get */ +#define ESP_BLE_MESH_MODEL_OP_COMPOSITION_DATA_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x08) /*!< Config Composition Data Get */ +#define ESP_BLE_MESH_MODEL_OP_DEFAULT_TTL_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x0C) /*!< Config Default TTL Get */ +#define ESP_BLE_MESH_MODEL_OP_GATT_PROXY_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x12) /*!< Config GATT Proxy Get */ +#define ESP_BLE_MESH_MODEL_OP_RELAY_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x26) /*!< Config Relay Get */ +#define ESP_BLE_MESH_MODEL_OP_MODEL_PUB_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x18) /*!< Config Model Publication Get */ +#define ESP_BLE_MESH_MODEL_OP_FRIEND_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x0F) /*!< Config Friend Get */ +#define ESP_BLE_MESH_MODEL_OP_HEARTBEAT_PUB_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x38) /*!< Config Heartbeat Publication Get */ +#define ESP_BLE_MESH_MODEL_OP_HEARTBEAT_SUB_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x3a) /*!< Config Heartbeat Subscription Get */ +#define ESP_BLE_MESH_MODEL_OP_NET_KEY_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x42) /*!< Config NetKey Get */ +#define ESP_BLE_MESH_MODEL_OP_APP_KEY_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x01) /*!< Config AppKey Get */ +#define ESP_BLE_MESH_MODEL_OP_NODE_IDENTITY_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x46) /*!< Config Node Identity Get */ +#define ESP_BLE_MESH_MODEL_OP_SIG_MODEL_SUB_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x29) /*!< Config SIG Model Subscription Get */ +#define ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_SUB_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x2B) /*!< Config Vendor Model Subscription Get */ +#define ESP_BLE_MESH_MODEL_OP_SIG_MODEL_APP_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x4B) /*!< Config SIG Model App Get */ +#define ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_APP_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x4D) /*!< Config Vendor Model App Get */ +#define ESP_BLE_MESH_MODEL_OP_KEY_REFRESH_PHASE_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x15) /*!< Config Key Refresh Phase Get */ +#define ESP_BLE_MESH_MODEL_OP_LPN_POLLTIMEOUT_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x2D) /*!< Config Low Power Node PollTimeout Get */ +#define ESP_BLE_MESH_MODEL_OP_NETWORK_TRANSMIT_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x23) /*!< Config Network Transmit Get */ + +/** + * esp_ble_mesh_opcode_config_client_set_t belongs to esp_ble_mesh_opcode_t, this typedef is + * only used to locate the opcodes used by esp_ble_mesh_config_client_set_state. + * The following opcodes will only be used in the esp_ble_mesh_config_client_set_state function. + */ +typedef uint32_t esp_ble_mesh_opcode_config_client_set_t; + +#define ESP_BLE_MESH_MODEL_OP_BEACON_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x0A) /*!< Config Beacon Set */ +#define ESP_BLE_MESH_MODEL_OP_DEFAULT_TTL_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x0D) /*!< Config Default TTL Set */ +#define ESP_BLE_MESH_MODEL_OP_GATT_PROXY_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x13) /*!< Config GATT Proxy Set */ +#define ESP_BLE_MESH_MODEL_OP_RELAY_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x27) /*!< Config Relay Set */ +#define ESP_BLE_MESH_MODEL_OP_MODEL_PUB_SET ESP_BLE_MESH_MODEL_OP_1(0x03) /*!< Config Model Publication Set */ +#define ESP_BLE_MESH_MODEL_OP_MODEL_SUB_ADD ESP_BLE_MESH_MODEL_OP_2(0x80, 0x1B) /*!< Config Model Subscription Add */ +#define ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_ADD ESP_BLE_MESH_MODEL_OP_2(0x80, 0x20) /*!< Config Model Subscription Virtual Address Add */ +#define ESP_BLE_MESH_MODEL_OP_MODEL_SUB_DELETE ESP_BLE_MESH_MODEL_OP_2(0x80, 0x1C) /*!< Config Model Subscription Delete */ +#define ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_DELETE ESP_BLE_MESH_MODEL_OP_2(0x80, 0x21) /*!< Config Model Subscription Virtual Address Delete */ +#define ESP_BLE_MESH_MODEL_OP_MODEL_SUB_OVERWRITE ESP_BLE_MESH_MODEL_OP_2(0x80, 0x1E) /*!< Config Model Subscription Overwrite */ +#define ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_OVERWRITE ESP_BLE_MESH_MODEL_OP_2(0x80, 0x22) /*!< Config Model Subscription Virtual Address Overwrite */ +#define ESP_BLE_MESH_MODEL_OP_NET_KEY_ADD ESP_BLE_MESH_MODEL_OP_2(0x80, 0x40) /*!< Config NetKey Add */ +#define ESP_BLE_MESH_MODEL_OP_APP_KEY_ADD ESP_BLE_MESH_MODEL_OP_1(0x00) /*!< Config AppKey Add */ +#define ESP_BLE_MESH_MODEL_OP_MODEL_APP_BIND ESP_BLE_MESH_MODEL_OP_2(0x80, 0x3D) /*!< Config Model App Bind */ +#define ESP_BLE_MESH_MODEL_OP_NODE_RESET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x49) /*!< Config Node Reset */ +#define ESP_BLE_MESH_MODEL_OP_FRIEND_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x10) /*!< Config Friend Set */ +#define ESP_BLE_MESH_MODEL_OP_HEARTBEAT_PUB_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x39) /*!< Config Heartbeat Publication Set */ +#define ESP_BLE_MESH_MODEL_OP_HEARTBEAT_SUB_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x3B) /*!< Config Heartbeat Subscription Set */ +#define ESP_BLE_MESH_MODEL_OP_NET_KEY_UPDATE ESP_BLE_MESH_MODEL_OP_2(0x80, 0x45) /*!< Config NetKey Update */ +#define ESP_BLE_MESH_MODEL_OP_NET_KEY_DELETE ESP_BLE_MESH_MODEL_OP_2(0x80, 0x41) /*!< Config NetKey Delete */ +#define ESP_BLE_MESH_MODEL_OP_APP_KEY_UPDATE ESP_BLE_MESH_MODEL_OP_1(0x01) /*!< Config AppKey Update */ +#define ESP_BLE_MESH_MODEL_OP_APP_KEY_DELETE ESP_BLE_MESH_MODEL_OP_2(0x80, 0x00) /*!< Config AppKey Delete */ +#define ESP_BLE_MESH_MODEL_OP_NODE_IDENTITY_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x47) /*!< Config Node Identity Set */ +#define ESP_BLE_MESH_MODEL_OP_KEY_REFRESH_PHASE_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x16) /*!< Config Key Refresh Phase Set */ +#define ESP_BLE_MESH_MODEL_OP_MODEL_PUB_VIRTUAL_ADDR_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x1A) /*!< Config Model Publication Virtual Address Set */ +#define ESP_BLE_MESH_MODEL_OP_MODEL_SUB_DELETE_ALL ESP_BLE_MESH_MODEL_OP_2(0x80, 0x1D) /*!< Config Model Subscription Delete All */ +#define ESP_BLE_MESH_MODEL_OP_MODEL_APP_UNBIND ESP_BLE_MESH_MODEL_OP_2(0x80, 0x3F) /*!< Config Model App Unbind */ +#define ESP_BLE_MESH_MODEL_OP_NETWORK_TRANSMIT_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x24) /*!< Config Network Transmit Set */ + +/** + * esp_ble_mesh_opcode_config_status_t belongs to esp_ble_mesh_opcode_t, this typedef is only + * used to locate the opcodes used by the Config Model messages + * The following opcodes are used by the BLE Mesh Config Server Model internally to respond + * to the Config Client Model's request messages. + */ +typedef uint32_t esp_ble_mesh_opcode_config_status_t; + +#define ESP_BLE_MESH_MODEL_OP_BEACON_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x0B) +#define ESP_BLE_MESH_MODEL_OP_COMPOSITION_DATA_STATUS ESP_BLE_MESH_MODEL_OP_1(0x02) +#define ESP_BLE_MESH_MODEL_OP_DEFAULT_TTL_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x0E) +#define ESP_BLE_MESH_MODEL_OP_GATT_PROXY_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x14) +#define ESP_BLE_MESH_MODEL_OP_RELAY_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x28) +#define ESP_BLE_MESH_MODEL_OP_MODEL_PUB_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x19) +#define ESP_BLE_MESH_MODEL_OP_MODEL_SUB_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x1F) +#define ESP_BLE_MESH_MODEL_OP_SIG_MODEL_SUB_LIST ESP_BLE_MESH_MODEL_OP_2(0x80, 0x2A) +#define ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_SUB_LIST ESP_BLE_MESH_MODEL_OP_2(0x80, 0x2C) +#define ESP_BLE_MESH_MODEL_OP_NET_KEY_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x44) +#define ESP_BLE_MESH_MODEL_OP_NET_KEY_LIST ESP_BLE_MESH_MODEL_OP_2(0x80, 0x43) +#define ESP_BLE_MESH_MODEL_OP_APP_KEY_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x03) +#define ESP_BLE_MESH_MODEL_OP_APP_KEY_LIST ESP_BLE_MESH_MODEL_OP_2(0x80, 0x02) +#define ESP_BLE_MESH_MODEL_OP_NODE_IDENTITY_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x48) +#define ESP_BLE_MESH_MODEL_OP_MODEL_APP_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x3E) +#define ESP_BLE_MESH_MODEL_OP_SIG_MODEL_APP_LIST ESP_BLE_MESH_MODEL_OP_2(0x80, 0x4C) +#define ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_APP_LIST ESP_BLE_MESH_MODEL_OP_2(0x80, 0x4E) +#define ESP_BLE_MESH_MODEL_OP_NODE_RESET_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x4A) +#define ESP_BLE_MESH_MODEL_OP_FRIEND_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x11) +#define ESP_BLE_MESH_MODEL_OP_KEY_REFRESH_PHASE_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x17) +#define ESP_BLE_MESH_MODEL_OP_HEARTBEAT_PUB_STATUS ESP_BLE_MESH_MODEL_OP_1(0x06) +#define ESP_BLE_MESH_MODEL_OP_HEARTBEAT_SUB_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x3C) +#define ESP_BLE_MESH_MODEL_OP_LPN_POLLTIMEOUT_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x2E) +#define ESP_BLE_MESH_MODEL_OP_NETWORK_TRANSMIT_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x25) + +/** + * This typedef is only used to indicate the status code contained in some of + * the Configuration Server Model status message. + */ +typedef uint8_t esp_ble_mesh_cfg_status_t; + +#define ESP_BLE_MESH_CFG_STATUS_SUCCESS 0x00 +#define ESP_BLE_MESH_CFG_STATUS_INVALID_ADDRESS 0x01 +#define ESP_BLE_MESH_CFG_STATUS_INVALID_MODEL 0x02 +#define ESP_BLE_MESH_CFG_STATUS_INVALID_APPKEY 0x03 +#define ESP_BLE_MESH_CFG_STATUS_INVALID_NETKEY 0x04 +#define ESP_BLE_MESH_CFG_STATUS_INSUFFICIENT_RESOURCES 0x05 +#define ESP_BLE_MESH_CFG_STATUS_KEY_INDEX_ALREADY_STORED 0x06 +#define ESP_BLE_MESH_CFG_STATUS_INVALID_PUBLISH_PARAMETERS 0x07 +#define ESP_BLE_MESH_CFG_STATUS_NOT_A_SUBSCRIBE_MODEL 0x08 +#define ESP_BLE_MESH_CFG_STATUS_STORAGE_FAILURE 0x09 +#define ESP_BLE_MESH_CFG_STATUS_FEATURE_NOT_SUPPORTED 0x0A +#define ESP_BLE_MESH_CFG_STATUS_CANNOT_UPDATE 0x0B +#define ESP_BLE_MESH_CFG_STATUS_CANNOT_REMOVE 0x0C +#define ESP_BLE_MESH_CFG_STATUS_CANNOT_BIND 0x0D +#define ESP_BLE_MESH_CFG_STATUS_TEMP_UNABLE_TO_CHANGE_STATE 0x0E +#define ESP_BLE_MESH_CFG_STATUS_CANNOT_SET 0x0F +#define ESP_BLE_MESH_CFG_STATUS_UNSPECIFIED_ERROR 0x10 +#define ESP_BLE_MESH_CFG_STATUS_INVALID_BINDING 0x11 + +/** + * esp_ble_mesh_opcode_health_client_get_t belongs to esp_ble_mesh_opcode_t, this typedef is + * only used to locate the opcodes used by esp_ble_mesh_health_client_get_state. + * The following opcodes will only be used in the esp_ble_mesh_health_client_get_state function. + */ +typedef uint32_t esp_ble_mesh_opcode_health_client_get_t; + +#define ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x31) /*!< Health Fault Get */ +#define ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x34) /*!< Health Period Get */ +#define ESP_BLE_MESH_MODEL_OP_ATTENTION_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x04) /*!< Health Attention Get */ + +/** + * esp_ble_mesh_opcode_health_client_set_t belongs to esp_ble_mesh_opcode_t, this typedef is + * only used to locate the opcodes used by esp_ble_mesh_health_client_set_state. + * The following opcodes will only be used in the esp_ble_mesh_health_client_set_state function. + */ +typedef uint32_t esp_ble_mesh_opcode_health_client_set_t; + +#define ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR ESP_BLE_MESH_MODEL_OP_2(0x80, 0x2F) /*!< Health Fault Clear */ +#define ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR_UNACK ESP_BLE_MESH_MODEL_OP_2(0x80, 0x30) /*!< Health Fault Clear Unacknowledged */ +#define ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST ESP_BLE_MESH_MODEL_OP_2(0x80, 0x32) /*!< Health Fault Test */ +#define ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST_UNACK ESP_BLE_MESH_MODEL_OP_2(0x80, 0x33) /*!< Health Fault Test Unacknowledged */ +#define ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x35) /*!< Health Period Set */ +#define ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x80, 0x36) /*!< Health Period Set Unacknowledged */ +#define ESP_BLE_MESH_MODEL_OP_ATTENTION_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x05) /*!< Health Attention Set */ +#define ESP_BLE_MESH_MODEL_OP_ATTENTION_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x80, 0x06) /*!< Health Attention Set Unacknowledged */ + +/** + * esp_ble_mesh_health_model_status_t belongs to esp_ble_mesh_opcode_t, this typedef is + * only used to locate the opcodes used by the Health Model messages. + * The following opcodes are used by the BLE Mesh Health Server Model internally to + * respond to the Health Client Model's request messages. + */ +typedef uint32_t esp_ble_mesh_health_model_status_t; + +#define ESP_BLE_MESH_MODEL_OP_HEALTH_CURRENT_STATUS ESP_BLE_MESH_MODEL_OP_1(0x04) +#define ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_STATUS ESP_BLE_MESH_MODEL_OP_1(0x05) +#define ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x37) +#define ESP_BLE_MESH_MODEL_OP_ATTENTION_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x07) + +/** + * esp_ble_mesh_generic_message_opcode_t belongs to esp_ble_mesh_opcode_t, this typedef is + * only used to locate the opcodes used by functions esp_ble_mesh_generic_client_get_state + * & esp_ble_mesh_generic_client_set_state. + */ +typedef uint32_t esp_ble_mesh_generic_message_opcode_t; + +/*!< Generic OnOff Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x01) +#define ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x02) +#define ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x03) +#define ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x04) + +/*!< Generic Level Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_GEN_LEVEL_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x05) +#define ESP_BLE_MESH_MODEL_OP_GEN_LEVEL_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x06) +#define ESP_BLE_MESH_MODEL_OP_GEN_LEVEL_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x07) +#define ESP_BLE_MESH_MODEL_OP_GEN_LEVEL_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x08) +#define ESP_BLE_MESH_MODEL_OP_GEN_DELTA_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x09) +#define ESP_BLE_MESH_MODEL_OP_GEN_DELTA_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x0A) +#define ESP_BLE_MESH_MODEL_OP_GEN_MOVE_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x0B) +#define ESP_BLE_MESH_MODEL_OP_GEN_MOVE_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x0C) + +/*!< Generic Default Transition Time Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x0D) +#define ESP_BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x0E) +#define ESP_BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x0F) +#define ESP_BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x10) + +/*!< Generic Power OnOff Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_GEN_ONPOWERUP_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x11) +#define ESP_BLE_MESH_MODEL_OP_GEN_ONPOWERUP_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x12) + +/*!< Generic Power OnOff Setup Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_GEN_ONPOWERUP_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x13) +#define ESP_BLE_MESH_MODEL_OP_GEN_ONPOWERUP_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x14) + +/*!< Generic Power Level Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x15) +#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x16) +#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x17) +#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x18) +#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_LAST_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x19) +#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_LAST_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x1A) +#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x1B) +#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x1C) +#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_RANGE_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x1D) +#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_RANGE_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x1E) + +/*!< Generic Power Level Setup Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x1F) +#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x20) +#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_RANGE_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x21) +#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_RANGE_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x22) + +/*!< Generic Battery Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_GEN_BATTERY_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x23) +#define ESP_BLE_MESH_MODEL_OP_GEN_BATTERY_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x24) + +/*!< Generic Location Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x25) +#define ESP_BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_STATUS ESP_BLE_MESH_MODEL_OP_1(0x40) +#define ESP_BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x26) +#define ESP_BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x27) + +/*!< Generic Location Setup Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_SET ESP_BLE_MESH_MODEL_OP_1(0x41) +#define ESP_BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_SET_UNACK ESP_BLE_MESH_MODEL_OP_1(0x42) +#define ESP_BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x28) +#define ESP_BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x29) + +/*!< Generic Manufacturer Property Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTIES_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x2A) +#define ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTIES_STATUS ESP_BLE_MESH_MODEL_OP_1(0x43) +#define ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTY_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x2B) +#define ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTY_SET ESP_BLE_MESH_MODEL_OP_1(0x44) +#define ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTY_SET_UNACK ESP_BLE_MESH_MODEL_OP_1(0x45) +#define ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTY_STATUS ESP_BLE_MESH_MODEL_OP_1(0x46) + +/*!< Generic Admin Property Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTIES_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x2C) +#define ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTIES_STATUS ESP_BLE_MESH_MODEL_OP_1(0x47) +#define ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x2D) +#define ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET ESP_BLE_MESH_MODEL_OP_1(0x48) +#define ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET_UNACK ESP_BLE_MESH_MODEL_OP_1(0x49) +#define ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_STATUS ESP_BLE_MESH_MODEL_OP_1(0x4A) + +/*!< Generic User Property Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x2E) +#define ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_STATUS ESP_BLE_MESH_MODEL_OP_1(0x4B) +#define ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x2F) +#define ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET ESP_BLE_MESH_MODEL_OP_1(0x4C) +#define ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET_UNACK ESP_BLE_MESH_MODEL_OP_1(0x4D) +#define ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_STATUS ESP_BLE_MESH_MODEL_OP_1(0x4E) + +/*!< Generic Client Property Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_GEN_CLIENT_PROPERTIES_GET ESP_BLE_MESH_MODEL_OP_1(0x4F) +#define ESP_BLE_MESH_MODEL_OP_GEN_CLIENT_PROPERTIES_STATUS ESP_BLE_MESH_MODEL_OP_1(0x50) + +/** + * esp_ble_mesh_sensor_message_opcode_t belongs to esp_ble_mesh_opcode_t, this typedef is + * only used to locate the opcodes used by functions esp_ble_mesh_sensor_client_get_state + * & esp_ble_mesh_sensor_client_set_state. + */ +typedef uint32_t esp_ble_mesh_sensor_message_opcode_t; + +/*!< Sensor Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x30) +#define ESP_BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_STATUS ESP_BLE_MESH_MODEL_OP_1(0x51) +#define ESP_BLE_MESH_MODEL_OP_SENSOR_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x31) +#define ESP_BLE_MESH_MODEL_OP_SENSOR_STATUS ESP_BLE_MESH_MODEL_OP_1(0x52) +#define ESP_BLE_MESH_MODEL_OP_SENSOR_COLUMN_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x32) +#define ESP_BLE_MESH_MODEL_OP_SENSOR_COLUMN_STATUS ESP_BLE_MESH_MODEL_OP_1(0x53) +#define ESP_BLE_MESH_MODEL_OP_SENSOR_SERIES_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x33) +#define ESP_BLE_MESH_MODEL_OP_SENSOR_SERIES_STATUS ESP_BLE_MESH_MODEL_OP_1(0x54) + +/*!< Sensor Setup Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x34) +#define ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET ESP_BLE_MESH_MODEL_OP_1(0x55) +#define ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET_UNACK ESP_BLE_MESH_MODEL_OP_1(0x56) +#define ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_STATUS ESP_BLE_MESH_MODEL_OP_1(0x57) +#define ESP_BLE_MESH_MODEL_OP_SENSOR_SETTINGS_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x35) +#define ESP_BLE_MESH_MODEL_OP_SENSOR_SETTINGS_STATUS ESP_BLE_MESH_MODEL_OP_1(0x58) +#define ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x36) +#define ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET ESP_BLE_MESH_MODEL_OP_1(0x59) +#define ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET_UNACK ESP_BLE_MESH_MODEL_OP_1(0x5A) +#define ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_STATUS ESP_BLE_MESH_MODEL_OP_1(0x5B) + +/** + * esp_ble_mesh_time_scene_message_opcode_t belongs to esp_ble_mesh_opcode_t, this typedef is + * only used to locate the opcodes used by functions esp_ble_mesh_time_scene_client_get_state + * & esp_ble_mesh_time_scene_client_set_state. + */ +typedef uint32_t esp_ble_mesh_time_scene_message_opcode_t; + +/*!< Time Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_TIME_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x37) +#define ESP_BLE_MESH_MODEL_OP_TIME_SET ESP_BLE_MESH_MODEL_OP_1(0x5C) +#define ESP_BLE_MESH_MODEL_OP_TIME_STATUS ESP_BLE_MESH_MODEL_OP_1(0x5D) +#define ESP_BLE_MESH_MODEL_OP_TIME_ROLE_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x38) +#define ESP_BLE_MESH_MODEL_OP_TIME_ROLE_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x39) +#define ESP_BLE_MESH_MODEL_OP_TIME_ROLE_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x3A) +#define ESP_BLE_MESH_MODEL_OP_TIME_ZONE_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x3B) +#define ESP_BLE_MESH_MODEL_OP_TIME_ZONE_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x3C) +#define ESP_BLE_MESH_MODEL_OP_TIME_ZONE_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x3D) +#define ESP_BLE_MESH_MODEL_OP_TAI_UTC_DELTA_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x3E) +#define ESP_BLE_MESH_MODEL_OP_TAI_UTC_DELTA_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x3F) +#define ESP_BLE_MESH_MODEL_OP_TAI_UTC_DELTA_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x40) + +/*!< Scene Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_SCENE_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x41) +#define ESP_BLE_MESH_MODEL_OP_SCENE_RECALL ESP_BLE_MESH_MODEL_OP_2(0x82, 0x42) +#define ESP_BLE_MESH_MODEL_OP_SCENE_RECALL_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x43) +#define ESP_BLE_MESH_MODEL_OP_SCENE_STATUS ESP_BLE_MESH_MODEL_OP_1(0x5E) +#define ESP_BLE_MESH_MODEL_OP_SCENE_REGISTER_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x44) +#define ESP_BLE_MESH_MODEL_OP_SCENE_REGISTER_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x45) + +/*!< Scene Setup Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_SCENE_STORE ESP_BLE_MESH_MODEL_OP_2(0x82, 0x46) +#define ESP_BLE_MESH_MODEL_OP_SCENE_STORE_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x47) +#define ESP_BLE_MESH_MODEL_OP_SCENE_DELETE ESP_BLE_MESH_MODEL_OP_2(0x82, 0x9E) +#define ESP_BLE_MESH_MODEL_OP_SCENE_DELETE_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x9F) + +/*!< Scheduler Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x48) +#define ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_STATUS ESP_BLE_MESH_MODEL_OP_1(0x5F) +#define ESP_BLE_MESH_MODEL_OP_SCHEDULER_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x49) +#define ESP_BLE_MESH_MODEL_OP_SCHEDULER_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x4A) + +/*!< Scheduler Setup Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_SET ESP_BLE_MESH_MODEL_OP_1(0x60) +#define ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_SET_UNACK ESP_BLE_MESH_MODEL_OP_1(0x61) + +/** + * esp_ble_mesh_light_message_opcode_t belongs to esp_ble_mesh_opcode_t, this typedef is + * only used to locate the opcodes used by functions esp_ble_mesh_light_client_get_state + * & esp_ble_mesh_light_client_set_state. + */ +typedef uint32_t esp_ble_mesh_light_message_opcode_t; + +/*!< Light Lightness Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x4B) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x4C) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x4D) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x4E) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x4F) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x50) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x51) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x52) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LAST_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x53) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LAST_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x54) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x55) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x56) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x57) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x58) + +/*!< Light Lightness Setup Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x59) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x5A) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x5B) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x5C) + +/*!< Light CTL Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x5D) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x5E) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x5F) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x60) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x61) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x62) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x63) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x64) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x65) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x66) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x67) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x68) + +/*!< Light CTL Setup Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x69) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x6A) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x6B) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x6C) + +/*!< Light HSL Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x6D) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x6E) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x6F) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x70) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x71) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x72) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x73) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x74) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x75) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x76) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x77) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x78) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_TARGET_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x79) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_TARGET_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x7A) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x7B) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x7C) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x7D) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x7E) + +/*!< Light HSL Setup Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x7F) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x80) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x81) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x82) + +/*!< Light xyL Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x83) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x84) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x85) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x86) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_TARGET_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x87) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_TARGET_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x88) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x89) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x8A) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x8B) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x8C) + +/*!< Light xyL Setup Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x8D) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x8E) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x8F) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x90) + +/*!< Light Control Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_MODE_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x91) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_MODE_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x92) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_MODE_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x93) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_MODE_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x94) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_OM_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x95) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_OM_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x96) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_OM_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x97) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_OM_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x98) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x99) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x9A) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x9B) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x9C) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x9D) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET ESP_BLE_MESH_MODEL_OP_1(0x62) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET_UNACK ESP_BLE_MESH_MODEL_OP_1(0x63) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_STATUS ESP_BLE_MESH_MODEL_OP_1(0x64) + +typedef uint32_t esp_ble_mesh_opcode_t; +/*!< End of defines of esp_ble_mesh_opcode_t */ + +/** + * This typedef is only used to indicate the status code contained in some of the + * server models (e.g. Generic Server Model) status message. + */ +typedef uint8_t esp_ble_mesh_model_status_t; + +#define ESP_BLE_MESH_MODEL_STATUS_SUCCESS 0x00 +#define ESP_BLE_MESH_MODEL_STATUS_CANNOT_SET_RANGE_MIN 0x01 +#define ESP_BLE_MESH_MODEL_STATUS_CANNOT_SET_RANGE_MAX 0x02 + +/** + * @brief BLE Mesh client models related definitions + */ + +/** Client model Get/Set message opcode and corresponding Status message opcode */ +typedef struct { + uint32_t cli_op; /*!< The client message opcode */ + uint32_t status_op; /*!< The server status opcode corresponding to the client message opcode */ +} esp_ble_mesh_client_op_pair_t; + +/** Client Model user data context. */ +typedef struct { + esp_ble_mesh_model_t *model; /*!< Pointer to the client model. Initialized by the stack. */ + int op_pair_size; /*!< Size of the op_pair */ + const esp_ble_mesh_client_op_pair_t *op_pair; /*!< Table containing get/set message opcode and corresponding status message opcode */ + uint32_t publish_status; /*!< Callback used to handle the received unsolicited message. Initialized by the stack. */ + void *internal_data; /*!< Pointer to the internal data of client model */ + uint8_t msg_role; /*!< Role of the device (Node/Provisioner) that is going to send messages */ +} esp_ble_mesh_client_t; + +/** Common parameters of the messages sent by Client Model. */ +typedef struct { + esp_ble_mesh_opcode_t opcode; /*!< Message opcode */ + esp_ble_mesh_model_t *model; /*!< Pointer to the client model structure */ + esp_ble_mesh_msg_ctx_t ctx; /*!< The context used to send message */ + int32_t msg_timeout; /*!< Timeout value (ms) to get response to the sent message */ + /*!< Note: if using default timeout value in menuconfig, make sure to set this value to 0 */ + uint8_t msg_role; /*!< Role of the device - Node/Provisioner */ +} esp_ble_mesh_client_common_param_t; + +/** + * @brief BLE Mesh server models related definitions + */ + +/** This enum value is the flag of transition timer operation */ +enum { + ESP_BLE_MESH_SERVER_TRANS_TIMER_START, /* Proper transition timer has been started */ + ESP_BLE_MESH_SERVER_FLAG_MAX, +}; + +/** Parameters of the server model state transition */ +typedef struct { + bool just_started; /*!< Indicate if the state transition has just started */ + + uint8_t trans_time; /*!< State transition time */ + uint8_t remain_time; /*!< Remaining time of state transition */ + uint8_t delay; /*!< Delay before starting state transition */ + uint32_t quo_tt; /*!< Duration of each divided transition step */ + uint32_t counter; /*!< Number of steps which the transition duration is divided */ + uint32_t total_duration; /*!< State transition total duration */ + int64_t start_timestamp; /*!< Time when the state transition is started */ + + /** + * Flag used to indicate if the transition timer has been started internally. + * + * If the model which contains esp_ble_mesh_state_transition_t sets "set_auto_rsp" + * to ESP_BLE_MESH_SERVER_RSP_BY_APP, the handler of the timer shall be initialized + * by the users. + * + * And users can use this flag to indicate whether the timer is started or not. + */ + BLE_MESH_ATOMIC_DEFINE(flag, ESP_BLE_MESH_SERVER_FLAG_MAX); + struct k_delayed_work timer; /*!< Timer used for state transition */ +} esp_ble_mesh_state_transition_t; + +/** Parameters of the server model received last same set message. */ +typedef struct { + uint8_t tid; /*!< Transaction number of the last message */ + uint16_t src; /*!< Source address of the last message */ + uint16_t dst; /*!< Destination address of the last message */ + int64_t timestamp; /*!< Time when the last message is received */ +} esp_ble_mesh_last_msg_info_t; + +#define ESP_BLE_MESH_SERVER_RSP_BY_APP 0 /*!< Response need to be sent in the application */ +#define ESP_BLE_MESH_SERVER_AUTO_RSP 1 /*!< Response will be sent internally */ + +/** Parameters of the Server Model response control */ +typedef struct { + /** + * @brief BLE Mesh Server Response Option + * 1. If get_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, then the + * response of Client Get messages need to be replied by the application; + * 2. If get_auto_rsp is set to ESP_BLE_MESH_SERVER_AUTO_RSP, then the + * response of Client Get messages will be replied by the server models; + * 3. If set_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, then the + * response of Client Set messages need to be replied by the application; + * 4. If set_auto_rsp is set to ESP_BLE_MESH_SERVER_AUTO_RSP, then the + * response of Client Set messages will be replied by the server models; + * 5. If status_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, then the + * response of Server Status messages need to be replied by the application; + * 6. If status_auto_rsp is set to ESP_BLE_MESH_SERVER_AUTO_RSP, then the + * response of Server Status messages will be replied by the server models; + */ + uint8_t get_auto_rsp : 1, /*!< Response control for Client Get messages */ + set_auto_rsp : 1, /*!< Response control for Client Set messages */ + status_auto_rsp : 1; /*!< Response control for Server Status messages */ +} esp_ble_mesh_server_rsp_ctrl_t; + +/** + * @brief Server model state value union + */ +typedef union { + struct { + uint8_t onoff; /*!< The value of the Generic OnOff state */ + } gen_onoff; /*!< The Generic OnOff state */ + struct { + int16_t level; /*!< The value of the Generic Level state */ + } gen_level; /*!< The Generic Level state */ + struct { + uint8_t onpowerup; /*!< The value of the Generic OnPowerUp state */ + } gen_onpowerup; /*!< The Generic OnPowerUp state */ + struct { + uint16_t power; /*!< The value of the Generic Power Actual state */ + } gen_power_actual; /*!< The Generic Power Actual state */ + struct { + uint16_t lightness; /*!< The value of the Light Lightness Actual state */ + } light_lightness_actual; /*!< The Light Lightness Actual state */ + struct { + uint16_t lightness; /*!< The value of the Light Lightness Linear state */ + } light_lightness_linear; /*!< The Light Lightness Linear state */ + struct { + uint16_t lightness; /*!< The value of the Light CTL Lightness state */ + } light_ctl_lightness; /*!< The Light CTL Lightness state */ + struct { + uint16_t temperature; /*!< The value of the Light CTL Temperature state */ + int16_t delta_uv; /*!< The value of the Light CTL Delta UV state */ + } light_ctl_temp_delta_uv; /*!< The Light CTL Temperature & Delta UV states */ + struct { + uint16_t lightness; /*!< The value of the Light HSL Lightness state */ + uint16_t hue; /*!< The value of the Light HSL Hue state */ + uint16_t saturation; /*!< The value of the Light HSL Saturation state */ + } light_hsl; /*!< The Light HSL composite state */ + struct { + uint16_t lightness; /*!< The value of the Light HSL Lightness state */ + } light_hsl_lightness; /*!< The Light HSL Lightness state */ + struct { + uint16_t hue; /*!< The value of the Light HSL Hue state */ + } light_hsl_hue; /*!< The Light HSL Hue state */ + struct { + uint16_t saturation; /*!< The value of the Light HSL Saturation state */ + } light_hsl_saturation; /*!< The Light HSL Saturation state */ + struct { + uint16_t lightness; /*!< The value of the Light xyL Lightness state */ + } light_xyl_lightness; /*!< The Light xyL Lightness state */ + struct { + uint8_t onoff; /*!< The value of the Light LC Light OnOff state */ + } light_lc_light_onoff; /*!< The Light LC Light OnOff state */ +} esp_ble_mesh_server_state_value_t; + +/** This enum value is the type of server model states */ +typedef enum { + ESP_BLE_MESH_GENERIC_ONOFF_STATE, + ESP_BLE_MESH_GENERIC_LEVEL_STATE, + ESP_BLE_MESH_GENERIC_ONPOWERUP_STATE, + ESP_BLE_MESH_GENERIC_POWER_ACTUAL_STATE, + ESP_BLE_MESH_LIGHT_LIGHTNESS_ACTUAL_STATE, + ESP_BLE_MESH_LIGHT_LIGHTNESS_LINEAR_STATE, + ESP_BLE_MESH_LIGHT_CTL_LIGHTNESS_STATE, + ESP_BLE_MESH_LIGHT_CTL_TEMP_DELTA_UV_STATE, + ESP_BLE_MESH_LIGHT_HSL_STATE, + ESP_BLE_MESH_LIGHT_HSL_LIGHTNESS_STATE, + ESP_BLE_MESH_LIGHT_HSL_HUE_STATE, + ESP_BLE_MESH_LIGHT_HSL_SATURATION_STATE, + ESP_BLE_MESH_LIGHT_XYL_LIGHTNESS_STATE, + ESP_BLE_MESH_LIGHT_LC_LIGHT_ONOFF_STATE, + ESP_BLE_MESH_SERVER_MODEL_STATE_MAX, +} esp_ble_mesh_server_state_type_t; + +/*!< This enum value is the event of undefined SIG models and vendor models */ +typedef enum { + ESP_BLE_MESH_MODEL_OPERATION_EVT, /*!< User-defined models receive messages from peer devices (e.g. get, set, status, etc) event */ + ESP_BLE_MESH_MODEL_SEND_COMP_EVT, /*!< User-defined models send messages completion event */ + ESP_BLE_MESH_MODEL_PUBLISH_COMP_EVT, /*!< User-defined models publish messages completion event */ + ESP_BLE_MESH_CLIENT_MODEL_RECV_PUBLISH_MSG_EVT, /*!< User-defined client models receive publish messages event */ + ESP_BLE_MESH_CLIENT_MODEL_SEND_TIMEOUT_EVT, /*!< Timeout event for the user-defined client models that failed to receive response from peer server models */ + ESP_BLE_MESH_MODEL_PUBLISH_UPDATE_EVT, /*!< When a model is configured to publish messages periodically, this event will occur during every publish period */ + ESP_BLE_MESH_SERVER_MODEL_UPDATE_STATE_COMP_EVT, /*!< Server models update state value completion event */ + ESP_BLE_MESH_MODEL_EVT_MAX, +} esp_ble_mesh_model_cb_event_t; + +/** + * @brief BLE Mesh model callback parameters union + */ +typedef union { + /** + * @brief ESP_BLE_MESH_MODEL_OPERATION_EVT + */ + struct ble_mesh_model_operation_evt_param { + uint32_t opcode; /*!< Opcode of the received message */ + esp_ble_mesh_model_t *model; /*!< Pointer to the model which receives the message */ + esp_ble_mesh_msg_ctx_t *ctx; /*!< Pointer to the context of the received message */ + uint16_t length; /*!< Length of the received message */ + uint8_t *msg; /*!< Value of the received message */ + } model_operation; /*!< Event parameter of ESP_BLE_MESH_MODEL_OPERATION_EVT */ + /** + * @brief ESP_BLE_MESH_MODEL_SEND_COMP_EVT + */ + struct ble_mesh_model_send_comp_param { + int err_code; /*!< Indicate the result of sending a message */ + uint32_t opcode; /*!< Opcode of the message */ + esp_ble_mesh_model_t *model; /*!< Pointer to the model which sends the message */ + esp_ble_mesh_msg_ctx_t *ctx; /*!< Context of the message */ + } model_send_comp; /*!< Event parameter of ESP_BLE_MESH_MODEL_SEND_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_MODEL_PUBLISH_COMP_EVT + */ + struct ble_mesh_model_publish_comp_param { + int err_code; /*!< Indicate the result of publishing a message */ + esp_ble_mesh_model_t *model; /*!< Pointer to the model which publishes the message */ + } model_publish_comp; /*!< Event parameter of ESP_BLE_MESH_MODEL_PUBLISH_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_CLIENT_MODEL_RECV_PUBLISH_MSG_EVT + */ + struct ble_mesh_mod_recv_publish_msg_param { + uint32_t opcode; /*!< Opcode of the unsolicited received message */ + esp_ble_mesh_model_t *model; /*!< Pointer to the model which receives the message */ + esp_ble_mesh_msg_ctx_t *ctx; /*!< Pointer to the context of the message */ + uint16_t length; /*!< Length of the received message */ + uint8_t *msg; /*!< Value of the received message */ + } client_recv_publish_msg; /*!< Event parameter of ESP_BLE_MESH_CLIENT_MODEL_RECV_PUBLISH_MSG_EVT */ + /** + * @brief ESP_BLE_MESH_CLIENT_MODEL_SEND_TIMEOUT_EVT + */ + struct ble_mesh_client_model_send_timeout_param { + uint32_t opcode; /*!< Opcode of the previously sent message */ + esp_ble_mesh_model_t *model; /*!< Pointer to the model which sends the previous message */ + esp_ble_mesh_msg_ctx_t *ctx; /*!< Pointer to the context of the previous message */ + } client_send_timeout; /*!< Event parameter of ESP_BLE_MESH_CLIENT_MODEL_SEND_TIMEOUT_EVT */ + /** + * @brief ESP_BLE_MESH_MODEL_PUBLISH_UPDATE_EVT + */ + struct ble_mesh_model_publish_update_evt_param { + esp_ble_mesh_model_t *model; /*!< Pointer to the model which is going to update its publish message */ + } model_publish_update; /*!< Event parameter of ESP_BLE_MESH_MODEL_PUBLISH_UPDATE_EVT */ + /** + * @brief ESP_BLE_MESH_SERVER_MODEL_UPDATE_STATE_COMP_EVT + */ + struct ble_mesh_server_model_update_state_comp_param { + int err_code; /*!< Indicate the result of updating server model state */ + esp_ble_mesh_model_t *model; /*!< Pointer to the server model which state value is updated */ + esp_ble_mesh_server_state_type_t type; /*!< Type of the updated server state */ + } server_model_update_state; /*!< Event parameter of ESP_BLE_MESH_SERVER_MODEL_UPDATE_STATE_COMP_EVT */ +} esp_ble_mesh_model_cb_param_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _ESP_BLE_MESH_DEFS_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_config_model_api.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_config_model_api.h new file mode 100644 index 00000000000..31369d89567 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_config_model_api.h @@ -0,0 +1,817 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _ESP_BLE_MESH_CONFIG_MODEL_API_H_ +#define _ESP_BLE_MESH_CONFIG_MODEL_API_H_ + +#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. + * + * @note The Config Server Model can only be included by a Primary Element. + * + * @param srv_data Pointer to a unique Config Server Model user_data. + * + * @return New Config Server Model instance. + */ +#define ESP_BLE_MESH_MODEL_CFG_SRV(srv_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_CONFIG_SRV, \ + NULL, NULL, srv_data) + +/** @def ESP_BLE_MESH_MODEL_CFG_CLI + * + * @brief Define a new Config Client Model. + * + * @note The Config Client Model can only be included by a Primary Element. + * + * @param cli_data Pointer to a unique struct esp_ble_mesh_client_t. + * + * @return New Config Client Model instance. + */ +#define ESP_BLE_MESH_MODEL_CFG_CLI(cli_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_CONFIG_CLI, \ + NULL, NULL, cli_data) + +/** Configuration Server Model context */ +typedef struct esp_ble_mesh_cfg_srv { + esp_ble_mesh_model_t *model; /*!< Pointer to Configuration Server Model */ + + uint8_t net_transmit; /*!< Network Transmit state */ + uint8_t relay; /*!< Relay Mode state */ + uint8_t relay_retransmit; /*!< Relay Retransmit state */ + uint8_t beacon; /*!< Secure Network Beacon state */ + uint8_t gatt_proxy; /*!< GATT Proxy state */ + uint8_t friend_state; /*!< Friend state */ + uint8_t default_ttl; /*!< Default TTL */ + + /** Heartbeat Publication */ + struct { + struct k_delayed_work timer; /*!< Heartbeat Publication timer */ + + uint16_t dst; /*!< Destination address for Heartbeat messages */ + uint16_t count; /*!< Number of Heartbeat messages to be sent */ + uint8_t period; /*!< Period for sending Heartbeat messages */ + uint8_t ttl; /*!< TTL to be used when sending Heartbeat messages */ + uint16_t feature; /*!< Bit field indicating features that trigger Heartbeat messages when changed */ + uint16_t net_idx; /*!< NetKey Index used by Heartbeat Publication */ + } heartbeat_pub; + + /** Heartbeat Subscription */ + struct { + int64_t expiry; /*!< Timestamp when Heartbeat subscription period is expired */ + + uint16_t src; /*!< Source address for Heartbeat messages */ + uint16_t dst; /*!< Destination address for Heartbeat messages */ + uint16_t count; /*!< Number of Heartbeat messages received */ + uint8_t min_hops; /*!< Minimum hops when receiving Heartbeat messages */ + uint8_t max_hops; /*!< Maximum hops when receiving Heartbeat messages */ + + /** Optional heartbeat subscription tracking function */ + esp_ble_mesh_cb_t heartbeat_recv_cb; + } heartbeat_sub; +} esp_ble_mesh_cfg_srv_t; + +/** Parameters of Config Composition Data Get. */ +typedef struct { + uint8_t page; /*!< Page number of the Composition Data. */ +} esp_ble_mesh_cfg_composition_data_get_t; + +/** Parameters of Config Model Publication Get. */ +typedef struct { + uint16_t element_addr; /*!< The element address */ + uint16_t model_id; /*!< The model id */ + uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */ +} esp_ble_mesh_cfg_model_pub_get_t; + +/** Parameters of Config SIG Model Subscription Get. */ +typedef struct { + uint16_t element_addr; /*!< The element address */ + uint16_t model_id; /*!< The model id */ +} esp_ble_mesh_cfg_sig_model_sub_get_t; + +/** Parameters of Config Vendor Model Subscription Get. */ +typedef struct { + uint16_t element_addr; /*!< The element address */ + uint16_t model_id; /*!< The model id */ + uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */ +} esp_ble_mesh_cfg_vnd_model_sub_get_t; + +/** Parameters of Config AppKey Get. */ +typedef struct { + uint16_t net_idx; /*!< The network key index */ +} esp_ble_mesh_cfg_app_key_get_t; + +/** Parameters of Config Node Identity Get. */ +typedef struct { + uint16_t net_idx; /*!< The network key index */ +} esp_ble_mesh_cfg_node_identity_get_t; + +/** Parameters of Config SIG Model App Get. */ +typedef struct { + uint16_t element_addr; /*!< The element address */ + uint16_t model_id; /*!< The model id */ +} esp_ble_mesh_cfg_sig_model_app_get_t; + +/** Parameters of Config Vendor Model App Get. */ +typedef struct { + uint16_t element_addr; /*!< The element address */ + uint16_t model_id; /*!< The model id */ + uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */ +} esp_ble_mesh_cfg_vnd_model_app_get_t; + +/** Parameters of Config Key Refresh Phase Get. */ +typedef struct { + uint16_t net_idx; /*!< The network key index */ +} esp_ble_mesh_cfg_kr_phase_get_t; + +/** Parameters of Config Low Power Node PollTimeout Get. */ +typedef struct { + uint16_t lpn_addr; /*!< The unicast address of the Low Power node */ +} esp_ble_mesh_cfg_lpn_polltimeout_get_t; + +/** Parameters of Config Beacon Set. */ +typedef struct { + uint8_t beacon; /*!< New Secure Network Beacon state */ +} esp_ble_mesh_cfg_beacon_set_t; + +/** Parameters of Config Default TTL Set. */ +typedef struct { + uint8_t ttl; /*!< The default TTL state value */ +} esp_ble_mesh_cfg_default_ttl_set_t; + +/** Parameters of Config Friend Set. */ +typedef struct { + uint8_t friend_state; /*!< The friend state value */ +} esp_ble_mesh_cfg_friend_set_t; + +/** Parameters of Config GATT Proxy Set. */ +typedef struct { + uint8_t gatt_proxy; /*!< The GATT Proxy state value */ +} esp_ble_mesh_cfg_gatt_proxy_set_t; + +/** Parameters of Config Relay Set. */ +typedef struct { + uint8_t relay; /*!< The relay value */ + uint8_t relay_retransmit; /*!< The relay retransmit value */ +} esp_ble_mesh_cfg_relay_set_t; + +/** Parameters of Config NetKey Add. */ +typedef struct { + uint16_t net_idx; /*!< The network key index */ + uint8_t net_key[16]; /*!< The network key value */ +} esp_ble_mesh_cfg_net_key_add_t; + +/** Parameters of Config AppKey Add. */ +typedef struct { + uint16_t net_idx; /*!< The network key index */ + uint16_t app_idx; /*!< The app key index */ + uint8_t app_key[16]; /*!< The app key value */ +} esp_ble_mesh_cfg_app_key_add_t; + +/** Parameters of Config Model App Bind. */ +typedef struct { + uint16_t element_addr; /*!< The element address */ + uint16_t model_app_idx; /*!< Index of the app key to bind with the model */ + uint16_t model_id; /*!< The model id */ + uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */ +} esp_ble_mesh_cfg_model_app_bind_t; + +/** Parameters of Config Model Publication Set. */ +typedef struct { + uint16_t element_addr; /*!< The element address */ + uint16_t publish_addr; /*!< Value of the publish address */ + uint16_t publish_app_idx; /*!< Index of the application key */ + bool cred_flag; /*!< Value of the Friendship Credential Flag */ + uint8_t publish_ttl; /*!< Default TTL value for the publishing messages */ + uint8_t publish_period; /*!< Period for periodic status publishing */ + uint8_t publish_retransmit; /*!< Number of retransmissions and number of 50-millisecond steps between retransmissions */ + uint16_t model_id; /*!< The model id */ + uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */ +} esp_ble_mesh_cfg_model_pub_set_t; + +/** Parameters of Config Model Subscription Add. */ +typedef struct { + uint16_t element_addr; /*!< The element address */ + uint16_t sub_addr; /*!< The address to be added to the Subscription List */ + uint16_t model_id; /*!< The model id */ + uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */ +} esp_ble_mesh_cfg_model_sub_add_t; + +/** Parameters of Config Model Subscription Delete. */ +typedef struct { + uint16_t element_addr; /*!< The element address */ + uint16_t sub_addr; /*!< The address to be removed from the Subscription List */ + uint16_t model_id; /*!< The model id */ + uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */ +} esp_ble_mesh_cfg_model_sub_delete_t; + +/** Parameters of Config Model Subscription Overwrite. */ +typedef struct { + uint16_t element_addr; /*!< The element address */ + uint16_t sub_addr; /*!< The address to be added to the Subscription List */ + uint16_t model_id; /*!< The model id */ + uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */ +} esp_ble_mesh_cfg_model_sub_overwrite_t; + +/** Parameters of Config Model Subscription Virtual Address Add. */ +typedef struct { + uint16_t element_addr; /*!< The element address */ + uint8_t label_uuid[16]; /*!< The Label UUID of the virtual address to be added to the Subscription List */ + uint16_t model_id; /*!< The model id */ + uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */ +} esp_ble_mesh_cfg_model_sub_va_add_t; + +/** Parameters of Config Model Subscription Virtual Address Delete. */ +typedef struct { + uint16_t element_addr; /*!< The element address */ + uint8_t label_uuid[16]; /*!< The Label UUID of the virtual address to be removed from the Subscription List */ + uint16_t model_id; /*!< The model id */ + uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */ +} esp_ble_mesh_cfg_model_sub_va_delete_t; + +/** Parameters of Config Model Subscription Virtual Address Overwrite. */ +typedef struct { + uint16_t element_addr; /*!< The element address */ + uint8_t label_uuid[16]; /*!< The Label UUID of the virtual address to be added to the Subscription List */ + uint16_t model_id; /*!< The model id */ + uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */ +} esp_ble_mesh_cfg_model_sub_va_overwrite_t; + +/** Parameters of Config Model Publication Virtual Address Set. */ +typedef struct { + uint16_t element_addr; /*!< The element address */ + uint8_t label_uuid[16]; /*!< Value of the Label UUID publish address */ + uint16_t publish_app_idx; /*!< Index of the application key */ + bool cred_flag; /*!< Value of the Friendship Credential Flag */ + uint8_t publish_ttl; /*!< Default TTL value for the publishing messages */ + uint8_t publish_period; /*!< Period for periodic status publishing */ + uint8_t publish_retransmit; /*!< Number of retransmissions and number of 50-millisecond steps between retransmissions */ + uint16_t model_id; /*!< The model id */ + uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */ +} esp_ble_mesh_cfg_model_pub_va_set_t; + +/** Parameters of Config Model Subscription Delete All. */ +typedef struct { + uint16_t element_addr; /*!< The element address */ + uint16_t model_id; /*!< The model id */ + uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */ +} esp_ble_mesh_cfg_model_sub_delete_all_t; + +/** Parameters of Config NetKey Update. */ +typedef struct { + uint16_t net_idx; /*!< The network key index */ + uint8_t net_key[16]; /*!< The network key value */ +} esp_ble_mesh_cfg_net_key_update_t; + +/** Parameters of Config NetKey Delete. */ +typedef struct { + uint16_t net_idx; /*!< The network key index */ +} esp_ble_mesh_cfg_net_key_delete_t; + +/** Parameters of Config AppKey Update. */ +typedef struct { + uint16_t net_idx; /*!< The network key index */ + uint16_t app_idx; /*!< The app key index */ + uint8_t app_key[16]; /*!< The app key value */ +} esp_ble_mesh_cfg_app_key_update_t; + +/** Parameters of Config AppKey Delete. */ +typedef struct { + uint16_t net_idx; /*!< The network key index */ + uint16_t app_idx; /*!< The app key index */ +} esp_ble_mesh_cfg_app_key_delete_t; + +/** Parameters of Config Node Identity Set. */ +typedef struct { + uint16_t net_idx; /*!< The network key index */ + uint8_t identity; /*!< New Node Identity state */ +} esp_ble_mesh_cfg_node_identity_set_t; + +/** Parameters of Config Model App Unbind. */ +typedef struct { + uint16_t element_addr; /*!< The element address */ + uint16_t model_app_idx; /*!< Index of the app key to bind with the model */ + uint16_t model_id; /*!< The model id */ + uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */ +} esp_ble_mesh_cfg_model_app_unbind_t; + +/** Parameters of Config Key Refresh Phase Set. */ +typedef struct { + uint16_t net_idx; /*!< The network key index */ + uint8_t transition; /*!< New Key Refresh Phase Transition */ +} esp_ble_mesh_cfg_kr_phase_set_t; + +/** Parameters of Config Network Transmit Set. */ +typedef struct { + uint8_t net_transmit; /*!< Network Transmit State */ +} esp_ble_mesh_cfg_net_transmit_set_t; + +/** Parameters of Config Model Heartbeat Publication Set. */ +typedef struct { + uint16_t dst; /*!< Destination address for Heartbeat messages */ + uint8_t count; /*!< Number of Heartbeat messages to be sent */ + uint8_t period; /*!< Period for sending Heartbeat messages */ + uint8_t ttl; /*!< TTL to be used when sending Heartbeat messages */ + uint16_t feature; /*!< Bit field indicating features that trigger Heartbeat messages when changed */ + uint16_t net_idx; /*!< NetKey Index */ +} esp_ble_mesh_cfg_heartbeat_pub_set_t; + +/** Parameters of Config Model Heartbeat Subscription Set. */ +typedef struct { + uint16_t src; /*!< Source address for Heartbeat messages */ + uint16_t dst; /*!< Destination address for Heartbeat messages */ + uint8_t period; /*!< Period for receiving Heartbeat messages */ +} esp_ble_mesh_cfg_heartbeat_sub_set_t; + +/** + * @brief For ESP_BLE_MESH_MODEL_OP_BEACON_GET + * ESP_BLE_MESH_MODEL_OP_COMPOSITION_DATA_GET + * ESP_BLE_MESH_MODEL_OP_DEFAULT_TTL_GET + * ESP_BLE_MESH_MODEL_OP_GATT_PROXY_GET + * ESP_BLE_MESH_MODEL_OP_RELAY_GET + * ESP_BLE_MESH_MODEL_OP_MODEL_PUB_GET + * ESP_BLE_MESH_MODEL_OP_FRIEND_GET + * ESP_BLE_MESH_MODEL_OP_HEARTBEAT_PUB_GET + * ESP_BLE_MESH_MODEL_OP_HEARTBEAT_SUB_GET + * the get_state parameter in the esp_ble_mesh_config_client_get_state function should not be set to NULL. + */ +typedef union { + esp_ble_mesh_cfg_model_pub_get_t model_pub_get; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_PUB_GET. */ + esp_ble_mesh_cfg_composition_data_get_t comp_data_get; /*!< For ESP_BLE_MESH_MODEL_OP_COMPOSITION_DATA_GET. */ + esp_ble_mesh_cfg_sig_model_sub_get_t sig_model_sub_get; /*!< For ESP_BLE_MESH_MODEL_OP_SIG_MODEL_SUB_GET */ + esp_ble_mesh_cfg_vnd_model_sub_get_t vnd_model_sub_get; /*!< For ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_SUB_GET */ + esp_ble_mesh_cfg_app_key_get_t app_key_get; /*!< For ESP_BLE_MESH_MODEL_OP_APP_KEY_GET. */ + esp_ble_mesh_cfg_node_identity_get_t node_identity_get; /*!< For ESP_BLE_MESH_MODEL_OP_NODE_IDENTITY_GET. */ + esp_ble_mesh_cfg_sig_model_app_get_t sig_model_app_get; /*!< For ESP_BLE_MESH_MODEL_OP_SIG_MODEL_APP_GET */ + esp_ble_mesh_cfg_vnd_model_app_get_t vnd_model_app_get; /*!< For ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_APP_GET */ + esp_ble_mesh_cfg_kr_phase_get_t kr_phase_get; /*!< For ESP_BLE_MESH_MODEL_OP_KEY_REFRESH_PHASE_GET */ + esp_ble_mesh_cfg_lpn_polltimeout_get_t lpn_pollto_get; /*!< For ESP_BLE_MESH_MODEL_OP_LPN_POLLTIMEOUT_GET */ +} esp_ble_mesh_cfg_client_get_state_t; + +/** + * @brief For ESP_BLE_MESH_MODEL_OP_BEACON_SET + * ESP_BLE_MESH_MODEL_OP_DEFAULT_TTL_SET + * ESP_BLE_MESH_MODEL_OP_GATT_PROXY_SET + * ESP_BLE_MESH_MODEL_OP_RELAY_SET + * ESP_BLE_MESH_MODEL_OP_MODEL_PUB_SET + * ESP_BLE_MESH_MODEL_OP_MODEL_SUB_ADD + * ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_ADD + * ESP_BLE_MESH_MODEL_OP_MODEL_SUB_DELETE + * ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_DELETE + * ESP_BLE_MESH_MODEL_OP_MODEL_SUB_OVERWRITE + * ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_OVERWRITE + * ESP_BLE_MESH_MODEL_OP_NET_KEY_ADD + * ESP_BLE_MESH_MODEL_OP_APP_KEY_ADD + * ESP_BLE_MESH_MODEL_OP_MODEL_APP_BIND + * ESP_BLE_MESH_MODEL_OP_NODE_RESET + * ESP_BLE_MESH_MODEL_OP_FRIEND_SET + * ESP_BLE_MESH_MODEL_OP_HEARTBEAT_PUB_SET + * ESP_BLE_MESH_MODEL_OP_HEARTBEAT_SUB_SET + * the set_state parameter in the esp_ble_mesh_config_client_set_state function should not be set to NULL. + */ +typedef union { + esp_ble_mesh_cfg_beacon_set_t beacon_set; /*!< For ESP_BLE_MESH_MODEL_OP_BEACON_SET */ + esp_ble_mesh_cfg_default_ttl_set_t default_ttl_set; /*!< For ESP_BLE_MESH_MODEL_OP_DEFAULT_TTL_SET */ + esp_ble_mesh_cfg_friend_set_t friend_set; /*!< For ESP_BLE_MESH_MODEL_OP_FRIEND_SET */ + esp_ble_mesh_cfg_gatt_proxy_set_t gatt_proxy_set; /*!< For ESP_BLE_MESH_MODEL_OP_GATT_PROXY_SET */ + esp_ble_mesh_cfg_relay_set_t relay_set; /*!< For ESP_BLE_MESH_MODEL_OP_RELAY_SET */ + esp_ble_mesh_cfg_net_key_add_t net_key_add; /*!< For ESP_BLE_MESH_MODEL_OP_NET_KEY_ADD */ + esp_ble_mesh_cfg_app_key_add_t app_key_add; /*!< For ESP_BLE_MESH_MODEL_OP_APP_KEY_ADD */ + esp_ble_mesh_cfg_model_app_bind_t model_app_bind; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_APP_BIND */ + esp_ble_mesh_cfg_model_pub_set_t model_pub_set; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_PUB_SET */ + esp_ble_mesh_cfg_model_sub_add_t model_sub_add; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_SUB_ADD */ + esp_ble_mesh_cfg_model_sub_delete_t model_sub_delete; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_SUB_DELETE */ + esp_ble_mesh_cfg_model_sub_overwrite_t model_sub_overwrite; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_SUB_OVERWRITE */ + esp_ble_mesh_cfg_model_sub_va_add_t model_sub_va_add; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_ADD */ + esp_ble_mesh_cfg_model_sub_va_delete_t model_sub_va_delete; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_DELETE */ + esp_ble_mesh_cfg_model_sub_va_overwrite_t model_sub_va_overwrite; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_OVERWRITE */ + esp_ble_mesh_cfg_heartbeat_pub_set_t heartbeat_pub_set; /*!< For ESP_BLE_MESH_MODEL_OP_HEARTBEAT_PUB_SET */ + esp_ble_mesh_cfg_heartbeat_sub_set_t heartbeat_sub_set; /*!< For ESP_BLE_MESH_MODEL_OP_HEARTBEAT_SUB_SET */ + esp_ble_mesh_cfg_model_pub_va_set_t model_pub_va_set; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_PUB_VIRTUAL_ADDR_SET */ + esp_ble_mesh_cfg_model_sub_delete_all_t model_sub_delete_all; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_SUB_DELETE_ALL */ + esp_ble_mesh_cfg_net_key_update_t net_key_update; /*!< For ESP_BLE_MESH_MODEL_OP_NET_KEY_UPDATE */ + esp_ble_mesh_cfg_net_key_delete_t net_key_delete; /*!< For ESP_BLE_MESH_MODEL_OP_NET_KEY_DELETE */ + esp_ble_mesh_cfg_app_key_update_t app_key_update; /*!< For ESP_BLE_MESH_MODEL_OP_APP_KEY_UPDATE */ + esp_ble_mesh_cfg_app_key_delete_t app_key_delete; /*!< For ESP_BLE_MESH_MODEL_OP_APP_KEY_DELETE */ + esp_ble_mesh_cfg_node_identity_set_t node_identity_set; /*!< For ESP_BLE_MESH_MODEL_OP_NODE_IDENTITY_SET */ + esp_ble_mesh_cfg_model_app_unbind_t model_app_unbind; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_APP_UNBIND */ + esp_ble_mesh_cfg_kr_phase_set_t kr_phase_set; /*!< For ESP_BLE_MESH_MODEL_OP_KEY_REFRESH_PHASE_SET */ + esp_ble_mesh_cfg_net_transmit_set_t net_transmit_set; /*!< For ESP_BLE_MESH_MODEL_OP_NETWORK_TRANSMIT_SET */ +} esp_ble_mesh_cfg_client_set_state_t; + +/** Parameter of Config Beacon Status */ +typedef struct { + uint8_t beacon; /*!< Secure Network Beacon state value */ +} esp_ble_mesh_cfg_beacon_status_cb_t; + +/** Parameters of Config Composition Data Status */ +typedef struct { + uint8_t page; /*!< Page number of the Composition Data */ + struct net_buf_simple *composition_data; /*!< Pointer to Composition Data for the identified page */ +} esp_ble_mesh_cfg_comp_data_status_cb_t; + +/** Parameter of Config Default TTL Status */ +typedef struct { + uint8_t default_ttl; /*!< Default TTL state value */ +} esp_ble_mesh_cfg_default_ttl_status_cb_t; + +/** Parameter of Config GATT Proxy Status */ +typedef struct { + uint8_t gatt_proxy; /*!< GATT Proxy state value */ +} esp_ble_mesh_cfg_gatt_proxy_status_cb_t; + +/** Parameters of Config Relay Status */ +typedef struct { + uint8_t relay; /*!< Relay state value */ + uint8_t retransmit; /*!< Relay retransmit value(number of retransmissions and number of 10-millisecond steps between retransmissions) */ +} esp_ble_mesh_cfg_relay_status_cb_t; + +/** Parameters of Config Model Publication Status */ +typedef struct { + uint8_t status; /*!< Status Code for the request message */ + uint16_t element_addr; /*!< Address of the element */ + uint16_t publish_addr; /*!< Value of the publish address */ + uint16_t app_idx; /*!< Index of the application key */ + bool cred_flag; /*!< Value of the Friendship Credential Flag */ + uint8_t ttl; /*!< Default TTL value for the outgoing messages */ + uint8_t period; /*!< Period for periodic status publishing */ + uint8_t transmit; /*!< Number of retransmissions and number of 50-millisecond steps between retransmissions */ + uint16_t company_id; /*!< Company ID */ + uint16_t model_id; /*!< Model ID */ +} esp_ble_mesh_cfg_model_pub_status_cb_t; + +/** Parameters of Config Model Subscription Status */ +typedef struct { + uint8_t status; /*!< Status Code for the request message */ + uint16_t element_addr; /*!< Address of the element */ + uint16_t sub_addr; /*!< Value of the address */ + uint16_t company_id; /*!< Company ID */ + uint16_t model_id; /*!< Model ID */ +} esp_ble_mesh_cfg_model_sub_status_cb_t; + +/** Parameters of Config NetKey Status */ +typedef struct { + uint8_t status; /*!< Status Code for the request message */ + uint16_t net_idx; /*!< Index of the NetKey */ +} esp_ble_mesh_cfg_net_key_status_cb_t; + +/** Parameters of Config AppKey Status */ +typedef struct { + uint8_t status; /*!< Status Code for the request message */ + uint16_t net_idx; /*!< Index of the NetKey */ + uint16_t app_idx; /*!< Index of the application key */ +} esp_ble_mesh_cfg_app_key_status_cb_t; + +/** Parameters of Config Model App Status */ +typedef struct { + uint8_t status; /*!< Status Code for the request message */ + uint16_t element_addr; /*!< Address of the element */ + uint16_t app_idx; /*!< Index of the application key */ + uint16_t company_id; /*!< Company ID */ + uint16_t model_id; /*!< Model ID */ +} esp_ble_mesh_cfg_mod_app_status_cb_t; + +/** Parameter of Config Friend Status */ +typedef struct { + uint8_t friend_state; /*!< Friend state value */ +} esp_ble_mesh_cfg_friend_status_cb_t; + +/** Parameters of Config Heartbeat Publication Status */ +typedef struct { + uint8_t status; /*!< Status Code for the request message */ + uint16_t dst; /*!< Destination address for Heartbeat messages */ + uint8_t count; /*!< Number of Heartbeat messages remaining to be sent */ + uint8_t period; /*!< Period for sending Heartbeat messages */ + uint8_t ttl; /*!< TTL to be used when sending Heartbeat messages */ + uint16_t features; /*!< Features that trigger Heartbeat messages when changed */ + uint16_t net_idx; /*!< Index of the NetKey */ +} esp_ble_mesh_cfg_hb_pub_status_cb_t; + +/** Parameters of Config Heartbeat Subscription Status */ +typedef struct { + uint8_t status; /*!< Status Code for the request message */ + uint16_t src; /*!< Source address for Heartbeat messages */ + uint16_t dst; /*!< Destination address for Heartbeat messages */ + uint8_t period; /*!< Remaining Period for processing Heartbeat messages */ + uint8_t count; /*!< Number of Heartbeat messages received */ + uint8_t min_hops; /*!< Minimum hops when receiving Heartbeat messages */ + uint8_t max_hops; /*!< Maximum hops when receiving Heartbeat messages */ +} esp_ble_mesh_cfg_hb_sub_status_cb_t; + +/** 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 */ +} esp_ble_mesh_cfg_net_trans_status_cb_t; + +/** Parameters of Config SIG/Vendor Subscription List */ +typedef struct { + uint8_t status; /*!< Status Code for the request message */ + uint16_t element_addr; /*!< Address of the element */ + uint16_t company_id; /*!< Company ID */ + uint16_t model_id; /*!< Model ID */ + struct net_buf_simple *sub_addr; /*!< A block of all addresses from the Subscription List */ +} esp_ble_mesh_cfg_model_sub_list_cb_t; + +/** Parameter of Config NetKey List */ +typedef struct { + struct net_buf_simple *net_idx; /*!< A list of NetKey Indexes known to the node */ +} esp_ble_mesh_cfg_net_key_list_cb_t; + +/** Parameters of Config AppKey List */ +typedef struct { + uint8_t status; /*!< Status Code for the request message */ + uint16_t net_idx; /*!< NetKey Index of the NetKey that the AppKeys are bound to */ + struct net_buf_simple *app_idx; /*!< A list of AppKey indexes that are bound to the NetKey identified by NetKeyIndex */ +} esp_ble_mesh_cfg_app_key_list_cb_t; + +/** Parameters of Config Node Identity Status */ +typedef struct { + uint8_t status; /*!< Status Code for the request message */ + uint16_t net_idx; /*!< Index of the NetKey */ + uint8_t identity; /*!< Node Identity state */ +} esp_ble_mesh_cfg_node_id_status_cb_t; + +/** Parameters of Config SIG/Vendor Model App List */ +typedef struct { + uint8_t status; /*!< Status Code for the request message */ + uint16_t element_addr; /*!< Address of the element */ + uint16_t company_id; /*!< Company ID */ + uint16_t model_id; /*!< Model ID */ + struct net_buf_simple *app_idx; /*!< All AppKey indexes bound to the Model */ +} esp_ble_mesh_cfg_model_app_list_cb_t; + +/** Parameters of Config Key Refresh Phase Status */ +typedef struct { + uint8_t status; /*!< Status Code for the request message */ + uint16_t net_idx; /*!< Index of the NetKey */ + uint8_t phase; /*!< Key Refresh Phase state */ +} esp_ble_mesh_cfg_kr_phase_status_cb_t; + +/** Parameters of Config Low Power Node PollTimeout Status */ +typedef struct { + uint16_t lpn_addr; /*!< The unicast address of the Low Power node */ + int32_t poll_timeout; /*!< The current value of the PollTimeout timer of the Low Power node */ +} esp_ble_mesh_cfg_lpn_pollto_status_cb_t; + +/** + * @brief Configuration Client Model received message union + */ +typedef union { + esp_ble_mesh_cfg_beacon_status_cb_t beacon_status; /*!< The beacon status value */ + esp_ble_mesh_cfg_comp_data_status_cb_t comp_data_status; /*!< The composition data status value */ + esp_ble_mesh_cfg_default_ttl_status_cb_t default_ttl_status; /*!< The default_ttl status value */ + esp_ble_mesh_cfg_gatt_proxy_status_cb_t gatt_proxy_status; /*!< The gatt_proxy status value */ + esp_ble_mesh_cfg_relay_status_cb_t relay_status; /*!< The relay status value */ + esp_ble_mesh_cfg_model_pub_status_cb_t model_pub_status; /*!< The model publication status value */ + esp_ble_mesh_cfg_model_sub_status_cb_t model_sub_status; /*!< The model subscription status value */ + esp_ble_mesh_cfg_net_key_status_cb_t netkey_status; /*!< The netkey status value */ + esp_ble_mesh_cfg_app_key_status_cb_t appkey_status; /*!< The appkey status value */ + esp_ble_mesh_cfg_mod_app_status_cb_t model_app_status; /*!< The model app status value */ + esp_ble_mesh_cfg_friend_status_cb_t friend_status; /*!< The friend status value */ + esp_ble_mesh_cfg_hb_pub_status_cb_t heartbeat_pub_status; /*!< The heartbeat publication status value */ + esp_ble_mesh_cfg_hb_sub_status_cb_t heartbeat_sub_status; /*!< The heartbeat subscription status value */ + esp_ble_mesh_cfg_net_trans_status_cb_t net_transmit_status; /*!< The network transmit status value */ + esp_ble_mesh_cfg_model_sub_list_cb_t model_sub_list; /*!< The model subscription list value */ + esp_ble_mesh_cfg_net_key_list_cb_t netkey_list; /*!< The network key index list value */ + esp_ble_mesh_cfg_app_key_list_cb_t appkey_list; /*!< The application key index list value */ + esp_ble_mesh_cfg_node_id_status_cb_t node_identity_status; /*!< The node identity status value */ + esp_ble_mesh_cfg_model_app_list_cb_t model_app_list; /*!< The model application key index list value */ + esp_ble_mesh_cfg_kr_phase_status_cb_t kr_phase_status; /*!< The key refresh phase status value */ + esp_ble_mesh_cfg_lpn_pollto_status_cb_t lpn_timeout_status; /*!< The low power node poll timeout status value */ +} esp_ble_mesh_cfg_client_common_cb_param_t; + +/** Configuration Client Model callback parameters */ +typedef struct { + int error_code; /*!< Appropriate error code */ + esp_ble_mesh_client_common_param_t *params; /*!< The client common parameters */ + esp_ble_mesh_cfg_client_common_cb_param_t status_cb; /*!< The config status message callback values */ +} esp_ble_mesh_cfg_client_cb_param_t; + +/** This enum value is the event of Configuration Client Model */ +typedef enum { + ESP_BLE_MESH_CFG_CLIENT_GET_STATE_EVT, + ESP_BLE_MESH_CFG_CLIENT_SET_STATE_EVT, + ESP_BLE_MESH_CFG_CLIENT_PUBLISH_EVT, + ESP_BLE_MESH_CFG_CLIENT_TIMEOUT_EVT, + ESP_BLE_MESH_CFG_CLIENT_EVT_MAX, +} esp_ble_mesh_cfg_client_cb_event_t; + +/** + * @brief Configuration Server model related context. + */ + +typedef struct { + 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 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_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; + +/** + * @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; /*!< 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 */ +typedef enum { + ESP_BLE_MESH_CFG_SERVER_STATE_CHANGE_EVT, + ESP_BLE_MESH_CFG_SERVER_EVT_MAX, +} esp_ble_mesh_cfg_server_cb_event_t; + +/** + * @brief Bluetooth Mesh Config Client and Server Model functions. + */ + +/** + * @brief Configuration Client Model callback function type + * @param event: Event type + * @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); + +/** + * @brief Configuration Server Model callback function type + * @param event: Event type + * @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); + +/** + * @brief Register BLE Mesh Config Client 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_config_client_callback(esp_ble_mesh_cfg_client_cb_t callback); + +/** + * @brief Register BLE Mesh Config 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_config_server_callback(esp_ble_mesh_cfg_server_cb_t callback); + +/** + * @brief Get the value of Config Server Model states using the Config Client Model get messages. + * + * @note If you want to find the opcodes and corresponding meanings accepted by this API, + * please refer to esp_ble_mesh_opcode_config_client_get_t in esp_ble_mesh_defs.h + * + * @param[in] params: Pointer to BLE Mesh common client parameters. + * @param[in] get_state: Pointer to a union, each kind of opcode corresponds to one structure inside. + * Shall not be set to NULL. + * + * @return ESP_OK on success or error code otherwise. + * + */ +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); + +/** + * @brief Set the value of the Configuration Server Model states using the Config Client Model set messages. + * + * @note If you want to find the opcodes and corresponding meanings accepted by this API, + * please refer to esp_ble_mesh_opcode_config_client_set_t in esp_ble_mesh_defs.h + * + * @param[in] params: Pointer to BLE Mesh common client parameters. + * @param[in] set_state: Pointer to a union, each kind of opcode corresponds to one structure inside. + * Shall not be set to NULL. + * + * @return ESP_OK on success or error code otherwise. + * + */ +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); + +#ifdef __cplusplus +} +#endif + +#endif /* _ESP_BLE_MESH_CONFIG_MODEL_API_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_generic_model_api.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_generic_model_api.h new file mode 100644 index 00000000000..fc4808af411 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_generic_model_api.h @@ -0,0 +1,1296 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** @file + * @brief Bluetooth Mesh Generic Client Model APIs. + */ + +#ifndef _ESP_BLE_MESH_GENERIC_MODEL_API_H_ +#define _ESP_BLE_MESH_GENERIC_MODEL_API_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. + * + * @note This API needs to be called for each element on which + * the application needs to have a Generic OnOff Client Model. + * + * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t. + * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t. + * + * @return New Generic OnOff Client Model instance. + */ +#define ESP_BLE_MESH_MODEL_GEN_ONOFF_CLI(cli_pub, cli_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_CLI, \ + NULL, cli_pub, cli_data) + +/** @def ESP_BLE_MESH_MODEL_GEN_LEVEL_CLI + * + * @brief Define a new Generic Level Client Model. + * + * @note This API needs to be called for each element on which + * the application needs to have a Generic Level Client Model. + * + * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t. + * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t. + * + * @return New Generic Level Client Model instance. + */ + +#define ESP_BLE_MESH_MODEL_GEN_LEVEL_CLI(cli_pub, cli_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_LEVEL_CLI, \ + NULL, cli_pub, cli_data) + +/** @def ESP_BLE_MESH_MODEL_GEN_DEF_TRANS_TIME_CLI + * + * @brief Define a new Generic Default Transition Time Client Model. + * + * @note This API needs to be called for each element on which + * the application needs to have a Generic Default Transition + * Time Client Model. + * + * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t. + * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t. + * + * @return New Generic Default Transition Time Client Model instance. + */ +#define ESP_BLE_MESH_MODEL_GEN_DEF_TRANS_TIME_CLI(cli_pub, cli_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_CLI, \ + NULL, cli_pub, cli_data) + +/** @def ESP_BLE_MESH_MODEL_GEN_POWER_ONOFF_CLI + * + * @brief Define a new Generic Power OnOff Client Model. + * + * @note This API needs to be called for each element on which + * the application needs to have a Generic Power OnOff Client Model. + * + * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t. + * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t. + * + * @return New Generic Power OnOff Client Model instance. + */ +#define ESP_BLE_MESH_MODEL_GEN_POWER_ONOFF_CLI(cli_pub, cli_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_CLI, \ + NULL, cli_pub, cli_data) + +/** @def ESP_BLE_MESH_MODEL_GEN_POWER_LEVEL_CLI + * + * @brief Define a new Generic Power Level Client Model. + * + * @note This API needs to be called for each element on which + * the application needs to have a Generic Power Level Client Model. + * + * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t. + * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t. + * + * @return New Generic Power Level Client Model instance. + */ +#define ESP_BLE_MESH_MODEL_GEN_POWER_LEVEL_CLI(cli_pub, cli_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_CLI, \ + NULL, cli_pub, cli_data) + +/** @def ESP_BLE_MESH_MODEL_GEN_BATTERY_CLI + * + * @brief Define a new Generic Battery Client Model. + * + * @note This API needs to be called for each element on which + * the application needs to have a Generic Battery Client Model. + * + * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t. + * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t. + * + * @return New Generic Battery Client Model instance. + */ +#define ESP_BLE_MESH_MODEL_GEN_BATTERY_CLI(cli_pub, cli_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_BATTERY_CLI, \ + NULL, cli_pub, cli_data) + +/** @def ESP_BLE_MESH_MODEL_GEN_LOCATION_CLI + * + * @brief Define a new Generic Location Client Model. + * + * @note This API needs to be called for each element on which + * the application needs to have a Generic Location Client Model. + * + * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t. + * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t. + * + * @return New Generic Location Client Model instance. + */ +#define ESP_BLE_MESH_MODEL_GEN_LOCATION_CLI(cli_pub, cli_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_LOCATION_CLI, \ + NULL, cli_pub, cli_data) + +/** @def ESP_BLE_MESH_MODEL_GEN_PROPERTY_CLI + * + * @brief Define a new Generic Property Client Model. + * + * @note This API needs to be called for each element on which + * the application needs to have a Generic Property Client Model. + * + * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t. + * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t. + * + * @return New Generic Location Client Model instance. + */ +#define ESP_BLE_MESH_MODEL_GEN_PROPERTY_CLI(cli_pub, cli_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_PROP_CLI, \ + NULL, cli_pub, cli_data) + +/** + * @brief Bluetooth Mesh Generic Client Model Get and Set parameters structure. + */ + +/** Parameters of Generic OnOff Set. */ +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_gen_onoff_set_t; + +/** Parameters of Generic Level Set. */ +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_gen_level_set_t; + +/** Parameters of Generic Delta Set. */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + int32_t 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_gen_delta_set_t; + +/** Parameters of Generic Move Set. */ +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_gen_move_set_t; + +/** Parameter of Generic Default Transition Time Set. */ +typedef struct { + uint8_t trans_time; /*!< The value of the Generic Default Transition Time state */ +} esp_ble_mesh_gen_def_trans_time_set_t; + +/** Parameter of Generic OnPowerUp Set. */ +typedef struct { + uint8_t onpowerup; /*!< The value of the Generic OnPowerUp state */ +} esp_ble_mesh_gen_onpowerup_set_t; + +/** Parameters of Generic Power Level Set. */ +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_gen_power_level_set_t; + +/** Parameter of Generic Power Default Set. */ +typedef struct { + uint16_t power; /*!< The value of the Generic Power Default state */ +} esp_ble_mesh_gen_power_default_set_t; + +/** Parameters of Generic Power Range Set. */ +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_gen_power_range_set_t; + +/** Parameters of Generic Location Global Set. */ +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_gen_loc_global_set_t; + +/** Parameters of Generic Location Local Set. */ +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_gen_loc_local_set_t; + +/** Parameter of Generic User Property Get. */ +typedef struct { + uint16_t property_id; /*!< Property ID identifying a Generic User Property */ +} esp_ble_mesh_gen_user_property_get_t; + +/** Parameters of Generic User Property Set. */ +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_gen_user_property_set_t; + +/** Parameter of Generic Admin Property Get. */ +typedef struct { + uint16_t property_id; /*!< Property ID identifying a Generic Admin Property */ +} esp_ble_mesh_gen_admin_property_get_t; + +/** 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 access */ + struct net_buf_simple *property_value; /*!< Raw value for the Admin Property */ +} esp_ble_mesh_gen_admin_property_set_t; + +/** Parameter of Generic Manufacturer Property Get. */ +typedef struct { + uint16_t property_id; /*!< Property ID identifying a Generic Manufacturer Property */ +} esp_ble_mesh_gen_manufacturer_property_get_t; + +/** Parameters of Generic Manufacturer Property Set. */ +typedef struct { + uint16_t property_id; /*!< Property ID identifying a Generic Manufacturer Property */ + uint8_t user_access; /*!< Enumeration indicating user access */ +} esp_ble_mesh_gen_manufacturer_property_set_t; + +/** Parameter of Generic Client Properties Get. */ +typedef struct { + uint16_t property_id; /*!< A starting Client Property ID present within an element */ +} esp_ble_mesh_gen_client_properties_get_t; + +/** + * @brief Generic Client Model get message union + */ +typedef union { + esp_ble_mesh_gen_user_property_get_t user_property_get; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_GET */ + esp_ble_mesh_gen_admin_property_get_t admin_property_get; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_GET*/ + esp_ble_mesh_gen_manufacturer_property_get_t manufacturer_property_get; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTY_SET */ + esp_ble_mesh_gen_client_properties_get_t client_properties_get; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_CLIENT_PROPERTIES_GET */ +} esp_ble_mesh_generic_client_get_state_t; + +/** + * @brief Generic Client Model set message union + */ +typedef union { + esp_ble_mesh_gen_onoff_set_t onoff_set; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_SET & ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_SET_UNACK */ + esp_ble_mesh_gen_level_set_t level_set; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_LEVEL_SET & ESP_BLE_MESH_MODEL_OP_GEN_LEVEL_SET_UNACK */ + esp_ble_mesh_gen_delta_set_t delta_set; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_DELTA_SET & ESP_BLE_MESH_MODEL_OP_GEN_DELTA_SET_UNACK */ + esp_ble_mesh_gen_move_set_t move_set; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_MOVE_SET & ESP_BLE_MESH_MODEL_OP_GEN_MOVE_SET_UNACK */ + esp_ble_mesh_gen_def_trans_time_set_t def_trans_time_set; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_SET & ESP_BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_SET_UNACK */ + esp_ble_mesh_gen_onpowerup_set_t power_set; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_ONPOWERUP_SET & ESP_BLE_MESH_MODEL_OP_GEN_ONPOWERUP_SET_UNACK */ + esp_ble_mesh_gen_power_level_set_t power_level_set; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_SET & ESP_BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_SET_UNACK */ + esp_ble_mesh_gen_power_default_set_t power_default_set; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_SET & ESP_BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_SET_UNACK */ + esp_ble_mesh_gen_power_range_set_t power_range_set; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_POWER_RANGE_SET & ESP_BLE_MESH_MODEL_OP_GEN_POWER_RANGE_SET_UNACK */ + esp_ble_mesh_gen_loc_global_set_t loc_global_set; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_SET & ESP_BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_SET_UNACK */ + esp_ble_mesh_gen_loc_local_set_t loc_local_set; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_SET & ESP_BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_SET_UNACK */ + esp_ble_mesh_gen_user_property_set_t user_property_set; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET & ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET_UNACK */ + esp_ble_mesh_gen_admin_property_set_t admin_property_set; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET & ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET_UNACK */ + esp_ble_mesh_gen_manufacturer_property_set_t manufacturer_property_set; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTY_SET & ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTY_SET_UNACK */ +} esp_ble_mesh_generic_client_set_state_t; + +/** + * @brief Bluetooth Mesh Generic Client Model Get and Set callback parameters structure. + */ + +/** Parameters of Generic OnOff Status. */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint8_t present_onoff; /*!< Current value of Generic OnOff state */ + uint8_t target_onoff; /*!< Target value of Generic OnOff state (optional) */ + uint8_t remain_time; /*!< Time to complete state transition (C.1) */ +} esp_ble_mesh_gen_onoff_status_cb_t; + +/** Parameters of Generic Level Status. */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + int16_t present_level; /*!< Current value of Generic Level state */ + int16_t target_level; /*!< Target value of the Generic Level state (optional) */ + uint8_t remain_time; /*!< Time to complete state transition (C.1) */ +} esp_ble_mesh_gen_level_status_cb_t; + +/** Parameter of Generic Default Transition Time Status. */ +typedef struct { + uint8_t trans_time; /*!< The value of the Generic Default Transition Time state */ +} esp_ble_mesh_gen_def_trans_time_status_cb_t; + +/** Parameter of Generic OnPowerUp Status. */ +typedef struct { + uint8_t onpowerup; /*!< The value of the Generic OnPowerUp state */ +} esp_ble_mesh_gen_onpowerup_status_cb_t; + +/** Parameters of Generic Power Level Status. */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t present_power; /*!< Current value of Generic Power Actual state */ + uint16_t target_power; /*!< Target value of Generic Power Actual state (optional) */ + uint8_t remain_time; /*!< Time to complete state transition (C.1) */ +} esp_ble_mesh_gen_power_level_status_cb_t; + +/** Parameter of Generic Power Last Status. */ +typedef struct { + uint16_t power; /*!< The value of the Generic Power Last state */ +} esp_ble_mesh_gen_power_last_status_cb_t; + +/** Parameter of Generic Power Default Status. */ +typedef struct { + uint16_t power; /*!< The value of the Generic Default Last state */ +} esp_ble_mesh_gen_power_default_status_cb_t; + +/** Parameters of Generic Power Range Status. */ +typedef struct { + uint8_t status_code; /*!< Status Code for the request message */ + 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_gen_power_range_status_cb_t; + +/** Parameters of Generic Battery Status. */ +typedef struct { + uint32_t battery_level : 8; /*!< Value of Generic Battery Level state */ + uint32_t time_to_discharge : 24; /*!< Value of Generic Battery Time to Discharge state */ + uint32_t time_to_charge : 24; /*!< Value of Generic Battery Time to Charge state */ + uint32_t flags : 8; /*!< Value of Generic Battery Flags state */ +} esp_ble_mesh_gen_battery_status_cb_t; + +/** Parameters of Generic Location Global Status. */ +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_gen_loc_global_status_cb_t; + +/** Parameters of Generic Location Local Status. */ +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_gen_loc_local_status_cb_t; + +/** Parameter of Generic User Properties Status. */ +typedef struct { + struct net_buf_simple *property_ids; /*!< Buffer contains a sequence of N User Property IDs */ +} esp_ble_mesh_gen_user_properties_status_cb_t; + +/** Parameters of Generic User Property Status. */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t property_id; /*!< Property ID identifying a Generic User Property */ + uint8_t user_access; /*!< Enumeration indicating user access (optional) */ + struct net_buf_simple *property_value; /*!< Raw value for the User Property (C.1) */ +} esp_ble_mesh_gen_user_property_status_cb_t; + +/** Parameter of Generic Admin Properties Status. */ +typedef struct { + struct net_buf_simple *property_ids; /*!< Buffer contains a sequence of N Admin Property IDs */ +} esp_ble_mesh_gen_admin_properties_status_cb_t; + +/** Parameters of Generic Admin Property Status. */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t property_id; /*!< Property ID identifying a Generic Admin Property */ + uint8_t user_access; /*!< Enumeration indicating user access (optional) */ + struct net_buf_simple *property_value; /*!< Raw value for the Admin Property (C.1) */ +} esp_ble_mesh_gen_admin_property_status_cb_t; + +/** Parameter of Generic Manufacturer Properties Status. */ +typedef struct { + struct net_buf_simple *property_ids; /*!< Buffer contains a sequence of N Manufacturer Property IDs */ +} esp_ble_mesh_gen_manufacturer_properties_status_cb_t; + +/** Parameters of Generic Manufacturer Property Status. */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t property_id; /*!< Property ID identifying a Generic Manufacturer Property */ + uint8_t user_access; /*!< Enumeration indicating user access (optional) */ + struct net_buf_simple *property_value; /*!< Raw value for the Manufacturer Property (C.1) */ +} esp_ble_mesh_gen_manufacturer_property_status_cb_t; + +/** Parameter of Generic Client Properties Status. */ +typedef struct { + struct net_buf_simple *property_ids; /*!< Buffer contains a sequence of N Client Property IDs */ +} esp_ble_mesh_gen_client_properties_status_cb_t; + +/** + * @brief Generic Client Model received message union + */ +typedef union { + esp_ble_mesh_gen_onoff_status_cb_t onoff_status; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_STATUS */ + esp_ble_mesh_gen_level_status_cb_t level_status; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_LEVEL_STATUS */ + esp_ble_mesh_gen_def_trans_time_status_cb_t def_trans_time_status; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_STATUS */ + esp_ble_mesh_gen_onpowerup_status_cb_t onpowerup_status; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_ONPOWERUP_STATUS */ + esp_ble_mesh_gen_power_level_status_cb_t power_level_status; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_STATUS */ + esp_ble_mesh_gen_power_last_status_cb_t power_last_status; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_POWER_LAST_STATUS */ + esp_ble_mesh_gen_power_default_status_cb_t power_default_status; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_STATUS */ + esp_ble_mesh_gen_power_range_status_cb_t power_range_status; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_POWER_RANGE_STATUS */ + esp_ble_mesh_gen_battery_status_cb_t battery_status; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_BATTERY_STATUS */ + esp_ble_mesh_gen_loc_global_status_cb_t location_global_status; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_STATUS */ + esp_ble_mesh_gen_loc_local_status_cb_t location_local_status; /*!< ESP_BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_STATUS */ + esp_ble_mesh_gen_user_properties_status_cb_t user_properties_status; /*!< ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_STATUS */ + esp_ble_mesh_gen_user_property_status_cb_t user_property_status; /*!< ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_STATUS */ + esp_ble_mesh_gen_admin_properties_status_cb_t admin_properties_status; /*!< ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTIES_STATUS */ + esp_ble_mesh_gen_admin_property_status_cb_t admin_property_status; /*!< ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_STATUS */ + esp_ble_mesh_gen_manufacturer_properties_status_cb_t manufacturer_properties_status; /*!< ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTIES_STATUS */ + esp_ble_mesh_gen_manufacturer_property_status_cb_t manufacturer_property_status; /*!< ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTY_STATUS */ + esp_ble_mesh_gen_client_properties_status_cb_t client_properties_status; /*!< ESP_BLE_MESH_MODEL_OP_GEN_CLIENT_PROPERTIES_STATUS */ +} esp_ble_mesh_gen_client_status_cb_t; + +/** Generic Client Model callback parameters */ +typedef struct { + int error_code; /*!< Appropriate error code */ + esp_ble_mesh_client_common_param_t *params; /*!< The client common parameters. */ + esp_ble_mesh_gen_client_status_cb_t status_cb; /*!< The generic status message callback values */ +} esp_ble_mesh_generic_client_cb_param_t; + +/** This enum value is the event of Generic Client Model */ +typedef enum { + ESP_BLE_MESH_GENERIC_CLIENT_GET_STATE_EVT, + ESP_BLE_MESH_GENERIC_CLIENT_SET_STATE_EVT, + ESP_BLE_MESH_GENERIC_CLIENT_PUBLISH_EVT, + ESP_BLE_MESH_GENERIC_CLIENT_TIMEOUT_EVT, + ESP_BLE_MESH_GENERIC_CLIENT_EVT_MAX, +} esp_ble_mesh_generic_client_cb_event_t; + +/** + * @brief Bluetooth Mesh Generic Client Model function. + */ + +/** + * @brief Generic Client Model callback function type + * @param event: Event type + * @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); + +/** + * @brief Register BLE Mesh Generic Client 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_client_callback(esp_ble_mesh_generic_client_cb_t callback); + +/** + * @brief Get the value of Generic Server Model states using the Generic Client Model get messages. + * + * @note If you want to find the opcodes and corresponding meanings accepted by this API, + * please refer to esp_ble_mesh_generic_message_opcode_t in esp_ble_mesh_defs.h + * + * @param[in] params: Pointer to BLE Mesh common client parameters. + * @param[in] get_state: Pointer to generic get message value. + * Shall not be set to NULL. + * + * @return ESP_OK on success or error code otherwise. + * + */ +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); + +/** + * @brief Set the value of Generic Server Model states using the Generic Client Model set messages. + * + * @note If you want to find the opcodes and corresponding meanings accepted by this API, + * please refer to esp_ble_mesh_generic_message_opcode_t in esp_ble_mesh_defs.h + * + * @param[in] params: Pointer to BLE Mesh common client parameters. + * @param[in] set_state: Pointer to generic set message value. + * Shall not be set to NULL. + * + * @return ESP_OK on success or error code otherwise. + * + */ +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); + +/** + * @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_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_health_model_api.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_health_model_api.h new file mode 100644 index 00000000000..3a636ce1c38 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_health_model_api.h @@ -0,0 +1,406 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _ESP_BLE_MESH_HEALTH_MODEL_API_H_ +#define _ESP_BLE_MESH_HEALTH_MODEL_API_H_ + +#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. + * + * @note The Health Server Model can only be included by a Primary Element. + * + * @param srv Pointer to the unique struct esp_ble_mesh_health_srv_t. + * @param pub Pointer to the unique struct esp_ble_mesh_model_pub_t. + * + * @return New Health Server Model instance. + */ +#define ESP_BLE_MESH_MODEL_HEALTH_SRV(srv, pub) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_HEALTH_SRV, \ + NULL, pub, srv) + +/** @def ESP_BLE_MESH_MODEL_HEALTH_CLI + * + * @brief Define a new Health Client Model. + * + * @note This API needs to be called for each element on which + * the application needs to have a Health Client Model. + * + * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t. + * + * @return New Health Client Model instance. + */ +#define ESP_BLE_MESH_MODEL_HEALTH_CLI(cli_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_HEALTH_CLI, \ + NULL, NULL, cli_data) + +/** @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 { + /** Clear health registered faults. Initialized by the stack. */ + esp_ble_mesh_cb_t fault_clear; + + /** Run a specific health test. Initialized by the stack. */ + esp_ble_mesh_cb_t fault_test; + + /** Health attention on callback. Initialized by the stack. */ + esp_ble_mesh_cb_t attention_on; + + /** Health attention off callback. Initialized by the stack. */ + esp_ble_mesh_cb_t attention_off; +} esp_ble_mesh_health_srv_cb_t; + +#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; + + /** Health callback struct */ + esp_ble_mesh_health_srv_cb_t health_cb; + + /** Attention Timer state */ + 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 */ +typedef struct { + uint16_t company_id; /*!< Bluetooth assigned 16-bit Company ID */ +} esp_ble_mesh_health_fault_get_t; + +/** Parameter of Health Attention Set */ +typedef struct { + uint8_t attention; /*!< Value of the Attention Timer state */ +} esp_ble_mesh_health_attention_set_t; + +/** Parameter of Health Period Set */ +typedef struct { + uint8_t fast_period_divisor; /*!< Divider for the Publish Period */ +} esp_ble_mesh_health_period_set_t; + +/** Parameter of Health Fault Test */ +typedef struct { + uint16_t company_id; /*!< Bluetooth assigned 16-bit Company ID */ + uint8_t test_id; /*!< ID of a specific test to be performed */ +} esp_ble_mesh_health_fault_test_t; + +/** Parameter of Health Fault Clear */ +typedef struct { + uint16_t company_id; /*!< Bluetooth assigned 16-bit Company ID */ +} esp_ble_mesh_health_fault_clear_t; + +/** + * @brief For ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET + * ESP_BLE_MESH_MODEL_OP_ATTENTION_GET + * ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_GET + * the get_state parameter in the esp_ble_mesh_health_client_get_state function should not be set to NULL. + */ +typedef union { + esp_ble_mesh_health_fault_get_t fault_get; /*!< For ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET. */ +} esp_ble_mesh_health_client_get_state_t; + +/** + * @brief For ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR + * ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR_UNACK + * ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST + * ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST_UNACK + * ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET + * ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET_UNACK + * ESP_BLE_MESH_MODEL_OP_ATTENTION_SET + * ESP_BLE_MESH_MODEL_OP_ATTENTION_SET_UNACK + * the set_state parameter in the esp_ble_mesh_health_client_set_state function should not be set to NULL. + */ +typedef union { + esp_ble_mesh_health_attention_set_t attention_set; /*!< For ESP_BLE_MESH_MODEL_OP_ATTENTION_SET or ESP_BLE_MESH_MODEL_OP_ATTENTION_SET_UNACK. */ + esp_ble_mesh_health_period_set_t period_set; /*!< For ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET or ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET_UNACK. */ + esp_ble_mesh_health_fault_test_t fault_test; /*!< For ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST or ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST_UNACK. */ + esp_ble_mesh_health_fault_clear_t fault_clear; /*!< For ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR or ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR_UNACK. */ +} esp_ble_mesh_health_client_set_state_t; + +/** Parameters of Health Current Status */ +typedef struct { + uint8_t test_id; /*!< ID of a most recently performed test */ + uint16_t company_id; /*!< Bluetooth assigned 16-bit Company ID */ + struct net_buf_simple *fault_array; /*!< FaultArray field contains a sequence of 1-octet fault values */ +} esp_ble_mesh_health_current_status_cb_t; + +/** Parameters of Health Fault Status */ +typedef struct { + uint8_t test_id; /*!< ID of a most recently performed test */ + uint16_t company_id; /*!< Bluetooth assigned 16-bit Company ID */ + struct net_buf_simple *fault_array; /*!< FaultArray field contains a sequence of 1-octet fault values */ +} esp_ble_mesh_health_fault_status_cb_t; + +/** Parameter of Health Period Status */ +typedef struct { + uint8_t fast_period_divisor; /*!< Divider for the Publish Period */ +} esp_ble_mesh_health_period_status_cb_t; + +/** Parameter of Health Attention Status */ +typedef struct { + uint8_t attention; /*!< Value of the Attention Timer state */ +} esp_ble_mesh_health_attention_status_cb_t; + +/** + * @brief Health Client Model received message union + */ +typedef union { + esp_ble_mesh_health_current_status_cb_t current_status; /*!< The health current status value */ + esp_ble_mesh_health_fault_status_cb_t fault_status; /*!< The health fault status value */ + esp_ble_mesh_health_period_status_cb_t period_status; /*!< The health period status value */ + esp_ble_mesh_health_attention_status_cb_t attention_status; /*!< The health attention status value */ +} esp_ble_mesh_health_client_common_cb_param_t; + +/** Health Client Model callback parameters */ +typedef struct { + int error_code; /*!< Appropriate error code */ + esp_ble_mesh_client_common_param_t *params; /*!< The client common parameters. */ + esp_ble_mesh_health_client_common_cb_param_t status_cb; /*!< The health message status callback values */ +} esp_ble_mesh_health_client_cb_param_t; + +/** This enum value is the event of Health Client Model */ +typedef enum { + ESP_BLE_MESH_HEALTH_CLIENT_GET_STATE_EVT, + ESP_BLE_MESH_HEALTH_CLIENT_SET_STATE_EVT, + ESP_BLE_MESH_HEALTH_CLIENT_PUBLISH_EVT, + ESP_BLE_MESH_HEALTH_CLIENT_TIMEOUT_EVT, + ESP_BLE_MESH_HEALTH_CLIENT_EVT_MAX, +} esp_ble_mesh_health_client_cb_event_t; + +/** Parameter of publishing Health Current Status completion event */ +typedef struct { + 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_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; + +/** + * @brief Bluetooth Mesh Health Client and Server Model function. + */ + +/** + * @brief Health Client Model callback function type + * @param event: Event type + * @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); + +/** + * @brief Health Server Model callback function type + * @param event: Event type + * @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); + +/** + * @brief Register BLE Mesh Health Model callback, the callback will report Health Client & Server Model events. + * + * @param[in] callback: Pointer to the callback function. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_register_health_client_callback(esp_ble_mesh_health_client_cb_t callback); + +/** + * @brief Register BLE Mesh Health 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_health_server_callback(esp_ble_mesh_health_server_cb_t callback); + +/** + * @brief This function is called to get the Health Server states using the Health Client Model get messages. + * + * @note If you want to find the opcodes and corresponding meanings accepted by this API, + * please refer to esp_ble_mesh_opcode_health_client_get_t in esp_ble_mesh_defs.h + * + * @param[in] params: Pointer to BLE Mesh common client parameters. + * @param[in] get_state: Pointer to a union, each kind of opcode corresponds to one structure inside. + * Shall not be set to NULL. + * + * @return ESP_OK on success or error code otherwise. + * + */ +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); + +/** + * @brief This function is called to set the Health Server states using the Health Client Model set messages. + * + * @note If you want to find the opcodes and corresponding meanings accepted by this API, + * please refer to esp_ble_mesh_opcode_health_client_set_t in esp_ble_mesh_defs.h + * + * @param[in] params: Pointer to BLE Mesh common client parameters. + * @param[in] set_state: Pointer to a union, each kind of opcode corresponds to one structure inside. + * Shall not be set to NULL. + * + * @return ESP_OK on success or error code otherwise. + * + */ +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); + +/** + * @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. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_health_server_fault_update(esp_ble_mesh_elem_t *element); + +#ifdef __cplusplus +} +#endif + +#endif /* _ESP_BLE_MESH_HEALTH_MODEL_API_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_lighting_model_api.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_lighting_model_api.h new file mode 100644 index 00000000000..48f45f5e4f2 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_lighting_model_api.h @@ -0,0 +1,1674 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** @file + * @brief Bluetooth Mesh Light Client Model APIs. + */ + +#ifndef _ESP_BLE_MESH_LIGHTING_MODEL_API_H_ +#define _ESP_BLE_MESH_LIGHTING_MODEL_API_H_ + +#include "esp_ble_mesh_defs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** @def ESP_BLE_MESH_MODEL_LIGHT_LIGHTNESS_CLI + * + * @brief Define a new Light Lightness Client Model. + * + * @note This API needs to be called for each element on which + * the application needs to have a Light Lightness Client Model. + * + * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t. + * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t. + * + * @return New Light Lightness Client Model instance. + */ +#define ESP_BLE_MESH_MODEL_LIGHT_LIGHTNESS_CLI(cli_pub, cli_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_CLI, \ + NULL, cli_pub, cli_data) + +/** @def ESP_BLE_MESH_MODEL_LIGHT_CTL_CLI + * + * @brief Define a new Light CTL Client Model. + * + * @note This API needs to be called for each element on which + * the application needs to have a Light CTL Client Model. + * + * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t. + * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t. + * + * @return New Light CTL Client Model instance. + */ +#define ESP_BLE_MESH_MODEL_LIGHT_CTL_CLI(cli_pub, cli_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_CTL_CLI, \ + NULL, cli_pub, cli_data) + +/** @def ESP_BLE_MESH_MODEL_LIGHT_HSL_CLI + * + * @brief Define a new Light HSL Client Model. + * + * @note This API needs to be called for each element on which + * the application needs to have a Light HSL Client Model. + * + * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t. + * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t. + * + * @return New Light HSL Client Model instance. + */ +#define ESP_BLE_MESH_MODEL_LIGHT_HSL_CLI(cli_pub, cli_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_HSL_CLI, \ + NULL, cli_pub, cli_data) + +/** @def ESP_BLE_MESH_MODEL_LIGHT_XYL_CLI + * + * @brief Define a new Light xyL Client Model. + * + * @note This API needs to be called for each element on which + * the application needs to have a Light xyL Client Model. + * + * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t. + * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t. + * + * @return New Light xyL Client Model instance. + */ +#define ESP_BLE_MESH_MODEL_LIGHT_XYL_CLI(cli_pub, cli_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_XYL_CLI, \ + NULL, cli_pub, cli_data) + +/** @def ESP_BLE_MESH_MODEL_LIGHT_LC_CLI + * + * @brief Define a new Light LC Client Model. + * + * @note This API needs to be called for each element on which + * the application needs to have a Light LC Client Model. + * + * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t. + * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t. + * + * @return New Light LC Client Model instance. + */ +#define ESP_BLE_MESH_MODEL_LIGHT_LC_CLI(cli_pub, cli_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_LC_CLI, \ + NULL, cli_pub, cli_data) + +/** + * @brief Bluetooth Mesh Light Lightness Client Model Get and Set parameters structure. + */ + +/** Parameters of Light Lightness Set */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t lightness; /*!< Target value of light lightness 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_light_lightness_set_t; + +/** Parameters of Light Lightness Linear Set */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t lightness; /*!< Target value of light lightness linear 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_light_lightness_linear_set_t; + +/** Parameter of Light Lightness Default Set */ +typedef struct { + uint16_t lightness; /*!< The value of the Light Lightness Default state */ +} esp_ble_mesh_light_lightness_default_set_t; + +/** Parameters of Light Lightness Range Set */ +typedef struct { + uint16_t range_min; /*!< Value of range min field of light lightness range state */ + uint16_t range_max; /*!< Value of range max field of light lightness range state */ +} esp_ble_mesh_light_lightness_range_set_t; + +/** Parameters of Light CTL Set */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t ctl_lightness; /*!< Target value of light ctl lightness state */ + uint16_t ctl_temperatrue; /*!< Target value of light ctl temperature state */ + int16_t ctl_delta_uv; /*!< Target value of light ctl delta UV 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_light_ctl_set_t; + +/** Parameters of Light CTL Temperature Set */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t ctl_temperatrue; /*!< Target value of light ctl temperature state */ + int16_t ctl_delta_uv; /*!< Target value of light ctl delta UV 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_light_ctl_temperature_set_t; + +/** Parameters of Light CTL Temperature Range Set */ +typedef struct { + uint16_t range_min; /*!< Value of temperature range min field of light ctl temperature range state */ + uint16_t range_max; /*!< Value of temperature range max field of light ctl temperature range state */ +} esp_ble_mesh_light_ctl_temperature_range_set_t; + +/** Parameters of Light CTL Default Set */ +typedef struct { + uint16_t lightness; /*!< Value of light lightness default state */ + uint16_t temperature; /*!< Value of light temperature default state */ + int16_t delta_uv; /*!< Value of light delta UV default state */ +} esp_ble_mesh_light_ctl_default_set_t; + +/** Parameters of Light HSL Set */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t hsl_lightness; /*!< Target value of light hsl lightness state */ + uint16_t hsl_hue; /*!< Target value of light hsl hue state */ + uint16_t hsl_saturation; /*!< Target value of light hsl saturation 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_light_hsl_set_t; + +/** Parameters of Light HSL Hue Set */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t hue; /*!< Target value of light hsl hue 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_light_hsl_hue_set_t; + +/** Parameters of Light HSL Saturation Set */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t saturation; /*!< Target value of light hsl hue 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_light_hsl_saturation_set_t; + +/** Parameters of Light HSL Default Set */ +typedef struct { + uint16_t lightness; /*!< Value of light lightness default state */ + uint16_t hue; /*!< Value of light hue default state */ + uint16_t saturation; /*!< Value of light saturation default state */ +} esp_ble_mesh_light_hsl_default_set_t; + +/** Parameters of Light HSL Range Set */ +typedef struct { + uint16_t hue_range_min; /*!< Value of hue range min field of light hsl hue range state */ + uint16_t hue_range_max; /*!< Value of hue range max field of light hsl hue range state */ + uint16_t saturation_range_min; /*!< Value of saturation range min field of light hsl saturation range state */ + uint16_t saturation_range_max; /*!< Value of saturation range max field of light hsl saturation range state */ +} esp_ble_mesh_light_hsl_range_set_t; + +/** Parameters of Light xyL Set */ +typedef struct { + bool op_en; /*!< Indicate whether optional parameters included */ + uint16_t xyl_lightness; /*!< The target value of the Light xyL Lightness state */ + uint16_t xyl_x; /*!< The target value of the Light xyL x state */ + uint16_t xyl_y; /*!< The target value of the Light xyL y state */ + uint8_t tid; /*!< Transaction Identifier */ + uint8_t trans_time; /*!< Time to complete state transition (optional) */ + uint8_t delay; /*!< Indicate message execution delay (C.1) */ +} esp_ble_mesh_light_xyl_set_t; + +/** Parameters of Light xyL Default Set */ +typedef struct { + uint16_t lightness; /*!< The value of the Light Lightness Default state */ + uint16_t xyl_x; /*!< The value of the Light xyL x Default state */ + uint16_t xyl_y; /*!< The value of the Light xyL y Default state */ +} esp_ble_mesh_light_xyl_default_set_t; + +/** Parameters of Light xyL Range Set */ +typedef struct { + uint16_t xyl_x_range_min; /*!< The value of the xyL x Range Min field of the Light xyL x Range state */ + uint16_t xyl_x_range_max; /*!< The value of the xyL x Range Max field of the Light xyL x Range state */ + uint16_t xyl_y_range_min; /*!< The value of the xyL y Range Min field of the Light xyL y Range state */ + uint16_t xyl_y_range_max; /*!< The value of the xyL y Range Max field of the Light xyL y Range state */ +} esp_ble_mesh_light_xyl_range_set_t; + +/** Parameter of Light LC Mode Set */ +typedef struct { + uint8_t mode; /*!< The target value of the Light LC Mode state */ +} esp_ble_mesh_light_lc_mode_set_t; + +/** Parameter of Light LC OM Set */ +typedef struct { + uint8_t mode; /*!< The target value of the Light LC Occupancy Mode state */ +} esp_ble_mesh_light_lc_om_set_t; + +/** Parameters of Light LC Light OnOff Set */ +typedef struct { + bool op_en; /*!< Indicate whether optional parameters included */ + uint8_t light_onoff; /*!< The target value of the Light LC Light OnOff state */ + uint8_t tid; /*!< Transaction Identifier */ + uint8_t trans_time; /*!< Time to complete state transition (optional) */ + uint8_t delay; /*!< Indicate message execution delay (C.1) */ +} esp_ble_mesh_light_lc_light_onoff_set_t; + +/** Parameter of Light LC Property Get */ +typedef struct { + uint16_t property_id; /*!< Property ID identifying a Light LC Property */ +} esp_ble_mesh_light_lc_property_get_t; + +/** Parameters of Light LC Property Set */ +typedef struct { + uint16_t property_id; /*!< Property ID identifying a Light LC Property */ + struct net_buf_simple *property_value; /*!< Raw value for the Light LC Property */ +} esp_ble_mesh_light_lc_property_set_t; + +/** + * @brief Lighting Client Model get message union + */ +typedef union { + esp_ble_mesh_light_lc_property_get_t lc_property_get; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_GET */ +} esp_ble_mesh_light_client_get_state_t; + +/** + * @brief Lighting Client Model set message union + */ +typedef union { + esp_ble_mesh_light_lightness_set_t lightness_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_SET_UNACK */ + esp_ble_mesh_light_lightness_linear_set_t lightness_linear_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_SET_UNACK */ + esp_ble_mesh_light_lightness_default_set_t lightness_default_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_SET_UNACK */ + esp_ble_mesh_light_lightness_range_set_t lightness_range_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_SET_UNACK */ + esp_ble_mesh_light_ctl_set_t ctl_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_SET_UNACK */ + esp_ble_mesh_light_ctl_temperature_set_t ctl_temperature_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_SET_UNACK */ + esp_ble_mesh_light_ctl_temperature_range_set_t ctl_temperature_range_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_SET_UNACK */ + esp_ble_mesh_light_ctl_default_set_t ctl_default_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_SET_UNACK */ + esp_ble_mesh_light_hsl_set_t hsl_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SET_UNACK */ + esp_ble_mesh_light_hsl_hue_set_t hsl_hue_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_SET_UNACK */ + esp_ble_mesh_light_hsl_saturation_set_t hsl_saturation_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_SET_UNACK */ + esp_ble_mesh_light_hsl_default_set_t hsl_default_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_SET_UNACK */ + esp_ble_mesh_light_hsl_range_set_t hsl_range_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_SET_UNACK */ + esp_ble_mesh_light_xyl_set_t xyl_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_SET_UNACK */ + esp_ble_mesh_light_xyl_default_set_t xyl_default_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_SET_UNACK */ + esp_ble_mesh_light_xyl_range_set_t xyl_range_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_SET_UNACK */ + esp_ble_mesh_light_lc_mode_set_t lc_mode_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LC_MODE_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_LC_MODE_SET_UNACK */ + esp_ble_mesh_light_lc_om_set_t lc_om_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LC_OM_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_LC_OM_SET_UNACK */ + esp_ble_mesh_light_lc_light_onoff_set_t lc_light_onoff_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_SET_UNACK */ + esp_ble_mesh_light_lc_property_set_t lc_property_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET_UNACK */ +} esp_ble_mesh_light_client_set_state_t; + +/** + * @brief Bluetooth Mesh Light Lightness Client Model Get and Set callback parameters structure. + */ + +/** Parameters of Light Lightness Status */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t present_lightness; /*!< Current value of light lightness actual state */ + uint16_t target_lightness; /*!< Target value of light lightness actual state (optional) */ + uint8_t remain_time; /*!< Time to complete state transition (C.1) */ +} esp_ble_mesh_light_lightness_status_cb_t; + +/** Parameters of Light Lightness Linear Status */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t present_lightness; /*!< Current value of light lightness linear state */ + uint16_t target_lightness; /*!< Target value of light lightness linear state (optional) */ + uint8_t remain_time; /*!< Time to complete state transition (C.1) */ +} esp_ble_mesh_light_lightness_linear_status_cb_t; + +/** Parameter of Light Lightness Last Status */ +typedef struct { + uint16_t lightness; /*!< The value of the Light Lightness Last state */ +} esp_ble_mesh_light_lightness_last_status_cb_t; + +/** Parameter of Light Lightness Default Status */ +typedef struct { + uint16_t lightness; /*!< The value of the Light Lightness default State */ +} esp_ble_mesh_light_lightness_default_status_cb_t; + +/** Parameters of Light Lightness Range Status */ +typedef struct { + uint8_t status_code; /*!< Status Code for the request message */ + uint16_t range_min; /*!< Value of range min field of light lightness range state */ + uint16_t range_max; /*!< Value of range max field of light lightness range state */ +} esp_ble_mesh_light_lightness_range_status_cb_t; + +/** Parameters of Light CTL Status */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t present_ctl_lightness; /*!< Current value of light ctl lightness state */ + uint16_t present_ctl_temperature; /*!< Current value of light ctl temperature state */ + uint16_t target_ctl_lightness; /*!< Target value of light ctl lightness state (optional) */ + uint16_t target_ctl_temperature; /*!< Target value of light ctl temperature state (C.1) */ + uint8_t remain_time; /*!< Time to complete state transition (C.1) */ +} esp_ble_mesh_light_ctl_status_cb_t; + +/** Parameters of Light CTL Temperature Status */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t present_ctl_temperature; /*!< Current value of light ctl temperature state */ + uint16_t present_ctl_delta_uv; /*!< Current value of light ctl delta UV state */ + uint16_t target_ctl_temperature; /*!< Target value of light ctl temperature state (optional) */ + uint16_t target_ctl_delta_uv; /*!< Target value of light ctl delta UV state (C.1) */ + uint8_t remain_time; /*!< Time to complete state transition (C.1) */ +} esp_ble_mesh_light_ctl_temperature_status_cb_t; + +/** Parameters of Light CTL Temperature Range Status */ +typedef struct { + uint8_t status_code; /*!< Status code for the request message */ + uint16_t range_min; /*!< Value of temperature range min field of light ctl temperature range state */ + uint16_t range_max; /*!< Value of temperature range max field of light ctl temperature range state */ +} esp_ble_mesh_light_ctl_temperature_range_status_cb_t; + +/** Parameters of Light CTL Default Status */ +typedef struct { + uint16_t lightness; /*!< Value of light lightness default state */ + uint16_t temperature; /*!< Value of light temperature default state */ + int16_t delta_uv; /*!< Value of light delta UV default state */ +} esp_ble_mesh_light_ctl_default_status_cb_t; + +/** Parameters of Light HSL Status */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t hsl_lightness; /*!< Current value of light hsl lightness state */ + uint16_t hsl_hue; /*!< Current value of light hsl hue state */ + uint16_t hsl_saturation; /*!< Current value of light hsl saturation state */ + uint8_t remain_time; /*!< Time to complete state transition (optional) */ +} esp_ble_mesh_light_hsl_status_cb_t; + +/** Parameters of Light HSL Target Status */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t hsl_lightness_target; /*!< Target value of light hsl lightness state */ + uint16_t hsl_hue_target; /*!< Target value of light hsl hue state */ + uint16_t hsl_saturation_target; /*!< Target value of light hsl saturation state */ + uint8_t remain_time; /*!< Time to complete state transition (optional) */ +} esp_ble_mesh_light_hsl_target_status_cb_t; + +/** Parameters of Light HSL Hue Status */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t present_hue; /*!< Current value of light hsl hue state */ + uint16_t target_hue; /*!< Target value of light hsl hue state (optional) */ + uint8_t remain_time; /*!< Time to complete state transition (C.1) */ +} esp_ble_mesh_light_hsl_hue_status_cb_t; + +/** Parameters of Light HSL Saturation Status */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t present_saturation; /*!< Current value of light hsl saturation state */ + uint16_t target_saturation; /*!< Target value of light hsl saturation state (optional) */ + uint8_t remain_time; /*!< Time to complete state transition (C.1) */ +} esp_ble_mesh_light_hsl_saturation_status_cb_t; + +/** Parameters of Light HSL Default Status */ +typedef struct { + uint16_t lightness; /*!< Value of light lightness default state */ + uint16_t hue; /*!< Value of light hue default state */ + uint16_t saturation; /*!< Value of light saturation default state */ +} esp_ble_mesh_light_hsl_default_status_cb_t; + +/** Parameters of Light HSL Range Status */ +typedef struct { + uint8_t status_code; /*!< Status code for the request message */ + uint16_t hue_range_min; /*!< Value of hue range min field of light hsl hue range state */ + uint16_t hue_range_max; /*!< Value of hue range max field of light hsl hue range state */ + uint16_t saturation_range_min; /*!< Value of saturation range min field of light hsl saturation range state */ + uint16_t saturation_range_max; /*!< Value of saturation range max field of light hsl saturation range state */ +} esp_ble_mesh_light_hsl_range_status_cb_t; + +/** Parameters of Light xyL Status */ +typedef struct { + bool op_en; /*!< Indicate whether optional parameters included */ + uint16_t xyl_lightness; /*!< The present value of the Light xyL Lightness state */ + uint16_t xyl_x; /*!< The present value of the Light xyL x state */ + uint16_t xyl_y; /*!< The present value of the Light xyL y state */ + uint8_t remain_time; /*!< Time to complete state transition (optional) */ +} esp_ble_mesh_light_xyl_status_cb_t; + +/** Parameters of Light xyL Target Status */ +typedef struct { + bool op_en; /*!< Indicate whether optional parameters included */ + uint16_t target_xyl_lightness; /*!< The target value of the Light xyL Lightness state */ + uint16_t target_xyl_x; /*!< The target value of the Light xyL x state */ + uint16_t target_xyl_y; /*!< The target value of the Light xyL y state */ + uint8_t remain_time; /*!< Time to complete state transition (optional) */ +} esp_ble_mesh_light_xyl_target_status_cb_t; + +/** Parameters of Light xyL Default Status */ +typedef struct { + uint16_t lightness; /*!< The value of the Light Lightness Default state */ + uint16_t xyl_x; /*!< The value of the Light xyL x Default state */ + uint16_t xyl_y; /*!< The value of the Light xyL y Default state */ +} esp_ble_mesh_light_xyl_default_status_cb_t; + +/** Parameters of Light xyL Range Status */ +typedef struct { + uint8_t status_code; /*!< Status Code for the requesting message */ + uint16_t xyl_x_range_min; /*!< The value of the xyL x Range Min field of the Light xyL x Range state */ + uint16_t xyl_x_range_max; /*!< The value of the xyL x Range Max field of the Light xyL x Range state */ + uint16_t xyl_y_range_min; /*!< The value of the xyL y Range Min field of the Light xyL y Range state */ + uint16_t xyl_y_range_max; /*!< The value of the xyL y Range Max field of the Light xyL y Range state */ +} esp_ble_mesh_light_xyl_range_status_cb_t; + +/** Parameter of Light LC Mode Status */ +typedef struct { + uint8_t mode; /*!< The present value of the Light LC Mode state */ +} esp_ble_mesh_light_lc_mode_status_cb_t; + +/** Parameter of Light LC OM Status */ +typedef struct { + uint8_t mode; /*!< The present value of the Light LC Occupancy Mode state */ +} esp_ble_mesh_light_lc_om_status_cb_t; + +/** Parameters of Light LC Light OnOff Status */ +typedef struct { + bool op_en; /*!< Indicate whether optional parameters included */ + uint8_t present_light_onoff; /*!< The present value of the Light LC Light OnOff state */ + uint8_t target_light_onoff; /*!< The target value of the Light LC Light OnOff state (Optional) */ + uint8_t remain_time; /*!< Time to complete state transition (C.1) */ +} esp_ble_mesh_light_lc_light_onoff_status_cb_t; + +/** Parameters of Light LC Property Status */ +typedef struct { + uint16_t property_id; /*!< Property ID identifying a Light LC Property */ + struct net_buf_simple *property_value; /*!< Raw value for the Light LC Property */ +} esp_ble_mesh_light_lc_property_status_cb_t; + +/** + * @brief Lighting Client Model received message union + */ +typedef union { + esp_ble_mesh_light_lightness_status_cb_t lightness_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_STATUS */ + esp_ble_mesh_light_lightness_linear_status_cb_t lightness_linear_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_STATUS */ + esp_ble_mesh_light_lightness_last_status_cb_t lightness_last_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LAST_STATUS */ + esp_ble_mesh_light_lightness_default_status_cb_t lightness_default_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_STATUS */ + esp_ble_mesh_light_lightness_range_status_cb_t lightness_range_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_STATUS */ + esp_ble_mesh_light_ctl_status_cb_t ctl_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_STATUS */ + esp_ble_mesh_light_ctl_temperature_status_cb_t ctl_temperature_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_STATUS */ + esp_ble_mesh_light_ctl_temperature_range_status_cb_t ctl_temperature_range_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_STATUS */ + esp_ble_mesh_light_ctl_default_status_cb_t ctl_default_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_STATUS */ + esp_ble_mesh_light_hsl_status_cb_t hsl_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_STATUS */ + esp_ble_mesh_light_hsl_target_status_cb_t hsl_target_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_TARGET_STATUS */ + esp_ble_mesh_light_hsl_hue_status_cb_t hsl_hue_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_STATUS */ + esp_ble_mesh_light_hsl_saturation_status_cb_t hsl_saturation_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_STATUS */ + esp_ble_mesh_light_hsl_default_status_cb_t hsl_default_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_STATUS */ + esp_ble_mesh_light_hsl_range_status_cb_t hsl_range_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_STATUS */ + esp_ble_mesh_light_xyl_status_cb_t xyl_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_STATUS */ + esp_ble_mesh_light_xyl_target_status_cb_t xyl_target_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_TARGET_STATUS */ + esp_ble_mesh_light_xyl_default_status_cb_t xyl_default_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_STATUS */ + esp_ble_mesh_light_xyl_range_status_cb_t xyl_range_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_STATUS */ + esp_ble_mesh_light_lc_mode_status_cb_t lc_mode_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LC_MODE_STATUS */ + esp_ble_mesh_light_lc_om_status_cb_t lc_om_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LC_OM_STATUS */ + esp_ble_mesh_light_lc_light_onoff_status_cb_t lc_light_onoff_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_STATUS */ + esp_ble_mesh_light_lc_property_status_cb_t lc_property_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_STATUS */ +} esp_ble_mesh_light_client_status_cb_t; + +/** Lighting Client Model callback parameters */ +typedef struct { + int error_code; /*!< Appropriate error code */ + esp_ble_mesh_client_common_param_t *params; /*!< The client common parameters. */ + esp_ble_mesh_light_client_status_cb_t status_cb; /*!< The light status message callback values */ +} esp_ble_mesh_light_client_cb_param_t; + +/** This enum value is the event of Lighting Client Model */ +typedef enum { + ESP_BLE_MESH_LIGHT_CLIENT_GET_STATE_EVT, + ESP_BLE_MESH_LIGHT_CLIENT_SET_STATE_EVT, + ESP_BLE_MESH_LIGHT_CLIENT_PUBLISH_EVT, + ESP_BLE_MESH_LIGHT_CLIENT_TIMEOUT_EVT, + ESP_BLE_MESH_LIGHT_CLIENT_EVT_MAX, +} esp_ble_mesh_light_client_cb_event_t; + +/** + * @brief Bluetooth Mesh Light Client Model function. + */ + +/** + * @brief Lighting Client Model callback function type + * @param event: Event type + * @param param: Pointer to callback parameter + */ +typedef void (* esp_ble_mesh_light_client_cb_t)(esp_ble_mesh_light_client_cb_event_t event, + esp_ble_mesh_light_client_cb_param_t *param); + +/** + * @brief Register BLE Mesh Light Client 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_light_client_callback(esp_ble_mesh_light_client_cb_t callback); + +/** + * @brief Get the value of Light Server Model states using the Light Client Model get messages. + * + * @note If you want to know the opcodes and corresponding meanings accepted by this API, + * please refer to esp_ble_mesh_light_message_opcode_t in esp_ble_mesh_defs.h + * + * @param[in] params: Pointer to BLE Mesh common client parameters. + * @param[in] get_state: Pointer of light get message value. + * Shall not be set to NULL. + * + * @return ESP_OK on success or error code otherwise. + * + */ +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); + +/** + * @brief Set the value of Light Server Model states using the Light Client Model set messages. + * + * @note If you want to know the opcodes and corresponding meanings accepted by this API, + * please refer to esp_ble_mesh_light_message_opcode_t in esp_ble_mesh_defs.h + * + * @param[in] params: Pointer to BLE Mesh common client parameters. + * @param[in] set_state: Pointer of light set message value. + * Shall not be set to NULL. + * + * @return ESP_OK on success or error code otherwise. + * + */ +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); + +/** + * @brief Lighting Server Models related context. + */ + +/** @def ESP_BLE_MESH_MODEL_LIGHT_LIGHTNESS_SRV + * + * @brief Define a new Light Lightness Server Model. + * + * @note 1. The Light Lightness 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 Light Lightness 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_light_lightness_srv_t. + * + * @return New Light Lightness Server Model instance. + */ +#define ESP_BLE_MESH_MODEL_LIGHT_LIGHTNESS_SRV(srv_pub, srv_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SRV, \ + NULL, srv_pub, srv_data) + +/** @def ESP_BLE_MESH_MODEL_LIGHT_LIGHTNESS_SETUP_SRV + * + * @brief Define a new Light Lightness Setup Server Model. + * + * @note 1. The Light Lightness Setup Server model extends the Light Lightness + * 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_light_lightness_setup_srv_t. + * + * @return New Light Lightness Setup Server Model instance. + */ +#define ESP_BLE_MESH_MODEL_LIGHT_LIGHTNESS_SETUP_SRV(srv_pub, srv_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SETUP_SRV, \ + NULL, srv_pub, srv_data) + +/** @def ESP_BLE_MESH_MODEL_LIGHT_CTL_SRV + * + * @brief Define a new Light CTL Server Model. + * + * @note 1. The Light CTL Server model extends the Light Lightness Server model. + * When this model is present on an Element, the corresponding Light + * CTL Temperature Server model and the corresponding Light CTL Setup + * Server model shall also be present. + * 2. This model shall support model publication and model subscription. + * 3. The model requires two elements: the main element and the Temperature + * element. The Temperature element contains the corresponding Light CTL + * Temperature Server model and an instance of a Generic Level state + * bound to the Light CTL Temperature state on the Temperature element. + * The Light CTL Temperature state on the Temperature element is bound to + * the Light CTL state on the main 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_light_ctl_srv_t. + * + * @return New Light CTL Server Model instance. + */ +#define ESP_BLE_MESH_MODEL_LIGHT_CTL_SRV(srv_pub, srv_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_CTL_SRV, \ + NULL, srv_pub, srv_data) + +/** @def ESP_BLE_MESH_MODEL_LIGHT_CTL_SETUP_SRV + * + * @brief Define a new Light CTL Setup Server Model. + * + * @note 1. The Light CTL Setup Server model extends the Light CTL Server and + * the Light Lightness Setup Server. + * 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_light_ctl_setup_srv_t. + * + * @return New Light CTL Setup Server Model instance. + */ +#define ESP_BLE_MESH_MODEL_LIGHT_CTL_SETUP_SRV(srv_pub, srv_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_CTL_SETUP_SRV, \ + NULL, srv_pub, srv_data) + +/** @def ESP_BLE_MESH_MODEL_LIGHT_CTL_TEMP_SRV + * + * @brief Define a new Light CTL Temperature Server Model. + * + * @note 1. The Light CTL Temperature Server model extends the Generic Level + * 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_light_ctl_temp_srv_t. + * + * @return New Light CTL Temperature Server Model instance. + */ +#define ESP_BLE_MESH_MODEL_LIGHT_CTL_TEMP_SRV(srv_pub, srv_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_CTL_TEMP_SRV, \ + NULL, srv_pub, srv_data) + +/** @def ESP_BLE_MESH_MODEL_LIGHT_HSL_SRV + * + * @brief Define a new Light HSL Server Model. + * + * @note 1. The Light HSL Server model extends the Light Lightness Server model. When + * this model is present on an Element, the corresponding Light HSL Hue + * Server model and the corresponding Light HSL Saturation Server model and + * the corresponding Light HSL Setup Server model shall also be present. + * 2. This model shall support model publication and model subscription. + * 3. The model requires three elements: the main element and the Hue element + * and the Saturation element. The Hue element contains the corresponding + * Light HSL Hue Server model and an instance of a Generic Level state bound + * to the Light HSL Hue state on the Hue element. The Saturation element + * contains the corresponding Light HSL Saturation Server model and an + * instance of a Generic Level state bound to the Light HSL Saturation state + * on the Saturation element. The Light HSL Hue state on the Hue element is + * bound to the Light HSL state on the main element and the Light HSL + * Saturation state on the Saturation element is bound to the Light HSL state + * on the main 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_light_hsl_srv_t. + * + * @return New Light HSL Server Model instance. + */ +#define ESP_BLE_MESH_MODEL_LIGHT_HSL_SRV(srv_pub, srv_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_HSL_SRV, \ + NULL, srv_pub, srv_data) + +/** @def ESP_BLE_MESH_MODEL_LIGHT_HSL_SETUP_SRV + * + * @brief Define a new Light HSL Setup Server Model. + * + * @note 1. The Light HSL Setup Server model extends the Light HSL Server and + * the Light Lightness Setup Server. + * 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_light_hsl_setup_srv_t. + * + * @return New Light HSL Setup Server Model instance. + */ +#define ESP_BLE_MESH_MODEL_LIGHT_HSL_SETUP_SRV(srv_pub, srv_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_HSL_SETUP_SRV, \ + NULL, srv_pub, srv_data) + +/** @def ESP_BLE_MESH_MODEL_LIGHT_HSL_HUE_SRV + * + * @brief Define a new Light HSL Hue Server Model. + * + * @note 1. The Light HSL Hue Server model extends the Generic Level Server model. + * This model is associated with the Light HSL 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_light_hsl_hue_srv_t. + * + * @return New Light HSL Hue Server Model instance. + */ +#define ESP_BLE_MESH_MODEL_LIGHT_HSL_HUE_SRV(srv_pub, srv_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_HSL_HUE_SRV, \ + NULL, srv_pub, srv_data) + +/** @def ESP_BLE_MESH_MODEL_LIGHT_HSL_SAT_SRV + * + * @brief Define a new Light HSL Saturation Server Model. + * + * @note 1. The Light HSL Saturation Server model extends the Generic Level Server + * model. This model is associated with the Light HSL 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_light_hsl_sat_srv_t. + * + * @return New Light HSL Saturation Server Model instance. + */ +#define ESP_BLE_MESH_MODEL_LIGHT_HSL_SAT_SRV(srv_pub, srv_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_HSL_SAT_SRV, \ + NULL, srv_pub, srv_data) + +/** @def ESP_BLE_MESH_MODEL_LIGHT_XYL_SRV + * + * @brief Define a new Light xyL Server Model. + * + * @note 1. The Light xyL Server model extends the Light Lightness Server model. + * When this model is present on an Element, the corresponding Light xyL + * 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_light_xyl_srv_t. + * + * @return New Light xyL Server Model instance. + */ +#define ESP_BLE_MESH_MODEL_LIGHT_XYL_SRV(srv_pub, srv_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_XYL_SRV, \ + NULL, srv_pub, srv_data) + +/** @def ESP_BLE_MESH_MODEL_LIGHT_XYL_SETUP_SRV + * + * @brief Define a new Light xyL Setup Server Model. + * + * @note 1. The Light xyL Setup Server model extends the Light xyL Server and + * the Light Lightness Setup Server. + * 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_light_xyl_setup_srv_t. + * + * @return New Light xyL Setup Server Model instance. + */ +#define ESP_BLE_MESH_MODEL_LIGHT_XYL_SETUP_SRV(srv_pub, srv_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_XYL_SETUP_SRV, \ + NULL, srv_pub, srv_data) + +/** @def ESP_BLE_MESH_MODEL_LIGHT_LC_SRV + * + * @brief Define a new Light LC Server Model. + * + * @note 1. The Light LC (Lightness Control) Server model extends the Light + * Lightness Server model and the Generic OnOff Server model. When + * this model is present on an Element, the corresponding Light LC + * Setup Server model shall also be present. + * 2. This model shall support model publication and model subscription. + * 3. This model may be used to represent an element that is a client to + * a Sensor Server model and controls the Light Lightness Actual state + * via defined state bindings. + * + * @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_light_lc_srv_t. + * + * @return New Light LC Server Model instance. + */ +#define ESP_BLE_MESH_MODEL_LIGHT_LC_SRV(srv_pub, srv_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_LC_SRV, \ + NULL, srv_pub, srv_data) + +/** @def ESP_BLE_MESH_MODEL_LIGHT_LC_SETUP_SRV + * + * @brief Define a new Light LC Setup Server Model. + * + * @note 1. The Light LC (Lightness Control) Setup model extends the Light LC + * Server model. + * 2. This model shall support model publication and model subscription. + * 3. This model may be used to configure setup parameters for the Light + * LC Server model. + * + * @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_light_lc_setup_srv_t. + * + * @return New Light LC Setup Server Model instance. + */ +#define ESP_BLE_MESH_MODEL_LIGHT_LC_SETUP_SRV(srv_pub, srv_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_LC_SETUP_SRV, \ + NULL, srv_pub, srv_data) + +/** Parameters of Light Lightness state */ +typedef struct { + uint16_t lightness_linear; /*!< The present value of Light Lightness Linear state */ + uint16_t target_lightness_linear; /*!< The target value of Light Lightness Linear state */ + + uint16_t lightness_actual; /*!< The present value of Light Lightness Actual state */ + uint16_t target_lightness_actual; /*!< The target value of Light Lightness Actual state */ + + uint16_t lightness_last; /*!< The value of Light Lightness Last state */ + uint16_t lightness_default; /*!< The value of Light Lightness Default state */ + + uint8_t status_code; /*!< The status code of setting Light Lightness Range state */ + uint16_t lightness_range_min; /*!< The minimum value of Light Lightness Range state */ + uint16_t lightness_range_max; /*!< The maximum value of Light Lightness Range state */ +} esp_ble_mesh_light_lightness_state_t; + +/** User data of Light Lightness Server Model */ +typedef struct { + esp_ble_mesh_model_t *model; /*!< Pointer to the Lighting Lightness Server Model. Initialized internally. */ + esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */ + esp_ble_mesh_light_lightness_state_t *state; /*!< Parameters of the Light Lightness state */ + esp_ble_mesh_last_msg_info_t last; /*!< Parameters of the last received set message */ + esp_ble_mesh_state_transition_t actual_transition; /*!< Parameters of state transition */ + esp_ble_mesh_state_transition_t linear_transition; /*!< Parameters of state transition */ + int32_t tt_delta_lightness_actual; /*!< Delta change value of lightness actual state transition */ + int32_t tt_delta_lightness_linear; /*!< Delta change value of lightness linear state transition */ +} esp_ble_mesh_light_lightness_srv_t; + +/** User data of Light Lightness Setup Server Model */ +typedef struct { + esp_ble_mesh_model_t *model; /*!< Pointer to the Lighting Lightness 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_light_lightness_state_t *state; /*!< Parameters of the Light Lightness state */ +} esp_ble_mesh_light_lightness_setup_srv_t; + +/** Parameters of Light CTL state */ +typedef struct { + uint16_t lightness; /*!< The present value of Light CTL Lightness state */ + uint16_t target_lightness; /*!< The target value of Light CTL Lightness state */ + + uint16_t temperature; /*!< The present value of Light CTL Temperature state */ + uint16_t target_temperature; /*!< The target value of Light CTL Temperature state */ + + int16_t delta_uv; /*!< The present value of Light CTL Delta UV state */ + int16_t target_delta_uv; /*!< The target value of Light CTL Delta UV state */ + + uint8_t status_code; /*!< The statue code of setting Light CTL Temperature Range state */ + uint16_t temperature_range_min; /*!< The minimum value of Light CTL Temperature Range state */ + uint16_t temperature_range_max; /*!< The maximum value of Light CTL Temperature Range state */ + + uint16_t lightness_default; /*!< The value of Light Lightness Default state */ + uint16_t temperature_default; /*!< The value of Light CTL Temperature Default state */ + int16_t delta_uv_default; /*!< The value of Light CTL Delta UV Default state */ +} esp_ble_mesh_light_ctl_state_t; + +/** User data of Light CTL Server Model */ +typedef struct { + esp_ble_mesh_model_t *model; /*!< Pointer to the Lighting CTL Server Model. Initialized internally. */ + esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */ + esp_ble_mesh_light_ctl_state_t *state; /*!< Parameters of the Light CTL 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_lightness; /*!< Delta change value of lightness state transition */ + int32_t tt_delta_temperature; /*!< Delta change value of temperature state transition */ + int32_t tt_delta_delta_uv; /*!< Delta change value of delta uv state transition */ +} esp_ble_mesh_light_ctl_srv_t; + +/** User data of Light CTL Setup Server Model */ +typedef struct { + esp_ble_mesh_model_t *model; /*!< Pointer to the Lighting CTL 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_light_ctl_state_t *state; /*!< Parameters of the Light CTL state */ +} esp_ble_mesh_light_ctl_setup_srv_t; + +/** User data of Light CTL Temperature Server Model */ +typedef struct { + esp_ble_mesh_model_t *model; /*!< Pointer to the Lighting CTL Temperature Server Model. Initialized internally. */ + esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */ + esp_ble_mesh_light_ctl_state_t *state; /*!< Parameters of the Light CTL 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_temperature; /*!< Delta change value of temperature state transition */ + int32_t tt_delta_delta_uv; /*!< Delta change value of delta uv state transition */ +} esp_ble_mesh_light_ctl_temp_srv_t; + +/** Parameters of Light HSL state */ +typedef struct { + uint16_t lightness; /*!< The present value of Light HSL Lightness state */ + uint16_t target_lightness; /*!< The target value of Light HSL Lightness state */ + + uint16_t hue; /*!< The present value of Light HSL Hue state */ + uint16_t target_hue; /*!< The target value of Light HSL Hue state */ + + uint16_t saturation; /*!< The present value of Light HSL Saturation state */ + uint16_t target_saturation; /*!< The target value of Light HSL Saturation state */ + + uint16_t lightness_default; /*!< The value of Light Lightness Default state */ + uint16_t hue_default; /*!< The value of Light HSL Hue Default state */ + uint16_t saturation_default; /*!< The value of Light HSL Saturation Default state */ + + uint8_t status_code; /*!< The status code of setting Light HSL Hue & Saturation Range state */ + uint16_t hue_range_min; /*!< The minimum value of Light HSL Hue Range state */ + uint16_t hue_range_max; /*!< The maximum value of Light HSL Hue Range state */ + uint16_t saturation_range_min; /*!< The minimum value of Light HSL Saturation state */ + uint16_t saturation_range_max; /*!< The maximum value of Light HSL Saturation state */ +} esp_ble_mesh_light_hsl_state_t; + +/** User data of Light HSL Server Model */ +typedef struct { + esp_ble_mesh_model_t *model; /*!< Pointer to the Lighting HSL Server Model. Initialized internally. */ + esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */ + esp_ble_mesh_light_hsl_state_t *state; /*!< Parameters of the Light HSL 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_lightness; /*!< Delta change value of lightness state transition */ + int32_t tt_delta_hue; /*!< Delta change value of hue state transition */ + int32_t tt_delta_saturation; /*!< Delta change value of saturation state transition */ +} esp_ble_mesh_light_hsl_srv_t; + +/** User data of Light HSL Setup Server Model */ +typedef struct { + esp_ble_mesh_model_t *model; /*!< Pointer to the Lighting HSL 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_light_hsl_state_t *state; /*!< Parameters of the Light HSL state */ +} esp_ble_mesh_light_hsl_setup_srv_t; + +/** User data of Light HSL Hue Server Model */ +typedef struct { + esp_ble_mesh_model_t *model; /*!< Pointer to the Lighting HSL Hue Server Model. Initialized internally. */ + esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */ + esp_ble_mesh_light_hsl_state_t *state; /*!< Parameters of the Light HSL 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_hue; /*!< Delta change value of hue state transition */ +} esp_ble_mesh_light_hsl_hue_srv_t; + +/** User data of Light HSL Saturation Server Model */ +typedef struct { + esp_ble_mesh_model_t *model; /*!< Pointer to the Lighting HSL Saturation Server Model. Initialized internally. */ + esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */ + esp_ble_mesh_light_hsl_state_t *state; /*!< Parameters of the Light HSL 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_saturation; /*!< Delta change value of saturation state transition */ +} esp_ble_mesh_light_hsl_sat_srv_t; + +/** Parameters of Light xyL state */ +typedef struct { + uint16_t lightness; /*!< The present value of Light xyL Lightness state */ + uint16_t target_lightness; /*!< The target value of Light xyL Lightness state */ + + uint16_t x; /*!< The present value of Light xyL x state */ + uint16_t target_x; /*!< The target value of Light xyL x state */ + + uint16_t y; /*!< The present value of Light xyL y state */ + uint16_t target_y; /*!< The target value of Light xyL y state */ + + uint16_t lightness_default; /*!< The value of Light Lightness Default state */ + uint16_t x_default; /*!< The value of Light xyL x Default state */ + uint16_t y_default; /*!< The value of Light xyL y Default state */ + + uint8_t status_code; /*!< The status code of setting Light xyL x & y Range state */ + uint16_t x_range_min; /*!< The minimum value of Light xyL x Range state */ + uint16_t x_range_max; /*!< The maximum value of Light xyL x Range state */ + uint16_t y_range_min; /*!< The minimum value of Light xyL y Range state */ + uint16_t y_range_max; /*!< The maximum value of Light xyL y Range state */ +} esp_ble_mesh_light_xyl_state_t; + +/** User data of Light xyL Server Model */ +typedef struct { + esp_ble_mesh_model_t *model; /*!< Pointer to the Lighting xyL Server Model. Initialized internally. */ + esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */ + esp_ble_mesh_light_xyl_state_t *state; /*!< Parameters of the Light xyL 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_lightness; /*!< Delta change value of lightness state transition */ + int32_t tt_delta_x; /*!< Delta change value of x state transition */ + int32_t tt_delta_y; /*!< Delta change value of y state transition */ +} esp_ble_mesh_light_xyl_srv_t; + +/** User data of Light xyL Setup Server Model */ +typedef struct { + esp_ble_mesh_model_t *model; /*!< Pointer to the Lighting xyL 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_light_xyl_state_t *state; /*!< Parameters of the Light xyL state */ +} esp_ble_mesh_light_xyl_setup_srv_t; + +/** Parameters of Light LC states */ +typedef struct { + /** + * 0b0 The controller is turned off. + * - The binding with the Light Lightness state is disabled. + * 0b1 The controller is turned on. + * - The binding with the Light Lightness state is enabled. + */ + uint32_t mode : 1, /*!< The value of Light LC Mode state */ + occupancy_mode : 1, /*!< The value of Light LC Occupancy Mode state */ + light_onoff : 1, /*!< The present value of Light LC Light OnOff state */ + target_light_onoff : 1, /*!< The target value of Light LC Light OnOff state */ + occupancy : 1, /*!< The value of Light LC Occupancy state */ + ambient_luxlevel : 24; /*!< The value of Light LC Ambient LuxLevel state */ + + /** + * 1. Light LC Linear Output = max((Lightness Out)^2/65535, Regulator Output) + * 2. If the Light LC Mode state is set to 0b1, the binding is enabled and upon + * a change of the Light LC Linear Output state, the following operation + * shall be performed: + * Light Lightness Linear = Light LC Linear Output + * 3. If the Light LC Mode state is set to 0b0, the binding is disabled (i.e., + * upon a change of the Light LC Linear Output state, no operation on the + * Light Lightness Linear state is performed). + */ + uint16_t linear_output; /*!< The value of Light LC Linear Output state */ +} esp_ble_mesh_light_lc_state_t; + +/** + * Parameters of Light Property states. + * The Light LC Property states are read / write states that determine the + * configuration of a Light Lightness Controller. Each state is represented + * by a device property and is controlled by Light LC Property messages. + */ +typedef struct { + /** + * A timing state that determines the delay for changing the Light LC + * Occupancy state upon receiving a Sensor Status message from an + * occupancy sensor. + */ + uint32_t time_occupancy_delay; /*!< The value of Light LC Time Occupancy Delay state */ + /** + * A timing state that determines the time the controlled lights fade + * to the level determined by the Light LC Lightness On state. + */ + uint32_t time_fade_on; /*!< The value of Light LC Time Fade On state */ + /** + * A timing state that determines the time the controlled lights stay + * at the level determined by the Light LC Lightness On state. + */ + uint32_t time_run_on; /*!< The value of Light LC Time Run On state */ + /** + * A timing state that determines the time the controlled lights fade + * from the level determined by the Light LC Lightness On state to the + * level determined by the Light Lightness Prolong state. + */ + uint32_t time_fade; /*!< The value of Light LC Time Fade state */ + /** + * A timing state that determines the time the controlled lights stay at + * the level determined by the Light LC Lightness Prolong state. + */ + uint32_t time_prolong; /*!< The value of Light LC Time Prolong state */ + /** + * A timing state that determines the time the controlled lights fade from + * the level determined by the Light LC Lightness Prolong state to the level + * determined by the Light LC Lightness Standby state when the transition is + * automatic. + */ + uint32_t time_fade_standby_auto; /*!< The value of Light LC Time Fade Standby Auto state */ + /** + * A timing state that determines the time the controlled lights fade from + * the level determined by the Light LC Lightness Prolong state to the level + * determined by the Light LC Lightness Standby state when the transition is + * triggered by a change in the Light LC Light OnOff state. + */ + uint32_t time_fade_standby_manual; /*!< The value of Light LC Time Fade Standby Manual state */ + + /** + * A lightness state that determines the perceptive light lightness at the + * Occupancy and Run internal controller states. + */ + uint16_t lightness_on; /*!< The value of Light LC Lightness On state */ + /** + * A lightness state that determines the light lightness at the Prolong + * internal controller state. + */ + uint16_t lightness_prolong; /*!< The value of Light LC Lightness Prolong state */ + /** + * A lightness state that determines the light lightness at the Standby + * internal controller state. + */ + uint16_t lightness_standby; /*!< The value of Light LC Lightness Standby state */ + + /** + * A uint16 state representing the Ambient LuxLevel level that determines + * if the controller transitions from the Light Control Standby state. + */ + uint16_t ambient_luxlevel_on; /*!< The value of Light LC Ambient LuxLevel On state */ + /** + * A uint16 state representing the required Ambient LuxLevel level in the + * Prolong state. + */ + uint16_t ambient_luxlevel_prolong; /*!< The value of Light LC Ambient LuxLevel Prolong state */ + /** + * A uint16 state representing the required Ambient LuxLevel level in the + * Standby state. + */ + uint16_t ambient_luxlevel_standby; /*!< The value of Light LC Ambient LuxLevel Standby state */ + + /** + * A float32 state representing the integral coefficient that determines the + * integral part of the equation defining the output of the Light LC PI + * Feedback Regulator, when Light LC Ambient LuxLevel is less than LuxLevel + * Out. Valid range: 0.0 ~ 1000.0. The default value is 250.0. + */ + float regulator_kiu; /*!< The value of Light LC Regulator Kiu state */ + /** + * A float32 state representing the integral coefficient that determines the + * integral part of the equation defining the output of the Light LC PI + * Feedback Regulator, when Light LC Ambient LuxLevel is greater than or equal + * to the value of the LuxLevel Out state. Valid range: 0.0 ~ 1000.0. The + * default value is 25.0. + */ + float regulator_kid; /*!< The value of Light LC Regulator Kid state */ + /** + * A float32 state representing the proportional coefficient that determines + * the proportional part of the equation defining the output of the Light LC + * PI Feedback Regulator, when Light LC Ambient LuxLevel is less than the value + * of the LuxLevel Out state. Valid range: 0.0 ~ 1000.0. The default value is 80.0. + */ + float regulator_kpu; /*!< The value of Light LC Regulator Kpu state */ + /** + * A float32 state representing the proportional coefficient that determines + * the proportional part of the equation defining the output of the Light LC PI + * Feedback Regulator, when Light LC Ambient LuxLevel is greater than or equal + * to the value of the LuxLevel Out state. Valid range: 0.0 ~ 1000.0. The default + * value is 80.0. + */ + float regulator_kpd; /*!< The value of Light LC Regulator Kpd state */ + /** + * A int8 state representing the percentage accuracy of the Light LC PI Feedback + * Regulator. Valid range: 0.0 ~ 100.0. The default value is 2.0. + */ + int8_t regulator_accuracy; /*!< The value of Light LC Regulator Accuracy state */ + + /** + * If the message Raw field contains a Raw Value for the Time Since Motion + * Sensed device property, which represents a value less than or equal to + * the value of the Light LC Occupancy Delay state, it shall delay setting + * the Light LC Occupancy state to 0b1 by the difference between the value + * of the Light LC Occupancy Delay state and the received Time Since Motion + * value. + */ + uint32_t set_occupancy_to_1_delay; /*!< The value of the difference between value of the + Light LC Occupancy Delay state and the received + Time Since Motion value */ +} esp_ble_mesh_light_lc_property_state_t; + +/** This enum value is the Light LC State Machine states */ +typedef enum { + ESP_BLE_MESH_LC_OFF, + ESP_BLE_MESH_LC_STANDBY, + ESP_BLE_MESH_LC_FADE_ON, + ESP_BLE_MESH_LC_RUN, + ESP_BLE_MESH_LC_FADE, + ESP_BLE_MESH_LC_PROLONG, + ESP_BLE_MESH_LC_FADE_STANDBY_AUTO, + ESP_BLE_MESH_LC_FADE_STANDBY_MANUAL, +} esp_ble_mesh_lc_state_t; + +/** Parameters of Light LC state machine */ +typedef struct { + /** + * The Fade On, Fade, Fade Standby Auto, and Fade Standby Manual states are + * transition states that define the transition of the Lightness Out and + * LuxLevel Out states. This transition can be started as a result of the + * Light LC State Machine change or as a result of receiving the Light LC + * Light OnOff Set or Light LC Light Set Unacknowledged message. + */ + struct { + uint8_t fade_on; /*!< The value of transition time of Light LC Time Fade On */ + uint8_t fade; /*!< The value of transition time of Light LC Time Fade */ + uint8_t fade_standby_auto; /*!< The value of transition time of Light LC Time Fade Standby Auto */ + uint8_t fade_standby_manual; /*!< The value of transition time of Light LC Time Fade Standby Manual */ + } trans_time; /*!< The value of transition time */ + esp_ble_mesh_lc_state_t state; /*!< The value of Light LC state machine state */ + struct k_delayed_work timer; /*!< Timer of Light LC state machine */ +} esp_ble_mesh_light_lc_state_machine_t; + +/** Parameters of Light Lightness controller */ +typedef struct { + esp_ble_mesh_light_lc_state_t state; /*!< Parameters of Light LC state */ + esp_ble_mesh_light_lc_property_state_t prop_state; /*!< Parameters of Light LC Property state */ + esp_ble_mesh_light_lc_state_machine_t state_machine; /*!< Parameters of Light LC state machine */ +} esp_ble_mesh_light_control_t; + +/** User data of Light LC Server Model */ +typedef struct { + esp_ble_mesh_model_t *model; /*!< Pointer to the Lighting LC Server Model. Initialized internally. */ + esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */ + esp_ble_mesh_light_control_t *lc; /*!< Parameters of the Light controller */ + 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_light_lc_srv_t; + +/** User data of Light LC Setup Server Model */ +typedef struct { + esp_ble_mesh_model_t *model; /*!< Pointer to the Lighting LC 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_light_control_t *lc; /*!< Parameters of the Light controller */ +} esp_ble_mesh_light_lc_setup_srv_t; + +/** Parameter of Light Lightness Actual state change event */ +typedef struct { + uint16_t lightness; /*!< The value of Light Lightness Actual state */ +} esp_ble_mesh_state_change_light_lightness_set_t; + +/** Parameter of Light Lightness Linear state change event */ +typedef struct { + uint16_t lightness; /*!< The value of Light Lightness Linear state */ +} esp_ble_mesh_state_change_light_lightness_linear_set_t; + +/** Parameter of Light Lightness Default state change event */ +typedef struct { + uint16_t lightness; /*!< The value of Light Lightness Default state */ +} esp_ble_mesh_state_change_light_lightness_default_set_t; + +/** Parameters of Light Lightness Range state change event */ +typedef struct { + uint16_t range_min; /*!< The minimum value of Light Lightness Range state */ + uint16_t range_max; /*!< The maximum value of Light Lightness Range state */ +} esp_ble_mesh_state_change_light_lightness_range_set_t; + +/** Parameters of Light CTL state change event */ +typedef struct { + uint16_t lightness; /*!< The value of Light CTL Lightness state */ + uint16_t temperature; /*!< The value of Light CTL Temperature state */ + int16_t delta_uv; /*!< The value of Light CTL Delta UV state */ +} esp_ble_mesh_state_change_light_ctl_set_t; + +/** Parameters of Light CTL Temperature state change event */ +typedef struct { + uint16_t temperature; /*!< The value of Light CTL Temperature state */ + int16_t delta_uv; /*!< The value of Light CTL Delta UV state */ +} esp_ble_mesh_state_change_light_ctl_temperature_set_t; + +/** Parameters of Light CTL Temperature Range state change event */ +typedef struct { + uint16_t range_min; /*!< The minimum value of Light CTL Temperature Range state */ + uint16_t range_max; /*!< The maximum value of Light CTL Temperature Range state */ +} esp_ble_mesh_state_change_light_ctl_temperature_range_set_t; + +/** Parameters of Light CTL Default state change event */ +typedef struct { + uint16_t lightness; /*!< The value of Light Lightness Default state */ + uint16_t temperature; /*!< The value of Light CTL Temperature Default state */ + int16_t delta_uv; /*!< The value of Light CTL Delta UV Default state */ +} esp_ble_mesh_state_change_light_ctl_default_set_t; + +/** Parameters of Light HSL state change event */ +typedef struct { + uint16_t lightness; /*!< The value of Light HSL Lightness state */ + uint16_t hue; /*!< The value of Light HSL Hue state */ + uint16_t saturation; /*!< The value of Light HSL Saturation state */ +} esp_ble_mesh_state_change_light_hsl_set_t; + +/** Parameter of Light HSL Hue state change event */ +typedef struct { + uint16_t hue; /*!< The value of Light HSL Hue state */ +} esp_ble_mesh_state_change_light_hsl_hue_set_t; + +/** Parameter of Light HSL Saturation state change event */ +typedef struct { + uint16_t saturation; /*!< The value of Light HSL Saturation state */ +} esp_ble_mesh_state_change_light_hsl_saturation_set_t; + +/** Parameters of Light HSL Default state change event */ +typedef struct { + uint16_t lightness; /*!< The value of Light HSL Lightness Default state */ + uint16_t hue; /*!< The value of Light HSL Hue Default state */ + uint16_t saturation; /*!< The value of Light HSL Saturation Default state */ +} esp_ble_mesh_state_change_light_hsl_default_set_t; + +/** Parameters of Light HSL Range state change event */ +typedef struct { + uint16_t hue_range_min; /*!< The minimum hue value of Light HSL Range state */ + uint16_t hue_range_max; /*!< The maximum hue value of Light HSL Range state */ + uint16_t saturation_range_min; /*!< The minimum saturation value of Light HSL Range state */ + uint16_t saturation_range_max; /*!< The maximum saturation value of Light HSL Range state */ +} esp_ble_mesh_state_change_light_hsl_range_set_t; + +/** Parameters of Light xyL state change event */ +typedef struct { + uint16_t lightness; /*!< The value of Light xyL Lightness state */ + uint16_t x; /*!< The value of Light xyL x state */ + uint16_t y; /*!< The value of Light xyL y state */ +} esp_ble_mesh_state_change_light_xyl_set_t; + +/** Parameters of Light xyL Default state change event */ +typedef struct { + uint16_t lightness; /*!< The value of Light Lightness Default state */ + uint16_t x; /*!< The value of Light xyL x Default state */ + uint16_t y; /*!< The value of Light xyL y Default state */ +} esp_ble_mesh_state_change_light_xyl_default_set_t; + +/** Parameters of Light xyL Range state change event */ +typedef struct { + uint16_t x_range_min; /*!< The minimum value of Light xyL x Range state */ + uint16_t x_range_max; /*!< The maximum value of Light xyL x Range state */ + uint16_t y_range_min; /*!< The minimum value of Light xyL y Range state */ + uint16_t y_range_max; /*!< The maximum value of Light xyL y Range state */ +} esp_ble_mesh_state_change_light_xyl_range_set_t; + +/** Parameter of Light LC Mode state change event */ +typedef struct { + uint8_t mode; /*!< The value of Light LC Mode state */ +} esp_ble_mesh_state_change_light_lc_mode_set_t; + +/** Parameter of Light LC Occupancy Mode state change event */ +typedef struct { + uint8_t mode; /*!< The value of Light LC Occupancy Mode state */ +} esp_ble_mesh_state_change_light_lc_om_set_t; + +/** Parameter of Light LC Light OnOff state change event */ +typedef struct { + uint8_t onoff; /*!< The value of Light LC Light OnOff state */ +} esp_ble_mesh_state_change_light_lc_light_onoff_set_t; + +/** Parameters of Light LC Property state change event */ +typedef struct { + uint16_t property_id; /*!< The property id of Light LC Property state */ + struct net_buf_simple *property_value; /*!< The property value of Light LC Property state */ +} esp_ble_mesh_state_change_light_lc_property_set_t; + +/** Parameters of Sensor Status state change event */ +typedef struct { + uint16_t property_id; /*!< The value of Sensor Property ID */ + /** Parameters of Sensor Status related state */ + union { + uint8_t occupancy; /*!< The value of Light LC Occupancy state */ + uint32_t set_occupancy_to_1_delay; /*!< The value of Light LC Set Occupancy to 1 Delay state */ + uint32_t ambient_luxlevel; /*!< The value of Light LC Ambient Luxlevel state */ + } state; +} esp_ble_mesh_state_change_sensor_status_t; + +/** + * @brief Lighting 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_light_lightness_set_t lightness_set; /*!< Light Lightness Set */ + esp_ble_mesh_state_change_light_lightness_linear_set_t lightness_linear_set; /*!< Light Lightness Linear Set */ + esp_ble_mesh_state_change_light_lightness_default_set_t lightness_default_set; /*!< Light Lightness Default Set */ + esp_ble_mesh_state_change_light_lightness_range_set_t lightness_range_set; /*!< Light Lightness Range Set */ + esp_ble_mesh_state_change_light_ctl_set_t ctl_set; /*!< Light CTL Set */ + esp_ble_mesh_state_change_light_ctl_temperature_set_t ctl_temp_set; /*!< Light CTL Temperature Set */ + esp_ble_mesh_state_change_light_ctl_temperature_range_set_t ctl_temp_range_set; /*!< Light CTL Temperature Range Set */ + esp_ble_mesh_state_change_light_ctl_default_set_t ctl_default_set; /*!< Light CTL Default Set */ + esp_ble_mesh_state_change_light_hsl_set_t hsl_set; /*!< Light HSL Set */ + esp_ble_mesh_state_change_light_hsl_hue_set_t hsl_hue_set; /*!< Light HSL Hue Set */ + esp_ble_mesh_state_change_light_hsl_saturation_set_t hsl_saturation_set; /*!< Light HSL Saturation Set */ + esp_ble_mesh_state_change_light_hsl_default_set_t hsl_default_set; /*!< Light HSL Default Set */ + esp_ble_mesh_state_change_light_hsl_range_set_t hsl_range_set; /*!< Light HSL Range Set */ + esp_ble_mesh_state_change_light_xyl_set_t xyl_set; /*!< Light xyL Set */ + esp_ble_mesh_state_change_light_xyl_default_set_t xyl_default_set; /*!< Light xyL Default Set */ + esp_ble_mesh_state_change_light_xyl_range_set_t xyl_range_set; /*!< Light xyL Range Set */ + esp_ble_mesh_state_change_light_lc_mode_set_t lc_mode_set; /*!< Light LC Mode Set */ + esp_ble_mesh_state_change_light_lc_om_set_t lc_om_set; /*!< Light LC Occupancy Mode Set */ + esp_ble_mesh_state_change_light_lc_light_onoff_set_t lc_light_onoff_set; /*!< Light LC Light OnOff Set */ + esp_ble_mesh_state_change_light_lc_property_set_t lc_property_set; /*!< Light LC Property Set */ + esp_ble_mesh_state_change_sensor_status_t sensor_status; /*!< Sensor Status */ +} esp_ble_mesh_lighting_server_state_change_t; + +/** Context of the received Light LC Property Get message */ +typedef struct { + uint16_t property_id; /*!< Property ID identifying a Light LC Property */ +} esp_ble_mesh_server_recv_light_lc_property_get_t; + +/** + * @brief Lighting Server Model received get message union + */ +typedef union { + esp_ble_mesh_server_recv_light_lc_property_get_t lc_property; /*!< Light LC Property Get */ +} esp_ble_mesh_lighting_server_recv_get_msg_t; + +/** Context of the received Light Lightness Set message */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t lightness; /*!< Target value of light lightness 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_light_lightness_set_t; + +/** Context of the received Light Lightness Linear Set message */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t lightness; /*!< Target value of light lightness linear 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_light_lightness_linear_set_t; + +/** Context of the received Light Lightness Default Set message */ +typedef struct { + uint16_t lightness; /*!< The value of the Light Lightness Default state */ +} esp_ble_mesh_server_recv_light_lightness_default_set_t; + +/** Context of the received Light Lightness Range Set message */ +typedef struct { + uint16_t range_min; /*!< Value of range min field of light lightness range state */ + uint16_t range_max; /*!< Value of range max field of light lightness range state */ +} esp_ble_mesh_server_recv_light_lightness_range_set_t; + +/** Context of the received Light CTL Set message */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t lightness; /*!< Target value of light ctl lightness state */ + uint16_t temperature; /*!< Target value of light ctl temperature state */ + int16_t delta_uv; /*!< Target value of light ctl delta UV 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_light_ctl_set_t; + +/** Context of the received Light CTL Temperature Set message */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t temperature; /*!< Target value of light ctl temperature state */ + int16_t delta_uv; /*!< Target value of light ctl delta UV 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_light_ctl_temperature_set_t; + +/** Context of the received Light CTL Temperature Range Set message */ +typedef struct { + uint16_t range_min; /*!< Value of temperature range min field of light ctl temperature range state */ + uint16_t range_max; /*!< Value of temperature range max field of light ctl temperature range state */ +} esp_ble_mesh_server_recv_light_ctl_temperature_range_set_t; + +/** Context of the received Light CTL Default Set message */ +typedef struct { + uint16_t lightness; /*!< Value of light lightness default state */ + uint16_t temperature; /*!< Value of light temperature default state */ + int16_t delta_uv; /*!< Value of light delta UV default state */ +} esp_ble_mesh_server_recv_light_ctl_default_set_t; + +/** Context of the received Light HSL Set message */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t lightness; /*!< Target value of light hsl lightness state */ + uint16_t hue; /*!< Target value of light hsl hue state */ + uint16_t saturation; /*!< Target value of light hsl saturation 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_light_hsl_set_t; + +/** Context of the received Light HSL Hue Set message */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t hue; /*!< Target value of light hsl hue 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_light_hsl_hue_set_t; + +/** Context of the received Light HSL Saturation Set message */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t saturation; /*!< Target value of light hsl hue 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_light_hsl_saturation_set_t; + +/** Context of the received Light HSL Default Set message */ +typedef struct { + uint16_t lightness; /*!< Value of light lightness default state */ + uint16_t hue; /*!< Value of light hue default state */ + uint16_t saturation; /*!< Value of light saturation default state */ +} esp_ble_mesh_server_recv_light_hsl_default_set_t; + +/** Context of the received Light HSL Range Set message */ +typedef struct { + uint16_t hue_range_min; /*!< Value of hue range min field of light hsl hue range state */ + uint16_t hue_range_max; /*!< Value of hue range max field of light hsl hue range state */ + uint16_t saturation_range_min; /*!< Value of saturation range min field of light hsl saturation range state */ + uint16_t saturation_range_max; /*!< Value of saturation range max field of light hsl saturation range state */ +} esp_ble_mesh_server_recv_light_hsl_range_set_t; + +/** Context of the received Light xyL Set message */ +typedef struct { + bool op_en; /*!< Indicate whether optional parameters included */ + uint16_t lightness; /*!< The target value of the Light xyL Lightness state */ + uint16_t x; /*!< The target value of the Light xyL x state */ + uint16_t y; /*!< The target value of the Light xyL y state */ + uint8_t tid; /*!< Transaction Identifier */ + uint8_t trans_time; /*!< Time to complete state transition (optional) */ + uint8_t delay; /*!< Indicate message execution delay (C.1) */ +} esp_ble_mesh_server_recv_light_xyl_set_t; + +/** Context of the received Light xyL Default Set message */ +typedef struct { + uint16_t lightness; /*!< The value of the Light Lightness Default state */ + uint16_t x; /*!< The value of the Light xyL x Default state */ + uint16_t y; /*!< The value of the Light xyL y Default state */ +} esp_ble_mesh_server_recv_light_xyl_default_set_t; + +/** Context of the received Light xyl Range Set message */ +typedef struct { + uint16_t x_range_min; /*!< The value of the xyL x Range Min field of the Light xyL x Range state */ + uint16_t x_range_max; /*!< The value of the xyL x Range Max field of the Light xyL x Range state */ + uint16_t y_range_min; /*!< The value of the xyL y Range Min field of the Light xyL y Range state */ + uint16_t y_range_max; /*!< The value of the xyL y Range Max field of the Light xyL y Range state */ +} esp_ble_mesh_server_recv_light_xyl_range_set_t; + +/** Context of the received Light LC Mode Set message */ +typedef struct { + uint8_t mode; /*!< The target value of the Light LC Mode state */ +} esp_ble_mesh_server_recv_light_lc_mode_set_t; + +/** Context of the received Light OM Set message */ +typedef struct { + uint8_t mode; /*!< The target value of the Light LC Occupancy Mode state */ +} esp_ble_mesh_server_recv_light_lc_om_set_t; + +/** Context of the received Light LC Light OnOff Set message */ +typedef struct { + bool op_en; /*!< Indicate whether optional parameters included */ + uint8_t light_onoff; /*!< The target value of the Light LC Light OnOff state */ + uint8_t tid; /*!< Transaction Identifier */ + uint8_t trans_time; /*!< Time to complete state transition (optional) */ + uint8_t delay; /*!< Indicate message execution delay (C.1) */ +} esp_ble_mesh_server_recv_light_lc_light_onoff_set_t; + +/** Context of the received Light LC Property Set message */ +typedef struct { + uint16_t property_id; /*!< Property ID identifying a Light LC Property */ + struct net_buf_simple *property_value; /*!< Raw value for the Light LC Property */ +} esp_ble_mesh_server_recv_light_lc_property_set_t; + +/** + * @brief Lighting Server Model received set message union + */ +typedef union { + esp_ble_mesh_server_recv_light_lightness_set_t lightness; /*!< Light Lightness Set/Light Lightness Set Unack */ + esp_ble_mesh_server_recv_light_lightness_linear_set_t lightness_linear; /*!< Light Lightness Linear Set/Light Lightness Linear Set Unack */ + esp_ble_mesh_server_recv_light_lightness_default_set_t lightness_default; /*!< Light Lightness Default Set/Light Lightness Default Set Unack */ + esp_ble_mesh_server_recv_light_lightness_range_set_t lightness_range; /*!< Light Lightness Range Set/Light Lightness Range Set Unack */ + esp_ble_mesh_server_recv_light_ctl_set_t ctl; /*!< Light CTL Set/Light CTL Set Unack */ + esp_ble_mesh_server_recv_light_ctl_temperature_set_t ctl_temp; /*!< Light CTL Temperature Set/Light CTL Temperature Set Unack */ + esp_ble_mesh_server_recv_light_ctl_temperature_range_set_t ctl_temp_range; /*!< Light CTL Temperature Range Set/Light CTL Temperature Range Set Unack */ + esp_ble_mesh_server_recv_light_ctl_default_set_t ctl_default; /*!< Light CTL Default Set/Light CTL Default Set Unack */ + esp_ble_mesh_server_recv_light_hsl_set_t hsl; /*!< Light HSL Set/Light HSL Set Unack */ + esp_ble_mesh_server_recv_light_hsl_hue_set_t hsl_hue; /*!< Light HSL Hue Set/Light HSL Hue Set Unack */ + esp_ble_mesh_server_recv_light_hsl_saturation_set_t hsl_saturation; /*!< Light HSL Saturation Set/Light HSL Saturation Set Unack */ + esp_ble_mesh_server_recv_light_hsl_default_set_t hsl_default; /*!< Light HSL Default Set/Light HSL Default Set Unack */ + esp_ble_mesh_server_recv_light_hsl_range_set_t hsl_range; /*!< Light HSL Range Set/Light HSL Range Set Unack */ + esp_ble_mesh_server_recv_light_xyl_set_t xyl; /*!< Light xyL Set/Light xyL Set Unack */ + esp_ble_mesh_server_recv_light_xyl_default_set_t xyl_default; /*!< Light xyL Default Set/Light xyL Default Set Unack */ + esp_ble_mesh_server_recv_light_xyl_range_set_t xyl_range; /*!< Light xyL Range Set/Light xyL Range Set Unack */ + esp_ble_mesh_server_recv_light_lc_mode_set_t lc_mode; /*!< Light LC Mode Set/Light LC Mode Set Unack */ + esp_ble_mesh_server_recv_light_lc_om_set_t lc_om; /*!< Light LC OM Set/Light LC OM Set Unack */ + esp_ble_mesh_server_recv_light_lc_light_onoff_set_t lc_light_onoff; /*!< Light LC Light OnOff Set/Light LC Light OnOff Set Unack */ + esp_ble_mesh_server_recv_light_lc_property_set_t lc_property; /*!< Light LC Property Set/Light LC Property Set Unack */ +} esp_ble_mesh_lighting_server_recv_set_msg_t; + +/** Context of the received Sensor Status message */ +typedef struct { + struct net_buf_simple *data; /*!< Value of sensor data state (optional) */ +} esp_ble_mesh_server_recv_sensor_status_t; + +/** + * @brief Lighting Server Model received status message union + */ +typedef union { + esp_ble_mesh_server_recv_sensor_status_t sensor_status; /*!< Sensor Status */ +} esp_ble_mesh_lighting_server_recv_status_msg_t; + +/** + * @brief Lighting Server Model callback value union + */ +typedef union { + esp_ble_mesh_lighting_server_state_change_t state_change; /*!< ESP_BLE_MESH_LIGHTING_SERVER_STATE_CHANGE_EVT */ + esp_ble_mesh_lighting_server_recv_get_msg_t get; /*!< ESP_BLE_MESH_LIGHTING_SERVER_RECV_GET_MSG_EVT */ + esp_ble_mesh_lighting_server_recv_set_msg_t set; /*!< ESP_BLE_MESH_LIGHTING_SERVER_RECV_SET_MSG_EVT */ + esp_ble_mesh_lighting_server_recv_status_msg_t status; /*!< ESP_BLE_MESH_LIGHTING_SERVER_RECV_STATUS_MSG_EVT */ +} esp_ble_mesh_lighting_server_cb_value_t; + +/** Lighting Server Model callback parameters */ +typedef struct { + esp_ble_mesh_model_t *model; /*!< Pointer to Lighting Server Models */ + esp_ble_mesh_msg_ctx_t ctx; /*!< Context of the received messages */ + esp_ble_mesh_lighting_server_cb_value_t value; /*!< Value of the received Lighting Messages */ +} esp_ble_mesh_lighting_server_cb_param_t; + +/** This enum value is the event of Lighting 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 Lighting 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 Lighting Set/Set Unack messages + * are received. + */ + ESP_BLE_MESH_LIGHTING_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 Lighting Get messages are received. + */ + ESP_BLE_MESH_LIGHTING_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 Lighting Set/Set Unack messages are received. + */ + ESP_BLE_MESH_LIGHTING_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 Sensor Status message is received. + */ + ESP_BLE_MESH_LIGHTING_SERVER_RECV_STATUS_MSG_EVT, + ESP_BLE_MESH_LIGHTING_SERVER_EVT_MAX, +} esp_ble_mesh_lighting_server_cb_event_t; + +/** + * @brief Bluetooth Mesh Lighting Server Model function. + */ + +/** + * @brief Lighting Server Model callback function type + * @param event: Event type + * @param param: Pointer to callback parameter + */ +typedef void (* esp_ble_mesh_lighting_server_cb_t)(esp_ble_mesh_lighting_server_cb_event_t event, + esp_ble_mesh_lighting_server_cb_param_t *param); + +/** + * @brief Register BLE Mesh Lighting 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_lighting_server_callback(esp_ble_mesh_lighting_server_cb_t callback); + +#ifdef __cplusplus +} +#endif + +#endif /* _ESP_BLE_MESH_LIGHTING_MODEL_API_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_sensor_model_api.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_sensor_model_api.h new file mode 100644 index 00000000000..4f051a0b265 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_sensor_model_api.h @@ -0,0 +1,709 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** @file + * @brief Bluetooth Mesh Sensor Client Model APIs. + */ + +#ifndef _ESP_BLE_MESH_SENSOR_MODEL_API_H_ +#define _ESP_BLE_MESH_SENSOR_MODEL_API_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. + * + * @note This API needs to be called for each element on which + * the application needs to have a Sensor Client Model. + * + * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t. + * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t. + * + * @return New Sensor Client Model instance. + */ +#define ESP_BLE_MESH_MODEL_SENSOR_CLI(cli_pub, cli_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SENSOR_CLI, \ + NULL, cli_pub, cli_data) + +/** + * @brief Bluetooth Mesh Sensor Client Model Get and Set parameters structure. + */ + +/** Parameters of Sensor Descriptor Get */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t property_id; /*!< Property ID of a sensor (optional) */ +} esp_ble_mesh_sensor_descriptor_get_t; + +/** Parameter of Sensor Cadence Get */ +typedef struct { + uint16_t property_id; /*!< Property ID of a sensor */ +} esp_ble_mesh_sensor_cadence_get_t; + +/** Parameters of Sensor Cadence Set */ +typedef struct { + 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 */ + 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 { + uint16_t sensor_property_id; /*!< Property ID of a sensor */ +} esp_ble_mesh_sensor_settings_get_t; + +/** Parameters of Sensor Setting Get */ +typedef struct { + 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 { + 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 */ + uint16_t property_id; /*!< Property ID for the sensor (optional) */ +} esp_ble_mesh_sensor_get_t; + +/** Parameters of Sensor Column Get */ +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_sensor_column_get_t; + +/** Parameters of Sensor Series Get */ +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_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; + +/** + * @brief Sensor Client Model get message union + */ +typedef union { + esp_ble_mesh_sensor_descriptor_get_t descriptor_get; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_GET */ + esp_ble_mesh_sensor_cadence_get_t cadence_get; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_GET */ + esp_ble_mesh_sensor_settings_get_t settings_get; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_SETTINGS_GET */ + esp_ble_mesh_sensor_setting_get_t setting_get; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_GET */ + esp_ble_mesh_sensor_get_t sensor_get; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_GET */ + esp_ble_mesh_sensor_column_get_t column_get; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_COLUMN_GET */ + esp_ble_mesh_sensor_series_get_t series_get; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_SERIES_GET */ +} esp_ble_mesh_sensor_client_get_state_t; + +/** + * @brief Sensor Client Model set message union + */ +typedef union { + esp_ble_mesh_sensor_cadence_set_t cadence_set; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET & ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET_UNACK */ + esp_ble_mesh_sensor_setting_set_t setting_set; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET & ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET_UNACK */ +} esp_ble_mesh_sensor_client_set_state_t; + +/** + * @brief Bluetooth Mesh Sensor Client Model Get and Set callback parameters structure. + */ + +/** Parameter of Sensor Descriptor Status */ +typedef struct { + struct net_buf_simple *descriptor; /*!< Sequence of 8-octet sensor descriptors (optional) */ +} esp_ble_mesh_sensor_descriptor_status_cb_t; + +/** Parameters of Sensor Cadence Status */ +typedef struct { + 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 { + 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 */ + 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; + +/** Parameter of Sensor Status */ +typedef struct { + struct net_buf_simple *marshalled_sensor_data; /*!< Value of sensor data state (optional) */ +} esp_ble_mesh_sensor_status_cb_t; + +/** Parameters of Sensor Column Status */ +typedef struct { + 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 { + 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; + +/** + * @brief Sensor Client Model received message union + */ +typedef union { + esp_ble_mesh_sensor_descriptor_status_cb_t descriptor_status; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_STATUS */ + esp_ble_mesh_sensor_cadence_status_cb_t cadence_status; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_STATUS */ + esp_ble_mesh_sensor_settings_status_cb_t settings_status; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_SETTINGS_STATUS */ + esp_ble_mesh_sensor_setting_status_cb_t setting_status; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_STATUS */ + esp_ble_mesh_sensor_status_cb_t sensor_status; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_STATUS */ + esp_ble_mesh_sensor_column_status_cb_t column_status; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_COLUMN_STATUS */ + esp_ble_mesh_sensor_series_status_cb_t series_status; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_SERIES_STATUS */ +} esp_ble_mesh_sensor_client_status_cb_t; + +/** Sensor Client Model callback parameters */ +typedef struct { + int error_code; /*!< 0: success, + * otherwise failure. For the error code values please refer to errno.h file. + * A negative sign is added to the standard error codes in errno.h. */ + esp_ble_mesh_client_common_param_t *params; /*!< The client common parameters. */ + esp_ble_mesh_sensor_client_status_cb_t status_cb; /*!< The sensor status message callback values */ +} esp_ble_mesh_sensor_client_cb_param_t; + +/** This enum value is the event of Sensor Client Model */ +typedef enum { + ESP_BLE_MESH_SENSOR_CLIENT_GET_STATE_EVT, + ESP_BLE_MESH_SENSOR_CLIENT_SET_STATE_EVT, + ESP_BLE_MESH_SENSOR_CLIENT_PUBLISH_EVT, + ESP_BLE_MESH_SENSOR_CLIENT_TIMEOUT_EVT, + ESP_BLE_MESH_SENSOR_CLIENT_EVT_MAX, +} esp_ble_mesh_sensor_client_cb_event_t; + +/** + * @brief Bluetooth Mesh Sensor Client Model function. + */ + +/** + * @brief Sensor Client Model callback function type + * @param event: Event type + * @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); + +/** + * @brief Register BLE Mesh Sensor Client 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_client_callback(esp_ble_mesh_sensor_client_cb_t callback); + +/** + * @brief Get the value of Sensor Server Model states using the Sensor Client Model get messages. + * + * @note If you want to know the opcodes and corresponding meanings accepted by this API, + * please refer to esp_ble_mesh_sensor_message_opcode_t in esp_ble_mesh_defs.h + * + * @param[in] params: Pointer to BLE Mesh common client parameters. + * @param[in] get_state: Pointer to sensor get message value. + * Shall not be set to NULL. + * + * @return ESP_OK on success or error code otherwise. + * + */ +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); + +/** + * @brief Set the value of Sensor Server Model states using the Sensor Client Model set messages. + * + * @note If you want to know the opcodes and corresponding meanings accepted by this API, + * please refer to esp_ble_mesh_sensor_message_opcode_t in esp_ble_mesh_defs.h + * + * @param[in] params: Pointer to BLE Mesh common client parameters. + * @param[in] set_state: Pointer to sensor set message value. + * Shall not be set to NULL. + * + * @return ESP_OK on success or error code otherwise. + * + */ +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); + +/** + * @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 0x0–0x7F, + * representing range of 1–127). 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 0x0–0xF, + * representing range of 1–16). + * 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 0x0–0x7F, representing + * range of 1–127). 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 0x0–0xF, + * representing range of 1 – 16). + * Format B: The Length field is a 1-based uint7 value (valid range 0x0–0x7F, + * 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_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_time_scene_model_api.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_time_scene_model_api.h new file mode 100644 index 00000000000..07e5a5ba017 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_time_scene_model_api.h @@ -0,0 +1,911 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** @file + * @brief Bluetooth Mesh Time and Scene Client Model APIs. + */ + +#ifndef _ESP_BLE_MESH_TIME_SCENE_MODEL_API_H_ +#define _ESP_BLE_MESH_TIME_SCENE_MODEL_API_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. + * + * @note This API needs to be called for each element on which + * the application needs to have a Time Client Model. + * + * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t. + * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t. + * + * @return New Time Client Model instance. + */ +#define ESP_BLE_MESH_MODEL_TIME_CLI(cli_pub, cli_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_TIME_CLI, \ + NULL, cli_pub, cli_data) + +/** @def ESP_BLE_MESH_MODEL_SCENE_CLI + * + * @brief Define a new Scene Client Model. + * + * @note This API needs to be called for each element on which + * the application needs to have a Scene Client Model. + * + * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t. + * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t. + * + * @return New Scene Client Model instance. + */ +#define ESP_BLE_MESH_MODEL_SCENE_CLI(cli_pub, cli_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SCENE_CLI, \ + NULL, cli_pub, cli_data) + +/** @def ESP_BLE_MESH_MODEL_SCHEDULER_CLI + * + * @brief Define a new Scheduler Client Model. + * + * @note This API needs to be called for each element on which + * the application needs to have a Scheduler Client Model. + * + * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t. + * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t. + * + * @return New Scheduler Client Model instance. + */ +#define ESP_BLE_MESH_MODEL_SCHEDULER_CLI(cli_pub, cli_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SCHEDULER_CLI, \ + NULL, cli_pub, cli_data) + +/** + * @brief Bluetooth Mesh Time Scene Client Model Get and Set parameters structure. + */ + +/** Parameters of Time Set */ +typedef struct { + 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 { + 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 { + 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 { + uint8_t time_role; /*!< The Time Role for the element */ +} esp_ble_mesh_time_role_set_t; + +/** Parameter of Scene Store */ +typedef struct { + 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 */ + 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 { + uint16_t scene_number; /*!< The number of scenes to be deleted */ +} esp_ble_mesh_scene_delete_t; + +/** Parameter of Scheduler Action Get */ +typedef struct { + 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 { + 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; + +/** + * @brief Time Scene Client Model get message union + */ +typedef union { + esp_ble_mesh_scheduler_act_get_t scheduler_act_get; /*!< For ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_GET */ +} esp_ble_mesh_time_scene_client_get_state_t; + +/** + * @brief Time Scene Client Model set message union + */ +typedef union { + esp_ble_mesh_time_set_t time_set; /*!< For ESP_BLE_MESH_MODEL_OP_TIME_SET */ + esp_ble_mesh_time_zone_set_t time_zone_set; /*!< For ESP_BLE_MESH_MODEL_OP_TIME_ZONE_SET */ + esp_ble_mesh_tai_utc_delta_set_t tai_utc_delta_set; /*!< For ESP_BLE_MESH_MODEL_OP_TAI_UTC_DELTA_SET */ + esp_ble_mesh_time_role_set_t time_role_set; /*!< For ESP_BLE_MESH_MODEL_OP_TIME_ROLE_SET */ + esp_ble_mesh_scene_store_t scene_store; /*!< For ESP_BLE_MESH_MODEL_OP_SCENE_STORE & ESP_BLE_MESH_MODEL_OP_SCENE_STORE_UNACK */ + esp_ble_mesh_scene_recall_t scene_recall; /*!< For ESP_BLE_MESH_MODEL_OP_SCENE_RECALL & ESP_BLE_MESH_MODEL_OP_SCENE_RECALL_UNACK */ + esp_ble_mesh_scene_delete_t scene_delete; /*!< For ESP_BLE_MESH_MODEL_OP_SCENE_DELETE & ESP_BLE_MESH_MODEL_OP_SCENE_DELETE_UNACK */ + esp_ble_mesh_scheduler_act_set_t scheduler_act_set; /*!< For ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_SET & ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_SET_UNACK */ +} esp_ble_mesh_time_scene_client_set_state_t; + +/** + * @brief Bluetooth Mesh Time Scene Client Model Get and Set callback parameters structure. + */ + +/** Parameters of Time Status */ +typedef struct { + 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 { + 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 { + 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 { + 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 */ + 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 { + 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 { + 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 { + 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; + +/** + * @brief Time Scene Client Model received message union + */ +typedef union { + esp_ble_mesh_time_status_cb_t time_status; /*!< For ESP_BLE_MESH_MODEL_OP_TIME_STATUS */ + esp_ble_mesh_time_zone_status_cb_t time_zone_status; /*!< For ESP_BLE_MESH_MODEL_OP_TIME_ZONE_STATUS */ + esp_ble_mesh_tai_utc_delta_status_cb_t tai_utc_delta_status; /*!< For ESP_BLE_MESH_MODEL_OP_TAI_UTC_DELTA_STATUS */ + esp_ble_mesh_time_role_status_cb_t time_role_status; /*!< For ESP_BLE_MESH_MODEL_OP_TIME_ROLE_STATUS */ + esp_ble_mesh_scene_status_cb_t scene_status; /*!< For ESP_BLE_MESH_MODEL_OP_SCENE_STATUS */ + esp_ble_mesh_scene_register_status_cb_t scene_register_status; /*!< For ESP_BLE_MESH_MODEL_OP_SCENE_REGISTER_STATUS */ + esp_ble_mesh_scheduler_status_cb_t scheduler_status; /*!< For ESP_BLE_MESH_MODEL_OP_SCHEDULER_STATUS */ + esp_ble_mesh_scheduler_act_status_cb_t scheduler_act_status; /*!< For ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_STATUS */ +} esp_ble_mesh_time_scene_client_status_cb_t; + +/** Time Scene Client Model callback parameters */ +typedef struct { + int error_code; /*!< Appropriate error code */ + esp_ble_mesh_client_common_param_t *params; /*!< The client common parameters. */ + esp_ble_mesh_time_scene_client_status_cb_t status_cb; /*!< The scene status message callback values */ +} esp_ble_mesh_time_scene_client_cb_param_t; + +/** This enum value is the event of Time Scene Client Model */ +typedef enum { + ESP_BLE_MESH_TIME_SCENE_CLIENT_GET_STATE_EVT, + ESP_BLE_MESH_TIME_SCENE_CLIENT_SET_STATE_EVT, + ESP_BLE_MESH_TIME_SCENE_CLIENT_PUBLISH_EVT, + ESP_BLE_MESH_TIME_SCENE_CLIENT_TIMEOUT_EVT, + ESP_BLE_MESH_TIME_SCENE_CLIENT_EVT_MAX, +} esp_ble_mesh_time_scene_client_cb_event_t; + +/** + * @brief Bluetooth Mesh Time Scene Client Model function. + */ + +/** + * @brief Time Scene Client Model callback function type + * @param event: Event type + * @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); + +/** + * @brief Register BLE Mesh Time Scene Client 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_client_callback(esp_ble_mesh_time_scene_client_cb_t callback); + +/** + * @brief Get the value of Time Scene Server Model states using the Time Scene Client Model get messages. + * + * @note If you want to know the opcodes and corresponding meanings accepted by this API, + * please refer to esp_ble_mesh_time_scene_message_opcode_t in esp_ble_mesh_defs.h + * + * @param[in] params: Pointer to BLE Mesh common client parameters. + * @param[in] get_state: Pointer to time scene get message value. + * Shall not be set to NULL. + * + * @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); + +/** + * @brief Set the value of Time Scene Server Model states using the Time Scene Client Model set messages. + * + * @note If you want to know the opcodes and corresponding meanings accepted by this API, + * please refer to esp_ble_mesh_time_scene_message_opcode_t in esp_ble_mesh_defs.h + * + * @param[in] params: Pointer to BLE Mesh common client parameters. + * @param[in] set_state: Pointer to time scene set message value. + * Shall not be set to NULL. + * + * @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); + +/** + * @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_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_ble.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_ble.h new file mode 100644 index 00000000000..854ca96522d --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_ble.h @@ -0,0 +1,54 @@ +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _BTC_BLE_MESH_BLE_H_ +#define _BTC_BLE_MESH_BLE_H_ + +#include +#include "btc/btc_manage.h" +#include "mesh_bearer_adapt.h" +#include "esp_ble_mesh_ble_api.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef union { + struct { + esp_ble_mesh_ble_adv_param_t param; + esp_ble_mesh_ble_adv_data_t data; + } start_ble_adv; + struct { + uint8_t index; + } stop_ble_adv; + struct { + esp_ble_mesh_ble_scan_param_t param; + } start_ble_scan; + struct { + /* RFU */ + } stop_ble_scan; +} btc_ble_mesh_ble_args_t; + +typedef enum { + BTC_BLE_MESH_ACT_START_BLE_ADV, + BTC_BLE_MESH_ACT_STOP_BLE_ADV, + BTC_BLE_MESH_ACT_START_BLE_SCAN, + BTC_BLE_MESH_ACT_STOP_BLE_SCAN, +} btc_ble_mesh_ble_act_t; + +void bt_mesh_ble_scan_cb_evt_to_btc(const bt_mesh_addr_t *addr, + uint8_t adv_type, uint8_t data[], + uint16_t length, int8_t rssi); + +void btc_ble_mesh_ble_call_handler(btc_msg_t *msg); + +void btc_ble_mesh_ble_cb_handler(btc_msg_t *msg); + +#ifdef __cplusplus +} +#endif + +#endif /* _BTC_BLE_MESH_BLE_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_config_model.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_config_model.h new file mode 100644 index 00000000000..39ed1a5c1a4 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_config_model.h @@ -0,0 +1,72 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _BTC_BLE_MESH_CONFIG_MODEL_H_ +#define _BTC_BLE_MESH_CONFIG_MODEL_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_ACT_CONFIG_CLIENT_MAX, +} btc_ble_mesh_config_client_act_t; + +typedef union { + 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_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_config_client_args_t; + +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_ble_mesh_config_client_call_handler(btc_msg_t *msg); + +void btc_ble_mesh_config_client_cb_handler(btc_msg_t *msg); + +void btc_ble_mesh_config_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src); + +void btc_ble_mesh_config_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf); + +void bt_mesh_config_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type, + struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + const uint8_t *val, size_t len); + +void btc_ble_mesh_config_server_cb_handler(btc_msg_t *msg); + +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_config_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + const uint8_t *val, size_t len); + +#ifdef __cplusplus +} +#endif + +#endif /* _BTC_BLE_MESH_CONFIG_MODEL_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_generic_model.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_generic_model.h new file mode 100644 index 00000000000..a5b586d5ab7 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_generic_model.h @@ -0,0 +1,74 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _BTC_BLE_MESH_GENERIC_MODEL_H_ +#define _BTC_BLE_MESH_GENERIC_MODEL_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 { + struct ble_mesh_generic_client_get_state_reg_args { + esp_ble_mesh_client_common_param_t *params; + esp_ble_mesh_generic_client_get_state_t *get_state; + } generic_client_get_state; + struct ble_mesh_generic_client_set_state_reg_args { + esp_ble_mesh_client_common_param_t *params; + esp_ble_mesh_generic_client_set_state_t *set_state; + } generic_client_set_state; +} btc_ble_mesh_generic_client_args_t; + +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_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_ble_mesh_generic_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf); + +void bt_mesh_generic_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type, + struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + const uint8_t *val, size_t len); + +typedef enum { + BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, + BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_GET_MSG, + BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_SET_MSG, + BTC_BLE_MESH_EVT_GENERIC_SERVER_MAX, +} btc_ble_mesh_generic_server_evt_t; + +void bt_mesh_generic_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + const uint8_t *val, size_t len); + +void btc_ble_mesh_generic_server_cb_handler(btc_msg_t *msg); + +#ifdef __cplusplus +} +#endif + +#endif /* _BTC_BLE_MESH_GENERIC_MODEL_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_health_model.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_health_model.h new file mode 100644 index 00000000000..331f41c23d6 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_health_model.h @@ -0,0 +1,87 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _BTC_BLE_MESH_HEALTH_MODEL_H_ +#define _BTC_BLE_MESH_HEALTH_MODEL_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 union { + struct ble_mesh_health_client_get_state_reg_args { + esp_ble_mesh_client_common_param_t *params; + esp_ble_mesh_health_client_get_state_t *get_state; + } health_client_get_state; + struct ble_mesh_health_client_set_state_reg_args { + esp_ble_mesh_client_common_param_t *params; + esp_ble_mesh_health_client_set_state_t *set_state; + } health_client_set_state; +} btc_ble_mesh_health_client_args_t; + +typedef enum { + BTC_BLE_MESH_EVT_HEALTH_CLIENT_GET_STATE, + BTC_BLE_MESH_EVT_HEALTH_CLIENT_SET_STATE, + BTC_BLE_MESH_EVT_HEALTH_CLIENT_PUBLISH, + BTC_BLE_MESH_EVT_HEALTH_CLIENT_TIMEOUT, + BTC_BLE_MESH_EVT_HEALTH_CLIENT_MAX, +} btc_ble_mesh_health_client_evt_t; + +void btc_ble_mesh_health_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src); + +void btc_ble_mesh_health_client_call_handler(btc_msg_t *msg); + +void btc_ble_mesh_health_client_cb_handler(btc_msg_t *msg); + +void btc_ble_mesh_health_publish_callback(uint32_t opcode, struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf); + +void bt_mesh_health_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type, + struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + const uint8_t *val, uint16_t len); + +typedef enum { + BTC_BLE_MESH_ACT_HEALTH_SERVER_FAULT_UPDATE, + BTC_BLE_MESH_ACT_HEALTH_SERVER_MAX, +} btc_ble_mesh_health_server_act_t; + +typedef union { + struct ble_mesh_health_server_fault_update_args { + esp_ble_mesh_elem_t *element; + } health_fault_update; +} btc_ble_mesh_health_server_args_t; + +void btc_ble_mesh_health_server_call_handler(btc_msg_t *msg); + +void btc_ble_mesh_health_server_cb_handler(btc_msg_t *msg); + +void btc_ble_mesh_health_server_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src); + +void btc_ble_mesh_health_server_fault_clear(struct bt_mesh_model *model, uint16_t company_id); + +void btc_ble_mesh_health_server_fault_test(struct bt_mesh_model *model, + uint8_t test_id, uint16_t company_id); + +void btc_ble_mesh_health_server_attention_on(struct bt_mesh_model *model, uint8_t time); + +void btc_ble_mesh_health_server_attention_off(struct bt_mesh_model *model); + +#ifdef __cplusplus +} +#endif + +#endif /* _BTC_BLE_MESH_HEALTH_MODEL_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_lighting_model.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_lighting_model.h new file mode 100644 index 00000000000..854d6521612 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_lighting_model.h @@ -0,0 +1,75 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _BTC_BLE_MESH_LIGHTING_MODEL_H_ +#define _BTC_BLE_MESH_LIGHTING_MODEL_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_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 { + esp_ble_mesh_client_common_param_t *params; + esp_ble_mesh_light_client_get_state_t *get_state; + } light_client_get_state; + struct ble_mesh_light_client_set_state_reg_args { + 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_lighting_client_args_t; + +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_ble_mesh_lighting_client_call_handler(btc_msg_t *msg); + +void btc_ble_mesh_lighting_client_cb_handler(btc_msg_t *msg); + +void btc_ble_mesh_lighting_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src); + +void btc_ble_mesh_lighting_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf); + +void bt_mesh_lighting_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type, + struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + const uint8_t *val, size_t len); + +typedef enum { + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, + BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_GET_MSG, + BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG, + BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_STATUS_MSG, + BTC_BLE_MESH_EVT_LIGHTING_SERVER_MAX, +} btc_ble_mesh_lighting_server_evt_t; + +void bt_mesh_lighting_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + const uint8_t *val, size_t len); + +void btc_ble_mesh_lighting_server_cb_handler(btc_msg_t *msg); + +#ifdef __cplusplus +} +#endif + +#endif /* _BTC_BLE_MESH_LIGHTING_MODEL_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_prov.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_prov.h new file mode 100644 index 00000000000..ab54cc487b8 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_prov.h @@ -0,0 +1,392 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _BTC_BLE_MESH_PROV_H_ +#define _BTC_BLE_MESH_PROV_H_ + +#include "btc/btc_manage.h" +#include "mesh_byteorder.h" +#include "mesh_config.h" +#include "mesh_main.h" +#include "fast_prov.h" +#include "provisioner_prov.h" +#include "esp_ble_mesh_defs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + BTC_BLE_MESH_ACT_MESH_INIT = 0, + BTC_BLE_MESH_ACT_PROV_ENABLE, + BTC_BLE_MESH_ACT_PROV_DISABLE, + BTC_BLE_MESH_ACT_NODE_RESET, + BTC_BLE_MESH_ACT_SET_OOB_PUB_KEY, + BTC_BLE_MESH_ACT_INPUT_NUMBER, + BTC_BLE_MESH_ACT_INPUT_STRING, + BTC_BLE_MESH_ACT_SET_DEVICE_NAME, + BTC_BLE_MESH_ACT_PROXY_IDENTITY_ENABLE, + BTC_BLE_MESH_ACT_PROXY_GATT_ENABLE, + BTC_BLE_MESH_ACT_PROXY_GATT_DISABLE, + BTC_BLE_MESH_ACT_NODE_ADD_LOCAL_NET_KEY, + BTC_BLE_MESH_ACT_NODE_ADD_LOCAL_APP_KEY, + BTC_BLE_MESH_ACT_NODE_BIND_APP_KEY_TO_MODEL, + BTC_BLE_MESH_ACT_PROVISIONER_READ_OOB_PUB_KEY, + BTC_BLE_MESH_ACT_PROVISIONER_INPUT_STR, + BTC_BLE_MESH_ACT_PROVISIONER_INPUT_NUM, + BTC_BLE_MESH_ACT_PROVISIONER_ENABLE, + BTC_BLE_MESH_ACT_PROVISIONER_DISABLE, + BTC_BLE_MESH_ACT_PROVISIONER_DEV_ADD, + BTC_BLE_MESH_ACT_PROVISIONER_PROV_DEV_WITH_ADDR, + BTC_BLE_MESH_ACT_PROVISIONER_DEV_DEL, + BTC_BLE_MESH_ACT_PROVISIONER_SET_DEV_UUID_MATCH, + BTC_BLE_MESH_ACT_PROVISIONER_SET_PROV_DATA_INFO, + BTC_BLE_MESH_ACT_PROVISIONER_SET_STATIC_OOB_VAL, + BTC_BLE_MESH_ACT_PROVISIONER_SET_PRIMARY_ELEM_ADDR, + BTC_BLE_MESH_ACT_PROVISIONER_SET_NODE_NAME, + BTC_BLE_MESH_ACT_PROVISIONER_ADD_LOCAL_APP_KEY, + BTC_BLE_MESH_ACT_PROVISIONER_UPDATE_LOCAL_APP_KEY, + BTC_BLE_MESH_ACT_PROVISIONER_BIND_LOCAL_MOD_APP, + BTC_BLE_MESH_ACT_PROVISIONER_ADD_LOCAL_NET_KEY, + BTC_BLE_MESH_ACT_PROVISIONER_UPDATE_LOCAL_NET_KEY, + BTC_BLE_MESH_ACT_PROVISIONER_STORE_NODE_COMP_DATA, + BTC_BLE_MESH_ACT_PROVISIONER_DELETE_NODE_WITH_UUID, + BTC_BLE_MESH_ACT_PROVISIONER_DELETE_NODE_WITH_ADDR, + BTC_BLE_MESH_ACT_PROVISIONER_ENABLE_HEARTBEAT_RECV, + BTC_BLE_MESH_ACT_PROVISIONER_SET_HEARTBEAT_FILTER_TYPE, + BTC_BLE_MESH_ACT_PROVISIONER_SET_HEARTBEAT_FILTER_INFO, + BTC_BLE_MESH_ACT_PROVISIONER_DIRECT_ERASE_SETTINGS, + BTC_BLE_MESH_ACT_PROVISIONER_OPEN_SETTINGS_WITH_INDEX, + BTC_BLE_MESH_ACT_PROVISIONER_OPEN_SETTINGS_WITH_UID, + BTC_BLE_MESH_ACT_PROVISIONER_CLOSE_SETTINGS_WITH_INDEX, + BTC_BLE_MESH_ACT_PROVISIONER_CLOSE_SETTINGS_WITH_UID, + BTC_BLE_MESH_ACT_PROVISIONER_DELETE_SETTINGS_WITH_INDEX, + BTC_BLE_MESH_ACT_PROVISIONER_DELETE_SETTINGS_WITH_UID, + BTC_BLE_MESH_ACT_SET_FAST_PROV_INFO, + BTC_BLE_MESH_ACT_SET_FAST_PROV_ACTION, + BTC_BLE_MESH_ACT_LPN_ENABLE, + BTC_BLE_MESH_ACT_LPN_DISABLE, + BTC_BLE_MESH_ACT_LPN_POLL, + BTC_BLE_MESH_ACT_PROXY_CLIENT_CONNECT, + BTC_BLE_MESH_ACT_PROXY_CLIENT_DISCONNECT, + BTC_BLE_MESH_ACT_PROXY_CLIENT_SET_FILTER_TYPE, + BTC_BLE_MESH_ACT_PROXY_CLIENT_ADD_FILTER_ADDR, + BTC_BLE_MESH_ACT_PROXY_CLIENT_REMOVE_FILTER_ADDR, + BTC_BLE_MESH_ACT_MODEL_SUBSCRIBE_GROUP_ADDR, + BTC_BLE_MESH_ACT_MODEL_UNSUBSCRIBE_GROUP_ADDR, + BTC_BLE_MESH_ACT_DEINIT_MESH, +} btc_ble_mesh_prov_act_t; + +typedef enum { + BTC_BLE_MESH_ACT_MODEL_PUBLISH, + BTC_BLE_MESH_ACT_SERVER_MODEL_SEND, + BTC_BLE_MESH_ACT_CLIENT_MODEL_SEND, + BTC_BLE_MESH_ACT_SERVER_MODEL_UPDATE_STATE, +} btc_ble_mesh_model_act_t; + +typedef union { + struct ble_mesh_init_args { + esp_ble_mesh_prov_t *prov; + esp_ble_mesh_comp_t *comp; + SemaphoreHandle_t semaphore; + } mesh_init; + struct ble_mesh_node_prov_enable_args { + esp_ble_mesh_prov_bearer_t bearers; + } node_prov_enable; + struct ble_mesh_node_prov_disable_args { + esp_ble_mesh_prov_bearer_t bearers; + } node_prov_disable; + struct ble_mesh_set_oob_pub_key_args { + uint8_t pub_key_x[32]; + uint8_t pub_key_y[32]; + uint8_t private_key[32]; + } set_oob_pub_key; + struct ble_mesh_node_input_num_args { + uint32_t number; + } input_number; + struct ble_mesh_node_input_str_args { + char string[8]; + } input_string; + struct ble_mesh_set_device_name_args { + char name[ESP_BLE_MESH_DEVICE_NAME_MAX_LEN + 1]; + } set_device_name; + struct ble_mesh_node_add_local_net_key_args { + uint8_t net_key[16]; + uint16_t net_idx; + } node_add_local_net_key; + struct ble_mesh_node_add_local_app_key_args { + uint8_t app_key[16]; + uint16_t net_idx; + uint16_t app_idx; + } node_add_local_app_key; + struct ble_mesh_node_bind_local_mod_app_args { + uint16_t element_addr; + uint16_t company_id; + uint16_t model_id; + uint16_t app_idx; + } node_local_mod_app_bind; + struct ble_mesh_provisioner_read_oob_pub_key_args { + uint8_t link_idx; + uint8_t pub_key_x[32]; + uint8_t pub_key_y[32]; + } provisioner_read_oob_pub_key; + struct ble_mesh_provisioner_input_str_args { + char string[8]; + uint8_t link_idx; + } provisioner_input_str; + struct ble_mesh_provisioner_input_num_args { + uint32_t number; + uint8_t link_idx; + } provisioner_input_num; + struct ble_mesh_provisioner_enable_args { + esp_ble_mesh_prov_bearer_t bearers; + } provisioner_enable; + struct ble_mesh_provisioner_disable_args { + esp_ble_mesh_prov_bearer_t bearers; + } provisioner_disable; + struct ble_mesh_provisioner_dev_add_args { + 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; + struct ble_mesh_provisioner_set_dev_uuid_match_args { + uint8_t offset; + uint8_t match_len; + uint8_t match_val[16]; + bool prov_after_match; + } set_dev_uuid_match; + 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 { + 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; + uint16_t cid; + uint16_t app_idx; + } local_mod_app_bind; + struct ble_mesh_provisioner_add_local_net_key_args { + uint8_t net_key[16]; + uint16_t net_idx; + } add_local_net_key; + struct ble_mesh_provisioner_update_local_net_key_args { + uint8_t net_key[16]; + uint16_t net_idx; + } update_local_net_key; + struct ble_mesh_provisioner_store_node_comp_data_args { + uint16_t unicast_addr; + uint16_t length; + uint8_t *data; + } store_node_comp_data; + struct ble_mesh_provisioner_delete_node_with_uuid_args { + uint8_t uuid[16]; + } delete_node_with_uuid; + struct ble_mesh_provisioner_delete_node_with_addr_args { + uint16_t unicast_addr; + } delete_node_with_addr; + struct { + bool enable; + } enable_heartbeat_recv; + struct { + uint8_t type; + } set_heartbeat_filter_type; + struct { + uint8_t op; + uint16_t hb_src; + uint16_t hb_dst; + } set_heartbeat_filter_info; + struct { + uint8_t index; + } open_settings_with_index; + struct { + char uid[ESP_BLE_MESH_SETTINGS_UID_SIZE + 1]; + } open_settings_with_uid; + struct { + uint8_t index; + bool erase; + } close_settings_with_index; + struct { + char uid[ESP_BLE_MESH_SETTINGS_UID_SIZE + 1]; + bool erase; + } close_settings_with_uid; + struct { + uint8_t index; + } delete_settings_with_index; + struct { + char uid[ESP_BLE_MESH_SETTINGS_UID_SIZE + 1]; + } delete_settings_with_uid; + struct ble_mesh_set_fast_prov_info_args { + uint16_t unicast_min; + uint16_t unicast_max; + uint16_t net_idx; + uint8_t flags; + uint32_t iv_index; + uint8_t offset; + uint8_t match_len; + uint8_t match_val[16]; + } set_fast_prov_info; + struct ble_mesh_set_fast_prov_action_args { + uint8_t action; + } set_fast_prov_action; + struct ble_mesh_lpn_enable_args { + /* RFU */ + } lpn_enable; + struct ble_mesh_lpn_disable_args { + bool force; + } lpn_disable; + struct ble_mesh_lpn_poll_args { + /* RFU */ + } lpn_poll; + struct ble_mesh_proxy_client_connect_args { + uint8_t addr[6]; + uint8_t addr_type; + uint16_t net_idx; + } proxy_client_connect; + struct ble_mesh_proxy_client_disconnect_args { + uint8_t conn_handle; + } proxy_client_disconnect; + struct ble_mesh_proxy_client_set_filter_type_args { + uint8_t conn_handle; + uint16_t net_idx; + uint8_t filter_type; + } proxy_client_set_filter_type; + struct ble_mesh_proxy_client_add_filter_addr_args { + uint8_t conn_handle; + uint16_t net_idx; + uint16_t addr_num; + uint16_t *addr; + } proxy_client_add_filter_addr; + struct ble_mesh_proxy_client_remove_filter_addr_args { + uint8_t conn_handle; + uint16_t net_idx; + uint16_t addr_num; + uint16_t *addr; + } proxy_client_remove_filter_addr; + struct ble_mesh_model_sub_group_addr_args { + uint16_t element_addr; + uint16_t company_id; + uint16_t model_id; + uint16_t group_addr; + } model_sub_group_addr; + struct ble_mesh_model_unsub_group_addr_args { + uint16_t element_addr; + uint16_t company_id; + uint16_t model_id; + uint16_t group_addr; + } model_unsub_group_addr; + struct ble_mesh_deinit_args { + esp_ble_mesh_deinit_param_t param; + } mesh_deinit; +} btc_ble_mesh_prov_args_t; + +typedef union { + struct ble_mesh_model_publish_args { + esp_ble_mesh_model_t *model; + uint8_t device_role; + } model_publish; + struct ble_mesh_model_send_args { + esp_ble_mesh_model_t *model; + esp_ble_mesh_msg_ctx_t *ctx; + uint32_t opcode; + bool need_rsp; + uint16_t length; + uint8_t *data; + 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_copy(btc_msg_t *msg, void *p_dest, void *p_src); + +void btc_ble_mesh_model_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src); + +const uint8_t *btc_ble_mesh_node_get_local_net_key(uint16_t net_idx); + +const uint8_t *btc_ble_mesh_node_get_local_app_key(uint16_t app_idx); + +esp_ble_mesh_node_t *btc_ble_mesh_provisioner_get_node_with_uuid(const uint8_t uuid[16]); + +esp_ble_mesh_node_t *btc_ble_mesh_provisioner_get_node_with_addr(uint16_t unicast_addr); + +esp_ble_mesh_node_t *btc_ble_mesh_provisioner_get_node_with_name(const char *name); + +uint16_t btc_ble_mesh_provisioner_get_prov_node_count(void); + +const esp_ble_mesh_node_t **btc_ble_mesh_provisioner_get_node_table_entry(void); + +int btc_ble_mesh_client_model_init(esp_ble_mesh_model_t *model); + +int btc_ble_mesh_client_model_deinit(esp_ble_mesh_model_t *model); + +int32_t btc_ble_mesh_model_pub_period_get(esp_ble_mesh_model_t *mod); + +uint16_t btc_ble_mesh_get_primary_addr(void); + +uint16_t *btc_ble_mesh_model_find_group(esp_ble_mesh_model_t *mod, uint16_t addr); + +esp_ble_mesh_elem_t *btc_ble_mesh_elem_find(uint16_t addr); + +uint8_t btc_ble_mesh_elem_count(void); + +esp_ble_mesh_model_t *btc_ble_mesh_model_find_vnd(const esp_ble_mesh_elem_t *elem, + uint16_t company, uint16_t id); + +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); + +const char *btc_ble_mesh_provisioner_get_settings_uid(uint8_t index); + +uint8_t btc_ble_mesh_provisioner_get_settings_index(const char *uid); + +uint8_t btc_ble_mesh_provisioner_get_free_settings_count(void); + +void btc_ble_mesh_model_call_handler(btc_msg_t *msg); +void btc_ble_mesh_model_cb_handler(btc_msg_t *msg); + +void btc_ble_mesh_prov_call_handler(btc_msg_t *msg); +void btc_ble_mesh_prov_cb_handler(btc_msg_t *msg); + +#ifdef __cplusplus +} +#endif + +#endif /* _BTC_BLE_MESH_PROV_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_sensor_model.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_sensor_model.h new file mode 100644 index 00000000000..a0dc29f3784 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_sensor_model.h @@ -0,0 +1,74 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _BTC_BLE_MESH_SENSOR_MODEL_H_ +#define _BTC_BLE_MESH_SENSOR_MODEL_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 { + struct ble_mesh_sensor_client_get_state_reg_args { + esp_ble_mesh_client_common_param_t *params; + esp_ble_mesh_sensor_client_get_state_t *get_state; + } sensor_client_get_state; + struct ble_mesh_sensor_client_set_state_reg_args { + esp_ble_mesh_client_common_param_t *params; + esp_ble_mesh_sensor_client_set_state_t *set_state; + } sensor_client_set_state; +} btc_ble_mesh_sensor_client_args_t; + +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_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_ble_mesh_sensor_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf); + +void bt_mesh_sensor_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type, + struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + const uint8_t *val, size_t len); + +typedef enum { + BTC_BLE_MESH_EVT_SENSOR_SERVER_STATE_CHANGE, + BTC_BLE_MESH_EVT_SENSOR_SERVER_RECV_GET_MSG, + BTC_BLE_MESH_EVT_SENSOR_SERVER_RECV_SET_MSG, + BTC_BLE_MESH_EVT_SENSOR_SERVER_MAX, +} btc_ble_mesh_sensor_server_evt_t; + +void bt_mesh_sensor_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + const uint8_t *val, size_t len); + +void btc_ble_mesh_sensor_server_cb_handler(btc_msg_t *msg); + +#ifdef __cplusplus +} +#endif + +#endif /* _BTC_BLE_MESH_SENSOR_MODEL_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_time_scene_model.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_time_scene_model.h new file mode 100644 index 00000000000..6c878dc7769 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_time_scene_model.h @@ -0,0 +1,75 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _BTC_BLE_MESH_TIME_SCENE_MODEL_H_ +#define _BTC_BLE_MESH_TIME_SCENE_MODEL_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 { + struct ble_mesh_time_scene_client_get_state_reg_args { + esp_ble_mesh_client_common_param_t *params; + esp_ble_mesh_time_scene_client_get_state_t *get_state; + } time_scene_client_get_state; + struct ble_mesh_time_scene_client_set_state_reg_args { + esp_ble_mesh_client_common_param_t *params; + esp_ble_mesh_time_scene_client_set_state_t *set_state; + } time_scene_client_set_state; +} btc_ble_mesh_time_scene_client_args_t; + +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_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_ble_mesh_time_scene_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf); + +void bt_mesh_time_scene_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type, + struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + const uint8_t *val, size_t len); + +typedef enum { + BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_STATE_CHANGE, + BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_GET_MSG, + BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_SET_MSG, + BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_STATUS_MSG, + BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_MAX, +} btc_ble_mesh_time_scene_server_evt_t; + +void bt_mesh_time_scene_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + const uint8_t *val, size_t len); + +void btc_ble_mesh_time_scene_server_cb_handler(btc_msg_t *msg); + +#ifdef __cplusplus +} +#endif + +#endif /* _BTC_BLE_MESH_TIME_SCENE_MODEL_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_atomic.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_atomic.h new file mode 100644 index 00000000000..6d62840e46e --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_atomic.h @@ -0,0 +1,305 @@ +/* atomic operations */ + +/* + * SPDX-FileCopyrightText: 1997-2015 Wind River Systems, Inc. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _BLE_MESH_ATOMIC_H_ +#define _BLE_MESH_ATOMIC_H_ + +#include "mesh_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef bt_mesh_atomic_t bt_mesh_atomic_val_t; + +/** + * @defgroup atomic_apis Atomic Services APIs + * @ingroup kernel_apis + * @{ + */ + +/** + * + * @brief Atomic increment. + * + * This routine performs an atomic increment by 1 on @a target. + * + * @param target Address of atomic variable. + * + * @return Previous value of @a target. + */ +#ifdef CONFIG_ATOMIC_OPERATIONS_BUILTIN +static inline bt_mesh_atomic_val_t bt_mesh_atomic_inc(bt_mesh_atomic_t *target) +{ + return bt_mesh_atomic_add(target, 1); +} +#else +extern bt_mesh_atomic_val_t bt_mesh_atomic_inc(bt_mesh_atomic_t *target); +#endif + +/** + * + * @brief Atomic decrement. + * + * This routine performs an atomic decrement by 1 on @a target. + * + * @param target Address of atomic variable. + * + * @return Previous value of @a target. + */ +#ifdef CONFIG_ATOMIC_OPERATIONS_BUILTIN +static inline bt_mesh_atomic_val_t bt_mesh_atomic_dec(bt_mesh_atomic_t *target) +{ + return bt_mesh_atomic_sub(target, 1); +} +#else +extern bt_mesh_atomic_val_t bt_mesh_atomic_dec(bt_mesh_atomic_t *target); +#endif + +/** + * + * @brief Atomic get. + * + * This routine performs an atomic read on @a target. + * + * @param target Address of atomic variable. + * + * @return Value of @a target. + */ +#ifdef CONFIG_ATOMIC_OPERATIONS_BUILTIN +static inline bt_mesh_atomic_val_t bt_mesh_atomic_get(const bt_mesh_atomic_t *target) +{ + return __atomic_load_n(target, __ATOMIC_SEQ_CST); +} +#else +extern bt_mesh_atomic_val_t bt_mesh_atomic_get(const bt_mesh_atomic_t *target); +#endif + +/** + * + * @brief Atomic get-and-set. + * + * This routine atomically sets @a target to @a value and returns + * the previous value of @a target. + * + * @param target Address of atomic variable. + * @param value Value to write to @a target. + * + * @return Previous value of @a target. + */ +#ifdef CONFIG_ATOMIC_OPERATIONS_BUILTIN +static inline bt_mesh_atomic_val_t bt_mesh_atomic_set(bt_mesh_atomic_t *target, bt_mesh_atomic_val_t value) +{ + /* This builtin, as described by Intel, is not a traditional + * test-and-set operation, but rather an atomic exchange operation. It + * writes value into *ptr, and returns the previous contents of *ptr. + */ + return __atomic_exchange_n(target, value, __ATOMIC_SEQ_CST); +} +#else +extern bt_mesh_atomic_val_t bt_mesh_atomic_set(bt_mesh_atomic_t *target, bt_mesh_atomic_val_t value); +#endif + +/** + * + * @brief Atomic bitwise inclusive OR. + * + * This routine atomically sets @a target to the bitwise inclusive OR of + * @a target and @a value. + * + * @param target Address of atomic variable. + * @param value Value to OR. + * + * @return Previous value of @a target. + */ +#ifdef CONFIG_ATOMIC_OPERATIONS_BUILTIN +static inline bt_mesh_atomic_val_t bt_mesh_atomic_or(bt_mesh_atomic_t *target, bt_mesh_atomic_val_t value) +{ + return __atomic_fetch_or(target, value, __ATOMIC_SEQ_CST); +} +#else +extern bt_mesh_atomic_val_t bt_mesh_atomic_or(bt_mesh_atomic_t *target, bt_mesh_atomic_val_t value); +#endif + +/** + * + * @brief Atomic bitwise AND. + * + * This routine atomically sets @a target to the bitwise AND of @a target + * and @a value. + * + * @param target Address of atomic variable. + * @param value Value to AND. + * + * @return Previous value of @a target. + */ +#ifdef CONFIG_ATOMIC_OPERATIONS_BUILTIN +static inline bt_mesh_atomic_val_t bt_mesh_atomic_and(bt_mesh_atomic_t *target, bt_mesh_atomic_val_t value) +{ + return __atomic_fetch_and(target, value, __ATOMIC_SEQ_CST); +} +#else +extern bt_mesh_atomic_val_t bt_mesh_atomic_and(bt_mesh_atomic_t *target, bt_mesh_atomic_val_t value); +#endif + +/** + * @cond INTERNAL_HIDDEN + */ + +#define BLE_MESH_ATOMIC_BITS (sizeof(bt_mesh_atomic_val_t) * 8) +#define BLE_MESH_ATOMIC_MASK(bit) (1 << ((bit) & (BLE_MESH_ATOMIC_BITS - 1))) +#define BLE_MESH_ATOMIC_ELEM(addr, bit) ((addr) + ((bit) / BLE_MESH_ATOMIC_BITS)) + +/** + * INTERNAL_HIDDEN @endcond + */ + +/** + * @brief Define an array of atomic variables. + * + * This macro defines an array of atomic variables containing at least + * @a num_bits bits. + * + * @note + * If used from file scope, the bits of the array are initialized to zero; + * if used from within a function, the bits are left uninitialized. + * + * @param name Name of array of atomic variables. + * @param num_bits Number of bits needed. + */ +#define BLE_MESH_ATOMIC_DEFINE(name, num_bits) \ + bt_mesh_atomic_t name[1 + ((num_bits) - 1) / BLE_MESH_ATOMIC_BITS] + +/** + * @brief Atomically test a bit. + * + * This routine tests whether bit number @a bit of @a target is set or not. + * The target may be a single atomic variable or an array of them. + * + * @param target Address of atomic variable or array. + * @param bit Bit number (starting from 0). + * + * @return 1 if the bit was set, 0 if it wasn't. + */ +static inline int bt_mesh_atomic_test_bit(const bt_mesh_atomic_t *target, int bit) +{ + bt_mesh_atomic_val_t val = bt_mesh_atomic_get(BLE_MESH_ATOMIC_ELEM(target, bit)); + + return (1 & (val >> (bit & (BLE_MESH_ATOMIC_BITS - 1)))); +} + +/** + * @brief Atomically test and clear a bit. + * + * Atomically clear bit number @a bit of @a target and return its old value. + * The target may be a single atomic variable or an array of them. + * + * @param target Address of atomic variable or array. + * @param bit Bit number (starting from 0). + * + * @return 1 if the bit was set, 0 if it wasn't. + */ +static inline int bt_mesh_atomic_test_and_clear_bit(bt_mesh_atomic_t *target, int bit) +{ + bt_mesh_atomic_val_t mask = BLE_MESH_ATOMIC_MASK(bit); + bt_mesh_atomic_val_t old; + + old = bt_mesh_atomic_and(BLE_MESH_ATOMIC_ELEM(target, bit), ~mask); + + return (old & mask) != 0; +} + +/** + * @brief Atomically set a bit. + * + * Atomically set bit number @a bit of @a target and return its old value. + * The target may be a single atomic variable or an array of them. + * + * @param target Address of atomic variable or array. + * @param bit Bit number (starting from 0). + * + * @return 1 if the bit was set, 0 if it wasn't. + */ +static inline int bt_mesh_atomic_test_and_set_bit(bt_mesh_atomic_t *target, int bit) +{ + bt_mesh_atomic_val_t mask = BLE_MESH_ATOMIC_MASK(bit); + bt_mesh_atomic_val_t old; + + old = bt_mesh_atomic_or(BLE_MESH_ATOMIC_ELEM(target, bit), mask); + + return (old & mask) != 0; +} + +/** + * @brief Atomically clear a bit. + * + * Atomically clear bit number @a bit of @a target. + * The target may be a single atomic variable or an array of them. + * + * @param target Address of atomic variable or array. + * @param bit Bit number (starting from 0). + * + * @return N/A + */ +static inline void bt_mesh_atomic_clear_bit(bt_mesh_atomic_t *target, int bit) +{ + bt_mesh_atomic_val_t mask = BLE_MESH_ATOMIC_MASK(bit); + + (void)bt_mesh_atomic_and(BLE_MESH_ATOMIC_ELEM(target, bit), ~mask); +} + +/** + * @brief Atomically set a bit. + * + * Atomically set bit number @a bit of @a target. + * The target may be a single atomic variable or an array of them. + * + * @param target Address of atomic variable or array. + * @param bit Bit number (starting from 0). + * + * @return N/A + */ +static inline void bt_mesh_atomic_set_bit(bt_mesh_atomic_t *target, int bit) +{ + bt_mesh_atomic_val_t mask = BLE_MESH_ATOMIC_MASK(bit); + + (void)bt_mesh_atomic_or(BLE_MESH_ATOMIC_ELEM(target, bit), mask); +} + +/** + * @brief Atomically set a bit to a given value. + * + * Atomically set bit number @a bit of @a target to value @a val. + * The target may be a single atomic variable or an array of them. + * + * @param target Address of atomic variable or array. + * @param bit Bit number (starting from 0). + * @param val true for 1, false for 0. + * + * @return N/A + */ +static inline void bt_mesh_atomic_set_bit_to(bt_mesh_atomic_t *target, int bit, bool val) +{ + bt_mesh_atomic_val_t mask = BLE_MESH_ATOMIC_MASK(bit); + + if (val) { + (void)bt_mesh_atomic_or(BLE_MESH_ATOMIC_ELEM(target, bit), mask); + } else { + (void)bt_mesh_atomic_and(BLE_MESH_ATOMIC_ELEM(target, bit), ~mask); + } +} + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* _BLE_MESH_ATOMIC_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_buf.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_buf.h new file mode 100644 index 00000000000..33baa8cc81d --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_buf.h @@ -0,0 +1,1758 @@ +/** @file + * @brief Buffer management. + */ + +/* + * SPDX-FileCopyrightText: 2015 Intel Corporation + * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#ifndef _BLE_MESH_BUF_H_ +#define _BLE_MESH_BUF_H_ + +#include "mesh_config.h" +#include "mesh_types.h" +#include "mesh_slist.h" +#include "mesh_compiler.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Unaligned access */ +#define UNALIGNED_GET(p) \ +__extension__ ({ \ + struct __attribute__((__packed__)) { \ + __typeof__(*(p)) __v; \ + } *__p = (__typeof__(__p)) (p); \ + __p->__v; \ +}) + +#define BLE_MESH_NET_BUF_USER_DATA_SIZE 4 + +/** + * @brief Network buffer library + * @defgroup net_buf Network Buffer Library + * @ingroup networking + * @{ + */ + +/* Alignment needed for various parts of the buffer definition */ +#define __net_buf_align __aligned(sizeof(int)) + +/** + * @def NET_BUF_SIMPLE_DEFINE + * @brief Define a net_buf_simple stack variable. + * + * This is a helper macro which is used to define a net_buf_simple object + * on the stack. + * + * @param _name Name of the net_buf_simple object. + * @param _size Maximum data storage for the buffer. + */ +#define NET_BUF_SIMPLE_DEFINE(_name, _size) \ + uint8_t net_buf_data_##_name[_size]; \ + struct net_buf_simple _name = { \ + .data = net_buf_data_##_name, \ + .len = 0, \ + .size = _size, \ + .__buf = net_buf_data_##_name, \ + } + +/** + * @def NET_BUF_SIMPLE_DEFINE_STATIC + * @brief Define a static net_buf_simple variable. + * + * This is a helper macro which is used to define a static net_buf_simple + * object. + * + * @param _name Name of the net_buf_simple object. + * @param _size Maximum data storage for the buffer. + */ +#define NET_BUF_SIMPLE_DEFINE_STATIC(_name, _size) \ + static uint8_t net_buf_data_##_name[_size]; \ + static struct net_buf_simple _name = { \ + .data = net_buf_data_##_name, \ + .len = 0, \ + .size = _size, \ + .__buf = net_buf_data_##_name, \ + } + +/** + * @brief Simple network buffer representation. + * + * This is a simpler variant of the net_buf object (in fact net_buf uses + * net_buf_simple internally). It doesn't provide any kind of reference + * counting, user data, dynamic allocation, or in general the ability to + * pass through kernel objects such as FIFOs. + * + * The main use of this is for scenarios where the meta-data of the normal + * net_buf isn't needed and causes too much overhead. This could be e.g. + * when the buffer only needs to be allocated on the stack or when the + * access to and lifetime of the buffer is well controlled and constrained. + */ +struct net_buf_simple { + /** Pointer to the start of data in the buffer. */ + uint8_t *data; + + /** Length of the data behind the data pointer. */ + uint16_t len; + + /** Amount of data that this buffer can store. */ + uint16_t size; + + /** Start of the data storage. Not to be accessed directly + * (the data pointer should be used instead). + */ + uint8_t *__buf; +}; + +/** + * @def NET_BUF_SIMPLE + * @brief Define a net_buf_simple stack variable and get a pointer to it. + * + * This is a helper macro which is used to define a net_buf_simple object on + * the stack and the get a pointer to it as follows: + * + * struct net_buf_simple *my_buf = NET_BUF_SIMPLE(10); + * + * After creating the object it needs to be initialized by calling + * net_buf_simple_init(). + * + * @param _size Maximum data storage for the buffer. + * + * @return Pointer to stack-allocated net_buf_simple object. + */ +#define NET_BUF_SIMPLE(_size) \ + ((struct net_buf_simple *)(&(struct { \ + struct net_buf_simple buf; \ + uint8_t data[_size] __net_buf_align; \ + }) { \ + .buf.size = _size, \ + .buf.__buf = NULL, \ + })) + +/** + * @brief Initialize a net_buf_simple object. + * + * This needs to be called after creating a net_buf_simple object using + * the NET_BUF_SIMPLE macro. + * + * @param buf Buffer to initialize. + * @param reserve_head Headroom to reserve. + */ +static inline void net_buf_simple_init(struct net_buf_simple *buf, + size_t reserve_head) +{ + if (!buf->__buf) { + buf->__buf = (uint8_t *)buf + sizeof(*buf); + } + + buf->data = buf->__buf + reserve_head; + buf->len = 0; +} + +/** + * @brief Initialize a net_buf_simple object with data. + * + * Initialized buffer object with external data. + * + * @param buf Buffer to initialize. + * @param data External data pointer + * @param size Amount of data the pointed data buffer if able to fit. + */ +void net_buf_simple_init_with_data(struct net_buf_simple *buf, + void *data, size_t size); + +/** + * @brief Reset buffer + * + * Reset buffer data so it can be reused for other purposes. + * + * @param buf Buffer to reset. + */ +static inline void net_buf_simple_reset(struct net_buf_simple *buf) +{ + buf->len = 0; + 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 + * + * Increments the data length of a buffer to account for more data + * at the end. + * + * @param buf Buffer to update. + * @param len Number of bytes to increment the length with. + * + * @return The original tail of the buffer. + */ +void *net_buf_simple_add(struct net_buf_simple *buf, size_t len); + +/** + * @brief Copy given number of bytes from memory to the end of the buffer + * + * Increments the data length of the buffer to account for more data at the + * end. + * + * @param buf Buffer to update. + * @param mem Location of data to be added. + * @param len Length of data to be added + * + * @return The original tail of the buffer. + */ +void *net_buf_simple_add_mem(struct net_buf_simple *buf, const void *mem, + size_t len); + +/** + * @brief Add (8-bit) byte at the end of the buffer + * + * Increments the data length of the buffer to account for more data at the + * end. + * + * @param buf Buffer to update. + * @param val byte value to be added. + * + * @return Pointer to the value added + */ +uint8_t *net_buf_simple_add_u8(struct net_buf_simple *buf, uint8_t val); + +/** + * @brief Add 16-bit value at the end of the buffer + * + * Adds 16-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 16-bit value to be added. + */ +void net_buf_simple_add_le16(struct net_buf_simple *buf, uint16_t val); + +/** + * @brief Add 16-bit value at the end of the buffer + * + * Adds 16-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 16-bit value to be added. + */ +void net_buf_simple_add_be16(struct net_buf_simple *buf, uint16_t val); + +/** + * @brief Add 24-bit value at the end of the buffer + * + * 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, uint32_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, uint32_t val); + +/** + * @brief Add 32-bit value at the end of the buffer + * + * Adds 32-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 32-bit value to be added. + */ +void net_buf_simple_add_le32(struct net_buf_simple *buf, uint32_t val); + +/** + * @brief Add 32-bit value at the end of the buffer + * + * Adds 32-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 32-bit value to be added. + */ +void net_buf_simple_add_be32(struct net_buf_simple *buf, uint32_t val); + +/** + * @brief Add 48-bit value at the end of the buffer + * + * 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, uint64_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, uint64_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, uint64_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, uint64_t val); + +/** + * @brief Push data to the beginning of the buffer. + * + * Modifies the data pointer and buffer length to account for more data + * in the beginning of the buffer. + * + * @param buf Buffer to update. + * @param len Number of bytes to add to the beginning. + * + * @return The new beginning of the buffer data. + */ +void *net_buf_simple_push(struct net_buf_simple *buf, size_t len); + +/** + * @brief Push 16-bit value to the beginning of the buffer + * + * Adds 16-bit value in little endian format to the beginning of the + * buffer. + * + * @param buf Buffer to update. + * @param val 16-bit value to be pushed to the buffer. + */ +void net_buf_simple_push_le16(struct net_buf_simple *buf, uint16_t val); + +/** + * @brief Push 16-bit value to the beginning of the buffer + * + * Adds 16-bit value in big endian format to the beginning of the + * buffer. + * + * @param buf Buffer to update. + * @param val 16-bit value to be pushed to the buffer. + */ +void net_buf_simple_push_be16(struct net_buf_simple *buf, uint16_t val); + +/** + * @brief Push 8-bit value to the beginning of the buffer + * + * Adds 8-bit value the beginning of the buffer. + * + * @param buf Buffer to update. + * @param val 8-bit value to be pushed to the buffer. + */ +void net_buf_simple_push_u8(struct net_buf_simple *buf, uint8_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, uint32_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, uint32_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, uint32_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, uint32_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, uint64_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, uint64_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, uint64_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, uint64_t val); + +/** + * @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 New beginning of the buffer data. + */ +void *net_buf_simple_pull(struct net_buf_simple *buf, size_t len); + +/** + * @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 location of the buffer data. + */ +void *net_buf_simple_pull_mem(struct net_buf_simple *buf, size_t len); + +/** + * @brief Remove a 8-bit value from the beginning of the buffer + * + * Same idea as with net_buf_simple_pull(), but a helper for operating + * on 8-bit values. + * + * @param buf A valid pointer on a buffer. + * + * @return The 8-bit removed value + */ +uint8_t net_buf_simple_pull_u8(struct net_buf_simple *buf); + +/** + * @brief Remove and convert 16 bits from the beginning of the buffer. + * + * Same idea as with net_buf_simple_pull(), but a helper for operating + * on 16-bit little endian data. + * + * @param buf A valid pointer on a buffer. + * + * @return 16-bit value converted from little endian to host endian. + */ +uint16_t net_buf_simple_pull_le16(struct net_buf_simple *buf); + +/** + * @brief Remove and convert 16 bits from the beginning of the buffer. + * + * Same idea as with net_buf_simple_pull(), but a helper for operating + * on 16-bit big endian data. + * + * @param buf A valid pointer on a buffer. + * + * @return 16-bit value converted from big endian to host endian. + */ +uint16_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. + */ +uint32_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. + */ +uint32_t net_buf_simple_pull_be24(struct net_buf_simple *buf); + +/** + * @brief Remove and convert 32 bits from the beginning of the buffer. + * + * Same idea as with net_buf_simple_pull(), but a helper for operating + * on 32-bit little endian data. + * + * @param buf A valid pointer on a buffer. + * + * @return 32-bit value converted from little endian to host endian. + */ +uint32_t net_buf_simple_pull_le32(struct net_buf_simple *buf); + +/** + * @brief Remove and convert 32 bits from the beginning of the buffer. + * + * Same idea as with net_buf_simple_pull(), but a helper for operating + * on 32-bit big endian data. + * + * @param buf A valid pointer on a buffer. + * + * @return 32-bit value converted from big endian to host endian. + */ +uint32_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. + */ +uint64_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. + */ +uint64_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. + */ +uint64_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. + */ +uint64_t net_buf_simple_pull_be64(struct net_buf_simple *buf); + +/** + * @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. + */ +static inline uint8_t *net_buf_simple_tail(struct net_buf_simple *buf) +{ + return buf->data + buf->len; +} + +/** + * @brief Check buffer headroom. + * + * Check how much free space there is in the beginning of the buffer. + * + * buf A valid pointer on a buffer + * + * @return Number of bytes available in the beginning of the buffer. + */ +size_t net_buf_simple_headroom(struct net_buf_simple *buf); + +/** + * @brief Check buffer tailroom. + * + * Check how much free space there is at the end of the buffer. + * + * @param buf A valid pointer on a buffer + * + * @return Number of bytes available at the end of the buffer. + */ +size_t net_buf_simple_tailroom(struct net_buf_simple *buf); + +/** + * @brief Parsing state of a buffer. + * + * This is used for temporarily storing the parsing state of a buffer + * while giving control of the parsing to a routine which we don't + * control. + */ +struct net_buf_simple_state { + /** Offset of the data pointer from the beginning of the storage */ + uint16_t offset; + /** Length of data */ + uint16_t len; +}; + +/** + * @brief Save the parsing state of a buffer. + * + * Saves the parsing state of a buffer so it can be restored later. + * + * @param buf Buffer from which the state should be saved. + * @param state Storage for the state. + */ +static inline void net_buf_simple_save(struct net_buf_simple *buf, + struct net_buf_simple_state *state) +{ + state->offset = net_buf_simple_headroom(buf); + state->len = buf->len; +} + +/** + * @brief Restore the parsing state of a buffer. + * + * Restores the parsing state of a buffer from a state previously stored + * by net_buf_simple_save(). + * + * @param buf Buffer to which the state should be restored. + * @param state Stored state. + */ +static inline void net_buf_simple_restore(struct net_buf_simple *buf, + struct net_buf_simple_state *state) +{ + buf->data = buf->__buf + state->offset; + buf->len = state->len; +} + +/** + * @brief Initialize buffer with the given headroom. + * + * The buffer is not expected to contain any data when this API is called. + * + * @param buf Buffer to initialize. + * @param reserve How much headroom to reserve. + */ +void net_buf_simple_reserve(struct net_buf_simple *buf, size_t reserve); + +/** + * Flag indicating that the buffer has associated fragments. Only used + * internally by the buffer handling code while the buffer is inside a + * FIFO, meaning this never needs to be explicitly set or unset by the + * net_buf API user. As long as the buffer is outside of a FIFO, i.e. + * in practice always for the user for this API, the buf->frags pointer + * should be used instead. + */ +#define NET_BUF_FRAGS BIT(0) + +/** + * @brief Network buffer representation. + * + * This struct is used to represent network buffers. Such buffers are + * normally defined through the NET_BUF_POOL_*_DEFINE() APIs and allocated + * using the net_buf_alloc() API. + */ +struct net_buf { + union { + /** Allow placing the buffer into sys_slist_t */ + sys_snode_t node; + + /** Fragments associated with this buffer. */ + struct net_buf *frags; + }; + + /** Reference count. */ + uint8_t ref; + + /** Bit-field of buffer flags. */ + uint8_t flags; + + /** Where the buffer should go when freed up. */ + struct net_buf_pool *pool; + + /* Union for convenience access to the net_buf_simple members, also + * preserving the old API. + */ + union { + /* The ABI of this struct must match net_buf_simple */ + struct { + /** Pointer to the start of data in the buffer. */ + uint8_t *data; + + /** Length of the data behind the data pointer. */ + uint16_t len; + + /** Amount of data that this buffer can store. */ + uint16_t size; + + /** Start of the data storage. Not to be accessed + * directly (the data pointer should be used + * instead). + */ + uint8_t *__buf; + }; + + struct net_buf_simple b; + }; + + /** System metadata for this buffer. */ + uint8_t user_data[BLE_MESH_NET_BUF_USER_DATA_SIZE] __net_buf_align; +}; + +struct net_buf_data_cb { + uint8_t *(*alloc)(struct net_buf *buf, size_t *size, int32_t timeout); + uint8_t *(*ref)(struct net_buf *buf, uint8_t *data); + void (*unref)(struct net_buf *buf, uint8_t *data); +}; + +struct net_buf_data_alloc { + const struct net_buf_data_cb *cb; + void *alloc_data; +}; + +struct net_buf_pool { + /** Number of buffers in pool */ + const uint16_t buf_count; + + /** Number of uninitialized buffers */ + uint16_t uninit_count; + +#if defined(CONFIG_BLE_MESH_NET_BUF_POOL_USAGE) + /** Amount of available buffers in the pool. */ + int16_t avail_count; + + /** Total size of the pool. */ + const uint16_t pool_size; + + /** Name of the pool. Used when printing pool information. */ + const char *name; +#endif /* CONFIG_BLE_MESH_NET_BUF_POOL_USAGE */ + + /** Optional destroy callback when buffer is freed. */ + void (*const destroy)(struct net_buf *buf); + + /** Data allocation handlers. */ + const struct net_buf_data_alloc *alloc; + + /** Helper to access the start of storage (for net_buf_pool_init) */ + struct net_buf *const __bufs; +}; + +#if defined(CONFIG_BLE_MESH_NET_BUF_POOL_USAGE) +#define NET_BUF_POOL_INITIALIZER(_pool, _alloc, _bufs, _count, _destroy) \ + { \ + .alloc = _alloc, \ + .__bufs = (struct net_buf *)_bufs, \ + .buf_count = _count, \ + .uninit_count = _count, \ + .avail_count = _count, \ + .destroy = _destroy, \ + .name = STRINGIFY(_pool), \ + } +#else +#define NET_BUF_POOL_INITIALIZER(_pool, _alloc, _bufs, _count, _destroy) \ + { \ + .alloc = _alloc, \ + .__bufs = (struct net_buf *)_bufs, \ + .buf_count = _count, \ + .uninit_count = _count, \ + .destroy = _destroy, \ + } +#endif /* CONFIG_BLE_MESH_NET_BUF_POOL_USAGE */ + +struct net_buf_pool_fixed { + size_t data_size; + uint8_t *data_pool; +}; + +/** @cond INTERNAL_HIDDEN */ +extern const struct net_buf_data_cb net_buf_fixed_cb; + +/** + * @def NET_BUF_POOL_FIXED_DEFINE + * @brief Define a new pool for buffers based on fixed-size data + * + * Defines a net_buf_pool struct and the necessary memory storage (array of + * structs) for the needed amount of buffers. After this, the buffers can be + * accessed from the pool through net_buf_alloc. The pool is defined as a + * static variable, so if it needs to be exported outside the current module + * this needs to happen with the help of a separate pointer rather than an + * extern declaration. + * + * The data payload of the buffers will be allocated from a byte array + * of fixed sized chunks. This kind of pool does not support blocking on + * the data allocation, so the timeout passed to net_buf_alloc will be + * always treated as K_NO_WAIT when trying to allocate the data. This means + * that allocation failures, i.e. NULL returns, must always be handled + * cleanly. + * + * If provided with a custom destroy callback, this callback is + * responsible for eventually calling net_buf_destroy() to complete the + * process of returning the buffer to the pool. + * + * @param _name Name of the pool variable. + * @param _count Number of buffers in the pool. + * @param _data_size Maximum data payload per buffer. + * @param _destroy Optional destroy callback when buffer is freed. + */ +#define NET_BUF_POOL_FIXED_DEFINE(_name, _count, _data_size, _destroy) \ + static struct net_buf net_buf_##_name[_count]; \ + static uint8_t net_buf_data_##_name[_count][_data_size]; \ + static const struct net_buf_pool_fixed net_buf_fixed_##_name = { \ + .data_size = _data_size, \ + .data_pool = (uint8_t *)net_buf_data_##_name, \ + }; \ + static const struct net_buf_data_alloc net_buf_fixed_alloc_##_name = { \ + .cb = &net_buf_fixed_cb, \ + .alloc_data = (void *)&net_buf_fixed_##_name, \ + }; \ + struct net_buf_pool _name __net_buf_align \ + __in_section(_net_buf_pool, static, _name) = \ + NET_BUF_POOL_INITIALIZER(_name, &net_buf_fixed_alloc_##_name, \ + net_buf_##_name, _count, _destroy) + +/** + * @def NET_BUF_POOL_DEFINE + * @brief Define a new pool for buffers + * + * Defines a net_buf_pool struct and the necessary memory storage (array of + * structs) for the needed amount of buffers. After this,the buffers can be + * accessed from the pool through net_buf_alloc. The pool is defined as a + * static variable, so if it needs to be exported outside the current module + * this needs to happen with the help of a separate pointer rather than an + * extern declaration. + * + * If provided with a custom destroy callback this callback is + * responsible for eventually calling net_buf_destroy() to complete the + * process of returning the buffer to the pool. + * + * @param _name Name of the pool variable. + * @param _count Number of buffers in the pool. + * @param _size Maximum data size for each buffer. + * @param _ud_size Amount of user data space to reserve. + * @param _destroy Optional destroy callback when buffer is freed. + */ +#define NET_BUF_POOL_DEFINE(_name, _count, _size, _ud_size, _destroy) \ + NET_BUF_POOL_FIXED_DEFINE(_name, _count, _size, _destroy) + +/** + * @brief Get a zero-based index for a buffer. + * + * This function will translate a buffer into a zero-based index, + * based on its placement in its buffer pool. This can be useful if you + * want to associate an external array of meta-data contexts with the + * buffers of a pool. + * + * @param buf Network buffer. + * + * @return Zero-based index for the buffer. + */ +int net_buf_id(struct net_buf *buf); + +/** + * @brief Allocate a new fixed buffer from a pool. + * + * @param pool Which pool to allocate the buffer from. + * @param timeout Affects the action taken should the 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. Note that some types + * of data allocators do not support blocking (such as the HEAP + * type). In this case it's still possible for net_buf_alloc() to + * fail (return NULL) even if it was given K_FOREVER. + * + * @return New buffer or NULL if out of buffers. + */ +#if defined(CONFIG_BLE_MESH_NET_BUF_LOG) +struct net_buf *net_buf_alloc_fixed_debug(struct net_buf_pool *pool, int32_t timeout, + const char *func, int line); +#define net_buf_alloc_fixed(_pool, _timeout) \ + net_buf_alloc_fixed_debug(_pool, _timeout, __func__, __LINE__) +#else +struct net_buf *net_buf_alloc_fixed(struct net_buf_pool *pool, int32_t timeout); +#endif + +/** + * @def net_buf_alloc + * + * @copydetails net_buf_alloc_fixed + */ +#define net_buf_alloc(pool, timeout) net_buf_alloc_fixed(pool, timeout) + +/** + * @brief Reset buffer + * + * Reset buffer data and flags so it can be reused for other purposes. + * + * @param buf Buffer to reset. + */ +void net_buf_reset(struct net_buf *buf); + +/** + * @def net_buf_reserve + * @brief Initialize buffer with the given headroom. + * + * The buffer is not expected to contain any data when this API is called. + * + * @param buf Buffer to initialize. + * @param reserve How much headroom to reserve. + */ +#define net_buf_reserve(buf, reserve) net_buf_simple_reserve(&(buf)->b, reserve) + +/** + * @brief Put a buffer into a list + * + * Put a buffer to the end of a list. If the buffer contains follow-up + * fragments this function will take care of inserting them as well + * into the list. + * + * @param list Which list to append the buffer to. + * @param buf Buffer. + */ +void net_buf_slist_put(sys_slist_t *list, struct net_buf *buf); + +/** + * @brief Get a buffer from a list. + * + * Get buffer from a list. If the buffer had any fragments, these will + * automatically be recovered from the list as well and be placed to + * the buffer's fragment list. + * + * @param list Which list to take the buffer from. + * + * @return New buffer or NULL if the FIFO is empty. + */ +struct net_buf *net_buf_slist_get(sys_slist_t *list); + +/** + * @brief Decrements the reference count of a buffer. + * + * Decrements the reference count of a buffer and puts it back into the + * pool if the count reaches zero. + * + * @param buf A valid pointer on a buffer + */ +#if defined(CONFIG_BLE_MESH_NET_BUF_LOG) +void net_buf_unref_debug(struct net_buf *buf, const char *func, int line); +#define net_buf_unref(_buf) \ + net_buf_unref_debug(_buf, __func__, __LINE__) +#else +void net_buf_unref(struct net_buf *buf); +#endif + +/** + * @brief Increment the reference count of a buffer. + * + * @param buf A valid pointer on a buffer + * + * @return the buffer newly referenced + */ +struct net_buf *net_buf_ref(struct net_buf *buf); + +/** + * @brief Get a pointer to the user data of a buffer. + * + * @param buf A valid pointer on a buffer + * + * @return Pointer to the user data of the buffer. + */ +static inline void *net_buf_user_data(struct net_buf *buf) +{ + return (void *)buf->user_data; +} + +/** + * @def net_buf_add + * @brief Prepare data to be added at the end of the buffer + * + * Increments the data length of a buffer to account for more data + * at the end. + * + * @param buf Buffer to update. + * @param len Number of bytes to increment the length with. + * + * @return The original tail of the buffer. + */ +#define net_buf_add(buf, len) net_buf_simple_add(&(buf)->b, len) + +/** + * @def net_buf_add_mem + * @brief Copy bytes from memory to the end of the buffer + * + * Copies the given number of bytes to the end of the buffer. Increments the + * data length of the buffer to account for more data at the end. + * + * @param buf Buffer to update. + * @param mem Location of data to be added. + * @param len Length of data to be added + * + * @return The original tail of the buffer. + */ +#define net_buf_add_mem(buf, mem, len) net_buf_simple_add_mem(&(buf)->b, mem, len) + +/** + * @def net_buf_add_u8 + * @brief Add (8-bit) byte at the end of the buffer + * + * Adds a byte at the end of the buffer. Increments the data length of + * the buffer to account for more data at the end. + * + * @param buf Buffer to update. + * @param val byte value to be added. + * + * @return Pointer to the value added + */ +#define net_buf_add_u8(buf, val) net_buf_simple_add_u8(&(buf)->b, val) + +/** + * @def net_buf_add_le16 + * @brief Add 16-bit value at the end of the buffer + * + * Adds 16-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 16-bit value to be added. + */ +#define net_buf_add_le16(buf, val) net_buf_simple_add_le16(&(buf)->b, val) + +/** + * @def net_buf_add_be16 + * @brief Add 16-bit value at the end of the buffer + * + * Adds 16-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 16-bit value to be added. + */ +#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 + * + * Adds 32-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 32-bit value to be added. + */ +#define net_buf_add_le32(buf, val) net_buf_simple_add_le32(&(buf)->b, val) + +/** + * @def net_buf_add_be32 + * @brief Add 32-bit value at the end of the buffer + * + * Adds 32-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 32-bit value to be added. + */ +#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. + * + * Modifies the data pointer and buffer length to account for more data + * in the beginning of the buffer. + * + * @param buf Buffer to update. + * @param len Number of bytes to add to the beginning. + * + * @return The new beginning of the buffer data. + */ +#define net_buf_push(buf, len) net_buf_simple_push(&(buf)->b, len) + +/** + * @def net_buf_push_le16 + * @brief Push 16-bit value to the beginning of the buffer + * + * Adds 16-bit value in little endian format to the beginning of the + * buffer. + * + * @param buf Buffer to update. + * @param val 16-bit value to be pushed to the buffer. + */ +#define net_buf_push_le16(buf, val) net_buf_simple_push_le16(&(buf)->b, val) + +/** + * @def net_buf_push_be16 + * @brief Push 16-bit value to the beginning of the buffer + * + * Adds 16-bit value in little endian format to the beginning of the + * buffer. + * + * @param buf Buffer to update. + * @param val 16-bit value to be pushed to the buffer. + */ +#define net_buf_push_be16(buf, val) net_buf_simple_push_be16(&(buf)->b, val) + +/** + * @def net_buf_push_u8 + * @brief Push 8-bit value to the beginning of the buffer + * + * Adds 8-bit value the beginning of the buffer. + * + * @param buf Buffer to update. + * @param val 8-bit value to be pushed to the buffer. + */ +#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. + * + * 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 New beginning of the buffer data. + */ +#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 + * + * Same idea as with net_buf_pull(), but a helper for operating on + * 8-bit values. + * + * @param buf A valid pointer on a buffer. + * + * @return The 8-bit removed value + */ +#define net_buf_pull_u8(buf) net_buf_simple_pull_u8(&(buf)->b) + +/** + * @def net_buf_pull_le16 + * @brief Remove and convert 16 bits from the beginning of the buffer. + * + * Same idea as with net_buf_pull(), but a helper for operating on + * 16-bit little endian data. + * + * @param buf A valid pointer on a buffer. + * + * @return 16-bit value converted from little endian to host endian. + */ +#define net_buf_pull_le16(buf) net_buf_simple_pull_le16(&(buf)->b) + +/** + * @def net_buf_pull_be16 + * @brief Remove and convert 16 bits from the beginning of the buffer. + * + * Same idea as with net_buf_pull(), but a helper for operating on + * 16-bit big endian data. + * + * @param buf A valid pointer on a buffer. + * + * @return 16-bit value converted from big endian to host endian. + */ +#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. + * + * Same idea as with net_buf_pull(), but a helper for operating on + * 32-bit little endian data. + * + * @param buf A valid pointer on a buffer. + * + * @return 32-bit value converted from little endian to host endian. + */ +#define net_buf_pull_le32(buf) net_buf_simple_pull_le32(&(buf)->b) + +/** + * @def net_buf_pull_be32 + * @brief Remove and convert 32 bits from the beginning of the buffer. + * + * Same idea as with net_buf_pull(), but a helper for operating on + * 32-bit big endian data. + * + * @param buf A valid pointer on a buffer + * + * @return 32-bit value converted from big endian to host endian. + */ +#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. + * + * Check how much free space there is at the end of the buffer. + * + * @param buf A valid pointer on a buffer + * + * @return Number of bytes available at the end of the buffer. + */ +#define net_buf_tailroom(buf) net_buf_simple_tailroom(&(buf)->b) + +/** + * @def net_buf_headroom + * @brief Check buffer headroom. + * + * Check how much free space there is in the beginning of the buffer. + * + * buf A valid pointer on a buffer + * + * @return Number of bytes available in the beginning of the buffer. + */ +#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)(int32_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, int32_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; +} + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* _BLE_MESH_BUF_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_byteorder.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_byteorder.h new file mode 100644 index 00000000000..0ccf2b5b9ea --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_byteorder.h @@ -0,0 +1,599 @@ +/* + * SPDX-FileCopyrightText: 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) ((uint16_t) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))) +#endif + +#ifndef __bswap_24 +#define __bswap_24(x) ((uint32_t) ((((x) >> 16) & 0xff) | \ + (((x)) & 0xff00) | \ + (((x) & 0xff) << 16))) +#endif + +#ifndef __bswap_32 +#define __bswap_32(x) ((uint32_t) ((((x) >> 24) & 0xff) | \ + (((x) >> 8) & 0xff00) | \ + (((x) & 0xff00) << 8) | \ + (((x) & 0xff) << 24))) +#endif + +#ifndef __bswap_48 +#define __bswap_48(x) ((uint64_t) ((((x) >> 40) & 0xff) | \ + (((x) >> 24) & 0xff00) | \ + (((x) >> 8) & 0xff0000) | \ + (((x) & 0xff0000) << 8) | \ + (((x) & 0xff00) << 24) | \ + (((x) & 0xff) << 40))) +#endif + +#ifndef __bswap_64 +#define __bswap_64(x) ((uint64_t) ((((x) >> 56) & 0xff) | \ + (((x) >> 40) & 0xff00) | \ + (((x) >> 24) & 0xff0000) | \ + (((x) >> 8) & 0xff000000) | \ + (((x) & 0xff000000) << 8) | \ + (((x) & 0xff0000) << 24) | \ + (((x) & 0xff00) << 40) | \ + (((x) & 0xff) << 56))) +#endif + +/** @def sys_le16_to_cpu + * @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(uint16_t val, uint8_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(uint32_t val, uint8_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(uint32_t val, uint8_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(uint64_t val, uint8_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(uint64_t val, uint8_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(uint16_t val, uint8_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(uint32_t val, uint8_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(uint32_t val, uint8_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(uint64_t val, uint8_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(uint64_t val, uint8_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 uint16_t sys_get_be16(const uint8_t src[2]) +{ + return ((uint16_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 uint32_t sys_get_be24(const uint8_t src[3]) +{ + return ((uint32_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 uint32_t sys_get_be32(const uint8_t src[4]) +{ + return ((uint32_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 uint64_t sys_get_be48(const uint8_t src[6]) +{ + return ((uint64_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 uint64_t sys_get_be64(const uint8_t src[8]) +{ + return ((uint64_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 uint16_t sys_get_le16(const uint8_t src[2]) +{ + return ((uint16_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 uint32_t sys_get_le24(const uint8_t src[3]) +{ + return ((uint32_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 uint32_t sys_get_le32(const uint8_t src[4]) +{ + return ((uint32_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 uint64_t sys_get_le48(const uint8_t src[6]) +{ + return ((uint64_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 uint64_t sys_get_le64(const uint8_t src[8]) +{ + return ((uint64_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) +{ + uint8_t *pdst = (uint8_t *)dst; + const uint8_t *psrc = (const uint8_t *)src; + + __ASSERT(((psrc < pdst && (psrc + length) <= pdst) || + (psrc > pdst && (pdst + length) <= psrc)), + "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++) { + uint8_t tmp = ((uint8_t *)buf)[i]; + + ((uint8_t *)buf)[i] = ((uint8_t *)buf)[length - 1 - i]; + ((uint8_t *)buf)[length - 1 - i] = tmp; + } +} + +#ifdef __cplusplus +} +#endif + +#endif /* _BLE_MESH_BYTEORDER_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_common.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_common.h new file mode 100644 index 00000000000..42e28be696e --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_common.h @@ -0,0 +1,74 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** @file + * @brief Bluetooth Mesh Model Common APIs. + */ + +#ifndef _BLE_MESH_COMMON_H_ +#define _BLE_MESH_COMMON_H_ + +#include +#include + +#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. + * + * @param[in] size: Length of memory allocated to store message value + * + * @return NULL-fail, pointer of a net_buf_simple structure-success + */ +struct net_buf_simple *bt_mesh_alloc_buf(uint16_t size); + +/** + * @brief This function releases the memory allocated for the outgoing message. + * + * @param[in] buf: Pointer to the net_buf_simple structure to be freed + * + * @return none + */ +void bt_mesh_free_buf(struct net_buf_simple *buf); + +/** + * @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 + */ +uint8_t bt_mesh_get_device_role(struct bt_mesh_model *model, bool srv_send); + +int bt_mesh_rand(void *buf, size_t len); + +#ifdef __cplusplus +} +#endif + +#endif /* _BLE_MESH_COMMON_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_compiler.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_compiler.h new file mode 100644 index 00000000000..c73e8dfbc06 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_compiler.h @@ -0,0 +1,80 @@ +/* + * SPDX-FileCopyrightText: 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_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_config.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_config.h new file mode 100644 index 00000000000..d75a4588c31 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_config.h @@ -0,0 +1,47 @@ +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _BLE_MESH_CONFIG_H_ +#define _BLE_MESH_CONFIG_H_ + +#include "sdkconfig.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define CONFIG_BLE_MESH_GENERIC_CLIENT (CONFIG_BLE_MESH_GENERIC_ONOFF_CLI || \ + CONFIG_BLE_MESH_GENERIC_LEVEL_CLI || \ + CONFIG_BLE_MESH_GENERIC_DEF_TRANS_TIME_CLI || \ + CONFIG_BLE_MESH_GENERIC_POWER_ONOFF_CLI || \ + CONFIG_BLE_MESH_GENERIC_POWER_LEVEL_CLI || \ + CONFIG_BLE_MESH_GENERIC_BATTERY_CLI || \ + CONFIG_BLE_MESH_GENERIC_LOCATION_CLI || \ + CONFIG_BLE_MESH_GENERIC_PROPERTY_CLI) + +#define CONFIG_BLE_MESH_TIME_SCENE_CLIENT (CONFIG_BLE_MESH_TIME_CLI || \ + CONFIG_BLE_MESH_SCENE_CLI || \ + CONFIG_BLE_MESH_SCHEDULER_CLI) + +#define CONFIG_BLE_MESH_LIGHTING_CLIENT (CONFIG_BLE_MESH_LIGHT_LIGHTNESS_CLI || \ + CONFIG_BLE_MESH_LIGHT_CTL_CLI || \ + CONFIG_BLE_MESH_LIGHT_HSL_CLI || \ + CONFIG_BLE_MESH_LIGHT_XYL_CLI || \ + CONFIG_BLE_MESH_LIGHT_LC_CLI) + +#define CONFIG_BLE_MESH_SERVER_MODEL (CONFIG_BLE_MESH_GENERIC_SERVER || \ + CONFIG_BLE_MESH_SENSOR_SERVER || \ + CONFIG_BLE_MESH_TIME_SCENE_SERVER || \ + CONFIG_BLE_MESH_LIGHTING_SERVER) + +#define CONFIG_BLE_MESH_BLE_COEX_SUPPORT (CONFIG_BLE_MESH_SUPPORT_BLE_ADV || \ + CONFIG_BLE_MESH_SUPPORT_BLE_SCAN) + +#ifdef __cplusplus +} +#endif + +#endif /* _BLE_MESH_CONFIG_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_dlist.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_dlist.h new file mode 100644 index 00000000000..e21d08b761d --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_dlist.h @@ -0,0 +1,498 @@ +/* + * SPDX-FileCopyrightText: 2013-2015 Wind River Systems, Inc. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** + * @file + * @brief Doubly-linked list implementation + * + * Doubly-linked list implementation using inline macros/functions. + * This API is not thread safe, and thus if a list is used across threads, + * calls to functions must be protected with synchronization primitives. + * + * The lists are expected to be initialized such that both the head and tail + * pointers point to the list itself. Initializing the lists in such a fashion + * simplifies the adding and removing of nodes to/from the list. + */ + +#ifndef _BLE_MESH_DLIST_H_ +#define _BLE_MESH_DLIST_H_ + +#include +#include "mesh_util.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +struct _dnode { + union { + struct _dnode *head; /* ptr to head of list (sys_dlist_t) */ + struct _dnode *next; /* ptr to next node (sys_dnode_t) */ + }; + union { + struct _dnode *tail; /* ptr to tail of list (sys_dlist_t) */ + struct _dnode *prev; /* ptr to previous node (sys_dnode_t) */ + }; +}; + +typedef struct _dnode sys_dlist_t; +typedef struct _dnode sys_dnode_t; + +/** + * @brief Provide the primitive to iterate on a list + * Note: the loop is unsafe and thus __dn should not be removed + * + * User _MUST_ add the loop statement curly braces enclosing its own code: + * + * SYS_DLIST_FOR_EACH_NODE(l, n) { + * + * } + * + * This and other SYS_DLIST_*() macros are not thread safe. + * + * @param __dl A pointer on a sys_dlist_t to iterate on + * @param __dn A sys_dnode_t pointer to peek each node of the list + */ +#define SYS_DLIST_FOR_EACH_NODE(__dl, __dn) \ + for (__dn = sys_dlist_peek_head(__dl); __dn; \ + __dn = sys_dlist_peek_next(__dl, __dn)) + +/** + * @brief Provide the primitive to iterate on a list, from a node in the list + * Note: the loop is unsafe and thus __dn should not be removed + * + * User _MUST_ add the loop statement curly braces enclosing its own code: + * + * SYS_DLIST_ITERATE_FROM_NODE(l, n) { + * + * } + * + * Like SYS_DLIST_FOR_EACH_NODE(), but __dn already contains a node in the list + * where to start searching for the next entry from. If NULL, it starts from + * the head. + * + * This and other SYS_DLIST_*() macros are not thread safe. + * + * @param __dl A pointer on a sys_dlist_t to iterate on + * @param __dn A sys_dnode_t pointer to peek each node of the list; + * it contains the starting node, or NULL to start from the head + */ +#define SYS_DLIST_ITERATE_FROM_NODE(__dl, __dn) \ + for (__dn = __dn ? sys_dlist_peek_next_no_check(__dl, __dn) \ + : sys_dlist_peek_head(__dl); \ + __dn; \ + __dn = sys_dlist_peek_next(__dl, __dn)) + +/** + * @brief Provide the primitive to safely iterate on a list + * Note: __dn can be removed, it will not break the loop. + * + * User _MUST_ add the loop statement curly braces enclosing its own code: + * + * SYS_DLIST_FOR_EACH_NODE_SAFE(l, n, s) { + * + * } + * + * This and other SYS_DLIST_*() macros are not thread safe. + * + * @param __dl A pointer on a sys_dlist_t to iterate on + * @param __dn A sys_dnode_t pointer to peek each node of the list + * @param __dns A sys_dnode_t pointer for the loop to run safely + */ +#define SYS_DLIST_FOR_EACH_NODE_SAFE(__dl, __dn, __dns) \ + for (__dn = sys_dlist_peek_head(__dl), \ + __dns = sys_dlist_peek_next(__dl, __dn); \ + __dn; __dn = __dns, \ + __dns = sys_dlist_peek_next(__dl, __dn)) + +/* + * @brief Provide the primitive to resolve the container of a list node + * Note: it is safe to use with NULL pointer nodes + * + * @param __dn A pointer on a sys_dnode_t to get its container + * @param __cn Container struct type pointer + * @param __n The field name of sys_dnode_t within the container struct + */ +#define SYS_DLIST_CONTAINER(__dn, __cn, __n) \ + (__dn ? CONTAINER_OF(__dn, __typeof__(*__cn), __n) : NULL) +/* + * @brief Provide the primitive to peek container of the list head + * + * @param __dl A pointer on a sys_dlist_t to peek + * @param __cn Container struct type pointer + * @param __n The field name of sys_dnode_t within the container struct + */ +#define SYS_DLIST_PEEK_HEAD_CONTAINER(__dl, __cn, __n) \ + SYS_DLIST_CONTAINER(sys_dlist_peek_head(__dl), __cn, __n) + +/* + * @brief Provide the primitive to peek the next container + * + * @param __dl A pointer on a sys_dlist_t to peek + * @param __cn Container struct type pointer + * @param __n The field name of sys_dnode_t within the container struct + */ +#define SYS_DLIST_PEEK_NEXT_CONTAINER(__dl, __cn, __n) \ + ((__cn) ? SYS_DLIST_CONTAINER(sys_dlist_peek_next(__dl, &(__cn->__n)), \ + __cn, __n) : NULL) + +/** + * @brief Provide the primitive to iterate on a list under a container + * Note: the loop is unsafe and thus __cn should not be detached + * + * User _MUST_ add the loop statement curly braces enclosing its own code: + * + * SYS_DLIST_FOR_EACH_CONTAINER(l, c, n) { + * + * } + * + * @param __dl A pointer on a sys_dlist_t to iterate on + * @param __cn A pointer to peek each entry of the list + * @param __n The field name of sys_dnode_t within the container struct + */ +#define SYS_DLIST_FOR_EACH_CONTAINER(__dl, __cn, __n) \ + for (__cn = SYS_DLIST_PEEK_HEAD_CONTAINER(__dl, __cn, __n); __cn; \ + __cn = SYS_DLIST_PEEK_NEXT_CONTAINER(__dl, __cn, __n)) + +/** + * @brief Provide the primitive to safely iterate on a list under a container + * Note: __cn can be detached, it will not break the loop. + * + * User _MUST_ add the loop statement curly braces enclosing its own code: + * + * SYS_DLIST_FOR_EACH_CONTAINER_SAFE(l, c, cn, n) { + * + * } + * + * @param __dl A pointer on a sys_dlist_t to iterate on + * @param __cn A pointer to peek each entry of the list + * @param __cns A pointer for the loop to run safely + * @param __n The field name of sys_dnode_t within the container struct + */ +#define SYS_DLIST_FOR_EACH_CONTAINER_SAFE(__dl, __cn, __cns, __n) \ + for (__cn = SYS_DLIST_PEEK_HEAD_CONTAINER(__dl, __cn, __n), \ + __cns = SYS_DLIST_PEEK_NEXT_CONTAINER(__dl, __cn, __n); __cn; \ + __cn = __cns, \ + __cns = SYS_DLIST_PEEK_NEXT_CONTAINER(__dl, __cn, __n)) + +/** + * @brief initialize list + * + * @param list the doubly-linked list + * + * @return N/A + */ + +static inline void sys_dlist_init(sys_dlist_t *list) +{ + list->head = (sys_dnode_t *)list; + list->tail = (sys_dnode_t *)list; +} + +#define SYS_DLIST_STATIC_INIT(ptr_to_list) {{(ptr_to_list)}, {(ptr_to_list)}} + +/** + * @brief check if a node is the list's head + * + * @param list the doubly-linked list to operate on + * @param node the node to check + * + * @return 1 if node is the head, 0 otherwise + */ + +static inline int sys_dlist_is_head(sys_dlist_t *list, sys_dnode_t *node) +{ + return list->head == node; +} + +/** + * @brief check if a node is the list's tail + * + * @param list the doubly-linked list to operate on + * @param node the node to check + * + * @return 1 if node is the tail, 0 otherwise + */ + +static inline int sys_dlist_is_tail(sys_dlist_t *list, sys_dnode_t *node) +{ + return list->tail == node; +} + +/** + * @brief check if the list is empty + * + * @param list the doubly-linked list to operate on + * + * @return 1 if empty, 0 otherwise + */ + +static inline int sys_dlist_is_empty(sys_dlist_t *list) +{ + return list->head == list; +} + +/** + * @brief check if more than one node present + * + * This and other sys_dlist_*() functions are not thread safe. + * + * @param list the doubly-linked list to operate on + * + * @return 1 if multiple nodes, 0 otherwise + */ + +static inline int sys_dlist_has_multiple_nodes(sys_dlist_t *list) +{ + return list->head != list->tail; +} + +/** + * @brief get a reference to the head item in the list + * + * @param list the doubly-linked list to operate on + * + * @return a pointer to the head element, NULL if list is empty + */ + +static inline sys_dnode_t *sys_dlist_peek_head(sys_dlist_t *list) +{ + return sys_dlist_is_empty(list) ? NULL : list->head; +} + +/** + * @brief get a reference to the head item in the list + * + * The list must be known to be non-empty. + * + * @param list the doubly-linked list to operate on + * + * @return a pointer to the head element + */ + +static inline sys_dnode_t *sys_dlist_peek_head_not_empty(sys_dlist_t *list) +{ + return list->head; +} + +/** + * @brief get a reference to the next item in the list, node is not NULL + * + * Faster than sys_dlist_peek_next() if node is known not to be NULL. + * + * @param list the doubly-linked list to operate on + * @param node the node from which to get the next element in the list + * + * @return a pointer to the next element from a node, NULL if node is the tail + */ + +static inline sys_dnode_t *sys_dlist_peek_next_no_check(sys_dlist_t *list, + sys_dnode_t *node) +{ + return (node == list->tail) ? NULL : node->next; +} + +/** + * @brief get a reference to the next item in the list + * + * @param list the doubly-linked list to operate on + * @param node the node from which to get the next element in the list + * + * @return a pointer to the next element from a node, NULL if node is the tail + * or NULL (when node comes from reading the head of an empty list). + */ + +static inline sys_dnode_t *sys_dlist_peek_next(sys_dlist_t *list, + sys_dnode_t *node) +{ + return node ? sys_dlist_peek_next_no_check(list, node) : NULL; +} + +/** + * @brief get a reference to the tail item in the list + * + * @param list the doubly-linked list to operate on + * + * @return a pointer to the tail element, NULL if list is empty + */ + +static inline sys_dnode_t *sys_dlist_peek_tail(sys_dlist_t *list) +{ + return sys_dlist_is_empty(list) ? NULL : list->tail; +} + +/** + * @brief add node to tail of list + * + * This and other sys_dlist_*() functions are not thread safe. + * + * @param list the doubly-linked list to operate on + * @param node the element to append + * + * @return N/A + */ + +static inline void sys_dlist_append(sys_dlist_t *list, sys_dnode_t *node) +{ + node->next = list; + node->prev = list->tail; + + list->tail->next = node; + list->tail = node; +} + +/** + * @brief add node to head of list + * + * This and other sys_dlist_*() functions are not thread safe. + * + * @param list the doubly-linked list to operate on + * @param node the element to append + * + * @return N/A + */ + +static inline void sys_dlist_prepend(sys_dlist_t *list, sys_dnode_t *node) +{ + node->next = list->head; + node->prev = list; + + list->head->prev = node; + list->head = node; +} + +/** + * @brief insert node after a node + * + * Insert a node after a specified node in a list. + * This and other sys_dlist_*() functions are not thread safe. + * + * @param list the doubly-linked list to operate on + * @param insert_point the insert point in the list: if NULL, insert at head + * @param node the element to append + * + * @return N/A + */ + +static inline void sys_dlist_insert_after(sys_dlist_t *list, + sys_dnode_t *insert_point, + sys_dnode_t *node) +{ + if (!insert_point) { + sys_dlist_prepend(list, node); + } else { + node->next = insert_point->next; + node->prev = insert_point; + insert_point->next->prev = node; + insert_point->next = node; + } +} + +/** + * @brief insert node before a node + * + * Insert a node before a specified node in a list. + * This and other sys_dlist_*() functions are not thread safe. + * + * @param list the doubly-linked list to operate on + * @param insert_point the insert point in the list: if NULL, insert at tail + * @param node the element to insert + * + * @return N/A + */ + +static inline void sys_dlist_insert_before(sys_dlist_t *list, + sys_dnode_t *insert_point, + sys_dnode_t *node) +{ + if (!insert_point) { + sys_dlist_append(list, node); + } else { + node->prev = insert_point->prev; + node->next = insert_point; + insert_point->prev->next = node; + insert_point->prev = node; + } +} + +/** + * @brief insert node at position + * + * Insert a node in a location depending on a external condition. The cond() + * function checks if the node is to be inserted _before_ the current node + * against which it is checked. + * This and other sys_dlist_*() functions are not thread safe. + * + * @param list the doubly-linked list to operate on + * @param node the element to insert + * @param cond a function that determines if the current node is the correct + * insert point + * @param data parameter to cond() + * + * @return N/A + */ + +static inline void sys_dlist_insert_at(sys_dlist_t *list, sys_dnode_t *node, + int (*cond)(sys_dnode_t *, void *), void *data) +{ + if (sys_dlist_is_empty(list)) { + sys_dlist_append(list, node); + } else { + sys_dnode_t *pos = sys_dlist_peek_head(list); + + while (pos && !cond(pos, data)) { + pos = sys_dlist_peek_next(list, pos); + } + sys_dlist_insert_before(list, pos, node); + } +} + +/** + * @brief remove a specific node from a list + * + * The list is implicit from the node. The node must be part of a list. + * This and other sys_dlist_*() functions are not thread safe. + * + * @param node the node to remove + * + * @return N/A + */ + +static inline void sys_dlist_remove(sys_dnode_t *node) +{ + node->prev->next = node->next; + node->next->prev = node->prev; +} + +/** + * @brief get the first node in a list + * + * This and other sys_dlist_*() functions are not thread safe. + * + * @param list the doubly-linked list to operate on + * + * @return the first node in the list, NULL if list is empty + */ + +static inline sys_dnode_t *sys_dlist_get(sys_dlist_t *list) +{ + sys_dnode_t *node; + + if (sys_dlist_is_empty(list)) { + return NULL; + } + + node = list->head; + sys_dlist_remove(node); + return node; +} + +#ifdef __cplusplus +} +#endif + +#endif /* _BLE_MESH_DLIST_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_ffs.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_ffs.h new file mode 100644 index 00000000000..1173affbb4d --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_ffs.h @@ -0,0 +1,60 @@ +/* + * SPDX-FileCopyrightText: 2015 Wind River Systems, Inc. + * SPDX-FileCopyrightText: 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(uint32_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(uint32_t op) +{ + return __builtin_ffs(op); +} + +#ifdef __cplusplus +} +#endif + +#endif /* _BLE_MESH_FFS_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_kernel.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_kernel.h new file mode 100644 index 00000000000..b11e144e087 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_kernel.h @@ -0,0 +1,59 @@ +/* + * SPDX-FileCopyrightText: 2016 Wind River Systems, Inc. + * SPDX-FileContributor: 2020-2021 Espressif Systems (Shanghai) CO 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 "mesh_config.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(int32_t duration); + +#ifdef __cplusplus +} +#endif + +#endif /* _BLE_MESH_KERNEL_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_mutex.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_mutex.h new file mode 100644 index 00000000000..13d405bab09 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_mutex.h @@ -0,0 +1,49 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#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_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_slist.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_slist.h new file mode 100644 index 00000000000..aaeb5407cb0 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_slist.h @@ -0,0 +1,467 @@ +/* + * SPDX-FileCopyrightText: 2016 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** + * @file + * + * @brief Single-linked list implementation + * + * Single-linked list implementation using inline macros/functions. + * This API is not thread safe, and thus if a list is used across threads, + * calls to functions must be protected with synchronization primitives. + */ + +#ifndef _BLE_MESH_SLIST_H_ +#define _BLE_MESH_SLIST_H_ + +#include +#include +#include "mesh_util.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct _snode { + struct _snode *next; +}; + +typedef struct _snode sys_snode_t; + +struct _slist { + sys_snode_t *head; + sys_snode_t *tail; +}; + +typedef struct _slist sys_slist_t; + +/** + * @brief Provide the primitive to iterate on a list + * Note: the loop is unsafe and thus __sn should not be removed + * + * User _MUST_ add the loop statement curly braces enclosing its own code: + * + * SYS_SLIST_FOR_EACH_NODE(l, n) { + * + * } + * + * This and other SYS_SLIST_*() macros are not thread safe. + * + * @param __sl A pointer on a sys_slist_t to iterate on + * @param __sn A sys_snode_t pointer to peek each node of the list + */ +#define SYS_SLIST_FOR_EACH_NODE(__sl, __sn) \ + for (__sn = sys_slist_peek_head(__sl); __sn; \ + __sn = sys_slist_peek_next(__sn)) + +/** + * @brief Provide the primitive to iterate on a list, from a node in the list + * Note: the loop is unsafe and thus __sn should not be removed + * + * User _MUST_ add the loop statement curly braces enclosing its own code: + * + * SYS_SLIST_ITERATE_FROM_NODE(l, n) { + * + * } + * + * Like SYS_SLIST_FOR_EACH_NODE(), but __dn already contains a node in the list + * where to start searching for the next entry from. If NULL, it starts from + * the head. + * + * This and other SYS_SLIST_*() macros are not thread safe. + * + * @param __sl A pointer on a sys_slist_t to iterate on + * @param __sn A sys_snode_t pointer to peek each node of the list + * it contains the starting node, or NULL to start from the head + */ +#define SYS_SLIST_ITERATE_FROM_NODE(__sl, __sn) \ + for (__sn = __sn ? sys_slist_peek_next_no_check(__sn) \ + : sys_slist_peek_head(__sl); \ + __sn; \ + __sn = sys_slist_peek_next(__sn)) + +/** + * @brief Provide the primitive to safely iterate on a list + * Note: __sn can be removed, it will not break the loop. + * + * User _MUST_ add the loop statement curly braces enclosing its own code: + * + * SYS_SLIST_FOR_EACH_NODE_SAFE(l, n, s) { + * + * } + * + * This and other SYS_SLIST_*() macros are not thread safe. + * + * @param __sl A pointer on a sys_slist_t to iterate on + * @param __sn A sys_snode_t pointer to peek each node of the list + * @param __sns A sys_snode_t pointer for the loop to run safely + */ +#define SYS_SLIST_FOR_EACH_NODE_SAFE(__sl, __sn, __sns) \ + for (__sn = sys_slist_peek_head(__sl), \ + __sns = sys_slist_peek_next(__sn); \ + __sn; __sn = __sns, \ + __sns = sys_slist_peek_next(__sn)) + +/* + * @brief Provide the primitive to resolve the container of a list node + * Note: it is safe to use with NULL pointer nodes + * + * @param __ln A pointer on a sys_node_t to get its container + * @param __cn Container struct type pointer + * @param __n The field name of sys_node_t within the container struct + */ +#define SYS_SLIST_CONTAINER(__ln, __cn, __n) \ + ((__ln) ? CONTAINER_OF((__ln), __typeof__(*(__cn)), __n) : NULL) +/* + * @brief Provide the primitive to peek container of the list head + * + * @param __sl A pointer on a sys_slist_t to peek + * @param __cn Container struct type pointer + * @param __n The field name of sys_node_t within the container struct + */ +#define SYS_SLIST_PEEK_HEAD_CONTAINER(__sl, __cn, __n) \ + SYS_SLIST_CONTAINER(sys_slist_peek_head(__sl), __cn, __n) + +/* + * @brief Provide the primitive to peek container of the list tail + * + * @param __sl A pointer on a sys_slist_t to peek + * @param __cn Container struct type pointer + * @param __n The field name of sys_node_t within the container struct + */ +#define SYS_SLIST_PEEK_TAIL_CONTAINER(__sl, __cn, __n) \ + SYS_SLIST_CONTAINER(sys_slist_peek_tail(__sl), __cn, __n) + +/* + * @brief Provide the primitive to peek the next container + * + * @param __cn Container struct type pointer + * @param __n The field name of sys_node_t within the container struct + */ + +#define SYS_SLIST_PEEK_NEXT_CONTAINER(__cn, __n) \ + ((__cn) ? SYS_SLIST_CONTAINER(sys_slist_peek_next(&((__cn)->__n)), \ + __cn, __n) : NULL) + +/** + * @brief Provide the primitive to iterate on a list under a container + * Note: the loop is unsafe and thus __cn should not be detached + * + * User _MUST_ add the loop statement curly braces enclosing its own code: + * + * SYS_SLIST_FOR_EACH_CONTAINER(l, c, n) { + * + * } + * + * @param __sl A pointer on a sys_slist_t to iterate on + * @param __cn A pointer to peek each entry of the list + * @param __n The field name of sys_node_t within the container struct + */ +#define SYS_SLIST_FOR_EACH_CONTAINER(__sl, __cn, __n) \ + for (__cn = SYS_SLIST_PEEK_HEAD_CONTAINER(__sl, __cn, __n); __cn; \ + __cn = SYS_SLIST_PEEK_NEXT_CONTAINER(__cn, __n)) + +/** + * @brief Provide the primitive to safely iterate on a list under a container + * Note: __cn can be detached, it will not break the loop. + * + * User _MUST_ add the loop statement curly braces enclosing its own code: + * + * SYS_SLIST_FOR_EACH_NODE_SAFE(l, c, cn, n) { + * + * } + * + * @param __sl A pointer on a sys_slist_t to iterate on + * @param __cn A pointer to peek each entry of the list + * @param __cns A pointer for the loop to run safely + * @param __n The field name of sys_node_t within the container struct + */ +#define SYS_SLIST_FOR_EACH_CONTAINER_SAFE(__sl, __cn, __cns, __n) \ + for (__cn = SYS_SLIST_PEEK_HEAD_CONTAINER(__sl, __cn, __n), \ + __cns = SYS_SLIST_PEEK_NEXT_CONTAINER(__cn, __n); __cn; \ + __cn = __cns, __cns = SYS_SLIST_PEEK_NEXT_CONTAINER(__cn, __n)) + +/** + * @brief Initialize a list + * + * @param list A pointer on the list to initialize + */ +static inline void sys_slist_init(sys_slist_t *list) +{ + list->head = NULL; + list->tail = NULL; +} + +#define SYS_SLIST_STATIC_INIT(ptr_to_list) {NULL, NULL} + +/** + * @brief Test if the given list is empty + * + * @param list A pointer on the list to test + * + * @return a boolean, true if it's empty, false otherwise + */ +static inline bool sys_slist_is_empty(sys_slist_t *list) +{ + return (!list->head); +} + +/** + * @brief Peek the first node from the list + * + * @param list A point on the list to peek the first node from + * + * @return A pointer on the first node of the list (or NULL if none) + */ +static inline sys_snode_t *sys_slist_peek_head(sys_slist_t *list) +{ + return list->head; +} + +/** + * @brief Peek the last node from the list + * + * @param list A point on the list to peek the last node from + * + * @return A pointer on the last node of the list (or NULL if none) + */ +static inline sys_snode_t *sys_slist_peek_tail(sys_slist_t *list) +{ + return list->tail; +} + +/** + * @brief Peek the next node from current node, node is not NULL + * + * Faster then sys_slist_peek_next() if node is known not to be NULL. + * + * @param node A pointer on the node where to peek the next node + * + * @return a pointer on the next node (or NULL if none) + */ +static inline sys_snode_t *sys_slist_peek_next_no_check(sys_snode_t *node) +{ + return node->next; +} + +/** + * @brief Peek the next node from current node + * + * @param node A pointer on the node where to peek the next node + * + * @return a pointer on the next node (or NULL if none) + */ +static inline sys_snode_t *sys_slist_peek_next(sys_snode_t *node) +{ + return node ? sys_slist_peek_next_no_check(node) : NULL; +} + +/** + * @brief Prepend a node to the given list + * + * This and other sys_slist_*() functions are not thread safe. + * + * @param list A pointer on the list to affect + * @param node A pointer on the node to prepend + */ +static inline void sys_slist_prepend(sys_slist_t *list, + sys_snode_t *node) +{ + node->next = list->head; + list->head = node; + + if (!list->tail) { + list->tail = list->head; + } +} + +/** + * @brief Append a node to the given list + * + * This and other sys_slist_*() functions are not thread safe. + * + * @param list A pointer on the list to affect + * @param node A pointer on the node to append + */ +static inline void sys_slist_append(sys_slist_t *list, + sys_snode_t *node) +{ + node->next = NULL; + + if (!list->tail) { + list->tail = node; + list->head = node; + } else { + list->tail->next = node; + list->tail = node; + } +} + +/** + * @brief Append a list to the given list + * + * Append a singly-linked, NULL-terminated list consisting of nodes containing + * the pointer to the next node as the first element of a node, to @a list. + * This and other sys_slist_*() functions are not thread safe. + * + * @param list A pointer on the list to affect + * @param head A pointer to the first element of the list to append + * @param tail A pointer to the last element of the list to append + */ +static inline void sys_slist_append_list(sys_slist_t *list, + void *head, void *tail) +{ + if (!list->tail) { + list->head = (sys_snode_t *)head; + list->tail = (sys_snode_t *)tail; + } else { + list->tail->next = (sys_snode_t *)head; + list->tail = (sys_snode_t *)tail; + } +} + +/** + * @brief merge two slists, appending the second one to the first + * + * When the operation is completed, the appending list is empty. + * This and other sys_slist_*() functions are not thread safe. + * + * @param list A pointer on the list to affect + * @param list_to_append A pointer to the list to append. + */ +static inline void sys_slist_merge_slist(sys_slist_t *list, + sys_slist_t *list_to_append) +{ + sys_slist_append_list(list, list_to_append->head, + list_to_append->tail); + sys_slist_init(list_to_append); +} + +/** + * @brief Insert a node to the given list + * + * This and other sys_slist_*() functions are not thread safe. + * + * @param list A pointer on the list to affect + * @param prev A pointer on the previous node + * @param node A pointer on the node to insert + */ +static inline void sys_slist_insert(sys_slist_t *list, + sys_snode_t *prev, + sys_snode_t *node) +{ + if (!prev) { + sys_slist_prepend(list, node); + } else if (!prev->next) { + sys_slist_append(list, node); + } else { + node->next = prev->next; + prev->next = node; + } +} + +/** + * @brief Fetch and remove the first node of the given list + * + * List must be known to be non-empty. + * This and other sys_slist_*() functions are not thread safe. + * + * @param list A pointer on the list to affect + * + * @return A pointer to the first node of the list + */ +static inline sys_snode_t *sys_slist_get_not_empty(sys_slist_t *list) +{ + sys_snode_t *node = list->head; + + list->head = node->next; + if (list->tail == node) { + list->tail = list->head; + } + + return node; +} + +/** + * @brief Fetch and remove the first node of the given list + * + * This and other sys_slist_*() functions are not thread safe. + * + * @param list A pointer on the list to affect + * + * @return A pointer to the first node of the list (or NULL if empty) + */ +static inline sys_snode_t *sys_slist_get(sys_slist_t *list) +{ + return sys_slist_is_empty(list) ? NULL : sys_slist_get_not_empty(list); +} + +/** + * @brief Remove a node + * + * This and other sys_slist_*() functions are not thread safe. + * + * @param list A pointer on the list to affect + * @param prev_node A pointer on the previous node + * (can be NULL, which means the node is the list's head) + * @param node A pointer on the node to remove + */ +static inline void sys_slist_remove(sys_slist_t *list, + sys_snode_t *prev_node, + sys_snode_t *node) +{ + if (!prev_node) { + list->head = node->next; + + /* Was node also the tail? */ + if (list->tail == node) { + list->tail = list->head; + } + } else { + prev_node->next = node->next; + + /* Was node the tail? */ + if (list->tail == node) { + list->tail = prev_node; + } + } + + node->next = NULL; +} + +/** + * @brief Find and remove a node from a list + * + * This and other sys_slist_*() functions are not thread safe. + * + * @param list A pointer on the list to affect + * @param node A pointer on the node to remove from the list + * + * @return true if node was removed + */ +static inline bool sys_slist_find_and_remove(sys_slist_t *list, + sys_snode_t *node) +{ + sys_snode_t *prev = NULL; + sys_snode_t *test; + + SYS_SLIST_FOR_EACH_NODE(list, test) { + if (test == node) { + sys_slist_remove(list, prev, node); + return true; + } + + prev = test; + } + + return false; +} + +#ifdef __cplusplus +} +#endif + +#endif /* _BLE_MESH_SLIST_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_timer.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_timer.h new file mode 100644 index 00000000000..5399c4e5c73 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_timer.h @@ -0,0 +1,266 @@ +/* + * SPDX-FileCopyrightText: 2016 Wind River Systems, Inc. + * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _BLE_MESH_TIMER_H_ +#define _BLE_MESH_TIMER_H_ + +#include "mesh_types.h" +#include "mesh_slist.h" +#include "mesh_atomic.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* number of nsec per usec */ +#define NSEC_PER_USEC 1000 + +/* number of microseconds per millisecond */ +#define USEC_PER_MSEC 1000 + +/* number of milliseconds per second */ +#define MSEC_PER_SEC 1000 + +/* number of microseconds per second */ +#define USEC_PER_SEC ((USEC_PER_MSEC) * (MSEC_PER_SEC)) + +/* number of nanoseconds per second */ +#define NSEC_PER_SEC ((NSEC_PER_USEC) * (USEC_PER_MSEC) * (MSEC_PER_SEC)) + +/* timeout is not in use */ +#define _INACTIVE (-1) + +struct k_work; + +/** + * @typedef k_work_handler_t + * @brief Work item handler function type. + * + * A work item's handler function is executed by a workqueue's thread + * when the work item is processed by the workqueue. + * + * @param work Address of the work item. + * + * @return N/A + */ +typedef void (*k_work_handler_t)(struct k_work *work); + +struct k_work { + void *_reserved; + k_work_handler_t handler; + int index; +}; + +#define _K_WORK_INITIALIZER(work_handler) \ +{ \ + ._reserved = NULL, \ + .handler = work_handler, \ +} + +/** + * @brief Generate null timeout delay. + * + * This macro generates a timeout delay that that instructs a kernel API + * not to wait if the requested operation cannot be performed immediately. + * + * @return Timeout delay value. + */ +#define K_NO_WAIT 0 + +/** + * @brief Generate timeout delay from milliseconds. + * + * This macro generates a timeout delay that that instructs a kernel API + * to wait up to @a ms milliseconds to perform the requested operation. + * + * @param ms Duration in milliseconds. + * + * @return Timeout delay value. + */ +#define K_MSEC(ms) (ms) + +/** + * @brief Generate timeout delay from seconds. + * + * This macro generates a timeout delay that that instructs a kernel API + * to wait up to @a s seconds to perform the requested operation. + * + * @param s Duration in seconds. + * + * @return Timeout delay value. + */ +#define K_SECONDS(s) K_MSEC((s) * MSEC_PER_SEC) + +/** + * @brief Generate timeout delay from minutes. + * + * This macro generates a timeout delay that that instructs a kernel API + * to wait up to @a m minutes to perform the requested operation. + * + * @param m Duration in minutes. + * + * @return Timeout delay value. + */ +#define K_MINUTES(m) K_SECONDS((m) * 60) + +/** + * @brief Generate timeout delay from hours. + * + * This macro generates a timeout delay that that instructs a kernel API + * to wait up to @a h hours to perform the requested operation. + * + * @param h Duration in hours. + * + * @return Timeout delay value. + */ +#define K_HOURS(h) K_MINUTES((h) * 60) + +/** + * @brief Generate infinite timeout delay. + * + * This macro generates a timeout delay that that instructs a kernel API + * to wait as long as necessary to perform the requested operation. + * + * @return Timeout delay value. + */ +#define K_FOREVER (-1) + +/** + * @brief Get system uptime (32-bit version). + * + * This routine returns the lower 32-bits of the elapsed time since the system + * booted, in milliseconds. + * + * This routine can be more efficient than k_uptime_get(), as it reduces the + * need for interrupt locking and 64-bit math. However, the 32-bit result + * cannot hold a system uptime time larger than approximately 50 days, so the + * caller must handle possible rollovers. + * + * @return Current uptime. + */ +uint32_t k_uptime_get_32(void); + +struct k_delayed_work { + struct k_work work; +}; + +/** + * @brief Submit a delayed work item to the system workqueue. + * + * This routine schedules work item @a work to be processed by the system + * workqueue after a delay of @a delay milliseconds. The routine initiates + * an asynchronous countdown for the work item and then returns to the caller. + * Only when the countdown completes is the work item actually submitted to + * the workqueue and becomes pending. + * + * Submitting a previously submitted delayed work item that is still + * counting down cancels the existing submission and restarts the countdown + * using the new delay. If the work item is currently pending on the + * workqueue's queue because the countdown has completed it is too late to + * resubmit the item, and resubmission fails without impacting the work item. + * If the work item has already been processed, or is currently being processed, + * its work is considered complete and the work item can be resubmitted. + * + * @warning + * Work items submitted to the system workqueue should avoid using handlers + * that block or yield since this may prevent the system workqueue from + * processing other work items in a timely manner. + * + * @note Can be called by ISRs. + * + * @param work Address of delayed work item. + * @param delay Delay before submitting the work item (in milliseconds). + * + * @retval 0 Work item countdown started. + * @retval -EINPROGRESS Work item is already pending. + * @retval -EINVAL Work item is being processed or has completed its work. + * @retval -EADDRINUSE Work item is pending on a different workqueue. + */ +int k_delayed_work_submit(struct k_delayed_work *work, int32_t delay); + +int k_delayed_work_submit_periodic(struct k_delayed_work *work, int32_t period); + +/** + * @brief Get time remaining before a delayed work gets scheduled. + * + * This routine computes the (approximate) time remaining before a + * delayed work gets executed. If the delayed work is not waiting to be + * scheduled, it returns zero. + * + * @param work Delayed work item. + * + * @return Remaining time (in milliseconds). + */ +int32_t k_delayed_work_remaining_get(struct k_delayed_work *work); + +/** + * @brief Submit a work item to the system workqueue. + * + * This routine submits work item @a work to be processed by the system + * workqueue. If the work item is already pending in the workqueue's queue + * as a result of an earlier submission, this routine has no effect on the + * work item. If the work item has already been processed, or is currently + * being processed, its work is considered complete and the work item can be + * resubmitted. + * + * @warning + * Work items submitted to the system workqueue should avoid using handlers + * that block or yield since this may prevent the system workqueue from + * processing other work items in a timely manner. + * + * @note Can be called by ISRs. + * + * @param work Address of work item. + * + * @return N/A + */ +static inline void k_work_submit(struct k_work *work) +{ + if (work && work->handler) { + work->handler(work); + } +} + +/** + * @brief Initialize a work item. + * + * This routine initializes a workqueue work item, prior to its first use. + * + * @param work Address of work item. + * @param handler Function to invoke each time work item is processed. + * + * @return N/A + */ +static inline void k_work_init(struct k_work *work, k_work_handler_t handler) +{ + work->handler = handler; +} + +int k_delayed_work_cancel(struct k_delayed_work *work); + +int k_delayed_work_free(struct k_delayed_work *work); + +int k_delayed_work_init(struct k_delayed_work *work, k_work_handler_t handler); + +/** + * @brief Get system uptime. + * + * This routine returns the elapsed time since the system booted, + * in milliseconds. + * + * @return Current uptime. + */ +int64_t k_uptime_get(void); + +void bt_mesh_timer_init(void); +void bt_mesh_timer_deinit(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _BLE_MESH_TIMER_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_trace.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_trace.h new file mode 100644 index 00000000000..72ad111ac3e --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_trace.h @@ -0,0 +1,127 @@ +/* + * SPDX-FileCopyrightText: 2017 Nordic Semiconductor ASA + * SPDX-FileCopyrightText: 2015-2016 Intel Corporation + * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _BLE_MESH_TRACE_H_ +#define _BLE_MESH_TRACE_H_ + +#include +#include "esp_log.h" +#include "mesh_util.h" +#include "esp_rom_sys.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Define common tracing for all */ +#ifndef BLE_MESH_LOG_LEVEL_ERROR +#define BLE_MESH_LOG_LEVEL_ERROR 1 +#endif /* BLE_MESH_LOG_LEVEL_ERROR */ + +#ifndef BLE_MESH_LOG_LEVEL_WARN +#define BLE_MESH_LOG_LEVEL_WARN 2 +#endif /* BLE_MESH_LOG_LEVEL_WARN */ + +#ifndef BLE_MESH_LOG_LEVEL_INFO +#define BLE_MESH_LOG_LEVEL_INFO 3 +#endif /* BLE_MESH_LOG_LEVEL_INFO */ + +#ifndef BLE_MESH_LOG_LEVEL_DEBUG +#define BLE_MESH_LOG_LEVEL_DEBUG 4 +#endif /* BLE_MESH_LOG_LEVEL_DEBUG */ + +#ifndef BLE_MESH_LOG_LEVEL_VERBOSE +#define BLE_MESH_LOG_LEVEL_VERBOSE 5 +#endif /*BLE_MESH_LOG_LEVEL_VERBOSE */ + +#ifdef CONFIG_BLE_MESH_STACK_TRACE_LEVEL +#define BLE_MESH_LOG_LEVEL CONFIG_BLE_MESH_STACK_TRACE_LEVEL +#else +#define BLE_MESH_LOG_LEVEL BLE_MESH_LOG_LEVEL_WARN +#endif + +#ifdef CONFIG_BLE_MESH_NET_BUF_TRACE_LEVEL +#define BLE_MESH_NET_BUF_LOG_LEVEL CONFIG_BLE_MESH_NET_BUF_TRACE_LEVEL +#else +#define BLE_MESH_NET_BUF_LOG_LEVEL BLE_MESH_LOG_LEVEL_WARN +#endif + +#define BLE_MESH_TRACE_TAG "BLE_MESH" + +#if (LOG_LOCAL_LEVEL >= 4) +#define BLE_MESH_LOG_LOCAL_LEVEL_MAPPING (LOG_LOCAL_LEVEL + 1) +#else +#define BLE_MESH_LOG_LOCAL_LEVEL_MAPPING LOG_LOCAL_LEVEL +#endif + +#define BLE_MESH_LOG_LEVEL_CHECK(LAYER, LEVEL) (MAX(LAYER##_LOG_LEVEL, BLE_MESH_LOG_LOCAL_LEVEL_MAPPING) >= BLE_MESH_LOG_LEVEL_##LEVEL) + +#define BLE_MESH_PRINT_E(tag, format, ...) {esp_log_write(ESP_LOG_ERROR, tag, LOG_FORMAT(E, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } +#define BLE_MESH_PRINT_W(tag, format, ...) {esp_log_write(ESP_LOG_WARN, tag, LOG_FORMAT(W, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } +#define BLE_MESH_PRINT_I(tag, format, ...) {esp_log_write(ESP_LOG_INFO, tag, LOG_FORMAT(I, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } +#define BLE_MESH_PRINT_D(tag, format, ...) {esp_log_write(ESP_LOG_DEBUG, tag, LOG_FORMAT(D, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } +#define BLE_MESH_PRINT_V(tag, format, ...) {esp_log_write(ESP_LOG_VERBOSE, tag, LOG_FORMAT(V, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } + +#define printk esp_rom_printf + +#define _STRINGIFY(x) #x +#define STRINGIFY(s) _STRINGIFY(s) + +#ifndef __ASSERT +#define __ASSERT(test, str) assert(test) +#endif + +#ifndef __ASSERT_NO_MSG +#define __ASSERT_NO_MSG(x) assert(x) +#endif + +#if !CONFIG_BLE_MESH_NO_LOG +#define BT_ERR(fmt, args...) do {if ((BLE_MESH_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_ERROR) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH, ERROR)) BLE_MESH_PRINT_E(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0) +#define BT_WARN(fmt, args...) do {if ((BLE_MESH_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_WARN) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH, WARN)) BLE_MESH_PRINT_W(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0) +#define BT_INFO(fmt, args...) do {if ((BLE_MESH_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_INFO) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH, INFO)) BLE_MESH_PRINT_I(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0) +#define BT_DBG(fmt, args...) do {if ((BLE_MESH_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_DEBUG) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH, DEBUG)) BLE_MESH_PRINT_D(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0) +#else +#define BT_ERR(fmt, args...) +#define BT_WARN(fmt, args...) +#define BT_INFO(fmt, args...) +#define BT_DBG(fmt, args...) +#endif + +#if defined(CONFIG_BLE_MESH_NET_BUF_LOG) && (!CONFIG_BLE_MESH_NO_LOG) +#define NET_BUF_ERR(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_ERROR) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, ERROR)) BLE_MESH_PRINT_E(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0) +#define NET_BUF_WARN(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_WARN) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, WARN)) BLE_MESH_PRINT_W(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0) +#define NET_BUF_INFO(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_INFO) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, INFO)) BLE_MESH_PRINT_I(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0) +#define NET_BUF_DBG(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_DEBUG) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, DEBUG)) BLE_MESH_PRINT_D(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0) +#define NET_BUF_ASSERT(cond) __ASSERT_NO_MSG(cond) +#else +#define NET_BUF_ERR(fmt, args...) +#define NET_BUF_WARN(fmt, args...) +#define NET_BUF_INFO(fmt, args...) +#define NET_BUF_DBG(fmt, args...) +#define NET_BUF_ASSERT(cond) +#endif + +#if defined(CONFIG_BLE_MESH_NET_BUF_SIMPLE_LOG) && (!CONFIG_BLE_MESH_NO_LOG) +#define NET_BUF_SIMPLE_ERR(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_ERROR) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, ERROR)) BLE_MESH_PRINT_E(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0) +#define NET_BUF_SIMPLE_WARN(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_WARN) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, WARN)) BLE_MESH_PRINT_W(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0) +#define NET_BUF_SIMPLE_INFO(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_INFO) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, INFO)) BLE_MESH_PRINT_I(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0) +#define NET_BUF_SIMPLE_DBG(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_DEBUG) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, DEBUG)) BLE_MESH_PRINT_D(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0) +#define NET_BUF_SIMPLE_ASSERT(cond) __ASSERT_NO_MSG(cond) +#else +#define NET_BUF_SIMPLE_ERR(fmt, args...) +#define NET_BUF_SIMPLE_WARN(fmt, args...) +#define NET_BUF_SIMPLE_INFO(fmt, args...) +#define NET_BUF_SIMPLE_DBG(fmt, args...) +#define NET_BUF_SIMPLE_ASSERT(cond) +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _BLE_MESH_TRACE_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_types.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_types.h new file mode 100644 index 00000000000..eba8c1a2063 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_types.h @@ -0,0 +1,33 @@ +/* + * SPDX-FileCopyrightText: 2017 Linaro Limited + * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _BLE_MESH_TYPES_H_ +#define _BLE_MESH_TYPES_H_ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef int bt_mesh_atomic_t; + +#ifndef PRIu64 +#define PRIu64 "llu" +#endif + +#ifndef PRIx64 +#define PRIx64 "llx" +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _BLE_MESH_TYPES_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_util.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_util.h new file mode 100644 index 00000000000..c12c8d70a65 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/include/mesh_util.h @@ -0,0 +1,191 @@ +/* + * SPDX-FileCopyrightText: 2011-2014 Wind River Systems, Inc. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** + * @file + * @brief Misc utilities + * + * Misc utilities usable by the kernel and application code. + */ + +#ifndef _BLE_MESH_UTIL_H_ +#define _BLE_MESH_UTIL_H_ + +#include +#include "esp_bit_defs.h" +#include "mesh_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Helper to pass a int as a pointer or vice-versa. + * Those are available for 32 bits architectures: + */ +#ifndef POINTER_TO_UINT +#define POINTER_TO_UINT(x) ((uint32_t) (x)) +#endif +#ifndef UINT_TO_POINTER +#define UINT_TO_POINTER(x) ((void *) (x)) +#endif +#ifndef POINTER_TO_INT +#define POINTER_TO_INT(x) ((int32_t) (x)) +#endif +#ifndef INT_TO_POINTER +#define INT_TO_POINTER(x) ((void *) (x)) +#endif + +/* Evaluates to 0 if cond is true-ish; compile error otherwise */ +#ifndef ZERO_OR_COMPILE_ERROR +#define ZERO_OR_COMPILE_ERROR(cond) ((int) sizeof(char[1 - 2 * !(cond)]) - 1) +#endif + +/* Evaluates to 0 if array is an array; compile error if not array (e.g. + * pointer) + */ +#ifndef IS_ARRAY +#define IS_ARRAY(array) \ + ZERO_OR_COMPILE_ERROR( \ + !__builtin_types_compatible_p(__typeof__(array), \ + __typeof__(&(array)[0]))) +#endif + +/* Evaluates to number of elements in an array; compile error if not + * an array (e.g. pointer) + */ +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) +#endif + +/* Evaluates to 1 if ptr is part of array, 0 otherwise; compile error if + * "array" argument is not an array (e.g. "ptr" and "array" mixed up) + */ +#ifndef PART_OF_ARRAY +#define PART_OF_ARRAY(array, ptr) \ + ((ptr) && ((ptr) >= &array[0] && (ptr) < &array[ARRAY_SIZE(array)])) +#endif + +#ifndef CONTAINER_OF +#define CONTAINER_OF(ptr, type, field) \ + ((type *)(((char *)(ptr)) - offsetof(type, field))) +#endif + +/* round "x" up/down to next multiple of "align" (which must be a power of 2) */ +#ifndef ROUND_UP +#define ROUND_UP(x, align) \ + (((unsigned long)(x) + ((unsigned long)align - 1)) & \ + ~((unsigned long)align - 1)) +#endif + +#ifndef ROUND_DOWN +#define ROUND_DOWN(x, align) ((unsigned long)(x) & ~((unsigned long)align - 1)) +#endif + +/* round up/down to the next word boundary */ +#ifndef WB_UP +#define WB_UP(x) ROUND_UP(x, sizeof(void *)) +#endif + +#ifndef WB_DN +#define WB_DN(x) ROUND_DOWN(x, sizeof(void *)) +#endif + +#ifndef ceiling_fraction +#define ceiling_fraction(numerator, divider) \ + (((numerator) + ((divider) - 1)) / (divider)) +#endif + +#ifndef CHECKIF +#define CHECKIF(expr) if (expr) +#endif + +/** @brief Return larger value of two provided expressions. + * + * @note Arguments are evaluated twice. See Z_MAX for GCC only, single + * evaluation version. + */ +#ifndef MAX +#define MAX(a, b) (((a) > (b)) ? (a) : (b)) +#endif + +/** @brief Return smaller value of two provided expressions. + * + * @note Arguments are evaluated twice. See Z_MIN for GCC only, single + * evaluation version. + */ +#ifndef MIN +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) +#endif + +#ifndef BIT +#define BIT(n) (1UL << (n)) +#endif + +#ifndef BIT_MASK +#define BIT_MASK(n) (BIT(n) - 1) +#endif + +/** + * @brief Check for macro definition in compiler-visible expressions + * + * This trick was pioneered in Linux as the config_enabled() macro. + * The madness has the effect of taking a macro value that may be + * defined to "1" (e.g. CONFIG_MYFEATURE), or may not be defined at + * all and turning it into a literal expression that can be used at + * "runtime". That is, it works similarly to + * "defined(CONFIG_MYFEATURE)" does except that it is an expansion + * that can exist in a standard expression and be seen by the compiler + * and optimizer. Thus much ifdef usage can be replaced with cleaner + * expressions like: + * + * if (IS_ENABLED(CONFIG_MYFEATURE)) + * myfeature_enable(); + * + * INTERNAL + * First pass just to expand any existing macros, we need the macro + * value to be e.g. a literal "1" at expansion time in the next macro, + * not "(1)", etc... Standard recursive expansion does not work. + */ +#define IS_ENABLED(config_macro) Z_IS_ENABLED1(config_macro) + +/* Now stick on a "_XXXX" prefix, it will now be "_XXXX1" if config_macro + * is "1", or just "_XXXX" if it's undefined. + * ENABLED: Z_IS_ENABLED2(_XXXX1) + * DISABLED Z_IS_ENABLED2(_XXXX) + */ +#define Z_IS_ENABLED1(config_macro) Z_IS_ENABLED2(_XXXX##config_macro) + +/* Here's the core trick, we map "_XXXX1" to "_YYYY," (i.e. a string + * with a trailing comma), so it has the effect of making this a + * two-argument tuple to the preprocessor only in the case where the + * value is defined to "1" + * ENABLED: _YYYY, <--- note comma! + * DISABLED: _XXXX + */ +#define _XXXX1 _YYYY, + +/* Then we append an extra argument to fool the gcc preprocessor into + * accepting it as a varargs macro. + * arg1 arg2 arg3 + * ENABLED: Z_IS_ENABLED3(_YYYY, 1, 0) + * DISABLED Z_IS_ENABLED3(_XXXX 1, 0) + */ +#define Z_IS_ENABLED2(one_or_two_args) Z_IS_ENABLED3(one_or_two_args true, false) + +/* And our second argument is thus now cooked to be 1 in the case + * where the value is defined to 1, and 0 if not: + */ +#define Z_IS_ENABLED3(ignore_this, val, ...) val + +const char *bt_hex(const void *buf, size_t len); + +void mem_rcopy(uint8_t *dst, uint8_t const *src, uint16_t len); + +#ifdef __cplusplus +} +#endif + +#endif /* _BLE_MESH_UTIL_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/aes.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/aes.h new file mode 100644 index 00000000000..aa636c7d4f9 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/aes.h @@ -0,0 +1,130 @@ +/* aes.h - TinyCrypt interface to an AES-128 implementation */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief -- Interface to an AES-128 implementation. + * + * Overview: AES-128 is a NIST approved block cipher specified in + * FIPS 197. Block ciphers are deterministic algorithms that + * perform a transformation specified by a symmetric key in fixed- + * length data sets, also called blocks. + * + * Security: AES-128 provides approximately 128 bits of security. + * + * Usage: 1) call tc_aes128_set_encrypt/decrypt_key to set the key. + * + * 2) call tc_aes_encrypt/decrypt to process the data. + */ + +#ifndef __BLE_MESH_TC_AES_H__ +#define __BLE_MESH_TC_AES_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define Nb (4) /* number of columns (32-bit words) comprising the state */ +#define Nk (4) /* number of 32-bit words comprising the key */ +#define Nr (10) /* number of rounds */ +#define TC_AES_BLOCK_SIZE (Nb*Nk) +#define TC_AES_KEY_SIZE (Nb*Nk) + +typedef struct tc_aes_key_sched_struct { + unsigned int words[Nb * (Nr + 1)]; +} *TCAesKeySched_t; + +/** + * @brief Set AES-128 encryption key + * Uses key k to initialize s + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: s == NULL or k == NULL + * @note This implementation skips the additional steps required for keys + * larger than 128 bits, and must not be used for AES-192 or + * AES-256 key schedule -- see FIPS 197 for details + * @param s IN/OUT -- initialized struct tc_aes_key_sched_struct + * @param k IN -- points to the AES key + */ +int tc_aes128_set_encrypt_key(TCAesKeySched_t s, const uint8_t *k); + +/** + * @brief AES-128 Encryption procedure + * Encrypts contents of in buffer into out buffer under key; + * schedule s + * @note Assumes s was initialized by aes_set_encrypt_key; + * out and in point to 16 byte buffers + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: out == NULL or in == NULL or s == NULL + * @param out IN/OUT -- buffer to receive ciphertext block + * @param in IN -- a plaintext block to encrypt + * @param s IN -- initialized AES key schedule + */ +int tc_aes_encrypt(uint8_t *out, const uint8_t *in, + const TCAesKeySched_t s); + +/** + * @brief Set the AES-128 decryption key + * Uses key k to initialize s + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: s == NULL or k == NULL + * @note This is the implementation of the straightforward inverse cipher + * using the cipher documented in FIPS-197 figure 12, not the + * equivalent inverse cipher presented in Figure 15 + * @warning This routine skips the additional steps required for keys larger + * than 128, and must not be used for AES-192 or AES-256 key + * schedule -- see FIPS 197 for details + * @param s IN/OUT -- initialized struct tc_aes_key_sched_struct + * @param k IN -- points to the AES key + */ +int tc_aes128_set_decrypt_key(TCAesKeySched_t s, const uint8_t *k); + +/** + * @brief AES-128 Encryption procedure + * Decrypts in buffer into out buffer under key schedule s + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: out is NULL or in is NULL or s is NULL + * @note Assumes s was initialized by aes_set_encrypt_key + * out and in point to 16 byte buffers + * @param out IN/OUT -- buffer to receive ciphertext block + * @param in IN -- a plaintext block to encrypt + * @param s IN -- initialized AES key schedule + */ +int tc_aes_decrypt(uint8_t *out, const uint8_t *in, + const TCAesKeySched_t s); + +#ifdef __cplusplus +} +#endif + +#endif /* __BLE_MESH_TC_AES_H__ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/cbc_mode.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/cbc_mode.h new file mode 100644 index 00000000000..4be3d95e56f --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/cbc_mode.h @@ -0,0 +1,151 @@ +/* cbc_mode.h - TinyCrypt interface to a CBC mode implementation */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief Interface to a CBC mode implementation. + * + * Overview: CBC (for "cipher block chaining") mode is a NIST approved mode of + * operation defined in SP 800-38a. It can be used with any block + * cipher to provide confidentiality of strings whose lengths are + * multiples of the block_size of the underlying block cipher. + * TinyCrypt hard codes AES as the block cipher. + * + * Security: CBC mode provides data confidentiality given that the maximum + * number q of blocks encrypted under a single key satisfies + * q < 2^63, which is not a practical constraint (it is considered a + * good practice to replace the encryption when q == 2^56). CBC mode + * provides NO data integrity. + * + * CBC mode assumes that the IV value input into the + * tc_cbc_mode_encrypt is randomly generated. The TinyCrypt library + * provides HMAC-PRNG module, which generates suitable IVs. Other + * methods for generating IVs are acceptable, provided that the + * values of the IVs generated appear random to any adversary, + * including someone with complete knowledge of the system design. + * + * The randomness property on which CBC mode's security depends is + * the unpredictability of the IV. Since it is unpredictable, this + * means in practice that CBC mode requires that the IV is stored + * somehow with the ciphertext in order to recover the plaintext. + * + * TinyCrypt CBC encryption prepends the IV to the ciphertext, + * because this affords a more efficient (few buffers) decryption. + * Hence tc_cbc_mode_encrypt assumes the ciphertext buffer is always + * 16 bytes larger than the plaintext buffer. + * + * Requires: AES-128 + * + * Usage: 1) call tc_cbc_mode_encrypt to encrypt data. + * + * 2) call tc_cbc_mode_decrypt to decrypt data. + * + */ + +#ifndef __BLE_MESH_TC_CBC_MODE_H__ +#define __BLE_MESH_TC_CBC_MODE_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief CBC encryption procedure + * CBC encrypts inlen bytes of the in buffer into the out buffer + * using the encryption key schedule provided, prepends iv to out + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: + * out == NULL or + * in == NULL or + * ctr == NULL or + * sched == NULL or + * inlen == 0 or + * (inlen % TC_AES_BLOCK_SIZE) != 0 or + * (outlen % TC_AES_BLOCK_SIZE) != 0 or + * outlen != inlen + TC_AES_BLOCK_SIZE + * @note Assumes: - sched has been configured by aes_set_encrypt_key + * - iv contains a 16 byte random string + * - out buffer is large enough to hold the ciphertext + iv + * - out buffer is a contiguous buffer + * - in holds the plaintext and is a contiguous buffer + * - inlen gives the number of bytes in the in buffer + * @param out IN/OUT -- buffer to receive the ciphertext + * @param outlen IN -- length of ciphertext buffer in bytes + * @param in IN -- plaintext to encrypt + * @param inlen IN -- length of plaintext buffer in bytes + * @param iv IN -- the IV for the this encrypt/decrypt + * @param sched IN -- AES key schedule for this encrypt + */ +int tc_cbc_mode_encrypt(uint8_t *out, unsigned int outlen, const uint8_t *in, + unsigned int inlen, const uint8_t *iv, + const TCAesKeySched_t sched); + +/** + * @brief CBC decryption procedure + * CBC decrypts inlen bytes of the in buffer into the out buffer + * using the provided encryption key schedule + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: + * out == NULL or + * in == NULL or + * sched == NULL or + * inlen == 0 or + * outlen == 0 or + * (inlen % TC_AES_BLOCK_SIZE) != 0 or + * (outlen % TC_AES_BLOCK_SIZE) != 0 or + * outlen != inlen + TC_AES_BLOCK_SIZE + * @note Assumes:- in == iv + ciphertext, i.e. the iv and the ciphertext are + * contiguous. This allows for a very efficient decryption + * algorithm that would not otherwise be possible + * - sched was configured by aes_set_decrypt_key + * - out buffer is large enough to hold the decrypted plaintext + * and is a contiguous buffer + * - inlen gives the number of bytes in the in buffer + * @param out IN/OUT -- buffer to receive decrypted data + * @param outlen IN -- length of plaintext buffer in bytes + * @param in IN -- ciphertext to decrypt, including IV + * @param inlen IN -- length of ciphertext buffer in bytes + * @param iv IN -- the IV for the this encrypt/decrypt + * @param sched IN -- AES key schedule for this decrypt + * + */ +int tc_cbc_mode_decrypt(uint8_t *out, unsigned int outlen, const uint8_t *in, + unsigned int inlen, const uint8_t *iv, + const TCAesKeySched_t sched); + +#ifdef __cplusplus +} +#endif + +#endif /* __BLE_MESH_TC_CBC_MODE_H__ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ccm_mode.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ccm_mode.h new file mode 100644 index 00000000000..1f85c76e613 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ccm_mode.h @@ -0,0 +1,211 @@ +/* ccm_mode.h - TinyCrypt interface to a CCM mode implementation */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief Interface to a CCM mode implementation. + * + * Overview: CCM (for "Counter with CBC-MAC") mode is a NIST approved mode of + * operation defined in SP 800-38C. + * + * TinyCrypt CCM implementation accepts: + * + * 1) Both non-empty payload and associated data (it encrypts and + * authenticates the payload and also authenticates the associated + * data); + * 2) Non-empty payload and empty associated data (it encrypts and + * authenticates the payload); + * 3) Non-empty associated data and empty payload (it degenerates to + * an authentication mode on the associated data). + * + * TinyCrypt CCM implementation accepts associated data of any length + * between 0 and (2^16 - 2^8) bytes. + * + * Security: The mac length parameter is an important parameter to estimate the + * security against collision attacks (that aim at finding different + * messages that produce the same authentication tag). TinyCrypt CCM + * implementation accepts any even integer between 4 and 16, as + * suggested in SP 800-38C. + * + * RFC-3610, which also specifies CCM, presents a few relevant + * security suggestions, such as: it is recommended for most + * applications to use a mac length greater than 8. Besides, the + * usage of the same nonce for two different messages which are + * encrypted with the same key destroys the security of CCM mode. + * + * Requires: AES-128 + * + * Usage: 1) call tc_ccm_config to configure. + * + * 2) call tc_ccm_mode_encrypt to encrypt data and generate tag. + * + * 3) call tc_ccm_mode_decrypt to decrypt data and verify tag. + */ + +#ifndef __BLE_MESH_TC_CCM_MODE_H__ +#define __BLE_MESH_TC_CCM_MODE_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* max additional authenticated size in bytes: 2^16 - 2^8 = 65280 */ +#define TC_CCM_AAD_MAX_BYTES 0xff00 + +/* max message size in bytes: 2^(8L) = 2^16 = 65536 */ +#define TC_CCM_PAYLOAD_MAX_BYTES 0x10000 + +/* struct tc_ccm_mode_struct represents the state of a CCM computation */ +typedef struct tc_ccm_mode_struct { + TCAesKeySched_t sched; /* AES key schedule */ + uint8_t *nonce; /* nonce required by CCM */ + unsigned int mlen; /* mac length in bytes (parameter t in SP-800 38C) */ +} *TCCcmMode_t; + +/** + * @brief CCM configuration procedure + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: + * c == NULL or + * sched == NULL or + * nonce == NULL or + * mlen != {4, 6, 8, 10, 12, 16} + * @param c -- CCM state + * @param sched IN -- AES key schedule + * @param nonce IN - nonce + * @param nlen -- nonce length in bytes + * @param mlen -- mac length in bytes (parameter t in SP-800 38C) + */ +int tc_ccm_config(TCCcmMode_t c, TCAesKeySched_t sched, uint8_t *nonce, + unsigned int nlen, unsigned int mlen); + +/** + * @brief CCM tag generation and encryption procedure + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: + * out == NULL or + * c == NULL or + * ((plen > 0) and (payload == NULL)) or + * ((alen > 0) and (associated_data == NULL)) or + * (alen >= TC_CCM_AAD_MAX_BYTES) or + * (plen >= TC_CCM_PAYLOAD_MAX_BYTES) or + * (olen < plen + maclength) + * + * @param out OUT -- encrypted data + * @param olen IN -- output length in bytes + * @param associated_data IN -- associated data + * @param alen IN -- associated data length in bytes + * @param payload IN -- payload + * @param plen IN -- payload length in bytes + * @param c IN -- CCM state + * + * @note: out buffer should be at least (plen + c->mlen) bytes long. + * + * @note: The sequence b for encryption is formatted as follows: + * b = [FLAGS | nonce | counter ], where: + * FLAGS is 1 byte long + * nonce is 13 bytes long + * counter is 2 bytes long + * The byte FLAGS is composed by the following 8 bits: + * 0-2 bits: used to represent the value of q-1 + * 3-7 btis: always 0's + * + * @note: The sequence b for authentication is formatted as follows: + * b = [FLAGS | nonce | length(mac length)], where: + * FLAGS is 1 byte long + * nonce is 13 bytes long + * length(mac length) is 2 bytes long + * The byte FLAGS is composed by the following 8 bits: + * 0-2 bits: used to represent the value of q-1 + * 3-5 bits: mac length (encoded as: (mlen-2)/2) + * 6: Adata (0 if alen == 0, and 1 otherwise) + * 7: always 0 + */ +int tc_ccm_generation_encryption(uint8_t *out, unsigned int olen, + const uint8_t *associated_data, + unsigned int alen, const uint8_t *payload, + unsigned int plen, TCCcmMode_t c); + +/** + * @brief CCM decryption and tag verification procedure + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: + * out == NULL or + * c == NULL or + * ((plen > 0) and (payload == NULL)) or + * ((alen > 0) and (associated_data == NULL)) or + * (alen >= TC_CCM_AAD_MAX_BYTES) or + * (plen >= TC_CCM_PAYLOAD_MAX_BYTES) or + * (olen < plen - c->mlen) + * + * @param out OUT -- decrypted data + * @param associated_data IN -- associated data + * @param alen IN -- associated data length in bytes + * @param payload IN -- payload + * @param plen IN -- payload length in bytes + * @param c IN -- CCM state + * + * @note: out buffer should be at least (plen - c->mlen) bytes long. + * + * @note: The sequence b for encryption is formatted as follows: + * b = [FLAGS | nonce | counter ], where: + * FLAGS is 1 byte long + * nonce is 13 bytes long + * counter is 2 bytes long + * The byte FLAGS is composed by the following 8 bits: + * 0-2 bits: used to represent the value of q-1 + * 3-7 btis: always 0's + * + * @note: The sequence b for authentication is formatted as follows: + * b = [FLAGS | nonce | length(mac length)], where: + * FLAGS is 1 byte long + * nonce is 13 bytes long + * length(mac length) is 2 bytes long + * The byte FLAGS is composed by the following 8 bits: + * 0-2 bits: used to represent the value of q-1 + * 3-5 bits: mac length (encoded as: (mlen-2)/2) + * 6: Adata (0 if alen == 0, and 1 otherwise) + * 7: always 0 + */ +int tc_ccm_decryption_verification(uint8_t *out, unsigned int olen, + const uint8_t *associated_data, + unsigned int alen, const uint8_t *payload, unsigned int plen, + TCCcmMode_t c); + +#ifdef __cplusplus +} +#endif + +#endif /* __BLE_MESH_TC_CCM_MODE_H__ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/cmac_mode.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/cmac_mode.h new file mode 100644 index 00000000000..cf0b3601b20 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/cmac_mode.h @@ -0,0 +1,194 @@ +/* cmac_mode.h -- interface to a CMAC implementation */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief Interface to a CMAC implementation. + * + * Overview: CMAC is defined NIST in SP 800-38B, and is the standard algorithm + * for computing a MAC using a block cipher. It can compute the MAC + * for a byte string of any length. It is distinguished from CBC-MAC + * in the processing of the final message block; CMAC uses a + * different technique to compute the final message block is full + * size or only partial, while CBC-MAC uses the same technique for + * both. This difference permits CMAC to be applied to variable + * length messages, while all messages authenticated by CBC-MAC must + * be the same length. + * + * Security: AES128-CMAC mode of operation offers 64 bits of security against + * collision attacks. Note however that an external attacker cannot + * generate the tags him/herself without knowing the MAC key. In this + * sense, to attack the collision property of AES128-CMAC, an + * external attacker would need the cooperation of the legal user to + * produce an exponentially high number of tags (e.g. 2^64) to + * finally be able to look for collisions and benefit from them. As + * an extra precaution, the current implementation allows to at most + * 2^48 calls to the tc_cmac_update function before re-calling + * tc_cmac_setup (allowing a new key to be set), as suggested in + * Appendix B of SP 800-38B. + * + * Requires: AES-128 + * + * Usage: This implementation provides a "scatter-gather" interface, so that + * the CMAC value can be computed incrementally over a message + * scattered in different segments throughout memory. Experience shows + * this style of interface tends to minimize the burden of programming + * correctly. Like all symmetric key operations, it is session + * oriented. + * + * To begin a CMAC session, use tc_cmac_setup to initialize a struct + * tc_cmac_struct with encryption key and buffer. Our implementation + * always assume that the AES key to be the same size as the block + * cipher block size. Once setup, this data structure can be used for + * many CMAC computations. + * + * Once the state has been setup with a key, computing the CMAC of + * some data requires three steps: + * + * (1) first use tc_cmac_init to initialize a new CMAC computation. + * (2) next mix all of the data into the CMAC computation state using + * tc_cmac_update. If all of the data resides in a single data + * segment then only one tc_cmac_update call is needed; if data + * is scattered throughout memory in n data segments, then n calls + * will be needed. CMAC IS ORDER SENSITIVE, to be able to detect + * attacks that swap bytes, so the order in which data is mixed + * into the state is critical! + * (3) Once all of the data for a message has been mixed, use + * tc_cmac_final to compute the CMAC tag value. + * + * Steps (1)-(3) can be repeated as many times as you want to CMAC + * multiple messages. A practical limit is 2^48 1K messages before you + * have to change the key. + * + * Once you are done computing CMAC with a key, it is a good idea to + * destroy the state so an attacker cannot recover the key; use + * tc_cmac_erase to accomplish this. + */ + +#ifndef __BLE_MESH_TC_CMAC_MODE_H__ +#define __BLE_MESH_TC_CMAC_MODE_H__ + +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* padding for last message block */ +#define TC_CMAC_PADDING 0x80 + +/* struct tc_cmac_struct represents the state of a CMAC computation */ +typedef struct tc_cmac_struct { + /* initialization vector */ + uint8_t iv[TC_AES_BLOCK_SIZE]; + /* used if message length is a multiple of block_size bytes */ + uint8_t K1[TC_AES_BLOCK_SIZE]; + /* used if message length isn't a multiple block_size bytes */ + uint8_t K2[TC_AES_BLOCK_SIZE]; + /* where to put bytes that didn't fill a block */ + uint8_t leftover[TC_AES_BLOCK_SIZE]; + /* identifies the encryption key */ + unsigned int keyid; + /* next available leftover location */ + unsigned int leftover_offset; + /* AES key schedule */ + TCAesKeySched_t sched; + /* calls to tc_cmac_update left before re-key */ + uint64_t countdown; +} *TCCmacState_t; + +/** + * @brief Configures the CMAC state to use the given AES key + * @return returns TC_CRYPTO_SUCCESS (1) after having configured the CMAC state + * returns TC_CRYPTO_FAIL (0) if: + * s == NULL or + * key == NULL + * + * @param s IN/OUT -- the state to set up + * @param key IN -- the key to use + * @param sched IN -- AES key schedule + */ +int tc_cmac_setup(TCCmacState_t s, const uint8_t *key, + TCAesKeySched_t sched); + +/** + * @brief Erases the CMAC state + * @return returns TC_CRYPTO_SUCCESS (1) after having configured the CMAC state + * returns TC_CRYPTO_FAIL (0) if: + * s == NULL + * + * @param s IN/OUT -- the state to erase + */ +int tc_cmac_erase(TCCmacState_t s); + +/** + * @brief Initializes a new CMAC computation + * @return returns TC_CRYPTO_SUCCESS (1) after having initialized the CMAC state + * returns TC_CRYPTO_FAIL (0) if: + * s == NULL + * + * @param s IN/OUT -- the state to initialize + */ +int tc_cmac_init(TCCmacState_t s); + +/** + * @brief Incrementally computes CMAC over the next data segment + * @return returns TC_CRYPTO_SUCCESS (1) after successfully updating the CMAC state + * returns TC_CRYPTO_FAIL (0) if: + * s == NULL or + * if data == NULL when dlen > 0 + * + * @param s IN/OUT -- the CMAC state + * @param data IN -- the next data segment to MAC + * @param dlen IN -- the length of data in bytes + */ +int tc_cmac_update(TCCmacState_t s, const uint8_t *data, size_t dlen); + +/** + * @brief Generates the tag from the CMAC state + * @return returns TC_CRYPTO_SUCCESS (1) after successfully generating the tag + * returns TC_CRYPTO_FAIL (0) if: + * tag == NULL or + * s == NULL + * + * @param tag OUT -- the CMAC tag + * @param s IN -- CMAC state + */ +int tc_cmac_final(uint8_t *tag, TCCmacState_t s); + +#ifdef __cplusplus +} +#endif + +#endif /* __BLE_MESH_TC_CMAC_MODE_H__ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/constants.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/constants.h new file mode 100644 index 00000000000..0abb01a15a8 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/constants.h @@ -0,0 +1,61 @@ +/* constants.h - TinyCrypt interface to constants */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief -- Interface to constants. + * + */ + +#ifndef __BLE_MESH_TC_CONSTANTS_H__ +#define __BLE_MESH_TC_CONSTANTS_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#ifndef NULL +#define NULL ((void *)0) +#endif + +#define TC_CRYPTO_SUCCESS 1 +#define TC_CRYPTO_FAIL 0 + +#define TC_ZERO_BYTE 0x00 + +#ifdef __cplusplus +} +#endif + +#endif /* __BLE_MESH_TC_CONSTANTS_H__ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ctr_mode.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ctr_mode.h new file mode 100644 index 00000000000..039f58c86c4 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ctr_mode.h @@ -0,0 +1,108 @@ +/* ctr_mode.h - TinyCrypt interface to CTR mode */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief Interface to CTR mode. + * + * Overview: CTR (pronounced "counter") mode is a NIST approved mode of + * operation defined in SP 800-38a. It can be used with any + * block cipher to provide confidentiality of strings of any + * length. TinyCrypt hard codes AES128 as the block cipher. + * + * Security: CTR mode achieves confidentiality only if the counter value is + * never reused with a same encryption key. If the counter is + * repeated, than an adversary might be able to defeat the scheme. + * + * A usual method to ensure different counter values refers to + * initialize the counter in a given value (0, for example) and + * increases it every time a new block is enciphered. This naturally + * leaves to a limitation on the number q of blocks that can be + * enciphered using a same key: q < 2^(counter size). + * + * TinyCrypt uses a counter of 32 bits. This means that after 2^32 + * block encryptions, the counter will be reused (thus losing CBC + * security). 2^32 block encryptions should be enough for most of + * applications targeting constrained devices. Applications intended + * to encrypt a larger number of blocks must replace the key after + * 2^32 block encryptions. + * + * CTR mode provides NO data integrity. + * + * Requires: AES-128 + * + * Usage: 1) call tc_ctr_mode to process the data to encrypt/decrypt. + * + */ + +#ifndef __BLE_MESH_TC_CTR_MODE_H__ +#define __BLE_MESH_TC_CTR_MODE_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief CTR mode encryption/decryption procedure. + * CTR mode encrypts (or decrypts) inlen bytes from in buffer into out buffer + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: + * out == NULL or + * in == NULL or + * ctr == NULL or + * sched == NULL or + * inlen == 0 or + * outlen == 0 or + * inlen != outlen + * @note Assumes:- The current value in ctr has NOT been used with sched + * - out points to inlen bytes + * - in points to inlen bytes + * - ctr is an integer counter in littleEndian format + * - sched was initialized by aes_set_encrypt_key + * @param out OUT -- produced ciphertext (plaintext) + * @param outlen IN -- length of ciphertext buffer in bytes + * @param in IN -- data to encrypt (or decrypt) + * @param inlen IN -- length of input data in bytes + * @param ctr IN/OUT -- the current counter value + * @param sched IN -- an initialized AES key schedule + */ +int tc_ctr_mode(uint8_t *out, unsigned int outlen, const uint8_t *in, + unsigned int inlen, uint8_t *ctr, const TCAesKeySched_t sched); + +#ifdef __cplusplus +} +#endif + +#endif /* __BLE_MESH_TC_CTR_MODE_H__ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ctr_prng.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ctr_prng.h new file mode 100644 index 00000000000..04e070d3ee7 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ctr_prng.h @@ -0,0 +1,166 @@ +/* ctr_prng.h - TinyCrypt interface to a CTR-PRNG implementation */ + +/* + * Copyright (c) 2016, Chris Morrison + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief Interface to a CTR-PRNG implementation. + * + * Overview: A pseudo-random number generator (PRNG) generates a sequence + * of numbers that have a distribution close to the one expected + * for a sequence of truly random numbers. The NIST Special + * Publication 800-90A specifies several mechanisms to generate + * sequences of pseudo random numbers, including the CTR-PRNG one + * which is based on AES. TinyCrypt implements CTR-PRNG with + * AES-128. + * + * Security: A cryptographically secure PRNG depends on the existence of an + * entropy source to provide a truly random seed as well as the + * security of the primitives used as the building blocks (AES-128 + * in this instance). + * + * Requires: - AES-128 + * + * Usage: 1) call tc_ctr_prng_init to seed the prng context + * + * 2) call tc_ctr_prng_reseed to mix in additional entropy into + * the prng context + * + * 3) call tc_ctr_prng_generate to output the pseudo-random data + * + * 4) call tc_ctr_prng_uninstantiate to zero out the prng context + */ + +#ifndef __BLE_MESH_TC_CTR_PRNG_H__ +#define __BLE_MESH_TC_CTR_PRNG_H__ + +#include + +#define TC_CTR_PRNG_RESEED_REQ -1 + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + /* updated each time another BLOCKLEN_BYTES bytes are produced */ + uint8_t V[TC_AES_BLOCK_SIZE]; + + /* updated whenever the PRNG is reseeded */ + struct tc_aes_key_sched_struct key; + + /* number of requests since initialization/reseeding */ + uint64_t reseedCount; +} TCCtrPrng_t; + + +/** + * @brief CTR-PRNG initialization procedure + * Initializes prng context with entropy and personalization string (if any) + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: + * ctx == NULL, + * entropy == NULL, + * entropyLen < (TC_AES_KEY_SIZE + TC_AES_BLOCK_SIZE) + * @note Only the first (TC_AES_KEY_SIZE + TC_AES_BLOCK_SIZE) bytes of + * both the entropy and personalization inputs are used - + * supplying additional bytes has no effect. + * @param ctx IN/OUT -- the PRNG context to initialize + * @param entropy IN -- entropy used to seed the PRNG + * @param entropyLen IN -- entropy length in bytes + * @param personalization IN -- personalization string used to seed the PRNG + * (may be null) + * @param plen IN -- personalization length in bytes + * + */ +int tc_ctr_prng_init(TCCtrPrng_t *const ctx, + uint8_t const *const entropy, + unsigned int entropyLen, + uint8_t const *const personalization, + unsigned int pLen); + +/** + * @brief CTR-PRNG reseed procedure + * Mixes entropy and additional_input into the prng context + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: + * ctx == NULL, + * entropy == NULL, + * entropylen < (TC_AES_KEY_SIZE + TC_AES_BLOCK_SIZE) + * @note It is better to reseed an existing prng context rather than + * re-initialise, so that any existing entropy in the context is + * presereved. This offers some protection against undetected failures + * of the entropy source. + * @note Assumes tc_ctr_prng_init has been called for ctx + * @param ctx IN/OUT -- the PRNG state + * @param entropy IN -- entropy to mix into the prng + * @param entropylen IN -- length of entropy in bytes + * @param additional_input IN -- additional input to the prng (may be null) + * @param additionallen IN -- additional input length in bytes + */ +int tc_ctr_prng_reseed(TCCtrPrng_t *const ctx, + uint8_t const *const entropy, + unsigned int entropyLen, + uint8_t const *const additional_input, + unsigned int additionallen); + +/** + * @brief CTR-PRNG generate procedure + * Generates outlen pseudo-random bytes into out buffer, updates prng + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CTR_PRNG_RESEED_REQ (-1) if a reseed is needed + * returns TC_CRYPTO_FAIL (0) if: + * ctx == NULL, + * out == NULL, + * outlen >= 2^16 + * @note Assumes tc_ctr_prng_init has been called for ctx + * @param ctx IN/OUT -- the PRNG context + * @param additional_input IN -- additional input to the prng (may be null) + * @param additionallen IN -- additional input length in bytes + * @param out IN/OUT -- buffer to receive output + * @param outlen IN -- size of out buffer in bytes + */ +int tc_ctr_prng_generate(TCCtrPrng_t *const ctx, + uint8_t const *const additional_input, + unsigned int additionallen, + uint8_t *const out, + unsigned int outlen); + +/** + * @brief CTR-PRNG uninstantiate procedure + * Zeroes the internal state of the supplied prng context + * @return none + * @param ctx IN/OUT -- the PRNG context + */ +void tc_ctr_prng_uninstantiate(TCCtrPrng_t *const ctx); + +#ifdef __cplusplus +} +#endif + +#endif /* __BLE_MESH_TC_CTR_PRNG_H__ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ecc.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ecc.h new file mode 100644 index 00000000000..72ba652f26d --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ecc.h @@ -0,0 +1,545 @@ +/* ecc.h - TinyCrypt interface to common ECC functions */ + +/* Copyright (c) 2014, Kenneth MacKay + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief -- Interface to common ECC functions. + * + * Overview: This software is an implementation of common functions + * necessary to elliptic curve cryptography. This implementation uses + * curve NIST p-256. + * + * Security: The curve NIST p-256 provides approximately 128 bits of security. + * + */ + +#ifndef __BLE_MESH_TC_UECC_H__ +#define __BLE_MESH_TC_UECC_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Word size (4 bytes considering 32-bits architectures) */ +#define uECC_WORD_SIZE 4 + +/* setting max number of calls to prng: */ +#ifndef uECC_RNG_MAX_TRIES +#define uECC_RNG_MAX_TRIES 64 +#endif + +/* defining data types to store word and bit counts: */ +typedef int8_t wordcount_t; +typedef int16_t bitcount_t; +/* defining data type for comparison result: */ +typedef int8_t cmpresult_t; +/* defining data type to store ECC coordinate/point in 32bits words: */ +typedef unsigned int uECC_word_t; +/* defining data type to store an ECC coordinate/point in 64bits words: */ +typedef uint64_t uECC_dword_t; + +/* defining masks useful for ecc computations: */ +#define HIGH_BIT_SET 0x80000000 +#define uECC_WORD_BITS 32 +#define uECC_WORD_BITS_SHIFT 5 +#define uECC_WORD_BITS_MASK 0x01F + +/* Number of words of 32 bits to represent an element of the the curve p-256: */ +#define NUM_ECC_WORDS 8 +/* Number of bytes to represent an element of the the curve p-256: */ +#define NUM_ECC_BYTES (uECC_WORD_SIZE*NUM_ECC_WORDS) + +/* structure that represents an elliptic curve (e.g. p256):*/ +struct uECC_Curve_t; +typedef const struct uECC_Curve_t *uECC_Curve; +struct uECC_Curve_t { + wordcount_t num_words; + wordcount_t num_bytes; + bitcount_t num_n_bits; + uECC_word_t p[NUM_ECC_WORDS]; + uECC_word_t n[NUM_ECC_WORDS]; + uECC_word_t G[NUM_ECC_WORDS * 2]; + uECC_word_t b[NUM_ECC_WORDS]; + void (*double_jacobian)(uECC_word_t *X1, uECC_word_t *Y1, uECC_word_t *Z1, + uECC_Curve curve); + void (*x_side)(uECC_word_t *result, const uECC_word_t *x, uECC_Curve curve); + void (*mmod_fast)(uECC_word_t *result, uECC_word_t *product); +}; + +/* + * @brief computes doubling of point ion jacobian coordinates, in place. + * @param X1 IN/OUT -- x coordinate + * @param Y1 IN/OUT -- y coordinate + * @param Z1 IN/OUT -- z coordinate + * @param curve IN -- elliptic curve + */ +void double_jacobian_default(uECC_word_t *X1, uECC_word_t *Y1, + uECC_word_t *Z1, uECC_Curve curve); + +/* + * @brief Computes x^3 + ax + b. result must not overlap x. + * @param result OUT -- x^3 + ax + b + * @param x IN -- value of x + * @param curve IN -- elliptic curve + */ +void x_side_default(uECC_word_t *result, const uECC_word_t *x, + uECC_Curve curve); + +/* + * @brief Computes result = product % curve_p + * from http://www.nsa.gov/ia/_files/nist-routines.pdf + * @param result OUT -- product % curve_p + * @param product IN -- value to be reduced mod curve_p + */ +void vli_mmod_fast_secp256r1(unsigned int *result, unsigned int *product); + +/* Bytes to words ordering: */ +#define BYTES_TO_WORDS_8(a, b, c, d, e, f, g, h) 0x##d##c##b##a, 0x##h##g##f##e +#define BYTES_TO_WORDS_4(a, b, c, d) 0x##d##c##b##a +#define BITS_TO_WORDS(num_bits) \ + ((num_bits + ((uECC_WORD_SIZE * 8) - 1)) / (uECC_WORD_SIZE * 8)) +#define BITS_TO_BYTES(num_bits) ((num_bits + 7) / 8) + +/* definition of curve NIST p-256: */ +static const struct uECC_Curve_t curve_secp256r1 = { + NUM_ECC_WORDS, + NUM_ECC_BYTES, + 256, /* num_n_bits */ { + BYTES_TO_WORDS_8(FF, FF, FF, FF, FF, FF, FF, FF), + BYTES_TO_WORDS_8(FF, FF, FF, FF, 00, 00, 00, 00), + BYTES_TO_WORDS_8(00, 00, 00, 00, 00, 00, 00, 00), + BYTES_TO_WORDS_8(01, 00, 00, 00, FF, FF, FF, FF) + }, { + BYTES_TO_WORDS_8(51, 25, 63, FC, C2, CA, B9, F3), + BYTES_TO_WORDS_8(84, 9E, 17, A7, AD, FA, E6, BC), + BYTES_TO_WORDS_8(FF, FF, FF, FF, FF, FF, FF, FF), + BYTES_TO_WORDS_8(00, 00, 00, 00, FF, FF, FF, FF) + }, { + BYTES_TO_WORDS_8(96, C2, 98, D8, 45, 39, A1, F4), + BYTES_TO_WORDS_8(A0, 33, EB, 2D, 81, 7D, 03, 77), + BYTES_TO_WORDS_8(F2, 40, A4, 63, E5, E6, BC, F8), + BYTES_TO_WORDS_8(47, 42, 2C, E1, F2, D1, 17, 6B), + + BYTES_TO_WORDS_8(F5, 51, BF, 37, 68, 40, B6, CB), + BYTES_TO_WORDS_8(CE, 5E, 31, 6B, 57, 33, CE, 2B), + BYTES_TO_WORDS_8(16, 9E, 0F, 7C, 4A, EB, E7, 8E), + BYTES_TO_WORDS_8(9B, 7F, 1A, FE, E2, 42, E3, 4F) + }, { + BYTES_TO_WORDS_8(4B, 60, D2, 27, 3E, 3C, CE, 3B), + BYTES_TO_WORDS_8(F6, B0, 53, CC, B0, 06, 1D, 65), + BYTES_TO_WORDS_8(BC, 86, 98, 76, 55, BD, EB, B3), + BYTES_TO_WORDS_8(E7, 93, 3A, AA, D8, 35, C6, 5A) + }, + &double_jacobian_default, + &x_side_default, + &vli_mmod_fast_secp256r1 +}; + +uECC_Curve uECC_secp256r1(void); + +/* + * @brief Generates a random integer in the range 0 < random < top. + * Both random and top have num_words words. + * @param random OUT -- random integer in the range 0 < random < top + * @param top IN -- upper limit + * @param num_words IN -- number of words + * @return a random integer in the range 0 < random < top + */ +int uECC_generate_random_int(uECC_word_t *random, const uECC_word_t *top, + wordcount_t num_words); + + +/* uECC_RNG_Function type + * The RNG function should fill 'size' random bytes into 'dest'. It should + * return 1 if 'dest' was filled with random data, or 0 if the random data could + * not be generated. The filled-in values should be either truly random, or from + * a cryptographically-secure PRNG. + * + * A correctly functioning RNG function must be set (using uECC_set_rng()) + * before calling uECC_make_key() or uECC_sign(). + * + * Setting a correctly functioning RNG function improves the resistance to + * side-channel attacks for uECC_shared_secret(). + * + * A correct RNG function is set by default. If you are building on another + * POSIX-compliant system that supports /dev/random or /dev/urandom, you can + * define uECC_POSIX to use the predefined RNG. + */ +typedef int(*uECC_RNG_Function)(uint8_t *dest, unsigned int size); + +/* + * @brief Set the function that will be used to generate random bytes. The RNG + * function should return 1 if the random data was generated, or 0 if the random + * data could not be generated. + * + * @note On platforms where there is no predefined RNG function, this must be + * called before uECC_make_key() or uECC_sign() are used. + * + * @param rng_function IN -- function that will be used to generate random bytes + */ +void uECC_set_rng(uECC_RNG_Function rng_function); + +/* + * @brief provides current uECC_RNG_Function. + * @return Returns the function that will be used to generate random bytes. + */ +uECC_RNG_Function uECC_get_rng(void); + +/* + * @brief computes the size of a private key for the curve in bytes. + * @param curve IN -- elliptic curve + * @return size of a private key for the curve in bytes. + */ +int uECC_curve_private_key_size(uECC_Curve curve); + +/* + * @brief computes the size of a public key for the curve in bytes. + * @param curve IN -- elliptic curve + * @return the size of a public key for the curve in bytes. + */ +int uECC_curve_public_key_size(uECC_Curve curve); + +/* + * @brief Compute the corresponding public key for a private key. + * @param private_key IN -- The private key to compute the public key for + * @param public_key OUT -- Will be filled in with the corresponding public key + * @param curve + * @return Returns 1 if key was computed successfully, 0 if an error occurred. + */ +int uECC_compute_public_key(const uint8_t *private_key, + uint8_t *public_key, uECC_Curve curve); + +/* + * @brief Compute public-key. + * @return corresponding public-key. + * @param result OUT -- public-key + * @param private_key IN -- private-key + * @param curve IN -- elliptic curve + */ +uECC_word_t EccPoint_compute_public_key(uECC_word_t *result, + uECC_word_t *private_key, uECC_Curve curve); + +/* + * @brief Regularize the bitcount for the private key so that attackers cannot + * use a side channel attack to learn the number of leading zeros. + * @return Regularized k + * @param k IN -- private-key + * @param k0 IN/OUT -- regularized k + * @param k1 IN/OUT -- regularized k + * @param curve IN -- elliptic curve + */ +uECC_word_t regularize_k(const uECC_word_t *const k, uECC_word_t *k0, + uECC_word_t *k1, uECC_Curve curve); + +/* + * @brief Point multiplication algorithm using Montgomery's ladder with co-Z + * coordinates. See http://eprint.iacr.org/2011/338.pdf. + * @note Result may overlap point. + * @param result OUT -- returns scalar*point + * @param point IN -- elliptic curve point + * @param scalar IN -- scalar + * @param initial_Z IN -- initial value for z + * @param num_bits IN -- number of bits in scalar + * @param curve IN -- elliptic curve + */ +void EccPoint_mult(uECC_word_t *result, const uECC_word_t *point, + const uECC_word_t *scalar, const uECC_word_t *initial_Z, + bitcount_t num_bits, uECC_Curve curve); + +/* + * @brief Constant-time comparison to zero - secure way to compare long integers + * @param vli IN -- very long integer + * @param num_words IN -- number of words in the vli + * @return 1 if vli == 0, 0 otherwise. + */ +uECC_word_t uECC_vli_isZero(const uECC_word_t *vli, wordcount_t num_words); + +/* + * @brief Check if 'point' is the point at infinity + * @param point IN -- elliptic curve point + * @param curve IN -- elliptic curve + * @return if 'point' is the point at infinity, 0 otherwise. + */ +uECC_word_t EccPoint_isZero(const uECC_word_t *point, uECC_Curve curve); + +/* + * @brief computes the sign of left - right, in constant time. + * @param left IN -- left term to be compared + * @param right IN -- right term to be compared + * @param num_words IN -- number of words + * @return the sign of left - right + */ +cmpresult_t uECC_vli_cmp(const uECC_word_t *left, const uECC_word_t *right, + wordcount_t num_words); + +/* + * @brief computes sign of left - right, not in constant time. + * @note should not be used if inputs are part of a secret + * @param left IN -- left term to be compared + * @param right IN -- right term to be compared + * @param num_words IN -- number of words + * @return the sign of left - right + */ +cmpresult_t uECC_vli_cmp_unsafe(const uECC_word_t *left, const uECC_word_t *right, + wordcount_t num_words); + +/* + * @brief Computes result = (left - right) % mod. + * @note Assumes that (left < mod) and (right < mod), and that result does not + * overlap mod. + * @param result OUT -- (left - right) % mod + * @param left IN -- leftright term in modular subtraction + * @param right IN -- right term in modular subtraction + * @param mod IN -- mod + * @param num_words IN -- number of words + */ +void uECC_vli_modSub(uECC_word_t *result, const uECC_word_t *left, + const uECC_word_t *right, const uECC_word_t *mod, + wordcount_t num_words); + +/* + * @brief Computes P' = (x1', y1', Z3), P + Q = (x3, y3, Z3) or + * P => P', Q => P + Q + * @note assumes Input P = (x1, y1, Z), Q = (x2, y2, Z) + * @param X1 IN -- x coordinate of P + * @param Y1 IN -- y coordinate of P + * @param X2 IN -- x coordinate of Q + * @param Y2 IN -- y coordinate of Q + * @param curve IN -- elliptic curve + */ +void XYcZ_add(uECC_word_t *X1, uECC_word_t *Y1, uECC_word_t *X2, + uECC_word_t *Y2, uECC_Curve curve); + +/* + * @brief Computes (x1 * z^2, y1 * z^3) + * @param X1 IN -- previous x1 coordinate + * @param Y1 IN -- previous y1 coordinate + * @param Z IN -- z value + * @param curve IN -- elliptic curve + */ +void apply_z(uECC_word_t *X1, uECC_word_t *Y1, const uECC_word_t *const Z, + uECC_Curve curve); + +/* + * @brief Check if bit is set. + * @return Returns nonzero if bit 'bit' of vli is set. + * @warning It is assumed that the value provided in 'bit' is within the + * boundaries of the word-array 'vli'. + * @note The bit ordering layout assumed for vli is: {31, 30, ..., 0}, + * {63, 62, ..., 32}, {95, 94, ..., 64}, {127, 126,..., 96} for a vli consisting + * of 4 uECC_word_t elements. + */ +uECC_word_t uECC_vli_testBit(const uECC_word_t *vli, bitcount_t bit); + +/* + * @brief Computes result = product % mod, where product is 2N words long. + * @param result OUT -- product % mod + * @param mod IN -- module + * @param num_words IN -- number of words + * @warning Currently only designed to work for curve_p or curve_n. + */ +void uECC_vli_mmod(uECC_word_t *result, uECC_word_t *product, + const uECC_word_t *mod, wordcount_t num_words); + +/* + * @brief Computes modular product (using curve->mmod_fast) + * @param result OUT -- (left * right) mod % curve_p + * @param left IN -- left term in product + * @param right IN -- right term in product + * @param curve IN -- elliptic curve + */ +void uECC_vli_modMult_fast(uECC_word_t *result, const uECC_word_t *left, + const uECC_word_t *right, uECC_Curve curve); + +/* + * @brief Computes result = left - right. + * @note Can modify in place. + * @param result OUT -- left - right + * @param left IN -- left term in subtraction + * @param right IN -- right term in subtraction + * @param num_words IN -- number of words + * @return borrow + */ +uECC_word_t uECC_vli_sub(uECC_word_t *result, const uECC_word_t *left, + const uECC_word_t *right, wordcount_t num_words); + +/* + * @brief Constant-time comparison function(secure way to compare long ints) + * @param left IN -- left term in comparison + * @param right IN -- right term in comparison + * @param num_words IN -- number of words + * @return Returns 0 if left == right, 1 otherwise. + */ +uECC_word_t uECC_vli_equal(const uECC_word_t *left, const uECC_word_t *right, + wordcount_t num_words); + +/* + * @brief Computes (left * right) % mod + * @param result OUT -- (left * right) % mod + * @param left IN -- left term in product + * @param right IN -- right term in product + * @param mod IN -- mod + * @param num_words IN -- number of words + */ +void uECC_vli_modMult(uECC_word_t *result, const uECC_word_t *left, + const uECC_word_t *right, const uECC_word_t *mod, + wordcount_t num_words); + +/* + * @brief Computes (1 / input) % mod + * @note All VLIs are the same size. + * @note See "Euclid's GCD to Montgomery Multiplication to the Great Divide" + * @param result OUT -- (1 / input) % mod + * @param input IN -- value to be modular inverted + * @param mod IN -- mod + * @param num_words -- number of words + */ +void uECC_vli_modInv(uECC_word_t *result, const uECC_word_t *input, + const uECC_word_t *mod, wordcount_t num_words); + +/* + * @brief Sets dest = src. + * @param dest OUT -- destination buffer + * @param src IN -- origin buffer + * @param num_words IN -- number of words + */ +void uECC_vli_set(uECC_word_t *dest, const uECC_word_t *src, + wordcount_t num_words); + +/* + * @brief Computes (left + right) % mod. + * @note Assumes that (left < mod) and right < mod), and that result does not + * overlap mod. + * @param result OUT -- (left + right) % mod. + * @param left IN -- left term in addition + * @param right IN -- right term in addition + * @param mod IN -- mod + * @param num_words IN -- number of words + */ +void uECC_vli_modAdd(uECC_word_t *result, const uECC_word_t *left, + const uECC_word_t *right, const uECC_word_t *mod, + wordcount_t num_words); + +/* + * @brief Counts the number of bits required to represent vli. + * @param vli IN -- very long integer + * @param max_words IN -- number of words + * @return number of bits in given vli + */ +bitcount_t uECC_vli_numBits(const uECC_word_t *vli, + const wordcount_t max_words); + +/* + * @brief Erases (set to 0) vli + * @param vli IN -- very long integer + * @param num_words IN -- number of words + */ +void uECC_vli_clear(uECC_word_t *vli, wordcount_t num_words); + +/* + * @brief check if it is a valid point in the curve + * @param point IN -- point to be checked + * @param curve IN -- elliptic curve + * @return 0 if point is valid + * @exception returns -1 if it is a point at infinity + * @exception returns -2 if x or y is smaller than p, + * @exception returns -3 if y^2 != x^3 + ax + b. + */ +int uECC_valid_point(const uECC_word_t *point, uECC_Curve curve); + +/* + * @brief Check if a public key is valid. + * @param public_key IN -- The public key to be checked. + * @return returns 0 if the public key is valid + * @exception returns -1 if it is a point at infinity + * @exception returns -2 if x or y is smaller than p, + * @exception returns -3 if y^2 != x^3 + ax + b. + * @exception returns -4 if public key is the group generator. + * + * @note Note that you are not required to check for a valid public key before + * using any other uECC functions. However, you may wish to avoid spending CPU + * time computing a shared secret or verifying a signature using an invalid + * public key. + */ +int uECC_valid_public_key(const uint8_t *public_key, uECC_Curve curve); + +/* + * @brief Converts an integer in uECC native format to big-endian bytes. + * @param bytes OUT -- bytes representation + * @param num_bytes IN -- number of bytes + * @param native IN -- uECC native representation + */ +void uECC_vli_nativeToBytes(uint8_t *bytes, int num_bytes, + const unsigned int *native); + +/* + * @brief Converts big-endian bytes to an integer in uECC native format. + * @param native OUT -- uECC native representation + * @param bytes IN -- bytes representation + * @param num_bytes IN -- number of bytes + */ +void uECC_vli_bytesToNative(unsigned int *native, const uint8_t *bytes, + int num_bytes); + +#ifdef __cplusplus +} +#endif + +#endif /* __BLE_MESH_TC_UECC_H__ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ecc_dh.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ecc_dh.h new file mode 100644 index 00000000000..ba9a0ebb2dc --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ecc_dh.h @@ -0,0 +1,131 @@ +/* ecc_dh.h - TinyCrypt interface to EC-DH implementation */ + +/* + * Copyright (c) 2014, Kenneth MacKay + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief -- Interface to EC-DH implementation. + * + * Overview: This software is an implementation of EC-DH. This implementation + * uses curve NIST p-256. + * + * Security: The curve NIST p-256 provides approximately 128 bits of security. + */ + +#ifndef __BLE_MESH_TC_ECC_DH_H__ +#define __BLE_MESH_TC_ECC_DH_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Create a public/private key pair. + * @return returns TC_CRYPTO_SUCCESS (1) if the key pair was generated successfully + * returns TC_CRYPTO_FAIL (0) if error while generating key pair + * + * @param p_public_key OUT -- Will be filled in with the public key. Must be at + * least 2 * the curve size (in bytes) long. For curve secp256r1, p_public_key + * must be 64 bytes long. + * @param p_private_key OUT -- Will be filled in with the private key. Must be as + * long as the curve order (for secp256r1, p_private_key must be 32 bytes long). + * + * @note side-channel countermeasure: algorithm strengthened against timing + * attack. + * @warning A cryptographically-secure PRNG function must be set (using + * uECC_set_rng()) before calling uECC_make_key(). + */ +int uECC_make_key(uint8_t *p_public_key, uint8_t *p_private_key, uECC_Curve curve); + +#ifdef ENABLE_TESTS + +/** + * @brief Create a public/private key pair given a specific d. + * + * @note THIS FUNCTION SHOULD BE CALLED ONLY FOR TEST PURPOSES. Refer to + * uECC_make_key() function for real applications. + */ +int uECC_make_key_with_d(uint8_t *p_public_key, uint8_t *p_private_key, + unsigned int *d, uECC_Curve curve); +#endif + +/** + * @brief Compute a shared secret given your secret key and someone else's + * public key. + * @return returns TC_CRYPTO_SUCCESS (1) if the shared secret was computed successfully + * returns TC_CRYPTO_FAIL (0) otherwise + * + * @param p_secret OUT -- Will be filled in with the shared secret value. Must be + * the same size as the curve size (for curve secp256r1, secret must be 32 bytes + * long. + * @param p_public_key IN -- The public key of the remote party. + * @param p_private_key IN -- Your private key. + * + * @warning It is recommended to use the output of uECC_shared_secret() as the + * input of a recommended Key Derivation Function (see NIST SP 800-108) in + * order to produce a cryptographically secure symmetric key. + */ +int uECC_shared_secret(const uint8_t *p_public_key, const uint8_t *p_private_key, + uint8_t *p_secret, uECC_Curve curve); + +#ifdef __cplusplus +} +#endif + +#endif /* __BLE_MESH_TC_ECC_DH_H__ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ecc_dsa.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ecc_dsa.h new file mode 100644 index 00000000000..cfada859d32 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ecc_dsa.h @@ -0,0 +1,139 @@ +/* ecc_dh.h - TinyCrypt interface to EC-DSA implementation */ + +/* + * Copyright (c) 2014, Kenneth MacKay + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief -- Interface to EC-DSA implementation. + * + * Overview: This software is an implementation of EC-DSA. This implementation + * uses curve NIST p-256. + * + * Security: The curve NIST p-256 provides approximately 128 bits of security. + * + * Usage: - To sign: Compute a hash of the data you wish to sign (SHA-2 is + * recommended) and pass it in to ecdsa_sign function along with your + * private key and a random number. You must use a new non-predictable + * random number to generate each new signature. + * - To verify a signature: Compute the hash of the signed data using + * the same hash as the signer and pass it to this function along with + * the signer's public key and the signature values (r and s). + */ + +#ifndef __BLE_MESH_TC_ECC_DSA_H__ +#define __BLE_MESH_TC_ECC_DSA_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Generate an ECDSA signature for a given hash value. + * @return returns TC_CRYPTO_SUCCESS (1) if the signature generated successfully + * returns TC_CRYPTO_FAIL (0) if an error occurred. + * + * @param p_private_key IN -- Your private key. + * @param p_message_hash IN -- The hash of the message to sign. + * @param p_hash_size IN -- The size of p_message_hash in bytes. + * @param p_signature OUT -- Will be filled in with the signature value. Must be + * at least 2 * curve size long (for secp256r1, signature must be 64 bytes long). + * + * @warning A cryptographically-secure PRNG function must be set (using + * uECC_set_rng()) before calling uECC_sign(). + * @note Usage: Compute a hash of the data you wish to sign (SHA-2 is + * recommended) and pass it in to this function along with your private key. + * @note side-channel countermeasure: algorithm strengthened against timing + * attack. + */ +int uECC_sign(const uint8_t *p_private_key, const uint8_t *p_message_hash, + unsigned p_hash_size, uint8_t *p_signature, uECC_Curve curve); + +#ifdef ENABLE_TESTS +/* + * THIS FUNCTION SHOULD BE CALLED FOR TEST PURPOSES ONLY. + * Refer to uECC_sign() function for real applications. + */ +int uECC_sign_with_k(const uint8_t *private_key, const uint8_t *message_hash, + unsigned int hash_size, uECC_word_t *k, uint8_t *signature, + uECC_Curve curve); +#endif + +/** + * @brief Verify an ECDSA signature. + * @return returns TC_SUCCESS (1) if the signature is valid + * returns TC_FAIL (0) if the signature is invalid. + * + * @param p_public_key IN -- The signer's public key. + * @param p_message_hash IN -- The hash of the signed data. + * @param p_hash_size IN -- The size of p_message_hash in bytes. + * @param p_signature IN -- The signature values. + * + * @note Usage: Compute the hash of the signed data using the same hash as the + * signer and pass it to this function along with the signer's public key and + * the signature values (hash_size and signature). + */ +int uECC_verify(const uint8_t *p_public_key, const uint8_t *p_message_hash, + unsigned int p_hash_size, const uint8_t *p_signature, uECC_Curve curve); + +#ifdef __cplusplus +} +#endif + +#endif /* __BLE_MESH_TC_ECC_DSA_H__ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ecc_platform_specific.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ecc_platform_specific.h new file mode 100644 index 00000000000..972e5f7fee3 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ecc_platform_specific.h @@ -0,0 +1,81 @@ +/* uECC_platform_specific.h - Interface to platform specific functions*/ + +/* Copyright (c) 2014, Kenneth MacKay + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE.*/ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * uECC_platform_specific.h -- Interface to platform specific functions + */ + +#ifndef __BLE_MESH_UECC_PLATFORM_SPECIFIC_H_ +#define __BLE_MESH_UECC_PLATFORM_SPECIFIC_H_ + +/* + * The RNG function should fill 'size' random bytes into 'dest'. It should + * return 1 if 'dest' was filled with random data, or 0 if the random data could + * not be generated. The filled-in values should be either truly random, or from + * a cryptographically-secure PRNG. + * + * A cryptographically-secure PRNG function must be set (using uECC_set_rng()) + * before calling uECC_make_key() or uECC_sign(). + * + * Setting a cryptographically-secure PRNG function improves the resistance to + * side-channel attacks for uECC_shared_secret(). + * + * A correct PRNG function is set by default (default_RNG_defined = 1) and works + * for some platforms, such as Unix and Linux. For other platforms, you may need + * to provide another PRNG function. +*/ +#define default_RNG_defined 0 + +int default_CSPRNG(uint8_t *dest, unsigned int size); + +#endif /* __BLE_MESH_UECC_PLATFORM_SPECIFIC_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/hmac.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/hmac.h new file mode 100644 index 00000000000..cb399d8d5c7 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/hmac.h @@ -0,0 +1,139 @@ +/* hmac.h - TinyCrypt interface to an HMAC implementation */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief Interface to an HMAC implementation. + * + * Overview: HMAC is a message authentication code based on hash functions. + * TinyCrypt hard codes SHA-256 as the hash function. A message + * authentication code based on hash functions is also called a + * keyed cryptographic hash function since it performs a + * transformation specified by a key in an arbitrary length data + * set into a fixed length data set (also called tag). + * + * Security: The security of the HMAC depends on the length of the key and + * on the security of the hash function. Note that HMAC primitives + * are much less affected by collision attacks than their + * corresponding hash functions. + * + * Requires: SHA-256 + * + * Usage: 1) call tc_hmac_set_key to set the HMAC key. + * + * 2) call tc_hmac_init to initialize a struct hash_state before + * processing the data. + * + * 3) call tc_hmac_update to process the next input segment; + * tc_hmac_update can be called as many times as needed to process + * all of the segments of the input; the order is important. + * + * 4) call tc_hmac_final to out put the tag. + */ + +#ifndef __BLE_MESH_TC_HMAC_H__ +#define __BLE_MESH_TC_HMAC_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct tc_hmac_state_struct { + /* the internal state required by h */ + struct tc_sha256_state_struct hash_state; + /* HMAC key schedule */ + uint8_t key[2 * TC_SHA256_BLOCK_SIZE]; +}; +typedef struct tc_hmac_state_struct *TCHmacState_t; + +/** + * @brief HMAC set key procedure + * Configures ctx to use key + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if + * ctx == NULL or + * key == NULL or + * key_size == 0 + * @param ctx IN/OUT -- the struct tc_hmac_state_struct to initial + * @param key IN -- the HMAC key to configure + * @param key_size IN -- the HMAC key size + */ +int tc_hmac_set_key(TCHmacState_t ctx, const uint8_t *key, + unsigned int key_size); + +/** + * @brief HMAC init procedure + * Initializes ctx to begin the next HMAC operation + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: ctx == NULL or key == NULL + * @param ctx IN/OUT -- struct tc_hmac_state_struct buffer to init + */ +int tc_hmac_init(TCHmacState_t ctx); + +/** + * @brief HMAC update procedure + * Mixes data_length bytes addressed by data into state + * @return returns TC_CRYPTO_SUCCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: ctx == NULL or key == NULL + * @note Assumes state has been initialized by tc_hmac_init + * @param ctx IN/OUT -- state of HMAC computation so far + * @param data IN -- data to incorporate into state + * @param data_length IN -- size of data in bytes + */ +int tc_hmac_update(TCHmacState_t ctx, const void *data, + unsigned int data_length); + +/** + * @brief HMAC final procedure + * Writes the HMAC tag into the tag buffer + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: + * tag == NULL or + * ctx == NULL or + * key == NULL or + * taglen != TC_SHA256_DIGEST_SIZE + * @note ctx is erased before exiting. This should never be changed/removed. + * @note Assumes the tag bufer is at least sizeof(hmac_tag_size(state)) bytes + * state has been initialized by tc_hmac_init + * @param tag IN/OUT -- buffer to receive computed HMAC tag + * @param taglen IN -- size of tag in bytes + * @param ctx IN/OUT -- the HMAC state for computing tag + */ +int tc_hmac_final(uint8_t *tag, unsigned int taglen, TCHmacState_t ctx); + +#ifdef __cplusplus +} +#endif + +#endif /*__BLE_MESH_TC_HMAC_H__*/ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/hmac_prng.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/hmac_prng.h new file mode 100644 index 00000000000..f7f90010213 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/hmac_prng.h @@ -0,0 +1,164 @@ +/* hmac_prng.h - TinyCrypt interface to an HMAC-PRNG implementation */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief Interface to an HMAC-PRNG implementation. + * + * Overview: A pseudo-random number generator (PRNG) generates a sequence + * of numbers that have a distribution close to the one expected + * for a sequence of truly random numbers. The NIST Special + * Publication 800-90A specifies several mechanisms to generate + * sequences of pseudo random numbers, including the HMAC-PRNG one + * which is based on HMAC. TinyCrypt implements HMAC-PRNG with + * certain modifications from the NIST SP 800-90A spec. + * + * Security: A cryptographically secure PRNG depends on the existence of an + * entropy source to provide a truly random seed as well as the + * security of the primitives used as the building blocks (HMAC and + * SHA256, for TinyCrypt). + * + * The NIST SP 800-90A standard tolerates a null personalization, + * while TinyCrypt requires a non-null personalization. This is + * because a personalization string (the host name concatenated + * with a time stamp, for example) is easily computed and might be + * the last line of defense against failure of the entropy source. + * + * Requires: - SHA-256 + * - HMAC + * + * Usage: 1) call tc_hmac_prng_init to set the HMAC key and process the + * personalization data. + * + * 2) call tc_hmac_prng_reseed to process the seed and additional + * input. + * + * 3) call tc_hmac_prng_generate to out put the pseudo-random data. + */ + +#ifndef __BLE_MESH_TC_HMAC_PRNG_H__ +#define __BLE_MESH_TC_HMAC_PRNG_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define TC_HMAC_PRNG_RESEED_REQ -1 + +struct tc_hmac_prng_struct { + /* the HMAC instance for this PRNG */ + struct tc_hmac_state_struct h; + /* the PRNG key */ + uint8_t key[TC_SHA256_DIGEST_SIZE]; + /* PRNG state */ + uint8_t v[TC_SHA256_DIGEST_SIZE]; + /* calls to tc_hmac_prng_generate left before re-seed */ + unsigned int countdown; +}; + +typedef struct tc_hmac_prng_struct *TCHmacPrng_t; + +/** + * @brief HMAC-PRNG initialization procedure + * Initializes prng with personalization, disables tc_hmac_prng_generate + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: + * prng == NULL, + * personalization == NULL, + * plen > MAX_PLEN + * @note Assumes: - personalization != NULL. + * The personalization is a platform unique string (e.g., the host + * name) and is the last line of defense against failure of the + * entropy source + * @warning NIST SP 800-90A specifies 3 items as seed material during + * initialization: entropy seed, personalization, and an optional + * nonce. TinyCrypts requires instead a non-null personalization + * (which is easily computed) and indirectly requires an entropy + * seed (since the reseed function is mandatorily called after + * init) + * @param prng IN/OUT -- the PRNG state to initialize + * @param personalization IN -- personalization string + * @param plen IN -- personalization length in bytes + */ +int tc_hmac_prng_init(TCHmacPrng_t prng, + const uint8_t *personalization, + unsigned int plen); + +/** + * @brief HMAC-PRNG reseed procedure + * Mixes seed into prng, enables tc_hmac_prng_generate + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: + * prng == NULL, + * seed == NULL, + * seedlen < MIN_SLEN, + * seendlen > MAX_SLEN, + * additional_input != (const uint8_t *) 0 && additionallen == 0, + * additional_input != (const uint8_t *) 0 && additionallen > MAX_ALEN + * @note Assumes:- tc_hmac_prng_init has been called for prng + * - seed has sufficient entropy. + * + * @param prng IN/OUT -- the PRNG state + * @param seed IN -- entropy to mix into the prng + * @param seedlen IN -- length of seed in bytes + * @param additional_input IN -- additional input to the prng + * @param additionallen IN -- additional input length in bytes + */ +int tc_hmac_prng_reseed(TCHmacPrng_t prng, const uint8_t *seed, + unsigned int seedlen, const uint8_t *additional_input, + unsigned int additionallen); + +/** + * @brief HMAC-PRNG generate procedure + * Generates outlen pseudo-random bytes into out buffer, updates prng + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_HMAC_PRNG_RESEED_REQ (-1) if a reseed is needed + * returns TC_CRYPTO_FAIL (0) if: + * out == NULL, + * prng == NULL, + * outlen == 0, + * outlen >= MAX_OUT + * @note Assumes tc_hmac_prng_init has been called for prng + * @param out IN/OUT -- buffer to receive output + * @param outlen IN -- size of out buffer in bytes + * @param prng IN/OUT -- the PRNG state + */ +int tc_hmac_prng_generate(uint8_t *out, unsigned int outlen, TCHmacPrng_t prng); + +#ifdef __cplusplus +} +#endif + +#endif /* __BLE_MESH_TC_HMAC_PRNG_H__ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/sha256.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/sha256.h new file mode 100644 index 00000000000..c57cb00cad2 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/sha256.h @@ -0,0 +1,129 @@ +/* sha256.h - TinyCrypt interface to a SHA-256 implementation */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief Interface to a SHA-256 implementation. + * + * Overview: SHA-256 is a NIST approved cryptographic hashing algorithm + * specified in FIPS 180. A hash algorithm maps data of arbitrary + * size to data of fixed length. + * + * Security: SHA-256 provides 128 bits of security against collision attacks + * and 256 bits of security against pre-image attacks. SHA-256 does + * NOT behave like a random oracle, but it can be used as one if + * the string being hashed is prefix-free encoded before hashing. + * + * Usage: 1) call tc_sha256_init to initialize a struct + * tc_sha256_state_struct before hashing a new string. + * + * 2) call tc_sha256_update to hash the next string segment; + * tc_sha256_update can be called as many times as needed to hash + * all of the segments of a string; the order is important. + * + * 3) call tc_sha256_final to out put the digest from a hashing + * operation. + */ + +#ifndef __BLE_MESH_TC_SHA256_H__ +#define __BLE_MESH_TC_SHA256_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define TC_SHA256_BLOCK_SIZE (64) +#define TC_SHA256_DIGEST_SIZE (32) +#define TC_SHA256_STATE_BLOCKS (TC_SHA256_DIGEST_SIZE/4) + +struct tc_sha256_state_struct { + unsigned int iv[TC_SHA256_STATE_BLOCKS]; + uint64_t bits_hashed; + uint8_t leftover[TC_SHA256_BLOCK_SIZE]; + size_t leftover_offset; +}; + +typedef struct tc_sha256_state_struct *TCSha256State_t; + +/** + * @brief SHA256 initialization procedure + * Initializes s + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if s == NULL + * @param s Sha256 state struct + */ +int tc_sha256_init(TCSha256State_t s); + +/** + * @brief SHA256 update procedure + * Hashes data_length bytes addressed by data into state s + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: + * s == NULL, + * s->iv == NULL, + * data == NULL + * @note Assumes s has been initialized by tc_sha256_init + * @warning The state buffer 'leftover' is left in memory after processing + * If your application intends to have sensitive data in this + * buffer, remind to erase it after the data has been processed + * @param s Sha256 state struct + * @param data message to hash + * @param datalen length of message to hash + */ +int tc_sha256_update (TCSha256State_t s, const uint8_t *data, size_t datalen); + +/** + * @brief SHA256 final procedure + * Inserts the completed hash computation into digest + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: + * s == NULL, + * s->iv == NULL, + * digest == NULL + * @note Assumes: s has been initialized by tc_sha256_init + * digest points to at least TC_SHA256_DIGEST_SIZE bytes + * @warning The state buffer 'leftover' is left in memory after processing + * If your application intends to have sensitive data in this + * buffer, remind to erase it after the data has been processed + * @param digest unsigned eight bit integer + * @param Sha256 state struct + */ +int tc_sha256_final(uint8_t *digest, TCSha256State_t s); + +#ifdef __cplusplus +} +#endif + +#endif /* __BLE_MESH_TC_SHA256_H__ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/utils.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/utils.h new file mode 100644 index 00000000000..422892390fd --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/utils.h @@ -0,0 +1,121 @@ +/* utils.h - TinyCrypt interface to platform-dependent run-time operations */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief Interface to platform-dependent run-time operations. + * + */ + +#ifndef __BLE_MESH_TC_UTILS_H__ +#define __BLE_MESH_TC_UTILS_H__ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Copy the the buffer 'from' to the buffer 'to'. + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: + * from_len > to_len. + * + * @param to OUT -- destination buffer + * @param to_len IN -- length of destination buffer + * @param from IN -- origin buffer + * @param from_len IN -- length of origin buffer + */ +unsigned int _copy(uint8_t *to, unsigned int to_len, + const uint8_t *from, unsigned int from_len); + +/** + * @brief Set the value 'val' into the buffer 'to', 'len' times. + * + * @param to OUT -- destination buffer + * @param val IN -- value to be set in 'to' + * @param len IN -- number of times the value will be copied + */ +void _set(void *to, uint8_t val, unsigned int len); + +/** + * @brief Set the value 'val' into the buffer 'to', 'len' times, in a way + * which does not risk getting optimized out by the compiler + * In cases where the compiler does not set __GNUC__ and where the + * optimization level removes the memset, it may be necessary to + * implement a _set_secure function and define the + * TINYCRYPT_ARCH_HAS_SET_SECURE, which then can ensure that the + * memset does not get optimized out. + * + * @param to OUT -- destination buffer + * @param val IN -- value to be set in 'to' + * @param len IN -- number of times the value will be copied + */ +#ifdef TINYCRYPT_ARCH_HAS_SET_SECURE +extern void _set_secure(void *to, uint8_t val, unsigned int len); +#else /* ! TINYCRYPT_ARCH_HAS_SET_SECURE */ +static inline void _set_secure(void *to, uint8_t val, unsigned int len) +{ + (void) memset(to, val, len); +#ifdef __GNUC__ + __asm__ __volatile__("" :: "g"(to) : "memory"); +#endif /* __GNUC__ */ +} +#endif /* TINYCRYPT_ARCH_HAS_SET_SECURE */ + +/* + * @brief AES specific doubling function, which utilizes + * the finite field used by AES. + * @return Returns a^2 + * + * @param a IN/OUT -- value to be doubled + */ +uint8_t _double_byte(uint8_t a); + +/* + * @brief Constant-time algorithm to compare if two sequences of bytes are equal + * @return Returns 0 if equal, and non-zero otherwise + * + * @param a IN -- sequence of bytes a + * @param b IN -- sequence of bytes b + * @param size IN -- size of sequences a and b + */ +int _compare(const uint8_t *a, const uint8_t *b, size_t size); + +#ifdef __cplusplus +} +#endif + +#endif /* __BLE_MESH_TC_UTILS_H__ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/access.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/access.h new file mode 100644 index 00000000000..a74e0563920 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/access.h @@ -0,0 +1,80 @@ +/* Bluetooth Mesh */ + +/* + * SPDX-FileCopyrightText: 2017 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _ACCESS_H_ +#define _ACCESS_H_ + +#include "net.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* bt_mesh_model.flags */ +enum { + BLE_MESH_MOD_BIND_PENDING = BIT(0), + BLE_MESH_MOD_SUB_PENDING = BIT(1), + BLE_MESH_MOD_PUB_PENDING = BIT(2), +}; + +void bt_mesh_elem_register(struct bt_mesh_elem *elem, uint8_t count); + +uint8_t bt_mesh_elem_count(void); + +/* Find local element based on unicast or group address */ +struct bt_mesh_elem *bt_mesh_elem_find(uint16_t addr); + +uint16_t *bt_mesh_model_find_group(struct bt_mesh_model *mod, uint16_t addr); + +bool bt_mesh_fixed_group_match(uint16_t addr); + +void bt_mesh_model_foreach(void (*func)(struct bt_mesh_model *mod, + struct bt_mesh_elem *elem, + bool vnd, bool primary, + void *user_data), + void *user_data); + +int32_t bt_mesh_model_pub_period_get(struct bt_mesh_model *mod); + +void bt_mesh_comp_provision(uint16_t addr); +void bt_mesh_comp_unprovision(void); + +uint16_t bt_mesh_primary_addr(void); + +const struct bt_mesh_comp *bt_mesh_comp_get(void); + +struct bt_mesh_model *bt_mesh_model_get(bool vnd, uint8_t elem_idx, uint8_t mod_idx); + +void bt_mesh_model_recv(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf); + +int bt_mesh_comp_register(const struct bt_mesh_comp *comp); +int bt_mesh_comp_deregister(void); + +struct bt_mesh_subnet *bt_mesh_tx_netkey_get(uint8_t role, uint16_t net_idx); + +const uint8_t *bt_mesh_tx_devkey_get(uint8_t role, uint16_t dst); + +struct bt_mesh_app_key *bt_mesh_tx_appkey_get(uint8_t role, uint16_t app_idx); + +size_t bt_mesh_rx_netkey_size(void); + +struct bt_mesh_subnet *bt_mesh_rx_netkey_get(size_t index); + +size_t bt_mesh_rx_devkey_size(void); + +const uint8_t *bt_mesh_rx_devkey_get(size_t index, uint16_t src); + +size_t bt_mesh_rx_appkey_size(void); + +struct bt_mesh_app_key *bt_mesh_rx_appkey_get(size_t index); + +#ifdef __cplusplus +} +#endif + +#endif /* _ACCESS_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/adv.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/adv.h new file mode 100644 index 00000000000..27108c203a0 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/adv.h @@ -0,0 +1,102 @@ +/* Bluetooth Mesh */ + +/* + * SPDX-FileCopyrightText: 2017 Intel Corporation + * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _ADV_H_ +#define _ADV_H_ + +#include "mesh_access.h" +#include "mesh_bearer_adapt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Maximum advertising data payload for a single data type */ +#define BLE_MESH_ADV_DATA_SIZE 29 + +/* The user data is a pointer (4 bytes) to struct bt_mesh_adv */ +#define BLE_MESH_ADV_USER_DATA_SIZE 4 + +#define BLE_MESH_ADV(buf) (*(struct bt_mesh_adv **)net_buf_user_data(buf)) + +typedef struct bt_mesh_msg { + bool relay; /* Flag indicates if the packet is a relayed one */ + void *arg; /* Pointer to the struct net_buf */ + uint16_t src; /* Source address for relay packets */ + uint16_t dst; /* Destination address for relay packets */ + uint32_t timestamp; /* Timestamp recorded when the relay packet is posted to queue */ +} bt_mesh_msg_t; + +enum bt_mesh_adv_type { + BLE_MESH_ADV_PROV, + BLE_MESH_ADV_DATA, + BLE_MESH_ADV_BEACON, + BLE_MESH_ADV_URI, + BLE_MESH_ADV_BLE, +}; + +struct bt_mesh_adv { + const struct bt_mesh_send_cb *cb; + void *cb_data; + + uint8_t type:3, + busy:1; + uint8_t xmit; +}; + +typedef struct bt_mesh_adv *(*bt_mesh_adv_alloc_t)(int id); + +/* xmit_count: Number of retransmissions, i.e. 0 == 1 transmission */ +struct net_buf *bt_mesh_adv_create(enum bt_mesh_adv_type type, uint8_t xmit, + int32_t timeout); + +typedef enum { + BLE_MESH_BUF_REF_EQUAL, + BLE_MESH_BUF_REF_SMALL, + BLE_MESH_BUF_REF_MAX, +} bt_mesh_buf_ref_flag_t; + +void bt_mesh_adv_buf_ref_debug(const char *func, struct net_buf *buf, + uint8_t ref_cmp, bt_mesh_buf_ref_flag_t flag); + +struct net_buf *bt_mesh_adv_create_from_pool(struct net_buf_pool *pool, + bt_mesh_adv_alloc_t get_id, + enum bt_mesh_adv_type type, + uint8_t xmit, int32_t timeout); + +void bt_mesh_unref_buf_from_pool(struct net_buf_pool *pool); + +void bt_mesh_adv_send(struct net_buf *buf, const struct bt_mesh_send_cb *cb, + void *cb_data); + +struct net_buf *bt_mesh_relay_adv_create(enum bt_mesh_adv_type type, uint8_t xmit, + int32_t timeout); + +void bt_mesh_relay_adv_send(struct net_buf *buf, const struct bt_mesh_send_cb *cb, + void *cb_data, uint16_t src, uint16_t dst); + +uint16_t bt_mesh_get_stored_relay_count(void); + +void bt_mesh_adv_update(void); + +void bt_mesh_adv_init(void); +void bt_mesh_adv_deinit(void); + +#if CONFIG_BLE_MESH_SUPPORT_BLE_ADV +int bt_mesh_start_ble_advertising(const struct bt_mesh_ble_adv_param *param, + const struct bt_mesh_ble_adv_data *data, uint8_t *index); + +int bt_mesh_stop_ble_advertising(uint8_t index); +#endif /* CONFIG_BLE_MESH_SUPPORT_BLE_ADV */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ADV_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/beacon.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/beacon.h new file mode 100644 index 00000000000..5e97b4cfe00 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/beacon.h @@ -0,0 +1,35 @@ +/* Bluetooth Mesh */ + +/* + * SPDX-FileCopyrightText: 2017 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _BEACON_H_ +#define _BEACON_H_ + +#include "net.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void bt_mesh_beacon_enable(void); +void bt_mesh_beacon_disable(void); + +void bt_mesh_beacon_ivu_initiator(bool enable); + +void bt_mesh_beacon_recv(struct net_buf_simple *buf, int8_t rssi); + +void bt_mesh_beacon_create(struct bt_mesh_subnet *sub, + struct net_buf_simple *buf); + +void bt_mesh_beacon_init(void); +void bt_mesh_beacon_deinit(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _BEACON_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/crypto.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/crypto.h new file mode 100644 index 00000000000..e8b3450728c --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/crypto.h @@ -0,0 +1,174 @@ +/* Bluetooth Mesh */ + +/* + * SPDX-FileCopyrightText: 2017 Intel Corporation + * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _CRYPTO_H_ +#define _CRYPTO_H_ + +#include +#include "mesh_buf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct bt_mesh_sg { + const void *data; + size_t len; +}; + +int bt_mesh_aes_cmac(const uint8_t key[16], struct bt_mesh_sg *sg, + size_t sg_len, uint8_t mac[16]); + +static inline int bt_mesh_aes_cmac_one(const uint8_t key[16], const void *m, + size_t len, uint8_t mac[16]) +{ + struct bt_mesh_sg sg = { m, len }; + + return bt_mesh_aes_cmac(key, &sg, 1, mac); +} + +static inline bool bt_mesh_s1(const char *m, uint8_t salt[16]) +{ + const uint8_t zero[16] = { 0 }; + + return bt_mesh_aes_cmac_one(zero, m, strlen(m), salt); +} + +int bt_mesh_k1(const uint8_t *ikm, size_t ikm_len, const uint8_t salt[16], + const char *info, uint8_t okm[16]); + +#define bt_mesh_k1_str(ikm, ikm_len, salt_str, info, okm) \ +({ \ + const uint8_t salt[16] = salt_str; \ + bt_mesh_k1(ikm, ikm_len, salt, info, okm); \ +}) + +int bt_mesh_k2(const uint8_t n[16], const uint8_t *p, size_t p_len, + uint8_t net_id[1], uint8_t enc_key[16], uint8_t priv_key[16]); + +int bt_mesh_k3(const uint8_t n[16], uint8_t out[8]); + +int bt_mesh_k4(const uint8_t n[16], uint8_t out[1]); + +int bt_mesh_id128(const uint8_t n[16], const char *s, uint8_t out[16]); + +static inline int bt_mesh_id_resolving_key(const uint8_t net_key[16], + uint8_t resolving_key[16]) +{ + return bt_mesh_k1_str(net_key, 16, "smbt", "smbi", resolving_key); +} + +static inline int bt_mesh_identity_key(const uint8_t net_key[16], + uint8_t identity_key[16]) +{ + return bt_mesh_id128(net_key, "nkik", identity_key); +} + +static inline int bt_mesh_beacon_key(const uint8_t net_key[16], + uint8_t beacon_key[16]) +{ + return bt_mesh_id128(net_key, "nkbk", beacon_key); +} + +int bt_mesh_beacon_auth(const uint8_t beacon_key[16], uint8_t flags, + const uint8_t net_id[16], uint32_t iv_index, + uint8_t auth[8]); + +static inline int bt_mesh_app_id(const uint8_t app_key[16], uint8_t app_id[1]) +{ + return bt_mesh_k4(app_key, app_id); +} + +static inline int bt_mesh_session_key(const uint8_t dhkey[32], + const uint8_t prov_salt[16], + uint8_t session_key[16]) +{ + return bt_mesh_k1(dhkey, 32, prov_salt, "prsk", session_key); +} + +static inline int bt_mesh_prov_nonce(const uint8_t dhkey[32], + const uint8_t prov_salt[16], + uint8_t nonce[13]) +{ + uint8_t tmp[16]; + int err; + + err = bt_mesh_k1(dhkey, 32, prov_salt, "prsn", tmp); + if (!err) { + memcpy(nonce, tmp + 3, 13); + } + + return err; +} + +static inline int bt_mesh_dev_key(const uint8_t dhkey[32], + const uint8_t prov_salt[16], + uint8_t dev_key[16]) +{ + return bt_mesh_k1(dhkey, 32, prov_salt, "prdk", dev_key); +} + +static inline int bt_mesh_prov_salt(const uint8_t conf_salt[16], + const uint8_t prov_rand[16], + const uint8_t dev_rand[16], + uint8_t prov_salt[16]) +{ + const uint8_t prov_salt_key[16] = { 0 }; + struct bt_mesh_sg sg[] = { + { conf_salt, 16 }, + { prov_rand, 16 }, + { dev_rand, 16 }, + }; + + return bt_mesh_aes_cmac(prov_salt_key, sg, ARRAY_SIZE(sg), prov_salt); +} + +int bt_mesh_net_obfuscate(uint8_t *pdu, uint32_t iv_index, + const uint8_t privacy_key[16]); + +int bt_mesh_net_encrypt(const uint8_t key[16], struct net_buf_simple *buf, + uint32_t iv_index, bool proxy); + +int bt_mesh_net_decrypt(const uint8_t key[16], struct net_buf_simple *buf, + uint32_t iv_index, bool proxy); + +int bt_mesh_app_encrypt(const uint8_t key[16], bool dev_key, uint8_t aszmic, + struct net_buf_simple *buf, const uint8_t *ad, + uint16_t src, uint16_t dst, uint32_t seq_num, uint32_t iv_index); + +int bt_mesh_app_decrypt(const uint8_t key[16], bool dev_key, uint8_t aszmic, + struct net_buf_simple *buf, struct net_buf_simple *out, + const uint8_t *ad, uint16_t src, uint16_t dst, uint32_t seq_num, + uint32_t iv_index); + +uint8_t bt_mesh_fcs_calc(const uint8_t *data, uint8_t data_len); + +bool bt_mesh_fcs_check(struct net_buf_simple *buf, uint8_t received_fcs); + +int bt_mesh_virtual_addr(const uint8_t virtual_label[16], uint16_t *addr); + +int bt_mesh_prov_conf_salt(const uint8_t conf_inputs[145], uint8_t salt[16]); + +int bt_mesh_prov_conf_key(const uint8_t dhkey[32], const uint8_t conf_salt[16], + uint8_t conf_key[16]); + +int bt_mesh_prov_conf(const uint8_t conf_key[16], const uint8_t rand[16], + const uint8_t auth[16], uint8_t conf[16]); + +int bt_mesh_prov_decrypt(const uint8_t key[16], uint8_t nonce[13], + const uint8_t data[25 + 8], uint8_t out[25]); + +int bt_mesh_prov_encrypt(const uint8_t key[16], uint8_t nonce[13], + const uint8_t data[25], uint8_t out[33]); + +#ifdef __cplusplus +} +#endif + +#endif /* _CRYPTO_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/fast_prov.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/fast_prov.h new file mode 100644 index 00000000000..69bea4402f4 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/fast_prov.h @@ -0,0 +1,36 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _FAST_PROV_H_ +#define _FAST_PROV_H_ + +#include "net.h" + +#ifdef __cplusplus +extern "C" { +#endif + +const uint8_t *bt_mesh_fast_prov_dev_key_get(uint16_t dst); + +struct bt_mesh_subnet *bt_mesh_fast_prov_subnet_get(uint16_t net_idx); + +struct bt_mesh_app_key *bt_mesh_fast_prov_app_key_find(uint16_t app_idx); + +uint8_t bt_mesh_set_fast_prov_net_idx(uint16_t net_idx); + +uint8_t bt_mesh_fast_prov_net_key_add(const uint8_t net_key[16]); + +const uint8_t *bt_mesh_fast_prov_net_key_get(uint16_t net_idx); + +const uint8_t *bt_mesh_get_fast_prov_app_key(uint16_t net_idx, uint16_t app_idx); + +uint8_t bt_mesh_set_fast_prov_action(uint8_t action); + +#ifdef __cplusplus +} +#endif + +#endif /* _FAST_PROV_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/foundation.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/foundation.h new file mode 100644 index 00000000000..3855d93fb6f --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/foundation.h @@ -0,0 +1,183 @@ +/* Bluetooth Mesh */ + +/* + * SPDX-FileCopyrightText: 2017 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ +#ifndef _FOUNDATION_H_ +#define _FOUNDATION_H_ + +#include "mesh_byteorder.h" +#include "net.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define OP_APP_KEY_ADD BLE_MESH_MODEL_OP_1(0x00) +#define OP_APP_KEY_UPDATE BLE_MESH_MODEL_OP_1(0x01) +#define OP_DEV_COMP_DATA_STATUS BLE_MESH_MODEL_OP_1(0x02) +#define OP_MOD_PUB_SET BLE_MESH_MODEL_OP_1(0x03) +#define OP_HEALTH_CURRENT_STATUS BLE_MESH_MODEL_OP_1(0x04) +#define OP_HEALTH_FAULT_STATUS BLE_MESH_MODEL_OP_1(0x05) +#define OP_HEARTBEAT_PUB_STATUS BLE_MESH_MODEL_OP_1(0x06) +#define OP_APP_KEY_DEL BLE_MESH_MODEL_OP_2(0x80, 0x00) +#define OP_APP_KEY_GET BLE_MESH_MODEL_OP_2(0x80, 0x01) +#define OP_APP_KEY_LIST BLE_MESH_MODEL_OP_2(0x80, 0x02) +#define OP_APP_KEY_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x03) +#define OP_ATTENTION_GET BLE_MESH_MODEL_OP_2(0x80, 0x04) +#define OP_ATTENTION_SET BLE_MESH_MODEL_OP_2(0x80, 0x05) +#define OP_ATTENTION_SET_UNREL BLE_MESH_MODEL_OP_2(0x80, 0x06) +#define OP_ATTENTION_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x07) +#define OP_DEV_COMP_DATA_GET BLE_MESH_MODEL_OP_2(0x80, 0x08) +#define OP_BEACON_GET BLE_MESH_MODEL_OP_2(0x80, 0x09) +#define OP_BEACON_SET BLE_MESH_MODEL_OP_2(0x80, 0x0a) +#define OP_BEACON_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x0b) +#define OP_DEFAULT_TTL_GET BLE_MESH_MODEL_OP_2(0x80, 0x0c) +#define OP_DEFAULT_TTL_SET BLE_MESH_MODEL_OP_2(0x80, 0x0d) +#define OP_DEFAULT_TTL_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x0e) +#define OP_FRIEND_GET BLE_MESH_MODEL_OP_2(0x80, 0x0f) +#define OP_FRIEND_SET BLE_MESH_MODEL_OP_2(0x80, 0x10) +#define OP_FRIEND_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x11) +#define OP_GATT_PROXY_GET BLE_MESH_MODEL_OP_2(0x80, 0x12) +#define OP_GATT_PROXY_SET BLE_MESH_MODEL_OP_2(0x80, 0x13) +#define OP_GATT_PROXY_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x14) +#define OP_KRP_GET BLE_MESH_MODEL_OP_2(0x80, 0x15) +#define OP_KRP_SET BLE_MESH_MODEL_OP_2(0x80, 0x16) +#define OP_KRP_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x17) +#define OP_MOD_PUB_GET BLE_MESH_MODEL_OP_2(0x80, 0x18) +#define OP_MOD_PUB_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x19) +#define OP_MOD_PUB_VA_SET BLE_MESH_MODEL_OP_2(0x80, 0x1a) +#define OP_MOD_SUB_ADD BLE_MESH_MODEL_OP_2(0x80, 0x1b) +#define OP_MOD_SUB_DEL BLE_MESH_MODEL_OP_2(0x80, 0x1c) +#define OP_MOD_SUB_DEL_ALL BLE_MESH_MODEL_OP_2(0x80, 0x1d) +#define OP_MOD_SUB_OVERWRITE BLE_MESH_MODEL_OP_2(0x80, 0x1e) +#define OP_MOD_SUB_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x1f) +#define OP_MOD_SUB_VA_ADD BLE_MESH_MODEL_OP_2(0x80, 0x20) +#define OP_MOD_SUB_VA_DEL BLE_MESH_MODEL_OP_2(0x80, 0x21) +#define OP_MOD_SUB_VA_OVERWRITE BLE_MESH_MODEL_OP_2(0x80, 0x22) +#define OP_NET_TRANSMIT_GET BLE_MESH_MODEL_OP_2(0x80, 0x23) +#define OP_NET_TRANSMIT_SET BLE_MESH_MODEL_OP_2(0x80, 0x24) +#define OP_NET_TRANSMIT_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x25) +#define OP_RELAY_GET BLE_MESH_MODEL_OP_2(0x80, 0x26) +#define OP_RELAY_SET BLE_MESH_MODEL_OP_2(0x80, 0x27) +#define OP_RELAY_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x28) +#define OP_MOD_SUB_GET BLE_MESH_MODEL_OP_2(0x80, 0x29) +#define OP_MOD_SUB_LIST BLE_MESH_MODEL_OP_2(0x80, 0x2a) +#define OP_MOD_SUB_GET_VND BLE_MESH_MODEL_OP_2(0x80, 0x2b) +#define OP_MOD_SUB_LIST_VND BLE_MESH_MODEL_OP_2(0x80, 0x2c) +#define OP_LPN_TIMEOUT_GET BLE_MESH_MODEL_OP_2(0x80, 0x2d) +#define OP_LPN_TIMEOUT_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x2e) +#define OP_HEALTH_FAULT_CLEAR BLE_MESH_MODEL_OP_2(0x80, 0x2f) +#define OP_HEALTH_FAULT_CLEAR_UNREL BLE_MESH_MODEL_OP_2(0x80, 0x30) +#define OP_HEALTH_FAULT_GET BLE_MESH_MODEL_OP_2(0x80, 0x31) +#define OP_HEALTH_FAULT_TEST BLE_MESH_MODEL_OP_2(0x80, 0x32) +#define OP_HEALTH_FAULT_TEST_UNREL BLE_MESH_MODEL_OP_2(0x80, 0x33) +#define OP_HEALTH_PERIOD_GET BLE_MESH_MODEL_OP_2(0x80, 0x34) +#define OP_HEALTH_PERIOD_SET BLE_MESH_MODEL_OP_2(0x80, 0x35) +#define OP_HEALTH_PERIOD_SET_UNREL BLE_MESH_MODEL_OP_2(0x80, 0x36) +#define OP_HEALTH_PERIOD_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x37) +#define OP_HEARTBEAT_PUB_GET BLE_MESH_MODEL_OP_2(0x80, 0x38) +#define OP_HEARTBEAT_PUB_SET BLE_MESH_MODEL_OP_2(0x80, 0x39) +#define OP_HEARTBEAT_SUB_GET BLE_MESH_MODEL_OP_2(0x80, 0x3a) +#define OP_HEARTBEAT_SUB_SET BLE_MESH_MODEL_OP_2(0x80, 0x3b) +#define OP_HEARTBEAT_SUB_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x3c) +#define OP_MOD_APP_BIND BLE_MESH_MODEL_OP_2(0x80, 0x3d) +#define OP_MOD_APP_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x3e) +#define OP_MOD_APP_UNBIND BLE_MESH_MODEL_OP_2(0x80, 0x3f) +#define OP_NET_KEY_ADD BLE_MESH_MODEL_OP_2(0x80, 0x40) +#define OP_NET_KEY_DEL BLE_MESH_MODEL_OP_2(0x80, 0x41) +#define OP_NET_KEY_GET BLE_MESH_MODEL_OP_2(0x80, 0x42) +#define OP_NET_KEY_LIST BLE_MESH_MODEL_OP_2(0x80, 0x43) +#define OP_NET_KEY_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x44) +#define OP_NET_KEY_UPDATE BLE_MESH_MODEL_OP_2(0x80, 0x45) +#define OP_NODE_IDENTITY_GET BLE_MESH_MODEL_OP_2(0x80, 0x46) +#define OP_NODE_IDENTITY_SET BLE_MESH_MODEL_OP_2(0x80, 0x47) +#define OP_NODE_IDENTITY_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x48) +#define OP_NODE_RESET BLE_MESH_MODEL_OP_2(0x80, 0x49) +#define OP_NODE_RESET_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x4a) +#define OP_SIG_MOD_APP_GET BLE_MESH_MODEL_OP_2(0x80, 0x4b) +#define OP_SIG_MOD_APP_LIST BLE_MESH_MODEL_OP_2(0x80, 0x4c) +#define OP_VND_MOD_APP_GET BLE_MESH_MODEL_OP_2(0x80, 0x4d) +#define OP_VND_MOD_APP_LIST BLE_MESH_MODEL_OP_2(0x80, 0x4e) + +#define STATUS_SUCCESS 0x00 +#define STATUS_INVALID_ADDRESS 0x01 +#define STATUS_INVALID_MODEL 0x02 +#define STATUS_INVALID_APPKEY 0x03 +#define STATUS_INVALID_NETKEY 0x04 +#define STATUS_INSUFF_RESOURCES 0x05 +#define STATUS_IDX_ALREADY_STORED 0x06 +#define STATUS_NVAL_PUB_PARAM 0x07 +#define STATUS_NOT_SUB_MOD 0x08 +#define STATUS_STORAGE_FAIL 0x09 +#define STATUS_FEAT_NOT_SUPP 0x0a +#define STATUS_CANNOT_UPDATE 0x0b +#define STATUS_CANNOT_REMOVE 0x0c +#define STATUS_CANNOT_BIND 0x0d +#define STATUS_TEMP_STATE_CHG_FAIL 0x0e +#define STATUS_CANNOT_SET 0x0f +#define STATUS_UNSPECIFIED 0x10 +#define STATUS_INVALID_BINDING 0x11 + +enum { + BLE_MESH_VA_CHANGED, /* Label information changed */ +}; + +struct label { + uint16_t ref; + uint16_t addr; + uint8_t uuid[16]; + bt_mesh_atomic_t flags[1]; +}; + +void bt_mesh_mod_sub_reset(bool store); + +void bt_mesh_cfg_reset(bool store); + +void bt_mesh_heartbeat(uint16_t src, uint16_t dst, uint8_t hops, uint16_t feat); + +void bt_mesh_attention(struct bt_mesh_model *model, uint8_t time); + +struct label *get_label(uint16_t index); + +uint8_t *bt_mesh_label_uuid_get(uint16_t addr); + +struct bt_mesh_hb_pub *bt_mesh_hb_pub_get(void); +void bt_mesh_hb_pub_disable(void); +struct bt_mesh_cfg_srv *bt_mesh_cfg_get(void); + +uint8_t bt_mesh_net_transmit_get(void); +uint8_t bt_mesh_relay_get(void); +uint8_t bt_mesh_friend_get(void); +uint8_t bt_mesh_relay_retransmit_get(void); +uint8_t bt_mesh_beacon_get(void); +uint8_t bt_mesh_gatt_proxy_get(void); +uint8_t bt_mesh_default_ttl_get(void); + +void bt_mesh_subnet_del(struct bt_mesh_subnet *sub, bool store); + +struct bt_mesh_app_key *bt_mesh_app_key_alloc(uint16_t app_idx); +void bt_mesh_app_key_del(struct bt_mesh_app_key *key, bool store); + +static inline void key_idx_pack(struct net_buf_simple *buf, + uint16_t idx1, uint16_t idx2) +{ + net_buf_simple_add_le16(buf, idx1 | ((idx2 & 0x00f) << 12)); + net_buf_simple_add_u8(buf, idx2 >> 4); +} + +static inline void key_idx_unpack(struct net_buf_simple *buf, + uint16_t *idx1, uint16_t *idx2) +{ + *idx1 = sys_get_le16(&buf->data[0]) & 0xfff; + *idx2 = sys_get_le16(&buf->data[1]) >> 4; + net_buf_simple_pull(buf, 3); +} + +#ifdef __cplusplus +} +#endif + +#endif /* _FOUNDATION_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/friend.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/friend.h new file mode 100644 index 00000000000..2855081bf57 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/friend.h @@ -0,0 +1,67 @@ +/* Bluetooth Mesh */ + +/* + * SPDX-FileCopyrightText: 2017 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _FRIEND_H_ +#define _FRIEND_H_ + +#include "net.h" + +#ifdef __cplusplus +extern "C" { +#endif + +enum bt_mesh_friend_pdu_type { + BLE_MESH_FRIEND_PDU_SINGLE, + BLE_MESH_FRIEND_PDU_PARTIAL, + BLE_MESH_FRIEND_PDU_COMPLETE, +}; + +bool bt_mesh_friend_match(uint16_t net_idx, uint16_t addr); + +struct bt_mesh_friend *bt_mesh_friend_find(uint16_t net_idx, uint16_t lpn_addr, + bool valid, bool established); + +bool bt_mesh_friend_queue_has_space(uint16_t net_idx, uint16_t src, uint16_t dst, + const uint64_t *seq_auth, uint8_t seg_count); + +void bt_mesh_friend_enqueue_rx(struct bt_mesh_net_rx *rx, + enum bt_mesh_friend_pdu_type type, + const uint64_t *seq_auth, uint8_t seg_count, + struct net_buf_simple *sbuf); +bool bt_mesh_friend_enqueue_tx(struct bt_mesh_net_tx *tx, + enum bt_mesh_friend_pdu_type type, + const uint64_t *seq_auth, uint8_t seg_count, + struct net_buf_simple *sbuf); + +void bt_mesh_friend_clear_incomplete(struct bt_mesh_subnet *sub, uint16_t src, + uint16_t dst, const uint64_t *seq_auth); + +void bt_mesh_friend_sec_update(uint16_t net_idx); + +void bt_mesh_friend_clear_net_idx(uint16_t net_idx); + +int bt_mesh_friend_poll(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf); +int bt_mesh_friend_req(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf); +int bt_mesh_friend_clear(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf); +int bt_mesh_friend_clear_cfm(struct bt_mesh_net_rx *rx, + struct net_buf_simple *buf); +int bt_mesh_friend_sub_add(struct bt_mesh_net_rx *rx, + struct net_buf_simple *buf); +int bt_mesh_friend_sub_rem(struct bt_mesh_net_rx *rx, + struct net_buf_simple *buf); + +int bt_mesh_friend_init(void); +int bt_mesh_friend_deinit(void); + +void bt_mesh_friend_remove_lpn(uint16_t lpn_addr); + +#ifdef __cplusplus +} +#endif + +#endif /* _FRIEND_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/include/cfg_cli.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/include/cfg_cli.h new file mode 100644 index 00000000000..02ff566dd92 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/include/cfg_cli.h @@ -0,0 +1,318 @@ +/** @file + * @brief Bluetooth Mesh Configuration Client Model APIs. + */ + +/* + * SPDX-FileCopyrightText: 2017 Intel Corporation + * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#ifndef _BLE_MESH_CFG_CLI_H_ +#define _BLE_MESH_CFG_CLI_H_ + +#include "client_common.h" + +/** + * @brief Bluetooth Mesh + * @defgroup bt_mesh_cfg_cli Bluetooth Mesh Configuration Client Model + * @ingroup bt_mesh + * @{ + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Config client model common structure */ +typedef bt_mesh_client_user_data_t bt_mesh_config_client_t; +typedef bt_mesh_client_internal_data_t config_internal_data_t; + +extern const struct bt_mesh_model_op bt_mesh_cfg_cli_op[]; +extern const struct bt_mesh_model_cb bt_mesh_cfg_cli_cb; + +#define BLE_MESH_MODEL_CFG_CLI(cli_data) \ + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_CFG_CLI, \ + bt_mesh_cfg_cli_op, NULL, cli_data, &bt_mesh_cfg_cli_cb) + +int bt_mesh_cfg_comp_data_get(bt_mesh_client_common_param_t *param, uint8_t page); + +int bt_mesh_cfg_beacon_get(bt_mesh_client_common_param_t *param); + +int bt_mesh_cfg_beacon_set(bt_mesh_client_common_param_t *param, uint8_t val); + +int bt_mesh_cfg_ttl_get(bt_mesh_client_common_param_t *param); + +int bt_mesh_cfg_ttl_set(bt_mesh_client_common_param_t *param, uint8_t val); + +int bt_mesh_cfg_friend_get(bt_mesh_client_common_param_t *param); + +int bt_mesh_cfg_friend_set(bt_mesh_client_common_param_t *param, uint8_t val); + +int bt_mesh_cfg_gatt_proxy_get(bt_mesh_client_common_param_t *param); + +int bt_mesh_cfg_gatt_proxy_set(bt_mesh_client_common_param_t *param, uint8_t val); + +int bt_mesh_cfg_relay_get(bt_mesh_client_common_param_t *param); + +int bt_mesh_cfg_relay_set(bt_mesh_client_common_param_t *param, + uint8_t relay, uint8_t retransmit); + +int bt_mesh_cfg_net_key_add(bt_mesh_client_common_param_t *param, + uint16_t net_idx, const uint8_t net_key[16]); + +int bt_mesh_cfg_app_key_add(bt_mesh_client_common_param_t *param, + uint16_t net_idx, uint16_t app_idx, + const uint8_t app_key[16]); + +int bt_mesh_cfg_mod_app_bind(bt_mesh_client_common_param_t *param, + uint16_t elem_addr, uint16_t app_idx, + uint16_t mod_id, uint16_t cid); + +struct bt_mesh_cfg_mod_pub { + uint16_t addr; + uint16_t app_idx; + bool cred_flag; + uint8_t ttl; + uint8_t period; + uint8_t transmit; +}; + +int bt_mesh_cfg_mod_pub_get(bt_mesh_client_common_param_t *param, + uint16_t elem_addr, uint16_t mod_id, uint16_t cid); + +int bt_mesh_cfg_mod_pub_set(bt_mesh_client_common_param_t *param, + uint16_t elem_addr, uint16_t mod_id, uint16_t cid, + struct bt_mesh_cfg_mod_pub *pub); + +int bt_mesh_cfg_mod_sub_add(bt_mesh_client_common_param_t *param, + uint16_t elem_addr, uint16_t sub_addr, + uint16_t mod_id, uint16_t cid); + +int bt_mesh_cfg_mod_sub_del(bt_mesh_client_common_param_t *param, + uint16_t elem_addr, uint16_t sub_addr, + uint16_t mod_id, uint16_t cid); + +int bt_mesh_cfg_mod_sub_overwrite(bt_mesh_client_common_param_t *param, + uint16_t elem_addr, uint16_t sub_addr, + uint16_t mod_id, uint16_t cid); + +int bt_mesh_cfg_mod_sub_va_add(bt_mesh_client_common_param_t *param, + uint16_t elem_addr, const uint8_t label[16], + uint16_t mod_id, uint16_t cid); + +int bt_mesh_cfg_mod_sub_va_del(bt_mesh_client_common_param_t *param, + uint16_t elem_addr, const uint8_t label[16], + uint16_t mod_id, uint16_t cid); + +int bt_mesh_cfg_mod_sub_va_overwrite(bt_mesh_client_common_param_t *param, + uint16_t elem_addr, const uint8_t label[16], + uint16_t mod_id, uint16_t cid); + +struct bt_mesh_cfg_hb_sub { + uint16_t src; + uint16_t dst; + uint8_t period; +}; + +int bt_mesh_cfg_hb_sub_set(bt_mesh_client_common_param_t *param, + struct bt_mesh_cfg_hb_sub *sub); + +int bt_mesh_cfg_hb_sub_get(bt_mesh_client_common_param_t *param); + +struct bt_mesh_cfg_hb_pub { + uint16_t dst; + uint8_t count; + uint8_t period; + uint8_t ttl; + uint16_t feat; + uint16_t net_idx; +}; + +int bt_mesh_cfg_hb_pub_set(bt_mesh_client_common_param_t *param, + struct bt_mesh_cfg_hb_pub *pub); + +int bt_mesh_cfg_hb_pub_get(bt_mesh_client_common_param_t *param); + +int bt_mesh_cfg_node_reset(bt_mesh_client_common_param_t *param); + +/* Configuration Client Status Message Context */ + +struct bt_mesh_cfg_comp_data_status { + uint8_t page; + struct net_buf_simple *comp_data; +}; + +struct bt_mesh_cfg_relay_status { + uint8_t relay; + uint8_t retransmit; +}; + +struct bt_mesh_cfg_netkey_status { + uint8_t status; + uint16_t net_idx; +}; + +struct bt_mesh_cfg_appkey_status { + uint8_t status; + uint16_t net_idx; + uint16_t app_idx; +}; + +struct bt_mesh_cfg_mod_app_status { + uint8_t status; + uint16_t elem_addr; + uint16_t app_idx; + uint16_t cid; + uint16_t mod_id; +}; + +struct bt_mesh_cfg_mod_pub_status { + uint8_t status; + uint16_t elem_addr; + uint16_t addr; + uint16_t app_idx; + bool cred_flag; + uint8_t ttl; + uint8_t period; + uint8_t transmit; + uint16_t cid; + uint16_t mod_id; +}; + +struct bt_mesh_cfg_mod_sub_status { + uint8_t status; + uint16_t elem_addr; + uint16_t sub_addr; + uint16_t cid; + uint16_t mod_id; +}; + +struct bt_mesh_cfg_hb_sub_status { + uint8_t status; + uint16_t src; + uint16_t dst; + uint8_t period; + uint8_t count; + uint8_t min; + uint8_t max; +}; + +struct bt_mesh_cfg_hb_pub_status { + uint8_t status; + uint16_t dst; + uint8_t count; + uint8_t period; + uint8_t ttl; + uint16_t feat; + uint16_t net_idx; +}; + +struct bt_mesh_cfg_mod_sub_list { + uint8_t status; + uint16_t elem_addr; + uint16_t cid; + uint16_t mod_id; + struct net_buf_simple *addr; +}; + +struct bt_mesh_cfg_net_key_list { + struct net_buf_simple *net_idx; +}; + +struct bt_mesh_cfg_app_key_list { + uint8_t status; + uint16_t net_idx; + struct net_buf_simple *app_idx; +}; + +struct bt_mesh_cfg_node_id_status { + uint8_t status; + uint16_t net_idx; + uint8_t identity; +}; + +struct bt_mesh_cfg_mod_app_list { + uint8_t status; + uint16_t elem_addr; + uint16_t cid; + uint16_t mod_id; + struct net_buf_simple *app_idx; +}; + +struct bt_mesh_cfg_key_refresh_status { + uint8_t status; + uint16_t net_idx; + uint8_t phase; +}; + +struct bt_mesh_cfg_lpn_pollto_status { + uint16_t lpn_addr; + int32_t timeout; +}; + +int bt_mesh_cfg_mod_pub_va_set(bt_mesh_client_common_param_t *param, + uint16_t elem_addr, uint16_t mod_id, + uint16_t cid, const uint8_t label[16], + struct bt_mesh_cfg_mod_pub *pub); + +int bt_mesh_cfg_mod_sub_del_all(bt_mesh_client_common_param_t *param, + uint16_t elem_addr, uint16_t mod_id, uint16_t cid); + +int bt_mesh_cfg_mod_sub_get(bt_mesh_client_common_param_t *param, + uint16_t elem_addr, uint16_t mod_id); + +int bt_mesh_cfg_mod_sub_get_vnd(bt_mesh_client_common_param_t *param, + uint16_t elem_addr, uint16_t mod_id, uint16_t cid); + +int bt_mesh_cfg_net_key_update(bt_mesh_client_common_param_t *param, + uint16_t net_idx, const uint8_t net_key[16]); + +int bt_mesh_cfg_net_key_delete(bt_mesh_client_common_param_t *param, uint16_t net_idx); + +int bt_mesh_cfg_net_key_get(bt_mesh_client_common_param_t *param); + +int bt_mesh_cfg_app_key_update(bt_mesh_client_common_param_t *param, + uint16_t net_idx, uint16_t app_idx, + const uint8_t app_key[16]); + +int bt_mesh_cfg_app_key_delete(bt_mesh_client_common_param_t *param, + uint16_t net_idx, uint16_t app_idx); + +int bt_mesh_cfg_app_key_get(bt_mesh_client_common_param_t *param, uint16_t net_idx); + +int bt_mesh_cfg_node_identity_get(bt_mesh_client_common_param_t *param, uint16_t net_idx); + +int bt_mesh_cfg_node_identity_set(bt_mesh_client_common_param_t *param, + uint16_t net_idx, uint8_t identity); + +int bt_mesh_cfg_mod_app_unbind(bt_mesh_client_common_param_t *param, + uint16_t elem_addr, uint16_t app_idx, + uint16_t mod_id, uint16_t cid); + +int bt_mesh_cfg_mod_app_get(bt_mesh_client_common_param_t *param, + uint16_t elem_addr, uint16_t mod_id); + +int bt_mesh_cfg_mod_app_get_vnd(bt_mesh_client_common_param_t *param, + uint16_t elem_addr, uint16_t mod_id, uint16_t cid); + +int bt_mesh_cfg_kr_phase_get(bt_mesh_client_common_param_t *param, uint16_t net_idx); + +int bt_mesh_cfg_kr_phase_set(bt_mesh_client_common_param_t *param, + uint16_t net_idx, uint8_t transition); + +int bt_mesh_cfg_lpn_timeout_get(bt_mesh_client_common_param_t *param, uint16_t lpn_addr); + +int bt_mesh_cfg_net_transmit_get(bt_mesh_client_common_param_t *param); + +int bt_mesh_cfg_net_transmit_set(bt_mesh_client_common_param_t *param, uint8_t transmit); + +#ifdef __cplusplus +} +#endif + +/** + * @} + */ + +#endif /* __BLE_MESH_CFG_CLI_H */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/include/cfg_srv.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/include/cfg_srv.h new file mode 100644 index 00000000000..41b9a6236f5 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/include/cfg_srv.h @@ -0,0 +1,223 @@ +/** @file + * @brief Bluetooth Mesh Configuration Server Model APIs. + */ + +/* + * SPDX-FileCopyrightText: 2017 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ +#ifndef _BLE_MESH_CFG_SRV_H_ +#define _BLE_MESH_CFG_SRV_H_ + +#include "mesh_access.h" + +/** + * @brief Bluetooth Mesh + * @defgroup bt_mesh_cfg_srv Bluetooth Mesh Configuration Server Model + * @ingroup bt_mesh + * @{ + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** Mesh Configuration Server Model Context */ +struct bt_mesh_cfg_srv { + struct bt_mesh_model *model; + + uint8_t net_transmit; /* Network Transmit state */ + uint8_t relay; /* Relay Mode state */ + uint8_t relay_retransmit; /* Relay Retransmit state */ + uint8_t beacon; /* Secure Network Beacon state */ + uint8_t gatt_proxy; /* GATT Proxy state */ + uint8_t frnd; /* Friend state */ + uint8_t default_ttl; /* Default TTL */ + + /* Heartbeat Publication */ + struct bt_mesh_hb_pub { + struct k_delayed_work timer; + + uint16_t dst; + uint16_t count; + uint8_t period; + uint8_t ttl; + uint16_t feat; + uint16_t net_idx; + } hb_pub; + + /* Heartbeat Subscription */ + struct bt_mesh_hb_sub { + int64_t expiry; + + uint16_t src; + uint16_t dst; + uint16_t count; + uint8_t min_hops; + uint8_t max_hops; + + /* Optional subscription tracking function */ + void (*func)(uint8_t hops, uint16_t feat); + } hb_sub; +}; + +extern const struct bt_mesh_model_op bt_mesh_cfg_srv_op[]; +extern const struct bt_mesh_model_cb bt_mesh_cfg_srv_cb; + +#define BLE_MESH_MODEL_CFG_SRV(srv_data) \ + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_CFG_SRV, \ + bt_mesh_cfg_srv_op, NULL, srv_data, &bt_mesh_cfg_srv_cb) + +typedef union { + struct { + uint8_t beacon; + } cfg_beacon_set; + struct { + uint8_t ttl; + } cfg_default_ttl_set; + struct { + uint8_t gatt_proxy; + } cfg_gatt_proxy_set; + struct { + uint8_t relay; + uint8_t retransmit; + } cfg_relay_set; + struct { + uint16_t elem_addr; + uint16_t pub_addr; + uint16_t app_idx; + bool cred_flag; + uint8_t ttl; + uint8_t period; + uint8_t transmit; + uint16_t cid; + uint16_t mod_id; + } cfg_mod_pub_set; + struct { + uint16_t elem_addr; + uint8_t pub_addr[16]; + uint16_t app_idx; + bool cred_flag; + uint8_t ttl; + uint8_t period; + uint8_t transmit; + uint16_t cid; + uint16_t mod_id; + } cfg_mod_pub_va_set; + struct { + uint16_t elem_addr; + uint16_t sub_addr; + uint16_t cid; + uint16_t mod_id; + } cfg_mod_sub_add; + struct { + uint16_t elem_addr; + uint8_t sub_addr[16]; + uint16_t cid; + uint16_t mod_id; + } cfg_mod_sub_va_add; + struct { + uint16_t elem_addr; + uint16_t sub_addr; + uint16_t cid; + uint16_t mod_id; + } cfg_mod_sub_delete; + struct { + uint16_t elem_addr; + uint8_t sub_addr[16]; + uint16_t cid; + uint16_t mod_id; + } cfg_mod_sub_va_delete; + struct { + uint16_t elem_addr; + uint16_t sub_addr; + uint16_t cid; + uint16_t mod_id; + } cfg_mod_sub_overwrite; + struct { + uint16_t elem_addr; + uint8_t sub_addr[16]; + uint16_t cid; + uint16_t mod_id; + } cfg_mod_sub_va_overwrite; + struct { + uint16_t elem_addr; + uint16_t cid; + uint16_t mod_id; + } cfg_mod_sub_delete_all; + struct { + uint16_t net_idx; + uint8_t net_key[16]; + } cfg_netkey_add; + struct { + uint16_t net_idx; + uint8_t net_key[16]; + } cfg_netkey_update; + struct { + uint16_t net_idx; + } cfg_netkey_delete; + struct { + uint16_t net_idx; + uint16_t app_idx; + uint8_t app_key[16]; + } cfg_appkey_add; + struct { + uint16_t net_idx; + uint16_t app_idx; + uint8_t app_key[16]; + } cfg_appkey_update; + struct { + uint16_t net_idx; + uint16_t app_idx; + } cfg_appkey_delete; + struct { + uint16_t net_idx; + uint8_t identity; + } cfg_node_identity_set; + struct { + uint16_t elem_addr; + uint16_t app_idx; + uint16_t cid; + uint16_t mod_id; + } cfg_mod_app_bind; + struct { + uint16_t elem_addr; + uint16_t app_idx; + uint16_t cid; + uint16_t mod_id; + } cfg_mod_app_unbind; + struct { + uint8_t frnd; + } cfg_friend_set; + struct { + uint16_t net_idx; + uint8_t kr_phase; + } cfg_kr_phase_set; + struct { + uint16_t dst; + uint8_t count; + uint8_t period; + uint8_t ttl; + uint16_t feat; + uint16_t net_idx; + } cfg_hb_pub_set; + struct { + uint16_t src; + uint16_t dst; + uint8_t period; + } cfg_hb_sub_set; + struct { + uint8_t transmit; + } cfg_net_transmit_set; +} bt_mesh_cfg_server_state_change_t; + +#ifdef __cplusplus +} +#endif + +/** + * @} + */ + +#endif /* __BLE_MESH_CFG_SRV_H */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/include/health_cli.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/include/health_cli.h new file mode 100644 index 00000000000..239e14cbede --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/include/health_cli.h @@ -0,0 +1,78 @@ +/** @file + * @brief Bluetooth Mesh Health Client Model APIs. + */ + +/* + * SPDX-FileCopyrightText: 2017 Intel Corporation + * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#ifndef _BLE_MESH_HEALTH_CLI_H_ +#define _BLE_MESH_HEALTH_CLI_H_ + +#include "client_common.h" + +/** + * @brief Bluetooth Mesh + * @defgroup bt_mesh_health_cli Bluetooth Mesh Health Client Model + * @ingroup bt_mesh + * @{ + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Health client model common structure */ +typedef bt_mesh_client_user_data_t bt_mesh_health_client_t; +typedef bt_mesh_client_internal_data_t health_internal_data_t; + +extern const struct bt_mesh_model_op bt_mesh_health_cli_op[]; +extern const struct bt_mesh_model_cb bt_mesh_health_cli_cb; + +#define BLE_MESH_MODEL_HEALTH_CLI(cli_data) \ + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_HEALTH_CLI, \ + bt_mesh_health_cli_op, NULL, cli_data, &bt_mesh_health_cli_cb) + +int bt_mesh_health_fault_get(bt_mesh_client_common_param_t *param, uint16_t cid); + +int bt_mesh_health_fault_clear(bt_mesh_client_common_param_t *param, + uint16_t cid, bool need_ack); + +int bt_mesh_health_fault_test(bt_mesh_client_common_param_t *param, + uint16_t cid, uint8_t test_id, bool need_ack); + +int bt_mesh_health_period_get(bt_mesh_client_common_param_t *param); + +int bt_mesh_health_period_set(bt_mesh_client_common_param_t *param, + uint8_t divisor, bool need_ack); + +int bt_mesh_health_attention_get(bt_mesh_client_common_param_t *param); + +int bt_mesh_health_attention_set(bt_mesh_client_common_param_t *param, + uint8_t attention, bool need_ack); + +/* Health Client Status Message Context */ + +struct bt_mesh_health_current_status { + uint8_t test_id; + uint16_t cid; + struct net_buf_simple *fault_array; +}; + +struct bt_mesh_health_fault_status { + uint8_t test_id; + uint16_t cid; + struct net_buf_simple *fault_array; +}; + +#ifdef __cplusplus +} +#endif + +/** + * @} + */ + +#endif /* __BLE_MESH_HEALTH_CLI_H */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/include/health_srv.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/include/health_srv.h new file mode 100644 index 00000000000..35a61b8258f --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/include/health_srv.h @@ -0,0 +1,106 @@ +/** @file + * @brief Bluetooth Mesh Health Server Model APIs. + */ + +/* + * SPDX-FileCopyrightText: 2017 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ +#ifndef _BLE_MESH_HEALTH_SRV_H_ +#define _BLE_MESH_HEALTH_SRV_H_ + +#include "mesh_access.h" + +/** + * @brief Bluetooth Mesh Health Server Model + * @defgroup bt_mesh_health_srv Bluetooth Mesh Health Server Model + * @ingroup bt_mesh + * @{ + */ + +#ifdef __cplusplus +extern "C" { +#endif + +struct bt_mesh_health_srv_cb { + /* Clear registered faults */ + void (*fault_clear)(struct bt_mesh_model *model, uint16_t company_id); + + /* Run a specific test */ + void (*fault_test)(struct bt_mesh_model *model, uint8_t test_id, + uint16_t company_id); + + /* Attention on */ + void (*attn_on)(struct bt_mesh_model *model, uint8_t time); + + /* Attention off */ + void (*attn_off)(struct bt_mesh_model *model); +}; + +/** @def BLE_MESH_HEALTH_PUB_DEFINE + * + * A helper to define a health publication context + * + * @param _name Name given to the publication context variable. + * @param _max_faults Maximum number of faults the element can have. + */ +#define BLE_MESH_HEALTH_PUB_DEFINE(_name, _max_faults) \ + BLE_MESH_MODEL_PUB_DEFINE(_name, NULL, (1 + 3 + (_max_faults))) + +struct bt_mesh_health_test { + 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; /* Most currently performed test id */ + uint8_t curr_faults[32]; /* Array of current faults */ + uint8_t reg_faults[32]; /* Array of registered faults */ +} __attribute__((packed)); + +/** Mesh Health Server Model Context */ +struct bt_mesh_health_srv { + struct bt_mesh_model *model; + + /* Optional callback struct */ + struct bt_mesh_health_srv_cb cb; + + /* Attention Timer state */ + struct k_delayed_work attn_timer; + + /* Attention Timer start flag */ + bool attn_timer_start; + + /* Health Server fault test */ + struct bt_mesh_health_test test; +}; + +extern const struct bt_mesh_model_op bt_mesh_health_srv_op[]; +extern const struct bt_mesh_model_cb bt_mesh_health_srv_cb; + +/** @def BLE_MESH_MODEL_HEALTH_SRV + * + * Define a new health server model. Note that this API needs to be + * repeated for each element which the application wants to have a + * health server model on. Each instance also needs a unique + * bt_mesh_health_srv and bt_mesh_model_pub context. + * + * @param srv Pointer to a unique struct bt_mesh_health_srv. + * @param pub Pointer to a unique struct bt_mesh_model_pub. + * + * @return New mesh model instance. + */ +#define BLE_MESH_MODEL_HEALTH_SRV(srv, pub) \ + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_HEALTH_SRV, \ + bt_mesh_health_srv_op, pub, srv, &bt_mesh_health_srv_cb) + +int bt_mesh_fault_update(struct bt_mesh_elem *elem); + +#ifdef __cplusplus +} +#endif + +/** + * @} + */ + +#endif /* __BLE_MESH_HEALTH_SRV_H */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/include/mesh_access.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/include/mesh_access.h new file mode 100644 index 00000000000..66fbb7e43fb --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/include/mesh_access.h @@ -0,0 +1,601 @@ +/** @file + * @brief Bluetooth Mesh Access Layer APIs. + */ + +/* + * SPDX-FileCopyrightText: 2017 Intel Corporation + * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#ifndef _BLE_MESH_ACCESS_H_ +#define _BLE_MESH_ACCESS_H_ + +#include "mesh_config.h" +#include "mesh_buf.h" +#include "mesh_timer.h" + +/** + * @brief Bluetooth Mesh Access Layer + * @defgroup bt_mesh_access Bluetooth Mesh Access Layer + * @ingroup bt_mesh + * @{ + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#define BLE_MESH_CID_NVAL 0xFFFF + +#define BLE_MESH_ADDR_UNASSIGNED 0x0000 +#define BLE_MESH_ADDR_ALL_NODES 0xffff +#define BLE_MESH_ADDR_PROXIES 0xfffc +#define BLE_MESH_ADDR_FRIENDS 0xfffd +#define BLE_MESH_ADDR_RELAYS 0xfffe + +#define BLE_MESH_KEY_UNUSED 0xffff +#define BLE_MESH_KEY_DEV 0xfffe + +/** Helper to define a mesh element within an array. + * + * In case the element has no SIG or Vendor models the helper + * macro BLE_MESH_MODEL_NONE can be given instead. + * + * @param _loc Location Descriptor. + * @param _mods Array of models. + * @param _vnd_mods Array of vendor models. + */ +#define BLE_MESH_ELEM(_loc, _mods, _vnd_mods) \ +{ \ + .loc = (_loc), \ + .model_count = ARRAY_SIZE(_mods), \ + .models = (_mods), \ + .vnd_model_count = ARRAY_SIZE(_vnd_mods), \ + .vnd_models = (_vnd_mods), \ +} + +/** Abstraction that describes a Mesh Element */ +struct bt_mesh_elem { + /* Unicast Address. Set at runtime during provisioning. */ + uint16_t addr; + + /* Location Descriptor (GATT Bluetooth Namespace Descriptors) */ + const uint16_t loc; + + const uint8_t model_count; + const uint8_t vnd_model_count; + + struct bt_mesh_model *const models; + struct bt_mesh_model *const vnd_models; +}; + +/* Foundation Models */ +#define BLE_MESH_MODEL_ID_CFG_SRV 0x0000 +#define BLE_MESH_MODEL_ID_CFG_CLI 0x0001 +#define BLE_MESH_MODEL_ID_HEALTH_SRV 0x0002 +#define BLE_MESH_MODEL_ID_HEALTH_CLI 0x0003 + +/* Models from the Mesh Model Specification */ +#define BLE_MESH_MODEL_ID_GEN_ONOFF_SRV 0x1000 +#define BLE_MESH_MODEL_ID_GEN_ONOFF_CLI 0x1001 +#define BLE_MESH_MODEL_ID_GEN_LEVEL_SRV 0x1002 +#define BLE_MESH_MODEL_ID_GEN_LEVEL_CLI 0x1003 +#define BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_SRV 0x1004 +#define BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_CLI 0x1005 +#define BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SRV 0x1006 +#define BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SETUP_SRV 0x1007 +#define BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_CLI 0x1008 +#define BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SRV 0x1009 +#define BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SETUP_SRV 0x100a +#define BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_CLI 0x100b +#define BLE_MESH_MODEL_ID_GEN_BATTERY_SRV 0x100c +#define BLE_MESH_MODEL_ID_GEN_BATTERY_CLI 0x100d +#define BLE_MESH_MODEL_ID_GEN_LOCATION_SRV 0x100e +#define BLE_MESH_MODEL_ID_GEN_LOCATION_SETUP_SRV 0x100f +#define BLE_MESH_MODEL_ID_GEN_LOCATION_CLI 0x1010 +#define BLE_MESH_MODEL_ID_GEN_ADMIN_PROP_SRV 0x1011 +#define BLE_MESH_MODEL_ID_GEN_MANUFACTURER_PROP_SRV 0x1012 +#define BLE_MESH_MODEL_ID_GEN_USER_PROP_SRV 0x1013 +#define BLE_MESH_MODEL_ID_GEN_CLIENT_PROP_SRV 0x1014 +#define BLE_MESH_MODEL_ID_GEN_PROP_CLI 0x1015 +#define BLE_MESH_MODEL_ID_SENSOR_SRV 0x1100 +#define BLE_MESH_MODEL_ID_SENSOR_SETUP_SRV 0x1101 +#define BLE_MESH_MODEL_ID_SENSOR_CLI 0x1102 +#define BLE_MESH_MODEL_ID_TIME_SRV 0x1200 +#define BLE_MESH_MODEL_ID_TIME_SETUP_SRV 0x1201 +#define BLE_MESH_MODEL_ID_TIME_CLI 0x1202 +#define BLE_MESH_MODEL_ID_SCENE_SRV 0x1203 +#define BLE_MESH_MODEL_ID_SCENE_SETUP_SRV 0x1204 +#define BLE_MESH_MODEL_ID_SCENE_CLI 0x1205 +#define BLE_MESH_MODEL_ID_SCHEDULER_SRV 0x1206 +#define BLE_MESH_MODEL_ID_SCHEDULER_SETUP_SRV 0x1207 +#define BLE_MESH_MODEL_ID_SCHEDULER_CLI 0x1208 +#define BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SRV 0x1300 +#define BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SETUP_SRV 0x1301 +#define BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_CLI 0x1302 +#define BLE_MESH_MODEL_ID_LIGHT_CTL_SRV 0x1303 +#define BLE_MESH_MODEL_ID_LIGHT_CTL_SETUP_SRV 0x1304 +#define BLE_MESH_MODEL_ID_LIGHT_CTL_CLI 0x1305 +#define BLE_MESH_MODEL_ID_LIGHT_CTL_TEMP_SRV 0x1306 +#define BLE_MESH_MODEL_ID_LIGHT_HSL_SRV 0x1307 +#define BLE_MESH_MODEL_ID_LIGHT_HSL_SETUP_SRV 0x1308 +#define BLE_MESH_MODEL_ID_LIGHT_HSL_CLI 0x1309 +#define BLE_MESH_MODEL_ID_LIGHT_HSL_HUE_SRV 0x130a +#define BLE_MESH_MODEL_ID_LIGHT_HSL_SAT_SRV 0x130b +#define BLE_MESH_MODEL_ID_LIGHT_XYL_SRV 0x130c +#define BLE_MESH_MODEL_ID_LIGHT_XYL_SETUP_SRV 0x130d +#define BLE_MESH_MODEL_ID_LIGHT_XYL_CLI 0x130e +#define BLE_MESH_MODEL_ID_LIGHT_LC_SRV 0x130f +#define BLE_MESH_MODEL_ID_LIGHT_LC_SETUP_SRV 0x1310 +#define BLE_MESH_MODEL_ID_LIGHT_LC_CLI 0x1311 + +/** Message sending context. */ +struct bt_mesh_msg_ctx { + /** NetKey Index of the subnet to send the message on. */ + uint16_t net_idx; + + /** AppKey Index to encrypt the message with. */ + uint16_t app_idx; + + /** Remote address. */ + uint16_t addr; + + /** Destination address of a received message. Not used for sending. */ + uint16_t recv_dst; + + /** RSSI of received packet. Not used for sending. */ + int8_t recv_rssi; + + /** Received TTL value. Not used for sending. */ + uint8_t recv_ttl: 7; + + /** Force sending reliably by using segment acknowledgement */ + uint8_t send_rel: 1; + + /** TTL, or BLE_MESH_TTL_DEFAULT for default TTL. */ + uint8_t send_ttl; + + /** Change by Espressif, opcode of a received message. + * Not used for sending message. */ + uint32_t recv_op; + + /** Change by Espressif, model corresponds to the message */ + struct bt_mesh_model *model; + + /** Change by Espressif, if the message is sent by a server + * model. Not used for receiving message. */ + bool srv_send; +}; + +struct bt_mesh_model_op { + /* OpCode encoded using the BLE_MESH_MODEL_OP_* macros */ + const uint32_t opcode; + + /* Minimum required message length */ + const size_t min_len; + + /* Message handler for the opcode */ + void (*const func)(struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf); +}; + +#define BLE_MESH_MODEL_OP_1(b0) (b0) +#define BLE_MESH_MODEL_OP_2(b0, b1) (((b0) << 8) | (b1)) +#define BLE_MESH_MODEL_OP_3(b0, cid) ((((b0) << 16) | 0xc00000) | (cid)) + +#define BLE_MESH_MODEL_OP_END { 0, 0, NULL } +#define BLE_MESH_MODEL_NO_OPS ((struct bt_mesh_model_op []) \ + { BLE_MESH_MODEL_OP_END }) + +/** Helper to define an empty model array */ +#define BLE_MESH_MODEL_NONE ((struct bt_mesh_model []){}) + +/** Length of a short Mesh MIC. */ +#define BLE_MESH_MIC_SHORT 4 +/** Length of a long Mesh MIC. */ +#define BLE_MESH_MIC_LONG 8 + +/** @def BLE_MESH_MODEL_OP_LEN + * + * @brief Helper to determine the length of an opcode. + * + * @param _op Opcode. + */ +#define BLE_MESH_MODEL_OP_LEN(_op) ((_op) <= 0xff ? 1 : (_op) <= 0xffff ? 2 : 3) + +/** @def BLE_MESH_MODEL_BUF_LEN + * + * @brief Helper for model message buffer length. + * + * Returns the length of a Mesh model message buffer, including the opcode + * length and a short MIC. + * + * @param _op Opcode of the message. + * @param _payload_len Length of the model payload. + */ +#define BLE_MESH_MODEL_BUF_LEN(_op, _payload_len) \ + (BLE_MESH_MODEL_OP_LEN(_op) + (_payload_len) + BLE_MESH_MIC_SHORT) + +/** @def BLE_MESH_MODEL_BUF_LEN_LONG_MIC + * + * @brief Helper for model message buffer length. + * + * Returns the length of a Mesh model message buffer, including the opcode + * length and a long MIC. + * + * @param _op Opcode of the message. + * @param _payload_len Length of the model payload. + */ +#define BLE_MESH_MODEL_BUF_LEN_LONG_MIC(_op, _payload_len) \ + (BLE_MESH_MODEL_OP_LEN(_op) + (_payload_len) + BLE_MESH_MIC_LONG) + +/** @def BLE_MESH_MODEL_BUF_DEFINE + * + * @brief Define a Mesh model message buffer using @ref NET_BUF_SIMPLE_DEFINE. + * + * @param _buf Buffer name. + * @param _op Opcode of the message. + * @param _payload_len Length of the model message payload. + */ +#define BLE_MESH_MODEL_BUF_DEFINE(_buf, _op, _payload_len) \ + NET_BUF_SIMPLE_DEFINE(_buf, BLE_MESH_MODEL_BUF_LEN((_op), (_payload_len))) + +/** @def BLE_MESH_MODEL_CB + * + * @brief Composition data SIG model entry with callback functions. + * + * @param _id Model ID. + * @param _op Array of model opcode handlers. + * @param _pub Model publish parameters. + * @param _user_data User data for the model. + * @param _cb Callback structure, or NULL to keep no callbacks. + */ +#define BLE_MESH_MODEL_CB(_id, _op, _pub, _user_data, _cb) \ +{ \ + .id = (_id), \ + .op = (_op), \ + .keys = { [0 ... (CONFIG_BLE_MESH_MODEL_KEY_COUNT - 1)] = \ + BLE_MESH_KEY_UNUSED }, \ + .pub = (_pub), \ + .groups = { [0 ... (CONFIG_BLE_MESH_MODEL_GROUP_COUNT - 1)] = \ + BLE_MESH_ADDR_UNASSIGNED }, \ + .user_data = (_user_data), \ + .cb = (_cb), \ +} + +/** @def BLE_MESH_MODEL_VND_CB + * + * @brief Composition data vendor model entry with callback functions. + * + * @param _company Company ID. + * @param _id Model ID. + * @param _op Array of model opcode handlers. + * @param _pub Model publish parameters. + * @param _user_data User data for the model. + * @param _cb Callback structure, or NULL to keep no callbacks. + */ +#define BLE_MESH_MODEL_VND_CB(_company, _id, _op, _pub, _user_data, _cb) \ +{ \ + .vnd.company = (_company), \ + .vnd.id = (_id), \ + .op = (_op), \ + .pub = (_pub), \ + .keys = { [0 ... (CONFIG_BLE_MESH_MODEL_KEY_COUNT - 1)] = \ + BLE_MESH_KEY_UNUSED }, \ + .groups = { [0 ... (CONFIG_BLE_MESH_MODEL_GROUP_COUNT - 1)] = \ + BLE_MESH_ADDR_UNASSIGNED }, \ + .user_data = (_user_data), \ + .cb = (_cb), \ +} + +/** @def BLE_MESH_TRANSMIT + * + * @brief Encode transmission count & interval steps. + * + * @param count Number of retransmissions (first transmission is excluded). + * @param int_ms Interval steps in milliseconds. Must be greater than 0 + * and a multiple of 10. + * + * @return Mesh transmit value that can be used e.g. for the default + * values of the configuration model data. + */ +#define BLE_MESH_TRANSMIT(count, int_ms) ((count) | ((((int_ms) / 10) - 1) << 3)) + +/** @def BLE_MESH_TRANSMIT_COUNT + * + * @brief Decode transmit count from a transmit value. + * + * @param transmit Encoded transmit count & interval value. + * + * @return Transmission count (actual transmissions is N + 1). + */ +#define BLE_MESH_TRANSMIT_COUNT(transmit) (((transmit) & (uint8_t)BIT_MASK(3))) + +/** @def BLE_MESH_TRANSMIT_INT + * + * @brief Decode transmit interval from a transmit value. + * + * @param transmit Encoded transmit count & interval value. + * + * @return Transmission interval in milliseconds. + */ +#define BLE_MESH_TRANSMIT_INT(transmit) ((((transmit) >> 3) + 1) * 10) + +/** @def BLE_MESH_PUB_TRANSMIT + * + * @brief Encode Publish Retransmit count & interval steps. + * + * @param count Number of retransmissions (first transmission is excluded). + * @param int_ms Interval steps in milliseconds. Must be greater than 0 + * and a multiple of 50. + * + * @return Mesh transmit value that can be used e.g. for the default + * values of the configuration model data. + */ +#define BLE_MESH_PUB_TRANSMIT(count, int_ms) BLE_MESH_TRANSMIT((count), (int_ms) / 5) + +/** @def BLE_MESH_PUB_TRANSMIT_COUNT + * + * @brief Decode Publish Retransmit count from a given value. + * + * @param transmit Encoded Publish Retransmit count & interval value. + * + * @return Retransmission count (actual transmissions is N + 1). + */ +#define BLE_MESH_PUB_TRANSMIT_COUNT(transmit) BLE_MESH_TRANSMIT_COUNT(transmit) + +/** @def BLE_MESH_PUB_TRANSMIT_INT + * + * @brief Decode Publish Retransmit interval from a given value. + * + * @param transmit Encoded Publish Retransmit count & interval value. + * + * @return Transmission interval in milliseconds. + */ +#define BLE_MESH_PUB_TRANSMIT_INT(transmit) ((((transmit) >> 3) + 1) * 50) + +/** Model publication context. */ +struct bt_mesh_model_pub { + /** The model the context belongs to. Initialized by the stack. */ + struct bt_mesh_model *mod; + + uint16_t addr; /**< Publish Address. */ + uint16_t key:12, /**< Publish AppKey Index. */ + cred:1, /**< Friendship Credentials Flag. */ + send_rel:1; /**< Force reliable sending (segment acks) */ + + uint8_t ttl; /**< Publish Time to Live. */ + uint8_t retransmit; /**< Retransmit Count & Interval Steps. */ + uint8_t period; /**< Publish Period. */ + uint8_t period_div:4, /**< Divisor for the Period. */ + fast_period:1, /**< Use FastPeriodDivisor */ + count:3; /**< Retransmissions left. */ + + uint32_t period_start; /**< Start of the current period. */ + + /** @brief Publication buffer, containing the publication message. + * + * This will get correctly created when the publication context + * has been defined using the BLE_MESH_MODEL_PUB_DEFINE macro. + * + * BLE_MESH_MODEL_PUB_DEFINE(name, update, size); + */ + struct net_buf_simple *msg; + + /** @brief Callback for updating the publication buffer. + * + * When set to NULL, the model is assumed not to support + * periodic publishing. When set to non-NULL the callback + * will be called periodically and is expected to update + * @ref bt_mesh_model_pub.msg with a valid publication + * message. + * + * If the callback returns non-zero, the publication is skipped + * and will resume on the next periodic publishing interval. + * + * @param mod The Model the Publication Context belongs to. + * + * @return Zero on success or (negative) error code otherwise. + */ + int (*update)(struct bt_mesh_model *mod); + + /** Publish Period Timer. Only for stack-internal use. */ + struct k_delayed_work timer; + + /* Change by Espressif, role of the device going to publish messages */ + uint8_t dev_role; +}; + +/** @def BLE_MESH_MODEL_PUB_DEFINE + * + * Define a model publication context. + * + * @param _name Variable name given to the context. + * @param _update Optional message update callback (may be NULL). + * @param _msg_len Length of the publication message. + */ +#define BLE_MESH_MODEL_PUB_DEFINE(_name, _update, _msg_len) \ + NET_BUF_SIMPLE_DEFINE_STATIC(bt_mesh_pub_msg_##_name, _msg_len); \ + static struct bt_mesh_model_pub _name = { \ + .update = _update, \ + .msg = &bt_mesh_pub_msg_##_name, \ + } + +/** Model callback functions. */ +struct bt_mesh_model_cb { + /** @brief Model init callback. + * + * Called on every model instance during mesh initialization. + * + * If any of the model init callbacks return an error, the mesh + * subsystem initialization will be aborted, and the error will + * be returned to the caller of @ref bt_mesh_init. + * + * @param model Model to be initialized. + * + * @return 0 on success, error otherwise. + */ + int (*const init)(struct bt_mesh_model *model); + +#if CONFIG_BLE_MESH_DEINIT + /** @brief Model deinit callback. + * + * Called on every model instance during mesh deinitialization. + * All model data is deleted, and the model should clear its state. + * + * If any of the model deinit callbacks return an error, the mesh + * subsystem deinitialization will be aborted, and the error will + * be returned to the caller of @ref bt_mesh_deinit. + * + * @param model Model to be de-initialized. + */ + int (*const deinit)(struct bt_mesh_model *model); +#endif /* CONFIG_BLE_MESH_DEINIT */ +}; + +/** Abstraction that describes a Mesh Model instance */ +struct bt_mesh_model { + union { + const uint16_t id; + struct { + uint16_t company; + uint16_t id; + } vnd; + }; + + /* Internal information, mainly for persistent storage */ + uint8_t elem_idx; /* Belongs to Nth element */ + uint8_t model_idx; /* Is the Nth model in the element */ + uint16_t flags; /* Information about what has changed */ + + /* The Element this Model belongs to */ + struct bt_mesh_elem *elem; + + /* Model Publication */ + struct bt_mesh_model_pub *const pub; + + /* AppKey List */ + uint16_t keys[CONFIG_BLE_MESH_MODEL_KEY_COUNT]; + + /* Subscription List (group or virtual addresses) */ + uint16_t groups[CONFIG_BLE_MESH_MODEL_GROUP_COUNT]; + + /** Opcode handler list */ + const struct bt_mesh_model_op *const op; + + /** Model callback structure. */ + const struct bt_mesh_model_cb *const cb; + + /* Model-specific user data */ + void *user_data; +}; + +struct bt_mesh_send_cb { + void (*start)(uint16_t duration, int err, void *cb_data); + void (*end)(int err, void *cb_data); +}; + +void bt_mesh_model_msg_init(struct net_buf_simple *msg, uint32_t opcode); + +/** Special TTL value to request using configured default TTL */ +#define BLE_MESH_TTL_DEFAULT 0xff + +/** Maximum allowed TTL value */ +#define BLE_MESH_TTL_MAX 0x7f + +/** + * @brief Send an Access Layer message. + * + * @param model Mesh (client) Model that the message belongs to. + * @param ctx Message context, includes keys, TTL, etc. + * @param msg Access Layer payload (the actual message to be sent). + * @param cb Optional "message sent" callback. + * @param cb_data User data to be passed to the callback. + * + * @return 0 on success, or (negative) error code on failure. + */ +int bt_mesh_model_send(struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *msg, + const struct bt_mesh_send_cb *cb, + void *cb_data); + +/** + * @brief Send a model publication message. + * + * Before calling this function, the user needs to ensure that the model + * publication message (@ref bt_mesh_model_pub.msg) contains a valid + * message to be sent. Note that this API is only to be used for + * non-period publishing. For periodic publishing the app only needs + * to make sure that @ref bt_mesh_model_pub.msg contains a valid message + * whenever the @ref bt_mesh_model_pub.update callback is called. + * + * @param model Mesh (client) Model that's publishing the message. + * + * @return 0 on success, or (negative) error code on failure. + */ +int bt_mesh_model_publish(struct bt_mesh_model *model); + +/** + * @brief Get the element that a model belongs to. + * + * @param mod Mesh model. + * + * @return Pointer to the element that the given model belongs to. + */ +struct bt_mesh_elem *bt_mesh_model_elem(struct bt_mesh_model *mod); + +/** @brief Find a SIG model. + * + * @param elem Element to search for the model in. + * @param id Model ID of the model. + * + * @return A pointer to the Mesh model matching the given parameters, or NULL + * if no SIG model with the given ID exists in the given element. + */ +struct bt_mesh_model *bt_mesh_model_find(struct bt_mesh_elem *elem, uint16_t id); + +/** @brief Find a vendor model. + * + * @param elem Element to search for the model in. + * @param company Company ID of the model. + * @param id Model ID of the model. + * + * @return A pointer to the Mesh model matching the given parameters, or NULL + * if no vendor model with the given ID exists in the given element. + */ +struct bt_mesh_model *bt_mesh_model_find_vnd(struct bt_mesh_elem *elem, + uint16_t company, uint16_t id); + +/** @brief Get whether the model is in the primary element of the device. + * + * @param mod Mesh model. + * + * @return true if the model is on the primary element, false otherwise. + */ +static inline bool bt_mesh_model_in_primary(const struct bt_mesh_model *mod) +{ + return (mod->elem_idx == 0); +} + +/** Node Composition */ +struct bt_mesh_comp { + uint16_t cid; + uint16_t pid; + uint16_t vid; + + size_t elem_count; + struct bt_mesh_elem *elem; +}; + +#ifdef __cplusplus +} +#endif + +/** + * @} + */ + +#endif /* __BLE_MESH_ACCESS_H */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/include/mesh_bearer_adapt.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/include/mesh_bearer_adapt.h new file mode 100644 index 00000000000..0174c32741f --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/include/mesh_bearer_adapt.h @@ -0,0 +1,807 @@ +/* + * SPDX-FileCopyrightText: 2017 Nordic Semiconductor ASA + * SPDX-FileCopyrightText: 2015-2017 Intel Corporation + * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _BLE_MESH_BEARER_ADAPT_H_ +#define _BLE_MESH_BEARER_ADAPT_H_ + +#include +#include "mesh_config.h" +#include "mesh_types.h" +#include "mesh_util.h" +#include "mesh_uuid.h" +#include "mesh_buf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* BLE Mesh Max Connection Count */ +#ifdef CONFIG_BT_BLUEDROID_ENABLED +#define BLE_MESH_MAX_CONN CONFIG_BT_ACL_CONNECTIONS +#endif + +#ifdef CONFIG_BT_NIMBLE_ENABLED +#define BLE_MESH_MAX_CONN CONFIG_BT_NIMBLE_MAX_CONNECTIONS +#endif + +#define BLE_MESH_GAP_ADV_MAX_LEN 31 + +#define BLE_MESH_GATT_DEF_MTU_SIZE 23 + +/* BD ADDR types */ +#define BLE_MESH_ADDR_PUBLIC 0x00 +#define BLE_MESH_ADDR_RANDOM 0x01 +#define BLE_MESH_ADDR_PUBLIC_ID 0x02 +#define BLE_MESH_ADDR_RANDOM_ID 0x03 + +/* BD ADDR length */ +#define BLE_MESH_ADDR_LEN 0x06 + +/* Advertising types */ +#define BLE_MESH_ADV_IND 0x00 +#define BLE_MESH_ADV_DIRECT_IND 0x01 +#define BLE_MESH_ADV_SCAN_IND 0x02 +#define BLE_MESH_ADV_NONCONN_IND 0x03 +#define BLE_MESH_ADV_DIRECT_IND_LOW_DUTY 0x04 + +/* advertising channel map */ +#define BLE_MESH_ADV_CHNL_37 BIT(0) +#define BLE_MESH_ADV_CHNL_38 BIT(1) +#define BLE_MESH_ADV_CHNL_39 BIT(2) + +/* Advertising filter policy */ +#define BLE_MESH_AP_SCAN_CONN_ALL 0x00 +#define BLE_MESH_AP_SCAN_WL_CONN_ALL 0x01 +#define BLE_MESH_AP_SCAN_ALL_CONN_WL 0x02 +#define BLE_MESH_AP_SCAN_CONN_WL 0x03 + +/* Scan types */ +#define BLE_MESH_SCAN_PASSIVE 0x00 +#define BLE_MESH_SCAN_ACTIVE 0x01 + +/* Scan operation */ +#define BLE_MESH_SCAN_DISABLE 0x00 +#define BLE_MESH_SCAN_ENABLE 0x01 + +/* Scan duplicate operation */ +#define BLE_MESH_SCAN_FILTER_DUP_DISABLE 0x00 +#define BLE_MESH_SCAN_FILTER_DUP_ENABLE 0x01 + +/* Scan filter policy */ +#define BLE_MESH_SP_ADV_ALL 0x00 +#define BLE_MESH_SP_ADV_WL 0x01 +#define BLE_MESH_SP_ADV_ALL_RPA_DIR_ADV 0x02 +#define BLE_MESH_SP_ADV_WL_RPA_DIR_ADV 0x03 + +/* Error codes for Error response PDU */ +#define BLE_MESH_ATT_ERR_INVALID_HANDLE 0x01 +#define BLE_MESH_ATT_ERR_READ_NOT_PERMITTED 0x02 +#define BLE_MESH_ATT_ERR_WRITE_NOT_PERMITTED 0x03 +#define BLE_MESH_ATT_ERR_INVALID_PDU 0x04 +#define BLE_MESH_ATT_ERR_AUTHENTICATION 0x05 +#define BLE_MESH_ATT_ERR_NOT_SUPPORTED 0x06 +#define BLE_MESH_ATT_ERR_INVALID_OFFSET 0x07 +#define BLE_MESH_ATT_ERR_AUTHORIZATION 0x08 +#define BLE_MESH_ATT_ERR_PREPARE_QUEUE_FULL 0x09 +#define BLE_MESH_ATT_ERR_ATTRIBUTE_NOT_FOUND 0x0a +#define BLE_MESH_ATT_ERR_ATTRIBUTE_NOT_LONG 0x0b +#define BLE_MESH_ATT_ERR_ENCRYPTION_KEY_SIZE 0x0c +#define BLE_MESH_ATT_ERR_INVALID_ATTRIBUTE_LEN 0x0d +#define BLE_MESH_ATT_ERR_UNLIKELY 0x0e +#define BLE_MESH_ATT_ERR_INSUFFICIENT_ENCRYPTION 0x0f +#define BLE_MESH_ATT_ERR_UNSUPPORTED_GROUP_TYPE 0x10 +#define BLE_MESH_ATT_ERR_INSUFFICIENT_RESOURCES 0x11 + +/* Common Profile Error Codes (from CSS) */ +#define BLE_MESH_ATT_ERR_WRITE_REQ_REJECTED 0xfc +#define BLE_MESH_ATT_ERR_CCC_IMPROPER_CONF 0xfd +#define BLE_MESH_ATT_ERR_PROCEDURE_IN_PROGRESS 0xfe +#define BLE_MESH_ATT_ERR_OUT_OF_RANGE 0xff + +/* EIR/AD data type definitions */ +#define BLE_MESH_DATA_FLAGS 0x01 /* AD flags */ +#define BLE_MESH_DATA_UUID16_SOME 0x02 /* 16-bit UUID, more available */ +#define BLE_MESH_DATA_UUID16_ALL 0x03 /* 16-bit UUID, all listed */ +#define BLE_MESH_DATA_UUID32_SOME 0x04 /* 32-bit UUID, more available */ +#define BLE_MESH_DATA_UUID32_ALL 0x05 /* 32-bit UUID, all listed */ +#define BLE_MESH_DATA_UUID128_SOME 0x06 /* 128-bit UUID, more available */ +#define BLE_MESH_DATA_UUID128_ALL 0x07 /* 128-bit UUID, all listed */ +#define BLE_MESH_DATA_NAME_SHORTENED 0x08 /* Shortened name */ +#define BLE_MESH_DATA_NAME_COMPLETE 0x09 /* Complete name */ +#define BLE_MESH_DATA_TX_POWER 0x0a /* Tx Power */ +#define BLE_MESH_DATA_SOLICIT16 0x14 /* Solicit UUIDs, 16-bit */ +#define BLE_MESH_DATA_SOLICIT128 0x15 /* Solicit UUIDs, 128-bit */ +#define BLE_MESH_DATA_SVC_DATA16 0x16 /* Service data, 16-bit UUID */ +#define BLE_MESH_DATA_GAP_APPEARANCE 0x19 /* GAP appearance */ +#define BLE_MESH_DATA_SOLICIT32 0x1f /* Solicit UUIDs, 32-bit */ +#define BLE_MESH_DATA_SVC_DATA32 0x20 /* Service data, 32-bit UUID */ +#define BLE_MESH_DATA_SVC_DATA128 0x21 /* Service data, 128-bit UUID */ +#define BLE_MESH_DATA_URI 0x24 /* URI */ +#define BLE_MESH_DATA_MESH_PROV 0x29 /* Mesh Provisioning PDU */ +#define BLE_MESH_DATA_MESH_MESSAGE 0x2a /* Mesh Networking PDU */ +#define BLE_MESH_DATA_MESH_BEACON 0x2b /* Mesh Beacon */ + +#define BLE_MESH_DATA_MANUFACTURER_DATA 0xff /* Manufacturer Specific Data */ + +#define BLE_MESH_AD_LIMITED 0x01 /* Limited Discoverable */ +#define BLE_MESH_AD_GENERAL 0x02 /* General Discoverable */ +#define BLE_MESH_AD_NO_BREDR 0x04 /* BR/EDR not supported */ + +/* Client Characteristic Configuration Values */ + +/** @def BLE_MESH_GATT_CCC_NOTIFY + * @brief Client Characteristic Configuration Notification. + * + * If set, changes to Characteristic Value shall be notified. + */ +#define BLE_MESH_GATT_CCC_NOTIFY 0x0001 + +/** @def BLE_MESH_GATT_CCC_INDICATE + * @brief Client Characteristic Configuration Indication. + * + * If set, changes to Characteristic Value shall be indicated. + */ +#define BLE_MESH_GATT_CCC_INDICATE 0x0002 + +/** @def BLE_MESH_GATT_ERR + * @brief Construct error return value for attribute read and write callbacks. + * + * @param _att_err ATT error code + * + * @return Appropriate error code for the attribute callbacks. + * + */ +#define BLE_MESH_GATT_ERR(_att_err) (-(_att_err)) + +enum { + BLE_MESH_GATT_ITER_STOP = 0, + BLE_MESH_GATT_ITER_CONTINUE, +}; + +/* GATT attribute permission bit field values */ +enum { + /** No operations supported, e.g. for notify-only */ + BLE_MESH_GATT_PERM_NONE = 0, + + /** Attribute read permission. */ + BLE_MESH_GATT_PERM_READ = BIT(0), + + /** Attribute write permission. */ + BLE_MESH_GATT_PERM_WRITE = BIT(1), + + /** Attribute read permission with encryption. + * + * If set, requires encryption for read access. + */ + BLE_MESH_GATT_PERM_READ_ENCRYPT = BIT(2), + + /** Attribute write permission with encryption. + * + * If set, requires encryption for write access. + */ + BLE_MESH_GATT_PERM_WRITE_ENCRYPT = BIT(3), + + /** Attribute read permission with authentication. + * + * If set, requires encryption using authenticated link-key for read + * access. + */ + BLE_MESH_GATT_PERM_READ_AUTHEN = BIT(4), + + /** Attribute write permission with authentication. + * + * If set, requires encryption using authenticated link-key for write + * access. + */ + BLE_MESH_GATT_PERM_WRITE_AUTHEN = BIT(5), + + /** Attribute prepare write permission. + * + * If set, allows prepare writes with use of BT_GATT_WRITE_FLAG_PREPARE + * passed to write callback. + */ + BLE_MESH_GATT_PERM_PREPARE_WRITE = BIT(6), +}; + +/** Advertising options */ +enum { + /** Convenience value when no options are specified. */ + BLE_MESH_ADV_OPT_NONE = 0, + + /** Advertise as connectable. Type of advertising is determined by + * providing SCAN_RSP data and/or enabling local privacy support. + */ + BLE_MESH_ADV_OPT_CONNECTABLE = BIT(0), + + /** Don't try to resume connectable advertising after a connection. + * This option is only meaningful when used together with + * BLE_MESH_ADV_OPT_CONNECTABLE. If set the advertising will be stopped + * when bt_le_adv_stop() is called or when an incoming (slave) + * connection happens. If this option is not set the stack will + * take care of keeping advertising enabled even as connections + * occur. + */ + BLE_MESH_ADV_OPT_ONE_TIME = BIT(1), +}; + +/* Defined GAP timers */ +#define BLE_MESH_GAP_SCAN_FAST_INTERVAL 0x0060 /* 60 ms */ +#define BLE_MESH_GAP_SCAN_FAST_WINDOW 0x0030 /* 30 ms */ +#define BLE_MESH_GAP_SCAN_SLOW_INTERVAL_1 0x0800 /* 1.28 s */ +#define BLE_MESH_GAP_SCAN_SLOW_WINDOW_1 0x0012 /* 11.25 ms */ +#define BLE_MESH_GAP_SCAN_SLOW_INTERVAL_2 0x1000 /* 2.56 s */ +#define BLE_MESH_GAP_SCAN_SLOW_WINDOW_2 0x0012 /* 11.25 ms */ +#define BLE_MESH_GAP_ADV_FAST_INT_MIN_0 0x0020 /* 20 ms */ +#define BLE_MESH_GAP_ADV_FAST_INT_MAX_0 0x0020 /* 20 ms */ +#define BLE_MESH_GAP_ADV_FAST_INT_MIN_1 0x0030 /* 30 ms */ +#define BLE_MESH_GAP_ADV_FAST_INT_MAX_1 0x0060 /* 60 ms */ +#define BLE_MESH_GAP_ADV_FAST_INT_MIN_2 0x00a0 /* 100 ms */ +#define BLE_MESH_GAP_ADV_FAST_INT_MAX_2 0x00f0 /* 150 ms */ +#define BLE_MESH_GAP_ADV_SLOW_INT_MIN 0x0320 /* 500 ms */ +#define BLE_MESH_GAP_ADV_SLOW_INT_MAX 0x0320 /* 500 ms */ +#define BLE_MESH_GAP_INIT_CONN_INT_MIN 0x0018 /* 30 ms */ +#define BLE_MESH_GAP_INIT_CONN_INT_MAX 0x0028 /* 50 ms */ + +/* Characteristic Properties Bit field values */ + +/** @def BLE_MESH_GATT_CHRC_BROADCAST + * @brief Characteristic broadcast property. + * + * If set, permits broadcasts of the Characteristic Value using Server + * Characteristic Configuration Descriptor. + */ +#define BLE_MESH_GATT_CHRC_BROADCAST 0x01 + +/** @def BLE_MESH_GATT_CHRC_READ + * @brief Characteristic read property. + * + * If set, permits reads of the Characteristic Value. + */ +#define BLE_MESH_GATT_CHRC_READ 0x02 + +/** @def BLE_MESH_GATT_CHRC_WRITE_WITHOUT_RESP + * @brief Characteristic write without response property. + * + * If set, permits write of the Characteristic Value without response. + */ +#define BLE_MESH_GATT_CHRC_WRITE_WITHOUT_RESP 0x04 + +/** @def BLE_MESH_GATT_CHRC_WRITE + * @brief Characteristic write with response property. + * + * If set, permits write of the Characteristic Value with response. + */ +#define BLE_MESH_GATT_CHRC_WRITE 0x08 + +/** @def BLE_MESH_GATT_CHRC_NOTIFY + * @brief Characteristic notify property. + * + * If set, permits notifications of a Characteristic Value without + * acknowledgment. + */ +#define BLE_MESH_GATT_CHRC_NOTIFY 0x10 + +/** @def BLE_MESH_GATT_CHRC_INDICATE + * @brief Characteristic indicate property. + * + * If set, permits indications of a Characteristic Value with acknowledgment. + */ +#define BLE_MESH_GATT_CHRC_INDICATE 0x20 + +/** @def BLE_MESH_GATT_CHRC_AUTH + * @brief Characteristic Authenticated Signed Writes property. + * + * If set, permits signed writes to the Characteristic Value. + */ +#define BLE_MESH_GATT_CHRC_AUTH 0x40 + +/** @def BLE_MESH_GATT_CHRC_EXT_PROP + * @brief Characteristic Extended Properties property. + * + * If set, additional characteristic properties are defined in the + * Characteristic Extended Properties Descriptor. + */ +#define BLE_MESH_GATT_CHRC_EXT_PROP 0x80 + +/** @brief Characteristic Attribute Value. */ +struct bt_mesh_gatt_char { + /** Characteristic UUID. */ + const struct bt_mesh_uuid *uuid; + /** Characteristic properties. */ + uint8_t properties; +}; + +/** @brief GATT Service structure */ +struct bt_mesh_gatt_service { + /** Service Attributes */ + struct bt_mesh_gatt_attr *attrs; + /** Service Attribute count */ + uint16_t attr_count; + sys_snode_t node; +}; + +typedef struct { + uint8_t type; + uint8_t val[6]; +} bt_mesh_addr_t; + +/** Description of different data types that can be encoded into + * advertising data. Used to form arrays that are passed to the + * bt_le_adv_start() function. + */ +struct bt_mesh_adv_data { + uint8_t type; + uint8_t data_len; + const uint8_t *data; +}; + +/** @brief Helper to declare elements of bt_data arrays + * + * This macro is mainly for creating an array of struct + * bt_mesh_adv_data elements which is then passed to + * bt_le_adv_start(). + * + * @param _type Type of advertising data field + * @param _data Pointer to the data field payload + * @param _data_len Number of bytes behind the _data pointer + */ +#define BLE_MESH_ADV_DATA(_type, _data, _data_len) \ + { \ + .type = (_type), \ + .data_len = (_data_len), \ + .data = (const uint8_t *)(_data), \ + } + +/** @brief Helper to declare elements of bt_data arrays + * + * This macro is mainly for creating an array of struct bt_mesh_adv_data + * elements which is then passed to bt_le_adv_start(). + * + * @param _type Type of advertising data field + * @param _bytes Variable number of single-byte parameters + */ +#define BLE_MESH_ADV_DATA_BYTES(_type, _bytes...) \ + BLE_MESH_ADV_DATA(_type, ((uint8_t []) { _bytes }), \ + sizeof((uint8_t []) { _bytes })) + +/* BLE Mesh Advertising Parameters */ +struct bt_mesh_adv_param { + /** Bit-field of advertising options */ + uint8_t options; + + /** Minimum Advertising Interval (N * 0.625) */ + uint16_t interval_min; + + /** Maximum Advertising Interval (N * 0.625) */ + uint16_t interval_max; +}; + +#if CONFIG_BLE_MESH_SUPPORT_BLE_ADV +enum bt_mesh_ble_adv_priority { + BLE_MESH_BLE_ADV_PRIO_LOW, + BLE_MESH_BLE_ADV_PRIO_HIGH, +}; + +struct bt_mesh_ble_adv_param { + uint16_t interval; /* Advertising interval */ + uint8_t adv_type; /* Advertising type */ + uint8_t own_addr_type; /* Own address type */ + uint8_t peer_addr_type; /* Peer address type */ + uint8_t peer_addr[6]; /* Peer address */ + uint16_t duration; /* Duration is milliseconds */ + uint16_t period; /* Period in milliseconds */ + uint16_t count; /* Number of advertising duration */ + uint8_t priority:2; /* Priority of BLE advertising packet */ +}; + +struct bt_mesh_ble_adv_data { + uint8_t adv_data_len; /* Advertising data length */ + uint8_t adv_data[31]; /* Advertising data */ + uint8_t scan_rsp_data_len; /* Scan response data length */ + uint8_t scan_rsp_data[31]; /* Scan response data */ +}; +#endif /* CONFIG_BLE_MESH_SUPPORT_BLE_ADV */ + +/* BLE Mesh scan parameters */ +struct bt_mesh_scan_param { + /** Scan type (BLE_MESH_SCAN_ACTIVE or BLE_MESH_SCAN_PASSIVE) */ + uint8_t type; + + /** Duplicate filtering (BLE_MESH_SCAN_FILTER_DUP_ENABLE or + * BLE_MESH_SCAN_FILTER_DUP_DISABLE) + */ + uint8_t filter_dup; + + /** Scan interval (N * 0.625 ms) */ + uint16_t interval; + + /** Scan window (N * 0.625 ms) */ + uint16_t window; + + /** BLE scan filter policy */ + uint8_t scan_fil_policy; +}; + +struct bt_mesh_conn { + uint16_t handle; + bt_mesh_atomic_t ref; +}; + +/** @typedef bt_mesh_scan_cb_t + * @brief Callback type for reporting LE scan results. + * + * A function of this type is given to the bt_le_scan_start() function + * and will be called for any discovered LE device. + * + * @param addr Advertiser LE address and type. + * @param rssi Strength of advertiser signal. + * @param adv_type Type of advertising response from advertiser. + * @param data Buffer containing advertiser data. + */ +typedef void bt_mesh_scan_cb_t(const bt_mesh_addr_t *addr, int8_t rssi, + uint8_t adv_type, struct net_buf_simple *buf); + +/* @typedef bt_mesh_dh_key_cb_t + * @brief Callback type for DH Key calculation. + * + * Used to notify of the calculated DH Key. + * + * @param key Public key. + * @param idx Provisioning link index, only used by Provisioner. + * + * @return The DH Key, or NULL in case of failure. + */ +typedef void (*bt_mesh_dh_key_cb_t)(const uint8_t key[32], const uint8_t idx); + +/** @typedef bt_mesh_gatt_attr_func_t + * @brief Attribute iterator callback. + * + * @param attr Attribute found. + * @param user_data Data given. + * + * @return BLE_MESH_GATT_ITER_CONTINUE if should continue to the next attribute + * or BLE_MESH_GATT_ITER_STOP to stop. + */ +typedef uint8_t (*bt_mesh_gatt_attr_func_t)(const struct bt_mesh_gatt_attr *attr, + void *user_data); + +/** @brief Connection callback structure. + * + * This structure is used for tracking the state of a connection. + * It is registered with the help of the bt_mesh_gatts_conn_cb_register() API. + * It's permissible to register multiple instances of this @ref bt_conn_cb + * type, in case different modules of an application are interested in + * tracking the connection state. If a callback is not of interest for + * an instance, it may be set to NULL and will as a consequence not be + * used for that instance. + */ +struct bt_mesh_conn_cb { + /** @brief A new connection has been established. + * + * This callback notifies the application of a new connection. + * In case the err parameter is non-zero it means that the + * connection establishment failed. + * + * @param conn New connection object. + * @param err HCI error. Zero for success, non-zero otherwise. + */ + void (*connected)(struct bt_mesh_conn *conn, uint8_t err); + + /** @brief A connection has been disconnected. + * + * This callback notifies the application that a connection + * has been disconnected. + * + * @param conn Connection object. + * @param reason HCI reason for the disconnection. + */ + void (*disconnected)(struct bt_mesh_conn *conn, uint8_t reason); +}; + +struct bt_mesh_prov_conn_cb { + void (*connected)(bt_mesh_addr_t *addr, struct bt_mesh_conn *conn, int id); + + void (*disconnected)(bt_mesh_addr_t *addr, struct bt_mesh_conn *conn, uint8_t reason); + + ssize_t (*prov_write_descr)(bt_mesh_addr_t *addr, struct bt_mesh_conn *conn); + + ssize_t (*prov_notify)(struct bt_mesh_conn *conn, uint8_t *data, uint16_t len); + + ssize_t (*proxy_write_descr)(bt_mesh_addr_t *addr, struct bt_mesh_conn *conn); + + ssize_t (*proxy_notify)(struct bt_mesh_conn *conn, uint8_t *data, uint16_t len); +}; + +/** @brief GATT Attribute structure. */ +struct bt_mesh_gatt_attr { + /** Attribute UUID */ + const struct bt_mesh_uuid *uuid; + + /** Attribute read callback + * + * @param conn The connection that is requesting to read + * @param attr The attribute that's being read + * @param buf Buffer to place the read result in + * @param len Length of data to read + * @param offset Offset to start reading from + * + * @return Number fo bytes read, or in case of an error + * BLE_MESH_GATT_ERR() with a specific ATT error code. + */ + ssize_t (*read)(struct bt_mesh_conn *conn, + const struct bt_mesh_gatt_attr *attr, + void *buf, uint16_t len, + uint16_t offset); + + /** Attribute write callback + * + * @param conn The connection that is requesting to write + * @param attr The attribute that's being written + * @param buf Buffer with the data to write + * @param len Number of bytes in the buffer + * @param offset Offset to start writing from + * @param flags Flags (BT_GATT_WRITE_*) + * + * @return Number of bytes written, or in case of an error + * BLE_MESH_GATT_ERR() with a specific ATT error code. + */ + ssize_t (*write)(struct bt_mesh_conn *conn, + const struct bt_mesh_gatt_attr *attr, + const void *buf, uint16_t len, + uint16_t offset, uint8_t flags); + + /** Attribute user data */ + void *user_data; + /** Attribute handle */ + uint16_t handle; + /** Attribute permissions */ + uint8_t perm; +}; + +/** @def BLE_MESH_GATT_PRIMARY_SERVICE + * @brief Primary Service Declaration Macro. + * + * Helper macro to declare a primary service attribute. + * + * @param _service Service attribute value. + */ +#define BLE_MESH_GATT_PRIMARY_SERVICE(_service) \ +{ \ + .uuid = BLE_MESH_UUID_GATT_PRIMARY, \ + .perm = BLE_MESH_GATT_PERM_READ, \ + .read = bt_mesh_gatts_attr_read_service, \ + .user_data = _service, \ +} + +/** @def BLE_MESH_GATT_SECONDARY_SERVICE + * @brief Secondary Service Declaration Macro. + * + * Helper macro to declare a secondary service attribute. + * + * @param _service Service attribute value. + */ +#define BLE_MESH_GATT_SECONDARY_SERVICE(_service) \ +{ \ + .uuid = BLE_MESH_UUID_GATT_SECONDARY, \ + .perm = BLE_MESH_GATT_PERM_READ, \ + .read = bt_mesh_gatts_attr_read_service, \ + .user_data = _service, \ +} + +/** @def BLE_MESH_GATT_INCLUDE_SERVICE + * @brief Include Service Declaration Macro. + * + * Helper macro to declare database internal include service attribute. + * + * @param _service_incl the first service attribute of service to include + */ +#define BLE_MESH_GATT_INCLUDE_SERVICE(_service_incl) \ +{ \ + .uuid = BLE_MESH_UUID_GATT_INCLUDE, \ + .perm = BLE_MESH_GATT_PERM_READ, \ + .read = bt_mesh_gatts_attr_read_included, \ + .user_data = _service_incl, \ +} + +/** @def BLE_MESH_GATT_CHARACTERISTIC + * @brief Characteristic Declaration Macro. + * + * Helper macro to declare a characteristic attribute. + * + * @param _uuid Characteristic attribute uuid. + * @param _props Characteristic attribute properties. + */ +#define BLE_MESH_GATT_CHARACTERISTIC(_uuid, _props) \ +{ \ + .uuid = BLE_MESH_UUID_GATT_CHRC, \ + .perm = BLE_MESH_GATT_PERM_READ, \ + .read = bt_mesh_gatts_attr_read_chrc, \ + .user_data = (&(struct bt_mesh_gatt_char) { .uuid = _uuid, \ + .properties = _props, }), \ +} + +/** @def BLE_MESH_GATT_DESCRIPTOR + * @brief Descriptor Declaration Macro. + * + * Helper macro to declare a descriptor attribute. + * + * @param _uuid Descriptor attribute uuid. + * @param _perm Descriptor attribute access permissions. + * @param _read Descriptor attribute read callback. + * @param _write Descriptor attribute write callback. + * @param _value Descriptor attribute value. + */ +#define BLE_MESH_GATT_DESCRIPTOR(_uuid, _perm, _read, _write, _value) \ +{ \ + .uuid = _uuid, \ + .perm = _perm, \ + .read = _read, \ + .write = _write, \ + .user_data = _value, \ +} + +/** @def BLE_MESH_GATT_SERVICE + * @brief Service Structure Declaration Macro. + * + * Helper macro to declare a service structure. + * + * @param _attrs Service attributes. + */ +#define BLE_MESH_GATT_SERVICE(_attrs) \ +{ \ + .attrs = _attrs, \ + .attr_count = ARRAY_SIZE(_attrs), \ +} + +int bt_mesh_host_init(void); + +int bt_le_adv_start(const struct bt_mesh_adv_param *param, + const struct bt_mesh_adv_data *ad, size_t ad_len, + const struct bt_mesh_adv_data *sd, size_t sd_len); + +#if CONFIG_BLE_MESH_SUPPORT_BLE_ADV +int bt_mesh_ble_adv_start(const struct bt_mesh_ble_adv_param *param, + const struct bt_mesh_ble_adv_data *data); +#endif + +int bt_le_adv_stop(void); + +int bt_le_scan_start(const struct bt_mesh_scan_param *param, bt_mesh_scan_cb_t cb); + +int bt_le_scan_stop(void); + +typedef enum { + BLE_MESH_WHITELIST_REMOVE, + BLE_MESH_WHITELIST_ADD, +} bt_mesh_wl_operation; + +struct bt_mesh_white_list { + bool add_remove; + uint8_t remote_bda[BLE_MESH_ADDR_LEN]; + uint8_t addr_type; + /* For Bluedroid host, this callback is used to notify the + * result of updating white list. + */ + void (*update_wl_comp_cb)(uint8_t status, bt_mesh_wl_operation wl_operation); +}; + +int bt_le_update_white_list(struct bt_mesh_white_list *wl); + +void bt_mesh_gatts_conn_cb_register(struct bt_mesh_conn_cb *cb); +void bt_mesh_gatts_conn_cb_deregister(void); + +int bt_mesh_gatts_disconnect(struct bt_mesh_conn *conn, uint8_t reason); + +int bt_mesh_gatts_service_register(struct bt_mesh_gatt_service *svc); +int bt_mesh_gatts_service_deregister(struct bt_mesh_gatt_service *svc); + +int bt_mesh_gatts_service_unregister(struct bt_mesh_gatt_service *svc); + +ssize_t bt_mesh_gatts_attr_read_included(struct bt_mesh_conn *conn, + const struct bt_mesh_gatt_attr *attr, + void *buf, uint16_t len, uint16_t offset); + +ssize_t bt_mesh_gatts_attr_read(struct bt_mesh_conn *conn, + const struct bt_mesh_gatt_attr *attr, + void *buf, uint16_t buf_len, uint16_t offset, + const void *value, uint16_t value_len); + +ssize_t bt_mesh_gatts_attr_read_service(struct bt_mesh_conn *conn, + const struct bt_mesh_gatt_attr *attr, + void *buf, uint16_t len, uint16_t offset); + +ssize_t bt_mesh_gatts_attr_read_chrc(struct bt_mesh_conn *conn, + const struct bt_mesh_gatt_attr *attr, + void *buf, uint16_t len, uint16_t offset); + +int bt_mesh_gatts_notify(struct bt_mesh_conn *conn, + const struct bt_mesh_gatt_attr *attr, + const void *data, uint16_t len); + +uint16_t bt_mesh_gatt_get_mtu(struct bt_mesh_conn *conn); + +/** APIs added by Espressif */ +int bt_mesh_gatts_service_stop(struct bt_mesh_gatt_service *svc); +int bt_mesh_gatts_service_start(struct bt_mesh_gatt_service *svc); + +int bt_mesh_gatts_set_local_device_name(const char *name); + +void bt_mesh_gattc_conn_cb_register(struct bt_mesh_prov_conn_cb *cb); +void bt_mesh_gattc_conn_cb_deregister(void); + +uint8_t bt_mesh_gattc_get_free_conn_count(void); + +uint16_t bt_mesh_gattc_get_service_uuid(struct bt_mesh_conn *conn); + +int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, uint16_t service_uuid); + +void bt_gattc_conn_close(struct bt_mesh_conn *conn); + +void bt_mesh_gattc_exchange_mtu(uint8_t index); + +uint16_t bt_mesh_gattc_get_mtu_info(struct bt_mesh_conn *conn); + +int bt_mesh_gattc_write_no_rsp(struct bt_mesh_conn *conn, + const struct bt_mesh_gatt_attr *attr, + const void *data, uint16_t len); + +void bt_mesh_gattc_disconnect(struct bt_mesh_conn *conn); + +struct bt_mesh_conn *bt_mesh_conn_ref(struct bt_mesh_conn *conn); + +void bt_mesh_conn_unref(struct bt_mesh_conn *conn); + +void bt_mesh_gatt_init(void); +void bt_mesh_gatt_deinit(void); + +void bt_mesh_adapt_init(void); + +void bt_mesh_set_private_key(const uint8_t pri_key[32]); + +const uint8_t *bt_mesh_pub_key_get(void); + +bool bt_mesh_check_public_key(const uint8_t key[64]); + +int bt_mesh_dh_key_gen(const uint8_t remote_pk[64], bt_mesh_dh_key_cb_t cb, const uint8_t idx); + +int bt_mesh_encrypt_le(const uint8_t key[16], const uint8_t plaintext[16], + uint8_t enc_data[16]); + +int bt_mesh_encrypt_be(const uint8_t key[16], const uint8_t plaintext[16], + uint8_t enc_data[16]); + +enum { + BLE_MESH_EXCEP_LIST_ADD = 0, + BLE_MESH_EXCEP_LIST_REMOVE, + BLE_MESH_EXCEP_LIST_CLEAN, +}; + +enum { + BLE_MESH_EXCEP_INFO_ADV_ADDR = 0, + BLE_MESH_EXCEP_INFO_MESH_LINK_ID, + BLE_MESH_EXCEP_INFO_MESH_BEACON, + BLE_MESH_EXCEP_INFO_MESH_PROV_ADV, + BLE_MESH_EXCEP_INFO_MESH_PROXY_ADV, +}; + +enum { + BLE_MESH_EXCEP_CLEAN_ADDR_LIST = BIT(0), + BLE_MESH_EXCEP_CLEAN_MESH_LINK_ID_LIST = BIT(1), + BLE_MESH_EXCEP_CLEAN_MESH_BEACON_LIST = BIT(2), + BLE_MESH_EXCEP_CLEAN_MESH_PROV_ADV_LIST = BIT(3), + BLE_MESH_EXCEP_CLEAN_MESH_PROXY_ADV_LIST = BIT(4), + BLE_MESH_EXCEP_CLEAN_ALL_LIST = 0xFFFF, +}; + +int bt_mesh_update_exceptional_list(uint8_t sub_code, uint8_t type, void *info); + +#ifdef __cplusplus +} +#endif + +#endif /* _BLE_MESH_BEARER_ADAPT_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/include/mesh_hci.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/include/mesh_hci.h new file mode 100644 index 00000000000..860d575c2bd --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/include/mesh_hci.h @@ -0,0 +1,133 @@ +/* + * SPDX-FileCopyrightText: 2015-2016 Intel Corporation + * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#ifndef _BLE_MESH_HCI_H_ +#define _BLE_MESH_HCI_H_ + +#include "mesh_atomic.h" +#include "mesh_bearer_adapt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Porting form zephyr/subsys/bluetooth/host/hci_core.h */ + +#define BLE_MESH_LMP_FEAT_PAGES_COUNT 1 + +/* bt_mesh_dev flags: the flags defined here represent BT controller state */ +enum { + BLE_MESH_DEV_ENABLE, + BLE_MESH_DEV_READY, + BLE_MESH_DEV_ID_STATIC_RANDOM, + BLE_MESH_DEV_HAS_PUB_KEY, + BLE_MESH_DEV_PUB_KEY_BUSY, + + BLE_MESH_DEV_ADVERTISING, + BLE_MESH_DEV_KEEP_ADVERTISING, + BLE_MESH_DEV_SCANNING, + BLE_MESH_DEV_EXPLICIT_SCAN, + BLE_MESH_DEV_ACTIVE_SCAN, + BLE_MESH_DEV_SCAN_FILTER_DUP, + + BLE_MESH_DEV_RPA_VALID, + + BLE_MESH_DEV_ID_PENDING, + + /* Total number of flags - must be at the end of the enum */ + BLE_MESH_DEV_NUM_FLAGS, +}; + +struct bt_mesh_dev_le { + /* LE features */ + uint8_t features[8]; + + /* LE states */ + uint64_t states; +}; + +/* State tracking for the local Bluetooth controller */ +struct bt_mesh_dev { + /* Flags indicate which functionality is enabled */ + BLE_MESH_ATOMIC_DEFINE(flags, BLE_MESH_DEV_NUM_FLAGS); + + /* Controller version & manufacturer information */ + uint8_t hci_version; + uint8_t lmp_version; + uint16_t hci_revision; + uint16_t lmp_subversion; + uint16_t manufacturer; + + /* LMP features (pages 0, 1, 2) */ + uint8_t features[BLE_MESH_LMP_FEAT_PAGES_COUNT][8]; + + /* LE controller specific features */ + struct bt_mesh_dev_le le; +}; + +/*Porting from zephyr/subsys/bluetooth/host/hci_core.h */ +/* HCI version from Assigned Numbers */ +#define BLE_MESH_HCI_VERSION_1_0B 0 +#define BLE_MESH_HCI_VERSION_1_1 1 +#define BLE_MESH_HCI_VERSION_1_2 2 +#define BLE_MESH_HCI_VERSION_2_0 3 +#define BLE_MESH_HCI_VERSION_2_1 4 +#define BLE_MESH_HCI_VERSION_3_0 5 +#define BLE_MESH_HCI_VERSION_4_0 6 +#define BLE_MESH_HCI_VERSION_4_1 7 +#define BLE_MESH_HCI_VERSION_4_2 8 +#define BLE_MESH_HCI_VERSION_5_0 9 + +/* OpCode Group Fields */ +#define BLE_MESH_OGF_LINK_CTRL 0x01 +#define BLE_MESH_OGF_BASEBAND 0x03 +#define BLE_MESH_OGF_INFO 0x04 +#define BLE_MESH_OGF_STATUS 0x05 +#define BLE_MESH_OGF_LE 0x08 +#define BLE_MESH_OGF_VS 0x3f + +/* Construct OpCode from OGF and OCF */ +#define BLE_MESH_OP(ogf, ocf) ((ocf) | ((ogf) << 10)) + +/* Obtain OGF from OpCode */ +#define BLE_MESH_OGF(opcode) (((opcode) >> 10) & BIT_MASK(6)) + +/* Obtain OCF from OpCode */ +#define BLE_MESH_OCF(opcode) ((opcode) & BIT_MASK(10)) + +#define BLE_MESH_HCI_OP_SET_ADV_PARAM BLE_MESH_OP(BLE_MESH_OGF_LE, 0x0006) +struct bt_mesh_hci_cp_set_adv_param { + uint16_t min_interval; + uint16_t max_interval; + uint8_t type; + uint8_t own_addr_type; + bt_mesh_addr_t direct_addr; + uint8_t channel_map; + uint8_t filter_policy; +} __packed; + +#define BLE_MESH_HCI_OP_SET_ADV_DATA BLE_MESH_OP(BLE_MESH_OGF_LE, 0x0008) +struct bt_mesh_hci_cp_set_adv_data { + uint8_t len; + uint8_t data[31]; +} __packed; + +#define BLE_MESH_HCI_OP_SET_SCAN_RSP_DATA BLE_MESH_OP(BLE_MESH_OGF_LE, 0x0009) +struct bt_mesh_hci_cp_set_scan_rsp_data { + uint8_t len; + uint8_t data[31]; +} __packed; + +/* Added by Espressif */ +extern struct bt_mesh_dev bt_mesh_dev; + +void bt_mesh_hci_init(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _BLE_MESH_HCI_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/include/mesh_main.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/include/mesh_main.h new file mode 100644 index 00000000000..ff41994a8e7 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/include/mesh_main.h @@ -0,0 +1,635 @@ +/** @file + * @brief Bluetooth Mesh Profile APIs. + */ + +/* + * SPDX-FileCopyrightText: 2017 Intel Corporation + * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#ifndef _BLE_MESH_MAIN_H_ +#define _BLE_MESH_MAIN_H_ + +#include "mesh_access.h" + +/** + * @brief Bluetooth Mesh Provisioning + * @defgroup bt_mesh_prov Bluetooth Mesh Provisioning + * @ingroup bt_mesh + * @{ + */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + BLE_MESH_NO_OUTPUT = 0, + BLE_MESH_BLINK = BIT(0), + BLE_MESH_BEEP = BIT(1), + BLE_MESH_VIBRATE = BIT(2), + BLE_MESH_DISPLAY_NUMBER = BIT(3), + BLE_MESH_DISPLAY_STRING = BIT(4), +} bt_mesh_output_action_t; + +typedef enum { + BLE_MESH_NO_INPUT = 0, + BLE_MESH_PUSH = BIT(0), + BLE_MESH_TWIST = BIT(1), + BLE_MESH_ENTER_NUMBER = BIT(2), + BLE_MESH_ENTER_STRING = BIT(3), +} bt_mesh_input_action_t; + +typedef enum { + BLE_MESH_PROV_ADV = BIT(0), + BLE_MESH_PROV_GATT = BIT(1), +} bt_mesh_prov_bearer_t; + +typedef enum { + BLE_MESH_PROV_OOB_OTHER = BIT(0), + BLE_MESH_PROV_OOB_URI = BIT(1), + BLE_MESH_PROV_OOB_2D_CODE = BIT(2), + BLE_MESH_PROV_OOB_BAR_CODE = BIT(3), + BLE_MESH_PROV_OOB_NFC = BIT(4), + BLE_MESH_PROV_OOB_NUMBER = BIT(5), + BLE_MESH_PROV_OOB_STRING = BIT(6), + /* 7 - 10 are reserved */ + BLE_MESH_PROV_OOB_ON_BOX = BIT(11), + BLE_MESH_PROV_OOB_IN_BOX = BIT(12), + BLE_MESH_PROV_OOB_ON_PAPER = BIT(13), + BLE_MESH_PROV_OOB_IN_MANUAL = BIT(14), + BLE_MESH_PROV_OOB_ON_DEV = BIT(15), +} bt_mesh_prov_oob_info_t; + +#define BLE_MESH_PROV_STATIC_OOB_MAX_LEN 16 +#define BLE_MESH_PROV_OUTPUT_OOB_MAX_LEN 8 +#define BLE_MESH_PROV_INPUT_OOB_MAX_LEN 8 + +/** Provisioning properties & capabilities. */ +struct bt_mesh_prov { +#if CONFIG_BLE_MESH_NODE + /** The UUID that's used when advertising as unprovisioned */ + const uint8_t *uuid; + + /** Optional URI. This will be advertised separately from the + * unprovisioned beacon, however the unprovisioned beacon will + * contain a hash of it so the two can be associated by the + * provisioner. + */ + const char *uri; + + /** Out of Band information field. */ + bt_mesh_prov_oob_info_t oob_info; + + /** Flag indicates whether unprovisioned devices support OOB public key */ + bool oob_pub_key; + + /** @brief Set device OOB public key. + * + * This callback notifies the application to + * set OOB public key & private key pair. + */ + void (*oob_pub_key_cb)(void); + + /** Static OOB value */ + const uint8_t *static_val; + /** Static OOB value length */ + uint8_t static_val_len; + + /** Maximum size of Output OOB supported */ + uint8_t output_size; + /** Supported Output OOB Actions */ + uint16_t output_actions; + + /* Maximum size of Input OOB supported */ + uint8_t input_size; + /** Supported Input OOB Actions */ + uint16_t input_actions; + + /** @brief Output of a number is requested. + * + * This callback notifies the application to + * output the given number using the given action. + * + * @param act Action for outputting the number. + * @param num Number to be out-put. + * + * @return Zero on success or negative error code otherwise + */ + int (*output_number)(bt_mesh_output_action_t act, uint32_t num); + + /** @brief Output of a string is requested. + * + * This callback notifies the application to + * display the given string to the user. + * + * @param str String to be displayed. + * + * @return Zero on success or negative error code otherwise + */ + int (*output_string)(const char *str); + + /** @brief Input is requested. + * + * This callback notifies the application to request + * input from the user using the given action. The + * requested input will either be a string or a number, and + * the application needs to consequently call the + * bt_mesh_input_string() or bt_mesh_input_number() functions + * once the data has been acquired from the user. + * + * @param act Action for inputting data. + * @param num Maximum size of the in-put data. + * + * @return Zero on success or negative error code otherwise + */ + int (*input)(bt_mesh_input_action_t act, uint8_t size); + + /** @brief Provisioning link has been opened. + * + * This callback notifies the application that a provisioning + * link has been opened on the given provisioning bearer. + * + * @param bearer Provisioning bearer. + */ + void (*link_open)(bt_mesh_prov_bearer_t bearer); + + /** @brief Provisioning link has been closed. + * + * This callback notifies the application that a provisioning + * link has been closed on the given provisioning bearer. + * + * @param bearer Provisioning bearer. + */ + void (*link_close)(bt_mesh_prov_bearer_t bearer); + + /** @brief Provisioning is complete. + * + * This callback notifies the application that provisioning has + * been successfully completed, and that the local node has been + * assigned the specified NetKeyIndex and primary element address. + * + * @param net_idx NetKeyIndex given during provisioning. + * @param net_key NetKey given during provisioning. + * @param addr Primary element address. + * @param flags Key Refresh & IV Update flags + * @param iv_index IV Index. + */ + void (*complete)(uint16_t net_idx, const uint8_t net_key[16], uint16_t addr, uint8_t flags, uint32_t iv_index); + + /** @brief Node has been reset. + * + * This callback notifies the application that the local node + * has been reset and needs to be reprovisioned. The node will + * not automatically advertise as unprovisioned, rather the + * bt_mesh_prov_enable() API needs to be called to enable + * unprovisioned advertising on one or more provisioning bearers. + */ + void (*reset)(void); +#endif /* CONFIG_BLE_MESH_NODE */ + +#if CONFIG_BLE_MESH_PROVISIONER + /* Provisioner device uuid */ + const uint8_t *prov_uuid; + + /* + * Primary element address of the provisioner. + * No need to initialize it for fast provisioning. + */ + const uint16_t prov_unicast_addr; + + /* + * Starting unicast address going to assigned. + * No need to initialize it for fast provisioning. + */ + uint16_t prov_start_address; + + /* Attention timer contained in Provisioning Invite */ + uint8_t prov_attention; + + /* Provisioner provisioning Algorithm */ + uint8_t prov_algorithm; + + /* Provisioner public key oob */ + uint8_t prov_pub_key_oob; + + /** @brief Input is requested. + * + * This callback notifies the application that it should + * read device's public key with OOB + * + * @param link_idx: The provisioning link index + * + * @return Zero on success or negative error code otherwise + */ + int (*prov_pub_key_oob_cb)(uint8_t link_idx); + + /* Provisioner static oob value */ + uint8_t *prov_static_oob_val; + + /* Provisioner static oob value length */ + uint8_t prov_static_oob_len; + + /** @brief Provisioner input a number read from device output + * + * This callback notifies the application that it should + * input the number given by the device. + * + * @param method: The OOB authentication method + * @param act: The output action of the device + * @param size: The output size of the device + * @param link_idx: The provisioning link index + * + * @return Zero on success or negative error code otherwise + */ + int (*prov_input_num)(uint8_t method, bt_mesh_output_action_t act, uint8_t size, uint8_t link_idx); + + /** @brief Provisioner output a number to the device + * + * This callback notifies the application that it should + * output the number to the device. + * + * @param method: The OOB authentication method + * @param act: The input action of the device + * @param data: The input number/string of the device + * @param size: The input size of the device + * @param link_idx: The provisioning link index + * + * @return Zero on success or negative error code otherwise + */ + int (*prov_output_num)(uint8_t method, bt_mesh_input_action_t act, void *data, uint8_t size, uint8_t link_idx); + + /* + * Key refresh and IV update flag. + * No need to initialize it for fast provisioning. + */ + uint8_t flags; + + /* + * IV index. No need to initialize it for fast provisioning. + */ + uint32_t iv_index; + + /** @brief Provisioner has opened a provisioning link. + * + * This callback notifies the application that a provisioning + * link has been opened on the given provisioning bearer. + * + * @param bearer Provisioning bearer. + */ + void (*prov_link_open)(bt_mesh_prov_bearer_t bearer); + + /** @brief Provisioner has closed a provisioning link. + * + * This callback notifies the application that a provisioning + * link has been closed on the given provisioning bearer. + * + * @param bearer Provisioning bearer. + * @param reason Provisioning link close reason(disconnect reason) + */ + void (*prov_link_close)(bt_mesh_prov_bearer_t bearer, uint8_t reason); + + /** @brief Provision one device is complete. + * + * This callback notifies the application that provisioner has + * successfully provisioned a device, and the node has been assigned + * the specified NetKeyIndex and primary element address. + * + * @param node_idx Node index within the node(provisioned device) queue. + * @param device_uuid Provisioned device uuid pointer. + * @param unicast_addr Provisioned device assigned unicast address. + * @param element_num Provisioned device element number. + * @param netkey_idx Provisioned device assigned netkey index. + */ + void (*prov_complete)(uint16_t node_idx, const uint8_t device_uuid[16], + uint16_t unicast_addr, uint8_t element_num, + uint16_t netkey_idx); +#endif /* CONFIG_BLE_MESH_PROVISIONER */ +}; + +enum ble_mesh_role { + NODE = 0, + PROVISIONER, + FAST_PROV, + ROLE_NVAL, +}; + +/* The following APIs are for BLE Mesh Node */ + +/** @brief Provide provisioning input OOB string. + * + * This is intended to be called after the bt_mesh_prov input callback + * has been called with BLE_MESH_ENTER_STRING as the action. + * + * @param str String. + * + * @return Zero on success or (negative) error code otherwise. + */ +int bt_mesh_input_string(const char *str); + +/** @brief Provide provisioning input OOB number. + * + * This is intended to be called after the bt_mesh_prov input callback + * has been called with BLE_MESH_ENTER_NUMBER as the action. + * + * @param num Number. + * + * @return Zero on success or (negative) error code otherwise. + */ +int bt_mesh_input_number(uint32_t num); + +/** @brief Enable specific provisioning bearers + * + * Enable one or more provisioning bearers. + * + * @param Bit-wise OR of provisioning bearers. + * + * @return Zero on success or (negative) error code otherwise. + */ +int bt_mesh_prov_enable(bt_mesh_prov_bearer_t bearers); + +/** @brief Disable specific provisioning bearers + * + * Disable one or more provisioning bearers. + * + * @param Bit-wise OR of provisioning bearers. + * + * @return Zero on success or (negative) error code otherwise. + */ +int bt_mesh_prov_disable(bt_mesh_prov_bearer_t bearers); + +/* The following APIs are for BLE Mesh Provisioner */ + +/** @brief Provide provisioning input OOB string. + * + * This is intended to be called after the bt_mesh_prov input callback + * has been called with BLE_MESH_ENTER_STRING as the action. + * + * @param str String. + * + * @return Zero on success or (negative) error code otherwise. + */ +int bt_mesh_prov_input_string(const char *str); + +/** @brief Provide provisioning input OOB number. + * + * This is intended to be called after the bt_mesh_prov input callback + * has been called with BLE_MESH_ENTER_NUMBER as the action. + * + * @param num Number. + * + * @return Zero on success or (negative) error code otherwise. + */ +int bt_mesh_prov_input_number(uint32_t num); + +/** @brief Enable specific provisioning bearers + * + * Enable one or more provisioning bearers. + * + * @param bearers Bit-wise OR of provisioning bearers. + * + * @return Zero on success or (negative) error code otherwise. + */ +int bt_mesh_provisioner_enable(bt_mesh_prov_bearer_t bearers); + +/** @brief Disable specific provisioning bearers + * + * Disable one or more provisioning bearers. + * + * @param bearers Bit-wise OR of provisioning bearers. + * + * @return Zero on success or (negative) error code otherwise. + */ +int bt_mesh_provisioner_disable(bt_mesh_prov_bearer_t bearers); + +/** + * @} + */ + +/** + * @brief Bluetooth Mesh + * @defgroup bt_mesh Bluetooth Mesh + * @ingroup bluetooth + * @{ + */ + +/* Primary Network Key index */ +#define BLE_MESH_NET_PRIMARY 0x000 + +#define BLE_MESH_RELAY_DISABLED 0x00 +#define BLE_MESH_RELAY_ENABLED 0x01 +#define BLE_MESH_RELAY_NOT_SUPPORTED 0x02 + +#define BLE_MESH_BEACON_DISABLED 0x00 +#define BLE_MESH_BEACON_ENABLED 0x01 + +#define BLE_MESH_GATT_PROXY_DISABLED 0x00 +#define BLE_MESH_GATT_PROXY_ENABLED 0x01 +#define BLE_MESH_GATT_PROXY_NOT_SUPPORTED 0x02 + +#define BLE_MESH_FRIEND_DISABLED 0x00 +#define BLE_MESH_FRIEND_ENABLED 0x01 +#define BLE_MESH_FRIEND_NOT_SUPPORTED 0x02 + +#define BLE_MESH_NODE_IDENTITY_STOPPED 0x00 +#define BLE_MESH_NODE_IDENTITY_RUNNING 0x01 +#define BLE_MESH_NODE_IDENTITY_NOT_SUPPORTED 0x02 + +/* Features */ +#define BLE_MESH_FEAT_RELAY BIT(0) +#define BLE_MESH_FEAT_PROXY BIT(1) +#define BLE_MESH_FEAT_FRIEND BIT(2) +#define BLE_MESH_FEAT_LOW_POWER BIT(3) +#define BLE_MESH_FEAT_SUPPORTED (BLE_MESH_FEAT_RELAY | \ + BLE_MESH_FEAT_PROXY | \ + BLE_MESH_FEAT_FRIEND | \ + BLE_MESH_FEAT_LOW_POWER) + +/** @brief Check if the mesh stack is initialized. + * + * @return true - yes, false - no. + */ +bool bt_mesh_is_initialized(void); + +/** @brief Initialize Mesh support + * + * After calling this API, the node will not automatically advertise as + * unprovisioned, rather the bt_mesh_prov_enable() API needs to be called + * to enable unprovisioned advertising on one or more provisioning bearers. + * + * @param prov Node provisioning information. + * @param comp Node Composition. + * + * @return Zero on success or (negative) error code otherwise. + */ +int bt_mesh_init(const struct bt_mesh_prov *prov, + const struct bt_mesh_comp *comp); + +/* BLE Mesh deinit parameters */ +struct bt_mesh_deinit_param { + bool erase; /* Indicate if erasing flash when deinit mesh stack */ +}; + +/** @brief De-initialize Mesh support + * + * @param param BLE Mesh deinit parameters. + * + * @return Zero on success or (negative) error code otherwise. + */ +int bt_mesh_deinit(struct bt_mesh_deinit_param *param); + +/** @brief Reset the state of the local Mesh node. + * + * Resets the state of the node, which means that it needs to be + * reprovisioned to become an active node in a Mesh network again. + * + * After calling this API, the node will not automatically advertise as + * unprovisioned, rather the bt_mesh_prov_enable() API needs to be called + * to enable unprovisioned advertising on one or more provisioning bearers. + * + */ +void bt_mesh_node_reset(void); + +/** @brief Suspend the Mesh network temporarily. + * + * This API can be used for power saving purposes, but the user should be + * aware that leaving the local node suspended for a long period of time + * may cause it to become permanently disconnected from the Mesh network. + * If at all possible, the Friendship feature should be used instead, to + * make the node into a Low Power Node. + * + * @return 0 on success, or (negative) error code on failure. + */ +int bt_mesh_suspend(void); + +/** @brief Resume a suspended Mesh network. + * + * This API resumes the local node, after it has been suspended using the + * bt_mesh_suspend() API. + * + * @return 0 on success, or (negative) error code on failure. + */ +int bt_mesh_resume(void); + +/** @brief Provision the local Mesh Node. + * + * This API should normally not be used directly by the application. The + * only exception is for testing purposes where manual provisioning is + * desired without an actual external provisioner. + * + * @param net_key Network Key + * @param net_idx Network Key Index + * @param flags Provisioning Flags + * @param iv_index IV Index + * @param addr Primary element address + * @param dev_key Device Key + * + * @return Zero on success or (negative) error code otherwise. + */ +int bt_mesh_provision(const uint8_t net_key[16], uint16_t net_idx, + uint8_t flags, uint32_t iv_index, uint16_t addr, + const uint8_t dev_key[16]); + +/** @brief Check if the device is an unprovisioned device + * and will act as a node once provisioned. + * + * @return true - yes, false - no. + */ +bool bt_mesh_is_node(void); + +/** @brief Check if the local node has been provisioned. + * + * This API can be used to check if the local node has been provisioned + * or not. It can e.g. be helpful to determine if there was a stored + * network in flash, i.e. if the network was restored after calling + * settings_load(). + * + * @return True if the node is provisioned. False otherwise. + */ +bool bt_mesh_is_provisioned(void); + +/** @brief Check if the device is a Provisioner. + * + * @return true - yes, false - no. + */ +bool bt_mesh_is_provisioner(void); + +/** @brief Check if the Provisioner is enabled + * + * @return true - enabled, false - disabled. + */ +bool bt_mesh_is_provisioner_en(void); + +/** @brief Toggle the IV Update test mode + * + * This API is only available if the IV Update test mode has been enabled + * in Kconfig. It is needed for passing most of the IV Update qualification + * test cases. + * + * @param enable true to enable IV Update test mode, false to disable it. + */ +void bt_mesh_iv_update_test(bool enable); + +/** @brief Toggle the IV Update state + * + * This API is only available if the IV Update test mode has been enabled + * in Kconfig. It is needed for passing most of the IV Update qualification + * test cases. + * + * @return true if IV Update In Progress state was entered, false otherwise. + */ +bool bt_mesh_iv_update(void); + +/** @brief Toggle the Low Power feature of the local device + * + * Enables or disables the Low Power feature of the local device. This is + * exposed as a run-time feature, since the device might want to change + * this e.g. based on being plugged into a stable power source or running + * from a battery power source. + * + * @param enable true to enable LPN functionality, false to disable it. + * @param force when disable LPN functionality, use this flag to indicate + * whether directly clear corresponding information or sending + * friend clear to disable it. + * + * @return Zero on success or (negative) error code otherwise. + */ +int bt_mesh_lpn_set(bool enable, bool force); + +/** @brief Send out a Friend Poll message. + * + * Send a Friend Poll message to the Friend of this node. If there is no + * established Friendship the function will return an error. + * + * @return Zero on success or (negative) error code otherwise. + */ +int bt_mesh_lpn_poll(void); + +/** @brief Register a callback for Friendship changes. + * + * Registers a callback that will be called whenever Friendship gets + * established or is lost. + * + * @param cb Function to call when the Friendship status changes. + */ +void bt_mesh_lpn_set_cb(void (*cb)(uint16_t friend_addr, bool established)); + +/** @brief Register a callback for Friendship changes of friend node. + * + * Registers a callback that will be called whenever Friendship gets + * established or is terminated. + * + * @param cb Function to call when the Friendship status of friend node changes. + */ +void bt_mesh_friend_set_cb(void (*cb)(bool establish, uint16_t lpn_addr, uint8_t reason)); + +#ifdef __cplusplus +} +#endif + +/** + * @} + */ + +#endif /* _BLE_MESH_MAIN_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/include/mesh_proxy.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/include/mesh_proxy.h new file mode 100644 index 00000000000..3bdf5c405c0 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/include/mesh_proxy.h @@ -0,0 +1,45 @@ +/** @file + * @brief Bluetooth Mesh Proxy APIs. + */ + +/* + * SPDX-FileCopyrightText: 2017 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _BLE_MESH_PROXY_H_ +#define _BLE_MESH_PROXY_H_ + +#include +/** + * @brief Bluetooth Mesh Proxy + * @defgroup bt_mesh_proxy Bluetooth Mesh Proxy + * @ingroup bt_mesh + * @{ + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Enable advertising with Node Identity. + * + * This API requires that GATT Proxy support has been enabled. Once called + * each subnet will start advertising using Node Identity for the next + * 60 seconds. + * + * @return 0 on success, or (negative) error code on failure. + */ +int bt_mesh_proxy_identity_enable(void); + +#ifdef __cplusplus +} +#endif + +/** + * @} + */ + +#endif /* _BLE_MESH_PROXY_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/include/mesh_uuid.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/include/mesh_uuid.h new file mode 100644 index 00000000000..b3d207cbe88 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/include/mesh_uuid.h @@ -0,0 +1,530 @@ +/** @file + * @brief Bluetooth UUID handling + */ + +/* + * SPDX-FileCopyrightText: 2015-2016 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ +#ifndef _BLE_MESH_UUID_H_ +#define _BLE_MESH_UUID_H_ + +/** + * @brief UUIDs + * @defgroup bt_uuid UUIDs + * @ingroup bluetooth + * @{ + */ + +#include "mesh_util.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** @brief Bluetooth UUID types */ +enum { + BLE_MESH_UUID_TYPE_16, + BLE_MESH_UUID_TYPE_32, + BLE_MESH_UUID_TYPE_128, +}; + +/** @brief This is a 'tentative' type and should be used as a pointer only */ +struct bt_mesh_uuid { + uint8_t type; +}; + +struct bt_mesh_uuid_16 { + struct bt_mesh_uuid uuid; + uint16_t val; +}; + +struct bt_mesh_uuid_32 { + struct bt_mesh_uuid uuid; + uint32_t val; +}; + +struct bt_mesh_uuid_128 { + struct bt_mesh_uuid uuid; + uint8_t val[16]; +}; + +#define BLE_MESH_UUID_INIT_16(value) \ +{ \ + .uuid.type = BLE_MESH_UUID_TYPE_16, \ + .val = (value), \ +} + +#define BLE_MESH_UUID_INIT_32(value) \ +{ \ + .uuid.type = BLE_MESH_UUID_TYPE_32, \ + .val = (value), \ +} + +#define BLE_MESH_UUID_INIT_128(value...) \ +{ \ + .uuid.type = BLE_MESH_UUID_TYPE_128, \ + .val = { value }, \ +} + +#define BLE_MESH_UUID_DECLARE_16(value) \ + ((struct bt_mesh_uuid *) (&(struct bt_mesh_uuid_16) BLE_MESH_UUID_INIT_16(value))) + +#define BLE_MESH_UUID_DECLARE_32(value) \ + ((struct bt_mesh_uuid *) (&(struct bt_mesh_uuid_32) BLE_MESH_UUID_INIT_32(value))) + +#define BLE_MESH_UUID_DECLARE_128(value...) \ + ((struct bt_mesh_uuid *) (&(struct bt_mesh_uuid_128) BLE_MESH_UUID_INIT_128(value))) + +#define BLE_MESH_UUID_16(__u) CONTAINER_OF(__u, struct bt_mesh_uuid_16, uuid) +#define BLE_MESH_UUID_32(__u) CONTAINER_OF(__u, struct bt_mesh_uuid_32, uuid) +#define BLE_MESH_UUID_128(__u) CONTAINER_OF(__u, struct bt_mesh_uuid_128, uuid) + +/** @def BLE_MESH_UUID_GAP + * @brief Generic Access + */ +#define BLE_MESH_UUID_GAP BLE_MESH_UUID_DECLARE_16(0x1800) +#define BLE_MESH_UUID_GAP_VAL 0x1800 +/** @def BLE_MESH_UUID_GATT + * @brief Generic Attribute + */ +#define BLE_MESH_UUID_GATT BLE_MESH_UUID_DECLARE_16(0x1801) +#define BLE_MESH_UUID_GATT_VAL 0x1801 +/** @def BLE_MESH_UUID_CTS + * @brief Current Time Service + */ +#define BLE_MESH_UUID_CTS BLE_MESH_UUID_DECLARE_16(0x1805) +#define BLE_MESH_UUID_CTS_VAL 0x1805 +/** @def BLE_MESH_UUID_DIS + * @brief Device Information Service + */ +#define BLE_MESH_UUID_DIS BLE_MESH_UUID_DECLARE_16(0x180a) +#define BLE_MESH_UUID_DIS_VAL 0x180a +/** @def BLE_MESH_UUID_HRS + * @brief Heart Rate Service + */ +#define BLE_MESH_UUID_HRS BLE_MESH_UUID_DECLARE_16(0x180d) +#define BLE_MESH_UUID_HRS_VAL 0x180d +/** @def BLE_MESH_UUID_BAS + * @brief Battery Service + */ +#define BLE_MESH_UUID_BAS BLE_MESH_UUID_DECLARE_16(0x180f) +#define BLE_MESH_UUID_BAS_VAL 0x180f +/** @def BLE_MESH_UUID_HIDS + * @brief HID Service + */ +#define BLE_MESH_UUID_HIDS BLE_MESH_UUID_DECLARE_16(0x1812) +#define BLE_MESH_UUID_HIDS_VAL 0x1812 +/** @def BLE_MESH_UUID_CSC + * @brief Cycling Speed and Cadence Service + */ +#define BLE_MESH_UUID_CSC BLE_MESH_UUID_DECLARE_16(0x1816) +#define BLE_MESH_UUID_CSC_VAL 0x1816 +/** @def BLE_MESH_UUID_ESS + * @brief Environmental Sensing Service + */ +#define BLE_MESH_UUID_ESS BLE_MESH_UUID_DECLARE_16(0x181a) +#define BLE_MESH_UUID_ESS_VAL 0x181a +/** @def BLE_MESH_UUID_IPSS + * @brief IP Support Service + */ +#define BLE_MESH_UUID_IPSS BLE_MESH_UUID_DECLARE_16(0x1820) +#define BLE_MESH_UUID_IPSS_VAL 0x1820 +/** @def BLE_MESH_UUID_MESH_PROV + * @brief Mesh Provisioning Service + */ +#define BLE_MESH_UUID_MESH_PROV BLE_MESH_UUID_DECLARE_16(0x1827) +#define BLE_MESH_UUID_MESH_PROV_VAL 0x1827 +/** @def BLE_MESH_UUID_MESH_PROXY + * @brief Mesh Proxy Service + */ +#define BLE_MESH_UUID_MESH_PROXY BLE_MESH_UUID_DECLARE_16(0x1828) +#define BLE_MESH_UUID_MESH_PROXY_VAL 0x1828 +/** @def BLE_MESH_UUID_GATT_PRIMARY + * @brief GATT Primary Service + */ +#define BLE_MESH_UUID_GATT_PRIMARY BLE_MESH_UUID_DECLARE_16(0x2800) +#define BLE_MESH_UUID_GATT_PRIMARY_VAL 0x2800 +/** @def BLE_MESH_UUID_GATT_SECONDARY + * @brief GATT Secondary Service + */ +#define BLE_MESH_UUID_GATT_SECONDARY BLE_MESH_UUID_DECLARE_16(0x2801) +#define BLE_MESH_UUID_GATT_SECONDARY_VAL 0x2801 +/** @def BLE_MESH_UUID_GATT_INCLUDE + * @brief GATT Include Service + */ +#define BLE_MESH_UUID_GATT_INCLUDE BLE_MESH_UUID_DECLARE_16(0x2802) +#define BLE_MESH_UUID_GATT_INCLUDE_VAL 0x2802 +/** @def BLE_MESH_UUID_GATT_CHRC + * @brief GATT Characteristic + */ +#define BLE_MESH_UUID_GATT_CHRC BLE_MESH_UUID_DECLARE_16(0x2803) +#define BLE_MESH_UUID_GATT_CHRC_VAL 0x2803 +/** @def BLE_MESH_UUID_GATT_CEP + * @brief GATT Characteristic Extended Properties + */ +#define BLE_MESH_UUID_GATT_CEP BLE_MESH_UUID_DECLARE_16(0x2900) +#define BLE_MESH_UUID_GATT_CEP_VAL 0x2900 +/** @def BLE_MESH_UUID_GATT_CUD + * @brief GATT Characteristic User Description + */ +#define BLE_MESH_UUID_GATT_CUD BLE_MESH_UUID_DECLARE_16(0x2901) +#define BLE_MESH_UUID_GATT_CUD_VAL 0x2901 +/** @def BLE_MESH_UUID_GATT_CCC + * @brief GATT Client Characteristic Configuration + */ +#define BLE_MESH_UUID_GATT_CCC BLE_MESH_UUID_DECLARE_16(0x2902) +#define BLE_MESH_UUID_GATT_CCC_VAL 0x2902 +/** @def BLE_MESH_UUID_GATT_SCC + * @brief GATT Server Characteristic Configuration + */ +#define BLE_MESH_UUID_GATT_SCC BLE_MESH_UUID_DECLARE_16(0x2903) +#define BLE_MESH_UUID_GATT_SCC_VAL 0x2903 +/** @def BLE_MESH_UUID_GATT_CPF + * @brief GATT Characteristic Presentation Format + */ +#define BLE_MESH_UUID_GATT_CPF BLE_MESH_UUID_DECLARE_16(0x2904) +#define BLE_MESH_UUID_GATT_CPF_VAL 0x2904 +/** @def BLE_MESH_UUID_VALID_RANGE + * @brief Valid Range Descriptor + */ +#define BLE_MESH_UUID_VALID_RANGE BLE_MESH_UUID_DECLARE_16(0x2906) +#define BLE_MESH_UUID_VALID_RANGE_VAL 0x2906 +/** @def BLE_MESH_UUID_HIDS_EXT_REPORT + * @brief HID External Report Descriptor + */ +#define BLE_MESH_UUID_HIDS_EXT_REPORT BLE_MESH_UUID_DECLARE_16(0x2907) +#define BLE_MESH_UUID_HIDS_EXT_REPORT_VAL 0x2907 +/** @def BLE_MESH_UUID_HIDS_REPORT_REF + * @brief HID Report Reference Descriptor + */ +#define BLE_MESH_UUID_HIDS_REPORT_REF BLE_MESH_UUID_DECLARE_16(0x2908) +#define BLE_MESH_UUID_HIDS_REPORT_REF_VAL 0x2908 +/** @def BLE_MESH_UUID_ES_CONFIGURATION + * @brief Environmental Sensing Configuration Descriptor + */ +#define BLE_MESH_UUID_ES_CONFIGURATION BLE_MESH_UUID_DECLARE_16(0x290b) +#define BLE_MESH_UUID_ES_CONFIGURATION_VAL 0x290b +/** @def BLE_MESH_UUID_ES_MEASUREMENT + * @brief Environmental Sensing Measurement Descriptor + */ +#define BLE_MESH_UUID_ES_MEASUREMENT BLE_MESH_UUID_DECLARE_16(0x290c) +#define BLE_MESH_UUID_ES_MEASUREMENT_VAL 0x290c +/** @def BLE_MESH_UUID_ES_TRIGGER_SETTING + * @brief Environmental Sensing Trigger Setting Descriptor + */ +#define BLE_MESH_UUID_ES_TRIGGER_SETTING BLE_MESH_UUID_DECLARE_16(0x290d) +#define BLE_MESH_UUID_ES_TRIGGER_SETTING_VAL 0x290d +/** @def BLE_MESH_UUID_GAP_DEVICE_NAME + * @brief GAP Characteristic Device Name + */ +#define BLE_MESH_UUID_GAP_DEVICE_NAME BLE_MESH_UUID_DECLARE_16(0x2a00) +#define BLE_MESH_UUID_GAP_DEVICE_NAME_VAL 0x2a00 +/** @def BLE_MESH_UUID_GAP_APPEARANCE + * @brief GAP Characteristic Appearance + */ +#define BLE_MESH_UUID_GAP_APPEARANCE BLE_MESH_UUID_DECLARE_16(0x2a01) +#define BLE_MESH_UUID_GAP_APPEARANCE_VAL 0x2a01 +/** @def BLE_MESH_UUID_GAP_PPCP + * @brief GAP Characteristic Peripheral Preferred Connection Parameters + */ +#define BLE_MESH_UUID_GAP_PPCP BLE_MESH_UUID_DECLARE_16(0x2a04) +#define BLE_MESH_UUID_GAP_PPCP_VAL 0x2a04 +/** @def BLE_MESH_UUID_GATT_SC + * @brief GATT Characteristic Service Changed + */ +#define BLE_MESH_UUID_GATT_SC BLE_MESH_UUID_DECLARE_16(0x2a05) +#define BLE_MESH_UUID_GATT_SC_VAL 0x2a05 +/** @def BLE_MESH_UUID_BAS_BATTERY_LEVEL + * @brief BAS Characteristic Battery Level + */ +#define BLE_MESH_UUID_BAS_BATTERY_LEVEL BLE_MESH_UUID_DECLARE_16(0x2a19) +#define BLE_MESH_UUID_BAS_BATTERY_LEVEL_VAL 0x2a19 +/** @def BLE_MESH_UUID_DIS_SYSTEM_ID + * @brief DIS Characteristic System ID + */ +#define BLE_MESH_UUID_DIS_SYSTEM_ID BLE_MESH_UUID_DECLARE_16(0x2a23) +#define BLE_MESH_UUID_DIS_SYSTEM_ID_VAL 0x2a23 +/** @def BLE_MESH_UUID_DIS_MODEL_NUMBER + * @brief DIS Characteristic Model Number String + */ +#define BLE_MESH_UUID_DIS_MODEL_NUMBER BLE_MESH_UUID_DECLARE_16(0x2a24) +#define BLE_MESH_UUID_DIS_MODEL_NUMBER_VAL 0x2a24 +/** @def BLE_MESH_UUID_DIS_SERIAL_NUMBER + * @brief DIS Characteristic Serial Number String + */ +#define BLE_MESH_UUID_DIS_SERIAL_NUMBER BLE_MESH_UUID_DECLARE_16(0x2a25) +#define BLE_MESH_UUID_DIS_SERIAL_NUMBER_VAL 0x2a25 +/** @def BLE_MESH_UUID_DIS_FIRMWARE_REVISION + * @brief DIS Characteristic Firmware Revision String + */ +#define BLE_MESH_UUID_DIS_FIRMWARE_REVISION BLE_MESH_UUID_DECLARE_16(0x2a26) +#define BLE_MESH_UUID_DIS_FIRMWARE_REVISION_VAL 0x2a26 +/** @def BLE_MESH_UUID_DIS_HARDWARE_REVISION + * @brief DIS Characteristic Hardware Revision String + */ +#define BLE_MESH_UUID_DIS_HARDWARE_REVISION BLE_MESH_UUID_DECLARE_16(0x2a27) +#define BLE_MESH_UUID_DIS_HARDWARE_REVISION_VAL 0x2a27 +/** @def BLE_MESH_UUID_DIS_SOFTWARE_REVISION + * @brief DIS Characteristic Software Revision String + */ +#define BLE_MESH_UUID_DIS_SOFTWARE_REVISION BLE_MESH_UUID_DECLARE_16(0x2a28) +#define BLE_MESH_UUID_DIS_SOFTWARE_REVISION_VAL 0x2a28 +/** @def BLE_MESH_UUID_DIS_MANUFACTURER_NAME + * @brief DIS Characteristic Manufacturer Name String + */ +#define BLE_MESH_UUID_DIS_MANUFACTURER_NAME BLE_MESH_UUID_DECLARE_16(0x2a29) +#define BLE_MESH_UUID_DIS_MANUFACTURER_NAME_VAL 0x2a29 +/** @def BLE_MESH_UUID_DIS_PNP_ID + * @brief DIS Characteristic PnP ID + */ +#define BLE_MESH_UUID_DIS_PNP_ID BLE_MESH_UUID_DECLARE_16(0x2a50) +#define BLE_MESH_UUID_DIS_PNP_ID_VAL 0x2a50 +/** @def BLE_MESH_UUID_CTS_CURRENT_TIME + * @brief CTS Characteristic Current Time + */ +#define BLE_MESH_UUID_CTS_CURRENT_TIME BLE_MESH_UUID_DECLARE_16(0x2a2b) +#define BLE_MESH_UUID_CTS_CURRENT_TIME_VAL 0x2a2b +/** @def BLE_MESH_UUID_MAGN_DECLINATION + * @brief Magnetic Declination Characteristic + */ +#define BLE_MESH_UUID_MAGN_DECLINATION BLE_MESH_UUID_DECLARE_16(0x2a2c) +#define BLE_MESH_UUID_MAGN_DECLINATION_VAL 0x2a2c +/** @def BLE_MESH_UUID_HRS_MEASUREMENT + * @brief HRS Characteristic Measurement Interval + */ +#define BLE_MESH_UUID_HRS_MEASUREMENT BLE_MESH_UUID_DECLARE_16(0x2a37) +#define BLE_MESH_UUID_HRS_MEASUREMENT_VAL 0x2a37 +/** @def BLE_MESH_UUID_HRS_BODY_SENSOR + * @brief HRS Characteristic Body Sensor Location + */ +#define BLE_MESH_UUID_HRS_BODY_SENSOR BLE_MESH_UUID_DECLARE_16(0x2a38) +#define BLE_MESH_UUID_HRS_BODY_SENSOR_VAL 0x2a38 +/** @def BLE_MESH_UUID_HRS_CONTROL_POINT + * @brief HRS Characteristic Control Point + */ +#define BLE_MESH_UUID_HRS_CONTROL_POINT BLE_MESH_UUID_DECLARE_16(0x2a39) +#define BLE_MESH_UUID_HRS_CONTROL_POINT_VAL 0x2a39 +/** @def BLE_MESH_UUID_HIDS_INFO + * @brief HID Information Characteristic + */ +#define BLE_MESH_UUID_HIDS_INFO BLE_MESH_UUID_DECLARE_16(0x2a4a) +#define BLE_MESH_UUID_HIDS_INFO_VAL 0x2a4a +/** @def BLE_MESH_UUID_HIDS_REPORT_MAP + * @brief HID Report Map Characteristic + */ +#define BLE_MESH_UUID_HIDS_REPORT_MAP BLE_MESH_UUID_DECLARE_16(0x2a4b) +#define BLE_MESH_UUID_HIDS_REPORT_MAP_VAL 0x2a4b +/** @def BLE_MESH_UUID_HIDS_CTRL_POINT + * @brief HID Control Point Characteristic + */ +#define BLE_MESH_UUID_HIDS_CTRL_POINT BLE_MESH_UUID_DECLARE_16(0x2a4c) +#define BLE_MESH_UUID_HIDS_CTRL_POINT_VAL 0x2a4c +/** @def BLE_MESH_UUID_HIDS_REPORT + * @brief HID Report Characteristic + */ +#define BLE_MESH_UUID_HIDS_REPORT BLE_MESH_UUID_DECLARE_16(0x2a4d) +#define BLE_MESH_UUID_HIDS_REPORT_VAL 0x2a4d +/** @def BLE_MESH_UUID_CSC_MEASUREMENT + * @brief CSC Measurement Characteristic + */ +#define BLE_MESH_UUID_CSC_MEASUREMENT BLE_MESH_UUID_DECLARE_16(0x2a5b) +#define BLE_MESH_UUID_CSC_MEASUREMENT_VAL 0x2a5b +/** @def BLE_MESH_UUID_CSC_FEATURE + * @brief CSC Feature Characteristic + */ +#define BLE_MESH_UUID_CSC_FEATURE BLE_MESH_UUID_DECLARE_16(0x2a5c) +#define BLE_MESH_UUID_CSC_FEATURE_VAL 0x2a5c +/** @def BLE_MESH_UUID_SENSOR_LOCATION + * @brief Sensor Location Characteristic + */ +#define BLE_MESH_UUID_SENSOR_LOCATION BLE_MESH_UUID_DECLARE_16(0x2a5d) +#define BLE_MESH_UUID_SENSOR_LOCATION_VAL 0x2a5d +/** @def BLE_MESH_UUID_SC_CONTROL_POINT + * @brief SC Control Point Characteristic + */ +#define BLE_MESH_UUID_SC_CONTROL_POINT BLE_MESH_UUID_DECLARE_16(0x2a55) +#define BLE_MESH_UUID_SC_CONTROL_POINT_VAl 0x2a55 +/** @def BLE_MESH_UUID_ELEVATION + * @brief Elevation Characteristic + */ +#define BLE_MESH_UUID_ELEVATION BLE_MESH_UUID_DECLARE_16(0x2a6c) +#define BLE_MESH_UUID_ELEVATION_VAL 0x2a6c +/** @def BLE_MESH_UUID_PRESSURE + * @brief Pressure Characteristic + */ +#define BLE_MESH_UUID_PRESSURE BLE_MESH_UUID_DECLARE_16(0x2a6d) +#define BLE_MESH_UUID_PRESSURE_VAL 0x2a6d +/** @def BLE_MESH_UUID_TEMPERATURE + * @brief Temperature Characteristic + */ +#define BLE_MESH_UUID_TEMPERATURE BLE_MESH_UUID_DECLARE_16(0x2a6e) +#define BLE_MESH_UUID_TEMPERATURE_VAL 0x2a6e +/** @def BLE_MESH_UUID_HUMIDITY + * @brief Humidity Characteristic + */ +#define BLE_MESH_UUID_HUMIDITY BLE_MESH_UUID_DECLARE_16(0x2a6f) +#define BLE_MESH_UUID_HUMIDITY_VAL 0x2a6f +/** @def BLE_MESH_UUID_TRUE_WIND_SPEED + * @brief True Wind Speed Characteristic + */ +#define BLE_MESH_UUID_TRUE_WIND_SPEED BLE_MESH_UUID_DECLARE_16(0x2a70) +#define BLE_MESH_UUID_TRUE_WIND_SPEED_VAL 0x2a70 +/** @def BLE_MESH_UUID_TRUE_WIND_DIR + * @brief True Wind Direction Characteristic + */ +#define BLE_MESH_UUID_TRUE_WIND_DIR BLE_MESH_UUID_DECLARE_16(0x2a71) +#define BLE_MESH_UUID_TRUE_WIND_DIR_VAL 0x2a71 +/** @def BLE_MESH_UUID_APPARENT_WIND_SPEED + * @brief Apparent Wind Speed Characteristic + */ +#define BLE_MESH_UUID_APPARENT_WIND_SPEED BLE_MESH_UUID_DECLARE_16(0x2a72) +#define BLE_MESH_UUID_APPARENT_WIND_SPEED_VAL 0x2a72 +/** @def BLE_MESH_UUID_APPARENT_WIND_DIR + * @brief Apparent Wind Direction Characteristic + */ +#define BLE_MESH_UUID_APPARENT_WIND_DIR BLE_MESH_UUID_DECLARE_16(0x2a73) +#define BLE_MESH_UUID_APPARENT_WIND_DIR_VAL 0x2a73 +/** @def BLE_MESH_UUID_GUST_FACTOR + * @brief Gust Factor Characteristic + */ +#define BLE_MESH_UUID_GUST_FACTOR BLE_MESH_UUID_DECLARE_16(0x2a74) +#define BLE_MESH_UUID_GUST_FACTOR_VAL 0x2a74 +/** @def BLE_MESH_UUID_POLLEN_CONCENTRATION + * @brief Pollen Concentration Characteristic + */ +#define BLE_MESH_UUID_POLLEN_CONCENTRATION BLE_MESH_UUID_DECLARE_16(0x2a75) +#define BLE_MESH_UUID_POLLEN_CONCENTRATION_VAL 0x2a75 +/** @def BLE_MESH_UUID_UV_INDEX + * @brief UV Index Characteristic + */ +#define BLE_MESH_UUID_UV_INDEX BLE_MESH_UUID_DECLARE_16(0x2a76) +#define BLE_MESH_UUID_UV_INDEX_VAL 0x2a76 +/** @def BLE_MESH_UUID_IRRADIANCE + * @brief Irradiance Characteristic + */ +#define BLE_MESH_UUID_IRRADIANCE BLE_MESH_UUID_DECLARE_16(0x2a77) +#define BLE_MESH_UUID_IRRADIANCE_VAL 0x2a77 +/** @def BLE_MESH_UUID_RAINFALL + * @brief Rainfall Characteristic + */ +#define BLE_MESH_UUID_RAINFALL BLE_MESH_UUID_DECLARE_16(0x2a78) +#define BLE_MESH_UUID_RAINFALL_VAL 0x2a78 +/** @def BLE_MESH_UUID_WIND_CHILL + * @brief Wind Chill Characteristic + */ +#define BLE_MESH_UUID_WIND_CHILL BLE_MESH_UUID_DECLARE_16(0x2a79) +#define BLE_MESH_UUID_WIND_CHILL_VAL 0x2a79 +/** @def BLE_MESH_UUID_HEAT_INDEX + * @brief Heat Index Characteristic + */ +#define BLE_MESH_UUID_HEAT_INDEX BLE_MESH_UUID_DECLARE_16(0x2a7a) +#define BLE_MESH_UUID_HEAT_INDEX_VAL 0x2a7a +/** @def BLE_MESH_UUID_DEW_POINT + * @brief Dew Point Characteristic + */ +#define BLE_MESH_UUID_DEW_POINT BLE_MESH_UUID_DECLARE_16(0x2a7b) +#define BLE_MESH_UUID_DEW_POINT_VAL 0x2a7b +/** @def BLE_MESH_UUID_DESC_VALUE_CHANGED + * @brief Descriptor Value Changed Characteristic + */ +#define BLE_MESH_UUID_DESC_VALUE_CHANGED BLE_MESH_UUID_DECLARE_16(0x2a7d) +#define BLE_MESH_UUID_DESC_VALUE_CHANGED_VAL 0x2a7d +/** @def BLE_MESH_UUID_MAGN_FLUX_DENSITY_2D + * @brief Magnetic Flux Density - 2D Characteristic + */ +#define BLE_MESH_UUID_MAGN_FLUX_DENSITY_2D BLE_MESH_UUID_DECLARE_16(0x2aa0) +#define BLE_MESH_UUID_MAGN_FLUX_DENSITY_2D_VAL 0x2aa0 +/** @def BLE_MESH_UUID_MAGN_FLUX_DENSITY_3D + * @brief Magnetic Flux Density - 3D Characteristic + */ +#define BLE_MESH_UUID_MAGN_FLUX_DENSITY_3D BLE_MESH_UUID_DECLARE_16(0x2aa1) +#define BLE_MESH_UUID_MAGN_FLUX_DENSITY_3D_VAL 0x2aa1 +/** @def BLE_MESH_UUID_BAR_PRESSURE_TREND + * @brief Barometric Pressure Trend Characteristic + */ +#define BLE_MESH_UUID_BAR_PRESSURE_TREND BLE_MESH_UUID_DECLARE_16(0x2aa3) +#define BLE_MESH_UUID_BAR_PRESSURE_TREND_VAL 0x2aa3 +/** @def BLE_MESH_UUID_MESH_PROV_DATA_IN + * @brief Mesh Provisioning Data In + */ +#define BLE_MESH_UUID_MESH_PROV_DATA_IN BLE_MESH_UUID_DECLARE_16(0x2adb) +#define BLE_MESH_UUID_MESH_PROV_DATA_IN_VAL 0x2adb +/** @def BLE_MESH_UUID_MESH_PROV_DATA_OUT + * @brief Mesh Provisioning Data Out + */ +#define BLE_MESH_UUID_MESH_PROV_DATA_OUT BLE_MESH_UUID_DECLARE_16(0x2adc) +#define BLE_MESH_UUID_MESH_PROV_DATA_OUT_VAL 0x2adc +/** @def BLE_MESH_UUID_MESH_PROXY_DATA_IN + * @brief Mesh Proxy Data In + */ +#define BLE_MESH_UUID_MESH_PROXY_DATA_IN BLE_MESH_UUID_DECLARE_16(0x2add) +#define BLE_MESH_UUID_MESH_PROXY_DATA_IN_VAL 0x2add +/** @def BLE_MESH_UUID_MESH_PROXY_DATA_OUT + * @brief Mesh Proxy Data Out + */ +#define BLE_MESH_UUID_MESH_PROXY_DATA_OUT BLE_MESH_UUID_DECLARE_16(0x2ade) +#define BLE_MESH_UUID_MESH_PROXY_DATA_OUT_VAL 0x2ade + +/* + * Protocol UUIDs + */ +#define BLE_MESH_UUID_SDP BLE_MESH_UUID_DECLARE_16(0x0001) +#define BLE_MESH_UUID_SDP_VAL 0x0001 +#define BLE_MESH_UUID_UDP BLE_MESH_UUID_DECLARE_16(0x0002) +#define BLE_MESH_UUID_UDP_VAL 0x0002 +#define BLE_MESH_UUID_RFCOMM BLE_MESH_UUID_DECLARE_16(0x0003) +#define BLE_MESH_UUID_RFCOMM_VAL 0x0003 +#define BLE_MESH_UUID_TCP BLE_MESH_UUID_DECLARE_16(0x0004) +#define BLE_MESH_UUID_TCP_VAL 0x0004 +#define BLE_MESH_UUID_TCS_BIN BLE_MESH_UUID_DECLARE_16(0x0005) +#define BLE_MESH_UUID_TCS_BIN_VAL 0x0005 +#define BLE_MESH_UUID_TCS_AT BLE_MESH_UUID_DECLARE_16(0x0006) +#define BLE_MESH_UUID_TCS_AT_VAL 0x0006 +#define BLE_MESH_UUID_ATT BLE_MESH_UUID_DECLARE_16(0x0007) +#define BLE_MESH_UUID_ATT_VAL 0x0007 +#define BLE_MESH_UUID_OBEX BLE_MESH_UUID_DECLARE_16(0x0008) +#define BLE_MESH_UUID_OBEX_VAL 0x0008 +#define BLE_MESH_UUID_IP BLE_MESH_UUID_DECLARE_16(0x0009) +#define BLE_MESH_UUID_IP_VAL 0x0009 +#define BLE_MESH_UUID_FTP BLE_MESH_UUID_DECLARE_16(0x000a) +#define BLE_MESH_UUID_FTP_VAL 0x000a +#define BLE_MESH_UUID_HTTP BLE_MESH_UUID_DECLARE_16(0x000c) +#define BLE_MESH_UUID_HTTP_VAL 0x000c +#define BLE_MESH_UUID_BNEP BLE_MESH_UUID_DECLARE_16(0x000f) +#define BLE_MESH_UUID_BNEP_VAL 0x000f +#define BLE_MESH_UUID_UPNP BLE_MESH_UUID_DECLARE_16(0x0010) +#define BLE_MESH_UUID_UPNP_VAL 0x0010 +#define BLE_MESH_UUID_HIDP BLE_MESH_UUID_DECLARE_16(0x0011) +#define BLE_MESH_UUID_HIDP_VAL 0x0011 +#define BLE_MESH_UUID_HCRP_CTRL BLE_MESH_UUID_DECLARE_16(0x0012) +#define BLE_MESH_UUID_HCRP_CTRL_VAL 0x0012 +#define BLE_MESH_UUID_HCRP_DATA BLE_MESH_UUID_DECLARE_16(0x0014) +#define BLE_MESH_UUID_HCRP_DATA_VAL 0x0014 +#define BLE_MESH_UUID_HCRP_NOTE BLE_MESH_UUID_DECLARE_16(0x0016) +#define BLE_MESH_UUID_HCRP_NOTE_VAL 0x0016 +#define BLE_MESH_UUID_AVCTP BLE_MESH_UUID_DECLARE_16(0x0017) +#define BLE_MESH_UUID_AVCTP_VAL 0x0017 +#define BLE_MESH_UUID_AVDTP BLE_MESH_UUID_DECLARE_16(0x0019) +#define BLE_MESH_UUID_AVDTP_VAL 0x0019 +#define BLE_MESH_UUID_CMTP BLE_MESH_UUID_DECLARE_16(0x001b) +#define BLE_MESH_UUID_CMTP_VAL 0x001b +#define BLE_MESH_UUID_UDI BLE_MESH_UUID_DECLARE_16(0x001d) +#define BLE_MESH_UUID_UDI_VAL 0x001d +#define BLE_MESH_UUID_MCAP_CTRL BLE_MESH_UUID_DECLARE_16(0x001e) +#define BLE_MESH_UUID_MCAP_CTRL_VAL 0x001e +#define BLE_MESH_UUID_MCAP_DATA BLE_MESH_UUID_DECLARE_16(0x001f) +#define BLE_MESH_UUID_MCAP_DATA_VAL 0x001f +#define BLE_MESH_UUID_L2CAP BLE_MESH_UUID_DECLARE_16(0x0100) +#define BLE_MESH_UUID_L2CAP_VAL 0x0100 + +#ifdef __cplusplus +} +#endif + +/** + * @} + */ + +#endif /* _BLE_MESH_UUID_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/local_operation.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/local_operation.h new file mode 100644 index 00000000000..f7f169d1f8c --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/local_operation.h @@ -0,0 +1,41 @@ +/* Bluetooth Mesh */ + +/* + * SPDX-FileCopyrightText: 2017 Intel Corporation + * SPDX-FileContributor: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _LOCAL_OPERATION_H_ +#define _LOCAL_OPERATION_H_ + +#include "mesh_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +int bt_mesh_model_subscribe_group_addr(uint16_t elem_addr, uint16_t mod_id, + uint16_t cid, uint16_t group_addr); + +int bt_mesh_model_unsubscribe_group_addr(uint16_t elem_addr, uint16_t cid, + uint16_t mod_id, uint16_t group_addr); + +const uint8_t *bt_mesh_node_get_local_net_key(uint16_t net_idx); + +const uint8_t *bt_mesh_node_get_local_app_key(uint16_t app_idx); + +int bt_mesh_node_local_net_key_add(uint16_t net_idx, const uint8_t net_key[16]); + +int bt_mesh_node_local_app_key_add(uint16_t net_idx, uint16_t app_idx, + const uint8_t app_key[16]); + +int bt_mesh_node_bind_app_key_to_model(uint16_t elem_addr, uint16_t mod_id, + uint16_t cid, uint16_t app_idx); + +#ifdef __cplusplus +} +#endif + +#endif /* _LOCAL_OPERATION_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/lpn.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/lpn.h new file mode 100644 index 00000000000..dbff49d624d --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/lpn.h @@ -0,0 +1,78 @@ +/* Bluetooth Mesh */ + +/* + * SPDX-FileCopyrightText: 2017 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _LPN_H_ +#define _LPN_H_ + +#include "net.h" + +#ifdef __cplusplus +extern "C" { +#endif + +int bt_mesh_lpn_friend_update(struct bt_mesh_net_rx *rx, + struct net_buf_simple *buf); +int bt_mesh_lpn_friend_offer(struct bt_mesh_net_rx *rx, + struct net_buf_simple *buf); +int bt_mesh_lpn_friend_clear_cfm(struct bt_mesh_net_rx *rx, + struct net_buf_simple *buf); +int bt_mesh_lpn_friend_sub_cfm(struct bt_mesh_net_rx *rx, + struct net_buf_simple *buf); + +static inline bool bt_mesh_lpn_established(void) +{ +#if defined(CONFIG_BLE_MESH_LOW_POWER) + return bt_mesh.lpn.established; +#else + return false; +#endif +} + +static inline bool bt_mesh_lpn_match(uint16_t addr) +{ +#if defined(CONFIG_BLE_MESH_LOW_POWER) + if (bt_mesh_lpn_established()) { + return (addr == bt_mesh.lpn.frnd); + } +#endif + return false; +} + +static inline bool bt_mesh_lpn_waiting_update(void) +{ +#if defined(CONFIG_BLE_MESH_LOW_POWER) + return (bt_mesh.lpn.state == BLE_MESH_LPN_WAIT_UPDATE); +#else + return false; +#endif +} + +static inline bool bt_mesh_lpn_timer(void) +{ +#if defined(CONFIG_BLE_MESH_LPN_AUTO) + return (bt_mesh.lpn.state == BLE_MESH_LPN_TIMER); +#else + return false; +#endif +} + +void bt_mesh_lpn_msg_received(struct bt_mesh_net_rx *rx); + +void bt_mesh_lpn_group_add(uint16_t group); +void bt_mesh_lpn_group_del(uint16_t *groups, size_t group_count); + +void bt_mesh_lpn_disable(bool force); + +int bt_mesh_lpn_init(void); +int bt_mesh_lpn_deinit(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _LPN_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/mesh.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/mesh.h new file mode 100644 index 00000000000..33155aa555c --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/mesh.h @@ -0,0 +1,33 @@ +/* Bluetooth Mesh */ + +/* + * SPDX-FileCopyrightText: 2017 Intel Corporation + * SPDX-FileContributor: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _MESH_H_ +#define _MESH_H_ + +#include "net.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define BLE_MESH_KEY_PRIMARY 0x0000 +#define BLE_MESH_KEY_ANY 0xffff + +#define BLE_MESH_ADDR_IS_UNICAST(addr) ((addr) && (addr) < 0x8000) +#define BLE_MESH_ADDR_IS_GROUP(addr) ((addr) >= 0xc000 && (addr) <= 0xff00) +#define BLE_MESH_ADDR_IS_VIRTUAL(addr) ((addr) >= 0x8000 && (addr) < 0xc000) +#define BLE_MESH_ADDR_IS_RFU(addr) ((addr) >= 0xff00 && (addr) <= 0xfffb) + +struct bt_mesh_net; + +#ifdef __cplusplus +} +#endif + +#endif /* _MESH_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/net.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/net.h new file mode 100644 index 00000000000..8a1b9b343a3 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/net.h @@ -0,0 +1,424 @@ +/* Bluetooth Mesh */ + +/* + * SPDX-FileCopyrightText: 2017 Intel Corporation + * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _NET_H_ +#define _NET_H_ + +#include "mesh_access.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define BLE_MESH_NET_FLAG_KR BIT(0) +#define BLE_MESH_NET_FLAG_IVU BIT(1) + +#define BLE_MESH_KR_NORMAL 0x00 +#define BLE_MESH_KR_PHASE_1 0x01 +#define BLE_MESH_KR_PHASE_2 0x02 +#define BLE_MESH_KR_PHASE_3 0x03 + +#define BLE_MESH_IV_UPDATE(flags) ((flags >> 1) & 0x01) +#define BLE_MESH_KEY_REFRESH(flags) (flags & 0x01) + +/* How many hours in between updating IVU duration */ +#define BLE_MESH_IVU_MIN_HOURS 96 +#define BLE_MESH_IVU_HOURS (BLE_MESH_IVU_MIN_HOURS / CONFIG_BLE_MESH_IVU_DIVIDER) +#define BLE_MESH_IVU_TIMEOUT K_HOURS(BLE_MESH_IVU_HOURS) + +struct bt_mesh_app_key { + uint16_t net_idx; + uint16_t app_idx; + bool updated; + struct bt_mesh_app_keys { + uint8_t id; + uint8_t val[16]; + } keys[2]; +}; + +struct bt_mesh_subnet { + uint32_t beacon_sent; /* Timestamp of last sent beacon */ + uint8_t beacons_last; /* Number of beacons during last observation window. */ + uint8_t beacons_cur; /* Number of beacons observed during currently ongoing window. */ + + uint8_t beacon_cache[21]; /* Cached last authenticated beacon */ + + uint16_t net_idx; /* NetKeyIndex */ + + bool kr_flag; /* Key Refresh Flag */ + uint8_t kr_phase; /* Key Refresh Phase */ + + uint8_t node_id; /* Node Identity State */ + uint32_t node_id_start; /* Node Identity started timestamp */ + + uint8_t auth[8]; /* Beacon Authentication Value */ + + struct bt_mesh_subnet_keys { + uint8_t net[16]; /* NetKey */ + uint8_t nid; /* NID */ + uint8_t enc[16]; /* EncKey */ + uint8_t net_id[8]; /* Network ID */ +#if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER) + uint8_t identity[16]; /* IdentityKey */ +#endif + uint8_t privacy[16]; /* PrivacyKey */ + uint8_t beacon[16]; /* BeaconKey */ + } keys[2]; +}; + +struct bt_mesh_rpl { + uint16_t src; + bool old_iv; +#if defined(CONFIG_BLE_MESH_SETTINGS) + bool store; +#endif + uint32_t seq; +}; + +#if defined(CONFIG_BLE_MESH_FRIEND) +#define FRIEND_SEG_RX CONFIG_BLE_MESH_FRIEND_SEG_RX +#define FRIEND_SUB_LIST_SIZE CONFIG_BLE_MESH_FRIEND_SUB_LIST_SIZE +#else +#define FRIEND_SEG_RX 0 +#define FRIEND_SUB_LIST_SIZE 0 +#endif + +struct bt_mesh_friend { + uint16_t lpn; + uint8_t recv_delay; + uint8_t fsn:1, + send_last:1, + pending_req:1, + sec_update:1, + pending_buf:1, + valid:1, + established:1; + int32_t poll_to; + uint8_t num_elem; + uint16_t lpn_counter; + uint16_t counter; + + uint16_t net_idx; + + uint16_t sub_list[FRIEND_SUB_LIST_SIZE]; + + struct k_delayed_work timer; + + struct bt_mesh_friend_seg { + sys_slist_t queue; + + /* The target number of segments, i.e. not necessarily + * the current number of segments, in the queue. This is + * used for Friend Queue free space calculations. + */ + uint8_t seg_count; + } seg[FRIEND_SEG_RX]; + + struct net_buf *last; + + sys_slist_t queue; + uint32_t queue_size; + + /* Friend Clear Procedure */ + struct { + uint32_t start; /* Clear Procedure start */ + uint16_t frnd; /* Previous Friend's address */ + uint16_t repeat_sec; /* Repeat timeout in seconds */ + struct k_delayed_work timer; /* Repeat timer */ + } clear; +}; + +#if defined(CONFIG_BLE_MESH_LOW_POWER) +#define LPN_GROUPS CONFIG_BLE_MESH_LPN_GROUPS +#else +#define LPN_GROUPS 0 +#endif + +/* Low Power Node state */ +struct bt_mesh_lpn { + enum __packed { + BLE_MESH_LPN_DISABLED, /* LPN feature is disabled */ + BLE_MESH_LPN_CLEAR, /* Clear in progress */ + BLE_MESH_LPN_TIMER, /* Waiting for auto timer expiry */ + BLE_MESH_LPN_ENABLED, /* LPN enabled, but no Friend */ + BLE_MESH_LPN_REQ_WAIT, /* Wait before scanning for offers */ + BLE_MESH_LPN_WAIT_OFFER, /* Friend Req sent */ + BLE_MESH_LPN_ESTABLISHED, /* Friendship established */ + BLE_MESH_LPN_RECV_DELAY, /* Poll sent, waiting ReceiveDelay */ + BLE_MESH_LPN_WAIT_UPDATE, /* Waiting for Update or message */ + BLE_MESH_LPN_OFFER_RECV, /* Friend offer received */ + } state; + + /* Transaction Number (used for subscription list) */ + uint8_t xact_next; + uint8_t xact_pending; + uint8_t sent_req; + + /* Address of our Friend when we're a LPN. Unassigned if we don't + * have a friend yet. + */ + uint16_t frnd; + + /* Value from the friend offer */ + uint8_t recv_win; + + uint8_t req_attempts; /* Number of Request attempts */ + + int32_t poll_timeout; + + uint8_t groups_changed: 1, /* Friend Subscription List needs updating */ + pending_poll: 1, /* Poll to be sent after subscription */ + disable: 1, /* Disable LPN after clearing */ + fsn: 1, /* Friend Sequence Number */ + established: 1, /* Friendship established */ + clear_success: 1; /* Friend Clear Confirm received */ + + /* Friend Queue Size */ + uint8_t queue_size; + + /* LPNCounter */ + uint16_t counter; + + /* Previous Friend of this LPN */ + uint16_t old_friend; + + /* Duration reported for last advertising packet */ + uint16_t adv_duration; + + /* Next LPN related action timer */ + struct k_delayed_work timer; + + /* Subscribed groups */ + uint16_t groups[LPN_GROUPS]; + + /* Bit fields for tracking which groups the Friend knows about */ + BLE_MESH_ATOMIC_DEFINE(added, LPN_GROUPS); + BLE_MESH_ATOMIC_DEFINE(pending, LPN_GROUPS); + BLE_MESH_ATOMIC_DEFINE(to_remove, LPN_GROUPS); +}; + +/* bt_mesh_net.flags */ +enum { + BLE_MESH_NODE, /* Device is a node */ + BLE_MESH_PROVISIONER, /* Device is a Provisioner */ + BLE_MESH_VALID, /* We have been provisioned */ + BLE_MESH_VALID_PROV, /* Provisioner has been enabled */ + BLE_MESH_SUSPENDED, /* Network is temporarily suspended */ + BLE_MESH_IVU_IN_PROGRESS, /* IV Update in Progress */ + BLE_MESH_IVU_INITIATOR, /* IV Update initiated by us */ + BLE_MESH_IVU_TEST, /* IV Update test mode */ + BLE_MESH_IVU_PENDING, /* Update blocked by SDU in progress */ + + /* pending storage actions, must reside within first 32 flags */ + BLE_MESH_RPL_PENDING, + BLE_MESH_KEYS_PENDING, + BLE_MESH_NET_PENDING, + BLE_MESH_IV_PENDING, + BLE_MESH_SEQ_PENDING, + BLE_MESH_HB_PUB_PENDING, + BLE_MESH_CFG_PENDING, + BLE_MESH_MOD_PENDING, + BLE_MESH_VA_PENDING, + + /* Don't touch - intentionally last */ + BLE_MESH_FLAG_COUNT, +}; + +struct bt_mesh_net { + uint32_t iv_index; /* Current IV Index */ + uint32_t seq; /* Next outgoing sequence number (24 bits) */ + + BLE_MESH_ATOMIC_DEFINE(flags, BLE_MESH_FLAG_COUNT); + + /* Local network interface */ + struct k_work local_work; + sys_slist_t local_queue; + +#if defined(CONFIG_BLE_MESH_FRIEND) + /* Friend state, unique for each LPN that we're Friends for */ + struct bt_mesh_friend frnd[CONFIG_BLE_MESH_FRIEND_LPN_COUNT]; +#endif + +#if defined(CONFIG_BLE_MESH_LOW_POWER) + struct bt_mesh_lpn lpn; /* Low Power Node state */ +#endif + + /* Number of hours in current IV Update state */ + uint8_t ivu_duration; + + /* Timer to track duration in current IV Update state */ + struct k_delayed_work ivu_timer; + + uint8_t dev_key[16]; + + struct bt_mesh_app_key app_keys[CONFIG_BLE_MESH_APP_KEY_COUNT]; + + struct bt_mesh_subnet sub[CONFIG_BLE_MESH_SUBNET_COUNT]; + + struct bt_mesh_rpl rpl[CONFIG_BLE_MESH_CRPL]; + +#if defined(CONFIG_BLE_MESH_PROVISIONER) + /* Application keys stored by provisioner */ + struct bt_mesh_app_key *p_app_keys[CONFIG_BLE_MESH_PROVISIONER_APP_KEY_COUNT]; + /* Next app_idx can be assigned */ + uint16_t p_app_idx_next; + + /* Network keys stored by provisioner */ + struct bt_mesh_subnet *p_sub[CONFIG_BLE_MESH_PROVISIONER_SUBNET_COUNT]; + /* Next net_idx can be assigned */ + uint16_t p_net_idx_next; +#endif +}; + +/* Network interface */ +enum bt_mesh_net_if { + BLE_MESH_NET_IF_ADV, + BLE_MESH_NET_IF_LOCAL, + BLE_MESH_NET_IF_PROXY, + BLE_MESH_NET_IF_PROXY_CFG, +}; + +/* Decoding context for Network/Transport data */ +struct bt_mesh_net_rx { + struct bt_mesh_subnet *sub; + struct bt_mesh_msg_ctx ctx; + uint32_t seq; /* Sequence Number */ + uint8_t old_iv:1, /* iv_index - 1 was used */ + new_key:1, /* Data was encrypted with updated key */ + friend_cred:1, /* Data was encrypted with friend cred */ + ctl:1, /* Network Control */ + net_if:2, /* Network interface */ + local_match:1, /* Matched a local element */ + friend_match:1; /* Matched an LPN we're friends for */ + uint16_t msg_cache_idx; /* Index of entry in message cache */ +}; + +/* Encoding context for Network/Transport data */ +struct bt_mesh_net_tx { + struct bt_mesh_subnet *sub; + struct bt_mesh_msg_ctx *ctx; + uint16_t src; + uint8_t xmit; + uint8_t friend_cred:1, + aszmic:1, + aid: 6; +}; + +extern struct bt_mesh_net bt_mesh; + +#define BLE_MESH_NET_IVI_TX (bt_mesh.iv_index - \ + bt_mesh_atomic_test_bit(bt_mesh.flags, \ + BLE_MESH_IVU_IN_PROGRESS)) +#define BLE_MESH_NET_IVI_RX(rx) (bt_mesh.iv_index - (rx)->old_iv) + +#define BLE_MESH_NET_HDR_LEN 9 + +void bt_mesh_msg_cache_clear(uint16_t unicast_addr, uint8_t elem_num); + +int bt_mesh_net_keys_create(struct bt_mesh_subnet_keys *keys, + const uint8_t key[16]); + +int bt_mesh_net_create(uint16_t idx, uint8_t flags, const uint8_t key[16], + uint32_t iv_index); + +uint8_t bt_mesh_net_flags(struct bt_mesh_subnet *sub); + +bool bt_mesh_kr_update(struct bt_mesh_subnet *sub, uint8_t new_kr, bool new_key); + +void bt_mesh_net_revoke_keys(struct bt_mesh_subnet *sub); + +int bt_mesh_net_beacon_update(struct bt_mesh_subnet *sub); + +void bt_mesh_rpl_reset(void); + +bool bt_mesh_net_iv_update(uint32_t iv_index, bool iv_update); + +void bt_mesh_net_sec_update(struct bt_mesh_subnet *sub); + +struct bt_mesh_subnet *bt_mesh_subnet_get(uint16_t net_idx); + +struct bt_mesh_subnet *bt_mesh_subnet_find(const uint8_t net_id[8], uint8_t flags, + uint32_t iv_index, const uint8_t auth[8], + bool *new_key); + +int bt_mesh_net_encode(struct bt_mesh_net_tx *tx, struct net_buf_simple *buf, + bool proxy); + +int bt_mesh_net_send(struct bt_mesh_net_tx *tx, struct net_buf *buf, + const struct bt_mesh_send_cb *cb, void *cb_data); + +int bt_mesh_net_resend(struct bt_mesh_subnet *sub, struct net_buf *buf, + bool new_key, const struct bt_mesh_send_cb *cb, + void *cb_data); + +int bt_mesh_net_decode(struct net_buf_simple *data, enum bt_mesh_net_if net_if, + struct bt_mesh_net_rx *rx, struct net_buf_simple *buf); + +void bt_mesh_net_recv(struct net_buf_simple *data, int8_t rssi, + enum bt_mesh_net_if net_if); + +bool bt_mesh_primary_subnet_exist(void); + +uint32_t bt_mesh_next_seq(void); + +void bt_mesh_net_start(void); + +void bt_mesh_net_init(void); +void bt_mesh_net_reset(void); +void bt_mesh_net_deinit(void); + +void bt_mesh_net_header_parse(struct net_buf_simple *buf, + struct bt_mesh_net_rx *rx); + +/* Friendship Credential Management */ +struct friend_cred { + uint16_t net_idx; + uint16_t addr; + + uint16_t lpn_counter; + uint16_t frnd_counter; + + struct { + uint8_t nid; /* NID */ + uint8_t enc[16]; /* EncKey */ + uint8_t privacy[16]; /* PrivacyKey */ + } cred[2]; +}; + +int friend_cred_get(struct bt_mesh_subnet *sub, uint16_t addr, uint8_t *nid, + const uint8_t **enc, const uint8_t **priv); +int friend_cred_set(struct friend_cred *cred, uint8_t idx, const uint8_t net_key[16]); +void friend_cred_refresh(uint16_t net_idx); +int friend_cred_update(struct bt_mesh_subnet *sub); +struct friend_cred *friend_cred_create(struct bt_mesh_subnet *sub, uint16_t addr, + uint16_t lpn_counter, uint16_t frnd_counter); +void friend_cred_clear(struct friend_cred *cred); +int friend_cred_del(uint16_t net_idx, uint16_t addr); + +static inline void send_cb_finalize(const struct bt_mesh_send_cb *cb, + void *cb_data) +{ + if (!cb) { + return; + } + + if (cb->start) { + cb->start(0, 0, cb_data); + } + + if (cb->end) { + cb->end(0, cb_data); + } +} + +#ifdef __cplusplus +} +#endif + +#endif /* _NET_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/prov.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/prov.h new file mode 100644 index 00000000000..789d33a3866 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/prov.h @@ -0,0 +1,43 @@ +/* Bluetooth Mesh */ + +/* + * SPDX-FileCopyrightText: 2017 Intel Corporation + * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#ifndef _PROV_H_ +#define _PROV_H_ + +#include "mesh_main.h" +#include "mesh_bearer_adapt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void bt_mesh_pb_adv_recv(struct net_buf_simple *buf); + +bool bt_prov_active(void); + +int bt_mesh_pb_gatt_open(struct bt_mesh_conn *conn); +int bt_mesh_pb_gatt_close(struct bt_mesh_conn *conn); +int bt_mesh_pb_gatt_recv(struct bt_mesh_conn *conn, struct net_buf_simple *buf); + +int bt_mesh_set_oob_pub_key(const uint8_t pub_key_x[32], const uint8_t pub_key_y[32], + const uint8_t pri_key[32]); + +const struct bt_mesh_prov *bt_mesh_prov_get(void); + +int bt_mesh_prov_init(const struct bt_mesh_prov *prov); +int bt_mesh_prov_deinit(void); + +void bt_mesh_prov_complete(uint16_t net_idx, const uint8_t net_key[16], + uint16_t addr, uint8_t flags, uint32_t iv_index); +void bt_mesh_prov_reset(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _PROV_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/provisioner_main.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/provisioner_main.h new file mode 100644 index 00000000000..9b01e31fb73 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/provisioner_main.h @@ -0,0 +1,145 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _PROVISIONER_MAIN_H_ +#define _PROVISIONER_MAIN_H_ + +#include "net.h" +#include "mesh_bearer_adapt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define BLE_MESH_INVALID_NODE_INDEX 0xFFFF +#define BLE_MESH_NODE_NAME_SIZE 31 + +/* Each node information stored by provisioner */ +struct bt_mesh_node { + /* Device information */ + uint8_t addr[6]; /* Node device address */ + uint8_t addr_type; /* Node device address type */ + uint8_t dev_uuid[16]; /* Node Device UUID */ + uint16_t oob_info; /* Node OOB information */ + + /* Provisioning information */ + uint16_t unicast_addr; /* Node unicast address */ + uint8_t element_num; /* Node element number */ + uint16_t net_idx; /* Node NetKey Index */ + uint8_t flags; /* Node key refresh flag and iv update flag */ + uint32_t iv_index; /* Node IV Index */ + uint8_t dev_key[16]; /* Node device key */ + + /* Additional information */ + char name[BLE_MESH_NODE_NAME_SIZE + 1]; /* Node name */ + uint16_t comp_length; /* Length of Composition Data */ + uint8_t *comp_data; /* Value of Composition Data */ +} __packed; + +int bt_mesh_provisioner_init(void); + +int bt_mesh_provisioner_net_create(void); + +void bt_mesh_provisioner_main_reset(bool erase); + +int bt_mesh_provisioner_deinit(bool erase); + +bool bt_mesh_provisioner_check_is_addr_dup(uint16_t addr, uint8_t elem_num, bool comp_with_own); + +uint16_t bt_mesh_provisioner_get_node_count(void); + +int bt_mesh_provisioner_restore_node_info(struct bt_mesh_node *node); + +int bt_mesh_provisioner_provision(const bt_mesh_addr_t *addr, const uint8_t uuid[16], + uint16_t oob_info, uint16_t unicast_addr, + uint8_t element_num, uint16_t net_idx, + uint8_t flags, uint32_t iv_index, + const uint8_t dev_key[16], uint16_t *index); + +int bt_mesh_provisioner_remove_node(const uint8_t uuid[16]); + +int bt_mesh_provisioner_restore_node_name(uint16_t addr, const char *name); + +int bt_mesh_provisioner_restore_node_comp_data(uint16_t addr, const uint8_t *data, uint16_t length); + +struct bt_mesh_node *bt_mesh_provisioner_get_node_with_uuid(const uint8_t uuid[16]); + +struct bt_mesh_node *bt_mesh_provisioner_get_node_with_addr(uint16_t unicast_addr); + +int bt_mesh_provisioner_delete_node_with_uuid(const uint8_t uuid[16]); + +int bt_mesh_provisioner_delete_node_with_node_addr(uint16_t unicast_addr); + +int bt_mesh_provisioner_delete_node_with_dev_addr(const bt_mesh_addr_t *addr); + +int bt_mesh_provisioner_set_node_name(uint16_t index, const char *name); + +const char *bt_mesh_provisioner_get_node_name(uint16_t index); + +uint16_t bt_mesh_provisioner_get_node_index(const char *name); + +struct bt_mesh_node *bt_mesh_provisioner_get_node_with_name(const char *name); + +const struct bt_mesh_node **bt_mesh_provisioner_get_node_table_entry(void); + +int bt_mesh_provisioner_store_node_comp_data(uint16_t addr, const uint8_t *data, uint16_t length); + +const uint8_t *bt_mesh_provisioner_net_key_get(uint16_t net_idx); + +struct bt_mesh_subnet *bt_mesh_provisioner_subnet_get(uint16_t net_idx); + +bool bt_mesh_provisioner_check_msg_dst(uint16_t dst); + +const uint8_t *bt_mesh_provisioner_dev_key_get(uint16_t dst); + +struct bt_mesh_app_key *bt_mesh_provisioner_app_key_find(uint16_t app_idx); + +int bt_mesh_provisioner_local_app_key_add(const uint8_t app_key[16], + uint16_t net_idx, uint16_t *app_idx); + +int bt_mesh_provisioner_local_app_key_update(const uint8_t app_key[16], + uint16_t net_idx, uint16_t app_idx); + +const uint8_t *bt_mesh_provisioner_local_app_key_get(uint16_t net_idx, uint16_t app_idx); + +int bt_mesh_provisioner_local_app_key_del(uint16_t net_idx, uint16_t app_idx, bool store); + +int bt_mesh_provisioner_local_net_key_add(const uint8_t net_key[16], uint16_t *net_idx); + +int bt_mesh_provisioner_local_net_key_update(const uint8_t net_key[16], uint16_t net_idx); + +const uint8_t *bt_mesh_provisioner_local_net_key_get(uint16_t net_idx); + +int bt_mesh_provisioner_local_net_key_del(uint16_t net_idx, bool store); + +/* Provisioner bind local client model with proper appkey index */ +int bt_mesh_provisioner_bind_local_model_app_idx(uint16_t elem_addr, uint16_t mod_id, + uint16_t cid, uint16_t app_idx); + +typedef void (* bt_mesh_heartbeat_recv_cb_t)(uint16_t hb_src, uint16_t hb_dst, + uint8_t init_ttl, uint8_t rx_ttl, + uint8_t hops, uint16_t feat, int8_t rssi); + +int bt_mesh_provisioner_recv_heartbeat(bt_mesh_heartbeat_recv_cb_t cb); + +int bt_mesh_provisioner_set_heartbeat_filter_type(uint8_t filter_type); + +int bt_mesh_provisioner_set_heartbeat_filter_info(uint8_t op, uint16_t src, uint16_t dst); + +void bt_mesh_provisioner_heartbeat(uint16_t hb_src, uint16_t hb_dst, + uint8_t init_ttl, uint8_t rx_ttl, + uint8_t hops, uint16_t feat, int8_t rssi); + +/* Provisioner print own element information */ +int bt_mesh_print_local_composition_data(void); + +int bt_mesh_provisioner_store_node_info(struct bt_mesh_node *node); + +#ifdef __cplusplus +} +#endif + +#endif /* _PROVISIONER_MAIN_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/provisioner_prov.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/provisioner_prov.h new file mode 100644 index 00000000000..66827232ad6 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/provisioner_prov.h @@ -0,0 +1,423 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _PROVISIONER_PROV_H_ +#define _PROVISIONER_PROV_H_ + +#include "mesh_main.h" +#include "mesh_bearer_adapt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef CONFIG_BLE_MESH_PBA_SAME_TIME +#define CONFIG_BLE_MESH_PBA_SAME_TIME 0 +#endif + +#ifndef CONFIG_BLE_MESH_PBG_SAME_TIME +#define CONFIG_BLE_MESH_PBG_SAME_TIME 0 +#endif + +#define RM_AFTER_PROV BIT(0) +#define START_PROV_NOW BIT(1) +#define FLUSHABLE_DEV BIT(2) + +struct bt_mesh_unprov_dev_add { + uint8_t addr[6]; + uint8_t addr_type; + uint8_t uuid[16]; + uint16_t oob_info; + uint8_t bearer; +}; + +struct bt_mesh_device_delete { + uint8_t addr[6]; + uint8_t addr_type; + uint8_t uuid[16]; +}; + +#define NET_IDX_FLAG BIT(0) +#define FLAGS_FLAG BIT(1) +#define IV_INDEX_FLAG BIT(2) + +struct bt_mesh_prov_data_info { + union { + uint16_t net_idx; + uint8_t flags; + uint32_t iv_index; + }; + uint8_t flag; +}; + +/* The following APIs are for primary provisioner internal use */ + +/** + * @brief This function decrements the current PB-GATT count. + * + * @return None + */ +void bt_mesh_provisioner_pbg_count_dec(void); + +/** + * @brief This function clears the part of the link info of the proper device. + * + * @param[in] addr: Remote device address + * + * @return None + */ +void bt_mesh_provisioner_clear_link_info(const uint8_t addr[6]); + +/** + * @brief This function handles the received PB-ADV PDUs. + * + * @param[in] buf: Pointer to the buffer containing generic provisioning PDUs + * + * @return Zero - success, otherwise - fail + */ +void bt_mesh_provisioner_pb_adv_recv(struct net_buf_simple *buf); + +/** + * @brief This function sends provisioning invite to start + * provisioning this unprovisioned device. + * + * @param[in] addr: Remote device address + * @param[in] conn: Pointer to the bt_conn structure + * + * @return Zero - success, otherwise - fail + */ +int bt_mesh_provisioner_set_prov_conn(const uint8_t addr[6], struct bt_mesh_conn *conn); + +/** + * @brief This function sends provisioning invite to start + * provisioning this unprovisioned device. + * + * @param[in] conn: Pointer to the bt_conn structure + * @param[in] addr: Address of the connected device + * + * @return Zero - success, otherwise - fail + */ +int bt_mesh_provisioner_pb_gatt_open(struct bt_mesh_conn *conn, uint8_t *addr); + +/** + * @brief This function resets the used information when + * related connection is terminated. + * + * @param[in] conn: Pointer to the bt_conn structure + * @param[in] reason: Connection terminated reason + * + * @return Zero - success, otherwise - fail + */ +int bt_mesh_provisioner_pb_gatt_close(struct bt_mesh_conn *conn, uint8_t reason); + +/** + * @brief This function handles the received PB-GATT provision + * PDUs. + * + * @param[in] conn: Pointer to the bt_conn structure + * @param[in] buf: Pointer to the buffer containing provision PDUs + * + * @return Zero - success, otherwise - fail + */ +int bt_mesh_provisioner_pb_gatt_recv(struct bt_mesh_conn *conn, struct net_buf_simple *buf); + +/** + * @brief This function initializes provisioner's PB-GATT and PB-ADV + * related information. + * + * @param[in] prov_info: Pointer to the application-initialized provisioner info. + * + * @return Zero - success, otherwise - fail + */ +int bt_mesh_provisioner_prov_init(const struct bt_mesh_prov *prov_info); + +int bt_mesh_provisioner_prov_reset(bool erase); + +/** + * @brief This function de-initializes provisioner's PB-GATT and PB-ADV + * related information. + * + * @param[in] erase: Indicate if erasing provisioning information from flash. + * + * @return Zero - success, otherwise - fail + */ +int bt_mesh_provisioner_prov_deinit(bool erase); + +/** + * @brief This function parses the received unprovisioned device + * beacon advertising packets, and if checked, starts to provision this device + * using PB-ADV bearer. + * + * @param[in] buf: Pointer to the buffer containing unprovisioned device beacon + * @param[in] rssi: RSSI of the received unprovisioned device beacon + * + * @return None + */ +void bt_mesh_provisioner_unprov_beacon_recv(struct net_buf_simple *buf, int8_t rssi); + +void bt_mesh_provisioner_prov_adv_recv(struct net_buf_simple *buf, + const bt_mesh_addr_t *addr, int8_t rssi); + +/** + * @brief This function gets the bt_mesh_prov pointer. + * + * @return bt_mesh_prov pointer(prov) + */ +const struct bt_mesh_prov *bt_mesh_provisioner_get_prov_info(void); + +void bt_mesh_provisioner_restore_prov_info(uint16_t primary_addr, uint16_t alloc_addr); + +/* The following APIs are for primary provisioner application use */ + +/** @brief Add unprovisioned device info to unprov_dev queue + * + * @param[in] add_dev: Pointer to the structure containing the device information + * @param[in] flags: Flags indicate several operations of the device information + * - Remove device information from queue after it is provisioned (BIT0) + * - Start provisioning as soon as device is added to queue (BIT1) + * - Device can be flushed when device queue is full (BIT2) + * + * @return Zero on success or (negative) error code otherwise. + * + * @note 1. Currently address type only supports public address and static random address. + * 2. If device UUID and/or device address and address type already exist in the + * device queue, but the bearer differs from the existing one, add operation + * will also be successful and it will update the provision bearer supported by + * the device. + */ +int bt_mesh_provisioner_add_unprov_dev(struct bt_mesh_unprov_dev_add *add_dev, uint8_t flags); + +/** @brief Provision an unprovisioned device with fixed unicast address. + * + * @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 + * @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 BLE_MESH_PROV_ADV or BLE_MESH_PROV_GATT + */ +int bt_mesh_provisioner_prov_device_with_addr(const uint8_t uuid[16], const uint8_t addr[6], + uint8_t addr_type, bt_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 + * + * @param[in] del_dev: Pointer to the structure containing the device information + * + * @return Zero on success or (negative) error code otherwise. + */ +int bt_mesh_provisioner_delete_device(struct bt_mesh_device_delete *del_dev); + +/** + * @brief This function sets a part of the device UUID for comparison before + * starting to provision the device. + * + * @param[in] offset: offset of the device UUID to be compared + * @param[in] length: length of the device UUID to be compared + * @param[in] match: value to be compared + * @param[in] prov_flag: flags indicate if uuid_match advertising packets are received, after that + * the device will be provisioned at once or reported to the application layer + * + * @return Zero - success, otherwise - fail + */ +int bt_mesh_provisioner_set_dev_uuid_match(uint8_t offset, uint8_t length, + const uint8_t *match, bool prov_flag); + +/** @brief Callback for provisioner receiving advertising packet from unprovisioned devices which are + * not in the unprovisioned device queue. + * + * Report on the unprovisioned device beacon and mesh provisioning service advertising data to application layer + * + * @param addr Unprovisioned device address pointer + * @param addr_type Unprovisioned device address type + * @param dev_uuid Unprovisioned device device UUID pointer + * @param bearer Advertising packet received from PB-GATT or PB-ADV bearer + * @param adv_type Adv packet type, currently this is not used and we can use bearer to device + * the adv_type(ADV_IND or ADV_NONCONN_IND). This parameter will be used, when + * scan response data will be supported. + * @param rssi RSSI of the received advertising packet + * + */ +typedef void (*unprov_adv_pkt_cb_t)(const uint8_t addr[6], const uint8_t addr_type, + const uint8_t adv_type, const uint8_t dev_uuid[16], + uint16_t oob_info, bt_mesh_prov_bearer_t bearer, int8_t rssi); + +/** + * @brief This function registers the callback which notifies the application + * layer of the received mesh provisioning or unprovisioned device + * beacon advertizing packets (from devices not in the unprov device queue). + * + * @param[in] cb: Callback of the notifying adv pkts function + * + * @return Zero - success, otherwise - fail + */ +int bt_mesh_provisioner_adv_pkt_cb_register(unprov_adv_pkt_cb_t cb); + +/** + * @brief This function changes net_idx or flags or iv_index used in provisioning data. + * + * @param[in] info: Pointer of structure containing net_idx or flags or iv_index + * + * @return Zero - success, otherwise - fail + */ +int bt_mesh_provisioner_set_prov_data_info(struct bt_mesh_prov_data_info *info); + +/** + * @brief This function initializes the provisioning information needed by Provisioner, + * including NetKey Index, flags, IV Index, etc. + * + * @return Zero - success, otherwise - fail + */ +int bt_mesh_provisioner_init_prov_info(void); + +/** + * @brief This function sets the provisioning bearer type used by Provisioner. + * + * @param[in] bearers: Provisioning bearer type + * @param[in] clear: Indicate if the corresponding bearer type will be cleared + * + * @return None + */ +void bt_mesh_provisioner_set_prov_bearer(bt_mesh_prov_bearer_t bearers, bool clear); + +/** + * @brief This function gets the provisioning bearer type used by Provisioner. + * + * @return Currently supported provisioning bearer type + */ +bt_mesh_prov_bearer_t bt_mesh_provisioner_get_prov_bearer(void); + +/** + * @brief This function sets the Static OOB value used by Provisioner. + * + * @param[in] value: Static OOB value + * @param[in] length: Static OOB value length + * + * @return Zero - success, otherwise - fail + */ +int bt_mesh_provisioner_set_static_oob_value(const uint8_t *value, uint8_t length); + +/** + * @brief This function gets the unicast address of primary element of Provisioner. + * + * @return Unicast address of primary element of Provisioner. + */ +uint16_t bt_mesh_provisioner_get_primary_elem_addr(void); + +/** + * @brief This function sets the unicast address of primary element of Provisioner. + * + * @param[in] addr: unicast address of primary element + * + * @return Zero - success, otherwise - fail + */ +int bt_mesh_provisioner_set_primary_elem_addr(uint16_t addr); + +/** + * @brief This function is used to update next allocated address by Provisioner. + * + * @note This function is used for mesh internal test. + * + * @param[in] unicast_addr: unicast address of the node + * @param[in] element_num: element count of the node + * + * @return Zero - success, otherwise - fail + */ +int bt_mesh_test_provisioner_update_alloc_addr(uint16_t unicast_addr, uint16_t element_num); + +/** + * @brief This function is called to input number/string out-put by unprovisioned device. + * + * @param[in] idx The provisioning link index + * @param[in] val Pointer of the input number/string + * @param[in] num_flag Flag indicates if it is a number or string + * + * @return Zero - success, otherwise - fail + */ +int bt_mesh_provisioner_set_oob_input_data(const uint8_t idx, const uint8_t *val, bool num_flag); + +/** + * @brief This function is called to output number/string which will be input by unprovisioned device. + * + * @param[in] idx The provisioning link index + * @param[in] num Pointer of the output number/string + * @param[in] size Size of the output number/string + * @param[in] num_flag Flag indicates if it is a number or string + * + * @return Zero - success, otherwise - fail + */ +int bt_mesh_provisioner_set_oob_output_data(const uint8_t idx, const uint8_t *num, + uint8_t size, bool num_flag); + +/** + * @brief This function is called to read unprovisioned device's oob public key. + * + * @param[in] idx The provisioning link index + * @param[in] pub_key_x Unprovisioned device's Public Key X + * @param[in] pub_key_y Unprovisioned device's Public Key Y + * + * @return Zero - success, otherwise - fail + */ +int bt_mesh_provisioner_read_oob_pub_key(const uint8_t idx, const uint8_t pub_key_x[32], + const uint8_t pub_key_y[32]); + +/* The following APIs are for fast provisioning */ + +/** + * @brief This function is called to set fast_prov_flag. + * + * @param[in] enable: Enable or disable fast provisioning + * + * @return None + */ +void bt_mesh_provisioner_fast_prov_enable(bool enable); + +/** + * @brief This function is called to set netkey index used for fast provisioning. + * + * @param[in] net_idx: Netkey index + * + * @return None + */ +void bt_mesh_provisioner_set_fast_prov_net_idx(uint16_t net_idx); + +/** + * @brief This function is called to get netkey index used for fast provisioning. + * + * @return net_idx of fast provisioning + */ +uint16_t bt_mesh_provisioner_get_fast_prov_net_idx(void); + +/** + * @brief This function is called to set unicast address range used for fast provisioning. + * + * @param[in] min: Minimum unicast address + * @param[in] max: Maximum unicast address + * + * @return status for set unicast address range message + */ +uint8_t bt_mesh_set_fast_prov_unicast_addr_range(uint16_t min, uint16_t max); + +/** + * @brief This function is called to set flags & iv_index used for fast provisioning. + * + * @param[in] flags: Key refresh flag and iv update flag + * @param[in] iv_index: IV index + * + * @return None + */ +void bt_mesh_set_fast_prov_flags_iv_index(uint8_t flags, uint32_t iv_index); + +#ifdef __cplusplus +} +#endif + +#endif /* _PROVISIONER_PROV_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/proxy_client.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/proxy_client.h new file mode 100644 index 00000000000..3c25a9b104d --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/proxy_client.h @@ -0,0 +1,112 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _PROXY_CLIENT_H_ +#define _PROXY_CLIENT_H_ + +#include "net.h" +#include "mesh_bearer_adapt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define BLE_MESH_PROXY_ADV_NET_ID 0x00 +#define BLE_MESH_PROXY_ADV_NODE_ID 0x01 + +#define BLE_MESH_PROXY_NET_PDU 0x00 +#define BLE_MESH_PROXY_BEACON 0x01 +#define BLE_MESH_PROXY_CONFIG 0x02 +#define BLE_MESH_PROXY_PROV 0x03 + +#define BLE_MESH_PROXY_CFG_FILTER_SET 0x00 +#define BLE_MESH_PROXY_CFG_FILTER_ADD 0x01 +#define BLE_MESH_PROXY_CFG_FILTER_REMOVE 0x02 +#define BLE_MESH_PROXY_CFG_FILTER_STATUS 0x03 + +typedef union { + struct { + uint8_t net_id[8]; + uint16_t net_idx; + } net_id; + struct { + uint16_t src; + } node_id; +} bt_mesh_proxy_adv_ctx_t; + +struct bt_mesh_proxy_net_pdu { + struct net_buf_simple *val; +}; + +struct bt_mesh_proxy_cfg_pdu { + uint8_t opcode; + union { + struct cfg_filter_set { + uint8_t filter_type; + } set; + struct cfg_addr_add { + uint16_t *addr; + uint16_t addr_num; + } add; + struct cfg_addr_remove { + uint16_t *addr; + uint16_t addr_num; + } remove; + }; +}; + +typedef struct { + uint8_t type; + union { + struct bt_mesh_proxy_net_pdu net; + struct bt_mesh_proxy_cfg_pdu cfg; + }; +} bt_mesh_proxy_client_pdu_t; + +int bt_mesh_proxy_client_send(struct bt_mesh_conn *conn, uint8_t type, + struct net_buf_simple *msg); + +int bt_mesh_proxy_client_prov_enable(void); +int bt_mesh_proxy_client_prov_disable(void); + +int bt_mesh_proxy_client_gatt_enable(void); +int bt_mesh_proxy_client_gatt_disable(void); + +typedef void (*proxy_client_recv_adv_cb_t)(const bt_mesh_addr_t *addr, uint8_t type, + bt_mesh_proxy_adv_ctx_t *ctx, int8_t rssi); +typedef void (*proxy_client_connect_cb_t)(const bt_mesh_addr_t *addr, + uint8_t conn_handle, uint16_t net_idx); +typedef void (*proxy_client_disconnect_cb_t)(const bt_mesh_addr_t *addr, uint8_t conn_handle, + uint16_t net_idx, uint8_t reason); +typedef void (*proxy_client_recv_filter_status_cb_t)(uint8_t conn_handle, uint16_t src, uint16_t net_idx, + uint8_t filter_type, uint16_t list_size); + +void bt_mesh_proxy_client_set_adv_recv_cb(proxy_client_recv_adv_cb_t cb); +void bt_mesh_proxy_client_set_conn_cb(proxy_client_connect_cb_t cb); +void bt_mesh_proxy_client_set_disconn_cb(proxy_client_disconnect_cb_t cb); +void bt_mesh_proxy_client_set_filter_status_cb(proxy_client_recv_filter_status_cb_t cb); + +void bt_mesh_proxy_client_gatt_adv_recv(struct net_buf_simple *buf, + const bt_mesh_addr_t *addr, int8_t rssi); + +int bt_mesh_proxy_client_connect(const uint8_t addr[6], uint8_t addr_type, uint16_t net_idx); +int bt_mesh_proxy_client_disconnect(uint8_t conn_handle); + +bool bt_mesh_proxy_client_beacon_send(struct bt_mesh_subnet *sub); + +bool bt_mesh_proxy_client_relay(struct net_buf_simple *buf, uint16_t dst); + +int bt_mesh_proxy_client_cfg_send(uint8_t conn_handle, uint16_t net_idx, + struct bt_mesh_proxy_cfg_pdu *pdu); + +int bt_mesh_proxy_client_init(void); +int bt_mesh_proxy_client_deinit(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _PROXY_CLIENT_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/proxy_server.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/proxy_server.h new file mode 100644 index 00000000000..d84dbd0ecfa --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/proxy_server.h @@ -0,0 +1,80 @@ +/* Bluetooth Mesh */ + +/* + * SPDX-FileCopyrightText: 2017 Intel Corporation + * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _PROXY_H_ +#define _PROXY_H_ + +#include "net.h" +#include "mesh_bearer_adapt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define BLE_MESH_PROXY_NET_PDU 0x00 +#define BLE_MESH_PROXY_BEACON 0x01 +#define BLE_MESH_PROXY_CONFIG 0x02 +#define BLE_MESH_PROXY_PROV 0x03 + +#if CONFIG_BLE_MESH_PROXY +/** + * Device Name Characteristic: + * 1. For iOS, when it tries to get the value of Device Name Characteristic, the PDU + * "Read By Type Request" will be used, and the valid length of corresponding + * response is 19 (23 - 1 - 1 - 2). + * 2. For Android, when it tries to get the value of Device Name Characteristic, the + * PDU "Read Request" will be used, and the valid length of corresponding response + * is 22 (23 - 1). + */ +#define DEVICE_NAME_SIZE MIN((BLE_MESH_GATT_DEF_MTU_SIZE - 4), (BLE_MESH_GAP_ADV_MAX_LEN - 2)) +#else +/* For Scan Response Data, the maximum length is 29 (31 - 1 - 1) currently. */ +#define DEVICE_NAME_SIZE (BLE_MESH_GAP_ADV_MAX_LEN - 2) +#endif + +typedef void (*proxy_server_connect_cb_t)(uint8_t conn_handle); +typedef void (*proxy_server_disconnect_cb_t)(uint8_t conn_handle, uint8_t reason); + +int bt_mesh_set_device_name(const char *name); + +int bt_mesh_proxy_server_send(struct bt_mesh_conn *conn, uint8_t type, + struct net_buf_simple *msg); + +int bt_mesh_proxy_server_prov_enable(void); +int bt_mesh_proxy_server_prov_disable(bool disconnect); + +void bt_mesh_proxy_server_set_conn_cb(proxy_server_connect_cb_t cb); +void bt_mesh_proxy_server_set_disconn_cb(proxy_server_disconnect_cb_t cb); + +int bt_mesh_proxy_server_gatt_enable(void); +int bt_mesh_proxy_server_gatt_disable(void); + +void bt_mesh_proxy_server_gatt_disconnect(void); + +void bt_mesh_proxy_server_beacon_send(struct bt_mesh_subnet *sub); + +struct net_buf_simple *bt_mesh_proxy_server_get_buf(void); + +int32_t bt_mesh_proxy_server_adv_start(void); +void bt_mesh_proxy_server_adv_stop(void); + +void bt_mesh_proxy_server_identity_start(struct bt_mesh_subnet *sub); +void bt_mesh_proxy_server_identity_stop(struct bt_mesh_subnet *sub); + +bool bt_mesh_proxy_server_relay(struct net_buf_simple *buf, uint16_t dst); +void bt_mesh_proxy_server_addr_add(struct net_buf_simple *buf, uint16_t addr); + +int bt_mesh_proxy_server_init(void); +int bt_mesh_proxy_server_deinit(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _PROXY_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/scan.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/scan.h new file mode 100644 index 00000000000..2d999565fad --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/scan.h @@ -0,0 +1,39 @@ +/* Bluetooth Mesh */ + +/* + * SPDX-FileCopyrightText: 2017 Intel Corporation + * SPDX-FileContributor: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _SCAN_H_ +#define _SCAN_H_ + +#include "mesh_bearer_adapt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +const bt_mesh_addr_t *bt_mesh_get_unprov_dev_addr(void); + +int bt_mesh_scan_enable(void); + +int bt_mesh_scan_disable(void); + +int bt_mesh_scan_with_wl_enable(void); + +struct bt_mesh_ble_scan_param { + uint32_t duration; +}; + +int bt_mesh_start_ble_scan(struct bt_mesh_ble_scan_param *param); + +int bt_mesh_stop_ble_scan(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _SCAN_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/settings.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/settings.h new file mode 100644 index 00000000000..dd112d70dd9 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/settings.h @@ -0,0 +1,79 @@ +/* + * SPDX-FileCopyrightText: 2018 Intel Corporation + * SPDX-FileContributor: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _SETTINGS_H_ +#define _SETTINGS_H_ + +#include "net.h" +#include "provisioner_main.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define BLE_MESH_SETTINGS_ROLE_NONE 0 +#define BLE_MESH_SETTINGS_ROLE_NODE (BIT(BLE_MESH_NODE)) +#define BLE_MESH_SETTINGS_ROLE_PROV (BIT(BLE_MESH_PROVISIONER)) +#define BLE_MESH_SETTINGS_ROLE_BIT_MASK (BIT(BLE_MESH_NODE) | BIT(BLE_MESH_PROVISIONER)) + +void bt_mesh_store_role(void); +void bt_mesh_store_net(void); +void bt_mesh_store_iv(bool only_duration); +void bt_mesh_store_seq(void); +void bt_mesh_clear_seq(void); +void bt_mesh_store_rpl(struct bt_mesh_rpl *rpl); +void bt_mesh_store_subnet(struct bt_mesh_subnet *sub); +void bt_mesh_store_app_key(struct bt_mesh_app_key *key); +void bt_mesh_store_hb_pub(void); +void bt_mesh_store_cfg(void); +void bt_mesh_store_mod_bind(struct bt_mesh_model *mod); +void bt_mesh_store_mod_sub(struct bt_mesh_model *mod); +void bt_mesh_store_mod_pub(struct bt_mesh_model *mod); +void bt_mesh_store_label(void); + +void bt_mesh_clear_role(void); +void bt_mesh_clear_net(void); +void bt_mesh_clear_subnet(struct bt_mesh_subnet *sub); +void bt_mesh_clear_app_key(struct bt_mesh_app_key *key); +void bt_mesh_clear_rpl(void); + +#if CONFIG_BLE_MESH_PROVISIONER +void bt_mesh_store_prov_info(uint16_t primary_addr, uint16_t alloc_addr); +void bt_mesh_clear_prov_info(void); +void bt_mesh_store_p_net_idx(void); +void bt_mesh_clear_p_net_idx(void); +void bt_mesh_store_p_app_idx(void); +void bt_mesh_clear_p_app_idx(void); +void bt_mesh_store_p_subnet(struct bt_mesh_subnet *sub); +void bt_mesh_store_p_app_key(struct bt_mesh_app_key *key); +void bt_mesh_clear_p_subnet(uint16_t net_idx); +void bt_mesh_clear_p_app_key(uint16_t app_idx); +void bt_mesh_clear_rpl_single(uint16_t src); +void bt_mesh_store_node_info(struct bt_mesh_node *node); +void bt_mesh_clear_node_info(uint16_t unicast_addr); +void bt_mesh_store_node_name(struct bt_mesh_node *node); +void bt_mesh_store_node_comp_data(struct bt_mesh_node *node); +#endif + +void bt_mesh_settings_lock(void); +void bt_mesh_settings_unlock(void); + +int settings_core_init(void); +int settings_core_load(void); +int settings_core_commit(void); +int settings_core_deinit(void); +int settings_core_erase(void); + +int bt_mesh_settings_init(void); +int bt_mesh_settings_deinit(bool erase); +void bt_mesh_settings_reset(bool erase); + +#ifdef __cplusplus +} +#endif + +#endif /* _SETTINGS_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/settings_uid.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/settings_uid.h new file mode 100644 index 00000000000..ef7dc93bc29 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/settings_uid.h @@ -0,0 +1,39 @@ +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _SETTINGS_UID_H_ +#define _SETTINGS_UID_H_ + +#include "mesh_types.h" +#include "settings_nvs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +int settings_uid_init(void); +int settings_uid_load(void); +int settings_uid_deinit(void); +int settings_uid_erase(void); + +int bt_mesh_provisioner_open_settings_with_index(uint8_t index); +int bt_mesh_provisioner_open_settings_with_uid(const char *id, uint8_t *index); +int bt_mesh_provisioner_close_settings_with_index(uint8_t index, bool erase); +int bt_mesh_provisioner_close_settings_with_uid(const char *id, bool erase, uint8_t *index); +int bt_mesh_provisioner_delete_settings_with_index(uint8_t index); +int bt_mesh_provisioner_delete_settings_with_uid(const char *id, uint8_t *index); + +const char *bt_mesh_provisioner_get_settings_uid(uint8_t index); +uint8_t bt_mesh_provisioner_get_settings_index(const char *id); +uint8_t bt_mesh_provisioner_get_free_settings_count(void); + +int bt_mesh_provisioner_direct_erase_settings(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _SETTINGS_UID_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/storage/settings_nvs.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/storage/settings_nvs.h new file mode 100644 index 00000000000..a82392cab61 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/storage/settings_nvs.h @@ -0,0 +1,67 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _BLE_MESH_SETTINGS_NVS_H_ +#define _BLE_MESH_SETTINGS_NVS_H_ + +#include "nvs_flash.h" +#include "mesh_buf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef nvs_handle_t bt_mesh_nvs_handle_t; + +#define SETTINGS_ITEM_SIZE sizeof(uint16_t) + +#define BLE_MESH_GET_ELEM_IDX(x) ((uint8_t)((x) >> 8)) +#define BLE_MESH_GET_MODEL_IDX(x) ((uint8_t)(x)) +#define BLE_MESH_GET_MODEL_KEY(a, b) ((uint16_t)(((uint16_t)((a) << 8)) | (b))) + +int bt_mesh_settings_nvs_open(const char* name, bt_mesh_nvs_handle_t *handle); +void bt_mesh_settings_nvs_close(bt_mesh_nvs_handle_t handle); + +void bt_mesh_settings_init_foreach(void); +void bt_mesh_settings_deinit_foreach(bool erase); + +int bt_mesh_settings_direct_open(bt_mesh_nvs_handle_t *handle); +void bt_mesh_settings_direct_close(void); + +int bt_mesh_save_settings(bt_mesh_nvs_handle_t handle, const char *key, + const uint8_t *val, size_t len); +int bt_mesh_save_core_settings(const char *key, const uint8_t *val, size_t len); +int bt_mesh_save_uid_settings(const char *key, const uint8_t *val, size_t len); + +int bt_mesh_erase_settings(bt_mesh_nvs_handle_t handle, const char *key); +int bt_mesh_erase_core_settings(const char *key); +int bt_mesh_erase_uid_settings(const char *name); + +int bt_mesh_load_settings(bt_mesh_nvs_handle_t handle, const char *key, + uint8_t *buf, size_t buf_len, bool *exist); +int bt_mesh_load_core_settings(const char *key, uint8_t *buf, size_t buf_len, bool *exist); +int bt_mesh_load_uid_settings(const char *key, uint8_t *buf, size_t buf_len, bool *exist); + +struct net_buf_simple *bt_mesh_get_settings_item(bt_mesh_nvs_handle_t handle, const char *key); +struct net_buf_simple *bt_mesh_get_core_settings_item(const char *key); +struct net_buf_simple *bt_mesh_get_uid_settings_item(const char *key); + +int bt_mesh_add_settings_item(bt_mesh_nvs_handle_t handle, const char *key, const uint16_t val); +int bt_mesh_add_core_settings_item(const char *key, const uint16_t val); +int bt_mesh_add_uid_settings_item(const char *key, const uint16_t val); + +int bt_mesh_remove_settings_item(bt_mesh_nvs_handle_t handle, const char *key, const uint16_t val); +int bt_mesh_remove_core_settings_item(const char *key, const uint16_t val); +int bt_mesh_remove_uid_settings_item(const char *key, const uint16_t val); + +int bt_mesh_settings_erase_key(bt_mesh_nvs_handle_t handle, const char *key); +int bt_mesh_settings_erase_all(bt_mesh_nvs_handle_t handle); + +#ifdef __cplusplus +} +#endif + +#endif /* _BLE_MESH_SETTINGS_NVS_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/test.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/test.h new file mode 100644 index 00000000000..c02947ac531 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/test.h @@ -0,0 +1,52 @@ +/* Bluetooth Mesh */ + +/* + * SPDX-FileCopyrightText: 2017 Intel Corporation + * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _BLE_MESH_TEST_H_ +#define _BLE_MESH_TEST_H_ + +#include "mesh_bearer_adapt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +int bt_mesh_test(void); + +struct bt_mesh_device_network_info { + uint8_t net_key[16]; + uint16_t net_idx; + uint8_t flags; + uint32_t iv_index; + uint16_t unicast_addr; + uint8_t dev_key[16]; + uint8_t app_key[16]; + uint16_t app_idx; + uint16_t group_addr; +}; + +int bt_mesh_device_auto_enter_network(struct bt_mesh_device_network_info *info); + +/* Before trying to update the white list, users need to make sure that + * one of the following conditions is satisfied: + * 1. BLE scanning is disabled; + * 2. BLE scanning is enabled with scan filter policy disabled; + * If BLE scanning is enabled with scan filter policy enabled, users need + * to stop BLE scanning firstly, then the white list can be updated. + */ +int bt_mesh_test_update_white_list(struct bt_mesh_white_list *wl); + +int bt_mesh_test_start_scanning(bool wl_en); + +int bt_mesh_test_stop_scanning(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _BLE_MESH_TEST_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/transport.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/transport.h new file mode 100644 index 00000000000..015b51e4df4 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_core/transport.h @@ -0,0 +1,128 @@ +/* Bluetooth Mesh */ + +/* + * SPDX-FileCopyrightText: 2017 Intel Corporation + * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _TRANSPORT_H_ +#define _TRANSPORT_H_ + +#include "net.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define TRANS_SEQ_AUTH_NVAL 0xffffffffffffffff + +#define BLE_MESH_SDU_UNSEG_MAX 11 +#define BLE_MESH_CTL_SEG_SDU_MAX 8 +#define BLE_MESH_APP_SEG_SDU_MAX 12 +#define BLE_MESH_TX_SDU_MAX (CONFIG_BLE_MESH_TX_SEG_MAX * 12) + +#define TRANS_SEQ_ZERO_MASK ((uint16_t)BIT_MASK(13)) +#define TRANS_CTL_OP_MASK ((uint8_t)BIT_MASK(7)) +#define TRANS_CTL_OP(data) ((data)[0] & TRANS_CTL_OP_MASK) +#define TRANS_CTL_HDR(op, seg) ((op & TRANS_CTL_OP_MASK) | (seg << 7)) + +#define TRANS_CTL_OP_ACK 0x00 +#define TRANS_CTL_OP_FRIEND_POLL 0x01 +#define TRANS_CTL_OP_FRIEND_UPDATE 0x02 +#define TRANS_CTL_OP_FRIEND_REQ 0x03 +#define TRANS_CTL_OP_FRIEND_OFFER 0x04 +#define TRANS_CTL_OP_FRIEND_CLEAR 0x05 +#define TRANS_CTL_OP_FRIEND_CLEAR_CFM 0x06 +#define TRANS_CTL_OP_FRIEND_SUB_ADD 0x07 +#define TRANS_CTL_OP_FRIEND_SUB_REM 0x08 +#define TRANS_CTL_OP_FRIEND_SUB_CFM 0x09 +#define TRANS_CTL_OP_HEARTBEAT 0x0a + +struct bt_mesh_ctl_friend_poll { + uint8_t fsn; +} __packed; + +struct bt_mesh_ctl_friend_update { + uint8_t flags; + uint32_t iv_index; + uint8_t md; +} __packed; + +struct bt_mesh_ctl_friend_req { + uint8_t criteria; + uint8_t recv_delay; + uint8_t poll_to[3]; + uint16_t prev_addr; + uint8_t num_elem; + uint16_t lpn_counter; +} __packed; + +struct bt_mesh_ctl_friend_offer { + uint8_t recv_win; + uint8_t queue_size; + uint8_t sub_list_size; + int8_t rssi; + uint16_t frnd_counter; +} __packed; + +struct bt_mesh_ctl_friend_clear { + uint16_t lpn_addr; + uint16_t lpn_counter; +} __packed; + +struct bt_mesh_ctl_friend_clear_confirm { + uint16_t lpn_addr; + uint16_t lpn_counter; +} __packed; + +#define BLE_MESH_FRIEND_SUB_MIN_LEN (1 + 2) +struct bt_mesh_ctl_friend_sub { + uint8_t xact; + uint16_t addr_list[5]; +} __packed; + +struct bt_mesh_ctl_friend_sub_confirm { + uint8_t xact; +} __packed; + +uint8_t bt_mesh_get_seg_retrans_num(void); + +int32_t bt_mesh_get_seg_retrans_timeout(uint8_t ttl); + +void bt_mesh_set_hb_sub_dst(uint16_t addr); + +struct bt_mesh_app_key *bt_mesh_app_key_find(uint16_t app_idx); + +bool bt_mesh_tx_in_progress(void); + +void bt_mesh_rx_reset(bool erase); +void bt_mesh_tx_reset(void); +void bt_mesh_rx_reset_single(uint16_t src); +void bt_mesh_tx_reset_single(uint16_t dst); + +int bt_mesh_ctl_send(struct bt_mesh_net_tx *tx, uint8_t ctl_op, void *data, + size_t data_len, const struct bt_mesh_send_cb *cb, + void *cb_data); + +int bt_mesh_trans_send(struct bt_mesh_net_tx *tx, struct net_buf_simple *msg, + const struct bt_mesh_send_cb *cb, void *cb_data); + +int bt_mesh_trans_recv(struct net_buf_simple *buf, struct bt_mesh_net_rx *rx); + +void bt_mesh_trans_init(void); +void bt_mesh_trans_deinit(bool erase); + +bool bt_mesh_rpl_check(struct bt_mesh_net_rx *rx, struct bt_mesh_rpl **match); + +void bt_mesh_heartbeat_send(void); + +int bt_mesh_app_key_get(const struct bt_mesh_subnet *subnet, uint16_t app_idx, + const uint8_t **key, uint8_t *aid, uint8_t role, uint16_t dst); + +#ifdef __cplusplus +} +#endif + +#endif /* _TRANSPORT_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/client/include/client_common.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/client/include/client_common.h new file mode 100644 index 00000000000..5d2bc64bec6 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/client/include/client_common.h @@ -0,0 +1,122 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _CLIENT_COMMON_H_ +#define _CLIENT_COMMON_H_ + +#include "mesh_access.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** Client model opcode pair table */ +typedef struct { + uint32_t cli_op; /* Client message opcode */ + uint32_t status_op; /* Corresponding status message opcode */ +} bt_mesh_client_op_pair_t; + +/** Client model user data context */ +typedef struct { + /** Pointer to the client model */ + struct bt_mesh_model *model; + + /** Size of the opcode pair table */ + int op_pair_size; + + /** Pointer to the opcode pair table */ + const bt_mesh_client_op_pair_t *op_pair; + + /** + * @brief This function is a callback function used to push the received unsolicited + * messages to the application layer. + * + * @param[in] opcode: Opcode of received status message + * @param[in] model: Model associated with the status message + * @param[in] ctx: Context information of the status message + * @param[in] buf: Buffer contains the status message value + * + * @return None + */ + void (*publish_status)(uint32_t opcode, struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf); + + /** Pointer to the internal data of client model */ + void *internal_data; + + /** Role of the device to which the client model belongs */ + uint8_t msg_role; +} bt_mesh_client_user_data_t; + +/** Client model internal data context */ +typedef struct { + sys_slist_t queue; +} bt_mesh_client_internal_data_t; + +/** Client model sending message related context */ +typedef struct { + sys_snode_t client_node; + struct bt_mesh_msg_ctx ctx; /* Message context */ + uint32_t opcode; /* Message opcode */ + uint32_t op_pending; /* Expected status message opcode */ + int32_t timeout; /* Calculated message timeout value */ + struct k_delayed_work timer; /* Time used to get response. Only for internal use. */ +} bt_mesh_client_node_t; + +/** Client model sending message parameters */ +typedef struct { + uint32_t opcode; /* Message opcode */ + struct bt_mesh_model *model; /* Pointer to the client model */ + struct bt_mesh_msg_ctx ctx; /* Message context */ + int32_t msg_timeout; /* Time to get corresponding response */ + uint8_t msg_role; /* Role (Node/Provisioner) of the device */ + const struct bt_mesh_send_cb *cb; /* User defined callback function */ + void *cb_data; /* User defined callback value */ +} bt_mesh_client_common_param_t; + +void bt_mesh_client_model_lock(void); + +void bt_mesh_client_model_unlock(void); + +int bt_mesh_client_init(struct bt_mesh_model *model); + +int bt_mesh_client_deinit(struct bt_mesh_model *model); + +/** + * @brief Check if the msg received by client model is a publish msg or not + * + * @param model Mesh (client) Model that the message belongs to. + * @param ctx Message context, includes keys, TTL, etc. + * @param buf The message buffer + * @param need_pub Indicate if the msg sent to app layer as a publish msg + * @return 0 on success, or (negative) error code on failure. + */ +bt_mesh_client_node_t *bt_mesh_is_client_recv_publish_msg(struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf, bool need_pub); + +int bt_mesh_client_send_msg(bt_mesh_client_common_param_t *param, + struct net_buf_simple *msg, bool need_ack, + k_work_handler_t timer_handler); + +int bt_mesh_client_free_node(bt_mesh_client_node_t *node); + +int bt_mesh_client_clear_list(void *data); + +/** + * @brief Set role of the client model for internal use. + * + * @param[in] model: Pointer to the client model + * @param[in] role: Role of the device + * + * @return Zero - success, otherwise - fail + */ +int bt_mesh_set_client_model_role(struct bt_mesh_model *model, uint8_t role); + +#ifdef __cplusplus +} +#endif + +#endif /* _CLIENT_COMMON_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/client/include/generic_client.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/client/include/generic_client.h new file mode 100644 index 00000000000..1e8a45e57f0 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/client/include/generic_client.h @@ -0,0 +1,408 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** @file + * @brief Bluetooth Mesh Generic Client Model APIs. + */ + +#ifndef _GENERIC_CLIENT_H_ +#define _GENERIC_CLIENT_H_ + +#include "client_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Generic client model common structure */ +typedef bt_mesh_client_user_data_t bt_mesh_generic_client_t; +typedef bt_mesh_client_internal_data_t generic_internal_data_t; + +/* Generic Client Model Callback */ +extern const struct bt_mesh_model_cb bt_mesh_generic_client_cb; + +/* Generic OnOff Client Model Context */ +extern const struct bt_mesh_model_op bt_mesh_gen_onoff_cli_op[]; + +/** @def BLE_MESH_MODEL_GEN_ONOFF_CLI + * + * Define a new generic onoff client model. Note that this API + * needs to be repeated for each element which the application + * wants to have a generic onoff client model on. + * @param cli_pub Pointer to a unique struct bt_mesh_model_pub. + * @param cli_data Pointer to a unique struct bt_mesh_gen_onoff_cli. + * + * @return New generic onoff client model instance. + */ +#define BLE_MESH_MODEL_GEN_ONOFF_CLI(cli_pub, cli_data) \ + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_GEN_ONOFF_CLI, \ + bt_mesh_gen_onoff_cli_op, cli_pub, cli_data, &bt_mesh_generic_client_cb) + +typedef bt_mesh_client_user_data_t bt_mesh_gen_onoff_client_t; + +struct bt_mesh_gen_onoff_status { + bool op_en; /* Indicate whether optional parameters included */ + uint8_t present_onoff; /* Present value of Generic OnOff state */ + uint8_t target_onoff; /* Target value of Generic OnOff state (optional) */ + uint8_t remain_time; /* Time to complete state transition (C.1) */ +}; + +struct bt_mesh_gen_onoff_set { + bool op_en; /* Indicate whether optional parameters included */ + uint8_t onoff; /* Target value of Generic OnOff state */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ +}; + +/* Generic Level Client Model Context */ +extern const struct bt_mesh_model_op bt_mesh_gen_level_cli_op[]; + +/** @def BLE_MESH_MODEL_GEN_LEVEL_CLI + * + * Define a new generic level client model. Note that this API + * needs to be repeated for each element which the application + * wants to have a generic level client model on. + * @param cli_pub Pointer to a unique struct bt_mesh_model_pub. + * @param cli_data Pointer to a unique struct bt_mesh_gen_level_cli. + * + * @return New generic level client model instance. + */ +#define BLE_MESH_MODEL_GEN_LEVEL_CLI(cli_pub, cli_data) \ + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_GEN_LEVEL_CLI, \ + bt_mesh_gen_level_cli_op, cli_pub, cli_data, &bt_mesh_generic_client_cb) + +typedef bt_mesh_client_user_data_t bt_mesh_gen_level_client_t; + +struct bt_mesh_gen_level_status { + bool op_en; /* Indicate whether optional parameters included */ + int16_t present_level; /* Present value of Generic Level state */ + int16_t target_level; /* Target value of the Generic Level state (optional) */ + uint8_t remain_time; /* Time to complete state transition (C.1) */ +}; + +struct bt_mesh_gen_level_set { + bool op_en; /* Indicate whether optional parameters included */ + int16_t level; /* Target value of Generic Level state */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ +}; + +struct bt_mesh_gen_delta_set { + bool op_en; /* Indicate whether optional parameters included */ + int32_t delta_level; /* Delta change of Generic Level state */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ +}; + +struct bt_mesh_gen_move_set { + bool op_en; /* Indicate whether optional parameters included */ + int16_t delta_level; /* Delta Level step to calculate Move speed for Generic Level state */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ +}; + +/* Generic Default Transition Time Client Model Context */ +extern const struct bt_mesh_model_op bt_mesh_gen_def_trans_time_cli_op[]; + +/** @def BLE_MESH_MODEL_GEN_DEF_TRANS_TIME_CLI + * + * Define a new generic default transition time client model. Note + * that this API needs to be repeated for each element that the + * application wants to have a generic default transition client + * model on. + * @param cli_pub Pointer to a unique struct bt_mesh_model_pub. + * @param cli_data Pointer to a unique struct bt_mesh_gen_def_trans_time_cli. + * + * @return New generic default transition time client model instance. + */ +#define BLE_MESH_MODEL_GEN_DEF_TRANS_TIME_CLI(cli_pub, cli_data) \ + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_CLI, \ + bt_mesh_gen_def_trans_time_cli_op, cli_pub, cli_data, &bt_mesh_generic_client_cb) + +typedef bt_mesh_client_user_data_t bt_mesh_gen_def_trans_time_client_t; + +struct bt_mesh_gen_def_trans_time_set { + uint8_t trans_time; /* The value of the Generic Default Transition Time state */ +}; + +struct bt_mesh_gen_def_trans_time_status { + uint8_t trans_time; /* The value of the Generic Default Transition Time state */ +}; + +/* Generic Power OnOff Client Model Context */ +extern const struct bt_mesh_model_op bt_mesh_gen_power_onoff_cli_op[]; + +/** @def BLE_MESH_MODEL_GEN_POWER_ONOFF_CLI + * + * Define a new generic power onoff client model. Note that this API + * needs to be repeated for each element which the application wants + * to have a generic power onoff client model on. + * @param cli_pub Pointer to a unique struct bt_mesh_model_pub. + * @param cli_data Pointer to a unique struct bt_mesh_gen_power_onoff_cli. + * + * @return New generic power onoff client model instance. + */ +#define BLE_MESH_MODEL_GEN_POWER_ONOFF_CLI(cli_pub, cli_data) \ + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_CLI, \ + bt_mesh_gen_power_onoff_cli_op, cli_pub, cli_data, &bt_mesh_generic_client_cb) + +typedef bt_mesh_client_user_data_t bt_mesh_gen_power_onoff_client_t; + +struct bt_mesh_gen_onpowerup_set { + uint8_t onpowerup; /* The value of the Generic OnPowerUp state */ +}; + +struct bt_mesh_gen_onpowerup_status { + uint8_t onpowerup; /* The value of the Generic OnPowerUp state */ +}; + +/* Generic Power Level Client Model Context */ +extern const struct bt_mesh_model_op bt_mesh_gen_power_level_cli_op[]; + +/** @def BLE_MESH_MODEL_GEN_POWER_LEVEL_CLI + * + * Define a new generic power level client model. Note that this API + * needs to be repeated for each element which the application wants + * to have a generic power level client model on. + * @param cli_pub Pointer to a unique struct bt_mesh_model_pub. + * @param cli_data Pointer to a unique struct bt_mesh_gen_power_level_cli. + * + * @return New generic power level client model instance. + */ +#define BLE_MESH_MODEL_GEN_POWER_LEVEL_CLI(cli_pub, cli_data) \ + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_CLI, \ + bt_mesh_gen_power_level_cli_op, cli_pub, cli_data, &bt_mesh_generic_client_cb) + +typedef bt_mesh_client_user_data_t bt_mesh_gen_power_level_client_t; + +struct bt_mesh_gen_power_level_status { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t present_power; /* Present value of Generic Power Actual state */ + uint16_t target_power; /* Target value of Generic Power Actual state (optional) */ + uint8_t remain_time; /* Time to complete state transition (C.1) */ +}; + +struct bt_mesh_gen_power_last_status { + uint16_t power; /* The value of the Generic Power Last state */ +}; + +struct bt_mesh_gen_power_default_status { + uint16_t power; /* The value of the Generic Default Last state */ +}; + +struct bt_mesh_gen_power_range_status { + uint8_t status_code; /* Status Code for the requesting message */ + 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 */ +}; + +struct bt_mesh_gen_power_level_set { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t power; /* Target value of Generic Power Actual state */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ +}; + +struct bt_mesh_gen_power_default_set { + uint16_t power; /* The value of the Generic Power Default state */ +}; + +struct bt_mesh_gen_power_range_set { + 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 */ +}; + +/* Generic Battery Client Model Context */ +extern const struct bt_mesh_model_op bt_mesh_gen_battery_cli_op[]; + +/** @def BLE_MESH_MODEL_GEN_BATTERY_CLI + * + * Define a new generic battery client model. Note that this API + * needs to be repeated for each element which the application + * wants to have a generic battery client model on. + * @param cli_pub Pointer to a unique struct bt_mesh_model_pub. + * @param cli_data Pointer to a unique struct bt_mesh_gen_battery_cli. + * + * @return New generic battery client model instance. + */ +#define BLE_MESH_MODEL_GEN_BATTERY_CLI(cli_pub, cli_data) \ + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_GEN_BATTERY_CLI, \ + bt_mesh_gen_battery_cli_op, cli_pub, cli_data, &bt_mesh_generic_client_cb) + +typedef bt_mesh_client_user_data_t bt_mesh_gen_battery_client_t; + +struct bt_mesh_gen_battery_status { + uint32_t battery_level : 8; /* Value of Generic Battery Level state */ + uint32_t time_to_discharge : 24; /* Value of Generic Battery Time to Discharge state */ + uint32_t time_to_charge : 24; /* Value of Generic Battery Time to Charge state */ + uint32_t flags : 8; /* Value of Generic Battery Flags state */ +}; + +/* Generic Location Client Model Context */ +extern const struct bt_mesh_model_op bt_mesh_gen_location_cli_op[]; + +/** @def BLE_MESH_MODEL_GEN_LOCATION_CLI + * + * Define a new generic location client model. Note that this API + * needs to be repeated for each element which the application + * wants to have a generic location client model on. + * @param cli_pub Pointer to a unique struct bt_mesh_model_pub. + * @param cli_data Pointer to a unique struct bt_mesh_gen_location_cli. + * + * @return New generic location client model instance. + */ +#define BLE_MESH_MODEL_GEN_LOCATION_CLI(cli_pub, cli_data) \ + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_GEN_LOCATION_CLI, \ + bt_mesh_gen_location_cli_op, cli_pub, cli_data, &bt_mesh_generic_client_cb) + +typedef bt_mesh_client_user_data_t bt_mesh_gen_location_client_t; + +struct bt_mesh_gen_loc_global_status { + int32_t global_latitude; /* Global Coordinates (Latitude) */ + int32_t global_longitude; /* Global Coordinates (Longitude) */ + int16_t global_altitude; /* Global Altitude */ +}; + +struct bt_mesh_gen_loc_local_status { + 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 */ +}; + +struct bt_mesh_gen_loc_global_set { + int32_t global_latitude; /* Global Coordinates (Latitude) */ + int32_t global_longitude; /* Global Coordinates (Longitude) */ + int16_t global_altitude; /* Global Altitude */ +}; + +struct bt_mesh_gen_loc_local_set { + 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 */ +}; + +/* Generic Property Client Model Context */ +extern const struct bt_mesh_model_op bt_mesh_gen_property_cli_op[]; + +/** @def BLE_MESH_MODEL_GEN_LOCATION_CLI + * + * Define a new generic location client model. Note that this API + * needs to be repeated for each element which the application + * wants to have a generic location client model on. + * @param cli_pub Pointer to a unique struct bt_mesh_model_pub. + * @param cli_data Pointer to a unique struct bt_mesh_gen_location_cli. + * + * @return New generic location client model instance. + */ +#define BLE_MESH_MODEL_GEN_PROPERTY_CLI(cli_pub, cli_data) \ + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_GEN_PROP_CLI, \ + bt_mesh_gen_property_cli_op, cli_pub, cli_data, &bt_mesh_generic_client_cb) + +typedef bt_mesh_client_user_data_t bt_mesh_gen_property_client_t; + +struct bt_mesh_gen_user_properties_status { + struct net_buf_simple *user_property_ids; /* Buffer contains a sequence of N User Property IDs */ +}; + +struct bt_mesh_gen_user_property_status { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t user_property_id; /* Property ID identifying a Generic User Property */ + uint8_t user_access; /* Enumeration indicating user access (optional) */ + struct net_buf_simple *user_property_value; /* Raw value for the User Property (C.1) */ +}; + +struct bt_mesh_gen_admin_properties_status { + struct net_buf_simple *admin_property_ids; /* Buffer contains a sequence of N Admin Property IDs */ +}; + +struct bt_mesh_gen_admin_property_status { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t admin_property_id; /* Property ID identifying a Generic Admin Property */ + uint8_t admin_user_access; /* Enumeration indicating user access (optional) */ + struct net_buf_simple *admin_property_value; /* Raw value for the Admin Property (C.1) */ +}; + +struct bt_mesh_gen_manu_properties_status { + struct net_buf_simple *manu_property_ids; /* Buffer contains a sequence of N Manufacturer Property IDs */ +}; + +struct bt_mesh_gen_manu_property_status { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t manu_property_id; /* Property ID identifying a Generic Manufacturer Property */ + uint8_t manu_user_access; /* Enumeration indicating user access (optional) */ + struct net_buf_simple *manu_property_value; /* Raw value for the Manufacturer Property (C.1) */ +}; + +struct bt_mesh_gen_client_properties_status { + struct net_buf_simple *client_property_ids; /* Buffer contains a sequence of N Client Property IDs */ +}; + +struct bt_mesh_gen_user_property_get { + uint16_t user_property_id; /* Property ID identifying a Generic User Property */ +}; + +struct bt_mesh_gen_user_property_set { + uint16_t user_property_id; /* Property ID identifying a Generic User Property */ + struct net_buf_simple *user_property_value; /* Raw value for the User Property */ +}; + +struct bt_mesh_gen_admin_property_get { + uint16_t admin_property_id; /* Property ID identifying a Generic Admin Property */ +}; + +struct bt_mesh_gen_admin_property_set { + uint16_t admin_property_id; /* Property ID identifying a Generic Admin Property */ + uint8_t admin_user_access; /* Enumeration indicating user access */ + struct net_buf_simple *admin_property_value; /* Raw value for the Admin Property */ +}; + +struct bt_mesh_gen_manu_property_get { + uint16_t manu_property_id; /* Property ID identifying a Generic Manufacturer Property */ +}; + +struct bt_mesh_gen_manu_property_set { + uint16_t manu_property_id; /* Property ID identifying a Generic Manufacturer Property */ + uint8_t manu_user_access; /* Enumeration indicating user access */ +}; + +struct bt_mesh_gen_client_properties_get { + uint16_t client_property_id; /* A starting Client Property ID present within an element */ +}; + +/** + * @brief This function is called to get generic states. + * + * @param[in] common: Message common information structure + * @param[in] get: Pointer of generic get message value + * + * @return Zero-success, other-fail + */ +int bt_mesh_generic_client_get_state(bt_mesh_client_common_param_t *common, void *get); + +/** + * @brief This function is called to set generic states. + * + * @param[in] common: Message common information structure + * @param[in] set: Pointer of generic set message value + * + * @return Zero-success, other-fail + */ +int bt_mesh_generic_client_set_state(bt_mesh_client_common_param_t *common, void *set); + +#ifdef __cplusplus +} +#endif + +#endif /* _GENERIC_CLIENT_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/client/include/lighting_client.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/client/include/lighting_client.h new file mode 100644 index 00000000000..4fcd7f31903 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/client/include/lighting_client.h @@ -0,0 +1,440 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** @file + * @brief Bluetooth Mesh Lighting Client Model APIs. + */ + +#ifndef _LIGHTING_CLIENT_H_ +#define _LIGHTING_CLIENT_H_ + +#include "client_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Light client model common structure */ +typedef bt_mesh_client_user_data_t bt_mesh_light_client_t; +typedef bt_mesh_client_internal_data_t light_internal_data_t; + +/* Lighting Client Model Callback */ +extern const struct bt_mesh_model_cb bt_mesh_lighting_client_cb; + +/* Light Lightness Client Model Context */ +extern const struct bt_mesh_model_op bt_mesh_light_lightness_cli_op[]; + +/** @def BLE_MESH_MODEL_LIGHT_LIGHTNESS_CLI + * + * Define a new light lightness client model. Note that this API + * needs to be repeated for each element which the application + * wants to have a light lightness client model on. + * @param cli_pub Pointer to a unique struct bt_mesh_model_pub. + * @param cli_data Pointer to a unique struct bt_mesh_light_lightness_cli. + * + * @return New light lightness client model instance. + */ +#define BLE_MESH_MODEL_LIGHT_LIGHTNESS_CLI(cli_pub, cli_data) \ + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_CLI, \ + bt_mesh_light_lightness_cli_op, cli_pub, cli_data, &bt_mesh_lighting_client_cb) + +typedef bt_mesh_client_user_data_t bt_mesh_light_lightness_client_t; + +struct bt_mesh_light_lightness_status { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t present_lightness; /* Present value of light lightness actual state */ + uint16_t target_lightness; /* Target value of light lightness actual state (optional) */ + uint8_t remain_time; /* Time to complete state transition (C.1) */ +}; + +struct bt_mesh_light_lightness_linear_status { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t present_lightness; /* Present value of light lightness linear state */ + uint16_t target_lightness; /* Target value of light lightness linear state (optional) */ + uint8_t remain_time; /* Time to complete state transition (C.1) */ +}; + +struct bt_mesh_light_lightness_last_status { + uint16_t lightness; /* The value of the Light Lightness Last state */ +}; + +struct bt_mesh_light_lightness_default_status { + uint16_t lightness; /* The value of the Light Lightness default state */ +}; + +struct bt_mesh_light_lightness_range_status { + uint8_t status_code; /* Status Code for the requesting message */ + uint16_t range_min; /* Value of range min field of light lightness range state */ + uint16_t range_max; /* Value of range max field of light lightness range state */ +}; + +struct bt_mesh_light_lightness_set { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t lightness; /* Target value of light lightness actual state */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ +}; + +struct bt_mesh_light_lightness_linear_set { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t lightness; /* Target value of light lightness linear state */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ +}; + +struct bt_mesh_light_lightness_default_set { + uint16_t lightness; /* The value of the Light Lightness Default state */ +}; + +struct bt_mesh_light_lightness_range_set { + uint16_t range_min; /* Value of range min field of light lightness range state */ + uint16_t range_max; /* Value of range max field of light lightness range state */ +}; + +/* Light CTL Client Model Context */ +extern const struct bt_mesh_model_op bt_mesh_light_ctl_cli_op[]; + +/** @def BLE_MESH_MODEL_LIGHT_CTL_CLI + * + * Define a new light CTL client model. Note that this API needs + * to be repeated for each element which the application wants to + * have a light CTL client model on. + * @param cli_pub Pointer to a unique struct bt_mesh_model_pub. + * @param cli_data Pointer to a unique struct bt_mesh_light_ctl_cli. + * + * @return New light CTL client model instance. + */ +#define BLE_MESH_MODEL_LIGHT_CTL_CLI(cli_pub, cli_data) \ + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_LIGHT_CTL_CLI, \ + bt_mesh_light_ctl_cli_op, cli_pub, cli_data, &bt_mesh_lighting_client_cb) + +typedef bt_mesh_client_user_data_t bt_mesh_light_ctl_client_t; + +struct bt_mesh_light_ctl_status { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t present_ctl_lightness; /* Present value of light ctl lightness state */ + uint16_t present_ctl_temperature; /* Present value of light ctl temperature state */ + uint16_t target_ctl_lightness; /* Target value of light ctl lightness state (optional) */ + uint16_t target_ctl_temperature; /* Target value of light ctl temperature state (C.1) */ + uint8_t remain_time; /* Time to complete state transition (C.1) */ +}; + +struct bt_mesh_light_ctl_temperature_status { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t present_ctl_temperature; /* Present value of light ctl temperature state */ + uint16_t present_ctl_delta_uv; /* Present value of light ctl delta UV state */ + uint16_t target_ctl_temperature; /* Target value of light ctl temperature state (optional) */ + uint16_t target_ctl_delta_uv; /* Target value of light ctl delta UV state (C.1) */ + uint8_t remain_time; /* Time to complete state transition (C.1) */ +}; + +struct bt_mesh_light_ctl_temperature_range_status { + uint8_t status_code; /* Status code for the requesting message */ + uint16_t range_min; /* Value of temperature range min field of light ctl temperature range state */ + uint16_t range_max; /* Value of temperature range max field of light ctl temperature range state */ +}; + +struct bt_mesh_light_ctl_default_status { + uint16_t lightness; /* Value of light lightness default state */ + uint16_t temperature; /* Value of light temperature default state */ + int16_t delta_uv; /* Value of light delta UV default state */ +}; + +struct bt_mesh_light_ctl_set { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t ctl_lightness; /* Target value of light ctl lightness state */ + uint16_t ctl_temperature; /* Target value of light ctl temperature state */ + int16_t ctl_delta_uv; /* Target value of light ctl delta UV state */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ +}; + +struct bt_mesh_light_ctl_temperature_set { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t ctl_temperature; /* Target value of light ctl temperature state */ + int16_t ctl_delta_uv; /* Target value of light ctl delta UV state */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ +}; + +struct bt_mesh_light_ctl_temperature_range_set { + uint16_t range_min; /* Value of temperature range min field of light ctl temperature range state */ + uint16_t range_max; /* Value of temperature range max field of light ctl temperature range state */ +}; + +struct bt_mesh_light_ctl_default_set { + uint16_t lightness; /* Value of light lightness default state */ + uint16_t temperature; /* Value of light temperature default state */ + int16_t delta_uv; /* Value of light delta UV default state */ +}; + +/* Light HSL Client Model Context */ +extern const struct bt_mesh_model_op bt_mesh_light_hsl_cli_op[]; + +/** @def BLE_MESH_MODEL_LIGHT_HSL_CLI + * + * Define a new light HSL client model. Note that this API needs + * to be repeated for each element which the application wants to + * have a light HSL client model on. + * @param cli_pub Pointer to a unique struct bt_mesh_model_pub. + * @param cli_data Pointer to a unique struct bt_mesh_light_hsl_cli. + * + * @return New light HSL client model instance. + */ +#define BLE_MESH_MODEL_LIGHT_HSL_CLI(cli_pub, cli_data) \ + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_LIGHT_HSL_CLI, \ + bt_mesh_light_hsl_cli_op, cli_pub, cli_data, &bt_mesh_lighting_client_cb) + +typedef bt_mesh_client_user_data_t bt_mesh_light_hsl_client_t; + +struct bt_mesh_light_hsl_status { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t hsl_lightness; /* Present value of light hsl lightness state */ + uint16_t hsl_hue; /* Present value of light hsl hue state */ + uint16_t hsl_saturation; /* Present value of light hsl saturation state */ + uint8_t remain_time; /* Time to complete state transition (optional) */ +}; + +struct bt_mesh_light_hsl_target_status { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t hsl_lightness_target; /* Target value of light hsl lightness state */ + uint16_t hsl_hue_target; /* Target value of light hsl hue state */ + uint16_t hsl_saturation_target; /* Target value of light hsl saturation state */ + uint8_t remain_time; /* Time to complete state transition (optional) */ +}; + +struct bt_mesh_light_hsl_hue_status { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t present_hue; /* Present value of light hsl hue state */ + uint16_t target_hue; /* Target value of light hsl hue state (optional) */ + uint8_t remain_time; /* Time to complete state transition (C.1) */ +}; + +struct bt_mesh_light_hsl_saturation_status { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t present_saturation; /* Present value of light hsl saturation state */ + uint16_t target_saturation; /* Target value of light hsl saturation state (optional) */ + uint8_t remain_time; /* Time to complete state transition (C.1) */ +}; + +struct bt_mesh_light_hsl_default_status { + uint16_t lightness; /* Value of light lightness default state */ + uint16_t hue; /* Value of light hue default state */ + uint16_t saturation; /* Value of light saturation default state */ +}; + +struct bt_mesh_light_hsl_range_status { + uint8_t status_code; /* Status code for the requesting message */ + uint16_t hue_range_min; /* Value of hue range min field of light hsl hue range state */ + uint16_t hue_range_max; /* Value of hue range max field of light hsl hue range state */ + uint16_t saturation_range_min; /* Value of saturation range min field of light hsl saturation range state */ + uint16_t saturation_range_max; /* Value of saturation range max field of light hsl saturation range state */ +}; + +struct bt_mesh_light_hsl_set { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t hsl_lightness; /* Target value of light hsl lightness state */ + uint16_t hsl_hue; /* Target value of light hsl hue state */ + uint16_t hsl_saturation; /* Target value of light hsl saturation state */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ +}; + +struct bt_mesh_light_hsl_hue_set { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t hue; /* Target value of light hsl hue state */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ +}; + +struct bt_mesh_light_hsl_saturation_set { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t saturation; /* Target value of light hsl hue state */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ +}; + +struct bt_mesh_light_hsl_default_set { + uint16_t lightness; /* Value of light lightness default state */ + uint16_t hue; /* Value of light hue default state */ + uint16_t saturation; /* Value of light saturation default state */ +}; + +struct bt_mesh_light_hsl_range_set { + uint16_t hue_range_min; /* Value of hue range min field of light hsl hue range state */ + uint16_t hue_range_max; /* Value of hue range max field of light hsl hue range state */ + uint16_t saturation_range_min; /* Value of saturation range min field of light hsl saturation range state */ + uint16_t saturation_range_max; /* Value of saturation range max field of light hsl saturation range state */ +}; + +/* Light xyL Client Model Context */ +extern const struct bt_mesh_model_op bt_mesh_light_xyl_cli_op[]; + +/** @def BLE_MESH_MODEL_LIGHT_XYL_CLI + * + * Define a new light xyL client model. Note that this API needs + * to be repeated for each element which the application wants + * to have a light xyL client model on. + * @param cli_pub Pointer to a unique struct bt_mesh_model_pub. + * @param cli_data Pointer to a unique struct bt_mesh_light_xyl_cli. + * + * @return New light xyL client model instance. + */ +#define BLE_MESH_MODEL_LIGHT_XYL_CLI(cli_pub, cli_data) \ + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_LIGHT_XYL_CLI, \ + bt_mesh_light_xyl_cli_op, cli_pub, cli_data, &bt_mesh_lighting_client_cb) + +typedef bt_mesh_client_user_data_t bt_mesh_light_xyl_client_t; + +struct bt_mesh_light_xyl_status { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t xyl_lightness; /* The present value of the Light xyL Lightness state */ + uint16_t xyl_x; /* The present value of the Light xyL x state */ + uint16_t xyl_y; /* The present value of the Light xyL y state */ + uint8_t remain_time; /* Time to complete state transition (optional) */ +}; + +struct bt_mesh_light_xyl_target_status { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t target_xyl_lightness; /* The target value of the Light xyL Lightness state */ + uint16_t target_xyl_x; /* The target value of the Light xyL x state */ + uint16_t target_xyl_y; /* The target value of the Light xyL y state */ + uint8_t remain_time; /* Time to complete state transition (optional) */ +}; + +struct bt_mesh_light_xyl_default_status { + uint16_t lightness; /* The value of the Light Lightness Default state */ + uint16_t xyl_x; /* The value of the Light xyL x Default state */ + uint16_t xyl_y; /* The value of the Light xyL y Default state */ +}; + +struct bt_mesh_light_xyl_range_status { + uint8_t status_code; /* Status Code for the requesting message */ + uint16_t xyl_x_range_min; /* The value of the xyL x Range Min field of the Light xyL x Range state */ + uint16_t xyl_x_range_max; /* The value of the xyL x Range Max field of the Light xyL x Range state */ + uint16_t xyl_y_range_min; /* The value of the xyL y Range Min field of the Light xyL y Range state */ + uint16_t xyl_y_range_max; /* The value of the xyL y Range Max field of the Light xyL y Range state */ +}; + +struct bt_mesh_light_xyl_set { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t xyl_lightness; /* The target value of the Light xyL Lightness state */ + uint16_t xyl_x; /* The target value of the Light xyL x state */ + uint16_t xyl_y; /* The target value of the Light xyL y state */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ +}; + +struct bt_mesh_light_xyl_default_set { + uint16_t lightness; /* The value of the Light Lightness Default state */ + uint16_t xyl_x; /* The value of the Light xyL x Default state */ + uint16_t xyl_y; /* The value of the Light xyL y Default state */ +}; + +struct bt_mesh_light_xyl_range_set { + uint16_t xyl_x_range_min; /* The value of the xyL x Range Min field of the Light xyL x Range state */ + uint16_t xyl_x_range_max; /* The value of the xyL x Range Max field of the Light xyL x Range state */ + uint16_t xyl_y_range_min; /* The value of the xyL y Range Min field of the Light xyL y Range state */ + uint16_t xyl_y_range_max; /* The value of the xyL y Range Max field of the Light xyL y Range state */ +}; + +/* Light LC Client Model Context */ +extern const struct bt_mesh_model_op bt_mesh_light_lc_cli_op[]; + +/** @def BLE_MESH_MODEL_LIGHT_LC_CLI + * + * Define a new light lc client model. Note that this API needs + * to be repeated for each element which the application wants + * to have a light lc client model on. + * @param cli_pub Pointer to a unique struct bt_mesh_model_pub. + * @param cli_data Pointer to a unique struct bt_mesh_light_lc_cli. + * + * @return New light lc client model instance. + */ +#define BLE_MESH_MODEL_LIGHT_LC_CLI(cli_pub, cli_data) \ + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_LIGHT_LC_CLI, \ + bt_mesh_light_lc_cli_op, cli_pub, cli_data, &bt_mesh_lighting_client_cb) + +typedef bt_mesh_client_user_data_t bt_mesh_light_lc_client_t; + +struct bt_mesh_light_lc_mode_status { + uint8_t mode; /* The present value of the Light LC Mode state */ +}; + +struct bt_mesh_light_lc_om_status { + uint8_t mode; /* The present value of the Light LC Occupancy Mode state */ +}; + +struct bt_mesh_light_lc_light_onoff_status { + bool op_en; /* Indicate whether optional parameters included */ + uint8_t present_light_onoff; /* The present value of the Light LC Light OnOff state */ + uint8_t target_light_onoff; /* The target value of the Light LC Light OnOff state (Optional) */ + uint8_t remain_time; /* Time to complete state transition (C.1) */ +}; + +struct bt_mesh_light_lc_property_status { + uint16_t light_lc_property_id; /* Property ID identifying a Light LC Property */ + struct net_buf_simple *light_lc_property_value; /* Raw value for the Light LC Property */ +}; + +struct bt_mesh_light_lc_mode_set { + uint8_t mode; /* The target value of the Light LC Mode state */ +}; + +struct bt_mesh_light_lc_om_set { + uint8_t mode; /* The target value of the Light LC Occupancy Mode state */ +}; + +struct bt_mesh_light_lc_light_onoff_set { + bool op_en; /* Indicate whether optional parameters included */ + uint8_t light_onoff; /* The target value of the Light LC Light OnOff state */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ +}; + +struct bt_mesh_light_lc_property_get { + uint16_t light_lc_property_id; /* Property ID identifying a Light LC Property */ +}; + +struct bt_mesh_light_lc_property_set { + uint16_t light_lc_property_id; /* Property ID identifying a Light LC Property */ + struct net_buf_simple *light_lc_property_value; /* Raw value for the Light LC Property */ +}; + +/** + * @brief This function is called to get light states. + * + * @param[in] common: Message common information structure + * @param[in] get: Pointer of light get message value + * + * @return Zero-success, other-fail + */ +int bt_mesh_light_client_get_state(bt_mesh_client_common_param_t *common, void *get); + +/** + * @brief This function is called to set light states. + * + * @param[in] common: Message common information structure + * @param[in] set: Pointer of light set message value + * + * @return Zero-success, other-fail + */ +int bt_mesh_light_client_set_state(bt_mesh_client_common_param_t *common, void *set); + +#ifdef __cplusplus +} +#endif + +#endif /* _LIGHTING_CLIENT_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/client/include/sensor_client.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/client/include/sensor_client.h new file mode 100644 index 00000000000..6dfcebdfbb2 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/client/include/sensor_client.h @@ -0,0 +1,155 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** @file + * @brief Bluetooth Mesh Sensor Client Model APIs. + */ + +#ifndef _SENSOR_CLIENT_H_ +#define _SENSOR_CLIENT_H_ + +#include "client_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Sensor Client Model Callback */ +extern const struct bt_mesh_model_cb bt_mesh_sensor_client_cb; + +/* Sensor Client Model Context */ +extern const struct bt_mesh_model_op bt_mesh_sensor_cli_op[]; + +/** @def BLE_MESH_MODEL_SENSOR_CLI + * + * Define a new sensor client model. Note that this API needs to + * be repeated for each element which the application wants to + * have a sensor client model on. + * @param cli_pub Pointer to a unique struct bt_mesh_model_pub. + * @param cli_data Pointer to a unique struct bt_mesh_sensor_cli. + * + * @return New sensor client model instance. + */ +#define BLE_MESH_MODEL_SENSOR_CLI(cli_pub, cli_data) \ + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_SENSOR_CLI, \ + bt_mesh_sensor_cli_op, cli_pub, cli_data, &bt_mesh_sensor_client_cb) + +typedef bt_mesh_client_user_data_t bt_mesh_sensor_client_t; +typedef bt_mesh_client_internal_data_t sensor_internal_data_t; + +struct bt_mesh_sensor_descriptor_status { + struct net_buf_simple *descriptor; /* Sequence of 8-octet sensor descriptors (optional) */ +}; + +struct bt_mesh_sensor_cadence_status { + uint16_t property_id; /* Property for the sensor */ + struct net_buf_simple *sensor_cadence_value; /* Value of sensor cadence state */ +}; + +struct bt_mesh_sensor_settings_status { + 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) */ +}; + +struct bt_mesh_sensor_setting_status { + bool op_en; /* Indicate whether optional parameters 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 */ +}; + +struct bt_mesh_sensor_status { + struct net_buf_simple *marshalled_sensor_data; /* Value of sensor data state (optional) */ +}; + +struct bt_mesh_sensor_column_status { + 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 */ +}; + +struct bt_mesh_sensor_series_status { + 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 */ +}; + +struct bt_mesh_sensor_descriptor_get { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t property_id; /* Property ID for the sensor (optional) */ +}; + +struct bt_mesh_sensor_cadence_get { + uint16_t property_id; /* Property ID for the sensor */ +}; + +struct bt_mesh_sensor_cadence_set { + 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 */ + 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 */ +}; + +struct bt_mesh_sensor_settings_get { + uint16_t sensor_property_id; /* Property ID for the sensor */ +}; + +struct bt_mesh_sensor_setting_get { + 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 bt_mesh_sensor_setting_set { + 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 */ +}; + +struct bt_mesh_sensor_get { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t property_id; /* Property ID for the sensor (optional) */ +}; + +struct bt_mesh_sensor_column_get { + uint16_t property_id; /* Property identifying a sensor */ + struct net_buf_simple *raw_value_x; /* Raw value identifying a column */ +}; + +struct bt_mesh_sensor_series_get { + bool op_en; /* Indicate whether optional parameters 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 a ending column (C.1) */ +}; + +/** + * @brief This function is called to get sensor states. + * + * @param[in] common: Message common information structure + * @param[in] get: Pointer of sensor get message value + * + * @return Zero-success, other-fail + */ +int bt_mesh_sensor_client_get_state(bt_mesh_client_common_param_t *common, void *get); + +/** + * @brief This function is called to set sensor states. + * + * @param[in] common: Message common information structure + * @param[in] set: Pointer of sensor set message value + * + * @return Zero-success, other-fail + */ +int bt_mesh_sensor_client_set_state(bt_mesh_client_common_param_t *common, void *set); + +#ifdef __cplusplus +} +#endif + +#endif /* _SENSOR_CLIENT_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/client/include/time_scene_client.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/client/include/time_scene_client.h new file mode 100644 index 00000000000..f7c7f5e58c4 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/client/include/time_scene_client.h @@ -0,0 +1,225 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** @file + * @brief Bluetooth Mesh Time and Scene Client Model APIs. + */ + +#ifndef _TIME_SCENE_CLIENT_H_ +#define _TIME_SCENE_CLIENT_H_ + +#include "client_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Time scene client model common structure */ +typedef bt_mesh_client_user_data_t bt_mesh_time_scene_client_t; +typedef bt_mesh_client_internal_data_t time_scene_internal_data_t; + +/* Time Scene Client Model Callback */ +extern const struct bt_mesh_model_cb bt_mesh_time_scene_client_cb; + +/* Time Client Model Context */ +extern const struct bt_mesh_model_op bt_mesh_time_cli_op[]; + +/** @def BLE_MESH_MODEL_TIME_CLI + * + * Define a new time client model. Note that this API needs to + * be repeated for each element which the application wants to + * have a time model on. + * @param cli_pub Pointer to a unique struct bt_mesh_model_pub. + * @param cli_data Pointer to a unique struct bt_mesh_time_cli. + * + * @return New time client model instance. + */ +#define BLE_MESH_MODEL_TIME_CLI(cli_pub, cli_data) \ + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_TIME_CLI, \ + bt_mesh_time_cli_op, cli_pub, cli_data, &bt_mesh_time_scene_client_cb) + +typedef bt_mesh_client_user_data_t bt_mesh_time_client_t; + +struct bt_mesh_time_status { + 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 */ +}; + +struct bt_mesh_time_zone_status { + 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 */ +}; + +struct bt_mesh_tai_utc_delta_status { + 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 */ +}; + +struct bt_mesh_time_role_status { + uint8_t time_role; /* The Time Role for the element */ +}; + +struct bt_mesh_time_set { + 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 */ +}; + +struct bt_mesh_time_zone_set { + 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 */ +}; + +struct bt_mesh_tai_utc_delta_set { + 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 */ +}; + +struct bt_mesh_time_role_set { + uint8_t time_role; /* The Time Role for the element */ +}; + +/* Scene Client Model Context */ +extern const struct bt_mesh_model_op bt_mesh_scene_cli_op[]; + +/** @def BLE_MESH_MODEL_SCENE_CLI + * + * Define a new scene client model. Note that this API needs to + * be repeated for each element which the application wants to + * have a scene model on. + * @param cli_pub Pointer to a unique struct bt_mesh_model_pub. + * @param cli_data Pointer to a unique struct bt_mesh_scene_cli. + * + * @return New scene client model instance. + */ +#define BLE_MESH_MODEL_SCENE_CLI(cli_pub, cli_data) \ + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_SCENE_CLI, \ + bt_mesh_scene_cli_op, cli_pub, cli_data, &bt_mesh_time_scene_client_cb) + +typedef bt_mesh_client_user_data_t bt_mesh_scene_client_t; + +struct bt_mesh_scene_status { + bool op_en; /* Indicate whether optional parameters included */ + uint8_t status_code; /* Status code for the last operation */ + uint16_t current_scene; /* Scene Number of a current scene */ + uint16_t target_scene; /* Scene Number of a target scene (optional) */ + uint8_t remain_time; /* Time to complete state transition (C.1) */ +}; + +struct bt_mesh_scene_register_status { + uint8_t status_code; /* Status code for the previous operation */ + uint16_t current_scene; /* Scene Number of a current scene */ + struct net_buf_simple *scenes; /* A list of scenes stored within an element */ +}; + +struct bt_mesh_scene_store { + uint16_t scene_number; /* The number of the scene to be stored */ +}; + +struct bt_mesh_scene_recall { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t scene_number; /* The number of the scene to be recalled */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ +}; + +struct bt_mesh_scene_delete { + uint16_t scene_number; /* The number of the scene to be deleted */ +}; + +/* Scheduler Client Model Context */ +extern const struct bt_mesh_model_op bt_mesh_scheduler_cli_op[]; + +/** @def BLE_MESH_MODEL_SCHEDULER_CLI + * + * Define a new scheduler client model. Note that this API needs to + * be repeated for each element which the application wants to + * have a scheduler model on. + * @param cli_pub Pointer to a unique struct bt_mesh_model_pub. + * @param cli_data Pointer to a unique struct bt_mesh_scheduler_cli. + * + * @return New scheduler client model instance. + */ +#define BLE_MESH_MODEL_SCHEDULER_CLI(cli_pub, cli_data) \ + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_SCHEDULER_CLI, \ + bt_mesh_scheduler_cli_op, cli_pub, cli_data, &bt_mesh_time_scene_client_cb) + +typedef bt_mesh_client_user_data_t bt_mesh_scheduler_client_t; + +struct bt_mesh_scheduler_status { + uint16_t schedules; /* Bit field indicating defined Actions in the Schedule Register */ +}; + +struct bt_mesh_scheduler_act_status { + 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 */ +}; + +struct bt_mesh_scheduler_act_get { + uint8_t index; /* Index of the Schedule Register entry to get */ +}; + +struct bt_mesh_scheduler_act_set { + 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 */ +}; + +/** + * @brief This function is called to get scene states. + * + * @param[in] common: Message common information structure + * @param[in] get: Pointer of time scene get message value + * + * @return Zero-success, other-fail + */ +int bt_mesh_time_scene_client_get_state(bt_mesh_client_common_param_t *common, void *get); + +/** + * @brief This function is called to set scene states. + * + * @param[in] common: Message common information structure + * @param[in] set: Pointer of time scene set message value + * + * @return Zero-success, other-fail + */ +int bt_mesh_time_scene_client_set_state(bt_mesh_client_common_param_t *common, void *set); + +#ifdef __cplusplus +} +#endif + +#endif /* _TIME_SCENE_CLIENT_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/common/include/device_property.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/common/include/device_property.h new file mode 100644 index 00000000000..74bf76a938f --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/common/include/device_property.h @@ -0,0 +1,1350 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _DEVICE_PROPERTY_H_ +#define _DEVICE_PROPERTY_H_ + +#include "mesh_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Details of BLE Mesh Device Properties. + * Note: For the size of the corresponding characteristic, please refer to the GATT_Specification_Supplement_v2. + * + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Property Name | ID | Characteristic | Size | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Average Ambient Temperature In A Period Of Day | 0x0001 | Temperature 8 In A Period Of Day | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Average Input Current | 0x0002 | Average Current | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Average Input Voltage | 0x0003 | Average Voltage | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Average Output Current | 0x0004 | Average Current | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Average Output Voltage | 0x0005 | Average Voltage | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Center Beam Intensity At Full Power | 0x0006 | Luminous Intensity | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Chromaticity Tolerance | 0x0007 | Chromaticity Tolerance | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Color Rendering Index R9 | 0x0008 | Cie 13.3-1995 Color Rendering Index | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Color Rendering Index Ra | 0x0009 | Cie 13.3-1995 Color Rendering Index | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Appearance | 0x000A | Gap.Appearance | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Country Of Origin | 0x000B | Country Code | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Date Of Manufacture | 0x000C | Date UTC | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Energy Use Since Turn On | 0x000D | Energy | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Firmware Revision | 0x000E | Fixed String 8 | 8 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Global Trade Item Number | 0x000F | Global Trade Item Number | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Hardware Revision | 0x0010 | Fixed String 16 | 16 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Manufacturer Name | 0x0011 | Fixed String 36 | 36 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Model Number | 0x0012 | Fixed String 24 | 24 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Operating Temperature Range Specification | 0x0013 | Temperature Range | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Operating Temperature Statistical Values | 0x0014 | Temperature Statistics | 9 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Over Temperature Event Statistics | 0x0015 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Power Range Specification | 0x0016 | Power Specification | 9 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Runtime Since Turn On | 0x0017 | Time Hour 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Runtime Warranty | 0x0018 | Time Hour 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Serial Number | 0x0019 | Fixed String 16 | 16 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Software Revision | 0x001A | Fixed String 8 | 8 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Under Temperature Event Statistics | 0x001B | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Indoor Ambient Temperature Statistical Values | 0x001C | Temperature 8 Statistics | 5 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Initial CIE 1931 Chromaticity Coordinates | 0x001D | Chromaticity Coordinates | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Initial Correlated Color Temperature | 0x001E | Correlated Color Temperature | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Initial Luminous Flux | 0x001F | Luminous Flux | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Initial Planckian Distance | 0x0020 | Chromatic Distance From Planckian | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Input Current Range Specification | 0x0021 | Electric Current Specification | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Input Current Statistics | 0x0022 | Electric Current Statistics | 9 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Input Over Current Event Statistics | 0x0023 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Input Over Ripple Voltage Event Statistics | 0x0024 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Input Over Voltage Event Statistics | 0x0025 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Input Under Current Event Statistics | 0x0026 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Input Under Voltage Event Statistics | 0x0027 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Input Voltage Range Specification | 0x0028 | Voltage Specification | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Input Voltage Ripple Specification | 0x0029 | Percentage 8 | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Input Voltage Statistics | 0x002A | Voltage Statistics | 9 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Ambient LuxLevel On | 0x002B | Illuminance | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Ambient LuxLevel Prolong | 0x002C | Illuminance | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Ambient LuxLevel Standby | 0x002D | Illuminance | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Lightness On | 0x002E | Perceived Lightness | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Lightness Prolong | 0x002F | Perceived Lightness | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Lightness Standby | 0x0030 | Perceived Lightness | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Regulator Accuracy | 0x0031 | Percentage 8 | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Regulator Kid | 0x0032 | Coefficient | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Regulator Kiu | 0x0033 | Coefficient | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Regulator Kpd | 0x0034 | Coefficient | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Regulator Kpu | 0x0035 | Coefficient | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Time Fade | 0x0036 | Time Millisecond 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Time Fade On | 0x0037 | Time Millisecond 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Time Fade Standby Auto | 0x0038 | Time Millisecond 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Time Fade Standby Manual | 0x0039 | Time Millisecond 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Time Occupancy Delay | 0x003A | Time Millisecond 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Time Prolong | 0x003B | Time Millisecond 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Time Run On | 0x003C | Time Millisecond 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Lumen Maintenance Factor | 0x003D | Percentage 8 | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Luminous Efficacy | 0x003E | Luminous Efficacy | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Luminous Energy Since Turn On | 0x003F | Luminous Energy | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Luminous Exposure | 0x0040 | Luminous Exposure | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Luminous Flux Range | 0x0041 | Luminous Flux Range | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Motion Sensed | 0x0042 | Percentage 8 | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Motion Threshold | 0x0043 | Percentage 8 | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Open Circuit Event Statistics | 0x0044 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Outdoor Statistical Values | 0x0045 | Temperature 8 Statistics | 5 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Output Current Range | 0x0046 | Electric Current Range | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Output Current Statistics | 0x0047 | Electric Current Statistics | 9 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Output Ripple Voltage Specification | 0x0048 | Percentage 8 | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Output Voltage Range | 0x0049 | Voltage Specification | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Output Voltage Statistics | 0x004A | Voltage Statistics | 9 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Over Output Ripple Voltage Event Statistics | 0x004B | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | People Count | 0x004C | Count 16 | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Presence Detected | 0x004D | Boolean | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Ambient Light Level | 0x004E | Illuminance | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Ambient Temperature | 0x004F | Temperature 8 | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present CIE 1931 Chromaticity Coordinates | 0x0050 | Chromaticity Coordinates | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Correlated Color Temperature | 0x0051 | Correlated Color Temperature | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Device Input Power | 0x0052 | Power | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Device Operating Efficiency | 0x0053 | Percentage 8 | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Device Operating Temperature | 0x0054 | Temperature | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Illuminance | 0x0055 | Illuminance | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Indoor Ambient Temperature | 0x0056 | Temperature 8 | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Input Current | 0x0057 | Electric Current | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Input Ripple Voltage | 0x0058 | Percentage 8 | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Input Voltage | 0x0059 | Voltage | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Luminous Flux | 0x005A | Luminous Flux | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Outdoor Ambient Temperature | 0x005B | Temperature 8 | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Output Current | 0x005C | Electric Current | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Output Voltage | 0x005D | Voltage | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Planckian Distance | 0x005E | Chromatic Distance From Planckian | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Relative Output Ripple Voltage | 0x005F | Percentage 8 | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Relative Device Energy Use In A Period Of Day | 0x0060 | Energy In A Period Of Day | 5 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Relative Device Runtime In A Generic Level Range | 0x0061 | Relative Runtime In A Generic Level Range | 5 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Relative Exposure Time In An Illuminance Range | 0x0062 | Relative Value In An Illuminance Range | 5 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Relative Runtime In A Correlated Color Temperature Range | 0x0063 | Luminous Energy | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Relative Runtime In A Device Operating Temperature Range | 0x0064 | Relative Value In A Temperature Range | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Relative Runtime In An Input Current Range | 0x0065 | Relative Runtime In A Current Range | 5 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Relative Runtime In An Input Voltage Range | 0x0066 | Relative Value In A Voltage Range | 5 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Short Circuit Event Statistics | 0x0067 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Time Since Motion Sensed | 0x0068 | Time Second 16 | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Time Since Presence Detected | 0x0069 | Time Second 16 | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Total Device Energy Use | 0x006A | Energy | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Total Device Off On Cycles | 0x006B | Count 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Total Device Power On Cycles | 0x006C | Count 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Total Device Power On Time | 0x006D | Time Hour 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Total Device Runtime | 0x006E | Time Hour 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Total Light Exposure Time | 0x006F | Time Hour 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Total Luminous Energy | 0x0070 | Luminous Energy | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Desired Ambient Temperature | 0x0071 | Temperature 8 | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Precise Total Device Energy Use | 0x0072 | Energy32 | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Power Factor | 0x0073 | Cosine Of The Angle | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Sensor Gain | 0x0074 | Coefficient | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Precise Present Ambient Temperature | 0x0075 | Temperature | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Ambient Relative Humidity | 0x0076 | Humidity | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Ambient Carbon Dioxide Concentration | 0x0077 | CO2 Concentration | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Ambient Volatile Organic Compounds Concentration | 0x0078 | VOC Concentration | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Ambient Noise | 0x0079 | Noise | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Active Energy Loadside | 0x0080 | Energy32 | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Active Power Loadside | 0x0081 | Power | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Air Pressure | 0x0082 | Pressure | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Apparent Energy | 0x0083 | Apparent Energy32 | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Apparent Power | 0x0084 | Apparent Power | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Apparent Wind Direction | 0x0085 | Apparent Wind Direction | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Apparent Wind Speed | 0x0086 | Apparent Wind Speed | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Dew Point | 0x0087 | Dew Point | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | External Supply Voltage | 0x0088 | High Voltage | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | External Supply Voltage Frequency | 0x0089 | Voltage Frequency | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Gust Factor | 0x008A | Gust Factor | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Heat Index | 0x008B | Heat Index | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Distribution | 0x008C | Light Distribution | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Source Current | 0x008D | Average Current | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Source On Time Not Resettable | 0x008E | Time Second 32 | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Source On Time Resettable | 0x008F | Time Second 32 | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Source Open Circuit Statistics | 0x0090 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Source Overall Failures Statistics | 0x0091 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Source Short Circuit Statistics | 0x0092 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Source Start Counter Resettable | 0x0093 | Count 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Source Temperature | 0x0094 | High Temperature | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Source Thermal Derating Statistics | 0x0095 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Source Thermal Shutdown Statistics | 0x0096 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Source Total Power On Cycles | 0x0097 | Count 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Source Voltage | 0x0098 | Average Voltage | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Luminaire Color | 0x0099 | Fixed String 24 | 24 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Luminaire Identification Number | 0x009A | Fixed String 24 | 24 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Luminaire Manufacturer GTIN | 0x009B | Global Trade Item Number | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Luminaire Nominal Input Power | 0x009C | Power | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Luminaire Nominal Maximum AC Mains Voltage | 0x009D | Voltage | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Luminaire Nominal Minimum AC Mains Voltage | 0x009E | Voltage | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Luminaire Power At Minimum Dim Level | 0x009F | Power | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Luminaire Time Of Manufacture | 0x00A0 | Date UTC | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Magnetic Declination | 0x00A1 | Magnetic Declination | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Magnetic Flux Density - 2D | 0x00A2 | Magnetic Flux Density - 2D | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Magnetic Flux Density - 3D | 0x00A3 | Magnetic Flux Density - 3D | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Nominal Light Output | 0x00A4 | Light Output | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Overall Failure Condition | 0x00A5 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Pollen Concentration | 0x00A6 | Pollen Concentration | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Indoor Relative Humidity | 0x00A7 | Humidity | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Outdoor Relative Humidity | 0x00A8 | Humidity | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Pressure | 0x00A9 | Pressure | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Rainfall | 0x00AA | Rainfall | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Rated Median Useful Life Of Luminaire | 0x00AB | Time Hour 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Rated Median Useful Light Source Starts | 0x00AC | Count 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Reference Temperature | 0x00AD | High Temperature | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Total Device Starts | 0x00AE | Count 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | True Wind Direction | 0x00AF | True Wind Direction | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | True Wind Speed | 0x00B0 | True Wind Speed | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | UV Index | 0x00B1 | UV Index | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Wind Chill | 0x00B2 | Wind Chill | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Source Type | 0x00B3 | Light Source Type | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Luminaire Identification String | 0x00B4 | Fixed String 64 | 64 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Output Power Limitation | 0x00B5 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Thermal Derating | 0x00B6 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Output Current Percent | 0x00B7 | Percentage 8 | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + */ + +/** + * @brief BLE Mesh Device Property IDs + */ +#define BLE_MESH_INVALID_DEVICE_PROPERTY_ID 0x0000 +#define BLE_MESH_AVERAGE_AMBIENT_TEMPERATURE_IN_A_PERIOD_OF_DAY 0x0001 +#define BLE_MESH_AVERAGE_INPUT_CURRENT 0x0002 +#define BLE_MESH_AVERAGE_INPUT_VOLTAGE 0x0003 +#define BLE_MESH_AVERAGE_OUTPUT_CURRENT 0x0004 +#define BLE_MESH_AVERAGE_OUTPUT_VOLTAGE 0x0005 +#define BLE_MESH_CENTER_BEAM_INTENSITY_AT_FULL_POWER 0x0006 +#define BLE_MESH_CHROMATICITY_TOLERANCE 0x0007 +#define BLE_MESH_COLOR_RENDERING_INDEX_R9 0x0008 +#define BLE_MESH_COLOR_RENDERING_INDEX_RA 0x0009 +#define BLE_MESH_DEVICE_APPEARANCE 0x000A +#define BLE_MESH_DEVICE_COUNTRY_OF_ORIGIN 0x000B +#define BLE_MESH_DEVICE_DATE_OF_MANUFACTURE 0x000C +#define BLE_MESH_DEVICE_ENERGY_USE_SINCE_TURN_ON 0x000D +#define BLE_MESH_DEVICE_FIRMWARE_REVISION 0x000E +#define BLE_MESH_DEVICE_GLOBAL_TRADE_ITEM_NUMBER 0x000F +#define BLE_MESH_DEVICE_HARDWARE_REVISION 0x0010 +#define BLE_MESH_DEVICE_MANUFACTURER_NAME 0x0011 +#define BLE_MESH_DEVICE_MODEL_NUMBER 0x0012 +#define BLE_MESH_DEVICE_OPERATING_TEMPERATURE_RANGE_SPECIFICATION 0x0013 +#define BLE_MESH_DEVICE_OPERATING_TEMPERATURE_STATISTICAL_VALUES 0x0014 +#define BLE_MESH_DEVICE_OVER_TEMPERATURE_EVENT_STATISTICS 0x0015 +#define BLE_MESH_DEVICE_POWER_RANGE_SPECIFICATION 0x0016 +#define BLE_MESH_DEVICE_RUNTIME_SINCE_TURN_ON 0x0017 +#define BLE_MESH_DEVICE_RUNTIME_WARRANTY 0x0018 +#define BLE_MESH_DEVICE_SERIAL_NUMBER 0x0019 +#define BLE_MESH_DEVICE_SOFTWARE_REVISION 0x001A +#define BLE_MESH_DEVICE_UNDER_TEMPERATURE_EVENT_STATISTICS 0x001B +#define BLE_MESH_INDOOR_AMBIENT_TEMPERATURE_STATISTICAL_VALUES 0x001C +#define BLE_MESH_INITIAL_CIE_1931_CHROMATICITY_COORDINATES 0x001D +#define BLE_MESH_INITIAL_CORRELATED_COLOR_TEMPERATURE 0x001E +#define BLE_MESH_INITIAL_LUMINOUS_FLUX 0x001F +#define BLE_MESH_INITIAL_PLANCKIAN_DISTANCE 0x0020 +#define BLE_MESH_INPUT_CURRENT_RANGE_SPECIFICATION 0x0021 +#define BLE_MESH_INPUT_CURRENT_STATISTICS 0x0022 +#define BLE_MESH_INPUT_OVER_CURRENT_EVENT_STATISTICS 0x0023 +#define BLE_MESH_INPUT_OVER_RIPPLE_VOLTAGE_EVENT_STATISTICS 0x0024 +#define BLE_MESH_INPUT_OVER_VOLTAGE_EVENT_STATISTICS 0x0025 +#define BLE_MESH_INPUT_UNDER_CURRENT_EVENT_STATISTICS 0x0026 +#define BLE_MESH_INPUT_UNDER_VOLTAGE_EVENT_STATISTICS 0x0027 +#define BLE_MESH_INPUT_VOLTAGE_RANGE_SPECIFICATION 0x0028 +#define BLE_MESH_INPUT_VOLTAGE_RIPPLE_SPECIFICATION 0x0029 +#define BLE_MESH_INPUT_VOLTAGE_STATISTICS 0x002A +#define BLE_MESH_LIGHT_CONTROL_AMBIENT_LUXLEVEL_ON 0x002B +#define BLE_MESH_LIGHT_CONTROL_AMBIENT_LUXLEVEL_PROLONG 0x002C +#define BLE_MESH_LIGHT_CONTROL_AMBIENT_LUXLEVEL_STANDBY 0x002D +#define BLE_MESH_LIGHT_CONTROL_LIGHTNESS_ON 0x002E +#define BLE_MESH_LIGHT_CONTROL_LIGHTNESS_PROLONG 0x002F +#define BLE_MESH_LIGHT_CONTROL_LIGHTNESS_STANDBY 0x0030 +#define BLE_MESH_LIGHT_CONTROL_REGULATOR_ACCURACY 0x0031 +#define BLE_MESH_LIGHT_CONTROL_REGULATOR_KID 0x0032 +#define BLE_MESH_LIGHT_CONTROL_REGULATOR_KIU 0x0033 +#define BLE_MESH_LIGHT_CONTROL_REGULATOR_KPD 0x0034 +#define BLE_MESH_LIGHT_CONTROL_REGULATOR_KPU 0x0035 +#define BLE_MESH_LIGHT_CONTROL_TIME_FADE 0x0036 +#define BLE_MESH_LIGHT_CONTROL_TIME_FADE_ON 0x0037 +#define BLE_MESH_LIGHT_CONTROL_TIME_FADE_STANDBY_AUTO 0x0038 +#define BLE_MESH_LIGHT_CONTROL_TIME_FADE_STANDBY_MANUAL 0x0039 +#define BLE_MESH_LIGHT_CONTROL_TIME_OCCUPANCY_DELAY 0x003A +#define BLE_MESH_LIGHT_CONTROL_TIME_PROLONG 0x003B +#define BLE_MESH_LIGHT_CONTROL_TIME_RUN_ON 0x003C +#define BLE_MESH_LUMEN_MAINTENANCE_FACTOR 0x003D +#define BLE_MESH_LUMINOUS_EFFICACY 0x003E +#define BLE_MESH_LUMINOUS_ENERGY_SINCE_TURN_ON 0x003F +#define BLE_MESH_LUMINOUS_EXPOSURE 0x0040 +#define BLE_MESH_LUMINOUS_FLUX_RANGE 0x0041 +#define BLE_MESH_MOTION_SENSED 0x0042 +#define BLE_MESH_MOTION_THRESHOLD 0x0043 +#define BLE_MESH_OPEN_CIRCUIT_EVENT_STATISTICS 0x0044 +#define BLE_MESH_OUTDOOR_STATISTICAL_VALUES 0x0045 +#define BLE_MESH_OUTPUT_CURRENT_RANGE 0x0046 +#define BLE_MESH_OUTPUT_CURRENT_STATISTICS 0x0047 +#define BLE_MESH_OUTPUT_RIPPLE_VOLTAGE_SPECIFICATION 0x0048 +#define BLE_MESH_OUTPUT_VOLTAGE_RANGE 0x0049 +#define BLE_MESH_OUTPUT_VOLTAGE_STATISTICS 0x004A +#define BLE_MESH_OVER_OUTPUT_RIPPLE_VOLTAGE_EVENT_STATISTICS 0x004B +#define BLE_MESH_PEOPLE_COUNT 0x004C +#define BLE_MESH_PRESENCE_DETECTED 0x004D +#define BLE_MESH_PRESENT_AMBIENT_LIGHT_LEVEL 0x004E +#define BLE_MESH_PRESENT_AMBIENT_TEMPERATURE 0x004F +#define BLE_MESH_PRESENT_CIE_1931_CHROMATICITY 0x0050 +#define BLE_MESH_PRESENT_CORRELATED_COLOR_TEMPERATURE 0x0051 +#define BLE_MESH_PRESENT_DEVICE_INPUT_POWER 0x0052 +#define BLE_MESH_PRESENT_DEVICE_OPERATING_EFFICIENCY 0x0053 +#define BLE_MESH_PRESENT_DEVICE_OPERATING_TEMPERATURE 0x0054 +#define BLE_MESH_PRESENT_ILLUMINANCE 0x0055 +#define BLE_MESH_PRESENT_INDOOR_AMBIENT_TEMPERATURE 0x0056 +#define BLE_MESH_PRESENT_INPUT_CURRENT 0x0057 +#define BLE_MESH_PRESENT_INPUT_RIPPLE_VOLTAGE 0x0058 +#define BLE_MESH_PRESENT_INPUT_VOLTAGE 0x0059 +#define BLE_MESH_PRESENT_LUMINOUS_FLUX 0x005A +#define BLE_MESH_PRESENT_OUTDOOR_AMBIENT_TEMPERATURE 0x005B +#define BLE_MESH_PRESENT_OUTPUT_CURRENT 0x005C +#define BLE_MESH_PRESENT_OUTPUT_VOLTAGE 0x005D +#define BLE_MESH_PRESENT_PLANCKIAN_DISTANCE 0x005E +#define BLE_MESH_PRESENT_RELATIVE_OUTPUT_RIPPLE_VOLTAGE 0x005F +#define BLE_MESH_RELATIVE_DEVICE_ENERGY_USE_IN_A_PERIOD_OF_DAY 0x0060 +#define BLE_MESH_RELATIVE_DEVICE_RUNTIME_IN_A_GENERIC_LEVEL_RANGE 0x0061 +#define BLE_MESH_RELATIVE_EXPOSURE_TIME_IN_AN_ILLUMINANCE_RANGE 0x0062 +#define BLE_MESH_RELATIVE_RUNTIME_IN_A_CORRELATED_COLOR_TEMPERATURE_RANGE 0x0063 +#define BLE_MESH_RELATIVE_RUNTIME_IN_A_DEVICE_OPERATING_TEMPERATURE_RANGE 0x0064 +#define BLE_MESH_RELATIVE_RUNTIME_IN_AN_INPUT_CURRENT_RANGE 0x0065 +#define BLE_MESH_RELATIVE_RUNTIME_IN_AN_INPUT_VOLTAGE_RANGE 0x0066 +#define BLE_MESH_SHORT_CIRCUIT_EVENT_STATISTICS 0x0067 +#define BLE_MESH_TIME_SINCE_MOTION_SENSED 0x0068 +#define BLE_MESH_TIME_SINCE_PRESENCE_DETECTED 0x0069 +#define BLE_MESH_TOTAL_DEVICE_ENERGY_USE 0x006A +#define BLE_MESH_TOTAL_DEVICE_OFF_ON_CYCLES 0x006B +#define BLE_MESH_TOTAL_DEVICE_POWER_ON_CYCLES 0x006C +#define BLE_MESH_TOTAL_DEVICE_POWER_ON_TIME 0x006D +#define BLE_MESH_TOTAL_DEVICE_RUNTIME 0x006E +#define BLE_MESH_TOTAL_LIGHT_EXPOSURE_TIME 0x006F +#define BLE_MESH_TOTAL_LUMINOUS_ENERGY 0x0070 +#define BLE_MESH_DESIRED_AMBIENT_TEMPERATURE 0x0071 +#define BLE_MESH_PRECISE_TOTAL_DEVICE_ENERGY_USE 0x0072 +#define BLE_MESH_POWER_FACTOR 0x0073 +#define BLE_MESH_SENSOR_GAIN 0x0074 +#define BLE_MESH_PRECISE_PRESENT_AMBIENT_TEMPERATURE 0x0075 +#define BLE_MESH_PRESENT_AMBIENT_RELATIVE_HUMIDITY 0x0076 +#define BLE_MESH_PRESENT_AMBIENT_CARBON_DIOXIDE_CONCENTRATION 0x0077 +#define BLE_MESH_PRESENT_AMBIENT_VOLATILE_ORGANIC_COMPOUNDS_CONCENTRATION 0x0078 +#define BLE_MESH_PRESENT_AMBIENT_NOISE 0x0079 +#define BLE_MESH_ACTIVE_ENERGY_LOADSIDE 0x0080 +#define BLE_MESH_ACTIVE_POWER_LOADSIDE 0x0081 +#define BLE_MESH_AIR_PRESSURE 0x0082 +#define BLE_MESH_APPARENT_ENERGY 0x0083 +#define BLE_MESH_APPARENT_POWER 0x0084 +#define BLE_MESH_APPARENT_WIND_DIRECTION 0x0085 +#define BLE_MESH_APPARENT_WIND_SPEED 0x0086 +#define BLE_MESH_DEW_POINT 0x0087 +#define BLE_MESH_EXTERNAL_SUPPLY_VOLTAGE 0x0088 +#define BLE_MESH_EXTERNAL_SUPPLY_VOLTAGE_FREQUENCY 0x0089 +#define BLE_MESH_GUST_FACTOR 0x008A +#define BLE_MESH_HEAT_INDEX 0x008B +#define BLE_MESH_LIGHT_DISTRIBUTION 0x008C +#define BLE_MESH_LIGHT_SOURCE_CURRENT 0x008D +#define BLE_MESH_LIGHT_SOURCE_ON_TIME_NOT_RESETTABLE 0x008E +#define BLE_MESH_LIGHT_SOURCE_ON_TIME_RESETTABLE 0x008F +#define BLE_MESH_LIGHT_SOURCE_OPEN_CIRCUIT_STATISTICS 0x0090 +#define BLE_MESH_LIGHT_SOURCE_OVERALL_FAILURES_STATISTICS 0x0091 +#define BLE_MESH_LIGHT_SOURCE_SHORT_CIRCUIT_STATISTICS 0x0092 +#define BLE_MESH_LIGHT_SOURCE_START_COUNTER_RESETTABLE 0x0093 +#define BLE_MESH_LIGHT_SOURCE_TEMPERATURE 0x0094 +#define BLE_MESH_LIGHT_SOURCE_THERMAL_DERATING_STATISTICS 0x0095 +#define BLE_MESH_LIGHT_SOURCE_THERMAL_SHUTDOWN_STATISTICS 0x0096 +#define BLE_MESH_LIGHT_SOURCE_TOTAL_POWER_ON_CYCLES 0x0097 +#define BLE_MESH_LIGHT_SOURCE_VOLTAGE 0x0098 +#define BLE_MESH_LUMINAIRE_COLOR 0x0099 +#define BLE_MESH_LUMINAIRE_IDENTIFICATION_NUMBER 0x009A +#define BLE_MESH_LUMINAIRE_MANUFACTURER_GTIN 0x009B +#define BLE_MESH_LUMINAIRE_NOMINAL_INPUT_POWER 0x009C +#define BLE_MESH_LUMINAIRE_NOMINAL_MAXIMUM_AC_MAINS_VOLTAGE 0x009D +#define BLE_MESH_LUMINAIRE_NOMINAL_MINIMUM_AC_MAINS_VOLTAGE 0x009E +#define BLE_MESH_LUMINAIRE_POWER_AT_MINIMUM_DIM_LEVEL 0x009F +#define BLE_MESH_LUMINAIRE_TIME_OF_MANUFACTURE 0x00A0 +#define BLE_MESH_MAGNETIC_DECLINATION 0x00A1 +#define BLE_MESH_MAGNETIC_FLUX_DENSITY_2D 0x00A2 +#define BLE_MESH_MAGNETIC_FLUX_DENSITY_3D 0x00A3 +#define BLE_MESH_NOMINAL_LIGHT_OUTPUT 0x00A4 +#define BLE_MESH_OVERALL_FAILURE_CONDITION 0x00A5 +#define BLE_MESH_POLLEN_CONCENTRATION 0x00A6 +#define BLE_MESH_PRESENT_INDOOR_RELATIVE_HUMIDITY 0x00A7 +#define BLE_MESH_PRESENT_OUTDOOR_RELATIVE_HUMIDITY 0x00A8 +#define BLE_MESH_PRESSURE 0x00A9 +#define BLE_MESH_RAINFALL 0x00AA +#define BLE_MESH_RATED_MEDIAN_USEFUL_LIFE_OF_LUMINAIRE 0x00AB +#define BLE_MESH_RATED_MEDIAN_USEFUL_LIGHT_SOURCE_STARTS 0x00AC +#define BLE_MESH_REFERENCE_TEMPERATURE 0x00AD +#define BLE_MESH_TOTAL_DEVICE_STARTS 0x00AE +#define BLE_MESH_TRUE_WIND_DIRECTION 0x00AF +#define BLE_MESH_TRUE_WIND_SPEED 0x00B0 +#define BLE_MESH_UV_INDEX 0x00B1 +#define BLE_MESH_WIND_CHILL 0x00B2 +#define BLE_MESH_LIGHT_SOURCE_TYPE 0x00B3 +#define BLE_MESH_LUMINAIRE_IDENTIFICATION_STRING 0x00B4 +#define BLE_MESH_OUTPUT_POWER_LIMITATION 0x00B5 +#define BLE_MESH_THERMAL_DERATING 0x00B6 +#define BLE_MESH_OUTPUT_CURRENT_PERCENT 0x00B7 + +/** + * @brief BLE Mesh Device Property value length + */ +#define BLE_MESH_AVERAGE_AMBIENT_TEMPERATURE_IN_A_PERIOD_OF_DAY_LEN 3 +#define BLE_MESH_AVERAGE_INPUT_CURRENT_LEN 3 +#define BLE_MESH_AVERAGE_INPUT_VOLTAGE_LEN 3 +#define BLE_MESH_AVERAGE_OUTPUT_CURRENT_LEN 3 +#define BLE_MESH_AVERAGE_OUTPUT_VOLTAGE_LEN 3 +#define BLE_MESH_CENTER_BEAM_INTENSITY_AT_FULL_POWER_LEN 2 +#define BLE_MESH_CHROMATICITY_TOLERANCE_LEN 1 +#define BLE_MESH_COLOR_RENDERING_INDEX_R9_LEN 1 +#define BLE_MESH_COLOR_RENDERING_INDEX_RA_LEN 1 +#define BLE_MESH_DEVICE_APPEARANCE_LEN 2 +#define BLE_MESH_DEVICE_COUNTRY_OF_ORIGIN_LEN 2 +#define BLE_MESH_DEVICE_DATE_OF_MANUFACTURE_LEN 3 +#define BLE_MESH_DEVICE_ENERGY_USE_SINCE_TURN_ON_LEN 3 +#define BLE_MESH_DEVICE_FIRMWARE_REVISION_LEN 8 +#define BLE_MESH_DEVICE_GLOBAL_TRADE_ITEM_NUMBER_LEN 6 +#define BLE_MESH_DEVICE_HARDWARE_REVISION_LEN 16 +#define BLE_MESH_DEVICE_MANUFACTURER_NAME_LEN 36 +#define BLE_MESH_DEVICE_MODEL_NUMBER_LEN 24 +#define BLE_MESH_DEVICE_OPERATING_TEMPERATURE_RANGE_SPECIFICATION_LEN 4 +#define BLE_MESH_DEVICE_OPERATING_TEMPERATURE_STATISTICAL_VALUES_LEN 9 +#define BLE_MESH_DEVICE_OVER_TEMPERATURE_EVENT_STATISTICS_LEN 6 +#define BLE_MESH_DEVICE_POWER_RANGE_SPECIFICATION_LEN 9 +#define BLE_MESH_DEVICE_RUNTIME_SINCE_TURN_ON_LEN 3 +#define BLE_MESH_DEVICE_RUNTIME_WARRANTY_LEN 3 +#define BLE_MESH_DEVICE_SERIAL_NUMBER_LEN 16 +#define BLE_MESH_DEVICE_SOFTWARE_REVISION_LEN 8 +#define BLE_MESH_DEVICE_UNDER_TEMPERATURE_EVENT_STATISTICS_LEN 6 +#define BLE_MESH_INDOOR_AMBIENT_TEMPERATURE_STATISTICAL_VALUES_LEN 5 +#define BLE_MESH_INITIAL_CIE_1931_CHROMATICITY_COORDINATES_LEN 4 +#define BLE_MESH_INITIAL_CORRELATED_COLOR_TEMPERATURE_LEN 2 +#define BLE_MESH_INITIAL_LUMINOUS_FLUX_LEN 2 +#define BLE_MESH_INITIAL_PLANCKIAN_DISTANCE_LEN 2 +#define BLE_MESH_INPUT_CURRENT_RANGE_SPECIFICATION_LEN 6 +#define BLE_MESH_INPUT_CURRENT_STATISTICS_LEN 9 +#define BLE_MESH_INPUT_OVER_CURRENT_EVENT_STATISTICS_LEN 6 +#define BLE_MESH_INPUT_OVER_RIPPLE_VOLTAGE_EVENT_STATISTICS_LEN 6 +#define BLE_MESH_INPUT_OVER_VOLTAGE_EVENT_STATISTICS_LEN 6 +#define BLE_MESH_INPUT_UNDER_CURRENT_EVENT_STATISTICS_LEN 6 +#define BLE_MESH_INPUT_UNDER_VOLTAGE_EVENT_STATISTICS_LEN 6 +#define BLE_MESH_INPUT_VOLTAGE_RANGE_SPECIFICATION_LEN 6 +#define BLE_MESH_INPUT_VOLTAGE_RIPPLE_SPECIFICATION_LEN 1 +#define BLE_MESH_INPUT_VOLTAGE_STATISTICS_LEN 9 +#define BLE_MESH_LIGHT_CONTROL_AMBIENT_LUXLEVEL_ON_LEN 3 +#define BLE_MESH_LIGHT_CONTROL_AMBIENT_LUXLEVEL_PROLONG_LEN 3 +#define BLE_MESH_LIGHT_CONTROL_AMBIENT_LUXLEVEL_STANDBY_LEN 3 +#define BLE_MESH_LIGHT_CONTROL_LIGHTNESS_ON_LEN 2 +#define BLE_MESH_LIGHT_CONTROL_LIGHTNESS_PROLONG_LEN 2 +#define BLE_MESH_LIGHT_CONTROL_LIGHTNESS_STANDBY_LEN 2 +#define BLE_MESH_LIGHT_CONTROL_REGULATOR_ACCURACY_LEN 1 +#define BLE_MESH_LIGHT_CONTROL_REGULATOR_KID_LEN 4 +#define BLE_MESH_LIGHT_CONTROL_REGULATOR_KIU_LEN 4 +#define BLE_MESH_LIGHT_CONTROL_REGULATOR_KPD_LEN 4 +#define BLE_MESH_LIGHT_CONTROL_REGULATOR_KPU_LEN 4 +#define BLE_MESH_LIGHT_CONTROL_TIME_FADE_LEN 3 +#define BLE_MESH_LIGHT_CONTROL_TIME_FADE_ON_LEN 3 +#define BLE_MESH_LIGHT_CONTROL_TIME_FADE_STANDBY_AUTO_LEN 3 +#define BLE_MESH_LIGHT_CONTROL_TIME_FADE_STANDBY_MANUAL_LEN 3 +#define BLE_MESH_LIGHT_CONTROL_TIME_OCCUPANCY_DELAY_LEN 3 +#define BLE_MESH_LIGHT_CONTROL_TIME_PROLONG_LEN 3 +#define BLE_MESH_LIGHT_CONTROL_TIME_RUN_ON_LEN 3 +#define BLE_MESH_LUMEN_MAINTENANCE_FACTOR_LEN 1 +#define BLE_MESH_LUMINOUS_EFFICACY_LEN 2 +#define BLE_MESH_LUMINOUS_ENERGY_SINCE_TURN_ON_LEN 3 +#define BLE_MESH_LUMINOUS_EXPOSURE_LEN 3 +#define BLE_MESH_LUMINOUS_FLUX_RANGE_LEN 4 +#define BLE_MESH_MOTION_SENSED_LEN 1 +#define BLE_MESH_MOTION_THRESHOLD_LEN 1 +#define BLE_MESH_OPEN_CIRCUIT_EVENT_STATISTICS_LEN 6 +#define BLE_MESH_OUTDOOR_STATISTICAL_VALUES_LEN 5 +#define BLE_MESH_OUTPUT_CURRENT_RANGE_LEN 4 +#define BLE_MESH_OUTPUT_CURRENT_STATISTICS_LEN 9 +#define BLE_MESH_OUTPUT_RIPPLE_VOLTAGE_SPECIFICATION_LEN 1 +#define BLE_MESH_OUTPUT_VOLTAGE_RANGE_LEN 6 +#define BLE_MESH_OUTPUT_VOLTAGE_STATISTICS_LEN 9 +#define BLE_MESH_OVER_OUTPUT_RIPPLE_VOLTAGE_EVENT_STATISTICS_LEN 6 +#define BLE_MESH_PEOPLE_COUNT_LEN 2 +#define BLE_MESH_PRESENCE_DETECTED_LEN 1 +#define BLE_MESH_PRESENT_AMBIENT_LIGHT_LEVEL_LEN 3 +#define BLE_MESH_PRESENT_AMBIENT_TEMPERATURE_LEN 1 +#define BLE_MESH_PRESENT_CIE_1931_CHROMATICITY_LEN 4 +#define BLE_MESH_PRESENT_CORRELATED_COLOR_TEMPERATURE_LEN 2 +#define BLE_MESH_PRESENT_DEVICE_INPUT_POWER_LEN 3 +#define BLE_MESH_PRESENT_DEVICE_OPERATING_EFFICIENCY_LEN 1 +#define BLE_MESH_PRESENT_DEVICE_OPERATING_TEMPERATURE_LEN 2 +#define BLE_MESH_PRESENT_ILLUMINANCE_LEN 3 +#define BLE_MESH_PRESENT_INDOOR_AMBIENT_TEMPERATURE_LEN 1 +#define BLE_MESH_PRESENT_INPUT_CURRENT_LEN 2 +#define BLE_MESH_PRESENT_INPUT_RIPPLE_VOLTAGE_LEN 1 +#define BLE_MESH_PRESENT_INPUT_VOLTAGE_LEN 2 +#define BLE_MESH_PRESENT_LUMINOUS_FLUX_LEN 2 +#define BLE_MESH_PRESENT_OUTDOOR_AMBIENT_TEMPERATURE_LEN 1 +#define BLE_MESH_PRESENT_OUTPUT_CURRENT_LEN 2 +#define BLE_MESH_PRESENT_OUTPUT_VOLTAGE_LEN 2 +#define BLE_MESH_PRESENT_PLANCKIAN_DISTANCE_LEN 2 +#define BLE_MESH_PRESENT_RELATIVE_OUTPUT_RIPPLE_VOLTAGE_LEN 1 +#define BLE_MESH_RELATIVE_DEVICE_ENERGY_USE_IN_A_PERIOD_OF_DAY_LEN 5 +#define BLE_MESH_RELATIVE_DEVICE_RUNTIME_IN_A_GENERIC_LEVEL_RANGE_LEN 5 +#define BLE_MESH_RELATIVE_EXPOSURE_TIME_IN_AN_ILLUMINANCE_RANGE_LEN 5 +#define BLE_MESH_RELATIVE_RUNTIME_IN_A_CORRELATED_COLOR_TEMPERATURE_RANGE_LEN 3 +#define BLE_MESH_RELATIVE_RUNTIME_IN_A_DEVICE_OPERATING_TEMPERATURE_RANGE_LEN 3 +#define BLE_MESH_RELATIVE_RUNTIME_IN_AN_INPUT_CURRENT_RANGE_LEN 5 +#define BLE_MESH_RELATIVE_RUNTIME_IN_AN_INPUT_VOLTAGE_RANGE_LEN 5 +#define BLE_MESH_SHORT_CIRCUIT_EVENT_STATISTICS_LEN 6 +#define BLE_MESH_TIME_SINCE_MOTION_SENSED_LEN 2 +#define BLE_MESH_TIME_SINCE_PRESENCE_DETECTED_LEN 2 +#define BLE_MESH_TOTAL_DEVICE_ENERGY_USE_LEN 3 +#define BLE_MESH_TOTAL_DEVICE_OFF_ON_CYCLES_LEN 3 +#define BLE_MESH_TOTAL_DEVICE_POWER_ON_CYCLES_LEN 3 +#define BLE_MESH_TOTAL_DEVICE_POWER_ON_TIME_LEN 3 +#define BLE_MESH_TOTAL_DEVICE_RUNTIME_LEN 3 +#define BLE_MESH_TOTAL_LIGHT_EXPOSURE_TIME_LEN 3 +#define BLE_MESH_TOTAL_LUMINOUS_ENERGY_LEN 3 +#define BLE_MESH_DESIRED_AMBIENT_TEMPERATURE_LEN 1 +#define BLE_MESH_PRECISE_TOTAL_DEVICE_ENERGY_USE_LEN 4 +#define BLE_MESH_POWER_FACTOR_LEN 1 +#define BLE_MESH_SENSOR_GAIN_LEN 4 +#define BLE_MESH_PRECISE_PRESENT_AMBIENT_TEMPERATURE_LEN 2 +#define BLE_MESH_PRESENT_AMBIENT_RELATIVE_HUMIDITY_LEN 2 +#define BLE_MESH_PRESENT_AMBIENT_CARBON_DIOXIDE_CONCENTRATION_LEN 2 +#define BLE_MESH_PRESENT_AMBIENT_VOLATILE_ORGANIC_COMPOUNDS_CONCENTRATION_LEN 2 +#define BLE_MESH_PRESENT_AMBIENT_NOISE_LEN 1 +#define BLE_MESH_ACTIVE_ENERGY_LOADSIDE_LEN 4 +#define BLE_MESH_ACTIVE_POWER_LOADSIDE_LEN 3 +#define BLE_MESH_AIR_PRESSURE_LEN 4 +#define BLE_MESH_APPARENT_ENERGY_LEN 4 +#define BLE_MESH_APPARENT_POWER_LEN 3 +#define BLE_MESH_APPARENT_WIND_DIRECTION_LEN 2 +#define BLE_MESH_APPARENT_WIND_SPEED_LEN 2 +#define BLE_MESH_DEW_POINT_LEN 1 +#define BLE_MESH_EXTERNAL_SUPPLY_VOLTAGE_LEN 3 +#define BLE_MESH_EXTERNAL_SUPPLY_VOLTAGE_FREQUENCY_LEN 2 +#define BLE_MESH_GUST_FACTOR_LEN 1 +#define BLE_MESH_HEAT_INDEX_LEN 1 +#define BLE_MESH_LIGHT_DISTRIBUTION_LEN 1 +#define BLE_MESH_LIGHT_SOURCE_CURRENT_LEN 3 +#define BLE_MESH_LIGHT_SOURCE_ON_TIME_NOT_RESETTABLE_LEN 4 +#define BLE_MESH_LIGHT_SOURCE_ON_TIME_RESETTABLE_LEN 4 +#define BLE_MESH_LIGHT_SOURCE_OPEN_CIRCUIT_STATISTICS_LEN 6 +#define BLE_MESH_LIGHT_SOURCE_OVERALL_FAILURES_STATISTICS_LEN 6 +#define BLE_MESH_LIGHT_SOURCE_SHORT_CIRCUIT_STATISTICS_LEN 6 +#define BLE_MESH_LIGHT_SOURCE_START_COUNTER_RESETTABLE_LEN 3 +#define BLE_MESH_LIGHT_SOURCE_TEMPERATURE_LEN 2 +#define BLE_MESH_LIGHT_SOURCE_THERMAL_DERATING_STATISTICS_LEN 6 +#define BLE_MESH_LIGHT_SOURCE_THERMAL_SHUTDOWN_STATISTICS_LEN 6 +#define BLE_MESH_LIGHT_SOURCE_TOTAL_POWER_ON_CYCLES_LEN 3 +#define BLE_MESH_LIGHT_SOURCE_VOLTAGE_LEN 3 +#define BLE_MESH_LUMINAIRE_COLOR_LEN 24 +#define BLE_MESH_LUMINAIRE_IDENTIFICATION_NUMBER_LEN 24 +#define BLE_MESH_LUMINAIRE_MANUFACTURER_GTIN_LEN 6 +#define BLE_MESH_LUMINAIRE_NOMINAL_INPUT_POWER_LEN 3 +#define BLE_MESH_LUMINAIRE_NOMINAL_MAXIMUM_AC_MAINS_VOLTAGE_LEN 2 +#define BLE_MESH_LUMINAIRE_NOMINAL_MINIMUM_AC_MAINS_VOLTAGE_LEN 2 +#define BLE_MESH_LUMINAIRE_POWER_AT_MINIMUM_DIM_LEVEL_LEN 3 +#define BLE_MESH_LUMINAIRE_TIME_OF_MANUFACTURE_LEN 3 +#define BLE_MESH_MAGNETIC_DECLINATION_LEN 2 +#define BLE_MESH_MAGNETIC_FLUX_DENSITY_2D_LEN 4 +#define BLE_MESH_MAGNETIC_FLUX_DENSITY_3D_LEN 6 +#define BLE_MESH_NOMINAL_LIGHT_OUTPUT_LEN 3 +#define BLE_MESH_OVERALL_FAILURE_CONDITION_LEN 6 +#define BLE_MESH_POLLEN_CONCENTRATION_LEN 3 +#define BLE_MESH_PRESENT_INDOOR_RELATIVE_HUMIDITY_LEN 2 +#define BLE_MESH_PRESENT_OUTDOOR_RELATIVE_HUMIDITY_LEN 2 +#define BLE_MESH_PRESSURE_LEN 4 +#define BLE_MESH_RAINFALL_LEN 2 +#define BLE_MESH_RATED_MEDIAN_USEFUL_LIFE_OF_LUMINAIRE_LEN 3 +#define BLE_MESH_RATED_MEDIAN_USEFUL_LIGHT_SOURCE_STARTS_LEN 3 +#define BLE_MESH_REFERENCE_TEMPERATURE_LEN 2 +#define BLE_MESH_TOTAL_DEVICE_STARTS_LEN 3 +#define BLE_MESH_TRUE_WIND_DIRECTION_LEN 2 +#define BLE_MESH_TRUE_WIND_SPEED_LEN 2 +#define BLE_MESH_UV_INDEX_LEN 1 +#define BLE_MESH_WIND_CHILL_LEN 1 +#define BLE_MESH_LIGHT_SOURCE_TYPE_LEN 1 +#define BLE_MESH_LUMINAIRE_IDENTIFICATION_STRING_LEN 64 +#define BLE_MESH_OUTPUT_POWER_LIMITATION_LEN 6 +#define BLE_MESH_THERMAL_DERATING_LEN 6 +#define BLE_MESH_OUTPUT_CURRENT_PERCENT_LEN 1 + +/** + * @brief BLE Mesh Device Property referenced Characteristic UUIDs + */ +#define BLE_MESH_UUID_AVERAGE_CURRENT_VAL 0x2AE0 +#define BLE_MESH_UUID_AVERAGE_VOLTAGE_VAL 0x2AE1 +#define BLE_MESH_UUID_BOOLEAN_VAL 0x2AE2 +#define BLE_MESH_UUID_CHROMATIC_DISTANCE_FROM_PLANCKIAN_VAL 0x2AE3 +#define BLE_MESH_UUID_CHROMATICITY_COORDINATE_VAL 0x2B1C +#define BLE_MESH_UUID_CHROMATICITY_COORDINATES_VAL 0x2AE4 +#define BLE_MESH_UUID_CHROMATICITY_IN_CCT_AND_DUV_VALUES_VAL 0x2AE5 +#define BLE_MESH_UUID_CHROMATICITY_TOLERANCE_VAL 0x2AE6 +#define BLE_MESH_UUID_CIE_13_3_1995_COLOR_RENDERING_INDEX_VAL 0x2AE7 +#define BLE_MESH_UUID_COEFFICIENT_VAL 0x2AE8 +#define BLE_MESH_UUID_CORRELATED_COLOR_TEMPERATURE_VAL 0x2AE9 +#define BLE_MESH_UUID_COUNT_16_VAL 0x2AEA +#define BLE_MESH_UUID_COUNT_24_VAL 0x2AEB +#define BLE_MESH_UUID_COUNTRY_CODE_VAL 0x2AEC +#define BLE_MESH_UUID_DATE_UTC_VAL 0x2AED +#define BLE_MESH_UUID_ELECTRIC_CURRENT_VAL 0x2AEE +#define BLE_MESH_UUID_ELECTRIC_CURRENT_RANGE_VAL 0x2AEF +#define BLE_MESH_UUID_ELECTRIC_CURRENT_SPECIFICATION_VAL 0x2AF0 +#define BLE_MESH_UUID_ELECTRIC_CURRENT_STATISTICS_VAL 0x2AF1 +#define BLE_MESH_UUID_ENERGY_VAL 0x2AF2 +#define BLE_MESH_UUID_ENERGY_IN_A_PERIOD_OF_DAY_VAL 0x2AF3 +#define BLE_MESH_UUID_EVENT_STATISTICS_VAL 0x2AF4 +#define BLE_MESH_UUID_FIXED_STRING_16_VAL 0x2AF5 +#define BLE_MESH_UUID_FIXED_STRING_24_VAL 0x2AF6 +#define BLE_MESH_UUID_FIXED_STRING_36_VAL 0x2AF7 +#define BLE_MESH_UUID_FIXED_STRING_8_VAL 0x2AF8 +#define BLE_MESH_UUID_GENERIC_LEVEL_VAL 0x2AF9 +#define BLE_MESH_UUID_GLOBAL_TRADE_ITEM_NUMBER_VAL 0x2AFA +#define BLE_MESH_UUID_ILLUMINANCE_VAL 0x2AFB +#define BLE_MESH_UUID_LUMINOUS_EFFICACY_VAL 0x2AFC +#define BLE_MESH_UUID_LUMINOUS_ENERGY_VAL 0x2AFD +#define BLE_MESH_UUID_LUMINOUS_EXPOSURE_VAL 0x2AFE +#define BLE_MESH_UUID_LUMINOUS_FLUX_VAL 0x2AFF +#define BLE_MESH_UUID_LUMINOUS_FLUX_RANGE_VAL 0x2B00 +#define BLE_MESH_UUID_LUMINOUS_INTENSITY_VAL 0x2B01 +#define BLE_MESH_UUID_MASS_FLOW_VAL 0x2B02 +/** + * The following four have been defined in mesh_uuid.h + * #define BLE_MESH_UUID_MESH_PROV_DATA_IN_VAL 0x2ADB + * #define BLE_MESH_UUID_MESH_PROV_DATA_OUT_VAL 0x2ADC + * #define BLE_MESH_UUID_MESH_PROXY_DATA_IN_VAL 0x2ADD + * #define BLE_MESH_UUID_MESH_PROXY_DATA_OUT_VAL 0x2ADE + */ +#define BLE_MESH_UUID_PERCEIVED_LIGHTNESS_VAL 0x2B03 +#define BLE_MESH_UUID_PERCENTAGE_8_VAL 0x2B04 +#define BLE_MESH_UUID_POWER_VAL 0x2B05 +#define BLE_MESH_UUID_POWER_SPECIFICATION_VAL 0x2B06 +#define BLE_MESH_UUID_RELATIVE_RUNTIME_IN_A_CURRENT_RANGE_VAL 0x2B07 +#define BLE_MESH_UUID_RELATIVE_RUNTIME_IN_A_GENERIC_LEVEL_RANGE_VAL 0x2B08 +#define BLE_MESH_UUID_RELATIVE_VALUE_IN_A_PERIOD_OF_DAY_VAL 0x2B0B +#define BLE_MESH_UUID_RELATIVE_VALUE_IN_A_TEMPERATURE_RANGE_VAL 0x2B0C +#define BLE_MESH_UUID_RELATIVE_VALUE_IN_A_VOLTAGE_RANGE_VAL 0x2B09 +#define BLE_MESH_UUID_RELATIVE_VALUE_IN_AN_ILLUMINANCE_RANGE_VAL 0x2B0A +#define BLE_MESH_UUID_TEMPERATURE_8_VAL 0x2B0D +#define BLE_MESH_UUID_TEMPERATURE_8_IN_A_PERIOD_OF_DAY_VAL 0x2B0E +#define BLE_MESH_UUID_TEMPERATURE_8_STATISTICS_VAL 0x2B0F +#define BLE_MESH_UUID_TEMPERATURE_RANGE_VAL 0x2B10 +#define BLE_MESH_UUID_TEMPERATURE_STATISTICS_VAL 0x2B11 +#define BLE_MESH_UUID_TIME_DECIHOUR_8_VAL 0x2B12 +#define BLE_MESH_UUID_TIME_EXPONENTIAL_8_VAL 0x2B13 +#define BLE_MESH_UUID_TIME_HOUR_24_VAL 0x2B14 +#define BLE_MESH_UUID_TIME_MILLISECOND_24_VAL 0x2B15 +#define BLE_MESH_UUID_TIME_SECOND_16_VAL 0x2B16 +#define BLE_MESH_UUID_TIME_SECOND_8_VAL 0x2B17 +#define BLE_MESH_UUID_VOLTAGE_VAL 0x2B18 +#define BLE_MESH_UUID_VOLTAGE_SPECIFICATION_VAL 0x2B19 +#define BLE_MESH_UUID_VOLTAGE_STATISTICS_VAL 0x2B1A +#define BLE_MESH_UUID_VOLUME_FLOW_VAL 0x2B1B + +/** + * @brief BLE Mesh Device Property referenced Characteristic Type Definitions + */ + +/* Unit is in degrees Celsius with a resolution of 0.01 degrees Celsius. */ +typedef int16_t bt_mesh_temperature_t; + +typedef uint16_t bt_mesh_gap_appearance_t; + +/* Mesh Characteristics Type Definitions */ + +/* This characteristic represents an electric current. + * Note: Unit is ampere with a resolution of 0.01. + * Minimum value: 0, maximum value: 655.34; + * A value of 0xFFFF represents 'value is not known'. + */ +typedef uint16_t bt_mesh_electric_current_t; + +/* The Time Exponential 8 characteristic is used to represent a measure of period of + * time in seconds. + * Note: The time duration is given by the value 1.1^(N-64) in seconds, with N being + * the raw 8-bit value; + * Minimum value: 0.0, maximum value: 73216705; + * A raw value of 0x00 represents 0 seconds, and a raw value of 0xFF represents + * the total life of the device. + */ +typedef uint8_t bt_mesh_time_exponential_8_t; + +/* The Voltage characteristic is used to represent a measure of positive electric + * potential difference in units of volts. + * Note: Unit is volt with a resolution of 1/64V; + * Minimum value: 0.0, maximum value: 1022.0; + * A value of 0xFFFF represents 'value is not known'. The minimum representable + * value represents the minimum value or lower, the maximum representable value + * represents the maximum value or higher. + */ +typedef uint16_t bt_mesh_voltage_t; + +/* This characteristic aggregates the Electric Current characteristic and instance of + * the Time Exponential 8 characteristic. + */ +typedef struct __packed average_current { + bt_mesh_electric_current_t electric_current; + bt_mesh_time_exponential_8_t sensing_duration; +} bt_mesh_average_current_t; + +/* This characteristic aggregates the Voltage characteristic and instance of the Time + * Exponential 8 characteristic. + */ +typedef struct __packed average_voltage { + bt_mesh_voltage_t voltage; + bt_mesh_time_exponential_8_t sensing_duration; +} bt_mesh_average_voltage_t; + +/* The Boolean characteristic defines the predefined Boolean values as an enumeration. + * Key | Value + * 0 | False + * 1 | True + * 2 to 255 | Prohibited + */ +typedef uint8_t bt_mesh_boolean_t; + +/* The Chromatic Distance From Planckian characteristic represents a distance of a + * chromaticity coordinate from the Planckian locus in the (u',2/3 v') diagram as + * defined by ANSI standard C78.377-2008. The distance is positive if the chromaticity + * coordinate is located above the Planckian locus (i.e. has as higher y value than the + * Planckian), and negative if it is located below. The distance is only valid within + * the range from -0.05 to 0.05. + * Note: Unit is unitless with a resolution of 0.00001; + * Minimum value: -0.05, maximum value: 0.05; + * A value of 0xFFFF represents 'value is not known'; + * A value of 0xFFFE represents 'value is not valid'. + */ +typedef int16_t bt_mesh_chromatic_distance_from_planckian_t; + +/* This characteristic represents a chromaticity coordinate in a color diagram such as + * the CIE1931 diagram. It can represent an x or y coordinate. + * Note: Unit is unitless with a resolution of 1/65535; + * Minimum value: 0, maximum value: 1.0. + */ +typedef uint16_t bt_mesh_chromaticity_coordinate_t; + +/* This characteristic represents a chromaticity coordinate as a tuple with an x and + * y coordinate. + */ +typedef struct __packed chromaticity_coordinates { + bt_mesh_chromaticity_coordinate_t chromaticity_x_coordinate; + bt_mesh_chromaticity_coordinate_t chromaticity_y_coordinate; +} bt_mesh_chromaticity_coordinates_t; + +/* The Correlated Color Temperature characteristic is used to represent correlated color + * temperature in a range from 800 to 65534 Kelvin with a resolution of 1 Kelvin. + * Note: Unit is Kelvin with a resolution of 1; + * Minimum value: 800, maximum value: 65534; + * A value of 0xFFFF represents 'value is not known'. + */ +typedef uint16_t bt_mesh_correlated_color_temperature_t; + +/* The Chromaticity In CCT And Duv Values characteristic is a composite characteristic + * consisting of the Correlated Color Temperature characteristic and the Chromatic + * Distance From Planckian characteristic. + */ +typedef struct __packed chromaticity_in_cct_and_duv_values { + bt_mesh_correlated_color_temperature_t correlated_color_temperature; + bt_mesh_chromatic_distance_from_planckian_t chromaticity_distance_from_planckian; +} bt_mesh_chromaticity_in_cct_and_duv_values_t; + +/* The Chromaticity Tolerance characteristic is a tolerance of a tuple of chromaticity + * values represented as a value of a radius of a circle in the CIE 1976 (u',v') diagram; + * value corresponding to the 3-sigma values of the expected chromaticity deviations. + * Note: Unit is unitless with a resolution of 0.0001; + * Minimum value: 0, maximum value: 0.0255. + */ +typedef uint8_t bt_mesh_chromaticity_tolerance_t; + +/* The CIE 13.3-1995 Color Rendering Index characteristic is a color rendition index value + * for a color patch as calculated in accordance with the CIE 13.3-1995 standard. + * Note: Unit is unitless with a resolution of 1; + * Minimum value: -128, maximum value: 100. + */ +typedef int8_t bt_mesh_cie_13_3_1995_color_rendering_index_t; + +/* The Coefficient characteristic is used to represent a general coefficient value. */ +typedef float bt_mesh_coefficient_t; + +/* The Count 16 characteristic is used to represent a general count value. + * Note: Unit is unitless with a resolution of 1; + * Minimum value: 0, maximum value 65534; + * A value of 0xFFFF represents 'value is not known'. + */ +typedef uint16_t bt_mesh_count_16_t; + +/* The Count 24 characteristic is used to represent a general count value. + * Note: Unit is unitless with a resolution of 1; + * Minimum value: 0, maximum value 16777214; + * A value of 0xFFFFFF represents 'value is not known'. + */ +typedef uint8_t bt_mesh_count_24_t[3]; + +/* This characteristic represents a country or dependent areas in accordance with + * the ISO 3166-1 Numeric standard. + * Note: Unit is unitless with a resolution of 1; + * Minimum value: 0, maximum value: 4095; + * A value of 0xFFFF represents 'value is not known'. + */ +typedef uint16_t bt_mesh_country_code_t; + +/* Date as days elapsed since the Epoch (Jan 1, 1970) in the Coordinated Universal + * Time (UTC) time zone. + * Note: Unit is a day with a resolution of 1; + * Minimum value: 1, maximum value: 16777214; + * A value of 0x000000 represents 'value is not known'. + */ +typedef uint8_t bt_mesh_date_utc_t[3]; + +/* This characteristic aggregates two instances of the Electric Current characteristic + * to represent a range of Electric Current values. + */ +typedef struct __packed electric_current_range { + bt_mesh_electric_current_t minimum_electric_current_value; + bt_mesh_electric_current_t maximum_electric_current_value; +} bt_mesh_electric_current_range_t; + +/* This characteristic aggregates three instances of the Electric Current characteristic + * to represent a specification of electric current values. + */ +typedef struct __packed electric_current_specification { + bt_mesh_electric_current_t minimum_electric_current_value; + bt_mesh_electric_current_t typical_electric_current_value; + bt_mesh_electric_current_t maximum_electric_current_value; +} bt_mesh_electric_current_specification_t; + +/* This characteristic aggregates four instances of the Electric Current characteristic + * with a Sensing Duration to represent a set of statistical electric current values. + */ +typedef struct __packed electric_current_statistics { + bt_mesh_electric_current_t average_electric_current_value; + bt_mesh_electric_current_t standard_electric_current_value; + bt_mesh_electric_current_t minimum_electric_current_value; + bt_mesh_electric_current_t maximum_electric_current_value; + bt_mesh_time_exponential_8_t sensing_duration; +} bt_mesh_electric_current_statistics_t; + +/* The Energy characteristic is used to represent a measure of energy in units of + * kilowatt hours. + * Note: Unit is kilowatt-hour with a resolution of 1; + * Minimum value: 0, maximum value: 16777214; + * A value of 0xFFFFFF represents ‘value is not known’. + */ +typedef uint8_t bt_mesh_energy_t[3]; + +/* The Time Decihour 8 characteristic is used to represent a period of time in + * tenths of an hour. + * Note: Unit is hour with a resolution of 0.1; + * Minimum value: 0.0, maximum value: 24.0; + * A value of 0xFF represents 'value is not known'. All other values are Prohibited. + */ +typedef uint8_t bt_mesh_time_decihour_8_t; + +/* This characteristic aggregates the Energy characteristic, and two instances of + * the Time Decihour 8 characteristic, to represent energy use in a period of day. + */ +typedef struct __packed energy_in_a_period_of_day { + bt_mesh_energy_t energy_value; + bt_mesh_time_decihour_8_t start_time; + bt_mesh_time_decihour_8_t end_time; +} bt_mesh_energy_in_a_period_of_day_t; + +/* The Time Second 16 characteristic is used to represent a period of time with a + * unit of 1 second. + * Note: Unit is second with a resolution of 1; + * Minimum value: 0, maximum value: 65534; + * A value of 0xFFFF represents 'value is not known'. + */ +typedef uint16_t bt_mesh_time_second_16_t; + +/* This characteristic aggregates the Count 16 characteristic, two instances of the + * Time Decihour 8 characteristic and an instance of the Sensing Duration characteristic, + * to represent statistical values of events. + */ +typedef struct __packed event_statistics { + bt_mesh_count_16_t number_of_events; + bt_mesh_time_second_16_t average_event_duration; + bt_mesh_time_exponential_8_t time_elapsed_since_last_event; + bt_mesh_time_exponential_8_t sensing_duration; +} bt_mesh_event_statistics_t; + +/* The Fixed String 16 characteristic represents a 16-octet UTF-8 string. */ +typedef char bt_mesh_fixed_string_16_t[16]; + +/* The Fixed String 24 characteristic represents a 24-octet UTF-8 string. */ +typedef char bt_mesh_fixed_string_24_t[24]; + +/* The Fixed String 36 characteristic represents a 36-octet UTF-8 string. */ +typedef char bt_mesh_fixed_string_36_t[36]; + +/* The Fixed String 8 characteristic represents an 8-octet UTF-8 string. */ +typedef char bt_mesh_fixed_string_8_t[8]; + +/* The Generic Level characteristic represents a general level value of a + * setting of a device. + * Note: Unit is unitless with a resolution of 1; + * Minimum value: 0, maximum value: 65535. + */ +typedef uint16_t bt_mesh_generic_level_t; + +/* The Global Trade Item Number characteristic represents an identifier as + * issued by GS1 General Specifications, which may consist up to 14 digits, + * and is here represented as a 48-bit unsigned integer. + */ +typedef uint8_t bt_mesh_global_trade_item_number_t[6]; + +/* The Illuminance characteristic is used to represent a measure of illuminance + * in units of lux. + * Note: Unit is lux with a resolution of 0.01; + * Minimum value: 0, maximum value: 167772.14; + * A value of 0xFFFFFF represents 'value is not known'. + */ +typedef uint8_t bt_mesh_illuminance_t[3]; + +/* The Luminous Efficacy characteristic is used to represent a measure of luminous + * efficacy in units of lumen per watt. + * Note: Unit is lumen per watt with a resolution of 0.1; + * Minimum value: 0, maximum value: 1800; + * A value of 0xFFFF represents 'value is not known'. All other values are Prohibited. + */ +typedef uint16_t bt_mesh_luminous_efficacy_t; + +/* The Luminous Energy characteristic is used to represent a measure of luminous + * energy in units of lumen hour. + * Note: Unit is lumen hour with a resolution of 1000; + * Minimum value: 0, maximum value: 16777214000; + * A value of 0xFFFFFF represents 'value is not known'. + */ +typedef uint8_t bt_mesh_luminous_energy_t[3]; + +/* The Luminous Exposure characteristic is used to represent a measure of luminous + * exposure in units of lux-hour. + * Note: Unit is lux hour with a resolution of 1000; + * Minimum value: 0, maximum value: 16777214000; + * A value of 0xFFFFFF represents 'value is not known'. + */ +typedef uint8_t bt_mesh_luminous_exposure_t[3]; + +/* The Luminous Flux characteristic is used to represent a measure of luminous flux + * in units of lumen. + * Note: Unit is lumen with a resolution of 1; + * Minimum value: 0, maximum value: 65534; + * A value of 0xFFFF represents 'value is not known'. + */ +typedef uint16_t bt_mesh_luminous_flux_t; + +/* This characteristic aggregates two instances of the Luminous Flux characteristic + * to represent a luminous flux range. + */ +typedef struct __packed luminous_flux_range { + bt_mesh_luminous_flux_t minimum_luminous_flux; + bt_mesh_luminous_flux_t maximum_luminous_flux; +} bt_mesh_luminous_flux_range_t; + +/* The Luminous Intensity characteristic is used to represent a luminous intensity of + * a beam of light in units of candela. + * Note: Unit is candela with a resolution of 1; + * Minimum value: 0, maximum value: 65534; + * A value of 0xFFFF represents 'value is not known'. + */ +typedef uint16_t bt_mesh_luminous_intensity_t; + +/* The Mass Flow characteristic is used to represent a flow of mass. + * Note: Unit is gram/second with a resolution of 1; + * Minimum value: 0, maximum value: 65534; + * A value of 0xFFFF represents 'value is not known'. + */ +typedef uint16_t bt_mesh_mass_flow_t; + +/* The Mesh Provisioning Data In characteristic can be written to send a Proxy PDU + * message containing Provisioning PDU to the Provisioning Server. + */ +struct mesh_provisioning_data_in { + +}; + +/* The Mesh Provisioning Data Out characteristic can be notified to send a Proxy PDU + * message containing Provisioning PDU from a Provisioning Server to a Provisioning Client. + */ +struct mesh_provisioning_data_out { + +}; + +/* The Mesh Proxy Data In characteristic is used by the client to send Proxy PDUs to + * the server. + */ +struct mesh_proxy_data_in { + +}; + +/* The Mesh Proxy Data Out characteristic is used by the server to send Proxy PDUs to + * the client. + */ +struct mesh_proxy_data_out { + +}; + +/* The Perceived Lightness characteristic is used to represent the perceived lightness + * of a light. + * Note: Unit is unitless with a resolution of 1; + * Minimum value: 0, maximum value: 65535. + */ +typedef uint16_t bt_mesh_perceived_lightness_t; + +/* The Percentage 8 characteristic is used to represent a measure of percentage. + * Note: Unit is a percentage with a resolution of 0.5; + * Minimum value: 0, maximum value: 100; + * A value of 0xFF represents 'value is not known'. All other values are Prohibited. + */ +typedef uint8_t bt_mesh_percentage_8_t; + +/* The Power characteristic is used to represent a measure of power in units of watts. + * Note: Unit is watt with a resolution of 0.1; + * Minimum value: 0, maximum value: 1677721.4; + * A value of 0xFFFFFF represents 'value is not known'. + */ +typedef uint8_t bt_mesh_power_t[3]; + +/* This characteristic aggregates three instances of the Power characteristic to + * represent a specification of Power values. + */ +typedef struct __packed power_specification { + bt_mesh_power_t minimum_power_value; + bt_mesh_power_t typical_power_value; + bt_mesh_power_t maximum_power_value; +} bt_mesh_power_specification_t; + +/* This characteristic aggregates the Percentage 8 characteristic and two instances of + * the Electric Current characteristic to represent a relative value in an electric + * current range. + */ +typedef struct __packed relative_runtime_in_a_current_range { + bt_mesh_percentage_8_t relative_runtime_value; + bt_mesh_electric_current_t minimum_current; + bt_mesh_electric_current_t maximum_current; +} bt_mesh_relative_runtime_in_a_current_range_t; + +/* This characteristic aggregates the Percentage 8 characteristic and two instances of + * the Generic Level characteristic to represent a runtime in a generic level range. + */ +typedef struct __packed relative_runtime_in_a_generic_level_range { + bt_mesh_percentage_8_t relative_value; + bt_mesh_generic_level_t minimum_generic_level; + bt_mesh_generic_level_t maximum_generic_level; +} bt_mesh_relative_runtime_in_a_generic_level_range_t; + +/* This characteristic aggregates the Percentage 8 characteristic, and two instances of + * the Time Decihour 8 characteristic. + */ +typedef struct __packed relative_value_in_a_period_of_day { + bt_mesh_percentage_8_t relative_value; + bt_mesh_time_decihour_8_t start_time; + bt_mesh_time_decihour_8_t end_time; +} bt_mesh_relative_value_in_a_period_of_day_t; + +/* This characteristic aggregates the Percentage 8 characteristic, and two instances of + * the Temperature characteristic. + */ +typedef struct __packed relative_value_in_a_temperature_range { + bt_mesh_percentage_8_t relative_value; + bt_mesh_temperature_t minimum_temperature_value; + bt_mesh_temperature_t maximum_temperature_value; +} bt_mesh_relative_value_in_a_temperature_range_t; + +/* This characteristic aggregates the Percentage 8 characteristic and two instances of + * the Voltage characteristic to represent a relative value in a voltage range. + */ +typedef struct __packed relative_value_in_a_voltage_range { + bt_mesh_percentage_8_t relative_value; + bt_mesh_voltage_t minimum_voltage; + bt_mesh_voltage_t maximum_voltage; +} bt_mesh_relative_value_in_a_voltage_range_t; + +/* This characteristic aggregates the Percentage 8 characteristic and two instances of + * the Illuminance characteristic to represent a relative value in a illuminance range. + */ +typedef struct __packed relative_value_in_an_illuminance_range { + bt_mesh_percentage_8_t relative_value; + bt_mesh_illuminance_t minimum_illuminance; + bt_mesh_illuminance_t maximum_illuminance; +} bt_mesh_relative_value_in_an_illuminance_range_t; + +/* The Temperature 8 characteristic is used to represent a measure of temperature with + * a unit of 0.5 degree Celsius. + * Note: Unit is degree Celsius with a resolution of 0.5; + * Minimum value: -64.0, maximum value: 63.5; + * A value of 0xFF represents 'value is not known'. + */ +typedef int8_t bt_mesh_temperature_8_t; + +/* This characteristic aggregates the Temperature 8 characteristic, and two instances + * of the Time Decihour 8 characteristic, to represent a temperature value in a period + * of day. + */ +typedef struct __packed temperature_8_in_a_period_of_day { + bt_mesh_temperature_8_t temperature; + bt_mesh_time_decihour_8_t start_time; + bt_mesh_time_decihour_8_t end_time; +} bt_mesh_temperature_8_in_a_period_of_day_t; + +/* This characteristic aggregates four instances of the Temperature 8 characteristic, + * and one instance of the Time Exponential 8 characteristic. + */ +typedef struct __packed temperature_8_statistics { + bt_mesh_temperature_8_t average; + bt_mesh_temperature_8_t standard_deviation_value; + bt_mesh_temperature_8_t minimum_value; + bt_mesh_temperature_8_t maximum_value; + bt_mesh_time_exponential_8_t sensing_duration; +} bt_mesh_temperature_8_statistics_t; + +/* This characteristic aggregates two instances of the Temperature characteristic to + * represent a temperature range. + */ +typedef struct __packed temperature_range { + bt_mesh_temperature_t minimum_temperature; + bt_mesh_temperature_t maximum_temperature; +} bt_mesh_temperature_range_t; + +/* This characteristic aggregates four instances of the Temperature characteristic, + * and one instance of the Time Exponential 8 characteristic. + */ +typedef struct __packed temperature_statistics { + bt_mesh_temperature_t average_temperature; + bt_mesh_temperature_t standard_deviation_temperature; + bt_mesh_temperature_t minimum_temperature; + bt_mesh_temperature_t maximum_temperature; + bt_mesh_time_exponential_8_t sensing_duration; +} bt_mesh_temperature_statistics_t; + +/* The Time Hour 24 characteristic is used to represent a period of time in hours. + * Note: Unit is hour with a resolution of 1; + * Minimum value: 0, maximum value: 16777214; + * A value of 0xFFFFFF represents 'value is not known'. + */ +typedef uint8_t bt_mesh_time_hour_24_t[3]; + +/* The Time Millisecond 24 characteristic is used to represent a period of time with + * a resolution of 1 millisecond. + * Note: Unit is second with a resolution of 0.001; + * Minimum value: 0, maximum value: 16777.214; + * A value of 0xFFFFFF represents 'value is not known'. + */ +typedef uint8_t bt_mesh_time_millisecond_24_t[3]; + +/* The Time Second 8 characteristic is used to represent a period of time with a unit + * of 1 second. + * Note: Unit is second with a resolution of 1; + * Minimum value: 0, maximum value: 254; + * A value of 0xFF represents 'value is not known'. + */ +typedef uint8_t bt_mesh_time_second_8_t; + +/* This characteristic aggregates three instances of the Voltage characteristic to + * represent a specification of voltage values. + */ +typedef struct __packed voltage_specification { + bt_mesh_voltage_t minimum_voltage_value; + bt_mesh_voltage_t typical_voltage_value; + bt_mesh_voltage_t maximum_voltage_value; +} bt_mesh_voltage_specification_t; + +/* This characteristic aggregates four instances of the Voltage characteristic and an + * instance of the Time Exponential 8 characteristic to represent a set of statistical + * voltage values over a period of time. + */ +typedef struct __packed voltage_statistics { + bt_mesh_voltage_t average_voltage_value; + bt_mesh_voltage_t standard_deviation_voltage_value; + bt_mesh_voltage_t minimum_voltage_value; + bt_mesh_voltage_t maximum_voltage_value; + bt_mesh_time_exponential_8_t sensing_duration; +} bt_mesh_voltage_statistics_t; + +/* The Volume Flow characteristic is used to represent a flow of a general volume such + * as a volume of material or gas. + * Note: Unit is liter/second with a resolution of 0.001 (1 milliliter); + * Minimum value: 0, maximum value: 65534; + * A value of 0xFFFF represents 'value is not known'. + */ +typedef uint16_t bt_mesh_volume_flow_t; + +/* Mesh Device Property related function */ + +uint8_t bt_mesh_get_dev_prop_len(uint16_t prop_id); + +#ifdef __cplusplus +} +#endif + +#endif /* _DEVICE_PROPERTY_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/common/include/model_opcode.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/common/include/model_opcode.h new file mode 100644 index 00000000000..29294a88990 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/common/include/model_opcode.h @@ -0,0 +1,276 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _MODEL_OPCODE_H_ +#define _MODEL_OPCODE_H_ + +#include "mesh_access.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Generic OnOff Message Opcode */ +#define BLE_MESH_MODEL_OP_GEN_ONOFF_GET BLE_MESH_MODEL_OP_2(0x82, 0x01) +#define BLE_MESH_MODEL_OP_GEN_ONOFF_SET BLE_MESH_MODEL_OP_2(0x82, 0x02) +#define BLE_MESH_MODEL_OP_GEN_ONOFF_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x03) +#define BLE_MESH_MODEL_OP_GEN_ONOFF_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x04) + +/* Generic Level Message Opcode */ +#define BLE_MESH_MODEL_OP_GEN_LEVEL_GET BLE_MESH_MODEL_OP_2(0x82, 0x05) +#define BLE_MESH_MODEL_OP_GEN_LEVEL_SET BLE_MESH_MODEL_OP_2(0x82, 0x06) +#define BLE_MESH_MODEL_OP_GEN_LEVEL_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x07) +#define BLE_MESH_MODEL_OP_GEN_LEVEL_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x08) +#define BLE_MESH_MODEL_OP_GEN_DELTA_SET BLE_MESH_MODEL_OP_2(0x82, 0x09) +#define BLE_MESH_MODEL_OP_GEN_DELTA_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x0A) +#define BLE_MESH_MODEL_OP_GEN_MOVE_SET BLE_MESH_MODEL_OP_2(0x82, 0x0B) +#define BLE_MESH_MODEL_OP_GEN_MOVE_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x0C) + +/* Generic Default Transition Time Message Opcode*/ +#define BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_GET BLE_MESH_MODEL_OP_2(0x82, 0x0D) +#define BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_SET BLE_MESH_MODEL_OP_2(0x82, 0x0E) +#define BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x0F) +#define BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x10) + +/* Generic Power OnOff Message Opcode*/ +#define BLE_MESH_MODEL_OP_GEN_ONPOWERUP_GET BLE_MESH_MODEL_OP_2(0x82, 0x11) +#define BLE_MESH_MODEL_OP_GEN_ONPOWERUP_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x12) + +/* Generic Power OnOff Setup Message Opcode */ +#define BLE_MESH_MODEL_OP_GEN_ONPOWERUP_SET BLE_MESH_MODEL_OP_2(0x82, 0x13) +#define BLE_MESH_MODEL_OP_GEN_ONPOWERUP_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x14) + +/* Generic Power Level Message Opcode */ +#define BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_GET BLE_MESH_MODEL_OP_2(0x82, 0x15) +#define BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_SET BLE_MESH_MODEL_OP_2(0x82, 0x16) +#define BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x17) +#define BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x18) +#define BLE_MESH_MODEL_OP_GEN_POWER_LAST_GET BLE_MESH_MODEL_OP_2(0x82, 0x19) +#define BLE_MESH_MODEL_OP_GEN_POWER_LAST_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x1A) +#define BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_GET BLE_MESH_MODEL_OP_2(0x82, 0x1B) +#define BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x1C) +#define BLE_MESH_MODEL_OP_GEN_POWER_RANGE_GET BLE_MESH_MODEL_OP_2(0x82, 0x1D) +#define BLE_MESH_MODEL_OP_GEN_POWER_RANGE_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x1E) + +/* Generic Power Level Setup Message Opcode */ +#define BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_SET BLE_MESH_MODEL_OP_2(0x82, 0x1F) +#define BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x20) +#define BLE_MESH_MODEL_OP_GEN_POWER_RANGE_SET BLE_MESH_MODEL_OP_2(0x82, 0x21) +#define BLE_MESH_MODEL_OP_GEN_POWER_RANGE_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x22) + +/* Generic Battery Message Opcode */ +#define BLE_MESH_MODEL_OP_GEN_BATTERY_GET BLE_MESH_MODEL_OP_2(0x82, 0x23) +#define BLE_MESH_MODEL_OP_GEN_BATTERY_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x24) + +/* Generic Location Message Opcode */ +#define BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_GET BLE_MESH_MODEL_OP_2(0x82, 0x25) +#define BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_STATUS BLE_MESH_MODEL_OP_1(0x40) +#define BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_GET BLE_MESH_MODEL_OP_2(0x82, 0x26) +#define BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x27) + +/* Generic Location Setup Message Opcode */ +#define BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_SET BLE_MESH_MODEL_OP_1(0x41) +#define BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_SET_UNACK BLE_MESH_MODEL_OP_1(0x42) +#define BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_SET BLE_MESH_MODEL_OP_2(0x82, 0x28) +#define BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x29) + +/* Generic Manufacturer Property Message Opcode */ +#define BLE_MESH_MODEL_OP_GEN_MANU_PROPERTIES_GET BLE_MESH_MODEL_OP_2(0x82, 0x2A) +#define BLE_MESH_MODEL_OP_GEN_MANU_PROPERTIES_STATUS BLE_MESH_MODEL_OP_1(0x43) +#define BLE_MESH_MODEL_OP_GEN_MANU_PROPERTY_GET BLE_MESH_MODEL_OP_2(0x82, 0x2B) +#define BLE_MESH_MODEL_OP_GEN_MANU_PROPERTY_SET BLE_MESH_MODEL_OP_1(0x44) +#define BLE_MESH_MODEL_OP_GEN_MANU_PROPERTY_SET_UNACK BLE_MESH_MODEL_OP_1(0x45) +#define BLE_MESH_MODEL_OP_GEN_MANU_PROPERTY_STATUS BLE_MESH_MODEL_OP_1(0x46) + +/* Generic Admin Property Message Opcode */ +#define BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTIES_GET BLE_MESH_MODEL_OP_2(0x82, 0x2C) +#define BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTIES_STATUS BLE_MESH_MODEL_OP_1(0x47) +#define BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_GET BLE_MESH_MODEL_OP_2(0x82, 0x2D) +#define BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET BLE_MESH_MODEL_OP_1(0x48) +#define BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET_UNACK BLE_MESH_MODEL_OP_1(0x49) +#define BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_STATUS BLE_MESH_MODEL_OP_1(0x4A) + +/* Generic User Property Message Opcode */ +#define BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_GET BLE_MESH_MODEL_OP_2(0x82, 0x2E) +#define BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_STATUS BLE_MESH_MODEL_OP_1(0x4B) +#define BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_GET BLE_MESH_MODEL_OP_2(0x82, 0x2F) +#define BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET BLE_MESH_MODEL_OP_1(0x4C) +#define BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET_UNACK BLE_MESH_MODEL_OP_1(0x4D) +#define BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_STATUS BLE_MESH_MODEL_OP_1(0x4E) + +/* Generic Client Property Message Opcode */ +#define BLE_MESH_MODEL_OP_GEN_CLIENT_PROPERTIES_GET BLE_MESH_MODEL_OP_1(0x4F) +#define BLE_MESH_MODEL_OP_GEN_CLIENT_PROPERTIES_STATUS BLE_MESH_MODEL_OP_1(0x50) + +/* Sensor Message Opcode */ +#define BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_GET BLE_MESH_MODEL_OP_2(0x82, 0x30) +#define BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_STATUS BLE_MESH_MODEL_OP_1(0x51) +#define BLE_MESH_MODEL_OP_SENSOR_GET BLE_MESH_MODEL_OP_2(0x82, 0x31) +#define BLE_MESH_MODEL_OP_SENSOR_STATUS BLE_MESH_MODEL_OP_1(0x52) +#define BLE_MESH_MODEL_OP_SENSOR_COLUMN_GET BLE_MESH_MODEL_OP_2(0x82, 0x32) +#define BLE_MESH_MODEL_OP_SENSOR_COLUMN_STATUS BLE_MESH_MODEL_OP_1(0x53) +#define BLE_MESH_MODEL_OP_SENSOR_SERIES_GET BLE_MESH_MODEL_OP_2(0x82, 0x33) +#define BLE_MESH_MODEL_OP_SENSOR_SERIES_STATUS BLE_MESH_MODEL_OP_1(0x54) + +/* Sensor Setup Message Opcode */ +#define BLE_MESH_MODEL_OP_SENSOR_CADENCE_GET BLE_MESH_MODEL_OP_2(0x82, 0x34) +#define BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET BLE_MESH_MODEL_OP_1(0x55) +#define BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET_UNACK BLE_MESH_MODEL_OP_1(0x56) +#define BLE_MESH_MODEL_OP_SENSOR_CADENCE_STATUS BLE_MESH_MODEL_OP_1(0x57) +#define BLE_MESH_MODEL_OP_SENSOR_SETTINGS_GET BLE_MESH_MODEL_OP_2(0x82, 0x35) +#define BLE_MESH_MODEL_OP_SENSOR_SETTINGS_STATUS BLE_MESH_MODEL_OP_1(0x58) +#define BLE_MESH_MODEL_OP_SENSOR_SETTING_GET BLE_MESH_MODEL_OP_2(0x82, 0x36) +#define BLE_MESH_MODEL_OP_SENSOR_SETTING_SET BLE_MESH_MODEL_OP_1(0x59) +#define BLE_MESH_MODEL_OP_SENSOR_SETTING_SET_UNACK BLE_MESH_MODEL_OP_1(0x5A) +#define BLE_MESH_MODEL_OP_SENSOR_SETTING_STATUS BLE_MESH_MODEL_OP_1(0x5B) + +/* Time Message Opcode */ +#define BLE_MESH_MODEL_OP_TIME_GET BLE_MESH_MODEL_OP_2(0x82, 0x37) +#define BLE_MESH_MODEL_OP_TIME_SET BLE_MESH_MODEL_OP_1(0x5C) +#define BLE_MESH_MODEL_OP_TIME_STATUS BLE_MESH_MODEL_OP_1(0x5D) +#define BLE_MESH_MODEL_OP_TIME_ROLE_GET BLE_MESH_MODEL_OP_2(0x82, 0x38) +#define BLE_MESH_MODEL_OP_TIME_ROLE_SET BLE_MESH_MODEL_OP_2(0x82, 0x39) +#define BLE_MESH_MODEL_OP_TIME_ROLE_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x3A) +#define BLE_MESH_MODEL_OP_TIME_ZONE_GET BLE_MESH_MODEL_OP_2(0x82, 0x3B) +#define BLE_MESH_MODEL_OP_TIME_ZONE_SET BLE_MESH_MODEL_OP_2(0x82, 0x3C) +#define BLE_MESH_MODEL_OP_TIME_ZONE_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x3D) +#define BLE_MESH_MODEL_OP_TAI_UTC_DELTA_GET BLE_MESH_MODEL_OP_2(0x82, 0x3E) +#define BLE_MESH_MODEL_OP_TAI_UTC_DELTA_SET BLE_MESH_MODEL_OP_2(0x82, 0x3F) +#define BLE_MESH_MODEL_OP_TAI_UTC_DELTA_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x40) + +/* Scene Message Opcode */ +#define BLE_MESH_MODEL_OP_SCENE_GET BLE_MESH_MODEL_OP_2(0x82, 0x41) +#define BLE_MESH_MODEL_OP_SCENE_RECALL BLE_MESH_MODEL_OP_2(0x82, 0x42) +#define BLE_MESH_MODEL_OP_SCENE_RECALL_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x43) +#define BLE_MESH_MODEL_OP_SCENE_STATUS BLE_MESH_MODEL_OP_1(0x5E) +#define BLE_MESH_MODEL_OP_SCENE_REGISTER_GET BLE_MESH_MODEL_OP_2(0x82, 0x44) +#define BLE_MESH_MODEL_OP_SCENE_REGISTER_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x45) + +/* Scene Setup Message Opcode */ +#define BLE_MESH_MODEL_OP_SCENE_STORE BLE_MESH_MODEL_OP_2(0x82, 0x46) +#define BLE_MESH_MODEL_OP_SCENE_STORE_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x47) +#define BLE_MESH_MODEL_OP_SCENE_DELETE BLE_MESH_MODEL_OP_2(0x82, 0x9E) +#define BLE_MESH_MODEL_OP_SCENE_DELETE_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x9F) + +/* Scheduler Message Opcode */ +#define BLE_MESH_MODEL_OP_SCHEDULER_ACT_GET BLE_MESH_MODEL_OP_2(0x82, 0x48) +#define BLE_MESH_MODEL_OP_SCHEDULER_ACT_STATUS BLE_MESH_MODEL_OP_1(0x5F) +#define BLE_MESH_MODEL_OP_SCHEDULER_GET BLE_MESH_MODEL_OP_2(0x82, 0x49) +#define BLE_MESH_MODEL_OP_SCHEDULER_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x4A) + +/* Scheduler Setup Message Opcode */ +#define BLE_MESH_MODEL_OP_SCHEDULER_ACT_SET BLE_MESH_MODEL_OP_1(0x60) +#define BLE_MESH_MODEL_OP_SCHEDULER_ACT_SET_UNACK BLE_MESH_MODEL_OP_1(0x61) + +/* Light Lightness Message Opcode */ +#define BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_GET BLE_MESH_MODEL_OP_2(0x82, 0x4B) +#define BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_SET BLE_MESH_MODEL_OP_2(0x82, 0x4C) +#define BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x4D) +#define BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x4E) +#define BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_GET BLE_MESH_MODEL_OP_2(0x82, 0x4F) +#define BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_SET BLE_MESH_MODEL_OP_2(0x82, 0x50) +#define BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x51) +#define BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x52) +#define BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LAST_GET BLE_MESH_MODEL_OP_2(0x82, 0x53) +#define BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LAST_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x54) +#define BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_GET BLE_MESH_MODEL_OP_2(0x82, 0x55) +#define BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x56) +#define BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_GET BLE_MESH_MODEL_OP_2(0x82, 0x57) +#define BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x58) + +/* Light Lightness Setup Message Opcode */ +#define BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_SET BLE_MESH_MODEL_OP_2(0x82, 0x59) +#define BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x5A) +#define BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_SET BLE_MESH_MODEL_OP_2(0x82, 0x5B) +#define BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x5C) + +/* Light CTL Message Opcode */ +#define BLE_MESH_MODEL_OP_LIGHT_CTL_GET BLE_MESH_MODEL_OP_2(0x82, 0x5D) +#define BLE_MESH_MODEL_OP_LIGHT_CTL_SET BLE_MESH_MODEL_OP_2(0x82, 0x5E) +#define BLE_MESH_MODEL_OP_LIGHT_CTL_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x5F) +#define BLE_MESH_MODEL_OP_LIGHT_CTL_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x60) +#define BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_GET BLE_MESH_MODEL_OP_2(0x82, 0x61) +#define BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_GET BLE_MESH_MODEL_OP_2(0x82, 0x62) +#define BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x63) +#define BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_SET BLE_MESH_MODEL_OP_2(0x82, 0x64) +#define BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x65) +#define BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x66) +#define BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_GET BLE_MESH_MODEL_OP_2(0x82, 0x67) +#define BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x68) + +/* Light CTL Setup Message Opcode */ +#define BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_SET BLE_MESH_MODEL_OP_2(0x82, 0x69) +#define BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x6A) +#define BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_SET BLE_MESH_MODEL_OP_2(0x82, 0x6B) +#define BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x6C) + +/* Light HSL Message Opcode */ +#define BLE_MESH_MODEL_OP_LIGHT_HSL_GET BLE_MESH_MODEL_OP_2(0x82, 0x6D) +#define BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_GET BLE_MESH_MODEL_OP_2(0x82, 0x6E) +#define BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_SET BLE_MESH_MODEL_OP_2(0x82, 0x6F) +#define BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x70) +#define BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x71) +#define BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_GET BLE_MESH_MODEL_OP_2(0x82, 0x72) +#define BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_SET BLE_MESH_MODEL_OP_2(0x82, 0x73) +#define BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x74) +#define BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x75) +#define BLE_MESH_MODEL_OP_LIGHT_HSL_SET BLE_MESH_MODEL_OP_2(0x82, 0x76) +#define BLE_MESH_MODEL_OP_LIGHT_HSL_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x77) +#define BLE_MESH_MODEL_OP_LIGHT_HSL_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x78) +#define BLE_MESH_MODEL_OP_LIGHT_HSL_TARGET_GET BLE_MESH_MODEL_OP_2(0x82, 0x79) +#define BLE_MESH_MODEL_OP_LIGHT_HSL_TARGET_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x7A) +#define BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_GET BLE_MESH_MODEL_OP_2(0x82, 0x7B) +#define BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x7C) +#define BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_GET BLE_MESH_MODEL_OP_2(0x82, 0x7D) +#define BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x7E) + +/* Light HSL Setup Message Opcode */ +#define BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_SET BLE_MESH_MODEL_OP_2(0x82, 0x7F) +#define BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x80) +#define BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_SET BLE_MESH_MODEL_OP_2(0x82, 0x81) +#define BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x82) + +/* Light xyL Message Opcode */ +#define BLE_MESH_MODEL_OP_LIGHT_XYL_GET BLE_MESH_MODEL_OP_2(0x82, 0x83) +#define BLE_MESH_MODEL_OP_LIGHT_XYL_SET BLE_MESH_MODEL_OP_2(0x82, 0x84) +#define BLE_MESH_MODEL_OP_LIGHT_XYL_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x85) +#define BLE_MESH_MODEL_OP_LIGHT_XYL_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x86) +#define BLE_MESH_MODEL_OP_LIGHT_XYL_TARGET_GET BLE_MESH_MODEL_OP_2(0x82, 0x87) +#define BLE_MESH_MODEL_OP_LIGHT_XYL_TARGET_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x88) +#define BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_GET BLE_MESH_MODEL_OP_2(0x82, 0x89) +#define BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x8A) +#define BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_GET BLE_MESH_MODEL_OP_2(0x82, 0x8B) +#define BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x8C) + +/* Light xyL Setup Message Opcode */ +#define BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_SET BLE_MESH_MODEL_OP_2(0x82, 0x8D) +#define BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x8E) +#define BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_SET BLE_MESH_MODEL_OP_2(0x82, 0x8F) +#define BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x90) + +/* Light Control Message Opcode */ +#define BLE_MESH_MODEL_OP_LIGHT_LC_MODE_GET BLE_MESH_MODEL_OP_2(0x82, 0x91) +#define BLE_MESH_MODEL_OP_LIGHT_LC_MODE_SET BLE_MESH_MODEL_OP_2(0x82, 0x92) +#define BLE_MESH_MODEL_OP_LIGHT_LC_MODE_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x93) +#define BLE_MESH_MODEL_OP_LIGHT_LC_MODE_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x94) +#define BLE_MESH_MODEL_OP_LIGHT_LC_OM_GET BLE_MESH_MODEL_OP_2(0x82, 0x95) +#define BLE_MESH_MODEL_OP_LIGHT_LC_OM_SET BLE_MESH_MODEL_OP_2(0x82, 0x96) +#define BLE_MESH_MODEL_OP_LIGHT_LC_OM_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x97) +#define BLE_MESH_MODEL_OP_LIGHT_LC_OM_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x98) +#define BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_GET BLE_MESH_MODEL_OP_2(0x82, 0x99) +#define BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_SET BLE_MESH_MODEL_OP_2(0x82, 0x9A) +#define BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x9B) +#define BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x9C) +#define BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_GET BLE_MESH_MODEL_OP_2(0x82, 0x9D) +#define BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET BLE_MESH_MODEL_OP_1(0x62) +#define BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET_UNACK BLE_MESH_MODEL_OP_1(0x63) +#define BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_STATUS BLE_MESH_MODEL_OP_1(0x64) + +#ifdef __cplusplus +} +#endif + +#endif /* _MODEL_OPCODE_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/server/include/generic_server.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/server/include/generic_server.h new file mode 100644 index 00000000000..0e79233f958 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/server/include/generic_server.h @@ -0,0 +1,367 @@ +/* Bluetooth: Mesh Generic OnOff, Generic Level, Lighting & Vendor Models + * + * SPDX-FileCopyrightText: 2018 Vikrant More + * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _GENERIC_SERVER_H_ +#define _GENERIC_SERVER_H_ + +#include "server_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct bt_mesh_gen_onoff_state { + uint8_t onoff; + uint8_t target_onoff; +}; + +struct bt_mesh_gen_onoff_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_gen_onoff_state state; + struct bt_mesh_last_msg_info last; + struct bt_mesh_state_transition transition; +}; + +struct bt_mesh_gen_level_state { + int16_t level; + int16_t target_level; + + int16_t last_level; + int32_t last_delta; + + bool move_start; + bool positive; +}; + +struct bt_mesh_gen_level_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_gen_level_state state; + struct bt_mesh_last_msg_info last; + struct bt_mesh_state_transition transition; + int32_t tt_delta_level; +}; + +struct bt_mesh_gen_def_trans_time_state { + uint8_t trans_time; +}; + +struct bt_mesh_gen_def_trans_time_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_gen_def_trans_time_state state; +}; + +struct bt_mesh_gen_onpowerup_state { + uint8_t onpowerup; +}; + +struct bt_mesh_gen_power_onoff_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_gen_onpowerup_state *state; +}; + +struct bt_mesh_gen_power_onoff_setup_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_gen_onpowerup_state *state; +}; + +struct bt_mesh_gen_power_level_state { + uint16_t power_actual; + uint16_t target_power_actual; + + uint16_t power_last; + uint16_t power_default; + + uint8_t status_code; + uint16_t power_range_min; + uint16_t power_range_max; +}; + +struct bt_mesh_gen_power_level_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_gen_power_level_state *state; + struct bt_mesh_last_msg_info last; + struct bt_mesh_state_transition transition; + int32_t tt_delta_level; +}; + +struct bt_mesh_gen_power_level_setup_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_gen_power_level_state *state; +}; + +struct bt_mesh_gen_battery_state { + uint32_t battery_level : 8, + time_to_discharge : 24; + uint32_t time_to_charge : 24, + battery_flags : 8; +}; + +struct bt_mesh_gen_battery_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_gen_battery_state state; +}; + +struct bt_mesh_gen_location_state { + int32_t global_latitude; + int32_t global_longitude; + int16_t global_altitude; + int16_t local_north; + int16_t local_east; + int16_t local_altitude; + uint8_t floor_number; + uint16_t uncertainty; +}; + +struct bt_mesh_gen_location_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_gen_location_state *state; +}; + +struct bt_mesh_gen_location_setup_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_gen_location_state *state; +}; + +/** + * According to the hierarchy of Generic Property states (Model Spec section 3.1.8), + * the Manufacturer Properties and Admin Properties may contain multiple Property + * states. User Properties just a collection of which can be accessed. + * + * property_count: Number of the properties contained in the table + * properties: Table of the properties + * + * These variables need to be initialized in the application layer, the precise + * number of the properties should be set and memories used to store the property + * values should be allocated. + */ + +enum bt_mesh_gen_user_prop_access { + USER_ACCESS_PROHIBIT, + USER_ACCESS_READ, + USER_ACCESS_WRITE, + USER_ACCESS_READ_WRITE, +}; + +enum bt_mesh_gen_admin_prop_access { + ADMIN_NOT_USER_PROP, + ADMIN_ACCESS_READ, + ADMIN_ACCESS_WRITE, + ADMIN_ACCESS_READ_WRITE, +}; + +enum bt_mesh_gen_manu_prop_access { + MANU_NOT_USER_PROP, + MANU_ACCESS_READ, +}; + +struct bt_mesh_generic_property { + uint16_t id; + uint8_t user_access; + uint8_t admin_access; + uint8_t manu_access; + struct net_buf_simple *val; +}; + +struct bt_mesh_gen_user_prop_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + uint8_t property_count; + struct bt_mesh_generic_property *properties; +}; + +struct bt_mesh_gen_admin_prop_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + uint8_t property_count; + struct bt_mesh_generic_property *properties; +}; + +struct bt_mesh_gen_manu_prop_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + uint8_t property_count; + struct bt_mesh_generic_property *properties; +}; + +struct bt_mesh_gen_client_prop_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + uint8_t id_count; + uint16_t *property_ids; +}; + +typedef union { + struct { + uint8_t onoff; + } gen_onoff_set; + struct { + int16_t level; + } gen_level_set; + struct { + int16_t level; + } gen_delta_set; + struct { + int16_t level; + } gen_move_set; + struct { + uint8_t trans_time; + } gen_def_trans_time_set; + struct { + uint8_t onpowerup; + } gen_onpowerup_set; + struct { + uint16_t power; + } gen_power_level_set; + struct { + uint16_t power; + } gen_power_default_set; + struct { + uint16_t range_min; + uint16_t range_max; + } gen_power_range_set; + struct { + int32_t latitude; + int32_t longitude; + int16_t altitude; + } gen_loc_global_set; + struct { + int16_t north; + int16_t east; + int16_t altitude; + uint8_t floor_number; + uint16_t uncertainty; + } gen_loc_local_set; + struct { + uint16_t id; + struct net_buf_simple *value; + } gen_user_prop_set; + struct { + uint16_t id; + uint8_t access; + struct net_buf_simple *value; + } gen_admin_prop_set; + struct { + uint16_t id; + uint8_t access; + } gen_manu_prop_set; +} bt_mesh_gen_server_state_change_t; + +typedef union { + struct { + uint16_t id; + } user_property_get; + struct { + uint16_t id; + } admin_property_get; + struct { + uint16_t id; + } manu_property_get; + struct { + uint16_t id; + } client_properties_get; +} bt_mesh_gen_server_recv_get_msg_t; + +typedef union { + struct { + bool op_en; + uint8_t onoff; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; + } onoff_set; + struct { + bool op_en; + int16_t level; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; + } level_set; + struct { + bool op_en; + int32_t delta_level; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; + } delta_set; + struct { + bool op_en; + int16_t delta_level; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; + } move_set; + struct { + uint8_t trans_time; + } def_trans_time_set; + struct { + uint8_t onpowerup; + } onpowerup_set; + struct { + bool op_en; + uint16_t power; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; + } power_level_set; + struct { + uint16_t power; + } power_default_set; + struct { + uint16_t range_min; + uint16_t range_max; + } power_range_set; + struct { + int32_t latitude; + int32_t longitude; + int16_t altitude; + } loc_global_set; + struct { + int16_t north; + int16_t east; + int16_t altitude; + uint8_t floor_number; + uint16_t uncertainty; + } loc_local_set; + struct { + uint16_t id; + struct net_buf_simple *value; + } user_property_set; + struct { + uint16_t id; + uint8_t access; + struct net_buf_simple *value; + } admin_property_set; + struct { + uint16_t id; + uint8_t access; + } manu_property_set; +} bt_mesh_gen_server_recv_set_msg_t; + +void bt_mesh_generic_server_lock(void); +void bt_mesh_generic_server_unlock(void); + +void gen_onoff_publish(struct bt_mesh_model *model); +void gen_level_publish(struct bt_mesh_model *model); +void gen_onpowerup_publish(struct bt_mesh_model *model); +void gen_power_level_publish(struct bt_mesh_model *model, uint16_t opcode); + +#ifdef __cplusplus +} +#endif + +#endif /* _GENERIC_SERVER_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/server/include/lighting_server.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/server/include/lighting_server.h new file mode 100644 index 00000000000..a3e595a4917 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/server/include/lighting_server.h @@ -0,0 +1,510 @@ +/* Bluetooth: Mesh Generic OnOff, Generic Level, Lighting & Vendor Models + * + * SPDX-FileCopyrightText: 2018 Vikrant More + * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _LIGHTING_SERVER_H_ +#define _LIGHTING_SERVER_H_ + +#include "server_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct bt_mesh_light_lightness_state { + uint16_t lightness_linear; + uint16_t target_lightness_linear; + + uint16_t lightness_actual; + uint16_t target_lightness_actual; + + uint16_t lightness_last; + uint16_t lightness_default; + + uint8_t status_code; + uint16_t lightness_range_min; + uint16_t lightness_range_max; +}; + +struct bt_mesh_light_lightness_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_light_lightness_state *state; + struct bt_mesh_last_msg_info last; + struct bt_mesh_state_transition actual_transition; + struct bt_mesh_state_transition linear_transition; + int32_t tt_delta_lightness_actual; + int32_t tt_delta_lightness_linear; +}; + +struct bt_mesh_light_lightness_setup_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_light_lightness_state *state; +}; + +struct bt_mesh_light_ctl_state { + uint16_t lightness; + uint16_t target_lightness; + + uint16_t temperature; + uint16_t target_temperature; + + int16_t delta_uv; + int16_t target_delta_uv; + + uint8_t status_code; + uint16_t temperature_range_min; + uint16_t temperature_range_max; + + uint16_t lightness_default; + uint16_t temperature_default; + int16_t delta_uv_default; +}; + +struct bt_mesh_light_ctl_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_light_ctl_state *state; + struct bt_mesh_last_msg_info last; + struct bt_mesh_state_transition transition; + int32_t tt_delta_lightness; + int32_t tt_delta_temperature; + int32_t tt_delta_delta_uv; +}; + +struct bt_mesh_light_ctl_setup_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_light_ctl_state *state; +}; + +struct bt_mesh_light_ctl_temp_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_light_ctl_state *state; + struct bt_mesh_last_msg_info last; + struct bt_mesh_state_transition transition; + int32_t tt_delta_temperature; + int32_t tt_delta_delta_uv; +}; + +struct bt_mesh_light_hsl_state { + uint16_t lightness; + uint16_t target_lightness; + + uint16_t hue; + uint16_t target_hue; + + uint16_t saturation; + uint16_t target_saturation; + + uint16_t lightness_default; + uint16_t hue_default; + uint16_t saturation_default; + + uint8_t status_code; + uint16_t hue_range_min; + uint16_t hue_range_max; + uint16_t saturation_range_min; + uint16_t saturation_range_max; +}; + +struct bt_mesh_light_hsl_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_light_hsl_state *state; + struct bt_mesh_last_msg_info last; + struct bt_mesh_state_transition transition; + int32_t tt_delta_lightness; + int32_t tt_delta_hue; + int32_t tt_delta_saturation; +}; + +struct bt_mesh_light_hsl_setup_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_light_hsl_state *state; +}; + +struct bt_mesh_light_hsl_hue_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_light_hsl_state *state; + struct bt_mesh_last_msg_info last; + struct bt_mesh_state_transition transition; + int32_t tt_delta_hue; +}; + +struct bt_mesh_light_hsl_sat_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_light_hsl_state *state; + struct bt_mesh_last_msg_info last; + struct bt_mesh_state_transition transition; + int32_t tt_delta_saturation; +}; + +struct bt_mesh_light_xyl_state { + uint16_t lightness; + uint16_t target_lightness; + + uint16_t x; + uint16_t target_x; + + uint16_t y; + uint16_t target_y; + + uint16_t lightness_default; + uint16_t x_default; + uint16_t y_default; + + uint8_t status_code; + uint16_t x_range_min; + uint16_t x_range_max; + uint16_t y_range_min; + uint16_t y_range_max; +}; + +struct bt_mesh_light_xyl_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_light_xyl_state *state; + struct bt_mesh_last_msg_info last; + struct bt_mesh_state_transition transition; + int32_t tt_delta_lightness; + int32_t tt_delta_x; + int32_t tt_delta_y; +}; + +struct bt_mesh_light_xyl_setup_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_light_xyl_state *state; +}; + +struct bt_mesh_light_lc_state { + uint32_t mode : 1, /* default 0 */ + occupancy_mode : 1, /* default 1 */ + light_onoff : 1, + target_light_onoff : 1, + occupancy : 1, + ambient_luxlevel : 24; /* 0x000000 ~ 0xFFFFFF */ + + uint16_t linear_output; /* 0x0000 ~ 0xFFFF */ +}; + +struct bt_mesh_light_lc_property_state { + uint32_t time_occupancy_delay; /* 0x003A */ + uint32_t time_fade_on; /* 0x0037 */ + uint32_t time_run_on; /* 0x003C */ + uint32_t time_fade; /* 0x0036 */ + uint32_t time_prolong; /* 0x003B */ + uint32_t time_fade_standby_auto; /* 0x0038 */ + uint32_t time_fade_standby_manual; /* 0x0039 */ + + uint16_t lightness_on; /* 0x002E */ + uint16_t lightness_prolong; /* 0x002F */ + uint16_t lightness_standby; /* 0x0030 */ + + uint16_t ambient_luxlevel_on; /* 0x002B, 0x0000 ~ 0xFFFF */ + uint16_t ambient_luxlevel_prolong; /* 0x002C, 0x0000 ~ 0xFFFF */ + uint16_t ambient_luxlevel_standby; /* 0x002D, 0x0000 ~ 0xFFFF */ + + float regulator_kiu; /* 0x0033, 0.0 ~ 1000.0, default 250.0 */ + float regulator_kid; /* 0x0032, 0.0 ~ 1000.0, default 25.0 */ + float regulator_kpu; /* 0x0035, 0.0 ~ 1000.0, default 80.0 */ + float regulator_kpd; /* 0x0034, 0.0 ~ 1000.0, default 80.0 */ + int8_t regulator_accuracy; /* 0x0031, 0.0 ~ 100.0, default 2.0 */ + + uint32_t set_occupancy_to_1_delay; +}; + +typedef enum { + LC_OFF, + LC_STANDBY, + LC_FADE_ON, + LC_RUN, + LC_FADE, + LC_PROLONG, + LC_FADE_STANDBY_AUTO, + LC_FADE_STANDBY_MANUAL, +} bt_mesh_lc_state; + +struct bt_mesh_light_lc_state_machine { + struct { + uint8_t fade_on; + uint8_t fade; + uint8_t fade_standby_auto; + uint8_t fade_standby_manual; + } trans_time; + bt_mesh_lc_state state; + struct k_delayed_work timer; +}; + +struct bt_mesh_light_control { + struct bt_mesh_light_lc_state state; + struct bt_mesh_light_lc_property_state prop_state; + struct bt_mesh_light_lc_state_machine state_machine; +}; + +struct bt_mesh_light_lc_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_light_control *lc; + struct bt_mesh_last_msg_info last; + struct bt_mesh_state_transition transition; +}; + +struct bt_mesh_light_lc_setup_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_light_control *lc; +}; + +typedef union { + struct { + uint16_t lightness; + } lightness_set; + struct { + uint16_t lightness; + } lightness_linear_set; + struct { + uint16_t lightness; + } lightness_default_set; + struct { + uint16_t range_min; + uint16_t range_max; + } lightness_range_set; + struct { + uint16_t lightness; + uint16_t temperature; + int16_t delta_uv; + } ctl_set; + struct { + uint16_t temperature; + int16_t delta_uv; + } ctl_temp_set; + struct { + uint16_t range_min; + uint16_t range_max; + } ctl_temp_range_set; + struct { + uint16_t lightness; + uint16_t temperature; + int16_t delta_uv; + } ctl_default_set; + struct { + uint16_t lightness; + uint16_t hue; + uint16_t saturation; + } hsl_set; + struct { + uint16_t hue; + } hsl_hue_set; + struct { + uint16_t saturation; + } hsl_saturation_set; + struct { + uint16_t lightness; + uint16_t hue; + uint16_t saturation; + } hsl_default_set; + struct { + uint16_t hue_range_min; + uint16_t hue_range_max; + uint16_t sat_range_min; + uint16_t sat_range_max; + } hsl_range_set; + struct { + uint16_t lightness; + uint16_t x; + uint16_t y; + } xyl_set; + struct { + uint16_t lightness; + uint16_t x; + uint16_t y; + } xyl_default_set; + struct { + uint16_t x_range_min; + uint16_t x_range_max; + uint16_t y_range_min; + uint16_t y_range_max; + } xyl_range_set; + struct { + uint8_t mode; + } lc_mode_set; + struct { + uint8_t mode; + } lc_om_set; + struct { + uint8_t onoff; + } lc_light_onoff_set; + struct { + uint16_t id; + struct net_buf_simple *value; + } lc_property_set; + struct { + uint16_t property_id; + union { + uint8_t occupancy; + uint32_t set_occupancy_to_1_delay; + uint32_t ambient_luxlevel; + } state; + } sensor_status; +} bt_mesh_light_server_state_change_t; + +typedef union { + struct { + uint16_t id; + } lc_property_get; +} bt_mesh_light_server_recv_get_msg_t; + +typedef union { + struct { + bool op_en; + uint16_t lightness; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; + } lightness_set; + struct { + bool op_en; + uint16_t lightness; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; + } lightness_linear_set; + struct { + uint16_t lightness; + } lightness_default_set; + struct { + uint16_t range_min; + uint16_t range_max; + } lightness_range_set; + struct { + bool op_en; + uint16_t lightness; + uint16_t temperature; + int16_t delta_uv; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; + } ctl_set; + struct { + bool op_en; + uint16_t temperature; + int16_t delta_uv; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; + } ctl_temp_set; + struct { + uint16_t range_min; + uint16_t range_max; + } ctl_temp_range_set; + struct { + uint16_t lightness; + uint16_t temperature; + int16_t delta_uv; + } ctl_default_set; + struct { + bool op_en; + uint16_t lightness; + uint16_t hue; + uint16_t saturation; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; + } hsl_set; + struct { + bool op_en; + uint16_t hue; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; + } hsl_hue_set; + struct { + bool op_en; + uint16_t saturation; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; + } hsl_saturation_set; + struct { + uint16_t lightness; + uint16_t hue; + uint16_t saturation; + } hsl_default_set; + struct { + uint16_t hue_range_min; + uint16_t hue_range_max; + uint16_t sat_range_min; + uint16_t sat_range_max; + } hsl_range_set; + struct { + bool op_en; + uint16_t lightness; + uint16_t x; + uint16_t y; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; + } xyl_set; + struct { + uint16_t lightness; + uint16_t x; + uint16_t y; + } xyl_default_set; + struct { + uint16_t x_range_min; + uint16_t x_range_max; + uint16_t y_range_min; + uint16_t y_range_max; + } xyl_range_set; + struct { + uint8_t mode; + } lc_mode_set; + struct { + uint8_t mode; + } lc_om_set; + struct { + bool op_en; + uint8_t light_onoff; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; + } lc_light_onoff_set; + struct { + uint16_t id; + struct net_buf_simple *value; + } lc_property_set; +} bt_mesh_light_server_recv_set_msg_t; + +typedef union { + struct { + struct net_buf_simple *data; + } sensor_status; +} bt_mesh_light_server_recv_status_msg_t; + +void bt_mesh_light_server_lock(void); +void bt_mesh_light_server_unlock(void); + +uint8_t *bt_mesh_get_lc_prop_value(struct bt_mesh_model *model, uint16_t prop_id); + +void light_lightness_publish(struct bt_mesh_model *model, uint16_t opcode); +void light_ctl_publish(struct bt_mesh_model *model, uint16_t opcode); +void light_hsl_publish(struct bt_mesh_model *model, uint16_t opcode); +void light_xyl_publish(struct bt_mesh_model *model, uint16_t opcode); +void light_lc_publish(struct bt_mesh_model *model, uint16_t opcode); + +#ifdef __cplusplus +} +#endif + +#endif /* _LIGHTING_SERVER_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/server/include/sensor_server.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/server/include/sensor_server.h new file mode 100644 index 00000000000..7946f3b4faf --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/server/include/sensor_server.h @@ -0,0 +1,246 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _SENSOR_SERVER_H_ +#define _SENSOR_SERVER_H_ + +#include "server_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Sensor Property ID related */ +#define INVALID_SENSOR_PROPERTY_ID 0x0000 + +#define SENSOR_PROPERTY_ID_LEN 0x02 + +/* Sensor Descriptor state related */ +#define SENSOR_DESCRIPTOR_LEN 0x08 + +#define SENSOR_UNSPECIFIED_POS_TOLERANCE 0x000 +#define SENSOR_UNSPECIFIED_NEG_TOLERANCE 0x000 + +#define SENSOR_NOT_APPL_MEASURE_PERIOD 0x00 + +#define SENSOR_NOT_APPL_UPDATE_INTERVAL 0x00 + +/* Sensor Setting state related */ +#define INVALID_SENSOR_SETTING_PROPERTY_ID 0x0000 + +#define SENSOR_SETTING_PROPERTY_ID_LEN 0x02 +#define SENSOR_SETTING_ACCESS_LEN 0x01 + +#define SENSOR_SETTING_ACCESS_READ 0x01 +#define SENSOR_SETTING_ACCESS_READ_WRITE 0x03 + +/* Sensor Cadence state related */ +#define SENSOR_DIVISOR_TRIGGER_TYPE_LEN 0x01 +#define SENSOR_STATUS_MIN_INTERVAL_LEN 0x01 + +#define SENSOR_PERIOD_DIVISOR_MAX_VALUE 15 + +#define SENSOR_STATUS_MIN_INTERVAL_MAX 26 + +#define SENSOR_STATUS_TRIGGER_TYPE_CHAR 0 +#define SENSOR_STATUS_TRIGGER_TYPE_UINT16 1 + +#define SENSOR_STATUS_TRIGGER_UINT16_LEN 0x02 + +/* Sensor Data state related */ +#define SENSOR_DATA_FORMAT_A 0x00 +#define SENSOR_DATA_FORMAT_B 0x01 + +#define SENSOR_DATA_FORMAT_A_MPID_LEN 0x02 +#define SENSOR_DATA_FORMAT_B_MPID_LEN 0x03 + +#define SENSOR_DATA_ZERO_LEN 0x7F + +enum bt_mesh_sensor_sample_func { + UNSPECIFIED, + INSTANTANEOUS, + ARITHMETIC_MEAN, + RMS, + MAXIMUM, + MINIMUM, + ACCUMULATED, + COUNT, +}; + +struct sensor_descriptor { + uint32_t positive_tolerance : 12, + negative_tolerance : 12, + sample_function : 8; + uint8_t measure_period; + uint8_t update_interval; +}; + +struct sensor_setting { + uint16_t property_id; + uint8_t access; + /* Or use union to include all possible types */ + struct net_buf_simple *raw; +}; + +struct sensor_cadence { + uint8_t period_divisor : 7, + trigger_type : 1; + struct net_buf_simple *trigger_delta_down; + struct net_buf_simple *trigger_delta_up; + uint8_t min_interval; + struct net_buf_simple *fast_cadence_low; + struct net_buf_simple *fast_cadence_high; +}; + +struct sensor_data { + /** + * Format A: The Length field is a 1-based uint4 value (valid range 0x0–0xF, + * representing range of 1 – 16). + * Format B: The Length field is a 1-based uint7 value (valid range 0x0–0x7F, + * representing range of 1 – 127). The value 0x7F represents a + * length of zero. + */ + uint8_t format : 1, + length : 7; + struct net_buf_simple *raw_value; +}; + +struct sensor_series_column { + struct net_buf_simple *raw_value_x; + struct net_buf_simple *column_width; + struct net_buf_simple *raw_value_y; +}; + +struct bt_mesh_sensor_state { + uint16_t sensor_property_id; + + /* Constant throughout the lifetime of an element */ + struct sensor_descriptor descriptor; + + /* 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; + struct sensor_setting *settings; + + /* The Sensor Cadence state may be not supported by sensors based + * on device properties referencing "non-scalar characteristics" + * such as "histograms" or "composite characteristics". + */ + struct sensor_cadence *cadence; + + struct sensor_data sensor_data; + + /* Values measured by sensors may be organized as arrays (and + * represented as series of columns, such as histograms). + * 1. The Sensor Raw Value X field has a size and representation + * defined by the Sensor Property ID and represents the left + * corner of the column on the X axis. + * 2. The Sensor Column Width field has a size and representation + * defined by the Sensor Property ID and represents the width + * of the column on the X axis. + * 3. The Sensor Raw Value Y field has a size and representation + * defined by the Sensor Property ID and represents the height + * of the column on the Y axis. + * Note: Values outside the bins defined by a Sensor Property are + * not included. For example, if the histogram is defined as 3 bins + * representing “lamp operating hours in a given temperature range” + * and the bins are [40,60), [60, 80), and [80,100], then any hours + * outside that [40, 100] range would not be included. + */ + struct sensor_series_column series_column; +}; + +/* 1. Multiple instances of the Sensor states may be present within the + * same model, provided that each instance has a unique value of the + * Sensor Property ID to allow the instances to be differentiated. + * 2. Note: The number of sensors within a multisensor is limited by the + * size of the message payload for the Sensor Descriptor Status message. + * A single Sensor Descriptor may be sent using a single Unsegmented + * Access message. Using Segmentation and Reassembly (SAR), up to 38 + * Sensor Descriptor states may be sent. + */ + +struct bt_mesh_sensor_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + const uint8_t state_count; + struct bt_mesh_sensor_state *states; +}; + +struct bt_mesh_sensor_setup_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + const uint8_t state_count; + struct bt_mesh_sensor_state *states; +}; + +typedef union { + struct { + uint16_t id; + uint8_t period_divisor : 7, + trigger_type : 1; + struct net_buf_simple *trigger_delta_down; + struct net_buf_simple *trigger_delta_up; + uint8_t min_interval; + struct net_buf_simple *fast_cadence_low; + struct net_buf_simple *fast_cadence_high; + } sensor_cadence_set; + struct { + uint16_t id; + uint16_t setting_id; + struct net_buf_simple *value; + } sensor_setting_set; +} bt_mesh_sensor_server_state_change_t; + +typedef union { + struct { + bool op_en; + uint16_t id; + } sensor_descriptor_get; + struct { + uint16_t id; + } sensor_cadence_get; + struct { + uint16_t id; + } sensor_settings_get; + struct { + uint16_t id; + uint16_t setting_id; + } sensor_setting_get; + struct { + bool op_en; + uint16_t id; + } sensor_get; + struct { + uint16_t id; + struct net_buf_simple *raw_x; + } sensor_column_get; + struct { + bool op_en; + uint16_t id; + struct net_buf_simple *raw; + } sensor_series_get; +} bt_mesh_sensor_server_recv_get_msg_t; + +typedef union { + struct { + uint16_t id; + struct net_buf_simple *cadence; + } sensor_cadence_set; + struct { + uint16_t id; + uint16_t setting_id; + struct net_buf_simple *raw; + } sensor_setting_set; +} bt_mesh_sensor_server_recv_set_msg_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _SENSOR_SERVER_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/server/include/server_common.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/server/include/server_common.h new file mode 100644 index 00000000000..d56dcbd8433 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/server/include/server_common.h @@ -0,0 +1,124 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _SERVER_COMMON_H_ +#define _SERVER_COMMON_H_ + +#include +#include +#include "mesh_access.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define BLE_MESH_SERVER_RSP_MAX_LEN 384 + +#define BLE_MESH_SERVER_TRANS_MIC_SIZE 4 + +#define BLE_MESH_CHECK_SEND_STATUS(_func) do { \ + int __status = (_func); \ + if (__status) { \ + BT_ERR("%s, Send failed, err %d", __func__, __status); \ + } \ + } while(0); + +#define BLE_MESH_STATE_OFF 0x00 +#define BLE_MESH_STATE_ON 0x01 +#define BLE_MESH_STATE_RESTORE 0x02 + +/* Following 4 values are as per Mesh Model specification */ +#define BLE_MESH_LIGHTNESS_MIN 0x0001 +#define BLE_MESH_LIGHTNESS_MAX 0xFFFF +#define BLE_MESH_TEMPERATURE_MIN 0x0320 +#define BLE_MESH_TEMPERATURE_MAX 0x4E20 +#define BLE_MESH_TEMPERATURE_UNKNOWN 0xFFFF + +/* Refer 7.2 of Mesh Model Specification */ +#define BLE_MESH_RANGE_UPDATE_SUCCESS 0x00 +#define BLE_MESH_CANNOT_SET_RANGE_MIN 0x01 +#define BLE_MESH_CANNOT_SET_RANGE_MAX 0x02 + +#define BLE_MESH_UNKNOWN_REMAIN_TIME 0x3F +#define BLE_MESH_DEVICE_SPECIFIC_RESOLUTION 10 + +enum { + BLE_MESH_TRANS_TIMER_START, /* Proper transition timer has been started */ + BLE_MESH_TRANS_FLAG_MAX, +}; + +struct bt_mesh_state_transition { + bool just_started; + + uint8_t trans_time; + uint8_t remain_time; + uint8_t delay; + uint32_t quo_tt; + uint32_t counter; + uint32_t total_duration; + int64_t start_timestamp; + + BLE_MESH_ATOMIC_DEFINE(flag, BLE_MESH_TRANS_FLAG_MAX); + struct k_delayed_work timer; +}; + +struct bt_mesh_last_msg_info { + uint8_t tid; + uint16_t src; + uint16_t dst; + int64_t timestamp; +}; + +#define BLE_MESH_SERVER_RSP_BY_APP 0 +#define BLE_MESH_SERVER_AUTO_RSP 1 + +struct bt_mesh_server_rsp_ctrl { + /** + * @brief BLE Mesh Server Response Option + * 1. If get_auto_rsp is set to BLE_MESH_SERVER_RSP_BY_APP, then the response + * of Client Get messages need to be replied by the application; + * 2. If get_auto_rsp is set to BLE_MESH_SERVER_AUTO_RSP, then the response + * of Client Get messages will be replied by the server models; + * 3. If set_auto_rsp is set to BLE_MESH_SERVER_RSP_BY_APP, then the response + * of Client Set messages need to be replied by the application; + * 4. If set_auto_rsp is set to BLE_MESH_SERVER_AUTO_RSP, then the response + * of Client Set messages will be replied by the server models; + * 5. If status_auto_rsp is set to BLE_MESH_SERVER_RSP_BY_APP, then the response + * of Server Status messages need to be replied by the application; + * 6. If status_auto_rsp is set to BLE_MESH_SERVER_AUTO_RSP, then the response + * of Server status messages will be replied by the server models; + */ + uint8_t get_auto_rsp : 1, /* Response for Client Get messages */ + set_auto_rsp : 1, /* Response for Client Set messages */ + status_auto_rsp : 1; /* Response for Server Status messages */ +}; + +uint8_t bt_mesh_get_default_trans_time(struct bt_mesh_model *model); + +int bt_mesh_get_light_lc_trans_time(struct bt_mesh_model *model, uint8_t *trans_time); + +int bt_mesh_server_get_optional(struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf, + uint8_t *trans_time, uint8_t *delay, + bool *optional); + +void bt_mesh_server_alloc_ctx(struct k_work *work); +void bt_mesh_server_free_ctx(struct k_work *work); + +bool bt_mesh_is_server_recv_last_msg(struct bt_mesh_last_msg_info *last, + uint8_t tid, uint16_t src, uint16_t dst, int64_t *now); + +void bt_mesh_server_update_last_msg(struct bt_mesh_last_msg_info *last, + uint8_t tid, uint16_t src, uint16_t dst, int64_t *now); + +struct net_buf_simple *bt_mesh_server_get_pub_msg(struct bt_mesh_model *model, uint16_t msg_len); + +#ifdef __cplusplus +} +#endif + +#endif /* _SERVER_COMMON_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/server/include/state_binding.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/server/include/state_binding.h new file mode 100644 index 00000000000..3a44f9e0010 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/server/include/state_binding.h @@ -0,0 +1,108 @@ +/* Bluetooth: Mesh Generic OnOff, Generic Level, Lighting & Vendor Models + * + * SPDX-FileCopyrightText: 2018 Vikrant More + * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _STATE_BINDING_H_ +#define _STATE_BINDING_H_ + +#include "mesh_access.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + GENERIC_ONOFF_STATE, + GENERIC_LEVEL_STATE, + GENERIC_ONPOWERUP_STATE, + GENERIC_POWER_ACTUAL_STATE, + LIGHT_LIGHTNESS_ACTUAL_STATE, + LIGHT_LIGHTNESS_LINEAR_STATE, + LIGHT_CTL_LIGHTNESS_STATE, + LIGHT_CTL_TEMP_DELTA_UV_STATE, + LIGHT_HSL_STATE, + LIGHT_HSL_LIGHTNESS_STATE, + LIGHT_HSL_HUE_STATE, + LIGHT_HSL_SATURATION_STATE, + LIGHT_XYL_LIGHTNESS_STATE, + LIGHT_LC_LIGHT_ONOFF_STATE, + BIND_STATE_MAX, +} bt_mesh_server_state_type_t; + +typedef union { + struct { + uint8_t onoff; + } gen_onoff; + struct { + int16_t level; + } gen_level; + struct { + uint8_t onpowerup; + } gen_onpowerup; + struct { + uint16_t power; + } gen_power_actual; + struct { + uint16_t lightness; + } light_lightness_actual; + struct { + uint16_t lightness; + } light_lightness_linear; + struct { + uint16_t lightness; + } light_ctl_lightness; + struct { + uint16_t temperature; + int16_t delta_uv; + } light_ctl_temp_delta_uv; + struct { + uint16_t lightness; + uint16_t hue; + uint16_t saturation; + } light_hsl; + struct { + uint16_t lightness; + } light_hsl_lightness; + struct { + uint16_t hue; + } light_hsl_hue; + struct { + uint16_t saturation; + } light_hsl_saturation; + struct { + uint16_t lightness; + } light_xyl_lightness; + struct { + uint8_t onoff; + } light_lc_light_onoff; +} bt_mesh_server_state_value_t; + +uint16_t bt_mesh_convert_lightness_actual_to_linear(uint16_t actual); + +uint16_t bt_mesh_convert_lightness_linear_to_actual(uint16_t linear); + +int16_t bt_mesh_convert_temperature_to_gen_level(uint16_t temp, uint16_t min, uint16_t max); + +uint16_t bt_mesh_covert_gen_level_to_temperature(int16_t level, uint16_t min, uint16_t max); + +int16_t bt_mesh_convert_hue_to_level(uint16_t hue); + +uint16_t bt_mesh_convert_level_to_hue(int16_t level); + +int16_t bt_mesh_convert_saturation_to_level(uint16_t saturation); + +uint16_t bt_mesh_convert_level_to_saturation(int16_t level); + +int bt_mesh_update_binding_state(struct bt_mesh_model *model, + bt_mesh_server_state_type_t type, + bt_mesh_server_state_value_t *value); + +#ifdef __cplusplus +} +#endif + +#endif /* _STATE_BINDING_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/server/include/state_transition.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/server/include/state_transition.h new file mode 100644 index 00000000000..86ca747b5a4 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/server/include/state_transition.h @@ -0,0 +1,100 @@ +/* Bluetooth: Mesh Generic OnOff, Generic Level, Lighting & Vendor Models + * + * SPDX-FileCopyrightText: 2018 Vikrant More + * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _STATE_TRANSITION_H_ +#define _STATE_TRANSITION_H_ + +#include "server_common.h" +#include "generic_server.h" +#include "sensor_server.h" +#include "lighting_server.h" +#include "time_scene_server.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void bt_mesh_server_calc_remain_time(struct bt_mesh_state_transition *transition); + +/* APIs used to get server model transition time values */ + +void generic_onoff_tt_values(struct bt_mesh_gen_onoff_srv *srv, + uint8_t trans_time, uint8_t delay); + +void generic_level_tt_values(struct bt_mesh_gen_level_srv *srv, + uint8_t trans_time, uint8_t delay); + +void generic_power_level_tt_values(struct bt_mesh_gen_power_level_srv *srv, + uint8_t trans_time, uint8_t delay); + +void light_lightness_actual_tt_values(struct bt_mesh_light_lightness_srv *srv, + uint8_t trans_time, uint8_t delay); + +void light_lightness_linear_tt_values(struct bt_mesh_light_lightness_srv *srv, + uint8_t trans_time, uint8_t delay); + +void light_ctl_tt_values(struct bt_mesh_light_ctl_srv *srv, + uint8_t trans_time, uint8_t delay); + +void light_ctl_temp_tt_values(struct bt_mesh_light_ctl_temp_srv *srv, + uint8_t trans_time, uint8_t delay); + +void light_hsl_tt_values(struct bt_mesh_light_hsl_srv *srv, + uint8_t trans_time, uint8_t delay); + +void light_hsl_hue_tt_values(struct bt_mesh_light_hsl_hue_srv *srv, + uint8_t trans_time, uint8_t delay); + +void light_hsl_sat_tt_values(struct bt_mesh_light_hsl_sat_srv *srv, + uint8_t trans_time, uint8_t delay); + +void light_xyl_tt_values(struct bt_mesh_light_xyl_srv *srv, + uint8_t trans_time, uint8_t delay); + +void light_lc_tt_values(struct bt_mesh_light_lc_srv *srv, + uint8_t trans_time, uint8_t delay); + +void scene_tt_values(struct bt_mesh_scene_srv *srv, uint8_t trans_time, uint8_t delay); + +/* Server model transition timer handlers */ + +void generic_onoff_work_handler(struct k_work *work); + +void generic_level_work_handler(struct k_work *work); + +void generic_power_level_work_handler(struct k_work *work); + +void light_lightness_actual_work_handler(struct k_work *work); + +void light_lightness_linear_work_handler(struct k_work *work); + +void light_ctl_work_handler(struct k_work *work); + +void light_ctl_temp_work_handler(struct k_work *work); + +void light_hsl_work_handler(struct k_work *work); + +void light_hsl_hue_work_handler(struct k_work *work); + +void light_hsl_sat_work_handler(struct k_work *work); + +void light_xyl_work_handler(struct k_work *work); + +void light_lc_work_handler(struct k_work *work); + +void scene_recall_work_handler(struct k_work *work); + +void bt_mesh_server_stop_transition(struct bt_mesh_state_transition *transition); + +void bt_mesh_server_start_transition(struct bt_mesh_state_transition *transition); + +#ifdef __cplusplus +} +#endif + +#endif /* _STATE_TRANSITION_H_ */ diff --git a/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/server/include/time_scene_server.h b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/server/include/time_scene_server.h new file mode 100644 index 00000000000..6728e6ff578 --- /dev/null +++ b/tools/sdk/esp32/include/bt/esp_ble_mesh/mesh_models/server/include/time_scene_server.h @@ -0,0 +1,384 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _TIME_SCENE_SERVER_H_ +#define _TIME_SCENE_SERVER_H_ + +#include "server_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * 1. Mesh defines times based on International Atomic Time (TAI). The base + * representation of times is the number of seconds after 00:00:00 TAI + * on 2000-01-01 (that is, 1999-12-31 T23:59:28 UTC). + * 2. UTC: Coordinated Universal Time. For more information, please refer + * to https://time.is/zh/UTC + * 3. For the algorithm used for the transfer between TAI and UTC, please + * refer to Mesh Model Spec Section 5.1.1 + */ + +#define UNKNOWN_TAI_SECONDS 0x0000000000 +#define UNKNOWN_TAI_ZONE_CHANGE 0x0000000000 +#define UNKNOWN_TAI_DELTA_CHANGE 0x0000000000 +#define TAI_UTC_DELTA_MAX_VALUE 0x7FFF +#define TAI_SECONDS_LEN 0x05 +#define TAI_OF_ZONE_CHANGE_LEN 0x05 +#define TAI_OF_DELTA_CHANGE_LEN 0x05 + +#define INVALID_SCENE_NUMBER 0x0000 +#define SCENE_NUMBER_LEN 0x02 + +#define SCHEDULE_YEAR_ANY_YEAR 0x64 + +#define SCHEDULE_DAY_ANY_DAY 0x00 + +#define SCHEDULE_HOUR_ANY_HOUR 0x18 +#define SCHEDULE_HOUR_ONCE_A_DAY 0x19 + +#define SCHEDULE_SEC_ANY_OF_HOUR 0x3C +#define SCHEDULE_SEC_EVERY_15_MIN 0x3D +#define SCHEDULE_SEC_EVERY_20_MIN 0x3E +#define SCHEDULE_SEC_ONCE_AN_HOUR 0x3F + +#define SCHEDULE_SEC_ANY_OF_MIN 0x3C +#define SCHEDULE_SEC_EVERY_15_SEC 0x3D +#define SCHEDULE_SEC_EVERY_20_SEC 0x3E +#define SCHEDULE_SEC_ONCE_AN_MIN 0x3F + +#define SCHEDULE_ACT_TURN_OFF 0x00 +#define SCHEDULE_ACT_TURN_ON 0x01 +#define SCHEDULE_ACT_SCENE_RECALL 0x02 +#define SCHEDULE_ACT_NO_ACTION 0x0F + +#define SCHEDULE_SCENE_NO_SCENE 0x0000 + +#define SCHEDULE_ENTRY_MAX_INDEX 0x0F + +#define TIME_NONE 0x00 +#define TIME_AUTHORITY 0x01 +#define TIME_RELAY 0x02 +#define TIME_CLINET 0x03 + +#define SCENE_SUCCESS 0x00 +#define SCENE_REG_FULL 0x01 +#define SCENE_NOT_FOUND 0x02 + +/** + * The Time state represents the present TAI time, the current TAI-UTC Delta + * and local time zone offset, and the next change to each of the latter + * (e.g., because of a switch from winter to summer time or an announced leap + * second). It consists of 10 fields with a total size of 183 bits. + */ +struct bt_mesh_time_state { + struct { + uint8_t tai_seconds[5]; + uint8_t subsecond; + uint8_t uncertainty; + uint8_t time_zone_offset_curr; + uint8_t time_zone_offset_new; + uint8_t tai_zone_change[5]; + uint16_t time_authority : 1, + tai_utc_delta_curr : 15; + uint16_t tai_utc_delta_new : 15; + uint8_t tai_delta_change[5]; + } time; + uint8_t time_role; +}; + +struct bt_mesh_time_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_time_state *state; +}; + +struct bt_mesh_time_setup_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_time_state *state; +}; + +struct scene_register { + uint16_t scene_number; + uint8_t scene_type; /* Indicate the type of scene value */ + /** + * 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; +}; + +/** + * 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. + */ +struct bt_mesh_scenes_state { + const uint16_t scene_count; + struct scene_register *scenes; + + /** + * 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 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; + + /* Indicate the status code for the last operation */ + uint8_t status_code; + + /* Indicate if scene transition is in progress */ + bool in_progress; +}; + +struct bt_mesh_scene_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_scenes_state *state; + struct bt_mesh_last_msg_info last; + struct bt_mesh_state_transition transition; +}; + +struct bt_mesh_scene_setup_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_scenes_state *state; +}; + +struct schedule_register { + bool in_use; + uint64_t year : 7, + month : 12, + day : 5, + hour : 5, + minute : 6, + second : 6, + day_of_week : 7, + action : 4, + trans_time : 8; + uint16_t scene_number; +}; + +struct bt_mesh_scheduler_state { + const uint8_t schedule_count; + struct schedule_register *schedules; /* Up to 16 scheduled entries */ + + /** + * A recommended implementation of the Scheduler should calculate the + * value of the TAI Seconds of the next scheduled event and put it in + * a queue of scheduled events sorted by time. + * + * Every second, the first event in the queue is compared with the value + * of the Time state. The first event is executed if it is less than or + * equal to the Time state and then removed from the queue. After + * execution, the Repeat Flag shall be checked, and the next occurrence + * of the scheduled event is calculated and put in the queue. + * + * One second timeout value, and compare the first event in queue with the + * Time state. If it is satisfied, then execute the first event. Also the + * Repeat Flag need to be checked, if it is set then the event needs to + * be put into the end of queue. + * + * sys_slist_t event_queue; + * + * For each event_queue item, it can use the following struct: + * struct schedule_event { + * sys_snode_t node; + * uint8_t event_index; + * }; + * + * Also we need a "struct k_delayed_work track_timer" which can be used to + * track the schedule timer and handle proper scheduled events. + */ +}; + +struct bt_mesh_scheduler_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_scheduler_state *state; +}; + +struct bt_mesh_scheduler_setup_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_scheduler_state *state; +}; + +typedef union { + struct { + uint8_t tai_seconds[5]; + uint8_t subsecond; + uint8_t uncertainty; + uint16_t time_authority : 1; + uint16_t tai_utc_delta_curr : 15; + uint8_t time_zone_offset_curr; + } time_set; + struct { + uint8_t tai_seconds[5]; + uint8_t subsecond; + uint8_t uncertainty; + uint16_t time_authority : 1; + uint16_t tai_utc_delta_curr : 15; + uint8_t time_zone_offset_curr; + } time_status; + struct { + uint8_t time_zone_offset_new; + uint8_t tai_zone_change[5]; + } time_zone_set; + struct { + uint16_t tai_utc_delta_new : 15; + uint8_t tai_delta_change[5]; + } tai_utc_delta_set; + struct { + uint8_t role; + } time_role_set; + struct { + uint16_t scene_number; + } scene_store; + struct { + uint16_t scene_number; + } scene_recall; + struct { + uint16_t scene_number; + } scene_delete; + struct { + uint64_t index : 4, + year : 7, + month : 12, + day : 5, + hour : 5, + minute : 6, + second : 6, + day_of_week : 7, + action : 4, + trans_time : 8; + uint16_t scene_number; + } scheduler_act_set; +} bt_mesh_time_scene_server_state_change_t; + +typedef union { + struct { + uint8_t index; + } scheduler_act_get; +} bt_mesh_time_scene_server_recv_get_msg_t; + +typedef union { + struct { + uint8_t tai_seconds[5]; + uint8_t subsecond; + uint8_t uncertainty; + uint16_t time_authority : 1; + uint16_t tai_utc_delta : 15; + uint8_t time_zone_offset; + } time_set; + struct { + uint8_t time_zone_offset_new; + uint8_t tai_zone_change[5]; + } time_zone_set; + struct { + uint16_t tai_utc_delta_new : 15; + uint16_t padding : 1; + uint8_t tai_delta_change[5]; + } tai_utc_delta_set; + struct { + uint8_t time_role; + } time_role_set; + struct { + uint16_t scene_number; + } scene_store; + struct { + bool op_en; + uint16_t scene_number; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; + } scene_recall; + struct { + uint16_t scene_number; + } scene_delete; + struct { + uint64_t index : 4, + year : 7, + month : 12, + day : 5, + hour : 5, + minute : 6, + second : 6, + day_of_week : 7, + action : 4, + trans_time : 8; + uint16_t scene_number; + } scheduler_act_set; +} bt_mesh_time_scene_server_recv_set_msg_t; + +typedef union { + struct { + uint8_t tai_seconds[5]; + uint8_t subsecond; + uint8_t uncertainty; + uint16_t time_authority : 1; + uint16_t tai_utc_delta : 15; + uint8_t time_zone_offset; + } time_status; +} bt_mesh_time_scene_server_recv_status_msg_t; + +void bt_mesh_time_scene_server_lock(void); +void bt_mesh_time_scene_server_unlock(void); + +void scene_publish(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, uint16_t opcode); + +#ifdef __cplusplus +} +#endif + +#endif /* _TIME_SCENE_SERVER_H_ */ diff --git a/tools/sdk/esp32/include/bt/host/bluedroid/api/include/api/esp_bt_defs.h b/tools/sdk/esp32/include/bt/host/bluedroid/api/include/api/esp_bt_defs.h index 1287404ce35..d0e1ec00950 100644 --- a/tools/sdk/esp32/include/bt/host/bluedroid/api/include/api/esp_bt_defs.h +++ b/tools/sdk/esp32/include/bt/host/bluedroid/api/include/api/esp_bt_defs.h @@ -68,6 +68,8 @@ typedef uint8_t esp_link_key[ESP_BT_OCTET16_LEN]; /* Link Key */ /// Default GATT interface id #define ESP_DEFAULT_GATT_IF 0xff +#define ESP_BLE_PRIM_ADV_INT_MIN 0x000020 /*!< Minimum advertising interval for undirected and low duty cycle directed advertising */ +#define ESP_BLE_PRIM_ADV_INT_MAX 0xFFFFFF /*!< Maximum advertising interval for undirected and low duty cycle directed advertising */ #define ESP_BLE_CONN_INT_MIN 0x0006 /*!< relate to BTM_BLE_CONN_INT_MIN in stack/btm_ble_api.h */ #define ESP_BLE_CONN_INT_MAX 0x0C80 /*!< relate to BTM_BLE_CONN_INT_MAX in stack/btm_ble_api.h */ #define ESP_BLE_CONN_LATENCY_MAX 499 /*!< relate to ESP_BLE_CONN_LATENCY_MAX in stack/btm_ble_api.h */ diff --git a/tools/sdk/esp32/include/bt/host/bluedroid/api/include/api/esp_gap_bt_api.h b/tools/sdk/esp32/include/bt/host/bluedroid/api/include/api/esp_gap_bt_api.h index 285cbb028cf..686ad1c63e8 100644 --- a/tools/sdk/esp32/include/bt/host/bluedroid/api/include/api/esp_gap_bt_api.h +++ b/tools/sdk/esp32/include/bt/host/bluedroid/api/include/api/esp_gap_bt_api.h @@ -347,6 +347,7 @@ typedef union { struct read_rmt_name_param { esp_bt_status_t stat; /*!< read Remote Name status */ uint8_t rmt_name[ESP_BT_GAP_MAX_BDNAME_LEN + 1]; /*!< Remote device name */ + esp_bd_addr_t bda; /*!< remote bluetooth device address*/ } read_rmt_name; /*!< read Remote Name parameter struct */ /** diff --git a/tools/sdk/esp32/include/bt/host/bluedroid/api/include/api/esp_gattc_api.h b/tools/sdk/esp32/include/bt/host/bluedroid/api/include/api/esp_gattc_api.h index 40719096345..6c32868156f 100644 --- a/tools/sdk/esp32/include/bt/host/bluedroid/api/include/api/esp_gattc_api.h +++ b/tools/sdk/esp32/include/bt/host/bluedroid/api/include/api/esp_gattc_api.h @@ -220,6 +220,7 @@ typedef union { struct gattc_disconnect_evt_param { esp_gatt_conn_reason_t reason; /*!< disconnection reason */ uint16_t conn_id; /*!< Connection id */ + uint8_t link_role; /*!< Link role : master role = 0 ; slave role = 1*/ esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */ } disconnect; /*!< Gatt client callback param of ESP_GATTC_DISCONNECT_EVT */ /** diff --git a/tools/sdk/esp32/include/bt/host/bluedroid/api/include/api/esp_gatts_api.h b/tools/sdk/esp32/include/bt/host/bluedroid/api/include/api/esp_gatts_api.h index 475ae08c553..558d5d62960 100644 --- a/tools/sdk/esp32/include/bt/host/bluedroid/api/include/api/esp_gatts_api.h +++ b/tools/sdk/esp32/include/bt/host/bluedroid/api/include/api/esp_gatts_api.h @@ -206,6 +206,7 @@ typedef union { */ struct gatts_disconnect_evt_param { uint16_t conn_id; /*!< Connection id */ + uint8_t link_role; /*!< Link role : master role = 0 ; slave role = 1*/ esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */ esp_gatt_conn_reason_t reason; /*!< Indicate the reason of disconnection */ } disconnect; /*!< Gatt server callback param of ESP_GATTS_DISCONNECT_EVT */ diff --git a/tools/sdk/esp32/include/coap/port/include/coap_config_posix.h b/tools/sdk/esp32/include/coap/port/include/coap_config_posix.h index b24335ad156..f96faea7665 100644 --- a/tools/sdk/esp32/include/coap/port/include/coap_config_posix.h +++ b/tools/sdk/esp32/include/coap/port/include/coap_config_posix.h @@ -30,6 +30,8 @@ #define HAVE_NETDB_H #define HAVE_NETINET_IN_H #define HAVE_STRUCT_CMSGHDR +#define HAVE_PTHREAD_H +#define HAVE_PTHREAD_MUTEX_LOCK #define COAP_DISABLE_TCP 0 #define ipi_spec_dst ipi_addr diff --git a/tools/sdk/esp32/include/driver/include/driver/gpio.h b/tools/sdk/esp32/include/driver/include/driver/gpio.h index eeb63f74f8e..77bb2dd78c0 100644 --- a/tools/sdk/esp32/include/driver/include/driver/gpio.h +++ b/tools/sdk/esp32/include/driver/include/driver/gpio.h @@ -97,7 +97,7 @@ esp_err_t gpio_set_intr_type(gpio_num_t gpio_num, gpio_int_type_t intr_type); /** * @brief Enable GPIO module interrupt signal * - * @note Please do not use the interrupt of GPIO36 and GPIO39 when using ADC or Wi-Fi with sleep mode enabled. + * @note Please do not use the interrupt of GPIO36 and GPIO39 when using ADC or Wi-Fi and Bluetooth with sleep mode enabled. * Please refer to the comments of `adc1_get_raw`. * Please refer to section 3.11 of 'ECO_and_Workarounds_for_Bugs_in_ESP32' for the description of this issue. * As a workaround, call adc_power_acquire() in the app. This will result in higher power consumption (by ~1mA), @@ -498,7 +498,8 @@ esp_err_t gpio_sleep_set_pull_mode(gpio_num_t gpio_num, gpio_pull_mode_t pull); #if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP -#define GPIO_IS_DEEP_SLEEP_WAKEUP_VALID_GPIO(gpio_num) ((gpio_num & ~SOC_GPIO_DEEP_SLEEP_WAKEUP_VALID_GPIO_MASK) == 0) +#define GPIO_IS_DEEP_SLEEP_WAKEUP_VALID_GPIO(gpio_num) ((gpio_num >= 0) && \ + (((1ULL << (gpio_num)) & SOC_GPIO_DEEP_SLEEP_WAKEUP_VALID_GPIO_MASK) != 0)) /** * @brief Enable GPIO deep-sleep wake-up function. diff --git a/tools/sdk/esp32/include/driver/include/driver/i2c.h b/tools/sdk/esp32/include/driver/include/driver/i2c.h index 22dcc8ab241..57d9091e70a 100644 --- a/tools/sdk/esp32/include/driver/include/driver/i2c.h +++ b/tools/sdk/esp32/include/driver/include/driver/i2c.h @@ -429,8 +429,7 @@ esp_err_t i2c_master_stop(i2c_cmd_handle_t cmd_handle); /** * @brief Send all the queued commands on the I2C bus, in master mode. * The task will be blocked until all the commands have been sent out. - * The I2C APIs are not thread-safe, if you want to use one I2C port in different tasks, - * you need to take care of the multi-thread issue. + * The I2C port is protected by mutex, so this function is thread-safe. * This function shall only be called in I2C master mode. * * @param i2c_num I2C port number diff --git a/tools/sdk/esp32/include/driver/include/driver/sdspi_host.h b/tools/sdk/esp32/include/driver/include/driver/sdspi_host.h index abb690c39bc..a5d942e9d86 100644 --- a/tools/sdk/esp32/include/driver/include/driver/sdspi_host.h +++ b/tools/sdk/esp32/include/driver/include/driver/sdspi_host.h @@ -22,8 +22,10 @@ typedef int sdspi_dev_handle_t; #if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2 #define SDSPI_DEFAULT_HOST HSPI_HOST +#define SDSPI_DEFAULT_DMA SDSPI_DEFAULT_HOST #else #define SDSPI_DEFAULT_HOST SPI2_HOST +#define SDSPI_DEFAULT_DMA SPI_DMA_CH_AUTO #endif /** @@ -216,7 +218,7 @@ typedef struct { .gpio_miso = GPIO_NUM_2, \ .gpio_mosi = GPIO_NUM_15, \ .gpio_sck = GPIO_NUM_14, \ - .dma_channel = 1, \ + .dma_channel = SDSPI_DEFAULT_DMA, \ } /** diff --git a/tools/sdk/esp32/include/driver/include/driver/spi_common.h b/tools/sdk/esp32/include/driver/include/driver/spi_common.h index 830b8efd8c2..424e9c0588f 100644 --- a/tools/sdk/esp32/include/driver/include/driver/spi_common.h +++ b/tools/sdk/esp32/include/driver/include/driver/spi_common.h @@ -163,7 +163,7 @@ esp_err_t spi_bus_initialize(spi_host_device_t host_id, const spi_bus_config_t * * @param host_id SPI peripheral to free * @return * - ESP_ERR_INVALID_ARG if parameter is invalid - * - ESP_ERR_INVALID_STATE if not all devices on the bus are freed + * - ESP_ERR_INVALID_STATE if bus hasn't been initialized before, or not all devices on the bus are freed * - ESP_OK on success */ esp_err_t spi_bus_free(spi_host_device_t host_id); diff --git a/tools/sdk/esp32/include/driver/include/esp_private/gdma.h b/tools/sdk/esp32/include/driver/include/esp_private/gdma.h index 88a45b56cfe..f888cd5bc9b 100644 --- a/tools/sdk/esp32/include/driver/include/esp_private/gdma.h +++ b/tools/sdk/esp32/include/driver/include/esp_private/gdma.h @@ -269,6 +269,9 @@ esp_err_t gdma_register_rx_event_callbacks(gdma_channel_handle_t dma_chan, gdma_ /** * @brief Set DMA descriptor address and start engine * + * @note This function is allowed to run within ISR context + * @note This function is also allowed to run when Cache is disabled, if `CONFIG_GDMA_CTRL_FUNC_IN_IRAM` is enabled + * * @param[in] dma_chan GDMA channel handle, allocated by `gdma_new_channel` * @param[in] desc_base_addr Base address of descriptors (usually the descriptors are chained into a link or ring) * @return @@ -281,6 +284,9 @@ esp_err_t gdma_start(gdma_channel_handle_t dma_chan, intptr_t desc_base_addr); /** * @brief Stop DMA engine * + * @note This function is allowed to run within ISR context + * @note This function is also allowed to run when Cache is disabled, if `CONFIG_GDMA_CTRL_FUNC_IN_IRAM` is enabled + * * @param[in] dma_chan GDMA channel handle, allocated by `gdma_new_channel` * @return * - ESP_OK: Stop DMA engine successfully @@ -291,6 +297,9 @@ esp_err_t gdma_stop(gdma_channel_handle_t dma_chan); /** * @brief Make the appended descriptors be aware to the DMA engine + * + * @note This function is allowed to run within ISR context + * @note This function is also allowed to run when Cache is disabled, if `CONFIG_GDMA_CTRL_FUNC_IN_IRAM` is enabled * @note This API could also resume a paused DMA engine, make sure new descriptors have been appended to the descriptor chain before calling it. * * @param[in] dma_chan GDMA channel handle, allocated by `gdma_new_channel` @@ -303,6 +312,9 @@ esp_err_t gdma_append(gdma_channel_handle_t dma_chan); /** * @brief Reset DMA channel FIFO and internal finite state machine + * + * @note This function is allowed to run within ISR context + * @note This function is also allowed to run when Cache is disabled, if `CONFIG_GDMA_CTRL_FUNC_IN_IRAM` is enabled * @note Resetting a DMA channel won't break the connection with the target peripheral * * @param[in] dma_chan GDMA channel handle, allocated by `gdma_new_channel` diff --git a/tools/sdk/esp32/include/esp-tls/esp_tls.h b/tools/sdk/esp32/include/esp-tls/esp_tls.h index 588f70d83f9..5b5b3628023 100644 --- a/tools/sdk/esp32/include/esp-tls/esp_tls.h +++ b/tools/sdk/esp32/include/esp-tls/esp_tls.h @@ -688,6 +688,16 @@ esp_err_t esp_tls_plain_tcp_connect(const char *host, int hostlen, int port, con * NULL on Failure */ esp_tls_client_session_t *esp_tls_get_client_session(esp_tls_t *tls); + +/** + * @brief Free the client session + * + * This function should be called after esp_tls_get_client_session(). + * + * @param[in] client_session context as esp_tls_client_session_t + * + */ +void esp_tls_free_client_session(esp_tls_client_session_t *client_session); #endif /* CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS */ #ifdef __cplusplus } diff --git a/tools/sdk/esp32/include/esp-tls/private_include/esp_tls_mbedtls.h b/tools/sdk/esp32/include/esp-tls/private_include/esp_tls_mbedtls.h index c1c5d4f3288..43dce58ad6e 100644 --- a/tools/sdk/esp32/include/esp-tls/private_include/esp_tls_mbedtls.h +++ b/tools/sdk/esp32/include/esp-tls/private_include/esp_tls_mbedtls.h @@ -104,6 +104,11 @@ esp_err_t set_client_config(const char *hostname, size_t hostlen, esp_tls_cfg_t * Internal Callback for mbedtls_get_client_session */ esp_tls_client_session_t *esp_mbedtls_get_client_session(esp_tls_t *tls); + +/** + * Internal Callback for mbedtls_free_client_session + */ +void esp_mbedtls_free_client_session(esp_tls_client_session_t *client_session); #endif /** diff --git a/tools/sdk/esp32/include/esp32-camera/driver/include/sensor.h b/tools/sdk/esp32/include/esp32-camera/driver/include/sensor.h index 26afeec3fd5..e4a1cceba57 100755 --- a/tools/sdk/esp32/include/esp32-camera/driver/include/sensor.h +++ b/tools/sdk/esp32/include/esp32-camera/driver/include/sensor.h @@ -28,6 +28,7 @@ typedef enum { GC0308_PID = 0x9b, BF3005_PID = 0x30, BF20A6_PID = 0x20a6, + SC030IOT_PID = 0x9a46, } camera_pid_t; typedef enum { @@ -42,6 +43,7 @@ typedef enum { CAMERA_GC0308, CAMERA_BF3005, CAMERA_BF20A6, + CAMERA_SC030IOT, CAMERA_MODEL_MAX, CAMERA_NONE, } camera_model_t; @@ -58,6 +60,7 @@ typedef enum { GC0308_SCCB_ADDR = 0x21,// 0x42 >> 1 BF3005_SCCB_ADDR = 0x6E, BF20A6_SCCB_ADDR = 0x6E, + SC030IOT_SCCB_ADDR = 0x68,// 0xd0 >> 1 } camera_sccb_addr_t; typedef enum { diff --git a/tools/sdk/esp32/include/esp_http_client/include/esp_http_client.h b/tools/sdk/esp32/include/esp_http_client/include/esp_http_client.h index d1b530a42e3..6ba8ed6e582 100644 --- a/tools/sdk/esp32/include/esp_http_client/include/esp_http_client.h +++ b/tools/sdk/esp32/include/esp_http_client/include/esp_http_client.h @@ -149,7 +149,9 @@ typedef enum { HttpStatus_MultipleChoices = 300, HttpStatus_MovedPermanently = 301, HttpStatus_Found = 302, + HttpStatus_SeeOther = 303, HttpStatus_TemporaryRedirect = 307, + HttpStatus_PermanentRedirect = 308, /* 4xx - Client Error */ HttpStatus_BadRequest = 400, diff --git a/tools/sdk/esp32/include/esp_https_server/include/esp_https_server.h b/tools/sdk/esp32/include/esp_https_server/include/esp_https_server.h new file mode 100644 index 00000000000..efe726e9e70 --- /dev/null +++ b/tools/sdk/esp32/include/esp_https_server/include/esp_https_server.h @@ -0,0 +1,160 @@ +/* + * SPDX-FileCopyrightText: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _ESP_HTTPS_SERVER_H_ +#define _ESP_HTTPS_SERVER_H_ + +#include +#include "esp_err.h" +#include "esp_http_server.h" +#include "esp_tls.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + HTTPD_SSL_TRANSPORT_SECURE, // SSL Enabled + HTTPD_SSL_TRANSPORT_INSECURE // SSL disabled +} httpd_ssl_transport_mode_t; + +/** + * @brief Callback data struct, contains the ESP-TLS connection handle + */ +typedef struct esp_https_server_user_cb_arg { + const esp_tls_t *tls; +} esp_https_server_user_cb_arg_t; + +/** + * @brief Callback function prototype + * Can be used to get connection or client information (SSL context) + * E.g. Client certificate, Socket FD, Connection state, etc. + * + * @param user_cb Callback data struct + */ +typedef void esp_https_server_user_cb(esp_https_server_user_cb_arg_t *user_cb); + +/** + * HTTPS server config struct + * + * Please use HTTPD_SSL_CONFIG_DEFAULT() to initialize it. + */ +struct httpd_ssl_config { + /** + * Underlying HTTPD server config + * + * Parameters like task stack size and priority can be adjusted here. + */ + httpd_config_t httpd; + + /** CA certificate (here it is treated as server cert) + * Todo: Fix this change in release/v5.0 as it would be a breaking change + * i.e. Rename the nomenclature of variables holding different certs in https_server component as well as example + * 1)The cacert variable should hold the CA which is used to authenticate clients (should inherit current role of client_verify_cert_pem var) + * 2)There should be another variable servercert which whould hold servers own certificate (should inherit current role of cacert var) */ + const uint8_t *cacert_pem; + + /** CA certificate byte length */ + size_t cacert_len; + + /** Client verify authority certificate (CA used to sign clients, or client cert itself */ + const uint8_t *client_verify_cert_pem; + + /** Client verify authority cert len */ + size_t client_verify_cert_len; + + /** Private key */ + const uint8_t *prvtkey_pem; + + /** Private key byte length */ + size_t prvtkey_len; + + /** Transport Mode (default secure) */ + httpd_ssl_transport_mode_t transport_mode; + + /** Port used when transport mode is secure (default 443) */ + uint16_t port_secure; + + /** Port used when transport mode is insecure (default 80) */ + uint16_t port_insecure; + + /** Enable tls session tickets */ + bool session_tickets; + + /** User callback for esp_https_server */ + esp_https_server_user_cb *user_cb; +}; + +typedef struct httpd_ssl_config httpd_ssl_config_t; + +/** + * Default config struct init + * + * (http_server default config had to be copied for customization) + * + * Notes: + * - port is set when starting the server, according to 'transport_mode' + * - one socket uses ~ 40kB RAM with SSL, we reduce the default socket count to 4 + * - SSL sockets are usually long-lived, closing LRU prevents pool exhaustion DOS + * - Stack size may need adjustments depending on the user application + */ +#define HTTPD_SSL_CONFIG_DEFAULT() { \ + .httpd = { \ + .task_priority = tskIDLE_PRIORITY+5, \ + .stack_size = 10240, \ + .core_id = tskNO_AFFINITY, \ + .server_port = 0, \ + .ctrl_port = 32768, \ + .max_open_sockets = 4, \ + .max_uri_handlers = 8, \ + .max_resp_headers = 8, \ + .backlog_conn = 5, \ + .lru_purge_enable = true, \ + .recv_wait_timeout = 5, \ + .send_wait_timeout = 5, \ + .global_user_ctx = NULL, \ + .global_user_ctx_free_fn = NULL, \ + .global_transport_ctx = NULL, \ + .global_transport_ctx_free_fn = NULL, \ + .open_fn = NULL, \ + .close_fn = NULL, \ + .uri_match_fn = NULL \ + }, \ + .cacert_pem = NULL, \ + .cacert_len = 0, \ + .client_verify_cert_pem = NULL, \ + .client_verify_cert_len = 0, \ + .prvtkey_pem = NULL, \ + .prvtkey_len = 0, \ + .transport_mode = HTTPD_SSL_TRANSPORT_SECURE, \ + .port_secure = 443, \ + .port_insecure = 80, \ + .session_tickets = false, \ + .user_cb = NULL, \ +} + +/** + * Create a SSL capable HTTP server (secure mode may be disabled in config) + * + * @param[in,out] config - server config, must not be const. Does not have to stay valid after + * calling this function. + * @param[out] handle - storage for the server handle, must be a valid pointer + * @return success + */ +esp_err_t httpd_ssl_start(httpd_handle_t *handle, httpd_ssl_config_t *config); + +/** + * Stop the server. Blocks until the server is shut down. + * + * @param[in] handle + */ +void httpd_ssl_stop(httpd_handle_t handle); + +#ifdef __cplusplus +} +#endif + +#endif // _ESP_HTTPS_SERVER_H_ diff --git a/tools/sdk/esp32/include/esp_hw_support/include/soc/spinlock.h b/tools/sdk/esp32/include/esp_hw_support/include/soc/spinlock.h index fbeff5054b4..b2fadfe49e3 100644 --- a/tools/sdk/esp32/include/esp_hw_support/include/soc/spinlock.h +++ b/tools/sdk/esp32/include/esp_hw_support/include/soc/spinlock.h @@ -95,13 +95,13 @@ static inline bool __attribute__((always_inline)) spinlock_acquire(spinlock_t *l */ result = core_id; -#if defined(CONFIG_ESP32_SPIRAM_SUPPORT) +#if (CONFIG_ESP32_SPIRAM_SUPPORT || CONFIG_ESP32S3_SPIRAM_SUPPORT) if (esp_ptr_external_ram(lock)) { compare_and_set_extram(&lock->owner, SPINLOCK_FREE, &result); } else { #endif compare_and_set_native(&lock->owner, SPINLOCK_FREE, &result); -#if defined(CONFIG_ESP32_SPIRAM_SUPPORT) +#if (CONFIG_ESP32_SPIRAM_SUPPORT || CONFIG_ESP32S3_SPIRAM_SUPPORT) } #endif if(result != other_core_id) { diff --git a/tools/sdk/esp32/include/esp_lcd/include/esp_lcd_panel_io.h b/tools/sdk/esp32/include/esp_lcd/include/esp_lcd_panel_io.h index 330f4d9a165..7b99bde3f17 100644 --- a/tools/sdk/esp32/include/esp_lcd/include/esp_lcd_panel_io.h +++ b/tools/sdk/esp32/include/esp_lcd/include/esp_lcd_panel_io.h @@ -19,6 +19,25 @@ typedef void *esp_lcd_spi_bus_handle_t; /*!< Type of LCD S typedef void *esp_lcd_i2c_bus_handle_t; /*!< Type of LCD I2C bus handle */ typedef struct esp_lcd_i80_bus_t *esp_lcd_i80_bus_handle_t; /*!< Type of LCD intel 8080 bus handle */ +/** + * @brief Transmit LCD command and receive corresponding parameters + * + * @note Commands sent by this function are short, so they are sent using polling transactions. + * The function does not return before the command tranfer is completed. + * If any queued transactions sent by `esp_lcd_panel_io_tx_color()` are still pending when this function is called, + * this function will wait until they are finished and the queue is empty before sending the command(s). + * + * @param[in] io LCD panel IO handle, which is created by other factory API like `esp_lcd_new_panel_io_spi()` + * @param[in] lcd_cmd The specific LCD command, set to -1 if no command needed + * @param[out] param Buffer for the command data + * @param[in] param_size Size of `param` buffer + * @return + * - ESP_ERR_INVALID_ARG if parameter is invalid + * - ESP_ERR_NOT_SUPPORTED if read is not supported by transport + * - ESP_OK on success + */ +esp_err_t esp_lcd_panel_io_rx_param(esp_lcd_panel_io_handle_t io, int lcd_cmd, void *param, size_t param_size); + /** * @brief Transmit LCD command and corresponding parameters * @@ -98,7 +117,8 @@ typedef struct { unsigned int dc_as_cmd_phase: 1; /*!< D/C line value is encoded into SPI transaction command phase */ unsigned int dc_low_on_data: 1; /*!< If this flag is enabled, DC line = 0 means transfer data, DC line = 1 means transfer command; vice versa */ unsigned int octal_mode: 1; /*!< transmit with octal mode (8 data lines), this mode is used to simulate Intel 8080 timing */ - } flags; + unsigned int lsb_first: 1; /*!< transmit LSB bit first */ + } flags; /*!< Extra flags to fine-tune the SPI device */ } esp_lcd_panel_io_spi_config_t; /** @@ -124,6 +144,7 @@ typedef struct { int lcd_param_bits; /*!< Bit-width of LCD parameter */ struct { unsigned int dc_low_on_data: 1; /*!< If this flag is enabled, DC line = 0 means transfer data, DC line = 1 means transfer command; vice versa */ + unsigned int disable_control_phase: 1; /*!< If this flag is enabled, the control phase isn't used */ } flags; } esp_lcd_panel_io_i2c_config_t; @@ -151,6 +172,8 @@ typedef struct { int data_gpio_nums[SOC_LCD_I80_BUS_WIDTH]; /*!< GPIOs used for data lines */ size_t bus_width; /*!< Number of data lines, 8 or 16 */ size_t max_transfer_bytes; /*!< Maximum transfer size, this determines the length of internal DMA link */ + size_t psram_trans_align; /*!< DMA transfer alignment for data allocated from PSRAM */ + size_t sram_trans_align; /*!< DMA transfer alignment for data allocated from SRAM */ } esp_lcd_i80_bus_config_t; /** diff --git a/tools/sdk/esp32/include/esp_lcd/include/esp_lcd_panel_rgb.h b/tools/sdk/esp32/include/esp_lcd/include/esp_lcd_panel_rgb.h index 6f06deb8165..95dfb6ba4fc 100644 --- a/tools/sdk/esp32/include/esp_lcd/include/esp_lcd_panel_rgb.h +++ b/tools/sdk/esp32/include/esp_lcd/include/esp_lcd_panel_rgb.h @@ -59,7 +59,7 @@ typedef struct { unsigned int hsync_front_porch; /*!< Horizontal front porch, number of PCLK between the end of active data and the next hsync */ unsigned int vsync_pulse_width; /*!< Vertical sync width, unit: number of lines */ unsigned int vsync_back_porch; /*!< Vertical back porch, number of invalid lines between vsync and start of frame */ - unsigned int vsync_front_porch; /*!< Vertical front porch, number of invalid lines between then end of frame and the next vsync */ + unsigned int vsync_front_porch; /*!< Vertical front porch, number of invalid lines between the end of frame and the next vsync */ struct { unsigned int hsync_idle_low: 1; /*!< The hsync signal is low in IDLE state */ unsigned int vsync_idle_low: 1; /*!< The vsync signal is low in IDLE state */ diff --git a/tools/sdk/esp32/include/esp_lcd/interface/esp_lcd_panel_io_interface.h b/tools/sdk/esp32/include/esp_lcd/interface/esp_lcd_panel_io_interface.h index 2faa6fab268..9f2226587e5 100644 --- a/tools/sdk/esp32/include/esp_lcd/interface/esp_lcd_panel_io_interface.h +++ b/tools/sdk/esp32/include/esp_lcd/interface/esp_lcd_panel_io_interface.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -18,6 +18,22 @@ typedef struct esp_lcd_panel_io_t esp_lcd_panel_io_t; /*!< Type of LCD panel IO * @brief LCD panel IO interface */ struct esp_lcd_panel_io_t { + /** + * @brief Transmit LCD command and receive corresponding parameters + * + * @note This is the panel-specific interface called by function `esp_lcd_panel_io_rx_param()`. + * + * @param[in] io LCD panel IO handle, which is created by other factory API like `esp_lcd_new_panel_io_spi()` + * @param[in] lcd_cmd The specific LCD command, set to -1 if no command needed + * @param[out] param Buffer for the command data + * @param[in] param_size Size of `param` buffer + * @return + * - ESP_ERR_INVALID_ARG if parameter is invalid + * - ESP_ERR_NOT_SUPPORTED if read is not supported by transport + * - ESP_OK on success + */ + esp_err_t (*rx_param)(esp_lcd_panel_io_t *io, int lcd_cmd, void *param, size_t param_size); + /** * @brief Transmit LCD command and corresponding parameters * diff --git a/tools/sdk/esp32/include/esp_phy/include/esp_phy_init.h b/tools/sdk/esp32/include/esp_phy/include/esp_phy_init.h index 04068c7f38d..ec682139506 100644 --- a/tools/sdk/esp32/include/esp_phy/include/esp_phy_init.h +++ b/tools/sdk/esp32/include/esp_phy/include/esp_phy_init.h @@ -170,12 +170,27 @@ void esp_phy_disable(void); */ void esp_phy_load_cal_and_init(void); +/** + * @brief Initialize backup memory for Phy power up/down + */ +void esp_phy_pd_mem_init(void); + +/** + * @brief Deinitialize backup memory for Phy power up/down + */ +void esp_phy_pd_mem_deinit(void); + #if CONFIG_MAC_BB_PD /** * @brief Initialize backup memory for MAC and Baseband power up/down */ void esp_mac_bb_pd_mem_init(void); +/** + * @brief Deinitialize backup memory for MAC and Baseband power up/down + */ +void esp_mac_bb_pd_mem_deinit(void); + /** * @brief Power up MAC and Baseband */ diff --git a/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_core.h b/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_core.h index 9dbdbae658b..eb01e6d8e3d 100644 --- a/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_core.h +++ b/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_core.h @@ -63,6 +63,8 @@ typedef struct { char *fw_version; /** Model (Optional). If not set, PROJECT_NAME is used as default (recommended)*/ char *model; + /** Subtype (Optional). */ + char *subtype; } esp_rmaker_node_info_t; /** ESP RainMaker Configuration */ @@ -430,10 +432,11 @@ esp_err_t esp_rmaker_node_add_attribute(const esp_rmaker_node_t *node, const cha */ esp_err_t esp_rmaker_node_add_fw_version(const esp_rmaker_node_t *node, const char *fw_version); -/** Add model for a node (Not recommended) +/** Add model for a node * * Model is set internally to the project name. This API can be used to - * override that name. + * override that name, now that a new field "project" has also been added + * internally to the node info. * * @param node Node handle. * @param[in] model New model string. @@ -443,6 +446,16 @@ esp_err_t esp_rmaker_node_add_fw_version(const esp_rmaker_node_t *node, const ch */ esp_err_t esp_rmaker_node_add_model(const esp_rmaker_node_t *node, const char *model); +/** Add subtype for a node + * + * @param node Node handle. + * @param[in] subtype Subtype string. + * + * @return ESP_OK on success. + * @return error in case of failure. + */ +esp_err_t esp_rmaker_node_add_subtype(const esp_rmaker_node_t *node, const char *subtype); + /** * Create a Device * @@ -572,6 +585,18 @@ esp_err_t esp_rmaker_device_add_attribute(const esp_rmaker_device_t *device, con */ esp_err_t esp_rmaker_device_add_subtype(const esp_rmaker_device_t *device, const char *subtype); +/** Add a Device model + * + * This would primarily be used by the phone apps to render different icons for the same device type. + * + * @param[in] device Device handle. + * @param[in] model String describing the model. + * + * @return ESP_OK if the model was added successfully. + * @return error in case of failure. + */ +esp_err_t esp_rmaker_device_add_model(const esp_rmaker_device_t *device, const char *model); + /** Get device name from handle * * @param[in] device Device handle. @@ -892,6 +917,20 @@ esp_err_t esp_rmaker_system_service_enable(esp_rmaker_system_serv_config_t *conf */ bool esp_rmaker_local_ctrl_service_started(void); +/** + * Enable Default RainMaker OTA Firmware Upgrade + * + * This enables the default recommended RainMaker OTA Firmware Upgrade, which is + * "Using the Topics", which allows performing OTA from Dashboard. + * This OTA can be triggered by Admin Users only. + * On Public RainMaker deployment, for nodes using "Self Claiming", since there + * is no associated admin user, the Primary user will automatically become the admin + * and can perform OTA from dashboard. + * + * @return ESP_OK on success + * @return error on failure + */ +esp_err_t esp_rmaker_ota_enable_default(void); #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_ota.h b/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_ota.h index e66b95705bc..6dc7962177e 100644 --- a/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_ota.h +++ b/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_ota.h @@ -34,6 +34,8 @@ typedef enum { OTA_STATUS_FAILED, /** OTA was delayed by the application */ OTA_STATUS_DELAYED, + /** OTA rejected due to some reason (wrong project, version, etc.) */ + OTA_STATUS_REJECTED, } ota_status_t; /** OTA Workflow type */ @@ -145,6 +147,29 @@ esp_err_t esp_rmaker_ota_enable(esp_rmaker_ota_config_t *ota_config, esp_rmaker_ */ esp_err_t esp_rmaker_ota_report_status(esp_rmaker_ota_handle_t ota_handle, ota_status_t status, char *additional_info); +/** Default OTA callback + * + * This is the default OTA callback which will get used if you do not pass your own callback. You can call this + * even from your callback, in case you want better control on when the OTA can proceed and yet let the actual + * OTA process be managed by the RainMaker Core. + * + * @param[in] handle An OTA handle assigned by the ESP RainMaker Core + * @param[in] ota_data The data to be used for the OTA + * + * @return ESP_OK if the OTA was successful + * @return ESP_FAIL if the OTA failed. + * */ +esp_err_t esp_rmaker_ota_default_cb(esp_rmaker_ota_handle_t handle, esp_rmaker_ota_data_t *ota_data); + +/** Fetch OTA Info + * + * For OTA using Topics, this API can be used to explicitly ask the backend if an OTA is available. + * If it is, then the OTA callback would get invoked. + * + * @return ESP_OK if the OTA fetch publish message was successful. + * @return error on failure + */ +esp_err_t esp_rmaker_ota_fetch(void); #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_standard_types.h b/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_standard_types.h index 4dc99eab401..9f74fcaea7c 100644 --- a/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_standard_types.h +++ b/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_standard_types.h @@ -25,6 +25,10 @@ extern "C" #define ESP_RMAKER_UI_DROPDOWN "esp.ui.dropdown" #define ESP_RMAKER_UI_TEXT "esp.ui.text" #define ESP_RMAKER_UI_HUE_SLIDER "esp.ui.hue-slider" +#define ESP_RMAKER_UI_HUE_CIRCLE "esp.ui.hue-circle" +#define ESP_RMAKER_UI_PUSHBUTTON "esp.ui.push-btn-big" +#define ESP_RMAKER_UI_TRIGGER "esp.ui.trigger" +#define ESP_RMAKER_UI_HIDDEN "esp.ui.hidden" /********** STANDARD PARAM TYPES **********/ @@ -50,6 +54,13 @@ extern "C" #define ESP_RMAKER_PARAM_WIFI_RESET "esp.param.wifi-reset" #define ESP_RMAKER_PARAM_LOCAL_CONTROL_POP "esp.param.local_control_pop" #define ESP_RMAKER_PARAM_LOCAL_CONTROL_TYPE "esp.param.local_control_type" +#define ESP_RMAKER_PARAM_TOGGLE "esp.param.toggle" +#define ESP_RMAKER_PARAM_RANGE "esp.param.range" +#define ESP_RMAKER_PARAM_MODE "esp.param.mode" +#define ESP_RMAKER_PARAM_BLINDS_POSITION "esp.param.blinds-position" +#define ESP_RMAKER_PARAM_GARAGE_POSITION "esp.param.garage-position" +#define ESP_RMAKER_PARAM_LIGHT_MODE "esp.param.light-mode" +#define ESP_RMAKER_PARAM_AC_MODE "esp.param.ac-mode" /********** STANDARD DEVICE TYPES **********/ @@ -58,7 +69,21 @@ extern "C" #define ESP_RMAKER_DEVICE_LIGHTBULB "esp.device.lightbulb" #define ESP_RMAKER_DEVICE_FAN "esp.device.fan" #define ESP_RMAKER_DEVICE_TEMP_SENSOR "esp.device.temperature-sensor" - +#define ESP_RMAKER_DEVICE_LIGHT "esp.device.light" +#define ESP_RMAKER_DEVICE_OUTLET "esp.device.outlet" +#define ESP_RMAKER_DEVICE_PLUG "esp.device.plug" +#define ESP_RMAKER_DEVICE_SOCKET "esp.device.socket" +#define ESP_RMAKER_DEVICE_LOCK "esp.device.lock" +#define ESP_RMAKER_DEVICE_BLINDS_INTERNAL "esp.device.blinds-internal" +#define ESP_RMAKER_DEVICE_BLINDS_EXTERNAL "esp.device.blinds-external" +#define ESP_RMAKER_DEVICE_GARAGE_DOOR "esp.device.garage-door" +#define ESP_RMAKER_DEVICE_GARAGE_LOCK "esp.device.garage-door-lock" +#define ESP_RMAKER_DEVICE_SPEAKER "esp.device.speaker" +#define ESP_RMAKER_DEVICE_AIR_CONDITIONER "esp.device.air-conditioner" +#define ESP_RMAKER_DEVICE_THERMOSTAT "esp.device.thermostat" +#define ESP_RMAKER_DEVICE_TV "esp.device.tv" +#define ESP_RMAKER_DEVICE_WASHER "esp.device.washer" +#define ESP_RMAKER_DEVICE_OTHER "esp.device.other" /********** STANDARD SERVICE TYPES **********/ #define ESP_RMAKER_SERVICE_OTA "esp.service.ota" diff --git a/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_user_mapping.h b/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_user_mapping.h index 77a153b02f2..734cdd6da2a 100644 --- a/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_user_mapping.h +++ b/tools/sdk/esp32/include/esp_rainmaker/include/esp_rmaker_user_mapping.h @@ -25,6 +25,8 @@ typedef enum { ESP_RMAKER_USER_MAPPING_RESET = 0, /** Mapping has started */ ESP_RMAKER_USER_MAPPING_STARTED, + /** Mapping request sent to cloud */ + ESP_RMAKER_USER_MAPPING_REQ_SENT, /** Mapping is done */ ESP_RMAKER_USER_MAPPING_DONE, } esp_rmaker_user_mapping_state_t; diff --git a/tools/sdk/esp32/include/esp_rom/include/esp32c3/rom/efuse.h b/tools/sdk/esp32/include/esp_rom/include/esp32c3/rom/efuse.h index 9da1525f969..d1412c46110 100644 --- a/tools/sdk/esp32/include/esp_rom/include/esp32c3/rom/efuse.h +++ b/tools/sdk/esp32/include/esp_rom/include/esp32c3/rom/efuse.h @@ -1,16 +1,8 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ROM_EFUSE_H_ #define _ROM_EFUSE_H_ @@ -236,13 +228,13 @@ bool ets_efuse_legacy_spi_boot_mode_disabled(void); uint32_t ets_efuse_get_uart_print_control(void); /** - * @brief Read which channel will used by ROM to print + * @brief Read if USB-Serial-JTAG print during rom boot is disabled from Efuse * * @return - * - 0 for UART0. - * - 1 for UART1. + * - 1 for efuse disable USB-Serial-JTAG print during rom boot. + * - 0 for efuse doesn't disable USB-Serial-JTAG print during rom boot. */ -uint32_t ets_efuse_get_uart_print_channel(void); +uint32_t ets_efuse_usb_serial_jtag_print_is_disabled(void); /** * @brief Read if usb download mode disabled from Efuse diff --git a/tools/sdk/esp32/include/esp_rom/include/esp32h2/rom/efuse.h b/tools/sdk/esp32/include/esp_rom/include/esp32h2/rom/efuse.h index 9da1525f969..d1412c46110 100644 --- a/tools/sdk/esp32/include/esp_rom/include/esp32h2/rom/efuse.h +++ b/tools/sdk/esp32/include/esp_rom/include/esp32h2/rom/efuse.h @@ -1,16 +1,8 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ROM_EFUSE_H_ #define _ROM_EFUSE_H_ @@ -236,13 +228,13 @@ bool ets_efuse_legacy_spi_boot_mode_disabled(void); uint32_t ets_efuse_get_uart_print_control(void); /** - * @brief Read which channel will used by ROM to print + * @brief Read if USB-Serial-JTAG print during rom boot is disabled from Efuse * * @return - * - 0 for UART0. - * - 1 for UART1. + * - 1 for efuse disable USB-Serial-JTAG print during rom boot. + * - 0 for efuse doesn't disable USB-Serial-JTAG print during rom boot. */ -uint32_t ets_efuse_get_uart_print_channel(void); +uint32_t ets_efuse_usb_serial_jtag_print_is_disabled(void); /** * @brief Read if usb download mode disabled from Efuse diff --git a/tools/sdk/esp32/include/esp_rom/include/esp32s3/rom/efuse.h b/tools/sdk/esp32/include/esp_rom/include/esp32s3/rom/efuse.h index cbe38e6a55e..3d347f48330 100644 --- a/tools/sdk/esp32/include/esp_rom/include/esp32s3/rom/efuse.h +++ b/tools/sdk/esp32/include/esp_rom/include/esp32s3/rom/efuse.h @@ -1,16 +1,8 @@ -// Copyright 2015-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. +/* + * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once @@ -237,13 +229,13 @@ bool ets_efuse_legacy_spi_boot_mode_disabled(void); uint32_t ets_efuse_get_uart_print_control(void); /** - * @brief Read which channel will used by ROM to print + * @brief Read if USB-Serial-JTAG print during rom boot is disabled from Efuse * * @return - * - 0 for UART0. - * - 1 for UART1. + * - 1 for efuse disable USB-Serial-JTAG print during rom boot. + * - 0 for efuse doesn't disable USB-Serial-JTAG print during rom boot. */ -uint32_t ets_efuse_get_uart_print_channel(void); +uint32_t ets_efuse_usb_serial_jtag_print_is_disabled(void); /** * @brief Read if usb download mode disabled from Efuse diff --git a/tools/sdk/esp32/include/esp_wifi/include/esp_wifi.h b/tools/sdk/esp32/include/esp_wifi/include/esp_wifi.h index bcd10c77a10..3d62c5c297c 100644 --- a/tools/sdk/esp32/include/esp_wifi/include/esp_wifi.h +++ b/tools/sdk/esp32/include/esp_wifi/include/esp_wifi.h @@ -1295,6 +1295,19 @@ esp_err_t esp_wifi_get_country_code(char *country); */ esp_err_t esp_wifi_config_80211_tx_rate(wifi_interface_t ifx, wifi_phy_rate_t rate); +/** + * @brief Disable PMF configuration for specified interface + * + * @attention This API should be called after esp_wifi_set_config() and before esp_wifi_start(). + * + * @param ifx Interface to be configured. + * + * @return + * - ESP_OK: succeed + * - others: failed + */ +esp_err_t esp_wifi_disable_pmf_config(wifi_interface_t ifx); + #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32/include/freertos/include/esp_additions/freertos/task_snapshot.h b/tools/sdk/esp32/include/freertos/include/esp_additions/freertos/task_snapshot.h index 1ad04cce694..635a5150257 100644 --- a/tools/sdk/esp32/include/freertos/include/esp_additions/freertos/task_snapshot.h +++ b/tools/sdk/esp32/include/freertos/include/esp_additions/freertos/task_snapshot.h @@ -80,8 +80,9 @@ TaskHandle_t pxTaskGetNext( TaskHandle_t pxTask ); * @note This function should not be used while FreeRTOS is running (as it doesn't acquire any locks). * @param pxTask task handle. * @param pxTaskSnapshot address of TaskSnapshot_t structure to fill. + * @return pdTRUE if operation was successful else pdFALSE */ -void vTaskGetSnapshot( TaskHandle_t pxTask, TaskSnapshot_t *pxTaskSnapshot ); +BaseType_t vTaskGetSnapshot( TaskHandle_t pxTask, TaskSnapshot_t *pxTaskSnapshot ); #ifdef __cplusplus } diff --git a/tools/sdk/esp32/include/hal/esp32/include/hal/cpu_ll.h b/tools/sdk/esp32/include/hal/esp32/include/hal/cpu_ll.h index 49d2e3947d5..68475e4ddf9 100644 --- a/tools/sdk/esp32/include/hal/esp32/include/hal/cpu_ll.h +++ b/tools/sdk/esp32/include/hal/esp32/include/hal/cpu_ll.h @@ -39,7 +39,7 @@ static inline uint32_t IRAM_ATTR cpu_ll_get_core_id(void) return id; } -static inline uint32_t cpu_ll_get_cycle_count(void) +static inline uint32_t IRAM_ATTR cpu_ll_get_cycle_count(void) { uint32_t result; RSR(CCOUNT, result); diff --git a/tools/sdk/esp32/include/hal/esp32/include/hal/i2c_ll.h b/tools/sdk/esp32/include/hal/esp32/include/hal/i2c_ll.h index 650dbbaa048..9a99341c595 100644 --- a/tools/sdk/esp32/include/hal/esp32/include/hal/i2c_ll.h +++ b/tools/sdk/esp32/include/hal/esp32/include/hal/i2c_ll.h @@ -1,16 +1,8 @@ -// Copyright 2015-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. +/* + * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ // The LL layer for I2C register operations @@ -125,9 +117,28 @@ static inline void i2c_ll_cal_bus_clk(uint32_t source_clk, uint32_t bus_freq, i2 */ static inline void i2c_ll_set_bus_timing(i2c_dev_t *hw, i2c_clk_cal_t *bus_cfg) { - //scl period - hw->scl_low_period.period = bus_cfg->scl_low; - hw->scl_high_period.period = bus_cfg->scl_high; + /* SCL period. According to the TRM, we should always subtract 1 to SCL low period */ + assert(bus_cfg->scl_low > 0); + hw->scl_low_period.period = bus_cfg->scl_low - 1; + /* Still according to the TRM, if filter is not enbled, we have to subtract 7, + * if SCL filter is enabled, we have to subtract: + * 8 if SCL filter is between 0 and 2 (included) + * 6 + SCL threshold if SCL filter is between 3 and 7 (included) + * to SCL high period */ + uint16_t scl_high = bus_cfg->scl_high; + /* In the "worst" case, we will subtract 13, make sure the result will still be correct */ + assert(scl_high > 13); + if (hw->scl_filter_cfg.en) { + if (hw->scl_filter_cfg.thres <= 2) { + scl_high -= 8; + } else { + assert(hw->scl_filter_cfg.thres <= 7); + scl_high -= hw->scl_filter_cfg.thres + 6; + } + } else { + scl_high -= 7; + } + hw->scl_high_period.period = scl_high; //sda sample hw->sda_hold.time = bus_cfg->sda_hold; hw->sda_sample.time = bus_cfg->sda_sample; diff --git a/tools/sdk/esp32/include/hal/esp32/include/hal/i2s_ll.h b/tools/sdk/esp32/include/hal/esp32/include/hal/i2s_ll.h index fd20c406cb6..144ae402c34 100644 --- a/tools/sdk/esp32/include/hal/esp32/include/hal/i2s_ll.h +++ b/tools/sdk/esp32/include/hal/esp32/include/hal/i2s_ll.h @@ -695,6 +695,17 @@ static inline void i2s_ll_tx_set_chan_mod(i2s_dev_t *hw, uint32_t val) hw->conf_chan.tx_chan_mod = val; } +/** + * @brief Set I2S rx chan mode + * + * @param hw Peripheral I2S hardware instance address. + * @param val value to set rx chan mode + */ +static inline void i2s_ll_rx_set_chan_mod(i2s_dev_t *hw, uint32_t val) +{ + hw->conf_chan.rx_chan_mod = val; +} + /** * @brief Enable TX mono mode * @@ -705,7 +716,6 @@ static inline void i2s_ll_tx_enable_mono_mode(i2s_dev_t *hw, bool mono_ena) { int data_bit = hw->sample_rate_conf.tx_bits_mod; hw->fifo_conf.tx_fifo_mod = data_bit <= I2S_BITS_PER_SAMPLE_16BIT ? mono_ena : 2 + mono_ena; - hw->conf_chan.tx_chan_mod = mono_ena; } /** @@ -718,7 +728,6 @@ static inline void i2s_ll_rx_enable_mono_mode(i2s_dev_t *hw, bool mono_ena) { int data_bit = hw->sample_rate_conf.rx_bits_mod; hw->fifo_conf.rx_fifo_mod = data_bit <= I2S_BITS_PER_SAMPLE_16BIT ? mono_ena : 2 + mono_ena; - hw->conf_chan.rx_chan_mod = mono_ena; } /** diff --git a/tools/sdk/esp32/include/hal/esp32/include/hal/rtc_cntl_ll.h b/tools/sdk/esp32/include/hal/esp32/include/hal/rtc_cntl_ll.h index f026da853bd..31caf551bf7 100644 --- a/tools/sdk/esp32/include/hal/esp32/include/hal/rtc_cntl_ll.h +++ b/tools/sdk/esp32/include/hal/esp32/include/hal/rtc_cntl_ll.h @@ -1,16 +1,8 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once @@ -50,6 +42,11 @@ static inline void rtc_cntl_ll_ulp_wakeup_enable(void) SET_PERI_REG_MASK(RTC_CNTL_STATE0_REG, RTC_CNTL_ULP_CP_WAKEUP_FORCE_EN); } +static inline void rtc_cntl_ll_ulp_int_clear(void) +{ + REG_SET_BIT(RTC_CNTL_INT_CLR_REG, RTC_CNTL_SAR_INT_CLR); +} + #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32/include/hal/esp32/include/hal/spi_ll.h b/tools/sdk/esp32/include/hal/esp32/include/hal/spi_ll.h index 89b4dedae3d..63efb384ebb 100644 --- a/tools/sdk/esp32/include/hal/esp32/include/hal/spi_ll.h +++ b/tools/sdk/esp32/include/hal/esp32/include/hal/spi_ll.h @@ -1,16 +1,8 @@ -// Copyright 2015-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. +/* + * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ /******************************************************************************* * NOTICE @@ -49,6 +41,8 @@ extern "C" { #define SPI_LL_PERIPH_CLK_FREQ (80 * 1000000) #define SPI_LL_GET_HW(ID) ((ID)==0? &SPI1:((ID)==1? &SPI2 : &SPI3)) +#define SPI_LL_DATA_MAX_BIT_LEN (1 << 24) + /** * The data structure holding calculated clock configuration. Since the * calculation needs long time, it should be calculated during initialization and diff --git a/tools/sdk/esp32/include/hal/include/hal/cpu_hal.h b/tools/sdk/esp32/include/hal/include/hal/cpu_hal.h index 824095871db..0e7e6f53a79 100644 --- a/tools/sdk/esp32/include/hal/include/hal/cpu_hal.h +++ b/tools/sdk/esp32/include/hal/include/hal/cpu_hal.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -70,11 +70,6 @@ extern "C" { */ #define cpu_hal_waiti() cpu_ll_waiti() -/** - * Trigger a syscall. - */ -#define cpu_hal_syscall(sys_nr, arg1, arg2, arg3, arg4, ret_errno) cpu_ll_syscall(sys_nr, arg1, arg2, arg3, arg4, ret_errno) - #if SOC_CPU_BREAKPOINTS_NUM > 0 /** diff --git a/tools/sdk/esp32/include/hal/include/hal/lcd_types.h b/tools/sdk/esp32/include/hal/include/hal/lcd_types.h index 1a62d8f8eb4..13810a79ac3 100644 --- a/tools/sdk/esp32/include/hal/include/hal/lcd_types.h +++ b/tools/sdk/esp32/include/hal/include/hal/lcd_types.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -19,6 +19,8 @@ extern "C" { * +=====================+=========================+============================+ * | LCD_CLK_SRC_PLL160M | High resolution | ESP_PM_APB_FREQ_MAX lock | * +---------------------+-------------------------+----------------------------+ + * | LCD_CLK_SRC_PLL240M | High resolution | ESP_PM_APB_FREQ_MAX lock | + * +---------------------+-------------------------+----------------------------+ * | LCD_CLK_SRC_APLL | Configurable resolution | ESP_PM_NO_LIGHT_SLEEP lock | * +---------------------+-------------------------+----------------------------+ * | LCD_CLK_SRC_XTAL | Medium resolution | No PM lock | @@ -27,6 +29,7 @@ extern "C" { */ typedef enum { LCD_CLK_SRC_PLL160M, /*!< Select PLL160M as the source clock */ + LCD_CLK_SRC_PLL240M, /*!< Select PLL240M as the source clock */ LCD_CLK_SRC_APLL, /*!< Select APLL as the source clock */ LCD_CLK_SRC_XTAL, /*!< Select XTAL as the source clock */ } lcd_clock_source_t; diff --git a/tools/sdk/esp32/include/hal/include/hal/rtc_hal.h b/tools/sdk/esp32/include/hal/include/hal/rtc_hal.h index 90f965ed58c..953123ec928 100644 --- a/tools/sdk/esp32/include/hal/include/hal/rtc_hal.h +++ b/tools/sdk/esp32/include/hal/include/hal/rtc_hal.h @@ -90,3 +90,5 @@ void rtc_cntl_hal_disable_tagmem_retention(void *addr); * Enable wakeup from ULP coprocessor. */ #define rtc_hal_ulp_wakeup_enable() rtc_cntl_ll_ulp_wakeup_enable() + +#define rtc_hal_ulp_int_clear() rtc_cntl_ll_ulp_int_clear() diff --git a/tools/sdk/esp32/include/hal/include/hal/systimer_types.h b/tools/sdk/esp32/include/hal/include/hal/systimer_types.h index 2af2f60f30c..d4583dc7ae0 100644 --- a/tools/sdk/esp32/include/hal/include/hal/systimer_types.h +++ b/tools/sdk/esp32/include/hal/include/hal/systimer_types.h @@ -30,6 +30,9 @@ typedef struct { struct { uint64_t lo : SOC_SYSTIMER_BIT_WIDTH_LO; /*!< Low part of counter value */ uint64_t hi : SOC_SYSTIMER_BIT_WIDTH_HI; /*!< High part of counter value */ +#if (SOC_SYSTIMER_BIT_WIDTH_LO + SOC_SYSTIMER_BIT_WIDTH_HI) < 64 + uint64_t reserved: (64 - (SOC_SYSTIMER_BIT_WIDTH_LO + SOC_SYSTIMER_BIT_WIDTH_HI)); +#endif }; uint64_t val; /*!< counter value */ }; diff --git a/tools/sdk/esp32/include/json_generator/upstream/json_generator.h b/tools/sdk/esp32/include/json_generator/upstream/json_generator.h index e3aa92eeecf..30e6a8dca74 100644 --- a/tools/sdk/esp32/include/json_generator/upstream/json_generator.h +++ b/tools/sdk/esp32/include/json_generator/upstream/json_generator.h @@ -174,7 +174,7 @@ int json_gen_end_array(json_gen_str_t *jstr); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that */ -int json_gen_push_object(json_gen_str_t *jstr, char *name); +int json_gen_push_object(json_gen_str_t *jstr, const char *name); /** Pop a named JSON object * @@ -208,7 +208,7 @@ int json_gen_pop_object(json_gen_str_t *jstr); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that. */ -int json_gen_push_object_str(json_gen_str_t *jstr, char *name, char *object_str); +int json_gen_push_object_str(json_gen_str_t *jstr, const char *name, const char *object_str); /** Push a named JSON array * @@ -223,7 +223,7 @@ int json_gen_push_object_str(json_gen_str_t *jstr, char *name, char *object_str) * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that */ -int json_gen_push_array(json_gen_str_t *jstr, char *name); +int json_gen_push_array(json_gen_str_t *jstr, const char *name); /** Pop a named JSON array * @@ -257,7 +257,7 @@ int json_gen_pop_array(json_gen_str_t *jstr); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that. */ -int json_gen_push_array_str(json_gen_str_t *jstr, char *name, char *array_str); +int json_gen_push_array_str(json_gen_str_t *jstr, const char *name, const char *array_str); /** Add a boolean element to an object * @@ -276,7 +276,7 @@ int json_gen_push_array_str(json_gen_str_t *jstr, char *name, char *array_str); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that */ -int json_gen_obj_set_bool(json_gen_str_t *jstr, char *name, bool val); +int json_gen_obj_set_bool(json_gen_str_t *jstr, const char *name, bool val); /** Add an integer element to an object * @@ -295,7 +295,7 @@ int json_gen_obj_set_bool(json_gen_str_t *jstr, char *name, bool val); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that */ -int json_gen_obj_set_int(json_gen_str_t *jstr, char *name, int val); +int json_gen_obj_set_int(json_gen_str_t *jstr, const char *name, int val); /** Add a float element to an object * @@ -314,7 +314,7 @@ int json_gen_obj_set_int(json_gen_str_t *jstr, char *name, int val); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that */ -int json_gen_obj_set_float(json_gen_str_t *jstr, char *name, float val); +int json_gen_obj_set_float(json_gen_str_t *jstr, const char *name, float val); /** Add a string element to an object * @@ -333,7 +333,7 @@ int json_gen_obj_set_float(json_gen_str_t *jstr, char *name, float val); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that */ -int json_gen_obj_set_string(json_gen_str_t *jstr, char *name, char *val); +int json_gen_obj_set_string(json_gen_str_t *jstr, const char *name, const char *val); /** Add a NULL element to an object * @@ -351,7 +351,7 @@ int json_gen_obj_set_string(json_gen_str_t *jstr, char *name, char *val); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that */ -int json_gen_obj_set_null(json_gen_str_t *jstr, char *name); +int json_gen_obj_set_null(json_gen_str_t *jstr, const char *name); /** Add a boolean element to an array * @@ -415,7 +415,7 @@ int json_gen_arr_set_float(json_gen_str_t *jstr, float val); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that */ -int json_gen_arr_set_string(json_gen_str_t *jstr, char *val); +int json_gen_arr_set_string(json_gen_str_t *jstr, const char *val); /** Add a NULL element to an array * @@ -452,7 +452,7 @@ int json_gen_arr_set_null(json_gen_str_t *jstr); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that */ -int json_gen_obj_start_long_string(json_gen_str_t *jstr, char *name, char *val); +int json_gen_obj_start_long_string(json_gen_str_t *jstr, const char *name, const char *val); /** Start a Long string in an array * @@ -473,7 +473,7 @@ int json_gen_obj_start_long_string(json_gen_str_t *jstr, char *name, char *val); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that */ -int json_gen_arr_start_long_string(json_gen_str_t *jstr, char *val); +int json_gen_arr_start_long_string(json_gen_str_t *jstr, const char *val); /** Add to a JSON Long string * @@ -489,7 +489,7 @@ int json_gen_arr_start_long_string(json_gen_str_t *jstr, char *val); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that */ -int json_gen_add_to_long_string(json_gen_str_t *jstr, char *val); +int json_gen_add_to_long_string(json_gen_str_t *jstr, const char *val); /** End a JSON Long string * diff --git a/tools/sdk/esp32/include/json_parser/upstream/include/json_parser.h b/tools/sdk/esp32/include/json_parser/upstream/include/json_parser.h index 3e982fe14eb..8e92fe7d63f 100644 --- a/tools/sdk/esp32/include/json_parser/upstream/include/json_parser.h +++ b/tools/sdk/esp32/include/json_parser/upstream/include/json_parser.h @@ -16,6 +16,7 @@ #ifndef _JSON_PARSER_H_ #define _JSON_PARSER_H_ +#define JSMN_PARENT_LINKS #define JSMN_HEADER #include #include @@ -34,29 +35,31 @@ typedef jsmntok_t json_tok_t; typedef struct { json_parser_t parser; - char *js; + const char *js; json_tok_t *tokens; json_tok_t *cur; int num_tokens; } jparse_ctx_t; -int json_parse_start(jparse_ctx_t *jctx, char *js, int len); +int json_parse_start(jparse_ctx_t *jctx, const char *js, int len); int json_parse_end(jparse_ctx_t *jctx); +int json_parse_start_static(jparse_ctx_t *jctx, const char *js, int len, json_tok_t *buffer_tokens, int buffer_tokens_max_count); +int json_parse_end_static(jparse_ctx_t *jctx); -int json_obj_get_array(jparse_ctx_t *jctx, char *name, int *num_elem); +int json_obj_get_array(jparse_ctx_t *jctx, const char *name, int *num_elem); int json_obj_leave_array(jparse_ctx_t *jctx); -int json_obj_get_object(jparse_ctx_t *jctx, char *name); +int json_obj_get_object(jparse_ctx_t *jctx, const char *name); int json_obj_leave_object(jparse_ctx_t *jctx); -int json_obj_get_bool(jparse_ctx_t *jctx, char *name, bool *val); -int json_obj_get_int(jparse_ctx_t *jctx, char *name, int *val); -int json_obj_get_int64(jparse_ctx_t *jctx, char *name, int64_t *val); -int json_obj_get_float(jparse_ctx_t *jctx, char *name, float *val); -int json_obj_get_string(jparse_ctx_t *jctx, char *name, char *val, int size); -int json_obj_get_strlen(jparse_ctx_t *jctx, char *name, int *strlen); -int json_obj_get_object_str(jparse_ctx_t *jctx, char *name, char *val, int size); -int json_obj_get_object_strlen(jparse_ctx_t *jctx, char *name, int *strlen); -int json_obj_get_array_str(jparse_ctx_t *jctx, char *name, char *val, int size); -int json_obj_get_array_strlen(jparse_ctx_t *jctx, char *name, int *strlen); +int json_obj_get_bool(jparse_ctx_t *jctx, const char *name, bool *val); +int json_obj_get_int(jparse_ctx_t *jctx, const char *name, int *val); +int json_obj_get_int64(jparse_ctx_t *jctx, const char *name, int64_t *val); +int json_obj_get_float(jparse_ctx_t *jctx, const char *name, float *val); +int json_obj_get_string(jparse_ctx_t *jctx, const char *name, char *val, int size); +int json_obj_get_strlen(jparse_ctx_t *jctx, const char *name, int *strlen); +int json_obj_get_object_str(jparse_ctx_t *jctx, const char *name, char *val, int size); +int json_obj_get_object_strlen(jparse_ctx_t *jctx, const char *name, int *strlen); +int json_obj_get_array_str(jparse_ctx_t *jctx, const char *name, char *val, int size); +int json_obj_get_array_strlen(jparse_ctx_t *jctx, const char *name, int *strlen); int json_arr_get_array(jparse_ctx_t *jctx, uint32_t index); int json_arr_leave_array(jparse_ctx_t *jctx); @@ -74,3 +77,4 @@ int json_arr_get_strlen(jparse_ctx_t *jctx, uint32_t index, int *strlen); #endif #endif /* _JSON_PARSER_H_ */ + diff --git a/tools/sdk/esp32/include/lwip/lwip/src/include/lwip/dns.h b/tools/sdk/esp32/include/lwip/lwip/src/include/lwip/dns.h index db52fedd1da..7c9933eaa32 100644 --- a/tools/sdk/esp32/include/lwip/lwip/src/include/lwip/dns.h +++ b/tools/sdk/esp32/include/lwip/lwip/src/include/lwip/dns.h @@ -113,6 +113,7 @@ err_t dns_gethostbyname_addrtype(const char *hostname, ip_addr_t *add u8_t dns_addrtype); #if ESP_DNS void dns_clear_servers(bool keep_fallback); +void dns_clear_cache(void); #endif #if DNS_LOCAL_HOSTLIST diff --git a/tools/sdk/esp32/include/lwip/lwip/src/include/lwip/init.h b/tools/sdk/esp32/include/lwip/lwip/src/include/lwip/init.h index c7f3eb99cbb..921573618d7 100644 --- a/tools/sdk/esp32/include/lwip/lwip/src/include/lwip/init.h +++ b/tools/sdk/esp32/include/lwip/lwip/src/include/lwip/init.h @@ -54,7 +54,7 @@ extern "C" { /** x.X.x: Minor version of the stack */ #define LWIP_VERSION_MINOR 1 /** x.x.X: Revision of the stack */ -#define LWIP_VERSION_REVISION 3 +#define LWIP_VERSION_REVISION 2 /** For release candidates, this is set to 1..254 * For official releases, this is set to 255 (LWIP_RC_RELEASE) * For development versions (Git), this is set to 0 (LWIP_RC_DEVELOPMENT) */ @@ -75,7 +75,7 @@ extern "C" { #if LWIP_VERSION_IS_RELEASE #define LWIP_VERSION_STRING_SUFFIX "" #elif LWIP_VERSION_IS_DEVELOPMENT -#define LWIP_VERSION_STRING_SUFFIX "d" +#define LWIP_VERSION_STRING_SUFFIX "esp" #else #define LWIP_VERSION_STRING_SUFFIX "rc" LWIP_VERSTR(LWIP_VERSION_RC) #endif diff --git a/tools/sdk/esp32/include/lwip/lwip/src/include/lwip/opt.h b/tools/sdk/esp32/include/lwip/lwip/src/include/lwip/opt.h index cdd7044c728..b314c59a439 100644 --- a/tools/sdk/esp32/include/lwip/lwip/src/include/lwip/opt.h +++ b/tools/sdk/esp32/include/lwip/lwip/src/include/lwip/opt.h @@ -2534,10 +2534,12 @@ /** * LWIP_ICMP6_DATASIZE: bytes from original packet to send back in - * ICMPv6 error messages. + * ICMPv6 error messages (0 = default of IP6_MIN_MTU_LENGTH) + * ATTENTION: RFC4443 section 2.4 says IP6_MIN_MTU_LENGTH is a MUST, + * so override this only if you absolutely have to! */ #if !defined LWIP_ICMP6_DATASIZE || defined __DOXYGEN__ -#define LWIP_ICMP6_DATASIZE 8 +#define LWIP_ICMP6_DATASIZE 0 #endif /** diff --git a/tools/sdk/esp32/include/lwip/lwip/src/include/lwip/pbuf.h b/tools/sdk/esp32/include/lwip/lwip/src/include/lwip/pbuf.h index deac38dcc47..2eedb956ee8 100644 --- a/tools/sdk/esp32/include/lwip/lwip/src/include/lwip/pbuf.h +++ b/tools/sdk/esp32/include/lwip/lwip/src/include/lwip/pbuf.h @@ -300,6 +300,7 @@ void pbuf_cat(struct pbuf *head, struct pbuf *tail); void pbuf_chain(struct pbuf *head, struct pbuf *tail); struct pbuf *pbuf_dechain(struct pbuf *p); err_t pbuf_copy(struct pbuf *p_to, const struct pbuf *p_from); +err_t pbuf_copy_partial_pbuf(struct pbuf *p_to, const struct pbuf *p_from, u16_t copy_len, u16_t offset); u16_t pbuf_copy_partial(const struct pbuf *p, void *dataptr, u16_t len, u16_t offset); void *pbuf_get_contiguous(const struct pbuf *p, void *buffer, size_t bufsize, u16_t len, u16_t offset); err_t pbuf_take(struct pbuf *buf, const void *dataptr, u16_t len); diff --git a/tools/sdk/esp32/include/lwip/lwip/src/include/lwip/prot/icmp6.h b/tools/sdk/esp32/include/lwip/lwip/src/include/lwip/prot/icmp6.h index 3461120421e..36989f6b32a 100644 --- a/tools/sdk/esp32/include/lwip/lwip/src/include/lwip/prot/icmp6.h +++ b/tools/sdk/esp32/include/lwip/lwip/src/include/lwip/prot/icmp6.h @@ -146,6 +146,8 @@ PACK_STRUCT_END # include "arch/epstruct.h" #endif +#define ICMP6_HLEN 8 + /** This is the ICMP6 header adapted for echo req/resp. */ #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/bpstruct.h" diff --git a/tools/sdk/esp32/include/lwip/lwip/src/include/lwip/prot/ip6.h b/tools/sdk/esp32/include/lwip/lwip/src/include/lwip/prot/ip6.h index 0f6de455932..7df81edd690 100644 --- a/tools/sdk/esp32/include/lwip/lwip/src/include/lwip/prot/ip6.h +++ b/tools/sdk/esp32/include/lwip/lwip/src/include/lwip/prot/ip6.h @@ -44,6 +44,8 @@ extern "C" { #endif +#define IP6_MIN_MTU_LENGTH 1280 + /** This is the packed version of ip6_addr_t, used in network headers that are itself packed */ #ifdef PACK_STRUCT_USE_INCLUDES diff --git a/tools/sdk/esp32/include/lwip/port/esp32/include/lwipopts.h b/tools/sdk/esp32/include/lwip/port/esp32/include/lwipopts.h index 47215e99dae..bb0d371c6ee 100644 --- a/tools/sdk/esp32/include/lwip/port/esp32/include/lwipopts.h +++ b/tools/sdk/esp32/include/lwip/port/esp32/include/lwipopts.h @@ -1007,6 +1007,7 @@ #define ESP_LWIP_SELECT 1 #define ESP_LWIP_LOCK 1 #define ESP_THREAD_PROTECTION 1 +#define ESP_IP_FORWARD 1 #ifdef CONFIG_LWIP_IPV6_AUTOCONFIG #define ESP_IPV6_AUTOCONFIG CONFIG_LWIP_IPV6_AUTOCONFIG diff --git a/tools/sdk/esp32/include/mbedtls/esp_crt_bundle/include/esp_crt_bundle.h b/tools/sdk/esp32/include/mbedtls/esp_crt_bundle/include/esp_crt_bundle.h index 33fb98b9969..49069185b3a 100644 --- a/tools/sdk/esp32/include/mbedtls/esp_crt_bundle/include/esp_crt_bundle.h +++ b/tools/sdk/esp32/include/mbedtls/esp_crt_bundle/include/esp_crt_bundle.h @@ -1,21 +1,14 @@ -// 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. +/* + * SPDX-FileCopyrightText: 2017-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ESP_CRT_BUNDLE_H_ #define _ESP_CRT_BUNDLE_H_ +#include "esp_err.h" #include "mbedtls/ssl.h" #ifdef __cplusplus @@ -52,13 +45,19 @@ void esp_crt_bundle_detach(mbedtls_ssl_config *conf); /** * @brief Set the default certificate bundle used for verification * - * Overrides the default certificate bundle. In most use cases the bundle should be + * Overrides the default certificate bundle only in case of successful initialization. In most use cases the bundle should be * set through menuconfig. The bundle needs to be sorted by subject name since binary search is * used to find certificates. * * @param[in] x509_bundle A pointer to the certificate bundle. + * + * @param[in] bundle_size Size of the certificate bundle in bytes. + * + * @return + * - ESP_OK if adding certificates was successful. + * - Other if an error occured or an action must be taken by the calling process. */ -void esp_crt_bundle_set(const uint8_t *x509_bundle); +esp_err_t esp_crt_bundle_set(const uint8_t *x509_bundle, size_t bundle_size); #ifdef __cplusplus diff --git a/tools/sdk/esp32/include/mqtt/esp-mqtt/include/mqtt_client.h b/tools/sdk/esp32/include/mqtt/esp-mqtt/include/mqtt_client.h index 475581b50db..07feed3c370 100644 --- a/tools/sdk/esp32/include/mqtt/esp-mqtt/include/mqtt_client.h +++ b/tools/sdk/esp32/include/mqtt/esp-mqtt/include/mqtt_client.h @@ -39,7 +39,11 @@ typedef enum { MQTT_EVENT_ERROR = 0, /*!< on error event, additional context: connection return code, error handle from esp_tls (if supported) */ MQTT_EVENT_CONNECTED, /*!< connected event, additional context: session_present flag */ MQTT_EVENT_DISCONNECTED, /*!< disconnected event */ - MQTT_EVENT_SUBSCRIBED, /*!< subscribed event, additional context: msg_id */ + MQTT_EVENT_SUBSCRIBED, /*!< subscribed event, additional context: + - msg_id message id + - data pointer to the received data + - data_len length of the data for this event + */ MQTT_EVENT_UNSUBSCRIBED, /*!< unsubscribed event */ MQTT_EVENT_PUBLISHED, /*!< published event, additional context: msg_id */ MQTT_EVENT_DATA, /*!< data event, additional context: @@ -51,6 +55,8 @@ typedef enum { - current_data_offset offset of the current data for this event - total_data_len total length of the data received - retain retain flag of the message + - qos qos level of the message + - dup dup flag of the message Note: Multiple MQTT_EVENT_DATA could be fired for one message, if it is longer than internal buffer. In that case only first event contains topic pointer and length, other contain data only with current data length @@ -153,6 +159,8 @@ typedef struct { int session_present; /*!< MQTT session_present flag for connection event */ esp_mqtt_error_codes_t *error_handle; /*!< esp-mqtt error handle including esp-tls errors as well as internal mqtt errors */ bool retain; /*!< Retained flag of the message associated with this event */ + int qos; /*!< qos of the messages associated with this event */ + bool dup; /*!< dup flag of the message associated with this event */ } esp_mqtt_event_t; typedef esp_mqtt_event_t *esp_mqtt_event_handle_t; @@ -168,7 +176,11 @@ typedef struct { const char *host; /*!< MQTT server domain (ipv4 as string) */ const char *uri; /*!< Complete MQTT broker URI */ uint32_t port; /*!< MQTT server port */ - const char *client_id; /*!< default client id is ``ESP32_%CHIPID%`` where %CHIPID% are last 3 bytes of MAC address in hex format */ + bool set_null_client_id; /*!< Selects a NULL client id */ + const char *client_id; /*!< Set client id. + Ignored if set_null_client_id == true + If NULL set the default client id. + Default client id is ``ESP32_%CHIPID%`` where %CHIPID% are last 3 bytes of MAC address in hex format */ const char *username; /*!< MQTT username */ const char *password; /*!< MQTT password */ const char *lwt_topic; /*!< LWT (Last Will and Testament) message topic (NULL by default) */ diff --git a/tools/sdk/esp32/include/newlib/platform_include/errno.h b/tools/sdk/esp32/include/newlib/platform_include/errno.h index 85fb2e15b85..98dedeef88a 100644 --- a/tools/sdk/esp32/include/newlib/platform_include/errno.h +++ b/tools/sdk/esp32/include/newlib/platform_include/errno.h @@ -1,17 +1,9 @@ -// Copyright 2018 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. +/* + * SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ESP_PLATFORM_ERRNO_H_ #define _ESP_PLATFORM_ERRNO_H_ @@ -21,7 +13,7 @@ // Possibly define some missing errors // #ifndef ESHUTDOWN -#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ +#define ESHUTDOWN 110 /* Cannot send after transport endpoint shutdown */ #endif #ifndef EAI_SOCKTYPE diff --git a/tools/sdk/esp32/include/nvs_flash/include/nvs.h b/tools/sdk/esp32/include/nvs_flash/include/nvs.h index 6a45327bbae..0faef98fd3d 100644 --- a/tools/sdk/esp32/include/nvs_flash/include/nvs.h +++ b/tools/sdk/esp32/include/nvs_flash/include/nvs.h @@ -40,7 +40,7 @@ typedef nvs_handle_t nvs_handle IDF_DEPRECATED("Replace with nvs_handle_t"); #define ESP_ERR_NVS_INVALID_STATE (ESP_ERR_NVS_BASE + 0x0b) /*!< NVS is in an inconsistent state due to a previous error. Call nvs_flash_init and nvs_open again, then retry. */ #define ESP_ERR_NVS_INVALID_LENGTH (ESP_ERR_NVS_BASE + 0x0c) /*!< String or blob length is not sufficient to store data */ #define ESP_ERR_NVS_NO_FREE_PAGES (ESP_ERR_NVS_BASE + 0x0d) /*!< NVS partition doesn't contain any empty pages. This may happen if NVS partition was truncated. Erase the whole partition and call nvs_flash_init again. */ -#define ESP_ERR_NVS_VALUE_TOO_LONG (ESP_ERR_NVS_BASE + 0x0e) /*!< String or blob length is longer than supported by the implementation */ +#define ESP_ERR_NVS_VALUE_TOO_LONG (ESP_ERR_NVS_BASE + 0x0e) /*!< Value doesn't fit into the entry or string or blob length is longer than supported by the implementation */ #define ESP_ERR_NVS_PART_NOT_FOUND (ESP_ERR_NVS_BASE + 0x0f) /*!< Partition with specified name is not found in the partition table */ #define ESP_ERR_NVS_NEW_VERSION_FOUND (ESP_ERR_NVS_BASE + 0x10) /*!< NVS partition contains data in new format and cannot be recognized by this version of code */ @@ -124,6 +124,8 @@ typedef struct nvs_opaque_iterator_t *nvs_iterator_t; * * @return * - ESP_OK if storage handle was opened successfully + * - ESP_FAIL if there is an internal error; most likely due to corrupted + * NVS partition (only if NVS assertion checks are disabled) * - ESP_ERR_NVS_NOT_INITIALIZED if the storage driver is not initialized * - ESP_ERR_NVS_PART_NOT_FOUND if the partition with label "nvs" is not found * - ESP_ERR_NVS_NOT_FOUND id namespace doesn't exist yet and @@ -151,6 +153,8 @@ esp_err_t nvs_open(const char* name, nvs_open_mode_t open_mode, nvs_handle_t *ou * * @return * - ESP_OK if storage handle was opened successfully + * - ESP_FAIL if there is an internal error; most likely due to corrupted + * NVS partition (only if NVS assertion checks are disabled) * - ESP_ERR_NVS_NOT_INITIALIZED if the storage driver is not initialized * - ESP_ERR_NVS_PART_NOT_FOUND if the partition with specified name is not found * - ESP_ERR_NVS_NOT_FOUND id namespace doesn't exist yet and @@ -175,6 +179,8 @@ esp_err_t nvs_open_from_partition(const char *part_name, const char* name, nvs_o * * @return * - ESP_OK if value was set successfully + * - ESP_FAIL if there is an internal error; most likely due to corrupted + * NVS partition (only if NVS assertion checks are disabled) * - ESP_ERR_NVS_INVALID_HANDLE if handle has been closed or is NULL * - ESP_ERR_NVS_READ_ONLY if storage handle was opened as read only * - ESP_ERR_NVS_INVALID_NAME if key name doesn't satisfy constraints @@ -282,6 +288,8 @@ esp_err_t nvs_set_str (nvs_handle_t handle, const char* key, const char* value); * * @return * - ESP_OK if value was set successfully + * - ESP_FAIL if there is an internal error; most likely due to corrupted + * NVS partition (only if NVS assertion checks are disabled) * - ESP_ERR_NVS_INVALID_HANDLE if handle has been closed or is NULL * - ESP_ERR_NVS_READ_ONLY if storage handle was opened as read only * - ESP_ERR_NVS_INVALID_NAME if key name doesn't satisfy constraints @@ -325,6 +333,8 @@ esp_err_t nvs_set_blob(nvs_handle_t handle, const char* key, const void* value, * * @return * - ESP_OK if the value was retrieved successfully + * - ESP_FAIL if there is an internal error; most likely due to corrupted + * NVS partition (only if NVS assertion checks are disabled) * - ESP_ERR_NVS_NOT_FOUND if the requested key doesn't exist * - ESP_ERR_NVS_INVALID_HANDLE if handle has been closed or is NULL * - ESP_ERR_NVS_INVALID_NAME if key name doesn't satisfy constraints @@ -432,6 +442,8 @@ esp_err_t nvs_get_u64 (nvs_handle_t handle, const char* key, uint64_t* out_value * * @return * - ESP_OK if the value was retrieved successfully + * - ESP_FAIL if there is an internal error; most likely due to corrupted + * NVS partition (only if NVS assertion checks are disabled) * - ESP_ERR_NVS_NOT_FOUND if the requested key doesn't exist * - ESP_ERR_NVS_INVALID_HANDLE if handle has been closed or is NULL * - ESP_ERR_NVS_INVALID_NAME if key name doesn't satisfy constraints @@ -459,6 +471,8 @@ esp_err_t nvs_get_blob(nvs_handle_t handle, const char* key, void* out_value, si * * @return * - ESP_OK if erase operation was successful + * - ESP_FAIL if there is an internal error; most likely due to corrupted + * NVS partition (only if NVS assertion checks are disabled) * - ESP_ERR_NVS_INVALID_HANDLE if handle has been closed or is NULL * - ESP_ERR_NVS_READ_ONLY if handle was opened as read only * - ESP_ERR_NVS_NOT_FOUND if the requested key doesn't exist @@ -476,6 +490,8 @@ esp_err_t nvs_erase_key(nvs_handle_t handle, const char* key); * * @return * - ESP_OK if erase operation was successful + * - ESP_FAIL if there is an internal error; most likely due to corrupted + * NVS partition (only if NVS assertion checks are disabled) * - ESP_ERR_NVS_INVALID_HANDLE if handle has been closed or is NULL * - ESP_ERR_NVS_READ_ONLY if handle was opened as read only * - other error codes from the underlying storage driver diff --git a/tools/sdk/esp32/include/protobuf-c/protobuf-c/protobuf-c/protobuf-c.h b/tools/sdk/esp32/include/protobuf-c/protobuf-c/protobuf-c/protobuf-c.h index c8fa4fc2a7c..b633722ed5e 100755 --- a/tools/sdk/esp32/include/protobuf-c/protobuf-c/protobuf-c/protobuf-c.h +++ b/tools/sdk/esp32/include/protobuf-c/protobuf-c/protobuf-c/protobuf-c.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008-2017, Dave Benson and the protobuf-c authors. + * Copyright (c) 2008-2018, Dave Benson and the protobuf-c authors. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -238,7 +238,11 @@ PROTOBUF_C__BEGIN_DECLS #define PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC 0x114315af /* Empty string used for initializers */ +#if defined(_WIN32) && defined(PROTOBUF_C_USE_SHARED_LIB) +static const char protobuf_c_empty_string[] = ""; +#else extern const char protobuf_c_empty_string[]; +#endif /** * \defgroup api Public API @@ -790,13 +794,13 @@ protobuf_c_version_number(void); * The version of the protobuf-c headers, represented as a string using the same * format as protobuf_c_version(). */ -#define PROTOBUF_C_VERSION "1.3.0" +#define PROTOBUF_C_VERSION "1.4.0" /** * The version of the protobuf-c headers, represented as an integer using the * same format as protobuf_c_version_number(). */ -#define PROTOBUF_C_VERSION_NUMBER 1003000 +#define PROTOBUF_C_VERSION_NUMBER 1004000 /** * The minimum protoc-c version which works with the current version of the diff --git a/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_bytes_field.h b/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_bytes_field.h index c4a71e85b47..bf873f0f763 100644 --- a/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_bytes_field.h +++ b/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_bytes_field.h @@ -82,11 +82,11 @@ class BytesFieldGenerator : public FieldGenerator { void GenerateDescriptorInitializer(io::Printer* printer) const; void GenerateDefaultValueDeclarations(io::Printer* printer) const; void GenerateDefaultValueImplementations(io::Printer* printer) const; - string GetDefaultValue(void) const; + std::string GetDefaultValue(void) const; void GenerateStaticInit(io::Printer* printer) const; private: - std::map variables_; + std::map variables_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(BytesFieldGenerator); }; diff --git a/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_enum.h b/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_enum.h index 9eb9a6679ce..9c34b697b82 100644 --- a/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_enum.h +++ b/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_enum.h @@ -81,7 +81,7 @@ class EnumGenerator { public: // See generator.cc for the meaning of dllexport_decl. explicit EnumGenerator(const EnumDescriptor* descriptor, - const string& dllexport_decl); + const std::string& dllexport_decl); ~EnumGenerator(); // Header stuff. @@ -105,7 +105,7 @@ class EnumGenerator { private: const EnumDescriptor* descriptor_; - string dllexport_decl_; + std::string dllexport_decl_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumGenerator); }; diff --git a/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_enum_field.h b/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_enum_field.h index 11df6824693..3f8c005d320 100644 --- a/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_enum_field.h +++ b/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_enum_field.h @@ -80,11 +80,11 @@ class EnumFieldGenerator : public FieldGenerator { // implements FieldGenerator --------------------------------------- void GenerateStructMembers(io::Printer* printer) const; void GenerateDescriptorInitializer(io::Printer* printer) const; - string GetDefaultValue(void) const; + std::string GetDefaultValue(void) const; void GenerateStaticInit(io::Printer* printer) const; private: - std::map variables_; + std::map variables_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumFieldGenerator); }; diff --git a/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_extension.h b/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_extension.h index ddbf270e5a1..95413885342 100644 --- a/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_extension.h +++ b/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_extension.h @@ -85,7 +85,7 @@ class ExtensionGenerator { public: // See generator.cc for the meaning of dllexport_decl. explicit ExtensionGenerator(const FieldDescriptor* descriptor, - const string& dllexport_decl); + const std::string& dllexport_decl); ~ExtensionGenerator(); // Header stuff. @@ -96,8 +96,8 @@ class ExtensionGenerator { private: const FieldDescriptor* descriptor_; - string type_traits_; - string dllexport_decl_; + std::string type_traits_; + std::string dllexport_decl_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ExtensionGenerator); }; diff --git a/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_field.h b/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_field.h index 91f1a03dafb..3cad35d3979 100644 --- a/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_field.h +++ b/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_field.h @@ -63,6 +63,7 @@ #ifndef GOOGLE_PROTOBUF_COMPILER_C_FIELD_H__ #define GOOGLE_PROTOBUF_COMPILER_C_FIELD_H__ +#include #include #include @@ -90,7 +91,7 @@ class FieldGenerator { virtual void GenerateDefaultValueDeclarations(io::Printer* printer) const { } virtual void GenerateDefaultValueImplementations(io::Printer* printer) const { } - virtual string GetDefaultValue() const = 0; + virtual std::string GetDefaultValue() const = 0; // Generate members to initialize this field from a static initializer virtual void GenerateStaticInit(io::Printer* printer) const = 0; @@ -99,8 +100,8 @@ class FieldGenerator { protected: void GenerateDescriptorInitializerGeneric(io::Printer* printer, bool optional_uses_has, - const string &type_macro, - const string &descriptor_addr) const; + const std::string &type_macro, + const std::string &descriptor_addr) const; const FieldDescriptor *descriptor_; private: @@ -117,7 +118,7 @@ class FieldGeneratorMap { private: const Descriptor* descriptor_; - scoped_array > field_generators_; + std::unique_ptr[]> field_generators_; static FieldGenerator* MakeGenerator(const FieldDescriptor* field); diff --git a/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_file.h b/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_file.h index ed38ce425c3..8dfd8ba0984 100644 --- a/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_file.h +++ b/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_file.h @@ -63,6 +63,7 @@ #ifndef GOOGLE_PROTOBUF_COMPILER_C_FILE_H__ #define GOOGLE_PROTOBUF_COMPILER_C_FILE_H__ +#include #include #include #include @@ -89,7 +90,7 @@ class FileGenerator { public: // See generator.cc for the meaning of dllexport_decl. explicit FileGenerator(const FileDescriptor* file, - const string& dllexport_decl); + const std::string& dllexport_decl); ~FileGenerator(); void GenerateHeader(io::Printer* printer); @@ -98,13 +99,10 @@ class FileGenerator { private: const FileDescriptor* file_; - scoped_array > message_generators_; - scoped_array > enum_generators_; - scoped_array > service_generators_; - scoped_array > extension_generators_; - - // E.g. if the package is foo.bar, package_parts_ is {"foo", "bar"}. - vector package_parts_; + std::unique_ptr[]> message_generators_; + std::unique_ptr[]> enum_generators_; + std::unique_ptr[]> service_generators_; + std::unique_ptr[]> extension_generators_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileGenerator); }; diff --git a/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_generator.h b/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_generator.h index f454710b36f..ac1ffafeab3 100644 --- a/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_generator.h +++ b/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_generator.h @@ -68,6 +68,12 @@ #include #include +#if defined(_WIN32) && defined(PROTOBUF_C_USE_SHARED_LIB) +# define PROTOC_C_EXPORT __declspec(dllexport) +#else +# define PROTOC_C_EXPORT +#endif + namespace google { namespace protobuf { namespace compiler { @@ -77,16 +83,16 @@ namespace c { // header. If you create your own protocol compiler binary and you want // it to support C++ output, you can do so by registering an instance of this // CodeGenerator with the CommandLineInterface in your main() function. -class LIBPROTOC_EXPORT CGenerator : public CodeGenerator { +class PROTOC_C_EXPORT CGenerator : public CodeGenerator { public: CGenerator(); ~CGenerator(); // implements CodeGenerator ---------------------------------------- bool Generate(const FileDescriptor* file, - const string& parameter, + const std::string& parameter, OutputDirectory* output_directory, - string* error) const; + std::string* error) const; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CGenerator); diff --git a/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_helpers.h b/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_helpers.h index 9dc8c5e859c..7598a4e1da5 100644 --- a/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_helpers.h +++ b/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_helpers.h @@ -67,7 +67,7 @@ #include #include #include -#include +#include #include namespace google { @@ -75,31 +75,20 @@ namespace protobuf { namespace compiler { namespace c { -// Returns the non-nested type name for the given type. If "qualified" is -// true, prefix the type with the full namespace. For example, if you had: -// package foo.bar; -// message Baz { message Qux {} } -// Then the qualified ClassName for Qux would be: -// Foo__Bar__Baz_Qux -// While the non-qualified version would be: -// Baz_Qux -string ClassName(const Descriptor* descriptor, bool qualified); -string ClassName(const EnumDescriptor* enum_descriptor, bool qualified); - // --- Borrowed from stubs. --- -template string SimpleItoa(T n) { +template std::string SimpleItoa(T n) { std::stringstream stream; stream << n; return stream.str(); } -string SimpleFtoa(float f); -string SimpleDtoa(double f); -void SplitStringUsing(const string &str, const char *delim, std::vector *out); -string CEscape(const string& src); -string StringReplace(const string& s, const string& oldsub, const string& newsub, bool replace_all); -inline bool HasSuffixString(const string& str, const string& suffix) { return str.size() >= suffix.size() && str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0; } -inline string StripSuffixString(const string& str, const string& suffix) { if (HasSuffixString(str, suffix)) { return str.substr(0, str.size() - suffix.size()); } else { return str; } } +std::string SimpleFtoa(float f); +std::string SimpleDtoa(double f); +void SplitStringUsing(const std::string &str, const char *delim, std::vector *out); +std::string CEscape(const std::string& src); +std::string StringReplace(const std::string& s, const std::string& oldsub, const std::string& newsub, bool replace_all); +inline bool HasSuffixString(const std::string& str, const std::string& suffix) { return str.size() >= suffix.size() && str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0; } +inline std::string StripSuffixString(const std::string& str, const std::string& suffix) { if (HasSuffixString(str, suffix)) { return str.substr(0, str.size() - suffix.size()); } else { return str; } } char* FastHexToBuffer(int i, char* buffer); @@ -107,10 +96,10 @@ char* FastHexToBuffer(int i, char* buffer); // The name is coerced to lower-case to emulate proto1 behavior. People // should be using lowercase-with-underscores style for proto field names // anyway, so normally this just returns field->name(). -string FieldName(const FieldDescriptor* field); +std::string FieldName(const FieldDescriptor* field); // Get macro string for deprecated field -string FieldDeprecated(const FieldDescriptor* field); +std::string FieldDeprecated(const FieldDescriptor* field); // Returns the scope where the field was defined (for extensions, this is // different from the message type to which the field applies). @@ -121,31 +110,31 @@ inline const Descriptor* FieldScope(const FieldDescriptor* field) { // convert a CamelCase class name into an all uppercase affair // with underscores separating words, e.g. MyClass becomes MY_CLASS. -string CamelToUpper(const string &class_name); -string CamelToLower(const string &class_name); +std::string CamelToUpper(const std::string &class_name); +std::string CamelToLower(const std::string &class_name); // lowercased, underscored name to camel case -string ToCamel(const string &name); +std::string ToCamel(const std::string &name); // lowercase the string -string ToLower(const string &class_name); -string ToUpper(const string &class_name); +std::string ToLower(const std::string &class_name); +std::string ToUpper(const std::string &class_name); // full_name() to lowercase with underscores -string FullNameToLower(const string &full_name); -string FullNameToUpper(const string &full_name); +std::string FullNameToLower(const std::string &full_name, const FileDescriptor *file); +std::string FullNameToUpper(const std::string &full_name, const FileDescriptor *file); // full_name() to c-typename (with underscores for packages, otherwise camel case) -string FullNameToC(const string &class_name); +std::string FullNameToC(const std::string &class_name, const FileDescriptor *file); // Splits, indents, formats, and prints comment lines -void PrintComment (io::Printer* printer, string comment); +void PrintComment (io::Printer* printer, std::string comment); // make a string of spaces as long as input -string ConvertToSpaces(const string &input); +std::string ConvertToSpaces(const std::string &input); // Strips ".proto" or ".protodevel" from the end of a filename. -string StripProto(const string& filename); +std::string StripProto(const std::string& filename); // Get the C++ type name for a primitive type (e.g. "double", "::google::protobuf::int32", etc.). // Note: non-built-in type names will be qualified, meaning they will start @@ -159,18 +148,18 @@ const char* PrimitiveTypeName(FieldDescriptor::CppType type); const char* DeclaredTypeMethodName(FieldDescriptor::Type type); // Convert a file name into a valid identifier. -string FilenameIdentifier(const string& filename); +std::string FilenameIdentifier(const std::string& filename); // Return the name of the BuildDescriptors() function for a given file. -string GlobalBuildDescriptorsName(const string& filename); +std::string GlobalBuildDescriptorsName(const std::string& filename); // return 'required', 'optional', or 'repeated' -string GetLabelName(FieldDescriptor::Label label); +std::string GetLabelName(FieldDescriptor::Label label); // write IntRanges entries for a bunch of sorted values. // returns the number of ranges there are to bsearch. -unsigned WriteIntRanges(io::Printer* printer, int n_values, const int *values, const string &name); +unsigned WriteIntRanges(io::Printer* printer, int n_values, const int *values, const std::string &name); struct NameIndex { diff --git a/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_message.h b/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_message.h index 8b115d1c8cb..ea1c3ab3c8e 100644 --- a/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_message.h +++ b/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_message.h @@ -63,6 +63,7 @@ #ifndef GOOGLE_PROTOBUF_COMPILER_C_MESSAGE_H__ #define GOOGLE_PROTOBUF_COMPILER_C_MESSAGE_H__ +#include #include #include #include @@ -85,7 +86,7 @@ class MessageGenerator { public: // See generator.cc for the meaning of dllexport_decl. explicit MessageGenerator(const Descriptor* descriptor, - const string& dllexport_decl); + const std::string& dllexport_decl); ~MessageGenerator(); // Header stuff. @@ -110,25 +111,31 @@ class MessageGenerator { void GenerateStructStaticInitMacro(io::Printer* printer); // Generate standard helper functions declarations for this message. - void GenerateHelperFunctionDeclarations(io::Printer* printer, bool is_submessage); + void GenerateHelperFunctionDeclarations(io::Printer* printer, + bool is_pack_deep, + bool gen_pack, + bool gen_init); // Source file stuff. // Generate code that initializes the global variable storing the message's // descriptor. - void GenerateMessageDescriptor(io::Printer* printer); - void GenerateHelperFunctionDefinitions(io::Printer* printer, bool is_submessage); + void GenerateMessageDescriptor(io::Printer* printer, bool gen_init); + void GenerateHelperFunctionDefinitions(io::Printer* printer, + bool is_pack_deep, + bool gen_pack, + bool gen_init); private: - string GetDefaultValueC(const FieldDescriptor *fd); + std::string GetDefaultValueC(const FieldDescriptor *fd); const Descriptor* descriptor_; - string dllexport_decl_; + std::string dllexport_decl_; FieldGeneratorMap field_generators_; - scoped_array > nested_generators_; - scoped_array > enum_generators_; - scoped_array > extension_generators_; + std::unique_ptr[]> nested_generators_; + std::unique_ptr[]> enum_generators_; + std::unique_ptr[]> extension_generators_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageGenerator); }; diff --git a/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_message_field.h b/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_message_field.h index b059fb031b0..39b8d999bfa 100644 --- a/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_message_field.h +++ b/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_message_field.h @@ -80,7 +80,7 @@ class MessageFieldGenerator : public FieldGenerator { // implements FieldGenerator --------------------------------------- void GenerateStructMembers(io::Printer* printer) const; void GenerateDescriptorInitializer(io::Printer* printer) const; - string GetDefaultValue(void) const; + std::string GetDefaultValue(void) const; void GenerateStaticInit(io::Printer* printer) const; private: diff --git a/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_primitive_field.h b/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_primitive_field.h index 5ff254c5dd8..a9eb893bb72 100644 --- a/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_primitive_field.h +++ b/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_primitive_field.h @@ -80,7 +80,7 @@ class PrimitiveFieldGenerator : public FieldGenerator { // implements FieldGenerator --------------------------------------- void GenerateStructMembers(io::Printer* printer) const; void GenerateDescriptorInitializer(io::Printer* printer) const; - string GetDefaultValue(void) const; + std::string GetDefaultValue(void) const; void GenerateStaticInit(io::Printer* printer) const; private: diff --git a/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_service.h b/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_service.h index 6f1798ca724..27125a601a5 100644 --- a/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_service.h +++ b/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_service.h @@ -82,7 +82,7 @@ class ServiceGenerator { public: // See generator.cc for the meaning of dllexport_decl. explicit ServiceGenerator(const ServiceDescriptor* descriptor, - const string& dllexport_decl); + const std::string& dllexport_decl); ~ServiceGenerator(); // Header stuff. @@ -99,7 +99,7 @@ class ServiceGenerator { void GenerateCallersImplementations(io::Printer* printer); const ServiceDescriptor* descriptor_; - std::map vars_; + std::map vars_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ServiceGenerator); }; diff --git a/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_string_field.h b/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_string_field.h index 68f0d25b7dd..513cea75306 100644 --- a/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_string_field.h +++ b/tools/sdk/esp32/include/protobuf-c/protobuf-c/protoc-c/c_string_field.h @@ -82,11 +82,11 @@ class StringFieldGenerator : public FieldGenerator { void GenerateDescriptorInitializer(io::Printer* printer) const; void GenerateDefaultValueDeclarations(io::Printer* printer) const; void GenerateDefaultValueImplementations(io::Printer* printer) const; - string GetDefaultValue(void) const; + std::string GetDefaultValue(void) const; void GenerateStaticInit(io::Printer* printer) const; private: - std::map variables_; + std::map variables_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StringFieldGenerator); }; diff --git a/tools/sdk/esp32/include/protobuf-c/protobuf-c/t/generated-code2/common-test-arrays.h b/tools/sdk/esp32/include/protobuf-c/protobuf-c/t/generated-code2/common-test-arrays.h index 1535d38e821..c5e37223c1a 100644 --- a/tools/sdk/esp32/include/protobuf-c/protobuf-c/t/generated-code2/common-test-arrays.h +++ b/tools/sdk/esp32/include/protobuf-c/protobuf-c/t/generated-code2/common-test-arrays.h @@ -56,7 +56,7 @@ TEST_ENUM_TYPE_NAME enum_random[] = { T(0), T(2097152), T(268435455), T(127), T(16383), T(16384) }; #undef T -char *repeated_strings_0[] = { (char*)"onestring" }; -char *repeated_strings_1[] = { (char*)"two", (char*)"string" }; -char *repeated_strings_2[] = { (char*)"many", (char*)"tiny", (char*)"little", (char*)"strings", (char*)"should", (char*)"be", (char*)"handled" }; -char *repeated_strings_3[] = { (char*)"one very long strings XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" }; +const char *repeated_strings_0[] = { "onestring" }; +const char *repeated_strings_1[] = { "two", "string" }; +const char *repeated_strings_2[] = { "many", "tiny", "little", "strings", "should", "be", "handled" }; +const char *repeated_strings_3[] = { "one very long strings XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" }; diff --git a/tools/sdk/esp32/include/protocomm/include/transports/protocomm_ble.h b/tools/sdk/esp32/include/protocomm/include/transports/protocomm_ble.h index f899f95b188..2447c1c5d25 100644 --- a/tools/sdk/esp32/include/protocomm/include/transports/protocomm_ble.h +++ b/tools/sdk/esp32/include/protocomm/include/transports/protocomm_ble.h @@ -82,6 +82,9 @@ typedef struct protocomm_ble_config { /* BLE bonding */ unsigned ble_bonding:1; + /* BLE security flag */ + unsigned ble_sm_sc:1; + } protocomm_ble_config_t; /** diff --git a/tools/sdk/esp32/include/rmaker_common/include/esp_rmaker_mqtt_glue.h b/tools/sdk/esp32/include/rmaker_common/include/esp_rmaker_mqtt_glue.h index 95744bdf58c..9355d034ef4 100644 --- a/tools/sdk/esp32/include/rmaker_common/include/esp_rmaker_mqtt_glue.h +++ b/tools/sdk/esp32/include/rmaker_common/include/esp_rmaker_mqtt_glue.h @@ -155,6 +155,12 @@ typedef struct { */ esp_err_t esp_rmaker_mqtt_glue_setup(esp_rmaker_mqtt_config_t *mqtt_config); +/* Get the ESP AWS PPI String + * + * @return pointer to a NULL terminated PPI string on success. + * @return NULL in case of any error. + */ +const char *esp_get_aws_ppi(void); #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32/include/soc/esp32/include/soc/i2s_struct.h b/tools/sdk/esp32/include/soc/esp32/include/soc/i2s_struct.h index df8baf1dace..647fb18b7b5 100644 --- a/tools/sdk/esp32/include/soc/esp32/include/soc/i2s_struct.h +++ b/tools/sdk/esp32/include/soc/esp32/include/soc/i2s_struct.h @@ -21,8 +21,8 @@ extern "C" { #endif typedef volatile struct i2s_dev_s { - uint32_t reserved_0; - uint32_t reserved_4; + uint32_t fifo_wr; + uint32_t fifo_rd; union { struct { uint32_t tx_reset: 1; diff --git a/tools/sdk/esp32/include/soc/esp32/include/soc/rtc.h b/tools/sdk/esp32/include/soc/esp32/include/soc/rtc.h index bbbf3c7550c..b336cb2a7db 100644 --- a/tools/sdk/esp32/include/soc/esp32/include/soc/rtc.h +++ b/tools/sdk/esp32/include/soc/esp32/include/soc/rtc.h @@ -474,6 +474,11 @@ void rtc_dig_clk8m_enable(void); */ void rtc_dig_clk8m_disable(void); +/** + * @brief Get whether the rtc digital 8M clock is enabled + */ +bool rtc_dig_8m_enabled(void); + /** * @brief Calculate the real clock value after the clock calibration * @@ -506,40 +511,6 @@ typedef struct rtc_sleep_config_s { uint32_t xtal_fpu : 1; //!< keep main XTAL powered up in sleep } rtc_sleep_config_t; -/** - * Default initializer for rtc_sleep_config_t - * - * This initializer sets all fields to "reasonable" values (e.g. suggested for - * production use) based on a combination of RTC_SLEEP_PD_x flags. - * - * @param RTC_SLEEP_PD_x flags combined using bitwise OR - */ -#define is_dslp(pd_flags) ((pd_flags) & RTC_SLEEP_PD_DIG) -#define RTC_SLEEP_CONFIG_DEFAULT(sleep_flags) { \ - .lslp_mem_inf_fpu = 0, \ - .rtc_mem_inf_fpu = 0, \ - .rtc_mem_inf_follow_cpu = ((sleep_flags) & RTC_SLEEP_PD_RTC_MEM_FOLLOW_CPU) ? 1 : 0, \ - .rtc_fastmem_pd_en = ((sleep_flags) & RTC_SLEEP_PD_RTC_FAST_MEM) ? 1 : 0, \ - .rtc_slowmem_pd_en = ((sleep_flags) & RTC_SLEEP_PD_RTC_SLOW_MEM) ? 1 : 0, \ - .rtc_peri_pd_en = ((sleep_flags) & RTC_SLEEP_PD_RTC_PERIPH) ? 1 : 0, \ - .wifi_pd_en = 0, \ - .int_8m_pd_en = is_dslp(sleep_flags) ? 1 : ((sleep_flags) & RTC_SLEEP_PD_INT_8M) ? 1 : 0, \ - .rom_mem_pd_en = 0, \ - .deep_slp = ((sleep_flags) & RTC_SLEEP_PD_DIG) ? 1 : 0, \ - .wdt_flashboot_mod_en = 0, \ - .dig_dbias_wak = RTC_CNTL_DBIAS_1V10, \ - .dig_dbias_slp = is_dslp(sleep_flags) ? RTC_CNTL_DBIAS_0V90 \ - : !((sleep_flags) & RTC_SLEEP_PD_INT_8M) ? RTC_CNTL_DBIAS_1V10 \ - : RTC_CNTL_DBIAS_0V90, \ - .rtc_dbias_wak = RTC_CNTL_DBIAS_1V10, \ - .rtc_dbias_slp = is_dslp(sleep_flags) ? RTC_CNTL_DBIAS_0V90 \ - : !((sleep_flags) & RTC_SLEEP_PD_INT_8M) ? RTC_CNTL_DBIAS_1V10 \ - : RTC_CNTL_DBIAS_0V90, \ - .lslp_meminf_pd = 1, \ - .vddsdio_pd_en = ((sleep_flags) & RTC_SLEEP_PD_VDDSDIO) ? 1 : 0, \ - .xtal_fpu = ((sleep_flags) & RTC_SLEEP_PD_XTAL) ? 0 : 1 \ -}; - #define RTC_SLEEP_PD_DIG BIT(0) //!< Deep sleep (power down digital domain) #define RTC_SLEEP_PD_RTC_PERIPH BIT(1) //!< Power down RTC peripherals #define RTC_SLEEP_PD_RTC_SLOW_MEM BIT(2) //!< Power down RTC SLOW memory @@ -549,6 +520,21 @@ typedef struct rtc_sleep_config_s { #define RTC_SLEEP_PD_XTAL BIT(6) //!< Power down main XTAL #define RTC_SLEEP_PD_INT_8M BIT(7) //!< Power down Internal 8M oscillator +//These flags are not power domains, but will affect some sleep parameters +#define RTC_SLEEP_DIG_USE_8M BIT(16) +#define RTC_SLEEP_USE_ADC_TESEN_MONITOR BIT(17) +#define RTC_SLEEP_NO_ULTRA_LOW BIT(18) //!< Avoid using ultra low power in deep sleep, in which RTCIO cannot be used as input, and RTCMEM can't work under high temperature + +/** + * Default initializer for rtc_sleep_config_t + * + * This initializer sets all fields to "reasonable" values (e.g. suggested for + * production use) based on a combination of RTC_SLEEP_PD_x flags. + * + * @param RTC_SLEEP_PD_x flags combined using bitwise OR + */ +void rtc_sleep_get_default_config(uint32_t sleep_flags, rtc_sleep_config_t *out_config); + /* Various delays to be programmed into power control state machines */ #define RTC_CNTL_XTL_BUF_WAIT_SLP_US (500) #define RTC_CNTL_PLL_BUF_WAIT_SLP_CYCLES (1) @@ -557,6 +543,9 @@ typedef struct rtc_sleep_config_s { #define RTC_CNTL_OTHER_BLOCKS_POWERUP_CYCLES (1) #define RTC_CNTL_OTHER_BLOCKS_WAIT_CYCLES (1) +#define RTC_CNTL_CK8M_WAIT_DEFAULT 20 +#define RTC_CK8M_ENABLE_WAIT_DEFAULT 5 + /** * @brief Prepare the chip to enter sleep mode * diff --git a/tools/sdk/esp32/include/soc/esp32/include/soc/rtc_cntl_reg.h b/tools/sdk/esp32/include/soc/esp32/include/soc/rtc_cntl_reg.h index 96a867b31cd..7e53e96993a 100644 --- a/tools/sdk/esp32/include/soc/esp32/include/soc/rtc_cntl_reg.h +++ b/tools/sdk/esp32/include/soc/esp32/include/soc/rtc_cntl_reg.h @@ -1,16 +1,8 @@ -// Copyright 2015-2016 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. +/* + * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _SOC_RTC_CNTL_REG_H_ #define _SOC_RTC_CNTL_REG_H_ @@ -341,7 +333,6 @@ #define RTC_CNTL_CK8M_WAIT_M ((RTC_CNTL_CK8M_WAIT_V)<<(RTC_CNTL_CK8M_WAIT_S)) #define RTC_CNTL_CK8M_WAIT_V 0xFF #define RTC_CNTL_CK8M_WAIT_S 6 -#define RTC_CNTL_CK8M_WAIT_DEFAULT 20 /* RTC_CNTL_CPU_STALL_WAIT : R/W ;bitpos:[5:1] ;default: 5'd1 ; */ /*description: CPU stall wait cycles in fast_clk_rtc*/ #define RTC_CNTL_CPU_STALL_WAIT 0x0000001F diff --git a/tools/sdk/esp32/include/soc/esp32/include/soc/soc_caps.h b/tools/sdk/esp32/include/soc/esp32/include/soc/soc_caps.h index 3449129ad06..b4c9404441b 100644 --- a/tools/sdk/esp32/include/soc/esp32/include/soc/soc_caps.h +++ b/tools/sdk/esp32/include/soc/esp32/include/soc/soc_caps.h @@ -96,6 +96,7 @@ /*!< RTC */ #define SOC_ADC_MAX_BITWIDTH (12) +#define SOC_RTC_SLOW_CLOCK_SUPPORT_8MD256 (1) /*-------------------------- BROWNOUT CAPS -----------------------------------*/ @@ -163,7 +164,7 @@ /*-------------------------- LCD CAPS ----------------------------------------*/ /* Notes: On esp32, LCD intel 8080 timing is generated by I2S peripheral */ #define SOC_LCD_I80_SUPPORTED (1) /*!< Intel 8080 LCD is supported */ -#define SOC_LCD_I80_BUSES (1) /*!< Only I2S0 has LCD mode */ +#define SOC_LCD_I80_BUSES (2) /*!< Both I2S0/1 have LCD mode */ #define SOC_LCD_I80_BUS_WIDTH (24) /*!< Intel 8080 bus width */ /*-------------------------- LEDC CAPS ---------------------------------------*/ @@ -297,6 +298,8 @@ #define SOC_PM_SUPPORT_EXT_WAKEUP (1) #define SOC_PM_SUPPORT_TOUCH_SENSOR_WAKEUP (1) /*! /* including in bootloader for error values */ #include "sdkconfig.h" #include "soc/soc_caps.h" +#include "bootloader_flash_override.h" #ifdef __cplusplus extern "C" { @@ -32,20 +33,21 @@ uint32_t bootloader_read_flash_id(void); esp_err_t bootloader_flash_wrap_set(spi_flash_wrap_mode_t mode); #endif +/** + * @brief Startup flow recommended by XMC. Call at startup before any erase/write operation. + * + * @return ESP_OK When startup successfully, otherwise ESP_FAIL (indiciating you should reboot before erase/write). + */ +esp_err_t bootloader_flash_xmc_startup(void); + /** * @brief Unlock Flash write protect. * Please do not call this function in SDK. * * @note This can be overridden because it's attribute weak. */ -esp_err_t bootloader_flash_unlock(void); +esp_err_t IRAM_ATTR __attribute__((weak)) bootloader_flash_unlock(void); -/** - * @brief Startup flow recommended by XMC. Call at startup before any erase/write operation. - * - * @return ESP_OK When startup successfully, otherwise ESP_FAIL (indiciating you should reboot before erase/write). - */ -esp_err_t bootloader_flash_xmc_startup(void); #ifdef __cplusplus } diff --git a/tools/sdk/esp32c3/include/bootloader_support/include/bootloader_flash_override.h b/tools/sdk/esp32c3/include/bootloader_support/include/bootloader_flash_override.h new file mode 100644 index 00000000000..ae29f004344 --- /dev/null +++ b/tools/sdk/esp32c3/include/bootloader_support/include/bootloader_flash_override.h @@ -0,0 +1,101 @@ +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#pragma once + +#include "esp_err.h" +#include "esp_attr.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef unsigned (*bootloader_flash_read_status_fn_t)(void); +typedef void (*bootloader_flash_write_status_fn_t)(unsigned); + +typedef struct __attribute__((packed)) +{ + const char *manufacturer; + uint8_t mfg_id; /* 8-bit JEDEC manufacturer ID */ + uint16_t flash_id; /* 16-bit JEDEC flash chip ID */ + uint16_t id_mask; /* Bits to match on in flash chip ID */ + bootloader_flash_read_status_fn_t read_status_fn; + bootloader_flash_write_status_fn_t write_status_fn; + uint8_t status_qio_bit; +} bootloader_qio_info_t; + +/** + * @brief Read 8 bit status using RDSR command + * + * @return Value of SR1. + */ +unsigned bootloader_read_status_8b_rdsr(void); + +/** + * @brief Read 8 bit status (second byte) using RDSR2 command + * + * @return Value of SR2 + */ +unsigned bootloader_read_status_8b_rdsr2(void); + +/** + * @brief Read 16 bit status using RDSR & RDSR2 (low and high bytes) + * + * @return Value of SR2#SR1. + */ +unsigned bootloader_read_status_16b_rdsr_rdsr2(void); + +/** + * @brief Write 8 bit status using WRSR + */ +void bootloader_write_status_8b_wrsr(unsigned new_status); + +/** + * @brief Write 8 bit status (second byte) using WRSR2. + */ +void bootloader_write_status_8b_wrsr2(unsigned new_status); + +/** + * @brief Write 16 bit status using WRSR, (both write SR1 and SR2) + */ +void bootloader_write_status_16b_wrsr(unsigned new_status); + +/** + * @brief Read 8 bit status of XM25QU64A. + * + * @return Value of 8 bit SR. + */ +unsigned bootloader_read_status_8b_xmc25qu64a(void); + +/** + * @brief Write 8 bit status for XM25QU64A + */ +void bootloader_write_status_8b_xmc25qu64a(unsigned new_status); + +/* Array of known flash chips and data to enable Quad I/O mode + + Manufacturer & flash ID can be tested by running "esptool.py + flash_id" + + If manufacturer ID matches, and flash ID ORed with flash ID mask + matches, enable_qio_mode() will execute "Read Cmd", test if bit + number "QIE Bit" is set, and if not set it will call "Write Cmd" + with this bit set. + + Searching of this table stops when the first match is found. + */ +extern const bootloader_qio_info_t __attribute__((weak)) bootloader_flash_qe_support_list[]; + +/** + * @brief Unlock Flash write protect. + * Please do not call this function in SDK. + * + * @note This can be overridden because it's attribute weak. + */ +esp_err_t IRAM_ATTR __attribute__((weak)) bootloader_flash_unlock(void); + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32c3/include/bootloader_support/include/esp_app_format.h b/tools/sdk/esp32c3/include/bootloader_support/include/esp_app_format.h index 64744fdfe5a..ef4f7f4f48f 100644 --- a/tools/sdk/esp32c3/include/bootloader_support/include/esp_app_format.h +++ b/tools/sdk/esp32c3/include/bootloader_support/include/esp_app_format.h @@ -55,6 +55,9 @@ typedef enum { ESP_IMAGE_FLASH_SIZE_4MB, /*!< SPI flash size 4 MB */ ESP_IMAGE_FLASH_SIZE_8MB, /*!< SPI flash size 8 MB */ ESP_IMAGE_FLASH_SIZE_16MB, /*!< SPI flash size 16 MB */ + ESP_IMAGE_FLASH_SIZE_32MB, /*!< SPI flash size 32 MB */ + ESP_IMAGE_FLASH_SIZE_64MB, /*!< SPI flash size 64 MB */ + ESP_IMAGE_FLASH_SIZE_128MB, /*!< SPI flash size 128 MB */ ESP_IMAGE_FLASH_SIZE_MAX /*!< SPI flash size MAX */ } esp_image_flash_size_t; diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_ble_api.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_ble_api.h new file mode 100644 index 00000000000..80ab5707dc0 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_ble_api.h @@ -0,0 +1,182 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _ESP_BLE_MESH_BLE_API_H_ +#define _ESP_BLE_MESH_BLE_API_H_ + +#include "esp_ble_mesh_defs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** This enum value is the event of BLE operations */ +typedef enum { + ESP_BLE_MESH_START_BLE_ADVERTISING_COMP_EVT, /*!< Start BLE advertising completion event */ + ESP_BLE_MESH_STOP_BLE_ADVERTISING_COMP_EVT, /*!< Stop BLE advertising completion event */ + ESP_BLE_MESH_START_BLE_SCANNING_COMP_EVT, /*!< Start BLE scanning completion event */ + ESP_BLE_MESH_STOP_BLE_SCANNING_COMP_EVT, /*!< Stop BLE scanning completion event */ + ESP_BLE_MESH_SCAN_BLE_ADVERTISING_PKT_EVT, /*!< Scanning BLE advertising packets event */ + ESP_BLE_MESH_BLE_EVT_MAX, +} esp_ble_mesh_ble_cb_event_t; + +/** BLE operation callback parameters */ +typedef union { + /** + * @brief ESP_BLE_MESH_START_BLE_ADVERTISING_COMP_EVT + */ + struct { + int err_code; /*!< Indicate the result of starting BLE advertising */ + uint8_t index; /*!< Index of the BLE advertising */ + } start_ble_advertising_comp; /*!< Event parameters of ESP_BLE_MESH_START_BLE_ADVERTISING_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_STOP_BLE_ADVERTISING_COMP_EVT + */ + struct { + int err_code; /*!< Indicate the result of stopping BLE advertising */ + uint8_t index; /*!< Index of the BLE advertising */ + } stop_ble_advertising_comp; /*!< Event parameters of ESP_BLE_MESH_STOP_BLE_ADVERTISING_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_START_BLE_SCANNING_COMP_EVT + */ + struct { + int err_code; /*!< Indicate the result of starting BLE scanning */ + } start_ble_scan_comp; /*!< Event parameters of ESP_BLE_MESH_START_BLE_SCANNING_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_STOP_BLE_SCANNING_COMP_EVT + */ + struct { + int err_code; /*!< Indicate the result of stopping BLE scanning */ + } stop_ble_scan_comp; /*!< Event parameters of ESP_BLE_MESH_STOP_BLE_SCANNING_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_SCAN_BLE_ADVERTISING_PKT_EVT + */ + struct { + uint8_t addr[6]; /*!< Device address */ + uint8_t addr_type; /*!< Device address type */ + uint8_t adv_type; /*!< Advertising data type */ + uint8_t *data; /*!< Advertising data */ + uint16_t length; /*!< Advertising data length */ + int8_t rssi; /*!< RSSI of the advertising packet */ + } scan_ble_adv_pkt; /*!< Event parameters of ESP_BLE_MESH_SCAN_BLE_ADVERTISING_PKT_EVT */ +} esp_ble_mesh_ble_cb_param_t; + +/** + * @brief BLE scanning callback function type + * + * @param event: BLE scanning callback event type + * @param param: BLE scanning callback parameter + */ +typedef void (* esp_ble_mesh_ble_cb_t)(esp_ble_mesh_ble_cb_event_t event, + esp_ble_mesh_ble_cb_param_t *param); + +/** + * @brief Register BLE scanning callback. + * + * @param[in] callback: Pointer to the BLE scaning callback function. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_register_ble_callback(esp_ble_mesh_ble_cb_t callback); + +/** Count for sending BLE advertising packet infinitely */ +#define ESP_BLE_MESH_BLE_ADV_INFINITE 0xFFFF + +/*!< This enum value is the priority of BLE advertising packet */ +typedef enum { + ESP_BLE_MESH_BLE_ADV_PRIO_LOW, + ESP_BLE_MESH_BLE_ADV_PRIO_HIGH, +} esp_ble_mesh_ble_adv_priority_t; + +/** Context of BLE advertising parameters. */ +typedef struct { + uint16_t interval; /*!< BLE advertising interval */ + uint8_t adv_type; /*!< BLE advertising type */ + uint8_t own_addr_type; /*!< Own address type */ + uint8_t peer_addr_type; /*!< Peer address type */ + uint8_t peer_addr[BD_ADDR_LEN]; /*!< Peer address */ + uint16_t duration; /*!< Duration is milliseconds */ + uint16_t period; /*!< Period in milliseconds */ + uint16_t count; /*!< Number of advertising duration */ + uint8_t priority:2; /*!< Priority of BLE advertising packet */ +} esp_ble_mesh_ble_adv_param_t; + +/** Context of BLE advertising data. */ +typedef struct { + uint8_t adv_data_len; /*!< Advertising data length */ + uint8_t adv_data[31]; /*!< Advertising data */ + uint8_t scan_rsp_data_len; /*!< Scan response data length */ + uint8_t scan_rsp_data[31]; /*!< Scan response data */ +} esp_ble_mesh_ble_adv_data_t; + +/** + * @brief This function is called to start BLE advertising with the corresponding data + * and parameters while BLE Mesh is working at the same time. + * + * @note 1. When this function is called, the BLE advertising packet will be posted to + * the BLE mesh adv queue in the mesh stack and waited to be sent. + * 2. In the BLE advertising parameters, the "duration" means the time used for + * sending the BLE advertising packet each time, it shall not be smaller than the + * advertising interval. When the packet is sent successfully, it will be posted + * to the adv queue again after the "period" time if the "count" is bigger than 0. + * The "count" means how many durations the packet will be sent after it is sent + * successfully for the first time. And if the "count" is set to 0xFFFF, which + * means the packet will be sent infinitely. + * 3. The "priority" means the priority of BLE advertising packet compared with + * BLE Mesh packets. Currently two options (i.e. low/high) are provided. If the + * "priority" is high, the BLE advertising packet will be posted to the front of + * adv queue. Otherwise it will be posted to the back of adv queue. + * + * @param[in] param: Pointer to the BLE advertising parameters + * @param[in] data: Pointer to the BLE advertising data and scan response data + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_start_ble_advertising(const esp_ble_mesh_ble_adv_param_t *param, + const esp_ble_mesh_ble_adv_data_t *data); + +/** + * @brief This function is called to stop BLE advertising with the corresponding index. + * + * @param[in] index: Index of BLE advertising + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_stop_ble_advertising(uint8_t index); + +/** Context of BLE scanning parameters. */ +typedef struct { + uint32_t duration; /*!< Duration used to scan normal BLE advertising packets */ +} esp_ble_mesh_ble_scan_param_t; + +/** + * @brief This function is called to start scanning normal BLE advertising packets + * and notifying the packets to the application layer. + * + * @param[in] param: Pointer to the BLE scanning parameters + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_start_ble_scanning(esp_ble_mesh_ble_scan_param_t *param); + +/** + * @brief This function is called to stop notifying normal BLE advertising packets + * to the application layer. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_stop_ble_scanning(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _ESP_BLE_MESH_BLE_API_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_common_api.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_common_api.h new file mode 100644 index 00000000000..f7209d8e5fe --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_common_api.h @@ -0,0 +1,49 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _ESP_BLE_MESH_COMMON_API_H_ +#define _ESP_BLE_MESH_COMMON_API_H_ + +#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. + * + * @note After calling this API, the device needs to call esp_ble_mesh_prov_enable() + * to enable provisioning functionality again. + * + * @param[in] prov: Pointer to the device provisioning capabilities. This pointer must + * remain valid during the lifetime of the BLE Mesh device. + * @param[in] comp: Pointer to the device composition data information. This pointer + * must remain valid during the lifetime of the BLE Mesh device. + * + * @return ESP_OK on success or error code otherwise. + * + */ +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_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_local_data_operation_api.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_local_data_operation_api.h new file mode 100644 index 00000000000..80078681267 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_local_data_operation_api.h @@ -0,0 +1,207 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _ESP_BLE_MESH_LOCAL_DATA_OPERATION_API_H_ +#define _ESP_BLE_MESH_LOCAL_DATA_OPERATION_API_H_ + +#include "esp_ble_mesh_defs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Get the model publish period, the unit is ms. + * + * @param[in] model: Model instance pointer. + * + * @return Publish period value on success, 0 or (negative) error code from errno.h on failure. + * + */ +int32_t esp_ble_mesh_get_model_publish_period(esp_ble_mesh_model_t *model); + +/** + * @brief Get the address of the primary element. + * + * @return Address of the primary element on success, or + * ESP_BLE_MESH_ADDR_UNASSIGNED on failure which means the device has not been provisioned. + * + */ +uint16_t esp_ble_mesh_get_primary_element_address(void); + +/** + * @brief Check if the model has subscribed to the given group address. + * Note: E.g., once a status message is received and the destination address + * is a group address, the model uses this API to check if it is successfully subscribed + * to the given group address. + * + * @param[in] model: Pointer to the model. + * @param[in] group_addr: Group address. + * + * @return Pointer to the group address within the Subscription List of the model on success, or + * NULL on failure which means the model has not subscribed to the given group address. + * Note: With the pointer to the group address returned, you can reset the group address + * 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); + +/** + * @brief Find the BLE Mesh element pointer via the element address. + * + * @param[in] element_addr: Element address. + * + * @return Pointer to the element on success, or NULL on failure. + * + */ +esp_ble_mesh_elem_t *esp_ble_mesh_find_element(uint16_t element_addr); + +/** + * @brief Get the number of elements that have been registered. + * + * @return Number of elements. + * + */ +uint8_t esp_ble_mesh_get_element_count(void); + +/** + * @brief Find the Vendor specific model with the given element, + * the company ID and the Vendor Model ID. + * + * @param[in] element: Element to which the model belongs. + * @param[in] company_id: A 16-bit company identifier assigned by the Bluetooth SIG. + * @param[in] model_id: A 16-bit vendor-assigned model identifier. + * + * @return Pointer to the Vendor Model on success, or NULL on failure which means the Vendor Model is not found. + * + */ +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); + +/** + * @brief Find the SIG model with the given element and Model id. + * + * @param[in] element: Element to which the model belongs. + * @param[in] model_id: SIG model identifier. + * + * @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); + +/** + * @brief Get the Composition data which has been registered. + * + * @return Pointer to the Composition data on success, or NULL on failure which means the Composition data is not initialized. + * + */ +const esp_ble_mesh_comp_t *esp_ble_mesh_get_composition_data(void); + +/** + * @brief A local model of node or Provisioner subscribes a group address. + * + * @note This function shall not be invoked before node is provisioned or Provisioner is enabled. + * + * @param[in] element_addr: Unicast address of the element to which the model belongs. + * @param[in] company_id: A 16-bit company identifier. + * @param[in] model_id: A 16-bit model identifier. + * @param[in] group_addr: The group address to be subscribed. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_model_subscribe_group_addr(uint16_t element_addr, uint16_t company_id, + uint16_t model_id, uint16_t group_addr); + +/** + * @brief A local model of node or Provisioner unsubscribes a group address. + * + * @note This function shall not be invoked before node is provisioned or Provisioner is enabled. + * + * @param[in] element_addr: Unicast address of the element to which the model belongs. + * @param[in] company_id: A 16-bit company identifier. + * @param[in] model_id: A 16-bit model identifier. + * @param[in] group_addr: The subscribed group address. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_model_unsubscribe_group_addr(uint16_t element_addr, uint16_t company_id, + uint16_t model_id, uint16_t group_addr); + +/** + * @brief This function is called by Node to get the local NetKey. + * + * @param[in] net_idx: NetKey index. + * + * @return NetKey on success, or NULL on failure. + * + */ +const uint8_t *esp_ble_mesh_node_get_local_net_key(uint16_t net_idx); + +/** + * @brief This function is called by Node to get the local AppKey. + * + * @param[in] app_idx: AppKey index. + * + * @return AppKey on success, or NULL on failure. + * + */ +const uint8_t *esp_ble_mesh_node_get_local_app_key(uint16_t app_idx); + +/** + * @brief This function is called by Node to add a local NetKey. + * + * @param[in] net_key: NetKey to be added. + * @param[in] net_idx: NetKey Index. + * + * @note This function can only be called after the device is provisioned. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_node_add_local_net_key(const uint8_t net_key[16], uint16_t net_idx); + +/** + * @brief This function is called by Node to add a local AppKey. + * + * @param[in] app_key: AppKey to be added. + * @param[in] net_idx: NetKey Index. + * @param[in] app_idx: AppKey Index. + * + * @note The net_idx must be an existing one. + * This function can only be called after the device is provisioned. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_node_add_local_app_key(const uint8_t app_key[16], uint16_t net_idx, uint16_t app_idx); + +/** + * @brief This function is called by Node to bind AppKey to model locally. + * + * @param[in] element_addr: Node local element address + * @param[in] company_id: Node local company id + * @param[in] model_id: Node local model id + * @param[in] app_idx: Node local appkey index + * + * @note If going to bind app_key with local vendor model, the company_id + * shall be set to 0xFFFF. + * This function can only be called after the device is provisioned. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_node_bind_app_key_to_local_model(uint16_t element_addr, uint16_t company_id, + uint16_t model_id, uint16_t app_idx); + +#ifdef __cplusplus +} +#endif + +#endif /* _ESP_BLE_MESH_LOCAL_DATA_OPERATION_API_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_low_power_api.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_low_power_api.h new file mode 100644 index 00000000000..e55c6a71788 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_low_power_api.h @@ -0,0 +1,61 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _ESP_BLE_MESH_LOW_POWER_API_H_ +#define _ESP_BLE_MESH_LOW_POWER_API_H_ + +#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_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_networking_api.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_networking_api.h new file mode 100644 index 00000000000..01af7951382 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_networking_api.h @@ -0,0 +1,648 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _ESP_BLE_MESH_NETWORKING_API_H_ +#define _ESP_BLE_MESH_NETWORKING_API_H_ + +#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); + +/** + * @brief Register BLE Mesh callback for user-defined models' operations. + * This callback can report the following events generated for the user-defined models: + * - Call back the messages received by user-defined client and server models to the + * application layer; + * - If users call esp_ble_mesh_server/client_model_send, this callback notifies the + * application layer of the send_complete event; + * - If user-defined client model sends a message that requires response, and the response + * message is received after the timer expires, the response message will be reported + * to the application layer as published by a peer device; + * - If the user-defined client model fails to receive the response message during a specified + * period of time, a timeout event will be reported to the application layer. + * + * @note The client models (i.e. Config Client model, Health Client model, Generic + * Client models, Sensor Client model, Scene Client model and Lighting Client models) + * that have been realized internally have their specific register functions. + * For example, esp_ble_mesh_register_config_client_callback is the register + * function for Config Client Model. + * + * @param[in] callback: Pointer to the callback function. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_register_custom_model_callback(esp_ble_mesh_model_cb_t callback); + +/** + * @brief Add the message opcode to the beginning of the model message + * before sending or publishing the model message. + * + * @note This API is only used to set the opcode of the message. + * + * @param[in] data: Pointer to the message data. + * @param[in] opcode: The message opcode. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_model_msg_opcode_init(uint8_t *data, uint32_t opcode); + +/** + * @brief Initialize the user-defined client model. All user-defined client models + * shall call this function to initialize the client model internal data. + * Node: Before calling this API, the op_pair_size and op_pair variabled within + * the user_data(defined using esp_ble_mesh_client_t_) of the client model + * need to be initialized. + * + * @param[in] model: BLE Mesh Client model to which the message belongs. + * + * @return ESP_OK on success or error code otherwise. + * + */ +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). + * + * @param[in] model: BLE Mesh Server Model to which the message belongs. + * @param[in] ctx: Message context, includes keys, TTL, etc. + * @param[in] opcode: Message opcode. + * @param[in] length: Message length (exclude the message opcode). + * @param[in] data: Parameters of Access Payload (exclude the message opcode) to be sent. + * + * @return ESP_OK on success or error code otherwise. + * + */ +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); + +/** + * @brief Send client model message (such as model get, set, etc). + * + * @param[in] model: BLE Mesh Client Model to which the message belongs. + * @param[in] ctx: Message context, includes keys, TTL, etc. + * @param[in] opcode: Message opcode. + * @param[in] length: Message length (exclude the message opcode). + * @param[in] data: Parameters of the Access Payload (exclude the message opcode) to be sent. + * @param[in] msg_timeout: Time to get response to the message (in milliseconds). + * @param[in] need_rsp: TRUE if the opcode requires the peer device to reply, FALSE otherwise. + * @param[in] device_role: Role of the device (Node/Provisioner) that sends the message. + * + * @return ESP_OK on success or error code otherwise. + * + */ +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); + +/** + * @brief Send a model publication message. + * + * @note Before calling this function, the user needs to ensure that the model + * publication message (@ref esp_ble_mesh_model_pub_t.msg) contains a valid + * message to be sent. And if users want to update the publishing message, + * this API should be called in ESP_BLE_MESH_MODEL_PUBLISH_UPDATE_EVT + * with the message updated. + * + * + * @param[in] model: Mesh (client) Model publishing the message. + * @param[in] opcode: Message opcode. + * @param[in] length: Message length (exclude the message opcode). + * @param[in] data: Parameters of the Access Payload (exclude the message opcode) to be sent. + * @param[in] device_role: Role of the device (node/provisioner) publishing the message of the type esp_ble_mesh_dev_role_t. + * + * @return ESP_OK on success or error code otherwise. + * + */ +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); + +/** + * @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. + * + * @note All provisioning information in this node will be deleted and the node + * needs to be reprovisioned. The API function esp_ble_mesh_node_prov_enable() + * needs to be called to start a new provisioning procedure. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_node_local_reset(void); + +/** + * @brief This function is called to set the node (provisioned device) name. + * + * @param[in] index: Index of the node in the node queue. + * @param[in] name: Name (end by '\0') to be set for the node. + * + * @note index is obtained from the parameters of ESP_BLE_MESH_PROVISIONER_PROV_COMPLETE_EVT. + * + * @return ESP_OK on success or error code otherwise. + * + */ +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. + * + * @param[in] index: Index of the node in the node queue. + * + * @note index is obtained from the parameters of ESP_BLE_MESH_PROVISIONER_PROV_COMPLETE_EVT. + * + * @return Node name on success, or NULL on failure. + * + */ +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 an invalid value (0xFFFF) on failure. + * + */ +uint16_t esp_ble_mesh_provisioner_get_node_index(const char *name); + +/** + * @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. + * @param[in] app_idx: The app key index. + * + * @note app_key: If set to NULL, app_key will be generated internally. + * net_idx: Should be an existing one. + * app_idx: If it is going to be generated internally, it should be set to + * 0xFFFF, and the new app_idx will be reported via an event. + * + * @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); + +/** + * @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. + * + * @param[in] net_idx: Network key index. + * @param[in] app_idx: Application key index. + * + * @return App key on success, or NULL on failure. + * + */ +const uint8_t *esp_ble_mesh_provisioner_get_local_app_key(uint16_t net_idx, uint16_t app_idx); + +/** + * @brief This function is called by Provisioner to bind own model with proper app key. + * + * @param[in] element_addr: Provisioner local element address + * @param[in] app_idx: Provisioner local appkey index + * @param[in] model_id: Provisioner local model id + * @param[in] company_id: Provisioner local company id + * + * @note company_id: If going to bind app_key with local vendor model, company_id + * should be set to 0xFFFF. + * + * @return ESP_OK on success or error code otherwise. + * + */ +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); + +/** + * @brief This function is called by Provisioner to add local network key. + * + * @param[in] net_key: The network key to be added to the Provisioner local BLE Mesh stack. + * @param[in] net_idx: The network key index. + * + * @note net_key: If set to NULL, net_key will be generated internally. + * net_idx: If it is going to be generated internally, it should be set to + * 0xFFFF, and the new net_idx will be reported via an event. + * + * @return ESP_OK on success or error code otherwise. + * + */ +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. + * + * @param[in] net_idx: Network key index. + * + * @return Network key on success, or NULL on failure. + * + */ +const uint8_t *esp_ble_mesh_provisioner_get_local_net_key(uint16_t net_idx); + +/** + * @brief This function is called by Provisioner to enable or disable receiving + * heartbeat messages. + * + * @note If enabling receiving heartbeat message successfully, the filter will + * be an empty rejectlist by default, which means all heartbeat messages + * received by the Provisioner will be reported to the application layer. + * + * @param[in] enable: Enable or disable receiving heartbeat messages. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_provisioner_recv_heartbeat(bool enable); + +/** + * @brief This function is called by Provisioner to set the heartbeat filter type. + * + * @note 1. If the filter type is not the same with the current value, then all the + * filter entries will be cleaned. + * 2. If the previous type is rejectlist, and changed to acceptlist, then the + * filter will be an empty acceptlist, which means no heartbeat messages + * will be reported. Users need to add SRC or DST into the filter entry, + * then heartbeat messages from the SRC or to the DST will be reported. + * + * @param[in] type: Heartbeat filter type (acceptlist or rejectlist). + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_provisioner_set_heartbeat_filter_type(uint8_t type); + +/** + * @brief This function is called by Provisioner to add or remove a heartbeat filter entry. + * + * @note 1. If the operation is "ADD", the "hb_src" can be set to the SRC (can only be a + * unicast address) of heartbeat messages, and the "hb_dst" can be set to the + * DST (unicast address or group address), at least one of them needs to be set. + * - If only one of them is set, the filter entry will only use the configured + * SRC or DST to filter heartbeat messages. + * - If both of them are set, the SRC and DST will both be used to decide if a + * heartbeat message will be handled. + * - If SRC or DST already exists in some filter entry, then the corresponding + * entry will be cleaned firstly, then a new entry will be allocated to store + * the information. + * 2. If the operation is "REMOVE", the "hb_src" can be set to the SRC (can only be + * a unicast address) of heartbeat messages, and the "hb_dst" can be set to the + * DST (unicast address or group address), at least one of them needs to be set. + * - The filter entry with the same SRC or DST will be removed. + * + * @param[in] op: Add or REMOVE + * @param[in] info: Heartbeat filter entry information, including: + * hb_src - Heartbeat source address; + * hb_dst - Heartbeat destination address; + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_provisioner_set_heartbeat_filter_info(uint8_t op, esp_ble_mesh_heartbeat_filter_info_t *info); + +/** + * @brief This function is called by Provisioner to directly erase the mesh + * information from nvs namespace. + * + * @note This function can be invoked when the mesh stack is not initialized + * or has been de-initialized. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_provisioner_direct_erase_settings(void); + +/** + * @brief This function is called by Provisioner to open a nvs namespace + * for storing mesh information. + * + * @note Before open another nvs namespace, the previously opened nvs + * namespace must be closed firstly. + * + * @param[in] index: Settings index. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_provisioner_open_settings_with_index(uint8_t index); + +/** + * @brief This function is called by Provisioner to open a nvs namespace + * for storing mesh information. + * + * @note Before open another nvs namespace, the previously opened nvs + * namespace must be closed firstly. + * + * @param[in] uid: Settings user id. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_provisioner_open_settings_with_uid(const char *uid); + +/** + * @brief This function is called by Provisioner to close a nvs namespace + * which is opened previously for storing mesh information. + * + * @note 1. Before closing the nvs namespace, it must be open. + * 2. When the function is invoked, the Provisioner functionality + * will be disabled firstly, and: + * a) If the "erase" flag is set to false, the mesh information + * will be cleaned (e.g. removing NetKey, AppKey, nodes, etc) + * from the mesh stack. + * b) If the "erase" flag is set to true, the mesh information + * stored in the nvs namespace will also be erased besides + * been cleaned from the mesh stack. + * 3. If Provisioner tries to work properly again, we can invoke the + * open function to open a new nvs namespace or a previously added + * one, and restore the mesh information from it if not erased. + * 4. The working process shall be as following: + * a) Open settings A + * b) Start to provision and control nodes + * c) Close settings A + * d) Open settings B + * e) Start to provision and control other nodes + * f) Close settings B + * g) ...... + * + * @param[in] index: Settings index. + * @param[in] erase: Indicate if erasing mesh information. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_provisioner_close_settings_with_index(uint8_t index, bool erase); + +/** + * @brief This function is called by Provisioner to close a nvs namespace + * which is opened previously for storing mesh information. + * + * @note 1. Before closing the nvs namespace, it must be open. + * 2. When the function is invoked, the Provisioner functionality + * will be disabled firstly, and: + * a) If the "erase" flag is set to false, the mesh information + * will be cleaned (e.g. removing NetKey, AppKey, nodes, etc) + * from the mesh stack. + * b) If the "erase" flag is set to true, the mesh information + * stored in the nvs namespace will also be erased besides + * been cleaned from the mesh stack. + * 3. If Provisioner tries to work properly again, we can invoke the + * open function to open a new nvs namespace or a previously added + * one, and restore the mesh information from it if not erased. + * 4. The working process shall be as following: + * a) Open settings A + * b) Start to provision and control nodes + * c) Close settings A + * d) Open settings B + * e) Start to provision and control other nodes + * f) Close settings B + * g) ...... + * + * @param[in] uid: Settings user id. + * @param[in] erase: Indicate if erasing mesh information. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_provisioner_close_settings_with_uid(const char *uid, bool erase); + +/** + * @brief This function is called by Provisioner to erase the mesh information + * and settings user id from a nvs namespace. + * + * @note When this function is called, the nvs namespace must not be open. + * This function is used to erase the mesh information and settings + * user id which are not used currently. + * + * @param[in] index: Settings index. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_provisioner_delete_settings_with_index(uint8_t index); + +/** + * @brief This function is called by Provisioner to erase the mesh information + * and settings user id from a nvs namespace. + * + * @note When this function is called, the nvs namespace must not be open. + * This function is used to erase the mesh information and settings + * user id which are not used currently. + * + * @param[in] uid: Settings user id. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_provisioner_delete_settings_with_uid(const char *uid); + +/** + * @brief This function is called by Provisioner to get settings user id. + * + * @param[in] index: Settings index. + * + * @return Setting user id on success or NULL on failure. + * + */ +const char *esp_ble_mesh_provisioner_get_settings_uid(uint8_t index); + +/** + * @brief This function is called by Provisioner to get settings index. + * + * @param[in] uid: Settings user id. + * + * @return Settings index. + * + */ +uint8_t esp_ble_mesh_provisioner_get_settings_index(const char *uid); + +/** + * @brief This function is called by Provisioner to get the number of free + * settings user id. + * + * @return Number of free settings user id. + * + */ +uint8_t esp_ble_mesh_provisioner_get_free_settings_count(void); + +/** + * @brief This function is called to get fast provisioning application key. + * + * @param[in] net_idx: Network key index. + * @param[in] app_idx: Application key index. + * + * @return Application key on success, or NULL on failure. + * + */ +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_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_provisioning_api.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_provisioning_api.h new file mode 100644 index 00000000000..58ad280468f --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_provisioning_api.h @@ -0,0 +1,394 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _ESP_BLE_MESH_PROVISIONING_API_H_ +#define _ESP_BLE_MESH_PROVISIONING_API_H_ + +#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); + +/** + * @brief Register BLE Mesh provisioning 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_prov_callback(esp_ble_mesh_prov_cb_t callback); + +/** + * @brief Check if a device has been provisioned. + * + * @return TRUE if the device is provisioned, FALSE if the device is unprovisioned. + * + */ +bool esp_ble_mesh_node_is_provisioned(void); + +/** + * @brief Enable specific provisioning bearers to get the device ready for provisioning. + * + * @note PB-ADV: send unprovisioned device beacon. + * PB-GATT: send connectable advertising packets. + * + * @param bearers: Bit-wise OR of provisioning bearers. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_node_prov_enable(esp_ble_mesh_prov_bearer_t bearers); + +/** + * @brief Disable specific provisioning bearers to make a device inaccessible for provisioning. + * + * @param bearers: Bit-wise OR of provisioning bearers. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_node_prov_disable(esp_ble_mesh_prov_bearer_t bearers); + +/** + * @brief Unprovisioned device set own oob public key & private key pair. + * + * @note In order to avoid suffering brute-forcing attack (CVE-2020-26559). + * The Bluetooth SIG recommends that potentially vulnerable mesh provisioners + * use an out-of-band mechanism to exchange the public keys. + * So as an unprovisioned device, it should use this function to input + * the Public Key exchanged through the out-of-band mechanism. + * + * @param[in] pub_key_x: Unprovisioned device's Public Key X + * @param[in] pub_key_y: Unprovisioned device's Public Key Y + * @param[in] private_key: Unprovisioned device's Private Key + * + * @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]); + +/** + * @brief Provide provisioning input OOB number. + * + * @note This is intended to be called if the user has received ESP_BLE_MESH_NODE_PROV_INPUT_EVT + * with ESP_BLE_MESH_ENTER_NUMBER as the action. + * + * @param[in] number: Number input by device. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_node_input_number(uint32_t number); + +/** + * @brief Provide provisioning input OOB string. + * + * @note This is intended to be called if the user has received ESP_BLE_MESH_NODE_PROV_INPUT_EVT + * with ESP_BLE_MESH_ENTER_STRING as the action. + * + * @param[in] string: String input by device. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_node_input_string(const char *string); + +/** + * @brief Using this function, an unprovisioned device can set its own device name, + * which will be broadcasted in its advertising data. + * + * @param[in] name: Unprovisioned device name + * + * @note This API applicable to PB-GATT mode only by setting the name to the scan response data, + * it doesn't apply to PB-ADV mode. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_set_unprovisioned_device_name(const char *name); + +/** + * @brief Provisioner inputs unprovisioned device's oob public key. + * + * @note In order to avoid suffering brute-forcing attack (CVE-2020-26559). + * The Bluetooth SIG recommends that potentially vulnerable mesh provisioners + * use an out-of-band mechanism to exchange the public keys. + * + * @param[in] link_idx: The provisioning link index + * @param[in] pub_key_x: Unprovisioned device's Public Key X + * @param[in] pub_key_y: Unprovisioned device's Public Key Y + * + * @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]); + +/** + * @brief Provide provisioning input OOB string. + * + * This is intended to be called after the esp_ble_mesh_prov_t prov_input_num + * callback has been called with ESP_BLE_MESH_ENTER_STRING as the action. + * + * @param[in] string: String input by Provisioner. + * @param[in] link_idx: The provisioning link index. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_provisioner_input_string(const char *string, uint8_t link_idx); + +/** + * @brief Provide provisioning input OOB number. + * + * This is intended to be called after the esp_ble_mesh_prov_t prov_input_num + * callback has been called with ESP_BLE_MESH_ENTER_NUMBER as the action. + * + * @param[in] number: Number input by Provisioner. + * @param[in] link_idx: The provisioning link index. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_provisioner_input_number(uint32_t number, uint8_t link_idx); + +/** + * @brief Enable one or more provisioning bearers. + * + * @param[in] bearers: Bit-wise OR of provisioning bearers. + * + * @note PB-ADV: Enable BLE scan. + * PB-GATT: Initialize corresponding BLE Mesh Proxy info. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_provisioner_prov_enable(esp_ble_mesh_prov_bearer_t bearers); + +/** + * @brief Disable one or more provisioning bearers. + * + * @param[in] bearers: Bit-wise OR of provisioning bearers. + * + * @note PB-ADV: Disable BLE scan. + * PB-GATT: Break any existing BLE Mesh Provisioning connections. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_provisioner_prov_disable(esp_ble_mesh_prov_bearer_t bearers); + +/** + * @brief Add unprovisioned device info to the unprov_dev queue. + * + * @param[in] add_dev: Pointer to a struct containing the device information + * @param[in] flags: Flags indicate several operations on the device information + * - Remove device information from queue after device has been provisioned (BIT0) + * - Start provisioning immediately after device is added to queue (BIT1) + * - Device can be removed if device queue is full (BIT2) + * + * @return ESP_OK on success or error code otherwise. + * + * @note: 1. Currently address type only supports public address and static random address. + * 2. If device UUID and/or device address as well as address type already exist in the + * device queue, but the bearer is different from the existing one, add operation + * will also be successful and it will update the provision bearer supported by + * the device. + * 3. For example, if the Provisioner wants to add an unprovisioned device info before + * receiving its unprovisioned device beacon or Mesh Provisioning advertising packets, + * the Provisioner can use this API to add the device info with each one or both of + * device UUID and device address added. When the Provisioner gets the device's + * advertising packets, it will start provisioning the device internally. + * - In this situation, the Provisioner can set bearers with each one or both of + * ESP_BLE_MESH_PROV_ADV and ESP_BLE_MESH_PROV_GATT enabled, and cannot set flags + * with ADD_DEV_START_PROV_NOW_FLAG enabled. + * 4. Another example is when the Provisioner receives the unprovisioned device's beacon or + * Mesh Provisioning advertising packets, the advertising packets will be reported on to + * the application layer using the callback registered by the function + * esp_ble_mesh_register_prov_callback. And in the callback, the Provisioner + * can call this API to start provisioning the device. + * - If the Provisioner uses PB-ADV to provision, either one or both of device UUID and + * device address can be added, bearers shall be set with ESP_BLE_MESH_PROV_ADV + * enabled and the flags shall be set with ADD_DEV_START_PROV_NOW_FLAG enabled. + * - If the Provisioner uses PB-GATT to provision, both the device UUID and device + * address need to be added, bearers shall be set with ESP_BLE_MESH_PROV_GATT enabled, + * and the flags shall be set with ADD_DEV_START_PROV_NOW_FLAG enabled. + * - If the Provisioner just wants to store the unprovisioned device info when receiving + * its advertising packets and start to provision it the next time (e.g. after receiving + * its advertising packets again), then it can add the device info with either one or both + * of device UUID and device address included. Bearers can be set with either one or both + * of ESP_BLE_MESH_PROV_ADV and ESP_BLE_MESH_PROV_GATT enabled (recommend to enable the + * bearer which will receive its advertising packets, because if the other bearer is + * enabled, the Provisioner is not aware if the device supports the bearer), and flags + * cannot be set with ADD_DEV_START_PROV_NOW_FLAG enabled. + * - Note: ESP_BLE_MESH_PROV_ADV, ESP_BLE_MESH_PROV_GATT and ADD_DEV_START_PROV_NOW_FLAG + * can not be enabled at the same time. + * + */ +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); + +/** @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, and reset current provisioning link with the device. + * + * @note If the device is in the queue, remove it from the queue; if the device is + * being provisioned, terminate the provisioning procedure. Either one of the + * device address or device UUID can be used as input. + * + * @param[in] del_dev: Pointer to a struct containing the device information. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_provisioner_delete_dev(esp_ble_mesh_device_delete_t *del_dev); + +/** + * @brief Callback for Provisioner that received advertising packets from unprovisioned devices which are + * not in the unprovisioned device queue. + * + * Report on the unprovisioned device beacon and mesh provisioning service adv data to application. + * + * @param[in] addr: Pointer to the unprovisioned device address. + * @param[in] addr_type: Unprovisioned device address type. + * @param[in] adv_type: Adv packet type(ADV_IND or ADV_NONCONN_IND). + * @param[in] dev_uuid: Unprovisioned device UUID pointer. + * @param[in] oob_info: OOB information of the unprovisioned device. + * @param[in] bearer: Adv packet received from PB-GATT or PB-ADV 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 + * to be compared before starting to provision. + * + * @param[in] match_val: Value to be compared with the part of the device UUID. + * @param[in] match_len: Length of the compared match value. + * @param[in] offset: Offset of the device UUID to be compared (based on zero). + * @param[in] prov_after_match: Flag used to indicate whether provisioner should start to provision + * the device immediately if the part of the UUID matches. + * + * @return ESP_OK on success or error code otherwise. + * + */ +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); + +/** + * @brief This function is called by Provisioner to set provisioning data information + * before starting to provision. + * + * @param[in] prov_data_info: Pointer to a struct containing net_idx or flags or iv_index. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_provisioner_set_prov_data_info(esp_ble_mesh_prov_data_info_t *prov_data_info); + +/** + * @brief This function is called by Provisioner to set static oob value used for provisioning. + * + * @note The Bluetooth SIG recommends that mesh implementations enforce a randomly selected + * AuthValue using all of the available bits, where permitted by the implementation. + * A large entropy helps ensure that a brute-force of the AuthValue, even a static + * AuthValue, cannot normally be completed in a reasonable time (CVE-2020-26557). + * + * AuthValues selected using a cryptographically secure random or pseudorandom number + * generator and having the maximum permitted entropy (128-bits) will be most difficult + * to brute-force. AuthValues with reduced entropy or generated in a predictable manner + * will not grant the same level of protection against this vulnerability. Selecting a + * new AuthValue with each provisioning attempt can also make it more difficult to launch + * a brute-force attack by requiring the attacker to restart the search with each + * provisioning attempt (CVE-2020-26556). + * + * @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. + * + * @param[in] fast_prov_info: Pointer to a struct containing unicast address range, net_idx, etc. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_set_fast_prov_info(esp_ble_mesh_fast_prov_info_t *fast_prov_info); + +/** + * @brief This function is called to start/suspend/exit fast provisioning. + * + * @param[in] action: fast provisioning action (i.e. enter, suspend, exit). + * + * @return ESP_OK on success or error code otherwise. + * + */ +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_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_proxy_api.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_proxy_api.h new file mode 100644 index 00000000000..c29e284481e --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_proxy_api.h @@ -0,0 +1,118 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _ESP_BLE_MESH_PROXY_API_H_ +#define _ESP_BLE_MESH_PROXY_API_H_ + +#include "esp_ble_mesh_defs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Enable advertising with Node Identity. + * + * @note This API requires that GATT Proxy support be enabled. Once called, + * each subnet starts advertising using Node Identity for the next 60 + * seconds, and after 60s Network ID will be advertised. + * Under normal conditions, the BLE Mesh Proxy Node Identity and + * Network ID advertising will be enabled automatically by BLE Mesh + * stack after the device is provisioned. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_proxy_identity_enable(void); + +/** + * @brief Enable BLE Mesh GATT Proxy Service. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_proxy_gatt_enable(void); + +/** + * @brief Disconnect the BLE Mesh GATT Proxy connection if there is any, and + * disable the BLE Mesh GATT Proxy Service. + * + * @return ESP_OK on success or error code otherwise. + * + */ +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_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/api/esp_ble_mesh_defs.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/api/esp_ble_mesh_defs.h new file mode 100644 index 00000000000..3fff33363be --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/api/esp_ble_mesh_defs.h @@ -0,0 +1,2275 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _ESP_BLE_MESH_DEFS_H_ +#define _ESP_BLE_MESH_DEFS_H_ + +#include + +#include "mesh_config.h" +#include "mesh_common.h" +#include "proxy_server.h" +#include "provisioner_main.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*!< The maximum length of a BLE Mesh message, including Opcode, Payload and TransMIC */ +#define ESP_BLE_MESH_SDU_MAX_LEN 384 + +/*!< Length of a short Mesh MIC. */ +#define ESP_BLE_MESH_MIC_SHORT 4 + +/*!< Length of a long Mesh MIC. */ +#define ESP_BLE_MESH_MIC_LONG 8 + +/*!< The maximum length of a BLE Mesh provisioned node name */ +#define ESP_BLE_MESH_NODE_NAME_MAX_LEN 31 + +/*!< The maximum length of a BLE Mesh unprovisioned device name */ +#define ESP_BLE_MESH_DEVICE_NAME_MAX_LEN DEVICE_NAME_SIZE + +/*!< The maximum length of settings user id */ +#define ESP_BLE_MESH_SETTINGS_UID_SIZE 20 + +/*!< Invalid settings index */ +#define ESP_BLE_MESH_INVALID_SETTINGS_IDX 0xFF + +/*!< Define the BLE Mesh octet 16 bytes size */ +#define ESP_BLE_MESH_OCTET16_LEN 16 +typedef uint8_t esp_ble_mesh_octet16_t[ESP_BLE_MESH_OCTET16_LEN]; + +/*!< Define the BLE Mesh octet 8 bytes size */ +#define ESP_BLE_MESH_OCTET8_LEN 8 +typedef uint8_t esp_ble_mesh_octet8_t[ESP_BLE_MESH_OCTET8_LEN]; + +/*!< Invalid Company ID */ +#define ESP_BLE_MESH_CID_NVAL 0xFFFF + +/*!< Special TTL value to request using configured default TTL */ +#define ESP_BLE_MESH_TTL_DEFAULT 0xFF + +/*!< Maximum allowed TTL value */ +#define ESP_BLE_MESH_TTL_MAX 0x7F + +#define ESP_BLE_MESH_ADDR_UNASSIGNED 0x0000 +#define ESP_BLE_MESH_ADDR_ALL_NODES 0xFFFF +#define ESP_BLE_MESH_ADDR_PROXIES 0xFFFC +#define ESP_BLE_MESH_ADDR_FRIENDS 0xFFFD +#define ESP_BLE_MESH_ADDR_RELAYS 0xFFFE + +#define ESP_BLE_MESH_KEY_UNUSED 0xFFFF +#define ESP_BLE_MESH_KEY_DEV 0xFFFE + +#define ESP_BLE_MESH_KEY_PRIMARY 0x0000 +#define ESP_BLE_MESH_KEY_ANY 0xFFFF + +/*!< Primary Network Key index */ +#define ESP_BLE_MESH_NET_PRIMARY 0x000 + +/*!< Relay state value */ +#define ESP_BLE_MESH_RELAY_DISABLED 0x00 +#define ESP_BLE_MESH_RELAY_ENABLED 0x01 +#define ESP_BLE_MESH_RELAY_NOT_SUPPORTED 0x02 + +/*!< Beacon state value */ +#define ESP_BLE_MESH_BEACON_DISABLED 0x00 +#define ESP_BLE_MESH_BEACON_ENABLED 0x01 + +/*!< GATT Proxy state value */ +#define ESP_BLE_MESH_GATT_PROXY_DISABLED 0x00 +#define ESP_BLE_MESH_GATT_PROXY_ENABLED 0x01 +#define ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED 0x02 + +/*!< Friend state value */ +#define ESP_BLE_MESH_FRIEND_DISABLED 0x00 +#define ESP_BLE_MESH_FRIEND_ENABLED 0x01 +#define ESP_BLE_MESH_FRIEND_NOT_SUPPORTED 0x02 + +/*!< Node identity state value */ +#define ESP_BLE_MESH_NODE_IDENTITY_STOPPED 0x00 +#define ESP_BLE_MESH_NODE_IDENTITY_RUNNING 0x01 +#define ESP_BLE_MESH_NODE_IDENTITY_NOT_SUPPORTED 0x02 + +/*!< Supported features */ +#define ESP_BLE_MESH_FEATURE_RELAY BIT(0) +#define ESP_BLE_MESH_FEATURE_PROXY BIT(1) +#define ESP_BLE_MESH_FEATURE_FRIEND BIT(2) +#define ESP_BLE_MESH_FEATURE_LOW_POWER BIT(3) +#define ESP_BLE_MESH_FEATURE_ALL_SUPPORTED (ESP_BLE_MESH_FEATURE_RELAY | \ + ESP_BLE_MESH_FEATURE_PROXY | \ + ESP_BLE_MESH_FEATURE_FRIEND | \ + ESP_BLE_MESH_FEATURE_LOW_POWER) + +#define ESP_BLE_MESH_ADDR_IS_UNICAST(addr) ((addr) && (addr) < 0x8000) +#define ESP_BLE_MESH_ADDR_IS_GROUP(addr) ((addr) >= 0xC000 && (addr) <= 0xFF00) +#define ESP_BLE_MESH_ADDR_IS_VIRTUAL(addr) ((addr) >= 0x8000 && (addr) < 0xC000) +#define ESP_BLE_MESH_ADDR_IS_RFU(addr) ((addr) >= 0xFF00 && (addr) <= 0xFFFB) + +#define ESP_BLE_MESH_INVALID_NODE_INDEX 0xFFFF + +/** @def ESP_BLE_MESH_TRANSMIT + * + * @brief Encode transmission count & interval steps. + * + * @note For example, ESP_BLE_MESH_TRANSMIT(2, 20) means that the message + * will be sent about 90ms(count is 3, step is 1, interval is 30 ms + * which includes 10ms of advertising interval random delay). + * + * @param count Number of retransmissions (first transmission is excluded). + * @param int_ms Interval steps in milliseconds. Must be greater than 0 + * and a multiple of 10. + * + * @return BLE Mesh transmit value that can be used e.g. for the default + * values of the Configuration Model data. + */ +#define ESP_BLE_MESH_TRANSMIT(count, int_ms) ((count) | (((int_ms / 10) - 1) << 3)) + +/** @def ESP_BLE_MESH_GET_TRANSMIT_COUNT + * + * @brief Decode transmit count from a transmit value. + * + * @param transmit Encoded transmit count & interval value. + * + * @return Transmission count (actual transmissions equal to N + 1). + */ +#define ESP_BLE_MESH_GET_TRANSMIT_COUNT(transmit) (((transmit) & (uint8_t)BIT_MASK(3))) + +/** @def ESP_BLE_MESH_GET_TRANSMIT_INTERVAL + * + * @brief Decode transmit interval from a transmit value. + * + * @param transmit Encoded transmit count & interval value. + * + * @return Transmission interval in milliseconds. + */ +#define ESP_BLE_MESH_GET_TRANSMIT_INTERVAL(transmit) ((((transmit) >> 3) + 1) * 10) + +/** @def ESP_BLE_MESH_PUBLISH_TRANSMIT + * + * @brief Encode Publish Retransmit count & interval steps. + * + * @param count Number of retransmissions (first transmission is excluded). + * @param int_ms Interval steps in milliseconds. Must be greater than 0 + * and a multiple of 50. + * + * @return BLE Mesh transmit value that can be used e.g. for the default + * values of the Configuration Model data. + */ +#define ESP_BLE_MESH_PUBLISH_TRANSMIT(count, int_ms) ESP_BLE_MESH_TRANSMIT(count, (int_ms) / 5) + +/** @def ESP_BLE_MESH_GET_PUBLISH_TRANSMIT_COUNT + * + * @brief Decode Publish Retransmit count from a given value. + * + * @param transmit Encoded Publish Retransmit count & interval value. + * + * @return Retransmission count (actual transmissions equal to N + 1). + */ +#define ESP_BLE_MESH_GET_PUBLISH_TRANSMIT_COUNT(transmit) ESP_BLE_MESH_GET_TRANSMIT_COUNT(transmit) + +/** @def ESP_BLE_MESH_GET_PUBLISH_TRANSMIT_INTERVAL + * + * @brief Decode Publish Retransmit interval from a given value. + * + * @param transmit Encoded Publish Retransmit count & interval value. + * + * @return Transmission interval in milliseconds. + */ +#define ESP_BLE_MESH_GET_PUBLISH_TRANSMIT_INTERVAL(transmit) ((((transmit) >> 3) + 1) * 50) + +/*!< Callbacks which are not needed to be initialized by users (set with 0 and will be initialized internally) */ +typedef uint32_t esp_ble_mesh_cb_t; + +typedef enum { + ESP_BLE_MESH_TYPE_PROV_CB, + ESP_BLE_MESH_TYPE_OUTPUT_NUM_CB, + ESP_BLE_MESH_TYPE_OUTPUT_STR_CB, + ESP_BLE_MESH_TYPE_INTPUT_CB, + ESP_BLE_MESH_TYPE_LINK_OPEN_CB, + ESP_BLE_MESH_TYPE_LINK_CLOSE_CB, + ESP_BLE_MESH_TYPE_COMPLETE_CB, + ESP_BLE_MESH_TYPE_RESET_CB, +} esp_ble_mesh_cb_type_t; + +/*!< This enum value is provisioning authentication oob method */ +typedef enum { + ESP_BLE_MESH_NO_OOB, + ESP_BLE_MESH_STATIC_OOB, + ESP_BLE_MESH_OUTPUT_OOB, + ESP_BLE_MESH_INPUT_OOB, +} esp_ble_mesh_oob_method_t; + +/*!< This enum value is associated with bt_mesh_output_action_t in mesh_main.h */ +typedef enum { + ESP_BLE_MESH_NO_OUTPUT = 0, + ESP_BLE_MESH_BLINK = BIT(0), + ESP_BLE_MESH_BEEP = BIT(1), + ESP_BLE_MESH_VIBRATE = BIT(2), + ESP_BLE_MESH_DISPLAY_NUMBER = BIT(3), + ESP_BLE_MESH_DISPLAY_STRING = BIT(4), +} esp_ble_mesh_output_action_t; + +/*!< This enum value is associated with bt_mesh_input_action_t in mesh_main.h */ +typedef enum { + ESP_BLE_MESH_NO_INPUT = 0, + ESP_BLE_MESH_PUSH = BIT(0), + ESP_BLE_MESH_TWIST = BIT(1), + ESP_BLE_MESH_ENTER_NUMBER = BIT(2), + ESP_BLE_MESH_ENTER_STRING = BIT(3), +} esp_ble_mesh_input_action_t; + +/*!< This enum value is associated with bt_mesh_prov_bearer_t in mesh_main.h */ +typedef enum { + ESP_BLE_MESH_PROV_ADV = BIT(0), + ESP_BLE_MESH_PROV_GATT = BIT(1), +} esp_ble_mesh_prov_bearer_t; + +/*!< This enum value is associated with bt_mesh_prov_oob_info_t in mesh_main.h */ +typedef enum { + ESP_BLE_MESH_PROV_OOB_OTHER = BIT(0), + ESP_BLE_MESH_PROV_OOB_URI = BIT(1), + ESP_BLE_MESH_PROV_OOB_2D_CODE = BIT(2), + ESP_BLE_MESH_PROV_OOB_BAR_CODE = BIT(3), + ESP_BLE_MESH_PROV_OOB_NFC = BIT(4), + ESP_BLE_MESH_PROV_OOB_NUMBER = BIT(5), + ESP_BLE_MESH_PROV_OOB_STRING = BIT(6), + /* 7 - 10 are reserved */ + ESP_BLE_MESH_PROV_OOB_ON_BOX = BIT(11), + ESP_BLE_MESH_PROV_OOB_IN_BOX = BIT(12), + ESP_BLE_MESH_PROV_OOB_ON_PAPER = BIT(13), + ESP_BLE_MESH_PROV_OOB_IN_MANUAL = BIT(14), + ESP_BLE_MESH_PROV_OOB_ON_DEV = BIT(15), +} esp_ble_mesh_prov_oob_info_t; + +/*!< Maximum length of value used by Static OOB authentication */ +#define ESP_BLE_MESH_PROV_STATIC_OOB_MAX_LEN 16 + +/*!< Maximum length of string used by Output OOB authentication */ +#define ESP_BLE_MESH_PROV_OUTPUT_OOB_MAX_LEN 8 + +/*!< Maximum length of string used by Output OOB authentication */ +#define ESP_BLE_MESH_PROV_INPUT_OOB_MAX_LEN 8 + +/*!< Macros used to define message opcode */ +#define ESP_BLE_MESH_MODEL_OP_1(b0) (b0) +#define ESP_BLE_MESH_MODEL_OP_2(b0, b1) (((b0) << 8) | (b1)) +#define ESP_BLE_MESH_MODEL_OP_3(b0, cid) ((((b0) << 16) | 0xC00000) | (cid)) + +/*!< This macro is associated with BLE_MESH_MODEL_CB in mesh_access.h */ +#define ESP_BLE_MESH_SIG_MODEL(_id, _op, _pub, _user_data) \ +{ \ + .model_id = (_id), \ + .op = _op, \ + .keys = { [0 ... (CONFIG_BLE_MESH_MODEL_KEY_COUNT - 1)] = \ + ESP_BLE_MESH_KEY_UNUSED }, \ + .pub = _pub, \ + .groups = { [0 ... (CONFIG_BLE_MESH_MODEL_GROUP_COUNT - 1)] = \ + ESP_BLE_MESH_ADDR_UNASSIGNED }, \ + .user_data = _user_data, \ +} + +/*!< This macro is associated with BLE_MESH_MODEL_VND_CB in mesh_access.h */ +#define ESP_BLE_MESH_VENDOR_MODEL(_company, _id, _op, _pub, _user_data) \ +{ \ + .vnd.company_id = (_company), \ + .vnd.model_id = (_id), \ + .op = _op, \ + .pub = _pub, \ + .keys = { [0 ... (CONFIG_BLE_MESH_MODEL_KEY_COUNT - 1)] = \ + ESP_BLE_MESH_KEY_UNUSED }, \ + .groups = { [0 ... (CONFIG_BLE_MESH_MODEL_GROUP_COUNT - 1)] = \ + ESP_BLE_MESH_ADDR_UNASSIGNED }, \ + .user_data = _user_data, \ +} + +/** @brief Helper to define a BLE Mesh element within an array. + * + * In case the element has no SIG or Vendor models, the helper + * macro ESP_BLE_MESH_MODEL_NONE can be given instead. + * + * @note This macro is associated with BLE_MESH_ELEM in mesh_access.h + * + * @param _loc Location Descriptor. + * @param _mods Array of SIG models. + * @param _vnd_mods Array of vendor models. + */ +#define ESP_BLE_MESH_ELEMENT(_loc, _mods, _vnd_mods) \ +{ \ + .location = (_loc), \ + .sig_model_count = ARRAY_SIZE(_mods), \ + .sig_models = (_mods), \ + .vnd_model_count = ARRAY_SIZE(_vnd_mods), \ + .vnd_models = (_vnd_mods), \ +} + +#define ESP_BLE_MESH_PROV(uuid, sta_val, sta_val_len, out_size, out_act, in_size, in_act) { \ + .uuid = uuid, \ + .static_val = sta_val, \ + .static_val_len = sta_val_len, \ + .output_size = out_size, \ + .output_action = out_act, \ + .input_size = in_size, \ + .input_action = in_act, \ +} + +typedef uint8_t UINT8; +typedef uint16_t UINT16; +typedef uint32_t UINT32; +typedef uint64_t UINT64; + +#define BT_OCTET32_LEN 32 +typedef UINT8 BT_OCTET32[BT_OCTET32_LEN]; /* octet array: size 32 */ + + +#ifndef BD_ADDR_LEN +#define BD_ADDR_LEN 6 +typedef uint8_t BD_ADDR[BD_ADDR_LEN]; +#endif + +typedef uint8_t esp_ble_mesh_bd_addr_t[BD_ADDR_LEN]; + +#define ESP_BLE_MESH_ADDR_TYPE_PUBLIC 0x00 +#define ESP_BLE_MESH_ADDR_TYPE_RANDOM 0x01 +#define ESP_BLE_MESH_ADDR_TYPE_RPA_PUBLIC 0x02 +#define ESP_BLE_MESH_ADDR_TYPE_RPA_RANDOM 0x03 +/// BLE device address type +typedef uint8_t esp_ble_mesh_addr_type_t; + +/** BLE Mesh deinit parameters */ +typedef struct { + bool erase_flash; /*!< Indicate if erasing flash when deinit mesh stack */ +} esp_ble_mesh_deinit_param_t; + +typedef struct esp_ble_mesh_model esp_ble_mesh_model_t; + +/** Abstraction that describes a BLE Mesh Element. + * This structure is associated with struct bt_mesh_elem in mesh_access.h + */ +typedef struct { + /** Element Address, assigned during provisioning. */ + uint16_t element_addr; + + /** Location Descriptor (GATT Bluetooth Namespace Descriptors) */ + const uint16_t location; + + const uint8_t sig_model_count; /*!< SIG Model count */ + const uint8_t vnd_model_count; /*!< Vendor Model count */ + + esp_ble_mesh_model_t *sig_models; /*!< SIG Models */ + esp_ble_mesh_model_t *vnd_models; /*!< Vendor Models */ +} esp_ble_mesh_elem_t; + +/** Abstraction that describes a model publication context. + * This structure is associated with struct bt_mesh_model_pub in mesh_access.h + */ +typedef struct { + /** Pointer to the model to which the context belongs. Initialized by the stack. */ + esp_ble_mesh_model_t *model; + + uint16_t publish_addr; /*!< Publish Address. */ + uint16_t app_idx:12, /*!< Publish AppKey Index. */ + cred:1, /*!< Friendship Credentials Flag. */ + send_rel:1; /*!< Force reliable sending (segment acks) */ + + uint8_t ttl; /*!< Publish Time to Live. */ + uint8_t retransmit; /*!< Retransmit Count & Interval Steps. */ + + uint8_t period; /*!< Publish Period. */ + uint8_t period_div:4, /*!< Divisor for the Period. */ + fast_period:1, /*!< Use FastPeriodDivisor */ + count:3; /*!< Retransmissions left. */ + + uint32_t period_start; /*!< Start of the current period. */ + + /** @brief Publication buffer, containing the publication message. + * + * This will get correctly created when the publication context + * has been defined using the ESP_BLE_MESH_MODEL_PUB_DEFINE macro. + * + * ESP_BLE_MESH_MODEL_PUB_DEFINE(name, size); + */ + struct net_buf_simple *msg; + + /** Callback used to update publish message. Initialized by the stack. */ + esp_ble_mesh_cb_t update; + + /** Publish Period Timer. Initialized by the stack. */ + struct k_delayed_work timer; + + /** Role of the device that is going to publish messages */ + uint8_t dev_role; +} esp_ble_mesh_model_pub_t; + +/** @def ESP_BLE_MESH_MODEL_PUB_DEFINE + * + * Define a model publication context. + * + * @param _name Variable name given to the context. + * @param _msg_len Length of the publication message. + * @param _role Role of the device which contains the model. + */ +#define ESP_BLE_MESH_MODEL_PUB_DEFINE(_name, _msg_len, _role) \ + NET_BUF_SIMPLE_DEFINE_STATIC(bt_mesh_pub_msg_##_name, _msg_len); \ + static esp_ble_mesh_model_pub_t _name = { \ + .update = (uint32_t)NULL, \ + .msg = &bt_mesh_pub_msg_##_name, \ + .dev_role = _role, \ + } + +/** @def ESP_BLE_MESH_MODEL_OP + * + * Define a model operation context. + * + * @param _opcode Message opcode. + * @param _min_len Message minimum length. + */ +#define ESP_BLE_MESH_MODEL_OP(_opcode, _min_len) \ +{ \ + .opcode = _opcode, \ + .min_len = _min_len, \ + .param_cb = (uint32_t)NULL, \ +} + +/** Abstraction that describes a model operation context. + * This structure is associated with struct bt_mesh_model_op in mesh_access.h + */ +typedef struct { + const uint32_t opcode; /*!< Message opcode */ + const size_t min_len; /*!< Message minimum length */ + esp_ble_mesh_cb_t param_cb; /*!< Callback used to handle message. Initialized by the stack. */ +} esp_ble_mesh_model_op_t; + +/** Define the terminator for the model operation table. + * Each model operation struct array must use this terminator as + * the end tag of the operation unit. + */ +#define ESP_BLE_MESH_MODEL_OP_END {0, 0, 0} + +/** Abstraction that describes a model callback structure. + * This structure is associated with struct bt_mesh_model_cb in mesh_access.h. + */ +typedef struct { + /** Callback used during model initialization. Initialized by the stack. */ + esp_ble_mesh_cb_t init_cb; + +#if CONFIG_BLE_MESH_DEINIT + /** Callback used during model deinitialization. Initialized by the stack. */ + esp_ble_mesh_cb_t deinit_cb; +#endif /* CONFIG_BLE_MESH_DEINIT */ +} esp_ble_mesh_model_cbs_t; + +/** Abstraction that describes a Mesh Model instance. + * This structure is associated with struct bt_mesh_model in mesh_access.h + */ +struct esp_ble_mesh_model { + /** Model ID */ + union { + const uint16_t model_id; /*!< 16-bit model identifier */ + struct { + uint16_t company_id; /*!< 16-bit company identifier */ + uint16_t model_id; /*!< 16-bit model identifier */ + } vnd; /*!< Structure encapsulating a model ID with a company ID */ + }; + + /** Internal information, mainly for persistent storage */ + uint8_t element_idx; /*!< Belongs to Nth element */ + uint8_t model_idx; /*!< Is the Nth model in the element */ + uint16_t flags; /*!< Information about what has changed */ + + /** The Element to which this Model belongs */ + esp_ble_mesh_elem_t *element; + + /** Model Publication */ + esp_ble_mesh_model_pub_t *const pub; + + /** AppKey List */ + uint16_t keys[CONFIG_BLE_MESH_MODEL_KEY_COUNT]; + + /** Subscription List (group or virtual addresses) */ + uint16_t groups[CONFIG_BLE_MESH_MODEL_GROUP_COUNT]; + + /** Model operation context */ + esp_ble_mesh_model_op_t *op; + + /** Model callback structure */ + esp_ble_mesh_model_cbs_t *cb; + + /** Model-specific user data */ + void *user_data; +}; + +/** Helper to define an empty model array. + * This structure is associated with BLE_MESH_MODEL_NONE in mesh_access.h + */ +#define ESP_BLE_MESH_MODEL_NONE ((esp_ble_mesh_model_t []){}) + +/** Message sending context. + * This structure is associated with struct bt_mesh_msg_ctx in mesh_access.h + */ +typedef struct { + /** NetKey Index of the subnet through which to send the message. */ + uint16_t net_idx; + + /** AppKey Index for message encryption. */ + uint16_t app_idx; + + /** Remote address. */ + uint16_t addr; + + /** Destination address of a received message. Not used for sending. */ + uint16_t recv_dst; + + /** RSSI of received packet. Not used for sending. */ + int8_t recv_rssi; + + /** Received TTL value. Not used for sending. */ + uint8_t recv_ttl: 7; + + /** Force sending reliably by using segment acknowledgement */ + uint8_t send_rel: 1; + + /** TTL, or ESP_BLE_MESH_TTL_DEFAULT for default TTL. */ + uint8_t send_ttl; + + /** Opcode of a received message. Not used for sending message. */ + uint32_t recv_op; + + /** Model corresponding to the message, no need to be initialized before sending message */ + esp_ble_mesh_model_t *model; + + /** Indicate if the message is sent by a node server model, no need to be initialized before sending message */ + bool srv_send; +} esp_ble_mesh_msg_ctx_t; + +/** Provisioning properties & capabilities. + * This structure is associated with struct bt_mesh_prov in mesh_access.h + */ +typedef struct { +#if CONFIG_BLE_MESH_NODE + /** The UUID that is used when advertising as an unprovisioned device */ + const uint8_t *uuid; + + /** Optional URI. This will be advertised separately from the + * unprovisioned beacon, however the unprovisioned beacon will + * contain a hash of it so the two can be associated by the + * provisioner. + */ + const char *uri; + + /** Out of Band information field. */ + esp_ble_mesh_prov_oob_info_t oob_info; + + /* NOTE: In order to avoid suffering brute-forcing attack (CVE-2020-26559). + * The Bluetooth SIG recommends that potentially vulnerable mesh provisioners + * support an out-of-band mechanism to exchange the public keys. + * So as an unprovisioned device, it should enable this flag to support + * using an out-of-band mechanism to exchange Public Key. + */ + /** Flag indicates whether unprovisioned devices support OOB public key */ + bool oob_pub_key; + + /** Callback used to notify to set OOB Public Key. Initialized by the stack. */ + esp_ble_mesh_cb_t oob_pub_key_cb; + + /** Static OOB value */ + const uint8_t *static_val; + /** Static OOB value length */ + uint8_t static_val_len; + + /** Maximum size of Output OOB supported */ + uint8_t output_size; + /** Supported Output OOB Actions */ + uint16_t output_actions; + + /** Maximum size of Input OOB supported */ + uint8_t input_size; + /** Supported Input OOB Actions */ + uint16_t input_actions; + + /** Callback used to output the number. Initialized by the stack. */ + esp_ble_mesh_cb_t output_num_cb; + /** Callback used to output the string. Initialized by the stack. */ + esp_ble_mesh_cb_t output_str_cb; + /** Callback used to notify to input number/string. Initialized by the stack. */ + esp_ble_mesh_cb_t input_cb; + /** Callback used to indicate that link is opened. Initialized by the stack. */ + esp_ble_mesh_cb_t link_open_cb; + /** Callback used to indicate that link is closed. Initialized by the stack. */ + esp_ble_mesh_cb_t link_close_cb; + /** Callback used to indicate that provisioning is completed. Initialized by the stack. */ + esp_ble_mesh_cb_t complete_cb; + /** Callback used to indicate that node has been reset. Initialized by the stack. */ + esp_ble_mesh_cb_t reset_cb; +#endif /* CONFIG_BLE_MESH_NODE */ + +#ifdef CONFIG_BLE_MESH_PROVISIONER + /** Provisioner device UUID */ + const uint8_t *prov_uuid; + + /** Primary element address of the provisioner */ + const uint16_t prov_unicast_addr; + + /** Pre-incremental unicast address value to be assigned to the first device */ + uint16_t prov_start_address; + + /** Attention timer contained in Provisioning Invite PDU */ + uint8_t prov_attention; + + /** Provisioning Algorithm for the Provisioner */ + uint8_t prov_algorithm; + + /* NOTE: In order to avoid suffering brute-forcing attack (CVE-2020-26559). + * The Bluetooth SIG recommends that potentially vulnerable mesh provisioners + * use an out-of-band mechanism to exchange the public keys. + */ + /** Provisioner public key oob */ + uint8_t prov_pub_key_oob; + + /** Callback used to notify to set device OOB Public Key. Initialized by the stack. */ + esp_ble_mesh_cb_t provisioner_prov_read_oob_pub_key; + + /* NOTE: The Bluetooth SIG recommends that mesh implementations enforce a randomly + * selected AuthValue using all of the available bits, where permitted by the + * implementation. A large entropy helps ensure that a brute-force of the AuthValue, + * even a static AuthValue, cannot normally be completed in a reasonable time (CVE-2020-26557). + * + * AuthValues selected using a cryptographically secure random or pseudorandom number + * generator and having the maximum permitted entropy (128-bits) will be most difficult + * to brute-force. AuthValues with reduced entropy or generated in a predictable manner + * will not grant the same level of protection against this vulnerability. Selecting a + * new AuthValue with each provisioning attempt can also make it more difficult to launch + * a brute-force attack by requiring the attacker to restart the search with each + * provisioning attempt (CVE-2020-26556). + */ + /** Provisioner static oob value */ + uint8_t *prov_static_oob_val; + /** Provisioner static oob value length */ + uint8_t prov_static_oob_len; + + /** Callback used to notify to input number/string. Initialized by the stack. */ + esp_ble_mesh_cb_t provisioner_prov_input; + /** Callback used to output number/string. Initialized by the stack. */ + esp_ble_mesh_cb_t provisioner_prov_output; + + /** Key refresh and IV update flag */ + uint8_t flags; + + /** IV index */ + uint32_t iv_index; + + /** Callback used to indicate that link is opened. Initialized by the stack. */ + esp_ble_mesh_cb_t provisioner_link_open; + /** Callback used to indicate that link is closed. Initialized by the stack. */ + esp_ble_mesh_cb_t provisioner_link_close; + /** Callback used to indicate that a device is provisioned. Initialized by the stack. */ + esp_ble_mesh_cb_t provisioner_prov_comp; +#endif /* CONFIG_BLE_MESH_PROVISIONER */ +} esp_ble_mesh_prov_t; + +/** Node Composition data context. + * This structure is associated with struct bt_mesh_comp in mesh_access.h + */ +typedef struct { + uint16_t cid; /*!< 16-bit SIG-assigned company identifier */ + uint16_t pid; /*!< 16-bit vendor-assigned product identifier */ + uint16_t vid; /*!< 16-bit vendor-assigned product version identifier */ + + size_t element_count; /*!< Element count */ + esp_ble_mesh_elem_t *elements; /*!< A sequence of elements */ +} esp_ble_mesh_comp_t; + +/*!< This enum value is the role of the device */ +typedef enum { + ROLE_NODE = 0, + ROLE_PROVISIONER, + ROLE_FAST_PROV, +} esp_ble_mesh_dev_role_t; + +/*!< Flag which will be set when device is going to be added. */ +typedef uint8_t esp_ble_mesh_dev_add_flag_t; +#define ADD_DEV_RM_AFTER_PROV_FLAG BIT(0) /*!< Device will be removed from queue after provisioned successfully */ +#define ADD_DEV_START_PROV_NOW_FLAG BIT(1) /*!< Start provisioning device immediately */ +#define ADD_DEV_FLUSHABLE_DEV_FLAG BIT(2) /*!< Device can be remove when queue is full and new device is going to added */ + +/** Information of the device which is going to be added for provisioning. */ +typedef struct { + esp_ble_mesh_bd_addr_t addr; /*!< Device address */ + esp_ble_mesh_addr_type_t addr_type; /*!< Device address type */ + uint8_t uuid[16]; /*!< Device UUID */ + uint16_t oob_info; /*!< Device OOB Info */ + /*!< ADD_DEV_START_PROV_NOW_FLAG shall not be set if the bearer has both PB-ADV and PB-GATT enabled */ + esp_ble_mesh_prov_bearer_t bearer; /*!< Provisioning Bearer */ +} esp_ble_mesh_unprov_dev_add_t; + +#define DEL_DEV_ADDR_FLAG BIT(0) +#define DEL_DEV_UUID_FLAG BIT(1) +/** Information of the device which is going to be deleted. */ +typedef struct { + union { + struct { + esp_ble_mesh_bd_addr_t addr; /*!< Device address */ + esp_ble_mesh_addr_type_t addr_type; /*!< Device address type */ + }; + uint8_t uuid[16]; /*!< Device UUID */ + }; + uint8_t flag; /*!< BIT0: device address; BIT1: device UUID */ +} esp_ble_mesh_device_delete_t; + +#define PROV_DATA_NET_IDX_FLAG BIT(0) +#define PROV_DATA_FLAGS_FLAG BIT(1) +#define PROV_DATA_IV_INDEX_FLAG BIT(2) +/** Information of the provisioner which is going to be updated. */ +typedef struct { + union { + uint16_t net_idx; /*!< NetKey Index */ + uint8_t flags; /*!< Flags */ + uint32_t iv_index; /*!< IV Index */ + }; + uint8_t flag; /*!< BIT0: net_idx; BIT1: flags; BIT2: iv_index */ +} esp_ble_mesh_prov_data_info_t; + +/** Information of the provisioned node */ +typedef struct { + /* Device information */ + esp_ble_mesh_bd_addr_t addr; /*!< Node device address */ + esp_ble_mesh_addr_type_t addr_type; /*!< Node device address type */ + uint8_t dev_uuid[16]; /*!< Device UUID */ + uint16_t oob_info; /*!< Node OOB information */ + + /* Provisioning information */ + uint16_t unicast_addr; /*!< Node unicast address */ + uint8_t element_num; /*!< Node element number */ + uint16_t net_idx; /*!< Node NetKey Index */ + uint8_t flags; /*!< Node key refresh flag and iv update flag */ + uint32_t iv_index; /*!< Node IV Index */ + uint8_t dev_key[16]; /*!< Node device key */ + + /* Additional information */ + char name[ESP_BLE_MESH_NODE_NAME_MAX_LEN + 1]; /*!< Node name */ + uint16_t comp_length; /*!< Length of Composition Data */ + uint8_t *comp_data; /*!< Value of Composition Data */ +} __attribute__((packed)) esp_ble_mesh_node_t; + +/** Context of fast provisioning which need to be set. */ +typedef struct { + uint16_t unicast_min; /*!< Minimum unicast address used for fast provisioning */ + uint16_t unicast_max; /*!< Maximum unicast address used for fast provisioning */ + uint16_t net_idx; /*!< Netkey index used for fast provisioning */ + uint8_t flags; /*!< Flags used for fast provisioning */ + uint32_t iv_index; /*!< IV Index used for fast provisioning */ + uint8_t offset; /*!< Offset of the UUID to be compared */ + uint8_t match_len; /*!< Length of the UUID to be compared */ + uint8_t match_val[16]; /*!< Value of UUID to be compared */ +} esp_ble_mesh_fast_prov_info_t; + +/*!< This enum value is the action of fast provisioning */ +typedef enum { + FAST_PROV_ACT_NONE, + FAST_PROV_ACT_ENTER, + FAST_PROV_ACT_SUSPEND, + FAST_PROV_ACT_EXIT, + FAST_PROV_ACT_MAX, +} esp_ble_mesh_fast_prov_action_t; + +/*!< This enum value is the type of proxy filter */ +typedef enum { + PROXY_FILTER_WHITELIST, + PROXY_FILTER_BLACKLIST, +} esp_ble_mesh_proxy_filter_type_t; + +/*!< Provisioner heartbeat filter type */ +#define ESP_BLE_MESH_HEARTBEAT_FILTER_ACCEPTLIST 0x00 +#define ESP_BLE_MESH_HEARTBEAT_FILTER_REJECTLIST 0x01 + +/*!< Provisioner heartbeat filter operation */ +#define ESP_BLE_MESH_HEARTBEAT_FILTER_ADD 0x00 +#define ESP_BLE_MESH_HEARTBEAT_FILTER_REMOVE 0x01 + +/** Context of Provisioner heartbeat filter information to be set */ +typedef struct { + uint16_t hb_src; /*!< Heartbeat source address (unicast address) */ + uint16_t hb_dst; /*!< Heartbeat destination address (unicast address or group address) */ +} esp_ble_mesh_heartbeat_filter_info_t; + +/*!< This enum value is the event of node/provisioner/fast provisioning */ +typedef enum { + ESP_BLE_MESH_PROV_REGISTER_COMP_EVT, /*!< Initialize BLE Mesh provisioning capabilities and internal data information completion event */ + ESP_BLE_MESH_NODE_SET_UNPROV_DEV_NAME_COMP_EVT, /*!< Set the unprovisioned device name completion event */ + ESP_BLE_MESH_NODE_PROV_ENABLE_COMP_EVT, /*!< Enable node provisioning functionality completion event */ + ESP_BLE_MESH_NODE_PROV_DISABLE_COMP_EVT, /*!< Disable node provisioning functionality completion event */ + ESP_BLE_MESH_NODE_PROV_LINK_OPEN_EVT, /*!< Establish a BLE Mesh link event */ + ESP_BLE_MESH_NODE_PROV_LINK_CLOSE_EVT, /*!< Close a BLE Mesh link event */ + ESP_BLE_MESH_NODE_PROV_OOB_PUB_KEY_EVT, /*!< Generate Node input OOB public key event */ + ESP_BLE_MESH_NODE_PROV_OUTPUT_NUMBER_EVT, /*!< Generate Node Output Number event */ + ESP_BLE_MESH_NODE_PROV_OUTPUT_STRING_EVT, /*!< Generate Node Output String event */ + ESP_BLE_MESH_NODE_PROV_INPUT_EVT, /*!< Event requiring the user to input a number or string */ + ESP_BLE_MESH_NODE_PROV_COMPLETE_EVT, /*!< Provisioning done event */ + ESP_BLE_MESH_NODE_PROV_RESET_EVT, /*!< Provisioning reset event */ + ESP_BLE_MESH_NODE_PROV_SET_OOB_PUB_KEY_COMP_EVT, /*!< Node set oob public key completion event */ + ESP_BLE_MESH_NODE_PROV_INPUT_NUMBER_COMP_EVT, /*!< Node input number completion event */ + ESP_BLE_MESH_NODE_PROV_INPUT_STRING_COMP_EVT, /*!< Node input string completion event */ + ESP_BLE_MESH_NODE_PROXY_IDENTITY_ENABLE_COMP_EVT, /*!< Enable BLE Mesh Proxy Identity advertising completion event */ + ESP_BLE_MESH_NODE_PROXY_GATT_ENABLE_COMP_EVT, /*!< Enable BLE Mesh GATT Proxy Service completion event */ + ESP_BLE_MESH_NODE_PROXY_GATT_DISABLE_COMP_EVT, /*!< Disable BLE Mesh GATT Proxy Service completion event */ + ESP_BLE_MESH_NODE_ADD_LOCAL_NET_KEY_COMP_EVT, /*!< Node add NetKey locally completion event */ + ESP_BLE_MESH_NODE_ADD_LOCAL_APP_KEY_COMP_EVT, /*!< Node add AppKey locally completion event */ + ESP_BLE_MESH_NODE_BIND_APP_KEY_TO_MODEL_COMP_EVT, /*!< Node bind AppKey to model locally completion event */ + ESP_BLE_MESH_PROVISIONER_PROV_ENABLE_COMP_EVT, /*!< Provisioner enable provisioning functionality completion event */ + ESP_BLE_MESH_PROVISIONER_PROV_DISABLE_COMP_EVT, /*!< Provisioner disable provisioning functionality completion event */ + ESP_BLE_MESH_PROVISIONER_RECV_UNPROV_ADV_PKT_EVT, /*!< Provisioner receives unprovisioned device beacon event */ + ESP_BLE_MESH_PROVISIONER_PROV_READ_OOB_PUB_KEY_EVT, /*!< Provisioner read unprovisioned device OOB public key event */ + ESP_BLE_MESH_PROVISIONER_PROV_INPUT_EVT, /*!< Provisioner input value for provisioning procedure event */ + ESP_BLE_MESH_PROVISIONER_PROV_OUTPUT_EVT, /*!< Provisioner output value for provisioning procedure event */ + ESP_BLE_MESH_PROVISIONER_PROV_LINK_OPEN_EVT, /*!< Provisioner establish a BLE Mesh link event */ + ESP_BLE_MESH_PROVISIONER_PROV_LINK_CLOSE_EVT, /*!< Provisioner close a BLE Mesh link event */ + ESP_BLE_MESH_PROVISIONER_PROV_COMPLETE_EVT, /*!< Provisioner provisioning done event */ + ESP_BLE_MESH_PROVISIONER_ADD_UNPROV_DEV_COMP_EVT, /*!< Provisioner add a device to the list which contains devices that are waiting/going to be provisioned completion event */ + ESP_BLE_MESH_PROVISIONER_PROV_DEV_WITH_ADDR_COMP_EVT, /*!< Provisioner start to provision an unprovisioned device completion event */ + ESP_BLE_MESH_PROVISIONER_DELETE_DEV_COMP_EVT, /*!< Provisioner delete a device from the list, close provisioning link with the device completion event */ + ESP_BLE_MESH_PROVISIONER_SET_DEV_UUID_MATCH_COMP_EVT, /*!< Provisioner set the value to be compared with part of the unprovisioned device UUID completion event */ + ESP_BLE_MESH_PROVISIONER_SET_PROV_DATA_INFO_COMP_EVT, /*!< Provisioner set net_idx/flags/iv_index used for provisioning completion event */ + ESP_BLE_MESH_PROVISIONER_SET_STATIC_OOB_VALUE_COMP_EVT, /*!< Provisioner set static oob value used for provisioning completion event */ + ESP_BLE_MESH_PROVISIONER_SET_PRIMARY_ELEM_ADDR_COMP_EVT, /*!< Provisioner set unicast address of primary element completion event */ + ESP_BLE_MESH_PROVISIONER_PROV_READ_OOB_PUB_KEY_COMP_EVT, /*!< Provisioner read unprovisioned device OOB public key completion event */ + ESP_BLE_MESH_PROVISIONER_PROV_INPUT_NUMBER_COMP_EVT, /*!< Provisioner input number completion event */ + ESP_BLE_MESH_PROVISIONER_PROV_INPUT_STRING_COMP_EVT, /*!< Provisioner input string completion event */ + ESP_BLE_MESH_PROVISIONER_SET_NODE_NAME_COMP_EVT, /*!< Provisioner set node name completion event */ + ESP_BLE_MESH_PROVISIONER_ADD_LOCAL_APP_KEY_COMP_EVT, /*!< Provisioner add local app key completion event */ + ESP_BLE_MESH_PROVISIONER_UPDATE_LOCAL_APP_KEY_COMP_EVT, /*!< Provisioner update local app key completion event */ + ESP_BLE_MESH_PROVISIONER_BIND_APP_KEY_TO_MODEL_COMP_EVT, /*!< Provisioner bind local model with local app key completion event */ + ESP_BLE_MESH_PROVISIONER_ADD_LOCAL_NET_KEY_COMP_EVT, /*!< Provisioner add local network key completion event */ + ESP_BLE_MESH_PROVISIONER_UPDATE_LOCAL_NET_KEY_COMP_EVT, /*!< Provisioner update local network key completion event */ + ESP_BLE_MESH_PROVISIONER_STORE_NODE_COMP_DATA_COMP_EVT, /*!< Provisioner store node composition data completion event */ + ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_UUID_COMP_EVT, /*!< Provisioner delete node with uuid completion event */ + ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_ADDR_COMP_EVT, /*!< Provisioner delete node with unicast address completion event */ + ESP_BLE_MESH_PROVISIONER_ENABLE_HEARTBEAT_RECV_COMP_EVT, /*!< Provisioner start to receive heartbeat message completion event */ + ESP_BLE_MESH_PROVISIONER_SET_HEARTBEAT_FILTER_TYPE_COMP_EVT, /*!< Provisioner set the heartbeat filter type completion event */ + ESP_BLE_MESH_PROVISIONER_SET_HEARTBEAT_FILTER_INFO_COMP_EVT, /*!< Provisioner set the heartbeat filter information completion event */ + ESP_BLE_MESH_PROVISIONER_RECV_HEARTBEAT_MESSAGE_EVT, /*!< Provisioner receive heartbeat message event */ + ESP_BLE_MESH_PROVISIONER_DRIECT_ERASE_SETTINGS_COMP_EVT, /*!< Provisioner directly erase settings completion event */ + ESP_BLE_MESH_PROVISIONER_OPEN_SETTINGS_WITH_INDEX_COMP_EVT, /*!< Provisioner open settings with index completion event */ + ESP_BLE_MESH_PROVISIONER_OPEN_SETTINGS_WITH_UID_COMP_EVT, /*!< Provisioner open settings with user id completion event */ + ESP_BLE_MESH_PROVISIONER_CLOSE_SETTINGS_WITH_INDEX_COMP_EVT, /*!< Provisioner close settings with index completion event */ + ESP_BLE_MESH_PROVISIONER_CLOSE_SETTINGS_WITH_UID_COMP_EVT, /*!< Provisioner close settings with user id completion event */ + ESP_BLE_MESH_PROVISIONER_DELETE_SETTINGS_WITH_INDEX_COMP_EVT, /*!< Provisioner delete settings with index completion event */ + ESP_BLE_MESH_PROVISIONER_DELETE_SETTINGS_WITH_UID_COMP_EVT, /*!< Provisioner delete settings with user id completion event */ + ESP_BLE_MESH_SET_FAST_PROV_INFO_COMP_EVT, /*!< Set fast provisioning information (e.g. unicast address range, net_idx, etc.) completion event */ + ESP_BLE_MESH_SET_FAST_PROV_ACTION_COMP_EVT, /*!< Set fast provisioning action completion event */ + ESP_BLE_MESH_HEARTBEAT_MESSAGE_RECV_EVT, /*!< Receive Heartbeat message event */ + ESP_BLE_MESH_LPN_ENABLE_COMP_EVT, /*!< Enable Low Power Node completion event */ + ESP_BLE_MESH_LPN_DISABLE_COMP_EVT, /*!< Disable Low Power Node completion event */ + ESP_BLE_MESH_LPN_POLL_COMP_EVT, /*!< Low Power Node send Friend Poll completion event */ + ESP_BLE_MESH_LPN_FRIENDSHIP_ESTABLISH_EVT, /*!< Low Power Node establishes friendship event */ + ESP_BLE_MESH_LPN_FRIENDSHIP_TERMINATE_EVT, /*!< Low Power Node terminates friendship event */ + ESP_BLE_MESH_FRIEND_FRIENDSHIP_ESTABLISH_EVT, /*!< Friend Node establishes friendship event */ + ESP_BLE_MESH_FRIEND_FRIENDSHIP_TERMINATE_EVT, /*!< Friend Node terminates friendship event */ + ESP_BLE_MESH_PROXY_CLIENT_RECV_ADV_PKT_EVT, /*!< Proxy Client receives Network ID advertising packet event */ + ESP_BLE_MESH_PROXY_CLIENT_CONNECTED_EVT, /*!< Proxy Client establishes connection successfully event */ + ESP_BLE_MESH_PROXY_CLIENT_DISCONNECTED_EVT, /*!< Proxy Client terminates connection successfully event */ + ESP_BLE_MESH_PROXY_CLIENT_RECV_FILTER_STATUS_EVT, /*!< Proxy Client receives Proxy Filter Status event */ + ESP_BLE_MESH_PROXY_CLIENT_CONNECT_COMP_EVT, /*!< Proxy Client connect completion event */ + ESP_BLE_MESH_PROXY_CLIENT_DISCONNECT_COMP_EVT, /*!< Proxy Client disconnect completion event */ + ESP_BLE_MESH_PROXY_CLIENT_SET_FILTER_TYPE_COMP_EVT, /*!< Proxy Client set filter type completion event */ + ESP_BLE_MESH_PROXY_CLIENT_ADD_FILTER_ADDR_COMP_EVT, /*!< Proxy Client add filter address completion event */ + ESP_BLE_MESH_PROXY_CLIENT_REMOVE_FILTER_ADDR_COMP_EVT, /*!< Proxy Client remove filter address completion event */ + ESP_BLE_MESH_PROXY_SERVER_CONNECTED_EVT, /*!< Proxy Server establishes connection successfully event */ + ESP_BLE_MESH_PROXY_SERVER_DISCONNECTED_EVT, /*!< Proxy Server terminates connection successfully event */ + ESP_BLE_MESH_MODEL_SUBSCRIBE_GROUP_ADDR_COMP_EVT, /*!< Local model subscribes group address completion event */ + ESP_BLE_MESH_MODEL_UNSUBSCRIBE_GROUP_ADDR_COMP_EVT, /*!< Local model unsubscribes group address completion event */ + ESP_BLE_MESH_DEINIT_MESH_COMP_EVT, /*!< De-initialize BLE Mesh stack completion event */ + ESP_BLE_MESH_PROV_EVT_MAX, +} esp_ble_mesh_prov_cb_event_t; + +/** + * @brief BLE Mesh Node/Provisioner callback parameters union + */ +typedef union { + /** + * @brief ESP_BLE_MESH_PROV_REGISTER_COMP_EVT + */ + struct ble_mesh_prov_register_comp_param { + int err_code; /*!< Indicate the result of BLE Mesh initialization */ + } prov_register_comp; /*!< Event parameter of ESP_BLE_MESH_PROV_REGISTER_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_NODE_SET_UNPROV_DEV_NAME_COMP_EVT + */ + struct ble_mesh_set_unprov_dev_name_comp_param { + int err_code; /*!< Indicate the result of setting BLE Mesh device name */ + } node_set_unprov_dev_name_comp; /*!< Event parameter of ESP_BLE_MESH_NODE_SET_UNPROV_DEV_NAME_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_NODE_PROV_ENABLE_COMP_EVT + */ + struct ble_mesh_prov_enable_comp_param { + int err_code; /*!< Indicate the result of enabling BLE Mesh device */ + } node_prov_enable_comp; /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_ENABLE_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_NODE_PROV_DISABLE_COMP_EVT + */ + struct ble_mesh_prov_disable_comp_param { + int err_code; /*!< Indicate the result of disabling BLE Mesh device */ + } node_prov_disable_comp; /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_DISABLE_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_NODE_PROV_LINK_OPEN_EVT + */ + struct ble_mesh_link_open_evt_param { + esp_ble_mesh_prov_bearer_t bearer; /*!< Type of the bearer used when device link is open */ + } node_prov_link_open; /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_LINK_OPEN_EVT */ + /** + * @brief ESP_BLE_MESH_NODE_PROV_LINK_CLOSE_EVT + */ + struct ble_mesh_link_close_evt_param { + esp_ble_mesh_prov_bearer_t bearer; /*!< Type of the bearer used when device link is closed */ + } node_prov_link_close; /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_LINK_CLOSE_EVT */ + /** + * @brief ESP_BLE_MESH_NODE_PROV_OUTPUT_NUMBER_EVT + */ + struct ble_mesh_output_num_evt_param { + esp_ble_mesh_output_action_t action; /*!< Action of Output OOB Authentication */ + uint32_t number; /*!< Number of Output OOB Authentication */ + } node_prov_output_num; /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_OUTPUT_NUMBER_EVT */ + /** + * @brief ESP_BLE_MESH_NODE_PROV_OUTPUT_STRING_EVT + */ + struct ble_mesh_output_str_evt_param { + char string[8]; /*!< String of Output OOB Authentication */ + } node_prov_output_str; /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_OUTPUT_STRING_EVT */ + /** + * @brief ESP_BLE_MESH_NODE_PROV_INPUT_EVT + */ + struct ble_mesh_input_evt_param { + esp_ble_mesh_input_action_t action; /*!< Action of Input OOB Authentication */ + uint8_t size; /*!< Size of Input OOB Authentication */ + } node_prov_input; /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_INPUT_EVT */ + /** + * @brief ESP_BLE_MESH_NODE_PROV_COMPLETE_EVT + */ + struct ble_mesh_provision_complete_evt_param { + uint16_t net_idx; /*!< NetKey Index */ + uint8_t net_key[16]; /*!< NetKey */ + uint16_t addr; /*!< Primary address */ + uint8_t flags; /*!< Flags */ + uint32_t iv_index; /*!< IV Index */ + } node_prov_complete; /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_COMPLETE_EVT */ + /** + * @brief ESP_BLE_MESH_NODE_PROV_RESET_EVT + */ + struct ble_mesh_provision_reset_param { + + } node_prov_reset; /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_RESET_EVT */ + /** + * @brief ESP_BLE_MESH_NODE_PROV_SET_OOB_PUB_KEY_COMP_EVT + */ + struct ble_mesh_set_oob_pub_key_comp_param { + int err_code; /*!< Indicate the result of setting OOB Public Key */ + } node_prov_set_oob_pub_key_comp; /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_SET_OOB_PUB_KEY_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_NODE_PROV_INPUT_NUM_COMP_EVT + */ + struct ble_mesh_input_number_comp_param { + int err_code; /*!< Indicate the result of inputting number */ + } node_prov_input_num_comp; /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_INPUT_NUM_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_NODE_PROV_INPUT_STR_COMP_EVT + */ + struct ble_mesh_input_string_comp_param { + int err_code; /*!< Indicate the result of inputting string */ + } node_prov_input_str_comp; /*!< Event parameter of ESP_BLE_MESH_NODE_PROV_INPUT_STR_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_NODE_PROXY_IDENTITY_ENABLE_COMP_EVT + */ + struct ble_mesh_proxy_identity_enable_comp_param { + int err_code; /*!< Indicate the result of enabling Mesh Proxy advertising */ + } node_proxy_identity_enable_comp; /*!< Event parameter of ESP_BLE_MESH_NODE_PROXY_IDENTITY_ENABLE_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_NODE_PROXY_GATT_ENABLE_COMP_EVT + */ + struct ble_mesh_proxy_gatt_enable_comp_param { + int err_code; /*!< Indicate the result of enabling Mesh Proxy Service */ + } node_proxy_gatt_enable_comp; /*!< Event parameter of ESP_BLE_MESH_NODE_PROXY_GATT_ENABLE_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_NODE_PROXY_GATT_DISABLE_COMP_EVT + */ + struct ble_mesh_proxy_gatt_disable_comp_param { + int err_code; /*!< Indicate the result of disabling Mesh Proxy Service */ + } node_proxy_gatt_disable_comp; /*!< Event parameter of ESP_BLE_MESH_NODE_PROXY_GATT_DISABLE_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_NODE_ADD_LOCAL_NET_KEY_COMP_EVT + */ + struct ble_mesh_node_add_local_net_key_comp_param { + int err_code; /*!< Indicate the result of adding local NetKey by the node */ + uint16_t net_idx; /*!< NetKey Index */ + } node_add_net_key_comp; /*!< Event parameter of ESP_BLE_MESH_NODE_ADD_LOCAL_NET_KEY_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_NODE_ADD_LOCAL_APP_KEY_COMP_EVT + */ + struct ble_mesh_node_add_local_app_key_comp_param { + int err_code; /*!< Indicate the result of adding local AppKey by the node */ + uint16_t net_idx; /*!< NetKey Index */ + uint16_t app_idx; /*!< AppKey Index */ + } node_add_app_key_comp; /*!< Event parameter of ESP_BLE_MESH_NODE_ADD_LOCAL_APP_KEY_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_NODE_BIND_APP_KEY_TO_MODEL_COMP_EVT + */ + struct ble_mesh_node_bind_local_mod_app_comp_param { + int err_code; /*!< Indicate the result of binding AppKey with model by the node */ + uint16_t element_addr; /*!< Element address */ + uint16_t app_idx; /*!< AppKey Index */ + uint16_t company_id; /*!< Company ID */ + uint16_t model_id; /*!< Model ID */ + } node_bind_app_key_to_model_comp; /*!< Event parameter of ESP_BLE_MESH_NODE_BIND_APP_KEY_TO_MODEL_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_RECV_UNPROV_ADV_PKT_EVT + */ + struct ble_mesh_provisioner_recv_unprov_adv_pkt_param { + uint8_t dev_uuid[16]; /*!< Device UUID of the unprovisioned device */ + esp_ble_mesh_bd_addr_t addr; /*!< Device address of the unprovisioned device */ + esp_ble_mesh_addr_type_t addr_type; /*!< Device address type */ + uint16_t oob_info; /*!< OOB Info of the unprovisioned device */ + uint8_t adv_type; /*!< Avertising type of the unprovisioned device */ + esp_ble_mesh_prov_bearer_t bearer; /*!< Bearer of the unprovisioned device */ + int8_t rssi; /*!< RSSI of the received advertising packet */ + } provisioner_recv_unprov_adv_pkt; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_RECV_UNPROV_ADV_PKT_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_PROV_ENABLE_COMP_EVT + */ + struct ble_mesh_provisioner_prov_enable_comp_param { + int err_code; /*!< Indicate the result of enabling BLE Mesh Provisioner */ + } provisioner_prov_enable_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_PROV_ENABLE_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_PROV_DISABLE_COMP_EVT + */ + struct ble_mesh_provisioner_prov_disable_comp_param { + int err_code; /*!< Indicate the result of disabling BLE Mesh Provisioner */ + } provisioner_prov_disable_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_PROV_DISABLE_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_PROV_LINK_OPEN_EVT + */ + struct ble_mesh_provisioner_link_open_evt_param { + esp_ble_mesh_prov_bearer_t bearer; /*!< Type of the bearer used when Provisioner link is opened */ + } provisioner_prov_link_open; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_PROV_LINK_OPEN_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_PROV_READ_OOB_PUB_KEY_EVT + */ + struct ble_mesh_provisioner_prov_read_oob_pub_key_evt_param { + uint8_t link_idx; /*!< Index of the provisioning link */ + } provisioner_prov_read_oob_pub_key; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_PROV_READ_OOB_PUB_KEY_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_PROV_INPUT_EVT + */ + struct ble_mesh_provisioner_prov_input_evt_param { + esp_ble_mesh_oob_method_t method; /*!< Method of device Output OOB Authentication */ + esp_ble_mesh_output_action_t action; /*!< Action of device Output OOB Authentication */ + uint8_t size; /*!< Size of device Output OOB Authentication */ + uint8_t link_idx; /*!< Index of the provisioning link */ + } provisioner_prov_input; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_PROV_INPUT_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_PROV_OUTPUT_EVT + */ + struct ble_mesh_provisioner_prov_output_evt_param { + esp_ble_mesh_oob_method_t method; /*!< Method of device Input OOB Authentication */ + esp_ble_mesh_input_action_t action; /*!< Action of device Input OOB Authentication */ + uint8_t size; /*!< Size of device Input OOB Authentication */ + uint8_t link_idx; /*!< Index of the provisioning link */ + union { + char string[8]; /*!< String output by the Provisioner */ + uint32_t number; /*!< Number output by the Provisioner */ + }; + } provisioner_prov_output; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_PROV_OUTPUT_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_PROV_LINK_CLOSE_EVT + */ + struct ble_mesh_provisioner_link_close_evt_param { + esp_ble_mesh_prov_bearer_t bearer; /*!< Type of the bearer used when Provisioner link is closed */ + uint8_t reason; /*!< Reason of the closed provisioning link */ + } provisioner_prov_link_close; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_PROV_LINK_CLOSE_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_PROV_COMPLETE_EVT + */ + struct ble_mesh_provisioner_prov_comp_param { + uint16_t node_idx; /*!< Index of the provisioned device */ + esp_ble_mesh_octet16_t device_uuid; /*!< Device UUID of the provisioned device */ + uint16_t unicast_addr; /*!< Primary address of the provisioned device */ + uint8_t element_num; /*!< Element count of the provisioned device */ + uint16_t netkey_idx; /*!< NetKey Index of the provisioned device */ + } provisioner_prov_complete; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_PROV_COMPLETE_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_ADD_UNPROV_DEV_COMP_EVT + */ + struct ble_mesh_provisioner_add_unprov_dev_comp_param { + int err_code; /*!< Indicate the result of adding device into queue by the Provisioner */ + } provisioner_add_unprov_dev_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_ADD_UNPROV_DEV_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_PROV_DEV_WITH_ADDR_COMP_EVT + */ + struct ble_mesh_provisioner_prov_dev_with_addr_comp_param { + int err_code; /*!< Indicate the result of Provisioner starting to provision a device */ + } provisioner_prov_dev_with_addr_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_PROV_DEV_WITH_ADDR_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_DELETE_DEV_COMP_EVT + */ + struct ble_mesh_provisioner_delete_dev_comp_param { + int err_code; /*!< Indicate the result of deleting device by the Provisioner */ + } provisioner_delete_dev_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_DELETE_DEV_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_SET_DEV_UUID_MATCH_COMP_EVT + */ + struct ble_mesh_provisioner_set_dev_uuid_match_comp_param { + int err_code; /*!< Indicate the result of setting Device UUID match value by the Provisioner */ + } provisioner_set_dev_uuid_match_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_SET_DEV_UUID_MATCH_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_SET_PROV_DATA_INFO_COMP_EVT + */ + struct ble_mesh_provisioner_set_prov_data_info_comp_param { + int err_code; /*!< Indicate the result of setting provisioning info by the Provisioner */ + } provisioner_set_prov_data_info_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_SET_PROV_DATA_INFO_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_SET_STATIC_OOB_VALUE_COMP_EVT + */ + struct ble_mesh_provisioner_set_static_oob_val_comp_param { + int err_code; /*!< Indicate the result of setting static oob value by the Provisioner */ + } provisioner_set_static_oob_val_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_SET_STATIC_OOB_VALUE_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_SET_PRIMARY_ELEM_ADDR_COMP_EVT + */ + struct ble_mesh_provisioner_set_primary_elem_addr_comp_param { + int err_code; /*!< Indicate the result of setting unicast address of primary element by the Provisioner */ + } provisioner_set_primary_elem_addr_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_SET_PRIMARY_ELEM_ADDR_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_PROV_READ_OOB_PUB_KEY_COMP_EVT + */ + struct ble_mesh_provisioner_prov_read_oob_pub_key_comp_param { + int err_code; /*!< Indicate the result of setting OOB Public Key by the Provisioner */ + } provisioner_prov_read_oob_pub_key_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_PROV_READ_OOB_PUB_KEY_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_PROV_INPUT_NUMBER_COMP_EVT + */ + struct ble_mesh_provisioner_prov_input_num_comp_param { + int err_code; /*!< Indicate the result of inputting number by the Provisioner */ + } provisioner_prov_input_num_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_PROV_INPUT_NUMBER_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_PROV_INPUT_STRING_COMP_EVT + */ + struct ble_mesh_provisioner_prov_input_str_comp_param { + int err_code; /*!< Indicate the result of inputting string by the Provisioner */ + } provisioner_prov_input_str_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_PROV_INPUT_STRING_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_SET_NODE_NAME_COMP_EVT + */ + struct ble_mesh_provisioner_set_node_name_comp_param { + int err_code; /*!< Indicate the result of setting provisioned device name by the Provisioner */ + uint16_t node_index; /*!< Index of the provisioned device */ + } provisioner_set_node_name_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_SET_NODE_NAME_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_ADD_LOCAL_APP_KEY_COMP_EVT + */ + struct ble_mesh_provisioner_add_local_app_key_comp_param { + int err_code; /*!< Indicate the result of adding local AppKey by the Provisioner */ + uint16_t net_idx; /*!< NetKey Index */ + uint16_t app_idx; /*!< AppKey Index */ + } provisioner_add_app_key_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_ADD_LOCAL_APP_KEY_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_UPDATE_LOCAL_APP_KEY_COMP_EVT + */ + struct ble_mesh_provisioner_update_local_app_key_comp_param { + int err_code; /*!< Indicate the result of updating local AppKey by the Provisioner */ + uint16_t net_idx; /*!< NetKey Index */ + uint16_t app_idx; /*!< AppKey Index */ + } provisioner_update_app_key_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_UPDATE_LOCAL_APP_KEY_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_BIND_APP_KEY_TO_MODEL_COMP_EVT + */ + struct ble_mesh_provisioner_bind_local_mod_app_comp_param { + int err_code; /*!< Indicate the result of binding AppKey with model by the Provisioner */ + uint16_t element_addr; /*!< Element address */ + uint16_t app_idx; /*!< AppKey Index */ + uint16_t company_id; /*!< Company ID */ + uint16_t model_id; /*!< Model ID */ + } provisioner_bind_app_key_to_model_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_BIND_APP_KEY_TO_MODEL_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_ADD_LOCAL_NET_KEY_COMP_EVT + */ + struct ble_mesh_provisioner_add_local_net_key_comp_param { + int err_code; /*!< Indicate the result of adding local NetKey by the Provisioner */ + uint16_t net_idx; /*!< NetKey Index */ + } provisioner_add_net_key_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_ADD_LOCAL_NET_KEY_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_UPDATE_LOCAL_NET_KEY_COMP_EVT + */ + struct ble_mesh_provisioner_update_local_net_key_comp_param { + int err_code; /*!< Indicate the result of updating local NetKey by the Provisioner */ + uint16_t net_idx; /*!< NetKey Index */ + } provisioner_update_net_key_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_UPDATE_LOCAL_NET_KEY_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_STORE_NODE_COMP_DATA_COMP_EVT + */ + struct ble_mesh_provisioner_store_node_comp_data_comp_param { + int err_code; /*!< Indicate the result of storing node composition data by the Provisioner */ + uint16_t addr; /*!< Node element address */ + } provisioner_store_node_comp_data_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_STORE_NODE_COMP_DATA_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_UUID_COMP_EVT + */ + struct ble_mesh_provisioner_delete_node_with_uuid_comp_param { + int err_code; /*!< Indicate the result of deleting node with uuid by the Provisioner */ + uint8_t uuid[16]; /*!< Node device uuid */ + } provisioner_delete_node_with_uuid_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_UUID_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_ADDR_COMP_EVT + */ + struct ble_mesh_provisioner_delete_node_with_addr_comp_param { + int err_code; /*!< Indicate the result of deleting node with unicast address by the Provisioner */ + uint16_t unicast_addr; /*!< Node unicast address */ + } provisioner_delete_node_with_addr_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_ADDR_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_ENABLE_HEARTBEAT_RECV_COMP_EVT + */ + struct { + int err_code; /*!< Indicate the result of enabling/disabling to receive heartbeat messages by the Provisioner */ + bool enable; /*!< Indicate enabling or disabling receiving heartbeat messages */ + } provisioner_enable_heartbeat_recv_comp; /*!< Event parameters of ESP_BLE_MESH_PROVISIONER_ENABLE_HEARTBEAT_RECV_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_SET_HEARTBEAT_FILTER_TYPE_COMP_EVT + */ + struct { + int err_code; /*!< Indicate the result of setting the heartbeat filter type by the Provisioner */ + uint8_t type; /*!< Type of the filter used for receiving heartbeat messages */ + } provisioner_set_heartbeat_filter_type_comp; /*!< Event parameters of ESP_BLE_MESH_PROVISIONER_SET_HEARTBEAT_FILTER_TYPE_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_SET_HEARTBEAT_FILTER_INFO_COMP_EVT + */ + struct { + int err_code; /*!< Indicate the result of setting the heartbeat filter address by the Provisioner */ + uint8_t op; /*!< Operation (add, remove, clean) */ + uint16_t hb_src; /*!< Heartbeat source address */ + uint16_t hb_dst; /*!< Heartbeat destination address */ + } provisioner_set_heartbeat_filter_info_comp; /*!< Event parameters of ESP_BLE_MESH_PROVISIONER_SET_HEARTBEAT_FILTER_INFO_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_RECV_HEARTBEAT_MESSAGE_EVT + */ + struct { + uint16_t hb_src; /*!< Heartbeat source address */ + uint16_t hb_dst; /*!< Heartbeat destination address */ + uint8_t init_ttl; /*!< Heartbeat InitTTL */ + uint8_t rx_ttl; /*!< Heartbeat RxTTL */ + uint8_t hops; /*!< Heartbeat hops (InitTTL - RxTTL + 1) */ + uint16_t feature; /*!< Bit field of currently active features of the node */ + int8_t rssi; /*!< RSSI of the heartbeat message */ + } provisioner_recv_heartbeat; /*!< Event parameters of ESP_BLE_MESH_PROVISIONER_RECV_HEARTBEAT_MESSAGE_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_DRIECT_ERASE_SETTINGS_COMP_EVT + */ + struct { + int err_code; /*!< Indicate the result of directly erasing settings by the Provisioner */ + } provisioner_direct_erase_settings_comp; /*!< Event parameters of ESP_BLE_MESH_PROVISIONER_DRIECT_ERASE_SETTINGS_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_OPEN_SETTINGS_WITH_INDEX_COMP_EVT + */ + struct { + int err_code; /*!< Indicate the result of opening settings with index by the Provisioner */ + uint8_t index; /*!< Index of Provisioner settings */ + } provisioner_open_settings_with_index_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_OPEN_SETTINGS_WITH_INDEX_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_OPEN_SETTINGS_WITH_UID_COMP_EVT + */ + struct { + int err_code; /*!< Indicate the result of opening settings with user id by the Provisioner */ + uint8_t index; /*!< Index of Provisioner settings */ + char uid[ESP_BLE_MESH_SETTINGS_UID_SIZE + 1]; /*!< Provisioner settings user id */ + } provisioner_open_settings_with_uid_comp; /*!< Event parameters of ESP_BLE_MESH_PROVISIONER_OPEN_SETTINGS_WITH_UID_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_CLOSE_SETTINGS_WITH_INDEX_COMP_EVT + */ + struct { + int err_code; /*!< Indicate the result of closing settings with index by the Provisioner */ + uint8_t index; /*!< Index of Provisioner settings */ + } provisioner_close_settings_with_index_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_CLOSE_SETTINGS_WITH_INDEX_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_CLOSE_SETTINGS_WITH_UID_COMP_EVT + */ + struct { + int err_code; /*!< Indicate the result of closing settings with user id by the Provisioner */ + uint8_t index; /*!< Index of Provisioner settings */ + char uid[ESP_BLE_MESH_SETTINGS_UID_SIZE + 1]; /*!< Provisioner settings user id */ + } provisioner_close_settings_with_uid_comp; /*!< Event parameters of ESP_BLE_MESH_PROVISIONER_CLOSE_SETTINGS_WITH_UID_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_DELETE_SETTINGS_WITH_INDEX_COMP_EVT + */ + struct { + int err_code; /*!< Indicate the result of deleting settings with index by the Provisioner */ + uint8_t index; /*!< Index of Provisioner settings */ + } provisioner_delete_settings_with_index_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_DELETE_SETTINGS_WITH_INDEX_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROVISIONER_DELETE_SETTINGS_WITH_UID_COMP_EVT + */ + struct { + int err_code; /*!< Indicate the result of deleting settings with user id by the Provisioner */ + uint8_t index; /*!< Index of Provisioner settings */ + char uid[ESP_BLE_MESH_SETTINGS_UID_SIZE + 1]; /*!< Provisioner settings user id */ + } provisioner_delete_settings_with_uid_comp; /*!< Event parameters of ESP_BLE_MESH_PROVISIONER_DELETE_SETTINGS_WITH_UID_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_SET_FAST_PROV_INFO_COMP_EVT + */ + struct ble_mesh_set_fast_prov_info_comp_param { + uint8_t status_unicast; /*!< Indicate the result of setting unicast address range of fast provisioning */ + uint8_t status_net_idx; /*!< Indicate the result of setting NetKey Index of fast provisioning */ + uint8_t status_match; /*!< Indicate the result of setting matching Device UUID of fast provisioning */ + } set_fast_prov_info_comp; /*!< Event parameter of ESP_BLE_MESH_SET_FAST_PROV_INFO_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_SET_FAST_PROV_ACTION_COMP_EVT + */ + struct ble_mesh_set_fast_prov_action_comp_param { + uint8_t status_action; /*!< Indicate the result of setting action of fast provisioning */ + } set_fast_prov_action_comp; /*!< Event parameter of ESP_BLE_MESH_SET_FAST_PROV_ACTION_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_HEARTBEAT_MESSAGE_RECV_EVT + */ + struct ble_mesh_heartbeat_msg_recv_param { + uint8_t hops; /*!< Heartbeat hops (InitTTL - RxTTL + 1) */ + uint16_t feature; /*!< Bit field of currently active features of the node */ + } heartbeat_msg_recv; /*!< Event parameter of ESP_BLE_MESH_HEARTBEAT_MESSAGE_RECV_EVT */ + /** + * @brief ESP_BLE_MESH_LPN_ENABLE_COMP_EVT + */ + struct ble_mesh_lpn_enable_comp_param { + int err_code; /*!< Indicate the result of enabling LPN functionality */ + } lpn_enable_comp; /*!< Event parameter of ESP_BLE_MESH_LPN_ENABLE_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_LPN_DISABLE_COMP_EVT + */ + struct ble_mesh_lpn_disable_comp_param { + int err_code; /*!< Indicate the result of disabling LPN functionality */ + } lpn_disable_comp; /*!< Event parameter of ESP_BLE_MESH_LPN_DISABLE_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_LPN_POLL_COMP_EVT + */ + struct ble_mesh_lpn_poll_comp_param { + int err_code; /*!< Indicate the result of sending Friend Poll */ + } lpn_poll_comp; /*!< Event parameter of ESP_BLE_MESH_LPN_POLL_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_LPN_FRIENDSHIP_ESTABLISH_EVT + */ + struct ble_mesh_lpn_friendship_establish_param { + uint16_t friend_addr; /*!< Friend Node unicast address */ + } lpn_friendship_establish; /*!< Event parameter of ESP_BLE_MESH_LPN_FRIENDSHIP_ESTABLISH_EVT */ + /** + * @brief ESP_BLE_MESH_LPN_FRIENDSHIP_TERMINATE_EVT + */ + struct ble_mesh_lpn_friendship_terminate_param { + uint16_t friend_addr; /*!< Friend Node unicast address */ + } lpn_friendship_terminate; /*!< Event parameter of ESP_BLE_MESH_LPN_FRIENDSHIP_TERMINATE_EVT */ + /** + * @brief ESP_BLE_MESH_FRIEND_FRIENDSHIP_ESTABLISH_EVT + */ + struct ble_mesh_friend_friendship_establish_param { + uint16_t lpn_addr; /*!< Low Power Node unicast address */ + } frnd_friendship_establish; /*!< Event parameter of ESP_BLE_MESH_FRIEND_FRIENDSHIP_ESTABLISH_EVT */ + /** + * @brief ESP_BLE_MESH_FRIEND_FRIENDSHIP_TERMINATE_EVT + */ + struct ble_mesh_friend_friendship_terminate_param { + uint16_t lpn_addr; /*!< Low Power Node unicast address */ + /** This enum value is the reason of friendship termination on the friend node side */ + enum { + ESP_BLE_MESH_FRND_FRIENDSHIP_TERMINATE_ESTABLISH_FAIL, /*!< Friend Offer has been sent, but Friend Offer is not received within 1 second, friendship fails to be established */ + ESP_BLE_MESH_FRND_FRIENDSHIP_TERMINATE_POLL_TIMEOUT, /*!< Friendship is established, PollTimeout timer expires and no Friend Poll/Sub Add/Sub Remove is received */ + ESP_BLE_MESH_FRND_FRIENDSHIP_TERMINATE_RECV_FRND_REQ, /*!< Receive Friend Request from existing Low Power Node */ + ESP_BLE_MESH_FRND_FRIENDSHIP_TERMINATE_RECV_FRND_CLEAR, /*!< Receive Friend Clear from other friend node */ + ESP_BLE_MESH_FRND_FRIENDSHIP_TERMINATE_DISABLE, /*!< Friend feature disabled or corresponding NetKey is deleted */ + } reason; /*!< Friendship terminated reason */ + } frnd_friendship_terminate; /*!< Event parameter of ESP_BLE_MESH_FRIEND_FRIENDSHIP_TERMINATE_EVT */ + /** + * @brief ESP_BLE_MESH_PROXY_CLIENT_RECV_ADV_PKT_EVT + */ + struct ble_mesh_proxy_client_recv_adv_pkt_param { + esp_ble_mesh_bd_addr_t addr; /*!< Device address */ + esp_ble_mesh_addr_type_t addr_type; /*!< Device address type */ + uint16_t net_idx; /*!< Network ID related NetKey Index */ + uint8_t net_id[8]; /*!< Network ID contained in the advertising packet */ + int8_t rssi; /*!< RSSI of the received advertising packet */ + } proxy_client_recv_adv_pkt; /*!< Event parameter of ESP_BLE_MESH_PROXY_CLIENT_RECV_ADV_PKT_EVT */ + /** + * @brief ESP_BLE_MESH_PROXY_CLIENT_CONNECTED_EVT + */ + struct ble_mesh_proxy_client_connected_param { + esp_ble_mesh_bd_addr_t addr; /*!< Device address of the Proxy Server */ + esp_ble_mesh_addr_type_t addr_type; /*!< Device address type */ + uint8_t conn_handle; /*!< Proxy connection handle */ + uint16_t net_idx; /*!< Corresponding NetKey Index */ + } proxy_client_connected; /*!< Event parameter of ESP_BLE_MESH_PROXY_CLIENT_CONNECTED_EVT */ + /** + * @brief ESP_BLE_MESH_PROXY_CLIENT_DISCONNECTED_EVT + */ + struct ble_mesh_proxy_client_disconnected_param { + esp_ble_mesh_bd_addr_t addr; /*!< Device address of the Proxy Server */ + esp_ble_mesh_addr_type_t addr_type; /*!< Device address type */ + uint8_t conn_handle; /*!< Proxy connection handle */ + uint16_t net_idx; /*!< Corresponding NetKey Index */ + uint8_t reason; /*!< Proxy disconnect reason */ + } proxy_client_disconnected; /*!< Event parameter of ESP_BLE_MESH_PROXY_CLIENT_DISCONNECTED_EVT */ + /** + * @brief ESP_BLE_MESH_PROXY_CLIENT_RECV_FILTER_STATUS_EVT + */ + struct ble_mesh_proxy_client_recv_filter_status_param { + uint8_t conn_handle; /*!< Proxy connection handle */ + uint16_t server_addr; /*!< Proxy Server primary element address */ + uint16_t net_idx; /*!< Corresponding NetKey Index */ + uint8_t filter_type; /*!< Proxy Server filter type(whitelist or blacklist) */ + uint16_t list_size; /*!< Number of addresses in the Proxy Server filter list */ + } proxy_client_recv_filter_status; /*!< Event parameter of ESP_BLE_MESH_PROXY_CLIENT_RECV_FILTER_STATUS_EVT */ + /** + * @brief ESP_BLE_MESH_PROXY_CLIENT_CONNECT_COMP_EVT + */ + struct ble_mesh_proxy_client_connect_comp_param { + int err_code; /*!< Indicate the result of Proxy Client connect */ + esp_ble_mesh_bd_addr_t addr; /*!< Device address of the Proxy Server */ + esp_ble_mesh_addr_type_t addr_type; /*!< Device address type */ + uint16_t net_idx; /*!< Corresponding NetKey Index */ + } proxy_client_connect_comp; /*!< Event parameter of ESP_BLE_MESH_PROXY_CLIENT_CONNECT_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROXY_CLIENT_DISCONNECT_COMP_EVT + */ + struct ble_mesh_proxy_client_disconnect_comp_param { + int err_code; /*!< Indicate the result of Proxy Client disconnect */ + uint8_t conn_handle; /*!< Proxy connection handle */ + } proxy_client_disconnect_comp; /*!< Event parameter of ESP_BLE_MESH_PROXY_CLIENT_DISCONNECT_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROXY_CLIENT_SET_FILTER_TYPE_COMP_EVT + */ + struct ble_mesh_proxy_client_set_filter_type_comp_param { + int err_code; /*!< Indicate the result of Proxy Client set filter type */ + uint8_t conn_handle; /*!< Proxy connection handle */ + uint16_t net_idx; /*!< Corresponding NetKey Index */ + } proxy_client_set_filter_type_comp; /*!< Event parameter of ESP_BLE_MESH_PROXY_CLIENT_SET_FILTER_TYPE_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROXY_CLIENT_ADD_FILTER_ADDR_COMP_EVT + */ + struct ble_mesh_proxy_client_add_filter_addr_comp_param { + int err_code; /*!< Indicate the result of Proxy Client add filter address */ + uint8_t conn_handle; /*!< Proxy connection handle */ + uint16_t net_idx; /*!< Corresponding NetKey Index */ + } proxy_client_add_filter_addr_comp; /*!< Event parameter of ESP_BLE_MESH_PROXY_CLIENT_ADD_FILTER_ADDR_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROXY_CLIENT_REMOVE_FILTER_ADDR_COMP_EVT + */ + struct ble_mesh_proxy_client_remove_filter_addr_comp_param { + int err_code; /*!< Indicate the result of Proxy Client remove filter address */ + uint8_t conn_handle; /*!< Proxy connection handle */ + uint16_t net_idx; /*!< Corresponding NetKey Index */ + } proxy_client_remove_filter_addr_comp; /*!< Event parameter of ESP_BLE_MESH_PROXY_CLIENT_REMOVE_FILTER_ADDR_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_PROXY_SERVER_CONNECTED_EVT + */ + struct ble_mesh_proxy_server_connected_param { + uint8_t conn_handle; /*!< Proxy connection handle */ + } proxy_server_connected; /*!< Event parameter of ESP_BLE_MESH_PROXY_SERVER_CONNECTED_EVT */ + /** + * @brief ESP_BLE_MESH_PROXY_SERVER_DISCONNECTED_EVT + */ + struct ble_mesh_proxy_server_disconnected_param { + uint8_t conn_handle; /*!< Proxy connection handle */ + uint8_t reason; /*!< Proxy disconnect reason */ + } proxy_server_disconnected; /*!< Event parameter of ESP_BLE_MESH_PROXY_SERVER_DISCONNECTED_EVT */ + /** + * @brief ESP_BLE_MESH_MODEL_SUBSCRIBE_GROUP_ADDR_COMP_EVT + */ + struct ble_mesh_model_sub_group_addr_comp_param { + int err_code; /*!< Indicate the result of local model subscribing group address */ + uint16_t element_addr; /*!< Element address */ + uint16_t company_id; /*!< Company ID */ + uint16_t model_id; /*!< Model ID */ + uint16_t group_addr; /*!< Group Address */ + } model_sub_group_addr_comp; /*!< Event parameters of ESP_BLE_MESH_MODEL_SUBSCRIBE_GROUP_ADDR_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_MODEL_UNSUBSCRIBE_GROUP_ADDR_COMP_EVT + */ + struct ble_mesh_model_unsub_group_addr_comp_param { + int err_code; /*!< Indicate the result of local model unsubscribing group address */ + uint16_t element_addr; /*!< Element address */ + uint16_t company_id; /*!< Company ID */ + uint16_t model_id; /*!< Model ID */ + uint16_t group_addr; /*!< Group Address */ + } model_unsub_group_addr_comp; /*!< Event parameters of ESP_BLE_MESH_MODEL_UNSUBSCRIBE_GROUP_ADDR_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_DEINIT_MESH_COMP_EVT + */ + struct ble_mesh_deinit_mesh_comp_param { + int err_code; /*!< Indicate the result of BLE Mesh deinitialization */ + } deinit_mesh_comp; /*!< Event parameter of ESP_BLE_MESH_DEINIT_MESH_COMP_EVT */ +} esp_ble_mesh_prov_cb_param_t; + +/** + * @brief BLE Mesh models related Model ID and Opcode definitions + */ + +/*!< Foundation Models */ +#define ESP_BLE_MESH_MODEL_ID_CONFIG_SRV 0x0000 +#define ESP_BLE_MESH_MODEL_ID_CONFIG_CLI 0x0001 +#define ESP_BLE_MESH_MODEL_ID_HEALTH_SRV 0x0002 +#define ESP_BLE_MESH_MODEL_ID_HEALTH_CLI 0x0003 + +/*!< Models from the Mesh Model Specification */ +#define ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_SRV 0x1000 +#define ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_CLI 0x1001 +#define ESP_BLE_MESH_MODEL_ID_GEN_LEVEL_SRV 0x1002 +#define ESP_BLE_MESH_MODEL_ID_GEN_LEVEL_CLI 0x1003 +#define ESP_BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_SRV 0x1004 +#define ESP_BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_CLI 0x1005 +#define ESP_BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SRV 0x1006 +#define ESP_BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SETUP_SRV 0x1007 +#define ESP_BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_CLI 0x1008 +#define ESP_BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SRV 0x1009 +#define ESP_BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SETUP_SRV 0x100a +#define ESP_BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_CLI 0x100b +#define ESP_BLE_MESH_MODEL_ID_GEN_BATTERY_SRV 0x100c +#define ESP_BLE_MESH_MODEL_ID_GEN_BATTERY_CLI 0x100d +#define ESP_BLE_MESH_MODEL_ID_GEN_LOCATION_SRV 0x100e +#define ESP_BLE_MESH_MODEL_ID_GEN_LOCATION_SETUP_SRV 0x100f +#define ESP_BLE_MESH_MODEL_ID_GEN_LOCATION_CLI 0x1010 +#define ESP_BLE_MESH_MODEL_ID_GEN_ADMIN_PROP_SRV 0x1011 +#define ESP_BLE_MESH_MODEL_ID_GEN_MANUFACTURER_PROP_SRV 0x1012 +#define ESP_BLE_MESH_MODEL_ID_GEN_USER_PROP_SRV 0x1013 +#define ESP_BLE_MESH_MODEL_ID_GEN_CLIENT_PROP_SRV 0x1014 +#define ESP_BLE_MESH_MODEL_ID_GEN_PROP_CLI 0x1015 +#define ESP_BLE_MESH_MODEL_ID_SENSOR_SRV 0x1100 +#define ESP_BLE_MESH_MODEL_ID_SENSOR_SETUP_SRV 0x1101 +#define ESP_BLE_MESH_MODEL_ID_SENSOR_CLI 0x1102 +#define ESP_BLE_MESH_MODEL_ID_TIME_SRV 0x1200 +#define ESP_BLE_MESH_MODEL_ID_TIME_SETUP_SRV 0x1201 +#define ESP_BLE_MESH_MODEL_ID_TIME_CLI 0x1202 +#define ESP_BLE_MESH_MODEL_ID_SCENE_SRV 0x1203 +#define ESP_BLE_MESH_MODEL_ID_SCENE_SETUP_SRV 0x1204 +#define ESP_BLE_MESH_MODEL_ID_SCENE_CLI 0x1205 +#define ESP_BLE_MESH_MODEL_ID_SCHEDULER_SRV 0x1206 +#define ESP_BLE_MESH_MODEL_ID_SCHEDULER_SETUP_SRV 0x1207 +#define ESP_BLE_MESH_MODEL_ID_SCHEDULER_CLI 0x1208 +#define ESP_BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SRV 0x1300 +#define ESP_BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SETUP_SRV 0x1301 +#define ESP_BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_CLI 0x1302 +#define ESP_BLE_MESH_MODEL_ID_LIGHT_CTL_SRV 0x1303 +#define ESP_BLE_MESH_MODEL_ID_LIGHT_CTL_SETUP_SRV 0x1304 +#define ESP_BLE_MESH_MODEL_ID_LIGHT_CTL_CLI 0x1305 +#define ESP_BLE_MESH_MODEL_ID_LIGHT_CTL_TEMP_SRV 0x1306 +#define ESP_BLE_MESH_MODEL_ID_LIGHT_HSL_SRV 0x1307 +#define ESP_BLE_MESH_MODEL_ID_LIGHT_HSL_SETUP_SRV 0x1308 +#define ESP_BLE_MESH_MODEL_ID_LIGHT_HSL_CLI 0x1309 +#define ESP_BLE_MESH_MODEL_ID_LIGHT_HSL_HUE_SRV 0x130a +#define ESP_BLE_MESH_MODEL_ID_LIGHT_HSL_SAT_SRV 0x130b +#define ESP_BLE_MESH_MODEL_ID_LIGHT_XYL_SRV 0x130c +#define ESP_BLE_MESH_MODEL_ID_LIGHT_XYL_SETUP_SRV 0x130d +#define ESP_BLE_MESH_MODEL_ID_LIGHT_XYL_CLI 0x130e +#define ESP_BLE_MESH_MODEL_ID_LIGHT_LC_SRV 0x130f +#define ESP_BLE_MESH_MODEL_ID_LIGHT_LC_SETUP_SRV 0x1310 +#define ESP_BLE_MESH_MODEL_ID_LIGHT_LC_CLI 0x1311 + +/** + * esp_ble_mesh_opcode_config_client_get_t belongs to esp_ble_mesh_opcode_t, this typedef is only + * used to locate the opcodes used by esp_ble_mesh_config_client_get_state. + * The following opcodes will only be used in the esp_ble_mesh_config_client_get_state function. + */ +typedef uint32_t esp_ble_mesh_opcode_config_client_get_t; + +#define ESP_BLE_MESH_MODEL_OP_BEACON_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x09) /*!< Config Beacon Get */ +#define ESP_BLE_MESH_MODEL_OP_COMPOSITION_DATA_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x08) /*!< Config Composition Data Get */ +#define ESP_BLE_MESH_MODEL_OP_DEFAULT_TTL_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x0C) /*!< Config Default TTL Get */ +#define ESP_BLE_MESH_MODEL_OP_GATT_PROXY_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x12) /*!< Config GATT Proxy Get */ +#define ESP_BLE_MESH_MODEL_OP_RELAY_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x26) /*!< Config Relay Get */ +#define ESP_BLE_MESH_MODEL_OP_MODEL_PUB_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x18) /*!< Config Model Publication Get */ +#define ESP_BLE_MESH_MODEL_OP_FRIEND_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x0F) /*!< Config Friend Get */ +#define ESP_BLE_MESH_MODEL_OP_HEARTBEAT_PUB_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x38) /*!< Config Heartbeat Publication Get */ +#define ESP_BLE_MESH_MODEL_OP_HEARTBEAT_SUB_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x3a) /*!< Config Heartbeat Subscription Get */ +#define ESP_BLE_MESH_MODEL_OP_NET_KEY_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x42) /*!< Config NetKey Get */ +#define ESP_BLE_MESH_MODEL_OP_APP_KEY_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x01) /*!< Config AppKey Get */ +#define ESP_BLE_MESH_MODEL_OP_NODE_IDENTITY_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x46) /*!< Config Node Identity Get */ +#define ESP_BLE_MESH_MODEL_OP_SIG_MODEL_SUB_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x29) /*!< Config SIG Model Subscription Get */ +#define ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_SUB_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x2B) /*!< Config Vendor Model Subscription Get */ +#define ESP_BLE_MESH_MODEL_OP_SIG_MODEL_APP_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x4B) /*!< Config SIG Model App Get */ +#define ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_APP_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x4D) /*!< Config Vendor Model App Get */ +#define ESP_BLE_MESH_MODEL_OP_KEY_REFRESH_PHASE_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x15) /*!< Config Key Refresh Phase Get */ +#define ESP_BLE_MESH_MODEL_OP_LPN_POLLTIMEOUT_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x2D) /*!< Config Low Power Node PollTimeout Get */ +#define ESP_BLE_MESH_MODEL_OP_NETWORK_TRANSMIT_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x23) /*!< Config Network Transmit Get */ + +/** + * esp_ble_mesh_opcode_config_client_set_t belongs to esp_ble_mesh_opcode_t, this typedef is + * only used to locate the opcodes used by esp_ble_mesh_config_client_set_state. + * The following opcodes will only be used in the esp_ble_mesh_config_client_set_state function. + */ +typedef uint32_t esp_ble_mesh_opcode_config_client_set_t; + +#define ESP_BLE_MESH_MODEL_OP_BEACON_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x0A) /*!< Config Beacon Set */ +#define ESP_BLE_MESH_MODEL_OP_DEFAULT_TTL_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x0D) /*!< Config Default TTL Set */ +#define ESP_BLE_MESH_MODEL_OP_GATT_PROXY_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x13) /*!< Config GATT Proxy Set */ +#define ESP_BLE_MESH_MODEL_OP_RELAY_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x27) /*!< Config Relay Set */ +#define ESP_BLE_MESH_MODEL_OP_MODEL_PUB_SET ESP_BLE_MESH_MODEL_OP_1(0x03) /*!< Config Model Publication Set */ +#define ESP_BLE_MESH_MODEL_OP_MODEL_SUB_ADD ESP_BLE_MESH_MODEL_OP_2(0x80, 0x1B) /*!< Config Model Subscription Add */ +#define ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_ADD ESP_BLE_MESH_MODEL_OP_2(0x80, 0x20) /*!< Config Model Subscription Virtual Address Add */ +#define ESP_BLE_MESH_MODEL_OP_MODEL_SUB_DELETE ESP_BLE_MESH_MODEL_OP_2(0x80, 0x1C) /*!< Config Model Subscription Delete */ +#define ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_DELETE ESP_BLE_MESH_MODEL_OP_2(0x80, 0x21) /*!< Config Model Subscription Virtual Address Delete */ +#define ESP_BLE_MESH_MODEL_OP_MODEL_SUB_OVERWRITE ESP_BLE_MESH_MODEL_OP_2(0x80, 0x1E) /*!< Config Model Subscription Overwrite */ +#define ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_OVERWRITE ESP_BLE_MESH_MODEL_OP_2(0x80, 0x22) /*!< Config Model Subscription Virtual Address Overwrite */ +#define ESP_BLE_MESH_MODEL_OP_NET_KEY_ADD ESP_BLE_MESH_MODEL_OP_2(0x80, 0x40) /*!< Config NetKey Add */ +#define ESP_BLE_MESH_MODEL_OP_APP_KEY_ADD ESP_BLE_MESH_MODEL_OP_1(0x00) /*!< Config AppKey Add */ +#define ESP_BLE_MESH_MODEL_OP_MODEL_APP_BIND ESP_BLE_MESH_MODEL_OP_2(0x80, 0x3D) /*!< Config Model App Bind */ +#define ESP_BLE_MESH_MODEL_OP_NODE_RESET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x49) /*!< Config Node Reset */ +#define ESP_BLE_MESH_MODEL_OP_FRIEND_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x10) /*!< Config Friend Set */ +#define ESP_BLE_MESH_MODEL_OP_HEARTBEAT_PUB_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x39) /*!< Config Heartbeat Publication Set */ +#define ESP_BLE_MESH_MODEL_OP_HEARTBEAT_SUB_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x3B) /*!< Config Heartbeat Subscription Set */ +#define ESP_BLE_MESH_MODEL_OP_NET_KEY_UPDATE ESP_BLE_MESH_MODEL_OP_2(0x80, 0x45) /*!< Config NetKey Update */ +#define ESP_BLE_MESH_MODEL_OP_NET_KEY_DELETE ESP_BLE_MESH_MODEL_OP_2(0x80, 0x41) /*!< Config NetKey Delete */ +#define ESP_BLE_MESH_MODEL_OP_APP_KEY_UPDATE ESP_BLE_MESH_MODEL_OP_1(0x01) /*!< Config AppKey Update */ +#define ESP_BLE_MESH_MODEL_OP_APP_KEY_DELETE ESP_BLE_MESH_MODEL_OP_2(0x80, 0x00) /*!< Config AppKey Delete */ +#define ESP_BLE_MESH_MODEL_OP_NODE_IDENTITY_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x47) /*!< Config Node Identity Set */ +#define ESP_BLE_MESH_MODEL_OP_KEY_REFRESH_PHASE_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x16) /*!< Config Key Refresh Phase Set */ +#define ESP_BLE_MESH_MODEL_OP_MODEL_PUB_VIRTUAL_ADDR_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x1A) /*!< Config Model Publication Virtual Address Set */ +#define ESP_BLE_MESH_MODEL_OP_MODEL_SUB_DELETE_ALL ESP_BLE_MESH_MODEL_OP_2(0x80, 0x1D) /*!< Config Model Subscription Delete All */ +#define ESP_BLE_MESH_MODEL_OP_MODEL_APP_UNBIND ESP_BLE_MESH_MODEL_OP_2(0x80, 0x3F) /*!< Config Model App Unbind */ +#define ESP_BLE_MESH_MODEL_OP_NETWORK_TRANSMIT_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x24) /*!< Config Network Transmit Set */ + +/** + * esp_ble_mesh_opcode_config_status_t belongs to esp_ble_mesh_opcode_t, this typedef is only + * used to locate the opcodes used by the Config Model messages + * The following opcodes are used by the BLE Mesh Config Server Model internally to respond + * to the Config Client Model's request messages. + */ +typedef uint32_t esp_ble_mesh_opcode_config_status_t; + +#define ESP_BLE_MESH_MODEL_OP_BEACON_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x0B) +#define ESP_BLE_MESH_MODEL_OP_COMPOSITION_DATA_STATUS ESP_BLE_MESH_MODEL_OP_1(0x02) +#define ESP_BLE_MESH_MODEL_OP_DEFAULT_TTL_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x0E) +#define ESP_BLE_MESH_MODEL_OP_GATT_PROXY_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x14) +#define ESP_BLE_MESH_MODEL_OP_RELAY_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x28) +#define ESP_BLE_MESH_MODEL_OP_MODEL_PUB_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x19) +#define ESP_BLE_MESH_MODEL_OP_MODEL_SUB_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x1F) +#define ESP_BLE_MESH_MODEL_OP_SIG_MODEL_SUB_LIST ESP_BLE_MESH_MODEL_OP_2(0x80, 0x2A) +#define ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_SUB_LIST ESP_BLE_MESH_MODEL_OP_2(0x80, 0x2C) +#define ESP_BLE_MESH_MODEL_OP_NET_KEY_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x44) +#define ESP_BLE_MESH_MODEL_OP_NET_KEY_LIST ESP_BLE_MESH_MODEL_OP_2(0x80, 0x43) +#define ESP_BLE_MESH_MODEL_OP_APP_KEY_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x03) +#define ESP_BLE_MESH_MODEL_OP_APP_KEY_LIST ESP_BLE_MESH_MODEL_OP_2(0x80, 0x02) +#define ESP_BLE_MESH_MODEL_OP_NODE_IDENTITY_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x48) +#define ESP_BLE_MESH_MODEL_OP_MODEL_APP_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x3E) +#define ESP_BLE_MESH_MODEL_OP_SIG_MODEL_APP_LIST ESP_BLE_MESH_MODEL_OP_2(0x80, 0x4C) +#define ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_APP_LIST ESP_BLE_MESH_MODEL_OP_2(0x80, 0x4E) +#define ESP_BLE_MESH_MODEL_OP_NODE_RESET_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x4A) +#define ESP_BLE_MESH_MODEL_OP_FRIEND_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x11) +#define ESP_BLE_MESH_MODEL_OP_KEY_REFRESH_PHASE_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x17) +#define ESP_BLE_MESH_MODEL_OP_HEARTBEAT_PUB_STATUS ESP_BLE_MESH_MODEL_OP_1(0x06) +#define ESP_BLE_MESH_MODEL_OP_HEARTBEAT_SUB_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x3C) +#define ESP_BLE_MESH_MODEL_OP_LPN_POLLTIMEOUT_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x2E) +#define ESP_BLE_MESH_MODEL_OP_NETWORK_TRANSMIT_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x25) + +/** + * This typedef is only used to indicate the status code contained in some of + * the Configuration Server Model status message. + */ +typedef uint8_t esp_ble_mesh_cfg_status_t; + +#define ESP_BLE_MESH_CFG_STATUS_SUCCESS 0x00 +#define ESP_BLE_MESH_CFG_STATUS_INVALID_ADDRESS 0x01 +#define ESP_BLE_MESH_CFG_STATUS_INVALID_MODEL 0x02 +#define ESP_BLE_MESH_CFG_STATUS_INVALID_APPKEY 0x03 +#define ESP_BLE_MESH_CFG_STATUS_INVALID_NETKEY 0x04 +#define ESP_BLE_MESH_CFG_STATUS_INSUFFICIENT_RESOURCES 0x05 +#define ESP_BLE_MESH_CFG_STATUS_KEY_INDEX_ALREADY_STORED 0x06 +#define ESP_BLE_MESH_CFG_STATUS_INVALID_PUBLISH_PARAMETERS 0x07 +#define ESP_BLE_MESH_CFG_STATUS_NOT_A_SUBSCRIBE_MODEL 0x08 +#define ESP_BLE_MESH_CFG_STATUS_STORAGE_FAILURE 0x09 +#define ESP_BLE_MESH_CFG_STATUS_FEATURE_NOT_SUPPORTED 0x0A +#define ESP_BLE_MESH_CFG_STATUS_CANNOT_UPDATE 0x0B +#define ESP_BLE_MESH_CFG_STATUS_CANNOT_REMOVE 0x0C +#define ESP_BLE_MESH_CFG_STATUS_CANNOT_BIND 0x0D +#define ESP_BLE_MESH_CFG_STATUS_TEMP_UNABLE_TO_CHANGE_STATE 0x0E +#define ESP_BLE_MESH_CFG_STATUS_CANNOT_SET 0x0F +#define ESP_BLE_MESH_CFG_STATUS_UNSPECIFIED_ERROR 0x10 +#define ESP_BLE_MESH_CFG_STATUS_INVALID_BINDING 0x11 + +/** + * esp_ble_mesh_opcode_health_client_get_t belongs to esp_ble_mesh_opcode_t, this typedef is + * only used to locate the opcodes used by esp_ble_mesh_health_client_get_state. + * The following opcodes will only be used in the esp_ble_mesh_health_client_get_state function. + */ +typedef uint32_t esp_ble_mesh_opcode_health_client_get_t; + +#define ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x31) /*!< Health Fault Get */ +#define ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x34) /*!< Health Period Get */ +#define ESP_BLE_MESH_MODEL_OP_ATTENTION_GET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x04) /*!< Health Attention Get */ + +/** + * esp_ble_mesh_opcode_health_client_set_t belongs to esp_ble_mesh_opcode_t, this typedef is + * only used to locate the opcodes used by esp_ble_mesh_health_client_set_state. + * The following opcodes will only be used in the esp_ble_mesh_health_client_set_state function. + */ +typedef uint32_t esp_ble_mesh_opcode_health_client_set_t; + +#define ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR ESP_BLE_MESH_MODEL_OP_2(0x80, 0x2F) /*!< Health Fault Clear */ +#define ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR_UNACK ESP_BLE_MESH_MODEL_OP_2(0x80, 0x30) /*!< Health Fault Clear Unacknowledged */ +#define ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST ESP_BLE_MESH_MODEL_OP_2(0x80, 0x32) /*!< Health Fault Test */ +#define ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST_UNACK ESP_BLE_MESH_MODEL_OP_2(0x80, 0x33) /*!< Health Fault Test Unacknowledged */ +#define ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x35) /*!< Health Period Set */ +#define ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x80, 0x36) /*!< Health Period Set Unacknowledged */ +#define ESP_BLE_MESH_MODEL_OP_ATTENTION_SET ESP_BLE_MESH_MODEL_OP_2(0x80, 0x05) /*!< Health Attention Set */ +#define ESP_BLE_MESH_MODEL_OP_ATTENTION_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x80, 0x06) /*!< Health Attention Set Unacknowledged */ + +/** + * esp_ble_mesh_health_model_status_t belongs to esp_ble_mesh_opcode_t, this typedef is + * only used to locate the opcodes used by the Health Model messages. + * The following opcodes are used by the BLE Mesh Health Server Model internally to + * respond to the Health Client Model's request messages. + */ +typedef uint32_t esp_ble_mesh_health_model_status_t; + +#define ESP_BLE_MESH_MODEL_OP_HEALTH_CURRENT_STATUS ESP_BLE_MESH_MODEL_OP_1(0x04) +#define ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_STATUS ESP_BLE_MESH_MODEL_OP_1(0x05) +#define ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x37) +#define ESP_BLE_MESH_MODEL_OP_ATTENTION_STATUS ESP_BLE_MESH_MODEL_OP_2(0x80, 0x07) + +/** + * esp_ble_mesh_generic_message_opcode_t belongs to esp_ble_mesh_opcode_t, this typedef is + * only used to locate the opcodes used by functions esp_ble_mesh_generic_client_get_state + * & esp_ble_mesh_generic_client_set_state. + */ +typedef uint32_t esp_ble_mesh_generic_message_opcode_t; + +/*!< Generic OnOff Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x01) +#define ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x02) +#define ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x03) +#define ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x04) + +/*!< Generic Level Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_GEN_LEVEL_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x05) +#define ESP_BLE_MESH_MODEL_OP_GEN_LEVEL_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x06) +#define ESP_BLE_MESH_MODEL_OP_GEN_LEVEL_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x07) +#define ESP_BLE_MESH_MODEL_OP_GEN_LEVEL_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x08) +#define ESP_BLE_MESH_MODEL_OP_GEN_DELTA_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x09) +#define ESP_BLE_MESH_MODEL_OP_GEN_DELTA_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x0A) +#define ESP_BLE_MESH_MODEL_OP_GEN_MOVE_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x0B) +#define ESP_BLE_MESH_MODEL_OP_GEN_MOVE_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x0C) + +/*!< Generic Default Transition Time Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x0D) +#define ESP_BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x0E) +#define ESP_BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x0F) +#define ESP_BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x10) + +/*!< Generic Power OnOff Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_GEN_ONPOWERUP_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x11) +#define ESP_BLE_MESH_MODEL_OP_GEN_ONPOWERUP_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x12) + +/*!< Generic Power OnOff Setup Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_GEN_ONPOWERUP_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x13) +#define ESP_BLE_MESH_MODEL_OP_GEN_ONPOWERUP_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x14) + +/*!< Generic Power Level Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x15) +#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x16) +#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x17) +#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x18) +#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_LAST_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x19) +#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_LAST_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x1A) +#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x1B) +#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x1C) +#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_RANGE_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x1D) +#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_RANGE_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x1E) + +/*!< Generic Power Level Setup Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x1F) +#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x20) +#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_RANGE_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x21) +#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_RANGE_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x22) + +/*!< Generic Battery Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_GEN_BATTERY_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x23) +#define ESP_BLE_MESH_MODEL_OP_GEN_BATTERY_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x24) + +/*!< Generic Location Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x25) +#define ESP_BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_STATUS ESP_BLE_MESH_MODEL_OP_1(0x40) +#define ESP_BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x26) +#define ESP_BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x27) + +/*!< Generic Location Setup Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_SET ESP_BLE_MESH_MODEL_OP_1(0x41) +#define ESP_BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_SET_UNACK ESP_BLE_MESH_MODEL_OP_1(0x42) +#define ESP_BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x28) +#define ESP_BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x29) + +/*!< Generic Manufacturer Property Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTIES_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x2A) +#define ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTIES_STATUS ESP_BLE_MESH_MODEL_OP_1(0x43) +#define ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTY_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x2B) +#define ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTY_SET ESP_BLE_MESH_MODEL_OP_1(0x44) +#define ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTY_SET_UNACK ESP_BLE_MESH_MODEL_OP_1(0x45) +#define ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTY_STATUS ESP_BLE_MESH_MODEL_OP_1(0x46) + +/*!< Generic Admin Property Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTIES_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x2C) +#define ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTIES_STATUS ESP_BLE_MESH_MODEL_OP_1(0x47) +#define ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x2D) +#define ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET ESP_BLE_MESH_MODEL_OP_1(0x48) +#define ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET_UNACK ESP_BLE_MESH_MODEL_OP_1(0x49) +#define ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_STATUS ESP_BLE_MESH_MODEL_OP_1(0x4A) + +/*!< Generic User Property Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x2E) +#define ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_STATUS ESP_BLE_MESH_MODEL_OP_1(0x4B) +#define ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x2F) +#define ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET ESP_BLE_MESH_MODEL_OP_1(0x4C) +#define ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET_UNACK ESP_BLE_MESH_MODEL_OP_1(0x4D) +#define ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_STATUS ESP_BLE_MESH_MODEL_OP_1(0x4E) + +/*!< Generic Client Property Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_GEN_CLIENT_PROPERTIES_GET ESP_BLE_MESH_MODEL_OP_1(0x4F) +#define ESP_BLE_MESH_MODEL_OP_GEN_CLIENT_PROPERTIES_STATUS ESP_BLE_MESH_MODEL_OP_1(0x50) + +/** + * esp_ble_mesh_sensor_message_opcode_t belongs to esp_ble_mesh_opcode_t, this typedef is + * only used to locate the opcodes used by functions esp_ble_mesh_sensor_client_get_state + * & esp_ble_mesh_sensor_client_set_state. + */ +typedef uint32_t esp_ble_mesh_sensor_message_opcode_t; + +/*!< Sensor Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x30) +#define ESP_BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_STATUS ESP_BLE_MESH_MODEL_OP_1(0x51) +#define ESP_BLE_MESH_MODEL_OP_SENSOR_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x31) +#define ESP_BLE_MESH_MODEL_OP_SENSOR_STATUS ESP_BLE_MESH_MODEL_OP_1(0x52) +#define ESP_BLE_MESH_MODEL_OP_SENSOR_COLUMN_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x32) +#define ESP_BLE_MESH_MODEL_OP_SENSOR_COLUMN_STATUS ESP_BLE_MESH_MODEL_OP_1(0x53) +#define ESP_BLE_MESH_MODEL_OP_SENSOR_SERIES_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x33) +#define ESP_BLE_MESH_MODEL_OP_SENSOR_SERIES_STATUS ESP_BLE_MESH_MODEL_OP_1(0x54) + +/*!< Sensor Setup Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x34) +#define ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET ESP_BLE_MESH_MODEL_OP_1(0x55) +#define ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET_UNACK ESP_BLE_MESH_MODEL_OP_1(0x56) +#define ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_STATUS ESP_BLE_MESH_MODEL_OP_1(0x57) +#define ESP_BLE_MESH_MODEL_OP_SENSOR_SETTINGS_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x35) +#define ESP_BLE_MESH_MODEL_OP_SENSOR_SETTINGS_STATUS ESP_BLE_MESH_MODEL_OP_1(0x58) +#define ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x36) +#define ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET ESP_BLE_MESH_MODEL_OP_1(0x59) +#define ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET_UNACK ESP_BLE_MESH_MODEL_OP_1(0x5A) +#define ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_STATUS ESP_BLE_MESH_MODEL_OP_1(0x5B) + +/** + * esp_ble_mesh_time_scene_message_opcode_t belongs to esp_ble_mesh_opcode_t, this typedef is + * only used to locate the opcodes used by functions esp_ble_mesh_time_scene_client_get_state + * & esp_ble_mesh_time_scene_client_set_state. + */ +typedef uint32_t esp_ble_mesh_time_scene_message_opcode_t; + +/*!< Time Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_TIME_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x37) +#define ESP_BLE_MESH_MODEL_OP_TIME_SET ESP_BLE_MESH_MODEL_OP_1(0x5C) +#define ESP_BLE_MESH_MODEL_OP_TIME_STATUS ESP_BLE_MESH_MODEL_OP_1(0x5D) +#define ESP_BLE_MESH_MODEL_OP_TIME_ROLE_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x38) +#define ESP_BLE_MESH_MODEL_OP_TIME_ROLE_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x39) +#define ESP_BLE_MESH_MODEL_OP_TIME_ROLE_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x3A) +#define ESP_BLE_MESH_MODEL_OP_TIME_ZONE_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x3B) +#define ESP_BLE_MESH_MODEL_OP_TIME_ZONE_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x3C) +#define ESP_BLE_MESH_MODEL_OP_TIME_ZONE_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x3D) +#define ESP_BLE_MESH_MODEL_OP_TAI_UTC_DELTA_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x3E) +#define ESP_BLE_MESH_MODEL_OP_TAI_UTC_DELTA_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x3F) +#define ESP_BLE_MESH_MODEL_OP_TAI_UTC_DELTA_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x40) + +/*!< Scene Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_SCENE_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x41) +#define ESP_BLE_MESH_MODEL_OP_SCENE_RECALL ESP_BLE_MESH_MODEL_OP_2(0x82, 0x42) +#define ESP_BLE_MESH_MODEL_OP_SCENE_RECALL_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x43) +#define ESP_BLE_MESH_MODEL_OP_SCENE_STATUS ESP_BLE_MESH_MODEL_OP_1(0x5E) +#define ESP_BLE_MESH_MODEL_OP_SCENE_REGISTER_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x44) +#define ESP_BLE_MESH_MODEL_OP_SCENE_REGISTER_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x45) + +/*!< Scene Setup Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_SCENE_STORE ESP_BLE_MESH_MODEL_OP_2(0x82, 0x46) +#define ESP_BLE_MESH_MODEL_OP_SCENE_STORE_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x47) +#define ESP_BLE_MESH_MODEL_OP_SCENE_DELETE ESP_BLE_MESH_MODEL_OP_2(0x82, 0x9E) +#define ESP_BLE_MESH_MODEL_OP_SCENE_DELETE_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x9F) + +/*!< Scheduler Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x48) +#define ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_STATUS ESP_BLE_MESH_MODEL_OP_1(0x5F) +#define ESP_BLE_MESH_MODEL_OP_SCHEDULER_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x49) +#define ESP_BLE_MESH_MODEL_OP_SCHEDULER_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x4A) + +/*!< Scheduler Setup Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_SET ESP_BLE_MESH_MODEL_OP_1(0x60) +#define ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_SET_UNACK ESP_BLE_MESH_MODEL_OP_1(0x61) + +/** + * esp_ble_mesh_light_message_opcode_t belongs to esp_ble_mesh_opcode_t, this typedef is + * only used to locate the opcodes used by functions esp_ble_mesh_light_client_get_state + * & esp_ble_mesh_light_client_set_state. + */ +typedef uint32_t esp_ble_mesh_light_message_opcode_t; + +/*!< Light Lightness Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x4B) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x4C) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x4D) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x4E) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x4F) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x50) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x51) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x52) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LAST_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x53) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LAST_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x54) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x55) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x56) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x57) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x58) + +/*!< Light Lightness Setup Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x59) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x5A) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x5B) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x5C) + +/*!< Light CTL Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x5D) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x5E) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x5F) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x60) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x61) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x62) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x63) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x64) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x65) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x66) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x67) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x68) + +/*!< Light CTL Setup Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x69) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x6A) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x6B) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x6C) + +/*!< Light HSL Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x6D) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x6E) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x6F) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x70) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x71) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x72) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x73) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x74) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x75) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x76) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x77) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x78) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_TARGET_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x79) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_TARGET_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x7A) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x7B) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x7C) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x7D) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x7E) + +/*!< Light HSL Setup Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x7F) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x80) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x81) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x82) + +/*!< Light xyL Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x83) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x84) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x85) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x86) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_TARGET_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x87) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_TARGET_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x88) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x89) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x8A) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x8B) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x8C) + +/*!< Light xyL Setup Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x8D) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x8E) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x8F) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x90) + +/*!< Light Control Message Opcode */ +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_MODE_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x91) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_MODE_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x92) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_MODE_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x93) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_MODE_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x94) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_OM_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x95) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_OM_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x96) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_OM_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x97) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_OM_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x98) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x99) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_SET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x9A) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_SET_UNACK ESP_BLE_MESH_MODEL_OP_2(0x82, 0x9B) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_STATUS ESP_BLE_MESH_MODEL_OP_2(0x82, 0x9C) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_GET ESP_BLE_MESH_MODEL_OP_2(0x82, 0x9D) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET ESP_BLE_MESH_MODEL_OP_1(0x62) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET_UNACK ESP_BLE_MESH_MODEL_OP_1(0x63) +#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_STATUS ESP_BLE_MESH_MODEL_OP_1(0x64) + +typedef uint32_t esp_ble_mesh_opcode_t; +/*!< End of defines of esp_ble_mesh_opcode_t */ + +/** + * This typedef is only used to indicate the status code contained in some of the + * server models (e.g. Generic Server Model) status message. + */ +typedef uint8_t esp_ble_mesh_model_status_t; + +#define ESP_BLE_MESH_MODEL_STATUS_SUCCESS 0x00 +#define ESP_BLE_MESH_MODEL_STATUS_CANNOT_SET_RANGE_MIN 0x01 +#define ESP_BLE_MESH_MODEL_STATUS_CANNOT_SET_RANGE_MAX 0x02 + +/** + * @brief BLE Mesh client models related definitions + */ + +/** Client model Get/Set message opcode and corresponding Status message opcode */ +typedef struct { + uint32_t cli_op; /*!< The client message opcode */ + uint32_t status_op; /*!< The server status opcode corresponding to the client message opcode */ +} esp_ble_mesh_client_op_pair_t; + +/** Client Model user data context. */ +typedef struct { + esp_ble_mesh_model_t *model; /*!< Pointer to the client model. Initialized by the stack. */ + int op_pair_size; /*!< Size of the op_pair */ + const esp_ble_mesh_client_op_pair_t *op_pair; /*!< Table containing get/set message opcode and corresponding status message opcode */ + uint32_t publish_status; /*!< Callback used to handle the received unsolicited message. Initialized by the stack. */ + void *internal_data; /*!< Pointer to the internal data of client model */ + uint8_t msg_role; /*!< Role of the device (Node/Provisioner) that is going to send messages */ +} esp_ble_mesh_client_t; + +/** Common parameters of the messages sent by Client Model. */ +typedef struct { + esp_ble_mesh_opcode_t opcode; /*!< Message opcode */ + esp_ble_mesh_model_t *model; /*!< Pointer to the client model structure */ + esp_ble_mesh_msg_ctx_t ctx; /*!< The context used to send message */ + int32_t msg_timeout; /*!< Timeout value (ms) to get response to the sent message */ + /*!< Note: if using default timeout value in menuconfig, make sure to set this value to 0 */ + uint8_t msg_role; /*!< Role of the device - Node/Provisioner */ +} esp_ble_mesh_client_common_param_t; + +/** + * @brief BLE Mesh server models related definitions + */ + +/** This enum value is the flag of transition timer operation */ +enum { + ESP_BLE_MESH_SERVER_TRANS_TIMER_START, /* Proper transition timer has been started */ + ESP_BLE_MESH_SERVER_FLAG_MAX, +}; + +/** Parameters of the server model state transition */ +typedef struct { + bool just_started; /*!< Indicate if the state transition has just started */ + + uint8_t trans_time; /*!< State transition time */ + uint8_t remain_time; /*!< Remaining time of state transition */ + uint8_t delay; /*!< Delay before starting state transition */ + uint32_t quo_tt; /*!< Duration of each divided transition step */ + uint32_t counter; /*!< Number of steps which the transition duration is divided */ + uint32_t total_duration; /*!< State transition total duration */ + int64_t start_timestamp; /*!< Time when the state transition is started */ + + /** + * Flag used to indicate if the transition timer has been started internally. + * + * If the model which contains esp_ble_mesh_state_transition_t sets "set_auto_rsp" + * to ESP_BLE_MESH_SERVER_RSP_BY_APP, the handler of the timer shall be initialized + * by the users. + * + * And users can use this flag to indicate whether the timer is started or not. + */ + BLE_MESH_ATOMIC_DEFINE(flag, ESP_BLE_MESH_SERVER_FLAG_MAX); + struct k_delayed_work timer; /*!< Timer used for state transition */ +} esp_ble_mesh_state_transition_t; + +/** Parameters of the server model received last same set message. */ +typedef struct { + uint8_t tid; /*!< Transaction number of the last message */ + uint16_t src; /*!< Source address of the last message */ + uint16_t dst; /*!< Destination address of the last message */ + int64_t timestamp; /*!< Time when the last message is received */ +} esp_ble_mesh_last_msg_info_t; + +#define ESP_BLE_MESH_SERVER_RSP_BY_APP 0 /*!< Response need to be sent in the application */ +#define ESP_BLE_MESH_SERVER_AUTO_RSP 1 /*!< Response will be sent internally */ + +/** Parameters of the Server Model response control */ +typedef struct { + /** + * @brief BLE Mesh Server Response Option + * 1. If get_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, then the + * response of Client Get messages need to be replied by the application; + * 2. If get_auto_rsp is set to ESP_BLE_MESH_SERVER_AUTO_RSP, then the + * response of Client Get messages will be replied by the server models; + * 3. If set_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, then the + * response of Client Set messages need to be replied by the application; + * 4. If set_auto_rsp is set to ESP_BLE_MESH_SERVER_AUTO_RSP, then the + * response of Client Set messages will be replied by the server models; + * 5. If status_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, then the + * response of Server Status messages need to be replied by the application; + * 6. If status_auto_rsp is set to ESP_BLE_MESH_SERVER_AUTO_RSP, then the + * response of Server Status messages will be replied by the server models; + */ + uint8_t get_auto_rsp : 1, /*!< Response control for Client Get messages */ + set_auto_rsp : 1, /*!< Response control for Client Set messages */ + status_auto_rsp : 1; /*!< Response control for Server Status messages */ +} esp_ble_mesh_server_rsp_ctrl_t; + +/** + * @brief Server model state value union + */ +typedef union { + struct { + uint8_t onoff; /*!< The value of the Generic OnOff state */ + } gen_onoff; /*!< The Generic OnOff state */ + struct { + int16_t level; /*!< The value of the Generic Level state */ + } gen_level; /*!< The Generic Level state */ + struct { + uint8_t onpowerup; /*!< The value of the Generic OnPowerUp state */ + } gen_onpowerup; /*!< The Generic OnPowerUp state */ + struct { + uint16_t power; /*!< The value of the Generic Power Actual state */ + } gen_power_actual; /*!< The Generic Power Actual state */ + struct { + uint16_t lightness; /*!< The value of the Light Lightness Actual state */ + } light_lightness_actual; /*!< The Light Lightness Actual state */ + struct { + uint16_t lightness; /*!< The value of the Light Lightness Linear state */ + } light_lightness_linear; /*!< The Light Lightness Linear state */ + struct { + uint16_t lightness; /*!< The value of the Light CTL Lightness state */ + } light_ctl_lightness; /*!< The Light CTL Lightness state */ + struct { + uint16_t temperature; /*!< The value of the Light CTL Temperature state */ + int16_t delta_uv; /*!< The value of the Light CTL Delta UV state */ + } light_ctl_temp_delta_uv; /*!< The Light CTL Temperature & Delta UV states */ + struct { + uint16_t lightness; /*!< The value of the Light HSL Lightness state */ + uint16_t hue; /*!< The value of the Light HSL Hue state */ + uint16_t saturation; /*!< The value of the Light HSL Saturation state */ + } light_hsl; /*!< The Light HSL composite state */ + struct { + uint16_t lightness; /*!< The value of the Light HSL Lightness state */ + } light_hsl_lightness; /*!< The Light HSL Lightness state */ + struct { + uint16_t hue; /*!< The value of the Light HSL Hue state */ + } light_hsl_hue; /*!< The Light HSL Hue state */ + struct { + uint16_t saturation; /*!< The value of the Light HSL Saturation state */ + } light_hsl_saturation; /*!< The Light HSL Saturation state */ + struct { + uint16_t lightness; /*!< The value of the Light xyL Lightness state */ + } light_xyl_lightness; /*!< The Light xyL Lightness state */ + struct { + uint8_t onoff; /*!< The value of the Light LC Light OnOff state */ + } light_lc_light_onoff; /*!< The Light LC Light OnOff state */ +} esp_ble_mesh_server_state_value_t; + +/** This enum value is the type of server model states */ +typedef enum { + ESP_BLE_MESH_GENERIC_ONOFF_STATE, + ESP_BLE_MESH_GENERIC_LEVEL_STATE, + ESP_BLE_MESH_GENERIC_ONPOWERUP_STATE, + ESP_BLE_MESH_GENERIC_POWER_ACTUAL_STATE, + ESP_BLE_MESH_LIGHT_LIGHTNESS_ACTUAL_STATE, + ESP_BLE_MESH_LIGHT_LIGHTNESS_LINEAR_STATE, + ESP_BLE_MESH_LIGHT_CTL_LIGHTNESS_STATE, + ESP_BLE_MESH_LIGHT_CTL_TEMP_DELTA_UV_STATE, + ESP_BLE_MESH_LIGHT_HSL_STATE, + ESP_BLE_MESH_LIGHT_HSL_LIGHTNESS_STATE, + ESP_BLE_MESH_LIGHT_HSL_HUE_STATE, + ESP_BLE_MESH_LIGHT_HSL_SATURATION_STATE, + ESP_BLE_MESH_LIGHT_XYL_LIGHTNESS_STATE, + ESP_BLE_MESH_LIGHT_LC_LIGHT_ONOFF_STATE, + ESP_BLE_MESH_SERVER_MODEL_STATE_MAX, +} esp_ble_mesh_server_state_type_t; + +/*!< This enum value is the event of undefined SIG models and vendor models */ +typedef enum { + ESP_BLE_MESH_MODEL_OPERATION_EVT, /*!< User-defined models receive messages from peer devices (e.g. get, set, status, etc) event */ + ESP_BLE_MESH_MODEL_SEND_COMP_EVT, /*!< User-defined models send messages completion event */ + ESP_BLE_MESH_MODEL_PUBLISH_COMP_EVT, /*!< User-defined models publish messages completion event */ + ESP_BLE_MESH_CLIENT_MODEL_RECV_PUBLISH_MSG_EVT, /*!< User-defined client models receive publish messages event */ + ESP_BLE_MESH_CLIENT_MODEL_SEND_TIMEOUT_EVT, /*!< Timeout event for the user-defined client models that failed to receive response from peer server models */ + ESP_BLE_MESH_MODEL_PUBLISH_UPDATE_EVT, /*!< When a model is configured to publish messages periodically, this event will occur during every publish period */ + ESP_BLE_MESH_SERVER_MODEL_UPDATE_STATE_COMP_EVT, /*!< Server models update state value completion event */ + ESP_BLE_MESH_MODEL_EVT_MAX, +} esp_ble_mesh_model_cb_event_t; + +/** + * @brief BLE Mesh model callback parameters union + */ +typedef union { + /** + * @brief ESP_BLE_MESH_MODEL_OPERATION_EVT + */ + struct ble_mesh_model_operation_evt_param { + uint32_t opcode; /*!< Opcode of the received message */ + esp_ble_mesh_model_t *model; /*!< Pointer to the model which receives the message */ + esp_ble_mesh_msg_ctx_t *ctx; /*!< Pointer to the context of the received message */ + uint16_t length; /*!< Length of the received message */ + uint8_t *msg; /*!< Value of the received message */ + } model_operation; /*!< Event parameter of ESP_BLE_MESH_MODEL_OPERATION_EVT */ + /** + * @brief ESP_BLE_MESH_MODEL_SEND_COMP_EVT + */ + struct ble_mesh_model_send_comp_param { + int err_code; /*!< Indicate the result of sending a message */ + uint32_t opcode; /*!< Opcode of the message */ + esp_ble_mesh_model_t *model; /*!< Pointer to the model which sends the message */ + esp_ble_mesh_msg_ctx_t *ctx; /*!< Context of the message */ + } model_send_comp; /*!< Event parameter of ESP_BLE_MESH_MODEL_SEND_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_MODEL_PUBLISH_COMP_EVT + */ + struct ble_mesh_model_publish_comp_param { + int err_code; /*!< Indicate the result of publishing a message */ + esp_ble_mesh_model_t *model; /*!< Pointer to the model which publishes the message */ + } model_publish_comp; /*!< Event parameter of ESP_BLE_MESH_MODEL_PUBLISH_COMP_EVT */ + /** + * @brief ESP_BLE_MESH_CLIENT_MODEL_RECV_PUBLISH_MSG_EVT + */ + struct ble_mesh_mod_recv_publish_msg_param { + uint32_t opcode; /*!< Opcode of the unsolicited received message */ + esp_ble_mesh_model_t *model; /*!< Pointer to the model which receives the message */ + esp_ble_mesh_msg_ctx_t *ctx; /*!< Pointer to the context of the message */ + uint16_t length; /*!< Length of the received message */ + uint8_t *msg; /*!< Value of the received message */ + } client_recv_publish_msg; /*!< Event parameter of ESP_BLE_MESH_CLIENT_MODEL_RECV_PUBLISH_MSG_EVT */ + /** + * @brief ESP_BLE_MESH_CLIENT_MODEL_SEND_TIMEOUT_EVT + */ + struct ble_mesh_client_model_send_timeout_param { + uint32_t opcode; /*!< Opcode of the previously sent message */ + esp_ble_mesh_model_t *model; /*!< Pointer to the model which sends the previous message */ + esp_ble_mesh_msg_ctx_t *ctx; /*!< Pointer to the context of the previous message */ + } client_send_timeout; /*!< Event parameter of ESP_BLE_MESH_CLIENT_MODEL_SEND_TIMEOUT_EVT */ + /** + * @brief ESP_BLE_MESH_MODEL_PUBLISH_UPDATE_EVT + */ + struct ble_mesh_model_publish_update_evt_param { + esp_ble_mesh_model_t *model; /*!< Pointer to the model which is going to update its publish message */ + } model_publish_update; /*!< Event parameter of ESP_BLE_MESH_MODEL_PUBLISH_UPDATE_EVT */ + /** + * @brief ESP_BLE_MESH_SERVER_MODEL_UPDATE_STATE_COMP_EVT + */ + struct ble_mesh_server_model_update_state_comp_param { + int err_code; /*!< Indicate the result of updating server model state */ + esp_ble_mesh_model_t *model; /*!< Pointer to the server model which state value is updated */ + esp_ble_mesh_server_state_type_t type; /*!< Type of the updated server state */ + } server_model_update_state; /*!< Event parameter of ESP_BLE_MESH_SERVER_MODEL_UPDATE_STATE_COMP_EVT */ +} esp_ble_mesh_model_cb_param_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _ESP_BLE_MESH_DEFS_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_config_model_api.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_config_model_api.h new file mode 100644 index 00000000000..31369d89567 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_config_model_api.h @@ -0,0 +1,817 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _ESP_BLE_MESH_CONFIG_MODEL_API_H_ +#define _ESP_BLE_MESH_CONFIG_MODEL_API_H_ + +#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. + * + * @note The Config Server Model can only be included by a Primary Element. + * + * @param srv_data Pointer to a unique Config Server Model user_data. + * + * @return New Config Server Model instance. + */ +#define ESP_BLE_MESH_MODEL_CFG_SRV(srv_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_CONFIG_SRV, \ + NULL, NULL, srv_data) + +/** @def ESP_BLE_MESH_MODEL_CFG_CLI + * + * @brief Define a new Config Client Model. + * + * @note The Config Client Model can only be included by a Primary Element. + * + * @param cli_data Pointer to a unique struct esp_ble_mesh_client_t. + * + * @return New Config Client Model instance. + */ +#define ESP_BLE_MESH_MODEL_CFG_CLI(cli_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_CONFIG_CLI, \ + NULL, NULL, cli_data) + +/** Configuration Server Model context */ +typedef struct esp_ble_mesh_cfg_srv { + esp_ble_mesh_model_t *model; /*!< Pointer to Configuration Server Model */ + + uint8_t net_transmit; /*!< Network Transmit state */ + uint8_t relay; /*!< Relay Mode state */ + uint8_t relay_retransmit; /*!< Relay Retransmit state */ + uint8_t beacon; /*!< Secure Network Beacon state */ + uint8_t gatt_proxy; /*!< GATT Proxy state */ + uint8_t friend_state; /*!< Friend state */ + uint8_t default_ttl; /*!< Default TTL */ + + /** Heartbeat Publication */ + struct { + struct k_delayed_work timer; /*!< Heartbeat Publication timer */ + + uint16_t dst; /*!< Destination address for Heartbeat messages */ + uint16_t count; /*!< Number of Heartbeat messages to be sent */ + uint8_t period; /*!< Period for sending Heartbeat messages */ + uint8_t ttl; /*!< TTL to be used when sending Heartbeat messages */ + uint16_t feature; /*!< Bit field indicating features that trigger Heartbeat messages when changed */ + uint16_t net_idx; /*!< NetKey Index used by Heartbeat Publication */ + } heartbeat_pub; + + /** Heartbeat Subscription */ + struct { + int64_t expiry; /*!< Timestamp when Heartbeat subscription period is expired */ + + uint16_t src; /*!< Source address for Heartbeat messages */ + uint16_t dst; /*!< Destination address for Heartbeat messages */ + uint16_t count; /*!< Number of Heartbeat messages received */ + uint8_t min_hops; /*!< Minimum hops when receiving Heartbeat messages */ + uint8_t max_hops; /*!< Maximum hops when receiving Heartbeat messages */ + + /** Optional heartbeat subscription tracking function */ + esp_ble_mesh_cb_t heartbeat_recv_cb; + } heartbeat_sub; +} esp_ble_mesh_cfg_srv_t; + +/** Parameters of Config Composition Data Get. */ +typedef struct { + uint8_t page; /*!< Page number of the Composition Data. */ +} esp_ble_mesh_cfg_composition_data_get_t; + +/** Parameters of Config Model Publication Get. */ +typedef struct { + uint16_t element_addr; /*!< The element address */ + uint16_t model_id; /*!< The model id */ + uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */ +} esp_ble_mesh_cfg_model_pub_get_t; + +/** Parameters of Config SIG Model Subscription Get. */ +typedef struct { + uint16_t element_addr; /*!< The element address */ + uint16_t model_id; /*!< The model id */ +} esp_ble_mesh_cfg_sig_model_sub_get_t; + +/** Parameters of Config Vendor Model Subscription Get. */ +typedef struct { + uint16_t element_addr; /*!< The element address */ + uint16_t model_id; /*!< The model id */ + uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */ +} esp_ble_mesh_cfg_vnd_model_sub_get_t; + +/** Parameters of Config AppKey Get. */ +typedef struct { + uint16_t net_idx; /*!< The network key index */ +} esp_ble_mesh_cfg_app_key_get_t; + +/** Parameters of Config Node Identity Get. */ +typedef struct { + uint16_t net_idx; /*!< The network key index */ +} esp_ble_mesh_cfg_node_identity_get_t; + +/** Parameters of Config SIG Model App Get. */ +typedef struct { + uint16_t element_addr; /*!< The element address */ + uint16_t model_id; /*!< The model id */ +} esp_ble_mesh_cfg_sig_model_app_get_t; + +/** Parameters of Config Vendor Model App Get. */ +typedef struct { + uint16_t element_addr; /*!< The element address */ + uint16_t model_id; /*!< The model id */ + uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */ +} esp_ble_mesh_cfg_vnd_model_app_get_t; + +/** Parameters of Config Key Refresh Phase Get. */ +typedef struct { + uint16_t net_idx; /*!< The network key index */ +} esp_ble_mesh_cfg_kr_phase_get_t; + +/** Parameters of Config Low Power Node PollTimeout Get. */ +typedef struct { + uint16_t lpn_addr; /*!< The unicast address of the Low Power node */ +} esp_ble_mesh_cfg_lpn_polltimeout_get_t; + +/** Parameters of Config Beacon Set. */ +typedef struct { + uint8_t beacon; /*!< New Secure Network Beacon state */ +} esp_ble_mesh_cfg_beacon_set_t; + +/** Parameters of Config Default TTL Set. */ +typedef struct { + uint8_t ttl; /*!< The default TTL state value */ +} esp_ble_mesh_cfg_default_ttl_set_t; + +/** Parameters of Config Friend Set. */ +typedef struct { + uint8_t friend_state; /*!< The friend state value */ +} esp_ble_mesh_cfg_friend_set_t; + +/** Parameters of Config GATT Proxy Set. */ +typedef struct { + uint8_t gatt_proxy; /*!< The GATT Proxy state value */ +} esp_ble_mesh_cfg_gatt_proxy_set_t; + +/** Parameters of Config Relay Set. */ +typedef struct { + uint8_t relay; /*!< The relay value */ + uint8_t relay_retransmit; /*!< The relay retransmit value */ +} esp_ble_mesh_cfg_relay_set_t; + +/** Parameters of Config NetKey Add. */ +typedef struct { + uint16_t net_idx; /*!< The network key index */ + uint8_t net_key[16]; /*!< The network key value */ +} esp_ble_mesh_cfg_net_key_add_t; + +/** Parameters of Config AppKey Add. */ +typedef struct { + uint16_t net_idx; /*!< The network key index */ + uint16_t app_idx; /*!< The app key index */ + uint8_t app_key[16]; /*!< The app key value */ +} esp_ble_mesh_cfg_app_key_add_t; + +/** Parameters of Config Model App Bind. */ +typedef struct { + uint16_t element_addr; /*!< The element address */ + uint16_t model_app_idx; /*!< Index of the app key to bind with the model */ + uint16_t model_id; /*!< The model id */ + uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */ +} esp_ble_mesh_cfg_model_app_bind_t; + +/** Parameters of Config Model Publication Set. */ +typedef struct { + uint16_t element_addr; /*!< The element address */ + uint16_t publish_addr; /*!< Value of the publish address */ + uint16_t publish_app_idx; /*!< Index of the application key */ + bool cred_flag; /*!< Value of the Friendship Credential Flag */ + uint8_t publish_ttl; /*!< Default TTL value for the publishing messages */ + uint8_t publish_period; /*!< Period for periodic status publishing */ + uint8_t publish_retransmit; /*!< Number of retransmissions and number of 50-millisecond steps between retransmissions */ + uint16_t model_id; /*!< The model id */ + uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */ +} esp_ble_mesh_cfg_model_pub_set_t; + +/** Parameters of Config Model Subscription Add. */ +typedef struct { + uint16_t element_addr; /*!< The element address */ + uint16_t sub_addr; /*!< The address to be added to the Subscription List */ + uint16_t model_id; /*!< The model id */ + uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */ +} esp_ble_mesh_cfg_model_sub_add_t; + +/** Parameters of Config Model Subscription Delete. */ +typedef struct { + uint16_t element_addr; /*!< The element address */ + uint16_t sub_addr; /*!< The address to be removed from the Subscription List */ + uint16_t model_id; /*!< The model id */ + uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */ +} esp_ble_mesh_cfg_model_sub_delete_t; + +/** Parameters of Config Model Subscription Overwrite. */ +typedef struct { + uint16_t element_addr; /*!< The element address */ + uint16_t sub_addr; /*!< The address to be added to the Subscription List */ + uint16_t model_id; /*!< The model id */ + uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */ +} esp_ble_mesh_cfg_model_sub_overwrite_t; + +/** Parameters of Config Model Subscription Virtual Address Add. */ +typedef struct { + uint16_t element_addr; /*!< The element address */ + uint8_t label_uuid[16]; /*!< The Label UUID of the virtual address to be added to the Subscription List */ + uint16_t model_id; /*!< The model id */ + uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */ +} esp_ble_mesh_cfg_model_sub_va_add_t; + +/** Parameters of Config Model Subscription Virtual Address Delete. */ +typedef struct { + uint16_t element_addr; /*!< The element address */ + uint8_t label_uuid[16]; /*!< The Label UUID of the virtual address to be removed from the Subscription List */ + uint16_t model_id; /*!< The model id */ + uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */ +} esp_ble_mesh_cfg_model_sub_va_delete_t; + +/** Parameters of Config Model Subscription Virtual Address Overwrite. */ +typedef struct { + uint16_t element_addr; /*!< The element address */ + uint8_t label_uuid[16]; /*!< The Label UUID of the virtual address to be added to the Subscription List */ + uint16_t model_id; /*!< The model id */ + uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */ +} esp_ble_mesh_cfg_model_sub_va_overwrite_t; + +/** Parameters of Config Model Publication Virtual Address Set. */ +typedef struct { + uint16_t element_addr; /*!< The element address */ + uint8_t label_uuid[16]; /*!< Value of the Label UUID publish address */ + uint16_t publish_app_idx; /*!< Index of the application key */ + bool cred_flag; /*!< Value of the Friendship Credential Flag */ + uint8_t publish_ttl; /*!< Default TTL value for the publishing messages */ + uint8_t publish_period; /*!< Period for periodic status publishing */ + uint8_t publish_retransmit; /*!< Number of retransmissions and number of 50-millisecond steps between retransmissions */ + uint16_t model_id; /*!< The model id */ + uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */ +} esp_ble_mesh_cfg_model_pub_va_set_t; + +/** Parameters of Config Model Subscription Delete All. */ +typedef struct { + uint16_t element_addr; /*!< The element address */ + uint16_t model_id; /*!< The model id */ + uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */ +} esp_ble_mesh_cfg_model_sub_delete_all_t; + +/** Parameters of Config NetKey Update. */ +typedef struct { + uint16_t net_idx; /*!< The network key index */ + uint8_t net_key[16]; /*!< The network key value */ +} esp_ble_mesh_cfg_net_key_update_t; + +/** Parameters of Config NetKey Delete. */ +typedef struct { + uint16_t net_idx; /*!< The network key index */ +} esp_ble_mesh_cfg_net_key_delete_t; + +/** Parameters of Config AppKey Update. */ +typedef struct { + uint16_t net_idx; /*!< The network key index */ + uint16_t app_idx; /*!< The app key index */ + uint8_t app_key[16]; /*!< The app key value */ +} esp_ble_mesh_cfg_app_key_update_t; + +/** Parameters of Config AppKey Delete. */ +typedef struct { + uint16_t net_idx; /*!< The network key index */ + uint16_t app_idx; /*!< The app key index */ +} esp_ble_mesh_cfg_app_key_delete_t; + +/** Parameters of Config Node Identity Set. */ +typedef struct { + uint16_t net_idx; /*!< The network key index */ + uint8_t identity; /*!< New Node Identity state */ +} esp_ble_mesh_cfg_node_identity_set_t; + +/** Parameters of Config Model App Unbind. */ +typedef struct { + uint16_t element_addr; /*!< The element address */ + uint16_t model_app_idx; /*!< Index of the app key to bind with the model */ + uint16_t model_id; /*!< The model id */ + uint16_t company_id; /*!< The company id, if not a vendor model, shall set to 0xFFFF */ +} esp_ble_mesh_cfg_model_app_unbind_t; + +/** Parameters of Config Key Refresh Phase Set. */ +typedef struct { + uint16_t net_idx; /*!< The network key index */ + uint8_t transition; /*!< New Key Refresh Phase Transition */ +} esp_ble_mesh_cfg_kr_phase_set_t; + +/** Parameters of Config Network Transmit Set. */ +typedef struct { + uint8_t net_transmit; /*!< Network Transmit State */ +} esp_ble_mesh_cfg_net_transmit_set_t; + +/** Parameters of Config Model Heartbeat Publication Set. */ +typedef struct { + uint16_t dst; /*!< Destination address for Heartbeat messages */ + uint8_t count; /*!< Number of Heartbeat messages to be sent */ + uint8_t period; /*!< Period for sending Heartbeat messages */ + uint8_t ttl; /*!< TTL to be used when sending Heartbeat messages */ + uint16_t feature; /*!< Bit field indicating features that trigger Heartbeat messages when changed */ + uint16_t net_idx; /*!< NetKey Index */ +} esp_ble_mesh_cfg_heartbeat_pub_set_t; + +/** Parameters of Config Model Heartbeat Subscription Set. */ +typedef struct { + uint16_t src; /*!< Source address for Heartbeat messages */ + uint16_t dst; /*!< Destination address for Heartbeat messages */ + uint8_t period; /*!< Period for receiving Heartbeat messages */ +} esp_ble_mesh_cfg_heartbeat_sub_set_t; + +/** + * @brief For ESP_BLE_MESH_MODEL_OP_BEACON_GET + * ESP_BLE_MESH_MODEL_OP_COMPOSITION_DATA_GET + * ESP_BLE_MESH_MODEL_OP_DEFAULT_TTL_GET + * ESP_BLE_MESH_MODEL_OP_GATT_PROXY_GET + * ESP_BLE_MESH_MODEL_OP_RELAY_GET + * ESP_BLE_MESH_MODEL_OP_MODEL_PUB_GET + * ESP_BLE_MESH_MODEL_OP_FRIEND_GET + * ESP_BLE_MESH_MODEL_OP_HEARTBEAT_PUB_GET + * ESP_BLE_MESH_MODEL_OP_HEARTBEAT_SUB_GET + * the get_state parameter in the esp_ble_mesh_config_client_get_state function should not be set to NULL. + */ +typedef union { + esp_ble_mesh_cfg_model_pub_get_t model_pub_get; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_PUB_GET. */ + esp_ble_mesh_cfg_composition_data_get_t comp_data_get; /*!< For ESP_BLE_MESH_MODEL_OP_COMPOSITION_DATA_GET. */ + esp_ble_mesh_cfg_sig_model_sub_get_t sig_model_sub_get; /*!< For ESP_BLE_MESH_MODEL_OP_SIG_MODEL_SUB_GET */ + esp_ble_mesh_cfg_vnd_model_sub_get_t vnd_model_sub_get; /*!< For ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_SUB_GET */ + esp_ble_mesh_cfg_app_key_get_t app_key_get; /*!< For ESP_BLE_MESH_MODEL_OP_APP_KEY_GET. */ + esp_ble_mesh_cfg_node_identity_get_t node_identity_get; /*!< For ESP_BLE_MESH_MODEL_OP_NODE_IDENTITY_GET. */ + esp_ble_mesh_cfg_sig_model_app_get_t sig_model_app_get; /*!< For ESP_BLE_MESH_MODEL_OP_SIG_MODEL_APP_GET */ + esp_ble_mesh_cfg_vnd_model_app_get_t vnd_model_app_get; /*!< For ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_APP_GET */ + esp_ble_mesh_cfg_kr_phase_get_t kr_phase_get; /*!< For ESP_BLE_MESH_MODEL_OP_KEY_REFRESH_PHASE_GET */ + esp_ble_mesh_cfg_lpn_polltimeout_get_t lpn_pollto_get; /*!< For ESP_BLE_MESH_MODEL_OP_LPN_POLLTIMEOUT_GET */ +} esp_ble_mesh_cfg_client_get_state_t; + +/** + * @brief For ESP_BLE_MESH_MODEL_OP_BEACON_SET + * ESP_BLE_MESH_MODEL_OP_DEFAULT_TTL_SET + * ESP_BLE_MESH_MODEL_OP_GATT_PROXY_SET + * ESP_BLE_MESH_MODEL_OP_RELAY_SET + * ESP_BLE_MESH_MODEL_OP_MODEL_PUB_SET + * ESP_BLE_MESH_MODEL_OP_MODEL_SUB_ADD + * ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_ADD + * ESP_BLE_MESH_MODEL_OP_MODEL_SUB_DELETE + * ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_DELETE + * ESP_BLE_MESH_MODEL_OP_MODEL_SUB_OVERWRITE + * ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_OVERWRITE + * ESP_BLE_MESH_MODEL_OP_NET_KEY_ADD + * ESP_BLE_MESH_MODEL_OP_APP_KEY_ADD + * ESP_BLE_MESH_MODEL_OP_MODEL_APP_BIND + * ESP_BLE_MESH_MODEL_OP_NODE_RESET + * ESP_BLE_MESH_MODEL_OP_FRIEND_SET + * ESP_BLE_MESH_MODEL_OP_HEARTBEAT_PUB_SET + * ESP_BLE_MESH_MODEL_OP_HEARTBEAT_SUB_SET + * the set_state parameter in the esp_ble_mesh_config_client_set_state function should not be set to NULL. + */ +typedef union { + esp_ble_mesh_cfg_beacon_set_t beacon_set; /*!< For ESP_BLE_MESH_MODEL_OP_BEACON_SET */ + esp_ble_mesh_cfg_default_ttl_set_t default_ttl_set; /*!< For ESP_BLE_MESH_MODEL_OP_DEFAULT_TTL_SET */ + esp_ble_mesh_cfg_friend_set_t friend_set; /*!< For ESP_BLE_MESH_MODEL_OP_FRIEND_SET */ + esp_ble_mesh_cfg_gatt_proxy_set_t gatt_proxy_set; /*!< For ESP_BLE_MESH_MODEL_OP_GATT_PROXY_SET */ + esp_ble_mesh_cfg_relay_set_t relay_set; /*!< For ESP_BLE_MESH_MODEL_OP_RELAY_SET */ + esp_ble_mesh_cfg_net_key_add_t net_key_add; /*!< For ESP_BLE_MESH_MODEL_OP_NET_KEY_ADD */ + esp_ble_mesh_cfg_app_key_add_t app_key_add; /*!< For ESP_BLE_MESH_MODEL_OP_APP_KEY_ADD */ + esp_ble_mesh_cfg_model_app_bind_t model_app_bind; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_APP_BIND */ + esp_ble_mesh_cfg_model_pub_set_t model_pub_set; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_PUB_SET */ + esp_ble_mesh_cfg_model_sub_add_t model_sub_add; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_SUB_ADD */ + esp_ble_mesh_cfg_model_sub_delete_t model_sub_delete; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_SUB_DELETE */ + esp_ble_mesh_cfg_model_sub_overwrite_t model_sub_overwrite; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_SUB_OVERWRITE */ + esp_ble_mesh_cfg_model_sub_va_add_t model_sub_va_add; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_ADD */ + esp_ble_mesh_cfg_model_sub_va_delete_t model_sub_va_delete; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_DELETE */ + esp_ble_mesh_cfg_model_sub_va_overwrite_t model_sub_va_overwrite; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_OVERWRITE */ + esp_ble_mesh_cfg_heartbeat_pub_set_t heartbeat_pub_set; /*!< For ESP_BLE_MESH_MODEL_OP_HEARTBEAT_PUB_SET */ + esp_ble_mesh_cfg_heartbeat_sub_set_t heartbeat_sub_set; /*!< For ESP_BLE_MESH_MODEL_OP_HEARTBEAT_SUB_SET */ + esp_ble_mesh_cfg_model_pub_va_set_t model_pub_va_set; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_PUB_VIRTUAL_ADDR_SET */ + esp_ble_mesh_cfg_model_sub_delete_all_t model_sub_delete_all; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_SUB_DELETE_ALL */ + esp_ble_mesh_cfg_net_key_update_t net_key_update; /*!< For ESP_BLE_MESH_MODEL_OP_NET_KEY_UPDATE */ + esp_ble_mesh_cfg_net_key_delete_t net_key_delete; /*!< For ESP_BLE_MESH_MODEL_OP_NET_KEY_DELETE */ + esp_ble_mesh_cfg_app_key_update_t app_key_update; /*!< For ESP_BLE_MESH_MODEL_OP_APP_KEY_UPDATE */ + esp_ble_mesh_cfg_app_key_delete_t app_key_delete; /*!< For ESP_BLE_MESH_MODEL_OP_APP_KEY_DELETE */ + esp_ble_mesh_cfg_node_identity_set_t node_identity_set; /*!< For ESP_BLE_MESH_MODEL_OP_NODE_IDENTITY_SET */ + esp_ble_mesh_cfg_model_app_unbind_t model_app_unbind; /*!< For ESP_BLE_MESH_MODEL_OP_MODEL_APP_UNBIND */ + esp_ble_mesh_cfg_kr_phase_set_t kr_phase_set; /*!< For ESP_BLE_MESH_MODEL_OP_KEY_REFRESH_PHASE_SET */ + esp_ble_mesh_cfg_net_transmit_set_t net_transmit_set; /*!< For ESP_BLE_MESH_MODEL_OP_NETWORK_TRANSMIT_SET */ +} esp_ble_mesh_cfg_client_set_state_t; + +/** Parameter of Config Beacon Status */ +typedef struct { + uint8_t beacon; /*!< Secure Network Beacon state value */ +} esp_ble_mesh_cfg_beacon_status_cb_t; + +/** Parameters of Config Composition Data Status */ +typedef struct { + uint8_t page; /*!< Page number of the Composition Data */ + struct net_buf_simple *composition_data; /*!< Pointer to Composition Data for the identified page */ +} esp_ble_mesh_cfg_comp_data_status_cb_t; + +/** Parameter of Config Default TTL Status */ +typedef struct { + uint8_t default_ttl; /*!< Default TTL state value */ +} esp_ble_mesh_cfg_default_ttl_status_cb_t; + +/** Parameter of Config GATT Proxy Status */ +typedef struct { + uint8_t gatt_proxy; /*!< GATT Proxy state value */ +} esp_ble_mesh_cfg_gatt_proxy_status_cb_t; + +/** Parameters of Config Relay Status */ +typedef struct { + uint8_t relay; /*!< Relay state value */ + uint8_t retransmit; /*!< Relay retransmit value(number of retransmissions and number of 10-millisecond steps between retransmissions) */ +} esp_ble_mesh_cfg_relay_status_cb_t; + +/** Parameters of Config Model Publication Status */ +typedef struct { + uint8_t status; /*!< Status Code for the request message */ + uint16_t element_addr; /*!< Address of the element */ + uint16_t publish_addr; /*!< Value of the publish address */ + uint16_t app_idx; /*!< Index of the application key */ + bool cred_flag; /*!< Value of the Friendship Credential Flag */ + uint8_t ttl; /*!< Default TTL value for the outgoing messages */ + uint8_t period; /*!< Period for periodic status publishing */ + uint8_t transmit; /*!< Number of retransmissions and number of 50-millisecond steps between retransmissions */ + uint16_t company_id; /*!< Company ID */ + uint16_t model_id; /*!< Model ID */ +} esp_ble_mesh_cfg_model_pub_status_cb_t; + +/** Parameters of Config Model Subscription Status */ +typedef struct { + uint8_t status; /*!< Status Code for the request message */ + uint16_t element_addr; /*!< Address of the element */ + uint16_t sub_addr; /*!< Value of the address */ + uint16_t company_id; /*!< Company ID */ + uint16_t model_id; /*!< Model ID */ +} esp_ble_mesh_cfg_model_sub_status_cb_t; + +/** Parameters of Config NetKey Status */ +typedef struct { + uint8_t status; /*!< Status Code for the request message */ + uint16_t net_idx; /*!< Index of the NetKey */ +} esp_ble_mesh_cfg_net_key_status_cb_t; + +/** Parameters of Config AppKey Status */ +typedef struct { + uint8_t status; /*!< Status Code for the request message */ + uint16_t net_idx; /*!< Index of the NetKey */ + uint16_t app_idx; /*!< Index of the application key */ +} esp_ble_mesh_cfg_app_key_status_cb_t; + +/** Parameters of Config Model App Status */ +typedef struct { + uint8_t status; /*!< Status Code for the request message */ + uint16_t element_addr; /*!< Address of the element */ + uint16_t app_idx; /*!< Index of the application key */ + uint16_t company_id; /*!< Company ID */ + uint16_t model_id; /*!< Model ID */ +} esp_ble_mesh_cfg_mod_app_status_cb_t; + +/** Parameter of Config Friend Status */ +typedef struct { + uint8_t friend_state; /*!< Friend state value */ +} esp_ble_mesh_cfg_friend_status_cb_t; + +/** Parameters of Config Heartbeat Publication Status */ +typedef struct { + uint8_t status; /*!< Status Code for the request message */ + uint16_t dst; /*!< Destination address for Heartbeat messages */ + uint8_t count; /*!< Number of Heartbeat messages remaining to be sent */ + uint8_t period; /*!< Period for sending Heartbeat messages */ + uint8_t ttl; /*!< TTL to be used when sending Heartbeat messages */ + uint16_t features; /*!< Features that trigger Heartbeat messages when changed */ + uint16_t net_idx; /*!< Index of the NetKey */ +} esp_ble_mesh_cfg_hb_pub_status_cb_t; + +/** Parameters of Config Heartbeat Subscription Status */ +typedef struct { + uint8_t status; /*!< Status Code for the request message */ + uint16_t src; /*!< Source address for Heartbeat messages */ + uint16_t dst; /*!< Destination address for Heartbeat messages */ + uint8_t period; /*!< Remaining Period for processing Heartbeat messages */ + uint8_t count; /*!< Number of Heartbeat messages received */ + uint8_t min_hops; /*!< Minimum hops when receiving Heartbeat messages */ + uint8_t max_hops; /*!< Maximum hops when receiving Heartbeat messages */ +} esp_ble_mesh_cfg_hb_sub_status_cb_t; + +/** 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 */ +} esp_ble_mesh_cfg_net_trans_status_cb_t; + +/** Parameters of Config SIG/Vendor Subscription List */ +typedef struct { + uint8_t status; /*!< Status Code for the request message */ + uint16_t element_addr; /*!< Address of the element */ + uint16_t company_id; /*!< Company ID */ + uint16_t model_id; /*!< Model ID */ + struct net_buf_simple *sub_addr; /*!< A block of all addresses from the Subscription List */ +} esp_ble_mesh_cfg_model_sub_list_cb_t; + +/** Parameter of Config NetKey List */ +typedef struct { + struct net_buf_simple *net_idx; /*!< A list of NetKey Indexes known to the node */ +} esp_ble_mesh_cfg_net_key_list_cb_t; + +/** Parameters of Config AppKey List */ +typedef struct { + uint8_t status; /*!< Status Code for the request message */ + uint16_t net_idx; /*!< NetKey Index of the NetKey that the AppKeys are bound to */ + struct net_buf_simple *app_idx; /*!< A list of AppKey indexes that are bound to the NetKey identified by NetKeyIndex */ +} esp_ble_mesh_cfg_app_key_list_cb_t; + +/** Parameters of Config Node Identity Status */ +typedef struct { + uint8_t status; /*!< Status Code for the request message */ + uint16_t net_idx; /*!< Index of the NetKey */ + uint8_t identity; /*!< Node Identity state */ +} esp_ble_mesh_cfg_node_id_status_cb_t; + +/** Parameters of Config SIG/Vendor Model App List */ +typedef struct { + uint8_t status; /*!< Status Code for the request message */ + uint16_t element_addr; /*!< Address of the element */ + uint16_t company_id; /*!< Company ID */ + uint16_t model_id; /*!< Model ID */ + struct net_buf_simple *app_idx; /*!< All AppKey indexes bound to the Model */ +} esp_ble_mesh_cfg_model_app_list_cb_t; + +/** Parameters of Config Key Refresh Phase Status */ +typedef struct { + uint8_t status; /*!< Status Code for the request message */ + uint16_t net_idx; /*!< Index of the NetKey */ + uint8_t phase; /*!< Key Refresh Phase state */ +} esp_ble_mesh_cfg_kr_phase_status_cb_t; + +/** Parameters of Config Low Power Node PollTimeout Status */ +typedef struct { + uint16_t lpn_addr; /*!< The unicast address of the Low Power node */ + int32_t poll_timeout; /*!< The current value of the PollTimeout timer of the Low Power node */ +} esp_ble_mesh_cfg_lpn_pollto_status_cb_t; + +/** + * @brief Configuration Client Model received message union + */ +typedef union { + esp_ble_mesh_cfg_beacon_status_cb_t beacon_status; /*!< The beacon status value */ + esp_ble_mesh_cfg_comp_data_status_cb_t comp_data_status; /*!< The composition data status value */ + esp_ble_mesh_cfg_default_ttl_status_cb_t default_ttl_status; /*!< The default_ttl status value */ + esp_ble_mesh_cfg_gatt_proxy_status_cb_t gatt_proxy_status; /*!< The gatt_proxy status value */ + esp_ble_mesh_cfg_relay_status_cb_t relay_status; /*!< The relay status value */ + esp_ble_mesh_cfg_model_pub_status_cb_t model_pub_status; /*!< The model publication status value */ + esp_ble_mesh_cfg_model_sub_status_cb_t model_sub_status; /*!< The model subscription status value */ + esp_ble_mesh_cfg_net_key_status_cb_t netkey_status; /*!< The netkey status value */ + esp_ble_mesh_cfg_app_key_status_cb_t appkey_status; /*!< The appkey status value */ + esp_ble_mesh_cfg_mod_app_status_cb_t model_app_status; /*!< The model app status value */ + esp_ble_mesh_cfg_friend_status_cb_t friend_status; /*!< The friend status value */ + esp_ble_mesh_cfg_hb_pub_status_cb_t heartbeat_pub_status; /*!< The heartbeat publication status value */ + esp_ble_mesh_cfg_hb_sub_status_cb_t heartbeat_sub_status; /*!< The heartbeat subscription status value */ + esp_ble_mesh_cfg_net_trans_status_cb_t net_transmit_status; /*!< The network transmit status value */ + esp_ble_mesh_cfg_model_sub_list_cb_t model_sub_list; /*!< The model subscription list value */ + esp_ble_mesh_cfg_net_key_list_cb_t netkey_list; /*!< The network key index list value */ + esp_ble_mesh_cfg_app_key_list_cb_t appkey_list; /*!< The application key index list value */ + esp_ble_mesh_cfg_node_id_status_cb_t node_identity_status; /*!< The node identity status value */ + esp_ble_mesh_cfg_model_app_list_cb_t model_app_list; /*!< The model application key index list value */ + esp_ble_mesh_cfg_kr_phase_status_cb_t kr_phase_status; /*!< The key refresh phase status value */ + esp_ble_mesh_cfg_lpn_pollto_status_cb_t lpn_timeout_status; /*!< The low power node poll timeout status value */ +} esp_ble_mesh_cfg_client_common_cb_param_t; + +/** Configuration Client Model callback parameters */ +typedef struct { + int error_code; /*!< Appropriate error code */ + esp_ble_mesh_client_common_param_t *params; /*!< The client common parameters */ + esp_ble_mesh_cfg_client_common_cb_param_t status_cb; /*!< The config status message callback values */ +} esp_ble_mesh_cfg_client_cb_param_t; + +/** This enum value is the event of Configuration Client Model */ +typedef enum { + ESP_BLE_MESH_CFG_CLIENT_GET_STATE_EVT, + ESP_BLE_MESH_CFG_CLIENT_SET_STATE_EVT, + ESP_BLE_MESH_CFG_CLIENT_PUBLISH_EVT, + ESP_BLE_MESH_CFG_CLIENT_TIMEOUT_EVT, + ESP_BLE_MESH_CFG_CLIENT_EVT_MAX, +} esp_ble_mesh_cfg_client_cb_event_t; + +/** + * @brief Configuration Server model related context. + */ + +typedef struct { + 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 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_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; + +/** + * @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; /*!< 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 */ +typedef enum { + ESP_BLE_MESH_CFG_SERVER_STATE_CHANGE_EVT, + ESP_BLE_MESH_CFG_SERVER_EVT_MAX, +} esp_ble_mesh_cfg_server_cb_event_t; + +/** + * @brief Bluetooth Mesh Config Client and Server Model functions. + */ + +/** + * @brief Configuration Client Model callback function type + * @param event: Event type + * @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); + +/** + * @brief Configuration Server Model callback function type + * @param event: Event type + * @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); + +/** + * @brief Register BLE Mesh Config Client 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_config_client_callback(esp_ble_mesh_cfg_client_cb_t callback); + +/** + * @brief Register BLE Mesh Config 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_config_server_callback(esp_ble_mesh_cfg_server_cb_t callback); + +/** + * @brief Get the value of Config Server Model states using the Config Client Model get messages. + * + * @note If you want to find the opcodes and corresponding meanings accepted by this API, + * please refer to esp_ble_mesh_opcode_config_client_get_t in esp_ble_mesh_defs.h + * + * @param[in] params: Pointer to BLE Mesh common client parameters. + * @param[in] get_state: Pointer to a union, each kind of opcode corresponds to one structure inside. + * Shall not be set to NULL. + * + * @return ESP_OK on success or error code otherwise. + * + */ +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); + +/** + * @brief Set the value of the Configuration Server Model states using the Config Client Model set messages. + * + * @note If you want to find the opcodes and corresponding meanings accepted by this API, + * please refer to esp_ble_mesh_opcode_config_client_set_t in esp_ble_mesh_defs.h + * + * @param[in] params: Pointer to BLE Mesh common client parameters. + * @param[in] set_state: Pointer to a union, each kind of opcode corresponds to one structure inside. + * Shall not be set to NULL. + * + * @return ESP_OK on success or error code otherwise. + * + */ +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); + +#ifdef __cplusplus +} +#endif + +#endif /* _ESP_BLE_MESH_CONFIG_MODEL_API_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_generic_model_api.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_generic_model_api.h new file mode 100644 index 00000000000..fc4808af411 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_generic_model_api.h @@ -0,0 +1,1296 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** @file + * @brief Bluetooth Mesh Generic Client Model APIs. + */ + +#ifndef _ESP_BLE_MESH_GENERIC_MODEL_API_H_ +#define _ESP_BLE_MESH_GENERIC_MODEL_API_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. + * + * @note This API needs to be called for each element on which + * the application needs to have a Generic OnOff Client Model. + * + * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t. + * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t. + * + * @return New Generic OnOff Client Model instance. + */ +#define ESP_BLE_MESH_MODEL_GEN_ONOFF_CLI(cli_pub, cli_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_CLI, \ + NULL, cli_pub, cli_data) + +/** @def ESP_BLE_MESH_MODEL_GEN_LEVEL_CLI + * + * @brief Define a new Generic Level Client Model. + * + * @note This API needs to be called for each element on which + * the application needs to have a Generic Level Client Model. + * + * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t. + * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t. + * + * @return New Generic Level Client Model instance. + */ + +#define ESP_BLE_MESH_MODEL_GEN_LEVEL_CLI(cli_pub, cli_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_LEVEL_CLI, \ + NULL, cli_pub, cli_data) + +/** @def ESP_BLE_MESH_MODEL_GEN_DEF_TRANS_TIME_CLI + * + * @brief Define a new Generic Default Transition Time Client Model. + * + * @note This API needs to be called for each element on which + * the application needs to have a Generic Default Transition + * Time Client Model. + * + * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t. + * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t. + * + * @return New Generic Default Transition Time Client Model instance. + */ +#define ESP_BLE_MESH_MODEL_GEN_DEF_TRANS_TIME_CLI(cli_pub, cli_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_CLI, \ + NULL, cli_pub, cli_data) + +/** @def ESP_BLE_MESH_MODEL_GEN_POWER_ONOFF_CLI + * + * @brief Define a new Generic Power OnOff Client Model. + * + * @note This API needs to be called for each element on which + * the application needs to have a Generic Power OnOff Client Model. + * + * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t. + * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t. + * + * @return New Generic Power OnOff Client Model instance. + */ +#define ESP_BLE_MESH_MODEL_GEN_POWER_ONOFF_CLI(cli_pub, cli_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_CLI, \ + NULL, cli_pub, cli_data) + +/** @def ESP_BLE_MESH_MODEL_GEN_POWER_LEVEL_CLI + * + * @brief Define a new Generic Power Level Client Model. + * + * @note This API needs to be called for each element on which + * the application needs to have a Generic Power Level Client Model. + * + * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t. + * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t. + * + * @return New Generic Power Level Client Model instance. + */ +#define ESP_BLE_MESH_MODEL_GEN_POWER_LEVEL_CLI(cli_pub, cli_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_CLI, \ + NULL, cli_pub, cli_data) + +/** @def ESP_BLE_MESH_MODEL_GEN_BATTERY_CLI + * + * @brief Define a new Generic Battery Client Model. + * + * @note This API needs to be called for each element on which + * the application needs to have a Generic Battery Client Model. + * + * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t. + * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t. + * + * @return New Generic Battery Client Model instance. + */ +#define ESP_BLE_MESH_MODEL_GEN_BATTERY_CLI(cli_pub, cli_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_BATTERY_CLI, \ + NULL, cli_pub, cli_data) + +/** @def ESP_BLE_MESH_MODEL_GEN_LOCATION_CLI + * + * @brief Define a new Generic Location Client Model. + * + * @note This API needs to be called for each element on which + * the application needs to have a Generic Location Client Model. + * + * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t. + * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t. + * + * @return New Generic Location Client Model instance. + */ +#define ESP_BLE_MESH_MODEL_GEN_LOCATION_CLI(cli_pub, cli_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_LOCATION_CLI, \ + NULL, cli_pub, cli_data) + +/** @def ESP_BLE_MESH_MODEL_GEN_PROPERTY_CLI + * + * @brief Define a new Generic Property Client Model. + * + * @note This API needs to be called for each element on which + * the application needs to have a Generic Property Client Model. + * + * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t. + * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t. + * + * @return New Generic Location Client Model instance. + */ +#define ESP_BLE_MESH_MODEL_GEN_PROPERTY_CLI(cli_pub, cli_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_PROP_CLI, \ + NULL, cli_pub, cli_data) + +/** + * @brief Bluetooth Mesh Generic Client Model Get and Set parameters structure. + */ + +/** Parameters of Generic OnOff Set. */ +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_gen_onoff_set_t; + +/** Parameters of Generic Level Set. */ +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_gen_level_set_t; + +/** Parameters of Generic Delta Set. */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + int32_t 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_gen_delta_set_t; + +/** Parameters of Generic Move Set. */ +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_gen_move_set_t; + +/** Parameter of Generic Default Transition Time Set. */ +typedef struct { + uint8_t trans_time; /*!< The value of the Generic Default Transition Time state */ +} esp_ble_mesh_gen_def_trans_time_set_t; + +/** Parameter of Generic OnPowerUp Set. */ +typedef struct { + uint8_t onpowerup; /*!< The value of the Generic OnPowerUp state */ +} esp_ble_mesh_gen_onpowerup_set_t; + +/** Parameters of Generic Power Level Set. */ +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_gen_power_level_set_t; + +/** Parameter of Generic Power Default Set. */ +typedef struct { + uint16_t power; /*!< The value of the Generic Power Default state */ +} esp_ble_mesh_gen_power_default_set_t; + +/** Parameters of Generic Power Range Set. */ +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_gen_power_range_set_t; + +/** Parameters of Generic Location Global Set. */ +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_gen_loc_global_set_t; + +/** Parameters of Generic Location Local Set. */ +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_gen_loc_local_set_t; + +/** Parameter of Generic User Property Get. */ +typedef struct { + uint16_t property_id; /*!< Property ID identifying a Generic User Property */ +} esp_ble_mesh_gen_user_property_get_t; + +/** Parameters of Generic User Property Set. */ +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_gen_user_property_set_t; + +/** Parameter of Generic Admin Property Get. */ +typedef struct { + uint16_t property_id; /*!< Property ID identifying a Generic Admin Property */ +} esp_ble_mesh_gen_admin_property_get_t; + +/** 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 access */ + struct net_buf_simple *property_value; /*!< Raw value for the Admin Property */ +} esp_ble_mesh_gen_admin_property_set_t; + +/** Parameter of Generic Manufacturer Property Get. */ +typedef struct { + uint16_t property_id; /*!< Property ID identifying a Generic Manufacturer Property */ +} esp_ble_mesh_gen_manufacturer_property_get_t; + +/** Parameters of Generic Manufacturer Property Set. */ +typedef struct { + uint16_t property_id; /*!< Property ID identifying a Generic Manufacturer Property */ + uint8_t user_access; /*!< Enumeration indicating user access */ +} esp_ble_mesh_gen_manufacturer_property_set_t; + +/** Parameter of Generic Client Properties Get. */ +typedef struct { + uint16_t property_id; /*!< A starting Client Property ID present within an element */ +} esp_ble_mesh_gen_client_properties_get_t; + +/** + * @brief Generic Client Model get message union + */ +typedef union { + esp_ble_mesh_gen_user_property_get_t user_property_get; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_GET */ + esp_ble_mesh_gen_admin_property_get_t admin_property_get; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_GET*/ + esp_ble_mesh_gen_manufacturer_property_get_t manufacturer_property_get; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTY_SET */ + esp_ble_mesh_gen_client_properties_get_t client_properties_get; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_CLIENT_PROPERTIES_GET */ +} esp_ble_mesh_generic_client_get_state_t; + +/** + * @brief Generic Client Model set message union + */ +typedef union { + esp_ble_mesh_gen_onoff_set_t onoff_set; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_SET & ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_SET_UNACK */ + esp_ble_mesh_gen_level_set_t level_set; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_LEVEL_SET & ESP_BLE_MESH_MODEL_OP_GEN_LEVEL_SET_UNACK */ + esp_ble_mesh_gen_delta_set_t delta_set; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_DELTA_SET & ESP_BLE_MESH_MODEL_OP_GEN_DELTA_SET_UNACK */ + esp_ble_mesh_gen_move_set_t move_set; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_MOVE_SET & ESP_BLE_MESH_MODEL_OP_GEN_MOVE_SET_UNACK */ + esp_ble_mesh_gen_def_trans_time_set_t def_trans_time_set; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_SET & ESP_BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_SET_UNACK */ + esp_ble_mesh_gen_onpowerup_set_t power_set; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_ONPOWERUP_SET & ESP_BLE_MESH_MODEL_OP_GEN_ONPOWERUP_SET_UNACK */ + esp_ble_mesh_gen_power_level_set_t power_level_set; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_SET & ESP_BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_SET_UNACK */ + esp_ble_mesh_gen_power_default_set_t power_default_set; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_SET & ESP_BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_SET_UNACK */ + esp_ble_mesh_gen_power_range_set_t power_range_set; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_POWER_RANGE_SET & ESP_BLE_MESH_MODEL_OP_GEN_POWER_RANGE_SET_UNACK */ + esp_ble_mesh_gen_loc_global_set_t loc_global_set; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_SET & ESP_BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_SET_UNACK */ + esp_ble_mesh_gen_loc_local_set_t loc_local_set; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_SET & ESP_BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_SET_UNACK */ + esp_ble_mesh_gen_user_property_set_t user_property_set; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET & ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET_UNACK */ + esp_ble_mesh_gen_admin_property_set_t admin_property_set; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET & ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET_UNACK */ + esp_ble_mesh_gen_manufacturer_property_set_t manufacturer_property_set; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTY_SET & ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTY_SET_UNACK */ +} esp_ble_mesh_generic_client_set_state_t; + +/** + * @brief Bluetooth Mesh Generic Client Model Get and Set callback parameters structure. + */ + +/** Parameters of Generic OnOff Status. */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint8_t present_onoff; /*!< Current value of Generic OnOff state */ + uint8_t target_onoff; /*!< Target value of Generic OnOff state (optional) */ + uint8_t remain_time; /*!< Time to complete state transition (C.1) */ +} esp_ble_mesh_gen_onoff_status_cb_t; + +/** Parameters of Generic Level Status. */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + int16_t present_level; /*!< Current value of Generic Level state */ + int16_t target_level; /*!< Target value of the Generic Level state (optional) */ + uint8_t remain_time; /*!< Time to complete state transition (C.1) */ +} esp_ble_mesh_gen_level_status_cb_t; + +/** Parameter of Generic Default Transition Time Status. */ +typedef struct { + uint8_t trans_time; /*!< The value of the Generic Default Transition Time state */ +} esp_ble_mesh_gen_def_trans_time_status_cb_t; + +/** Parameter of Generic OnPowerUp Status. */ +typedef struct { + uint8_t onpowerup; /*!< The value of the Generic OnPowerUp state */ +} esp_ble_mesh_gen_onpowerup_status_cb_t; + +/** Parameters of Generic Power Level Status. */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t present_power; /*!< Current value of Generic Power Actual state */ + uint16_t target_power; /*!< Target value of Generic Power Actual state (optional) */ + uint8_t remain_time; /*!< Time to complete state transition (C.1) */ +} esp_ble_mesh_gen_power_level_status_cb_t; + +/** Parameter of Generic Power Last Status. */ +typedef struct { + uint16_t power; /*!< The value of the Generic Power Last state */ +} esp_ble_mesh_gen_power_last_status_cb_t; + +/** Parameter of Generic Power Default Status. */ +typedef struct { + uint16_t power; /*!< The value of the Generic Default Last state */ +} esp_ble_mesh_gen_power_default_status_cb_t; + +/** Parameters of Generic Power Range Status. */ +typedef struct { + uint8_t status_code; /*!< Status Code for the request message */ + 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_gen_power_range_status_cb_t; + +/** Parameters of Generic Battery Status. */ +typedef struct { + uint32_t battery_level : 8; /*!< Value of Generic Battery Level state */ + uint32_t time_to_discharge : 24; /*!< Value of Generic Battery Time to Discharge state */ + uint32_t time_to_charge : 24; /*!< Value of Generic Battery Time to Charge state */ + uint32_t flags : 8; /*!< Value of Generic Battery Flags state */ +} esp_ble_mesh_gen_battery_status_cb_t; + +/** Parameters of Generic Location Global Status. */ +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_gen_loc_global_status_cb_t; + +/** Parameters of Generic Location Local Status. */ +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_gen_loc_local_status_cb_t; + +/** Parameter of Generic User Properties Status. */ +typedef struct { + struct net_buf_simple *property_ids; /*!< Buffer contains a sequence of N User Property IDs */ +} esp_ble_mesh_gen_user_properties_status_cb_t; + +/** Parameters of Generic User Property Status. */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t property_id; /*!< Property ID identifying a Generic User Property */ + uint8_t user_access; /*!< Enumeration indicating user access (optional) */ + struct net_buf_simple *property_value; /*!< Raw value for the User Property (C.1) */ +} esp_ble_mesh_gen_user_property_status_cb_t; + +/** Parameter of Generic Admin Properties Status. */ +typedef struct { + struct net_buf_simple *property_ids; /*!< Buffer contains a sequence of N Admin Property IDs */ +} esp_ble_mesh_gen_admin_properties_status_cb_t; + +/** Parameters of Generic Admin Property Status. */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t property_id; /*!< Property ID identifying a Generic Admin Property */ + uint8_t user_access; /*!< Enumeration indicating user access (optional) */ + struct net_buf_simple *property_value; /*!< Raw value for the Admin Property (C.1) */ +} esp_ble_mesh_gen_admin_property_status_cb_t; + +/** Parameter of Generic Manufacturer Properties Status. */ +typedef struct { + struct net_buf_simple *property_ids; /*!< Buffer contains a sequence of N Manufacturer Property IDs */ +} esp_ble_mesh_gen_manufacturer_properties_status_cb_t; + +/** Parameters of Generic Manufacturer Property Status. */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t property_id; /*!< Property ID identifying a Generic Manufacturer Property */ + uint8_t user_access; /*!< Enumeration indicating user access (optional) */ + struct net_buf_simple *property_value; /*!< Raw value for the Manufacturer Property (C.1) */ +} esp_ble_mesh_gen_manufacturer_property_status_cb_t; + +/** Parameter of Generic Client Properties Status. */ +typedef struct { + struct net_buf_simple *property_ids; /*!< Buffer contains a sequence of N Client Property IDs */ +} esp_ble_mesh_gen_client_properties_status_cb_t; + +/** + * @brief Generic Client Model received message union + */ +typedef union { + esp_ble_mesh_gen_onoff_status_cb_t onoff_status; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_STATUS */ + esp_ble_mesh_gen_level_status_cb_t level_status; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_LEVEL_STATUS */ + esp_ble_mesh_gen_def_trans_time_status_cb_t def_trans_time_status; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_STATUS */ + esp_ble_mesh_gen_onpowerup_status_cb_t onpowerup_status; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_ONPOWERUP_STATUS */ + esp_ble_mesh_gen_power_level_status_cb_t power_level_status; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_STATUS */ + esp_ble_mesh_gen_power_last_status_cb_t power_last_status; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_POWER_LAST_STATUS */ + esp_ble_mesh_gen_power_default_status_cb_t power_default_status; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_STATUS */ + esp_ble_mesh_gen_power_range_status_cb_t power_range_status; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_POWER_RANGE_STATUS */ + esp_ble_mesh_gen_battery_status_cb_t battery_status; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_BATTERY_STATUS */ + esp_ble_mesh_gen_loc_global_status_cb_t location_global_status; /*!< For ESP_BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_STATUS */ + esp_ble_mesh_gen_loc_local_status_cb_t location_local_status; /*!< ESP_BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_STATUS */ + esp_ble_mesh_gen_user_properties_status_cb_t user_properties_status; /*!< ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_STATUS */ + esp_ble_mesh_gen_user_property_status_cb_t user_property_status; /*!< ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_STATUS */ + esp_ble_mesh_gen_admin_properties_status_cb_t admin_properties_status; /*!< ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTIES_STATUS */ + esp_ble_mesh_gen_admin_property_status_cb_t admin_property_status; /*!< ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_STATUS */ + esp_ble_mesh_gen_manufacturer_properties_status_cb_t manufacturer_properties_status; /*!< ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTIES_STATUS */ + esp_ble_mesh_gen_manufacturer_property_status_cb_t manufacturer_property_status; /*!< ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTY_STATUS */ + esp_ble_mesh_gen_client_properties_status_cb_t client_properties_status; /*!< ESP_BLE_MESH_MODEL_OP_GEN_CLIENT_PROPERTIES_STATUS */ +} esp_ble_mesh_gen_client_status_cb_t; + +/** Generic Client Model callback parameters */ +typedef struct { + int error_code; /*!< Appropriate error code */ + esp_ble_mesh_client_common_param_t *params; /*!< The client common parameters. */ + esp_ble_mesh_gen_client_status_cb_t status_cb; /*!< The generic status message callback values */ +} esp_ble_mesh_generic_client_cb_param_t; + +/** This enum value is the event of Generic Client Model */ +typedef enum { + ESP_BLE_MESH_GENERIC_CLIENT_GET_STATE_EVT, + ESP_BLE_MESH_GENERIC_CLIENT_SET_STATE_EVT, + ESP_BLE_MESH_GENERIC_CLIENT_PUBLISH_EVT, + ESP_BLE_MESH_GENERIC_CLIENT_TIMEOUT_EVT, + ESP_BLE_MESH_GENERIC_CLIENT_EVT_MAX, +} esp_ble_mesh_generic_client_cb_event_t; + +/** + * @brief Bluetooth Mesh Generic Client Model function. + */ + +/** + * @brief Generic Client Model callback function type + * @param event: Event type + * @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); + +/** + * @brief Register BLE Mesh Generic Client 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_client_callback(esp_ble_mesh_generic_client_cb_t callback); + +/** + * @brief Get the value of Generic Server Model states using the Generic Client Model get messages. + * + * @note If you want to find the opcodes and corresponding meanings accepted by this API, + * please refer to esp_ble_mesh_generic_message_opcode_t in esp_ble_mesh_defs.h + * + * @param[in] params: Pointer to BLE Mesh common client parameters. + * @param[in] get_state: Pointer to generic get message value. + * Shall not be set to NULL. + * + * @return ESP_OK on success or error code otherwise. + * + */ +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); + +/** + * @brief Set the value of Generic Server Model states using the Generic Client Model set messages. + * + * @note If you want to find the opcodes and corresponding meanings accepted by this API, + * please refer to esp_ble_mesh_generic_message_opcode_t in esp_ble_mesh_defs.h + * + * @param[in] params: Pointer to BLE Mesh common client parameters. + * @param[in] set_state: Pointer to generic set message value. + * Shall not be set to NULL. + * + * @return ESP_OK on success or error code otherwise. + * + */ +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); + +/** + * @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_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_health_model_api.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_health_model_api.h new file mode 100644 index 00000000000..3a636ce1c38 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_health_model_api.h @@ -0,0 +1,406 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _ESP_BLE_MESH_HEALTH_MODEL_API_H_ +#define _ESP_BLE_MESH_HEALTH_MODEL_API_H_ + +#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. + * + * @note The Health Server Model can only be included by a Primary Element. + * + * @param srv Pointer to the unique struct esp_ble_mesh_health_srv_t. + * @param pub Pointer to the unique struct esp_ble_mesh_model_pub_t. + * + * @return New Health Server Model instance. + */ +#define ESP_BLE_MESH_MODEL_HEALTH_SRV(srv, pub) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_HEALTH_SRV, \ + NULL, pub, srv) + +/** @def ESP_BLE_MESH_MODEL_HEALTH_CLI + * + * @brief Define a new Health Client Model. + * + * @note This API needs to be called for each element on which + * the application needs to have a Health Client Model. + * + * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t. + * + * @return New Health Client Model instance. + */ +#define ESP_BLE_MESH_MODEL_HEALTH_CLI(cli_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_HEALTH_CLI, \ + NULL, NULL, cli_data) + +/** @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 { + /** Clear health registered faults. Initialized by the stack. */ + esp_ble_mesh_cb_t fault_clear; + + /** Run a specific health test. Initialized by the stack. */ + esp_ble_mesh_cb_t fault_test; + + /** Health attention on callback. Initialized by the stack. */ + esp_ble_mesh_cb_t attention_on; + + /** Health attention off callback. Initialized by the stack. */ + esp_ble_mesh_cb_t attention_off; +} esp_ble_mesh_health_srv_cb_t; + +#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; + + /** Health callback struct */ + esp_ble_mesh_health_srv_cb_t health_cb; + + /** Attention Timer state */ + 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 */ +typedef struct { + uint16_t company_id; /*!< Bluetooth assigned 16-bit Company ID */ +} esp_ble_mesh_health_fault_get_t; + +/** Parameter of Health Attention Set */ +typedef struct { + uint8_t attention; /*!< Value of the Attention Timer state */ +} esp_ble_mesh_health_attention_set_t; + +/** Parameter of Health Period Set */ +typedef struct { + uint8_t fast_period_divisor; /*!< Divider for the Publish Period */ +} esp_ble_mesh_health_period_set_t; + +/** Parameter of Health Fault Test */ +typedef struct { + uint16_t company_id; /*!< Bluetooth assigned 16-bit Company ID */ + uint8_t test_id; /*!< ID of a specific test to be performed */ +} esp_ble_mesh_health_fault_test_t; + +/** Parameter of Health Fault Clear */ +typedef struct { + uint16_t company_id; /*!< Bluetooth assigned 16-bit Company ID */ +} esp_ble_mesh_health_fault_clear_t; + +/** + * @brief For ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET + * ESP_BLE_MESH_MODEL_OP_ATTENTION_GET + * ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_GET + * the get_state parameter in the esp_ble_mesh_health_client_get_state function should not be set to NULL. + */ +typedef union { + esp_ble_mesh_health_fault_get_t fault_get; /*!< For ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET. */ +} esp_ble_mesh_health_client_get_state_t; + +/** + * @brief For ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR + * ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR_UNACK + * ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST + * ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST_UNACK + * ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET + * ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET_UNACK + * ESP_BLE_MESH_MODEL_OP_ATTENTION_SET + * ESP_BLE_MESH_MODEL_OP_ATTENTION_SET_UNACK + * the set_state parameter in the esp_ble_mesh_health_client_set_state function should not be set to NULL. + */ +typedef union { + esp_ble_mesh_health_attention_set_t attention_set; /*!< For ESP_BLE_MESH_MODEL_OP_ATTENTION_SET or ESP_BLE_MESH_MODEL_OP_ATTENTION_SET_UNACK. */ + esp_ble_mesh_health_period_set_t period_set; /*!< For ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET or ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET_UNACK. */ + esp_ble_mesh_health_fault_test_t fault_test; /*!< For ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST or ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST_UNACK. */ + esp_ble_mesh_health_fault_clear_t fault_clear; /*!< For ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR or ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR_UNACK. */ +} esp_ble_mesh_health_client_set_state_t; + +/** Parameters of Health Current Status */ +typedef struct { + uint8_t test_id; /*!< ID of a most recently performed test */ + uint16_t company_id; /*!< Bluetooth assigned 16-bit Company ID */ + struct net_buf_simple *fault_array; /*!< FaultArray field contains a sequence of 1-octet fault values */ +} esp_ble_mesh_health_current_status_cb_t; + +/** Parameters of Health Fault Status */ +typedef struct { + uint8_t test_id; /*!< ID of a most recently performed test */ + uint16_t company_id; /*!< Bluetooth assigned 16-bit Company ID */ + struct net_buf_simple *fault_array; /*!< FaultArray field contains a sequence of 1-octet fault values */ +} esp_ble_mesh_health_fault_status_cb_t; + +/** Parameter of Health Period Status */ +typedef struct { + uint8_t fast_period_divisor; /*!< Divider for the Publish Period */ +} esp_ble_mesh_health_period_status_cb_t; + +/** Parameter of Health Attention Status */ +typedef struct { + uint8_t attention; /*!< Value of the Attention Timer state */ +} esp_ble_mesh_health_attention_status_cb_t; + +/** + * @brief Health Client Model received message union + */ +typedef union { + esp_ble_mesh_health_current_status_cb_t current_status; /*!< The health current status value */ + esp_ble_mesh_health_fault_status_cb_t fault_status; /*!< The health fault status value */ + esp_ble_mesh_health_period_status_cb_t period_status; /*!< The health period status value */ + esp_ble_mesh_health_attention_status_cb_t attention_status; /*!< The health attention status value */ +} esp_ble_mesh_health_client_common_cb_param_t; + +/** Health Client Model callback parameters */ +typedef struct { + int error_code; /*!< Appropriate error code */ + esp_ble_mesh_client_common_param_t *params; /*!< The client common parameters. */ + esp_ble_mesh_health_client_common_cb_param_t status_cb; /*!< The health message status callback values */ +} esp_ble_mesh_health_client_cb_param_t; + +/** This enum value is the event of Health Client Model */ +typedef enum { + ESP_BLE_MESH_HEALTH_CLIENT_GET_STATE_EVT, + ESP_BLE_MESH_HEALTH_CLIENT_SET_STATE_EVT, + ESP_BLE_MESH_HEALTH_CLIENT_PUBLISH_EVT, + ESP_BLE_MESH_HEALTH_CLIENT_TIMEOUT_EVT, + ESP_BLE_MESH_HEALTH_CLIENT_EVT_MAX, +} esp_ble_mesh_health_client_cb_event_t; + +/** Parameter of publishing Health Current Status completion event */ +typedef struct { + 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_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; + +/** + * @brief Bluetooth Mesh Health Client and Server Model function. + */ + +/** + * @brief Health Client Model callback function type + * @param event: Event type + * @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); + +/** + * @brief Health Server Model callback function type + * @param event: Event type + * @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); + +/** + * @brief Register BLE Mesh Health Model callback, the callback will report Health Client & Server Model events. + * + * @param[in] callback: Pointer to the callback function. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_register_health_client_callback(esp_ble_mesh_health_client_cb_t callback); + +/** + * @brief Register BLE Mesh Health 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_health_server_callback(esp_ble_mesh_health_server_cb_t callback); + +/** + * @brief This function is called to get the Health Server states using the Health Client Model get messages. + * + * @note If you want to find the opcodes and corresponding meanings accepted by this API, + * please refer to esp_ble_mesh_opcode_health_client_get_t in esp_ble_mesh_defs.h + * + * @param[in] params: Pointer to BLE Mesh common client parameters. + * @param[in] get_state: Pointer to a union, each kind of opcode corresponds to one structure inside. + * Shall not be set to NULL. + * + * @return ESP_OK on success or error code otherwise. + * + */ +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); + +/** + * @brief This function is called to set the Health Server states using the Health Client Model set messages. + * + * @note If you want to find the opcodes and corresponding meanings accepted by this API, + * please refer to esp_ble_mesh_opcode_health_client_set_t in esp_ble_mesh_defs.h + * + * @param[in] params: Pointer to BLE Mesh common client parameters. + * @param[in] set_state: Pointer to a union, each kind of opcode corresponds to one structure inside. + * Shall not be set to NULL. + * + * @return ESP_OK on success or error code otherwise. + * + */ +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); + +/** + * @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. + * + * @return ESP_OK on success or error code otherwise. + * + */ +esp_err_t esp_ble_mesh_health_server_fault_update(esp_ble_mesh_elem_t *element); + +#ifdef __cplusplus +} +#endif + +#endif /* _ESP_BLE_MESH_HEALTH_MODEL_API_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_lighting_model_api.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_lighting_model_api.h new file mode 100644 index 00000000000..48f45f5e4f2 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_lighting_model_api.h @@ -0,0 +1,1674 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** @file + * @brief Bluetooth Mesh Light Client Model APIs. + */ + +#ifndef _ESP_BLE_MESH_LIGHTING_MODEL_API_H_ +#define _ESP_BLE_MESH_LIGHTING_MODEL_API_H_ + +#include "esp_ble_mesh_defs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** @def ESP_BLE_MESH_MODEL_LIGHT_LIGHTNESS_CLI + * + * @brief Define a new Light Lightness Client Model. + * + * @note This API needs to be called for each element on which + * the application needs to have a Light Lightness Client Model. + * + * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t. + * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t. + * + * @return New Light Lightness Client Model instance. + */ +#define ESP_BLE_MESH_MODEL_LIGHT_LIGHTNESS_CLI(cli_pub, cli_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_CLI, \ + NULL, cli_pub, cli_data) + +/** @def ESP_BLE_MESH_MODEL_LIGHT_CTL_CLI + * + * @brief Define a new Light CTL Client Model. + * + * @note This API needs to be called for each element on which + * the application needs to have a Light CTL Client Model. + * + * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t. + * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t. + * + * @return New Light CTL Client Model instance. + */ +#define ESP_BLE_MESH_MODEL_LIGHT_CTL_CLI(cli_pub, cli_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_CTL_CLI, \ + NULL, cli_pub, cli_data) + +/** @def ESP_BLE_MESH_MODEL_LIGHT_HSL_CLI + * + * @brief Define a new Light HSL Client Model. + * + * @note This API needs to be called for each element on which + * the application needs to have a Light HSL Client Model. + * + * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t. + * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t. + * + * @return New Light HSL Client Model instance. + */ +#define ESP_BLE_MESH_MODEL_LIGHT_HSL_CLI(cli_pub, cli_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_HSL_CLI, \ + NULL, cli_pub, cli_data) + +/** @def ESP_BLE_MESH_MODEL_LIGHT_XYL_CLI + * + * @brief Define a new Light xyL Client Model. + * + * @note This API needs to be called for each element on which + * the application needs to have a Light xyL Client Model. + * + * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t. + * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t. + * + * @return New Light xyL Client Model instance. + */ +#define ESP_BLE_MESH_MODEL_LIGHT_XYL_CLI(cli_pub, cli_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_XYL_CLI, \ + NULL, cli_pub, cli_data) + +/** @def ESP_BLE_MESH_MODEL_LIGHT_LC_CLI + * + * @brief Define a new Light LC Client Model. + * + * @note This API needs to be called for each element on which + * the application needs to have a Light LC Client Model. + * + * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t. + * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t. + * + * @return New Light LC Client Model instance. + */ +#define ESP_BLE_MESH_MODEL_LIGHT_LC_CLI(cli_pub, cli_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_LC_CLI, \ + NULL, cli_pub, cli_data) + +/** + * @brief Bluetooth Mesh Light Lightness Client Model Get and Set parameters structure. + */ + +/** Parameters of Light Lightness Set */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t lightness; /*!< Target value of light lightness 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_light_lightness_set_t; + +/** Parameters of Light Lightness Linear Set */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t lightness; /*!< Target value of light lightness linear 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_light_lightness_linear_set_t; + +/** Parameter of Light Lightness Default Set */ +typedef struct { + uint16_t lightness; /*!< The value of the Light Lightness Default state */ +} esp_ble_mesh_light_lightness_default_set_t; + +/** Parameters of Light Lightness Range Set */ +typedef struct { + uint16_t range_min; /*!< Value of range min field of light lightness range state */ + uint16_t range_max; /*!< Value of range max field of light lightness range state */ +} esp_ble_mesh_light_lightness_range_set_t; + +/** Parameters of Light CTL Set */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t ctl_lightness; /*!< Target value of light ctl lightness state */ + uint16_t ctl_temperatrue; /*!< Target value of light ctl temperature state */ + int16_t ctl_delta_uv; /*!< Target value of light ctl delta UV 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_light_ctl_set_t; + +/** Parameters of Light CTL Temperature Set */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t ctl_temperatrue; /*!< Target value of light ctl temperature state */ + int16_t ctl_delta_uv; /*!< Target value of light ctl delta UV 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_light_ctl_temperature_set_t; + +/** Parameters of Light CTL Temperature Range Set */ +typedef struct { + uint16_t range_min; /*!< Value of temperature range min field of light ctl temperature range state */ + uint16_t range_max; /*!< Value of temperature range max field of light ctl temperature range state */ +} esp_ble_mesh_light_ctl_temperature_range_set_t; + +/** Parameters of Light CTL Default Set */ +typedef struct { + uint16_t lightness; /*!< Value of light lightness default state */ + uint16_t temperature; /*!< Value of light temperature default state */ + int16_t delta_uv; /*!< Value of light delta UV default state */ +} esp_ble_mesh_light_ctl_default_set_t; + +/** Parameters of Light HSL Set */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t hsl_lightness; /*!< Target value of light hsl lightness state */ + uint16_t hsl_hue; /*!< Target value of light hsl hue state */ + uint16_t hsl_saturation; /*!< Target value of light hsl saturation 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_light_hsl_set_t; + +/** Parameters of Light HSL Hue Set */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t hue; /*!< Target value of light hsl hue 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_light_hsl_hue_set_t; + +/** Parameters of Light HSL Saturation Set */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t saturation; /*!< Target value of light hsl hue 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_light_hsl_saturation_set_t; + +/** Parameters of Light HSL Default Set */ +typedef struct { + uint16_t lightness; /*!< Value of light lightness default state */ + uint16_t hue; /*!< Value of light hue default state */ + uint16_t saturation; /*!< Value of light saturation default state */ +} esp_ble_mesh_light_hsl_default_set_t; + +/** Parameters of Light HSL Range Set */ +typedef struct { + uint16_t hue_range_min; /*!< Value of hue range min field of light hsl hue range state */ + uint16_t hue_range_max; /*!< Value of hue range max field of light hsl hue range state */ + uint16_t saturation_range_min; /*!< Value of saturation range min field of light hsl saturation range state */ + uint16_t saturation_range_max; /*!< Value of saturation range max field of light hsl saturation range state */ +} esp_ble_mesh_light_hsl_range_set_t; + +/** Parameters of Light xyL Set */ +typedef struct { + bool op_en; /*!< Indicate whether optional parameters included */ + uint16_t xyl_lightness; /*!< The target value of the Light xyL Lightness state */ + uint16_t xyl_x; /*!< The target value of the Light xyL x state */ + uint16_t xyl_y; /*!< The target value of the Light xyL y state */ + uint8_t tid; /*!< Transaction Identifier */ + uint8_t trans_time; /*!< Time to complete state transition (optional) */ + uint8_t delay; /*!< Indicate message execution delay (C.1) */ +} esp_ble_mesh_light_xyl_set_t; + +/** Parameters of Light xyL Default Set */ +typedef struct { + uint16_t lightness; /*!< The value of the Light Lightness Default state */ + uint16_t xyl_x; /*!< The value of the Light xyL x Default state */ + uint16_t xyl_y; /*!< The value of the Light xyL y Default state */ +} esp_ble_mesh_light_xyl_default_set_t; + +/** Parameters of Light xyL Range Set */ +typedef struct { + uint16_t xyl_x_range_min; /*!< The value of the xyL x Range Min field of the Light xyL x Range state */ + uint16_t xyl_x_range_max; /*!< The value of the xyL x Range Max field of the Light xyL x Range state */ + uint16_t xyl_y_range_min; /*!< The value of the xyL y Range Min field of the Light xyL y Range state */ + uint16_t xyl_y_range_max; /*!< The value of the xyL y Range Max field of the Light xyL y Range state */ +} esp_ble_mesh_light_xyl_range_set_t; + +/** Parameter of Light LC Mode Set */ +typedef struct { + uint8_t mode; /*!< The target value of the Light LC Mode state */ +} esp_ble_mesh_light_lc_mode_set_t; + +/** Parameter of Light LC OM Set */ +typedef struct { + uint8_t mode; /*!< The target value of the Light LC Occupancy Mode state */ +} esp_ble_mesh_light_lc_om_set_t; + +/** Parameters of Light LC Light OnOff Set */ +typedef struct { + bool op_en; /*!< Indicate whether optional parameters included */ + uint8_t light_onoff; /*!< The target value of the Light LC Light OnOff state */ + uint8_t tid; /*!< Transaction Identifier */ + uint8_t trans_time; /*!< Time to complete state transition (optional) */ + uint8_t delay; /*!< Indicate message execution delay (C.1) */ +} esp_ble_mesh_light_lc_light_onoff_set_t; + +/** Parameter of Light LC Property Get */ +typedef struct { + uint16_t property_id; /*!< Property ID identifying a Light LC Property */ +} esp_ble_mesh_light_lc_property_get_t; + +/** Parameters of Light LC Property Set */ +typedef struct { + uint16_t property_id; /*!< Property ID identifying a Light LC Property */ + struct net_buf_simple *property_value; /*!< Raw value for the Light LC Property */ +} esp_ble_mesh_light_lc_property_set_t; + +/** + * @brief Lighting Client Model get message union + */ +typedef union { + esp_ble_mesh_light_lc_property_get_t lc_property_get; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_GET */ +} esp_ble_mesh_light_client_get_state_t; + +/** + * @brief Lighting Client Model set message union + */ +typedef union { + esp_ble_mesh_light_lightness_set_t lightness_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_SET_UNACK */ + esp_ble_mesh_light_lightness_linear_set_t lightness_linear_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_SET_UNACK */ + esp_ble_mesh_light_lightness_default_set_t lightness_default_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_SET_UNACK */ + esp_ble_mesh_light_lightness_range_set_t lightness_range_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_SET_UNACK */ + esp_ble_mesh_light_ctl_set_t ctl_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_SET_UNACK */ + esp_ble_mesh_light_ctl_temperature_set_t ctl_temperature_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_SET_UNACK */ + esp_ble_mesh_light_ctl_temperature_range_set_t ctl_temperature_range_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_SET_UNACK */ + esp_ble_mesh_light_ctl_default_set_t ctl_default_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_SET_UNACK */ + esp_ble_mesh_light_hsl_set_t hsl_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SET_UNACK */ + esp_ble_mesh_light_hsl_hue_set_t hsl_hue_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_SET_UNACK */ + esp_ble_mesh_light_hsl_saturation_set_t hsl_saturation_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_SET_UNACK */ + esp_ble_mesh_light_hsl_default_set_t hsl_default_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_SET_UNACK */ + esp_ble_mesh_light_hsl_range_set_t hsl_range_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_SET_UNACK */ + esp_ble_mesh_light_xyl_set_t xyl_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_SET_UNACK */ + esp_ble_mesh_light_xyl_default_set_t xyl_default_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_SET_UNACK */ + esp_ble_mesh_light_xyl_range_set_t xyl_range_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_SET_UNACK */ + esp_ble_mesh_light_lc_mode_set_t lc_mode_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LC_MODE_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_LC_MODE_SET_UNACK */ + esp_ble_mesh_light_lc_om_set_t lc_om_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LC_OM_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_LC_OM_SET_UNACK */ + esp_ble_mesh_light_lc_light_onoff_set_t lc_light_onoff_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_SET_UNACK */ + esp_ble_mesh_light_lc_property_set_t lc_property_set; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET & ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET_UNACK */ +} esp_ble_mesh_light_client_set_state_t; + +/** + * @brief Bluetooth Mesh Light Lightness Client Model Get and Set callback parameters structure. + */ + +/** Parameters of Light Lightness Status */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t present_lightness; /*!< Current value of light lightness actual state */ + uint16_t target_lightness; /*!< Target value of light lightness actual state (optional) */ + uint8_t remain_time; /*!< Time to complete state transition (C.1) */ +} esp_ble_mesh_light_lightness_status_cb_t; + +/** Parameters of Light Lightness Linear Status */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t present_lightness; /*!< Current value of light lightness linear state */ + uint16_t target_lightness; /*!< Target value of light lightness linear state (optional) */ + uint8_t remain_time; /*!< Time to complete state transition (C.1) */ +} esp_ble_mesh_light_lightness_linear_status_cb_t; + +/** Parameter of Light Lightness Last Status */ +typedef struct { + uint16_t lightness; /*!< The value of the Light Lightness Last state */ +} esp_ble_mesh_light_lightness_last_status_cb_t; + +/** Parameter of Light Lightness Default Status */ +typedef struct { + uint16_t lightness; /*!< The value of the Light Lightness default State */ +} esp_ble_mesh_light_lightness_default_status_cb_t; + +/** Parameters of Light Lightness Range Status */ +typedef struct { + uint8_t status_code; /*!< Status Code for the request message */ + uint16_t range_min; /*!< Value of range min field of light lightness range state */ + uint16_t range_max; /*!< Value of range max field of light lightness range state */ +} esp_ble_mesh_light_lightness_range_status_cb_t; + +/** Parameters of Light CTL Status */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t present_ctl_lightness; /*!< Current value of light ctl lightness state */ + uint16_t present_ctl_temperature; /*!< Current value of light ctl temperature state */ + uint16_t target_ctl_lightness; /*!< Target value of light ctl lightness state (optional) */ + uint16_t target_ctl_temperature; /*!< Target value of light ctl temperature state (C.1) */ + uint8_t remain_time; /*!< Time to complete state transition (C.1) */ +} esp_ble_mesh_light_ctl_status_cb_t; + +/** Parameters of Light CTL Temperature Status */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t present_ctl_temperature; /*!< Current value of light ctl temperature state */ + uint16_t present_ctl_delta_uv; /*!< Current value of light ctl delta UV state */ + uint16_t target_ctl_temperature; /*!< Target value of light ctl temperature state (optional) */ + uint16_t target_ctl_delta_uv; /*!< Target value of light ctl delta UV state (C.1) */ + uint8_t remain_time; /*!< Time to complete state transition (C.1) */ +} esp_ble_mesh_light_ctl_temperature_status_cb_t; + +/** Parameters of Light CTL Temperature Range Status */ +typedef struct { + uint8_t status_code; /*!< Status code for the request message */ + uint16_t range_min; /*!< Value of temperature range min field of light ctl temperature range state */ + uint16_t range_max; /*!< Value of temperature range max field of light ctl temperature range state */ +} esp_ble_mesh_light_ctl_temperature_range_status_cb_t; + +/** Parameters of Light CTL Default Status */ +typedef struct { + uint16_t lightness; /*!< Value of light lightness default state */ + uint16_t temperature; /*!< Value of light temperature default state */ + int16_t delta_uv; /*!< Value of light delta UV default state */ +} esp_ble_mesh_light_ctl_default_status_cb_t; + +/** Parameters of Light HSL Status */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t hsl_lightness; /*!< Current value of light hsl lightness state */ + uint16_t hsl_hue; /*!< Current value of light hsl hue state */ + uint16_t hsl_saturation; /*!< Current value of light hsl saturation state */ + uint8_t remain_time; /*!< Time to complete state transition (optional) */ +} esp_ble_mesh_light_hsl_status_cb_t; + +/** Parameters of Light HSL Target Status */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t hsl_lightness_target; /*!< Target value of light hsl lightness state */ + uint16_t hsl_hue_target; /*!< Target value of light hsl hue state */ + uint16_t hsl_saturation_target; /*!< Target value of light hsl saturation state */ + uint8_t remain_time; /*!< Time to complete state transition (optional) */ +} esp_ble_mesh_light_hsl_target_status_cb_t; + +/** Parameters of Light HSL Hue Status */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t present_hue; /*!< Current value of light hsl hue state */ + uint16_t target_hue; /*!< Target value of light hsl hue state (optional) */ + uint8_t remain_time; /*!< Time to complete state transition (C.1) */ +} esp_ble_mesh_light_hsl_hue_status_cb_t; + +/** Parameters of Light HSL Saturation Status */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t present_saturation; /*!< Current value of light hsl saturation state */ + uint16_t target_saturation; /*!< Target value of light hsl saturation state (optional) */ + uint8_t remain_time; /*!< Time to complete state transition (C.1) */ +} esp_ble_mesh_light_hsl_saturation_status_cb_t; + +/** Parameters of Light HSL Default Status */ +typedef struct { + uint16_t lightness; /*!< Value of light lightness default state */ + uint16_t hue; /*!< Value of light hue default state */ + uint16_t saturation; /*!< Value of light saturation default state */ +} esp_ble_mesh_light_hsl_default_status_cb_t; + +/** Parameters of Light HSL Range Status */ +typedef struct { + uint8_t status_code; /*!< Status code for the request message */ + uint16_t hue_range_min; /*!< Value of hue range min field of light hsl hue range state */ + uint16_t hue_range_max; /*!< Value of hue range max field of light hsl hue range state */ + uint16_t saturation_range_min; /*!< Value of saturation range min field of light hsl saturation range state */ + uint16_t saturation_range_max; /*!< Value of saturation range max field of light hsl saturation range state */ +} esp_ble_mesh_light_hsl_range_status_cb_t; + +/** Parameters of Light xyL Status */ +typedef struct { + bool op_en; /*!< Indicate whether optional parameters included */ + uint16_t xyl_lightness; /*!< The present value of the Light xyL Lightness state */ + uint16_t xyl_x; /*!< The present value of the Light xyL x state */ + uint16_t xyl_y; /*!< The present value of the Light xyL y state */ + uint8_t remain_time; /*!< Time to complete state transition (optional) */ +} esp_ble_mesh_light_xyl_status_cb_t; + +/** Parameters of Light xyL Target Status */ +typedef struct { + bool op_en; /*!< Indicate whether optional parameters included */ + uint16_t target_xyl_lightness; /*!< The target value of the Light xyL Lightness state */ + uint16_t target_xyl_x; /*!< The target value of the Light xyL x state */ + uint16_t target_xyl_y; /*!< The target value of the Light xyL y state */ + uint8_t remain_time; /*!< Time to complete state transition (optional) */ +} esp_ble_mesh_light_xyl_target_status_cb_t; + +/** Parameters of Light xyL Default Status */ +typedef struct { + uint16_t lightness; /*!< The value of the Light Lightness Default state */ + uint16_t xyl_x; /*!< The value of the Light xyL x Default state */ + uint16_t xyl_y; /*!< The value of the Light xyL y Default state */ +} esp_ble_mesh_light_xyl_default_status_cb_t; + +/** Parameters of Light xyL Range Status */ +typedef struct { + uint8_t status_code; /*!< Status Code for the requesting message */ + uint16_t xyl_x_range_min; /*!< The value of the xyL x Range Min field of the Light xyL x Range state */ + uint16_t xyl_x_range_max; /*!< The value of the xyL x Range Max field of the Light xyL x Range state */ + uint16_t xyl_y_range_min; /*!< The value of the xyL y Range Min field of the Light xyL y Range state */ + uint16_t xyl_y_range_max; /*!< The value of the xyL y Range Max field of the Light xyL y Range state */ +} esp_ble_mesh_light_xyl_range_status_cb_t; + +/** Parameter of Light LC Mode Status */ +typedef struct { + uint8_t mode; /*!< The present value of the Light LC Mode state */ +} esp_ble_mesh_light_lc_mode_status_cb_t; + +/** Parameter of Light LC OM Status */ +typedef struct { + uint8_t mode; /*!< The present value of the Light LC Occupancy Mode state */ +} esp_ble_mesh_light_lc_om_status_cb_t; + +/** Parameters of Light LC Light OnOff Status */ +typedef struct { + bool op_en; /*!< Indicate whether optional parameters included */ + uint8_t present_light_onoff; /*!< The present value of the Light LC Light OnOff state */ + uint8_t target_light_onoff; /*!< The target value of the Light LC Light OnOff state (Optional) */ + uint8_t remain_time; /*!< Time to complete state transition (C.1) */ +} esp_ble_mesh_light_lc_light_onoff_status_cb_t; + +/** Parameters of Light LC Property Status */ +typedef struct { + uint16_t property_id; /*!< Property ID identifying a Light LC Property */ + struct net_buf_simple *property_value; /*!< Raw value for the Light LC Property */ +} esp_ble_mesh_light_lc_property_status_cb_t; + +/** + * @brief Lighting Client Model received message union + */ +typedef union { + esp_ble_mesh_light_lightness_status_cb_t lightness_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_STATUS */ + esp_ble_mesh_light_lightness_linear_status_cb_t lightness_linear_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_STATUS */ + esp_ble_mesh_light_lightness_last_status_cb_t lightness_last_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LAST_STATUS */ + esp_ble_mesh_light_lightness_default_status_cb_t lightness_default_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_STATUS */ + esp_ble_mesh_light_lightness_range_status_cb_t lightness_range_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_STATUS */ + esp_ble_mesh_light_ctl_status_cb_t ctl_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_STATUS */ + esp_ble_mesh_light_ctl_temperature_status_cb_t ctl_temperature_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_STATUS */ + esp_ble_mesh_light_ctl_temperature_range_status_cb_t ctl_temperature_range_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_STATUS */ + esp_ble_mesh_light_ctl_default_status_cb_t ctl_default_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_STATUS */ + esp_ble_mesh_light_hsl_status_cb_t hsl_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_STATUS */ + esp_ble_mesh_light_hsl_target_status_cb_t hsl_target_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_TARGET_STATUS */ + esp_ble_mesh_light_hsl_hue_status_cb_t hsl_hue_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_STATUS */ + esp_ble_mesh_light_hsl_saturation_status_cb_t hsl_saturation_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_STATUS */ + esp_ble_mesh_light_hsl_default_status_cb_t hsl_default_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_STATUS */ + esp_ble_mesh_light_hsl_range_status_cb_t hsl_range_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_STATUS */ + esp_ble_mesh_light_xyl_status_cb_t xyl_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_STATUS */ + esp_ble_mesh_light_xyl_target_status_cb_t xyl_target_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_TARGET_STATUS */ + esp_ble_mesh_light_xyl_default_status_cb_t xyl_default_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_STATUS */ + esp_ble_mesh_light_xyl_range_status_cb_t xyl_range_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_STATUS */ + esp_ble_mesh_light_lc_mode_status_cb_t lc_mode_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LC_MODE_STATUS */ + esp_ble_mesh_light_lc_om_status_cb_t lc_om_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LC_OM_STATUS */ + esp_ble_mesh_light_lc_light_onoff_status_cb_t lc_light_onoff_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_STATUS */ + esp_ble_mesh_light_lc_property_status_cb_t lc_property_status; /*!< For ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_STATUS */ +} esp_ble_mesh_light_client_status_cb_t; + +/** Lighting Client Model callback parameters */ +typedef struct { + int error_code; /*!< Appropriate error code */ + esp_ble_mesh_client_common_param_t *params; /*!< The client common parameters. */ + esp_ble_mesh_light_client_status_cb_t status_cb; /*!< The light status message callback values */ +} esp_ble_mesh_light_client_cb_param_t; + +/** This enum value is the event of Lighting Client Model */ +typedef enum { + ESP_BLE_MESH_LIGHT_CLIENT_GET_STATE_EVT, + ESP_BLE_MESH_LIGHT_CLIENT_SET_STATE_EVT, + ESP_BLE_MESH_LIGHT_CLIENT_PUBLISH_EVT, + ESP_BLE_MESH_LIGHT_CLIENT_TIMEOUT_EVT, + ESP_BLE_MESH_LIGHT_CLIENT_EVT_MAX, +} esp_ble_mesh_light_client_cb_event_t; + +/** + * @brief Bluetooth Mesh Light Client Model function. + */ + +/** + * @brief Lighting Client Model callback function type + * @param event: Event type + * @param param: Pointer to callback parameter + */ +typedef void (* esp_ble_mesh_light_client_cb_t)(esp_ble_mesh_light_client_cb_event_t event, + esp_ble_mesh_light_client_cb_param_t *param); + +/** + * @brief Register BLE Mesh Light Client 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_light_client_callback(esp_ble_mesh_light_client_cb_t callback); + +/** + * @brief Get the value of Light Server Model states using the Light Client Model get messages. + * + * @note If you want to know the opcodes and corresponding meanings accepted by this API, + * please refer to esp_ble_mesh_light_message_opcode_t in esp_ble_mesh_defs.h + * + * @param[in] params: Pointer to BLE Mesh common client parameters. + * @param[in] get_state: Pointer of light get message value. + * Shall not be set to NULL. + * + * @return ESP_OK on success or error code otherwise. + * + */ +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); + +/** + * @brief Set the value of Light Server Model states using the Light Client Model set messages. + * + * @note If you want to know the opcodes and corresponding meanings accepted by this API, + * please refer to esp_ble_mesh_light_message_opcode_t in esp_ble_mesh_defs.h + * + * @param[in] params: Pointer to BLE Mesh common client parameters. + * @param[in] set_state: Pointer of light set message value. + * Shall not be set to NULL. + * + * @return ESP_OK on success or error code otherwise. + * + */ +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); + +/** + * @brief Lighting Server Models related context. + */ + +/** @def ESP_BLE_MESH_MODEL_LIGHT_LIGHTNESS_SRV + * + * @brief Define a new Light Lightness Server Model. + * + * @note 1. The Light Lightness 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 Light Lightness 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_light_lightness_srv_t. + * + * @return New Light Lightness Server Model instance. + */ +#define ESP_BLE_MESH_MODEL_LIGHT_LIGHTNESS_SRV(srv_pub, srv_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SRV, \ + NULL, srv_pub, srv_data) + +/** @def ESP_BLE_MESH_MODEL_LIGHT_LIGHTNESS_SETUP_SRV + * + * @brief Define a new Light Lightness Setup Server Model. + * + * @note 1. The Light Lightness Setup Server model extends the Light Lightness + * 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_light_lightness_setup_srv_t. + * + * @return New Light Lightness Setup Server Model instance. + */ +#define ESP_BLE_MESH_MODEL_LIGHT_LIGHTNESS_SETUP_SRV(srv_pub, srv_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SETUP_SRV, \ + NULL, srv_pub, srv_data) + +/** @def ESP_BLE_MESH_MODEL_LIGHT_CTL_SRV + * + * @brief Define a new Light CTL Server Model. + * + * @note 1. The Light CTL Server model extends the Light Lightness Server model. + * When this model is present on an Element, the corresponding Light + * CTL Temperature Server model and the corresponding Light CTL Setup + * Server model shall also be present. + * 2. This model shall support model publication and model subscription. + * 3. The model requires two elements: the main element and the Temperature + * element. The Temperature element contains the corresponding Light CTL + * Temperature Server model and an instance of a Generic Level state + * bound to the Light CTL Temperature state on the Temperature element. + * The Light CTL Temperature state on the Temperature element is bound to + * the Light CTL state on the main 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_light_ctl_srv_t. + * + * @return New Light CTL Server Model instance. + */ +#define ESP_BLE_MESH_MODEL_LIGHT_CTL_SRV(srv_pub, srv_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_CTL_SRV, \ + NULL, srv_pub, srv_data) + +/** @def ESP_BLE_MESH_MODEL_LIGHT_CTL_SETUP_SRV + * + * @brief Define a new Light CTL Setup Server Model. + * + * @note 1. The Light CTL Setup Server model extends the Light CTL Server and + * the Light Lightness Setup Server. + * 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_light_ctl_setup_srv_t. + * + * @return New Light CTL Setup Server Model instance. + */ +#define ESP_BLE_MESH_MODEL_LIGHT_CTL_SETUP_SRV(srv_pub, srv_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_CTL_SETUP_SRV, \ + NULL, srv_pub, srv_data) + +/** @def ESP_BLE_MESH_MODEL_LIGHT_CTL_TEMP_SRV + * + * @brief Define a new Light CTL Temperature Server Model. + * + * @note 1. The Light CTL Temperature Server model extends the Generic Level + * 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_light_ctl_temp_srv_t. + * + * @return New Light CTL Temperature Server Model instance. + */ +#define ESP_BLE_MESH_MODEL_LIGHT_CTL_TEMP_SRV(srv_pub, srv_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_CTL_TEMP_SRV, \ + NULL, srv_pub, srv_data) + +/** @def ESP_BLE_MESH_MODEL_LIGHT_HSL_SRV + * + * @brief Define a new Light HSL Server Model. + * + * @note 1. The Light HSL Server model extends the Light Lightness Server model. When + * this model is present on an Element, the corresponding Light HSL Hue + * Server model and the corresponding Light HSL Saturation Server model and + * the corresponding Light HSL Setup Server model shall also be present. + * 2. This model shall support model publication and model subscription. + * 3. The model requires three elements: the main element and the Hue element + * and the Saturation element. The Hue element contains the corresponding + * Light HSL Hue Server model and an instance of a Generic Level state bound + * to the Light HSL Hue state on the Hue element. The Saturation element + * contains the corresponding Light HSL Saturation Server model and an + * instance of a Generic Level state bound to the Light HSL Saturation state + * on the Saturation element. The Light HSL Hue state on the Hue element is + * bound to the Light HSL state on the main element and the Light HSL + * Saturation state on the Saturation element is bound to the Light HSL state + * on the main 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_light_hsl_srv_t. + * + * @return New Light HSL Server Model instance. + */ +#define ESP_BLE_MESH_MODEL_LIGHT_HSL_SRV(srv_pub, srv_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_HSL_SRV, \ + NULL, srv_pub, srv_data) + +/** @def ESP_BLE_MESH_MODEL_LIGHT_HSL_SETUP_SRV + * + * @brief Define a new Light HSL Setup Server Model. + * + * @note 1. The Light HSL Setup Server model extends the Light HSL Server and + * the Light Lightness Setup Server. + * 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_light_hsl_setup_srv_t. + * + * @return New Light HSL Setup Server Model instance. + */ +#define ESP_BLE_MESH_MODEL_LIGHT_HSL_SETUP_SRV(srv_pub, srv_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_HSL_SETUP_SRV, \ + NULL, srv_pub, srv_data) + +/** @def ESP_BLE_MESH_MODEL_LIGHT_HSL_HUE_SRV + * + * @brief Define a new Light HSL Hue Server Model. + * + * @note 1. The Light HSL Hue Server model extends the Generic Level Server model. + * This model is associated with the Light HSL 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_light_hsl_hue_srv_t. + * + * @return New Light HSL Hue Server Model instance. + */ +#define ESP_BLE_MESH_MODEL_LIGHT_HSL_HUE_SRV(srv_pub, srv_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_HSL_HUE_SRV, \ + NULL, srv_pub, srv_data) + +/** @def ESP_BLE_MESH_MODEL_LIGHT_HSL_SAT_SRV + * + * @brief Define a new Light HSL Saturation Server Model. + * + * @note 1. The Light HSL Saturation Server model extends the Generic Level Server + * model. This model is associated with the Light HSL 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_light_hsl_sat_srv_t. + * + * @return New Light HSL Saturation Server Model instance. + */ +#define ESP_BLE_MESH_MODEL_LIGHT_HSL_SAT_SRV(srv_pub, srv_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_HSL_SAT_SRV, \ + NULL, srv_pub, srv_data) + +/** @def ESP_BLE_MESH_MODEL_LIGHT_XYL_SRV + * + * @brief Define a new Light xyL Server Model. + * + * @note 1. The Light xyL Server model extends the Light Lightness Server model. + * When this model is present on an Element, the corresponding Light xyL + * 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_light_xyl_srv_t. + * + * @return New Light xyL Server Model instance. + */ +#define ESP_BLE_MESH_MODEL_LIGHT_XYL_SRV(srv_pub, srv_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_XYL_SRV, \ + NULL, srv_pub, srv_data) + +/** @def ESP_BLE_MESH_MODEL_LIGHT_XYL_SETUP_SRV + * + * @brief Define a new Light xyL Setup Server Model. + * + * @note 1. The Light xyL Setup Server model extends the Light xyL Server and + * the Light Lightness Setup Server. + * 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_light_xyl_setup_srv_t. + * + * @return New Light xyL Setup Server Model instance. + */ +#define ESP_BLE_MESH_MODEL_LIGHT_XYL_SETUP_SRV(srv_pub, srv_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_XYL_SETUP_SRV, \ + NULL, srv_pub, srv_data) + +/** @def ESP_BLE_MESH_MODEL_LIGHT_LC_SRV + * + * @brief Define a new Light LC Server Model. + * + * @note 1. The Light LC (Lightness Control) Server model extends the Light + * Lightness Server model and the Generic OnOff Server model. When + * this model is present on an Element, the corresponding Light LC + * Setup Server model shall also be present. + * 2. This model shall support model publication and model subscription. + * 3. This model may be used to represent an element that is a client to + * a Sensor Server model and controls the Light Lightness Actual state + * via defined state bindings. + * + * @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_light_lc_srv_t. + * + * @return New Light LC Server Model instance. + */ +#define ESP_BLE_MESH_MODEL_LIGHT_LC_SRV(srv_pub, srv_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_LC_SRV, \ + NULL, srv_pub, srv_data) + +/** @def ESP_BLE_MESH_MODEL_LIGHT_LC_SETUP_SRV + * + * @brief Define a new Light LC Setup Server Model. + * + * @note 1. The Light LC (Lightness Control) Setup model extends the Light LC + * Server model. + * 2. This model shall support model publication and model subscription. + * 3. This model may be used to configure setup parameters for the Light + * LC Server model. + * + * @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_light_lc_setup_srv_t. + * + * @return New Light LC Setup Server Model instance. + */ +#define ESP_BLE_MESH_MODEL_LIGHT_LC_SETUP_SRV(srv_pub, srv_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_LIGHT_LC_SETUP_SRV, \ + NULL, srv_pub, srv_data) + +/** Parameters of Light Lightness state */ +typedef struct { + uint16_t lightness_linear; /*!< The present value of Light Lightness Linear state */ + uint16_t target_lightness_linear; /*!< The target value of Light Lightness Linear state */ + + uint16_t lightness_actual; /*!< The present value of Light Lightness Actual state */ + uint16_t target_lightness_actual; /*!< The target value of Light Lightness Actual state */ + + uint16_t lightness_last; /*!< The value of Light Lightness Last state */ + uint16_t lightness_default; /*!< The value of Light Lightness Default state */ + + uint8_t status_code; /*!< The status code of setting Light Lightness Range state */ + uint16_t lightness_range_min; /*!< The minimum value of Light Lightness Range state */ + uint16_t lightness_range_max; /*!< The maximum value of Light Lightness Range state */ +} esp_ble_mesh_light_lightness_state_t; + +/** User data of Light Lightness Server Model */ +typedef struct { + esp_ble_mesh_model_t *model; /*!< Pointer to the Lighting Lightness Server Model. Initialized internally. */ + esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */ + esp_ble_mesh_light_lightness_state_t *state; /*!< Parameters of the Light Lightness state */ + esp_ble_mesh_last_msg_info_t last; /*!< Parameters of the last received set message */ + esp_ble_mesh_state_transition_t actual_transition; /*!< Parameters of state transition */ + esp_ble_mesh_state_transition_t linear_transition; /*!< Parameters of state transition */ + int32_t tt_delta_lightness_actual; /*!< Delta change value of lightness actual state transition */ + int32_t tt_delta_lightness_linear; /*!< Delta change value of lightness linear state transition */ +} esp_ble_mesh_light_lightness_srv_t; + +/** User data of Light Lightness Setup Server Model */ +typedef struct { + esp_ble_mesh_model_t *model; /*!< Pointer to the Lighting Lightness 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_light_lightness_state_t *state; /*!< Parameters of the Light Lightness state */ +} esp_ble_mesh_light_lightness_setup_srv_t; + +/** Parameters of Light CTL state */ +typedef struct { + uint16_t lightness; /*!< The present value of Light CTL Lightness state */ + uint16_t target_lightness; /*!< The target value of Light CTL Lightness state */ + + uint16_t temperature; /*!< The present value of Light CTL Temperature state */ + uint16_t target_temperature; /*!< The target value of Light CTL Temperature state */ + + int16_t delta_uv; /*!< The present value of Light CTL Delta UV state */ + int16_t target_delta_uv; /*!< The target value of Light CTL Delta UV state */ + + uint8_t status_code; /*!< The statue code of setting Light CTL Temperature Range state */ + uint16_t temperature_range_min; /*!< The minimum value of Light CTL Temperature Range state */ + uint16_t temperature_range_max; /*!< The maximum value of Light CTL Temperature Range state */ + + uint16_t lightness_default; /*!< The value of Light Lightness Default state */ + uint16_t temperature_default; /*!< The value of Light CTL Temperature Default state */ + int16_t delta_uv_default; /*!< The value of Light CTL Delta UV Default state */ +} esp_ble_mesh_light_ctl_state_t; + +/** User data of Light CTL Server Model */ +typedef struct { + esp_ble_mesh_model_t *model; /*!< Pointer to the Lighting CTL Server Model. Initialized internally. */ + esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */ + esp_ble_mesh_light_ctl_state_t *state; /*!< Parameters of the Light CTL 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_lightness; /*!< Delta change value of lightness state transition */ + int32_t tt_delta_temperature; /*!< Delta change value of temperature state transition */ + int32_t tt_delta_delta_uv; /*!< Delta change value of delta uv state transition */ +} esp_ble_mesh_light_ctl_srv_t; + +/** User data of Light CTL Setup Server Model */ +typedef struct { + esp_ble_mesh_model_t *model; /*!< Pointer to the Lighting CTL 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_light_ctl_state_t *state; /*!< Parameters of the Light CTL state */ +} esp_ble_mesh_light_ctl_setup_srv_t; + +/** User data of Light CTL Temperature Server Model */ +typedef struct { + esp_ble_mesh_model_t *model; /*!< Pointer to the Lighting CTL Temperature Server Model. Initialized internally. */ + esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */ + esp_ble_mesh_light_ctl_state_t *state; /*!< Parameters of the Light CTL 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_temperature; /*!< Delta change value of temperature state transition */ + int32_t tt_delta_delta_uv; /*!< Delta change value of delta uv state transition */ +} esp_ble_mesh_light_ctl_temp_srv_t; + +/** Parameters of Light HSL state */ +typedef struct { + uint16_t lightness; /*!< The present value of Light HSL Lightness state */ + uint16_t target_lightness; /*!< The target value of Light HSL Lightness state */ + + uint16_t hue; /*!< The present value of Light HSL Hue state */ + uint16_t target_hue; /*!< The target value of Light HSL Hue state */ + + uint16_t saturation; /*!< The present value of Light HSL Saturation state */ + uint16_t target_saturation; /*!< The target value of Light HSL Saturation state */ + + uint16_t lightness_default; /*!< The value of Light Lightness Default state */ + uint16_t hue_default; /*!< The value of Light HSL Hue Default state */ + uint16_t saturation_default; /*!< The value of Light HSL Saturation Default state */ + + uint8_t status_code; /*!< The status code of setting Light HSL Hue & Saturation Range state */ + uint16_t hue_range_min; /*!< The minimum value of Light HSL Hue Range state */ + uint16_t hue_range_max; /*!< The maximum value of Light HSL Hue Range state */ + uint16_t saturation_range_min; /*!< The minimum value of Light HSL Saturation state */ + uint16_t saturation_range_max; /*!< The maximum value of Light HSL Saturation state */ +} esp_ble_mesh_light_hsl_state_t; + +/** User data of Light HSL Server Model */ +typedef struct { + esp_ble_mesh_model_t *model; /*!< Pointer to the Lighting HSL Server Model. Initialized internally. */ + esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */ + esp_ble_mesh_light_hsl_state_t *state; /*!< Parameters of the Light HSL 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_lightness; /*!< Delta change value of lightness state transition */ + int32_t tt_delta_hue; /*!< Delta change value of hue state transition */ + int32_t tt_delta_saturation; /*!< Delta change value of saturation state transition */ +} esp_ble_mesh_light_hsl_srv_t; + +/** User data of Light HSL Setup Server Model */ +typedef struct { + esp_ble_mesh_model_t *model; /*!< Pointer to the Lighting HSL 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_light_hsl_state_t *state; /*!< Parameters of the Light HSL state */ +} esp_ble_mesh_light_hsl_setup_srv_t; + +/** User data of Light HSL Hue Server Model */ +typedef struct { + esp_ble_mesh_model_t *model; /*!< Pointer to the Lighting HSL Hue Server Model. Initialized internally. */ + esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */ + esp_ble_mesh_light_hsl_state_t *state; /*!< Parameters of the Light HSL 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_hue; /*!< Delta change value of hue state transition */ +} esp_ble_mesh_light_hsl_hue_srv_t; + +/** User data of Light HSL Saturation Server Model */ +typedef struct { + esp_ble_mesh_model_t *model; /*!< Pointer to the Lighting HSL Saturation Server Model. Initialized internally. */ + esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */ + esp_ble_mesh_light_hsl_state_t *state; /*!< Parameters of the Light HSL 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_saturation; /*!< Delta change value of saturation state transition */ +} esp_ble_mesh_light_hsl_sat_srv_t; + +/** Parameters of Light xyL state */ +typedef struct { + uint16_t lightness; /*!< The present value of Light xyL Lightness state */ + uint16_t target_lightness; /*!< The target value of Light xyL Lightness state */ + + uint16_t x; /*!< The present value of Light xyL x state */ + uint16_t target_x; /*!< The target value of Light xyL x state */ + + uint16_t y; /*!< The present value of Light xyL y state */ + uint16_t target_y; /*!< The target value of Light xyL y state */ + + uint16_t lightness_default; /*!< The value of Light Lightness Default state */ + uint16_t x_default; /*!< The value of Light xyL x Default state */ + uint16_t y_default; /*!< The value of Light xyL y Default state */ + + uint8_t status_code; /*!< The status code of setting Light xyL x & y Range state */ + uint16_t x_range_min; /*!< The minimum value of Light xyL x Range state */ + uint16_t x_range_max; /*!< The maximum value of Light xyL x Range state */ + uint16_t y_range_min; /*!< The minimum value of Light xyL y Range state */ + uint16_t y_range_max; /*!< The maximum value of Light xyL y Range state */ +} esp_ble_mesh_light_xyl_state_t; + +/** User data of Light xyL Server Model */ +typedef struct { + esp_ble_mesh_model_t *model; /*!< Pointer to the Lighting xyL Server Model. Initialized internally. */ + esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */ + esp_ble_mesh_light_xyl_state_t *state; /*!< Parameters of the Light xyL 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_lightness; /*!< Delta change value of lightness state transition */ + int32_t tt_delta_x; /*!< Delta change value of x state transition */ + int32_t tt_delta_y; /*!< Delta change value of y state transition */ +} esp_ble_mesh_light_xyl_srv_t; + +/** User data of Light xyL Setup Server Model */ +typedef struct { + esp_ble_mesh_model_t *model; /*!< Pointer to the Lighting xyL 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_light_xyl_state_t *state; /*!< Parameters of the Light xyL state */ +} esp_ble_mesh_light_xyl_setup_srv_t; + +/** Parameters of Light LC states */ +typedef struct { + /** + * 0b0 The controller is turned off. + * - The binding with the Light Lightness state is disabled. + * 0b1 The controller is turned on. + * - The binding with the Light Lightness state is enabled. + */ + uint32_t mode : 1, /*!< The value of Light LC Mode state */ + occupancy_mode : 1, /*!< The value of Light LC Occupancy Mode state */ + light_onoff : 1, /*!< The present value of Light LC Light OnOff state */ + target_light_onoff : 1, /*!< The target value of Light LC Light OnOff state */ + occupancy : 1, /*!< The value of Light LC Occupancy state */ + ambient_luxlevel : 24; /*!< The value of Light LC Ambient LuxLevel state */ + + /** + * 1. Light LC Linear Output = max((Lightness Out)^2/65535, Regulator Output) + * 2. If the Light LC Mode state is set to 0b1, the binding is enabled and upon + * a change of the Light LC Linear Output state, the following operation + * shall be performed: + * Light Lightness Linear = Light LC Linear Output + * 3. If the Light LC Mode state is set to 0b0, the binding is disabled (i.e., + * upon a change of the Light LC Linear Output state, no operation on the + * Light Lightness Linear state is performed). + */ + uint16_t linear_output; /*!< The value of Light LC Linear Output state */ +} esp_ble_mesh_light_lc_state_t; + +/** + * Parameters of Light Property states. + * The Light LC Property states are read / write states that determine the + * configuration of a Light Lightness Controller. Each state is represented + * by a device property and is controlled by Light LC Property messages. + */ +typedef struct { + /** + * A timing state that determines the delay for changing the Light LC + * Occupancy state upon receiving a Sensor Status message from an + * occupancy sensor. + */ + uint32_t time_occupancy_delay; /*!< The value of Light LC Time Occupancy Delay state */ + /** + * A timing state that determines the time the controlled lights fade + * to the level determined by the Light LC Lightness On state. + */ + uint32_t time_fade_on; /*!< The value of Light LC Time Fade On state */ + /** + * A timing state that determines the time the controlled lights stay + * at the level determined by the Light LC Lightness On state. + */ + uint32_t time_run_on; /*!< The value of Light LC Time Run On state */ + /** + * A timing state that determines the time the controlled lights fade + * from the level determined by the Light LC Lightness On state to the + * level determined by the Light Lightness Prolong state. + */ + uint32_t time_fade; /*!< The value of Light LC Time Fade state */ + /** + * A timing state that determines the time the controlled lights stay at + * the level determined by the Light LC Lightness Prolong state. + */ + uint32_t time_prolong; /*!< The value of Light LC Time Prolong state */ + /** + * A timing state that determines the time the controlled lights fade from + * the level determined by the Light LC Lightness Prolong state to the level + * determined by the Light LC Lightness Standby state when the transition is + * automatic. + */ + uint32_t time_fade_standby_auto; /*!< The value of Light LC Time Fade Standby Auto state */ + /** + * A timing state that determines the time the controlled lights fade from + * the level determined by the Light LC Lightness Prolong state to the level + * determined by the Light LC Lightness Standby state when the transition is + * triggered by a change in the Light LC Light OnOff state. + */ + uint32_t time_fade_standby_manual; /*!< The value of Light LC Time Fade Standby Manual state */ + + /** + * A lightness state that determines the perceptive light lightness at the + * Occupancy and Run internal controller states. + */ + uint16_t lightness_on; /*!< The value of Light LC Lightness On state */ + /** + * A lightness state that determines the light lightness at the Prolong + * internal controller state. + */ + uint16_t lightness_prolong; /*!< The value of Light LC Lightness Prolong state */ + /** + * A lightness state that determines the light lightness at the Standby + * internal controller state. + */ + uint16_t lightness_standby; /*!< The value of Light LC Lightness Standby state */ + + /** + * A uint16 state representing the Ambient LuxLevel level that determines + * if the controller transitions from the Light Control Standby state. + */ + uint16_t ambient_luxlevel_on; /*!< The value of Light LC Ambient LuxLevel On state */ + /** + * A uint16 state representing the required Ambient LuxLevel level in the + * Prolong state. + */ + uint16_t ambient_luxlevel_prolong; /*!< The value of Light LC Ambient LuxLevel Prolong state */ + /** + * A uint16 state representing the required Ambient LuxLevel level in the + * Standby state. + */ + uint16_t ambient_luxlevel_standby; /*!< The value of Light LC Ambient LuxLevel Standby state */ + + /** + * A float32 state representing the integral coefficient that determines the + * integral part of the equation defining the output of the Light LC PI + * Feedback Regulator, when Light LC Ambient LuxLevel is less than LuxLevel + * Out. Valid range: 0.0 ~ 1000.0. The default value is 250.0. + */ + float regulator_kiu; /*!< The value of Light LC Regulator Kiu state */ + /** + * A float32 state representing the integral coefficient that determines the + * integral part of the equation defining the output of the Light LC PI + * Feedback Regulator, when Light LC Ambient LuxLevel is greater than or equal + * to the value of the LuxLevel Out state. Valid range: 0.0 ~ 1000.0. The + * default value is 25.0. + */ + float regulator_kid; /*!< The value of Light LC Regulator Kid state */ + /** + * A float32 state representing the proportional coefficient that determines + * the proportional part of the equation defining the output of the Light LC + * PI Feedback Regulator, when Light LC Ambient LuxLevel is less than the value + * of the LuxLevel Out state. Valid range: 0.0 ~ 1000.0. The default value is 80.0. + */ + float regulator_kpu; /*!< The value of Light LC Regulator Kpu state */ + /** + * A float32 state representing the proportional coefficient that determines + * the proportional part of the equation defining the output of the Light LC PI + * Feedback Regulator, when Light LC Ambient LuxLevel is greater than or equal + * to the value of the LuxLevel Out state. Valid range: 0.0 ~ 1000.0. The default + * value is 80.0. + */ + float regulator_kpd; /*!< The value of Light LC Regulator Kpd state */ + /** + * A int8 state representing the percentage accuracy of the Light LC PI Feedback + * Regulator. Valid range: 0.0 ~ 100.0. The default value is 2.0. + */ + int8_t regulator_accuracy; /*!< The value of Light LC Regulator Accuracy state */ + + /** + * If the message Raw field contains a Raw Value for the Time Since Motion + * Sensed device property, which represents a value less than or equal to + * the value of the Light LC Occupancy Delay state, it shall delay setting + * the Light LC Occupancy state to 0b1 by the difference between the value + * of the Light LC Occupancy Delay state and the received Time Since Motion + * value. + */ + uint32_t set_occupancy_to_1_delay; /*!< The value of the difference between value of the + Light LC Occupancy Delay state and the received + Time Since Motion value */ +} esp_ble_mesh_light_lc_property_state_t; + +/** This enum value is the Light LC State Machine states */ +typedef enum { + ESP_BLE_MESH_LC_OFF, + ESP_BLE_MESH_LC_STANDBY, + ESP_BLE_MESH_LC_FADE_ON, + ESP_BLE_MESH_LC_RUN, + ESP_BLE_MESH_LC_FADE, + ESP_BLE_MESH_LC_PROLONG, + ESP_BLE_MESH_LC_FADE_STANDBY_AUTO, + ESP_BLE_MESH_LC_FADE_STANDBY_MANUAL, +} esp_ble_mesh_lc_state_t; + +/** Parameters of Light LC state machine */ +typedef struct { + /** + * The Fade On, Fade, Fade Standby Auto, and Fade Standby Manual states are + * transition states that define the transition of the Lightness Out and + * LuxLevel Out states. This transition can be started as a result of the + * Light LC State Machine change or as a result of receiving the Light LC + * Light OnOff Set or Light LC Light Set Unacknowledged message. + */ + struct { + uint8_t fade_on; /*!< The value of transition time of Light LC Time Fade On */ + uint8_t fade; /*!< The value of transition time of Light LC Time Fade */ + uint8_t fade_standby_auto; /*!< The value of transition time of Light LC Time Fade Standby Auto */ + uint8_t fade_standby_manual; /*!< The value of transition time of Light LC Time Fade Standby Manual */ + } trans_time; /*!< The value of transition time */ + esp_ble_mesh_lc_state_t state; /*!< The value of Light LC state machine state */ + struct k_delayed_work timer; /*!< Timer of Light LC state machine */ +} esp_ble_mesh_light_lc_state_machine_t; + +/** Parameters of Light Lightness controller */ +typedef struct { + esp_ble_mesh_light_lc_state_t state; /*!< Parameters of Light LC state */ + esp_ble_mesh_light_lc_property_state_t prop_state; /*!< Parameters of Light LC Property state */ + esp_ble_mesh_light_lc_state_machine_t state_machine; /*!< Parameters of Light LC state machine */ +} esp_ble_mesh_light_control_t; + +/** User data of Light LC Server Model */ +typedef struct { + esp_ble_mesh_model_t *model; /*!< Pointer to the Lighting LC Server Model. Initialized internally. */ + esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */ + esp_ble_mesh_light_control_t *lc; /*!< Parameters of the Light controller */ + 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_light_lc_srv_t; + +/** User data of Light LC Setup Server Model */ +typedef struct { + esp_ble_mesh_model_t *model; /*!< Pointer to the Lighting LC 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_light_control_t *lc; /*!< Parameters of the Light controller */ +} esp_ble_mesh_light_lc_setup_srv_t; + +/** Parameter of Light Lightness Actual state change event */ +typedef struct { + uint16_t lightness; /*!< The value of Light Lightness Actual state */ +} esp_ble_mesh_state_change_light_lightness_set_t; + +/** Parameter of Light Lightness Linear state change event */ +typedef struct { + uint16_t lightness; /*!< The value of Light Lightness Linear state */ +} esp_ble_mesh_state_change_light_lightness_linear_set_t; + +/** Parameter of Light Lightness Default state change event */ +typedef struct { + uint16_t lightness; /*!< The value of Light Lightness Default state */ +} esp_ble_mesh_state_change_light_lightness_default_set_t; + +/** Parameters of Light Lightness Range state change event */ +typedef struct { + uint16_t range_min; /*!< The minimum value of Light Lightness Range state */ + uint16_t range_max; /*!< The maximum value of Light Lightness Range state */ +} esp_ble_mesh_state_change_light_lightness_range_set_t; + +/** Parameters of Light CTL state change event */ +typedef struct { + uint16_t lightness; /*!< The value of Light CTL Lightness state */ + uint16_t temperature; /*!< The value of Light CTL Temperature state */ + int16_t delta_uv; /*!< The value of Light CTL Delta UV state */ +} esp_ble_mesh_state_change_light_ctl_set_t; + +/** Parameters of Light CTL Temperature state change event */ +typedef struct { + uint16_t temperature; /*!< The value of Light CTL Temperature state */ + int16_t delta_uv; /*!< The value of Light CTL Delta UV state */ +} esp_ble_mesh_state_change_light_ctl_temperature_set_t; + +/** Parameters of Light CTL Temperature Range state change event */ +typedef struct { + uint16_t range_min; /*!< The minimum value of Light CTL Temperature Range state */ + uint16_t range_max; /*!< The maximum value of Light CTL Temperature Range state */ +} esp_ble_mesh_state_change_light_ctl_temperature_range_set_t; + +/** Parameters of Light CTL Default state change event */ +typedef struct { + uint16_t lightness; /*!< The value of Light Lightness Default state */ + uint16_t temperature; /*!< The value of Light CTL Temperature Default state */ + int16_t delta_uv; /*!< The value of Light CTL Delta UV Default state */ +} esp_ble_mesh_state_change_light_ctl_default_set_t; + +/** Parameters of Light HSL state change event */ +typedef struct { + uint16_t lightness; /*!< The value of Light HSL Lightness state */ + uint16_t hue; /*!< The value of Light HSL Hue state */ + uint16_t saturation; /*!< The value of Light HSL Saturation state */ +} esp_ble_mesh_state_change_light_hsl_set_t; + +/** Parameter of Light HSL Hue state change event */ +typedef struct { + uint16_t hue; /*!< The value of Light HSL Hue state */ +} esp_ble_mesh_state_change_light_hsl_hue_set_t; + +/** Parameter of Light HSL Saturation state change event */ +typedef struct { + uint16_t saturation; /*!< The value of Light HSL Saturation state */ +} esp_ble_mesh_state_change_light_hsl_saturation_set_t; + +/** Parameters of Light HSL Default state change event */ +typedef struct { + uint16_t lightness; /*!< The value of Light HSL Lightness Default state */ + uint16_t hue; /*!< The value of Light HSL Hue Default state */ + uint16_t saturation; /*!< The value of Light HSL Saturation Default state */ +} esp_ble_mesh_state_change_light_hsl_default_set_t; + +/** Parameters of Light HSL Range state change event */ +typedef struct { + uint16_t hue_range_min; /*!< The minimum hue value of Light HSL Range state */ + uint16_t hue_range_max; /*!< The maximum hue value of Light HSL Range state */ + uint16_t saturation_range_min; /*!< The minimum saturation value of Light HSL Range state */ + uint16_t saturation_range_max; /*!< The maximum saturation value of Light HSL Range state */ +} esp_ble_mesh_state_change_light_hsl_range_set_t; + +/** Parameters of Light xyL state change event */ +typedef struct { + uint16_t lightness; /*!< The value of Light xyL Lightness state */ + uint16_t x; /*!< The value of Light xyL x state */ + uint16_t y; /*!< The value of Light xyL y state */ +} esp_ble_mesh_state_change_light_xyl_set_t; + +/** Parameters of Light xyL Default state change event */ +typedef struct { + uint16_t lightness; /*!< The value of Light Lightness Default state */ + uint16_t x; /*!< The value of Light xyL x Default state */ + uint16_t y; /*!< The value of Light xyL y Default state */ +} esp_ble_mesh_state_change_light_xyl_default_set_t; + +/** Parameters of Light xyL Range state change event */ +typedef struct { + uint16_t x_range_min; /*!< The minimum value of Light xyL x Range state */ + uint16_t x_range_max; /*!< The maximum value of Light xyL x Range state */ + uint16_t y_range_min; /*!< The minimum value of Light xyL y Range state */ + uint16_t y_range_max; /*!< The maximum value of Light xyL y Range state */ +} esp_ble_mesh_state_change_light_xyl_range_set_t; + +/** Parameter of Light LC Mode state change event */ +typedef struct { + uint8_t mode; /*!< The value of Light LC Mode state */ +} esp_ble_mesh_state_change_light_lc_mode_set_t; + +/** Parameter of Light LC Occupancy Mode state change event */ +typedef struct { + uint8_t mode; /*!< The value of Light LC Occupancy Mode state */ +} esp_ble_mesh_state_change_light_lc_om_set_t; + +/** Parameter of Light LC Light OnOff state change event */ +typedef struct { + uint8_t onoff; /*!< The value of Light LC Light OnOff state */ +} esp_ble_mesh_state_change_light_lc_light_onoff_set_t; + +/** Parameters of Light LC Property state change event */ +typedef struct { + uint16_t property_id; /*!< The property id of Light LC Property state */ + struct net_buf_simple *property_value; /*!< The property value of Light LC Property state */ +} esp_ble_mesh_state_change_light_lc_property_set_t; + +/** Parameters of Sensor Status state change event */ +typedef struct { + uint16_t property_id; /*!< The value of Sensor Property ID */ + /** Parameters of Sensor Status related state */ + union { + uint8_t occupancy; /*!< The value of Light LC Occupancy state */ + uint32_t set_occupancy_to_1_delay; /*!< The value of Light LC Set Occupancy to 1 Delay state */ + uint32_t ambient_luxlevel; /*!< The value of Light LC Ambient Luxlevel state */ + } state; +} esp_ble_mesh_state_change_sensor_status_t; + +/** + * @brief Lighting 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_light_lightness_set_t lightness_set; /*!< Light Lightness Set */ + esp_ble_mesh_state_change_light_lightness_linear_set_t lightness_linear_set; /*!< Light Lightness Linear Set */ + esp_ble_mesh_state_change_light_lightness_default_set_t lightness_default_set; /*!< Light Lightness Default Set */ + esp_ble_mesh_state_change_light_lightness_range_set_t lightness_range_set; /*!< Light Lightness Range Set */ + esp_ble_mesh_state_change_light_ctl_set_t ctl_set; /*!< Light CTL Set */ + esp_ble_mesh_state_change_light_ctl_temperature_set_t ctl_temp_set; /*!< Light CTL Temperature Set */ + esp_ble_mesh_state_change_light_ctl_temperature_range_set_t ctl_temp_range_set; /*!< Light CTL Temperature Range Set */ + esp_ble_mesh_state_change_light_ctl_default_set_t ctl_default_set; /*!< Light CTL Default Set */ + esp_ble_mesh_state_change_light_hsl_set_t hsl_set; /*!< Light HSL Set */ + esp_ble_mesh_state_change_light_hsl_hue_set_t hsl_hue_set; /*!< Light HSL Hue Set */ + esp_ble_mesh_state_change_light_hsl_saturation_set_t hsl_saturation_set; /*!< Light HSL Saturation Set */ + esp_ble_mesh_state_change_light_hsl_default_set_t hsl_default_set; /*!< Light HSL Default Set */ + esp_ble_mesh_state_change_light_hsl_range_set_t hsl_range_set; /*!< Light HSL Range Set */ + esp_ble_mesh_state_change_light_xyl_set_t xyl_set; /*!< Light xyL Set */ + esp_ble_mesh_state_change_light_xyl_default_set_t xyl_default_set; /*!< Light xyL Default Set */ + esp_ble_mesh_state_change_light_xyl_range_set_t xyl_range_set; /*!< Light xyL Range Set */ + esp_ble_mesh_state_change_light_lc_mode_set_t lc_mode_set; /*!< Light LC Mode Set */ + esp_ble_mesh_state_change_light_lc_om_set_t lc_om_set; /*!< Light LC Occupancy Mode Set */ + esp_ble_mesh_state_change_light_lc_light_onoff_set_t lc_light_onoff_set; /*!< Light LC Light OnOff Set */ + esp_ble_mesh_state_change_light_lc_property_set_t lc_property_set; /*!< Light LC Property Set */ + esp_ble_mesh_state_change_sensor_status_t sensor_status; /*!< Sensor Status */ +} esp_ble_mesh_lighting_server_state_change_t; + +/** Context of the received Light LC Property Get message */ +typedef struct { + uint16_t property_id; /*!< Property ID identifying a Light LC Property */ +} esp_ble_mesh_server_recv_light_lc_property_get_t; + +/** + * @brief Lighting Server Model received get message union + */ +typedef union { + esp_ble_mesh_server_recv_light_lc_property_get_t lc_property; /*!< Light LC Property Get */ +} esp_ble_mesh_lighting_server_recv_get_msg_t; + +/** Context of the received Light Lightness Set message */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t lightness; /*!< Target value of light lightness 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_light_lightness_set_t; + +/** Context of the received Light Lightness Linear Set message */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t lightness; /*!< Target value of light lightness linear 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_light_lightness_linear_set_t; + +/** Context of the received Light Lightness Default Set message */ +typedef struct { + uint16_t lightness; /*!< The value of the Light Lightness Default state */ +} esp_ble_mesh_server_recv_light_lightness_default_set_t; + +/** Context of the received Light Lightness Range Set message */ +typedef struct { + uint16_t range_min; /*!< Value of range min field of light lightness range state */ + uint16_t range_max; /*!< Value of range max field of light lightness range state */ +} esp_ble_mesh_server_recv_light_lightness_range_set_t; + +/** Context of the received Light CTL Set message */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t lightness; /*!< Target value of light ctl lightness state */ + uint16_t temperature; /*!< Target value of light ctl temperature state */ + int16_t delta_uv; /*!< Target value of light ctl delta UV 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_light_ctl_set_t; + +/** Context of the received Light CTL Temperature Set message */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t temperature; /*!< Target value of light ctl temperature state */ + int16_t delta_uv; /*!< Target value of light ctl delta UV 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_light_ctl_temperature_set_t; + +/** Context of the received Light CTL Temperature Range Set message */ +typedef struct { + uint16_t range_min; /*!< Value of temperature range min field of light ctl temperature range state */ + uint16_t range_max; /*!< Value of temperature range max field of light ctl temperature range state */ +} esp_ble_mesh_server_recv_light_ctl_temperature_range_set_t; + +/** Context of the received Light CTL Default Set message */ +typedef struct { + uint16_t lightness; /*!< Value of light lightness default state */ + uint16_t temperature; /*!< Value of light temperature default state */ + int16_t delta_uv; /*!< Value of light delta UV default state */ +} esp_ble_mesh_server_recv_light_ctl_default_set_t; + +/** Context of the received Light HSL Set message */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t lightness; /*!< Target value of light hsl lightness state */ + uint16_t hue; /*!< Target value of light hsl hue state */ + uint16_t saturation; /*!< Target value of light hsl saturation 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_light_hsl_set_t; + +/** Context of the received Light HSL Hue Set message */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t hue; /*!< Target value of light hsl hue 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_light_hsl_hue_set_t; + +/** Context of the received Light HSL Saturation Set message */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t saturation; /*!< Target value of light hsl hue 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_light_hsl_saturation_set_t; + +/** Context of the received Light HSL Default Set message */ +typedef struct { + uint16_t lightness; /*!< Value of light lightness default state */ + uint16_t hue; /*!< Value of light hue default state */ + uint16_t saturation; /*!< Value of light saturation default state */ +} esp_ble_mesh_server_recv_light_hsl_default_set_t; + +/** Context of the received Light HSL Range Set message */ +typedef struct { + uint16_t hue_range_min; /*!< Value of hue range min field of light hsl hue range state */ + uint16_t hue_range_max; /*!< Value of hue range max field of light hsl hue range state */ + uint16_t saturation_range_min; /*!< Value of saturation range min field of light hsl saturation range state */ + uint16_t saturation_range_max; /*!< Value of saturation range max field of light hsl saturation range state */ +} esp_ble_mesh_server_recv_light_hsl_range_set_t; + +/** Context of the received Light xyL Set message */ +typedef struct { + bool op_en; /*!< Indicate whether optional parameters included */ + uint16_t lightness; /*!< The target value of the Light xyL Lightness state */ + uint16_t x; /*!< The target value of the Light xyL x state */ + uint16_t y; /*!< The target value of the Light xyL y state */ + uint8_t tid; /*!< Transaction Identifier */ + uint8_t trans_time; /*!< Time to complete state transition (optional) */ + uint8_t delay; /*!< Indicate message execution delay (C.1) */ +} esp_ble_mesh_server_recv_light_xyl_set_t; + +/** Context of the received Light xyL Default Set message */ +typedef struct { + uint16_t lightness; /*!< The value of the Light Lightness Default state */ + uint16_t x; /*!< The value of the Light xyL x Default state */ + uint16_t y; /*!< The value of the Light xyL y Default state */ +} esp_ble_mesh_server_recv_light_xyl_default_set_t; + +/** Context of the received Light xyl Range Set message */ +typedef struct { + uint16_t x_range_min; /*!< The value of the xyL x Range Min field of the Light xyL x Range state */ + uint16_t x_range_max; /*!< The value of the xyL x Range Max field of the Light xyL x Range state */ + uint16_t y_range_min; /*!< The value of the xyL y Range Min field of the Light xyL y Range state */ + uint16_t y_range_max; /*!< The value of the xyL y Range Max field of the Light xyL y Range state */ +} esp_ble_mesh_server_recv_light_xyl_range_set_t; + +/** Context of the received Light LC Mode Set message */ +typedef struct { + uint8_t mode; /*!< The target value of the Light LC Mode state */ +} esp_ble_mesh_server_recv_light_lc_mode_set_t; + +/** Context of the received Light OM Set message */ +typedef struct { + uint8_t mode; /*!< The target value of the Light LC Occupancy Mode state */ +} esp_ble_mesh_server_recv_light_lc_om_set_t; + +/** Context of the received Light LC Light OnOff Set message */ +typedef struct { + bool op_en; /*!< Indicate whether optional parameters included */ + uint8_t light_onoff; /*!< The target value of the Light LC Light OnOff state */ + uint8_t tid; /*!< Transaction Identifier */ + uint8_t trans_time; /*!< Time to complete state transition (optional) */ + uint8_t delay; /*!< Indicate message execution delay (C.1) */ +} esp_ble_mesh_server_recv_light_lc_light_onoff_set_t; + +/** Context of the received Light LC Property Set message */ +typedef struct { + uint16_t property_id; /*!< Property ID identifying a Light LC Property */ + struct net_buf_simple *property_value; /*!< Raw value for the Light LC Property */ +} esp_ble_mesh_server_recv_light_lc_property_set_t; + +/** + * @brief Lighting Server Model received set message union + */ +typedef union { + esp_ble_mesh_server_recv_light_lightness_set_t lightness; /*!< Light Lightness Set/Light Lightness Set Unack */ + esp_ble_mesh_server_recv_light_lightness_linear_set_t lightness_linear; /*!< Light Lightness Linear Set/Light Lightness Linear Set Unack */ + esp_ble_mesh_server_recv_light_lightness_default_set_t lightness_default; /*!< Light Lightness Default Set/Light Lightness Default Set Unack */ + esp_ble_mesh_server_recv_light_lightness_range_set_t lightness_range; /*!< Light Lightness Range Set/Light Lightness Range Set Unack */ + esp_ble_mesh_server_recv_light_ctl_set_t ctl; /*!< Light CTL Set/Light CTL Set Unack */ + esp_ble_mesh_server_recv_light_ctl_temperature_set_t ctl_temp; /*!< Light CTL Temperature Set/Light CTL Temperature Set Unack */ + esp_ble_mesh_server_recv_light_ctl_temperature_range_set_t ctl_temp_range; /*!< Light CTL Temperature Range Set/Light CTL Temperature Range Set Unack */ + esp_ble_mesh_server_recv_light_ctl_default_set_t ctl_default; /*!< Light CTL Default Set/Light CTL Default Set Unack */ + esp_ble_mesh_server_recv_light_hsl_set_t hsl; /*!< Light HSL Set/Light HSL Set Unack */ + esp_ble_mesh_server_recv_light_hsl_hue_set_t hsl_hue; /*!< Light HSL Hue Set/Light HSL Hue Set Unack */ + esp_ble_mesh_server_recv_light_hsl_saturation_set_t hsl_saturation; /*!< Light HSL Saturation Set/Light HSL Saturation Set Unack */ + esp_ble_mesh_server_recv_light_hsl_default_set_t hsl_default; /*!< Light HSL Default Set/Light HSL Default Set Unack */ + esp_ble_mesh_server_recv_light_hsl_range_set_t hsl_range; /*!< Light HSL Range Set/Light HSL Range Set Unack */ + esp_ble_mesh_server_recv_light_xyl_set_t xyl; /*!< Light xyL Set/Light xyL Set Unack */ + esp_ble_mesh_server_recv_light_xyl_default_set_t xyl_default; /*!< Light xyL Default Set/Light xyL Default Set Unack */ + esp_ble_mesh_server_recv_light_xyl_range_set_t xyl_range; /*!< Light xyL Range Set/Light xyL Range Set Unack */ + esp_ble_mesh_server_recv_light_lc_mode_set_t lc_mode; /*!< Light LC Mode Set/Light LC Mode Set Unack */ + esp_ble_mesh_server_recv_light_lc_om_set_t lc_om; /*!< Light LC OM Set/Light LC OM Set Unack */ + esp_ble_mesh_server_recv_light_lc_light_onoff_set_t lc_light_onoff; /*!< Light LC Light OnOff Set/Light LC Light OnOff Set Unack */ + esp_ble_mesh_server_recv_light_lc_property_set_t lc_property; /*!< Light LC Property Set/Light LC Property Set Unack */ +} esp_ble_mesh_lighting_server_recv_set_msg_t; + +/** Context of the received Sensor Status message */ +typedef struct { + struct net_buf_simple *data; /*!< Value of sensor data state (optional) */ +} esp_ble_mesh_server_recv_sensor_status_t; + +/** + * @brief Lighting Server Model received status message union + */ +typedef union { + esp_ble_mesh_server_recv_sensor_status_t sensor_status; /*!< Sensor Status */ +} esp_ble_mesh_lighting_server_recv_status_msg_t; + +/** + * @brief Lighting Server Model callback value union + */ +typedef union { + esp_ble_mesh_lighting_server_state_change_t state_change; /*!< ESP_BLE_MESH_LIGHTING_SERVER_STATE_CHANGE_EVT */ + esp_ble_mesh_lighting_server_recv_get_msg_t get; /*!< ESP_BLE_MESH_LIGHTING_SERVER_RECV_GET_MSG_EVT */ + esp_ble_mesh_lighting_server_recv_set_msg_t set; /*!< ESP_BLE_MESH_LIGHTING_SERVER_RECV_SET_MSG_EVT */ + esp_ble_mesh_lighting_server_recv_status_msg_t status; /*!< ESP_BLE_MESH_LIGHTING_SERVER_RECV_STATUS_MSG_EVT */ +} esp_ble_mesh_lighting_server_cb_value_t; + +/** Lighting Server Model callback parameters */ +typedef struct { + esp_ble_mesh_model_t *model; /*!< Pointer to Lighting Server Models */ + esp_ble_mesh_msg_ctx_t ctx; /*!< Context of the received messages */ + esp_ble_mesh_lighting_server_cb_value_t value; /*!< Value of the received Lighting Messages */ +} esp_ble_mesh_lighting_server_cb_param_t; + +/** This enum value is the event of Lighting 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 Lighting 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 Lighting Set/Set Unack messages + * are received. + */ + ESP_BLE_MESH_LIGHTING_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 Lighting Get messages are received. + */ + ESP_BLE_MESH_LIGHTING_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 Lighting Set/Set Unack messages are received. + */ + ESP_BLE_MESH_LIGHTING_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 Sensor Status message is received. + */ + ESP_BLE_MESH_LIGHTING_SERVER_RECV_STATUS_MSG_EVT, + ESP_BLE_MESH_LIGHTING_SERVER_EVT_MAX, +} esp_ble_mesh_lighting_server_cb_event_t; + +/** + * @brief Bluetooth Mesh Lighting Server Model function. + */ + +/** + * @brief Lighting Server Model callback function type + * @param event: Event type + * @param param: Pointer to callback parameter + */ +typedef void (* esp_ble_mesh_lighting_server_cb_t)(esp_ble_mesh_lighting_server_cb_event_t event, + esp_ble_mesh_lighting_server_cb_param_t *param); + +/** + * @brief Register BLE Mesh Lighting 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_lighting_server_callback(esp_ble_mesh_lighting_server_cb_t callback); + +#ifdef __cplusplus +} +#endif + +#endif /* _ESP_BLE_MESH_LIGHTING_MODEL_API_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_sensor_model_api.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_sensor_model_api.h new file mode 100644 index 00000000000..4f051a0b265 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_sensor_model_api.h @@ -0,0 +1,709 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** @file + * @brief Bluetooth Mesh Sensor Client Model APIs. + */ + +#ifndef _ESP_BLE_MESH_SENSOR_MODEL_API_H_ +#define _ESP_BLE_MESH_SENSOR_MODEL_API_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. + * + * @note This API needs to be called for each element on which + * the application needs to have a Sensor Client Model. + * + * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t. + * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t. + * + * @return New Sensor Client Model instance. + */ +#define ESP_BLE_MESH_MODEL_SENSOR_CLI(cli_pub, cli_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SENSOR_CLI, \ + NULL, cli_pub, cli_data) + +/** + * @brief Bluetooth Mesh Sensor Client Model Get and Set parameters structure. + */ + +/** Parameters of Sensor Descriptor Get */ +typedef struct { + bool op_en; /*!< Indicate if optional parameters are included */ + uint16_t property_id; /*!< Property ID of a sensor (optional) */ +} esp_ble_mesh_sensor_descriptor_get_t; + +/** Parameter of Sensor Cadence Get */ +typedef struct { + uint16_t property_id; /*!< Property ID of a sensor */ +} esp_ble_mesh_sensor_cadence_get_t; + +/** Parameters of Sensor Cadence Set */ +typedef struct { + 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 */ + 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 { + uint16_t sensor_property_id; /*!< Property ID of a sensor */ +} esp_ble_mesh_sensor_settings_get_t; + +/** Parameters of Sensor Setting Get */ +typedef struct { + 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 { + 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 */ + uint16_t property_id; /*!< Property ID for the sensor (optional) */ +} esp_ble_mesh_sensor_get_t; + +/** Parameters of Sensor Column Get */ +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_sensor_column_get_t; + +/** Parameters of Sensor Series Get */ +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_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; + +/** + * @brief Sensor Client Model get message union + */ +typedef union { + esp_ble_mesh_sensor_descriptor_get_t descriptor_get; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_GET */ + esp_ble_mesh_sensor_cadence_get_t cadence_get; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_GET */ + esp_ble_mesh_sensor_settings_get_t settings_get; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_SETTINGS_GET */ + esp_ble_mesh_sensor_setting_get_t setting_get; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_GET */ + esp_ble_mesh_sensor_get_t sensor_get; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_GET */ + esp_ble_mesh_sensor_column_get_t column_get; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_COLUMN_GET */ + esp_ble_mesh_sensor_series_get_t series_get; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_SERIES_GET */ +} esp_ble_mesh_sensor_client_get_state_t; + +/** + * @brief Sensor Client Model set message union + */ +typedef union { + esp_ble_mesh_sensor_cadence_set_t cadence_set; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET & ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET_UNACK */ + esp_ble_mesh_sensor_setting_set_t setting_set; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET & ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET_UNACK */ +} esp_ble_mesh_sensor_client_set_state_t; + +/** + * @brief Bluetooth Mesh Sensor Client Model Get and Set callback parameters structure. + */ + +/** Parameter of Sensor Descriptor Status */ +typedef struct { + struct net_buf_simple *descriptor; /*!< Sequence of 8-octet sensor descriptors (optional) */ +} esp_ble_mesh_sensor_descriptor_status_cb_t; + +/** Parameters of Sensor Cadence Status */ +typedef struct { + 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 { + 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 */ + 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; + +/** Parameter of Sensor Status */ +typedef struct { + struct net_buf_simple *marshalled_sensor_data; /*!< Value of sensor data state (optional) */ +} esp_ble_mesh_sensor_status_cb_t; + +/** Parameters of Sensor Column Status */ +typedef struct { + 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 { + 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; + +/** + * @brief Sensor Client Model received message union + */ +typedef union { + esp_ble_mesh_sensor_descriptor_status_cb_t descriptor_status; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_STATUS */ + esp_ble_mesh_sensor_cadence_status_cb_t cadence_status; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_STATUS */ + esp_ble_mesh_sensor_settings_status_cb_t settings_status; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_SETTINGS_STATUS */ + esp_ble_mesh_sensor_setting_status_cb_t setting_status; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_STATUS */ + esp_ble_mesh_sensor_status_cb_t sensor_status; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_STATUS */ + esp_ble_mesh_sensor_column_status_cb_t column_status; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_COLUMN_STATUS */ + esp_ble_mesh_sensor_series_status_cb_t series_status; /*!< For ESP_BLE_MESH_MODEL_OP_SENSOR_SERIES_STATUS */ +} esp_ble_mesh_sensor_client_status_cb_t; + +/** Sensor Client Model callback parameters */ +typedef struct { + int error_code; /*!< 0: success, + * otherwise failure. For the error code values please refer to errno.h file. + * A negative sign is added to the standard error codes in errno.h. */ + esp_ble_mesh_client_common_param_t *params; /*!< The client common parameters. */ + esp_ble_mesh_sensor_client_status_cb_t status_cb; /*!< The sensor status message callback values */ +} esp_ble_mesh_sensor_client_cb_param_t; + +/** This enum value is the event of Sensor Client Model */ +typedef enum { + ESP_BLE_MESH_SENSOR_CLIENT_GET_STATE_EVT, + ESP_BLE_MESH_SENSOR_CLIENT_SET_STATE_EVT, + ESP_BLE_MESH_SENSOR_CLIENT_PUBLISH_EVT, + ESP_BLE_MESH_SENSOR_CLIENT_TIMEOUT_EVT, + ESP_BLE_MESH_SENSOR_CLIENT_EVT_MAX, +} esp_ble_mesh_sensor_client_cb_event_t; + +/** + * @brief Bluetooth Mesh Sensor Client Model function. + */ + +/** + * @brief Sensor Client Model callback function type + * @param event: Event type + * @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); + +/** + * @brief Register BLE Mesh Sensor Client 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_client_callback(esp_ble_mesh_sensor_client_cb_t callback); + +/** + * @brief Get the value of Sensor Server Model states using the Sensor Client Model get messages. + * + * @note If you want to know the opcodes and corresponding meanings accepted by this API, + * please refer to esp_ble_mesh_sensor_message_opcode_t in esp_ble_mesh_defs.h + * + * @param[in] params: Pointer to BLE Mesh common client parameters. + * @param[in] get_state: Pointer to sensor get message value. + * Shall not be set to NULL. + * + * @return ESP_OK on success or error code otherwise. + * + */ +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); + +/** + * @brief Set the value of Sensor Server Model states using the Sensor Client Model set messages. + * + * @note If you want to know the opcodes and corresponding meanings accepted by this API, + * please refer to esp_ble_mesh_sensor_message_opcode_t in esp_ble_mesh_defs.h + * + * @param[in] params: Pointer to BLE Mesh common client parameters. + * @param[in] set_state: Pointer to sensor set message value. + * Shall not be set to NULL. + * + * @return ESP_OK on success or error code otherwise. + * + */ +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); + +/** + * @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 0x0–0x7F, + * representing range of 1–127). 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 0x0–0xF, + * representing range of 1–16). + * 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 0x0–0x7F, representing + * range of 1–127). 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 0x0–0xF, + * representing range of 1 – 16). + * Format B: The Length field is a 1-based uint7 value (valid range 0x0–0x7F, + * 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_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_time_scene_model_api.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_time_scene_model_api.h new file mode 100644 index 00000000000..07e5a5ba017 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_time_scene_model_api.h @@ -0,0 +1,911 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** @file + * @brief Bluetooth Mesh Time and Scene Client Model APIs. + */ + +#ifndef _ESP_BLE_MESH_TIME_SCENE_MODEL_API_H_ +#define _ESP_BLE_MESH_TIME_SCENE_MODEL_API_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. + * + * @note This API needs to be called for each element on which + * the application needs to have a Time Client Model. + * + * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t. + * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t. + * + * @return New Time Client Model instance. + */ +#define ESP_BLE_MESH_MODEL_TIME_CLI(cli_pub, cli_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_TIME_CLI, \ + NULL, cli_pub, cli_data) + +/** @def ESP_BLE_MESH_MODEL_SCENE_CLI + * + * @brief Define a new Scene Client Model. + * + * @note This API needs to be called for each element on which + * the application needs to have a Scene Client Model. + * + * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t. + * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t. + * + * @return New Scene Client Model instance. + */ +#define ESP_BLE_MESH_MODEL_SCENE_CLI(cli_pub, cli_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SCENE_CLI, \ + NULL, cli_pub, cli_data) + +/** @def ESP_BLE_MESH_MODEL_SCHEDULER_CLI + * + * @brief Define a new Scheduler Client Model. + * + * @note This API needs to be called for each element on which + * the application needs to have a Scheduler Client Model. + * + * @param cli_pub Pointer to the unique struct esp_ble_mesh_model_pub_t. + * @param cli_data Pointer to the unique struct esp_ble_mesh_client_t. + * + * @return New Scheduler Client Model instance. + */ +#define ESP_BLE_MESH_MODEL_SCHEDULER_CLI(cli_pub, cli_data) \ + ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SCHEDULER_CLI, \ + NULL, cli_pub, cli_data) + +/** + * @brief Bluetooth Mesh Time Scene Client Model Get and Set parameters structure. + */ + +/** Parameters of Time Set */ +typedef struct { + 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 { + 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 { + 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 { + uint8_t time_role; /*!< The Time Role for the element */ +} esp_ble_mesh_time_role_set_t; + +/** Parameter of Scene Store */ +typedef struct { + 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 */ + 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 { + uint16_t scene_number; /*!< The number of scenes to be deleted */ +} esp_ble_mesh_scene_delete_t; + +/** Parameter of Scheduler Action Get */ +typedef struct { + 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 { + 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; + +/** + * @brief Time Scene Client Model get message union + */ +typedef union { + esp_ble_mesh_scheduler_act_get_t scheduler_act_get; /*!< For ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_GET */ +} esp_ble_mesh_time_scene_client_get_state_t; + +/** + * @brief Time Scene Client Model set message union + */ +typedef union { + esp_ble_mesh_time_set_t time_set; /*!< For ESP_BLE_MESH_MODEL_OP_TIME_SET */ + esp_ble_mesh_time_zone_set_t time_zone_set; /*!< For ESP_BLE_MESH_MODEL_OP_TIME_ZONE_SET */ + esp_ble_mesh_tai_utc_delta_set_t tai_utc_delta_set; /*!< For ESP_BLE_MESH_MODEL_OP_TAI_UTC_DELTA_SET */ + esp_ble_mesh_time_role_set_t time_role_set; /*!< For ESP_BLE_MESH_MODEL_OP_TIME_ROLE_SET */ + esp_ble_mesh_scene_store_t scene_store; /*!< For ESP_BLE_MESH_MODEL_OP_SCENE_STORE & ESP_BLE_MESH_MODEL_OP_SCENE_STORE_UNACK */ + esp_ble_mesh_scene_recall_t scene_recall; /*!< For ESP_BLE_MESH_MODEL_OP_SCENE_RECALL & ESP_BLE_MESH_MODEL_OP_SCENE_RECALL_UNACK */ + esp_ble_mesh_scene_delete_t scene_delete; /*!< For ESP_BLE_MESH_MODEL_OP_SCENE_DELETE & ESP_BLE_MESH_MODEL_OP_SCENE_DELETE_UNACK */ + esp_ble_mesh_scheduler_act_set_t scheduler_act_set; /*!< For ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_SET & ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_SET_UNACK */ +} esp_ble_mesh_time_scene_client_set_state_t; + +/** + * @brief Bluetooth Mesh Time Scene Client Model Get and Set callback parameters structure. + */ + +/** Parameters of Time Status */ +typedef struct { + 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 { + 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 { + 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 { + 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 */ + 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 { + 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 { + 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 { + 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; + +/** + * @brief Time Scene Client Model received message union + */ +typedef union { + esp_ble_mesh_time_status_cb_t time_status; /*!< For ESP_BLE_MESH_MODEL_OP_TIME_STATUS */ + esp_ble_mesh_time_zone_status_cb_t time_zone_status; /*!< For ESP_BLE_MESH_MODEL_OP_TIME_ZONE_STATUS */ + esp_ble_mesh_tai_utc_delta_status_cb_t tai_utc_delta_status; /*!< For ESP_BLE_MESH_MODEL_OP_TAI_UTC_DELTA_STATUS */ + esp_ble_mesh_time_role_status_cb_t time_role_status; /*!< For ESP_BLE_MESH_MODEL_OP_TIME_ROLE_STATUS */ + esp_ble_mesh_scene_status_cb_t scene_status; /*!< For ESP_BLE_MESH_MODEL_OP_SCENE_STATUS */ + esp_ble_mesh_scene_register_status_cb_t scene_register_status; /*!< For ESP_BLE_MESH_MODEL_OP_SCENE_REGISTER_STATUS */ + esp_ble_mesh_scheduler_status_cb_t scheduler_status; /*!< For ESP_BLE_MESH_MODEL_OP_SCHEDULER_STATUS */ + esp_ble_mesh_scheduler_act_status_cb_t scheduler_act_status; /*!< For ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_STATUS */ +} esp_ble_mesh_time_scene_client_status_cb_t; + +/** Time Scene Client Model callback parameters */ +typedef struct { + int error_code; /*!< Appropriate error code */ + esp_ble_mesh_client_common_param_t *params; /*!< The client common parameters. */ + esp_ble_mesh_time_scene_client_status_cb_t status_cb; /*!< The scene status message callback values */ +} esp_ble_mesh_time_scene_client_cb_param_t; + +/** This enum value is the event of Time Scene Client Model */ +typedef enum { + ESP_BLE_MESH_TIME_SCENE_CLIENT_GET_STATE_EVT, + ESP_BLE_MESH_TIME_SCENE_CLIENT_SET_STATE_EVT, + ESP_BLE_MESH_TIME_SCENE_CLIENT_PUBLISH_EVT, + ESP_BLE_MESH_TIME_SCENE_CLIENT_TIMEOUT_EVT, + ESP_BLE_MESH_TIME_SCENE_CLIENT_EVT_MAX, +} esp_ble_mesh_time_scene_client_cb_event_t; + +/** + * @brief Bluetooth Mesh Time Scene Client Model function. + */ + +/** + * @brief Time Scene Client Model callback function type + * @param event: Event type + * @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); + +/** + * @brief Register BLE Mesh Time Scene Client 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_client_callback(esp_ble_mesh_time_scene_client_cb_t callback); + +/** + * @brief Get the value of Time Scene Server Model states using the Time Scene Client Model get messages. + * + * @note If you want to know the opcodes and corresponding meanings accepted by this API, + * please refer to esp_ble_mesh_time_scene_message_opcode_t in esp_ble_mesh_defs.h + * + * @param[in] params: Pointer to BLE Mesh common client parameters. + * @param[in] get_state: Pointer to time scene get message value. + * Shall not be set to NULL. + * + * @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); + +/** + * @brief Set the value of Time Scene Server Model states using the Time Scene Client Model set messages. + * + * @note If you want to know the opcodes and corresponding meanings accepted by this API, + * please refer to esp_ble_mesh_time_scene_message_opcode_t in esp_ble_mesh_defs.h + * + * @param[in] params: Pointer to BLE Mesh common client parameters. + * @param[in] set_state: Pointer to time scene set message value. + * Shall not be set to NULL. + * + * @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); + +/** + * @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_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_ble.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_ble.h new file mode 100644 index 00000000000..854ca96522d --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_ble.h @@ -0,0 +1,54 @@ +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _BTC_BLE_MESH_BLE_H_ +#define _BTC_BLE_MESH_BLE_H_ + +#include +#include "btc/btc_manage.h" +#include "mesh_bearer_adapt.h" +#include "esp_ble_mesh_ble_api.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef union { + struct { + esp_ble_mesh_ble_adv_param_t param; + esp_ble_mesh_ble_adv_data_t data; + } start_ble_adv; + struct { + uint8_t index; + } stop_ble_adv; + struct { + esp_ble_mesh_ble_scan_param_t param; + } start_ble_scan; + struct { + /* RFU */ + } stop_ble_scan; +} btc_ble_mesh_ble_args_t; + +typedef enum { + BTC_BLE_MESH_ACT_START_BLE_ADV, + BTC_BLE_MESH_ACT_STOP_BLE_ADV, + BTC_BLE_MESH_ACT_START_BLE_SCAN, + BTC_BLE_MESH_ACT_STOP_BLE_SCAN, +} btc_ble_mesh_ble_act_t; + +void bt_mesh_ble_scan_cb_evt_to_btc(const bt_mesh_addr_t *addr, + uint8_t adv_type, uint8_t data[], + uint16_t length, int8_t rssi); + +void btc_ble_mesh_ble_call_handler(btc_msg_t *msg); + +void btc_ble_mesh_ble_cb_handler(btc_msg_t *msg); + +#ifdef __cplusplus +} +#endif + +#endif /* _BTC_BLE_MESH_BLE_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_config_model.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_config_model.h new file mode 100644 index 00000000000..39ed1a5c1a4 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_config_model.h @@ -0,0 +1,72 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _BTC_BLE_MESH_CONFIG_MODEL_H_ +#define _BTC_BLE_MESH_CONFIG_MODEL_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_ACT_CONFIG_CLIENT_MAX, +} btc_ble_mesh_config_client_act_t; + +typedef union { + 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_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_config_client_args_t; + +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_ble_mesh_config_client_call_handler(btc_msg_t *msg); + +void btc_ble_mesh_config_client_cb_handler(btc_msg_t *msg); + +void btc_ble_mesh_config_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src); + +void btc_ble_mesh_config_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf); + +void bt_mesh_config_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type, + struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + const uint8_t *val, size_t len); + +void btc_ble_mesh_config_server_cb_handler(btc_msg_t *msg); + +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_config_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + const uint8_t *val, size_t len); + +#ifdef __cplusplus +} +#endif + +#endif /* _BTC_BLE_MESH_CONFIG_MODEL_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_generic_model.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_generic_model.h new file mode 100644 index 00000000000..a5b586d5ab7 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_generic_model.h @@ -0,0 +1,74 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _BTC_BLE_MESH_GENERIC_MODEL_H_ +#define _BTC_BLE_MESH_GENERIC_MODEL_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 { + struct ble_mesh_generic_client_get_state_reg_args { + esp_ble_mesh_client_common_param_t *params; + esp_ble_mesh_generic_client_get_state_t *get_state; + } generic_client_get_state; + struct ble_mesh_generic_client_set_state_reg_args { + esp_ble_mesh_client_common_param_t *params; + esp_ble_mesh_generic_client_set_state_t *set_state; + } generic_client_set_state; +} btc_ble_mesh_generic_client_args_t; + +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_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_ble_mesh_generic_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf); + +void bt_mesh_generic_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type, + struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + const uint8_t *val, size_t len); + +typedef enum { + BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE, + BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_GET_MSG, + BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_SET_MSG, + BTC_BLE_MESH_EVT_GENERIC_SERVER_MAX, +} btc_ble_mesh_generic_server_evt_t; + +void bt_mesh_generic_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + const uint8_t *val, size_t len); + +void btc_ble_mesh_generic_server_cb_handler(btc_msg_t *msg); + +#ifdef __cplusplus +} +#endif + +#endif /* _BTC_BLE_MESH_GENERIC_MODEL_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_health_model.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_health_model.h new file mode 100644 index 00000000000..331f41c23d6 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_health_model.h @@ -0,0 +1,87 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _BTC_BLE_MESH_HEALTH_MODEL_H_ +#define _BTC_BLE_MESH_HEALTH_MODEL_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 union { + struct ble_mesh_health_client_get_state_reg_args { + esp_ble_mesh_client_common_param_t *params; + esp_ble_mesh_health_client_get_state_t *get_state; + } health_client_get_state; + struct ble_mesh_health_client_set_state_reg_args { + esp_ble_mesh_client_common_param_t *params; + esp_ble_mesh_health_client_set_state_t *set_state; + } health_client_set_state; +} btc_ble_mesh_health_client_args_t; + +typedef enum { + BTC_BLE_MESH_EVT_HEALTH_CLIENT_GET_STATE, + BTC_BLE_MESH_EVT_HEALTH_CLIENT_SET_STATE, + BTC_BLE_MESH_EVT_HEALTH_CLIENT_PUBLISH, + BTC_BLE_MESH_EVT_HEALTH_CLIENT_TIMEOUT, + BTC_BLE_MESH_EVT_HEALTH_CLIENT_MAX, +} btc_ble_mesh_health_client_evt_t; + +void btc_ble_mesh_health_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src); + +void btc_ble_mesh_health_client_call_handler(btc_msg_t *msg); + +void btc_ble_mesh_health_client_cb_handler(btc_msg_t *msg); + +void btc_ble_mesh_health_publish_callback(uint32_t opcode, struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf); + +void bt_mesh_health_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type, + struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + const uint8_t *val, uint16_t len); + +typedef enum { + BTC_BLE_MESH_ACT_HEALTH_SERVER_FAULT_UPDATE, + BTC_BLE_MESH_ACT_HEALTH_SERVER_MAX, +} btc_ble_mesh_health_server_act_t; + +typedef union { + struct ble_mesh_health_server_fault_update_args { + esp_ble_mesh_elem_t *element; + } health_fault_update; +} btc_ble_mesh_health_server_args_t; + +void btc_ble_mesh_health_server_call_handler(btc_msg_t *msg); + +void btc_ble_mesh_health_server_cb_handler(btc_msg_t *msg); + +void btc_ble_mesh_health_server_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src); + +void btc_ble_mesh_health_server_fault_clear(struct bt_mesh_model *model, uint16_t company_id); + +void btc_ble_mesh_health_server_fault_test(struct bt_mesh_model *model, + uint8_t test_id, uint16_t company_id); + +void btc_ble_mesh_health_server_attention_on(struct bt_mesh_model *model, uint8_t time); + +void btc_ble_mesh_health_server_attention_off(struct bt_mesh_model *model); + +#ifdef __cplusplus +} +#endif + +#endif /* _BTC_BLE_MESH_HEALTH_MODEL_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_lighting_model.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_lighting_model.h new file mode 100644 index 00000000000..854d6521612 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_lighting_model.h @@ -0,0 +1,75 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _BTC_BLE_MESH_LIGHTING_MODEL_H_ +#define _BTC_BLE_MESH_LIGHTING_MODEL_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_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 { + esp_ble_mesh_client_common_param_t *params; + esp_ble_mesh_light_client_get_state_t *get_state; + } light_client_get_state; + struct ble_mesh_light_client_set_state_reg_args { + 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_lighting_client_args_t; + +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_ble_mesh_lighting_client_call_handler(btc_msg_t *msg); + +void btc_ble_mesh_lighting_client_cb_handler(btc_msg_t *msg); + +void btc_ble_mesh_lighting_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src); + +void btc_ble_mesh_lighting_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf); + +void bt_mesh_lighting_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type, + struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + const uint8_t *val, size_t len); + +typedef enum { + BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE, + BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_GET_MSG, + BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG, + BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_STATUS_MSG, + BTC_BLE_MESH_EVT_LIGHTING_SERVER_MAX, +} btc_ble_mesh_lighting_server_evt_t; + +void bt_mesh_lighting_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + const uint8_t *val, size_t len); + +void btc_ble_mesh_lighting_server_cb_handler(btc_msg_t *msg); + +#ifdef __cplusplus +} +#endif + +#endif /* _BTC_BLE_MESH_LIGHTING_MODEL_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_prov.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_prov.h new file mode 100644 index 00000000000..ab54cc487b8 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_prov.h @@ -0,0 +1,392 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _BTC_BLE_MESH_PROV_H_ +#define _BTC_BLE_MESH_PROV_H_ + +#include "btc/btc_manage.h" +#include "mesh_byteorder.h" +#include "mesh_config.h" +#include "mesh_main.h" +#include "fast_prov.h" +#include "provisioner_prov.h" +#include "esp_ble_mesh_defs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + BTC_BLE_MESH_ACT_MESH_INIT = 0, + BTC_BLE_MESH_ACT_PROV_ENABLE, + BTC_BLE_MESH_ACT_PROV_DISABLE, + BTC_BLE_MESH_ACT_NODE_RESET, + BTC_BLE_MESH_ACT_SET_OOB_PUB_KEY, + BTC_BLE_MESH_ACT_INPUT_NUMBER, + BTC_BLE_MESH_ACT_INPUT_STRING, + BTC_BLE_MESH_ACT_SET_DEVICE_NAME, + BTC_BLE_MESH_ACT_PROXY_IDENTITY_ENABLE, + BTC_BLE_MESH_ACT_PROXY_GATT_ENABLE, + BTC_BLE_MESH_ACT_PROXY_GATT_DISABLE, + BTC_BLE_MESH_ACT_NODE_ADD_LOCAL_NET_KEY, + BTC_BLE_MESH_ACT_NODE_ADD_LOCAL_APP_KEY, + BTC_BLE_MESH_ACT_NODE_BIND_APP_KEY_TO_MODEL, + BTC_BLE_MESH_ACT_PROVISIONER_READ_OOB_PUB_KEY, + BTC_BLE_MESH_ACT_PROVISIONER_INPUT_STR, + BTC_BLE_MESH_ACT_PROVISIONER_INPUT_NUM, + BTC_BLE_MESH_ACT_PROVISIONER_ENABLE, + BTC_BLE_MESH_ACT_PROVISIONER_DISABLE, + BTC_BLE_MESH_ACT_PROVISIONER_DEV_ADD, + BTC_BLE_MESH_ACT_PROVISIONER_PROV_DEV_WITH_ADDR, + BTC_BLE_MESH_ACT_PROVISIONER_DEV_DEL, + BTC_BLE_MESH_ACT_PROVISIONER_SET_DEV_UUID_MATCH, + BTC_BLE_MESH_ACT_PROVISIONER_SET_PROV_DATA_INFO, + BTC_BLE_MESH_ACT_PROVISIONER_SET_STATIC_OOB_VAL, + BTC_BLE_MESH_ACT_PROVISIONER_SET_PRIMARY_ELEM_ADDR, + BTC_BLE_MESH_ACT_PROVISIONER_SET_NODE_NAME, + BTC_BLE_MESH_ACT_PROVISIONER_ADD_LOCAL_APP_KEY, + BTC_BLE_MESH_ACT_PROVISIONER_UPDATE_LOCAL_APP_KEY, + BTC_BLE_MESH_ACT_PROVISIONER_BIND_LOCAL_MOD_APP, + BTC_BLE_MESH_ACT_PROVISIONER_ADD_LOCAL_NET_KEY, + BTC_BLE_MESH_ACT_PROVISIONER_UPDATE_LOCAL_NET_KEY, + BTC_BLE_MESH_ACT_PROVISIONER_STORE_NODE_COMP_DATA, + BTC_BLE_MESH_ACT_PROVISIONER_DELETE_NODE_WITH_UUID, + BTC_BLE_MESH_ACT_PROVISIONER_DELETE_NODE_WITH_ADDR, + BTC_BLE_MESH_ACT_PROVISIONER_ENABLE_HEARTBEAT_RECV, + BTC_BLE_MESH_ACT_PROVISIONER_SET_HEARTBEAT_FILTER_TYPE, + BTC_BLE_MESH_ACT_PROVISIONER_SET_HEARTBEAT_FILTER_INFO, + BTC_BLE_MESH_ACT_PROVISIONER_DIRECT_ERASE_SETTINGS, + BTC_BLE_MESH_ACT_PROVISIONER_OPEN_SETTINGS_WITH_INDEX, + BTC_BLE_MESH_ACT_PROVISIONER_OPEN_SETTINGS_WITH_UID, + BTC_BLE_MESH_ACT_PROVISIONER_CLOSE_SETTINGS_WITH_INDEX, + BTC_BLE_MESH_ACT_PROVISIONER_CLOSE_SETTINGS_WITH_UID, + BTC_BLE_MESH_ACT_PROVISIONER_DELETE_SETTINGS_WITH_INDEX, + BTC_BLE_MESH_ACT_PROVISIONER_DELETE_SETTINGS_WITH_UID, + BTC_BLE_MESH_ACT_SET_FAST_PROV_INFO, + BTC_BLE_MESH_ACT_SET_FAST_PROV_ACTION, + BTC_BLE_MESH_ACT_LPN_ENABLE, + BTC_BLE_MESH_ACT_LPN_DISABLE, + BTC_BLE_MESH_ACT_LPN_POLL, + BTC_BLE_MESH_ACT_PROXY_CLIENT_CONNECT, + BTC_BLE_MESH_ACT_PROXY_CLIENT_DISCONNECT, + BTC_BLE_MESH_ACT_PROXY_CLIENT_SET_FILTER_TYPE, + BTC_BLE_MESH_ACT_PROXY_CLIENT_ADD_FILTER_ADDR, + BTC_BLE_MESH_ACT_PROXY_CLIENT_REMOVE_FILTER_ADDR, + BTC_BLE_MESH_ACT_MODEL_SUBSCRIBE_GROUP_ADDR, + BTC_BLE_MESH_ACT_MODEL_UNSUBSCRIBE_GROUP_ADDR, + BTC_BLE_MESH_ACT_DEINIT_MESH, +} btc_ble_mesh_prov_act_t; + +typedef enum { + BTC_BLE_MESH_ACT_MODEL_PUBLISH, + BTC_BLE_MESH_ACT_SERVER_MODEL_SEND, + BTC_BLE_MESH_ACT_CLIENT_MODEL_SEND, + BTC_BLE_MESH_ACT_SERVER_MODEL_UPDATE_STATE, +} btc_ble_mesh_model_act_t; + +typedef union { + struct ble_mesh_init_args { + esp_ble_mesh_prov_t *prov; + esp_ble_mesh_comp_t *comp; + SemaphoreHandle_t semaphore; + } mesh_init; + struct ble_mesh_node_prov_enable_args { + esp_ble_mesh_prov_bearer_t bearers; + } node_prov_enable; + struct ble_mesh_node_prov_disable_args { + esp_ble_mesh_prov_bearer_t bearers; + } node_prov_disable; + struct ble_mesh_set_oob_pub_key_args { + uint8_t pub_key_x[32]; + uint8_t pub_key_y[32]; + uint8_t private_key[32]; + } set_oob_pub_key; + struct ble_mesh_node_input_num_args { + uint32_t number; + } input_number; + struct ble_mesh_node_input_str_args { + char string[8]; + } input_string; + struct ble_mesh_set_device_name_args { + char name[ESP_BLE_MESH_DEVICE_NAME_MAX_LEN + 1]; + } set_device_name; + struct ble_mesh_node_add_local_net_key_args { + uint8_t net_key[16]; + uint16_t net_idx; + } node_add_local_net_key; + struct ble_mesh_node_add_local_app_key_args { + uint8_t app_key[16]; + uint16_t net_idx; + uint16_t app_idx; + } node_add_local_app_key; + struct ble_mesh_node_bind_local_mod_app_args { + uint16_t element_addr; + uint16_t company_id; + uint16_t model_id; + uint16_t app_idx; + } node_local_mod_app_bind; + struct ble_mesh_provisioner_read_oob_pub_key_args { + uint8_t link_idx; + uint8_t pub_key_x[32]; + uint8_t pub_key_y[32]; + } provisioner_read_oob_pub_key; + struct ble_mesh_provisioner_input_str_args { + char string[8]; + uint8_t link_idx; + } provisioner_input_str; + struct ble_mesh_provisioner_input_num_args { + uint32_t number; + uint8_t link_idx; + } provisioner_input_num; + struct ble_mesh_provisioner_enable_args { + esp_ble_mesh_prov_bearer_t bearers; + } provisioner_enable; + struct ble_mesh_provisioner_disable_args { + esp_ble_mesh_prov_bearer_t bearers; + } provisioner_disable; + struct ble_mesh_provisioner_dev_add_args { + 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; + struct ble_mesh_provisioner_set_dev_uuid_match_args { + uint8_t offset; + uint8_t match_len; + uint8_t match_val[16]; + bool prov_after_match; + } set_dev_uuid_match; + 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 { + 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; + uint16_t cid; + uint16_t app_idx; + } local_mod_app_bind; + struct ble_mesh_provisioner_add_local_net_key_args { + uint8_t net_key[16]; + uint16_t net_idx; + } add_local_net_key; + struct ble_mesh_provisioner_update_local_net_key_args { + uint8_t net_key[16]; + uint16_t net_idx; + } update_local_net_key; + struct ble_mesh_provisioner_store_node_comp_data_args { + uint16_t unicast_addr; + uint16_t length; + uint8_t *data; + } store_node_comp_data; + struct ble_mesh_provisioner_delete_node_with_uuid_args { + uint8_t uuid[16]; + } delete_node_with_uuid; + struct ble_mesh_provisioner_delete_node_with_addr_args { + uint16_t unicast_addr; + } delete_node_with_addr; + struct { + bool enable; + } enable_heartbeat_recv; + struct { + uint8_t type; + } set_heartbeat_filter_type; + struct { + uint8_t op; + uint16_t hb_src; + uint16_t hb_dst; + } set_heartbeat_filter_info; + struct { + uint8_t index; + } open_settings_with_index; + struct { + char uid[ESP_BLE_MESH_SETTINGS_UID_SIZE + 1]; + } open_settings_with_uid; + struct { + uint8_t index; + bool erase; + } close_settings_with_index; + struct { + char uid[ESP_BLE_MESH_SETTINGS_UID_SIZE + 1]; + bool erase; + } close_settings_with_uid; + struct { + uint8_t index; + } delete_settings_with_index; + struct { + char uid[ESP_BLE_MESH_SETTINGS_UID_SIZE + 1]; + } delete_settings_with_uid; + struct ble_mesh_set_fast_prov_info_args { + uint16_t unicast_min; + uint16_t unicast_max; + uint16_t net_idx; + uint8_t flags; + uint32_t iv_index; + uint8_t offset; + uint8_t match_len; + uint8_t match_val[16]; + } set_fast_prov_info; + struct ble_mesh_set_fast_prov_action_args { + uint8_t action; + } set_fast_prov_action; + struct ble_mesh_lpn_enable_args { + /* RFU */ + } lpn_enable; + struct ble_mesh_lpn_disable_args { + bool force; + } lpn_disable; + struct ble_mesh_lpn_poll_args { + /* RFU */ + } lpn_poll; + struct ble_mesh_proxy_client_connect_args { + uint8_t addr[6]; + uint8_t addr_type; + uint16_t net_idx; + } proxy_client_connect; + struct ble_mesh_proxy_client_disconnect_args { + uint8_t conn_handle; + } proxy_client_disconnect; + struct ble_mesh_proxy_client_set_filter_type_args { + uint8_t conn_handle; + uint16_t net_idx; + uint8_t filter_type; + } proxy_client_set_filter_type; + struct ble_mesh_proxy_client_add_filter_addr_args { + uint8_t conn_handle; + uint16_t net_idx; + uint16_t addr_num; + uint16_t *addr; + } proxy_client_add_filter_addr; + struct ble_mesh_proxy_client_remove_filter_addr_args { + uint8_t conn_handle; + uint16_t net_idx; + uint16_t addr_num; + uint16_t *addr; + } proxy_client_remove_filter_addr; + struct ble_mesh_model_sub_group_addr_args { + uint16_t element_addr; + uint16_t company_id; + uint16_t model_id; + uint16_t group_addr; + } model_sub_group_addr; + struct ble_mesh_model_unsub_group_addr_args { + uint16_t element_addr; + uint16_t company_id; + uint16_t model_id; + uint16_t group_addr; + } model_unsub_group_addr; + struct ble_mesh_deinit_args { + esp_ble_mesh_deinit_param_t param; + } mesh_deinit; +} btc_ble_mesh_prov_args_t; + +typedef union { + struct ble_mesh_model_publish_args { + esp_ble_mesh_model_t *model; + uint8_t device_role; + } model_publish; + struct ble_mesh_model_send_args { + esp_ble_mesh_model_t *model; + esp_ble_mesh_msg_ctx_t *ctx; + uint32_t opcode; + bool need_rsp; + uint16_t length; + uint8_t *data; + 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_copy(btc_msg_t *msg, void *p_dest, void *p_src); + +void btc_ble_mesh_model_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src); + +const uint8_t *btc_ble_mesh_node_get_local_net_key(uint16_t net_idx); + +const uint8_t *btc_ble_mesh_node_get_local_app_key(uint16_t app_idx); + +esp_ble_mesh_node_t *btc_ble_mesh_provisioner_get_node_with_uuid(const uint8_t uuid[16]); + +esp_ble_mesh_node_t *btc_ble_mesh_provisioner_get_node_with_addr(uint16_t unicast_addr); + +esp_ble_mesh_node_t *btc_ble_mesh_provisioner_get_node_with_name(const char *name); + +uint16_t btc_ble_mesh_provisioner_get_prov_node_count(void); + +const esp_ble_mesh_node_t **btc_ble_mesh_provisioner_get_node_table_entry(void); + +int btc_ble_mesh_client_model_init(esp_ble_mesh_model_t *model); + +int btc_ble_mesh_client_model_deinit(esp_ble_mesh_model_t *model); + +int32_t btc_ble_mesh_model_pub_period_get(esp_ble_mesh_model_t *mod); + +uint16_t btc_ble_mesh_get_primary_addr(void); + +uint16_t *btc_ble_mesh_model_find_group(esp_ble_mesh_model_t *mod, uint16_t addr); + +esp_ble_mesh_elem_t *btc_ble_mesh_elem_find(uint16_t addr); + +uint8_t btc_ble_mesh_elem_count(void); + +esp_ble_mesh_model_t *btc_ble_mesh_model_find_vnd(const esp_ble_mesh_elem_t *elem, + uint16_t company, uint16_t id); + +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); + +const char *btc_ble_mesh_provisioner_get_settings_uid(uint8_t index); + +uint8_t btc_ble_mesh_provisioner_get_settings_index(const char *uid); + +uint8_t btc_ble_mesh_provisioner_get_free_settings_count(void); + +void btc_ble_mesh_model_call_handler(btc_msg_t *msg); +void btc_ble_mesh_model_cb_handler(btc_msg_t *msg); + +void btc_ble_mesh_prov_call_handler(btc_msg_t *msg); +void btc_ble_mesh_prov_cb_handler(btc_msg_t *msg); + +#ifdef __cplusplus +} +#endif + +#endif /* _BTC_BLE_MESH_PROV_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_sensor_model.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_sensor_model.h new file mode 100644 index 00000000000..a0dc29f3784 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_sensor_model.h @@ -0,0 +1,74 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _BTC_BLE_MESH_SENSOR_MODEL_H_ +#define _BTC_BLE_MESH_SENSOR_MODEL_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 { + struct ble_mesh_sensor_client_get_state_reg_args { + esp_ble_mesh_client_common_param_t *params; + esp_ble_mesh_sensor_client_get_state_t *get_state; + } sensor_client_get_state; + struct ble_mesh_sensor_client_set_state_reg_args { + esp_ble_mesh_client_common_param_t *params; + esp_ble_mesh_sensor_client_set_state_t *set_state; + } sensor_client_set_state; +} btc_ble_mesh_sensor_client_args_t; + +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_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_ble_mesh_sensor_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf); + +void bt_mesh_sensor_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type, + struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + const uint8_t *val, size_t len); + +typedef enum { + BTC_BLE_MESH_EVT_SENSOR_SERVER_STATE_CHANGE, + BTC_BLE_MESH_EVT_SENSOR_SERVER_RECV_GET_MSG, + BTC_BLE_MESH_EVT_SENSOR_SERVER_RECV_SET_MSG, + BTC_BLE_MESH_EVT_SENSOR_SERVER_MAX, +} btc_ble_mesh_sensor_server_evt_t; + +void bt_mesh_sensor_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + const uint8_t *val, size_t len); + +void btc_ble_mesh_sensor_server_cb_handler(btc_msg_t *msg); + +#ifdef __cplusplus +} +#endif + +#endif /* _BTC_BLE_MESH_SENSOR_MODEL_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_time_scene_model.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_time_scene_model.h new file mode 100644 index 00000000000..6c878dc7769 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/btc/include/btc_ble_mesh_time_scene_model.h @@ -0,0 +1,75 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _BTC_BLE_MESH_TIME_SCENE_MODEL_H_ +#define _BTC_BLE_MESH_TIME_SCENE_MODEL_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 { + struct ble_mesh_time_scene_client_get_state_reg_args { + esp_ble_mesh_client_common_param_t *params; + esp_ble_mesh_time_scene_client_get_state_t *get_state; + } time_scene_client_get_state; + struct ble_mesh_time_scene_client_set_state_reg_args { + esp_ble_mesh_client_common_param_t *params; + esp_ble_mesh_time_scene_client_set_state_t *set_state; + } time_scene_client_set_state; +} btc_ble_mesh_time_scene_client_args_t; + +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_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_ble_mesh_time_scene_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf); + +void bt_mesh_time_scene_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type, + struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + const uint8_t *val, size_t len); + +typedef enum { + BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_STATE_CHANGE, + BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_GET_MSG, + BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_SET_MSG, + BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_STATUS_MSG, + BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_MAX, +} btc_ble_mesh_time_scene_server_evt_t; + +void bt_mesh_time_scene_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + const uint8_t *val, size_t len); + +void btc_ble_mesh_time_scene_server_cb_handler(btc_msg_t *msg); + +#ifdef __cplusplus +} +#endif + +#endif /* _BTC_BLE_MESH_TIME_SCENE_MODEL_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_atomic.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_atomic.h new file mode 100644 index 00000000000..6d62840e46e --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_atomic.h @@ -0,0 +1,305 @@ +/* atomic operations */ + +/* + * SPDX-FileCopyrightText: 1997-2015 Wind River Systems, Inc. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _BLE_MESH_ATOMIC_H_ +#define _BLE_MESH_ATOMIC_H_ + +#include "mesh_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef bt_mesh_atomic_t bt_mesh_atomic_val_t; + +/** + * @defgroup atomic_apis Atomic Services APIs + * @ingroup kernel_apis + * @{ + */ + +/** + * + * @brief Atomic increment. + * + * This routine performs an atomic increment by 1 on @a target. + * + * @param target Address of atomic variable. + * + * @return Previous value of @a target. + */ +#ifdef CONFIG_ATOMIC_OPERATIONS_BUILTIN +static inline bt_mesh_atomic_val_t bt_mesh_atomic_inc(bt_mesh_atomic_t *target) +{ + return bt_mesh_atomic_add(target, 1); +} +#else +extern bt_mesh_atomic_val_t bt_mesh_atomic_inc(bt_mesh_atomic_t *target); +#endif + +/** + * + * @brief Atomic decrement. + * + * This routine performs an atomic decrement by 1 on @a target. + * + * @param target Address of atomic variable. + * + * @return Previous value of @a target. + */ +#ifdef CONFIG_ATOMIC_OPERATIONS_BUILTIN +static inline bt_mesh_atomic_val_t bt_mesh_atomic_dec(bt_mesh_atomic_t *target) +{ + return bt_mesh_atomic_sub(target, 1); +} +#else +extern bt_mesh_atomic_val_t bt_mesh_atomic_dec(bt_mesh_atomic_t *target); +#endif + +/** + * + * @brief Atomic get. + * + * This routine performs an atomic read on @a target. + * + * @param target Address of atomic variable. + * + * @return Value of @a target. + */ +#ifdef CONFIG_ATOMIC_OPERATIONS_BUILTIN +static inline bt_mesh_atomic_val_t bt_mesh_atomic_get(const bt_mesh_atomic_t *target) +{ + return __atomic_load_n(target, __ATOMIC_SEQ_CST); +} +#else +extern bt_mesh_atomic_val_t bt_mesh_atomic_get(const bt_mesh_atomic_t *target); +#endif + +/** + * + * @brief Atomic get-and-set. + * + * This routine atomically sets @a target to @a value and returns + * the previous value of @a target. + * + * @param target Address of atomic variable. + * @param value Value to write to @a target. + * + * @return Previous value of @a target. + */ +#ifdef CONFIG_ATOMIC_OPERATIONS_BUILTIN +static inline bt_mesh_atomic_val_t bt_mesh_atomic_set(bt_mesh_atomic_t *target, bt_mesh_atomic_val_t value) +{ + /* This builtin, as described by Intel, is not a traditional + * test-and-set operation, but rather an atomic exchange operation. It + * writes value into *ptr, and returns the previous contents of *ptr. + */ + return __atomic_exchange_n(target, value, __ATOMIC_SEQ_CST); +} +#else +extern bt_mesh_atomic_val_t bt_mesh_atomic_set(bt_mesh_atomic_t *target, bt_mesh_atomic_val_t value); +#endif + +/** + * + * @brief Atomic bitwise inclusive OR. + * + * This routine atomically sets @a target to the bitwise inclusive OR of + * @a target and @a value. + * + * @param target Address of atomic variable. + * @param value Value to OR. + * + * @return Previous value of @a target. + */ +#ifdef CONFIG_ATOMIC_OPERATIONS_BUILTIN +static inline bt_mesh_atomic_val_t bt_mesh_atomic_or(bt_mesh_atomic_t *target, bt_mesh_atomic_val_t value) +{ + return __atomic_fetch_or(target, value, __ATOMIC_SEQ_CST); +} +#else +extern bt_mesh_atomic_val_t bt_mesh_atomic_or(bt_mesh_atomic_t *target, bt_mesh_atomic_val_t value); +#endif + +/** + * + * @brief Atomic bitwise AND. + * + * This routine atomically sets @a target to the bitwise AND of @a target + * and @a value. + * + * @param target Address of atomic variable. + * @param value Value to AND. + * + * @return Previous value of @a target. + */ +#ifdef CONFIG_ATOMIC_OPERATIONS_BUILTIN +static inline bt_mesh_atomic_val_t bt_mesh_atomic_and(bt_mesh_atomic_t *target, bt_mesh_atomic_val_t value) +{ + return __atomic_fetch_and(target, value, __ATOMIC_SEQ_CST); +} +#else +extern bt_mesh_atomic_val_t bt_mesh_atomic_and(bt_mesh_atomic_t *target, bt_mesh_atomic_val_t value); +#endif + +/** + * @cond INTERNAL_HIDDEN + */ + +#define BLE_MESH_ATOMIC_BITS (sizeof(bt_mesh_atomic_val_t) * 8) +#define BLE_MESH_ATOMIC_MASK(bit) (1 << ((bit) & (BLE_MESH_ATOMIC_BITS - 1))) +#define BLE_MESH_ATOMIC_ELEM(addr, bit) ((addr) + ((bit) / BLE_MESH_ATOMIC_BITS)) + +/** + * INTERNAL_HIDDEN @endcond + */ + +/** + * @brief Define an array of atomic variables. + * + * This macro defines an array of atomic variables containing at least + * @a num_bits bits. + * + * @note + * If used from file scope, the bits of the array are initialized to zero; + * if used from within a function, the bits are left uninitialized. + * + * @param name Name of array of atomic variables. + * @param num_bits Number of bits needed. + */ +#define BLE_MESH_ATOMIC_DEFINE(name, num_bits) \ + bt_mesh_atomic_t name[1 + ((num_bits) - 1) / BLE_MESH_ATOMIC_BITS] + +/** + * @brief Atomically test a bit. + * + * This routine tests whether bit number @a bit of @a target is set or not. + * The target may be a single atomic variable or an array of them. + * + * @param target Address of atomic variable or array. + * @param bit Bit number (starting from 0). + * + * @return 1 if the bit was set, 0 if it wasn't. + */ +static inline int bt_mesh_atomic_test_bit(const bt_mesh_atomic_t *target, int bit) +{ + bt_mesh_atomic_val_t val = bt_mesh_atomic_get(BLE_MESH_ATOMIC_ELEM(target, bit)); + + return (1 & (val >> (bit & (BLE_MESH_ATOMIC_BITS - 1)))); +} + +/** + * @brief Atomically test and clear a bit. + * + * Atomically clear bit number @a bit of @a target and return its old value. + * The target may be a single atomic variable or an array of them. + * + * @param target Address of atomic variable or array. + * @param bit Bit number (starting from 0). + * + * @return 1 if the bit was set, 0 if it wasn't. + */ +static inline int bt_mesh_atomic_test_and_clear_bit(bt_mesh_atomic_t *target, int bit) +{ + bt_mesh_atomic_val_t mask = BLE_MESH_ATOMIC_MASK(bit); + bt_mesh_atomic_val_t old; + + old = bt_mesh_atomic_and(BLE_MESH_ATOMIC_ELEM(target, bit), ~mask); + + return (old & mask) != 0; +} + +/** + * @brief Atomically set a bit. + * + * Atomically set bit number @a bit of @a target and return its old value. + * The target may be a single atomic variable or an array of them. + * + * @param target Address of atomic variable or array. + * @param bit Bit number (starting from 0). + * + * @return 1 if the bit was set, 0 if it wasn't. + */ +static inline int bt_mesh_atomic_test_and_set_bit(bt_mesh_atomic_t *target, int bit) +{ + bt_mesh_atomic_val_t mask = BLE_MESH_ATOMIC_MASK(bit); + bt_mesh_atomic_val_t old; + + old = bt_mesh_atomic_or(BLE_MESH_ATOMIC_ELEM(target, bit), mask); + + return (old & mask) != 0; +} + +/** + * @brief Atomically clear a bit. + * + * Atomically clear bit number @a bit of @a target. + * The target may be a single atomic variable or an array of them. + * + * @param target Address of atomic variable or array. + * @param bit Bit number (starting from 0). + * + * @return N/A + */ +static inline void bt_mesh_atomic_clear_bit(bt_mesh_atomic_t *target, int bit) +{ + bt_mesh_atomic_val_t mask = BLE_MESH_ATOMIC_MASK(bit); + + (void)bt_mesh_atomic_and(BLE_MESH_ATOMIC_ELEM(target, bit), ~mask); +} + +/** + * @brief Atomically set a bit. + * + * Atomically set bit number @a bit of @a target. + * The target may be a single atomic variable or an array of them. + * + * @param target Address of atomic variable or array. + * @param bit Bit number (starting from 0). + * + * @return N/A + */ +static inline void bt_mesh_atomic_set_bit(bt_mesh_atomic_t *target, int bit) +{ + bt_mesh_atomic_val_t mask = BLE_MESH_ATOMIC_MASK(bit); + + (void)bt_mesh_atomic_or(BLE_MESH_ATOMIC_ELEM(target, bit), mask); +} + +/** + * @brief Atomically set a bit to a given value. + * + * Atomically set bit number @a bit of @a target to value @a val. + * The target may be a single atomic variable or an array of them. + * + * @param target Address of atomic variable or array. + * @param bit Bit number (starting from 0). + * @param val true for 1, false for 0. + * + * @return N/A + */ +static inline void bt_mesh_atomic_set_bit_to(bt_mesh_atomic_t *target, int bit, bool val) +{ + bt_mesh_atomic_val_t mask = BLE_MESH_ATOMIC_MASK(bit); + + if (val) { + (void)bt_mesh_atomic_or(BLE_MESH_ATOMIC_ELEM(target, bit), mask); + } else { + (void)bt_mesh_atomic_and(BLE_MESH_ATOMIC_ELEM(target, bit), ~mask); + } +} + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* _BLE_MESH_ATOMIC_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_buf.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_buf.h new file mode 100644 index 00000000000..33baa8cc81d --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_buf.h @@ -0,0 +1,1758 @@ +/** @file + * @brief Buffer management. + */ + +/* + * SPDX-FileCopyrightText: 2015 Intel Corporation + * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#ifndef _BLE_MESH_BUF_H_ +#define _BLE_MESH_BUF_H_ + +#include "mesh_config.h" +#include "mesh_types.h" +#include "mesh_slist.h" +#include "mesh_compiler.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Unaligned access */ +#define UNALIGNED_GET(p) \ +__extension__ ({ \ + struct __attribute__((__packed__)) { \ + __typeof__(*(p)) __v; \ + } *__p = (__typeof__(__p)) (p); \ + __p->__v; \ +}) + +#define BLE_MESH_NET_BUF_USER_DATA_SIZE 4 + +/** + * @brief Network buffer library + * @defgroup net_buf Network Buffer Library + * @ingroup networking + * @{ + */ + +/* Alignment needed for various parts of the buffer definition */ +#define __net_buf_align __aligned(sizeof(int)) + +/** + * @def NET_BUF_SIMPLE_DEFINE + * @brief Define a net_buf_simple stack variable. + * + * This is a helper macro which is used to define a net_buf_simple object + * on the stack. + * + * @param _name Name of the net_buf_simple object. + * @param _size Maximum data storage for the buffer. + */ +#define NET_BUF_SIMPLE_DEFINE(_name, _size) \ + uint8_t net_buf_data_##_name[_size]; \ + struct net_buf_simple _name = { \ + .data = net_buf_data_##_name, \ + .len = 0, \ + .size = _size, \ + .__buf = net_buf_data_##_name, \ + } + +/** + * @def NET_BUF_SIMPLE_DEFINE_STATIC + * @brief Define a static net_buf_simple variable. + * + * This is a helper macro which is used to define a static net_buf_simple + * object. + * + * @param _name Name of the net_buf_simple object. + * @param _size Maximum data storage for the buffer. + */ +#define NET_BUF_SIMPLE_DEFINE_STATIC(_name, _size) \ + static uint8_t net_buf_data_##_name[_size]; \ + static struct net_buf_simple _name = { \ + .data = net_buf_data_##_name, \ + .len = 0, \ + .size = _size, \ + .__buf = net_buf_data_##_name, \ + } + +/** + * @brief Simple network buffer representation. + * + * This is a simpler variant of the net_buf object (in fact net_buf uses + * net_buf_simple internally). It doesn't provide any kind of reference + * counting, user data, dynamic allocation, or in general the ability to + * pass through kernel objects such as FIFOs. + * + * The main use of this is for scenarios where the meta-data of the normal + * net_buf isn't needed and causes too much overhead. This could be e.g. + * when the buffer only needs to be allocated on the stack or when the + * access to and lifetime of the buffer is well controlled and constrained. + */ +struct net_buf_simple { + /** Pointer to the start of data in the buffer. */ + uint8_t *data; + + /** Length of the data behind the data pointer. */ + uint16_t len; + + /** Amount of data that this buffer can store. */ + uint16_t size; + + /** Start of the data storage. Not to be accessed directly + * (the data pointer should be used instead). + */ + uint8_t *__buf; +}; + +/** + * @def NET_BUF_SIMPLE + * @brief Define a net_buf_simple stack variable and get a pointer to it. + * + * This is a helper macro which is used to define a net_buf_simple object on + * the stack and the get a pointer to it as follows: + * + * struct net_buf_simple *my_buf = NET_BUF_SIMPLE(10); + * + * After creating the object it needs to be initialized by calling + * net_buf_simple_init(). + * + * @param _size Maximum data storage for the buffer. + * + * @return Pointer to stack-allocated net_buf_simple object. + */ +#define NET_BUF_SIMPLE(_size) \ + ((struct net_buf_simple *)(&(struct { \ + struct net_buf_simple buf; \ + uint8_t data[_size] __net_buf_align; \ + }) { \ + .buf.size = _size, \ + .buf.__buf = NULL, \ + })) + +/** + * @brief Initialize a net_buf_simple object. + * + * This needs to be called after creating a net_buf_simple object using + * the NET_BUF_SIMPLE macro. + * + * @param buf Buffer to initialize. + * @param reserve_head Headroom to reserve. + */ +static inline void net_buf_simple_init(struct net_buf_simple *buf, + size_t reserve_head) +{ + if (!buf->__buf) { + buf->__buf = (uint8_t *)buf + sizeof(*buf); + } + + buf->data = buf->__buf + reserve_head; + buf->len = 0; +} + +/** + * @brief Initialize a net_buf_simple object with data. + * + * Initialized buffer object with external data. + * + * @param buf Buffer to initialize. + * @param data External data pointer + * @param size Amount of data the pointed data buffer if able to fit. + */ +void net_buf_simple_init_with_data(struct net_buf_simple *buf, + void *data, size_t size); + +/** + * @brief Reset buffer + * + * Reset buffer data so it can be reused for other purposes. + * + * @param buf Buffer to reset. + */ +static inline void net_buf_simple_reset(struct net_buf_simple *buf) +{ + buf->len = 0; + 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 + * + * Increments the data length of a buffer to account for more data + * at the end. + * + * @param buf Buffer to update. + * @param len Number of bytes to increment the length with. + * + * @return The original tail of the buffer. + */ +void *net_buf_simple_add(struct net_buf_simple *buf, size_t len); + +/** + * @brief Copy given number of bytes from memory to the end of the buffer + * + * Increments the data length of the buffer to account for more data at the + * end. + * + * @param buf Buffer to update. + * @param mem Location of data to be added. + * @param len Length of data to be added + * + * @return The original tail of the buffer. + */ +void *net_buf_simple_add_mem(struct net_buf_simple *buf, const void *mem, + size_t len); + +/** + * @brief Add (8-bit) byte at the end of the buffer + * + * Increments the data length of the buffer to account for more data at the + * end. + * + * @param buf Buffer to update. + * @param val byte value to be added. + * + * @return Pointer to the value added + */ +uint8_t *net_buf_simple_add_u8(struct net_buf_simple *buf, uint8_t val); + +/** + * @brief Add 16-bit value at the end of the buffer + * + * Adds 16-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 16-bit value to be added. + */ +void net_buf_simple_add_le16(struct net_buf_simple *buf, uint16_t val); + +/** + * @brief Add 16-bit value at the end of the buffer + * + * Adds 16-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 16-bit value to be added. + */ +void net_buf_simple_add_be16(struct net_buf_simple *buf, uint16_t val); + +/** + * @brief Add 24-bit value at the end of the buffer + * + * 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, uint32_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, uint32_t val); + +/** + * @brief Add 32-bit value at the end of the buffer + * + * Adds 32-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 32-bit value to be added. + */ +void net_buf_simple_add_le32(struct net_buf_simple *buf, uint32_t val); + +/** + * @brief Add 32-bit value at the end of the buffer + * + * Adds 32-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 32-bit value to be added. + */ +void net_buf_simple_add_be32(struct net_buf_simple *buf, uint32_t val); + +/** + * @brief Add 48-bit value at the end of the buffer + * + * 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, uint64_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, uint64_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, uint64_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, uint64_t val); + +/** + * @brief Push data to the beginning of the buffer. + * + * Modifies the data pointer and buffer length to account for more data + * in the beginning of the buffer. + * + * @param buf Buffer to update. + * @param len Number of bytes to add to the beginning. + * + * @return The new beginning of the buffer data. + */ +void *net_buf_simple_push(struct net_buf_simple *buf, size_t len); + +/** + * @brief Push 16-bit value to the beginning of the buffer + * + * Adds 16-bit value in little endian format to the beginning of the + * buffer. + * + * @param buf Buffer to update. + * @param val 16-bit value to be pushed to the buffer. + */ +void net_buf_simple_push_le16(struct net_buf_simple *buf, uint16_t val); + +/** + * @brief Push 16-bit value to the beginning of the buffer + * + * Adds 16-bit value in big endian format to the beginning of the + * buffer. + * + * @param buf Buffer to update. + * @param val 16-bit value to be pushed to the buffer. + */ +void net_buf_simple_push_be16(struct net_buf_simple *buf, uint16_t val); + +/** + * @brief Push 8-bit value to the beginning of the buffer + * + * Adds 8-bit value the beginning of the buffer. + * + * @param buf Buffer to update. + * @param val 8-bit value to be pushed to the buffer. + */ +void net_buf_simple_push_u8(struct net_buf_simple *buf, uint8_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, uint32_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, uint32_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, uint32_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, uint32_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, uint64_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, uint64_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, uint64_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, uint64_t val); + +/** + * @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 New beginning of the buffer data. + */ +void *net_buf_simple_pull(struct net_buf_simple *buf, size_t len); + +/** + * @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 location of the buffer data. + */ +void *net_buf_simple_pull_mem(struct net_buf_simple *buf, size_t len); + +/** + * @brief Remove a 8-bit value from the beginning of the buffer + * + * Same idea as with net_buf_simple_pull(), but a helper for operating + * on 8-bit values. + * + * @param buf A valid pointer on a buffer. + * + * @return The 8-bit removed value + */ +uint8_t net_buf_simple_pull_u8(struct net_buf_simple *buf); + +/** + * @brief Remove and convert 16 bits from the beginning of the buffer. + * + * Same idea as with net_buf_simple_pull(), but a helper for operating + * on 16-bit little endian data. + * + * @param buf A valid pointer on a buffer. + * + * @return 16-bit value converted from little endian to host endian. + */ +uint16_t net_buf_simple_pull_le16(struct net_buf_simple *buf); + +/** + * @brief Remove and convert 16 bits from the beginning of the buffer. + * + * Same idea as with net_buf_simple_pull(), but a helper for operating + * on 16-bit big endian data. + * + * @param buf A valid pointer on a buffer. + * + * @return 16-bit value converted from big endian to host endian. + */ +uint16_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. + */ +uint32_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. + */ +uint32_t net_buf_simple_pull_be24(struct net_buf_simple *buf); + +/** + * @brief Remove and convert 32 bits from the beginning of the buffer. + * + * Same idea as with net_buf_simple_pull(), but a helper for operating + * on 32-bit little endian data. + * + * @param buf A valid pointer on a buffer. + * + * @return 32-bit value converted from little endian to host endian. + */ +uint32_t net_buf_simple_pull_le32(struct net_buf_simple *buf); + +/** + * @brief Remove and convert 32 bits from the beginning of the buffer. + * + * Same idea as with net_buf_simple_pull(), but a helper for operating + * on 32-bit big endian data. + * + * @param buf A valid pointer on a buffer. + * + * @return 32-bit value converted from big endian to host endian. + */ +uint32_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. + */ +uint64_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. + */ +uint64_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. + */ +uint64_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. + */ +uint64_t net_buf_simple_pull_be64(struct net_buf_simple *buf); + +/** + * @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. + */ +static inline uint8_t *net_buf_simple_tail(struct net_buf_simple *buf) +{ + return buf->data + buf->len; +} + +/** + * @brief Check buffer headroom. + * + * Check how much free space there is in the beginning of the buffer. + * + * buf A valid pointer on a buffer + * + * @return Number of bytes available in the beginning of the buffer. + */ +size_t net_buf_simple_headroom(struct net_buf_simple *buf); + +/** + * @brief Check buffer tailroom. + * + * Check how much free space there is at the end of the buffer. + * + * @param buf A valid pointer on a buffer + * + * @return Number of bytes available at the end of the buffer. + */ +size_t net_buf_simple_tailroom(struct net_buf_simple *buf); + +/** + * @brief Parsing state of a buffer. + * + * This is used for temporarily storing the parsing state of a buffer + * while giving control of the parsing to a routine which we don't + * control. + */ +struct net_buf_simple_state { + /** Offset of the data pointer from the beginning of the storage */ + uint16_t offset; + /** Length of data */ + uint16_t len; +}; + +/** + * @brief Save the parsing state of a buffer. + * + * Saves the parsing state of a buffer so it can be restored later. + * + * @param buf Buffer from which the state should be saved. + * @param state Storage for the state. + */ +static inline void net_buf_simple_save(struct net_buf_simple *buf, + struct net_buf_simple_state *state) +{ + state->offset = net_buf_simple_headroom(buf); + state->len = buf->len; +} + +/** + * @brief Restore the parsing state of a buffer. + * + * Restores the parsing state of a buffer from a state previously stored + * by net_buf_simple_save(). + * + * @param buf Buffer to which the state should be restored. + * @param state Stored state. + */ +static inline void net_buf_simple_restore(struct net_buf_simple *buf, + struct net_buf_simple_state *state) +{ + buf->data = buf->__buf + state->offset; + buf->len = state->len; +} + +/** + * @brief Initialize buffer with the given headroom. + * + * The buffer is not expected to contain any data when this API is called. + * + * @param buf Buffer to initialize. + * @param reserve How much headroom to reserve. + */ +void net_buf_simple_reserve(struct net_buf_simple *buf, size_t reserve); + +/** + * Flag indicating that the buffer has associated fragments. Only used + * internally by the buffer handling code while the buffer is inside a + * FIFO, meaning this never needs to be explicitly set or unset by the + * net_buf API user. As long as the buffer is outside of a FIFO, i.e. + * in practice always for the user for this API, the buf->frags pointer + * should be used instead. + */ +#define NET_BUF_FRAGS BIT(0) + +/** + * @brief Network buffer representation. + * + * This struct is used to represent network buffers. Such buffers are + * normally defined through the NET_BUF_POOL_*_DEFINE() APIs and allocated + * using the net_buf_alloc() API. + */ +struct net_buf { + union { + /** Allow placing the buffer into sys_slist_t */ + sys_snode_t node; + + /** Fragments associated with this buffer. */ + struct net_buf *frags; + }; + + /** Reference count. */ + uint8_t ref; + + /** Bit-field of buffer flags. */ + uint8_t flags; + + /** Where the buffer should go when freed up. */ + struct net_buf_pool *pool; + + /* Union for convenience access to the net_buf_simple members, also + * preserving the old API. + */ + union { + /* The ABI of this struct must match net_buf_simple */ + struct { + /** Pointer to the start of data in the buffer. */ + uint8_t *data; + + /** Length of the data behind the data pointer. */ + uint16_t len; + + /** Amount of data that this buffer can store. */ + uint16_t size; + + /** Start of the data storage. Not to be accessed + * directly (the data pointer should be used + * instead). + */ + uint8_t *__buf; + }; + + struct net_buf_simple b; + }; + + /** System metadata for this buffer. */ + uint8_t user_data[BLE_MESH_NET_BUF_USER_DATA_SIZE] __net_buf_align; +}; + +struct net_buf_data_cb { + uint8_t *(*alloc)(struct net_buf *buf, size_t *size, int32_t timeout); + uint8_t *(*ref)(struct net_buf *buf, uint8_t *data); + void (*unref)(struct net_buf *buf, uint8_t *data); +}; + +struct net_buf_data_alloc { + const struct net_buf_data_cb *cb; + void *alloc_data; +}; + +struct net_buf_pool { + /** Number of buffers in pool */ + const uint16_t buf_count; + + /** Number of uninitialized buffers */ + uint16_t uninit_count; + +#if defined(CONFIG_BLE_MESH_NET_BUF_POOL_USAGE) + /** Amount of available buffers in the pool. */ + int16_t avail_count; + + /** Total size of the pool. */ + const uint16_t pool_size; + + /** Name of the pool. Used when printing pool information. */ + const char *name; +#endif /* CONFIG_BLE_MESH_NET_BUF_POOL_USAGE */ + + /** Optional destroy callback when buffer is freed. */ + void (*const destroy)(struct net_buf *buf); + + /** Data allocation handlers. */ + const struct net_buf_data_alloc *alloc; + + /** Helper to access the start of storage (for net_buf_pool_init) */ + struct net_buf *const __bufs; +}; + +#if defined(CONFIG_BLE_MESH_NET_BUF_POOL_USAGE) +#define NET_BUF_POOL_INITIALIZER(_pool, _alloc, _bufs, _count, _destroy) \ + { \ + .alloc = _alloc, \ + .__bufs = (struct net_buf *)_bufs, \ + .buf_count = _count, \ + .uninit_count = _count, \ + .avail_count = _count, \ + .destroy = _destroy, \ + .name = STRINGIFY(_pool), \ + } +#else +#define NET_BUF_POOL_INITIALIZER(_pool, _alloc, _bufs, _count, _destroy) \ + { \ + .alloc = _alloc, \ + .__bufs = (struct net_buf *)_bufs, \ + .buf_count = _count, \ + .uninit_count = _count, \ + .destroy = _destroy, \ + } +#endif /* CONFIG_BLE_MESH_NET_BUF_POOL_USAGE */ + +struct net_buf_pool_fixed { + size_t data_size; + uint8_t *data_pool; +}; + +/** @cond INTERNAL_HIDDEN */ +extern const struct net_buf_data_cb net_buf_fixed_cb; + +/** + * @def NET_BUF_POOL_FIXED_DEFINE + * @brief Define a new pool for buffers based on fixed-size data + * + * Defines a net_buf_pool struct and the necessary memory storage (array of + * structs) for the needed amount of buffers. After this, the buffers can be + * accessed from the pool through net_buf_alloc. The pool is defined as a + * static variable, so if it needs to be exported outside the current module + * this needs to happen with the help of a separate pointer rather than an + * extern declaration. + * + * The data payload of the buffers will be allocated from a byte array + * of fixed sized chunks. This kind of pool does not support blocking on + * the data allocation, so the timeout passed to net_buf_alloc will be + * always treated as K_NO_WAIT when trying to allocate the data. This means + * that allocation failures, i.e. NULL returns, must always be handled + * cleanly. + * + * If provided with a custom destroy callback, this callback is + * responsible for eventually calling net_buf_destroy() to complete the + * process of returning the buffer to the pool. + * + * @param _name Name of the pool variable. + * @param _count Number of buffers in the pool. + * @param _data_size Maximum data payload per buffer. + * @param _destroy Optional destroy callback when buffer is freed. + */ +#define NET_BUF_POOL_FIXED_DEFINE(_name, _count, _data_size, _destroy) \ + static struct net_buf net_buf_##_name[_count]; \ + static uint8_t net_buf_data_##_name[_count][_data_size]; \ + static const struct net_buf_pool_fixed net_buf_fixed_##_name = { \ + .data_size = _data_size, \ + .data_pool = (uint8_t *)net_buf_data_##_name, \ + }; \ + static const struct net_buf_data_alloc net_buf_fixed_alloc_##_name = { \ + .cb = &net_buf_fixed_cb, \ + .alloc_data = (void *)&net_buf_fixed_##_name, \ + }; \ + struct net_buf_pool _name __net_buf_align \ + __in_section(_net_buf_pool, static, _name) = \ + NET_BUF_POOL_INITIALIZER(_name, &net_buf_fixed_alloc_##_name, \ + net_buf_##_name, _count, _destroy) + +/** + * @def NET_BUF_POOL_DEFINE + * @brief Define a new pool for buffers + * + * Defines a net_buf_pool struct and the necessary memory storage (array of + * structs) for the needed amount of buffers. After this,the buffers can be + * accessed from the pool through net_buf_alloc. The pool is defined as a + * static variable, so if it needs to be exported outside the current module + * this needs to happen with the help of a separate pointer rather than an + * extern declaration. + * + * If provided with a custom destroy callback this callback is + * responsible for eventually calling net_buf_destroy() to complete the + * process of returning the buffer to the pool. + * + * @param _name Name of the pool variable. + * @param _count Number of buffers in the pool. + * @param _size Maximum data size for each buffer. + * @param _ud_size Amount of user data space to reserve. + * @param _destroy Optional destroy callback when buffer is freed. + */ +#define NET_BUF_POOL_DEFINE(_name, _count, _size, _ud_size, _destroy) \ + NET_BUF_POOL_FIXED_DEFINE(_name, _count, _size, _destroy) + +/** + * @brief Get a zero-based index for a buffer. + * + * This function will translate a buffer into a zero-based index, + * based on its placement in its buffer pool. This can be useful if you + * want to associate an external array of meta-data contexts with the + * buffers of a pool. + * + * @param buf Network buffer. + * + * @return Zero-based index for the buffer. + */ +int net_buf_id(struct net_buf *buf); + +/** + * @brief Allocate a new fixed buffer from a pool. + * + * @param pool Which pool to allocate the buffer from. + * @param timeout Affects the action taken should the 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. Note that some types + * of data allocators do not support blocking (such as the HEAP + * type). In this case it's still possible for net_buf_alloc() to + * fail (return NULL) even if it was given K_FOREVER. + * + * @return New buffer or NULL if out of buffers. + */ +#if defined(CONFIG_BLE_MESH_NET_BUF_LOG) +struct net_buf *net_buf_alloc_fixed_debug(struct net_buf_pool *pool, int32_t timeout, + const char *func, int line); +#define net_buf_alloc_fixed(_pool, _timeout) \ + net_buf_alloc_fixed_debug(_pool, _timeout, __func__, __LINE__) +#else +struct net_buf *net_buf_alloc_fixed(struct net_buf_pool *pool, int32_t timeout); +#endif + +/** + * @def net_buf_alloc + * + * @copydetails net_buf_alloc_fixed + */ +#define net_buf_alloc(pool, timeout) net_buf_alloc_fixed(pool, timeout) + +/** + * @brief Reset buffer + * + * Reset buffer data and flags so it can be reused for other purposes. + * + * @param buf Buffer to reset. + */ +void net_buf_reset(struct net_buf *buf); + +/** + * @def net_buf_reserve + * @brief Initialize buffer with the given headroom. + * + * The buffer is not expected to contain any data when this API is called. + * + * @param buf Buffer to initialize. + * @param reserve How much headroom to reserve. + */ +#define net_buf_reserve(buf, reserve) net_buf_simple_reserve(&(buf)->b, reserve) + +/** + * @brief Put a buffer into a list + * + * Put a buffer to the end of a list. If the buffer contains follow-up + * fragments this function will take care of inserting them as well + * into the list. + * + * @param list Which list to append the buffer to. + * @param buf Buffer. + */ +void net_buf_slist_put(sys_slist_t *list, struct net_buf *buf); + +/** + * @brief Get a buffer from a list. + * + * Get buffer from a list. If the buffer had any fragments, these will + * automatically be recovered from the list as well and be placed to + * the buffer's fragment list. + * + * @param list Which list to take the buffer from. + * + * @return New buffer or NULL if the FIFO is empty. + */ +struct net_buf *net_buf_slist_get(sys_slist_t *list); + +/** + * @brief Decrements the reference count of a buffer. + * + * Decrements the reference count of a buffer and puts it back into the + * pool if the count reaches zero. + * + * @param buf A valid pointer on a buffer + */ +#if defined(CONFIG_BLE_MESH_NET_BUF_LOG) +void net_buf_unref_debug(struct net_buf *buf, const char *func, int line); +#define net_buf_unref(_buf) \ + net_buf_unref_debug(_buf, __func__, __LINE__) +#else +void net_buf_unref(struct net_buf *buf); +#endif + +/** + * @brief Increment the reference count of a buffer. + * + * @param buf A valid pointer on a buffer + * + * @return the buffer newly referenced + */ +struct net_buf *net_buf_ref(struct net_buf *buf); + +/** + * @brief Get a pointer to the user data of a buffer. + * + * @param buf A valid pointer on a buffer + * + * @return Pointer to the user data of the buffer. + */ +static inline void *net_buf_user_data(struct net_buf *buf) +{ + return (void *)buf->user_data; +} + +/** + * @def net_buf_add + * @brief Prepare data to be added at the end of the buffer + * + * Increments the data length of a buffer to account for more data + * at the end. + * + * @param buf Buffer to update. + * @param len Number of bytes to increment the length with. + * + * @return The original tail of the buffer. + */ +#define net_buf_add(buf, len) net_buf_simple_add(&(buf)->b, len) + +/** + * @def net_buf_add_mem + * @brief Copy bytes from memory to the end of the buffer + * + * Copies the given number of bytes to the end of the buffer. Increments the + * data length of the buffer to account for more data at the end. + * + * @param buf Buffer to update. + * @param mem Location of data to be added. + * @param len Length of data to be added + * + * @return The original tail of the buffer. + */ +#define net_buf_add_mem(buf, mem, len) net_buf_simple_add_mem(&(buf)->b, mem, len) + +/** + * @def net_buf_add_u8 + * @brief Add (8-bit) byte at the end of the buffer + * + * Adds a byte at the end of the buffer. Increments the data length of + * the buffer to account for more data at the end. + * + * @param buf Buffer to update. + * @param val byte value to be added. + * + * @return Pointer to the value added + */ +#define net_buf_add_u8(buf, val) net_buf_simple_add_u8(&(buf)->b, val) + +/** + * @def net_buf_add_le16 + * @brief Add 16-bit value at the end of the buffer + * + * Adds 16-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 16-bit value to be added. + */ +#define net_buf_add_le16(buf, val) net_buf_simple_add_le16(&(buf)->b, val) + +/** + * @def net_buf_add_be16 + * @brief Add 16-bit value at the end of the buffer + * + * Adds 16-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 16-bit value to be added. + */ +#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 + * + * Adds 32-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 32-bit value to be added. + */ +#define net_buf_add_le32(buf, val) net_buf_simple_add_le32(&(buf)->b, val) + +/** + * @def net_buf_add_be32 + * @brief Add 32-bit value at the end of the buffer + * + * Adds 32-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 32-bit value to be added. + */ +#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. + * + * Modifies the data pointer and buffer length to account for more data + * in the beginning of the buffer. + * + * @param buf Buffer to update. + * @param len Number of bytes to add to the beginning. + * + * @return The new beginning of the buffer data. + */ +#define net_buf_push(buf, len) net_buf_simple_push(&(buf)->b, len) + +/** + * @def net_buf_push_le16 + * @brief Push 16-bit value to the beginning of the buffer + * + * Adds 16-bit value in little endian format to the beginning of the + * buffer. + * + * @param buf Buffer to update. + * @param val 16-bit value to be pushed to the buffer. + */ +#define net_buf_push_le16(buf, val) net_buf_simple_push_le16(&(buf)->b, val) + +/** + * @def net_buf_push_be16 + * @brief Push 16-bit value to the beginning of the buffer + * + * Adds 16-bit value in little endian format to the beginning of the + * buffer. + * + * @param buf Buffer to update. + * @param val 16-bit value to be pushed to the buffer. + */ +#define net_buf_push_be16(buf, val) net_buf_simple_push_be16(&(buf)->b, val) + +/** + * @def net_buf_push_u8 + * @brief Push 8-bit value to the beginning of the buffer + * + * Adds 8-bit value the beginning of the buffer. + * + * @param buf Buffer to update. + * @param val 8-bit value to be pushed to the buffer. + */ +#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. + * + * 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 New beginning of the buffer data. + */ +#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 + * + * Same idea as with net_buf_pull(), but a helper for operating on + * 8-bit values. + * + * @param buf A valid pointer on a buffer. + * + * @return The 8-bit removed value + */ +#define net_buf_pull_u8(buf) net_buf_simple_pull_u8(&(buf)->b) + +/** + * @def net_buf_pull_le16 + * @brief Remove and convert 16 bits from the beginning of the buffer. + * + * Same idea as with net_buf_pull(), but a helper for operating on + * 16-bit little endian data. + * + * @param buf A valid pointer on a buffer. + * + * @return 16-bit value converted from little endian to host endian. + */ +#define net_buf_pull_le16(buf) net_buf_simple_pull_le16(&(buf)->b) + +/** + * @def net_buf_pull_be16 + * @brief Remove and convert 16 bits from the beginning of the buffer. + * + * Same idea as with net_buf_pull(), but a helper for operating on + * 16-bit big endian data. + * + * @param buf A valid pointer on a buffer. + * + * @return 16-bit value converted from big endian to host endian. + */ +#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. + * + * Same idea as with net_buf_pull(), but a helper for operating on + * 32-bit little endian data. + * + * @param buf A valid pointer on a buffer. + * + * @return 32-bit value converted from little endian to host endian. + */ +#define net_buf_pull_le32(buf) net_buf_simple_pull_le32(&(buf)->b) + +/** + * @def net_buf_pull_be32 + * @brief Remove and convert 32 bits from the beginning of the buffer. + * + * Same idea as with net_buf_pull(), but a helper for operating on + * 32-bit big endian data. + * + * @param buf A valid pointer on a buffer + * + * @return 32-bit value converted from big endian to host endian. + */ +#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. + * + * Check how much free space there is at the end of the buffer. + * + * @param buf A valid pointer on a buffer + * + * @return Number of bytes available at the end of the buffer. + */ +#define net_buf_tailroom(buf) net_buf_simple_tailroom(&(buf)->b) + +/** + * @def net_buf_headroom + * @brief Check buffer headroom. + * + * Check how much free space there is in the beginning of the buffer. + * + * buf A valid pointer on a buffer + * + * @return Number of bytes available in the beginning of the buffer. + */ +#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)(int32_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, int32_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; +} + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* _BLE_MESH_BUF_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_byteorder.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_byteorder.h new file mode 100644 index 00000000000..0ccf2b5b9ea --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_byteorder.h @@ -0,0 +1,599 @@ +/* + * SPDX-FileCopyrightText: 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) ((uint16_t) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))) +#endif + +#ifndef __bswap_24 +#define __bswap_24(x) ((uint32_t) ((((x) >> 16) & 0xff) | \ + (((x)) & 0xff00) | \ + (((x) & 0xff) << 16))) +#endif + +#ifndef __bswap_32 +#define __bswap_32(x) ((uint32_t) ((((x) >> 24) & 0xff) | \ + (((x) >> 8) & 0xff00) | \ + (((x) & 0xff00) << 8) | \ + (((x) & 0xff) << 24))) +#endif + +#ifndef __bswap_48 +#define __bswap_48(x) ((uint64_t) ((((x) >> 40) & 0xff) | \ + (((x) >> 24) & 0xff00) | \ + (((x) >> 8) & 0xff0000) | \ + (((x) & 0xff0000) << 8) | \ + (((x) & 0xff00) << 24) | \ + (((x) & 0xff) << 40))) +#endif + +#ifndef __bswap_64 +#define __bswap_64(x) ((uint64_t) ((((x) >> 56) & 0xff) | \ + (((x) >> 40) & 0xff00) | \ + (((x) >> 24) & 0xff0000) | \ + (((x) >> 8) & 0xff000000) | \ + (((x) & 0xff000000) << 8) | \ + (((x) & 0xff0000) << 24) | \ + (((x) & 0xff00) << 40) | \ + (((x) & 0xff) << 56))) +#endif + +/** @def sys_le16_to_cpu + * @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(uint16_t val, uint8_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(uint32_t val, uint8_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(uint32_t val, uint8_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(uint64_t val, uint8_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(uint64_t val, uint8_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(uint16_t val, uint8_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(uint32_t val, uint8_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(uint32_t val, uint8_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(uint64_t val, uint8_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(uint64_t val, uint8_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 uint16_t sys_get_be16(const uint8_t src[2]) +{ + return ((uint16_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 uint32_t sys_get_be24(const uint8_t src[3]) +{ + return ((uint32_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 uint32_t sys_get_be32(const uint8_t src[4]) +{ + return ((uint32_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 uint64_t sys_get_be48(const uint8_t src[6]) +{ + return ((uint64_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 uint64_t sys_get_be64(const uint8_t src[8]) +{ + return ((uint64_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 uint16_t sys_get_le16(const uint8_t src[2]) +{ + return ((uint16_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 uint32_t sys_get_le24(const uint8_t src[3]) +{ + return ((uint32_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 uint32_t sys_get_le32(const uint8_t src[4]) +{ + return ((uint32_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 uint64_t sys_get_le48(const uint8_t src[6]) +{ + return ((uint64_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 uint64_t sys_get_le64(const uint8_t src[8]) +{ + return ((uint64_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) +{ + uint8_t *pdst = (uint8_t *)dst; + const uint8_t *psrc = (const uint8_t *)src; + + __ASSERT(((psrc < pdst && (psrc + length) <= pdst) || + (psrc > pdst && (pdst + length) <= psrc)), + "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++) { + uint8_t tmp = ((uint8_t *)buf)[i]; + + ((uint8_t *)buf)[i] = ((uint8_t *)buf)[length - 1 - i]; + ((uint8_t *)buf)[length - 1 - i] = tmp; + } +} + +#ifdef __cplusplus +} +#endif + +#endif /* _BLE_MESH_BYTEORDER_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_common.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_common.h new file mode 100644 index 00000000000..42e28be696e --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_common.h @@ -0,0 +1,74 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** @file + * @brief Bluetooth Mesh Model Common APIs. + */ + +#ifndef _BLE_MESH_COMMON_H_ +#define _BLE_MESH_COMMON_H_ + +#include +#include + +#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. + * + * @param[in] size: Length of memory allocated to store message value + * + * @return NULL-fail, pointer of a net_buf_simple structure-success + */ +struct net_buf_simple *bt_mesh_alloc_buf(uint16_t size); + +/** + * @brief This function releases the memory allocated for the outgoing message. + * + * @param[in] buf: Pointer to the net_buf_simple structure to be freed + * + * @return none + */ +void bt_mesh_free_buf(struct net_buf_simple *buf); + +/** + * @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 + */ +uint8_t bt_mesh_get_device_role(struct bt_mesh_model *model, bool srv_send); + +int bt_mesh_rand(void *buf, size_t len); + +#ifdef __cplusplus +} +#endif + +#endif /* _BLE_MESH_COMMON_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_compiler.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_compiler.h new file mode 100644 index 00000000000..c73e8dfbc06 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_compiler.h @@ -0,0 +1,80 @@ +/* + * SPDX-FileCopyrightText: 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_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_config.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_config.h new file mode 100644 index 00000000000..d75a4588c31 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_config.h @@ -0,0 +1,47 @@ +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _BLE_MESH_CONFIG_H_ +#define _BLE_MESH_CONFIG_H_ + +#include "sdkconfig.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define CONFIG_BLE_MESH_GENERIC_CLIENT (CONFIG_BLE_MESH_GENERIC_ONOFF_CLI || \ + CONFIG_BLE_MESH_GENERIC_LEVEL_CLI || \ + CONFIG_BLE_MESH_GENERIC_DEF_TRANS_TIME_CLI || \ + CONFIG_BLE_MESH_GENERIC_POWER_ONOFF_CLI || \ + CONFIG_BLE_MESH_GENERIC_POWER_LEVEL_CLI || \ + CONFIG_BLE_MESH_GENERIC_BATTERY_CLI || \ + CONFIG_BLE_MESH_GENERIC_LOCATION_CLI || \ + CONFIG_BLE_MESH_GENERIC_PROPERTY_CLI) + +#define CONFIG_BLE_MESH_TIME_SCENE_CLIENT (CONFIG_BLE_MESH_TIME_CLI || \ + CONFIG_BLE_MESH_SCENE_CLI || \ + CONFIG_BLE_MESH_SCHEDULER_CLI) + +#define CONFIG_BLE_MESH_LIGHTING_CLIENT (CONFIG_BLE_MESH_LIGHT_LIGHTNESS_CLI || \ + CONFIG_BLE_MESH_LIGHT_CTL_CLI || \ + CONFIG_BLE_MESH_LIGHT_HSL_CLI || \ + CONFIG_BLE_MESH_LIGHT_XYL_CLI || \ + CONFIG_BLE_MESH_LIGHT_LC_CLI) + +#define CONFIG_BLE_MESH_SERVER_MODEL (CONFIG_BLE_MESH_GENERIC_SERVER || \ + CONFIG_BLE_MESH_SENSOR_SERVER || \ + CONFIG_BLE_MESH_TIME_SCENE_SERVER || \ + CONFIG_BLE_MESH_LIGHTING_SERVER) + +#define CONFIG_BLE_MESH_BLE_COEX_SUPPORT (CONFIG_BLE_MESH_SUPPORT_BLE_ADV || \ + CONFIG_BLE_MESH_SUPPORT_BLE_SCAN) + +#ifdef __cplusplus +} +#endif + +#endif /* _BLE_MESH_CONFIG_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_dlist.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_dlist.h new file mode 100644 index 00000000000..e21d08b761d --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_dlist.h @@ -0,0 +1,498 @@ +/* + * SPDX-FileCopyrightText: 2013-2015 Wind River Systems, Inc. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** + * @file + * @brief Doubly-linked list implementation + * + * Doubly-linked list implementation using inline macros/functions. + * This API is not thread safe, and thus if a list is used across threads, + * calls to functions must be protected with synchronization primitives. + * + * The lists are expected to be initialized such that both the head and tail + * pointers point to the list itself. Initializing the lists in such a fashion + * simplifies the adding and removing of nodes to/from the list. + */ + +#ifndef _BLE_MESH_DLIST_H_ +#define _BLE_MESH_DLIST_H_ + +#include +#include "mesh_util.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +struct _dnode { + union { + struct _dnode *head; /* ptr to head of list (sys_dlist_t) */ + struct _dnode *next; /* ptr to next node (sys_dnode_t) */ + }; + union { + struct _dnode *tail; /* ptr to tail of list (sys_dlist_t) */ + struct _dnode *prev; /* ptr to previous node (sys_dnode_t) */ + }; +}; + +typedef struct _dnode sys_dlist_t; +typedef struct _dnode sys_dnode_t; + +/** + * @brief Provide the primitive to iterate on a list + * Note: the loop is unsafe and thus __dn should not be removed + * + * User _MUST_ add the loop statement curly braces enclosing its own code: + * + * SYS_DLIST_FOR_EACH_NODE(l, n) { + * + * } + * + * This and other SYS_DLIST_*() macros are not thread safe. + * + * @param __dl A pointer on a sys_dlist_t to iterate on + * @param __dn A sys_dnode_t pointer to peek each node of the list + */ +#define SYS_DLIST_FOR_EACH_NODE(__dl, __dn) \ + for (__dn = sys_dlist_peek_head(__dl); __dn; \ + __dn = sys_dlist_peek_next(__dl, __dn)) + +/** + * @brief Provide the primitive to iterate on a list, from a node in the list + * Note: the loop is unsafe and thus __dn should not be removed + * + * User _MUST_ add the loop statement curly braces enclosing its own code: + * + * SYS_DLIST_ITERATE_FROM_NODE(l, n) { + * + * } + * + * Like SYS_DLIST_FOR_EACH_NODE(), but __dn already contains a node in the list + * where to start searching for the next entry from. If NULL, it starts from + * the head. + * + * This and other SYS_DLIST_*() macros are not thread safe. + * + * @param __dl A pointer on a sys_dlist_t to iterate on + * @param __dn A sys_dnode_t pointer to peek each node of the list; + * it contains the starting node, or NULL to start from the head + */ +#define SYS_DLIST_ITERATE_FROM_NODE(__dl, __dn) \ + for (__dn = __dn ? sys_dlist_peek_next_no_check(__dl, __dn) \ + : sys_dlist_peek_head(__dl); \ + __dn; \ + __dn = sys_dlist_peek_next(__dl, __dn)) + +/** + * @brief Provide the primitive to safely iterate on a list + * Note: __dn can be removed, it will not break the loop. + * + * User _MUST_ add the loop statement curly braces enclosing its own code: + * + * SYS_DLIST_FOR_EACH_NODE_SAFE(l, n, s) { + * + * } + * + * This and other SYS_DLIST_*() macros are not thread safe. + * + * @param __dl A pointer on a sys_dlist_t to iterate on + * @param __dn A sys_dnode_t pointer to peek each node of the list + * @param __dns A sys_dnode_t pointer for the loop to run safely + */ +#define SYS_DLIST_FOR_EACH_NODE_SAFE(__dl, __dn, __dns) \ + for (__dn = sys_dlist_peek_head(__dl), \ + __dns = sys_dlist_peek_next(__dl, __dn); \ + __dn; __dn = __dns, \ + __dns = sys_dlist_peek_next(__dl, __dn)) + +/* + * @brief Provide the primitive to resolve the container of a list node + * Note: it is safe to use with NULL pointer nodes + * + * @param __dn A pointer on a sys_dnode_t to get its container + * @param __cn Container struct type pointer + * @param __n The field name of sys_dnode_t within the container struct + */ +#define SYS_DLIST_CONTAINER(__dn, __cn, __n) \ + (__dn ? CONTAINER_OF(__dn, __typeof__(*__cn), __n) : NULL) +/* + * @brief Provide the primitive to peek container of the list head + * + * @param __dl A pointer on a sys_dlist_t to peek + * @param __cn Container struct type pointer + * @param __n The field name of sys_dnode_t within the container struct + */ +#define SYS_DLIST_PEEK_HEAD_CONTAINER(__dl, __cn, __n) \ + SYS_DLIST_CONTAINER(sys_dlist_peek_head(__dl), __cn, __n) + +/* + * @brief Provide the primitive to peek the next container + * + * @param __dl A pointer on a sys_dlist_t to peek + * @param __cn Container struct type pointer + * @param __n The field name of sys_dnode_t within the container struct + */ +#define SYS_DLIST_PEEK_NEXT_CONTAINER(__dl, __cn, __n) \ + ((__cn) ? SYS_DLIST_CONTAINER(sys_dlist_peek_next(__dl, &(__cn->__n)), \ + __cn, __n) : NULL) + +/** + * @brief Provide the primitive to iterate on a list under a container + * Note: the loop is unsafe and thus __cn should not be detached + * + * User _MUST_ add the loop statement curly braces enclosing its own code: + * + * SYS_DLIST_FOR_EACH_CONTAINER(l, c, n) { + * + * } + * + * @param __dl A pointer on a sys_dlist_t to iterate on + * @param __cn A pointer to peek each entry of the list + * @param __n The field name of sys_dnode_t within the container struct + */ +#define SYS_DLIST_FOR_EACH_CONTAINER(__dl, __cn, __n) \ + for (__cn = SYS_DLIST_PEEK_HEAD_CONTAINER(__dl, __cn, __n); __cn; \ + __cn = SYS_DLIST_PEEK_NEXT_CONTAINER(__dl, __cn, __n)) + +/** + * @brief Provide the primitive to safely iterate on a list under a container + * Note: __cn can be detached, it will not break the loop. + * + * User _MUST_ add the loop statement curly braces enclosing its own code: + * + * SYS_DLIST_FOR_EACH_CONTAINER_SAFE(l, c, cn, n) { + * + * } + * + * @param __dl A pointer on a sys_dlist_t to iterate on + * @param __cn A pointer to peek each entry of the list + * @param __cns A pointer for the loop to run safely + * @param __n The field name of sys_dnode_t within the container struct + */ +#define SYS_DLIST_FOR_EACH_CONTAINER_SAFE(__dl, __cn, __cns, __n) \ + for (__cn = SYS_DLIST_PEEK_HEAD_CONTAINER(__dl, __cn, __n), \ + __cns = SYS_DLIST_PEEK_NEXT_CONTAINER(__dl, __cn, __n); __cn; \ + __cn = __cns, \ + __cns = SYS_DLIST_PEEK_NEXT_CONTAINER(__dl, __cn, __n)) + +/** + * @brief initialize list + * + * @param list the doubly-linked list + * + * @return N/A + */ + +static inline void sys_dlist_init(sys_dlist_t *list) +{ + list->head = (sys_dnode_t *)list; + list->tail = (sys_dnode_t *)list; +} + +#define SYS_DLIST_STATIC_INIT(ptr_to_list) {{(ptr_to_list)}, {(ptr_to_list)}} + +/** + * @brief check if a node is the list's head + * + * @param list the doubly-linked list to operate on + * @param node the node to check + * + * @return 1 if node is the head, 0 otherwise + */ + +static inline int sys_dlist_is_head(sys_dlist_t *list, sys_dnode_t *node) +{ + return list->head == node; +} + +/** + * @brief check if a node is the list's tail + * + * @param list the doubly-linked list to operate on + * @param node the node to check + * + * @return 1 if node is the tail, 0 otherwise + */ + +static inline int sys_dlist_is_tail(sys_dlist_t *list, sys_dnode_t *node) +{ + return list->tail == node; +} + +/** + * @brief check if the list is empty + * + * @param list the doubly-linked list to operate on + * + * @return 1 if empty, 0 otherwise + */ + +static inline int sys_dlist_is_empty(sys_dlist_t *list) +{ + return list->head == list; +} + +/** + * @brief check if more than one node present + * + * This and other sys_dlist_*() functions are not thread safe. + * + * @param list the doubly-linked list to operate on + * + * @return 1 if multiple nodes, 0 otherwise + */ + +static inline int sys_dlist_has_multiple_nodes(sys_dlist_t *list) +{ + return list->head != list->tail; +} + +/** + * @brief get a reference to the head item in the list + * + * @param list the doubly-linked list to operate on + * + * @return a pointer to the head element, NULL if list is empty + */ + +static inline sys_dnode_t *sys_dlist_peek_head(sys_dlist_t *list) +{ + return sys_dlist_is_empty(list) ? NULL : list->head; +} + +/** + * @brief get a reference to the head item in the list + * + * The list must be known to be non-empty. + * + * @param list the doubly-linked list to operate on + * + * @return a pointer to the head element + */ + +static inline sys_dnode_t *sys_dlist_peek_head_not_empty(sys_dlist_t *list) +{ + return list->head; +} + +/** + * @brief get a reference to the next item in the list, node is not NULL + * + * Faster than sys_dlist_peek_next() if node is known not to be NULL. + * + * @param list the doubly-linked list to operate on + * @param node the node from which to get the next element in the list + * + * @return a pointer to the next element from a node, NULL if node is the tail + */ + +static inline sys_dnode_t *sys_dlist_peek_next_no_check(sys_dlist_t *list, + sys_dnode_t *node) +{ + return (node == list->tail) ? NULL : node->next; +} + +/** + * @brief get a reference to the next item in the list + * + * @param list the doubly-linked list to operate on + * @param node the node from which to get the next element in the list + * + * @return a pointer to the next element from a node, NULL if node is the tail + * or NULL (when node comes from reading the head of an empty list). + */ + +static inline sys_dnode_t *sys_dlist_peek_next(sys_dlist_t *list, + sys_dnode_t *node) +{ + return node ? sys_dlist_peek_next_no_check(list, node) : NULL; +} + +/** + * @brief get a reference to the tail item in the list + * + * @param list the doubly-linked list to operate on + * + * @return a pointer to the tail element, NULL if list is empty + */ + +static inline sys_dnode_t *sys_dlist_peek_tail(sys_dlist_t *list) +{ + return sys_dlist_is_empty(list) ? NULL : list->tail; +} + +/** + * @brief add node to tail of list + * + * This and other sys_dlist_*() functions are not thread safe. + * + * @param list the doubly-linked list to operate on + * @param node the element to append + * + * @return N/A + */ + +static inline void sys_dlist_append(sys_dlist_t *list, sys_dnode_t *node) +{ + node->next = list; + node->prev = list->tail; + + list->tail->next = node; + list->tail = node; +} + +/** + * @brief add node to head of list + * + * This and other sys_dlist_*() functions are not thread safe. + * + * @param list the doubly-linked list to operate on + * @param node the element to append + * + * @return N/A + */ + +static inline void sys_dlist_prepend(sys_dlist_t *list, sys_dnode_t *node) +{ + node->next = list->head; + node->prev = list; + + list->head->prev = node; + list->head = node; +} + +/** + * @brief insert node after a node + * + * Insert a node after a specified node in a list. + * This and other sys_dlist_*() functions are not thread safe. + * + * @param list the doubly-linked list to operate on + * @param insert_point the insert point in the list: if NULL, insert at head + * @param node the element to append + * + * @return N/A + */ + +static inline void sys_dlist_insert_after(sys_dlist_t *list, + sys_dnode_t *insert_point, + sys_dnode_t *node) +{ + if (!insert_point) { + sys_dlist_prepend(list, node); + } else { + node->next = insert_point->next; + node->prev = insert_point; + insert_point->next->prev = node; + insert_point->next = node; + } +} + +/** + * @brief insert node before a node + * + * Insert a node before a specified node in a list. + * This and other sys_dlist_*() functions are not thread safe. + * + * @param list the doubly-linked list to operate on + * @param insert_point the insert point in the list: if NULL, insert at tail + * @param node the element to insert + * + * @return N/A + */ + +static inline void sys_dlist_insert_before(sys_dlist_t *list, + sys_dnode_t *insert_point, + sys_dnode_t *node) +{ + if (!insert_point) { + sys_dlist_append(list, node); + } else { + node->prev = insert_point->prev; + node->next = insert_point; + insert_point->prev->next = node; + insert_point->prev = node; + } +} + +/** + * @brief insert node at position + * + * Insert a node in a location depending on a external condition. The cond() + * function checks if the node is to be inserted _before_ the current node + * against which it is checked. + * This and other sys_dlist_*() functions are not thread safe. + * + * @param list the doubly-linked list to operate on + * @param node the element to insert + * @param cond a function that determines if the current node is the correct + * insert point + * @param data parameter to cond() + * + * @return N/A + */ + +static inline void sys_dlist_insert_at(sys_dlist_t *list, sys_dnode_t *node, + int (*cond)(sys_dnode_t *, void *), void *data) +{ + if (sys_dlist_is_empty(list)) { + sys_dlist_append(list, node); + } else { + sys_dnode_t *pos = sys_dlist_peek_head(list); + + while (pos && !cond(pos, data)) { + pos = sys_dlist_peek_next(list, pos); + } + sys_dlist_insert_before(list, pos, node); + } +} + +/** + * @brief remove a specific node from a list + * + * The list is implicit from the node. The node must be part of a list. + * This and other sys_dlist_*() functions are not thread safe. + * + * @param node the node to remove + * + * @return N/A + */ + +static inline void sys_dlist_remove(sys_dnode_t *node) +{ + node->prev->next = node->next; + node->next->prev = node->prev; +} + +/** + * @brief get the first node in a list + * + * This and other sys_dlist_*() functions are not thread safe. + * + * @param list the doubly-linked list to operate on + * + * @return the first node in the list, NULL if list is empty + */ + +static inline sys_dnode_t *sys_dlist_get(sys_dlist_t *list) +{ + sys_dnode_t *node; + + if (sys_dlist_is_empty(list)) { + return NULL; + } + + node = list->head; + sys_dlist_remove(node); + return node; +} + +#ifdef __cplusplus +} +#endif + +#endif /* _BLE_MESH_DLIST_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_ffs.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_ffs.h new file mode 100644 index 00000000000..1173affbb4d --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_ffs.h @@ -0,0 +1,60 @@ +/* + * SPDX-FileCopyrightText: 2015 Wind River Systems, Inc. + * SPDX-FileCopyrightText: 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(uint32_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(uint32_t op) +{ + return __builtin_ffs(op); +} + +#ifdef __cplusplus +} +#endif + +#endif /* _BLE_MESH_FFS_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_kernel.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_kernel.h new file mode 100644 index 00000000000..b11e144e087 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_kernel.h @@ -0,0 +1,59 @@ +/* + * SPDX-FileCopyrightText: 2016 Wind River Systems, Inc. + * SPDX-FileContributor: 2020-2021 Espressif Systems (Shanghai) CO 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 "mesh_config.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(int32_t duration); + +#ifdef __cplusplus +} +#endif + +#endif /* _BLE_MESH_KERNEL_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_mutex.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_mutex.h new file mode 100644 index 00000000000..13d405bab09 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_mutex.h @@ -0,0 +1,49 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#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_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_slist.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_slist.h new file mode 100644 index 00000000000..aaeb5407cb0 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_slist.h @@ -0,0 +1,467 @@ +/* + * SPDX-FileCopyrightText: 2016 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** + * @file + * + * @brief Single-linked list implementation + * + * Single-linked list implementation using inline macros/functions. + * This API is not thread safe, and thus if a list is used across threads, + * calls to functions must be protected with synchronization primitives. + */ + +#ifndef _BLE_MESH_SLIST_H_ +#define _BLE_MESH_SLIST_H_ + +#include +#include +#include "mesh_util.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct _snode { + struct _snode *next; +}; + +typedef struct _snode sys_snode_t; + +struct _slist { + sys_snode_t *head; + sys_snode_t *tail; +}; + +typedef struct _slist sys_slist_t; + +/** + * @brief Provide the primitive to iterate on a list + * Note: the loop is unsafe and thus __sn should not be removed + * + * User _MUST_ add the loop statement curly braces enclosing its own code: + * + * SYS_SLIST_FOR_EACH_NODE(l, n) { + * + * } + * + * This and other SYS_SLIST_*() macros are not thread safe. + * + * @param __sl A pointer on a sys_slist_t to iterate on + * @param __sn A sys_snode_t pointer to peek each node of the list + */ +#define SYS_SLIST_FOR_EACH_NODE(__sl, __sn) \ + for (__sn = sys_slist_peek_head(__sl); __sn; \ + __sn = sys_slist_peek_next(__sn)) + +/** + * @brief Provide the primitive to iterate on a list, from a node in the list + * Note: the loop is unsafe and thus __sn should not be removed + * + * User _MUST_ add the loop statement curly braces enclosing its own code: + * + * SYS_SLIST_ITERATE_FROM_NODE(l, n) { + * + * } + * + * Like SYS_SLIST_FOR_EACH_NODE(), but __dn already contains a node in the list + * where to start searching for the next entry from. If NULL, it starts from + * the head. + * + * This and other SYS_SLIST_*() macros are not thread safe. + * + * @param __sl A pointer on a sys_slist_t to iterate on + * @param __sn A sys_snode_t pointer to peek each node of the list + * it contains the starting node, or NULL to start from the head + */ +#define SYS_SLIST_ITERATE_FROM_NODE(__sl, __sn) \ + for (__sn = __sn ? sys_slist_peek_next_no_check(__sn) \ + : sys_slist_peek_head(__sl); \ + __sn; \ + __sn = sys_slist_peek_next(__sn)) + +/** + * @brief Provide the primitive to safely iterate on a list + * Note: __sn can be removed, it will not break the loop. + * + * User _MUST_ add the loop statement curly braces enclosing its own code: + * + * SYS_SLIST_FOR_EACH_NODE_SAFE(l, n, s) { + * + * } + * + * This and other SYS_SLIST_*() macros are not thread safe. + * + * @param __sl A pointer on a sys_slist_t to iterate on + * @param __sn A sys_snode_t pointer to peek each node of the list + * @param __sns A sys_snode_t pointer for the loop to run safely + */ +#define SYS_SLIST_FOR_EACH_NODE_SAFE(__sl, __sn, __sns) \ + for (__sn = sys_slist_peek_head(__sl), \ + __sns = sys_slist_peek_next(__sn); \ + __sn; __sn = __sns, \ + __sns = sys_slist_peek_next(__sn)) + +/* + * @brief Provide the primitive to resolve the container of a list node + * Note: it is safe to use with NULL pointer nodes + * + * @param __ln A pointer on a sys_node_t to get its container + * @param __cn Container struct type pointer + * @param __n The field name of sys_node_t within the container struct + */ +#define SYS_SLIST_CONTAINER(__ln, __cn, __n) \ + ((__ln) ? CONTAINER_OF((__ln), __typeof__(*(__cn)), __n) : NULL) +/* + * @brief Provide the primitive to peek container of the list head + * + * @param __sl A pointer on a sys_slist_t to peek + * @param __cn Container struct type pointer + * @param __n The field name of sys_node_t within the container struct + */ +#define SYS_SLIST_PEEK_HEAD_CONTAINER(__sl, __cn, __n) \ + SYS_SLIST_CONTAINER(sys_slist_peek_head(__sl), __cn, __n) + +/* + * @brief Provide the primitive to peek container of the list tail + * + * @param __sl A pointer on a sys_slist_t to peek + * @param __cn Container struct type pointer + * @param __n The field name of sys_node_t within the container struct + */ +#define SYS_SLIST_PEEK_TAIL_CONTAINER(__sl, __cn, __n) \ + SYS_SLIST_CONTAINER(sys_slist_peek_tail(__sl), __cn, __n) + +/* + * @brief Provide the primitive to peek the next container + * + * @param __cn Container struct type pointer + * @param __n The field name of sys_node_t within the container struct + */ + +#define SYS_SLIST_PEEK_NEXT_CONTAINER(__cn, __n) \ + ((__cn) ? SYS_SLIST_CONTAINER(sys_slist_peek_next(&((__cn)->__n)), \ + __cn, __n) : NULL) + +/** + * @brief Provide the primitive to iterate on a list under a container + * Note: the loop is unsafe and thus __cn should not be detached + * + * User _MUST_ add the loop statement curly braces enclosing its own code: + * + * SYS_SLIST_FOR_EACH_CONTAINER(l, c, n) { + * + * } + * + * @param __sl A pointer on a sys_slist_t to iterate on + * @param __cn A pointer to peek each entry of the list + * @param __n The field name of sys_node_t within the container struct + */ +#define SYS_SLIST_FOR_EACH_CONTAINER(__sl, __cn, __n) \ + for (__cn = SYS_SLIST_PEEK_HEAD_CONTAINER(__sl, __cn, __n); __cn; \ + __cn = SYS_SLIST_PEEK_NEXT_CONTAINER(__cn, __n)) + +/** + * @brief Provide the primitive to safely iterate on a list under a container + * Note: __cn can be detached, it will not break the loop. + * + * User _MUST_ add the loop statement curly braces enclosing its own code: + * + * SYS_SLIST_FOR_EACH_NODE_SAFE(l, c, cn, n) { + * + * } + * + * @param __sl A pointer on a sys_slist_t to iterate on + * @param __cn A pointer to peek each entry of the list + * @param __cns A pointer for the loop to run safely + * @param __n The field name of sys_node_t within the container struct + */ +#define SYS_SLIST_FOR_EACH_CONTAINER_SAFE(__sl, __cn, __cns, __n) \ + for (__cn = SYS_SLIST_PEEK_HEAD_CONTAINER(__sl, __cn, __n), \ + __cns = SYS_SLIST_PEEK_NEXT_CONTAINER(__cn, __n); __cn; \ + __cn = __cns, __cns = SYS_SLIST_PEEK_NEXT_CONTAINER(__cn, __n)) + +/** + * @brief Initialize a list + * + * @param list A pointer on the list to initialize + */ +static inline void sys_slist_init(sys_slist_t *list) +{ + list->head = NULL; + list->tail = NULL; +} + +#define SYS_SLIST_STATIC_INIT(ptr_to_list) {NULL, NULL} + +/** + * @brief Test if the given list is empty + * + * @param list A pointer on the list to test + * + * @return a boolean, true if it's empty, false otherwise + */ +static inline bool sys_slist_is_empty(sys_slist_t *list) +{ + return (!list->head); +} + +/** + * @brief Peek the first node from the list + * + * @param list A point on the list to peek the first node from + * + * @return A pointer on the first node of the list (or NULL if none) + */ +static inline sys_snode_t *sys_slist_peek_head(sys_slist_t *list) +{ + return list->head; +} + +/** + * @brief Peek the last node from the list + * + * @param list A point on the list to peek the last node from + * + * @return A pointer on the last node of the list (or NULL if none) + */ +static inline sys_snode_t *sys_slist_peek_tail(sys_slist_t *list) +{ + return list->tail; +} + +/** + * @brief Peek the next node from current node, node is not NULL + * + * Faster then sys_slist_peek_next() if node is known not to be NULL. + * + * @param node A pointer on the node where to peek the next node + * + * @return a pointer on the next node (or NULL if none) + */ +static inline sys_snode_t *sys_slist_peek_next_no_check(sys_snode_t *node) +{ + return node->next; +} + +/** + * @brief Peek the next node from current node + * + * @param node A pointer on the node where to peek the next node + * + * @return a pointer on the next node (or NULL if none) + */ +static inline sys_snode_t *sys_slist_peek_next(sys_snode_t *node) +{ + return node ? sys_slist_peek_next_no_check(node) : NULL; +} + +/** + * @brief Prepend a node to the given list + * + * This and other sys_slist_*() functions are not thread safe. + * + * @param list A pointer on the list to affect + * @param node A pointer on the node to prepend + */ +static inline void sys_slist_prepend(sys_slist_t *list, + sys_snode_t *node) +{ + node->next = list->head; + list->head = node; + + if (!list->tail) { + list->tail = list->head; + } +} + +/** + * @brief Append a node to the given list + * + * This and other sys_slist_*() functions are not thread safe. + * + * @param list A pointer on the list to affect + * @param node A pointer on the node to append + */ +static inline void sys_slist_append(sys_slist_t *list, + sys_snode_t *node) +{ + node->next = NULL; + + if (!list->tail) { + list->tail = node; + list->head = node; + } else { + list->tail->next = node; + list->tail = node; + } +} + +/** + * @brief Append a list to the given list + * + * Append a singly-linked, NULL-terminated list consisting of nodes containing + * the pointer to the next node as the first element of a node, to @a list. + * This and other sys_slist_*() functions are not thread safe. + * + * @param list A pointer on the list to affect + * @param head A pointer to the first element of the list to append + * @param tail A pointer to the last element of the list to append + */ +static inline void sys_slist_append_list(sys_slist_t *list, + void *head, void *tail) +{ + if (!list->tail) { + list->head = (sys_snode_t *)head; + list->tail = (sys_snode_t *)tail; + } else { + list->tail->next = (sys_snode_t *)head; + list->tail = (sys_snode_t *)tail; + } +} + +/** + * @brief merge two slists, appending the second one to the first + * + * When the operation is completed, the appending list is empty. + * This and other sys_slist_*() functions are not thread safe. + * + * @param list A pointer on the list to affect + * @param list_to_append A pointer to the list to append. + */ +static inline void sys_slist_merge_slist(sys_slist_t *list, + sys_slist_t *list_to_append) +{ + sys_slist_append_list(list, list_to_append->head, + list_to_append->tail); + sys_slist_init(list_to_append); +} + +/** + * @brief Insert a node to the given list + * + * This and other sys_slist_*() functions are not thread safe. + * + * @param list A pointer on the list to affect + * @param prev A pointer on the previous node + * @param node A pointer on the node to insert + */ +static inline void sys_slist_insert(sys_slist_t *list, + sys_snode_t *prev, + sys_snode_t *node) +{ + if (!prev) { + sys_slist_prepend(list, node); + } else if (!prev->next) { + sys_slist_append(list, node); + } else { + node->next = prev->next; + prev->next = node; + } +} + +/** + * @brief Fetch and remove the first node of the given list + * + * List must be known to be non-empty. + * This and other sys_slist_*() functions are not thread safe. + * + * @param list A pointer on the list to affect + * + * @return A pointer to the first node of the list + */ +static inline sys_snode_t *sys_slist_get_not_empty(sys_slist_t *list) +{ + sys_snode_t *node = list->head; + + list->head = node->next; + if (list->tail == node) { + list->tail = list->head; + } + + return node; +} + +/** + * @brief Fetch and remove the first node of the given list + * + * This and other sys_slist_*() functions are not thread safe. + * + * @param list A pointer on the list to affect + * + * @return A pointer to the first node of the list (or NULL if empty) + */ +static inline sys_snode_t *sys_slist_get(sys_slist_t *list) +{ + return sys_slist_is_empty(list) ? NULL : sys_slist_get_not_empty(list); +} + +/** + * @brief Remove a node + * + * This and other sys_slist_*() functions are not thread safe. + * + * @param list A pointer on the list to affect + * @param prev_node A pointer on the previous node + * (can be NULL, which means the node is the list's head) + * @param node A pointer on the node to remove + */ +static inline void sys_slist_remove(sys_slist_t *list, + sys_snode_t *prev_node, + sys_snode_t *node) +{ + if (!prev_node) { + list->head = node->next; + + /* Was node also the tail? */ + if (list->tail == node) { + list->tail = list->head; + } + } else { + prev_node->next = node->next; + + /* Was node the tail? */ + if (list->tail == node) { + list->tail = prev_node; + } + } + + node->next = NULL; +} + +/** + * @brief Find and remove a node from a list + * + * This and other sys_slist_*() functions are not thread safe. + * + * @param list A pointer on the list to affect + * @param node A pointer on the node to remove from the list + * + * @return true if node was removed + */ +static inline bool sys_slist_find_and_remove(sys_slist_t *list, + sys_snode_t *node) +{ + sys_snode_t *prev = NULL; + sys_snode_t *test; + + SYS_SLIST_FOR_EACH_NODE(list, test) { + if (test == node) { + sys_slist_remove(list, prev, node); + return true; + } + + prev = test; + } + + return false; +} + +#ifdef __cplusplus +} +#endif + +#endif /* _BLE_MESH_SLIST_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_timer.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_timer.h new file mode 100644 index 00000000000..5399c4e5c73 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_timer.h @@ -0,0 +1,266 @@ +/* + * SPDX-FileCopyrightText: 2016 Wind River Systems, Inc. + * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _BLE_MESH_TIMER_H_ +#define _BLE_MESH_TIMER_H_ + +#include "mesh_types.h" +#include "mesh_slist.h" +#include "mesh_atomic.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* number of nsec per usec */ +#define NSEC_PER_USEC 1000 + +/* number of microseconds per millisecond */ +#define USEC_PER_MSEC 1000 + +/* number of milliseconds per second */ +#define MSEC_PER_SEC 1000 + +/* number of microseconds per second */ +#define USEC_PER_SEC ((USEC_PER_MSEC) * (MSEC_PER_SEC)) + +/* number of nanoseconds per second */ +#define NSEC_PER_SEC ((NSEC_PER_USEC) * (USEC_PER_MSEC) * (MSEC_PER_SEC)) + +/* timeout is not in use */ +#define _INACTIVE (-1) + +struct k_work; + +/** + * @typedef k_work_handler_t + * @brief Work item handler function type. + * + * A work item's handler function is executed by a workqueue's thread + * when the work item is processed by the workqueue. + * + * @param work Address of the work item. + * + * @return N/A + */ +typedef void (*k_work_handler_t)(struct k_work *work); + +struct k_work { + void *_reserved; + k_work_handler_t handler; + int index; +}; + +#define _K_WORK_INITIALIZER(work_handler) \ +{ \ + ._reserved = NULL, \ + .handler = work_handler, \ +} + +/** + * @brief Generate null timeout delay. + * + * This macro generates a timeout delay that that instructs a kernel API + * not to wait if the requested operation cannot be performed immediately. + * + * @return Timeout delay value. + */ +#define K_NO_WAIT 0 + +/** + * @brief Generate timeout delay from milliseconds. + * + * This macro generates a timeout delay that that instructs a kernel API + * to wait up to @a ms milliseconds to perform the requested operation. + * + * @param ms Duration in milliseconds. + * + * @return Timeout delay value. + */ +#define K_MSEC(ms) (ms) + +/** + * @brief Generate timeout delay from seconds. + * + * This macro generates a timeout delay that that instructs a kernel API + * to wait up to @a s seconds to perform the requested operation. + * + * @param s Duration in seconds. + * + * @return Timeout delay value. + */ +#define K_SECONDS(s) K_MSEC((s) * MSEC_PER_SEC) + +/** + * @brief Generate timeout delay from minutes. + * + * This macro generates a timeout delay that that instructs a kernel API + * to wait up to @a m minutes to perform the requested operation. + * + * @param m Duration in minutes. + * + * @return Timeout delay value. + */ +#define K_MINUTES(m) K_SECONDS((m) * 60) + +/** + * @brief Generate timeout delay from hours. + * + * This macro generates a timeout delay that that instructs a kernel API + * to wait up to @a h hours to perform the requested operation. + * + * @param h Duration in hours. + * + * @return Timeout delay value. + */ +#define K_HOURS(h) K_MINUTES((h) * 60) + +/** + * @brief Generate infinite timeout delay. + * + * This macro generates a timeout delay that that instructs a kernel API + * to wait as long as necessary to perform the requested operation. + * + * @return Timeout delay value. + */ +#define K_FOREVER (-1) + +/** + * @brief Get system uptime (32-bit version). + * + * This routine returns the lower 32-bits of the elapsed time since the system + * booted, in milliseconds. + * + * This routine can be more efficient than k_uptime_get(), as it reduces the + * need for interrupt locking and 64-bit math. However, the 32-bit result + * cannot hold a system uptime time larger than approximately 50 days, so the + * caller must handle possible rollovers. + * + * @return Current uptime. + */ +uint32_t k_uptime_get_32(void); + +struct k_delayed_work { + struct k_work work; +}; + +/** + * @brief Submit a delayed work item to the system workqueue. + * + * This routine schedules work item @a work to be processed by the system + * workqueue after a delay of @a delay milliseconds. The routine initiates + * an asynchronous countdown for the work item and then returns to the caller. + * Only when the countdown completes is the work item actually submitted to + * the workqueue and becomes pending. + * + * Submitting a previously submitted delayed work item that is still + * counting down cancels the existing submission and restarts the countdown + * using the new delay. If the work item is currently pending on the + * workqueue's queue because the countdown has completed it is too late to + * resubmit the item, and resubmission fails without impacting the work item. + * If the work item has already been processed, or is currently being processed, + * its work is considered complete and the work item can be resubmitted. + * + * @warning + * Work items submitted to the system workqueue should avoid using handlers + * that block or yield since this may prevent the system workqueue from + * processing other work items in a timely manner. + * + * @note Can be called by ISRs. + * + * @param work Address of delayed work item. + * @param delay Delay before submitting the work item (in milliseconds). + * + * @retval 0 Work item countdown started. + * @retval -EINPROGRESS Work item is already pending. + * @retval -EINVAL Work item is being processed or has completed its work. + * @retval -EADDRINUSE Work item is pending on a different workqueue. + */ +int k_delayed_work_submit(struct k_delayed_work *work, int32_t delay); + +int k_delayed_work_submit_periodic(struct k_delayed_work *work, int32_t period); + +/** + * @brief Get time remaining before a delayed work gets scheduled. + * + * This routine computes the (approximate) time remaining before a + * delayed work gets executed. If the delayed work is not waiting to be + * scheduled, it returns zero. + * + * @param work Delayed work item. + * + * @return Remaining time (in milliseconds). + */ +int32_t k_delayed_work_remaining_get(struct k_delayed_work *work); + +/** + * @brief Submit a work item to the system workqueue. + * + * This routine submits work item @a work to be processed by the system + * workqueue. If the work item is already pending in the workqueue's queue + * as a result of an earlier submission, this routine has no effect on the + * work item. If the work item has already been processed, or is currently + * being processed, its work is considered complete and the work item can be + * resubmitted. + * + * @warning + * Work items submitted to the system workqueue should avoid using handlers + * that block or yield since this may prevent the system workqueue from + * processing other work items in a timely manner. + * + * @note Can be called by ISRs. + * + * @param work Address of work item. + * + * @return N/A + */ +static inline void k_work_submit(struct k_work *work) +{ + if (work && work->handler) { + work->handler(work); + } +} + +/** + * @brief Initialize a work item. + * + * This routine initializes a workqueue work item, prior to its first use. + * + * @param work Address of work item. + * @param handler Function to invoke each time work item is processed. + * + * @return N/A + */ +static inline void k_work_init(struct k_work *work, k_work_handler_t handler) +{ + work->handler = handler; +} + +int k_delayed_work_cancel(struct k_delayed_work *work); + +int k_delayed_work_free(struct k_delayed_work *work); + +int k_delayed_work_init(struct k_delayed_work *work, k_work_handler_t handler); + +/** + * @brief Get system uptime. + * + * This routine returns the elapsed time since the system booted, + * in milliseconds. + * + * @return Current uptime. + */ +int64_t k_uptime_get(void); + +void bt_mesh_timer_init(void); +void bt_mesh_timer_deinit(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _BLE_MESH_TIMER_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_trace.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_trace.h new file mode 100644 index 00000000000..72ad111ac3e --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_trace.h @@ -0,0 +1,127 @@ +/* + * SPDX-FileCopyrightText: 2017 Nordic Semiconductor ASA + * SPDX-FileCopyrightText: 2015-2016 Intel Corporation + * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _BLE_MESH_TRACE_H_ +#define _BLE_MESH_TRACE_H_ + +#include +#include "esp_log.h" +#include "mesh_util.h" +#include "esp_rom_sys.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Define common tracing for all */ +#ifndef BLE_MESH_LOG_LEVEL_ERROR +#define BLE_MESH_LOG_LEVEL_ERROR 1 +#endif /* BLE_MESH_LOG_LEVEL_ERROR */ + +#ifndef BLE_MESH_LOG_LEVEL_WARN +#define BLE_MESH_LOG_LEVEL_WARN 2 +#endif /* BLE_MESH_LOG_LEVEL_WARN */ + +#ifndef BLE_MESH_LOG_LEVEL_INFO +#define BLE_MESH_LOG_LEVEL_INFO 3 +#endif /* BLE_MESH_LOG_LEVEL_INFO */ + +#ifndef BLE_MESH_LOG_LEVEL_DEBUG +#define BLE_MESH_LOG_LEVEL_DEBUG 4 +#endif /* BLE_MESH_LOG_LEVEL_DEBUG */ + +#ifndef BLE_MESH_LOG_LEVEL_VERBOSE +#define BLE_MESH_LOG_LEVEL_VERBOSE 5 +#endif /*BLE_MESH_LOG_LEVEL_VERBOSE */ + +#ifdef CONFIG_BLE_MESH_STACK_TRACE_LEVEL +#define BLE_MESH_LOG_LEVEL CONFIG_BLE_MESH_STACK_TRACE_LEVEL +#else +#define BLE_MESH_LOG_LEVEL BLE_MESH_LOG_LEVEL_WARN +#endif + +#ifdef CONFIG_BLE_MESH_NET_BUF_TRACE_LEVEL +#define BLE_MESH_NET_BUF_LOG_LEVEL CONFIG_BLE_MESH_NET_BUF_TRACE_LEVEL +#else +#define BLE_MESH_NET_BUF_LOG_LEVEL BLE_MESH_LOG_LEVEL_WARN +#endif + +#define BLE_MESH_TRACE_TAG "BLE_MESH" + +#if (LOG_LOCAL_LEVEL >= 4) +#define BLE_MESH_LOG_LOCAL_LEVEL_MAPPING (LOG_LOCAL_LEVEL + 1) +#else +#define BLE_MESH_LOG_LOCAL_LEVEL_MAPPING LOG_LOCAL_LEVEL +#endif + +#define BLE_MESH_LOG_LEVEL_CHECK(LAYER, LEVEL) (MAX(LAYER##_LOG_LEVEL, BLE_MESH_LOG_LOCAL_LEVEL_MAPPING) >= BLE_MESH_LOG_LEVEL_##LEVEL) + +#define BLE_MESH_PRINT_E(tag, format, ...) {esp_log_write(ESP_LOG_ERROR, tag, LOG_FORMAT(E, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } +#define BLE_MESH_PRINT_W(tag, format, ...) {esp_log_write(ESP_LOG_WARN, tag, LOG_FORMAT(W, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } +#define BLE_MESH_PRINT_I(tag, format, ...) {esp_log_write(ESP_LOG_INFO, tag, LOG_FORMAT(I, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } +#define BLE_MESH_PRINT_D(tag, format, ...) {esp_log_write(ESP_LOG_DEBUG, tag, LOG_FORMAT(D, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } +#define BLE_MESH_PRINT_V(tag, format, ...) {esp_log_write(ESP_LOG_VERBOSE, tag, LOG_FORMAT(V, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } + +#define printk esp_rom_printf + +#define _STRINGIFY(x) #x +#define STRINGIFY(s) _STRINGIFY(s) + +#ifndef __ASSERT +#define __ASSERT(test, str) assert(test) +#endif + +#ifndef __ASSERT_NO_MSG +#define __ASSERT_NO_MSG(x) assert(x) +#endif + +#if !CONFIG_BLE_MESH_NO_LOG +#define BT_ERR(fmt, args...) do {if ((BLE_MESH_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_ERROR) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH, ERROR)) BLE_MESH_PRINT_E(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0) +#define BT_WARN(fmt, args...) do {if ((BLE_MESH_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_WARN) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH, WARN)) BLE_MESH_PRINT_W(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0) +#define BT_INFO(fmt, args...) do {if ((BLE_MESH_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_INFO) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH, INFO)) BLE_MESH_PRINT_I(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0) +#define BT_DBG(fmt, args...) do {if ((BLE_MESH_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_DEBUG) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH, DEBUG)) BLE_MESH_PRINT_D(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0) +#else +#define BT_ERR(fmt, args...) +#define BT_WARN(fmt, args...) +#define BT_INFO(fmt, args...) +#define BT_DBG(fmt, args...) +#endif + +#if defined(CONFIG_BLE_MESH_NET_BUF_LOG) && (!CONFIG_BLE_MESH_NO_LOG) +#define NET_BUF_ERR(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_ERROR) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, ERROR)) BLE_MESH_PRINT_E(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0) +#define NET_BUF_WARN(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_WARN) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, WARN)) BLE_MESH_PRINT_W(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0) +#define NET_BUF_INFO(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_INFO) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, INFO)) BLE_MESH_PRINT_I(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0) +#define NET_BUF_DBG(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_DEBUG) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, DEBUG)) BLE_MESH_PRINT_D(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0) +#define NET_BUF_ASSERT(cond) __ASSERT_NO_MSG(cond) +#else +#define NET_BUF_ERR(fmt, args...) +#define NET_BUF_WARN(fmt, args...) +#define NET_BUF_INFO(fmt, args...) +#define NET_BUF_DBG(fmt, args...) +#define NET_BUF_ASSERT(cond) +#endif + +#if defined(CONFIG_BLE_MESH_NET_BUF_SIMPLE_LOG) && (!CONFIG_BLE_MESH_NO_LOG) +#define NET_BUF_SIMPLE_ERR(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_ERROR) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, ERROR)) BLE_MESH_PRINT_E(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0) +#define NET_BUF_SIMPLE_WARN(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_WARN) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, WARN)) BLE_MESH_PRINT_W(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0) +#define NET_BUF_SIMPLE_INFO(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_INFO) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, INFO)) BLE_MESH_PRINT_I(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0) +#define NET_BUF_SIMPLE_DBG(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_DEBUG) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, DEBUG)) BLE_MESH_PRINT_D(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0) +#define NET_BUF_SIMPLE_ASSERT(cond) __ASSERT_NO_MSG(cond) +#else +#define NET_BUF_SIMPLE_ERR(fmt, args...) +#define NET_BUF_SIMPLE_WARN(fmt, args...) +#define NET_BUF_SIMPLE_INFO(fmt, args...) +#define NET_BUF_SIMPLE_DBG(fmt, args...) +#define NET_BUF_SIMPLE_ASSERT(cond) +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _BLE_MESH_TRACE_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_types.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_types.h new file mode 100644 index 00000000000..eba8c1a2063 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_types.h @@ -0,0 +1,33 @@ +/* + * SPDX-FileCopyrightText: 2017 Linaro Limited + * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _BLE_MESH_TYPES_H_ +#define _BLE_MESH_TYPES_H_ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef int bt_mesh_atomic_t; + +#ifndef PRIu64 +#define PRIu64 "llu" +#endif + +#ifndef PRIx64 +#define PRIx64 "llx" +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _BLE_MESH_TYPES_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_util.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_util.h new file mode 100644 index 00000000000..c12c8d70a65 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/include/mesh_util.h @@ -0,0 +1,191 @@ +/* + * SPDX-FileCopyrightText: 2011-2014 Wind River Systems, Inc. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** + * @file + * @brief Misc utilities + * + * Misc utilities usable by the kernel and application code. + */ + +#ifndef _BLE_MESH_UTIL_H_ +#define _BLE_MESH_UTIL_H_ + +#include +#include "esp_bit_defs.h" +#include "mesh_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Helper to pass a int as a pointer or vice-versa. + * Those are available for 32 bits architectures: + */ +#ifndef POINTER_TO_UINT +#define POINTER_TO_UINT(x) ((uint32_t) (x)) +#endif +#ifndef UINT_TO_POINTER +#define UINT_TO_POINTER(x) ((void *) (x)) +#endif +#ifndef POINTER_TO_INT +#define POINTER_TO_INT(x) ((int32_t) (x)) +#endif +#ifndef INT_TO_POINTER +#define INT_TO_POINTER(x) ((void *) (x)) +#endif + +/* Evaluates to 0 if cond is true-ish; compile error otherwise */ +#ifndef ZERO_OR_COMPILE_ERROR +#define ZERO_OR_COMPILE_ERROR(cond) ((int) sizeof(char[1 - 2 * !(cond)]) - 1) +#endif + +/* Evaluates to 0 if array is an array; compile error if not array (e.g. + * pointer) + */ +#ifndef IS_ARRAY +#define IS_ARRAY(array) \ + ZERO_OR_COMPILE_ERROR( \ + !__builtin_types_compatible_p(__typeof__(array), \ + __typeof__(&(array)[0]))) +#endif + +/* Evaluates to number of elements in an array; compile error if not + * an array (e.g. pointer) + */ +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) +#endif + +/* Evaluates to 1 if ptr is part of array, 0 otherwise; compile error if + * "array" argument is not an array (e.g. "ptr" and "array" mixed up) + */ +#ifndef PART_OF_ARRAY +#define PART_OF_ARRAY(array, ptr) \ + ((ptr) && ((ptr) >= &array[0] && (ptr) < &array[ARRAY_SIZE(array)])) +#endif + +#ifndef CONTAINER_OF +#define CONTAINER_OF(ptr, type, field) \ + ((type *)(((char *)(ptr)) - offsetof(type, field))) +#endif + +/* round "x" up/down to next multiple of "align" (which must be a power of 2) */ +#ifndef ROUND_UP +#define ROUND_UP(x, align) \ + (((unsigned long)(x) + ((unsigned long)align - 1)) & \ + ~((unsigned long)align - 1)) +#endif + +#ifndef ROUND_DOWN +#define ROUND_DOWN(x, align) ((unsigned long)(x) & ~((unsigned long)align - 1)) +#endif + +/* round up/down to the next word boundary */ +#ifndef WB_UP +#define WB_UP(x) ROUND_UP(x, sizeof(void *)) +#endif + +#ifndef WB_DN +#define WB_DN(x) ROUND_DOWN(x, sizeof(void *)) +#endif + +#ifndef ceiling_fraction +#define ceiling_fraction(numerator, divider) \ + (((numerator) + ((divider) - 1)) / (divider)) +#endif + +#ifndef CHECKIF +#define CHECKIF(expr) if (expr) +#endif + +/** @brief Return larger value of two provided expressions. + * + * @note Arguments are evaluated twice. See Z_MAX for GCC only, single + * evaluation version. + */ +#ifndef MAX +#define MAX(a, b) (((a) > (b)) ? (a) : (b)) +#endif + +/** @brief Return smaller value of two provided expressions. + * + * @note Arguments are evaluated twice. See Z_MIN for GCC only, single + * evaluation version. + */ +#ifndef MIN +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) +#endif + +#ifndef BIT +#define BIT(n) (1UL << (n)) +#endif + +#ifndef BIT_MASK +#define BIT_MASK(n) (BIT(n) - 1) +#endif + +/** + * @brief Check for macro definition in compiler-visible expressions + * + * This trick was pioneered in Linux as the config_enabled() macro. + * The madness has the effect of taking a macro value that may be + * defined to "1" (e.g. CONFIG_MYFEATURE), or may not be defined at + * all and turning it into a literal expression that can be used at + * "runtime". That is, it works similarly to + * "defined(CONFIG_MYFEATURE)" does except that it is an expansion + * that can exist in a standard expression and be seen by the compiler + * and optimizer. Thus much ifdef usage can be replaced with cleaner + * expressions like: + * + * if (IS_ENABLED(CONFIG_MYFEATURE)) + * myfeature_enable(); + * + * INTERNAL + * First pass just to expand any existing macros, we need the macro + * value to be e.g. a literal "1" at expansion time in the next macro, + * not "(1)", etc... Standard recursive expansion does not work. + */ +#define IS_ENABLED(config_macro) Z_IS_ENABLED1(config_macro) + +/* Now stick on a "_XXXX" prefix, it will now be "_XXXX1" if config_macro + * is "1", or just "_XXXX" if it's undefined. + * ENABLED: Z_IS_ENABLED2(_XXXX1) + * DISABLED Z_IS_ENABLED2(_XXXX) + */ +#define Z_IS_ENABLED1(config_macro) Z_IS_ENABLED2(_XXXX##config_macro) + +/* Here's the core trick, we map "_XXXX1" to "_YYYY," (i.e. a string + * with a trailing comma), so it has the effect of making this a + * two-argument tuple to the preprocessor only in the case where the + * value is defined to "1" + * ENABLED: _YYYY, <--- note comma! + * DISABLED: _XXXX + */ +#define _XXXX1 _YYYY, + +/* Then we append an extra argument to fool the gcc preprocessor into + * accepting it as a varargs macro. + * arg1 arg2 arg3 + * ENABLED: Z_IS_ENABLED3(_YYYY, 1, 0) + * DISABLED Z_IS_ENABLED3(_XXXX 1, 0) + */ +#define Z_IS_ENABLED2(one_or_two_args) Z_IS_ENABLED3(one_or_two_args true, false) + +/* And our second argument is thus now cooked to be 1 in the case + * where the value is defined to 1, and 0 if not: + */ +#define Z_IS_ENABLED3(ignore_this, val, ...) val + +const char *bt_hex(const void *buf, size_t len); + +void mem_rcopy(uint8_t *dst, uint8_t const *src, uint16_t len); + +#ifdef __cplusplus +} +#endif + +#endif /* _BLE_MESH_UTIL_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/aes.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/aes.h new file mode 100644 index 00000000000..aa636c7d4f9 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/aes.h @@ -0,0 +1,130 @@ +/* aes.h - TinyCrypt interface to an AES-128 implementation */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief -- Interface to an AES-128 implementation. + * + * Overview: AES-128 is a NIST approved block cipher specified in + * FIPS 197. Block ciphers are deterministic algorithms that + * perform a transformation specified by a symmetric key in fixed- + * length data sets, also called blocks. + * + * Security: AES-128 provides approximately 128 bits of security. + * + * Usage: 1) call tc_aes128_set_encrypt/decrypt_key to set the key. + * + * 2) call tc_aes_encrypt/decrypt to process the data. + */ + +#ifndef __BLE_MESH_TC_AES_H__ +#define __BLE_MESH_TC_AES_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define Nb (4) /* number of columns (32-bit words) comprising the state */ +#define Nk (4) /* number of 32-bit words comprising the key */ +#define Nr (10) /* number of rounds */ +#define TC_AES_BLOCK_SIZE (Nb*Nk) +#define TC_AES_KEY_SIZE (Nb*Nk) + +typedef struct tc_aes_key_sched_struct { + unsigned int words[Nb * (Nr + 1)]; +} *TCAesKeySched_t; + +/** + * @brief Set AES-128 encryption key + * Uses key k to initialize s + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: s == NULL or k == NULL + * @note This implementation skips the additional steps required for keys + * larger than 128 bits, and must not be used for AES-192 or + * AES-256 key schedule -- see FIPS 197 for details + * @param s IN/OUT -- initialized struct tc_aes_key_sched_struct + * @param k IN -- points to the AES key + */ +int tc_aes128_set_encrypt_key(TCAesKeySched_t s, const uint8_t *k); + +/** + * @brief AES-128 Encryption procedure + * Encrypts contents of in buffer into out buffer under key; + * schedule s + * @note Assumes s was initialized by aes_set_encrypt_key; + * out and in point to 16 byte buffers + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: out == NULL or in == NULL or s == NULL + * @param out IN/OUT -- buffer to receive ciphertext block + * @param in IN -- a plaintext block to encrypt + * @param s IN -- initialized AES key schedule + */ +int tc_aes_encrypt(uint8_t *out, const uint8_t *in, + const TCAesKeySched_t s); + +/** + * @brief Set the AES-128 decryption key + * Uses key k to initialize s + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: s == NULL or k == NULL + * @note This is the implementation of the straightforward inverse cipher + * using the cipher documented in FIPS-197 figure 12, not the + * equivalent inverse cipher presented in Figure 15 + * @warning This routine skips the additional steps required for keys larger + * than 128, and must not be used for AES-192 or AES-256 key + * schedule -- see FIPS 197 for details + * @param s IN/OUT -- initialized struct tc_aes_key_sched_struct + * @param k IN -- points to the AES key + */ +int tc_aes128_set_decrypt_key(TCAesKeySched_t s, const uint8_t *k); + +/** + * @brief AES-128 Encryption procedure + * Decrypts in buffer into out buffer under key schedule s + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: out is NULL or in is NULL or s is NULL + * @note Assumes s was initialized by aes_set_encrypt_key + * out and in point to 16 byte buffers + * @param out IN/OUT -- buffer to receive ciphertext block + * @param in IN -- a plaintext block to encrypt + * @param s IN -- initialized AES key schedule + */ +int tc_aes_decrypt(uint8_t *out, const uint8_t *in, + const TCAesKeySched_t s); + +#ifdef __cplusplus +} +#endif + +#endif /* __BLE_MESH_TC_AES_H__ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/cbc_mode.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/cbc_mode.h new file mode 100644 index 00000000000..4be3d95e56f --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/cbc_mode.h @@ -0,0 +1,151 @@ +/* cbc_mode.h - TinyCrypt interface to a CBC mode implementation */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief Interface to a CBC mode implementation. + * + * Overview: CBC (for "cipher block chaining") mode is a NIST approved mode of + * operation defined in SP 800-38a. It can be used with any block + * cipher to provide confidentiality of strings whose lengths are + * multiples of the block_size of the underlying block cipher. + * TinyCrypt hard codes AES as the block cipher. + * + * Security: CBC mode provides data confidentiality given that the maximum + * number q of blocks encrypted under a single key satisfies + * q < 2^63, which is not a practical constraint (it is considered a + * good practice to replace the encryption when q == 2^56). CBC mode + * provides NO data integrity. + * + * CBC mode assumes that the IV value input into the + * tc_cbc_mode_encrypt is randomly generated. The TinyCrypt library + * provides HMAC-PRNG module, which generates suitable IVs. Other + * methods for generating IVs are acceptable, provided that the + * values of the IVs generated appear random to any adversary, + * including someone with complete knowledge of the system design. + * + * The randomness property on which CBC mode's security depends is + * the unpredictability of the IV. Since it is unpredictable, this + * means in practice that CBC mode requires that the IV is stored + * somehow with the ciphertext in order to recover the plaintext. + * + * TinyCrypt CBC encryption prepends the IV to the ciphertext, + * because this affords a more efficient (few buffers) decryption. + * Hence tc_cbc_mode_encrypt assumes the ciphertext buffer is always + * 16 bytes larger than the plaintext buffer. + * + * Requires: AES-128 + * + * Usage: 1) call tc_cbc_mode_encrypt to encrypt data. + * + * 2) call tc_cbc_mode_decrypt to decrypt data. + * + */ + +#ifndef __BLE_MESH_TC_CBC_MODE_H__ +#define __BLE_MESH_TC_CBC_MODE_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief CBC encryption procedure + * CBC encrypts inlen bytes of the in buffer into the out buffer + * using the encryption key schedule provided, prepends iv to out + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: + * out == NULL or + * in == NULL or + * ctr == NULL or + * sched == NULL or + * inlen == 0 or + * (inlen % TC_AES_BLOCK_SIZE) != 0 or + * (outlen % TC_AES_BLOCK_SIZE) != 0 or + * outlen != inlen + TC_AES_BLOCK_SIZE + * @note Assumes: - sched has been configured by aes_set_encrypt_key + * - iv contains a 16 byte random string + * - out buffer is large enough to hold the ciphertext + iv + * - out buffer is a contiguous buffer + * - in holds the plaintext and is a contiguous buffer + * - inlen gives the number of bytes in the in buffer + * @param out IN/OUT -- buffer to receive the ciphertext + * @param outlen IN -- length of ciphertext buffer in bytes + * @param in IN -- plaintext to encrypt + * @param inlen IN -- length of plaintext buffer in bytes + * @param iv IN -- the IV for the this encrypt/decrypt + * @param sched IN -- AES key schedule for this encrypt + */ +int tc_cbc_mode_encrypt(uint8_t *out, unsigned int outlen, const uint8_t *in, + unsigned int inlen, const uint8_t *iv, + const TCAesKeySched_t sched); + +/** + * @brief CBC decryption procedure + * CBC decrypts inlen bytes of the in buffer into the out buffer + * using the provided encryption key schedule + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: + * out == NULL or + * in == NULL or + * sched == NULL or + * inlen == 0 or + * outlen == 0 or + * (inlen % TC_AES_BLOCK_SIZE) != 0 or + * (outlen % TC_AES_BLOCK_SIZE) != 0 or + * outlen != inlen + TC_AES_BLOCK_SIZE + * @note Assumes:- in == iv + ciphertext, i.e. the iv and the ciphertext are + * contiguous. This allows for a very efficient decryption + * algorithm that would not otherwise be possible + * - sched was configured by aes_set_decrypt_key + * - out buffer is large enough to hold the decrypted plaintext + * and is a contiguous buffer + * - inlen gives the number of bytes in the in buffer + * @param out IN/OUT -- buffer to receive decrypted data + * @param outlen IN -- length of plaintext buffer in bytes + * @param in IN -- ciphertext to decrypt, including IV + * @param inlen IN -- length of ciphertext buffer in bytes + * @param iv IN -- the IV for the this encrypt/decrypt + * @param sched IN -- AES key schedule for this decrypt + * + */ +int tc_cbc_mode_decrypt(uint8_t *out, unsigned int outlen, const uint8_t *in, + unsigned int inlen, const uint8_t *iv, + const TCAesKeySched_t sched); + +#ifdef __cplusplus +} +#endif + +#endif /* __BLE_MESH_TC_CBC_MODE_H__ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ccm_mode.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ccm_mode.h new file mode 100644 index 00000000000..1f85c76e613 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ccm_mode.h @@ -0,0 +1,211 @@ +/* ccm_mode.h - TinyCrypt interface to a CCM mode implementation */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief Interface to a CCM mode implementation. + * + * Overview: CCM (for "Counter with CBC-MAC") mode is a NIST approved mode of + * operation defined in SP 800-38C. + * + * TinyCrypt CCM implementation accepts: + * + * 1) Both non-empty payload and associated data (it encrypts and + * authenticates the payload and also authenticates the associated + * data); + * 2) Non-empty payload and empty associated data (it encrypts and + * authenticates the payload); + * 3) Non-empty associated data and empty payload (it degenerates to + * an authentication mode on the associated data). + * + * TinyCrypt CCM implementation accepts associated data of any length + * between 0 and (2^16 - 2^8) bytes. + * + * Security: The mac length parameter is an important parameter to estimate the + * security against collision attacks (that aim at finding different + * messages that produce the same authentication tag). TinyCrypt CCM + * implementation accepts any even integer between 4 and 16, as + * suggested in SP 800-38C. + * + * RFC-3610, which also specifies CCM, presents a few relevant + * security suggestions, such as: it is recommended for most + * applications to use a mac length greater than 8. Besides, the + * usage of the same nonce for two different messages which are + * encrypted with the same key destroys the security of CCM mode. + * + * Requires: AES-128 + * + * Usage: 1) call tc_ccm_config to configure. + * + * 2) call tc_ccm_mode_encrypt to encrypt data and generate tag. + * + * 3) call tc_ccm_mode_decrypt to decrypt data and verify tag. + */ + +#ifndef __BLE_MESH_TC_CCM_MODE_H__ +#define __BLE_MESH_TC_CCM_MODE_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* max additional authenticated size in bytes: 2^16 - 2^8 = 65280 */ +#define TC_CCM_AAD_MAX_BYTES 0xff00 + +/* max message size in bytes: 2^(8L) = 2^16 = 65536 */ +#define TC_CCM_PAYLOAD_MAX_BYTES 0x10000 + +/* struct tc_ccm_mode_struct represents the state of a CCM computation */ +typedef struct tc_ccm_mode_struct { + TCAesKeySched_t sched; /* AES key schedule */ + uint8_t *nonce; /* nonce required by CCM */ + unsigned int mlen; /* mac length in bytes (parameter t in SP-800 38C) */ +} *TCCcmMode_t; + +/** + * @brief CCM configuration procedure + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: + * c == NULL or + * sched == NULL or + * nonce == NULL or + * mlen != {4, 6, 8, 10, 12, 16} + * @param c -- CCM state + * @param sched IN -- AES key schedule + * @param nonce IN - nonce + * @param nlen -- nonce length in bytes + * @param mlen -- mac length in bytes (parameter t in SP-800 38C) + */ +int tc_ccm_config(TCCcmMode_t c, TCAesKeySched_t sched, uint8_t *nonce, + unsigned int nlen, unsigned int mlen); + +/** + * @brief CCM tag generation and encryption procedure + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: + * out == NULL or + * c == NULL or + * ((plen > 0) and (payload == NULL)) or + * ((alen > 0) and (associated_data == NULL)) or + * (alen >= TC_CCM_AAD_MAX_BYTES) or + * (plen >= TC_CCM_PAYLOAD_MAX_BYTES) or + * (olen < plen + maclength) + * + * @param out OUT -- encrypted data + * @param olen IN -- output length in bytes + * @param associated_data IN -- associated data + * @param alen IN -- associated data length in bytes + * @param payload IN -- payload + * @param plen IN -- payload length in bytes + * @param c IN -- CCM state + * + * @note: out buffer should be at least (plen + c->mlen) bytes long. + * + * @note: The sequence b for encryption is formatted as follows: + * b = [FLAGS | nonce | counter ], where: + * FLAGS is 1 byte long + * nonce is 13 bytes long + * counter is 2 bytes long + * The byte FLAGS is composed by the following 8 bits: + * 0-2 bits: used to represent the value of q-1 + * 3-7 btis: always 0's + * + * @note: The sequence b for authentication is formatted as follows: + * b = [FLAGS | nonce | length(mac length)], where: + * FLAGS is 1 byte long + * nonce is 13 bytes long + * length(mac length) is 2 bytes long + * The byte FLAGS is composed by the following 8 bits: + * 0-2 bits: used to represent the value of q-1 + * 3-5 bits: mac length (encoded as: (mlen-2)/2) + * 6: Adata (0 if alen == 0, and 1 otherwise) + * 7: always 0 + */ +int tc_ccm_generation_encryption(uint8_t *out, unsigned int olen, + const uint8_t *associated_data, + unsigned int alen, const uint8_t *payload, + unsigned int plen, TCCcmMode_t c); + +/** + * @brief CCM decryption and tag verification procedure + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: + * out == NULL or + * c == NULL or + * ((plen > 0) and (payload == NULL)) or + * ((alen > 0) and (associated_data == NULL)) or + * (alen >= TC_CCM_AAD_MAX_BYTES) or + * (plen >= TC_CCM_PAYLOAD_MAX_BYTES) or + * (olen < plen - c->mlen) + * + * @param out OUT -- decrypted data + * @param associated_data IN -- associated data + * @param alen IN -- associated data length in bytes + * @param payload IN -- payload + * @param plen IN -- payload length in bytes + * @param c IN -- CCM state + * + * @note: out buffer should be at least (plen - c->mlen) bytes long. + * + * @note: The sequence b for encryption is formatted as follows: + * b = [FLAGS | nonce | counter ], where: + * FLAGS is 1 byte long + * nonce is 13 bytes long + * counter is 2 bytes long + * The byte FLAGS is composed by the following 8 bits: + * 0-2 bits: used to represent the value of q-1 + * 3-7 btis: always 0's + * + * @note: The sequence b for authentication is formatted as follows: + * b = [FLAGS | nonce | length(mac length)], where: + * FLAGS is 1 byte long + * nonce is 13 bytes long + * length(mac length) is 2 bytes long + * The byte FLAGS is composed by the following 8 bits: + * 0-2 bits: used to represent the value of q-1 + * 3-5 bits: mac length (encoded as: (mlen-2)/2) + * 6: Adata (0 if alen == 0, and 1 otherwise) + * 7: always 0 + */ +int tc_ccm_decryption_verification(uint8_t *out, unsigned int olen, + const uint8_t *associated_data, + unsigned int alen, const uint8_t *payload, unsigned int plen, + TCCcmMode_t c); + +#ifdef __cplusplus +} +#endif + +#endif /* __BLE_MESH_TC_CCM_MODE_H__ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/cmac_mode.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/cmac_mode.h new file mode 100644 index 00000000000..cf0b3601b20 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/cmac_mode.h @@ -0,0 +1,194 @@ +/* cmac_mode.h -- interface to a CMAC implementation */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief Interface to a CMAC implementation. + * + * Overview: CMAC is defined NIST in SP 800-38B, and is the standard algorithm + * for computing a MAC using a block cipher. It can compute the MAC + * for a byte string of any length. It is distinguished from CBC-MAC + * in the processing of the final message block; CMAC uses a + * different technique to compute the final message block is full + * size or only partial, while CBC-MAC uses the same technique for + * both. This difference permits CMAC to be applied to variable + * length messages, while all messages authenticated by CBC-MAC must + * be the same length. + * + * Security: AES128-CMAC mode of operation offers 64 bits of security against + * collision attacks. Note however that an external attacker cannot + * generate the tags him/herself without knowing the MAC key. In this + * sense, to attack the collision property of AES128-CMAC, an + * external attacker would need the cooperation of the legal user to + * produce an exponentially high number of tags (e.g. 2^64) to + * finally be able to look for collisions and benefit from them. As + * an extra precaution, the current implementation allows to at most + * 2^48 calls to the tc_cmac_update function before re-calling + * tc_cmac_setup (allowing a new key to be set), as suggested in + * Appendix B of SP 800-38B. + * + * Requires: AES-128 + * + * Usage: This implementation provides a "scatter-gather" interface, so that + * the CMAC value can be computed incrementally over a message + * scattered in different segments throughout memory. Experience shows + * this style of interface tends to minimize the burden of programming + * correctly. Like all symmetric key operations, it is session + * oriented. + * + * To begin a CMAC session, use tc_cmac_setup to initialize a struct + * tc_cmac_struct with encryption key and buffer. Our implementation + * always assume that the AES key to be the same size as the block + * cipher block size. Once setup, this data structure can be used for + * many CMAC computations. + * + * Once the state has been setup with a key, computing the CMAC of + * some data requires three steps: + * + * (1) first use tc_cmac_init to initialize a new CMAC computation. + * (2) next mix all of the data into the CMAC computation state using + * tc_cmac_update. If all of the data resides in a single data + * segment then only one tc_cmac_update call is needed; if data + * is scattered throughout memory in n data segments, then n calls + * will be needed. CMAC IS ORDER SENSITIVE, to be able to detect + * attacks that swap bytes, so the order in which data is mixed + * into the state is critical! + * (3) Once all of the data for a message has been mixed, use + * tc_cmac_final to compute the CMAC tag value. + * + * Steps (1)-(3) can be repeated as many times as you want to CMAC + * multiple messages. A practical limit is 2^48 1K messages before you + * have to change the key. + * + * Once you are done computing CMAC with a key, it is a good idea to + * destroy the state so an attacker cannot recover the key; use + * tc_cmac_erase to accomplish this. + */ + +#ifndef __BLE_MESH_TC_CMAC_MODE_H__ +#define __BLE_MESH_TC_CMAC_MODE_H__ + +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* padding for last message block */ +#define TC_CMAC_PADDING 0x80 + +/* struct tc_cmac_struct represents the state of a CMAC computation */ +typedef struct tc_cmac_struct { + /* initialization vector */ + uint8_t iv[TC_AES_BLOCK_SIZE]; + /* used if message length is a multiple of block_size bytes */ + uint8_t K1[TC_AES_BLOCK_SIZE]; + /* used if message length isn't a multiple block_size bytes */ + uint8_t K2[TC_AES_BLOCK_SIZE]; + /* where to put bytes that didn't fill a block */ + uint8_t leftover[TC_AES_BLOCK_SIZE]; + /* identifies the encryption key */ + unsigned int keyid; + /* next available leftover location */ + unsigned int leftover_offset; + /* AES key schedule */ + TCAesKeySched_t sched; + /* calls to tc_cmac_update left before re-key */ + uint64_t countdown; +} *TCCmacState_t; + +/** + * @brief Configures the CMAC state to use the given AES key + * @return returns TC_CRYPTO_SUCCESS (1) after having configured the CMAC state + * returns TC_CRYPTO_FAIL (0) if: + * s == NULL or + * key == NULL + * + * @param s IN/OUT -- the state to set up + * @param key IN -- the key to use + * @param sched IN -- AES key schedule + */ +int tc_cmac_setup(TCCmacState_t s, const uint8_t *key, + TCAesKeySched_t sched); + +/** + * @brief Erases the CMAC state + * @return returns TC_CRYPTO_SUCCESS (1) after having configured the CMAC state + * returns TC_CRYPTO_FAIL (0) if: + * s == NULL + * + * @param s IN/OUT -- the state to erase + */ +int tc_cmac_erase(TCCmacState_t s); + +/** + * @brief Initializes a new CMAC computation + * @return returns TC_CRYPTO_SUCCESS (1) after having initialized the CMAC state + * returns TC_CRYPTO_FAIL (0) if: + * s == NULL + * + * @param s IN/OUT -- the state to initialize + */ +int tc_cmac_init(TCCmacState_t s); + +/** + * @brief Incrementally computes CMAC over the next data segment + * @return returns TC_CRYPTO_SUCCESS (1) after successfully updating the CMAC state + * returns TC_CRYPTO_FAIL (0) if: + * s == NULL or + * if data == NULL when dlen > 0 + * + * @param s IN/OUT -- the CMAC state + * @param data IN -- the next data segment to MAC + * @param dlen IN -- the length of data in bytes + */ +int tc_cmac_update(TCCmacState_t s, const uint8_t *data, size_t dlen); + +/** + * @brief Generates the tag from the CMAC state + * @return returns TC_CRYPTO_SUCCESS (1) after successfully generating the tag + * returns TC_CRYPTO_FAIL (0) if: + * tag == NULL or + * s == NULL + * + * @param tag OUT -- the CMAC tag + * @param s IN -- CMAC state + */ +int tc_cmac_final(uint8_t *tag, TCCmacState_t s); + +#ifdef __cplusplus +} +#endif + +#endif /* __BLE_MESH_TC_CMAC_MODE_H__ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/constants.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/constants.h new file mode 100644 index 00000000000..0abb01a15a8 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/constants.h @@ -0,0 +1,61 @@ +/* constants.h - TinyCrypt interface to constants */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief -- Interface to constants. + * + */ + +#ifndef __BLE_MESH_TC_CONSTANTS_H__ +#define __BLE_MESH_TC_CONSTANTS_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#ifndef NULL +#define NULL ((void *)0) +#endif + +#define TC_CRYPTO_SUCCESS 1 +#define TC_CRYPTO_FAIL 0 + +#define TC_ZERO_BYTE 0x00 + +#ifdef __cplusplus +} +#endif + +#endif /* __BLE_MESH_TC_CONSTANTS_H__ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ctr_mode.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ctr_mode.h new file mode 100644 index 00000000000..039f58c86c4 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ctr_mode.h @@ -0,0 +1,108 @@ +/* ctr_mode.h - TinyCrypt interface to CTR mode */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief Interface to CTR mode. + * + * Overview: CTR (pronounced "counter") mode is a NIST approved mode of + * operation defined in SP 800-38a. It can be used with any + * block cipher to provide confidentiality of strings of any + * length. TinyCrypt hard codes AES128 as the block cipher. + * + * Security: CTR mode achieves confidentiality only if the counter value is + * never reused with a same encryption key. If the counter is + * repeated, than an adversary might be able to defeat the scheme. + * + * A usual method to ensure different counter values refers to + * initialize the counter in a given value (0, for example) and + * increases it every time a new block is enciphered. This naturally + * leaves to a limitation on the number q of blocks that can be + * enciphered using a same key: q < 2^(counter size). + * + * TinyCrypt uses a counter of 32 bits. This means that after 2^32 + * block encryptions, the counter will be reused (thus losing CBC + * security). 2^32 block encryptions should be enough for most of + * applications targeting constrained devices. Applications intended + * to encrypt a larger number of blocks must replace the key after + * 2^32 block encryptions. + * + * CTR mode provides NO data integrity. + * + * Requires: AES-128 + * + * Usage: 1) call tc_ctr_mode to process the data to encrypt/decrypt. + * + */ + +#ifndef __BLE_MESH_TC_CTR_MODE_H__ +#define __BLE_MESH_TC_CTR_MODE_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief CTR mode encryption/decryption procedure. + * CTR mode encrypts (or decrypts) inlen bytes from in buffer into out buffer + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: + * out == NULL or + * in == NULL or + * ctr == NULL or + * sched == NULL or + * inlen == 0 or + * outlen == 0 or + * inlen != outlen + * @note Assumes:- The current value in ctr has NOT been used with sched + * - out points to inlen bytes + * - in points to inlen bytes + * - ctr is an integer counter in littleEndian format + * - sched was initialized by aes_set_encrypt_key + * @param out OUT -- produced ciphertext (plaintext) + * @param outlen IN -- length of ciphertext buffer in bytes + * @param in IN -- data to encrypt (or decrypt) + * @param inlen IN -- length of input data in bytes + * @param ctr IN/OUT -- the current counter value + * @param sched IN -- an initialized AES key schedule + */ +int tc_ctr_mode(uint8_t *out, unsigned int outlen, const uint8_t *in, + unsigned int inlen, uint8_t *ctr, const TCAesKeySched_t sched); + +#ifdef __cplusplus +} +#endif + +#endif /* __BLE_MESH_TC_CTR_MODE_H__ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ctr_prng.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ctr_prng.h new file mode 100644 index 00000000000..04e070d3ee7 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ctr_prng.h @@ -0,0 +1,166 @@ +/* ctr_prng.h - TinyCrypt interface to a CTR-PRNG implementation */ + +/* + * Copyright (c) 2016, Chris Morrison + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief Interface to a CTR-PRNG implementation. + * + * Overview: A pseudo-random number generator (PRNG) generates a sequence + * of numbers that have a distribution close to the one expected + * for a sequence of truly random numbers. The NIST Special + * Publication 800-90A specifies several mechanisms to generate + * sequences of pseudo random numbers, including the CTR-PRNG one + * which is based on AES. TinyCrypt implements CTR-PRNG with + * AES-128. + * + * Security: A cryptographically secure PRNG depends on the existence of an + * entropy source to provide a truly random seed as well as the + * security of the primitives used as the building blocks (AES-128 + * in this instance). + * + * Requires: - AES-128 + * + * Usage: 1) call tc_ctr_prng_init to seed the prng context + * + * 2) call tc_ctr_prng_reseed to mix in additional entropy into + * the prng context + * + * 3) call tc_ctr_prng_generate to output the pseudo-random data + * + * 4) call tc_ctr_prng_uninstantiate to zero out the prng context + */ + +#ifndef __BLE_MESH_TC_CTR_PRNG_H__ +#define __BLE_MESH_TC_CTR_PRNG_H__ + +#include + +#define TC_CTR_PRNG_RESEED_REQ -1 + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + /* updated each time another BLOCKLEN_BYTES bytes are produced */ + uint8_t V[TC_AES_BLOCK_SIZE]; + + /* updated whenever the PRNG is reseeded */ + struct tc_aes_key_sched_struct key; + + /* number of requests since initialization/reseeding */ + uint64_t reseedCount; +} TCCtrPrng_t; + + +/** + * @brief CTR-PRNG initialization procedure + * Initializes prng context with entropy and personalization string (if any) + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: + * ctx == NULL, + * entropy == NULL, + * entropyLen < (TC_AES_KEY_SIZE + TC_AES_BLOCK_SIZE) + * @note Only the first (TC_AES_KEY_SIZE + TC_AES_BLOCK_SIZE) bytes of + * both the entropy and personalization inputs are used - + * supplying additional bytes has no effect. + * @param ctx IN/OUT -- the PRNG context to initialize + * @param entropy IN -- entropy used to seed the PRNG + * @param entropyLen IN -- entropy length in bytes + * @param personalization IN -- personalization string used to seed the PRNG + * (may be null) + * @param plen IN -- personalization length in bytes + * + */ +int tc_ctr_prng_init(TCCtrPrng_t *const ctx, + uint8_t const *const entropy, + unsigned int entropyLen, + uint8_t const *const personalization, + unsigned int pLen); + +/** + * @brief CTR-PRNG reseed procedure + * Mixes entropy and additional_input into the prng context + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: + * ctx == NULL, + * entropy == NULL, + * entropylen < (TC_AES_KEY_SIZE + TC_AES_BLOCK_SIZE) + * @note It is better to reseed an existing prng context rather than + * re-initialise, so that any existing entropy in the context is + * presereved. This offers some protection against undetected failures + * of the entropy source. + * @note Assumes tc_ctr_prng_init has been called for ctx + * @param ctx IN/OUT -- the PRNG state + * @param entropy IN -- entropy to mix into the prng + * @param entropylen IN -- length of entropy in bytes + * @param additional_input IN -- additional input to the prng (may be null) + * @param additionallen IN -- additional input length in bytes + */ +int tc_ctr_prng_reseed(TCCtrPrng_t *const ctx, + uint8_t const *const entropy, + unsigned int entropyLen, + uint8_t const *const additional_input, + unsigned int additionallen); + +/** + * @brief CTR-PRNG generate procedure + * Generates outlen pseudo-random bytes into out buffer, updates prng + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CTR_PRNG_RESEED_REQ (-1) if a reseed is needed + * returns TC_CRYPTO_FAIL (0) if: + * ctx == NULL, + * out == NULL, + * outlen >= 2^16 + * @note Assumes tc_ctr_prng_init has been called for ctx + * @param ctx IN/OUT -- the PRNG context + * @param additional_input IN -- additional input to the prng (may be null) + * @param additionallen IN -- additional input length in bytes + * @param out IN/OUT -- buffer to receive output + * @param outlen IN -- size of out buffer in bytes + */ +int tc_ctr_prng_generate(TCCtrPrng_t *const ctx, + uint8_t const *const additional_input, + unsigned int additionallen, + uint8_t *const out, + unsigned int outlen); + +/** + * @brief CTR-PRNG uninstantiate procedure + * Zeroes the internal state of the supplied prng context + * @return none + * @param ctx IN/OUT -- the PRNG context + */ +void tc_ctr_prng_uninstantiate(TCCtrPrng_t *const ctx); + +#ifdef __cplusplus +} +#endif + +#endif /* __BLE_MESH_TC_CTR_PRNG_H__ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ecc.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ecc.h new file mode 100644 index 00000000000..72ba652f26d --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ecc.h @@ -0,0 +1,545 @@ +/* ecc.h - TinyCrypt interface to common ECC functions */ + +/* Copyright (c) 2014, Kenneth MacKay + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief -- Interface to common ECC functions. + * + * Overview: This software is an implementation of common functions + * necessary to elliptic curve cryptography. This implementation uses + * curve NIST p-256. + * + * Security: The curve NIST p-256 provides approximately 128 bits of security. + * + */ + +#ifndef __BLE_MESH_TC_UECC_H__ +#define __BLE_MESH_TC_UECC_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Word size (4 bytes considering 32-bits architectures) */ +#define uECC_WORD_SIZE 4 + +/* setting max number of calls to prng: */ +#ifndef uECC_RNG_MAX_TRIES +#define uECC_RNG_MAX_TRIES 64 +#endif + +/* defining data types to store word and bit counts: */ +typedef int8_t wordcount_t; +typedef int16_t bitcount_t; +/* defining data type for comparison result: */ +typedef int8_t cmpresult_t; +/* defining data type to store ECC coordinate/point in 32bits words: */ +typedef unsigned int uECC_word_t; +/* defining data type to store an ECC coordinate/point in 64bits words: */ +typedef uint64_t uECC_dword_t; + +/* defining masks useful for ecc computations: */ +#define HIGH_BIT_SET 0x80000000 +#define uECC_WORD_BITS 32 +#define uECC_WORD_BITS_SHIFT 5 +#define uECC_WORD_BITS_MASK 0x01F + +/* Number of words of 32 bits to represent an element of the the curve p-256: */ +#define NUM_ECC_WORDS 8 +/* Number of bytes to represent an element of the the curve p-256: */ +#define NUM_ECC_BYTES (uECC_WORD_SIZE*NUM_ECC_WORDS) + +/* structure that represents an elliptic curve (e.g. p256):*/ +struct uECC_Curve_t; +typedef const struct uECC_Curve_t *uECC_Curve; +struct uECC_Curve_t { + wordcount_t num_words; + wordcount_t num_bytes; + bitcount_t num_n_bits; + uECC_word_t p[NUM_ECC_WORDS]; + uECC_word_t n[NUM_ECC_WORDS]; + uECC_word_t G[NUM_ECC_WORDS * 2]; + uECC_word_t b[NUM_ECC_WORDS]; + void (*double_jacobian)(uECC_word_t *X1, uECC_word_t *Y1, uECC_word_t *Z1, + uECC_Curve curve); + void (*x_side)(uECC_word_t *result, const uECC_word_t *x, uECC_Curve curve); + void (*mmod_fast)(uECC_word_t *result, uECC_word_t *product); +}; + +/* + * @brief computes doubling of point ion jacobian coordinates, in place. + * @param X1 IN/OUT -- x coordinate + * @param Y1 IN/OUT -- y coordinate + * @param Z1 IN/OUT -- z coordinate + * @param curve IN -- elliptic curve + */ +void double_jacobian_default(uECC_word_t *X1, uECC_word_t *Y1, + uECC_word_t *Z1, uECC_Curve curve); + +/* + * @brief Computes x^3 + ax + b. result must not overlap x. + * @param result OUT -- x^3 + ax + b + * @param x IN -- value of x + * @param curve IN -- elliptic curve + */ +void x_side_default(uECC_word_t *result, const uECC_word_t *x, + uECC_Curve curve); + +/* + * @brief Computes result = product % curve_p + * from http://www.nsa.gov/ia/_files/nist-routines.pdf + * @param result OUT -- product % curve_p + * @param product IN -- value to be reduced mod curve_p + */ +void vli_mmod_fast_secp256r1(unsigned int *result, unsigned int *product); + +/* Bytes to words ordering: */ +#define BYTES_TO_WORDS_8(a, b, c, d, e, f, g, h) 0x##d##c##b##a, 0x##h##g##f##e +#define BYTES_TO_WORDS_4(a, b, c, d) 0x##d##c##b##a +#define BITS_TO_WORDS(num_bits) \ + ((num_bits + ((uECC_WORD_SIZE * 8) - 1)) / (uECC_WORD_SIZE * 8)) +#define BITS_TO_BYTES(num_bits) ((num_bits + 7) / 8) + +/* definition of curve NIST p-256: */ +static const struct uECC_Curve_t curve_secp256r1 = { + NUM_ECC_WORDS, + NUM_ECC_BYTES, + 256, /* num_n_bits */ { + BYTES_TO_WORDS_8(FF, FF, FF, FF, FF, FF, FF, FF), + BYTES_TO_WORDS_8(FF, FF, FF, FF, 00, 00, 00, 00), + BYTES_TO_WORDS_8(00, 00, 00, 00, 00, 00, 00, 00), + BYTES_TO_WORDS_8(01, 00, 00, 00, FF, FF, FF, FF) + }, { + BYTES_TO_WORDS_8(51, 25, 63, FC, C2, CA, B9, F3), + BYTES_TO_WORDS_8(84, 9E, 17, A7, AD, FA, E6, BC), + BYTES_TO_WORDS_8(FF, FF, FF, FF, FF, FF, FF, FF), + BYTES_TO_WORDS_8(00, 00, 00, 00, FF, FF, FF, FF) + }, { + BYTES_TO_WORDS_8(96, C2, 98, D8, 45, 39, A1, F4), + BYTES_TO_WORDS_8(A0, 33, EB, 2D, 81, 7D, 03, 77), + BYTES_TO_WORDS_8(F2, 40, A4, 63, E5, E6, BC, F8), + BYTES_TO_WORDS_8(47, 42, 2C, E1, F2, D1, 17, 6B), + + BYTES_TO_WORDS_8(F5, 51, BF, 37, 68, 40, B6, CB), + BYTES_TO_WORDS_8(CE, 5E, 31, 6B, 57, 33, CE, 2B), + BYTES_TO_WORDS_8(16, 9E, 0F, 7C, 4A, EB, E7, 8E), + BYTES_TO_WORDS_8(9B, 7F, 1A, FE, E2, 42, E3, 4F) + }, { + BYTES_TO_WORDS_8(4B, 60, D2, 27, 3E, 3C, CE, 3B), + BYTES_TO_WORDS_8(F6, B0, 53, CC, B0, 06, 1D, 65), + BYTES_TO_WORDS_8(BC, 86, 98, 76, 55, BD, EB, B3), + BYTES_TO_WORDS_8(E7, 93, 3A, AA, D8, 35, C6, 5A) + }, + &double_jacobian_default, + &x_side_default, + &vli_mmod_fast_secp256r1 +}; + +uECC_Curve uECC_secp256r1(void); + +/* + * @brief Generates a random integer in the range 0 < random < top. + * Both random and top have num_words words. + * @param random OUT -- random integer in the range 0 < random < top + * @param top IN -- upper limit + * @param num_words IN -- number of words + * @return a random integer in the range 0 < random < top + */ +int uECC_generate_random_int(uECC_word_t *random, const uECC_word_t *top, + wordcount_t num_words); + + +/* uECC_RNG_Function type + * The RNG function should fill 'size' random bytes into 'dest'. It should + * return 1 if 'dest' was filled with random data, or 0 if the random data could + * not be generated. The filled-in values should be either truly random, or from + * a cryptographically-secure PRNG. + * + * A correctly functioning RNG function must be set (using uECC_set_rng()) + * before calling uECC_make_key() or uECC_sign(). + * + * Setting a correctly functioning RNG function improves the resistance to + * side-channel attacks for uECC_shared_secret(). + * + * A correct RNG function is set by default. If you are building on another + * POSIX-compliant system that supports /dev/random or /dev/urandom, you can + * define uECC_POSIX to use the predefined RNG. + */ +typedef int(*uECC_RNG_Function)(uint8_t *dest, unsigned int size); + +/* + * @brief Set the function that will be used to generate random bytes. The RNG + * function should return 1 if the random data was generated, or 0 if the random + * data could not be generated. + * + * @note On platforms where there is no predefined RNG function, this must be + * called before uECC_make_key() or uECC_sign() are used. + * + * @param rng_function IN -- function that will be used to generate random bytes + */ +void uECC_set_rng(uECC_RNG_Function rng_function); + +/* + * @brief provides current uECC_RNG_Function. + * @return Returns the function that will be used to generate random bytes. + */ +uECC_RNG_Function uECC_get_rng(void); + +/* + * @brief computes the size of a private key for the curve in bytes. + * @param curve IN -- elliptic curve + * @return size of a private key for the curve in bytes. + */ +int uECC_curve_private_key_size(uECC_Curve curve); + +/* + * @brief computes the size of a public key for the curve in bytes. + * @param curve IN -- elliptic curve + * @return the size of a public key for the curve in bytes. + */ +int uECC_curve_public_key_size(uECC_Curve curve); + +/* + * @brief Compute the corresponding public key for a private key. + * @param private_key IN -- The private key to compute the public key for + * @param public_key OUT -- Will be filled in with the corresponding public key + * @param curve + * @return Returns 1 if key was computed successfully, 0 if an error occurred. + */ +int uECC_compute_public_key(const uint8_t *private_key, + uint8_t *public_key, uECC_Curve curve); + +/* + * @brief Compute public-key. + * @return corresponding public-key. + * @param result OUT -- public-key + * @param private_key IN -- private-key + * @param curve IN -- elliptic curve + */ +uECC_word_t EccPoint_compute_public_key(uECC_word_t *result, + uECC_word_t *private_key, uECC_Curve curve); + +/* + * @brief Regularize the bitcount for the private key so that attackers cannot + * use a side channel attack to learn the number of leading zeros. + * @return Regularized k + * @param k IN -- private-key + * @param k0 IN/OUT -- regularized k + * @param k1 IN/OUT -- regularized k + * @param curve IN -- elliptic curve + */ +uECC_word_t regularize_k(const uECC_word_t *const k, uECC_word_t *k0, + uECC_word_t *k1, uECC_Curve curve); + +/* + * @brief Point multiplication algorithm using Montgomery's ladder with co-Z + * coordinates. See http://eprint.iacr.org/2011/338.pdf. + * @note Result may overlap point. + * @param result OUT -- returns scalar*point + * @param point IN -- elliptic curve point + * @param scalar IN -- scalar + * @param initial_Z IN -- initial value for z + * @param num_bits IN -- number of bits in scalar + * @param curve IN -- elliptic curve + */ +void EccPoint_mult(uECC_word_t *result, const uECC_word_t *point, + const uECC_word_t *scalar, const uECC_word_t *initial_Z, + bitcount_t num_bits, uECC_Curve curve); + +/* + * @brief Constant-time comparison to zero - secure way to compare long integers + * @param vli IN -- very long integer + * @param num_words IN -- number of words in the vli + * @return 1 if vli == 0, 0 otherwise. + */ +uECC_word_t uECC_vli_isZero(const uECC_word_t *vli, wordcount_t num_words); + +/* + * @brief Check if 'point' is the point at infinity + * @param point IN -- elliptic curve point + * @param curve IN -- elliptic curve + * @return if 'point' is the point at infinity, 0 otherwise. + */ +uECC_word_t EccPoint_isZero(const uECC_word_t *point, uECC_Curve curve); + +/* + * @brief computes the sign of left - right, in constant time. + * @param left IN -- left term to be compared + * @param right IN -- right term to be compared + * @param num_words IN -- number of words + * @return the sign of left - right + */ +cmpresult_t uECC_vli_cmp(const uECC_word_t *left, const uECC_word_t *right, + wordcount_t num_words); + +/* + * @brief computes sign of left - right, not in constant time. + * @note should not be used if inputs are part of a secret + * @param left IN -- left term to be compared + * @param right IN -- right term to be compared + * @param num_words IN -- number of words + * @return the sign of left - right + */ +cmpresult_t uECC_vli_cmp_unsafe(const uECC_word_t *left, const uECC_word_t *right, + wordcount_t num_words); + +/* + * @brief Computes result = (left - right) % mod. + * @note Assumes that (left < mod) and (right < mod), and that result does not + * overlap mod. + * @param result OUT -- (left - right) % mod + * @param left IN -- leftright term in modular subtraction + * @param right IN -- right term in modular subtraction + * @param mod IN -- mod + * @param num_words IN -- number of words + */ +void uECC_vli_modSub(uECC_word_t *result, const uECC_word_t *left, + const uECC_word_t *right, const uECC_word_t *mod, + wordcount_t num_words); + +/* + * @brief Computes P' = (x1', y1', Z3), P + Q = (x3, y3, Z3) or + * P => P', Q => P + Q + * @note assumes Input P = (x1, y1, Z), Q = (x2, y2, Z) + * @param X1 IN -- x coordinate of P + * @param Y1 IN -- y coordinate of P + * @param X2 IN -- x coordinate of Q + * @param Y2 IN -- y coordinate of Q + * @param curve IN -- elliptic curve + */ +void XYcZ_add(uECC_word_t *X1, uECC_word_t *Y1, uECC_word_t *X2, + uECC_word_t *Y2, uECC_Curve curve); + +/* + * @brief Computes (x1 * z^2, y1 * z^3) + * @param X1 IN -- previous x1 coordinate + * @param Y1 IN -- previous y1 coordinate + * @param Z IN -- z value + * @param curve IN -- elliptic curve + */ +void apply_z(uECC_word_t *X1, uECC_word_t *Y1, const uECC_word_t *const Z, + uECC_Curve curve); + +/* + * @brief Check if bit is set. + * @return Returns nonzero if bit 'bit' of vli is set. + * @warning It is assumed that the value provided in 'bit' is within the + * boundaries of the word-array 'vli'. + * @note The bit ordering layout assumed for vli is: {31, 30, ..., 0}, + * {63, 62, ..., 32}, {95, 94, ..., 64}, {127, 126,..., 96} for a vli consisting + * of 4 uECC_word_t elements. + */ +uECC_word_t uECC_vli_testBit(const uECC_word_t *vli, bitcount_t bit); + +/* + * @brief Computes result = product % mod, where product is 2N words long. + * @param result OUT -- product % mod + * @param mod IN -- module + * @param num_words IN -- number of words + * @warning Currently only designed to work for curve_p or curve_n. + */ +void uECC_vli_mmod(uECC_word_t *result, uECC_word_t *product, + const uECC_word_t *mod, wordcount_t num_words); + +/* + * @brief Computes modular product (using curve->mmod_fast) + * @param result OUT -- (left * right) mod % curve_p + * @param left IN -- left term in product + * @param right IN -- right term in product + * @param curve IN -- elliptic curve + */ +void uECC_vli_modMult_fast(uECC_word_t *result, const uECC_word_t *left, + const uECC_word_t *right, uECC_Curve curve); + +/* + * @brief Computes result = left - right. + * @note Can modify in place. + * @param result OUT -- left - right + * @param left IN -- left term in subtraction + * @param right IN -- right term in subtraction + * @param num_words IN -- number of words + * @return borrow + */ +uECC_word_t uECC_vli_sub(uECC_word_t *result, const uECC_word_t *left, + const uECC_word_t *right, wordcount_t num_words); + +/* + * @brief Constant-time comparison function(secure way to compare long ints) + * @param left IN -- left term in comparison + * @param right IN -- right term in comparison + * @param num_words IN -- number of words + * @return Returns 0 if left == right, 1 otherwise. + */ +uECC_word_t uECC_vli_equal(const uECC_word_t *left, const uECC_word_t *right, + wordcount_t num_words); + +/* + * @brief Computes (left * right) % mod + * @param result OUT -- (left * right) % mod + * @param left IN -- left term in product + * @param right IN -- right term in product + * @param mod IN -- mod + * @param num_words IN -- number of words + */ +void uECC_vli_modMult(uECC_word_t *result, const uECC_word_t *left, + const uECC_word_t *right, const uECC_word_t *mod, + wordcount_t num_words); + +/* + * @brief Computes (1 / input) % mod + * @note All VLIs are the same size. + * @note See "Euclid's GCD to Montgomery Multiplication to the Great Divide" + * @param result OUT -- (1 / input) % mod + * @param input IN -- value to be modular inverted + * @param mod IN -- mod + * @param num_words -- number of words + */ +void uECC_vli_modInv(uECC_word_t *result, const uECC_word_t *input, + const uECC_word_t *mod, wordcount_t num_words); + +/* + * @brief Sets dest = src. + * @param dest OUT -- destination buffer + * @param src IN -- origin buffer + * @param num_words IN -- number of words + */ +void uECC_vli_set(uECC_word_t *dest, const uECC_word_t *src, + wordcount_t num_words); + +/* + * @brief Computes (left + right) % mod. + * @note Assumes that (left < mod) and right < mod), and that result does not + * overlap mod. + * @param result OUT -- (left + right) % mod. + * @param left IN -- left term in addition + * @param right IN -- right term in addition + * @param mod IN -- mod + * @param num_words IN -- number of words + */ +void uECC_vli_modAdd(uECC_word_t *result, const uECC_word_t *left, + const uECC_word_t *right, const uECC_word_t *mod, + wordcount_t num_words); + +/* + * @brief Counts the number of bits required to represent vli. + * @param vli IN -- very long integer + * @param max_words IN -- number of words + * @return number of bits in given vli + */ +bitcount_t uECC_vli_numBits(const uECC_word_t *vli, + const wordcount_t max_words); + +/* + * @brief Erases (set to 0) vli + * @param vli IN -- very long integer + * @param num_words IN -- number of words + */ +void uECC_vli_clear(uECC_word_t *vli, wordcount_t num_words); + +/* + * @brief check if it is a valid point in the curve + * @param point IN -- point to be checked + * @param curve IN -- elliptic curve + * @return 0 if point is valid + * @exception returns -1 if it is a point at infinity + * @exception returns -2 if x or y is smaller than p, + * @exception returns -3 if y^2 != x^3 + ax + b. + */ +int uECC_valid_point(const uECC_word_t *point, uECC_Curve curve); + +/* + * @brief Check if a public key is valid. + * @param public_key IN -- The public key to be checked. + * @return returns 0 if the public key is valid + * @exception returns -1 if it is a point at infinity + * @exception returns -2 if x or y is smaller than p, + * @exception returns -3 if y^2 != x^3 + ax + b. + * @exception returns -4 if public key is the group generator. + * + * @note Note that you are not required to check for a valid public key before + * using any other uECC functions. However, you may wish to avoid spending CPU + * time computing a shared secret or verifying a signature using an invalid + * public key. + */ +int uECC_valid_public_key(const uint8_t *public_key, uECC_Curve curve); + +/* + * @brief Converts an integer in uECC native format to big-endian bytes. + * @param bytes OUT -- bytes representation + * @param num_bytes IN -- number of bytes + * @param native IN -- uECC native representation + */ +void uECC_vli_nativeToBytes(uint8_t *bytes, int num_bytes, + const unsigned int *native); + +/* + * @brief Converts big-endian bytes to an integer in uECC native format. + * @param native OUT -- uECC native representation + * @param bytes IN -- bytes representation + * @param num_bytes IN -- number of bytes + */ +void uECC_vli_bytesToNative(unsigned int *native, const uint8_t *bytes, + int num_bytes); + +#ifdef __cplusplus +} +#endif + +#endif /* __BLE_MESH_TC_UECC_H__ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ecc_dh.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ecc_dh.h new file mode 100644 index 00000000000..ba9a0ebb2dc --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ecc_dh.h @@ -0,0 +1,131 @@ +/* ecc_dh.h - TinyCrypt interface to EC-DH implementation */ + +/* + * Copyright (c) 2014, Kenneth MacKay + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief -- Interface to EC-DH implementation. + * + * Overview: This software is an implementation of EC-DH. This implementation + * uses curve NIST p-256. + * + * Security: The curve NIST p-256 provides approximately 128 bits of security. + */ + +#ifndef __BLE_MESH_TC_ECC_DH_H__ +#define __BLE_MESH_TC_ECC_DH_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Create a public/private key pair. + * @return returns TC_CRYPTO_SUCCESS (1) if the key pair was generated successfully + * returns TC_CRYPTO_FAIL (0) if error while generating key pair + * + * @param p_public_key OUT -- Will be filled in with the public key. Must be at + * least 2 * the curve size (in bytes) long. For curve secp256r1, p_public_key + * must be 64 bytes long. + * @param p_private_key OUT -- Will be filled in with the private key. Must be as + * long as the curve order (for secp256r1, p_private_key must be 32 bytes long). + * + * @note side-channel countermeasure: algorithm strengthened against timing + * attack. + * @warning A cryptographically-secure PRNG function must be set (using + * uECC_set_rng()) before calling uECC_make_key(). + */ +int uECC_make_key(uint8_t *p_public_key, uint8_t *p_private_key, uECC_Curve curve); + +#ifdef ENABLE_TESTS + +/** + * @brief Create a public/private key pair given a specific d. + * + * @note THIS FUNCTION SHOULD BE CALLED ONLY FOR TEST PURPOSES. Refer to + * uECC_make_key() function for real applications. + */ +int uECC_make_key_with_d(uint8_t *p_public_key, uint8_t *p_private_key, + unsigned int *d, uECC_Curve curve); +#endif + +/** + * @brief Compute a shared secret given your secret key and someone else's + * public key. + * @return returns TC_CRYPTO_SUCCESS (1) if the shared secret was computed successfully + * returns TC_CRYPTO_FAIL (0) otherwise + * + * @param p_secret OUT -- Will be filled in with the shared secret value. Must be + * the same size as the curve size (for curve secp256r1, secret must be 32 bytes + * long. + * @param p_public_key IN -- The public key of the remote party. + * @param p_private_key IN -- Your private key. + * + * @warning It is recommended to use the output of uECC_shared_secret() as the + * input of a recommended Key Derivation Function (see NIST SP 800-108) in + * order to produce a cryptographically secure symmetric key. + */ +int uECC_shared_secret(const uint8_t *p_public_key, const uint8_t *p_private_key, + uint8_t *p_secret, uECC_Curve curve); + +#ifdef __cplusplus +} +#endif + +#endif /* __BLE_MESH_TC_ECC_DH_H__ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ecc_dsa.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ecc_dsa.h new file mode 100644 index 00000000000..cfada859d32 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ecc_dsa.h @@ -0,0 +1,139 @@ +/* ecc_dh.h - TinyCrypt interface to EC-DSA implementation */ + +/* + * Copyright (c) 2014, Kenneth MacKay + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief -- Interface to EC-DSA implementation. + * + * Overview: This software is an implementation of EC-DSA. This implementation + * uses curve NIST p-256. + * + * Security: The curve NIST p-256 provides approximately 128 bits of security. + * + * Usage: - To sign: Compute a hash of the data you wish to sign (SHA-2 is + * recommended) and pass it in to ecdsa_sign function along with your + * private key and a random number. You must use a new non-predictable + * random number to generate each new signature. + * - To verify a signature: Compute the hash of the signed data using + * the same hash as the signer and pass it to this function along with + * the signer's public key and the signature values (r and s). + */ + +#ifndef __BLE_MESH_TC_ECC_DSA_H__ +#define __BLE_MESH_TC_ECC_DSA_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Generate an ECDSA signature for a given hash value. + * @return returns TC_CRYPTO_SUCCESS (1) if the signature generated successfully + * returns TC_CRYPTO_FAIL (0) if an error occurred. + * + * @param p_private_key IN -- Your private key. + * @param p_message_hash IN -- The hash of the message to sign. + * @param p_hash_size IN -- The size of p_message_hash in bytes. + * @param p_signature OUT -- Will be filled in with the signature value. Must be + * at least 2 * curve size long (for secp256r1, signature must be 64 bytes long). + * + * @warning A cryptographically-secure PRNG function must be set (using + * uECC_set_rng()) before calling uECC_sign(). + * @note Usage: Compute a hash of the data you wish to sign (SHA-2 is + * recommended) and pass it in to this function along with your private key. + * @note side-channel countermeasure: algorithm strengthened against timing + * attack. + */ +int uECC_sign(const uint8_t *p_private_key, const uint8_t *p_message_hash, + unsigned p_hash_size, uint8_t *p_signature, uECC_Curve curve); + +#ifdef ENABLE_TESTS +/* + * THIS FUNCTION SHOULD BE CALLED FOR TEST PURPOSES ONLY. + * Refer to uECC_sign() function for real applications. + */ +int uECC_sign_with_k(const uint8_t *private_key, const uint8_t *message_hash, + unsigned int hash_size, uECC_word_t *k, uint8_t *signature, + uECC_Curve curve); +#endif + +/** + * @brief Verify an ECDSA signature. + * @return returns TC_SUCCESS (1) if the signature is valid + * returns TC_FAIL (0) if the signature is invalid. + * + * @param p_public_key IN -- The signer's public key. + * @param p_message_hash IN -- The hash of the signed data. + * @param p_hash_size IN -- The size of p_message_hash in bytes. + * @param p_signature IN -- The signature values. + * + * @note Usage: Compute the hash of the signed data using the same hash as the + * signer and pass it to this function along with the signer's public key and + * the signature values (hash_size and signature). + */ +int uECC_verify(const uint8_t *p_public_key, const uint8_t *p_message_hash, + unsigned int p_hash_size, const uint8_t *p_signature, uECC_Curve curve); + +#ifdef __cplusplus +} +#endif + +#endif /* __BLE_MESH_TC_ECC_DSA_H__ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ecc_platform_specific.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ecc_platform_specific.h new file mode 100644 index 00000000000..972e5f7fee3 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/ecc_platform_specific.h @@ -0,0 +1,81 @@ +/* uECC_platform_specific.h - Interface to platform specific functions*/ + +/* Copyright (c) 2014, Kenneth MacKay + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE.*/ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * uECC_platform_specific.h -- Interface to platform specific functions + */ + +#ifndef __BLE_MESH_UECC_PLATFORM_SPECIFIC_H_ +#define __BLE_MESH_UECC_PLATFORM_SPECIFIC_H_ + +/* + * The RNG function should fill 'size' random bytes into 'dest'. It should + * return 1 if 'dest' was filled with random data, or 0 if the random data could + * not be generated. The filled-in values should be either truly random, or from + * a cryptographically-secure PRNG. + * + * A cryptographically-secure PRNG function must be set (using uECC_set_rng()) + * before calling uECC_make_key() or uECC_sign(). + * + * Setting a cryptographically-secure PRNG function improves the resistance to + * side-channel attacks for uECC_shared_secret(). + * + * A correct PRNG function is set by default (default_RNG_defined = 1) and works + * for some platforms, such as Unix and Linux. For other platforms, you may need + * to provide another PRNG function. +*/ +#define default_RNG_defined 0 + +int default_CSPRNG(uint8_t *dest, unsigned int size); + +#endif /* __BLE_MESH_UECC_PLATFORM_SPECIFIC_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/hmac.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/hmac.h new file mode 100644 index 00000000000..cb399d8d5c7 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/hmac.h @@ -0,0 +1,139 @@ +/* hmac.h - TinyCrypt interface to an HMAC implementation */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief Interface to an HMAC implementation. + * + * Overview: HMAC is a message authentication code based on hash functions. + * TinyCrypt hard codes SHA-256 as the hash function. A message + * authentication code based on hash functions is also called a + * keyed cryptographic hash function since it performs a + * transformation specified by a key in an arbitrary length data + * set into a fixed length data set (also called tag). + * + * Security: The security of the HMAC depends on the length of the key and + * on the security of the hash function. Note that HMAC primitives + * are much less affected by collision attacks than their + * corresponding hash functions. + * + * Requires: SHA-256 + * + * Usage: 1) call tc_hmac_set_key to set the HMAC key. + * + * 2) call tc_hmac_init to initialize a struct hash_state before + * processing the data. + * + * 3) call tc_hmac_update to process the next input segment; + * tc_hmac_update can be called as many times as needed to process + * all of the segments of the input; the order is important. + * + * 4) call tc_hmac_final to out put the tag. + */ + +#ifndef __BLE_MESH_TC_HMAC_H__ +#define __BLE_MESH_TC_HMAC_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct tc_hmac_state_struct { + /* the internal state required by h */ + struct tc_sha256_state_struct hash_state; + /* HMAC key schedule */ + uint8_t key[2 * TC_SHA256_BLOCK_SIZE]; +}; +typedef struct tc_hmac_state_struct *TCHmacState_t; + +/** + * @brief HMAC set key procedure + * Configures ctx to use key + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if + * ctx == NULL or + * key == NULL or + * key_size == 0 + * @param ctx IN/OUT -- the struct tc_hmac_state_struct to initial + * @param key IN -- the HMAC key to configure + * @param key_size IN -- the HMAC key size + */ +int tc_hmac_set_key(TCHmacState_t ctx, const uint8_t *key, + unsigned int key_size); + +/** + * @brief HMAC init procedure + * Initializes ctx to begin the next HMAC operation + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: ctx == NULL or key == NULL + * @param ctx IN/OUT -- struct tc_hmac_state_struct buffer to init + */ +int tc_hmac_init(TCHmacState_t ctx); + +/** + * @brief HMAC update procedure + * Mixes data_length bytes addressed by data into state + * @return returns TC_CRYPTO_SUCCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: ctx == NULL or key == NULL + * @note Assumes state has been initialized by tc_hmac_init + * @param ctx IN/OUT -- state of HMAC computation so far + * @param data IN -- data to incorporate into state + * @param data_length IN -- size of data in bytes + */ +int tc_hmac_update(TCHmacState_t ctx, const void *data, + unsigned int data_length); + +/** + * @brief HMAC final procedure + * Writes the HMAC tag into the tag buffer + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: + * tag == NULL or + * ctx == NULL or + * key == NULL or + * taglen != TC_SHA256_DIGEST_SIZE + * @note ctx is erased before exiting. This should never be changed/removed. + * @note Assumes the tag bufer is at least sizeof(hmac_tag_size(state)) bytes + * state has been initialized by tc_hmac_init + * @param tag IN/OUT -- buffer to receive computed HMAC tag + * @param taglen IN -- size of tag in bytes + * @param ctx IN/OUT -- the HMAC state for computing tag + */ +int tc_hmac_final(uint8_t *tag, unsigned int taglen, TCHmacState_t ctx); + +#ifdef __cplusplus +} +#endif + +#endif /*__BLE_MESH_TC_HMAC_H__*/ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/hmac_prng.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/hmac_prng.h new file mode 100644 index 00000000000..f7f90010213 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/hmac_prng.h @@ -0,0 +1,164 @@ +/* hmac_prng.h - TinyCrypt interface to an HMAC-PRNG implementation */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief Interface to an HMAC-PRNG implementation. + * + * Overview: A pseudo-random number generator (PRNG) generates a sequence + * of numbers that have a distribution close to the one expected + * for a sequence of truly random numbers. The NIST Special + * Publication 800-90A specifies several mechanisms to generate + * sequences of pseudo random numbers, including the HMAC-PRNG one + * which is based on HMAC. TinyCrypt implements HMAC-PRNG with + * certain modifications from the NIST SP 800-90A spec. + * + * Security: A cryptographically secure PRNG depends on the existence of an + * entropy source to provide a truly random seed as well as the + * security of the primitives used as the building blocks (HMAC and + * SHA256, for TinyCrypt). + * + * The NIST SP 800-90A standard tolerates a null personalization, + * while TinyCrypt requires a non-null personalization. This is + * because a personalization string (the host name concatenated + * with a time stamp, for example) is easily computed and might be + * the last line of defense against failure of the entropy source. + * + * Requires: - SHA-256 + * - HMAC + * + * Usage: 1) call tc_hmac_prng_init to set the HMAC key and process the + * personalization data. + * + * 2) call tc_hmac_prng_reseed to process the seed and additional + * input. + * + * 3) call tc_hmac_prng_generate to out put the pseudo-random data. + */ + +#ifndef __BLE_MESH_TC_HMAC_PRNG_H__ +#define __BLE_MESH_TC_HMAC_PRNG_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define TC_HMAC_PRNG_RESEED_REQ -1 + +struct tc_hmac_prng_struct { + /* the HMAC instance for this PRNG */ + struct tc_hmac_state_struct h; + /* the PRNG key */ + uint8_t key[TC_SHA256_DIGEST_SIZE]; + /* PRNG state */ + uint8_t v[TC_SHA256_DIGEST_SIZE]; + /* calls to tc_hmac_prng_generate left before re-seed */ + unsigned int countdown; +}; + +typedef struct tc_hmac_prng_struct *TCHmacPrng_t; + +/** + * @brief HMAC-PRNG initialization procedure + * Initializes prng with personalization, disables tc_hmac_prng_generate + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: + * prng == NULL, + * personalization == NULL, + * plen > MAX_PLEN + * @note Assumes: - personalization != NULL. + * The personalization is a platform unique string (e.g., the host + * name) and is the last line of defense against failure of the + * entropy source + * @warning NIST SP 800-90A specifies 3 items as seed material during + * initialization: entropy seed, personalization, and an optional + * nonce. TinyCrypts requires instead a non-null personalization + * (which is easily computed) and indirectly requires an entropy + * seed (since the reseed function is mandatorily called after + * init) + * @param prng IN/OUT -- the PRNG state to initialize + * @param personalization IN -- personalization string + * @param plen IN -- personalization length in bytes + */ +int tc_hmac_prng_init(TCHmacPrng_t prng, + const uint8_t *personalization, + unsigned int plen); + +/** + * @brief HMAC-PRNG reseed procedure + * Mixes seed into prng, enables tc_hmac_prng_generate + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: + * prng == NULL, + * seed == NULL, + * seedlen < MIN_SLEN, + * seendlen > MAX_SLEN, + * additional_input != (const uint8_t *) 0 && additionallen == 0, + * additional_input != (const uint8_t *) 0 && additionallen > MAX_ALEN + * @note Assumes:- tc_hmac_prng_init has been called for prng + * - seed has sufficient entropy. + * + * @param prng IN/OUT -- the PRNG state + * @param seed IN -- entropy to mix into the prng + * @param seedlen IN -- length of seed in bytes + * @param additional_input IN -- additional input to the prng + * @param additionallen IN -- additional input length in bytes + */ +int tc_hmac_prng_reseed(TCHmacPrng_t prng, const uint8_t *seed, + unsigned int seedlen, const uint8_t *additional_input, + unsigned int additionallen); + +/** + * @brief HMAC-PRNG generate procedure + * Generates outlen pseudo-random bytes into out buffer, updates prng + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_HMAC_PRNG_RESEED_REQ (-1) if a reseed is needed + * returns TC_CRYPTO_FAIL (0) if: + * out == NULL, + * prng == NULL, + * outlen == 0, + * outlen >= MAX_OUT + * @note Assumes tc_hmac_prng_init has been called for prng + * @param out IN/OUT -- buffer to receive output + * @param outlen IN -- size of out buffer in bytes + * @param prng IN/OUT -- the PRNG state + */ +int tc_hmac_prng_generate(uint8_t *out, unsigned int outlen, TCHmacPrng_t prng); + +#ifdef __cplusplus +} +#endif + +#endif /* __BLE_MESH_TC_HMAC_PRNG_H__ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/sha256.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/sha256.h new file mode 100644 index 00000000000..c57cb00cad2 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/sha256.h @@ -0,0 +1,129 @@ +/* sha256.h - TinyCrypt interface to a SHA-256 implementation */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief Interface to a SHA-256 implementation. + * + * Overview: SHA-256 is a NIST approved cryptographic hashing algorithm + * specified in FIPS 180. A hash algorithm maps data of arbitrary + * size to data of fixed length. + * + * Security: SHA-256 provides 128 bits of security against collision attacks + * and 256 bits of security against pre-image attacks. SHA-256 does + * NOT behave like a random oracle, but it can be used as one if + * the string being hashed is prefix-free encoded before hashing. + * + * Usage: 1) call tc_sha256_init to initialize a struct + * tc_sha256_state_struct before hashing a new string. + * + * 2) call tc_sha256_update to hash the next string segment; + * tc_sha256_update can be called as many times as needed to hash + * all of the segments of a string; the order is important. + * + * 3) call tc_sha256_final to out put the digest from a hashing + * operation. + */ + +#ifndef __BLE_MESH_TC_SHA256_H__ +#define __BLE_MESH_TC_SHA256_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define TC_SHA256_BLOCK_SIZE (64) +#define TC_SHA256_DIGEST_SIZE (32) +#define TC_SHA256_STATE_BLOCKS (TC_SHA256_DIGEST_SIZE/4) + +struct tc_sha256_state_struct { + unsigned int iv[TC_SHA256_STATE_BLOCKS]; + uint64_t bits_hashed; + uint8_t leftover[TC_SHA256_BLOCK_SIZE]; + size_t leftover_offset; +}; + +typedef struct tc_sha256_state_struct *TCSha256State_t; + +/** + * @brief SHA256 initialization procedure + * Initializes s + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if s == NULL + * @param s Sha256 state struct + */ +int tc_sha256_init(TCSha256State_t s); + +/** + * @brief SHA256 update procedure + * Hashes data_length bytes addressed by data into state s + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: + * s == NULL, + * s->iv == NULL, + * data == NULL + * @note Assumes s has been initialized by tc_sha256_init + * @warning The state buffer 'leftover' is left in memory after processing + * If your application intends to have sensitive data in this + * buffer, remind to erase it after the data has been processed + * @param s Sha256 state struct + * @param data message to hash + * @param datalen length of message to hash + */ +int tc_sha256_update (TCSha256State_t s, const uint8_t *data, size_t datalen); + +/** + * @brief SHA256 final procedure + * Inserts the completed hash computation into digest + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: + * s == NULL, + * s->iv == NULL, + * digest == NULL + * @note Assumes: s has been initialized by tc_sha256_init + * digest points to at least TC_SHA256_DIGEST_SIZE bytes + * @warning The state buffer 'leftover' is left in memory after processing + * If your application intends to have sensitive data in this + * buffer, remind to erase it after the data has been processed + * @param digest unsigned eight bit integer + * @param Sha256 state struct + */ +int tc_sha256_final(uint8_t *digest, TCSha256State_t s); + +#ifdef __cplusplus +} +#endif + +#endif /* __BLE_MESH_TC_SHA256_H__ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/utils.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/utils.h new file mode 100644 index 00000000000..422892390fd --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_common/tinycrypt/include/tinycrypt/utils.h @@ -0,0 +1,121 @@ +/* utils.h - TinyCrypt interface to platform-dependent run-time operations */ + +/* + * Copyright (C) 2017 by Intel Corporation, All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief Interface to platform-dependent run-time operations. + * + */ + +#ifndef __BLE_MESH_TC_UTILS_H__ +#define __BLE_MESH_TC_UTILS_H__ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Copy the the buffer 'from' to the buffer 'to'. + * @return returns TC_CRYPTO_SUCCESS (1) + * returns TC_CRYPTO_FAIL (0) if: + * from_len > to_len. + * + * @param to OUT -- destination buffer + * @param to_len IN -- length of destination buffer + * @param from IN -- origin buffer + * @param from_len IN -- length of origin buffer + */ +unsigned int _copy(uint8_t *to, unsigned int to_len, + const uint8_t *from, unsigned int from_len); + +/** + * @brief Set the value 'val' into the buffer 'to', 'len' times. + * + * @param to OUT -- destination buffer + * @param val IN -- value to be set in 'to' + * @param len IN -- number of times the value will be copied + */ +void _set(void *to, uint8_t val, unsigned int len); + +/** + * @brief Set the value 'val' into the buffer 'to', 'len' times, in a way + * which does not risk getting optimized out by the compiler + * In cases where the compiler does not set __GNUC__ and where the + * optimization level removes the memset, it may be necessary to + * implement a _set_secure function and define the + * TINYCRYPT_ARCH_HAS_SET_SECURE, which then can ensure that the + * memset does not get optimized out. + * + * @param to OUT -- destination buffer + * @param val IN -- value to be set in 'to' + * @param len IN -- number of times the value will be copied + */ +#ifdef TINYCRYPT_ARCH_HAS_SET_SECURE +extern void _set_secure(void *to, uint8_t val, unsigned int len); +#else /* ! TINYCRYPT_ARCH_HAS_SET_SECURE */ +static inline void _set_secure(void *to, uint8_t val, unsigned int len) +{ + (void) memset(to, val, len); +#ifdef __GNUC__ + __asm__ __volatile__("" :: "g"(to) : "memory"); +#endif /* __GNUC__ */ +} +#endif /* TINYCRYPT_ARCH_HAS_SET_SECURE */ + +/* + * @brief AES specific doubling function, which utilizes + * the finite field used by AES. + * @return Returns a^2 + * + * @param a IN/OUT -- value to be doubled + */ +uint8_t _double_byte(uint8_t a); + +/* + * @brief Constant-time algorithm to compare if two sequences of bytes are equal + * @return Returns 0 if equal, and non-zero otherwise + * + * @param a IN -- sequence of bytes a + * @param b IN -- sequence of bytes b + * @param size IN -- size of sequences a and b + */ +int _compare(const uint8_t *a, const uint8_t *b, size_t size); + +#ifdef __cplusplus +} +#endif + +#endif /* __BLE_MESH_TC_UTILS_H__ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/access.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/access.h new file mode 100644 index 00000000000..a74e0563920 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/access.h @@ -0,0 +1,80 @@ +/* Bluetooth Mesh */ + +/* + * SPDX-FileCopyrightText: 2017 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _ACCESS_H_ +#define _ACCESS_H_ + +#include "net.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* bt_mesh_model.flags */ +enum { + BLE_MESH_MOD_BIND_PENDING = BIT(0), + BLE_MESH_MOD_SUB_PENDING = BIT(1), + BLE_MESH_MOD_PUB_PENDING = BIT(2), +}; + +void bt_mesh_elem_register(struct bt_mesh_elem *elem, uint8_t count); + +uint8_t bt_mesh_elem_count(void); + +/* Find local element based on unicast or group address */ +struct bt_mesh_elem *bt_mesh_elem_find(uint16_t addr); + +uint16_t *bt_mesh_model_find_group(struct bt_mesh_model *mod, uint16_t addr); + +bool bt_mesh_fixed_group_match(uint16_t addr); + +void bt_mesh_model_foreach(void (*func)(struct bt_mesh_model *mod, + struct bt_mesh_elem *elem, + bool vnd, bool primary, + void *user_data), + void *user_data); + +int32_t bt_mesh_model_pub_period_get(struct bt_mesh_model *mod); + +void bt_mesh_comp_provision(uint16_t addr); +void bt_mesh_comp_unprovision(void); + +uint16_t bt_mesh_primary_addr(void); + +const struct bt_mesh_comp *bt_mesh_comp_get(void); + +struct bt_mesh_model *bt_mesh_model_get(bool vnd, uint8_t elem_idx, uint8_t mod_idx); + +void bt_mesh_model_recv(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf); + +int bt_mesh_comp_register(const struct bt_mesh_comp *comp); +int bt_mesh_comp_deregister(void); + +struct bt_mesh_subnet *bt_mesh_tx_netkey_get(uint8_t role, uint16_t net_idx); + +const uint8_t *bt_mesh_tx_devkey_get(uint8_t role, uint16_t dst); + +struct bt_mesh_app_key *bt_mesh_tx_appkey_get(uint8_t role, uint16_t app_idx); + +size_t bt_mesh_rx_netkey_size(void); + +struct bt_mesh_subnet *bt_mesh_rx_netkey_get(size_t index); + +size_t bt_mesh_rx_devkey_size(void); + +const uint8_t *bt_mesh_rx_devkey_get(size_t index, uint16_t src); + +size_t bt_mesh_rx_appkey_size(void); + +struct bt_mesh_app_key *bt_mesh_rx_appkey_get(size_t index); + +#ifdef __cplusplus +} +#endif + +#endif /* _ACCESS_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/adv.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/adv.h new file mode 100644 index 00000000000..27108c203a0 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/adv.h @@ -0,0 +1,102 @@ +/* Bluetooth Mesh */ + +/* + * SPDX-FileCopyrightText: 2017 Intel Corporation + * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _ADV_H_ +#define _ADV_H_ + +#include "mesh_access.h" +#include "mesh_bearer_adapt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Maximum advertising data payload for a single data type */ +#define BLE_MESH_ADV_DATA_SIZE 29 + +/* The user data is a pointer (4 bytes) to struct bt_mesh_adv */ +#define BLE_MESH_ADV_USER_DATA_SIZE 4 + +#define BLE_MESH_ADV(buf) (*(struct bt_mesh_adv **)net_buf_user_data(buf)) + +typedef struct bt_mesh_msg { + bool relay; /* Flag indicates if the packet is a relayed one */ + void *arg; /* Pointer to the struct net_buf */ + uint16_t src; /* Source address for relay packets */ + uint16_t dst; /* Destination address for relay packets */ + uint32_t timestamp; /* Timestamp recorded when the relay packet is posted to queue */ +} bt_mesh_msg_t; + +enum bt_mesh_adv_type { + BLE_MESH_ADV_PROV, + BLE_MESH_ADV_DATA, + BLE_MESH_ADV_BEACON, + BLE_MESH_ADV_URI, + BLE_MESH_ADV_BLE, +}; + +struct bt_mesh_adv { + const struct bt_mesh_send_cb *cb; + void *cb_data; + + uint8_t type:3, + busy:1; + uint8_t xmit; +}; + +typedef struct bt_mesh_adv *(*bt_mesh_adv_alloc_t)(int id); + +/* xmit_count: Number of retransmissions, i.e. 0 == 1 transmission */ +struct net_buf *bt_mesh_adv_create(enum bt_mesh_adv_type type, uint8_t xmit, + int32_t timeout); + +typedef enum { + BLE_MESH_BUF_REF_EQUAL, + BLE_MESH_BUF_REF_SMALL, + BLE_MESH_BUF_REF_MAX, +} bt_mesh_buf_ref_flag_t; + +void bt_mesh_adv_buf_ref_debug(const char *func, struct net_buf *buf, + uint8_t ref_cmp, bt_mesh_buf_ref_flag_t flag); + +struct net_buf *bt_mesh_adv_create_from_pool(struct net_buf_pool *pool, + bt_mesh_adv_alloc_t get_id, + enum bt_mesh_adv_type type, + uint8_t xmit, int32_t timeout); + +void bt_mesh_unref_buf_from_pool(struct net_buf_pool *pool); + +void bt_mesh_adv_send(struct net_buf *buf, const struct bt_mesh_send_cb *cb, + void *cb_data); + +struct net_buf *bt_mesh_relay_adv_create(enum bt_mesh_adv_type type, uint8_t xmit, + int32_t timeout); + +void bt_mesh_relay_adv_send(struct net_buf *buf, const struct bt_mesh_send_cb *cb, + void *cb_data, uint16_t src, uint16_t dst); + +uint16_t bt_mesh_get_stored_relay_count(void); + +void bt_mesh_adv_update(void); + +void bt_mesh_adv_init(void); +void bt_mesh_adv_deinit(void); + +#if CONFIG_BLE_MESH_SUPPORT_BLE_ADV +int bt_mesh_start_ble_advertising(const struct bt_mesh_ble_adv_param *param, + const struct bt_mesh_ble_adv_data *data, uint8_t *index); + +int bt_mesh_stop_ble_advertising(uint8_t index); +#endif /* CONFIG_BLE_MESH_SUPPORT_BLE_ADV */ + +#ifdef __cplusplus +} +#endif + +#endif /* _ADV_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/beacon.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/beacon.h new file mode 100644 index 00000000000..5e97b4cfe00 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/beacon.h @@ -0,0 +1,35 @@ +/* Bluetooth Mesh */ + +/* + * SPDX-FileCopyrightText: 2017 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _BEACON_H_ +#define _BEACON_H_ + +#include "net.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void bt_mesh_beacon_enable(void); +void bt_mesh_beacon_disable(void); + +void bt_mesh_beacon_ivu_initiator(bool enable); + +void bt_mesh_beacon_recv(struct net_buf_simple *buf, int8_t rssi); + +void bt_mesh_beacon_create(struct bt_mesh_subnet *sub, + struct net_buf_simple *buf); + +void bt_mesh_beacon_init(void); +void bt_mesh_beacon_deinit(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _BEACON_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/crypto.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/crypto.h new file mode 100644 index 00000000000..e8b3450728c --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/crypto.h @@ -0,0 +1,174 @@ +/* Bluetooth Mesh */ + +/* + * SPDX-FileCopyrightText: 2017 Intel Corporation + * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _CRYPTO_H_ +#define _CRYPTO_H_ + +#include +#include "mesh_buf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct bt_mesh_sg { + const void *data; + size_t len; +}; + +int bt_mesh_aes_cmac(const uint8_t key[16], struct bt_mesh_sg *sg, + size_t sg_len, uint8_t mac[16]); + +static inline int bt_mesh_aes_cmac_one(const uint8_t key[16], const void *m, + size_t len, uint8_t mac[16]) +{ + struct bt_mesh_sg sg = { m, len }; + + return bt_mesh_aes_cmac(key, &sg, 1, mac); +} + +static inline bool bt_mesh_s1(const char *m, uint8_t salt[16]) +{ + const uint8_t zero[16] = { 0 }; + + return bt_mesh_aes_cmac_one(zero, m, strlen(m), salt); +} + +int bt_mesh_k1(const uint8_t *ikm, size_t ikm_len, const uint8_t salt[16], + const char *info, uint8_t okm[16]); + +#define bt_mesh_k1_str(ikm, ikm_len, salt_str, info, okm) \ +({ \ + const uint8_t salt[16] = salt_str; \ + bt_mesh_k1(ikm, ikm_len, salt, info, okm); \ +}) + +int bt_mesh_k2(const uint8_t n[16], const uint8_t *p, size_t p_len, + uint8_t net_id[1], uint8_t enc_key[16], uint8_t priv_key[16]); + +int bt_mesh_k3(const uint8_t n[16], uint8_t out[8]); + +int bt_mesh_k4(const uint8_t n[16], uint8_t out[1]); + +int bt_mesh_id128(const uint8_t n[16], const char *s, uint8_t out[16]); + +static inline int bt_mesh_id_resolving_key(const uint8_t net_key[16], + uint8_t resolving_key[16]) +{ + return bt_mesh_k1_str(net_key, 16, "smbt", "smbi", resolving_key); +} + +static inline int bt_mesh_identity_key(const uint8_t net_key[16], + uint8_t identity_key[16]) +{ + return bt_mesh_id128(net_key, "nkik", identity_key); +} + +static inline int bt_mesh_beacon_key(const uint8_t net_key[16], + uint8_t beacon_key[16]) +{ + return bt_mesh_id128(net_key, "nkbk", beacon_key); +} + +int bt_mesh_beacon_auth(const uint8_t beacon_key[16], uint8_t flags, + const uint8_t net_id[16], uint32_t iv_index, + uint8_t auth[8]); + +static inline int bt_mesh_app_id(const uint8_t app_key[16], uint8_t app_id[1]) +{ + return bt_mesh_k4(app_key, app_id); +} + +static inline int bt_mesh_session_key(const uint8_t dhkey[32], + const uint8_t prov_salt[16], + uint8_t session_key[16]) +{ + return bt_mesh_k1(dhkey, 32, prov_salt, "prsk", session_key); +} + +static inline int bt_mesh_prov_nonce(const uint8_t dhkey[32], + const uint8_t prov_salt[16], + uint8_t nonce[13]) +{ + uint8_t tmp[16]; + int err; + + err = bt_mesh_k1(dhkey, 32, prov_salt, "prsn", tmp); + if (!err) { + memcpy(nonce, tmp + 3, 13); + } + + return err; +} + +static inline int bt_mesh_dev_key(const uint8_t dhkey[32], + const uint8_t prov_salt[16], + uint8_t dev_key[16]) +{ + return bt_mesh_k1(dhkey, 32, prov_salt, "prdk", dev_key); +} + +static inline int bt_mesh_prov_salt(const uint8_t conf_salt[16], + const uint8_t prov_rand[16], + const uint8_t dev_rand[16], + uint8_t prov_salt[16]) +{ + const uint8_t prov_salt_key[16] = { 0 }; + struct bt_mesh_sg sg[] = { + { conf_salt, 16 }, + { prov_rand, 16 }, + { dev_rand, 16 }, + }; + + return bt_mesh_aes_cmac(prov_salt_key, sg, ARRAY_SIZE(sg), prov_salt); +} + +int bt_mesh_net_obfuscate(uint8_t *pdu, uint32_t iv_index, + const uint8_t privacy_key[16]); + +int bt_mesh_net_encrypt(const uint8_t key[16], struct net_buf_simple *buf, + uint32_t iv_index, bool proxy); + +int bt_mesh_net_decrypt(const uint8_t key[16], struct net_buf_simple *buf, + uint32_t iv_index, bool proxy); + +int bt_mesh_app_encrypt(const uint8_t key[16], bool dev_key, uint8_t aszmic, + struct net_buf_simple *buf, const uint8_t *ad, + uint16_t src, uint16_t dst, uint32_t seq_num, uint32_t iv_index); + +int bt_mesh_app_decrypt(const uint8_t key[16], bool dev_key, uint8_t aszmic, + struct net_buf_simple *buf, struct net_buf_simple *out, + const uint8_t *ad, uint16_t src, uint16_t dst, uint32_t seq_num, + uint32_t iv_index); + +uint8_t bt_mesh_fcs_calc(const uint8_t *data, uint8_t data_len); + +bool bt_mesh_fcs_check(struct net_buf_simple *buf, uint8_t received_fcs); + +int bt_mesh_virtual_addr(const uint8_t virtual_label[16], uint16_t *addr); + +int bt_mesh_prov_conf_salt(const uint8_t conf_inputs[145], uint8_t salt[16]); + +int bt_mesh_prov_conf_key(const uint8_t dhkey[32], const uint8_t conf_salt[16], + uint8_t conf_key[16]); + +int bt_mesh_prov_conf(const uint8_t conf_key[16], const uint8_t rand[16], + const uint8_t auth[16], uint8_t conf[16]); + +int bt_mesh_prov_decrypt(const uint8_t key[16], uint8_t nonce[13], + const uint8_t data[25 + 8], uint8_t out[25]); + +int bt_mesh_prov_encrypt(const uint8_t key[16], uint8_t nonce[13], + const uint8_t data[25], uint8_t out[33]); + +#ifdef __cplusplus +} +#endif + +#endif /* _CRYPTO_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/fast_prov.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/fast_prov.h new file mode 100644 index 00000000000..69bea4402f4 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/fast_prov.h @@ -0,0 +1,36 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _FAST_PROV_H_ +#define _FAST_PROV_H_ + +#include "net.h" + +#ifdef __cplusplus +extern "C" { +#endif + +const uint8_t *bt_mesh_fast_prov_dev_key_get(uint16_t dst); + +struct bt_mesh_subnet *bt_mesh_fast_prov_subnet_get(uint16_t net_idx); + +struct bt_mesh_app_key *bt_mesh_fast_prov_app_key_find(uint16_t app_idx); + +uint8_t bt_mesh_set_fast_prov_net_idx(uint16_t net_idx); + +uint8_t bt_mesh_fast_prov_net_key_add(const uint8_t net_key[16]); + +const uint8_t *bt_mesh_fast_prov_net_key_get(uint16_t net_idx); + +const uint8_t *bt_mesh_get_fast_prov_app_key(uint16_t net_idx, uint16_t app_idx); + +uint8_t bt_mesh_set_fast_prov_action(uint8_t action); + +#ifdef __cplusplus +} +#endif + +#endif /* _FAST_PROV_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/foundation.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/foundation.h new file mode 100644 index 00000000000..3855d93fb6f --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/foundation.h @@ -0,0 +1,183 @@ +/* Bluetooth Mesh */ + +/* + * SPDX-FileCopyrightText: 2017 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ +#ifndef _FOUNDATION_H_ +#define _FOUNDATION_H_ + +#include "mesh_byteorder.h" +#include "net.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define OP_APP_KEY_ADD BLE_MESH_MODEL_OP_1(0x00) +#define OP_APP_KEY_UPDATE BLE_MESH_MODEL_OP_1(0x01) +#define OP_DEV_COMP_DATA_STATUS BLE_MESH_MODEL_OP_1(0x02) +#define OP_MOD_PUB_SET BLE_MESH_MODEL_OP_1(0x03) +#define OP_HEALTH_CURRENT_STATUS BLE_MESH_MODEL_OP_1(0x04) +#define OP_HEALTH_FAULT_STATUS BLE_MESH_MODEL_OP_1(0x05) +#define OP_HEARTBEAT_PUB_STATUS BLE_MESH_MODEL_OP_1(0x06) +#define OP_APP_KEY_DEL BLE_MESH_MODEL_OP_2(0x80, 0x00) +#define OP_APP_KEY_GET BLE_MESH_MODEL_OP_2(0x80, 0x01) +#define OP_APP_KEY_LIST BLE_MESH_MODEL_OP_2(0x80, 0x02) +#define OP_APP_KEY_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x03) +#define OP_ATTENTION_GET BLE_MESH_MODEL_OP_2(0x80, 0x04) +#define OP_ATTENTION_SET BLE_MESH_MODEL_OP_2(0x80, 0x05) +#define OP_ATTENTION_SET_UNREL BLE_MESH_MODEL_OP_2(0x80, 0x06) +#define OP_ATTENTION_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x07) +#define OP_DEV_COMP_DATA_GET BLE_MESH_MODEL_OP_2(0x80, 0x08) +#define OP_BEACON_GET BLE_MESH_MODEL_OP_2(0x80, 0x09) +#define OP_BEACON_SET BLE_MESH_MODEL_OP_2(0x80, 0x0a) +#define OP_BEACON_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x0b) +#define OP_DEFAULT_TTL_GET BLE_MESH_MODEL_OP_2(0x80, 0x0c) +#define OP_DEFAULT_TTL_SET BLE_MESH_MODEL_OP_2(0x80, 0x0d) +#define OP_DEFAULT_TTL_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x0e) +#define OP_FRIEND_GET BLE_MESH_MODEL_OP_2(0x80, 0x0f) +#define OP_FRIEND_SET BLE_MESH_MODEL_OP_2(0x80, 0x10) +#define OP_FRIEND_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x11) +#define OP_GATT_PROXY_GET BLE_MESH_MODEL_OP_2(0x80, 0x12) +#define OP_GATT_PROXY_SET BLE_MESH_MODEL_OP_2(0x80, 0x13) +#define OP_GATT_PROXY_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x14) +#define OP_KRP_GET BLE_MESH_MODEL_OP_2(0x80, 0x15) +#define OP_KRP_SET BLE_MESH_MODEL_OP_2(0x80, 0x16) +#define OP_KRP_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x17) +#define OP_MOD_PUB_GET BLE_MESH_MODEL_OP_2(0x80, 0x18) +#define OP_MOD_PUB_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x19) +#define OP_MOD_PUB_VA_SET BLE_MESH_MODEL_OP_2(0x80, 0x1a) +#define OP_MOD_SUB_ADD BLE_MESH_MODEL_OP_2(0x80, 0x1b) +#define OP_MOD_SUB_DEL BLE_MESH_MODEL_OP_2(0x80, 0x1c) +#define OP_MOD_SUB_DEL_ALL BLE_MESH_MODEL_OP_2(0x80, 0x1d) +#define OP_MOD_SUB_OVERWRITE BLE_MESH_MODEL_OP_2(0x80, 0x1e) +#define OP_MOD_SUB_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x1f) +#define OP_MOD_SUB_VA_ADD BLE_MESH_MODEL_OP_2(0x80, 0x20) +#define OP_MOD_SUB_VA_DEL BLE_MESH_MODEL_OP_2(0x80, 0x21) +#define OP_MOD_SUB_VA_OVERWRITE BLE_MESH_MODEL_OP_2(0x80, 0x22) +#define OP_NET_TRANSMIT_GET BLE_MESH_MODEL_OP_2(0x80, 0x23) +#define OP_NET_TRANSMIT_SET BLE_MESH_MODEL_OP_2(0x80, 0x24) +#define OP_NET_TRANSMIT_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x25) +#define OP_RELAY_GET BLE_MESH_MODEL_OP_2(0x80, 0x26) +#define OP_RELAY_SET BLE_MESH_MODEL_OP_2(0x80, 0x27) +#define OP_RELAY_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x28) +#define OP_MOD_SUB_GET BLE_MESH_MODEL_OP_2(0x80, 0x29) +#define OP_MOD_SUB_LIST BLE_MESH_MODEL_OP_2(0x80, 0x2a) +#define OP_MOD_SUB_GET_VND BLE_MESH_MODEL_OP_2(0x80, 0x2b) +#define OP_MOD_SUB_LIST_VND BLE_MESH_MODEL_OP_2(0x80, 0x2c) +#define OP_LPN_TIMEOUT_GET BLE_MESH_MODEL_OP_2(0x80, 0x2d) +#define OP_LPN_TIMEOUT_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x2e) +#define OP_HEALTH_FAULT_CLEAR BLE_MESH_MODEL_OP_2(0x80, 0x2f) +#define OP_HEALTH_FAULT_CLEAR_UNREL BLE_MESH_MODEL_OP_2(0x80, 0x30) +#define OP_HEALTH_FAULT_GET BLE_MESH_MODEL_OP_2(0x80, 0x31) +#define OP_HEALTH_FAULT_TEST BLE_MESH_MODEL_OP_2(0x80, 0x32) +#define OP_HEALTH_FAULT_TEST_UNREL BLE_MESH_MODEL_OP_2(0x80, 0x33) +#define OP_HEALTH_PERIOD_GET BLE_MESH_MODEL_OP_2(0x80, 0x34) +#define OP_HEALTH_PERIOD_SET BLE_MESH_MODEL_OP_2(0x80, 0x35) +#define OP_HEALTH_PERIOD_SET_UNREL BLE_MESH_MODEL_OP_2(0x80, 0x36) +#define OP_HEALTH_PERIOD_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x37) +#define OP_HEARTBEAT_PUB_GET BLE_MESH_MODEL_OP_2(0x80, 0x38) +#define OP_HEARTBEAT_PUB_SET BLE_MESH_MODEL_OP_2(0x80, 0x39) +#define OP_HEARTBEAT_SUB_GET BLE_MESH_MODEL_OP_2(0x80, 0x3a) +#define OP_HEARTBEAT_SUB_SET BLE_MESH_MODEL_OP_2(0x80, 0x3b) +#define OP_HEARTBEAT_SUB_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x3c) +#define OP_MOD_APP_BIND BLE_MESH_MODEL_OP_2(0x80, 0x3d) +#define OP_MOD_APP_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x3e) +#define OP_MOD_APP_UNBIND BLE_MESH_MODEL_OP_2(0x80, 0x3f) +#define OP_NET_KEY_ADD BLE_MESH_MODEL_OP_2(0x80, 0x40) +#define OP_NET_KEY_DEL BLE_MESH_MODEL_OP_2(0x80, 0x41) +#define OP_NET_KEY_GET BLE_MESH_MODEL_OP_2(0x80, 0x42) +#define OP_NET_KEY_LIST BLE_MESH_MODEL_OP_2(0x80, 0x43) +#define OP_NET_KEY_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x44) +#define OP_NET_KEY_UPDATE BLE_MESH_MODEL_OP_2(0x80, 0x45) +#define OP_NODE_IDENTITY_GET BLE_MESH_MODEL_OP_2(0x80, 0x46) +#define OP_NODE_IDENTITY_SET BLE_MESH_MODEL_OP_2(0x80, 0x47) +#define OP_NODE_IDENTITY_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x48) +#define OP_NODE_RESET BLE_MESH_MODEL_OP_2(0x80, 0x49) +#define OP_NODE_RESET_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x4a) +#define OP_SIG_MOD_APP_GET BLE_MESH_MODEL_OP_2(0x80, 0x4b) +#define OP_SIG_MOD_APP_LIST BLE_MESH_MODEL_OP_2(0x80, 0x4c) +#define OP_VND_MOD_APP_GET BLE_MESH_MODEL_OP_2(0x80, 0x4d) +#define OP_VND_MOD_APP_LIST BLE_MESH_MODEL_OP_2(0x80, 0x4e) + +#define STATUS_SUCCESS 0x00 +#define STATUS_INVALID_ADDRESS 0x01 +#define STATUS_INVALID_MODEL 0x02 +#define STATUS_INVALID_APPKEY 0x03 +#define STATUS_INVALID_NETKEY 0x04 +#define STATUS_INSUFF_RESOURCES 0x05 +#define STATUS_IDX_ALREADY_STORED 0x06 +#define STATUS_NVAL_PUB_PARAM 0x07 +#define STATUS_NOT_SUB_MOD 0x08 +#define STATUS_STORAGE_FAIL 0x09 +#define STATUS_FEAT_NOT_SUPP 0x0a +#define STATUS_CANNOT_UPDATE 0x0b +#define STATUS_CANNOT_REMOVE 0x0c +#define STATUS_CANNOT_BIND 0x0d +#define STATUS_TEMP_STATE_CHG_FAIL 0x0e +#define STATUS_CANNOT_SET 0x0f +#define STATUS_UNSPECIFIED 0x10 +#define STATUS_INVALID_BINDING 0x11 + +enum { + BLE_MESH_VA_CHANGED, /* Label information changed */ +}; + +struct label { + uint16_t ref; + uint16_t addr; + uint8_t uuid[16]; + bt_mesh_atomic_t flags[1]; +}; + +void bt_mesh_mod_sub_reset(bool store); + +void bt_mesh_cfg_reset(bool store); + +void bt_mesh_heartbeat(uint16_t src, uint16_t dst, uint8_t hops, uint16_t feat); + +void bt_mesh_attention(struct bt_mesh_model *model, uint8_t time); + +struct label *get_label(uint16_t index); + +uint8_t *bt_mesh_label_uuid_get(uint16_t addr); + +struct bt_mesh_hb_pub *bt_mesh_hb_pub_get(void); +void bt_mesh_hb_pub_disable(void); +struct bt_mesh_cfg_srv *bt_mesh_cfg_get(void); + +uint8_t bt_mesh_net_transmit_get(void); +uint8_t bt_mesh_relay_get(void); +uint8_t bt_mesh_friend_get(void); +uint8_t bt_mesh_relay_retransmit_get(void); +uint8_t bt_mesh_beacon_get(void); +uint8_t bt_mesh_gatt_proxy_get(void); +uint8_t bt_mesh_default_ttl_get(void); + +void bt_mesh_subnet_del(struct bt_mesh_subnet *sub, bool store); + +struct bt_mesh_app_key *bt_mesh_app_key_alloc(uint16_t app_idx); +void bt_mesh_app_key_del(struct bt_mesh_app_key *key, bool store); + +static inline void key_idx_pack(struct net_buf_simple *buf, + uint16_t idx1, uint16_t idx2) +{ + net_buf_simple_add_le16(buf, idx1 | ((idx2 & 0x00f) << 12)); + net_buf_simple_add_u8(buf, idx2 >> 4); +} + +static inline void key_idx_unpack(struct net_buf_simple *buf, + uint16_t *idx1, uint16_t *idx2) +{ + *idx1 = sys_get_le16(&buf->data[0]) & 0xfff; + *idx2 = sys_get_le16(&buf->data[1]) >> 4; + net_buf_simple_pull(buf, 3); +} + +#ifdef __cplusplus +} +#endif + +#endif /* _FOUNDATION_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/friend.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/friend.h new file mode 100644 index 00000000000..2855081bf57 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/friend.h @@ -0,0 +1,67 @@ +/* Bluetooth Mesh */ + +/* + * SPDX-FileCopyrightText: 2017 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _FRIEND_H_ +#define _FRIEND_H_ + +#include "net.h" + +#ifdef __cplusplus +extern "C" { +#endif + +enum bt_mesh_friend_pdu_type { + BLE_MESH_FRIEND_PDU_SINGLE, + BLE_MESH_FRIEND_PDU_PARTIAL, + BLE_MESH_FRIEND_PDU_COMPLETE, +}; + +bool bt_mesh_friend_match(uint16_t net_idx, uint16_t addr); + +struct bt_mesh_friend *bt_mesh_friend_find(uint16_t net_idx, uint16_t lpn_addr, + bool valid, bool established); + +bool bt_mesh_friend_queue_has_space(uint16_t net_idx, uint16_t src, uint16_t dst, + const uint64_t *seq_auth, uint8_t seg_count); + +void bt_mesh_friend_enqueue_rx(struct bt_mesh_net_rx *rx, + enum bt_mesh_friend_pdu_type type, + const uint64_t *seq_auth, uint8_t seg_count, + struct net_buf_simple *sbuf); +bool bt_mesh_friend_enqueue_tx(struct bt_mesh_net_tx *tx, + enum bt_mesh_friend_pdu_type type, + const uint64_t *seq_auth, uint8_t seg_count, + struct net_buf_simple *sbuf); + +void bt_mesh_friend_clear_incomplete(struct bt_mesh_subnet *sub, uint16_t src, + uint16_t dst, const uint64_t *seq_auth); + +void bt_mesh_friend_sec_update(uint16_t net_idx); + +void bt_mesh_friend_clear_net_idx(uint16_t net_idx); + +int bt_mesh_friend_poll(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf); +int bt_mesh_friend_req(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf); +int bt_mesh_friend_clear(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf); +int bt_mesh_friend_clear_cfm(struct bt_mesh_net_rx *rx, + struct net_buf_simple *buf); +int bt_mesh_friend_sub_add(struct bt_mesh_net_rx *rx, + struct net_buf_simple *buf); +int bt_mesh_friend_sub_rem(struct bt_mesh_net_rx *rx, + struct net_buf_simple *buf); + +int bt_mesh_friend_init(void); +int bt_mesh_friend_deinit(void); + +void bt_mesh_friend_remove_lpn(uint16_t lpn_addr); + +#ifdef __cplusplus +} +#endif + +#endif /* _FRIEND_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/include/cfg_cli.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/include/cfg_cli.h new file mode 100644 index 00000000000..02ff566dd92 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/include/cfg_cli.h @@ -0,0 +1,318 @@ +/** @file + * @brief Bluetooth Mesh Configuration Client Model APIs. + */ + +/* + * SPDX-FileCopyrightText: 2017 Intel Corporation + * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#ifndef _BLE_MESH_CFG_CLI_H_ +#define _BLE_MESH_CFG_CLI_H_ + +#include "client_common.h" + +/** + * @brief Bluetooth Mesh + * @defgroup bt_mesh_cfg_cli Bluetooth Mesh Configuration Client Model + * @ingroup bt_mesh + * @{ + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Config client model common structure */ +typedef bt_mesh_client_user_data_t bt_mesh_config_client_t; +typedef bt_mesh_client_internal_data_t config_internal_data_t; + +extern const struct bt_mesh_model_op bt_mesh_cfg_cli_op[]; +extern const struct bt_mesh_model_cb bt_mesh_cfg_cli_cb; + +#define BLE_MESH_MODEL_CFG_CLI(cli_data) \ + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_CFG_CLI, \ + bt_mesh_cfg_cli_op, NULL, cli_data, &bt_mesh_cfg_cli_cb) + +int bt_mesh_cfg_comp_data_get(bt_mesh_client_common_param_t *param, uint8_t page); + +int bt_mesh_cfg_beacon_get(bt_mesh_client_common_param_t *param); + +int bt_mesh_cfg_beacon_set(bt_mesh_client_common_param_t *param, uint8_t val); + +int bt_mesh_cfg_ttl_get(bt_mesh_client_common_param_t *param); + +int bt_mesh_cfg_ttl_set(bt_mesh_client_common_param_t *param, uint8_t val); + +int bt_mesh_cfg_friend_get(bt_mesh_client_common_param_t *param); + +int bt_mesh_cfg_friend_set(bt_mesh_client_common_param_t *param, uint8_t val); + +int bt_mesh_cfg_gatt_proxy_get(bt_mesh_client_common_param_t *param); + +int bt_mesh_cfg_gatt_proxy_set(bt_mesh_client_common_param_t *param, uint8_t val); + +int bt_mesh_cfg_relay_get(bt_mesh_client_common_param_t *param); + +int bt_mesh_cfg_relay_set(bt_mesh_client_common_param_t *param, + uint8_t relay, uint8_t retransmit); + +int bt_mesh_cfg_net_key_add(bt_mesh_client_common_param_t *param, + uint16_t net_idx, const uint8_t net_key[16]); + +int bt_mesh_cfg_app_key_add(bt_mesh_client_common_param_t *param, + uint16_t net_idx, uint16_t app_idx, + const uint8_t app_key[16]); + +int bt_mesh_cfg_mod_app_bind(bt_mesh_client_common_param_t *param, + uint16_t elem_addr, uint16_t app_idx, + uint16_t mod_id, uint16_t cid); + +struct bt_mesh_cfg_mod_pub { + uint16_t addr; + uint16_t app_idx; + bool cred_flag; + uint8_t ttl; + uint8_t period; + uint8_t transmit; +}; + +int bt_mesh_cfg_mod_pub_get(bt_mesh_client_common_param_t *param, + uint16_t elem_addr, uint16_t mod_id, uint16_t cid); + +int bt_mesh_cfg_mod_pub_set(bt_mesh_client_common_param_t *param, + uint16_t elem_addr, uint16_t mod_id, uint16_t cid, + struct bt_mesh_cfg_mod_pub *pub); + +int bt_mesh_cfg_mod_sub_add(bt_mesh_client_common_param_t *param, + uint16_t elem_addr, uint16_t sub_addr, + uint16_t mod_id, uint16_t cid); + +int bt_mesh_cfg_mod_sub_del(bt_mesh_client_common_param_t *param, + uint16_t elem_addr, uint16_t sub_addr, + uint16_t mod_id, uint16_t cid); + +int bt_mesh_cfg_mod_sub_overwrite(bt_mesh_client_common_param_t *param, + uint16_t elem_addr, uint16_t sub_addr, + uint16_t mod_id, uint16_t cid); + +int bt_mesh_cfg_mod_sub_va_add(bt_mesh_client_common_param_t *param, + uint16_t elem_addr, const uint8_t label[16], + uint16_t mod_id, uint16_t cid); + +int bt_mesh_cfg_mod_sub_va_del(bt_mesh_client_common_param_t *param, + uint16_t elem_addr, const uint8_t label[16], + uint16_t mod_id, uint16_t cid); + +int bt_mesh_cfg_mod_sub_va_overwrite(bt_mesh_client_common_param_t *param, + uint16_t elem_addr, const uint8_t label[16], + uint16_t mod_id, uint16_t cid); + +struct bt_mesh_cfg_hb_sub { + uint16_t src; + uint16_t dst; + uint8_t period; +}; + +int bt_mesh_cfg_hb_sub_set(bt_mesh_client_common_param_t *param, + struct bt_mesh_cfg_hb_sub *sub); + +int bt_mesh_cfg_hb_sub_get(bt_mesh_client_common_param_t *param); + +struct bt_mesh_cfg_hb_pub { + uint16_t dst; + uint8_t count; + uint8_t period; + uint8_t ttl; + uint16_t feat; + uint16_t net_idx; +}; + +int bt_mesh_cfg_hb_pub_set(bt_mesh_client_common_param_t *param, + struct bt_mesh_cfg_hb_pub *pub); + +int bt_mesh_cfg_hb_pub_get(bt_mesh_client_common_param_t *param); + +int bt_mesh_cfg_node_reset(bt_mesh_client_common_param_t *param); + +/* Configuration Client Status Message Context */ + +struct bt_mesh_cfg_comp_data_status { + uint8_t page; + struct net_buf_simple *comp_data; +}; + +struct bt_mesh_cfg_relay_status { + uint8_t relay; + uint8_t retransmit; +}; + +struct bt_mesh_cfg_netkey_status { + uint8_t status; + uint16_t net_idx; +}; + +struct bt_mesh_cfg_appkey_status { + uint8_t status; + uint16_t net_idx; + uint16_t app_idx; +}; + +struct bt_mesh_cfg_mod_app_status { + uint8_t status; + uint16_t elem_addr; + uint16_t app_idx; + uint16_t cid; + uint16_t mod_id; +}; + +struct bt_mesh_cfg_mod_pub_status { + uint8_t status; + uint16_t elem_addr; + uint16_t addr; + uint16_t app_idx; + bool cred_flag; + uint8_t ttl; + uint8_t period; + uint8_t transmit; + uint16_t cid; + uint16_t mod_id; +}; + +struct bt_mesh_cfg_mod_sub_status { + uint8_t status; + uint16_t elem_addr; + uint16_t sub_addr; + uint16_t cid; + uint16_t mod_id; +}; + +struct bt_mesh_cfg_hb_sub_status { + uint8_t status; + uint16_t src; + uint16_t dst; + uint8_t period; + uint8_t count; + uint8_t min; + uint8_t max; +}; + +struct bt_mesh_cfg_hb_pub_status { + uint8_t status; + uint16_t dst; + uint8_t count; + uint8_t period; + uint8_t ttl; + uint16_t feat; + uint16_t net_idx; +}; + +struct bt_mesh_cfg_mod_sub_list { + uint8_t status; + uint16_t elem_addr; + uint16_t cid; + uint16_t mod_id; + struct net_buf_simple *addr; +}; + +struct bt_mesh_cfg_net_key_list { + struct net_buf_simple *net_idx; +}; + +struct bt_mesh_cfg_app_key_list { + uint8_t status; + uint16_t net_idx; + struct net_buf_simple *app_idx; +}; + +struct bt_mesh_cfg_node_id_status { + uint8_t status; + uint16_t net_idx; + uint8_t identity; +}; + +struct bt_mesh_cfg_mod_app_list { + uint8_t status; + uint16_t elem_addr; + uint16_t cid; + uint16_t mod_id; + struct net_buf_simple *app_idx; +}; + +struct bt_mesh_cfg_key_refresh_status { + uint8_t status; + uint16_t net_idx; + uint8_t phase; +}; + +struct bt_mesh_cfg_lpn_pollto_status { + uint16_t lpn_addr; + int32_t timeout; +}; + +int bt_mesh_cfg_mod_pub_va_set(bt_mesh_client_common_param_t *param, + uint16_t elem_addr, uint16_t mod_id, + uint16_t cid, const uint8_t label[16], + struct bt_mesh_cfg_mod_pub *pub); + +int bt_mesh_cfg_mod_sub_del_all(bt_mesh_client_common_param_t *param, + uint16_t elem_addr, uint16_t mod_id, uint16_t cid); + +int bt_mesh_cfg_mod_sub_get(bt_mesh_client_common_param_t *param, + uint16_t elem_addr, uint16_t mod_id); + +int bt_mesh_cfg_mod_sub_get_vnd(bt_mesh_client_common_param_t *param, + uint16_t elem_addr, uint16_t mod_id, uint16_t cid); + +int bt_mesh_cfg_net_key_update(bt_mesh_client_common_param_t *param, + uint16_t net_idx, const uint8_t net_key[16]); + +int bt_mesh_cfg_net_key_delete(bt_mesh_client_common_param_t *param, uint16_t net_idx); + +int bt_mesh_cfg_net_key_get(bt_mesh_client_common_param_t *param); + +int bt_mesh_cfg_app_key_update(bt_mesh_client_common_param_t *param, + uint16_t net_idx, uint16_t app_idx, + const uint8_t app_key[16]); + +int bt_mesh_cfg_app_key_delete(bt_mesh_client_common_param_t *param, + uint16_t net_idx, uint16_t app_idx); + +int bt_mesh_cfg_app_key_get(bt_mesh_client_common_param_t *param, uint16_t net_idx); + +int bt_mesh_cfg_node_identity_get(bt_mesh_client_common_param_t *param, uint16_t net_idx); + +int bt_mesh_cfg_node_identity_set(bt_mesh_client_common_param_t *param, + uint16_t net_idx, uint8_t identity); + +int bt_mesh_cfg_mod_app_unbind(bt_mesh_client_common_param_t *param, + uint16_t elem_addr, uint16_t app_idx, + uint16_t mod_id, uint16_t cid); + +int bt_mesh_cfg_mod_app_get(bt_mesh_client_common_param_t *param, + uint16_t elem_addr, uint16_t mod_id); + +int bt_mesh_cfg_mod_app_get_vnd(bt_mesh_client_common_param_t *param, + uint16_t elem_addr, uint16_t mod_id, uint16_t cid); + +int bt_mesh_cfg_kr_phase_get(bt_mesh_client_common_param_t *param, uint16_t net_idx); + +int bt_mesh_cfg_kr_phase_set(bt_mesh_client_common_param_t *param, + uint16_t net_idx, uint8_t transition); + +int bt_mesh_cfg_lpn_timeout_get(bt_mesh_client_common_param_t *param, uint16_t lpn_addr); + +int bt_mesh_cfg_net_transmit_get(bt_mesh_client_common_param_t *param); + +int bt_mesh_cfg_net_transmit_set(bt_mesh_client_common_param_t *param, uint8_t transmit); + +#ifdef __cplusplus +} +#endif + +/** + * @} + */ + +#endif /* __BLE_MESH_CFG_CLI_H */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/include/cfg_srv.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/include/cfg_srv.h new file mode 100644 index 00000000000..41b9a6236f5 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/include/cfg_srv.h @@ -0,0 +1,223 @@ +/** @file + * @brief Bluetooth Mesh Configuration Server Model APIs. + */ + +/* + * SPDX-FileCopyrightText: 2017 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ +#ifndef _BLE_MESH_CFG_SRV_H_ +#define _BLE_MESH_CFG_SRV_H_ + +#include "mesh_access.h" + +/** + * @brief Bluetooth Mesh + * @defgroup bt_mesh_cfg_srv Bluetooth Mesh Configuration Server Model + * @ingroup bt_mesh + * @{ + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** Mesh Configuration Server Model Context */ +struct bt_mesh_cfg_srv { + struct bt_mesh_model *model; + + uint8_t net_transmit; /* Network Transmit state */ + uint8_t relay; /* Relay Mode state */ + uint8_t relay_retransmit; /* Relay Retransmit state */ + uint8_t beacon; /* Secure Network Beacon state */ + uint8_t gatt_proxy; /* GATT Proxy state */ + uint8_t frnd; /* Friend state */ + uint8_t default_ttl; /* Default TTL */ + + /* Heartbeat Publication */ + struct bt_mesh_hb_pub { + struct k_delayed_work timer; + + uint16_t dst; + uint16_t count; + uint8_t period; + uint8_t ttl; + uint16_t feat; + uint16_t net_idx; + } hb_pub; + + /* Heartbeat Subscription */ + struct bt_mesh_hb_sub { + int64_t expiry; + + uint16_t src; + uint16_t dst; + uint16_t count; + uint8_t min_hops; + uint8_t max_hops; + + /* Optional subscription tracking function */ + void (*func)(uint8_t hops, uint16_t feat); + } hb_sub; +}; + +extern const struct bt_mesh_model_op bt_mesh_cfg_srv_op[]; +extern const struct bt_mesh_model_cb bt_mesh_cfg_srv_cb; + +#define BLE_MESH_MODEL_CFG_SRV(srv_data) \ + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_CFG_SRV, \ + bt_mesh_cfg_srv_op, NULL, srv_data, &bt_mesh_cfg_srv_cb) + +typedef union { + struct { + uint8_t beacon; + } cfg_beacon_set; + struct { + uint8_t ttl; + } cfg_default_ttl_set; + struct { + uint8_t gatt_proxy; + } cfg_gatt_proxy_set; + struct { + uint8_t relay; + uint8_t retransmit; + } cfg_relay_set; + struct { + uint16_t elem_addr; + uint16_t pub_addr; + uint16_t app_idx; + bool cred_flag; + uint8_t ttl; + uint8_t period; + uint8_t transmit; + uint16_t cid; + uint16_t mod_id; + } cfg_mod_pub_set; + struct { + uint16_t elem_addr; + uint8_t pub_addr[16]; + uint16_t app_idx; + bool cred_flag; + uint8_t ttl; + uint8_t period; + uint8_t transmit; + uint16_t cid; + uint16_t mod_id; + } cfg_mod_pub_va_set; + struct { + uint16_t elem_addr; + uint16_t sub_addr; + uint16_t cid; + uint16_t mod_id; + } cfg_mod_sub_add; + struct { + uint16_t elem_addr; + uint8_t sub_addr[16]; + uint16_t cid; + uint16_t mod_id; + } cfg_mod_sub_va_add; + struct { + uint16_t elem_addr; + uint16_t sub_addr; + uint16_t cid; + uint16_t mod_id; + } cfg_mod_sub_delete; + struct { + uint16_t elem_addr; + uint8_t sub_addr[16]; + uint16_t cid; + uint16_t mod_id; + } cfg_mod_sub_va_delete; + struct { + uint16_t elem_addr; + uint16_t sub_addr; + uint16_t cid; + uint16_t mod_id; + } cfg_mod_sub_overwrite; + struct { + uint16_t elem_addr; + uint8_t sub_addr[16]; + uint16_t cid; + uint16_t mod_id; + } cfg_mod_sub_va_overwrite; + struct { + uint16_t elem_addr; + uint16_t cid; + uint16_t mod_id; + } cfg_mod_sub_delete_all; + struct { + uint16_t net_idx; + uint8_t net_key[16]; + } cfg_netkey_add; + struct { + uint16_t net_idx; + uint8_t net_key[16]; + } cfg_netkey_update; + struct { + uint16_t net_idx; + } cfg_netkey_delete; + struct { + uint16_t net_idx; + uint16_t app_idx; + uint8_t app_key[16]; + } cfg_appkey_add; + struct { + uint16_t net_idx; + uint16_t app_idx; + uint8_t app_key[16]; + } cfg_appkey_update; + struct { + uint16_t net_idx; + uint16_t app_idx; + } cfg_appkey_delete; + struct { + uint16_t net_idx; + uint8_t identity; + } cfg_node_identity_set; + struct { + uint16_t elem_addr; + uint16_t app_idx; + uint16_t cid; + uint16_t mod_id; + } cfg_mod_app_bind; + struct { + uint16_t elem_addr; + uint16_t app_idx; + uint16_t cid; + uint16_t mod_id; + } cfg_mod_app_unbind; + struct { + uint8_t frnd; + } cfg_friend_set; + struct { + uint16_t net_idx; + uint8_t kr_phase; + } cfg_kr_phase_set; + struct { + uint16_t dst; + uint8_t count; + uint8_t period; + uint8_t ttl; + uint16_t feat; + uint16_t net_idx; + } cfg_hb_pub_set; + struct { + uint16_t src; + uint16_t dst; + uint8_t period; + } cfg_hb_sub_set; + struct { + uint8_t transmit; + } cfg_net_transmit_set; +} bt_mesh_cfg_server_state_change_t; + +#ifdef __cplusplus +} +#endif + +/** + * @} + */ + +#endif /* __BLE_MESH_CFG_SRV_H */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/include/health_cli.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/include/health_cli.h new file mode 100644 index 00000000000..239e14cbede --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/include/health_cli.h @@ -0,0 +1,78 @@ +/** @file + * @brief Bluetooth Mesh Health Client Model APIs. + */ + +/* + * SPDX-FileCopyrightText: 2017 Intel Corporation + * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#ifndef _BLE_MESH_HEALTH_CLI_H_ +#define _BLE_MESH_HEALTH_CLI_H_ + +#include "client_common.h" + +/** + * @brief Bluetooth Mesh + * @defgroup bt_mesh_health_cli Bluetooth Mesh Health Client Model + * @ingroup bt_mesh + * @{ + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Health client model common structure */ +typedef bt_mesh_client_user_data_t bt_mesh_health_client_t; +typedef bt_mesh_client_internal_data_t health_internal_data_t; + +extern const struct bt_mesh_model_op bt_mesh_health_cli_op[]; +extern const struct bt_mesh_model_cb bt_mesh_health_cli_cb; + +#define BLE_MESH_MODEL_HEALTH_CLI(cli_data) \ + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_HEALTH_CLI, \ + bt_mesh_health_cli_op, NULL, cli_data, &bt_mesh_health_cli_cb) + +int bt_mesh_health_fault_get(bt_mesh_client_common_param_t *param, uint16_t cid); + +int bt_mesh_health_fault_clear(bt_mesh_client_common_param_t *param, + uint16_t cid, bool need_ack); + +int bt_mesh_health_fault_test(bt_mesh_client_common_param_t *param, + uint16_t cid, uint8_t test_id, bool need_ack); + +int bt_mesh_health_period_get(bt_mesh_client_common_param_t *param); + +int bt_mesh_health_period_set(bt_mesh_client_common_param_t *param, + uint8_t divisor, bool need_ack); + +int bt_mesh_health_attention_get(bt_mesh_client_common_param_t *param); + +int bt_mesh_health_attention_set(bt_mesh_client_common_param_t *param, + uint8_t attention, bool need_ack); + +/* Health Client Status Message Context */ + +struct bt_mesh_health_current_status { + uint8_t test_id; + uint16_t cid; + struct net_buf_simple *fault_array; +}; + +struct bt_mesh_health_fault_status { + uint8_t test_id; + uint16_t cid; + struct net_buf_simple *fault_array; +}; + +#ifdef __cplusplus +} +#endif + +/** + * @} + */ + +#endif /* __BLE_MESH_HEALTH_CLI_H */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/include/health_srv.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/include/health_srv.h new file mode 100644 index 00000000000..35a61b8258f --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/include/health_srv.h @@ -0,0 +1,106 @@ +/** @file + * @brief Bluetooth Mesh Health Server Model APIs. + */ + +/* + * SPDX-FileCopyrightText: 2017 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ +#ifndef _BLE_MESH_HEALTH_SRV_H_ +#define _BLE_MESH_HEALTH_SRV_H_ + +#include "mesh_access.h" + +/** + * @brief Bluetooth Mesh Health Server Model + * @defgroup bt_mesh_health_srv Bluetooth Mesh Health Server Model + * @ingroup bt_mesh + * @{ + */ + +#ifdef __cplusplus +extern "C" { +#endif + +struct bt_mesh_health_srv_cb { + /* Clear registered faults */ + void (*fault_clear)(struct bt_mesh_model *model, uint16_t company_id); + + /* Run a specific test */ + void (*fault_test)(struct bt_mesh_model *model, uint8_t test_id, + uint16_t company_id); + + /* Attention on */ + void (*attn_on)(struct bt_mesh_model *model, uint8_t time); + + /* Attention off */ + void (*attn_off)(struct bt_mesh_model *model); +}; + +/** @def BLE_MESH_HEALTH_PUB_DEFINE + * + * A helper to define a health publication context + * + * @param _name Name given to the publication context variable. + * @param _max_faults Maximum number of faults the element can have. + */ +#define BLE_MESH_HEALTH_PUB_DEFINE(_name, _max_faults) \ + BLE_MESH_MODEL_PUB_DEFINE(_name, NULL, (1 + 3 + (_max_faults))) + +struct bt_mesh_health_test { + 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; /* Most currently performed test id */ + uint8_t curr_faults[32]; /* Array of current faults */ + uint8_t reg_faults[32]; /* Array of registered faults */ +} __attribute__((packed)); + +/** Mesh Health Server Model Context */ +struct bt_mesh_health_srv { + struct bt_mesh_model *model; + + /* Optional callback struct */ + struct bt_mesh_health_srv_cb cb; + + /* Attention Timer state */ + struct k_delayed_work attn_timer; + + /* Attention Timer start flag */ + bool attn_timer_start; + + /* Health Server fault test */ + struct bt_mesh_health_test test; +}; + +extern const struct bt_mesh_model_op bt_mesh_health_srv_op[]; +extern const struct bt_mesh_model_cb bt_mesh_health_srv_cb; + +/** @def BLE_MESH_MODEL_HEALTH_SRV + * + * Define a new health server model. Note that this API needs to be + * repeated for each element which the application wants to have a + * health server model on. Each instance also needs a unique + * bt_mesh_health_srv and bt_mesh_model_pub context. + * + * @param srv Pointer to a unique struct bt_mesh_health_srv. + * @param pub Pointer to a unique struct bt_mesh_model_pub. + * + * @return New mesh model instance. + */ +#define BLE_MESH_MODEL_HEALTH_SRV(srv, pub) \ + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_HEALTH_SRV, \ + bt_mesh_health_srv_op, pub, srv, &bt_mesh_health_srv_cb) + +int bt_mesh_fault_update(struct bt_mesh_elem *elem); + +#ifdef __cplusplus +} +#endif + +/** + * @} + */ + +#endif /* __BLE_MESH_HEALTH_SRV_H */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/include/mesh_access.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/include/mesh_access.h new file mode 100644 index 00000000000..66fbb7e43fb --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/include/mesh_access.h @@ -0,0 +1,601 @@ +/** @file + * @brief Bluetooth Mesh Access Layer APIs. + */ + +/* + * SPDX-FileCopyrightText: 2017 Intel Corporation + * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#ifndef _BLE_MESH_ACCESS_H_ +#define _BLE_MESH_ACCESS_H_ + +#include "mesh_config.h" +#include "mesh_buf.h" +#include "mesh_timer.h" + +/** + * @brief Bluetooth Mesh Access Layer + * @defgroup bt_mesh_access Bluetooth Mesh Access Layer + * @ingroup bt_mesh + * @{ + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#define BLE_MESH_CID_NVAL 0xFFFF + +#define BLE_MESH_ADDR_UNASSIGNED 0x0000 +#define BLE_MESH_ADDR_ALL_NODES 0xffff +#define BLE_MESH_ADDR_PROXIES 0xfffc +#define BLE_MESH_ADDR_FRIENDS 0xfffd +#define BLE_MESH_ADDR_RELAYS 0xfffe + +#define BLE_MESH_KEY_UNUSED 0xffff +#define BLE_MESH_KEY_DEV 0xfffe + +/** Helper to define a mesh element within an array. + * + * In case the element has no SIG or Vendor models the helper + * macro BLE_MESH_MODEL_NONE can be given instead. + * + * @param _loc Location Descriptor. + * @param _mods Array of models. + * @param _vnd_mods Array of vendor models. + */ +#define BLE_MESH_ELEM(_loc, _mods, _vnd_mods) \ +{ \ + .loc = (_loc), \ + .model_count = ARRAY_SIZE(_mods), \ + .models = (_mods), \ + .vnd_model_count = ARRAY_SIZE(_vnd_mods), \ + .vnd_models = (_vnd_mods), \ +} + +/** Abstraction that describes a Mesh Element */ +struct bt_mesh_elem { + /* Unicast Address. Set at runtime during provisioning. */ + uint16_t addr; + + /* Location Descriptor (GATT Bluetooth Namespace Descriptors) */ + const uint16_t loc; + + const uint8_t model_count; + const uint8_t vnd_model_count; + + struct bt_mesh_model *const models; + struct bt_mesh_model *const vnd_models; +}; + +/* Foundation Models */ +#define BLE_MESH_MODEL_ID_CFG_SRV 0x0000 +#define BLE_MESH_MODEL_ID_CFG_CLI 0x0001 +#define BLE_MESH_MODEL_ID_HEALTH_SRV 0x0002 +#define BLE_MESH_MODEL_ID_HEALTH_CLI 0x0003 + +/* Models from the Mesh Model Specification */ +#define BLE_MESH_MODEL_ID_GEN_ONOFF_SRV 0x1000 +#define BLE_MESH_MODEL_ID_GEN_ONOFF_CLI 0x1001 +#define BLE_MESH_MODEL_ID_GEN_LEVEL_SRV 0x1002 +#define BLE_MESH_MODEL_ID_GEN_LEVEL_CLI 0x1003 +#define BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_SRV 0x1004 +#define BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_CLI 0x1005 +#define BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SRV 0x1006 +#define BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SETUP_SRV 0x1007 +#define BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_CLI 0x1008 +#define BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SRV 0x1009 +#define BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SETUP_SRV 0x100a +#define BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_CLI 0x100b +#define BLE_MESH_MODEL_ID_GEN_BATTERY_SRV 0x100c +#define BLE_MESH_MODEL_ID_GEN_BATTERY_CLI 0x100d +#define BLE_MESH_MODEL_ID_GEN_LOCATION_SRV 0x100e +#define BLE_MESH_MODEL_ID_GEN_LOCATION_SETUP_SRV 0x100f +#define BLE_MESH_MODEL_ID_GEN_LOCATION_CLI 0x1010 +#define BLE_MESH_MODEL_ID_GEN_ADMIN_PROP_SRV 0x1011 +#define BLE_MESH_MODEL_ID_GEN_MANUFACTURER_PROP_SRV 0x1012 +#define BLE_MESH_MODEL_ID_GEN_USER_PROP_SRV 0x1013 +#define BLE_MESH_MODEL_ID_GEN_CLIENT_PROP_SRV 0x1014 +#define BLE_MESH_MODEL_ID_GEN_PROP_CLI 0x1015 +#define BLE_MESH_MODEL_ID_SENSOR_SRV 0x1100 +#define BLE_MESH_MODEL_ID_SENSOR_SETUP_SRV 0x1101 +#define BLE_MESH_MODEL_ID_SENSOR_CLI 0x1102 +#define BLE_MESH_MODEL_ID_TIME_SRV 0x1200 +#define BLE_MESH_MODEL_ID_TIME_SETUP_SRV 0x1201 +#define BLE_MESH_MODEL_ID_TIME_CLI 0x1202 +#define BLE_MESH_MODEL_ID_SCENE_SRV 0x1203 +#define BLE_MESH_MODEL_ID_SCENE_SETUP_SRV 0x1204 +#define BLE_MESH_MODEL_ID_SCENE_CLI 0x1205 +#define BLE_MESH_MODEL_ID_SCHEDULER_SRV 0x1206 +#define BLE_MESH_MODEL_ID_SCHEDULER_SETUP_SRV 0x1207 +#define BLE_MESH_MODEL_ID_SCHEDULER_CLI 0x1208 +#define BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SRV 0x1300 +#define BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SETUP_SRV 0x1301 +#define BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_CLI 0x1302 +#define BLE_MESH_MODEL_ID_LIGHT_CTL_SRV 0x1303 +#define BLE_MESH_MODEL_ID_LIGHT_CTL_SETUP_SRV 0x1304 +#define BLE_MESH_MODEL_ID_LIGHT_CTL_CLI 0x1305 +#define BLE_MESH_MODEL_ID_LIGHT_CTL_TEMP_SRV 0x1306 +#define BLE_MESH_MODEL_ID_LIGHT_HSL_SRV 0x1307 +#define BLE_MESH_MODEL_ID_LIGHT_HSL_SETUP_SRV 0x1308 +#define BLE_MESH_MODEL_ID_LIGHT_HSL_CLI 0x1309 +#define BLE_MESH_MODEL_ID_LIGHT_HSL_HUE_SRV 0x130a +#define BLE_MESH_MODEL_ID_LIGHT_HSL_SAT_SRV 0x130b +#define BLE_MESH_MODEL_ID_LIGHT_XYL_SRV 0x130c +#define BLE_MESH_MODEL_ID_LIGHT_XYL_SETUP_SRV 0x130d +#define BLE_MESH_MODEL_ID_LIGHT_XYL_CLI 0x130e +#define BLE_MESH_MODEL_ID_LIGHT_LC_SRV 0x130f +#define BLE_MESH_MODEL_ID_LIGHT_LC_SETUP_SRV 0x1310 +#define BLE_MESH_MODEL_ID_LIGHT_LC_CLI 0x1311 + +/** Message sending context. */ +struct bt_mesh_msg_ctx { + /** NetKey Index of the subnet to send the message on. */ + uint16_t net_idx; + + /** AppKey Index to encrypt the message with. */ + uint16_t app_idx; + + /** Remote address. */ + uint16_t addr; + + /** Destination address of a received message. Not used for sending. */ + uint16_t recv_dst; + + /** RSSI of received packet. Not used for sending. */ + int8_t recv_rssi; + + /** Received TTL value. Not used for sending. */ + uint8_t recv_ttl: 7; + + /** Force sending reliably by using segment acknowledgement */ + uint8_t send_rel: 1; + + /** TTL, or BLE_MESH_TTL_DEFAULT for default TTL. */ + uint8_t send_ttl; + + /** Change by Espressif, opcode of a received message. + * Not used for sending message. */ + uint32_t recv_op; + + /** Change by Espressif, model corresponds to the message */ + struct bt_mesh_model *model; + + /** Change by Espressif, if the message is sent by a server + * model. Not used for receiving message. */ + bool srv_send; +}; + +struct bt_mesh_model_op { + /* OpCode encoded using the BLE_MESH_MODEL_OP_* macros */ + const uint32_t opcode; + + /* Minimum required message length */ + const size_t min_len; + + /* Message handler for the opcode */ + void (*const func)(struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf); +}; + +#define BLE_MESH_MODEL_OP_1(b0) (b0) +#define BLE_MESH_MODEL_OP_2(b0, b1) (((b0) << 8) | (b1)) +#define BLE_MESH_MODEL_OP_3(b0, cid) ((((b0) << 16) | 0xc00000) | (cid)) + +#define BLE_MESH_MODEL_OP_END { 0, 0, NULL } +#define BLE_MESH_MODEL_NO_OPS ((struct bt_mesh_model_op []) \ + { BLE_MESH_MODEL_OP_END }) + +/** Helper to define an empty model array */ +#define BLE_MESH_MODEL_NONE ((struct bt_mesh_model []){}) + +/** Length of a short Mesh MIC. */ +#define BLE_MESH_MIC_SHORT 4 +/** Length of a long Mesh MIC. */ +#define BLE_MESH_MIC_LONG 8 + +/** @def BLE_MESH_MODEL_OP_LEN + * + * @brief Helper to determine the length of an opcode. + * + * @param _op Opcode. + */ +#define BLE_MESH_MODEL_OP_LEN(_op) ((_op) <= 0xff ? 1 : (_op) <= 0xffff ? 2 : 3) + +/** @def BLE_MESH_MODEL_BUF_LEN + * + * @brief Helper for model message buffer length. + * + * Returns the length of a Mesh model message buffer, including the opcode + * length and a short MIC. + * + * @param _op Opcode of the message. + * @param _payload_len Length of the model payload. + */ +#define BLE_MESH_MODEL_BUF_LEN(_op, _payload_len) \ + (BLE_MESH_MODEL_OP_LEN(_op) + (_payload_len) + BLE_MESH_MIC_SHORT) + +/** @def BLE_MESH_MODEL_BUF_LEN_LONG_MIC + * + * @brief Helper for model message buffer length. + * + * Returns the length of a Mesh model message buffer, including the opcode + * length and a long MIC. + * + * @param _op Opcode of the message. + * @param _payload_len Length of the model payload. + */ +#define BLE_MESH_MODEL_BUF_LEN_LONG_MIC(_op, _payload_len) \ + (BLE_MESH_MODEL_OP_LEN(_op) + (_payload_len) + BLE_MESH_MIC_LONG) + +/** @def BLE_MESH_MODEL_BUF_DEFINE + * + * @brief Define a Mesh model message buffer using @ref NET_BUF_SIMPLE_DEFINE. + * + * @param _buf Buffer name. + * @param _op Opcode of the message. + * @param _payload_len Length of the model message payload. + */ +#define BLE_MESH_MODEL_BUF_DEFINE(_buf, _op, _payload_len) \ + NET_BUF_SIMPLE_DEFINE(_buf, BLE_MESH_MODEL_BUF_LEN((_op), (_payload_len))) + +/** @def BLE_MESH_MODEL_CB + * + * @brief Composition data SIG model entry with callback functions. + * + * @param _id Model ID. + * @param _op Array of model opcode handlers. + * @param _pub Model publish parameters. + * @param _user_data User data for the model. + * @param _cb Callback structure, or NULL to keep no callbacks. + */ +#define BLE_MESH_MODEL_CB(_id, _op, _pub, _user_data, _cb) \ +{ \ + .id = (_id), \ + .op = (_op), \ + .keys = { [0 ... (CONFIG_BLE_MESH_MODEL_KEY_COUNT - 1)] = \ + BLE_MESH_KEY_UNUSED }, \ + .pub = (_pub), \ + .groups = { [0 ... (CONFIG_BLE_MESH_MODEL_GROUP_COUNT - 1)] = \ + BLE_MESH_ADDR_UNASSIGNED }, \ + .user_data = (_user_data), \ + .cb = (_cb), \ +} + +/** @def BLE_MESH_MODEL_VND_CB + * + * @brief Composition data vendor model entry with callback functions. + * + * @param _company Company ID. + * @param _id Model ID. + * @param _op Array of model opcode handlers. + * @param _pub Model publish parameters. + * @param _user_data User data for the model. + * @param _cb Callback structure, or NULL to keep no callbacks. + */ +#define BLE_MESH_MODEL_VND_CB(_company, _id, _op, _pub, _user_data, _cb) \ +{ \ + .vnd.company = (_company), \ + .vnd.id = (_id), \ + .op = (_op), \ + .pub = (_pub), \ + .keys = { [0 ... (CONFIG_BLE_MESH_MODEL_KEY_COUNT - 1)] = \ + BLE_MESH_KEY_UNUSED }, \ + .groups = { [0 ... (CONFIG_BLE_MESH_MODEL_GROUP_COUNT - 1)] = \ + BLE_MESH_ADDR_UNASSIGNED }, \ + .user_data = (_user_data), \ + .cb = (_cb), \ +} + +/** @def BLE_MESH_TRANSMIT + * + * @brief Encode transmission count & interval steps. + * + * @param count Number of retransmissions (first transmission is excluded). + * @param int_ms Interval steps in milliseconds. Must be greater than 0 + * and a multiple of 10. + * + * @return Mesh transmit value that can be used e.g. for the default + * values of the configuration model data. + */ +#define BLE_MESH_TRANSMIT(count, int_ms) ((count) | ((((int_ms) / 10) - 1) << 3)) + +/** @def BLE_MESH_TRANSMIT_COUNT + * + * @brief Decode transmit count from a transmit value. + * + * @param transmit Encoded transmit count & interval value. + * + * @return Transmission count (actual transmissions is N + 1). + */ +#define BLE_MESH_TRANSMIT_COUNT(transmit) (((transmit) & (uint8_t)BIT_MASK(3))) + +/** @def BLE_MESH_TRANSMIT_INT + * + * @brief Decode transmit interval from a transmit value. + * + * @param transmit Encoded transmit count & interval value. + * + * @return Transmission interval in milliseconds. + */ +#define BLE_MESH_TRANSMIT_INT(transmit) ((((transmit) >> 3) + 1) * 10) + +/** @def BLE_MESH_PUB_TRANSMIT + * + * @brief Encode Publish Retransmit count & interval steps. + * + * @param count Number of retransmissions (first transmission is excluded). + * @param int_ms Interval steps in milliseconds. Must be greater than 0 + * and a multiple of 50. + * + * @return Mesh transmit value that can be used e.g. for the default + * values of the configuration model data. + */ +#define BLE_MESH_PUB_TRANSMIT(count, int_ms) BLE_MESH_TRANSMIT((count), (int_ms) / 5) + +/** @def BLE_MESH_PUB_TRANSMIT_COUNT + * + * @brief Decode Publish Retransmit count from a given value. + * + * @param transmit Encoded Publish Retransmit count & interval value. + * + * @return Retransmission count (actual transmissions is N + 1). + */ +#define BLE_MESH_PUB_TRANSMIT_COUNT(transmit) BLE_MESH_TRANSMIT_COUNT(transmit) + +/** @def BLE_MESH_PUB_TRANSMIT_INT + * + * @brief Decode Publish Retransmit interval from a given value. + * + * @param transmit Encoded Publish Retransmit count & interval value. + * + * @return Transmission interval in milliseconds. + */ +#define BLE_MESH_PUB_TRANSMIT_INT(transmit) ((((transmit) >> 3) + 1) * 50) + +/** Model publication context. */ +struct bt_mesh_model_pub { + /** The model the context belongs to. Initialized by the stack. */ + struct bt_mesh_model *mod; + + uint16_t addr; /**< Publish Address. */ + uint16_t key:12, /**< Publish AppKey Index. */ + cred:1, /**< Friendship Credentials Flag. */ + send_rel:1; /**< Force reliable sending (segment acks) */ + + uint8_t ttl; /**< Publish Time to Live. */ + uint8_t retransmit; /**< Retransmit Count & Interval Steps. */ + uint8_t period; /**< Publish Period. */ + uint8_t period_div:4, /**< Divisor for the Period. */ + fast_period:1, /**< Use FastPeriodDivisor */ + count:3; /**< Retransmissions left. */ + + uint32_t period_start; /**< Start of the current period. */ + + /** @brief Publication buffer, containing the publication message. + * + * This will get correctly created when the publication context + * has been defined using the BLE_MESH_MODEL_PUB_DEFINE macro. + * + * BLE_MESH_MODEL_PUB_DEFINE(name, update, size); + */ + struct net_buf_simple *msg; + + /** @brief Callback for updating the publication buffer. + * + * When set to NULL, the model is assumed not to support + * periodic publishing. When set to non-NULL the callback + * will be called periodically and is expected to update + * @ref bt_mesh_model_pub.msg with a valid publication + * message. + * + * If the callback returns non-zero, the publication is skipped + * and will resume on the next periodic publishing interval. + * + * @param mod The Model the Publication Context belongs to. + * + * @return Zero on success or (negative) error code otherwise. + */ + int (*update)(struct bt_mesh_model *mod); + + /** Publish Period Timer. Only for stack-internal use. */ + struct k_delayed_work timer; + + /* Change by Espressif, role of the device going to publish messages */ + uint8_t dev_role; +}; + +/** @def BLE_MESH_MODEL_PUB_DEFINE + * + * Define a model publication context. + * + * @param _name Variable name given to the context. + * @param _update Optional message update callback (may be NULL). + * @param _msg_len Length of the publication message. + */ +#define BLE_MESH_MODEL_PUB_DEFINE(_name, _update, _msg_len) \ + NET_BUF_SIMPLE_DEFINE_STATIC(bt_mesh_pub_msg_##_name, _msg_len); \ + static struct bt_mesh_model_pub _name = { \ + .update = _update, \ + .msg = &bt_mesh_pub_msg_##_name, \ + } + +/** Model callback functions. */ +struct bt_mesh_model_cb { + /** @brief Model init callback. + * + * Called on every model instance during mesh initialization. + * + * If any of the model init callbacks return an error, the mesh + * subsystem initialization will be aborted, and the error will + * be returned to the caller of @ref bt_mesh_init. + * + * @param model Model to be initialized. + * + * @return 0 on success, error otherwise. + */ + int (*const init)(struct bt_mesh_model *model); + +#if CONFIG_BLE_MESH_DEINIT + /** @brief Model deinit callback. + * + * Called on every model instance during mesh deinitialization. + * All model data is deleted, and the model should clear its state. + * + * If any of the model deinit callbacks return an error, the mesh + * subsystem deinitialization will be aborted, and the error will + * be returned to the caller of @ref bt_mesh_deinit. + * + * @param model Model to be de-initialized. + */ + int (*const deinit)(struct bt_mesh_model *model); +#endif /* CONFIG_BLE_MESH_DEINIT */ +}; + +/** Abstraction that describes a Mesh Model instance */ +struct bt_mesh_model { + union { + const uint16_t id; + struct { + uint16_t company; + uint16_t id; + } vnd; + }; + + /* Internal information, mainly for persistent storage */ + uint8_t elem_idx; /* Belongs to Nth element */ + uint8_t model_idx; /* Is the Nth model in the element */ + uint16_t flags; /* Information about what has changed */ + + /* The Element this Model belongs to */ + struct bt_mesh_elem *elem; + + /* Model Publication */ + struct bt_mesh_model_pub *const pub; + + /* AppKey List */ + uint16_t keys[CONFIG_BLE_MESH_MODEL_KEY_COUNT]; + + /* Subscription List (group or virtual addresses) */ + uint16_t groups[CONFIG_BLE_MESH_MODEL_GROUP_COUNT]; + + /** Opcode handler list */ + const struct bt_mesh_model_op *const op; + + /** Model callback structure. */ + const struct bt_mesh_model_cb *const cb; + + /* Model-specific user data */ + void *user_data; +}; + +struct bt_mesh_send_cb { + void (*start)(uint16_t duration, int err, void *cb_data); + void (*end)(int err, void *cb_data); +}; + +void bt_mesh_model_msg_init(struct net_buf_simple *msg, uint32_t opcode); + +/** Special TTL value to request using configured default TTL */ +#define BLE_MESH_TTL_DEFAULT 0xff + +/** Maximum allowed TTL value */ +#define BLE_MESH_TTL_MAX 0x7f + +/** + * @brief Send an Access Layer message. + * + * @param model Mesh (client) Model that the message belongs to. + * @param ctx Message context, includes keys, TTL, etc. + * @param msg Access Layer payload (the actual message to be sent). + * @param cb Optional "message sent" callback. + * @param cb_data User data to be passed to the callback. + * + * @return 0 on success, or (negative) error code on failure. + */ +int bt_mesh_model_send(struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *msg, + const struct bt_mesh_send_cb *cb, + void *cb_data); + +/** + * @brief Send a model publication message. + * + * Before calling this function, the user needs to ensure that the model + * publication message (@ref bt_mesh_model_pub.msg) contains a valid + * message to be sent. Note that this API is only to be used for + * non-period publishing. For periodic publishing the app only needs + * to make sure that @ref bt_mesh_model_pub.msg contains a valid message + * whenever the @ref bt_mesh_model_pub.update callback is called. + * + * @param model Mesh (client) Model that's publishing the message. + * + * @return 0 on success, or (negative) error code on failure. + */ +int bt_mesh_model_publish(struct bt_mesh_model *model); + +/** + * @brief Get the element that a model belongs to. + * + * @param mod Mesh model. + * + * @return Pointer to the element that the given model belongs to. + */ +struct bt_mesh_elem *bt_mesh_model_elem(struct bt_mesh_model *mod); + +/** @brief Find a SIG model. + * + * @param elem Element to search for the model in. + * @param id Model ID of the model. + * + * @return A pointer to the Mesh model matching the given parameters, or NULL + * if no SIG model with the given ID exists in the given element. + */ +struct bt_mesh_model *bt_mesh_model_find(struct bt_mesh_elem *elem, uint16_t id); + +/** @brief Find a vendor model. + * + * @param elem Element to search for the model in. + * @param company Company ID of the model. + * @param id Model ID of the model. + * + * @return A pointer to the Mesh model matching the given parameters, or NULL + * if no vendor model with the given ID exists in the given element. + */ +struct bt_mesh_model *bt_mesh_model_find_vnd(struct bt_mesh_elem *elem, + uint16_t company, uint16_t id); + +/** @brief Get whether the model is in the primary element of the device. + * + * @param mod Mesh model. + * + * @return true if the model is on the primary element, false otherwise. + */ +static inline bool bt_mesh_model_in_primary(const struct bt_mesh_model *mod) +{ + return (mod->elem_idx == 0); +} + +/** Node Composition */ +struct bt_mesh_comp { + uint16_t cid; + uint16_t pid; + uint16_t vid; + + size_t elem_count; + struct bt_mesh_elem *elem; +}; + +#ifdef __cplusplus +} +#endif + +/** + * @} + */ + +#endif /* __BLE_MESH_ACCESS_H */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/include/mesh_bearer_adapt.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/include/mesh_bearer_adapt.h new file mode 100644 index 00000000000..0174c32741f --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/include/mesh_bearer_adapt.h @@ -0,0 +1,807 @@ +/* + * SPDX-FileCopyrightText: 2017 Nordic Semiconductor ASA + * SPDX-FileCopyrightText: 2015-2017 Intel Corporation + * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _BLE_MESH_BEARER_ADAPT_H_ +#define _BLE_MESH_BEARER_ADAPT_H_ + +#include +#include "mesh_config.h" +#include "mesh_types.h" +#include "mesh_util.h" +#include "mesh_uuid.h" +#include "mesh_buf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* BLE Mesh Max Connection Count */ +#ifdef CONFIG_BT_BLUEDROID_ENABLED +#define BLE_MESH_MAX_CONN CONFIG_BT_ACL_CONNECTIONS +#endif + +#ifdef CONFIG_BT_NIMBLE_ENABLED +#define BLE_MESH_MAX_CONN CONFIG_BT_NIMBLE_MAX_CONNECTIONS +#endif + +#define BLE_MESH_GAP_ADV_MAX_LEN 31 + +#define BLE_MESH_GATT_DEF_MTU_SIZE 23 + +/* BD ADDR types */ +#define BLE_MESH_ADDR_PUBLIC 0x00 +#define BLE_MESH_ADDR_RANDOM 0x01 +#define BLE_MESH_ADDR_PUBLIC_ID 0x02 +#define BLE_MESH_ADDR_RANDOM_ID 0x03 + +/* BD ADDR length */ +#define BLE_MESH_ADDR_LEN 0x06 + +/* Advertising types */ +#define BLE_MESH_ADV_IND 0x00 +#define BLE_MESH_ADV_DIRECT_IND 0x01 +#define BLE_MESH_ADV_SCAN_IND 0x02 +#define BLE_MESH_ADV_NONCONN_IND 0x03 +#define BLE_MESH_ADV_DIRECT_IND_LOW_DUTY 0x04 + +/* advertising channel map */ +#define BLE_MESH_ADV_CHNL_37 BIT(0) +#define BLE_MESH_ADV_CHNL_38 BIT(1) +#define BLE_MESH_ADV_CHNL_39 BIT(2) + +/* Advertising filter policy */ +#define BLE_MESH_AP_SCAN_CONN_ALL 0x00 +#define BLE_MESH_AP_SCAN_WL_CONN_ALL 0x01 +#define BLE_MESH_AP_SCAN_ALL_CONN_WL 0x02 +#define BLE_MESH_AP_SCAN_CONN_WL 0x03 + +/* Scan types */ +#define BLE_MESH_SCAN_PASSIVE 0x00 +#define BLE_MESH_SCAN_ACTIVE 0x01 + +/* Scan operation */ +#define BLE_MESH_SCAN_DISABLE 0x00 +#define BLE_MESH_SCAN_ENABLE 0x01 + +/* Scan duplicate operation */ +#define BLE_MESH_SCAN_FILTER_DUP_DISABLE 0x00 +#define BLE_MESH_SCAN_FILTER_DUP_ENABLE 0x01 + +/* Scan filter policy */ +#define BLE_MESH_SP_ADV_ALL 0x00 +#define BLE_MESH_SP_ADV_WL 0x01 +#define BLE_MESH_SP_ADV_ALL_RPA_DIR_ADV 0x02 +#define BLE_MESH_SP_ADV_WL_RPA_DIR_ADV 0x03 + +/* Error codes for Error response PDU */ +#define BLE_MESH_ATT_ERR_INVALID_HANDLE 0x01 +#define BLE_MESH_ATT_ERR_READ_NOT_PERMITTED 0x02 +#define BLE_MESH_ATT_ERR_WRITE_NOT_PERMITTED 0x03 +#define BLE_MESH_ATT_ERR_INVALID_PDU 0x04 +#define BLE_MESH_ATT_ERR_AUTHENTICATION 0x05 +#define BLE_MESH_ATT_ERR_NOT_SUPPORTED 0x06 +#define BLE_MESH_ATT_ERR_INVALID_OFFSET 0x07 +#define BLE_MESH_ATT_ERR_AUTHORIZATION 0x08 +#define BLE_MESH_ATT_ERR_PREPARE_QUEUE_FULL 0x09 +#define BLE_MESH_ATT_ERR_ATTRIBUTE_NOT_FOUND 0x0a +#define BLE_MESH_ATT_ERR_ATTRIBUTE_NOT_LONG 0x0b +#define BLE_MESH_ATT_ERR_ENCRYPTION_KEY_SIZE 0x0c +#define BLE_MESH_ATT_ERR_INVALID_ATTRIBUTE_LEN 0x0d +#define BLE_MESH_ATT_ERR_UNLIKELY 0x0e +#define BLE_MESH_ATT_ERR_INSUFFICIENT_ENCRYPTION 0x0f +#define BLE_MESH_ATT_ERR_UNSUPPORTED_GROUP_TYPE 0x10 +#define BLE_MESH_ATT_ERR_INSUFFICIENT_RESOURCES 0x11 + +/* Common Profile Error Codes (from CSS) */ +#define BLE_MESH_ATT_ERR_WRITE_REQ_REJECTED 0xfc +#define BLE_MESH_ATT_ERR_CCC_IMPROPER_CONF 0xfd +#define BLE_MESH_ATT_ERR_PROCEDURE_IN_PROGRESS 0xfe +#define BLE_MESH_ATT_ERR_OUT_OF_RANGE 0xff + +/* EIR/AD data type definitions */ +#define BLE_MESH_DATA_FLAGS 0x01 /* AD flags */ +#define BLE_MESH_DATA_UUID16_SOME 0x02 /* 16-bit UUID, more available */ +#define BLE_MESH_DATA_UUID16_ALL 0x03 /* 16-bit UUID, all listed */ +#define BLE_MESH_DATA_UUID32_SOME 0x04 /* 32-bit UUID, more available */ +#define BLE_MESH_DATA_UUID32_ALL 0x05 /* 32-bit UUID, all listed */ +#define BLE_MESH_DATA_UUID128_SOME 0x06 /* 128-bit UUID, more available */ +#define BLE_MESH_DATA_UUID128_ALL 0x07 /* 128-bit UUID, all listed */ +#define BLE_MESH_DATA_NAME_SHORTENED 0x08 /* Shortened name */ +#define BLE_MESH_DATA_NAME_COMPLETE 0x09 /* Complete name */ +#define BLE_MESH_DATA_TX_POWER 0x0a /* Tx Power */ +#define BLE_MESH_DATA_SOLICIT16 0x14 /* Solicit UUIDs, 16-bit */ +#define BLE_MESH_DATA_SOLICIT128 0x15 /* Solicit UUIDs, 128-bit */ +#define BLE_MESH_DATA_SVC_DATA16 0x16 /* Service data, 16-bit UUID */ +#define BLE_MESH_DATA_GAP_APPEARANCE 0x19 /* GAP appearance */ +#define BLE_MESH_DATA_SOLICIT32 0x1f /* Solicit UUIDs, 32-bit */ +#define BLE_MESH_DATA_SVC_DATA32 0x20 /* Service data, 32-bit UUID */ +#define BLE_MESH_DATA_SVC_DATA128 0x21 /* Service data, 128-bit UUID */ +#define BLE_MESH_DATA_URI 0x24 /* URI */ +#define BLE_MESH_DATA_MESH_PROV 0x29 /* Mesh Provisioning PDU */ +#define BLE_MESH_DATA_MESH_MESSAGE 0x2a /* Mesh Networking PDU */ +#define BLE_MESH_DATA_MESH_BEACON 0x2b /* Mesh Beacon */ + +#define BLE_MESH_DATA_MANUFACTURER_DATA 0xff /* Manufacturer Specific Data */ + +#define BLE_MESH_AD_LIMITED 0x01 /* Limited Discoverable */ +#define BLE_MESH_AD_GENERAL 0x02 /* General Discoverable */ +#define BLE_MESH_AD_NO_BREDR 0x04 /* BR/EDR not supported */ + +/* Client Characteristic Configuration Values */ + +/** @def BLE_MESH_GATT_CCC_NOTIFY + * @brief Client Characteristic Configuration Notification. + * + * If set, changes to Characteristic Value shall be notified. + */ +#define BLE_MESH_GATT_CCC_NOTIFY 0x0001 + +/** @def BLE_MESH_GATT_CCC_INDICATE + * @brief Client Characteristic Configuration Indication. + * + * If set, changes to Characteristic Value shall be indicated. + */ +#define BLE_MESH_GATT_CCC_INDICATE 0x0002 + +/** @def BLE_MESH_GATT_ERR + * @brief Construct error return value for attribute read and write callbacks. + * + * @param _att_err ATT error code + * + * @return Appropriate error code for the attribute callbacks. + * + */ +#define BLE_MESH_GATT_ERR(_att_err) (-(_att_err)) + +enum { + BLE_MESH_GATT_ITER_STOP = 0, + BLE_MESH_GATT_ITER_CONTINUE, +}; + +/* GATT attribute permission bit field values */ +enum { + /** No operations supported, e.g. for notify-only */ + BLE_MESH_GATT_PERM_NONE = 0, + + /** Attribute read permission. */ + BLE_MESH_GATT_PERM_READ = BIT(0), + + /** Attribute write permission. */ + BLE_MESH_GATT_PERM_WRITE = BIT(1), + + /** Attribute read permission with encryption. + * + * If set, requires encryption for read access. + */ + BLE_MESH_GATT_PERM_READ_ENCRYPT = BIT(2), + + /** Attribute write permission with encryption. + * + * If set, requires encryption for write access. + */ + BLE_MESH_GATT_PERM_WRITE_ENCRYPT = BIT(3), + + /** Attribute read permission with authentication. + * + * If set, requires encryption using authenticated link-key for read + * access. + */ + BLE_MESH_GATT_PERM_READ_AUTHEN = BIT(4), + + /** Attribute write permission with authentication. + * + * If set, requires encryption using authenticated link-key for write + * access. + */ + BLE_MESH_GATT_PERM_WRITE_AUTHEN = BIT(5), + + /** Attribute prepare write permission. + * + * If set, allows prepare writes with use of BT_GATT_WRITE_FLAG_PREPARE + * passed to write callback. + */ + BLE_MESH_GATT_PERM_PREPARE_WRITE = BIT(6), +}; + +/** Advertising options */ +enum { + /** Convenience value when no options are specified. */ + BLE_MESH_ADV_OPT_NONE = 0, + + /** Advertise as connectable. Type of advertising is determined by + * providing SCAN_RSP data and/or enabling local privacy support. + */ + BLE_MESH_ADV_OPT_CONNECTABLE = BIT(0), + + /** Don't try to resume connectable advertising after a connection. + * This option is only meaningful when used together with + * BLE_MESH_ADV_OPT_CONNECTABLE. If set the advertising will be stopped + * when bt_le_adv_stop() is called or when an incoming (slave) + * connection happens. If this option is not set the stack will + * take care of keeping advertising enabled even as connections + * occur. + */ + BLE_MESH_ADV_OPT_ONE_TIME = BIT(1), +}; + +/* Defined GAP timers */ +#define BLE_MESH_GAP_SCAN_FAST_INTERVAL 0x0060 /* 60 ms */ +#define BLE_MESH_GAP_SCAN_FAST_WINDOW 0x0030 /* 30 ms */ +#define BLE_MESH_GAP_SCAN_SLOW_INTERVAL_1 0x0800 /* 1.28 s */ +#define BLE_MESH_GAP_SCAN_SLOW_WINDOW_1 0x0012 /* 11.25 ms */ +#define BLE_MESH_GAP_SCAN_SLOW_INTERVAL_2 0x1000 /* 2.56 s */ +#define BLE_MESH_GAP_SCAN_SLOW_WINDOW_2 0x0012 /* 11.25 ms */ +#define BLE_MESH_GAP_ADV_FAST_INT_MIN_0 0x0020 /* 20 ms */ +#define BLE_MESH_GAP_ADV_FAST_INT_MAX_0 0x0020 /* 20 ms */ +#define BLE_MESH_GAP_ADV_FAST_INT_MIN_1 0x0030 /* 30 ms */ +#define BLE_MESH_GAP_ADV_FAST_INT_MAX_1 0x0060 /* 60 ms */ +#define BLE_MESH_GAP_ADV_FAST_INT_MIN_2 0x00a0 /* 100 ms */ +#define BLE_MESH_GAP_ADV_FAST_INT_MAX_2 0x00f0 /* 150 ms */ +#define BLE_MESH_GAP_ADV_SLOW_INT_MIN 0x0320 /* 500 ms */ +#define BLE_MESH_GAP_ADV_SLOW_INT_MAX 0x0320 /* 500 ms */ +#define BLE_MESH_GAP_INIT_CONN_INT_MIN 0x0018 /* 30 ms */ +#define BLE_MESH_GAP_INIT_CONN_INT_MAX 0x0028 /* 50 ms */ + +/* Characteristic Properties Bit field values */ + +/** @def BLE_MESH_GATT_CHRC_BROADCAST + * @brief Characteristic broadcast property. + * + * If set, permits broadcasts of the Characteristic Value using Server + * Characteristic Configuration Descriptor. + */ +#define BLE_MESH_GATT_CHRC_BROADCAST 0x01 + +/** @def BLE_MESH_GATT_CHRC_READ + * @brief Characteristic read property. + * + * If set, permits reads of the Characteristic Value. + */ +#define BLE_MESH_GATT_CHRC_READ 0x02 + +/** @def BLE_MESH_GATT_CHRC_WRITE_WITHOUT_RESP + * @brief Characteristic write without response property. + * + * If set, permits write of the Characteristic Value without response. + */ +#define BLE_MESH_GATT_CHRC_WRITE_WITHOUT_RESP 0x04 + +/** @def BLE_MESH_GATT_CHRC_WRITE + * @brief Characteristic write with response property. + * + * If set, permits write of the Characteristic Value with response. + */ +#define BLE_MESH_GATT_CHRC_WRITE 0x08 + +/** @def BLE_MESH_GATT_CHRC_NOTIFY + * @brief Characteristic notify property. + * + * If set, permits notifications of a Characteristic Value without + * acknowledgment. + */ +#define BLE_MESH_GATT_CHRC_NOTIFY 0x10 + +/** @def BLE_MESH_GATT_CHRC_INDICATE + * @brief Characteristic indicate property. + * + * If set, permits indications of a Characteristic Value with acknowledgment. + */ +#define BLE_MESH_GATT_CHRC_INDICATE 0x20 + +/** @def BLE_MESH_GATT_CHRC_AUTH + * @brief Characteristic Authenticated Signed Writes property. + * + * If set, permits signed writes to the Characteristic Value. + */ +#define BLE_MESH_GATT_CHRC_AUTH 0x40 + +/** @def BLE_MESH_GATT_CHRC_EXT_PROP + * @brief Characteristic Extended Properties property. + * + * If set, additional characteristic properties are defined in the + * Characteristic Extended Properties Descriptor. + */ +#define BLE_MESH_GATT_CHRC_EXT_PROP 0x80 + +/** @brief Characteristic Attribute Value. */ +struct bt_mesh_gatt_char { + /** Characteristic UUID. */ + const struct bt_mesh_uuid *uuid; + /** Characteristic properties. */ + uint8_t properties; +}; + +/** @brief GATT Service structure */ +struct bt_mesh_gatt_service { + /** Service Attributes */ + struct bt_mesh_gatt_attr *attrs; + /** Service Attribute count */ + uint16_t attr_count; + sys_snode_t node; +}; + +typedef struct { + uint8_t type; + uint8_t val[6]; +} bt_mesh_addr_t; + +/** Description of different data types that can be encoded into + * advertising data. Used to form arrays that are passed to the + * bt_le_adv_start() function. + */ +struct bt_mesh_adv_data { + uint8_t type; + uint8_t data_len; + const uint8_t *data; +}; + +/** @brief Helper to declare elements of bt_data arrays + * + * This macro is mainly for creating an array of struct + * bt_mesh_adv_data elements which is then passed to + * bt_le_adv_start(). + * + * @param _type Type of advertising data field + * @param _data Pointer to the data field payload + * @param _data_len Number of bytes behind the _data pointer + */ +#define BLE_MESH_ADV_DATA(_type, _data, _data_len) \ + { \ + .type = (_type), \ + .data_len = (_data_len), \ + .data = (const uint8_t *)(_data), \ + } + +/** @brief Helper to declare elements of bt_data arrays + * + * This macro is mainly for creating an array of struct bt_mesh_adv_data + * elements which is then passed to bt_le_adv_start(). + * + * @param _type Type of advertising data field + * @param _bytes Variable number of single-byte parameters + */ +#define BLE_MESH_ADV_DATA_BYTES(_type, _bytes...) \ + BLE_MESH_ADV_DATA(_type, ((uint8_t []) { _bytes }), \ + sizeof((uint8_t []) { _bytes })) + +/* BLE Mesh Advertising Parameters */ +struct bt_mesh_adv_param { + /** Bit-field of advertising options */ + uint8_t options; + + /** Minimum Advertising Interval (N * 0.625) */ + uint16_t interval_min; + + /** Maximum Advertising Interval (N * 0.625) */ + uint16_t interval_max; +}; + +#if CONFIG_BLE_MESH_SUPPORT_BLE_ADV +enum bt_mesh_ble_adv_priority { + BLE_MESH_BLE_ADV_PRIO_LOW, + BLE_MESH_BLE_ADV_PRIO_HIGH, +}; + +struct bt_mesh_ble_adv_param { + uint16_t interval; /* Advertising interval */ + uint8_t adv_type; /* Advertising type */ + uint8_t own_addr_type; /* Own address type */ + uint8_t peer_addr_type; /* Peer address type */ + uint8_t peer_addr[6]; /* Peer address */ + uint16_t duration; /* Duration is milliseconds */ + uint16_t period; /* Period in milliseconds */ + uint16_t count; /* Number of advertising duration */ + uint8_t priority:2; /* Priority of BLE advertising packet */ +}; + +struct bt_mesh_ble_adv_data { + uint8_t adv_data_len; /* Advertising data length */ + uint8_t adv_data[31]; /* Advertising data */ + uint8_t scan_rsp_data_len; /* Scan response data length */ + uint8_t scan_rsp_data[31]; /* Scan response data */ +}; +#endif /* CONFIG_BLE_MESH_SUPPORT_BLE_ADV */ + +/* BLE Mesh scan parameters */ +struct bt_mesh_scan_param { + /** Scan type (BLE_MESH_SCAN_ACTIVE or BLE_MESH_SCAN_PASSIVE) */ + uint8_t type; + + /** Duplicate filtering (BLE_MESH_SCAN_FILTER_DUP_ENABLE or + * BLE_MESH_SCAN_FILTER_DUP_DISABLE) + */ + uint8_t filter_dup; + + /** Scan interval (N * 0.625 ms) */ + uint16_t interval; + + /** Scan window (N * 0.625 ms) */ + uint16_t window; + + /** BLE scan filter policy */ + uint8_t scan_fil_policy; +}; + +struct bt_mesh_conn { + uint16_t handle; + bt_mesh_atomic_t ref; +}; + +/** @typedef bt_mesh_scan_cb_t + * @brief Callback type for reporting LE scan results. + * + * A function of this type is given to the bt_le_scan_start() function + * and will be called for any discovered LE device. + * + * @param addr Advertiser LE address and type. + * @param rssi Strength of advertiser signal. + * @param adv_type Type of advertising response from advertiser. + * @param data Buffer containing advertiser data. + */ +typedef void bt_mesh_scan_cb_t(const bt_mesh_addr_t *addr, int8_t rssi, + uint8_t adv_type, struct net_buf_simple *buf); + +/* @typedef bt_mesh_dh_key_cb_t + * @brief Callback type for DH Key calculation. + * + * Used to notify of the calculated DH Key. + * + * @param key Public key. + * @param idx Provisioning link index, only used by Provisioner. + * + * @return The DH Key, or NULL in case of failure. + */ +typedef void (*bt_mesh_dh_key_cb_t)(const uint8_t key[32], const uint8_t idx); + +/** @typedef bt_mesh_gatt_attr_func_t + * @brief Attribute iterator callback. + * + * @param attr Attribute found. + * @param user_data Data given. + * + * @return BLE_MESH_GATT_ITER_CONTINUE if should continue to the next attribute + * or BLE_MESH_GATT_ITER_STOP to stop. + */ +typedef uint8_t (*bt_mesh_gatt_attr_func_t)(const struct bt_mesh_gatt_attr *attr, + void *user_data); + +/** @brief Connection callback structure. + * + * This structure is used for tracking the state of a connection. + * It is registered with the help of the bt_mesh_gatts_conn_cb_register() API. + * It's permissible to register multiple instances of this @ref bt_conn_cb + * type, in case different modules of an application are interested in + * tracking the connection state. If a callback is not of interest for + * an instance, it may be set to NULL and will as a consequence not be + * used for that instance. + */ +struct bt_mesh_conn_cb { + /** @brief A new connection has been established. + * + * This callback notifies the application of a new connection. + * In case the err parameter is non-zero it means that the + * connection establishment failed. + * + * @param conn New connection object. + * @param err HCI error. Zero for success, non-zero otherwise. + */ + void (*connected)(struct bt_mesh_conn *conn, uint8_t err); + + /** @brief A connection has been disconnected. + * + * This callback notifies the application that a connection + * has been disconnected. + * + * @param conn Connection object. + * @param reason HCI reason for the disconnection. + */ + void (*disconnected)(struct bt_mesh_conn *conn, uint8_t reason); +}; + +struct bt_mesh_prov_conn_cb { + void (*connected)(bt_mesh_addr_t *addr, struct bt_mesh_conn *conn, int id); + + void (*disconnected)(bt_mesh_addr_t *addr, struct bt_mesh_conn *conn, uint8_t reason); + + ssize_t (*prov_write_descr)(bt_mesh_addr_t *addr, struct bt_mesh_conn *conn); + + ssize_t (*prov_notify)(struct bt_mesh_conn *conn, uint8_t *data, uint16_t len); + + ssize_t (*proxy_write_descr)(bt_mesh_addr_t *addr, struct bt_mesh_conn *conn); + + ssize_t (*proxy_notify)(struct bt_mesh_conn *conn, uint8_t *data, uint16_t len); +}; + +/** @brief GATT Attribute structure. */ +struct bt_mesh_gatt_attr { + /** Attribute UUID */ + const struct bt_mesh_uuid *uuid; + + /** Attribute read callback + * + * @param conn The connection that is requesting to read + * @param attr The attribute that's being read + * @param buf Buffer to place the read result in + * @param len Length of data to read + * @param offset Offset to start reading from + * + * @return Number fo bytes read, or in case of an error + * BLE_MESH_GATT_ERR() with a specific ATT error code. + */ + ssize_t (*read)(struct bt_mesh_conn *conn, + const struct bt_mesh_gatt_attr *attr, + void *buf, uint16_t len, + uint16_t offset); + + /** Attribute write callback + * + * @param conn The connection that is requesting to write + * @param attr The attribute that's being written + * @param buf Buffer with the data to write + * @param len Number of bytes in the buffer + * @param offset Offset to start writing from + * @param flags Flags (BT_GATT_WRITE_*) + * + * @return Number of bytes written, or in case of an error + * BLE_MESH_GATT_ERR() with a specific ATT error code. + */ + ssize_t (*write)(struct bt_mesh_conn *conn, + const struct bt_mesh_gatt_attr *attr, + const void *buf, uint16_t len, + uint16_t offset, uint8_t flags); + + /** Attribute user data */ + void *user_data; + /** Attribute handle */ + uint16_t handle; + /** Attribute permissions */ + uint8_t perm; +}; + +/** @def BLE_MESH_GATT_PRIMARY_SERVICE + * @brief Primary Service Declaration Macro. + * + * Helper macro to declare a primary service attribute. + * + * @param _service Service attribute value. + */ +#define BLE_MESH_GATT_PRIMARY_SERVICE(_service) \ +{ \ + .uuid = BLE_MESH_UUID_GATT_PRIMARY, \ + .perm = BLE_MESH_GATT_PERM_READ, \ + .read = bt_mesh_gatts_attr_read_service, \ + .user_data = _service, \ +} + +/** @def BLE_MESH_GATT_SECONDARY_SERVICE + * @brief Secondary Service Declaration Macro. + * + * Helper macro to declare a secondary service attribute. + * + * @param _service Service attribute value. + */ +#define BLE_MESH_GATT_SECONDARY_SERVICE(_service) \ +{ \ + .uuid = BLE_MESH_UUID_GATT_SECONDARY, \ + .perm = BLE_MESH_GATT_PERM_READ, \ + .read = bt_mesh_gatts_attr_read_service, \ + .user_data = _service, \ +} + +/** @def BLE_MESH_GATT_INCLUDE_SERVICE + * @brief Include Service Declaration Macro. + * + * Helper macro to declare database internal include service attribute. + * + * @param _service_incl the first service attribute of service to include + */ +#define BLE_MESH_GATT_INCLUDE_SERVICE(_service_incl) \ +{ \ + .uuid = BLE_MESH_UUID_GATT_INCLUDE, \ + .perm = BLE_MESH_GATT_PERM_READ, \ + .read = bt_mesh_gatts_attr_read_included, \ + .user_data = _service_incl, \ +} + +/** @def BLE_MESH_GATT_CHARACTERISTIC + * @brief Characteristic Declaration Macro. + * + * Helper macro to declare a characteristic attribute. + * + * @param _uuid Characteristic attribute uuid. + * @param _props Characteristic attribute properties. + */ +#define BLE_MESH_GATT_CHARACTERISTIC(_uuid, _props) \ +{ \ + .uuid = BLE_MESH_UUID_GATT_CHRC, \ + .perm = BLE_MESH_GATT_PERM_READ, \ + .read = bt_mesh_gatts_attr_read_chrc, \ + .user_data = (&(struct bt_mesh_gatt_char) { .uuid = _uuid, \ + .properties = _props, }), \ +} + +/** @def BLE_MESH_GATT_DESCRIPTOR + * @brief Descriptor Declaration Macro. + * + * Helper macro to declare a descriptor attribute. + * + * @param _uuid Descriptor attribute uuid. + * @param _perm Descriptor attribute access permissions. + * @param _read Descriptor attribute read callback. + * @param _write Descriptor attribute write callback. + * @param _value Descriptor attribute value. + */ +#define BLE_MESH_GATT_DESCRIPTOR(_uuid, _perm, _read, _write, _value) \ +{ \ + .uuid = _uuid, \ + .perm = _perm, \ + .read = _read, \ + .write = _write, \ + .user_data = _value, \ +} + +/** @def BLE_MESH_GATT_SERVICE + * @brief Service Structure Declaration Macro. + * + * Helper macro to declare a service structure. + * + * @param _attrs Service attributes. + */ +#define BLE_MESH_GATT_SERVICE(_attrs) \ +{ \ + .attrs = _attrs, \ + .attr_count = ARRAY_SIZE(_attrs), \ +} + +int bt_mesh_host_init(void); + +int bt_le_adv_start(const struct bt_mesh_adv_param *param, + const struct bt_mesh_adv_data *ad, size_t ad_len, + const struct bt_mesh_adv_data *sd, size_t sd_len); + +#if CONFIG_BLE_MESH_SUPPORT_BLE_ADV +int bt_mesh_ble_adv_start(const struct bt_mesh_ble_adv_param *param, + const struct bt_mesh_ble_adv_data *data); +#endif + +int bt_le_adv_stop(void); + +int bt_le_scan_start(const struct bt_mesh_scan_param *param, bt_mesh_scan_cb_t cb); + +int bt_le_scan_stop(void); + +typedef enum { + BLE_MESH_WHITELIST_REMOVE, + BLE_MESH_WHITELIST_ADD, +} bt_mesh_wl_operation; + +struct bt_mesh_white_list { + bool add_remove; + uint8_t remote_bda[BLE_MESH_ADDR_LEN]; + uint8_t addr_type; + /* For Bluedroid host, this callback is used to notify the + * result of updating white list. + */ + void (*update_wl_comp_cb)(uint8_t status, bt_mesh_wl_operation wl_operation); +}; + +int bt_le_update_white_list(struct bt_mesh_white_list *wl); + +void bt_mesh_gatts_conn_cb_register(struct bt_mesh_conn_cb *cb); +void bt_mesh_gatts_conn_cb_deregister(void); + +int bt_mesh_gatts_disconnect(struct bt_mesh_conn *conn, uint8_t reason); + +int bt_mesh_gatts_service_register(struct bt_mesh_gatt_service *svc); +int bt_mesh_gatts_service_deregister(struct bt_mesh_gatt_service *svc); + +int bt_mesh_gatts_service_unregister(struct bt_mesh_gatt_service *svc); + +ssize_t bt_mesh_gatts_attr_read_included(struct bt_mesh_conn *conn, + const struct bt_mesh_gatt_attr *attr, + void *buf, uint16_t len, uint16_t offset); + +ssize_t bt_mesh_gatts_attr_read(struct bt_mesh_conn *conn, + const struct bt_mesh_gatt_attr *attr, + void *buf, uint16_t buf_len, uint16_t offset, + const void *value, uint16_t value_len); + +ssize_t bt_mesh_gatts_attr_read_service(struct bt_mesh_conn *conn, + const struct bt_mesh_gatt_attr *attr, + void *buf, uint16_t len, uint16_t offset); + +ssize_t bt_mesh_gatts_attr_read_chrc(struct bt_mesh_conn *conn, + const struct bt_mesh_gatt_attr *attr, + void *buf, uint16_t len, uint16_t offset); + +int bt_mesh_gatts_notify(struct bt_mesh_conn *conn, + const struct bt_mesh_gatt_attr *attr, + const void *data, uint16_t len); + +uint16_t bt_mesh_gatt_get_mtu(struct bt_mesh_conn *conn); + +/** APIs added by Espressif */ +int bt_mesh_gatts_service_stop(struct bt_mesh_gatt_service *svc); +int bt_mesh_gatts_service_start(struct bt_mesh_gatt_service *svc); + +int bt_mesh_gatts_set_local_device_name(const char *name); + +void bt_mesh_gattc_conn_cb_register(struct bt_mesh_prov_conn_cb *cb); +void bt_mesh_gattc_conn_cb_deregister(void); + +uint8_t bt_mesh_gattc_get_free_conn_count(void); + +uint16_t bt_mesh_gattc_get_service_uuid(struct bt_mesh_conn *conn); + +int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, uint16_t service_uuid); + +void bt_gattc_conn_close(struct bt_mesh_conn *conn); + +void bt_mesh_gattc_exchange_mtu(uint8_t index); + +uint16_t bt_mesh_gattc_get_mtu_info(struct bt_mesh_conn *conn); + +int bt_mesh_gattc_write_no_rsp(struct bt_mesh_conn *conn, + const struct bt_mesh_gatt_attr *attr, + const void *data, uint16_t len); + +void bt_mesh_gattc_disconnect(struct bt_mesh_conn *conn); + +struct bt_mesh_conn *bt_mesh_conn_ref(struct bt_mesh_conn *conn); + +void bt_mesh_conn_unref(struct bt_mesh_conn *conn); + +void bt_mesh_gatt_init(void); +void bt_mesh_gatt_deinit(void); + +void bt_mesh_adapt_init(void); + +void bt_mesh_set_private_key(const uint8_t pri_key[32]); + +const uint8_t *bt_mesh_pub_key_get(void); + +bool bt_mesh_check_public_key(const uint8_t key[64]); + +int bt_mesh_dh_key_gen(const uint8_t remote_pk[64], bt_mesh_dh_key_cb_t cb, const uint8_t idx); + +int bt_mesh_encrypt_le(const uint8_t key[16], const uint8_t plaintext[16], + uint8_t enc_data[16]); + +int bt_mesh_encrypt_be(const uint8_t key[16], const uint8_t plaintext[16], + uint8_t enc_data[16]); + +enum { + BLE_MESH_EXCEP_LIST_ADD = 0, + BLE_MESH_EXCEP_LIST_REMOVE, + BLE_MESH_EXCEP_LIST_CLEAN, +}; + +enum { + BLE_MESH_EXCEP_INFO_ADV_ADDR = 0, + BLE_MESH_EXCEP_INFO_MESH_LINK_ID, + BLE_MESH_EXCEP_INFO_MESH_BEACON, + BLE_MESH_EXCEP_INFO_MESH_PROV_ADV, + BLE_MESH_EXCEP_INFO_MESH_PROXY_ADV, +}; + +enum { + BLE_MESH_EXCEP_CLEAN_ADDR_LIST = BIT(0), + BLE_MESH_EXCEP_CLEAN_MESH_LINK_ID_LIST = BIT(1), + BLE_MESH_EXCEP_CLEAN_MESH_BEACON_LIST = BIT(2), + BLE_MESH_EXCEP_CLEAN_MESH_PROV_ADV_LIST = BIT(3), + BLE_MESH_EXCEP_CLEAN_MESH_PROXY_ADV_LIST = BIT(4), + BLE_MESH_EXCEP_CLEAN_ALL_LIST = 0xFFFF, +}; + +int bt_mesh_update_exceptional_list(uint8_t sub_code, uint8_t type, void *info); + +#ifdef __cplusplus +} +#endif + +#endif /* _BLE_MESH_BEARER_ADAPT_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/include/mesh_hci.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/include/mesh_hci.h new file mode 100644 index 00000000000..860d575c2bd --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/include/mesh_hci.h @@ -0,0 +1,133 @@ +/* + * SPDX-FileCopyrightText: 2015-2016 Intel Corporation + * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#ifndef _BLE_MESH_HCI_H_ +#define _BLE_MESH_HCI_H_ + +#include "mesh_atomic.h" +#include "mesh_bearer_adapt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Porting form zephyr/subsys/bluetooth/host/hci_core.h */ + +#define BLE_MESH_LMP_FEAT_PAGES_COUNT 1 + +/* bt_mesh_dev flags: the flags defined here represent BT controller state */ +enum { + BLE_MESH_DEV_ENABLE, + BLE_MESH_DEV_READY, + BLE_MESH_DEV_ID_STATIC_RANDOM, + BLE_MESH_DEV_HAS_PUB_KEY, + BLE_MESH_DEV_PUB_KEY_BUSY, + + BLE_MESH_DEV_ADVERTISING, + BLE_MESH_DEV_KEEP_ADVERTISING, + BLE_MESH_DEV_SCANNING, + BLE_MESH_DEV_EXPLICIT_SCAN, + BLE_MESH_DEV_ACTIVE_SCAN, + BLE_MESH_DEV_SCAN_FILTER_DUP, + + BLE_MESH_DEV_RPA_VALID, + + BLE_MESH_DEV_ID_PENDING, + + /* Total number of flags - must be at the end of the enum */ + BLE_MESH_DEV_NUM_FLAGS, +}; + +struct bt_mesh_dev_le { + /* LE features */ + uint8_t features[8]; + + /* LE states */ + uint64_t states; +}; + +/* State tracking for the local Bluetooth controller */ +struct bt_mesh_dev { + /* Flags indicate which functionality is enabled */ + BLE_MESH_ATOMIC_DEFINE(flags, BLE_MESH_DEV_NUM_FLAGS); + + /* Controller version & manufacturer information */ + uint8_t hci_version; + uint8_t lmp_version; + uint16_t hci_revision; + uint16_t lmp_subversion; + uint16_t manufacturer; + + /* LMP features (pages 0, 1, 2) */ + uint8_t features[BLE_MESH_LMP_FEAT_PAGES_COUNT][8]; + + /* LE controller specific features */ + struct bt_mesh_dev_le le; +}; + +/*Porting from zephyr/subsys/bluetooth/host/hci_core.h */ +/* HCI version from Assigned Numbers */ +#define BLE_MESH_HCI_VERSION_1_0B 0 +#define BLE_MESH_HCI_VERSION_1_1 1 +#define BLE_MESH_HCI_VERSION_1_2 2 +#define BLE_MESH_HCI_VERSION_2_0 3 +#define BLE_MESH_HCI_VERSION_2_1 4 +#define BLE_MESH_HCI_VERSION_3_0 5 +#define BLE_MESH_HCI_VERSION_4_0 6 +#define BLE_MESH_HCI_VERSION_4_1 7 +#define BLE_MESH_HCI_VERSION_4_2 8 +#define BLE_MESH_HCI_VERSION_5_0 9 + +/* OpCode Group Fields */ +#define BLE_MESH_OGF_LINK_CTRL 0x01 +#define BLE_MESH_OGF_BASEBAND 0x03 +#define BLE_MESH_OGF_INFO 0x04 +#define BLE_MESH_OGF_STATUS 0x05 +#define BLE_MESH_OGF_LE 0x08 +#define BLE_MESH_OGF_VS 0x3f + +/* Construct OpCode from OGF and OCF */ +#define BLE_MESH_OP(ogf, ocf) ((ocf) | ((ogf) << 10)) + +/* Obtain OGF from OpCode */ +#define BLE_MESH_OGF(opcode) (((opcode) >> 10) & BIT_MASK(6)) + +/* Obtain OCF from OpCode */ +#define BLE_MESH_OCF(opcode) ((opcode) & BIT_MASK(10)) + +#define BLE_MESH_HCI_OP_SET_ADV_PARAM BLE_MESH_OP(BLE_MESH_OGF_LE, 0x0006) +struct bt_mesh_hci_cp_set_adv_param { + uint16_t min_interval; + uint16_t max_interval; + uint8_t type; + uint8_t own_addr_type; + bt_mesh_addr_t direct_addr; + uint8_t channel_map; + uint8_t filter_policy; +} __packed; + +#define BLE_MESH_HCI_OP_SET_ADV_DATA BLE_MESH_OP(BLE_MESH_OGF_LE, 0x0008) +struct bt_mesh_hci_cp_set_adv_data { + uint8_t len; + uint8_t data[31]; +} __packed; + +#define BLE_MESH_HCI_OP_SET_SCAN_RSP_DATA BLE_MESH_OP(BLE_MESH_OGF_LE, 0x0009) +struct bt_mesh_hci_cp_set_scan_rsp_data { + uint8_t len; + uint8_t data[31]; +} __packed; + +/* Added by Espressif */ +extern struct bt_mesh_dev bt_mesh_dev; + +void bt_mesh_hci_init(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _BLE_MESH_HCI_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/include/mesh_main.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/include/mesh_main.h new file mode 100644 index 00000000000..ff41994a8e7 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/include/mesh_main.h @@ -0,0 +1,635 @@ +/** @file + * @brief Bluetooth Mesh Profile APIs. + */ + +/* + * SPDX-FileCopyrightText: 2017 Intel Corporation + * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#ifndef _BLE_MESH_MAIN_H_ +#define _BLE_MESH_MAIN_H_ + +#include "mesh_access.h" + +/** + * @brief Bluetooth Mesh Provisioning + * @defgroup bt_mesh_prov Bluetooth Mesh Provisioning + * @ingroup bt_mesh + * @{ + */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + BLE_MESH_NO_OUTPUT = 0, + BLE_MESH_BLINK = BIT(0), + BLE_MESH_BEEP = BIT(1), + BLE_MESH_VIBRATE = BIT(2), + BLE_MESH_DISPLAY_NUMBER = BIT(3), + BLE_MESH_DISPLAY_STRING = BIT(4), +} bt_mesh_output_action_t; + +typedef enum { + BLE_MESH_NO_INPUT = 0, + BLE_MESH_PUSH = BIT(0), + BLE_MESH_TWIST = BIT(1), + BLE_MESH_ENTER_NUMBER = BIT(2), + BLE_MESH_ENTER_STRING = BIT(3), +} bt_mesh_input_action_t; + +typedef enum { + BLE_MESH_PROV_ADV = BIT(0), + BLE_MESH_PROV_GATT = BIT(1), +} bt_mesh_prov_bearer_t; + +typedef enum { + BLE_MESH_PROV_OOB_OTHER = BIT(0), + BLE_MESH_PROV_OOB_URI = BIT(1), + BLE_MESH_PROV_OOB_2D_CODE = BIT(2), + BLE_MESH_PROV_OOB_BAR_CODE = BIT(3), + BLE_MESH_PROV_OOB_NFC = BIT(4), + BLE_MESH_PROV_OOB_NUMBER = BIT(5), + BLE_MESH_PROV_OOB_STRING = BIT(6), + /* 7 - 10 are reserved */ + BLE_MESH_PROV_OOB_ON_BOX = BIT(11), + BLE_MESH_PROV_OOB_IN_BOX = BIT(12), + BLE_MESH_PROV_OOB_ON_PAPER = BIT(13), + BLE_MESH_PROV_OOB_IN_MANUAL = BIT(14), + BLE_MESH_PROV_OOB_ON_DEV = BIT(15), +} bt_mesh_prov_oob_info_t; + +#define BLE_MESH_PROV_STATIC_OOB_MAX_LEN 16 +#define BLE_MESH_PROV_OUTPUT_OOB_MAX_LEN 8 +#define BLE_MESH_PROV_INPUT_OOB_MAX_LEN 8 + +/** Provisioning properties & capabilities. */ +struct bt_mesh_prov { +#if CONFIG_BLE_MESH_NODE + /** The UUID that's used when advertising as unprovisioned */ + const uint8_t *uuid; + + /** Optional URI. This will be advertised separately from the + * unprovisioned beacon, however the unprovisioned beacon will + * contain a hash of it so the two can be associated by the + * provisioner. + */ + const char *uri; + + /** Out of Band information field. */ + bt_mesh_prov_oob_info_t oob_info; + + /** Flag indicates whether unprovisioned devices support OOB public key */ + bool oob_pub_key; + + /** @brief Set device OOB public key. + * + * This callback notifies the application to + * set OOB public key & private key pair. + */ + void (*oob_pub_key_cb)(void); + + /** Static OOB value */ + const uint8_t *static_val; + /** Static OOB value length */ + uint8_t static_val_len; + + /** Maximum size of Output OOB supported */ + uint8_t output_size; + /** Supported Output OOB Actions */ + uint16_t output_actions; + + /* Maximum size of Input OOB supported */ + uint8_t input_size; + /** Supported Input OOB Actions */ + uint16_t input_actions; + + /** @brief Output of a number is requested. + * + * This callback notifies the application to + * output the given number using the given action. + * + * @param act Action for outputting the number. + * @param num Number to be out-put. + * + * @return Zero on success or negative error code otherwise + */ + int (*output_number)(bt_mesh_output_action_t act, uint32_t num); + + /** @brief Output of a string is requested. + * + * This callback notifies the application to + * display the given string to the user. + * + * @param str String to be displayed. + * + * @return Zero on success or negative error code otherwise + */ + int (*output_string)(const char *str); + + /** @brief Input is requested. + * + * This callback notifies the application to request + * input from the user using the given action. The + * requested input will either be a string or a number, and + * the application needs to consequently call the + * bt_mesh_input_string() or bt_mesh_input_number() functions + * once the data has been acquired from the user. + * + * @param act Action for inputting data. + * @param num Maximum size of the in-put data. + * + * @return Zero on success or negative error code otherwise + */ + int (*input)(bt_mesh_input_action_t act, uint8_t size); + + /** @brief Provisioning link has been opened. + * + * This callback notifies the application that a provisioning + * link has been opened on the given provisioning bearer. + * + * @param bearer Provisioning bearer. + */ + void (*link_open)(bt_mesh_prov_bearer_t bearer); + + /** @brief Provisioning link has been closed. + * + * This callback notifies the application that a provisioning + * link has been closed on the given provisioning bearer. + * + * @param bearer Provisioning bearer. + */ + void (*link_close)(bt_mesh_prov_bearer_t bearer); + + /** @brief Provisioning is complete. + * + * This callback notifies the application that provisioning has + * been successfully completed, and that the local node has been + * assigned the specified NetKeyIndex and primary element address. + * + * @param net_idx NetKeyIndex given during provisioning. + * @param net_key NetKey given during provisioning. + * @param addr Primary element address. + * @param flags Key Refresh & IV Update flags + * @param iv_index IV Index. + */ + void (*complete)(uint16_t net_idx, const uint8_t net_key[16], uint16_t addr, uint8_t flags, uint32_t iv_index); + + /** @brief Node has been reset. + * + * This callback notifies the application that the local node + * has been reset and needs to be reprovisioned. The node will + * not automatically advertise as unprovisioned, rather the + * bt_mesh_prov_enable() API needs to be called to enable + * unprovisioned advertising on one or more provisioning bearers. + */ + void (*reset)(void); +#endif /* CONFIG_BLE_MESH_NODE */ + +#if CONFIG_BLE_MESH_PROVISIONER + /* Provisioner device uuid */ + const uint8_t *prov_uuid; + + /* + * Primary element address of the provisioner. + * No need to initialize it for fast provisioning. + */ + const uint16_t prov_unicast_addr; + + /* + * Starting unicast address going to assigned. + * No need to initialize it for fast provisioning. + */ + uint16_t prov_start_address; + + /* Attention timer contained in Provisioning Invite */ + uint8_t prov_attention; + + /* Provisioner provisioning Algorithm */ + uint8_t prov_algorithm; + + /* Provisioner public key oob */ + uint8_t prov_pub_key_oob; + + /** @brief Input is requested. + * + * This callback notifies the application that it should + * read device's public key with OOB + * + * @param link_idx: The provisioning link index + * + * @return Zero on success or negative error code otherwise + */ + int (*prov_pub_key_oob_cb)(uint8_t link_idx); + + /* Provisioner static oob value */ + uint8_t *prov_static_oob_val; + + /* Provisioner static oob value length */ + uint8_t prov_static_oob_len; + + /** @brief Provisioner input a number read from device output + * + * This callback notifies the application that it should + * input the number given by the device. + * + * @param method: The OOB authentication method + * @param act: The output action of the device + * @param size: The output size of the device + * @param link_idx: The provisioning link index + * + * @return Zero on success or negative error code otherwise + */ + int (*prov_input_num)(uint8_t method, bt_mesh_output_action_t act, uint8_t size, uint8_t link_idx); + + /** @brief Provisioner output a number to the device + * + * This callback notifies the application that it should + * output the number to the device. + * + * @param method: The OOB authentication method + * @param act: The input action of the device + * @param data: The input number/string of the device + * @param size: The input size of the device + * @param link_idx: The provisioning link index + * + * @return Zero on success or negative error code otherwise + */ + int (*prov_output_num)(uint8_t method, bt_mesh_input_action_t act, void *data, uint8_t size, uint8_t link_idx); + + /* + * Key refresh and IV update flag. + * No need to initialize it for fast provisioning. + */ + uint8_t flags; + + /* + * IV index. No need to initialize it for fast provisioning. + */ + uint32_t iv_index; + + /** @brief Provisioner has opened a provisioning link. + * + * This callback notifies the application that a provisioning + * link has been opened on the given provisioning bearer. + * + * @param bearer Provisioning bearer. + */ + void (*prov_link_open)(bt_mesh_prov_bearer_t bearer); + + /** @brief Provisioner has closed a provisioning link. + * + * This callback notifies the application that a provisioning + * link has been closed on the given provisioning bearer. + * + * @param bearer Provisioning bearer. + * @param reason Provisioning link close reason(disconnect reason) + */ + void (*prov_link_close)(bt_mesh_prov_bearer_t bearer, uint8_t reason); + + /** @brief Provision one device is complete. + * + * This callback notifies the application that provisioner has + * successfully provisioned a device, and the node has been assigned + * the specified NetKeyIndex and primary element address. + * + * @param node_idx Node index within the node(provisioned device) queue. + * @param device_uuid Provisioned device uuid pointer. + * @param unicast_addr Provisioned device assigned unicast address. + * @param element_num Provisioned device element number. + * @param netkey_idx Provisioned device assigned netkey index. + */ + void (*prov_complete)(uint16_t node_idx, const uint8_t device_uuid[16], + uint16_t unicast_addr, uint8_t element_num, + uint16_t netkey_idx); +#endif /* CONFIG_BLE_MESH_PROVISIONER */ +}; + +enum ble_mesh_role { + NODE = 0, + PROVISIONER, + FAST_PROV, + ROLE_NVAL, +}; + +/* The following APIs are for BLE Mesh Node */ + +/** @brief Provide provisioning input OOB string. + * + * This is intended to be called after the bt_mesh_prov input callback + * has been called with BLE_MESH_ENTER_STRING as the action. + * + * @param str String. + * + * @return Zero on success or (negative) error code otherwise. + */ +int bt_mesh_input_string(const char *str); + +/** @brief Provide provisioning input OOB number. + * + * This is intended to be called after the bt_mesh_prov input callback + * has been called with BLE_MESH_ENTER_NUMBER as the action. + * + * @param num Number. + * + * @return Zero on success or (negative) error code otherwise. + */ +int bt_mesh_input_number(uint32_t num); + +/** @brief Enable specific provisioning bearers + * + * Enable one or more provisioning bearers. + * + * @param Bit-wise OR of provisioning bearers. + * + * @return Zero on success or (negative) error code otherwise. + */ +int bt_mesh_prov_enable(bt_mesh_prov_bearer_t bearers); + +/** @brief Disable specific provisioning bearers + * + * Disable one or more provisioning bearers. + * + * @param Bit-wise OR of provisioning bearers. + * + * @return Zero on success or (negative) error code otherwise. + */ +int bt_mesh_prov_disable(bt_mesh_prov_bearer_t bearers); + +/* The following APIs are for BLE Mesh Provisioner */ + +/** @brief Provide provisioning input OOB string. + * + * This is intended to be called after the bt_mesh_prov input callback + * has been called with BLE_MESH_ENTER_STRING as the action. + * + * @param str String. + * + * @return Zero on success or (negative) error code otherwise. + */ +int bt_mesh_prov_input_string(const char *str); + +/** @brief Provide provisioning input OOB number. + * + * This is intended to be called after the bt_mesh_prov input callback + * has been called with BLE_MESH_ENTER_NUMBER as the action. + * + * @param num Number. + * + * @return Zero on success or (negative) error code otherwise. + */ +int bt_mesh_prov_input_number(uint32_t num); + +/** @brief Enable specific provisioning bearers + * + * Enable one or more provisioning bearers. + * + * @param bearers Bit-wise OR of provisioning bearers. + * + * @return Zero on success or (negative) error code otherwise. + */ +int bt_mesh_provisioner_enable(bt_mesh_prov_bearer_t bearers); + +/** @brief Disable specific provisioning bearers + * + * Disable one or more provisioning bearers. + * + * @param bearers Bit-wise OR of provisioning bearers. + * + * @return Zero on success or (negative) error code otherwise. + */ +int bt_mesh_provisioner_disable(bt_mesh_prov_bearer_t bearers); + +/** + * @} + */ + +/** + * @brief Bluetooth Mesh + * @defgroup bt_mesh Bluetooth Mesh + * @ingroup bluetooth + * @{ + */ + +/* Primary Network Key index */ +#define BLE_MESH_NET_PRIMARY 0x000 + +#define BLE_MESH_RELAY_DISABLED 0x00 +#define BLE_MESH_RELAY_ENABLED 0x01 +#define BLE_MESH_RELAY_NOT_SUPPORTED 0x02 + +#define BLE_MESH_BEACON_DISABLED 0x00 +#define BLE_MESH_BEACON_ENABLED 0x01 + +#define BLE_MESH_GATT_PROXY_DISABLED 0x00 +#define BLE_MESH_GATT_PROXY_ENABLED 0x01 +#define BLE_MESH_GATT_PROXY_NOT_SUPPORTED 0x02 + +#define BLE_MESH_FRIEND_DISABLED 0x00 +#define BLE_MESH_FRIEND_ENABLED 0x01 +#define BLE_MESH_FRIEND_NOT_SUPPORTED 0x02 + +#define BLE_MESH_NODE_IDENTITY_STOPPED 0x00 +#define BLE_MESH_NODE_IDENTITY_RUNNING 0x01 +#define BLE_MESH_NODE_IDENTITY_NOT_SUPPORTED 0x02 + +/* Features */ +#define BLE_MESH_FEAT_RELAY BIT(0) +#define BLE_MESH_FEAT_PROXY BIT(1) +#define BLE_MESH_FEAT_FRIEND BIT(2) +#define BLE_MESH_FEAT_LOW_POWER BIT(3) +#define BLE_MESH_FEAT_SUPPORTED (BLE_MESH_FEAT_RELAY | \ + BLE_MESH_FEAT_PROXY | \ + BLE_MESH_FEAT_FRIEND | \ + BLE_MESH_FEAT_LOW_POWER) + +/** @brief Check if the mesh stack is initialized. + * + * @return true - yes, false - no. + */ +bool bt_mesh_is_initialized(void); + +/** @brief Initialize Mesh support + * + * After calling this API, the node will not automatically advertise as + * unprovisioned, rather the bt_mesh_prov_enable() API needs to be called + * to enable unprovisioned advertising on one or more provisioning bearers. + * + * @param prov Node provisioning information. + * @param comp Node Composition. + * + * @return Zero on success or (negative) error code otherwise. + */ +int bt_mesh_init(const struct bt_mesh_prov *prov, + const struct bt_mesh_comp *comp); + +/* BLE Mesh deinit parameters */ +struct bt_mesh_deinit_param { + bool erase; /* Indicate if erasing flash when deinit mesh stack */ +}; + +/** @brief De-initialize Mesh support + * + * @param param BLE Mesh deinit parameters. + * + * @return Zero on success or (negative) error code otherwise. + */ +int bt_mesh_deinit(struct bt_mesh_deinit_param *param); + +/** @brief Reset the state of the local Mesh node. + * + * Resets the state of the node, which means that it needs to be + * reprovisioned to become an active node in a Mesh network again. + * + * After calling this API, the node will not automatically advertise as + * unprovisioned, rather the bt_mesh_prov_enable() API needs to be called + * to enable unprovisioned advertising on one or more provisioning bearers. + * + */ +void bt_mesh_node_reset(void); + +/** @brief Suspend the Mesh network temporarily. + * + * This API can be used for power saving purposes, but the user should be + * aware that leaving the local node suspended for a long period of time + * may cause it to become permanently disconnected from the Mesh network. + * If at all possible, the Friendship feature should be used instead, to + * make the node into a Low Power Node. + * + * @return 0 on success, or (negative) error code on failure. + */ +int bt_mesh_suspend(void); + +/** @brief Resume a suspended Mesh network. + * + * This API resumes the local node, after it has been suspended using the + * bt_mesh_suspend() API. + * + * @return 0 on success, or (negative) error code on failure. + */ +int bt_mesh_resume(void); + +/** @brief Provision the local Mesh Node. + * + * This API should normally not be used directly by the application. The + * only exception is for testing purposes where manual provisioning is + * desired without an actual external provisioner. + * + * @param net_key Network Key + * @param net_idx Network Key Index + * @param flags Provisioning Flags + * @param iv_index IV Index + * @param addr Primary element address + * @param dev_key Device Key + * + * @return Zero on success or (negative) error code otherwise. + */ +int bt_mesh_provision(const uint8_t net_key[16], uint16_t net_idx, + uint8_t flags, uint32_t iv_index, uint16_t addr, + const uint8_t dev_key[16]); + +/** @brief Check if the device is an unprovisioned device + * and will act as a node once provisioned. + * + * @return true - yes, false - no. + */ +bool bt_mesh_is_node(void); + +/** @brief Check if the local node has been provisioned. + * + * This API can be used to check if the local node has been provisioned + * or not. It can e.g. be helpful to determine if there was a stored + * network in flash, i.e. if the network was restored after calling + * settings_load(). + * + * @return True if the node is provisioned. False otherwise. + */ +bool bt_mesh_is_provisioned(void); + +/** @brief Check if the device is a Provisioner. + * + * @return true - yes, false - no. + */ +bool bt_mesh_is_provisioner(void); + +/** @brief Check if the Provisioner is enabled + * + * @return true - enabled, false - disabled. + */ +bool bt_mesh_is_provisioner_en(void); + +/** @brief Toggle the IV Update test mode + * + * This API is only available if the IV Update test mode has been enabled + * in Kconfig. It is needed for passing most of the IV Update qualification + * test cases. + * + * @param enable true to enable IV Update test mode, false to disable it. + */ +void bt_mesh_iv_update_test(bool enable); + +/** @brief Toggle the IV Update state + * + * This API is only available if the IV Update test mode has been enabled + * in Kconfig. It is needed for passing most of the IV Update qualification + * test cases. + * + * @return true if IV Update In Progress state was entered, false otherwise. + */ +bool bt_mesh_iv_update(void); + +/** @brief Toggle the Low Power feature of the local device + * + * Enables or disables the Low Power feature of the local device. This is + * exposed as a run-time feature, since the device might want to change + * this e.g. based on being plugged into a stable power source or running + * from a battery power source. + * + * @param enable true to enable LPN functionality, false to disable it. + * @param force when disable LPN functionality, use this flag to indicate + * whether directly clear corresponding information or sending + * friend clear to disable it. + * + * @return Zero on success or (negative) error code otherwise. + */ +int bt_mesh_lpn_set(bool enable, bool force); + +/** @brief Send out a Friend Poll message. + * + * Send a Friend Poll message to the Friend of this node. If there is no + * established Friendship the function will return an error. + * + * @return Zero on success or (negative) error code otherwise. + */ +int bt_mesh_lpn_poll(void); + +/** @brief Register a callback for Friendship changes. + * + * Registers a callback that will be called whenever Friendship gets + * established or is lost. + * + * @param cb Function to call when the Friendship status changes. + */ +void bt_mesh_lpn_set_cb(void (*cb)(uint16_t friend_addr, bool established)); + +/** @brief Register a callback for Friendship changes of friend node. + * + * Registers a callback that will be called whenever Friendship gets + * established or is terminated. + * + * @param cb Function to call when the Friendship status of friend node changes. + */ +void bt_mesh_friend_set_cb(void (*cb)(bool establish, uint16_t lpn_addr, uint8_t reason)); + +#ifdef __cplusplus +} +#endif + +/** + * @} + */ + +#endif /* _BLE_MESH_MAIN_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/include/mesh_proxy.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/include/mesh_proxy.h new file mode 100644 index 00000000000..3bdf5c405c0 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/include/mesh_proxy.h @@ -0,0 +1,45 @@ +/** @file + * @brief Bluetooth Mesh Proxy APIs. + */ + +/* + * SPDX-FileCopyrightText: 2017 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _BLE_MESH_PROXY_H_ +#define _BLE_MESH_PROXY_H_ + +#include +/** + * @brief Bluetooth Mesh Proxy + * @defgroup bt_mesh_proxy Bluetooth Mesh Proxy + * @ingroup bt_mesh + * @{ + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Enable advertising with Node Identity. + * + * This API requires that GATT Proxy support has been enabled. Once called + * each subnet will start advertising using Node Identity for the next + * 60 seconds. + * + * @return 0 on success, or (negative) error code on failure. + */ +int bt_mesh_proxy_identity_enable(void); + +#ifdef __cplusplus +} +#endif + +/** + * @} + */ + +#endif /* _BLE_MESH_PROXY_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/include/mesh_uuid.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/include/mesh_uuid.h new file mode 100644 index 00000000000..b3d207cbe88 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/include/mesh_uuid.h @@ -0,0 +1,530 @@ +/** @file + * @brief Bluetooth UUID handling + */ + +/* + * SPDX-FileCopyrightText: 2015-2016 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ +#ifndef _BLE_MESH_UUID_H_ +#define _BLE_MESH_UUID_H_ + +/** + * @brief UUIDs + * @defgroup bt_uuid UUIDs + * @ingroup bluetooth + * @{ + */ + +#include "mesh_util.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** @brief Bluetooth UUID types */ +enum { + BLE_MESH_UUID_TYPE_16, + BLE_MESH_UUID_TYPE_32, + BLE_MESH_UUID_TYPE_128, +}; + +/** @brief This is a 'tentative' type and should be used as a pointer only */ +struct bt_mesh_uuid { + uint8_t type; +}; + +struct bt_mesh_uuid_16 { + struct bt_mesh_uuid uuid; + uint16_t val; +}; + +struct bt_mesh_uuid_32 { + struct bt_mesh_uuid uuid; + uint32_t val; +}; + +struct bt_mesh_uuid_128 { + struct bt_mesh_uuid uuid; + uint8_t val[16]; +}; + +#define BLE_MESH_UUID_INIT_16(value) \ +{ \ + .uuid.type = BLE_MESH_UUID_TYPE_16, \ + .val = (value), \ +} + +#define BLE_MESH_UUID_INIT_32(value) \ +{ \ + .uuid.type = BLE_MESH_UUID_TYPE_32, \ + .val = (value), \ +} + +#define BLE_MESH_UUID_INIT_128(value...) \ +{ \ + .uuid.type = BLE_MESH_UUID_TYPE_128, \ + .val = { value }, \ +} + +#define BLE_MESH_UUID_DECLARE_16(value) \ + ((struct bt_mesh_uuid *) (&(struct bt_mesh_uuid_16) BLE_MESH_UUID_INIT_16(value))) + +#define BLE_MESH_UUID_DECLARE_32(value) \ + ((struct bt_mesh_uuid *) (&(struct bt_mesh_uuid_32) BLE_MESH_UUID_INIT_32(value))) + +#define BLE_MESH_UUID_DECLARE_128(value...) \ + ((struct bt_mesh_uuid *) (&(struct bt_mesh_uuid_128) BLE_MESH_UUID_INIT_128(value))) + +#define BLE_MESH_UUID_16(__u) CONTAINER_OF(__u, struct bt_mesh_uuid_16, uuid) +#define BLE_MESH_UUID_32(__u) CONTAINER_OF(__u, struct bt_mesh_uuid_32, uuid) +#define BLE_MESH_UUID_128(__u) CONTAINER_OF(__u, struct bt_mesh_uuid_128, uuid) + +/** @def BLE_MESH_UUID_GAP + * @brief Generic Access + */ +#define BLE_MESH_UUID_GAP BLE_MESH_UUID_DECLARE_16(0x1800) +#define BLE_MESH_UUID_GAP_VAL 0x1800 +/** @def BLE_MESH_UUID_GATT + * @brief Generic Attribute + */ +#define BLE_MESH_UUID_GATT BLE_MESH_UUID_DECLARE_16(0x1801) +#define BLE_MESH_UUID_GATT_VAL 0x1801 +/** @def BLE_MESH_UUID_CTS + * @brief Current Time Service + */ +#define BLE_MESH_UUID_CTS BLE_MESH_UUID_DECLARE_16(0x1805) +#define BLE_MESH_UUID_CTS_VAL 0x1805 +/** @def BLE_MESH_UUID_DIS + * @brief Device Information Service + */ +#define BLE_MESH_UUID_DIS BLE_MESH_UUID_DECLARE_16(0x180a) +#define BLE_MESH_UUID_DIS_VAL 0x180a +/** @def BLE_MESH_UUID_HRS + * @brief Heart Rate Service + */ +#define BLE_MESH_UUID_HRS BLE_MESH_UUID_DECLARE_16(0x180d) +#define BLE_MESH_UUID_HRS_VAL 0x180d +/** @def BLE_MESH_UUID_BAS + * @brief Battery Service + */ +#define BLE_MESH_UUID_BAS BLE_MESH_UUID_DECLARE_16(0x180f) +#define BLE_MESH_UUID_BAS_VAL 0x180f +/** @def BLE_MESH_UUID_HIDS + * @brief HID Service + */ +#define BLE_MESH_UUID_HIDS BLE_MESH_UUID_DECLARE_16(0x1812) +#define BLE_MESH_UUID_HIDS_VAL 0x1812 +/** @def BLE_MESH_UUID_CSC + * @brief Cycling Speed and Cadence Service + */ +#define BLE_MESH_UUID_CSC BLE_MESH_UUID_DECLARE_16(0x1816) +#define BLE_MESH_UUID_CSC_VAL 0x1816 +/** @def BLE_MESH_UUID_ESS + * @brief Environmental Sensing Service + */ +#define BLE_MESH_UUID_ESS BLE_MESH_UUID_DECLARE_16(0x181a) +#define BLE_MESH_UUID_ESS_VAL 0x181a +/** @def BLE_MESH_UUID_IPSS + * @brief IP Support Service + */ +#define BLE_MESH_UUID_IPSS BLE_MESH_UUID_DECLARE_16(0x1820) +#define BLE_MESH_UUID_IPSS_VAL 0x1820 +/** @def BLE_MESH_UUID_MESH_PROV + * @brief Mesh Provisioning Service + */ +#define BLE_MESH_UUID_MESH_PROV BLE_MESH_UUID_DECLARE_16(0x1827) +#define BLE_MESH_UUID_MESH_PROV_VAL 0x1827 +/** @def BLE_MESH_UUID_MESH_PROXY + * @brief Mesh Proxy Service + */ +#define BLE_MESH_UUID_MESH_PROXY BLE_MESH_UUID_DECLARE_16(0x1828) +#define BLE_MESH_UUID_MESH_PROXY_VAL 0x1828 +/** @def BLE_MESH_UUID_GATT_PRIMARY + * @brief GATT Primary Service + */ +#define BLE_MESH_UUID_GATT_PRIMARY BLE_MESH_UUID_DECLARE_16(0x2800) +#define BLE_MESH_UUID_GATT_PRIMARY_VAL 0x2800 +/** @def BLE_MESH_UUID_GATT_SECONDARY + * @brief GATT Secondary Service + */ +#define BLE_MESH_UUID_GATT_SECONDARY BLE_MESH_UUID_DECLARE_16(0x2801) +#define BLE_MESH_UUID_GATT_SECONDARY_VAL 0x2801 +/** @def BLE_MESH_UUID_GATT_INCLUDE + * @brief GATT Include Service + */ +#define BLE_MESH_UUID_GATT_INCLUDE BLE_MESH_UUID_DECLARE_16(0x2802) +#define BLE_MESH_UUID_GATT_INCLUDE_VAL 0x2802 +/** @def BLE_MESH_UUID_GATT_CHRC + * @brief GATT Characteristic + */ +#define BLE_MESH_UUID_GATT_CHRC BLE_MESH_UUID_DECLARE_16(0x2803) +#define BLE_MESH_UUID_GATT_CHRC_VAL 0x2803 +/** @def BLE_MESH_UUID_GATT_CEP + * @brief GATT Characteristic Extended Properties + */ +#define BLE_MESH_UUID_GATT_CEP BLE_MESH_UUID_DECLARE_16(0x2900) +#define BLE_MESH_UUID_GATT_CEP_VAL 0x2900 +/** @def BLE_MESH_UUID_GATT_CUD + * @brief GATT Characteristic User Description + */ +#define BLE_MESH_UUID_GATT_CUD BLE_MESH_UUID_DECLARE_16(0x2901) +#define BLE_MESH_UUID_GATT_CUD_VAL 0x2901 +/** @def BLE_MESH_UUID_GATT_CCC + * @brief GATT Client Characteristic Configuration + */ +#define BLE_MESH_UUID_GATT_CCC BLE_MESH_UUID_DECLARE_16(0x2902) +#define BLE_MESH_UUID_GATT_CCC_VAL 0x2902 +/** @def BLE_MESH_UUID_GATT_SCC + * @brief GATT Server Characteristic Configuration + */ +#define BLE_MESH_UUID_GATT_SCC BLE_MESH_UUID_DECLARE_16(0x2903) +#define BLE_MESH_UUID_GATT_SCC_VAL 0x2903 +/** @def BLE_MESH_UUID_GATT_CPF + * @brief GATT Characteristic Presentation Format + */ +#define BLE_MESH_UUID_GATT_CPF BLE_MESH_UUID_DECLARE_16(0x2904) +#define BLE_MESH_UUID_GATT_CPF_VAL 0x2904 +/** @def BLE_MESH_UUID_VALID_RANGE + * @brief Valid Range Descriptor + */ +#define BLE_MESH_UUID_VALID_RANGE BLE_MESH_UUID_DECLARE_16(0x2906) +#define BLE_MESH_UUID_VALID_RANGE_VAL 0x2906 +/** @def BLE_MESH_UUID_HIDS_EXT_REPORT + * @brief HID External Report Descriptor + */ +#define BLE_MESH_UUID_HIDS_EXT_REPORT BLE_MESH_UUID_DECLARE_16(0x2907) +#define BLE_MESH_UUID_HIDS_EXT_REPORT_VAL 0x2907 +/** @def BLE_MESH_UUID_HIDS_REPORT_REF + * @brief HID Report Reference Descriptor + */ +#define BLE_MESH_UUID_HIDS_REPORT_REF BLE_MESH_UUID_DECLARE_16(0x2908) +#define BLE_MESH_UUID_HIDS_REPORT_REF_VAL 0x2908 +/** @def BLE_MESH_UUID_ES_CONFIGURATION + * @brief Environmental Sensing Configuration Descriptor + */ +#define BLE_MESH_UUID_ES_CONFIGURATION BLE_MESH_UUID_DECLARE_16(0x290b) +#define BLE_MESH_UUID_ES_CONFIGURATION_VAL 0x290b +/** @def BLE_MESH_UUID_ES_MEASUREMENT + * @brief Environmental Sensing Measurement Descriptor + */ +#define BLE_MESH_UUID_ES_MEASUREMENT BLE_MESH_UUID_DECLARE_16(0x290c) +#define BLE_MESH_UUID_ES_MEASUREMENT_VAL 0x290c +/** @def BLE_MESH_UUID_ES_TRIGGER_SETTING + * @brief Environmental Sensing Trigger Setting Descriptor + */ +#define BLE_MESH_UUID_ES_TRIGGER_SETTING BLE_MESH_UUID_DECLARE_16(0x290d) +#define BLE_MESH_UUID_ES_TRIGGER_SETTING_VAL 0x290d +/** @def BLE_MESH_UUID_GAP_DEVICE_NAME + * @brief GAP Characteristic Device Name + */ +#define BLE_MESH_UUID_GAP_DEVICE_NAME BLE_MESH_UUID_DECLARE_16(0x2a00) +#define BLE_MESH_UUID_GAP_DEVICE_NAME_VAL 0x2a00 +/** @def BLE_MESH_UUID_GAP_APPEARANCE + * @brief GAP Characteristic Appearance + */ +#define BLE_MESH_UUID_GAP_APPEARANCE BLE_MESH_UUID_DECLARE_16(0x2a01) +#define BLE_MESH_UUID_GAP_APPEARANCE_VAL 0x2a01 +/** @def BLE_MESH_UUID_GAP_PPCP + * @brief GAP Characteristic Peripheral Preferred Connection Parameters + */ +#define BLE_MESH_UUID_GAP_PPCP BLE_MESH_UUID_DECLARE_16(0x2a04) +#define BLE_MESH_UUID_GAP_PPCP_VAL 0x2a04 +/** @def BLE_MESH_UUID_GATT_SC + * @brief GATT Characteristic Service Changed + */ +#define BLE_MESH_UUID_GATT_SC BLE_MESH_UUID_DECLARE_16(0x2a05) +#define BLE_MESH_UUID_GATT_SC_VAL 0x2a05 +/** @def BLE_MESH_UUID_BAS_BATTERY_LEVEL + * @brief BAS Characteristic Battery Level + */ +#define BLE_MESH_UUID_BAS_BATTERY_LEVEL BLE_MESH_UUID_DECLARE_16(0x2a19) +#define BLE_MESH_UUID_BAS_BATTERY_LEVEL_VAL 0x2a19 +/** @def BLE_MESH_UUID_DIS_SYSTEM_ID + * @brief DIS Characteristic System ID + */ +#define BLE_MESH_UUID_DIS_SYSTEM_ID BLE_MESH_UUID_DECLARE_16(0x2a23) +#define BLE_MESH_UUID_DIS_SYSTEM_ID_VAL 0x2a23 +/** @def BLE_MESH_UUID_DIS_MODEL_NUMBER + * @brief DIS Characteristic Model Number String + */ +#define BLE_MESH_UUID_DIS_MODEL_NUMBER BLE_MESH_UUID_DECLARE_16(0x2a24) +#define BLE_MESH_UUID_DIS_MODEL_NUMBER_VAL 0x2a24 +/** @def BLE_MESH_UUID_DIS_SERIAL_NUMBER + * @brief DIS Characteristic Serial Number String + */ +#define BLE_MESH_UUID_DIS_SERIAL_NUMBER BLE_MESH_UUID_DECLARE_16(0x2a25) +#define BLE_MESH_UUID_DIS_SERIAL_NUMBER_VAL 0x2a25 +/** @def BLE_MESH_UUID_DIS_FIRMWARE_REVISION + * @brief DIS Characteristic Firmware Revision String + */ +#define BLE_MESH_UUID_DIS_FIRMWARE_REVISION BLE_MESH_UUID_DECLARE_16(0x2a26) +#define BLE_MESH_UUID_DIS_FIRMWARE_REVISION_VAL 0x2a26 +/** @def BLE_MESH_UUID_DIS_HARDWARE_REVISION + * @brief DIS Characteristic Hardware Revision String + */ +#define BLE_MESH_UUID_DIS_HARDWARE_REVISION BLE_MESH_UUID_DECLARE_16(0x2a27) +#define BLE_MESH_UUID_DIS_HARDWARE_REVISION_VAL 0x2a27 +/** @def BLE_MESH_UUID_DIS_SOFTWARE_REVISION + * @brief DIS Characteristic Software Revision String + */ +#define BLE_MESH_UUID_DIS_SOFTWARE_REVISION BLE_MESH_UUID_DECLARE_16(0x2a28) +#define BLE_MESH_UUID_DIS_SOFTWARE_REVISION_VAL 0x2a28 +/** @def BLE_MESH_UUID_DIS_MANUFACTURER_NAME + * @brief DIS Characteristic Manufacturer Name String + */ +#define BLE_MESH_UUID_DIS_MANUFACTURER_NAME BLE_MESH_UUID_DECLARE_16(0x2a29) +#define BLE_MESH_UUID_DIS_MANUFACTURER_NAME_VAL 0x2a29 +/** @def BLE_MESH_UUID_DIS_PNP_ID + * @brief DIS Characteristic PnP ID + */ +#define BLE_MESH_UUID_DIS_PNP_ID BLE_MESH_UUID_DECLARE_16(0x2a50) +#define BLE_MESH_UUID_DIS_PNP_ID_VAL 0x2a50 +/** @def BLE_MESH_UUID_CTS_CURRENT_TIME + * @brief CTS Characteristic Current Time + */ +#define BLE_MESH_UUID_CTS_CURRENT_TIME BLE_MESH_UUID_DECLARE_16(0x2a2b) +#define BLE_MESH_UUID_CTS_CURRENT_TIME_VAL 0x2a2b +/** @def BLE_MESH_UUID_MAGN_DECLINATION + * @brief Magnetic Declination Characteristic + */ +#define BLE_MESH_UUID_MAGN_DECLINATION BLE_MESH_UUID_DECLARE_16(0x2a2c) +#define BLE_MESH_UUID_MAGN_DECLINATION_VAL 0x2a2c +/** @def BLE_MESH_UUID_HRS_MEASUREMENT + * @brief HRS Characteristic Measurement Interval + */ +#define BLE_MESH_UUID_HRS_MEASUREMENT BLE_MESH_UUID_DECLARE_16(0x2a37) +#define BLE_MESH_UUID_HRS_MEASUREMENT_VAL 0x2a37 +/** @def BLE_MESH_UUID_HRS_BODY_SENSOR + * @brief HRS Characteristic Body Sensor Location + */ +#define BLE_MESH_UUID_HRS_BODY_SENSOR BLE_MESH_UUID_DECLARE_16(0x2a38) +#define BLE_MESH_UUID_HRS_BODY_SENSOR_VAL 0x2a38 +/** @def BLE_MESH_UUID_HRS_CONTROL_POINT + * @brief HRS Characteristic Control Point + */ +#define BLE_MESH_UUID_HRS_CONTROL_POINT BLE_MESH_UUID_DECLARE_16(0x2a39) +#define BLE_MESH_UUID_HRS_CONTROL_POINT_VAL 0x2a39 +/** @def BLE_MESH_UUID_HIDS_INFO + * @brief HID Information Characteristic + */ +#define BLE_MESH_UUID_HIDS_INFO BLE_MESH_UUID_DECLARE_16(0x2a4a) +#define BLE_MESH_UUID_HIDS_INFO_VAL 0x2a4a +/** @def BLE_MESH_UUID_HIDS_REPORT_MAP + * @brief HID Report Map Characteristic + */ +#define BLE_MESH_UUID_HIDS_REPORT_MAP BLE_MESH_UUID_DECLARE_16(0x2a4b) +#define BLE_MESH_UUID_HIDS_REPORT_MAP_VAL 0x2a4b +/** @def BLE_MESH_UUID_HIDS_CTRL_POINT + * @brief HID Control Point Characteristic + */ +#define BLE_MESH_UUID_HIDS_CTRL_POINT BLE_MESH_UUID_DECLARE_16(0x2a4c) +#define BLE_MESH_UUID_HIDS_CTRL_POINT_VAL 0x2a4c +/** @def BLE_MESH_UUID_HIDS_REPORT + * @brief HID Report Characteristic + */ +#define BLE_MESH_UUID_HIDS_REPORT BLE_MESH_UUID_DECLARE_16(0x2a4d) +#define BLE_MESH_UUID_HIDS_REPORT_VAL 0x2a4d +/** @def BLE_MESH_UUID_CSC_MEASUREMENT + * @brief CSC Measurement Characteristic + */ +#define BLE_MESH_UUID_CSC_MEASUREMENT BLE_MESH_UUID_DECLARE_16(0x2a5b) +#define BLE_MESH_UUID_CSC_MEASUREMENT_VAL 0x2a5b +/** @def BLE_MESH_UUID_CSC_FEATURE + * @brief CSC Feature Characteristic + */ +#define BLE_MESH_UUID_CSC_FEATURE BLE_MESH_UUID_DECLARE_16(0x2a5c) +#define BLE_MESH_UUID_CSC_FEATURE_VAL 0x2a5c +/** @def BLE_MESH_UUID_SENSOR_LOCATION + * @brief Sensor Location Characteristic + */ +#define BLE_MESH_UUID_SENSOR_LOCATION BLE_MESH_UUID_DECLARE_16(0x2a5d) +#define BLE_MESH_UUID_SENSOR_LOCATION_VAL 0x2a5d +/** @def BLE_MESH_UUID_SC_CONTROL_POINT + * @brief SC Control Point Characteristic + */ +#define BLE_MESH_UUID_SC_CONTROL_POINT BLE_MESH_UUID_DECLARE_16(0x2a55) +#define BLE_MESH_UUID_SC_CONTROL_POINT_VAl 0x2a55 +/** @def BLE_MESH_UUID_ELEVATION + * @brief Elevation Characteristic + */ +#define BLE_MESH_UUID_ELEVATION BLE_MESH_UUID_DECLARE_16(0x2a6c) +#define BLE_MESH_UUID_ELEVATION_VAL 0x2a6c +/** @def BLE_MESH_UUID_PRESSURE + * @brief Pressure Characteristic + */ +#define BLE_MESH_UUID_PRESSURE BLE_MESH_UUID_DECLARE_16(0x2a6d) +#define BLE_MESH_UUID_PRESSURE_VAL 0x2a6d +/** @def BLE_MESH_UUID_TEMPERATURE + * @brief Temperature Characteristic + */ +#define BLE_MESH_UUID_TEMPERATURE BLE_MESH_UUID_DECLARE_16(0x2a6e) +#define BLE_MESH_UUID_TEMPERATURE_VAL 0x2a6e +/** @def BLE_MESH_UUID_HUMIDITY + * @brief Humidity Characteristic + */ +#define BLE_MESH_UUID_HUMIDITY BLE_MESH_UUID_DECLARE_16(0x2a6f) +#define BLE_MESH_UUID_HUMIDITY_VAL 0x2a6f +/** @def BLE_MESH_UUID_TRUE_WIND_SPEED + * @brief True Wind Speed Characteristic + */ +#define BLE_MESH_UUID_TRUE_WIND_SPEED BLE_MESH_UUID_DECLARE_16(0x2a70) +#define BLE_MESH_UUID_TRUE_WIND_SPEED_VAL 0x2a70 +/** @def BLE_MESH_UUID_TRUE_WIND_DIR + * @brief True Wind Direction Characteristic + */ +#define BLE_MESH_UUID_TRUE_WIND_DIR BLE_MESH_UUID_DECLARE_16(0x2a71) +#define BLE_MESH_UUID_TRUE_WIND_DIR_VAL 0x2a71 +/** @def BLE_MESH_UUID_APPARENT_WIND_SPEED + * @brief Apparent Wind Speed Characteristic + */ +#define BLE_MESH_UUID_APPARENT_WIND_SPEED BLE_MESH_UUID_DECLARE_16(0x2a72) +#define BLE_MESH_UUID_APPARENT_WIND_SPEED_VAL 0x2a72 +/** @def BLE_MESH_UUID_APPARENT_WIND_DIR + * @brief Apparent Wind Direction Characteristic + */ +#define BLE_MESH_UUID_APPARENT_WIND_DIR BLE_MESH_UUID_DECLARE_16(0x2a73) +#define BLE_MESH_UUID_APPARENT_WIND_DIR_VAL 0x2a73 +/** @def BLE_MESH_UUID_GUST_FACTOR + * @brief Gust Factor Characteristic + */ +#define BLE_MESH_UUID_GUST_FACTOR BLE_MESH_UUID_DECLARE_16(0x2a74) +#define BLE_MESH_UUID_GUST_FACTOR_VAL 0x2a74 +/** @def BLE_MESH_UUID_POLLEN_CONCENTRATION + * @brief Pollen Concentration Characteristic + */ +#define BLE_MESH_UUID_POLLEN_CONCENTRATION BLE_MESH_UUID_DECLARE_16(0x2a75) +#define BLE_MESH_UUID_POLLEN_CONCENTRATION_VAL 0x2a75 +/** @def BLE_MESH_UUID_UV_INDEX + * @brief UV Index Characteristic + */ +#define BLE_MESH_UUID_UV_INDEX BLE_MESH_UUID_DECLARE_16(0x2a76) +#define BLE_MESH_UUID_UV_INDEX_VAL 0x2a76 +/** @def BLE_MESH_UUID_IRRADIANCE + * @brief Irradiance Characteristic + */ +#define BLE_MESH_UUID_IRRADIANCE BLE_MESH_UUID_DECLARE_16(0x2a77) +#define BLE_MESH_UUID_IRRADIANCE_VAL 0x2a77 +/** @def BLE_MESH_UUID_RAINFALL + * @brief Rainfall Characteristic + */ +#define BLE_MESH_UUID_RAINFALL BLE_MESH_UUID_DECLARE_16(0x2a78) +#define BLE_MESH_UUID_RAINFALL_VAL 0x2a78 +/** @def BLE_MESH_UUID_WIND_CHILL + * @brief Wind Chill Characteristic + */ +#define BLE_MESH_UUID_WIND_CHILL BLE_MESH_UUID_DECLARE_16(0x2a79) +#define BLE_MESH_UUID_WIND_CHILL_VAL 0x2a79 +/** @def BLE_MESH_UUID_HEAT_INDEX + * @brief Heat Index Characteristic + */ +#define BLE_MESH_UUID_HEAT_INDEX BLE_MESH_UUID_DECLARE_16(0x2a7a) +#define BLE_MESH_UUID_HEAT_INDEX_VAL 0x2a7a +/** @def BLE_MESH_UUID_DEW_POINT + * @brief Dew Point Characteristic + */ +#define BLE_MESH_UUID_DEW_POINT BLE_MESH_UUID_DECLARE_16(0x2a7b) +#define BLE_MESH_UUID_DEW_POINT_VAL 0x2a7b +/** @def BLE_MESH_UUID_DESC_VALUE_CHANGED + * @brief Descriptor Value Changed Characteristic + */ +#define BLE_MESH_UUID_DESC_VALUE_CHANGED BLE_MESH_UUID_DECLARE_16(0x2a7d) +#define BLE_MESH_UUID_DESC_VALUE_CHANGED_VAL 0x2a7d +/** @def BLE_MESH_UUID_MAGN_FLUX_DENSITY_2D + * @brief Magnetic Flux Density - 2D Characteristic + */ +#define BLE_MESH_UUID_MAGN_FLUX_DENSITY_2D BLE_MESH_UUID_DECLARE_16(0x2aa0) +#define BLE_MESH_UUID_MAGN_FLUX_DENSITY_2D_VAL 0x2aa0 +/** @def BLE_MESH_UUID_MAGN_FLUX_DENSITY_3D + * @brief Magnetic Flux Density - 3D Characteristic + */ +#define BLE_MESH_UUID_MAGN_FLUX_DENSITY_3D BLE_MESH_UUID_DECLARE_16(0x2aa1) +#define BLE_MESH_UUID_MAGN_FLUX_DENSITY_3D_VAL 0x2aa1 +/** @def BLE_MESH_UUID_BAR_PRESSURE_TREND + * @brief Barometric Pressure Trend Characteristic + */ +#define BLE_MESH_UUID_BAR_PRESSURE_TREND BLE_MESH_UUID_DECLARE_16(0x2aa3) +#define BLE_MESH_UUID_BAR_PRESSURE_TREND_VAL 0x2aa3 +/** @def BLE_MESH_UUID_MESH_PROV_DATA_IN + * @brief Mesh Provisioning Data In + */ +#define BLE_MESH_UUID_MESH_PROV_DATA_IN BLE_MESH_UUID_DECLARE_16(0x2adb) +#define BLE_MESH_UUID_MESH_PROV_DATA_IN_VAL 0x2adb +/** @def BLE_MESH_UUID_MESH_PROV_DATA_OUT + * @brief Mesh Provisioning Data Out + */ +#define BLE_MESH_UUID_MESH_PROV_DATA_OUT BLE_MESH_UUID_DECLARE_16(0x2adc) +#define BLE_MESH_UUID_MESH_PROV_DATA_OUT_VAL 0x2adc +/** @def BLE_MESH_UUID_MESH_PROXY_DATA_IN + * @brief Mesh Proxy Data In + */ +#define BLE_MESH_UUID_MESH_PROXY_DATA_IN BLE_MESH_UUID_DECLARE_16(0x2add) +#define BLE_MESH_UUID_MESH_PROXY_DATA_IN_VAL 0x2add +/** @def BLE_MESH_UUID_MESH_PROXY_DATA_OUT + * @brief Mesh Proxy Data Out + */ +#define BLE_MESH_UUID_MESH_PROXY_DATA_OUT BLE_MESH_UUID_DECLARE_16(0x2ade) +#define BLE_MESH_UUID_MESH_PROXY_DATA_OUT_VAL 0x2ade + +/* + * Protocol UUIDs + */ +#define BLE_MESH_UUID_SDP BLE_MESH_UUID_DECLARE_16(0x0001) +#define BLE_MESH_UUID_SDP_VAL 0x0001 +#define BLE_MESH_UUID_UDP BLE_MESH_UUID_DECLARE_16(0x0002) +#define BLE_MESH_UUID_UDP_VAL 0x0002 +#define BLE_MESH_UUID_RFCOMM BLE_MESH_UUID_DECLARE_16(0x0003) +#define BLE_MESH_UUID_RFCOMM_VAL 0x0003 +#define BLE_MESH_UUID_TCP BLE_MESH_UUID_DECLARE_16(0x0004) +#define BLE_MESH_UUID_TCP_VAL 0x0004 +#define BLE_MESH_UUID_TCS_BIN BLE_MESH_UUID_DECLARE_16(0x0005) +#define BLE_MESH_UUID_TCS_BIN_VAL 0x0005 +#define BLE_MESH_UUID_TCS_AT BLE_MESH_UUID_DECLARE_16(0x0006) +#define BLE_MESH_UUID_TCS_AT_VAL 0x0006 +#define BLE_MESH_UUID_ATT BLE_MESH_UUID_DECLARE_16(0x0007) +#define BLE_MESH_UUID_ATT_VAL 0x0007 +#define BLE_MESH_UUID_OBEX BLE_MESH_UUID_DECLARE_16(0x0008) +#define BLE_MESH_UUID_OBEX_VAL 0x0008 +#define BLE_MESH_UUID_IP BLE_MESH_UUID_DECLARE_16(0x0009) +#define BLE_MESH_UUID_IP_VAL 0x0009 +#define BLE_MESH_UUID_FTP BLE_MESH_UUID_DECLARE_16(0x000a) +#define BLE_MESH_UUID_FTP_VAL 0x000a +#define BLE_MESH_UUID_HTTP BLE_MESH_UUID_DECLARE_16(0x000c) +#define BLE_MESH_UUID_HTTP_VAL 0x000c +#define BLE_MESH_UUID_BNEP BLE_MESH_UUID_DECLARE_16(0x000f) +#define BLE_MESH_UUID_BNEP_VAL 0x000f +#define BLE_MESH_UUID_UPNP BLE_MESH_UUID_DECLARE_16(0x0010) +#define BLE_MESH_UUID_UPNP_VAL 0x0010 +#define BLE_MESH_UUID_HIDP BLE_MESH_UUID_DECLARE_16(0x0011) +#define BLE_MESH_UUID_HIDP_VAL 0x0011 +#define BLE_MESH_UUID_HCRP_CTRL BLE_MESH_UUID_DECLARE_16(0x0012) +#define BLE_MESH_UUID_HCRP_CTRL_VAL 0x0012 +#define BLE_MESH_UUID_HCRP_DATA BLE_MESH_UUID_DECLARE_16(0x0014) +#define BLE_MESH_UUID_HCRP_DATA_VAL 0x0014 +#define BLE_MESH_UUID_HCRP_NOTE BLE_MESH_UUID_DECLARE_16(0x0016) +#define BLE_MESH_UUID_HCRP_NOTE_VAL 0x0016 +#define BLE_MESH_UUID_AVCTP BLE_MESH_UUID_DECLARE_16(0x0017) +#define BLE_MESH_UUID_AVCTP_VAL 0x0017 +#define BLE_MESH_UUID_AVDTP BLE_MESH_UUID_DECLARE_16(0x0019) +#define BLE_MESH_UUID_AVDTP_VAL 0x0019 +#define BLE_MESH_UUID_CMTP BLE_MESH_UUID_DECLARE_16(0x001b) +#define BLE_MESH_UUID_CMTP_VAL 0x001b +#define BLE_MESH_UUID_UDI BLE_MESH_UUID_DECLARE_16(0x001d) +#define BLE_MESH_UUID_UDI_VAL 0x001d +#define BLE_MESH_UUID_MCAP_CTRL BLE_MESH_UUID_DECLARE_16(0x001e) +#define BLE_MESH_UUID_MCAP_CTRL_VAL 0x001e +#define BLE_MESH_UUID_MCAP_DATA BLE_MESH_UUID_DECLARE_16(0x001f) +#define BLE_MESH_UUID_MCAP_DATA_VAL 0x001f +#define BLE_MESH_UUID_L2CAP BLE_MESH_UUID_DECLARE_16(0x0100) +#define BLE_MESH_UUID_L2CAP_VAL 0x0100 + +#ifdef __cplusplus +} +#endif + +/** + * @} + */ + +#endif /* _BLE_MESH_UUID_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/local_operation.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/local_operation.h new file mode 100644 index 00000000000..f7f169d1f8c --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/local_operation.h @@ -0,0 +1,41 @@ +/* Bluetooth Mesh */ + +/* + * SPDX-FileCopyrightText: 2017 Intel Corporation + * SPDX-FileContributor: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _LOCAL_OPERATION_H_ +#define _LOCAL_OPERATION_H_ + +#include "mesh_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +int bt_mesh_model_subscribe_group_addr(uint16_t elem_addr, uint16_t mod_id, + uint16_t cid, uint16_t group_addr); + +int bt_mesh_model_unsubscribe_group_addr(uint16_t elem_addr, uint16_t cid, + uint16_t mod_id, uint16_t group_addr); + +const uint8_t *bt_mesh_node_get_local_net_key(uint16_t net_idx); + +const uint8_t *bt_mesh_node_get_local_app_key(uint16_t app_idx); + +int bt_mesh_node_local_net_key_add(uint16_t net_idx, const uint8_t net_key[16]); + +int bt_mesh_node_local_app_key_add(uint16_t net_idx, uint16_t app_idx, + const uint8_t app_key[16]); + +int bt_mesh_node_bind_app_key_to_model(uint16_t elem_addr, uint16_t mod_id, + uint16_t cid, uint16_t app_idx); + +#ifdef __cplusplus +} +#endif + +#endif /* _LOCAL_OPERATION_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/lpn.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/lpn.h new file mode 100644 index 00000000000..dbff49d624d --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/lpn.h @@ -0,0 +1,78 @@ +/* Bluetooth Mesh */ + +/* + * SPDX-FileCopyrightText: 2017 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _LPN_H_ +#define _LPN_H_ + +#include "net.h" + +#ifdef __cplusplus +extern "C" { +#endif + +int bt_mesh_lpn_friend_update(struct bt_mesh_net_rx *rx, + struct net_buf_simple *buf); +int bt_mesh_lpn_friend_offer(struct bt_mesh_net_rx *rx, + struct net_buf_simple *buf); +int bt_mesh_lpn_friend_clear_cfm(struct bt_mesh_net_rx *rx, + struct net_buf_simple *buf); +int bt_mesh_lpn_friend_sub_cfm(struct bt_mesh_net_rx *rx, + struct net_buf_simple *buf); + +static inline bool bt_mesh_lpn_established(void) +{ +#if defined(CONFIG_BLE_MESH_LOW_POWER) + return bt_mesh.lpn.established; +#else + return false; +#endif +} + +static inline bool bt_mesh_lpn_match(uint16_t addr) +{ +#if defined(CONFIG_BLE_MESH_LOW_POWER) + if (bt_mesh_lpn_established()) { + return (addr == bt_mesh.lpn.frnd); + } +#endif + return false; +} + +static inline bool bt_mesh_lpn_waiting_update(void) +{ +#if defined(CONFIG_BLE_MESH_LOW_POWER) + return (bt_mesh.lpn.state == BLE_MESH_LPN_WAIT_UPDATE); +#else + return false; +#endif +} + +static inline bool bt_mesh_lpn_timer(void) +{ +#if defined(CONFIG_BLE_MESH_LPN_AUTO) + return (bt_mesh.lpn.state == BLE_MESH_LPN_TIMER); +#else + return false; +#endif +} + +void bt_mesh_lpn_msg_received(struct bt_mesh_net_rx *rx); + +void bt_mesh_lpn_group_add(uint16_t group); +void bt_mesh_lpn_group_del(uint16_t *groups, size_t group_count); + +void bt_mesh_lpn_disable(bool force); + +int bt_mesh_lpn_init(void); +int bt_mesh_lpn_deinit(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _LPN_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/mesh.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/mesh.h new file mode 100644 index 00000000000..33155aa555c --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/mesh.h @@ -0,0 +1,33 @@ +/* Bluetooth Mesh */ + +/* + * SPDX-FileCopyrightText: 2017 Intel Corporation + * SPDX-FileContributor: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _MESH_H_ +#define _MESH_H_ + +#include "net.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define BLE_MESH_KEY_PRIMARY 0x0000 +#define BLE_MESH_KEY_ANY 0xffff + +#define BLE_MESH_ADDR_IS_UNICAST(addr) ((addr) && (addr) < 0x8000) +#define BLE_MESH_ADDR_IS_GROUP(addr) ((addr) >= 0xc000 && (addr) <= 0xff00) +#define BLE_MESH_ADDR_IS_VIRTUAL(addr) ((addr) >= 0x8000 && (addr) < 0xc000) +#define BLE_MESH_ADDR_IS_RFU(addr) ((addr) >= 0xff00 && (addr) <= 0xfffb) + +struct bt_mesh_net; + +#ifdef __cplusplus +} +#endif + +#endif /* _MESH_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/net.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/net.h new file mode 100644 index 00000000000..8a1b9b343a3 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/net.h @@ -0,0 +1,424 @@ +/* Bluetooth Mesh */ + +/* + * SPDX-FileCopyrightText: 2017 Intel Corporation + * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _NET_H_ +#define _NET_H_ + +#include "mesh_access.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define BLE_MESH_NET_FLAG_KR BIT(0) +#define BLE_MESH_NET_FLAG_IVU BIT(1) + +#define BLE_MESH_KR_NORMAL 0x00 +#define BLE_MESH_KR_PHASE_1 0x01 +#define BLE_MESH_KR_PHASE_2 0x02 +#define BLE_MESH_KR_PHASE_3 0x03 + +#define BLE_MESH_IV_UPDATE(flags) ((flags >> 1) & 0x01) +#define BLE_MESH_KEY_REFRESH(flags) (flags & 0x01) + +/* How many hours in between updating IVU duration */ +#define BLE_MESH_IVU_MIN_HOURS 96 +#define BLE_MESH_IVU_HOURS (BLE_MESH_IVU_MIN_HOURS / CONFIG_BLE_MESH_IVU_DIVIDER) +#define BLE_MESH_IVU_TIMEOUT K_HOURS(BLE_MESH_IVU_HOURS) + +struct bt_mesh_app_key { + uint16_t net_idx; + uint16_t app_idx; + bool updated; + struct bt_mesh_app_keys { + uint8_t id; + uint8_t val[16]; + } keys[2]; +}; + +struct bt_mesh_subnet { + uint32_t beacon_sent; /* Timestamp of last sent beacon */ + uint8_t beacons_last; /* Number of beacons during last observation window. */ + uint8_t beacons_cur; /* Number of beacons observed during currently ongoing window. */ + + uint8_t beacon_cache[21]; /* Cached last authenticated beacon */ + + uint16_t net_idx; /* NetKeyIndex */ + + bool kr_flag; /* Key Refresh Flag */ + uint8_t kr_phase; /* Key Refresh Phase */ + + uint8_t node_id; /* Node Identity State */ + uint32_t node_id_start; /* Node Identity started timestamp */ + + uint8_t auth[8]; /* Beacon Authentication Value */ + + struct bt_mesh_subnet_keys { + uint8_t net[16]; /* NetKey */ + uint8_t nid; /* NID */ + uint8_t enc[16]; /* EncKey */ + uint8_t net_id[8]; /* Network ID */ +#if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER) + uint8_t identity[16]; /* IdentityKey */ +#endif + uint8_t privacy[16]; /* PrivacyKey */ + uint8_t beacon[16]; /* BeaconKey */ + } keys[2]; +}; + +struct bt_mesh_rpl { + uint16_t src; + bool old_iv; +#if defined(CONFIG_BLE_MESH_SETTINGS) + bool store; +#endif + uint32_t seq; +}; + +#if defined(CONFIG_BLE_MESH_FRIEND) +#define FRIEND_SEG_RX CONFIG_BLE_MESH_FRIEND_SEG_RX +#define FRIEND_SUB_LIST_SIZE CONFIG_BLE_MESH_FRIEND_SUB_LIST_SIZE +#else +#define FRIEND_SEG_RX 0 +#define FRIEND_SUB_LIST_SIZE 0 +#endif + +struct bt_mesh_friend { + uint16_t lpn; + uint8_t recv_delay; + uint8_t fsn:1, + send_last:1, + pending_req:1, + sec_update:1, + pending_buf:1, + valid:1, + established:1; + int32_t poll_to; + uint8_t num_elem; + uint16_t lpn_counter; + uint16_t counter; + + uint16_t net_idx; + + uint16_t sub_list[FRIEND_SUB_LIST_SIZE]; + + struct k_delayed_work timer; + + struct bt_mesh_friend_seg { + sys_slist_t queue; + + /* The target number of segments, i.e. not necessarily + * the current number of segments, in the queue. This is + * used for Friend Queue free space calculations. + */ + uint8_t seg_count; + } seg[FRIEND_SEG_RX]; + + struct net_buf *last; + + sys_slist_t queue; + uint32_t queue_size; + + /* Friend Clear Procedure */ + struct { + uint32_t start; /* Clear Procedure start */ + uint16_t frnd; /* Previous Friend's address */ + uint16_t repeat_sec; /* Repeat timeout in seconds */ + struct k_delayed_work timer; /* Repeat timer */ + } clear; +}; + +#if defined(CONFIG_BLE_MESH_LOW_POWER) +#define LPN_GROUPS CONFIG_BLE_MESH_LPN_GROUPS +#else +#define LPN_GROUPS 0 +#endif + +/* Low Power Node state */ +struct bt_mesh_lpn { + enum __packed { + BLE_MESH_LPN_DISABLED, /* LPN feature is disabled */ + BLE_MESH_LPN_CLEAR, /* Clear in progress */ + BLE_MESH_LPN_TIMER, /* Waiting for auto timer expiry */ + BLE_MESH_LPN_ENABLED, /* LPN enabled, but no Friend */ + BLE_MESH_LPN_REQ_WAIT, /* Wait before scanning for offers */ + BLE_MESH_LPN_WAIT_OFFER, /* Friend Req sent */ + BLE_MESH_LPN_ESTABLISHED, /* Friendship established */ + BLE_MESH_LPN_RECV_DELAY, /* Poll sent, waiting ReceiveDelay */ + BLE_MESH_LPN_WAIT_UPDATE, /* Waiting for Update or message */ + BLE_MESH_LPN_OFFER_RECV, /* Friend offer received */ + } state; + + /* Transaction Number (used for subscription list) */ + uint8_t xact_next; + uint8_t xact_pending; + uint8_t sent_req; + + /* Address of our Friend when we're a LPN. Unassigned if we don't + * have a friend yet. + */ + uint16_t frnd; + + /* Value from the friend offer */ + uint8_t recv_win; + + uint8_t req_attempts; /* Number of Request attempts */ + + int32_t poll_timeout; + + uint8_t groups_changed: 1, /* Friend Subscription List needs updating */ + pending_poll: 1, /* Poll to be sent after subscription */ + disable: 1, /* Disable LPN after clearing */ + fsn: 1, /* Friend Sequence Number */ + established: 1, /* Friendship established */ + clear_success: 1; /* Friend Clear Confirm received */ + + /* Friend Queue Size */ + uint8_t queue_size; + + /* LPNCounter */ + uint16_t counter; + + /* Previous Friend of this LPN */ + uint16_t old_friend; + + /* Duration reported for last advertising packet */ + uint16_t adv_duration; + + /* Next LPN related action timer */ + struct k_delayed_work timer; + + /* Subscribed groups */ + uint16_t groups[LPN_GROUPS]; + + /* Bit fields for tracking which groups the Friend knows about */ + BLE_MESH_ATOMIC_DEFINE(added, LPN_GROUPS); + BLE_MESH_ATOMIC_DEFINE(pending, LPN_GROUPS); + BLE_MESH_ATOMIC_DEFINE(to_remove, LPN_GROUPS); +}; + +/* bt_mesh_net.flags */ +enum { + BLE_MESH_NODE, /* Device is a node */ + BLE_MESH_PROVISIONER, /* Device is a Provisioner */ + BLE_MESH_VALID, /* We have been provisioned */ + BLE_MESH_VALID_PROV, /* Provisioner has been enabled */ + BLE_MESH_SUSPENDED, /* Network is temporarily suspended */ + BLE_MESH_IVU_IN_PROGRESS, /* IV Update in Progress */ + BLE_MESH_IVU_INITIATOR, /* IV Update initiated by us */ + BLE_MESH_IVU_TEST, /* IV Update test mode */ + BLE_MESH_IVU_PENDING, /* Update blocked by SDU in progress */ + + /* pending storage actions, must reside within first 32 flags */ + BLE_MESH_RPL_PENDING, + BLE_MESH_KEYS_PENDING, + BLE_MESH_NET_PENDING, + BLE_MESH_IV_PENDING, + BLE_MESH_SEQ_PENDING, + BLE_MESH_HB_PUB_PENDING, + BLE_MESH_CFG_PENDING, + BLE_MESH_MOD_PENDING, + BLE_MESH_VA_PENDING, + + /* Don't touch - intentionally last */ + BLE_MESH_FLAG_COUNT, +}; + +struct bt_mesh_net { + uint32_t iv_index; /* Current IV Index */ + uint32_t seq; /* Next outgoing sequence number (24 bits) */ + + BLE_MESH_ATOMIC_DEFINE(flags, BLE_MESH_FLAG_COUNT); + + /* Local network interface */ + struct k_work local_work; + sys_slist_t local_queue; + +#if defined(CONFIG_BLE_MESH_FRIEND) + /* Friend state, unique for each LPN that we're Friends for */ + struct bt_mesh_friend frnd[CONFIG_BLE_MESH_FRIEND_LPN_COUNT]; +#endif + +#if defined(CONFIG_BLE_MESH_LOW_POWER) + struct bt_mesh_lpn lpn; /* Low Power Node state */ +#endif + + /* Number of hours in current IV Update state */ + uint8_t ivu_duration; + + /* Timer to track duration in current IV Update state */ + struct k_delayed_work ivu_timer; + + uint8_t dev_key[16]; + + struct bt_mesh_app_key app_keys[CONFIG_BLE_MESH_APP_KEY_COUNT]; + + struct bt_mesh_subnet sub[CONFIG_BLE_MESH_SUBNET_COUNT]; + + struct bt_mesh_rpl rpl[CONFIG_BLE_MESH_CRPL]; + +#if defined(CONFIG_BLE_MESH_PROVISIONER) + /* Application keys stored by provisioner */ + struct bt_mesh_app_key *p_app_keys[CONFIG_BLE_MESH_PROVISIONER_APP_KEY_COUNT]; + /* Next app_idx can be assigned */ + uint16_t p_app_idx_next; + + /* Network keys stored by provisioner */ + struct bt_mesh_subnet *p_sub[CONFIG_BLE_MESH_PROVISIONER_SUBNET_COUNT]; + /* Next net_idx can be assigned */ + uint16_t p_net_idx_next; +#endif +}; + +/* Network interface */ +enum bt_mesh_net_if { + BLE_MESH_NET_IF_ADV, + BLE_MESH_NET_IF_LOCAL, + BLE_MESH_NET_IF_PROXY, + BLE_MESH_NET_IF_PROXY_CFG, +}; + +/* Decoding context for Network/Transport data */ +struct bt_mesh_net_rx { + struct bt_mesh_subnet *sub; + struct bt_mesh_msg_ctx ctx; + uint32_t seq; /* Sequence Number */ + uint8_t old_iv:1, /* iv_index - 1 was used */ + new_key:1, /* Data was encrypted with updated key */ + friend_cred:1, /* Data was encrypted with friend cred */ + ctl:1, /* Network Control */ + net_if:2, /* Network interface */ + local_match:1, /* Matched a local element */ + friend_match:1; /* Matched an LPN we're friends for */ + uint16_t msg_cache_idx; /* Index of entry in message cache */ +}; + +/* Encoding context for Network/Transport data */ +struct bt_mesh_net_tx { + struct bt_mesh_subnet *sub; + struct bt_mesh_msg_ctx *ctx; + uint16_t src; + uint8_t xmit; + uint8_t friend_cred:1, + aszmic:1, + aid: 6; +}; + +extern struct bt_mesh_net bt_mesh; + +#define BLE_MESH_NET_IVI_TX (bt_mesh.iv_index - \ + bt_mesh_atomic_test_bit(bt_mesh.flags, \ + BLE_MESH_IVU_IN_PROGRESS)) +#define BLE_MESH_NET_IVI_RX(rx) (bt_mesh.iv_index - (rx)->old_iv) + +#define BLE_MESH_NET_HDR_LEN 9 + +void bt_mesh_msg_cache_clear(uint16_t unicast_addr, uint8_t elem_num); + +int bt_mesh_net_keys_create(struct bt_mesh_subnet_keys *keys, + const uint8_t key[16]); + +int bt_mesh_net_create(uint16_t idx, uint8_t flags, const uint8_t key[16], + uint32_t iv_index); + +uint8_t bt_mesh_net_flags(struct bt_mesh_subnet *sub); + +bool bt_mesh_kr_update(struct bt_mesh_subnet *sub, uint8_t new_kr, bool new_key); + +void bt_mesh_net_revoke_keys(struct bt_mesh_subnet *sub); + +int bt_mesh_net_beacon_update(struct bt_mesh_subnet *sub); + +void bt_mesh_rpl_reset(void); + +bool bt_mesh_net_iv_update(uint32_t iv_index, bool iv_update); + +void bt_mesh_net_sec_update(struct bt_mesh_subnet *sub); + +struct bt_mesh_subnet *bt_mesh_subnet_get(uint16_t net_idx); + +struct bt_mesh_subnet *bt_mesh_subnet_find(const uint8_t net_id[8], uint8_t flags, + uint32_t iv_index, const uint8_t auth[8], + bool *new_key); + +int bt_mesh_net_encode(struct bt_mesh_net_tx *tx, struct net_buf_simple *buf, + bool proxy); + +int bt_mesh_net_send(struct bt_mesh_net_tx *tx, struct net_buf *buf, + const struct bt_mesh_send_cb *cb, void *cb_data); + +int bt_mesh_net_resend(struct bt_mesh_subnet *sub, struct net_buf *buf, + bool new_key, const struct bt_mesh_send_cb *cb, + void *cb_data); + +int bt_mesh_net_decode(struct net_buf_simple *data, enum bt_mesh_net_if net_if, + struct bt_mesh_net_rx *rx, struct net_buf_simple *buf); + +void bt_mesh_net_recv(struct net_buf_simple *data, int8_t rssi, + enum bt_mesh_net_if net_if); + +bool bt_mesh_primary_subnet_exist(void); + +uint32_t bt_mesh_next_seq(void); + +void bt_mesh_net_start(void); + +void bt_mesh_net_init(void); +void bt_mesh_net_reset(void); +void bt_mesh_net_deinit(void); + +void bt_mesh_net_header_parse(struct net_buf_simple *buf, + struct bt_mesh_net_rx *rx); + +/* Friendship Credential Management */ +struct friend_cred { + uint16_t net_idx; + uint16_t addr; + + uint16_t lpn_counter; + uint16_t frnd_counter; + + struct { + uint8_t nid; /* NID */ + uint8_t enc[16]; /* EncKey */ + uint8_t privacy[16]; /* PrivacyKey */ + } cred[2]; +}; + +int friend_cred_get(struct bt_mesh_subnet *sub, uint16_t addr, uint8_t *nid, + const uint8_t **enc, const uint8_t **priv); +int friend_cred_set(struct friend_cred *cred, uint8_t idx, const uint8_t net_key[16]); +void friend_cred_refresh(uint16_t net_idx); +int friend_cred_update(struct bt_mesh_subnet *sub); +struct friend_cred *friend_cred_create(struct bt_mesh_subnet *sub, uint16_t addr, + uint16_t lpn_counter, uint16_t frnd_counter); +void friend_cred_clear(struct friend_cred *cred); +int friend_cred_del(uint16_t net_idx, uint16_t addr); + +static inline void send_cb_finalize(const struct bt_mesh_send_cb *cb, + void *cb_data) +{ + if (!cb) { + return; + } + + if (cb->start) { + cb->start(0, 0, cb_data); + } + + if (cb->end) { + cb->end(0, cb_data); + } +} + +#ifdef __cplusplus +} +#endif + +#endif /* _NET_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/prov.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/prov.h new file mode 100644 index 00000000000..789d33a3866 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/prov.h @@ -0,0 +1,43 @@ +/* Bluetooth Mesh */ + +/* + * SPDX-FileCopyrightText: 2017 Intel Corporation + * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#ifndef _PROV_H_ +#define _PROV_H_ + +#include "mesh_main.h" +#include "mesh_bearer_adapt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void bt_mesh_pb_adv_recv(struct net_buf_simple *buf); + +bool bt_prov_active(void); + +int bt_mesh_pb_gatt_open(struct bt_mesh_conn *conn); +int bt_mesh_pb_gatt_close(struct bt_mesh_conn *conn); +int bt_mesh_pb_gatt_recv(struct bt_mesh_conn *conn, struct net_buf_simple *buf); + +int bt_mesh_set_oob_pub_key(const uint8_t pub_key_x[32], const uint8_t pub_key_y[32], + const uint8_t pri_key[32]); + +const struct bt_mesh_prov *bt_mesh_prov_get(void); + +int bt_mesh_prov_init(const struct bt_mesh_prov *prov); +int bt_mesh_prov_deinit(void); + +void bt_mesh_prov_complete(uint16_t net_idx, const uint8_t net_key[16], + uint16_t addr, uint8_t flags, uint32_t iv_index); +void bt_mesh_prov_reset(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _PROV_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/provisioner_main.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/provisioner_main.h new file mode 100644 index 00000000000..9b01e31fb73 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/provisioner_main.h @@ -0,0 +1,145 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _PROVISIONER_MAIN_H_ +#define _PROVISIONER_MAIN_H_ + +#include "net.h" +#include "mesh_bearer_adapt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define BLE_MESH_INVALID_NODE_INDEX 0xFFFF +#define BLE_MESH_NODE_NAME_SIZE 31 + +/* Each node information stored by provisioner */ +struct bt_mesh_node { + /* Device information */ + uint8_t addr[6]; /* Node device address */ + uint8_t addr_type; /* Node device address type */ + uint8_t dev_uuid[16]; /* Node Device UUID */ + uint16_t oob_info; /* Node OOB information */ + + /* Provisioning information */ + uint16_t unicast_addr; /* Node unicast address */ + uint8_t element_num; /* Node element number */ + uint16_t net_idx; /* Node NetKey Index */ + uint8_t flags; /* Node key refresh flag and iv update flag */ + uint32_t iv_index; /* Node IV Index */ + uint8_t dev_key[16]; /* Node device key */ + + /* Additional information */ + char name[BLE_MESH_NODE_NAME_SIZE + 1]; /* Node name */ + uint16_t comp_length; /* Length of Composition Data */ + uint8_t *comp_data; /* Value of Composition Data */ +} __packed; + +int bt_mesh_provisioner_init(void); + +int bt_mesh_provisioner_net_create(void); + +void bt_mesh_provisioner_main_reset(bool erase); + +int bt_mesh_provisioner_deinit(bool erase); + +bool bt_mesh_provisioner_check_is_addr_dup(uint16_t addr, uint8_t elem_num, bool comp_with_own); + +uint16_t bt_mesh_provisioner_get_node_count(void); + +int bt_mesh_provisioner_restore_node_info(struct bt_mesh_node *node); + +int bt_mesh_provisioner_provision(const bt_mesh_addr_t *addr, const uint8_t uuid[16], + uint16_t oob_info, uint16_t unicast_addr, + uint8_t element_num, uint16_t net_idx, + uint8_t flags, uint32_t iv_index, + const uint8_t dev_key[16], uint16_t *index); + +int bt_mesh_provisioner_remove_node(const uint8_t uuid[16]); + +int bt_mesh_provisioner_restore_node_name(uint16_t addr, const char *name); + +int bt_mesh_provisioner_restore_node_comp_data(uint16_t addr, const uint8_t *data, uint16_t length); + +struct bt_mesh_node *bt_mesh_provisioner_get_node_with_uuid(const uint8_t uuid[16]); + +struct bt_mesh_node *bt_mesh_provisioner_get_node_with_addr(uint16_t unicast_addr); + +int bt_mesh_provisioner_delete_node_with_uuid(const uint8_t uuid[16]); + +int bt_mesh_provisioner_delete_node_with_node_addr(uint16_t unicast_addr); + +int bt_mesh_provisioner_delete_node_with_dev_addr(const bt_mesh_addr_t *addr); + +int bt_mesh_provisioner_set_node_name(uint16_t index, const char *name); + +const char *bt_mesh_provisioner_get_node_name(uint16_t index); + +uint16_t bt_mesh_provisioner_get_node_index(const char *name); + +struct bt_mesh_node *bt_mesh_provisioner_get_node_with_name(const char *name); + +const struct bt_mesh_node **bt_mesh_provisioner_get_node_table_entry(void); + +int bt_mesh_provisioner_store_node_comp_data(uint16_t addr, const uint8_t *data, uint16_t length); + +const uint8_t *bt_mesh_provisioner_net_key_get(uint16_t net_idx); + +struct bt_mesh_subnet *bt_mesh_provisioner_subnet_get(uint16_t net_idx); + +bool bt_mesh_provisioner_check_msg_dst(uint16_t dst); + +const uint8_t *bt_mesh_provisioner_dev_key_get(uint16_t dst); + +struct bt_mesh_app_key *bt_mesh_provisioner_app_key_find(uint16_t app_idx); + +int bt_mesh_provisioner_local_app_key_add(const uint8_t app_key[16], + uint16_t net_idx, uint16_t *app_idx); + +int bt_mesh_provisioner_local_app_key_update(const uint8_t app_key[16], + uint16_t net_idx, uint16_t app_idx); + +const uint8_t *bt_mesh_provisioner_local_app_key_get(uint16_t net_idx, uint16_t app_idx); + +int bt_mesh_provisioner_local_app_key_del(uint16_t net_idx, uint16_t app_idx, bool store); + +int bt_mesh_provisioner_local_net_key_add(const uint8_t net_key[16], uint16_t *net_idx); + +int bt_mesh_provisioner_local_net_key_update(const uint8_t net_key[16], uint16_t net_idx); + +const uint8_t *bt_mesh_provisioner_local_net_key_get(uint16_t net_idx); + +int bt_mesh_provisioner_local_net_key_del(uint16_t net_idx, bool store); + +/* Provisioner bind local client model with proper appkey index */ +int bt_mesh_provisioner_bind_local_model_app_idx(uint16_t elem_addr, uint16_t mod_id, + uint16_t cid, uint16_t app_idx); + +typedef void (* bt_mesh_heartbeat_recv_cb_t)(uint16_t hb_src, uint16_t hb_dst, + uint8_t init_ttl, uint8_t rx_ttl, + uint8_t hops, uint16_t feat, int8_t rssi); + +int bt_mesh_provisioner_recv_heartbeat(bt_mesh_heartbeat_recv_cb_t cb); + +int bt_mesh_provisioner_set_heartbeat_filter_type(uint8_t filter_type); + +int bt_mesh_provisioner_set_heartbeat_filter_info(uint8_t op, uint16_t src, uint16_t dst); + +void bt_mesh_provisioner_heartbeat(uint16_t hb_src, uint16_t hb_dst, + uint8_t init_ttl, uint8_t rx_ttl, + uint8_t hops, uint16_t feat, int8_t rssi); + +/* Provisioner print own element information */ +int bt_mesh_print_local_composition_data(void); + +int bt_mesh_provisioner_store_node_info(struct bt_mesh_node *node); + +#ifdef __cplusplus +} +#endif + +#endif /* _PROVISIONER_MAIN_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/provisioner_prov.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/provisioner_prov.h new file mode 100644 index 00000000000..66827232ad6 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/provisioner_prov.h @@ -0,0 +1,423 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _PROVISIONER_PROV_H_ +#define _PROVISIONER_PROV_H_ + +#include "mesh_main.h" +#include "mesh_bearer_adapt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef CONFIG_BLE_MESH_PBA_SAME_TIME +#define CONFIG_BLE_MESH_PBA_SAME_TIME 0 +#endif + +#ifndef CONFIG_BLE_MESH_PBG_SAME_TIME +#define CONFIG_BLE_MESH_PBG_SAME_TIME 0 +#endif + +#define RM_AFTER_PROV BIT(0) +#define START_PROV_NOW BIT(1) +#define FLUSHABLE_DEV BIT(2) + +struct bt_mesh_unprov_dev_add { + uint8_t addr[6]; + uint8_t addr_type; + uint8_t uuid[16]; + uint16_t oob_info; + uint8_t bearer; +}; + +struct bt_mesh_device_delete { + uint8_t addr[6]; + uint8_t addr_type; + uint8_t uuid[16]; +}; + +#define NET_IDX_FLAG BIT(0) +#define FLAGS_FLAG BIT(1) +#define IV_INDEX_FLAG BIT(2) + +struct bt_mesh_prov_data_info { + union { + uint16_t net_idx; + uint8_t flags; + uint32_t iv_index; + }; + uint8_t flag; +}; + +/* The following APIs are for primary provisioner internal use */ + +/** + * @brief This function decrements the current PB-GATT count. + * + * @return None + */ +void bt_mesh_provisioner_pbg_count_dec(void); + +/** + * @brief This function clears the part of the link info of the proper device. + * + * @param[in] addr: Remote device address + * + * @return None + */ +void bt_mesh_provisioner_clear_link_info(const uint8_t addr[6]); + +/** + * @brief This function handles the received PB-ADV PDUs. + * + * @param[in] buf: Pointer to the buffer containing generic provisioning PDUs + * + * @return Zero - success, otherwise - fail + */ +void bt_mesh_provisioner_pb_adv_recv(struct net_buf_simple *buf); + +/** + * @brief This function sends provisioning invite to start + * provisioning this unprovisioned device. + * + * @param[in] addr: Remote device address + * @param[in] conn: Pointer to the bt_conn structure + * + * @return Zero - success, otherwise - fail + */ +int bt_mesh_provisioner_set_prov_conn(const uint8_t addr[6], struct bt_mesh_conn *conn); + +/** + * @brief This function sends provisioning invite to start + * provisioning this unprovisioned device. + * + * @param[in] conn: Pointer to the bt_conn structure + * @param[in] addr: Address of the connected device + * + * @return Zero - success, otherwise - fail + */ +int bt_mesh_provisioner_pb_gatt_open(struct bt_mesh_conn *conn, uint8_t *addr); + +/** + * @brief This function resets the used information when + * related connection is terminated. + * + * @param[in] conn: Pointer to the bt_conn structure + * @param[in] reason: Connection terminated reason + * + * @return Zero - success, otherwise - fail + */ +int bt_mesh_provisioner_pb_gatt_close(struct bt_mesh_conn *conn, uint8_t reason); + +/** + * @brief This function handles the received PB-GATT provision + * PDUs. + * + * @param[in] conn: Pointer to the bt_conn structure + * @param[in] buf: Pointer to the buffer containing provision PDUs + * + * @return Zero - success, otherwise - fail + */ +int bt_mesh_provisioner_pb_gatt_recv(struct bt_mesh_conn *conn, struct net_buf_simple *buf); + +/** + * @brief This function initializes provisioner's PB-GATT and PB-ADV + * related information. + * + * @param[in] prov_info: Pointer to the application-initialized provisioner info. + * + * @return Zero - success, otherwise - fail + */ +int bt_mesh_provisioner_prov_init(const struct bt_mesh_prov *prov_info); + +int bt_mesh_provisioner_prov_reset(bool erase); + +/** + * @brief This function de-initializes provisioner's PB-GATT and PB-ADV + * related information. + * + * @param[in] erase: Indicate if erasing provisioning information from flash. + * + * @return Zero - success, otherwise - fail + */ +int bt_mesh_provisioner_prov_deinit(bool erase); + +/** + * @brief This function parses the received unprovisioned device + * beacon advertising packets, and if checked, starts to provision this device + * using PB-ADV bearer. + * + * @param[in] buf: Pointer to the buffer containing unprovisioned device beacon + * @param[in] rssi: RSSI of the received unprovisioned device beacon + * + * @return None + */ +void bt_mesh_provisioner_unprov_beacon_recv(struct net_buf_simple *buf, int8_t rssi); + +void bt_mesh_provisioner_prov_adv_recv(struct net_buf_simple *buf, + const bt_mesh_addr_t *addr, int8_t rssi); + +/** + * @brief This function gets the bt_mesh_prov pointer. + * + * @return bt_mesh_prov pointer(prov) + */ +const struct bt_mesh_prov *bt_mesh_provisioner_get_prov_info(void); + +void bt_mesh_provisioner_restore_prov_info(uint16_t primary_addr, uint16_t alloc_addr); + +/* The following APIs are for primary provisioner application use */ + +/** @brief Add unprovisioned device info to unprov_dev queue + * + * @param[in] add_dev: Pointer to the structure containing the device information + * @param[in] flags: Flags indicate several operations of the device information + * - Remove device information from queue after it is provisioned (BIT0) + * - Start provisioning as soon as device is added to queue (BIT1) + * - Device can be flushed when device queue is full (BIT2) + * + * @return Zero on success or (negative) error code otherwise. + * + * @note 1. Currently address type only supports public address and static random address. + * 2. If device UUID and/or device address and address type already exist in the + * device queue, but the bearer differs from the existing one, add operation + * will also be successful and it will update the provision bearer supported by + * the device. + */ +int bt_mesh_provisioner_add_unprov_dev(struct bt_mesh_unprov_dev_add *add_dev, uint8_t flags); + +/** @brief Provision an unprovisioned device with fixed unicast address. + * + * @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 + * @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 BLE_MESH_PROV_ADV or BLE_MESH_PROV_GATT + */ +int bt_mesh_provisioner_prov_device_with_addr(const uint8_t uuid[16], const uint8_t addr[6], + uint8_t addr_type, bt_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 + * + * @param[in] del_dev: Pointer to the structure containing the device information + * + * @return Zero on success or (negative) error code otherwise. + */ +int bt_mesh_provisioner_delete_device(struct bt_mesh_device_delete *del_dev); + +/** + * @brief This function sets a part of the device UUID for comparison before + * starting to provision the device. + * + * @param[in] offset: offset of the device UUID to be compared + * @param[in] length: length of the device UUID to be compared + * @param[in] match: value to be compared + * @param[in] prov_flag: flags indicate if uuid_match advertising packets are received, after that + * the device will be provisioned at once or reported to the application layer + * + * @return Zero - success, otherwise - fail + */ +int bt_mesh_provisioner_set_dev_uuid_match(uint8_t offset, uint8_t length, + const uint8_t *match, bool prov_flag); + +/** @brief Callback for provisioner receiving advertising packet from unprovisioned devices which are + * not in the unprovisioned device queue. + * + * Report on the unprovisioned device beacon and mesh provisioning service advertising data to application layer + * + * @param addr Unprovisioned device address pointer + * @param addr_type Unprovisioned device address type + * @param dev_uuid Unprovisioned device device UUID pointer + * @param bearer Advertising packet received from PB-GATT or PB-ADV bearer + * @param adv_type Adv packet type, currently this is not used and we can use bearer to device + * the adv_type(ADV_IND or ADV_NONCONN_IND). This parameter will be used, when + * scan response data will be supported. + * @param rssi RSSI of the received advertising packet + * + */ +typedef void (*unprov_adv_pkt_cb_t)(const uint8_t addr[6], const uint8_t addr_type, + const uint8_t adv_type, const uint8_t dev_uuid[16], + uint16_t oob_info, bt_mesh_prov_bearer_t bearer, int8_t rssi); + +/** + * @brief This function registers the callback which notifies the application + * layer of the received mesh provisioning or unprovisioned device + * beacon advertizing packets (from devices not in the unprov device queue). + * + * @param[in] cb: Callback of the notifying adv pkts function + * + * @return Zero - success, otherwise - fail + */ +int bt_mesh_provisioner_adv_pkt_cb_register(unprov_adv_pkt_cb_t cb); + +/** + * @brief This function changes net_idx or flags or iv_index used in provisioning data. + * + * @param[in] info: Pointer of structure containing net_idx or flags or iv_index + * + * @return Zero - success, otherwise - fail + */ +int bt_mesh_provisioner_set_prov_data_info(struct bt_mesh_prov_data_info *info); + +/** + * @brief This function initializes the provisioning information needed by Provisioner, + * including NetKey Index, flags, IV Index, etc. + * + * @return Zero - success, otherwise - fail + */ +int bt_mesh_provisioner_init_prov_info(void); + +/** + * @brief This function sets the provisioning bearer type used by Provisioner. + * + * @param[in] bearers: Provisioning bearer type + * @param[in] clear: Indicate if the corresponding bearer type will be cleared + * + * @return None + */ +void bt_mesh_provisioner_set_prov_bearer(bt_mesh_prov_bearer_t bearers, bool clear); + +/** + * @brief This function gets the provisioning bearer type used by Provisioner. + * + * @return Currently supported provisioning bearer type + */ +bt_mesh_prov_bearer_t bt_mesh_provisioner_get_prov_bearer(void); + +/** + * @brief This function sets the Static OOB value used by Provisioner. + * + * @param[in] value: Static OOB value + * @param[in] length: Static OOB value length + * + * @return Zero - success, otherwise - fail + */ +int bt_mesh_provisioner_set_static_oob_value(const uint8_t *value, uint8_t length); + +/** + * @brief This function gets the unicast address of primary element of Provisioner. + * + * @return Unicast address of primary element of Provisioner. + */ +uint16_t bt_mesh_provisioner_get_primary_elem_addr(void); + +/** + * @brief This function sets the unicast address of primary element of Provisioner. + * + * @param[in] addr: unicast address of primary element + * + * @return Zero - success, otherwise - fail + */ +int bt_mesh_provisioner_set_primary_elem_addr(uint16_t addr); + +/** + * @brief This function is used to update next allocated address by Provisioner. + * + * @note This function is used for mesh internal test. + * + * @param[in] unicast_addr: unicast address of the node + * @param[in] element_num: element count of the node + * + * @return Zero - success, otherwise - fail + */ +int bt_mesh_test_provisioner_update_alloc_addr(uint16_t unicast_addr, uint16_t element_num); + +/** + * @brief This function is called to input number/string out-put by unprovisioned device. + * + * @param[in] idx The provisioning link index + * @param[in] val Pointer of the input number/string + * @param[in] num_flag Flag indicates if it is a number or string + * + * @return Zero - success, otherwise - fail + */ +int bt_mesh_provisioner_set_oob_input_data(const uint8_t idx, const uint8_t *val, bool num_flag); + +/** + * @brief This function is called to output number/string which will be input by unprovisioned device. + * + * @param[in] idx The provisioning link index + * @param[in] num Pointer of the output number/string + * @param[in] size Size of the output number/string + * @param[in] num_flag Flag indicates if it is a number or string + * + * @return Zero - success, otherwise - fail + */ +int bt_mesh_provisioner_set_oob_output_data(const uint8_t idx, const uint8_t *num, + uint8_t size, bool num_flag); + +/** + * @brief This function is called to read unprovisioned device's oob public key. + * + * @param[in] idx The provisioning link index + * @param[in] pub_key_x Unprovisioned device's Public Key X + * @param[in] pub_key_y Unprovisioned device's Public Key Y + * + * @return Zero - success, otherwise - fail + */ +int bt_mesh_provisioner_read_oob_pub_key(const uint8_t idx, const uint8_t pub_key_x[32], + const uint8_t pub_key_y[32]); + +/* The following APIs are for fast provisioning */ + +/** + * @brief This function is called to set fast_prov_flag. + * + * @param[in] enable: Enable or disable fast provisioning + * + * @return None + */ +void bt_mesh_provisioner_fast_prov_enable(bool enable); + +/** + * @brief This function is called to set netkey index used for fast provisioning. + * + * @param[in] net_idx: Netkey index + * + * @return None + */ +void bt_mesh_provisioner_set_fast_prov_net_idx(uint16_t net_idx); + +/** + * @brief This function is called to get netkey index used for fast provisioning. + * + * @return net_idx of fast provisioning + */ +uint16_t bt_mesh_provisioner_get_fast_prov_net_idx(void); + +/** + * @brief This function is called to set unicast address range used for fast provisioning. + * + * @param[in] min: Minimum unicast address + * @param[in] max: Maximum unicast address + * + * @return status for set unicast address range message + */ +uint8_t bt_mesh_set_fast_prov_unicast_addr_range(uint16_t min, uint16_t max); + +/** + * @brief This function is called to set flags & iv_index used for fast provisioning. + * + * @param[in] flags: Key refresh flag and iv update flag + * @param[in] iv_index: IV index + * + * @return None + */ +void bt_mesh_set_fast_prov_flags_iv_index(uint8_t flags, uint32_t iv_index); + +#ifdef __cplusplus +} +#endif + +#endif /* _PROVISIONER_PROV_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/proxy_client.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/proxy_client.h new file mode 100644 index 00000000000..3c25a9b104d --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/proxy_client.h @@ -0,0 +1,112 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _PROXY_CLIENT_H_ +#define _PROXY_CLIENT_H_ + +#include "net.h" +#include "mesh_bearer_adapt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define BLE_MESH_PROXY_ADV_NET_ID 0x00 +#define BLE_MESH_PROXY_ADV_NODE_ID 0x01 + +#define BLE_MESH_PROXY_NET_PDU 0x00 +#define BLE_MESH_PROXY_BEACON 0x01 +#define BLE_MESH_PROXY_CONFIG 0x02 +#define BLE_MESH_PROXY_PROV 0x03 + +#define BLE_MESH_PROXY_CFG_FILTER_SET 0x00 +#define BLE_MESH_PROXY_CFG_FILTER_ADD 0x01 +#define BLE_MESH_PROXY_CFG_FILTER_REMOVE 0x02 +#define BLE_MESH_PROXY_CFG_FILTER_STATUS 0x03 + +typedef union { + struct { + uint8_t net_id[8]; + uint16_t net_idx; + } net_id; + struct { + uint16_t src; + } node_id; +} bt_mesh_proxy_adv_ctx_t; + +struct bt_mesh_proxy_net_pdu { + struct net_buf_simple *val; +}; + +struct bt_mesh_proxy_cfg_pdu { + uint8_t opcode; + union { + struct cfg_filter_set { + uint8_t filter_type; + } set; + struct cfg_addr_add { + uint16_t *addr; + uint16_t addr_num; + } add; + struct cfg_addr_remove { + uint16_t *addr; + uint16_t addr_num; + } remove; + }; +}; + +typedef struct { + uint8_t type; + union { + struct bt_mesh_proxy_net_pdu net; + struct bt_mesh_proxy_cfg_pdu cfg; + }; +} bt_mesh_proxy_client_pdu_t; + +int bt_mesh_proxy_client_send(struct bt_mesh_conn *conn, uint8_t type, + struct net_buf_simple *msg); + +int bt_mesh_proxy_client_prov_enable(void); +int bt_mesh_proxy_client_prov_disable(void); + +int bt_mesh_proxy_client_gatt_enable(void); +int bt_mesh_proxy_client_gatt_disable(void); + +typedef void (*proxy_client_recv_adv_cb_t)(const bt_mesh_addr_t *addr, uint8_t type, + bt_mesh_proxy_adv_ctx_t *ctx, int8_t rssi); +typedef void (*proxy_client_connect_cb_t)(const bt_mesh_addr_t *addr, + uint8_t conn_handle, uint16_t net_idx); +typedef void (*proxy_client_disconnect_cb_t)(const bt_mesh_addr_t *addr, uint8_t conn_handle, + uint16_t net_idx, uint8_t reason); +typedef void (*proxy_client_recv_filter_status_cb_t)(uint8_t conn_handle, uint16_t src, uint16_t net_idx, + uint8_t filter_type, uint16_t list_size); + +void bt_mesh_proxy_client_set_adv_recv_cb(proxy_client_recv_adv_cb_t cb); +void bt_mesh_proxy_client_set_conn_cb(proxy_client_connect_cb_t cb); +void bt_mesh_proxy_client_set_disconn_cb(proxy_client_disconnect_cb_t cb); +void bt_mesh_proxy_client_set_filter_status_cb(proxy_client_recv_filter_status_cb_t cb); + +void bt_mesh_proxy_client_gatt_adv_recv(struct net_buf_simple *buf, + const bt_mesh_addr_t *addr, int8_t rssi); + +int bt_mesh_proxy_client_connect(const uint8_t addr[6], uint8_t addr_type, uint16_t net_idx); +int bt_mesh_proxy_client_disconnect(uint8_t conn_handle); + +bool bt_mesh_proxy_client_beacon_send(struct bt_mesh_subnet *sub); + +bool bt_mesh_proxy_client_relay(struct net_buf_simple *buf, uint16_t dst); + +int bt_mesh_proxy_client_cfg_send(uint8_t conn_handle, uint16_t net_idx, + struct bt_mesh_proxy_cfg_pdu *pdu); + +int bt_mesh_proxy_client_init(void); +int bt_mesh_proxy_client_deinit(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _PROXY_CLIENT_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/proxy_server.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/proxy_server.h new file mode 100644 index 00000000000..d84dbd0ecfa --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/proxy_server.h @@ -0,0 +1,80 @@ +/* Bluetooth Mesh */ + +/* + * SPDX-FileCopyrightText: 2017 Intel Corporation + * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _PROXY_H_ +#define _PROXY_H_ + +#include "net.h" +#include "mesh_bearer_adapt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define BLE_MESH_PROXY_NET_PDU 0x00 +#define BLE_MESH_PROXY_BEACON 0x01 +#define BLE_MESH_PROXY_CONFIG 0x02 +#define BLE_MESH_PROXY_PROV 0x03 + +#if CONFIG_BLE_MESH_PROXY +/** + * Device Name Characteristic: + * 1. For iOS, when it tries to get the value of Device Name Characteristic, the PDU + * "Read By Type Request" will be used, and the valid length of corresponding + * response is 19 (23 - 1 - 1 - 2). + * 2. For Android, when it tries to get the value of Device Name Characteristic, the + * PDU "Read Request" will be used, and the valid length of corresponding response + * is 22 (23 - 1). + */ +#define DEVICE_NAME_SIZE MIN((BLE_MESH_GATT_DEF_MTU_SIZE - 4), (BLE_MESH_GAP_ADV_MAX_LEN - 2)) +#else +/* For Scan Response Data, the maximum length is 29 (31 - 1 - 1) currently. */ +#define DEVICE_NAME_SIZE (BLE_MESH_GAP_ADV_MAX_LEN - 2) +#endif + +typedef void (*proxy_server_connect_cb_t)(uint8_t conn_handle); +typedef void (*proxy_server_disconnect_cb_t)(uint8_t conn_handle, uint8_t reason); + +int bt_mesh_set_device_name(const char *name); + +int bt_mesh_proxy_server_send(struct bt_mesh_conn *conn, uint8_t type, + struct net_buf_simple *msg); + +int bt_mesh_proxy_server_prov_enable(void); +int bt_mesh_proxy_server_prov_disable(bool disconnect); + +void bt_mesh_proxy_server_set_conn_cb(proxy_server_connect_cb_t cb); +void bt_mesh_proxy_server_set_disconn_cb(proxy_server_disconnect_cb_t cb); + +int bt_mesh_proxy_server_gatt_enable(void); +int bt_mesh_proxy_server_gatt_disable(void); + +void bt_mesh_proxy_server_gatt_disconnect(void); + +void bt_mesh_proxy_server_beacon_send(struct bt_mesh_subnet *sub); + +struct net_buf_simple *bt_mesh_proxy_server_get_buf(void); + +int32_t bt_mesh_proxy_server_adv_start(void); +void bt_mesh_proxy_server_adv_stop(void); + +void bt_mesh_proxy_server_identity_start(struct bt_mesh_subnet *sub); +void bt_mesh_proxy_server_identity_stop(struct bt_mesh_subnet *sub); + +bool bt_mesh_proxy_server_relay(struct net_buf_simple *buf, uint16_t dst); +void bt_mesh_proxy_server_addr_add(struct net_buf_simple *buf, uint16_t addr); + +int bt_mesh_proxy_server_init(void); +int bt_mesh_proxy_server_deinit(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _PROXY_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/scan.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/scan.h new file mode 100644 index 00000000000..2d999565fad --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/scan.h @@ -0,0 +1,39 @@ +/* Bluetooth Mesh */ + +/* + * SPDX-FileCopyrightText: 2017 Intel Corporation + * SPDX-FileContributor: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _SCAN_H_ +#define _SCAN_H_ + +#include "mesh_bearer_adapt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +const bt_mesh_addr_t *bt_mesh_get_unprov_dev_addr(void); + +int bt_mesh_scan_enable(void); + +int bt_mesh_scan_disable(void); + +int bt_mesh_scan_with_wl_enable(void); + +struct bt_mesh_ble_scan_param { + uint32_t duration; +}; + +int bt_mesh_start_ble_scan(struct bt_mesh_ble_scan_param *param); + +int bt_mesh_stop_ble_scan(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _SCAN_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/settings.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/settings.h new file mode 100644 index 00000000000..dd112d70dd9 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/settings.h @@ -0,0 +1,79 @@ +/* + * SPDX-FileCopyrightText: 2018 Intel Corporation + * SPDX-FileContributor: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _SETTINGS_H_ +#define _SETTINGS_H_ + +#include "net.h" +#include "provisioner_main.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define BLE_MESH_SETTINGS_ROLE_NONE 0 +#define BLE_MESH_SETTINGS_ROLE_NODE (BIT(BLE_MESH_NODE)) +#define BLE_MESH_SETTINGS_ROLE_PROV (BIT(BLE_MESH_PROVISIONER)) +#define BLE_MESH_SETTINGS_ROLE_BIT_MASK (BIT(BLE_MESH_NODE) | BIT(BLE_MESH_PROVISIONER)) + +void bt_mesh_store_role(void); +void bt_mesh_store_net(void); +void bt_mesh_store_iv(bool only_duration); +void bt_mesh_store_seq(void); +void bt_mesh_clear_seq(void); +void bt_mesh_store_rpl(struct bt_mesh_rpl *rpl); +void bt_mesh_store_subnet(struct bt_mesh_subnet *sub); +void bt_mesh_store_app_key(struct bt_mesh_app_key *key); +void bt_mesh_store_hb_pub(void); +void bt_mesh_store_cfg(void); +void bt_mesh_store_mod_bind(struct bt_mesh_model *mod); +void bt_mesh_store_mod_sub(struct bt_mesh_model *mod); +void bt_mesh_store_mod_pub(struct bt_mesh_model *mod); +void bt_mesh_store_label(void); + +void bt_mesh_clear_role(void); +void bt_mesh_clear_net(void); +void bt_mesh_clear_subnet(struct bt_mesh_subnet *sub); +void bt_mesh_clear_app_key(struct bt_mesh_app_key *key); +void bt_mesh_clear_rpl(void); + +#if CONFIG_BLE_MESH_PROVISIONER +void bt_mesh_store_prov_info(uint16_t primary_addr, uint16_t alloc_addr); +void bt_mesh_clear_prov_info(void); +void bt_mesh_store_p_net_idx(void); +void bt_mesh_clear_p_net_idx(void); +void bt_mesh_store_p_app_idx(void); +void bt_mesh_clear_p_app_idx(void); +void bt_mesh_store_p_subnet(struct bt_mesh_subnet *sub); +void bt_mesh_store_p_app_key(struct bt_mesh_app_key *key); +void bt_mesh_clear_p_subnet(uint16_t net_idx); +void bt_mesh_clear_p_app_key(uint16_t app_idx); +void bt_mesh_clear_rpl_single(uint16_t src); +void bt_mesh_store_node_info(struct bt_mesh_node *node); +void bt_mesh_clear_node_info(uint16_t unicast_addr); +void bt_mesh_store_node_name(struct bt_mesh_node *node); +void bt_mesh_store_node_comp_data(struct bt_mesh_node *node); +#endif + +void bt_mesh_settings_lock(void); +void bt_mesh_settings_unlock(void); + +int settings_core_init(void); +int settings_core_load(void); +int settings_core_commit(void); +int settings_core_deinit(void); +int settings_core_erase(void); + +int bt_mesh_settings_init(void); +int bt_mesh_settings_deinit(bool erase); +void bt_mesh_settings_reset(bool erase); + +#ifdef __cplusplus +} +#endif + +#endif /* _SETTINGS_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/settings_uid.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/settings_uid.h new file mode 100644 index 00000000000..ef7dc93bc29 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/settings_uid.h @@ -0,0 +1,39 @@ +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _SETTINGS_UID_H_ +#define _SETTINGS_UID_H_ + +#include "mesh_types.h" +#include "settings_nvs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +int settings_uid_init(void); +int settings_uid_load(void); +int settings_uid_deinit(void); +int settings_uid_erase(void); + +int bt_mesh_provisioner_open_settings_with_index(uint8_t index); +int bt_mesh_provisioner_open_settings_with_uid(const char *id, uint8_t *index); +int bt_mesh_provisioner_close_settings_with_index(uint8_t index, bool erase); +int bt_mesh_provisioner_close_settings_with_uid(const char *id, bool erase, uint8_t *index); +int bt_mesh_provisioner_delete_settings_with_index(uint8_t index); +int bt_mesh_provisioner_delete_settings_with_uid(const char *id, uint8_t *index); + +const char *bt_mesh_provisioner_get_settings_uid(uint8_t index); +uint8_t bt_mesh_provisioner_get_settings_index(const char *id); +uint8_t bt_mesh_provisioner_get_free_settings_count(void); + +int bt_mesh_provisioner_direct_erase_settings(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _SETTINGS_UID_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/storage/settings_nvs.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/storage/settings_nvs.h new file mode 100644 index 00000000000..a82392cab61 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/storage/settings_nvs.h @@ -0,0 +1,67 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _BLE_MESH_SETTINGS_NVS_H_ +#define _BLE_MESH_SETTINGS_NVS_H_ + +#include "nvs_flash.h" +#include "mesh_buf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef nvs_handle_t bt_mesh_nvs_handle_t; + +#define SETTINGS_ITEM_SIZE sizeof(uint16_t) + +#define BLE_MESH_GET_ELEM_IDX(x) ((uint8_t)((x) >> 8)) +#define BLE_MESH_GET_MODEL_IDX(x) ((uint8_t)(x)) +#define BLE_MESH_GET_MODEL_KEY(a, b) ((uint16_t)(((uint16_t)((a) << 8)) | (b))) + +int bt_mesh_settings_nvs_open(const char* name, bt_mesh_nvs_handle_t *handle); +void bt_mesh_settings_nvs_close(bt_mesh_nvs_handle_t handle); + +void bt_mesh_settings_init_foreach(void); +void bt_mesh_settings_deinit_foreach(bool erase); + +int bt_mesh_settings_direct_open(bt_mesh_nvs_handle_t *handle); +void bt_mesh_settings_direct_close(void); + +int bt_mesh_save_settings(bt_mesh_nvs_handle_t handle, const char *key, + const uint8_t *val, size_t len); +int bt_mesh_save_core_settings(const char *key, const uint8_t *val, size_t len); +int bt_mesh_save_uid_settings(const char *key, const uint8_t *val, size_t len); + +int bt_mesh_erase_settings(bt_mesh_nvs_handle_t handle, const char *key); +int bt_mesh_erase_core_settings(const char *key); +int bt_mesh_erase_uid_settings(const char *name); + +int bt_mesh_load_settings(bt_mesh_nvs_handle_t handle, const char *key, + uint8_t *buf, size_t buf_len, bool *exist); +int bt_mesh_load_core_settings(const char *key, uint8_t *buf, size_t buf_len, bool *exist); +int bt_mesh_load_uid_settings(const char *key, uint8_t *buf, size_t buf_len, bool *exist); + +struct net_buf_simple *bt_mesh_get_settings_item(bt_mesh_nvs_handle_t handle, const char *key); +struct net_buf_simple *bt_mesh_get_core_settings_item(const char *key); +struct net_buf_simple *bt_mesh_get_uid_settings_item(const char *key); + +int bt_mesh_add_settings_item(bt_mesh_nvs_handle_t handle, const char *key, const uint16_t val); +int bt_mesh_add_core_settings_item(const char *key, const uint16_t val); +int bt_mesh_add_uid_settings_item(const char *key, const uint16_t val); + +int bt_mesh_remove_settings_item(bt_mesh_nvs_handle_t handle, const char *key, const uint16_t val); +int bt_mesh_remove_core_settings_item(const char *key, const uint16_t val); +int bt_mesh_remove_uid_settings_item(const char *key, const uint16_t val); + +int bt_mesh_settings_erase_key(bt_mesh_nvs_handle_t handle, const char *key); +int bt_mesh_settings_erase_all(bt_mesh_nvs_handle_t handle); + +#ifdef __cplusplus +} +#endif + +#endif /* _BLE_MESH_SETTINGS_NVS_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/test.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/test.h new file mode 100644 index 00000000000..c02947ac531 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/test.h @@ -0,0 +1,52 @@ +/* Bluetooth Mesh */ + +/* + * SPDX-FileCopyrightText: 2017 Intel Corporation + * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _BLE_MESH_TEST_H_ +#define _BLE_MESH_TEST_H_ + +#include "mesh_bearer_adapt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +int bt_mesh_test(void); + +struct bt_mesh_device_network_info { + uint8_t net_key[16]; + uint16_t net_idx; + uint8_t flags; + uint32_t iv_index; + uint16_t unicast_addr; + uint8_t dev_key[16]; + uint8_t app_key[16]; + uint16_t app_idx; + uint16_t group_addr; +}; + +int bt_mesh_device_auto_enter_network(struct bt_mesh_device_network_info *info); + +/* Before trying to update the white list, users need to make sure that + * one of the following conditions is satisfied: + * 1. BLE scanning is disabled; + * 2. BLE scanning is enabled with scan filter policy disabled; + * If BLE scanning is enabled with scan filter policy enabled, users need + * to stop BLE scanning firstly, then the white list can be updated. + */ +int bt_mesh_test_update_white_list(struct bt_mesh_white_list *wl); + +int bt_mesh_test_start_scanning(bool wl_en); + +int bt_mesh_test_stop_scanning(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _BLE_MESH_TEST_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/transport.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/transport.h new file mode 100644 index 00000000000..015b51e4df4 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_core/transport.h @@ -0,0 +1,128 @@ +/* Bluetooth Mesh */ + +/* + * SPDX-FileCopyrightText: 2017 Intel Corporation + * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _TRANSPORT_H_ +#define _TRANSPORT_H_ + +#include "net.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define TRANS_SEQ_AUTH_NVAL 0xffffffffffffffff + +#define BLE_MESH_SDU_UNSEG_MAX 11 +#define BLE_MESH_CTL_SEG_SDU_MAX 8 +#define BLE_MESH_APP_SEG_SDU_MAX 12 +#define BLE_MESH_TX_SDU_MAX (CONFIG_BLE_MESH_TX_SEG_MAX * 12) + +#define TRANS_SEQ_ZERO_MASK ((uint16_t)BIT_MASK(13)) +#define TRANS_CTL_OP_MASK ((uint8_t)BIT_MASK(7)) +#define TRANS_CTL_OP(data) ((data)[0] & TRANS_CTL_OP_MASK) +#define TRANS_CTL_HDR(op, seg) ((op & TRANS_CTL_OP_MASK) | (seg << 7)) + +#define TRANS_CTL_OP_ACK 0x00 +#define TRANS_CTL_OP_FRIEND_POLL 0x01 +#define TRANS_CTL_OP_FRIEND_UPDATE 0x02 +#define TRANS_CTL_OP_FRIEND_REQ 0x03 +#define TRANS_CTL_OP_FRIEND_OFFER 0x04 +#define TRANS_CTL_OP_FRIEND_CLEAR 0x05 +#define TRANS_CTL_OP_FRIEND_CLEAR_CFM 0x06 +#define TRANS_CTL_OP_FRIEND_SUB_ADD 0x07 +#define TRANS_CTL_OP_FRIEND_SUB_REM 0x08 +#define TRANS_CTL_OP_FRIEND_SUB_CFM 0x09 +#define TRANS_CTL_OP_HEARTBEAT 0x0a + +struct bt_mesh_ctl_friend_poll { + uint8_t fsn; +} __packed; + +struct bt_mesh_ctl_friend_update { + uint8_t flags; + uint32_t iv_index; + uint8_t md; +} __packed; + +struct bt_mesh_ctl_friend_req { + uint8_t criteria; + uint8_t recv_delay; + uint8_t poll_to[3]; + uint16_t prev_addr; + uint8_t num_elem; + uint16_t lpn_counter; +} __packed; + +struct bt_mesh_ctl_friend_offer { + uint8_t recv_win; + uint8_t queue_size; + uint8_t sub_list_size; + int8_t rssi; + uint16_t frnd_counter; +} __packed; + +struct bt_mesh_ctl_friend_clear { + uint16_t lpn_addr; + uint16_t lpn_counter; +} __packed; + +struct bt_mesh_ctl_friend_clear_confirm { + uint16_t lpn_addr; + uint16_t lpn_counter; +} __packed; + +#define BLE_MESH_FRIEND_SUB_MIN_LEN (1 + 2) +struct bt_mesh_ctl_friend_sub { + uint8_t xact; + uint16_t addr_list[5]; +} __packed; + +struct bt_mesh_ctl_friend_sub_confirm { + uint8_t xact; +} __packed; + +uint8_t bt_mesh_get_seg_retrans_num(void); + +int32_t bt_mesh_get_seg_retrans_timeout(uint8_t ttl); + +void bt_mesh_set_hb_sub_dst(uint16_t addr); + +struct bt_mesh_app_key *bt_mesh_app_key_find(uint16_t app_idx); + +bool bt_mesh_tx_in_progress(void); + +void bt_mesh_rx_reset(bool erase); +void bt_mesh_tx_reset(void); +void bt_mesh_rx_reset_single(uint16_t src); +void bt_mesh_tx_reset_single(uint16_t dst); + +int bt_mesh_ctl_send(struct bt_mesh_net_tx *tx, uint8_t ctl_op, void *data, + size_t data_len, const struct bt_mesh_send_cb *cb, + void *cb_data); + +int bt_mesh_trans_send(struct bt_mesh_net_tx *tx, struct net_buf_simple *msg, + const struct bt_mesh_send_cb *cb, void *cb_data); + +int bt_mesh_trans_recv(struct net_buf_simple *buf, struct bt_mesh_net_rx *rx); + +void bt_mesh_trans_init(void); +void bt_mesh_trans_deinit(bool erase); + +bool bt_mesh_rpl_check(struct bt_mesh_net_rx *rx, struct bt_mesh_rpl **match); + +void bt_mesh_heartbeat_send(void); + +int bt_mesh_app_key_get(const struct bt_mesh_subnet *subnet, uint16_t app_idx, + const uint8_t **key, uint8_t *aid, uint8_t role, uint16_t dst); + +#ifdef __cplusplus +} +#endif + +#endif /* _TRANSPORT_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_models/client/include/client_common.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_models/client/include/client_common.h new file mode 100644 index 00000000000..5d2bc64bec6 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_models/client/include/client_common.h @@ -0,0 +1,122 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _CLIENT_COMMON_H_ +#define _CLIENT_COMMON_H_ + +#include "mesh_access.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** Client model opcode pair table */ +typedef struct { + uint32_t cli_op; /* Client message opcode */ + uint32_t status_op; /* Corresponding status message opcode */ +} bt_mesh_client_op_pair_t; + +/** Client model user data context */ +typedef struct { + /** Pointer to the client model */ + struct bt_mesh_model *model; + + /** Size of the opcode pair table */ + int op_pair_size; + + /** Pointer to the opcode pair table */ + const bt_mesh_client_op_pair_t *op_pair; + + /** + * @brief This function is a callback function used to push the received unsolicited + * messages to the application layer. + * + * @param[in] opcode: Opcode of received status message + * @param[in] model: Model associated with the status message + * @param[in] ctx: Context information of the status message + * @param[in] buf: Buffer contains the status message value + * + * @return None + */ + void (*publish_status)(uint32_t opcode, struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf); + + /** Pointer to the internal data of client model */ + void *internal_data; + + /** Role of the device to which the client model belongs */ + uint8_t msg_role; +} bt_mesh_client_user_data_t; + +/** Client model internal data context */ +typedef struct { + sys_slist_t queue; +} bt_mesh_client_internal_data_t; + +/** Client model sending message related context */ +typedef struct { + sys_snode_t client_node; + struct bt_mesh_msg_ctx ctx; /* Message context */ + uint32_t opcode; /* Message opcode */ + uint32_t op_pending; /* Expected status message opcode */ + int32_t timeout; /* Calculated message timeout value */ + struct k_delayed_work timer; /* Time used to get response. Only for internal use. */ +} bt_mesh_client_node_t; + +/** Client model sending message parameters */ +typedef struct { + uint32_t opcode; /* Message opcode */ + struct bt_mesh_model *model; /* Pointer to the client model */ + struct bt_mesh_msg_ctx ctx; /* Message context */ + int32_t msg_timeout; /* Time to get corresponding response */ + uint8_t msg_role; /* Role (Node/Provisioner) of the device */ + const struct bt_mesh_send_cb *cb; /* User defined callback function */ + void *cb_data; /* User defined callback value */ +} bt_mesh_client_common_param_t; + +void bt_mesh_client_model_lock(void); + +void bt_mesh_client_model_unlock(void); + +int bt_mesh_client_init(struct bt_mesh_model *model); + +int bt_mesh_client_deinit(struct bt_mesh_model *model); + +/** + * @brief Check if the msg received by client model is a publish msg or not + * + * @param model Mesh (client) Model that the message belongs to. + * @param ctx Message context, includes keys, TTL, etc. + * @param buf The message buffer + * @param need_pub Indicate if the msg sent to app layer as a publish msg + * @return 0 on success, or (negative) error code on failure. + */ +bt_mesh_client_node_t *bt_mesh_is_client_recv_publish_msg(struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf, bool need_pub); + +int bt_mesh_client_send_msg(bt_mesh_client_common_param_t *param, + struct net_buf_simple *msg, bool need_ack, + k_work_handler_t timer_handler); + +int bt_mesh_client_free_node(bt_mesh_client_node_t *node); + +int bt_mesh_client_clear_list(void *data); + +/** + * @brief Set role of the client model for internal use. + * + * @param[in] model: Pointer to the client model + * @param[in] role: Role of the device + * + * @return Zero - success, otherwise - fail + */ +int bt_mesh_set_client_model_role(struct bt_mesh_model *model, uint8_t role); + +#ifdef __cplusplus +} +#endif + +#endif /* _CLIENT_COMMON_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_models/client/include/generic_client.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_models/client/include/generic_client.h new file mode 100644 index 00000000000..1e8a45e57f0 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_models/client/include/generic_client.h @@ -0,0 +1,408 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** @file + * @brief Bluetooth Mesh Generic Client Model APIs. + */ + +#ifndef _GENERIC_CLIENT_H_ +#define _GENERIC_CLIENT_H_ + +#include "client_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Generic client model common structure */ +typedef bt_mesh_client_user_data_t bt_mesh_generic_client_t; +typedef bt_mesh_client_internal_data_t generic_internal_data_t; + +/* Generic Client Model Callback */ +extern const struct bt_mesh_model_cb bt_mesh_generic_client_cb; + +/* Generic OnOff Client Model Context */ +extern const struct bt_mesh_model_op bt_mesh_gen_onoff_cli_op[]; + +/** @def BLE_MESH_MODEL_GEN_ONOFF_CLI + * + * Define a new generic onoff client model. Note that this API + * needs to be repeated for each element which the application + * wants to have a generic onoff client model on. + * @param cli_pub Pointer to a unique struct bt_mesh_model_pub. + * @param cli_data Pointer to a unique struct bt_mesh_gen_onoff_cli. + * + * @return New generic onoff client model instance. + */ +#define BLE_MESH_MODEL_GEN_ONOFF_CLI(cli_pub, cli_data) \ + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_GEN_ONOFF_CLI, \ + bt_mesh_gen_onoff_cli_op, cli_pub, cli_data, &bt_mesh_generic_client_cb) + +typedef bt_mesh_client_user_data_t bt_mesh_gen_onoff_client_t; + +struct bt_mesh_gen_onoff_status { + bool op_en; /* Indicate whether optional parameters included */ + uint8_t present_onoff; /* Present value of Generic OnOff state */ + uint8_t target_onoff; /* Target value of Generic OnOff state (optional) */ + uint8_t remain_time; /* Time to complete state transition (C.1) */ +}; + +struct bt_mesh_gen_onoff_set { + bool op_en; /* Indicate whether optional parameters included */ + uint8_t onoff; /* Target value of Generic OnOff state */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ +}; + +/* Generic Level Client Model Context */ +extern const struct bt_mesh_model_op bt_mesh_gen_level_cli_op[]; + +/** @def BLE_MESH_MODEL_GEN_LEVEL_CLI + * + * Define a new generic level client model. Note that this API + * needs to be repeated for each element which the application + * wants to have a generic level client model on. + * @param cli_pub Pointer to a unique struct bt_mesh_model_pub. + * @param cli_data Pointer to a unique struct bt_mesh_gen_level_cli. + * + * @return New generic level client model instance. + */ +#define BLE_MESH_MODEL_GEN_LEVEL_CLI(cli_pub, cli_data) \ + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_GEN_LEVEL_CLI, \ + bt_mesh_gen_level_cli_op, cli_pub, cli_data, &bt_mesh_generic_client_cb) + +typedef bt_mesh_client_user_data_t bt_mesh_gen_level_client_t; + +struct bt_mesh_gen_level_status { + bool op_en; /* Indicate whether optional parameters included */ + int16_t present_level; /* Present value of Generic Level state */ + int16_t target_level; /* Target value of the Generic Level state (optional) */ + uint8_t remain_time; /* Time to complete state transition (C.1) */ +}; + +struct bt_mesh_gen_level_set { + bool op_en; /* Indicate whether optional parameters included */ + int16_t level; /* Target value of Generic Level state */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ +}; + +struct bt_mesh_gen_delta_set { + bool op_en; /* Indicate whether optional parameters included */ + int32_t delta_level; /* Delta change of Generic Level state */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ +}; + +struct bt_mesh_gen_move_set { + bool op_en; /* Indicate whether optional parameters included */ + int16_t delta_level; /* Delta Level step to calculate Move speed for Generic Level state */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ +}; + +/* Generic Default Transition Time Client Model Context */ +extern const struct bt_mesh_model_op bt_mesh_gen_def_trans_time_cli_op[]; + +/** @def BLE_MESH_MODEL_GEN_DEF_TRANS_TIME_CLI + * + * Define a new generic default transition time client model. Note + * that this API needs to be repeated for each element that the + * application wants to have a generic default transition client + * model on. + * @param cli_pub Pointer to a unique struct bt_mesh_model_pub. + * @param cli_data Pointer to a unique struct bt_mesh_gen_def_trans_time_cli. + * + * @return New generic default transition time client model instance. + */ +#define BLE_MESH_MODEL_GEN_DEF_TRANS_TIME_CLI(cli_pub, cli_data) \ + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_CLI, \ + bt_mesh_gen_def_trans_time_cli_op, cli_pub, cli_data, &bt_mesh_generic_client_cb) + +typedef bt_mesh_client_user_data_t bt_mesh_gen_def_trans_time_client_t; + +struct bt_mesh_gen_def_trans_time_set { + uint8_t trans_time; /* The value of the Generic Default Transition Time state */ +}; + +struct bt_mesh_gen_def_trans_time_status { + uint8_t trans_time; /* The value of the Generic Default Transition Time state */ +}; + +/* Generic Power OnOff Client Model Context */ +extern const struct bt_mesh_model_op bt_mesh_gen_power_onoff_cli_op[]; + +/** @def BLE_MESH_MODEL_GEN_POWER_ONOFF_CLI + * + * Define a new generic power onoff client model. Note that this API + * needs to be repeated for each element which the application wants + * to have a generic power onoff client model on. + * @param cli_pub Pointer to a unique struct bt_mesh_model_pub. + * @param cli_data Pointer to a unique struct bt_mesh_gen_power_onoff_cli. + * + * @return New generic power onoff client model instance. + */ +#define BLE_MESH_MODEL_GEN_POWER_ONOFF_CLI(cli_pub, cli_data) \ + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_CLI, \ + bt_mesh_gen_power_onoff_cli_op, cli_pub, cli_data, &bt_mesh_generic_client_cb) + +typedef bt_mesh_client_user_data_t bt_mesh_gen_power_onoff_client_t; + +struct bt_mesh_gen_onpowerup_set { + uint8_t onpowerup; /* The value of the Generic OnPowerUp state */ +}; + +struct bt_mesh_gen_onpowerup_status { + uint8_t onpowerup; /* The value of the Generic OnPowerUp state */ +}; + +/* Generic Power Level Client Model Context */ +extern const struct bt_mesh_model_op bt_mesh_gen_power_level_cli_op[]; + +/** @def BLE_MESH_MODEL_GEN_POWER_LEVEL_CLI + * + * Define a new generic power level client model. Note that this API + * needs to be repeated for each element which the application wants + * to have a generic power level client model on. + * @param cli_pub Pointer to a unique struct bt_mesh_model_pub. + * @param cli_data Pointer to a unique struct bt_mesh_gen_power_level_cli. + * + * @return New generic power level client model instance. + */ +#define BLE_MESH_MODEL_GEN_POWER_LEVEL_CLI(cli_pub, cli_data) \ + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_CLI, \ + bt_mesh_gen_power_level_cli_op, cli_pub, cli_data, &bt_mesh_generic_client_cb) + +typedef bt_mesh_client_user_data_t bt_mesh_gen_power_level_client_t; + +struct bt_mesh_gen_power_level_status { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t present_power; /* Present value of Generic Power Actual state */ + uint16_t target_power; /* Target value of Generic Power Actual state (optional) */ + uint8_t remain_time; /* Time to complete state transition (C.1) */ +}; + +struct bt_mesh_gen_power_last_status { + uint16_t power; /* The value of the Generic Power Last state */ +}; + +struct bt_mesh_gen_power_default_status { + uint16_t power; /* The value of the Generic Default Last state */ +}; + +struct bt_mesh_gen_power_range_status { + uint8_t status_code; /* Status Code for the requesting message */ + 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 */ +}; + +struct bt_mesh_gen_power_level_set { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t power; /* Target value of Generic Power Actual state */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ +}; + +struct bt_mesh_gen_power_default_set { + uint16_t power; /* The value of the Generic Power Default state */ +}; + +struct bt_mesh_gen_power_range_set { + 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 */ +}; + +/* Generic Battery Client Model Context */ +extern const struct bt_mesh_model_op bt_mesh_gen_battery_cli_op[]; + +/** @def BLE_MESH_MODEL_GEN_BATTERY_CLI + * + * Define a new generic battery client model. Note that this API + * needs to be repeated for each element which the application + * wants to have a generic battery client model on. + * @param cli_pub Pointer to a unique struct bt_mesh_model_pub. + * @param cli_data Pointer to a unique struct bt_mesh_gen_battery_cli. + * + * @return New generic battery client model instance. + */ +#define BLE_MESH_MODEL_GEN_BATTERY_CLI(cli_pub, cli_data) \ + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_GEN_BATTERY_CLI, \ + bt_mesh_gen_battery_cli_op, cli_pub, cli_data, &bt_mesh_generic_client_cb) + +typedef bt_mesh_client_user_data_t bt_mesh_gen_battery_client_t; + +struct bt_mesh_gen_battery_status { + uint32_t battery_level : 8; /* Value of Generic Battery Level state */ + uint32_t time_to_discharge : 24; /* Value of Generic Battery Time to Discharge state */ + uint32_t time_to_charge : 24; /* Value of Generic Battery Time to Charge state */ + uint32_t flags : 8; /* Value of Generic Battery Flags state */ +}; + +/* Generic Location Client Model Context */ +extern const struct bt_mesh_model_op bt_mesh_gen_location_cli_op[]; + +/** @def BLE_MESH_MODEL_GEN_LOCATION_CLI + * + * Define a new generic location client model. Note that this API + * needs to be repeated for each element which the application + * wants to have a generic location client model on. + * @param cli_pub Pointer to a unique struct bt_mesh_model_pub. + * @param cli_data Pointer to a unique struct bt_mesh_gen_location_cli. + * + * @return New generic location client model instance. + */ +#define BLE_MESH_MODEL_GEN_LOCATION_CLI(cli_pub, cli_data) \ + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_GEN_LOCATION_CLI, \ + bt_mesh_gen_location_cli_op, cli_pub, cli_data, &bt_mesh_generic_client_cb) + +typedef bt_mesh_client_user_data_t bt_mesh_gen_location_client_t; + +struct bt_mesh_gen_loc_global_status { + int32_t global_latitude; /* Global Coordinates (Latitude) */ + int32_t global_longitude; /* Global Coordinates (Longitude) */ + int16_t global_altitude; /* Global Altitude */ +}; + +struct bt_mesh_gen_loc_local_status { + 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 */ +}; + +struct bt_mesh_gen_loc_global_set { + int32_t global_latitude; /* Global Coordinates (Latitude) */ + int32_t global_longitude; /* Global Coordinates (Longitude) */ + int16_t global_altitude; /* Global Altitude */ +}; + +struct bt_mesh_gen_loc_local_set { + 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 */ +}; + +/* Generic Property Client Model Context */ +extern const struct bt_mesh_model_op bt_mesh_gen_property_cli_op[]; + +/** @def BLE_MESH_MODEL_GEN_LOCATION_CLI + * + * Define a new generic location client model. Note that this API + * needs to be repeated for each element which the application + * wants to have a generic location client model on. + * @param cli_pub Pointer to a unique struct bt_mesh_model_pub. + * @param cli_data Pointer to a unique struct bt_mesh_gen_location_cli. + * + * @return New generic location client model instance. + */ +#define BLE_MESH_MODEL_GEN_PROPERTY_CLI(cli_pub, cli_data) \ + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_GEN_PROP_CLI, \ + bt_mesh_gen_property_cli_op, cli_pub, cli_data, &bt_mesh_generic_client_cb) + +typedef bt_mesh_client_user_data_t bt_mesh_gen_property_client_t; + +struct bt_mesh_gen_user_properties_status { + struct net_buf_simple *user_property_ids; /* Buffer contains a sequence of N User Property IDs */ +}; + +struct bt_mesh_gen_user_property_status { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t user_property_id; /* Property ID identifying a Generic User Property */ + uint8_t user_access; /* Enumeration indicating user access (optional) */ + struct net_buf_simple *user_property_value; /* Raw value for the User Property (C.1) */ +}; + +struct bt_mesh_gen_admin_properties_status { + struct net_buf_simple *admin_property_ids; /* Buffer contains a sequence of N Admin Property IDs */ +}; + +struct bt_mesh_gen_admin_property_status { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t admin_property_id; /* Property ID identifying a Generic Admin Property */ + uint8_t admin_user_access; /* Enumeration indicating user access (optional) */ + struct net_buf_simple *admin_property_value; /* Raw value for the Admin Property (C.1) */ +}; + +struct bt_mesh_gen_manu_properties_status { + struct net_buf_simple *manu_property_ids; /* Buffer contains a sequence of N Manufacturer Property IDs */ +}; + +struct bt_mesh_gen_manu_property_status { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t manu_property_id; /* Property ID identifying a Generic Manufacturer Property */ + uint8_t manu_user_access; /* Enumeration indicating user access (optional) */ + struct net_buf_simple *manu_property_value; /* Raw value for the Manufacturer Property (C.1) */ +}; + +struct bt_mesh_gen_client_properties_status { + struct net_buf_simple *client_property_ids; /* Buffer contains a sequence of N Client Property IDs */ +}; + +struct bt_mesh_gen_user_property_get { + uint16_t user_property_id; /* Property ID identifying a Generic User Property */ +}; + +struct bt_mesh_gen_user_property_set { + uint16_t user_property_id; /* Property ID identifying a Generic User Property */ + struct net_buf_simple *user_property_value; /* Raw value for the User Property */ +}; + +struct bt_mesh_gen_admin_property_get { + uint16_t admin_property_id; /* Property ID identifying a Generic Admin Property */ +}; + +struct bt_mesh_gen_admin_property_set { + uint16_t admin_property_id; /* Property ID identifying a Generic Admin Property */ + uint8_t admin_user_access; /* Enumeration indicating user access */ + struct net_buf_simple *admin_property_value; /* Raw value for the Admin Property */ +}; + +struct bt_mesh_gen_manu_property_get { + uint16_t manu_property_id; /* Property ID identifying a Generic Manufacturer Property */ +}; + +struct bt_mesh_gen_manu_property_set { + uint16_t manu_property_id; /* Property ID identifying a Generic Manufacturer Property */ + uint8_t manu_user_access; /* Enumeration indicating user access */ +}; + +struct bt_mesh_gen_client_properties_get { + uint16_t client_property_id; /* A starting Client Property ID present within an element */ +}; + +/** + * @brief This function is called to get generic states. + * + * @param[in] common: Message common information structure + * @param[in] get: Pointer of generic get message value + * + * @return Zero-success, other-fail + */ +int bt_mesh_generic_client_get_state(bt_mesh_client_common_param_t *common, void *get); + +/** + * @brief This function is called to set generic states. + * + * @param[in] common: Message common information structure + * @param[in] set: Pointer of generic set message value + * + * @return Zero-success, other-fail + */ +int bt_mesh_generic_client_set_state(bt_mesh_client_common_param_t *common, void *set); + +#ifdef __cplusplus +} +#endif + +#endif /* _GENERIC_CLIENT_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_models/client/include/lighting_client.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_models/client/include/lighting_client.h new file mode 100644 index 00000000000..4fcd7f31903 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_models/client/include/lighting_client.h @@ -0,0 +1,440 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** @file + * @brief Bluetooth Mesh Lighting Client Model APIs. + */ + +#ifndef _LIGHTING_CLIENT_H_ +#define _LIGHTING_CLIENT_H_ + +#include "client_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Light client model common structure */ +typedef bt_mesh_client_user_data_t bt_mesh_light_client_t; +typedef bt_mesh_client_internal_data_t light_internal_data_t; + +/* Lighting Client Model Callback */ +extern const struct bt_mesh_model_cb bt_mesh_lighting_client_cb; + +/* Light Lightness Client Model Context */ +extern const struct bt_mesh_model_op bt_mesh_light_lightness_cli_op[]; + +/** @def BLE_MESH_MODEL_LIGHT_LIGHTNESS_CLI + * + * Define a new light lightness client model. Note that this API + * needs to be repeated for each element which the application + * wants to have a light lightness client model on. + * @param cli_pub Pointer to a unique struct bt_mesh_model_pub. + * @param cli_data Pointer to a unique struct bt_mesh_light_lightness_cli. + * + * @return New light lightness client model instance. + */ +#define BLE_MESH_MODEL_LIGHT_LIGHTNESS_CLI(cli_pub, cli_data) \ + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_CLI, \ + bt_mesh_light_lightness_cli_op, cli_pub, cli_data, &bt_mesh_lighting_client_cb) + +typedef bt_mesh_client_user_data_t bt_mesh_light_lightness_client_t; + +struct bt_mesh_light_lightness_status { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t present_lightness; /* Present value of light lightness actual state */ + uint16_t target_lightness; /* Target value of light lightness actual state (optional) */ + uint8_t remain_time; /* Time to complete state transition (C.1) */ +}; + +struct bt_mesh_light_lightness_linear_status { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t present_lightness; /* Present value of light lightness linear state */ + uint16_t target_lightness; /* Target value of light lightness linear state (optional) */ + uint8_t remain_time; /* Time to complete state transition (C.1) */ +}; + +struct bt_mesh_light_lightness_last_status { + uint16_t lightness; /* The value of the Light Lightness Last state */ +}; + +struct bt_mesh_light_lightness_default_status { + uint16_t lightness; /* The value of the Light Lightness default state */ +}; + +struct bt_mesh_light_lightness_range_status { + uint8_t status_code; /* Status Code for the requesting message */ + uint16_t range_min; /* Value of range min field of light lightness range state */ + uint16_t range_max; /* Value of range max field of light lightness range state */ +}; + +struct bt_mesh_light_lightness_set { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t lightness; /* Target value of light lightness actual state */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ +}; + +struct bt_mesh_light_lightness_linear_set { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t lightness; /* Target value of light lightness linear state */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ +}; + +struct bt_mesh_light_lightness_default_set { + uint16_t lightness; /* The value of the Light Lightness Default state */ +}; + +struct bt_mesh_light_lightness_range_set { + uint16_t range_min; /* Value of range min field of light lightness range state */ + uint16_t range_max; /* Value of range max field of light lightness range state */ +}; + +/* Light CTL Client Model Context */ +extern const struct bt_mesh_model_op bt_mesh_light_ctl_cli_op[]; + +/** @def BLE_MESH_MODEL_LIGHT_CTL_CLI + * + * Define a new light CTL client model. Note that this API needs + * to be repeated for each element which the application wants to + * have a light CTL client model on. + * @param cli_pub Pointer to a unique struct bt_mesh_model_pub. + * @param cli_data Pointer to a unique struct bt_mesh_light_ctl_cli. + * + * @return New light CTL client model instance. + */ +#define BLE_MESH_MODEL_LIGHT_CTL_CLI(cli_pub, cli_data) \ + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_LIGHT_CTL_CLI, \ + bt_mesh_light_ctl_cli_op, cli_pub, cli_data, &bt_mesh_lighting_client_cb) + +typedef bt_mesh_client_user_data_t bt_mesh_light_ctl_client_t; + +struct bt_mesh_light_ctl_status { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t present_ctl_lightness; /* Present value of light ctl lightness state */ + uint16_t present_ctl_temperature; /* Present value of light ctl temperature state */ + uint16_t target_ctl_lightness; /* Target value of light ctl lightness state (optional) */ + uint16_t target_ctl_temperature; /* Target value of light ctl temperature state (C.1) */ + uint8_t remain_time; /* Time to complete state transition (C.1) */ +}; + +struct bt_mesh_light_ctl_temperature_status { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t present_ctl_temperature; /* Present value of light ctl temperature state */ + uint16_t present_ctl_delta_uv; /* Present value of light ctl delta UV state */ + uint16_t target_ctl_temperature; /* Target value of light ctl temperature state (optional) */ + uint16_t target_ctl_delta_uv; /* Target value of light ctl delta UV state (C.1) */ + uint8_t remain_time; /* Time to complete state transition (C.1) */ +}; + +struct bt_mesh_light_ctl_temperature_range_status { + uint8_t status_code; /* Status code for the requesting message */ + uint16_t range_min; /* Value of temperature range min field of light ctl temperature range state */ + uint16_t range_max; /* Value of temperature range max field of light ctl temperature range state */ +}; + +struct bt_mesh_light_ctl_default_status { + uint16_t lightness; /* Value of light lightness default state */ + uint16_t temperature; /* Value of light temperature default state */ + int16_t delta_uv; /* Value of light delta UV default state */ +}; + +struct bt_mesh_light_ctl_set { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t ctl_lightness; /* Target value of light ctl lightness state */ + uint16_t ctl_temperature; /* Target value of light ctl temperature state */ + int16_t ctl_delta_uv; /* Target value of light ctl delta UV state */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ +}; + +struct bt_mesh_light_ctl_temperature_set { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t ctl_temperature; /* Target value of light ctl temperature state */ + int16_t ctl_delta_uv; /* Target value of light ctl delta UV state */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ +}; + +struct bt_mesh_light_ctl_temperature_range_set { + uint16_t range_min; /* Value of temperature range min field of light ctl temperature range state */ + uint16_t range_max; /* Value of temperature range max field of light ctl temperature range state */ +}; + +struct bt_mesh_light_ctl_default_set { + uint16_t lightness; /* Value of light lightness default state */ + uint16_t temperature; /* Value of light temperature default state */ + int16_t delta_uv; /* Value of light delta UV default state */ +}; + +/* Light HSL Client Model Context */ +extern const struct bt_mesh_model_op bt_mesh_light_hsl_cli_op[]; + +/** @def BLE_MESH_MODEL_LIGHT_HSL_CLI + * + * Define a new light HSL client model. Note that this API needs + * to be repeated for each element which the application wants to + * have a light HSL client model on. + * @param cli_pub Pointer to a unique struct bt_mesh_model_pub. + * @param cli_data Pointer to a unique struct bt_mesh_light_hsl_cli. + * + * @return New light HSL client model instance. + */ +#define BLE_MESH_MODEL_LIGHT_HSL_CLI(cli_pub, cli_data) \ + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_LIGHT_HSL_CLI, \ + bt_mesh_light_hsl_cli_op, cli_pub, cli_data, &bt_mesh_lighting_client_cb) + +typedef bt_mesh_client_user_data_t bt_mesh_light_hsl_client_t; + +struct bt_mesh_light_hsl_status { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t hsl_lightness; /* Present value of light hsl lightness state */ + uint16_t hsl_hue; /* Present value of light hsl hue state */ + uint16_t hsl_saturation; /* Present value of light hsl saturation state */ + uint8_t remain_time; /* Time to complete state transition (optional) */ +}; + +struct bt_mesh_light_hsl_target_status { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t hsl_lightness_target; /* Target value of light hsl lightness state */ + uint16_t hsl_hue_target; /* Target value of light hsl hue state */ + uint16_t hsl_saturation_target; /* Target value of light hsl saturation state */ + uint8_t remain_time; /* Time to complete state transition (optional) */ +}; + +struct bt_mesh_light_hsl_hue_status { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t present_hue; /* Present value of light hsl hue state */ + uint16_t target_hue; /* Target value of light hsl hue state (optional) */ + uint8_t remain_time; /* Time to complete state transition (C.1) */ +}; + +struct bt_mesh_light_hsl_saturation_status { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t present_saturation; /* Present value of light hsl saturation state */ + uint16_t target_saturation; /* Target value of light hsl saturation state (optional) */ + uint8_t remain_time; /* Time to complete state transition (C.1) */ +}; + +struct bt_mesh_light_hsl_default_status { + uint16_t lightness; /* Value of light lightness default state */ + uint16_t hue; /* Value of light hue default state */ + uint16_t saturation; /* Value of light saturation default state */ +}; + +struct bt_mesh_light_hsl_range_status { + uint8_t status_code; /* Status code for the requesting message */ + uint16_t hue_range_min; /* Value of hue range min field of light hsl hue range state */ + uint16_t hue_range_max; /* Value of hue range max field of light hsl hue range state */ + uint16_t saturation_range_min; /* Value of saturation range min field of light hsl saturation range state */ + uint16_t saturation_range_max; /* Value of saturation range max field of light hsl saturation range state */ +}; + +struct bt_mesh_light_hsl_set { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t hsl_lightness; /* Target value of light hsl lightness state */ + uint16_t hsl_hue; /* Target value of light hsl hue state */ + uint16_t hsl_saturation; /* Target value of light hsl saturation state */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ +}; + +struct bt_mesh_light_hsl_hue_set { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t hue; /* Target value of light hsl hue state */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ +}; + +struct bt_mesh_light_hsl_saturation_set { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t saturation; /* Target value of light hsl hue state */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ +}; + +struct bt_mesh_light_hsl_default_set { + uint16_t lightness; /* Value of light lightness default state */ + uint16_t hue; /* Value of light hue default state */ + uint16_t saturation; /* Value of light saturation default state */ +}; + +struct bt_mesh_light_hsl_range_set { + uint16_t hue_range_min; /* Value of hue range min field of light hsl hue range state */ + uint16_t hue_range_max; /* Value of hue range max field of light hsl hue range state */ + uint16_t saturation_range_min; /* Value of saturation range min field of light hsl saturation range state */ + uint16_t saturation_range_max; /* Value of saturation range max field of light hsl saturation range state */ +}; + +/* Light xyL Client Model Context */ +extern const struct bt_mesh_model_op bt_mesh_light_xyl_cli_op[]; + +/** @def BLE_MESH_MODEL_LIGHT_XYL_CLI + * + * Define a new light xyL client model. Note that this API needs + * to be repeated for each element which the application wants + * to have a light xyL client model on. + * @param cli_pub Pointer to a unique struct bt_mesh_model_pub. + * @param cli_data Pointer to a unique struct bt_mesh_light_xyl_cli. + * + * @return New light xyL client model instance. + */ +#define BLE_MESH_MODEL_LIGHT_XYL_CLI(cli_pub, cli_data) \ + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_LIGHT_XYL_CLI, \ + bt_mesh_light_xyl_cli_op, cli_pub, cli_data, &bt_mesh_lighting_client_cb) + +typedef bt_mesh_client_user_data_t bt_mesh_light_xyl_client_t; + +struct bt_mesh_light_xyl_status { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t xyl_lightness; /* The present value of the Light xyL Lightness state */ + uint16_t xyl_x; /* The present value of the Light xyL x state */ + uint16_t xyl_y; /* The present value of the Light xyL y state */ + uint8_t remain_time; /* Time to complete state transition (optional) */ +}; + +struct bt_mesh_light_xyl_target_status { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t target_xyl_lightness; /* The target value of the Light xyL Lightness state */ + uint16_t target_xyl_x; /* The target value of the Light xyL x state */ + uint16_t target_xyl_y; /* The target value of the Light xyL y state */ + uint8_t remain_time; /* Time to complete state transition (optional) */ +}; + +struct bt_mesh_light_xyl_default_status { + uint16_t lightness; /* The value of the Light Lightness Default state */ + uint16_t xyl_x; /* The value of the Light xyL x Default state */ + uint16_t xyl_y; /* The value of the Light xyL y Default state */ +}; + +struct bt_mesh_light_xyl_range_status { + uint8_t status_code; /* Status Code for the requesting message */ + uint16_t xyl_x_range_min; /* The value of the xyL x Range Min field of the Light xyL x Range state */ + uint16_t xyl_x_range_max; /* The value of the xyL x Range Max field of the Light xyL x Range state */ + uint16_t xyl_y_range_min; /* The value of the xyL y Range Min field of the Light xyL y Range state */ + uint16_t xyl_y_range_max; /* The value of the xyL y Range Max field of the Light xyL y Range state */ +}; + +struct bt_mesh_light_xyl_set { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t xyl_lightness; /* The target value of the Light xyL Lightness state */ + uint16_t xyl_x; /* The target value of the Light xyL x state */ + uint16_t xyl_y; /* The target value of the Light xyL y state */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ +}; + +struct bt_mesh_light_xyl_default_set { + uint16_t lightness; /* The value of the Light Lightness Default state */ + uint16_t xyl_x; /* The value of the Light xyL x Default state */ + uint16_t xyl_y; /* The value of the Light xyL y Default state */ +}; + +struct bt_mesh_light_xyl_range_set { + uint16_t xyl_x_range_min; /* The value of the xyL x Range Min field of the Light xyL x Range state */ + uint16_t xyl_x_range_max; /* The value of the xyL x Range Max field of the Light xyL x Range state */ + uint16_t xyl_y_range_min; /* The value of the xyL y Range Min field of the Light xyL y Range state */ + uint16_t xyl_y_range_max; /* The value of the xyL y Range Max field of the Light xyL y Range state */ +}; + +/* Light LC Client Model Context */ +extern const struct bt_mesh_model_op bt_mesh_light_lc_cli_op[]; + +/** @def BLE_MESH_MODEL_LIGHT_LC_CLI + * + * Define a new light lc client model. Note that this API needs + * to be repeated for each element which the application wants + * to have a light lc client model on. + * @param cli_pub Pointer to a unique struct bt_mesh_model_pub. + * @param cli_data Pointer to a unique struct bt_mesh_light_lc_cli. + * + * @return New light lc client model instance. + */ +#define BLE_MESH_MODEL_LIGHT_LC_CLI(cli_pub, cli_data) \ + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_LIGHT_LC_CLI, \ + bt_mesh_light_lc_cli_op, cli_pub, cli_data, &bt_mesh_lighting_client_cb) + +typedef bt_mesh_client_user_data_t bt_mesh_light_lc_client_t; + +struct bt_mesh_light_lc_mode_status { + uint8_t mode; /* The present value of the Light LC Mode state */ +}; + +struct bt_mesh_light_lc_om_status { + uint8_t mode; /* The present value of the Light LC Occupancy Mode state */ +}; + +struct bt_mesh_light_lc_light_onoff_status { + bool op_en; /* Indicate whether optional parameters included */ + uint8_t present_light_onoff; /* The present value of the Light LC Light OnOff state */ + uint8_t target_light_onoff; /* The target value of the Light LC Light OnOff state (Optional) */ + uint8_t remain_time; /* Time to complete state transition (C.1) */ +}; + +struct bt_mesh_light_lc_property_status { + uint16_t light_lc_property_id; /* Property ID identifying a Light LC Property */ + struct net_buf_simple *light_lc_property_value; /* Raw value for the Light LC Property */ +}; + +struct bt_mesh_light_lc_mode_set { + uint8_t mode; /* The target value of the Light LC Mode state */ +}; + +struct bt_mesh_light_lc_om_set { + uint8_t mode; /* The target value of the Light LC Occupancy Mode state */ +}; + +struct bt_mesh_light_lc_light_onoff_set { + bool op_en; /* Indicate whether optional parameters included */ + uint8_t light_onoff; /* The target value of the Light LC Light OnOff state */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ +}; + +struct bt_mesh_light_lc_property_get { + uint16_t light_lc_property_id; /* Property ID identifying a Light LC Property */ +}; + +struct bt_mesh_light_lc_property_set { + uint16_t light_lc_property_id; /* Property ID identifying a Light LC Property */ + struct net_buf_simple *light_lc_property_value; /* Raw value for the Light LC Property */ +}; + +/** + * @brief This function is called to get light states. + * + * @param[in] common: Message common information structure + * @param[in] get: Pointer of light get message value + * + * @return Zero-success, other-fail + */ +int bt_mesh_light_client_get_state(bt_mesh_client_common_param_t *common, void *get); + +/** + * @brief This function is called to set light states. + * + * @param[in] common: Message common information structure + * @param[in] set: Pointer of light set message value + * + * @return Zero-success, other-fail + */ +int bt_mesh_light_client_set_state(bt_mesh_client_common_param_t *common, void *set); + +#ifdef __cplusplus +} +#endif + +#endif /* _LIGHTING_CLIENT_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_models/client/include/sensor_client.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_models/client/include/sensor_client.h new file mode 100644 index 00000000000..6dfcebdfbb2 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_models/client/include/sensor_client.h @@ -0,0 +1,155 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** @file + * @brief Bluetooth Mesh Sensor Client Model APIs. + */ + +#ifndef _SENSOR_CLIENT_H_ +#define _SENSOR_CLIENT_H_ + +#include "client_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Sensor Client Model Callback */ +extern const struct bt_mesh_model_cb bt_mesh_sensor_client_cb; + +/* Sensor Client Model Context */ +extern const struct bt_mesh_model_op bt_mesh_sensor_cli_op[]; + +/** @def BLE_MESH_MODEL_SENSOR_CLI + * + * Define a new sensor client model. Note that this API needs to + * be repeated for each element which the application wants to + * have a sensor client model on. + * @param cli_pub Pointer to a unique struct bt_mesh_model_pub. + * @param cli_data Pointer to a unique struct bt_mesh_sensor_cli. + * + * @return New sensor client model instance. + */ +#define BLE_MESH_MODEL_SENSOR_CLI(cli_pub, cli_data) \ + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_SENSOR_CLI, \ + bt_mesh_sensor_cli_op, cli_pub, cli_data, &bt_mesh_sensor_client_cb) + +typedef bt_mesh_client_user_data_t bt_mesh_sensor_client_t; +typedef bt_mesh_client_internal_data_t sensor_internal_data_t; + +struct bt_mesh_sensor_descriptor_status { + struct net_buf_simple *descriptor; /* Sequence of 8-octet sensor descriptors (optional) */ +}; + +struct bt_mesh_sensor_cadence_status { + uint16_t property_id; /* Property for the sensor */ + struct net_buf_simple *sensor_cadence_value; /* Value of sensor cadence state */ +}; + +struct bt_mesh_sensor_settings_status { + 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) */ +}; + +struct bt_mesh_sensor_setting_status { + bool op_en; /* Indicate whether optional parameters 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 */ +}; + +struct bt_mesh_sensor_status { + struct net_buf_simple *marshalled_sensor_data; /* Value of sensor data state (optional) */ +}; + +struct bt_mesh_sensor_column_status { + 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 */ +}; + +struct bt_mesh_sensor_series_status { + 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 */ +}; + +struct bt_mesh_sensor_descriptor_get { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t property_id; /* Property ID for the sensor (optional) */ +}; + +struct bt_mesh_sensor_cadence_get { + uint16_t property_id; /* Property ID for the sensor */ +}; + +struct bt_mesh_sensor_cadence_set { + 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 */ + 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 */ +}; + +struct bt_mesh_sensor_settings_get { + uint16_t sensor_property_id; /* Property ID for the sensor */ +}; + +struct bt_mesh_sensor_setting_get { + 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 bt_mesh_sensor_setting_set { + 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 */ +}; + +struct bt_mesh_sensor_get { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t property_id; /* Property ID for the sensor (optional) */ +}; + +struct bt_mesh_sensor_column_get { + uint16_t property_id; /* Property identifying a sensor */ + struct net_buf_simple *raw_value_x; /* Raw value identifying a column */ +}; + +struct bt_mesh_sensor_series_get { + bool op_en; /* Indicate whether optional parameters 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 a ending column (C.1) */ +}; + +/** + * @brief This function is called to get sensor states. + * + * @param[in] common: Message common information structure + * @param[in] get: Pointer of sensor get message value + * + * @return Zero-success, other-fail + */ +int bt_mesh_sensor_client_get_state(bt_mesh_client_common_param_t *common, void *get); + +/** + * @brief This function is called to set sensor states. + * + * @param[in] common: Message common information structure + * @param[in] set: Pointer of sensor set message value + * + * @return Zero-success, other-fail + */ +int bt_mesh_sensor_client_set_state(bt_mesh_client_common_param_t *common, void *set); + +#ifdef __cplusplus +} +#endif + +#endif /* _SENSOR_CLIENT_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_models/client/include/time_scene_client.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_models/client/include/time_scene_client.h new file mode 100644 index 00000000000..f7c7f5e58c4 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_models/client/include/time_scene_client.h @@ -0,0 +1,225 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** @file + * @brief Bluetooth Mesh Time and Scene Client Model APIs. + */ + +#ifndef _TIME_SCENE_CLIENT_H_ +#define _TIME_SCENE_CLIENT_H_ + +#include "client_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Time scene client model common structure */ +typedef bt_mesh_client_user_data_t bt_mesh_time_scene_client_t; +typedef bt_mesh_client_internal_data_t time_scene_internal_data_t; + +/* Time Scene Client Model Callback */ +extern const struct bt_mesh_model_cb bt_mesh_time_scene_client_cb; + +/* Time Client Model Context */ +extern const struct bt_mesh_model_op bt_mesh_time_cli_op[]; + +/** @def BLE_MESH_MODEL_TIME_CLI + * + * Define a new time client model. Note that this API needs to + * be repeated for each element which the application wants to + * have a time model on. + * @param cli_pub Pointer to a unique struct bt_mesh_model_pub. + * @param cli_data Pointer to a unique struct bt_mesh_time_cli. + * + * @return New time client model instance. + */ +#define BLE_MESH_MODEL_TIME_CLI(cli_pub, cli_data) \ + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_TIME_CLI, \ + bt_mesh_time_cli_op, cli_pub, cli_data, &bt_mesh_time_scene_client_cb) + +typedef bt_mesh_client_user_data_t bt_mesh_time_client_t; + +struct bt_mesh_time_status { + 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 */ +}; + +struct bt_mesh_time_zone_status { + 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 */ +}; + +struct bt_mesh_tai_utc_delta_status { + 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 */ +}; + +struct bt_mesh_time_role_status { + uint8_t time_role; /* The Time Role for the element */ +}; + +struct bt_mesh_time_set { + 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 */ +}; + +struct bt_mesh_time_zone_set { + 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 */ +}; + +struct bt_mesh_tai_utc_delta_set { + 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 */ +}; + +struct bt_mesh_time_role_set { + uint8_t time_role; /* The Time Role for the element */ +}; + +/* Scene Client Model Context */ +extern const struct bt_mesh_model_op bt_mesh_scene_cli_op[]; + +/** @def BLE_MESH_MODEL_SCENE_CLI + * + * Define a new scene client model. Note that this API needs to + * be repeated for each element which the application wants to + * have a scene model on. + * @param cli_pub Pointer to a unique struct bt_mesh_model_pub. + * @param cli_data Pointer to a unique struct bt_mesh_scene_cli. + * + * @return New scene client model instance. + */ +#define BLE_MESH_MODEL_SCENE_CLI(cli_pub, cli_data) \ + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_SCENE_CLI, \ + bt_mesh_scene_cli_op, cli_pub, cli_data, &bt_mesh_time_scene_client_cb) + +typedef bt_mesh_client_user_data_t bt_mesh_scene_client_t; + +struct bt_mesh_scene_status { + bool op_en; /* Indicate whether optional parameters included */ + uint8_t status_code; /* Status code for the last operation */ + uint16_t current_scene; /* Scene Number of a current scene */ + uint16_t target_scene; /* Scene Number of a target scene (optional) */ + uint8_t remain_time; /* Time to complete state transition (C.1) */ +}; + +struct bt_mesh_scene_register_status { + uint8_t status_code; /* Status code for the previous operation */ + uint16_t current_scene; /* Scene Number of a current scene */ + struct net_buf_simple *scenes; /* A list of scenes stored within an element */ +}; + +struct bt_mesh_scene_store { + uint16_t scene_number; /* The number of the scene to be stored */ +}; + +struct bt_mesh_scene_recall { + bool op_en; /* Indicate whether optional parameters included */ + uint16_t scene_number; /* The number of the scene to be recalled */ + uint8_t tid; /* Transaction Identifier */ + uint8_t trans_time; /* Time to complete state transition (optional) */ + uint8_t delay; /* Indicate message execution delay (C.1) */ +}; + +struct bt_mesh_scene_delete { + uint16_t scene_number; /* The number of the scene to be deleted */ +}; + +/* Scheduler Client Model Context */ +extern const struct bt_mesh_model_op bt_mesh_scheduler_cli_op[]; + +/** @def BLE_MESH_MODEL_SCHEDULER_CLI + * + * Define a new scheduler client model. Note that this API needs to + * be repeated for each element which the application wants to + * have a scheduler model on. + * @param cli_pub Pointer to a unique struct bt_mesh_model_pub. + * @param cli_data Pointer to a unique struct bt_mesh_scheduler_cli. + * + * @return New scheduler client model instance. + */ +#define BLE_MESH_MODEL_SCHEDULER_CLI(cli_pub, cli_data) \ + BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_SCHEDULER_CLI, \ + bt_mesh_scheduler_cli_op, cli_pub, cli_data, &bt_mesh_time_scene_client_cb) + +typedef bt_mesh_client_user_data_t bt_mesh_scheduler_client_t; + +struct bt_mesh_scheduler_status { + uint16_t schedules; /* Bit field indicating defined Actions in the Schedule Register */ +}; + +struct bt_mesh_scheduler_act_status { + 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 */ +}; + +struct bt_mesh_scheduler_act_get { + uint8_t index; /* Index of the Schedule Register entry to get */ +}; + +struct bt_mesh_scheduler_act_set { + 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 */ +}; + +/** + * @brief This function is called to get scene states. + * + * @param[in] common: Message common information structure + * @param[in] get: Pointer of time scene get message value + * + * @return Zero-success, other-fail + */ +int bt_mesh_time_scene_client_get_state(bt_mesh_client_common_param_t *common, void *get); + +/** + * @brief This function is called to set scene states. + * + * @param[in] common: Message common information structure + * @param[in] set: Pointer of time scene set message value + * + * @return Zero-success, other-fail + */ +int bt_mesh_time_scene_client_set_state(bt_mesh_client_common_param_t *common, void *set); + +#ifdef __cplusplus +} +#endif + +#endif /* _TIME_SCENE_CLIENT_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_models/common/include/device_property.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_models/common/include/device_property.h new file mode 100644 index 00000000000..74bf76a938f --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_models/common/include/device_property.h @@ -0,0 +1,1350 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _DEVICE_PROPERTY_H_ +#define _DEVICE_PROPERTY_H_ + +#include "mesh_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Details of BLE Mesh Device Properties. + * Note: For the size of the corresponding characteristic, please refer to the GATT_Specification_Supplement_v2. + * + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Property Name | ID | Characteristic | Size | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Average Ambient Temperature In A Period Of Day | 0x0001 | Temperature 8 In A Period Of Day | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Average Input Current | 0x0002 | Average Current | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Average Input Voltage | 0x0003 | Average Voltage | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Average Output Current | 0x0004 | Average Current | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Average Output Voltage | 0x0005 | Average Voltage | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Center Beam Intensity At Full Power | 0x0006 | Luminous Intensity | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Chromaticity Tolerance | 0x0007 | Chromaticity Tolerance | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Color Rendering Index R9 | 0x0008 | Cie 13.3-1995 Color Rendering Index | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Color Rendering Index Ra | 0x0009 | Cie 13.3-1995 Color Rendering Index | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Appearance | 0x000A | Gap.Appearance | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Country Of Origin | 0x000B | Country Code | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Date Of Manufacture | 0x000C | Date UTC | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Energy Use Since Turn On | 0x000D | Energy | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Firmware Revision | 0x000E | Fixed String 8 | 8 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Global Trade Item Number | 0x000F | Global Trade Item Number | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Hardware Revision | 0x0010 | Fixed String 16 | 16 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Manufacturer Name | 0x0011 | Fixed String 36 | 36 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Model Number | 0x0012 | Fixed String 24 | 24 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Operating Temperature Range Specification | 0x0013 | Temperature Range | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Operating Temperature Statistical Values | 0x0014 | Temperature Statistics | 9 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Over Temperature Event Statistics | 0x0015 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Power Range Specification | 0x0016 | Power Specification | 9 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Runtime Since Turn On | 0x0017 | Time Hour 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Runtime Warranty | 0x0018 | Time Hour 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Serial Number | 0x0019 | Fixed String 16 | 16 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Software Revision | 0x001A | Fixed String 8 | 8 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Device Under Temperature Event Statistics | 0x001B | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Indoor Ambient Temperature Statistical Values | 0x001C | Temperature 8 Statistics | 5 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Initial CIE 1931 Chromaticity Coordinates | 0x001D | Chromaticity Coordinates | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Initial Correlated Color Temperature | 0x001E | Correlated Color Temperature | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Initial Luminous Flux | 0x001F | Luminous Flux | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Initial Planckian Distance | 0x0020 | Chromatic Distance From Planckian | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Input Current Range Specification | 0x0021 | Electric Current Specification | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Input Current Statistics | 0x0022 | Electric Current Statistics | 9 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Input Over Current Event Statistics | 0x0023 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Input Over Ripple Voltage Event Statistics | 0x0024 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Input Over Voltage Event Statistics | 0x0025 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Input Under Current Event Statistics | 0x0026 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Input Under Voltage Event Statistics | 0x0027 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Input Voltage Range Specification | 0x0028 | Voltage Specification | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Input Voltage Ripple Specification | 0x0029 | Percentage 8 | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Input Voltage Statistics | 0x002A | Voltage Statistics | 9 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Ambient LuxLevel On | 0x002B | Illuminance | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Ambient LuxLevel Prolong | 0x002C | Illuminance | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Ambient LuxLevel Standby | 0x002D | Illuminance | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Lightness On | 0x002E | Perceived Lightness | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Lightness Prolong | 0x002F | Perceived Lightness | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Lightness Standby | 0x0030 | Perceived Lightness | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Regulator Accuracy | 0x0031 | Percentage 8 | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Regulator Kid | 0x0032 | Coefficient | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Regulator Kiu | 0x0033 | Coefficient | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Regulator Kpd | 0x0034 | Coefficient | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Regulator Kpu | 0x0035 | Coefficient | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Time Fade | 0x0036 | Time Millisecond 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Time Fade On | 0x0037 | Time Millisecond 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Time Fade Standby Auto | 0x0038 | Time Millisecond 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Time Fade Standby Manual | 0x0039 | Time Millisecond 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Time Occupancy Delay | 0x003A | Time Millisecond 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Time Prolong | 0x003B | Time Millisecond 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Control Time Run On | 0x003C | Time Millisecond 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Lumen Maintenance Factor | 0x003D | Percentage 8 | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Luminous Efficacy | 0x003E | Luminous Efficacy | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Luminous Energy Since Turn On | 0x003F | Luminous Energy | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Luminous Exposure | 0x0040 | Luminous Exposure | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Luminous Flux Range | 0x0041 | Luminous Flux Range | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Motion Sensed | 0x0042 | Percentage 8 | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Motion Threshold | 0x0043 | Percentage 8 | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Open Circuit Event Statistics | 0x0044 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Outdoor Statistical Values | 0x0045 | Temperature 8 Statistics | 5 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Output Current Range | 0x0046 | Electric Current Range | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Output Current Statistics | 0x0047 | Electric Current Statistics | 9 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Output Ripple Voltage Specification | 0x0048 | Percentage 8 | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Output Voltage Range | 0x0049 | Voltage Specification | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Output Voltage Statistics | 0x004A | Voltage Statistics | 9 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Over Output Ripple Voltage Event Statistics | 0x004B | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | People Count | 0x004C | Count 16 | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Presence Detected | 0x004D | Boolean | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Ambient Light Level | 0x004E | Illuminance | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Ambient Temperature | 0x004F | Temperature 8 | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present CIE 1931 Chromaticity Coordinates | 0x0050 | Chromaticity Coordinates | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Correlated Color Temperature | 0x0051 | Correlated Color Temperature | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Device Input Power | 0x0052 | Power | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Device Operating Efficiency | 0x0053 | Percentage 8 | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Device Operating Temperature | 0x0054 | Temperature | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Illuminance | 0x0055 | Illuminance | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Indoor Ambient Temperature | 0x0056 | Temperature 8 | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Input Current | 0x0057 | Electric Current | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Input Ripple Voltage | 0x0058 | Percentage 8 | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Input Voltage | 0x0059 | Voltage | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Luminous Flux | 0x005A | Luminous Flux | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Outdoor Ambient Temperature | 0x005B | Temperature 8 | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Output Current | 0x005C | Electric Current | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Output Voltage | 0x005D | Voltage | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Planckian Distance | 0x005E | Chromatic Distance From Planckian | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Relative Output Ripple Voltage | 0x005F | Percentage 8 | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Relative Device Energy Use In A Period Of Day | 0x0060 | Energy In A Period Of Day | 5 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Relative Device Runtime In A Generic Level Range | 0x0061 | Relative Runtime In A Generic Level Range | 5 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Relative Exposure Time In An Illuminance Range | 0x0062 | Relative Value In An Illuminance Range | 5 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Relative Runtime In A Correlated Color Temperature Range | 0x0063 | Luminous Energy | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Relative Runtime In A Device Operating Temperature Range | 0x0064 | Relative Value In A Temperature Range | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Relative Runtime In An Input Current Range | 0x0065 | Relative Runtime In A Current Range | 5 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Relative Runtime In An Input Voltage Range | 0x0066 | Relative Value In A Voltage Range | 5 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Short Circuit Event Statistics | 0x0067 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Time Since Motion Sensed | 0x0068 | Time Second 16 | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Time Since Presence Detected | 0x0069 | Time Second 16 | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Total Device Energy Use | 0x006A | Energy | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Total Device Off On Cycles | 0x006B | Count 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Total Device Power On Cycles | 0x006C | Count 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Total Device Power On Time | 0x006D | Time Hour 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Total Device Runtime | 0x006E | Time Hour 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Total Light Exposure Time | 0x006F | Time Hour 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Total Luminous Energy | 0x0070 | Luminous Energy | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Desired Ambient Temperature | 0x0071 | Temperature 8 | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Precise Total Device Energy Use | 0x0072 | Energy32 | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Power Factor | 0x0073 | Cosine Of The Angle | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Sensor Gain | 0x0074 | Coefficient | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Precise Present Ambient Temperature | 0x0075 | Temperature | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Ambient Relative Humidity | 0x0076 | Humidity | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Ambient Carbon Dioxide Concentration | 0x0077 | CO2 Concentration | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Ambient Volatile Organic Compounds Concentration | 0x0078 | VOC Concentration | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Ambient Noise | 0x0079 | Noise | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Active Energy Loadside | 0x0080 | Energy32 | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Active Power Loadside | 0x0081 | Power | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Air Pressure | 0x0082 | Pressure | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Apparent Energy | 0x0083 | Apparent Energy32 | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Apparent Power | 0x0084 | Apparent Power | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Apparent Wind Direction | 0x0085 | Apparent Wind Direction | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Apparent Wind Speed | 0x0086 | Apparent Wind Speed | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Dew Point | 0x0087 | Dew Point | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | External Supply Voltage | 0x0088 | High Voltage | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | External Supply Voltage Frequency | 0x0089 | Voltage Frequency | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Gust Factor | 0x008A | Gust Factor | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Heat Index | 0x008B | Heat Index | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Distribution | 0x008C | Light Distribution | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Source Current | 0x008D | Average Current | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Source On Time Not Resettable | 0x008E | Time Second 32 | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Source On Time Resettable | 0x008F | Time Second 32 | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Source Open Circuit Statistics | 0x0090 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Source Overall Failures Statistics | 0x0091 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Source Short Circuit Statistics | 0x0092 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Source Start Counter Resettable | 0x0093 | Count 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Source Temperature | 0x0094 | High Temperature | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Source Thermal Derating Statistics | 0x0095 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Source Thermal Shutdown Statistics | 0x0096 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Source Total Power On Cycles | 0x0097 | Count 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Source Voltage | 0x0098 | Average Voltage | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Luminaire Color | 0x0099 | Fixed String 24 | 24 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Luminaire Identification Number | 0x009A | Fixed String 24 | 24 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Luminaire Manufacturer GTIN | 0x009B | Global Trade Item Number | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Luminaire Nominal Input Power | 0x009C | Power | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Luminaire Nominal Maximum AC Mains Voltage | 0x009D | Voltage | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Luminaire Nominal Minimum AC Mains Voltage | 0x009E | Voltage | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Luminaire Power At Minimum Dim Level | 0x009F | Power | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Luminaire Time Of Manufacture | 0x00A0 | Date UTC | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Magnetic Declination | 0x00A1 | Magnetic Declination | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Magnetic Flux Density - 2D | 0x00A2 | Magnetic Flux Density - 2D | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Magnetic Flux Density - 3D | 0x00A3 | Magnetic Flux Density - 3D | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Nominal Light Output | 0x00A4 | Light Output | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Overall Failure Condition | 0x00A5 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Pollen Concentration | 0x00A6 | Pollen Concentration | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Indoor Relative Humidity | 0x00A7 | Humidity | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Present Outdoor Relative Humidity | 0x00A8 | Humidity | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Pressure | 0x00A9 | Pressure | 4 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Rainfall | 0x00AA | Rainfall | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Rated Median Useful Life Of Luminaire | 0x00AB | Time Hour 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Rated Median Useful Light Source Starts | 0x00AC | Count 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Reference Temperature | 0x00AD | High Temperature | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Total Device Starts | 0x00AE | Count 24 | 3 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | True Wind Direction | 0x00AF | True Wind Direction | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | True Wind Speed | 0x00B0 | True Wind Speed | 2 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | UV Index | 0x00B1 | UV Index | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Wind Chill | 0x00B2 | Wind Chill | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Light Source Type | 0x00B3 | Light Source Type | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Luminaire Identification String | 0x00B4 | Fixed String 64 | 64 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Output Power Limitation | 0x00B5 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Thermal Derating | 0x00B6 | Event Statistics | 6 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + * | Output Current Percent | 0x00B7 | Percentage 8 | 1 | + * |----------------------------------------------------------|--------|-------------------------------------------|------| + */ + +/** + * @brief BLE Mesh Device Property IDs + */ +#define BLE_MESH_INVALID_DEVICE_PROPERTY_ID 0x0000 +#define BLE_MESH_AVERAGE_AMBIENT_TEMPERATURE_IN_A_PERIOD_OF_DAY 0x0001 +#define BLE_MESH_AVERAGE_INPUT_CURRENT 0x0002 +#define BLE_MESH_AVERAGE_INPUT_VOLTAGE 0x0003 +#define BLE_MESH_AVERAGE_OUTPUT_CURRENT 0x0004 +#define BLE_MESH_AVERAGE_OUTPUT_VOLTAGE 0x0005 +#define BLE_MESH_CENTER_BEAM_INTENSITY_AT_FULL_POWER 0x0006 +#define BLE_MESH_CHROMATICITY_TOLERANCE 0x0007 +#define BLE_MESH_COLOR_RENDERING_INDEX_R9 0x0008 +#define BLE_MESH_COLOR_RENDERING_INDEX_RA 0x0009 +#define BLE_MESH_DEVICE_APPEARANCE 0x000A +#define BLE_MESH_DEVICE_COUNTRY_OF_ORIGIN 0x000B +#define BLE_MESH_DEVICE_DATE_OF_MANUFACTURE 0x000C +#define BLE_MESH_DEVICE_ENERGY_USE_SINCE_TURN_ON 0x000D +#define BLE_MESH_DEVICE_FIRMWARE_REVISION 0x000E +#define BLE_MESH_DEVICE_GLOBAL_TRADE_ITEM_NUMBER 0x000F +#define BLE_MESH_DEVICE_HARDWARE_REVISION 0x0010 +#define BLE_MESH_DEVICE_MANUFACTURER_NAME 0x0011 +#define BLE_MESH_DEVICE_MODEL_NUMBER 0x0012 +#define BLE_MESH_DEVICE_OPERATING_TEMPERATURE_RANGE_SPECIFICATION 0x0013 +#define BLE_MESH_DEVICE_OPERATING_TEMPERATURE_STATISTICAL_VALUES 0x0014 +#define BLE_MESH_DEVICE_OVER_TEMPERATURE_EVENT_STATISTICS 0x0015 +#define BLE_MESH_DEVICE_POWER_RANGE_SPECIFICATION 0x0016 +#define BLE_MESH_DEVICE_RUNTIME_SINCE_TURN_ON 0x0017 +#define BLE_MESH_DEVICE_RUNTIME_WARRANTY 0x0018 +#define BLE_MESH_DEVICE_SERIAL_NUMBER 0x0019 +#define BLE_MESH_DEVICE_SOFTWARE_REVISION 0x001A +#define BLE_MESH_DEVICE_UNDER_TEMPERATURE_EVENT_STATISTICS 0x001B +#define BLE_MESH_INDOOR_AMBIENT_TEMPERATURE_STATISTICAL_VALUES 0x001C +#define BLE_MESH_INITIAL_CIE_1931_CHROMATICITY_COORDINATES 0x001D +#define BLE_MESH_INITIAL_CORRELATED_COLOR_TEMPERATURE 0x001E +#define BLE_MESH_INITIAL_LUMINOUS_FLUX 0x001F +#define BLE_MESH_INITIAL_PLANCKIAN_DISTANCE 0x0020 +#define BLE_MESH_INPUT_CURRENT_RANGE_SPECIFICATION 0x0021 +#define BLE_MESH_INPUT_CURRENT_STATISTICS 0x0022 +#define BLE_MESH_INPUT_OVER_CURRENT_EVENT_STATISTICS 0x0023 +#define BLE_MESH_INPUT_OVER_RIPPLE_VOLTAGE_EVENT_STATISTICS 0x0024 +#define BLE_MESH_INPUT_OVER_VOLTAGE_EVENT_STATISTICS 0x0025 +#define BLE_MESH_INPUT_UNDER_CURRENT_EVENT_STATISTICS 0x0026 +#define BLE_MESH_INPUT_UNDER_VOLTAGE_EVENT_STATISTICS 0x0027 +#define BLE_MESH_INPUT_VOLTAGE_RANGE_SPECIFICATION 0x0028 +#define BLE_MESH_INPUT_VOLTAGE_RIPPLE_SPECIFICATION 0x0029 +#define BLE_MESH_INPUT_VOLTAGE_STATISTICS 0x002A +#define BLE_MESH_LIGHT_CONTROL_AMBIENT_LUXLEVEL_ON 0x002B +#define BLE_MESH_LIGHT_CONTROL_AMBIENT_LUXLEVEL_PROLONG 0x002C +#define BLE_MESH_LIGHT_CONTROL_AMBIENT_LUXLEVEL_STANDBY 0x002D +#define BLE_MESH_LIGHT_CONTROL_LIGHTNESS_ON 0x002E +#define BLE_MESH_LIGHT_CONTROL_LIGHTNESS_PROLONG 0x002F +#define BLE_MESH_LIGHT_CONTROL_LIGHTNESS_STANDBY 0x0030 +#define BLE_MESH_LIGHT_CONTROL_REGULATOR_ACCURACY 0x0031 +#define BLE_MESH_LIGHT_CONTROL_REGULATOR_KID 0x0032 +#define BLE_MESH_LIGHT_CONTROL_REGULATOR_KIU 0x0033 +#define BLE_MESH_LIGHT_CONTROL_REGULATOR_KPD 0x0034 +#define BLE_MESH_LIGHT_CONTROL_REGULATOR_KPU 0x0035 +#define BLE_MESH_LIGHT_CONTROL_TIME_FADE 0x0036 +#define BLE_MESH_LIGHT_CONTROL_TIME_FADE_ON 0x0037 +#define BLE_MESH_LIGHT_CONTROL_TIME_FADE_STANDBY_AUTO 0x0038 +#define BLE_MESH_LIGHT_CONTROL_TIME_FADE_STANDBY_MANUAL 0x0039 +#define BLE_MESH_LIGHT_CONTROL_TIME_OCCUPANCY_DELAY 0x003A +#define BLE_MESH_LIGHT_CONTROL_TIME_PROLONG 0x003B +#define BLE_MESH_LIGHT_CONTROL_TIME_RUN_ON 0x003C +#define BLE_MESH_LUMEN_MAINTENANCE_FACTOR 0x003D +#define BLE_MESH_LUMINOUS_EFFICACY 0x003E +#define BLE_MESH_LUMINOUS_ENERGY_SINCE_TURN_ON 0x003F +#define BLE_MESH_LUMINOUS_EXPOSURE 0x0040 +#define BLE_MESH_LUMINOUS_FLUX_RANGE 0x0041 +#define BLE_MESH_MOTION_SENSED 0x0042 +#define BLE_MESH_MOTION_THRESHOLD 0x0043 +#define BLE_MESH_OPEN_CIRCUIT_EVENT_STATISTICS 0x0044 +#define BLE_MESH_OUTDOOR_STATISTICAL_VALUES 0x0045 +#define BLE_MESH_OUTPUT_CURRENT_RANGE 0x0046 +#define BLE_MESH_OUTPUT_CURRENT_STATISTICS 0x0047 +#define BLE_MESH_OUTPUT_RIPPLE_VOLTAGE_SPECIFICATION 0x0048 +#define BLE_MESH_OUTPUT_VOLTAGE_RANGE 0x0049 +#define BLE_MESH_OUTPUT_VOLTAGE_STATISTICS 0x004A +#define BLE_MESH_OVER_OUTPUT_RIPPLE_VOLTAGE_EVENT_STATISTICS 0x004B +#define BLE_MESH_PEOPLE_COUNT 0x004C +#define BLE_MESH_PRESENCE_DETECTED 0x004D +#define BLE_MESH_PRESENT_AMBIENT_LIGHT_LEVEL 0x004E +#define BLE_MESH_PRESENT_AMBIENT_TEMPERATURE 0x004F +#define BLE_MESH_PRESENT_CIE_1931_CHROMATICITY 0x0050 +#define BLE_MESH_PRESENT_CORRELATED_COLOR_TEMPERATURE 0x0051 +#define BLE_MESH_PRESENT_DEVICE_INPUT_POWER 0x0052 +#define BLE_MESH_PRESENT_DEVICE_OPERATING_EFFICIENCY 0x0053 +#define BLE_MESH_PRESENT_DEVICE_OPERATING_TEMPERATURE 0x0054 +#define BLE_MESH_PRESENT_ILLUMINANCE 0x0055 +#define BLE_MESH_PRESENT_INDOOR_AMBIENT_TEMPERATURE 0x0056 +#define BLE_MESH_PRESENT_INPUT_CURRENT 0x0057 +#define BLE_MESH_PRESENT_INPUT_RIPPLE_VOLTAGE 0x0058 +#define BLE_MESH_PRESENT_INPUT_VOLTAGE 0x0059 +#define BLE_MESH_PRESENT_LUMINOUS_FLUX 0x005A +#define BLE_MESH_PRESENT_OUTDOOR_AMBIENT_TEMPERATURE 0x005B +#define BLE_MESH_PRESENT_OUTPUT_CURRENT 0x005C +#define BLE_MESH_PRESENT_OUTPUT_VOLTAGE 0x005D +#define BLE_MESH_PRESENT_PLANCKIAN_DISTANCE 0x005E +#define BLE_MESH_PRESENT_RELATIVE_OUTPUT_RIPPLE_VOLTAGE 0x005F +#define BLE_MESH_RELATIVE_DEVICE_ENERGY_USE_IN_A_PERIOD_OF_DAY 0x0060 +#define BLE_MESH_RELATIVE_DEVICE_RUNTIME_IN_A_GENERIC_LEVEL_RANGE 0x0061 +#define BLE_MESH_RELATIVE_EXPOSURE_TIME_IN_AN_ILLUMINANCE_RANGE 0x0062 +#define BLE_MESH_RELATIVE_RUNTIME_IN_A_CORRELATED_COLOR_TEMPERATURE_RANGE 0x0063 +#define BLE_MESH_RELATIVE_RUNTIME_IN_A_DEVICE_OPERATING_TEMPERATURE_RANGE 0x0064 +#define BLE_MESH_RELATIVE_RUNTIME_IN_AN_INPUT_CURRENT_RANGE 0x0065 +#define BLE_MESH_RELATIVE_RUNTIME_IN_AN_INPUT_VOLTAGE_RANGE 0x0066 +#define BLE_MESH_SHORT_CIRCUIT_EVENT_STATISTICS 0x0067 +#define BLE_MESH_TIME_SINCE_MOTION_SENSED 0x0068 +#define BLE_MESH_TIME_SINCE_PRESENCE_DETECTED 0x0069 +#define BLE_MESH_TOTAL_DEVICE_ENERGY_USE 0x006A +#define BLE_MESH_TOTAL_DEVICE_OFF_ON_CYCLES 0x006B +#define BLE_MESH_TOTAL_DEVICE_POWER_ON_CYCLES 0x006C +#define BLE_MESH_TOTAL_DEVICE_POWER_ON_TIME 0x006D +#define BLE_MESH_TOTAL_DEVICE_RUNTIME 0x006E +#define BLE_MESH_TOTAL_LIGHT_EXPOSURE_TIME 0x006F +#define BLE_MESH_TOTAL_LUMINOUS_ENERGY 0x0070 +#define BLE_MESH_DESIRED_AMBIENT_TEMPERATURE 0x0071 +#define BLE_MESH_PRECISE_TOTAL_DEVICE_ENERGY_USE 0x0072 +#define BLE_MESH_POWER_FACTOR 0x0073 +#define BLE_MESH_SENSOR_GAIN 0x0074 +#define BLE_MESH_PRECISE_PRESENT_AMBIENT_TEMPERATURE 0x0075 +#define BLE_MESH_PRESENT_AMBIENT_RELATIVE_HUMIDITY 0x0076 +#define BLE_MESH_PRESENT_AMBIENT_CARBON_DIOXIDE_CONCENTRATION 0x0077 +#define BLE_MESH_PRESENT_AMBIENT_VOLATILE_ORGANIC_COMPOUNDS_CONCENTRATION 0x0078 +#define BLE_MESH_PRESENT_AMBIENT_NOISE 0x0079 +#define BLE_MESH_ACTIVE_ENERGY_LOADSIDE 0x0080 +#define BLE_MESH_ACTIVE_POWER_LOADSIDE 0x0081 +#define BLE_MESH_AIR_PRESSURE 0x0082 +#define BLE_MESH_APPARENT_ENERGY 0x0083 +#define BLE_MESH_APPARENT_POWER 0x0084 +#define BLE_MESH_APPARENT_WIND_DIRECTION 0x0085 +#define BLE_MESH_APPARENT_WIND_SPEED 0x0086 +#define BLE_MESH_DEW_POINT 0x0087 +#define BLE_MESH_EXTERNAL_SUPPLY_VOLTAGE 0x0088 +#define BLE_MESH_EXTERNAL_SUPPLY_VOLTAGE_FREQUENCY 0x0089 +#define BLE_MESH_GUST_FACTOR 0x008A +#define BLE_MESH_HEAT_INDEX 0x008B +#define BLE_MESH_LIGHT_DISTRIBUTION 0x008C +#define BLE_MESH_LIGHT_SOURCE_CURRENT 0x008D +#define BLE_MESH_LIGHT_SOURCE_ON_TIME_NOT_RESETTABLE 0x008E +#define BLE_MESH_LIGHT_SOURCE_ON_TIME_RESETTABLE 0x008F +#define BLE_MESH_LIGHT_SOURCE_OPEN_CIRCUIT_STATISTICS 0x0090 +#define BLE_MESH_LIGHT_SOURCE_OVERALL_FAILURES_STATISTICS 0x0091 +#define BLE_MESH_LIGHT_SOURCE_SHORT_CIRCUIT_STATISTICS 0x0092 +#define BLE_MESH_LIGHT_SOURCE_START_COUNTER_RESETTABLE 0x0093 +#define BLE_MESH_LIGHT_SOURCE_TEMPERATURE 0x0094 +#define BLE_MESH_LIGHT_SOURCE_THERMAL_DERATING_STATISTICS 0x0095 +#define BLE_MESH_LIGHT_SOURCE_THERMAL_SHUTDOWN_STATISTICS 0x0096 +#define BLE_MESH_LIGHT_SOURCE_TOTAL_POWER_ON_CYCLES 0x0097 +#define BLE_MESH_LIGHT_SOURCE_VOLTAGE 0x0098 +#define BLE_MESH_LUMINAIRE_COLOR 0x0099 +#define BLE_MESH_LUMINAIRE_IDENTIFICATION_NUMBER 0x009A +#define BLE_MESH_LUMINAIRE_MANUFACTURER_GTIN 0x009B +#define BLE_MESH_LUMINAIRE_NOMINAL_INPUT_POWER 0x009C +#define BLE_MESH_LUMINAIRE_NOMINAL_MAXIMUM_AC_MAINS_VOLTAGE 0x009D +#define BLE_MESH_LUMINAIRE_NOMINAL_MINIMUM_AC_MAINS_VOLTAGE 0x009E +#define BLE_MESH_LUMINAIRE_POWER_AT_MINIMUM_DIM_LEVEL 0x009F +#define BLE_MESH_LUMINAIRE_TIME_OF_MANUFACTURE 0x00A0 +#define BLE_MESH_MAGNETIC_DECLINATION 0x00A1 +#define BLE_MESH_MAGNETIC_FLUX_DENSITY_2D 0x00A2 +#define BLE_MESH_MAGNETIC_FLUX_DENSITY_3D 0x00A3 +#define BLE_MESH_NOMINAL_LIGHT_OUTPUT 0x00A4 +#define BLE_MESH_OVERALL_FAILURE_CONDITION 0x00A5 +#define BLE_MESH_POLLEN_CONCENTRATION 0x00A6 +#define BLE_MESH_PRESENT_INDOOR_RELATIVE_HUMIDITY 0x00A7 +#define BLE_MESH_PRESENT_OUTDOOR_RELATIVE_HUMIDITY 0x00A8 +#define BLE_MESH_PRESSURE 0x00A9 +#define BLE_MESH_RAINFALL 0x00AA +#define BLE_MESH_RATED_MEDIAN_USEFUL_LIFE_OF_LUMINAIRE 0x00AB +#define BLE_MESH_RATED_MEDIAN_USEFUL_LIGHT_SOURCE_STARTS 0x00AC +#define BLE_MESH_REFERENCE_TEMPERATURE 0x00AD +#define BLE_MESH_TOTAL_DEVICE_STARTS 0x00AE +#define BLE_MESH_TRUE_WIND_DIRECTION 0x00AF +#define BLE_MESH_TRUE_WIND_SPEED 0x00B0 +#define BLE_MESH_UV_INDEX 0x00B1 +#define BLE_MESH_WIND_CHILL 0x00B2 +#define BLE_MESH_LIGHT_SOURCE_TYPE 0x00B3 +#define BLE_MESH_LUMINAIRE_IDENTIFICATION_STRING 0x00B4 +#define BLE_MESH_OUTPUT_POWER_LIMITATION 0x00B5 +#define BLE_MESH_THERMAL_DERATING 0x00B6 +#define BLE_MESH_OUTPUT_CURRENT_PERCENT 0x00B7 + +/** + * @brief BLE Mesh Device Property value length + */ +#define BLE_MESH_AVERAGE_AMBIENT_TEMPERATURE_IN_A_PERIOD_OF_DAY_LEN 3 +#define BLE_MESH_AVERAGE_INPUT_CURRENT_LEN 3 +#define BLE_MESH_AVERAGE_INPUT_VOLTAGE_LEN 3 +#define BLE_MESH_AVERAGE_OUTPUT_CURRENT_LEN 3 +#define BLE_MESH_AVERAGE_OUTPUT_VOLTAGE_LEN 3 +#define BLE_MESH_CENTER_BEAM_INTENSITY_AT_FULL_POWER_LEN 2 +#define BLE_MESH_CHROMATICITY_TOLERANCE_LEN 1 +#define BLE_MESH_COLOR_RENDERING_INDEX_R9_LEN 1 +#define BLE_MESH_COLOR_RENDERING_INDEX_RA_LEN 1 +#define BLE_MESH_DEVICE_APPEARANCE_LEN 2 +#define BLE_MESH_DEVICE_COUNTRY_OF_ORIGIN_LEN 2 +#define BLE_MESH_DEVICE_DATE_OF_MANUFACTURE_LEN 3 +#define BLE_MESH_DEVICE_ENERGY_USE_SINCE_TURN_ON_LEN 3 +#define BLE_MESH_DEVICE_FIRMWARE_REVISION_LEN 8 +#define BLE_MESH_DEVICE_GLOBAL_TRADE_ITEM_NUMBER_LEN 6 +#define BLE_MESH_DEVICE_HARDWARE_REVISION_LEN 16 +#define BLE_MESH_DEVICE_MANUFACTURER_NAME_LEN 36 +#define BLE_MESH_DEVICE_MODEL_NUMBER_LEN 24 +#define BLE_MESH_DEVICE_OPERATING_TEMPERATURE_RANGE_SPECIFICATION_LEN 4 +#define BLE_MESH_DEVICE_OPERATING_TEMPERATURE_STATISTICAL_VALUES_LEN 9 +#define BLE_MESH_DEVICE_OVER_TEMPERATURE_EVENT_STATISTICS_LEN 6 +#define BLE_MESH_DEVICE_POWER_RANGE_SPECIFICATION_LEN 9 +#define BLE_MESH_DEVICE_RUNTIME_SINCE_TURN_ON_LEN 3 +#define BLE_MESH_DEVICE_RUNTIME_WARRANTY_LEN 3 +#define BLE_MESH_DEVICE_SERIAL_NUMBER_LEN 16 +#define BLE_MESH_DEVICE_SOFTWARE_REVISION_LEN 8 +#define BLE_MESH_DEVICE_UNDER_TEMPERATURE_EVENT_STATISTICS_LEN 6 +#define BLE_MESH_INDOOR_AMBIENT_TEMPERATURE_STATISTICAL_VALUES_LEN 5 +#define BLE_MESH_INITIAL_CIE_1931_CHROMATICITY_COORDINATES_LEN 4 +#define BLE_MESH_INITIAL_CORRELATED_COLOR_TEMPERATURE_LEN 2 +#define BLE_MESH_INITIAL_LUMINOUS_FLUX_LEN 2 +#define BLE_MESH_INITIAL_PLANCKIAN_DISTANCE_LEN 2 +#define BLE_MESH_INPUT_CURRENT_RANGE_SPECIFICATION_LEN 6 +#define BLE_MESH_INPUT_CURRENT_STATISTICS_LEN 9 +#define BLE_MESH_INPUT_OVER_CURRENT_EVENT_STATISTICS_LEN 6 +#define BLE_MESH_INPUT_OVER_RIPPLE_VOLTAGE_EVENT_STATISTICS_LEN 6 +#define BLE_MESH_INPUT_OVER_VOLTAGE_EVENT_STATISTICS_LEN 6 +#define BLE_MESH_INPUT_UNDER_CURRENT_EVENT_STATISTICS_LEN 6 +#define BLE_MESH_INPUT_UNDER_VOLTAGE_EVENT_STATISTICS_LEN 6 +#define BLE_MESH_INPUT_VOLTAGE_RANGE_SPECIFICATION_LEN 6 +#define BLE_MESH_INPUT_VOLTAGE_RIPPLE_SPECIFICATION_LEN 1 +#define BLE_MESH_INPUT_VOLTAGE_STATISTICS_LEN 9 +#define BLE_MESH_LIGHT_CONTROL_AMBIENT_LUXLEVEL_ON_LEN 3 +#define BLE_MESH_LIGHT_CONTROL_AMBIENT_LUXLEVEL_PROLONG_LEN 3 +#define BLE_MESH_LIGHT_CONTROL_AMBIENT_LUXLEVEL_STANDBY_LEN 3 +#define BLE_MESH_LIGHT_CONTROL_LIGHTNESS_ON_LEN 2 +#define BLE_MESH_LIGHT_CONTROL_LIGHTNESS_PROLONG_LEN 2 +#define BLE_MESH_LIGHT_CONTROL_LIGHTNESS_STANDBY_LEN 2 +#define BLE_MESH_LIGHT_CONTROL_REGULATOR_ACCURACY_LEN 1 +#define BLE_MESH_LIGHT_CONTROL_REGULATOR_KID_LEN 4 +#define BLE_MESH_LIGHT_CONTROL_REGULATOR_KIU_LEN 4 +#define BLE_MESH_LIGHT_CONTROL_REGULATOR_KPD_LEN 4 +#define BLE_MESH_LIGHT_CONTROL_REGULATOR_KPU_LEN 4 +#define BLE_MESH_LIGHT_CONTROL_TIME_FADE_LEN 3 +#define BLE_MESH_LIGHT_CONTROL_TIME_FADE_ON_LEN 3 +#define BLE_MESH_LIGHT_CONTROL_TIME_FADE_STANDBY_AUTO_LEN 3 +#define BLE_MESH_LIGHT_CONTROL_TIME_FADE_STANDBY_MANUAL_LEN 3 +#define BLE_MESH_LIGHT_CONTROL_TIME_OCCUPANCY_DELAY_LEN 3 +#define BLE_MESH_LIGHT_CONTROL_TIME_PROLONG_LEN 3 +#define BLE_MESH_LIGHT_CONTROL_TIME_RUN_ON_LEN 3 +#define BLE_MESH_LUMEN_MAINTENANCE_FACTOR_LEN 1 +#define BLE_MESH_LUMINOUS_EFFICACY_LEN 2 +#define BLE_MESH_LUMINOUS_ENERGY_SINCE_TURN_ON_LEN 3 +#define BLE_MESH_LUMINOUS_EXPOSURE_LEN 3 +#define BLE_MESH_LUMINOUS_FLUX_RANGE_LEN 4 +#define BLE_MESH_MOTION_SENSED_LEN 1 +#define BLE_MESH_MOTION_THRESHOLD_LEN 1 +#define BLE_MESH_OPEN_CIRCUIT_EVENT_STATISTICS_LEN 6 +#define BLE_MESH_OUTDOOR_STATISTICAL_VALUES_LEN 5 +#define BLE_MESH_OUTPUT_CURRENT_RANGE_LEN 4 +#define BLE_MESH_OUTPUT_CURRENT_STATISTICS_LEN 9 +#define BLE_MESH_OUTPUT_RIPPLE_VOLTAGE_SPECIFICATION_LEN 1 +#define BLE_MESH_OUTPUT_VOLTAGE_RANGE_LEN 6 +#define BLE_MESH_OUTPUT_VOLTAGE_STATISTICS_LEN 9 +#define BLE_MESH_OVER_OUTPUT_RIPPLE_VOLTAGE_EVENT_STATISTICS_LEN 6 +#define BLE_MESH_PEOPLE_COUNT_LEN 2 +#define BLE_MESH_PRESENCE_DETECTED_LEN 1 +#define BLE_MESH_PRESENT_AMBIENT_LIGHT_LEVEL_LEN 3 +#define BLE_MESH_PRESENT_AMBIENT_TEMPERATURE_LEN 1 +#define BLE_MESH_PRESENT_CIE_1931_CHROMATICITY_LEN 4 +#define BLE_MESH_PRESENT_CORRELATED_COLOR_TEMPERATURE_LEN 2 +#define BLE_MESH_PRESENT_DEVICE_INPUT_POWER_LEN 3 +#define BLE_MESH_PRESENT_DEVICE_OPERATING_EFFICIENCY_LEN 1 +#define BLE_MESH_PRESENT_DEVICE_OPERATING_TEMPERATURE_LEN 2 +#define BLE_MESH_PRESENT_ILLUMINANCE_LEN 3 +#define BLE_MESH_PRESENT_INDOOR_AMBIENT_TEMPERATURE_LEN 1 +#define BLE_MESH_PRESENT_INPUT_CURRENT_LEN 2 +#define BLE_MESH_PRESENT_INPUT_RIPPLE_VOLTAGE_LEN 1 +#define BLE_MESH_PRESENT_INPUT_VOLTAGE_LEN 2 +#define BLE_MESH_PRESENT_LUMINOUS_FLUX_LEN 2 +#define BLE_MESH_PRESENT_OUTDOOR_AMBIENT_TEMPERATURE_LEN 1 +#define BLE_MESH_PRESENT_OUTPUT_CURRENT_LEN 2 +#define BLE_MESH_PRESENT_OUTPUT_VOLTAGE_LEN 2 +#define BLE_MESH_PRESENT_PLANCKIAN_DISTANCE_LEN 2 +#define BLE_MESH_PRESENT_RELATIVE_OUTPUT_RIPPLE_VOLTAGE_LEN 1 +#define BLE_MESH_RELATIVE_DEVICE_ENERGY_USE_IN_A_PERIOD_OF_DAY_LEN 5 +#define BLE_MESH_RELATIVE_DEVICE_RUNTIME_IN_A_GENERIC_LEVEL_RANGE_LEN 5 +#define BLE_MESH_RELATIVE_EXPOSURE_TIME_IN_AN_ILLUMINANCE_RANGE_LEN 5 +#define BLE_MESH_RELATIVE_RUNTIME_IN_A_CORRELATED_COLOR_TEMPERATURE_RANGE_LEN 3 +#define BLE_MESH_RELATIVE_RUNTIME_IN_A_DEVICE_OPERATING_TEMPERATURE_RANGE_LEN 3 +#define BLE_MESH_RELATIVE_RUNTIME_IN_AN_INPUT_CURRENT_RANGE_LEN 5 +#define BLE_MESH_RELATIVE_RUNTIME_IN_AN_INPUT_VOLTAGE_RANGE_LEN 5 +#define BLE_MESH_SHORT_CIRCUIT_EVENT_STATISTICS_LEN 6 +#define BLE_MESH_TIME_SINCE_MOTION_SENSED_LEN 2 +#define BLE_MESH_TIME_SINCE_PRESENCE_DETECTED_LEN 2 +#define BLE_MESH_TOTAL_DEVICE_ENERGY_USE_LEN 3 +#define BLE_MESH_TOTAL_DEVICE_OFF_ON_CYCLES_LEN 3 +#define BLE_MESH_TOTAL_DEVICE_POWER_ON_CYCLES_LEN 3 +#define BLE_MESH_TOTAL_DEVICE_POWER_ON_TIME_LEN 3 +#define BLE_MESH_TOTAL_DEVICE_RUNTIME_LEN 3 +#define BLE_MESH_TOTAL_LIGHT_EXPOSURE_TIME_LEN 3 +#define BLE_MESH_TOTAL_LUMINOUS_ENERGY_LEN 3 +#define BLE_MESH_DESIRED_AMBIENT_TEMPERATURE_LEN 1 +#define BLE_MESH_PRECISE_TOTAL_DEVICE_ENERGY_USE_LEN 4 +#define BLE_MESH_POWER_FACTOR_LEN 1 +#define BLE_MESH_SENSOR_GAIN_LEN 4 +#define BLE_MESH_PRECISE_PRESENT_AMBIENT_TEMPERATURE_LEN 2 +#define BLE_MESH_PRESENT_AMBIENT_RELATIVE_HUMIDITY_LEN 2 +#define BLE_MESH_PRESENT_AMBIENT_CARBON_DIOXIDE_CONCENTRATION_LEN 2 +#define BLE_MESH_PRESENT_AMBIENT_VOLATILE_ORGANIC_COMPOUNDS_CONCENTRATION_LEN 2 +#define BLE_MESH_PRESENT_AMBIENT_NOISE_LEN 1 +#define BLE_MESH_ACTIVE_ENERGY_LOADSIDE_LEN 4 +#define BLE_MESH_ACTIVE_POWER_LOADSIDE_LEN 3 +#define BLE_MESH_AIR_PRESSURE_LEN 4 +#define BLE_MESH_APPARENT_ENERGY_LEN 4 +#define BLE_MESH_APPARENT_POWER_LEN 3 +#define BLE_MESH_APPARENT_WIND_DIRECTION_LEN 2 +#define BLE_MESH_APPARENT_WIND_SPEED_LEN 2 +#define BLE_MESH_DEW_POINT_LEN 1 +#define BLE_MESH_EXTERNAL_SUPPLY_VOLTAGE_LEN 3 +#define BLE_MESH_EXTERNAL_SUPPLY_VOLTAGE_FREQUENCY_LEN 2 +#define BLE_MESH_GUST_FACTOR_LEN 1 +#define BLE_MESH_HEAT_INDEX_LEN 1 +#define BLE_MESH_LIGHT_DISTRIBUTION_LEN 1 +#define BLE_MESH_LIGHT_SOURCE_CURRENT_LEN 3 +#define BLE_MESH_LIGHT_SOURCE_ON_TIME_NOT_RESETTABLE_LEN 4 +#define BLE_MESH_LIGHT_SOURCE_ON_TIME_RESETTABLE_LEN 4 +#define BLE_MESH_LIGHT_SOURCE_OPEN_CIRCUIT_STATISTICS_LEN 6 +#define BLE_MESH_LIGHT_SOURCE_OVERALL_FAILURES_STATISTICS_LEN 6 +#define BLE_MESH_LIGHT_SOURCE_SHORT_CIRCUIT_STATISTICS_LEN 6 +#define BLE_MESH_LIGHT_SOURCE_START_COUNTER_RESETTABLE_LEN 3 +#define BLE_MESH_LIGHT_SOURCE_TEMPERATURE_LEN 2 +#define BLE_MESH_LIGHT_SOURCE_THERMAL_DERATING_STATISTICS_LEN 6 +#define BLE_MESH_LIGHT_SOURCE_THERMAL_SHUTDOWN_STATISTICS_LEN 6 +#define BLE_MESH_LIGHT_SOURCE_TOTAL_POWER_ON_CYCLES_LEN 3 +#define BLE_MESH_LIGHT_SOURCE_VOLTAGE_LEN 3 +#define BLE_MESH_LUMINAIRE_COLOR_LEN 24 +#define BLE_MESH_LUMINAIRE_IDENTIFICATION_NUMBER_LEN 24 +#define BLE_MESH_LUMINAIRE_MANUFACTURER_GTIN_LEN 6 +#define BLE_MESH_LUMINAIRE_NOMINAL_INPUT_POWER_LEN 3 +#define BLE_MESH_LUMINAIRE_NOMINAL_MAXIMUM_AC_MAINS_VOLTAGE_LEN 2 +#define BLE_MESH_LUMINAIRE_NOMINAL_MINIMUM_AC_MAINS_VOLTAGE_LEN 2 +#define BLE_MESH_LUMINAIRE_POWER_AT_MINIMUM_DIM_LEVEL_LEN 3 +#define BLE_MESH_LUMINAIRE_TIME_OF_MANUFACTURE_LEN 3 +#define BLE_MESH_MAGNETIC_DECLINATION_LEN 2 +#define BLE_MESH_MAGNETIC_FLUX_DENSITY_2D_LEN 4 +#define BLE_MESH_MAGNETIC_FLUX_DENSITY_3D_LEN 6 +#define BLE_MESH_NOMINAL_LIGHT_OUTPUT_LEN 3 +#define BLE_MESH_OVERALL_FAILURE_CONDITION_LEN 6 +#define BLE_MESH_POLLEN_CONCENTRATION_LEN 3 +#define BLE_MESH_PRESENT_INDOOR_RELATIVE_HUMIDITY_LEN 2 +#define BLE_MESH_PRESENT_OUTDOOR_RELATIVE_HUMIDITY_LEN 2 +#define BLE_MESH_PRESSURE_LEN 4 +#define BLE_MESH_RAINFALL_LEN 2 +#define BLE_MESH_RATED_MEDIAN_USEFUL_LIFE_OF_LUMINAIRE_LEN 3 +#define BLE_MESH_RATED_MEDIAN_USEFUL_LIGHT_SOURCE_STARTS_LEN 3 +#define BLE_MESH_REFERENCE_TEMPERATURE_LEN 2 +#define BLE_MESH_TOTAL_DEVICE_STARTS_LEN 3 +#define BLE_MESH_TRUE_WIND_DIRECTION_LEN 2 +#define BLE_MESH_TRUE_WIND_SPEED_LEN 2 +#define BLE_MESH_UV_INDEX_LEN 1 +#define BLE_MESH_WIND_CHILL_LEN 1 +#define BLE_MESH_LIGHT_SOURCE_TYPE_LEN 1 +#define BLE_MESH_LUMINAIRE_IDENTIFICATION_STRING_LEN 64 +#define BLE_MESH_OUTPUT_POWER_LIMITATION_LEN 6 +#define BLE_MESH_THERMAL_DERATING_LEN 6 +#define BLE_MESH_OUTPUT_CURRENT_PERCENT_LEN 1 + +/** + * @brief BLE Mesh Device Property referenced Characteristic UUIDs + */ +#define BLE_MESH_UUID_AVERAGE_CURRENT_VAL 0x2AE0 +#define BLE_MESH_UUID_AVERAGE_VOLTAGE_VAL 0x2AE1 +#define BLE_MESH_UUID_BOOLEAN_VAL 0x2AE2 +#define BLE_MESH_UUID_CHROMATIC_DISTANCE_FROM_PLANCKIAN_VAL 0x2AE3 +#define BLE_MESH_UUID_CHROMATICITY_COORDINATE_VAL 0x2B1C +#define BLE_MESH_UUID_CHROMATICITY_COORDINATES_VAL 0x2AE4 +#define BLE_MESH_UUID_CHROMATICITY_IN_CCT_AND_DUV_VALUES_VAL 0x2AE5 +#define BLE_MESH_UUID_CHROMATICITY_TOLERANCE_VAL 0x2AE6 +#define BLE_MESH_UUID_CIE_13_3_1995_COLOR_RENDERING_INDEX_VAL 0x2AE7 +#define BLE_MESH_UUID_COEFFICIENT_VAL 0x2AE8 +#define BLE_MESH_UUID_CORRELATED_COLOR_TEMPERATURE_VAL 0x2AE9 +#define BLE_MESH_UUID_COUNT_16_VAL 0x2AEA +#define BLE_MESH_UUID_COUNT_24_VAL 0x2AEB +#define BLE_MESH_UUID_COUNTRY_CODE_VAL 0x2AEC +#define BLE_MESH_UUID_DATE_UTC_VAL 0x2AED +#define BLE_MESH_UUID_ELECTRIC_CURRENT_VAL 0x2AEE +#define BLE_MESH_UUID_ELECTRIC_CURRENT_RANGE_VAL 0x2AEF +#define BLE_MESH_UUID_ELECTRIC_CURRENT_SPECIFICATION_VAL 0x2AF0 +#define BLE_MESH_UUID_ELECTRIC_CURRENT_STATISTICS_VAL 0x2AF1 +#define BLE_MESH_UUID_ENERGY_VAL 0x2AF2 +#define BLE_MESH_UUID_ENERGY_IN_A_PERIOD_OF_DAY_VAL 0x2AF3 +#define BLE_MESH_UUID_EVENT_STATISTICS_VAL 0x2AF4 +#define BLE_MESH_UUID_FIXED_STRING_16_VAL 0x2AF5 +#define BLE_MESH_UUID_FIXED_STRING_24_VAL 0x2AF6 +#define BLE_MESH_UUID_FIXED_STRING_36_VAL 0x2AF7 +#define BLE_MESH_UUID_FIXED_STRING_8_VAL 0x2AF8 +#define BLE_MESH_UUID_GENERIC_LEVEL_VAL 0x2AF9 +#define BLE_MESH_UUID_GLOBAL_TRADE_ITEM_NUMBER_VAL 0x2AFA +#define BLE_MESH_UUID_ILLUMINANCE_VAL 0x2AFB +#define BLE_MESH_UUID_LUMINOUS_EFFICACY_VAL 0x2AFC +#define BLE_MESH_UUID_LUMINOUS_ENERGY_VAL 0x2AFD +#define BLE_MESH_UUID_LUMINOUS_EXPOSURE_VAL 0x2AFE +#define BLE_MESH_UUID_LUMINOUS_FLUX_VAL 0x2AFF +#define BLE_MESH_UUID_LUMINOUS_FLUX_RANGE_VAL 0x2B00 +#define BLE_MESH_UUID_LUMINOUS_INTENSITY_VAL 0x2B01 +#define BLE_MESH_UUID_MASS_FLOW_VAL 0x2B02 +/** + * The following four have been defined in mesh_uuid.h + * #define BLE_MESH_UUID_MESH_PROV_DATA_IN_VAL 0x2ADB + * #define BLE_MESH_UUID_MESH_PROV_DATA_OUT_VAL 0x2ADC + * #define BLE_MESH_UUID_MESH_PROXY_DATA_IN_VAL 0x2ADD + * #define BLE_MESH_UUID_MESH_PROXY_DATA_OUT_VAL 0x2ADE + */ +#define BLE_MESH_UUID_PERCEIVED_LIGHTNESS_VAL 0x2B03 +#define BLE_MESH_UUID_PERCENTAGE_8_VAL 0x2B04 +#define BLE_MESH_UUID_POWER_VAL 0x2B05 +#define BLE_MESH_UUID_POWER_SPECIFICATION_VAL 0x2B06 +#define BLE_MESH_UUID_RELATIVE_RUNTIME_IN_A_CURRENT_RANGE_VAL 0x2B07 +#define BLE_MESH_UUID_RELATIVE_RUNTIME_IN_A_GENERIC_LEVEL_RANGE_VAL 0x2B08 +#define BLE_MESH_UUID_RELATIVE_VALUE_IN_A_PERIOD_OF_DAY_VAL 0x2B0B +#define BLE_MESH_UUID_RELATIVE_VALUE_IN_A_TEMPERATURE_RANGE_VAL 0x2B0C +#define BLE_MESH_UUID_RELATIVE_VALUE_IN_A_VOLTAGE_RANGE_VAL 0x2B09 +#define BLE_MESH_UUID_RELATIVE_VALUE_IN_AN_ILLUMINANCE_RANGE_VAL 0x2B0A +#define BLE_MESH_UUID_TEMPERATURE_8_VAL 0x2B0D +#define BLE_MESH_UUID_TEMPERATURE_8_IN_A_PERIOD_OF_DAY_VAL 0x2B0E +#define BLE_MESH_UUID_TEMPERATURE_8_STATISTICS_VAL 0x2B0F +#define BLE_MESH_UUID_TEMPERATURE_RANGE_VAL 0x2B10 +#define BLE_MESH_UUID_TEMPERATURE_STATISTICS_VAL 0x2B11 +#define BLE_MESH_UUID_TIME_DECIHOUR_8_VAL 0x2B12 +#define BLE_MESH_UUID_TIME_EXPONENTIAL_8_VAL 0x2B13 +#define BLE_MESH_UUID_TIME_HOUR_24_VAL 0x2B14 +#define BLE_MESH_UUID_TIME_MILLISECOND_24_VAL 0x2B15 +#define BLE_MESH_UUID_TIME_SECOND_16_VAL 0x2B16 +#define BLE_MESH_UUID_TIME_SECOND_8_VAL 0x2B17 +#define BLE_MESH_UUID_VOLTAGE_VAL 0x2B18 +#define BLE_MESH_UUID_VOLTAGE_SPECIFICATION_VAL 0x2B19 +#define BLE_MESH_UUID_VOLTAGE_STATISTICS_VAL 0x2B1A +#define BLE_MESH_UUID_VOLUME_FLOW_VAL 0x2B1B + +/** + * @brief BLE Mesh Device Property referenced Characteristic Type Definitions + */ + +/* Unit is in degrees Celsius with a resolution of 0.01 degrees Celsius. */ +typedef int16_t bt_mesh_temperature_t; + +typedef uint16_t bt_mesh_gap_appearance_t; + +/* Mesh Characteristics Type Definitions */ + +/* This characteristic represents an electric current. + * Note: Unit is ampere with a resolution of 0.01. + * Minimum value: 0, maximum value: 655.34; + * A value of 0xFFFF represents 'value is not known'. + */ +typedef uint16_t bt_mesh_electric_current_t; + +/* The Time Exponential 8 characteristic is used to represent a measure of period of + * time in seconds. + * Note: The time duration is given by the value 1.1^(N-64) in seconds, with N being + * the raw 8-bit value; + * Minimum value: 0.0, maximum value: 73216705; + * A raw value of 0x00 represents 0 seconds, and a raw value of 0xFF represents + * the total life of the device. + */ +typedef uint8_t bt_mesh_time_exponential_8_t; + +/* The Voltage characteristic is used to represent a measure of positive electric + * potential difference in units of volts. + * Note: Unit is volt with a resolution of 1/64V; + * Minimum value: 0.0, maximum value: 1022.0; + * A value of 0xFFFF represents 'value is not known'. The minimum representable + * value represents the minimum value or lower, the maximum representable value + * represents the maximum value or higher. + */ +typedef uint16_t bt_mesh_voltage_t; + +/* This characteristic aggregates the Electric Current characteristic and instance of + * the Time Exponential 8 characteristic. + */ +typedef struct __packed average_current { + bt_mesh_electric_current_t electric_current; + bt_mesh_time_exponential_8_t sensing_duration; +} bt_mesh_average_current_t; + +/* This characteristic aggregates the Voltage characteristic and instance of the Time + * Exponential 8 characteristic. + */ +typedef struct __packed average_voltage { + bt_mesh_voltage_t voltage; + bt_mesh_time_exponential_8_t sensing_duration; +} bt_mesh_average_voltage_t; + +/* The Boolean characteristic defines the predefined Boolean values as an enumeration. + * Key | Value + * 0 | False + * 1 | True + * 2 to 255 | Prohibited + */ +typedef uint8_t bt_mesh_boolean_t; + +/* The Chromatic Distance From Planckian characteristic represents a distance of a + * chromaticity coordinate from the Planckian locus in the (u',2/3 v') diagram as + * defined by ANSI standard C78.377-2008. The distance is positive if the chromaticity + * coordinate is located above the Planckian locus (i.e. has as higher y value than the + * Planckian), and negative if it is located below. The distance is only valid within + * the range from -0.05 to 0.05. + * Note: Unit is unitless with a resolution of 0.00001; + * Minimum value: -0.05, maximum value: 0.05; + * A value of 0xFFFF represents 'value is not known'; + * A value of 0xFFFE represents 'value is not valid'. + */ +typedef int16_t bt_mesh_chromatic_distance_from_planckian_t; + +/* This characteristic represents a chromaticity coordinate in a color diagram such as + * the CIE1931 diagram. It can represent an x or y coordinate. + * Note: Unit is unitless with a resolution of 1/65535; + * Minimum value: 0, maximum value: 1.0. + */ +typedef uint16_t bt_mesh_chromaticity_coordinate_t; + +/* This characteristic represents a chromaticity coordinate as a tuple with an x and + * y coordinate. + */ +typedef struct __packed chromaticity_coordinates { + bt_mesh_chromaticity_coordinate_t chromaticity_x_coordinate; + bt_mesh_chromaticity_coordinate_t chromaticity_y_coordinate; +} bt_mesh_chromaticity_coordinates_t; + +/* The Correlated Color Temperature characteristic is used to represent correlated color + * temperature in a range from 800 to 65534 Kelvin with a resolution of 1 Kelvin. + * Note: Unit is Kelvin with a resolution of 1; + * Minimum value: 800, maximum value: 65534; + * A value of 0xFFFF represents 'value is not known'. + */ +typedef uint16_t bt_mesh_correlated_color_temperature_t; + +/* The Chromaticity In CCT And Duv Values characteristic is a composite characteristic + * consisting of the Correlated Color Temperature characteristic and the Chromatic + * Distance From Planckian characteristic. + */ +typedef struct __packed chromaticity_in_cct_and_duv_values { + bt_mesh_correlated_color_temperature_t correlated_color_temperature; + bt_mesh_chromatic_distance_from_planckian_t chromaticity_distance_from_planckian; +} bt_mesh_chromaticity_in_cct_and_duv_values_t; + +/* The Chromaticity Tolerance characteristic is a tolerance of a tuple of chromaticity + * values represented as a value of a radius of a circle in the CIE 1976 (u',v') diagram; + * value corresponding to the 3-sigma values of the expected chromaticity deviations. + * Note: Unit is unitless with a resolution of 0.0001; + * Minimum value: 0, maximum value: 0.0255. + */ +typedef uint8_t bt_mesh_chromaticity_tolerance_t; + +/* The CIE 13.3-1995 Color Rendering Index characteristic is a color rendition index value + * for a color patch as calculated in accordance with the CIE 13.3-1995 standard. + * Note: Unit is unitless with a resolution of 1; + * Minimum value: -128, maximum value: 100. + */ +typedef int8_t bt_mesh_cie_13_3_1995_color_rendering_index_t; + +/* The Coefficient characteristic is used to represent a general coefficient value. */ +typedef float bt_mesh_coefficient_t; + +/* The Count 16 characteristic is used to represent a general count value. + * Note: Unit is unitless with a resolution of 1; + * Minimum value: 0, maximum value 65534; + * A value of 0xFFFF represents 'value is not known'. + */ +typedef uint16_t bt_mesh_count_16_t; + +/* The Count 24 characteristic is used to represent a general count value. + * Note: Unit is unitless with a resolution of 1; + * Minimum value: 0, maximum value 16777214; + * A value of 0xFFFFFF represents 'value is not known'. + */ +typedef uint8_t bt_mesh_count_24_t[3]; + +/* This characteristic represents a country or dependent areas in accordance with + * the ISO 3166-1 Numeric standard. + * Note: Unit is unitless with a resolution of 1; + * Minimum value: 0, maximum value: 4095; + * A value of 0xFFFF represents 'value is not known'. + */ +typedef uint16_t bt_mesh_country_code_t; + +/* Date as days elapsed since the Epoch (Jan 1, 1970) in the Coordinated Universal + * Time (UTC) time zone. + * Note: Unit is a day with a resolution of 1; + * Minimum value: 1, maximum value: 16777214; + * A value of 0x000000 represents 'value is not known'. + */ +typedef uint8_t bt_mesh_date_utc_t[3]; + +/* This characteristic aggregates two instances of the Electric Current characteristic + * to represent a range of Electric Current values. + */ +typedef struct __packed electric_current_range { + bt_mesh_electric_current_t minimum_electric_current_value; + bt_mesh_electric_current_t maximum_electric_current_value; +} bt_mesh_electric_current_range_t; + +/* This characteristic aggregates three instances of the Electric Current characteristic + * to represent a specification of electric current values. + */ +typedef struct __packed electric_current_specification { + bt_mesh_electric_current_t minimum_electric_current_value; + bt_mesh_electric_current_t typical_electric_current_value; + bt_mesh_electric_current_t maximum_electric_current_value; +} bt_mesh_electric_current_specification_t; + +/* This characteristic aggregates four instances of the Electric Current characteristic + * with a Sensing Duration to represent a set of statistical electric current values. + */ +typedef struct __packed electric_current_statistics { + bt_mesh_electric_current_t average_electric_current_value; + bt_mesh_electric_current_t standard_electric_current_value; + bt_mesh_electric_current_t minimum_electric_current_value; + bt_mesh_electric_current_t maximum_electric_current_value; + bt_mesh_time_exponential_8_t sensing_duration; +} bt_mesh_electric_current_statistics_t; + +/* The Energy characteristic is used to represent a measure of energy in units of + * kilowatt hours. + * Note: Unit is kilowatt-hour with a resolution of 1; + * Minimum value: 0, maximum value: 16777214; + * A value of 0xFFFFFF represents ‘value is not known’. + */ +typedef uint8_t bt_mesh_energy_t[3]; + +/* The Time Decihour 8 characteristic is used to represent a period of time in + * tenths of an hour. + * Note: Unit is hour with a resolution of 0.1; + * Minimum value: 0.0, maximum value: 24.0; + * A value of 0xFF represents 'value is not known'. All other values are Prohibited. + */ +typedef uint8_t bt_mesh_time_decihour_8_t; + +/* This characteristic aggregates the Energy characteristic, and two instances of + * the Time Decihour 8 characteristic, to represent energy use in a period of day. + */ +typedef struct __packed energy_in_a_period_of_day { + bt_mesh_energy_t energy_value; + bt_mesh_time_decihour_8_t start_time; + bt_mesh_time_decihour_8_t end_time; +} bt_mesh_energy_in_a_period_of_day_t; + +/* The Time Second 16 characteristic is used to represent a period of time with a + * unit of 1 second. + * Note: Unit is second with a resolution of 1; + * Minimum value: 0, maximum value: 65534; + * A value of 0xFFFF represents 'value is not known'. + */ +typedef uint16_t bt_mesh_time_second_16_t; + +/* This characteristic aggregates the Count 16 characteristic, two instances of the + * Time Decihour 8 characteristic and an instance of the Sensing Duration characteristic, + * to represent statistical values of events. + */ +typedef struct __packed event_statistics { + bt_mesh_count_16_t number_of_events; + bt_mesh_time_second_16_t average_event_duration; + bt_mesh_time_exponential_8_t time_elapsed_since_last_event; + bt_mesh_time_exponential_8_t sensing_duration; +} bt_mesh_event_statistics_t; + +/* The Fixed String 16 characteristic represents a 16-octet UTF-8 string. */ +typedef char bt_mesh_fixed_string_16_t[16]; + +/* The Fixed String 24 characteristic represents a 24-octet UTF-8 string. */ +typedef char bt_mesh_fixed_string_24_t[24]; + +/* The Fixed String 36 characteristic represents a 36-octet UTF-8 string. */ +typedef char bt_mesh_fixed_string_36_t[36]; + +/* The Fixed String 8 characteristic represents an 8-octet UTF-8 string. */ +typedef char bt_mesh_fixed_string_8_t[8]; + +/* The Generic Level characteristic represents a general level value of a + * setting of a device. + * Note: Unit is unitless with a resolution of 1; + * Minimum value: 0, maximum value: 65535. + */ +typedef uint16_t bt_mesh_generic_level_t; + +/* The Global Trade Item Number characteristic represents an identifier as + * issued by GS1 General Specifications, which may consist up to 14 digits, + * and is here represented as a 48-bit unsigned integer. + */ +typedef uint8_t bt_mesh_global_trade_item_number_t[6]; + +/* The Illuminance characteristic is used to represent a measure of illuminance + * in units of lux. + * Note: Unit is lux with a resolution of 0.01; + * Minimum value: 0, maximum value: 167772.14; + * A value of 0xFFFFFF represents 'value is not known'. + */ +typedef uint8_t bt_mesh_illuminance_t[3]; + +/* The Luminous Efficacy characteristic is used to represent a measure of luminous + * efficacy in units of lumen per watt. + * Note: Unit is lumen per watt with a resolution of 0.1; + * Minimum value: 0, maximum value: 1800; + * A value of 0xFFFF represents 'value is not known'. All other values are Prohibited. + */ +typedef uint16_t bt_mesh_luminous_efficacy_t; + +/* The Luminous Energy characteristic is used to represent a measure of luminous + * energy in units of lumen hour. + * Note: Unit is lumen hour with a resolution of 1000; + * Minimum value: 0, maximum value: 16777214000; + * A value of 0xFFFFFF represents 'value is not known'. + */ +typedef uint8_t bt_mesh_luminous_energy_t[3]; + +/* The Luminous Exposure characteristic is used to represent a measure of luminous + * exposure in units of lux-hour. + * Note: Unit is lux hour with a resolution of 1000; + * Minimum value: 0, maximum value: 16777214000; + * A value of 0xFFFFFF represents 'value is not known'. + */ +typedef uint8_t bt_mesh_luminous_exposure_t[3]; + +/* The Luminous Flux characteristic is used to represent a measure of luminous flux + * in units of lumen. + * Note: Unit is lumen with a resolution of 1; + * Minimum value: 0, maximum value: 65534; + * A value of 0xFFFF represents 'value is not known'. + */ +typedef uint16_t bt_mesh_luminous_flux_t; + +/* This characteristic aggregates two instances of the Luminous Flux characteristic + * to represent a luminous flux range. + */ +typedef struct __packed luminous_flux_range { + bt_mesh_luminous_flux_t minimum_luminous_flux; + bt_mesh_luminous_flux_t maximum_luminous_flux; +} bt_mesh_luminous_flux_range_t; + +/* The Luminous Intensity characteristic is used to represent a luminous intensity of + * a beam of light in units of candela. + * Note: Unit is candela with a resolution of 1; + * Minimum value: 0, maximum value: 65534; + * A value of 0xFFFF represents 'value is not known'. + */ +typedef uint16_t bt_mesh_luminous_intensity_t; + +/* The Mass Flow characteristic is used to represent a flow of mass. + * Note: Unit is gram/second with a resolution of 1; + * Minimum value: 0, maximum value: 65534; + * A value of 0xFFFF represents 'value is not known'. + */ +typedef uint16_t bt_mesh_mass_flow_t; + +/* The Mesh Provisioning Data In characteristic can be written to send a Proxy PDU + * message containing Provisioning PDU to the Provisioning Server. + */ +struct mesh_provisioning_data_in { + +}; + +/* The Mesh Provisioning Data Out characteristic can be notified to send a Proxy PDU + * message containing Provisioning PDU from a Provisioning Server to a Provisioning Client. + */ +struct mesh_provisioning_data_out { + +}; + +/* The Mesh Proxy Data In characteristic is used by the client to send Proxy PDUs to + * the server. + */ +struct mesh_proxy_data_in { + +}; + +/* The Mesh Proxy Data Out characteristic is used by the server to send Proxy PDUs to + * the client. + */ +struct mesh_proxy_data_out { + +}; + +/* The Perceived Lightness characteristic is used to represent the perceived lightness + * of a light. + * Note: Unit is unitless with a resolution of 1; + * Minimum value: 0, maximum value: 65535. + */ +typedef uint16_t bt_mesh_perceived_lightness_t; + +/* The Percentage 8 characteristic is used to represent a measure of percentage. + * Note: Unit is a percentage with a resolution of 0.5; + * Minimum value: 0, maximum value: 100; + * A value of 0xFF represents 'value is not known'. All other values are Prohibited. + */ +typedef uint8_t bt_mesh_percentage_8_t; + +/* The Power characteristic is used to represent a measure of power in units of watts. + * Note: Unit is watt with a resolution of 0.1; + * Minimum value: 0, maximum value: 1677721.4; + * A value of 0xFFFFFF represents 'value is not known'. + */ +typedef uint8_t bt_mesh_power_t[3]; + +/* This characteristic aggregates three instances of the Power characteristic to + * represent a specification of Power values. + */ +typedef struct __packed power_specification { + bt_mesh_power_t minimum_power_value; + bt_mesh_power_t typical_power_value; + bt_mesh_power_t maximum_power_value; +} bt_mesh_power_specification_t; + +/* This characteristic aggregates the Percentage 8 characteristic and two instances of + * the Electric Current characteristic to represent a relative value in an electric + * current range. + */ +typedef struct __packed relative_runtime_in_a_current_range { + bt_mesh_percentage_8_t relative_runtime_value; + bt_mesh_electric_current_t minimum_current; + bt_mesh_electric_current_t maximum_current; +} bt_mesh_relative_runtime_in_a_current_range_t; + +/* This characteristic aggregates the Percentage 8 characteristic and two instances of + * the Generic Level characteristic to represent a runtime in a generic level range. + */ +typedef struct __packed relative_runtime_in_a_generic_level_range { + bt_mesh_percentage_8_t relative_value; + bt_mesh_generic_level_t minimum_generic_level; + bt_mesh_generic_level_t maximum_generic_level; +} bt_mesh_relative_runtime_in_a_generic_level_range_t; + +/* This characteristic aggregates the Percentage 8 characteristic, and two instances of + * the Time Decihour 8 characteristic. + */ +typedef struct __packed relative_value_in_a_period_of_day { + bt_mesh_percentage_8_t relative_value; + bt_mesh_time_decihour_8_t start_time; + bt_mesh_time_decihour_8_t end_time; +} bt_mesh_relative_value_in_a_period_of_day_t; + +/* This characteristic aggregates the Percentage 8 characteristic, and two instances of + * the Temperature characteristic. + */ +typedef struct __packed relative_value_in_a_temperature_range { + bt_mesh_percentage_8_t relative_value; + bt_mesh_temperature_t minimum_temperature_value; + bt_mesh_temperature_t maximum_temperature_value; +} bt_mesh_relative_value_in_a_temperature_range_t; + +/* This characteristic aggregates the Percentage 8 characteristic and two instances of + * the Voltage characteristic to represent a relative value in a voltage range. + */ +typedef struct __packed relative_value_in_a_voltage_range { + bt_mesh_percentage_8_t relative_value; + bt_mesh_voltage_t minimum_voltage; + bt_mesh_voltage_t maximum_voltage; +} bt_mesh_relative_value_in_a_voltage_range_t; + +/* This characteristic aggregates the Percentage 8 characteristic and two instances of + * the Illuminance characteristic to represent a relative value in a illuminance range. + */ +typedef struct __packed relative_value_in_an_illuminance_range { + bt_mesh_percentage_8_t relative_value; + bt_mesh_illuminance_t minimum_illuminance; + bt_mesh_illuminance_t maximum_illuminance; +} bt_mesh_relative_value_in_an_illuminance_range_t; + +/* The Temperature 8 characteristic is used to represent a measure of temperature with + * a unit of 0.5 degree Celsius. + * Note: Unit is degree Celsius with a resolution of 0.5; + * Minimum value: -64.0, maximum value: 63.5; + * A value of 0xFF represents 'value is not known'. + */ +typedef int8_t bt_mesh_temperature_8_t; + +/* This characteristic aggregates the Temperature 8 characteristic, and two instances + * of the Time Decihour 8 characteristic, to represent a temperature value in a period + * of day. + */ +typedef struct __packed temperature_8_in_a_period_of_day { + bt_mesh_temperature_8_t temperature; + bt_mesh_time_decihour_8_t start_time; + bt_mesh_time_decihour_8_t end_time; +} bt_mesh_temperature_8_in_a_period_of_day_t; + +/* This characteristic aggregates four instances of the Temperature 8 characteristic, + * and one instance of the Time Exponential 8 characteristic. + */ +typedef struct __packed temperature_8_statistics { + bt_mesh_temperature_8_t average; + bt_mesh_temperature_8_t standard_deviation_value; + bt_mesh_temperature_8_t minimum_value; + bt_mesh_temperature_8_t maximum_value; + bt_mesh_time_exponential_8_t sensing_duration; +} bt_mesh_temperature_8_statistics_t; + +/* This characteristic aggregates two instances of the Temperature characteristic to + * represent a temperature range. + */ +typedef struct __packed temperature_range { + bt_mesh_temperature_t minimum_temperature; + bt_mesh_temperature_t maximum_temperature; +} bt_mesh_temperature_range_t; + +/* This characteristic aggregates four instances of the Temperature characteristic, + * and one instance of the Time Exponential 8 characteristic. + */ +typedef struct __packed temperature_statistics { + bt_mesh_temperature_t average_temperature; + bt_mesh_temperature_t standard_deviation_temperature; + bt_mesh_temperature_t minimum_temperature; + bt_mesh_temperature_t maximum_temperature; + bt_mesh_time_exponential_8_t sensing_duration; +} bt_mesh_temperature_statistics_t; + +/* The Time Hour 24 characteristic is used to represent a period of time in hours. + * Note: Unit is hour with a resolution of 1; + * Minimum value: 0, maximum value: 16777214; + * A value of 0xFFFFFF represents 'value is not known'. + */ +typedef uint8_t bt_mesh_time_hour_24_t[3]; + +/* The Time Millisecond 24 characteristic is used to represent a period of time with + * a resolution of 1 millisecond. + * Note: Unit is second with a resolution of 0.001; + * Minimum value: 0, maximum value: 16777.214; + * A value of 0xFFFFFF represents 'value is not known'. + */ +typedef uint8_t bt_mesh_time_millisecond_24_t[3]; + +/* The Time Second 8 characteristic is used to represent a period of time with a unit + * of 1 second. + * Note: Unit is second with a resolution of 1; + * Minimum value: 0, maximum value: 254; + * A value of 0xFF represents 'value is not known'. + */ +typedef uint8_t bt_mesh_time_second_8_t; + +/* This characteristic aggregates three instances of the Voltage characteristic to + * represent a specification of voltage values. + */ +typedef struct __packed voltage_specification { + bt_mesh_voltage_t minimum_voltage_value; + bt_mesh_voltage_t typical_voltage_value; + bt_mesh_voltage_t maximum_voltage_value; +} bt_mesh_voltage_specification_t; + +/* This characteristic aggregates four instances of the Voltage characteristic and an + * instance of the Time Exponential 8 characteristic to represent a set of statistical + * voltage values over a period of time. + */ +typedef struct __packed voltage_statistics { + bt_mesh_voltage_t average_voltage_value; + bt_mesh_voltage_t standard_deviation_voltage_value; + bt_mesh_voltage_t minimum_voltage_value; + bt_mesh_voltage_t maximum_voltage_value; + bt_mesh_time_exponential_8_t sensing_duration; +} bt_mesh_voltage_statistics_t; + +/* The Volume Flow characteristic is used to represent a flow of a general volume such + * as a volume of material or gas. + * Note: Unit is liter/second with a resolution of 0.001 (1 milliliter); + * Minimum value: 0, maximum value: 65534; + * A value of 0xFFFF represents 'value is not known'. + */ +typedef uint16_t bt_mesh_volume_flow_t; + +/* Mesh Device Property related function */ + +uint8_t bt_mesh_get_dev_prop_len(uint16_t prop_id); + +#ifdef __cplusplus +} +#endif + +#endif /* _DEVICE_PROPERTY_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_models/common/include/model_opcode.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_models/common/include/model_opcode.h new file mode 100644 index 00000000000..29294a88990 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_models/common/include/model_opcode.h @@ -0,0 +1,276 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _MODEL_OPCODE_H_ +#define _MODEL_OPCODE_H_ + +#include "mesh_access.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Generic OnOff Message Opcode */ +#define BLE_MESH_MODEL_OP_GEN_ONOFF_GET BLE_MESH_MODEL_OP_2(0x82, 0x01) +#define BLE_MESH_MODEL_OP_GEN_ONOFF_SET BLE_MESH_MODEL_OP_2(0x82, 0x02) +#define BLE_MESH_MODEL_OP_GEN_ONOFF_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x03) +#define BLE_MESH_MODEL_OP_GEN_ONOFF_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x04) + +/* Generic Level Message Opcode */ +#define BLE_MESH_MODEL_OP_GEN_LEVEL_GET BLE_MESH_MODEL_OP_2(0x82, 0x05) +#define BLE_MESH_MODEL_OP_GEN_LEVEL_SET BLE_MESH_MODEL_OP_2(0x82, 0x06) +#define BLE_MESH_MODEL_OP_GEN_LEVEL_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x07) +#define BLE_MESH_MODEL_OP_GEN_LEVEL_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x08) +#define BLE_MESH_MODEL_OP_GEN_DELTA_SET BLE_MESH_MODEL_OP_2(0x82, 0x09) +#define BLE_MESH_MODEL_OP_GEN_DELTA_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x0A) +#define BLE_MESH_MODEL_OP_GEN_MOVE_SET BLE_MESH_MODEL_OP_2(0x82, 0x0B) +#define BLE_MESH_MODEL_OP_GEN_MOVE_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x0C) + +/* Generic Default Transition Time Message Opcode*/ +#define BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_GET BLE_MESH_MODEL_OP_2(0x82, 0x0D) +#define BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_SET BLE_MESH_MODEL_OP_2(0x82, 0x0E) +#define BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x0F) +#define BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x10) + +/* Generic Power OnOff Message Opcode*/ +#define BLE_MESH_MODEL_OP_GEN_ONPOWERUP_GET BLE_MESH_MODEL_OP_2(0x82, 0x11) +#define BLE_MESH_MODEL_OP_GEN_ONPOWERUP_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x12) + +/* Generic Power OnOff Setup Message Opcode */ +#define BLE_MESH_MODEL_OP_GEN_ONPOWERUP_SET BLE_MESH_MODEL_OP_2(0x82, 0x13) +#define BLE_MESH_MODEL_OP_GEN_ONPOWERUP_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x14) + +/* Generic Power Level Message Opcode */ +#define BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_GET BLE_MESH_MODEL_OP_2(0x82, 0x15) +#define BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_SET BLE_MESH_MODEL_OP_2(0x82, 0x16) +#define BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x17) +#define BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x18) +#define BLE_MESH_MODEL_OP_GEN_POWER_LAST_GET BLE_MESH_MODEL_OP_2(0x82, 0x19) +#define BLE_MESH_MODEL_OP_GEN_POWER_LAST_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x1A) +#define BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_GET BLE_MESH_MODEL_OP_2(0x82, 0x1B) +#define BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x1C) +#define BLE_MESH_MODEL_OP_GEN_POWER_RANGE_GET BLE_MESH_MODEL_OP_2(0x82, 0x1D) +#define BLE_MESH_MODEL_OP_GEN_POWER_RANGE_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x1E) + +/* Generic Power Level Setup Message Opcode */ +#define BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_SET BLE_MESH_MODEL_OP_2(0x82, 0x1F) +#define BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x20) +#define BLE_MESH_MODEL_OP_GEN_POWER_RANGE_SET BLE_MESH_MODEL_OP_2(0x82, 0x21) +#define BLE_MESH_MODEL_OP_GEN_POWER_RANGE_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x22) + +/* Generic Battery Message Opcode */ +#define BLE_MESH_MODEL_OP_GEN_BATTERY_GET BLE_MESH_MODEL_OP_2(0x82, 0x23) +#define BLE_MESH_MODEL_OP_GEN_BATTERY_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x24) + +/* Generic Location Message Opcode */ +#define BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_GET BLE_MESH_MODEL_OP_2(0x82, 0x25) +#define BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_STATUS BLE_MESH_MODEL_OP_1(0x40) +#define BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_GET BLE_MESH_MODEL_OP_2(0x82, 0x26) +#define BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x27) + +/* Generic Location Setup Message Opcode */ +#define BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_SET BLE_MESH_MODEL_OP_1(0x41) +#define BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_SET_UNACK BLE_MESH_MODEL_OP_1(0x42) +#define BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_SET BLE_MESH_MODEL_OP_2(0x82, 0x28) +#define BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x29) + +/* Generic Manufacturer Property Message Opcode */ +#define BLE_MESH_MODEL_OP_GEN_MANU_PROPERTIES_GET BLE_MESH_MODEL_OP_2(0x82, 0x2A) +#define BLE_MESH_MODEL_OP_GEN_MANU_PROPERTIES_STATUS BLE_MESH_MODEL_OP_1(0x43) +#define BLE_MESH_MODEL_OP_GEN_MANU_PROPERTY_GET BLE_MESH_MODEL_OP_2(0x82, 0x2B) +#define BLE_MESH_MODEL_OP_GEN_MANU_PROPERTY_SET BLE_MESH_MODEL_OP_1(0x44) +#define BLE_MESH_MODEL_OP_GEN_MANU_PROPERTY_SET_UNACK BLE_MESH_MODEL_OP_1(0x45) +#define BLE_MESH_MODEL_OP_GEN_MANU_PROPERTY_STATUS BLE_MESH_MODEL_OP_1(0x46) + +/* Generic Admin Property Message Opcode */ +#define BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTIES_GET BLE_MESH_MODEL_OP_2(0x82, 0x2C) +#define BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTIES_STATUS BLE_MESH_MODEL_OP_1(0x47) +#define BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_GET BLE_MESH_MODEL_OP_2(0x82, 0x2D) +#define BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET BLE_MESH_MODEL_OP_1(0x48) +#define BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET_UNACK BLE_MESH_MODEL_OP_1(0x49) +#define BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_STATUS BLE_MESH_MODEL_OP_1(0x4A) + +/* Generic User Property Message Opcode */ +#define BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_GET BLE_MESH_MODEL_OP_2(0x82, 0x2E) +#define BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_STATUS BLE_MESH_MODEL_OP_1(0x4B) +#define BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_GET BLE_MESH_MODEL_OP_2(0x82, 0x2F) +#define BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET BLE_MESH_MODEL_OP_1(0x4C) +#define BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET_UNACK BLE_MESH_MODEL_OP_1(0x4D) +#define BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_STATUS BLE_MESH_MODEL_OP_1(0x4E) + +/* Generic Client Property Message Opcode */ +#define BLE_MESH_MODEL_OP_GEN_CLIENT_PROPERTIES_GET BLE_MESH_MODEL_OP_1(0x4F) +#define BLE_MESH_MODEL_OP_GEN_CLIENT_PROPERTIES_STATUS BLE_MESH_MODEL_OP_1(0x50) + +/* Sensor Message Opcode */ +#define BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_GET BLE_MESH_MODEL_OP_2(0x82, 0x30) +#define BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_STATUS BLE_MESH_MODEL_OP_1(0x51) +#define BLE_MESH_MODEL_OP_SENSOR_GET BLE_MESH_MODEL_OP_2(0x82, 0x31) +#define BLE_MESH_MODEL_OP_SENSOR_STATUS BLE_MESH_MODEL_OP_1(0x52) +#define BLE_MESH_MODEL_OP_SENSOR_COLUMN_GET BLE_MESH_MODEL_OP_2(0x82, 0x32) +#define BLE_MESH_MODEL_OP_SENSOR_COLUMN_STATUS BLE_MESH_MODEL_OP_1(0x53) +#define BLE_MESH_MODEL_OP_SENSOR_SERIES_GET BLE_MESH_MODEL_OP_2(0x82, 0x33) +#define BLE_MESH_MODEL_OP_SENSOR_SERIES_STATUS BLE_MESH_MODEL_OP_1(0x54) + +/* Sensor Setup Message Opcode */ +#define BLE_MESH_MODEL_OP_SENSOR_CADENCE_GET BLE_MESH_MODEL_OP_2(0x82, 0x34) +#define BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET BLE_MESH_MODEL_OP_1(0x55) +#define BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET_UNACK BLE_MESH_MODEL_OP_1(0x56) +#define BLE_MESH_MODEL_OP_SENSOR_CADENCE_STATUS BLE_MESH_MODEL_OP_1(0x57) +#define BLE_MESH_MODEL_OP_SENSOR_SETTINGS_GET BLE_MESH_MODEL_OP_2(0x82, 0x35) +#define BLE_MESH_MODEL_OP_SENSOR_SETTINGS_STATUS BLE_MESH_MODEL_OP_1(0x58) +#define BLE_MESH_MODEL_OP_SENSOR_SETTING_GET BLE_MESH_MODEL_OP_2(0x82, 0x36) +#define BLE_MESH_MODEL_OP_SENSOR_SETTING_SET BLE_MESH_MODEL_OP_1(0x59) +#define BLE_MESH_MODEL_OP_SENSOR_SETTING_SET_UNACK BLE_MESH_MODEL_OP_1(0x5A) +#define BLE_MESH_MODEL_OP_SENSOR_SETTING_STATUS BLE_MESH_MODEL_OP_1(0x5B) + +/* Time Message Opcode */ +#define BLE_MESH_MODEL_OP_TIME_GET BLE_MESH_MODEL_OP_2(0x82, 0x37) +#define BLE_MESH_MODEL_OP_TIME_SET BLE_MESH_MODEL_OP_1(0x5C) +#define BLE_MESH_MODEL_OP_TIME_STATUS BLE_MESH_MODEL_OP_1(0x5D) +#define BLE_MESH_MODEL_OP_TIME_ROLE_GET BLE_MESH_MODEL_OP_2(0x82, 0x38) +#define BLE_MESH_MODEL_OP_TIME_ROLE_SET BLE_MESH_MODEL_OP_2(0x82, 0x39) +#define BLE_MESH_MODEL_OP_TIME_ROLE_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x3A) +#define BLE_MESH_MODEL_OP_TIME_ZONE_GET BLE_MESH_MODEL_OP_2(0x82, 0x3B) +#define BLE_MESH_MODEL_OP_TIME_ZONE_SET BLE_MESH_MODEL_OP_2(0x82, 0x3C) +#define BLE_MESH_MODEL_OP_TIME_ZONE_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x3D) +#define BLE_MESH_MODEL_OP_TAI_UTC_DELTA_GET BLE_MESH_MODEL_OP_2(0x82, 0x3E) +#define BLE_MESH_MODEL_OP_TAI_UTC_DELTA_SET BLE_MESH_MODEL_OP_2(0x82, 0x3F) +#define BLE_MESH_MODEL_OP_TAI_UTC_DELTA_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x40) + +/* Scene Message Opcode */ +#define BLE_MESH_MODEL_OP_SCENE_GET BLE_MESH_MODEL_OP_2(0x82, 0x41) +#define BLE_MESH_MODEL_OP_SCENE_RECALL BLE_MESH_MODEL_OP_2(0x82, 0x42) +#define BLE_MESH_MODEL_OP_SCENE_RECALL_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x43) +#define BLE_MESH_MODEL_OP_SCENE_STATUS BLE_MESH_MODEL_OP_1(0x5E) +#define BLE_MESH_MODEL_OP_SCENE_REGISTER_GET BLE_MESH_MODEL_OP_2(0x82, 0x44) +#define BLE_MESH_MODEL_OP_SCENE_REGISTER_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x45) + +/* Scene Setup Message Opcode */ +#define BLE_MESH_MODEL_OP_SCENE_STORE BLE_MESH_MODEL_OP_2(0x82, 0x46) +#define BLE_MESH_MODEL_OP_SCENE_STORE_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x47) +#define BLE_MESH_MODEL_OP_SCENE_DELETE BLE_MESH_MODEL_OP_2(0x82, 0x9E) +#define BLE_MESH_MODEL_OP_SCENE_DELETE_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x9F) + +/* Scheduler Message Opcode */ +#define BLE_MESH_MODEL_OP_SCHEDULER_ACT_GET BLE_MESH_MODEL_OP_2(0x82, 0x48) +#define BLE_MESH_MODEL_OP_SCHEDULER_ACT_STATUS BLE_MESH_MODEL_OP_1(0x5F) +#define BLE_MESH_MODEL_OP_SCHEDULER_GET BLE_MESH_MODEL_OP_2(0x82, 0x49) +#define BLE_MESH_MODEL_OP_SCHEDULER_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x4A) + +/* Scheduler Setup Message Opcode */ +#define BLE_MESH_MODEL_OP_SCHEDULER_ACT_SET BLE_MESH_MODEL_OP_1(0x60) +#define BLE_MESH_MODEL_OP_SCHEDULER_ACT_SET_UNACK BLE_MESH_MODEL_OP_1(0x61) + +/* Light Lightness Message Opcode */ +#define BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_GET BLE_MESH_MODEL_OP_2(0x82, 0x4B) +#define BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_SET BLE_MESH_MODEL_OP_2(0x82, 0x4C) +#define BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x4D) +#define BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x4E) +#define BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_GET BLE_MESH_MODEL_OP_2(0x82, 0x4F) +#define BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_SET BLE_MESH_MODEL_OP_2(0x82, 0x50) +#define BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x51) +#define BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x52) +#define BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LAST_GET BLE_MESH_MODEL_OP_2(0x82, 0x53) +#define BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LAST_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x54) +#define BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_GET BLE_MESH_MODEL_OP_2(0x82, 0x55) +#define BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x56) +#define BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_GET BLE_MESH_MODEL_OP_2(0x82, 0x57) +#define BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x58) + +/* Light Lightness Setup Message Opcode */ +#define BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_SET BLE_MESH_MODEL_OP_2(0x82, 0x59) +#define BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x5A) +#define BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_SET BLE_MESH_MODEL_OP_2(0x82, 0x5B) +#define BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x5C) + +/* Light CTL Message Opcode */ +#define BLE_MESH_MODEL_OP_LIGHT_CTL_GET BLE_MESH_MODEL_OP_2(0x82, 0x5D) +#define BLE_MESH_MODEL_OP_LIGHT_CTL_SET BLE_MESH_MODEL_OP_2(0x82, 0x5E) +#define BLE_MESH_MODEL_OP_LIGHT_CTL_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x5F) +#define BLE_MESH_MODEL_OP_LIGHT_CTL_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x60) +#define BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_GET BLE_MESH_MODEL_OP_2(0x82, 0x61) +#define BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_GET BLE_MESH_MODEL_OP_2(0x82, 0x62) +#define BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x63) +#define BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_SET BLE_MESH_MODEL_OP_2(0x82, 0x64) +#define BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x65) +#define BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x66) +#define BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_GET BLE_MESH_MODEL_OP_2(0x82, 0x67) +#define BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x68) + +/* Light CTL Setup Message Opcode */ +#define BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_SET BLE_MESH_MODEL_OP_2(0x82, 0x69) +#define BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x6A) +#define BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_SET BLE_MESH_MODEL_OP_2(0x82, 0x6B) +#define BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x6C) + +/* Light HSL Message Opcode */ +#define BLE_MESH_MODEL_OP_LIGHT_HSL_GET BLE_MESH_MODEL_OP_2(0x82, 0x6D) +#define BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_GET BLE_MESH_MODEL_OP_2(0x82, 0x6E) +#define BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_SET BLE_MESH_MODEL_OP_2(0x82, 0x6F) +#define BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x70) +#define BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x71) +#define BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_GET BLE_MESH_MODEL_OP_2(0x82, 0x72) +#define BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_SET BLE_MESH_MODEL_OP_2(0x82, 0x73) +#define BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x74) +#define BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x75) +#define BLE_MESH_MODEL_OP_LIGHT_HSL_SET BLE_MESH_MODEL_OP_2(0x82, 0x76) +#define BLE_MESH_MODEL_OP_LIGHT_HSL_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x77) +#define BLE_MESH_MODEL_OP_LIGHT_HSL_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x78) +#define BLE_MESH_MODEL_OP_LIGHT_HSL_TARGET_GET BLE_MESH_MODEL_OP_2(0x82, 0x79) +#define BLE_MESH_MODEL_OP_LIGHT_HSL_TARGET_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x7A) +#define BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_GET BLE_MESH_MODEL_OP_2(0x82, 0x7B) +#define BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x7C) +#define BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_GET BLE_MESH_MODEL_OP_2(0x82, 0x7D) +#define BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x7E) + +/* Light HSL Setup Message Opcode */ +#define BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_SET BLE_MESH_MODEL_OP_2(0x82, 0x7F) +#define BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x80) +#define BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_SET BLE_MESH_MODEL_OP_2(0x82, 0x81) +#define BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x82) + +/* Light xyL Message Opcode */ +#define BLE_MESH_MODEL_OP_LIGHT_XYL_GET BLE_MESH_MODEL_OP_2(0x82, 0x83) +#define BLE_MESH_MODEL_OP_LIGHT_XYL_SET BLE_MESH_MODEL_OP_2(0x82, 0x84) +#define BLE_MESH_MODEL_OP_LIGHT_XYL_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x85) +#define BLE_MESH_MODEL_OP_LIGHT_XYL_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x86) +#define BLE_MESH_MODEL_OP_LIGHT_XYL_TARGET_GET BLE_MESH_MODEL_OP_2(0x82, 0x87) +#define BLE_MESH_MODEL_OP_LIGHT_XYL_TARGET_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x88) +#define BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_GET BLE_MESH_MODEL_OP_2(0x82, 0x89) +#define BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x8A) +#define BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_GET BLE_MESH_MODEL_OP_2(0x82, 0x8B) +#define BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x8C) + +/* Light xyL Setup Message Opcode */ +#define BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_SET BLE_MESH_MODEL_OP_2(0x82, 0x8D) +#define BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x8E) +#define BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_SET BLE_MESH_MODEL_OP_2(0x82, 0x8F) +#define BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x90) + +/* Light Control Message Opcode */ +#define BLE_MESH_MODEL_OP_LIGHT_LC_MODE_GET BLE_MESH_MODEL_OP_2(0x82, 0x91) +#define BLE_MESH_MODEL_OP_LIGHT_LC_MODE_SET BLE_MESH_MODEL_OP_2(0x82, 0x92) +#define BLE_MESH_MODEL_OP_LIGHT_LC_MODE_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x93) +#define BLE_MESH_MODEL_OP_LIGHT_LC_MODE_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x94) +#define BLE_MESH_MODEL_OP_LIGHT_LC_OM_GET BLE_MESH_MODEL_OP_2(0x82, 0x95) +#define BLE_MESH_MODEL_OP_LIGHT_LC_OM_SET BLE_MESH_MODEL_OP_2(0x82, 0x96) +#define BLE_MESH_MODEL_OP_LIGHT_LC_OM_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x97) +#define BLE_MESH_MODEL_OP_LIGHT_LC_OM_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x98) +#define BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_GET BLE_MESH_MODEL_OP_2(0x82, 0x99) +#define BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_SET BLE_MESH_MODEL_OP_2(0x82, 0x9A) +#define BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_SET_UNACK BLE_MESH_MODEL_OP_2(0x82, 0x9B) +#define BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_STATUS BLE_MESH_MODEL_OP_2(0x82, 0x9C) +#define BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_GET BLE_MESH_MODEL_OP_2(0x82, 0x9D) +#define BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET BLE_MESH_MODEL_OP_1(0x62) +#define BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET_UNACK BLE_MESH_MODEL_OP_1(0x63) +#define BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_STATUS BLE_MESH_MODEL_OP_1(0x64) + +#ifdef __cplusplus +} +#endif + +#endif /* _MODEL_OPCODE_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_models/server/include/generic_server.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_models/server/include/generic_server.h new file mode 100644 index 00000000000..0e79233f958 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_models/server/include/generic_server.h @@ -0,0 +1,367 @@ +/* Bluetooth: Mesh Generic OnOff, Generic Level, Lighting & Vendor Models + * + * SPDX-FileCopyrightText: 2018 Vikrant More + * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _GENERIC_SERVER_H_ +#define _GENERIC_SERVER_H_ + +#include "server_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct bt_mesh_gen_onoff_state { + uint8_t onoff; + uint8_t target_onoff; +}; + +struct bt_mesh_gen_onoff_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_gen_onoff_state state; + struct bt_mesh_last_msg_info last; + struct bt_mesh_state_transition transition; +}; + +struct bt_mesh_gen_level_state { + int16_t level; + int16_t target_level; + + int16_t last_level; + int32_t last_delta; + + bool move_start; + bool positive; +}; + +struct bt_mesh_gen_level_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_gen_level_state state; + struct bt_mesh_last_msg_info last; + struct bt_mesh_state_transition transition; + int32_t tt_delta_level; +}; + +struct bt_mesh_gen_def_trans_time_state { + uint8_t trans_time; +}; + +struct bt_mesh_gen_def_trans_time_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_gen_def_trans_time_state state; +}; + +struct bt_mesh_gen_onpowerup_state { + uint8_t onpowerup; +}; + +struct bt_mesh_gen_power_onoff_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_gen_onpowerup_state *state; +}; + +struct bt_mesh_gen_power_onoff_setup_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_gen_onpowerup_state *state; +}; + +struct bt_mesh_gen_power_level_state { + uint16_t power_actual; + uint16_t target_power_actual; + + uint16_t power_last; + uint16_t power_default; + + uint8_t status_code; + uint16_t power_range_min; + uint16_t power_range_max; +}; + +struct bt_mesh_gen_power_level_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_gen_power_level_state *state; + struct bt_mesh_last_msg_info last; + struct bt_mesh_state_transition transition; + int32_t tt_delta_level; +}; + +struct bt_mesh_gen_power_level_setup_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_gen_power_level_state *state; +}; + +struct bt_mesh_gen_battery_state { + uint32_t battery_level : 8, + time_to_discharge : 24; + uint32_t time_to_charge : 24, + battery_flags : 8; +}; + +struct bt_mesh_gen_battery_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_gen_battery_state state; +}; + +struct bt_mesh_gen_location_state { + int32_t global_latitude; + int32_t global_longitude; + int16_t global_altitude; + int16_t local_north; + int16_t local_east; + int16_t local_altitude; + uint8_t floor_number; + uint16_t uncertainty; +}; + +struct bt_mesh_gen_location_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_gen_location_state *state; +}; + +struct bt_mesh_gen_location_setup_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_gen_location_state *state; +}; + +/** + * According to the hierarchy of Generic Property states (Model Spec section 3.1.8), + * the Manufacturer Properties and Admin Properties may contain multiple Property + * states. User Properties just a collection of which can be accessed. + * + * property_count: Number of the properties contained in the table + * properties: Table of the properties + * + * These variables need to be initialized in the application layer, the precise + * number of the properties should be set and memories used to store the property + * values should be allocated. + */ + +enum bt_mesh_gen_user_prop_access { + USER_ACCESS_PROHIBIT, + USER_ACCESS_READ, + USER_ACCESS_WRITE, + USER_ACCESS_READ_WRITE, +}; + +enum bt_mesh_gen_admin_prop_access { + ADMIN_NOT_USER_PROP, + ADMIN_ACCESS_READ, + ADMIN_ACCESS_WRITE, + ADMIN_ACCESS_READ_WRITE, +}; + +enum bt_mesh_gen_manu_prop_access { + MANU_NOT_USER_PROP, + MANU_ACCESS_READ, +}; + +struct bt_mesh_generic_property { + uint16_t id; + uint8_t user_access; + uint8_t admin_access; + uint8_t manu_access; + struct net_buf_simple *val; +}; + +struct bt_mesh_gen_user_prop_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + uint8_t property_count; + struct bt_mesh_generic_property *properties; +}; + +struct bt_mesh_gen_admin_prop_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + uint8_t property_count; + struct bt_mesh_generic_property *properties; +}; + +struct bt_mesh_gen_manu_prop_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + uint8_t property_count; + struct bt_mesh_generic_property *properties; +}; + +struct bt_mesh_gen_client_prop_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + uint8_t id_count; + uint16_t *property_ids; +}; + +typedef union { + struct { + uint8_t onoff; + } gen_onoff_set; + struct { + int16_t level; + } gen_level_set; + struct { + int16_t level; + } gen_delta_set; + struct { + int16_t level; + } gen_move_set; + struct { + uint8_t trans_time; + } gen_def_trans_time_set; + struct { + uint8_t onpowerup; + } gen_onpowerup_set; + struct { + uint16_t power; + } gen_power_level_set; + struct { + uint16_t power; + } gen_power_default_set; + struct { + uint16_t range_min; + uint16_t range_max; + } gen_power_range_set; + struct { + int32_t latitude; + int32_t longitude; + int16_t altitude; + } gen_loc_global_set; + struct { + int16_t north; + int16_t east; + int16_t altitude; + uint8_t floor_number; + uint16_t uncertainty; + } gen_loc_local_set; + struct { + uint16_t id; + struct net_buf_simple *value; + } gen_user_prop_set; + struct { + uint16_t id; + uint8_t access; + struct net_buf_simple *value; + } gen_admin_prop_set; + struct { + uint16_t id; + uint8_t access; + } gen_manu_prop_set; +} bt_mesh_gen_server_state_change_t; + +typedef union { + struct { + uint16_t id; + } user_property_get; + struct { + uint16_t id; + } admin_property_get; + struct { + uint16_t id; + } manu_property_get; + struct { + uint16_t id; + } client_properties_get; +} bt_mesh_gen_server_recv_get_msg_t; + +typedef union { + struct { + bool op_en; + uint8_t onoff; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; + } onoff_set; + struct { + bool op_en; + int16_t level; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; + } level_set; + struct { + bool op_en; + int32_t delta_level; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; + } delta_set; + struct { + bool op_en; + int16_t delta_level; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; + } move_set; + struct { + uint8_t trans_time; + } def_trans_time_set; + struct { + uint8_t onpowerup; + } onpowerup_set; + struct { + bool op_en; + uint16_t power; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; + } power_level_set; + struct { + uint16_t power; + } power_default_set; + struct { + uint16_t range_min; + uint16_t range_max; + } power_range_set; + struct { + int32_t latitude; + int32_t longitude; + int16_t altitude; + } loc_global_set; + struct { + int16_t north; + int16_t east; + int16_t altitude; + uint8_t floor_number; + uint16_t uncertainty; + } loc_local_set; + struct { + uint16_t id; + struct net_buf_simple *value; + } user_property_set; + struct { + uint16_t id; + uint8_t access; + struct net_buf_simple *value; + } admin_property_set; + struct { + uint16_t id; + uint8_t access; + } manu_property_set; +} bt_mesh_gen_server_recv_set_msg_t; + +void bt_mesh_generic_server_lock(void); +void bt_mesh_generic_server_unlock(void); + +void gen_onoff_publish(struct bt_mesh_model *model); +void gen_level_publish(struct bt_mesh_model *model); +void gen_onpowerup_publish(struct bt_mesh_model *model); +void gen_power_level_publish(struct bt_mesh_model *model, uint16_t opcode); + +#ifdef __cplusplus +} +#endif + +#endif /* _GENERIC_SERVER_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_models/server/include/lighting_server.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_models/server/include/lighting_server.h new file mode 100644 index 00000000000..a3e595a4917 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_models/server/include/lighting_server.h @@ -0,0 +1,510 @@ +/* Bluetooth: Mesh Generic OnOff, Generic Level, Lighting & Vendor Models + * + * SPDX-FileCopyrightText: 2018 Vikrant More + * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _LIGHTING_SERVER_H_ +#define _LIGHTING_SERVER_H_ + +#include "server_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct bt_mesh_light_lightness_state { + uint16_t lightness_linear; + uint16_t target_lightness_linear; + + uint16_t lightness_actual; + uint16_t target_lightness_actual; + + uint16_t lightness_last; + uint16_t lightness_default; + + uint8_t status_code; + uint16_t lightness_range_min; + uint16_t lightness_range_max; +}; + +struct bt_mesh_light_lightness_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_light_lightness_state *state; + struct bt_mesh_last_msg_info last; + struct bt_mesh_state_transition actual_transition; + struct bt_mesh_state_transition linear_transition; + int32_t tt_delta_lightness_actual; + int32_t tt_delta_lightness_linear; +}; + +struct bt_mesh_light_lightness_setup_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_light_lightness_state *state; +}; + +struct bt_mesh_light_ctl_state { + uint16_t lightness; + uint16_t target_lightness; + + uint16_t temperature; + uint16_t target_temperature; + + int16_t delta_uv; + int16_t target_delta_uv; + + uint8_t status_code; + uint16_t temperature_range_min; + uint16_t temperature_range_max; + + uint16_t lightness_default; + uint16_t temperature_default; + int16_t delta_uv_default; +}; + +struct bt_mesh_light_ctl_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_light_ctl_state *state; + struct bt_mesh_last_msg_info last; + struct bt_mesh_state_transition transition; + int32_t tt_delta_lightness; + int32_t tt_delta_temperature; + int32_t tt_delta_delta_uv; +}; + +struct bt_mesh_light_ctl_setup_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_light_ctl_state *state; +}; + +struct bt_mesh_light_ctl_temp_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_light_ctl_state *state; + struct bt_mesh_last_msg_info last; + struct bt_mesh_state_transition transition; + int32_t tt_delta_temperature; + int32_t tt_delta_delta_uv; +}; + +struct bt_mesh_light_hsl_state { + uint16_t lightness; + uint16_t target_lightness; + + uint16_t hue; + uint16_t target_hue; + + uint16_t saturation; + uint16_t target_saturation; + + uint16_t lightness_default; + uint16_t hue_default; + uint16_t saturation_default; + + uint8_t status_code; + uint16_t hue_range_min; + uint16_t hue_range_max; + uint16_t saturation_range_min; + uint16_t saturation_range_max; +}; + +struct bt_mesh_light_hsl_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_light_hsl_state *state; + struct bt_mesh_last_msg_info last; + struct bt_mesh_state_transition transition; + int32_t tt_delta_lightness; + int32_t tt_delta_hue; + int32_t tt_delta_saturation; +}; + +struct bt_mesh_light_hsl_setup_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_light_hsl_state *state; +}; + +struct bt_mesh_light_hsl_hue_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_light_hsl_state *state; + struct bt_mesh_last_msg_info last; + struct bt_mesh_state_transition transition; + int32_t tt_delta_hue; +}; + +struct bt_mesh_light_hsl_sat_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_light_hsl_state *state; + struct bt_mesh_last_msg_info last; + struct bt_mesh_state_transition transition; + int32_t tt_delta_saturation; +}; + +struct bt_mesh_light_xyl_state { + uint16_t lightness; + uint16_t target_lightness; + + uint16_t x; + uint16_t target_x; + + uint16_t y; + uint16_t target_y; + + uint16_t lightness_default; + uint16_t x_default; + uint16_t y_default; + + uint8_t status_code; + uint16_t x_range_min; + uint16_t x_range_max; + uint16_t y_range_min; + uint16_t y_range_max; +}; + +struct bt_mesh_light_xyl_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_light_xyl_state *state; + struct bt_mesh_last_msg_info last; + struct bt_mesh_state_transition transition; + int32_t tt_delta_lightness; + int32_t tt_delta_x; + int32_t tt_delta_y; +}; + +struct bt_mesh_light_xyl_setup_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_light_xyl_state *state; +}; + +struct bt_mesh_light_lc_state { + uint32_t mode : 1, /* default 0 */ + occupancy_mode : 1, /* default 1 */ + light_onoff : 1, + target_light_onoff : 1, + occupancy : 1, + ambient_luxlevel : 24; /* 0x000000 ~ 0xFFFFFF */ + + uint16_t linear_output; /* 0x0000 ~ 0xFFFF */ +}; + +struct bt_mesh_light_lc_property_state { + uint32_t time_occupancy_delay; /* 0x003A */ + uint32_t time_fade_on; /* 0x0037 */ + uint32_t time_run_on; /* 0x003C */ + uint32_t time_fade; /* 0x0036 */ + uint32_t time_prolong; /* 0x003B */ + uint32_t time_fade_standby_auto; /* 0x0038 */ + uint32_t time_fade_standby_manual; /* 0x0039 */ + + uint16_t lightness_on; /* 0x002E */ + uint16_t lightness_prolong; /* 0x002F */ + uint16_t lightness_standby; /* 0x0030 */ + + uint16_t ambient_luxlevel_on; /* 0x002B, 0x0000 ~ 0xFFFF */ + uint16_t ambient_luxlevel_prolong; /* 0x002C, 0x0000 ~ 0xFFFF */ + uint16_t ambient_luxlevel_standby; /* 0x002D, 0x0000 ~ 0xFFFF */ + + float regulator_kiu; /* 0x0033, 0.0 ~ 1000.0, default 250.0 */ + float regulator_kid; /* 0x0032, 0.0 ~ 1000.0, default 25.0 */ + float regulator_kpu; /* 0x0035, 0.0 ~ 1000.0, default 80.0 */ + float regulator_kpd; /* 0x0034, 0.0 ~ 1000.0, default 80.0 */ + int8_t regulator_accuracy; /* 0x0031, 0.0 ~ 100.0, default 2.0 */ + + uint32_t set_occupancy_to_1_delay; +}; + +typedef enum { + LC_OFF, + LC_STANDBY, + LC_FADE_ON, + LC_RUN, + LC_FADE, + LC_PROLONG, + LC_FADE_STANDBY_AUTO, + LC_FADE_STANDBY_MANUAL, +} bt_mesh_lc_state; + +struct bt_mesh_light_lc_state_machine { + struct { + uint8_t fade_on; + uint8_t fade; + uint8_t fade_standby_auto; + uint8_t fade_standby_manual; + } trans_time; + bt_mesh_lc_state state; + struct k_delayed_work timer; +}; + +struct bt_mesh_light_control { + struct bt_mesh_light_lc_state state; + struct bt_mesh_light_lc_property_state prop_state; + struct bt_mesh_light_lc_state_machine state_machine; +}; + +struct bt_mesh_light_lc_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_light_control *lc; + struct bt_mesh_last_msg_info last; + struct bt_mesh_state_transition transition; +}; + +struct bt_mesh_light_lc_setup_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_light_control *lc; +}; + +typedef union { + struct { + uint16_t lightness; + } lightness_set; + struct { + uint16_t lightness; + } lightness_linear_set; + struct { + uint16_t lightness; + } lightness_default_set; + struct { + uint16_t range_min; + uint16_t range_max; + } lightness_range_set; + struct { + uint16_t lightness; + uint16_t temperature; + int16_t delta_uv; + } ctl_set; + struct { + uint16_t temperature; + int16_t delta_uv; + } ctl_temp_set; + struct { + uint16_t range_min; + uint16_t range_max; + } ctl_temp_range_set; + struct { + uint16_t lightness; + uint16_t temperature; + int16_t delta_uv; + } ctl_default_set; + struct { + uint16_t lightness; + uint16_t hue; + uint16_t saturation; + } hsl_set; + struct { + uint16_t hue; + } hsl_hue_set; + struct { + uint16_t saturation; + } hsl_saturation_set; + struct { + uint16_t lightness; + uint16_t hue; + uint16_t saturation; + } hsl_default_set; + struct { + uint16_t hue_range_min; + uint16_t hue_range_max; + uint16_t sat_range_min; + uint16_t sat_range_max; + } hsl_range_set; + struct { + uint16_t lightness; + uint16_t x; + uint16_t y; + } xyl_set; + struct { + uint16_t lightness; + uint16_t x; + uint16_t y; + } xyl_default_set; + struct { + uint16_t x_range_min; + uint16_t x_range_max; + uint16_t y_range_min; + uint16_t y_range_max; + } xyl_range_set; + struct { + uint8_t mode; + } lc_mode_set; + struct { + uint8_t mode; + } lc_om_set; + struct { + uint8_t onoff; + } lc_light_onoff_set; + struct { + uint16_t id; + struct net_buf_simple *value; + } lc_property_set; + struct { + uint16_t property_id; + union { + uint8_t occupancy; + uint32_t set_occupancy_to_1_delay; + uint32_t ambient_luxlevel; + } state; + } sensor_status; +} bt_mesh_light_server_state_change_t; + +typedef union { + struct { + uint16_t id; + } lc_property_get; +} bt_mesh_light_server_recv_get_msg_t; + +typedef union { + struct { + bool op_en; + uint16_t lightness; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; + } lightness_set; + struct { + bool op_en; + uint16_t lightness; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; + } lightness_linear_set; + struct { + uint16_t lightness; + } lightness_default_set; + struct { + uint16_t range_min; + uint16_t range_max; + } lightness_range_set; + struct { + bool op_en; + uint16_t lightness; + uint16_t temperature; + int16_t delta_uv; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; + } ctl_set; + struct { + bool op_en; + uint16_t temperature; + int16_t delta_uv; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; + } ctl_temp_set; + struct { + uint16_t range_min; + uint16_t range_max; + } ctl_temp_range_set; + struct { + uint16_t lightness; + uint16_t temperature; + int16_t delta_uv; + } ctl_default_set; + struct { + bool op_en; + uint16_t lightness; + uint16_t hue; + uint16_t saturation; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; + } hsl_set; + struct { + bool op_en; + uint16_t hue; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; + } hsl_hue_set; + struct { + bool op_en; + uint16_t saturation; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; + } hsl_saturation_set; + struct { + uint16_t lightness; + uint16_t hue; + uint16_t saturation; + } hsl_default_set; + struct { + uint16_t hue_range_min; + uint16_t hue_range_max; + uint16_t sat_range_min; + uint16_t sat_range_max; + } hsl_range_set; + struct { + bool op_en; + uint16_t lightness; + uint16_t x; + uint16_t y; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; + } xyl_set; + struct { + uint16_t lightness; + uint16_t x; + uint16_t y; + } xyl_default_set; + struct { + uint16_t x_range_min; + uint16_t x_range_max; + uint16_t y_range_min; + uint16_t y_range_max; + } xyl_range_set; + struct { + uint8_t mode; + } lc_mode_set; + struct { + uint8_t mode; + } lc_om_set; + struct { + bool op_en; + uint8_t light_onoff; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; + } lc_light_onoff_set; + struct { + uint16_t id; + struct net_buf_simple *value; + } lc_property_set; +} bt_mesh_light_server_recv_set_msg_t; + +typedef union { + struct { + struct net_buf_simple *data; + } sensor_status; +} bt_mesh_light_server_recv_status_msg_t; + +void bt_mesh_light_server_lock(void); +void bt_mesh_light_server_unlock(void); + +uint8_t *bt_mesh_get_lc_prop_value(struct bt_mesh_model *model, uint16_t prop_id); + +void light_lightness_publish(struct bt_mesh_model *model, uint16_t opcode); +void light_ctl_publish(struct bt_mesh_model *model, uint16_t opcode); +void light_hsl_publish(struct bt_mesh_model *model, uint16_t opcode); +void light_xyl_publish(struct bt_mesh_model *model, uint16_t opcode); +void light_lc_publish(struct bt_mesh_model *model, uint16_t opcode); + +#ifdef __cplusplus +} +#endif + +#endif /* _LIGHTING_SERVER_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_models/server/include/sensor_server.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_models/server/include/sensor_server.h new file mode 100644 index 00000000000..7946f3b4faf --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_models/server/include/sensor_server.h @@ -0,0 +1,246 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _SENSOR_SERVER_H_ +#define _SENSOR_SERVER_H_ + +#include "server_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Sensor Property ID related */ +#define INVALID_SENSOR_PROPERTY_ID 0x0000 + +#define SENSOR_PROPERTY_ID_LEN 0x02 + +/* Sensor Descriptor state related */ +#define SENSOR_DESCRIPTOR_LEN 0x08 + +#define SENSOR_UNSPECIFIED_POS_TOLERANCE 0x000 +#define SENSOR_UNSPECIFIED_NEG_TOLERANCE 0x000 + +#define SENSOR_NOT_APPL_MEASURE_PERIOD 0x00 + +#define SENSOR_NOT_APPL_UPDATE_INTERVAL 0x00 + +/* Sensor Setting state related */ +#define INVALID_SENSOR_SETTING_PROPERTY_ID 0x0000 + +#define SENSOR_SETTING_PROPERTY_ID_LEN 0x02 +#define SENSOR_SETTING_ACCESS_LEN 0x01 + +#define SENSOR_SETTING_ACCESS_READ 0x01 +#define SENSOR_SETTING_ACCESS_READ_WRITE 0x03 + +/* Sensor Cadence state related */ +#define SENSOR_DIVISOR_TRIGGER_TYPE_LEN 0x01 +#define SENSOR_STATUS_MIN_INTERVAL_LEN 0x01 + +#define SENSOR_PERIOD_DIVISOR_MAX_VALUE 15 + +#define SENSOR_STATUS_MIN_INTERVAL_MAX 26 + +#define SENSOR_STATUS_TRIGGER_TYPE_CHAR 0 +#define SENSOR_STATUS_TRIGGER_TYPE_UINT16 1 + +#define SENSOR_STATUS_TRIGGER_UINT16_LEN 0x02 + +/* Sensor Data state related */ +#define SENSOR_DATA_FORMAT_A 0x00 +#define SENSOR_DATA_FORMAT_B 0x01 + +#define SENSOR_DATA_FORMAT_A_MPID_LEN 0x02 +#define SENSOR_DATA_FORMAT_B_MPID_LEN 0x03 + +#define SENSOR_DATA_ZERO_LEN 0x7F + +enum bt_mesh_sensor_sample_func { + UNSPECIFIED, + INSTANTANEOUS, + ARITHMETIC_MEAN, + RMS, + MAXIMUM, + MINIMUM, + ACCUMULATED, + COUNT, +}; + +struct sensor_descriptor { + uint32_t positive_tolerance : 12, + negative_tolerance : 12, + sample_function : 8; + uint8_t measure_period; + uint8_t update_interval; +}; + +struct sensor_setting { + uint16_t property_id; + uint8_t access; + /* Or use union to include all possible types */ + struct net_buf_simple *raw; +}; + +struct sensor_cadence { + uint8_t period_divisor : 7, + trigger_type : 1; + struct net_buf_simple *trigger_delta_down; + struct net_buf_simple *trigger_delta_up; + uint8_t min_interval; + struct net_buf_simple *fast_cadence_low; + struct net_buf_simple *fast_cadence_high; +}; + +struct sensor_data { + /** + * Format A: The Length field is a 1-based uint4 value (valid range 0x0–0xF, + * representing range of 1 – 16). + * Format B: The Length field is a 1-based uint7 value (valid range 0x0–0x7F, + * representing range of 1 – 127). The value 0x7F represents a + * length of zero. + */ + uint8_t format : 1, + length : 7; + struct net_buf_simple *raw_value; +}; + +struct sensor_series_column { + struct net_buf_simple *raw_value_x; + struct net_buf_simple *column_width; + struct net_buf_simple *raw_value_y; +}; + +struct bt_mesh_sensor_state { + uint16_t sensor_property_id; + + /* Constant throughout the lifetime of an element */ + struct sensor_descriptor descriptor; + + /* 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; + struct sensor_setting *settings; + + /* The Sensor Cadence state may be not supported by sensors based + * on device properties referencing "non-scalar characteristics" + * such as "histograms" or "composite characteristics". + */ + struct sensor_cadence *cadence; + + struct sensor_data sensor_data; + + /* Values measured by sensors may be organized as arrays (and + * represented as series of columns, such as histograms). + * 1. The Sensor Raw Value X field has a size and representation + * defined by the Sensor Property ID and represents the left + * corner of the column on the X axis. + * 2. The Sensor Column Width field has a size and representation + * defined by the Sensor Property ID and represents the width + * of the column on the X axis. + * 3. The Sensor Raw Value Y field has a size and representation + * defined by the Sensor Property ID and represents the height + * of the column on the Y axis. + * Note: Values outside the bins defined by a Sensor Property are + * not included. For example, if the histogram is defined as 3 bins + * representing “lamp operating hours in a given temperature range” + * and the bins are [40,60), [60, 80), and [80,100], then any hours + * outside that [40, 100] range would not be included. + */ + struct sensor_series_column series_column; +}; + +/* 1. Multiple instances of the Sensor states may be present within the + * same model, provided that each instance has a unique value of the + * Sensor Property ID to allow the instances to be differentiated. + * 2. Note: The number of sensors within a multisensor is limited by the + * size of the message payload for the Sensor Descriptor Status message. + * A single Sensor Descriptor may be sent using a single Unsegmented + * Access message. Using Segmentation and Reassembly (SAR), up to 38 + * Sensor Descriptor states may be sent. + */ + +struct bt_mesh_sensor_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + const uint8_t state_count; + struct bt_mesh_sensor_state *states; +}; + +struct bt_mesh_sensor_setup_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + const uint8_t state_count; + struct bt_mesh_sensor_state *states; +}; + +typedef union { + struct { + uint16_t id; + uint8_t period_divisor : 7, + trigger_type : 1; + struct net_buf_simple *trigger_delta_down; + struct net_buf_simple *trigger_delta_up; + uint8_t min_interval; + struct net_buf_simple *fast_cadence_low; + struct net_buf_simple *fast_cadence_high; + } sensor_cadence_set; + struct { + uint16_t id; + uint16_t setting_id; + struct net_buf_simple *value; + } sensor_setting_set; +} bt_mesh_sensor_server_state_change_t; + +typedef union { + struct { + bool op_en; + uint16_t id; + } sensor_descriptor_get; + struct { + uint16_t id; + } sensor_cadence_get; + struct { + uint16_t id; + } sensor_settings_get; + struct { + uint16_t id; + uint16_t setting_id; + } sensor_setting_get; + struct { + bool op_en; + uint16_t id; + } sensor_get; + struct { + uint16_t id; + struct net_buf_simple *raw_x; + } sensor_column_get; + struct { + bool op_en; + uint16_t id; + struct net_buf_simple *raw; + } sensor_series_get; +} bt_mesh_sensor_server_recv_get_msg_t; + +typedef union { + struct { + uint16_t id; + struct net_buf_simple *cadence; + } sensor_cadence_set; + struct { + uint16_t id; + uint16_t setting_id; + struct net_buf_simple *raw; + } sensor_setting_set; +} bt_mesh_sensor_server_recv_set_msg_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _SENSOR_SERVER_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_models/server/include/server_common.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_models/server/include/server_common.h new file mode 100644 index 00000000000..d56dcbd8433 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_models/server/include/server_common.h @@ -0,0 +1,124 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _SERVER_COMMON_H_ +#define _SERVER_COMMON_H_ + +#include +#include +#include "mesh_access.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define BLE_MESH_SERVER_RSP_MAX_LEN 384 + +#define BLE_MESH_SERVER_TRANS_MIC_SIZE 4 + +#define BLE_MESH_CHECK_SEND_STATUS(_func) do { \ + int __status = (_func); \ + if (__status) { \ + BT_ERR("%s, Send failed, err %d", __func__, __status); \ + } \ + } while(0); + +#define BLE_MESH_STATE_OFF 0x00 +#define BLE_MESH_STATE_ON 0x01 +#define BLE_MESH_STATE_RESTORE 0x02 + +/* Following 4 values are as per Mesh Model specification */ +#define BLE_MESH_LIGHTNESS_MIN 0x0001 +#define BLE_MESH_LIGHTNESS_MAX 0xFFFF +#define BLE_MESH_TEMPERATURE_MIN 0x0320 +#define BLE_MESH_TEMPERATURE_MAX 0x4E20 +#define BLE_MESH_TEMPERATURE_UNKNOWN 0xFFFF + +/* Refer 7.2 of Mesh Model Specification */ +#define BLE_MESH_RANGE_UPDATE_SUCCESS 0x00 +#define BLE_MESH_CANNOT_SET_RANGE_MIN 0x01 +#define BLE_MESH_CANNOT_SET_RANGE_MAX 0x02 + +#define BLE_MESH_UNKNOWN_REMAIN_TIME 0x3F +#define BLE_MESH_DEVICE_SPECIFIC_RESOLUTION 10 + +enum { + BLE_MESH_TRANS_TIMER_START, /* Proper transition timer has been started */ + BLE_MESH_TRANS_FLAG_MAX, +}; + +struct bt_mesh_state_transition { + bool just_started; + + uint8_t trans_time; + uint8_t remain_time; + uint8_t delay; + uint32_t quo_tt; + uint32_t counter; + uint32_t total_duration; + int64_t start_timestamp; + + BLE_MESH_ATOMIC_DEFINE(flag, BLE_MESH_TRANS_FLAG_MAX); + struct k_delayed_work timer; +}; + +struct bt_mesh_last_msg_info { + uint8_t tid; + uint16_t src; + uint16_t dst; + int64_t timestamp; +}; + +#define BLE_MESH_SERVER_RSP_BY_APP 0 +#define BLE_MESH_SERVER_AUTO_RSP 1 + +struct bt_mesh_server_rsp_ctrl { + /** + * @brief BLE Mesh Server Response Option + * 1. If get_auto_rsp is set to BLE_MESH_SERVER_RSP_BY_APP, then the response + * of Client Get messages need to be replied by the application; + * 2. If get_auto_rsp is set to BLE_MESH_SERVER_AUTO_RSP, then the response + * of Client Get messages will be replied by the server models; + * 3. If set_auto_rsp is set to BLE_MESH_SERVER_RSP_BY_APP, then the response + * of Client Set messages need to be replied by the application; + * 4. If set_auto_rsp is set to BLE_MESH_SERVER_AUTO_RSP, then the response + * of Client Set messages will be replied by the server models; + * 5. If status_auto_rsp is set to BLE_MESH_SERVER_RSP_BY_APP, then the response + * of Server Status messages need to be replied by the application; + * 6. If status_auto_rsp is set to BLE_MESH_SERVER_AUTO_RSP, then the response + * of Server status messages will be replied by the server models; + */ + uint8_t get_auto_rsp : 1, /* Response for Client Get messages */ + set_auto_rsp : 1, /* Response for Client Set messages */ + status_auto_rsp : 1; /* Response for Server Status messages */ +}; + +uint8_t bt_mesh_get_default_trans_time(struct bt_mesh_model *model); + +int bt_mesh_get_light_lc_trans_time(struct bt_mesh_model *model, uint8_t *trans_time); + +int bt_mesh_server_get_optional(struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf, + uint8_t *trans_time, uint8_t *delay, + bool *optional); + +void bt_mesh_server_alloc_ctx(struct k_work *work); +void bt_mesh_server_free_ctx(struct k_work *work); + +bool bt_mesh_is_server_recv_last_msg(struct bt_mesh_last_msg_info *last, + uint8_t tid, uint16_t src, uint16_t dst, int64_t *now); + +void bt_mesh_server_update_last_msg(struct bt_mesh_last_msg_info *last, + uint8_t tid, uint16_t src, uint16_t dst, int64_t *now); + +struct net_buf_simple *bt_mesh_server_get_pub_msg(struct bt_mesh_model *model, uint16_t msg_len); + +#ifdef __cplusplus +} +#endif + +#endif /* _SERVER_COMMON_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_models/server/include/state_binding.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_models/server/include/state_binding.h new file mode 100644 index 00000000000..3a44f9e0010 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_models/server/include/state_binding.h @@ -0,0 +1,108 @@ +/* Bluetooth: Mesh Generic OnOff, Generic Level, Lighting & Vendor Models + * + * SPDX-FileCopyrightText: 2018 Vikrant More + * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _STATE_BINDING_H_ +#define _STATE_BINDING_H_ + +#include "mesh_access.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + GENERIC_ONOFF_STATE, + GENERIC_LEVEL_STATE, + GENERIC_ONPOWERUP_STATE, + GENERIC_POWER_ACTUAL_STATE, + LIGHT_LIGHTNESS_ACTUAL_STATE, + LIGHT_LIGHTNESS_LINEAR_STATE, + LIGHT_CTL_LIGHTNESS_STATE, + LIGHT_CTL_TEMP_DELTA_UV_STATE, + LIGHT_HSL_STATE, + LIGHT_HSL_LIGHTNESS_STATE, + LIGHT_HSL_HUE_STATE, + LIGHT_HSL_SATURATION_STATE, + LIGHT_XYL_LIGHTNESS_STATE, + LIGHT_LC_LIGHT_ONOFF_STATE, + BIND_STATE_MAX, +} bt_mesh_server_state_type_t; + +typedef union { + struct { + uint8_t onoff; + } gen_onoff; + struct { + int16_t level; + } gen_level; + struct { + uint8_t onpowerup; + } gen_onpowerup; + struct { + uint16_t power; + } gen_power_actual; + struct { + uint16_t lightness; + } light_lightness_actual; + struct { + uint16_t lightness; + } light_lightness_linear; + struct { + uint16_t lightness; + } light_ctl_lightness; + struct { + uint16_t temperature; + int16_t delta_uv; + } light_ctl_temp_delta_uv; + struct { + uint16_t lightness; + uint16_t hue; + uint16_t saturation; + } light_hsl; + struct { + uint16_t lightness; + } light_hsl_lightness; + struct { + uint16_t hue; + } light_hsl_hue; + struct { + uint16_t saturation; + } light_hsl_saturation; + struct { + uint16_t lightness; + } light_xyl_lightness; + struct { + uint8_t onoff; + } light_lc_light_onoff; +} bt_mesh_server_state_value_t; + +uint16_t bt_mesh_convert_lightness_actual_to_linear(uint16_t actual); + +uint16_t bt_mesh_convert_lightness_linear_to_actual(uint16_t linear); + +int16_t bt_mesh_convert_temperature_to_gen_level(uint16_t temp, uint16_t min, uint16_t max); + +uint16_t bt_mesh_covert_gen_level_to_temperature(int16_t level, uint16_t min, uint16_t max); + +int16_t bt_mesh_convert_hue_to_level(uint16_t hue); + +uint16_t bt_mesh_convert_level_to_hue(int16_t level); + +int16_t bt_mesh_convert_saturation_to_level(uint16_t saturation); + +uint16_t bt_mesh_convert_level_to_saturation(int16_t level); + +int bt_mesh_update_binding_state(struct bt_mesh_model *model, + bt_mesh_server_state_type_t type, + bt_mesh_server_state_value_t *value); + +#ifdef __cplusplus +} +#endif + +#endif /* _STATE_BINDING_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_models/server/include/state_transition.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_models/server/include/state_transition.h new file mode 100644 index 00000000000..86ca747b5a4 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_models/server/include/state_transition.h @@ -0,0 +1,100 @@ +/* Bluetooth: Mesh Generic OnOff, Generic Level, Lighting & Vendor Models + * + * SPDX-FileCopyrightText: 2018 Vikrant More + * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _STATE_TRANSITION_H_ +#define _STATE_TRANSITION_H_ + +#include "server_common.h" +#include "generic_server.h" +#include "sensor_server.h" +#include "lighting_server.h" +#include "time_scene_server.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void bt_mesh_server_calc_remain_time(struct bt_mesh_state_transition *transition); + +/* APIs used to get server model transition time values */ + +void generic_onoff_tt_values(struct bt_mesh_gen_onoff_srv *srv, + uint8_t trans_time, uint8_t delay); + +void generic_level_tt_values(struct bt_mesh_gen_level_srv *srv, + uint8_t trans_time, uint8_t delay); + +void generic_power_level_tt_values(struct bt_mesh_gen_power_level_srv *srv, + uint8_t trans_time, uint8_t delay); + +void light_lightness_actual_tt_values(struct bt_mesh_light_lightness_srv *srv, + uint8_t trans_time, uint8_t delay); + +void light_lightness_linear_tt_values(struct bt_mesh_light_lightness_srv *srv, + uint8_t trans_time, uint8_t delay); + +void light_ctl_tt_values(struct bt_mesh_light_ctl_srv *srv, + uint8_t trans_time, uint8_t delay); + +void light_ctl_temp_tt_values(struct bt_mesh_light_ctl_temp_srv *srv, + uint8_t trans_time, uint8_t delay); + +void light_hsl_tt_values(struct bt_mesh_light_hsl_srv *srv, + uint8_t trans_time, uint8_t delay); + +void light_hsl_hue_tt_values(struct bt_mesh_light_hsl_hue_srv *srv, + uint8_t trans_time, uint8_t delay); + +void light_hsl_sat_tt_values(struct bt_mesh_light_hsl_sat_srv *srv, + uint8_t trans_time, uint8_t delay); + +void light_xyl_tt_values(struct bt_mesh_light_xyl_srv *srv, + uint8_t trans_time, uint8_t delay); + +void light_lc_tt_values(struct bt_mesh_light_lc_srv *srv, + uint8_t trans_time, uint8_t delay); + +void scene_tt_values(struct bt_mesh_scene_srv *srv, uint8_t trans_time, uint8_t delay); + +/* Server model transition timer handlers */ + +void generic_onoff_work_handler(struct k_work *work); + +void generic_level_work_handler(struct k_work *work); + +void generic_power_level_work_handler(struct k_work *work); + +void light_lightness_actual_work_handler(struct k_work *work); + +void light_lightness_linear_work_handler(struct k_work *work); + +void light_ctl_work_handler(struct k_work *work); + +void light_ctl_temp_work_handler(struct k_work *work); + +void light_hsl_work_handler(struct k_work *work); + +void light_hsl_hue_work_handler(struct k_work *work); + +void light_hsl_sat_work_handler(struct k_work *work); + +void light_xyl_work_handler(struct k_work *work); + +void light_lc_work_handler(struct k_work *work); + +void scene_recall_work_handler(struct k_work *work); + +void bt_mesh_server_stop_transition(struct bt_mesh_state_transition *transition); + +void bt_mesh_server_start_transition(struct bt_mesh_state_transition *transition); + +#ifdef __cplusplus +} +#endif + +#endif /* _STATE_TRANSITION_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_models/server/include/time_scene_server.h b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_models/server/include/time_scene_server.h new file mode 100644 index 00000000000..6728e6ff578 --- /dev/null +++ b/tools/sdk/esp32c3/include/bt/esp_ble_mesh/mesh_models/server/include/time_scene_server.h @@ -0,0 +1,384 @@ +/* + * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _TIME_SCENE_SERVER_H_ +#define _TIME_SCENE_SERVER_H_ + +#include "server_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * 1. Mesh defines times based on International Atomic Time (TAI). The base + * representation of times is the number of seconds after 00:00:00 TAI + * on 2000-01-01 (that is, 1999-12-31 T23:59:28 UTC). + * 2. UTC: Coordinated Universal Time. For more information, please refer + * to https://time.is/zh/UTC + * 3. For the algorithm used for the transfer between TAI and UTC, please + * refer to Mesh Model Spec Section 5.1.1 + */ + +#define UNKNOWN_TAI_SECONDS 0x0000000000 +#define UNKNOWN_TAI_ZONE_CHANGE 0x0000000000 +#define UNKNOWN_TAI_DELTA_CHANGE 0x0000000000 +#define TAI_UTC_DELTA_MAX_VALUE 0x7FFF +#define TAI_SECONDS_LEN 0x05 +#define TAI_OF_ZONE_CHANGE_LEN 0x05 +#define TAI_OF_DELTA_CHANGE_LEN 0x05 + +#define INVALID_SCENE_NUMBER 0x0000 +#define SCENE_NUMBER_LEN 0x02 + +#define SCHEDULE_YEAR_ANY_YEAR 0x64 + +#define SCHEDULE_DAY_ANY_DAY 0x00 + +#define SCHEDULE_HOUR_ANY_HOUR 0x18 +#define SCHEDULE_HOUR_ONCE_A_DAY 0x19 + +#define SCHEDULE_SEC_ANY_OF_HOUR 0x3C +#define SCHEDULE_SEC_EVERY_15_MIN 0x3D +#define SCHEDULE_SEC_EVERY_20_MIN 0x3E +#define SCHEDULE_SEC_ONCE_AN_HOUR 0x3F + +#define SCHEDULE_SEC_ANY_OF_MIN 0x3C +#define SCHEDULE_SEC_EVERY_15_SEC 0x3D +#define SCHEDULE_SEC_EVERY_20_SEC 0x3E +#define SCHEDULE_SEC_ONCE_AN_MIN 0x3F + +#define SCHEDULE_ACT_TURN_OFF 0x00 +#define SCHEDULE_ACT_TURN_ON 0x01 +#define SCHEDULE_ACT_SCENE_RECALL 0x02 +#define SCHEDULE_ACT_NO_ACTION 0x0F + +#define SCHEDULE_SCENE_NO_SCENE 0x0000 + +#define SCHEDULE_ENTRY_MAX_INDEX 0x0F + +#define TIME_NONE 0x00 +#define TIME_AUTHORITY 0x01 +#define TIME_RELAY 0x02 +#define TIME_CLINET 0x03 + +#define SCENE_SUCCESS 0x00 +#define SCENE_REG_FULL 0x01 +#define SCENE_NOT_FOUND 0x02 + +/** + * The Time state represents the present TAI time, the current TAI-UTC Delta + * and local time zone offset, and the next change to each of the latter + * (e.g., because of a switch from winter to summer time or an announced leap + * second). It consists of 10 fields with a total size of 183 bits. + */ +struct bt_mesh_time_state { + struct { + uint8_t tai_seconds[5]; + uint8_t subsecond; + uint8_t uncertainty; + uint8_t time_zone_offset_curr; + uint8_t time_zone_offset_new; + uint8_t tai_zone_change[5]; + uint16_t time_authority : 1, + tai_utc_delta_curr : 15; + uint16_t tai_utc_delta_new : 15; + uint8_t tai_delta_change[5]; + } time; + uint8_t time_role; +}; + +struct bt_mesh_time_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_time_state *state; +}; + +struct bt_mesh_time_setup_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_time_state *state; +}; + +struct scene_register { + uint16_t scene_number; + uint8_t scene_type; /* Indicate the type of scene value */ + /** + * 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; +}; + +/** + * 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. + */ +struct bt_mesh_scenes_state { + const uint16_t scene_count; + struct scene_register *scenes; + + /** + * 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 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; + + /* Indicate the status code for the last operation */ + uint8_t status_code; + + /* Indicate if scene transition is in progress */ + bool in_progress; +}; + +struct bt_mesh_scene_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_scenes_state *state; + struct bt_mesh_last_msg_info last; + struct bt_mesh_state_transition transition; +}; + +struct bt_mesh_scene_setup_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_scenes_state *state; +}; + +struct schedule_register { + bool in_use; + uint64_t year : 7, + month : 12, + day : 5, + hour : 5, + minute : 6, + second : 6, + day_of_week : 7, + action : 4, + trans_time : 8; + uint16_t scene_number; +}; + +struct bt_mesh_scheduler_state { + const uint8_t schedule_count; + struct schedule_register *schedules; /* Up to 16 scheduled entries */ + + /** + * A recommended implementation of the Scheduler should calculate the + * value of the TAI Seconds of the next scheduled event and put it in + * a queue of scheduled events sorted by time. + * + * Every second, the first event in the queue is compared with the value + * of the Time state. The first event is executed if it is less than or + * equal to the Time state and then removed from the queue. After + * execution, the Repeat Flag shall be checked, and the next occurrence + * of the scheduled event is calculated and put in the queue. + * + * One second timeout value, and compare the first event in queue with the + * Time state. If it is satisfied, then execute the first event. Also the + * Repeat Flag need to be checked, if it is set then the event needs to + * be put into the end of queue. + * + * sys_slist_t event_queue; + * + * For each event_queue item, it can use the following struct: + * struct schedule_event { + * sys_snode_t node; + * uint8_t event_index; + * }; + * + * Also we need a "struct k_delayed_work track_timer" which can be used to + * track the schedule timer and handle proper scheduled events. + */ +}; + +struct bt_mesh_scheduler_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_scheduler_state *state; +}; + +struct bt_mesh_scheduler_setup_srv { + struct bt_mesh_model *model; + struct bt_mesh_server_rsp_ctrl rsp_ctrl; + struct bt_mesh_scheduler_state *state; +}; + +typedef union { + struct { + uint8_t tai_seconds[5]; + uint8_t subsecond; + uint8_t uncertainty; + uint16_t time_authority : 1; + uint16_t tai_utc_delta_curr : 15; + uint8_t time_zone_offset_curr; + } time_set; + struct { + uint8_t tai_seconds[5]; + uint8_t subsecond; + uint8_t uncertainty; + uint16_t time_authority : 1; + uint16_t tai_utc_delta_curr : 15; + uint8_t time_zone_offset_curr; + } time_status; + struct { + uint8_t time_zone_offset_new; + uint8_t tai_zone_change[5]; + } time_zone_set; + struct { + uint16_t tai_utc_delta_new : 15; + uint8_t tai_delta_change[5]; + } tai_utc_delta_set; + struct { + uint8_t role; + } time_role_set; + struct { + uint16_t scene_number; + } scene_store; + struct { + uint16_t scene_number; + } scene_recall; + struct { + uint16_t scene_number; + } scene_delete; + struct { + uint64_t index : 4, + year : 7, + month : 12, + day : 5, + hour : 5, + minute : 6, + second : 6, + day_of_week : 7, + action : 4, + trans_time : 8; + uint16_t scene_number; + } scheduler_act_set; +} bt_mesh_time_scene_server_state_change_t; + +typedef union { + struct { + uint8_t index; + } scheduler_act_get; +} bt_mesh_time_scene_server_recv_get_msg_t; + +typedef union { + struct { + uint8_t tai_seconds[5]; + uint8_t subsecond; + uint8_t uncertainty; + uint16_t time_authority : 1; + uint16_t tai_utc_delta : 15; + uint8_t time_zone_offset; + } time_set; + struct { + uint8_t time_zone_offset_new; + uint8_t tai_zone_change[5]; + } time_zone_set; + struct { + uint16_t tai_utc_delta_new : 15; + uint16_t padding : 1; + uint8_t tai_delta_change[5]; + } tai_utc_delta_set; + struct { + uint8_t time_role; + } time_role_set; + struct { + uint16_t scene_number; + } scene_store; + struct { + bool op_en; + uint16_t scene_number; + uint8_t tid; + uint8_t trans_time; + uint8_t delay; + } scene_recall; + struct { + uint16_t scene_number; + } scene_delete; + struct { + uint64_t index : 4, + year : 7, + month : 12, + day : 5, + hour : 5, + minute : 6, + second : 6, + day_of_week : 7, + action : 4, + trans_time : 8; + uint16_t scene_number; + } scheduler_act_set; +} bt_mesh_time_scene_server_recv_set_msg_t; + +typedef union { + struct { + uint8_t tai_seconds[5]; + uint8_t subsecond; + uint8_t uncertainty; + uint16_t time_authority : 1; + uint16_t tai_utc_delta : 15; + uint8_t time_zone_offset; + } time_status; +} bt_mesh_time_scene_server_recv_status_msg_t; + +void bt_mesh_time_scene_server_lock(void); +void bt_mesh_time_scene_server_unlock(void); + +void scene_publish(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, uint16_t opcode); + +#ifdef __cplusplus +} +#endif + +#endif /* _TIME_SCENE_SERVER_H_ */ diff --git a/tools/sdk/esp32c3/include/bt/host/bluedroid/api/include/api/esp_bt_defs.h b/tools/sdk/esp32c3/include/bt/host/bluedroid/api/include/api/esp_bt_defs.h index 1287404ce35..d0e1ec00950 100644 --- a/tools/sdk/esp32c3/include/bt/host/bluedroid/api/include/api/esp_bt_defs.h +++ b/tools/sdk/esp32c3/include/bt/host/bluedroid/api/include/api/esp_bt_defs.h @@ -68,6 +68,8 @@ typedef uint8_t esp_link_key[ESP_BT_OCTET16_LEN]; /* Link Key */ /// Default GATT interface id #define ESP_DEFAULT_GATT_IF 0xff +#define ESP_BLE_PRIM_ADV_INT_MIN 0x000020 /*!< Minimum advertising interval for undirected and low duty cycle directed advertising */ +#define ESP_BLE_PRIM_ADV_INT_MAX 0xFFFFFF /*!< Maximum advertising interval for undirected and low duty cycle directed advertising */ #define ESP_BLE_CONN_INT_MIN 0x0006 /*!< relate to BTM_BLE_CONN_INT_MIN in stack/btm_ble_api.h */ #define ESP_BLE_CONN_INT_MAX 0x0C80 /*!< relate to BTM_BLE_CONN_INT_MAX in stack/btm_ble_api.h */ #define ESP_BLE_CONN_LATENCY_MAX 499 /*!< relate to ESP_BLE_CONN_LATENCY_MAX in stack/btm_ble_api.h */ diff --git a/tools/sdk/esp32c3/include/bt/host/bluedroid/api/include/api/esp_gap_bt_api.h b/tools/sdk/esp32c3/include/bt/host/bluedroid/api/include/api/esp_gap_bt_api.h index 285cbb028cf..686ad1c63e8 100644 --- a/tools/sdk/esp32c3/include/bt/host/bluedroid/api/include/api/esp_gap_bt_api.h +++ b/tools/sdk/esp32c3/include/bt/host/bluedroid/api/include/api/esp_gap_bt_api.h @@ -347,6 +347,7 @@ typedef union { struct read_rmt_name_param { esp_bt_status_t stat; /*!< read Remote Name status */ uint8_t rmt_name[ESP_BT_GAP_MAX_BDNAME_LEN + 1]; /*!< Remote device name */ + esp_bd_addr_t bda; /*!< remote bluetooth device address*/ } read_rmt_name; /*!< read Remote Name parameter struct */ /** diff --git a/tools/sdk/esp32c3/include/bt/host/bluedroid/api/include/api/esp_gattc_api.h b/tools/sdk/esp32c3/include/bt/host/bluedroid/api/include/api/esp_gattc_api.h index 40719096345..6c32868156f 100644 --- a/tools/sdk/esp32c3/include/bt/host/bluedroid/api/include/api/esp_gattc_api.h +++ b/tools/sdk/esp32c3/include/bt/host/bluedroid/api/include/api/esp_gattc_api.h @@ -220,6 +220,7 @@ typedef union { struct gattc_disconnect_evt_param { esp_gatt_conn_reason_t reason; /*!< disconnection reason */ uint16_t conn_id; /*!< Connection id */ + uint8_t link_role; /*!< Link role : master role = 0 ; slave role = 1*/ esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */ } disconnect; /*!< Gatt client callback param of ESP_GATTC_DISCONNECT_EVT */ /** diff --git a/tools/sdk/esp32c3/include/bt/host/bluedroid/api/include/api/esp_gatts_api.h b/tools/sdk/esp32c3/include/bt/host/bluedroid/api/include/api/esp_gatts_api.h index 475ae08c553..558d5d62960 100644 --- a/tools/sdk/esp32c3/include/bt/host/bluedroid/api/include/api/esp_gatts_api.h +++ b/tools/sdk/esp32c3/include/bt/host/bluedroid/api/include/api/esp_gatts_api.h @@ -206,6 +206,7 @@ typedef union { */ struct gatts_disconnect_evt_param { uint16_t conn_id; /*!< Connection id */ + uint8_t link_role; /*!< Link role : master role = 0 ; slave role = 1*/ esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */ esp_gatt_conn_reason_t reason; /*!< Indicate the reason of disconnection */ } disconnect; /*!< Gatt server callback param of ESP_GATTS_DISCONNECT_EVT */ diff --git a/tools/sdk/esp32c3/include/bt/include/esp32c3/include/esp_bt.h b/tools/sdk/esp32c3/include/bt/include/esp32c3/include/esp_bt.h index 2c1af6580e4..d62b7a4a949 100644 --- a/tools/sdk/esp32c3/include/bt/include/esp32c3/include/esp_bt.h +++ b/tools/sdk/esp32c3/include/bt/include/esp32c3/include/esp_bt.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -163,7 +163,9 @@ typedef void (* esp_bt_hci_tl_callback_t) (void *arg, uint8_t status); .ble_st_acl_tx_buf_nb = CONFIG_BT_CTRL_BLE_STATIC_ACL_TX_BUF_NB, \ .ble_hw_cca_check = CONFIG_BT_CTRL_HW_CCA_EFF, \ .ble_adv_dup_filt_max = CONFIG_BT_CTRL_ADV_DUP_FILT_MAX, \ + .coex_param_en = false, \ .ce_len_type = CONFIG_BT_CTRL_CE_LENGTH_TYPE_EFF, \ + .coex_use_hooks = false, \ .hci_tl_type = CONFIG_BT_CTRL_HCI_TL_EFF, \ .hci_tl_funcs = NULL, \ .txant_dft = CONFIG_BT_CTRL_TX_ANTENNA_INDEX_EFF, \ diff --git a/tools/sdk/esp32c3/include/coap/port/include/coap_config_posix.h b/tools/sdk/esp32c3/include/coap/port/include/coap_config_posix.h index b24335ad156..f96faea7665 100644 --- a/tools/sdk/esp32c3/include/coap/port/include/coap_config_posix.h +++ b/tools/sdk/esp32c3/include/coap/port/include/coap_config_posix.h @@ -30,6 +30,8 @@ #define HAVE_NETDB_H #define HAVE_NETINET_IN_H #define HAVE_STRUCT_CMSGHDR +#define HAVE_PTHREAD_H +#define HAVE_PTHREAD_MUTEX_LOCK #define COAP_DISABLE_TCP 0 #define ipi_spec_dst ipi_addr diff --git a/tools/sdk/esp32c3/include/driver/include/driver/gpio.h b/tools/sdk/esp32c3/include/driver/include/driver/gpio.h index eeb63f74f8e..77bb2dd78c0 100644 --- a/tools/sdk/esp32c3/include/driver/include/driver/gpio.h +++ b/tools/sdk/esp32c3/include/driver/include/driver/gpio.h @@ -97,7 +97,7 @@ esp_err_t gpio_set_intr_type(gpio_num_t gpio_num, gpio_int_type_t intr_type); /** * @brief Enable GPIO module interrupt signal * - * @note Please do not use the interrupt of GPIO36 and GPIO39 when using ADC or Wi-Fi with sleep mode enabled. + * @note Please do not use the interrupt of GPIO36 and GPIO39 when using ADC or Wi-Fi and Bluetooth with sleep mode enabled. * Please refer to the comments of `adc1_get_raw`. * Please refer to section 3.11 of 'ECO_and_Workarounds_for_Bugs_in_ESP32' for the description of this issue. * As a workaround, call adc_power_acquire() in the app. This will result in higher power consumption (by ~1mA), @@ -498,7 +498,8 @@ esp_err_t gpio_sleep_set_pull_mode(gpio_num_t gpio_num, gpio_pull_mode_t pull); #if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP -#define GPIO_IS_DEEP_SLEEP_WAKEUP_VALID_GPIO(gpio_num) ((gpio_num & ~SOC_GPIO_DEEP_SLEEP_WAKEUP_VALID_GPIO_MASK) == 0) +#define GPIO_IS_DEEP_SLEEP_WAKEUP_VALID_GPIO(gpio_num) ((gpio_num >= 0) && \ + (((1ULL << (gpio_num)) & SOC_GPIO_DEEP_SLEEP_WAKEUP_VALID_GPIO_MASK) != 0)) /** * @brief Enable GPIO deep-sleep wake-up function. diff --git a/tools/sdk/esp32c3/include/driver/include/driver/i2c.h b/tools/sdk/esp32c3/include/driver/include/driver/i2c.h index 22dcc8ab241..57d9091e70a 100644 --- a/tools/sdk/esp32c3/include/driver/include/driver/i2c.h +++ b/tools/sdk/esp32c3/include/driver/include/driver/i2c.h @@ -429,8 +429,7 @@ esp_err_t i2c_master_stop(i2c_cmd_handle_t cmd_handle); /** * @brief Send all the queued commands on the I2C bus, in master mode. * The task will be blocked until all the commands have been sent out. - * The I2C APIs are not thread-safe, if you want to use one I2C port in different tasks, - * you need to take care of the multi-thread issue. + * The I2C port is protected by mutex, so this function is thread-safe. * This function shall only be called in I2C master mode. * * @param i2c_num I2C port number diff --git a/tools/sdk/esp32c3/include/driver/include/driver/sdspi_host.h b/tools/sdk/esp32c3/include/driver/include/driver/sdspi_host.h index abb690c39bc..a5d942e9d86 100644 --- a/tools/sdk/esp32c3/include/driver/include/driver/sdspi_host.h +++ b/tools/sdk/esp32c3/include/driver/include/driver/sdspi_host.h @@ -22,8 +22,10 @@ typedef int sdspi_dev_handle_t; #if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2 #define SDSPI_DEFAULT_HOST HSPI_HOST +#define SDSPI_DEFAULT_DMA SDSPI_DEFAULT_HOST #else #define SDSPI_DEFAULT_HOST SPI2_HOST +#define SDSPI_DEFAULT_DMA SPI_DMA_CH_AUTO #endif /** @@ -216,7 +218,7 @@ typedef struct { .gpio_miso = GPIO_NUM_2, \ .gpio_mosi = GPIO_NUM_15, \ .gpio_sck = GPIO_NUM_14, \ - .dma_channel = 1, \ + .dma_channel = SDSPI_DEFAULT_DMA, \ } /** diff --git a/tools/sdk/esp32c3/include/driver/include/driver/spi_common.h b/tools/sdk/esp32c3/include/driver/include/driver/spi_common.h index 830b8efd8c2..424e9c0588f 100644 --- a/tools/sdk/esp32c3/include/driver/include/driver/spi_common.h +++ b/tools/sdk/esp32c3/include/driver/include/driver/spi_common.h @@ -163,7 +163,7 @@ esp_err_t spi_bus_initialize(spi_host_device_t host_id, const spi_bus_config_t * * @param host_id SPI peripheral to free * @return * - ESP_ERR_INVALID_ARG if parameter is invalid - * - ESP_ERR_INVALID_STATE if not all devices on the bus are freed + * - ESP_ERR_INVALID_STATE if bus hasn't been initialized before, or not all devices on the bus are freed * - ESP_OK on success */ esp_err_t spi_bus_free(spi_host_device_t host_id); diff --git a/tools/sdk/esp32c3/include/driver/include/esp_private/gdma.h b/tools/sdk/esp32c3/include/driver/include/esp_private/gdma.h index 88a45b56cfe..f888cd5bc9b 100644 --- a/tools/sdk/esp32c3/include/driver/include/esp_private/gdma.h +++ b/tools/sdk/esp32c3/include/driver/include/esp_private/gdma.h @@ -269,6 +269,9 @@ esp_err_t gdma_register_rx_event_callbacks(gdma_channel_handle_t dma_chan, gdma_ /** * @brief Set DMA descriptor address and start engine * + * @note This function is allowed to run within ISR context + * @note This function is also allowed to run when Cache is disabled, if `CONFIG_GDMA_CTRL_FUNC_IN_IRAM` is enabled + * * @param[in] dma_chan GDMA channel handle, allocated by `gdma_new_channel` * @param[in] desc_base_addr Base address of descriptors (usually the descriptors are chained into a link or ring) * @return @@ -281,6 +284,9 @@ esp_err_t gdma_start(gdma_channel_handle_t dma_chan, intptr_t desc_base_addr); /** * @brief Stop DMA engine * + * @note This function is allowed to run within ISR context + * @note This function is also allowed to run when Cache is disabled, if `CONFIG_GDMA_CTRL_FUNC_IN_IRAM` is enabled + * * @param[in] dma_chan GDMA channel handle, allocated by `gdma_new_channel` * @return * - ESP_OK: Stop DMA engine successfully @@ -291,6 +297,9 @@ esp_err_t gdma_stop(gdma_channel_handle_t dma_chan); /** * @brief Make the appended descriptors be aware to the DMA engine + * + * @note This function is allowed to run within ISR context + * @note This function is also allowed to run when Cache is disabled, if `CONFIG_GDMA_CTRL_FUNC_IN_IRAM` is enabled * @note This API could also resume a paused DMA engine, make sure new descriptors have been appended to the descriptor chain before calling it. * * @param[in] dma_chan GDMA channel handle, allocated by `gdma_new_channel` @@ -303,6 +312,9 @@ esp_err_t gdma_append(gdma_channel_handle_t dma_chan); /** * @brief Reset DMA channel FIFO and internal finite state machine + * + * @note This function is allowed to run within ISR context + * @note This function is also allowed to run when Cache is disabled, if `CONFIG_GDMA_CTRL_FUNC_IN_IRAM` is enabled * @note Resetting a DMA channel won't break the connection with the target peripheral * * @param[in] dma_chan GDMA channel handle, allocated by `gdma_new_channel` diff --git a/tools/sdk/esp32c3/include/efuse/esp32c3/include/esp_efuse_table.h b/tools/sdk/esp32c3/include/efuse/esp32c3/include/esp_efuse_table.h index d095ea1029a..5197a3e5da6 100644 --- a/tools/sdk/esp32c3/include/efuse/esp32c3/include/esp_efuse_table.h +++ b/tools/sdk/esp32c3/include/efuse/esp32c3/include/esp_efuse_table.h @@ -9,7 +9,7 @@ extern "C" { #endif -// md5_digest_table 720eb12a076091cb1a236c15d9fa3308 +// md5_digest_table 6614a99de35023cf9ba3849a2b80e9e7 // This file was generated from the file esp_efuse_table.csv. DO NOT CHANGE THIS FILE MANUALLY. // If you want to change some fields, you need to change esp_efuse_table.csv file // then run `efuse_common_table` or `efuse_custom_table` command it will generate this file. @@ -83,13 +83,14 @@ extern const esp_efuse_desc_t* ESP_EFUSE_SECURE_BOOT_EN[]; extern const esp_efuse_desc_t* ESP_EFUSE_SECURE_BOOT_AGGRESSIVE_REVOKE[]; extern const esp_efuse_desc_t* ESP_EFUSE_FLASH_TPUW[]; extern const esp_efuse_desc_t* ESP_EFUSE_DIS_DOWNLOAD_MODE[]; -extern const esp_efuse_desc_t* ESP_EFUSE_DIS_LEGACY_SPI_BOOT[]; -extern const esp_efuse_desc_t* ESP_EFUSE_UART_PRINT_CHANNEL[]; -extern const esp_efuse_desc_t* ESP_EFUSE_DIS_USB_DOWNLOAD_MODE[]; +extern const esp_efuse_desc_t* ESP_EFUSE_DIS_DIRECT_BOOT[]; +extern const esp_efuse_desc_t* ESP_EFUSE_DIS_USB_SERIAL_JTAG_ROM_PRINT[]; +extern const esp_efuse_desc_t* ESP_EFUSE_DIS_USB_SERIAL_JTAG_DOWNLOAD_MODE[]; extern const esp_efuse_desc_t* ESP_EFUSE_ENABLE_SECURITY_DOWNLOAD[]; extern const esp_efuse_desc_t* ESP_EFUSE_UART_PRINT_CONTROL[]; extern const esp_efuse_desc_t* ESP_EFUSE_FORCE_SEND_RESUME[]; extern const esp_efuse_desc_t* ESP_EFUSE_SECURE_VERSION[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ERR_RST_ENABLE[]; extern const esp_efuse_desc_t* ESP_EFUSE_MAC_FACTORY[]; extern const esp_efuse_desc_t* ESP_EFUSE_SPI_PAD_CONFIG_CLK[]; extern const esp_efuse_desc_t* ESP_EFUSE_SPI_PAD_CONFIG_Q_D1[]; diff --git a/tools/sdk/esp32c3/include/esp-tls/esp_tls.h b/tools/sdk/esp32c3/include/esp-tls/esp_tls.h index 588f70d83f9..5b5b3628023 100644 --- a/tools/sdk/esp32c3/include/esp-tls/esp_tls.h +++ b/tools/sdk/esp32c3/include/esp-tls/esp_tls.h @@ -688,6 +688,16 @@ esp_err_t esp_tls_plain_tcp_connect(const char *host, int hostlen, int port, con * NULL on Failure */ esp_tls_client_session_t *esp_tls_get_client_session(esp_tls_t *tls); + +/** + * @brief Free the client session + * + * This function should be called after esp_tls_get_client_session(). + * + * @param[in] client_session context as esp_tls_client_session_t + * + */ +void esp_tls_free_client_session(esp_tls_client_session_t *client_session); #endif /* CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS */ #ifdef __cplusplus } diff --git a/tools/sdk/esp32c3/include/esp-tls/private_include/esp_tls_mbedtls.h b/tools/sdk/esp32c3/include/esp-tls/private_include/esp_tls_mbedtls.h index c1c5d4f3288..43dce58ad6e 100644 --- a/tools/sdk/esp32c3/include/esp-tls/private_include/esp_tls_mbedtls.h +++ b/tools/sdk/esp32c3/include/esp-tls/private_include/esp_tls_mbedtls.h @@ -104,6 +104,11 @@ esp_err_t set_client_config(const char *hostname, size_t hostlen, esp_tls_cfg_t * Internal Callback for mbedtls_get_client_session */ esp_tls_client_session_t *esp_mbedtls_get_client_session(esp_tls_t *tls); + +/** + * Internal Callback for mbedtls_free_client_session + */ +void esp_mbedtls_free_client_session(esp_tls_client_session_t *client_session); #endif /** diff --git a/tools/sdk/esp32c3/include/esp32-camera/conversions/include/esp_jpg_decode.h b/tools/sdk/esp32c3/include/esp32-camera/conversions/include/esp_jpg_decode.h new file mode 100644 index 00000000000..f13536edf4d --- /dev/null +++ b/tools/sdk/esp32c3/include/esp32-camera/conversions/include/esp_jpg_decode.h @@ -0,0 +1,43 @@ +// Copyright 2015-2016 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_JPG_DECODE_H_ +#define _ESP_JPG_DECODE_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include "esp_err.h" + +typedef enum { + JPG_SCALE_NONE, + JPG_SCALE_2X, + JPG_SCALE_4X, + JPG_SCALE_8X, + JPG_SCALE_MAX = JPG_SCALE_8X +} jpg_scale_t; + +typedef size_t (* jpg_reader_cb)(void * arg, size_t index, uint8_t *buf, size_t len); +typedef bool (* jpg_writer_cb)(void * arg, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint8_t *data); + +esp_err_t esp_jpg_decode(size_t len, jpg_scale_t scale, jpg_reader_cb reader, jpg_writer_cb writer, void * arg); + +#ifdef __cplusplus +} +#endif + +#endif /* _ESP_JPG_DECODE_H_ */ diff --git a/tools/sdk/esp32c3/include/esp32-camera/conversions/include/img_converters.h b/tools/sdk/esp32c3/include/esp32-camera/conversions/include/img_converters.h new file mode 100644 index 00000000000..f736200a9b2 --- /dev/null +++ b/tools/sdk/esp32c3/include/esp32-camera/conversions/include/img_converters.h @@ -0,0 +1,130 @@ +// Copyright 2015-2016 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 _IMG_CONVERTERS_H_ +#define _IMG_CONVERTERS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include "esp_camera.h" +#include "esp_jpg_decode.h" + +typedef size_t (* jpg_out_cb)(void * arg, size_t index, const void* data, size_t len); + +/** + * @brief Convert image buffer to JPEG + * + * @param src Source buffer in RGB565, RGB888, YUYV or GRAYSCALE format + * @param src_len Length in bytes of the source buffer + * @param width Width in pixels of the source image + * @param height Height in pixels of the source image + * @param format Format of the source image + * @param quality JPEG quality of the resulting image + * @param cp Callback to be called to write the bytes of the output JPEG + * @param arg Pointer to be passed to the callback + * + * @return true on success + */ +bool fmt2jpg_cb(uint8_t *src, size_t src_len, uint16_t width, uint16_t height, pixformat_t format, uint8_t quality, jpg_out_cb cb, void * arg); + +/** + * @brief Convert camera frame buffer to JPEG + * + * @param fb Source camera frame buffer + * @param quality JPEG quality of the resulting image + * @param cp Callback to be called to write the bytes of the output JPEG + * @param arg Pointer to be passed to the callback + * + * @return true on success + */ +bool frame2jpg_cb(camera_fb_t * fb, uint8_t quality, jpg_out_cb cb, void * arg); + +/** + * @brief Convert image buffer to JPEG buffer + * + * @param src Source buffer in RGB565, RGB888, YUYV or GRAYSCALE format + * @param src_len Length in bytes of the source buffer + * @param width Width in pixels of the source image + * @param height Height in pixels of the source image + * @param format Format of the source image + * @param quality JPEG quality of the resulting image + * @param out Pointer to be populated with the address of the resulting buffer. + * You MUST free the pointer once you are done with it. + * @param out_len Pointer to be populated with the length of the output buffer + * + * @return true on success + */ +bool fmt2jpg(uint8_t *src, size_t src_len, uint16_t width, uint16_t height, pixformat_t format, uint8_t quality, uint8_t ** out, size_t * out_len); + +/** + * @brief Convert camera frame buffer to JPEG buffer + * + * @param fb Source camera frame buffer + * @param quality JPEG quality of the resulting image + * @param out Pointer to be populated with the address of the resulting buffer + * @param out_len Pointer to be populated with the length of the output buffer + * + * @return true on success + */ +bool frame2jpg(camera_fb_t * fb, uint8_t quality, uint8_t ** out, size_t * out_len); + +/** + * @brief Convert image buffer to BMP buffer + * + * @param src Source buffer in JPEG, RGB565, RGB888, YUYV or GRAYSCALE format + * @param src_len Length in bytes of the source buffer + * @param width Width in pixels of the source image + * @param height Height in pixels of the source image + * @param format Format of the source image + * @param out Pointer to be populated with the address of the resulting buffer + * @param out_len Pointer to be populated with the length of the output buffer + * + * @return true on success + */ +bool fmt2bmp(uint8_t *src, size_t src_len, uint16_t width, uint16_t height, pixformat_t format, uint8_t ** out, size_t * out_len); + +/** + * @brief Convert camera frame buffer to BMP buffer + * + * @param fb Source camera frame buffer + * @param out Pointer to be populated with the address of the resulting buffer + * @param out_len Pointer to be populated with the length of the output buffer + * + * @return true on success + */ +bool frame2bmp(camera_fb_t * fb, uint8_t ** out, size_t * out_len); + +/** + * @brief Convert image buffer to RGB888 buffer (used for face detection) + * + * @param src Source buffer in JPEG, RGB565, RGB888, YUYV or GRAYSCALE format + * @param src_len Length in bytes of the source buffer + * @param format Format of the source image + * @param rgb_buf Pointer to the output buffer (width * height * 3) + * + * @return true on success + */ +bool fmt2rgb888(const uint8_t *src_buf, size_t src_len, pixformat_t format, uint8_t * rgb_buf); + +bool jpg2rgb565(const uint8_t *src, size_t src_len, uint8_t * out, jpg_scale_t scale); + +#ifdef __cplusplus +} +#endif + +#endif /* _IMG_CONVERTERS_H_ */ diff --git a/tools/sdk/esp32c3/include/esp32-camera/driver/include/esp_camera.h b/tools/sdk/esp32c3/include/esp32-camera/driver/include/esp_camera.h new file mode 100755 index 00000000000..b6047d312ae --- /dev/null +++ b/tools/sdk/esp32c3/include/esp32-camera/driver/include/esp_camera.h @@ -0,0 +1,214 @@ +// Copyright 2015-2016 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. +/* + * Example Use + * + static camera_config_t camera_example_config = { + .pin_pwdn = PIN_PWDN, + .pin_reset = PIN_RESET, + .pin_xclk = PIN_XCLK, + .pin_sscb_sda = PIN_SIOD, + .pin_sscb_scl = PIN_SIOC, + .pin_d7 = PIN_D7, + .pin_d6 = PIN_D6, + .pin_d5 = PIN_D5, + .pin_d4 = PIN_D4, + .pin_d3 = PIN_D3, + .pin_d2 = PIN_D2, + .pin_d1 = PIN_D1, + .pin_d0 = PIN_D0, + .pin_vsync = PIN_VSYNC, + .pin_href = PIN_HREF, + .pin_pclk = PIN_PCLK, + + .xclk_freq_hz = 20000000, + .ledc_timer = LEDC_TIMER_0, + .ledc_channel = LEDC_CHANNEL_0, + .pixel_format = PIXFORMAT_JPEG, + .frame_size = FRAMESIZE_SVGA, + .jpeg_quality = 10, + .fb_count = 2, + .grab_mode = CAMERA_GRAB_WHEN_EMPTY + }; + + esp_err_t camera_example_init(){ + return esp_camera_init(&camera_example_config); + } + + esp_err_t camera_example_capture(){ + //capture a frame + camera_fb_t * fb = esp_camera_fb_get(); + if (!fb) { + ESP_LOGE(TAG, "Frame buffer could not be acquired"); + return ESP_FAIL; + } + + //replace this with your own function + display_image(fb->width, fb->height, fb->pixformat, fb->buf, fb->len); + + //return the frame buffer back to be reused + esp_camera_fb_return(fb); + + return ESP_OK; + } +*/ + +#pragma once + +#include "esp_err.h" +#include "driver/ledc.h" +#include "sensor.h" +#include "sys/time.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Configuration structure for camera initialization + */ +typedef enum { + CAMERA_GRAB_WHEN_EMPTY, /*!< Fills buffers when they are empty. Less resources but first 'fb_count' frames might be old */ + CAMERA_GRAB_LATEST /*!< Except when 1 frame buffer is used, queue will always contain the last 'fb_count' frames */ +} camera_grab_mode_t; + +/** + * @brief Camera frame buffer location + */ +typedef enum { + CAMERA_FB_IN_PSRAM, /*!< Frame buffer is placed in external PSRAM */ + CAMERA_FB_IN_DRAM /*!< Frame buffer is placed in internal DRAM */ +} camera_fb_location_t; + +/** + * @brief Configuration structure for camera initialization + */ +typedef struct { + int pin_pwdn; /*!< GPIO pin for camera power down line */ + int pin_reset; /*!< GPIO pin for camera reset line */ + int pin_xclk; /*!< GPIO pin for camera XCLK line */ + int pin_sscb_sda; /*!< GPIO pin for camera SDA line */ + int pin_sscb_scl; /*!< GPIO pin for camera SCL line */ + int pin_d7; /*!< GPIO pin for camera D7 line */ + int pin_d6; /*!< GPIO pin for camera D6 line */ + int pin_d5; /*!< GPIO pin for camera D5 line */ + int pin_d4; /*!< GPIO pin for camera D4 line */ + int pin_d3; /*!< GPIO pin for camera D3 line */ + int pin_d2; /*!< GPIO pin for camera D2 line */ + int pin_d1; /*!< GPIO pin for camera D1 line */ + int pin_d0; /*!< GPIO pin for camera D0 line */ + int pin_vsync; /*!< GPIO pin for camera VSYNC line */ + int pin_href; /*!< GPIO pin for camera HREF line */ + int pin_pclk; /*!< GPIO pin for camera PCLK line */ + + int xclk_freq_hz; /*!< Frequency of XCLK signal, in Hz. EXPERIMENTAL: Set to 16MHz on ESP32-S2 or ESP32-S3 to enable EDMA mode */ + + ledc_timer_t ledc_timer; /*!< LEDC timer to be used for generating XCLK */ + ledc_channel_t ledc_channel; /*!< LEDC channel to be used for generating XCLK */ + + pixformat_t pixel_format; /*!< Format of the pixel data: PIXFORMAT_ + YUV422|GRAYSCALE|RGB565|JPEG */ + framesize_t frame_size; /*!< Size of the output image: FRAMESIZE_ + QVGA|CIF|VGA|SVGA|XGA|SXGA|UXGA */ + + int jpeg_quality; /*!< Quality of JPEG output. 0-63 lower means higher quality */ + size_t fb_count; /*!< Number of frame buffers to be allocated. If more than one, then each frame will be acquired (double speed) */ + camera_fb_location_t fb_location; /*!< The location where the frame buffer will be allocated */ + camera_grab_mode_t grab_mode; /*!< When buffers should be filled */ +} camera_config_t; + +/** + * @brief Data structure of camera frame buffer + */ +typedef struct { + uint8_t * buf; /*!< Pointer to the pixel data */ + size_t len; /*!< Length of the buffer in bytes */ + size_t width; /*!< Width of the buffer in pixels */ + size_t height; /*!< Height of the buffer in pixels */ + pixformat_t format; /*!< Format of the pixel data */ + struct timeval timestamp; /*!< Timestamp since boot of the first DMA buffer of the frame */ +} camera_fb_t; + +#define ESP_ERR_CAMERA_BASE 0x20000 +#define ESP_ERR_CAMERA_NOT_DETECTED (ESP_ERR_CAMERA_BASE + 1) +#define ESP_ERR_CAMERA_FAILED_TO_SET_FRAME_SIZE (ESP_ERR_CAMERA_BASE + 2) +#define ESP_ERR_CAMERA_FAILED_TO_SET_OUT_FORMAT (ESP_ERR_CAMERA_BASE + 3) +#define ESP_ERR_CAMERA_NOT_SUPPORTED (ESP_ERR_CAMERA_BASE + 4) + +/** + * @brief Initialize the camera driver + * + * @note call camera_probe before calling this function + * + * This function detects and configures camera over I2C interface, + * allocates framebuffer and DMA buffers, + * initializes parallel I2S input, and sets up DMA descriptors. + * + * Currently this function can only be called once and there is + * no way to de-initialize this module. + * + * @param config Camera configuration parameters + * + * @return ESP_OK on success + */ +esp_err_t esp_camera_init(const camera_config_t* config); + +/** + * @brief Deinitialize the camera driver + * + * @return + * - ESP_OK on success + * - ESP_ERR_INVALID_STATE if the driver hasn't been initialized yet + */ +esp_err_t esp_camera_deinit(); + +/** + * @brief Obtain pointer to a frame buffer. + * + * @return pointer to the frame buffer + */ +camera_fb_t* esp_camera_fb_get(); + +/** + * @brief Return the frame buffer to be reused again. + * + * @param fb Pointer to the frame buffer + */ +void esp_camera_fb_return(camera_fb_t * fb); + +/** + * @brief Get a pointer to the image sensor control structure + * + * @return pointer to the sensor + */ +sensor_t * esp_camera_sensor_get(); + +/** + * @brief Save camera settings to non-volatile-storage (NVS) + * + * @param key A unique nvs key name for the camera settings + */ +esp_err_t esp_camera_save_to_nvs(const char *key); + +/** + * @brief Load camera settings from non-volatile-storage (NVS) + * + * @param key A unique nvs key name for the camera settings + */ +esp_err_t esp_camera_load_from_nvs(const char *key); + +#ifdef __cplusplus +} +#endif + +#include "img_converters.h" + diff --git a/tools/sdk/esp32c3/include/esp32-camera/driver/include/sensor.h b/tools/sdk/esp32c3/include/esp32-camera/driver/include/sensor.h new file mode 100755 index 00000000000..e4a1cceba57 --- /dev/null +++ b/tools/sdk/esp32c3/include/esp32-camera/driver/include/sensor.h @@ -0,0 +1,254 @@ +/* + * This file is part of the OpenMV project. + * Copyright (c) 2013/2014 Ibrahim Abdelkader + * This work is licensed under the MIT license, see the file LICENSE for details. + * + * Sensor abstraction layer. + * + */ +#ifndef __SENSOR_H__ +#define __SENSOR_H__ +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + OV9650_PID = 0x96, + OV7725_PID = 0x77, + OV2640_PID = 0x26, + OV3660_PID = 0x3660, + OV5640_PID = 0x5640, + OV7670_PID = 0x76, + NT99141_PID = 0x1410, + GC2145_PID = 0x2145, + GC032A_PID = 0x232a, + GC0308_PID = 0x9b, + BF3005_PID = 0x30, + BF20A6_PID = 0x20a6, + SC030IOT_PID = 0x9a46, +} camera_pid_t; + +typedef enum { + CAMERA_OV7725, + CAMERA_OV2640, + CAMERA_OV3660, + CAMERA_OV5640, + CAMERA_OV7670, + CAMERA_NT99141, + CAMERA_GC2145, + CAMERA_GC032A, + CAMERA_GC0308, + CAMERA_BF3005, + CAMERA_BF20A6, + CAMERA_SC030IOT, + CAMERA_MODEL_MAX, + CAMERA_NONE, +} camera_model_t; + +typedef enum { + OV2640_SCCB_ADDR = 0x30,// 0x60 >> 1 + OV5640_SCCB_ADDR = 0x3C,// 0x78 >> 1 + OV3660_SCCB_ADDR = 0x3C,// 0x78 >> 1 + OV7725_SCCB_ADDR = 0x21,// 0x42 >> 1 + OV7670_SCCB_ADDR = 0x21,// 0x42 >> 1 + NT99141_SCCB_ADDR = 0x2A,// 0x54 >> 1 + GC2145_SCCB_ADDR = 0x3C,// 0x78 >> 1 + GC032A_SCCB_ADDR = 0x21,// 0x42 >> 1 + GC0308_SCCB_ADDR = 0x21,// 0x42 >> 1 + BF3005_SCCB_ADDR = 0x6E, + BF20A6_SCCB_ADDR = 0x6E, + SC030IOT_SCCB_ADDR = 0x68,// 0xd0 >> 1 +} camera_sccb_addr_t; + +typedef enum { + PIXFORMAT_RGB565, // 2BPP/RGB565 + PIXFORMAT_YUV422, // 2BPP/YUV422 + PIXFORMAT_GRAYSCALE, // 1BPP/GRAYSCALE + PIXFORMAT_JPEG, // JPEG/COMPRESSED + PIXFORMAT_RGB888, // 3BPP/RGB888 + PIXFORMAT_RAW, // RAW + PIXFORMAT_RGB444, // 3BP2P/RGB444 + PIXFORMAT_RGB555, // 3BP2P/RGB555 +} pixformat_t; + +typedef enum { + FRAMESIZE_96X96, // 96x96 + FRAMESIZE_QQVGA, // 160x120 + FRAMESIZE_QCIF, // 176x144 + FRAMESIZE_HQVGA, // 240x176 + FRAMESIZE_240X240, // 240x240 + FRAMESIZE_QVGA, // 320x240 + FRAMESIZE_CIF, // 400x296 + FRAMESIZE_HVGA, // 480x320 + FRAMESIZE_VGA, // 640x480 + FRAMESIZE_SVGA, // 800x600 + FRAMESIZE_XGA, // 1024x768 + FRAMESIZE_HD, // 1280x720 + FRAMESIZE_SXGA, // 1280x1024 + FRAMESIZE_UXGA, // 1600x1200 + // 3MP Sensors + FRAMESIZE_FHD, // 1920x1080 + FRAMESIZE_P_HD, // 720x1280 + FRAMESIZE_P_3MP, // 864x1536 + FRAMESIZE_QXGA, // 2048x1536 + // 5MP Sensors + FRAMESIZE_QHD, // 2560x1440 + FRAMESIZE_WQXGA, // 2560x1600 + FRAMESIZE_P_FHD, // 1080x1920 + FRAMESIZE_QSXGA, // 2560x1920 + FRAMESIZE_INVALID +} framesize_t; + +typedef struct { + const camera_model_t model; + const char *name; + const camera_sccb_addr_t sccb_addr; + const camera_pid_t pid; + const framesize_t max_size; + const bool support_jpeg; +} camera_sensor_info_t; + +typedef enum { + ASPECT_RATIO_4X3, + ASPECT_RATIO_3X2, + ASPECT_RATIO_16X10, + ASPECT_RATIO_5X3, + ASPECT_RATIO_16X9, + ASPECT_RATIO_21X9, + ASPECT_RATIO_5X4, + ASPECT_RATIO_1X1, + ASPECT_RATIO_9X16 +} aspect_ratio_t; + +typedef enum { + GAINCEILING_2X, + GAINCEILING_4X, + GAINCEILING_8X, + GAINCEILING_16X, + GAINCEILING_32X, + GAINCEILING_64X, + GAINCEILING_128X, +} gainceiling_t; + +typedef struct { + uint16_t max_width; + uint16_t max_height; + uint16_t start_x; + uint16_t start_y; + uint16_t end_x; + uint16_t end_y; + uint16_t offset_x; + uint16_t offset_y; + uint16_t total_x; + uint16_t total_y; +} ratio_settings_t; + +typedef struct { + const uint16_t width; + const uint16_t height; + const aspect_ratio_t aspect_ratio; +} resolution_info_t; + +// Resolution table (in sensor.c) +extern const resolution_info_t resolution[]; +// camera sensor table (in sensor.c) +extern const camera_sensor_info_t camera_sensor[]; + +typedef struct { + uint8_t MIDH; + uint8_t MIDL; + uint16_t PID; + uint8_t VER; +} sensor_id_t; + +typedef struct { + framesize_t framesize;//0 - 10 + bool scale; + bool binning; + uint8_t quality;//0 - 63 + int8_t brightness;//-2 - 2 + int8_t contrast;//-2 - 2 + int8_t saturation;//-2 - 2 + int8_t sharpness;//-2 - 2 + uint8_t denoise; + uint8_t special_effect;//0 - 6 + uint8_t wb_mode;//0 - 4 + uint8_t awb; + uint8_t awb_gain; + uint8_t aec; + uint8_t aec2; + int8_t ae_level;//-2 - 2 + uint16_t aec_value;//0 - 1200 + uint8_t agc; + uint8_t agc_gain;//0 - 30 + uint8_t gainceiling;//0 - 6 + uint8_t bpc; + uint8_t wpc; + uint8_t raw_gma; + uint8_t lenc; + uint8_t hmirror; + uint8_t vflip; + uint8_t dcw; + uint8_t colorbar; +} camera_status_t; + +typedef struct _sensor sensor_t; +typedef struct _sensor { + sensor_id_t id; // Sensor ID. + uint8_t slv_addr; // Sensor I2C slave address. + pixformat_t pixformat; + camera_status_t status; + int xclk_freq_hz; + + // Sensor function pointers + int (*init_status) (sensor_t *sensor); + int (*reset) (sensor_t *sensor); + int (*set_pixformat) (sensor_t *sensor, pixformat_t pixformat); + int (*set_framesize) (sensor_t *sensor, framesize_t framesize); + int (*set_contrast) (sensor_t *sensor, int level); + int (*set_brightness) (sensor_t *sensor, int level); + int (*set_saturation) (sensor_t *sensor, int level); + int (*set_sharpness) (sensor_t *sensor, int level); + int (*set_denoise) (sensor_t *sensor, int level); + int (*set_gainceiling) (sensor_t *sensor, gainceiling_t gainceiling); + int (*set_quality) (sensor_t *sensor, int quality); + int (*set_colorbar) (sensor_t *sensor, int enable); + int (*set_whitebal) (sensor_t *sensor, int enable); + int (*set_gain_ctrl) (sensor_t *sensor, int enable); + int (*set_exposure_ctrl) (sensor_t *sensor, int enable); + int (*set_hmirror) (sensor_t *sensor, int enable); + int (*set_vflip) (sensor_t *sensor, int enable); + + int (*set_aec2) (sensor_t *sensor, int enable); + int (*set_awb_gain) (sensor_t *sensor, int enable); + int (*set_agc_gain) (sensor_t *sensor, int gain); + int (*set_aec_value) (sensor_t *sensor, int gain); + + int (*set_special_effect) (sensor_t *sensor, int effect); + int (*set_wb_mode) (sensor_t *sensor, int mode); + int (*set_ae_level) (sensor_t *sensor, int level); + + int (*set_dcw) (sensor_t *sensor, int enable); + int (*set_bpc) (sensor_t *sensor, int enable); + int (*set_wpc) (sensor_t *sensor, int enable); + + int (*set_raw_gma) (sensor_t *sensor, int enable); + int (*set_lenc) (sensor_t *sensor, int enable); + + int (*get_reg) (sensor_t *sensor, int reg, int mask); + int (*set_reg) (sensor_t *sensor, int reg, int mask, int value); + int (*set_res_raw) (sensor_t *sensor, int startX, int startY, int endX, int endY, int offsetX, int offsetY, int totalX, int totalY, int outputX, int outputY, bool scale, bool binning); + int (*set_pll) (sensor_t *sensor, int bypass, int mul, int sys, int root, int pre, int seld5, int pclken, int pclk); + int (*set_xclk) (sensor_t *sensor, int timer, int xclk); +} sensor_t; + +camera_sensor_info_t *esp_camera_sensor_get_info(sensor_id_t *id); + +#ifdef __cplusplus +} +#endif + +#endif /* __SENSOR_H__ */ diff --git a/tools/sdk/esp32c3/include/esp_http_client/include/esp_http_client.h b/tools/sdk/esp32c3/include/esp_http_client/include/esp_http_client.h index d1b530a42e3..6ba8ed6e582 100644 --- a/tools/sdk/esp32c3/include/esp_http_client/include/esp_http_client.h +++ b/tools/sdk/esp32c3/include/esp_http_client/include/esp_http_client.h @@ -149,7 +149,9 @@ typedef enum { HttpStatus_MultipleChoices = 300, HttpStatus_MovedPermanently = 301, HttpStatus_Found = 302, + HttpStatus_SeeOther = 303, HttpStatus_TemporaryRedirect = 307, + HttpStatus_PermanentRedirect = 308, /* 4xx - Client Error */ HttpStatus_BadRequest = 400, diff --git a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/spinlock.h b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/spinlock.h index fbeff5054b4..b2fadfe49e3 100644 --- a/tools/sdk/esp32c3/include/esp_hw_support/include/soc/spinlock.h +++ b/tools/sdk/esp32c3/include/esp_hw_support/include/soc/spinlock.h @@ -95,13 +95,13 @@ static inline bool __attribute__((always_inline)) spinlock_acquire(spinlock_t *l */ result = core_id; -#if defined(CONFIG_ESP32_SPIRAM_SUPPORT) +#if (CONFIG_ESP32_SPIRAM_SUPPORT || CONFIG_ESP32S3_SPIRAM_SUPPORT) if (esp_ptr_external_ram(lock)) { compare_and_set_extram(&lock->owner, SPINLOCK_FREE, &result); } else { #endif compare_and_set_native(&lock->owner, SPINLOCK_FREE, &result); -#if defined(CONFIG_ESP32_SPIRAM_SUPPORT) +#if (CONFIG_ESP32_SPIRAM_SUPPORT || CONFIG_ESP32S3_SPIRAM_SUPPORT) } #endif if(result != other_core_id) { diff --git a/tools/sdk/esp32c3/include/esp_lcd/include/esp_lcd_panel_io.h b/tools/sdk/esp32c3/include/esp_lcd/include/esp_lcd_panel_io.h index 330f4d9a165..7b99bde3f17 100644 --- a/tools/sdk/esp32c3/include/esp_lcd/include/esp_lcd_panel_io.h +++ b/tools/sdk/esp32c3/include/esp_lcd/include/esp_lcd_panel_io.h @@ -19,6 +19,25 @@ typedef void *esp_lcd_spi_bus_handle_t; /*!< Type of LCD S typedef void *esp_lcd_i2c_bus_handle_t; /*!< Type of LCD I2C bus handle */ typedef struct esp_lcd_i80_bus_t *esp_lcd_i80_bus_handle_t; /*!< Type of LCD intel 8080 bus handle */ +/** + * @brief Transmit LCD command and receive corresponding parameters + * + * @note Commands sent by this function are short, so they are sent using polling transactions. + * The function does not return before the command tranfer is completed. + * If any queued transactions sent by `esp_lcd_panel_io_tx_color()` are still pending when this function is called, + * this function will wait until they are finished and the queue is empty before sending the command(s). + * + * @param[in] io LCD panel IO handle, which is created by other factory API like `esp_lcd_new_panel_io_spi()` + * @param[in] lcd_cmd The specific LCD command, set to -1 if no command needed + * @param[out] param Buffer for the command data + * @param[in] param_size Size of `param` buffer + * @return + * - ESP_ERR_INVALID_ARG if parameter is invalid + * - ESP_ERR_NOT_SUPPORTED if read is not supported by transport + * - ESP_OK on success + */ +esp_err_t esp_lcd_panel_io_rx_param(esp_lcd_panel_io_handle_t io, int lcd_cmd, void *param, size_t param_size); + /** * @brief Transmit LCD command and corresponding parameters * @@ -98,7 +117,8 @@ typedef struct { unsigned int dc_as_cmd_phase: 1; /*!< D/C line value is encoded into SPI transaction command phase */ unsigned int dc_low_on_data: 1; /*!< If this flag is enabled, DC line = 0 means transfer data, DC line = 1 means transfer command; vice versa */ unsigned int octal_mode: 1; /*!< transmit with octal mode (8 data lines), this mode is used to simulate Intel 8080 timing */ - } flags; + unsigned int lsb_first: 1; /*!< transmit LSB bit first */ + } flags; /*!< Extra flags to fine-tune the SPI device */ } esp_lcd_panel_io_spi_config_t; /** @@ -124,6 +144,7 @@ typedef struct { int lcd_param_bits; /*!< Bit-width of LCD parameter */ struct { unsigned int dc_low_on_data: 1; /*!< If this flag is enabled, DC line = 0 means transfer data, DC line = 1 means transfer command; vice versa */ + unsigned int disable_control_phase: 1; /*!< If this flag is enabled, the control phase isn't used */ } flags; } esp_lcd_panel_io_i2c_config_t; @@ -151,6 +172,8 @@ typedef struct { int data_gpio_nums[SOC_LCD_I80_BUS_WIDTH]; /*!< GPIOs used for data lines */ size_t bus_width; /*!< Number of data lines, 8 or 16 */ size_t max_transfer_bytes; /*!< Maximum transfer size, this determines the length of internal DMA link */ + size_t psram_trans_align; /*!< DMA transfer alignment for data allocated from PSRAM */ + size_t sram_trans_align; /*!< DMA transfer alignment for data allocated from SRAM */ } esp_lcd_i80_bus_config_t; /** diff --git a/tools/sdk/esp32c3/include/esp_lcd/include/esp_lcd_panel_rgb.h b/tools/sdk/esp32c3/include/esp_lcd/include/esp_lcd_panel_rgb.h index 6f06deb8165..95dfb6ba4fc 100644 --- a/tools/sdk/esp32c3/include/esp_lcd/include/esp_lcd_panel_rgb.h +++ b/tools/sdk/esp32c3/include/esp_lcd/include/esp_lcd_panel_rgb.h @@ -59,7 +59,7 @@ typedef struct { unsigned int hsync_front_porch; /*!< Horizontal front porch, number of PCLK between the end of active data and the next hsync */ unsigned int vsync_pulse_width; /*!< Vertical sync width, unit: number of lines */ unsigned int vsync_back_porch; /*!< Vertical back porch, number of invalid lines between vsync and start of frame */ - unsigned int vsync_front_porch; /*!< Vertical front porch, number of invalid lines between then end of frame and the next vsync */ + unsigned int vsync_front_porch; /*!< Vertical front porch, number of invalid lines between the end of frame and the next vsync */ struct { unsigned int hsync_idle_low: 1; /*!< The hsync signal is low in IDLE state */ unsigned int vsync_idle_low: 1; /*!< The vsync signal is low in IDLE state */ diff --git a/tools/sdk/esp32c3/include/esp_lcd/interface/esp_lcd_panel_io_interface.h b/tools/sdk/esp32c3/include/esp_lcd/interface/esp_lcd_panel_io_interface.h index 2faa6fab268..9f2226587e5 100644 --- a/tools/sdk/esp32c3/include/esp_lcd/interface/esp_lcd_panel_io_interface.h +++ b/tools/sdk/esp32c3/include/esp_lcd/interface/esp_lcd_panel_io_interface.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -18,6 +18,22 @@ typedef struct esp_lcd_panel_io_t esp_lcd_panel_io_t; /*!< Type of LCD panel IO * @brief LCD panel IO interface */ struct esp_lcd_panel_io_t { + /** + * @brief Transmit LCD command and receive corresponding parameters + * + * @note This is the panel-specific interface called by function `esp_lcd_panel_io_rx_param()`. + * + * @param[in] io LCD panel IO handle, which is created by other factory API like `esp_lcd_new_panel_io_spi()` + * @param[in] lcd_cmd The specific LCD command, set to -1 if no command needed + * @param[out] param Buffer for the command data + * @param[in] param_size Size of `param` buffer + * @return + * - ESP_ERR_INVALID_ARG if parameter is invalid + * - ESP_ERR_NOT_SUPPORTED if read is not supported by transport + * - ESP_OK on success + */ + esp_err_t (*rx_param)(esp_lcd_panel_io_t *io, int lcd_cmd, void *param, size_t param_size); + /** * @brief Transmit LCD command and corresponding parameters * diff --git a/tools/sdk/esp32c3/include/esp_phy/esp32c3/include/phy_init_data.h b/tools/sdk/esp32c3/include/esp_phy/esp32c3/include/phy_init_data.h index 7e458c43117..212cd582de8 100644 --- a/tools/sdk/esp32c3/include/esp_phy/esp32c3/include/phy_init_data.h +++ b/tools/sdk/esp32c3/include/esp_phy/esp32c3/include/phy_init_data.h @@ -20,8 +20,8 @@ extern "C" { // define the lowest tx power as LOWEST_PHY_TX_POWER #define PHY_TX_POWER_LOWEST LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 52) -#define PHY_TX_POWER_OFFSET 44 -#define PHY_TX_POWER_NUM 5 +#define PHY_TX_POWER_OFFSET 2 +#define PHY_TX_POWER_NUM 14 #if CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN #define PHY_CRC_ALGORITHM 1 diff --git a/tools/sdk/esp32c3/include/esp_phy/include/esp_phy_init.h b/tools/sdk/esp32c3/include/esp_phy/include/esp_phy_init.h index 04068c7f38d..ec682139506 100644 --- a/tools/sdk/esp32c3/include/esp_phy/include/esp_phy_init.h +++ b/tools/sdk/esp32c3/include/esp_phy/include/esp_phy_init.h @@ -170,12 +170,27 @@ void esp_phy_disable(void); */ void esp_phy_load_cal_and_init(void); +/** + * @brief Initialize backup memory for Phy power up/down + */ +void esp_phy_pd_mem_init(void); + +/** + * @brief Deinitialize backup memory for Phy power up/down + */ +void esp_phy_pd_mem_deinit(void); + #if CONFIG_MAC_BB_PD /** * @brief Initialize backup memory for MAC and Baseband power up/down */ void esp_mac_bb_pd_mem_init(void); +/** + * @brief Deinitialize backup memory for MAC and Baseband power up/down + */ +void esp_mac_bb_pd_mem_deinit(void); + /** * @brief Power up MAC and Baseband */ diff --git a/tools/sdk/esp32c3/include/esp_rainmaker/include/esp_rmaker_core.h b/tools/sdk/esp32c3/include/esp_rainmaker/include/esp_rmaker_core.h index 9dbdbae658b..eb01e6d8e3d 100644 --- a/tools/sdk/esp32c3/include/esp_rainmaker/include/esp_rmaker_core.h +++ b/tools/sdk/esp32c3/include/esp_rainmaker/include/esp_rmaker_core.h @@ -63,6 +63,8 @@ typedef struct { char *fw_version; /** Model (Optional). If not set, PROJECT_NAME is used as default (recommended)*/ char *model; + /** Subtype (Optional). */ + char *subtype; } esp_rmaker_node_info_t; /** ESP RainMaker Configuration */ @@ -430,10 +432,11 @@ esp_err_t esp_rmaker_node_add_attribute(const esp_rmaker_node_t *node, const cha */ esp_err_t esp_rmaker_node_add_fw_version(const esp_rmaker_node_t *node, const char *fw_version); -/** Add model for a node (Not recommended) +/** Add model for a node * * Model is set internally to the project name. This API can be used to - * override that name. + * override that name, now that a new field "project" has also been added + * internally to the node info. * * @param node Node handle. * @param[in] model New model string. @@ -443,6 +446,16 @@ esp_err_t esp_rmaker_node_add_fw_version(const esp_rmaker_node_t *node, const ch */ esp_err_t esp_rmaker_node_add_model(const esp_rmaker_node_t *node, const char *model); +/** Add subtype for a node + * + * @param node Node handle. + * @param[in] subtype Subtype string. + * + * @return ESP_OK on success. + * @return error in case of failure. + */ +esp_err_t esp_rmaker_node_add_subtype(const esp_rmaker_node_t *node, const char *subtype); + /** * Create a Device * @@ -572,6 +585,18 @@ esp_err_t esp_rmaker_device_add_attribute(const esp_rmaker_device_t *device, con */ esp_err_t esp_rmaker_device_add_subtype(const esp_rmaker_device_t *device, const char *subtype); +/** Add a Device model + * + * This would primarily be used by the phone apps to render different icons for the same device type. + * + * @param[in] device Device handle. + * @param[in] model String describing the model. + * + * @return ESP_OK if the model was added successfully. + * @return error in case of failure. + */ +esp_err_t esp_rmaker_device_add_model(const esp_rmaker_device_t *device, const char *model); + /** Get device name from handle * * @param[in] device Device handle. @@ -892,6 +917,20 @@ esp_err_t esp_rmaker_system_service_enable(esp_rmaker_system_serv_config_t *conf */ bool esp_rmaker_local_ctrl_service_started(void); +/** + * Enable Default RainMaker OTA Firmware Upgrade + * + * This enables the default recommended RainMaker OTA Firmware Upgrade, which is + * "Using the Topics", which allows performing OTA from Dashboard. + * This OTA can be triggered by Admin Users only. + * On Public RainMaker deployment, for nodes using "Self Claiming", since there + * is no associated admin user, the Primary user will automatically become the admin + * and can perform OTA from dashboard. + * + * @return ESP_OK on success + * @return error on failure + */ +esp_err_t esp_rmaker_ota_enable_default(void); #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32c3/include/esp_rainmaker/include/esp_rmaker_ota.h b/tools/sdk/esp32c3/include/esp_rainmaker/include/esp_rmaker_ota.h index e66b95705bc..6dc7962177e 100644 --- a/tools/sdk/esp32c3/include/esp_rainmaker/include/esp_rmaker_ota.h +++ b/tools/sdk/esp32c3/include/esp_rainmaker/include/esp_rmaker_ota.h @@ -34,6 +34,8 @@ typedef enum { OTA_STATUS_FAILED, /** OTA was delayed by the application */ OTA_STATUS_DELAYED, + /** OTA rejected due to some reason (wrong project, version, etc.) */ + OTA_STATUS_REJECTED, } ota_status_t; /** OTA Workflow type */ @@ -145,6 +147,29 @@ esp_err_t esp_rmaker_ota_enable(esp_rmaker_ota_config_t *ota_config, esp_rmaker_ */ esp_err_t esp_rmaker_ota_report_status(esp_rmaker_ota_handle_t ota_handle, ota_status_t status, char *additional_info); +/** Default OTA callback + * + * This is the default OTA callback which will get used if you do not pass your own callback. You can call this + * even from your callback, in case you want better control on when the OTA can proceed and yet let the actual + * OTA process be managed by the RainMaker Core. + * + * @param[in] handle An OTA handle assigned by the ESP RainMaker Core + * @param[in] ota_data The data to be used for the OTA + * + * @return ESP_OK if the OTA was successful + * @return ESP_FAIL if the OTA failed. + * */ +esp_err_t esp_rmaker_ota_default_cb(esp_rmaker_ota_handle_t handle, esp_rmaker_ota_data_t *ota_data); + +/** Fetch OTA Info + * + * For OTA using Topics, this API can be used to explicitly ask the backend if an OTA is available. + * If it is, then the OTA callback would get invoked. + * + * @return ESP_OK if the OTA fetch publish message was successful. + * @return error on failure + */ +esp_err_t esp_rmaker_ota_fetch(void); #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32c3/include/esp_rainmaker/include/esp_rmaker_standard_types.h b/tools/sdk/esp32c3/include/esp_rainmaker/include/esp_rmaker_standard_types.h index 4dc99eab401..9f74fcaea7c 100644 --- a/tools/sdk/esp32c3/include/esp_rainmaker/include/esp_rmaker_standard_types.h +++ b/tools/sdk/esp32c3/include/esp_rainmaker/include/esp_rmaker_standard_types.h @@ -25,6 +25,10 @@ extern "C" #define ESP_RMAKER_UI_DROPDOWN "esp.ui.dropdown" #define ESP_RMAKER_UI_TEXT "esp.ui.text" #define ESP_RMAKER_UI_HUE_SLIDER "esp.ui.hue-slider" +#define ESP_RMAKER_UI_HUE_CIRCLE "esp.ui.hue-circle" +#define ESP_RMAKER_UI_PUSHBUTTON "esp.ui.push-btn-big" +#define ESP_RMAKER_UI_TRIGGER "esp.ui.trigger" +#define ESP_RMAKER_UI_HIDDEN "esp.ui.hidden" /********** STANDARD PARAM TYPES **********/ @@ -50,6 +54,13 @@ extern "C" #define ESP_RMAKER_PARAM_WIFI_RESET "esp.param.wifi-reset" #define ESP_RMAKER_PARAM_LOCAL_CONTROL_POP "esp.param.local_control_pop" #define ESP_RMAKER_PARAM_LOCAL_CONTROL_TYPE "esp.param.local_control_type" +#define ESP_RMAKER_PARAM_TOGGLE "esp.param.toggle" +#define ESP_RMAKER_PARAM_RANGE "esp.param.range" +#define ESP_RMAKER_PARAM_MODE "esp.param.mode" +#define ESP_RMAKER_PARAM_BLINDS_POSITION "esp.param.blinds-position" +#define ESP_RMAKER_PARAM_GARAGE_POSITION "esp.param.garage-position" +#define ESP_RMAKER_PARAM_LIGHT_MODE "esp.param.light-mode" +#define ESP_RMAKER_PARAM_AC_MODE "esp.param.ac-mode" /********** STANDARD DEVICE TYPES **********/ @@ -58,7 +69,21 @@ extern "C" #define ESP_RMAKER_DEVICE_LIGHTBULB "esp.device.lightbulb" #define ESP_RMAKER_DEVICE_FAN "esp.device.fan" #define ESP_RMAKER_DEVICE_TEMP_SENSOR "esp.device.temperature-sensor" - +#define ESP_RMAKER_DEVICE_LIGHT "esp.device.light" +#define ESP_RMAKER_DEVICE_OUTLET "esp.device.outlet" +#define ESP_RMAKER_DEVICE_PLUG "esp.device.plug" +#define ESP_RMAKER_DEVICE_SOCKET "esp.device.socket" +#define ESP_RMAKER_DEVICE_LOCK "esp.device.lock" +#define ESP_RMAKER_DEVICE_BLINDS_INTERNAL "esp.device.blinds-internal" +#define ESP_RMAKER_DEVICE_BLINDS_EXTERNAL "esp.device.blinds-external" +#define ESP_RMAKER_DEVICE_GARAGE_DOOR "esp.device.garage-door" +#define ESP_RMAKER_DEVICE_GARAGE_LOCK "esp.device.garage-door-lock" +#define ESP_RMAKER_DEVICE_SPEAKER "esp.device.speaker" +#define ESP_RMAKER_DEVICE_AIR_CONDITIONER "esp.device.air-conditioner" +#define ESP_RMAKER_DEVICE_THERMOSTAT "esp.device.thermostat" +#define ESP_RMAKER_DEVICE_TV "esp.device.tv" +#define ESP_RMAKER_DEVICE_WASHER "esp.device.washer" +#define ESP_RMAKER_DEVICE_OTHER "esp.device.other" /********** STANDARD SERVICE TYPES **********/ #define ESP_RMAKER_SERVICE_OTA "esp.service.ota" diff --git a/tools/sdk/esp32c3/include/esp_rainmaker/include/esp_rmaker_user_mapping.h b/tools/sdk/esp32c3/include/esp_rainmaker/include/esp_rmaker_user_mapping.h index 77a153b02f2..734cdd6da2a 100644 --- a/tools/sdk/esp32c3/include/esp_rainmaker/include/esp_rmaker_user_mapping.h +++ b/tools/sdk/esp32c3/include/esp_rainmaker/include/esp_rmaker_user_mapping.h @@ -25,6 +25,8 @@ typedef enum { ESP_RMAKER_USER_MAPPING_RESET = 0, /** Mapping has started */ ESP_RMAKER_USER_MAPPING_STARTED, + /** Mapping request sent to cloud */ + ESP_RMAKER_USER_MAPPING_REQ_SENT, /** Mapping is done */ ESP_RMAKER_USER_MAPPING_DONE, } esp_rmaker_user_mapping_state_t; diff --git a/tools/sdk/esp32c3/include/esp_rom/include/esp32c3/rom/efuse.h b/tools/sdk/esp32c3/include/esp_rom/include/esp32c3/rom/efuse.h index 9da1525f969..d1412c46110 100644 --- a/tools/sdk/esp32c3/include/esp_rom/include/esp32c3/rom/efuse.h +++ b/tools/sdk/esp32c3/include/esp_rom/include/esp32c3/rom/efuse.h @@ -1,16 +1,8 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ROM_EFUSE_H_ #define _ROM_EFUSE_H_ @@ -236,13 +228,13 @@ bool ets_efuse_legacy_spi_boot_mode_disabled(void); uint32_t ets_efuse_get_uart_print_control(void); /** - * @brief Read which channel will used by ROM to print + * @brief Read if USB-Serial-JTAG print during rom boot is disabled from Efuse * * @return - * - 0 for UART0. - * - 1 for UART1. + * - 1 for efuse disable USB-Serial-JTAG print during rom boot. + * - 0 for efuse doesn't disable USB-Serial-JTAG print during rom boot. */ -uint32_t ets_efuse_get_uart_print_channel(void); +uint32_t ets_efuse_usb_serial_jtag_print_is_disabled(void); /** * @brief Read if usb download mode disabled from Efuse diff --git a/tools/sdk/esp32c3/include/esp_rom/include/esp32h2/rom/efuse.h b/tools/sdk/esp32c3/include/esp_rom/include/esp32h2/rom/efuse.h index 9da1525f969..d1412c46110 100644 --- a/tools/sdk/esp32c3/include/esp_rom/include/esp32h2/rom/efuse.h +++ b/tools/sdk/esp32c3/include/esp_rom/include/esp32h2/rom/efuse.h @@ -1,16 +1,8 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ROM_EFUSE_H_ #define _ROM_EFUSE_H_ @@ -236,13 +228,13 @@ bool ets_efuse_legacy_spi_boot_mode_disabled(void); uint32_t ets_efuse_get_uart_print_control(void); /** - * @brief Read which channel will used by ROM to print + * @brief Read if USB-Serial-JTAG print during rom boot is disabled from Efuse * * @return - * - 0 for UART0. - * - 1 for UART1. + * - 1 for efuse disable USB-Serial-JTAG print during rom boot. + * - 0 for efuse doesn't disable USB-Serial-JTAG print during rom boot. */ -uint32_t ets_efuse_get_uart_print_channel(void); +uint32_t ets_efuse_usb_serial_jtag_print_is_disabled(void); /** * @brief Read if usb download mode disabled from Efuse diff --git a/tools/sdk/esp32c3/include/esp_rom/include/esp32s3/rom/efuse.h b/tools/sdk/esp32c3/include/esp_rom/include/esp32s3/rom/efuse.h index cbe38e6a55e..3d347f48330 100644 --- a/tools/sdk/esp32c3/include/esp_rom/include/esp32s3/rom/efuse.h +++ b/tools/sdk/esp32c3/include/esp_rom/include/esp32s3/rom/efuse.h @@ -1,16 +1,8 @@ -// Copyright 2015-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. +/* + * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once @@ -237,13 +229,13 @@ bool ets_efuse_legacy_spi_boot_mode_disabled(void); uint32_t ets_efuse_get_uart_print_control(void); /** - * @brief Read which channel will used by ROM to print + * @brief Read if USB-Serial-JTAG print during rom boot is disabled from Efuse * * @return - * - 0 for UART0. - * - 1 for UART1. + * - 1 for efuse disable USB-Serial-JTAG print during rom boot. + * - 0 for efuse doesn't disable USB-Serial-JTAG print during rom boot. */ -uint32_t ets_efuse_get_uart_print_channel(void); +uint32_t ets_efuse_usb_serial_jtag_print_is_disabled(void); /** * @brief Read if usb download mode disabled from Efuse diff --git a/tools/sdk/esp32c3/include/esp_wifi/include/esp_wifi.h b/tools/sdk/esp32c3/include/esp_wifi/include/esp_wifi.h index bcd10c77a10..3d62c5c297c 100644 --- a/tools/sdk/esp32c3/include/esp_wifi/include/esp_wifi.h +++ b/tools/sdk/esp32c3/include/esp_wifi/include/esp_wifi.h @@ -1295,6 +1295,19 @@ esp_err_t esp_wifi_get_country_code(char *country); */ esp_err_t esp_wifi_config_80211_tx_rate(wifi_interface_t ifx, wifi_phy_rate_t rate); +/** + * @brief Disable PMF configuration for specified interface + * + * @attention This API should be called after esp_wifi_set_config() and before esp_wifi_start(). + * + * @param ifx Interface to be configured. + * + * @return + * - ESP_OK: succeed + * - others: failed + */ +esp_err_t esp_wifi_disable_pmf_config(wifi_interface_t ifx); + #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32c3/include/freertos/include/esp_additions/freertos/task_snapshot.h b/tools/sdk/esp32c3/include/freertos/include/esp_additions/freertos/task_snapshot.h index 1ad04cce694..635a5150257 100644 --- a/tools/sdk/esp32c3/include/freertos/include/esp_additions/freertos/task_snapshot.h +++ b/tools/sdk/esp32c3/include/freertos/include/esp_additions/freertos/task_snapshot.h @@ -80,8 +80,9 @@ TaskHandle_t pxTaskGetNext( TaskHandle_t pxTask ); * @note This function should not be used while FreeRTOS is running (as it doesn't acquire any locks). * @param pxTask task handle. * @param pxTaskSnapshot address of TaskSnapshot_t structure to fill. + * @return pdTRUE if operation was successful else pdFALSE */ -void vTaskGetSnapshot( TaskHandle_t pxTask, TaskSnapshot_t *pxTaskSnapshot ); +BaseType_t vTaskGetSnapshot( TaskHandle_t pxTask, TaskSnapshot_t *pxTaskSnapshot ); #ifdef __cplusplus } diff --git a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/cpu_ll.h b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/cpu_ll.h index bce67579112..154254c871e 100644 --- a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/cpu_ll.h +++ b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/cpu_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -14,6 +14,7 @@ #include "soc/assist_debug_reg.h" #include "esp_attr.h" #include "riscv/csr.h" +#include "riscv/semihosting.h" /*performance counter*/ #define CSR_PCER_MACHINE 0x7e0 @@ -71,8 +72,29 @@ static inline void cpu_ll_init_hwloop(void) // Nothing needed here for ESP32-C3 } +FORCE_INLINE_ATTR bool cpu_ll_is_debugger_attached(void) +{ + return REG_GET_BIT(ASSIST_DEBUG_CORE_0_DEBUG_MODE_REG, ASSIST_DEBUG_CORE_0_DEBUG_MODULE_ACTIVE); +} + static inline void cpu_ll_set_breakpoint(int id, uint32_t pc) { + if (cpu_ll_is_debugger_attached()) { + /* If we want to set breakpoint which when hit transfers control to debugger + * we need to set `action` in `mcontrol` to 1 (Enter Debug Mode). + * That `action` value is supported only when `dmode` of `tdata1` is set. + * But `dmode` can be modified by debugger only (from Debug Mode). + * + * So when debugger is connected we use special syscall to ask it to set breakpoint for us. + */ + long args[] = {true, id, (long)pc}; + int ret = semihosting_call_noerrno(ESP_SEMIHOSTING_SYS_BREAKPOINT_SET, args); + if (ret == 0) { + return; + } + } + /* The code bellow sets breakpoint which will trigger `Breakpoint` exception + * instead transfering control to debugger. */ RV_WRITE_CSR(tselect,id); RV_SET_CSR(CSR_TCONTROL,TCONTROL_MTE); RV_SET_CSR(CSR_TDATA1, TDATA1_USER|TDATA1_MACHINE|TDATA1_EXECUTE); @@ -82,6 +104,14 @@ static inline void cpu_ll_set_breakpoint(int id, uint32_t pc) static inline void cpu_ll_clear_breakpoint(int id) { + if (cpu_ll_is_debugger_attached()) { + /* see description in cpu_ll_set_breakpoint() */ + long args[] = {false, id}; + int ret = semihosting_call_noerrno(ESP_SEMIHOSTING_SYS_BREAKPOINT_SET, args); + if (ret == 0){ + return; + } + } RV_WRITE_CSR(tselect,id); RV_CLEAR_CSR(CSR_TCONTROL,TCONTROL_MTE); RV_CLEAR_CSR(CSR_TDATA1, TDATA1_USER|TDATA1_MACHINE|TDATA1_EXECUTE); @@ -105,6 +135,17 @@ static inline void cpu_ll_set_watchpoint(int id, bool on_write) { uint32_t addr_napot; + + if (cpu_ll_is_debugger_attached()) { + /* see description in cpu_ll_set_breakpoint() */ + long args[] = {true, id, (long)addr, (long)size, + (long)((on_read ? ESP_SEMIHOSTING_WP_FLG_RD : 0) | (on_write ? ESP_SEMIHOSTING_WP_FLG_WR : 0))}; + int ret = semihosting_call_noerrno(ESP_SEMIHOSTING_SYS_WATCHPOINT_SET, args); + if (ret == 0) { + return; + } + } + RV_WRITE_CSR(tselect,id); RV_SET_CSR(CSR_TCONTROL, TCONTROL_MPTE | TCONTROL_MTE); RV_SET_CSR(CSR_TDATA1, TDATA1_USER|TDATA1_MACHINE); @@ -123,6 +164,14 @@ static inline void cpu_ll_set_watchpoint(int id, static inline void cpu_ll_clear_watchpoint(int id) { + if (cpu_ll_is_debugger_attached()) { + /* see description in cpu_ll_set_breakpoint() */ + long args[] = {false, id}; + int ret = semihosting_call_noerrno(ESP_SEMIHOSTING_SYS_WATCHPOINT_SET, args); + if (ret == 0){ + return; + } + } RV_WRITE_CSR(tselect,id); RV_CLEAR_CSR(CSR_TCONTROL,TCONTROL_MTE); RV_CLEAR_CSR(CSR_TDATA1, TDATA1_USER|TDATA1_MACHINE); @@ -132,45 +181,12 @@ static inline void cpu_ll_clear_watchpoint(int id) return; } -FORCE_INLINE_ATTR bool cpu_ll_is_debugger_attached(void) -{ - return REG_GET_BIT(ASSIST_DEBUG_CORE_0_DEBUG_MODE_REG, ASSIST_DEBUG_CORE_0_DEBUG_MODULE_ACTIVE); -} - static inline void cpu_ll_break(void) { asm volatile("ebreak\n"); return; } -static inline int cpu_ll_syscall(int sys_nr, int arg1, int arg2, int arg3, int arg4, int* ret_errno) -{ - int host_ret, host_errno; - - asm volatile ( \ - ".option push\n" \ - ".option norvc\n" \ - "mv a0, %[sys_nr]\n" \ - "mv a1, %[arg1]\n" \ - "mv a2, %[arg2]\n" \ - "mv a3, %[arg3]\n" \ - "mv a4, %[arg4]\n" \ - "slli zero,zero,0x1f\n" \ - "ebreak\n" \ - "srai zero,zero,0x7\n" \ - "mv %[host_ret], a0\n" \ - "mv %[host_errno], a1\n" \ - ".option pop\n" \ - :[host_ret]"=r"(host_ret),[host_errno]"=r"(host_errno) - :[sys_nr]"r"(sys_nr),[arg1]"r"(arg1),[arg2]"r"(arg2),[arg3]"r"(arg3),[arg4]"r"(arg4) - :"a0","a1","a2","a3","a4"); - - if (ret_errno) { - *ret_errno = host_errno; - } - return host_ret; -} - static inline void cpu_ll_set_vecbase(const void* vecbase) { uintptr_t vecbase_int = (uintptr_t)vecbase; diff --git a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/i2c_ll.h b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/i2c_ll.h index 31743005b6e..a4b3662fb58 100644 --- a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/i2c_ll.h +++ b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/i2c_ll.h @@ -1,16 +1,8 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ // The LL layer for I2C register operations @@ -159,17 +151,17 @@ static inline void i2c_ll_set_bus_timing(i2c_dev_t *hw, i2c_clk_cal_t *bus_cfg) { HAL_FORCE_MODIFY_U32_REG_FIELD(hw->clk_conf, sclk_div_num, bus_cfg->clkm_div - 1); //scl period - hw->scl_low_period.period = bus_cfg->scl_low - 1; - hw->scl_high_period.period = bus_cfg->scl_high; + hw->scl_low_period.period = bus_cfg->scl_low - 2; + hw->scl_high_period.period = bus_cfg->scl_high - 3; //sda sample - hw->sda_hold.time = bus_cfg->sda_hold; - hw->sda_sample.time = bus_cfg->sda_sample; + hw->sda_hold.time = bus_cfg->sda_hold - 1; + hw->sda_sample.time = bus_cfg->sda_sample - 1; //setup - hw->scl_rstart_setup.time = bus_cfg->setup; - hw->scl_stop_setup.time = bus_cfg->setup; + hw->scl_rstart_setup.time = bus_cfg->setup - 1; + hw->scl_stop_setup.time = bus_cfg->setup - 1; //hold hw->scl_start_hold.time = bus_cfg->hold - 1; - hw->scl_stop_hold.time = bus_cfg->hold; + hw->scl_stop_hold.time = bus_cfg->hold - 1; hw->timeout.time_out_value = bus_cfg->tout; hw->timeout.time_out_en = 1; } diff --git a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/spi_ll.h b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/spi_ll.h index 5aace3ffff4..01070e918fc 100644 --- a/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/spi_ll.h +++ b/tools/sdk/esp32c3/include/hal/esp32c3/include/hal/spi_ll.h @@ -40,6 +40,8 @@ extern "C" { #define SPI_LL_PERIPH_CLK_FREQ (80 * 1000000) #define SPI_LL_GET_HW(ID) ((ID)==0? ({abort();NULL;}):&GPSPI2) +#define SPI_LL_DATA_MAX_BIT_LEN (1 << 18) + /** * The data structure holding calculated clock configuration. Since the * calculation needs long time, it should be calculated during initialization and diff --git a/tools/sdk/esp32c3/include/hal/include/hal/cpu_hal.h b/tools/sdk/esp32c3/include/hal/include/hal/cpu_hal.h index 824095871db..0e7e6f53a79 100644 --- a/tools/sdk/esp32c3/include/hal/include/hal/cpu_hal.h +++ b/tools/sdk/esp32c3/include/hal/include/hal/cpu_hal.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -70,11 +70,6 @@ extern "C" { */ #define cpu_hal_waiti() cpu_ll_waiti() -/** - * Trigger a syscall. - */ -#define cpu_hal_syscall(sys_nr, arg1, arg2, arg3, arg4, ret_errno) cpu_ll_syscall(sys_nr, arg1, arg2, arg3, arg4, ret_errno) - #if SOC_CPU_BREAKPOINTS_NUM > 0 /** diff --git a/tools/sdk/esp32c3/include/hal/include/hal/lcd_types.h b/tools/sdk/esp32c3/include/hal/include/hal/lcd_types.h index 1a62d8f8eb4..13810a79ac3 100644 --- a/tools/sdk/esp32c3/include/hal/include/hal/lcd_types.h +++ b/tools/sdk/esp32c3/include/hal/include/hal/lcd_types.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -19,6 +19,8 @@ extern "C" { * +=====================+=========================+============================+ * | LCD_CLK_SRC_PLL160M | High resolution | ESP_PM_APB_FREQ_MAX lock | * +---------------------+-------------------------+----------------------------+ + * | LCD_CLK_SRC_PLL240M | High resolution | ESP_PM_APB_FREQ_MAX lock | + * +---------------------+-------------------------+----------------------------+ * | LCD_CLK_SRC_APLL | Configurable resolution | ESP_PM_NO_LIGHT_SLEEP lock | * +---------------------+-------------------------+----------------------------+ * | LCD_CLK_SRC_XTAL | Medium resolution | No PM lock | @@ -27,6 +29,7 @@ extern "C" { */ typedef enum { LCD_CLK_SRC_PLL160M, /*!< Select PLL160M as the source clock */ + LCD_CLK_SRC_PLL240M, /*!< Select PLL240M as the source clock */ LCD_CLK_SRC_APLL, /*!< Select APLL as the source clock */ LCD_CLK_SRC_XTAL, /*!< Select XTAL as the source clock */ } lcd_clock_source_t; diff --git a/tools/sdk/esp32c3/include/hal/include/hal/rtc_hal.h b/tools/sdk/esp32c3/include/hal/include/hal/rtc_hal.h index 90f965ed58c..953123ec928 100644 --- a/tools/sdk/esp32c3/include/hal/include/hal/rtc_hal.h +++ b/tools/sdk/esp32c3/include/hal/include/hal/rtc_hal.h @@ -90,3 +90,5 @@ void rtc_cntl_hal_disable_tagmem_retention(void *addr); * Enable wakeup from ULP coprocessor. */ #define rtc_hal_ulp_wakeup_enable() rtc_cntl_ll_ulp_wakeup_enable() + +#define rtc_hal_ulp_int_clear() rtc_cntl_ll_ulp_int_clear() diff --git a/tools/sdk/esp32c3/include/hal/include/hal/systimer_types.h b/tools/sdk/esp32c3/include/hal/include/hal/systimer_types.h index 2af2f60f30c..d4583dc7ae0 100644 --- a/tools/sdk/esp32c3/include/hal/include/hal/systimer_types.h +++ b/tools/sdk/esp32c3/include/hal/include/hal/systimer_types.h @@ -30,6 +30,9 @@ typedef struct { struct { uint64_t lo : SOC_SYSTIMER_BIT_WIDTH_LO; /*!< Low part of counter value */ uint64_t hi : SOC_SYSTIMER_BIT_WIDTH_HI; /*!< High part of counter value */ +#if (SOC_SYSTIMER_BIT_WIDTH_LO + SOC_SYSTIMER_BIT_WIDTH_HI) < 64 + uint64_t reserved: (64 - (SOC_SYSTIMER_BIT_WIDTH_LO + SOC_SYSTIMER_BIT_WIDTH_HI)); +#endif }; uint64_t val; /*!< counter value */ }; diff --git a/tools/sdk/esp32c3/include/json_generator/upstream/json_generator.h b/tools/sdk/esp32c3/include/json_generator/upstream/json_generator.h index e3aa92eeecf..30e6a8dca74 100644 --- a/tools/sdk/esp32c3/include/json_generator/upstream/json_generator.h +++ b/tools/sdk/esp32c3/include/json_generator/upstream/json_generator.h @@ -174,7 +174,7 @@ int json_gen_end_array(json_gen_str_t *jstr); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that */ -int json_gen_push_object(json_gen_str_t *jstr, char *name); +int json_gen_push_object(json_gen_str_t *jstr, const char *name); /** Pop a named JSON object * @@ -208,7 +208,7 @@ int json_gen_pop_object(json_gen_str_t *jstr); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that. */ -int json_gen_push_object_str(json_gen_str_t *jstr, char *name, char *object_str); +int json_gen_push_object_str(json_gen_str_t *jstr, const char *name, const char *object_str); /** Push a named JSON array * @@ -223,7 +223,7 @@ int json_gen_push_object_str(json_gen_str_t *jstr, char *name, char *object_str) * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that */ -int json_gen_push_array(json_gen_str_t *jstr, char *name); +int json_gen_push_array(json_gen_str_t *jstr, const char *name); /** Pop a named JSON array * @@ -257,7 +257,7 @@ int json_gen_pop_array(json_gen_str_t *jstr); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that. */ -int json_gen_push_array_str(json_gen_str_t *jstr, char *name, char *array_str); +int json_gen_push_array_str(json_gen_str_t *jstr, const char *name, const char *array_str); /** Add a boolean element to an object * @@ -276,7 +276,7 @@ int json_gen_push_array_str(json_gen_str_t *jstr, char *name, char *array_str); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that */ -int json_gen_obj_set_bool(json_gen_str_t *jstr, char *name, bool val); +int json_gen_obj_set_bool(json_gen_str_t *jstr, const char *name, bool val); /** Add an integer element to an object * @@ -295,7 +295,7 @@ int json_gen_obj_set_bool(json_gen_str_t *jstr, char *name, bool val); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that */ -int json_gen_obj_set_int(json_gen_str_t *jstr, char *name, int val); +int json_gen_obj_set_int(json_gen_str_t *jstr, const char *name, int val); /** Add a float element to an object * @@ -314,7 +314,7 @@ int json_gen_obj_set_int(json_gen_str_t *jstr, char *name, int val); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that */ -int json_gen_obj_set_float(json_gen_str_t *jstr, char *name, float val); +int json_gen_obj_set_float(json_gen_str_t *jstr, const char *name, float val); /** Add a string element to an object * @@ -333,7 +333,7 @@ int json_gen_obj_set_float(json_gen_str_t *jstr, char *name, float val); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that */ -int json_gen_obj_set_string(json_gen_str_t *jstr, char *name, char *val); +int json_gen_obj_set_string(json_gen_str_t *jstr, const char *name, const char *val); /** Add a NULL element to an object * @@ -351,7 +351,7 @@ int json_gen_obj_set_string(json_gen_str_t *jstr, char *name, char *val); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that */ -int json_gen_obj_set_null(json_gen_str_t *jstr, char *name); +int json_gen_obj_set_null(json_gen_str_t *jstr, const char *name); /** Add a boolean element to an array * @@ -415,7 +415,7 @@ int json_gen_arr_set_float(json_gen_str_t *jstr, float val); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that */ -int json_gen_arr_set_string(json_gen_str_t *jstr, char *val); +int json_gen_arr_set_string(json_gen_str_t *jstr, const char *val); /** Add a NULL element to an array * @@ -452,7 +452,7 @@ int json_gen_arr_set_null(json_gen_str_t *jstr); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that */ -int json_gen_obj_start_long_string(json_gen_str_t *jstr, char *name, char *val); +int json_gen_obj_start_long_string(json_gen_str_t *jstr, const char *name, const char *val); /** Start a Long string in an array * @@ -473,7 +473,7 @@ int json_gen_obj_start_long_string(json_gen_str_t *jstr, char *name, char *val); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that */ -int json_gen_arr_start_long_string(json_gen_str_t *jstr, char *val); +int json_gen_arr_start_long_string(json_gen_str_t *jstr, const char *val); /** Add to a JSON Long string * @@ -489,7 +489,7 @@ int json_gen_arr_start_long_string(json_gen_str_t *jstr, char *val); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that */ -int json_gen_add_to_long_string(json_gen_str_t *jstr, char *val); +int json_gen_add_to_long_string(json_gen_str_t *jstr, const char *val); /** End a JSON Long string * diff --git a/tools/sdk/esp32c3/include/json_parser/upstream/include/json_parser.h b/tools/sdk/esp32c3/include/json_parser/upstream/include/json_parser.h index 3e982fe14eb..8e92fe7d63f 100644 --- a/tools/sdk/esp32c3/include/json_parser/upstream/include/json_parser.h +++ b/tools/sdk/esp32c3/include/json_parser/upstream/include/json_parser.h @@ -16,6 +16,7 @@ #ifndef _JSON_PARSER_H_ #define _JSON_PARSER_H_ +#define JSMN_PARENT_LINKS #define JSMN_HEADER #include #include @@ -34,29 +35,31 @@ typedef jsmntok_t json_tok_t; typedef struct { json_parser_t parser; - char *js; + const char *js; json_tok_t *tokens; json_tok_t *cur; int num_tokens; } jparse_ctx_t; -int json_parse_start(jparse_ctx_t *jctx, char *js, int len); +int json_parse_start(jparse_ctx_t *jctx, const char *js, int len); int json_parse_end(jparse_ctx_t *jctx); +int json_parse_start_static(jparse_ctx_t *jctx, const char *js, int len, json_tok_t *buffer_tokens, int buffer_tokens_max_count); +int json_parse_end_static(jparse_ctx_t *jctx); -int json_obj_get_array(jparse_ctx_t *jctx, char *name, int *num_elem); +int json_obj_get_array(jparse_ctx_t *jctx, const char *name, int *num_elem); int json_obj_leave_array(jparse_ctx_t *jctx); -int json_obj_get_object(jparse_ctx_t *jctx, char *name); +int json_obj_get_object(jparse_ctx_t *jctx, const char *name); int json_obj_leave_object(jparse_ctx_t *jctx); -int json_obj_get_bool(jparse_ctx_t *jctx, char *name, bool *val); -int json_obj_get_int(jparse_ctx_t *jctx, char *name, int *val); -int json_obj_get_int64(jparse_ctx_t *jctx, char *name, int64_t *val); -int json_obj_get_float(jparse_ctx_t *jctx, char *name, float *val); -int json_obj_get_string(jparse_ctx_t *jctx, char *name, char *val, int size); -int json_obj_get_strlen(jparse_ctx_t *jctx, char *name, int *strlen); -int json_obj_get_object_str(jparse_ctx_t *jctx, char *name, char *val, int size); -int json_obj_get_object_strlen(jparse_ctx_t *jctx, char *name, int *strlen); -int json_obj_get_array_str(jparse_ctx_t *jctx, char *name, char *val, int size); -int json_obj_get_array_strlen(jparse_ctx_t *jctx, char *name, int *strlen); +int json_obj_get_bool(jparse_ctx_t *jctx, const char *name, bool *val); +int json_obj_get_int(jparse_ctx_t *jctx, const char *name, int *val); +int json_obj_get_int64(jparse_ctx_t *jctx, const char *name, int64_t *val); +int json_obj_get_float(jparse_ctx_t *jctx, const char *name, float *val); +int json_obj_get_string(jparse_ctx_t *jctx, const char *name, char *val, int size); +int json_obj_get_strlen(jparse_ctx_t *jctx, const char *name, int *strlen); +int json_obj_get_object_str(jparse_ctx_t *jctx, const char *name, char *val, int size); +int json_obj_get_object_strlen(jparse_ctx_t *jctx, const char *name, int *strlen); +int json_obj_get_array_str(jparse_ctx_t *jctx, const char *name, char *val, int size); +int json_obj_get_array_strlen(jparse_ctx_t *jctx, const char *name, int *strlen); int json_arr_get_array(jparse_ctx_t *jctx, uint32_t index); int json_arr_leave_array(jparse_ctx_t *jctx); @@ -74,3 +77,4 @@ int json_arr_get_strlen(jparse_ctx_t *jctx, uint32_t index, int *strlen); #endif #endif /* _JSON_PARSER_H_ */ + diff --git a/tools/sdk/esp32c3/include/lwip/lwip/src/include/lwip/dns.h b/tools/sdk/esp32c3/include/lwip/lwip/src/include/lwip/dns.h index db52fedd1da..7c9933eaa32 100644 --- a/tools/sdk/esp32c3/include/lwip/lwip/src/include/lwip/dns.h +++ b/tools/sdk/esp32c3/include/lwip/lwip/src/include/lwip/dns.h @@ -113,6 +113,7 @@ err_t dns_gethostbyname_addrtype(const char *hostname, ip_addr_t *add u8_t dns_addrtype); #if ESP_DNS void dns_clear_servers(bool keep_fallback); +void dns_clear_cache(void); #endif #if DNS_LOCAL_HOSTLIST diff --git a/tools/sdk/esp32c3/include/lwip/lwip/src/include/lwip/init.h b/tools/sdk/esp32c3/include/lwip/lwip/src/include/lwip/init.h index c7f3eb99cbb..921573618d7 100644 --- a/tools/sdk/esp32c3/include/lwip/lwip/src/include/lwip/init.h +++ b/tools/sdk/esp32c3/include/lwip/lwip/src/include/lwip/init.h @@ -54,7 +54,7 @@ extern "C" { /** x.X.x: Minor version of the stack */ #define LWIP_VERSION_MINOR 1 /** x.x.X: Revision of the stack */ -#define LWIP_VERSION_REVISION 3 +#define LWIP_VERSION_REVISION 2 /** For release candidates, this is set to 1..254 * For official releases, this is set to 255 (LWIP_RC_RELEASE) * For development versions (Git), this is set to 0 (LWIP_RC_DEVELOPMENT) */ @@ -75,7 +75,7 @@ extern "C" { #if LWIP_VERSION_IS_RELEASE #define LWIP_VERSION_STRING_SUFFIX "" #elif LWIP_VERSION_IS_DEVELOPMENT -#define LWIP_VERSION_STRING_SUFFIX "d" +#define LWIP_VERSION_STRING_SUFFIX "esp" #else #define LWIP_VERSION_STRING_SUFFIX "rc" LWIP_VERSTR(LWIP_VERSION_RC) #endif diff --git a/tools/sdk/esp32c3/include/lwip/lwip/src/include/lwip/opt.h b/tools/sdk/esp32c3/include/lwip/lwip/src/include/lwip/opt.h index cdd7044c728..b314c59a439 100644 --- a/tools/sdk/esp32c3/include/lwip/lwip/src/include/lwip/opt.h +++ b/tools/sdk/esp32c3/include/lwip/lwip/src/include/lwip/opt.h @@ -2534,10 +2534,12 @@ /** * LWIP_ICMP6_DATASIZE: bytes from original packet to send back in - * ICMPv6 error messages. + * ICMPv6 error messages (0 = default of IP6_MIN_MTU_LENGTH) + * ATTENTION: RFC4443 section 2.4 says IP6_MIN_MTU_LENGTH is a MUST, + * so override this only if you absolutely have to! */ #if !defined LWIP_ICMP6_DATASIZE || defined __DOXYGEN__ -#define LWIP_ICMP6_DATASIZE 8 +#define LWIP_ICMP6_DATASIZE 0 #endif /** diff --git a/tools/sdk/esp32c3/include/lwip/lwip/src/include/lwip/pbuf.h b/tools/sdk/esp32c3/include/lwip/lwip/src/include/lwip/pbuf.h index deac38dcc47..2eedb956ee8 100644 --- a/tools/sdk/esp32c3/include/lwip/lwip/src/include/lwip/pbuf.h +++ b/tools/sdk/esp32c3/include/lwip/lwip/src/include/lwip/pbuf.h @@ -300,6 +300,7 @@ void pbuf_cat(struct pbuf *head, struct pbuf *tail); void pbuf_chain(struct pbuf *head, struct pbuf *tail); struct pbuf *pbuf_dechain(struct pbuf *p); err_t pbuf_copy(struct pbuf *p_to, const struct pbuf *p_from); +err_t pbuf_copy_partial_pbuf(struct pbuf *p_to, const struct pbuf *p_from, u16_t copy_len, u16_t offset); u16_t pbuf_copy_partial(const struct pbuf *p, void *dataptr, u16_t len, u16_t offset); void *pbuf_get_contiguous(const struct pbuf *p, void *buffer, size_t bufsize, u16_t len, u16_t offset); err_t pbuf_take(struct pbuf *buf, const void *dataptr, u16_t len); diff --git a/tools/sdk/esp32c3/include/lwip/lwip/src/include/lwip/prot/icmp6.h b/tools/sdk/esp32c3/include/lwip/lwip/src/include/lwip/prot/icmp6.h index 3461120421e..36989f6b32a 100644 --- a/tools/sdk/esp32c3/include/lwip/lwip/src/include/lwip/prot/icmp6.h +++ b/tools/sdk/esp32c3/include/lwip/lwip/src/include/lwip/prot/icmp6.h @@ -146,6 +146,8 @@ PACK_STRUCT_END # include "arch/epstruct.h" #endif +#define ICMP6_HLEN 8 + /** This is the ICMP6 header adapted for echo req/resp. */ #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/bpstruct.h" diff --git a/tools/sdk/esp32c3/include/lwip/lwip/src/include/lwip/prot/ip6.h b/tools/sdk/esp32c3/include/lwip/lwip/src/include/lwip/prot/ip6.h index 0f6de455932..7df81edd690 100644 --- a/tools/sdk/esp32c3/include/lwip/lwip/src/include/lwip/prot/ip6.h +++ b/tools/sdk/esp32c3/include/lwip/lwip/src/include/lwip/prot/ip6.h @@ -44,6 +44,8 @@ extern "C" { #endif +#define IP6_MIN_MTU_LENGTH 1280 + /** This is the packed version of ip6_addr_t, used in network headers that are itself packed */ #ifdef PACK_STRUCT_USE_INCLUDES diff --git a/tools/sdk/esp32c3/include/lwip/port/esp32/include/lwipopts.h b/tools/sdk/esp32c3/include/lwip/port/esp32/include/lwipopts.h index 47215e99dae..bb0d371c6ee 100644 --- a/tools/sdk/esp32c3/include/lwip/port/esp32/include/lwipopts.h +++ b/tools/sdk/esp32c3/include/lwip/port/esp32/include/lwipopts.h @@ -1007,6 +1007,7 @@ #define ESP_LWIP_SELECT 1 #define ESP_LWIP_LOCK 1 #define ESP_THREAD_PROTECTION 1 +#define ESP_IP_FORWARD 1 #ifdef CONFIG_LWIP_IPV6_AUTOCONFIG #define ESP_IPV6_AUTOCONFIG CONFIG_LWIP_IPV6_AUTOCONFIG diff --git a/tools/sdk/esp32c3/include/mbedtls/esp_crt_bundle/include/esp_crt_bundle.h b/tools/sdk/esp32c3/include/mbedtls/esp_crt_bundle/include/esp_crt_bundle.h index 33fb98b9969..49069185b3a 100644 --- a/tools/sdk/esp32c3/include/mbedtls/esp_crt_bundle/include/esp_crt_bundle.h +++ b/tools/sdk/esp32c3/include/mbedtls/esp_crt_bundle/include/esp_crt_bundle.h @@ -1,21 +1,14 @@ -// 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. +/* + * SPDX-FileCopyrightText: 2017-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ESP_CRT_BUNDLE_H_ #define _ESP_CRT_BUNDLE_H_ +#include "esp_err.h" #include "mbedtls/ssl.h" #ifdef __cplusplus @@ -52,13 +45,19 @@ void esp_crt_bundle_detach(mbedtls_ssl_config *conf); /** * @brief Set the default certificate bundle used for verification * - * Overrides the default certificate bundle. In most use cases the bundle should be + * Overrides the default certificate bundle only in case of successful initialization. In most use cases the bundle should be * set through menuconfig. The bundle needs to be sorted by subject name since binary search is * used to find certificates. * * @param[in] x509_bundle A pointer to the certificate bundle. + * + * @param[in] bundle_size Size of the certificate bundle in bytes. + * + * @return + * - ESP_OK if adding certificates was successful. + * - Other if an error occured or an action must be taken by the calling process. */ -void esp_crt_bundle_set(const uint8_t *x509_bundle); +esp_err_t esp_crt_bundle_set(const uint8_t *x509_bundle, size_t bundle_size); #ifdef __cplusplus diff --git a/tools/sdk/esp32c3/include/mqtt/esp-mqtt/include/mqtt_client.h b/tools/sdk/esp32c3/include/mqtt/esp-mqtt/include/mqtt_client.h index 475581b50db..07feed3c370 100644 --- a/tools/sdk/esp32c3/include/mqtt/esp-mqtt/include/mqtt_client.h +++ b/tools/sdk/esp32c3/include/mqtt/esp-mqtt/include/mqtt_client.h @@ -39,7 +39,11 @@ typedef enum { MQTT_EVENT_ERROR = 0, /*!< on error event, additional context: connection return code, error handle from esp_tls (if supported) */ MQTT_EVENT_CONNECTED, /*!< connected event, additional context: session_present flag */ MQTT_EVENT_DISCONNECTED, /*!< disconnected event */ - MQTT_EVENT_SUBSCRIBED, /*!< subscribed event, additional context: msg_id */ + MQTT_EVENT_SUBSCRIBED, /*!< subscribed event, additional context: + - msg_id message id + - data pointer to the received data + - data_len length of the data for this event + */ MQTT_EVENT_UNSUBSCRIBED, /*!< unsubscribed event */ MQTT_EVENT_PUBLISHED, /*!< published event, additional context: msg_id */ MQTT_EVENT_DATA, /*!< data event, additional context: @@ -51,6 +55,8 @@ typedef enum { - current_data_offset offset of the current data for this event - total_data_len total length of the data received - retain retain flag of the message + - qos qos level of the message + - dup dup flag of the message Note: Multiple MQTT_EVENT_DATA could be fired for one message, if it is longer than internal buffer. In that case only first event contains topic pointer and length, other contain data only with current data length @@ -153,6 +159,8 @@ typedef struct { int session_present; /*!< MQTT session_present flag for connection event */ esp_mqtt_error_codes_t *error_handle; /*!< esp-mqtt error handle including esp-tls errors as well as internal mqtt errors */ bool retain; /*!< Retained flag of the message associated with this event */ + int qos; /*!< qos of the messages associated with this event */ + bool dup; /*!< dup flag of the message associated with this event */ } esp_mqtt_event_t; typedef esp_mqtt_event_t *esp_mqtt_event_handle_t; @@ -168,7 +176,11 @@ typedef struct { const char *host; /*!< MQTT server domain (ipv4 as string) */ const char *uri; /*!< Complete MQTT broker URI */ uint32_t port; /*!< MQTT server port */ - const char *client_id; /*!< default client id is ``ESP32_%CHIPID%`` where %CHIPID% are last 3 bytes of MAC address in hex format */ + bool set_null_client_id; /*!< Selects a NULL client id */ + const char *client_id; /*!< Set client id. + Ignored if set_null_client_id == true + If NULL set the default client id. + Default client id is ``ESP32_%CHIPID%`` where %CHIPID% are last 3 bytes of MAC address in hex format */ const char *username; /*!< MQTT username */ const char *password; /*!< MQTT password */ const char *lwt_topic; /*!< LWT (Last Will and Testament) message topic (NULL by default) */ diff --git a/tools/sdk/esp32c3/include/newlib/platform_include/errno.h b/tools/sdk/esp32c3/include/newlib/platform_include/errno.h index 85fb2e15b85..98dedeef88a 100644 --- a/tools/sdk/esp32c3/include/newlib/platform_include/errno.h +++ b/tools/sdk/esp32c3/include/newlib/platform_include/errno.h @@ -1,17 +1,9 @@ -// Copyright 2018 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. +/* + * SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ESP_PLATFORM_ERRNO_H_ #define _ESP_PLATFORM_ERRNO_H_ @@ -21,7 +13,7 @@ // Possibly define some missing errors // #ifndef ESHUTDOWN -#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ +#define ESHUTDOWN 110 /* Cannot send after transport endpoint shutdown */ #endif #ifndef EAI_SOCKTYPE diff --git a/tools/sdk/esp32c3/include/nvs_flash/include/nvs.h b/tools/sdk/esp32c3/include/nvs_flash/include/nvs.h index 6a45327bbae..0faef98fd3d 100644 --- a/tools/sdk/esp32c3/include/nvs_flash/include/nvs.h +++ b/tools/sdk/esp32c3/include/nvs_flash/include/nvs.h @@ -40,7 +40,7 @@ typedef nvs_handle_t nvs_handle IDF_DEPRECATED("Replace with nvs_handle_t"); #define ESP_ERR_NVS_INVALID_STATE (ESP_ERR_NVS_BASE + 0x0b) /*!< NVS is in an inconsistent state due to a previous error. Call nvs_flash_init and nvs_open again, then retry. */ #define ESP_ERR_NVS_INVALID_LENGTH (ESP_ERR_NVS_BASE + 0x0c) /*!< String or blob length is not sufficient to store data */ #define ESP_ERR_NVS_NO_FREE_PAGES (ESP_ERR_NVS_BASE + 0x0d) /*!< NVS partition doesn't contain any empty pages. This may happen if NVS partition was truncated. Erase the whole partition and call nvs_flash_init again. */ -#define ESP_ERR_NVS_VALUE_TOO_LONG (ESP_ERR_NVS_BASE + 0x0e) /*!< String or blob length is longer than supported by the implementation */ +#define ESP_ERR_NVS_VALUE_TOO_LONG (ESP_ERR_NVS_BASE + 0x0e) /*!< Value doesn't fit into the entry or string or blob length is longer than supported by the implementation */ #define ESP_ERR_NVS_PART_NOT_FOUND (ESP_ERR_NVS_BASE + 0x0f) /*!< Partition with specified name is not found in the partition table */ #define ESP_ERR_NVS_NEW_VERSION_FOUND (ESP_ERR_NVS_BASE + 0x10) /*!< NVS partition contains data in new format and cannot be recognized by this version of code */ @@ -124,6 +124,8 @@ typedef struct nvs_opaque_iterator_t *nvs_iterator_t; * * @return * - ESP_OK if storage handle was opened successfully + * - ESP_FAIL if there is an internal error; most likely due to corrupted + * NVS partition (only if NVS assertion checks are disabled) * - ESP_ERR_NVS_NOT_INITIALIZED if the storage driver is not initialized * - ESP_ERR_NVS_PART_NOT_FOUND if the partition with label "nvs" is not found * - ESP_ERR_NVS_NOT_FOUND id namespace doesn't exist yet and @@ -151,6 +153,8 @@ esp_err_t nvs_open(const char* name, nvs_open_mode_t open_mode, nvs_handle_t *ou * * @return * - ESP_OK if storage handle was opened successfully + * - ESP_FAIL if there is an internal error; most likely due to corrupted + * NVS partition (only if NVS assertion checks are disabled) * - ESP_ERR_NVS_NOT_INITIALIZED if the storage driver is not initialized * - ESP_ERR_NVS_PART_NOT_FOUND if the partition with specified name is not found * - ESP_ERR_NVS_NOT_FOUND id namespace doesn't exist yet and @@ -175,6 +179,8 @@ esp_err_t nvs_open_from_partition(const char *part_name, const char* name, nvs_o * * @return * - ESP_OK if value was set successfully + * - ESP_FAIL if there is an internal error; most likely due to corrupted + * NVS partition (only if NVS assertion checks are disabled) * - ESP_ERR_NVS_INVALID_HANDLE if handle has been closed or is NULL * - ESP_ERR_NVS_READ_ONLY if storage handle was opened as read only * - ESP_ERR_NVS_INVALID_NAME if key name doesn't satisfy constraints @@ -282,6 +288,8 @@ esp_err_t nvs_set_str (nvs_handle_t handle, const char* key, const char* value); * * @return * - ESP_OK if value was set successfully + * - ESP_FAIL if there is an internal error; most likely due to corrupted + * NVS partition (only if NVS assertion checks are disabled) * - ESP_ERR_NVS_INVALID_HANDLE if handle has been closed or is NULL * - ESP_ERR_NVS_READ_ONLY if storage handle was opened as read only * - ESP_ERR_NVS_INVALID_NAME if key name doesn't satisfy constraints @@ -325,6 +333,8 @@ esp_err_t nvs_set_blob(nvs_handle_t handle, const char* key, const void* value, * * @return * - ESP_OK if the value was retrieved successfully + * - ESP_FAIL if there is an internal error; most likely due to corrupted + * NVS partition (only if NVS assertion checks are disabled) * - ESP_ERR_NVS_NOT_FOUND if the requested key doesn't exist * - ESP_ERR_NVS_INVALID_HANDLE if handle has been closed or is NULL * - ESP_ERR_NVS_INVALID_NAME if key name doesn't satisfy constraints @@ -432,6 +442,8 @@ esp_err_t nvs_get_u64 (nvs_handle_t handle, const char* key, uint64_t* out_value * * @return * - ESP_OK if the value was retrieved successfully + * - ESP_FAIL if there is an internal error; most likely due to corrupted + * NVS partition (only if NVS assertion checks are disabled) * - ESP_ERR_NVS_NOT_FOUND if the requested key doesn't exist * - ESP_ERR_NVS_INVALID_HANDLE if handle has been closed or is NULL * - ESP_ERR_NVS_INVALID_NAME if key name doesn't satisfy constraints @@ -459,6 +471,8 @@ esp_err_t nvs_get_blob(nvs_handle_t handle, const char* key, void* out_value, si * * @return * - ESP_OK if erase operation was successful + * - ESP_FAIL if there is an internal error; most likely due to corrupted + * NVS partition (only if NVS assertion checks are disabled) * - ESP_ERR_NVS_INVALID_HANDLE if handle has been closed or is NULL * - ESP_ERR_NVS_READ_ONLY if handle was opened as read only * - ESP_ERR_NVS_NOT_FOUND if the requested key doesn't exist @@ -476,6 +490,8 @@ esp_err_t nvs_erase_key(nvs_handle_t handle, const char* key); * * @return * - ESP_OK if erase operation was successful + * - ESP_FAIL if there is an internal error; most likely due to corrupted + * NVS partition (only if NVS assertion checks are disabled) * - ESP_ERR_NVS_INVALID_HANDLE if handle has been closed or is NULL * - ESP_ERR_NVS_READ_ONLY if handle was opened as read only * - other error codes from the underlying storage driver diff --git a/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protobuf-c/protobuf-c.h b/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protobuf-c/protobuf-c.h index c8fa4fc2a7c..b633722ed5e 100755 --- a/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protobuf-c/protobuf-c.h +++ b/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protobuf-c/protobuf-c.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008-2017, Dave Benson and the protobuf-c authors. + * Copyright (c) 2008-2018, Dave Benson and the protobuf-c authors. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -238,7 +238,11 @@ PROTOBUF_C__BEGIN_DECLS #define PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC 0x114315af /* Empty string used for initializers */ +#if defined(_WIN32) && defined(PROTOBUF_C_USE_SHARED_LIB) +static const char protobuf_c_empty_string[] = ""; +#else extern const char protobuf_c_empty_string[]; +#endif /** * \defgroup api Public API @@ -790,13 +794,13 @@ protobuf_c_version_number(void); * The version of the protobuf-c headers, represented as a string using the same * format as protobuf_c_version(). */ -#define PROTOBUF_C_VERSION "1.3.0" +#define PROTOBUF_C_VERSION "1.4.0" /** * The version of the protobuf-c headers, represented as an integer using the * same format as protobuf_c_version_number(). */ -#define PROTOBUF_C_VERSION_NUMBER 1003000 +#define PROTOBUF_C_VERSION_NUMBER 1004000 /** * The minimum protoc-c version which works with the current version of the diff --git a/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_bytes_field.h b/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_bytes_field.h index c4a71e85b47..bf873f0f763 100644 --- a/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_bytes_field.h +++ b/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_bytes_field.h @@ -82,11 +82,11 @@ class BytesFieldGenerator : public FieldGenerator { void GenerateDescriptorInitializer(io::Printer* printer) const; void GenerateDefaultValueDeclarations(io::Printer* printer) const; void GenerateDefaultValueImplementations(io::Printer* printer) const; - string GetDefaultValue(void) const; + std::string GetDefaultValue(void) const; void GenerateStaticInit(io::Printer* printer) const; private: - std::map variables_; + std::map variables_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(BytesFieldGenerator); }; diff --git a/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_enum.h b/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_enum.h index 9eb9a6679ce..9c34b697b82 100644 --- a/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_enum.h +++ b/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_enum.h @@ -81,7 +81,7 @@ class EnumGenerator { public: // See generator.cc for the meaning of dllexport_decl. explicit EnumGenerator(const EnumDescriptor* descriptor, - const string& dllexport_decl); + const std::string& dllexport_decl); ~EnumGenerator(); // Header stuff. @@ -105,7 +105,7 @@ class EnumGenerator { private: const EnumDescriptor* descriptor_; - string dllexport_decl_; + std::string dllexport_decl_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumGenerator); }; diff --git a/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_enum_field.h b/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_enum_field.h index 11df6824693..3f8c005d320 100644 --- a/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_enum_field.h +++ b/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_enum_field.h @@ -80,11 +80,11 @@ class EnumFieldGenerator : public FieldGenerator { // implements FieldGenerator --------------------------------------- void GenerateStructMembers(io::Printer* printer) const; void GenerateDescriptorInitializer(io::Printer* printer) const; - string GetDefaultValue(void) const; + std::string GetDefaultValue(void) const; void GenerateStaticInit(io::Printer* printer) const; private: - std::map variables_; + std::map variables_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumFieldGenerator); }; diff --git a/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_extension.h b/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_extension.h index ddbf270e5a1..95413885342 100644 --- a/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_extension.h +++ b/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_extension.h @@ -85,7 +85,7 @@ class ExtensionGenerator { public: // See generator.cc for the meaning of dllexport_decl. explicit ExtensionGenerator(const FieldDescriptor* descriptor, - const string& dllexport_decl); + const std::string& dllexport_decl); ~ExtensionGenerator(); // Header stuff. @@ -96,8 +96,8 @@ class ExtensionGenerator { private: const FieldDescriptor* descriptor_; - string type_traits_; - string dllexport_decl_; + std::string type_traits_; + std::string dllexport_decl_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ExtensionGenerator); }; diff --git a/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_field.h b/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_field.h index 91f1a03dafb..3cad35d3979 100644 --- a/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_field.h +++ b/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_field.h @@ -63,6 +63,7 @@ #ifndef GOOGLE_PROTOBUF_COMPILER_C_FIELD_H__ #define GOOGLE_PROTOBUF_COMPILER_C_FIELD_H__ +#include #include #include @@ -90,7 +91,7 @@ class FieldGenerator { virtual void GenerateDefaultValueDeclarations(io::Printer* printer) const { } virtual void GenerateDefaultValueImplementations(io::Printer* printer) const { } - virtual string GetDefaultValue() const = 0; + virtual std::string GetDefaultValue() const = 0; // Generate members to initialize this field from a static initializer virtual void GenerateStaticInit(io::Printer* printer) const = 0; @@ -99,8 +100,8 @@ class FieldGenerator { protected: void GenerateDescriptorInitializerGeneric(io::Printer* printer, bool optional_uses_has, - const string &type_macro, - const string &descriptor_addr) const; + const std::string &type_macro, + const std::string &descriptor_addr) const; const FieldDescriptor *descriptor_; private: @@ -117,7 +118,7 @@ class FieldGeneratorMap { private: const Descriptor* descriptor_; - scoped_array > field_generators_; + std::unique_ptr[]> field_generators_; static FieldGenerator* MakeGenerator(const FieldDescriptor* field); diff --git a/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_file.h b/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_file.h index ed38ce425c3..8dfd8ba0984 100644 --- a/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_file.h +++ b/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_file.h @@ -63,6 +63,7 @@ #ifndef GOOGLE_PROTOBUF_COMPILER_C_FILE_H__ #define GOOGLE_PROTOBUF_COMPILER_C_FILE_H__ +#include #include #include #include @@ -89,7 +90,7 @@ class FileGenerator { public: // See generator.cc for the meaning of dllexport_decl. explicit FileGenerator(const FileDescriptor* file, - const string& dllexport_decl); + const std::string& dllexport_decl); ~FileGenerator(); void GenerateHeader(io::Printer* printer); @@ -98,13 +99,10 @@ class FileGenerator { private: const FileDescriptor* file_; - scoped_array > message_generators_; - scoped_array > enum_generators_; - scoped_array > service_generators_; - scoped_array > extension_generators_; - - // E.g. if the package is foo.bar, package_parts_ is {"foo", "bar"}. - vector package_parts_; + std::unique_ptr[]> message_generators_; + std::unique_ptr[]> enum_generators_; + std::unique_ptr[]> service_generators_; + std::unique_ptr[]> extension_generators_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileGenerator); }; diff --git a/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_generator.h b/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_generator.h index f454710b36f..ac1ffafeab3 100644 --- a/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_generator.h +++ b/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_generator.h @@ -68,6 +68,12 @@ #include #include +#if defined(_WIN32) && defined(PROTOBUF_C_USE_SHARED_LIB) +# define PROTOC_C_EXPORT __declspec(dllexport) +#else +# define PROTOC_C_EXPORT +#endif + namespace google { namespace protobuf { namespace compiler { @@ -77,16 +83,16 @@ namespace c { // header. If you create your own protocol compiler binary and you want // it to support C++ output, you can do so by registering an instance of this // CodeGenerator with the CommandLineInterface in your main() function. -class LIBPROTOC_EXPORT CGenerator : public CodeGenerator { +class PROTOC_C_EXPORT CGenerator : public CodeGenerator { public: CGenerator(); ~CGenerator(); // implements CodeGenerator ---------------------------------------- bool Generate(const FileDescriptor* file, - const string& parameter, + const std::string& parameter, OutputDirectory* output_directory, - string* error) const; + std::string* error) const; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CGenerator); diff --git a/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_helpers.h b/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_helpers.h index 9dc8c5e859c..7598a4e1da5 100644 --- a/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_helpers.h +++ b/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_helpers.h @@ -67,7 +67,7 @@ #include #include #include -#include +#include #include namespace google { @@ -75,31 +75,20 @@ namespace protobuf { namespace compiler { namespace c { -// Returns the non-nested type name for the given type. If "qualified" is -// true, prefix the type with the full namespace. For example, if you had: -// package foo.bar; -// message Baz { message Qux {} } -// Then the qualified ClassName for Qux would be: -// Foo__Bar__Baz_Qux -// While the non-qualified version would be: -// Baz_Qux -string ClassName(const Descriptor* descriptor, bool qualified); -string ClassName(const EnumDescriptor* enum_descriptor, bool qualified); - // --- Borrowed from stubs. --- -template string SimpleItoa(T n) { +template std::string SimpleItoa(T n) { std::stringstream stream; stream << n; return stream.str(); } -string SimpleFtoa(float f); -string SimpleDtoa(double f); -void SplitStringUsing(const string &str, const char *delim, std::vector *out); -string CEscape(const string& src); -string StringReplace(const string& s, const string& oldsub, const string& newsub, bool replace_all); -inline bool HasSuffixString(const string& str, const string& suffix) { return str.size() >= suffix.size() && str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0; } -inline string StripSuffixString(const string& str, const string& suffix) { if (HasSuffixString(str, suffix)) { return str.substr(0, str.size() - suffix.size()); } else { return str; } } +std::string SimpleFtoa(float f); +std::string SimpleDtoa(double f); +void SplitStringUsing(const std::string &str, const char *delim, std::vector *out); +std::string CEscape(const std::string& src); +std::string StringReplace(const std::string& s, const std::string& oldsub, const std::string& newsub, bool replace_all); +inline bool HasSuffixString(const std::string& str, const std::string& suffix) { return str.size() >= suffix.size() && str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0; } +inline std::string StripSuffixString(const std::string& str, const std::string& suffix) { if (HasSuffixString(str, suffix)) { return str.substr(0, str.size() - suffix.size()); } else { return str; } } char* FastHexToBuffer(int i, char* buffer); @@ -107,10 +96,10 @@ char* FastHexToBuffer(int i, char* buffer); // The name is coerced to lower-case to emulate proto1 behavior. People // should be using lowercase-with-underscores style for proto field names // anyway, so normally this just returns field->name(). -string FieldName(const FieldDescriptor* field); +std::string FieldName(const FieldDescriptor* field); // Get macro string for deprecated field -string FieldDeprecated(const FieldDescriptor* field); +std::string FieldDeprecated(const FieldDescriptor* field); // Returns the scope where the field was defined (for extensions, this is // different from the message type to which the field applies). @@ -121,31 +110,31 @@ inline const Descriptor* FieldScope(const FieldDescriptor* field) { // convert a CamelCase class name into an all uppercase affair // with underscores separating words, e.g. MyClass becomes MY_CLASS. -string CamelToUpper(const string &class_name); -string CamelToLower(const string &class_name); +std::string CamelToUpper(const std::string &class_name); +std::string CamelToLower(const std::string &class_name); // lowercased, underscored name to camel case -string ToCamel(const string &name); +std::string ToCamel(const std::string &name); // lowercase the string -string ToLower(const string &class_name); -string ToUpper(const string &class_name); +std::string ToLower(const std::string &class_name); +std::string ToUpper(const std::string &class_name); // full_name() to lowercase with underscores -string FullNameToLower(const string &full_name); -string FullNameToUpper(const string &full_name); +std::string FullNameToLower(const std::string &full_name, const FileDescriptor *file); +std::string FullNameToUpper(const std::string &full_name, const FileDescriptor *file); // full_name() to c-typename (with underscores for packages, otherwise camel case) -string FullNameToC(const string &class_name); +std::string FullNameToC(const std::string &class_name, const FileDescriptor *file); // Splits, indents, formats, and prints comment lines -void PrintComment (io::Printer* printer, string comment); +void PrintComment (io::Printer* printer, std::string comment); // make a string of spaces as long as input -string ConvertToSpaces(const string &input); +std::string ConvertToSpaces(const std::string &input); // Strips ".proto" or ".protodevel" from the end of a filename. -string StripProto(const string& filename); +std::string StripProto(const std::string& filename); // Get the C++ type name for a primitive type (e.g. "double", "::google::protobuf::int32", etc.). // Note: non-built-in type names will be qualified, meaning they will start @@ -159,18 +148,18 @@ const char* PrimitiveTypeName(FieldDescriptor::CppType type); const char* DeclaredTypeMethodName(FieldDescriptor::Type type); // Convert a file name into a valid identifier. -string FilenameIdentifier(const string& filename); +std::string FilenameIdentifier(const std::string& filename); // Return the name of the BuildDescriptors() function for a given file. -string GlobalBuildDescriptorsName(const string& filename); +std::string GlobalBuildDescriptorsName(const std::string& filename); // return 'required', 'optional', or 'repeated' -string GetLabelName(FieldDescriptor::Label label); +std::string GetLabelName(FieldDescriptor::Label label); // write IntRanges entries for a bunch of sorted values. // returns the number of ranges there are to bsearch. -unsigned WriteIntRanges(io::Printer* printer, int n_values, const int *values, const string &name); +unsigned WriteIntRanges(io::Printer* printer, int n_values, const int *values, const std::string &name); struct NameIndex { diff --git a/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_message.h b/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_message.h index 8b115d1c8cb..ea1c3ab3c8e 100644 --- a/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_message.h +++ b/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_message.h @@ -63,6 +63,7 @@ #ifndef GOOGLE_PROTOBUF_COMPILER_C_MESSAGE_H__ #define GOOGLE_PROTOBUF_COMPILER_C_MESSAGE_H__ +#include #include #include #include @@ -85,7 +86,7 @@ class MessageGenerator { public: // See generator.cc for the meaning of dllexport_decl. explicit MessageGenerator(const Descriptor* descriptor, - const string& dllexport_decl); + const std::string& dllexport_decl); ~MessageGenerator(); // Header stuff. @@ -110,25 +111,31 @@ class MessageGenerator { void GenerateStructStaticInitMacro(io::Printer* printer); // Generate standard helper functions declarations for this message. - void GenerateHelperFunctionDeclarations(io::Printer* printer, bool is_submessage); + void GenerateHelperFunctionDeclarations(io::Printer* printer, + bool is_pack_deep, + bool gen_pack, + bool gen_init); // Source file stuff. // Generate code that initializes the global variable storing the message's // descriptor. - void GenerateMessageDescriptor(io::Printer* printer); - void GenerateHelperFunctionDefinitions(io::Printer* printer, bool is_submessage); + void GenerateMessageDescriptor(io::Printer* printer, bool gen_init); + void GenerateHelperFunctionDefinitions(io::Printer* printer, + bool is_pack_deep, + bool gen_pack, + bool gen_init); private: - string GetDefaultValueC(const FieldDescriptor *fd); + std::string GetDefaultValueC(const FieldDescriptor *fd); const Descriptor* descriptor_; - string dllexport_decl_; + std::string dllexport_decl_; FieldGeneratorMap field_generators_; - scoped_array > nested_generators_; - scoped_array > enum_generators_; - scoped_array > extension_generators_; + std::unique_ptr[]> nested_generators_; + std::unique_ptr[]> enum_generators_; + std::unique_ptr[]> extension_generators_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageGenerator); }; diff --git a/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_message_field.h b/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_message_field.h index b059fb031b0..39b8d999bfa 100644 --- a/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_message_field.h +++ b/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_message_field.h @@ -80,7 +80,7 @@ class MessageFieldGenerator : public FieldGenerator { // implements FieldGenerator --------------------------------------- void GenerateStructMembers(io::Printer* printer) const; void GenerateDescriptorInitializer(io::Printer* printer) const; - string GetDefaultValue(void) const; + std::string GetDefaultValue(void) const; void GenerateStaticInit(io::Printer* printer) const; private: diff --git a/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_primitive_field.h b/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_primitive_field.h index 5ff254c5dd8..a9eb893bb72 100644 --- a/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_primitive_field.h +++ b/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_primitive_field.h @@ -80,7 +80,7 @@ class PrimitiveFieldGenerator : public FieldGenerator { // implements FieldGenerator --------------------------------------- void GenerateStructMembers(io::Printer* printer) const; void GenerateDescriptorInitializer(io::Printer* printer) const; - string GetDefaultValue(void) const; + std::string GetDefaultValue(void) const; void GenerateStaticInit(io::Printer* printer) const; private: diff --git a/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_service.h b/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_service.h index 6f1798ca724..27125a601a5 100644 --- a/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_service.h +++ b/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_service.h @@ -82,7 +82,7 @@ class ServiceGenerator { public: // See generator.cc for the meaning of dllexport_decl. explicit ServiceGenerator(const ServiceDescriptor* descriptor, - const string& dllexport_decl); + const std::string& dllexport_decl); ~ServiceGenerator(); // Header stuff. @@ -99,7 +99,7 @@ class ServiceGenerator { void GenerateCallersImplementations(io::Printer* printer); const ServiceDescriptor* descriptor_; - std::map vars_; + std::map vars_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ServiceGenerator); }; diff --git a/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_string_field.h b/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_string_field.h index 68f0d25b7dd..513cea75306 100644 --- a/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_string_field.h +++ b/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/protoc-c/c_string_field.h @@ -82,11 +82,11 @@ class StringFieldGenerator : public FieldGenerator { void GenerateDescriptorInitializer(io::Printer* printer) const; void GenerateDefaultValueDeclarations(io::Printer* printer) const; void GenerateDefaultValueImplementations(io::Printer* printer) const; - string GetDefaultValue(void) const; + std::string GetDefaultValue(void) const; void GenerateStaticInit(io::Printer* printer) const; private: - std::map variables_; + std::map variables_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StringFieldGenerator); }; diff --git a/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/t/generated-code2/common-test-arrays.h b/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/t/generated-code2/common-test-arrays.h index 1535d38e821..c5e37223c1a 100644 --- a/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/t/generated-code2/common-test-arrays.h +++ b/tools/sdk/esp32c3/include/protobuf-c/protobuf-c/t/generated-code2/common-test-arrays.h @@ -56,7 +56,7 @@ TEST_ENUM_TYPE_NAME enum_random[] = { T(0), T(2097152), T(268435455), T(127), T(16383), T(16384) }; #undef T -char *repeated_strings_0[] = { (char*)"onestring" }; -char *repeated_strings_1[] = { (char*)"two", (char*)"string" }; -char *repeated_strings_2[] = { (char*)"many", (char*)"tiny", (char*)"little", (char*)"strings", (char*)"should", (char*)"be", (char*)"handled" }; -char *repeated_strings_3[] = { (char*)"one very long strings XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" }; +const char *repeated_strings_0[] = { "onestring" }; +const char *repeated_strings_1[] = { "two", "string" }; +const char *repeated_strings_2[] = { "many", "tiny", "little", "strings", "should", "be", "handled" }; +const char *repeated_strings_3[] = { "one very long strings XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" }; diff --git a/tools/sdk/esp32c3/include/protocomm/include/transports/protocomm_ble.h b/tools/sdk/esp32c3/include/protocomm/include/transports/protocomm_ble.h index f899f95b188..2447c1c5d25 100644 --- a/tools/sdk/esp32c3/include/protocomm/include/transports/protocomm_ble.h +++ b/tools/sdk/esp32c3/include/protocomm/include/transports/protocomm_ble.h @@ -82,6 +82,9 @@ typedef struct protocomm_ble_config { /* BLE bonding */ unsigned ble_bonding:1; + /* BLE security flag */ + unsigned ble_sm_sc:1; + } protocomm_ble_config_t; /** diff --git a/tools/sdk/esp32c3/include/riscv/include/riscv/semihosting.h b/tools/sdk/esp32c3/include/riscv/include/riscv/semihosting.h new file mode 100644 index 00000000000..5330161d72f --- /dev/null +++ b/tools/sdk/esp32c3/include/riscv/include/riscv/semihosting.h @@ -0,0 +1,90 @@ +/* + * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + + +/* ESP custom semihosting calls numbers */ + +/** + * @brief Initialize apptrace data at host side + * + * @param addr address of apptrace control data block + * @return return 0 on sucess or non-zero error code + */ +#define ESP_SEMIHOSTING_SYS_APPTRACE_INIT 0x101 + +/** + * @brief Initialize debug stubs table at host side + * + * @param addr address of debug stubs table + * @return return 0 on sucess or non-zero error code + */ +#define ESP_SEMIHOSTING_SYS_DBG_STUBS_INIT 0x102 + +/** + * @brief Set/clear breakpoint + * + * @param set if true set breakpoint, otherwise clear it + * @param id breakpoint ID + * @param addr address to set breakpoint at. Ignored if `set` is false. + * @return return 0 on sucess or non-zero error code + */ +#define ESP_SEMIHOSTING_SYS_BREAKPOINT_SET 0x103 + +/** + * @brief Set/clear watchpoint + * + * @param set if true set watchpoint, otherwise clear it + * @param id watchpoint ID + * @param addr address to set watchpoint at. Ignored if `set` is false. + * @param size size of watchpoint. Ignored if `set` is false. + * @param flags watchpoint flags, see description below. Ignored if `set` is false. + * @return return 0 on sucess or non-zero error code + */ +#define ESP_SEMIHOSTING_SYS_WATCHPOINT_SET 0x104 + +/* bit values for `flags` argument of ESP_SEMIHOSTING_SYS_WATCHPOINT_SET call. Can be ORed. */ +/* watch for 'reads' at `addr` */ +#define ESP_SEMIHOSTING_WP_FLG_RD (1UL << 0) +/* watch for 'writes' at `addr` */ +#define ESP_SEMIHOSTING_WP_FLG_WR (1UL << 1) + +/** + * @brief Perform semihosting call + * + * See https://github.com/riscv/riscv-semihosting-spec/ and the linked + * ARM semihosting spec for details. + * + * @param id semihosting call number + * @param data data block to pass to the host; number of items and their + * meaning depends on the semihosting call. See the spec for + * details. + * + * @return return value from the host + */ +static inline long semihosting_call_noerrno(long id, long *data) +{ + register long a0 asm ("a0") = id; + register long a1 asm ("a1") = (long) data; + __asm__ __volatile__ ( + ".option push\n" + ".option norvc\n" + "slli zero, zero, 0x1f\n" + "ebreak\n" + "srai zero, zero, 0x7\n" + ".option pop\n" + : "+r"(a0) : "r"(a1) : "memory"); + return a0; +} + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32c3/include/rmaker_common/include/esp_rmaker_mqtt_glue.h b/tools/sdk/esp32c3/include/rmaker_common/include/esp_rmaker_mqtt_glue.h index 95744bdf58c..9355d034ef4 100644 --- a/tools/sdk/esp32c3/include/rmaker_common/include/esp_rmaker_mqtt_glue.h +++ b/tools/sdk/esp32c3/include/rmaker_common/include/esp_rmaker_mqtt_glue.h @@ -155,6 +155,12 @@ typedef struct { */ esp_err_t esp_rmaker_mqtt_glue_setup(esp_rmaker_mqtt_config_t *mqtt_config); +/* Get the ESP AWS PPI String + * + * @return pointer to a NULL terminated PPI string on success. + * @return NULL in case of any error. + */ +const char *esp_get_aws_ppi(void); #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/efuse_reg.h b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/efuse_reg.h index 0ec191f4381..2522821041e 100644 --- a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/efuse_reg.h +++ b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/efuse_reg.h @@ -256,11 +256,17 @@ extern "C" { #define EFUSE_KEY_PURPOSE_2_S 0 #define EFUSE_PGM_DATA4_REG (DR_REG_EFUSE_BASE + 0x010) -/* EFUSE_RPT4_RESERVED1 : RO ;bitpos:[31:30] ;default: 2'h0 ; */ +/* EFUSE_ERR_RST_ENABLE : RO ;bitpos:[31] ;default: 1'h0 ; */ +/*description: Use BLOCK0 to check error record registers, 0 - without check.*/ +#define EFUSE_ERR_RST_ENABLE (BIT(31)) +#define EFUSE_ERR_RST_ENABLE_M (BIT(31)) +#define EFUSE_ERR_RST_ENABLE_V 0x1 +#define EFUSE_ERR_RST_ENABLE_S 31 +/* EFUSE_RPT4_RESERVED1 : RO ;bitpos:[30] ;default: 1'h0 ; */ /*description: Reserved (used for four backups method).*/ -#define EFUSE_RPT4_RESERVED1 0x00000003 -#define EFUSE_RPT4_RESERVED1_M ((EFUSE_RPT4_RESERVED1_V)<<(EFUSE_RPT4_RESERVED1_S)) -#define EFUSE_RPT4_RESERVED1_V 0x3 +#define EFUSE_RPT4_RESERVED1 (BIT(30)) +#define EFUSE_RPT4_RESERVED1_M (BIT(30)) +#define EFUSE_RPT4_RESERVED1_V 0x1 #define EFUSE_RPT4_RESERVED1_S 30 /* EFUSE_SECURE_VERSION : R/W ;bitpos:[29:14] ;default: 16'h0 ; */ /*description: Secure version (used by ESP-IDF anti-rollback feature).*/ @@ -293,30 +299,30 @@ extern "C" { #define EFUSE_ENABLE_SECURITY_DOWNLOAD_M (BIT(5)) #define EFUSE_ENABLE_SECURITY_DOWNLOAD_V 0x1 #define EFUSE_ENABLE_SECURITY_DOWNLOAD_S 5 -/* EFUSE_DIS_USB_DOWNLOAD_MODE : R/W ;bitpos:[4] ;default: 1'b0 ; */ -/*description: Set this bit to disable UART download mode through USB.*/ -#define EFUSE_DIS_USB_DOWNLOAD_MODE (BIT(4)) -#define EFUSE_DIS_USB_DOWNLOAD_MODE_M (BIT(4)) -#define EFUSE_DIS_USB_DOWNLOAD_MODE_V 0x1 -#define EFUSE_DIS_USB_DOWNLOAD_MODE_S 4 +/* EFUSE_DIS_USB_SERIAL_JTAG_DOWNLOAD_MODE : R/W ;bitpos:[4] ;default: 1'b0 ; */ +/*description: Set this bit to disable download through USB-Serial-JTAG.*/ +#define EFUSE_DIS_USB_SERIAL_JTAG_DOWNLOAD_MODE (BIT(4)) +#define EFUSE_DIS_USB_SERIAL_JTAG_DOWNLOAD_MODE_M (BIT(4)) +#define EFUSE_DIS_USB_SERIAL_JTAG_DOWNLOAD_MODE_V 0x1 +#define EFUSE_DIS_USB_SERIAL_JTAG_DOWNLOAD_MODE_S 4 /* EFUSE_RPT4_RESERVED8 : R/W ;bitpos:[3] ;default: 1'b0 ; */ /*description: Reserved (used for four backups method).*/ #define EFUSE_RPT4_RESERVED8 (BIT(3)) #define EFUSE_RPT4_RESERVED8_M (BIT(3)) #define EFUSE_RPT4_RESERVED8_V 0x1 #define EFUSE_RPT4_RESERVED8_S 3 -/* EFUSE_UART_PRINT_CHANNEL : R/W ;bitpos:[2] ;default: 1'b0 ; */ -/*description: Selectes the default UART print channel. 0: UART0. 1: UART1.*/ -#define EFUSE_UART_PRINT_CHANNEL (BIT(2)) -#define EFUSE_UART_PRINT_CHANNEL_M (BIT(2)) -#define EFUSE_UART_PRINT_CHANNEL_V 0x1 -#define EFUSE_UART_PRINT_CHANNEL_S 2 -/* EFUSE_DIS_LEGACY_SPI_BOOT : R/W ;bitpos:[1] ;default: 1'b0 ; */ -/*description: Set this bit to disable Legacy SPI boot mode (boot_mode[3:0] = 4).*/ -#define EFUSE_DIS_LEGACY_SPI_BOOT (BIT(1)) -#define EFUSE_DIS_LEGACY_SPI_BOOT_M (BIT(1)) -#define EFUSE_DIS_LEGACY_SPI_BOOT_V 0x1 -#define EFUSE_DIS_LEGACY_SPI_BOOT_S 1 +/* EFUSE_DIS_USB_SERIAL_JTAG_ROM_PRINT : R/W ;bitpos:[2] ;default: 1'b0 ; */ +/*description: Disable USB-Serial-JTAG print during rom boot.*/ +#define EFUSE_DIS_USB_SERIAL_JTAG_ROM_PRINT (BIT(2)) +#define EFUSE_DIS_USB_SERIAL_JTAG_ROM_PRINT_M (BIT(2)) +#define EFUSE_DIS_USB_SERIAL_JTAG_ROM_PRINT_V 0x1 +#define EFUSE_DIS_USB_SERIAL_JTAG_ROM_PRINT_S 2 +/* EFUSE_DIS_DIRECT_BOOT : R/W ;bitpos:[1] ;default: 1'b0 ; */ +/*description: Set this bit to disable direct boot*/ +#define EFUSE_DIS_DIRECT_BOOT (BIT(1)) +#define EFUSE_DIS_DIRECT_BOOT_M (BIT(1)) +#define EFUSE_DIS_DIRECT_BOOT_V 0x1 +#define EFUSE_DIS_DIRECT_BOOT_S 1 /* EFUSE_DIS_DOWNLOAD_MODE : R/W ;bitpos:[0] ;default: 1'b0 ; */ /*description: Set this bit to disable download mode (boot_mode[3:0] = 0 1 2 3 6 7).*/ #define EFUSE_DIS_DOWNLOAD_MODE (BIT(0)) @@ -609,11 +615,17 @@ extern "C" { #define EFUSE_KEY_PURPOSE_2_S 0 #define EFUSE_RD_REPEAT_DATA3_REG (DR_REG_EFUSE_BASE + 0x03C) -/* EFUSE_RPT4_RESERVED1 : RO ;bitpos:[31:30] ;default: 2'h0 ; */ +/* EFUSE_ERR_RST_ENABLE : RO ;bitpos:[31] ;default: 1'h0 ; */ +/*description: Use BLOCK0 to check error record registers, 0 - without check.*/ +#define EFUSE_ERR_RST_ENABLE (BIT(31)) +#define EFUSE_ERR_RST_ENABLE_M (BIT(31)) +#define EFUSE_ERR_RST_ENABLE_V 0x1 +#define EFUSE_ERR_RST_ENABLE_S 31 +/* EFUSE_RPT4_RESERVED1 : RO ;bitpos:[30] ;default: 1'h0 ; */ /*description: Reserved.*/ -#define EFUSE_RPT4_RESERVED1 0x00000003 -#define EFUSE_RPT4_RESERVED1_M ((EFUSE_RPT4_RESERVED1_V)<<(EFUSE_RPT4_RESERVED1_S)) -#define EFUSE_RPT4_RESERVED1_V 0x3 +#define EFUSE_RPT4_RESERVED1 (BIT(30)) +#define EFUSE_RPT4_RESERVED1_M (BIT(30)) +#define EFUSE_RPT4_RESERVED1_V 0x1 #define EFUSE_RPT4_RESERVED1_S 30 /* EFUSE_SECURE_VERSION : RO ;bitpos:[29:14] ;default: 16'h0 ; */ /*description: The value of SECURE_VERSION.*/ @@ -645,30 +657,30 @@ extern "C" { #define EFUSE_ENABLE_SECURITY_DOWNLOAD_M (BIT(5)) #define EFUSE_ENABLE_SECURITY_DOWNLOAD_V 0x1 #define EFUSE_ENABLE_SECURITY_DOWNLOAD_S 5 -/* EFUSE_DIS_USB_DOWNLOAD_MODE : RO ;bitpos:[4] ;default: 1'b0 ; */ -/*description: The value of DIS_USB_DOWNLOAD_MODE.*/ -#define EFUSE_DIS_USB_DOWNLOAD_MODE (BIT(4)) -#define EFUSE_DIS_USB_DOWNLOAD_MODE_M (BIT(4)) -#define EFUSE_DIS_USB_DOWNLOAD_MODE_V 0x1 -#define EFUSE_DIS_USB_DOWNLOAD_MODE_S 4 +/* EFUSE_DIS_USB_SERIAL_JTAG_DOWNLOAD_MODE : RO ;bitpos:[4] ;default: 1'b0 ; */ +/*description: The value of DIS_USB_SERIAL_JTAG_DOWNLOAD_MODE.*/ +#define EFUSE_DIS_USB_SERIAL_JTAG_DOWNLOAD_MODE (BIT(4)) +#define EFUSE_DIS_USB_SERIAL_JTAG_DOWNLOAD_MODE_M (BIT(4)) +#define EFUSE_DIS_USB_SERIAL_JTAG_DOWNLOAD_MODE_V 0x1 +#define EFUSE_DIS_USB_SERIAL_JTAG_DOWNLOAD_MODE_S 4 /* EFUSE_RPT4_RESERVED8 : RO ;bitpos:[3] ;default: 1'b0 ; */ /*description: Reserved.*/ #define EFUSE_RPT4_RESERVED8 (BIT(3)) #define EFUSE_RPT4_RESERVED8_M (BIT(3)) #define EFUSE_RPT4_RESERVED8_V 0x1 #define EFUSE_RPT4_RESERVED8_S 3 -/* EFUSE_UART_PRINT_CHANNEL : RO ;bitpos:[2] ;default: 1'b0 ; */ -/*description: The value of UART_PRINT_CHANNEL.*/ -#define EFUSE_UART_PRINT_CHANNEL (BIT(2)) -#define EFUSE_UART_PRINT_CHANNEL_M (BIT(2)) -#define EFUSE_UART_PRINT_CHANNEL_V 0x1 -#define EFUSE_UART_PRINT_CHANNEL_S 2 -/* EFUSE_DIS_LEGACY_SPI_BOOT : RO ;bitpos:[1] ;default: 1'b0 ; */ -/*description: The value of DIS_LEGACY_SPI_BOOT.*/ -#define EFUSE_DIS_LEGACY_SPI_BOOT (BIT(1)) -#define EFUSE_DIS_LEGACY_SPI_BOOT_M (BIT(1)) -#define EFUSE_DIS_LEGACY_SPI_BOOT_V 0x1 -#define EFUSE_DIS_LEGACY_SPI_BOOT_S 1 +/* EFUSE_DIS_USB_SERIAL_JTAG_ROM_PRINT : RO ;bitpos:[2] ;default: 1'b0 ; */ +/*description: The value of DIS_USB_SERIAL_JTAG_ROM_PRINT.*/ +#define EFUSE_DIS_USB_SERIAL_JTAG_ROM_PRINT (BIT(2)) +#define EFUSE_DIS_USB_SERIAL_JTAG_ROM_PRINT_M (BIT(2)) +#define EFUSE_DIS_USB_SERIAL_JTAG_ROM_PRINT_V 0x1 +#define EFUSE_DIS_USB_SERIAL_JTAG_ROM_PRINT_S 2 +/* EFUSE_DIS_DIRECT_BOOT : RO ;bitpos:[1] ;default: 1'b0 ; */ +/*description: The value of DIS_DIRECT_BOOT.*/ +#define EFUSE_DIS_DIRECT_BOOT (BIT(1)) +#define EFUSE_DIS_DIRECT_BOOT_M (BIT(1)) +#define EFUSE_DIS_DIRECT_BOOT_V 0x1 +#define EFUSE_DIS_DIRECT_BOOT_S 1 /* EFUSE_DIS_DOWNLOAD_MODE : RO ;bitpos:[0] ;default: 1'b0 ; */ /*description: The value of DIS_DOWNLOAD_MODE.*/ #define EFUSE_DIS_DOWNLOAD_MODE (BIT(0)) @@ -1423,12 +1435,12 @@ extern "C" { #define EFUSE_DIS_USB_DEVICE_ERR_M (BIT(11)) #define EFUSE_DIS_USB_DEVICE_ERR_V 0x1 #define EFUSE_DIS_USB_DEVICE_ERR_S 11 -/* EFUSE_DIS_DOWNLOAD_ICACHE : RO ;bitpos:[10] ;default: 1'b0 ; */ +/* EFUSE_DIS_DOWNLOAD_ICACHE_ERR : RO ;bitpos:[10] ;default: 1'b0 ; */ /*description: If DIS_DOWNLOAD_ICACHE is 1 then it indicates a programming error.*/ -#define EFUSE_DIS_DOWNLOAD_ICACHE (BIT(10)) -#define EFUSE_DIS_DOWNLOAD_ICACHE_M (BIT(10)) -#define EFUSE_DIS_DOWNLOAD_ICACHE_V 0x1 -#define EFUSE_DIS_DOWNLOAD_ICACHE_S 10 +#define EFUSE_DIS_DOWNLOAD_ICACHE_ERR (BIT(10)) +#define EFUSE_DIS_DOWNLOAD_ICACHE_ERR_M (BIT(10)) +#define EFUSE_DIS_DOWNLOAD_ICACHE_ERR_V 0x1 +#define EFUSE_DIS_DOWNLOAD_ICACHE_ERR_S 10 /* EFUSE_DIS_USB_JTAG_ERR : RO ;bitpos:[9] ;default: 1'b0 ; */ /*description: If DIS_USB_JTAG is 1 then it indicates a programming error.*/ #define EFUSE_DIS_USB_JTAG_ERR (BIT(9)) @@ -1561,11 +1573,17 @@ extern "C" { #define EFUSE_KEY_PURPOSE_2_ERR_S 0 #define EFUSE_RD_REPEAT_ERR3_REG (DR_REG_EFUSE_BASE + 0x188) -/* EFUSE_RPT4_RESERVED1_ERR : RO ;bitpos:[31:30] ;default: 2'h0 ; */ +/* EFUSE_ERR_RST_ENABLE_ERR : RO ;bitpos:[31] ;default: 1'h0 ; */ +/*description: Use BLOCK0 to check error record registers, 0 - without check.*/ +#define EFUSE_ERR_RST_ENABLE_ERR (BIT(31)) +#define EFUSE_ERR_RST_ENABLE_ERR_M (BIT(31)) +#define EFUSE_ERR_RST_ENABLE_ERR_V 0x1 +#define EFUSE_ERR_RST_ENABLE_ERR_S 31 +/* EFUSE_RPT4_RESERVED1_ERR : RO ;bitpos:[30] ;default: 1'h0 ; */ /*description: Reserved.*/ -#define EFUSE_RPT4_RESERVED1_ERR 0x00000003 -#define EFUSE_RPT4_RESERVED1_ERR_M ((EFUSE_RPT4_RESERVED1_ERR_V)<<(EFUSE_RPT4_RESERVED1_ERR_S)) -#define EFUSE_RPT4_RESERVED1_ERR_V 0x3 +#define EFUSE_RPT4_RESERVED1_ERR (BIT(30)) +#define EFUSE_RPT4_RESERVED1_ERR_M (BIT(30)) +#define EFUSE_RPT4_RESERVED1_ERR_V 0x1 #define EFUSE_RPT4_RESERVED1_ERR_S 30 /* EFUSE_SECURE_VERSION_ERR : RO ;bitpos:[29:14] ;default: 16'h0 ; */ /*description: If any bit in SECURE_VERSION is 1 then it indicates a programming error.*/ @@ -1597,30 +1615,30 @@ extern "C" { #define EFUSE_ENABLE_SECURITY_DOWNLOAD_ERR_M (BIT(5)) #define EFUSE_ENABLE_SECURITY_DOWNLOAD_ERR_V 0x1 #define EFUSE_ENABLE_SECURITY_DOWNLOAD_ERR_S 5 -/* EFUSE_DIS_USB_DOWNLOAD_MODE_ERR : RO ;bitpos:[4] ;default: 1'b0 ; */ -/*description: If DIS_USB_DOWNLOAD_MODE is 1 then it indicates a programming error.*/ -#define EFUSE_DIS_USB_DOWNLOAD_MODE_ERR (BIT(4)) -#define EFUSE_DIS_USB_DOWNLOAD_MODE_ERR_M (BIT(4)) -#define EFUSE_DIS_USB_DOWNLOAD_MODE_ERR_V 0x1 -#define EFUSE_DIS_USB_DOWNLOAD_MODE_ERR_S 4 +/* EFUSE_DIS_USB_SERIAL_JTAG_DOWNLOAD_MODE_ERR : RO ;bitpos:[4] ;default: 1'b0 ; */ +/*description: If DIS_USB_SERIAL_JTAG_DOWNLOAD_MODE is 1 then it indicates a programming error.*/ +#define EFUSE_DIS_USB_SERIAL_JTAG_DOWNLOAD_MODE_ERR (BIT(4)) +#define EFUSE_DIS_USB_SERIAL_JTAG_DOWNLOAD_MODE_ERR_M (BIT(4)) +#define EFUSE_DIS_USB_SERIAL_JTAG_DOWNLOAD_MODE_ERR_V 0x1 +#define EFUSE_DIS_USB_SERIAL_JTAG_DOWNLOAD_MODE_ERR_S 4 /* EFUSE_RPT4_RESERVED8_ERR : RO ;bitpos:[3] ;default: 1'b0 ; */ /*description: Reserved.*/ #define EFUSE_RPT4_RESERVED8_ERR (BIT(3)) #define EFUSE_RPT4_RESERVED8_ERR_M (BIT(3)) #define EFUSE_RPT4_RESERVED8_ERR_V 0x1 #define EFUSE_RPT4_RESERVED8_ERR_S 3 -/* EFUSE_UART_PRINT_CHANNEL_ERR : RO ;bitpos:[2] ;default: 1'b0 ; */ -/*description: If UART_PRINT_CHANNEL is 1 then it indicates a programming error.*/ -#define EFUSE_UART_PRINT_CHANNEL_ERR (BIT(2)) -#define EFUSE_UART_PRINT_CHANNEL_ERR_M (BIT(2)) -#define EFUSE_UART_PRINT_CHANNEL_ERR_V 0x1 -#define EFUSE_UART_PRINT_CHANNEL_ERR_S 2 -/* EFUSE_DIS_LEGACY_SPI_BOOT_ERR : RO ;bitpos:[1] ;default: 1'b0 ; */ -/*description: If DIS_LEGACY_SPI_BOOT is 1 then it indicates a programming error.*/ -#define EFUSE_DIS_LEGACY_SPI_BOOT_ERR (BIT(1)) -#define EFUSE_DIS_LEGACY_SPI_BOOT_ERR_M (BIT(1)) -#define EFUSE_DIS_LEGACY_SPI_BOOT_ERR_V 0x1 -#define EFUSE_DIS_LEGACY_SPI_BOOT_ERR_S 1 +/* EFUSE_DIS_USB_SERIAL_JTAG_ROM_PRINT_ERR : RO ;bitpos:[2] ;default: 1'b0 ; */ +/*description: If DIS_USB_SERIAL_JTAG_ROM_PRINT is 1 then it indicates a programming error.*/ +#define EFUSE_DIS_USB_SERIAL_JTAG_ROM_PRINT_ERR (BIT(2)) +#define EFUSE_DIS_USB_SERIAL_JTAG_ROM_PRINT_ERR_M (BIT(2)) +#define EFUSE_DIS_USB_SERIAL_JTAG_ROM_PRINT_ERR_V 0x1 +#define EFUSE_DIS_USB_SERIAL_JTAG_ROM_PRINT_ERR_S 2 +/* EFUSE_DIS_DIRECT_BOOT_ERR : RO ;bitpos:[1] ;default: 1'b0 ; */ +/*description: If DIS_DIRECT_BOOT is 1 then it indicates a programming error.*/ +#define EFUSE_DIS_DIRECT_BOOT_ERR (BIT(1)) +#define EFUSE_DIS_DIRECT_BOOT_ERR_M (BIT(1)) +#define EFUSE_DIS_DIRECT_BOOT_ERR_V 0x1 +#define EFUSE_DIS_DIRECT_BOOT_ERR_S 1 /* EFUSE_DIS_DOWNLOAD_MODE_ERR : RO ;bitpos:[0] ;default: 1'b0 ; */ /*description: If DIS_DOWNLOAD_MODE is 1 then it indicates a programming error.*/ #define EFUSE_DIS_DOWNLOAD_MODE_ERR (BIT(0)) @@ -1637,104 +1655,97 @@ extern "C" { #define EFUSE_RPT4_RESERVED4_ERR_S 0 #define EFUSE_RD_RS_ERR0_REG (DR_REG_EFUSE_BASE + 0x1C0) -/* EFUSE_KEY4_FAIL : RO ;bitpos:[31] ;default: 1'b0 ; */ -/*description: 0: Means no failure and that the data of key$n is reliable 1: - Means that programming key$n failed and the number of error bytes is over 6.*/ -#define EFUSE_KEY4_FAIL (BIT(31)) -#define EFUSE_KEY4_FAIL_M (BIT(31)) -#define EFUSE_KEY4_FAIL_V 0x1 -#define EFUSE_KEY4_FAIL_S 31 +/* EFUSE_KEY3_FAIL : RO ;bitpos:[31] ;default: 1'b0 ; */ +/*description: 0: Means no failure and that the data of key3 is reliable 1: + Means that programming key3 failed and the number of error bytes is over 6.*/ +#define EFUSE_KEY3_FAIL (BIT(31)) +#define EFUSE_KEY3_FAIL_M (BIT(31)) +#define EFUSE_KEY3_FAIL_V 0x1 +#define EFUSE_KEY3_FAIL_S 31 /* EFUSE_KEY4_ERR_NUM : RO ;bitpos:[30:28] ;default: 3'h0 ; */ /*description: The value of this signal means the number of error bytes.*/ #define EFUSE_KEY4_ERR_NUM 0x00000007 #define EFUSE_KEY4_ERR_NUM_M ((EFUSE_KEY4_ERR_NUM_V)<<(EFUSE_KEY4_ERR_NUM_S)) #define EFUSE_KEY4_ERR_NUM_V 0x7 #define EFUSE_KEY4_ERR_NUM_S 28 -/* EFUSE_KEY3_FAIL : RO ;bitpos:[27] ;default: 1'b0 ; */ -/*description: 0: Means no failure and that the data of key$n is reliable 1: - Means that programming key$n failed and the number of error bytes is over 6.*/ -#define EFUSE_KEY3_FAIL (BIT(27)) -#define EFUSE_KEY3_FAIL_M (BIT(27)) -#define EFUSE_KEY3_FAIL_V 0x1 -#define EFUSE_KEY3_FAIL_S 27 +/* EFUSE_KEY2_FAIL : RO ;bitpos:[27] ;default: 1'b0 ; */ +/*description: 0: Means no failure and that the data of key2 is reliable 1: + Means that programming key2 failed and the number of error bytes is over 6.*/ +#define EFUSE_KEY2_FAIL (BIT(27)) +#define EFUSE_KEY2_FAIL_M (BIT(27)) +#define EFUSE_KEY2_FAIL_V 0x1 +#define EFUSE_KEY2_FAIL_S 27 /* EFUSE_KEY3_ERR_NUM : RO ;bitpos:[26:24] ;default: 3'h0 ; */ /*description: The value of this signal means the number of error bytes.*/ #define EFUSE_KEY3_ERR_NUM 0x00000007 #define EFUSE_KEY3_ERR_NUM_M ((EFUSE_KEY3_ERR_NUM_V)<<(EFUSE_KEY3_ERR_NUM_S)) #define EFUSE_KEY3_ERR_NUM_V 0x7 #define EFUSE_KEY3_ERR_NUM_S 24 -/* EFUSE_KEY2_FAIL : RO ;bitpos:[23] ;default: 1'b0 ; */ -/*description: 0: Means no failure and that the data of key$n is reliable 1: - Means that programming key$n failed and the number of error bytes is over 6.*/ -#define EFUSE_KEY2_FAIL (BIT(23)) -#define EFUSE_KEY2_FAIL_M (BIT(23)) -#define EFUSE_KEY2_FAIL_V 0x1 -#define EFUSE_KEY2_FAIL_S 23 +/* EFUSE_KEY1_FAIL : RO ;bitpos:[23] ;default: 1'b0 ; */ +/*description: 0: Means no failure and that the data of key1 is reliable 1: + Means that programming key1 failed and the number of error bytes is over 6.*/ +#define EFUSE_KEY1_FAIL (BIT(23)) +#define EFUSE_KEY1_FAIL_M (BIT(23)) +#define EFUSE_KEY1_FAIL_V 0x1 +#define EFUSE_KEY1_FAIL_S 23 /* EFUSE_KEY2_ERR_NUM : RO ;bitpos:[22:20] ;default: 3'h0 ; */ /*description: The value of this signal means the number of error bytes.*/ #define EFUSE_KEY2_ERR_NUM 0x00000007 #define EFUSE_KEY2_ERR_NUM_M ((EFUSE_KEY2_ERR_NUM_V)<<(EFUSE_KEY2_ERR_NUM_S)) #define EFUSE_KEY2_ERR_NUM_V 0x7 #define EFUSE_KEY2_ERR_NUM_S 20 -/* EFUSE_KEY1_FAIL : RO ;bitpos:[19] ;default: 1'b0 ; */ -/*description: 0: Means no failure and that the data of key$n is reliable 1: - Means that programming key$n failed and the number of error bytes is over 6.*/ -#define EFUSE_KEY1_FAIL (BIT(19)) -#define EFUSE_KEY1_FAIL_M (BIT(19)) -#define EFUSE_KEY1_FAIL_V 0x1 -#define EFUSE_KEY1_FAIL_S 19 +/* EFUSE_KEY0_FAIL : RO ;bitpos:[19] ;default: 1'b0 ; */ +/*description: 0: Means no failure and that the data of key0 is reliable 1: + Means that programming key0 failed and the number of error bytes is over 6.*/ +#define EFUSE_KEY0_FAIL (BIT(19)) +#define EFUSE_KEY0_FAIL_M (BIT(19)) +#define EFUSE_KEY0_FAIL_V 0x1 +#define EFUSE_KEY0_FAIL_S 19 /* EFUSE_KEY1_ERR_NUM : RO ;bitpos:[18:16] ;default: 3'h0 ; */ /*description: The value of this signal means the number of error bytes.*/ #define EFUSE_KEY1_ERR_NUM 0x00000007 #define EFUSE_KEY1_ERR_NUM_M ((EFUSE_KEY1_ERR_NUM_V)<<(EFUSE_KEY1_ERR_NUM_S)) #define EFUSE_KEY1_ERR_NUM_V 0x7 #define EFUSE_KEY1_ERR_NUM_S 16 -/* EFUSE_KEY0_FAIL : RO ;bitpos:[15] ;default: 1'b0 ; */ -/*description: 0: Means no failure and that the data of key$n is reliable 1: - Means that programming key$n failed and the number of error bytes is over 6.*/ -#define EFUSE_KEY0_FAIL (BIT(15)) -#define EFUSE_KEY0_FAIL_M (BIT(15)) -#define EFUSE_KEY0_FAIL_V 0x1 -#define EFUSE_KEY0_FAIL_S 15 +/* EFUSE_USR_DATA_FAIL : RO ;bitpos:[15] ;default: 1'b0 ; */ +/*description: 0: Means no failure and that the data of user data is reliable + 1: Means that programming user data failed and the number of error bytes is over 6.*/ +#define EFUSE_USR_DATA_FAIL (BIT(15)) +#define EFUSE_USR_DATA_FAIL_M (BIT(15)) +#define EFUSE_USR_DATA_FAIL_V 0x1 +#define EFUSE_USR_DATA_FAIL_S 15 /* EFUSE_KEY0_ERR_NUM : RO ;bitpos:[14:12] ;default: 3'h0 ; */ /*description: The value of this signal means the number of error bytes.*/ #define EFUSE_KEY0_ERR_NUM 0x00000007 #define EFUSE_KEY0_ERR_NUM_M ((EFUSE_KEY0_ERR_NUM_V)<<(EFUSE_KEY0_ERR_NUM_S)) #define EFUSE_KEY0_ERR_NUM_V 0x7 #define EFUSE_KEY0_ERR_NUM_S 12 -/* EFUSE_USR_DATA_FAIL : RO ;bitpos:[11] ;default: 1'b0 ; */ -/*description: 0: Means no failure and that the user data is reliable 1: Means - that programming user data failed and the number of error bytes is over 6.*/ -#define EFUSE_USR_DATA_FAIL (BIT(11)) -#define EFUSE_USR_DATA_FAIL_M (BIT(11)) -#define EFUSE_USR_DATA_FAIL_V 0x1 -#define EFUSE_USR_DATA_FAIL_S 11 +/* EFUSE_SYS_PART1_FAIL : RO ;bitpos:[11] ;default: 1'b0 ; */ +/*description: 0: Means no failure and that the data of system part1 is reliable + 1: Means that programming data of system part1 failed and the number of error bytes is over 6.*/ +#define EFUSE_SYS_PART1_FAIL (BIT(11)) +#define EFUSE_SYS_PART1_FAIL_M (BIT(11)) +#define EFUSE_SYS_PART1_FAIL_V 0x1 +#define EFUSE_SYS_PART1_FAIL_S 11 /* EFUSE_USR_DATA_ERR_NUM : RO ;bitpos:[10:8] ;default: 3'h0 ; */ /*description: The value of this signal means the number of error bytes.*/ #define EFUSE_USR_DATA_ERR_NUM 0x00000007 #define EFUSE_USR_DATA_ERR_NUM_M ((EFUSE_USR_DATA_ERR_NUM_V)<<(EFUSE_USR_DATA_ERR_NUM_S)) #define EFUSE_USR_DATA_ERR_NUM_V 0x7 #define EFUSE_USR_DATA_ERR_NUM_S 8 -/* EFUSE_SYS_PART1_FAIL : RO ;bitpos:[7] ;default: 1'b0 ; */ -/*description: 0: Means no failure and that the data of system part1 is reliable - 1: Means that programming user data failed and the number of error bytes is over 6.*/ -#define EFUSE_SYS_PART1_FAIL (BIT(7)) -#define EFUSE_SYS_PART1_FAIL_M (BIT(7)) -#define EFUSE_SYS_PART1_FAIL_V 0x1 -#define EFUSE_SYS_PART1_FAIL_S 7 +/* EFUSE_MAC_SPI_8M_FAIL : RO ;bitpos:[7] ;default: 1'b0 ; */ +/*description: 0: Means no failure and that the data of MAC_SPI_8M is reliable + 1: Means that programming MAC_SPI_8M failed and the number of error bytes is over 6.*/ +#define EFUSE_MAC_SPI_8M_FAIL (BIT(7)) +#define EFUSE_MAC_SPI_8M_FAIL_M (BIT(7)) +#define EFUSE_MAC_SPI_8M_FAIL_V 0x1 +#define EFUSE_MAC_SPI_8M_FAIL_S 7 /* EFUSE_SYS_PART1_NUM : RO ;bitpos:[6:4] ;default: 3'h0 ; */ /*description: The value of this signal means the number of error bytes.*/ #define EFUSE_SYS_PART1_NUM 0x00000007 #define EFUSE_SYS_PART1_NUM_M ((EFUSE_SYS_PART1_NUM_V)<<(EFUSE_SYS_PART1_NUM_S)) #define EFUSE_SYS_PART1_NUM_V 0x7 #define EFUSE_SYS_PART1_NUM_S 4 -/* EFUSE_MAC_SPI_8M_FAIL : RO ;bitpos:[3] ;default: 1'b0 ; */ -/*description: 0: Means no failure and that the data of MAC_SPI_8M is reliable - 1: Means that programming user data failed and the number of error bytes is over 6.*/ -#define EFUSE_MAC_SPI_8M_FAIL (BIT(3)) -#define EFUSE_MAC_SPI_8M_FAIL_M (BIT(3)) -#define EFUSE_MAC_SPI_8M_FAIL_V 0x1 -#define EFUSE_MAC_SPI_8M_FAIL_S 3 /* EFUSE_MAC_SPI_8M_ERR_NUM : RO ;bitpos:[2:0] ;default: 3'h0 ; */ /*description: The value of this signal means the number of error bytes.*/ #define EFUSE_MAC_SPI_8M_ERR_NUM 0x00000007 @@ -1743,26 +1754,26 @@ extern "C" { #define EFUSE_MAC_SPI_8M_ERR_NUM_S 0 #define EFUSE_RD_RS_ERR1_REG (DR_REG_EFUSE_BASE + 0x1C4) -/* EFUSE_SYS_PART2_FAIL : RO ;bitpos:[7] ;default: 1'b0 ; */ -/*description: 0: Means no failure and that the data of system part2 is reliable - 1: Means that programming user data failed and the number of error bytes is over 6.*/ -#define EFUSE_SYS_PART2_FAIL (BIT(7)) -#define EFUSE_SYS_PART2_FAIL_M (BIT(7)) -#define EFUSE_SYS_PART2_FAIL_V 0x1 -#define EFUSE_SYS_PART2_FAIL_S 7 +/* EFUSE_KEY5_FAIL : RO ;bitpos:[7] ;default: 1'b0 ; */ +/*description: 0: Means no failure and that the data of KEY5 is reliable 1: + Means that programming KEY5 failed and the number of error bytes is over 6.*/ +#define EFUSE_KEY5_FAIL (BIT(7)) +#define EFUSE_KEY5_FAIL_M (BIT(7)) +#define EFUSE_KEY5_FAIL_V 0x1 +#define EFUSE_KEY5_FAIL_S 7 /* EFUSE_SYS_PART2_ERR_NUM : RO ;bitpos:[6:4] ;default: 3'h0 ; */ /*description: The value of this signal means the number of error bytes.*/ #define EFUSE_SYS_PART2_ERR_NUM 0x00000007 #define EFUSE_SYS_PART2_ERR_NUM_M ((EFUSE_SYS_PART2_ERR_NUM_V)<<(EFUSE_SYS_PART2_ERR_NUM_S)) #define EFUSE_SYS_PART2_ERR_NUM_V 0x7 #define EFUSE_SYS_PART2_ERR_NUM_S 4 -/* EFUSE_KEY5_FAIL : RO ;bitpos:[3] ;default: 1'b0 ; */ -/*description: 0: Means no failure and that the data of KEY5 is reliable 1: - Means that programming user data failed and the number of error bytes is over 6.*/ -#define EFUSE_KEY5_FAIL (BIT(3)) -#define EFUSE_KEY5_FAIL_M (BIT(3)) -#define EFUSE_KEY5_FAIL_V 0x1 -#define EFUSE_KEY5_FAIL_S 3 +/* EFUSE_KEY4_FAIL : RO ;bitpos:[3] ;default: 1'b0 ; */ +/*description: 0: Means no failure and that the data of KEY4 is reliable 1: + Means that programming KEY4 failed and the number of error bytes is over 6.*/ +#define EFUSE_KEY4_FAIL (BIT(3)) +#define EFUSE_KEY4_FAIL_M (BIT(3)) +#define EFUSE_KEY4_FAIL_V 0x1 +#define EFUSE_KEY4_FAIL_S 3 /* EFUSE_KEY5_ERR_NUM : RO ;bitpos:[2:0] ;default: 3'h0 ; */ /*description: The value of this signal means the number of error bytes.*/ #define EFUSE_KEY5_ERR_NUM 0x00000007 diff --git a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/efuse_struct.h b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/efuse_struct.h index 358d78c9a3a..9cb4b01e449 100644 --- a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/efuse_struct.h +++ b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/efuse_struct.h @@ -73,17 +73,18 @@ typedef volatile struct efuse_dev_s { } pgm_data3; union { struct { - uint32_t dis_download_mode: 1; /*Set this bit to disable download mode (boot_mode[3:0] = 0 1 2 3 6 7).*/ - uint32_t dis_legacy_spi_boot: 1; /*Set this bit to disable Legacy SPI boot mode (boot_mode[3:0] = 4).*/ - uint32_t uart_print_channel: 1; /*Selectes the default UART print channel. 0: UART0. 1: UART1.*/ - uint32_t rpt4_reserved8: 1; /*Reserved (used for four backups method).*/ - uint32_t dis_usb_download_mode: 1; /*Set this bit to disable UART download mode through USB.*/ - uint32_t enable_security_download: 1; /*Set this bit to enable secure UART download mode.*/ - uint32_t uart_print_control: 2; /*Set the default UARTboot message output mode. 00: Enabled. 01: Enabled when GPIO8 is low at reset. 10: Enabled when GPIO8 is high at reset. 11:disabled.*/ - uint32_t rpt4_reserved7: 5; /*Reserved (used for four backups method).*/ - uint32_t force_send_resume: 1; /*Set this bit to force ROM code to send a resume command during SPI boot.*/ - uint32_t secure_version: 16; /*Secure version (used by ESP-IDF anti-rollback feature).*/ - uint32_t rpt4_reserved1: 2; /*Reserved (used for four backups method).*/ + uint32_t dis_download_mode: 1; /*Set this bit to disable download mode (boot_mode[3:0] = 0 1 2 3 6 7).*/ + uint32_t dis_direct_boot: 1; /*Set this bit to disable direct boot.*/ + uint32_t dis_usb_serial_jtag_rom_print: 1; /*Set this bit to disable USB-Serial-JTAG print during rom boot*/ + uint32_t rpt4_reserved8: 1; /*Reserved (used for four backups method).*/ + uint32_t dis_usb_serial_jtag_download_mode: 1; /*Set this bit to disable download mode through USB-Serial-JTAG.*/ + uint32_t enable_security_download: 1; /*Set this bit to enable secure UART download mode.*/ + uint32_t uart_print_control: 2; /*Set the default UARTboot message output mode. 00: Enabled. 01: Enabled when GPIO8 is low at reset. 10: Enabled when GPIO8 is high at reset. 11:disabled.*/ + uint32_t rpt4_reserved7: 5; /*Reserved (used for four backups method).*/ + uint32_t force_send_resume: 1; /*Set this bit to force ROM code to send a resume command during SPI boot.*/ + uint32_t secure_version: 16; /*Secure version (used by ESP-IDF anti-rollback feature).*/ + uint32_t rpt4_reserved1: 1; /*Reserved (used for four backups method).*/ + uint32_t err_rst_enable: 1; /*Use BLOCK0 to check error record registers, 0 - without check.*/ }; uint32_t val; } pgm_data4; @@ -155,16 +156,17 @@ typedef volatile struct efuse_dev_s { union { struct { uint32_t dis_download_mode: 1; /*The value of DIS_DOWNLOAD_MODE.*/ - uint32_t dis_legacy_spi_boot: 1; /*The value of DIS_LEGACY_SPI_BOOT.*/ - uint32_t uart_print_channel: 1; /*The value of UART_PRINT_CHANNEL.*/ + uint32_t dis_direct_boot: 1; /*The value of DIS_DIRECT_BOOT.*/ + uint32_t dis_usb_serial_jtag_rom_print:1; /*The value of DIS_USB_SERIAL_JTAG_ROM_PRINT.*/ uint32_t rpt4_reserved8: 1; /*Reserved.*/ - uint32_t dis_usb_download_mode: 1; /*The value of DIS_USB_DOWNLOAD_MODE.*/ + uint32_t dis_usb_serial_jtag_download_mode: 1; /*The value of dis_usb_serial_jtag_download_mode.*/ uint32_t enable_security_download: 1; /*The value of ENABLE_SECURITY_DOWNLOAD.*/ uint32_t uart_print_control: 2; /*The value of UART_PRINT_CONTROL.*/ uint32_t rpt4_reserved7: 5; /*Reserved.*/ uint32_t force_send_resume: 1; /*The value of FORCE_SEND_RESUME.*/ uint32_t secure_version: 16; /*The value of SECURE_VERSION.*/ - uint32_t rpt4_reserved1: 2; /*Reserved.*/ + uint32_t rpt4_reserved1: 1; /*Reserved.*/ + uint32_t err_rst_enable: 1; /*Use BLOCK0 to check error record registers, 0 - without check.*/ }; uint32_t val; } rd_repeat_data3; @@ -319,17 +321,18 @@ typedef volatile struct efuse_dev_s { } rd_repeat_err2; union { struct { - uint32_t dis_download_mode_err: 1; /*If DIS_DOWNLOAD_MODE is 1 then it indicates a programming error.*/ - uint32_t dis_legacy_spi_boot_err: 1; /*If DIS_LEGACY_SPI_BOOT is 1 then it indicates a programming error.*/ - uint32_t uart_print_channel_err: 1; /*If UART_PRINT_CHANNEL is 1 then it indicates a programming error.*/ + uint32_t dis_download_mode_err: 1; /*If the value is not zero then it indicates a programming error on DIS_DOWNLOAD_MODE.*/ + uint32_t dis_direct_boot_err: 1; /*If the value is not zero then it indicates a programming error on DIS_DIRECT_BOOT.*/ + uint32_t dis_usb_serial_jtag_rom_print_err:1; /*If the value is not zero then it indicates a programming error on DIS_USB_SERIAL_JTAG_ROM_PRINT.*/ uint32_t rpt4_reserved8_err: 1; /*Reserved.*/ - uint32_t dis_usb_download_mode_err: 1; /*If DIS_USB_DOWNLOAD_MODE is 1 then it indicates a programming error.*/ - uint32_t enable_security_download_err: 1; /*If ENABLE_SECURITY_DOWNLOAD is 1 then it indicates a programming error.*/ - uint32_t uart_print_control_err: 2; /*If any bit in UART_PRINT_CONTROL is 1 then it indicates a programming error.*/ + uint32_t dis_usb_serial_jtag_download_mode_err: 1; /*If the value is not zero then it indicates a programming error on DIS_USB_SERIAL_JTAG_DOWNLOAD_MODE.*/ + uint32_t enable_security_download_err: 1; /*If the value is not zero then it indicates a programming error on ENABLE_SECURITY_DOWNLOAD.*/ + uint32_t uart_print_control_err: 2; /*If the value is not zero then it indicates a programming error on UART_PRINT_CONTROL.*/ uint32_t rpt4_reserved7_err: 5; /*Reserved*/ - uint32_t force_send_resume_err: 1; /*If FORCE_SEND_RESUME is 1 then it indicates a programming error.*/ - uint32_t secure_version_err: 16; /*If any bit in SECURE_VERSION is 1 then it indicates a programming error.*/ - uint32_t rpt4_reserved1_err: 2; /*Reserved.*/ + uint32_t force_send_resume_err: 1; /*If the value is not zero then it indicates a programming error on FORCE_SEND_RESUME.*/ + uint32_t secure_version_err: 16; /*If the value is not zero then it indicates a programming error on SECURE_VERSION.*/ + uint32_t rpt4_reserved1_err: 1; /*Reserved.*/ + uint32_t err_rst_enable_err: 1; /*Use BLOCK0 to check error record registers, 0 - without check.*/ }; uint32_t val; } rd_repeat_err3; @@ -355,30 +358,30 @@ typedef volatile struct efuse_dev_s { union { struct { uint32_t mac_spi_8m_err_num: 3; /*The value of this signal means the number of error bytes.*/ - uint32_t mac_spi_8m_fail: 1; /*0: Means no failure and that the data of MAC_SPI_8M is reliable 1: Means that programming user data failed and the number of error bytes is over 6.*/ + uint32_t reserved3: 1; /*Reserved.*/ uint32_t sys_part1_num: 3; /*The value of this signal means the number of error bytes.*/ - uint32_t sys_part1_fail: 1; /*0: Means no failure and that the data of system part1 is reliable 1: Means that programming user data failed and the number of error bytes is over 6.*/ + uint32_t mac_spi_8m_fail: 1; /*0: Means no failure and that the data of MAC_SPI_8M is reliable 1: Means that programming MAC_SPI_8M failed and the number of error bytes is over 6.*/ uint32_t usr_data_err_num: 3; /*The value of this signal means the number of error bytes.*/ - uint32_t usr_data_fail: 1; /*0: Means no failure and that the user data is reliable 1: Means that programming user data failed and the number of error bytes is over 6.*/ + uint32_t sys_part1_fail: 1; /*0: Means no failure and that the data of system part1 is reliable 1: Means that programming the data of system part1 failed and the number of error bytes is over 6.*/ uint32_t key0_err_num: 3; /*The value of this signal means the number of error bytes.*/ - uint32_t key0_fail: 1; /*0: Means no failure and that the data of key$n is reliable 1: Means that programming key$n failed and the number of error bytes is over 6.*/ + uint32_t usr_data_fail: 1; /*0: Means no failure and that the data of user data is reliable 1: Means that programming user data failed and the number of error bytes is over 6.*/ uint32_t key1_err_num: 3; /*The value of this signal means the number of error bytes.*/ - uint32_t key1_fail: 1; /*0: Means no failure and that the data of key$n is reliable 1: Means that programming key$n failed and the number of error bytes is over 6.*/ + uint32_t key0_fail: 1; /*0: Means no failure and that the data of key0 is reliable 1: Means that programming key0 failed and the number of error bytes is over 6.*/ uint32_t key2_err_num: 3; /*The value of this signal means the number of error bytes.*/ - uint32_t key2_fail: 1; /*0: Means no failure and that the data of key$n is reliable 1: Means that programming key$n failed and the number of error bytes is over 6.*/ + uint32_t key1_fail: 1; /*0: Means no failure and that the data of key1 is reliable 1: Means that programming key1 failed and the number of error bytes is over 6.*/ uint32_t key3_err_num: 3; /*The value of this signal means the number of error bytes.*/ - uint32_t key3_fail: 1; /*0: Means no failure and that the data of key$n is reliable 1: Means that programming key$n failed and the number of error bytes is over 6.*/ + uint32_t key2_fail: 1; /*0: Means no failure and that the data of key2 is reliable 1: Means that programming key2 failed and the number of error bytes is over 6.*/ uint32_t key4_err_num: 3; /*The value of this signal means the number of error bytes.*/ - uint32_t key4_fail: 1; /*0: Means no failure and that the data of key$n is reliable 1: Means that programming key$n failed and the number of error bytes is over 6.*/ + uint32_t key3_fail: 1; /*0: Means no failure and that the data of key3 is reliable 1: Means that programming key3 failed and the number of error bytes is over 6.*/ }; uint32_t val; } rd_rs_err0; union { struct { uint32_t key5_err_num: 3; /*The value of this signal means the number of error bytes.*/ - uint32_t key5_fail: 1; /*0: Means no failure and that the data of KEY5 is reliable 1: Means that programming user data failed and the number of error bytes is over 6.*/ + uint32_t key4_fail: 1; /*0: Means no failure and that the data of KEY4 is reliable 1: Means that programming KEY4 failed and the number of error bytes is over 6.*/ uint32_t sys_part2_err_num: 3; /*The value of this signal means the number of error bytes.*/ - uint32_t sys_part2_fail: 1; /*0: Means no failure and that the data of system part2 is reliable 1: Means that programming user data failed and the number of error bytes is over 6.*/ + uint32_t key5_fail: 1; /*0: Means no failure and that the data of KEY5 is reliable 1: Means that programming KEY5 failed and the number of error bytes is over 6.*/ uint32_t reserved8: 24; /*Reserved.*/ }; uint32_t val; diff --git a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/rtc.h b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/rtc.h index dccd7a07780..5222da63ad7 100644 --- a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/rtc.h +++ b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/rtc.h @@ -58,9 +58,8 @@ extern "C" { /* Approximate mapping of voltages to RTC_CNTL_DBIAS_WAK, RTC_CNTL_DBIAS_SLP, * RTC_CNTL_DIG_DBIAS_WAK, RTC_CNTL_DIG_DBIAS_SLP values. - * Valid if RTC_CNTL_DBG_ATTEN is 0. */ -#define RTC_CNTL_DBIAS_SLP 0 //sleep dig_dbias & rtc_dbias +#define RTC_CNTL_DBIAS_SLP 5 //sleep dig_dbias & rtc_dbias #define RTC_CNTL_DBIAS_0V90 13 //digital voltage #define RTC_CNTL_DBIAS_0V95 16 #define RTC_CNTL_DBIAS_1V00 18 @@ -105,7 +104,7 @@ extern "C" { /* set sleep_init default param */ -#define RTC_CNTL_DBG_ATTEN_LIGHTSLEEP_DEFAULT 3 +#define RTC_CNTL_DBG_ATTEN_LIGHTSLEEP_DEFAULT 5 #define RTC_CNTL_DBG_ATTEN_LIGHTSLEEP_NODROP 0 #define RTC_CNTL_DBG_ATTEN_DEEPSLEEP_DEFAULT 15 #define RTC_CNTL_DBG_ATTEN_MONITOR_DEFAULT 0 @@ -583,6 +582,11 @@ void rtc_dig_clk8m_enable(void); */ void rtc_dig_clk8m_disable(void); +/** + * @brief Get whether the rtc digital 8M clock is enabled + */ +bool rtc_dig_8m_enabled(void); + /** * @brief Calculate the real clock value after the clock calibration * @@ -643,48 +647,18 @@ typedef struct { uint32_t dig_dbias_slp : 5; //!< set bias for digital domain, in sleep mode uint32_t rtc_dbias_wak : 5; //!< set bias for RTC domain, in active mode uint32_t rtc_dbias_slp : 5; //!< set bias for RTC domain, in sleep mode + uint32_t dbg_atten_monitor : 4; //!< voltage parameter, in monitor mode + uint32_t bias_sleep_monitor : 1; //!< circuit control parameter, in monitor mode + uint32_t dbg_atten_slp : 4; //!< voltage parameter, in sleep mode + uint32_t bias_sleep_slp : 1; //!< circuit control parameter, in sleep mode + uint32_t pd_cur_monitor : 1; //!< circuit control parameter, in monitor mode + uint32_t pd_cur_slp : 1; //!< circuit control parameter, in sleep mode uint32_t vddsdio_pd_en : 1; //!< power down VDDSDIO regulator uint32_t xtal_fpu : 1; //!< keep main XTAL powered up in sleep uint32_t deep_slp_reject : 1; uint32_t light_slp_reject : 1; } rtc_sleep_config_t; -/** - * Default initializer for rtc_sleep_config_t - * - * This initializer sets all fields to "reasonable" values (e.g. suggested for - * production use) based on a combination of RTC_SLEEP_PD_x flags. - * - * @param RTC_SLEEP_PD_x flags combined using bitwise OR - */ -#define is_dslp(pd_flags) ((pd_flags) & RTC_SLEEP_PD_DIG) -#define RTC_SLEEP_CONFIG_DEFAULT(sleep_flags) { \ - .lslp_mem_inf_fpu = 0, \ - .rtc_mem_inf_follow_cpu = ((sleep_flags) & RTC_SLEEP_PD_RTC_MEM_FOLLOW_CPU) ? 1 : 0, \ - .rtc_fastmem_pd_en = ((sleep_flags) & RTC_SLEEP_PD_RTC_FAST_MEM) ? 1 : 0, \ - .rtc_slowmem_pd_en = ((sleep_flags) & RTC_SLEEP_PD_RTC_SLOW_MEM) ? 1 : 0, \ - .rtc_peri_pd_en = ((sleep_flags) & RTC_SLEEP_PD_RTC_PERIPH) ? 1 : 0, \ - .wifi_pd_en = ((sleep_flags) & RTC_SLEEP_PD_WIFI) ? 1 : 0, \ - .bt_pd_en = ((sleep_flags) & RTC_SLEEP_PD_BT) ? 1 : 0, \ - .cpu_pd_en = ((sleep_flags) & RTC_SLEEP_PD_CPU) ? 1 : 0, \ - .int_8m_pd_en = is_dslp(sleep_flags) ? 1 : ((sleep_flags) & RTC_SLEEP_PD_INT_8M) ? 1 : 0, \ - .dig_peri_pd_en = ((sleep_flags) & RTC_SLEEP_PD_DIG_PERIPH) ? 1 : 0, \ - .deep_slp = ((sleep_flags) & RTC_SLEEP_PD_DIG) ? 1 : 0, \ - .wdt_flashboot_mod_en = 0, \ - .dig_dbias_wak = RTC_CNTL_DBIAS_1V10, \ - .dig_dbias_slp = is_dslp(sleep_flags) ? RTC_CNTL_DBIAS_SLP \ - : !((sleep_flags) & RTC_SLEEP_PD_INT_8M) ? RTC_CNTL_DBIAS_1V10 \ - : RTC_CNTL_DBIAS_SLP, \ - .rtc_dbias_wak = RTC_CNTL_DBIAS_1V10, \ - .rtc_dbias_slp = is_dslp(sleep_flags) ? RTC_CNTL_DBIAS_SLP \ - : !((sleep_flags) & RTC_SLEEP_PD_INT_8M) ? RTC_CNTL_DBIAS_1V10 \ - : RTC_CNTL_DBIAS_SLP, \ - .vddsdio_pd_en = ((sleep_flags) & RTC_SLEEP_PD_VDDSDIO) ? 1 : 0, \ - .xtal_fpu = is_dslp(sleep_flags) ? 0 : ((sleep_flags) & RTC_SLEEP_PD_XTAL) ? 0 : 1, \ - .deep_slp_reject = 1, \ - .light_slp_reject = 1 \ -}; - #define RTC_SLEEP_PD_DIG BIT(0) //!< Deep sleep (power down digital domain) #define RTC_SLEEP_PD_RTC_PERIPH BIT(1) //!< Power down RTC peripherals #define RTC_SLEEP_PD_RTC_SLOW_MEM BIT(2) //!< Power down RTC SLOW memory @@ -698,6 +672,21 @@ typedef struct { #define RTC_SLEEP_PD_INT_8M BIT(10) //!< Power down Internal 8M oscillator #define RTC_SLEEP_PD_XTAL BIT(11) //!< Power down main XTAL +//These flags are not power domains, but will affect some sleep parameters +#define RTC_SLEEP_DIG_USE_8M BIT(16) +#define RTC_SLEEP_USE_ADC_TESEN_MONITOR BIT(17) +#define RTC_SLEEP_NO_ULTRA_LOW BIT(18) //!< Avoid using ultra low power in deep sleep, in which RTCIO cannot be used as input, and RTCMEM can't work under high temperature + +/** + * Default initializer for rtc_sleep_config_t + * + * This initializer sets all fields to "reasonable" values (e.g. suggested for + * production use) based on a combination of RTC_SLEEP_PD_x flags. + * + * @param RTC_SLEEP_PD_x flags combined using bitwise OR + */ +void rtc_sleep_get_default_config(uint32_t sleep_flags, rtc_sleep_config_t *out_config); + /** * @brief Prepare the chip to enter sleep mode * diff --git a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/rtc_cntl_reg.h b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/rtc_cntl_reg.h index b25f6448323..a8953eeff4e 100644 --- a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/rtc_cntl_reg.h +++ b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/rtc_cntl_reg.h @@ -308,7 +308,6 @@ extern "C" { #define RTC_CNTL_CK8M_WAIT_M ((RTC_CNTL_CK8M_WAIT_V)<<(RTC_CNTL_CK8M_WAIT_S)) #define RTC_CNTL_CK8M_WAIT_V 0xFF #define RTC_CNTL_CK8M_WAIT_S 6 -#define RTC_CNTL_CK8M_WAIT_DEFAULT 20 /* RTC_CNTL_CPU_STALL_WAIT : R/W ;bitpos:[5:1] ;default: 5'd1 ; */ /*description: CPU stall wait cycles in fast_clk_rtc*/ #define RTC_CNTL_CPU_STALL_WAIT 0x0000001F diff --git a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/soc_caps.h b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/soc_caps.h index 33503c02843..9051c1b4c83 100644 --- a/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/soc_caps.h +++ b/tools/sdk/esp32c3/include/soc/esp32c3/include/soc/soc_caps.h @@ -127,7 +127,7 @@ #define SOC_I2C_FIFO_LEN (32) /*!< I2C hardware FIFO depth */ -#define SOC_I2C_SUPPORT_HW_FSM_RST (1) +// FSM_RST only resets the FSM, not using it. So SOC_I2C_SUPPORT_HW_FSM_RST not defined. #define SOC_I2C_SUPPORT_HW_CLR_BUS (1) #define SOC_I2C_SUPPORT_XTAL (1) @@ -172,6 +172,8 @@ #define SOC_RTC_CNTL_CPU_PD_RETENTION_MEM_SIZE (SOC_RTC_CNTL_CPU_PD_REG_FILE_NUM * (SOC_RTC_CNTL_CPU_PD_DMA_BUS_WIDTH >> 3)) +#define SOC_RTC_SLOW_CLOCK_SUPPORT_8MD256 (1) + /*-------------------------- RTCIO CAPS --------------------------------------*/ /* No dedicated RTCIO subsystem on ESP32-C3. RTC functions are still supported * for hold, wake & 32kHz crystal functions - via rtc_cntl_reg */ diff --git a/tools/sdk/esp32c3/include/spiffs/include/esp_spiffs.h b/tools/sdk/esp32c3/include/spiffs/include/esp_spiffs.h index 9cc120895db..eb1582d1511 100644 --- a/tools/sdk/esp32c3/include/spiffs/include/esp_spiffs.h +++ b/tools/sdk/esp32c3/include/spiffs/include/esp_spiffs.h @@ -92,6 +92,17 @@ esp_err_t esp_spiffs_format(const char* partition_label); */ esp_err_t esp_spiffs_info(const char* partition_label, size_t *total_bytes, size_t *used_bytes); +/** + * Check integrity of SPIFFS + * + * @param partition_label Same label as passed to esp_vfs_spiffs_register + * @return + * - ESP_OK if successful + * - ESP_ERR_INVALID_STATE if not mounted + * - ESP_FAIL on error + */ +esp_err_t esp_spiffs_check(const char* partition_label); + #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32c3/include/vfs/include/esp_vfs.h b/tools/sdk/esp32c3/include/vfs/include/esp_vfs.h index 0498a3aa59b..d2634670d47 100644 --- a/tools/sdk/esp32c3/include/vfs/include/esp_vfs.h +++ b/tools/sdk/esp32c3/include/vfs/include/esp_vfs.h @@ -195,6 +195,10 @@ typedef struct int (*truncate_p)(void* ctx, const char *path, off_t length); /*!< truncate with context pointer */ int (*truncate)(const char *path, off_t length); /*!< truncate without context pointer */ }; + union { + int (*ftruncate_p)(void* ctx, int fd, off_t length); /*!< ftruncate with context pointer */ + int (*ftruncate)(int fd, off_t length); /*!< ftruncate without context pointer */ + }; union { int (*utime_p)(void* ctx, const char *path, const struct utimbuf *times); /*!< utime with context pointer */ int (*utime)(const char *path, const struct utimbuf *times); /*!< utime without context pointer */ diff --git a/tools/sdk/esp32c3/include/vfs/include/esp_vfs_semihost.h b/tools/sdk/esp32c3/include/vfs/include/esp_vfs_semihost.h index 20a0ed55066..c6db970be78 100644 --- a/tools/sdk/esp32c3/include/vfs/include/esp_vfs_semihost.h +++ b/tools/sdk/esp32c3/include/vfs/include/esp_vfs_semihost.h @@ -1,16 +1,8 @@ -// Copyright 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. +/* + * SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once @@ -24,13 +16,12 @@ extern "C" { * @brief add virtual filesystem semihosting driver * * @param base_path VFS path to mount host directory - * @param host_path host path to mount; if NULL default dirctory will be used (see OpenOCD configuration) * @return * - ESP_OK on success * - ESP_ERR_INVALID_ARG if esp_vfs_semihost_register was already called for specified VFS path * - ESP_ERR_NO_MEM if there are no slots to register new mount point */ -esp_err_t esp_vfs_semihost_register(const char* base_path, const char* host_path); +esp_err_t esp_vfs_semihost_register(const char* base_path); /** * @brief Un-register semihosting driver from VFS diff --git a/tools/sdk/esp32c3/include/wifi_provisioning/include/wifi_provisioning/wifi_config.h b/tools/sdk/esp32c3/include/wifi_provisioning/include/wifi_provisioning/wifi_config.h index d477580fa99..95cb2d87ed6 100644 --- a/tools/sdk/esp32c3/include/wifi_provisioning/include/wifi_provisioning/wifi_config.h +++ b/tools/sdk/esp32c3/include/wifi_provisioning/include/wifi_provisioning/wifi_config.h @@ -1,16 +1,8 @@ -// Copyright 2018 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. +/* + * SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _WIFI_PROV_CONFIG_H_ #define _WIFI_PROV_CONFIG_H_ diff --git a/tools/sdk/esp32c3/include/wpa_supplicant/esp_supplicant/include/esp_dpp.h b/tools/sdk/esp32c3/include/wpa_supplicant/esp_supplicant/include/esp_dpp.h index c6c86bc536f..d1bb43a0ada 100644 --- a/tools/sdk/esp32c3/include/wpa_supplicant/esp_supplicant/include/esp_dpp.h +++ b/tools/sdk/esp32c3/include/wpa_supplicant/esp_supplicant/include/esp_dpp.h @@ -1,16 +1,8 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef ESP_DPP_H #define ESP_DPP_H diff --git a/tools/sdk/esp32c3/include/wpa_supplicant/esp_supplicant/include/esp_rrm.h b/tools/sdk/esp32c3/include/wpa_supplicant/esp_supplicant/include/esp_rrm.h index 1ffcf180475..fa40e0cd628 100644 --- a/tools/sdk/esp32c3/include/wpa_supplicant/esp_supplicant/include/esp_rrm.h +++ b/tools/sdk/esp32c3/include/wpa_supplicant/esp_supplicant/include/esp_rrm.h @@ -1,17 +1,7 @@ -/** - * Copyright 2020 Espressif Systems (Shanghai) PTE LTD - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at +/* + * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD * - * 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. + * SPDX-License-Identifier: Apache-2.0 */ #ifndef _ESP_RRM_H @@ -41,11 +31,22 @@ typedef void (*neighbor_rep_request_cb)(void *ctx, const uint8_t *report, size_t * @param cb_ctx: callback context * * @return - * - 0: success else failure + * - 0: success + * - -1: AP does not support RRM + * - -2: station not connected to AP */ int esp_rrm_send_neighbor_rep_request(neighbor_rep_request_cb cb, void *cb_ctx); +/** + * @brief Check RRM capability of connected AP + * + * @return + * - true: AP supports RRM + * - false: AP does not support RRM or station not connected to AP + */ +bool esp_rrm_is_rrm_supported_connection(void); + #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32c3/include/wpa_supplicant/esp_supplicant/include/esp_wnm.h b/tools/sdk/esp32c3/include/wpa_supplicant/esp_supplicant/include/esp_wnm.h index 4301385d2cf..2ee95bedd74 100644 --- a/tools/sdk/esp32c3/include/wpa_supplicant/esp_supplicant/include/esp_wnm.h +++ b/tools/sdk/esp32c3/include/wpa_supplicant/esp_supplicant/include/esp_wnm.h @@ -36,12 +36,23 @@ enum btm_query_reason { * @param cand_list: whether candidate list to be included from scan results available in supplicant's cache. * * @return - * - 0: success else failure + * - 0: success + * - -1: AP does not support BTM + * - -2: station not connected to AP */ int esp_wnm_send_bss_transition_mgmt_query(enum btm_query_reason query_reason, const char *btm_candidates, int cand_list); +/** + * @brief Check bss trasition capability of connected AP + * + * @return + * - true: AP supports BTM + * - false: AP does not support BTM or station not connected to AP + */ +bool esp_wnm_is_btm_supported_connection(void); + #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32c3/ld/esp32c3.rom.ld b/tools/sdk/esp32c3/ld/esp32c3.rom.ld index db1a6ac02c9..061b5bbe074 100644 --- a/tools/sdk/esp32c3/ld/esp32c3.rom.ld +++ b/tools/sdk/esp32c3/ld/esp32c3.rom.ld @@ -482,7 +482,8 @@ ets_efuse_get_flash_delay_us = 0x40000714; ets_efuse_get_mac = 0x40000718; ets_efuse_get_spiconfig = 0x4000071c; ets_efuse_usb_print_is_disabled = 0x40000720; -ets_efuse_get_uart_print_channel = 0x40000724; +/*ets_efuse_get_uart_print_channel = 0x40000724;*/ +ets_efuse_usb_serial_jtag_print_is_disabled = 0x40000724; ets_efuse_get_uart_print_control = 0x40000728; ets_efuse_get_wp_pad = 0x4000072c; ets_efuse_legacy_spi_boot_mode_disabled = 0x40000730; @@ -1503,7 +1504,7 @@ esf_buf_alloc = 0x400015bc; GetAccess = 0x400015c8; hal_mac_is_low_rate_enabled = 0x400015cc; hal_mac_tx_get_blockack = 0x400015d0; -hal_mac_tx_set_ppdu = 0x400015d4; +/* hal_mac_tx_set_ppdu = 0x400015d4; */ ic_get_trc = 0x400015d8; ic_mac_deinit = 0x400015dc; ic_mac_init = 0x400015e0; @@ -1527,9 +1528,9 @@ lmacRxDone = 0x40001624; lmacSetTxFrame = 0x40001628; lmacTxFrame = 0x40001630; mac_tx_set_duration = 0x40001634; -mac_tx_set_htsig = 0x40001638; +/* mac_tx_set_htsig = 0x40001638; */ mac_tx_set_plcp0 = 0x4000163c; -mac_tx_set_plcp1 = 0x40001640; +/* mac_tx_set_plcp1 = 0x40001640; */ mac_tx_set_plcp2 = 0x40001644; pm_check_state = 0x40001648; pm_disable_dream_timer = 0x4000164c; @@ -1551,7 +1552,7 @@ pm_parse_beacon = 0x40001688; pm_process_tim = 0x4000168c; pm_rx_beacon_process = 0x40001690; pm_rx_data_process = 0x40001694; -pm_sleep = 0x40001698; +/*pm_sleep = 0x40001698;*/ pm_sleep_for = 0x4000169c; pm_tbtt_process = 0x400016a0; ppAMPDU2Normal = 0x400016a4; @@ -1638,7 +1639,7 @@ wDev_ProcessRxSucData = 0x400017f4; wdevProcessRxSucDataAll = 0x400017f8; wdev_csi_len_align = 0x400017fc; ppDequeueTxDone_Locked = 0x40001800; -pm_tx_data_done_process = 0x40001808; +/*pm_tx_data_done_process = 0x40001808;*/ config_is_cache_tx_buf_enabled = 0x4000180c; ppMapWaitTxq = 0x40001810; ppProcessWaitingQueue = 0x40001814; diff --git a/tools/sdk/esp32c3/ld/libbtbb.a b/tools/sdk/esp32c3/ld/libbtbb.a index e58a848e6e9..b529a825fec 100644 Binary files a/tools/sdk/esp32c3/ld/libbtbb.a and b/tools/sdk/esp32c3/ld/libbtbb.a differ diff --git a/tools/sdk/esp32c3/ld/libphy.a b/tools/sdk/esp32c3/ld/libphy.a index ebf9e4709a6..b5997e90314 100644 Binary files a/tools/sdk/esp32c3/ld/libphy.a and b/tools/sdk/esp32c3/ld/libphy.a differ diff --git a/tools/sdk/esp32c3/ld/memory.ld b/tools/sdk/esp32c3/ld/memory.ld index 250e0796cbc..38a759f918b 100644 --- a/tools/sdk/esp32c3/ld/memory.ld +++ b/tools/sdk/esp32c3/ld/memory.ld @@ -56,7 +56,7 @@ MEMORY /** * RTC fast memory (executable). Persists over deep sleep. */ - rtc_iram_seg(RWX) : org = 0x50000000, len = 0x2000 - 0 + rtc_iram_seg(RWX) : org = 0x50000000, len = 0x2000 - (0x10) } _static_data_end = _bss_end; /* Heap ends at top of dram0_0_seg */ diff --git a/tools/sdk/esp32c3/lib/libapp_trace.a b/tools/sdk/esp32c3/lib/libapp_trace.a index e6e95a76136..7564b09114e 100644 Binary files a/tools/sdk/esp32c3/lib/libapp_trace.a and b/tools/sdk/esp32c3/lib/libapp_trace.a differ diff --git a/tools/sdk/esp32c3/lib/libapp_update.a b/tools/sdk/esp32c3/lib/libapp_update.a index 7743ebfd441..db2e70cb48e 100644 Binary files a/tools/sdk/esp32c3/lib/libapp_update.a and b/tools/sdk/esp32c3/lib/libapp_update.a differ diff --git a/tools/sdk/esp32c3/lib/libasio.a b/tools/sdk/esp32c3/lib/libasio.a index b289cf4c32d..31e7ab2227b 100644 Binary files a/tools/sdk/esp32c3/lib/libasio.a and b/tools/sdk/esp32c3/lib/libasio.a differ diff --git a/tools/sdk/esp32c3/lib/libbt.a b/tools/sdk/esp32c3/lib/libbt.a index 292d783da79..09968157986 100644 Binary files a/tools/sdk/esp32c3/lib/libbt.a and b/tools/sdk/esp32c3/lib/libbt.a differ diff --git a/tools/sdk/esp32c3/lib/libbutton.a b/tools/sdk/esp32c3/lib/libbutton.a index 497be6d4cb2..0e8e164d0bd 100644 Binary files a/tools/sdk/esp32c3/lib/libbutton.a and b/tools/sdk/esp32c3/lib/libbutton.a differ diff --git a/tools/sdk/esp32c3/lib/libcoap.a b/tools/sdk/esp32c3/lib/libcoap.a index 51bb4125973..a1bc41c69cd 100644 Binary files a/tools/sdk/esp32c3/lib/libcoap.a and b/tools/sdk/esp32c3/lib/libcoap.a differ diff --git a/tools/sdk/esp32c3/lib/libcoexist.a b/tools/sdk/esp32c3/lib/libcoexist.a index f8e415c93c8..25456f933c9 100644 Binary files a/tools/sdk/esp32c3/lib/libcoexist.a and b/tools/sdk/esp32c3/lib/libcoexist.a differ diff --git a/tools/sdk/esp32c3/lib/libconsole.a b/tools/sdk/esp32c3/lib/libconsole.a index 5ca5d738009..d062eaf9aea 100644 Binary files a/tools/sdk/esp32c3/lib/libconsole.a and b/tools/sdk/esp32c3/lib/libconsole.a differ diff --git a/tools/sdk/esp32c3/lib/libcore.a b/tools/sdk/esp32c3/lib/libcore.a index 31ede06440d..c5d81060a2a 100644 Binary files a/tools/sdk/esp32c3/lib/libcore.a and b/tools/sdk/esp32c3/lib/libcore.a differ diff --git a/tools/sdk/esp32c3/lib/libdriver.a b/tools/sdk/esp32c3/lib/libdriver.a index e66fcd2404c..b1a83e5777d 100644 Binary files a/tools/sdk/esp32c3/lib/libdriver.a and b/tools/sdk/esp32c3/lib/libdriver.a differ diff --git a/tools/sdk/esp32c3/lib/libefuse.a b/tools/sdk/esp32c3/lib/libefuse.a index 048d8985a58..ef36c5bec48 100644 Binary files a/tools/sdk/esp32c3/lib/libefuse.a and b/tools/sdk/esp32c3/lib/libefuse.a differ diff --git a/tools/sdk/esp32c3/lib/libesp-tls.a b/tools/sdk/esp32c3/lib/libesp-tls.a index 88845926b81..266bea6e189 100644 Binary files a/tools/sdk/esp32c3/lib/libesp-tls.a and b/tools/sdk/esp32c3/lib/libesp-tls.a differ diff --git a/tools/sdk/esp32c3/lib/libesp32-camera.a b/tools/sdk/esp32c3/lib/libesp32-camera.a new file mode 100644 index 00000000000..76afb347dca Binary files /dev/null and b/tools/sdk/esp32c3/lib/libesp32-camera.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_adc_cal.a b/tools/sdk/esp32c3/lib/libesp_adc_cal.a index 4b629a84948..985566335c7 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_adc_cal.a and b/tools/sdk/esp32c3/lib/libesp_adc_cal.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_common.a b/tools/sdk/esp32c3/lib/libesp_common.a index 5fd65cdd5d3..99dcc61437a 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_common.a and b/tools/sdk/esp32c3/lib/libesp_common.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_eth.a b/tools/sdk/esp32c3/lib/libesp_eth.a index ad601b37996..ea67fb03a6d 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_eth.a and b/tools/sdk/esp32c3/lib/libesp_eth.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_event.a b/tools/sdk/esp32c3/lib/libesp_event.a index 9573e95d9f2..1b98e7a6d3b 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_event.a and b/tools/sdk/esp32c3/lib/libesp_event.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_hid.a b/tools/sdk/esp32c3/lib/libesp_hid.a index 033951a646e..3669216cfdc 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_hid.a and b/tools/sdk/esp32c3/lib/libesp_hid.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_http_client.a b/tools/sdk/esp32c3/lib/libesp_http_client.a index 3dcbe1a875b..d39a2824db7 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_http_client.a and b/tools/sdk/esp32c3/lib/libesp_http_client.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_http_server.a b/tools/sdk/esp32c3/lib/libesp_http_server.a index 523ab6dbd24..4df24fd3d21 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_http_server.a and b/tools/sdk/esp32c3/lib/libesp_http_server.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_https_ota.a b/tools/sdk/esp32c3/lib/libesp_https_ota.a index 2b54a483253..8411cb47918 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_https_ota.a and b/tools/sdk/esp32c3/lib/libesp_https_ota.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_https_server.a b/tools/sdk/esp32c3/lib/libesp_https_server.a index eeb1975d0d5..4b9a3155cc5 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_https_server.a and b/tools/sdk/esp32c3/lib/libesp_https_server.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_lcd.a b/tools/sdk/esp32c3/lib/libesp_lcd.a index a9581fce40b..0dd472e63cd 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_lcd.a and b/tools/sdk/esp32c3/lib/libesp_lcd.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_littlefs.a b/tools/sdk/esp32c3/lib/libesp_littlefs.a index 055bca7bf4b..db9c6153384 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_littlefs.a and b/tools/sdk/esp32c3/lib/libesp_littlefs.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_local_ctrl.a b/tools/sdk/esp32c3/lib/libesp_local_ctrl.a index 7ea3a6570ea..3412bd87801 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_local_ctrl.a and b/tools/sdk/esp32c3/lib/libesp_local_ctrl.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_netif.a b/tools/sdk/esp32c3/lib/libesp_netif.a index e42710cf312..27b3cbaaef5 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_netif.a and b/tools/sdk/esp32c3/lib/libesp_netif.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_phy.a b/tools/sdk/esp32c3/lib/libesp_phy.a index 1ef12e78fc3..91ad3870504 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_phy.a and b/tools/sdk/esp32c3/lib/libesp_phy.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_pm.a b/tools/sdk/esp32c3/lib/libesp_pm.a index c383d578454..64d9a294010 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_pm.a and b/tools/sdk/esp32c3/lib/libesp_pm.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_rainmaker.a b/tools/sdk/esp32c3/lib/libesp_rainmaker.a index bd120aaaeaf..fbe313e37e7 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_rainmaker.a and b/tools/sdk/esp32c3/lib/libesp_rainmaker.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_ringbuf.a b/tools/sdk/esp32c3/lib/libesp_ringbuf.a index 28347bd955c..3e77252d25f 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_ringbuf.a and b/tools/sdk/esp32c3/lib/libesp_ringbuf.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_schedule.a b/tools/sdk/esp32c3/lib/libesp_schedule.a index 7278ff578a5..eac19120c06 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_schedule.a and b/tools/sdk/esp32c3/lib/libesp_schedule.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_serial_slave_link.a b/tools/sdk/esp32c3/lib/libesp_serial_slave_link.a index e74a90fb5cb..3fa3bd7c9da 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_serial_slave_link.a and b/tools/sdk/esp32c3/lib/libesp_serial_slave_link.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_timer.a b/tools/sdk/esp32c3/lib/libesp_timer.a index c9cdf87e335..1052ed6e68d 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_timer.a and b/tools/sdk/esp32c3/lib/libesp_timer.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_websocket_client.a b/tools/sdk/esp32c3/lib/libesp_websocket_client.a index a320ea6bd60..2ae33d61de1 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_websocket_client.a and b/tools/sdk/esp32c3/lib/libesp_websocket_client.a differ diff --git a/tools/sdk/esp32c3/lib/libesp_wifi.a b/tools/sdk/esp32c3/lib/libesp_wifi.a index a8d464f85ef..ffb538be99e 100644 Binary files a/tools/sdk/esp32c3/lib/libesp_wifi.a and b/tools/sdk/esp32c3/lib/libesp_wifi.a differ diff --git a/tools/sdk/esp32c3/lib/libespcoredump.a b/tools/sdk/esp32c3/lib/libespcoredump.a index 9e25502abb7..2257bd5506f 100644 Binary files a/tools/sdk/esp32c3/lib/libespcoredump.a and b/tools/sdk/esp32c3/lib/libespcoredump.a differ diff --git a/tools/sdk/esp32c3/lib/libespnow.a b/tools/sdk/esp32c3/lib/libespnow.a index a7f9979d790..7929af06416 100644 Binary files a/tools/sdk/esp32c3/lib/libespnow.a and b/tools/sdk/esp32c3/lib/libespnow.a differ diff --git a/tools/sdk/esp32c3/lib/libfatfs.a b/tools/sdk/esp32c3/lib/libfatfs.a index b3f15c73545..ab2c8beba10 100644 Binary files a/tools/sdk/esp32c3/lib/libfatfs.a and b/tools/sdk/esp32c3/lib/libfatfs.a differ diff --git a/tools/sdk/esp32c3/lib/libfreemodbus.a b/tools/sdk/esp32c3/lib/libfreemodbus.a index 4968041ddc2..01f5f6d168b 100644 Binary files a/tools/sdk/esp32c3/lib/libfreemodbus.a and b/tools/sdk/esp32c3/lib/libfreemodbus.a differ diff --git a/tools/sdk/esp32c3/lib/libhal.a b/tools/sdk/esp32c3/lib/libhal.a index e0eca21289e..c2963ed41ee 100644 Binary files a/tools/sdk/esp32c3/lib/libhal.a and b/tools/sdk/esp32c3/lib/libhal.a differ diff --git a/tools/sdk/esp32c3/lib/libheap.a b/tools/sdk/esp32c3/lib/libheap.a index 090992655a1..96f6377509d 100644 Binary files a/tools/sdk/esp32c3/lib/libheap.a and b/tools/sdk/esp32c3/lib/libheap.a differ diff --git a/tools/sdk/esp32c3/lib/libjson_generator.a b/tools/sdk/esp32c3/lib/libjson_generator.a index c7cdcde993c..c0b35b7cd41 100644 Binary files a/tools/sdk/esp32c3/lib/libjson_generator.a and b/tools/sdk/esp32c3/lib/libjson_generator.a differ diff --git a/tools/sdk/esp32c3/lib/libjson_parser.a b/tools/sdk/esp32c3/lib/libjson_parser.a index 68670bc58e0..c2ea9008db3 100644 Binary files a/tools/sdk/esp32c3/lib/libjson_parser.a and b/tools/sdk/esp32c3/lib/libjson_parser.a differ diff --git a/tools/sdk/esp32c3/lib/liblog.a b/tools/sdk/esp32c3/lib/liblog.a index cc1292173d4..0aa3978cf1a 100644 Binary files a/tools/sdk/esp32c3/lib/liblog.a and b/tools/sdk/esp32c3/lib/liblog.a differ diff --git a/tools/sdk/esp32c3/lib/liblwip.a b/tools/sdk/esp32c3/lib/liblwip.a index 46caaf3ccc6..e4726c8d2bb 100644 Binary files a/tools/sdk/esp32c3/lib/liblwip.a and b/tools/sdk/esp32c3/lib/liblwip.a differ diff --git a/tools/sdk/esp32c3/lib/libmbedcrypto.a b/tools/sdk/esp32c3/lib/libmbedcrypto.a index 6dae7ca738e..a9bf9ce3342 100644 Binary files a/tools/sdk/esp32c3/lib/libmbedcrypto.a and b/tools/sdk/esp32c3/lib/libmbedcrypto.a differ diff --git a/tools/sdk/esp32c3/lib/libmbedtls.a b/tools/sdk/esp32c3/lib/libmbedtls.a index d2a7c410cbc..d9756059a16 100644 Binary files a/tools/sdk/esp32c3/lib/libmbedtls.a and b/tools/sdk/esp32c3/lib/libmbedtls.a differ diff --git a/tools/sdk/esp32c3/lib/libmbedtls_2.a b/tools/sdk/esp32c3/lib/libmbedtls_2.a new file mode 100644 index 00000000000..58fe49256b3 Binary files /dev/null and b/tools/sdk/esp32c3/lib/libmbedtls_2.a differ diff --git a/tools/sdk/esp32c3/lib/libmdns.a b/tools/sdk/esp32c3/lib/libmdns.a index d76692fa24c..cc619407cc3 100644 Binary files a/tools/sdk/esp32c3/lib/libmdns.a and b/tools/sdk/esp32c3/lib/libmdns.a differ diff --git a/tools/sdk/esp32c3/lib/libmesh.a b/tools/sdk/esp32c3/lib/libmesh.a index 374c15e39da..f7eae718745 100644 Binary files a/tools/sdk/esp32c3/lib/libmesh.a and b/tools/sdk/esp32c3/lib/libmesh.a differ diff --git a/tools/sdk/esp32c3/lib/libmqtt.a b/tools/sdk/esp32c3/lib/libmqtt.a index f740ecfa89c..f9d149b26cc 100644 Binary files a/tools/sdk/esp32c3/lib/libmqtt.a and b/tools/sdk/esp32c3/lib/libmqtt.a differ diff --git a/tools/sdk/esp32c3/lib/libnet80211.a b/tools/sdk/esp32c3/lib/libnet80211.a index 79f5d023239..ca9ca9f2eb8 100644 Binary files a/tools/sdk/esp32c3/lib/libnet80211.a and b/tools/sdk/esp32c3/lib/libnet80211.a differ diff --git a/tools/sdk/esp32c3/lib/libnewlib.a b/tools/sdk/esp32c3/lib/libnewlib.a index 4613a52862c..cc6f41b4196 100644 Binary files a/tools/sdk/esp32c3/lib/libnewlib.a and b/tools/sdk/esp32c3/lib/libnewlib.a differ diff --git a/tools/sdk/esp32c3/lib/libnvs_flash.a b/tools/sdk/esp32c3/lib/libnvs_flash.a index ba7a873e35e..11bca602515 100644 Binary files a/tools/sdk/esp32c3/lib/libnvs_flash.a and b/tools/sdk/esp32c3/lib/libnvs_flash.a differ diff --git a/tools/sdk/esp32c3/lib/libopenssl.a b/tools/sdk/esp32c3/lib/libopenssl.a index 2dd80eb001e..b77d1733eaa 100644 Binary files a/tools/sdk/esp32c3/lib/libopenssl.a and b/tools/sdk/esp32c3/lib/libopenssl.a differ diff --git a/tools/sdk/esp32c3/lib/libpp.a b/tools/sdk/esp32c3/lib/libpp.a index 38b5403a3a1..ff9a6ac8835 100644 Binary files a/tools/sdk/esp32c3/lib/libpp.a and b/tools/sdk/esp32c3/lib/libpp.a differ diff --git a/tools/sdk/esp32c3/lib/libprotobuf-c.a b/tools/sdk/esp32c3/lib/libprotobuf-c.a index a5d0a4cb6eb..581d8721225 100644 Binary files a/tools/sdk/esp32c3/lib/libprotobuf-c.a and b/tools/sdk/esp32c3/lib/libprotobuf-c.a differ diff --git a/tools/sdk/esp32c3/lib/libprotocomm.a b/tools/sdk/esp32c3/lib/libprotocomm.a index 17ae2661139..75b28a32118 100644 Binary files a/tools/sdk/esp32c3/lib/libprotocomm.a and b/tools/sdk/esp32c3/lib/libprotocomm.a differ diff --git a/tools/sdk/esp32c3/lib/libpthread.a b/tools/sdk/esp32c3/lib/libpthread.a index d1e8fe62266..1a85b9ccc6d 100644 Binary files a/tools/sdk/esp32c3/lib/libpthread.a and b/tools/sdk/esp32c3/lib/libpthread.a differ diff --git a/tools/sdk/esp32c3/lib/libriscv.a b/tools/sdk/esp32c3/lib/libriscv.a index 5047dea84cf..f09486c488a 100644 Binary files a/tools/sdk/esp32c3/lib/libriscv.a and b/tools/sdk/esp32c3/lib/libriscv.a differ diff --git a/tools/sdk/esp32c3/lib/librmaker_common.a b/tools/sdk/esp32c3/lib/librmaker_common.a index 89b4a89740e..8e992ab391c 100644 Binary files a/tools/sdk/esp32c3/lib/librmaker_common.a and b/tools/sdk/esp32c3/lib/librmaker_common.a differ diff --git a/tools/sdk/esp32c3/lib/libsdmmc.a b/tools/sdk/esp32c3/lib/libsdmmc.a index 963c18c2c46..5bbbba55c4e 100644 Binary files a/tools/sdk/esp32c3/lib/libsdmmc.a and b/tools/sdk/esp32c3/lib/libsdmmc.a differ diff --git a/tools/sdk/esp32c3/lib/libsmartconfig.a b/tools/sdk/esp32c3/lib/libsmartconfig.a index 0131901e9e2..549abcacb1e 100644 Binary files a/tools/sdk/esp32c3/lib/libsmartconfig.a and b/tools/sdk/esp32c3/lib/libsmartconfig.a differ diff --git a/tools/sdk/esp32c3/lib/libspiffs.a b/tools/sdk/esp32c3/lib/libspiffs.a index a57ec9a1277..1e6adf65a9a 100644 Binary files a/tools/sdk/esp32c3/lib/libspiffs.a and b/tools/sdk/esp32c3/lib/libspiffs.a differ diff --git a/tools/sdk/esp32c3/lib/libtcp_transport.a b/tools/sdk/esp32c3/lib/libtcp_transport.a index 2765273157a..b839848d1a5 100644 Binary files a/tools/sdk/esp32c3/lib/libtcp_transport.a and b/tools/sdk/esp32c3/lib/libtcp_transport.a differ diff --git a/tools/sdk/esp32c3/lib/libunity.a b/tools/sdk/esp32c3/lib/libunity.a index 81dc03d430c..214b6d15b86 100644 Binary files a/tools/sdk/esp32c3/lib/libunity.a and b/tools/sdk/esp32c3/lib/libunity.a differ diff --git a/tools/sdk/esp32c3/lib/libvfs.a b/tools/sdk/esp32c3/lib/libvfs.a index 92b59631503..5d80d73d408 100644 Binary files a/tools/sdk/esp32c3/lib/libvfs.a and b/tools/sdk/esp32c3/lib/libvfs.a differ diff --git a/tools/sdk/esp32c3/lib/libwapi.a b/tools/sdk/esp32c3/lib/libwapi.a index 5904a44751b..ea52593fac8 100644 Binary files a/tools/sdk/esp32c3/lib/libwapi.a and b/tools/sdk/esp32c3/lib/libwapi.a differ diff --git a/tools/sdk/esp32c3/lib/libwifi_provisioning.a b/tools/sdk/esp32c3/lib/libwifi_provisioning.a index 3966dda1d28..82865f6f989 100644 Binary files a/tools/sdk/esp32c3/lib/libwifi_provisioning.a and b/tools/sdk/esp32c3/lib/libwifi_provisioning.a differ diff --git a/tools/sdk/esp32c3/lib/libwpa_supplicant.a b/tools/sdk/esp32c3/lib/libwpa_supplicant.a index 57f8268de39..51ff4670ccb 100644 Binary files a/tools/sdk/esp32c3/lib/libwpa_supplicant.a and b/tools/sdk/esp32c3/lib/libwpa_supplicant.a differ diff --git a/tools/sdk/esp32c3/qspi_qspi/include/sdkconfig.h b/tools/sdk/esp32c3/qspi_qspi/include/sdkconfig.h index 750b6236242..0f3d633fb8a 100644 --- a/tools/sdk/esp32c3/qspi_qspi/include/sdkconfig.h +++ b/tools/sdk/esp32c3/qspi_qspi/include/sdkconfig.h @@ -20,9 +20,11 @@ #define CONFIG_BOOTLOADER_LOG_LEVEL_NONE 1 #define CONFIG_BOOTLOADER_LOG_LEVEL 0 #define CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_9V 1 +#define CONFIG_BOOTLOADER_REGION_PROTECTION_ENABLE 1 #define CONFIG_BOOTLOADER_WDT_ENABLE 1 #define CONFIG_BOOTLOADER_WDT_TIME_MS 9000 -#define CONFIG_BOOTLOADER_RESERVE_RTC_SIZE 0x0 +#define CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP 1 +#define CONFIG_BOOTLOADER_RESERVE_RTC_SIZE 0x10 #define CONFIG_BOOTLOADER_FLASH_XMC_SUPPORT 1 #define CONFIG_SECURE_BOOT_SUPPORTS_RSA 1 #define CONFIG_SECURE_TARGET_HAS_SECURE_ROM_DL_MODE 1 @@ -33,8 +35,8 @@ #define CONFIG_ESPTOOLPY_FLASHMODE "dio" #define CONFIG_ESPTOOLPY_FLASHFREQ_80M 1 #define CONFIG_ESPTOOLPY_FLASHFREQ "80m" -#define CONFIG_ESPTOOLPY_FLASHSIZE_2MB 1 -#define CONFIG_ESPTOOLPY_FLASHSIZE "2MB" +#define CONFIG_ESPTOOLPY_FLASHSIZE_4MB 1 +#define CONFIG_ESPTOOLPY_FLASHSIZE "4MB" #define CONFIG_ESPTOOLPY_FLASHSIZE_DETECT 1 #define CONFIG_ESPTOOLPY_BEFORE_RESET 1 #define CONFIG_ESPTOOLPY_BEFORE "default_reset" @@ -50,12 +52,14 @@ #define CONFIG_PARTITION_TABLE_MD5 1 #define CONFIG_LIB_BUILDER_FLASHMODE "qio" #define CONFIG_LIB_BUILDER_FLASHFREQ "80m" -#define CONFIG_ESP_RMAKER_ASSISTED_CLAIM 1 -#define CONFIG_ESP_RMAKER_CLAIM_TYPE 2 +#define CONFIG_ESP_RMAKER_SELF_CLAIM 1 +#define CONFIG_ESP_RMAKER_CLAIM_TYPE 1 +#define CONFIG_ESP_RMAKER_CLAIM_SERVICE_BASE_URL "https://esp-claiming.rainmaker.espressif.com" #define CONFIG_ESP_RMAKER_MQTT_HOST "a1p72mufdu6064-ats.iot.us-east-1.amazonaws.com" #define CONFIG_ESP_RMAKER_MAX_PARAM_DATA_SIZE 1024 #define CONFIG_ESP_RMAKER_CONSOLE_UART_NUM_0 1 #define CONFIG_ESP_RMAKER_CONSOLE_UART_NUM 0 +#define CONFIG_ESP_RMAKER_USE_CERT_BUNDLE 1 #define CONFIG_ESP_RMAKER_OTA_AUTOFETCH 1 #define CONFIG_ESP_RMAKER_OTA_AUTOFETCH_PERIOD 0 #define CONFIG_ESP_RMAKER_OTA_HTTP_RX_BUFFER_SIZE 1024 @@ -68,11 +72,16 @@ #define CONFIG_ARDUINO_LOOP_STACK_SIZE 8192 #define CONFIG_ARDUINO_EVENT_RUN_CORE0 1 #define CONFIG_ARDUINO_EVENT_RUNNING_CORE 0 +#define CONFIG_ARDUINO_SERIAL_EVENT_RUN_CORE0 1 +#define CONFIG_ARDUINO_SERIAL_EVENT_TASK_RUNNING_CORE 0 +#define CONFIG_ARDUINO_SERIAL_EVENT_TASK_STACK_SIZE 2048 +#define CONFIG_ARDUINO_SERIAL_EVENT_TASK_PRIORITY 24 #define CONFIG_ARDUINO_UDP_RUN_CORE0 1 -#define CONFIG_ARDUINO_UDP_TASK_PRIORITY 3 #define CONFIG_ARDUINO_UDP_RUNNING_CORE 0 +#define CONFIG_ARDUINO_UDP_TASK_PRIORITY 3 #define CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL_ERROR 1 #define CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL 1 +#define CONFIG_ARDUHAL_ESP_LOG 1 #define CONFIG_ARDUHAL_PARTITION_SCHEME_DEFAULT 1 #define CONFIG_ARDUHAL_PARTITION_SCHEME "default" #define CONFIG_COMPILER_OPTIMIZATION_SIZE 1 @@ -113,6 +122,8 @@ #define CONFIG_BT_CTRL_SCAN_DUPL_TYPE_DEVICE 1 #define CONFIG_BT_CTRL_SCAN_DUPL_TYPE 0 #define CONFIG_BT_CTRL_SCAN_DUPL_CACHE_SIZE 100 +#define CONFIG_BT_CTRL_BLE_MESH_SCAN_DUPL_EN 1 +#define CONFIG_BT_CTRL_MESH_DUPL_SCAN_CACHE_SIZE 100 #define CONFIG_BT_CTRL_COEX_PHY_CODED_TX_RX_TLIM_DIS 1 #define CONFIG_BT_CTRL_COEX_PHY_CODED_TX_RX_TLIM_EFF 0 #define CONFIG_BT_CTRL_SLEEP_MODE_EFF 0 @@ -180,11 +191,41 @@ #define CONFIG_BT_BLE_RPA_SUPPORTED 1 #define CONFIG_BT_BLE_50_FEATURES_SUPPORTED 1 #define CONFIG_BT_BLE_42_FEATURES_SUPPORTED 1 +#define CONFIG_BLE_MESH 1 +#define CONFIG_BLE_MESH_HCI_5_0 1 +#define CONFIG_BLE_MESH_USE_DUPLICATE_SCAN 1 +#define CONFIG_BLE_MESH_MEM_ALLOC_MODE_INTERNAL 1 +#define CONFIG_BLE_MESH_DEINIT 1 +#define CONFIG_BLE_MESH_PROV 1 +#define CONFIG_BLE_MESH_PB_ADV 1 +#define CONFIG_BLE_MESH_PROXY 1 +#define CONFIG_BLE_MESH_NET_BUF_POOL_USAGE 1 +#define CONFIG_BLE_MESH_SUBNET_COUNT 3 +#define CONFIG_BLE_MESH_APP_KEY_COUNT 3 +#define CONFIG_BLE_MESH_MODEL_KEY_COUNT 3 +#define CONFIG_BLE_MESH_MODEL_GROUP_COUNT 3 +#define CONFIG_BLE_MESH_LABEL_COUNT 3 +#define CONFIG_BLE_MESH_CRPL 10 +#define CONFIG_BLE_MESH_MSG_CACHE_SIZE 10 +#define CONFIG_BLE_MESH_ADV_BUF_COUNT 60 +#define CONFIG_BLE_MESH_IVU_DIVIDER 4 +#define CONFIG_BLE_MESH_TX_SEG_MSG_COUNT 1 +#define CONFIG_BLE_MESH_RX_SEG_MSG_COUNT 1 +#define CONFIG_BLE_MESH_RX_SDU_MAX 384 +#define CONFIG_BLE_MESH_TX_SEG_MAX 32 +#define CONFIG_BLE_MESH_TRACE_LEVEL_WARNING 1 +#define CONFIG_BLE_MESH_STACK_TRACE_LEVEL 2 +#define CONFIG_BLE_MESH_NET_BUF_TRACE_LEVEL_WARNING 1 +#define CONFIG_BLE_MESH_NET_BUF_TRACE_LEVEL 2 +#define CONFIG_BLE_MESH_CLIENT_MSG_TIMEOUT 4000 +#define CONFIG_BLE_MESH_HEALTH_SRV 1 +#define CONFIG_BLE_MESH_GENERIC_SERVER 1 +#define CONFIG_BLE_MESH_SENSOR_SERVER 1 +#define CONFIG_BLE_MESH_TIME_SCENE_SERVER 1 +#define CONFIG_BLE_MESH_LIGHTING_SERVER 1 #define CONFIG_COAP_MBEDTLS_PSK 1 #define CONFIG_COAP_LOG_DEFAULT_LEVEL 0 #define CONFIG_ADC_DISABLE_DAC 1 -#define CONFIG_SPI_MASTER_ISR_IN_IRAM 1 -#define CONFIG_SPI_SLAVE_ISR_IN_IRAM 1 #define CONFIG_EFUSE_MAX_BLK_LEN 256 #define CONFIG_ESP_TLS_USING_MBEDTLS 1 #define CONFIG_ESP_TLS_USE_DS_PERIPHERAL 1 @@ -203,9 +244,12 @@ #define CONFIG_ESP_ERR_TO_NAME_LOOKUP 1 #define CONFIG_ETH_ENABLED 1 #define CONFIG_ETH_USE_SPI_ETHERNET 1 +#define CONFIG_ETH_SPI_ETHERNET_DM9051 1 +#define CONFIG_ETH_SPI_ETHERNET_W5500 1 #define CONFIG_ESP_EVENT_POST_FROM_ISR 1 #define CONFIG_ESP_EVENT_POST_FROM_IRAM_ISR 1 #define CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS 1 +#define CONFIG_ESP_HTTP_CLIENT_ENABLE_BASIC_AUTH 1 #define CONFIG_ESP_HTTP_CLIENT_ENABLE_DIGEST_AUTH 1 #define CONFIG_HTTPD_MAX_REQ_HDR_LEN 1024 #define CONFIG_HTTPD_MAX_URI_LEN 512 @@ -242,8 +286,8 @@ #define CONFIG_ESP_SYSTEM_MEMPROT_CPU_PREFETCH_PAD_SIZE 16 #define CONFIG_ESP_SYSTEM_MEMPROT_MEM_ALIGN_SIZE 512 #define CONFIG_ESP_SYSTEM_EVENT_QUEUE_SIZE 32 -#define CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE 2304 -#define CONFIG_ESP_MAIN_TASK_STACK_SIZE 3584 +#define CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE 2048 +#define CONFIG_ESP_MAIN_TASK_STACK_SIZE 4096 #define CONFIG_ESP_MAIN_TASK_AFFINITY_CPU0 1 #define CONFIG_ESP_MAIN_TASK_AFFINITY 0x0 #define CONFIG_ESP_MINIMAL_SHARED_STACK_SIZE 2048 @@ -255,21 +299,22 @@ #define CONFIG_ESP_INT_WDT 1 #define CONFIG_ESP_INT_WDT_TIMEOUT_MS 300 #define CONFIG_ESP_TASK_WDT 1 +#define CONFIG_ESP_TASK_WDT_PANIC 1 #define CONFIG_ESP_TASK_WDT_TIMEOUT_S 5 -#define CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0 1 #define CONFIG_ESP_SYSTEM_CHECK_INT_LEVEL_4 1 #define CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER 1 #define CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER 1 -#define CONFIG_ESP_TIMER_TASK_STACK_SIZE 3584 +#define CONFIG_ESP_TIMER_TASK_STACK_SIZE 4096 #define CONFIG_ESP_TIMER_INTERRUPT_LEVEL 1 #define CONFIG_ESP_TIMER_IMPL_SYSTIMER 1 #define CONFIG_ESP32_WIFI_ENABLED 1 #define CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE 1 -#define CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM 10 +#define CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM 8 #define CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM 32 #define CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER 1 #define CONFIG_ESP32_WIFI_TX_BUFFER_TYPE 1 #define CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM 32 +#define CONFIG_ESP32_WIFI_CSI_ENABLED 1 #define CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED 1 #define CONFIG_ESP32_WIFI_TX_BA_WIN 6 #define CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED 1 @@ -283,9 +328,9 @@ #define CONFIG_ESP_WIFI_FTM_RESPONDER_SUPPORT 1 #define CONFIG_ESP_WIFI_SOFTAP_SUPPORT 1 #define CONFIG_ESP_COREDUMP_ENABLE_TO_NONE 1 -#define CONFIG_FATFS_CODEPAGE_437 1 -#define CONFIG_FATFS_CODEPAGE 437 -#define CONFIG_FATFS_LFN_HEAP 1 +#define CONFIG_FATFS_CODEPAGE_850 1 +#define CONFIG_FATFS_CODEPAGE 850 +#define CONFIG_FATFS_LFN_STACK 1 #define CONFIG_FATFS_MAX_LFN 255 #define CONFIG_FATFS_API_ENCODING_ANSI_OEM 1 #define CONFIG_FATFS_FS_LOCK 0 @@ -306,8 +351,6 @@ #define CONFIG_FMB_SERIAL_ASCII_TIMEOUT_RESPOND_MS 1000 #define CONFIG_FMB_PORT_TASK_PRIO 10 #define CONFIG_FMB_PORT_TASK_AFFINITY 0x7FFFFFFF -#define CONFIG_FMB_CONTROLLER_SLAVE_ID_SUPPORT 1 -#define CONFIG_FMB_CONTROLLER_SLAVE_ID 0x00112233 #define CONFIG_FMB_CONTROLLER_NOTIFY_TIMEOUT 20 #define CONFIG_FMB_CONTROLLER_NOTIFY_QUEUE_SIZE 20 #define CONFIG_FMB_CONTROLLER_STACK_SIZE 4096 @@ -324,8 +367,8 @@ #define CONFIG_FREERTOS_SYSTICK_USES_SYSTIMER 1 #define CONFIG_FREERTOS_OPTIMIZED_SCHEDULER 1 #define CONFIG_FREERTOS_HZ 1000 -#define CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION 1 #define CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY 1 +#define CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK 1 #define CONFIG_FREERTOS_INTERRUPT_BACKTRACE 1 #define CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS 1 #define CONFIG_FREERTOS_ASSERT_FAIL_ABORT 1 @@ -342,7 +385,7 @@ #define CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT 1 #define CONFIG_HAL_ASSERTION_EQUALS_SYSTEM 1 #define CONFIG_HAL_DEFAULT_ASSERTION_LEVEL 2 -#define CONFIG_HEAP_POISONING_DISABLED 1 +#define CONFIG_HEAP_POISONING_LIGHT 1 #define CONFIG_HEAP_TRACING_OFF 1 #define CONFIG_LOG_DEFAULT_LEVEL_ERROR 1 #define CONFIG_LOG_DEFAULT_LEVEL 1 @@ -358,10 +401,10 @@ #define CONFIG_LWIP_SO_RCVBUF 1 #define CONFIG_LWIP_IP4_FRAG 1 #define CONFIG_LWIP_IP6_FRAG 1 +#define CONFIG_LWIP_ETHARP_TRUST_IP_MAC 1 #define CONFIG_LWIP_ESP_GRATUITOUS_ARP 1 #define CONFIG_LWIP_GARP_TMR_INTERVAL 60 #define CONFIG_LWIP_TCPIP_RECVMBOX_SIZE 32 -#define CONFIG_LWIP_DHCP_DOES_ARP_CHECK 1 #define CONFIG_LWIP_DHCP_DISABLE_VENDOR_CLASS_ID 1 #define CONFIG_LWIP_DHCP_RESTORE_LAST_IP 1 #define CONFIG_LWIP_DHCP_OPTIONS_LEN 128 @@ -369,15 +412,17 @@ #define CONFIG_LWIP_DHCPS_LEASE_UNIT 60 #define CONFIG_LWIP_DHCPS_MAX_STATION_NUM 8 #define CONFIG_LWIP_IPV6 1 +#define CONFIG_LWIP_IPV6_AUTOCONFIG 1 #define CONFIG_LWIP_IPV6_NUM_ADDRESSES 3 +#define CONFIG_LWIP_IPV6_RDNSS_MAX_DNS_SERVERS 0 #define CONFIG_LWIP_NETIF_LOOPBACK 1 #define CONFIG_LWIP_LOOPBACK_MAX_PBUFS 8 #define CONFIG_LWIP_MAX_ACTIVE_TCP 16 #define CONFIG_LWIP_MAX_LISTENING_TCP 16 #define CONFIG_LWIP_TCP_HIGH_SPEED_RETRANSMISSION 1 #define CONFIG_LWIP_TCP_MAXRTX 12 -#define CONFIG_LWIP_TCP_SYNMAXRTX 12 -#define CONFIG_LWIP_TCP_MSS 1440 +#define CONFIG_LWIP_TCP_SYNMAXRTX 6 +#define CONFIG_LWIP_TCP_MSS 1436 #define CONFIG_LWIP_TCP_TMR_INTERVAL 250 #define CONFIG_LWIP_TCP_MSL 60000 #define CONFIG_LWIP_TCP_SND_BUF_DEFAULT 5744 @@ -385,13 +430,13 @@ #define CONFIG_LWIP_TCP_RECVMBOX_SIZE 6 #define CONFIG_LWIP_TCP_QUEUE_OOSEQ 1 #define CONFIG_LWIP_TCP_OVERSIZE_MSS 1 -#define CONFIG_LWIP_TCP_RTO_TIME 1500 +#define CONFIG_LWIP_TCP_RTO_TIME 3000 #define CONFIG_LWIP_MAX_UDP_PCBS 16 #define CONFIG_LWIP_UDP_RECVMBOX_SIZE 6 #define CONFIG_LWIP_CHECKSUM_CHECK_ICMP 1 -#define CONFIG_LWIP_TCPIP_TASK_STACK_SIZE 3072 -#define CONFIG_LWIP_TCPIP_TASK_AFFINITY_NO_AFFINITY 1 -#define CONFIG_LWIP_TCPIP_TASK_AFFINITY 0x7FFFFFFF +#define CONFIG_LWIP_TCPIP_TASK_STACK_SIZE 2560 +#define CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU0 1 +#define CONFIG_LWIP_TCPIP_TASK_AFFINITY 0x0 #define CONFIG_LWIP_IPV6_MEMP_NUM_ND6_QUEUE 3 #define CONFIG_LWIP_IPV6_ND6_NUM_NEIGHBORS 5 #define CONFIG_LWIP_ICMP 1 @@ -399,19 +444,18 @@ #define CONFIG_LWIP_SNTP_MAX_SERVERS 3 #define CONFIG_LWIP_DHCP_GET_NTP_SRV 1 #define CONFIG_LWIP_DHCP_MAX_NTP_SERVERS 1 -#define CONFIG_LWIP_SNTP_UPDATE_DELAY 3600000 +#define CONFIG_LWIP_SNTP_UPDATE_DELAY 10800000 #define CONFIG_LWIP_ESP_LWIP_ASSERT 1 #define CONFIG_LWIP_HOOK_TCP_ISN_DEFAULT 1 #define CONFIG_LWIP_HOOK_IP6_ROUTE_NONE 1 #define CONFIG_LWIP_HOOK_ND6_GET_GW_NONE 1 #define CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_NONE 1 #define CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC 1 -#define CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN 1 -#define CONFIG_MBEDTLS_SSL_IN_CONTENT_LEN 16384 -#define CONFIG_MBEDTLS_SSL_OUT_CONTENT_LEN 4096 +#define CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN 16384 #define CONFIG_MBEDTLS_SSL_KEEP_PEER_CERTIFICATE 1 #define CONFIG_MBEDTLS_CERTIFICATE_BUNDLE 1 #define CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL 1 +#define CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS 200 #define CONFIG_MBEDTLS_HARDWARE_AES 1 #define CONFIG_MBEDTLS_AES_USE_INTERRUPT 1 #define CONFIG_MBEDTLS_HARDWARE_MPI 1 @@ -440,6 +484,7 @@ #define CONFIG_MBEDTLS_SSL_PROTO_TLS1 1 #define CONFIG_MBEDTLS_SSL_PROTO_TLS1_1 1 #define CONFIG_MBEDTLS_SSL_PROTO_TLS1_2 1 +#define CONFIG_MBEDTLS_SSL_PROTO_DTLS 1 #define CONFIG_MBEDTLS_SSL_ALPN 1 #define CONFIG_MBEDTLS_CLIENT_SSL_SESSION_TICKETS 1 #define CONFIG_MBEDTLS_X509_CHECK_KEY_USAGE 1 @@ -486,18 +531,18 @@ #define CONFIG_NEWLIB_STDOUT_LINE_ENDING_CRLF 1 #define CONFIG_NEWLIB_STDIN_LINE_ENDING_CR 1 #define CONFIG_OPENSSL_ERROR_STACK 1 -#define CONFIG_OPENSSL_ASSERT_EXIT 1 +#define CONFIG_OPENSSL_ASSERT_DO_NOTHING 1 #define CONFIG_PTHREAD_TASK_PRIO_DEFAULT 5 -#define CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT 3072 +#define CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT 2048 #define CONFIG_PTHREAD_STACK_MIN 768 #define CONFIG_PTHREAD_TASK_CORE_DEFAULT -1 #define CONFIG_PTHREAD_TASK_NAME_DEFAULT "pthread" #define CONFIG_SPI_FLASH_ROM_DRIVER_PATCH 1 #define CONFIG_SPI_FLASH_DANGEROUS_WRITE_ABORTS 1 #define CONFIG_SPI_FLASH_YIELD_DURING_ERASE 1 -#define CONFIG_SPI_FLASH_ERASE_YIELD_DURATION_MS 20 -#define CONFIG_SPI_FLASH_ERASE_YIELD_TICKS 1 -#define CONFIG_SPI_FLASH_WRITE_CHUNK_SIZE 8192 +#define CONFIG_SPI_FLASH_ERASE_YIELD_DURATION_MS 10 +#define CONFIG_SPI_FLASH_ERASE_YIELD_TICKS 2 +#define CONFIG_SPI_FLASH_WRITE_CHUNK_SIZE 4096 #define CONFIG_SPI_FLASH_SUPPORT_ISSI_CHIP 1 #define CONFIG_SPI_FLASH_SUPPORT_MXIC_CHIP 1 #define CONFIG_SPI_FLASH_SUPPORT_GD_CHIP 1 @@ -527,11 +572,11 @@ #define CONFIG_VFS_SUPPRESS_SELECT_DEBUG_OUTPUT 1 #define CONFIG_VFS_SUPPORT_TERMIOS 1 #define CONFIG_VFS_SEMIHOSTFS_MAX_MOUNT_POINTS 1 -#define CONFIG_VFS_SEMIHOSTFS_HOST_PATH_MAX_LEN 128 #define CONFIG_WL_SECTOR_SIZE_4096 1 #define CONFIG_WL_SECTOR_SIZE 4096 #define CONFIG_WIFI_PROV_SCAN_MAX_ENTRIES 16 #define CONFIG_WIFI_PROV_AUTOSTOP_TIMEOUT 30 +#define CONFIG_WIFI_PROV_BLE_BONDING 1 #define CONFIG_WPA_MBEDTLS_CRYPTO 1 #define CONFIG_IO_GLITCH_FILTER_TIME_MS 50 #define CONFIG_ESP_RMAKER_LIB_ESP_MQTT 1 @@ -539,7 +584,10 @@ #define CONFIG_ESP_RMAKER_MQTT_PORT_443 1 #define CONFIG_ESP_RMAKER_MQTT_PORT 1 #define CONFIG_ESP_RMAKER_MQTT_SEND_USERNAME 1 -#define CONFIG_ESP_RMAKER_MQTT_USERNAME "?Platform=APN/1 ESPIF,RAINMAKER,v1.0" +#define CONFIG_ESP_RMAKER_MQTT_PRODUCT_NAME "RMDev" +#define CONFIG_ESP_RMAKER_MQTT_PRODUCT_VERSION "1x0" +#define CONFIG_ESP_RMAKER_MQTT_PRODUCT_SKU "ES00" +#define CONFIG_ESP_RMAKER_MQTT_USE_CERT_BUNDLE 1 #define CONFIG_ESP_RMAKER_WORK_QUEUE_TASK_STACK 4096 #define CONFIG_ESP_RMAKER_WORK_QUEUE_TASK_PRIORITY 5 #define CONFIG_ESP_RMAKER_FACTORY_PARTITION_NAME "fctry" @@ -550,6 +598,23 @@ #define CONFIG_DSP_OPTIMIZATION 0 #define CONFIG_DSP_MAX_FFT_SIZE_4096 1 #define CONFIG_DSP_MAX_FFT_SIZE 4096 +#define CONFIG_OV7670_SUPPORT 1 +#define CONFIG_OV7725_SUPPORT 1 +#define CONFIG_NT99141_SUPPORT 1 +#define CONFIG_OV2640_SUPPORT 1 +#define CONFIG_OV3660_SUPPORT 1 +#define CONFIG_OV5640_SUPPORT 1 +#define CONFIG_GC2145_SUPPORT 1 +#define CONFIG_GC032A_SUPPORT 1 +#define CONFIG_GC0308_SUPPORT 1 +#define CONFIG_BF3005_SUPPORT 1 +#define CONFIG_BF20A6_SUPPORT 1 +#define CONFIG_SC030IOT_SUPPORT 1 +#define CONFIG_SCCB_HARDWARE_I2C_PORT1 1 +#define CONFIG_SCCB_CLK_FREQ 100000 +#define CONFIG_GC_SENSOR_SUBSAMPLE_MODE 1 +#define CONFIG_CAMERA_CORE0 1 +#define CONFIG_CAMERA_DMA_BUFFER_SIZE_MAX 32768 #define CONFIG_LITTLEFS_MAX_PARTITIONS 3 #define CONFIG_LITTLEFS_PAGE_SIZE 256 #define CONFIG_LITTLEFS_OBJ_NAME_LEN 64 @@ -620,8 +685,6 @@ #define CONFIG_MAIN_TASK_STACK_SIZE CONFIG_ESP_MAIN_TASK_STACK_SIZE #define CONFIG_MB_CONTROLLER_NOTIFY_QUEUE_SIZE CONFIG_FMB_CONTROLLER_NOTIFY_QUEUE_SIZE #define CONFIG_MB_CONTROLLER_NOTIFY_TIMEOUT CONFIG_FMB_CONTROLLER_NOTIFY_TIMEOUT -#define CONFIG_MB_CONTROLLER_SLAVE_ID CONFIG_FMB_CONTROLLER_SLAVE_ID -#define CONFIG_MB_CONTROLLER_SLAVE_ID_SUPPORT CONFIG_FMB_CONTROLLER_SLAVE_ID_SUPPORT #define CONFIG_MB_CONTROLLER_STACK_SIZE CONFIG_FMB_CONTROLLER_STACK_SIZE #define CONFIG_MB_EVENT_QUEUE_TIMEOUT CONFIG_FMB_EVENT_QUEUE_TIMEOUT #define CONFIG_MB_MASTER_DELAY_MS_CONVERT CONFIG_FMB_MASTER_DELAY_MS_CONVERT @@ -643,7 +706,6 @@ #define CONFIG_POST_EVENTS_FROM_ISR CONFIG_ESP_EVENT_POST_FROM_ISR #define CONFIG_RFCOMM_TRACE_LEVEL_WARNING CONFIG_BT_LOG_RFCOMM_TRACE_LEVEL_WARNING #define CONFIG_SDP_TRACE_LEVEL_WARNING CONFIG_BT_LOG_SDP_TRACE_LEVEL_WARNING -#define CONFIG_SEMIHOSTFS_HOST_PATH_MAX_LEN CONFIG_VFS_SEMIHOSTFS_HOST_PATH_MAX_LEN #define CONFIG_SEMIHOSTFS_MAX_MOUNT_POINTS CONFIG_VFS_SEMIHOSTFS_MAX_MOUNT_POINTS #define CONFIG_SMP_TRACE_LEVEL_WARNING CONFIG_BT_LOG_SMP_TRACE_LEVEL_WARNING #define CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ABORTS CONFIG_SPI_FLASH_DANGEROUS_WRITE_ABORTS @@ -654,10 +716,10 @@ #define CONFIG_SYSTEM_EVENT_QUEUE_SIZE CONFIG_ESP_SYSTEM_EVENT_QUEUE_SIZE #define CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE #define CONFIG_TASK_WDT CONFIG_ESP_TASK_WDT -#define CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU0 CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0 +#define CONFIG_TASK_WDT_PANIC CONFIG_ESP_TASK_WDT_PANIC #define CONFIG_TASK_WDT_TIMEOUT_S CONFIG_ESP_TASK_WDT_TIMEOUT_S #define CONFIG_TCPIP_RECVMBOX_SIZE CONFIG_LWIP_TCPIP_RECVMBOX_SIZE -#define CONFIG_TCPIP_TASK_AFFINITY_NO_AFFINITY CONFIG_LWIP_TCPIP_TASK_AFFINITY_NO_AFFINITY +#define CONFIG_TCPIP_TASK_AFFINITY_CPU0 CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU0 #define CONFIG_TCPIP_TASK_STACK_SIZE CONFIG_LWIP_TCPIP_TASK_STACK_SIZE #define CONFIG_TCP_MAXRTX CONFIG_LWIP_TCP_MAXRTX #define CONFIG_TCP_MSL CONFIG_LWIP_TCP_MSL @@ -675,5 +737,5 @@ #define CONFIG_TOOLPREFIX CONFIG_SDK_TOOLPREFIX #define CONFIG_UDP_RECVMBOX_SIZE CONFIG_LWIP_UDP_RECVMBOX_SIZE #define CONFIG_WARN_WRITE_STRINGS CONFIG_COMPILER_WARN_WRITE_STRINGS -#define CONFIG_ARDUINO_IDF_COMMIT "b8050b365e" +#define CONFIG_ARDUINO_IDF_COMMIT "6c5fb29c2c" #define CONFIG_ARDUINO_IDF_BRANCH "release/v4.4" diff --git a/tools/sdk/esp32c3/qspi_qspi/libbootloader_support.a b/tools/sdk/esp32c3/qspi_qspi/libbootloader_support.a index eb785ebe60b..594a8889cd9 100644 Binary files a/tools/sdk/esp32c3/qspi_qspi/libbootloader_support.a and b/tools/sdk/esp32c3/qspi_qspi/libbootloader_support.a differ diff --git a/tools/sdk/esp32c3/qspi_qspi/libesp_hw_support.a b/tools/sdk/esp32c3/qspi_qspi/libesp_hw_support.a index 60089e301ee..cbf75255da3 100644 Binary files a/tools/sdk/esp32c3/qspi_qspi/libesp_hw_support.a and b/tools/sdk/esp32c3/qspi_qspi/libesp_hw_support.a differ diff --git a/tools/sdk/esp32c3/qspi_qspi/libesp_system.a b/tools/sdk/esp32c3/qspi_qspi/libesp_system.a index 2cdce053943..1cc7b3ff85e 100644 Binary files a/tools/sdk/esp32c3/qspi_qspi/libesp_system.a and b/tools/sdk/esp32c3/qspi_qspi/libesp_system.a differ diff --git a/tools/sdk/esp32c3/qspi_qspi/libfreertos.a b/tools/sdk/esp32c3/qspi_qspi/libfreertos.a index 90e35db9e41..4f40f1bd781 100644 Binary files a/tools/sdk/esp32c3/qspi_qspi/libfreertos.a and b/tools/sdk/esp32c3/qspi_qspi/libfreertos.a differ diff --git a/tools/sdk/esp32c3/qspi_qspi/libspi_flash.a b/tools/sdk/esp32c3/qspi_qspi/libspi_flash.a index 5810a92bce8..09379b12d75 100644 Binary files a/tools/sdk/esp32c3/qspi_qspi/libspi_flash.a and b/tools/sdk/esp32c3/qspi_qspi/libspi_flash.a differ diff --git a/tools/sdk/esp32c3/qspi_qspi/sections.ld b/tools/sdk/esp32c3/qspi_qspi/sections.ld index ab4e3c04bf4..e2107897fd2 100644 --- a/tools/sdk/esp32c3/qspi_qspi/sections.ld +++ b/tools/sdk/esp32c3/qspi_qspi/sections.ld @@ -177,6 +177,7 @@ SECTIONS *libhal.a:wdt_hal_iram.*(.literal .literal.* .text .text.*) *libheap.a:heap_tlsf.*(.literal .literal.* .text .text.*) *libheap.a:multi_heap.*(.literal .literal.* .text .text.*) + *libheap.a:multi_heap_poisoning.*(.literal .literal.* .text .text.*) *liblog.a:log.*(.literal.esp_log_write .text.esp_log_write) *liblog.a:log_freertos.*(.literal.esp_log_early_timestamp .text.esp_log_early_timestamp) *liblog.a:log_freertos.*(.literal.esp_log_impl_lock .text.esp_log_impl_lock) @@ -264,6 +265,7 @@ SECTIONS *libhal.a:wdt_hal_iram.*(.rodata .rodata.*) *libheap.a:heap_tlsf.*(.rodata .rodata.*) *libheap.a:multi_heap.*(.rodata .rodata.*) + *libheap.a:multi_heap_poisoning.*(.rodata .rodata.*) *libnewlib.a:abort.*(.rodata .rodata.*) *libnewlib.a:assert.*(.rodata .rodata.*) *libnewlib.a:heap.*(.rodata .rodata.*) @@ -350,7 +352,7 @@ SECTIONS _instruction_reserved_start = ABSOLUTE(.); _text_start = ABSOLUTE(.); - *(EXCLUDE_FILE(*libesp_ringbuf.a *libfreertos.a *libgcov.a *librtc.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libesp_event.a:default_event_loop.* *libesp_event.a:esp_event.* *libesp_hw_support.a:cpu_util.* *libesp_hw_support.a:rtc_clk.* *libesp_hw_support.a:rtc_init.* *libesp_hw_support.a:rtc_pm.* *libesp_hw_support.a:rtc_sleep.* *libesp_hw_support.a:rtc_time.* *libesp_system.a:esp_err.* *libesp_system.a:esp_system.* *libesp_system.a:ubsan.* *libgcc.a:_divsf3.* *libgcc.a:lib2funcs.* *libgcc.a:save-restore.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_gpspi.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:systimer_hal.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *liblog.a:log.* *liblog.a:log_freertos.* *libnewlib.a:abort.* *libnewlib.a:assert.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libriscv.a:interrupt.* *libriscv.a:vectors.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_boya.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_th.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.*) .literal EXCLUDE_FILE(*libesp_ringbuf.a *libfreertos.a *libgcov.a *librtc.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libesp_event.a:default_event_loop.* *libesp_event.a:esp_event.* *libesp_hw_support.a:cpu_util.* *libesp_hw_support.a:rtc_clk.* *libesp_hw_support.a:rtc_init.* *libesp_hw_support.a:rtc_pm.* *libesp_hw_support.a:rtc_sleep.* *libesp_hw_support.a:rtc_time.* *libesp_system.a:esp_err.* *libesp_system.a:esp_system.* *libesp_system.a:ubsan.* *libgcc.a:_divsf3.* *libgcc.a:lib2funcs.* *libgcc.a:save-restore.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_gpspi.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:systimer_hal.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *liblog.a:log.* *liblog.a:log_freertos.* *libnewlib.a:abort.* *libnewlib.a:assert.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libriscv.a:interrupt.* *libriscv.a:vectors.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_boya.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_th.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.*) .literal.* EXCLUDE_FILE(*libesp_ringbuf.a *libfreertos.a *libgcov.a *librtc.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libesp_event.a:default_event_loop.* *libesp_event.a:esp_event.* *libesp_hw_support.a:cpu_util.* *libesp_hw_support.a:rtc_clk.* *libesp_hw_support.a:rtc_init.* *libesp_hw_support.a:rtc_pm.* *libesp_hw_support.a:rtc_sleep.* *libesp_hw_support.a:rtc_time.* *libesp_system.a:esp_err.* *libesp_system.a:esp_system.* *libesp_system.a:ubsan.* *libgcc.a:_divsf3.* *libgcc.a:lib2funcs.* *libgcc.a:save-restore.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_gpspi.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:systimer_hal.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *liblog.a:log.* *liblog.a:log_freertos.* *libnewlib.a:abort.* *libnewlib.a:assert.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libriscv.a:interrupt.* *libriscv.a:vectors.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_boya.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_th.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.*) .text EXCLUDE_FILE(*libesp_ringbuf.a *libfreertos.a *libgcov.a *librtc.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libesp_event.a:default_event_loop.* *libesp_event.a:esp_event.* *libesp_hw_support.a:cpu_util.* *libesp_hw_support.a:rtc_clk.* *libesp_hw_support.a:rtc_init.* *libesp_hw_support.a:rtc_pm.* *libesp_hw_support.a:rtc_sleep.* *libesp_hw_support.a:rtc_time.* *libesp_system.a:esp_err.* *libesp_system.a:esp_system.* *libesp_system.a:ubsan.* *libgcc.a:_divsf3.* *libgcc.a:lib2funcs.* *libgcc.a:save-restore.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_gpspi.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:systimer_hal.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *liblog.a:log.* *liblog.a:log_freertos.* *libnewlib.a:abort.* *libnewlib.a:assert.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libriscv.a:interrupt.* *libriscv.a:vectors.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_boya.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_th.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.*) .text.*) + *(EXCLUDE_FILE(*libesp_ringbuf.a *libfreertos.a *libgcov.a *librtc.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libesp_event.a:default_event_loop.* *libesp_event.a:esp_event.* *libesp_hw_support.a:cpu_util.* *libesp_hw_support.a:rtc_clk.* *libesp_hw_support.a:rtc_init.* *libesp_hw_support.a:rtc_pm.* *libesp_hw_support.a:rtc_sleep.* *libesp_hw_support.a:rtc_time.* *libesp_system.a:esp_err.* *libesp_system.a:esp_system.* *libesp_system.a:ubsan.* *libgcc.a:_divsf3.* *libgcc.a:lib2funcs.* *libgcc.a:save-restore.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_gpspi.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:systimer_hal.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *libheap.a:multi_heap_poisoning.* *liblog.a:log.* *liblog.a:log_freertos.* *libnewlib.a:abort.* *libnewlib.a:assert.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libriscv.a:interrupt.* *libriscv.a:vectors.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_boya.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_th.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.*) .literal EXCLUDE_FILE(*libesp_ringbuf.a *libfreertos.a *libgcov.a *librtc.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libesp_event.a:default_event_loop.* *libesp_event.a:esp_event.* *libesp_hw_support.a:cpu_util.* *libesp_hw_support.a:rtc_clk.* *libesp_hw_support.a:rtc_init.* *libesp_hw_support.a:rtc_pm.* *libesp_hw_support.a:rtc_sleep.* *libesp_hw_support.a:rtc_time.* *libesp_system.a:esp_err.* *libesp_system.a:esp_system.* *libesp_system.a:ubsan.* *libgcc.a:_divsf3.* *libgcc.a:lib2funcs.* *libgcc.a:save-restore.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_gpspi.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:systimer_hal.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *libheap.a:multi_heap_poisoning.* *liblog.a:log.* *liblog.a:log_freertos.* *libnewlib.a:abort.* *libnewlib.a:assert.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libriscv.a:interrupt.* *libriscv.a:vectors.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_boya.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_th.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.*) .literal.* EXCLUDE_FILE(*libesp_ringbuf.a *libfreertos.a *libgcov.a *librtc.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libesp_event.a:default_event_loop.* *libesp_event.a:esp_event.* *libesp_hw_support.a:cpu_util.* *libesp_hw_support.a:rtc_clk.* *libesp_hw_support.a:rtc_init.* *libesp_hw_support.a:rtc_pm.* *libesp_hw_support.a:rtc_sleep.* *libesp_hw_support.a:rtc_time.* *libesp_system.a:esp_err.* *libesp_system.a:esp_system.* *libesp_system.a:ubsan.* *libgcc.a:_divsf3.* *libgcc.a:lib2funcs.* *libgcc.a:save-restore.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_gpspi.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:systimer_hal.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *libheap.a:multi_heap_poisoning.* *liblog.a:log.* *liblog.a:log_freertos.* *libnewlib.a:abort.* *libnewlib.a:assert.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libriscv.a:interrupt.* *libriscv.a:vectors.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_boya.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_th.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.*) .text EXCLUDE_FILE(*libesp_ringbuf.a *libfreertos.a *libgcov.a *librtc.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libesp_event.a:default_event_loop.* *libesp_event.a:esp_event.* *libesp_hw_support.a:cpu_util.* *libesp_hw_support.a:rtc_clk.* *libesp_hw_support.a:rtc_init.* *libesp_hw_support.a:rtc_pm.* *libesp_hw_support.a:rtc_sleep.* *libesp_hw_support.a:rtc_time.* *libesp_system.a:esp_err.* *libesp_system.a:esp_system.* *libesp_system.a:ubsan.* *libgcc.a:_divsf3.* *libgcc.a:lib2funcs.* *libgcc.a:save-restore.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_gpspi.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:systimer_hal.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *libheap.a:multi_heap_poisoning.* *liblog.a:log.* *liblog.a:log_freertos.* *libnewlib.a:abort.* *libnewlib.a:assert.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libriscv.a:interrupt.* *libriscv.a:vectors.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_boya.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_th.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.*) .text.*) *(.wifi0iram .wifi0iram.*) *(.wifiorslpiram .wifiorslpiram.*) *(.wifirxiram .wifirxiram.*) @@ -424,7 +426,7 @@ SECTIONS { _flash_rodata_start = ABSOLUTE(.); - *(EXCLUDE_FILE(*libgcov.a *libphy.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libesp_hw_support.a:rtc_clk.* *libesp_system.a:esp_err.* *libesp_system.a:ubsan.* *libgcc.a:_divsf3.* *libgcc.a:save-restore.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_gpspi.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:systimer_hal.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *libnewlib.a:abort.* *libnewlib.a:assert.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_boya.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_th.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.*) .rodata EXCLUDE_FILE(*libgcov.a *libphy.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libesp_hw_support.a:rtc_clk.* *libesp_system.a:esp_err.* *libesp_system.a:ubsan.* *libgcc.a:_divsf3.* *libgcc.a:save-restore.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_gpspi.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:systimer_hal.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *libnewlib.a:abort.* *libnewlib.a:assert.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_boya.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_th.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.*) .rodata.*) + *(EXCLUDE_FILE(*libgcov.a *libphy.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libesp_hw_support.a:rtc_clk.* *libesp_system.a:esp_err.* *libesp_system.a:ubsan.* *libgcc.a:_divsf3.* *libgcc.a:save-restore.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_gpspi.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:systimer_hal.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *libheap.a:multi_heap_poisoning.* *libnewlib.a:abort.* *libnewlib.a:assert.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_boya.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_th.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.*) .rodata EXCLUDE_FILE(*libgcov.a *libphy.a *libapp_trace.a:app_trace.* *libapp_trace.a:app_trace_util.* *libesp_hw_support.a:rtc_clk.* *libesp_system.a:esp_err.* *libesp_system.a:ubsan.* *libgcc.a:_divsf3.* *libgcc.a:save-restore.* *libhal.a:cpu_hal.* *libhal.a:i2c_hal_iram.* *libhal.a:ledc_hal_iram.* *libhal.a:soc_hal.* *libhal.a:spi_flash_encrypt_hal_iram.* *libhal.a:spi_flash_hal_gpspi.* *libhal.a:spi_flash_hal_iram.* *libhal.a:spi_hal_iram.* *libhal.a:spi_slave_hal_iram.* *libhal.a:systimer_hal.* *libhal.a:wdt_hal_iram.* *libheap.a:heap_tlsf.* *libheap.a:multi_heap.* *libheap.a:multi_heap_poisoning.* *libnewlib.a:abort.* *libnewlib.a:assert.* *libnewlib.a:heap.* *libnewlib.a:stdatomic.* *libsoc.a:lldesc.* *libspi_flash.a:memspi_host_driver.* *libspi_flash.a:spi_flash_chip_boya.* *libspi_flash.a:spi_flash_chip_gd.* *libspi_flash.a:spi_flash_chip_generic.* *libspi_flash.a:spi_flash_chip_issi.* *libspi_flash.a:spi_flash_chip_mxic.* *libspi_flash.a:spi_flash_chip_th.* *libspi_flash.a:spi_flash_chip_winbond.* *libspi_flash.a:spi_flash_rom_patch.*) .rodata.*) *(.rodata_wlog_error .rodata_wlog_error.*) *(.irom1.text) /* catch stray ICACHE_RODATA_ATTR */ diff --git a/tools/sdk/esp32c3/sdkconfig b/tools/sdk/esp32c3/sdkconfig index 940e91f67dc..8d372ac7e63 100644 --- a/tools/sdk/esp32c3/sdkconfig +++ b/tools/sdk/esp32c3/sdkconfig @@ -53,14 +53,15 @@ CONFIG_BOOTLOADER_LOG_LEVEL=0 CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_9V=y # CONFIG_BOOTLOADER_FACTORY_RESET is not set # CONFIG_BOOTLOADER_APP_TEST is not set +CONFIG_BOOTLOADER_REGION_PROTECTION_ENABLE=y CONFIG_BOOTLOADER_WDT_ENABLE=y # CONFIG_BOOTLOADER_WDT_DISABLE_IN_USER_CODE is not set CONFIG_BOOTLOADER_WDT_TIME_MS=9000 # CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE is not set -# CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP is not set +CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP=y # CONFIG_BOOTLOADER_SKIP_VALIDATE_ON_POWER_ON is not set # CONFIG_BOOTLOADER_SKIP_VALIDATE_ALWAYS is not set -CONFIG_BOOTLOADER_RESERVE_RTC_SIZE=0 +CONFIG_BOOTLOADER_RESERVE_RTC_SIZE=0x10 # CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC is not set CONFIG_BOOTLOADER_FLASH_XMC_SUPPORT=y # end of Bootloader config @@ -101,11 +102,14 @@ CONFIG_ESPTOOLPY_FLASHFREQ_80M=y # CONFIG_ESPTOOLPY_FLASHFREQ_20M is not set CONFIG_ESPTOOLPY_FLASHFREQ="80m" # CONFIG_ESPTOOLPY_FLASHSIZE_1MB is not set -CONFIG_ESPTOOLPY_FLASHSIZE_2MB=y -# CONFIG_ESPTOOLPY_FLASHSIZE_4MB is not set +# CONFIG_ESPTOOLPY_FLASHSIZE_2MB is not set +CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y # CONFIG_ESPTOOLPY_FLASHSIZE_8MB is not set # CONFIG_ESPTOOLPY_FLASHSIZE_16MB is not set -CONFIG_ESPTOOLPY_FLASHSIZE="2MB" +# CONFIG_ESPTOOLPY_FLASHSIZE_32MB is not set +# CONFIG_ESPTOOLPY_FLASHSIZE_64MB is not set +# CONFIG_ESPTOOLPY_FLASHSIZE_128MB is not set +CONFIG_ESPTOOLPY_FLASHSIZE="4MB" CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y CONFIG_ESPTOOLPY_BEFORE_RESET=y # CONFIG_ESPTOOLPY_BEFORE_NORESET is not set @@ -145,17 +149,20 @@ CONFIG_LIB_BUILDER_FLASHFREQ="80m" # ESP RainMaker Config # # CONFIG_ESP_RMAKER_NO_CLAIM is not set -# CONFIG_ESP_RMAKER_SELF_CLAIM is not set -CONFIG_ESP_RMAKER_ASSISTED_CLAIM=y -CONFIG_ESP_RMAKER_CLAIM_TYPE=2 +CONFIG_ESP_RMAKER_SELF_CLAIM=y +# CONFIG_ESP_RMAKER_ASSISTED_CLAIM is not set +CONFIG_ESP_RMAKER_CLAIM_TYPE=1 +CONFIG_ESP_RMAKER_CLAIM_SERVICE_BASE_URL="https://esp-claiming.rainmaker.espressif.com" CONFIG_ESP_RMAKER_MQTT_HOST="a1p72mufdu6064-ats.iot.us-east-1.amazonaws.com" CONFIG_ESP_RMAKER_MAX_PARAM_DATA_SIZE=1024 # CONFIG_ESP_RMAKER_DISABLE_USER_MAPPING_PROV is not set # CONFIG_ESP_RMAKER_USER_ID_CHECK is not set +# CONFIG_RMAKER_NAME_PARAM_CB is not set # CONFIG_ESP_RMAKER_LOCAL_CTRL_ENABLE is not set CONFIG_ESP_RMAKER_CONSOLE_UART_NUM_0=y # CONFIG_ESP_RMAKER_CONSOLE_UART_NUM_1 is not set CONFIG_ESP_RMAKER_CONSOLE_UART_NUM=0 +CONFIG_ESP_RMAKER_USE_CERT_BUNDLE=y # # ESP RainMaker OTA Config @@ -188,19 +195,17 @@ CONFIG_ESP_RMAKER_SCENES_MAX_SCENES=10 CONFIG_ENABLE_ARDUINO_DEPENDS=y CONFIG_AUTOSTART_ARDUINO=y CONFIG_ARDUINO_RUN_CORE0=y -# CONFIG_ARDUINO_RUN_CORE1 is not set -# CONFIG_ARDUINO_RUN_NO_AFFINITY is not set CONFIG_ARDUINO_RUNNING_CORE=0 CONFIG_ARDUINO_LOOP_STACK_SIZE=8192 CONFIG_ARDUINO_EVENT_RUN_CORE0=y -# CONFIG_ARDUINO_EVENT_RUN_CORE1 is not set -# CONFIG_ARDUINO_EVENT_RUN_NO_AFFINITY is not set CONFIG_ARDUINO_EVENT_RUNNING_CORE=0 +CONFIG_ARDUINO_SERIAL_EVENT_RUN_CORE0=y +CONFIG_ARDUINO_SERIAL_EVENT_TASK_RUNNING_CORE=0 +CONFIG_ARDUINO_SERIAL_EVENT_TASK_STACK_SIZE=2048 +CONFIG_ARDUINO_SERIAL_EVENT_TASK_PRIORITY=24 CONFIG_ARDUINO_UDP_RUN_CORE0=y -# CONFIG_ARDUINO_UDP_RUN_CORE1 is not set -# CONFIG_ARDUINO_UDP_RUN_NO_AFFINITY is not set -CONFIG_ARDUINO_UDP_TASK_PRIORITY=3 CONFIG_ARDUINO_UDP_RUNNING_CORE=0 +CONFIG_ARDUINO_UDP_TASK_PRIORITY=3 # CONFIG_ARDUINO_ISR_IRAM is not set # CONFIG_DISABLE_HAL_LOCKS is not set @@ -215,7 +220,7 @@ CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL_ERROR=y # CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL_VERBOSE is not set CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL=1 # CONFIG_ARDUHAL_LOG_COLORS is not set -# CONFIG_ARDUHAL_ESP_LOG is not set +CONFIG_ARDUHAL_ESP_LOG=y # end of Debug Log Configuration CONFIG_ARDUHAL_PARTITION_SCHEME_DEFAULT=y @@ -335,7 +340,8 @@ CONFIG_BT_CTRL_SCAN_DUPL_TYPE_DEVICE=y # CONFIG_BT_CTRL_SCAN_DUPL_TYPE_DATA_DEVICE is not set CONFIG_BT_CTRL_SCAN_DUPL_TYPE=0 CONFIG_BT_CTRL_SCAN_DUPL_CACHE_SIZE=100 -# CONFIG_BT_CTRL_BLE_MESH_SCAN_DUPL_EN is not set +CONFIG_BT_CTRL_BLE_MESH_SCAN_DUPL_EN=y +CONFIG_BT_CTRL_MESH_DUPL_SCAN_CACHE_SIZE=100 # CONFIG_BT_CTRL_COEX_PHY_CODED_TX_RX_TLIM_EN is not set CONFIG_BT_CTRL_COEX_PHY_CODED_TX_RX_TLIM_DIS=y CONFIG_BT_CTRL_COEX_PHY_CODED_TX_RX_TLIM_EFF=0 @@ -564,7 +570,115 @@ CONFIG_BT_BLE_42_FEATURES_SUPPORTED=y # end of Bluedroid Options # end of Bluetooth -# CONFIG_BLE_MESH is not set +CONFIG_BLE_MESH=y +CONFIG_BLE_MESH_HCI_5_0=y +CONFIG_BLE_MESH_USE_DUPLICATE_SCAN=y +CONFIG_BLE_MESH_MEM_ALLOC_MODE_INTERNAL=y +# CONFIG_BLE_MESH_MEM_ALLOC_MODE_DEFAULT is not set +CONFIG_BLE_MESH_DEINIT=y + +# +# BLE Mesh and BLE coexistence support +# +# CONFIG_BLE_MESH_SUPPORT_BLE_ADV is not set +# CONFIG_BLE_MESH_SUPPORT_BLE_SCAN is not set +# end of BLE Mesh and BLE coexistence support + +# CONFIG_BLE_MESH_FAST_PROV is not set +# CONFIG_BLE_MESH_NODE is not set +# CONFIG_BLE_MESH_PROVISIONER is not set +CONFIG_BLE_MESH_PROV=y +CONFIG_BLE_MESH_PB_ADV=y +# CONFIG_BLE_MESH_PB_GATT is not set +CONFIG_BLE_MESH_PROXY=y +# CONFIG_BLE_MESH_GATT_PROXY_CLIENT is not set +CONFIG_BLE_MESH_NET_BUF_POOL_USAGE=y +# CONFIG_BLE_MESH_SETTINGS is not set +CONFIG_BLE_MESH_SUBNET_COUNT=3 +CONFIG_BLE_MESH_APP_KEY_COUNT=3 +CONFIG_BLE_MESH_MODEL_KEY_COUNT=3 +CONFIG_BLE_MESH_MODEL_GROUP_COUNT=3 +CONFIG_BLE_MESH_LABEL_COUNT=3 +CONFIG_BLE_MESH_CRPL=10 +CONFIG_BLE_MESH_MSG_CACHE_SIZE=10 +CONFIG_BLE_MESH_ADV_BUF_COUNT=60 +CONFIG_BLE_MESH_IVU_DIVIDER=4 +CONFIG_BLE_MESH_TX_SEG_MSG_COUNT=1 +CONFIG_BLE_MESH_RX_SEG_MSG_COUNT=1 +CONFIG_BLE_MESH_RX_SDU_MAX=384 +CONFIG_BLE_MESH_TX_SEG_MAX=32 +# CONFIG_BLE_MESH_FRIEND is not set +# CONFIG_BLE_MESH_NO_LOG is not set + +# +# BLE Mesh STACK DEBUG LOG LEVEL +# +# CONFIG_BLE_MESH_TRACE_LEVEL_NONE is not set +# CONFIG_BLE_MESH_TRACE_LEVEL_ERROR is not set +CONFIG_BLE_MESH_TRACE_LEVEL_WARNING=y +# CONFIG_BLE_MESH_TRACE_LEVEL_INFO is not set +# CONFIG_BLE_MESH_TRACE_LEVEL_DEBUG is not set +# CONFIG_BLE_MESH_TRACE_LEVEL_VERBOSE is not set +CONFIG_BLE_MESH_STACK_TRACE_LEVEL=2 +# end of BLE Mesh STACK DEBUG LOG LEVEL + +# +# BLE Mesh NET BUF DEBUG LOG LEVEL +# +# CONFIG_BLE_MESH_NET_BUF_TRACE_LEVEL_NONE is not set +# CONFIG_BLE_MESH_NET_BUF_TRACE_LEVEL_ERROR is not set +CONFIG_BLE_MESH_NET_BUF_TRACE_LEVEL_WARNING=y +# CONFIG_BLE_MESH_NET_BUF_TRACE_LEVEL_INFO is not set +# CONFIG_BLE_MESH_NET_BUF_TRACE_LEVEL_DEBUG is not set +# CONFIG_BLE_MESH_NET_BUF_TRACE_LEVEL_VERBOSE is not set +CONFIG_BLE_MESH_NET_BUF_TRACE_LEVEL=2 +# end of BLE Mesh NET BUF DEBUG LOG LEVEL + +CONFIG_BLE_MESH_CLIENT_MSG_TIMEOUT=4000 + +# +# Support for BLE Mesh Foundation models +# +# CONFIG_BLE_MESH_CFG_CLI is not set +# CONFIG_BLE_MESH_HEALTH_CLI is not set +CONFIG_BLE_MESH_HEALTH_SRV=y +# end of Support for BLE Mesh Foundation models + +# +# Support for BLE Mesh Client/Server models +# +# CONFIG_BLE_MESH_GENERIC_ONOFF_CLI is not set +# CONFIG_BLE_MESH_GENERIC_LEVEL_CLI is not set +# CONFIG_BLE_MESH_GENERIC_DEF_TRANS_TIME_CLI is not set +# CONFIG_BLE_MESH_GENERIC_POWER_ONOFF_CLI is not set +# CONFIG_BLE_MESH_GENERIC_POWER_LEVEL_CLI is not set +# CONFIG_BLE_MESH_GENERIC_BATTERY_CLI is not set +# CONFIG_BLE_MESH_GENERIC_LOCATION_CLI is not set +# CONFIG_BLE_MESH_GENERIC_PROPERTY_CLI is not set +# CONFIG_BLE_MESH_SENSOR_CLI is not set +# CONFIG_BLE_MESH_TIME_CLI is not set +# CONFIG_BLE_MESH_SCENE_CLI is not set +# CONFIG_BLE_MESH_SCHEDULER_CLI is not set +# CONFIG_BLE_MESH_LIGHT_LIGHTNESS_CLI is not set +# CONFIG_BLE_MESH_LIGHT_CTL_CLI is not set +# CONFIG_BLE_MESH_LIGHT_HSL_CLI is not set +# CONFIG_BLE_MESH_LIGHT_XYL_CLI is not set +# CONFIG_BLE_MESH_LIGHT_LC_CLI is not set +CONFIG_BLE_MESH_GENERIC_SERVER=y +CONFIG_BLE_MESH_SENSOR_SERVER=y +CONFIG_BLE_MESH_TIME_SCENE_SERVER=y +CONFIG_BLE_MESH_LIGHTING_SERVER=y +# end of Support for BLE Mesh Client/Server models + +# CONFIG_BLE_MESH_IV_UPDATE_TEST is not set + +# +# BLE Mesh specific test option +# +# CONFIG_BLE_MESH_SELF_TEST is not set +# CONFIG_BLE_MESH_SHELL is not set +# CONFIG_BLE_MESH_DEBUG is not set +# end of BLE Mesh specific test option # # CoAP Configuration @@ -596,9 +710,9 @@ CONFIG_ADC_DISABLE_DAC=y # SPI configuration # # CONFIG_SPI_MASTER_IN_IRAM is not set -CONFIG_SPI_MASTER_ISR_IN_IRAM=y +# CONFIG_SPI_MASTER_ISR_IN_IRAM is not set # CONFIG_SPI_SLAVE_IN_IRAM is not set -CONFIG_SPI_SLAVE_ISR_IN_IRAM=y +# CONFIG_SPI_SLAVE_ISR_IN_IRAM is not set # end of SPI configuration # @@ -634,9 +748,10 @@ CONFIG_EFUSE_MAX_BLK_LEN=256 # CONFIG_ESP_TLS_USING_MBEDTLS=y CONFIG_ESP_TLS_USE_DS_PERIPHERAL=y -CONFIG_ESP_TLS_SERVER=y # CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS is not set +CONFIG_ESP_TLS_SERVER=y # CONFIG_ESP_TLS_SERVER_SESSION_TICKETS is not set +# CONFIG_ESP_TLS_SERVER_MIN_AUTH_MODE_OPTIONAL is not set # CONFIG_ESP_TLS_PSK_VERIFICATION is not set # CONFIG_ESP_TLS_INSECURE is not set # end of ESP-TLS @@ -651,6 +766,7 @@ CONFIG_ESP32C3_DEFAULT_CPU_FREQ_MHZ=160 # CONFIG_ESP32C3_REV_MIN_1 is not set # CONFIG_ESP32C3_REV_MIN_2 is not set CONFIG_ESP32C3_REV_MIN_3=y +# CONFIG_ESP32C3_REV_MIN_4 is not set CONFIG_ESP32C3_REV_MIN=3 CONFIG_ESP32C3_DEBUG_OCDAWARE=y CONFIG_ESP32C3_BROWNOUT_DET=y @@ -688,8 +804,8 @@ CONFIG_ESP_ERR_TO_NAME_LOOKUP=y # CONFIG_ETH_ENABLED=y CONFIG_ETH_USE_SPI_ETHERNET=y -# CONFIG_ETH_SPI_ETHERNET_DM9051 is not set -# CONFIG_ETH_SPI_ETHERNET_W5500 is not set +CONFIG_ETH_SPI_ETHERNET_DM9051=y +CONFIG_ETH_SPI_ETHERNET_W5500=y # CONFIG_ETH_SPI_ETHERNET_KSZ8851SNL is not set # CONFIG_ETH_USE_OPENETH is not set # end of Ethernet @@ -711,7 +827,7 @@ CONFIG_ESP_EVENT_POST_FROM_IRAM_ISR=y # ESP HTTP client # CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS=y -# CONFIG_ESP_HTTP_CLIENT_ENABLE_BASIC_AUTH is not set +CONFIG_ESP_HTTP_CLIENT_ENABLE_BASIC_AUTH=y CONFIG_ESP_HTTP_CLIENT_ENABLE_DIGEST_AUTH=y # end of ESP HTTP client @@ -836,8 +952,8 @@ CONFIG_ESP_SYSTEM_MEMPROT_MEM_ALIGN_SIZE=512 # end of Memory protection CONFIG_ESP_SYSTEM_EVENT_QUEUE_SIZE=32 -CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=2304 -CONFIG_ESP_MAIN_TASK_STACK_SIZE=3584 +CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=2048 +CONFIG_ESP_MAIN_TASK_STACK_SIZE=4096 CONFIG_ESP_MAIN_TASK_AFFINITY_CPU0=y # CONFIG_ESP_MAIN_TASK_AFFINITY_NO_AFFINITY is not set CONFIG_ESP_MAIN_TASK_AFFINITY=0x0 @@ -854,9 +970,9 @@ CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200 CONFIG_ESP_INT_WDT=y CONFIG_ESP_INT_WDT_TIMEOUT_MS=300 CONFIG_ESP_TASK_WDT=y -# CONFIG_ESP_TASK_WDT_PANIC is not set +CONFIG_ESP_TASK_WDT_PANIC=y CONFIG_ESP_TASK_WDT_TIMEOUT_S=5 -CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0=y +# CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0 is not set # CONFIG_ESP_PANIC_HANDLER_IRAM is not set # CONFIG_ESP_DEBUG_STUBS_ENABLE is not set CONFIG_ESP_SYSTEM_CHECK_INT_LEVEL_4=y @@ -868,7 +984,7 @@ CONFIG_ESP_SYSTEM_CHECK_INT_LEVEL_4=y # CONFIG_ESP_TIMER_PROFILING is not set CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER=y CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER=y -CONFIG_ESP_TIMER_TASK_STACK_SIZE=3584 +CONFIG_ESP_TIMER_TASK_STACK_SIZE=4096 CONFIG_ESP_TIMER_INTERRUPT_LEVEL=1 # CONFIG_ESP_TIMER_SUPPORTS_ISR_DISPATCH_METHOD is not set CONFIG_ESP_TIMER_IMPL_SYSTIMER=y @@ -879,13 +995,13 @@ CONFIG_ESP_TIMER_IMPL_SYSTIMER=y # CONFIG_ESP32_WIFI_ENABLED=y CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE=y -CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=10 +CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=8 CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=32 # CONFIG_ESP32_WIFI_STATIC_TX_BUFFER is not set CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER=y CONFIG_ESP32_WIFI_TX_BUFFER_TYPE=1 CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=32 -# CONFIG_ESP32_WIFI_CSI_ENABLED is not set +CONFIG_ESP32_WIFI_CSI_ENABLED=y CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED=y CONFIG_ESP32_WIFI_TX_BA_WIN=6 CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=y @@ -918,12 +1034,12 @@ CONFIG_ESP_COREDUMP_ENABLE_TO_NONE=y # FAT Filesystem support # # CONFIG_FATFS_CODEPAGE_DYNAMIC is not set -CONFIG_FATFS_CODEPAGE_437=y +# CONFIG_FATFS_CODEPAGE_437 is not set # CONFIG_FATFS_CODEPAGE_720 is not set # CONFIG_FATFS_CODEPAGE_737 is not set # CONFIG_FATFS_CODEPAGE_771 is not set # CONFIG_FATFS_CODEPAGE_775 is not set -# CONFIG_FATFS_CODEPAGE_850 is not set +CONFIG_FATFS_CODEPAGE_850=y # CONFIG_FATFS_CODEPAGE_852 is not set # CONFIG_FATFS_CODEPAGE_855 is not set # CONFIG_FATFS_CODEPAGE_857 is not set @@ -939,10 +1055,10 @@ CONFIG_FATFS_CODEPAGE_437=y # CONFIG_FATFS_CODEPAGE_936 is not set # CONFIG_FATFS_CODEPAGE_949 is not set # CONFIG_FATFS_CODEPAGE_950 is not set -CONFIG_FATFS_CODEPAGE=437 +CONFIG_FATFS_CODEPAGE=850 # CONFIG_FATFS_LFN_NONE is not set -CONFIG_FATFS_LFN_HEAP=y -# CONFIG_FATFS_LFN_STACK is not set +# CONFIG_FATFS_LFN_HEAP is not set +CONFIG_FATFS_LFN_STACK=y CONFIG_FATFS_MAX_LFN=255 CONFIG_FATFS_API_ENCODING_ANSI_OEM=y # CONFIG_FATFS_API_ENCODING_UTF_16 is not set @@ -971,8 +1087,7 @@ CONFIG_FMB_SERIAL_ASCII_BITS_PER_SYMB=8 CONFIG_FMB_SERIAL_ASCII_TIMEOUT_RESPOND_MS=1000 CONFIG_FMB_PORT_TASK_PRIO=10 CONFIG_FMB_PORT_TASK_AFFINITY=0x7FFFFFFF -CONFIG_FMB_CONTROLLER_SLAVE_ID_SUPPORT=y -CONFIG_FMB_CONTROLLER_SLAVE_ID=0x00112233 +# CONFIG_FMB_CONTROLLER_SLAVE_ID_SUPPORT is not set CONFIG_FMB_CONTROLLER_NOTIFY_TIMEOUT=20 CONFIG_FMB_CONTROLLER_NOTIFY_QUEUE_SIZE=20 CONFIG_FMB_CONTROLLER_STACK_SIZE=4096 @@ -996,11 +1111,11 @@ CONFIG_FREERTOS_CORETIMER_SYSTIMER_LVL1=y CONFIG_FREERTOS_SYSTICK_USES_SYSTIMER=y CONFIG_FREERTOS_OPTIMIZED_SCHEDULER=y CONFIG_FREERTOS_HZ=1000 -CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION=y +# CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION is not set # CONFIG_FREERTOS_CHECK_STACKOVERFLOW_NONE is not set # CONFIG_FREERTOS_CHECK_STACKOVERFLOW_PTRVAL is not set CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY=y -# CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK is not set +CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK=y CONFIG_FREERTOS_INTERRUPT_BACKTRACE=y CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS=1 CONFIG_FREERTOS_ASSERT_FAIL_ABORT=y @@ -1039,12 +1154,13 @@ CONFIG_HAL_DEFAULT_ASSERTION_LEVEL=2 # # Heap memory debugging # -CONFIG_HEAP_POISONING_DISABLED=y -# CONFIG_HEAP_POISONING_LIGHT is not set +# CONFIG_HEAP_POISONING_DISABLED is not set +CONFIG_HEAP_POISONING_LIGHT=y # CONFIG_HEAP_POISONING_COMPREHENSIVE is not set CONFIG_HEAP_TRACING_OFF=y # CONFIG_HEAP_TRACING_STANDALONE is not set # CONFIG_HEAP_TRACING_TOHOST is not set +# CONFIG_HEAP_TASK_TRACKING is not set # CONFIG_HEAP_ABORT_WHEN_ALLOCATION_FAILS is not set # end of Heap memory debugging @@ -1104,11 +1220,11 @@ CONFIG_LWIP_IP6_FRAG=y # CONFIG_LWIP_IP6_REASSEMBLY is not set # CONFIG_LWIP_IP_FORWARD is not set # CONFIG_LWIP_STATS is not set -# CONFIG_LWIP_ETHARP_TRUST_IP_MAC is not set +CONFIG_LWIP_ETHARP_TRUST_IP_MAC=y CONFIG_LWIP_ESP_GRATUITOUS_ARP=y CONFIG_LWIP_GARP_TMR_INTERVAL=60 CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=32 -CONFIG_LWIP_DHCP_DOES_ARP_CHECK=y +# CONFIG_LWIP_DHCP_DOES_ARP_CHECK is not set # CONFIG_LWIP_DHCP_DISABLE_CLIENT_ID is not set CONFIG_LWIP_DHCP_DISABLE_VENDOR_CLASS_ID=y CONFIG_LWIP_DHCP_RESTORE_LAST_IP=y @@ -1124,9 +1240,11 @@ CONFIG_LWIP_DHCPS_MAX_STATION_NUM=8 # CONFIG_LWIP_AUTOIP is not set CONFIG_LWIP_IPV6=y -# CONFIG_LWIP_IPV6_AUTOCONFIG is not set +CONFIG_LWIP_IPV6_AUTOCONFIG=y CONFIG_LWIP_IPV6_NUM_ADDRESSES=3 # CONFIG_LWIP_IPV6_FORWARD is not set +CONFIG_LWIP_IPV6_RDNSS_MAX_DNS_SERVERS=0 +# CONFIG_LWIP_IPV6_DHCP6 is not set # CONFIG_LWIP_NETIF_STATUS_CALLBACK is not set CONFIG_LWIP_NETIF_LOOPBACK=y CONFIG_LWIP_LOOPBACK_MAX_PBUFS=8 @@ -1138,8 +1256,8 @@ CONFIG_LWIP_MAX_ACTIVE_TCP=16 CONFIG_LWIP_MAX_LISTENING_TCP=16 CONFIG_LWIP_TCP_HIGH_SPEED_RETRANSMISSION=y CONFIG_LWIP_TCP_MAXRTX=12 -CONFIG_LWIP_TCP_SYNMAXRTX=12 -CONFIG_LWIP_TCP_MSS=1440 +CONFIG_LWIP_TCP_SYNMAXRTX=6 +CONFIG_LWIP_TCP_MSS=1436 CONFIG_LWIP_TCP_TMR_INTERVAL=250 CONFIG_LWIP_TCP_MSL=60000 CONFIG_LWIP_TCP_SND_BUF_DEFAULT=5744 @@ -1151,7 +1269,7 @@ CONFIG_LWIP_TCP_QUEUE_OOSEQ=y CONFIG_LWIP_TCP_OVERSIZE_MSS=y # CONFIG_LWIP_TCP_OVERSIZE_QUARTER_MSS is not set # CONFIG_LWIP_TCP_OVERSIZE_DISABLE is not set -CONFIG_LWIP_TCP_RTO_TIME=1500 +CONFIG_LWIP_TCP_RTO_TIME=3000 # end of TCP # @@ -1169,10 +1287,10 @@ CONFIG_LWIP_UDP_RECVMBOX_SIZE=6 CONFIG_LWIP_CHECKSUM_CHECK_ICMP=y # end of Checksums -CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=3072 -CONFIG_LWIP_TCPIP_TASK_AFFINITY_NO_AFFINITY=y -# CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU0 is not set -CONFIG_LWIP_TCPIP_TASK_AFFINITY=0x7FFFFFFF +CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=2560 +# CONFIG_LWIP_TCPIP_TASK_AFFINITY_NO_AFFINITY is not set +CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU0=y +CONFIG_LWIP_TCPIP_TASK_AFFINITY=0x0 # CONFIG_LWIP_PPP_SUPPORT is not set CONFIG_LWIP_IPV6_MEMP_NUM_ND6_QUEUE=3 CONFIG_LWIP_IPV6_ND6_NUM_NEIGHBORS=5 @@ -1198,7 +1316,7 @@ CONFIG_LWIP_MAX_RAW_PCBS=16 CONFIG_LWIP_SNTP_MAX_SERVERS=3 CONFIG_LWIP_DHCP_GET_NTP_SRV=y CONFIG_LWIP_DHCP_MAX_NTP_SERVERS=1 -CONFIG_LWIP_SNTP_UPDATE_DELAY=3600000 +CONFIG_LWIP_SNTP_UPDATE_DELAY=10800000 # end of SNTP CONFIG_LWIP_ESP_LWIP_ASSERT=y @@ -1229,10 +1347,8 @@ CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_NONE=y CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC=y # CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC is not set # CONFIG_MBEDTLS_CUSTOM_MEM_ALLOC is not set -CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN=y -CONFIG_MBEDTLS_SSL_IN_CONTENT_LEN=16384 -CONFIG_MBEDTLS_SSL_OUT_CONTENT_LEN=4096 -# CONFIG_MBEDTLS_DYNAMIC_BUFFER is not set +CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=16384 +# CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN is not set # CONFIG_MBEDTLS_DEBUG is not set # @@ -1242,6 +1358,13 @@ CONFIG_MBEDTLS_SSL_OUT_CONTENT_LEN=4096 # CONFIG_MBEDTLS_X509_TRUSTED_CERT_CALLBACK is not set # CONFIG_MBEDTLS_SSL_CONTEXT_SERIALIZATION is not set CONFIG_MBEDTLS_SSL_KEEP_PEER_CERTIFICATE=y + +# +# DTLS-based configurations +# +# CONFIG_MBEDTLS_SSL_DTLS_CONNECTION_ID is not set +# CONFIG_MBEDTLS_SSL_DTLS_SRTP is not set +# end of DTLS-based configurations # end of mbedTLS v2.28.x related # @@ -1252,6 +1375,7 @@ CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=y # CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN is not set # CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE is not set # CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE is not set +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS=200 # end of Certificate Bundle # CONFIG_MBEDTLS_ECP_RESTARTABLE is not set @@ -1298,7 +1422,7 @@ CONFIG_MBEDTLS_SSL_PROTO_TLS1=y CONFIG_MBEDTLS_SSL_PROTO_TLS1_1=y CONFIG_MBEDTLS_SSL_PROTO_TLS1_2=y # CONFIG_MBEDTLS_SSL_PROTO_GMTSSL1_1 is not set -# CONFIG_MBEDTLS_SSL_PROTO_DTLS is not set +CONFIG_MBEDTLS_SSL_PROTO_DTLS=y CONFIG_MBEDTLS_SSL_ALPN=y CONFIG_MBEDTLS_CLIENT_SSL_SESSION_TICKETS=y CONFIG_MBEDTLS_X509_CHECK_KEY_USAGE=y @@ -1403,6 +1527,7 @@ CONFIG_NEWLIB_STDIN_LINE_ENDING_CR=y # # NVS # +# CONFIG_NVS_ASSERT_ERROR_CHECK is not set # end of NVS # @@ -1410,8 +1535,8 @@ CONFIG_NEWLIB_STDIN_LINE_ENDING_CR=y # # CONFIG_OPENSSL_DEBUG is not set CONFIG_OPENSSL_ERROR_STACK=y -# CONFIG_OPENSSL_ASSERT_DO_NOTHING is not set -CONFIG_OPENSSL_ASSERT_EXIT=y +CONFIG_OPENSSL_ASSERT_DO_NOTHING=y +# CONFIG_OPENSSL_ASSERT_EXIT is not set # end of OpenSSL # @@ -1424,7 +1549,7 @@ CONFIG_OPENSSL_ASSERT_EXIT=y # PThreads # CONFIG_PTHREAD_TASK_PRIO_DEFAULT=5 -CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT=3072 +CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT=2048 CONFIG_PTHREAD_STACK_MIN=768 CONFIG_PTHREAD_TASK_CORE_DEFAULT=-1 CONFIG_PTHREAD_TASK_NAME_DEFAULT="pthread" @@ -1444,10 +1569,10 @@ CONFIG_SPI_FLASH_DANGEROUS_WRITE_ABORTS=y # CONFIG_SPI_FLASH_SHARE_SPI1_BUS is not set # CONFIG_SPI_FLASH_BYPASS_BLOCK_ERASE is not set CONFIG_SPI_FLASH_YIELD_DURING_ERASE=y -CONFIG_SPI_FLASH_ERASE_YIELD_DURATION_MS=20 -CONFIG_SPI_FLASH_ERASE_YIELD_TICKS=1 +CONFIG_SPI_FLASH_ERASE_YIELD_DURATION_MS=10 +CONFIG_SPI_FLASH_ERASE_YIELD_TICKS=2 # CONFIG_SPI_FLASH_AUTO_SUSPEND is not set -CONFIG_SPI_FLASH_WRITE_CHUNK_SIZE=8192 +CONFIG_SPI_FLASH_WRITE_CHUNK_SIZE=4096 # CONFIG_SPI_FLASH_SIZE_OVERRIDE is not set # CONFIG_SPI_FLASH_CHECK_ERASE_TIMEOUT_DISABLED is not set # CONFIG_SPI_FLASH_OVERRIDE_CHIP_DRIVER_LIST is not set @@ -1539,7 +1664,6 @@ CONFIG_VFS_SUPPORT_TERMIOS=y # Host File System I/O (Semihosting) # CONFIG_VFS_SEMIHOSTFS_MAX_MOUNT_POINTS=1 -CONFIG_VFS_SEMIHOSTFS_HOST_PATH_MAX_LEN=128 # end of Host File System I/O (Semihosting) # end of Virtual file system @@ -1556,7 +1680,7 @@ CONFIG_WL_SECTOR_SIZE=4096 # CONFIG_WIFI_PROV_SCAN_MAX_ENTRIES=16 CONFIG_WIFI_PROV_AUTOSTOP_TIMEOUT=30 -# CONFIG_WIFI_PROV_BLE_BONDING is not set +CONFIG_WIFI_PROV_BLE_BONDING=y # end of Wi-Fi Provisioning Manager # @@ -1569,6 +1693,8 @@ CONFIG_WPA_MBEDTLS_CRYPTO=y # CONFIG_WPA_TESTING_OPTIONS is not set # CONFIG_WPA_WPS_STRICT is not set # CONFIG_WPA_11KV_SUPPORT is not set +# CONFIG_WPA_MBO_SUPPORT is not set +# CONFIG_WPA_DPP_SUPPORT is not set # end of Supplicant # @@ -1588,7 +1714,10 @@ CONFIG_ESP_RMAKER_MQTT_PORT_443=y CONFIG_ESP_RMAKER_MQTT_PORT=1 # CONFIG_ESP_RMAKER_MQTT_PERSISTENT_SESSION is not set CONFIG_ESP_RMAKER_MQTT_SEND_USERNAME=y -CONFIG_ESP_RMAKER_MQTT_USERNAME="?Platform=APN/1 ESPIF,RAINMAKER,v1.0" +CONFIG_ESP_RMAKER_MQTT_PRODUCT_NAME="RMDev" +CONFIG_ESP_RMAKER_MQTT_PRODUCT_VERSION="1x0" +CONFIG_ESP_RMAKER_MQTT_PRODUCT_SKU="ES00" +CONFIG_ESP_RMAKER_MQTT_USE_CERT_BUNDLE=y CONFIG_ESP_RMAKER_WORK_QUEUE_TASK_STACK=4096 CONFIG_ESP_RMAKER_WORK_QUEUE_TASK_PRIORITY=5 CONFIG_ESP_RMAKER_FACTORY_PARTITION_NAME="fctry" @@ -1618,6 +1747,32 @@ CONFIG_DSP_MAX_FFT_SIZE_4096=y CONFIG_DSP_MAX_FFT_SIZE=4096 # end of DSP Library +# +# Camera configuration +# +CONFIG_OV7670_SUPPORT=y +CONFIG_OV7725_SUPPORT=y +CONFIG_NT99141_SUPPORT=y +CONFIG_OV2640_SUPPORT=y +CONFIG_OV3660_SUPPORT=y +CONFIG_OV5640_SUPPORT=y +CONFIG_GC2145_SUPPORT=y +CONFIG_GC032A_SUPPORT=y +CONFIG_GC0308_SUPPORT=y +CONFIG_BF3005_SUPPORT=y +CONFIG_BF20A6_SUPPORT=y +CONFIG_SC030IOT_SUPPORT=y +# CONFIG_SCCB_HARDWARE_I2C_PORT0 is not set +CONFIG_SCCB_HARDWARE_I2C_PORT1=y +CONFIG_SCCB_CLK_FREQ=100000 +# CONFIG_GC_SENSOR_WINDOWING_MODE is not set +CONFIG_GC_SENSOR_SUBSAMPLE_MODE=y +CONFIG_CAMERA_CORE0=y +# CONFIG_CAMERA_CORE1 is not set +# CONFIG_CAMERA_NO_AFFINITY is not set +CONFIG_CAMERA_DMA_BUFFER_SIZE_MAX=32768 +# end of Camera configuration + # # LittleFS # @@ -1885,8 +2040,8 @@ CONFIG_ESP32S2_ALLOW_RTC_FAST_MEM_AS_HEAP=y CONFIG_ESP32H2_MEMPROT_FEATURE=y CONFIG_ESP32H2_MEMPROT_FEATURE_LOCK=y CONFIG_SYSTEM_EVENT_QUEUE_SIZE=32 -CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE=2304 -CONFIG_MAIN_TASK_STACK_SIZE=3584 +CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE=2048 +CONFIG_MAIN_TASK_STACK_SIZE=4096 CONFIG_CONSOLE_UART_DEFAULT=y # CONFIG_CONSOLE_UART_CUSTOM is not set # CONFIG_ESP_CONSOLE_UART_NONE is not set @@ -1896,11 +2051,11 @@ CONFIG_CONSOLE_UART_BAUDRATE=115200 CONFIG_INT_WDT=y CONFIG_INT_WDT_TIMEOUT_MS=300 CONFIG_TASK_WDT=y -# CONFIG_TASK_WDT_PANIC is not set +CONFIG_TASK_WDT_PANIC=y CONFIG_TASK_WDT_TIMEOUT_S=5 -CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU0=y +# CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU0 is not set # CONFIG_ESP32_DEBUG_STUBS_ENABLE is not set -CONFIG_TIMER_TASK_STACK_SIZE=3584 +CONFIG_TIMER_TASK_STACK_SIZE=4096 CONFIG_SW_COEXIST_ENABLE=y # CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH is not set # CONFIG_ESP32_ENABLE_COREDUMP_TO_UART is not set @@ -1911,8 +2066,7 @@ CONFIG_MB_QUEUE_LENGTH=20 CONFIG_MB_SERIAL_TASK_STACK_SIZE=4096 CONFIG_MB_SERIAL_BUF_SIZE=256 CONFIG_MB_SERIAL_TASK_PRIO=10 -CONFIG_MB_CONTROLLER_SLAVE_ID_SUPPORT=y -CONFIG_MB_CONTROLLER_SLAVE_ID=0x00112233 +# CONFIG_MB_CONTROLLER_SLAVE_ID_SUPPORT is not set CONFIG_MB_CONTROLLER_NOTIFY_TIMEOUT=20 CONFIG_MB_CONTROLLER_NOTIFY_QUEUE_SIZE=20 CONFIG_MB_CONTROLLER_STACK_SIZE=4096 @@ -1930,8 +2084,8 @@ CONFIG_ESP_GRATUITOUS_ARP=y CONFIG_GARP_TMR_INTERVAL=60 CONFIG_TCPIP_RECVMBOX_SIZE=32 CONFIG_TCP_MAXRTX=12 -CONFIG_TCP_SYNMAXRTX=12 -CONFIG_TCP_MSS=1440 +CONFIG_TCP_SYNMAXRTX=6 +CONFIG_TCP_MSS=1436 CONFIG_TCP_MSL=60000 CONFIG_TCP_SND_BUF_DEFAULT=5744 CONFIG_TCP_WND_DEFAULT=5744 @@ -1942,13 +2096,13 @@ CONFIG_TCP_OVERSIZE_MSS=y # CONFIG_TCP_OVERSIZE_QUARTER_MSS is not set # CONFIG_TCP_OVERSIZE_DISABLE is not set CONFIG_UDP_RECVMBOX_SIZE=6 -CONFIG_TCPIP_TASK_STACK_SIZE=3072 -CONFIG_TCPIP_TASK_AFFINITY_NO_AFFINITY=y -# CONFIG_TCPIP_TASK_AFFINITY_CPU0 is not set -CONFIG_TCPIP_TASK_AFFINITY=0x7FFFFFFF +CONFIG_TCPIP_TASK_STACK_SIZE=2560 +# CONFIG_TCPIP_TASK_AFFINITY_NO_AFFINITY is not set +CONFIG_TCPIP_TASK_AFFINITY_CPU0=y +CONFIG_TCPIP_TASK_AFFINITY=0x0 # CONFIG_PPP_SUPPORT is not set CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT=5 -CONFIG_ESP32_PTHREAD_TASK_STACK_SIZE_DEFAULT=3072 +CONFIG_ESP32_PTHREAD_TASK_STACK_SIZE_DEFAULT=2048 CONFIG_ESP32_PTHREAD_STACK_MIN=768 CONFIG_ESP32_PTHREAD_TASK_CORE_DEFAULT=-1 CONFIG_ESP32_PTHREAD_TASK_NAME_DEFAULT="pthread" @@ -1958,5 +2112,4 @@ CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ABORTS=y CONFIG_SUPPRESS_SELECT_DEBUG_OUTPUT=y CONFIG_SUPPORT_TERMIOS=y CONFIG_SEMIHOSTFS_MAX_MOUNT_POINTS=1 -CONFIG_SEMIHOSTFS_HOST_PATH_MAX_LEN=128 # End of deprecated options diff --git a/tools/sdk/esp32s2/bin/bootloader_dio_40m.bin b/tools/sdk/esp32s2/bin/bootloader_dio_40m.bin index 2c6b9e2fe14..022834066b9 100644 Binary files a/tools/sdk/esp32s2/bin/bootloader_dio_40m.bin and b/tools/sdk/esp32s2/bin/bootloader_dio_40m.bin differ diff --git a/tools/sdk/esp32s2/bin/bootloader_dio_80m.bin b/tools/sdk/esp32s2/bin/bootloader_dio_80m.bin index 8df299a5f12..3adcca19f28 100644 Binary files a/tools/sdk/esp32s2/bin/bootloader_dio_80m.bin and b/tools/sdk/esp32s2/bin/bootloader_dio_80m.bin differ diff --git a/tools/sdk/esp32s2/bin/bootloader_dout_40m.bin b/tools/sdk/esp32s2/bin/bootloader_dout_40m.bin index 2c6b9e2fe14..022834066b9 100644 Binary files a/tools/sdk/esp32s2/bin/bootloader_dout_40m.bin and b/tools/sdk/esp32s2/bin/bootloader_dout_40m.bin differ diff --git a/tools/sdk/esp32s2/bin/bootloader_dout_80m.bin b/tools/sdk/esp32s2/bin/bootloader_dout_80m.bin index 8df299a5f12..3adcca19f28 100644 Binary files a/tools/sdk/esp32s2/bin/bootloader_dout_80m.bin and b/tools/sdk/esp32s2/bin/bootloader_dout_80m.bin differ diff --git a/tools/sdk/esp32s2/bin/bootloader_qio_40m.bin b/tools/sdk/esp32s2/bin/bootloader_qio_40m.bin index d84d7af6104..0fc784fb669 100644 Binary files a/tools/sdk/esp32s2/bin/bootloader_qio_40m.bin and b/tools/sdk/esp32s2/bin/bootloader_qio_40m.bin differ diff --git a/tools/sdk/esp32s2/bin/bootloader_qio_80m.bin b/tools/sdk/esp32s2/bin/bootloader_qio_80m.bin index 62c647bd0d8..38f8745b64b 100644 Binary files a/tools/sdk/esp32s2/bin/bootloader_qio_80m.bin and b/tools/sdk/esp32s2/bin/bootloader_qio_80m.bin differ diff --git a/tools/sdk/esp32s2/bin/bootloader_qout_40m.bin b/tools/sdk/esp32s2/bin/bootloader_qout_40m.bin index d26a89c09ff..a0a525c2c4d 100644 Binary files a/tools/sdk/esp32s2/bin/bootloader_qout_40m.bin and b/tools/sdk/esp32s2/bin/bootloader_qout_40m.bin differ diff --git a/tools/sdk/esp32s2/bin/bootloader_qout_80m.bin b/tools/sdk/esp32s2/bin/bootloader_qout_80m.bin index 4d6daaaeaa4..0452e0c3ea5 100644 Binary files a/tools/sdk/esp32s2/bin/bootloader_qout_80m.bin and b/tools/sdk/esp32s2/bin/bootloader_qout_80m.bin differ diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/audio/audio_device.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/audio/audio_device.h index f406cf28110..0ef100fa4c3 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/audio/audio_device.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/audio/audio_device.h @@ -458,7 +458,14 @@ TU_ATTR_WEAK bool tud_audio_rx_done_post_read_cb(uint8_t rhport, uint16_t n_byte #endif #if CFG_TUD_AUDIO_ENABLE_EP_OUT && CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP -TU_ATTR_WEAK bool tud_audio_fb_done_cb(uint8_t rhport); +TU_ATTR_WEAK void tud_audio_fb_done_cb(uint8_t func_id); + + +// determined by the user itself and set by use of tud_audio_n_fb_set(). The feedback value may be determined e.g. from some fill status of some FIFO buffer. Advantage: No ISR interrupt is enabled, hence the CPU need not to handle an ISR every 1ms or 125us and thus less CPU load, disadvantage: typically a larger FIFO is needed to compensate for jitter (e.g. 8 frames), i.e. a larger delay is introduced. + +// Feedback value is calculated within the audio driver by use of SOF interrupt. The driver needs information about the master clock f_m from which the audio sample frequency f_s is derived, f_s itself, and the cycle count of f_m at time of the SOF interrupt (e.g. by use of a hardware counter) - see tud_audio_set_fb_params(). Advantage: Reduced jitter in the feedback value computation, hence, the receive FIFO can be smaller (e.g. 2 frames) and thus a smaller delay is possible, disadvantage: higher CPU load due to SOF ISR handling every frame i.e. 1ms or 125us. This option is a great starting point to try the SOF ISR option but depending on your hardware setup (performance of the CPU) it might not work. If so, figure out why and use the next option. (The most critical point is the reading of the cycle counter value of f_m. It is read from within the SOF ISR - see: audiod_sof() -, hence, the ISR must has a high priority such that no software dependent "random" delay i.e. jitter is introduced). + +// Feedback value is determined by the user by use of SOF interrupt. The user may use tud_audio_sof_isr() which is called every SOF (of course only invoked when an alternate interface other than zero was set). The number of frames used to determine the feedback value for the currently active alternate setting can be get by tud_audio_get_fb_n_frames(). The feedback value must be set by use of tud_audio_n_fb_set(). // This function is used to provide data rate feedback from an asynchronous sink. Feedback value will be sent at FB endpoint interval till it's changed. // @@ -468,9 +475,61 @@ TU_ATTR_WEAK bool tud_audio_fb_done_cb(uint8_t rhport); // // Note that due to a bug in its USB Audio 2.0 driver, Windows currently requires 16.16 format for _all_ USB 2.0 devices. On Linux and macOS it seems the // driver can work with either format. So a good compromise is to keep format correction disabled and stick to 16.16 format. + +// Feedback value can be determined from within the SOF ISR of the audio driver. This should reduce jitter. If the feature is used, the user can not set the feedback value. + +// Determine feedback value - The feedback method is described in 5.12.4.2 of the USB 2.0 spec +// Boiled down, the feedback value Ff = n_samples / (micro)frame. +// Since an accuracy of less than 1 Sample / second is desired, at least n_frames = ceil(2^K * f_s / f_m) frames need to be measured, where K = 10 for full speed and K = 13 for high speed, f_s is the sampling frequency e.g. 48 kHz and f_m is the cpu clock frequency e.g. 100 MHz (or any other master clock whose clock count is available and locked to f_s) +// The update interval in the (4.10.2.1) Feedback Endpoint Descriptor must be less or equal to 2^(K - P), where P = min( ceil(log2(f_m / f_s)), K) +// feedback = n_cycles / n_frames * f_s / f_m in 16.16 format, where n_cycles are the number of main clock cycles within fb_n_frames + bool tud_audio_n_fb_set(uint8_t func_id, uint32_t feedback); static inline bool tud_audio_fb_set(uint32_t feedback); + +// Update feedback value with passed cycles since last time this update function is called. +// Typically called within tud_audio_sof_isr(). Required tud_audio_feedback_params_cb() is implemented +// This function will also call tud_audio_feedback_set() +// return feedback value in 16.16 for reference (0 for error) +uint32_t tud_audio_feedback_update(uint8_t func_id, uint32_t cycles); + +enum { + AUDIO_FEEDBACK_METHOD_DISABLED, + AUDIO_FEEDBACK_METHOD_FREQUENCY_FIXED, + AUDIO_FEEDBACK_METHOD_FREQUENCY_FLOAT, + AUDIO_FEEDBACK_METHOD_FREQUENCY_POWER_OF_2, + + // impelemnt later + // AUDIO_FEEDBACK_METHOD_FIFO_COUNT +}; + +typedef struct { + uint8_t method; + uint32_t sample_freq; // sample frequency in Hz + + union { + struct { + uint32_t mclk_freq; // Main clock frequency in Hz i.e. master clock to which sample clock is based on + }frequency; + +#if 0 // implement later + struct { + uint32_t threshold_bytes; // minimum number of bytes received to be considered as filled/ready + }fifo_count; #endif + }; +}audio_feedback_params_t; + +// Invoked when needed to set feedback parameters +TU_ATTR_WEAK void tud_audio_feedback_params_cb(uint8_t func_id, uint8_t alt_itf, audio_feedback_params_t* feedback_param); + +// Callback in ISR context, invoked periodically according to feedback endpoint bInterval. +// Could be used to compute and update feedback value, should be placed in RAM if possible +// frame_number : current SOF count +// interval_shift: number of bit shift i.e log2(interval) from Feedback endpoint descriptor +TU_ATTR_WEAK TU_ATTR_FAST_FUNC void tud_audio_feedback_interval_isr(uint8_t func_id, uint32_t frame_number, uint8_t interval_shift); + +#endif // CFG_TUD_AUDIO_ENABLE_EP_OUT && CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP #if CFG_TUD_AUDIO_INT_CTR_EPSIZE_IN TU_ATTR_WEAK bool tud_audio_int_ctr_done_cb(uint8_t rhport, uint16_t n_bytes_copied); @@ -612,10 +671,12 @@ static inline uint16_t tud_audio_int_ctr_write(uint8_t const* buffer, uint16_t l #endif #if CFG_TUD_AUDIO_ENABLE_EP_OUT && CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP + static inline bool tud_audio_fb_set(uint32_t feedback) { return tud_audio_n_fb_set(0, feedback); } + #endif //--------------------------------------------------------------------+ @@ -626,6 +687,7 @@ void audiod_reset (uint8_t rhport); uint16_t audiod_open (uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t max_len); bool audiod_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t const * request); bool audiod_xfer_cb (uint8_t rhport, uint8_t edpt_addr, xfer_result_t result, uint32_t xferred_bytes); +void audiod_sof_isr (uint8_t rhport, uint32_t frame_count); #ifdef __cplusplus } diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/usbtmc/usbtmc_device.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/usbtmc/usbtmc_device.h index 0549a1569e8..5dc4d2dffba 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/usbtmc/usbtmc_device.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/class/usbtmc/usbtmc_device.h @@ -37,7 +37,7 @@ // USB spec says that full-speed must be 8,16,32, or 64. // However, this driver implementation requires it to be >=32 -#define USBTMCD_MAX_PACKET_SIZE (64u) +#define USBTMCD_MAX_PACKET_SIZE (TUD_OPT_HIGH_SPEED ? 512 : 64) /*********************************************** * Functions to be implemeted by the class implementation diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_common.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_common.h index 58591f0bea0..b1ee40a1a54 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_common.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_common.h @@ -134,12 +134,6 @@ TU_ATTR_ALWAYS_INLINE static inline uint32_t tu_offset4k(uint32_t value) { retur //------------- Mathematics -------------// TU_ATTR_ALWAYS_INLINE static inline uint32_t tu_div_ceil(uint32_t v, uint32_t d) { return (v + d -1)/d; } -/// inclusive range checking TODO remove -TU_ATTR_ALWAYS_INLINE static inline bool tu_within(uint32_t lower, uint32_t value, uint32_t upper) -{ - return (lower <= value) && (value <= upper); -} - // log2 of a value is its MSB's position // TODO use clz TODO remove static inline uint8_t tu_log2(uint32_t value) @@ -149,6 +143,16 @@ static inline uint8_t tu_log2(uint32_t value) return result; } +//static inline uint8_t tu_log2(uint32_t value) +//{ +// return sizeof(uint32_t) * CHAR_BIT - __builtin_clz(x) - 1; +//} + +static inline bool tu_is_power_of_two(uint32_t value) +{ + return (value != 0) && ((value & (value - 1)) == 0); +} + //------------- Unaligned Access -------------// #if TUP_ARCH_STRICT_ALIGN diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_debug.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_debug.h index 647e8a8db5d..ac5bee6ece6 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_debug.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_debug.h @@ -57,7 +57,7 @@ void tu_print_mem(void const *buf, uint32_t count, uint8_t indent); #define tu_printf printf #endif -static inline void tu_print_var(uint8_t const* buf, uint32_t bufsize) +static inline void tu_print_arr(uint8_t const* buf, uint32_t bufsize) { for(uint32_t i=0; i= 2 #define TU_LOG2 TU_LOG1 #define TU_LOG2_MEM TU_LOG1_MEM + #define TU_LOG2_ARR TU_LOG1_ARR #define TU_LOG2_VAR TU_LOG1_VAR #define TU_LOG2_INT TU_LOG1_INT #define TU_LOG2_HEX TU_LOG1_HEX @@ -91,6 +94,7 @@ static inline void tu_print_var(uint8_t const* buf, uint32_t bufsize) #if CFG_TUSB_DEBUG >= 3 #define TU_LOG3 TU_LOG1 #define TU_LOG3_MEM TU_LOG1_MEM + #define TU_LOG3_ARR TU_LOG1_ARR #define TU_LOG3_VAR TU_LOG1_VAR #define TU_LOG3_INT TU_LOG1_INT #define TU_LOG3_HEX TU_LOG1_HEX diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_mcu.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_mcu.h index 8eb4ad47581..383a8d68603 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_mcu.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_mcu.h @@ -45,8 +45,7 @@ * - ENDPOINT_MAX: max (logical) number of endpoint * - ENDPOINT_EXCLUSIVE_NUMBER: endpoint number with different direction IN and OUT aren't allowed, * e.g EP1 OUT & EP1 IN cannot exist together - * - RHPORT_HIGHSPEED: mask to indicate which port support highspeed mode (without external PHY) - * bit0 for port0 and so on. + * - RHPORT_HIGHSPEED: support highspeed with on-chip PHY */ //------------- NXP -------------// @@ -63,8 +62,7 @@ #define TUP_USBIP_EHCI #define TUP_DCD_ENDPOINT_MAX 6 - #define TUP_RHPORT_HIGHSPEED 0x01 // Port0 HS, Port1 FS - + #define TUP_RHPORT_HIGHSPEED 1 // Port0 HS, Port1 FS #elif TU_CHECK_MCU(OPT_MCU_LPC51UXX) #define TUP_DCD_ENDPOINT_MAX 5 @@ -82,8 +80,7 @@ #define TUP_USBIP_EHCI #define TUP_DCD_ENDPOINT_MAX 8 - #define TUP_RHPORT_HIGHSPEED 0x03 // Port0 HS, Port1 HS - + #define TUP_RHPORT_HIGHSPEED 1 // Port0 HS, Port1 HS #elif TU_CHECK_MCU(OPT_MCU_MKL25ZXX, OPT_MCU_K32L2BXX) #define TUP_DCD_ENDPOINT_MAX 16 @@ -107,7 +104,7 @@ #elif TU_CHECK_MCU(OPT_MCU_SAMX7X) #define TUP_DCD_ENDPOINT_MAX 10 - #define TUP_RHPORT_HIGHSPEED 0x01 + #define TUP_RHPORT_HIGHSPEED 1 #define TUP_DCD_ENDPOINT_EXCLUSIVE_NUMBER #elif TU_CHECK_MCU(OPT_MCU_PIC32MZ) @@ -155,7 +152,7 @@ // MCU with on-chip HS Phy #if defined(STM32F723xx) || defined(STM32F730xx) || defined(STM32F733xx) - #define TUP_RHPORT_HIGHSPEED 0x02 // Port 0: FS, Port 1: HS + #define TUP_RHPORT_HIGHSPEED 1 // Port0: FS, Port1: HS #endif #elif TU_CHECK_MCU(OPT_MCU_STM32H7) @@ -185,12 +182,12 @@ #endif #elif TU_CHECK_MCU(OPT_MCU_STM32WB) -#define TUP_DCD_ENDPOINT_MAX 8 + #define TUP_DCD_ENDPOINT_MAX 8 //------------- Sony -------------// #elif TU_CHECK_MCU(OPT_MCU_CXD56) #define TUP_DCD_ENDPOINT_MAX 7 - #define TUP_RHPORT_HIGHSPEED 0x01 + #define TUP_RHPORT_HIGHSPEED 1 #define TUP_DCD_ENDPOINT_EXCLUSIVE_NUMBER //------------- TI -------------// @@ -213,7 +210,7 @@ #elif TU_CHECK_MCU(OPT_MCU_NUC505) #define TUP_DCD_ENDPOINT_MAX 12 - #define TUP_RHPORT_HIGHSPEED 0x01 + #define TUP_RHPORT_HIGHSPEED 1 //------------- Espressif -------------// #elif TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3) @@ -228,6 +225,8 @@ #elif TU_CHECK_MCU(OPT_MCU_RP2040) #define TUP_DCD_ENDPOINT_MAX 16 + #define TU_ATTR_FAST_FUNC __attribute__((section(".time_critical.tinyusb"))) + //------------- Silabs -------------// #elif TU_CHECK_MCU(OPT_MCU_EFM32GG) #define TUP_USBIP_DWC2 @@ -246,7 +245,7 @@ #elif TU_CHECK_MCU(OPT_MCU_BCM2711, OPT_MCU_BCM2835, OPT_MCU_BCM2837) #define TUP_USBIP_DWC2 #define TUP_DCD_ENDPOINT_MAX 8 - #define TUP_RHPORT_HIGHSPEED 0x01 + #define TUP_RHPORT_HIGHSPEED 1 //------------- Broadcom -------------// #elif TU_CHECK_MCU(OPT_MCU_XMC4000) @@ -256,11 +255,11 @@ //------------- BridgeTek -------------// #elif TU_CHECK_MCU(OPT_MCU_FT90X) #define TUP_DCD_ENDPOINT_MAX 8 - #define TUP_RHPORT_HIGHSPEED 0x01 + #define TUP_RHPORT_HIGHSPEED 1 #elif TU_CHECK_MCU(OPT_MCU_FT93X) #define TUP_DCD_ENDPOINT_MAX 16 - #define TUP_RHPORT_HIGHSPEED 0x01 + #define TUP_RHPORT_HIGHSPEED 1 //------------ Allwinner -------------// #elif TU_CHECK_MCU(OPT_MCU_F1C100S) @@ -279,7 +278,12 @@ // Default to fullspeed if not defined #ifndef TUP_RHPORT_HIGHSPEED - #define TUP_RHPORT_HIGHSPEED 0x00 + #define TUP_RHPORT_HIGHSPEED 0 +#endif + +// fast function, normally mean placing function in SRAM +#ifndef TU_ATTR_FAST_FUNC + #define TU_ATTR_FAST_FUNC #endif #endif diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_types.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_types.h index e2fa175327f..1f2a38d4c7e 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_types.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_types.h @@ -492,23 +492,23 @@ TU_ATTR_BIT_FIELD_ORDER_END //--------------------------------------------------------------------+ // Get direction from Endpoint address -static inline tusb_dir_t tu_edpt_dir(uint8_t addr) +TU_ATTR_ALWAYS_INLINE static inline tusb_dir_t tu_edpt_dir(uint8_t addr) { return (addr & TUSB_DIR_IN_MASK) ? TUSB_DIR_IN : TUSB_DIR_OUT; } // Get Endpoint number from address -static inline uint8_t tu_edpt_number(uint8_t addr) +TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_edpt_number(uint8_t addr) { return (uint8_t)(addr & (~TUSB_DIR_IN_MASK)); } -static inline uint8_t tu_edpt_addr(uint8_t num, uint8_t dir) +TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_edpt_addr(uint8_t num, uint8_t dir) { return (uint8_t)(num | (dir ? TUSB_DIR_IN_MASK : 0)); } -static inline uint16_t tu_edpt_packet_size(tusb_desc_endpoint_t const* desc_ep) +TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_edpt_packet_size(tusb_desc_endpoint_t const* desc_ep) { return tu_le16toh(desc_ep->wMaxPacketSize) & TU_GENMASK(10, 0); } @@ -516,18 +516,18 @@ static inline uint16_t tu_edpt_packet_size(tusb_desc_endpoint_t const* desc_ep) //--------------------------------------------------------------------+ // Descriptor helper //--------------------------------------------------------------------+ -static inline uint8_t const * tu_desc_next(void const* desc) +TU_ATTR_ALWAYS_INLINE static inline uint8_t const * tu_desc_next(void const* desc) { uint8_t const* desc8 = (uint8_t const*) desc; return desc8 + desc8[DESC_OFFSET_LEN]; } -static inline uint8_t tu_desc_type(void const* desc) +TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_desc_type(void const* desc) { return ((uint8_t const*) desc)[DESC_OFFSET_TYPE]; } -static inline uint8_t tu_desc_len(void const* desc) +TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_desc_len(void const* desc) { return ((uint8_t const*) desc)[DESC_OFFSET_LEN]; } diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_verify.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_verify.h index f4a08ce2f91..a52a6d26964 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_verify.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/common/tusb_verify.h @@ -90,6 +90,9 @@ #elif defined(__riscv) #define TU_BREAKPOINT() do { __asm("ebreak\n"); } while(0) +#elif defined(_mips) + #define TU_BREAKPOINT() do { __asm("sdbbp 0"); } while (0) + #else #define TU_BREAKPOINT() do {} while (0) #endif @@ -99,8 +102,8 @@ *------------------------------------------------------------------*/ // Helper to implement optional parameter for TU_VERIFY Macro family -#define GET_3RD_ARG(arg1, arg2, arg3, ...) arg3 -#define GET_4TH_ARG(arg1, arg2, arg3, arg4, ...) arg4 +#define _GET_3RD_ARG(arg1, arg2, arg3, ...) arg3 +#define _GET_4TH_ARG(arg1, arg2, arg3, arg4, ...) arg4 /*------------- Generator for TU_VERIFY and TU_VERIFY_HDLR -------------*/ #define TU_VERIFY_DEFINE(_cond, _handler, _ret) do \ @@ -116,7 +119,7 @@ #define TU_VERIFY_1ARGS(_cond) TU_VERIFY_DEFINE(_cond, , false) #define TU_VERIFY_2ARGS(_cond, _ret) TU_VERIFY_DEFINE(_cond, , _ret) -#define TU_VERIFY(...) GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, UNUSED)(__VA_ARGS__) +#define TU_VERIFY(...) _GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, UNUSED)(__VA_ARGS__) /*------------------------------------------------------------------*/ @@ -127,7 +130,7 @@ #define TU_VERIFY_HDLR_2ARGS(_cond, _handler) TU_VERIFY_DEFINE(_cond, _handler, false) #define TU_VERIFY_HDLR_3ARGS(_cond, _handler, _ret) TU_VERIFY_DEFINE(_cond, _handler, _ret) -#define TU_VERIFY_HDLR(...) GET_4TH_ARG(__VA_ARGS__, TU_VERIFY_HDLR_3ARGS, TU_VERIFY_HDLR_2ARGS,UNUSED)(__VA_ARGS__) +#define TU_VERIFY_HDLR(...) _GET_4TH_ARG(__VA_ARGS__, TU_VERIFY_HDLR_3ARGS, TU_VERIFY_HDLR_2ARGS,UNUSED)(__VA_ARGS__) /*------------------------------------------------------------------*/ /* ASSERT @@ -139,7 +142,7 @@ #define ASSERT_2ARGS(_cond, _ret) TU_VERIFY_DEFINE(_cond, _MESS_FAILED(); TU_BREAKPOINT(), _ret) #ifndef TU_ASSERT -#define TU_ASSERT(...) GET_3RD_ARG(__VA_ARGS__, ASSERT_2ARGS, ASSERT_1ARGS,UNUSED)(__VA_ARGS__) +#define TU_ASSERT(...) _GET_3RD_ARG(__VA_ARGS__, ASSERT_2ARGS, ASSERT_1ARGS,UNUSED)(__VA_ARGS__) #endif /*------------------------------------------------------------------*/ diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/device/dcd.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/device/dcd.h index 8efbc90ef6b..6b99734fed5 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/device/dcd.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/device/dcd.h @@ -77,6 +77,11 @@ typedef struct TU_ATTR_ALIGNED(4) tusb_speed_t speed; } bus_reset; + // SOF + struct { + uint32_t frame_count; + }sof; + // SETUP_RECEIVED tusb_control_request_t setup_received; @@ -132,6 +137,9 @@ void dcd_connect(uint8_t rhport) TU_ATTR_WEAK; // Disconnect by disabling internal pull-up resistor on D+/D- void dcd_disconnect(uint8_t rhport) TU_ATTR_WEAK; +// Enable/Disable Start-of-frame interrupt. Default is disabled +void dcd_sof_enable(uint8_t rhport, bool en); + //--------------------------------------------------------------------+ // Endpoint API //--------------------------------------------------------------------+ @@ -174,16 +182,47 @@ void dcd_edpt_clear_stall (uint8_t rhport, uint8_t ep_addr); extern void dcd_event_handler(dcd_event_t const * event, bool in_isr); // helper to send bus signal event -extern void dcd_event_bus_signal (uint8_t rhport, dcd_eventid_t eid, bool in_isr); +TU_ATTR_ALWAYS_INLINE static inline void dcd_event_bus_signal (uint8_t rhport, dcd_eventid_t eid, bool in_isr) +{ + dcd_event_t event = { .rhport = rhport, .event_id = eid }; + dcd_event_handler(&event, in_isr); +} // helper to send bus reset event -extern void dcd_event_bus_reset (uint8_t rhport, tusb_speed_t speed, bool in_isr); +TU_ATTR_ALWAYS_INLINE static inline void dcd_event_bus_reset (uint8_t rhport, tusb_speed_t speed, bool in_isr) +{ + dcd_event_t event = { .rhport = rhport, .event_id = DCD_EVENT_BUS_RESET }; + event.bus_reset.speed = speed; + dcd_event_handler(&event, in_isr); +} // helper to send setup received -extern void dcd_event_setup_received(uint8_t rhport, uint8_t const * setup, bool in_isr); +TU_ATTR_ALWAYS_INLINE static inline void dcd_event_setup_received(uint8_t rhport, uint8_t const * setup, bool in_isr) +{ + dcd_event_t event = { .rhport = rhport, .event_id = DCD_EVENT_SETUP_RECEIVED }; + memcpy(&event.setup_received, setup, 8); + + dcd_event_handler(&event, in_isr); +} // helper to send transfer complete event -extern void dcd_event_xfer_complete (uint8_t rhport, uint8_t ep_addr, uint32_t xferred_bytes, uint8_t result, bool in_isr); +TU_ATTR_ALWAYS_INLINE static inline void dcd_event_xfer_complete (uint8_t rhport, uint8_t ep_addr, uint32_t xferred_bytes, uint8_t result, bool in_isr) +{ + dcd_event_t event = { .rhport = rhport, .event_id = DCD_EVENT_XFER_COMPLETE }; + + event.xfer_complete.ep_addr = ep_addr; + event.xfer_complete.len = xferred_bytes; + event.xfer_complete.result = result; + + dcd_event_handler(&event, in_isr); +} + +static inline void dcd_event_sof(uint8_t rhport, uint32_t frame_count, bool in_isr) +{ + dcd_event_t event = { .rhport = rhport, .event_id = DCD_EVENT_SOF }; + event.sof.frame_count = frame_count; + dcd_event_handler(&event, in_isr); +} #ifdef __cplusplus } diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/device/usbd.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/device/usbd.h index b2bf8ba9d78..964cfb99224 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/device/usbd.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/device/usbd.h @@ -43,10 +43,19 @@ bool tud_init (uint8_t rhport); // Check if device stack is already initialized bool tud_inited(void); +// Task function should be called in main/rtos loop, extended version of tud_task() +// - timeout_ms: millisecond to wait, zero = no wait, 0xFFFFFFFF = wait forever +// - in_isr: if function is called in ISR +void tud_task_ext(uint32_t timeout_ms, bool in_isr); + // Task function should be called in main/rtos loop -void tud_task (void); +TU_ATTR_ALWAYS_INLINE static inline +void tud_task (void) +{ + tud_task_ext(UINT32_MAX, false); +} -// Check if there is pending events need proccessing by tud_task() +// Check if there is pending events need processing by tud_task() bool tud_task_event_ready(void); // Interrupt handler, name alias to DCD diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/device/usbd_pvt.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/device/usbd_pvt.h index 29753451ebc..6fad46db358 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/device/usbd_pvt.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/device/usbd_pvt.h @@ -48,7 +48,7 @@ typedef struct uint16_t (* open ) (uint8_t rhport, tusb_desc_interface_t const * desc_intf, uint16_t max_len); bool (* control_xfer_cb ) (uint8_t rhport, uint8_t stage, tusb_control_request_t const * request); bool (* xfer_cb ) (uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes); - void (* sof ) (uint8_t rhport); /* optional */ + void (* sof ) (uint8_t rhport, uint32_t frame_count); // optional } usbd_class_driver_t; // Invoked when initializing device stack to get additional class drivers. @@ -62,6 +62,7 @@ void usbd_int_set(bool enabled); //--------------------------------------------------------------------+ // USBD Endpoint API +// Note: rhport should be 0 since device stack only support 1 rhport for now //--------------------------------------------------------------------+ // Open an endpoint @@ -102,6 +103,9 @@ bool usbd_edpt_ready(uint8_t rhport, uint8_t ep_addr) return !usbd_edpt_busy(rhport, ep_addr) && !usbd_edpt_stalled(rhport, ep_addr); } +// Enable SOF interrupt +void usbd_sof_enable(uint8_t rhport, bool en); + /*------------------------------------------------------------------*/ /* Helper *------------------------------------------------------------------*/ diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/hcd.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/hcd.h index c40bea64cec..deebc59d4ed 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/hcd.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/hcd.h @@ -48,7 +48,7 @@ // #endif #endif - //--------------------------------------------------------------------+ +//--------------------------------------------------------------------+ // MACRO CONSTANT TYPEDEF //--------------------------------------------------------------------+ typedef enum @@ -106,6 +106,9 @@ typedef struct // Controller API //--------------------------------------------------------------------+ +// optional hcd configuration, called by tuh_config() +bool hcd_configure(uint8_t rhport, uint32_t cfg_id, const void* cfg_param) TU_ATTR_WEAK; + // Initialize controller to host mode bool hcd_init(uint8_t rhport); @@ -144,9 +147,16 @@ void hcd_device_close(uint8_t rhport, uint8_t dev_addr); // Endpoints API //--------------------------------------------------------------------+ -bool hcd_setup_send(uint8_t rhport, uint8_t dev_addr, uint8_t const setup_packet[8]); +// Open an endpoint bool hcd_edpt_open(uint8_t rhport, uint8_t dev_addr, tusb_desc_endpoint_t const * ep_desc); + +// Submit a transfer, when complete hcd_event_xfer_complete() must be invoked bool hcd_edpt_xfer(uint8_t rhport, uint8_t dev_addr, uint8_t ep_addr, uint8_t * buffer, uint16_t buflen); + +// Submit a special transfer to send 8-byte Setup Packet, when complete hcd_event_xfer_complete() must be invoked +bool hcd_setup_send(uint8_t rhport, uint8_t dev_addr, uint8_t const setup_packet[8]); + +// clear stall, data toggle is also reset to DATA0 bool hcd_edpt_clear_stall(uint8_t dev_addr, uint8_t ep_addr); //--------------------------------------------------------------------+ @@ -164,13 +174,47 @@ extern void hcd_devtree_get_info(uint8_t dev_addr, hcd_devtree_info_t* devtree_i extern void hcd_event_handler(hcd_event_t const* event, bool in_isr); // Helper to send device attach event -extern void hcd_event_device_attach(uint8_t rhport, bool in_isr); +TU_ATTR_ALWAYS_INLINE static inline +void hcd_event_device_attach(uint8_t rhport, bool in_isr) +{ + hcd_event_t event; + event.rhport = rhport; + event.event_id = HCD_EVENT_DEVICE_ATTACH; + event.connection.hub_addr = 0; + event.connection.hub_port = 0; + hcd_event_handler(&event, in_isr); +} // Helper to send device removal event -extern void hcd_event_device_remove(uint8_t rhport, bool in_isr); +TU_ATTR_ALWAYS_INLINE static inline +void hcd_event_device_remove(uint8_t rhport, bool in_isr) +{ + hcd_event_t event; + event.rhport = rhport; + event.event_id = HCD_EVENT_DEVICE_REMOVE; + event.connection.hub_addr = 0; + event.connection.hub_port = 0; + + hcd_event_handler(&event, in_isr); +} // Helper to send USB transfer event -extern void hcd_event_xfer_complete(uint8_t dev_addr, uint8_t ep_addr, uint32_t xferred_bytes, xfer_result_t result, bool in_isr); +TU_ATTR_ALWAYS_INLINE static inline +void hcd_event_xfer_complete(uint8_t dev_addr, uint8_t ep_addr, uint32_t xferred_bytes, xfer_result_t result, bool in_isr) +{ + hcd_event_t event = + { + .rhport = 0, // TODO correct rhport + .event_id = HCD_EVENT_XFER_COMPLETE, + .dev_addr = dev_addr, + }; + event.xfer_complete.ep_addr = ep_addr; + event.xfer_complete.result = result; + event.xfer_complete.len = xferred_bytes; + + + hcd_event_handler(&event, in_isr); +} #ifdef __cplusplus } diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/usbh.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/usbh.h index e883ac90bc7..347c75b8c1b 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/usbh.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/host/usbh.h @@ -46,8 +46,8 @@ typedef void (*tuh_xfer_cb_t)(tuh_xfer_t* xfer); // Note1: layout and order of this will be changed in near future // it is advised to initialize it using member name -// Note2: not all field is available/meaningful in callback, some info is not saved by -// usbh to save SRAM +// Note2: not all field is available/meaningful in callback, +// some info is not saved by usbh to save SRAM struct tuh_xfer_s { uint8_t daddr; @@ -69,6 +69,12 @@ struct tuh_xfer_s // uint32_t timeout_ms; // place holder, not supported yet }; +// ConfigID for tuh_config() +enum +{ + TUH_CFGID_RPI_PIO_USB_CONFIGURATION = OPT_MCU_RP2040 // cfg_param: pio_usb_configuration_t +}; + //--------------------------------------------------------------------+ // APPLICATION CALLBACK //--------------------------------------------------------------------+ @@ -85,14 +91,29 @@ TU_ATTR_WEAK void tuh_umount_cb(uint8_t daddr); // APPLICATION API //--------------------------------------------------------------------+ +// Configure host stack behavior with dynamic or port-specific parameters. +// Should be called before tuh_init() +// - cfg_id : configure ID (TBD) +// - cfg_param: configure data, structure depends on the ID +bool tuh_configure(uint8_t controller_id, uint32_t cfg_id, const void* cfg_param); + // Init host stack -bool tuh_init(uint8_t rhport); +bool tuh_init(uint8_t controller_id); // Check if host stack is already initialized bool tuh_inited(void); +// Task function should be called in main/rtos loop, extended version of tuh_task() +// - timeout_ms: millisecond to wait, zero = no wait, 0xFFFFFFFF = wait forever +// - in_isr: if function is called in ISR +void tuh_task_ext(uint32_t timeout_ms, bool in_isr); + // Task function should be called in main/rtos loop -void tuh_task(void); +TU_ATTR_ALWAYS_INLINE static inline +void tuh_task(void) +{ + tuh_task_ext(UINT32_MAX, false); +} // Interrupt handler, name alias to HCD extern void hcd_int_handler(uint8_t rhport); @@ -106,8 +127,8 @@ tusb_speed_t tuh_speed_get(uint8_t daddr); bool tuh_mounted(uint8_t daddr); // Check if device is suspended -TU_ATTR_ALWAYS_INLINE -static inline bool tuh_suspended(uint8_t daddr) +TU_ATTR_ALWAYS_INLINE static inline +bool tuh_suspended(uint8_t daddr) { // TODO implement suspend & resume on host (void) daddr; @@ -115,8 +136,8 @@ static inline bool tuh_suspended(uint8_t daddr) } // Check if device is ready to communicate with -TU_ATTR_ALWAYS_INLINE -static inline bool tuh_ready(uint8_t daddr) +TU_ATTR_ALWAYS_INLINE static inline +bool tuh_ready(uint8_t daddr) { return tuh_mounted(daddr) && !tuh_suspended(daddr); } diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/osal/osal.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/osal/osal.h index 7111bbdb2a1..9d11866dfd7 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/osal/osal.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/osal/osal.h @@ -66,19 +66,19 @@ typedef void (*osal_task_func_t)( void * ); // OSAL Porting API // Should be implemented as static inline function in osal_port.h header /* - static inline osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t* semdef); - static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr); - static inline bool osal_semaphore_wait(osal_semaphore_t sem_hdl, uint32_t msec); - static inline void osal_semaphore_reset(osal_semaphore_t sem_hdl); // TODO removed + osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t* semdef); + bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr); + bool osal_semaphore_wait(osal_semaphore_t sem_hdl, uint32_t msec); + void osal_semaphore_reset(osal_semaphore_t sem_hdl); // TODO removed - static inline osal_mutex_t osal_mutex_create(osal_mutex_def_t* mdef); - static inline bool osal_mutex_lock (osal_mutex_t sem_hdl, uint32_t msec); - static inline bool osal_mutex_unlock(osal_mutex_t mutex_hdl); + osal_mutex_t osal_mutex_create(osal_mutex_def_t* mdef); + bool osal_mutex_lock (osal_mutex_t sem_hdl, uint32_t msec); + bool osal_mutex_unlock(osal_mutex_t mutex_hdl); - static inline osal_queue_t osal_queue_create(osal_queue_def_t* qdef); - static inline bool osal_queue_receive(osal_queue_t qhdl, void* data); - static inline bool osal_queue_send(osal_queue_t qhdl, void const * data, bool in_isr); - static inline bool osal_queue_empty(osal_queue_t qhdl); + osal_queue_t osal_queue_create(osal_queue_def_t* qdef); + bool osal_queue_receive(osal_queue_t qhdl, void* data, uint32_t msec); + bool osal_queue_send(osal_queue_t qhdl, void const * data, bool in_isr); + bool osal_queue_empty(osal_queue_t qhdl); */ //--------------------------------------------------------------------+ diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/osal/osal_freertos.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/osal/osal_freertos.h index 69a026df5b5..52db336f5bf 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/osal/osal_freertos.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/osal/osal_freertos.h @@ -37,10 +37,24 @@ extern "C" { #endif +TU_ATTR_ALWAYS_INLINE static inline uint32_t _osal_ms2tick(uint32_t msec) +{ + if (msec == OSAL_TIMEOUT_WAIT_FOREVER) return portMAX_DELAY; + if (msec == 0) return 0; + + uint32_t ticks = pdMS_TO_TICKS(msec); + + // configTICK_RATE_HZ is less than 1000 and 1 tick > 1 ms + // we still need to delay at least 1 tick + if (ticks == 0) ticks =1 ; + + return ticks; +} + //--------------------------------------------------------------------+ // TASK API //--------------------------------------------------------------------+ -static inline void osal_task_delay(uint32_t msec) +TU_ATTR_ALWAYS_INLINE static inline void osal_task_delay(uint32_t msec) { vTaskDelay( pdMS_TO_TICKS(msec) ); } @@ -51,12 +65,12 @@ static inline void osal_task_delay(uint32_t msec) typedef StaticSemaphore_t osal_semaphore_def_t; typedef SemaphoreHandle_t osal_semaphore_t; -static inline osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t* semdef) +TU_ATTR_ALWAYS_INLINE static inline osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t* semdef) { return xSemaphoreCreateBinaryStatic(semdef); } -static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr) +TU_ATTR_ALWAYS_INLINE static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr) { if ( !in_isr ) { @@ -78,13 +92,12 @@ static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr) } } -static inline bool osal_semaphore_wait (osal_semaphore_t sem_hdl, uint32_t msec) +TU_ATTR_ALWAYS_INLINE static inline bool osal_semaphore_wait (osal_semaphore_t sem_hdl, uint32_t msec) { - uint32_t const ticks = (msec == OSAL_TIMEOUT_WAIT_FOREVER) ? portMAX_DELAY : pdMS_TO_TICKS(msec); - return xSemaphoreTake(sem_hdl, ticks); + return xSemaphoreTake(sem_hdl, _osal_ms2tick(msec)); } -static inline void osal_semaphore_reset(osal_semaphore_t const sem_hdl) +TU_ATTR_ALWAYS_INLINE static inline void osal_semaphore_reset(osal_semaphore_t const sem_hdl) { xQueueReset(sem_hdl); } @@ -95,17 +108,17 @@ static inline void osal_semaphore_reset(osal_semaphore_t const sem_hdl) typedef StaticSemaphore_t osal_mutex_def_t; typedef SemaphoreHandle_t osal_mutex_t; -static inline osal_mutex_t osal_mutex_create(osal_mutex_def_t* mdef) +TU_ATTR_ALWAYS_INLINE static inline osal_mutex_t osal_mutex_create(osal_mutex_def_t* mdef) { return xSemaphoreCreateMutexStatic(mdef); } -static inline bool osal_mutex_lock (osal_mutex_t mutex_hdl, uint32_t msec) +TU_ATTR_ALWAYS_INLINE static inline bool osal_mutex_lock (osal_mutex_t mutex_hdl, uint32_t msec) { return osal_semaphore_wait(mutex_hdl, msec); } -static inline bool osal_mutex_unlock(osal_mutex_t mutex_hdl) +TU_ATTR_ALWAYS_INLINE static inline bool osal_mutex_unlock(osal_mutex_t mutex_hdl) { return xSemaphoreGive(mutex_hdl); } @@ -114,7 +127,7 @@ static inline bool osal_mutex_unlock(osal_mutex_t mutex_hdl) // QUEUE API //--------------------------------------------------------------------+ -// role device/host is used by OS NONE for mutex (disable usb isr) only +// _int_set is not used with an RTOS #define OSAL_QUEUE_DEF(_int_set, _name, _depth, _type) \ static _type _name##_##buf[_depth];\ osal_queue_def_t _name = { .depth = _depth, .item_sz = sizeof(_type), .buf = _name##_##buf }; @@ -130,17 +143,17 @@ typedef struct typedef QueueHandle_t osal_queue_t; -static inline osal_queue_t osal_queue_create(osal_queue_def_t* qdef) +TU_ATTR_ALWAYS_INLINE static inline osal_queue_t osal_queue_create(osal_queue_def_t* qdef) { return xQueueCreateStatic(qdef->depth, qdef->item_sz, (uint8_t*) qdef->buf, &qdef->sq); } -static inline bool osal_queue_receive(osal_queue_t qhdl, void* data) +TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_receive(osal_queue_t qhdl, void* data, uint32_t msec) { - return xQueueReceive(qhdl, data, portMAX_DELAY); + return xQueueReceive(qhdl, data, _osal_ms2tick(msec)); } -static inline bool osal_queue_send(osal_queue_t qhdl, void const * data, bool in_isr) +TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_send(osal_queue_t qhdl, void const * data, bool in_isr) { if ( !in_isr ) { @@ -162,7 +175,7 @@ static inline bool osal_queue_send(osal_queue_t qhdl, void const * data, bool in } } -static inline bool osal_queue_empty(osal_queue_t qhdl) +TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_empty(osal_queue_t qhdl) { return uxQueueMessagesWaiting(qhdl) == 0; } diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/osal/osal_mynewt.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/osal/osal_mynewt.h index 78a257cd69f..b8ea2087c19 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/osal/osal_mynewt.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/osal/osal_mynewt.h @@ -36,7 +36,7 @@ //--------------------------------------------------------------------+ // TASK API //--------------------------------------------------------------------+ -static inline void osal_task_delay(uint32_t msec) +TU_ATTR_ALWAYS_INLINE static inline void osal_task_delay(uint32_t msec) { os_time_delay( os_time_ms_to_ticks32(msec) ); } @@ -47,18 +47,18 @@ static inline void osal_task_delay(uint32_t msec) typedef struct os_sem osal_semaphore_def_t; typedef struct os_sem* osal_semaphore_t; -static inline osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t* semdef) +TU_ATTR_ALWAYS_INLINE static inline osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t* semdef) { return (os_sem_init(semdef, 0) == OS_OK) ? (osal_semaphore_t) semdef : NULL; } -static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr) +TU_ATTR_ALWAYS_INLINE static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr) { (void) in_isr; return os_sem_release(sem_hdl) == OS_OK; } -static inline bool osal_semaphore_wait(osal_semaphore_t sem_hdl, uint32_t msec) +TU_ATTR_ALWAYS_INLINE static inline bool osal_semaphore_wait(osal_semaphore_t sem_hdl, uint32_t msec) { uint32_t const ticks = (msec == OSAL_TIMEOUT_WAIT_FOREVER) ? OS_TIMEOUT_NEVER : os_time_ms_to_ticks32(msec); return os_sem_pend(sem_hdl, ticks) == OS_OK; @@ -75,18 +75,18 @@ static inline void osal_semaphore_reset(osal_semaphore_t sem_hdl) typedef struct os_mutex osal_mutex_def_t; typedef struct os_mutex* osal_mutex_t; -static inline osal_mutex_t osal_mutex_create(osal_mutex_def_t* mdef) +TU_ATTR_ALWAYS_INLINE static inline osal_mutex_t osal_mutex_create(osal_mutex_def_t* mdef) { return (os_mutex_init(mdef) == OS_OK) ? (osal_mutex_t) mdef : NULL; } -static inline bool osal_mutex_lock(osal_mutex_t mutex_hdl, uint32_t msec) +TU_ATTR_ALWAYS_INLINE static inline bool osal_mutex_lock(osal_mutex_t mutex_hdl, uint32_t msec) { uint32_t const ticks = (msec == OSAL_TIMEOUT_WAIT_FOREVER) ? OS_TIMEOUT_NEVER : os_time_ms_to_ticks32(msec); return os_mutex_pend(mutex_hdl, ticks) == OS_OK; } -static inline bool osal_mutex_unlock(osal_mutex_t mutex_hdl) +TU_ATTR_ALWAYS_INLINE static inline bool osal_mutex_unlock(osal_mutex_t mutex_hdl) { return os_mutex_release(mutex_hdl) == OS_OK; } @@ -116,7 +116,7 @@ typedef struct typedef osal_queue_def_t* osal_queue_t; -static inline osal_queue_t osal_queue_create(osal_queue_def_t* qdef) +TU_ATTR_ALWAYS_INLINE static inline osal_queue_t osal_queue_create(osal_queue_def_t* qdef) { if ( OS_OK != os_mempool_init(&qdef->mpool, qdef->depth, qdef->item_sz, qdef->buf, "usbd queue") ) return NULL; if ( OS_OK != os_mempool_init(&qdef->epool, qdef->depth, sizeof(struct os_event), qdef->evbuf, "usbd evqueue") ) return NULL; @@ -125,8 +125,10 @@ static inline osal_queue_t osal_queue_create(osal_queue_def_t* qdef) return (osal_queue_t) qdef; } -static inline bool osal_queue_receive(osal_queue_t qhdl, void* data) +TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_receive(osal_queue_t qhdl, void* data, uint32_t msec) { + (void) msec; // os_eventq_get() does not take timeout, always behave as msec = WAIT_FOREVER + struct os_event* ev; ev = os_eventq_get(&qhdl->evq); @@ -161,7 +163,7 @@ static inline bool osal_queue_send(osal_queue_t qhdl, void const * data, bool in return true; } -static inline bool osal_queue_empty(osal_queue_t qhdl) +TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_empty(osal_queue_t qhdl) { return STAILQ_EMPTY(&qhdl->evq.evq_list); } diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/osal/osal_none.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/osal/osal_none.h index 4217f042225..9c80e4548d6 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/osal/osal_none.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/osal/osal_none.h @@ -46,13 +46,13 @@ typedef struct typedef osal_semaphore_def_t* osal_semaphore_t; -static inline osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t* semdef) +TU_ATTR_ALWAYS_INLINE static inline osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t* semdef) { semdef->count = 0; return semdef; } -static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr) +TU_ATTR_ALWAYS_INLINE static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr) { (void) in_isr; sem_hdl->count++; @@ -60,7 +60,7 @@ static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr) } // TODO blocking for now -static inline bool osal_semaphore_wait (osal_semaphore_t sem_hdl, uint32_t msec) +TU_ATTR_ALWAYS_INLINE static inline bool osal_semaphore_wait (osal_semaphore_t sem_hdl, uint32_t msec) { (void) msec; @@ -70,7 +70,7 @@ static inline bool osal_semaphore_wait (osal_semaphore_t sem_hdl, uint32_t msec) return true; } -static inline void osal_semaphore_reset(osal_semaphore_t sem_hdl) +TU_ATTR_ALWAYS_INLINE static inline void osal_semaphore_reset(osal_semaphore_t sem_hdl) { sem_hdl->count = 0; } @@ -82,18 +82,18 @@ static inline void osal_semaphore_reset(osal_semaphore_t sem_hdl) typedef osal_semaphore_def_t osal_mutex_def_t; typedef osal_semaphore_t osal_mutex_t; -static inline osal_mutex_t osal_mutex_create(osal_mutex_def_t* mdef) +TU_ATTR_ALWAYS_INLINE static inline osal_mutex_t osal_mutex_create(osal_mutex_def_t* mdef) { mdef->count = 1; return mdef; } -static inline bool osal_mutex_lock (osal_mutex_t mutex_hdl, uint32_t msec) +TU_ATTR_ALWAYS_INLINE static inline bool osal_mutex_lock (osal_mutex_t mutex_hdl, uint32_t msec) { return osal_semaphore_wait(mutex_hdl, msec); } -static inline bool osal_mutex_unlock(osal_mutex_t mutex_hdl) +TU_ATTR_ALWAYS_INLINE static inline bool osal_mutex_unlock(osal_mutex_t mutex_hdl) { return osal_semaphore_post(mutex_hdl, false); } @@ -120,27 +120,29 @@ typedef osal_queue_def_t* osal_queue_t; } // lock queue by disable USB interrupt -static inline void _osal_q_lock(osal_queue_t qhdl) +TU_ATTR_ALWAYS_INLINE static inline void _osal_q_lock(osal_queue_t qhdl) { // disable dcd/hcd interrupt qhdl->interrupt_set(false); } // unlock queue -static inline void _osal_q_unlock(osal_queue_t qhdl) +TU_ATTR_ALWAYS_INLINE static inline void _osal_q_unlock(osal_queue_t qhdl) { // enable dcd/hcd interrupt qhdl->interrupt_set(true); } -static inline osal_queue_t osal_queue_create(osal_queue_def_t* qdef) +TU_ATTR_ALWAYS_INLINE static inline osal_queue_t osal_queue_create(osal_queue_def_t* qdef) { tu_fifo_clear(&qdef->ff); return (osal_queue_t) qdef; } -static inline bool osal_queue_receive(osal_queue_t qhdl, void* data) +TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_receive(osal_queue_t qhdl, void* data, uint32_t msec) { + (void) msec; // not used, always behave as msec = 0 + _osal_q_lock(qhdl); bool success = tu_fifo_read(&qhdl->ff, data); _osal_q_unlock(qhdl); @@ -148,7 +150,7 @@ static inline bool osal_queue_receive(osal_queue_t qhdl, void* data) return success; } -static inline bool osal_queue_send(osal_queue_t qhdl, void const * data, bool in_isr) +TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_send(osal_queue_t qhdl, void const * data, bool in_isr) { if (!in_isr) { _osal_q_lock(qhdl); @@ -165,7 +167,7 @@ static inline bool osal_queue_send(osal_queue_t qhdl, void const * data, bool in return success; } -static inline bool osal_queue_empty(osal_queue_t qhdl) +TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_empty(osal_queue_t qhdl) { // Skip queue lock/unlock since this function is primarily called // with interrupt disabled before going into low power mode diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/osal/osal_pico.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/osal/osal_pico.h index 70432d22b5f..abef286b474 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/osal/osal_pico.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/osal/osal_pico.h @@ -39,7 +39,7 @@ //--------------------------------------------------------------------+ // TASK API //--------------------------------------------------------------------+ -static inline void osal_task_delay(uint32_t msec) +TU_ATTR_ALWAYS_INLINE static inline void osal_task_delay(uint32_t msec) { sleep_ms(msec); } @@ -49,25 +49,25 @@ static inline void osal_task_delay(uint32_t msec) //--------------------------------------------------------------------+ typedef struct semaphore osal_semaphore_def_t, *osal_semaphore_t; -static inline osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t* semdef) +TU_ATTR_ALWAYS_INLINE static inline osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t* semdef) { sem_init(semdef, 0, 255); return semdef; } -static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr) +TU_ATTR_ALWAYS_INLINE static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr) { (void) in_isr; sem_release(sem_hdl); return true; } -static inline bool osal_semaphore_wait (osal_semaphore_t sem_hdl, uint32_t msec) +TU_ATTR_ALWAYS_INLINE static inline bool osal_semaphore_wait (osal_semaphore_t sem_hdl, uint32_t msec) { return sem_acquire_timeout_ms(sem_hdl, msec); } -static inline void osal_semaphore_reset(osal_semaphore_t sem_hdl) +TU_ATTR_ALWAYS_INLINE static inline void osal_semaphore_reset(osal_semaphore_t sem_hdl) { sem_reset(sem_hdl, 0); } @@ -78,21 +78,21 @@ static inline void osal_semaphore_reset(osal_semaphore_t sem_hdl) //--------------------------------------------------------------------+ typedef struct mutex osal_mutex_def_t, *osal_mutex_t; -static inline osal_mutex_t osal_mutex_create(osal_mutex_def_t* mdef) +TU_ATTR_ALWAYS_INLINE static inline osal_mutex_t osal_mutex_create(osal_mutex_def_t* mdef) { - mutex_init(mdef); - return mdef; + mutex_init(mdef); + return mdef; } -static inline bool osal_mutex_lock (osal_mutex_t mutex_hdl, uint32_t msec) +TU_ATTR_ALWAYS_INLINE static inline bool osal_mutex_lock (osal_mutex_t mutex_hdl, uint32_t msec) { - return mutex_enter_timeout_ms(mutex_hdl, msec); + return mutex_enter_timeout_ms(mutex_hdl, msec); } -static inline bool osal_mutex_unlock(osal_mutex_t mutex_hdl) +TU_ATTR_ALWAYS_INLINE static inline bool osal_mutex_unlock(osal_mutex_t mutex_hdl) { - mutex_exit(mutex_hdl); - return true; + mutex_exit(mutex_hdl); + return true; } //--------------------------------------------------------------------+ @@ -121,26 +121,28 @@ typedef osal_queue_def_t* osal_queue_t; } // lock queue by disable USB interrupt -static inline void _osal_q_lock(osal_queue_t qhdl) +TU_ATTR_ALWAYS_INLINE static inline void _osal_q_lock(osal_queue_t qhdl) { - critical_section_enter_blocking(&qhdl->critsec); + critical_section_enter_blocking(&qhdl->critsec); } // unlock queue -static inline void _osal_q_unlock(osal_queue_t qhdl) +TU_ATTR_ALWAYS_INLINE static inline void _osal_q_unlock(osal_queue_t qhdl) { - critical_section_exit(&qhdl->critsec); + critical_section_exit(&qhdl->critsec); } -static inline osal_queue_t osal_queue_create(osal_queue_def_t* qdef) +TU_ATTR_ALWAYS_INLINE static inline osal_queue_t osal_queue_create(osal_queue_def_t* qdef) { critical_section_init(&qdef->critsec); tu_fifo_clear(&qdef->ff); return (osal_queue_t) qdef; } -static inline bool osal_queue_receive(osal_queue_t qhdl, void* data) +TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_receive(osal_queue_t qhdl, void* data, uint32_t msec) { + (void) msec; // not used, always behave as msec = 0 + // TODO: revisit... docs say that mutexes are never used from IRQ context, // however osal_queue_recieve may be. therefore my assumption is that // the fifo mutex is not populated for queues used from an IRQ context @@ -153,7 +155,7 @@ static inline bool osal_queue_receive(osal_queue_t qhdl, void* data) return success; } -static inline bool osal_queue_send(osal_queue_t qhdl, void const * data, bool in_isr) +TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_send(osal_queue_t qhdl, void const * data, bool in_isr) { // TODO: revisit... docs say that mutexes are never used from IRQ context, // however osal_queue_recieve may be. therefore my assumption is that @@ -170,7 +172,7 @@ static inline bool osal_queue_send(osal_queue_t qhdl, void const * data, bool in return success; } -static inline bool osal_queue_empty(osal_queue_t qhdl) +TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_empty(osal_queue_t qhdl) { // TODO: revisit; whether this is true or not currently, tu_fifo_empty is a single // volatile read. diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/osal/osal_rtthread.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/osal/osal_rtthread.h index 0845175b852..f8452bfb201 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/osal/osal_rtthread.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/osal/osal_rtthread.h @@ -37,7 +37,7 @@ extern "C" { //--------------------------------------------------------------------+ // TASK API //--------------------------------------------------------------------+ -static inline void osal_task_delay(uint32_t msec) { +TU_ATTR_ALWAYS_INLINE static inline void osal_task_delay(uint32_t msec) { rt_thread_mdelay(msec); } @@ -47,22 +47,22 @@ static inline void osal_task_delay(uint32_t msec) { typedef struct rt_semaphore osal_semaphore_def_t; typedef rt_sem_t osal_semaphore_t; -static inline osal_semaphore_t +TU_ATTR_ALWAYS_INLINE static inline osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t *semdef) { - rt_sem_init(semdef, "tusb", 0, RT_IPC_FLAG_FIFO); + rt_sem_init(semdef, "tusb", 0, RT_IPC_FLAG_PRIO); return semdef; } -static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr) { +TU_ATTR_ALWAYS_INLINE static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr) { (void) in_isr; return rt_sem_release(sem_hdl) == RT_EOK; } -static inline bool osal_semaphore_wait(osal_semaphore_t sem_hdl, uint32_t msec) { - return rt_sem_take(sem_hdl, rt_tick_from_millisecond(msec)) == RT_EOK; +TU_ATTR_ALWAYS_INLINE static inline bool osal_semaphore_wait(osal_semaphore_t sem_hdl, uint32_t msec) { + return rt_sem_take(sem_hdl, rt_tick_from_millisecond((rt_int32_t) msec)) == RT_EOK; } -static inline void osal_semaphore_reset(osal_semaphore_t const sem_hdl) { +TU_ATTR_ALWAYS_INLINE static inline void osal_semaphore_reset(osal_semaphore_t const sem_hdl) { // TODO: implement } @@ -72,16 +72,16 @@ static inline void osal_semaphore_reset(osal_semaphore_t const sem_hdl) { typedef struct rt_mutex osal_mutex_def_t; typedef rt_mutex_t osal_mutex_t; -static inline osal_mutex_t osal_mutex_create(osal_mutex_def_t *mdef) { - rt_mutex_init(mdef, "tusb", RT_IPC_FLAG_FIFO); +TU_ATTR_ALWAYS_INLINE static inline osal_mutex_t osal_mutex_create(osal_mutex_def_t *mdef) { + rt_mutex_init(mdef, "tusb", RT_IPC_FLAG_PRIO); return mdef; } -static inline bool osal_mutex_lock(osal_mutex_t mutex_hdl, uint32_t msec) { - return rt_mutex_take(mutex_hdl, rt_tick_from_millisecond(msec)) == RT_EOK; +TU_ATTR_ALWAYS_INLINE static inline bool osal_mutex_lock(osal_mutex_t mutex_hdl, uint32_t msec) { + return rt_mutex_take(mutex_hdl, rt_tick_from_millisecond((rt_int32_t) msec)) == RT_EOK; } -static inline bool osal_mutex_unlock(osal_mutex_t mutex_hdl) { +TU_ATTR_ALWAYS_INLINE static inline bool osal_mutex_unlock(osal_mutex_t mutex_hdl) { return rt_mutex_release(mutex_hdl) == RT_EOK; } @@ -104,22 +104,24 @@ typedef struct { typedef rt_mq_t osal_queue_t; -static inline osal_queue_t osal_queue_create(osal_queue_def_t *qdef) { +TU_ATTR_ALWAYS_INLINE static inline osal_queue_t osal_queue_create(osal_queue_def_t *qdef) { rt_mq_init(&(qdef->sq), "tusb", qdef->buf, qdef->item_sz, - qdef->item_sz * qdef->depth, RT_IPC_FLAG_FIFO); + qdef->item_sz * qdef->depth, RT_IPC_FLAG_PRIO); return &(qdef->sq); } -static inline bool osal_queue_receive(osal_queue_t qhdl, void *data) { - return rt_mq_recv(qhdl, data, qhdl->msg_size, RT_WAITING_FOREVER) == RT_EOK; +TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_receive(osal_queue_t qhdl, void *data, uint32_t msec) { + + rt_tick_t tick = rt_tick_from_millisecond((rt_int32_t) msec); + return rt_mq_recv(qhdl, data, qhdl->msg_size, tick) == RT_EOK; } -static inline bool osal_queue_send(osal_queue_t qhdl, void const *data, bool in_isr) { +TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_send(osal_queue_t qhdl, void const *data, bool in_isr) { (void) in_isr; return rt_mq_send(qhdl, (void *)data, qhdl->msg_size) == RT_EOK; } -static inline bool osal_queue_empty(osal_queue_t qhdl) { +TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_empty(osal_queue_t qhdl) { return (qhdl->entry) == 0; } diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/osal/osal_rtx4.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/osal/osal_rtx4.h index 1856a5d9a68..dea1c12c8b1 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/osal/osal_rtx4.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/osal/osal_rtx4.h @@ -37,7 +37,7 @@ extern "C" { //--------------------------------------------------------------------+ // TASK API //--------------------------------------------------------------------+ -static inline void osal_task_delay(uint32_t msec) +TU_ATTR_ALWAYS_INLINE static inline void osal_task_delay(uint32_t msec) { uint16_t hi = msec >> 16; uint16_t lo = msec; @@ -47,7 +47,7 @@ static inline void osal_task_delay(uint32_t msec) os_dly_wait(lo); } -static inline uint16_t msec2wait(uint32_t msec) { +TU_ATTR_ALWAYS_INLINE static inline uint16_t msec2wait(uint32_t msec) { if (msec == OSAL_TIMEOUT_WAIT_FOREVER) return 0xFFFF; else if (msec >= 0xFFFE) @@ -62,12 +62,12 @@ static inline uint16_t msec2wait(uint32_t msec) { typedef OS_SEM osal_semaphore_def_t; typedef OS_ID osal_semaphore_t; -static inline OS_ID osal_semaphore_create(osal_semaphore_def_t* semdef) { +TU_ATTR_ALWAYS_INLINE static inline OS_ID osal_semaphore_create(osal_semaphore_def_t* semdef) { os_sem_init(semdef, 0); return semdef; } -static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr) { +TU_ATTR_ALWAYS_INLINE static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr) { if ( !in_isr ) { os_sem_send(sem_hdl); } else { @@ -76,11 +76,11 @@ static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr) { return true; } -static inline bool osal_semaphore_wait (osal_semaphore_t sem_hdl, uint32_t msec) { +TU_ATTR_ALWAYS_INLINE static inline bool osal_semaphore_wait (osal_semaphore_t sem_hdl, uint32_t msec) { return os_sem_wait(sem_hdl, msec2wait(msec)) != OS_R_TMO; } -static inline void osal_semaphore_reset(osal_semaphore_t const sem_hdl) { +TU_ATTR_ALWAYS_INLINE static inline void osal_semaphore_reset(osal_semaphore_t const sem_hdl) { // TODO: implement } @@ -90,18 +90,18 @@ static inline void osal_semaphore_reset(osal_semaphore_t const sem_hdl) { typedef OS_MUT osal_mutex_def_t; typedef OS_ID osal_mutex_t; -static inline osal_mutex_t osal_mutex_create(osal_mutex_def_t* mdef) +TU_ATTR_ALWAYS_INLINE static inline osal_mutex_t osal_mutex_create(osal_mutex_def_t* mdef) { os_mut_init(mdef); return mdef; } -static inline bool osal_mutex_lock (osal_mutex_t mutex_hdl, uint32_t msec) +TU_ATTR_ALWAYS_INLINE static inline bool osal_mutex_lock (osal_mutex_t mutex_hdl, uint32_t msec) { return os_mut_wait(mutex_hdl, msec2wait(msec)) != OS_R_TMO; } -static inline bool osal_mutex_unlock(osal_mutex_t mutex_hdl) +TU_ATTR_ALWAYS_INLINE static inline bool osal_mutex_unlock(osal_mutex_t mutex_hdl) { return os_mut_release(mutex_hdl) == OS_R_OK; } @@ -127,23 +127,23 @@ typedef struct typedef osal_queue_def_t* osal_queue_t; -static inline osal_queue_t osal_queue_create(osal_queue_def_t* qdef) +TU_ATTR_ALWAYS_INLINE static inline osal_queue_t osal_queue_create(osal_queue_def_t* qdef) { os_mbx_init(qdef->mbox, (qdef->depth + 4) * 4); _init_box(qdef->pool, ((qdef->item_sz+3)/4)*(qdef->depth) + 3, qdef->item_sz); return qdef; } -static inline bool osal_queue_receive(osal_queue_t qhdl, void* data) +TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_receive(osal_queue_t qhdl, void* data, uint32_t msec) { void* buf; - os_mbx_wait(qhdl->mbox, &buf, 0xFFFF); + os_mbx_wait(qhdl->mbox, &buf, msec2wait(msec)); memcpy(data, buf, qhdl->item_sz); _free_box(qhdl->pool, buf); return true; } -static inline bool osal_queue_send(osal_queue_t qhdl, void const * data, bool in_isr) +TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_send(osal_queue_t qhdl, void const * data, bool in_isr) { void* buf = _alloc_box(qhdl->pool); memcpy(buf, data, qhdl->item_sz); @@ -158,7 +158,7 @@ static inline bool osal_queue_send(osal_queue_t qhdl, void const * data, bool in return true; } -static inline bool osal_queue_empty(osal_queue_t qhdl) +TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_empty(osal_queue_t qhdl) { return os_mbx_check(qhdl->mbox) == qhdl->depth; } diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/broadcom/synopsys/synopsys_common.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/broadcom/synopsys/synopsys_common.h deleted file mode 100644 index 81ce3b4a945..00000000000 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/broadcom/synopsys/synopsys_common.h +++ /dev/null @@ -1,1476 +0,0 @@ -/** - ****************************************************************************** - * @file synopsys_common.h - * @author MCD Application Team - * @brief CMSIS Cortex-M3 Device USB OTG peripheral Header File. - * This file contains the USB OTG peripheral register's definitions, bits - * definitions and memory mapping for STM32F1xx devices. - * - * This file contains: - * - Data structures and the address mapping for the USB OTG peripheral - * - The Peripheral's registers declarations and bits definition - * - Macros to access the peripheral's registers hardware - * - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2017 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** - */ - -#include "stdint.h" - -#pragma once - -#ifdef __cplusplus - #define __I volatile -#else - #define __I volatile const -#endif -#define __O volatile -#define __IO volatile -#define __IM volatile const -#define __OM volatile -#define __IOM volatile - -/** - * @brief __USB_OTG_Core_register - */ - -typedef struct -{ - __IO uint32_t GOTGCTL; /*!< USB_OTG Control and Status Register Address offset: 000h */ - __IO uint32_t GOTGINT; /*!< USB_OTG Interrupt Register Address offset: 004h */ - __IO uint32_t GAHBCFG; /*!< Core AHB Configuration Register Address offset: 008h */ - __IO uint32_t GUSBCFG; /*!< Core USB Configuration Register Address offset: 00Ch */ - __IO uint32_t GRSTCTL; /*!< Core Reset Register Address offset: 010h */ - __IO uint32_t GINTSTS; /*!< Core Interrupt Register Address offset: 014h */ - __IO uint32_t GINTMSK; /*!< Core Interrupt Mask Register Address offset: 018h */ - __IO uint32_t GRXSTSR; /*!< Receive Sts Q Read Register Address offset: 01Ch */ - __IO uint32_t GRXSTSP; /*!< Receive Sts Q Read & POP Register Address offset: 020h */ - __IO uint32_t GRXFSIZ; /*!< Receive FIFO Size Register Address offset: 024h */ - __IO uint32_t DIEPTXF0_HNPTXFSIZ; /*!< EP0 / Non Periodic Tx FIFO Size Register Address offset: 028h */ - __IO uint32_t HNPTXSTS; /*!< Non Periodic Tx FIFO/Queue Sts reg Address offset: 02Ch */ - uint32_t Reserved30[2]; /*!< Reserved 030h*/ - __IO uint32_t GCCFG; /*!< General Purpose IO Register Address offset: 038h */ - __IO uint32_t CID; /*!< User ID Register 03Ch */ - __IO uint32_t GSNPSID; /* USB_OTG core ID 040h*/ - __IO uint32_t GHWCFG1; /* User HW config1 044h*/ - __IO uint32_t GHWCFG2; /* User HW config2 048h*/ - __IO uint32_t GHWCFG3; /*!< User HW config3 04Ch */ - uint32_t Reserved6; /*!< Reserved 050h */ - __IO uint32_t GLPMCFG; /*!< LPM Register 054h */ - __IO uint32_t GPWRDN; /*!< Power Down Register 058h */ - __IO uint32_t GDFIFOCFG; /*!< DFIFO Software Config Register 05Ch */ - __IO uint32_t GADPCTL; /*!< ADP Timer, Control and Status Register 60Ch */ - uint32_t Reserved43[39]; /*!< Reserved 058h-0FFh */ - __IO uint32_t HPTXFSIZ; /*!< Host Periodic Tx FIFO Size Reg Address offset: 100h */ - __IO uint32_t DIEPTXF[0x0F]; /*!< dev Periodic Transmit FIFO Address offset: 0x104 */ -} USB_OTG_GlobalTypeDef; - - - -/** - * @brief __device_Registers - */ - -typedef struct -{ - __IO uint32_t DCFG; /*!< dev Configuration Register Address offset: 800h*/ - __IO uint32_t DCTL; /*!< dev Control Register Address offset: 804h*/ - __IO uint32_t DSTS; /*!< dev Status Register (RO) Address offset: 808h*/ - uint32_t Reserved0C; /*!< Reserved 80Ch*/ - __IO uint32_t DIEPMSK; /*!< dev IN Endpoint Mask Address offset: 810h*/ - __IO uint32_t DOEPMSK; /*!< dev OUT Endpoint Mask Address offset: 814h*/ - __IO uint32_t DAINT; /*!< dev All Endpoints Itr Reg Address offset: 818h*/ - __IO uint32_t DAINTMSK; /*!< dev All Endpoints Itr Mask Address offset: 81Ch*/ - uint32_t Reserved20; /*!< Reserved 820h*/ - uint32_t Reserved9; /*!< Reserved 824h*/ - __IO uint32_t DVBUSDIS; /*!< dev VBUS discharge Register Address offset: 828h*/ - __IO uint32_t DVBUSPULSE; /*!< dev VBUS Pulse Register Address offset: 82Ch*/ - __IO uint32_t DTHRCTL; /*!< dev thr Address offset: 830h*/ - __IO uint32_t DIEPEMPMSK; /*!< dev empty msk Address offset: 834h*/ - __IO uint32_t DEACHINT; /*!< dedicated EP interrupt Address offset: 838h*/ - __IO uint32_t DEACHMSK; /*!< dedicated EP msk Address offset: 83Ch*/ - uint32_t Reserved40; /*!< dedicated EP mask Address offset: 840h*/ - __IO uint32_t DINEP1MSK; /*!< dedicated EP mask Address offset: 844h*/ - uint32_t Reserved44[15]; /*!< Reserved 844-87Ch*/ - __IO uint32_t DOUTEP1MSK; /*!< dedicated EP msk Address offset: 884h*/ -} USB_OTG_DeviceTypeDef; - -/** - * @brief __IN_Endpoint-Specific_Register - */ - -typedef struct -{ - __IO uint32_t DIEPCTL; /*!< dev IN Endpoint Control Reg 900h + (ep_num * 20h) + 00h*/ - uint32_t Reserved04; /*!< Reserved 900h + (ep_num * 20h) + 04h*/ - __IO uint32_t DIEPINT; /*!< dev IN Endpoint Itr Reg 900h + (ep_num * 20h) + 08h*/ - uint32_t Reserved0C; /*!< Reserved 900h + (ep_num * 20h) + 0Ch*/ - __IO uint32_t DIEPTSIZ; /*!< IN Endpoint Txfer Size 900h + (ep_num * 20h) + 10h*/ - __IO uint32_t DIEPDMA; /*!< IN Endpoint DMA Address Reg 900h + (ep_num * 20h) + 14h*/ - __IO uint32_t DTXFSTS; /*!< IN Endpoint Tx FIFO Status Reg 900h + (ep_num * 20h) + 18h*/ - uint32_t Reserved18; /*!< Reserved 900h+(ep_num*20h)+1Ch-900h+ (ep_num * 20h) + 1Ch*/ -} USB_OTG_INEndpointTypeDef; - -/** - * @brief __OUT_Endpoint-Specific_Registers - */ - -typedef struct -{ - __IO uint32_t DOEPCTL; /*!< dev OUT Endpoint Control Reg B00h + (ep_num * 20h) + 00h*/ - uint32_t Reserved04; /*!< Reserved B00h + (ep_num * 20h) + 04h*/ - __IO uint32_t DOEPINT; /*!< dev OUT Endpoint Itr Reg B00h + (ep_num * 20h) + 08h*/ - uint32_t Reserved0C; /*!< Reserved B00h + (ep_num * 20h) + 0Ch*/ - __IO uint32_t DOEPTSIZ; /*!< dev OUT Endpoint Txfer Size B00h + (ep_num * 20h) + 10h*/ - __IO uint32_t DOEPDMA; /*!< dev OUT Endpoint DMA Address B00h + (ep_num * 20h) + 14h*/ - uint32_t Reserved18[2]; /*!< Reserved B00h + (ep_num * 20h) + 18h - B00h + (ep_num * 20h) + 1Ch*/ -} USB_OTG_OUTEndpointTypeDef; - -/** - * @brief __Host_Mode_Register_Structures - */ - -typedef struct -{ - __IO uint32_t HCFG; /*!< Host Configuration Register 400h*/ - __IO uint32_t HFIR; /*!< Host Frame Interval Register 404h*/ - __IO uint32_t HFNUM; /*!< Host Frame Nbr/Frame Remaining 408h*/ - uint32_t Reserved40C; /*!< Reserved 40Ch*/ - __IO uint32_t HPTXSTS; /*!< Host Periodic Tx FIFO/ Queue Status 410h*/ - __IO uint32_t HAINT; /*!< Host All Channels Interrupt Register 414h*/ - __IO uint32_t HAINTMSK; /*!< Host All Channels Interrupt Mask 418h*/ -} USB_OTG_HostTypeDef; - -/** - * @brief __Host_Channel_Specific_Registers - */ - -typedef struct -{ - __IO uint32_t HCCHAR; - __IO uint32_t HCSPLT; - __IO uint32_t HCINT; - __IO uint32_t HCINTMSK; - __IO uint32_t HCTSIZ; - __IO uint32_t HCDMA; - uint32_t Reserved[2]; -} USB_OTG_HostChannelTypeDef; - -/*!< USB registers base address */ -#define USB_OTG_FS_PERIPH_BASE 0x50000000UL - -// #define USB_OTG_GLOBAL_BASE 0x00000000UL -// #define USB_OTG_DEVICE_BASE 0x00000800UL -#define USB_OTG_IN_ENDPOINT_BASE 0x00000900UL -#define USB_OTG_OUT_ENDPOINT_BASE 0x00000B00UL -#define USB_OTG_EP_REG_SIZE 0x00000020UL -// #define USB_OTG_HOST_BASE 0x00000400UL -#define USB_OTG_HOST_PORT_BASE 0x00000440UL -#define USB_OTG_HOST_CHANNEL_BASE 0x00000500UL -#define USB_OTG_HOST_CHANNEL_SIZE 0x00000020UL -#define USB_OTG_PCGCCTL_BASE 0x00000E00UL -#define USB_OTG_FIFO_BASE 0x00001000UL -#define USB_OTG_FIFO_SIZE 0x00001000UL - -/******************************************************************************/ -/* */ -/* USB_OTG */ -/* */ -/******************************************************************************/ -/******************** Bit definition for USB_OTG_GOTGCTL register ***********/ -#define USB_OTG_GOTGCTL_SRQSCS_Pos (0U) -#define USB_OTG_GOTGCTL_SRQSCS_Msk (0x1UL << USB_OTG_GOTGCTL_SRQSCS_Pos) /*!< 0x00000001 */ -#define USB_OTG_GOTGCTL_SRQSCS USB_OTG_GOTGCTL_SRQSCS_Msk /*!< Session request success */ -#define USB_OTG_GOTGCTL_SRQ_Pos (1U) -#define USB_OTG_GOTGCTL_SRQ_Msk (0x1UL << USB_OTG_GOTGCTL_SRQ_Pos) /*!< 0x00000002 */ -#define USB_OTG_GOTGCTL_SRQ USB_OTG_GOTGCTL_SRQ_Msk /*!< Session request */ -#define USB_OTG_GOTGCTL_HNGSCS_Pos (8U) -#define USB_OTG_GOTGCTL_HNGSCS_Msk (0x1UL << USB_OTG_GOTGCTL_HNGSCS_Pos) /*!< 0x00000100 */ -#define USB_OTG_GOTGCTL_HNGSCS USB_OTG_GOTGCTL_HNGSCS_Msk /*!< Host set HNP enable */ -#define USB_OTG_GOTGCTL_HNPRQ_Pos (9U) -#define USB_OTG_GOTGCTL_HNPRQ_Msk (0x1UL << USB_OTG_GOTGCTL_HNPRQ_Pos) /*!< 0x00000200 */ -#define USB_OTG_GOTGCTL_HNPRQ USB_OTG_GOTGCTL_HNPRQ_Msk /*!< HNP request */ -#define USB_OTG_GOTGCTL_HSHNPEN_Pos (10U) -#define USB_OTG_GOTGCTL_HSHNPEN_Msk (0x1UL << USB_OTG_GOTGCTL_HSHNPEN_Pos) /*!< 0x00000400 */ -#define USB_OTG_GOTGCTL_HSHNPEN USB_OTG_GOTGCTL_HSHNPEN_Msk /*!< Host set HNP enable */ -#define USB_OTG_GOTGCTL_DHNPEN_Pos (11U) -#define USB_OTG_GOTGCTL_DHNPEN_Msk (0x1UL << USB_OTG_GOTGCTL_DHNPEN_Pos) /*!< 0x00000800 */ -#define USB_OTG_GOTGCTL_DHNPEN USB_OTG_GOTGCTL_DHNPEN_Msk /*!< Device HNP enabled */ -#define USB_OTG_GOTGCTL_CIDSTS_Pos (16U) -#define USB_OTG_GOTGCTL_CIDSTS_Msk (0x1UL << USB_OTG_GOTGCTL_CIDSTS_Pos) /*!< 0x00010000 */ -#define USB_OTG_GOTGCTL_CIDSTS USB_OTG_GOTGCTL_CIDSTS_Msk /*!< Connector ID status */ -#define USB_OTG_GOTGCTL_DBCT_Pos (17U) -#define USB_OTG_GOTGCTL_DBCT_Msk (0x1UL << USB_OTG_GOTGCTL_DBCT_Pos) /*!< 0x00020000 */ -#define USB_OTG_GOTGCTL_DBCT USB_OTG_GOTGCTL_DBCT_Msk /*!< Long/short debounce time */ -#define USB_OTG_GOTGCTL_ASVLD_Pos (18U) -#define USB_OTG_GOTGCTL_ASVLD_Msk (0x1UL << USB_OTG_GOTGCTL_ASVLD_Pos) /*!< 0x00040000 */ -#define USB_OTG_GOTGCTL_ASVLD USB_OTG_GOTGCTL_ASVLD_Msk /*!< A-session valid */ -#define USB_OTG_GOTGCTL_BSVLD_Pos (19U) -#define USB_OTG_GOTGCTL_BSVLD_Msk (0x1UL << USB_OTG_GOTGCTL_BSVLD_Pos) /*!< 0x00080000 */ -#define USB_OTG_GOTGCTL_BSVLD USB_OTG_GOTGCTL_BSVLD_Msk /*!< B-session valid */ - -/******************** Bit definition for USB_OTG_HCFG register ********************/ - -#define USB_OTG_HCFG_FSLSPCS_Pos (0U) -#define USB_OTG_HCFG_FSLSPCS_Msk (0x3UL << USB_OTG_HCFG_FSLSPCS_Pos) /*!< 0x00000003 */ -#define USB_OTG_HCFG_FSLSPCS USB_OTG_HCFG_FSLSPCS_Msk /*!< FS/LS PHY clock select */ -#define USB_OTG_HCFG_FSLSPCS_0 (0x1UL << USB_OTG_HCFG_FSLSPCS_Pos) /*!< 0x00000001 */ -#define USB_OTG_HCFG_FSLSPCS_1 (0x2UL << USB_OTG_HCFG_FSLSPCS_Pos) /*!< 0x00000002 */ -#define USB_OTG_HCFG_FSLSS_Pos (2U) -#define USB_OTG_HCFG_FSLSS_Msk (0x1UL << USB_OTG_HCFG_FSLSS_Pos) /*!< 0x00000004 */ -#define USB_OTG_HCFG_FSLSS USB_OTG_HCFG_FSLSS_Msk /*!< FS- and LS-only support */ - -/******************** Bit definition for USB_OTG_DCFG register ********************/ - -#define USB_OTG_DCFG_DSPD_Pos (0U) -#define USB_OTG_DCFG_DSPD_Msk (0x3UL << USB_OTG_DCFG_DSPD_Pos) /*!< 0x00000003 */ -#define USB_OTG_DCFG_DSPD USB_OTG_DCFG_DSPD_Msk /*!< Device speed */ -#define USB_OTG_DCFG_DSPD_0 (0x1UL << USB_OTG_DCFG_DSPD_Pos) /*!< 0x00000001 */ -#define USB_OTG_DCFG_DSPD_1 (0x2UL << USB_OTG_DCFG_DSPD_Pos) /*!< 0x00000002 */ -#define USB_OTG_DCFG_NZLSOHSK_Pos (2U) -#define USB_OTG_DCFG_NZLSOHSK_Msk (0x1UL << USB_OTG_DCFG_NZLSOHSK_Pos) /*!< 0x00000004 */ -#define USB_OTG_DCFG_NZLSOHSK USB_OTG_DCFG_NZLSOHSK_Msk /*!< Nonzero-length status OUT handshake */ - -#define USB_OTG_DCFG_DAD_Pos (4U) -#define USB_OTG_DCFG_DAD_Msk (0x7FUL << USB_OTG_DCFG_DAD_Pos) /*!< 0x000007F0 */ -#define USB_OTG_DCFG_DAD USB_OTG_DCFG_DAD_Msk /*!< Device address */ -#define USB_OTG_DCFG_DAD_0 (0x01UL << USB_OTG_DCFG_DAD_Pos) /*!< 0x00000010 */ -#define USB_OTG_DCFG_DAD_1 (0x02UL << USB_OTG_DCFG_DAD_Pos) /*!< 0x00000020 */ -#define USB_OTG_DCFG_DAD_2 (0x04UL << USB_OTG_DCFG_DAD_Pos) /*!< 0x00000040 */ -#define USB_OTG_DCFG_DAD_3 (0x08UL << USB_OTG_DCFG_DAD_Pos) /*!< 0x00000080 */ -#define USB_OTG_DCFG_DAD_4 (0x10UL << USB_OTG_DCFG_DAD_Pos) /*!< 0x00000100 */ -#define USB_OTG_DCFG_DAD_5 (0x20UL << USB_OTG_DCFG_DAD_Pos) /*!< 0x00000200 */ -#define USB_OTG_DCFG_DAD_6 (0x40UL << USB_OTG_DCFG_DAD_Pos) /*!< 0x00000400 */ - -#define USB_OTG_DCFG_PFIVL_Pos (11U) -#define USB_OTG_DCFG_PFIVL_Msk (0x3UL << USB_OTG_DCFG_PFIVL_Pos) /*!< 0x00001800 */ -#define USB_OTG_DCFG_PFIVL USB_OTG_DCFG_PFIVL_Msk /*!< Periodic (micro)frame interval */ -#define USB_OTG_DCFG_PFIVL_0 (0x1UL << USB_OTG_DCFG_PFIVL_Pos) /*!< 0x00000800 */ -#define USB_OTG_DCFG_PFIVL_1 (0x2UL << USB_OTG_DCFG_PFIVL_Pos) /*!< 0x00001000 */ - -#define USB_OTG_DCFG_PERSCHIVL_Pos (24U) -#define USB_OTG_DCFG_PERSCHIVL_Msk (0x3UL << USB_OTG_DCFG_PERSCHIVL_Pos) /*!< 0x03000000 */ -#define USB_OTG_DCFG_PERSCHIVL USB_OTG_DCFG_PERSCHIVL_Msk /*!< Periodic scheduling interval */ -#define USB_OTG_DCFG_PERSCHIVL_0 (0x1UL << USB_OTG_DCFG_PERSCHIVL_Pos) /*!< 0x01000000 */ -#define USB_OTG_DCFG_PERSCHIVL_1 (0x2UL << USB_OTG_DCFG_PERSCHIVL_Pos) /*!< 0x02000000 */ - -/******************** Bit definition for USB_OTG_PCGCR register ********************/ -#define USB_OTG_PCGCR_STPPCLK_Pos (0U) -#define USB_OTG_PCGCR_STPPCLK_Msk (0x1UL << USB_OTG_PCGCR_STPPCLK_Pos) /*!< 0x00000001 */ -#define USB_OTG_PCGCR_STPPCLK USB_OTG_PCGCR_STPPCLK_Msk /*!< Stop PHY clock */ -#define USB_OTG_PCGCR_GATEHCLK_Pos (1U) -#define USB_OTG_PCGCR_GATEHCLK_Msk (0x1UL << USB_OTG_PCGCR_GATEHCLK_Pos) /*!< 0x00000002 */ -#define USB_OTG_PCGCR_GATEHCLK USB_OTG_PCGCR_GATEHCLK_Msk /*!< Gate HCLK */ -#define USB_OTG_PCGCR_PHYSUSP_Pos (4U) -#define USB_OTG_PCGCR_PHYSUSP_Msk (0x1UL << USB_OTG_PCGCR_PHYSUSP_Pos) /*!< 0x00000010 */ -#define USB_OTG_PCGCR_PHYSUSP USB_OTG_PCGCR_PHYSUSP_Msk /*!< PHY suspended */ - -/******************** Bit definition for USB_OTG_GOTGINT register ********************/ -#define USB_OTG_GOTGINT_SEDET_Pos (2U) -#define USB_OTG_GOTGINT_SEDET_Msk (0x1UL << USB_OTG_GOTGINT_SEDET_Pos) /*!< 0x00000004 */ -#define USB_OTG_GOTGINT_SEDET USB_OTG_GOTGINT_SEDET_Msk /*!< Session end detected */ -#define USB_OTG_GOTGINT_SRSSCHG_Pos (8U) -#define USB_OTG_GOTGINT_SRSSCHG_Msk (0x1UL << USB_OTG_GOTGINT_SRSSCHG_Pos) /*!< 0x00000100 */ -#define USB_OTG_GOTGINT_SRSSCHG USB_OTG_GOTGINT_SRSSCHG_Msk /*!< Session request success status change */ -#define USB_OTG_GOTGINT_HNSSCHG_Pos (9U) -#define USB_OTG_GOTGINT_HNSSCHG_Msk (0x1UL << USB_OTG_GOTGINT_HNSSCHG_Pos) /*!< 0x00000200 */ -#define USB_OTG_GOTGINT_HNSSCHG USB_OTG_GOTGINT_HNSSCHG_Msk /*!< Host negotiation success status change */ -#define USB_OTG_GOTGINT_HNGDET_Pos (17U) -#define USB_OTG_GOTGINT_HNGDET_Msk (0x1UL << USB_OTG_GOTGINT_HNGDET_Pos) /*!< 0x00020000 */ -#define USB_OTG_GOTGINT_HNGDET USB_OTG_GOTGINT_HNGDET_Msk /*!< Host negotiation detected */ -#define USB_OTG_GOTGINT_ADTOCHG_Pos (18U) -#define USB_OTG_GOTGINT_ADTOCHG_Msk (0x1UL << USB_OTG_GOTGINT_ADTOCHG_Pos) /*!< 0x00040000 */ -#define USB_OTG_GOTGINT_ADTOCHG USB_OTG_GOTGINT_ADTOCHG_Msk /*!< A-device timeout change */ -#define USB_OTG_GOTGINT_DBCDNE_Pos (19U) -#define USB_OTG_GOTGINT_DBCDNE_Msk (0x1UL << USB_OTG_GOTGINT_DBCDNE_Pos) /*!< 0x00080000 */ -#define USB_OTG_GOTGINT_DBCDNE USB_OTG_GOTGINT_DBCDNE_Msk /*!< Debounce done */ - -/******************** Bit definition for USB_OTG_DCTL register ********************/ -#define USB_OTG_DCTL_RWUSIG_Pos (0U) -#define USB_OTG_DCTL_RWUSIG_Msk (0x1UL << USB_OTG_DCTL_RWUSIG_Pos) /*!< 0x00000001 */ -#define USB_OTG_DCTL_RWUSIG USB_OTG_DCTL_RWUSIG_Msk /*!< Remote wakeup signaling */ -#define USB_OTG_DCTL_SDIS_Pos (1U) -#define USB_OTG_DCTL_SDIS_Msk (0x1UL << USB_OTG_DCTL_SDIS_Pos) /*!< 0x00000002 */ -#define USB_OTG_DCTL_SDIS USB_OTG_DCTL_SDIS_Msk /*!< Soft disconnect */ -#define USB_OTG_DCTL_GINSTS_Pos (2U) -#define USB_OTG_DCTL_GINSTS_Msk (0x1UL << USB_OTG_DCTL_GINSTS_Pos) /*!< 0x00000004 */ -#define USB_OTG_DCTL_GINSTS USB_OTG_DCTL_GINSTS_Msk /*!< Global IN NAK status */ -#define USB_OTG_DCTL_GONSTS_Pos (3U) -#define USB_OTG_DCTL_GONSTS_Msk (0x1UL << USB_OTG_DCTL_GONSTS_Pos) /*!< 0x00000008 */ -#define USB_OTG_DCTL_GONSTS USB_OTG_DCTL_GONSTS_Msk /*!< Global OUT NAK status */ - -#define USB_OTG_DCTL_TCTL_Pos (4U) -#define USB_OTG_DCTL_TCTL_Msk (0x7UL << USB_OTG_DCTL_TCTL_Pos) /*!< 0x00000070 */ -#define USB_OTG_DCTL_TCTL USB_OTG_DCTL_TCTL_Msk /*!< Test control */ -#define USB_OTG_DCTL_TCTL_0 (0x1UL << USB_OTG_DCTL_TCTL_Pos) /*!< 0x00000010 */ -#define USB_OTG_DCTL_TCTL_1 (0x2UL << USB_OTG_DCTL_TCTL_Pos) /*!< 0x00000020 */ -#define USB_OTG_DCTL_TCTL_2 (0x4UL << USB_OTG_DCTL_TCTL_Pos) /*!< 0x00000040 */ -#define USB_OTG_DCTL_SGINAK_Pos (7U) -#define USB_OTG_DCTL_SGINAK_Msk (0x1UL << USB_OTG_DCTL_SGINAK_Pos) /*!< 0x00000080 */ -#define USB_OTG_DCTL_SGINAK USB_OTG_DCTL_SGINAK_Msk /*!< Set global IN NAK */ -#define USB_OTG_DCTL_CGINAK_Pos (8U) -#define USB_OTG_DCTL_CGINAK_Msk (0x1UL << USB_OTG_DCTL_CGINAK_Pos) /*!< 0x00000100 */ -#define USB_OTG_DCTL_CGINAK USB_OTG_DCTL_CGINAK_Msk /*!< Clear global IN NAK */ -#define USB_OTG_DCTL_SGONAK_Pos (9U) -#define USB_OTG_DCTL_SGONAK_Msk (0x1UL << USB_OTG_DCTL_SGONAK_Pos) /*!< 0x00000200 */ -#define USB_OTG_DCTL_SGONAK USB_OTG_DCTL_SGONAK_Msk /*!< Set global OUT NAK */ -#define USB_OTG_DCTL_CGONAK_Pos (10U) -#define USB_OTG_DCTL_CGONAK_Msk (0x1UL << USB_OTG_DCTL_CGONAK_Pos) /*!< 0x00000400 */ -#define USB_OTG_DCTL_CGONAK USB_OTG_DCTL_CGONAK_Msk /*!< Clear global OUT NAK */ -#define USB_OTG_DCTL_POPRGDNE_Pos (11U) -#define USB_OTG_DCTL_POPRGDNE_Msk (0x1UL << USB_OTG_DCTL_POPRGDNE_Pos) /*!< 0x00000800 */ -#define USB_OTG_DCTL_POPRGDNE USB_OTG_DCTL_POPRGDNE_Msk /*!< Power-on programming done */ - -/******************** Bit definition for USB_OTG_HFIR register ********************/ -#define USB_OTG_HFIR_FRIVL_Pos (0U) -#define USB_OTG_HFIR_FRIVL_Msk (0xFFFFUL << USB_OTG_HFIR_FRIVL_Pos) /*!< 0x0000FFFF */ -#define USB_OTG_HFIR_FRIVL USB_OTG_HFIR_FRIVL_Msk /*!< Frame interval */ - -/******************** Bit definition for USB_OTG_HFNUM register ********************/ -#define USB_OTG_HFNUM_FRNUM_Pos (0U) -#define USB_OTG_HFNUM_FRNUM_Msk (0xFFFFUL << USB_OTG_HFNUM_FRNUM_Pos) /*!< 0x0000FFFF */ -#define USB_OTG_HFNUM_FRNUM USB_OTG_HFNUM_FRNUM_Msk /*!< Frame number */ -#define USB_OTG_HFNUM_FTREM_Pos (16U) -#define USB_OTG_HFNUM_FTREM_Msk (0xFFFFUL << USB_OTG_HFNUM_FTREM_Pos) /*!< 0xFFFF0000 */ -#define USB_OTG_HFNUM_FTREM USB_OTG_HFNUM_FTREM_Msk /*!< Frame time remaining */ - -/******************** Bit definition for USB_OTG_DSTS register ********************/ -#define USB_OTG_DSTS_SUSPSTS_Pos (0U) -#define USB_OTG_DSTS_SUSPSTS_Msk (0x1UL << USB_OTG_DSTS_SUSPSTS_Pos) /*!< 0x00000001 */ -#define USB_OTG_DSTS_SUSPSTS USB_OTG_DSTS_SUSPSTS_Msk /*!< Suspend status */ - -#define USB_OTG_DSTS_ENUMSPD_Pos (1U) -#define USB_OTG_DSTS_ENUMSPD_Msk (0x3UL << USB_OTG_DSTS_ENUMSPD_Pos) /*!< 0x00000006 */ -#define USB_OTG_DSTS_ENUMSPD USB_OTG_DSTS_ENUMSPD_Msk /*!< Enumerated speed */ -#define USB_OTG_DSTS_ENUMSPD_0 (0x1UL << USB_OTG_DSTS_ENUMSPD_Pos) /*!< 0x00000002 */ -#define USB_OTG_DSTS_ENUMSPD_1 (0x2UL << USB_OTG_DSTS_ENUMSPD_Pos) /*!< 0x00000004 */ -#define USB_OTG_DSTS_EERR_Pos (3U) -#define USB_OTG_DSTS_EERR_Msk (0x1UL << USB_OTG_DSTS_EERR_Pos) /*!< 0x00000008 */ -#define USB_OTG_DSTS_EERR USB_OTG_DSTS_EERR_Msk /*!< Erratic error */ -#define USB_OTG_DSTS_FNSOF_Pos (8U) -#define USB_OTG_DSTS_FNSOF_Msk (0x3FFFUL << USB_OTG_DSTS_FNSOF_Pos) /*!< 0x003FFF00 */ -#define USB_OTG_DSTS_FNSOF USB_OTG_DSTS_FNSOF_Msk /*!< Frame number of the received SOF */ - -/******************** Bit definition for USB_OTG_GAHBCFG register ********************/ -#define USB_OTG_GAHBCFG_GINT_Pos (0U) -#define USB_OTG_GAHBCFG_GINT_Msk (0x1UL << USB_OTG_GAHBCFG_GINT_Pos) /*!< 0x00000001 */ -#define USB_OTG_GAHBCFG_GINT USB_OTG_GAHBCFG_GINT_Msk /*!< Global interrupt mask */ -#define USB_OTG_GAHBCFG_HBSTLEN_Pos (1U) -#define USB_OTG_GAHBCFG_HBSTLEN_Msk (0xFUL << USB_OTG_GAHBCFG_HBSTLEN_Pos) /*!< 0x0000001E */ -#define USB_OTG_GAHBCFG_HBSTLEN USB_OTG_GAHBCFG_HBSTLEN_Msk /*!< Burst length/type */ -#define USB_OTG_GAHBCFG_HBSTLEN_0 (0x0UL << USB_OTG_GAHBCFG_HBSTLEN_Pos) /*!< Single */ -#define USB_OTG_GAHBCFG_HBSTLEN_1 (0x1UL << USB_OTG_GAHBCFG_HBSTLEN_Pos) /*!< INCR */ -#define USB_OTG_GAHBCFG_HBSTLEN_2 (0x3UL << USB_OTG_GAHBCFG_HBSTLEN_Pos) /*!< INCR4 */ -#define USB_OTG_GAHBCFG_HBSTLEN_3 (0x5UL << USB_OTG_GAHBCFG_HBSTLEN_Pos) /*!< INCR8 */ -#define USB_OTG_GAHBCFG_HBSTLEN_4 (0x7UL << USB_OTG_GAHBCFG_HBSTLEN_Pos) /*!< INCR16 */ -#define USB_OTG_GAHBCFG_DMAEN_Pos (5U) -#define USB_OTG_GAHBCFG_DMAEN_Msk (0x1UL << USB_OTG_GAHBCFG_DMAEN_Pos) /*!< 0x00000020 */ -#define USB_OTG_GAHBCFG_DMAEN USB_OTG_GAHBCFG_DMAEN_Msk /*!< DMA enable */ -#define USB_OTG_GAHBCFG_TXFELVL_Pos (7U) -#define USB_OTG_GAHBCFG_TXFELVL_Msk (0x1UL << USB_OTG_GAHBCFG_TXFELVL_Pos) /*!< 0x00000080 */ -#define USB_OTG_GAHBCFG_TXFELVL USB_OTG_GAHBCFG_TXFELVL_Msk /*!< TxFIFO empty level */ -#define USB_OTG_GAHBCFG_PTXFELVL_Pos (8U) -#define USB_OTG_GAHBCFG_PTXFELVL_Msk (0x1UL << USB_OTG_GAHBCFG_PTXFELVL_Pos) /*!< 0x00000100 */ -#define USB_OTG_GAHBCFG_PTXFELVL USB_OTG_GAHBCFG_PTXFELVL_Msk /*!< Periodic TxFIFO empty level */ - -/******************** Bit definition for USB_OTG_GUSBCFG register ********************/ - -#define USB_OTG_GUSBCFG_TOCAL_Pos (0U) -#define USB_OTG_GUSBCFG_TOCAL_Msk (0x7UL << USB_OTG_GUSBCFG_TOCAL_Pos) /*!< 0x00000007 */ -#define USB_OTG_GUSBCFG_TOCAL USB_OTG_GUSBCFG_TOCAL_Msk /*!< FS timeout calibration */ -#define USB_OTG_GUSBCFG_TOCAL_0 (0x1UL << USB_OTG_GUSBCFG_TOCAL_Pos) /*!< 0x00000001 */ -#define USB_OTG_GUSBCFG_TOCAL_1 (0x2UL << USB_OTG_GUSBCFG_TOCAL_Pos) /*!< 0x00000002 */ -#define USB_OTG_GUSBCFG_TOCAL_2 (0x4UL << USB_OTG_GUSBCFG_TOCAL_Pos) /*!< 0x00000004 */ -#define USB_OTG_GUSBCFG_PHYSEL_Pos (6U) -#define USB_OTG_GUSBCFG_PHYSEL_Msk (0x1UL << USB_OTG_GUSBCFG_PHYSEL_Pos) /*!< 0x00000040 */ -#define USB_OTG_GUSBCFG_PHYSEL USB_OTG_GUSBCFG_PHYSEL_Msk /*!< USB 2.0 high-speed ULPI PHY or USB 1.1 full-speed serial transceiver select */ -#define USB_OTG_GUSBCFG_SRPCAP_Pos (8U) -#define USB_OTG_GUSBCFG_SRPCAP_Msk (0x1UL << USB_OTG_GUSBCFG_SRPCAP_Pos) /*!< 0x00000100 */ -#define USB_OTG_GUSBCFG_SRPCAP USB_OTG_GUSBCFG_SRPCAP_Msk /*!< SRP-capable */ -#define USB_OTG_GUSBCFG_HNPCAP_Pos (9U) -#define USB_OTG_GUSBCFG_HNPCAP_Msk (0x1UL << USB_OTG_GUSBCFG_HNPCAP_Pos) /*!< 0x00000200 */ -#define USB_OTG_GUSBCFG_HNPCAP USB_OTG_GUSBCFG_HNPCAP_Msk /*!< HNP-capable */ -#define USB_OTG_GUSBCFG_TRDT_Pos (10U) -#define USB_OTG_GUSBCFG_TRDT_Msk (0xFUL << USB_OTG_GUSBCFG_TRDT_Pos) /*!< 0x00003C00 */ -#define USB_OTG_GUSBCFG_TRDT USB_OTG_GUSBCFG_TRDT_Msk /*!< USB turnaround time */ -#define USB_OTG_GUSBCFG_TRDT_0 (0x1UL << USB_OTG_GUSBCFG_TRDT_Pos) /*!< 0x00000400 */ -#define USB_OTG_GUSBCFG_TRDT_1 (0x2UL << USB_OTG_GUSBCFG_TRDT_Pos) /*!< 0x00000800 */ -#define USB_OTG_GUSBCFG_TRDT_2 (0x4UL << USB_OTG_GUSBCFG_TRDT_Pos) /*!< 0x00001000 */ -#define USB_OTG_GUSBCFG_TRDT_3 (0x8UL << USB_OTG_GUSBCFG_TRDT_Pos) /*!< 0x00002000 */ -#define USB_OTG_GUSBCFG_PHYLPCS_Pos (15U) -#define USB_OTG_GUSBCFG_PHYLPCS_Msk (0x1UL << USB_OTG_GUSBCFG_PHYLPCS_Pos) /*!< 0x00008000 */ -#define USB_OTG_GUSBCFG_PHYLPCS USB_OTG_GUSBCFG_PHYLPCS_Msk /*!< PHY Low-power clock select */ -#define USB_OTG_GUSBCFG_ULPIFSLS_Pos (17U) -#define USB_OTG_GUSBCFG_ULPIFSLS_Msk (0x1UL << USB_OTG_GUSBCFG_ULPIFSLS_Pos) /*!< 0x00020000 */ -#define USB_OTG_GUSBCFG_ULPIFSLS USB_OTG_GUSBCFG_ULPIFSLS_Msk /*!< ULPI FS/LS select */ -#define USB_OTG_GUSBCFG_ULPIAR_Pos (18U) -#define USB_OTG_GUSBCFG_ULPIAR_Msk (0x1UL << USB_OTG_GUSBCFG_ULPIAR_Pos) /*!< 0x00040000 */ -#define USB_OTG_GUSBCFG_ULPIAR USB_OTG_GUSBCFG_ULPIAR_Msk /*!< ULPI Auto-resume */ -#define USB_OTG_GUSBCFG_ULPICSM_Pos (19U) -#define USB_OTG_GUSBCFG_ULPICSM_Msk (0x1UL << USB_OTG_GUSBCFG_ULPICSM_Pos) /*!< 0x00080000 */ -#define USB_OTG_GUSBCFG_ULPICSM USB_OTG_GUSBCFG_ULPICSM_Msk /*!< ULPI Clock SuspendM */ -#define USB_OTG_GUSBCFG_ULPIEVBUSD_Pos (20U) -#define USB_OTG_GUSBCFG_ULPIEVBUSD_Msk (0x1UL << USB_OTG_GUSBCFG_ULPIEVBUSD_Pos) /*!< 0x00100000 */ -#define USB_OTG_GUSBCFG_ULPIEVBUSD USB_OTG_GUSBCFG_ULPIEVBUSD_Msk /*!< ULPI External VBUS Drive */ -#define USB_OTG_GUSBCFG_ULPIEVBUSI_Pos (21U) -#define USB_OTG_GUSBCFG_ULPIEVBUSI_Msk (0x1UL << USB_OTG_GUSBCFG_ULPIEVBUSI_Pos) /*!< 0x00200000 */ -#define USB_OTG_GUSBCFG_ULPIEVBUSI USB_OTG_GUSBCFG_ULPIEVBUSI_Msk /*!< ULPI external VBUS indicator */ -#define USB_OTG_GUSBCFG_TSDPS_Pos (22U) -#define USB_OTG_GUSBCFG_TSDPS_Msk (0x1UL << USB_OTG_GUSBCFG_TSDPS_Pos) /*!< 0x00400000 */ -#define USB_OTG_GUSBCFG_TSDPS USB_OTG_GUSBCFG_TSDPS_Msk /*!< TermSel DLine pulsing selection */ -#define USB_OTG_GUSBCFG_PCCI_Pos (23U) -#define USB_OTG_GUSBCFG_PCCI_Msk (0x1UL << USB_OTG_GUSBCFG_PCCI_Pos) /*!< 0x00800000 */ -#define USB_OTG_GUSBCFG_PCCI USB_OTG_GUSBCFG_PCCI_Msk /*!< Indicator complement */ -#define USB_OTG_GUSBCFG_PTCI_Pos (24U) -#define USB_OTG_GUSBCFG_PTCI_Msk (0x1UL << USB_OTG_GUSBCFG_PTCI_Pos) /*!< 0x01000000 */ -#define USB_OTG_GUSBCFG_PTCI USB_OTG_GUSBCFG_PTCI_Msk /*!< Indicator pass through */ -#define USB_OTG_GUSBCFG_ULPIIPD_Pos (25U) -#define USB_OTG_GUSBCFG_ULPIIPD_Msk (0x1UL << USB_OTG_GUSBCFG_ULPIIPD_Pos) /*!< 0x02000000 */ -#define USB_OTG_GUSBCFG_ULPIIPD USB_OTG_GUSBCFG_ULPIIPD_Msk /*!< ULPI interface protect disable */ -#define USB_OTG_GUSBCFG_FHMOD_Pos (29U) -#define USB_OTG_GUSBCFG_FHMOD_Msk (0x1UL << USB_OTG_GUSBCFG_FHMOD_Pos) /*!< 0x20000000 */ -#define USB_OTG_GUSBCFG_FHMOD USB_OTG_GUSBCFG_FHMOD_Msk /*!< Forced host mode */ -#define USB_OTG_GUSBCFG_FDMOD_Pos (30U) -#define USB_OTG_GUSBCFG_FDMOD_Msk (0x1UL << USB_OTG_GUSBCFG_FDMOD_Pos) /*!< 0x40000000 */ -#define USB_OTG_GUSBCFG_FDMOD USB_OTG_GUSBCFG_FDMOD_Msk /*!< Forced peripheral mode */ -#define USB_OTG_GUSBCFG_CTXPKT_Pos (31U) -#define USB_OTG_GUSBCFG_CTXPKT_Msk (0x1UL << USB_OTG_GUSBCFG_CTXPKT_Pos) /*!< 0x80000000 */ -#define USB_OTG_GUSBCFG_CTXPKT USB_OTG_GUSBCFG_CTXPKT_Msk /*!< Corrupt Tx packet */ - -/******************** Bit definition for USB_OTG_GRSTCTL register ********************/ -#define USB_OTG_GRSTCTL_CSRST_Pos (0U) -#define USB_OTG_GRSTCTL_CSRST_Msk (0x1UL << USB_OTG_GRSTCTL_CSRST_Pos) /*!< 0x00000001 */ -#define USB_OTG_GRSTCTL_CSRST USB_OTG_GRSTCTL_CSRST_Msk /*!< Core soft reset */ -#define USB_OTG_GRSTCTL_HSRST_Pos (1U) -#define USB_OTG_GRSTCTL_HSRST_Msk (0x1UL << USB_OTG_GRSTCTL_HSRST_Pos) /*!< 0x00000002 */ -#define USB_OTG_GRSTCTL_HSRST USB_OTG_GRSTCTL_HSRST_Msk /*!< HCLK soft reset */ -#define USB_OTG_GRSTCTL_FCRST_Pos (2U) -#define USB_OTG_GRSTCTL_FCRST_Msk (0x1UL << USB_OTG_GRSTCTL_FCRST_Pos) /*!< 0x00000004 */ -#define USB_OTG_GRSTCTL_FCRST USB_OTG_GRSTCTL_FCRST_Msk /*!< Host frame counter reset */ -#define USB_OTG_GRSTCTL_RXFFLSH_Pos (4U) -#define USB_OTG_GRSTCTL_RXFFLSH_Msk (0x1UL << USB_OTG_GRSTCTL_RXFFLSH_Pos) /*!< 0x00000010 */ -#define USB_OTG_GRSTCTL_RXFFLSH USB_OTG_GRSTCTL_RXFFLSH_Msk /*!< RxFIFO flush */ -#define USB_OTG_GRSTCTL_TXFFLSH_Pos (5U) -#define USB_OTG_GRSTCTL_TXFFLSH_Msk (0x1UL << USB_OTG_GRSTCTL_TXFFLSH_Pos) /*!< 0x00000020 */ -#define USB_OTG_GRSTCTL_TXFFLSH USB_OTG_GRSTCTL_TXFFLSH_Msk /*!< TxFIFO flush */ - - -#define USB_OTG_GRSTCTL_TXFNUM_Pos (6U) -#define USB_OTG_GRSTCTL_TXFNUM_Msk (0x1FUL << USB_OTG_GRSTCTL_TXFNUM_Pos) /*!< 0x000007C0 */ -#define USB_OTG_GRSTCTL_TXFNUM USB_OTG_GRSTCTL_TXFNUM_Msk /*!< TxFIFO number */ -#define USB_OTG_GRSTCTL_TXFNUM_0 (0x01UL << USB_OTG_GRSTCTL_TXFNUM_Pos) /*!< 0x00000040 */ -#define USB_OTG_GRSTCTL_TXFNUM_1 (0x02UL << USB_OTG_GRSTCTL_TXFNUM_Pos) /*!< 0x00000080 */ -#define USB_OTG_GRSTCTL_TXFNUM_2 (0x04UL << USB_OTG_GRSTCTL_TXFNUM_Pos) /*!< 0x00000100 */ -#define USB_OTG_GRSTCTL_TXFNUM_3 (0x08UL << USB_OTG_GRSTCTL_TXFNUM_Pos) /*!< 0x00000200 */ -#define USB_OTG_GRSTCTL_TXFNUM_4 (0x10UL << USB_OTG_GRSTCTL_TXFNUM_Pos) /*!< 0x00000400 */ -#define USB_OTG_GRSTCTL_DMAREQ_Pos (30U) -#define USB_OTG_GRSTCTL_DMAREQ_Msk (0x1UL << USB_OTG_GRSTCTL_DMAREQ_Pos) /*!< 0x40000000 */ -#define USB_OTG_GRSTCTL_DMAREQ USB_OTG_GRSTCTL_DMAREQ_Msk /*!< DMA request signal */ -#define USB_OTG_GRSTCTL_AHBIDL_Pos (31U) -#define USB_OTG_GRSTCTL_AHBIDL_Msk (0x1UL << USB_OTG_GRSTCTL_AHBIDL_Pos) /*!< 0x80000000 */ -#define USB_OTG_GRSTCTL_AHBIDL USB_OTG_GRSTCTL_AHBIDL_Msk /*!< AHB master idle */ - -/******************** Bit definition for USB_OTG_DIEPMSK register ********************/ -#define USB_OTG_DIEPMSK_XFRCM_Pos (0U) -#define USB_OTG_DIEPMSK_XFRCM_Msk (0x1UL << USB_OTG_DIEPMSK_XFRCM_Pos) /*!< 0x00000001 */ -#define USB_OTG_DIEPMSK_XFRCM USB_OTG_DIEPMSK_XFRCM_Msk /*!< Transfer completed interrupt mask */ -#define USB_OTG_DIEPMSK_EPDM_Pos (1U) -#define USB_OTG_DIEPMSK_EPDM_Msk (0x1UL << USB_OTG_DIEPMSK_EPDM_Pos) /*!< 0x00000002 */ -#define USB_OTG_DIEPMSK_EPDM USB_OTG_DIEPMSK_EPDM_Msk /*!< Endpoint disabled interrupt mask */ -#define USB_OTG_DIEPMSK_TOM_Pos (3U) -#define USB_OTG_DIEPMSK_TOM_Msk (0x1UL << USB_OTG_DIEPMSK_TOM_Pos) /*!< 0x00000008 */ -#define USB_OTG_DIEPMSK_TOM USB_OTG_DIEPMSK_TOM_Msk /*!< Timeout condition mask (nonisochronous endpoints) */ -#define USB_OTG_DIEPMSK_ITTXFEMSK_Pos (4U) -#define USB_OTG_DIEPMSK_ITTXFEMSK_Msk (0x1UL << USB_OTG_DIEPMSK_ITTXFEMSK_Pos) /*!< 0x00000010 */ -#define USB_OTG_DIEPMSK_ITTXFEMSK USB_OTG_DIEPMSK_ITTXFEMSK_Msk /*!< IN token received when TxFIFO empty mask */ -#define USB_OTG_DIEPMSK_INEPNMM_Pos (5U) -#define USB_OTG_DIEPMSK_INEPNMM_Msk (0x1UL << USB_OTG_DIEPMSK_INEPNMM_Pos) /*!< 0x00000020 */ -#define USB_OTG_DIEPMSK_INEPNMM USB_OTG_DIEPMSK_INEPNMM_Msk /*!< IN token received with EP mismatch mask */ -#define USB_OTG_DIEPMSK_INEPNEM_Pos (6U) -#define USB_OTG_DIEPMSK_INEPNEM_Msk (0x1UL << USB_OTG_DIEPMSK_INEPNEM_Pos) /*!< 0x00000040 */ -#define USB_OTG_DIEPMSK_INEPNEM USB_OTG_DIEPMSK_INEPNEM_Msk /*!< IN endpoint NAK effective mask */ -#define USB_OTG_DIEPMSK_TXFURM_Pos (8U) -#define USB_OTG_DIEPMSK_TXFURM_Msk (0x1UL << USB_OTG_DIEPMSK_TXFURM_Pos) /*!< 0x00000100 */ -#define USB_OTG_DIEPMSK_TXFURM USB_OTG_DIEPMSK_TXFURM_Msk /*!< FIFO underrun mask */ -#define USB_OTG_DIEPMSK_BIM_Pos (9U) -#define USB_OTG_DIEPMSK_BIM_Msk (0x1UL << USB_OTG_DIEPMSK_BIM_Pos) /*!< 0x00000200 */ -#define USB_OTG_DIEPMSK_BIM USB_OTG_DIEPMSK_BIM_Msk /*!< BNA interrupt mask */ - -/******************** Bit definition for USB_OTG_HPTXSTS register ********************/ -#define USB_OTG_HPTXSTS_PTXFSAVL_Pos (0U) -#define USB_OTG_HPTXSTS_PTXFSAVL_Msk (0xFFFFUL << USB_OTG_HPTXSTS_PTXFSAVL_Pos) /*!< 0x0000FFFF */ -#define USB_OTG_HPTXSTS_PTXFSAVL USB_OTG_HPTXSTS_PTXFSAVL_Msk /*!< Periodic transmit data FIFO space available */ -#define USB_OTG_HPTXSTS_PTXQSAV_Pos (16U) -#define USB_OTG_HPTXSTS_PTXQSAV_Msk (0xFFUL << USB_OTG_HPTXSTS_PTXQSAV_Pos) /*!< 0x00FF0000 */ -#define USB_OTG_HPTXSTS_PTXQSAV USB_OTG_HPTXSTS_PTXQSAV_Msk /*!< Periodic transmit request queue space available */ -#define USB_OTG_HPTXSTS_PTXQSAV_0 (0x01UL << USB_OTG_HPTXSTS_PTXQSAV_Pos) /*!< 0x00010000 */ -#define USB_OTG_HPTXSTS_PTXQSAV_1 (0x02UL << USB_OTG_HPTXSTS_PTXQSAV_Pos) /*!< 0x00020000 */ -#define USB_OTG_HPTXSTS_PTXQSAV_2 (0x04UL << USB_OTG_HPTXSTS_PTXQSAV_Pos) /*!< 0x00040000 */ -#define USB_OTG_HPTXSTS_PTXQSAV_3 (0x08UL << USB_OTG_HPTXSTS_PTXQSAV_Pos) /*!< 0x00080000 */ -#define USB_OTG_HPTXSTS_PTXQSAV_4 (0x10UL << USB_OTG_HPTXSTS_PTXQSAV_Pos) /*!< 0x00100000 */ -#define USB_OTG_HPTXSTS_PTXQSAV_5 (0x20UL << USB_OTG_HPTXSTS_PTXQSAV_Pos) /*!< 0x00200000 */ -#define USB_OTG_HPTXSTS_PTXQSAV_6 (0x40UL << USB_OTG_HPTXSTS_PTXQSAV_Pos) /*!< 0x00400000 */ -#define USB_OTG_HPTXSTS_PTXQSAV_7 (0x80UL << USB_OTG_HPTXSTS_PTXQSAV_Pos) /*!< 0x00800000 */ - -#define USB_OTG_HPTXSTS_PTXQTOP_Pos (24U) -#define USB_OTG_HPTXSTS_PTXQTOP_Msk (0xFFUL << USB_OTG_HPTXSTS_PTXQTOP_Pos) /*!< 0xFF000000 */ -#define USB_OTG_HPTXSTS_PTXQTOP USB_OTG_HPTXSTS_PTXQTOP_Msk /*!< Top of the periodic transmit request queue */ -#define USB_OTG_HPTXSTS_PTXQTOP_0 (0x01UL << USB_OTG_HPTXSTS_PTXQTOP_Pos) /*!< 0x01000000 */ -#define USB_OTG_HPTXSTS_PTXQTOP_1 (0x02UL << USB_OTG_HPTXSTS_PTXQTOP_Pos) /*!< 0x02000000 */ -#define USB_OTG_HPTXSTS_PTXQTOP_2 (0x04UL << USB_OTG_HPTXSTS_PTXQTOP_Pos) /*!< 0x04000000 */ -#define USB_OTG_HPTXSTS_PTXQTOP_3 (0x08UL << USB_OTG_HPTXSTS_PTXQTOP_Pos) /*!< 0x08000000 */ -#define USB_OTG_HPTXSTS_PTXQTOP_4 (0x10UL << USB_OTG_HPTXSTS_PTXQTOP_Pos) /*!< 0x10000000 */ -#define USB_OTG_HPTXSTS_PTXQTOP_5 (0x20UL << USB_OTG_HPTXSTS_PTXQTOP_Pos) /*!< 0x20000000 */ -#define USB_OTG_HPTXSTS_PTXQTOP_6 (0x40UL << USB_OTG_HPTXSTS_PTXQTOP_Pos) /*!< 0x40000000 */ -#define USB_OTG_HPTXSTS_PTXQTOP_7 (0x80UL << USB_OTG_HPTXSTS_PTXQTOP_Pos) /*!< 0x80000000 */ - -/******************** Bit definition for USB_OTG_HAINT register ********************/ -#define USB_OTG_HAINT_HAINT_Pos (0U) -#define USB_OTG_HAINT_HAINT_Msk (0xFFFFUL << USB_OTG_HAINT_HAINT_Pos) /*!< 0x0000FFFF */ -#define USB_OTG_HAINT_HAINT USB_OTG_HAINT_HAINT_Msk /*!< Channel interrupts */ - -/******************** Bit definition for USB_OTG_DOEPMSK register ********************/ -#define USB_OTG_DOEPMSK_XFRCM_Pos (0U) -#define USB_OTG_DOEPMSK_XFRCM_Msk (0x1UL << USB_OTG_DOEPMSK_XFRCM_Pos) /*!< 0x00000001 */ -#define USB_OTG_DOEPMSK_XFRCM USB_OTG_DOEPMSK_XFRCM_Msk /*!< Transfer completed interrupt mask */ -#define USB_OTG_DOEPMSK_EPDM_Pos (1U) -#define USB_OTG_DOEPMSK_EPDM_Msk (0x1UL << USB_OTG_DOEPMSK_EPDM_Pos) /*!< 0x00000002 */ -#define USB_OTG_DOEPMSK_EPDM USB_OTG_DOEPMSK_EPDM_Msk /*!< Endpoint disabled interrupt mask */ -#define USB_OTG_DOEPMSK_AHBERRM_Pos (2U) -#define USB_OTG_DOEPMSK_AHBERRM_Msk (0x1UL << USB_OTG_DOEPMSK_AHBERRM_Pos) /*!< 0x00000004 */ -#define USB_OTG_DOEPMSK_AHBERRM USB_OTG_DOEPMSK_AHBERRM_Msk /*!< OUT transaction AHB Error interrupt mask */ -#define USB_OTG_DOEPMSK_STUPM_Pos (3U) -#define USB_OTG_DOEPMSK_STUPM_Msk (0x1UL << USB_OTG_DOEPMSK_STUPM_Pos) /*!< 0x00000008 */ -#define USB_OTG_DOEPMSK_STUPM USB_OTG_DOEPMSK_STUPM_Msk /*!< SETUP phase done mask */ -#define USB_OTG_DOEPMSK_OTEPDM_Pos (4U) -#define USB_OTG_DOEPMSK_OTEPDM_Msk (0x1UL << USB_OTG_DOEPMSK_OTEPDM_Pos) /*!< 0x00000010 */ -#define USB_OTG_DOEPMSK_OTEPDM USB_OTG_DOEPMSK_OTEPDM_Msk /*!< OUT token received when endpoint disabled mask */ -#define USB_OTG_DOEPMSK_OTEPSPRM_Pos (5U) -#define USB_OTG_DOEPMSK_OTEPSPRM_Msk (0x1UL << USB_OTG_DOEPMSK_OTEPSPRM_Pos) /*!< 0x00000020 */ -#define USB_OTG_DOEPMSK_OTEPSPRM USB_OTG_DOEPMSK_OTEPSPRM_Msk /*!< Status Phase Received mask */ -#define USB_OTG_DOEPMSK_B2BSTUP_Pos (6U) -#define USB_OTG_DOEPMSK_B2BSTUP_Msk (0x1UL << USB_OTG_DOEPMSK_B2BSTUP_Pos) /*!< 0x00000040 */ -#define USB_OTG_DOEPMSK_B2BSTUP USB_OTG_DOEPMSK_B2BSTUP_Msk /*!< Back-to-back SETUP packets received mask */ -#define USB_OTG_DOEPMSK_OPEM_Pos (8U) -#define USB_OTG_DOEPMSK_OPEM_Msk (0x1UL << USB_OTG_DOEPMSK_OPEM_Pos) /*!< 0x00000100 */ -#define USB_OTG_DOEPMSK_OPEM USB_OTG_DOEPMSK_OPEM_Msk /*!< OUT packet error mask */ -#define USB_OTG_DOEPMSK_BOIM_Pos (9U) -#define USB_OTG_DOEPMSK_BOIM_Msk (0x1UL << USB_OTG_DOEPMSK_BOIM_Pos) /*!< 0x00000200 */ -#define USB_OTG_DOEPMSK_BOIM USB_OTG_DOEPMSK_BOIM_Msk /*!< BNA interrupt mask */ -#define USB_OTG_DOEPMSK_BERRM_Pos (12U) -#define USB_OTG_DOEPMSK_BERRM_Msk (0x1UL << USB_OTG_DOEPMSK_BERRM_Pos) /*!< 0x00001000 */ -#define USB_OTG_DOEPMSK_BERRM USB_OTG_DOEPMSK_BERRM_Msk /*!< Babble error interrupt mask */ -#define USB_OTG_DOEPMSK_NAKM_Pos (13U) -#define USB_OTG_DOEPMSK_NAKM_Msk (0x1UL << USB_OTG_DOEPMSK_NAKM_Pos) /*!< 0x00002000 */ -#define USB_OTG_DOEPMSK_NAKM USB_OTG_DOEPMSK_NAKM_Msk /*!< OUT Packet NAK interrupt mask */ -#define USB_OTG_DOEPMSK_NYETM_Pos (14U) -#define USB_OTG_DOEPMSK_NYETM_Msk (0x1UL << USB_OTG_DOEPMSK_NYETM_Pos) /*!< 0x00004000 */ -#define USB_OTG_DOEPMSK_NYETM USB_OTG_DOEPMSK_NYETM_Msk /*!< NYET interrupt mask */ -/******************** Bit definition for USB_OTG_GINTSTS register ********************/ -#define USB_OTG_GINTSTS_CMOD_Pos (0U) -#define USB_OTG_GINTSTS_CMOD_Msk (0x1UL << USB_OTG_GINTSTS_CMOD_Pos) /*!< 0x00000001 */ -#define USB_OTG_GINTSTS_CMOD USB_OTG_GINTSTS_CMOD_Msk /*!< Current mode of operation */ -#define USB_OTG_GINTSTS_MMIS_Pos (1U) -#define USB_OTG_GINTSTS_MMIS_Msk (0x1UL << USB_OTG_GINTSTS_MMIS_Pos) /*!< 0x00000002 */ -#define USB_OTG_GINTSTS_MMIS USB_OTG_GINTSTS_MMIS_Msk /*!< Mode mismatch interrupt */ -#define USB_OTG_GINTSTS_OTGINT_Pos (2U) -#define USB_OTG_GINTSTS_OTGINT_Msk (0x1UL << USB_OTG_GINTSTS_OTGINT_Pos) /*!< 0x00000004 */ -#define USB_OTG_GINTSTS_OTGINT USB_OTG_GINTSTS_OTGINT_Msk /*!< OTG interrupt */ -#define USB_OTG_GINTSTS_SOF_Pos (3U) -#define USB_OTG_GINTSTS_SOF_Msk (0x1UL << USB_OTG_GINTSTS_SOF_Pos) /*!< 0x00000008 */ -#define USB_OTG_GINTSTS_SOF USB_OTG_GINTSTS_SOF_Msk /*!< Start of frame */ -#define USB_OTG_GINTSTS_RXFLVL_Pos (4U) -#define USB_OTG_GINTSTS_RXFLVL_Msk (0x1UL << USB_OTG_GINTSTS_RXFLVL_Pos) /*!< 0x00000010 */ -#define USB_OTG_GINTSTS_RXFLVL USB_OTG_GINTSTS_RXFLVL_Msk /*!< RxFIFO nonempty */ -#define USB_OTG_GINTSTS_NPTXFE_Pos (5U) -#define USB_OTG_GINTSTS_NPTXFE_Msk (0x1UL << USB_OTG_GINTSTS_NPTXFE_Pos) /*!< 0x00000020 */ -#define USB_OTG_GINTSTS_NPTXFE USB_OTG_GINTSTS_NPTXFE_Msk /*!< Nonperiodic TxFIFO empty */ -#define USB_OTG_GINTSTS_GINAKEFF_Pos (6U) -#define USB_OTG_GINTSTS_GINAKEFF_Msk (0x1UL << USB_OTG_GINTSTS_GINAKEFF_Pos) /*!< 0x00000040 */ -#define USB_OTG_GINTSTS_GINAKEFF USB_OTG_GINTSTS_GINAKEFF_Msk /*!< Global IN nonperiodic NAK effective */ -#define USB_OTG_GINTSTS_BOUTNAKEFF_Pos (7U) -#define USB_OTG_GINTSTS_BOUTNAKEFF_Msk (0x1UL << USB_OTG_GINTSTS_BOUTNAKEFF_Pos) /*!< 0x00000080 */ -#define USB_OTG_GINTSTS_BOUTNAKEFF USB_OTG_GINTSTS_BOUTNAKEFF_Msk /*!< Global OUT NAK effective */ -#define USB_OTG_GINTSTS_ESUSP_Pos (10U) -#define USB_OTG_GINTSTS_ESUSP_Msk (0x1UL << USB_OTG_GINTSTS_ESUSP_Pos) /*!< 0x00000400 */ -#define USB_OTG_GINTSTS_ESUSP USB_OTG_GINTSTS_ESUSP_Msk /*!< Early suspend */ -#define USB_OTG_GINTSTS_USBSUSP_Pos (11U) -#define USB_OTG_GINTSTS_USBSUSP_Msk (0x1UL << USB_OTG_GINTSTS_USBSUSP_Pos) /*!< 0x00000800 */ -#define USB_OTG_GINTSTS_USBSUSP USB_OTG_GINTSTS_USBSUSP_Msk /*!< USB suspend */ -#define USB_OTG_GINTSTS_USBRST_Pos (12U) -#define USB_OTG_GINTSTS_USBRST_Msk (0x1UL << USB_OTG_GINTSTS_USBRST_Pos) /*!< 0x00001000 */ -#define USB_OTG_GINTSTS_USBRST USB_OTG_GINTSTS_USBRST_Msk /*!< USB reset */ -#define USB_OTG_GINTSTS_ENUMDNE_Pos (13U) -#define USB_OTG_GINTSTS_ENUMDNE_Msk (0x1UL << USB_OTG_GINTSTS_ENUMDNE_Pos) /*!< 0x00002000 */ -#define USB_OTG_GINTSTS_ENUMDNE USB_OTG_GINTSTS_ENUMDNE_Msk /*!< Enumeration done */ -#define USB_OTG_GINTSTS_ISOODRP_Pos (14U) -#define USB_OTG_GINTSTS_ISOODRP_Msk (0x1UL << USB_OTG_GINTSTS_ISOODRP_Pos) /*!< 0x00004000 */ -#define USB_OTG_GINTSTS_ISOODRP USB_OTG_GINTSTS_ISOODRP_Msk /*!< Isochronous OUT packet dropped interrupt */ -#define USB_OTG_GINTSTS_EOPF_Pos (15U) -#define USB_OTG_GINTSTS_EOPF_Msk (0x1UL << USB_OTG_GINTSTS_EOPF_Pos) /*!< 0x00008000 */ -#define USB_OTG_GINTSTS_EOPF USB_OTG_GINTSTS_EOPF_Msk /*!< End of periodic frame interrupt */ -#define USB_OTG_GINTSTS_IEPINT_Pos (18U) -#define USB_OTG_GINTSTS_IEPINT_Msk (0x1UL << USB_OTG_GINTSTS_IEPINT_Pos) /*!< 0x00040000 */ -#define USB_OTG_GINTSTS_IEPINT USB_OTG_GINTSTS_IEPINT_Msk /*!< IN endpoint interrupt */ -#define USB_OTG_GINTSTS_OEPINT_Pos (19U) -#define USB_OTG_GINTSTS_OEPINT_Msk (0x1UL << USB_OTG_GINTSTS_OEPINT_Pos) /*!< 0x00080000 */ -#define USB_OTG_GINTSTS_OEPINT USB_OTG_GINTSTS_OEPINT_Msk /*!< OUT endpoint interrupt */ -#define USB_OTG_GINTSTS_IISOIXFR_Pos (20U) -#define USB_OTG_GINTSTS_IISOIXFR_Msk (0x1UL << USB_OTG_GINTSTS_IISOIXFR_Pos) /*!< 0x00100000 */ -#define USB_OTG_GINTSTS_IISOIXFR USB_OTG_GINTSTS_IISOIXFR_Msk /*!< Incomplete isochronous IN transfer */ -#define USB_OTG_GINTSTS_PXFR_INCOMPISOOUT_Pos (21U) -#define USB_OTG_GINTSTS_PXFR_INCOMPISOOUT_Msk (0x1UL << USB_OTG_GINTSTS_PXFR_INCOMPISOOUT_Pos) /*!< 0x00200000 */ -#define USB_OTG_GINTSTS_PXFR_INCOMPISOOUT USB_OTG_GINTSTS_PXFR_INCOMPISOOUT_Msk /*!< Incomplete periodic transfer */ -#define USB_OTG_GINTSTS_DATAFSUSP_Pos (22U) -#define USB_OTG_GINTSTS_DATAFSUSP_Msk (0x1UL << USB_OTG_GINTSTS_DATAFSUSP_Pos) /*!< 0x00400000 */ -#define USB_OTG_GINTSTS_DATAFSUSP USB_OTG_GINTSTS_DATAFSUSP_Msk /*!< Data fetch suspended */ -#define USB_OTG_GINTSTS_HPRTINT_Pos (24U) -#define USB_OTG_GINTSTS_HPRTINT_Msk (0x1UL << USB_OTG_GINTSTS_HPRTINT_Pos) /*!< 0x01000000 */ -#define USB_OTG_GINTSTS_HPRTINT USB_OTG_GINTSTS_HPRTINT_Msk /*!< Host port interrupt */ -#define USB_OTG_GINTSTS_HCINT_Pos (25U) -#define USB_OTG_GINTSTS_HCINT_Msk (0x1UL << USB_OTG_GINTSTS_HCINT_Pos) /*!< 0x02000000 */ -#define USB_OTG_GINTSTS_HCINT USB_OTG_GINTSTS_HCINT_Msk /*!< Host channels interrupt */ -#define USB_OTG_GINTSTS_PTXFE_Pos (26U) -#define USB_OTG_GINTSTS_PTXFE_Msk (0x1UL << USB_OTG_GINTSTS_PTXFE_Pos) /*!< 0x04000000 */ -#define USB_OTG_GINTSTS_PTXFE USB_OTG_GINTSTS_PTXFE_Msk /*!< Periodic TxFIFO empty */ -#define USB_OTG_GINTSTS_CIDSCHG_Pos (28U) -#define USB_OTG_GINTSTS_CIDSCHG_Msk (0x1UL << USB_OTG_GINTSTS_CIDSCHG_Pos) /*!< 0x10000000 */ -#define USB_OTG_GINTSTS_CIDSCHG USB_OTG_GINTSTS_CIDSCHG_Msk /*!< Connector ID status change */ -#define USB_OTG_GINTSTS_DISCINT_Pos (29U) -#define USB_OTG_GINTSTS_DISCINT_Msk (0x1UL << USB_OTG_GINTSTS_DISCINT_Pos) /*!< 0x20000000 */ -#define USB_OTG_GINTSTS_DISCINT USB_OTG_GINTSTS_DISCINT_Msk /*!< Disconnect detected interrupt */ -#define USB_OTG_GINTSTS_SRQINT_Pos (30U) -#define USB_OTG_GINTSTS_SRQINT_Msk (0x1UL << USB_OTG_GINTSTS_SRQINT_Pos) /*!< 0x40000000 */ -#define USB_OTG_GINTSTS_SRQINT USB_OTG_GINTSTS_SRQINT_Msk /*!< Session request/new session detected interrupt */ -#define USB_OTG_GINTSTS_WKUINT_Pos (31U) -#define USB_OTG_GINTSTS_WKUINT_Msk (0x1UL << USB_OTG_GINTSTS_WKUINT_Pos) /*!< 0x80000000 */ -#define USB_OTG_GINTSTS_WKUINT USB_OTG_GINTSTS_WKUINT_Msk /*!< Resume/remote wakeup detected interrupt */ - -/******************** Bit definition for USB_OTG_GINTMSK register ********************/ -#define USB_OTG_GINTMSK_MMISM_Pos (1U) -#define USB_OTG_GINTMSK_MMISM_Msk (0x1UL << USB_OTG_GINTMSK_MMISM_Pos) /*!< 0x00000002 */ -#define USB_OTG_GINTMSK_MMISM USB_OTG_GINTMSK_MMISM_Msk /*!< Mode mismatch interrupt mask */ -#define USB_OTG_GINTMSK_OTGINT_Pos (2U) -#define USB_OTG_GINTMSK_OTGINT_Msk (0x1UL << USB_OTG_GINTMSK_OTGINT_Pos) /*!< 0x00000004 */ -#define USB_OTG_GINTMSK_OTGINT USB_OTG_GINTMSK_OTGINT_Msk /*!< OTG interrupt mask */ -#define USB_OTG_GINTMSK_SOFM_Pos (3U) -#define USB_OTG_GINTMSK_SOFM_Msk (0x1UL << USB_OTG_GINTMSK_SOFM_Pos) /*!< 0x00000008 */ -#define USB_OTG_GINTMSK_SOFM USB_OTG_GINTMSK_SOFM_Msk /*!< Start of frame mask */ -#define USB_OTG_GINTMSK_RXFLVLM_Pos (4U) -#define USB_OTG_GINTMSK_RXFLVLM_Msk (0x1UL << USB_OTG_GINTMSK_RXFLVLM_Pos) /*!< 0x00000010 */ -#define USB_OTG_GINTMSK_RXFLVLM USB_OTG_GINTMSK_RXFLVLM_Msk /*!< Receive FIFO nonempty mask */ -#define USB_OTG_GINTMSK_NPTXFEM_Pos (5U) -#define USB_OTG_GINTMSK_NPTXFEM_Msk (0x1UL << USB_OTG_GINTMSK_NPTXFEM_Pos) /*!< 0x00000020 */ -#define USB_OTG_GINTMSK_NPTXFEM USB_OTG_GINTMSK_NPTXFEM_Msk /*!< Nonperiodic TxFIFO empty mask */ -#define USB_OTG_GINTMSK_GINAKEFFM_Pos (6U) -#define USB_OTG_GINTMSK_GINAKEFFM_Msk (0x1UL << USB_OTG_GINTMSK_GINAKEFFM_Pos) /*!< 0x00000040 */ -#define USB_OTG_GINTMSK_GINAKEFFM USB_OTG_GINTMSK_GINAKEFFM_Msk /*!< Global nonperiodic IN NAK effective mask */ -#define USB_OTG_GINTMSK_GONAKEFFM_Pos (7U) -#define USB_OTG_GINTMSK_GONAKEFFM_Msk (0x1UL << USB_OTG_GINTMSK_GONAKEFFM_Pos) /*!< 0x00000080 */ -#define USB_OTG_GINTMSK_GONAKEFFM USB_OTG_GINTMSK_GONAKEFFM_Msk /*!< Global OUT NAK effective mask */ -#define USB_OTG_GINTMSK_ESUSPM_Pos (10U) -#define USB_OTG_GINTMSK_ESUSPM_Msk (0x1UL << USB_OTG_GINTMSK_ESUSPM_Pos) /*!< 0x00000400 */ -#define USB_OTG_GINTMSK_ESUSPM USB_OTG_GINTMSK_ESUSPM_Msk /*!< Early suspend mask */ -#define USB_OTG_GINTMSK_USBSUSPM_Pos (11U) -#define USB_OTG_GINTMSK_USBSUSPM_Msk (0x1UL << USB_OTG_GINTMSK_USBSUSPM_Pos) /*!< 0x00000800 */ -#define USB_OTG_GINTMSK_USBSUSPM USB_OTG_GINTMSK_USBSUSPM_Msk /*!< USB suspend mask */ -#define USB_OTG_GINTMSK_USBRST_Pos (12U) -#define USB_OTG_GINTMSK_USBRST_Msk (0x1UL << USB_OTG_GINTMSK_USBRST_Pos) /*!< 0x00001000 */ -#define USB_OTG_GINTMSK_USBRST USB_OTG_GINTMSK_USBRST_Msk /*!< USB reset mask */ -#define USB_OTG_GINTMSK_ENUMDNEM_Pos (13U) -#define USB_OTG_GINTMSK_ENUMDNEM_Msk (0x1UL << USB_OTG_GINTMSK_ENUMDNEM_Pos) /*!< 0x00002000 */ -#define USB_OTG_GINTMSK_ENUMDNEM USB_OTG_GINTMSK_ENUMDNEM_Msk /*!< Enumeration done mask */ -#define USB_OTG_GINTMSK_ISOODRPM_Pos (14U) -#define USB_OTG_GINTMSK_ISOODRPM_Msk (0x1UL << USB_OTG_GINTMSK_ISOODRPM_Pos) /*!< 0x00004000 */ -#define USB_OTG_GINTMSK_ISOODRPM USB_OTG_GINTMSK_ISOODRPM_Msk /*!< Isochronous OUT packet dropped interrupt mask */ -#define USB_OTG_GINTMSK_EOPFM_Pos (15U) -#define USB_OTG_GINTMSK_EOPFM_Msk (0x1UL << USB_OTG_GINTMSK_EOPFM_Pos) /*!< 0x00008000 */ -#define USB_OTG_GINTMSK_EOPFM USB_OTG_GINTMSK_EOPFM_Msk /*!< End of periodic frame interrupt mask */ -#define USB_OTG_GINTMSK_EPMISM_Pos (17U) -#define USB_OTG_GINTMSK_EPMISM_Msk (0x1UL << USB_OTG_GINTMSK_EPMISM_Pos) /*!< 0x00020000 */ -#define USB_OTG_GINTMSK_EPMISM USB_OTG_GINTMSK_EPMISM_Msk /*!< Endpoint mismatch interrupt mask */ -#define USB_OTG_GINTMSK_IEPINT_Pos (18U) -#define USB_OTG_GINTMSK_IEPINT_Msk (0x1UL << USB_OTG_GINTMSK_IEPINT_Pos) /*!< 0x00040000 */ -#define USB_OTG_GINTMSK_IEPINT USB_OTG_GINTMSK_IEPINT_Msk /*!< IN endpoints interrupt mask */ -#define USB_OTG_GINTMSK_OEPINT_Pos (19U) -#define USB_OTG_GINTMSK_OEPINT_Msk (0x1UL << USB_OTG_GINTMSK_OEPINT_Pos) /*!< 0x00080000 */ -#define USB_OTG_GINTMSK_OEPINT USB_OTG_GINTMSK_OEPINT_Msk /*!< OUT endpoints interrupt mask */ -#define USB_OTG_GINTMSK_IISOIXFRM_Pos (20U) -#define USB_OTG_GINTMSK_IISOIXFRM_Msk (0x1UL << USB_OTG_GINTMSK_IISOIXFRM_Pos) /*!< 0x00100000 */ -#define USB_OTG_GINTMSK_IISOIXFRM USB_OTG_GINTMSK_IISOIXFRM_Msk /*!< Incomplete isochronous IN transfer mask */ -#define USB_OTG_GINTMSK_PXFRM_IISOOXFRM_Pos (21U) -#define USB_OTG_GINTMSK_PXFRM_IISOOXFRM_Msk (0x1UL << USB_OTG_GINTMSK_PXFRM_IISOOXFRM_Pos) /*!< 0x00200000 */ -#define USB_OTG_GINTMSK_PXFRM_IISOOXFRM USB_OTG_GINTMSK_PXFRM_IISOOXFRM_Msk /*!< Incomplete periodic transfer mask */ -#define USB_OTG_GINTMSK_FSUSPM_Pos (22U) -#define USB_OTG_GINTMSK_FSUSPM_Msk (0x1UL << USB_OTG_GINTMSK_FSUSPM_Pos) /*!< 0x00400000 */ -#define USB_OTG_GINTMSK_FSUSPM USB_OTG_GINTMSK_FSUSPM_Msk /*!< Data fetch suspended mask */ -#define USB_OTG_GINTMSK_PRTIM_Pos (24U) -#define USB_OTG_GINTMSK_PRTIM_Msk (0x1UL << USB_OTG_GINTMSK_PRTIM_Pos) /*!< 0x01000000 */ -#define USB_OTG_GINTMSK_PRTIM USB_OTG_GINTMSK_PRTIM_Msk /*!< Host port interrupt mask */ -#define USB_OTG_GINTMSK_HCIM_Pos (25U) -#define USB_OTG_GINTMSK_HCIM_Msk (0x1UL << USB_OTG_GINTMSK_HCIM_Pos) /*!< 0x02000000 */ -#define USB_OTG_GINTMSK_HCIM USB_OTG_GINTMSK_HCIM_Msk /*!< Host channels interrupt mask */ -#define USB_OTG_GINTMSK_PTXFEM_Pos (26U) -#define USB_OTG_GINTMSK_PTXFEM_Msk (0x1UL << USB_OTG_GINTMSK_PTXFEM_Pos) /*!< 0x04000000 */ -#define USB_OTG_GINTMSK_PTXFEM USB_OTG_GINTMSK_PTXFEM_Msk /*!< Periodic TxFIFO empty mask */ -#define USB_OTG_GINTMSK_CIDSCHGM_Pos (28U) -#define USB_OTG_GINTMSK_CIDSCHGM_Msk (0x1UL << USB_OTG_GINTMSK_CIDSCHGM_Pos) /*!< 0x10000000 */ -#define USB_OTG_GINTMSK_CIDSCHGM USB_OTG_GINTMSK_CIDSCHGM_Msk /*!< Connector ID status change mask */ -#define USB_OTG_GINTMSK_DISCINT_Pos (29U) -#define USB_OTG_GINTMSK_DISCINT_Msk (0x1UL << USB_OTG_GINTMSK_DISCINT_Pos) /*!< 0x20000000 */ -#define USB_OTG_GINTMSK_DISCINT USB_OTG_GINTMSK_DISCINT_Msk /*!< Disconnect detected interrupt mask */ -#define USB_OTG_GINTMSK_SRQIM_Pos (30U) -#define USB_OTG_GINTMSK_SRQIM_Msk (0x1UL << USB_OTG_GINTMSK_SRQIM_Pos) /*!< 0x40000000 */ -#define USB_OTG_GINTMSK_SRQIM USB_OTG_GINTMSK_SRQIM_Msk /*!< Session request/new session detected interrupt mask */ -#define USB_OTG_GINTMSK_WUIM_Pos (31U) -#define USB_OTG_GINTMSK_WUIM_Msk (0x1UL << USB_OTG_GINTMSK_WUIM_Pos) /*!< 0x80000000 */ -#define USB_OTG_GINTMSK_WUIM USB_OTG_GINTMSK_WUIM_Msk /*!< Resume/remote wakeup detected interrupt mask */ - -/******************** Bit definition for USB_OTG_DAINT register ********************/ -#define USB_OTG_DAINT_IEPINT_Pos (0U) -#define USB_OTG_DAINT_IEPINT_Msk (0xFFFFUL << USB_OTG_DAINT_IEPINT_Pos) /*!< 0x0000FFFF */ -#define USB_OTG_DAINT_IEPINT USB_OTG_DAINT_IEPINT_Msk /*!< IN endpoint interrupt bits */ -#define USB_OTG_DAINT_OEPINT_Pos (16U) -#define USB_OTG_DAINT_OEPINT_Msk (0xFFFFUL << USB_OTG_DAINT_OEPINT_Pos) /*!< 0xFFFF0000 */ -#define USB_OTG_DAINT_OEPINT USB_OTG_DAINT_OEPINT_Msk /*!< OUT endpoint interrupt bits */ - -/******************** Bit definition for USB_OTG_HAINTMSK register ********************/ -#define USB_OTG_HAINTMSK_HAINTM_Pos (0U) -#define USB_OTG_HAINTMSK_HAINTM_Msk (0xFFFFUL << USB_OTG_HAINTMSK_HAINTM_Pos) /*!< 0x0000FFFF */ -#define USB_OTG_HAINTMSK_HAINTM USB_OTG_HAINTMSK_HAINTM_Msk /*!< Channel interrupt mask */ - -/******************** Bit definition for USB_OTG_GRXSTSP register ********************/ -#define USB_OTG_GRXSTSP_EPNUM_Pos (0U) -#define USB_OTG_GRXSTSP_EPNUM_Msk (0xFUL << USB_OTG_GRXSTSP_EPNUM_Pos) /*!< 0x0000000F */ -#define USB_OTG_GRXSTSP_EPNUM USB_OTG_GRXSTSP_EPNUM_Msk /*!< IN EP interrupt mask bits */ -#define USB_OTG_GRXSTSP_BCNT_Pos (4U) -#define USB_OTG_GRXSTSP_BCNT_Msk (0x7FFUL << USB_OTG_GRXSTSP_BCNT_Pos) /*!< 0x00007FF0 */ -#define USB_OTG_GRXSTSP_BCNT USB_OTG_GRXSTSP_BCNT_Msk /*!< OUT EP interrupt mask bits */ -#define USB_OTG_GRXSTSP_DPID_Pos (15U) -#define USB_OTG_GRXSTSP_DPID_Msk (0x3UL << USB_OTG_GRXSTSP_DPID_Pos) /*!< 0x00018000 */ -#define USB_OTG_GRXSTSP_DPID USB_OTG_GRXSTSP_DPID_Msk /*!< OUT EP interrupt mask bits */ -#define USB_OTG_GRXSTSP_PKTSTS_Pos (17U) -#define USB_OTG_GRXSTSP_PKTSTS_Msk (0xFUL << USB_OTG_GRXSTSP_PKTSTS_Pos) /*!< 0x001E0000 */ -#define USB_OTG_GRXSTSP_PKTSTS USB_OTG_GRXSTSP_PKTSTS_Msk /*!< OUT EP interrupt mask bits */ - -/******************** Bit definition for USB_OTG_DAINTMSK register ********************/ -#define USB_OTG_DAINTMSK_IEPM_Pos (0U) -#define USB_OTG_DAINTMSK_IEPM_Msk (0xFFFFUL << USB_OTG_DAINTMSK_IEPM_Pos) /*!< 0x0000FFFF */ -#define USB_OTG_DAINTMSK_IEPM USB_OTG_DAINTMSK_IEPM_Msk /*!< IN EP interrupt mask bits */ -#define USB_OTG_DAINTMSK_OEPM_Pos (16U) -#define USB_OTG_DAINTMSK_OEPM_Msk (0xFFFFUL << USB_OTG_DAINTMSK_OEPM_Pos) /*!< 0xFFFF0000 */ -#define USB_OTG_DAINTMSK_OEPM USB_OTG_DAINTMSK_OEPM_Msk /*!< OUT EP interrupt mask bits */ - -/******************** Bit definition for USB_OTG_GRXFSIZ register ********************/ -#define USB_OTG_GRXFSIZ_RXFD_Pos (0U) -#define USB_OTG_GRXFSIZ_RXFD_Msk (0xFFFFUL << USB_OTG_GRXFSIZ_RXFD_Pos) /*!< 0x0000FFFF */ -#define USB_OTG_GRXFSIZ_RXFD USB_OTG_GRXFSIZ_RXFD_Msk /*!< RxFIFO depth */ - -/******************** Bit definition for USB_OTG_DVBUSDIS register ********************/ -#define USB_OTG_DVBUSDIS_VBUSDT_Pos (0U) -#define USB_OTG_DVBUSDIS_VBUSDT_Msk (0xFFFFUL << USB_OTG_DVBUSDIS_VBUSDT_Pos) /*!< 0x0000FFFF */ -#define USB_OTG_DVBUSDIS_VBUSDT USB_OTG_DVBUSDIS_VBUSDT_Msk /*!< Device VBUS discharge time */ - -/******************** Bit definition for OTG register ********************/ -#define USB_OTG_NPTXFSA_Pos (0U) -#define USB_OTG_NPTXFSA_Msk (0xFFFFUL << USB_OTG_NPTXFSA_Pos) /*!< 0x0000FFFF */ -#define USB_OTG_NPTXFSA USB_OTG_NPTXFSA_Msk /*!< Nonperiodic transmit RAM start address */ -#define USB_OTG_NPTXFD_Pos (16U) -#define USB_OTG_NPTXFD_Msk (0xFFFFUL << USB_OTG_NPTXFD_Pos) /*!< 0xFFFF0000 */ -#define USB_OTG_NPTXFD USB_OTG_NPTXFD_Msk /*!< Nonperiodic TxFIFO depth */ -#define USB_OTG_TX0FSA_Pos (0U) -#define USB_OTG_TX0FSA_Msk (0xFFFFUL << USB_OTG_TX0FSA_Pos) /*!< 0x0000FFFF */ -#define USB_OTG_TX0FSA USB_OTG_TX0FSA_Msk /*!< Endpoint 0 transmit RAM start address */ -#define USB_OTG_TX0FD_Pos (16U) -#define USB_OTG_TX0FD_Msk (0xFFFFUL << USB_OTG_TX0FD_Pos) /*!< 0xFFFF0000 */ -#define USB_OTG_TX0FD USB_OTG_TX0FD_Msk /*!< Endpoint 0 TxFIFO depth */ - -/******************** Bit definition for USB_OTG_DVBUSPULSE register ********************/ -#define USB_OTG_DVBUSPULSE_DVBUSP_Pos (0U) -#define USB_OTG_DVBUSPULSE_DVBUSP_Msk (0xFFFUL << USB_OTG_DVBUSPULSE_DVBUSP_Pos) /*!< 0x00000FFF */ -#define USB_OTG_DVBUSPULSE_DVBUSP USB_OTG_DVBUSPULSE_DVBUSP_Msk /*!< Device VBUS pulsing time */ - -/******************** Bit definition for USB_OTG_GNPTXSTS register ********************/ -#define USB_OTG_GNPTXSTS_NPTXFSAV_Pos (0U) -#define USB_OTG_GNPTXSTS_NPTXFSAV_Msk (0xFFFFUL << USB_OTG_GNPTXSTS_NPTXFSAV_Pos) /*!< 0x0000FFFF */ -#define USB_OTG_GNPTXSTS_NPTXFSAV USB_OTG_GNPTXSTS_NPTXFSAV_Msk /*!< Nonperiodic TxFIFO space available */ - -#define USB_OTG_GNPTXSTS_NPTQXSAV_Pos (16U) -#define USB_OTG_GNPTXSTS_NPTQXSAV_Msk (0xFFUL << USB_OTG_GNPTXSTS_NPTQXSAV_Pos) /*!< 0x00FF0000 */ -#define USB_OTG_GNPTXSTS_NPTQXSAV USB_OTG_GNPTXSTS_NPTQXSAV_Msk /*!< Nonperiodic transmit request queue space available */ -#define USB_OTG_GNPTXSTS_NPTQXSAV_0 (0x01UL << USB_OTG_GNPTXSTS_NPTQXSAV_Pos) /*!< 0x00010000 */ -#define USB_OTG_GNPTXSTS_NPTQXSAV_1 (0x02UL << USB_OTG_GNPTXSTS_NPTQXSAV_Pos) /*!< 0x00020000 */ -#define USB_OTG_GNPTXSTS_NPTQXSAV_2 (0x04UL << USB_OTG_GNPTXSTS_NPTQXSAV_Pos) /*!< 0x00040000 */ -#define USB_OTG_GNPTXSTS_NPTQXSAV_3 (0x08UL << USB_OTG_GNPTXSTS_NPTQXSAV_Pos) /*!< 0x00080000 */ -#define USB_OTG_GNPTXSTS_NPTQXSAV_4 (0x10UL << USB_OTG_GNPTXSTS_NPTQXSAV_Pos) /*!< 0x00100000 */ -#define USB_OTG_GNPTXSTS_NPTQXSAV_5 (0x20UL << USB_OTG_GNPTXSTS_NPTQXSAV_Pos) /*!< 0x00200000 */ -#define USB_OTG_GNPTXSTS_NPTQXSAV_6 (0x40UL << USB_OTG_GNPTXSTS_NPTQXSAV_Pos) /*!< 0x00400000 */ -#define USB_OTG_GNPTXSTS_NPTQXSAV_7 (0x80UL << USB_OTG_GNPTXSTS_NPTQXSAV_Pos) /*!< 0x00800000 */ - -#define USB_OTG_GNPTXSTS_NPTXQTOP_Pos (24U) -#define USB_OTG_GNPTXSTS_NPTXQTOP_Msk (0x7FUL << USB_OTG_GNPTXSTS_NPTXQTOP_Pos) /*!< 0x7F000000 */ -#define USB_OTG_GNPTXSTS_NPTXQTOP USB_OTG_GNPTXSTS_NPTXQTOP_Msk /*!< Top of the nonperiodic transmit request queue */ -#define USB_OTG_GNPTXSTS_NPTXQTOP_0 (0x01UL << USB_OTG_GNPTXSTS_NPTXQTOP_Pos) /*!< 0x01000000 */ -#define USB_OTG_GNPTXSTS_NPTXQTOP_1 (0x02UL << USB_OTG_GNPTXSTS_NPTXQTOP_Pos) /*!< 0x02000000 */ -#define USB_OTG_GNPTXSTS_NPTXQTOP_2 (0x04UL << USB_OTG_GNPTXSTS_NPTXQTOP_Pos) /*!< 0x04000000 */ -#define USB_OTG_GNPTXSTS_NPTXQTOP_3 (0x08UL << USB_OTG_GNPTXSTS_NPTXQTOP_Pos) /*!< 0x08000000 */ -#define USB_OTG_GNPTXSTS_NPTXQTOP_4 (0x10UL << USB_OTG_GNPTXSTS_NPTXQTOP_Pos) /*!< 0x10000000 */ -#define USB_OTG_GNPTXSTS_NPTXQTOP_5 (0x20UL << USB_OTG_GNPTXSTS_NPTXQTOP_Pos) /*!< 0x20000000 */ -#define USB_OTG_GNPTXSTS_NPTXQTOP_6 (0x40UL << USB_OTG_GNPTXSTS_NPTXQTOP_Pos) /*!< 0x40000000 */ - -/******************** Bit definition for USB_OTG_DTHRCTL register ********************/ -#define USB_OTG_DTHRCTL_NONISOTHREN_Pos (0U) -#define USB_OTG_DTHRCTL_NONISOTHREN_Msk (0x1UL << USB_OTG_DTHRCTL_NONISOTHREN_Pos) /*!< 0x00000001 */ -#define USB_OTG_DTHRCTL_NONISOTHREN USB_OTG_DTHRCTL_NONISOTHREN_Msk /*!< Nonisochronous IN endpoints threshold enable */ -#define USB_OTG_DTHRCTL_ISOTHREN_Pos (1U) -#define USB_OTG_DTHRCTL_ISOTHREN_Msk (0x1UL << USB_OTG_DTHRCTL_ISOTHREN_Pos) /*!< 0x00000002 */ -#define USB_OTG_DTHRCTL_ISOTHREN USB_OTG_DTHRCTL_ISOTHREN_Msk /*!< ISO IN endpoint threshold enable */ - -#define USB_OTG_DTHRCTL_TXTHRLEN_Pos (2U) -#define USB_OTG_DTHRCTL_TXTHRLEN_Msk (0x1FFUL << USB_OTG_DTHRCTL_TXTHRLEN_Pos) /*!< 0x000007FC */ -#define USB_OTG_DTHRCTL_TXTHRLEN USB_OTG_DTHRCTL_TXTHRLEN_Msk /*!< Transmit threshold length */ -#define USB_OTG_DTHRCTL_TXTHRLEN_0 (0x001UL << USB_OTG_DTHRCTL_TXTHRLEN_Pos) /*!< 0x00000004 */ -#define USB_OTG_DTHRCTL_TXTHRLEN_1 (0x002UL << USB_OTG_DTHRCTL_TXTHRLEN_Pos) /*!< 0x00000008 */ -#define USB_OTG_DTHRCTL_TXTHRLEN_2 (0x004UL << USB_OTG_DTHRCTL_TXTHRLEN_Pos) /*!< 0x00000010 */ -#define USB_OTG_DTHRCTL_TXTHRLEN_3 (0x008UL << USB_OTG_DTHRCTL_TXTHRLEN_Pos) /*!< 0x00000020 */ -#define USB_OTG_DTHRCTL_TXTHRLEN_4 (0x010UL << USB_OTG_DTHRCTL_TXTHRLEN_Pos) /*!< 0x00000040 */ -#define USB_OTG_DTHRCTL_TXTHRLEN_5 (0x020UL << USB_OTG_DTHRCTL_TXTHRLEN_Pos) /*!< 0x00000080 */ -#define USB_OTG_DTHRCTL_TXTHRLEN_6 (0x040UL << USB_OTG_DTHRCTL_TXTHRLEN_Pos) /*!< 0x00000100 */ -#define USB_OTG_DTHRCTL_TXTHRLEN_7 (0x080UL << USB_OTG_DTHRCTL_TXTHRLEN_Pos) /*!< 0x00000200 */ -#define USB_OTG_DTHRCTL_TXTHRLEN_8 (0x100UL << USB_OTG_DTHRCTL_TXTHRLEN_Pos) /*!< 0x00000400 */ -#define USB_OTG_DTHRCTL_RXTHREN_Pos (16U) -#define USB_OTG_DTHRCTL_RXTHREN_Msk (0x1UL << USB_OTG_DTHRCTL_RXTHREN_Pos) /*!< 0x00010000 */ -#define USB_OTG_DTHRCTL_RXTHREN USB_OTG_DTHRCTL_RXTHREN_Msk /*!< Receive threshold enable */ - -#define USB_OTG_DTHRCTL_RXTHRLEN_Pos (17U) -#define USB_OTG_DTHRCTL_RXTHRLEN_Msk (0x1FFUL << USB_OTG_DTHRCTL_RXTHRLEN_Pos) /*!< 0x03FE0000 */ -#define USB_OTG_DTHRCTL_RXTHRLEN USB_OTG_DTHRCTL_RXTHRLEN_Msk /*!< Receive threshold length */ -#define USB_OTG_DTHRCTL_RXTHRLEN_0 (0x001UL << USB_OTG_DTHRCTL_RXTHRLEN_Pos) /*!< 0x00020000 */ -#define USB_OTG_DTHRCTL_RXTHRLEN_1 (0x002UL << USB_OTG_DTHRCTL_RXTHRLEN_Pos) /*!< 0x00040000 */ -#define USB_OTG_DTHRCTL_RXTHRLEN_2 (0x004UL << USB_OTG_DTHRCTL_RXTHRLEN_Pos) /*!< 0x00080000 */ -#define USB_OTG_DTHRCTL_RXTHRLEN_3 (0x008UL << USB_OTG_DTHRCTL_RXTHRLEN_Pos) /*!< 0x00100000 */ -#define USB_OTG_DTHRCTL_RXTHRLEN_4 (0x010UL << USB_OTG_DTHRCTL_RXTHRLEN_Pos) /*!< 0x00200000 */ -#define USB_OTG_DTHRCTL_RXTHRLEN_5 (0x020UL << USB_OTG_DTHRCTL_RXTHRLEN_Pos) /*!< 0x00400000 */ -#define USB_OTG_DTHRCTL_RXTHRLEN_6 (0x040UL << USB_OTG_DTHRCTL_RXTHRLEN_Pos) /*!< 0x00800000 */ -#define USB_OTG_DTHRCTL_RXTHRLEN_7 (0x080UL << USB_OTG_DTHRCTL_RXTHRLEN_Pos) /*!< 0x01000000 */ -#define USB_OTG_DTHRCTL_RXTHRLEN_8 (0x100UL << USB_OTG_DTHRCTL_RXTHRLEN_Pos) /*!< 0x02000000 */ -#define USB_OTG_DTHRCTL_ARPEN_Pos (27U) -#define USB_OTG_DTHRCTL_ARPEN_Msk (0x1UL << USB_OTG_DTHRCTL_ARPEN_Pos) /*!< 0x08000000 */ -#define USB_OTG_DTHRCTL_ARPEN USB_OTG_DTHRCTL_ARPEN_Msk /*!< Arbiter parking enable */ - -/******************** Bit definition for USB_OTG_DIEPEMPMSK register ********************/ -#define USB_OTG_DIEPEMPMSK_INEPTXFEM_Pos (0U) -#define USB_OTG_DIEPEMPMSK_INEPTXFEM_Msk (0xFFFFUL << USB_OTG_DIEPEMPMSK_INEPTXFEM_Pos) /*!< 0x0000FFFF */ -#define USB_OTG_DIEPEMPMSK_INEPTXFEM USB_OTG_DIEPEMPMSK_INEPTXFEM_Msk /*!< IN EP Tx FIFO empty interrupt mask bits */ - -/******************** Bit definition for USB_OTG_DEACHINT register ********************/ -#define USB_OTG_DEACHINT_IEP1INT_Pos (1U) -#define USB_OTG_DEACHINT_IEP1INT_Msk (0x1UL << USB_OTG_DEACHINT_IEP1INT_Pos) /*!< 0x00000002 */ -#define USB_OTG_DEACHINT_IEP1INT USB_OTG_DEACHINT_IEP1INT_Msk /*!< IN endpoint 1interrupt bit */ -#define USB_OTG_DEACHINT_OEP1INT_Pos (17U) -#define USB_OTG_DEACHINT_OEP1INT_Msk (0x1UL << USB_OTG_DEACHINT_OEP1INT_Pos) /*!< 0x00020000 */ -#define USB_OTG_DEACHINT_OEP1INT USB_OTG_DEACHINT_OEP1INT_Msk /*!< OUT endpoint 1 interrupt bit */ - -/******************** Bit definition for USB_OTG_GCCFG register ********************/ -#define USB_OTG_GCCFG_PWRDWN_Pos (16U) -#define USB_OTG_GCCFG_PWRDWN_Msk (0x1UL << USB_OTG_GCCFG_PWRDWN_Pos) /*!< 0x00010000 */ -#define USB_OTG_GCCFG_PWRDWN USB_OTG_GCCFG_PWRDWN_Msk /*!< Power down */ -#define USB_OTG_GCCFG_VBUSASEN_Pos (18U) -#define USB_OTG_GCCFG_VBUSASEN_Msk (0x1UL << USB_OTG_GCCFG_VBUSASEN_Pos) /*!< 0x00040000 */ -#define USB_OTG_GCCFG_VBUSASEN USB_OTG_GCCFG_VBUSASEN_Msk /*!< Enable the VBUS sensing device */ -#define USB_OTG_GCCFG_VBUSBSEN_Pos (19U) -#define USB_OTG_GCCFG_VBUSBSEN_Msk (0x1UL << USB_OTG_GCCFG_VBUSBSEN_Pos) /*!< 0x00080000 */ -#define USB_OTG_GCCFG_VBUSBSEN USB_OTG_GCCFG_VBUSBSEN_Msk /*!< Enable the VBUS sensing device */ -#define USB_OTG_GCCFG_SOFOUTEN_Pos (20U) -#define USB_OTG_GCCFG_SOFOUTEN_Msk (0x1UL << USB_OTG_GCCFG_SOFOUTEN_Pos) /*!< 0x00100000 */ -#define USB_OTG_GCCFG_SOFOUTEN USB_OTG_GCCFG_SOFOUTEN_Msk /*!< SOF output enable */ - -/******************** Bit definition for USB_OTG_DEACHINTMSK register ********************/ -#define USB_OTG_DEACHINTMSK_IEP1INTM_Pos (1U) -#define USB_OTG_DEACHINTMSK_IEP1INTM_Msk (0x1UL << USB_OTG_DEACHINTMSK_IEP1INTM_Pos) /*!< 0x00000002 */ -#define USB_OTG_DEACHINTMSK_IEP1INTM USB_OTG_DEACHINTMSK_IEP1INTM_Msk /*!< IN Endpoint 1 interrupt mask bit */ -#define USB_OTG_DEACHINTMSK_OEP1INTM_Pos (17U) -#define USB_OTG_DEACHINTMSK_OEP1INTM_Msk (0x1UL << USB_OTG_DEACHINTMSK_OEP1INTM_Pos) /*!< 0x00020000 */ -#define USB_OTG_DEACHINTMSK_OEP1INTM USB_OTG_DEACHINTMSK_OEP1INTM_Msk /*!< OUT Endpoint 1 interrupt mask bit */ - -/******************** Bit definition for USB_OTG_CID register ********************/ -#define USB_OTG_CID_PRODUCT_ID_Pos (0U) -#define USB_OTG_CID_PRODUCT_ID_Msk (0xFFFFFFFFUL << USB_OTG_CID_PRODUCT_ID_Pos) /*!< 0xFFFFFFFF */ -#define USB_OTG_CID_PRODUCT_ID USB_OTG_CID_PRODUCT_ID_Msk /*!< Product ID field */ - -/******************** Bit definition for USB_OTG_DIEPEACHMSK1 register ********************/ -#define USB_OTG_DIEPEACHMSK1_XFRCM_Pos (0U) -#define USB_OTG_DIEPEACHMSK1_XFRCM_Msk (0x1UL << USB_OTG_DIEPEACHMSK1_XFRCM_Pos) /*!< 0x00000001 */ -#define USB_OTG_DIEPEACHMSK1_XFRCM USB_OTG_DIEPEACHMSK1_XFRCM_Msk /*!< Transfer completed interrupt mask */ -#define USB_OTG_DIEPEACHMSK1_EPDM_Pos (1U) -#define USB_OTG_DIEPEACHMSK1_EPDM_Msk (0x1UL << USB_OTG_DIEPEACHMSK1_EPDM_Pos) /*!< 0x00000002 */ -#define USB_OTG_DIEPEACHMSK1_EPDM USB_OTG_DIEPEACHMSK1_EPDM_Msk /*!< Endpoint disabled interrupt mask */ -#define USB_OTG_DIEPEACHMSK1_TOM_Pos (3U) -#define USB_OTG_DIEPEACHMSK1_TOM_Msk (0x1UL << USB_OTG_DIEPEACHMSK1_TOM_Pos) /*!< 0x00000008 */ -#define USB_OTG_DIEPEACHMSK1_TOM USB_OTG_DIEPEACHMSK1_TOM_Msk /*!< Timeout condition mask (nonisochronous endpoints) */ -#define USB_OTG_DIEPEACHMSK1_ITTXFEMSK_Pos (4U) -#define USB_OTG_DIEPEACHMSK1_ITTXFEMSK_Msk (0x1UL << USB_OTG_DIEPEACHMSK1_ITTXFEMSK_Pos) /*!< 0x00000010 */ -#define USB_OTG_DIEPEACHMSK1_ITTXFEMSK USB_OTG_DIEPEACHMSK1_ITTXFEMSK_Msk /*!< IN token received when TxFIFO empty mask */ -#define USB_OTG_DIEPEACHMSK1_INEPNMM_Pos (5U) -#define USB_OTG_DIEPEACHMSK1_INEPNMM_Msk (0x1UL << USB_OTG_DIEPEACHMSK1_INEPNMM_Pos) /*!< 0x00000020 */ -#define USB_OTG_DIEPEACHMSK1_INEPNMM USB_OTG_DIEPEACHMSK1_INEPNMM_Msk /*!< IN token received with EP mismatch mask */ -#define USB_OTG_DIEPEACHMSK1_INEPNEM_Pos (6U) -#define USB_OTG_DIEPEACHMSK1_INEPNEM_Msk (0x1UL << USB_OTG_DIEPEACHMSK1_INEPNEM_Pos) /*!< 0x00000040 */ -#define USB_OTG_DIEPEACHMSK1_INEPNEM USB_OTG_DIEPEACHMSK1_INEPNEM_Msk /*!< IN endpoint NAK effective mask */ -#define USB_OTG_DIEPEACHMSK1_TXFURM_Pos (8U) -#define USB_OTG_DIEPEACHMSK1_TXFURM_Msk (0x1UL << USB_OTG_DIEPEACHMSK1_TXFURM_Pos) /*!< 0x00000100 */ -#define USB_OTG_DIEPEACHMSK1_TXFURM USB_OTG_DIEPEACHMSK1_TXFURM_Msk /*!< FIFO underrun mask */ -#define USB_OTG_DIEPEACHMSK1_BIM_Pos (9U) -#define USB_OTG_DIEPEACHMSK1_BIM_Msk (0x1UL << USB_OTG_DIEPEACHMSK1_BIM_Pos) /*!< 0x00000200 */ -#define USB_OTG_DIEPEACHMSK1_BIM USB_OTG_DIEPEACHMSK1_BIM_Msk /*!< BNA interrupt mask */ -#define USB_OTG_DIEPEACHMSK1_NAKM_Pos (13U) -#define USB_OTG_DIEPEACHMSK1_NAKM_Msk (0x1UL << USB_OTG_DIEPEACHMSK1_NAKM_Pos) /*!< 0x00002000 */ -#define USB_OTG_DIEPEACHMSK1_NAKM USB_OTG_DIEPEACHMSK1_NAKM_Msk /*!< NAK interrupt mask */ - -/******************** Bit definition for USB_OTG_HPRT register ********************/ -#define USB_OTG_HPRT_PCSTS_Pos (0U) -#define USB_OTG_HPRT_PCSTS_Msk (0x1UL << USB_OTG_HPRT_PCSTS_Pos) /*!< 0x00000001 */ -#define USB_OTG_HPRT_PCSTS USB_OTG_HPRT_PCSTS_Msk /*!< Port connect status */ -#define USB_OTG_HPRT_PCDET_Pos (1U) -#define USB_OTG_HPRT_PCDET_Msk (0x1UL << USB_OTG_HPRT_PCDET_Pos) /*!< 0x00000002 */ -#define USB_OTG_HPRT_PCDET USB_OTG_HPRT_PCDET_Msk /*!< Port connect detected */ -#define USB_OTG_HPRT_PENA_Pos (2U) -#define USB_OTG_HPRT_PENA_Msk (0x1UL << USB_OTG_HPRT_PENA_Pos) /*!< 0x00000004 */ -#define USB_OTG_HPRT_PENA USB_OTG_HPRT_PENA_Msk /*!< Port enable */ -#define USB_OTG_HPRT_PENCHNG_Pos (3U) -#define USB_OTG_HPRT_PENCHNG_Msk (0x1UL << USB_OTG_HPRT_PENCHNG_Pos) /*!< 0x00000008 */ -#define USB_OTG_HPRT_PENCHNG USB_OTG_HPRT_PENCHNG_Msk /*!< Port enable/disable change */ -#define USB_OTG_HPRT_POCA_Pos (4U) -#define USB_OTG_HPRT_POCA_Msk (0x1UL << USB_OTG_HPRT_POCA_Pos) /*!< 0x00000010 */ -#define USB_OTG_HPRT_POCA USB_OTG_HPRT_POCA_Msk /*!< Port overcurrent active */ -#define USB_OTG_HPRT_POCCHNG_Pos (5U) -#define USB_OTG_HPRT_POCCHNG_Msk (0x1UL << USB_OTG_HPRT_POCCHNG_Pos) /*!< 0x00000020 */ -#define USB_OTG_HPRT_POCCHNG USB_OTG_HPRT_POCCHNG_Msk /*!< Port overcurrent change */ -#define USB_OTG_HPRT_PRES_Pos (6U) -#define USB_OTG_HPRT_PRES_Msk (0x1UL << USB_OTG_HPRT_PRES_Pos) /*!< 0x00000040 */ -#define USB_OTG_HPRT_PRES USB_OTG_HPRT_PRES_Msk /*!< Port resume */ -#define USB_OTG_HPRT_PSUSP_Pos (7U) -#define USB_OTG_HPRT_PSUSP_Msk (0x1UL << USB_OTG_HPRT_PSUSP_Pos) /*!< 0x00000080 */ -#define USB_OTG_HPRT_PSUSP USB_OTG_HPRT_PSUSP_Msk /*!< Port suspend */ -#define USB_OTG_HPRT_PRST_Pos (8U) -#define USB_OTG_HPRT_PRST_Msk (0x1UL << USB_OTG_HPRT_PRST_Pos) /*!< 0x00000100 */ -#define USB_OTG_HPRT_PRST USB_OTG_HPRT_PRST_Msk /*!< Port reset */ - -#define USB_OTG_HPRT_PLSTS_Pos (10U) -#define USB_OTG_HPRT_PLSTS_Msk (0x3UL << USB_OTG_HPRT_PLSTS_Pos) /*!< 0x00000C00 */ -#define USB_OTG_HPRT_PLSTS USB_OTG_HPRT_PLSTS_Msk /*!< Port line status */ -#define USB_OTG_HPRT_PLSTS_0 (0x1UL << USB_OTG_HPRT_PLSTS_Pos) /*!< 0x00000400 */ -#define USB_OTG_HPRT_PLSTS_1 (0x2UL << USB_OTG_HPRT_PLSTS_Pos) /*!< 0x00000800 */ -#define USB_OTG_HPRT_PPWR_Pos (12U) -#define USB_OTG_HPRT_PPWR_Msk (0x1UL << USB_OTG_HPRT_PPWR_Pos) /*!< 0x00001000 */ -#define USB_OTG_HPRT_PPWR USB_OTG_HPRT_PPWR_Msk /*!< Port power */ - -#define USB_OTG_HPRT_PTCTL_Pos (13U) -#define USB_OTG_HPRT_PTCTL_Msk (0xFUL << USB_OTG_HPRT_PTCTL_Pos) /*!< 0x0001E000 */ -#define USB_OTG_HPRT_PTCTL USB_OTG_HPRT_PTCTL_Msk /*!< Port test control */ -#define USB_OTG_HPRT_PTCTL_0 (0x1UL << USB_OTG_HPRT_PTCTL_Pos) /*!< 0x00002000 */ -#define USB_OTG_HPRT_PTCTL_1 (0x2UL << USB_OTG_HPRT_PTCTL_Pos) /*!< 0x00004000 */ -#define USB_OTG_HPRT_PTCTL_2 (0x4UL << USB_OTG_HPRT_PTCTL_Pos) /*!< 0x00008000 */ -#define USB_OTG_HPRT_PTCTL_3 (0x8UL << USB_OTG_HPRT_PTCTL_Pos) /*!< 0x00010000 */ - -#define USB_OTG_HPRT_PSPD_Pos (17U) -#define USB_OTG_HPRT_PSPD_Msk (0x3UL << USB_OTG_HPRT_PSPD_Pos) /*!< 0x00060000 */ -#define USB_OTG_HPRT_PSPD USB_OTG_HPRT_PSPD_Msk /*!< Port speed */ -#define USB_OTG_HPRT_PSPD_0 (0x1UL << USB_OTG_HPRT_PSPD_Pos) /*!< 0x00020000 */ -#define USB_OTG_HPRT_PSPD_1 (0x2UL << USB_OTG_HPRT_PSPD_Pos) /*!< 0x00040000 */ - -/******************** Bit definition for USB_OTG_DOEPEACHMSK1 register ********************/ -#define USB_OTG_DOEPEACHMSK1_XFRCM_Pos (0U) -#define USB_OTG_DOEPEACHMSK1_XFRCM_Msk (0x1UL << USB_OTG_DOEPEACHMSK1_XFRCM_Pos) /*!< 0x00000001 */ -#define USB_OTG_DOEPEACHMSK1_XFRCM USB_OTG_DOEPEACHMSK1_XFRCM_Msk /*!< Transfer completed interrupt mask */ -#define USB_OTG_DOEPEACHMSK1_EPDM_Pos (1U) -#define USB_OTG_DOEPEACHMSK1_EPDM_Msk (0x1UL << USB_OTG_DOEPEACHMSK1_EPDM_Pos) /*!< 0x00000002 */ -#define USB_OTG_DOEPEACHMSK1_EPDM USB_OTG_DOEPEACHMSK1_EPDM_Msk /*!< Endpoint disabled interrupt mask */ -#define USB_OTG_DOEPEACHMSK1_TOM_Pos (3U) -#define USB_OTG_DOEPEACHMSK1_TOM_Msk (0x1UL << USB_OTG_DOEPEACHMSK1_TOM_Pos) /*!< 0x00000008 */ -#define USB_OTG_DOEPEACHMSK1_TOM USB_OTG_DOEPEACHMSK1_TOM_Msk /*!< Timeout condition mask */ -#define USB_OTG_DOEPEACHMSK1_ITTXFEMSK_Pos (4U) -#define USB_OTG_DOEPEACHMSK1_ITTXFEMSK_Msk (0x1UL << USB_OTG_DOEPEACHMSK1_ITTXFEMSK_Pos) /*!< 0x00000010 */ -#define USB_OTG_DOEPEACHMSK1_ITTXFEMSK USB_OTG_DOEPEACHMSK1_ITTXFEMSK_Msk /*!< IN token received when TxFIFO empty mask */ -#define USB_OTG_DOEPEACHMSK1_INEPNMM_Pos (5U) -#define USB_OTG_DOEPEACHMSK1_INEPNMM_Msk (0x1UL << USB_OTG_DOEPEACHMSK1_INEPNMM_Pos) /*!< 0x00000020 */ -#define USB_OTG_DOEPEACHMSK1_INEPNMM USB_OTG_DOEPEACHMSK1_INEPNMM_Msk /*!< IN token received with EP mismatch mask */ -#define USB_OTG_DOEPEACHMSK1_INEPNEM_Pos (6U) -#define USB_OTG_DOEPEACHMSK1_INEPNEM_Msk (0x1UL << USB_OTG_DOEPEACHMSK1_INEPNEM_Pos) /*!< 0x00000040 */ -#define USB_OTG_DOEPEACHMSK1_INEPNEM USB_OTG_DOEPEACHMSK1_INEPNEM_Msk /*!< IN endpoint NAK effective mask */ -#define USB_OTG_DOEPEACHMSK1_TXFURM_Pos (8U) -#define USB_OTG_DOEPEACHMSK1_TXFURM_Msk (0x1UL << USB_OTG_DOEPEACHMSK1_TXFURM_Pos) /*!< 0x00000100 */ -#define USB_OTG_DOEPEACHMSK1_TXFURM USB_OTG_DOEPEACHMSK1_TXFURM_Msk /*!< OUT packet error mask */ -#define USB_OTG_DOEPEACHMSK1_BIM_Pos (9U) -#define USB_OTG_DOEPEACHMSK1_BIM_Msk (0x1UL << USB_OTG_DOEPEACHMSK1_BIM_Pos) /*!< 0x00000200 */ -#define USB_OTG_DOEPEACHMSK1_BIM USB_OTG_DOEPEACHMSK1_BIM_Msk /*!< BNA interrupt mask */ -#define USB_OTG_DOEPEACHMSK1_BERRM_Pos (12U) -#define USB_OTG_DOEPEACHMSK1_BERRM_Msk (0x1UL << USB_OTG_DOEPEACHMSK1_BERRM_Pos) /*!< 0x00001000 */ -#define USB_OTG_DOEPEACHMSK1_BERRM USB_OTG_DOEPEACHMSK1_BERRM_Msk /*!< Bubble error interrupt mask */ -#define USB_OTG_DOEPEACHMSK1_NAKM_Pos (13U) -#define USB_OTG_DOEPEACHMSK1_NAKM_Msk (0x1UL << USB_OTG_DOEPEACHMSK1_NAKM_Pos) /*!< 0x00002000 */ -#define USB_OTG_DOEPEACHMSK1_NAKM USB_OTG_DOEPEACHMSK1_NAKM_Msk /*!< NAK interrupt mask */ -#define USB_OTG_DOEPEACHMSK1_NYETM_Pos (14U) -#define USB_OTG_DOEPEACHMSK1_NYETM_Msk (0x1UL << USB_OTG_DOEPEACHMSK1_NYETM_Pos) /*!< 0x00004000 */ -#define USB_OTG_DOEPEACHMSK1_NYETM USB_OTG_DOEPEACHMSK1_NYETM_Msk /*!< NYET interrupt mask */ - -/******************** Bit definition for USB_OTG_HPTXFSIZ register ********************/ -#define USB_OTG_HPTXFSIZ_PTXSA_Pos (0U) -#define USB_OTG_HPTXFSIZ_PTXSA_Msk (0xFFFFUL << USB_OTG_HPTXFSIZ_PTXSA_Pos) /*!< 0x0000FFFF */ -#define USB_OTG_HPTXFSIZ_PTXSA USB_OTG_HPTXFSIZ_PTXSA_Msk /*!< Host periodic TxFIFO start address */ -#define USB_OTG_HPTXFSIZ_PTXFD_Pos (16U) -#define USB_OTG_HPTXFSIZ_PTXFD_Msk (0xFFFFUL << USB_OTG_HPTXFSIZ_PTXFD_Pos) /*!< 0xFFFF0000 */ -#define USB_OTG_HPTXFSIZ_PTXFD USB_OTG_HPTXFSIZ_PTXFD_Msk /*!< Host periodic TxFIFO depth */ - -/******************** Bit definition for USB_OTG_DIEPCTL register ********************/ -#define USB_OTG_DIEPCTL_MPSIZ_Pos (0U) -#define USB_OTG_DIEPCTL_MPSIZ_Msk (0x7FFUL << USB_OTG_DIEPCTL_MPSIZ_Pos) /*!< 0x000007FF */ -#define USB_OTG_DIEPCTL_MPSIZ USB_OTG_DIEPCTL_MPSIZ_Msk /*!< Maximum packet size */ -#define USB_OTG_DIEPCTL_USBAEP_Pos (15U) -#define USB_OTG_DIEPCTL_USBAEP_Msk (0x1UL << USB_OTG_DIEPCTL_USBAEP_Pos) /*!< 0x00008000 */ -#define USB_OTG_DIEPCTL_USBAEP USB_OTG_DIEPCTL_USBAEP_Msk /*!< USB active endpoint */ -#define USB_OTG_DIEPCTL_EONUM_DPID_Pos (16U) -#define USB_OTG_DIEPCTL_EONUM_DPID_Msk (0x1UL << USB_OTG_DIEPCTL_EONUM_DPID_Pos) /*!< 0x00010000 */ -#define USB_OTG_DIEPCTL_EONUM_DPID USB_OTG_DIEPCTL_EONUM_DPID_Msk /*!< Even/odd frame */ -#define USB_OTG_DIEPCTL_NAKSTS_Pos (17U) -#define USB_OTG_DIEPCTL_NAKSTS_Msk (0x1UL << USB_OTG_DIEPCTL_NAKSTS_Pos) /*!< 0x00020000 */ -#define USB_OTG_DIEPCTL_NAKSTS USB_OTG_DIEPCTL_NAKSTS_Msk /*!< NAK status */ - -#define USB_OTG_DIEPCTL_EPTYP_Pos (18U) -#define USB_OTG_DIEPCTL_EPTYP_Msk (0x3UL << USB_OTG_DIEPCTL_EPTYP_Pos) /*!< 0x000C0000 */ -#define USB_OTG_DIEPCTL_EPTYP USB_OTG_DIEPCTL_EPTYP_Msk /*!< Endpoint type */ -#define USB_OTG_DIEPCTL_EPTYP_0 (0x1UL << USB_OTG_DIEPCTL_EPTYP_Pos) /*!< 0x00040000 */ -#define USB_OTG_DIEPCTL_EPTYP_1 (0x2UL << USB_OTG_DIEPCTL_EPTYP_Pos) /*!< 0x00080000 */ -#define USB_OTG_DIEPCTL_STALL_Pos (21U) -#define USB_OTG_DIEPCTL_STALL_Msk (0x1UL << USB_OTG_DIEPCTL_STALL_Pos) /*!< 0x00200000 */ -#define USB_OTG_DIEPCTL_STALL USB_OTG_DIEPCTL_STALL_Msk /*!< STALL handshake */ - -#define USB_OTG_DIEPCTL_TXFNUM_Pos (22U) -#define USB_OTG_DIEPCTL_TXFNUM_Msk (0xFUL << USB_OTG_DIEPCTL_TXFNUM_Pos) /*!< 0x03C00000 */ -#define USB_OTG_DIEPCTL_TXFNUM USB_OTG_DIEPCTL_TXFNUM_Msk /*!< TxFIFO number */ -#define USB_OTG_DIEPCTL_TXFNUM_0 (0x1UL << USB_OTG_DIEPCTL_TXFNUM_Pos) /*!< 0x00400000 */ -#define USB_OTG_DIEPCTL_TXFNUM_1 (0x2UL << USB_OTG_DIEPCTL_TXFNUM_Pos) /*!< 0x00800000 */ -#define USB_OTG_DIEPCTL_TXFNUM_2 (0x4UL << USB_OTG_DIEPCTL_TXFNUM_Pos) /*!< 0x01000000 */ -#define USB_OTG_DIEPCTL_TXFNUM_3 (0x8UL << USB_OTG_DIEPCTL_TXFNUM_Pos) /*!< 0x02000000 */ -#define USB_OTG_DIEPCTL_CNAK_Pos (26U) -#define USB_OTG_DIEPCTL_CNAK_Msk (0x1UL << USB_OTG_DIEPCTL_CNAK_Pos) /*!< 0x04000000 */ -#define USB_OTG_DIEPCTL_CNAK USB_OTG_DIEPCTL_CNAK_Msk /*!< Clear NAK */ -#define USB_OTG_DIEPCTL_SNAK_Pos (27U) -#define USB_OTG_DIEPCTL_SNAK_Msk (0x1UL << USB_OTG_DIEPCTL_SNAK_Pos) /*!< 0x08000000 */ -#define USB_OTG_DIEPCTL_SNAK USB_OTG_DIEPCTL_SNAK_Msk /*!< Set NAK */ -#define USB_OTG_DIEPCTL_SD0PID_SEVNFRM_Pos (28U) -#define USB_OTG_DIEPCTL_SD0PID_SEVNFRM_Msk (0x1UL << USB_OTG_DIEPCTL_SD0PID_SEVNFRM_Pos) /*!< 0x10000000 */ -#define USB_OTG_DIEPCTL_SD0PID_SEVNFRM USB_OTG_DIEPCTL_SD0PID_SEVNFRM_Msk /*!< Set DATA0 PID */ -#define USB_OTG_DIEPCTL_SODDFRM_Pos (29U) -#define USB_OTG_DIEPCTL_SODDFRM_Msk (0x1UL << USB_OTG_DIEPCTL_SODDFRM_Pos) /*!< 0x20000000 */ -#define USB_OTG_DIEPCTL_SODDFRM USB_OTG_DIEPCTL_SODDFRM_Msk /*!< Set odd frame */ -#define USB_OTG_DIEPCTL_EPDIS_Pos (30U) -#define USB_OTG_DIEPCTL_EPDIS_Msk (0x1UL << USB_OTG_DIEPCTL_EPDIS_Pos) /*!< 0x40000000 */ -#define USB_OTG_DIEPCTL_EPDIS USB_OTG_DIEPCTL_EPDIS_Msk /*!< Endpoint disable */ -#define USB_OTG_DIEPCTL_EPENA_Pos (31U) -#define USB_OTG_DIEPCTL_EPENA_Msk (0x1UL << USB_OTG_DIEPCTL_EPENA_Pos) /*!< 0x80000000 */ -#define USB_OTG_DIEPCTL_EPENA USB_OTG_DIEPCTL_EPENA_Msk /*!< Endpoint enable */ - -/******************** Bit definition for USB_OTG_HCCHAR register ********************/ -#define USB_OTG_HCCHAR_MPSIZ_Pos (0U) -#define USB_OTG_HCCHAR_MPSIZ_Msk (0x7FFUL << USB_OTG_HCCHAR_MPSIZ_Pos) /*!< 0x000007FF */ -#define USB_OTG_HCCHAR_MPSIZ USB_OTG_HCCHAR_MPSIZ_Msk /*!< Maximum packet size */ - -#define USB_OTG_HCCHAR_EPNUM_Pos (11U) -#define USB_OTG_HCCHAR_EPNUM_Msk (0xFUL << USB_OTG_HCCHAR_EPNUM_Pos) /*!< 0x00007800 */ -#define USB_OTG_HCCHAR_EPNUM USB_OTG_HCCHAR_EPNUM_Msk /*!< Endpoint number */ -#define USB_OTG_HCCHAR_EPNUM_0 (0x1UL << USB_OTG_HCCHAR_EPNUM_Pos) /*!< 0x00000800 */ -#define USB_OTG_HCCHAR_EPNUM_1 (0x2UL << USB_OTG_HCCHAR_EPNUM_Pos) /*!< 0x00001000 */ -#define USB_OTG_HCCHAR_EPNUM_2 (0x4UL << USB_OTG_HCCHAR_EPNUM_Pos) /*!< 0x00002000 */ -#define USB_OTG_HCCHAR_EPNUM_3 (0x8UL << USB_OTG_HCCHAR_EPNUM_Pos) /*!< 0x00004000 */ -#define USB_OTG_HCCHAR_EPDIR_Pos (15U) -#define USB_OTG_HCCHAR_EPDIR_Msk (0x1UL << USB_OTG_HCCHAR_EPDIR_Pos) /*!< 0x00008000 */ -#define USB_OTG_HCCHAR_EPDIR USB_OTG_HCCHAR_EPDIR_Msk /*!< Endpoint direction */ -#define USB_OTG_HCCHAR_LSDEV_Pos (17U) -#define USB_OTG_HCCHAR_LSDEV_Msk (0x1UL << USB_OTG_HCCHAR_LSDEV_Pos) /*!< 0x00020000 */ -#define USB_OTG_HCCHAR_LSDEV USB_OTG_HCCHAR_LSDEV_Msk /*!< Low-speed device */ - -#define USB_OTG_HCCHAR_EPTYP_Pos (18U) -#define USB_OTG_HCCHAR_EPTYP_Msk (0x3UL << USB_OTG_HCCHAR_EPTYP_Pos) /*!< 0x000C0000 */ -#define USB_OTG_HCCHAR_EPTYP USB_OTG_HCCHAR_EPTYP_Msk /*!< Endpoint type */ -#define USB_OTG_HCCHAR_EPTYP_0 (0x1UL << USB_OTG_HCCHAR_EPTYP_Pos) /*!< 0x00040000 */ -#define USB_OTG_HCCHAR_EPTYP_1 (0x2UL << USB_OTG_HCCHAR_EPTYP_Pos) /*!< 0x00080000 */ - -#define USB_OTG_HCCHAR_MC_Pos (20U) -#define USB_OTG_HCCHAR_MC_Msk (0x3UL << USB_OTG_HCCHAR_MC_Pos) /*!< 0x00300000 */ -#define USB_OTG_HCCHAR_MC USB_OTG_HCCHAR_MC_Msk /*!< Multi Count (MC) / Error Count (EC) */ -#define USB_OTG_HCCHAR_MC_0 (0x1UL << USB_OTG_HCCHAR_MC_Pos) /*!< 0x00100000 */ -#define USB_OTG_HCCHAR_MC_1 (0x2UL << USB_OTG_HCCHAR_MC_Pos) /*!< 0x00200000 */ - -#define USB_OTG_HCCHAR_DAD_Pos (22U) -#define USB_OTG_HCCHAR_DAD_Msk (0x7FUL << USB_OTG_HCCHAR_DAD_Pos) /*!< 0x1FC00000 */ -#define USB_OTG_HCCHAR_DAD USB_OTG_HCCHAR_DAD_Msk /*!< Device address */ -#define USB_OTG_HCCHAR_DAD_0 (0x01UL << USB_OTG_HCCHAR_DAD_Pos) /*!< 0x00400000 */ -#define USB_OTG_HCCHAR_DAD_1 (0x02UL << USB_OTG_HCCHAR_DAD_Pos) /*!< 0x00800000 */ -#define USB_OTG_HCCHAR_DAD_2 (0x04UL << USB_OTG_HCCHAR_DAD_Pos) /*!< 0x01000000 */ -#define USB_OTG_HCCHAR_DAD_3 (0x08UL << USB_OTG_HCCHAR_DAD_Pos) /*!< 0x02000000 */ -#define USB_OTG_HCCHAR_DAD_4 (0x10UL << USB_OTG_HCCHAR_DAD_Pos) /*!< 0x04000000 */ -#define USB_OTG_HCCHAR_DAD_5 (0x20UL << USB_OTG_HCCHAR_DAD_Pos) /*!< 0x08000000 */ -#define USB_OTG_HCCHAR_DAD_6 (0x40UL << USB_OTG_HCCHAR_DAD_Pos) /*!< 0x10000000 */ -#define USB_OTG_HCCHAR_ODDFRM_Pos (29U) -#define USB_OTG_HCCHAR_ODDFRM_Msk (0x1UL << USB_OTG_HCCHAR_ODDFRM_Pos) /*!< 0x20000000 */ -#define USB_OTG_HCCHAR_ODDFRM USB_OTG_HCCHAR_ODDFRM_Msk /*!< Odd frame */ -#define USB_OTG_HCCHAR_CHDIS_Pos (30U) -#define USB_OTG_HCCHAR_CHDIS_Msk (0x1UL << USB_OTG_HCCHAR_CHDIS_Pos) /*!< 0x40000000 */ -#define USB_OTG_HCCHAR_CHDIS USB_OTG_HCCHAR_CHDIS_Msk /*!< Channel disable */ -#define USB_OTG_HCCHAR_CHENA_Pos (31U) -#define USB_OTG_HCCHAR_CHENA_Msk (0x1UL << USB_OTG_HCCHAR_CHENA_Pos) /*!< 0x80000000 */ -#define USB_OTG_HCCHAR_CHENA USB_OTG_HCCHAR_CHENA_Msk /*!< Channel enable */ - -/******************** Bit definition for USB_OTG_HCSPLT register ********************/ - -#define USB_OTG_HCSPLT_PRTADDR_Pos (0U) -#define USB_OTG_HCSPLT_PRTADDR_Msk (0x7FUL << USB_OTG_HCSPLT_PRTADDR_Pos) /*!< 0x0000007F */ -#define USB_OTG_HCSPLT_PRTADDR USB_OTG_HCSPLT_PRTADDR_Msk /*!< Port address */ -#define USB_OTG_HCSPLT_PRTADDR_0 (0x01UL << USB_OTG_HCSPLT_PRTADDR_Pos) /*!< 0x00000001 */ -#define USB_OTG_HCSPLT_PRTADDR_1 (0x02UL << USB_OTG_HCSPLT_PRTADDR_Pos) /*!< 0x00000002 */ -#define USB_OTG_HCSPLT_PRTADDR_2 (0x04UL << USB_OTG_HCSPLT_PRTADDR_Pos) /*!< 0x00000004 */ -#define USB_OTG_HCSPLT_PRTADDR_3 (0x08UL << USB_OTG_HCSPLT_PRTADDR_Pos) /*!< 0x00000008 */ -#define USB_OTG_HCSPLT_PRTADDR_4 (0x10UL << USB_OTG_HCSPLT_PRTADDR_Pos) /*!< 0x00000010 */ -#define USB_OTG_HCSPLT_PRTADDR_5 (0x20UL << USB_OTG_HCSPLT_PRTADDR_Pos) /*!< 0x00000020 */ -#define USB_OTG_HCSPLT_PRTADDR_6 (0x40UL << USB_OTG_HCSPLT_PRTADDR_Pos) /*!< 0x00000040 */ - -#define USB_OTG_HCSPLT_HUBADDR_Pos (7U) -#define USB_OTG_HCSPLT_HUBADDR_Msk (0x7FUL << USB_OTG_HCSPLT_HUBADDR_Pos) /*!< 0x00003F80 */ -#define USB_OTG_HCSPLT_HUBADDR USB_OTG_HCSPLT_HUBADDR_Msk /*!< Hub address */ -#define USB_OTG_HCSPLT_HUBADDR_0 (0x01UL << USB_OTG_HCSPLT_HUBADDR_Pos) /*!< 0x00000080 */ -#define USB_OTG_HCSPLT_HUBADDR_1 (0x02UL << USB_OTG_HCSPLT_HUBADDR_Pos) /*!< 0x00000100 */ -#define USB_OTG_HCSPLT_HUBADDR_2 (0x04UL << USB_OTG_HCSPLT_HUBADDR_Pos) /*!< 0x00000200 */ -#define USB_OTG_HCSPLT_HUBADDR_3 (0x08UL << USB_OTG_HCSPLT_HUBADDR_Pos) /*!< 0x00000400 */ -#define USB_OTG_HCSPLT_HUBADDR_4 (0x10UL << USB_OTG_HCSPLT_HUBADDR_Pos) /*!< 0x00000800 */ -#define USB_OTG_HCSPLT_HUBADDR_5 (0x20UL << USB_OTG_HCSPLT_HUBADDR_Pos) /*!< 0x00001000 */ -#define USB_OTG_HCSPLT_HUBADDR_6 (0x40UL << USB_OTG_HCSPLT_HUBADDR_Pos) /*!< 0x00002000 */ - -#define USB_OTG_HCSPLT_XACTPOS_Pos (14U) -#define USB_OTG_HCSPLT_XACTPOS_Msk (0x3UL << USB_OTG_HCSPLT_XACTPOS_Pos) /*!< 0x0000C000 */ -#define USB_OTG_HCSPLT_XACTPOS USB_OTG_HCSPLT_XACTPOS_Msk /*!< XACTPOS */ -#define USB_OTG_HCSPLT_XACTPOS_0 (0x1UL << USB_OTG_HCSPLT_XACTPOS_Pos) /*!< 0x00004000 */ -#define USB_OTG_HCSPLT_XACTPOS_1 (0x2UL << USB_OTG_HCSPLT_XACTPOS_Pos) /*!< 0x00008000 */ -#define USB_OTG_HCSPLT_COMPLSPLT_Pos (16U) -#define USB_OTG_HCSPLT_COMPLSPLT_Msk (0x1UL << USB_OTG_HCSPLT_COMPLSPLT_Pos) /*!< 0x00010000 */ -#define USB_OTG_HCSPLT_COMPLSPLT USB_OTG_HCSPLT_COMPLSPLT_Msk /*!< Do complete split */ -#define USB_OTG_HCSPLT_SPLITEN_Pos (31U) -#define USB_OTG_HCSPLT_SPLITEN_Msk (0x1UL << USB_OTG_HCSPLT_SPLITEN_Pos) /*!< 0x80000000 */ -#define USB_OTG_HCSPLT_SPLITEN USB_OTG_HCSPLT_SPLITEN_Msk /*!< Split enable */ - -/******************** Bit definition for USB_OTG_HCINT register ********************/ -#define USB_OTG_HCINT_XFRC_Pos (0U) -#define USB_OTG_HCINT_XFRC_Msk (0x1UL << USB_OTG_HCINT_XFRC_Pos) /*!< 0x00000001 */ -#define USB_OTG_HCINT_XFRC USB_OTG_HCINT_XFRC_Msk /*!< Transfer completed */ -#define USB_OTG_HCINT_CHH_Pos (1U) -#define USB_OTG_HCINT_CHH_Msk (0x1UL << USB_OTG_HCINT_CHH_Pos) /*!< 0x00000002 */ -#define USB_OTG_HCINT_CHH USB_OTG_HCINT_CHH_Msk /*!< Channel halted */ -#define USB_OTG_HCINT_AHBERR_Pos (2U) -#define USB_OTG_HCINT_AHBERR_Msk (0x1UL << USB_OTG_HCINT_AHBERR_Pos) /*!< 0x00000004 */ -#define USB_OTG_HCINT_AHBERR USB_OTG_HCINT_AHBERR_Msk /*!< AHB error */ -#define USB_OTG_HCINT_STALL_Pos (3U) -#define USB_OTG_HCINT_STALL_Msk (0x1UL << USB_OTG_HCINT_STALL_Pos) /*!< 0x00000008 */ -#define USB_OTG_HCINT_STALL USB_OTG_HCINT_STALL_Msk /*!< STALL response received interrupt */ -#define USB_OTG_HCINT_NAK_Pos (4U) -#define USB_OTG_HCINT_NAK_Msk (0x1UL << USB_OTG_HCINT_NAK_Pos) /*!< 0x00000010 */ -#define USB_OTG_HCINT_NAK USB_OTG_HCINT_NAK_Msk /*!< NAK response received interrupt */ -#define USB_OTG_HCINT_ACK_Pos (5U) -#define USB_OTG_HCINT_ACK_Msk (0x1UL << USB_OTG_HCINT_ACK_Pos) /*!< 0x00000020 */ -#define USB_OTG_HCINT_ACK USB_OTG_HCINT_ACK_Msk /*!< ACK response received/transmitted interrupt */ -#define USB_OTG_HCINT_NYET_Pos (6U) -#define USB_OTG_HCINT_NYET_Msk (0x1UL << USB_OTG_HCINT_NYET_Pos) /*!< 0x00000040 */ -#define USB_OTG_HCINT_NYET USB_OTG_HCINT_NYET_Msk /*!< Response received interrupt */ -#define USB_OTG_HCINT_TXERR_Pos (7U) -#define USB_OTG_HCINT_TXERR_Msk (0x1UL << USB_OTG_HCINT_TXERR_Pos) /*!< 0x00000080 */ -#define USB_OTG_HCINT_TXERR USB_OTG_HCINT_TXERR_Msk /*!< Transaction error */ -#define USB_OTG_HCINT_BBERR_Pos (8U) -#define USB_OTG_HCINT_BBERR_Msk (0x1UL << USB_OTG_HCINT_BBERR_Pos) /*!< 0x00000100 */ -#define USB_OTG_HCINT_BBERR USB_OTG_HCINT_BBERR_Msk /*!< Babble error */ -#define USB_OTG_HCINT_FRMOR_Pos (9U) -#define USB_OTG_HCINT_FRMOR_Msk (0x1UL << USB_OTG_HCINT_FRMOR_Pos) /*!< 0x00000200 */ -#define USB_OTG_HCINT_FRMOR USB_OTG_HCINT_FRMOR_Msk /*!< Frame overrun */ -#define USB_OTG_HCINT_DTERR_Pos (10U) -#define USB_OTG_HCINT_DTERR_Msk (0x1UL << USB_OTG_HCINT_DTERR_Pos) /*!< 0x00000400 */ -#define USB_OTG_HCINT_DTERR USB_OTG_HCINT_DTERR_Msk /*!< Data toggle error */ - -/******************** Bit definition for USB_OTG_DIEPINT register ********************/ -#define USB_OTG_DIEPINT_XFRC_Pos (0U) -#define USB_OTG_DIEPINT_XFRC_Msk (0x1UL << USB_OTG_DIEPINT_XFRC_Pos) /*!< 0x00000001 */ -#define USB_OTG_DIEPINT_XFRC USB_OTG_DIEPINT_XFRC_Msk /*!< Transfer completed interrupt */ -#define USB_OTG_DIEPINT_EPDISD_Pos (1U) -#define USB_OTG_DIEPINT_EPDISD_Msk (0x1UL << USB_OTG_DIEPINT_EPDISD_Pos) /*!< 0x00000002 */ -#define USB_OTG_DIEPINT_EPDISD USB_OTG_DIEPINT_EPDISD_Msk /*!< Endpoint disabled interrupt */ -#define USB_OTG_DIEPINT_AHBERR_Pos (2U) -#define USB_OTG_DIEPINT_AHBERR_Msk (0x1UL << USB_OTG_DIEPINT_AHBERR_Pos) /*!< 0x00000004 */ -#define USB_OTG_DIEPINT_AHBERR USB_OTG_DIEPINT_AHBERR_Msk /*!< AHB Error (AHBErr) during an IN transaction */ -#define USB_OTG_DIEPINT_TOC_Pos (3U) -#define USB_OTG_DIEPINT_TOC_Msk (0x1UL << USB_OTG_DIEPINT_TOC_Pos) /*!< 0x00000008 */ -#define USB_OTG_DIEPINT_TOC USB_OTG_DIEPINT_TOC_Msk /*!< Timeout condition */ -#define USB_OTG_DIEPINT_ITTXFE_Pos (4U) -#define USB_OTG_DIEPINT_ITTXFE_Msk (0x1UL << USB_OTG_DIEPINT_ITTXFE_Pos) /*!< 0x00000010 */ -#define USB_OTG_DIEPINT_ITTXFE USB_OTG_DIEPINT_ITTXFE_Msk /*!< IN token received when TxFIFO is empty */ -#define USB_OTG_DIEPINT_INEPNM_Pos (5U) -#define USB_OTG_DIEPINT_INEPNM_Msk (0x1UL << USB_OTG_DIEPINT_INEPNM_Pos) /*!< 0x00000004 */ -#define USB_OTG_DIEPINT_INEPNM USB_OTG_DIEPINT_INEPNM_Msk /*!< IN token received with EP mismatch */ -#define USB_OTG_DIEPINT_INEPNE_Pos (6U) -#define USB_OTG_DIEPINT_INEPNE_Msk (0x1UL << USB_OTG_DIEPINT_INEPNE_Pos) /*!< 0x00000040 */ -#define USB_OTG_DIEPINT_INEPNE USB_OTG_DIEPINT_INEPNE_Msk /*!< IN endpoint NAK effective */ -#define USB_OTG_DIEPINT_TXFE_Pos (7U) -#define USB_OTG_DIEPINT_TXFE_Msk (0x1UL << USB_OTG_DIEPINT_TXFE_Pos) /*!< 0x00000080 */ -#define USB_OTG_DIEPINT_TXFE USB_OTG_DIEPINT_TXFE_Msk /*!< Transmit FIFO empty */ -#define USB_OTG_DIEPINT_TXFIFOUDRN_Pos (8U) -#define USB_OTG_DIEPINT_TXFIFOUDRN_Msk (0x1UL << USB_OTG_DIEPINT_TXFIFOUDRN_Pos) /*!< 0x00000100 */ -#define USB_OTG_DIEPINT_TXFIFOUDRN USB_OTG_DIEPINT_TXFIFOUDRN_Msk /*!< Transmit Fifo Underrun */ -#define USB_OTG_DIEPINT_BNA_Pos (9U) -#define USB_OTG_DIEPINT_BNA_Msk (0x1UL << USB_OTG_DIEPINT_BNA_Pos) /*!< 0x00000200 */ -#define USB_OTG_DIEPINT_BNA USB_OTG_DIEPINT_BNA_Msk /*!< Buffer not available interrupt */ -#define USB_OTG_DIEPINT_PKTDRPSTS_Pos (11U) -#define USB_OTG_DIEPINT_PKTDRPSTS_Msk (0x1UL << USB_OTG_DIEPINT_PKTDRPSTS_Pos) /*!< 0x00000800 */ -#define USB_OTG_DIEPINT_PKTDRPSTS USB_OTG_DIEPINT_PKTDRPSTS_Msk /*!< Packet dropped status */ -#define USB_OTG_DIEPINT_BERR_Pos (12U) -#define USB_OTG_DIEPINT_BERR_Msk (0x1UL << USB_OTG_DIEPINT_BERR_Pos) /*!< 0x00001000 */ -#define USB_OTG_DIEPINT_BERR USB_OTG_DIEPINT_BERR_Msk /*!< Babble error interrupt */ -#define USB_OTG_DIEPINT_NAK_Pos (13U) -#define USB_OTG_DIEPINT_NAK_Msk (0x1UL << USB_OTG_DIEPINT_NAK_Pos) /*!< 0x00002000 */ -#define USB_OTG_DIEPINT_NAK USB_OTG_DIEPINT_NAK_Msk /*!< NAK interrupt */ - -/******************** Bit definition for USB_OTG_HCINTMSK register ********************/ -#define USB_OTG_HCINTMSK_XFRCM_Pos (0U) -#define USB_OTG_HCINTMSK_XFRCM_Msk (0x1UL << USB_OTG_HCINTMSK_XFRCM_Pos) /*!< 0x00000001 */ -#define USB_OTG_HCINTMSK_XFRCM USB_OTG_HCINTMSK_XFRCM_Msk /*!< Transfer completed mask */ -#define USB_OTG_HCINTMSK_CHHM_Pos (1U) -#define USB_OTG_HCINTMSK_CHHM_Msk (0x1UL << USB_OTG_HCINTMSK_CHHM_Pos) /*!< 0x00000002 */ -#define USB_OTG_HCINTMSK_CHHM USB_OTG_HCINTMSK_CHHM_Msk /*!< Channel halted mask */ -#define USB_OTG_HCINTMSK_AHBERR_Pos (2U) -#define USB_OTG_HCINTMSK_AHBERR_Msk (0x1UL << USB_OTG_HCINTMSK_AHBERR_Pos) /*!< 0x00000004 */ -#define USB_OTG_HCINTMSK_AHBERR USB_OTG_HCINTMSK_AHBERR_Msk /*!< AHB error */ -#define USB_OTG_HCINTMSK_STALLM_Pos (3U) -#define USB_OTG_HCINTMSK_STALLM_Msk (0x1UL << USB_OTG_HCINTMSK_STALLM_Pos) /*!< 0x00000008 */ -#define USB_OTG_HCINTMSK_STALLM USB_OTG_HCINTMSK_STALLM_Msk /*!< STALL response received interrupt mask */ -#define USB_OTG_HCINTMSK_NAKM_Pos (4U) -#define USB_OTG_HCINTMSK_NAKM_Msk (0x1UL << USB_OTG_HCINTMSK_NAKM_Pos) /*!< 0x00000010 */ -#define USB_OTG_HCINTMSK_NAKM USB_OTG_HCINTMSK_NAKM_Msk /*!< NAK response received interrupt mask */ -#define USB_OTG_HCINTMSK_ACKM_Pos (5U) -#define USB_OTG_HCINTMSK_ACKM_Msk (0x1UL << USB_OTG_HCINTMSK_ACKM_Pos) /*!< 0x00000020 */ -#define USB_OTG_HCINTMSK_ACKM USB_OTG_HCINTMSK_ACKM_Msk /*!< ACK response received/transmitted interrupt mask */ -#define USB_OTG_HCINTMSK_NYET_Pos (6U) -#define USB_OTG_HCINTMSK_NYET_Msk (0x1UL << USB_OTG_HCINTMSK_NYET_Pos) /*!< 0x00000040 */ -#define USB_OTG_HCINTMSK_NYET USB_OTG_HCINTMSK_NYET_Msk /*!< response received interrupt mask */ -#define USB_OTG_HCINTMSK_TXERRM_Pos (7U) -#define USB_OTG_HCINTMSK_TXERRM_Msk (0x1UL << USB_OTG_HCINTMSK_TXERRM_Pos) /*!< 0x00000080 */ -#define USB_OTG_HCINTMSK_TXERRM USB_OTG_HCINTMSK_TXERRM_Msk /*!< Transaction error mask */ -#define USB_OTG_HCINTMSK_BBERRM_Pos (8U) -#define USB_OTG_HCINTMSK_BBERRM_Msk (0x1UL << USB_OTG_HCINTMSK_BBERRM_Pos) /*!< 0x00000100 */ -#define USB_OTG_HCINTMSK_BBERRM USB_OTG_HCINTMSK_BBERRM_Msk /*!< Babble error mask */ -#define USB_OTG_HCINTMSK_FRMORM_Pos (9U) -#define USB_OTG_HCINTMSK_FRMORM_Msk (0x1UL << USB_OTG_HCINTMSK_FRMORM_Pos) /*!< 0x00000200 */ -#define USB_OTG_HCINTMSK_FRMORM USB_OTG_HCINTMSK_FRMORM_Msk /*!< Frame overrun mask */ -#define USB_OTG_HCINTMSK_DTERRM_Pos (10U) -#define USB_OTG_HCINTMSK_DTERRM_Msk (0x1UL << USB_OTG_HCINTMSK_DTERRM_Pos) /*!< 0x00000400 */ -#define USB_OTG_HCINTMSK_DTERRM USB_OTG_HCINTMSK_DTERRM_Msk /*!< Data toggle error mask */ - -/******************** Bit definition for USB_OTG_DIEPTSIZ register ********************/ - -#define USB_OTG_DIEPTSIZ_XFRSIZ_Pos (0U) -#define USB_OTG_DIEPTSIZ_XFRSIZ_Msk (0x7FFFFUL << USB_OTG_DIEPTSIZ_XFRSIZ_Pos) /*!< 0x0007FFFF */ -#define USB_OTG_DIEPTSIZ_XFRSIZ USB_OTG_DIEPTSIZ_XFRSIZ_Msk /*!< Transfer size */ -#define USB_OTG_DIEPTSIZ_PKTCNT_Pos (19U) -#define USB_OTG_DIEPTSIZ_PKTCNT_Msk (0x3FFUL << USB_OTG_DIEPTSIZ_PKTCNT_Pos) /*!< 0x1FF80000 */ -#define USB_OTG_DIEPTSIZ_PKTCNT USB_OTG_DIEPTSIZ_PKTCNT_Msk /*!< Packet count */ -#define USB_OTG_DIEPTSIZ_MULCNT_Pos (29U) -#define USB_OTG_DIEPTSIZ_MULCNT_Msk (0x3UL << USB_OTG_DIEPTSIZ_MULCNT_Pos) /*!< 0x60000000 */ -#define USB_OTG_DIEPTSIZ_MULCNT USB_OTG_DIEPTSIZ_MULCNT_Msk /*!< Packet count */ -/******************** Bit definition for USB_OTG_HCTSIZ register ********************/ -#define USB_OTG_HCTSIZ_XFRSIZ_Pos (0U) -#define USB_OTG_HCTSIZ_XFRSIZ_Msk (0x7FFFFUL << USB_OTG_HCTSIZ_XFRSIZ_Pos) /*!< 0x0007FFFF */ -#define USB_OTG_HCTSIZ_XFRSIZ USB_OTG_HCTSIZ_XFRSIZ_Msk /*!< Transfer size */ -#define USB_OTG_HCTSIZ_PKTCNT_Pos (19U) -#define USB_OTG_HCTSIZ_PKTCNT_Msk (0x3FFUL << USB_OTG_HCTSIZ_PKTCNT_Pos) /*!< 0x1FF80000 */ -#define USB_OTG_HCTSIZ_PKTCNT USB_OTG_HCTSIZ_PKTCNT_Msk /*!< Packet count */ -#define USB_OTG_HCTSIZ_DOPING_Pos (31U) -#define USB_OTG_HCTSIZ_DOPING_Msk (0x1UL << USB_OTG_HCTSIZ_DOPING_Pos) /*!< 0x80000000 */ -#define USB_OTG_HCTSIZ_DOPING USB_OTG_HCTSIZ_DOPING_Msk /*!< Do PING */ -#define USB_OTG_HCTSIZ_DPID_Pos (29U) -#define USB_OTG_HCTSIZ_DPID_Msk (0x3UL << USB_OTG_HCTSIZ_DPID_Pos) /*!< 0x60000000 */ -#define USB_OTG_HCTSIZ_DPID USB_OTG_HCTSIZ_DPID_Msk /*!< Data PID */ -#define USB_OTG_HCTSIZ_DPID_0 (0x1UL << USB_OTG_HCTSIZ_DPID_Pos) /*!< 0x20000000 */ -#define USB_OTG_HCTSIZ_DPID_1 (0x2UL << USB_OTG_HCTSIZ_DPID_Pos) /*!< 0x40000000 */ - -/******************** Bit definition for USB_OTG_DIEPDMA register ********************/ -#define USB_OTG_DIEPDMA_DMAADDR_Pos (0U) -#define USB_OTG_DIEPDMA_DMAADDR_Msk (0xFFFFFFFFUL << USB_OTG_DIEPDMA_DMAADDR_Pos) /*!< 0xFFFFFFFF */ -#define USB_OTG_DIEPDMA_DMAADDR USB_OTG_DIEPDMA_DMAADDR_Msk /*!< DMA address */ - -/******************** Bit definition for USB_OTG_HCDMA register ********************/ -#define USB_OTG_HCDMA_DMAADDR_Pos (0U) -#define USB_OTG_HCDMA_DMAADDR_Msk (0xFFFFFFFFUL << USB_OTG_HCDMA_DMAADDR_Pos) /*!< 0xFFFFFFFF */ -#define USB_OTG_HCDMA_DMAADDR USB_OTG_HCDMA_DMAADDR_Msk /*!< DMA address */ - -/******************** Bit definition for USB_OTG_DTXFSTS register ********************/ -#define USB_OTG_DTXFSTS_INEPTFSAV_Pos (0U) -#define USB_OTG_DTXFSTS_INEPTFSAV_Msk (0xFFFFUL << USB_OTG_DTXFSTS_INEPTFSAV_Pos) /*!< 0x0000FFFF */ -#define USB_OTG_DTXFSTS_INEPTFSAV USB_OTG_DTXFSTS_INEPTFSAV_Msk /*!< IN endpoint TxFIFO space available */ - -/******************** Bit definition for USB_OTG_DIEPTXF register ********************/ -#define USB_OTG_DIEPTXF_INEPTXSA_Pos (0U) -#define USB_OTG_DIEPTXF_INEPTXSA_Msk (0xFFFFUL << USB_OTG_DIEPTXF_INEPTXSA_Pos) /*!< 0x0000FFFF */ -#define USB_OTG_DIEPTXF_INEPTXSA USB_OTG_DIEPTXF_INEPTXSA_Msk /*!< IN endpoint FIFOx transmit RAM start address */ -#define USB_OTG_DIEPTXF_INEPTXFD_Pos (16U) -#define USB_OTG_DIEPTXF_INEPTXFD_Msk (0xFFFFUL << USB_OTG_DIEPTXF_INEPTXFD_Pos) /*!< 0xFFFF0000 */ -#define USB_OTG_DIEPTXF_INEPTXFD USB_OTG_DIEPTXF_INEPTXFD_Msk /*!< IN endpoint TxFIFO depth */ - -/******************** Bit definition for USB_OTG_DOEPCTL register ********************/ - -#define USB_OTG_DOEPCTL_MPSIZ_Pos (0U) -#define USB_OTG_DOEPCTL_MPSIZ_Msk (0x7FFUL << USB_OTG_DOEPCTL_MPSIZ_Pos) /*!< 0x000007FF */ -#define USB_OTG_DOEPCTL_MPSIZ USB_OTG_DOEPCTL_MPSIZ_Msk /*!< Maximum packet size */ /*!buffer_control; } -static inline void _hw_endpoint_buffer_control_set_value32(struct hw_endpoint *ep, uint32_t value) { + +TU_ATTR_ALWAYS_INLINE static inline void _hw_endpoint_buffer_control_set_value32(struct hw_endpoint *ep, uint32_t value) { return _hw_endpoint_buffer_control_update32(ep, 0, value); } -static inline void _hw_endpoint_buffer_control_set_mask32(struct hw_endpoint *ep, uint32_t value) { + +TU_ATTR_ALWAYS_INLINE static inline void _hw_endpoint_buffer_control_set_mask32(struct hw_endpoint *ep, uint32_t value) { return _hw_endpoint_buffer_control_update32(ep, ~value, value); } -static inline void _hw_endpoint_buffer_control_clear_mask32(struct hw_endpoint *ep, uint32_t value) { + +TU_ATTR_ALWAYS_INLINE static inline void _hw_endpoint_buffer_control_clear_mask32(struct hw_endpoint *ep, uint32_t value) { return _hw_endpoint_buffer_control_update32(ep, ~value, 0); } diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_bcm.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_bcm.h index 14194e7548f..732d96ae09c 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_bcm.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_bcm.h @@ -35,9 +35,12 @@ #include "broadcom/interrupts.h" #include "broadcom/caches.h" -#define DWC2_REG_BASE USB_OTG_GLOBAL_BASE #define DWC2_EP_MAX 8 -#define DWC2_EP_FIFO_SIZE 4096 + +static const dwc2_controller_t _dwc2_controller[] = +{ + { .reg_base = USB_OTG_GLOBAL_BASE, .irqnum = USB_IRQn, .ep_count = DWC2_EP_MAX, .ep_fifo_size = 4096 } +}; #define dcache_clean(_addr, _size) data_clean(_addr, _size) #define dcache_invalidate(_addr, _size) data_invalidate(_addr, _size) @@ -46,15 +49,13 @@ TU_ATTR_ALWAYS_INLINE static inline void dwc2_dcd_int_enable(uint8_t rhport) { - (void) rhport; - BP_EnableIRQ(USB_IRQn); + BP_EnableIRQ(_dwc2_controller[rhport].irqnum); } TU_ATTR_ALWAYS_INLINE static inline void dwc2_dcd_int_disable (uint8_t rhport) { - (void) rhport; - BP_DisableIRQ(USB_IRQn); + BP_DisableIRQ(_dwc2_controller[rhport].irqnum); } static inline void dwc2_remote_wakeup_delay(void) diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_efm32.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_efm32.h index ee4c3c71565..0e3570cbb18 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_efm32.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_efm32.h @@ -37,20 +37,22 @@ // EFM32 has custom control register before DWC registers #define DWC2_REG_BASE (USB_BASE + offsetof(USB_TypeDef, GOTGCTL)) #define DWC2_EP_MAX 7 -#define DWC2_EP_FIFO_SIZE 2048 + +static const dwc2_controller_t _dwc2_controller[] = +{ + { .reg_base = DWC2_REG_BASE, .irqnum = USB_IRQn, .ep_count = DWC2_EP_MAX, .ep_fifo_size = 2048 } +}; TU_ATTR_ALWAYS_INLINE static inline void dwc2_dcd_int_enable(uint8_t rhport) { - (void) rhport; - NVIC_EnableIRQ(USB_IRQn); + NVIC_EnableIRQ(_dwc2_controller[rhport].irqnum); } TU_ATTR_ALWAYS_INLINE static inline void dwc2_dcd_int_disable (uint8_t rhport) { - (void) rhport; - NVIC_DisableIRQ(USB_IRQn); + NVIC_DisableIRQ(_dwc2_controller[rhport].irqnum); } static inline void dwc2_remote_wakeup_delay(void) diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_esp32.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_esp32.h index 78da277d5fc..c50dd66b89a 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_esp32.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_esp32.h @@ -37,10 +37,12 @@ //#include "soc/usb_periph.h" #define DWC2_REG_BASE 0x60080000UL -#define DWC2_EP_MAX 5 // USB_OUT_EP_NUM -#define DWC2_EP_FIFO_SIZE 1024 +#define DWC2_EP_MAX 6 // USB_OUT_EP_NUM. TODO ESP32Sx only has 5 tx fifo (5 endpoint IN) -// #define EP_FIFO_NUM 5 +static const dwc2_controller_t _dwc2_controller[] = +{ + { .reg_base = DWC2_REG_BASE, .irqnum = 0, .ep_count = DWC2_EP_MAX, .ep_fifo_size = 1024 } +}; static intr_handle_t usb_ih; diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_gd32.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_gd32.h index f8fa01ee0ad..0375fffe4e5 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_gd32.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_gd32.h @@ -34,8 +34,11 @@ #define DWC2_REG_BASE 0x50000000UL #define DWC2_EP_MAX 4 -#define DWC2_EP_FIFO_SIZE 1280 -#define RHPORT_IRQn 86 + +static const dwc2_controller_t _dwc2_controller[] = +{ + { .reg_base = DWC2_REG_BASE, .irqnum = 86, .ep_count = DWC2_EP_MAX, .ep_fifo_size = 1280 } +}; extern uint32_t SystemCoreClock; @@ -57,15 +60,13 @@ static inline void __eclic_disable_interrupt (uint32_t irq){ TU_ATTR_ALWAYS_INLINE static inline void dwc2_dcd_int_enable(uint8_t rhport) { - (void) rhport; - __eclic_enable_interrupt(RHPORT_IRQn); + __eclic_enable_interrupt(_dwc2_controller[rhport].irqnum); } TU_ATTR_ALWAYS_INLINE static inline void dwc2_dcd_int_disable (uint8_t rhport) { - (void) rhport; - __eclic_disable_interrupt(RHPORT_IRQn); + __eclic_disable_interrupt(_dwc2_controller[rhport].irqnum); } static inline void dwc2_remote_wakeup_delay(void) diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_stm32.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_stm32.h index 469045ac46e..b500ddc465a 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_stm32.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_stm32.h @@ -47,6 +47,7 @@ #include "stm32f4xx.h" #define EP_MAX_FS USB_OTG_FS_MAX_IN_ENDPOINTS #define EP_FIFO_SIZE_FS USB_OTG_FS_TOTAL_FIFO_SIZE + #define EP_MAX_HS USB_OTG_HS_MAX_IN_ENDPOINTS #define EP_FIFO_SIZE_HS USB_OTG_HS_TOTAL_FIFO_SIZE @@ -54,13 +55,18 @@ #include "stm32h7xx.h" #define EP_MAX_FS 9 #define EP_FIFO_SIZE_FS 4096 + #define EP_MAX_HS 9 #define EP_FIFO_SIZE_HS 4096 + // NOTE: H7 with only 1 USB port: H72x / H73x / H7Ax / H7Bx + // USB_OTG_FS_PERIPH_BASE and OTG_FS_IRQn not defined + #elif CFG_TUSB_MCU == OPT_MCU_STM32F7 #include "stm32f7xx.h" #define EP_MAX_FS 6 #define EP_FIFO_SIZE_FS 1280 + #define EP_MAX_HS 9 #define EP_FIFO_SIZE_HS 4096 @@ -73,35 +79,42 @@ #error "Unsupported MCUs" #endif -// On STM32 we associate Port0 to OTG_FS, and Port1 to OTG_HS -#if TUD_OPT_RHPORT == 0 - #define DWC2_REG_BASE USB_OTG_FS_PERIPH_BASE - #define DWC2_EP_MAX EP_MAX_FS - #define DWC2_EP_FIFO_SIZE EP_FIFO_SIZE_FS - #define RHPORT_IRQn OTG_FS_IRQn - +// OTG HS always has higher number of endpoints than FS +#ifdef USB_OTG_HS_PERIPH_BASE + #define DWC2_EP_MAX EP_MAX_HS #else - #define DWC2_REG_BASE USB_OTG_HS_PERIPH_BASE - #define DWC2_EP_MAX EP_MAX_HS - #define DWC2_EP_FIFO_SIZE EP_FIFO_SIZE_HS - #define RHPORT_IRQn OTG_HS_IRQn + #define DWC2_EP_MAX EP_MAX_FS +#endif +// On STM32 for consistency we associate +// - Port0 to OTG_FS, and Port1 to OTG_HS +static const dwc2_controller_t _dwc2_controller[] = +{ +#ifdef USB_OTG_FS_PERIPH_BASE + { .reg_base = USB_OTG_FS_PERIPH_BASE, .irqnum = OTG_FS_IRQn, .ep_count = EP_MAX_FS, .ep_fifo_size = EP_FIFO_SIZE_FS }, #endif +#ifdef USB_OTG_HS_PERIPH_BASE + { .reg_base = USB_OTG_HS_PERIPH_BASE, .irqnum = OTG_HS_IRQn, .ep_count = EP_MAX_HS, .ep_fifo_size = EP_FIFO_SIZE_HS }, +#endif +}; + +//--------------------------------------------------------------------+ +// +//--------------------------------------------------------------------+ + extern uint32_t SystemCoreClock; TU_ATTR_ALWAYS_INLINE static inline void dwc2_dcd_int_enable(uint8_t rhport) { - (void) rhport; - NVIC_EnableIRQ(RHPORT_IRQn); + NVIC_EnableIRQ(_dwc2_controller[rhport].irqnum); } TU_ATTR_ALWAYS_INLINE static inline void dwc2_dcd_int_disable (uint8_t rhport) { - (void) rhport; - NVIC_DisableIRQ(RHPORT_IRQn); + NVIC_DisableIRQ(_dwc2_controller[rhport].irqnum); } TU_ATTR_ALWAYS_INLINE diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_type.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_type.h index 7fa2028eb93..3fc979337db 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_type.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_type.h @@ -19,6 +19,19 @@ #include "stdint.h" +#ifdef __cplusplus + extern "C" { +#endif + +// Controller +typedef struct +{ + uintptr_t reg_base; + uint32_t irqnum; + uint8_t ep_count; + uint32_t ep_fifo_size; +}dwc2_controller_t; + /* DWC OTG HW Release versions */ #define DWC2_CORE_REV_2_71a 0x4f54271a #define DWC2_CORE_REV_2_72a 0x4f54272a @@ -40,10 +53,6 @@ #define DWC2_FS_IOT_ID 0x55310000 #define DWC2_HS_IOT_ID 0x55320000 -#ifdef __cplusplus - extern "C" { -#endif - #if 0 // HS PHY typedef struct diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_xmc.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_xmc.h index 4e6bebb0167..63419abf798 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_xmc.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_xmc.h @@ -34,23 +34,24 @@ #include "xmc_device.h" -// XMC has custom control register before DWC registers -#define DWC2_REG_BASE USB0_BASE #define DWC2_EP_MAX 7 -#define DWC2_EP_FIFO_SIZE 2048 + +static const dwc2_controller_t _dwc2_controller[] = +{ + // Note: XMC has some custom control registers before DWC registers + { .reg_base = USB0_BASE, .irqnum = USB0_0_IRQn, .ep_count = DWC2_EP_MAX, .ep_fifo_size = 2048 } +}; TU_ATTR_ALWAYS_INLINE static inline void dwc2_dcd_int_enable(uint8_t rhport) { - (void) rhport; - NVIC_EnableIRQ(USB0_0_IRQn); + NVIC_EnableIRQ(_dwc2_controller[rhport].irqnum); } TU_ATTR_ALWAYS_INLINE static inline void dwc2_dcd_int_disable (uint8_t rhport) { - (void) rhport; - NVIC_DisableIRQ(USB0_0_IRQn); + NVIC_DisableIRQ(_dwc2_controller[rhport].irqnum); } static inline void dwc2_remote_wakeup_delay(void) diff --git a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/tusb_option.h b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/tusb_option.h index bd87a953c47..206d23e72cc 100644 --- a/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/tusb_option.h +++ b/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/tusb_option.h @@ -27,6 +27,9 @@ #ifndef _TUSB_OPTION_H_ #define _TUSB_OPTION_H_ +// To avoid GCC compiler warnings when -pedantic option is used (strict ISO C) +typedef int make_iso_compilers_happy; + #include "common/tusb_compiler.h" #define TUSB_VERSION_MAJOR 0 @@ -192,60 +195,63 @@ #define OPT_MODE_HIGH_SPEED 0x0400 ///< High Speed #define OPT_MODE_SPEED_MASK 0xff00 -#ifndef CFG_TUSB_RHPORT0_MODE - #define CFG_TUSB_RHPORT0_MODE OPT_MODE_NONE -#endif - -#ifndef CFG_TUSB_RHPORT1_MODE - #define CFG_TUSB_RHPORT1_MODE OPT_MODE_NONE -#endif - -#if (((CFG_TUSB_RHPORT0_MODE) & OPT_MODE_HOST ) && ((CFG_TUSB_RHPORT1_MODE) & OPT_MODE_HOST )) || \ - (((CFG_TUSB_RHPORT0_MODE) & OPT_MODE_DEVICE) && ((CFG_TUSB_RHPORT1_MODE) & OPT_MODE_DEVICE)) - #error "TinyUSB currently does not support same modes on more than 1 roothub port" -#endif - //------------- Roothub as Device -------------// -#if (CFG_TUSB_RHPORT0_MODE) & OPT_MODE_DEVICE +#if defined(CFG_TUSB_RHPORT0_MODE) && ((CFG_TUSB_RHPORT0_MODE) & OPT_MODE_DEVICE) #define TUD_RHPORT_MODE (CFG_TUSB_RHPORT0_MODE) #define TUD_OPT_RHPORT 0 -#elif (CFG_TUSB_RHPORT1_MODE) & OPT_MODE_DEVICE +#elif defined(CFG_TUSB_RHPORT1_MODE) && ((CFG_TUSB_RHPORT1_MODE) & OPT_MODE_DEVICE) #define TUD_RHPORT_MODE (CFG_TUSB_RHPORT1_MODE) #define TUD_OPT_RHPORT 1 #else #define TUD_RHPORT_MODE OPT_MODE_NONE - #define TUD_OPT_RHPORT -1 #endif -#define CFG_TUD_ENABLED (TUD_RHPORT_MODE & OPT_MODE_DEVICE) +#ifndef CFG_TUD_ENABLED + // fallback to use CFG_TUSB_RHPORTx_MODE + #define CFG_TUD_ENABLED (TUD_RHPORT_MODE & OPT_MODE_DEVICE) +#endif -#if CFG_TUD_ENABLED - #define TUD_OPT_HIGH_SPEED ((TUD_RHPORT_MODE & OPT_MODE_SPEED_MASK) ? (TUD_RHPORT_MODE & OPT_MODE_HIGH_SPEED) : (TUP_RHPORT_HIGHSPEED & (1 << TUD_OPT_RHPORT))) -#else - #define TUD_OPT_HIGH_SPEED 0 +#ifndef CFG_TUD_MAX_SPEED + // fallback to use CFG_TUSB_RHPORTx_MODE + #define CFG_TUD_MAX_SPEED (TUD_RHPORT_MODE & OPT_MODE_SPEED_MASK) #endif +// For backward compatible +#define TUSB_OPT_DEVICE_ENABLED CFG_TUD_ENABLED + +// highspeed support indicator +#define TUD_OPT_HIGH_SPEED (CFG_TUD_MAX_SPEED ? CFG_TUD_MAX_SPEED : TUP_RHPORT_HIGHSPEED) + //------------- Roothub as Host -------------// -#if (CFG_TUSB_RHPORT0_MODE) & OPT_MODE_HOST +#if defined(CFG_TUSB_RHPORT0_MODE) && ((CFG_TUSB_RHPORT0_MODE) & OPT_MODE_HOST) #define TUH_RHPORT_MODE (CFG_TUSB_RHPORT0_MODE) #define TUH_OPT_RHPORT 0 -#elif (CFG_TUSB_RHPORT1_MODE) & OPT_MODE_HOST +#elif defined(CFG_TUSB_RHPORT1_MODE) && ((CFG_TUSB_RHPORT1_MODE) & OPT_MODE_HOST) #define TUH_RHPORT_MODE (CFG_TUSB_RHPORT1_MODE) #define TUH_OPT_RHPORT 1 #else #define TUH_RHPORT_MODE OPT_MODE_NONE - #define TUH_OPT_RHPORT -1 #endif -#define CFG_TUH_ENABLED ( TUH_RHPORT_MODE & OPT_MODE_HOST ) +#ifndef CFG_TUH_ENABLED + // fallback to use CFG_TUSB_RHPORTx_MODE + #define CFG_TUH_ENABLED (TUH_RHPORT_MODE & OPT_MODE_HOST) +#endif + +#ifndef CFG_TUH_MAX_SPEED + // fallback to use CFG_TUSB_RHPORTx_MODE + #define CFG_TUH_MAX_SPEED (TUH_RHPORT_MODE & OPT_MODE_SPEED_MASK) +#endif // For backward compatible -#define TUSB_OPT_DEVICE_ENABLED CFG_TUD_ENABLED #define TUSB_OPT_HOST_ENABLED CFG_TUH_ENABLED +//--------------------------------------------------------------------+ // TODO move later +//--------------------------------------------------------------------+ + // TUP_MCU_STRICT_ALIGN will overwrite TUP_ARCH_STRICT_ALIGN. // In case TUP_MCU_STRICT_ALIGN = 1 and TUP_ARCH_STRICT_ALIGN =0, we will not reply on compiler // to generate unaligned access code. @@ -258,7 +264,7 @@ //--------------------------------------------------------------------+ -// COMMON OPTIONS +// Common Options (Default) //--------------------------------------------------------------------+ // Debug enable to print out error message @@ -286,16 +292,20 @@ #endif // mutex is only needed for RTOS TODO also required with multiple core MCUs -#define TUSB_OPT_MUTEX (CFG_TUSB_OS != OPT_OS_NONE) +#define TUSB_OPT_MUTEX (CFG_TUSB_OS != OPT_OS_NONE) //-------------------------------------------------------------------- -// DEVICE OPTIONS +// Device Options (Default) //-------------------------------------------------------------------- #ifndef CFG_TUD_ENDPOINT0_SIZE #define CFG_TUD_ENDPOINT0_SIZE 64 #endif +#ifndef CFG_TUD_INTERFACE_MAX + #define CFG_TUD_INTERFACE_MAX 16 +#endif + #ifndef CFG_TUD_CDC #define CFG_TUD_CDC 0 #endif @@ -354,7 +364,7 @@ #endif //-------------------------------------------------------------------- -// HOST OPTIONS +// Host Options (Default) //-------------------------------------------------------------------- #if CFG_TUH_ENABLED #ifndef CFG_TUH_DEVICE_MAX @@ -396,6 +406,16 @@ #define CFG_TUH_API_EDPT_XFER 0 #endif +// Enable PIO-USB software host controller +#ifndef CFG_TUH_RPI_PIO_USB +#define CFG_TUH_RPI_PIO_USB 0 +#endif + +#ifndef CFG_TUD_RPI_PIO_USB +#define CFG_TUD_RPI_PIO_USB 0 +#endif + + //------------------------------------------------------------------ // Configuration Validation //------------------------------------------------------------------ diff --git a/tools/sdk/esp32s2/include/bootloader_support/include/bootloader_flash.h b/tools/sdk/esp32s2/include/bootloader_support/include/bootloader_flash.h index 49e457f372e..90865e234d6 100644 --- a/tools/sdk/esp32s2/include/bootloader_support/include/bootloader_flash.h +++ b/tools/sdk/esp32s2/include/bootloader_support/include/bootloader_flash.h @@ -9,6 +9,7 @@ #include /* including in bootloader for error values */ #include "sdkconfig.h" #include "soc/soc_caps.h" +#include "bootloader_flash_override.h" #ifdef __cplusplus extern "C" { @@ -32,20 +33,21 @@ uint32_t bootloader_read_flash_id(void); esp_err_t bootloader_flash_wrap_set(spi_flash_wrap_mode_t mode); #endif +/** + * @brief Startup flow recommended by XMC. Call at startup before any erase/write operation. + * + * @return ESP_OK When startup successfully, otherwise ESP_FAIL (indiciating you should reboot before erase/write). + */ +esp_err_t bootloader_flash_xmc_startup(void); + /** * @brief Unlock Flash write protect. * Please do not call this function in SDK. * * @note This can be overridden because it's attribute weak. */ -esp_err_t bootloader_flash_unlock(void); +esp_err_t IRAM_ATTR __attribute__((weak)) bootloader_flash_unlock(void); -/** - * @brief Startup flow recommended by XMC. Call at startup before any erase/write operation. - * - * @return ESP_OK When startup successfully, otherwise ESP_FAIL (indiciating you should reboot before erase/write). - */ -esp_err_t bootloader_flash_xmc_startup(void); #ifdef __cplusplus } diff --git a/tools/sdk/esp32s2/include/bootloader_support/include/bootloader_flash_override.h b/tools/sdk/esp32s2/include/bootloader_support/include/bootloader_flash_override.h new file mode 100644 index 00000000000..ae29f004344 --- /dev/null +++ b/tools/sdk/esp32s2/include/bootloader_support/include/bootloader_flash_override.h @@ -0,0 +1,101 @@ +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#pragma once + +#include "esp_err.h" +#include "esp_attr.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef unsigned (*bootloader_flash_read_status_fn_t)(void); +typedef void (*bootloader_flash_write_status_fn_t)(unsigned); + +typedef struct __attribute__((packed)) +{ + const char *manufacturer; + uint8_t mfg_id; /* 8-bit JEDEC manufacturer ID */ + uint16_t flash_id; /* 16-bit JEDEC flash chip ID */ + uint16_t id_mask; /* Bits to match on in flash chip ID */ + bootloader_flash_read_status_fn_t read_status_fn; + bootloader_flash_write_status_fn_t write_status_fn; + uint8_t status_qio_bit; +} bootloader_qio_info_t; + +/** + * @brief Read 8 bit status using RDSR command + * + * @return Value of SR1. + */ +unsigned bootloader_read_status_8b_rdsr(void); + +/** + * @brief Read 8 bit status (second byte) using RDSR2 command + * + * @return Value of SR2 + */ +unsigned bootloader_read_status_8b_rdsr2(void); + +/** + * @brief Read 16 bit status using RDSR & RDSR2 (low and high bytes) + * + * @return Value of SR2#SR1. + */ +unsigned bootloader_read_status_16b_rdsr_rdsr2(void); + +/** + * @brief Write 8 bit status using WRSR + */ +void bootloader_write_status_8b_wrsr(unsigned new_status); + +/** + * @brief Write 8 bit status (second byte) using WRSR2. + */ +void bootloader_write_status_8b_wrsr2(unsigned new_status); + +/** + * @brief Write 16 bit status using WRSR, (both write SR1 and SR2) + */ +void bootloader_write_status_16b_wrsr(unsigned new_status); + +/** + * @brief Read 8 bit status of XM25QU64A. + * + * @return Value of 8 bit SR. + */ +unsigned bootloader_read_status_8b_xmc25qu64a(void); + +/** + * @brief Write 8 bit status for XM25QU64A + */ +void bootloader_write_status_8b_xmc25qu64a(unsigned new_status); + +/* Array of known flash chips and data to enable Quad I/O mode + + Manufacturer & flash ID can be tested by running "esptool.py + flash_id" + + If manufacturer ID matches, and flash ID ORed with flash ID mask + matches, enable_qio_mode() will execute "Read Cmd", test if bit + number "QIE Bit" is set, and if not set it will call "Write Cmd" + with this bit set. + + Searching of this table stops when the first match is found. + */ +extern const bootloader_qio_info_t __attribute__((weak)) bootloader_flash_qe_support_list[]; + +/** + * @brief Unlock Flash write protect. + * Please do not call this function in SDK. + * + * @note This can be overridden because it's attribute weak. + */ +esp_err_t IRAM_ATTR __attribute__((weak)) bootloader_flash_unlock(void); + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32s2/include/bootloader_support/include/esp_app_format.h b/tools/sdk/esp32s2/include/bootloader_support/include/esp_app_format.h index 64744fdfe5a..ef4f7f4f48f 100644 --- a/tools/sdk/esp32s2/include/bootloader_support/include/esp_app_format.h +++ b/tools/sdk/esp32s2/include/bootloader_support/include/esp_app_format.h @@ -55,6 +55,9 @@ typedef enum { ESP_IMAGE_FLASH_SIZE_4MB, /*!< SPI flash size 4 MB */ ESP_IMAGE_FLASH_SIZE_8MB, /*!< SPI flash size 8 MB */ ESP_IMAGE_FLASH_SIZE_16MB, /*!< SPI flash size 16 MB */ + ESP_IMAGE_FLASH_SIZE_32MB, /*!< SPI flash size 32 MB */ + ESP_IMAGE_FLASH_SIZE_64MB, /*!< SPI flash size 64 MB */ + ESP_IMAGE_FLASH_SIZE_128MB, /*!< SPI flash size 128 MB */ ESP_IMAGE_FLASH_SIZE_MAX /*!< SPI flash size MAX */ } esp_image_flash_size_t; diff --git a/tools/sdk/esp32s2/include/coap/port/include/coap_config_posix.h b/tools/sdk/esp32s2/include/coap/port/include/coap_config_posix.h index b24335ad156..f96faea7665 100644 --- a/tools/sdk/esp32s2/include/coap/port/include/coap_config_posix.h +++ b/tools/sdk/esp32s2/include/coap/port/include/coap_config_posix.h @@ -30,6 +30,8 @@ #define HAVE_NETDB_H #define HAVE_NETINET_IN_H #define HAVE_STRUCT_CMSGHDR +#define HAVE_PTHREAD_H +#define HAVE_PTHREAD_MUTEX_LOCK #define COAP_DISABLE_TCP 0 #define ipi_spec_dst ipi_addr diff --git a/tools/sdk/esp32s2/include/driver/include/driver/gpio.h b/tools/sdk/esp32s2/include/driver/include/driver/gpio.h index eeb63f74f8e..77bb2dd78c0 100644 --- a/tools/sdk/esp32s2/include/driver/include/driver/gpio.h +++ b/tools/sdk/esp32s2/include/driver/include/driver/gpio.h @@ -97,7 +97,7 @@ esp_err_t gpio_set_intr_type(gpio_num_t gpio_num, gpio_int_type_t intr_type); /** * @brief Enable GPIO module interrupt signal * - * @note Please do not use the interrupt of GPIO36 and GPIO39 when using ADC or Wi-Fi with sleep mode enabled. + * @note Please do not use the interrupt of GPIO36 and GPIO39 when using ADC or Wi-Fi and Bluetooth with sleep mode enabled. * Please refer to the comments of `adc1_get_raw`. * Please refer to section 3.11 of 'ECO_and_Workarounds_for_Bugs_in_ESP32' for the description of this issue. * As a workaround, call adc_power_acquire() in the app. This will result in higher power consumption (by ~1mA), @@ -498,7 +498,8 @@ esp_err_t gpio_sleep_set_pull_mode(gpio_num_t gpio_num, gpio_pull_mode_t pull); #if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP -#define GPIO_IS_DEEP_SLEEP_WAKEUP_VALID_GPIO(gpio_num) ((gpio_num & ~SOC_GPIO_DEEP_SLEEP_WAKEUP_VALID_GPIO_MASK) == 0) +#define GPIO_IS_DEEP_SLEEP_WAKEUP_VALID_GPIO(gpio_num) ((gpio_num >= 0) && \ + (((1ULL << (gpio_num)) & SOC_GPIO_DEEP_SLEEP_WAKEUP_VALID_GPIO_MASK) != 0)) /** * @brief Enable GPIO deep-sleep wake-up function. diff --git a/tools/sdk/esp32s2/include/driver/include/driver/i2c.h b/tools/sdk/esp32s2/include/driver/include/driver/i2c.h index 22dcc8ab241..57d9091e70a 100644 --- a/tools/sdk/esp32s2/include/driver/include/driver/i2c.h +++ b/tools/sdk/esp32s2/include/driver/include/driver/i2c.h @@ -429,8 +429,7 @@ esp_err_t i2c_master_stop(i2c_cmd_handle_t cmd_handle); /** * @brief Send all the queued commands on the I2C bus, in master mode. * The task will be blocked until all the commands have been sent out. - * The I2C APIs are not thread-safe, if you want to use one I2C port in different tasks, - * you need to take care of the multi-thread issue. + * The I2C port is protected by mutex, so this function is thread-safe. * This function shall only be called in I2C master mode. * * @param i2c_num I2C port number diff --git a/tools/sdk/esp32s2/include/driver/include/driver/sdspi_host.h b/tools/sdk/esp32s2/include/driver/include/driver/sdspi_host.h index abb690c39bc..a5d942e9d86 100644 --- a/tools/sdk/esp32s2/include/driver/include/driver/sdspi_host.h +++ b/tools/sdk/esp32s2/include/driver/include/driver/sdspi_host.h @@ -22,8 +22,10 @@ typedef int sdspi_dev_handle_t; #if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2 #define SDSPI_DEFAULT_HOST HSPI_HOST +#define SDSPI_DEFAULT_DMA SDSPI_DEFAULT_HOST #else #define SDSPI_DEFAULT_HOST SPI2_HOST +#define SDSPI_DEFAULT_DMA SPI_DMA_CH_AUTO #endif /** @@ -216,7 +218,7 @@ typedef struct { .gpio_miso = GPIO_NUM_2, \ .gpio_mosi = GPIO_NUM_15, \ .gpio_sck = GPIO_NUM_14, \ - .dma_channel = 1, \ + .dma_channel = SDSPI_DEFAULT_DMA, \ } /** diff --git a/tools/sdk/esp32s2/include/driver/include/driver/spi_common.h b/tools/sdk/esp32s2/include/driver/include/driver/spi_common.h index 830b8efd8c2..424e9c0588f 100644 --- a/tools/sdk/esp32s2/include/driver/include/driver/spi_common.h +++ b/tools/sdk/esp32s2/include/driver/include/driver/spi_common.h @@ -163,7 +163,7 @@ esp_err_t spi_bus_initialize(spi_host_device_t host_id, const spi_bus_config_t * * @param host_id SPI peripheral to free * @return * - ESP_ERR_INVALID_ARG if parameter is invalid - * - ESP_ERR_INVALID_STATE if not all devices on the bus are freed + * - ESP_ERR_INVALID_STATE if bus hasn't been initialized before, or not all devices on the bus are freed * - ESP_OK on success */ esp_err_t spi_bus_free(spi_host_device_t host_id); diff --git a/tools/sdk/esp32s2/include/driver/include/esp_private/gdma.h b/tools/sdk/esp32s2/include/driver/include/esp_private/gdma.h index 88a45b56cfe..f888cd5bc9b 100644 --- a/tools/sdk/esp32s2/include/driver/include/esp_private/gdma.h +++ b/tools/sdk/esp32s2/include/driver/include/esp_private/gdma.h @@ -269,6 +269,9 @@ esp_err_t gdma_register_rx_event_callbacks(gdma_channel_handle_t dma_chan, gdma_ /** * @brief Set DMA descriptor address and start engine * + * @note This function is allowed to run within ISR context + * @note This function is also allowed to run when Cache is disabled, if `CONFIG_GDMA_CTRL_FUNC_IN_IRAM` is enabled + * * @param[in] dma_chan GDMA channel handle, allocated by `gdma_new_channel` * @param[in] desc_base_addr Base address of descriptors (usually the descriptors are chained into a link or ring) * @return @@ -281,6 +284,9 @@ esp_err_t gdma_start(gdma_channel_handle_t dma_chan, intptr_t desc_base_addr); /** * @brief Stop DMA engine * + * @note This function is allowed to run within ISR context + * @note This function is also allowed to run when Cache is disabled, if `CONFIG_GDMA_CTRL_FUNC_IN_IRAM` is enabled + * * @param[in] dma_chan GDMA channel handle, allocated by `gdma_new_channel` * @return * - ESP_OK: Stop DMA engine successfully @@ -291,6 +297,9 @@ esp_err_t gdma_stop(gdma_channel_handle_t dma_chan); /** * @brief Make the appended descriptors be aware to the DMA engine + * + * @note This function is allowed to run within ISR context + * @note This function is also allowed to run when Cache is disabled, if `CONFIG_GDMA_CTRL_FUNC_IN_IRAM` is enabled * @note This API could also resume a paused DMA engine, make sure new descriptors have been appended to the descriptor chain before calling it. * * @param[in] dma_chan GDMA channel handle, allocated by `gdma_new_channel` @@ -303,6 +312,9 @@ esp_err_t gdma_append(gdma_channel_handle_t dma_chan); /** * @brief Reset DMA channel FIFO and internal finite state machine + * + * @note This function is allowed to run within ISR context + * @note This function is also allowed to run when Cache is disabled, if `CONFIG_GDMA_CTRL_FUNC_IN_IRAM` is enabled * @note Resetting a DMA channel won't break the connection with the target peripheral * * @param[in] dma_chan GDMA channel handle, allocated by `gdma_new_channel` diff --git a/tools/sdk/esp32s2/include/esp-tls/esp_tls.h b/tools/sdk/esp32s2/include/esp-tls/esp_tls.h index 588f70d83f9..5b5b3628023 100644 --- a/tools/sdk/esp32s2/include/esp-tls/esp_tls.h +++ b/tools/sdk/esp32s2/include/esp-tls/esp_tls.h @@ -688,6 +688,16 @@ esp_err_t esp_tls_plain_tcp_connect(const char *host, int hostlen, int port, con * NULL on Failure */ esp_tls_client_session_t *esp_tls_get_client_session(esp_tls_t *tls); + +/** + * @brief Free the client session + * + * This function should be called after esp_tls_get_client_session(). + * + * @param[in] client_session context as esp_tls_client_session_t + * + */ +void esp_tls_free_client_session(esp_tls_client_session_t *client_session); #endif /* CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS */ #ifdef __cplusplus } diff --git a/tools/sdk/esp32s2/include/esp-tls/private_include/esp_tls_mbedtls.h b/tools/sdk/esp32s2/include/esp-tls/private_include/esp_tls_mbedtls.h index c1c5d4f3288..43dce58ad6e 100644 --- a/tools/sdk/esp32s2/include/esp-tls/private_include/esp_tls_mbedtls.h +++ b/tools/sdk/esp32s2/include/esp-tls/private_include/esp_tls_mbedtls.h @@ -104,6 +104,11 @@ esp_err_t set_client_config(const char *hostname, size_t hostlen, esp_tls_cfg_t * Internal Callback for mbedtls_get_client_session */ esp_tls_client_session_t *esp_mbedtls_get_client_session(esp_tls_t *tls); + +/** + * Internal Callback for mbedtls_free_client_session + */ +void esp_mbedtls_free_client_session(esp_tls_client_session_t *client_session); #endif /** diff --git a/tools/sdk/esp32s2/include/esp32-camera/driver/include/sensor.h b/tools/sdk/esp32s2/include/esp32-camera/driver/include/sensor.h index 26afeec3fd5..e4a1cceba57 100755 --- a/tools/sdk/esp32s2/include/esp32-camera/driver/include/sensor.h +++ b/tools/sdk/esp32s2/include/esp32-camera/driver/include/sensor.h @@ -28,6 +28,7 @@ typedef enum { GC0308_PID = 0x9b, BF3005_PID = 0x30, BF20A6_PID = 0x20a6, + SC030IOT_PID = 0x9a46, } camera_pid_t; typedef enum { @@ -42,6 +43,7 @@ typedef enum { CAMERA_GC0308, CAMERA_BF3005, CAMERA_BF20A6, + CAMERA_SC030IOT, CAMERA_MODEL_MAX, CAMERA_NONE, } camera_model_t; @@ -58,6 +60,7 @@ typedef enum { GC0308_SCCB_ADDR = 0x21,// 0x42 >> 1 BF3005_SCCB_ADDR = 0x6E, BF20A6_SCCB_ADDR = 0x6E, + SC030IOT_SCCB_ADDR = 0x68,// 0xd0 >> 1 } camera_sccb_addr_t; typedef enum { diff --git a/tools/sdk/esp32s2/include/esp_http_client/include/esp_http_client.h b/tools/sdk/esp32s2/include/esp_http_client/include/esp_http_client.h index d1b530a42e3..6ba8ed6e582 100644 --- a/tools/sdk/esp32s2/include/esp_http_client/include/esp_http_client.h +++ b/tools/sdk/esp32s2/include/esp_http_client/include/esp_http_client.h @@ -149,7 +149,9 @@ typedef enum { HttpStatus_MultipleChoices = 300, HttpStatus_MovedPermanently = 301, HttpStatus_Found = 302, + HttpStatus_SeeOther = 303, HttpStatus_TemporaryRedirect = 307, + HttpStatus_PermanentRedirect = 308, /* 4xx - Client Error */ HttpStatus_BadRequest = 400, diff --git a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/spinlock.h b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/spinlock.h index fbeff5054b4..b2fadfe49e3 100644 --- a/tools/sdk/esp32s2/include/esp_hw_support/include/soc/spinlock.h +++ b/tools/sdk/esp32s2/include/esp_hw_support/include/soc/spinlock.h @@ -95,13 +95,13 @@ static inline bool __attribute__((always_inline)) spinlock_acquire(spinlock_t *l */ result = core_id; -#if defined(CONFIG_ESP32_SPIRAM_SUPPORT) +#if (CONFIG_ESP32_SPIRAM_SUPPORT || CONFIG_ESP32S3_SPIRAM_SUPPORT) if (esp_ptr_external_ram(lock)) { compare_and_set_extram(&lock->owner, SPINLOCK_FREE, &result); } else { #endif compare_and_set_native(&lock->owner, SPINLOCK_FREE, &result); -#if defined(CONFIG_ESP32_SPIRAM_SUPPORT) +#if (CONFIG_ESP32_SPIRAM_SUPPORT || CONFIG_ESP32S3_SPIRAM_SUPPORT) } #endif if(result != other_core_id) { diff --git a/tools/sdk/esp32s2/include/esp_lcd/include/esp_lcd_panel_io.h b/tools/sdk/esp32s2/include/esp_lcd/include/esp_lcd_panel_io.h index 330f4d9a165..7b99bde3f17 100644 --- a/tools/sdk/esp32s2/include/esp_lcd/include/esp_lcd_panel_io.h +++ b/tools/sdk/esp32s2/include/esp_lcd/include/esp_lcd_panel_io.h @@ -19,6 +19,25 @@ typedef void *esp_lcd_spi_bus_handle_t; /*!< Type of LCD S typedef void *esp_lcd_i2c_bus_handle_t; /*!< Type of LCD I2C bus handle */ typedef struct esp_lcd_i80_bus_t *esp_lcd_i80_bus_handle_t; /*!< Type of LCD intel 8080 bus handle */ +/** + * @brief Transmit LCD command and receive corresponding parameters + * + * @note Commands sent by this function are short, so they are sent using polling transactions. + * The function does not return before the command tranfer is completed. + * If any queued transactions sent by `esp_lcd_panel_io_tx_color()` are still pending when this function is called, + * this function will wait until they are finished and the queue is empty before sending the command(s). + * + * @param[in] io LCD panel IO handle, which is created by other factory API like `esp_lcd_new_panel_io_spi()` + * @param[in] lcd_cmd The specific LCD command, set to -1 if no command needed + * @param[out] param Buffer for the command data + * @param[in] param_size Size of `param` buffer + * @return + * - ESP_ERR_INVALID_ARG if parameter is invalid + * - ESP_ERR_NOT_SUPPORTED if read is not supported by transport + * - ESP_OK on success + */ +esp_err_t esp_lcd_panel_io_rx_param(esp_lcd_panel_io_handle_t io, int lcd_cmd, void *param, size_t param_size); + /** * @brief Transmit LCD command and corresponding parameters * @@ -98,7 +117,8 @@ typedef struct { unsigned int dc_as_cmd_phase: 1; /*!< D/C line value is encoded into SPI transaction command phase */ unsigned int dc_low_on_data: 1; /*!< If this flag is enabled, DC line = 0 means transfer data, DC line = 1 means transfer command; vice versa */ unsigned int octal_mode: 1; /*!< transmit with octal mode (8 data lines), this mode is used to simulate Intel 8080 timing */ - } flags; + unsigned int lsb_first: 1; /*!< transmit LSB bit first */ + } flags; /*!< Extra flags to fine-tune the SPI device */ } esp_lcd_panel_io_spi_config_t; /** @@ -124,6 +144,7 @@ typedef struct { int lcd_param_bits; /*!< Bit-width of LCD parameter */ struct { unsigned int dc_low_on_data: 1; /*!< If this flag is enabled, DC line = 0 means transfer data, DC line = 1 means transfer command; vice versa */ + unsigned int disable_control_phase: 1; /*!< If this flag is enabled, the control phase isn't used */ } flags; } esp_lcd_panel_io_i2c_config_t; @@ -151,6 +172,8 @@ typedef struct { int data_gpio_nums[SOC_LCD_I80_BUS_WIDTH]; /*!< GPIOs used for data lines */ size_t bus_width; /*!< Number of data lines, 8 or 16 */ size_t max_transfer_bytes; /*!< Maximum transfer size, this determines the length of internal DMA link */ + size_t psram_trans_align; /*!< DMA transfer alignment for data allocated from PSRAM */ + size_t sram_trans_align; /*!< DMA transfer alignment for data allocated from SRAM */ } esp_lcd_i80_bus_config_t; /** diff --git a/tools/sdk/esp32s2/include/esp_lcd/include/esp_lcd_panel_rgb.h b/tools/sdk/esp32s2/include/esp_lcd/include/esp_lcd_panel_rgb.h index 6f06deb8165..95dfb6ba4fc 100644 --- a/tools/sdk/esp32s2/include/esp_lcd/include/esp_lcd_panel_rgb.h +++ b/tools/sdk/esp32s2/include/esp_lcd/include/esp_lcd_panel_rgb.h @@ -59,7 +59,7 @@ typedef struct { unsigned int hsync_front_porch; /*!< Horizontal front porch, number of PCLK between the end of active data and the next hsync */ unsigned int vsync_pulse_width; /*!< Vertical sync width, unit: number of lines */ unsigned int vsync_back_porch; /*!< Vertical back porch, number of invalid lines between vsync and start of frame */ - unsigned int vsync_front_porch; /*!< Vertical front porch, number of invalid lines between then end of frame and the next vsync */ + unsigned int vsync_front_porch; /*!< Vertical front porch, number of invalid lines between the end of frame and the next vsync */ struct { unsigned int hsync_idle_low: 1; /*!< The hsync signal is low in IDLE state */ unsigned int vsync_idle_low: 1; /*!< The vsync signal is low in IDLE state */ diff --git a/tools/sdk/esp32s2/include/esp_lcd/interface/esp_lcd_panel_io_interface.h b/tools/sdk/esp32s2/include/esp_lcd/interface/esp_lcd_panel_io_interface.h index 2faa6fab268..9f2226587e5 100644 --- a/tools/sdk/esp32s2/include/esp_lcd/interface/esp_lcd_panel_io_interface.h +++ b/tools/sdk/esp32s2/include/esp_lcd/interface/esp_lcd_panel_io_interface.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -18,6 +18,22 @@ typedef struct esp_lcd_panel_io_t esp_lcd_panel_io_t; /*!< Type of LCD panel IO * @brief LCD panel IO interface */ struct esp_lcd_panel_io_t { + /** + * @brief Transmit LCD command and receive corresponding parameters + * + * @note This is the panel-specific interface called by function `esp_lcd_panel_io_rx_param()`. + * + * @param[in] io LCD panel IO handle, which is created by other factory API like `esp_lcd_new_panel_io_spi()` + * @param[in] lcd_cmd The specific LCD command, set to -1 if no command needed + * @param[out] param Buffer for the command data + * @param[in] param_size Size of `param` buffer + * @return + * - ESP_ERR_INVALID_ARG if parameter is invalid + * - ESP_ERR_NOT_SUPPORTED if read is not supported by transport + * - ESP_OK on success + */ + esp_err_t (*rx_param)(esp_lcd_panel_io_t *io, int lcd_cmd, void *param, size_t param_size); + /** * @brief Transmit LCD command and corresponding parameters * diff --git a/tools/sdk/esp32s2/include/esp_phy/esp32s2/include/phy_init_data.h b/tools/sdk/esp32s2/include/esp_phy/esp32s2/include/phy_init_data.h index e1aa8d46138..5128a865692 100644 --- a/tools/sdk/esp32s2/include/esp_phy/esp32s2/include/phy_init_data.h +++ b/tools/sdk/esp32s2/include/esp_phy/esp32s2/include/phy_init_data.h @@ -20,8 +20,8 @@ extern "C" { // define the lowest tx power as LOWEST_PHY_TX_POWER #define PHY_TX_POWER_LOWEST LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 52) -#define PHY_TX_POWER_OFFSET 44 -#define PHY_TX_POWER_NUM 5 +#define PHY_TX_POWER_OFFSET 2 +#define PHY_TX_POWER_NUM 14 #if CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN #define PHY_CRC_ALGORITHM 1 diff --git a/tools/sdk/esp32s2/include/esp_phy/include/esp_phy_init.h b/tools/sdk/esp32s2/include/esp_phy/include/esp_phy_init.h index 04068c7f38d..ec682139506 100644 --- a/tools/sdk/esp32s2/include/esp_phy/include/esp_phy_init.h +++ b/tools/sdk/esp32s2/include/esp_phy/include/esp_phy_init.h @@ -170,12 +170,27 @@ void esp_phy_disable(void); */ void esp_phy_load_cal_and_init(void); +/** + * @brief Initialize backup memory for Phy power up/down + */ +void esp_phy_pd_mem_init(void); + +/** + * @brief Deinitialize backup memory for Phy power up/down + */ +void esp_phy_pd_mem_deinit(void); + #if CONFIG_MAC_BB_PD /** * @brief Initialize backup memory for MAC and Baseband power up/down */ void esp_mac_bb_pd_mem_init(void); +/** + * @brief Deinitialize backup memory for MAC and Baseband power up/down + */ +void esp_mac_bb_pd_mem_deinit(void); + /** * @brief Power up MAC and Baseband */ diff --git a/tools/sdk/esp32s2/include/esp_rainmaker/include/esp_rmaker_core.h b/tools/sdk/esp32s2/include/esp_rainmaker/include/esp_rmaker_core.h index 9dbdbae658b..eb01e6d8e3d 100644 --- a/tools/sdk/esp32s2/include/esp_rainmaker/include/esp_rmaker_core.h +++ b/tools/sdk/esp32s2/include/esp_rainmaker/include/esp_rmaker_core.h @@ -63,6 +63,8 @@ typedef struct { char *fw_version; /** Model (Optional). If not set, PROJECT_NAME is used as default (recommended)*/ char *model; + /** Subtype (Optional). */ + char *subtype; } esp_rmaker_node_info_t; /** ESP RainMaker Configuration */ @@ -430,10 +432,11 @@ esp_err_t esp_rmaker_node_add_attribute(const esp_rmaker_node_t *node, const cha */ esp_err_t esp_rmaker_node_add_fw_version(const esp_rmaker_node_t *node, const char *fw_version); -/** Add model for a node (Not recommended) +/** Add model for a node * * Model is set internally to the project name. This API can be used to - * override that name. + * override that name, now that a new field "project" has also been added + * internally to the node info. * * @param node Node handle. * @param[in] model New model string. @@ -443,6 +446,16 @@ esp_err_t esp_rmaker_node_add_fw_version(const esp_rmaker_node_t *node, const ch */ esp_err_t esp_rmaker_node_add_model(const esp_rmaker_node_t *node, const char *model); +/** Add subtype for a node + * + * @param node Node handle. + * @param[in] subtype Subtype string. + * + * @return ESP_OK on success. + * @return error in case of failure. + */ +esp_err_t esp_rmaker_node_add_subtype(const esp_rmaker_node_t *node, const char *subtype); + /** * Create a Device * @@ -572,6 +585,18 @@ esp_err_t esp_rmaker_device_add_attribute(const esp_rmaker_device_t *device, con */ esp_err_t esp_rmaker_device_add_subtype(const esp_rmaker_device_t *device, const char *subtype); +/** Add a Device model + * + * This would primarily be used by the phone apps to render different icons for the same device type. + * + * @param[in] device Device handle. + * @param[in] model String describing the model. + * + * @return ESP_OK if the model was added successfully. + * @return error in case of failure. + */ +esp_err_t esp_rmaker_device_add_model(const esp_rmaker_device_t *device, const char *model); + /** Get device name from handle * * @param[in] device Device handle. @@ -892,6 +917,20 @@ esp_err_t esp_rmaker_system_service_enable(esp_rmaker_system_serv_config_t *conf */ bool esp_rmaker_local_ctrl_service_started(void); +/** + * Enable Default RainMaker OTA Firmware Upgrade + * + * This enables the default recommended RainMaker OTA Firmware Upgrade, which is + * "Using the Topics", which allows performing OTA from Dashboard. + * This OTA can be triggered by Admin Users only. + * On Public RainMaker deployment, for nodes using "Self Claiming", since there + * is no associated admin user, the Primary user will automatically become the admin + * and can perform OTA from dashboard. + * + * @return ESP_OK on success + * @return error on failure + */ +esp_err_t esp_rmaker_ota_enable_default(void); #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32s2/include/esp_rainmaker/include/esp_rmaker_ota.h b/tools/sdk/esp32s2/include/esp_rainmaker/include/esp_rmaker_ota.h index e66b95705bc..6dc7962177e 100644 --- a/tools/sdk/esp32s2/include/esp_rainmaker/include/esp_rmaker_ota.h +++ b/tools/sdk/esp32s2/include/esp_rainmaker/include/esp_rmaker_ota.h @@ -34,6 +34,8 @@ typedef enum { OTA_STATUS_FAILED, /** OTA was delayed by the application */ OTA_STATUS_DELAYED, + /** OTA rejected due to some reason (wrong project, version, etc.) */ + OTA_STATUS_REJECTED, } ota_status_t; /** OTA Workflow type */ @@ -145,6 +147,29 @@ esp_err_t esp_rmaker_ota_enable(esp_rmaker_ota_config_t *ota_config, esp_rmaker_ */ esp_err_t esp_rmaker_ota_report_status(esp_rmaker_ota_handle_t ota_handle, ota_status_t status, char *additional_info); +/** Default OTA callback + * + * This is the default OTA callback which will get used if you do not pass your own callback. You can call this + * even from your callback, in case you want better control on when the OTA can proceed and yet let the actual + * OTA process be managed by the RainMaker Core. + * + * @param[in] handle An OTA handle assigned by the ESP RainMaker Core + * @param[in] ota_data The data to be used for the OTA + * + * @return ESP_OK if the OTA was successful + * @return ESP_FAIL if the OTA failed. + * */ +esp_err_t esp_rmaker_ota_default_cb(esp_rmaker_ota_handle_t handle, esp_rmaker_ota_data_t *ota_data); + +/** Fetch OTA Info + * + * For OTA using Topics, this API can be used to explicitly ask the backend if an OTA is available. + * If it is, then the OTA callback would get invoked. + * + * @return ESP_OK if the OTA fetch publish message was successful. + * @return error on failure + */ +esp_err_t esp_rmaker_ota_fetch(void); #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32s2/include/esp_rainmaker/include/esp_rmaker_standard_types.h b/tools/sdk/esp32s2/include/esp_rainmaker/include/esp_rmaker_standard_types.h index 4dc99eab401..9f74fcaea7c 100644 --- a/tools/sdk/esp32s2/include/esp_rainmaker/include/esp_rmaker_standard_types.h +++ b/tools/sdk/esp32s2/include/esp_rainmaker/include/esp_rmaker_standard_types.h @@ -25,6 +25,10 @@ extern "C" #define ESP_RMAKER_UI_DROPDOWN "esp.ui.dropdown" #define ESP_RMAKER_UI_TEXT "esp.ui.text" #define ESP_RMAKER_UI_HUE_SLIDER "esp.ui.hue-slider" +#define ESP_RMAKER_UI_HUE_CIRCLE "esp.ui.hue-circle" +#define ESP_RMAKER_UI_PUSHBUTTON "esp.ui.push-btn-big" +#define ESP_RMAKER_UI_TRIGGER "esp.ui.trigger" +#define ESP_RMAKER_UI_HIDDEN "esp.ui.hidden" /********** STANDARD PARAM TYPES **********/ @@ -50,6 +54,13 @@ extern "C" #define ESP_RMAKER_PARAM_WIFI_RESET "esp.param.wifi-reset" #define ESP_RMAKER_PARAM_LOCAL_CONTROL_POP "esp.param.local_control_pop" #define ESP_RMAKER_PARAM_LOCAL_CONTROL_TYPE "esp.param.local_control_type" +#define ESP_RMAKER_PARAM_TOGGLE "esp.param.toggle" +#define ESP_RMAKER_PARAM_RANGE "esp.param.range" +#define ESP_RMAKER_PARAM_MODE "esp.param.mode" +#define ESP_RMAKER_PARAM_BLINDS_POSITION "esp.param.blinds-position" +#define ESP_RMAKER_PARAM_GARAGE_POSITION "esp.param.garage-position" +#define ESP_RMAKER_PARAM_LIGHT_MODE "esp.param.light-mode" +#define ESP_RMAKER_PARAM_AC_MODE "esp.param.ac-mode" /********** STANDARD DEVICE TYPES **********/ @@ -58,7 +69,21 @@ extern "C" #define ESP_RMAKER_DEVICE_LIGHTBULB "esp.device.lightbulb" #define ESP_RMAKER_DEVICE_FAN "esp.device.fan" #define ESP_RMAKER_DEVICE_TEMP_SENSOR "esp.device.temperature-sensor" - +#define ESP_RMAKER_DEVICE_LIGHT "esp.device.light" +#define ESP_RMAKER_DEVICE_OUTLET "esp.device.outlet" +#define ESP_RMAKER_DEVICE_PLUG "esp.device.plug" +#define ESP_RMAKER_DEVICE_SOCKET "esp.device.socket" +#define ESP_RMAKER_DEVICE_LOCK "esp.device.lock" +#define ESP_RMAKER_DEVICE_BLINDS_INTERNAL "esp.device.blinds-internal" +#define ESP_RMAKER_DEVICE_BLINDS_EXTERNAL "esp.device.blinds-external" +#define ESP_RMAKER_DEVICE_GARAGE_DOOR "esp.device.garage-door" +#define ESP_RMAKER_DEVICE_GARAGE_LOCK "esp.device.garage-door-lock" +#define ESP_RMAKER_DEVICE_SPEAKER "esp.device.speaker" +#define ESP_RMAKER_DEVICE_AIR_CONDITIONER "esp.device.air-conditioner" +#define ESP_RMAKER_DEVICE_THERMOSTAT "esp.device.thermostat" +#define ESP_RMAKER_DEVICE_TV "esp.device.tv" +#define ESP_RMAKER_DEVICE_WASHER "esp.device.washer" +#define ESP_RMAKER_DEVICE_OTHER "esp.device.other" /********** STANDARD SERVICE TYPES **********/ #define ESP_RMAKER_SERVICE_OTA "esp.service.ota" diff --git a/tools/sdk/esp32s2/include/esp_rainmaker/include/esp_rmaker_user_mapping.h b/tools/sdk/esp32s2/include/esp_rainmaker/include/esp_rmaker_user_mapping.h index 77a153b02f2..734cdd6da2a 100644 --- a/tools/sdk/esp32s2/include/esp_rainmaker/include/esp_rmaker_user_mapping.h +++ b/tools/sdk/esp32s2/include/esp_rainmaker/include/esp_rmaker_user_mapping.h @@ -25,6 +25,8 @@ typedef enum { ESP_RMAKER_USER_MAPPING_RESET = 0, /** Mapping has started */ ESP_RMAKER_USER_MAPPING_STARTED, + /** Mapping request sent to cloud */ + ESP_RMAKER_USER_MAPPING_REQ_SENT, /** Mapping is done */ ESP_RMAKER_USER_MAPPING_DONE, } esp_rmaker_user_mapping_state_t; diff --git a/tools/sdk/esp32s2/include/esp_rom/include/esp32c3/rom/efuse.h b/tools/sdk/esp32s2/include/esp_rom/include/esp32c3/rom/efuse.h index 9da1525f969..d1412c46110 100644 --- a/tools/sdk/esp32s2/include/esp_rom/include/esp32c3/rom/efuse.h +++ b/tools/sdk/esp32s2/include/esp_rom/include/esp32c3/rom/efuse.h @@ -1,16 +1,8 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ROM_EFUSE_H_ #define _ROM_EFUSE_H_ @@ -236,13 +228,13 @@ bool ets_efuse_legacy_spi_boot_mode_disabled(void); uint32_t ets_efuse_get_uart_print_control(void); /** - * @brief Read which channel will used by ROM to print + * @brief Read if USB-Serial-JTAG print during rom boot is disabled from Efuse * * @return - * - 0 for UART0. - * - 1 for UART1. + * - 1 for efuse disable USB-Serial-JTAG print during rom boot. + * - 0 for efuse doesn't disable USB-Serial-JTAG print during rom boot. */ -uint32_t ets_efuse_get_uart_print_channel(void); +uint32_t ets_efuse_usb_serial_jtag_print_is_disabled(void); /** * @brief Read if usb download mode disabled from Efuse diff --git a/tools/sdk/esp32s2/include/esp_rom/include/esp32h2/rom/efuse.h b/tools/sdk/esp32s2/include/esp_rom/include/esp32h2/rom/efuse.h index 9da1525f969..d1412c46110 100644 --- a/tools/sdk/esp32s2/include/esp_rom/include/esp32h2/rom/efuse.h +++ b/tools/sdk/esp32s2/include/esp_rom/include/esp32h2/rom/efuse.h @@ -1,16 +1,8 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ROM_EFUSE_H_ #define _ROM_EFUSE_H_ @@ -236,13 +228,13 @@ bool ets_efuse_legacy_spi_boot_mode_disabled(void); uint32_t ets_efuse_get_uart_print_control(void); /** - * @brief Read which channel will used by ROM to print + * @brief Read if USB-Serial-JTAG print during rom boot is disabled from Efuse * * @return - * - 0 for UART0. - * - 1 for UART1. + * - 1 for efuse disable USB-Serial-JTAG print during rom boot. + * - 0 for efuse doesn't disable USB-Serial-JTAG print during rom boot. */ -uint32_t ets_efuse_get_uart_print_channel(void); +uint32_t ets_efuse_usb_serial_jtag_print_is_disabled(void); /** * @brief Read if usb download mode disabled from Efuse diff --git a/tools/sdk/esp32s2/include/esp_rom/include/esp32s3/rom/efuse.h b/tools/sdk/esp32s2/include/esp_rom/include/esp32s3/rom/efuse.h index cbe38e6a55e..3d347f48330 100644 --- a/tools/sdk/esp32s2/include/esp_rom/include/esp32s3/rom/efuse.h +++ b/tools/sdk/esp32s2/include/esp_rom/include/esp32s3/rom/efuse.h @@ -1,16 +1,8 @@ -// Copyright 2015-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. +/* + * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once @@ -237,13 +229,13 @@ bool ets_efuse_legacy_spi_boot_mode_disabled(void); uint32_t ets_efuse_get_uart_print_control(void); /** - * @brief Read which channel will used by ROM to print + * @brief Read if USB-Serial-JTAG print during rom boot is disabled from Efuse * * @return - * - 0 for UART0. - * - 1 for UART1. + * - 1 for efuse disable USB-Serial-JTAG print during rom boot. + * - 0 for efuse doesn't disable USB-Serial-JTAG print during rom boot. */ -uint32_t ets_efuse_get_uart_print_channel(void); +uint32_t ets_efuse_usb_serial_jtag_print_is_disabled(void); /** * @brief Read if usb download mode disabled from Efuse diff --git a/tools/sdk/esp32s2/include/esp_wifi/include/esp_wifi.h b/tools/sdk/esp32s2/include/esp_wifi/include/esp_wifi.h index bcd10c77a10..3d62c5c297c 100644 --- a/tools/sdk/esp32s2/include/esp_wifi/include/esp_wifi.h +++ b/tools/sdk/esp32s2/include/esp_wifi/include/esp_wifi.h @@ -1295,6 +1295,19 @@ esp_err_t esp_wifi_get_country_code(char *country); */ esp_err_t esp_wifi_config_80211_tx_rate(wifi_interface_t ifx, wifi_phy_rate_t rate); +/** + * @brief Disable PMF configuration for specified interface + * + * @attention This API should be called after esp_wifi_set_config() and before esp_wifi_start(). + * + * @param ifx Interface to be configured. + * + * @return + * - ESP_OK: succeed + * - others: failed + */ +esp_err_t esp_wifi_disable_pmf_config(wifi_interface_t ifx); + #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32s2/include/freertos/include/esp_additions/freertos/task_snapshot.h b/tools/sdk/esp32s2/include/freertos/include/esp_additions/freertos/task_snapshot.h index 1ad04cce694..635a5150257 100644 --- a/tools/sdk/esp32s2/include/freertos/include/esp_additions/freertos/task_snapshot.h +++ b/tools/sdk/esp32s2/include/freertos/include/esp_additions/freertos/task_snapshot.h @@ -80,8 +80,9 @@ TaskHandle_t pxTaskGetNext( TaskHandle_t pxTask ); * @note This function should not be used while FreeRTOS is running (as it doesn't acquire any locks). * @param pxTask task handle. * @param pxTaskSnapshot address of TaskSnapshot_t structure to fill. + * @return pdTRUE if operation was successful else pdFALSE */ -void vTaskGetSnapshot( TaskHandle_t pxTask, TaskSnapshot_t *pxTaskSnapshot ); +BaseType_t vTaskGetSnapshot( TaskHandle_t pxTask, TaskSnapshot_t *pxTaskSnapshot ); #ifdef __cplusplus } diff --git a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/cpu_ll.h b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/cpu_ll.h index ded1ca3ab4f..bb7bd9d735d 100644 --- a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/cpu_ll.h +++ b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/cpu_ll.h @@ -33,7 +33,7 @@ static inline uint32_t IRAM_ATTR cpu_ll_get_core_id(void) return 0; } -static inline uint32_t cpu_ll_get_cycle_count(void) +static inline uint32_t IRAM_ATTR cpu_ll_get_cycle_count(void) { uint32_t result; RSR(CCOUNT, result); diff --git a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/i2s_ll.h b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/i2s_ll.h index 6f453221eec..521c5e70dcd 100644 --- a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/i2s_ll.h +++ b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/i2s_ll.h @@ -771,6 +771,17 @@ static inline void i2s_ll_tx_set_chan_mod(i2s_dev_t *hw, uint32_t val) hw->conf_chan.tx_chan_mod = val; } +/** + * @brief Set I2S rx chan mode + * + * @param hw Peripheral I2S hardware instance address. + * @param val value to set rx chan mode + */ +static inline void i2s_ll_rx_set_chan_mod(i2s_dev_t *hw, uint32_t val) +{ + hw->conf_chan.rx_chan_mod = val; +} + /** * @brief Set I2S tx bits mod * @@ -804,7 +815,6 @@ static inline void i2s_ll_tx_enable_mono_mode(i2s_dev_t *hw, bool mono_ena) int data_bit = hw->sample_rate_conf.tx_bits_mod; hw->fifo_conf.tx_fifo_mod = data_bit <= I2S_BITS_PER_SAMPLE_16BIT ? mono_ena : 2 + mono_ena; hw->conf.tx_dma_equal = mono_ena; - hw->conf_chan.tx_chan_mod = mono_ena; } /** @@ -818,7 +828,6 @@ static inline void i2s_ll_rx_enable_mono_mode(i2s_dev_t *hw, bool mono_ena) int data_bit = hw->sample_rate_conf.rx_bits_mod; hw->fifo_conf.rx_fifo_mod = data_bit <= I2S_BITS_PER_SAMPLE_16BIT ? mono_ena : 2 + mono_ena; hw->conf.rx_dma_equal = mono_ena; - hw->conf_chan.rx_chan_mod = mono_ena; } /** diff --git a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/rtc_cntl_ll.h b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/rtc_cntl_ll.h index e1ad1d52cd3..ffba472c477 100644 --- a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/rtc_cntl_ll.h +++ b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/rtc_cntl_ll.h @@ -1,16 +1,8 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once @@ -48,9 +40,11 @@ static inline void rtc_cntl_ll_ext1_clear_wakeup_pins(void) REG_SET_BIT(RTC_CNTL_EXT_WAKEUP1_REG, RTC_CNTL_EXT_WAKEUP1_STATUS_CLR); } -static inline void rtc_cntl_ll_ulp_wakeup_enable(void) +static inline void rtc_cntl_ll_ulp_int_clear(void) { - SET_PERI_REG_BITS(RTC_CNTL_STATE0_REG, RTC_CNTL_WAKEUP_ENA_V, 0x800, RTC_CNTL_WAKEUP_ENA_S); + REG_SET_BIT(RTC_CNTL_INT_CLR_REG, RTC_CNTL_ULP_CP_INT_CLR); + REG_SET_BIT(RTC_CNTL_INT_CLR_REG, RTC_CNTL_COCPU_INT_CLR); + REG_SET_BIT(RTC_CNTL_INT_CLR_REG, RTC_CNTL_COCPU_TRAP_INT_CLR); } #ifdef __cplusplus diff --git a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/spi_ll.h b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/spi_ll.h index c6dac13154c..b975206d0f2 100644 --- a/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/spi_ll.h +++ b/tools/sdk/esp32s2/include/hal/esp32s2/include/hal/spi_ll.h @@ -43,6 +43,8 @@ extern "C" { #define SPI_LL_PERIPH_CLK_FREQ (80 * 1000000) #define SPI_LL_GET_HW(ID) ((ID)==0? ({abort();NULL;}):((ID)==1? &GPSPI2 : &GPSPI3)) +#define SPI_LL_DATA_MAX_BIT_LEN (1 << 23) + /** * The data structure holding calculated clock configuration. Since the * calculation needs long time, it should be calculated during initialization and diff --git a/tools/sdk/esp32s2/include/hal/include/hal/cpu_hal.h b/tools/sdk/esp32s2/include/hal/include/hal/cpu_hal.h index 824095871db..0e7e6f53a79 100644 --- a/tools/sdk/esp32s2/include/hal/include/hal/cpu_hal.h +++ b/tools/sdk/esp32s2/include/hal/include/hal/cpu_hal.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -70,11 +70,6 @@ extern "C" { */ #define cpu_hal_waiti() cpu_ll_waiti() -/** - * Trigger a syscall. - */ -#define cpu_hal_syscall(sys_nr, arg1, arg2, arg3, arg4, ret_errno) cpu_ll_syscall(sys_nr, arg1, arg2, arg3, arg4, ret_errno) - #if SOC_CPU_BREAKPOINTS_NUM > 0 /** diff --git a/tools/sdk/esp32s2/include/hal/include/hal/lcd_types.h b/tools/sdk/esp32s2/include/hal/include/hal/lcd_types.h index 1a62d8f8eb4..13810a79ac3 100644 --- a/tools/sdk/esp32s2/include/hal/include/hal/lcd_types.h +++ b/tools/sdk/esp32s2/include/hal/include/hal/lcd_types.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -19,6 +19,8 @@ extern "C" { * +=====================+=========================+============================+ * | LCD_CLK_SRC_PLL160M | High resolution | ESP_PM_APB_FREQ_MAX lock | * +---------------------+-------------------------+----------------------------+ + * | LCD_CLK_SRC_PLL240M | High resolution | ESP_PM_APB_FREQ_MAX lock | + * +---------------------+-------------------------+----------------------------+ * | LCD_CLK_SRC_APLL | Configurable resolution | ESP_PM_NO_LIGHT_SLEEP lock | * +---------------------+-------------------------+----------------------------+ * | LCD_CLK_SRC_XTAL | Medium resolution | No PM lock | @@ -27,6 +29,7 @@ extern "C" { */ typedef enum { LCD_CLK_SRC_PLL160M, /*!< Select PLL160M as the source clock */ + LCD_CLK_SRC_PLL240M, /*!< Select PLL240M as the source clock */ LCD_CLK_SRC_APLL, /*!< Select APLL as the source clock */ LCD_CLK_SRC_XTAL, /*!< Select XTAL as the source clock */ } lcd_clock_source_t; diff --git a/tools/sdk/esp32s2/include/hal/include/hal/rtc_hal.h b/tools/sdk/esp32s2/include/hal/include/hal/rtc_hal.h index 90f965ed58c..953123ec928 100644 --- a/tools/sdk/esp32s2/include/hal/include/hal/rtc_hal.h +++ b/tools/sdk/esp32s2/include/hal/include/hal/rtc_hal.h @@ -90,3 +90,5 @@ void rtc_cntl_hal_disable_tagmem_retention(void *addr); * Enable wakeup from ULP coprocessor. */ #define rtc_hal_ulp_wakeup_enable() rtc_cntl_ll_ulp_wakeup_enable() + +#define rtc_hal_ulp_int_clear() rtc_cntl_ll_ulp_int_clear() diff --git a/tools/sdk/esp32s2/include/hal/include/hal/systimer_types.h b/tools/sdk/esp32s2/include/hal/include/hal/systimer_types.h index 2af2f60f30c..d4583dc7ae0 100644 --- a/tools/sdk/esp32s2/include/hal/include/hal/systimer_types.h +++ b/tools/sdk/esp32s2/include/hal/include/hal/systimer_types.h @@ -30,6 +30,9 @@ typedef struct { struct { uint64_t lo : SOC_SYSTIMER_BIT_WIDTH_LO; /*!< Low part of counter value */ uint64_t hi : SOC_SYSTIMER_BIT_WIDTH_HI; /*!< High part of counter value */ +#if (SOC_SYSTIMER_BIT_WIDTH_LO + SOC_SYSTIMER_BIT_WIDTH_HI) < 64 + uint64_t reserved: (64 - (SOC_SYSTIMER_BIT_WIDTH_LO + SOC_SYSTIMER_BIT_WIDTH_HI)); +#endif }; uint64_t val; /*!< counter value */ }; diff --git a/tools/sdk/esp32s2/include/json_generator/upstream/json_generator.h b/tools/sdk/esp32s2/include/json_generator/upstream/json_generator.h index e3aa92eeecf..30e6a8dca74 100644 --- a/tools/sdk/esp32s2/include/json_generator/upstream/json_generator.h +++ b/tools/sdk/esp32s2/include/json_generator/upstream/json_generator.h @@ -174,7 +174,7 @@ int json_gen_end_array(json_gen_str_t *jstr); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that */ -int json_gen_push_object(json_gen_str_t *jstr, char *name); +int json_gen_push_object(json_gen_str_t *jstr, const char *name); /** Pop a named JSON object * @@ -208,7 +208,7 @@ int json_gen_pop_object(json_gen_str_t *jstr); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that. */ -int json_gen_push_object_str(json_gen_str_t *jstr, char *name, char *object_str); +int json_gen_push_object_str(json_gen_str_t *jstr, const char *name, const char *object_str); /** Push a named JSON array * @@ -223,7 +223,7 @@ int json_gen_push_object_str(json_gen_str_t *jstr, char *name, char *object_str) * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that */ -int json_gen_push_array(json_gen_str_t *jstr, char *name); +int json_gen_push_array(json_gen_str_t *jstr, const char *name); /** Pop a named JSON array * @@ -257,7 +257,7 @@ int json_gen_pop_array(json_gen_str_t *jstr); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that. */ -int json_gen_push_array_str(json_gen_str_t *jstr, char *name, char *array_str); +int json_gen_push_array_str(json_gen_str_t *jstr, const char *name, const char *array_str); /** Add a boolean element to an object * @@ -276,7 +276,7 @@ int json_gen_push_array_str(json_gen_str_t *jstr, char *name, char *array_str); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that */ -int json_gen_obj_set_bool(json_gen_str_t *jstr, char *name, bool val); +int json_gen_obj_set_bool(json_gen_str_t *jstr, const char *name, bool val); /** Add an integer element to an object * @@ -295,7 +295,7 @@ int json_gen_obj_set_bool(json_gen_str_t *jstr, char *name, bool val); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that */ -int json_gen_obj_set_int(json_gen_str_t *jstr, char *name, int val); +int json_gen_obj_set_int(json_gen_str_t *jstr, const char *name, int val); /** Add a float element to an object * @@ -314,7 +314,7 @@ int json_gen_obj_set_int(json_gen_str_t *jstr, char *name, int val); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that */ -int json_gen_obj_set_float(json_gen_str_t *jstr, char *name, float val); +int json_gen_obj_set_float(json_gen_str_t *jstr, const char *name, float val); /** Add a string element to an object * @@ -333,7 +333,7 @@ int json_gen_obj_set_float(json_gen_str_t *jstr, char *name, float val); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that */ -int json_gen_obj_set_string(json_gen_str_t *jstr, char *name, char *val); +int json_gen_obj_set_string(json_gen_str_t *jstr, const char *name, const char *val); /** Add a NULL element to an object * @@ -351,7 +351,7 @@ int json_gen_obj_set_string(json_gen_str_t *jstr, char *name, char *val); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that */ -int json_gen_obj_set_null(json_gen_str_t *jstr, char *name); +int json_gen_obj_set_null(json_gen_str_t *jstr, const char *name); /** Add a boolean element to an array * @@ -415,7 +415,7 @@ int json_gen_arr_set_float(json_gen_str_t *jstr, float val); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that */ -int json_gen_arr_set_string(json_gen_str_t *jstr, char *val); +int json_gen_arr_set_string(json_gen_str_t *jstr, const char *val); /** Add a NULL element to an array * @@ -452,7 +452,7 @@ int json_gen_arr_set_null(json_gen_str_t *jstr); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that */ -int json_gen_obj_start_long_string(json_gen_str_t *jstr, char *name, char *val); +int json_gen_obj_start_long_string(json_gen_str_t *jstr, const char *name, const char *val); /** Start a Long string in an array * @@ -473,7 +473,7 @@ int json_gen_obj_start_long_string(json_gen_str_t *jstr, char *name, char *val); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that */ -int json_gen_arr_start_long_string(json_gen_str_t *jstr, char *val); +int json_gen_arr_start_long_string(json_gen_str_t *jstr, const char *val); /** Add to a JSON Long string * @@ -489,7 +489,7 @@ int json_gen_arr_start_long_string(json_gen_str_t *jstr, char *val); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that */ -int json_gen_add_to_long_string(json_gen_str_t *jstr, char *val); +int json_gen_add_to_long_string(json_gen_str_t *jstr, const char *val); /** End a JSON Long string * diff --git a/tools/sdk/esp32s2/include/json_parser/upstream/include/json_parser.h b/tools/sdk/esp32s2/include/json_parser/upstream/include/json_parser.h index 3e982fe14eb..8e92fe7d63f 100644 --- a/tools/sdk/esp32s2/include/json_parser/upstream/include/json_parser.h +++ b/tools/sdk/esp32s2/include/json_parser/upstream/include/json_parser.h @@ -16,6 +16,7 @@ #ifndef _JSON_PARSER_H_ #define _JSON_PARSER_H_ +#define JSMN_PARENT_LINKS #define JSMN_HEADER #include #include @@ -34,29 +35,31 @@ typedef jsmntok_t json_tok_t; typedef struct { json_parser_t parser; - char *js; + const char *js; json_tok_t *tokens; json_tok_t *cur; int num_tokens; } jparse_ctx_t; -int json_parse_start(jparse_ctx_t *jctx, char *js, int len); +int json_parse_start(jparse_ctx_t *jctx, const char *js, int len); int json_parse_end(jparse_ctx_t *jctx); +int json_parse_start_static(jparse_ctx_t *jctx, const char *js, int len, json_tok_t *buffer_tokens, int buffer_tokens_max_count); +int json_parse_end_static(jparse_ctx_t *jctx); -int json_obj_get_array(jparse_ctx_t *jctx, char *name, int *num_elem); +int json_obj_get_array(jparse_ctx_t *jctx, const char *name, int *num_elem); int json_obj_leave_array(jparse_ctx_t *jctx); -int json_obj_get_object(jparse_ctx_t *jctx, char *name); +int json_obj_get_object(jparse_ctx_t *jctx, const char *name); int json_obj_leave_object(jparse_ctx_t *jctx); -int json_obj_get_bool(jparse_ctx_t *jctx, char *name, bool *val); -int json_obj_get_int(jparse_ctx_t *jctx, char *name, int *val); -int json_obj_get_int64(jparse_ctx_t *jctx, char *name, int64_t *val); -int json_obj_get_float(jparse_ctx_t *jctx, char *name, float *val); -int json_obj_get_string(jparse_ctx_t *jctx, char *name, char *val, int size); -int json_obj_get_strlen(jparse_ctx_t *jctx, char *name, int *strlen); -int json_obj_get_object_str(jparse_ctx_t *jctx, char *name, char *val, int size); -int json_obj_get_object_strlen(jparse_ctx_t *jctx, char *name, int *strlen); -int json_obj_get_array_str(jparse_ctx_t *jctx, char *name, char *val, int size); -int json_obj_get_array_strlen(jparse_ctx_t *jctx, char *name, int *strlen); +int json_obj_get_bool(jparse_ctx_t *jctx, const char *name, bool *val); +int json_obj_get_int(jparse_ctx_t *jctx, const char *name, int *val); +int json_obj_get_int64(jparse_ctx_t *jctx, const char *name, int64_t *val); +int json_obj_get_float(jparse_ctx_t *jctx, const char *name, float *val); +int json_obj_get_string(jparse_ctx_t *jctx, const char *name, char *val, int size); +int json_obj_get_strlen(jparse_ctx_t *jctx, const char *name, int *strlen); +int json_obj_get_object_str(jparse_ctx_t *jctx, const char *name, char *val, int size); +int json_obj_get_object_strlen(jparse_ctx_t *jctx, const char *name, int *strlen); +int json_obj_get_array_str(jparse_ctx_t *jctx, const char *name, char *val, int size); +int json_obj_get_array_strlen(jparse_ctx_t *jctx, const char *name, int *strlen); int json_arr_get_array(jparse_ctx_t *jctx, uint32_t index); int json_arr_leave_array(jparse_ctx_t *jctx); @@ -74,3 +77,4 @@ int json_arr_get_strlen(jparse_ctx_t *jctx, uint32_t index, int *strlen); #endif #endif /* _JSON_PARSER_H_ */ + diff --git a/tools/sdk/esp32s2/include/lwip/lwip/src/include/lwip/dns.h b/tools/sdk/esp32s2/include/lwip/lwip/src/include/lwip/dns.h index db52fedd1da..7c9933eaa32 100644 --- a/tools/sdk/esp32s2/include/lwip/lwip/src/include/lwip/dns.h +++ b/tools/sdk/esp32s2/include/lwip/lwip/src/include/lwip/dns.h @@ -113,6 +113,7 @@ err_t dns_gethostbyname_addrtype(const char *hostname, ip_addr_t *add u8_t dns_addrtype); #if ESP_DNS void dns_clear_servers(bool keep_fallback); +void dns_clear_cache(void); #endif #if DNS_LOCAL_HOSTLIST diff --git a/tools/sdk/esp32s2/include/lwip/lwip/src/include/lwip/init.h b/tools/sdk/esp32s2/include/lwip/lwip/src/include/lwip/init.h index c7f3eb99cbb..921573618d7 100644 --- a/tools/sdk/esp32s2/include/lwip/lwip/src/include/lwip/init.h +++ b/tools/sdk/esp32s2/include/lwip/lwip/src/include/lwip/init.h @@ -54,7 +54,7 @@ extern "C" { /** x.X.x: Minor version of the stack */ #define LWIP_VERSION_MINOR 1 /** x.x.X: Revision of the stack */ -#define LWIP_VERSION_REVISION 3 +#define LWIP_VERSION_REVISION 2 /** For release candidates, this is set to 1..254 * For official releases, this is set to 255 (LWIP_RC_RELEASE) * For development versions (Git), this is set to 0 (LWIP_RC_DEVELOPMENT) */ @@ -75,7 +75,7 @@ extern "C" { #if LWIP_VERSION_IS_RELEASE #define LWIP_VERSION_STRING_SUFFIX "" #elif LWIP_VERSION_IS_DEVELOPMENT -#define LWIP_VERSION_STRING_SUFFIX "d" +#define LWIP_VERSION_STRING_SUFFIX "esp" #else #define LWIP_VERSION_STRING_SUFFIX "rc" LWIP_VERSTR(LWIP_VERSION_RC) #endif diff --git a/tools/sdk/esp32s2/include/lwip/lwip/src/include/lwip/opt.h b/tools/sdk/esp32s2/include/lwip/lwip/src/include/lwip/opt.h index cdd7044c728..b314c59a439 100644 --- a/tools/sdk/esp32s2/include/lwip/lwip/src/include/lwip/opt.h +++ b/tools/sdk/esp32s2/include/lwip/lwip/src/include/lwip/opt.h @@ -2534,10 +2534,12 @@ /** * LWIP_ICMP6_DATASIZE: bytes from original packet to send back in - * ICMPv6 error messages. + * ICMPv6 error messages (0 = default of IP6_MIN_MTU_LENGTH) + * ATTENTION: RFC4443 section 2.4 says IP6_MIN_MTU_LENGTH is a MUST, + * so override this only if you absolutely have to! */ #if !defined LWIP_ICMP6_DATASIZE || defined __DOXYGEN__ -#define LWIP_ICMP6_DATASIZE 8 +#define LWIP_ICMP6_DATASIZE 0 #endif /** diff --git a/tools/sdk/esp32s2/include/lwip/lwip/src/include/lwip/pbuf.h b/tools/sdk/esp32s2/include/lwip/lwip/src/include/lwip/pbuf.h index deac38dcc47..2eedb956ee8 100644 --- a/tools/sdk/esp32s2/include/lwip/lwip/src/include/lwip/pbuf.h +++ b/tools/sdk/esp32s2/include/lwip/lwip/src/include/lwip/pbuf.h @@ -300,6 +300,7 @@ void pbuf_cat(struct pbuf *head, struct pbuf *tail); void pbuf_chain(struct pbuf *head, struct pbuf *tail); struct pbuf *pbuf_dechain(struct pbuf *p); err_t pbuf_copy(struct pbuf *p_to, const struct pbuf *p_from); +err_t pbuf_copy_partial_pbuf(struct pbuf *p_to, const struct pbuf *p_from, u16_t copy_len, u16_t offset); u16_t pbuf_copy_partial(const struct pbuf *p, void *dataptr, u16_t len, u16_t offset); void *pbuf_get_contiguous(const struct pbuf *p, void *buffer, size_t bufsize, u16_t len, u16_t offset); err_t pbuf_take(struct pbuf *buf, const void *dataptr, u16_t len); diff --git a/tools/sdk/esp32s2/include/lwip/lwip/src/include/lwip/prot/icmp6.h b/tools/sdk/esp32s2/include/lwip/lwip/src/include/lwip/prot/icmp6.h index 3461120421e..36989f6b32a 100644 --- a/tools/sdk/esp32s2/include/lwip/lwip/src/include/lwip/prot/icmp6.h +++ b/tools/sdk/esp32s2/include/lwip/lwip/src/include/lwip/prot/icmp6.h @@ -146,6 +146,8 @@ PACK_STRUCT_END # include "arch/epstruct.h" #endif +#define ICMP6_HLEN 8 + /** This is the ICMP6 header adapted for echo req/resp. */ #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/bpstruct.h" diff --git a/tools/sdk/esp32s2/include/lwip/lwip/src/include/lwip/prot/ip6.h b/tools/sdk/esp32s2/include/lwip/lwip/src/include/lwip/prot/ip6.h index 0f6de455932..7df81edd690 100644 --- a/tools/sdk/esp32s2/include/lwip/lwip/src/include/lwip/prot/ip6.h +++ b/tools/sdk/esp32s2/include/lwip/lwip/src/include/lwip/prot/ip6.h @@ -44,6 +44,8 @@ extern "C" { #endif +#define IP6_MIN_MTU_LENGTH 1280 + /** This is the packed version of ip6_addr_t, used in network headers that are itself packed */ #ifdef PACK_STRUCT_USE_INCLUDES diff --git a/tools/sdk/esp32s2/include/lwip/port/esp32/include/lwipopts.h b/tools/sdk/esp32s2/include/lwip/port/esp32/include/lwipopts.h index 47215e99dae..bb0d371c6ee 100644 --- a/tools/sdk/esp32s2/include/lwip/port/esp32/include/lwipopts.h +++ b/tools/sdk/esp32s2/include/lwip/port/esp32/include/lwipopts.h @@ -1007,6 +1007,7 @@ #define ESP_LWIP_SELECT 1 #define ESP_LWIP_LOCK 1 #define ESP_THREAD_PROTECTION 1 +#define ESP_IP_FORWARD 1 #ifdef CONFIG_LWIP_IPV6_AUTOCONFIG #define ESP_IPV6_AUTOCONFIG CONFIG_LWIP_IPV6_AUTOCONFIG diff --git a/tools/sdk/esp32s2/include/mbedtls/esp_crt_bundle/include/esp_crt_bundle.h b/tools/sdk/esp32s2/include/mbedtls/esp_crt_bundle/include/esp_crt_bundle.h index 33fb98b9969..49069185b3a 100644 --- a/tools/sdk/esp32s2/include/mbedtls/esp_crt_bundle/include/esp_crt_bundle.h +++ b/tools/sdk/esp32s2/include/mbedtls/esp_crt_bundle/include/esp_crt_bundle.h @@ -1,21 +1,14 @@ -// 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. +/* + * SPDX-FileCopyrightText: 2017-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ESP_CRT_BUNDLE_H_ #define _ESP_CRT_BUNDLE_H_ +#include "esp_err.h" #include "mbedtls/ssl.h" #ifdef __cplusplus @@ -52,13 +45,19 @@ void esp_crt_bundle_detach(mbedtls_ssl_config *conf); /** * @brief Set the default certificate bundle used for verification * - * Overrides the default certificate bundle. In most use cases the bundle should be + * Overrides the default certificate bundle only in case of successful initialization. In most use cases the bundle should be * set through menuconfig. The bundle needs to be sorted by subject name since binary search is * used to find certificates. * * @param[in] x509_bundle A pointer to the certificate bundle. + * + * @param[in] bundle_size Size of the certificate bundle in bytes. + * + * @return + * - ESP_OK if adding certificates was successful. + * - Other if an error occured or an action must be taken by the calling process. */ -void esp_crt_bundle_set(const uint8_t *x509_bundle); +esp_err_t esp_crt_bundle_set(const uint8_t *x509_bundle, size_t bundle_size); #ifdef __cplusplus diff --git a/tools/sdk/esp32s2/include/mqtt/esp-mqtt/include/mqtt_client.h b/tools/sdk/esp32s2/include/mqtt/esp-mqtt/include/mqtt_client.h index 475581b50db..07feed3c370 100644 --- a/tools/sdk/esp32s2/include/mqtt/esp-mqtt/include/mqtt_client.h +++ b/tools/sdk/esp32s2/include/mqtt/esp-mqtt/include/mqtt_client.h @@ -39,7 +39,11 @@ typedef enum { MQTT_EVENT_ERROR = 0, /*!< on error event, additional context: connection return code, error handle from esp_tls (if supported) */ MQTT_EVENT_CONNECTED, /*!< connected event, additional context: session_present flag */ MQTT_EVENT_DISCONNECTED, /*!< disconnected event */ - MQTT_EVENT_SUBSCRIBED, /*!< subscribed event, additional context: msg_id */ + MQTT_EVENT_SUBSCRIBED, /*!< subscribed event, additional context: + - msg_id message id + - data pointer to the received data + - data_len length of the data for this event + */ MQTT_EVENT_UNSUBSCRIBED, /*!< unsubscribed event */ MQTT_EVENT_PUBLISHED, /*!< published event, additional context: msg_id */ MQTT_EVENT_DATA, /*!< data event, additional context: @@ -51,6 +55,8 @@ typedef enum { - current_data_offset offset of the current data for this event - total_data_len total length of the data received - retain retain flag of the message + - qos qos level of the message + - dup dup flag of the message Note: Multiple MQTT_EVENT_DATA could be fired for one message, if it is longer than internal buffer. In that case only first event contains topic pointer and length, other contain data only with current data length @@ -153,6 +159,8 @@ typedef struct { int session_present; /*!< MQTT session_present flag for connection event */ esp_mqtt_error_codes_t *error_handle; /*!< esp-mqtt error handle including esp-tls errors as well as internal mqtt errors */ bool retain; /*!< Retained flag of the message associated with this event */ + int qos; /*!< qos of the messages associated with this event */ + bool dup; /*!< dup flag of the message associated with this event */ } esp_mqtt_event_t; typedef esp_mqtt_event_t *esp_mqtt_event_handle_t; @@ -168,7 +176,11 @@ typedef struct { const char *host; /*!< MQTT server domain (ipv4 as string) */ const char *uri; /*!< Complete MQTT broker URI */ uint32_t port; /*!< MQTT server port */ - const char *client_id; /*!< default client id is ``ESP32_%CHIPID%`` where %CHIPID% are last 3 bytes of MAC address in hex format */ + bool set_null_client_id; /*!< Selects a NULL client id */ + const char *client_id; /*!< Set client id. + Ignored if set_null_client_id == true + If NULL set the default client id. + Default client id is ``ESP32_%CHIPID%`` where %CHIPID% are last 3 bytes of MAC address in hex format */ const char *username; /*!< MQTT username */ const char *password; /*!< MQTT password */ const char *lwt_topic; /*!< LWT (Last Will and Testament) message topic (NULL by default) */ diff --git a/tools/sdk/esp32s2/include/newlib/platform_include/errno.h b/tools/sdk/esp32s2/include/newlib/platform_include/errno.h index 85fb2e15b85..98dedeef88a 100644 --- a/tools/sdk/esp32s2/include/newlib/platform_include/errno.h +++ b/tools/sdk/esp32s2/include/newlib/platform_include/errno.h @@ -1,17 +1,9 @@ -// Copyright 2018 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. +/* + * SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ESP_PLATFORM_ERRNO_H_ #define _ESP_PLATFORM_ERRNO_H_ @@ -21,7 +13,7 @@ // Possibly define some missing errors // #ifndef ESHUTDOWN -#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ +#define ESHUTDOWN 110 /* Cannot send after transport endpoint shutdown */ #endif #ifndef EAI_SOCKTYPE diff --git a/tools/sdk/esp32s2/include/nvs_flash/include/nvs.h b/tools/sdk/esp32s2/include/nvs_flash/include/nvs.h index 6a45327bbae..0faef98fd3d 100644 --- a/tools/sdk/esp32s2/include/nvs_flash/include/nvs.h +++ b/tools/sdk/esp32s2/include/nvs_flash/include/nvs.h @@ -40,7 +40,7 @@ typedef nvs_handle_t nvs_handle IDF_DEPRECATED("Replace with nvs_handle_t"); #define ESP_ERR_NVS_INVALID_STATE (ESP_ERR_NVS_BASE + 0x0b) /*!< NVS is in an inconsistent state due to a previous error. Call nvs_flash_init and nvs_open again, then retry. */ #define ESP_ERR_NVS_INVALID_LENGTH (ESP_ERR_NVS_BASE + 0x0c) /*!< String or blob length is not sufficient to store data */ #define ESP_ERR_NVS_NO_FREE_PAGES (ESP_ERR_NVS_BASE + 0x0d) /*!< NVS partition doesn't contain any empty pages. This may happen if NVS partition was truncated. Erase the whole partition and call nvs_flash_init again. */ -#define ESP_ERR_NVS_VALUE_TOO_LONG (ESP_ERR_NVS_BASE + 0x0e) /*!< String or blob length is longer than supported by the implementation */ +#define ESP_ERR_NVS_VALUE_TOO_LONG (ESP_ERR_NVS_BASE + 0x0e) /*!< Value doesn't fit into the entry or string or blob length is longer than supported by the implementation */ #define ESP_ERR_NVS_PART_NOT_FOUND (ESP_ERR_NVS_BASE + 0x0f) /*!< Partition with specified name is not found in the partition table */ #define ESP_ERR_NVS_NEW_VERSION_FOUND (ESP_ERR_NVS_BASE + 0x10) /*!< NVS partition contains data in new format and cannot be recognized by this version of code */ @@ -124,6 +124,8 @@ typedef struct nvs_opaque_iterator_t *nvs_iterator_t; * * @return * - ESP_OK if storage handle was opened successfully + * - ESP_FAIL if there is an internal error; most likely due to corrupted + * NVS partition (only if NVS assertion checks are disabled) * - ESP_ERR_NVS_NOT_INITIALIZED if the storage driver is not initialized * - ESP_ERR_NVS_PART_NOT_FOUND if the partition with label "nvs" is not found * - ESP_ERR_NVS_NOT_FOUND id namespace doesn't exist yet and @@ -151,6 +153,8 @@ esp_err_t nvs_open(const char* name, nvs_open_mode_t open_mode, nvs_handle_t *ou * * @return * - ESP_OK if storage handle was opened successfully + * - ESP_FAIL if there is an internal error; most likely due to corrupted + * NVS partition (only if NVS assertion checks are disabled) * - ESP_ERR_NVS_NOT_INITIALIZED if the storage driver is not initialized * - ESP_ERR_NVS_PART_NOT_FOUND if the partition with specified name is not found * - ESP_ERR_NVS_NOT_FOUND id namespace doesn't exist yet and @@ -175,6 +179,8 @@ esp_err_t nvs_open_from_partition(const char *part_name, const char* name, nvs_o * * @return * - ESP_OK if value was set successfully + * - ESP_FAIL if there is an internal error; most likely due to corrupted + * NVS partition (only if NVS assertion checks are disabled) * - ESP_ERR_NVS_INVALID_HANDLE if handle has been closed or is NULL * - ESP_ERR_NVS_READ_ONLY if storage handle was opened as read only * - ESP_ERR_NVS_INVALID_NAME if key name doesn't satisfy constraints @@ -282,6 +288,8 @@ esp_err_t nvs_set_str (nvs_handle_t handle, const char* key, const char* value); * * @return * - ESP_OK if value was set successfully + * - ESP_FAIL if there is an internal error; most likely due to corrupted + * NVS partition (only if NVS assertion checks are disabled) * - ESP_ERR_NVS_INVALID_HANDLE if handle has been closed or is NULL * - ESP_ERR_NVS_READ_ONLY if storage handle was opened as read only * - ESP_ERR_NVS_INVALID_NAME if key name doesn't satisfy constraints @@ -325,6 +333,8 @@ esp_err_t nvs_set_blob(nvs_handle_t handle, const char* key, const void* value, * * @return * - ESP_OK if the value was retrieved successfully + * - ESP_FAIL if there is an internal error; most likely due to corrupted + * NVS partition (only if NVS assertion checks are disabled) * - ESP_ERR_NVS_NOT_FOUND if the requested key doesn't exist * - ESP_ERR_NVS_INVALID_HANDLE if handle has been closed or is NULL * - ESP_ERR_NVS_INVALID_NAME if key name doesn't satisfy constraints @@ -432,6 +442,8 @@ esp_err_t nvs_get_u64 (nvs_handle_t handle, const char* key, uint64_t* out_value * * @return * - ESP_OK if the value was retrieved successfully + * - ESP_FAIL if there is an internal error; most likely due to corrupted + * NVS partition (only if NVS assertion checks are disabled) * - ESP_ERR_NVS_NOT_FOUND if the requested key doesn't exist * - ESP_ERR_NVS_INVALID_HANDLE if handle has been closed or is NULL * - ESP_ERR_NVS_INVALID_NAME if key name doesn't satisfy constraints @@ -459,6 +471,8 @@ esp_err_t nvs_get_blob(nvs_handle_t handle, const char* key, void* out_value, si * * @return * - ESP_OK if erase operation was successful + * - ESP_FAIL if there is an internal error; most likely due to corrupted + * NVS partition (only if NVS assertion checks are disabled) * - ESP_ERR_NVS_INVALID_HANDLE if handle has been closed or is NULL * - ESP_ERR_NVS_READ_ONLY if handle was opened as read only * - ESP_ERR_NVS_NOT_FOUND if the requested key doesn't exist @@ -476,6 +490,8 @@ esp_err_t nvs_erase_key(nvs_handle_t handle, const char* key); * * @return * - ESP_OK if erase operation was successful + * - ESP_FAIL if there is an internal error; most likely due to corrupted + * NVS partition (only if NVS assertion checks are disabled) * - ESP_ERR_NVS_INVALID_HANDLE if handle has been closed or is NULL * - ESP_ERR_NVS_READ_ONLY if handle was opened as read only * - other error codes from the underlying storage driver diff --git a/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protobuf-c/protobuf-c.h b/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protobuf-c/protobuf-c.h index c8fa4fc2a7c..b633722ed5e 100755 --- a/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protobuf-c/protobuf-c.h +++ b/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protobuf-c/protobuf-c.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008-2017, Dave Benson and the protobuf-c authors. + * Copyright (c) 2008-2018, Dave Benson and the protobuf-c authors. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -238,7 +238,11 @@ PROTOBUF_C__BEGIN_DECLS #define PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC 0x114315af /* Empty string used for initializers */ +#if defined(_WIN32) && defined(PROTOBUF_C_USE_SHARED_LIB) +static const char protobuf_c_empty_string[] = ""; +#else extern const char protobuf_c_empty_string[]; +#endif /** * \defgroup api Public API @@ -790,13 +794,13 @@ protobuf_c_version_number(void); * The version of the protobuf-c headers, represented as a string using the same * format as protobuf_c_version(). */ -#define PROTOBUF_C_VERSION "1.3.0" +#define PROTOBUF_C_VERSION "1.4.0" /** * The version of the protobuf-c headers, represented as an integer using the * same format as protobuf_c_version_number(). */ -#define PROTOBUF_C_VERSION_NUMBER 1003000 +#define PROTOBUF_C_VERSION_NUMBER 1004000 /** * The minimum protoc-c version which works with the current version of the diff --git a/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_bytes_field.h b/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_bytes_field.h index c4a71e85b47..bf873f0f763 100644 --- a/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_bytes_field.h +++ b/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_bytes_field.h @@ -82,11 +82,11 @@ class BytesFieldGenerator : public FieldGenerator { void GenerateDescriptorInitializer(io::Printer* printer) const; void GenerateDefaultValueDeclarations(io::Printer* printer) const; void GenerateDefaultValueImplementations(io::Printer* printer) const; - string GetDefaultValue(void) const; + std::string GetDefaultValue(void) const; void GenerateStaticInit(io::Printer* printer) const; private: - std::map variables_; + std::map variables_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(BytesFieldGenerator); }; diff --git a/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_enum.h b/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_enum.h index 9eb9a6679ce..9c34b697b82 100644 --- a/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_enum.h +++ b/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_enum.h @@ -81,7 +81,7 @@ class EnumGenerator { public: // See generator.cc for the meaning of dllexport_decl. explicit EnumGenerator(const EnumDescriptor* descriptor, - const string& dllexport_decl); + const std::string& dllexport_decl); ~EnumGenerator(); // Header stuff. @@ -105,7 +105,7 @@ class EnumGenerator { private: const EnumDescriptor* descriptor_; - string dllexport_decl_; + std::string dllexport_decl_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumGenerator); }; diff --git a/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_enum_field.h b/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_enum_field.h index 11df6824693..3f8c005d320 100644 --- a/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_enum_field.h +++ b/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_enum_field.h @@ -80,11 +80,11 @@ class EnumFieldGenerator : public FieldGenerator { // implements FieldGenerator --------------------------------------- void GenerateStructMembers(io::Printer* printer) const; void GenerateDescriptorInitializer(io::Printer* printer) const; - string GetDefaultValue(void) const; + std::string GetDefaultValue(void) const; void GenerateStaticInit(io::Printer* printer) const; private: - std::map variables_; + std::map variables_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumFieldGenerator); }; diff --git a/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_extension.h b/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_extension.h index ddbf270e5a1..95413885342 100644 --- a/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_extension.h +++ b/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_extension.h @@ -85,7 +85,7 @@ class ExtensionGenerator { public: // See generator.cc for the meaning of dllexport_decl. explicit ExtensionGenerator(const FieldDescriptor* descriptor, - const string& dllexport_decl); + const std::string& dllexport_decl); ~ExtensionGenerator(); // Header stuff. @@ -96,8 +96,8 @@ class ExtensionGenerator { private: const FieldDescriptor* descriptor_; - string type_traits_; - string dllexport_decl_; + std::string type_traits_; + std::string dllexport_decl_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ExtensionGenerator); }; diff --git a/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_field.h b/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_field.h index 91f1a03dafb..3cad35d3979 100644 --- a/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_field.h +++ b/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_field.h @@ -63,6 +63,7 @@ #ifndef GOOGLE_PROTOBUF_COMPILER_C_FIELD_H__ #define GOOGLE_PROTOBUF_COMPILER_C_FIELD_H__ +#include #include #include @@ -90,7 +91,7 @@ class FieldGenerator { virtual void GenerateDefaultValueDeclarations(io::Printer* printer) const { } virtual void GenerateDefaultValueImplementations(io::Printer* printer) const { } - virtual string GetDefaultValue() const = 0; + virtual std::string GetDefaultValue() const = 0; // Generate members to initialize this field from a static initializer virtual void GenerateStaticInit(io::Printer* printer) const = 0; @@ -99,8 +100,8 @@ class FieldGenerator { protected: void GenerateDescriptorInitializerGeneric(io::Printer* printer, bool optional_uses_has, - const string &type_macro, - const string &descriptor_addr) const; + const std::string &type_macro, + const std::string &descriptor_addr) const; const FieldDescriptor *descriptor_; private: @@ -117,7 +118,7 @@ class FieldGeneratorMap { private: const Descriptor* descriptor_; - scoped_array > field_generators_; + std::unique_ptr[]> field_generators_; static FieldGenerator* MakeGenerator(const FieldDescriptor* field); diff --git a/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_file.h b/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_file.h index ed38ce425c3..8dfd8ba0984 100644 --- a/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_file.h +++ b/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_file.h @@ -63,6 +63,7 @@ #ifndef GOOGLE_PROTOBUF_COMPILER_C_FILE_H__ #define GOOGLE_PROTOBUF_COMPILER_C_FILE_H__ +#include #include #include #include @@ -89,7 +90,7 @@ class FileGenerator { public: // See generator.cc for the meaning of dllexport_decl. explicit FileGenerator(const FileDescriptor* file, - const string& dllexport_decl); + const std::string& dllexport_decl); ~FileGenerator(); void GenerateHeader(io::Printer* printer); @@ -98,13 +99,10 @@ class FileGenerator { private: const FileDescriptor* file_; - scoped_array > message_generators_; - scoped_array > enum_generators_; - scoped_array > service_generators_; - scoped_array > extension_generators_; - - // E.g. if the package is foo.bar, package_parts_ is {"foo", "bar"}. - vector package_parts_; + std::unique_ptr[]> message_generators_; + std::unique_ptr[]> enum_generators_; + std::unique_ptr[]> service_generators_; + std::unique_ptr[]> extension_generators_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileGenerator); }; diff --git a/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_generator.h b/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_generator.h index f454710b36f..ac1ffafeab3 100644 --- a/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_generator.h +++ b/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_generator.h @@ -68,6 +68,12 @@ #include #include +#if defined(_WIN32) && defined(PROTOBUF_C_USE_SHARED_LIB) +# define PROTOC_C_EXPORT __declspec(dllexport) +#else +# define PROTOC_C_EXPORT +#endif + namespace google { namespace protobuf { namespace compiler { @@ -77,16 +83,16 @@ namespace c { // header. If you create your own protocol compiler binary and you want // it to support C++ output, you can do so by registering an instance of this // CodeGenerator with the CommandLineInterface in your main() function. -class LIBPROTOC_EXPORT CGenerator : public CodeGenerator { +class PROTOC_C_EXPORT CGenerator : public CodeGenerator { public: CGenerator(); ~CGenerator(); // implements CodeGenerator ---------------------------------------- bool Generate(const FileDescriptor* file, - const string& parameter, + const std::string& parameter, OutputDirectory* output_directory, - string* error) const; + std::string* error) const; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CGenerator); diff --git a/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_helpers.h b/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_helpers.h index 9dc8c5e859c..7598a4e1da5 100644 --- a/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_helpers.h +++ b/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_helpers.h @@ -67,7 +67,7 @@ #include #include #include -#include +#include #include namespace google { @@ -75,31 +75,20 @@ namespace protobuf { namespace compiler { namespace c { -// Returns the non-nested type name for the given type. If "qualified" is -// true, prefix the type with the full namespace. For example, if you had: -// package foo.bar; -// message Baz { message Qux {} } -// Then the qualified ClassName for Qux would be: -// Foo__Bar__Baz_Qux -// While the non-qualified version would be: -// Baz_Qux -string ClassName(const Descriptor* descriptor, bool qualified); -string ClassName(const EnumDescriptor* enum_descriptor, bool qualified); - // --- Borrowed from stubs. --- -template string SimpleItoa(T n) { +template std::string SimpleItoa(T n) { std::stringstream stream; stream << n; return stream.str(); } -string SimpleFtoa(float f); -string SimpleDtoa(double f); -void SplitStringUsing(const string &str, const char *delim, std::vector *out); -string CEscape(const string& src); -string StringReplace(const string& s, const string& oldsub, const string& newsub, bool replace_all); -inline bool HasSuffixString(const string& str, const string& suffix) { return str.size() >= suffix.size() && str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0; } -inline string StripSuffixString(const string& str, const string& suffix) { if (HasSuffixString(str, suffix)) { return str.substr(0, str.size() - suffix.size()); } else { return str; } } +std::string SimpleFtoa(float f); +std::string SimpleDtoa(double f); +void SplitStringUsing(const std::string &str, const char *delim, std::vector *out); +std::string CEscape(const std::string& src); +std::string StringReplace(const std::string& s, const std::string& oldsub, const std::string& newsub, bool replace_all); +inline bool HasSuffixString(const std::string& str, const std::string& suffix) { return str.size() >= suffix.size() && str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0; } +inline std::string StripSuffixString(const std::string& str, const std::string& suffix) { if (HasSuffixString(str, suffix)) { return str.substr(0, str.size() - suffix.size()); } else { return str; } } char* FastHexToBuffer(int i, char* buffer); @@ -107,10 +96,10 @@ char* FastHexToBuffer(int i, char* buffer); // The name is coerced to lower-case to emulate proto1 behavior. People // should be using lowercase-with-underscores style for proto field names // anyway, so normally this just returns field->name(). -string FieldName(const FieldDescriptor* field); +std::string FieldName(const FieldDescriptor* field); // Get macro string for deprecated field -string FieldDeprecated(const FieldDescriptor* field); +std::string FieldDeprecated(const FieldDescriptor* field); // Returns the scope where the field was defined (for extensions, this is // different from the message type to which the field applies). @@ -121,31 +110,31 @@ inline const Descriptor* FieldScope(const FieldDescriptor* field) { // convert a CamelCase class name into an all uppercase affair // with underscores separating words, e.g. MyClass becomes MY_CLASS. -string CamelToUpper(const string &class_name); -string CamelToLower(const string &class_name); +std::string CamelToUpper(const std::string &class_name); +std::string CamelToLower(const std::string &class_name); // lowercased, underscored name to camel case -string ToCamel(const string &name); +std::string ToCamel(const std::string &name); // lowercase the string -string ToLower(const string &class_name); -string ToUpper(const string &class_name); +std::string ToLower(const std::string &class_name); +std::string ToUpper(const std::string &class_name); // full_name() to lowercase with underscores -string FullNameToLower(const string &full_name); -string FullNameToUpper(const string &full_name); +std::string FullNameToLower(const std::string &full_name, const FileDescriptor *file); +std::string FullNameToUpper(const std::string &full_name, const FileDescriptor *file); // full_name() to c-typename (with underscores for packages, otherwise camel case) -string FullNameToC(const string &class_name); +std::string FullNameToC(const std::string &class_name, const FileDescriptor *file); // Splits, indents, formats, and prints comment lines -void PrintComment (io::Printer* printer, string comment); +void PrintComment (io::Printer* printer, std::string comment); // make a string of spaces as long as input -string ConvertToSpaces(const string &input); +std::string ConvertToSpaces(const std::string &input); // Strips ".proto" or ".protodevel" from the end of a filename. -string StripProto(const string& filename); +std::string StripProto(const std::string& filename); // Get the C++ type name for a primitive type (e.g. "double", "::google::protobuf::int32", etc.). // Note: non-built-in type names will be qualified, meaning they will start @@ -159,18 +148,18 @@ const char* PrimitiveTypeName(FieldDescriptor::CppType type); const char* DeclaredTypeMethodName(FieldDescriptor::Type type); // Convert a file name into a valid identifier. -string FilenameIdentifier(const string& filename); +std::string FilenameIdentifier(const std::string& filename); // Return the name of the BuildDescriptors() function for a given file. -string GlobalBuildDescriptorsName(const string& filename); +std::string GlobalBuildDescriptorsName(const std::string& filename); // return 'required', 'optional', or 'repeated' -string GetLabelName(FieldDescriptor::Label label); +std::string GetLabelName(FieldDescriptor::Label label); // write IntRanges entries for a bunch of sorted values. // returns the number of ranges there are to bsearch. -unsigned WriteIntRanges(io::Printer* printer, int n_values, const int *values, const string &name); +unsigned WriteIntRanges(io::Printer* printer, int n_values, const int *values, const std::string &name); struct NameIndex { diff --git a/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_message.h b/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_message.h index 8b115d1c8cb..ea1c3ab3c8e 100644 --- a/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_message.h +++ b/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_message.h @@ -63,6 +63,7 @@ #ifndef GOOGLE_PROTOBUF_COMPILER_C_MESSAGE_H__ #define GOOGLE_PROTOBUF_COMPILER_C_MESSAGE_H__ +#include #include #include #include @@ -85,7 +86,7 @@ class MessageGenerator { public: // See generator.cc for the meaning of dllexport_decl. explicit MessageGenerator(const Descriptor* descriptor, - const string& dllexport_decl); + const std::string& dllexport_decl); ~MessageGenerator(); // Header stuff. @@ -110,25 +111,31 @@ class MessageGenerator { void GenerateStructStaticInitMacro(io::Printer* printer); // Generate standard helper functions declarations for this message. - void GenerateHelperFunctionDeclarations(io::Printer* printer, bool is_submessage); + void GenerateHelperFunctionDeclarations(io::Printer* printer, + bool is_pack_deep, + bool gen_pack, + bool gen_init); // Source file stuff. // Generate code that initializes the global variable storing the message's // descriptor. - void GenerateMessageDescriptor(io::Printer* printer); - void GenerateHelperFunctionDefinitions(io::Printer* printer, bool is_submessage); + void GenerateMessageDescriptor(io::Printer* printer, bool gen_init); + void GenerateHelperFunctionDefinitions(io::Printer* printer, + bool is_pack_deep, + bool gen_pack, + bool gen_init); private: - string GetDefaultValueC(const FieldDescriptor *fd); + std::string GetDefaultValueC(const FieldDescriptor *fd); const Descriptor* descriptor_; - string dllexport_decl_; + std::string dllexport_decl_; FieldGeneratorMap field_generators_; - scoped_array > nested_generators_; - scoped_array > enum_generators_; - scoped_array > extension_generators_; + std::unique_ptr[]> nested_generators_; + std::unique_ptr[]> enum_generators_; + std::unique_ptr[]> extension_generators_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageGenerator); }; diff --git a/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_message_field.h b/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_message_field.h index b059fb031b0..39b8d999bfa 100644 --- a/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_message_field.h +++ b/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_message_field.h @@ -80,7 +80,7 @@ class MessageFieldGenerator : public FieldGenerator { // implements FieldGenerator --------------------------------------- void GenerateStructMembers(io::Printer* printer) const; void GenerateDescriptorInitializer(io::Printer* printer) const; - string GetDefaultValue(void) const; + std::string GetDefaultValue(void) const; void GenerateStaticInit(io::Printer* printer) const; private: diff --git a/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_primitive_field.h b/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_primitive_field.h index 5ff254c5dd8..a9eb893bb72 100644 --- a/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_primitive_field.h +++ b/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_primitive_field.h @@ -80,7 +80,7 @@ class PrimitiveFieldGenerator : public FieldGenerator { // implements FieldGenerator --------------------------------------- void GenerateStructMembers(io::Printer* printer) const; void GenerateDescriptorInitializer(io::Printer* printer) const; - string GetDefaultValue(void) const; + std::string GetDefaultValue(void) const; void GenerateStaticInit(io::Printer* printer) const; private: diff --git a/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_service.h b/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_service.h index 6f1798ca724..27125a601a5 100644 --- a/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_service.h +++ b/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_service.h @@ -82,7 +82,7 @@ class ServiceGenerator { public: // See generator.cc for the meaning of dllexport_decl. explicit ServiceGenerator(const ServiceDescriptor* descriptor, - const string& dllexport_decl); + const std::string& dllexport_decl); ~ServiceGenerator(); // Header stuff. @@ -99,7 +99,7 @@ class ServiceGenerator { void GenerateCallersImplementations(io::Printer* printer); const ServiceDescriptor* descriptor_; - std::map vars_; + std::map vars_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ServiceGenerator); }; diff --git a/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_string_field.h b/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_string_field.h index 68f0d25b7dd..513cea75306 100644 --- a/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_string_field.h +++ b/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/protoc-c/c_string_field.h @@ -82,11 +82,11 @@ class StringFieldGenerator : public FieldGenerator { void GenerateDescriptorInitializer(io::Printer* printer) const; void GenerateDefaultValueDeclarations(io::Printer* printer) const; void GenerateDefaultValueImplementations(io::Printer* printer) const; - string GetDefaultValue(void) const; + std::string GetDefaultValue(void) const; void GenerateStaticInit(io::Printer* printer) const; private: - std::map variables_; + std::map variables_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StringFieldGenerator); }; diff --git a/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/t/generated-code2/common-test-arrays.h b/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/t/generated-code2/common-test-arrays.h index 1535d38e821..c5e37223c1a 100644 --- a/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/t/generated-code2/common-test-arrays.h +++ b/tools/sdk/esp32s2/include/protobuf-c/protobuf-c/t/generated-code2/common-test-arrays.h @@ -56,7 +56,7 @@ TEST_ENUM_TYPE_NAME enum_random[] = { T(0), T(2097152), T(268435455), T(127), T(16383), T(16384) }; #undef T -char *repeated_strings_0[] = { (char*)"onestring" }; -char *repeated_strings_1[] = { (char*)"two", (char*)"string" }; -char *repeated_strings_2[] = { (char*)"many", (char*)"tiny", (char*)"little", (char*)"strings", (char*)"should", (char*)"be", (char*)"handled" }; -char *repeated_strings_3[] = { (char*)"one very long strings XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" }; +const char *repeated_strings_0[] = { "onestring" }; +const char *repeated_strings_1[] = { "two", "string" }; +const char *repeated_strings_2[] = { "many", "tiny", "little", "strings", "should", "be", "handled" }; +const char *repeated_strings_3[] = { "one very long strings XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" }; diff --git a/tools/sdk/esp32s2/include/protocomm/include/transports/protocomm_ble.h b/tools/sdk/esp32s2/include/protocomm/include/transports/protocomm_ble.h index f899f95b188..2447c1c5d25 100644 --- a/tools/sdk/esp32s2/include/protocomm/include/transports/protocomm_ble.h +++ b/tools/sdk/esp32s2/include/protocomm/include/transports/protocomm_ble.h @@ -82,6 +82,9 @@ typedef struct protocomm_ble_config { /* BLE bonding */ unsigned ble_bonding:1; + /* BLE security flag */ + unsigned ble_sm_sc:1; + } protocomm_ble_config_t; /** diff --git a/tools/sdk/esp32s2/include/rmaker_common/include/esp_rmaker_mqtt_glue.h b/tools/sdk/esp32s2/include/rmaker_common/include/esp_rmaker_mqtt_glue.h index 95744bdf58c..9355d034ef4 100644 --- a/tools/sdk/esp32s2/include/rmaker_common/include/esp_rmaker_mqtt_glue.h +++ b/tools/sdk/esp32s2/include/rmaker_common/include/esp_rmaker_mqtt_glue.h @@ -155,6 +155,12 @@ typedef struct { */ esp_err_t esp_rmaker_mqtt_glue_setup(esp_rmaker_mqtt_config_t *mqtt_config); +/* Get the ESP AWS PPI String + * + * @return pointer to a NULL terminated PPI string on success. + * @return NULL in case of any error. + */ +const char *esp_get_aws_ppi(void); #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/rmt_reg.h b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/rmt_reg.h index 8225f6a6876..351eac3b5fb 100644 --- a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/rmt_reg.h +++ b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/rmt_reg.h @@ -28,37 +28,37 @@ extern "C" { * Read and write data for channel 1 via APB FIFO */ #define RMT_CH1DATA_REG (DR_REG_RMT_BASE + 0x4) -/** RMT_CH0_DATA : RO; bitpos: [31:0]; default: 0; +/** RMT_CH1_DATA : RO; bitpos: [31:0]; default: 0; * This register is used to read and write data for channel 1 via APB FIFO. */ -#define RMT_CH0_DATA 0xFFFFFFFFU -#define RMT_CH0_DATA_M (RMT_CH0_DATA_V << RMT_CH0_DATA_S) -#define RMT_CH0_DATA_V 0xFFFFFFFFU -#define RMT_CH0_DATA_S 0 +#define RMT_CH1_DATA 0xFFFFFFFFU +#define RMT_CH1_DATA_M (RMT_CH1_DATA_V << RMT_CH1_DATA_S) +#define RMT_CH1_DATA_V 0xFFFFFFFFU +#define RMT_CH1_DATA_S 0 /** RMT_CH2DATA_REG register * Read and write data for channel 2 via APB FIFO */ #define RMT_CH2DATA_REG (DR_REG_RMT_BASE + 0x8) -/** RMT_CH0_DATA : RO; bitpos: [31:0]; default: 0; +/** RMT_CH2_DATA : RO; bitpos: [31:0]; default: 0; * This register is used to read and write data for channel 2 via APB FIFO. */ -#define RMT_CH0_DATA 0xFFFFFFFFU -#define RMT_CH0_DATA_M (RMT_CH0_DATA_V << RMT_CH0_DATA_S) -#define RMT_CH0_DATA_V 0xFFFFFFFFU -#define RMT_CH0_DATA_S 0 +#define RMT_CH2_DATA 0xFFFFFFFFU +#define RMT_CH2_DATA_M (RMT_CH2_DATA_V << RMT_CH2_DATA_S) +#define RMT_CH2_DATA_V 0xFFFFFFFFU +#define RMT_CH2_DATA_S 0 /** RMT_CH3DATA_REG register * Read and write data for channel 3 via APB FIFO */ #define RMT_CH3DATA_REG (DR_REG_RMT_BASE + 0xc) -/** RMT_CH0_DATA : RO; bitpos: [31:0]; default: 0; +/** RMT_CH3_DATA : RO; bitpos: [31:0]; default: 0; * This register is used to read and write data for channel 3 via APB FIFO. */ -#define RMT_CH0_DATA 0xFFFFFFFFU -#define RMT_CH0_DATA_M (RMT_CH0_DATA_V << RMT_CH0_DATA_S) -#define RMT_CH0_DATA_V 0xFFFFFFFFU -#define RMT_CH0_DATA_S 0 +#define RMT_CH3_DATA 0xFFFFFFFFU +#define RMT_CH3_DATA_M (RMT_CH3_DATA_V << RMT_CH3_DATA_S) +#define RMT_CH3_DATA_V 0xFFFFFFFFU +#define RMT_CH3_DATA_S 0 /** RMT_CH0CONF0_REG register * Channel 0 configuration register 0 @@ -234,652 +234,518 @@ extern "C" { * Channel 1 configuration register 0 */ #define RMT_CH1CONF0_REG (DR_REG_RMT_BASE + 0x18) -/** RMT_DIV_CNT_CH0 : R/W; bitpos: [7:0]; default: 2; +/** RMT_DIV_CNT_CH1 : R/W; bitpos: [7:0]; default: 2; * This field is used to configure clock divider for channel 1. */ -#define RMT_DIV_CNT_CH0 0x000000FFU -#define RMT_DIV_CNT_CH0_M (RMT_DIV_CNT_CH0_V << RMT_DIV_CNT_CH0_S) -#define RMT_DIV_CNT_CH0_V 0x000000FFU -#define RMT_DIV_CNT_CH0_S 0 -/** RMT_IDLE_THRES_CH0 : R/W; bitpos: [23:8]; default: 4096; +#define RMT_DIV_CNT_CH1 0x000000FFU +#define RMT_DIV_CNT_CH1_M (RMT_DIV_CNT_CH1_V << RMT_DIV_CNT_CH1_S) +#define RMT_DIV_CNT_CH1_V 0x000000FFU +#define RMT_DIV_CNT_CH1_S 0 +/** RMT_IDLE_THRES_CH1 : R/W; bitpos: [23:8]; default: 4096; * Receiving ends when no edge is detected on input signals for continuous clock * cycles longer than this field value. */ -#define RMT_IDLE_THRES_CH0 0x0000FFFFU -#define RMT_IDLE_THRES_CH0_M (RMT_IDLE_THRES_CH0_V << RMT_IDLE_THRES_CH0_S) -#define RMT_IDLE_THRES_CH0_V 0x0000FFFFU -#define RMT_IDLE_THRES_CH0_S 8 -/** RMT_MEM_SIZE_CH0 : R/W; bitpos: [26:24]; default: 1; +#define RMT_IDLE_THRES_CH1 0x0000FFFFU +#define RMT_IDLE_THRES_CH1_M (RMT_IDLE_THRES_CH1_V << RMT_IDLE_THRES_CH1_S) +#define RMT_IDLE_THRES_CH1_V 0x0000FFFFU +#define RMT_IDLE_THRES_CH1_S 8 +/** RMT_MEM_SIZE_CH1 : R/W; bitpos: [26:24]; default: 1; * This field is used to configure the maximum blocks allocated to channel 1. The * valid range is from 1 ~ 4-1. */ -#define RMT_MEM_SIZE_CH0 0x00000007U -#define RMT_MEM_SIZE_CH0_M (RMT_MEM_SIZE_CH0_V << RMT_MEM_SIZE_CH0_S) -#define RMT_MEM_SIZE_CH0_V 0x00000007U -#define RMT_MEM_SIZE_CH0_S 24 -/** RMT_CARRIER_EFF_EN_CH0 : R/W; bitpos: [27]; default: 1; +#define RMT_MEM_SIZE_CH1 0x00000007U +#define RMT_MEM_SIZE_CH1_M (RMT_MEM_SIZE_CH1_V << RMT_MEM_SIZE_CH1_S) +#define RMT_MEM_SIZE_CH1_V 0x00000007U +#define RMT_MEM_SIZE_CH1_S 24 +/** RMT_CARRIER_EFF_EN_CH1 : R/W; bitpos: [27]; default: 1; * 1: Add carrier modulation on output signals only at data sending state for channel * 1. 0: Add carrier modulation on signals at all states for channel 1. States here * include idle state (ST_IDLE), reading data from RAM (ST_RD_MEM), and sending data * stored in RAM (ST_SEND). Only valid when RMT_CARRIER_EN_CH1 is set to 1. */ -#define RMT_CARRIER_EFF_EN_CH0 (BIT(27)) -#define RMT_CARRIER_EFF_EN_CH0_M (RMT_CARRIER_EFF_EN_CH0_V << RMT_CARRIER_EFF_EN_CH0_S) -#define RMT_CARRIER_EFF_EN_CH0_V 0x00000001U -#define RMT_CARRIER_EFF_EN_CH0_S 27 -/** RMT_CARRIER_EN_CH0 : R/W; bitpos: [28]; default: 1; +#define RMT_CARRIER_EFF_EN_CH1 (BIT(27)) +#define RMT_CARRIER_EFF_EN_CH1_M (RMT_CARRIER_EFF_EN_CH1_V << RMT_CARRIER_EFF_EN_CH1_S) +#define RMT_CARRIER_EFF_EN_CH1_V 0x00000001U +#define RMT_CARRIER_EFF_EN_CH1_S 27 +/** RMT_CARRIER_EN_CH1 : R/W; bitpos: [28]; default: 1; * This bit is used to enable carrier modulation for channel 1. 1: Add carrier * modulation on output signals. 0: No carrier modulation is added on output signals. */ -#define RMT_CARRIER_EN_CH0 (BIT(28)) -#define RMT_CARRIER_EN_CH0_M (RMT_CARRIER_EN_CH0_V << RMT_CARRIER_EN_CH0_S) -#define RMT_CARRIER_EN_CH0_V 0x00000001U -#define RMT_CARRIER_EN_CH0_S 28 -/** RMT_CARRIER_OUT_LV_CH0 : R/W; bitpos: [29]; default: 1; +#define RMT_CARRIER_EN_CH1 (BIT(28)) +#define RMT_CARRIER_EN_CH1_M (RMT_CARRIER_EN_CH1_V << RMT_CARRIER_EN_CH1_S) +#define RMT_CARRIER_EN_CH1_V 0x00000001U +#define RMT_CARRIER_EN_CH1_S 28 +/** RMT_CARRIER_OUT_LV_CH1 : R/W; bitpos: [29]; default: 1; * This bit is used to configure the position of carrier wave for channel 1. * * 1'h0: Add carrier wave on low-level output signals. * * 1'h1: Add carrier wave on high-level output signals. */ -#define RMT_CARRIER_OUT_LV_CH0 (BIT(29)) -#define RMT_CARRIER_OUT_LV_CH0_M (RMT_CARRIER_OUT_LV_CH0_V << RMT_CARRIER_OUT_LV_CH0_S) -#define RMT_CARRIER_OUT_LV_CH0_V 0x00000001U -#define RMT_CARRIER_OUT_LV_CH0_S 29 +#define RMT_CARRIER_OUT_LV_CH1 (BIT(29)) +#define RMT_CARRIER_OUT_LV_CH1_M (RMT_CARRIER_OUT_LV_CH1_V << RMT_CARRIER_OUT_LV_CH1_S) +#define RMT_CARRIER_OUT_LV_CH1_V 0x00000001U +#define RMT_CARRIER_OUT_LV_CH1_S 29 /** RMT_CH1CONF1_REG register * Channel 1 configuration register 1 */ #define RMT_CH1CONF1_REG (DR_REG_RMT_BASE + 0x1c) -/** RMT_TX_START_CH0 : R/W; bitpos: [0]; default: 0; +/** RMT_TX_START_CH1 : R/W; bitpos: [0]; default: 0; * Set this bit to start sending data on channel 1. */ -#define RMT_TX_START_CH0 (BIT(0)) -#define RMT_TX_START_CH0_M (RMT_TX_START_CH0_V << RMT_TX_START_CH0_S) -#define RMT_TX_START_CH0_V 0x00000001U -#define RMT_TX_START_CH0_S 0 -/** RMT_RX_EN_CH0 : R/W; bitpos: [1]; default: 0; +#define RMT_TX_START_CH1 (BIT(0)) +#define RMT_TX_START_CH1_M (RMT_TX_START_CH1_V << RMT_TX_START_CH1_S) +#define RMT_TX_START_CH1_V 0x00000001U +#define RMT_TX_START_CH1_S 0 +/** RMT_RX_EN_CH1 : R/W; bitpos: [1]; default: 0; * Set this bit to enable receiver to receive data on channel 1. */ -#define RMT_RX_EN_CH0 (BIT(1)) -#define RMT_RX_EN_CH0_M (RMT_RX_EN_CH0_V << RMT_RX_EN_CH0_S) -#define RMT_RX_EN_CH0_V 0x00000001U -#define RMT_RX_EN_CH0_S 1 -/** RMT_MEM_WR_RST_CH0 : WO; bitpos: [2]; default: 0; +#define RMT_RX_EN_CH1 (BIT(1)) +#define RMT_RX_EN_CH1_M (RMT_RX_EN_CH1_V << RMT_RX_EN_CH1_S) +#define RMT_RX_EN_CH1_V 0x00000001U +#define RMT_RX_EN_CH1_S 1 +/** RMT_MEM_WR_RST_CH1 : WO; bitpos: [2]; default: 0; * Set this bit to reset RAM write address accessed by the receiver for channel 1. */ -#define RMT_MEM_WR_RST_CH0 (BIT(2)) -#define RMT_MEM_WR_RST_CH0_M (RMT_MEM_WR_RST_CH0_V << RMT_MEM_WR_RST_CH0_S) -#define RMT_MEM_WR_RST_CH0_V 0x00000001U -#define RMT_MEM_WR_RST_CH0_S 2 -/** RMT_MEM_RD_RST_CH0 : WO; bitpos: [3]; default: 0; +#define RMT_MEM_WR_RST_CH1 (BIT(2)) +#define RMT_MEM_WR_RST_CH1_M (RMT_MEM_WR_RST_CH1_V << RMT_MEM_WR_RST_CH1_S) +#define RMT_MEM_WR_RST_CH1_V 0x00000001U +#define RMT_MEM_WR_RST_CH1_S 2 +/** RMT_MEM_RD_RST_CH1 : WO; bitpos: [3]; default: 0; * Set this bit to reset RAM read address accessed by the transmitter for channel 1. */ -#define RMT_MEM_RD_RST_CH0 (BIT(3)) -#define RMT_MEM_RD_RST_CH0_M (RMT_MEM_RD_RST_CH0_V << RMT_MEM_RD_RST_CH0_S) -#define RMT_MEM_RD_RST_CH0_V 0x00000001U -#define RMT_MEM_RD_RST_CH0_S 3 -/** RMT_APB_MEM_RST_CH0 : WO; bitpos: [4]; default: 0; +#define RMT_MEM_RD_RST_CH1 (BIT(3)) +#define RMT_MEM_RD_RST_CH1_M (RMT_MEM_RD_RST_CH1_V << RMT_MEM_RD_RST_CH1_S) +#define RMT_MEM_RD_RST_CH1_V 0x00000001U +#define RMT_MEM_RD_RST_CH1_S 3 +/** RMT_APB_MEM_RST_CH1 : WO; bitpos: [4]; default: 0; * Set this bit to reset W/R ram address for channel 1 by accessing apb fifo. */ -#define RMT_APB_MEM_RST_CH0 (BIT(4)) -#define RMT_APB_MEM_RST_CH0_M (RMT_APB_MEM_RST_CH0_V << RMT_APB_MEM_RST_CH0_S) -#define RMT_APB_MEM_RST_CH0_V 0x00000001U -#define RMT_APB_MEM_RST_CH0_S 4 -/** RMT_MEM_OWNER_CH0 : R/W; bitpos: [5]; default: 1; +#define RMT_APB_MEM_RST_CH1 (BIT(4)) +#define RMT_APB_MEM_RST_CH1_M (RMT_APB_MEM_RST_CH1_V << RMT_APB_MEM_RST_CH1_S) +#define RMT_APB_MEM_RST_CH1_V 0x00000001U +#define RMT_APB_MEM_RST_CH1_S 4 +/** RMT_MEM_OWNER_CH1 : R/W; bitpos: [5]; default: 1; * This bit marks the ownership of channel 1's RAM block. * * 1'h1: Receiver is using the RAM. * * 1'h0: Transmitter is using the RAM. */ -#define RMT_MEM_OWNER_CH0 (BIT(5)) -#define RMT_MEM_OWNER_CH0_M (RMT_MEM_OWNER_CH0_V << RMT_MEM_OWNER_CH0_S) -#define RMT_MEM_OWNER_CH0_V 0x00000001U -#define RMT_MEM_OWNER_CH0_S 5 -/** RMT_TX_CONTI_MODE_CH0 : R/W; bitpos: [6]; default: 0; +#define RMT_MEM_OWNER_CH1 (BIT(5)) +#define RMT_MEM_OWNER_CH1_M (RMT_MEM_OWNER_CH1_V << RMT_MEM_OWNER_CH1_S) +#define RMT_MEM_OWNER_CH1_V 0x00000001U +#define RMT_MEM_OWNER_CH1_S 5 +/** RMT_TX_CONTI_MODE_CH1 : R/W; bitpos: [6]; default: 0; * Set this bit to restart transmission in continuous node from the first data in * channel 1. */ -#define RMT_TX_CONTI_MODE_CH0 (BIT(6)) -#define RMT_TX_CONTI_MODE_CH0_M (RMT_TX_CONTI_MODE_CH0_V << RMT_TX_CONTI_MODE_CH0_S) -#define RMT_TX_CONTI_MODE_CH0_V 0x00000001U -#define RMT_TX_CONTI_MODE_CH0_S 6 -/** RMT_RX_FILTER_EN_CH0 : R/W; bitpos: [7]; default: 0; +#define RMT_TX_CONTI_MODE_CH1 (BIT(6)) +#define RMT_TX_CONTI_MODE_CH1_M (RMT_TX_CONTI_MODE_CH1_V << RMT_TX_CONTI_MODE_CH1_S) +#define RMT_TX_CONTI_MODE_CH1_V 0x00000001U +#define RMT_TX_CONTI_MODE_CH1_S 6 +/** RMT_RX_FILTER_EN_CH1 : R/W; bitpos: [7]; default: 0; * Set this bit to enable the receiver's filter for channel 1. */ -#define RMT_RX_FILTER_EN_CH0 (BIT(7)) -#define RMT_RX_FILTER_EN_CH0_M (RMT_RX_FILTER_EN_CH0_V << RMT_RX_FILTER_EN_CH0_S) -#define RMT_RX_FILTER_EN_CH0_V 0x00000001U -#define RMT_RX_FILTER_EN_CH0_S 7 -/** RMT_RX_FILTER_THRES_CH0 : R/W; bitpos: [15:8]; default: 15; +#define RMT_RX_FILTER_EN_CH1 (BIT(7)) +#define RMT_RX_FILTER_EN_CH1_M (RMT_RX_FILTER_EN_CH1_V << RMT_RX_FILTER_EN_CH1_S) +#define RMT_RX_FILTER_EN_CH1_V 0x00000001U +#define RMT_RX_FILTER_EN_CH1_S 7 +/** RMT_RX_FILTER_THRES_CH1 : R/W; bitpos: [15:8]; default: 15; * Set this field to ignore the input pulse when its width is less than * RMT_RX_FILTER_THRES_CH1 APB clock cycles in receive mode. */ -#define RMT_RX_FILTER_THRES_CH0 0x000000FFU -#define RMT_RX_FILTER_THRES_CH0_M (RMT_RX_FILTER_THRES_CH0_V << RMT_RX_FILTER_THRES_CH0_S) -#define RMT_RX_FILTER_THRES_CH0_V 0x000000FFU -#define RMT_RX_FILTER_THRES_CH0_S 8 -/** RMT_CHK_RX_CARRIER_EN_CH0 : R/W; bitpos: [16]; default: 0; +#define RMT_RX_FILTER_THRES_CH1 0x000000FFU +#define RMT_RX_FILTER_THRES_CH1_M (RMT_RX_FILTER_THRES_CH1_V << RMT_RX_FILTER_THRES_CH1_S) +#define RMT_RX_FILTER_THRES_CH1_V 0x000000FFU +#define RMT_RX_FILTER_THRES_CH1_S 8 +/** RMT_CHK_RX_CARRIER_EN_CH1 : R/W; bitpos: [16]; default: 0; * Set this bit to enable memory loop read mode when carrier modulation is enabled for * channel 1. */ -#define RMT_CHK_RX_CARRIER_EN_CH0 (BIT(16)) -#define RMT_CHK_RX_CARRIER_EN_CH0_M (RMT_CHK_RX_CARRIER_EN_CH0_V << RMT_CHK_RX_CARRIER_EN_CH0_S) -#define RMT_CHK_RX_CARRIER_EN_CH0_V 0x00000001U -#define RMT_CHK_RX_CARRIER_EN_CH0_S 16 -/** RMT_REF_ALWAYS_ON_CH0 : R/W; bitpos: [17]; default: 0; +#define RMT_CHK_RX_CARRIER_EN_CH1 (BIT(16)) +#define RMT_CHK_RX_CARRIER_EN_CH1_M (RMT_CHK_RX_CARRIER_EN_CH1_V << RMT_CHK_RX_CARRIER_EN_CH1_S) +#define RMT_CHK_RX_CARRIER_EN_CH1_V 0x00000001U +#define RMT_CHK_RX_CARRIER_EN_CH1_S 16 +/** RMT_REF_ALWAYS_ON_CH1 : R/W; bitpos: [17]; default: 0; * Set this bit to select a base clock for channel 1. * * 1'h1: APB_CLK 1'h0: REF_TICK */ -#define RMT_REF_ALWAYS_ON_CH0 (BIT(17)) -#define RMT_REF_ALWAYS_ON_CH0_M (RMT_REF_ALWAYS_ON_CH0_V << RMT_REF_ALWAYS_ON_CH0_S) -#define RMT_REF_ALWAYS_ON_CH0_V 0x00000001U -#define RMT_REF_ALWAYS_ON_CH0_S 17 -/** RMT_IDLE_OUT_LV_CH0 : R/W; bitpos: [18]; default: 0; +#define RMT_REF_ALWAYS_ON_CH1 (BIT(17)) +#define RMT_REF_ALWAYS_ON_CH1_M (RMT_REF_ALWAYS_ON_CH1_V << RMT_REF_ALWAYS_ON_CH1_S) +#define RMT_REF_ALWAYS_ON_CH1_V 0x00000001U +#define RMT_REF_ALWAYS_ON_CH1_S 17 +/** RMT_IDLE_OUT_LV_CH1 : R/W; bitpos: [18]; default: 0; * This bit configures the level of output signals in channel 1 when the transmitter * is in idle state. */ -#define RMT_IDLE_OUT_LV_CH0 (BIT(18)) -#define RMT_IDLE_OUT_LV_CH0_M (RMT_IDLE_OUT_LV_CH0_V << RMT_IDLE_OUT_LV_CH0_S) -#define RMT_IDLE_OUT_LV_CH0_V 0x00000001U -#define RMT_IDLE_OUT_LV_CH0_S 18 -/** RMT_IDLE_OUT_EN_CH0 : R/W; bitpos: [19]; default: 0; +#define RMT_IDLE_OUT_LV_CH1 (BIT(18)) +#define RMT_IDLE_OUT_LV_CH1_M (RMT_IDLE_OUT_LV_CH1_V << RMT_IDLE_OUT_LV_CH1_S) +#define RMT_IDLE_OUT_LV_CH1_V 0x00000001U +#define RMT_IDLE_OUT_LV_CH1_S 18 +/** RMT_IDLE_OUT_EN_CH1 : R/W; bitpos: [19]; default: 0; * This is the output enable bit for channel 1 in idle state. */ -#define RMT_IDLE_OUT_EN_CH0 (BIT(19)) -#define RMT_IDLE_OUT_EN_CH0_M (RMT_IDLE_OUT_EN_CH0_V << RMT_IDLE_OUT_EN_CH0_S) -#define RMT_IDLE_OUT_EN_CH0_V 0x00000001U -#define RMT_IDLE_OUT_EN_CH0_S 19 -/** RMT_TX_STOP_CH0 : R/W; bitpos: [20]; default: 0; +#define RMT_IDLE_OUT_EN_CH1 (BIT(19)) +#define RMT_IDLE_OUT_EN_CH1_M (RMT_IDLE_OUT_EN_CH1_V << RMT_IDLE_OUT_EN_CH1_S) +#define RMT_IDLE_OUT_EN_CH1_V 0x00000001U +#define RMT_IDLE_OUT_EN_CH1_S 19 +/** RMT_TX_STOP_CH1 : R/W; bitpos: [20]; default: 0; * Set this bit to stop the transmitter of channel 1 sending data out. */ -#define RMT_TX_STOP_CH0 (BIT(20)) -#define RMT_TX_STOP_CH0_M (RMT_TX_STOP_CH0_V << RMT_TX_STOP_CH0_S) -#define RMT_TX_STOP_CH0_V 0x00000001U -#define RMT_TX_STOP_CH0_S 20 +#define RMT_TX_STOP_CH1 (BIT(20)) +#define RMT_TX_STOP_CH1_M (RMT_TX_STOP_CH1_V << RMT_TX_STOP_CH1_S) +#define RMT_TX_STOP_CH1_V 0x00000001U +#define RMT_TX_STOP_CH1_S 20 /** RMT_CH2CONF0_REG register * Channel 2 configuration register 0 */ #define RMT_CH2CONF0_REG (DR_REG_RMT_BASE + 0x20) -/** RMT_DIV_CNT_CH0 : R/W; bitpos: [7:0]; default: 2; +/** RMT_DIV_CNT_CH2 : R/W; bitpos: [7:0]; default: 2; * This field is used to configure clock divider for channel 2. */ -#define RMT_DIV_CNT_CH0 0x000000FFU -#define RMT_DIV_CNT_CH0_M (RMT_DIV_CNT_CH0_V << RMT_DIV_CNT_CH0_S) -#define RMT_DIV_CNT_CH0_V 0x000000FFU -#define RMT_DIV_CNT_CH0_S 0 -/** RMT_IDLE_THRES_CH0 : R/W; bitpos: [23:8]; default: 4096; +#define RMT_DIV_CNT_CH2 0x000000FFU +#define RMT_DIV_CNT_CH2_M (RMT_DIV_CNT_CH2_V << RMT_DIV_CNT_CH2_S) +#define RMT_DIV_CNT_CH2_V 0x000000FFU +#define RMT_DIV_CNT_CH2_S 0 +/** RMT_IDLE_THRES_CH2 : R/W; bitpos: [23:8]; default: 4096; * Receiving ends when no edge is detected on input signals for continuous clock * cycles longer than this field value. */ -#define RMT_IDLE_THRES_CH0 0x0000FFFFU -#define RMT_IDLE_THRES_CH0_M (RMT_IDLE_THRES_CH0_V << RMT_IDLE_THRES_CH0_S) -#define RMT_IDLE_THRES_CH0_V 0x0000FFFFU -#define RMT_IDLE_THRES_CH0_S 8 -/** RMT_MEM_SIZE_CH0 : R/W; bitpos: [26:24]; default: 1; +#define RMT_IDLE_THRES_CH2 0x0000FFFFU +#define RMT_IDLE_THRES_CH2_M (RMT_IDLE_THRES_CH2_V << RMT_IDLE_THRES_CH2_S) +#define RMT_IDLE_THRES_CH2_V 0x0000FFFFU +#define RMT_IDLE_THRES_CH2_S 8 +/** RMT_MEM_SIZE_CH2 : R/W; bitpos: [26:24]; default: 1; * This field is used to configure the maximum blocks allocated to channel 2. The * valid range is from 1 ~ 4-2. */ -#define RMT_MEM_SIZE_CH0 0x00000007U -#define RMT_MEM_SIZE_CH0_M (RMT_MEM_SIZE_CH0_V << RMT_MEM_SIZE_CH0_S) -#define RMT_MEM_SIZE_CH0_V 0x00000007U -#define RMT_MEM_SIZE_CH0_S 24 -/** RMT_CARRIER_EFF_EN_CH0 : R/W; bitpos: [27]; default: 1; +#define RMT_MEM_SIZE_CH2 0x00000007U +#define RMT_MEM_SIZE_CH2_M (RMT_MEM_SIZE_CH2_V << RMT_MEM_SIZE_CH2_S) +#define RMT_MEM_SIZE_CH2_V 0x00000007U +#define RMT_MEM_SIZE_CH2_S 24 +/** RMT_CARRIER_EFF_EN_CH2 : R/W; bitpos: [27]; default: 1; * 1: Add carrier modulation on output signals only at data sending state for channel * 2. 0: Add carrier modulation on signals at all states for channel 2. States here * include idle state (ST_IDLE), reading data from RAM (ST_RD_MEM), and sending data * stored in RAM (ST_SEND). Only valid when RMT_CARRIER_EN_CH2 is set to 1. */ -#define RMT_CARRIER_EFF_EN_CH0 (BIT(27)) -#define RMT_CARRIER_EFF_EN_CH0_M (RMT_CARRIER_EFF_EN_CH0_V << RMT_CARRIER_EFF_EN_CH0_S) -#define RMT_CARRIER_EFF_EN_CH0_V 0x00000001U -#define RMT_CARRIER_EFF_EN_CH0_S 27 -/** RMT_CARRIER_EN_CH0 : R/W; bitpos: [28]; default: 1; +#define RMT_CARRIER_EFF_EN_CH2 (BIT(27)) +#define RMT_CARRIER_EFF_EN_CH2_M (RMT_CARRIER_EFF_EN_CH2_V << RMT_CARRIER_EFF_EN_CH2_S) +#define RMT_CARRIER_EFF_EN_CH2_V 0x00000001U +#define RMT_CARRIER_EFF_EN_CH2_S 27 +/** RMT_CARRIER_EN_CH2 : R/W; bitpos: [28]; default: 1; * This bit is used to enable carrier modulation for channel 2. 1: Add carrier * modulation on output signals. 0: No carrier modulation is added on output signals. */ -#define RMT_CARRIER_EN_CH0 (BIT(28)) -#define RMT_CARRIER_EN_CH0_M (RMT_CARRIER_EN_CH0_V << RMT_CARRIER_EN_CH0_S) -#define RMT_CARRIER_EN_CH0_V 0x00000001U -#define RMT_CARRIER_EN_CH0_S 28 -/** RMT_CARRIER_OUT_LV_CH0 : R/W; bitpos: [29]; default: 1; +#define RMT_CARRIER_EN_CH2 (BIT(28)) +#define RMT_CARRIER_EN_CH2_M (RMT_CARRIER_EN_CH2_V << RMT_CARRIER_EN_CH2_S) +#define RMT_CARRIER_EN_CH2_V 0x00000001U +#define RMT_CARRIER_EN_CH2_S 28 +/** RMT_CARRIER_OUT_LV_CH2 : R/W; bitpos: [29]; default: 1; * This bit is used to configure the position of carrier wave for channel 2. * * 1'h0: Add carrier wave on low-level output signals. * * 1'h1: Add carrier wave on high-level output signals. */ -#define RMT_CARRIER_OUT_LV_CH0 (BIT(29)) -#define RMT_CARRIER_OUT_LV_CH0_M (RMT_CARRIER_OUT_LV_CH0_V << RMT_CARRIER_OUT_LV_CH0_S) -#define RMT_CARRIER_OUT_LV_CH0_V 0x00000001U -#define RMT_CARRIER_OUT_LV_CH0_S 29 +#define RMT_CARRIER_OUT_LV_CH2 (BIT(29)) +#define RMT_CARRIER_OUT_LV_CH2_M (RMT_CARRIER_OUT_LV_CH2_V << RMT_CARRIER_OUT_LV_CH2_S) +#define RMT_CARRIER_OUT_LV_CH2_V 0x00000001U +#define RMT_CARRIER_OUT_LV_CH2_S 29 /** RMT_CH2CONF1_REG register * Channel 2 configuration register 1 */ #define RMT_CH2CONF1_REG (DR_REG_RMT_BASE + 0x24) -/** RMT_TX_START_CH0 : R/W; bitpos: [0]; default: 0; +/** RMT_TX_START_CH2 : R/W; bitpos: [0]; default: 0; * Set this bit to start sending data on channel 2. */ -#define RMT_TX_START_CH0 (BIT(0)) -#define RMT_TX_START_CH0_M (RMT_TX_START_CH0_V << RMT_TX_START_CH0_S) -#define RMT_TX_START_CH0_V 0x00000001U -#define RMT_TX_START_CH0_S 0 -/** RMT_RX_EN_CH0 : R/W; bitpos: [1]; default: 0; +#define RMT_TX_START_CH2 (BIT(0)) +#define RMT_TX_START_CH2_M (RMT_TX_START_CH2_V << RMT_TX_START_CH2_S) +#define RMT_TX_START_CH2_V 0x00000001U +#define RMT_TX_START_CH2_S 0 +/** RMT_RX_EN_CH2 : R/W; bitpos: [1]; default: 0; * Set this bit to enable receiver to receive data on channel 2. */ -#define RMT_RX_EN_CH0 (BIT(1)) -#define RMT_RX_EN_CH0_M (RMT_RX_EN_CH0_V << RMT_RX_EN_CH0_S) -#define RMT_RX_EN_CH0_V 0x00000001U -#define RMT_RX_EN_CH0_S 1 -/** RMT_MEM_WR_RST_CH0 : WO; bitpos: [2]; default: 0; +#define RMT_RX_EN_CH2 (BIT(1)) +#define RMT_RX_EN_CH2_M (RMT_RX_EN_CH2_V << RMT_RX_EN_CH2_S) +#define RMT_RX_EN_CH2_V 0x00000001U +#define RMT_RX_EN_CH2_S 1 +/** RMT_MEM_WR_RST_CH2 : WO; bitpos: [2]; default: 0; * Set this bit to reset RAM write address accessed by the receiver for channel 2. */ -#define RMT_MEM_WR_RST_CH0 (BIT(2)) -#define RMT_MEM_WR_RST_CH0_M (RMT_MEM_WR_RST_CH0_V << RMT_MEM_WR_RST_CH0_S) -#define RMT_MEM_WR_RST_CH0_V 0x00000001U -#define RMT_MEM_WR_RST_CH0_S 2 -/** RMT_MEM_RD_RST_CH0 : WO; bitpos: [3]; default: 0; +#define RMT_MEM_WR_RST_CH2 (BIT(2)) +#define RMT_MEM_WR_RST_CH2_M (RMT_MEM_WR_RST_CH2_V << RMT_MEM_WR_RST_CH2_S) +#define RMT_MEM_WR_RST_CH2_V 0x00000001U +#define RMT_MEM_WR_RST_CH2_S 2 +/** RMT_MEM_RD_RST_CH2 : WO; bitpos: [3]; default: 0; * Set this bit to reset RAM read address accessed by the transmitter for channel 2. */ -#define RMT_MEM_RD_RST_CH0 (BIT(3)) -#define RMT_MEM_RD_RST_CH0_M (RMT_MEM_RD_RST_CH0_V << RMT_MEM_RD_RST_CH0_S) -#define RMT_MEM_RD_RST_CH0_V 0x00000001U -#define RMT_MEM_RD_RST_CH0_S 3 -/** RMT_APB_MEM_RST_CH0 : WO; bitpos: [4]; default: 0; +#define RMT_MEM_RD_RST_CH2 (BIT(3)) +#define RMT_MEM_RD_RST_CH2_M (RMT_MEM_RD_RST_CH2_V << RMT_MEM_RD_RST_CH2_S) +#define RMT_MEM_RD_RST_CH2_V 0x00000001U +#define RMT_MEM_RD_RST_CH2_S 3 +/** RMT_APB_MEM_RST_CH2 : WO; bitpos: [4]; default: 0; * Set this bit to reset W/R ram address for channel 2 by accessing apb fifo. */ -#define RMT_APB_MEM_RST_CH0 (BIT(4)) -#define RMT_APB_MEM_RST_CH0_M (RMT_APB_MEM_RST_CH0_V << RMT_APB_MEM_RST_CH0_S) -#define RMT_APB_MEM_RST_CH0_V 0x00000001U -#define RMT_APB_MEM_RST_CH0_S 4 -/** RMT_MEM_OWNER_CH0 : R/W; bitpos: [5]; default: 1; +#define RMT_APB_MEM_RST_CH2 (BIT(4)) +#define RMT_APB_MEM_RST_CH2_M (RMT_APB_MEM_RST_CH2_V << RMT_APB_MEM_RST_CH2_S) +#define RMT_APB_MEM_RST_CH2_V 0x00000001U +#define RMT_APB_MEM_RST_CH2_S 4 +/** RMT_MEM_OWNER_CH2 : R/W; bitpos: [5]; default: 1; * This bit marks the ownership of channel 2's RAM block. * * 1'h1: Receiver is using the RAM. * * 1'h0: Transmitter is using the RAM. */ -#define RMT_MEM_OWNER_CH0 (BIT(5)) -#define RMT_MEM_OWNER_CH0_M (RMT_MEM_OWNER_CH0_V << RMT_MEM_OWNER_CH0_S) -#define RMT_MEM_OWNER_CH0_V 0x00000001U -#define RMT_MEM_OWNER_CH0_S 5 -/** RMT_TX_CONTI_MODE_CH0 : R/W; bitpos: [6]; default: 0; +#define RMT_MEM_OWNER_CH2 (BIT(5)) +#define RMT_MEM_OWNER_CH2_M (RMT_MEM_OWNER_CH2_V << RMT_MEM_OWNER_CH2_S) +#define RMT_MEM_OWNER_CH2_V 0x00000001U +#define RMT_MEM_OWNER_CH2_S 5 +/** RMT_TX_CONTI_MODE_CH2 : R/W; bitpos: [6]; default: 0; * Set this bit to restart transmission in continuous node from the first data in * channel 2. */ -#define RMT_TX_CONTI_MODE_CH0 (BIT(6)) -#define RMT_TX_CONTI_MODE_CH0_M (RMT_TX_CONTI_MODE_CH0_V << RMT_TX_CONTI_MODE_CH0_S) -#define RMT_TX_CONTI_MODE_CH0_V 0x00000001U -#define RMT_TX_CONTI_MODE_CH0_S 6 -/** RMT_RX_FILTER_EN_CH0 : R/W; bitpos: [7]; default: 0; +#define RMT_TX_CONTI_MODE_CH2 (BIT(6)) +#define RMT_TX_CONTI_MODE_CH2_M (RMT_TX_CONTI_MODE_CH2_V << RMT_TX_CONTI_MODE_CH2_S) +#define RMT_TX_CONTI_MODE_CH2_V 0x00000001U +#define RMT_TX_CONTI_MODE_CH2_S 6 +/** RMT_RX_FILTER_EN_CH2 : R/W; bitpos: [7]; default: 0; * Set this bit to enable the receiver's filter for channel 2. */ -#define RMT_RX_FILTER_EN_CH0 (BIT(7)) -#define RMT_RX_FILTER_EN_CH0_M (RMT_RX_FILTER_EN_CH0_V << RMT_RX_FILTER_EN_CH0_S) -#define RMT_RX_FILTER_EN_CH0_V 0x00000001U -#define RMT_RX_FILTER_EN_CH0_S 7 -/** RMT_RX_FILTER_THRES_CH0 : R/W; bitpos: [15:8]; default: 15; +#define RMT_RX_FILTER_EN_CH2 (BIT(7)) +#define RMT_RX_FILTER_EN_CH2_M (RMT_RX_FILTER_EN_CH2_V << RMT_RX_FILTER_EN_CH2_S) +#define RMT_RX_FILTER_EN_CH2_V 0x00000001U +#define RMT_RX_FILTER_EN_CH2_S 7 +/** RMT_RX_FILTER_THRES_CH2 : R/W; bitpos: [15:8]; default: 15; * Set this field to ignore the input pulse when its width is less than * RMT_RX_FILTER_THRES_CH2 APB clock cycles in receive mode. */ -#define RMT_RX_FILTER_THRES_CH0 0x000000FFU -#define RMT_RX_FILTER_THRES_CH0_M (RMT_RX_FILTER_THRES_CH0_V << RMT_RX_FILTER_THRES_CH0_S) -#define RMT_RX_FILTER_THRES_CH0_V 0x000000FFU -#define RMT_RX_FILTER_THRES_CH0_S 8 -/** RMT_CHK_RX_CARRIER_EN_CH0 : R/W; bitpos: [16]; default: 0; +#define RMT_RX_FILTER_THRES_CH2 0x000000FFU +#define RMT_RX_FILTER_THRES_CH2_M (RMT_RX_FILTER_THRES_CH2_V << RMT_RX_FILTER_THRES_CH2_S) +#define RMT_RX_FILTER_THRES_CH2_V 0x000000FFU +#define RMT_RX_FILTER_THRES_CH2_S 8 +/** RMT_CHK_RX_CARRIER_EN_CH2 : R/W; bitpos: [16]; default: 0; * Set this bit to enable memory loop read mode when carrier modulation is enabled for * channel 2. */ -#define RMT_CHK_RX_CARRIER_EN_CH0 (BIT(16)) -#define RMT_CHK_RX_CARRIER_EN_CH0_M (RMT_CHK_RX_CARRIER_EN_CH0_V << RMT_CHK_RX_CARRIER_EN_CH0_S) -#define RMT_CHK_RX_CARRIER_EN_CH0_V 0x00000001U -#define RMT_CHK_RX_CARRIER_EN_CH0_S 16 -/** RMT_REF_ALWAYS_ON_CH0 : R/W; bitpos: [17]; default: 0; +#define RMT_CHK_RX_CARRIER_EN_CH2 (BIT(16)) +#define RMT_CHK_RX_CARRIER_EN_CH2_M (RMT_CHK_RX_CARRIER_EN_CH2_V << RMT_CHK_RX_CARRIER_EN_CH2_S) +#define RMT_CHK_RX_CARRIER_EN_CH2_V 0x00000001U +#define RMT_CHK_RX_CARRIER_EN_CH2_S 16 +/** RMT_REF_ALWAYS_ON_CH2 : R/W; bitpos: [17]; default: 0; * Set this bit to select a base clock for channel 2. * * 1'h1: APB_CLK 1'h0: REF_TICK */ -#define RMT_REF_ALWAYS_ON_CH0 (BIT(17)) -#define RMT_REF_ALWAYS_ON_CH0_M (RMT_REF_ALWAYS_ON_CH0_V << RMT_REF_ALWAYS_ON_CH0_S) -#define RMT_REF_ALWAYS_ON_CH0_V 0x00000001U -#define RMT_REF_ALWAYS_ON_CH0_S 17 -/** RMT_IDLE_OUT_LV_CH0 : R/W; bitpos: [18]; default: 0; +#define RMT_REF_ALWAYS_ON_CH2 (BIT(17)) +#define RMT_REF_ALWAYS_ON_CH2_M (RMT_REF_ALWAYS_ON_CH2_V << RMT_REF_ALWAYS_ON_CH2_S) +#define RMT_REF_ALWAYS_ON_CH2_V 0x00000001U +#define RMT_REF_ALWAYS_ON_CH2_S 17 +/** RMT_IDLE_OUT_LV_CH2 : R/W; bitpos: [18]; default: 0; * This bit configures the level of output signals in channel 2 when the transmitter * is in idle state. */ -#define RMT_IDLE_OUT_LV_CH0 (BIT(18)) -#define RMT_IDLE_OUT_LV_CH0_M (RMT_IDLE_OUT_LV_CH0_V << RMT_IDLE_OUT_LV_CH0_S) -#define RMT_IDLE_OUT_LV_CH0_V 0x00000001U -#define RMT_IDLE_OUT_LV_CH0_S 18 -/** RMT_IDLE_OUT_EN_CH0 : R/W; bitpos: [19]; default: 0; +#define RMT_IDLE_OUT_LV_CH2 (BIT(18)) +#define RMT_IDLE_OUT_LV_CH2_M (RMT_IDLE_OUT_LV_CH2_V << RMT_IDLE_OUT_LV_CH2_S) +#define RMT_IDLE_OUT_LV_CH2_V 0x00000001U +#define RMT_IDLE_OUT_LV_CH2_S 18 +/** RMT_IDLE_OUT_EN_CH2 : R/W; bitpos: [19]; default: 0; * This is the output enable bit for channel 2 in idle state. */ -#define RMT_IDLE_OUT_EN_CH0 (BIT(19)) -#define RMT_IDLE_OUT_EN_CH0_M (RMT_IDLE_OUT_EN_CH0_V << RMT_IDLE_OUT_EN_CH0_S) -#define RMT_IDLE_OUT_EN_CH0_V 0x00000001U -#define RMT_IDLE_OUT_EN_CH0_S 19 -/** RMT_TX_STOP_CH0 : R/W; bitpos: [20]; default: 0; +#define RMT_IDLE_OUT_EN_CH2 (BIT(19)) +#define RMT_IDLE_OUT_EN_CH2_M (RMT_IDLE_OUT_EN_CH2_V << RMT_IDLE_OUT_EN_CH2_S) +#define RMT_IDLE_OUT_EN_CH2_V 0x00000001U +#define RMT_IDLE_OUT_EN_CH2_S 19 +/** RMT_TX_STOP_CH2 : R/W; bitpos: [20]; default: 0; * Set this bit to stop the transmitter of channel 2 sending data out. */ -#define RMT_TX_STOP_CH0 (BIT(20)) -#define RMT_TX_STOP_CH0_M (RMT_TX_STOP_CH0_V << RMT_TX_STOP_CH0_S) -#define RMT_TX_STOP_CH0_V 0x00000001U -#define RMT_TX_STOP_CH0_S 20 +#define RMT_TX_STOP_CH2 (BIT(20)) +#define RMT_TX_STOP_CH2_M (RMT_TX_STOP_CH2_V << RMT_TX_STOP_CH2_S) +#define RMT_TX_STOP_CH2_V 0x00000001U +#define RMT_TX_STOP_CH2_S 20 /** RMT_CH3CONF0_REG register * Channel 3 configuration register 0 */ #define RMT_CH3CONF0_REG (DR_REG_RMT_BASE + 0x28) -/** RMT_DIV_CNT_CH0 : R/W; bitpos: [7:0]; default: 2; +/** RMT_DIV_CNT_CH3 : R/W; bitpos: [7:0]; default: 2; * This field is used to configure clock divider for channel 3. */ -#define RMT_DIV_CNT_CH0 0x000000FFU -#define RMT_DIV_CNT_CH0_M (RMT_DIV_CNT_CH0_V << RMT_DIV_CNT_CH0_S) -#define RMT_DIV_CNT_CH0_V 0x000000FFU -#define RMT_DIV_CNT_CH0_S 0 -/** RMT_IDLE_THRES_CH0 : R/W; bitpos: [23:8]; default: 4096; +#define RMT_DIV_CNT_CH3 0x000000FFU +#define RMT_DIV_CNT_CH3_M (RMT_DIV_CNT_CH3_V << RMT_DIV_CNT_CH3_S) +#define RMT_DIV_CNT_CH3_V 0x000000FFU +#define RMT_DIV_CNT_CH3_S 0 +/** RMT_IDLE_THRES_CH3 : R/W; bitpos: [23:8]; default: 4096; * Receiving ends when no edge is detected on input signals for continuous clock * cycles longer than this field value. */ -#define RMT_IDLE_THRES_CH0 0x0000FFFFU -#define RMT_IDLE_THRES_CH0_M (RMT_IDLE_THRES_CH0_V << RMT_IDLE_THRES_CH0_S) -#define RMT_IDLE_THRES_CH0_V 0x0000FFFFU -#define RMT_IDLE_THRES_CH0_S 8 -/** RMT_MEM_SIZE_CH0 : R/W; bitpos: [26:24]; default: 1; +#define RMT_IDLE_THRES_CH3 0x0000FFFFU +#define RMT_IDLE_THRES_CH3_M (RMT_IDLE_THRES_CH3_V << RMT_IDLE_THRES_CH3_S) +#define RMT_IDLE_THRES_CH3_V 0x0000FFFFU +#define RMT_IDLE_THRES_CH3_S 8 +/** RMT_MEM_SIZE_CH3 : R/W; bitpos: [26:24]; default: 1; * This field is used to configure the maximum blocks allocated to channel 3. The * valid range is from 1 ~ 4-3. */ -#define RMT_MEM_SIZE_CH0 0x00000007U -#define RMT_MEM_SIZE_CH0_M (RMT_MEM_SIZE_CH0_V << RMT_MEM_SIZE_CH0_S) -#define RMT_MEM_SIZE_CH0_V 0x00000007U -#define RMT_MEM_SIZE_CH0_S 24 -/** RMT_CARRIER_EFF_EN_CH0 : R/W; bitpos: [27]; default: 1; +#define RMT_MEM_SIZE_CH3 0x00000007U +#define RMT_MEM_SIZE_CH3_M (RMT_MEM_SIZE_CH3_V << RMT_MEM_SIZE_CH3_S) +#define RMT_MEM_SIZE_CH3_V 0x00000007U +#define RMT_MEM_SIZE_CH3_S 24 +/** RMT_CARRIER_EFF_EN_CH3 : R/W; bitpos: [27]; default: 1; * 1: Add carrier modulation on output signals only at data sending state for channel * 3. 0: Add carrier modulation on signals at all states for channel 3. States here * include idle state (ST_IDLE), reading data from RAM (ST_RD_MEM), and sending data * stored in RAM (ST_SEND). Only valid when RMT_CARRIER_EN_CH3 is set to 1. */ -#define RMT_CARRIER_EFF_EN_CH0 (BIT(27)) -#define RMT_CARRIER_EFF_EN_CH0_M (RMT_CARRIER_EFF_EN_CH0_V << RMT_CARRIER_EFF_EN_CH0_S) -#define RMT_CARRIER_EFF_EN_CH0_V 0x00000001U -#define RMT_CARRIER_EFF_EN_CH0_S 27 -/** RMT_CARRIER_EN_CH0 : R/W; bitpos: [28]; default: 1; +#define RMT_CARRIER_EFF_EN_CH3 (BIT(27)) +#define RMT_CARRIER_EFF_EN_CH3_M (RMT_CARRIER_EFF_EN_CH3_V << RMT_CARRIER_EFF_EN_CH3_S) +#define RMT_CARRIER_EFF_EN_CH3_V 0x00000001U +#define RMT_CARRIER_EFF_EN_CH3_S 27 +/** RMT_CARRIER_EN_CH3 : R/W; bitpos: [28]; default: 1; * This bit is used to enable carrier modulation for channel 3. 1: Add carrier * modulation on output signals. 0: No carrier modulation is added on output signals. */ -#define RMT_CARRIER_EN_CH0 (BIT(28)) -#define RMT_CARRIER_EN_CH0_M (RMT_CARRIER_EN_CH0_V << RMT_CARRIER_EN_CH0_S) -#define RMT_CARRIER_EN_CH0_V 0x00000001U -#define RMT_CARRIER_EN_CH0_S 28 -/** RMT_CARRIER_OUT_LV_CH0 : R/W; bitpos: [29]; default: 1; +#define RMT_CARRIER_EN_CH3 (BIT(28)) +#define RMT_CARRIER_EN_CH3_M (RMT_CARRIER_EN_CH3_V << RMT_CARRIER_EN_CH3_S) +#define RMT_CARRIER_EN_CH3_V 0x00000001U +#define RMT_CARRIER_EN_CH3_S 28 +/** RMT_CARRIER_OUT_LV_CH3 : R/W; bitpos: [29]; default: 1; * This bit is used to configure the position of carrier wave for channel 3. * * 1'h0: Add carrier wave on low-level output signals. * * 1'h1: Add carrier wave on high-level output signals. */ -#define RMT_CARRIER_OUT_LV_CH0 (BIT(29)) -#define RMT_CARRIER_OUT_LV_CH0_M (RMT_CARRIER_OUT_LV_CH0_V << RMT_CARRIER_OUT_LV_CH0_S) -#define RMT_CARRIER_OUT_LV_CH0_V 0x00000001U -#define RMT_CARRIER_OUT_LV_CH0_S 29 +#define RMT_CARRIER_OUT_LV_CH3 (BIT(29)) +#define RMT_CARRIER_OUT_LV_CH3_M (RMT_CARRIER_OUT_LV_CH3_V << RMT_CARRIER_OUT_LV_CH3_S) +#define RMT_CARRIER_OUT_LV_CH3_V 0x00000001U +#define RMT_CARRIER_OUT_LV_CH3_S 29 /** RMT_CH3CONF1_REG register * Channel 3 configuration register 1 */ #define RMT_CH3CONF1_REG (DR_REG_RMT_BASE + 0x2c) -/** RMT_TX_START_CH0 : R/W; bitpos: [0]; default: 0; +/** RMT_TX_START_CH3 : R/W; bitpos: [0]; default: 0; * Set this bit to start sending data on channel 3. */ -#define RMT_TX_START_CH0 (BIT(0)) -#define RMT_TX_START_CH0_M (RMT_TX_START_CH0_V << RMT_TX_START_CH0_S) -#define RMT_TX_START_CH0_V 0x00000001U -#define RMT_TX_START_CH0_S 0 -/** RMT_RX_EN_CH0 : R/W; bitpos: [1]; default: 0; +#define RMT_TX_START_CH3 (BIT(0)) +#define RMT_TX_START_CH3_M (RMT_TX_START_CH3_V << RMT_TX_START_CH3_S) +#define RMT_TX_START_CH3_V 0x00000001U +#define RMT_TX_START_CH3_S 0 +/** RMT_RX_EN_CH3 : R/W; bitpos: [1]; default: 0; * Set this bit to enable receiver to receive data on channel 3. */ -#define RMT_RX_EN_CH0 (BIT(1)) -#define RMT_RX_EN_CH0_M (RMT_RX_EN_CH0_V << RMT_RX_EN_CH0_S) -#define RMT_RX_EN_CH0_V 0x00000001U -#define RMT_RX_EN_CH0_S 1 -/** RMT_MEM_WR_RST_CH0 : WO; bitpos: [2]; default: 0; +#define RMT_RX_EN_CH3 (BIT(1)) +#define RMT_RX_EN_CH3_M (RMT_RX_EN_CH3_V << RMT_RX_EN_CH3_S) +#define RMT_RX_EN_CH3_V 0x00000001U +#define RMT_RX_EN_CH3_S 1 +/** RMT_MEM_WR_RST_CH3 : WO; bitpos: [2]; default: 0; * Set this bit to reset RAM write address accessed by the receiver for channel 3. */ -#define RMT_MEM_WR_RST_CH0 (BIT(2)) -#define RMT_MEM_WR_RST_CH0_M (RMT_MEM_WR_RST_CH0_V << RMT_MEM_WR_RST_CH0_S) -#define RMT_MEM_WR_RST_CH0_V 0x00000001U -#define RMT_MEM_WR_RST_CH0_S 2 -/** RMT_MEM_RD_RST_CH0 : WO; bitpos: [3]; default: 0; +#define RMT_MEM_WR_RST_CH3 (BIT(2)) +#define RMT_MEM_WR_RST_CH3_M (RMT_MEM_WR_RST_CH3_V << RMT_MEM_WR_RST_CH3_S) +#define RMT_MEM_WR_RST_CH3_V 0x00000001U +#define RMT_MEM_WR_RST_CH3_S 2 +/** RMT_MEM_RD_RST_CH3 : WO; bitpos: [3]; default: 0; * Set this bit to reset RAM read address accessed by the transmitter for channel 3. */ -#define RMT_MEM_RD_RST_CH0 (BIT(3)) -#define RMT_MEM_RD_RST_CH0_M (RMT_MEM_RD_RST_CH0_V << RMT_MEM_RD_RST_CH0_S) -#define RMT_MEM_RD_RST_CH0_V 0x00000001U -#define RMT_MEM_RD_RST_CH0_S 3 -/** RMT_APB_MEM_RST_CH0 : WO; bitpos: [4]; default: 0; +#define RMT_MEM_RD_RST_CH3 (BIT(3)) +#define RMT_MEM_RD_RST_CH3_M (RMT_MEM_RD_RST_CH3_V << RMT_MEM_RD_RST_CH3_S) +#define RMT_MEM_RD_RST_CH3_V 0x00000001U +#define RMT_MEM_RD_RST_CH3_S 3 +/** RMT_APB_MEM_RST_CH3 : WO; bitpos: [4]; default: 0; * Set this bit to reset W/R ram address for channel 3 by accessing apb fifo. */ -#define RMT_APB_MEM_RST_CH0 (BIT(4)) -#define RMT_APB_MEM_RST_CH0_M (RMT_APB_MEM_RST_CH0_V << RMT_APB_MEM_RST_CH0_S) -#define RMT_APB_MEM_RST_CH0_V 0x00000001U -#define RMT_APB_MEM_RST_CH0_S 4 -/** RMT_MEM_OWNER_CH0 : R/W; bitpos: [5]; default: 1; +#define RMT_APB_MEM_RST_CH3 (BIT(4)) +#define RMT_APB_MEM_RST_CH3_M (RMT_APB_MEM_RST_CH3_V << RMT_APB_MEM_RST_CH3_S) +#define RMT_APB_MEM_RST_CH3_V 0x00000001U +#define RMT_APB_MEM_RST_CH3_S 4 +/** RMT_MEM_OWNER_CH3 : R/W; bitpos: [5]; default: 1; * This bit marks the ownership of channel 3's RAM block. * * 1'h1: Receiver is using the RAM. * * 1'h0: Transmitter is using the RAM. */ -#define RMT_MEM_OWNER_CH0 (BIT(5)) -#define RMT_MEM_OWNER_CH0_M (RMT_MEM_OWNER_CH0_V << RMT_MEM_OWNER_CH0_S) -#define RMT_MEM_OWNER_CH0_V 0x00000001U -#define RMT_MEM_OWNER_CH0_S 5 -/** RMT_TX_CONTI_MODE_CH0 : R/W; bitpos: [6]; default: 0; +#define RMT_MEM_OWNER_CH3 (BIT(5)) +#define RMT_MEM_OWNER_CH3_M (RMT_MEM_OWNER_CH3_V << RMT_MEM_OWNER_CH3_S) +#define RMT_MEM_OWNER_CH3_V 0x00000001U +#define RMT_MEM_OWNER_CH3_S 5 +/** RMT_TX_CONTI_MODE_CH3 : R/W; bitpos: [6]; default: 0; * Set this bit to restart transmission in continuous node from the first data in * channel 3. */ -#define RMT_TX_CONTI_MODE_CH0 (BIT(6)) -#define RMT_TX_CONTI_MODE_CH0_M (RMT_TX_CONTI_MODE_CH0_V << RMT_TX_CONTI_MODE_CH0_S) -#define RMT_TX_CONTI_MODE_CH0_V 0x00000001U -#define RMT_TX_CONTI_MODE_CH0_S 6 -/** RMT_RX_FILTER_EN_CH0 : R/W; bitpos: [7]; default: 0; +#define RMT_TX_CONTI_MODE_CH3 (BIT(6)) +#define RMT_TX_CONTI_MODE_CH3_M (RMT_TX_CONTI_MODE_CH3_V << RMT_TX_CONTI_MODE_CH3_S) +#define RMT_TX_CONTI_MODE_CH3_V 0x00000001U +#define RMT_TX_CONTI_MODE_CH3_S 6 +/** RMT_RX_FILTER_EN_CH3 : R/W; bitpos: [7]; default: 0; * Set this bit to enable the receiver's filter for channel 3. */ -#define RMT_RX_FILTER_EN_CH0 (BIT(7)) -#define RMT_RX_FILTER_EN_CH0_M (RMT_RX_FILTER_EN_CH0_V << RMT_RX_FILTER_EN_CH0_S) -#define RMT_RX_FILTER_EN_CH0_V 0x00000001U -#define RMT_RX_FILTER_EN_CH0_S 7 -/** RMT_RX_FILTER_THRES_CH0 : R/W; bitpos: [15:8]; default: 15; +#define RMT_RX_FILTER_EN_CH3 (BIT(7)) +#define RMT_RX_FILTER_EN_CH3_M (RMT_RX_FILTER_EN_CH3_V << RMT_RX_FILTER_EN_CH3_S) +#define RMT_RX_FILTER_EN_CH3_V 0x00000001U +#define RMT_RX_FILTER_EN_CH3_S 7 +/** RMT_RX_FILTER_THRES_CH3 : R/W; bitpos: [15:8]; default: 15; * Set this field to ignore the input pulse when its width is less than * RMT_RX_FILTER_THRES_CH3 APB clock cycles in receive mode. */ -#define RMT_RX_FILTER_THRES_CH0 0x000000FFU -#define RMT_RX_FILTER_THRES_CH0_M (RMT_RX_FILTER_THRES_CH0_V << RMT_RX_FILTER_THRES_CH0_S) -#define RMT_RX_FILTER_THRES_CH0_V 0x000000FFU -#define RMT_RX_FILTER_THRES_CH0_S 8 -/** RMT_CHK_RX_CARRIER_EN_CH0 : R/W; bitpos: [16]; default: 0; +#define RMT_RX_FILTER_THRES_CH3 0x000000FFU +#define RMT_RX_FILTER_THRES_CH3_M (RMT_RX_FILTER_THRES_CH3_V << RMT_RX_FILTER_THRES_CH3_S) +#define RMT_RX_FILTER_THRES_CH3_V 0x000000FFU +#define RMT_RX_FILTER_THRES_CH3_S 8 +/** RMT_CHK_RX_CARRIER_EN_CH3 : R/W; bitpos: [16]; default: 0; * Set this bit to enable memory loop read mode when carrier modulation is enabled for * channel 3. */ -#define RMT_CHK_RX_CARRIER_EN_CH0 (BIT(16)) -#define RMT_CHK_RX_CARRIER_EN_CH0_M (RMT_CHK_RX_CARRIER_EN_CH0_V << RMT_CHK_RX_CARRIER_EN_CH0_S) -#define RMT_CHK_RX_CARRIER_EN_CH0_V 0x00000001U -#define RMT_CHK_RX_CARRIER_EN_CH0_S 16 -/** RMT_REF_ALWAYS_ON_CH0 : R/W; bitpos: [17]; default: 0; +#define RMT_CHK_RX_CARRIER_EN_CH3 (BIT(16)) +#define RMT_CHK_RX_CARRIER_EN_CH3_M (RMT_CHK_RX_CARRIER_EN_CH3_V << RMT_CHK_RX_CARRIER_EN_CH3_S) +#define RMT_CHK_RX_CARRIER_EN_CH3_V 0x00000001U +#define RMT_CHK_RX_CARRIER_EN_CH3_S 16 +/** RMT_REF_ALWAYS_ON_CH3 : R/W; bitpos: [17]; default: 0; * Set this bit to select a base clock for channel 3. * * 1'h1: APB_CLK 1'h0: REF_TICK */ -#define RMT_REF_ALWAYS_ON_CH0 (BIT(17)) -#define RMT_REF_ALWAYS_ON_CH0_M (RMT_REF_ALWAYS_ON_CH0_V << RMT_REF_ALWAYS_ON_CH0_S) -#define RMT_REF_ALWAYS_ON_CH0_V 0x00000001U -#define RMT_REF_ALWAYS_ON_CH0_S 17 -/** RMT_IDLE_OUT_LV_CH0 : R/W; bitpos: [18]; default: 0; +#define RMT_REF_ALWAYS_ON_CH3 (BIT(17)) +#define RMT_REF_ALWAYS_ON_CH3_M (RMT_REF_ALWAYS_ON_CH3_V << RMT_REF_ALWAYS_ON_CH3_S) +#define RMT_REF_ALWAYS_ON_CH3_V 0x00000001U +#define RMT_REF_ALWAYS_ON_CH3_S 17 +/** RMT_IDLE_OUT_LV_CH3 : R/W; bitpos: [18]; default: 0; * This bit configures the level of output signals in channel 3 when the transmitter * is in idle state. */ -#define RMT_IDLE_OUT_LV_CH0 (BIT(18)) -#define RMT_IDLE_OUT_LV_CH0_M (RMT_IDLE_OUT_LV_CH0_V << RMT_IDLE_OUT_LV_CH0_S) -#define RMT_IDLE_OUT_LV_CH0_V 0x00000001U -#define RMT_IDLE_OUT_LV_CH0_S 18 -/** RMT_IDLE_OUT_EN_CH0 : R/W; bitpos: [19]; default: 0; +#define RMT_IDLE_OUT_LV_CH3 (BIT(18)) +#define RMT_IDLE_OUT_LV_CH3_M (RMT_IDLE_OUT_LV_CH3_V << RMT_IDLE_OUT_LV_CH3_S) +#define RMT_IDLE_OUT_LV_CH3_V 0x00000001U +#define RMT_IDLE_OUT_LV_CH3_S 18 +/** RMT_IDLE_OUT_EN_CH3 : R/W; bitpos: [19]; default: 0; * This is the output enable bit for channel 3 in idle state. */ -#define RMT_IDLE_OUT_EN_CH0 (BIT(19)) -#define RMT_IDLE_OUT_EN_CH0_M (RMT_IDLE_OUT_EN_CH0_V << RMT_IDLE_OUT_EN_CH0_S) -#define RMT_IDLE_OUT_EN_CH0_V 0x00000001U -#define RMT_IDLE_OUT_EN_CH0_S 19 -/** RMT_TX_STOP_CH0 : R/W; bitpos: [20]; default: 0; +#define RMT_IDLE_OUT_EN_CH3 (BIT(19)) +#define RMT_IDLE_OUT_EN_CH3_M (RMT_IDLE_OUT_EN_CH3_V << RMT_IDLE_OUT_EN_CH3_S) +#define RMT_IDLE_OUT_EN_CH3_V 0x00000001U +#define RMT_IDLE_OUT_EN_CH3_S 19 +/** RMT_TX_STOP_CH3 : R/W; bitpos: [20]; default: 0; * Set this bit to stop the transmitter of channel 3 sending data out. */ -#define RMT_TX_STOP_CH0 (BIT(20)) -#define RMT_TX_STOP_CH0_M (RMT_TX_STOP_CH0_V << RMT_TX_STOP_CH0_S) -#define RMT_TX_STOP_CH0_V 0x00000001U -#define RMT_TX_STOP_CH0_S 20 - -/** RMT_CH0STATUS_REG register - * Channel 0 status register - */ -#define RMT_CH0STATUS_REG (DR_REG_RMT_BASE + 0x30) -/** RMT_MEM_WADDR_EX_CH0 : RO; bitpos: [8:0]; default: 0; - * This field records the memory address offset when receiver of channel 0 is using - * the RAM. - */ -#define RMT_MEM_WADDR_EX_CH0 0x000001FFU -#define RMT_MEM_WADDR_EX_CH0_M (RMT_MEM_WADDR_EX_CH0_V << RMT_MEM_WADDR_EX_CH0_S) -#define RMT_MEM_WADDR_EX_CH0_V 0x000001FFU -#define RMT_MEM_WADDR_EX_CH0_S 0 -/** RMT_MEM_RADDR_EX_CH0 : RO; bitpos: [18:10]; default: 0; - * This field records the memory address offset when transmitter of channel 0 is using - * the RAM. - */ -#define RMT_MEM_RADDR_EX_CH0 0x000001FFU -#define RMT_MEM_RADDR_EX_CH0_M (RMT_MEM_RADDR_EX_CH0_V << RMT_MEM_RADDR_EX_CH0_S) -#define RMT_MEM_RADDR_EX_CH0_V 0x000001FFU -#define RMT_MEM_RADDR_EX_CH0_S 10 -/** RMT_STATE_CH0 : RO; bitpos: [22:20]; default: 0; - * This field records the FSM status of channel 0. - */ -#define RMT_STATE_CH0 0x00000007U -#define RMT_STATE_CH0_M (RMT_STATE_CH0_V << RMT_STATE_CH0_S) -#define RMT_STATE_CH0_V 0x00000007U -#define RMT_STATE_CH0_S 20 -/** RMT_MEM_OWNER_ERR_CH0 : RO; bitpos: [23]; default: 0; - * This status bit will be set when the ownership of memory block is violated. - */ -#define RMT_MEM_OWNER_ERR_CH0 (BIT(23)) -#define RMT_MEM_OWNER_ERR_CH0_M (RMT_MEM_OWNER_ERR_CH0_V << RMT_MEM_OWNER_ERR_CH0_S) -#define RMT_MEM_OWNER_ERR_CH0_V 0x00000001U -#define RMT_MEM_OWNER_ERR_CH0_S 23 -/** RMT_MEM_FULL_CH0 : RO; bitpos: [24]; default: 0; - * This status bit will be set if the receiver receives more data than the memory - * allows. - */ -#define RMT_MEM_FULL_CH0 (BIT(24)) -#define RMT_MEM_FULL_CH0_M (RMT_MEM_FULL_CH0_V << RMT_MEM_FULL_CH0_S) -#define RMT_MEM_FULL_CH0_V 0x00000001U -#define RMT_MEM_FULL_CH0_S 24 -/** RMT_MEM_EMPTY_CH0 : RO; bitpos: [25]; default: 0; - * This status bit will be set when the data to be sent is more than memory allows and - * the wrap mode is disabled. - */ -#define RMT_MEM_EMPTY_CH0 (BIT(25)) -#define RMT_MEM_EMPTY_CH0_M (RMT_MEM_EMPTY_CH0_V << RMT_MEM_EMPTY_CH0_S) -#define RMT_MEM_EMPTY_CH0_V 0x00000001U -#define RMT_MEM_EMPTY_CH0_S 25 -/** RMT_APB_MEM_WR_ERR_CH0 : RO; bitpos: [26]; default: 0; - * This status bit will be set if the offset address out of memory size when writes - * RAM via APB bus. - */ -#define RMT_APB_MEM_WR_ERR_CH0 (BIT(26)) -#define RMT_APB_MEM_WR_ERR_CH0_M (RMT_APB_MEM_WR_ERR_CH0_V << RMT_APB_MEM_WR_ERR_CH0_S) -#define RMT_APB_MEM_WR_ERR_CH0_V 0x00000001U -#define RMT_APB_MEM_WR_ERR_CH0_S 26 -/** RMT_APB_MEM_RD_ERR_CH0 : RO; bitpos: [27]; default: 0; - * This status bit will be set if the offset address out of memory size when reads RAM - * via APB bus. - */ -#define RMT_APB_MEM_RD_ERR_CH0 (BIT(27)) -#define RMT_APB_MEM_RD_ERR_CH0_M (RMT_APB_MEM_RD_ERR_CH0_V << RMT_APB_MEM_RD_ERR_CH0_S) -#define RMT_APB_MEM_RD_ERR_CH0_V 0x00000001U -#define RMT_APB_MEM_RD_ERR_CH0_S 27 - -/** RMT_CH1STATUS_REG register - * Channel 1 status register - */ -#define RMT_CH1STATUS_REG (DR_REG_RMT_BASE + 0x34) -/** RMT_MEM_WADDR_EX_CH0 : RO; bitpos: [8:0]; default: 0; - * This field records the memory address offset when receiver of channel 1 is using - * the RAM. - */ -#define RMT_MEM_WADDR_EX_CH0 0x000001FFU -#define RMT_MEM_WADDR_EX_CH0_M (RMT_MEM_WADDR_EX_CH0_V << RMT_MEM_WADDR_EX_CH0_S) -#define RMT_MEM_WADDR_EX_CH0_V 0x000001FFU -#define RMT_MEM_WADDR_EX_CH0_S 0 -/** RMT_MEM_RADDR_EX_CH0 : RO; bitpos: [18:10]; default: 0; - * This field records the memory address offset when transmitter of channel 1 is using - * the RAM. - */ -#define RMT_MEM_RADDR_EX_CH0 0x000001FFU -#define RMT_MEM_RADDR_EX_CH0_M (RMT_MEM_RADDR_EX_CH0_V << RMT_MEM_RADDR_EX_CH0_S) -#define RMT_MEM_RADDR_EX_CH0_V 0x000001FFU -#define RMT_MEM_RADDR_EX_CH0_S 10 -/** RMT_STATE_CH0 : RO; bitpos: [22:20]; default: 0; - * This field records the FSM status of channel 1. - */ -#define RMT_STATE_CH0 0x00000007U -#define RMT_STATE_CH0_M (RMT_STATE_CH0_V << RMT_STATE_CH0_S) -#define RMT_STATE_CH0_V 0x00000007U -#define RMT_STATE_CH0_S 20 -/** RMT_MEM_OWNER_ERR_CH0 : RO; bitpos: [23]; default: 0; - * This status bit will be set when the ownership of memory block is violated. - */ -#define RMT_MEM_OWNER_ERR_CH0 (BIT(23)) -#define RMT_MEM_OWNER_ERR_CH0_M (RMT_MEM_OWNER_ERR_CH0_V << RMT_MEM_OWNER_ERR_CH0_S) -#define RMT_MEM_OWNER_ERR_CH0_V 0x00000001U -#define RMT_MEM_OWNER_ERR_CH0_S 23 -/** RMT_MEM_FULL_CH0 : RO; bitpos: [24]; default: 0; - * This status bit will be set if the receiver receives more data than the memory - * allows. - */ -#define RMT_MEM_FULL_CH0 (BIT(24)) -#define RMT_MEM_FULL_CH0_M (RMT_MEM_FULL_CH0_V << RMT_MEM_FULL_CH0_S) -#define RMT_MEM_FULL_CH0_V 0x00000001U -#define RMT_MEM_FULL_CH0_S 24 -/** RMT_MEM_EMPTY_CH0 : RO; bitpos: [25]; default: 0; - * This status bit will be set when the data to be sent is more than memory allows and - * the wrap mode is disabled. - */ -#define RMT_MEM_EMPTY_CH0 (BIT(25)) -#define RMT_MEM_EMPTY_CH0_M (RMT_MEM_EMPTY_CH0_V << RMT_MEM_EMPTY_CH0_S) -#define RMT_MEM_EMPTY_CH0_V 0x00000001U -#define RMT_MEM_EMPTY_CH0_S 25 -/** RMT_APB_MEM_WR_ERR_CH0 : RO; bitpos: [26]; default: 0; - * This status bit will be set if the offset address out of memory size when writes - * RAM via APB bus. - */ -#define RMT_APB_MEM_WR_ERR_CH0 (BIT(26)) -#define RMT_APB_MEM_WR_ERR_CH0_M (RMT_APB_MEM_WR_ERR_CH0_V << RMT_APB_MEM_WR_ERR_CH0_S) -#define RMT_APB_MEM_WR_ERR_CH0_V 0x00000001U -#define RMT_APB_MEM_WR_ERR_CH0_S 26 -/** RMT_APB_MEM_RD_ERR_CH0 : RO; bitpos: [27]; default: 0; - * This status bit will be set if the offset address out of memory size when reads RAM - * via APB bus. - */ -#define RMT_APB_MEM_RD_ERR_CH0 (BIT(27)) -#define RMT_APB_MEM_RD_ERR_CH0_M (RMT_APB_MEM_RD_ERR_CH0_V << RMT_APB_MEM_RD_ERR_CH0_S) -#define RMT_APB_MEM_RD_ERR_CH0_V 0x00000001U -#define RMT_APB_MEM_RD_ERR_CH0_S 27 +#define RMT_TX_STOP_CH3 (BIT(20)) +#define RMT_TX_STOP_CH3_M (RMT_TX_STOP_CH3_V << RMT_TX_STOP_CH3_S) +#define RMT_TX_STOP_CH3_V 0x00000001U +#define RMT_TX_STOP_CH3_S 20 -/** RMT_CH2STATUS_REG register - * Channel 2 status register +/** RMT_CH0STATUS_REG register + * Channel 0 status register */ -#define RMT_CH2STATUS_REG (DR_REG_RMT_BASE + 0x38) +#define RMT_CH0STATUS_REG (DR_REG_RMT_BASE + 0x30) /** RMT_MEM_WADDR_EX_CH0 : RO; bitpos: [8:0]; default: 0; - * This field records the memory address offset when receiver of channel 2 is using + * This field records the memory address offset when receiver of channel 0 is using * the RAM. */ #define RMT_MEM_WADDR_EX_CH0 0x000001FFU @@ -887,7 +753,7 @@ extern "C" { #define RMT_MEM_WADDR_EX_CH0_V 0x000001FFU #define RMT_MEM_WADDR_EX_CH0_S 0 /** RMT_MEM_RADDR_EX_CH0 : RO; bitpos: [18:10]; default: 0; - * This field records the memory address offset when transmitter of channel 2 is using + * This field records the memory address offset when transmitter of channel 0 is using * the RAM. */ #define RMT_MEM_RADDR_EX_CH0 0x000001FFU @@ -895,7 +761,7 @@ extern "C" { #define RMT_MEM_RADDR_EX_CH0_V 0x000001FFU #define RMT_MEM_RADDR_EX_CH0_S 10 /** RMT_STATE_CH0 : RO; bitpos: [22:20]; default: 0; - * This field records the FSM status of channel 2. + * This field records the FSM status of channel 0. */ #define RMT_STATE_CH0 0x00000007U #define RMT_STATE_CH0_M (RMT_STATE_CH0_V << RMT_STATE_CH0_S) @@ -941,72 +807,206 @@ extern "C" { #define RMT_APB_MEM_RD_ERR_CH0_V 0x00000001U #define RMT_APB_MEM_RD_ERR_CH0_S 27 +/** RMT_CH1STATUS_REG register + * Channel 1 status register + */ +#define RMT_CH1STATUS_REG (DR_REG_RMT_BASE + 0x34) +/** RMT_MEM_WADDR_EX_CH1 : RO; bitpos: [8:0]; default: 0; + * This field records the memory address offset when receiver of channel 1 is using + * the RAM. + */ +#define RMT_MEM_WADDR_EX_CH1 0x000001FFU +#define RMT_MEM_WADDR_EX_CH1_M (RMT_MEM_WADDR_EX_CH1_V << RMT_MEM_WADDR_EX_CH1_S) +#define RMT_MEM_WADDR_EX_CH1_V 0x000001FFU +#define RMT_MEM_WADDR_EX_CH1_S 0 +/** RMT_MEM_RADDR_EX_CH1 : RO; bitpos: [18:10]; default: 0; + * This field records the memory address offset when transmitter of channel 1 is using + * the RAM. + */ +#define RMT_MEM_RADDR_EX_CH1 0x000001FFU +#define RMT_MEM_RADDR_EX_CH1_M (RMT_MEM_RADDR_EX_CH1_V << RMT_MEM_RADDR_EX_CH1_S) +#define RMT_MEM_RADDR_EX_CH1_V 0x000001FFU +#define RMT_MEM_RADDR_EX_CH1_S 10 +/** RMT_STATE_CH1 : RO; bitpos: [22:20]; default: 0; + * This field records the FSM status of channel 1. + */ +#define RMT_STATE_CH1 0x00000007U +#define RMT_STATE_CH1_M (RMT_STATE_CH1_V << RMT_STATE_CH1_S) +#define RMT_STATE_CH1_V 0x00000007U +#define RMT_STATE_CH1_S 20 +/** RMT_MEM_OWNER_ERR_CH1 : RO; bitpos: [23]; default: 0; + * This status bit will be set when the ownership of memory block is violated. + */ +#define RMT_MEM_OWNER_ERR_CH1 (BIT(23)) +#define RMT_MEM_OWNER_ERR_CH1_M (RMT_MEM_OWNER_ERR_CH1_V << RMT_MEM_OWNER_ERR_CH1_S) +#define RMT_MEM_OWNER_ERR_CH1_V 0x00000001U +#define RMT_MEM_OWNER_ERR_CH1_S 23 +/** RMT_MEM_FULL_CH1 : RO; bitpos: [24]; default: 0; + * This status bit will be set if the receiver receives more data than the memory + * allows. + */ +#define RMT_MEM_FULL_CH1 (BIT(24)) +#define RMT_MEM_FULL_CH1_M (RMT_MEM_FULL_CH1_V << RMT_MEM_FULL_CH1_S) +#define RMT_MEM_FULL_CH1_V 0x00000001U +#define RMT_MEM_FULL_CH1_S 24 +/** RMT_MEM_EMPTY_CH1 : RO; bitpos: [25]; default: 0; + * This status bit will be set when the data to be sent is more than memory allows and + * the wrap mode is disabled. + */ +#define RMT_MEM_EMPTY_CH1 (BIT(25)) +#define RMT_MEM_EMPTY_CH1_M (RMT_MEM_EMPTY_CH1_V << RMT_MEM_EMPTY_CH1_S) +#define RMT_MEM_EMPTY_CH1_V 0x00000001U +#define RMT_MEM_EMPTY_CH1_S 25 +/** RMT_APB_MEM_WR_ERR_CH1 : RO; bitpos: [26]; default: 0; + * This status bit will be set if the offset address out of memory size when writes + * RAM via APB bus. + */ +#define RMT_APB_MEM_WR_ERR_CH1 (BIT(26)) +#define RMT_APB_MEM_WR_ERR_CH1_M (RMT_APB_MEM_WR_ERR_CH1_V << RMT_APB_MEM_WR_ERR_CH1_S) +#define RMT_APB_MEM_WR_ERR_CH1_V 0x00000001U +#define RMT_APB_MEM_WR_ERR_CH1_S 26 +/** RMT_APB_MEM_RD_ERR_CH1 : RO; bitpos: [27]; default: 0; + * This status bit will be set if the offset address out of memory size when reads RAM + * via APB bus. + */ +#define RMT_APB_MEM_RD_ERR_CH1 (BIT(27)) +#define RMT_APB_MEM_RD_ERR_CH1_M (RMT_APB_MEM_RD_ERR_CH1_V << RMT_APB_MEM_RD_ERR_CH1_S) +#define RMT_APB_MEM_RD_ERR_CH1_V 0x00000001U +#define RMT_APB_MEM_RD_ERR_CH1_S 27 + +/** RMT_CH2STATUS_REG register + * Channel 2 status register + */ +#define RMT_CH2STATUS_REG (DR_REG_RMT_BASE + 0x38) +/** RMT_MEM_WADDR_EX_CH2 : RO; bitpos: [8:0]; default: 0; + * This field records the memory address offset when receiver of channel 2 is using + * the RAM. + */ +#define RMT_MEM_WADDR_EX_CH2 0x000001FFU +#define RMT_MEM_WADDR_EX_CH2_M (RMT_MEM_WADDR_EX_CH2_V << RMT_MEM_WADDR_EX_CH2_S) +#define RMT_MEM_WADDR_EX_CH2_V 0x000001FFU +#define RMT_MEM_WADDR_EX_CH2_S 0 +/** RMT_MEM_RADDR_EX_CH2 : RO; bitpos: [18:10]; default: 0; + * This field records the memory address offset when transmitter of channel 2 is using + * the RAM. + */ +#define RMT_MEM_RADDR_EX_CH2 0x000001FFU +#define RMT_MEM_RADDR_EX_CH2_M (RMT_MEM_RADDR_EX_CH2_V << RMT_MEM_RADDR_EX_CH2_S) +#define RMT_MEM_RADDR_EX_CH2_V 0x000001FFU +#define RMT_MEM_RADDR_EX_CH2_S 10 +/** RMT_STATE_CH2 : RO; bitpos: [22:20]; default: 0; + * This field records the FSM status of channel 2. + */ +#define RMT_STATE_CH2 0x00000007U +#define RMT_STATE_CH2_M (RMT_STATE_CH2_V << RMT_STATE_CH2_S) +#define RMT_STATE_CH2_V 0x00000007U +#define RMT_STATE_CH2_S 20 +/** RMT_MEM_OWNER_ERR_CH2 : RO; bitpos: [23]; default: 0; + * This status bit will be set when the ownership of memory block is violated. + */ +#define RMT_MEM_OWNER_ERR_CH2 (BIT(23)) +#define RMT_MEM_OWNER_ERR_CH2_M (RMT_MEM_OWNER_ERR_CH2_V << RMT_MEM_OWNER_ERR_CH2_S) +#define RMT_MEM_OWNER_ERR_CH2_V 0x00000001U +#define RMT_MEM_OWNER_ERR_CH2_S 23 +/** RMT_MEM_FULL_CH2 : RO; bitpos: [24]; default: 0; + * This status bit will be set if the receiver receives more data than the memory + * allows. + */ +#define RMT_MEM_FULL_CH2 (BIT(24)) +#define RMT_MEM_FULL_CH2_M (RMT_MEM_FULL_CH2_V << RMT_MEM_FULL_CH2_S) +#define RMT_MEM_FULL_CH2_V 0x00000001U +#define RMT_MEM_FULL_CH2_S 24 +/** RMT_MEM_EMPTY_CH2 : RO; bitpos: [25]; default: 0; + * This status bit will be set when the data to be sent is more than memory allows and + * the wrap mode is disabled. + */ +#define RMT_MEM_EMPTY_CH2 (BIT(25)) +#define RMT_MEM_EMPTY_CH2_M (RMT_MEM_EMPTY_CH2_V << RMT_MEM_EMPTY_CH2_S) +#define RMT_MEM_EMPTY_CH2_V 0x00000001U +#define RMT_MEM_EMPTY_CH2_S 25 +/** RMT_APB_MEM_WR_ERR_CH2 : RO; bitpos: [26]; default: 0; + * This status bit will be set if the offset address out of memory size when writes + * RAM via APB bus. + */ +#define RMT_APB_MEM_WR_ERR_CH2 (BIT(26)) +#define RMT_APB_MEM_WR_ERR_CH2_M (RMT_APB_MEM_WR_ERR_CH2_V << RMT_APB_MEM_WR_ERR_CH2_S) +#define RMT_APB_MEM_WR_ERR_CH2_V 0x00000001U +#define RMT_APB_MEM_WR_ERR_CH2_S 26 +/** RMT_APB_MEM_RD_ERR_CH2 : RO; bitpos: [27]; default: 0; + * This status bit will be set if the offset address out of memory size when reads RAM + * via APB bus. + */ +#define RMT_APB_MEM_RD_ERR_CH2 (BIT(27)) +#define RMT_APB_MEM_RD_ERR_CH2_M (RMT_APB_MEM_RD_ERR_CH2_V << RMT_APB_MEM_RD_ERR_CH2_S) +#define RMT_APB_MEM_RD_ERR_CH2_V 0x00000001U +#define RMT_APB_MEM_RD_ERR_CH2_S 27 + /** RMT_CH3STATUS_REG register * Channel 3 status register */ #define RMT_CH3STATUS_REG (DR_REG_RMT_BASE + 0x3c) -/** RMT_MEM_WADDR_EX_CH0 : RO; bitpos: [8:0]; default: 0; +/** RMT_MEM_WADDR_EX_CH3 : RO; bitpos: [8:0]; default: 0; * This field records the memory address offset when receiver of channel 3 is using * the RAM. */ -#define RMT_MEM_WADDR_EX_CH0 0x000001FFU -#define RMT_MEM_WADDR_EX_CH0_M (RMT_MEM_WADDR_EX_CH0_V << RMT_MEM_WADDR_EX_CH0_S) -#define RMT_MEM_WADDR_EX_CH0_V 0x000001FFU -#define RMT_MEM_WADDR_EX_CH0_S 0 -/** RMT_MEM_RADDR_EX_CH0 : RO; bitpos: [18:10]; default: 0; +#define RMT_MEM_WADDR_EX_CH3 0x000001FFU +#define RMT_MEM_WADDR_EX_CH3_M (RMT_MEM_WADDR_EX_CH3_V << RMT_MEM_WADDR_EX_CH3_S) +#define RMT_MEM_WADDR_EX_CH3_V 0x000001FFU +#define RMT_MEM_WADDR_EX_CH3_S 0 +/** RMT_MEM_RADDR_EX_CH3 : RO; bitpos: [18:10]; default: 0; * This field records the memory address offset when transmitter of channel 3 is using * the RAM. */ -#define RMT_MEM_RADDR_EX_CH0 0x000001FFU -#define RMT_MEM_RADDR_EX_CH0_M (RMT_MEM_RADDR_EX_CH0_V << RMT_MEM_RADDR_EX_CH0_S) -#define RMT_MEM_RADDR_EX_CH0_V 0x000001FFU -#define RMT_MEM_RADDR_EX_CH0_S 10 -/** RMT_STATE_CH0 : RO; bitpos: [22:20]; default: 0; +#define RMT_MEM_RADDR_EX_CH3 0x000001FFU +#define RMT_MEM_RADDR_EX_CH3_M (RMT_MEM_RADDR_EX_CH3_V << RMT_MEM_RADDR_EX_CH3_S) +#define RMT_MEM_RADDR_EX_CH3_V 0x000001FFU +#define RMT_MEM_RADDR_EX_CH3_S 10 +/** RMT_STATE_CH3 : RO; bitpos: [22:20]; default: 0; * This field records the FSM status of channel 3. */ -#define RMT_STATE_CH0 0x00000007U -#define RMT_STATE_CH0_M (RMT_STATE_CH0_V << RMT_STATE_CH0_S) -#define RMT_STATE_CH0_V 0x00000007U -#define RMT_STATE_CH0_S 20 -/** RMT_MEM_OWNER_ERR_CH0 : RO; bitpos: [23]; default: 0; +#define RMT_STATE_CH3 0x00000007U +#define RMT_STATE_CH3_M (RMT_STATE_CH3_V << RMT_STATE_CH3_S) +#define RMT_STATE_CH3_V 0x00000007U +#define RMT_STATE_CH3_S 20 +/** RMT_MEM_OWNER_ERR_CH3 : RO; bitpos: [23]; default: 0; * This status bit will be set when the ownership of memory block is violated. */ -#define RMT_MEM_OWNER_ERR_CH0 (BIT(23)) -#define RMT_MEM_OWNER_ERR_CH0_M (RMT_MEM_OWNER_ERR_CH0_V << RMT_MEM_OWNER_ERR_CH0_S) -#define RMT_MEM_OWNER_ERR_CH0_V 0x00000001U -#define RMT_MEM_OWNER_ERR_CH0_S 23 -/** RMT_MEM_FULL_CH0 : RO; bitpos: [24]; default: 0; +#define RMT_MEM_OWNER_ERR_CH3 (BIT(23)) +#define RMT_MEM_OWNER_ERR_CH3_M (RMT_MEM_OWNER_ERR_CH3_V << RMT_MEM_OWNER_ERR_CH3_S) +#define RMT_MEM_OWNER_ERR_CH3_V 0x00000001U +#define RMT_MEM_OWNER_ERR_CH3_S 23 +/** RMT_MEM_FULL_CH3 : RO; bitpos: [24]; default: 0; * This status bit will be set if the receiver receives more data than the memory * allows. */ -#define RMT_MEM_FULL_CH0 (BIT(24)) -#define RMT_MEM_FULL_CH0_M (RMT_MEM_FULL_CH0_V << RMT_MEM_FULL_CH0_S) -#define RMT_MEM_FULL_CH0_V 0x00000001U -#define RMT_MEM_FULL_CH0_S 24 -/** RMT_MEM_EMPTY_CH0 : RO; bitpos: [25]; default: 0; +#define RMT_MEM_FULL_CH3 (BIT(24)) +#define RMT_MEM_FULL_CH3_M (RMT_MEM_FULL_CH3_V << RMT_MEM_FULL_CH3_S) +#define RMT_MEM_FULL_CH3_V 0x00000001U +#define RMT_MEM_FULL_CH3_S 24 +/** RMT_MEM_EMPTY_CH3 : RO; bitpos: [25]; default: 0; * This status bit will be set when the data to be sent is more than memory allows and * the wrap mode is disabled. */ -#define RMT_MEM_EMPTY_CH0 (BIT(25)) -#define RMT_MEM_EMPTY_CH0_M (RMT_MEM_EMPTY_CH0_V << RMT_MEM_EMPTY_CH0_S) -#define RMT_MEM_EMPTY_CH0_V 0x00000001U -#define RMT_MEM_EMPTY_CH0_S 25 -/** RMT_APB_MEM_WR_ERR_CH0 : RO; bitpos: [26]; default: 0; +#define RMT_MEM_EMPTY_CH3 (BIT(25)) +#define RMT_MEM_EMPTY_CH3_M (RMT_MEM_EMPTY_CH3_V << RMT_MEM_EMPTY_CH3_S) +#define RMT_MEM_EMPTY_CH3_V 0x00000001U +#define RMT_MEM_EMPTY_CH3_S 25 +/** RMT_APB_MEM_WR_ERR_CH3 : RO; bitpos: [26]; default: 0; * This status bit will be set if the offset address out of memory size when writes * RAM via APB bus. */ -#define RMT_APB_MEM_WR_ERR_CH0 (BIT(26)) -#define RMT_APB_MEM_WR_ERR_CH0_M (RMT_APB_MEM_WR_ERR_CH0_V << RMT_APB_MEM_WR_ERR_CH0_S) -#define RMT_APB_MEM_WR_ERR_CH0_V 0x00000001U -#define RMT_APB_MEM_WR_ERR_CH0_S 26 -/** RMT_APB_MEM_RD_ERR_CH0 : RO; bitpos: [27]; default: 0; +#define RMT_APB_MEM_WR_ERR_CH3 (BIT(26)) +#define RMT_APB_MEM_WR_ERR_CH3_M (RMT_APB_MEM_WR_ERR_CH3_V << RMT_APB_MEM_WR_ERR_CH3_S) +#define RMT_APB_MEM_WR_ERR_CH3_V 0x00000001U +#define RMT_APB_MEM_WR_ERR_CH3_S 26 +/** RMT_APB_MEM_RD_ERR_CH3 : RO; bitpos: [27]; default: 0; * This status bit will be set if the offset address out of memory size when reads RAM * via APB bus. */ -#define RMT_APB_MEM_RD_ERR_CH0 (BIT(27)) -#define RMT_APB_MEM_RD_ERR_CH0_M (RMT_APB_MEM_RD_ERR_CH0_V << RMT_APB_MEM_RD_ERR_CH0_S) -#define RMT_APB_MEM_RD_ERR_CH0_V 0x00000001U -#define RMT_APB_MEM_RD_ERR_CH0_S 27 +#define RMT_APB_MEM_RD_ERR_CH3 (BIT(27)) +#define RMT_APB_MEM_RD_ERR_CH3_M (RMT_APB_MEM_RD_ERR_CH3_V << RMT_APB_MEM_RD_ERR_CH3_S) +#define RMT_APB_MEM_RD_ERR_CH3_V 0x00000001U +#define RMT_APB_MEM_RD_ERR_CH3_S 27 /** RMT_CH0ADDR_REG register * Channel 0 address register @@ -1031,58 +1031,58 @@ extern "C" { * Channel 1 address register */ #define RMT_CH1ADDR_REG (DR_REG_RMT_BASE + 0x44) -/** RMT_APB_MEM_WADDR_CH0 : RO; bitpos: [8:0]; default: 0; +/** RMT_APB_MEM_WADDR_CH1 : RO; bitpos: [8:0]; default: 0; * This field records the memory address offset when channel 1 writes RAM via APB bus. */ -#define RMT_APB_MEM_WADDR_CH0 0x000001FFU -#define RMT_APB_MEM_WADDR_CH0_M (RMT_APB_MEM_WADDR_CH0_V << RMT_APB_MEM_WADDR_CH0_S) -#define RMT_APB_MEM_WADDR_CH0_V 0x000001FFU -#define RMT_APB_MEM_WADDR_CH0_S 0 -/** RMT_APB_MEM_RADDR_CH0 : RO; bitpos: [18:10]; default: 0; +#define RMT_APB_MEM_WADDR_CH1 0x000001FFU +#define RMT_APB_MEM_WADDR_CH1_M (RMT_APB_MEM_WADDR_CH1_V << RMT_APB_MEM_WADDR_CH1_S) +#define RMT_APB_MEM_WADDR_CH1_V 0x000001FFU +#define RMT_APB_MEM_WADDR_CH1_S 0 +/** RMT_APB_MEM_RADDR_CH1 : RO; bitpos: [18:10]; default: 0; * This field records the memory address offset when channel 1 reads RAM via APB bus. */ -#define RMT_APB_MEM_RADDR_CH0 0x000001FFU -#define RMT_APB_MEM_RADDR_CH0_M (RMT_APB_MEM_RADDR_CH0_V << RMT_APB_MEM_RADDR_CH0_S) -#define RMT_APB_MEM_RADDR_CH0_V 0x000001FFU -#define RMT_APB_MEM_RADDR_CH0_S 10 +#define RMT_APB_MEM_RADDR_CH1 0x000001FFU +#define RMT_APB_MEM_RADDR_CH1_M (RMT_APB_MEM_RADDR_CH1_V << RMT_APB_MEM_RADDR_CH1_S) +#define RMT_APB_MEM_RADDR_CH1_V 0x000001FFU +#define RMT_APB_MEM_RADDR_CH1_S 10 /** RMT_CH2ADDR_REG register * Channel 2 address register */ #define RMT_CH2ADDR_REG (DR_REG_RMT_BASE + 0x48) -/** RMT_APB_MEM_WADDR_CH0 : RO; bitpos: [8:0]; default: 0; +/** RMT_APB_MEM_WADDR_CH2 : RO; bitpos: [8:0]; default: 0; * This field records the memory address offset when channel 2 writes RAM via APB bus. */ -#define RMT_APB_MEM_WADDR_CH0 0x000001FFU -#define RMT_APB_MEM_WADDR_CH0_M (RMT_APB_MEM_WADDR_CH0_V << RMT_APB_MEM_WADDR_CH0_S) -#define RMT_APB_MEM_WADDR_CH0_V 0x000001FFU -#define RMT_APB_MEM_WADDR_CH0_S 0 -/** RMT_APB_MEM_RADDR_CH0 : RO; bitpos: [18:10]; default: 0; +#define RMT_APB_MEM_WADDR_CH2 0x000001FFU +#define RMT_APB_MEM_WADDR_CH2_M (RMT_APB_MEM_WADDR_CH2_V << RMT_APB_MEM_WADDR_CH2_S) +#define RMT_APB_MEM_WADDR_CH2_V 0x000001FFU +#define RMT_APB_MEM_WADDR_CH2_S 0 +/** RMT_APB_MEM_RADDR_CH2 : RO; bitpos: [18:10]; default: 0; * This field records the memory address offset when channel 2 reads RAM via APB bus. */ -#define RMT_APB_MEM_RADDR_CH0 0x000001FFU -#define RMT_APB_MEM_RADDR_CH0_M (RMT_APB_MEM_RADDR_CH0_V << RMT_APB_MEM_RADDR_CH0_S) -#define RMT_APB_MEM_RADDR_CH0_V 0x000001FFU -#define RMT_APB_MEM_RADDR_CH0_S 10 +#define RMT_APB_MEM_RADDR_CH2 0x000001FFU +#define RMT_APB_MEM_RADDR_CH2_M (RMT_APB_MEM_RADDR_CH2_V << RMT_APB_MEM_RADDR_CH2_S) +#define RMT_APB_MEM_RADDR_CH2_V 0x000001FFU +#define RMT_APB_MEM_RADDR_CH2_S 10 /** RMT_CH3ADDR_REG register * Channel 3 address register */ #define RMT_CH3ADDR_REG (DR_REG_RMT_BASE + 0x4c) -/** RMT_APB_MEM_WADDR_CH0 : RO; bitpos: [8:0]; default: 0; +/** RMT_APB_MEM_WADDR_CH3 : RO; bitpos: [8:0]; default: 0; * This field records the memory address offset when channel 3 writes RAM via APB bus. */ -#define RMT_APB_MEM_WADDR_CH0 0x000001FFU -#define RMT_APB_MEM_WADDR_CH0_M (RMT_APB_MEM_WADDR_CH0_V << RMT_APB_MEM_WADDR_CH0_S) -#define RMT_APB_MEM_WADDR_CH0_V 0x000001FFU -#define RMT_APB_MEM_WADDR_CH0_S 0 -/** RMT_APB_MEM_RADDR_CH0 : RO; bitpos: [18:10]; default: 0; +#define RMT_APB_MEM_WADDR_CH3 0x000001FFU +#define RMT_APB_MEM_WADDR_CH3_M (RMT_APB_MEM_WADDR_CH3_V << RMT_APB_MEM_WADDR_CH3_S) +#define RMT_APB_MEM_WADDR_CH3_V 0x000001FFU +#define RMT_APB_MEM_WADDR_CH3_S 0 +/** RMT_APB_MEM_RADDR_CH3 : RO; bitpos: [18:10]; default: 0; * This field records the memory address offset when channel 3 reads RAM via APB bus. */ -#define RMT_APB_MEM_RADDR_CH0 0x000001FFU -#define RMT_APB_MEM_RADDR_CH0_M (RMT_APB_MEM_RADDR_CH0_V << RMT_APB_MEM_RADDR_CH0_S) -#define RMT_APB_MEM_RADDR_CH0_V 0x000001FFU -#define RMT_APB_MEM_RADDR_CH0_S 10 +#define RMT_APB_MEM_RADDR_CH3 0x000001FFU +#define RMT_APB_MEM_RADDR_CH3_M (RMT_APB_MEM_RADDR_CH3_V << RMT_APB_MEM_RADDR_CH3_S) +#define RMT_APB_MEM_RADDR_CH3_V 0x000001FFU +#define RMT_APB_MEM_RADDR_CH3_S 10 /** RMT_INT_RAW_REG register * Raw interrupt status register @@ -1697,64 +1697,64 @@ extern "C" { * Channel 1 duty cycle configuration register */ #define RMT_CH1CARRIER_DUTY_REG (DR_REG_RMT_BASE + 0x64) -/** RMT_CARRIER_LOW_CH0 : R/W; bitpos: [15:0]; default: 64; +/** RMT_CARRIER_LOW_CH1 : R/W; bitpos: [15:0]; default: 64; * This field is used to configure the clock cycles of carrier wave at low level for * channel 1. */ -#define RMT_CARRIER_LOW_CH0 0x0000FFFFU -#define RMT_CARRIER_LOW_CH0_M (RMT_CARRIER_LOW_CH0_V << RMT_CARRIER_LOW_CH0_S) -#define RMT_CARRIER_LOW_CH0_V 0x0000FFFFU -#define RMT_CARRIER_LOW_CH0_S 0 -/** RMT_CARRIER_HIGH_CH0 : R/W; bitpos: [31:16]; default: 64; +#define RMT_CARRIER_LOW_CH1 0x0000FFFFU +#define RMT_CARRIER_LOW_CH1_M (RMT_CARRIER_LOW_CH1_V << RMT_CARRIER_LOW_CH1_S) +#define RMT_CARRIER_LOW_CH1_V 0x0000FFFFU +#define RMT_CARRIER_LOW_CH1_S 0 +/** RMT_CARRIER_HIGH_CH1 : R/W; bitpos: [31:16]; default: 64; * This field is used to configure the clock cycles of carrier wave at high level for * channel 1. */ -#define RMT_CARRIER_HIGH_CH0 0x0000FFFFU -#define RMT_CARRIER_HIGH_CH0_M (RMT_CARRIER_HIGH_CH0_V << RMT_CARRIER_HIGH_CH0_S) -#define RMT_CARRIER_HIGH_CH0_V 0x0000FFFFU -#define RMT_CARRIER_HIGH_CH0_S 16 +#define RMT_CARRIER_HIGH_CH1 0x0000FFFFU +#define RMT_CARRIER_HIGH_CH1_M (RMT_CARRIER_HIGH_CH1_V << RMT_CARRIER_HIGH_CH1_S) +#define RMT_CARRIER_HIGH_CH1_V 0x0000FFFFU +#define RMT_CARRIER_HIGH_CH1_S 16 /** RMT_CH2CARRIER_DUTY_REG register * Channel 2 duty cycle configuration register */ #define RMT_CH2CARRIER_DUTY_REG (DR_REG_RMT_BASE + 0x68) -/** RMT_CARRIER_LOW_CH0 : R/W; bitpos: [15:0]; default: 64; +/** RMT_CARRIER_LOW_CH2 : R/W; bitpos: [15:0]; default: 64; * This field is used to configure the clock cycles of carrier wave at low level for * channel 2. */ -#define RMT_CARRIER_LOW_CH0 0x0000FFFFU -#define RMT_CARRIER_LOW_CH0_M (RMT_CARRIER_LOW_CH0_V << RMT_CARRIER_LOW_CH0_S) -#define RMT_CARRIER_LOW_CH0_V 0x0000FFFFU -#define RMT_CARRIER_LOW_CH0_S 0 -/** RMT_CARRIER_HIGH_CH0 : R/W; bitpos: [31:16]; default: 64; +#define RMT_CARRIER_LOW_CH2 0x0000FFFFU +#define RMT_CARRIER_LOW_CH2_M (RMT_CARRIER_LOW_CH2_V << RMT_CARRIER_LOW_CH2_S) +#define RMT_CARRIER_LOW_CH2_V 0x0000FFFFU +#define RMT_CARRIER_LOW_CH2_S 0 +/** RMT_CARRIER_HIGH_CH2 : R/W; bitpos: [31:16]; default: 64; * This field is used to configure the clock cycles of carrier wave at high level for * channel 2. */ -#define RMT_CARRIER_HIGH_CH0 0x0000FFFFU -#define RMT_CARRIER_HIGH_CH0_M (RMT_CARRIER_HIGH_CH0_V << RMT_CARRIER_HIGH_CH0_S) -#define RMT_CARRIER_HIGH_CH0_V 0x0000FFFFU -#define RMT_CARRIER_HIGH_CH0_S 16 +#define RMT_CARRIER_HIGH_CH2 0x0000FFFFU +#define RMT_CARRIER_HIGH_CH2_M (RMT_CARRIER_HIGH_CH2_V << RMT_CARRIER_HIGH_CH2_S) +#define RMT_CARRIER_HIGH_CH2_V 0x0000FFFFU +#define RMT_CARRIER_HIGH_CH2_S 16 /** RMT_CH3CARRIER_DUTY_REG register * Channel 3 duty cycle configuration register */ #define RMT_CH3CARRIER_DUTY_REG (DR_REG_RMT_BASE + 0x6c) -/** RMT_CARRIER_LOW_CH0 : R/W; bitpos: [15:0]; default: 64; +/** RMT_CARRIER_LOW_CH3 : R/W; bitpos: [15:0]; default: 64; * This field is used to configure the clock cycles of carrier wave at low level for * channel 3. */ -#define RMT_CARRIER_LOW_CH0 0x0000FFFFU -#define RMT_CARRIER_LOW_CH0_M (RMT_CARRIER_LOW_CH0_V << RMT_CARRIER_LOW_CH0_S) -#define RMT_CARRIER_LOW_CH0_V 0x0000FFFFU -#define RMT_CARRIER_LOW_CH0_S 0 -/** RMT_CARRIER_HIGH_CH0 : R/W; bitpos: [31:16]; default: 64; +#define RMT_CARRIER_LOW_CH3 0x0000FFFFU +#define RMT_CARRIER_LOW_CH3_M (RMT_CARRIER_LOW_CH3_V << RMT_CARRIER_LOW_CH3_S) +#define RMT_CARRIER_LOW_CH3_V 0x0000FFFFU +#define RMT_CARRIER_LOW_CH3_S 0 +/** RMT_CARRIER_HIGH_CH3 : R/W; bitpos: [31:16]; default: 64; * This field is used to configure the clock cycles of carrier wave at high level for * channel 3. */ -#define RMT_CARRIER_HIGH_CH0 0x0000FFFFU -#define RMT_CARRIER_HIGH_CH0_M (RMT_CARRIER_HIGH_CH0_V << RMT_CARRIER_HIGH_CH0_S) -#define RMT_CARRIER_HIGH_CH0_V 0x0000FFFFU -#define RMT_CARRIER_HIGH_CH0_S 16 +#define RMT_CARRIER_HIGH_CH3 0x0000FFFFU +#define RMT_CARRIER_HIGH_CH3_M (RMT_CARRIER_HIGH_CH3_V << RMT_CARRIER_HIGH_CH3_S) +#define RMT_CARRIER_HIGH_CH3_V 0x0000FFFFU +#define RMT_CARRIER_HIGH_CH3_S 16 /** RMT_CH0_TX_LIM_REG register * Channel 0 Tx event configuration register @@ -1797,112 +1797,112 @@ extern "C" { * Channel 1 Tx event configuration register */ #define RMT_CH1_TX_LIM_REG (DR_REG_RMT_BASE + 0x74) -/** RMT_TX_LIM_CH0 : R/W; bitpos: [8:0]; default: 128; +/** RMT_TX_LIM_CH1 : R/W; bitpos: [8:0]; default: 128; * This field is used to configure the maximum entries that channel 1 can send out. * When RMT_MEM_SIZE_CH1 = 1, this field can be set to any value among 0 ~ 128 * (64*32/16 = 128). When RMT_MEM_SIZE_CH1 > 1, this field can be set to any value * among (0 ~ 128)*RMT_MEM_SIZE_CH1. */ -#define RMT_TX_LIM_CH0 0x000001FFU -#define RMT_TX_LIM_CH0_M (RMT_TX_LIM_CH0_V << RMT_TX_LIM_CH0_S) -#define RMT_TX_LIM_CH0_V 0x000001FFU -#define RMT_TX_LIM_CH0_S 0 -/** RMT_TX_LOOP_NUM_CH0 : R/W; bitpos: [18:9]; default: 0; +#define RMT_TX_LIM_CH1 0x000001FFU +#define RMT_TX_LIM_CH1_M (RMT_TX_LIM_CH1_V << RMT_TX_LIM_CH1_S) +#define RMT_TX_LIM_CH1_V 0x000001FFU +#define RMT_TX_LIM_CH1_S 0 +/** RMT_TX_LOOP_NUM_CH1 : R/W; bitpos: [18:9]; default: 0; * This field is used to configure the maximum loop times when continuous transmission * mode is enabled. */ -#define RMT_TX_LOOP_NUM_CH0 0x000003FFU -#define RMT_TX_LOOP_NUM_CH0_M (RMT_TX_LOOP_NUM_CH0_V << RMT_TX_LOOP_NUM_CH0_S) -#define RMT_TX_LOOP_NUM_CH0_V 0x000003FFU -#define RMT_TX_LOOP_NUM_CH0_S 9 -/** RMT_TX_LOOP_CNT_EN_CH0 : R/W; bitpos: [19]; default: 0; +#define RMT_TX_LOOP_NUM_CH1 0x000003FFU +#define RMT_TX_LOOP_NUM_CH1_M (RMT_TX_LOOP_NUM_CH1_V << RMT_TX_LOOP_NUM_CH1_S) +#define RMT_TX_LOOP_NUM_CH1_V 0x000003FFU +#define RMT_TX_LOOP_NUM_CH1_S 9 +/** RMT_TX_LOOP_CNT_EN_CH1 : R/W; bitpos: [19]; default: 0; * This bit is used to enable loop counting. */ -#define RMT_TX_LOOP_CNT_EN_CH0 (BIT(19)) -#define RMT_TX_LOOP_CNT_EN_CH0_M (RMT_TX_LOOP_CNT_EN_CH0_V << RMT_TX_LOOP_CNT_EN_CH0_S) -#define RMT_TX_LOOP_CNT_EN_CH0_V 0x00000001U -#define RMT_TX_LOOP_CNT_EN_CH0_S 19 -/** RMT_LOOP_COUNT_RESET_CH0 : WO; bitpos: [20]; default: 0; +#define RMT_TX_LOOP_CNT_EN_CH1 (BIT(19)) +#define RMT_TX_LOOP_CNT_EN_CH1_M (RMT_TX_LOOP_CNT_EN_CH1_V << RMT_TX_LOOP_CNT_EN_CH1_S) +#define RMT_TX_LOOP_CNT_EN_CH1_V 0x00000001U +#define RMT_TX_LOOP_CNT_EN_CH1_S 19 +/** RMT_LOOP_COUNT_RESET_CH1 : WO; bitpos: [20]; default: 0; * This bit is used to reset loop counting when continuous transmission mode is valid. */ -#define RMT_LOOP_COUNT_RESET_CH0 (BIT(20)) -#define RMT_LOOP_COUNT_RESET_CH0_M (RMT_LOOP_COUNT_RESET_CH0_V << RMT_LOOP_COUNT_RESET_CH0_S) -#define RMT_LOOP_COUNT_RESET_CH0_V 0x00000001U -#define RMT_LOOP_COUNT_RESET_CH0_S 20 +#define RMT_LOOP_COUNT_RESET_CH1 (BIT(20)) +#define RMT_LOOP_COUNT_RESET_CH1_M (RMT_LOOP_COUNT_RESET_CH1_V << RMT_LOOP_COUNT_RESET_CH1_S) +#define RMT_LOOP_COUNT_RESET_CH1_V 0x00000001U +#define RMT_LOOP_COUNT_RESET_CH1_S 20 /** RMT_CH2_TX_LIM_REG register * Channel 2 Tx event configuration register */ #define RMT_CH2_TX_LIM_REG (DR_REG_RMT_BASE + 0x78) -/** RMT_TX_LIM_CH0 : R/W; bitpos: [8:0]; default: 128; +/** RMT_TX_LIM_CH2 : R/W; bitpos: [8:0]; default: 128; * This field is used to configure the maximum entries that channel 2 can send out. * When RMT_MEM_SIZE_CH2 = 1, this field can be set to any value among 0 ~ 128 * (64*32/16 = 128). When RMT_MEM_SIZE_CH2 > 1, this field can be set to any value * among (0 ~ 128)*RMT_MEM_SIZE_CH2. */ -#define RMT_TX_LIM_CH0 0x000001FFU -#define RMT_TX_LIM_CH0_M (RMT_TX_LIM_CH0_V << RMT_TX_LIM_CH0_S) -#define RMT_TX_LIM_CH0_V 0x000001FFU -#define RMT_TX_LIM_CH0_S 0 -/** RMT_TX_LOOP_NUM_CH0 : R/W; bitpos: [18:9]; default: 0; +#define RMT_TX_LIM_CH2 0x000001FFU +#define RMT_TX_LIM_CH2_M (RMT_TX_LIM_CH2_V << RMT_TX_LIM_CH2_S) +#define RMT_TX_LIM_CH2_V 0x000001FFU +#define RMT_TX_LIM_CH2_S 0 +/** RMT_TX_LOOP_NUM_CH2 : R/W; bitpos: [18:9]; default: 0; * This field is used to configure the maximum loop times when continuous transmission * mode is enabled. */ -#define RMT_TX_LOOP_NUM_CH0 0x000003FFU -#define RMT_TX_LOOP_NUM_CH0_M (RMT_TX_LOOP_NUM_CH0_V << RMT_TX_LOOP_NUM_CH0_S) -#define RMT_TX_LOOP_NUM_CH0_V 0x000003FFU -#define RMT_TX_LOOP_NUM_CH0_S 9 -/** RMT_TX_LOOP_CNT_EN_CH0 : R/W; bitpos: [19]; default: 0; +#define RMT_TX_LOOP_NUM_CH2 0x000003FFU +#define RMT_TX_LOOP_NUM_CH2_M (RMT_TX_LOOP_NUM_CH2_V << RMT_TX_LOOP_NUM_CH2_S) +#define RMT_TX_LOOP_NUM_CH2_V 0x000003FFU +#define RMT_TX_LOOP_NUM_CH2_S 9 +/** RMT_TX_LOOP_CNT_EN_CH2 : R/W; bitpos: [19]; default: 0; * This bit is used to enable loop counting. */ -#define RMT_TX_LOOP_CNT_EN_CH0 (BIT(19)) -#define RMT_TX_LOOP_CNT_EN_CH0_M (RMT_TX_LOOP_CNT_EN_CH0_V << RMT_TX_LOOP_CNT_EN_CH0_S) -#define RMT_TX_LOOP_CNT_EN_CH0_V 0x00000001U -#define RMT_TX_LOOP_CNT_EN_CH0_S 19 -/** RMT_LOOP_COUNT_RESET_CH0 : WO; bitpos: [20]; default: 0; +#define RMT_TX_LOOP_CNT_EN_CH2 (BIT(19)) +#define RMT_TX_LOOP_CNT_EN_CH2_M (RMT_TX_LOOP_CNT_EN_CH2_V << RMT_TX_LOOP_CNT_EN_CH2_S) +#define RMT_TX_LOOP_CNT_EN_CH2_V 0x00000001U +#define RMT_TX_LOOP_CNT_EN_CH2_S 19 +/** RMT_LOOP_COUNT_RESET_CH2 : WO; bitpos: [20]; default: 0; * This bit is used to reset loop counting when continuous transmission mode is valid. */ -#define RMT_LOOP_COUNT_RESET_CH0 (BIT(20)) -#define RMT_LOOP_COUNT_RESET_CH0_M (RMT_LOOP_COUNT_RESET_CH0_V << RMT_LOOP_COUNT_RESET_CH0_S) -#define RMT_LOOP_COUNT_RESET_CH0_V 0x00000001U -#define RMT_LOOP_COUNT_RESET_CH0_S 20 +#define RMT_LOOP_COUNT_RESET_CH2 (BIT(20)) +#define RMT_LOOP_COUNT_RESET_CH2_M (RMT_LOOP_COUNT_RESET_CH2_V << RMT_LOOP_COUNT_RESET_CH2_S) +#define RMT_LOOP_COUNT_RESET_CH2_V 0x00000001U +#define RMT_LOOP_COUNT_RESET_CH2_S 20 /** RMT_CH3_TX_LIM_REG register * Channel 3 Tx event configuration register */ #define RMT_CH3_TX_LIM_REG (DR_REG_RMT_BASE + 0x7c) -/** RMT_TX_LIM_CH0 : R/W; bitpos: [8:0]; default: 128; +/** RMT_TX_LIM_CH3 : R/W; bitpos: [8:0]; default: 128; * This field is used to configure the maximum entries that channel 3 can send out. * When RMT_MEM_SIZE_CH3 = 1, this field can be set to any value among 0 ~ 128 * (64*32/16 = 128). When RMT_MEM_SIZE_CH3 > 1, this field can be set to any value * among (0 ~ 128)*RMT_MEM_SIZE_CH3. */ -#define RMT_TX_LIM_CH0 0x000001FFU -#define RMT_TX_LIM_CH0_M (RMT_TX_LIM_CH0_V << RMT_TX_LIM_CH0_S) -#define RMT_TX_LIM_CH0_V 0x000001FFU -#define RMT_TX_LIM_CH0_S 0 -/** RMT_TX_LOOP_NUM_CH0 : R/W; bitpos: [18:9]; default: 0; +#define RMT_TX_LIM_CH3 0x000001FFU +#define RMT_TX_LIM_CH3_M (RMT_TX_LIM_CH3_V << RMT_TX_LIM_CH3_S) +#define RMT_TX_LIM_CH3_V 0x000001FFU +#define RMT_TX_LIM_CH3_S 0 +/** RMT_TX_LOOP_NUM_CH3 : R/W; bitpos: [18:9]; default: 0; * This field is used to configure the maximum loop times when continuous transmission * mode is enabled. */ -#define RMT_TX_LOOP_NUM_CH0 0x000003FFU -#define RMT_TX_LOOP_NUM_CH0_M (RMT_TX_LOOP_NUM_CH0_V << RMT_TX_LOOP_NUM_CH0_S) -#define RMT_TX_LOOP_NUM_CH0_V 0x000003FFU -#define RMT_TX_LOOP_NUM_CH0_S 9 -/** RMT_TX_LOOP_CNT_EN_CH0 : R/W; bitpos: [19]; default: 0; +#define RMT_TX_LOOP_NUM_CH3 0x000003FFU +#define RMT_TX_LOOP_NUM_CH3_M (RMT_TX_LOOP_NUM_CH3_V << RMT_TX_LOOP_NUM_CH3_S) +#define RMT_TX_LOOP_NUM_CH3_V 0x000003FFU +#define RMT_TX_LOOP_NUM_CH3_S 9 +/** RMT_TX_LOOP_CNT_EN_CH3 : R/W; bitpos: [19]; default: 0; * This bit is used to enable loop counting. */ -#define RMT_TX_LOOP_CNT_EN_CH0 (BIT(19)) -#define RMT_TX_LOOP_CNT_EN_CH0_M (RMT_TX_LOOP_CNT_EN_CH0_V << RMT_TX_LOOP_CNT_EN_CH0_S) -#define RMT_TX_LOOP_CNT_EN_CH0_V 0x00000001U -#define RMT_TX_LOOP_CNT_EN_CH0_S 19 -/** RMT_LOOP_COUNT_RESET_CH0 : WO; bitpos: [20]; default: 0; +#define RMT_TX_LOOP_CNT_EN_CH3 (BIT(19)) +#define RMT_TX_LOOP_CNT_EN_CH3_M (RMT_TX_LOOP_CNT_EN_CH3_V << RMT_TX_LOOP_CNT_EN_CH3_S) +#define RMT_TX_LOOP_CNT_EN_CH3_V 0x00000001U +#define RMT_TX_LOOP_CNT_EN_CH3_S 19 +/** RMT_LOOP_COUNT_RESET_CH3 : WO; bitpos: [20]; default: 0; * This bit is used to reset loop counting when continuous transmission mode is valid. */ -#define RMT_LOOP_COUNT_RESET_CH0 (BIT(20)) -#define RMT_LOOP_COUNT_RESET_CH0_M (RMT_LOOP_COUNT_RESET_CH0_V << RMT_LOOP_COUNT_RESET_CH0_S) -#define RMT_LOOP_COUNT_RESET_CH0_V 0x00000001U -#define RMT_LOOP_COUNT_RESET_CH0_S 20 +#define RMT_LOOP_COUNT_RESET_CH3 (BIT(20)) +#define RMT_LOOP_COUNT_RESET_CH3_M (RMT_LOOP_COUNT_RESET_CH3_V << RMT_LOOP_COUNT_RESET_CH3_S) +#define RMT_LOOP_COUNT_RESET_CH3_V 0x00000001U +#define RMT_LOOP_COUNT_RESET_CH3_S 20 /** RMT_APB_CONF_REG register * RMT APB configuration register @@ -2056,64 +2056,64 @@ extern "C" { * Channel 1 carrier remove register */ #define RMT_CH1_RX_CARRIER_RM_REG (DR_REG_RMT_BASE + 0x90) -/** RMT_CARRIER_LOW_THRES_CH0 : R/W; bitpos: [15:0]; default: 0; +/** RMT_CARRIER_LOW_THRES_CH1 : R/W; bitpos: [15:0]; default: 0; * The low level period in carrier modulation mode is (RMT_CARRIER_LOW_THRES_CH1 + 1) * clock cycles for channel 1. */ -#define RMT_CARRIER_LOW_THRES_CH0 0x0000FFFFU -#define RMT_CARRIER_LOW_THRES_CH0_M (RMT_CARRIER_LOW_THRES_CH0_V << RMT_CARRIER_LOW_THRES_CH0_S) -#define RMT_CARRIER_LOW_THRES_CH0_V 0x0000FFFFU -#define RMT_CARRIER_LOW_THRES_CH0_S 0 -/** RMT_CARRIER_HIGH_THRES_CH0 : R/W; bitpos: [31:16]; default: 0; +#define RMT_CARRIER_LOW_THRES_CH1 0x0000FFFFU +#define RMT_CARRIER_LOW_THRES_CH1_M (RMT_CARRIER_LOW_THRES_CH1_V << RMT_CARRIER_LOW_THRES_CH1_S) +#define RMT_CARRIER_LOW_THRES_CH1_V 0x0000FFFFU +#define RMT_CARRIER_LOW_THRES_CH1_S 0 +/** RMT_CARRIER_HIGH_THRES_CH1 : R/W; bitpos: [31:16]; default: 0; * The high level period in carrier modulation mode is (RMT_CARRIER_HIGH_THRES_CH1 + * 1) clock cycles for channel 1. */ -#define RMT_CARRIER_HIGH_THRES_CH0 0x0000FFFFU -#define RMT_CARRIER_HIGH_THRES_CH0_M (RMT_CARRIER_HIGH_THRES_CH0_V << RMT_CARRIER_HIGH_THRES_CH0_S) -#define RMT_CARRIER_HIGH_THRES_CH0_V 0x0000FFFFU -#define RMT_CARRIER_HIGH_THRES_CH0_S 16 +#define RMT_CARRIER_HIGH_THRES_CH1 0x0000FFFFU +#define RMT_CARRIER_HIGH_THRES_CH1_M (RMT_CARRIER_HIGH_THRES_CH1_V << RMT_CARRIER_HIGH_THRES_CH1_S) +#define RMT_CARRIER_HIGH_THRES_CH1_V 0x0000FFFFU +#define RMT_CARRIER_HIGH_THRES_CH1_S 16 /** RMT_CH2_RX_CARRIER_RM_REG register * Channel 2 carrier remove register */ #define RMT_CH2_RX_CARRIER_RM_REG (DR_REG_RMT_BASE + 0x94) -/** RMT_CARRIER_LOW_THRES_CH0 : R/W; bitpos: [15:0]; default: 0; +/** RMT_CARRIER_LOW_THRES_CH2 : R/W; bitpos: [15:0]; default: 0; * The low level period in carrier modulation mode is (RMT_CARRIER_LOW_THRES_CH2 + 1) * clock cycles for channel 2. */ -#define RMT_CARRIER_LOW_THRES_CH0 0x0000FFFFU -#define RMT_CARRIER_LOW_THRES_CH0_M (RMT_CARRIER_LOW_THRES_CH0_V << RMT_CARRIER_LOW_THRES_CH0_S) -#define RMT_CARRIER_LOW_THRES_CH0_V 0x0000FFFFU -#define RMT_CARRIER_LOW_THRES_CH0_S 0 -/** RMT_CARRIER_HIGH_THRES_CH0 : R/W; bitpos: [31:16]; default: 0; +#define RMT_CARRIER_LOW_THRES_CH2 0x0000FFFFU +#define RMT_CARRIER_LOW_THRES_CH2_M (RMT_CARRIER_LOW_THRES_CH2_V << RMT_CARRIER_LOW_THRES_CH2_S) +#define RMT_CARRIER_LOW_THRES_CH2_V 0x0000FFFFU +#define RMT_CARRIER_LOW_THRES_CH2_S 0 +/** RMT_CARRIER_HIGH_THRES_CH2 : R/W; bitpos: [31:16]; default: 0; * The high level period in carrier modulation mode is (RMT_CARRIER_HIGH_THRES_CH2 + * 1) clock cycles for channel 2. */ -#define RMT_CARRIER_HIGH_THRES_CH0 0x0000FFFFU -#define RMT_CARRIER_HIGH_THRES_CH0_M (RMT_CARRIER_HIGH_THRES_CH0_V << RMT_CARRIER_HIGH_THRES_CH0_S) -#define RMT_CARRIER_HIGH_THRES_CH0_V 0x0000FFFFU -#define RMT_CARRIER_HIGH_THRES_CH0_S 16 +#define RMT_CARRIER_HIGH_THRES_CH2 0x0000FFFFU +#define RMT_CARRIER_HIGH_THRES_CH2_M (RMT_CARRIER_HIGH_THRES_CH2_V << RMT_CARRIER_HIGH_THRES_CH2_S) +#define RMT_CARRIER_HIGH_THRES_CH2_V 0x0000FFFFU +#define RMT_CARRIER_HIGH_THRES_CH2_S 16 /** RMT_CH3_RX_CARRIER_RM_REG register * Channel 3 carrier remove register */ #define RMT_CH3_RX_CARRIER_RM_REG (DR_REG_RMT_BASE + 0x98) -/** RMT_CARRIER_LOW_THRES_CH0 : R/W; bitpos: [15:0]; default: 0; +/** RMT_CARRIER_LOW_THRES_CH3 : R/W; bitpos: [15:0]; default: 0; * The low level period in carrier modulation mode is (RMT_CARRIER_LOW_THRES_CH3 + 1) * clock cycles for channel 3. */ -#define RMT_CARRIER_LOW_THRES_CH0 0x0000FFFFU -#define RMT_CARRIER_LOW_THRES_CH0_M (RMT_CARRIER_LOW_THRES_CH0_V << RMT_CARRIER_LOW_THRES_CH0_S) -#define RMT_CARRIER_LOW_THRES_CH0_V 0x0000FFFFU -#define RMT_CARRIER_LOW_THRES_CH0_S 0 -/** RMT_CARRIER_HIGH_THRES_CH0 : R/W; bitpos: [31:16]; default: 0; +#define RMT_CARRIER_LOW_THRES_CH3 0x0000FFFFU +#define RMT_CARRIER_LOW_THRES_CH3_M (RMT_CARRIER_LOW_THRES_CH3_V << RMT_CARRIER_LOW_THRES_CH3_S) +#define RMT_CARRIER_LOW_THRES_CH3_V 0x0000FFFFU +#define RMT_CARRIER_LOW_THRES_CH3_S 0 +/** RMT_CARRIER_HIGH_THRES_CH3 : R/W; bitpos: [31:16]; default: 0; * The high level period in carrier modulation mode is (RMT_CARRIER_HIGH_THRES_CH3 + * 1) clock cycles for channel 3. */ -#define RMT_CARRIER_HIGH_THRES_CH0 0x0000FFFFU -#define RMT_CARRIER_HIGH_THRES_CH0_M (RMT_CARRIER_HIGH_THRES_CH0_V << RMT_CARRIER_HIGH_THRES_CH0_S) -#define RMT_CARRIER_HIGH_THRES_CH0_V 0x0000FFFFU -#define RMT_CARRIER_HIGH_THRES_CH0_S 16 +#define RMT_CARRIER_HIGH_THRES_CH3 0x0000FFFFU +#define RMT_CARRIER_HIGH_THRES_CH3_M (RMT_CARRIER_HIGH_THRES_CH3_V << RMT_CARRIER_HIGH_THRES_CH3_S) +#define RMT_CARRIER_HIGH_THRES_CH3_V 0x0000FFFFU +#define RMT_CARRIER_HIGH_THRES_CH3_S 16 /** RMT_DATE_REG register * Version control register diff --git a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/rtc.h b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/rtc.h index 11b13fb6aaf..12cb8ba1e80 100644 --- a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/rtc.h +++ b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/rtc.h @@ -615,6 +615,11 @@ void rtc_dig_clk8m_enable(void); */ void rtc_dig_clk8m_disable(void); +/** + * @brief Get whether the rtc digital 8M clock is enabled + */ +bool rtc_dig_8m_enabled(void); + /** * @brief Calculate the real clock value after the clock calibration * @@ -668,47 +673,18 @@ typedef struct { uint32_t dig_dbias_slp : 3; //!< set bias for digital domain, in sleep mode uint32_t rtc_dbias_wak : 3; //!< set bias for RTC domain, in active mode uint32_t rtc_dbias_slp : 3; //!< set bias for RTC domain, in sleep mode + uint32_t dbg_atten_monitor : 4; //!< voltage parameter, in monitor mode + uint32_t bias_sleep_monitor : 1; //!< circuit control parameter, in monitor mode + uint32_t dbg_atten_slp : 4; //!< voltage parameter, in sleep mode + uint32_t bias_sleep_slp : 1; //!< circuit control parameter, in sleep mode + uint32_t pd_cur_monitor : 1; //!< circuit control parameter, in monitor mode + uint32_t pd_cur_slp : 1; //!< circuit control parameter, in sleep mode uint32_t vddsdio_pd_en : 1; //!< power down VDDSDIO regulator uint32_t xtal_fpu : 1; //!< keep main XTAL powered up in sleep uint32_t deep_slp_reject : 1; uint32_t light_slp_reject : 1; } rtc_sleep_config_t; -/** - * Default initializer for rtc_sleep_config_t - * - * This initializer sets all fields to "reasonable" values (e.g. suggested for - * production use) based on a combination of RTC_SLEEP_PD_x flags. - * - * @param RTC_SLEEP_PD_x flags combined using bitwise OR - */ -#define is_dslp(pd_flags) ((pd_flags) & RTC_SLEEP_PD_DIG) -#define RTC_SLEEP_CONFIG_DEFAULT(sleep_flags) { \ - .lslp_mem_inf_fpu = 0, \ - .rtc_mem_inf_follow_cpu = ((sleep_flags) & RTC_SLEEP_PD_RTC_MEM_FOLLOW_CPU) ? 1 : 0, \ - .rtc_fastmem_pd_en = ((sleep_flags) & RTC_SLEEP_PD_RTC_FAST_MEM) ? 1 : 0, \ - .rtc_slowmem_pd_en = ((sleep_flags) & RTC_SLEEP_PD_RTC_SLOW_MEM) ? 1 : 0, \ - .rtc_peri_pd_en = ((sleep_flags) & RTC_SLEEP_PD_RTC_PERIPH) ? 1 : 0, \ - .wifi_pd_en = ((sleep_flags) & RTC_SLEEP_PD_WIFI) ? 1 : 0, \ - .int_8m_pd_en = is_dslp(sleep_flags) ? 1 : ((sleep_flags) & RTC_SLEEP_PD_INT_8M) ? 1 : 0, \ - .deep_slp = ((sleep_flags) & RTC_SLEEP_PD_DIG) ? 1 : 0, \ - .wdt_flashboot_mod_en = 0, \ - .dig_dbias_wak = RTC_CNTL_DIG_DBIAS_1V10, \ - .dig_dbias_slp = is_dslp(sleep_flags) ? RTC_CNTL_DIG_DBIAS_0V90 \ - : !((sleep_flags) & RTC_SLEEP_PD_INT_8M) ? RTC_CNTL_DIG_DBIAS_1V10 \ - : !((sleep_flags) & RTC_SLEEP_PD_XTAL) ? RTC_CNTL_DIG_DBIAS_1V10 \ - : RTC_CNTL_DIG_DBIAS_0V90, \ - .rtc_dbias_wak = RTC_CNTL_DBIAS_1V10, \ - .rtc_dbias_slp = is_dslp(sleep_flags) ? RTC_CNTL_DBIAS_1V00 \ - : !((sleep_flags) & RTC_SLEEP_PD_INT_8M) ? RTC_CNTL_DBIAS_1V10 \ - : !((sleep_flags) & RTC_SLEEP_PD_XTAL) ? RTC_CNTL_DBIAS_1V10 \ - : RTC_CNTL_DBIAS_1V00, \ - .vddsdio_pd_en = ((sleep_flags) & RTC_SLEEP_PD_VDDSDIO) ? 1 : 0, \ - .xtal_fpu = is_dslp(sleep_flags) ? 0 : ((sleep_flags) & RTC_SLEEP_PD_XTAL) ? 0 : 1, \ - .deep_slp_reject = 1, \ - .light_slp_reject = 1 \ -}; - #define RTC_SLEEP_PD_DIG BIT(0) //!< Deep sleep (power down digital domain) #define RTC_SLEEP_PD_RTC_PERIPH BIT(1) //!< Power down RTC peripherals #define RTC_SLEEP_PD_RTC_SLOW_MEM BIT(2) //!< Power down RTC SLOW memory @@ -719,6 +695,21 @@ typedef struct { #define RTC_SLEEP_PD_INT_8M BIT(7) //!< Power down Internal 8M oscillator #define RTC_SLEEP_PD_XTAL BIT(8) //!< Power down main XTAL +//These flags are not power domains, but will affect some sleep parameters +#define RTC_SLEEP_DIG_USE_8M BIT(16) +#define RTC_SLEEP_USE_ADC_TESEN_MONITOR BIT(17) +#define RTC_SLEEP_NO_ULTRA_LOW BIT(18) //!< Avoid using ultra low power in deep sleep, in which RTCIO cannot be used as input, and RTCMEM can't work under high temperature + +/** + * Default initializer for rtc_sleep_config_t + * + * This initializer sets all fields to "reasonable" values (e.g. suggested for + * production use) based on a combination of RTC_SLEEP_PD_x flags. + * + * @param RTC_SLEEP_PD_x flags combined using bitwise OR + */ +void rtc_sleep_get_default_config(uint32_t sleep_flags, rtc_sleep_config_t *out_config); + /** * @brief Prepare the chip to enter sleep mode * diff --git a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/soc_caps.h b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/soc_caps.h index 2d311893dde..60d240c44dc 100644 --- a/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/soc_caps.h +++ b/tools/sdk/esp32s2/include/soc/esp32s2/include/soc/soc_caps.h @@ -75,6 +75,7 @@ /*!< RTC */ #define SOC_ADC_MAX_BITWIDTH (13) +#define SOC_RTC_SLOW_CLOCK_SUPPORT_8MD256 (1) /*!< Calibration */ #define SOC_ADC_CALIBRATION_V1_SUPPORTED (1) /*!< support HW offset calibration version 1*/ @@ -127,8 +128,7 @@ #define SOC_I2C_FIFO_LEN (32) /*!< I2C hardware FIFO depth */ -//ESP32-S2 support hardware FSM reset -#define SOC_I2C_SUPPORT_HW_FSM_RST (1) +// FSM_RST only resets the FSM, not using it. So SOC_I2C_SUPPORT_HW_FSM_RST not defined. //ESP32-S2 support hardware clear bus #define SOC_I2C_SUPPORT_HW_CLR_BUS (1) @@ -330,12 +330,12 @@ #define SOC_SPI_MEM_SUPPORT_SW_SUSPEND (1) /*-------------------------- Power Management CAPS ---------------------------*/ #define SOC_PM_SUPPORT_EXT_WAKEUP (1) - #define SOC_PM_SUPPORT_WIFI_WAKEUP (1) +#define SOC_PM_SUPPORT_TOUCH_SENSOR_WAKEUP (1) /*!=32 -#define USBTMCD_MAX_PACKET_SIZE (64u) +#define USBTMCD_MAX_PACKET_SIZE (TUD_OPT_HIGH_SPEED ? 512 : 64) /*********************************************** * Functions to be implemeted by the class implementation diff --git a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/common/tusb_common.h b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/common/tusb_common.h index 58591f0bea0..b1ee40a1a54 100644 --- a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/common/tusb_common.h +++ b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/common/tusb_common.h @@ -134,12 +134,6 @@ TU_ATTR_ALWAYS_INLINE static inline uint32_t tu_offset4k(uint32_t value) { retur //------------- Mathematics -------------// TU_ATTR_ALWAYS_INLINE static inline uint32_t tu_div_ceil(uint32_t v, uint32_t d) { return (v + d -1)/d; } -/// inclusive range checking TODO remove -TU_ATTR_ALWAYS_INLINE static inline bool tu_within(uint32_t lower, uint32_t value, uint32_t upper) -{ - return (lower <= value) && (value <= upper); -} - // log2 of a value is its MSB's position // TODO use clz TODO remove static inline uint8_t tu_log2(uint32_t value) @@ -149,6 +143,16 @@ static inline uint8_t tu_log2(uint32_t value) return result; } +//static inline uint8_t tu_log2(uint32_t value) +//{ +// return sizeof(uint32_t) * CHAR_BIT - __builtin_clz(x) - 1; +//} + +static inline bool tu_is_power_of_two(uint32_t value) +{ + return (value != 0) && ((value & (value - 1)) == 0); +} + //------------- Unaligned Access -------------// #if TUP_ARCH_STRICT_ALIGN diff --git a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/common/tusb_debug.h b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/common/tusb_debug.h index 647e8a8db5d..ac5bee6ece6 100644 --- a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/common/tusb_debug.h +++ b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/common/tusb_debug.h @@ -57,7 +57,7 @@ void tu_print_mem(void const *buf, uint32_t count, uint8_t indent); #define tu_printf printf #endif -static inline void tu_print_var(uint8_t const* buf, uint32_t bufsize) +static inline void tu_print_arr(uint8_t const* buf, uint32_t bufsize) { for(uint32_t i=0; i= 2 #define TU_LOG2 TU_LOG1 #define TU_LOG2_MEM TU_LOG1_MEM + #define TU_LOG2_ARR TU_LOG1_ARR #define TU_LOG2_VAR TU_LOG1_VAR #define TU_LOG2_INT TU_LOG1_INT #define TU_LOG2_HEX TU_LOG1_HEX @@ -91,6 +94,7 @@ static inline void tu_print_var(uint8_t const* buf, uint32_t bufsize) #if CFG_TUSB_DEBUG >= 3 #define TU_LOG3 TU_LOG1 #define TU_LOG3_MEM TU_LOG1_MEM + #define TU_LOG3_ARR TU_LOG1_ARR #define TU_LOG3_VAR TU_LOG1_VAR #define TU_LOG3_INT TU_LOG1_INT #define TU_LOG3_HEX TU_LOG1_HEX diff --git a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/common/tusb_mcu.h b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/common/tusb_mcu.h index 8eb4ad47581..383a8d68603 100644 --- a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/common/tusb_mcu.h +++ b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/common/tusb_mcu.h @@ -45,8 +45,7 @@ * - ENDPOINT_MAX: max (logical) number of endpoint * - ENDPOINT_EXCLUSIVE_NUMBER: endpoint number with different direction IN and OUT aren't allowed, * e.g EP1 OUT & EP1 IN cannot exist together - * - RHPORT_HIGHSPEED: mask to indicate which port support highspeed mode (without external PHY) - * bit0 for port0 and so on. + * - RHPORT_HIGHSPEED: support highspeed with on-chip PHY */ //------------- NXP -------------// @@ -63,8 +62,7 @@ #define TUP_USBIP_EHCI #define TUP_DCD_ENDPOINT_MAX 6 - #define TUP_RHPORT_HIGHSPEED 0x01 // Port0 HS, Port1 FS - + #define TUP_RHPORT_HIGHSPEED 1 // Port0 HS, Port1 FS #elif TU_CHECK_MCU(OPT_MCU_LPC51UXX) #define TUP_DCD_ENDPOINT_MAX 5 @@ -82,8 +80,7 @@ #define TUP_USBIP_EHCI #define TUP_DCD_ENDPOINT_MAX 8 - #define TUP_RHPORT_HIGHSPEED 0x03 // Port0 HS, Port1 HS - + #define TUP_RHPORT_HIGHSPEED 1 // Port0 HS, Port1 HS #elif TU_CHECK_MCU(OPT_MCU_MKL25ZXX, OPT_MCU_K32L2BXX) #define TUP_DCD_ENDPOINT_MAX 16 @@ -107,7 +104,7 @@ #elif TU_CHECK_MCU(OPT_MCU_SAMX7X) #define TUP_DCD_ENDPOINT_MAX 10 - #define TUP_RHPORT_HIGHSPEED 0x01 + #define TUP_RHPORT_HIGHSPEED 1 #define TUP_DCD_ENDPOINT_EXCLUSIVE_NUMBER #elif TU_CHECK_MCU(OPT_MCU_PIC32MZ) @@ -155,7 +152,7 @@ // MCU with on-chip HS Phy #if defined(STM32F723xx) || defined(STM32F730xx) || defined(STM32F733xx) - #define TUP_RHPORT_HIGHSPEED 0x02 // Port 0: FS, Port 1: HS + #define TUP_RHPORT_HIGHSPEED 1 // Port0: FS, Port1: HS #endif #elif TU_CHECK_MCU(OPT_MCU_STM32H7) @@ -185,12 +182,12 @@ #endif #elif TU_CHECK_MCU(OPT_MCU_STM32WB) -#define TUP_DCD_ENDPOINT_MAX 8 + #define TUP_DCD_ENDPOINT_MAX 8 //------------- Sony -------------// #elif TU_CHECK_MCU(OPT_MCU_CXD56) #define TUP_DCD_ENDPOINT_MAX 7 - #define TUP_RHPORT_HIGHSPEED 0x01 + #define TUP_RHPORT_HIGHSPEED 1 #define TUP_DCD_ENDPOINT_EXCLUSIVE_NUMBER //------------- TI -------------// @@ -213,7 +210,7 @@ #elif TU_CHECK_MCU(OPT_MCU_NUC505) #define TUP_DCD_ENDPOINT_MAX 12 - #define TUP_RHPORT_HIGHSPEED 0x01 + #define TUP_RHPORT_HIGHSPEED 1 //------------- Espressif -------------// #elif TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3) @@ -228,6 +225,8 @@ #elif TU_CHECK_MCU(OPT_MCU_RP2040) #define TUP_DCD_ENDPOINT_MAX 16 + #define TU_ATTR_FAST_FUNC __attribute__((section(".time_critical.tinyusb"))) + //------------- Silabs -------------// #elif TU_CHECK_MCU(OPT_MCU_EFM32GG) #define TUP_USBIP_DWC2 @@ -246,7 +245,7 @@ #elif TU_CHECK_MCU(OPT_MCU_BCM2711, OPT_MCU_BCM2835, OPT_MCU_BCM2837) #define TUP_USBIP_DWC2 #define TUP_DCD_ENDPOINT_MAX 8 - #define TUP_RHPORT_HIGHSPEED 0x01 + #define TUP_RHPORT_HIGHSPEED 1 //------------- Broadcom -------------// #elif TU_CHECK_MCU(OPT_MCU_XMC4000) @@ -256,11 +255,11 @@ //------------- BridgeTek -------------// #elif TU_CHECK_MCU(OPT_MCU_FT90X) #define TUP_DCD_ENDPOINT_MAX 8 - #define TUP_RHPORT_HIGHSPEED 0x01 + #define TUP_RHPORT_HIGHSPEED 1 #elif TU_CHECK_MCU(OPT_MCU_FT93X) #define TUP_DCD_ENDPOINT_MAX 16 - #define TUP_RHPORT_HIGHSPEED 0x01 + #define TUP_RHPORT_HIGHSPEED 1 //------------ Allwinner -------------// #elif TU_CHECK_MCU(OPT_MCU_F1C100S) @@ -279,7 +278,12 @@ // Default to fullspeed if not defined #ifndef TUP_RHPORT_HIGHSPEED - #define TUP_RHPORT_HIGHSPEED 0x00 + #define TUP_RHPORT_HIGHSPEED 0 +#endif + +// fast function, normally mean placing function in SRAM +#ifndef TU_ATTR_FAST_FUNC + #define TU_ATTR_FAST_FUNC #endif #endif diff --git a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/common/tusb_types.h b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/common/tusb_types.h index e2fa175327f..1f2a38d4c7e 100644 --- a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/common/tusb_types.h +++ b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/common/tusb_types.h @@ -492,23 +492,23 @@ TU_ATTR_BIT_FIELD_ORDER_END //--------------------------------------------------------------------+ // Get direction from Endpoint address -static inline tusb_dir_t tu_edpt_dir(uint8_t addr) +TU_ATTR_ALWAYS_INLINE static inline tusb_dir_t tu_edpt_dir(uint8_t addr) { return (addr & TUSB_DIR_IN_MASK) ? TUSB_DIR_IN : TUSB_DIR_OUT; } // Get Endpoint number from address -static inline uint8_t tu_edpt_number(uint8_t addr) +TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_edpt_number(uint8_t addr) { return (uint8_t)(addr & (~TUSB_DIR_IN_MASK)); } -static inline uint8_t tu_edpt_addr(uint8_t num, uint8_t dir) +TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_edpt_addr(uint8_t num, uint8_t dir) { return (uint8_t)(num | (dir ? TUSB_DIR_IN_MASK : 0)); } -static inline uint16_t tu_edpt_packet_size(tusb_desc_endpoint_t const* desc_ep) +TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_edpt_packet_size(tusb_desc_endpoint_t const* desc_ep) { return tu_le16toh(desc_ep->wMaxPacketSize) & TU_GENMASK(10, 0); } @@ -516,18 +516,18 @@ static inline uint16_t tu_edpt_packet_size(tusb_desc_endpoint_t const* desc_ep) //--------------------------------------------------------------------+ // Descriptor helper //--------------------------------------------------------------------+ -static inline uint8_t const * tu_desc_next(void const* desc) +TU_ATTR_ALWAYS_INLINE static inline uint8_t const * tu_desc_next(void const* desc) { uint8_t const* desc8 = (uint8_t const*) desc; return desc8 + desc8[DESC_OFFSET_LEN]; } -static inline uint8_t tu_desc_type(void const* desc) +TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_desc_type(void const* desc) { return ((uint8_t const*) desc)[DESC_OFFSET_TYPE]; } -static inline uint8_t tu_desc_len(void const* desc) +TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_desc_len(void const* desc) { return ((uint8_t const*) desc)[DESC_OFFSET_LEN]; } diff --git a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/common/tusb_verify.h b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/common/tusb_verify.h index f4a08ce2f91..a52a6d26964 100644 --- a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/common/tusb_verify.h +++ b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/common/tusb_verify.h @@ -90,6 +90,9 @@ #elif defined(__riscv) #define TU_BREAKPOINT() do { __asm("ebreak\n"); } while(0) +#elif defined(_mips) + #define TU_BREAKPOINT() do { __asm("sdbbp 0"); } while (0) + #else #define TU_BREAKPOINT() do {} while (0) #endif @@ -99,8 +102,8 @@ *------------------------------------------------------------------*/ // Helper to implement optional parameter for TU_VERIFY Macro family -#define GET_3RD_ARG(arg1, arg2, arg3, ...) arg3 -#define GET_4TH_ARG(arg1, arg2, arg3, arg4, ...) arg4 +#define _GET_3RD_ARG(arg1, arg2, arg3, ...) arg3 +#define _GET_4TH_ARG(arg1, arg2, arg3, arg4, ...) arg4 /*------------- Generator for TU_VERIFY and TU_VERIFY_HDLR -------------*/ #define TU_VERIFY_DEFINE(_cond, _handler, _ret) do \ @@ -116,7 +119,7 @@ #define TU_VERIFY_1ARGS(_cond) TU_VERIFY_DEFINE(_cond, , false) #define TU_VERIFY_2ARGS(_cond, _ret) TU_VERIFY_DEFINE(_cond, , _ret) -#define TU_VERIFY(...) GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, UNUSED)(__VA_ARGS__) +#define TU_VERIFY(...) _GET_3RD_ARG(__VA_ARGS__, TU_VERIFY_2ARGS, TU_VERIFY_1ARGS, UNUSED)(__VA_ARGS__) /*------------------------------------------------------------------*/ @@ -127,7 +130,7 @@ #define TU_VERIFY_HDLR_2ARGS(_cond, _handler) TU_VERIFY_DEFINE(_cond, _handler, false) #define TU_VERIFY_HDLR_3ARGS(_cond, _handler, _ret) TU_VERIFY_DEFINE(_cond, _handler, _ret) -#define TU_VERIFY_HDLR(...) GET_4TH_ARG(__VA_ARGS__, TU_VERIFY_HDLR_3ARGS, TU_VERIFY_HDLR_2ARGS,UNUSED)(__VA_ARGS__) +#define TU_VERIFY_HDLR(...) _GET_4TH_ARG(__VA_ARGS__, TU_VERIFY_HDLR_3ARGS, TU_VERIFY_HDLR_2ARGS,UNUSED)(__VA_ARGS__) /*------------------------------------------------------------------*/ /* ASSERT @@ -139,7 +142,7 @@ #define ASSERT_2ARGS(_cond, _ret) TU_VERIFY_DEFINE(_cond, _MESS_FAILED(); TU_BREAKPOINT(), _ret) #ifndef TU_ASSERT -#define TU_ASSERT(...) GET_3RD_ARG(__VA_ARGS__, ASSERT_2ARGS, ASSERT_1ARGS,UNUSED)(__VA_ARGS__) +#define TU_ASSERT(...) _GET_3RD_ARG(__VA_ARGS__, ASSERT_2ARGS, ASSERT_1ARGS,UNUSED)(__VA_ARGS__) #endif /*------------------------------------------------------------------*/ diff --git a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/device/dcd.h b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/device/dcd.h index 8efbc90ef6b..6b99734fed5 100644 --- a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/device/dcd.h +++ b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/device/dcd.h @@ -77,6 +77,11 @@ typedef struct TU_ATTR_ALIGNED(4) tusb_speed_t speed; } bus_reset; + // SOF + struct { + uint32_t frame_count; + }sof; + // SETUP_RECEIVED tusb_control_request_t setup_received; @@ -132,6 +137,9 @@ void dcd_connect(uint8_t rhport) TU_ATTR_WEAK; // Disconnect by disabling internal pull-up resistor on D+/D- void dcd_disconnect(uint8_t rhport) TU_ATTR_WEAK; +// Enable/Disable Start-of-frame interrupt. Default is disabled +void dcd_sof_enable(uint8_t rhport, bool en); + //--------------------------------------------------------------------+ // Endpoint API //--------------------------------------------------------------------+ @@ -174,16 +182,47 @@ void dcd_edpt_clear_stall (uint8_t rhport, uint8_t ep_addr); extern void dcd_event_handler(dcd_event_t const * event, bool in_isr); // helper to send bus signal event -extern void dcd_event_bus_signal (uint8_t rhport, dcd_eventid_t eid, bool in_isr); +TU_ATTR_ALWAYS_INLINE static inline void dcd_event_bus_signal (uint8_t rhport, dcd_eventid_t eid, bool in_isr) +{ + dcd_event_t event = { .rhport = rhport, .event_id = eid }; + dcd_event_handler(&event, in_isr); +} // helper to send bus reset event -extern void dcd_event_bus_reset (uint8_t rhport, tusb_speed_t speed, bool in_isr); +TU_ATTR_ALWAYS_INLINE static inline void dcd_event_bus_reset (uint8_t rhport, tusb_speed_t speed, bool in_isr) +{ + dcd_event_t event = { .rhport = rhport, .event_id = DCD_EVENT_BUS_RESET }; + event.bus_reset.speed = speed; + dcd_event_handler(&event, in_isr); +} // helper to send setup received -extern void dcd_event_setup_received(uint8_t rhport, uint8_t const * setup, bool in_isr); +TU_ATTR_ALWAYS_INLINE static inline void dcd_event_setup_received(uint8_t rhport, uint8_t const * setup, bool in_isr) +{ + dcd_event_t event = { .rhport = rhport, .event_id = DCD_EVENT_SETUP_RECEIVED }; + memcpy(&event.setup_received, setup, 8); + + dcd_event_handler(&event, in_isr); +} // helper to send transfer complete event -extern void dcd_event_xfer_complete (uint8_t rhport, uint8_t ep_addr, uint32_t xferred_bytes, uint8_t result, bool in_isr); +TU_ATTR_ALWAYS_INLINE static inline void dcd_event_xfer_complete (uint8_t rhport, uint8_t ep_addr, uint32_t xferred_bytes, uint8_t result, bool in_isr) +{ + dcd_event_t event = { .rhport = rhport, .event_id = DCD_EVENT_XFER_COMPLETE }; + + event.xfer_complete.ep_addr = ep_addr; + event.xfer_complete.len = xferred_bytes; + event.xfer_complete.result = result; + + dcd_event_handler(&event, in_isr); +} + +static inline void dcd_event_sof(uint8_t rhport, uint32_t frame_count, bool in_isr) +{ + dcd_event_t event = { .rhport = rhport, .event_id = DCD_EVENT_SOF }; + event.sof.frame_count = frame_count; + dcd_event_handler(&event, in_isr); +} #ifdef __cplusplus } diff --git a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/device/usbd.h b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/device/usbd.h index b2bf8ba9d78..964cfb99224 100644 --- a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/device/usbd.h +++ b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/device/usbd.h @@ -43,10 +43,19 @@ bool tud_init (uint8_t rhport); // Check if device stack is already initialized bool tud_inited(void); +// Task function should be called in main/rtos loop, extended version of tud_task() +// - timeout_ms: millisecond to wait, zero = no wait, 0xFFFFFFFF = wait forever +// - in_isr: if function is called in ISR +void tud_task_ext(uint32_t timeout_ms, bool in_isr); + // Task function should be called in main/rtos loop -void tud_task (void); +TU_ATTR_ALWAYS_INLINE static inline +void tud_task (void) +{ + tud_task_ext(UINT32_MAX, false); +} -// Check if there is pending events need proccessing by tud_task() +// Check if there is pending events need processing by tud_task() bool tud_task_event_ready(void); // Interrupt handler, name alias to DCD diff --git a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/device/usbd_pvt.h b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/device/usbd_pvt.h index 29753451ebc..6fad46db358 100644 --- a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/device/usbd_pvt.h +++ b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/device/usbd_pvt.h @@ -48,7 +48,7 @@ typedef struct uint16_t (* open ) (uint8_t rhport, tusb_desc_interface_t const * desc_intf, uint16_t max_len); bool (* control_xfer_cb ) (uint8_t rhport, uint8_t stage, tusb_control_request_t const * request); bool (* xfer_cb ) (uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes); - void (* sof ) (uint8_t rhport); /* optional */ + void (* sof ) (uint8_t rhport, uint32_t frame_count); // optional } usbd_class_driver_t; // Invoked when initializing device stack to get additional class drivers. @@ -62,6 +62,7 @@ void usbd_int_set(bool enabled); //--------------------------------------------------------------------+ // USBD Endpoint API +// Note: rhport should be 0 since device stack only support 1 rhport for now //--------------------------------------------------------------------+ // Open an endpoint @@ -102,6 +103,9 @@ bool usbd_edpt_ready(uint8_t rhport, uint8_t ep_addr) return !usbd_edpt_busy(rhport, ep_addr) && !usbd_edpt_stalled(rhport, ep_addr); } +// Enable SOF interrupt +void usbd_sof_enable(uint8_t rhport, bool en); + /*------------------------------------------------------------------*/ /* Helper *------------------------------------------------------------------*/ diff --git a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/host/hcd.h b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/host/hcd.h index c40bea64cec..deebc59d4ed 100644 --- a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/host/hcd.h +++ b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/host/hcd.h @@ -48,7 +48,7 @@ // #endif #endif - //--------------------------------------------------------------------+ +//--------------------------------------------------------------------+ // MACRO CONSTANT TYPEDEF //--------------------------------------------------------------------+ typedef enum @@ -106,6 +106,9 @@ typedef struct // Controller API //--------------------------------------------------------------------+ +// optional hcd configuration, called by tuh_config() +bool hcd_configure(uint8_t rhport, uint32_t cfg_id, const void* cfg_param) TU_ATTR_WEAK; + // Initialize controller to host mode bool hcd_init(uint8_t rhport); @@ -144,9 +147,16 @@ void hcd_device_close(uint8_t rhport, uint8_t dev_addr); // Endpoints API //--------------------------------------------------------------------+ -bool hcd_setup_send(uint8_t rhport, uint8_t dev_addr, uint8_t const setup_packet[8]); +// Open an endpoint bool hcd_edpt_open(uint8_t rhport, uint8_t dev_addr, tusb_desc_endpoint_t const * ep_desc); + +// Submit a transfer, when complete hcd_event_xfer_complete() must be invoked bool hcd_edpt_xfer(uint8_t rhport, uint8_t dev_addr, uint8_t ep_addr, uint8_t * buffer, uint16_t buflen); + +// Submit a special transfer to send 8-byte Setup Packet, when complete hcd_event_xfer_complete() must be invoked +bool hcd_setup_send(uint8_t rhport, uint8_t dev_addr, uint8_t const setup_packet[8]); + +// clear stall, data toggle is also reset to DATA0 bool hcd_edpt_clear_stall(uint8_t dev_addr, uint8_t ep_addr); //--------------------------------------------------------------------+ @@ -164,13 +174,47 @@ extern void hcd_devtree_get_info(uint8_t dev_addr, hcd_devtree_info_t* devtree_i extern void hcd_event_handler(hcd_event_t const* event, bool in_isr); // Helper to send device attach event -extern void hcd_event_device_attach(uint8_t rhport, bool in_isr); +TU_ATTR_ALWAYS_INLINE static inline +void hcd_event_device_attach(uint8_t rhport, bool in_isr) +{ + hcd_event_t event; + event.rhport = rhport; + event.event_id = HCD_EVENT_DEVICE_ATTACH; + event.connection.hub_addr = 0; + event.connection.hub_port = 0; + hcd_event_handler(&event, in_isr); +} // Helper to send device removal event -extern void hcd_event_device_remove(uint8_t rhport, bool in_isr); +TU_ATTR_ALWAYS_INLINE static inline +void hcd_event_device_remove(uint8_t rhport, bool in_isr) +{ + hcd_event_t event; + event.rhport = rhport; + event.event_id = HCD_EVENT_DEVICE_REMOVE; + event.connection.hub_addr = 0; + event.connection.hub_port = 0; + + hcd_event_handler(&event, in_isr); +} // Helper to send USB transfer event -extern void hcd_event_xfer_complete(uint8_t dev_addr, uint8_t ep_addr, uint32_t xferred_bytes, xfer_result_t result, bool in_isr); +TU_ATTR_ALWAYS_INLINE static inline +void hcd_event_xfer_complete(uint8_t dev_addr, uint8_t ep_addr, uint32_t xferred_bytes, xfer_result_t result, bool in_isr) +{ + hcd_event_t event = + { + .rhport = 0, // TODO correct rhport + .event_id = HCD_EVENT_XFER_COMPLETE, + .dev_addr = dev_addr, + }; + event.xfer_complete.ep_addr = ep_addr; + event.xfer_complete.result = result; + event.xfer_complete.len = xferred_bytes; + + + hcd_event_handler(&event, in_isr); +} #ifdef __cplusplus } diff --git a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/host/usbh.h b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/host/usbh.h index e883ac90bc7..347c75b8c1b 100644 --- a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/host/usbh.h +++ b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/host/usbh.h @@ -46,8 +46,8 @@ typedef void (*tuh_xfer_cb_t)(tuh_xfer_t* xfer); // Note1: layout and order of this will be changed in near future // it is advised to initialize it using member name -// Note2: not all field is available/meaningful in callback, some info is not saved by -// usbh to save SRAM +// Note2: not all field is available/meaningful in callback, +// some info is not saved by usbh to save SRAM struct tuh_xfer_s { uint8_t daddr; @@ -69,6 +69,12 @@ struct tuh_xfer_s // uint32_t timeout_ms; // place holder, not supported yet }; +// ConfigID for tuh_config() +enum +{ + TUH_CFGID_RPI_PIO_USB_CONFIGURATION = OPT_MCU_RP2040 // cfg_param: pio_usb_configuration_t +}; + //--------------------------------------------------------------------+ // APPLICATION CALLBACK //--------------------------------------------------------------------+ @@ -85,14 +91,29 @@ TU_ATTR_WEAK void tuh_umount_cb(uint8_t daddr); // APPLICATION API //--------------------------------------------------------------------+ +// Configure host stack behavior with dynamic or port-specific parameters. +// Should be called before tuh_init() +// - cfg_id : configure ID (TBD) +// - cfg_param: configure data, structure depends on the ID +bool tuh_configure(uint8_t controller_id, uint32_t cfg_id, const void* cfg_param); + // Init host stack -bool tuh_init(uint8_t rhport); +bool tuh_init(uint8_t controller_id); // Check if host stack is already initialized bool tuh_inited(void); +// Task function should be called in main/rtos loop, extended version of tuh_task() +// - timeout_ms: millisecond to wait, zero = no wait, 0xFFFFFFFF = wait forever +// - in_isr: if function is called in ISR +void tuh_task_ext(uint32_t timeout_ms, bool in_isr); + // Task function should be called in main/rtos loop -void tuh_task(void); +TU_ATTR_ALWAYS_INLINE static inline +void tuh_task(void) +{ + tuh_task_ext(UINT32_MAX, false); +} // Interrupt handler, name alias to HCD extern void hcd_int_handler(uint8_t rhport); @@ -106,8 +127,8 @@ tusb_speed_t tuh_speed_get(uint8_t daddr); bool tuh_mounted(uint8_t daddr); // Check if device is suspended -TU_ATTR_ALWAYS_INLINE -static inline bool tuh_suspended(uint8_t daddr) +TU_ATTR_ALWAYS_INLINE static inline +bool tuh_suspended(uint8_t daddr) { // TODO implement suspend & resume on host (void) daddr; @@ -115,8 +136,8 @@ static inline bool tuh_suspended(uint8_t daddr) } // Check if device is ready to communicate with -TU_ATTR_ALWAYS_INLINE -static inline bool tuh_ready(uint8_t daddr) +TU_ATTR_ALWAYS_INLINE static inline +bool tuh_ready(uint8_t daddr) { return tuh_mounted(daddr) && !tuh_suspended(daddr); } diff --git a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/osal/osal.h b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/osal/osal.h index 7111bbdb2a1..9d11866dfd7 100644 --- a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/osal/osal.h +++ b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/osal/osal.h @@ -66,19 +66,19 @@ typedef void (*osal_task_func_t)( void * ); // OSAL Porting API // Should be implemented as static inline function in osal_port.h header /* - static inline osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t* semdef); - static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr); - static inline bool osal_semaphore_wait(osal_semaphore_t sem_hdl, uint32_t msec); - static inline void osal_semaphore_reset(osal_semaphore_t sem_hdl); // TODO removed + osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t* semdef); + bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr); + bool osal_semaphore_wait(osal_semaphore_t sem_hdl, uint32_t msec); + void osal_semaphore_reset(osal_semaphore_t sem_hdl); // TODO removed - static inline osal_mutex_t osal_mutex_create(osal_mutex_def_t* mdef); - static inline bool osal_mutex_lock (osal_mutex_t sem_hdl, uint32_t msec); - static inline bool osal_mutex_unlock(osal_mutex_t mutex_hdl); + osal_mutex_t osal_mutex_create(osal_mutex_def_t* mdef); + bool osal_mutex_lock (osal_mutex_t sem_hdl, uint32_t msec); + bool osal_mutex_unlock(osal_mutex_t mutex_hdl); - static inline osal_queue_t osal_queue_create(osal_queue_def_t* qdef); - static inline bool osal_queue_receive(osal_queue_t qhdl, void* data); - static inline bool osal_queue_send(osal_queue_t qhdl, void const * data, bool in_isr); - static inline bool osal_queue_empty(osal_queue_t qhdl); + osal_queue_t osal_queue_create(osal_queue_def_t* qdef); + bool osal_queue_receive(osal_queue_t qhdl, void* data, uint32_t msec); + bool osal_queue_send(osal_queue_t qhdl, void const * data, bool in_isr); + bool osal_queue_empty(osal_queue_t qhdl); */ //--------------------------------------------------------------------+ diff --git a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/osal/osal_freertos.h b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/osal/osal_freertos.h index 69a026df5b5..52db336f5bf 100644 --- a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/osal/osal_freertos.h +++ b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/osal/osal_freertos.h @@ -37,10 +37,24 @@ extern "C" { #endif +TU_ATTR_ALWAYS_INLINE static inline uint32_t _osal_ms2tick(uint32_t msec) +{ + if (msec == OSAL_TIMEOUT_WAIT_FOREVER) return portMAX_DELAY; + if (msec == 0) return 0; + + uint32_t ticks = pdMS_TO_TICKS(msec); + + // configTICK_RATE_HZ is less than 1000 and 1 tick > 1 ms + // we still need to delay at least 1 tick + if (ticks == 0) ticks =1 ; + + return ticks; +} + //--------------------------------------------------------------------+ // TASK API //--------------------------------------------------------------------+ -static inline void osal_task_delay(uint32_t msec) +TU_ATTR_ALWAYS_INLINE static inline void osal_task_delay(uint32_t msec) { vTaskDelay( pdMS_TO_TICKS(msec) ); } @@ -51,12 +65,12 @@ static inline void osal_task_delay(uint32_t msec) typedef StaticSemaphore_t osal_semaphore_def_t; typedef SemaphoreHandle_t osal_semaphore_t; -static inline osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t* semdef) +TU_ATTR_ALWAYS_INLINE static inline osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t* semdef) { return xSemaphoreCreateBinaryStatic(semdef); } -static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr) +TU_ATTR_ALWAYS_INLINE static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr) { if ( !in_isr ) { @@ -78,13 +92,12 @@ static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr) } } -static inline bool osal_semaphore_wait (osal_semaphore_t sem_hdl, uint32_t msec) +TU_ATTR_ALWAYS_INLINE static inline bool osal_semaphore_wait (osal_semaphore_t sem_hdl, uint32_t msec) { - uint32_t const ticks = (msec == OSAL_TIMEOUT_WAIT_FOREVER) ? portMAX_DELAY : pdMS_TO_TICKS(msec); - return xSemaphoreTake(sem_hdl, ticks); + return xSemaphoreTake(sem_hdl, _osal_ms2tick(msec)); } -static inline void osal_semaphore_reset(osal_semaphore_t const sem_hdl) +TU_ATTR_ALWAYS_INLINE static inline void osal_semaphore_reset(osal_semaphore_t const sem_hdl) { xQueueReset(sem_hdl); } @@ -95,17 +108,17 @@ static inline void osal_semaphore_reset(osal_semaphore_t const sem_hdl) typedef StaticSemaphore_t osal_mutex_def_t; typedef SemaphoreHandle_t osal_mutex_t; -static inline osal_mutex_t osal_mutex_create(osal_mutex_def_t* mdef) +TU_ATTR_ALWAYS_INLINE static inline osal_mutex_t osal_mutex_create(osal_mutex_def_t* mdef) { return xSemaphoreCreateMutexStatic(mdef); } -static inline bool osal_mutex_lock (osal_mutex_t mutex_hdl, uint32_t msec) +TU_ATTR_ALWAYS_INLINE static inline bool osal_mutex_lock (osal_mutex_t mutex_hdl, uint32_t msec) { return osal_semaphore_wait(mutex_hdl, msec); } -static inline bool osal_mutex_unlock(osal_mutex_t mutex_hdl) +TU_ATTR_ALWAYS_INLINE static inline bool osal_mutex_unlock(osal_mutex_t mutex_hdl) { return xSemaphoreGive(mutex_hdl); } @@ -114,7 +127,7 @@ static inline bool osal_mutex_unlock(osal_mutex_t mutex_hdl) // QUEUE API //--------------------------------------------------------------------+ -// role device/host is used by OS NONE for mutex (disable usb isr) only +// _int_set is not used with an RTOS #define OSAL_QUEUE_DEF(_int_set, _name, _depth, _type) \ static _type _name##_##buf[_depth];\ osal_queue_def_t _name = { .depth = _depth, .item_sz = sizeof(_type), .buf = _name##_##buf }; @@ -130,17 +143,17 @@ typedef struct typedef QueueHandle_t osal_queue_t; -static inline osal_queue_t osal_queue_create(osal_queue_def_t* qdef) +TU_ATTR_ALWAYS_INLINE static inline osal_queue_t osal_queue_create(osal_queue_def_t* qdef) { return xQueueCreateStatic(qdef->depth, qdef->item_sz, (uint8_t*) qdef->buf, &qdef->sq); } -static inline bool osal_queue_receive(osal_queue_t qhdl, void* data) +TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_receive(osal_queue_t qhdl, void* data, uint32_t msec) { - return xQueueReceive(qhdl, data, portMAX_DELAY); + return xQueueReceive(qhdl, data, _osal_ms2tick(msec)); } -static inline bool osal_queue_send(osal_queue_t qhdl, void const * data, bool in_isr) +TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_send(osal_queue_t qhdl, void const * data, bool in_isr) { if ( !in_isr ) { @@ -162,7 +175,7 @@ static inline bool osal_queue_send(osal_queue_t qhdl, void const * data, bool in } } -static inline bool osal_queue_empty(osal_queue_t qhdl) +TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_empty(osal_queue_t qhdl) { return uxQueueMessagesWaiting(qhdl) == 0; } diff --git a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/osal/osal_mynewt.h b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/osal/osal_mynewt.h index 78a257cd69f..b8ea2087c19 100644 --- a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/osal/osal_mynewt.h +++ b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/osal/osal_mynewt.h @@ -36,7 +36,7 @@ //--------------------------------------------------------------------+ // TASK API //--------------------------------------------------------------------+ -static inline void osal_task_delay(uint32_t msec) +TU_ATTR_ALWAYS_INLINE static inline void osal_task_delay(uint32_t msec) { os_time_delay( os_time_ms_to_ticks32(msec) ); } @@ -47,18 +47,18 @@ static inline void osal_task_delay(uint32_t msec) typedef struct os_sem osal_semaphore_def_t; typedef struct os_sem* osal_semaphore_t; -static inline osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t* semdef) +TU_ATTR_ALWAYS_INLINE static inline osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t* semdef) { return (os_sem_init(semdef, 0) == OS_OK) ? (osal_semaphore_t) semdef : NULL; } -static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr) +TU_ATTR_ALWAYS_INLINE static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr) { (void) in_isr; return os_sem_release(sem_hdl) == OS_OK; } -static inline bool osal_semaphore_wait(osal_semaphore_t sem_hdl, uint32_t msec) +TU_ATTR_ALWAYS_INLINE static inline bool osal_semaphore_wait(osal_semaphore_t sem_hdl, uint32_t msec) { uint32_t const ticks = (msec == OSAL_TIMEOUT_WAIT_FOREVER) ? OS_TIMEOUT_NEVER : os_time_ms_to_ticks32(msec); return os_sem_pend(sem_hdl, ticks) == OS_OK; @@ -75,18 +75,18 @@ static inline void osal_semaphore_reset(osal_semaphore_t sem_hdl) typedef struct os_mutex osal_mutex_def_t; typedef struct os_mutex* osal_mutex_t; -static inline osal_mutex_t osal_mutex_create(osal_mutex_def_t* mdef) +TU_ATTR_ALWAYS_INLINE static inline osal_mutex_t osal_mutex_create(osal_mutex_def_t* mdef) { return (os_mutex_init(mdef) == OS_OK) ? (osal_mutex_t) mdef : NULL; } -static inline bool osal_mutex_lock(osal_mutex_t mutex_hdl, uint32_t msec) +TU_ATTR_ALWAYS_INLINE static inline bool osal_mutex_lock(osal_mutex_t mutex_hdl, uint32_t msec) { uint32_t const ticks = (msec == OSAL_TIMEOUT_WAIT_FOREVER) ? OS_TIMEOUT_NEVER : os_time_ms_to_ticks32(msec); return os_mutex_pend(mutex_hdl, ticks) == OS_OK; } -static inline bool osal_mutex_unlock(osal_mutex_t mutex_hdl) +TU_ATTR_ALWAYS_INLINE static inline bool osal_mutex_unlock(osal_mutex_t mutex_hdl) { return os_mutex_release(mutex_hdl) == OS_OK; } @@ -116,7 +116,7 @@ typedef struct typedef osal_queue_def_t* osal_queue_t; -static inline osal_queue_t osal_queue_create(osal_queue_def_t* qdef) +TU_ATTR_ALWAYS_INLINE static inline osal_queue_t osal_queue_create(osal_queue_def_t* qdef) { if ( OS_OK != os_mempool_init(&qdef->mpool, qdef->depth, qdef->item_sz, qdef->buf, "usbd queue") ) return NULL; if ( OS_OK != os_mempool_init(&qdef->epool, qdef->depth, sizeof(struct os_event), qdef->evbuf, "usbd evqueue") ) return NULL; @@ -125,8 +125,10 @@ static inline osal_queue_t osal_queue_create(osal_queue_def_t* qdef) return (osal_queue_t) qdef; } -static inline bool osal_queue_receive(osal_queue_t qhdl, void* data) +TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_receive(osal_queue_t qhdl, void* data, uint32_t msec) { + (void) msec; // os_eventq_get() does not take timeout, always behave as msec = WAIT_FOREVER + struct os_event* ev; ev = os_eventq_get(&qhdl->evq); @@ -161,7 +163,7 @@ static inline bool osal_queue_send(osal_queue_t qhdl, void const * data, bool in return true; } -static inline bool osal_queue_empty(osal_queue_t qhdl) +TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_empty(osal_queue_t qhdl) { return STAILQ_EMPTY(&qhdl->evq.evq_list); } diff --git a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/osal/osal_none.h b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/osal/osal_none.h index 4217f042225..9c80e4548d6 100644 --- a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/osal/osal_none.h +++ b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/osal/osal_none.h @@ -46,13 +46,13 @@ typedef struct typedef osal_semaphore_def_t* osal_semaphore_t; -static inline osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t* semdef) +TU_ATTR_ALWAYS_INLINE static inline osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t* semdef) { semdef->count = 0; return semdef; } -static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr) +TU_ATTR_ALWAYS_INLINE static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr) { (void) in_isr; sem_hdl->count++; @@ -60,7 +60,7 @@ static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr) } // TODO blocking for now -static inline bool osal_semaphore_wait (osal_semaphore_t sem_hdl, uint32_t msec) +TU_ATTR_ALWAYS_INLINE static inline bool osal_semaphore_wait (osal_semaphore_t sem_hdl, uint32_t msec) { (void) msec; @@ -70,7 +70,7 @@ static inline bool osal_semaphore_wait (osal_semaphore_t sem_hdl, uint32_t msec) return true; } -static inline void osal_semaphore_reset(osal_semaphore_t sem_hdl) +TU_ATTR_ALWAYS_INLINE static inline void osal_semaphore_reset(osal_semaphore_t sem_hdl) { sem_hdl->count = 0; } @@ -82,18 +82,18 @@ static inline void osal_semaphore_reset(osal_semaphore_t sem_hdl) typedef osal_semaphore_def_t osal_mutex_def_t; typedef osal_semaphore_t osal_mutex_t; -static inline osal_mutex_t osal_mutex_create(osal_mutex_def_t* mdef) +TU_ATTR_ALWAYS_INLINE static inline osal_mutex_t osal_mutex_create(osal_mutex_def_t* mdef) { mdef->count = 1; return mdef; } -static inline bool osal_mutex_lock (osal_mutex_t mutex_hdl, uint32_t msec) +TU_ATTR_ALWAYS_INLINE static inline bool osal_mutex_lock (osal_mutex_t mutex_hdl, uint32_t msec) { return osal_semaphore_wait(mutex_hdl, msec); } -static inline bool osal_mutex_unlock(osal_mutex_t mutex_hdl) +TU_ATTR_ALWAYS_INLINE static inline bool osal_mutex_unlock(osal_mutex_t mutex_hdl) { return osal_semaphore_post(mutex_hdl, false); } @@ -120,27 +120,29 @@ typedef osal_queue_def_t* osal_queue_t; } // lock queue by disable USB interrupt -static inline void _osal_q_lock(osal_queue_t qhdl) +TU_ATTR_ALWAYS_INLINE static inline void _osal_q_lock(osal_queue_t qhdl) { // disable dcd/hcd interrupt qhdl->interrupt_set(false); } // unlock queue -static inline void _osal_q_unlock(osal_queue_t qhdl) +TU_ATTR_ALWAYS_INLINE static inline void _osal_q_unlock(osal_queue_t qhdl) { // enable dcd/hcd interrupt qhdl->interrupt_set(true); } -static inline osal_queue_t osal_queue_create(osal_queue_def_t* qdef) +TU_ATTR_ALWAYS_INLINE static inline osal_queue_t osal_queue_create(osal_queue_def_t* qdef) { tu_fifo_clear(&qdef->ff); return (osal_queue_t) qdef; } -static inline bool osal_queue_receive(osal_queue_t qhdl, void* data) +TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_receive(osal_queue_t qhdl, void* data, uint32_t msec) { + (void) msec; // not used, always behave as msec = 0 + _osal_q_lock(qhdl); bool success = tu_fifo_read(&qhdl->ff, data); _osal_q_unlock(qhdl); @@ -148,7 +150,7 @@ static inline bool osal_queue_receive(osal_queue_t qhdl, void* data) return success; } -static inline bool osal_queue_send(osal_queue_t qhdl, void const * data, bool in_isr) +TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_send(osal_queue_t qhdl, void const * data, bool in_isr) { if (!in_isr) { _osal_q_lock(qhdl); @@ -165,7 +167,7 @@ static inline bool osal_queue_send(osal_queue_t qhdl, void const * data, bool in return success; } -static inline bool osal_queue_empty(osal_queue_t qhdl) +TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_empty(osal_queue_t qhdl) { // Skip queue lock/unlock since this function is primarily called // with interrupt disabled before going into low power mode diff --git a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/osal/osal_pico.h b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/osal/osal_pico.h index 70432d22b5f..abef286b474 100644 --- a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/osal/osal_pico.h +++ b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/osal/osal_pico.h @@ -39,7 +39,7 @@ //--------------------------------------------------------------------+ // TASK API //--------------------------------------------------------------------+ -static inline void osal_task_delay(uint32_t msec) +TU_ATTR_ALWAYS_INLINE static inline void osal_task_delay(uint32_t msec) { sleep_ms(msec); } @@ -49,25 +49,25 @@ static inline void osal_task_delay(uint32_t msec) //--------------------------------------------------------------------+ typedef struct semaphore osal_semaphore_def_t, *osal_semaphore_t; -static inline osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t* semdef) +TU_ATTR_ALWAYS_INLINE static inline osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t* semdef) { sem_init(semdef, 0, 255); return semdef; } -static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr) +TU_ATTR_ALWAYS_INLINE static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr) { (void) in_isr; sem_release(sem_hdl); return true; } -static inline bool osal_semaphore_wait (osal_semaphore_t sem_hdl, uint32_t msec) +TU_ATTR_ALWAYS_INLINE static inline bool osal_semaphore_wait (osal_semaphore_t sem_hdl, uint32_t msec) { return sem_acquire_timeout_ms(sem_hdl, msec); } -static inline void osal_semaphore_reset(osal_semaphore_t sem_hdl) +TU_ATTR_ALWAYS_INLINE static inline void osal_semaphore_reset(osal_semaphore_t sem_hdl) { sem_reset(sem_hdl, 0); } @@ -78,21 +78,21 @@ static inline void osal_semaphore_reset(osal_semaphore_t sem_hdl) //--------------------------------------------------------------------+ typedef struct mutex osal_mutex_def_t, *osal_mutex_t; -static inline osal_mutex_t osal_mutex_create(osal_mutex_def_t* mdef) +TU_ATTR_ALWAYS_INLINE static inline osal_mutex_t osal_mutex_create(osal_mutex_def_t* mdef) { - mutex_init(mdef); - return mdef; + mutex_init(mdef); + return mdef; } -static inline bool osal_mutex_lock (osal_mutex_t mutex_hdl, uint32_t msec) +TU_ATTR_ALWAYS_INLINE static inline bool osal_mutex_lock (osal_mutex_t mutex_hdl, uint32_t msec) { - return mutex_enter_timeout_ms(mutex_hdl, msec); + return mutex_enter_timeout_ms(mutex_hdl, msec); } -static inline bool osal_mutex_unlock(osal_mutex_t mutex_hdl) +TU_ATTR_ALWAYS_INLINE static inline bool osal_mutex_unlock(osal_mutex_t mutex_hdl) { - mutex_exit(mutex_hdl); - return true; + mutex_exit(mutex_hdl); + return true; } //--------------------------------------------------------------------+ @@ -121,26 +121,28 @@ typedef osal_queue_def_t* osal_queue_t; } // lock queue by disable USB interrupt -static inline void _osal_q_lock(osal_queue_t qhdl) +TU_ATTR_ALWAYS_INLINE static inline void _osal_q_lock(osal_queue_t qhdl) { - critical_section_enter_blocking(&qhdl->critsec); + critical_section_enter_blocking(&qhdl->critsec); } // unlock queue -static inline void _osal_q_unlock(osal_queue_t qhdl) +TU_ATTR_ALWAYS_INLINE static inline void _osal_q_unlock(osal_queue_t qhdl) { - critical_section_exit(&qhdl->critsec); + critical_section_exit(&qhdl->critsec); } -static inline osal_queue_t osal_queue_create(osal_queue_def_t* qdef) +TU_ATTR_ALWAYS_INLINE static inline osal_queue_t osal_queue_create(osal_queue_def_t* qdef) { critical_section_init(&qdef->critsec); tu_fifo_clear(&qdef->ff); return (osal_queue_t) qdef; } -static inline bool osal_queue_receive(osal_queue_t qhdl, void* data) +TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_receive(osal_queue_t qhdl, void* data, uint32_t msec) { + (void) msec; // not used, always behave as msec = 0 + // TODO: revisit... docs say that mutexes are never used from IRQ context, // however osal_queue_recieve may be. therefore my assumption is that // the fifo mutex is not populated for queues used from an IRQ context @@ -153,7 +155,7 @@ static inline bool osal_queue_receive(osal_queue_t qhdl, void* data) return success; } -static inline bool osal_queue_send(osal_queue_t qhdl, void const * data, bool in_isr) +TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_send(osal_queue_t qhdl, void const * data, bool in_isr) { // TODO: revisit... docs say that mutexes are never used from IRQ context, // however osal_queue_recieve may be. therefore my assumption is that @@ -170,7 +172,7 @@ static inline bool osal_queue_send(osal_queue_t qhdl, void const * data, bool in return success; } -static inline bool osal_queue_empty(osal_queue_t qhdl) +TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_empty(osal_queue_t qhdl) { // TODO: revisit; whether this is true or not currently, tu_fifo_empty is a single // volatile read. diff --git a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/osal/osal_rtthread.h b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/osal/osal_rtthread.h index 0845175b852..f8452bfb201 100644 --- a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/osal/osal_rtthread.h +++ b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/osal/osal_rtthread.h @@ -37,7 +37,7 @@ extern "C" { //--------------------------------------------------------------------+ // TASK API //--------------------------------------------------------------------+ -static inline void osal_task_delay(uint32_t msec) { +TU_ATTR_ALWAYS_INLINE static inline void osal_task_delay(uint32_t msec) { rt_thread_mdelay(msec); } @@ -47,22 +47,22 @@ static inline void osal_task_delay(uint32_t msec) { typedef struct rt_semaphore osal_semaphore_def_t; typedef rt_sem_t osal_semaphore_t; -static inline osal_semaphore_t +TU_ATTR_ALWAYS_INLINE static inline osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t *semdef) { - rt_sem_init(semdef, "tusb", 0, RT_IPC_FLAG_FIFO); + rt_sem_init(semdef, "tusb", 0, RT_IPC_FLAG_PRIO); return semdef; } -static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr) { +TU_ATTR_ALWAYS_INLINE static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr) { (void) in_isr; return rt_sem_release(sem_hdl) == RT_EOK; } -static inline bool osal_semaphore_wait(osal_semaphore_t sem_hdl, uint32_t msec) { - return rt_sem_take(sem_hdl, rt_tick_from_millisecond(msec)) == RT_EOK; +TU_ATTR_ALWAYS_INLINE static inline bool osal_semaphore_wait(osal_semaphore_t sem_hdl, uint32_t msec) { + return rt_sem_take(sem_hdl, rt_tick_from_millisecond((rt_int32_t) msec)) == RT_EOK; } -static inline void osal_semaphore_reset(osal_semaphore_t const sem_hdl) { +TU_ATTR_ALWAYS_INLINE static inline void osal_semaphore_reset(osal_semaphore_t const sem_hdl) { // TODO: implement } @@ -72,16 +72,16 @@ static inline void osal_semaphore_reset(osal_semaphore_t const sem_hdl) { typedef struct rt_mutex osal_mutex_def_t; typedef rt_mutex_t osal_mutex_t; -static inline osal_mutex_t osal_mutex_create(osal_mutex_def_t *mdef) { - rt_mutex_init(mdef, "tusb", RT_IPC_FLAG_FIFO); +TU_ATTR_ALWAYS_INLINE static inline osal_mutex_t osal_mutex_create(osal_mutex_def_t *mdef) { + rt_mutex_init(mdef, "tusb", RT_IPC_FLAG_PRIO); return mdef; } -static inline bool osal_mutex_lock(osal_mutex_t mutex_hdl, uint32_t msec) { - return rt_mutex_take(mutex_hdl, rt_tick_from_millisecond(msec)) == RT_EOK; +TU_ATTR_ALWAYS_INLINE static inline bool osal_mutex_lock(osal_mutex_t mutex_hdl, uint32_t msec) { + return rt_mutex_take(mutex_hdl, rt_tick_from_millisecond((rt_int32_t) msec)) == RT_EOK; } -static inline bool osal_mutex_unlock(osal_mutex_t mutex_hdl) { +TU_ATTR_ALWAYS_INLINE static inline bool osal_mutex_unlock(osal_mutex_t mutex_hdl) { return rt_mutex_release(mutex_hdl) == RT_EOK; } @@ -104,22 +104,24 @@ typedef struct { typedef rt_mq_t osal_queue_t; -static inline osal_queue_t osal_queue_create(osal_queue_def_t *qdef) { +TU_ATTR_ALWAYS_INLINE static inline osal_queue_t osal_queue_create(osal_queue_def_t *qdef) { rt_mq_init(&(qdef->sq), "tusb", qdef->buf, qdef->item_sz, - qdef->item_sz * qdef->depth, RT_IPC_FLAG_FIFO); + qdef->item_sz * qdef->depth, RT_IPC_FLAG_PRIO); return &(qdef->sq); } -static inline bool osal_queue_receive(osal_queue_t qhdl, void *data) { - return rt_mq_recv(qhdl, data, qhdl->msg_size, RT_WAITING_FOREVER) == RT_EOK; +TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_receive(osal_queue_t qhdl, void *data, uint32_t msec) { + + rt_tick_t tick = rt_tick_from_millisecond((rt_int32_t) msec); + return rt_mq_recv(qhdl, data, qhdl->msg_size, tick) == RT_EOK; } -static inline bool osal_queue_send(osal_queue_t qhdl, void const *data, bool in_isr) { +TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_send(osal_queue_t qhdl, void const *data, bool in_isr) { (void) in_isr; return rt_mq_send(qhdl, (void *)data, qhdl->msg_size) == RT_EOK; } -static inline bool osal_queue_empty(osal_queue_t qhdl) { +TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_empty(osal_queue_t qhdl) { return (qhdl->entry) == 0; } diff --git a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/osal/osal_rtx4.h b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/osal/osal_rtx4.h index 1856a5d9a68..dea1c12c8b1 100644 --- a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/osal/osal_rtx4.h +++ b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/osal/osal_rtx4.h @@ -37,7 +37,7 @@ extern "C" { //--------------------------------------------------------------------+ // TASK API //--------------------------------------------------------------------+ -static inline void osal_task_delay(uint32_t msec) +TU_ATTR_ALWAYS_INLINE static inline void osal_task_delay(uint32_t msec) { uint16_t hi = msec >> 16; uint16_t lo = msec; @@ -47,7 +47,7 @@ static inline void osal_task_delay(uint32_t msec) os_dly_wait(lo); } -static inline uint16_t msec2wait(uint32_t msec) { +TU_ATTR_ALWAYS_INLINE static inline uint16_t msec2wait(uint32_t msec) { if (msec == OSAL_TIMEOUT_WAIT_FOREVER) return 0xFFFF; else if (msec >= 0xFFFE) @@ -62,12 +62,12 @@ static inline uint16_t msec2wait(uint32_t msec) { typedef OS_SEM osal_semaphore_def_t; typedef OS_ID osal_semaphore_t; -static inline OS_ID osal_semaphore_create(osal_semaphore_def_t* semdef) { +TU_ATTR_ALWAYS_INLINE static inline OS_ID osal_semaphore_create(osal_semaphore_def_t* semdef) { os_sem_init(semdef, 0); return semdef; } -static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr) { +TU_ATTR_ALWAYS_INLINE static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr) { if ( !in_isr ) { os_sem_send(sem_hdl); } else { @@ -76,11 +76,11 @@ static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr) { return true; } -static inline bool osal_semaphore_wait (osal_semaphore_t sem_hdl, uint32_t msec) { +TU_ATTR_ALWAYS_INLINE static inline bool osal_semaphore_wait (osal_semaphore_t sem_hdl, uint32_t msec) { return os_sem_wait(sem_hdl, msec2wait(msec)) != OS_R_TMO; } -static inline void osal_semaphore_reset(osal_semaphore_t const sem_hdl) { +TU_ATTR_ALWAYS_INLINE static inline void osal_semaphore_reset(osal_semaphore_t const sem_hdl) { // TODO: implement } @@ -90,18 +90,18 @@ static inline void osal_semaphore_reset(osal_semaphore_t const sem_hdl) { typedef OS_MUT osal_mutex_def_t; typedef OS_ID osal_mutex_t; -static inline osal_mutex_t osal_mutex_create(osal_mutex_def_t* mdef) +TU_ATTR_ALWAYS_INLINE static inline osal_mutex_t osal_mutex_create(osal_mutex_def_t* mdef) { os_mut_init(mdef); return mdef; } -static inline bool osal_mutex_lock (osal_mutex_t mutex_hdl, uint32_t msec) +TU_ATTR_ALWAYS_INLINE static inline bool osal_mutex_lock (osal_mutex_t mutex_hdl, uint32_t msec) { return os_mut_wait(mutex_hdl, msec2wait(msec)) != OS_R_TMO; } -static inline bool osal_mutex_unlock(osal_mutex_t mutex_hdl) +TU_ATTR_ALWAYS_INLINE static inline bool osal_mutex_unlock(osal_mutex_t mutex_hdl) { return os_mut_release(mutex_hdl) == OS_R_OK; } @@ -127,23 +127,23 @@ typedef struct typedef osal_queue_def_t* osal_queue_t; -static inline osal_queue_t osal_queue_create(osal_queue_def_t* qdef) +TU_ATTR_ALWAYS_INLINE static inline osal_queue_t osal_queue_create(osal_queue_def_t* qdef) { os_mbx_init(qdef->mbox, (qdef->depth + 4) * 4); _init_box(qdef->pool, ((qdef->item_sz+3)/4)*(qdef->depth) + 3, qdef->item_sz); return qdef; } -static inline bool osal_queue_receive(osal_queue_t qhdl, void* data) +TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_receive(osal_queue_t qhdl, void* data, uint32_t msec) { void* buf; - os_mbx_wait(qhdl->mbox, &buf, 0xFFFF); + os_mbx_wait(qhdl->mbox, &buf, msec2wait(msec)); memcpy(data, buf, qhdl->item_sz); _free_box(qhdl->pool, buf); return true; } -static inline bool osal_queue_send(osal_queue_t qhdl, void const * data, bool in_isr) +TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_send(osal_queue_t qhdl, void const * data, bool in_isr) { void* buf = _alloc_box(qhdl->pool); memcpy(buf, data, qhdl->item_sz); @@ -158,7 +158,7 @@ static inline bool osal_queue_send(osal_queue_t qhdl, void const * data, bool in return true; } -static inline bool osal_queue_empty(osal_queue_t qhdl) +TU_ATTR_ALWAYS_INLINE static inline bool osal_queue_empty(osal_queue_t qhdl) { return os_mbx_check(qhdl->mbox) == qhdl->depth; } diff --git a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/portable/broadcom/synopsys/synopsys_common.h b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/portable/broadcom/synopsys/synopsys_common.h deleted file mode 100644 index 81ce3b4a945..00000000000 --- a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/portable/broadcom/synopsys/synopsys_common.h +++ /dev/null @@ -1,1476 +0,0 @@ -/** - ****************************************************************************** - * @file synopsys_common.h - * @author MCD Application Team - * @brief CMSIS Cortex-M3 Device USB OTG peripheral Header File. - * This file contains the USB OTG peripheral register's definitions, bits - * definitions and memory mapping for STM32F1xx devices. - * - * This file contains: - * - Data structures and the address mapping for the USB OTG peripheral - * - The Peripheral's registers declarations and bits definition - * - Macros to access the peripheral's registers hardware - * - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2017 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** - */ - -#include "stdint.h" - -#pragma once - -#ifdef __cplusplus - #define __I volatile -#else - #define __I volatile const -#endif -#define __O volatile -#define __IO volatile -#define __IM volatile const -#define __OM volatile -#define __IOM volatile - -/** - * @brief __USB_OTG_Core_register - */ - -typedef struct -{ - __IO uint32_t GOTGCTL; /*!< USB_OTG Control and Status Register Address offset: 000h */ - __IO uint32_t GOTGINT; /*!< USB_OTG Interrupt Register Address offset: 004h */ - __IO uint32_t GAHBCFG; /*!< Core AHB Configuration Register Address offset: 008h */ - __IO uint32_t GUSBCFG; /*!< Core USB Configuration Register Address offset: 00Ch */ - __IO uint32_t GRSTCTL; /*!< Core Reset Register Address offset: 010h */ - __IO uint32_t GINTSTS; /*!< Core Interrupt Register Address offset: 014h */ - __IO uint32_t GINTMSK; /*!< Core Interrupt Mask Register Address offset: 018h */ - __IO uint32_t GRXSTSR; /*!< Receive Sts Q Read Register Address offset: 01Ch */ - __IO uint32_t GRXSTSP; /*!< Receive Sts Q Read & POP Register Address offset: 020h */ - __IO uint32_t GRXFSIZ; /*!< Receive FIFO Size Register Address offset: 024h */ - __IO uint32_t DIEPTXF0_HNPTXFSIZ; /*!< EP0 / Non Periodic Tx FIFO Size Register Address offset: 028h */ - __IO uint32_t HNPTXSTS; /*!< Non Periodic Tx FIFO/Queue Sts reg Address offset: 02Ch */ - uint32_t Reserved30[2]; /*!< Reserved 030h*/ - __IO uint32_t GCCFG; /*!< General Purpose IO Register Address offset: 038h */ - __IO uint32_t CID; /*!< User ID Register 03Ch */ - __IO uint32_t GSNPSID; /* USB_OTG core ID 040h*/ - __IO uint32_t GHWCFG1; /* User HW config1 044h*/ - __IO uint32_t GHWCFG2; /* User HW config2 048h*/ - __IO uint32_t GHWCFG3; /*!< User HW config3 04Ch */ - uint32_t Reserved6; /*!< Reserved 050h */ - __IO uint32_t GLPMCFG; /*!< LPM Register 054h */ - __IO uint32_t GPWRDN; /*!< Power Down Register 058h */ - __IO uint32_t GDFIFOCFG; /*!< DFIFO Software Config Register 05Ch */ - __IO uint32_t GADPCTL; /*!< ADP Timer, Control and Status Register 60Ch */ - uint32_t Reserved43[39]; /*!< Reserved 058h-0FFh */ - __IO uint32_t HPTXFSIZ; /*!< Host Periodic Tx FIFO Size Reg Address offset: 100h */ - __IO uint32_t DIEPTXF[0x0F]; /*!< dev Periodic Transmit FIFO Address offset: 0x104 */ -} USB_OTG_GlobalTypeDef; - - - -/** - * @brief __device_Registers - */ - -typedef struct -{ - __IO uint32_t DCFG; /*!< dev Configuration Register Address offset: 800h*/ - __IO uint32_t DCTL; /*!< dev Control Register Address offset: 804h*/ - __IO uint32_t DSTS; /*!< dev Status Register (RO) Address offset: 808h*/ - uint32_t Reserved0C; /*!< Reserved 80Ch*/ - __IO uint32_t DIEPMSK; /*!< dev IN Endpoint Mask Address offset: 810h*/ - __IO uint32_t DOEPMSK; /*!< dev OUT Endpoint Mask Address offset: 814h*/ - __IO uint32_t DAINT; /*!< dev All Endpoints Itr Reg Address offset: 818h*/ - __IO uint32_t DAINTMSK; /*!< dev All Endpoints Itr Mask Address offset: 81Ch*/ - uint32_t Reserved20; /*!< Reserved 820h*/ - uint32_t Reserved9; /*!< Reserved 824h*/ - __IO uint32_t DVBUSDIS; /*!< dev VBUS discharge Register Address offset: 828h*/ - __IO uint32_t DVBUSPULSE; /*!< dev VBUS Pulse Register Address offset: 82Ch*/ - __IO uint32_t DTHRCTL; /*!< dev thr Address offset: 830h*/ - __IO uint32_t DIEPEMPMSK; /*!< dev empty msk Address offset: 834h*/ - __IO uint32_t DEACHINT; /*!< dedicated EP interrupt Address offset: 838h*/ - __IO uint32_t DEACHMSK; /*!< dedicated EP msk Address offset: 83Ch*/ - uint32_t Reserved40; /*!< dedicated EP mask Address offset: 840h*/ - __IO uint32_t DINEP1MSK; /*!< dedicated EP mask Address offset: 844h*/ - uint32_t Reserved44[15]; /*!< Reserved 844-87Ch*/ - __IO uint32_t DOUTEP1MSK; /*!< dedicated EP msk Address offset: 884h*/ -} USB_OTG_DeviceTypeDef; - -/** - * @brief __IN_Endpoint-Specific_Register - */ - -typedef struct -{ - __IO uint32_t DIEPCTL; /*!< dev IN Endpoint Control Reg 900h + (ep_num * 20h) + 00h*/ - uint32_t Reserved04; /*!< Reserved 900h + (ep_num * 20h) + 04h*/ - __IO uint32_t DIEPINT; /*!< dev IN Endpoint Itr Reg 900h + (ep_num * 20h) + 08h*/ - uint32_t Reserved0C; /*!< Reserved 900h + (ep_num * 20h) + 0Ch*/ - __IO uint32_t DIEPTSIZ; /*!< IN Endpoint Txfer Size 900h + (ep_num * 20h) + 10h*/ - __IO uint32_t DIEPDMA; /*!< IN Endpoint DMA Address Reg 900h + (ep_num * 20h) + 14h*/ - __IO uint32_t DTXFSTS; /*!< IN Endpoint Tx FIFO Status Reg 900h + (ep_num * 20h) + 18h*/ - uint32_t Reserved18; /*!< Reserved 900h+(ep_num*20h)+1Ch-900h+ (ep_num * 20h) + 1Ch*/ -} USB_OTG_INEndpointTypeDef; - -/** - * @brief __OUT_Endpoint-Specific_Registers - */ - -typedef struct -{ - __IO uint32_t DOEPCTL; /*!< dev OUT Endpoint Control Reg B00h + (ep_num * 20h) + 00h*/ - uint32_t Reserved04; /*!< Reserved B00h + (ep_num * 20h) + 04h*/ - __IO uint32_t DOEPINT; /*!< dev OUT Endpoint Itr Reg B00h + (ep_num * 20h) + 08h*/ - uint32_t Reserved0C; /*!< Reserved B00h + (ep_num * 20h) + 0Ch*/ - __IO uint32_t DOEPTSIZ; /*!< dev OUT Endpoint Txfer Size B00h + (ep_num * 20h) + 10h*/ - __IO uint32_t DOEPDMA; /*!< dev OUT Endpoint DMA Address B00h + (ep_num * 20h) + 14h*/ - uint32_t Reserved18[2]; /*!< Reserved B00h + (ep_num * 20h) + 18h - B00h + (ep_num * 20h) + 1Ch*/ -} USB_OTG_OUTEndpointTypeDef; - -/** - * @brief __Host_Mode_Register_Structures - */ - -typedef struct -{ - __IO uint32_t HCFG; /*!< Host Configuration Register 400h*/ - __IO uint32_t HFIR; /*!< Host Frame Interval Register 404h*/ - __IO uint32_t HFNUM; /*!< Host Frame Nbr/Frame Remaining 408h*/ - uint32_t Reserved40C; /*!< Reserved 40Ch*/ - __IO uint32_t HPTXSTS; /*!< Host Periodic Tx FIFO/ Queue Status 410h*/ - __IO uint32_t HAINT; /*!< Host All Channels Interrupt Register 414h*/ - __IO uint32_t HAINTMSK; /*!< Host All Channels Interrupt Mask 418h*/ -} USB_OTG_HostTypeDef; - -/** - * @brief __Host_Channel_Specific_Registers - */ - -typedef struct -{ - __IO uint32_t HCCHAR; - __IO uint32_t HCSPLT; - __IO uint32_t HCINT; - __IO uint32_t HCINTMSK; - __IO uint32_t HCTSIZ; - __IO uint32_t HCDMA; - uint32_t Reserved[2]; -} USB_OTG_HostChannelTypeDef; - -/*!< USB registers base address */ -#define USB_OTG_FS_PERIPH_BASE 0x50000000UL - -// #define USB_OTG_GLOBAL_BASE 0x00000000UL -// #define USB_OTG_DEVICE_BASE 0x00000800UL -#define USB_OTG_IN_ENDPOINT_BASE 0x00000900UL -#define USB_OTG_OUT_ENDPOINT_BASE 0x00000B00UL -#define USB_OTG_EP_REG_SIZE 0x00000020UL -// #define USB_OTG_HOST_BASE 0x00000400UL -#define USB_OTG_HOST_PORT_BASE 0x00000440UL -#define USB_OTG_HOST_CHANNEL_BASE 0x00000500UL -#define USB_OTG_HOST_CHANNEL_SIZE 0x00000020UL -#define USB_OTG_PCGCCTL_BASE 0x00000E00UL -#define USB_OTG_FIFO_BASE 0x00001000UL -#define USB_OTG_FIFO_SIZE 0x00001000UL - -/******************************************************************************/ -/* */ -/* USB_OTG */ -/* */ -/******************************************************************************/ -/******************** Bit definition for USB_OTG_GOTGCTL register ***********/ -#define USB_OTG_GOTGCTL_SRQSCS_Pos (0U) -#define USB_OTG_GOTGCTL_SRQSCS_Msk (0x1UL << USB_OTG_GOTGCTL_SRQSCS_Pos) /*!< 0x00000001 */ -#define USB_OTG_GOTGCTL_SRQSCS USB_OTG_GOTGCTL_SRQSCS_Msk /*!< Session request success */ -#define USB_OTG_GOTGCTL_SRQ_Pos (1U) -#define USB_OTG_GOTGCTL_SRQ_Msk (0x1UL << USB_OTG_GOTGCTL_SRQ_Pos) /*!< 0x00000002 */ -#define USB_OTG_GOTGCTL_SRQ USB_OTG_GOTGCTL_SRQ_Msk /*!< Session request */ -#define USB_OTG_GOTGCTL_HNGSCS_Pos (8U) -#define USB_OTG_GOTGCTL_HNGSCS_Msk (0x1UL << USB_OTG_GOTGCTL_HNGSCS_Pos) /*!< 0x00000100 */ -#define USB_OTG_GOTGCTL_HNGSCS USB_OTG_GOTGCTL_HNGSCS_Msk /*!< Host set HNP enable */ -#define USB_OTG_GOTGCTL_HNPRQ_Pos (9U) -#define USB_OTG_GOTGCTL_HNPRQ_Msk (0x1UL << USB_OTG_GOTGCTL_HNPRQ_Pos) /*!< 0x00000200 */ -#define USB_OTG_GOTGCTL_HNPRQ USB_OTG_GOTGCTL_HNPRQ_Msk /*!< HNP request */ -#define USB_OTG_GOTGCTL_HSHNPEN_Pos (10U) -#define USB_OTG_GOTGCTL_HSHNPEN_Msk (0x1UL << USB_OTG_GOTGCTL_HSHNPEN_Pos) /*!< 0x00000400 */ -#define USB_OTG_GOTGCTL_HSHNPEN USB_OTG_GOTGCTL_HSHNPEN_Msk /*!< Host set HNP enable */ -#define USB_OTG_GOTGCTL_DHNPEN_Pos (11U) -#define USB_OTG_GOTGCTL_DHNPEN_Msk (0x1UL << USB_OTG_GOTGCTL_DHNPEN_Pos) /*!< 0x00000800 */ -#define USB_OTG_GOTGCTL_DHNPEN USB_OTG_GOTGCTL_DHNPEN_Msk /*!< Device HNP enabled */ -#define USB_OTG_GOTGCTL_CIDSTS_Pos (16U) -#define USB_OTG_GOTGCTL_CIDSTS_Msk (0x1UL << USB_OTG_GOTGCTL_CIDSTS_Pos) /*!< 0x00010000 */ -#define USB_OTG_GOTGCTL_CIDSTS USB_OTG_GOTGCTL_CIDSTS_Msk /*!< Connector ID status */ -#define USB_OTG_GOTGCTL_DBCT_Pos (17U) -#define USB_OTG_GOTGCTL_DBCT_Msk (0x1UL << USB_OTG_GOTGCTL_DBCT_Pos) /*!< 0x00020000 */ -#define USB_OTG_GOTGCTL_DBCT USB_OTG_GOTGCTL_DBCT_Msk /*!< Long/short debounce time */ -#define USB_OTG_GOTGCTL_ASVLD_Pos (18U) -#define USB_OTG_GOTGCTL_ASVLD_Msk (0x1UL << USB_OTG_GOTGCTL_ASVLD_Pos) /*!< 0x00040000 */ -#define USB_OTG_GOTGCTL_ASVLD USB_OTG_GOTGCTL_ASVLD_Msk /*!< A-session valid */ -#define USB_OTG_GOTGCTL_BSVLD_Pos (19U) -#define USB_OTG_GOTGCTL_BSVLD_Msk (0x1UL << USB_OTG_GOTGCTL_BSVLD_Pos) /*!< 0x00080000 */ -#define USB_OTG_GOTGCTL_BSVLD USB_OTG_GOTGCTL_BSVLD_Msk /*!< B-session valid */ - -/******************** Bit definition for USB_OTG_HCFG register ********************/ - -#define USB_OTG_HCFG_FSLSPCS_Pos (0U) -#define USB_OTG_HCFG_FSLSPCS_Msk (0x3UL << USB_OTG_HCFG_FSLSPCS_Pos) /*!< 0x00000003 */ -#define USB_OTG_HCFG_FSLSPCS USB_OTG_HCFG_FSLSPCS_Msk /*!< FS/LS PHY clock select */ -#define USB_OTG_HCFG_FSLSPCS_0 (0x1UL << USB_OTG_HCFG_FSLSPCS_Pos) /*!< 0x00000001 */ -#define USB_OTG_HCFG_FSLSPCS_1 (0x2UL << USB_OTG_HCFG_FSLSPCS_Pos) /*!< 0x00000002 */ -#define USB_OTG_HCFG_FSLSS_Pos (2U) -#define USB_OTG_HCFG_FSLSS_Msk (0x1UL << USB_OTG_HCFG_FSLSS_Pos) /*!< 0x00000004 */ -#define USB_OTG_HCFG_FSLSS USB_OTG_HCFG_FSLSS_Msk /*!< FS- and LS-only support */ - -/******************** Bit definition for USB_OTG_DCFG register ********************/ - -#define USB_OTG_DCFG_DSPD_Pos (0U) -#define USB_OTG_DCFG_DSPD_Msk (0x3UL << USB_OTG_DCFG_DSPD_Pos) /*!< 0x00000003 */ -#define USB_OTG_DCFG_DSPD USB_OTG_DCFG_DSPD_Msk /*!< Device speed */ -#define USB_OTG_DCFG_DSPD_0 (0x1UL << USB_OTG_DCFG_DSPD_Pos) /*!< 0x00000001 */ -#define USB_OTG_DCFG_DSPD_1 (0x2UL << USB_OTG_DCFG_DSPD_Pos) /*!< 0x00000002 */ -#define USB_OTG_DCFG_NZLSOHSK_Pos (2U) -#define USB_OTG_DCFG_NZLSOHSK_Msk (0x1UL << USB_OTG_DCFG_NZLSOHSK_Pos) /*!< 0x00000004 */ -#define USB_OTG_DCFG_NZLSOHSK USB_OTG_DCFG_NZLSOHSK_Msk /*!< Nonzero-length status OUT handshake */ - -#define USB_OTG_DCFG_DAD_Pos (4U) -#define USB_OTG_DCFG_DAD_Msk (0x7FUL << USB_OTG_DCFG_DAD_Pos) /*!< 0x000007F0 */ -#define USB_OTG_DCFG_DAD USB_OTG_DCFG_DAD_Msk /*!< Device address */ -#define USB_OTG_DCFG_DAD_0 (0x01UL << USB_OTG_DCFG_DAD_Pos) /*!< 0x00000010 */ -#define USB_OTG_DCFG_DAD_1 (0x02UL << USB_OTG_DCFG_DAD_Pos) /*!< 0x00000020 */ -#define USB_OTG_DCFG_DAD_2 (0x04UL << USB_OTG_DCFG_DAD_Pos) /*!< 0x00000040 */ -#define USB_OTG_DCFG_DAD_3 (0x08UL << USB_OTG_DCFG_DAD_Pos) /*!< 0x00000080 */ -#define USB_OTG_DCFG_DAD_4 (0x10UL << USB_OTG_DCFG_DAD_Pos) /*!< 0x00000100 */ -#define USB_OTG_DCFG_DAD_5 (0x20UL << USB_OTG_DCFG_DAD_Pos) /*!< 0x00000200 */ -#define USB_OTG_DCFG_DAD_6 (0x40UL << USB_OTG_DCFG_DAD_Pos) /*!< 0x00000400 */ - -#define USB_OTG_DCFG_PFIVL_Pos (11U) -#define USB_OTG_DCFG_PFIVL_Msk (0x3UL << USB_OTG_DCFG_PFIVL_Pos) /*!< 0x00001800 */ -#define USB_OTG_DCFG_PFIVL USB_OTG_DCFG_PFIVL_Msk /*!< Periodic (micro)frame interval */ -#define USB_OTG_DCFG_PFIVL_0 (0x1UL << USB_OTG_DCFG_PFIVL_Pos) /*!< 0x00000800 */ -#define USB_OTG_DCFG_PFIVL_1 (0x2UL << USB_OTG_DCFG_PFIVL_Pos) /*!< 0x00001000 */ - -#define USB_OTG_DCFG_PERSCHIVL_Pos (24U) -#define USB_OTG_DCFG_PERSCHIVL_Msk (0x3UL << USB_OTG_DCFG_PERSCHIVL_Pos) /*!< 0x03000000 */ -#define USB_OTG_DCFG_PERSCHIVL USB_OTG_DCFG_PERSCHIVL_Msk /*!< Periodic scheduling interval */ -#define USB_OTG_DCFG_PERSCHIVL_0 (0x1UL << USB_OTG_DCFG_PERSCHIVL_Pos) /*!< 0x01000000 */ -#define USB_OTG_DCFG_PERSCHIVL_1 (0x2UL << USB_OTG_DCFG_PERSCHIVL_Pos) /*!< 0x02000000 */ - -/******************** Bit definition for USB_OTG_PCGCR register ********************/ -#define USB_OTG_PCGCR_STPPCLK_Pos (0U) -#define USB_OTG_PCGCR_STPPCLK_Msk (0x1UL << USB_OTG_PCGCR_STPPCLK_Pos) /*!< 0x00000001 */ -#define USB_OTG_PCGCR_STPPCLK USB_OTG_PCGCR_STPPCLK_Msk /*!< Stop PHY clock */ -#define USB_OTG_PCGCR_GATEHCLK_Pos (1U) -#define USB_OTG_PCGCR_GATEHCLK_Msk (0x1UL << USB_OTG_PCGCR_GATEHCLK_Pos) /*!< 0x00000002 */ -#define USB_OTG_PCGCR_GATEHCLK USB_OTG_PCGCR_GATEHCLK_Msk /*!< Gate HCLK */ -#define USB_OTG_PCGCR_PHYSUSP_Pos (4U) -#define USB_OTG_PCGCR_PHYSUSP_Msk (0x1UL << USB_OTG_PCGCR_PHYSUSP_Pos) /*!< 0x00000010 */ -#define USB_OTG_PCGCR_PHYSUSP USB_OTG_PCGCR_PHYSUSP_Msk /*!< PHY suspended */ - -/******************** Bit definition for USB_OTG_GOTGINT register ********************/ -#define USB_OTG_GOTGINT_SEDET_Pos (2U) -#define USB_OTG_GOTGINT_SEDET_Msk (0x1UL << USB_OTG_GOTGINT_SEDET_Pos) /*!< 0x00000004 */ -#define USB_OTG_GOTGINT_SEDET USB_OTG_GOTGINT_SEDET_Msk /*!< Session end detected */ -#define USB_OTG_GOTGINT_SRSSCHG_Pos (8U) -#define USB_OTG_GOTGINT_SRSSCHG_Msk (0x1UL << USB_OTG_GOTGINT_SRSSCHG_Pos) /*!< 0x00000100 */ -#define USB_OTG_GOTGINT_SRSSCHG USB_OTG_GOTGINT_SRSSCHG_Msk /*!< Session request success status change */ -#define USB_OTG_GOTGINT_HNSSCHG_Pos (9U) -#define USB_OTG_GOTGINT_HNSSCHG_Msk (0x1UL << USB_OTG_GOTGINT_HNSSCHG_Pos) /*!< 0x00000200 */ -#define USB_OTG_GOTGINT_HNSSCHG USB_OTG_GOTGINT_HNSSCHG_Msk /*!< Host negotiation success status change */ -#define USB_OTG_GOTGINT_HNGDET_Pos (17U) -#define USB_OTG_GOTGINT_HNGDET_Msk (0x1UL << USB_OTG_GOTGINT_HNGDET_Pos) /*!< 0x00020000 */ -#define USB_OTG_GOTGINT_HNGDET USB_OTG_GOTGINT_HNGDET_Msk /*!< Host negotiation detected */ -#define USB_OTG_GOTGINT_ADTOCHG_Pos (18U) -#define USB_OTG_GOTGINT_ADTOCHG_Msk (0x1UL << USB_OTG_GOTGINT_ADTOCHG_Pos) /*!< 0x00040000 */ -#define USB_OTG_GOTGINT_ADTOCHG USB_OTG_GOTGINT_ADTOCHG_Msk /*!< A-device timeout change */ -#define USB_OTG_GOTGINT_DBCDNE_Pos (19U) -#define USB_OTG_GOTGINT_DBCDNE_Msk (0x1UL << USB_OTG_GOTGINT_DBCDNE_Pos) /*!< 0x00080000 */ -#define USB_OTG_GOTGINT_DBCDNE USB_OTG_GOTGINT_DBCDNE_Msk /*!< Debounce done */ - -/******************** Bit definition for USB_OTG_DCTL register ********************/ -#define USB_OTG_DCTL_RWUSIG_Pos (0U) -#define USB_OTG_DCTL_RWUSIG_Msk (0x1UL << USB_OTG_DCTL_RWUSIG_Pos) /*!< 0x00000001 */ -#define USB_OTG_DCTL_RWUSIG USB_OTG_DCTL_RWUSIG_Msk /*!< Remote wakeup signaling */ -#define USB_OTG_DCTL_SDIS_Pos (1U) -#define USB_OTG_DCTL_SDIS_Msk (0x1UL << USB_OTG_DCTL_SDIS_Pos) /*!< 0x00000002 */ -#define USB_OTG_DCTL_SDIS USB_OTG_DCTL_SDIS_Msk /*!< Soft disconnect */ -#define USB_OTG_DCTL_GINSTS_Pos (2U) -#define USB_OTG_DCTL_GINSTS_Msk (0x1UL << USB_OTG_DCTL_GINSTS_Pos) /*!< 0x00000004 */ -#define USB_OTG_DCTL_GINSTS USB_OTG_DCTL_GINSTS_Msk /*!< Global IN NAK status */ -#define USB_OTG_DCTL_GONSTS_Pos (3U) -#define USB_OTG_DCTL_GONSTS_Msk (0x1UL << USB_OTG_DCTL_GONSTS_Pos) /*!< 0x00000008 */ -#define USB_OTG_DCTL_GONSTS USB_OTG_DCTL_GONSTS_Msk /*!< Global OUT NAK status */ - -#define USB_OTG_DCTL_TCTL_Pos (4U) -#define USB_OTG_DCTL_TCTL_Msk (0x7UL << USB_OTG_DCTL_TCTL_Pos) /*!< 0x00000070 */ -#define USB_OTG_DCTL_TCTL USB_OTG_DCTL_TCTL_Msk /*!< Test control */ -#define USB_OTG_DCTL_TCTL_0 (0x1UL << USB_OTG_DCTL_TCTL_Pos) /*!< 0x00000010 */ -#define USB_OTG_DCTL_TCTL_1 (0x2UL << USB_OTG_DCTL_TCTL_Pos) /*!< 0x00000020 */ -#define USB_OTG_DCTL_TCTL_2 (0x4UL << USB_OTG_DCTL_TCTL_Pos) /*!< 0x00000040 */ -#define USB_OTG_DCTL_SGINAK_Pos (7U) -#define USB_OTG_DCTL_SGINAK_Msk (0x1UL << USB_OTG_DCTL_SGINAK_Pos) /*!< 0x00000080 */ -#define USB_OTG_DCTL_SGINAK USB_OTG_DCTL_SGINAK_Msk /*!< Set global IN NAK */ -#define USB_OTG_DCTL_CGINAK_Pos (8U) -#define USB_OTG_DCTL_CGINAK_Msk (0x1UL << USB_OTG_DCTL_CGINAK_Pos) /*!< 0x00000100 */ -#define USB_OTG_DCTL_CGINAK USB_OTG_DCTL_CGINAK_Msk /*!< Clear global IN NAK */ -#define USB_OTG_DCTL_SGONAK_Pos (9U) -#define USB_OTG_DCTL_SGONAK_Msk (0x1UL << USB_OTG_DCTL_SGONAK_Pos) /*!< 0x00000200 */ -#define USB_OTG_DCTL_SGONAK USB_OTG_DCTL_SGONAK_Msk /*!< Set global OUT NAK */ -#define USB_OTG_DCTL_CGONAK_Pos (10U) -#define USB_OTG_DCTL_CGONAK_Msk (0x1UL << USB_OTG_DCTL_CGONAK_Pos) /*!< 0x00000400 */ -#define USB_OTG_DCTL_CGONAK USB_OTG_DCTL_CGONAK_Msk /*!< Clear global OUT NAK */ -#define USB_OTG_DCTL_POPRGDNE_Pos (11U) -#define USB_OTG_DCTL_POPRGDNE_Msk (0x1UL << USB_OTG_DCTL_POPRGDNE_Pos) /*!< 0x00000800 */ -#define USB_OTG_DCTL_POPRGDNE USB_OTG_DCTL_POPRGDNE_Msk /*!< Power-on programming done */ - -/******************** Bit definition for USB_OTG_HFIR register ********************/ -#define USB_OTG_HFIR_FRIVL_Pos (0U) -#define USB_OTG_HFIR_FRIVL_Msk (0xFFFFUL << USB_OTG_HFIR_FRIVL_Pos) /*!< 0x0000FFFF */ -#define USB_OTG_HFIR_FRIVL USB_OTG_HFIR_FRIVL_Msk /*!< Frame interval */ - -/******************** Bit definition for USB_OTG_HFNUM register ********************/ -#define USB_OTG_HFNUM_FRNUM_Pos (0U) -#define USB_OTG_HFNUM_FRNUM_Msk (0xFFFFUL << USB_OTG_HFNUM_FRNUM_Pos) /*!< 0x0000FFFF */ -#define USB_OTG_HFNUM_FRNUM USB_OTG_HFNUM_FRNUM_Msk /*!< Frame number */ -#define USB_OTG_HFNUM_FTREM_Pos (16U) -#define USB_OTG_HFNUM_FTREM_Msk (0xFFFFUL << USB_OTG_HFNUM_FTREM_Pos) /*!< 0xFFFF0000 */ -#define USB_OTG_HFNUM_FTREM USB_OTG_HFNUM_FTREM_Msk /*!< Frame time remaining */ - -/******************** Bit definition for USB_OTG_DSTS register ********************/ -#define USB_OTG_DSTS_SUSPSTS_Pos (0U) -#define USB_OTG_DSTS_SUSPSTS_Msk (0x1UL << USB_OTG_DSTS_SUSPSTS_Pos) /*!< 0x00000001 */ -#define USB_OTG_DSTS_SUSPSTS USB_OTG_DSTS_SUSPSTS_Msk /*!< Suspend status */ - -#define USB_OTG_DSTS_ENUMSPD_Pos (1U) -#define USB_OTG_DSTS_ENUMSPD_Msk (0x3UL << USB_OTG_DSTS_ENUMSPD_Pos) /*!< 0x00000006 */ -#define USB_OTG_DSTS_ENUMSPD USB_OTG_DSTS_ENUMSPD_Msk /*!< Enumerated speed */ -#define USB_OTG_DSTS_ENUMSPD_0 (0x1UL << USB_OTG_DSTS_ENUMSPD_Pos) /*!< 0x00000002 */ -#define USB_OTG_DSTS_ENUMSPD_1 (0x2UL << USB_OTG_DSTS_ENUMSPD_Pos) /*!< 0x00000004 */ -#define USB_OTG_DSTS_EERR_Pos (3U) -#define USB_OTG_DSTS_EERR_Msk (0x1UL << USB_OTG_DSTS_EERR_Pos) /*!< 0x00000008 */ -#define USB_OTG_DSTS_EERR USB_OTG_DSTS_EERR_Msk /*!< Erratic error */ -#define USB_OTG_DSTS_FNSOF_Pos (8U) -#define USB_OTG_DSTS_FNSOF_Msk (0x3FFFUL << USB_OTG_DSTS_FNSOF_Pos) /*!< 0x003FFF00 */ -#define USB_OTG_DSTS_FNSOF USB_OTG_DSTS_FNSOF_Msk /*!< Frame number of the received SOF */ - -/******************** Bit definition for USB_OTG_GAHBCFG register ********************/ -#define USB_OTG_GAHBCFG_GINT_Pos (0U) -#define USB_OTG_GAHBCFG_GINT_Msk (0x1UL << USB_OTG_GAHBCFG_GINT_Pos) /*!< 0x00000001 */ -#define USB_OTG_GAHBCFG_GINT USB_OTG_GAHBCFG_GINT_Msk /*!< Global interrupt mask */ -#define USB_OTG_GAHBCFG_HBSTLEN_Pos (1U) -#define USB_OTG_GAHBCFG_HBSTLEN_Msk (0xFUL << USB_OTG_GAHBCFG_HBSTLEN_Pos) /*!< 0x0000001E */ -#define USB_OTG_GAHBCFG_HBSTLEN USB_OTG_GAHBCFG_HBSTLEN_Msk /*!< Burst length/type */ -#define USB_OTG_GAHBCFG_HBSTLEN_0 (0x0UL << USB_OTG_GAHBCFG_HBSTLEN_Pos) /*!< Single */ -#define USB_OTG_GAHBCFG_HBSTLEN_1 (0x1UL << USB_OTG_GAHBCFG_HBSTLEN_Pos) /*!< INCR */ -#define USB_OTG_GAHBCFG_HBSTLEN_2 (0x3UL << USB_OTG_GAHBCFG_HBSTLEN_Pos) /*!< INCR4 */ -#define USB_OTG_GAHBCFG_HBSTLEN_3 (0x5UL << USB_OTG_GAHBCFG_HBSTLEN_Pos) /*!< INCR8 */ -#define USB_OTG_GAHBCFG_HBSTLEN_4 (0x7UL << USB_OTG_GAHBCFG_HBSTLEN_Pos) /*!< INCR16 */ -#define USB_OTG_GAHBCFG_DMAEN_Pos (5U) -#define USB_OTG_GAHBCFG_DMAEN_Msk (0x1UL << USB_OTG_GAHBCFG_DMAEN_Pos) /*!< 0x00000020 */ -#define USB_OTG_GAHBCFG_DMAEN USB_OTG_GAHBCFG_DMAEN_Msk /*!< DMA enable */ -#define USB_OTG_GAHBCFG_TXFELVL_Pos (7U) -#define USB_OTG_GAHBCFG_TXFELVL_Msk (0x1UL << USB_OTG_GAHBCFG_TXFELVL_Pos) /*!< 0x00000080 */ -#define USB_OTG_GAHBCFG_TXFELVL USB_OTG_GAHBCFG_TXFELVL_Msk /*!< TxFIFO empty level */ -#define USB_OTG_GAHBCFG_PTXFELVL_Pos (8U) -#define USB_OTG_GAHBCFG_PTXFELVL_Msk (0x1UL << USB_OTG_GAHBCFG_PTXFELVL_Pos) /*!< 0x00000100 */ -#define USB_OTG_GAHBCFG_PTXFELVL USB_OTG_GAHBCFG_PTXFELVL_Msk /*!< Periodic TxFIFO empty level */ - -/******************** Bit definition for USB_OTG_GUSBCFG register ********************/ - -#define USB_OTG_GUSBCFG_TOCAL_Pos (0U) -#define USB_OTG_GUSBCFG_TOCAL_Msk (0x7UL << USB_OTG_GUSBCFG_TOCAL_Pos) /*!< 0x00000007 */ -#define USB_OTG_GUSBCFG_TOCAL USB_OTG_GUSBCFG_TOCAL_Msk /*!< FS timeout calibration */ -#define USB_OTG_GUSBCFG_TOCAL_0 (0x1UL << USB_OTG_GUSBCFG_TOCAL_Pos) /*!< 0x00000001 */ -#define USB_OTG_GUSBCFG_TOCAL_1 (0x2UL << USB_OTG_GUSBCFG_TOCAL_Pos) /*!< 0x00000002 */ -#define USB_OTG_GUSBCFG_TOCAL_2 (0x4UL << USB_OTG_GUSBCFG_TOCAL_Pos) /*!< 0x00000004 */ -#define USB_OTG_GUSBCFG_PHYSEL_Pos (6U) -#define USB_OTG_GUSBCFG_PHYSEL_Msk (0x1UL << USB_OTG_GUSBCFG_PHYSEL_Pos) /*!< 0x00000040 */ -#define USB_OTG_GUSBCFG_PHYSEL USB_OTG_GUSBCFG_PHYSEL_Msk /*!< USB 2.0 high-speed ULPI PHY or USB 1.1 full-speed serial transceiver select */ -#define USB_OTG_GUSBCFG_SRPCAP_Pos (8U) -#define USB_OTG_GUSBCFG_SRPCAP_Msk (0x1UL << USB_OTG_GUSBCFG_SRPCAP_Pos) /*!< 0x00000100 */ -#define USB_OTG_GUSBCFG_SRPCAP USB_OTG_GUSBCFG_SRPCAP_Msk /*!< SRP-capable */ -#define USB_OTG_GUSBCFG_HNPCAP_Pos (9U) -#define USB_OTG_GUSBCFG_HNPCAP_Msk (0x1UL << USB_OTG_GUSBCFG_HNPCAP_Pos) /*!< 0x00000200 */ -#define USB_OTG_GUSBCFG_HNPCAP USB_OTG_GUSBCFG_HNPCAP_Msk /*!< HNP-capable */ -#define USB_OTG_GUSBCFG_TRDT_Pos (10U) -#define USB_OTG_GUSBCFG_TRDT_Msk (0xFUL << USB_OTG_GUSBCFG_TRDT_Pos) /*!< 0x00003C00 */ -#define USB_OTG_GUSBCFG_TRDT USB_OTG_GUSBCFG_TRDT_Msk /*!< USB turnaround time */ -#define USB_OTG_GUSBCFG_TRDT_0 (0x1UL << USB_OTG_GUSBCFG_TRDT_Pos) /*!< 0x00000400 */ -#define USB_OTG_GUSBCFG_TRDT_1 (0x2UL << USB_OTG_GUSBCFG_TRDT_Pos) /*!< 0x00000800 */ -#define USB_OTG_GUSBCFG_TRDT_2 (0x4UL << USB_OTG_GUSBCFG_TRDT_Pos) /*!< 0x00001000 */ -#define USB_OTG_GUSBCFG_TRDT_3 (0x8UL << USB_OTG_GUSBCFG_TRDT_Pos) /*!< 0x00002000 */ -#define USB_OTG_GUSBCFG_PHYLPCS_Pos (15U) -#define USB_OTG_GUSBCFG_PHYLPCS_Msk (0x1UL << USB_OTG_GUSBCFG_PHYLPCS_Pos) /*!< 0x00008000 */ -#define USB_OTG_GUSBCFG_PHYLPCS USB_OTG_GUSBCFG_PHYLPCS_Msk /*!< PHY Low-power clock select */ -#define USB_OTG_GUSBCFG_ULPIFSLS_Pos (17U) -#define USB_OTG_GUSBCFG_ULPIFSLS_Msk (0x1UL << USB_OTG_GUSBCFG_ULPIFSLS_Pos) /*!< 0x00020000 */ -#define USB_OTG_GUSBCFG_ULPIFSLS USB_OTG_GUSBCFG_ULPIFSLS_Msk /*!< ULPI FS/LS select */ -#define USB_OTG_GUSBCFG_ULPIAR_Pos (18U) -#define USB_OTG_GUSBCFG_ULPIAR_Msk (0x1UL << USB_OTG_GUSBCFG_ULPIAR_Pos) /*!< 0x00040000 */ -#define USB_OTG_GUSBCFG_ULPIAR USB_OTG_GUSBCFG_ULPIAR_Msk /*!< ULPI Auto-resume */ -#define USB_OTG_GUSBCFG_ULPICSM_Pos (19U) -#define USB_OTG_GUSBCFG_ULPICSM_Msk (0x1UL << USB_OTG_GUSBCFG_ULPICSM_Pos) /*!< 0x00080000 */ -#define USB_OTG_GUSBCFG_ULPICSM USB_OTG_GUSBCFG_ULPICSM_Msk /*!< ULPI Clock SuspendM */ -#define USB_OTG_GUSBCFG_ULPIEVBUSD_Pos (20U) -#define USB_OTG_GUSBCFG_ULPIEVBUSD_Msk (0x1UL << USB_OTG_GUSBCFG_ULPIEVBUSD_Pos) /*!< 0x00100000 */ -#define USB_OTG_GUSBCFG_ULPIEVBUSD USB_OTG_GUSBCFG_ULPIEVBUSD_Msk /*!< ULPI External VBUS Drive */ -#define USB_OTG_GUSBCFG_ULPIEVBUSI_Pos (21U) -#define USB_OTG_GUSBCFG_ULPIEVBUSI_Msk (0x1UL << USB_OTG_GUSBCFG_ULPIEVBUSI_Pos) /*!< 0x00200000 */ -#define USB_OTG_GUSBCFG_ULPIEVBUSI USB_OTG_GUSBCFG_ULPIEVBUSI_Msk /*!< ULPI external VBUS indicator */ -#define USB_OTG_GUSBCFG_TSDPS_Pos (22U) -#define USB_OTG_GUSBCFG_TSDPS_Msk (0x1UL << USB_OTG_GUSBCFG_TSDPS_Pos) /*!< 0x00400000 */ -#define USB_OTG_GUSBCFG_TSDPS USB_OTG_GUSBCFG_TSDPS_Msk /*!< TermSel DLine pulsing selection */ -#define USB_OTG_GUSBCFG_PCCI_Pos (23U) -#define USB_OTG_GUSBCFG_PCCI_Msk (0x1UL << USB_OTG_GUSBCFG_PCCI_Pos) /*!< 0x00800000 */ -#define USB_OTG_GUSBCFG_PCCI USB_OTG_GUSBCFG_PCCI_Msk /*!< Indicator complement */ -#define USB_OTG_GUSBCFG_PTCI_Pos (24U) -#define USB_OTG_GUSBCFG_PTCI_Msk (0x1UL << USB_OTG_GUSBCFG_PTCI_Pos) /*!< 0x01000000 */ -#define USB_OTG_GUSBCFG_PTCI USB_OTG_GUSBCFG_PTCI_Msk /*!< Indicator pass through */ -#define USB_OTG_GUSBCFG_ULPIIPD_Pos (25U) -#define USB_OTG_GUSBCFG_ULPIIPD_Msk (0x1UL << USB_OTG_GUSBCFG_ULPIIPD_Pos) /*!< 0x02000000 */ -#define USB_OTG_GUSBCFG_ULPIIPD USB_OTG_GUSBCFG_ULPIIPD_Msk /*!< ULPI interface protect disable */ -#define USB_OTG_GUSBCFG_FHMOD_Pos (29U) -#define USB_OTG_GUSBCFG_FHMOD_Msk (0x1UL << USB_OTG_GUSBCFG_FHMOD_Pos) /*!< 0x20000000 */ -#define USB_OTG_GUSBCFG_FHMOD USB_OTG_GUSBCFG_FHMOD_Msk /*!< Forced host mode */ -#define USB_OTG_GUSBCFG_FDMOD_Pos (30U) -#define USB_OTG_GUSBCFG_FDMOD_Msk (0x1UL << USB_OTG_GUSBCFG_FDMOD_Pos) /*!< 0x40000000 */ -#define USB_OTG_GUSBCFG_FDMOD USB_OTG_GUSBCFG_FDMOD_Msk /*!< Forced peripheral mode */ -#define USB_OTG_GUSBCFG_CTXPKT_Pos (31U) -#define USB_OTG_GUSBCFG_CTXPKT_Msk (0x1UL << USB_OTG_GUSBCFG_CTXPKT_Pos) /*!< 0x80000000 */ -#define USB_OTG_GUSBCFG_CTXPKT USB_OTG_GUSBCFG_CTXPKT_Msk /*!< Corrupt Tx packet */ - -/******************** Bit definition for USB_OTG_GRSTCTL register ********************/ -#define USB_OTG_GRSTCTL_CSRST_Pos (0U) -#define USB_OTG_GRSTCTL_CSRST_Msk (0x1UL << USB_OTG_GRSTCTL_CSRST_Pos) /*!< 0x00000001 */ -#define USB_OTG_GRSTCTL_CSRST USB_OTG_GRSTCTL_CSRST_Msk /*!< Core soft reset */ -#define USB_OTG_GRSTCTL_HSRST_Pos (1U) -#define USB_OTG_GRSTCTL_HSRST_Msk (0x1UL << USB_OTG_GRSTCTL_HSRST_Pos) /*!< 0x00000002 */ -#define USB_OTG_GRSTCTL_HSRST USB_OTG_GRSTCTL_HSRST_Msk /*!< HCLK soft reset */ -#define USB_OTG_GRSTCTL_FCRST_Pos (2U) -#define USB_OTG_GRSTCTL_FCRST_Msk (0x1UL << USB_OTG_GRSTCTL_FCRST_Pos) /*!< 0x00000004 */ -#define USB_OTG_GRSTCTL_FCRST USB_OTG_GRSTCTL_FCRST_Msk /*!< Host frame counter reset */ -#define USB_OTG_GRSTCTL_RXFFLSH_Pos (4U) -#define USB_OTG_GRSTCTL_RXFFLSH_Msk (0x1UL << USB_OTG_GRSTCTL_RXFFLSH_Pos) /*!< 0x00000010 */ -#define USB_OTG_GRSTCTL_RXFFLSH USB_OTG_GRSTCTL_RXFFLSH_Msk /*!< RxFIFO flush */ -#define USB_OTG_GRSTCTL_TXFFLSH_Pos (5U) -#define USB_OTG_GRSTCTL_TXFFLSH_Msk (0x1UL << USB_OTG_GRSTCTL_TXFFLSH_Pos) /*!< 0x00000020 */ -#define USB_OTG_GRSTCTL_TXFFLSH USB_OTG_GRSTCTL_TXFFLSH_Msk /*!< TxFIFO flush */ - - -#define USB_OTG_GRSTCTL_TXFNUM_Pos (6U) -#define USB_OTG_GRSTCTL_TXFNUM_Msk (0x1FUL << USB_OTG_GRSTCTL_TXFNUM_Pos) /*!< 0x000007C0 */ -#define USB_OTG_GRSTCTL_TXFNUM USB_OTG_GRSTCTL_TXFNUM_Msk /*!< TxFIFO number */ -#define USB_OTG_GRSTCTL_TXFNUM_0 (0x01UL << USB_OTG_GRSTCTL_TXFNUM_Pos) /*!< 0x00000040 */ -#define USB_OTG_GRSTCTL_TXFNUM_1 (0x02UL << USB_OTG_GRSTCTL_TXFNUM_Pos) /*!< 0x00000080 */ -#define USB_OTG_GRSTCTL_TXFNUM_2 (0x04UL << USB_OTG_GRSTCTL_TXFNUM_Pos) /*!< 0x00000100 */ -#define USB_OTG_GRSTCTL_TXFNUM_3 (0x08UL << USB_OTG_GRSTCTL_TXFNUM_Pos) /*!< 0x00000200 */ -#define USB_OTG_GRSTCTL_TXFNUM_4 (0x10UL << USB_OTG_GRSTCTL_TXFNUM_Pos) /*!< 0x00000400 */ -#define USB_OTG_GRSTCTL_DMAREQ_Pos (30U) -#define USB_OTG_GRSTCTL_DMAREQ_Msk (0x1UL << USB_OTG_GRSTCTL_DMAREQ_Pos) /*!< 0x40000000 */ -#define USB_OTG_GRSTCTL_DMAREQ USB_OTG_GRSTCTL_DMAREQ_Msk /*!< DMA request signal */ -#define USB_OTG_GRSTCTL_AHBIDL_Pos (31U) -#define USB_OTG_GRSTCTL_AHBIDL_Msk (0x1UL << USB_OTG_GRSTCTL_AHBIDL_Pos) /*!< 0x80000000 */ -#define USB_OTG_GRSTCTL_AHBIDL USB_OTG_GRSTCTL_AHBIDL_Msk /*!< AHB master idle */ - -/******************** Bit definition for USB_OTG_DIEPMSK register ********************/ -#define USB_OTG_DIEPMSK_XFRCM_Pos (0U) -#define USB_OTG_DIEPMSK_XFRCM_Msk (0x1UL << USB_OTG_DIEPMSK_XFRCM_Pos) /*!< 0x00000001 */ -#define USB_OTG_DIEPMSK_XFRCM USB_OTG_DIEPMSK_XFRCM_Msk /*!< Transfer completed interrupt mask */ -#define USB_OTG_DIEPMSK_EPDM_Pos (1U) -#define USB_OTG_DIEPMSK_EPDM_Msk (0x1UL << USB_OTG_DIEPMSK_EPDM_Pos) /*!< 0x00000002 */ -#define USB_OTG_DIEPMSK_EPDM USB_OTG_DIEPMSK_EPDM_Msk /*!< Endpoint disabled interrupt mask */ -#define USB_OTG_DIEPMSK_TOM_Pos (3U) -#define USB_OTG_DIEPMSK_TOM_Msk (0x1UL << USB_OTG_DIEPMSK_TOM_Pos) /*!< 0x00000008 */ -#define USB_OTG_DIEPMSK_TOM USB_OTG_DIEPMSK_TOM_Msk /*!< Timeout condition mask (nonisochronous endpoints) */ -#define USB_OTG_DIEPMSK_ITTXFEMSK_Pos (4U) -#define USB_OTG_DIEPMSK_ITTXFEMSK_Msk (0x1UL << USB_OTG_DIEPMSK_ITTXFEMSK_Pos) /*!< 0x00000010 */ -#define USB_OTG_DIEPMSK_ITTXFEMSK USB_OTG_DIEPMSK_ITTXFEMSK_Msk /*!< IN token received when TxFIFO empty mask */ -#define USB_OTG_DIEPMSK_INEPNMM_Pos (5U) -#define USB_OTG_DIEPMSK_INEPNMM_Msk (0x1UL << USB_OTG_DIEPMSK_INEPNMM_Pos) /*!< 0x00000020 */ -#define USB_OTG_DIEPMSK_INEPNMM USB_OTG_DIEPMSK_INEPNMM_Msk /*!< IN token received with EP mismatch mask */ -#define USB_OTG_DIEPMSK_INEPNEM_Pos (6U) -#define USB_OTG_DIEPMSK_INEPNEM_Msk (0x1UL << USB_OTG_DIEPMSK_INEPNEM_Pos) /*!< 0x00000040 */ -#define USB_OTG_DIEPMSK_INEPNEM USB_OTG_DIEPMSK_INEPNEM_Msk /*!< IN endpoint NAK effective mask */ -#define USB_OTG_DIEPMSK_TXFURM_Pos (8U) -#define USB_OTG_DIEPMSK_TXFURM_Msk (0x1UL << USB_OTG_DIEPMSK_TXFURM_Pos) /*!< 0x00000100 */ -#define USB_OTG_DIEPMSK_TXFURM USB_OTG_DIEPMSK_TXFURM_Msk /*!< FIFO underrun mask */ -#define USB_OTG_DIEPMSK_BIM_Pos (9U) -#define USB_OTG_DIEPMSK_BIM_Msk (0x1UL << USB_OTG_DIEPMSK_BIM_Pos) /*!< 0x00000200 */ -#define USB_OTG_DIEPMSK_BIM USB_OTG_DIEPMSK_BIM_Msk /*!< BNA interrupt mask */ - -/******************** Bit definition for USB_OTG_HPTXSTS register ********************/ -#define USB_OTG_HPTXSTS_PTXFSAVL_Pos (0U) -#define USB_OTG_HPTXSTS_PTXFSAVL_Msk (0xFFFFUL << USB_OTG_HPTXSTS_PTXFSAVL_Pos) /*!< 0x0000FFFF */ -#define USB_OTG_HPTXSTS_PTXFSAVL USB_OTG_HPTXSTS_PTXFSAVL_Msk /*!< Periodic transmit data FIFO space available */ -#define USB_OTG_HPTXSTS_PTXQSAV_Pos (16U) -#define USB_OTG_HPTXSTS_PTXQSAV_Msk (0xFFUL << USB_OTG_HPTXSTS_PTXQSAV_Pos) /*!< 0x00FF0000 */ -#define USB_OTG_HPTXSTS_PTXQSAV USB_OTG_HPTXSTS_PTXQSAV_Msk /*!< Periodic transmit request queue space available */ -#define USB_OTG_HPTXSTS_PTXQSAV_0 (0x01UL << USB_OTG_HPTXSTS_PTXQSAV_Pos) /*!< 0x00010000 */ -#define USB_OTG_HPTXSTS_PTXQSAV_1 (0x02UL << USB_OTG_HPTXSTS_PTXQSAV_Pos) /*!< 0x00020000 */ -#define USB_OTG_HPTXSTS_PTXQSAV_2 (0x04UL << USB_OTG_HPTXSTS_PTXQSAV_Pos) /*!< 0x00040000 */ -#define USB_OTG_HPTXSTS_PTXQSAV_3 (0x08UL << USB_OTG_HPTXSTS_PTXQSAV_Pos) /*!< 0x00080000 */ -#define USB_OTG_HPTXSTS_PTXQSAV_4 (0x10UL << USB_OTG_HPTXSTS_PTXQSAV_Pos) /*!< 0x00100000 */ -#define USB_OTG_HPTXSTS_PTXQSAV_5 (0x20UL << USB_OTG_HPTXSTS_PTXQSAV_Pos) /*!< 0x00200000 */ -#define USB_OTG_HPTXSTS_PTXQSAV_6 (0x40UL << USB_OTG_HPTXSTS_PTXQSAV_Pos) /*!< 0x00400000 */ -#define USB_OTG_HPTXSTS_PTXQSAV_7 (0x80UL << USB_OTG_HPTXSTS_PTXQSAV_Pos) /*!< 0x00800000 */ - -#define USB_OTG_HPTXSTS_PTXQTOP_Pos (24U) -#define USB_OTG_HPTXSTS_PTXQTOP_Msk (0xFFUL << USB_OTG_HPTXSTS_PTXQTOP_Pos) /*!< 0xFF000000 */ -#define USB_OTG_HPTXSTS_PTXQTOP USB_OTG_HPTXSTS_PTXQTOP_Msk /*!< Top of the periodic transmit request queue */ -#define USB_OTG_HPTXSTS_PTXQTOP_0 (0x01UL << USB_OTG_HPTXSTS_PTXQTOP_Pos) /*!< 0x01000000 */ -#define USB_OTG_HPTXSTS_PTXQTOP_1 (0x02UL << USB_OTG_HPTXSTS_PTXQTOP_Pos) /*!< 0x02000000 */ -#define USB_OTG_HPTXSTS_PTXQTOP_2 (0x04UL << USB_OTG_HPTXSTS_PTXQTOP_Pos) /*!< 0x04000000 */ -#define USB_OTG_HPTXSTS_PTXQTOP_3 (0x08UL << USB_OTG_HPTXSTS_PTXQTOP_Pos) /*!< 0x08000000 */ -#define USB_OTG_HPTXSTS_PTXQTOP_4 (0x10UL << USB_OTG_HPTXSTS_PTXQTOP_Pos) /*!< 0x10000000 */ -#define USB_OTG_HPTXSTS_PTXQTOP_5 (0x20UL << USB_OTG_HPTXSTS_PTXQTOP_Pos) /*!< 0x20000000 */ -#define USB_OTG_HPTXSTS_PTXQTOP_6 (0x40UL << USB_OTG_HPTXSTS_PTXQTOP_Pos) /*!< 0x40000000 */ -#define USB_OTG_HPTXSTS_PTXQTOP_7 (0x80UL << USB_OTG_HPTXSTS_PTXQTOP_Pos) /*!< 0x80000000 */ - -/******************** Bit definition for USB_OTG_HAINT register ********************/ -#define USB_OTG_HAINT_HAINT_Pos (0U) -#define USB_OTG_HAINT_HAINT_Msk (0xFFFFUL << USB_OTG_HAINT_HAINT_Pos) /*!< 0x0000FFFF */ -#define USB_OTG_HAINT_HAINT USB_OTG_HAINT_HAINT_Msk /*!< Channel interrupts */ - -/******************** Bit definition for USB_OTG_DOEPMSK register ********************/ -#define USB_OTG_DOEPMSK_XFRCM_Pos (0U) -#define USB_OTG_DOEPMSK_XFRCM_Msk (0x1UL << USB_OTG_DOEPMSK_XFRCM_Pos) /*!< 0x00000001 */ -#define USB_OTG_DOEPMSK_XFRCM USB_OTG_DOEPMSK_XFRCM_Msk /*!< Transfer completed interrupt mask */ -#define USB_OTG_DOEPMSK_EPDM_Pos (1U) -#define USB_OTG_DOEPMSK_EPDM_Msk (0x1UL << USB_OTG_DOEPMSK_EPDM_Pos) /*!< 0x00000002 */ -#define USB_OTG_DOEPMSK_EPDM USB_OTG_DOEPMSK_EPDM_Msk /*!< Endpoint disabled interrupt mask */ -#define USB_OTG_DOEPMSK_AHBERRM_Pos (2U) -#define USB_OTG_DOEPMSK_AHBERRM_Msk (0x1UL << USB_OTG_DOEPMSK_AHBERRM_Pos) /*!< 0x00000004 */ -#define USB_OTG_DOEPMSK_AHBERRM USB_OTG_DOEPMSK_AHBERRM_Msk /*!< OUT transaction AHB Error interrupt mask */ -#define USB_OTG_DOEPMSK_STUPM_Pos (3U) -#define USB_OTG_DOEPMSK_STUPM_Msk (0x1UL << USB_OTG_DOEPMSK_STUPM_Pos) /*!< 0x00000008 */ -#define USB_OTG_DOEPMSK_STUPM USB_OTG_DOEPMSK_STUPM_Msk /*!< SETUP phase done mask */ -#define USB_OTG_DOEPMSK_OTEPDM_Pos (4U) -#define USB_OTG_DOEPMSK_OTEPDM_Msk (0x1UL << USB_OTG_DOEPMSK_OTEPDM_Pos) /*!< 0x00000010 */ -#define USB_OTG_DOEPMSK_OTEPDM USB_OTG_DOEPMSK_OTEPDM_Msk /*!< OUT token received when endpoint disabled mask */ -#define USB_OTG_DOEPMSK_OTEPSPRM_Pos (5U) -#define USB_OTG_DOEPMSK_OTEPSPRM_Msk (0x1UL << USB_OTG_DOEPMSK_OTEPSPRM_Pos) /*!< 0x00000020 */ -#define USB_OTG_DOEPMSK_OTEPSPRM USB_OTG_DOEPMSK_OTEPSPRM_Msk /*!< Status Phase Received mask */ -#define USB_OTG_DOEPMSK_B2BSTUP_Pos (6U) -#define USB_OTG_DOEPMSK_B2BSTUP_Msk (0x1UL << USB_OTG_DOEPMSK_B2BSTUP_Pos) /*!< 0x00000040 */ -#define USB_OTG_DOEPMSK_B2BSTUP USB_OTG_DOEPMSK_B2BSTUP_Msk /*!< Back-to-back SETUP packets received mask */ -#define USB_OTG_DOEPMSK_OPEM_Pos (8U) -#define USB_OTG_DOEPMSK_OPEM_Msk (0x1UL << USB_OTG_DOEPMSK_OPEM_Pos) /*!< 0x00000100 */ -#define USB_OTG_DOEPMSK_OPEM USB_OTG_DOEPMSK_OPEM_Msk /*!< OUT packet error mask */ -#define USB_OTG_DOEPMSK_BOIM_Pos (9U) -#define USB_OTG_DOEPMSK_BOIM_Msk (0x1UL << USB_OTG_DOEPMSK_BOIM_Pos) /*!< 0x00000200 */ -#define USB_OTG_DOEPMSK_BOIM USB_OTG_DOEPMSK_BOIM_Msk /*!< BNA interrupt mask */ -#define USB_OTG_DOEPMSK_BERRM_Pos (12U) -#define USB_OTG_DOEPMSK_BERRM_Msk (0x1UL << USB_OTG_DOEPMSK_BERRM_Pos) /*!< 0x00001000 */ -#define USB_OTG_DOEPMSK_BERRM USB_OTG_DOEPMSK_BERRM_Msk /*!< Babble error interrupt mask */ -#define USB_OTG_DOEPMSK_NAKM_Pos (13U) -#define USB_OTG_DOEPMSK_NAKM_Msk (0x1UL << USB_OTG_DOEPMSK_NAKM_Pos) /*!< 0x00002000 */ -#define USB_OTG_DOEPMSK_NAKM USB_OTG_DOEPMSK_NAKM_Msk /*!< OUT Packet NAK interrupt mask */ -#define USB_OTG_DOEPMSK_NYETM_Pos (14U) -#define USB_OTG_DOEPMSK_NYETM_Msk (0x1UL << USB_OTG_DOEPMSK_NYETM_Pos) /*!< 0x00004000 */ -#define USB_OTG_DOEPMSK_NYETM USB_OTG_DOEPMSK_NYETM_Msk /*!< NYET interrupt mask */ -/******************** Bit definition for USB_OTG_GINTSTS register ********************/ -#define USB_OTG_GINTSTS_CMOD_Pos (0U) -#define USB_OTG_GINTSTS_CMOD_Msk (0x1UL << USB_OTG_GINTSTS_CMOD_Pos) /*!< 0x00000001 */ -#define USB_OTG_GINTSTS_CMOD USB_OTG_GINTSTS_CMOD_Msk /*!< Current mode of operation */ -#define USB_OTG_GINTSTS_MMIS_Pos (1U) -#define USB_OTG_GINTSTS_MMIS_Msk (0x1UL << USB_OTG_GINTSTS_MMIS_Pos) /*!< 0x00000002 */ -#define USB_OTG_GINTSTS_MMIS USB_OTG_GINTSTS_MMIS_Msk /*!< Mode mismatch interrupt */ -#define USB_OTG_GINTSTS_OTGINT_Pos (2U) -#define USB_OTG_GINTSTS_OTGINT_Msk (0x1UL << USB_OTG_GINTSTS_OTGINT_Pos) /*!< 0x00000004 */ -#define USB_OTG_GINTSTS_OTGINT USB_OTG_GINTSTS_OTGINT_Msk /*!< OTG interrupt */ -#define USB_OTG_GINTSTS_SOF_Pos (3U) -#define USB_OTG_GINTSTS_SOF_Msk (0x1UL << USB_OTG_GINTSTS_SOF_Pos) /*!< 0x00000008 */ -#define USB_OTG_GINTSTS_SOF USB_OTG_GINTSTS_SOF_Msk /*!< Start of frame */ -#define USB_OTG_GINTSTS_RXFLVL_Pos (4U) -#define USB_OTG_GINTSTS_RXFLVL_Msk (0x1UL << USB_OTG_GINTSTS_RXFLVL_Pos) /*!< 0x00000010 */ -#define USB_OTG_GINTSTS_RXFLVL USB_OTG_GINTSTS_RXFLVL_Msk /*!< RxFIFO nonempty */ -#define USB_OTG_GINTSTS_NPTXFE_Pos (5U) -#define USB_OTG_GINTSTS_NPTXFE_Msk (0x1UL << USB_OTG_GINTSTS_NPTXFE_Pos) /*!< 0x00000020 */ -#define USB_OTG_GINTSTS_NPTXFE USB_OTG_GINTSTS_NPTXFE_Msk /*!< Nonperiodic TxFIFO empty */ -#define USB_OTG_GINTSTS_GINAKEFF_Pos (6U) -#define USB_OTG_GINTSTS_GINAKEFF_Msk (0x1UL << USB_OTG_GINTSTS_GINAKEFF_Pos) /*!< 0x00000040 */ -#define USB_OTG_GINTSTS_GINAKEFF USB_OTG_GINTSTS_GINAKEFF_Msk /*!< Global IN nonperiodic NAK effective */ -#define USB_OTG_GINTSTS_BOUTNAKEFF_Pos (7U) -#define USB_OTG_GINTSTS_BOUTNAKEFF_Msk (0x1UL << USB_OTG_GINTSTS_BOUTNAKEFF_Pos) /*!< 0x00000080 */ -#define USB_OTG_GINTSTS_BOUTNAKEFF USB_OTG_GINTSTS_BOUTNAKEFF_Msk /*!< Global OUT NAK effective */ -#define USB_OTG_GINTSTS_ESUSP_Pos (10U) -#define USB_OTG_GINTSTS_ESUSP_Msk (0x1UL << USB_OTG_GINTSTS_ESUSP_Pos) /*!< 0x00000400 */ -#define USB_OTG_GINTSTS_ESUSP USB_OTG_GINTSTS_ESUSP_Msk /*!< Early suspend */ -#define USB_OTG_GINTSTS_USBSUSP_Pos (11U) -#define USB_OTG_GINTSTS_USBSUSP_Msk (0x1UL << USB_OTG_GINTSTS_USBSUSP_Pos) /*!< 0x00000800 */ -#define USB_OTG_GINTSTS_USBSUSP USB_OTG_GINTSTS_USBSUSP_Msk /*!< USB suspend */ -#define USB_OTG_GINTSTS_USBRST_Pos (12U) -#define USB_OTG_GINTSTS_USBRST_Msk (0x1UL << USB_OTG_GINTSTS_USBRST_Pos) /*!< 0x00001000 */ -#define USB_OTG_GINTSTS_USBRST USB_OTG_GINTSTS_USBRST_Msk /*!< USB reset */ -#define USB_OTG_GINTSTS_ENUMDNE_Pos (13U) -#define USB_OTG_GINTSTS_ENUMDNE_Msk (0x1UL << USB_OTG_GINTSTS_ENUMDNE_Pos) /*!< 0x00002000 */ -#define USB_OTG_GINTSTS_ENUMDNE USB_OTG_GINTSTS_ENUMDNE_Msk /*!< Enumeration done */ -#define USB_OTG_GINTSTS_ISOODRP_Pos (14U) -#define USB_OTG_GINTSTS_ISOODRP_Msk (0x1UL << USB_OTG_GINTSTS_ISOODRP_Pos) /*!< 0x00004000 */ -#define USB_OTG_GINTSTS_ISOODRP USB_OTG_GINTSTS_ISOODRP_Msk /*!< Isochronous OUT packet dropped interrupt */ -#define USB_OTG_GINTSTS_EOPF_Pos (15U) -#define USB_OTG_GINTSTS_EOPF_Msk (0x1UL << USB_OTG_GINTSTS_EOPF_Pos) /*!< 0x00008000 */ -#define USB_OTG_GINTSTS_EOPF USB_OTG_GINTSTS_EOPF_Msk /*!< End of periodic frame interrupt */ -#define USB_OTG_GINTSTS_IEPINT_Pos (18U) -#define USB_OTG_GINTSTS_IEPINT_Msk (0x1UL << USB_OTG_GINTSTS_IEPINT_Pos) /*!< 0x00040000 */ -#define USB_OTG_GINTSTS_IEPINT USB_OTG_GINTSTS_IEPINT_Msk /*!< IN endpoint interrupt */ -#define USB_OTG_GINTSTS_OEPINT_Pos (19U) -#define USB_OTG_GINTSTS_OEPINT_Msk (0x1UL << USB_OTG_GINTSTS_OEPINT_Pos) /*!< 0x00080000 */ -#define USB_OTG_GINTSTS_OEPINT USB_OTG_GINTSTS_OEPINT_Msk /*!< OUT endpoint interrupt */ -#define USB_OTG_GINTSTS_IISOIXFR_Pos (20U) -#define USB_OTG_GINTSTS_IISOIXFR_Msk (0x1UL << USB_OTG_GINTSTS_IISOIXFR_Pos) /*!< 0x00100000 */ -#define USB_OTG_GINTSTS_IISOIXFR USB_OTG_GINTSTS_IISOIXFR_Msk /*!< Incomplete isochronous IN transfer */ -#define USB_OTG_GINTSTS_PXFR_INCOMPISOOUT_Pos (21U) -#define USB_OTG_GINTSTS_PXFR_INCOMPISOOUT_Msk (0x1UL << USB_OTG_GINTSTS_PXFR_INCOMPISOOUT_Pos) /*!< 0x00200000 */ -#define USB_OTG_GINTSTS_PXFR_INCOMPISOOUT USB_OTG_GINTSTS_PXFR_INCOMPISOOUT_Msk /*!< Incomplete periodic transfer */ -#define USB_OTG_GINTSTS_DATAFSUSP_Pos (22U) -#define USB_OTG_GINTSTS_DATAFSUSP_Msk (0x1UL << USB_OTG_GINTSTS_DATAFSUSP_Pos) /*!< 0x00400000 */ -#define USB_OTG_GINTSTS_DATAFSUSP USB_OTG_GINTSTS_DATAFSUSP_Msk /*!< Data fetch suspended */ -#define USB_OTG_GINTSTS_HPRTINT_Pos (24U) -#define USB_OTG_GINTSTS_HPRTINT_Msk (0x1UL << USB_OTG_GINTSTS_HPRTINT_Pos) /*!< 0x01000000 */ -#define USB_OTG_GINTSTS_HPRTINT USB_OTG_GINTSTS_HPRTINT_Msk /*!< Host port interrupt */ -#define USB_OTG_GINTSTS_HCINT_Pos (25U) -#define USB_OTG_GINTSTS_HCINT_Msk (0x1UL << USB_OTG_GINTSTS_HCINT_Pos) /*!< 0x02000000 */ -#define USB_OTG_GINTSTS_HCINT USB_OTG_GINTSTS_HCINT_Msk /*!< Host channels interrupt */ -#define USB_OTG_GINTSTS_PTXFE_Pos (26U) -#define USB_OTG_GINTSTS_PTXFE_Msk (0x1UL << USB_OTG_GINTSTS_PTXFE_Pos) /*!< 0x04000000 */ -#define USB_OTG_GINTSTS_PTXFE USB_OTG_GINTSTS_PTXFE_Msk /*!< Periodic TxFIFO empty */ -#define USB_OTG_GINTSTS_CIDSCHG_Pos (28U) -#define USB_OTG_GINTSTS_CIDSCHG_Msk (0x1UL << USB_OTG_GINTSTS_CIDSCHG_Pos) /*!< 0x10000000 */ -#define USB_OTG_GINTSTS_CIDSCHG USB_OTG_GINTSTS_CIDSCHG_Msk /*!< Connector ID status change */ -#define USB_OTG_GINTSTS_DISCINT_Pos (29U) -#define USB_OTG_GINTSTS_DISCINT_Msk (0x1UL << USB_OTG_GINTSTS_DISCINT_Pos) /*!< 0x20000000 */ -#define USB_OTG_GINTSTS_DISCINT USB_OTG_GINTSTS_DISCINT_Msk /*!< Disconnect detected interrupt */ -#define USB_OTG_GINTSTS_SRQINT_Pos (30U) -#define USB_OTG_GINTSTS_SRQINT_Msk (0x1UL << USB_OTG_GINTSTS_SRQINT_Pos) /*!< 0x40000000 */ -#define USB_OTG_GINTSTS_SRQINT USB_OTG_GINTSTS_SRQINT_Msk /*!< Session request/new session detected interrupt */ -#define USB_OTG_GINTSTS_WKUINT_Pos (31U) -#define USB_OTG_GINTSTS_WKUINT_Msk (0x1UL << USB_OTG_GINTSTS_WKUINT_Pos) /*!< 0x80000000 */ -#define USB_OTG_GINTSTS_WKUINT USB_OTG_GINTSTS_WKUINT_Msk /*!< Resume/remote wakeup detected interrupt */ - -/******************** Bit definition for USB_OTG_GINTMSK register ********************/ -#define USB_OTG_GINTMSK_MMISM_Pos (1U) -#define USB_OTG_GINTMSK_MMISM_Msk (0x1UL << USB_OTG_GINTMSK_MMISM_Pos) /*!< 0x00000002 */ -#define USB_OTG_GINTMSK_MMISM USB_OTG_GINTMSK_MMISM_Msk /*!< Mode mismatch interrupt mask */ -#define USB_OTG_GINTMSK_OTGINT_Pos (2U) -#define USB_OTG_GINTMSK_OTGINT_Msk (0x1UL << USB_OTG_GINTMSK_OTGINT_Pos) /*!< 0x00000004 */ -#define USB_OTG_GINTMSK_OTGINT USB_OTG_GINTMSK_OTGINT_Msk /*!< OTG interrupt mask */ -#define USB_OTG_GINTMSK_SOFM_Pos (3U) -#define USB_OTG_GINTMSK_SOFM_Msk (0x1UL << USB_OTG_GINTMSK_SOFM_Pos) /*!< 0x00000008 */ -#define USB_OTG_GINTMSK_SOFM USB_OTG_GINTMSK_SOFM_Msk /*!< Start of frame mask */ -#define USB_OTG_GINTMSK_RXFLVLM_Pos (4U) -#define USB_OTG_GINTMSK_RXFLVLM_Msk (0x1UL << USB_OTG_GINTMSK_RXFLVLM_Pos) /*!< 0x00000010 */ -#define USB_OTG_GINTMSK_RXFLVLM USB_OTG_GINTMSK_RXFLVLM_Msk /*!< Receive FIFO nonempty mask */ -#define USB_OTG_GINTMSK_NPTXFEM_Pos (5U) -#define USB_OTG_GINTMSK_NPTXFEM_Msk (0x1UL << USB_OTG_GINTMSK_NPTXFEM_Pos) /*!< 0x00000020 */ -#define USB_OTG_GINTMSK_NPTXFEM USB_OTG_GINTMSK_NPTXFEM_Msk /*!< Nonperiodic TxFIFO empty mask */ -#define USB_OTG_GINTMSK_GINAKEFFM_Pos (6U) -#define USB_OTG_GINTMSK_GINAKEFFM_Msk (0x1UL << USB_OTG_GINTMSK_GINAKEFFM_Pos) /*!< 0x00000040 */ -#define USB_OTG_GINTMSK_GINAKEFFM USB_OTG_GINTMSK_GINAKEFFM_Msk /*!< Global nonperiodic IN NAK effective mask */ -#define USB_OTG_GINTMSK_GONAKEFFM_Pos (7U) -#define USB_OTG_GINTMSK_GONAKEFFM_Msk (0x1UL << USB_OTG_GINTMSK_GONAKEFFM_Pos) /*!< 0x00000080 */ -#define USB_OTG_GINTMSK_GONAKEFFM USB_OTG_GINTMSK_GONAKEFFM_Msk /*!< Global OUT NAK effective mask */ -#define USB_OTG_GINTMSK_ESUSPM_Pos (10U) -#define USB_OTG_GINTMSK_ESUSPM_Msk (0x1UL << USB_OTG_GINTMSK_ESUSPM_Pos) /*!< 0x00000400 */ -#define USB_OTG_GINTMSK_ESUSPM USB_OTG_GINTMSK_ESUSPM_Msk /*!< Early suspend mask */ -#define USB_OTG_GINTMSK_USBSUSPM_Pos (11U) -#define USB_OTG_GINTMSK_USBSUSPM_Msk (0x1UL << USB_OTG_GINTMSK_USBSUSPM_Pos) /*!< 0x00000800 */ -#define USB_OTG_GINTMSK_USBSUSPM USB_OTG_GINTMSK_USBSUSPM_Msk /*!< USB suspend mask */ -#define USB_OTG_GINTMSK_USBRST_Pos (12U) -#define USB_OTG_GINTMSK_USBRST_Msk (0x1UL << USB_OTG_GINTMSK_USBRST_Pos) /*!< 0x00001000 */ -#define USB_OTG_GINTMSK_USBRST USB_OTG_GINTMSK_USBRST_Msk /*!< USB reset mask */ -#define USB_OTG_GINTMSK_ENUMDNEM_Pos (13U) -#define USB_OTG_GINTMSK_ENUMDNEM_Msk (0x1UL << USB_OTG_GINTMSK_ENUMDNEM_Pos) /*!< 0x00002000 */ -#define USB_OTG_GINTMSK_ENUMDNEM USB_OTG_GINTMSK_ENUMDNEM_Msk /*!< Enumeration done mask */ -#define USB_OTG_GINTMSK_ISOODRPM_Pos (14U) -#define USB_OTG_GINTMSK_ISOODRPM_Msk (0x1UL << USB_OTG_GINTMSK_ISOODRPM_Pos) /*!< 0x00004000 */ -#define USB_OTG_GINTMSK_ISOODRPM USB_OTG_GINTMSK_ISOODRPM_Msk /*!< Isochronous OUT packet dropped interrupt mask */ -#define USB_OTG_GINTMSK_EOPFM_Pos (15U) -#define USB_OTG_GINTMSK_EOPFM_Msk (0x1UL << USB_OTG_GINTMSK_EOPFM_Pos) /*!< 0x00008000 */ -#define USB_OTG_GINTMSK_EOPFM USB_OTG_GINTMSK_EOPFM_Msk /*!< End of periodic frame interrupt mask */ -#define USB_OTG_GINTMSK_EPMISM_Pos (17U) -#define USB_OTG_GINTMSK_EPMISM_Msk (0x1UL << USB_OTG_GINTMSK_EPMISM_Pos) /*!< 0x00020000 */ -#define USB_OTG_GINTMSK_EPMISM USB_OTG_GINTMSK_EPMISM_Msk /*!< Endpoint mismatch interrupt mask */ -#define USB_OTG_GINTMSK_IEPINT_Pos (18U) -#define USB_OTG_GINTMSK_IEPINT_Msk (0x1UL << USB_OTG_GINTMSK_IEPINT_Pos) /*!< 0x00040000 */ -#define USB_OTG_GINTMSK_IEPINT USB_OTG_GINTMSK_IEPINT_Msk /*!< IN endpoints interrupt mask */ -#define USB_OTG_GINTMSK_OEPINT_Pos (19U) -#define USB_OTG_GINTMSK_OEPINT_Msk (0x1UL << USB_OTG_GINTMSK_OEPINT_Pos) /*!< 0x00080000 */ -#define USB_OTG_GINTMSK_OEPINT USB_OTG_GINTMSK_OEPINT_Msk /*!< OUT endpoints interrupt mask */ -#define USB_OTG_GINTMSK_IISOIXFRM_Pos (20U) -#define USB_OTG_GINTMSK_IISOIXFRM_Msk (0x1UL << USB_OTG_GINTMSK_IISOIXFRM_Pos) /*!< 0x00100000 */ -#define USB_OTG_GINTMSK_IISOIXFRM USB_OTG_GINTMSK_IISOIXFRM_Msk /*!< Incomplete isochronous IN transfer mask */ -#define USB_OTG_GINTMSK_PXFRM_IISOOXFRM_Pos (21U) -#define USB_OTG_GINTMSK_PXFRM_IISOOXFRM_Msk (0x1UL << USB_OTG_GINTMSK_PXFRM_IISOOXFRM_Pos) /*!< 0x00200000 */ -#define USB_OTG_GINTMSK_PXFRM_IISOOXFRM USB_OTG_GINTMSK_PXFRM_IISOOXFRM_Msk /*!< Incomplete periodic transfer mask */ -#define USB_OTG_GINTMSK_FSUSPM_Pos (22U) -#define USB_OTG_GINTMSK_FSUSPM_Msk (0x1UL << USB_OTG_GINTMSK_FSUSPM_Pos) /*!< 0x00400000 */ -#define USB_OTG_GINTMSK_FSUSPM USB_OTG_GINTMSK_FSUSPM_Msk /*!< Data fetch suspended mask */ -#define USB_OTG_GINTMSK_PRTIM_Pos (24U) -#define USB_OTG_GINTMSK_PRTIM_Msk (0x1UL << USB_OTG_GINTMSK_PRTIM_Pos) /*!< 0x01000000 */ -#define USB_OTG_GINTMSK_PRTIM USB_OTG_GINTMSK_PRTIM_Msk /*!< Host port interrupt mask */ -#define USB_OTG_GINTMSK_HCIM_Pos (25U) -#define USB_OTG_GINTMSK_HCIM_Msk (0x1UL << USB_OTG_GINTMSK_HCIM_Pos) /*!< 0x02000000 */ -#define USB_OTG_GINTMSK_HCIM USB_OTG_GINTMSK_HCIM_Msk /*!< Host channels interrupt mask */ -#define USB_OTG_GINTMSK_PTXFEM_Pos (26U) -#define USB_OTG_GINTMSK_PTXFEM_Msk (0x1UL << USB_OTG_GINTMSK_PTXFEM_Pos) /*!< 0x04000000 */ -#define USB_OTG_GINTMSK_PTXFEM USB_OTG_GINTMSK_PTXFEM_Msk /*!< Periodic TxFIFO empty mask */ -#define USB_OTG_GINTMSK_CIDSCHGM_Pos (28U) -#define USB_OTG_GINTMSK_CIDSCHGM_Msk (0x1UL << USB_OTG_GINTMSK_CIDSCHGM_Pos) /*!< 0x10000000 */ -#define USB_OTG_GINTMSK_CIDSCHGM USB_OTG_GINTMSK_CIDSCHGM_Msk /*!< Connector ID status change mask */ -#define USB_OTG_GINTMSK_DISCINT_Pos (29U) -#define USB_OTG_GINTMSK_DISCINT_Msk (0x1UL << USB_OTG_GINTMSK_DISCINT_Pos) /*!< 0x20000000 */ -#define USB_OTG_GINTMSK_DISCINT USB_OTG_GINTMSK_DISCINT_Msk /*!< Disconnect detected interrupt mask */ -#define USB_OTG_GINTMSK_SRQIM_Pos (30U) -#define USB_OTG_GINTMSK_SRQIM_Msk (0x1UL << USB_OTG_GINTMSK_SRQIM_Pos) /*!< 0x40000000 */ -#define USB_OTG_GINTMSK_SRQIM USB_OTG_GINTMSK_SRQIM_Msk /*!< Session request/new session detected interrupt mask */ -#define USB_OTG_GINTMSK_WUIM_Pos (31U) -#define USB_OTG_GINTMSK_WUIM_Msk (0x1UL << USB_OTG_GINTMSK_WUIM_Pos) /*!< 0x80000000 */ -#define USB_OTG_GINTMSK_WUIM USB_OTG_GINTMSK_WUIM_Msk /*!< Resume/remote wakeup detected interrupt mask */ - -/******************** Bit definition for USB_OTG_DAINT register ********************/ -#define USB_OTG_DAINT_IEPINT_Pos (0U) -#define USB_OTG_DAINT_IEPINT_Msk (0xFFFFUL << USB_OTG_DAINT_IEPINT_Pos) /*!< 0x0000FFFF */ -#define USB_OTG_DAINT_IEPINT USB_OTG_DAINT_IEPINT_Msk /*!< IN endpoint interrupt bits */ -#define USB_OTG_DAINT_OEPINT_Pos (16U) -#define USB_OTG_DAINT_OEPINT_Msk (0xFFFFUL << USB_OTG_DAINT_OEPINT_Pos) /*!< 0xFFFF0000 */ -#define USB_OTG_DAINT_OEPINT USB_OTG_DAINT_OEPINT_Msk /*!< OUT endpoint interrupt bits */ - -/******************** Bit definition for USB_OTG_HAINTMSK register ********************/ -#define USB_OTG_HAINTMSK_HAINTM_Pos (0U) -#define USB_OTG_HAINTMSK_HAINTM_Msk (0xFFFFUL << USB_OTG_HAINTMSK_HAINTM_Pos) /*!< 0x0000FFFF */ -#define USB_OTG_HAINTMSK_HAINTM USB_OTG_HAINTMSK_HAINTM_Msk /*!< Channel interrupt mask */ - -/******************** Bit definition for USB_OTG_GRXSTSP register ********************/ -#define USB_OTG_GRXSTSP_EPNUM_Pos (0U) -#define USB_OTG_GRXSTSP_EPNUM_Msk (0xFUL << USB_OTG_GRXSTSP_EPNUM_Pos) /*!< 0x0000000F */ -#define USB_OTG_GRXSTSP_EPNUM USB_OTG_GRXSTSP_EPNUM_Msk /*!< IN EP interrupt mask bits */ -#define USB_OTG_GRXSTSP_BCNT_Pos (4U) -#define USB_OTG_GRXSTSP_BCNT_Msk (0x7FFUL << USB_OTG_GRXSTSP_BCNT_Pos) /*!< 0x00007FF0 */ -#define USB_OTG_GRXSTSP_BCNT USB_OTG_GRXSTSP_BCNT_Msk /*!< OUT EP interrupt mask bits */ -#define USB_OTG_GRXSTSP_DPID_Pos (15U) -#define USB_OTG_GRXSTSP_DPID_Msk (0x3UL << USB_OTG_GRXSTSP_DPID_Pos) /*!< 0x00018000 */ -#define USB_OTG_GRXSTSP_DPID USB_OTG_GRXSTSP_DPID_Msk /*!< OUT EP interrupt mask bits */ -#define USB_OTG_GRXSTSP_PKTSTS_Pos (17U) -#define USB_OTG_GRXSTSP_PKTSTS_Msk (0xFUL << USB_OTG_GRXSTSP_PKTSTS_Pos) /*!< 0x001E0000 */ -#define USB_OTG_GRXSTSP_PKTSTS USB_OTG_GRXSTSP_PKTSTS_Msk /*!< OUT EP interrupt mask bits */ - -/******************** Bit definition for USB_OTG_DAINTMSK register ********************/ -#define USB_OTG_DAINTMSK_IEPM_Pos (0U) -#define USB_OTG_DAINTMSK_IEPM_Msk (0xFFFFUL << USB_OTG_DAINTMSK_IEPM_Pos) /*!< 0x0000FFFF */ -#define USB_OTG_DAINTMSK_IEPM USB_OTG_DAINTMSK_IEPM_Msk /*!< IN EP interrupt mask bits */ -#define USB_OTG_DAINTMSK_OEPM_Pos (16U) -#define USB_OTG_DAINTMSK_OEPM_Msk (0xFFFFUL << USB_OTG_DAINTMSK_OEPM_Pos) /*!< 0xFFFF0000 */ -#define USB_OTG_DAINTMSK_OEPM USB_OTG_DAINTMSK_OEPM_Msk /*!< OUT EP interrupt mask bits */ - -/******************** Bit definition for USB_OTG_GRXFSIZ register ********************/ -#define USB_OTG_GRXFSIZ_RXFD_Pos (0U) -#define USB_OTG_GRXFSIZ_RXFD_Msk (0xFFFFUL << USB_OTG_GRXFSIZ_RXFD_Pos) /*!< 0x0000FFFF */ -#define USB_OTG_GRXFSIZ_RXFD USB_OTG_GRXFSIZ_RXFD_Msk /*!< RxFIFO depth */ - -/******************** Bit definition for USB_OTG_DVBUSDIS register ********************/ -#define USB_OTG_DVBUSDIS_VBUSDT_Pos (0U) -#define USB_OTG_DVBUSDIS_VBUSDT_Msk (0xFFFFUL << USB_OTG_DVBUSDIS_VBUSDT_Pos) /*!< 0x0000FFFF */ -#define USB_OTG_DVBUSDIS_VBUSDT USB_OTG_DVBUSDIS_VBUSDT_Msk /*!< Device VBUS discharge time */ - -/******************** Bit definition for OTG register ********************/ -#define USB_OTG_NPTXFSA_Pos (0U) -#define USB_OTG_NPTXFSA_Msk (0xFFFFUL << USB_OTG_NPTXFSA_Pos) /*!< 0x0000FFFF */ -#define USB_OTG_NPTXFSA USB_OTG_NPTXFSA_Msk /*!< Nonperiodic transmit RAM start address */ -#define USB_OTG_NPTXFD_Pos (16U) -#define USB_OTG_NPTXFD_Msk (0xFFFFUL << USB_OTG_NPTXFD_Pos) /*!< 0xFFFF0000 */ -#define USB_OTG_NPTXFD USB_OTG_NPTXFD_Msk /*!< Nonperiodic TxFIFO depth */ -#define USB_OTG_TX0FSA_Pos (0U) -#define USB_OTG_TX0FSA_Msk (0xFFFFUL << USB_OTG_TX0FSA_Pos) /*!< 0x0000FFFF */ -#define USB_OTG_TX0FSA USB_OTG_TX0FSA_Msk /*!< Endpoint 0 transmit RAM start address */ -#define USB_OTG_TX0FD_Pos (16U) -#define USB_OTG_TX0FD_Msk (0xFFFFUL << USB_OTG_TX0FD_Pos) /*!< 0xFFFF0000 */ -#define USB_OTG_TX0FD USB_OTG_TX0FD_Msk /*!< Endpoint 0 TxFIFO depth */ - -/******************** Bit definition for USB_OTG_DVBUSPULSE register ********************/ -#define USB_OTG_DVBUSPULSE_DVBUSP_Pos (0U) -#define USB_OTG_DVBUSPULSE_DVBUSP_Msk (0xFFFUL << USB_OTG_DVBUSPULSE_DVBUSP_Pos) /*!< 0x00000FFF */ -#define USB_OTG_DVBUSPULSE_DVBUSP USB_OTG_DVBUSPULSE_DVBUSP_Msk /*!< Device VBUS pulsing time */ - -/******************** Bit definition for USB_OTG_GNPTXSTS register ********************/ -#define USB_OTG_GNPTXSTS_NPTXFSAV_Pos (0U) -#define USB_OTG_GNPTXSTS_NPTXFSAV_Msk (0xFFFFUL << USB_OTG_GNPTXSTS_NPTXFSAV_Pos) /*!< 0x0000FFFF */ -#define USB_OTG_GNPTXSTS_NPTXFSAV USB_OTG_GNPTXSTS_NPTXFSAV_Msk /*!< Nonperiodic TxFIFO space available */ - -#define USB_OTG_GNPTXSTS_NPTQXSAV_Pos (16U) -#define USB_OTG_GNPTXSTS_NPTQXSAV_Msk (0xFFUL << USB_OTG_GNPTXSTS_NPTQXSAV_Pos) /*!< 0x00FF0000 */ -#define USB_OTG_GNPTXSTS_NPTQXSAV USB_OTG_GNPTXSTS_NPTQXSAV_Msk /*!< Nonperiodic transmit request queue space available */ -#define USB_OTG_GNPTXSTS_NPTQXSAV_0 (0x01UL << USB_OTG_GNPTXSTS_NPTQXSAV_Pos) /*!< 0x00010000 */ -#define USB_OTG_GNPTXSTS_NPTQXSAV_1 (0x02UL << USB_OTG_GNPTXSTS_NPTQXSAV_Pos) /*!< 0x00020000 */ -#define USB_OTG_GNPTXSTS_NPTQXSAV_2 (0x04UL << USB_OTG_GNPTXSTS_NPTQXSAV_Pos) /*!< 0x00040000 */ -#define USB_OTG_GNPTXSTS_NPTQXSAV_3 (0x08UL << USB_OTG_GNPTXSTS_NPTQXSAV_Pos) /*!< 0x00080000 */ -#define USB_OTG_GNPTXSTS_NPTQXSAV_4 (0x10UL << USB_OTG_GNPTXSTS_NPTQXSAV_Pos) /*!< 0x00100000 */ -#define USB_OTG_GNPTXSTS_NPTQXSAV_5 (0x20UL << USB_OTG_GNPTXSTS_NPTQXSAV_Pos) /*!< 0x00200000 */ -#define USB_OTG_GNPTXSTS_NPTQXSAV_6 (0x40UL << USB_OTG_GNPTXSTS_NPTQXSAV_Pos) /*!< 0x00400000 */ -#define USB_OTG_GNPTXSTS_NPTQXSAV_7 (0x80UL << USB_OTG_GNPTXSTS_NPTQXSAV_Pos) /*!< 0x00800000 */ - -#define USB_OTG_GNPTXSTS_NPTXQTOP_Pos (24U) -#define USB_OTG_GNPTXSTS_NPTXQTOP_Msk (0x7FUL << USB_OTG_GNPTXSTS_NPTXQTOP_Pos) /*!< 0x7F000000 */ -#define USB_OTG_GNPTXSTS_NPTXQTOP USB_OTG_GNPTXSTS_NPTXQTOP_Msk /*!< Top of the nonperiodic transmit request queue */ -#define USB_OTG_GNPTXSTS_NPTXQTOP_0 (0x01UL << USB_OTG_GNPTXSTS_NPTXQTOP_Pos) /*!< 0x01000000 */ -#define USB_OTG_GNPTXSTS_NPTXQTOP_1 (0x02UL << USB_OTG_GNPTXSTS_NPTXQTOP_Pos) /*!< 0x02000000 */ -#define USB_OTG_GNPTXSTS_NPTXQTOP_2 (0x04UL << USB_OTG_GNPTXSTS_NPTXQTOP_Pos) /*!< 0x04000000 */ -#define USB_OTG_GNPTXSTS_NPTXQTOP_3 (0x08UL << USB_OTG_GNPTXSTS_NPTXQTOP_Pos) /*!< 0x08000000 */ -#define USB_OTG_GNPTXSTS_NPTXQTOP_4 (0x10UL << USB_OTG_GNPTXSTS_NPTXQTOP_Pos) /*!< 0x10000000 */ -#define USB_OTG_GNPTXSTS_NPTXQTOP_5 (0x20UL << USB_OTG_GNPTXSTS_NPTXQTOP_Pos) /*!< 0x20000000 */ -#define USB_OTG_GNPTXSTS_NPTXQTOP_6 (0x40UL << USB_OTG_GNPTXSTS_NPTXQTOP_Pos) /*!< 0x40000000 */ - -/******************** Bit definition for USB_OTG_DTHRCTL register ********************/ -#define USB_OTG_DTHRCTL_NONISOTHREN_Pos (0U) -#define USB_OTG_DTHRCTL_NONISOTHREN_Msk (0x1UL << USB_OTG_DTHRCTL_NONISOTHREN_Pos) /*!< 0x00000001 */ -#define USB_OTG_DTHRCTL_NONISOTHREN USB_OTG_DTHRCTL_NONISOTHREN_Msk /*!< Nonisochronous IN endpoints threshold enable */ -#define USB_OTG_DTHRCTL_ISOTHREN_Pos (1U) -#define USB_OTG_DTHRCTL_ISOTHREN_Msk (0x1UL << USB_OTG_DTHRCTL_ISOTHREN_Pos) /*!< 0x00000002 */ -#define USB_OTG_DTHRCTL_ISOTHREN USB_OTG_DTHRCTL_ISOTHREN_Msk /*!< ISO IN endpoint threshold enable */ - -#define USB_OTG_DTHRCTL_TXTHRLEN_Pos (2U) -#define USB_OTG_DTHRCTL_TXTHRLEN_Msk (0x1FFUL << USB_OTG_DTHRCTL_TXTHRLEN_Pos) /*!< 0x000007FC */ -#define USB_OTG_DTHRCTL_TXTHRLEN USB_OTG_DTHRCTL_TXTHRLEN_Msk /*!< Transmit threshold length */ -#define USB_OTG_DTHRCTL_TXTHRLEN_0 (0x001UL << USB_OTG_DTHRCTL_TXTHRLEN_Pos) /*!< 0x00000004 */ -#define USB_OTG_DTHRCTL_TXTHRLEN_1 (0x002UL << USB_OTG_DTHRCTL_TXTHRLEN_Pos) /*!< 0x00000008 */ -#define USB_OTG_DTHRCTL_TXTHRLEN_2 (0x004UL << USB_OTG_DTHRCTL_TXTHRLEN_Pos) /*!< 0x00000010 */ -#define USB_OTG_DTHRCTL_TXTHRLEN_3 (0x008UL << USB_OTG_DTHRCTL_TXTHRLEN_Pos) /*!< 0x00000020 */ -#define USB_OTG_DTHRCTL_TXTHRLEN_4 (0x010UL << USB_OTG_DTHRCTL_TXTHRLEN_Pos) /*!< 0x00000040 */ -#define USB_OTG_DTHRCTL_TXTHRLEN_5 (0x020UL << USB_OTG_DTHRCTL_TXTHRLEN_Pos) /*!< 0x00000080 */ -#define USB_OTG_DTHRCTL_TXTHRLEN_6 (0x040UL << USB_OTG_DTHRCTL_TXTHRLEN_Pos) /*!< 0x00000100 */ -#define USB_OTG_DTHRCTL_TXTHRLEN_7 (0x080UL << USB_OTG_DTHRCTL_TXTHRLEN_Pos) /*!< 0x00000200 */ -#define USB_OTG_DTHRCTL_TXTHRLEN_8 (0x100UL << USB_OTG_DTHRCTL_TXTHRLEN_Pos) /*!< 0x00000400 */ -#define USB_OTG_DTHRCTL_RXTHREN_Pos (16U) -#define USB_OTG_DTHRCTL_RXTHREN_Msk (0x1UL << USB_OTG_DTHRCTL_RXTHREN_Pos) /*!< 0x00010000 */ -#define USB_OTG_DTHRCTL_RXTHREN USB_OTG_DTHRCTL_RXTHREN_Msk /*!< Receive threshold enable */ - -#define USB_OTG_DTHRCTL_RXTHRLEN_Pos (17U) -#define USB_OTG_DTHRCTL_RXTHRLEN_Msk (0x1FFUL << USB_OTG_DTHRCTL_RXTHRLEN_Pos) /*!< 0x03FE0000 */ -#define USB_OTG_DTHRCTL_RXTHRLEN USB_OTG_DTHRCTL_RXTHRLEN_Msk /*!< Receive threshold length */ -#define USB_OTG_DTHRCTL_RXTHRLEN_0 (0x001UL << USB_OTG_DTHRCTL_RXTHRLEN_Pos) /*!< 0x00020000 */ -#define USB_OTG_DTHRCTL_RXTHRLEN_1 (0x002UL << USB_OTG_DTHRCTL_RXTHRLEN_Pos) /*!< 0x00040000 */ -#define USB_OTG_DTHRCTL_RXTHRLEN_2 (0x004UL << USB_OTG_DTHRCTL_RXTHRLEN_Pos) /*!< 0x00080000 */ -#define USB_OTG_DTHRCTL_RXTHRLEN_3 (0x008UL << USB_OTG_DTHRCTL_RXTHRLEN_Pos) /*!< 0x00100000 */ -#define USB_OTG_DTHRCTL_RXTHRLEN_4 (0x010UL << USB_OTG_DTHRCTL_RXTHRLEN_Pos) /*!< 0x00200000 */ -#define USB_OTG_DTHRCTL_RXTHRLEN_5 (0x020UL << USB_OTG_DTHRCTL_RXTHRLEN_Pos) /*!< 0x00400000 */ -#define USB_OTG_DTHRCTL_RXTHRLEN_6 (0x040UL << USB_OTG_DTHRCTL_RXTHRLEN_Pos) /*!< 0x00800000 */ -#define USB_OTG_DTHRCTL_RXTHRLEN_7 (0x080UL << USB_OTG_DTHRCTL_RXTHRLEN_Pos) /*!< 0x01000000 */ -#define USB_OTG_DTHRCTL_RXTHRLEN_8 (0x100UL << USB_OTG_DTHRCTL_RXTHRLEN_Pos) /*!< 0x02000000 */ -#define USB_OTG_DTHRCTL_ARPEN_Pos (27U) -#define USB_OTG_DTHRCTL_ARPEN_Msk (0x1UL << USB_OTG_DTHRCTL_ARPEN_Pos) /*!< 0x08000000 */ -#define USB_OTG_DTHRCTL_ARPEN USB_OTG_DTHRCTL_ARPEN_Msk /*!< Arbiter parking enable */ - -/******************** Bit definition for USB_OTG_DIEPEMPMSK register ********************/ -#define USB_OTG_DIEPEMPMSK_INEPTXFEM_Pos (0U) -#define USB_OTG_DIEPEMPMSK_INEPTXFEM_Msk (0xFFFFUL << USB_OTG_DIEPEMPMSK_INEPTXFEM_Pos) /*!< 0x0000FFFF */ -#define USB_OTG_DIEPEMPMSK_INEPTXFEM USB_OTG_DIEPEMPMSK_INEPTXFEM_Msk /*!< IN EP Tx FIFO empty interrupt mask bits */ - -/******************** Bit definition for USB_OTG_DEACHINT register ********************/ -#define USB_OTG_DEACHINT_IEP1INT_Pos (1U) -#define USB_OTG_DEACHINT_IEP1INT_Msk (0x1UL << USB_OTG_DEACHINT_IEP1INT_Pos) /*!< 0x00000002 */ -#define USB_OTG_DEACHINT_IEP1INT USB_OTG_DEACHINT_IEP1INT_Msk /*!< IN endpoint 1interrupt bit */ -#define USB_OTG_DEACHINT_OEP1INT_Pos (17U) -#define USB_OTG_DEACHINT_OEP1INT_Msk (0x1UL << USB_OTG_DEACHINT_OEP1INT_Pos) /*!< 0x00020000 */ -#define USB_OTG_DEACHINT_OEP1INT USB_OTG_DEACHINT_OEP1INT_Msk /*!< OUT endpoint 1 interrupt bit */ - -/******************** Bit definition for USB_OTG_GCCFG register ********************/ -#define USB_OTG_GCCFG_PWRDWN_Pos (16U) -#define USB_OTG_GCCFG_PWRDWN_Msk (0x1UL << USB_OTG_GCCFG_PWRDWN_Pos) /*!< 0x00010000 */ -#define USB_OTG_GCCFG_PWRDWN USB_OTG_GCCFG_PWRDWN_Msk /*!< Power down */ -#define USB_OTG_GCCFG_VBUSASEN_Pos (18U) -#define USB_OTG_GCCFG_VBUSASEN_Msk (0x1UL << USB_OTG_GCCFG_VBUSASEN_Pos) /*!< 0x00040000 */ -#define USB_OTG_GCCFG_VBUSASEN USB_OTG_GCCFG_VBUSASEN_Msk /*!< Enable the VBUS sensing device */ -#define USB_OTG_GCCFG_VBUSBSEN_Pos (19U) -#define USB_OTG_GCCFG_VBUSBSEN_Msk (0x1UL << USB_OTG_GCCFG_VBUSBSEN_Pos) /*!< 0x00080000 */ -#define USB_OTG_GCCFG_VBUSBSEN USB_OTG_GCCFG_VBUSBSEN_Msk /*!< Enable the VBUS sensing device */ -#define USB_OTG_GCCFG_SOFOUTEN_Pos (20U) -#define USB_OTG_GCCFG_SOFOUTEN_Msk (0x1UL << USB_OTG_GCCFG_SOFOUTEN_Pos) /*!< 0x00100000 */ -#define USB_OTG_GCCFG_SOFOUTEN USB_OTG_GCCFG_SOFOUTEN_Msk /*!< SOF output enable */ - -/******************** Bit definition for USB_OTG_DEACHINTMSK register ********************/ -#define USB_OTG_DEACHINTMSK_IEP1INTM_Pos (1U) -#define USB_OTG_DEACHINTMSK_IEP1INTM_Msk (0x1UL << USB_OTG_DEACHINTMSK_IEP1INTM_Pos) /*!< 0x00000002 */ -#define USB_OTG_DEACHINTMSK_IEP1INTM USB_OTG_DEACHINTMSK_IEP1INTM_Msk /*!< IN Endpoint 1 interrupt mask bit */ -#define USB_OTG_DEACHINTMSK_OEP1INTM_Pos (17U) -#define USB_OTG_DEACHINTMSK_OEP1INTM_Msk (0x1UL << USB_OTG_DEACHINTMSK_OEP1INTM_Pos) /*!< 0x00020000 */ -#define USB_OTG_DEACHINTMSK_OEP1INTM USB_OTG_DEACHINTMSK_OEP1INTM_Msk /*!< OUT Endpoint 1 interrupt mask bit */ - -/******************** Bit definition for USB_OTG_CID register ********************/ -#define USB_OTG_CID_PRODUCT_ID_Pos (0U) -#define USB_OTG_CID_PRODUCT_ID_Msk (0xFFFFFFFFUL << USB_OTG_CID_PRODUCT_ID_Pos) /*!< 0xFFFFFFFF */ -#define USB_OTG_CID_PRODUCT_ID USB_OTG_CID_PRODUCT_ID_Msk /*!< Product ID field */ - -/******************** Bit definition for USB_OTG_DIEPEACHMSK1 register ********************/ -#define USB_OTG_DIEPEACHMSK1_XFRCM_Pos (0U) -#define USB_OTG_DIEPEACHMSK1_XFRCM_Msk (0x1UL << USB_OTG_DIEPEACHMSK1_XFRCM_Pos) /*!< 0x00000001 */ -#define USB_OTG_DIEPEACHMSK1_XFRCM USB_OTG_DIEPEACHMSK1_XFRCM_Msk /*!< Transfer completed interrupt mask */ -#define USB_OTG_DIEPEACHMSK1_EPDM_Pos (1U) -#define USB_OTG_DIEPEACHMSK1_EPDM_Msk (0x1UL << USB_OTG_DIEPEACHMSK1_EPDM_Pos) /*!< 0x00000002 */ -#define USB_OTG_DIEPEACHMSK1_EPDM USB_OTG_DIEPEACHMSK1_EPDM_Msk /*!< Endpoint disabled interrupt mask */ -#define USB_OTG_DIEPEACHMSK1_TOM_Pos (3U) -#define USB_OTG_DIEPEACHMSK1_TOM_Msk (0x1UL << USB_OTG_DIEPEACHMSK1_TOM_Pos) /*!< 0x00000008 */ -#define USB_OTG_DIEPEACHMSK1_TOM USB_OTG_DIEPEACHMSK1_TOM_Msk /*!< Timeout condition mask (nonisochronous endpoints) */ -#define USB_OTG_DIEPEACHMSK1_ITTXFEMSK_Pos (4U) -#define USB_OTG_DIEPEACHMSK1_ITTXFEMSK_Msk (0x1UL << USB_OTG_DIEPEACHMSK1_ITTXFEMSK_Pos) /*!< 0x00000010 */ -#define USB_OTG_DIEPEACHMSK1_ITTXFEMSK USB_OTG_DIEPEACHMSK1_ITTXFEMSK_Msk /*!< IN token received when TxFIFO empty mask */ -#define USB_OTG_DIEPEACHMSK1_INEPNMM_Pos (5U) -#define USB_OTG_DIEPEACHMSK1_INEPNMM_Msk (0x1UL << USB_OTG_DIEPEACHMSK1_INEPNMM_Pos) /*!< 0x00000020 */ -#define USB_OTG_DIEPEACHMSK1_INEPNMM USB_OTG_DIEPEACHMSK1_INEPNMM_Msk /*!< IN token received with EP mismatch mask */ -#define USB_OTG_DIEPEACHMSK1_INEPNEM_Pos (6U) -#define USB_OTG_DIEPEACHMSK1_INEPNEM_Msk (0x1UL << USB_OTG_DIEPEACHMSK1_INEPNEM_Pos) /*!< 0x00000040 */ -#define USB_OTG_DIEPEACHMSK1_INEPNEM USB_OTG_DIEPEACHMSK1_INEPNEM_Msk /*!< IN endpoint NAK effective mask */ -#define USB_OTG_DIEPEACHMSK1_TXFURM_Pos (8U) -#define USB_OTG_DIEPEACHMSK1_TXFURM_Msk (0x1UL << USB_OTG_DIEPEACHMSK1_TXFURM_Pos) /*!< 0x00000100 */ -#define USB_OTG_DIEPEACHMSK1_TXFURM USB_OTG_DIEPEACHMSK1_TXFURM_Msk /*!< FIFO underrun mask */ -#define USB_OTG_DIEPEACHMSK1_BIM_Pos (9U) -#define USB_OTG_DIEPEACHMSK1_BIM_Msk (0x1UL << USB_OTG_DIEPEACHMSK1_BIM_Pos) /*!< 0x00000200 */ -#define USB_OTG_DIEPEACHMSK1_BIM USB_OTG_DIEPEACHMSK1_BIM_Msk /*!< BNA interrupt mask */ -#define USB_OTG_DIEPEACHMSK1_NAKM_Pos (13U) -#define USB_OTG_DIEPEACHMSK1_NAKM_Msk (0x1UL << USB_OTG_DIEPEACHMSK1_NAKM_Pos) /*!< 0x00002000 */ -#define USB_OTG_DIEPEACHMSK1_NAKM USB_OTG_DIEPEACHMSK1_NAKM_Msk /*!< NAK interrupt mask */ - -/******************** Bit definition for USB_OTG_HPRT register ********************/ -#define USB_OTG_HPRT_PCSTS_Pos (0U) -#define USB_OTG_HPRT_PCSTS_Msk (0x1UL << USB_OTG_HPRT_PCSTS_Pos) /*!< 0x00000001 */ -#define USB_OTG_HPRT_PCSTS USB_OTG_HPRT_PCSTS_Msk /*!< Port connect status */ -#define USB_OTG_HPRT_PCDET_Pos (1U) -#define USB_OTG_HPRT_PCDET_Msk (0x1UL << USB_OTG_HPRT_PCDET_Pos) /*!< 0x00000002 */ -#define USB_OTG_HPRT_PCDET USB_OTG_HPRT_PCDET_Msk /*!< Port connect detected */ -#define USB_OTG_HPRT_PENA_Pos (2U) -#define USB_OTG_HPRT_PENA_Msk (0x1UL << USB_OTG_HPRT_PENA_Pos) /*!< 0x00000004 */ -#define USB_OTG_HPRT_PENA USB_OTG_HPRT_PENA_Msk /*!< Port enable */ -#define USB_OTG_HPRT_PENCHNG_Pos (3U) -#define USB_OTG_HPRT_PENCHNG_Msk (0x1UL << USB_OTG_HPRT_PENCHNG_Pos) /*!< 0x00000008 */ -#define USB_OTG_HPRT_PENCHNG USB_OTG_HPRT_PENCHNG_Msk /*!< Port enable/disable change */ -#define USB_OTG_HPRT_POCA_Pos (4U) -#define USB_OTG_HPRT_POCA_Msk (0x1UL << USB_OTG_HPRT_POCA_Pos) /*!< 0x00000010 */ -#define USB_OTG_HPRT_POCA USB_OTG_HPRT_POCA_Msk /*!< Port overcurrent active */ -#define USB_OTG_HPRT_POCCHNG_Pos (5U) -#define USB_OTG_HPRT_POCCHNG_Msk (0x1UL << USB_OTG_HPRT_POCCHNG_Pos) /*!< 0x00000020 */ -#define USB_OTG_HPRT_POCCHNG USB_OTG_HPRT_POCCHNG_Msk /*!< Port overcurrent change */ -#define USB_OTG_HPRT_PRES_Pos (6U) -#define USB_OTG_HPRT_PRES_Msk (0x1UL << USB_OTG_HPRT_PRES_Pos) /*!< 0x00000040 */ -#define USB_OTG_HPRT_PRES USB_OTG_HPRT_PRES_Msk /*!< Port resume */ -#define USB_OTG_HPRT_PSUSP_Pos (7U) -#define USB_OTG_HPRT_PSUSP_Msk (0x1UL << USB_OTG_HPRT_PSUSP_Pos) /*!< 0x00000080 */ -#define USB_OTG_HPRT_PSUSP USB_OTG_HPRT_PSUSP_Msk /*!< Port suspend */ -#define USB_OTG_HPRT_PRST_Pos (8U) -#define USB_OTG_HPRT_PRST_Msk (0x1UL << USB_OTG_HPRT_PRST_Pos) /*!< 0x00000100 */ -#define USB_OTG_HPRT_PRST USB_OTG_HPRT_PRST_Msk /*!< Port reset */ - -#define USB_OTG_HPRT_PLSTS_Pos (10U) -#define USB_OTG_HPRT_PLSTS_Msk (0x3UL << USB_OTG_HPRT_PLSTS_Pos) /*!< 0x00000C00 */ -#define USB_OTG_HPRT_PLSTS USB_OTG_HPRT_PLSTS_Msk /*!< Port line status */ -#define USB_OTG_HPRT_PLSTS_0 (0x1UL << USB_OTG_HPRT_PLSTS_Pos) /*!< 0x00000400 */ -#define USB_OTG_HPRT_PLSTS_1 (0x2UL << USB_OTG_HPRT_PLSTS_Pos) /*!< 0x00000800 */ -#define USB_OTG_HPRT_PPWR_Pos (12U) -#define USB_OTG_HPRT_PPWR_Msk (0x1UL << USB_OTG_HPRT_PPWR_Pos) /*!< 0x00001000 */ -#define USB_OTG_HPRT_PPWR USB_OTG_HPRT_PPWR_Msk /*!< Port power */ - -#define USB_OTG_HPRT_PTCTL_Pos (13U) -#define USB_OTG_HPRT_PTCTL_Msk (0xFUL << USB_OTG_HPRT_PTCTL_Pos) /*!< 0x0001E000 */ -#define USB_OTG_HPRT_PTCTL USB_OTG_HPRT_PTCTL_Msk /*!< Port test control */ -#define USB_OTG_HPRT_PTCTL_0 (0x1UL << USB_OTG_HPRT_PTCTL_Pos) /*!< 0x00002000 */ -#define USB_OTG_HPRT_PTCTL_1 (0x2UL << USB_OTG_HPRT_PTCTL_Pos) /*!< 0x00004000 */ -#define USB_OTG_HPRT_PTCTL_2 (0x4UL << USB_OTG_HPRT_PTCTL_Pos) /*!< 0x00008000 */ -#define USB_OTG_HPRT_PTCTL_3 (0x8UL << USB_OTG_HPRT_PTCTL_Pos) /*!< 0x00010000 */ - -#define USB_OTG_HPRT_PSPD_Pos (17U) -#define USB_OTG_HPRT_PSPD_Msk (0x3UL << USB_OTG_HPRT_PSPD_Pos) /*!< 0x00060000 */ -#define USB_OTG_HPRT_PSPD USB_OTG_HPRT_PSPD_Msk /*!< Port speed */ -#define USB_OTG_HPRT_PSPD_0 (0x1UL << USB_OTG_HPRT_PSPD_Pos) /*!< 0x00020000 */ -#define USB_OTG_HPRT_PSPD_1 (0x2UL << USB_OTG_HPRT_PSPD_Pos) /*!< 0x00040000 */ - -/******************** Bit definition for USB_OTG_DOEPEACHMSK1 register ********************/ -#define USB_OTG_DOEPEACHMSK1_XFRCM_Pos (0U) -#define USB_OTG_DOEPEACHMSK1_XFRCM_Msk (0x1UL << USB_OTG_DOEPEACHMSK1_XFRCM_Pos) /*!< 0x00000001 */ -#define USB_OTG_DOEPEACHMSK1_XFRCM USB_OTG_DOEPEACHMSK1_XFRCM_Msk /*!< Transfer completed interrupt mask */ -#define USB_OTG_DOEPEACHMSK1_EPDM_Pos (1U) -#define USB_OTG_DOEPEACHMSK1_EPDM_Msk (0x1UL << USB_OTG_DOEPEACHMSK1_EPDM_Pos) /*!< 0x00000002 */ -#define USB_OTG_DOEPEACHMSK1_EPDM USB_OTG_DOEPEACHMSK1_EPDM_Msk /*!< Endpoint disabled interrupt mask */ -#define USB_OTG_DOEPEACHMSK1_TOM_Pos (3U) -#define USB_OTG_DOEPEACHMSK1_TOM_Msk (0x1UL << USB_OTG_DOEPEACHMSK1_TOM_Pos) /*!< 0x00000008 */ -#define USB_OTG_DOEPEACHMSK1_TOM USB_OTG_DOEPEACHMSK1_TOM_Msk /*!< Timeout condition mask */ -#define USB_OTG_DOEPEACHMSK1_ITTXFEMSK_Pos (4U) -#define USB_OTG_DOEPEACHMSK1_ITTXFEMSK_Msk (0x1UL << USB_OTG_DOEPEACHMSK1_ITTXFEMSK_Pos) /*!< 0x00000010 */ -#define USB_OTG_DOEPEACHMSK1_ITTXFEMSK USB_OTG_DOEPEACHMSK1_ITTXFEMSK_Msk /*!< IN token received when TxFIFO empty mask */ -#define USB_OTG_DOEPEACHMSK1_INEPNMM_Pos (5U) -#define USB_OTG_DOEPEACHMSK1_INEPNMM_Msk (0x1UL << USB_OTG_DOEPEACHMSK1_INEPNMM_Pos) /*!< 0x00000020 */ -#define USB_OTG_DOEPEACHMSK1_INEPNMM USB_OTG_DOEPEACHMSK1_INEPNMM_Msk /*!< IN token received with EP mismatch mask */ -#define USB_OTG_DOEPEACHMSK1_INEPNEM_Pos (6U) -#define USB_OTG_DOEPEACHMSK1_INEPNEM_Msk (0x1UL << USB_OTG_DOEPEACHMSK1_INEPNEM_Pos) /*!< 0x00000040 */ -#define USB_OTG_DOEPEACHMSK1_INEPNEM USB_OTG_DOEPEACHMSK1_INEPNEM_Msk /*!< IN endpoint NAK effective mask */ -#define USB_OTG_DOEPEACHMSK1_TXFURM_Pos (8U) -#define USB_OTG_DOEPEACHMSK1_TXFURM_Msk (0x1UL << USB_OTG_DOEPEACHMSK1_TXFURM_Pos) /*!< 0x00000100 */ -#define USB_OTG_DOEPEACHMSK1_TXFURM USB_OTG_DOEPEACHMSK1_TXFURM_Msk /*!< OUT packet error mask */ -#define USB_OTG_DOEPEACHMSK1_BIM_Pos (9U) -#define USB_OTG_DOEPEACHMSK1_BIM_Msk (0x1UL << USB_OTG_DOEPEACHMSK1_BIM_Pos) /*!< 0x00000200 */ -#define USB_OTG_DOEPEACHMSK1_BIM USB_OTG_DOEPEACHMSK1_BIM_Msk /*!< BNA interrupt mask */ -#define USB_OTG_DOEPEACHMSK1_BERRM_Pos (12U) -#define USB_OTG_DOEPEACHMSK1_BERRM_Msk (0x1UL << USB_OTG_DOEPEACHMSK1_BERRM_Pos) /*!< 0x00001000 */ -#define USB_OTG_DOEPEACHMSK1_BERRM USB_OTG_DOEPEACHMSK1_BERRM_Msk /*!< Bubble error interrupt mask */ -#define USB_OTG_DOEPEACHMSK1_NAKM_Pos (13U) -#define USB_OTG_DOEPEACHMSK1_NAKM_Msk (0x1UL << USB_OTG_DOEPEACHMSK1_NAKM_Pos) /*!< 0x00002000 */ -#define USB_OTG_DOEPEACHMSK1_NAKM USB_OTG_DOEPEACHMSK1_NAKM_Msk /*!< NAK interrupt mask */ -#define USB_OTG_DOEPEACHMSK1_NYETM_Pos (14U) -#define USB_OTG_DOEPEACHMSK1_NYETM_Msk (0x1UL << USB_OTG_DOEPEACHMSK1_NYETM_Pos) /*!< 0x00004000 */ -#define USB_OTG_DOEPEACHMSK1_NYETM USB_OTG_DOEPEACHMSK1_NYETM_Msk /*!< NYET interrupt mask */ - -/******************** Bit definition for USB_OTG_HPTXFSIZ register ********************/ -#define USB_OTG_HPTXFSIZ_PTXSA_Pos (0U) -#define USB_OTG_HPTXFSIZ_PTXSA_Msk (0xFFFFUL << USB_OTG_HPTXFSIZ_PTXSA_Pos) /*!< 0x0000FFFF */ -#define USB_OTG_HPTXFSIZ_PTXSA USB_OTG_HPTXFSIZ_PTXSA_Msk /*!< Host periodic TxFIFO start address */ -#define USB_OTG_HPTXFSIZ_PTXFD_Pos (16U) -#define USB_OTG_HPTXFSIZ_PTXFD_Msk (0xFFFFUL << USB_OTG_HPTXFSIZ_PTXFD_Pos) /*!< 0xFFFF0000 */ -#define USB_OTG_HPTXFSIZ_PTXFD USB_OTG_HPTXFSIZ_PTXFD_Msk /*!< Host periodic TxFIFO depth */ - -/******************** Bit definition for USB_OTG_DIEPCTL register ********************/ -#define USB_OTG_DIEPCTL_MPSIZ_Pos (0U) -#define USB_OTG_DIEPCTL_MPSIZ_Msk (0x7FFUL << USB_OTG_DIEPCTL_MPSIZ_Pos) /*!< 0x000007FF */ -#define USB_OTG_DIEPCTL_MPSIZ USB_OTG_DIEPCTL_MPSIZ_Msk /*!< Maximum packet size */ -#define USB_OTG_DIEPCTL_USBAEP_Pos (15U) -#define USB_OTG_DIEPCTL_USBAEP_Msk (0x1UL << USB_OTG_DIEPCTL_USBAEP_Pos) /*!< 0x00008000 */ -#define USB_OTG_DIEPCTL_USBAEP USB_OTG_DIEPCTL_USBAEP_Msk /*!< USB active endpoint */ -#define USB_OTG_DIEPCTL_EONUM_DPID_Pos (16U) -#define USB_OTG_DIEPCTL_EONUM_DPID_Msk (0x1UL << USB_OTG_DIEPCTL_EONUM_DPID_Pos) /*!< 0x00010000 */ -#define USB_OTG_DIEPCTL_EONUM_DPID USB_OTG_DIEPCTL_EONUM_DPID_Msk /*!< Even/odd frame */ -#define USB_OTG_DIEPCTL_NAKSTS_Pos (17U) -#define USB_OTG_DIEPCTL_NAKSTS_Msk (0x1UL << USB_OTG_DIEPCTL_NAKSTS_Pos) /*!< 0x00020000 */ -#define USB_OTG_DIEPCTL_NAKSTS USB_OTG_DIEPCTL_NAKSTS_Msk /*!< NAK status */ - -#define USB_OTG_DIEPCTL_EPTYP_Pos (18U) -#define USB_OTG_DIEPCTL_EPTYP_Msk (0x3UL << USB_OTG_DIEPCTL_EPTYP_Pos) /*!< 0x000C0000 */ -#define USB_OTG_DIEPCTL_EPTYP USB_OTG_DIEPCTL_EPTYP_Msk /*!< Endpoint type */ -#define USB_OTG_DIEPCTL_EPTYP_0 (0x1UL << USB_OTG_DIEPCTL_EPTYP_Pos) /*!< 0x00040000 */ -#define USB_OTG_DIEPCTL_EPTYP_1 (0x2UL << USB_OTG_DIEPCTL_EPTYP_Pos) /*!< 0x00080000 */ -#define USB_OTG_DIEPCTL_STALL_Pos (21U) -#define USB_OTG_DIEPCTL_STALL_Msk (0x1UL << USB_OTG_DIEPCTL_STALL_Pos) /*!< 0x00200000 */ -#define USB_OTG_DIEPCTL_STALL USB_OTG_DIEPCTL_STALL_Msk /*!< STALL handshake */ - -#define USB_OTG_DIEPCTL_TXFNUM_Pos (22U) -#define USB_OTG_DIEPCTL_TXFNUM_Msk (0xFUL << USB_OTG_DIEPCTL_TXFNUM_Pos) /*!< 0x03C00000 */ -#define USB_OTG_DIEPCTL_TXFNUM USB_OTG_DIEPCTL_TXFNUM_Msk /*!< TxFIFO number */ -#define USB_OTG_DIEPCTL_TXFNUM_0 (0x1UL << USB_OTG_DIEPCTL_TXFNUM_Pos) /*!< 0x00400000 */ -#define USB_OTG_DIEPCTL_TXFNUM_1 (0x2UL << USB_OTG_DIEPCTL_TXFNUM_Pos) /*!< 0x00800000 */ -#define USB_OTG_DIEPCTL_TXFNUM_2 (0x4UL << USB_OTG_DIEPCTL_TXFNUM_Pos) /*!< 0x01000000 */ -#define USB_OTG_DIEPCTL_TXFNUM_3 (0x8UL << USB_OTG_DIEPCTL_TXFNUM_Pos) /*!< 0x02000000 */ -#define USB_OTG_DIEPCTL_CNAK_Pos (26U) -#define USB_OTG_DIEPCTL_CNAK_Msk (0x1UL << USB_OTG_DIEPCTL_CNAK_Pos) /*!< 0x04000000 */ -#define USB_OTG_DIEPCTL_CNAK USB_OTG_DIEPCTL_CNAK_Msk /*!< Clear NAK */ -#define USB_OTG_DIEPCTL_SNAK_Pos (27U) -#define USB_OTG_DIEPCTL_SNAK_Msk (0x1UL << USB_OTG_DIEPCTL_SNAK_Pos) /*!< 0x08000000 */ -#define USB_OTG_DIEPCTL_SNAK USB_OTG_DIEPCTL_SNAK_Msk /*!< Set NAK */ -#define USB_OTG_DIEPCTL_SD0PID_SEVNFRM_Pos (28U) -#define USB_OTG_DIEPCTL_SD0PID_SEVNFRM_Msk (0x1UL << USB_OTG_DIEPCTL_SD0PID_SEVNFRM_Pos) /*!< 0x10000000 */ -#define USB_OTG_DIEPCTL_SD0PID_SEVNFRM USB_OTG_DIEPCTL_SD0PID_SEVNFRM_Msk /*!< Set DATA0 PID */ -#define USB_OTG_DIEPCTL_SODDFRM_Pos (29U) -#define USB_OTG_DIEPCTL_SODDFRM_Msk (0x1UL << USB_OTG_DIEPCTL_SODDFRM_Pos) /*!< 0x20000000 */ -#define USB_OTG_DIEPCTL_SODDFRM USB_OTG_DIEPCTL_SODDFRM_Msk /*!< Set odd frame */ -#define USB_OTG_DIEPCTL_EPDIS_Pos (30U) -#define USB_OTG_DIEPCTL_EPDIS_Msk (0x1UL << USB_OTG_DIEPCTL_EPDIS_Pos) /*!< 0x40000000 */ -#define USB_OTG_DIEPCTL_EPDIS USB_OTG_DIEPCTL_EPDIS_Msk /*!< Endpoint disable */ -#define USB_OTG_DIEPCTL_EPENA_Pos (31U) -#define USB_OTG_DIEPCTL_EPENA_Msk (0x1UL << USB_OTG_DIEPCTL_EPENA_Pos) /*!< 0x80000000 */ -#define USB_OTG_DIEPCTL_EPENA USB_OTG_DIEPCTL_EPENA_Msk /*!< Endpoint enable */ - -/******************** Bit definition for USB_OTG_HCCHAR register ********************/ -#define USB_OTG_HCCHAR_MPSIZ_Pos (0U) -#define USB_OTG_HCCHAR_MPSIZ_Msk (0x7FFUL << USB_OTG_HCCHAR_MPSIZ_Pos) /*!< 0x000007FF */ -#define USB_OTG_HCCHAR_MPSIZ USB_OTG_HCCHAR_MPSIZ_Msk /*!< Maximum packet size */ - -#define USB_OTG_HCCHAR_EPNUM_Pos (11U) -#define USB_OTG_HCCHAR_EPNUM_Msk (0xFUL << USB_OTG_HCCHAR_EPNUM_Pos) /*!< 0x00007800 */ -#define USB_OTG_HCCHAR_EPNUM USB_OTG_HCCHAR_EPNUM_Msk /*!< Endpoint number */ -#define USB_OTG_HCCHAR_EPNUM_0 (0x1UL << USB_OTG_HCCHAR_EPNUM_Pos) /*!< 0x00000800 */ -#define USB_OTG_HCCHAR_EPNUM_1 (0x2UL << USB_OTG_HCCHAR_EPNUM_Pos) /*!< 0x00001000 */ -#define USB_OTG_HCCHAR_EPNUM_2 (0x4UL << USB_OTG_HCCHAR_EPNUM_Pos) /*!< 0x00002000 */ -#define USB_OTG_HCCHAR_EPNUM_3 (0x8UL << USB_OTG_HCCHAR_EPNUM_Pos) /*!< 0x00004000 */ -#define USB_OTG_HCCHAR_EPDIR_Pos (15U) -#define USB_OTG_HCCHAR_EPDIR_Msk (0x1UL << USB_OTG_HCCHAR_EPDIR_Pos) /*!< 0x00008000 */ -#define USB_OTG_HCCHAR_EPDIR USB_OTG_HCCHAR_EPDIR_Msk /*!< Endpoint direction */ -#define USB_OTG_HCCHAR_LSDEV_Pos (17U) -#define USB_OTG_HCCHAR_LSDEV_Msk (0x1UL << USB_OTG_HCCHAR_LSDEV_Pos) /*!< 0x00020000 */ -#define USB_OTG_HCCHAR_LSDEV USB_OTG_HCCHAR_LSDEV_Msk /*!< Low-speed device */ - -#define USB_OTG_HCCHAR_EPTYP_Pos (18U) -#define USB_OTG_HCCHAR_EPTYP_Msk (0x3UL << USB_OTG_HCCHAR_EPTYP_Pos) /*!< 0x000C0000 */ -#define USB_OTG_HCCHAR_EPTYP USB_OTG_HCCHAR_EPTYP_Msk /*!< Endpoint type */ -#define USB_OTG_HCCHAR_EPTYP_0 (0x1UL << USB_OTG_HCCHAR_EPTYP_Pos) /*!< 0x00040000 */ -#define USB_OTG_HCCHAR_EPTYP_1 (0x2UL << USB_OTG_HCCHAR_EPTYP_Pos) /*!< 0x00080000 */ - -#define USB_OTG_HCCHAR_MC_Pos (20U) -#define USB_OTG_HCCHAR_MC_Msk (0x3UL << USB_OTG_HCCHAR_MC_Pos) /*!< 0x00300000 */ -#define USB_OTG_HCCHAR_MC USB_OTG_HCCHAR_MC_Msk /*!< Multi Count (MC) / Error Count (EC) */ -#define USB_OTG_HCCHAR_MC_0 (0x1UL << USB_OTG_HCCHAR_MC_Pos) /*!< 0x00100000 */ -#define USB_OTG_HCCHAR_MC_1 (0x2UL << USB_OTG_HCCHAR_MC_Pos) /*!< 0x00200000 */ - -#define USB_OTG_HCCHAR_DAD_Pos (22U) -#define USB_OTG_HCCHAR_DAD_Msk (0x7FUL << USB_OTG_HCCHAR_DAD_Pos) /*!< 0x1FC00000 */ -#define USB_OTG_HCCHAR_DAD USB_OTG_HCCHAR_DAD_Msk /*!< Device address */ -#define USB_OTG_HCCHAR_DAD_0 (0x01UL << USB_OTG_HCCHAR_DAD_Pos) /*!< 0x00400000 */ -#define USB_OTG_HCCHAR_DAD_1 (0x02UL << USB_OTG_HCCHAR_DAD_Pos) /*!< 0x00800000 */ -#define USB_OTG_HCCHAR_DAD_2 (0x04UL << USB_OTG_HCCHAR_DAD_Pos) /*!< 0x01000000 */ -#define USB_OTG_HCCHAR_DAD_3 (0x08UL << USB_OTG_HCCHAR_DAD_Pos) /*!< 0x02000000 */ -#define USB_OTG_HCCHAR_DAD_4 (0x10UL << USB_OTG_HCCHAR_DAD_Pos) /*!< 0x04000000 */ -#define USB_OTG_HCCHAR_DAD_5 (0x20UL << USB_OTG_HCCHAR_DAD_Pos) /*!< 0x08000000 */ -#define USB_OTG_HCCHAR_DAD_6 (0x40UL << USB_OTG_HCCHAR_DAD_Pos) /*!< 0x10000000 */ -#define USB_OTG_HCCHAR_ODDFRM_Pos (29U) -#define USB_OTG_HCCHAR_ODDFRM_Msk (0x1UL << USB_OTG_HCCHAR_ODDFRM_Pos) /*!< 0x20000000 */ -#define USB_OTG_HCCHAR_ODDFRM USB_OTG_HCCHAR_ODDFRM_Msk /*!< Odd frame */ -#define USB_OTG_HCCHAR_CHDIS_Pos (30U) -#define USB_OTG_HCCHAR_CHDIS_Msk (0x1UL << USB_OTG_HCCHAR_CHDIS_Pos) /*!< 0x40000000 */ -#define USB_OTG_HCCHAR_CHDIS USB_OTG_HCCHAR_CHDIS_Msk /*!< Channel disable */ -#define USB_OTG_HCCHAR_CHENA_Pos (31U) -#define USB_OTG_HCCHAR_CHENA_Msk (0x1UL << USB_OTG_HCCHAR_CHENA_Pos) /*!< 0x80000000 */ -#define USB_OTG_HCCHAR_CHENA USB_OTG_HCCHAR_CHENA_Msk /*!< Channel enable */ - -/******************** Bit definition for USB_OTG_HCSPLT register ********************/ - -#define USB_OTG_HCSPLT_PRTADDR_Pos (0U) -#define USB_OTG_HCSPLT_PRTADDR_Msk (0x7FUL << USB_OTG_HCSPLT_PRTADDR_Pos) /*!< 0x0000007F */ -#define USB_OTG_HCSPLT_PRTADDR USB_OTG_HCSPLT_PRTADDR_Msk /*!< Port address */ -#define USB_OTG_HCSPLT_PRTADDR_0 (0x01UL << USB_OTG_HCSPLT_PRTADDR_Pos) /*!< 0x00000001 */ -#define USB_OTG_HCSPLT_PRTADDR_1 (0x02UL << USB_OTG_HCSPLT_PRTADDR_Pos) /*!< 0x00000002 */ -#define USB_OTG_HCSPLT_PRTADDR_2 (0x04UL << USB_OTG_HCSPLT_PRTADDR_Pos) /*!< 0x00000004 */ -#define USB_OTG_HCSPLT_PRTADDR_3 (0x08UL << USB_OTG_HCSPLT_PRTADDR_Pos) /*!< 0x00000008 */ -#define USB_OTG_HCSPLT_PRTADDR_4 (0x10UL << USB_OTG_HCSPLT_PRTADDR_Pos) /*!< 0x00000010 */ -#define USB_OTG_HCSPLT_PRTADDR_5 (0x20UL << USB_OTG_HCSPLT_PRTADDR_Pos) /*!< 0x00000020 */ -#define USB_OTG_HCSPLT_PRTADDR_6 (0x40UL << USB_OTG_HCSPLT_PRTADDR_Pos) /*!< 0x00000040 */ - -#define USB_OTG_HCSPLT_HUBADDR_Pos (7U) -#define USB_OTG_HCSPLT_HUBADDR_Msk (0x7FUL << USB_OTG_HCSPLT_HUBADDR_Pos) /*!< 0x00003F80 */ -#define USB_OTG_HCSPLT_HUBADDR USB_OTG_HCSPLT_HUBADDR_Msk /*!< Hub address */ -#define USB_OTG_HCSPLT_HUBADDR_0 (0x01UL << USB_OTG_HCSPLT_HUBADDR_Pos) /*!< 0x00000080 */ -#define USB_OTG_HCSPLT_HUBADDR_1 (0x02UL << USB_OTG_HCSPLT_HUBADDR_Pos) /*!< 0x00000100 */ -#define USB_OTG_HCSPLT_HUBADDR_2 (0x04UL << USB_OTG_HCSPLT_HUBADDR_Pos) /*!< 0x00000200 */ -#define USB_OTG_HCSPLT_HUBADDR_3 (0x08UL << USB_OTG_HCSPLT_HUBADDR_Pos) /*!< 0x00000400 */ -#define USB_OTG_HCSPLT_HUBADDR_4 (0x10UL << USB_OTG_HCSPLT_HUBADDR_Pos) /*!< 0x00000800 */ -#define USB_OTG_HCSPLT_HUBADDR_5 (0x20UL << USB_OTG_HCSPLT_HUBADDR_Pos) /*!< 0x00001000 */ -#define USB_OTG_HCSPLT_HUBADDR_6 (0x40UL << USB_OTG_HCSPLT_HUBADDR_Pos) /*!< 0x00002000 */ - -#define USB_OTG_HCSPLT_XACTPOS_Pos (14U) -#define USB_OTG_HCSPLT_XACTPOS_Msk (0x3UL << USB_OTG_HCSPLT_XACTPOS_Pos) /*!< 0x0000C000 */ -#define USB_OTG_HCSPLT_XACTPOS USB_OTG_HCSPLT_XACTPOS_Msk /*!< XACTPOS */ -#define USB_OTG_HCSPLT_XACTPOS_0 (0x1UL << USB_OTG_HCSPLT_XACTPOS_Pos) /*!< 0x00004000 */ -#define USB_OTG_HCSPLT_XACTPOS_1 (0x2UL << USB_OTG_HCSPLT_XACTPOS_Pos) /*!< 0x00008000 */ -#define USB_OTG_HCSPLT_COMPLSPLT_Pos (16U) -#define USB_OTG_HCSPLT_COMPLSPLT_Msk (0x1UL << USB_OTG_HCSPLT_COMPLSPLT_Pos) /*!< 0x00010000 */ -#define USB_OTG_HCSPLT_COMPLSPLT USB_OTG_HCSPLT_COMPLSPLT_Msk /*!< Do complete split */ -#define USB_OTG_HCSPLT_SPLITEN_Pos (31U) -#define USB_OTG_HCSPLT_SPLITEN_Msk (0x1UL << USB_OTG_HCSPLT_SPLITEN_Pos) /*!< 0x80000000 */ -#define USB_OTG_HCSPLT_SPLITEN USB_OTG_HCSPLT_SPLITEN_Msk /*!< Split enable */ - -/******************** Bit definition for USB_OTG_HCINT register ********************/ -#define USB_OTG_HCINT_XFRC_Pos (0U) -#define USB_OTG_HCINT_XFRC_Msk (0x1UL << USB_OTG_HCINT_XFRC_Pos) /*!< 0x00000001 */ -#define USB_OTG_HCINT_XFRC USB_OTG_HCINT_XFRC_Msk /*!< Transfer completed */ -#define USB_OTG_HCINT_CHH_Pos (1U) -#define USB_OTG_HCINT_CHH_Msk (0x1UL << USB_OTG_HCINT_CHH_Pos) /*!< 0x00000002 */ -#define USB_OTG_HCINT_CHH USB_OTG_HCINT_CHH_Msk /*!< Channel halted */ -#define USB_OTG_HCINT_AHBERR_Pos (2U) -#define USB_OTG_HCINT_AHBERR_Msk (0x1UL << USB_OTG_HCINT_AHBERR_Pos) /*!< 0x00000004 */ -#define USB_OTG_HCINT_AHBERR USB_OTG_HCINT_AHBERR_Msk /*!< AHB error */ -#define USB_OTG_HCINT_STALL_Pos (3U) -#define USB_OTG_HCINT_STALL_Msk (0x1UL << USB_OTG_HCINT_STALL_Pos) /*!< 0x00000008 */ -#define USB_OTG_HCINT_STALL USB_OTG_HCINT_STALL_Msk /*!< STALL response received interrupt */ -#define USB_OTG_HCINT_NAK_Pos (4U) -#define USB_OTG_HCINT_NAK_Msk (0x1UL << USB_OTG_HCINT_NAK_Pos) /*!< 0x00000010 */ -#define USB_OTG_HCINT_NAK USB_OTG_HCINT_NAK_Msk /*!< NAK response received interrupt */ -#define USB_OTG_HCINT_ACK_Pos (5U) -#define USB_OTG_HCINT_ACK_Msk (0x1UL << USB_OTG_HCINT_ACK_Pos) /*!< 0x00000020 */ -#define USB_OTG_HCINT_ACK USB_OTG_HCINT_ACK_Msk /*!< ACK response received/transmitted interrupt */ -#define USB_OTG_HCINT_NYET_Pos (6U) -#define USB_OTG_HCINT_NYET_Msk (0x1UL << USB_OTG_HCINT_NYET_Pos) /*!< 0x00000040 */ -#define USB_OTG_HCINT_NYET USB_OTG_HCINT_NYET_Msk /*!< Response received interrupt */ -#define USB_OTG_HCINT_TXERR_Pos (7U) -#define USB_OTG_HCINT_TXERR_Msk (0x1UL << USB_OTG_HCINT_TXERR_Pos) /*!< 0x00000080 */ -#define USB_OTG_HCINT_TXERR USB_OTG_HCINT_TXERR_Msk /*!< Transaction error */ -#define USB_OTG_HCINT_BBERR_Pos (8U) -#define USB_OTG_HCINT_BBERR_Msk (0x1UL << USB_OTG_HCINT_BBERR_Pos) /*!< 0x00000100 */ -#define USB_OTG_HCINT_BBERR USB_OTG_HCINT_BBERR_Msk /*!< Babble error */ -#define USB_OTG_HCINT_FRMOR_Pos (9U) -#define USB_OTG_HCINT_FRMOR_Msk (0x1UL << USB_OTG_HCINT_FRMOR_Pos) /*!< 0x00000200 */ -#define USB_OTG_HCINT_FRMOR USB_OTG_HCINT_FRMOR_Msk /*!< Frame overrun */ -#define USB_OTG_HCINT_DTERR_Pos (10U) -#define USB_OTG_HCINT_DTERR_Msk (0x1UL << USB_OTG_HCINT_DTERR_Pos) /*!< 0x00000400 */ -#define USB_OTG_HCINT_DTERR USB_OTG_HCINT_DTERR_Msk /*!< Data toggle error */ - -/******************** Bit definition for USB_OTG_DIEPINT register ********************/ -#define USB_OTG_DIEPINT_XFRC_Pos (0U) -#define USB_OTG_DIEPINT_XFRC_Msk (0x1UL << USB_OTG_DIEPINT_XFRC_Pos) /*!< 0x00000001 */ -#define USB_OTG_DIEPINT_XFRC USB_OTG_DIEPINT_XFRC_Msk /*!< Transfer completed interrupt */ -#define USB_OTG_DIEPINT_EPDISD_Pos (1U) -#define USB_OTG_DIEPINT_EPDISD_Msk (0x1UL << USB_OTG_DIEPINT_EPDISD_Pos) /*!< 0x00000002 */ -#define USB_OTG_DIEPINT_EPDISD USB_OTG_DIEPINT_EPDISD_Msk /*!< Endpoint disabled interrupt */ -#define USB_OTG_DIEPINT_AHBERR_Pos (2U) -#define USB_OTG_DIEPINT_AHBERR_Msk (0x1UL << USB_OTG_DIEPINT_AHBERR_Pos) /*!< 0x00000004 */ -#define USB_OTG_DIEPINT_AHBERR USB_OTG_DIEPINT_AHBERR_Msk /*!< AHB Error (AHBErr) during an IN transaction */ -#define USB_OTG_DIEPINT_TOC_Pos (3U) -#define USB_OTG_DIEPINT_TOC_Msk (0x1UL << USB_OTG_DIEPINT_TOC_Pos) /*!< 0x00000008 */ -#define USB_OTG_DIEPINT_TOC USB_OTG_DIEPINT_TOC_Msk /*!< Timeout condition */ -#define USB_OTG_DIEPINT_ITTXFE_Pos (4U) -#define USB_OTG_DIEPINT_ITTXFE_Msk (0x1UL << USB_OTG_DIEPINT_ITTXFE_Pos) /*!< 0x00000010 */ -#define USB_OTG_DIEPINT_ITTXFE USB_OTG_DIEPINT_ITTXFE_Msk /*!< IN token received when TxFIFO is empty */ -#define USB_OTG_DIEPINT_INEPNM_Pos (5U) -#define USB_OTG_DIEPINT_INEPNM_Msk (0x1UL << USB_OTG_DIEPINT_INEPNM_Pos) /*!< 0x00000004 */ -#define USB_OTG_DIEPINT_INEPNM USB_OTG_DIEPINT_INEPNM_Msk /*!< IN token received with EP mismatch */ -#define USB_OTG_DIEPINT_INEPNE_Pos (6U) -#define USB_OTG_DIEPINT_INEPNE_Msk (0x1UL << USB_OTG_DIEPINT_INEPNE_Pos) /*!< 0x00000040 */ -#define USB_OTG_DIEPINT_INEPNE USB_OTG_DIEPINT_INEPNE_Msk /*!< IN endpoint NAK effective */ -#define USB_OTG_DIEPINT_TXFE_Pos (7U) -#define USB_OTG_DIEPINT_TXFE_Msk (0x1UL << USB_OTG_DIEPINT_TXFE_Pos) /*!< 0x00000080 */ -#define USB_OTG_DIEPINT_TXFE USB_OTG_DIEPINT_TXFE_Msk /*!< Transmit FIFO empty */ -#define USB_OTG_DIEPINT_TXFIFOUDRN_Pos (8U) -#define USB_OTG_DIEPINT_TXFIFOUDRN_Msk (0x1UL << USB_OTG_DIEPINT_TXFIFOUDRN_Pos) /*!< 0x00000100 */ -#define USB_OTG_DIEPINT_TXFIFOUDRN USB_OTG_DIEPINT_TXFIFOUDRN_Msk /*!< Transmit Fifo Underrun */ -#define USB_OTG_DIEPINT_BNA_Pos (9U) -#define USB_OTG_DIEPINT_BNA_Msk (0x1UL << USB_OTG_DIEPINT_BNA_Pos) /*!< 0x00000200 */ -#define USB_OTG_DIEPINT_BNA USB_OTG_DIEPINT_BNA_Msk /*!< Buffer not available interrupt */ -#define USB_OTG_DIEPINT_PKTDRPSTS_Pos (11U) -#define USB_OTG_DIEPINT_PKTDRPSTS_Msk (0x1UL << USB_OTG_DIEPINT_PKTDRPSTS_Pos) /*!< 0x00000800 */ -#define USB_OTG_DIEPINT_PKTDRPSTS USB_OTG_DIEPINT_PKTDRPSTS_Msk /*!< Packet dropped status */ -#define USB_OTG_DIEPINT_BERR_Pos (12U) -#define USB_OTG_DIEPINT_BERR_Msk (0x1UL << USB_OTG_DIEPINT_BERR_Pos) /*!< 0x00001000 */ -#define USB_OTG_DIEPINT_BERR USB_OTG_DIEPINT_BERR_Msk /*!< Babble error interrupt */ -#define USB_OTG_DIEPINT_NAK_Pos (13U) -#define USB_OTG_DIEPINT_NAK_Msk (0x1UL << USB_OTG_DIEPINT_NAK_Pos) /*!< 0x00002000 */ -#define USB_OTG_DIEPINT_NAK USB_OTG_DIEPINT_NAK_Msk /*!< NAK interrupt */ - -/******************** Bit definition for USB_OTG_HCINTMSK register ********************/ -#define USB_OTG_HCINTMSK_XFRCM_Pos (0U) -#define USB_OTG_HCINTMSK_XFRCM_Msk (0x1UL << USB_OTG_HCINTMSK_XFRCM_Pos) /*!< 0x00000001 */ -#define USB_OTG_HCINTMSK_XFRCM USB_OTG_HCINTMSK_XFRCM_Msk /*!< Transfer completed mask */ -#define USB_OTG_HCINTMSK_CHHM_Pos (1U) -#define USB_OTG_HCINTMSK_CHHM_Msk (0x1UL << USB_OTG_HCINTMSK_CHHM_Pos) /*!< 0x00000002 */ -#define USB_OTG_HCINTMSK_CHHM USB_OTG_HCINTMSK_CHHM_Msk /*!< Channel halted mask */ -#define USB_OTG_HCINTMSK_AHBERR_Pos (2U) -#define USB_OTG_HCINTMSK_AHBERR_Msk (0x1UL << USB_OTG_HCINTMSK_AHBERR_Pos) /*!< 0x00000004 */ -#define USB_OTG_HCINTMSK_AHBERR USB_OTG_HCINTMSK_AHBERR_Msk /*!< AHB error */ -#define USB_OTG_HCINTMSK_STALLM_Pos (3U) -#define USB_OTG_HCINTMSK_STALLM_Msk (0x1UL << USB_OTG_HCINTMSK_STALLM_Pos) /*!< 0x00000008 */ -#define USB_OTG_HCINTMSK_STALLM USB_OTG_HCINTMSK_STALLM_Msk /*!< STALL response received interrupt mask */ -#define USB_OTG_HCINTMSK_NAKM_Pos (4U) -#define USB_OTG_HCINTMSK_NAKM_Msk (0x1UL << USB_OTG_HCINTMSK_NAKM_Pos) /*!< 0x00000010 */ -#define USB_OTG_HCINTMSK_NAKM USB_OTG_HCINTMSK_NAKM_Msk /*!< NAK response received interrupt mask */ -#define USB_OTG_HCINTMSK_ACKM_Pos (5U) -#define USB_OTG_HCINTMSK_ACKM_Msk (0x1UL << USB_OTG_HCINTMSK_ACKM_Pos) /*!< 0x00000020 */ -#define USB_OTG_HCINTMSK_ACKM USB_OTG_HCINTMSK_ACKM_Msk /*!< ACK response received/transmitted interrupt mask */ -#define USB_OTG_HCINTMSK_NYET_Pos (6U) -#define USB_OTG_HCINTMSK_NYET_Msk (0x1UL << USB_OTG_HCINTMSK_NYET_Pos) /*!< 0x00000040 */ -#define USB_OTG_HCINTMSK_NYET USB_OTG_HCINTMSK_NYET_Msk /*!< response received interrupt mask */ -#define USB_OTG_HCINTMSK_TXERRM_Pos (7U) -#define USB_OTG_HCINTMSK_TXERRM_Msk (0x1UL << USB_OTG_HCINTMSK_TXERRM_Pos) /*!< 0x00000080 */ -#define USB_OTG_HCINTMSK_TXERRM USB_OTG_HCINTMSK_TXERRM_Msk /*!< Transaction error mask */ -#define USB_OTG_HCINTMSK_BBERRM_Pos (8U) -#define USB_OTG_HCINTMSK_BBERRM_Msk (0x1UL << USB_OTG_HCINTMSK_BBERRM_Pos) /*!< 0x00000100 */ -#define USB_OTG_HCINTMSK_BBERRM USB_OTG_HCINTMSK_BBERRM_Msk /*!< Babble error mask */ -#define USB_OTG_HCINTMSK_FRMORM_Pos (9U) -#define USB_OTG_HCINTMSK_FRMORM_Msk (0x1UL << USB_OTG_HCINTMSK_FRMORM_Pos) /*!< 0x00000200 */ -#define USB_OTG_HCINTMSK_FRMORM USB_OTG_HCINTMSK_FRMORM_Msk /*!< Frame overrun mask */ -#define USB_OTG_HCINTMSK_DTERRM_Pos (10U) -#define USB_OTG_HCINTMSK_DTERRM_Msk (0x1UL << USB_OTG_HCINTMSK_DTERRM_Pos) /*!< 0x00000400 */ -#define USB_OTG_HCINTMSK_DTERRM USB_OTG_HCINTMSK_DTERRM_Msk /*!< Data toggle error mask */ - -/******************** Bit definition for USB_OTG_DIEPTSIZ register ********************/ - -#define USB_OTG_DIEPTSIZ_XFRSIZ_Pos (0U) -#define USB_OTG_DIEPTSIZ_XFRSIZ_Msk (0x7FFFFUL << USB_OTG_DIEPTSIZ_XFRSIZ_Pos) /*!< 0x0007FFFF */ -#define USB_OTG_DIEPTSIZ_XFRSIZ USB_OTG_DIEPTSIZ_XFRSIZ_Msk /*!< Transfer size */ -#define USB_OTG_DIEPTSIZ_PKTCNT_Pos (19U) -#define USB_OTG_DIEPTSIZ_PKTCNT_Msk (0x3FFUL << USB_OTG_DIEPTSIZ_PKTCNT_Pos) /*!< 0x1FF80000 */ -#define USB_OTG_DIEPTSIZ_PKTCNT USB_OTG_DIEPTSIZ_PKTCNT_Msk /*!< Packet count */ -#define USB_OTG_DIEPTSIZ_MULCNT_Pos (29U) -#define USB_OTG_DIEPTSIZ_MULCNT_Msk (0x3UL << USB_OTG_DIEPTSIZ_MULCNT_Pos) /*!< 0x60000000 */ -#define USB_OTG_DIEPTSIZ_MULCNT USB_OTG_DIEPTSIZ_MULCNT_Msk /*!< Packet count */ -/******************** Bit definition for USB_OTG_HCTSIZ register ********************/ -#define USB_OTG_HCTSIZ_XFRSIZ_Pos (0U) -#define USB_OTG_HCTSIZ_XFRSIZ_Msk (0x7FFFFUL << USB_OTG_HCTSIZ_XFRSIZ_Pos) /*!< 0x0007FFFF */ -#define USB_OTG_HCTSIZ_XFRSIZ USB_OTG_HCTSIZ_XFRSIZ_Msk /*!< Transfer size */ -#define USB_OTG_HCTSIZ_PKTCNT_Pos (19U) -#define USB_OTG_HCTSIZ_PKTCNT_Msk (0x3FFUL << USB_OTG_HCTSIZ_PKTCNT_Pos) /*!< 0x1FF80000 */ -#define USB_OTG_HCTSIZ_PKTCNT USB_OTG_HCTSIZ_PKTCNT_Msk /*!< Packet count */ -#define USB_OTG_HCTSIZ_DOPING_Pos (31U) -#define USB_OTG_HCTSIZ_DOPING_Msk (0x1UL << USB_OTG_HCTSIZ_DOPING_Pos) /*!< 0x80000000 */ -#define USB_OTG_HCTSIZ_DOPING USB_OTG_HCTSIZ_DOPING_Msk /*!< Do PING */ -#define USB_OTG_HCTSIZ_DPID_Pos (29U) -#define USB_OTG_HCTSIZ_DPID_Msk (0x3UL << USB_OTG_HCTSIZ_DPID_Pos) /*!< 0x60000000 */ -#define USB_OTG_HCTSIZ_DPID USB_OTG_HCTSIZ_DPID_Msk /*!< Data PID */ -#define USB_OTG_HCTSIZ_DPID_0 (0x1UL << USB_OTG_HCTSIZ_DPID_Pos) /*!< 0x20000000 */ -#define USB_OTG_HCTSIZ_DPID_1 (0x2UL << USB_OTG_HCTSIZ_DPID_Pos) /*!< 0x40000000 */ - -/******************** Bit definition for USB_OTG_DIEPDMA register ********************/ -#define USB_OTG_DIEPDMA_DMAADDR_Pos (0U) -#define USB_OTG_DIEPDMA_DMAADDR_Msk (0xFFFFFFFFUL << USB_OTG_DIEPDMA_DMAADDR_Pos) /*!< 0xFFFFFFFF */ -#define USB_OTG_DIEPDMA_DMAADDR USB_OTG_DIEPDMA_DMAADDR_Msk /*!< DMA address */ - -/******************** Bit definition for USB_OTG_HCDMA register ********************/ -#define USB_OTG_HCDMA_DMAADDR_Pos (0U) -#define USB_OTG_HCDMA_DMAADDR_Msk (0xFFFFFFFFUL << USB_OTG_HCDMA_DMAADDR_Pos) /*!< 0xFFFFFFFF */ -#define USB_OTG_HCDMA_DMAADDR USB_OTG_HCDMA_DMAADDR_Msk /*!< DMA address */ - -/******************** Bit definition for USB_OTG_DTXFSTS register ********************/ -#define USB_OTG_DTXFSTS_INEPTFSAV_Pos (0U) -#define USB_OTG_DTXFSTS_INEPTFSAV_Msk (0xFFFFUL << USB_OTG_DTXFSTS_INEPTFSAV_Pos) /*!< 0x0000FFFF */ -#define USB_OTG_DTXFSTS_INEPTFSAV USB_OTG_DTXFSTS_INEPTFSAV_Msk /*!< IN endpoint TxFIFO space available */ - -/******************** Bit definition for USB_OTG_DIEPTXF register ********************/ -#define USB_OTG_DIEPTXF_INEPTXSA_Pos (0U) -#define USB_OTG_DIEPTXF_INEPTXSA_Msk (0xFFFFUL << USB_OTG_DIEPTXF_INEPTXSA_Pos) /*!< 0x0000FFFF */ -#define USB_OTG_DIEPTXF_INEPTXSA USB_OTG_DIEPTXF_INEPTXSA_Msk /*!< IN endpoint FIFOx transmit RAM start address */ -#define USB_OTG_DIEPTXF_INEPTXFD_Pos (16U) -#define USB_OTG_DIEPTXF_INEPTXFD_Msk (0xFFFFUL << USB_OTG_DIEPTXF_INEPTXFD_Pos) /*!< 0xFFFF0000 */ -#define USB_OTG_DIEPTXF_INEPTXFD USB_OTG_DIEPTXF_INEPTXFD_Msk /*!< IN endpoint TxFIFO depth */ - -/******************** Bit definition for USB_OTG_DOEPCTL register ********************/ - -#define USB_OTG_DOEPCTL_MPSIZ_Pos (0U) -#define USB_OTG_DOEPCTL_MPSIZ_Msk (0x7FFUL << USB_OTG_DOEPCTL_MPSIZ_Pos) /*!< 0x000007FF */ -#define USB_OTG_DOEPCTL_MPSIZ USB_OTG_DOEPCTL_MPSIZ_Msk /*!< Maximum packet size */ /*!buffer_control; } -static inline void _hw_endpoint_buffer_control_set_value32(struct hw_endpoint *ep, uint32_t value) { + +TU_ATTR_ALWAYS_INLINE static inline void _hw_endpoint_buffer_control_set_value32(struct hw_endpoint *ep, uint32_t value) { return _hw_endpoint_buffer_control_update32(ep, 0, value); } -static inline void _hw_endpoint_buffer_control_set_mask32(struct hw_endpoint *ep, uint32_t value) { + +TU_ATTR_ALWAYS_INLINE static inline void _hw_endpoint_buffer_control_set_mask32(struct hw_endpoint *ep, uint32_t value) { return _hw_endpoint_buffer_control_update32(ep, ~value, value); } -static inline void _hw_endpoint_buffer_control_clear_mask32(struct hw_endpoint *ep, uint32_t value) { + +TU_ATTR_ALWAYS_INLINE static inline void _hw_endpoint_buffer_control_clear_mask32(struct hw_endpoint *ep, uint32_t value) { return _hw_endpoint_buffer_control_update32(ep, ~value, 0); } diff --git a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_bcm.h b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_bcm.h index 14194e7548f..732d96ae09c 100644 --- a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_bcm.h +++ b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_bcm.h @@ -35,9 +35,12 @@ #include "broadcom/interrupts.h" #include "broadcom/caches.h" -#define DWC2_REG_BASE USB_OTG_GLOBAL_BASE #define DWC2_EP_MAX 8 -#define DWC2_EP_FIFO_SIZE 4096 + +static const dwc2_controller_t _dwc2_controller[] = +{ + { .reg_base = USB_OTG_GLOBAL_BASE, .irqnum = USB_IRQn, .ep_count = DWC2_EP_MAX, .ep_fifo_size = 4096 } +}; #define dcache_clean(_addr, _size) data_clean(_addr, _size) #define dcache_invalidate(_addr, _size) data_invalidate(_addr, _size) @@ -46,15 +49,13 @@ TU_ATTR_ALWAYS_INLINE static inline void dwc2_dcd_int_enable(uint8_t rhport) { - (void) rhport; - BP_EnableIRQ(USB_IRQn); + BP_EnableIRQ(_dwc2_controller[rhport].irqnum); } TU_ATTR_ALWAYS_INLINE static inline void dwc2_dcd_int_disable (uint8_t rhport) { - (void) rhport; - BP_DisableIRQ(USB_IRQn); + BP_DisableIRQ(_dwc2_controller[rhport].irqnum); } static inline void dwc2_remote_wakeup_delay(void) diff --git a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_efm32.h b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_efm32.h index ee4c3c71565..0e3570cbb18 100644 --- a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_efm32.h +++ b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_efm32.h @@ -37,20 +37,22 @@ // EFM32 has custom control register before DWC registers #define DWC2_REG_BASE (USB_BASE + offsetof(USB_TypeDef, GOTGCTL)) #define DWC2_EP_MAX 7 -#define DWC2_EP_FIFO_SIZE 2048 + +static const dwc2_controller_t _dwc2_controller[] = +{ + { .reg_base = DWC2_REG_BASE, .irqnum = USB_IRQn, .ep_count = DWC2_EP_MAX, .ep_fifo_size = 2048 } +}; TU_ATTR_ALWAYS_INLINE static inline void dwc2_dcd_int_enable(uint8_t rhport) { - (void) rhport; - NVIC_EnableIRQ(USB_IRQn); + NVIC_EnableIRQ(_dwc2_controller[rhport].irqnum); } TU_ATTR_ALWAYS_INLINE static inline void dwc2_dcd_int_disable (uint8_t rhport) { - (void) rhport; - NVIC_DisableIRQ(USB_IRQn); + NVIC_DisableIRQ(_dwc2_controller[rhport].irqnum); } static inline void dwc2_remote_wakeup_delay(void) diff --git a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_esp32.h b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_esp32.h index 78da277d5fc..c50dd66b89a 100644 --- a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_esp32.h +++ b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_esp32.h @@ -37,10 +37,12 @@ //#include "soc/usb_periph.h" #define DWC2_REG_BASE 0x60080000UL -#define DWC2_EP_MAX 5 // USB_OUT_EP_NUM -#define DWC2_EP_FIFO_SIZE 1024 +#define DWC2_EP_MAX 6 // USB_OUT_EP_NUM. TODO ESP32Sx only has 5 tx fifo (5 endpoint IN) -// #define EP_FIFO_NUM 5 +static const dwc2_controller_t _dwc2_controller[] = +{ + { .reg_base = DWC2_REG_BASE, .irqnum = 0, .ep_count = DWC2_EP_MAX, .ep_fifo_size = 1024 } +}; static intr_handle_t usb_ih; diff --git a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_gd32.h b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_gd32.h index f8fa01ee0ad..0375fffe4e5 100644 --- a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_gd32.h +++ b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_gd32.h @@ -34,8 +34,11 @@ #define DWC2_REG_BASE 0x50000000UL #define DWC2_EP_MAX 4 -#define DWC2_EP_FIFO_SIZE 1280 -#define RHPORT_IRQn 86 + +static const dwc2_controller_t _dwc2_controller[] = +{ + { .reg_base = DWC2_REG_BASE, .irqnum = 86, .ep_count = DWC2_EP_MAX, .ep_fifo_size = 1280 } +}; extern uint32_t SystemCoreClock; @@ -57,15 +60,13 @@ static inline void __eclic_disable_interrupt (uint32_t irq){ TU_ATTR_ALWAYS_INLINE static inline void dwc2_dcd_int_enable(uint8_t rhport) { - (void) rhport; - __eclic_enable_interrupt(RHPORT_IRQn); + __eclic_enable_interrupt(_dwc2_controller[rhport].irqnum); } TU_ATTR_ALWAYS_INLINE static inline void dwc2_dcd_int_disable (uint8_t rhport) { - (void) rhport; - __eclic_disable_interrupt(RHPORT_IRQn); + __eclic_disable_interrupt(_dwc2_controller[rhport].irqnum); } static inline void dwc2_remote_wakeup_delay(void) diff --git a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_stm32.h b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_stm32.h index 469045ac46e..b500ddc465a 100644 --- a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_stm32.h +++ b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_stm32.h @@ -47,6 +47,7 @@ #include "stm32f4xx.h" #define EP_MAX_FS USB_OTG_FS_MAX_IN_ENDPOINTS #define EP_FIFO_SIZE_FS USB_OTG_FS_TOTAL_FIFO_SIZE + #define EP_MAX_HS USB_OTG_HS_MAX_IN_ENDPOINTS #define EP_FIFO_SIZE_HS USB_OTG_HS_TOTAL_FIFO_SIZE @@ -54,13 +55,18 @@ #include "stm32h7xx.h" #define EP_MAX_FS 9 #define EP_FIFO_SIZE_FS 4096 + #define EP_MAX_HS 9 #define EP_FIFO_SIZE_HS 4096 + // NOTE: H7 with only 1 USB port: H72x / H73x / H7Ax / H7Bx + // USB_OTG_FS_PERIPH_BASE and OTG_FS_IRQn not defined + #elif CFG_TUSB_MCU == OPT_MCU_STM32F7 #include "stm32f7xx.h" #define EP_MAX_FS 6 #define EP_FIFO_SIZE_FS 1280 + #define EP_MAX_HS 9 #define EP_FIFO_SIZE_HS 4096 @@ -73,35 +79,42 @@ #error "Unsupported MCUs" #endif -// On STM32 we associate Port0 to OTG_FS, and Port1 to OTG_HS -#if TUD_OPT_RHPORT == 0 - #define DWC2_REG_BASE USB_OTG_FS_PERIPH_BASE - #define DWC2_EP_MAX EP_MAX_FS - #define DWC2_EP_FIFO_SIZE EP_FIFO_SIZE_FS - #define RHPORT_IRQn OTG_FS_IRQn - +// OTG HS always has higher number of endpoints than FS +#ifdef USB_OTG_HS_PERIPH_BASE + #define DWC2_EP_MAX EP_MAX_HS #else - #define DWC2_REG_BASE USB_OTG_HS_PERIPH_BASE - #define DWC2_EP_MAX EP_MAX_HS - #define DWC2_EP_FIFO_SIZE EP_FIFO_SIZE_HS - #define RHPORT_IRQn OTG_HS_IRQn + #define DWC2_EP_MAX EP_MAX_FS +#endif +// On STM32 for consistency we associate +// - Port0 to OTG_FS, and Port1 to OTG_HS +static const dwc2_controller_t _dwc2_controller[] = +{ +#ifdef USB_OTG_FS_PERIPH_BASE + { .reg_base = USB_OTG_FS_PERIPH_BASE, .irqnum = OTG_FS_IRQn, .ep_count = EP_MAX_FS, .ep_fifo_size = EP_FIFO_SIZE_FS }, #endif +#ifdef USB_OTG_HS_PERIPH_BASE + { .reg_base = USB_OTG_HS_PERIPH_BASE, .irqnum = OTG_HS_IRQn, .ep_count = EP_MAX_HS, .ep_fifo_size = EP_FIFO_SIZE_HS }, +#endif +}; + +//--------------------------------------------------------------------+ +// +//--------------------------------------------------------------------+ + extern uint32_t SystemCoreClock; TU_ATTR_ALWAYS_INLINE static inline void dwc2_dcd_int_enable(uint8_t rhport) { - (void) rhport; - NVIC_EnableIRQ(RHPORT_IRQn); + NVIC_EnableIRQ(_dwc2_controller[rhport].irqnum); } TU_ATTR_ALWAYS_INLINE static inline void dwc2_dcd_int_disable (uint8_t rhport) { - (void) rhport; - NVIC_DisableIRQ(RHPORT_IRQn); + NVIC_DisableIRQ(_dwc2_controller[rhport].irqnum); } TU_ATTR_ALWAYS_INLINE diff --git a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_type.h b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_type.h index 7fa2028eb93..3fc979337db 100644 --- a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_type.h +++ b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_type.h @@ -19,6 +19,19 @@ #include "stdint.h" +#ifdef __cplusplus + extern "C" { +#endif + +// Controller +typedef struct +{ + uintptr_t reg_base; + uint32_t irqnum; + uint8_t ep_count; + uint32_t ep_fifo_size; +}dwc2_controller_t; + /* DWC OTG HW Release versions */ #define DWC2_CORE_REV_2_71a 0x4f54271a #define DWC2_CORE_REV_2_72a 0x4f54272a @@ -40,10 +53,6 @@ #define DWC2_FS_IOT_ID 0x55310000 #define DWC2_HS_IOT_ID 0x55320000 -#ifdef __cplusplus - extern "C" { -#endif - #if 0 // HS PHY typedef struct diff --git a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_xmc.h b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_xmc.h index 4e6bebb0167..63419abf798 100644 --- a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_xmc.h +++ b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/portable/synopsys/dwc2/dwc2_xmc.h @@ -34,23 +34,24 @@ #include "xmc_device.h" -// XMC has custom control register before DWC registers -#define DWC2_REG_BASE USB0_BASE #define DWC2_EP_MAX 7 -#define DWC2_EP_FIFO_SIZE 2048 + +static const dwc2_controller_t _dwc2_controller[] = +{ + // Note: XMC has some custom control registers before DWC registers + { .reg_base = USB0_BASE, .irqnum = USB0_0_IRQn, .ep_count = DWC2_EP_MAX, .ep_fifo_size = 2048 } +}; TU_ATTR_ALWAYS_INLINE static inline void dwc2_dcd_int_enable(uint8_t rhport) { - (void) rhport; - NVIC_EnableIRQ(USB0_0_IRQn); + NVIC_EnableIRQ(_dwc2_controller[rhport].irqnum); } TU_ATTR_ALWAYS_INLINE static inline void dwc2_dcd_int_disable (uint8_t rhport) { - (void) rhport; - NVIC_DisableIRQ(USB0_0_IRQn); + NVIC_DisableIRQ(_dwc2_controller[rhport].irqnum); } static inline void dwc2_remote_wakeup_delay(void) diff --git a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/tusb_option.h b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/tusb_option.h index bd87a953c47..206d23e72cc 100644 --- a/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/tusb_option.h +++ b/tools/sdk/esp32s3/include/arduino_tinyusb/tinyusb/src/tusb_option.h @@ -27,6 +27,9 @@ #ifndef _TUSB_OPTION_H_ #define _TUSB_OPTION_H_ +// To avoid GCC compiler warnings when -pedantic option is used (strict ISO C) +typedef int make_iso_compilers_happy; + #include "common/tusb_compiler.h" #define TUSB_VERSION_MAJOR 0 @@ -192,60 +195,63 @@ #define OPT_MODE_HIGH_SPEED 0x0400 ///< High Speed #define OPT_MODE_SPEED_MASK 0xff00 -#ifndef CFG_TUSB_RHPORT0_MODE - #define CFG_TUSB_RHPORT0_MODE OPT_MODE_NONE -#endif - -#ifndef CFG_TUSB_RHPORT1_MODE - #define CFG_TUSB_RHPORT1_MODE OPT_MODE_NONE -#endif - -#if (((CFG_TUSB_RHPORT0_MODE) & OPT_MODE_HOST ) && ((CFG_TUSB_RHPORT1_MODE) & OPT_MODE_HOST )) || \ - (((CFG_TUSB_RHPORT0_MODE) & OPT_MODE_DEVICE) && ((CFG_TUSB_RHPORT1_MODE) & OPT_MODE_DEVICE)) - #error "TinyUSB currently does not support same modes on more than 1 roothub port" -#endif - //------------- Roothub as Device -------------// -#if (CFG_TUSB_RHPORT0_MODE) & OPT_MODE_DEVICE +#if defined(CFG_TUSB_RHPORT0_MODE) && ((CFG_TUSB_RHPORT0_MODE) & OPT_MODE_DEVICE) #define TUD_RHPORT_MODE (CFG_TUSB_RHPORT0_MODE) #define TUD_OPT_RHPORT 0 -#elif (CFG_TUSB_RHPORT1_MODE) & OPT_MODE_DEVICE +#elif defined(CFG_TUSB_RHPORT1_MODE) && ((CFG_TUSB_RHPORT1_MODE) & OPT_MODE_DEVICE) #define TUD_RHPORT_MODE (CFG_TUSB_RHPORT1_MODE) #define TUD_OPT_RHPORT 1 #else #define TUD_RHPORT_MODE OPT_MODE_NONE - #define TUD_OPT_RHPORT -1 #endif -#define CFG_TUD_ENABLED (TUD_RHPORT_MODE & OPT_MODE_DEVICE) +#ifndef CFG_TUD_ENABLED + // fallback to use CFG_TUSB_RHPORTx_MODE + #define CFG_TUD_ENABLED (TUD_RHPORT_MODE & OPT_MODE_DEVICE) +#endif -#if CFG_TUD_ENABLED - #define TUD_OPT_HIGH_SPEED ((TUD_RHPORT_MODE & OPT_MODE_SPEED_MASK) ? (TUD_RHPORT_MODE & OPT_MODE_HIGH_SPEED) : (TUP_RHPORT_HIGHSPEED & (1 << TUD_OPT_RHPORT))) -#else - #define TUD_OPT_HIGH_SPEED 0 +#ifndef CFG_TUD_MAX_SPEED + // fallback to use CFG_TUSB_RHPORTx_MODE + #define CFG_TUD_MAX_SPEED (TUD_RHPORT_MODE & OPT_MODE_SPEED_MASK) #endif +// For backward compatible +#define TUSB_OPT_DEVICE_ENABLED CFG_TUD_ENABLED + +// highspeed support indicator +#define TUD_OPT_HIGH_SPEED (CFG_TUD_MAX_SPEED ? CFG_TUD_MAX_SPEED : TUP_RHPORT_HIGHSPEED) + //------------- Roothub as Host -------------// -#if (CFG_TUSB_RHPORT0_MODE) & OPT_MODE_HOST +#if defined(CFG_TUSB_RHPORT0_MODE) && ((CFG_TUSB_RHPORT0_MODE) & OPT_MODE_HOST) #define TUH_RHPORT_MODE (CFG_TUSB_RHPORT0_MODE) #define TUH_OPT_RHPORT 0 -#elif (CFG_TUSB_RHPORT1_MODE) & OPT_MODE_HOST +#elif defined(CFG_TUSB_RHPORT1_MODE) && ((CFG_TUSB_RHPORT1_MODE) & OPT_MODE_HOST) #define TUH_RHPORT_MODE (CFG_TUSB_RHPORT1_MODE) #define TUH_OPT_RHPORT 1 #else #define TUH_RHPORT_MODE OPT_MODE_NONE - #define TUH_OPT_RHPORT -1 #endif -#define CFG_TUH_ENABLED ( TUH_RHPORT_MODE & OPT_MODE_HOST ) +#ifndef CFG_TUH_ENABLED + // fallback to use CFG_TUSB_RHPORTx_MODE + #define CFG_TUH_ENABLED (TUH_RHPORT_MODE & OPT_MODE_HOST) +#endif + +#ifndef CFG_TUH_MAX_SPEED + // fallback to use CFG_TUSB_RHPORTx_MODE + #define CFG_TUH_MAX_SPEED (TUH_RHPORT_MODE & OPT_MODE_SPEED_MASK) +#endif // For backward compatible -#define TUSB_OPT_DEVICE_ENABLED CFG_TUD_ENABLED #define TUSB_OPT_HOST_ENABLED CFG_TUH_ENABLED +//--------------------------------------------------------------------+ // TODO move later +//--------------------------------------------------------------------+ + // TUP_MCU_STRICT_ALIGN will overwrite TUP_ARCH_STRICT_ALIGN. // In case TUP_MCU_STRICT_ALIGN = 1 and TUP_ARCH_STRICT_ALIGN =0, we will not reply on compiler // to generate unaligned access code. @@ -258,7 +264,7 @@ //--------------------------------------------------------------------+ -// COMMON OPTIONS +// Common Options (Default) //--------------------------------------------------------------------+ // Debug enable to print out error message @@ -286,16 +292,20 @@ #endif // mutex is only needed for RTOS TODO also required with multiple core MCUs -#define TUSB_OPT_MUTEX (CFG_TUSB_OS != OPT_OS_NONE) +#define TUSB_OPT_MUTEX (CFG_TUSB_OS != OPT_OS_NONE) //-------------------------------------------------------------------- -// DEVICE OPTIONS +// Device Options (Default) //-------------------------------------------------------------------- #ifndef CFG_TUD_ENDPOINT0_SIZE #define CFG_TUD_ENDPOINT0_SIZE 64 #endif +#ifndef CFG_TUD_INTERFACE_MAX + #define CFG_TUD_INTERFACE_MAX 16 +#endif + #ifndef CFG_TUD_CDC #define CFG_TUD_CDC 0 #endif @@ -354,7 +364,7 @@ #endif //-------------------------------------------------------------------- -// HOST OPTIONS +// Host Options (Default) //-------------------------------------------------------------------- #if CFG_TUH_ENABLED #ifndef CFG_TUH_DEVICE_MAX @@ -396,6 +406,16 @@ #define CFG_TUH_API_EDPT_XFER 0 #endif +// Enable PIO-USB software host controller +#ifndef CFG_TUH_RPI_PIO_USB +#define CFG_TUH_RPI_PIO_USB 0 +#endif + +#ifndef CFG_TUD_RPI_PIO_USB +#define CFG_TUD_RPI_PIO_USB 0 +#endif + + //------------------------------------------------------------------ // Configuration Validation //------------------------------------------------------------------ diff --git a/tools/sdk/esp32s3/include/bootloader_support/include/bootloader_flash.h b/tools/sdk/esp32s3/include/bootloader_support/include/bootloader_flash.h index 49e457f372e..90865e234d6 100644 --- a/tools/sdk/esp32s3/include/bootloader_support/include/bootloader_flash.h +++ b/tools/sdk/esp32s3/include/bootloader_support/include/bootloader_flash.h @@ -9,6 +9,7 @@ #include /* including in bootloader for error values */ #include "sdkconfig.h" #include "soc/soc_caps.h" +#include "bootloader_flash_override.h" #ifdef __cplusplus extern "C" { @@ -32,20 +33,21 @@ uint32_t bootloader_read_flash_id(void); esp_err_t bootloader_flash_wrap_set(spi_flash_wrap_mode_t mode); #endif +/** + * @brief Startup flow recommended by XMC. Call at startup before any erase/write operation. + * + * @return ESP_OK When startup successfully, otherwise ESP_FAIL (indiciating you should reboot before erase/write). + */ +esp_err_t bootloader_flash_xmc_startup(void); + /** * @brief Unlock Flash write protect. * Please do not call this function in SDK. * * @note This can be overridden because it's attribute weak. */ -esp_err_t bootloader_flash_unlock(void); +esp_err_t IRAM_ATTR __attribute__((weak)) bootloader_flash_unlock(void); -/** - * @brief Startup flow recommended by XMC. Call at startup before any erase/write operation. - * - * @return ESP_OK When startup successfully, otherwise ESP_FAIL (indiciating you should reboot before erase/write). - */ -esp_err_t bootloader_flash_xmc_startup(void); #ifdef __cplusplus } diff --git a/tools/sdk/esp32s3/include/bootloader_support/include/bootloader_flash_override.h b/tools/sdk/esp32s3/include/bootloader_support/include/bootloader_flash_override.h new file mode 100644 index 00000000000..ae29f004344 --- /dev/null +++ b/tools/sdk/esp32s3/include/bootloader_support/include/bootloader_flash_override.h @@ -0,0 +1,101 @@ +/* + * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#pragma once + +#include "esp_err.h" +#include "esp_attr.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef unsigned (*bootloader_flash_read_status_fn_t)(void); +typedef void (*bootloader_flash_write_status_fn_t)(unsigned); + +typedef struct __attribute__((packed)) +{ + const char *manufacturer; + uint8_t mfg_id; /* 8-bit JEDEC manufacturer ID */ + uint16_t flash_id; /* 16-bit JEDEC flash chip ID */ + uint16_t id_mask; /* Bits to match on in flash chip ID */ + bootloader_flash_read_status_fn_t read_status_fn; + bootloader_flash_write_status_fn_t write_status_fn; + uint8_t status_qio_bit; +} bootloader_qio_info_t; + +/** + * @brief Read 8 bit status using RDSR command + * + * @return Value of SR1. + */ +unsigned bootloader_read_status_8b_rdsr(void); + +/** + * @brief Read 8 bit status (second byte) using RDSR2 command + * + * @return Value of SR2 + */ +unsigned bootloader_read_status_8b_rdsr2(void); + +/** + * @brief Read 16 bit status using RDSR & RDSR2 (low and high bytes) + * + * @return Value of SR2#SR1. + */ +unsigned bootloader_read_status_16b_rdsr_rdsr2(void); + +/** + * @brief Write 8 bit status using WRSR + */ +void bootloader_write_status_8b_wrsr(unsigned new_status); + +/** + * @brief Write 8 bit status (second byte) using WRSR2. + */ +void bootloader_write_status_8b_wrsr2(unsigned new_status); + +/** + * @brief Write 16 bit status using WRSR, (both write SR1 and SR2) + */ +void bootloader_write_status_16b_wrsr(unsigned new_status); + +/** + * @brief Read 8 bit status of XM25QU64A. + * + * @return Value of 8 bit SR. + */ +unsigned bootloader_read_status_8b_xmc25qu64a(void); + +/** + * @brief Write 8 bit status for XM25QU64A + */ +void bootloader_write_status_8b_xmc25qu64a(unsigned new_status); + +/* Array of known flash chips and data to enable Quad I/O mode + + Manufacturer & flash ID can be tested by running "esptool.py + flash_id" + + If manufacturer ID matches, and flash ID ORed with flash ID mask + matches, enable_qio_mode() will execute "Read Cmd", test if bit + number "QIE Bit" is set, and if not set it will call "Write Cmd" + with this bit set. + + Searching of this table stops when the first match is found. + */ +extern const bootloader_qio_info_t __attribute__((weak)) bootloader_flash_qe_support_list[]; + +/** + * @brief Unlock Flash write protect. + * Please do not call this function in SDK. + * + * @note This can be overridden because it's attribute weak. + */ +esp_err_t IRAM_ATTR __attribute__((weak)) bootloader_flash_unlock(void); + +#ifdef __cplusplus +} +#endif diff --git a/tools/sdk/esp32s3/include/bootloader_support/include/esp_app_format.h b/tools/sdk/esp32s3/include/bootloader_support/include/esp_app_format.h index 64744fdfe5a..ef4f7f4f48f 100644 --- a/tools/sdk/esp32s3/include/bootloader_support/include/esp_app_format.h +++ b/tools/sdk/esp32s3/include/bootloader_support/include/esp_app_format.h @@ -55,6 +55,9 @@ typedef enum { ESP_IMAGE_FLASH_SIZE_4MB, /*!< SPI flash size 4 MB */ ESP_IMAGE_FLASH_SIZE_8MB, /*!< SPI flash size 8 MB */ ESP_IMAGE_FLASH_SIZE_16MB, /*!< SPI flash size 16 MB */ + ESP_IMAGE_FLASH_SIZE_32MB, /*!< SPI flash size 32 MB */ + ESP_IMAGE_FLASH_SIZE_64MB, /*!< SPI flash size 64 MB */ + ESP_IMAGE_FLASH_SIZE_128MB, /*!< SPI flash size 128 MB */ ESP_IMAGE_FLASH_SIZE_MAX /*!< SPI flash size MAX */ } esp_image_flash_size_t; diff --git a/tools/sdk/esp32s3/include/bt/host/bluedroid/api/include/api/esp_bt_defs.h b/tools/sdk/esp32s3/include/bt/host/bluedroid/api/include/api/esp_bt_defs.h index 1287404ce35..d0e1ec00950 100644 --- a/tools/sdk/esp32s3/include/bt/host/bluedroid/api/include/api/esp_bt_defs.h +++ b/tools/sdk/esp32s3/include/bt/host/bluedroid/api/include/api/esp_bt_defs.h @@ -68,6 +68,8 @@ typedef uint8_t esp_link_key[ESP_BT_OCTET16_LEN]; /* Link Key */ /// Default GATT interface id #define ESP_DEFAULT_GATT_IF 0xff +#define ESP_BLE_PRIM_ADV_INT_MIN 0x000020 /*!< Minimum advertising interval for undirected and low duty cycle directed advertising */ +#define ESP_BLE_PRIM_ADV_INT_MAX 0xFFFFFF /*!< Maximum advertising interval for undirected and low duty cycle directed advertising */ #define ESP_BLE_CONN_INT_MIN 0x0006 /*!< relate to BTM_BLE_CONN_INT_MIN in stack/btm_ble_api.h */ #define ESP_BLE_CONN_INT_MAX 0x0C80 /*!< relate to BTM_BLE_CONN_INT_MAX in stack/btm_ble_api.h */ #define ESP_BLE_CONN_LATENCY_MAX 499 /*!< relate to ESP_BLE_CONN_LATENCY_MAX in stack/btm_ble_api.h */ diff --git a/tools/sdk/esp32s3/include/bt/host/bluedroid/api/include/api/esp_gap_bt_api.h b/tools/sdk/esp32s3/include/bt/host/bluedroid/api/include/api/esp_gap_bt_api.h index 285cbb028cf..686ad1c63e8 100644 --- a/tools/sdk/esp32s3/include/bt/host/bluedroid/api/include/api/esp_gap_bt_api.h +++ b/tools/sdk/esp32s3/include/bt/host/bluedroid/api/include/api/esp_gap_bt_api.h @@ -347,6 +347,7 @@ typedef union { struct read_rmt_name_param { esp_bt_status_t stat; /*!< read Remote Name status */ uint8_t rmt_name[ESP_BT_GAP_MAX_BDNAME_LEN + 1]; /*!< Remote device name */ + esp_bd_addr_t bda; /*!< remote bluetooth device address*/ } read_rmt_name; /*!< read Remote Name parameter struct */ /** diff --git a/tools/sdk/esp32s3/include/bt/host/bluedroid/api/include/api/esp_gattc_api.h b/tools/sdk/esp32s3/include/bt/host/bluedroid/api/include/api/esp_gattc_api.h index 40719096345..6c32868156f 100644 --- a/tools/sdk/esp32s3/include/bt/host/bluedroid/api/include/api/esp_gattc_api.h +++ b/tools/sdk/esp32s3/include/bt/host/bluedroid/api/include/api/esp_gattc_api.h @@ -220,6 +220,7 @@ typedef union { struct gattc_disconnect_evt_param { esp_gatt_conn_reason_t reason; /*!< disconnection reason */ uint16_t conn_id; /*!< Connection id */ + uint8_t link_role; /*!< Link role : master role = 0 ; slave role = 1*/ esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */ } disconnect; /*!< Gatt client callback param of ESP_GATTC_DISCONNECT_EVT */ /** diff --git a/tools/sdk/esp32s3/include/bt/host/bluedroid/api/include/api/esp_gatts_api.h b/tools/sdk/esp32s3/include/bt/host/bluedroid/api/include/api/esp_gatts_api.h index 475ae08c553..558d5d62960 100644 --- a/tools/sdk/esp32s3/include/bt/host/bluedroid/api/include/api/esp_gatts_api.h +++ b/tools/sdk/esp32s3/include/bt/host/bluedroid/api/include/api/esp_gatts_api.h @@ -206,6 +206,7 @@ typedef union { */ struct gatts_disconnect_evt_param { uint16_t conn_id; /*!< Connection id */ + uint8_t link_role; /*!< Link role : master role = 0 ; slave role = 1*/ esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */ esp_gatt_conn_reason_t reason; /*!< Indicate the reason of disconnection */ } disconnect; /*!< Gatt server callback param of ESP_GATTS_DISCONNECT_EVT */ diff --git a/tools/sdk/esp32s3/include/bt/include/esp32s3/include/esp_bt.h b/tools/sdk/esp32s3/include/bt/include/esp32s3/include/esp_bt.h index efdc6ee63af..2172796eb5b 100644 --- a/tools/sdk/esp32s3/include/bt/include/esp32s3/include/esp_bt.h +++ b/tools/sdk/esp32s3/include/bt/include/esp32s3/include/esp_bt.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -162,7 +162,9 @@ typedef void (* esp_bt_hci_tl_callback_t) (void *arg, uint8_t status); .ble_st_acl_tx_buf_nb = CONFIG_BT_CTRL_BLE_STATIC_ACL_TX_BUF_NB, \ .ble_hw_cca_check = CONFIG_BT_CTRL_HW_CCA_EFF, \ .ble_adv_dup_filt_max = CONFIG_BT_CTRL_ADV_DUP_FILT_MAX, \ + .coex_param_en = false, \ .ce_len_type = CONFIG_BT_CTRL_CE_LENGTH_TYPE_EFF, \ + .coex_use_hooks = false, \ .hci_tl_type = CONFIG_BT_CTRL_HCI_TL_EFF, \ .hci_tl_funcs = NULL, \ .txant_dft = CONFIG_BT_CTRL_TX_ANTENNA_INDEX_EFF, \ diff --git a/tools/sdk/esp32s3/include/coap/port/include/coap_config_posix.h b/tools/sdk/esp32s3/include/coap/port/include/coap_config_posix.h index b24335ad156..f96faea7665 100644 --- a/tools/sdk/esp32s3/include/coap/port/include/coap_config_posix.h +++ b/tools/sdk/esp32s3/include/coap/port/include/coap_config_posix.h @@ -30,6 +30,8 @@ #define HAVE_NETDB_H #define HAVE_NETINET_IN_H #define HAVE_STRUCT_CMSGHDR +#define HAVE_PTHREAD_H +#define HAVE_PTHREAD_MUTEX_LOCK #define COAP_DISABLE_TCP 0 #define ipi_spec_dst ipi_addr diff --git a/tools/sdk/esp32s3/include/driver/include/driver/gpio.h b/tools/sdk/esp32s3/include/driver/include/driver/gpio.h index eeb63f74f8e..77bb2dd78c0 100644 --- a/tools/sdk/esp32s3/include/driver/include/driver/gpio.h +++ b/tools/sdk/esp32s3/include/driver/include/driver/gpio.h @@ -97,7 +97,7 @@ esp_err_t gpio_set_intr_type(gpio_num_t gpio_num, gpio_int_type_t intr_type); /** * @brief Enable GPIO module interrupt signal * - * @note Please do not use the interrupt of GPIO36 and GPIO39 when using ADC or Wi-Fi with sleep mode enabled. + * @note Please do not use the interrupt of GPIO36 and GPIO39 when using ADC or Wi-Fi and Bluetooth with sleep mode enabled. * Please refer to the comments of `adc1_get_raw`. * Please refer to section 3.11 of 'ECO_and_Workarounds_for_Bugs_in_ESP32' for the description of this issue. * As a workaround, call adc_power_acquire() in the app. This will result in higher power consumption (by ~1mA), @@ -498,7 +498,8 @@ esp_err_t gpio_sleep_set_pull_mode(gpio_num_t gpio_num, gpio_pull_mode_t pull); #if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP -#define GPIO_IS_DEEP_SLEEP_WAKEUP_VALID_GPIO(gpio_num) ((gpio_num & ~SOC_GPIO_DEEP_SLEEP_WAKEUP_VALID_GPIO_MASK) == 0) +#define GPIO_IS_DEEP_SLEEP_WAKEUP_VALID_GPIO(gpio_num) ((gpio_num >= 0) && \ + (((1ULL << (gpio_num)) & SOC_GPIO_DEEP_SLEEP_WAKEUP_VALID_GPIO_MASK) != 0)) /** * @brief Enable GPIO deep-sleep wake-up function. diff --git a/tools/sdk/esp32s3/include/driver/include/driver/i2c.h b/tools/sdk/esp32s3/include/driver/include/driver/i2c.h index 22dcc8ab241..57d9091e70a 100644 --- a/tools/sdk/esp32s3/include/driver/include/driver/i2c.h +++ b/tools/sdk/esp32s3/include/driver/include/driver/i2c.h @@ -429,8 +429,7 @@ esp_err_t i2c_master_stop(i2c_cmd_handle_t cmd_handle); /** * @brief Send all the queued commands on the I2C bus, in master mode. * The task will be blocked until all the commands have been sent out. - * The I2C APIs are not thread-safe, if you want to use one I2C port in different tasks, - * you need to take care of the multi-thread issue. + * The I2C port is protected by mutex, so this function is thread-safe. * This function shall only be called in I2C master mode. * * @param i2c_num I2C port number diff --git a/tools/sdk/esp32s3/include/driver/include/driver/sdspi_host.h b/tools/sdk/esp32s3/include/driver/include/driver/sdspi_host.h index abb690c39bc..a5d942e9d86 100644 --- a/tools/sdk/esp32s3/include/driver/include/driver/sdspi_host.h +++ b/tools/sdk/esp32s3/include/driver/include/driver/sdspi_host.h @@ -22,8 +22,10 @@ typedef int sdspi_dev_handle_t; #if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2 #define SDSPI_DEFAULT_HOST HSPI_HOST +#define SDSPI_DEFAULT_DMA SDSPI_DEFAULT_HOST #else #define SDSPI_DEFAULT_HOST SPI2_HOST +#define SDSPI_DEFAULT_DMA SPI_DMA_CH_AUTO #endif /** @@ -216,7 +218,7 @@ typedef struct { .gpio_miso = GPIO_NUM_2, \ .gpio_mosi = GPIO_NUM_15, \ .gpio_sck = GPIO_NUM_14, \ - .dma_channel = 1, \ + .dma_channel = SDSPI_DEFAULT_DMA, \ } /** diff --git a/tools/sdk/esp32s3/include/driver/include/driver/spi_common.h b/tools/sdk/esp32s3/include/driver/include/driver/spi_common.h index 830b8efd8c2..424e9c0588f 100644 --- a/tools/sdk/esp32s3/include/driver/include/driver/spi_common.h +++ b/tools/sdk/esp32s3/include/driver/include/driver/spi_common.h @@ -163,7 +163,7 @@ esp_err_t spi_bus_initialize(spi_host_device_t host_id, const spi_bus_config_t * * @param host_id SPI peripheral to free * @return * - ESP_ERR_INVALID_ARG if parameter is invalid - * - ESP_ERR_INVALID_STATE if not all devices on the bus are freed + * - ESP_ERR_INVALID_STATE if bus hasn't been initialized before, or not all devices on the bus are freed * - ESP_OK on success */ esp_err_t spi_bus_free(spi_host_device_t host_id); diff --git a/tools/sdk/esp32s3/include/driver/include/esp_private/gdma.h b/tools/sdk/esp32s3/include/driver/include/esp_private/gdma.h index 88a45b56cfe..f888cd5bc9b 100644 --- a/tools/sdk/esp32s3/include/driver/include/esp_private/gdma.h +++ b/tools/sdk/esp32s3/include/driver/include/esp_private/gdma.h @@ -269,6 +269,9 @@ esp_err_t gdma_register_rx_event_callbacks(gdma_channel_handle_t dma_chan, gdma_ /** * @brief Set DMA descriptor address and start engine * + * @note This function is allowed to run within ISR context + * @note This function is also allowed to run when Cache is disabled, if `CONFIG_GDMA_CTRL_FUNC_IN_IRAM` is enabled + * * @param[in] dma_chan GDMA channel handle, allocated by `gdma_new_channel` * @param[in] desc_base_addr Base address of descriptors (usually the descriptors are chained into a link or ring) * @return @@ -281,6 +284,9 @@ esp_err_t gdma_start(gdma_channel_handle_t dma_chan, intptr_t desc_base_addr); /** * @brief Stop DMA engine * + * @note This function is allowed to run within ISR context + * @note This function is also allowed to run when Cache is disabled, if `CONFIG_GDMA_CTRL_FUNC_IN_IRAM` is enabled + * * @param[in] dma_chan GDMA channel handle, allocated by `gdma_new_channel` * @return * - ESP_OK: Stop DMA engine successfully @@ -291,6 +297,9 @@ esp_err_t gdma_stop(gdma_channel_handle_t dma_chan); /** * @brief Make the appended descriptors be aware to the DMA engine + * + * @note This function is allowed to run within ISR context + * @note This function is also allowed to run when Cache is disabled, if `CONFIG_GDMA_CTRL_FUNC_IN_IRAM` is enabled * @note This API could also resume a paused DMA engine, make sure new descriptors have been appended to the descriptor chain before calling it. * * @param[in] dma_chan GDMA channel handle, allocated by `gdma_new_channel` @@ -303,6 +312,9 @@ esp_err_t gdma_append(gdma_channel_handle_t dma_chan); /** * @brief Reset DMA channel FIFO and internal finite state machine + * + * @note This function is allowed to run within ISR context + * @note This function is also allowed to run when Cache is disabled, if `CONFIG_GDMA_CTRL_FUNC_IN_IRAM` is enabled * @note Resetting a DMA channel won't break the connection with the target peripheral * * @param[in] dma_chan GDMA channel handle, allocated by `gdma_new_channel` diff --git a/tools/sdk/esp32s3/include/efuse/esp32s3/include/esp_efuse_table.h b/tools/sdk/esp32s3/include/efuse/esp32s3/include/esp_efuse_table.h index 3618ae3ddab..b81d10f18b8 100644 --- a/tools/sdk/esp32s3/include/efuse/esp32s3/include/esp_efuse_table.h +++ b/tools/sdk/esp32s3/include/efuse/esp32s3/include/esp_efuse_table.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2017-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -9,7 +9,7 @@ extern "C" { #endif -// md5_digest_table 9444b887379d924049af42806ca71d45 +// md5_digest_table 62fa98bed350ebc4951c5f8191c487de // This file was generated from the file esp_efuse_table.csv. DO NOT CHANGE THIS FILE MANUALLY. // If you want to change some fields, you need to change esp_efuse_table.csv file // then run `efuse_common_table` or `efuse_custom_table` command it will generate this file. @@ -88,10 +88,10 @@ extern const esp_efuse_desc_t* ESP_EFUSE_STRAP_JTAG_SEL[]; extern const esp_efuse_desc_t* ESP_EFUSE_USB_PHY_SEL[]; extern const esp_efuse_desc_t* ESP_EFUSE_FLASH_TPUW[]; extern const esp_efuse_desc_t* ESP_EFUSE_DIS_DOWNLOAD_MODE[]; -extern const esp_efuse_desc_t* ESP_EFUSE_DIS_LEGACY_SPI_BOOT[]; -extern const esp_efuse_desc_t* ESP_EFUSE_UART_PRINT_CHANNEL[]; +extern const esp_efuse_desc_t* ESP_EFUSE_DIS_DIRECT_BOOT[]; +extern const esp_efuse_desc_t* ESP_EFUSE_DIS_USB_SERIAL_JTAG_ROM_PRINT[]; extern const esp_efuse_desc_t* ESP_EFUSE_FLASH_ECC_MODE[]; -extern const esp_efuse_desc_t* ESP_EFUSE_DIS_USB_DOWNLOAD_MODE[]; +extern const esp_efuse_desc_t* ESP_EFUSE_DIS_USB_SERIAL_JTAG_DOWNLOAD_MODE[]; extern const esp_efuse_desc_t* ESP_EFUSE_ENABLE_SECURITY_DOWNLOAD[]; extern const esp_efuse_desc_t* ESP_EFUSE_UART_PRINT_CONTROL[]; extern const esp_efuse_desc_t* ESP_EFUSE_PIN_POWER_SELECTION[]; @@ -100,6 +100,7 @@ extern const esp_efuse_desc_t* ESP_EFUSE_FLASH_PAGE_SIZE[]; extern const esp_efuse_desc_t* ESP_EFUSE_FLASH_ECC_EN[]; extern const esp_efuse_desc_t* ESP_EFUSE_FORCE_SEND_RESUME[]; extern const esp_efuse_desc_t* ESP_EFUSE_SECURE_VERSION[]; +extern const esp_efuse_desc_t* ESP_EFUSE_DIS_USB_OTG_DOWNLOAD_MODE[]; extern const esp_efuse_desc_t* ESP_EFUSE_MAC_FACTORY[]; extern const esp_efuse_desc_t* ESP_EFUSE_SPI_PAD_CONFIG_CLK[]; extern const esp_efuse_desc_t* ESP_EFUSE_SPI_PAD_CONFIG_Q_D1[]; diff --git a/tools/sdk/esp32s3/include/esp-tls/esp_tls.h b/tools/sdk/esp32s3/include/esp-tls/esp_tls.h index 588f70d83f9..5b5b3628023 100644 --- a/tools/sdk/esp32s3/include/esp-tls/esp_tls.h +++ b/tools/sdk/esp32s3/include/esp-tls/esp_tls.h @@ -688,6 +688,16 @@ esp_err_t esp_tls_plain_tcp_connect(const char *host, int hostlen, int port, con * NULL on Failure */ esp_tls_client_session_t *esp_tls_get_client_session(esp_tls_t *tls); + +/** + * @brief Free the client session + * + * This function should be called after esp_tls_get_client_session(). + * + * @param[in] client_session context as esp_tls_client_session_t + * + */ +void esp_tls_free_client_session(esp_tls_client_session_t *client_session); #endif /* CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS */ #ifdef __cplusplus } diff --git a/tools/sdk/esp32s3/include/esp-tls/private_include/esp_tls_mbedtls.h b/tools/sdk/esp32s3/include/esp-tls/private_include/esp_tls_mbedtls.h index c1c5d4f3288..43dce58ad6e 100644 --- a/tools/sdk/esp32s3/include/esp-tls/private_include/esp_tls_mbedtls.h +++ b/tools/sdk/esp32s3/include/esp-tls/private_include/esp_tls_mbedtls.h @@ -104,6 +104,11 @@ esp_err_t set_client_config(const char *hostname, size_t hostlen, esp_tls_cfg_t * Internal Callback for mbedtls_get_client_session */ esp_tls_client_session_t *esp_mbedtls_get_client_session(esp_tls_t *tls); + +/** + * Internal Callback for mbedtls_free_client_session + */ +void esp_mbedtls_free_client_session(esp_tls_client_session_t *client_session); #endif /** diff --git a/tools/sdk/esp32s3/include/esp32-camera/driver/include/sensor.h b/tools/sdk/esp32s3/include/esp32-camera/driver/include/sensor.h index 26afeec3fd5..e4a1cceba57 100755 --- a/tools/sdk/esp32s3/include/esp32-camera/driver/include/sensor.h +++ b/tools/sdk/esp32s3/include/esp32-camera/driver/include/sensor.h @@ -28,6 +28,7 @@ typedef enum { GC0308_PID = 0x9b, BF3005_PID = 0x30, BF20A6_PID = 0x20a6, + SC030IOT_PID = 0x9a46, } camera_pid_t; typedef enum { @@ -42,6 +43,7 @@ typedef enum { CAMERA_GC0308, CAMERA_BF3005, CAMERA_BF20A6, + CAMERA_SC030IOT, CAMERA_MODEL_MAX, CAMERA_NONE, } camera_model_t; @@ -58,6 +60,7 @@ typedef enum { GC0308_SCCB_ADDR = 0x21,// 0x42 >> 1 BF3005_SCCB_ADDR = 0x6E, BF20A6_SCCB_ADDR = 0x6E, + SC030IOT_SCCB_ADDR = 0x68,// 0xd0 >> 1 } camera_sccb_addr_t; typedef enum { diff --git a/tools/sdk/esp32s3/include/esp_http_client/include/esp_http_client.h b/tools/sdk/esp32s3/include/esp_http_client/include/esp_http_client.h index d1b530a42e3..6ba8ed6e582 100644 --- a/tools/sdk/esp32s3/include/esp_http_client/include/esp_http_client.h +++ b/tools/sdk/esp32s3/include/esp_http_client/include/esp_http_client.h @@ -149,7 +149,9 @@ typedef enum { HttpStatus_MultipleChoices = 300, HttpStatus_MovedPermanently = 301, HttpStatus_Found = 302, + HttpStatus_SeeOther = 303, HttpStatus_TemporaryRedirect = 307, + HttpStatus_PermanentRedirect = 308, /* 4xx - Client Error */ HttpStatus_BadRequest = 400, diff --git a/tools/sdk/esp32s3/include/esp_hw_support/include/soc/spinlock.h b/tools/sdk/esp32s3/include/esp_hw_support/include/soc/spinlock.h index fbeff5054b4..b2fadfe49e3 100644 --- a/tools/sdk/esp32s3/include/esp_hw_support/include/soc/spinlock.h +++ b/tools/sdk/esp32s3/include/esp_hw_support/include/soc/spinlock.h @@ -95,13 +95,13 @@ static inline bool __attribute__((always_inline)) spinlock_acquire(spinlock_t *l */ result = core_id; -#if defined(CONFIG_ESP32_SPIRAM_SUPPORT) +#if (CONFIG_ESP32_SPIRAM_SUPPORT || CONFIG_ESP32S3_SPIRAM_SUPPORT) if (esp_ptr_external_ram(lock)) { compare_and_set_extram(&lock->owner, SPINLOCK_FREE, &result); } else { #endif compare_and_set_native(&lock->owner, SPINLOCK_FREE, &result); -#if defined(CONFIG_ESP32_SPIRAM_SUPPORT) +#if (CONFIG_ESP32_SPIRAM_SUPPORT || CONFIG_ESP32S3_SPIRAM_SUPPORT) } #endif if(result != other_core_id) { diff --git a/tools/sdk/esp32s3/include/esp_hw_support/port/esp32s3/regi2c_ctrl.h b/tools/sdk/esp32s3/include/esp_hw_support/port/esp32s3/regi2c_ctrl.h index a4a3cbce202..40a1ceb09f2 100644 --- a/tools/sdk/esp32s3/include/esp_hw_support/port/esp32s3/regi2c_ctrl.h +++ b/tools/sdk/esp32s3/include/esp_hw_support/port/esp32s3/regi2c_ctrl.h @@ -20,6 +20,7 @@ extern "C" { #define I2C_MST_ANA_CONF0_REG 0x6000E040 #define I2C_MST_BBPLL_STOP_FORCE_HIGH (BIT(2)) #define I2C_MST_BBPLL_STOP_FORCE_LOW (BIT(3)) +#define I2C_MST_BBPLL_CAL_DONE (BIT(24)) #define ANA_CONFIG_REG 0x6000E044 #define ANA_CONFIG_S (8) diff --git a/tools/sdk/esp32s3/include/esp_lcd/include/esp_lcd_panel_io.h b/tools/sdk/esp32s3/include/esp_lcd/include/esp_lcd_panel_io.h index 330f4d9a165..7b99bde3f17 100644 --- a/tools/sdk/esp32s3/include/esp_lcd/include/esp_lcd_panel_io.h +++ b/tools/sdk/esp32s3/include/esp_lcd/include/esp_lcd_panel_io.h @@ -19,6 +19,25 @@ typedef void *esp_lcd_spi_bus_handle_t; /*!< Type of LCD S typedef void *esp_lcd_i2c_bus_handle_t; /*!< Type of LCD I2C bus handle */ typedef struct esp_lcd_i80_bus_t *esp_lcd_i80_bus_handle_t; /*!< Type of LCD intel 8080 bus handle */ +/** + * @brief Transmit LCD command and receive corresponding parameters + * + * @note Commands sent by this function are short, so they are sent using polling transactions. + * The function does not return before the command tranfer is completed. + * If any queued transactions sent by `esp_lcd_panel_io_tx_color()` are still pending when this function is called, + * this function will wait until they are finished and the queue is empty before sending the command(s). + * + * @param[in] io LCD panel IO handle, which is created by other factory API like `esp_lcd_new_panel_io_spi()` + * @param[in] lcd_cmd The specific LCD command, set to -1 if no command needed + * @param[out] param Buffer for the command data + * @param[in] param_size Size of `param` buffer + * @return + * - ESP_ERR_INVALID_ARG if parameter is invalid + * - ESP_ERR_NOT_SUPPORTED if read is not supported by transport + * - ESP_OK on success + */ +esp_err_t esp_lcd_panel_io_rx_param(esp_lcd_panel_io_handle_t io, int lcd_cmd, void *param, size_t param_size); + /** * @brief Transmit LCD command and corresponding parameters * @@ -98,7 +117,8 @@ typedef struct { unsigned int dc_as_cmd_phase: 1; /*!< D/C line value is encoded into SPI transaction command phase */ unsigned int dc_low_on_data: 1; /*!< If this flag is enabled, DC line = 0 means transfer data, DC line = 1 means transfer command; vice versa */ unsigned int octal_mode: 1; /*!< transmit with octal mode (8 data lines), this mode is used to simulate Intel 8080 timing */ - } flags; + unsigned int lsb_first: 1; /*!< transmit LSB bit first */ + } flags; /*!< Extra flags to fine-tune the SPI device */ } esp_lcd_panel_io_spi_config_t; /** @@ -124,6 +144,7 @@ typedef struct { int lcd_param_bits; /*!< Bit-width of LCD parameter */ struct { unsigned int dc_low_on_data: 1; /*!< If this flag is enabled, DC line = 0 means transfer data, DC line = 1 means transfer command; vice versa */ + unsigned int disable_control_phase: 1; /*!< If this flag is enabled, the control phase isn't used */ } flags; } esp_lcd_panel_io_i2c_config_t; @@ -151,6 +172,8 @@ typedef struct { int data_gpio_nums[SOC_LCD_I80_BUS_WIDTH]; /*!< GPIOs used for data lines */ size_t bus_width; /*!< Number of data lines, 8 or 16 */ size_t max_transfer_bytes; /*!< Maximum transfer size, this determines the length of internal DMA link */ + size_t psram_trans_align; /*!< DMA transfer alignment for data allocated from PSRAM */ + size_t sram_trans_align; /*!< DMA transfer alignment for data allocated from SRAM */ } esp_lcd_i80_bus_config_t; /** diff --git a/tools/sdk/esp32s3/include/esp_lcd/include/esp_lcd_panel_rgb.h b/tools/sdk/esp32s3/include/esp_lcd/include/esp_lcd_panel_rgb.h index 6f06deb8165..95dfb6ba4fc 100644 --- a/tools/sdk/esp32s3/include/esp_lcd/include/esp_lcd_panel_rgb.h +++ b/tools/sdk/esp32s3/include/esp_lcd/include/esp_lcd_panel_rgb.h @@ -59,7 +59,7 @@ typedef struct { unsigned int hsync_front_porch; /*!< Horizontal front porch, number of PCLK between the end of active data and the next hsync */ unsigned int vsync_pulse_width; /*!< Vertical sync width, unit: number of lines */ unsigned int vsync_back_porch; /*!< Vertical back porch, number of invalid lines between vsync and start of frame */ - unsigned int vsync_front_porch; /*!< Vertical front porch, number of invalid lines between then end of frame and the next vsync */ + unsigned int vsync_front_porch; /*!< Vertical front porch, number of invalid lines between the end of frame and the next vsync */ struct { unsigned int hsync_idle_low: 1; /*!< The hsync signal is low in IDLE state */ unsigned int vsync_idle_low: 1; /*!< The vsync signal is low in IDLE state */ diff --git a/tools/sdk/esp32s3/include/esp_lcd/interface/esp_lcd_panel_io_interface.h b/tools/sdk/esp32s3/include/esp_lcd/interface/esp_lcd_panel_io_interface.h index 2faa6fab268..9f2226587e5 100644 --- a/tools/sdk/esp32s3/include/esp_lcd/interface/esp_lcd_panel_io_interface.h +++ b/tools/sdk/esp32s3/include/esp_lcd/interface/esp_lcd_panel_io_interface.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -18,6 +18,22 @@ typedef struct esp_lcd_panel_io_t esp_lcd_panel_io_t; /*!< Type of LCD panel IO * @brief LCD panel IO interface */ struct esp_lcd_panel_io_t { + /** + * @brief Transmit LCD command and receive corresponding parameters + * + * @note This is the panel-specific interface called by function `esp_lcd_panel_io_rx_param()`. + * + * @param[in] io LCD panel IO handle, which is created by other factory API like `esp_lcd_new_panel_io_spi()` + * @param[in] lcd_cmd The specific LCD command, set to -1 if no command needed + * @param[out] param Buffer for the command data + * @param[in] param_size Size of `param` buffer + * @return + * - ESP_ERR_INVALID_ARG if parameter is invalid + * - ESP_ERR_NOT_SUPPORTED if read is not supported by transport + * - ESP_OK on success + */ + esp_err_t (*rx_param)(esp_lcd_panel_io_t *io, int lcd_cmd, void *param, size_t param_size); + /** * @brief Transmit LCD command and corresponding parameters * diff --git a/tools/sdk/esp32s3/include/esp_phy/esp32s3/include/phy_init_data.h b/tools/sdk/esp32s3/include/esp_phy/esp32s3/include/phy_init_data.h index 88f56282d58..4f2b6694502 100644 --- a/tools/sdk/esp32s3/include/esp_phy/esp32s3/include/phy_init_data.h +++ b/tools/sdk/esp32s3/include/esp_phy/esp32s3/include/phy_init_data.h @@ -20,8 +20,8 @@ extern "C" { // define the lowest tx power as LOWEST_PHY_TX_POWER #define PHY_TX_POWER_LOWEST LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 52) -#define PHY_TX_POWER_OFFSET 44 -#define PHY_TX_POWER_NUM 5 +#define PHY_TX_POWER_OFFSET 2 +#define PHY_TX_POWER_NUM 14 #if CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN #define PHY_CRC_ALGORITHM 1 diff --git a/tools/sdk/esp32s3/include/esp_phy/include/esp_phy_init.h b/tools/sdk/esp32s3/include/esp_phy/include/esp_phy_init.h index 04068c7f38d..ec682139506 100644 --- a/tools/sdk/esp32s3/include/esp_phy/include/esp_phy_init.h +++ b/tools/sdk/esp32s3/include/esp_phy/include/esp_phy_init.h @@ -170,12 +170,27 @@ void esp_phy_disable(void); */ void esp_phy_load_cal_and_init(void); +/** + * @brief Initialize backup memory for Phy power up/down + */ +void esp_phy_pd_mem_init(void); + +/** + * @brief Deinitialize backup memory for Phy power up/down + */ +void esp_phy_pd_mem_deinit(void); + #if CONFIG_MAC_BB_PD /** * @brief Initialize backup memory for MAC and Baseband power up/down */ void esp_mac_bb_pd_mem_init(void); +/** + * @brief Deinitialize backup memory for MAC and Baseband power up/down + */ +void esp_mac_bb_pd_mem_deinit(void); + /** * @brief Power up MAC and Baseband */ diff --git a/tools/sdk/esp32s3/include/esp_rainmaker/include/esp_rmaker_core.h b/tools/sdk/esp32s3/include/esp_rainmaker/include/esp_rmaker_core.h index 9dbdbae658b..eb01e6d8e3d 100644 --- a/tools/sdk/esp32s3/include/esp_rainmaker/include/esp_rmaker_core.h +++ b/tools/sdk/esp32s3/include/esp_rainmaker/include/esp_rmaker_core.h @@ -63,6 +63,8 @@ typedef struct { char *fw_version; /** Model (Optional). If not set, PROJECT_NAME is used as default (recommended)*/ char *model; + /** Subtype (Optional). */ + char *subtype; } esp_rmaker_node_info_t; /** ESP RainMaker Configuration */ @@ -430,10 +432,11 @@ esp_err_t esp_rmaker_node_add_attribute(const esp_rmaker_node_t *node, const cha */ esp_err_t esp_rmaker_node_add_fw_version(const esp_rmaker_node_t *node, const char *fw_version); -/** Add model for a node (Not recommended) +/** Add model for a node * * Model is set internally to the project name. This API can be used to - * override that name. + * override that name, now that a new field "project" has also been added + * internally to the node info. * * @param node Node handle. * @param[in] model New model string. @@ -443,6 +446,16 @@ esp_err_t esp_rmaker_node_add_fw_version(const esp_rmaker_node_t *node, const ch */ esp_err_t esp_rmaker_node_add_model(const esp_rmaker_node_t *node, const char *model); +/** Add subtype for a node + * + * @param node Node handle. + * @param[in] subtype Subtype string. + * + * @return ESP_OK on success. + * @return error in case of failure. + */ +esp_err_t esp_rmaker_node_add_subtype(const esp_rmaker_node_t *node, const char *subtype); + /** * Create a Device * @@ -572,6 +585,18 @@ esp_err_t esp_rmaker_device_add_attribute(const esp_rmaker_device_t *device, con */ esp_err_t esp_rmaker_device_add_subtype(const esp_rmaker_device_t *device, const char *subtype); +/** Add a Device model + * + * This would primarily be used by the phone apps to render different icons for the same device type. + * + * @param[in] device Device handle. + * @param[in] model String describing the model. + * + * @return ESP_OK if the model was added successfully. + * @return error in case of failure. + */ +esp_err_t esp_rmaker_device_add_model(const esp_rmaker_device_t *device, const char *model); + /** Get device name from handle * * @param[in] device Device handle. @@ -892,6 +917,20 @@ esp_err_t esp_rmaker_system_service_enable(esp_rmaker_system_serv_config_t *conf */ bool esp_rmaker_local_ctrl_service_started(void); +/** + * Enable Default RainMaker OTA Firmware Upgrade + * + * This enables the default recommended RainMaker OTA Firmware Upgrade, which is + * "Using the Topics", which allows performing OTA from Dashboard. + * This OTA can be triggered by Admin Users only. + * On Public RainMaker deployment, for nodes using "Self Claiming", since there + * is no associated admin user, the Primary user will automatically become the admin + * and can perform OTA from dashboard. + * + * @return ESP_OK on success + * @return error on failure + */ +esp_err_t esp_rmaker_ota_enable_default(void); #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32s3/include/esp_rainmaker/include/esp_rmaker_ota.h b/tools/sdk/esp32s3/include/esp_rainmaker/include/esp_rmaker_ota.h index e66b95705bc..6dc7962177e 100644 --- a/tools/sdk/esp32s3/include/esp_rainmaker/include/esp_rmaker_ota.h +++ b/tools/sdk/esp32s3/include/esp_rainmaker/include/esp_rmaker_ota.h @@ -34,6 +34,8 @@ typedef enum { OTA_STATUS_FAILED, /** OTA was delayed by the application */ OTA_STATUS_DELAYED, + /** OTA rejected due to some reason (wrong project, version, etc.) */ + OTA_STATUS_REJECTED, } ota_status_t; /** OTA Workflow type */ @@ -145,6 +147,29 @@ esp_err_t esp_rmaker_ota_enable(esp_rmaker_ota_config_t *ota_config, esp_rmaker_ */ esp_err_t esp_rmaker_ota_report_status(esp_rmaker_ota_handle_t ota_handle, ota_status_t status, char *additional_info); +/** Default OTA callback + * + * This is the default OTA callback which will get used if you do not pass your own callback. You can call this + * even from your callback, in case you want better control on when the OTA can proceed and yet let the actual + * OTA process be managed by the RainMaker Core. + * + * @param[in] handle An OTA handle assigned by the ESP RainMaker Core + * @param[in] ota_data The data to be used for the OTA + * + * @return ESP_OK if the OTA was successful + * @return ESP_FAIL if the OTA failed. + * */ +esp_err_t esp_rmaker_ota_default_cb(esp_rmaker_ota_handle_t handle, esp_rmaker_ota_data_t *ota_data); + +/** Fetch OTA Info + * + * For OTA using Topics, this API can be used to explicitly ask the backend if an OTA is available. + * If it is, then the OTA callback would get invoked. + * + * @return ESP_OK if the OTA fetch publish message was successful. + * @return error on failure + */ +esp_err_t esp_rmaker_ota_fetch(void); #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32s3/include/esp_rainmaker/include/esp_rmaker_standard_types.h b/tools/sdk/esp32s3/include/esp_rainmaker/include/esp_rmaker_standard_types.h index 4dc99eab401..9f74fcaea7c 100644 --- a/tools/sdk/esp32s3/include/esp_rainmaker/include/esp_rmaker_standard_types.h +++ b/tools/sdk/esp32s3/include/esp_rainmaker/include/esp_rmaker_standard_types.h @@ -25,6 +25,10 @@ extern "C" #define ESP_RMAKER_UI_DROPDOWN "esp.ui.dropdown" #define ESP_RMAKER_UI_TEXT "esp.ui.text" #define ESP_RMAKER_UI_HUE_SLIDER "esp.ui.hue-slider" +#define ESP_RMAKER_UI_HUE_CIRCLE "esp.ui.hue-circle" +#define ESP_RMAKER_UI_PUSHBUTTON "esp.ui.push-btn-big" +#define ESP_RMAKER_UI_TRIGGER "esp.ui.trigger" +#define ESP_RMAKER_UI_HIDDEN "esp.ui.hidden" /********** STANDARD PARAM TYPES **********/ @@ -50,6 +54,13 @@ extern "C" #define ESP_RMAKER_PARAM_WIFI_RESET "esp.param.wifi-reset" #define ESP_RMAKER_PARAM_LOCAL_CONTROL_POP "esp.param.local_control_pop" #define ESP_RMAKER_PARAM_LOCAL_CONTROL_TYPE "esp.param.local_control_type" +#define ESP_RMAKER_PARAM_TOGGLE "esp.param.toggle" +#define ESP_RMAKER_PARAM_RANGE "esp.param.range" +#define ESP_RMAKER_PARAM_MODE "esp.param.mode" +#define ESP_RMAKER_PARAM_BLINDS_POSITION "esp.param.blinds-position" +#define ESP_RMAKER_PARAM_GARAGE_POSITION "esp.param.garage-position" +#define ESP_RMAKER_PARAM_LIGHT_MODE "esp.param.light-mode" +#define ESP_RMAKER_PARAM_AC_MODE "esp.param.ac-mode" /********** STANDARD DEVICE TYPES **********/ @@ -58,7 +69,21 @@ extern "C" #define ESP_RMAKER_DEVICE_LIGHTBULB "esp.device.lightbulb" #define ESP_RMAKER_DEVICE_FAN "esp.device.fan" #define ESP_RMAKER_DEVICE_TEMP_SENSOR "esp.device.temperature-sensor" - +#define ESP_RMAKER_DEVICE_LIGHT "esp.device.light" +#define ESP_RMAKER_DEVICE_OUTLET "esp.device.outlet" +#define ESP_RMAKER_DEVICE_PLUG "esp.device.plug" +#define ESP_RMAKER_DEVICE_SOCKET "esp.device.socket" +#define ESP_RMAKER_DEVICE_LOCK "esp.device.lock" +#define ESP_RMAKER_DEVICE_BLINDS_INTERNAL "esp.device.blinds-internal" +#define ESP_RMAKER_DEVICE_BLINDS_EXTERNAL "esp.device.blinds-external" +#define ESP_RMAKER_DEVICE_GARAGE_DOOR "esp.device.garage-door" +#define ESP_RMAKER_DEVICE_GARAGE_LOCK "esp.device.garage-door-lock" +#define ESP_RMAKER_DEVICE_SPEAKER "esp.device.speaker" +#define ESP_RMAKER_DEVICE_AIR_CONDITIONER "esp.device.air-conditioner" +#define ESP_RMAKER_DEVICE_THERMOSTAT "esp.device.thermostat" +#define ESP_RMAKER_DEVICE_TV "esp.device.tv" +#define ESP_RMAKER_DEVICE_WASHER "esp.device.washer" +#define ESP_RMAKER_DEVICE_OTHER "esp.device.other" /********** STANDARD SERVICE TYPES **********/ #define ESP_RMAKER_SERVICE_OTA "esp.service.ota" diff --git a/tools/sdk/esp32s3/include/esp_rainmaker/include/esp_rmaker_user_mapping.h b/tools/sdk/esp32s3/include/esp_rainmaker/include/esp_rmaker_user_mapping.h index 77a153b02f2..734cdd6da2a 100644 --- a/tools/sdk/esp32s3/include/esp_rainmaker/include/esp_rmaker_user_mapping.h +++ b/tools/sdk/esp32s3/include/esp_rainmaker/include/esp_rmaker_user_mapping.h @@ -25,6 +25,8 @@ typedef enum { ESP_RMAKER_USER_MAPPING_RESET = 0, /** Mapping has started */ ESP_RMAKER_USER_MAPPING_STARTED, + /** Mapping request sent to cloud */ + ESP_RMAKER_USER_MAPPING_REQ_SENT, /** Mapping is done */ ESP_RMAKER_USER_MAPPING_DONE, } esp_rmaker_user_mapping_state_t; diff --git a/tools/sdk/esp32s3/include/esp_rom/include/esp32c3/rom/efuse.h b/tools/sdk/esp32s3/include/esp_rom/include/esp32c3/rom/efuse.h index 9da1525f969..d1412c46110 100644 --- a/tools/sdk/esp32s3/include/esp_rom/include/esp32c3/rom/efuse.h +++ b/tools/sdk/esp32s3/include/esp_rom/include/esp32c3/rom/efuse.h @@ -1,16 +1,8 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ROM_EFUSE_H_ #define _ROM_EFUSE_H_ @@ -236,13 +228,13 @@ bool ets_efuse_legacy_spi_boot_mode_disabled(void); uint32_t ets_efuse_get_uart_print_control(void); /** - * @brief Read which channel will used by ROM to print + * @brief Read if USB-Serial-JTAG print during rom boot is disabled from Efuse * * @return - * - 0 for UART0. - * - 1 for UART1. + * - 1 for efuse disable USB-Serial-JTAG print during rom boot. + * - 0 for efuse doesn't disable USB-Serial-JTAG print during rom boot. */ -uint32_t ets_efuse_get_uart_print_channel(void); +uint32_t ets_efuse_usb_serial_jtag_print_is_disabled(void); /** * @brief Read if usb download mode disabled from Efuse diff --git a/tools/sdk/esp32s3/include/esp_rom/include/esp32h2/rom/efuse.h b/tools/sdk/esp32s3/include/esp_rom/include/esp32h2/rom/efuse.h index 9da1525f969..d1412c46110 100644 --- a/tools/sdk/esp32s3/include/esp_rom/include/esp32h2/rom/efuse.h +++ b/tools/sdk/esp32s3/include/esp_rom/include/esp32h2/rom/efuse.h @@ -1,16 +1,8 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ROM_EFUSE_H_ #define _ROM_EFUSE_H_ @@ -236,13 +228,13 @@ bool ets_efuse_legacy_spi_boot_mode_disabled(void); uint32_t ets_efuse_get_uart_print_control(void); /** - * @brief Read which channel will used by ROM to print + * @brief Read if USB-Serial-JTAG print during rom boot is disabled from Efuse * * @return - * - 0 for UART0. - * - 1 for UART1. + * - 1 for efuse disable USB-Serial-JTAG print during rom boot. + * - 0 for efuse doesn't disable USB-Serial-JTAG print during rom boot. */ -uint32_t ets_efuse_get_uart_print_channel(void); +uint32_t ets_efuse_usb_serial_jtag_print_is_disabled(void); /** * @brief Read if usb download mode disabled from Efuse diff --git a/tools/sdk/esp32s3/include/esp_rom/include/esp32s3/rom/efuse.h b/tools/sdk/esp32s3/include/esp_rom/include/esp32s3/rom/efuse.h index cbe38e6a55e..3d347f48330 100644 --- a/tools/sdk/esp32s3/include/esp_rom/include/esp32s3/rom/efuse.h +++ b/tools/sdk/esp32s3/include/esp_rom/include/esp32s3/rom/efuse.h @@ -1,16 +1,8 @@ -// Copyright 2015-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. +/* + * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once @@ -237,13 +229,13 @@ bool ets_efuse_legacy_spi_boot_mode_disabled(void); uint32_t ets_efuse_get_uart_print_control(void); /** - * @brief Read which channel will used by ROM to print + * @brief Read if USB-Serial-JTAG print during rom boot is disabled from Efuse * * @return - * - 0 for UART0. - * - 1 for UART1. + * - 1 for efuse disable USB-Serial-JTAG print during rom boot. + * - 0 for efuse doesn't disable USB-Serial-JTAG print during rom boot. */ -uint32_t ets_efuse_get_uart_print_channel(void); +uint32_t ets_efuse_usb_serial_jtag_print_is_disabled(void); /** * @brief Read if usb download mode disabled from Efuse diff --git a/tools/sdk/esp32s3/include/esp_wifi/include/esp_wifi.h b/tools/sdk/esp32s3/include/esp_wifi/include/esp_wifi.h index bcd10c77a10..3d62c5c297c 100644 --- a/tools/sdk/esp32s3/include/esp_wifi/include/esp_wifi.h +++ b/tools/sdk/esp32s3/include/esp_wifi/include/esp_wifi.h @@ -1295,6 +1295,19 @@ esp_err_t esp_wifi_get_country_code(char *country); */ esp_err_t esp_wifi_config_80211_tx_rate(wifi_interface_t ifx, wifi_phy_rate_t rate); +/** + * @brief Disable PMF configuration for specified interface + * + * @attention This API should be called after esp_wifi_set_config() and before esp_wifi_start(). + * + * @param ifx Interface to be configured. + * + * @return + * - ESP_OK: succeed + * - others: failed + */ +esp_err_t esp_wifi_disable_pmf_config(wifi_interface_t ifx); + #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32s3/include/freertos/include/esp_additions/freertos/task_snapshot.h b/tools/sdk/esp32s3/include/freertos/include/esp_additions/freertos/task_snapshot.h index 1ad04cce694..635a5150257 100644 --- a/tools/sdk/esp32s3/include/freertos/include/esp_additions/freertos/task_snapshot.h +++ b/tools/sdk/esp32s3/include/freertos/include/esp_additions/freertos/task_snapshot.h @@ -80,8 +80,9 @@ TaskHandle_t pxTaskGetNext( TaskHandle_t pxTask ); * @note This function should not be used while FreeRTOS is running (as it doesn't acquire any locks). * @param pxTask task handle. * @param pxTaskSnapshot address of TaskSnapshot_t structure to fill. + * @return pdTRUE if operation was successful else pdFALSE */ -void vTaskGetSnapshot( TaskHandle_t pxTask, TaskSnapshot_t *pxTaskSnapshot ); +BaseType_t vTaskGetSnapshot( TaskHandle_t pxTask, TaskSnapshot_t *pxTaskSnapshot ); #ifdef __cplusplus } diff --git a/tools/sdk/esp32s3/include/hal/esp32s3/include/hal/cpu_ll.h b/tools/sdk/esp32s3/include/hal/esp32s3/include/hal/cpu_ll.h index 284e86757d1..d22a32f2884 100644 --- a/tools/sdk/esp32s3/include/hal/esp32s3/include/hal/cpu_ll.h +++ b/tools/sdk/esp32s3/include/hal/esp32s3/include/hal/cpu_ll.h @@ -38,7 +38,7 @@ static inline uint32_t IRAM_ATTR cpu_ll_get_core_id(void) return id; } -static inline uint32_t cpu_ll_get_cycle_count(void) +static inline uint32_t IRAM_ATTR cpu_ll_get_cycle_count(void) { uint32_t result; RSR(CCOUNT, result); diff --git a/tools/sdk/esp32s3/include/hal/esp32s3/include/hal/i2c_ll.h b/tools/sdk/esp32s3/include/hal/esp32s3/include/hal/i2c_ll.h index eae2a660fbc..ec209daf2e6 100644 --- a/tools/sdk/esp32s3/include/hal/esp32s3/include/hal/i2c_ll.h +++ b/tools/sdk/esp32s3/include/hal/esp32s3/include/hal/i2c_ll.h @@ -1,16 +1,8 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ // The LL layer for I2C register operations @@ -152,18 +144,20 @@ static inline void i2c_ll_update(i2c_dev_t *hw) static inline void i2c_ll_set_bus_timing(i2c_dev_t *hw, i2c_clk_cal_t *bus_cfg) { HAL_FORCE_MODIFY_U32_REG_FIELD(hw->clk_conf, sclk_div_num, bus_cfg->clkm_div - 1); + /* According to the Technical Reference Manual, the following timings must be subtracted by 1. + * Moreover, the frequency calculation also shows that we must subtract 3 to the total SCL */ //scl period - hw->scl_low_period.scl_low_period = bus_cfg->scl_low - 1; - hw->scl_high_period.scl_high_period = bus_cfg->scl_high; + hw->scl_low_period.scl_low_period = bus_cfg->scl_low - 1 - 2; + hw->scl_high_period.scl_high_period = bus_cfg->scl_high - 1 - 1; //sda sample - hw->sda_hold.sda_hold_time = bus_cfg->sda_hold; - hw->sda_sample.sda_sample_time = bus_cfg->sda_sample; + hw->sda_hold.sda_hold_time = bus_cfg->sda_hold - 1; + hw->sda_sample.sda_sample_time = bus_cfg->sda_sample - 1; //setup - hw->scl_rstart_setup.scl_rstart_setup_time = bus_cfg->setup; - hw->scl_stop_setup.scl_stop_setup_time = bus_cfg->setup; + hw->scl_rstart_setup.scl_rstart_setup_time = bus_cfg->setup - 1; + hw->scl_stop_setup.scl_stop_setup_time = bus_cfg->setup - 1; //hold hw->scl_start_hold.scl_start_hold_time = bus_cfg->hold - 1; - hw->scl_stop_hold.scl_stop_hold_time = bus_cfg->hold; + hw->scl_stop_hold.scl_stop_hold_time = bus_cfg->hold - 1; hw->to.time_out_value = bus_cfg->tout; hw->to.time_out_en = 1; } diff --git a/tools/sdk/esp32s3/include/hal/esp32s3/include/hal/lcd_ll.h b/tools/sdk/esp32s3/include/hal/esp32s3/include/hal/lcd_ll.h index 8a5e0534e63..495d08b9056 100644 --- a/tools/sdk/esp32s3/include/hal/esp32s3/include/hal/lcd_ll.h +++ b/tools/sdk/esp32s3/include/hal/esp32s3/include/hal/lcd_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -34,7 +34,11 @@ static inline void lcd_ll_enable_clock(lcd_cam_dev_t *dev, bool en) static inline void lcd_ll_set_group_clock_src(lcd_cam_dev_t *dev, lcd_clock_source_t src, int div_num, int div_a, int div_b) { // lcd_clk = module_clock_src / (div_num + div_b / div_a) - HAL_ASSERT(div_num >= 2); + HAL_ASSERT(div_num >= 2 && div_num <= 256); + // dic_num == 0 means 256 divider in hardware + if (div_num >= 256) { + div_num = 0; + } HAL_FORCE_MODIFY_U32_REG_FIELD(dev->lcd_clock, lcd_clkm_div_num, div_num); dev->lcd_clock.lcd_clkm_div_a = div_a; dev->lcd_clock.lcd_clkm_div_b = div_b; @@ -42,10 +46,15 @@ static inline void lcd_ll_set_group_clock_src(lcd_cam_dev_t *dev, lcd_clock_sour case LCD_CLK_SRC_PLL160M: dev->lcd_clock.lcd_clk_sel = 3; break; + case LCD_CLK_SRC_PLL240M: + dev->lcd_clock.lcd_clk_sel = 2; + break; case LCD_CLK_SRC_XTAL: dev->lcd_clock.lcd_clk_sel = 1; break; default: + // disble LCD clock source + dev->lcd_clock.lcd_clk_sel = 0; HAL_ASSERT(false && "unsupported clock source"); break; } @@ -60,7 +69,6 @@ static inline void lcd_ll_set_clock_idle_level(lcd_cam_dev_t *dev, bool level) __attribute__((always_inline)) static inline void lcd_ll_set_pixel_clock_edge(lcd_cam_dev_t *dev, bool active_on_neg) { - dev->lcd_clock.lcd_clk_equ_sysclk = 0; // if we want to pixel_clk == lcd_clk, just make clkcnt = 0 dev->lcd_clock.lcd_ck_out_edge = active_on_neg; } @@ -68,7 +76,15 @@ __attribute__((always_inline)) static inline void lcd_ll_set_pixel_clock_prescale(lcd_cam_dev_t *dev, uint32_t prescale) { // Formula: pixel_clk = lcd_clk / (1 + clkcnt_n) - dev->lcd_clock.lcd_clkcnt_n = prescale - 1; + // clkcnt_n can't be zero + uint32_t scale = 1; + if (prescale == 1) { + dev->lcd_clock.lcd_clk_equ_sysclk = 1; + } else { + dev->lcd_clock.lcd_clk_equ_sysclk = 0; + scale = prescale - 1; + } + dev->lcd_clock.lcd_clkcnt_n = scale; } static inline void lcd_ll_enable_rgb_yuv_convert(lcd_cam_dev_t *dev, bool en) @@ -97,14 +113,10 @@ static inline void lcd_ll_set_blank_cycles(lcd_cam_dev_t *dev, uint32_t fk_cycle static inline void lcd_ll_set_data_width(lcd_cam_dev_t *dev, uint32_t width) { + HAL_ASSERT(width == 8 || width == 16); dev->lcd_user.lcd_2byte_en = (width == 16); } -static inline uint32_t lcd_ll_get_data_width(lcd_cam_dev_t *dev) -{ - return dev->lcd_user.lcd_2byte_en ? 16 : 8; -} - static inline void lcd_ll_enable_output_always_on(lcd_cam_dev_t *dev, bool en) { dev->lcd_user.lcd_always_out_en = en; @@ -117,6 +129,7 @@ static inline void lcd_ll_start(lcd_cam_dev_t *dev) dev->lcd_user.lcd_start = 1; } +__attribute__((always_inline)) static inline void lcd_ll_stop(lcd_cam_dev_t *dev) { dev->lcd_user.lcd_start = 0; @@ -125,33 +138,35 @@ static inline void lcd_ll_stop(lcd_cam_dev_t *dev) static inline void lcd_ll_reset(lcd_cam_dev_t *dev) { - dev->lcd_user.lcd_reset = 1; - dev->lcd_user.lcd_reset = 0; + dev->lcd_user.lcd_reset = 1; // self clear } __attribute__((always_inline)) -static inline void lcd_ll_reverse_data_bit_order(lcd_cam_dev_t *dev, bool en) +static inline void lcd_ll_reverse_bit_order(lcd_cam_dev_t *dev, bool en) { // whether to change LCD_DATA_out[N:0] to LCD_DATA_out[0:N] dev->lcd_user.lcd_bit_order = en; } __attribute__((always_inline)) -static inline void lcd_ll_reverse_data_byte_order(lcd_cam_dev_t *dev, bool en) -{ - dev->lcd_user.lcd_byte_order = en; +static inline void lcd_ll_swap_byte_order(lcd_cam_dev_t *dev, uint32_t width, bool en) +{ + HAL_ASSERT(width == 8 || width == 16); + if (width == 8) { + // {B0}{B1}{B2}{B3} => {B1}{B0}{B3}{B2} + dev->lcd_user.lcd_8bits_order = en; + dev->lcd_user.lcd_byte_order = 0; + } else if (width == 16) { + // {B1,B0},{B3,B2} => {B0,B1}{B2,B3} + dev->lcd_user.lcd_byte_order = en; + dev->lcd_user.lcd_8bits_order = 0; + } } __attribute__((always_inline)) -static inline void lcd_ll_reverse_data_8bits_order(lcd_cam_dev_t *dev, bool en) -{ - dev->lcd_user.lcd_8bits_order = en; -} - static inline void lcd_ll_fifo_reset(lcd_cam_dev_t *dev) { - dev->lcd_misc.lcd_afifo_reset = 1; - dev->lcd_misc.lcd_afifo_reset = 0; + dev->lcd_misc.lcd_afifo_reset = 1; // self clear } __attribute__((always_inline)) @@ -171,6 +186,7 @@ static inline void lcd_ll_set_dc_delay_ticks(lcd_cam_dev_t *dev, uint32_t delay) __attribute__((always_inline)) static inline void lcd_ll_set_command(lcd_cam_dev_t *dev, uint32_t data_width, uint32_t command) { + HAL_ASSERT(data_width == 8 || data_width == 16); // if command phase has two cycles, in the first cycle, command[15:0] is sent out via lcd_data_out[15:0] // in the second cycle, command[31:16] is sent out via lcd_data_out[15:0] if (data_width == 8) { diff --git a/tools/sdk/esp32s3/include/hal/esp32s3/include/hal/rtc_cntl_ll.h b/tools/sdk/esp32s3/include/hal/esp32s3/include/hal/rtc_cntl_ll.h index 075b961aa25..3dfa5e3e71e 100644 --- a/tools/sdk/esp32s3/include/hal/esp32s3/include/hal/rtc_cntl_ll.h +++ b/tools/sdk/esp32s3/include/hal/esp32s3/include/hal/rtc_cntl_ll.h @@ -1,16 +1,8 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once @@ -52,11 +44,6 @@ static inline void rtc_cntl_ll_ext1_clear_wakeup_pins(void) REG_SET_BIT(RTC_CNTL_EXT_WAKEUP1_REG, RTC_CNTL_EXT_WAKEUP1_STATUS_CLR); } -static inline void rtc_cntl_ll_ulp_wakeup_enable(void) -{ - SET_PERI_REG_BITS(RTC_CNTL_STATE0_REG, RTC_CNTL_WAKEUP_ENA_V, 0x800, RTC_CNTL_WAKEUP_ENA_S); -} - static inline void rtc_cntl_ll_set_tagmem_retention_link_addr(uint32_t link_addr) { REG_SET_FIELD(APB_CTRL_RETENTION_CTRL1_REG, APB_CTRL_RETENTION_TAG_LINK_ADDR, link_addr); @@ -133,6 +120,13 @@ static inline void rtc_cntl_ll_disable_cpu_retention(void) REG_CLR_BIT(RTC_CNTL_RETENTION_CTRL_REG, RTC_CNTL_RETENTION_EN); } +static inline void rtc_cntl_ll_ulp_int_clear(void) +{ + REG_SET_BIT(RTC_CNTL_INT_CLR_REG, RTC_CNTL_ULP_CP_INT_CLR); + REG_SET_BIT(RTC_CNTL_INT_CLR_REG, RTC_CNTL_COCPU_INT_CLR); + REG_SET_BIT(RTC_CNTL_INT_CLR_REG, RTC_CNTL_COCPU_TRAP_INT_CLR); +} + #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32s3/include/hal/esp32s3/include/hal/rtc_io_ll.h b/tools/sdk/esp32s3/include/hal/esp32s3/include/hal/rtc_io_ll.h index 2bd6d12fade..08a3c63e6ab 100644 --- a/tools/sdk/esp32s3/include/hal/esp32s3/include/hal/rtc_io_ll.h +++ b/tools/sdk/esp32s3/include/hal/esp32s3/include/hal/rtc_io_ll.h @@ -18,6 +18,8 @@ #include "hal/rtc_io_types.h" #include "hal/gpio_types.h" +#define RTCIO_LL_PIN_FUNC 0 + #ifdef __cplusplus extern "C" { #endif diff --git a/tools/sdk/esp32s3/include/hal/esp32s3/include/hal/spi_ll.h b/tools/sdk/esp32s3/include/hal/esp32s3/include/hal/spi_ll.h index a223b97600a..6058afe1e55 100644 --- a/tools/sdk/esp32s3/include/hal/esp32s3/include/hal/spi_ll.h +++ b/tools/sdk/esp32s3/include/hal/esp32s3/include/hal/spi_ll.h @@ -42,6 +42,8 @@ extern "C" { #define SPI_LL_PERIPH_CLK_FREQ (80 * 1000000) #define SPI_LL_GET_HW(ID) ((ID)==0? ({abort();NULL;}):((ID)==1? &GPSPI2 : &GPSPI3)) +#define SPI_LL_DATA_MAX_BIT_LEN (1 << 18) + /** * The data structure holding calculated clock configuration. Since the * calculation needs long time, it should be calculated during initialization and @@ -674,8 +676,8 @@ static inline int spi_ll_master_cal_clock(int fapb, int hz, int duty_cycle, spi_ if (pre <= 0) { pre = 1; } - if (pre > 8192) { - pre = 8192; + if (pre > 16) { + pre = 16; } errval = abs(spi_ll_freq_for_pre_n(fapb, pre, n) - hz); if (bestn == -1 || errval <= besterr) { diff --git a/tools/sdk/esp32s3/include/hal/include/hal/cpu_hal.h b/tools/sdk/esp32s3/include/hal/include/hal/cpu_hal.h index 824095871db..0e7e6f53a79 100644 --- a/tools/sdk/esp32s3/include/hal/include/hal/cpu_hal.h +++ b/tools/sdk/esp32s3/include/hal/include/hal/cpu_hal.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -70,11 +70,6 @@ extern "C" { */ #define cpu_hal_waiti() cpu_ll_waiti() -/** - * Trigger a syscall. - */ -#define cpu_hal_syscall(sys_nr, arg1, arg2, arg3, arg4, ret_errno) cpu_ll_syscall(sys_nr, arg1, arg2, arg3, arg4, ret_errno) - #if SOC_CPU_BREAKPOINTS_NUM > 0 /** diff --git a/tools/sdk/esp32s3/include/hal/include/hal/lcd_types.h b/tools/sdk/esp32s3/include/hal/include/hal/lcd_types.h index 1a62d8f8eb4..13810a79ac3 100644 --- a/tools/sdk/esp32s3/include/hal/include/hal/lcd_types.h +++ b/tools/sdk/esp32s3/include/hal/include/hal/lcd_types.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -19,6 +19,8 @@ extern "C" { * +=====================+=========================+============================+ * | LCD_CLK_SRC_PLL160M | High resolution | ESP_PM_APB_FREQ_MAX lock | * +---------------------+-------------------------+----------------------------+ + * | LCD_CLK_SRC_PLL240M | High resolution | ESP_PM_APB_FREQ_MAX lock | + * +---------------------+-------------------------+----------------------------+ * | LCD_CLK_SRC_APLL | Configurable resolution | ESP_PM_NO_LIGHT_SLEEP lock | * +---------------------+-------------------------+----------------------------+ * | LCD_CLK_SRC_XTAL | Medium resolution | No PM lock | @@ -27,6 +29,7 @@ extern "C" { */ typedef enum { LCD_CLK_SRC_PLL160M, /*!< Select PLL160M as the source clock */ + LCD_CLK_SRC_PLL240M, /*!< Select PLL240M as the source clock */ LCD_CLK_SRC_APLL, /*!< Select APLL as the source clock */ LCD_CLK_SRC_XTAL, /*!< Select XTAL as the source clock */ } lcd_clock_source_t; diff --git a/tools/sdk/esp32s3/include/hal/include/hal/rtc_hal.h b/tools/sdk/esp32s3/include/hal/include/hal/rtc_hal.h index 90f965ed58c..953123ec928 100644 --- a/tools/sdk/esp32s3/include/hal/include/hal/rtc_hal.h +++ b/tools/sdk/esp32s3/include/hal/include/hal/rtc_hal.h @@ -90,3 +90,5 @@ void rtc_cntl_hal_disable_tagmem_retention(void *addr); * Enable wakeup from ULP coprocessor. */ #define rtc_hal_ulp_wakeup_enable() rtc_cntl_ll_ulp_wakeup_enable() + +#define rtc_hal_ulp_int_clear() rtc_cntl_ll_ulp_int_clear() diff --git a/tools/sdk/esp32s3/include/hal/include/hal/systimer_types.h b/tools/sdk/esp32s3/include/hal/include/hal/systimer_types.h index 2af2f60f30c..d4583dc7ae0 100644 --- a/tools/sdk/esp32s3/include/hal/include/hal/systimer_types.h +++ b/tools/sdk/esp32s3/include/hal/include/hal/systimer_types.h @@ -30,6 +30,9 @@ typedef struct { struct { uint64_t lo : SOC_SYSTIMER_BIT_WIDTH_LO; /*!< Low part of counter value */ uint64_t hi : SOC_SYSTIMER_BIT_WIDTH_HI; /*!< High part of counter value */ +#if (SOC_SYSTIMER_BIT_WIDTH_LO + SOC_SYSTIMER_BIT_WIDTH_HI) < 64 + uint64_t reserved: (64 - (SOC_SYSTIMER_BIT_WIDTH_LO + SOC_SYSTIMER_BIT_WIDTH_HI)); +#endif }; uint64_t val; /*!< counter value */ }; diff --git a/tools/sdk/esp32s3/include/json_generator/upstream/json_generator.h b/tools/sdk/esp32s3/include/json_generator/upstream/json_generator.h index e3aa92eeecf..30e6a8dca74 100644 --- a/tools/sdk/esp32s3/include/json_generator/upstream/json_generator.h +++ b/tools/sdk/esp32s3/include/json_generator/upstream/json_generator.h @@ -174,7 +174,7 @@ int json_gen_end_array(json_gen_str_t *jstr); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that */ -int json_gen_push_object(json_gen_str_t *jstr, char *name); +int json_gen_push_object(json_gen_str_t *jstr, const char *name); /** Pop a named JSON object * @@ -208,7 +208,7 @@ int json_gen_pop_object(json_gen_str_t *jstr); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that. */ -int json_gen_push_object_str(json_gen_str_t *jstr, char *name, char *object_str); +int json_gen_push_object_str(json_gen_str_t *jstr, const char *name, const char *object_str); /** Push a named JSON array * @@ -223,7 +223,7 @@ int json_gen_push_object_str(json_gen_str_t *jstr, char *name, char *object_str) * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that */ -int json_gen_push_array(json_gen_str_t *jstr, char *name); +int json_gen_push_array(json_gen_str_t *jstr, const char *name); /** Pop a named JSON array * @@ -257,7 +257,7 @@ int json_gen_pop_array(json_gen_str_t *jstr); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that. */ -int json_gen_push_array_str(json_gen_str_t *jstr, char *name, char *array_str); +int json_gen_push_array_str(json_gen_str_t *jstr, const char *name, const char *array_str); /** Add a boolean element to an object * @@ -276,7 +276,7 @@ int json_gen_push_array_str(json_gen_str_t *jstr, char *name, char *array_str); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that */ -int json_gen_obj_set_bool(json_gen_str_t *jstr, char *name, bool val); +int json_gen_obj_set_bool(json_gen_str_t *jstr, const char *name, bool val); /** Add an integer element to an object * @@ -295,7 +295,7 @@ int json_gen_obj_set_bool(json_gen_str_t *jstr, char *name, bool val); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that */ -int json_gen_obj_set_int(json_gen_str_t *jstr, char *name, int val); +int json_gen_obj_set_int(json_gen_str_t *jstr, const char *name, int val); /** Add a float element to an object * @@ -314,7 +314,7 @@ int json_gen_obj_set_int(json_gen_str_t *jstr, char *name, int val); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that */ -int json_gen_obj_set_float(json_gen_str_t *jstr, char *name, float val); +int json_gen_obj_set_float(json_gen_str_t *jstr, const char *name, float val); /** Add a string element to an object * @@ -333,7 +333,7 @@ int json_gen_obj_set_float(json_gen_str_t *jstr, char *name, float val); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that */ -int json_gen_obj_set_string(json_gen_str_t *jstr, char *name, char *val); +int json_gen_obj_set_string(json_gen_str_t *jstr, const char *name, const char *val); /** Add a NULL element to an object * @@ -351,7 +351,7 @@ int json_gen_obj_set_string(json_gen_str_t *jstr, char *name, char *val); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that */ -int json_gen_obj_set_null(json_gen_str_t *jstr, char *name); +int json_gen_obj_set_null(json_gen_str_t *jstr, const char *name); /** Add a boolean element to an array * @@ -415,7 +415,7 @@ int json_gen_arr_set_float(json_gen_str_t *jstr, float val); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that */ -int json_gen_arr_set_string(json_gen_str_t *jstr, char *val); +int json_gen_arr_set_string(json_gen_str_t *jstr, const char *val); /** Add a NULL element to an array * @@ -452,7 +452,7 @@ int json_gen_arr_set_null(json_gen_str_t *jstr); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that */ -int json_gen_obj_start_long_string(json_gen_str_t *jstr, char *name, char *val); +int json_gen_obj_start_long_string(json_gen_str_t *jstr, const char *name, const char *val); /** Start a Long string in an array * @@ -473,7 +473,7 @@ int json_gen_obj_start_long_string(json_gen_str_t *jstr, char *name, char *val); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that */ -int json_gen_arr_start_long_string(json_gen_str_t *jstr, char *val); +int json_gen_arr_start_long_string(json_gen_str_t *jstr, const char *val); /** Add to a JSON Long string * @@ -489,7 +489,7 @@ int json_gen_arr_start_long_string(json_gen_str_t *jstr, char *val); * is passed to json_gen_str_start(). Else, buffer will be flushed out and new data * added after that */ -int json_gen_add_to_long_string(json_gen_str_t *jstr, char *val); +int json_gen_add_to_long_string(json_gen_str_t *jstr, const char *val); /** End a JSON Long string * diff --git a/tools/sdk/esp32s3/include/json_parser/upstream/include/json_parser.h b/tools/sdk/esp32s3/include/json_parser/upstream/include/json_parser.h index 3e982fe14eb..8e92fe7d63f 100644 --- a/tools/sdk/esp32s3/include/json_parser/upstream/include/json_parser.h +++ b/tools/sdk/esp32s3/include/json_parser/upstream/include/json_parser.h @@ -16,6 +16,7 @@ #ifndef _JSON_PARSER_H_ #define _JSON_PARSER_H_ +#define JSMN_PARENT_LINKS #define JSMN_HEADER #include #include @@ -34,29 +35,31 @@ typedef jsmntok_t json_tok_t; typedef struct { json_parser_t parser; - char *js; + const char *js; json_tok_t *tokens; json_tok_t *cur; int num_tokens; } jparse_ctx_t; -int json_parse_start(jparse_ctx_t *jctx, char *js, int len); +int json_parse_start(jparse_ctx_t *jctx, const char *js, int len); int json_parse_end(jparse_ctx_t *jctx); +int json_parse_start_static(jparse_ctx_t *jctx, const char *js, int len, json_tok_t *buffer_tokens, int buffer_tokens_max_count); +int json_parse_end_static(jparse_ctx_t *jctx); -int json_obj_get_array(jparse_ctx_t *jctx, char *name, int *num_elem); +int json_obj_get_array(jparse_ctx_t *jctx, const char *name, int *num_elem); int json_obj_leave_array(jparse_ctx_t *jctx); -int json_obj_get_object(jparse_ctx_t *jctx, char *name); +int json_obj_get_object(jparse_ctx_t *jctx, const char *name); int json_obj_leave_object(jparse_ctx_t *jctx); -int json_obj_get_bool(jparse_ctx_t *jctx, char *name, bool *val); -int json_obj_get_int(jparse_ctx_t *jctx, char *name, int *val); -int json_obj_get_int64(jparse_ctx_t *jctx, char *name, int64_t *val); -int json_obj_get_float(jparse_ctx_t *jctx, char *name, float *val); -int json_obj_get_string(jparse_ctx_t *jctx, char *name, char *val, int size); -int json_obj_get_strlen(jparse_ctx_t *jctx, char *name, int *strlen); -int json_obj_get_object_str(jparse_ctx_t *jctx, char *name, char *val, int size); -int json_obj_get_object_strlen(jparse_ctx_t *jctx, char *name, int *strlen); -int json_obj_get_array_str(jparse_ctx_t *jctx, char *name, char *val, int size); -int json_obj_get_array_strlen(jparse_ctx_t *jctx, char *name, int *strlen); +int json_obj_get_bool(jparse_ctx_t *jctx, const char *name, bool *val); +int json_obj_get_int(jparse_ctx_t *jctx, const char *name, int *val); +int json_obj_get_int64(jparse_ctx_t *jctx, const char *name, int64_t *val); +int json_obj_get_float(jparse_ctx_t *jctx, const char *name, float *val); +int json_obj_get_string(jparse_ctx_t *jctx, const char *name, char *val, int size); +int json_obj_get_strlen(jparse_ctx_t *jctx, const char *name, int *strlen); +int json_obj_get_object_str(jparse_ctx_t *jctx, const char *name, char *val, int size); +int json_obj_get_object_strlen(jparse_ctx_t *jctx, const char *name, int *strlen); +int json_obj_get_array_str(jparse_ctx_t *jctx, const char *name, char *val, int size); +int json_obj_get_array_strlen(jparse_ctx_t *jctx, const char *name, int *strlen); int json_arr_get_array(jparse_ctx_t *jctx, uint32_t index); int json_arr_leave_array(jparse_ctx_t *jctx); @@ -74,3 +77,4 @@ int json_arr_get_strlen(jparse_ctx_t *jctx, uint32_t index, int *strlen); #endif #endif /* _JSON_PARSER_H_ */ + diff --git a/tools/sdk/esp32s3/include/lwip/lwip/src/include/lwip/dns.h b/tools/sdk/esp32s3/include/lwip/lwip/src/include/lwip/dns.h index db52fedd1da..7c9933eaa32 100644 --- a/tools/sdk/esp32s3/include/lwip/lwip/src/include/lwip/dns.h +++ b/tools/sdk/esp32s3/include/lwip/lwip/src/include/lwip/dns.h @@ -113,6 +113,7 @@ err_t dns_gethostbyname_addrtype(const char *hostname, ip_addr_t *add u8_t dns_addrtype); #if ESP_DNS void dns_clear_servers(bool keep_fallback); +void dns_clear_cache(void); #endif #if DNS_LOCAL_HOSTLIST diff --git a/tools/sdk/esp32s3/include/lwip/lwip/src/include/lwip/init.h b/tools/sdk/esp32s3/include/lwip/lwip/src/include/lwip/init.h index c7f3eb99cbb..921573618d7 100644 --- a/tools/sdk/esp32s3/include/lwip/lwip/src/include/lwip/init.h +++ b/tools/sdk/esp32s3/include/lwip/lwip/src/include/lwip/init.h @@ -54,7 +54,7 @@ extern "C" { /** x.X.x: Minor version of the stack */ #define LWIP_VERSION_MINOR 1 /** x.x.X: Revision of the stack */ -#define LWIP_VERSION_REVISION 3 +#define LWIP_VERSION_REVISION 2 /** For release candidates, this is set to 1..254 * For official releases, this is set to 255 (LWIP_RC_RELEASE) * For development versions (Git), this is set to 0 (LWIP_RC_DEVELOPMENT) */ @@ -75,7 +75,7 @@ extern "C" { #if LWIP_VERSION_IS_RELEASE #define LWIP_VERSION_STRING_SUFFIX "" #elif LWIP_VERSION_IS_DEVELOPMENT -#define LWIP_VERSION_STRING_SUFFIX "d" +#define LWIP_VERSION_STRING_SUFFIX "esp" #else #define LWIP_VERSION_STRING_SUFFIX "rc" LWIP_VERSTR(LWIP_VERSION_RC) #endif diff --git a/tools/sdk/esp32s3/include/lwip/lwip/src/include/lwip/opt.h b/tools/sdk/esp32s3/include/lwip/lwip/src/include/lwip/opt.h index cdd7044c728..b314c59a439 100644 --- a/tools/sdk/esp32s3/include/lwip/lwip/src/include/lwip/opt.h +++ b/tools/sdk/esp32s3/include/lwip/lwip/src/include/lwip/opt.h @@ -2534,10 +2534,12 @@ /** * LWIP_ICMP6_DATASIZE: bytes from original packet to send back in - * ICMPv6 error messages. + * ICMPv6 error messages (0 = default of IP6_MIN_MTU_LENGTH) + * ATTENTION: RFC4443 section 2.4 says IP6_MIN_MTU_LENGTH is a MUST, + * so override this only if you absolutely have to! */ #if !defined LWIP_ICMP6_DATASIZE || defined __DOXYGEN__ -#define LWIP_ICMP6_DATASIZE 8 +#define LWIP_ICMP6_DATASIZE 0 #endif /** diff --git a/tools/sdk/esp32s3/include/lwip/lwip/src/include/lwip/pbuf.h b/tools/sdk/esp32s3/include/lwip/lwip/src/include/lwip/pbuf.h index deac38dcc47..2eedb956ee8 100644 --- a/tools/sdk/esp32s3/include/lwip/lwip/src/include/lwip/pbuf.h +++ b/tools/sdk/esp32s3/include/lwip/lwip/src/include/lwip/pbuf.h @@ -300,6 +300,7 @@ void pbuf_cat(struct pbuf *head, struct pbuf *tail); void pbuf_chain(struct pbuf *head, struct pbuf *tail); struct pbuf *pbuf_dechain(struct pbuf *p); err_t pbuf_copy(struct pbuf *p_to, const struct pbuf *p_from); +err_t pbuf_copy_partial_pbuf(struct pbuf *p_to, const struct pbuf *p_from, u16_t copy_len, u16_t offset); u16_t pbuf_copy_partial(const struct pbuf *p, void *dataptr, u16_t len, u16_t offset); void *pbuf_get_contiguous(const struct pbuf *p, void *buffer, size_t bufsize, u16_t len, u16_t offset); err_t pbuf_take(struct pbuf *buf, const void *dataptr, u16_t len); diff --git a/tools/sdk/esp32s3/include/lwip/lwip/src/include/lwip/prot/icmp6.h b/tools/sdk/esp32s3/include/lwip/lwip/src/include/lwip/prot/icmp6.h index 3461120421e..36989f6b32a 100644 --- a/tools/sdk/esp32s3/include/lwip/lwip/src/include/lwip/prot/icmp6.h +++ b/tools/sdk/esp32s3/include/lwip/lwip/src/include/lwip/prot/icmp6.h @@ -146,6 +146,8 @@ PACK_STRUCT_END # include "arch/epstruct.h" #endif +#define ICMP6_HLEN 8 + /** This is the ICMP6 header adapted for echo req/resp. */ #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/bpstruct.h" diff --git a/tools/sdk/esp32s3/include/lwip/lwip/src/include/lwip/prot/ip6.h b/tools/sdk/esp32s3/include/lwip/lwip/src/include/lwip/prot/ip6.h index 0f6de455932..7df81edd690 100644 --- a/tools/sdk/esp32s3/include/lwip/lwip/src/include/lwip/prot/ip6.h +++ b/tools/sdk/esp32s3/include/lwip/lwip/src/include/lwip/prot/ip6.h @@ -44,6 +44,8 @@ extern "C" { #endif +#define IP6_MIN_MTU_LENGTH 1280 + /** This is the packed version of ip6_addr_t, used in network headers that are itself packed */ #ifdef PACK_STRUCT_USE_INCLUDES diff --git a/tools/sdk/esp32s3/include/lwip/port/esp32/include/lwipopts.h b/tools/sdk/esp32s3/include/lwip/port/esp32/include/lwipopts.h index 47215e99dae..bb0d371c6ee 100644 --- a/tools/sdk/esp32s3/include/lwip/port/esp32/include/lwipopts.h +++ b/tools/sdk/esp32s3/include/lwip/port/esp32/include/lwipopts.h @@ -1007,6 +1007,7 @@ #define ESP_LWIP_SELECT 1 #define ESP_LWIP_LOCK 1 #define ESP_THREAD_PROTECTION 1 +#define ESP_IP_FORWARD 1 #ifdef CONFIG_LWIP_IPV6_AUTOCONFIG #define ESP_IPV6_AUTOCONFIG CONFIG_LWIP_IPV6_AUTOCONFIG diff --git a/tools/sdk/esp32s3/include/mbedtls/esp_crt_bundle/include/esp_crt_bundle.h b/tools/sdk/esp32s3/include/mbedtls/esp_crt_bundle/include/esp_crt_bundle.h index 33fb98b9969..49069185b3a 100644 --- a/tools/sdk/esp32s3/include/mbedtls/esp_crt_bundle/include/esp_crt_bundle.h +++ b/tools/sdk/esp32s3/include/mbedtls/esp_crt_bundle/include/esp_crt_bundle.h @@ -1,21 +1,14 @@ -// 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. +/* + * SPDX-FileCopyrightText: 2017-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ESP_CRT_BUNDLE_H_ #define _ESP_CRT_BUNDLE_H_ +#include "esp_err.h" #include "mbedtls/ssl.h" #ifdef __cplusplus @@ -52,13 +45,19 @@ void esp_crt_bundle_detach(mbedtls_ssl_config *conf); /** * @brief Set the default certificate bundle used for verification * - * Overrides the default certificate bundle. In most use cases the bundle should be + * Overrides the default certificate bundle only in case of successful initialization. In most use cases the bundle should be * set through menuconfig. The bundle needs to be sorted by subject name since binary search is * used to find certificates. * * @param[in] x509_bundle A pointer to the certificate bundle. + * + * @param[in] bundle_size Size of the certificate bundle in bytes. + * + * @return + * - ESP_OK if adding certificates was successful. + * - Other if an error occured or an action must be taken by the calling process. */ -void esp_crt_bundle_set(const uint8_t *x509_bundle); +esp_err_t esp_crt_bundle_set(const uint8_t *x509_bundle, size_t bundle_size); #ifdef __cplusplus diff --git a/tools/sdk/esp32s3/include/mqtt/esp-mqtt/include/mqtt_client.h b/tools/sdk/esp32s3/include/mqtt/esp-mqtt/include/mqtt_client.h index 475581b50db..07feed3c370 100644 --- a/tools/sdk/esp32s3/include/mqtt/esp-mqtt/include/mqtt_client.h +++ b/tools/sdk/esp32s3/include/mqtt/esp-mqtt/include/mqtt_client.h @@ -39,7 +39,11 @@ typedef enum { MQTT_EVENT_ERROR = 0, /*!< on error event, additional context: connection return code, error handle from esp_tls (if supported) */ MQTT_EVENT_CONNECTED, /*!< connected event, additional context: session_present flag */ MQTT_EVENT_DISCONNECTED, /*!< disconnected event */ - MQTT_EVENT_SUBSCRIBED, /*!< subscribed event, additional context: msg_id */ + MQTT_EVENT_SUBSCRIBED, /*!< subscribed event, additional context: + - msg_id message id + - data pointer to the received data + - data_len length of the data for this event + */ MQTT_EVENT_UNSUBSCRIBED, /*!< unsubscribed event */ MQTT_EVENT_PUBLISHED, /*!< published event, additional context: msg_id */ MQTT_EVENT_DATA, /*!< data event, additional context: @@ -51,6 +55,8 @@ typedef enum { - current_data_offset offset of the current data for this event - total_data_len total length of the data received - retain retain flag of the message + - qos qos level of the message + - dup dup flag of the message Note: Multiple MQTT_EVENT_DATA could be fired for one message, if it is longer than internal buffer. In that case only first event contains topic pointer and length, other contain data only with current data length @@ -153,6 +159,8 @@ typedef struct { int session_present; /*!< MQTT session_present flag for connection event */ esp_mqtt_error_codes_t *error_handle; /*!< esp-mqtt error handle including esp-tls errors as well as internal mqtt errors */ bool retain; /*!< Retained flag of the message associated with this event */ + int qos; /*!< qos of the messages associated with this event */ + bool dup; /*!< dup flag of the message associated with this event */ } esp_mqtt_event_t; typedef esp_mqtt_event_t *esp_mqtt_event_handle_t; @@ -168,7 +176,11 @@ typedef struct { const char *host; /*!< MQTT server domain (ipv4 as string) */ const char *uri; /*!< Complete MQTT broker URI */ uint32_t port; /*!< MQTT server port */ - const char *client_id; /*!< default client id is ``ESP32_%CHIPID%`` where %CHIPID% are last 3 bytes of MAC address in hex format */ + bool set_null_client_id; /*!< Selects a NULL client id */ + const char *client_id; /*!< Set client id. + Ignored if set_null_client_id == true + If NULL set the default client id. + Default client id is ``ESP32_%CHIPID%`` where %CHIPID% are last 3 bytes of MAC address in hex format */ const char *username; /*!< MQTT username */ const char *password; /*!< MQTT password */ const char *lwt_topic; /*!< LWT (Last Will and Testament) message topic (NULL by default) */ diff --git a/tools/sdk/esp32s3/include/newlib/platform_include/errno.h b/tools/sdk/esp32s3/include/newlib/platform_include/errno.h index 85fb2e15b85..98dedeef88a 100644 --- a/tools/sdk/esp32s3/include/newlib/platform_include/errno.h +++ b/tools/sdk/esp32s3/include/newlib/platform_include/errno.h @@ -1,17 +1,9 @@ -// Copyright 2018 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. +/* + * SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ESP_PLATFORM_ERRNO_H_ #define _ESP_PLATFORM_ERRNO_H_ @@ -21,7 +13,7 @@ // Possibly define some missing errors // #ifndef ESHUTDOWN -#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ +#define ESHUTDOWN 110 /* Cannot send after transport endpoint shutdown */ #endif #ifndef EAI_SOCKTYPE diff --git a/tools/sdk/esp32s3/include/nvs_flash/include/nvs.h b/tools/sdk/esp32s3/include/nvs_flash/include/nvs.h index 6a45327bbae..0faef98fd3d 100644 --- a/tools/sdk/esp32s3/include/nvs_flash/include/nvs.h +++ b/tools/sdk/esp32s3/include/nvs_flash/include/nvs.h @@ -40,7 +40,7 @@ typedef nvs_handle_t nvs_handle IDF_DEPRECATED("Replace with nvs_handle_t"); #define ESP_ERR_NVS_INVALID_STATE (ESP_ERR_NVS_BASE + 0x0b) /*!< NVS is in an inconsistent state due to a previous error. Call nvs_flash_init and nvs_open again, then retry. */ #define ESP_ERR_NVS_INVALID_LENGTH (ESP_ERR_NVS_BASE + 0x0c) /*!< String or blob length is not sufficient to store data */ #define ESP_ERR_NVS_NO_FREE_PAGES (ESP_ERR_NVS_BASE + 0x0d) /*!< NVS partition doesn't contain any empty pages. This may happen if NVS partition was truncated. Erase the whole partition and call nvs_flash_init again. */ -#define ESP_ERR_NVS_VALUE_TOO_LONG (ESP_ERR_NVS_BASE + 0x0e) /*!< String or blob length is longer than supported by the implementation */ +#define ESP_ERR_NVS_VALUE_TOO_LONG (ESP_ERR_NVS_BASE + 0x0e) /*!< Value doesn't fit into the entry or string or blob length is longer than supported by the implementation */ #define ESP_ERR_NVS_PART_NOT_FOUND (ESP_ERR_NVS_BASE + 0x0f) /*!< Partition with specified name is not found in the partition table */ #define ESP_ERR_NVS_NEW_VERSION_FOUND (ESP_ERR_NVS_BASE + 0x10) /*!< NVS partition contains data in new format and cannot be recognized by this version of code */ @@ -124,6 +124,8 @@ typedef struct nvs_opaque_iterator_t *nvs_iterator_t; * * @return * - ESP_OK if storage handle was opened successfully + * - ESP_FAIL if there is an internal error; most likely due to corrupted + * NVS partition (only if NVS assertion checks are disabled) * - ESP_ERR_NVS_NOT_INITIALIZED if the storage driver is not initialized * - ESP_ERR_NVS_PART_NOT_FOUND if the partition with label "nvs" is not found * - ESP_ERR_NVS_NOT_FOUND id namespace doesn't exist yet and @@ -151,6 +153,8 @@ esp_err_t nvs_open(const char* name, nvs_open_mode_t open_mode, nvs_handle_t *ou * * @return * - ESP_OK if storage handle was opened successfully + * - ESP_FAIL if there is an internal error; most likely due to corrupted + * NVS partition (only if NVS assertion checks are disabled) * - ESP_ERR_NVS_NOT_INITIALIZED if the storage driver is not initialized * - ESP_ERR_NVS_PART_NOT_FOUND if the partition with specified name is not found * - ESP_ERR_NVS_NOT_FOUND id namespace doesn't exist yet and @@ -175,6 +179,8 @@ esp_err_t nvs_open_from_partition(const char *part_name, const char* name, nvs_o * * @return * - ESP_OK if value was set successfully + * - ESP_FAIL if there is an internal error; most likely due to corrupted + * NVS partition (only if NVS assertion checks are disabled) * - ESP_ERR_NVS_INVALID_HANDLE if handle has been closed or is NULL * - ESP_ERR_NVS_READ_ONLY if storage handle was opened as read only * - ESP_ERR_NVS_INVALID_NAME if key name doesn't satisfy constraints @@ -282,6 +288,8 @@ esp_err_t nvs_set_str (nvs_handle_t handle, const char* key, const char* value); * * @return * - ESP_OK if value was set successfully + * - ESP_FAIL if there is an internal error; most likely due to corrupted + * NVS partition (only if NVS assertion checks are disabled) * - ESP_ERR_NVS_INVALID_HANDLE if handle has been closed or is NULL * - ESP_ERR_NVS_READ_ONLY if storage handle was opened as read only * - ESP_ERR_NVS_INVALID_NAME if key name doesn't satisfy constraints @@ -325,6 +333,8 @@ esp_err_t nvs_set_blob(nvs_handle_t handle, const char* key, const void* value, * * @return * - ESP_OK if the value was retrieved successfully + * - ESP_FAIL if there is an internal error; most likely due to corrupted + * NVS partition (only if NVS assertion checks are disabled) * - ESP_ERR_NVS_NOT_FOUND if the requested key doesn't exist * - ESP_ERR_NVS_INVALID_HANDLE if handle has been closed or is NULL * - ESP_ERR_NVS_INVALID_NAME if key name doesn't satisfy constraints @@ -432,6 +442,8 @@ esp_err_t nvs_get_u64 (nvs_handle_t handle, const char* key, uint64_t* out_value * * @return * - ESP_OK if the value was retrieved successfully + * - ESP_FAIL if there is an internal error; most likely due to corrupted + * NVS partition (only if NVS assertion checks are disabled) * - ESP_ERR_NVS_NOT_FOUND if the requested key doesn't exist * - ESP_ERR_NVS_INVALID_HANDLE if handle has been closed or is NULL * - ESP_ERR_NVS_INVALID_NAME if key name doesn't satisfy constraints @@ -459,6 +471,8 @@ esp_err_t nvs_get_blob(nvs_handle_t handle, const char* key, void* out_value, si * * @return * - ESP_OK if erase operation was successful + * - ESP_FAIL if there is an internal error; most likely due to corrupted + * NVS partition (only if NVS assertion checks are disabled) * - ESP_ERR_NVS_INVALID_HANDLE if handle has been closed or is NULL * - ESP_ERR_NVS_READ_ONLY if handle was opened as read only * - ESP_ERR_NVS_NOT_FOUND if the requested key doesn't exist @@ -476,6 +490,8 @@ esp_err_t nvs_erase_key(nvs_handle_t handle, const char* key); * * @return * - ESP_OK if erase operation was successful + * - ESP_FAIL if there is an internal error; most likely due to corrupted + * NVS partition (only if NVS assertion checks are disabled) * - ESP_ERR_NVS_INVALID_HANDLE if handle has been closed or is NULL * - ESP_ERR_NVS_READ_ONLY if handle was opened as read only * - other error codes from the underlying storage driver diff --git a/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protobuf-c/protobuf-c.h b/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protobuf-c/protobuf-c.h index c8fa4fc2a7c..b633722ed5e 100755 --- a/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protobuf-c/protobuf-c.h +++ b/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protobuf-c/protobuf-c.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008-2017, Dave Benson and the protobuf-c authors. + * Copyright (c) 2008-2018, Dave Benson and the protobuf-c authors. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -238,7 +238,11 @@ PROTOBUF_C__BEGIN_DECLS #define PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC 0x114315af /* Empty string used for initializers */ +#if defined(_WIN32) && defined(PROTOBUF_C_USE_SHARED_LIB) +static const char protobuf_c_empty_string[] = ""; +#else extern const char protobuf_c_empty_string[]; +#endif /** * \defgroup api Public API @@ -790,13 +794,13 @@ protobuf_c_version_number(void); * The version of the protobuf-c headers, represented as a string using the same * format as protobuf_c_version(). */ -#define PROTOBUF_C_VERSION "1.3.0" +#define PROTOBUF_C_VERSION "1.4.0" /** * The version of the protobuf-c headers, represented as an integer using the * same format as protobuf_c_version_number(). */ -#define PROTOBUF_C_VERSION_NUMBER 1003000 +#define PROTOBUF_C_VERSION_NUMBER 1004000 /** * The minimum protoc-c version which works with the current version of the diff --git a/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_bytes_field.h b/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_bytes_field.h index c4a71e85b47..bf873f0f763 100644 --- a/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_bytes_field.h +++ b/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_bytes_field.h @@ -82,11 +82,11 @@ class BytesFieldGenerator : public FieldGenerator { void GenerateDescriptorInitializer(io::Printer* printer) const; void GenerateDefaultValueDeclarations(io::Printer* printer) const; void GenerateDefaultValueImplementations(io::Printer* printer) const; - string GetDefaultValue(void) const; + std::string GetDefaultValue(void) const; void GenerateStaticInit(io::Printer* printer) const; private: - std::map variables_; + std::map variables_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(BytesFieldGenerator); }; diff --git a/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_enum.h b/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_enum.h index 9eb9a6679ce..9c34b697b82 100644 --- a/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_enum.h +++ b/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_enum.h @@ -81,7 +81,7 @@ class EnumGenerator { public: // See generator.cc for the meaning of dllexport_decl. explicit EnumGenerator(const EnumDescriptor* descriptor, - const string& dllexport_decl); + const std::string& dllexport_decl); ~EnumGenerator(); // Header stuff. @@ -105,7 +105,7 @@ class EnumGenerator { private: const EnumDescriptor* descriptor_; - string dllexport_decl_; + std::string dllexport_decl_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumGenerator); }; diff --git a/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_enum_field.h b/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_enum_field.h index 11df6824693..3f8c005d320 100644 --- a/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_enum_field.h +++ b/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_enum_field.h @@ -80,11 +80,11 @@ class EnumFieldGenerator : public FieldGenerator { // implements FieldGenerator --------------------------------------- void GenerateStructMembers(io::Printer* printer) const; void GenerateDescriptorInitializer(io::Printer* printer) const; - string GetDefaultValue(void) const; + std::string GetDefaultValue(void) const; void GenerateStaticInit(io::Printer* printer) const; private: - std::map variables_; + std::map variables_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumFieldGenerator); }; diff --git a/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_extension.h b/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_extension.h index ddbf270e5a1..95413885342 100644 --- a/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_extension.h +++ b/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_extension.h @@ -85,7 +85,7 @@ class ExtensionGenerator { public: // See generator.cc for the meaning of dllexport_decl. explicit ExtensionGenerator(const FieldDescriptor* descriptor, - const string& dllexport_decl); + const std::string& dllexport_decl); ~ExtensionGenerator(); // Header stuff. @@ -96,8 +96,8 @@ class ExtensionGenerator { private: const FieldDescriptor* descriptor_; - string type_traits_; - string dllexport_decl_; + std::string type_traits_; + std::string dllexport_decl_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ExtensionGenerator); }; diff --git a/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_field.h b/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_field.h index 91f1a03dafb..3cad35d3979 100644 --- a/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_field.h +++ b/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_field.h @@ -63,6 +63,7 @@ #ifndef GOOGLE_PROTOBUF_COMPILER_C_FIELD_H__ #define GOOGLE_PROTOBUF_COMPILER_C_FIELD_H__ +#include #include #include @@ -90,7 +91,7 @@ class FieldGenerator { virtual void GenerateDefaultValueDeclarations(io::Printer* printer) const { } virtual void GenerateDefaultValueImplementations(io::Printer* printer) const { } - virtual string GetDefaultValue() const = 0; + virtual std::string GetDefaultValue() const = 0; // Generate members to initialize this field from a static initializer virtual void GenerateStaticInit(io::Printer* printer) const = 0; @@ -99,8 +100,8 @@ class FieldGenerator { protected: void GenerateDescriptorInitializerGeneric(io::Printer* printer, bool optional_uses_has, - const string &type_macro, - const string &descriptor_addr) const; + const std::string &type_macro, + const std::string &descriptor_addr) const; const FieldDescriptor *descriptor_; private: @@ -117,7 +118,7 @@ class FieldGeneratorMap { private: const Descriptor* descriptor_; - scoped_array > field_generators_; + std::unique_ptr[]> field_generators_; static FieldGenerator* MakeGenerator(const FieldDescriptor* field); diff --git a/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_file.h b/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_file.h index ed38ce425c3..8dfd8ba0984 100644 --- a/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_file.h +++ b/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_file.h @@ -63,6 +63,7 @@ #ifndef GOOGLE_PROTOBUF_COMPILER_C_FILE_H__ #define GOOGLE_PROTOBUF_COMPILER_C_FILE_H__ +#include #include #include #include @@ -89,7 +90,7 @@ class FileGenerator { public: // See generator.cc for the meaning of dllexport_decl. explicit FileGenerator(const FileDescriptor* file, - const string& dllexport_decl); + const std::string& dllexport_decl); ~FileGenerator(); void GenerateHeader(io::Printer* printer); @@ -98,13 +99,10 @@ class FileGenerator { private: const FileDescriptor* file_; - scoped_array > message_generators_; - scoped_array > enum_generators_; - scoped_array > service_generators_; - scoped_array > extension_generators_; - - // E.g. if the package is foo.bar, package_parts_ is {"foo", "bar"}. - vector package_parts_; + std::unique_ptr[]> message_generators_; + std::unique_ptr[]> enum_generators_; + std::unique_ptr[]> service_generators_; + std::unique_ptr[]> extension_generators_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileGenerator); }; diff --git a/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_generator.h b/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_generator.h index f454710b36f..ac1ffafeab3 100644 --- a/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_generator.h +++ b/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_generator.h @@ -68,6 +68,12 @@ #include #include +#if defined(_WIN32) && defined(PROTOBUF_C_USE_SHARED_LIB) +# define PROTOC_C_EXPORT __declspec(dllexport) +#else +# define PROTOC_C_EXPORT +#endif + namespace google { namespace protobuf { namespace compiler { @@ -77,16 +83,16 @@ namespace c { // header. If you create your own protocol compiler binary and you want // it to support C++ output, you can do so by registering an instance of this // CodeGenerator with the CommandLineInterface in your main() function. -class LIBPROTOC_EXPORT CGenerator : public CodeGenerator { +class PROTOC_C_EXPORT CGenerator : public CodeGenerator { public: CGenerator(); ~CGenerator(); // implements CodeGenerator ---------------------------------------- bool Generate(const FileDescriptor* file, - const string& parameter, + const std::string& parameter, OutputDirectory* output_directory, - string* error) const; + std::string* error) const; private: GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CGenerator); diff --git a/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_helpers.h b/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_helpers.h index 9dc8c5e859c..7598a4e1da5 100644 --- a/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_helpers.h +++ b/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_helpers.h @@ -67,7 +67,7 @@ #include #include #include -#include +#include #include namespace google { @@ -75,31 +75,20 @@ namespace protobuf { namespace compiler { namespace c { -// Returns the non-nested type name for the given type. If "qualified" is -// true, prefix the type with the full namespace. For example, if you had: -// package foo.bar; -// message Baz { message Qux {} } -// Then the qualified ClassName for Qux would be: -// Foo__Bar__Baz_Qux -// While the non-qualified version would be: -// Baz_Qux -string ClassName(const Descriptor* descriptor, bool qualified); -string ClassName(const EnumDescriptor* enum_descriptor, bool qualified); - // --- Borrowed from stubs. --- -template string SimpleItoa(T n) { +template std::string SimpleItoa(T n) { std::stringstream stream; stream << n; return stream.str(); } -string SimpleFtoa(float f); -string SimpleDtoa(double f); -void SplitStringUsing(const string &str, const char *delim, std::vector *out); -string CEscape(const string& src); -string StringReplace(const string& s, const string& oldsub, const string& newsub, bool replace_all); -inline bool HasSuffixString(const string& str, const string& suffix) { return str.size() >= suffix.size() && str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0; } -inline string StripSuffixString(const string& str, const string& suffix) { if (HasSuffixString(str, suffix)) { return str.substr(0, str.size() - suffix.size()); } else { return str; } } +std::string SimpleFtoa(float f); +std::string SimpleDtoa(double f); +void SplitStringUsing(const std::string &str, const char *delim, std::vector *out); +std::string CEscape(const std::string& src); +std::string StringReplace(const std::string& s, const std::string& oldsub, const std::string& newsub, bool replace_all); +inline bool HasSuffixString(const std::string& str, const std::string& suffix) { return str.size() >= suffix.size() && str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0; } +inline std::string StripSuffixString(const std::string& str, const std::string& suffix) { if (HasSuffixString(str, suffix)) { return str.substr(0, str.size() - suffix.size()); } else { return str; } } char* FastHexToBuffer(int i, char* buffer); @@ -107,10 +96,10 @@ char* FastHexToBuffer(int i, char* buffer); // The name is coerced to lower-case to emulate proto1 behavior. People // should be using lowercase-with-underscores style for proto field names // anyway, so normally this just returns field->name(). -string FieldName(const FieldDescriptor* field); +std::string FieldName(const FieldDescriptor* field); // Get macro string for deprecated field -string FieldDeprecated(const FieldDescriptor* field); +std::string FieldDeprecated(const FieldDescriptor* field); // Returns the scope where the field was defined (for extensions, this is // different from the message type to which the field applies). @@ -121,31 +110,31 @@ inline const Descriptor* FieldScope(const FieldDescriptor* field) { // convert a CamelCase class name into an all uppercase affair // with underscores separating words, e.g. MyClass becomes MY_CLASS. -string CamelToUpper(const string &class_name); -string CamelToLower(const string &class_name); +std::string CamelToUpper(const std::string &class_name); +std::string CamelToLower(const std::string &class_name); // lowercased, underscored name to camel case -string ToCamel(const string &name); +std::string ToCamel(const std::string &name); // lowercase the string -string ToLower(const string &class_name); -string ToUpper(const string &class_name); +std::string ToLower(const std::string &class_name); +std::string ToUpper(const std::string &class_name); // full_name() to lowercase with underscores -string FullNameToLower(const string &full_name); -string FullNameToUpper(const string &full_name); +std::string FullNameToLower(const std::string &full_name, const FileDescriptor *file); +std::string FullNameToUpper(const std::string &full_name, const FileDescriptor *file); // full_name() to c-typename (with underscores for packages, otherwise camel case) -string FullNameToC(const string &class_name); +std::string FullNameToC(const std::string &class_name, const FileDescriptor *file); // Splits, indents, formats, and prints comment lines -void PrintComment (io::Printer* printer, string comment); +void PrintComment (io::Printer* printer, std::string comment); // make a string of spaces as long as input -string ConvertToSpaces(const string &input); +std::string ConvertToSpaces(const std::string &input); // Strips ".proto" or ".protodevel" from the end of a filename. -string StripProto(const string& filename); +std::string StripProto(const std::string& filename); // Get the C++ type name for a primitive type (e.g. "double", "::google::protobuf::int32", etc.). // Note: non-built-in type names will be qualified, meaning they will start @@ -159,18 +148,18 @@ const char* PrimitiveTypeName(FieldDescriptor::CppType type); const char* DeclaredTypeMethodName(FieldDescriptor::Type type); // Convert a file name into a valid identifier. -string FilenameIdentifier(const string& filename); +std::string FilenameIdentifier(const std::string& filename); // Return the name of the BuildDescriptors() function for a given file. -string GlobalBuildDescriptorsName(const string& filename); +std::string GlobalBuildDescriptorsName(const std::string& filename); // return 'required', 'optional', or 'repeated' -string GetLabelName(FieldDescriptor::Label label); +std::string GetLabelName(FieldDescriptor::Label label); // write IntRanges entries for a bunch of sorted values. // returns the number of ranges there are to bsearch. -unsigned WriteIntRanges(io::Printer* printer, int n_values, const int *values, const string &name); +unsigned WriteIntRanges(io::Printer* printer, int n_values, const int *values, const std::string &name); struct NameIndex { diff --git a/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_message.h b/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_message.h index 8b115d1c8cb..ea1c3ab3c8e 100644 --- a/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_message.h +++ b/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_message.h @@ -63,6 +63,7 @@ #ifndef GOOGLE_PROTOBUF_COMPILER_C_MESSAGE_H__ #define GOOGLE_PROTOBUF_COMPILER_C_MESSAGE_H__ +#include #include #include #include @@ -85,7 +86,7 @@ class MessageGenerator { public: // See generator.cc for the meaning of dllexport_decl. explicit MessageGenerator(const Descriptor* descriptor, - const string& dllexport_decl); + const std::string& dllexport_decl); ~MessageGenerator(); // Header stuff. @@ -110,25 +111,31 @@ class MessageGenerator { void GenerateStructStaticInitMacro(io::Printer* printer); // Generate standard helper functions declarations for this message. - void GenerateHelperFunctionDeclarations(io::Printer* printer, bool is_submessage); + void GenerateHelperFunctionDeclarations(io::Printer* printer, + bool is_pack_deep, + bool gen_pack, + bool gen_init); // Source file stuff. // Generate code that initializes the global variable storing the message's // descriptor. - void GenerateMessageDescriptor(io::Printer* printer); - void GenerateHelperFunctionDefinitions(io::Printer* printer, bool is_submessage); + void GenerateMessageDescriptor(io::Printer* printer, bool gen_init); + void GenerateHelperFunctionDefinitions(io::Printer* printer, + bool is_pack_deep, + bool gen_pack, + bool gen_init); private: - string GetDefaultValueC(const FieldDescriptor *fd); + std::string GetDefaultValueC(const FieldDescriptor *fd); const Descriptor* descriptor_; - string dllexport_decl_; + std::string dllexport_decl_; FieldGeneratorMap field_generators_; - scoped_array > nested_generators_; - scoped_array > enum_generators_; - scoped_array > extension_generators_; + std::unique_ptr[]> nested_generators_; + std::unique_ptr[]> enum_generators_; + std::unique_ptr[]> extension_generators_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageGenerator); }; diff --git a/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_message_field.h b/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_message_field.h index b059fb031b0..39b8d999bfa 100644 --- a/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_message_field.h +++ b/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_message_field.h @@ -80,7 +80,7 @@ class MessageFieldGenerator : public FieldGenerator { // implements FieldGenerator --------------------------------------- void GenerateStructMembers(io::Printer* printer) const; void GenerateDescriptorInitializer(io::Printer* printer) const; - string GetDefaultValue(void) const; + std::string GetDefaultValue(void) const; void GenerateStaticInit(io::Printer* printer) const; private: diff --git a/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_primitive_field.h b/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_primitive_field.h index 5ff254c5dd8..a9eb893bb72 100644 --- a/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_primitive_field.h +++ b/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_primitive_field.h @@ -80,7 +80,7 @@ class PrimitiveFieldGenerator : public FieldGenerator { // implements FieldGenerator --------------------------------------- void GenerateStructMembers(io::Printer* printer) const; void GenerateDescriptorInitializer(io::Printer* printer) const; - string GetDefaultValue(void) const; + std::string GetDefaultValue(void) const; void GenerateStaticInit(io::Printer* printer) const; private: diff --git a/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_service.h b/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_service.h index 6f1798ca724..27125a601a5 100644 --- a/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_service.h +++ b/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_service.h @@ -82,7 +82,7 @@ class ServiceGenerator { public: // See generator.cc for the meaning of dllexport_decl. explicit ServiceGenerator(const ServiceDescriptor* descriptor, - const string& dllexport_decl); + const std::string& dllexport_decl); ~ServiceGenerator(); // Header stuff. @@ -99,7 +99,7 @@ class ServiceGenerator { void GenerateCallersImplementations(io::Printer* printer); const ServiceDescriptor* descriptor_; - std::map vars_; + std::map vars_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ServiceGenerator); }; diff --git a/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_string_field.h b/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_string_field.h index 68f0d25b7dd..513cea75306 100644 --- a/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_string_field.h +++ b/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/protoc-c/c_string_field.h @@ -82,11 +82,11 @@ class StringFieldGenerator : public FieldGenerator { void GenerateDescriptorInitializer(io::Printer* printer) const; void GenerateDefaultValueDeclarations(io::Printer* printer) const; void GenerateDefaultValueImplementations(io::Printer* printer) const; - string GetDefaultValue(void) const; + std::string GetDefaultValue(void) const; void GenerateStaticInit(io::Printer* printer) const; private: - std::map variables_; + std::map variables_; GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StringFieldGenerator); }; diff --git a/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/t/generated-code2/common-test-arrays.h b/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/t/generated-code2/common-test-arrays.h index 1535d38e821..c5e37223c1a 100644 --- a/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/t/generated-code2/common-test-arrays.h +++ b/tools/sdk/esp32s3/include/protobuf-c/protobuf-c/t/generated-code2/common-test-arrays.h @@ -56,7 +56,7 @@ TEST_ENUM_TYPE_NAME enum_random[] = { T(0), T(2097152), T(268435455), T(127), T(16383), T(16384) }; #undef T -char *repeated_strings_0[] = { (char*)"onestring" }; -char *repeated_strings_1[] = { (char*)"two", (char*)"string" }; -char *repeated_strings_2[] = { (char*)"many", (char*)"tiny", (char*)"little", (char*)"strings", (char*)"should", (char*)"be", (char*)"handled" }; -char *repeated_strings_3[] = { (char*)"one very long strings XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" }; +const char *repeated_strings_0[] = { "onestring" }; +const char *repeated_strings_1[] = { "two", "string" }; +const char *repeated_strings_2[] = { "many", "tiny", "little", "strings", "should", "be", "handled" }; +const char *repeated_strings_3[] = { "one very long strings XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" }; diff --git a/tools/sdk/esp32s3/include/protocomm/include/transports/protocomm_ble.h b/tools/sdk/esp32s3/include/protocomm/include/transports/protocomm_ble.h index f899f95b188..2447c1c5d25 100644 --- a/tools/sdk/esp32s3/include/protocomm/include/transports/protocomm_ble.h +++ b/tools/sdk/esp32s3/include/protocomm/include/transports/protocomm_ble.h @@ -82,6 +82,9 @@ typedef struct protocomm_ble_config { /* BLE bonding */ unsigned ble_bonding:1; + /* BLE security flag */ + unsigned ble_sm_sc:1; + } protocomm_ble_config_t; /** diff --git a/tools/sdk/esp32s3/include/rmaker_common/include/esp_rmaker_mqtt_glue.h b/tools/sdk/esp32s3/include/rmaker_common/include/esp_rmaker_mqtt_glue.h index 95744bdf58c..9355d034ef4 100644 --- a/tools/sdk/esp32s3/include/rmaker_common/include/esp_rmaker_mqtt_glue.h +++ b/tools/sdk/esp32s3/include/rmaker_common/include/esp_rmaker_mqtt_glue.h @@ -155,6 +155,12 @@ typedef struct { */ esp_err_t esp_rmaker_mqtt_glue_setup(esp_rmaker_mqtt_config_t *mqtt_config); +/* Get the ESP AWS PPI String + * + * @return pointer to a NULL terminated PPI string on success. + * @return NULL in case of any error. + */ +const char *esp_get_aws_ppi(void); #ifdef __cplusplus } #endif diff --git a/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/efuse_reg.h b/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/efuse_reg.h index b4d10f3f661..df7a70a56fa 100644 --- a/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/efuse_reg.h +++ b/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/efuse_reg.h @@ -429,18 +429,18 @@ apping gpio10 when both reg_dis_usb_jtag and reg_dis_pad_jtag are equal to 0..*/ #define EFUSE_KEY_PURPOSE_2_S 0 #define EFUSE_RD_REPEAT_DATA3_REG (DR_REG_EFUSE_BASE + 0x3C) -/* EFUSE_RPT4_RESERVED1 : RO ;bitpos:[31] ;default: 1'h0 ; */ -/*description: Reserved (used for four backups method)..*/ -#define EFUSE_RPT4_RESERVED1 (BIT(31)) -#define EFUSE_RPT4_RESERVED1_M (BIT(31)) +/* EFUSE_DIS_USB_OTG_DOWNLOAD_MODE : RO ;bitpos:[31] ;default: 1'h0 ; */ +/*description: Set this bit to disable download through USB-OTG*/ +#define EFUSE_DIS_USB_OTG_DOWNLOAD_MODE (BIT(31)) +#define EFUSE_DIS_USB_OTG_DOWNLOAD_MODE_M (BIT(31)) +#define EFUSE_DIS_USB_OTG_DOWNLOAD_MODE_V 0x1 +#define EFUSE_DIS_USB_OTG_DOWNLOAD_MODE_S 31 +/* EFUSE_RPT4_RESERVED1 : RO ;bitpos:[30] ;default: 1'h0 ; */ +/*description: Reserved (used for four backups method).*/ +#define EFUSE_RPT4_RESERVED1 (BIT(30)) +#define EFUSE_RPT4_RESERVED1_M (BIT(30)) #define EFUSE_RPT4_RESERVED1_V 0x1 -#define EFUSE_RPT4_RESERVED1_S 31 -/* EFUSE_POWERGLITCH_EN : RO ;bitpos:[30] ;default: 1'b0 ; */ -/*description: Set this bit to enable power glitch function..*/ -#define EFUSE_POWERGLITCH_EN (BIT(30)) -#define EFUSE_POWERGLITCH_EN_M (BIT(30)) -#define EFUSE_POWERGLITCH_EN_V 0x1 -#define EFUSE_POWERGLITCH_EN_S 30 +#define EFUSE_RPT4_RESERVED1_S 30 /* EFUSE_SECURE_VERSION : RO ;bitpos:[29:14] ;default: 16'h0 ; */ /*description: Secure version (used by ESP-IDF anti-rollback feature)..*/ #define EFUSE_SECURE_VERSION 0x0000FFFF @@ -490,12 +490,12 @@ apping gpio10 when both reg_dis_usb_jtag and reg_dis_pad_jtag are equal to 0..*/ #define EFUSE_ENABLE_SECURITY_DOWNLOAD_M (BIT(5)) #define EFUSE_ENABLE_SECURITY_DOWNLOAD_V 0x1 #define EFUSE_ENABLE_SECURITY_DOWNLOAD_S 5 -/* EFUSE_DIS_USB_DOWNLOAD_MODE : RO ;bitpos:[4] ;default: 1'b0 ; */ -/*description: Set this bit to disable UART download mode through USB..*/ -#define EFUSE_DIS_USB_DOWNLOAD_MODE (BIT(4)) -#define EFUSE_DIS_USB_DOWNLOAD_MODE_M (BIT(4)) -#define EFUSE_DIS_USB_DOWNLOAD_MODE_V 0x1 -#define EFUSE_DIS_USB_DOWNLOAD_MODE_S 4 +/* EFUSE_DIS_USB_SERIAL_JTAG_DOWNLOAD_MODE : RO ;bitpos:[4] ;default: 1'b0 ; */ +/*description: Set this bit to disable download through USB-Seial-JTAG.*/ +#define EFUSE_DIS_USB_SERIAL_JTAG_DOWNLOAD_MODE (BIT(4)) +#define EFUSE_DIS_USB_SERIAL_JTAG_DOWNLOAD_MODE_M (BIT(4)) +#define EFUSE_DIS_USB_SERIAL_JTAG_DOWNLOAD_MODE_V 0x1 +#define EFUSE_DIS_USB_SERIAL_JTAG_DOWNLOAD_MODE_S 4 /* EFUSE_FLASH_ECC_MODE : RO ;bitpos:[3] ;default: 1'b0 ; */ /*description: Set ECC mode in ROM, 0: ROM would Enable Flash ECC 16to18 byte mode. 1:ROM would use 16to17 byte mode..*/ @@ -503,18 +503,18 @@ apping gpio10 when both reg_dis_usb_jtag and reg_dis_pad_jtag are equal to 0..*/ #define EFUSE_FLASH_ECC_MODE_M (BIT(3)) #define EFUSE_FLASH_ECC_MODE_V 0x1 #define EFUSE_FLASH_ECC_MODE_S 3 -/* EFUSE_UART_PRINT_CHANNEL : RO ;bitpos:[2] ;default: 1'b0 ; */ -/*description: Selectes the default UART print channel. 0: UART0. 1: UART1..*/ -#define EFUSE_UART_PRINT_CHANNEL (BIT(2)) -#define EFUSE_UART_PRINT_CHANNEL_M (BIT(2)) -#define EFUSE_UART_PRINT_CHANNEL_V 0x1 -#define EFUSE_UART_PRINT_CHANNEL_S 2 -/* EFUSE_DIS_LEGACY_SPI_BOOT : RO ;bitpos:[1] ;default: 1'b0 ; */ -/*description: Set this bit to disable Legacy SPI boot mode (boot_mode[3:0] = 4)..*/ -#define EFUSE_DIS_LEGACY_SPI_BOOT (BIT(1)) -#define EFUSE_DIS_LEGACY_SPI_BOOT_M (BIT(1)) -#define EFUSE_DIS_LEGACY_SPI_BOOT_V 0x1 -#define EFUSE_DIS_LEGACY_SPI_BOOT_S 1 +/* EFUSE_DIS_USB_SERIAL_JTAG_ROM_PRINT : RO ;bitpos:[2] ;default: 1'b0 ; */ +/*description: Disable USB-Serial-JTAG print during rom boot.*/ +#define EFUSE_DIS_USB_SERIAL_JTAG_ROM_PRINT (BIT(2)) +#define EFUSE_DIS_USB_SERIAL_JTAG_ROM_PRINT_M (BIT(2)) +#define EFUSE_DIS_USB_SERIAL_JTAG_ROM_PRINT_V 0x1 +#define EFUSE_DIS_USB_SERIAL_JTAG_ROM_PRINT_S 2 +/* EFUSE_DIS_DIRECT_BOOT : RO ;bitpos:[1] ;default: 1'b0 ; */ +/*description: Set this bit to disable direct boot.*/ +#define EFUSE_DIS_DIRECT_BOOT (BIT(1)) +#define EFUSE_DIS_DIRECT_BOOT_M (BIT(1)) +#define EFUSE_DIS_DIRECT_BOOT_V 0x1 +#define EFUSE_DIS_DIRECT_BOOT_S 1 /* EFUSE_DIS_DOWNLOAD_MODE : RO ;bitpos:[0] ;default: 1'b0 ; */ /*description: Set this bit to disable download mode (boot_mode[3:0] = 0, 1, 2, 3, 6, 7)..*/ #define EFUSE_DIS_DOWNLOAD_MODE (BIT(0)) @@ -1473,18 +1473,18 @@ apping gpio10 when both reg_dis_usb_jtag and reg_dis_pad_jtag are equal to 0..*/ #define EFUSE_KEY_PURPOSE_2_ERR_S 0 #define EFUSE_RD_REPEAT_ERR3_REG (DR_REG_EFUSE_BASE + 0x188) -/* EFUSE_RPT4_RESERVED1_ERR : RO ;bitpos:[31] ;default: 1'h0 ; */ -/*description: Reserved..*/ -#define EFUSE_RPT4_RESERVED1_ERR (BIT(31)) -#define EFUSE_RPT4_RESERVED1_ERR_M (BIT(31)) +/* EFUSE_DIS_USB_OTG_DOWNLOAD_MODE_ERR : RO ;bitpos:[31] ;default: 1'h0 ; */ +/*description: Set this bit to disable download through USB-OTG.*/ +#define EFUSE_DIS_USB_OTG_DOWNLOAD_MODE_ERR (BIT(31)) +#define EFUSE_DIS_USB_OTG_DOWNLOAD_MODE_ERR_M (BIT(31)) +#define EFUSE_DIS_USB_OTG_DOWNLOAD_MODE_ERR_V 0x1 +#define EFUSE_DIS_USB_OTG_DOWNLOAD_MODE_ERR_S 31 +/* EFUSE_RPT4_RESERVED1_ERR : RO ;bitpos:[30] ;default: 1'h0 ; */ +/*description: Reserved.*/ +#define EFUSE_RPT4_RESERVED1_ERR (BIT(30)) +#define EFUSE_RPT4_RESERVED1_ERR_M (BIT(30)) #define EFUSE_RPT4_RESERVED1_ERR_V 0x1 -#define EFUSE_RPT4_RESERVED1_ERR_S 31 -/* EFUSE_POWERGLITCH_EN_ERR : RO ;bitpos:[30] ;default: 1'b0 ; */ -/*description: .*/ -#define EFUSE_POWERGLITCH_EN_ERR (BIT(30)) -#define EFUSE_POWERGLITCH_EN_ERR_M (BIT(30)) -#define EFUSE_POWERGLITCH_EN_ERR_V 0x1 -#define EFUSE_POWERGLITCH_EN_ERR_S 30 +#define EFUSE_RPT4_RESERVED1_ERR_S 30 /* EFUSE_SECURE_VERSION_ERR : RO ;bitpos:[29:14] ;default: 16'h0 ; */ /*description: If any bits in this filed are 1, then it indicates a programming error..*/ #define EFUSE_SECURE_VERSION_ERR 0x0000FFFF @@ -1533,30 +1533,30 @@ apping gpio10 when both reg_dis_usb_jtag and reg_dis_pad_jtag are equal to 0..*/ #define EFUSE_ENABLE_SECURITY_DOWNLOAD_ERR_M (BIT(5)) #define EFUSE_ENABLE_SECURITY_DOWNLOAD_ERR_V 0x1 #define EFUSE_ENABLE_SECURITY_DOWNLOAD_ERR_S 5 -/* EFUSE_DIS_USB_DOWNLOAD_MODE_ERR : RO ;bitpos:[4] ;default: 1'b0 ; */ +/* EFUSE_DIS_USB_SERIAL_JTAG_DOWNLOAD_MODE_ERR : RO ;bitpos:[4] ;default: 1'b0 ; */ /*description: If any bits in this filed are 1, then it indicates a programming error..*/ -#define EFUSE_DIS_USB_DOWNLOAD_MODE_ERR (BIT(4)) -#define EFUSE_DIS_USB_DOWNLOAD_MODE_ERR_M (BIT(4)) -#define EFUSE_DIS_USB_DOWNLOAD_MODE_ERR_V 0x1 -#define EFUSE_DIS_USB_DOWNLOAD_MODE_ERR_S 4 +#define EFUSE_DIS_USB_SERIAL_JTAG_DOWNLOAD_MODE_ERR (BIT(4)) +#define EFUSE_DIS_USB_SERIAL_JTAG_DOWNLOAD_MODE_ERR_M (BIT(4)) +#define EFUSE_DIS_USB_SERIAL_JTAG_DOWNLOAD_MODE_ERR_V 0x1 +#define EFUSE_DIS_USB_SERIAL_JTAG_DOWNLOAD_MODE_ERR_S 4 /* EFUSE_FLASH_ECC_MODE_ERR : RO ;bitpos:[3] ;default: 1'b0 ; */ /*description: If any bits in this filed are 1, then it indicates a programming error..*/ #define EFUSE_FLASH_ECC_MODE_ERR (BIT(3)) #define EFUSE_FLASH_ECC_MODE_ERR_M (BIT(3)) #define EFUSE_FLASH_ECC_MODE_ERR_V 0x1 #define EFUSE_FLASH_ECC_MODE_ERR_S 3 -/* EFUSE_UART_PRINT_CHANNEL_ERR : RO ;bitpos:[2] ;default: 1'b0 ; */ +/* EFUSE_DIS_USB_SERIAL_JTAG_ROM_PRINT_ERR : RO ;bitpos:[2] ;default: 1'b0 ; */ /*description: If any bits in this filed are 1, then it indicates a programming error..*/ -#define EFUSE_UART_PRINT_CHANNEL_ERR (BIT(2)) -#define EFUSE_UART_PRINT_CHANNEL_ERR_M (BIT(2)) -#define EFUSE_UART_PRINT_CHANNEL_ERR_V 0x1 -#define EFUSE_UART_PRINT_CHANNEL_ERR_S 2 -/* EFUSE_DIS_LEGACY_SPI_BOOT_ERR : RO ;bitpos:[1] ;default: 1'b0 ; */ +#define EFUSE_DIS_USB_SERIAL_JTAG_ROM_PRINT_ERR (BIT(2)) +#define EFUSE_DIS_USB_SERIAL_JTAG_ROM_PRINT_ERR_M (BIT(2)) +#define EFUSE_DIS_USB_SERIAL_JTAG_ROM_PRINT_ERR_V 0x1 +#define EFUSE_DIS_USB_SERIAL_JTAG_ROM_PRINT_ERR_S 2 +/* EFUSE_DIS_DIRECT_BOOT_ERR : RO ;bitpos:[1] ;default: 1'b0 ; */ /*description: If any bits in this filed are 1, then it indicates a programming error..*/ -#define EFUSE_DIS_LEGACY_SPI_BOOT_ERR (BIT(1)) -#define EFUSE_DIS_LEGACY_SPI_BOOT_ERR_M (BIT(1)) -#define EFUSE_DIS_LEGACY_SPI_BOOT_ERR_V 0x1 -#define EFUSE_DIS_LEGACY_SPI_BOOT_ERR_S 1 +#define EFUSE_DIS_DIRECT_BOOT_ERR (BIT(1)) +#define EFUSE_DIS_DIRECT_BOOT_ERR_M (BIT(1)) +#define EFUSE_DIS_DIRECT_BOOT_ERR_V 0x1 +#define EFUSE_DIS_DIRECT_BOOT_ERR_S 1 /* EFUSE_DIS_DOWNLOAD_MODE_ERR : RO ;bitpos:[0] ;default: 1'b0 ; */ /*description: If any bits in this filed are 1, then it indicates a programming error..*/ #define EFUSE_DIS_DOWNLOAD_MODE_ERR (BIT(0)) diff --git a/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/efuse_struct.h b/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/efuse_struct.h index bd45983ba26..fb62d48ce77 100644 --- a/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/efuse_struct.h +++ b/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/efuse_struct.h @@ -101,10 +101,10 @@ typedef volatile struct efuse_dev_s { union { struct { uint32_t reg_dis_download_mode : 1; /*Set this bit to disable download mode (boot_mode[3:0] = 0, 1, 2, 3, 6, 7).*/ - uint32_t reg_dis_legacy_spi_boot : 1; /*Set this bit to disable Legacy SPI boot mode (boot_mode[3:0] = 4).*/ - uint32_t reg_uart_print_channel : 1; /*Selectes the default UART print channel. 0: UART0. 1: UART1.*/ + uint32_t reg_dis_direct_boot : 1; /*Set this bit to disable direct boot..*/ + uint32_t dis_usb_serial_jtag_rom_print : 1; /*Set this bit to disable USB-Serial-JTAG print during rom boot*/ uint32_t reg_flash_ecc_mode : 1; /*Set ECC mode in ROM, 0: ROM would Enable Flash ECC 16to18 byte mode. 1:ROM would use 16to17 byte mode.*/ - uint32_t reg_dis_usb_download_mode : 1; /*Set this bit to disable UART download mode through USB.*/ + uint32_t reg_dis_usb_serial_jtag_download_mode: 1; /*Set this bit to disable download through USB-Serial-JTAG.*/ uint32_t reg_enable_security_download : 1; /*Set this bit to enable secure UART download mode.*/ uint32_t reg_uart_print_control : 2; /*Set the default UARTboot message output mode. 00: Enabled. 01: Enabled when GPIO8 is low at reset. 10: Enabled when GPIO8 is high at reset. 11:disabled.*/ uint32_t reg_pin_power_selection : 1; /*GPIO33-GPIO37 power supply selection in ROM code. 0: VDD3P3_CPU. 1: VDD_SPI.*/ @@ -113,8 +113,8 @@ typedef volatile struct efuse_dev_s { uint32_t reg_flash_ecc_en : 1; /*Set 1 to enable ECC for flash boot.*/ uint32_t reg_force_send_resume : 1; /*Set this bit to force ROM code to send a resume command during SPI boot.*/ uint32_t reg_secure_version : 16; /*Secure version (used by ESP-IDF anti-rollback feature).*/ - uint32_t reg_powerglitch_en : 1; /*Set this bit to enable power glitch function.*/ uint32_t reg_rpt4_reserved1 : 1; /*Reserved (used for four backups method).*/ + uint32_t reg_dis_usb_otg_download_mode : 1; /*Set this bit to disable download through USB-OTG*/ }; uint32_t val; } rd_repeat_data3; @@ -283,10 +283,10 @@ typedef volatile struct efuse_dev_s { union { struct { uint32_t reg_dis_download_mode_err : 1; /*If any bits in this filed are 1, then it indicates a programming error.*/ - uint32_t reg_dis_legacy_spi_boot_err : 1; /*If any bits in this filed are 1, then it indicates a programming error.*/ - uint32_t reg_uart_print_channel_err : 1; /*If any bits in this filed are 1, then it indicates a programming error.*/ + uint32_t reg_dis_direct_boot_err : 1; /*If any bits in this filed are 1, then it indicates a programming error.*/ + uint32_t reg_dis_usb_serial_jtag_rom_print_err:1;/*If any bits in this filed are 1, then it indicates a programming error.*/ uint32_t reg_flash_ecc_mode_err : 1; /*If any bits in this filed are 1, then it indicates a programming error.*/ - uint32_t reg_dis_usb_download_mode_err : 1; /*If any bits in this filed are 1, then it indicates a programming error.*/ + uint32_t reg_dis_usb_serial_jtag_download_mode_err : 1; /*If any bits in this filed are 1, then it indicates a programming error.*/ uint32_t reg_enable_security_download_err: 1; /*If any bits in this filed are 1, then it indicates a programming error.*/ uint32_t reg_uart_print_control_err : 2; /*If any bits in this filed are 1, then it indicates a programming error.*/ uint32_t reg_pin_power_selection_err : 1; /*If any bits in this filed are 1, then it indicates a programming error.*/ @@ -294,9 +294,9 @@ typedef volatile struct efuse_dev_s { uint32_t reg_flash_page_size_err : 2; /*If any bits in this filed are 1, then it indicates a programming error.*/ uint32_t reg_flash_ecc_en_err : 1; /*If any bits in this filed are 1, then it indicates a programming error.*/ uint32_t reg_force_send_resume_err : 1; /*If any bits in this filed are 1, then it indicates a programming error.*/ - uint32_t reg_secure_version_err : 16; /*If any bits in this filed are 1, then it indicates a programming error.*/ - uint32_t reg_powerglitch_en_err : 1; + uint32_t reg_secure_version_err : 16; /*If any bits in this filed are 1, then it indicates a programming error.*/ uint32_t reg_rpt4_reserved1_err : 1; /*Reserved.*/ + uint32_t reg_dis_usb_otg_download_mode_err: 1; /*Set this bit to disable download through USB-OTG*/ }; uint32_t val; } rd_repeat_err3; diff --git a/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/gpio_caps.h b/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/gpio_caps.h deleted file mode 100644 index e2ddcdbb539..00000000000 --- a/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/gpio_caps.h +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2015-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. - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -// ESP32-S3 has 1 GPIO peripheral -#define SOC_GPIO_PORT (1) -#define SOC_GPIO_PIN_COUNT (49) - -// On ESP32-S3, Digital IOs have their own registers to control pullup/down/capability, independent with RTC registers. -#define SOC_GPIO_SUPPORT_RTC_INDEPENDENT (1) -// Force hold is a new function of ESP32-S3 -#define SOC_GPIO_SUPPORT_FORCE_HOLD (1) - -// 0~48 except from 22~25 are valid -#define SOC_GPIO_VALID_GPIO_MASK (0x1FFFFFFFFFFFFULL & ~(0ULL | BIT22 | BIT23 | BIT24 | BIT25)) -// No GPIO is input only -#define SOC_GPIO_VALID_OUTPUT_GPIO_MASK (SOC_GPIO_VALID_GPIO_MASK) - -// Support to configure slept status -#define SOC_GPIO_SUPPORT_SLP_SWITCH (1) - -#ifdef __cplusplus -} -#endif diff --git a/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/i2c_caps.h b/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/i2c_caps.h index 71ef195bb02..6e566ca01a3 100644 --- a/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/i2c_caps.h +++ b/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/i2c_caps.h @@ -23,8 +23,7 @@ extern "C" { #define SOC_I2C_FIFO_LEN (32) /*!< I2C hardware FIFO depth */ -//ESP32-S3 support hardware FSM reset -#define SOC_I2C_SUPPORT_HW_FSM_RST (1) +// FSM_RST only resets the FSM, not using it. So SOC_I2C_SUPPORT_HW_FSM_RST not defined. //ESP32-S3 support hardware clear bus #define SOC_I2C_SUPPORT_HW_CLR_BUS (1) diff --git a/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/rmt_reg.h b/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/rmt_reg.h index 55513e5e975..767467adced 100644 --- a/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/rmt_reg.h +++ b/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/rmt_reg.h @@ -120,1329 +120,1329 @@ extern "C" { * Channel 0 configure register 0 */ #define RMT_CH0CONF0_REG (DR_REG_RMT_BASE + 0x20) -/** RMT_TX_START_0 : WT; bitpos: [0]; default: 0; +/** RMT_TX_START_CH0 : WT; bitpos: [0]; default: 0; * Set this bit to start sending data on CHANNEL0. */ -#define RMT_TX_START_0 (BIT(0)) -#define RMT_TX_START_0_M (RMT_TX_START_0_V << RMT_TX_START_0_S) -#define RMT_TX_START_0_V 0x00000001U -#define RMT_TX_START_0_S 0 -/** RMT_MEM_RD_RST_0 : WT; bitpos: [1]; default: 0; +#define RMT_TX_START_CH0 (BIT(0)) +#define RMT_TX_START_CH0_M (RMT_TX_START_CH0_V << RMT_TX_START_CH0_S) +#define RMT_TX_START_CH0_V 0x00000001U +#define RMT_TX_START_CH0_S 0 +/** RMT_MEM_RD_RST_CH0 : WT; bitpos: [1]; default: 0; * Set this bit to reset read ram address for CHANNEL0 by accessing transmitter. */ -#define RMT_MEM_RD_RST_0 (BIT(1)) -#define RMT_MEM_RD_RST_0_M (RMT_MEM_RD_RST_0_V << RMT_MEM_RD_RST_0_S) -#define RMT_MEM_RD_RST_0_V 0x00000001U -#define RMT_MEM_RD_RST_0_S 1 -/** RMT_APB_MEM_RST_0 : WT; bitpos: [2]; default: 0; +#define RMT_MEM_RD_RST_CH0 (BIT(1)) +#define RMT_MEM_RD_RST_CH0_M (RMT_MEM_RD_RST_CH0_V << RMT_MEM_RD_RST_CH0_S) +#define RMT_MEM_RD_RST_CH0_V 0x00000001U +#define RMT_MEM_RD_RST_CH0_S 1 +/** RMT_APB_MEM_RST_CH0 : WT; bitpos: [2]; default: 0; * Set this bit to reset W/R ram address for CHANNEL0 by accessing apb fifo. */ -#define RMT_APB_MEM_RST_0 (BIT(2)) -#define RMT_APB_MEM_RST_0_M (RMT_APB_MEM_RST_0_V << RMT_APB_MEM_RST_0_S) -#define RMT_APB_MEM_RST_0_V 0x00000001U -#define RMT_APB_MEM_RST_0_S 2 -/** RMT_TX_CONTI_MODE_0 : R/W; bitpos: [3]; default: 0; +#define RMT_APB_MEM_RST_CH0 (BIT(2)) +#define RMT_APB_MEM_RST_CH0_M (RMT_APB_MEM_RST_CH0_V << RMT_APB_MEM_RST_CH0_S) +#define RMT_APB_MEM_RST_CH0_V 0x00000001U +#define RMT_APB_MEM_RST_CH0_S 2 +/** RMT_TX_CONTI_MODE_CH0 : R/W; bitpos: [3]; default: 0; * Set this bit to restart transmission from the first data to the last data in * CHANNEL0. */ -#define RMT_TX_CONTI_MODE_0 (BIT(3)) -#define RMT_TX_CONTI_MODE_0_M (RMT_TX_CONTI_MODE_0_V << RMT_TX_CONTI_MODE_0_S) -#define RMT_TX_CONTI_MODE_0_V 0x00000001U -#define RMT_TX_CONTI_MODE_0_S 3 -/** RMT_MEM_TX_WRAP_EN_0 : R/W; bitpos: [4]; default: 0; +#define RMT_TX_CONTI_MODE_CH0 (BIT(3)) +#define RMT_TX_CONTI_MODE_CH0_M (RMT_TX_CONTI_MODE_CH0_V << RMT_TX_CONTI_MODE_CH0_S) +#define RMT_TX_CONTI_MODE_CH0_V 0x00000001U +#define RMT_TX_CONTI_MODE_CH0_S 3 +/** RMT_MEM_TX_WRAP_EN_CH0 : R/W; bitpos: [4]; default: 0; * This is the channel 0 enable bit for wraparound mode: it will resume sending at the * start when the data to be sent is more than its memory size. */ -#define RMT_MEM_TX_WRAP_EN_0 (BIT(4)) -#define RMT_MEM_TX_WRAP_EN_0_M (RMT_MEM_TX_WRAP_EN_0_V << RMT_MEM_TX_WRAP_EN_0_S) -#define RMT_MEM_TX_WRAP_EN_0_V 0x00000001U -#define RMT_MEM_TX_WRAP_EN_0_S 4 -/** RMT_IDLE_OUT_LV_0 : R/W; bitpos: [5]; default: 0; +#define RMT_MEM_TX_WRAP_EN_CH0 (BIT(4)) +#define RMT_MEM_TX_WRAP_EN_CH0_M (RMT_MEM_TX_WRAP_EN_CH0_V << RMT_MEM_TX_WRAP_EN_CH0_S) +#define RMT_MEM_TX_WRAP_EN_CH0_V 0x00000001U +#define RMT_MEM_TX_WRAP_EN_CH0_S 4 +/** RMT_IDLE_OUT_LV_CH0 : R/W; bitpos: [5]; default: 0; * This bit configures the level of output signal in CHANNEL0 when the latter is in * IDLE state. */ -#define RMT_IDLE_OUT_LV_0 (BIT(5)) -#define RMT_IDLE_OUT_LV_0_M (RMT_IDLE_OUT_LV_0_V << RMT_IDLE_OUT_LV_0_S) -#define RMT_IDLE_OUT_LV_0_V 0x00000001U -#define RMT_IDLE_OUT_LV_0_S 5 -/** RMT_IDLE_OUT_EN_0 : R/W; bitpos: [6]; default: 0; +#define RMT_IDLE_OUT_LV_CH0 (BIT(5)) +#define RMT_IDLE_OUT_LV_CH0_M (RMT_IDLE_OUT_LV_CH0_V << RMT_IDLE_OUT_LV_CH0_S) +#define RMT_IDLE_OUT_LV_CH0_V 0x00000001U +#define RMT_IDLE_OUT_LV_CH0_S 5 +/** RMT_IDLE_OUT_EN_CH0 : R/W; bitpos: [6]; default: 0; * This is the output enable-control bit for CHANNEL0 in IDLE state. */ -#define RMT_IDLE_OUT_EN_0 (BIT(6)) -#define RMT_IDLE_OUT_EN_0_M (RMT_IDLE_OUT_EN_0_V << RMT_IDLE_OUT_EN_0_S) -#define RMT_IDLE_OUT_EN_0_V 0x00000001U -#define RMT_IDLE_OUT_EN_0_S 6 -/** RMT_TX_STOP_0 : R/W/SC; bitpos: [7]; default: 0; +#define RMT_IDLE_OUT_EN_CH0 (BIT(6)) +#define RMT_IDLE_OUT_EN_CH0_M (RMT_IDLE_OUT_EN_CH0_V << RMT_IDLE_OUT_EN_CH0_S) +#define RMT_IDLE_OUT_EN_CH0_V 0x00000001U +#define RMT_IDLE_OUT_EN_CH0_S 6 +/** RMT_TX_STOP_CH0 : R/W/SC; bitpos: [7]; default: 0; * Set this bit to stop the transmitter of CHANNEL0 sending data out. */ -#define RMT_TX_STOP_0 (BIT(7)) -#define RMT_TX_STOP_0_M (RMT_TX_STOP_0_V << RMT_TX_STOP_0_S) -#define RMT_TX_STOP_0_V 0x00000001U -#define RMT_TX_STOP_0_S 7 -/** RMT_DIV_CNT_0 : R/W; bitpos: [15:8]; default: 2; +#define RMT_TX_STOP_CH0 (BIT(7)) +#define RMT_TX_STOP_CH0_M (RMT_TX_STOP_CH0_V << RMT_TX_STOP_CH0_S) +#define RMT_TX_STOP_CH0_V 0x00000001U +#define RMT_TX_STOP_CH0_S 7 +/** RMT_DIV_CNT_CH0 : R/W; bitpos: [15:8]; default: 2; * This register is used to configure the divider for clock of CHANNEL0. */ -#define RMT_DIV_CNT_0 0x000000FFU -#define RMT_DIV_CNT_0_M (RMT_DIV_CNT_0_V << RMT_DIV_CNT_0_S) -#define RMT_DIV_CNT_0_V 0x000000FFU -#define RMT_DIV_CNT_0_S 8 -/** RMT_MEM_SIZE_0 : R/W; bitpos: [19:16]; default: 1; +#define RMT_DIV_CNT_CH0 0x000000FFU +#define RMT_DIV_CNT_CH0_M (RMT_DIV_CNT_CH0_V << RMT_DIV_CNT_CH0_S) +#define RMT_DIV_CNT_CH0_V 0x000000FFU +#define RMT_DIV_CNT_CH0_S 8 +/** RMT_MEM_SIZE_CH0 : R/W; bitpos: [19:16]; default: 1; * This register is used to configure the maximum size of memory allocated to CHANNEL0. */ -#define RMT_MEM_SIZE_0 0x0000000FU -#define RMT_MEM_SIZE_0_M (RMT_MEM_SIZE_0_V << RMT_MEM_SIZE_0_S) -#define RMT_MEM_SIZE_0_V 0x0000000FU -#define RMT_MEM_SIZE_0_S 16 -/** RMT_CARRIER_EFF_EN_0 : R/W; bitpos: [20]; default: 1; +#define RMT_MEM_SIZE_CH0 0x0000000FU +#define RMT_MEM_SIZE_CH0_M (RMT_MEM_SIZE_CH0_V << RMT_MEM_SIZE_CH0_S) +#define RMT_MEM_SIZE_CH0_V 0x0000000FU +#define RMT_MEM_SIZE_CH0_S 16 +/** RMT_CARRIER_EFF_EN_CH0 : R/W; bitpos: [20]; default: 1; * 1: Add carrier modulation on the output signal only at the send data state for * CHANNEL0. 0: Add carrier modulation on the output signal at all state for CHANNEL0. * Only valid when RMT_CARRIER_EN_CH0 is 1. */ -#define RMT_CARRIER_EFF_EN_0 (BIT(20)) -#define RMT_CARRIER_EFF_EN_0_M (RMT_CARRIER_EFF_EN_0_V << RMT_CARRIER_EFF_EN_0_S) -#define RMT_CARRIER_EFF_EN_0_V 0x00000001U -#define RMT_CARRIER_EFF_EN_0_S 20 -/** RMT_CARRIER_EN_0 : R/W; bitpos: [21]; default: 1; +#define RMT_CARRIER_EFF_EN_CH0 (BIT(20)) +#define RMT_CARRIER_EFF_EN_CH0_M (RMT_CARRIER_EFF_EN_CH0_V << RMT_CARRIER_EFF_EN_CH0_S) +#define RMT_CARRIER_EFF_EN_CH0_V 0x00000001U +#define RMT_CARRIER_EFF_EN_CH0_S 20 +/** RMT_CARRIER_EN_CH0 : R/W; bitpos: [21]; default: 1; * This is the carrier modulation enable-control bit for CHANNEL0. 1: Add carrier * modulation in the output signal. 0: No carrier modulation in sig_out. */ -#define RMT_CARRIER_EN_0 (BIT(21)) -#define RMT_CARRIER_EN_0_M (RMT_CARRIER_EN_0_V << RMT_CARRIER_EN_0_S) -#define RMT_CARRIER_EN_0_V 0x00000001U -#define RMT_CARRIER_EN_0_S 21 -/** RMT_CARRIER_OUT_LV_0 : R/W; bitpos: [22]; default: 1; +#define RMT_CARRIER_EN_CH0 (BIT(21)) +#define RMT_CARRIER_EN_CH0_M (RMT_CARRIER_EN_CH0_V << RMT_CARRIER_EN_CH0_S) +#define RMT_CARRIER_EN_CH0_V 0x00000001U +#define RMT_CARRIER_EN_CH0_S 21 +/** RMT_CARRIER_OUT_LV_CH0 : R/W; bitpos: [22]; default: 1; * This bit is used to configure the position of carrier wave for CHANNEL0. * * 1'h0: add carrier wave on low level. * * 1'h1: add carrier wave on high level. */ -#define RMT_CARRIER_OUT_LV_0 (BIT(22)) -#define RMT_CARRIER_OUT_LV_0_M (RMT_CARRIER_OUT_LV_0_V << RMT_CARRIER_OUT_LV_0_S) -#define RMT_CARRIER_OUT_LV_0_V 0x00000001U -#define RMT_CARRIER_OUT_LV_0_S 22 -/** RMT_AFIFO_RST_0 : WT; bitpos: [23]; default: 0; +#define RMT_CARRIER_OUT_LV_CH0 (BIT(22)) +#define RMT_CARRIER_OUT_LV_CH0_M (RMT_CARRIER_OUT_LV_CH0_V << RMT_CARRIER_OUT_LV_CH0_S) +#define RMT_CARRIER_OUT_LV_CH0_V 0x00000001U +#define RMT_CARRIER_OUT_LV_CH0_S 22 +/** RMT_AFIFO_RST_CH0 : WT; bitpos: [23]; default: 0; * Reserved */ -#define RMT_AFIFO_RST_0 (BIT(23)) -#define RMT_AFIFO_RST_0_M (RMT_AFIFO_RST_0_V << RMT_AFIFO_RST_0_S) -#define RMT_AFIFO_RST_0_V 0x00000001U -#define RMT_AFIFO_RST_0_S 23 -/** RMT_CONF_UPDATE_0 : WT; bitpos: [24]; default: 0; +#define RMT_AFIFO_RST_CH0 (BIT(23)) +#define RMT_AFIFO_RST_CH0_M (RMT_AFIFO_RST_CH0_V << RMT_AFIFO_RST_CH0_S) +#define RMT_AFIFO_RST_CH0_V 0x00000001U +#define RMT_AFIFO_RST_CH0_S 23 +/** RMT_CONF_UPDATE_CH0 : WT; bitpos: [24]; default: 0; * synchronization bit for CHANNEL0 */ -#define RMT_CONF_UPDATE_0 (BIT(24)) -#define RMT_CONF_UPDATE_0_M (RMT_CONF_UPDATE_0_V << RMT_CONF_UPDATE_0_S) -#define RMT_CONF_UPDATE_0_V 0x00000001U -#define RMT_CONF_UPDATE_0_S 24 +#define RMT_CONF_UPDATE_CH0 (BIT(24)) +#define RMT_CONF_UPDATE_CH0_M (RMT_CONF_UPDATE_CH0_V << RMT_CONF_UPDATE_CH0_S) +#define RMT_CONF_UPDATE_CH0_V 0x00000001U +#define RMT_CONF_UPDATE_CH0_S 24 /** RMT_CH1CONF0_REG register * Channel 1 configure register 0 */ #define RMT_CH1CONF0_REG (DR_REG_RMT_BASE + 0x24) -/** RMT_TX_START_1 : WT; bitpos: [0]; default: 0; +/** RMT_TX_START_CH1 : WT; bitpos: [0]; default: 0; * Set this bit to start sending data on CHANNEL1. */ -#define RMT_TX_START_1 (BIT(0)) -#define RMT_TX_START_1_M (RMT_TX_START_1_V << RMT_TX_START_1_S) -#define RMT_TX_START_1_V 0x00000001U -#define RMT_TX_START_1_S 0 -/** RMT_MEM_RD_RST_1 : WT; bitpos: [1]; default: 0; +#define RMT_TX_START_CH1 (BIT(0)) +#define RMT_TX_START_CH1_M (RMT_TX_START_CH1_V << RMT_TX_START_CH1_S) +#define RMT_TX_START_CH1_V 0x00000001U +#define RMT_TX_START_CH1_S 0 +/** RMT_MEM_RD_RST_CH1 : WT; bitpos: [1]; default: 0; * Set this bit to reset read ram address for CHANNEL1 by accessing transmitter. */ -#define RMT_MEM_RD_RST_1 (BIT(1)) -#define RMT_MEM_RD_RST_1_M (RMT_MEM_RD_RST_1_V << RMT_MEM_RD_RST_1_S) -#define RMT_MEM_RD_RST_1_V 0x00000001U -#define RMT_MEM_RD_RST_1_S 1 -/** RMT_APB_MEM_RST_1 : WT; bitpos: [2]; default: 0; +#define RMT_MEM_RD_RST_CH1 (BIT(1)) +#define RMT_MEM_RD_RST_CH1_M (RMT_MEM_RD_RST_CH1_V << RMT_MEM_RD_RST_CH1_S) +#define RMT_MEM_RD_RST_CH1_V 0x00000001U +#define RMT_MEM_RD_RST_CH1_S 1 +/** RMT_APB_MEM_RST_CH1 : WT; bitpos: [2]; default: 0; * Set this bit to reset W/R ram address for CHANNEL1 by accessing apb fifo. */ -#define RMT_APB_MEM_RST_1 (BIT(2)) -#define RMT_APB_MEM_RST_1_M (RMT_APB_MEM_RST_1_V << RMT_APB_MEM_RST_1_S) -#define RMT_APB_MEM_RST_1_V 0x00000001U -#define RMT_APB_MEM_RST_1_S 2 -/** RMT_TX_CONTI_MODE_1 : R/W; bitpos: [3]; default: 0; +#define RMT_APB_MEM_RST_CH1 (BIT(2)) +#define RMT_APB_MEM_RST_CH1_M (RMT_APB_MEM_RST_CH1_V << RMT_APB_MEM_RST_CH1_S) +#define RMT_APB_MEM_RST_CH1_V 0x00000001U +#define RMT_APB_MEM_RST_CH1_S 2 +/** RMT_TX_CONTI_MODE_CH1 : R/W; bitpos: [3]; default: 0; * Set this bit to restart transmission from the first data to the last data in * CHANNEL1. */ -#define RMT_TX_CONTI_MODE_1 (BIT(3)) -#define RMT_TX_CONTI_MODE_1_M (RMT_TX_CONTI_MODE_1_V << RMT_TX_CONTI_MODE_1_S) -#define RMT_TX_CONTI_MODE_1_V 0x00000001U -#define RMT_TX_CONTI_MODE_1_S 3 -/** RMT_MEM_TX_WRAP_EN_1 : R/W; bitpos: [4]; default: 0; +#define RMT_TX_CONTI_MODE_CH1 (BIT(3)) +#define RMT_TX_CONTI_MODE_CH1_M (RMT_TX_CONTI_MODE_CH1_V << RMT_TX_CONTI_MODE_CH1_S) +#define RMT_TX_CONTI_MODE_CH1_V 0x00000001U +#define RMT_TX_CONTI_MODE_CH1_S 3 +/** RMT_MEM_TX_WRAP_EN_CH1 : R/W; bitpos: [4]; default: 0; * This is the channel 1 enable bit for wraparound mode: it will resume sending at the * start when the data to be sent is more than its memory size. */ -#define RMT_MEM_TX_WRAP_EN_1 (BIT(4)) -#define RMT_MEM_TX_WRAP_EN_1_M (RMT_MEM_TX_WRAP_EN_1_V << RMT_MEM_TX_WRAP_EN_1_S) -#define RMT_MEM_TX_WRAP_EN_1_V 0x00000001U -#define RMT_MEM_TX_WRAP_EN_1_S 4 -/** RMT_IDLE_OUT_LV_1 : R/W; bitpos: [5]; default: 0; +#define RMT_MEM_TX_WRAP_EN_CH1 (BIT(4)) +#define RMT_MEM_TX_WRAP_EN_CH1_M (RMT_MEM_TX_WRAP_EN_CH1_V << RMT_MEM_TX_WRAP_EN_CH1_S) +#define RMT_MEM_TX_WRAP_EN_CH1_V 0x00000001U +#define RMT_MEM_TX_WRAP_EN_CH1_S 4 +/** RMT_IDLE_OUT_LV_CH1 : R/W; bitpos: [5]; default: 0; * This bit configures the level of output signal in CHANNEL1 when the latter is in * IDLE state. */ -#define RMT_IDLE_OUT_LV_1 (BIT(5)) -#define RMT_IDLE_OUT_LV_1_M (RMT_IDLE_OUT_LV_1_V << RMT_IDLE_OUT_LV_1_S) -#define RMT_IDLE_OUT_LV_1_V 0x00000001U -#define RMT_IDLE_OUT_LV_1_S 5 -/** RMT_IDLE_OUT_EN_1 : R/W; bitpos: [6]; default: 0; +#define RMT_IDLE_OUT_LV_CH1 (BIT(5)) +#define RMT_IDLE_OUT_LV_CH1_M (RMT_IDLE_OUT_LV_CH1_V << RMT_IDLE_OUT_LV_CH1_S) +#define RMT_IDLE_OUT_LV_CH1_V 0x00000001U +#define RMT_IDLE_OUT_LV_CH1_S 5 +/** RMT_IDLE_OUT_EN_CH1 : R/W; bitpos: [6]; default: 0; * This is the output enable-control bit for CHANNEL1 in IDLE state. */ -#define RMT_IDLE_OUT_EN_1 (BIT(6)) -#define RMT_IDLE_OUT_EN_1_M (RMT_IDLE_OUT_EN_1_V << RMT_IDLE_OUT_EN_1_S) -#define RMT_IDLE_OUT_EN_1_V 0x00000001U -#define RMT_IDLE_OUT_EN_1_S 6 -/** RMT_TX_STOP_1 : R/W/SC; bitpos: [7]; default: 0; +#define RMT_IDLE_OUT_EN_CH1 (BIT(6)) +#define RMT_IDLE_OUT_EN_CH1_M (RMT_IDLE_OUT_EN_CH1_V << RMT_IDLE_OUT_EN_CH1_S) +#define RMT_IDLE_OUT_EN_CH1_V 0x00000001U +#define RMT_IDLE_OUT_EN_CH1_S 6 +/** RMT_TX_STOP_CH1 : R/W/SC; bitpos: [7]; default: 0; * Set this bit to stop the transmitter of CHANNEL1 sending data out. */ -#define RMT_TX_STOP_1 (BIT(7)) -#define RMT_TX_STOP_1_M (RMT_TX_STOP_1_V << RMT_TX_STOP_1_S) -#define RMT_TX_STOP_1_V 0x00000001U -#define RMT_TX_STOP_1_S 7 -/** RMT_DIV_CNT_1 : R/W; bitpos: [15:8]; default: 2; +#define RMT_TX_STOP_CH1 (BIT(7)) +#define RMT_TX_STOP_CH1_M (RMT_TX_STOP_CH1_V << RMT_TX_STOP_CH1_S) +#define RMT_TX_STOP_CH1_V 0x00000001U +#define RMT_TX_STOP_CH1_S 7 +/** RMT_DIV_CNT_CH1 : R/W; bitpos: [15:8]; default: 2; * This register is used to configure the divider for clock of CHANNEL1. */ -#define RMT_DIV_CNT_1 0x000000FFU -#define RMT_DIV_CNT_1_M (RMT_DIV_CNT_1_V << RMT_DIV_CNT_1_S) -#define RMT_DIV_CNT_1_V 0x000000FFU -#define RMT_DIV_CNT_1_S 8 -/** RMT_MEM_SIZE_1 : R/W; bitpos: [19:16]; default: 1; +#define RMT_DIV_CNT_CH1 0x000000FFU +#define RMT_DIV_CNT_CH1_M (RMT_DIV_CNT_CH1_V << RMT_DIV_CNT_CH1_S) +#define RMT_DIV_CNT_CH1_V 0x000000FFU +#define RMT_DIV_CNT_CH1_S 8 +/** RMT_MEM_SIZE_CH1 : R/W; bitpos: [19:16]; default: 1; * This register is used to configure the maximum size of memory allocated to CHANNEL1. */ -#define RMT_MEM_SIZE_1 0x0000000FU -#define RMT_MEM_SIZE_1_M (RMT_MEM_SIZE_1_V << RMT_MEM_SIZE_1_S) -#define RMT_MEM_SIZE_1_V 0x0000000FU -#define RMT_MEM_SIZE_1_S 16 -/** RMT_CARRIER_EFF_EN_1 : R/W; bitpos: [20]; default: 1; +#define RMT_MEM_SIZE_CH1 0x0000000FU +#define RMT_MEM_SIZE_CH1_M (RMT_MEM_SIZE_CH1_V << RMT_MEM_SIZE_CH1_S) +#define RMT_MEM_SIZE_CH1_V 0x0000000FU +#define RMT_MEM_SIZE_CH1_S 16 +/** RMT_CARRIER_EFF_EN_CH1 : R/W; bitpos: [20]; default: 1; * 1: Add carrier modulation on the output signal only at the send data state for * CHANNEL1. 0: Add carrier modulation on the output signal at all state for CHANNEL1. * Only valid when RMT_CARRIER_EN_CH1 is 1. */ -#define RMT_CARRIER_EFF_EN_1 (BIT(20)) -#define RMT_CARRIER_EFF_EN_1_M (RMT_CARRIER_EFF_EN_1_V << RMT_CARRIER_EFF_EN_1_S) -#define RMT_CARRIER_EFF_EN_1_V 0x00000001U -#define RMT_CARRIER_EFF_EN_1_S 20 -/** RMT_CARRIER_EN_1 : R/W; bitpos: [21]; default: 1; +#define RMT_CARRIER_EFF_EN_CH1 (BIT(20)) +#define RMT_CARRIER_EFF_EN_CH1_M (RMT_CARRIER_EFF_EN_CH1_V << RMT_CARRIER_EFF_EN_CH1_S) +#define RMT_CARRIER_EFF_EN_CH1_V 0x00000001U +#define RMT_CARRIER_EFF_EN_CH1_S 20 +/** RMT_CARRIER_EN_CH1 : R/W; bitpos: [21]; default: 1; * This is the carrier modulation enable-control bit for CHANNEL1. 1: Add carrier * modulation in the output signal. 0: No carrier modulation in sig_out. */ -#define RMT_CARRIER_EN_1 (BIT(21)) -#define RMT_CARRIER_EN_1_M (RMT_CARRIER_EN_1_V << RMT_CARRIER_EN_1_S) -#define RMT_CARRIER_EN_1_V 0x00000001U -#define RMT_CARRIER_EN_1_S 21 -/** RMT_CARRIER_OUT_LV_1 : R/W; bitpos: [22]; default: 1; +#define RMT_CARRIER_EN_CH1 (BIT(21)) +#define RMT_CARRIER_EN_CH1_M (RMT_CARRIER_EN_CH1_V << RMT_CARRIER_EN_CH1_S) +#define RMT_CARRIER_EN_CH1_V 0x00000001U +#define RMT_CARRIER_EN_CH1_S 21 +/** RMT_CARRIER_OUT_LV_CH1 : R/W; bitpos: [22]; default: 1; * This bit is used to configure the position of carrier wave for CHANNEL1. * * 1'h0: add carrier wave on low level. * * 1'h1: add carrier wave on high level. */ -#define RMT_CARRIER_OUT_LV_1 (BIT(22)) -#define RMT_CARRIER_OUT_LV_1_M (RMT_CARRIER_OUT_LV_1_V << RMT_CARRIER_OUT_LV_1_S) -#define RMT_CARRIER_OUT_LV_1_V 0x00000001U -#define RMT_CARRIER_OUT_LV_1_S 22 -/** RMT_AFIFO_RST_1 : WT; bitpos: [23]; default: 0; +#define RMT_CARRIER_OUT_LV_CH1 (BIT(22)) +#define RMT_CARRIER_OUT_LV_CH1_M (RMT_CARRIER_OUT_LV_CH1_V << RMT_CARRIER_OUT_LV_CH1_S) +#define RMT_CARRIER_OUT_LV_CH1_V 0x00000001U +#define RMT_CARRIER_OUT_LV_CH1_S 22 +/** RMT_AFIFO_RST_CH1 : WT; bitpos: [23]; default: 0; * Reserved */ -#define RMT_AFIFO_RST_1 (BIT(23)) -#define RMT_AFIFO_RST_1_M (RMT_AFIFO_RST_1_V << RMT_AFIFO_RST_1_S) -#define RMT_AFIFO_RST_1_V 0x00000001U -#define RMT_AFIFO_RST_1_S 23 -/** RMT_CONF_UPDATE_1 : WT; bitpos: [24]; default: 0; +#define RMT_AFIFO_RST_CH1 (BIT(23)) +#define RMT_AFIFO_RST_CH1_M (RMT_AFIFO_RST_CH1_V << RMT_AFIFO_RST_CH1_S) +#define RMT_AFIFO_RST_CH1_V 0x00000001U +#define RMT_AFIFO_RST_CH1_S 23 +/** RMT_CONF_UPDATE_CH1 : WT; bitpos: [24]; default: 0; * synchronization bit for CHANNEL1 */ -#define RMT_CONF_UPDATE_1 (BIT(24)) -#define RMT_CONF_UPDATE_1_M (RMT_CONF_UPDATE_1_V << RMT_CONF_UPDATE_1_S) -#define RMT_CONF_UPDATE_1_V 0x00000001U -#define RMT_CONF_UPDATE_1_S 24 +#define RMT_CONF_UPDATE_CH1 (BIT(24)) +#define RMT_CONF_UPDATE_CH1_M (RMT_CONF_UPDATE_CH1_V << RMT_CONF_UPDATE_CH1_S) +#define RMT_CONF_UPDATE_CH1_V 0x00000001U +#define RMT_CONF_UPDATE_CH1_S 24 /** RMT_CH2CONF0_REG register * Channel 2 configure register 0 */ #define RMT_CH2CONF0_REG (DR_REG_RMT_BASE + 0x28) -/** RMT_TX_START_2 : WT; bitpos: [0]; default: 0; +/** RMT_TX_START_CH2 : WT; bitpos: [0]; default: 0; * Set this bit to start sending data on CHANNEL2. */ -#define RMT_TX_START_2 (BIT(0)) -#define RMT_TX_START_2_M (RMT_TX_START_2_V << RMT_TX_START_2_S) -#define RMT_TX_START_2_V 0x00000001U -#define RMT_TX_START_2_S 0 -/** RMT_MEM_RD_RST_2 : WT; bitpos: [1]; default: 0; +#define RMT_TX_START_CH2 (BIT(0)) +#define RMT_TX_START_CH2_M (RMT_TX_START_CH2_V << RMT_TX_START_CH2_S) +#define RMT_TX_START_CH2_V 0x00000001U +#define RMT_TX_START_CH2_S 0 +/** RMT_MEM_RD_RST_CH2 : WT; bitpos: [1]; default: 0; * Set this bit to reset read ram address for CHANNEL2 by accessing transmitter. */ -#define RMT_MEM_RD_RST_2 (BIT(1)) -#define RMT_MEM_RD_RST_2_M (RMT_MEM_RD_RST_2_V << RMT_MEM_RD_RST_2_S) -#define RMT_MEM_RD_RST_2_V 0x00000001U -#define RMT_MEM_RD_RST_2_S 1 -/** RMT_APB_MEM_RST_2 : WT; bitpos: [2]; default: 0; +#define RMT_MEM_RD_RST_CH2 (BIT(1)) +#define RMT_MEM_RD_RST_CH2_M (RMT_MEM_RD_RST_CH2_V << RMT_MEM_RD_RST_CH2_S) +#define RMT_MEM_RD_RST_CH2_V 0x00000001U +#define RMT_MEM_RD_RST_CH2_S 1 +/** RMT_APB_MEM_RST_CH2 : WT; bitpos: [2]; default: 0; * Set this bit to reset W/R ram address for CHANNEL2 by accessing apb fifo. */ -#define RMT_APB_MEM_RST_2 (BIT(2)) -#define RMT_APB_MEM_RST_2_M (RMT_APB_MEM_RST_2_V << RMT_APB_MEM_RST_2_S) -#define RMT_APB_MEM_RST_2_V 0x00000001U -#define RMT_APB_MEM_RST_2_S 2 -/** RMT_TX_CONTI_MODE_2 : R/W; bitpos: [3]; default: 0; +#define RMT_APB_MEM_RST_CH2 (BIT(2)) +#define RMT_APB_MEM_RST_CH2_M (RMT_APB_MEM_RST_CH2_V << RMT_APB_MEM_RST_CH2_S) +#define RMT_APB_MEM_RST_CH2_V 0x00000001U +#define RMT_APB_MEM_RST_CH2_S 2 +/** RMT_TX_CONTI_MODE_CH2 : R/W; bitpos: [3]; default: 0; * Set this bit to restart transmission from the first data to the last data in * CHANNEL2. */ -#define RMT_TX_CONTI_MODE_2 (BIT(3)) -#define RMT_TX_CONTI_MODE_2_M (RMT_TX_CONTI_MODE_2_V << RMT_TX_CONTI_MODE_2_S) -#define RMT_TX_CONTI_MODE_2_V 0x00000001U -#define RMT_TX_CONTI_MODE_2_S 3 -/** RMT_MEM_TX_WRAP_EN_2 : R/W; bitpos: [4]; default: 0; +#define RMT_TX_CONTI_MODE_CH2 (BIT(3)) +#define RMT_TX_CONTI_MODE_CH2_M (RMT_TX_CONTI_MODE_CH2_V << RMT_TX_CONTI_MODE_CH2_S) +#define RMT_TX_CONTI_MODE_CH2_V 0x00000001U +#define RMT_TX_CONTI_MODE_CH2_S 3 +/** RMT_MEM_TX_WRAP_EN_CH2 : R/W; bitpos: [4]; default: 0; * This is the channel 2 enable bit for wraparound mode: it will resume sending at the * start when the data to be sent is more than its memory size. */ -#define RMT_MEM_TX_WRAP_EN_2 (BIT(4)) -#define RMT_MEM_TX_WRAP_EN_2_M (RMT_MEM_TX_WRAP_EN_2_V << RMT_MEM_TX_WRAP_EN_2_S) -#define RMT_MEM_TX_WRAP_EN_2_V 0x00000001U -#define RMT_MEM_TX_WRAP_EN_2_S 4 -/** RMT_IDLE_OUT_LV_2 : R/W; bitpos: [5]; default: 0; +#define RMT_MEM_TX_WRAP_EN_CH2 (BIT(4)) +#define RMT_MEM_TX_WRAP_EN_CH2_M (RMT_MEM_TX_WRAP_EN_CH2_V << RMT_MEM_TX_WRAP_EN_CH2_S) +#define RMT_MEM_TX_WRAP_EN_CH2_V 0x00000001U +#define RMT_MEM_TX_WRAP_EN_CH2_S 4 +/** RMT_IDLE_OUT_LV_CH2 : R/W; bitpos: [5]; default: 0; * This bit configures the level of output signal in CHANNEL2 when the latter is in * IDLE state. */ -#define RMT_IDLE_OUT_LV_2 (BIT(5)) -#define RMT_IDLE_OUT_LV_2_M (RMT_IDLE_OUT_LV_2_V << RMT_IDLE_OUT_LV_2_S) -#define RMT_IDLE_OUT_LV_2_V 0x00000001U -#define RMT_IDLE_OUT_LV_2_S 5 -/** RMT_IDLE_OUT_EN_2 : R/W; bitpos: [6]; default: 0; +#define RMT_IDLE_OUT_LV_CH2 (BIT(5)) +#define RMT_IDLE_OUT_LV_CH2_M (RMT_IDLE_OUT_LV_CH2_V << RMT_IDLE_OUT_LV_CH2_S) +#define RMT_IDLE_OUT_LV_CH2_V 0x00000001U +#define RMT_IDLE_OUT_LV_CH2_S 5 +/** RMT_IDLE_OUT_EN_CH2 : R/W; bitpos: [6]; default: 0; * This is the output enable-control bit for CHANNEL2 in IDLE state. */ -#define RMT_IDLE_OUT_EN_2 (BIT(6)) -#define RMT_IDLE_OUT_EN_2_M (RMT_IDLE_OUT_EN_2_V << RMT_IDLE_OUT_EN_2_S) -#define RMT_IDLE_OUT_EN_2_V 0x00000001U -#define RMT_IDLE_OUT_EN_2_S 6 -/** RMT_TX_STOP_2 : R/W/SC; bitpos: [7]; default: 0; +#define RMT_IDLE_OUT_EN_CH2 (BIT(6)) +#define RMT_IDLE_OUT_EN_CH2_M (RMT_IDLE_OUT_EN_CH2_V << RMT_IDLE_OUT_EN_CH2_S) +#define RMT_IDLE_OUT_EN_CH2_V 0x00000001U +#define RMT_IDLE_OUT_EN_CH2_S 6 +/** RMT_TX_STOP_CH2 : R/W/SC; bitpos: [7]; default: 0; * Set this bit to stop the transmitter of CHANNEL2 sending data out. */ -#define RMT_TX_STOP_2 (BIT(7)) -#define RMT_TX_STOP_2_M (RMT_TX_STOP_2_V << RMT_TX_STOP_2_S) -#define RMT_TX_STOP_2_V 0x00000001U -#define RMT_TX_STOP_2_S 7 -/** RMT_DIV_CNT_2 : R/W; bitpos: [15:8]; default: 2; +#define RMT_TX_STOP_CH2 (BIT(7)) +#define RMT_TX_STOP_CH2_M (RMT_TX_STOP_CH2_V << RMT_TX_STOP_CH2_S) +#define RMT_TX_STOP_CH2_V 0x00000001U +#define RMT_TX_STOP_CH2_S 7 +/** RMT_DIV_CNT_CH2 : R/W; bitpos: [15:8]; default: 2; * This register is used to configure the divider for clock of CHANNEL2. */ -#define RMT_DIV_CNT_2 0x000000FFU -#define RMT_DIV_CNT_2_M (RMT_DIV_CNT_2_V << RMT_DIV_CNT_2_S) -#define RMT_DIV_CNT_2_V 0x000000FFU -#define RMT_DIV_CNT_2_S 8 -/** RMT_MEM_SIZE_2 : R/W; bitpos: [19:16]; default: 1; +#define RMT_DIV_CNT_CH2 0x000000FFU +#define RMT_DIV_CNT_CH2_M (RMT_DIV_CNT_CH2_V << RMT_DIV_CNT_CH2_S) +#define RMT_DIV_CNT_CH2_V 0x000000FFU +#define RMT_DIV_CNT_CH2_S 8 +/** RMT_MEM_SIZE_CH2 : R/W; bitpos: [19:16]; default: 1; * This register is used to configure the maximum size of memory allocated to CHANNEL2. */ -#define RMT_MEM_SIZE_2 0x0000000FU -#define RMT_MEM_SIZE_2_M (RMT_MEM_SIZE_2_V << RMT_MEM_SIZE_2_S) -#define RMT_MEM_SIZE_2_V 0x0000000FU -#define RMT_MEM_SIZE_2_S 16 -/** RMT_CARRIER_EFF_EN_2 : R/W; bitpos: [20]; default: 1; +#define RMT_MEM_SIZE_CH2 0x0000000FU +#define RMT_MEM_SIZE_CH2_M (RMT_MEM_SIZE_CH2_V << RMT_MEM_SIZE_CH2_S) +#define RMT_MEM_SIZE_CH2_V 0x0000000FU +#define RMT_MEM_SIZE_CH2_S 16 +/** RMT_CARRIER_EFF_EN_CH2 : R/W; bitpos: [20]; default: 1; * 1: Add carrier modulation on the output signal only at the send data state for * CHANNEL2. 0: Add carrier modulation on the output signal at all state for CHANNEL2. * Only valid when RMT_CARRIER_EN_CH2 is 1. */ -#define RMT_CARRIER_EFF_EN_2 (BIT(20)) -#define RMT_CARRIER_EFF_EN_2_M (RMT_CARRIER_EFF_EN_2_V << RMT_CARRIER_EFF_EN_2_S) -#define RMT_CARRIER_EFF_EN_2_V 0x00000001U -#define RMT_CARRIER_EFF_EN_2_S 20 -/** RMT_CARRIER_EN_2 : R/W; bitpos: [21]; default: 1; +#define RMT_CARRIER_EFF_EN_CH2 (BIT(20)) +#define RMT_CARRIER_EFF_EN_CH2_M (RMT_CARRIER_EFF_EN_CH2_V << RMT_CARRIER_EFF_EN_CH2_S) +#define RMT_CARRIER_EFF_EN_CH2_V 0x00000001U +#define RMT_CARRIER_EFF_EN_CH2_S 20 +/** RMT_CARRIER_EN_CH2 : R/W; bitpos: [21]; default: 1; * This is the carrier modulation enable-control bit for CHANNEL2. 1: Add carrier * modulation in the output signal. 0: No carrier modulation in sig_out. */ -#define RMT_CARRIER_EN_2 (BIT(21)) -#define RMT_CARRIER_EN_2_M (RMT_CARRIER_EN_2_V << RMT_CARRIER_EN_2_S) -#define RMT_CARRIER_EN_2_V 0x00000001U -#define RMT_CARRIER_EN_2_S 21 -/** RMT_CARRIER_OUT_LV_2 : R/W; bitpos: [22]; default: 1; +#define RMT_CARRIER_EN_CH2 (BIT(21)) +#define RMT_CARRIER_EN_CH2_M (RMT_CARRIER_EN_CH2_V << RMT_CARRIER_EN_CH2_S) +#define RMT_CARRIER_EN_CH2_V 0x00000001U +#define RMT_CARRIER_EN_CH2_S 21 +/** RMT_CARRIER_OUT_LV_CH2 : R/W; bitpos: [22]; default: 1; * This bit is used to configure the position of carrier wave for CHANNEL2. * * 1'h0: add carrier wave on low level. * * 1'h1: add carrier wave on high level. */ -#define RMT_CARRIER_OUT_LV_2 (BIT(22)) -#define RMT_CARRIER_OUT_LV_2_M (RMT_CARRIER_OUT_LV_2_V << RMT_CARRIER_OUT_LV_2_S) -#define RMT_CARRIER_OUT_LV_2_V 0x00000001U -#define RMT_CARRIER_OUT_LV_2_S 22 -/** RMT_AFIFO_RST_2 : WT; bitpos: [23]; default: 0; +#define RMT_CARRIER_OUT_LV_CH2 (BIT(22)) +#define RMT_CARRIER_OUT_LV_CH2_M (RMT_CARRIER_OUT_LV_CH2_V << RMT_CARRIER_OUT_LV_CH2_S) +#define RMT_CARRIER_OUT_LV_CH2_V 0x00000001U +#define RMT_CARRIER_OUT_LV_CH2_S 22 +/** RMT_AFIFO_RST_CH2 : WT; bitpos: [23]; default: 0; * Reserved */ -#define RMT_AFIFO_RST_2 (BIT(23)) -#define RMT_AFIFO_RST_2_M (RMT_AFIFO_RST_2_V << RMT_AFIFO_RST_2_S) -#define RMT_AFIFO_RST_2_V 0x00000001U -#define RMT_AFIFO_RST_2_S 23 -/** RMT_CONF_UPDATE_2 : WT; bitpos: [24]; default: 0; +#define RMT_AFIFO_RST_CH2 (BIT(23)) +#define RMT_AFIFO_RST_CH2_M (RMT_AFIFO_RST_CH2_V << RMT_AFIFO_RST_CH2_S) +#define RMT_AFIFO_RST_CH2_V 0x00000001U +#define RMT_AFIFO_RST_CH2_S 23 +/** RMT_CONF_UPDATE_CH2 : WT; bitpos: [24]; default: 0; * synchronization bit for CHANNEL2 */ -#define RMT_CONF_UPDATE_2 (BIT(24)) -#define RMT_CONF_UPDATE_2_M (RMT_CONF_UPDATE_2_V << RMT_CONF_UPDATE_2_S) -#define RMT_CONF_UPDATE_2_V 0x00000001U -#define RMT_CONF_UPDATE_2_S 24 +#define RMT_CONF_UPDATE_CH2 (BIT(24)) +#define RMT_CONF_UPDATE_CH2_M (RMT_CONF_UPDATE_CH2_V << RMT_CONF_UPDATE_CH2_S) +#define RMT_CONF_UPDATE_CH2_V 0x00000001U +#define RMT_CONF_UPDATE_CH2_S 24 /** RMT_CH3CONF0_REG register * Channel 3 configure register 0 */ #define RMT_CH3CONF0_REG (DR_REG_RMT_BASE + 0x2c) -/** RMT_TX_START_3 : WT; bitpos: [0]; default: 0; +/** RMT_TX_START_CH3 : WT; bitpos: [0]; default: 0; * Set this bit to start sending data on CHANNEL3. */ -#define RMT_TX_START_3 (BIT(0)) -#define RMT_TX_START_3_M (RMT_TX_START_3_V << RMT_TX_START_3_S) -#define RMT_TX_START_3_V 0x00000001U -#define RMT_TX_START_3_S 0 -/** RMT_MEM_RD_RST_3 : WT; bitpos: [1]; default: 0; +#define RMT_TX_START_CH3 (BIT(0)) +#define RMT_TX_START_CH3_M (RMT_TX_START_CH3_V << RMT_TX_START_CH3_S) +#define RMT_TX_START_CH3_V 0x00000001U +#define RMT_TX_START_CH3_S 0 +/** RMT_MEM_RD_RST_CH3 : WT; bitpos: [1]; default: 0; * Set this bit to reset read ram address for CHANNEL3 by accessing transmitter. */ -#define RMT_MEM_RD_RST_3 (BIT(1)) -#define RMT_MEM_RD_RST_3_M (RMT_MEM_RD_RST_3_V << RMT_MEM_RD_RST_3_S) -#define RMT_MEM_RD_RST_3_V 0x00000001U -#define RMT_MEM_RD_RST_3_S 1 -/** RMT_APB_MEM_RST_3 : WT; bitpos: [2]; default: 0; +#define RMT_MEM_RD_RST_CH3 (BIT(1)) +#define RMT_MEM_RD_RST_CH3_M (RMT_MEM_RD_RST_CH3_V << RMT_MEM_RD_RST_CH3_S) +#define RMT_MEM_RD_RST_CH3_V 0x00000001U +#define RMT_MEM_RD_RST_CH3_S 1 +/** RMT_APB_MEM_RST_CH3 : WT; bitpos: [2]; default: 0; * Set this bit to reset W/R ram address for CHANNEL3 by accessing apb fifo. */ -#define RMT_APB_MEM_RST_3 (BIT(2)) -#define RMT_APB_MEM_RST_3_M (RMT_APB_MEM_RST_3_V << RMT_APB_MEM_RST_3_S) -#define RMT_APB_MEM_RST_3_V 0x00000001U -#define RMT_APB_MEM_RST_3_S 2 -/** RMT_TX_CONTI_MODE_3 : R/W; bitpos: [3]; default: 0; +#define RMT_APB_MEM_RST_CH3 (BIT(2)) +#define RMT_APB_MEM_RST_CH3_M (RMT_APB_MEM_RST_CH3_V << RMT_APB_MEM_RST_CH3_S) +#define RMT_APB_MEM_RST_CH3_V 0x00000001U +#define RMT_APB_MEM_RST_CH3_S 2 +/** RMT_TX_CONTI_MODE_CH3 : R/W; bitpos: [3]; default: 0; * Set this bit to restart transmission from the first data to the last data in * CHANNEL3. */ -#define RMT_TX_CONTI_MODE_3 (BIT(3)) -#define RMT_TX_CONTI_MODE_3_M (RMT_TX_CONTI_MODE_3_V << RMT_TX_CONTI_MODE_3_S) -#define RMT_TX_CONTI_MODE_3_V 0x00000001U -#define RMT_TX_CONTI_MODE_3_S 3 -/** RMT_MEM_TX_WRAP_EN_3 : R/W; bitpos: [4]; default: 0; +#define RMT_TX_CONTI_MODE_CH3 (BIT(3)) +#define RMT_TX_CONTI_MODE_CH3_M (RMT_TX_CONTI_MODE_CH3_V << RMT_TX_CONTI_MODE_CH3_S) +#define RMT_TX_CONTI_MODE_CH3_V 0x00000001U +#define RMT_TX_CONTI_MODE_CH3_S 3 +/** RMT_MEM_TX_WRAP_EN_CH3 : R/W; bitpos: [4]; default: 0; * This is the channel 3 enable bit for wraparound mode: it will resume sending at the * start when the data to be sent is more than its memory size. */ -#define RMT_MEM_TX_WRAP_EN_3 (BIT(4)) -#define RMT_MEM_TX_WRAP_EN_3_M (RMT_MEM_TX_WRAP_EN_3_V << RMT_MEM_TX_WRAP_EN_3_S) -#define RMT_MEM_TX_WRAP_EN_3_V 0x00000001U -#define RMT_MEM_TX_WRAP_EN_3_S 4 -/** RMT_IDLE_OUT_LV_3 : R/W; bitpos: [5]; default: 0; +#define RMT_MEM_TX_WRAP_EN_CH3 (BIT(4)) +#define RMT_MEM_TX_WRAP_EN_CH3_M (RMT_MEM_TX_WRAP_EN_CH3_V << RMT_MEM_TX_WRAP_EN_CH3_S) +#define RMT_MEM_TX_WRAP_EN_CH3_V 0x00000001U +#define RMT_MEM_TX_WRAP_EN_CH3_S 4 +/** RMT_IDLE_OUT_LV_CH3 : R/W; bitpos: [5]; default: 0; * This bit configures the level of output signal in CHANNEL3 when the latter is in * IDLE state. */ -#define RMT_IDLE_OUT_LV_3 (BIT(5)) -#define RMT_IDLE_OUT_LV_3_M (RMT_IDLE_OUT_LV_3_V << RMT_IDLE_OUT_LV_3_S) -#define RMT_IDLE_OUT_LV_3_V 0x00000001U -#define RMT_IDLE_OUT_LV_3_S 5 -/** RMT_IDLE_OUT_EN_3 : R/W; bitpos: [6]; default: 0; +#define RMT_IDLE_OUT_LV_CH3 (BIT(5)) +#define RMT_IDLE_OUT_LV_CH3_M (RMT_IDLE_OUT_LV_CH3_V << RMT_IDLE_OUT_LV_CH3_S) +#define RMT_IDLE_OUT_LV_CH3_V 0x00000001U +#define RMT_IDLE_OUT_LV_CH3_S 5 +/** RMT_IDLE_OUT_EN_CH3 : R/W; bitpos: [6]; default: 0; * This is the output enable-control bit for CHANNEL3 in IDLE state. */ -#define RMT_IDLE_OUT_EN_3 (BIT(6)) -#define RMT_IDLE_OUT_EN_3_M (RMT_IDLE_OUT_EN_3_V << RMT_IDLE_OUT_EN_3_S) -#define RMT_IDLE_OUT_EN_3_V 0x00000001U -#define RMT_IDLE_OUT_EN_3_S 6 -/** RMT_TX_STOP_3 : R/W/SC; bitpos: [7]; default: 0; +#define RMT_IDLE_OUT_EN_CH3 (BIT(6)) +#define RMT_IDLE_OUT_EN_CH3_M (RMT_IDLE_OUT_EN_CH3_V << RMT_IDLE_OUT_EN_CH3_S) +#define RMT_IDLE_OUT_EN_CH3_V 0x00000001U +#define RMT_IDLE_OUT_EN_CH3_S 6 +/** RMT_TX_STOP_CH3 : R/W/SC; bitpos: [7]; default: 0; * Set this bit to stop the transmitter of CHANNEL3 sending data out. */ -#define RMT_TX_STOP_3 (BIT(7)) -#define RMT_TX_STOP_3_M (RMT_TX_STOP_3_V << RMT_TX_STOP_3_S) -#define RMT_TX_STOP_3_V 0x00000001U -#define RMT_TX_STOP_3_S 7 -/** RMT_DIV_CNT_3 : R/W; bitpos: [15:8]; default: 2; +#define RMT_TX_STOP_CH3 (BIT(7)) +#define RMT_TX_STOP_CH3_M (RMT_TX_STOP_CH3_V << RMT_TX_STOP_CH3_S) +#define RMT_TX_STOP_CH3_V 0x00000001U +#define RMT_TX_STOP_CH3_S 7 +/** RMT_DIV_CNT_CH3 : R/W; bitpos: [15:8]; default: 2; * This register is used to configure the divider for clock of CHANNEL3. */ -#define RMT_DIV_CNT_3 0x000000FFU -#define RMT_DIV_CNT_3_M (RMT_DIV_CNT_3_V << RMT_DIV_CNT_3_S) -#define RMT_DIV_CNT_3_V 0x000000FFU -#define RMT_DIV_CNT_3_S 8 -/** RMT_MEM_SIZE_3 : R/W; bitpos: [19:16]; default: 1; +#define RMT_DIV_CNT_CH3 0x000000FFU +#define RMT_DIV_CNT_CH3_M (RMT_DIV_CNT_CH3_V << RMT_DIV_CNT_CH3_S) +#define RMT_DIV_CNT_CH3_V 0x000000FFU +#define RMT_DIV_CNT_CH3_S 8 +/** RMT_MEM_SIZE_CH3 : R/W; bitpos: [19:16]; default: 1; * This register is used to configure the maximum size of memory allocated to CHANNEL3. */ -#define RMT_MEM_SIZE_3 0x0000000FU -#define RMT_MEM_SIZE_3_M (RMT_MEM_SIZE_3_V << RMT_MEM_SIZE_3_S) -#define RMT_MEM_SIZE_3_V 0x0000000FU -#define RMT_MEM_SIZE_3_S 16 -/** RMT_CARRIER_EFF_EN_3 : R/W; bitpos: [20]; default: 1; +#define RMT_MEM_SIZE_CH3 0x0000000FU +#define RMT_MEM_SIZE_CH3_M (RMT_MEM_SIZE_CH3_V << RMT_MEM_SIZE_CH3_S) +#define RMT_MEM_SIZE_CH3_V 0x0000000FU +#define RMT_MEM_SIZE_CH3_S 16 +/** RMT_CARRIER_EFF_EN_CH3 : R/W; bitpos: [20]; default: 1; * 1: Add carrier modulation on the output signal only at the send data state for * CHANNEL3. 0: Add carrier modulation on the output signal at all state for CHANNEL3. * Only valid when RMT_CARRIER_EN_CH3 is 1. */ -#define RMT_CARRIER_EFF_EN_3 (BIT(20)) -#define RMT_CARRIER_EFF_EN_3_M (RMT_CARRIER_EFF_EN_3_V << RMT_CARRIER_EFF_EN_3_S) -#define RMT_CARRIER_EFF_EN_3_V 0x00000001U -#define RMT_CARRIER_EFF_EN_3_S 20 -/** RMT_CARRIER_EN_3 : R/W; bitpos: [21]; default: 1; +#define RMT_CARRIER_EFF_EN_CH3 (BIT(20)) +#define RMT_CARRIER_EFF_EN_CH3_M (RMT_CARRIER_EFF_EN_CH3_V << RMT_CARRIER_EFF_EN_CH3_S) +#define RMT_CARRIER_EFF_EN_CH3_V 0x00000001U +#define RMT_CARRIER_EFF_EN_CH3_S 20 +/** RMT_CARRIER_EN_CH3 : R/W; bitpos: [21]; default: 1; * This is the carrier modulation enable-control bit for CHANNEL3. 1: Add carrier * modulation in the output signal. 0: No carrier modulation in sig_out. */ -#define RMT_CARRIER_EN_3 (BIT(21)) -#define RMT_CARRIER_EN_3_M (RMT_CARRIER_EN_3_V << RMT_CARRIER_EN_3_S) -#define RMT_CARRIER_EN_3_V 0x00000001U -#define RMT_CARRIER_EN_3_S 21 -/** RMT_CARRIER_OUT_LV_3 : R/W; bitpos: [22]; default: 1; +#define RMT_CARRIER_EN_CH3 (BIT(21)) +#define RMT_CARRIER_EN_CH3_M (RMT_CARRIER_EN_CH3_V << RMT_CARRIER_EN_CH3_S) +#define RMT_CARRIER_EN_CH3_V 0x00000001U +#define RMT_CARRIER_EN_CH3_S 21 +/** RMT_CARRIER_OUT_LV_CH3 : R/W; bitpos: [22]; default: 1; * This bit is used to configure the position of carrier wave for CHANNEL3. * * 1'h0: add carrier wave on low level. * * 1'h1: add carrier wave on high level. */ -#define RMT_CARRIER_OUT_LV_3 (BIT(22)) -#define RMT_CARRIER_OUT_LV_3_M (RMT_CARRIER_OUT_LV_3_V << RMT_CARRIER_OUT_LV_3_S) -#define RMT_CARRIER_OUT_LV_3_V 0x00000001U -#define RMT_CARRIER_OUT_LV_3_S 22 -/** RMT_AFIFO_RST_3 : WT; bitpos: [23]; default: 0; +#define RMT_CARRIER_OUT_LV_CH3 (BIT(22)) +#define RMT_CARRIER_OUT_LV_CH3_M (RMT_CARRIER_OUT_LV_CH3_V << RMT_CARRIER_OUT_LV_CH3_S) +#define RMT_CARRIER_OUT_LV_CH3_V 0x00000001U +#define RMT_CARRIER_OUT_LV_CH3_S 22 +/** RMT_AFIFO_RST_CH3 : WT; bitpos: [23]; default: 0; * Reserved */ -#define RMT_AFIFO_RST_3 (BIT(23)) -#define RMT_AFIFO_RST_3_M (RMT_AFIFO_RST_3_V << RMT_AFIFO_RST_3_S) -#define RMT_AFIFO_RST_3_V 0x00000001U -#define RMT_AFIFO_RST_3_S 23 -/** RMT_CONF_UPDATE_3 : WT; bitpos: [24]; default: 0; +#define RMT_AFIFO_RST_CH3 (BIT(23)) +#define RMT_AFIFO_RST_CH3_M (RMT_AFIFO_RST_CH3_V << RMT_AFIFO_RST_CH3_S) +#define RMT_AFIFO_RST_CH3_V 0x00000001U +#define RMT_AFIFO_RST_CH3_S 23 +/** RMT_CONF_UPDATE_CH3 : WT; bitpos: [24]; default: 0; * synchronization bit for CHANNEL3 */ -#define RMT_CONF_UPDATE_3 (BIT(24)) -#define RMT_CONF_UPDATE_3_M (RMT_CONF_UPDATE_3_V << RMT_CONF_UPDATE_3_S) -#define RMT_CONF_UPDATE_3_V 0x00000001U -#define RMT_CONF_UPDATE_3_S 24 +#define RMT_CONF_UPDATE_CH3 (BIT(24)) +#define RMT_CONF_UPDATE_CH3_M (RMT_CONF_UPDATE_CH3_V << RMT_CONF_UPDATE_CH3_S) +#define RMT_CONF_UPDATE_CH3_V 0x00000001U +#define RMT_CONF_UPDATE_CH3_S 24 /** RMT_CH4CONF0_REG register * Channel 4 configure register 0 */ #define RMT_CH4CONF0_REG (DR_REG_RMT_BASE + 0x30) -/** RMT_DIV_CNT_4 : R/W; bitpos: [7:0]; default: 2; +/** RMT_DIV_CNT_CH4 : R/W; bitpos: [7:0]; default: 2; * This register is used to configure the divider for clock of CHANNEL4. */ -#define RMT_DIV_CNT_4 0x000000FFU -#define RMT_DIV_CNT_4_M (RMT_DIV_CNT_4_V << RMT_DIV_CNT_4_S) -#define RMT_DIV_CNT_4_V 0x000000FFU -#define RMT_DIV_CNT_4_S 0 -/** RMT_IDLE_THRES_4 : R/W; bitpos: [22:8]; default: 32767; +#define RMT_DIV_CNT_CH4 0x000000FFU +#define RMT_DIV_CNT_CH4_M (RMT_DIV_CNT_CH4_V << RMT_DIV_CNT_CH4_S) +#define RMT_DIV_CNT_CH4_V 0x000000FFU +#define RMT_DIV_CNT_CH4_S 0 +/** RMT_IDLE_THRES_CH4 : R/W; bitpos: [22:8]; default: 32767; * When no edge is detected on the input signal and continuous clock cycles is longer * than this register value, received process is finished. */ -#define RMT_IDLE_THRES_4 0x00007FFFU -#define RMT_IDLE_THRES_4_M (RMT_IDLE_THRES_4_V << RMT_IDLE_THRES_4_S) -#define RMT_IDLE_THRES_4_V 0x00007FFFU -#define RMT_IDLE_THRES_4_S 8 -/** RMT_MEM_SIZE_4 : R/W; bitpos: [27:24]; default: 1; +#define RMT_IDLE_THRES_CH4 0x00007FFFU +#define RMT_IDLE_THRES_CH4_M (RMT_IDLE_THRES_CH4_V << RMT_IDLE_THRES_CH4_S) +#define RMT_IDLE_THRES_CH4_V 0x00007FFFU +#define RMT_IDLE_THRES_CH4_S 8 +/** RMT_MEM_SIZE_CH4 : R/W; bitpos: [27:24]; default: 1; * This register is used to configure the maximum size of memory allocated to CHANNEL4. */ -#define RMT_MEM_SIZE_4 0x0000000FU -#define RMT_MEM_SIZE_4_M (RMT_MEM_SIZE_4_V << RMT_MEM_SIZE_4_S) -#define RMT_MEM_SIZE_4_V 0x0000000FU -#define RMT_MEM_SIZE_4_S 24 -/** RMT_CARRIER_EN_4 : R/W; bitpos: [28]; default: 1; +#define RMT_MEM_SIZE_CH4 0x0000000FU +#define RMT_MEM_SIZE_CH4_M (RMT_MEM_SIZE_CH4_V << RMT_MEM_SIZE_CH4_S) +#define RMT_MEM_SIZE_CH4_V 0x0000000FU +#define RMT_MEM_SIZE_CH4_S 24 +/** RMT_CARRIER_EN_CH4 : R/W; bitpos: [28]; default: 1; * This is the carrier modulation enable-control bit for CHANNEL4. 1: Add carrier * modulation in the output signal. 0: No carrier modulation in sig_out. */ -#define RMT_CARRIER_EN_4 (BIT(28)) -#define RMT_CARRIER_EN_4_M (RMT_CARRIER_EN_4_V << RMT_CARRIER_EN_4_S) -#define RMT_CARRIER_EN_4_V 0x00000001U -#define RMT_CARRIER_EN_4_S 28 -/** RMT_CARRIER_OUT_LV_4 : R/W; bitpos: [29]; default: 1; +#define RMT_CARRIER_EN_CH4 (BIT(28)) +#define RMT_CARRIER_EN_CH4_M (RMT_CARRIER_EN_CH4_V << RMT_CARRIER_EN_CH4_S) +#define RMT_CARRIER_EN_CH4_V 0x00000001U +#define RMT_CARRIER_EN_CH4_S 28 +/** RMT_CARRIER_OUT_LV_CH4 : R/W; bitpos: [29]; default: 1; * This bit is used to configure the position of carrier wave for CHANNEL4. * * 1'h0: add carrier wave on low level. * * 1'h1: add carrier wave on high level. */ -#define RMT_CARRIER_OUT_LV_4 (BIT(29)) -#define RMT_CARRIER_OUT_LV_4_M (RMT_CARRIER_OUT_LV_4_V << RMT_CARRIER_OUT_LV_4_S) -#define RMT_CARRIER_OUT_LV_4_V 0x00000001U -#define RMT_CARRIER_OUT_LV_4_S 29 +#define RMT_CARRIER_OUT_LV_CH4 (BIT(29)) +#define RMT_CARRIER_OUT_LV_CH4_M (RMT_CARRIER_OUT_LV_CH4_V << RMT_CARRIER_OUT_LV_CH4_S) +#define RMT_CARRIER_OUT_LV_CH4_V 0x00000001U +#define RMT_CARRIER_OUT_LV_CH4_S 29 /** RMT_CH4CONF1_REG register * Channel 4 configure register 1 */ #define RMT_CH4CONF1_REG (DR_REG_RMT_BASE + 0x34) -/** RMT_RX_EN_4 : R/W; bitpos: [0]; default: 0; +/** RMT_RX_EN_CH4 : R/W; bitpos: [0]; default: 0; * Set this bit to enable receiver to receive data on CHANNEL4. */ -#define RMT_RX_EN_4 (BIT(0)) -#define RMT_RX_EN_4_M (RMT_RX_EN_4_V << RMT_RX_EN_4_S) -#define RMT_RX_EN_4_V 0x00000001U -#define RMT_RX_EN_4_S 0 -/** RMT_MEM_WR_RST_4 : WT; bitpos: [1]; default: 0; +#define RMT_RX_EN_CH4 (BIT(0)) +#define RMT_RX_EN_CH4_M (RMT_RX_EN_CH4_V << RMT_RX_EN_CH4_S) +#define RMT_RX_EN_CH4_V 0x00000001U +#define RMT_RX_EN_CH4_S 0 +/** RMT_MEM_WR_RST_CH4 : WT; bitpos: [1]; default: 0; * Set this bit to reset write ram address for CHANNEL4 by accessing receiver. */ -#define RMT_MEM_WR_RST_4 (BIT(1)) -#define RMT_MEM_WR_RST_4_M (RMT_MEM_WR_RST_4_V << RMT_MEM_WR_RST_4_S) -#define RMT_MEM_WR_RST_4_V 0x00000001U -#define RMT_MEM_WR_RST_4_S 1 -/** RMT_APB_MEM_RST_4 : WT; bitpos: [2]; default: 0; +#define RMT_MEM_WR_RST_CH4 (BIT(1)) +#define RMT_MEM_WR_RST_CH4_M (RMT_MEM_WR_RST_CH4_V << RMT_MEM_WR_RST_CH4_S) +#define RMT_MEM_WR_RST_CH4_V 0x00000001U +#define RMT_MEM_WR_RST_CH4_S 1 +/** RMT_APB_MEM_RST_CH4 : WT; bitpos: [2]; default: 0; * Set this bit to reset W/R ram address for CHANNEL4 by accessing apb fifo. */ -#define RMT_APB_MEM_RST_4 (BIT(2)) -#define RMT_APB_MEM_RST_4_M (RMT_APB_MEM_RST_4_V << RMT_APB_MEM_RST_4_S) -#define RMT_APB_MEM_RST_4_V 0x00000001U -#define RMT_APB_MEM_RST_4_S 2 -/** RMT_MEM_OWNER_4 : R/W/SC; bitpos: [3]; default: 1; +#define RMT_APB_MEM_RST_CH4 (BIT(2)) +#define RMT_APB_MEM_RST_CH4_M (RMT_APB_MEM_RST_CH4_V << RMT_APB_MEM_RST_CH4_S) +#define RMT_APB_MEM_RST_CH4_V 0x00000001U +#define RMT_APB_MEM_RST_CH4_S 2 +/** RMT_MEM_OWNER_CH4 : R/W/SC; bitpos: [3]; default: 1; * This register marks the ownership of CHANNEL4's ram block. * * 1'h1: Receiver is using the ram. * * 1'h0: APB bus is using the ram. */ -#define RMT_MEM_OWNER_4 (BIT(3)) -#define RMT_MEM_OWNER_4_M (RMT_MEM_OWNER_4_V << RMT_MEM_OWNER_4_S) -#define RMT_MEM_OWNER_4_V 0x00000001U -#define RMT_MEM_OWNER_4_S 3 -/** RMT_RX_FILTER_EN_4 : R/W; bitpos: [4]; default: 0; +#define RMT_MEM_OWNER_CH4 (BIT(3)) +#define RMT_MEM_OWNER_CH4_M (RMT_MEM_OWNER_CH4_V << RMT_MEM_OWNER_CH4_S) +#define RMT_MEM_OWNER_CH4_V 0x00000001U +#define RMT_MEM_OWNER_CH4_S 3 +/** RMT_RX_FILTER_EN_CH4 : R/W; bitpos: [4]; default: 0; * This is the receive filter's enable bit for CHANNEL4. */ -#define RMT_RX_FILTER_EN_4 (BIT(4)) -#define RMT_RX_FILTER_EN_4_M (RMT_RX_FILTER_EN_4_V << RMT_RX_FILTER_EN_4_S) -#define RMT_RX_FILTER_EN_4_V 0x00000001U -#define RMT_RX_FILTER_EN_4_S 4 -/** RMT_RX_FILTER_THRES_4 : R/W; bitpos: [12:5]; default: 15; +#define RMT_RX_FILTER_EN_CH4 (BIT(4)) +#define RMT_RX_FILTER_EN_CH4_M (RMT_RX_FILTER_EN_CH4_V << RMT_RX_FILTER_EN_CH4_S) +#define RMT_RX_FILTER_EN_CH4_V 0x00000001U +#define RMT_RX_FILTER_EN_CH4_S 4 +/** RMT_RX_FILTER_THRES_CH4 : R/W; bitpos: [12:5]; default: 15; * Ignores the input pulse when its width is smaller than this register value in APB * clock periods (in receive mode). */ -#define RMT_RX_FILTER_THRES_4 0x000000FFU -#define RMT_RX_FILTER_THRES_4_M (RMT_RX_FILTER_THRES_4_V << RMT_RX_FILTER_THRES_4_S) -#define RMT_RX_FILTER_THRES_4_V 0x000000FFU -#define RMT_RX_FILTER_THRES_4_S 5 -/** RMT_MEM_RX_WRAP_EN_4 : R/W; bitpos: [13]; default: 0; +#define RMT_RX_FILTER_THRES_CH4 0x000000FFU +#define RMT_RX_FILTER_THRES_CH4_M (RMT_RX_FILTER_THRES_CH4_V << RMT_RX_FILTER_THRES_CH4_S) +#define RMT_RX_FILTER_THRES_CH4_V 0x000000FFU +#define RMT_RX_FILTER_THRES_CH4_S 5 +/** RMT_MEM_RX_WRAP_EN_CH4 : R/W; bitpos: [13]; default: 0; * This is the channel 4 enable bit for wraparound mode: it will resume receiving at * the start when the data to be received is more than its memory size. */ -#define RMT_MEM_RX_WRAP_EN_4 (BIT(13)) -#define RMT_MEM_RX_WRAP_EN_4_M (RMT_MEM_RX_WRAP_EN_4_V << RMT_MEM_RX_WRAP_EN_4_S) -#define RMT_MEM_RX_WRAP_EN_4_V 0x00000001U -#define RMT_MEM_RX_WRAP_EN_4_S 13 -/** RMT_AFIFO_RST_4 : WT; bitpos: [14]; default: 0; +#define RMT_MEM_RX_WRAP_EN_CH4 (BIT(13)) +#define RMT_MEM_RX_WRAP_EN_CH4_M (RMT_MEM_RX_WRAP_EN_CH4_V << RMT_MEM_RX_WRAP_EN_CH4_S) +#define RMT_MEM_RX_WRAP_EN_CH4_V 0x00000001U +#define RMT_MEM_RX_WRAP_EN_CH4_S 13 +/** RMT_AFIFO_RST_CH4 : WT; bitpos: [14]; default: 0; * Reserved */ -#define RMT_AFIFO_RST_4 (BIT(14)) -#define RMT_AFIFO_RST_4_M (RMT_AFIFO_RST_4_V << RMT_AFIFO_RST_4_S) -#define RMT_AFIFO_RST_4_V 0x00000001U -#define RMT_AFIFO_RST_4_S 14 -/** RMT_CONF_UPDATE_4 : WT; bitpos: [15]; default: 0; +#define RMT_AFIFO_RST_CH4 (BIT(14)) +#define RMT_AFIFO_RST_CH4_M (RMT_AFIFO_RST_CH4_V << RMT_AFIFO_RST_CH4_S) +#define RMT_AFIFO_RST_CH4_V 0x00000001U +#define RMT_AFIFO_RST_CH4_S 14 +/** RMT_CONF_UPDATE_CH4 : WT; bitpos: [15]; default: 0; * synchronization bit for CHANNEL4 */ -#define RMT_CONF_UPDATE_4 (BIT(15)) -#define RMT_CONF_UPDATE_4_M (RMT_CONF_UPDATE_4_V << RMT_CONF_UPDATE_4_S) -#define RMT_CONF_UPDATE_4_V 0x00000001U -#define RMT_CONF_UPDATE_4_S 15 +#define RMT_CONF_UPDATE_CH4 (BIT(15)) +#define RMT_CONF_UPDATE_CH4_M (RMT_CONF_UPDATE_CH4_V << RMT_CONF_UPDATE_CH4_S) +#define RMT_CONF_UPDATE_CH4_V 0x00000001U +#define RMT_CONF_UPDATE_CH4_S 15 /** RMT_CH5CONF0_REG register * Channel 5 configure register 0 */ #define RMT_CH5CONF0_REG (DR_REG_RMT_BASE + 0x38) -/** RMT_DIV_CNT_5 : R/W; bitpos: [7:0]; default: 2; +/** RMT_DIV_CNT_CH5 : R/W; bitpos: [7:0]; default: 2; * This register is used to configure the divider for clock of CHANNEL5. */ -#define RMT_DIV_CNT_5 0x000000FFU -#define RMT_DIV_CNT_5_M (RMT_DIV_CNT_5_V << RMT_DIV_CNT_5_S) -#define RMT_DIV_CNT_5_V 0x000000FFU -#define RMT_DIV_CNT_5_S 0 -/** RMT_IDLE_THRES_5 : R/W; bitpos: [22:8]; default: 32767; +#define RMT_DIV_CNT_CH5 0x000000FFU +#define RMT_DIV_CNT_CH5_M (RMT_DIV_CNT_CH5_V << RMT_DIV_CNT_CH5_S) +#define RMT_DIV_CNT_CH5_V 0x000000FFU +#define RMT_DIV_CNT_CH5_S 0 +/** RMT_IDLE_THRES_CH5 : R/W; bitpos: [22:8]; default: 32767; * When no edge is detected on the input signal and continuous clock cycles is longer * than this register value, received process is finished. */ -#define RMT_IDLE_THRES_5 0x00007FFFU -#define RMT_IDLE_THRES_5_M (RMT_IDLE_THRES_5_V << RMT_IDLE_THRES_5_S) -#define RMT_IDLE_THRES_5_V 0x00007FFFU -#define RMT_IDLE_THRES_5_S 8 -/** RMT_MEM_SIZE_5 : R/W; bitpos: [27:24]; default: 1; +#define RMT_IDLE_THRES_CH5 0x00007FFFU +#define RMT_IDLE_THRES_CH5_M (RMT_IDLE_THRES_CH5_V << RMT_IDLE_THRES_CH5_S) +#define RMT_IDLE_THRES_CH5_V 0x00007FFFU +#define RMT_IDLE_THRES_CH5_S 8 +/** RMT_MEM_SIZE_CH5 : R/W; bitpos: [27:24]; default: 1; * This register is used to configure the maximum size of memory allocated to CHANNEL5. */ -#define RMT_MEM_SIZE_5 0x0000000FU -#define RMT_MEM_SIZE_5_M (RMT_MEM_SIZE_5_V << RMT_MEM_SIZE_5_S) -#define RMT_MEM_SIZE_5_V 0x0000000FU -#define RMT_MEM_SIZE_5_S 24 -/** RMT_CARRIER_EN_5 : R/W; bitpos: [28]; default: 1; +#define RMT_MEM_SIZE_CH5 0x0000000FU +#define RMT_MEM_SIZE_CH5_M (RMT_MEM_SIZE_CH5_V << RMT_MEM_SIZE_CH5_S) +#define RMT_MEM_SIZE_CH5_V 0x0000000FU +#define RMT_MEM_SIZE_CH5_S 24 +/** RMT_CARRIER_EN_CH5 : R/W; bitpos: [28]; default: 1; * This is the carrier modulation enable-control bit for CHANNEL5. 1: Add carrier * modulation in the output signal. 0: No carrier modulation in sig_out. */ -#define RMT_CARRIER_EN_5 (BIT(28)) -#define RMT_CARRIER_EN_5_M (RMT_CARRIER_EN_5_V << RMT_CARRIER_EN_5_S) -#define RMT_CARRIER_EN_5_V 0x00000001U -#define RMT_CARRIER_EN_5_S 28 -/** RMT_CARRIER_OUT_LV_5 : R/W; bitpos: [29]; default: 1; +#define RMT_CARRIER_EN_CH5 (BIT(28)) +#define RMT_CARRIER_EN_CH5_M (RMT_CARRIER_EN_CH5_V << RMT_CARRIER_EN_CH5_S) +#define RMT_CARRIER_EN_CH5_V 0x00000001U +#define RMT_CARRIER_EN_CH5_S 28 +/** RMT_CARRIER_OUT_LV_CH5 : R/W; bitpos: [29]; default: 1; * This bit is used to configure the position of carrier wave for CHANNEL5. * * 1'h0: add carrier wave on low level. * * 1'h1: add carrier wave on high level. */ -#define RMT_CARRIER_OUT_LV_5 (BIT(29)) -#define RMT_CARRIER_OUT_LV_5_M (RMT_CARRIER_OUT_LV_5_V << RMT_CARRIER_OUT_LV_5_S) -#define RMT_CARRIER_OUT_LV_5_V 0x00000001U -#define RMT_CARRIER_OUT_LV_5_S 29 +#define RMT_CARRIER_OUT_LV_CH5 (BIT(29)) +#define RMT_CARRIER_OUT_LV_CH5_M (RMT_CARRIER_OUT_LV_CH5_V << RMT_CARRIER_OUT_LV_CH5_S) +#define RMT_CARRIER_OUT_LV_CH5_V 0x00000001U +#define RMT_CARRIER_OUT_LV_CH5_S 29 /** RMT_CH5CONF1_REG register * Channel 5 configure register 1 */ #define RMT_CH5CONF1_REG (DR_REG_RMT_BASE + 0x3c) -/** RMT_RX_EN_5 : R/W; bitpos: [0]; default: 0; +/** RMT_RX_EN_CH5 : R/W; bitpos: [0]; default: 0; * Set this bit to enable receiver to receive data on CHANNEL5. */ -#define RMT_RX_EN_5 (BIT(0)) -#define RMT_RX_EN_5_M (RMT_RX_EN_5_V << RMT_RX_EN_5_S) -#define RMT_RX_EN_5_V 0x00000001U -#define RMT_RX_EN_5_S 0 -/** RMT_MEM_WR_RST_5 : WT; bitpos: [1]; default: 0; +#define RMT_RX_EN_CH5 (BIT(0)) +#define RMT_RX_EN_CH5_M (RMT_RX_EN_CH5_V << RMT_RX_EN_CH5_S) +#define RMT_RX_EN_CH5_V 0x00000001U +#define RMT_RX_EN_CH5_S 0 +/** RMT_MEM_WR_RST_CH5 : WT; bitpos: [1]; default: 0; * Set this bit to reset write ram address for CHANNEL5 by accessing receiver. */ -#define RMT_MEM_WR_RST_5 (BIT(1)) -#define RMT_MEM_WR_RST_5_M (RMT_MEM_WR_RST_5_V << RMT_MEM_WR_RST_5_S) -#define RMT_MEM_WR_RST_5_V 0x00000001U -#define RMT_MEM_WR_RST_5_S 1 -/** RMT_APB_MEM_RST_5 : WT; bitpos: [2]; default: 0; +#define RMT_MEM_WR_RST_CH5 (BIT(1)) +#define RMT_MEM_WR_RST_CH5_M (RMT_MEM_WR_RST_CH5_V << RMT_MEM_WR_RST_CH5_S) +#define RMT_MEM_WR_RST_CH5_V 0x00000001U +#define RMT_MEM_WR_RST_CH5_S 1 +/** RMT_APB_MEM_RST_CH5 : WT; bitpos: [2]; default: 0; * Set this bit to reset W/R ram address for CHANNEL5 by accessing apb fifo. */ -#define RMT_APB_MEM_RST_5 (BIT(2)) -#define RMT_APB_MEM_RST_5_M (RMT_APB_MEM_RST_5_V << RMT_APB_MEM_RST_5_S) -#define RMT_APB_MEM_RST_5_V 0x00000001U -#define RMT_APB_MEM_RST_5_S 2 -/** RMT_MEM_OWNER_5 : R/W/SC; bitpos: [3]; default: 1; +#define RMT_APB_MEM_RST_CH5 (BIT(2)) +#define RMT_APB_MEM_RST_CH5_M (RMT_APB_MEM_RST_CH5_V << RMT_APB_MEM_RST_CH5_S) +#define RMT_APB_MEM_RST_CH5_V 0x00000001U +#define RMT_APB_MEM_RST_CH5_S 2 +/** RMT_MEM_OWNER_CH5 : R/W/SC; bitpos: [3]; default: 1; * This register marks the ownership of CHANNEL5's ram block. * * 1'h1: Receiver is using the ram. * * 1'h0: APB bus is using the ram. */ -#define RMT_MEM_OWNER_5 (BIT(3)) -#define RMT_MEM_OWNER_5_M (RMT_MEM_OWNER_5_V << RMT_MEM_OWNER_5_S) -#define RMT_MEM_OWNER_5_V 0x00000001U -#define RMT_MEM_OWNER_5_S 3 -/** RMT_RX_FILTER_EN_5 : R/W; bitpos: [4]; default: 0; +#define RMT_MEM_OWNER_CH5 (BIT(3)) +#define RMT_MEM_OWNER_CH5_M (RMT_MEM_OWNER_CH5_V << RMT_MEM_OWNER_CH5_S) +#define RMT_MEM_OWNER_CH5_V 0x00000001U +#define RMT_MEM_OWNER_CH5_S 3 +/** RMT_RX_FILTER_EN_CH5 : R/W; bitpos: [4]; default: 0; * This is the receive filter's enable bit for CHANNEL5. */ -#define RMT_RX_FILTER_EN_5 (BIT(4)) -#define RMT_RX_FILTER_EN_5_M (RMT_RX_FILTER_EN_5_V << RMT_RX_FILTER_EN_5_S) -#define RMT_RX_FILTER_EN_5_V 0x00000001U -#define RMT_RX_FILTER_EN_5_S 4 -/** RMT_RX_FILTER_THRES_5 : R/W; bitpos: [12:5]; default: 15; +#define RMT_RX_FILTER_EN_CH5 (BIT(4)) +#define RMT_RX_FILTER_EN_CH5_M (RMT_RX_FILTER_EN_CH5_V << RMT_RX_FILTER_EN_CH5_S) +#define RMT_RX_FILTER_EN_CH5_V 0x00000001U +#define RMT_RX_FILTER_EN_CH5_S 4 +/** RMT_RX_FILTER_THRES_CH5 : R/W; bitpos: [12:5]; default: 15; * Ignores the input pulse when its width is smaller than this register value in APB * clock periods (in receive mode). */ -#define RMT_RX_FILTER_THRES_5 0x000000FFU -#define RMT_RX_FILTER_THRES_5_M (RMT_RX_FILTER_THRES_5_V << RMT_RX_FILTER_THRES_5_S) -#define RMT_RX_FILTER_THRES_5_V 0x000000FFU -#define RMT_RX_FILTER_THRES_5_S 5 -/** RMT_MEM_RX_WRAP_EN_5 : R/W; bitpos: [13]; default: 0; +#define RMT_RX_FILTER_THRES_CH5 0x000000FFU +#define RMT_RX_FILTER_THRES_CH5_M (RMT_RX_FILTER_THRES_CH5_V << RMT_RX_FILTER_THRES_CH5_S) +#define RMT_RX_FILTER_THRES_CH5_V 0x000000FFU +#define RMT_RX_FILTER_THRES_CH5_S 5 +/** RMT_MEM_RX_WRAP_EN_CH5 : R/W; bitpos: [13]; default: 0; * This is the channel 5 enable bit for wraparound mode: it will resume receiving at * the start when the data to be received is more than its memory size. */ -#define RMT_MEM_RX_WRAP_EN_5 (BIT(13)) -#define RMT_MEM_RX_WRAP_EN_5_M (RMT_MEM_RX_WRAP_EN_5_V << RMT_MEM_RX_WRAP_EN_5_S) -#define RMT_MEM_RX_WRAP_EN_5_V 0x00000001U -#define RMT_MEM_RX_WRAP_EN_5_S 13 -/** RMT_AFIFO_RST_5 : WT; bitpos: [14]; default: 0; +#define RMT_MEM_RX_WRAP_EN_CH5 (BIT(13)) +#define RMT_MEM_RX_WRAP_EN_CH5_M (RMT_MEM_RX_WRAP_EN_CH5_V << RMT_MEM_RX_WRAP_EN_CH5_S) +#define RMT_MEM_RX_WRAP_EN_CH5_V 0x00000001U +#define RMT_MEM_RX_WRAP_EN_CH5_S 13 +/** RMT_AFIFO_RST_CH5 : WT; bitpos: [14]; default: 0; * Reserved */ -#define RMT_AFIFO_RST_5 (BIT(14)) -#define RMT_AFIFO_RST_5_M (RMT_AFIFO_RST_5_V << RMT_AFIFO_RST_5_S) -#define RMT_AFIFO_RST_5_V 0x00000001U -#define RMT_AFIFO_RST_5_S 14 -/** RMT_CONF_UPDATE_5 : WT; bitpos: [15]; default: 0; +#define RMT_AFIFO_RST_CH5 (BIT(14)) +#define RMT_AFIFO_RST_CH5_M (RMT_AFIFO_RST_CH5_V << RMT_AFIFO_RST_CH5_S) +#define RMT_AFIFO_RST_CH5_V 0x00000001U +#define RMT_AFIFO_RST_CH5_S 14 +/** RMT_CONF_UPDATE_CH5 : WT; bitpos: [15]; default: 0; * synchronization bit for CHANNEL5 */ -#define RMT_CONF_UPDATE_5 (BIT(15)) -#define RMT_CONF_UPDATE_5_M (RMT_CONF_UPDATE_5_V << RMT_CONF_UPDATE_5_S) -#define RMT_CONF_UPDATE_5_V 0x00000001U -#define RMT_CONF_UPDATE_5_S 15 +#define RMT_CONF_UPDATE_CH5 (BIT(15)) +#define RMT_CONF_UPDATE_CH5_M (RMT_CONF_UPDATE_CH5_V << RMT_CONF_UPDATE_CH5_S) +#define RMT_CONF_UPDATE_CH5_V 0x00000001U +#define RMT_CONF_UPDATE_CH5_S 15 /** RMT_CH6CONF0_REG register * Channel 6 configure register 0 */ #define RMT_CH6CONF0_REG (DR_REG_RMT_BASE + 0x40) -/** RMT_DIV_CNT_6 : R/W; bitpos: [7:0]; default: 2; +/** RMT_DIV_CNT_CH6 : R/W; bitpos: [7:0]; default: 2; * This register is used to configure the divider for clock of CHANNEL6. */ -#define RMT_DIV_CNT_6 0x000000FFU -#define RMT_DIV_CNT_6_M (RMT_DIV_CNT_6_V << RMT_DIV_CNT_6_S) -#define RMT_DIV_CNT_6_V 0x000000FFU -#define RMT_DIV_CNT_6_S 0 -/** RMT_IDLE_THRES_6 : R/W; bitpos: [22:8]; default: 32767; +#define RMT_DIV_CNT_CH6 0x000000FFU +#define RMT_DIV_CNT_CH6_M (RMT_DIV_CNT_CH6_V << RMT_DIV_CNT_CH6_S) +#define RMT_DIV_CNT_CH6_V 0x000000FFU +#define RMT_DIV_CNT_CH6_S 0 +/** RMT_IDLE_THRES_CH6 : R/W; bitpos: [22:8]; default: 32767; * When no edge is detected on the input signal and continuous clock cycles is longer * than this register value, received process is finished. */ -#define RMT_IDLE_THRES_6 0x00007FFFU -#define RMT_IDLE_THRES_6_M (RMT_IDLE_THRES_6_V << RMT_IDLE_THRES_6_S) -#define RMT_IDLE_THRES_6_V 0x00007FFFU -#define RMT_IDLE_THRES_6_S 8 -/** RMT_MEM_SIZE_6 : R/W; bitpos: [27:24]; default: 1; +#define RMT_IDLE_THRES_CH6 0x00007FFFU +#define RMT_IDLE_THRES_CH6_M (RMT_IDLE_THRES_CH6_V << RMT_IDLE_THRES_CH6_S) +#define RMT_IDLE_THRES_CH6_V 0x00007FFFU +#define RMT_IDLE_THRES_CH6_S 8 +/** RMT_MEM_SIZE_CH6 : R/W; bitpos: [27:24]; default: 1; * This register is used to configure the maximum size of memory allocated to CHANNEL6. */ -#define RMT_MEM_SIZE_6 0x0000000FU -#define RMT_MEM_SIZE_6_M (RMT_MEM_SIZE_6_V << RMT_MEM_SIZE_6_S) -#define RMT_MEM_SIZE_6_V 0x0000000FU -#define RMT_MEM_SIZE_6_S 24 -/** RMT_CARRIER_EN_6 : R/W; bitpos: [28]; default: 1; +#define RMT_MEM_SIZE_CH6 0x0000000FU +#define RMT_MEM_SIZE_CH6_M (RMT_MEM_SIZE_CH6_V << RMT_MEM_SIZE_CH6_S) +#define RMT_MEM_SIZE_CH6_V 0x0000000FU +#define RMT_MEM_SIZE_CH6_S 24 +/** RMT_CARRIER_EN_CH6 : R/W; bitpos: [28]; default: 1; * This is the carrier modulation enable-control bit for CHANNEL6. 1: Add carrier * modulation in the output signal. 0: No carrier modulation in sig_out. */ -#define RMT_CARRIER_EN_6 (BIT(28)) -#define RMT_CARRIER_EN_6_M (RMT_CARRIER_EN_6_V << RMT_CARRIER_EN_6_S) -#define RMT_CARRIER_EN_6_V 0x00000001U -#define RMT_CARRIER_EN_6_S 28 -/** RMT_CARRIER_OUT_LV_6 : R/W; bitpos: [29]; default: 1; +#define RMT_CARRIER_EN_CH6 (BIT(28)) +#define RMT_CARRIER_EN_CH6_M (RMT_CARRIER_EN_CH6_V << RMT_CARRIER_EN_CH6_S) +#define RMT_CARRIER_EN_CH6_V 0x00000001U +#define RMT_CARRIER_EN_CH6_S 28 +/** RMT_CARRIER_OUT_LV_CH6 : R/W; bitpos: [29]; default: 1; * This bit is used to configure the position of carrier wave for CHANNEL6. * * 1'h0: add carrier wave on low level. * * 1'h1: add carrier wave on high level. */ -#define RMT_CARRIER_OUT_LV_6 (BIT(29)) -#define RMT_CARRIER_OUT_LV_6_M (RMT_CARRIER_OUT_LV_6_V << RMT_CARRIER_OUT_LV_6_S) -#define RMT_CARRIER_OUT_LV_6_V 0x00000001U -#define RMT_CARRIER_OUT_LV_6_S 29 +#define RMT_CARRIER_OUT_LV_CH6 (BIT(29)) +#define RMT_CARRIER_OUT_LV_CH6_M (RMT_CARRIER_OUT_LV_CH6_V << RMT_CARRIER_OUT_LV_CH6_S) +#define RMT_CARRIER_OUT_LV_CH6_V 0x00000001U +#define RMT_CARRIER_OUT_LV_CH6_S 29 /** RMT_CH6CONF1_REG register * Channel 6 configure register 1 */ #define RMT_CH6CONF1_REG (DR_REG_RMT_BASE + 0x44) -/** RMT_RX_EN_6 : R/W; bitpos: [0]; default: 0; +/** RMT_RX_EN_CH6 : R/W; bitpos: [0]; default: 0; * Set this bit to enable receiver to receive data on CHANNEL6. */ -#define RMT_RX_EN_6 (BIT(0)) -#define RMT_RX_EN_6_M (RMT_RX_EN_6_V << RMT_RX_EN_6_S) -#define RMT_RX_EN_6_V 0x00000001U -#define RMT_RX_EN_6_S 0 -/** RMT_MEM_WR_RST_6 : WT; bitpos: [1]; default: 0; +#define RMT_RX_EN_CH6 (BIT(0)) +#define RMT_RX_EN_CH6_M (RMT_RX_EN_CH6_V << RMT_RX_EN_CH6_S) +#define RMT_RX_EN_CH6_V 0x00000001U +#define RMT_RX_EN_CH6_S 0 +/** RMT_MEM_WR_RST_CH6 : WT; bitpos: [1]; default: 0; * Set this bit to reset write ram address for CHANNEL6 by accessing receiver. */ -#define RMT_MEM_WR_RST_6 (BIT(1)) -#define RMT_MEM_WR_RST_6_M (RMT_MEM_WR_RST_6_V << RMT_MEM_WR_RST_6_S) -#define RMT_MEM_WR_RST_6_V 0x00000001U -#define RMT_MEM_WR_RST_6_S 1 -/** RMT_APB_MEM_RST_6 : WT; bitpos: [2]; default: 0; +#define RMT_MEM_WR_RST_CH6 (BIT(1)) +#define RMT_MEM_WR_RST_CH6_M (RMT_MEM_WR_RST_CH6_V << RMT_MEM_WR_RST_CH6_S) +#define RMT_MEM_WR_RST_CH6_V 0x00000001U +#define RMT_MEM_WR_RST_CH6_S 1 +/** RMT_APB_MEM_RST_CH6 : WT; bitpos: [2]; default: 0; * Set this bit to reset W/R ram address for CHANNEL6 by accessing apb fifo. */ -#define RMT_APB_MEM_RST_6 (BIT(2)) -#define RMT_APB_MEM_RST_6_M (RMT_APB_MEM_RST_6_V << RMT_APB_MEM_RST_6_S) -#define RMT_APB_MEM_RST_6_V 0x00000001U -#define RMT_APB_MEM_RST_6_S 2 -/** RMT_MEM_OWNER_6 : R/W/SC; bitpos: [3]; default: 1; +#define RMT_APB_MEM_RST_CH6 (BIT(2)) +#define RMT_APB_MEM_RST_CH6_M (RMT_APB_MEM_RST_CH6_V << RMT_APB_MEM_RST_CH6_S) +#define RMT_APB_MEM_RST_CH6_V 0x00000001U +#define RMT_APB_MEM_RST_CH6_S 2 +/** RMT_MEM_OWNER_CH6 : R/W/SC; bitpos: [3]; default: 1; * This register marks the ownership of CHANNEL6's ram block. * * 1'h1: Receiver is using the ram. * * 1'h0: APB bus is using the ram. */ -#define RMT_MEM_OWNER_6 (BIT(3)) -#define RMT_MEM_OWNER_6_M (RMT_MEM_OWNER_6_V << RMT_MEM_OWNER_6_S) -#define RMT_MEM_OWNER_6_V 0x00000001U -#define RMT_MEM_OWNER_6_S 3 -/** RMT_RX_FILTER_EN_6 : R/W; bitpos: [4]; default: 0; +#define RMT_MEM_OWNER_CH6 (BIT(3)) +#define RMT_MEM_OWNER_CH6_M (RMT_MEM_OWNER_CH6_V << RMT_MEM_OWNER_CH6_S) +#define RMT_MEM_OWNER_CH6_V 0x00000001U +#define RMT_MEM_OWNER_CH6_S 3 +/** RMT_RX_FILTER_EN_CH6 : R/W; bitpos: [4]; default: 0; * This is the receive filter's enable bit for CHANNEL6. */ -#define RMT_RX_FILTER_EN_6 (BIT(4)) -#define RMT_RX_FILTER_EN_6_M (RMT_RX_FILTER_EN_6_V << RMT_RX_FILTER_EN_6_S) -#define RMT_RX_FILTER_EN_6_V 0x00000001U -#define RMT_RX_FILTER_EN_6_S 4 -/** RMT_RX_FILTER_THRES_6 : R/W; bitpos: [12:5]; default: 15; +#define RMT_RX_FILTER_EN_CH6 (BIT(4)) +#define RMT_RX_FILTER_EN_CH6_M (RMT_RX_FILTER_EN_CH6_V << RMT_RX_FILTER_EN_CH6_S) +#define RMT_RX_FILTER_EN_CH6_V 0x00000001U +#define RMT_RX_FILTER_EN_CH6_S 4 +/** RMT_RX_FILTER_THRES_CH6 : R/W; bitpos: [12:5]; default: 15; * Ignores the input pulse when its width is smaller than this register value in APB * clock periods (in receive mode). */ -#define RMT_RX_FILTER_THRES_6 0x000000FFU -#define RMT_RX_FILTER_THRES_6_M (RMT_RX_FILTER_THRES_6_V << RMT_RX_FILTER_THRES_6_S) -#define RMT_RX_FILTER_THRES_6_V 0x000000FFU -#define RMT_RX_FILTER_THRES_6_S 5 -/** RMT_MEM_RX_WRAP_EN_6 : R/W; bitpos: [13]; default: 0; +#define RMT_RX_FILTER_THRES_CH6 0x000000FFU +#define RMT_RX_FILTER_THRES_CH6_M (RMT_RX_FILTER_THRES_CH6_V << RMT_RX_FILTER_THRES_CH6_S) +#define RMT_RX_FILTER_THRES_CH6_V 0x000000FFU +#define RMT_RX_FILTER_THRES_CH6_S 5 +/** RMT_MEM_RX_WRAP_EN_CH6 : R/W; bitpos: [13]; default: 0; * This is the channel 6 enable bit for wraparound mode: it will resume receiving at * the start when the data to be received is more than its memory size. */ -#define RMT_MEM_RX_WRAP_EN_6 (BIT(13)) -#define RMT_MEM_RX_WRAP_EN_6_M (RMT_MEM_RX_WRAP_EN_6_V << RMT_MEM_RX_WRAP_EN_6_S) -#define RMT_MEM_RX_WRAP_EN_6_V 0x00000001U -#define RMT_MEM_RX_WRAP_EN_6_S 13 -/** RMT_AFIFO_RST_6 : WT; bitpos: [14]; default: 0; +#define RMT_MEM_RX_WRAP_EN_CH6 (BIT(13)) +#define RMT_MEM_RX_WRAP_EN_CH6_M (RMT_MEM_RX_WRAP_EN_CH6_V << RMT_MEM_RX_WRAP_EN_CH6_S) +#define RMT_MEM_RX_WRAP_EN_CH6_V 0x00000001U +#define RMT_MEM_RX_WRAP_EN_CH6_S 13 +/** RMT_AFIFO_RST_CH6 : WT; bitpos: [14]; default: 0; * Reserved */ -#define RMT_AFIFO_RST_6 (BIT(14)) -#define RMT_AFIFO_RST_6_M (RMT_AFIFO_RST_6_V << RMT_AFIFO_RST_6_S) -#define RMT_AFIFO_RST_6_V 0x00000001U -#define RMT_AFIFO_RST_6_S 14 -/** RMT_CONF_UPDATE_6 : WT; bitpos: [15]; default: 0; +#define RMT_AFIFO_RST_CH6 (BIT(14)) +#define RMT_AFIFO_RST_CH6_M (RMT_AFIFO_RST_CH6_V << RMT_AFIFO_RST_CH6_S) +#define RMT_AFIFO_RST_CH6_V 0x00000001U +#define RMT_AFIFO_RST_CH6_S 14 +/** RMT_CONF_UPDATE_CH6 : WT; bitpos: [15]; default: 0; * synchronization bit for CHANNEL6 */ -#define RMT_CONF_UPDATE_6 (BIT(15)) -#define RMT_CONF_UPDATE_6_M (RMT_CONF_UPDATE_6_V << RMT_CONF_UPDATE_6_S) -#define RMT_CONF_UPDATE_6_V 0x00000001U -#define RMT_CONF_UPDATE_6_S 15 +#define RMT_CONF_UPDATE_CH6 (BIT(15)) +#define RMT_CONF_UPDATE_CH6_M (RMT_CONF_UPDATE_CH6_V << RMT_CONF_UPDATE_CH6_S) +#define RMT_CONF_UPDATE_CH6_V 0x00000001U +#define RMT_CONF_UPDATE_CH6_S 15 /** RMT_CH7CONF0_REG register * Channel 7 configure register 0 */ #define RMT_CH7CONF0_REG (DR_REG_RMT_BASE + 0x48) -/** RMT_DIV_CNT_7 : R/W; bitpos: [7:0]; default: 2; +/** RMT_DIV_CNT_CH7 : R/W; bitpos: [7:0]; default: 2; * This register is used to configure the divider for clock of CHANNEL7. */ -#define RMT_DIV_CNT_7 0x000000FFU -#define RMT_DIV_CNT_7_M (RMT_DIV_CNT_7_V << RMT_DIV_CNT_7_S) -#define RMT_DIV_CNT_7_V 0x000000FFU -#define RMT_DIV_CNT_7_S 0 -/** RMT_IDLE_THRES_7 : R/W; bitpos: [22:8]; default: 32767; +#define RMT_DIV_CNT_CH7 0x000000FFU +#define RMT_DIV_CNT_CH7_M (RMT_DIV_CNT_CH7_V << RMT_DIV_CNT_CH7_S) +#define RMT_DIV_CNT_CH7_V 0x000000FFU +#define RMT_DIV_CNT_CH7_S 0 +/** RMT_IDLE_THRES_CH7 : R/W; bitpos: [22:8]; default: 32767; * When no edge is detected on the input signal and continuous clock cycles is longer * than this register value, received process is finished. */ -#define RMT_IDLE_THRES_7 0x00007FFFU -#define RMT_IDLE_THRES_7_M (RMT_IDLE_THRES_7_V << RMT_IDLE_THRES_7_S) -#define RMT_IDLE_THRES_7_V 0x00007FFFU -#define RMT_IDLE_THRES_7_S 8 -/** RMT_MEM_SIZE_7 : R/W; bitpos: [27:24]; default: 1; +#define RMT_IDLE_THRES_CH7 0x00007FFFU +#define RMT_IDLE_THRES_CH7_M (RMT_IDLE_THRES_CH7_V << RMT_IDLE_THRES_CH7_S) +#define RMT_IDLE_THRES_CH7_V 0x00007FFFU +#define RMT_IDLE_THRES_CH7_S 8 +/** RMT_MEM_SIZE_CH7 : R/W; bitpos: [27:24]; default: 1; * This register is used to configure the maximum size of memory allocated to CHANNEL7. */ -#define RMT_MEM_SIZE_7 0x0000000FU -#define RMT_MEM_SIZE_7_M (RMT_MEM_SIZE_7_V << RMT_MEM_SIZE_7_S) -#define RMT_MEM_SIZE_7_V 0x0000000FU -#define RMT_MEM_SIZE_7_S 24 -/** RMT_CARRIER_EN_7 : R/W; bitpos: [28]; default: 1; +#define RMT_MEM_SIZE_CH7 0x0000000FU +#define RMT_MEM_SIZE_CH7_M (RMT_MEM_SIZE_CH7_V << RMT_MEM_SIZE_CH7_S) +#define RMT_MEM_SIZE_CH7_V 0x0000000FU +#define RMT_MEM_SIZE_CH7_S 24 +/** RMT_CARRIER_EN_CH7 : R/W; bitpos: [28]; default: 1; * This is the carrier modulation enable-control bit for CHANNEL7. 1: Add carrier * modulation in the output signal. 0: No carrier modulation in sig_out. */ -#define RMT_CARRIER_EN_7 (BIT(28)) -#define RMT_CARRIER_EN_7_M (RMT_CARRIER_EN_7_V << RMT_CARRIER_EN_7_S) -#define RMT_CARRIER_EN_7_V 0x00000001U -#define RMT_CARRIER_EN_7_S 28 -/** RMT_CARRIER_OUT_LV_7 : R/W; bitpos: [29]; default: 1; +#define RMT_CARRIER_EN_CH7 (BIT(28)) +#define RMT_CARRIER_EN_CH7_M (RMT_CARRIER_EN_CH7_V << RMT_CARRIER_EN_CH7_S) +#define RMT_CARRIER_EN_CH7_V 0x00000001U +#define RMT_CARRIER_EN_CH7_S 28 +/** RMT_CARRIER_OUT_LV_CH7 : R/W; bitpos: [29]; default: 1; * This bit is used to configure the position of carrier wave for CHANNEL7. * * 1'h0: add carrier wave on low level. * * 1'h1: add carrier wave on high level. */ -#define RMT_CARRIER_OUT_LV_7 (BIT(29)) -#define RMT_CARRIER_OUT_LV_7_M (RMT_CARRIER_OUT_LV_7_V << RMT_CARRIER_OUT_LV_7_S) -#define RMT_CARRIER_OUT_LV_7_V 0x00000001U -#define RMT_CARRIER_OUT_LV_7_S 29 +#define RMT_CARRIER_OUT_LV_CH7 (BIT(29)) +#define RMT_CARRIER_OUT_LV_CH7_M (RMT_CARRIER_OUT_LV_CH7_V << RMT_CARRIER_OUT_LV_CH7_S) +#define RMT_CARRIER_OUT_LV_CH7_V 0x00000001U +#define RMT_CARRIER_OUT_LV_CH7_S 29 /** RMT_CH7CONF1_REG register * Channel 7 configure register 1 */ #define RMT_CH7CONF1_REG (DR_REG_RMT_BASE + 0x4c) -/** RMT_RX_EN_7 : R/W; bitpos: [0]; default: 0; +/** RMT_RX_EN_CH7 : R/W; bitpos: [0]; default: 0; * Set this bit to enable receiver to receive data on CHANNEL7. */ -#define RMT_RX_EN_7 (BIT(0)) -#define RMT_RX_EN_7_M (RMT_RX_EN_7_V << RMT_RX_EN_7_S) -#define RMT_RX_EN_7_V 0x00000001U -#define RMT_RX_EN_7_S 0 -/** RMT_MEM_WR_RST_7 : WT; bitpos: [1]; default: 0; +#define RMT_RX_EN_CH7 (BIT(0)) +#define RMT_RX_EN_CH7_M (RMT_RX_EN_CH7_V << RMT_RX_EN_CH7_S) +#define RMT_RX_EN_CH7_V 0x00000001U +#define RMT_RX_EN_CH7_S 0 +/** RMT_MEM_WR_RST_CH7 : WT; bitpos: [1]; default: 0; * Set this bit to reset write ram address for CHANNEL7 by accessing receiver. */ -#define RMT_MEM_WR_RST_7 (BIT(1)) -#define RMT_MEM_WR_RST_7_M (RMT_MEM_WR_RST_7_V << RMT_MEM_WR_RST_7_S) -#define RMT_MEM_WR_RST_7_V 0x00000001U -#define RMT_MEM_WR_RST_7_S 1 -/** RMT_APB_MEM_RST_7 : WT; bitpos: [2]; default: 0; +#define RMT_MEM_WR_RST_CH7 (BIT(1)) +#define RMT_MEM_WR_RST_CH7_M (RMT_MEM_WR_RST_CH7_V << RMT_MEM_WR_RST_CH7_S) +#define RMT_MEM_WR_RST_CH7_V 0x00000001U +#define RMT_MEM_WR_RST_CH7_S 1 +/** RMT_APB_MEM_RST_CH7 : WT; bitpos: [2]; default: 0; * Set this bit to reset W/R ram address for CHANNEL7 by accessing apb fifo. */ -#define RMT_APB_MEM_RST_7 (BIT(2)) -#define RMT_APB_MEM_RST_7_M (RMT_APB_MEM_RST_7_V << RMT_APB_MEM_RST_7_S) -#define RMT_APB_MEM_RST_7_V 0x00000001U -#define RMT_APB_MEM_RST_7_S 2 -/** RMT_MEM_OWNER_7 : R/W/SC; bitpos: [3]; default: 1; +#define RMT_APB_MEM_RST_CH7 (BIT(2)) +#define RMT_APB_MEM_RST_CH7_M (RMT_APB_MEM_RST_CH7_V << RMT_APB_MEM_RST_CH7_S) +#define RMT_APB_MEM_RST_CH7_V 0x00000001U +#define RMT_APB_MEM_RST_CH7_S 2 +/** RMT_MEM_OWNER_CH7 : R/W/SC; bitpos: [3]; default: 1; * This register marks the ownership of CHANNEL7's ram block. * * 1'h1: Receiver is using the ram. * * 1'h0: APB bus is using the ram. */ -#define RMT_MEM_OWNER_7 (BIT(3)) -#define RMT_MEM_OWNER_7_M (RMT_MEM_OWNER_7_V << RMT_MEM_OWNER_7_S) -#define RMT_MEM_OWNER_7_V 0x00000001U -#define RMT_MEM_OWNER_7_S 3 -/** RMT_RX_FILTER_EN_7 : R/W; bitpos: [4]; default: 0; +#define RMT_MEM_OWNER_CH7 (BIT(3)) +#define RMT_MEM_OWNER_CH7_M (RMT_MEM_OWNER_CH7_V << RMT_MEM_OWNER_CH7_S) +#define RMT_MEM_OWNER_CH7_V 0x00000001U +#define RMT_MEM_OWNER_CH7_S 3 +/** RMT_RX_FILTER_EN_CH7 : R/W; bitpos: [4]; default: 0; * This is the receive filter's enable bit for CHANNEL7. */ -#define RMT_RX_FILTER_EN_7 (BIT(4)) -#define RMT_RX_FILTER_EN_7_M (RMT_RX_FILTER_EN_7_V << RMT_RX_FILTER_EN_7_S) -#define RMT_RX_FILTER_EN_7_V 0x00000001U -#define RMT_RX_FILTER_EN_7_S 4 -/** RMT_RX_FILTER_THRES_7 : R/W; bitpos: [12:5]; default: 15; +#define RMT_RX_FILTER_EN_CH7 (BIT(4)) +#define RMT_RX_FILTER_EN_CH7_M (RMT_RX_FILTER_EN_CH7_V << RMT_RX_FILTER_EN_CH7_S) +#define RMT_RX_FILTER_EN_CH7_V 0x00000001U +#define RMT_RX_FILTER_EN_CH7_S 4 +/** RMT_RX_FILTER_THRES_CH7 : R/W; bitpos: [12:5]; default: 15; * Ignores the input pulse when its width is smaller than this register value in APB * clock periods (in receive mode). */ -#define RMT_RX_FILTER_THRES_7 0x000000FFU -#define RMT_RX_FILTER_THRES_7_M (RMT_RX_FILTER_THRES_7_V << RMT_RX_FILTER_THRES_7_S) -#define RMT_RX_FILTER_THRES_7_V 0x000000FFU -#define RMT_RX_FILTER_THRES_7_S 5 -/** RMT_MEM_RX_WRAP_EN_7 : R/W; bitpos: [13]; default: 0; +#define RMT_RX_FILTER_THRES_CH7 0x000000FFU +#define RMT_RX_FILTER_THRES_CH7_M (RMT_RX_FILTER_THRES_CH7_V << RMT_RX_FILTER_THRES_CH7_S) +#define RMT_RX_FILTER_THRES_CH7_V 0x000000FFU +#define RMT_RX_FILTER_THRES_CH7_S 5 +/** RMT_MEM_RX_WRAP_EN_CH7 : R/W; bitpos: [13]; default: 0; * This is the channel 7 enable bit for wraparound mode: it will resume receiving at * the start when the data to be received is more than its memory size. */ -#define RMT_MEM_RX_WRAP_EN_7 (BIT(13)) -#define RMT_MEM_RX_WRAP_EN_7_M (RMT_MEM_RX_WRAP_EN_7_V << RMT_MEM_RX_WRAP_EN_7_S) -#define RMT_MEM_RX_WRAP_EN_7_V 0x00000001U -#define RMT_MEM_RX_WRAP_EN_7_S 13 -/** RMT_AFIFO_RST_7 : WT; bitpos: [14]; default: 0; +#define RMT_MEM_RX_WRAP_EN_CH7 (BIT(13)) +#define RMT_MEM_RX_WRAP_EN_CH7_M (RMT_MEM_RX_WRAP_EN_CH7_V << RMT_MEM_RX_WRAP_EN_CH7_S) +#define RMT_MEM_RX_WRAP_EN_CH7_V 0x00000001U +#define RMT_MEM_RX_WRAP_EN_CH7_S 13 +/** RMT_AFIFO_RST_CH7 : WT; bitpos: [14]; default: 0; * Reserved */ -#define RMT_AFIFO_RST_7 (BIT(14)) -#define RMT_AFIFO_RST_7_M (RMT_AFIFO_RST_7_V << RMT_AFIFO_RST_7_S) -#define RMT_AFIFO_RST_7_V 0x00000001U -#define RMT_AFIFO_RST_7_S 14 -/** RMT_CONF_UPDATE_7 : WT; bitpos: [15]; default: 0; +#define RMT_AFIFO_RST_CH7 (BIT(14)) +#define RMT_AFIFO_RST_CH7_M (RMT_AFIFO_RST_CH7_V << RMT_AFIFO_RST_CH7_S) +#define RMT_AFIFO_RST_CH7_V 0x00000001U +#define RMT_AFIFO_RST_CH7_S 14 +/** RMT_CONF_UPDATE_CH7 : WT; bitpos: [15]; default: 0; * synchronization bit for CHANNEL7 */ -#define RMT_CONF_UPDATE_7 (BIT(15)) -#define RMT_CONF_UPDATE_7_M (RMT_CONF_UPDATE_7_V << RMT_CONF_UPDATE_7_S) -#define RMT_CONF_UPDATE_7_V 0x00000001U -#define RMT_CONF_UPDATE_7_S 15 +#define RMT_CONF_UPDATE_CH7 (BIT(15)) +#define RMT_CONF_UPDATE_CH7_M (RMT_CONF_UPDATE_CH7_V << RMT_CONF_UPDATE_CH7_S) +#define RMT_CONF_UPDATE_CH7_V 0x00000001U +#define RMT_CONF_UPDATE_CH7_S 15 /** RMT_CH0STATUS_REG register * Channel 0 status register */ #define RMT_CH0STATUS_REG (DR_REG_RMT_BASE + 0x50) -/** RMT_MEM_RADDR_EX_0 : RO; bitpos: [9:0]; default: 0; +/** RMT_MEM_RADDR_EX_CH0 : RO; bitpos: [9:0]; default: 0; * This register records the memory address offset when transmitter of CHANNEL0 is * using the RAM. */ -#define RMT_MEM_RADDR_EX_0 0x000003FFU -#define RMT_MEM_RADDR_EX_0_M (RMT_MEM_RADDR_EX_0_V << RMT_MEM_RADDR_EX_0_S) -#define RMT_MEM_RADDR_EX_0_V 0x000003FFU -#define RMT_MEM_RADDR_EX_0_S 0 -/** RMT_APB_MEM_WADDR_0 : RO; bitpos: [20:11]; default: 0; +#define RMT_MEM_RADDR_EX_CH0 0x000003FFU +#define RMT_MEM_RADDR_EX_CH0_M (RMT_MEM_RADDR_EX_CH0_V << RMT_MEM_RADDR_EX_CH0_S) +#define RMT_MEM_RADDR_EX_CH0_V 0x000003FFU +#define RMT_MEM_RADDR_EX_CH0_S 0 +/** RMT_APB_MEM_WADDR_CH0 : RO; bitpos: [20:11]; default: 0; * This register records the memory address offset when writes RAM over APB bus. */ -#define RMT_APB_MEM_WADDR_0 0x000003FFU -#define RMT_APB_MEM_WADDR_0_M (RMT_APB_MEM_WADDR_0_V << RMT_APB_MEM_WADDR_0_S) -#define RMT_APB_MEM_WADDR_0_V 0x000003FFU -#define RMT_APB_MEM_WADDR_0_S 11 -/** RMT_STATE_0 : RO; bitpos: [24:22]; default: 0; +#define RMT_APB_MEM_WADDR_CH0 0x000003FFU +#define RMT_APB_MEM_WADDR_CH0_M (RMT_APB_MEM_WADDR_CH0_V << RMT_APB_MEM_WADDR_CH0_S) +#define RMT_APB_MEM_WADDR_CH0_V 0x000003FFU +#define RMT_APB_MEM_WADDR_CH0_S 11 +/** RMT_STATE_CH0 : RO; bitpos: [24:22]; default: 0; * This register records the FSM status of CHANNEL0. */ -#define RMT_STATE_0 0x00000007U -#define RMT_STATE_0_M (RMT_STATE_0_V << RMT_STATE_0_S) -#define RMT_STATE_0_V 0x00000007U -#define RMT_STATE_0_S 22 -/** RMT_MEM_EMPTY_0 : RO; bitpos: [25]; default: 0; +#define RMT_STATE_CH0 0x00000007U +#define RMT_STATE_CH0_M (RMT_STATE_CH0_V << RMT_STATE_CH0_S) +#define RMT_STATE_CH0_V 0x00000007U +#define RMT_STATE_CH0_S 22 +/** RMT_MEM_EMPTY_CH0 : RO; bitpos: [25]; default: 0; * This status bit will be set when the data to be set is more than memory size and * the wraparound mode is disabled. */ -#define RMT_MEM_EMPTY_0 (BIT(25)) -#define RMT_MEM_EMPTY_0_M (RMT_MEM_EMPTY_0_V << RMT_MEM_EMPTY_0_S) -#define RMT_MEM_EMPTY_0_V 0x00000001U -#define RMT_MEM_EMPTY_0_S 25 -/** RMT_APB_MEM_WR_ERR_0 : RO; bitpos: [26]; default: 0; +#define RMT_MEM_EMPTY_CH0 (BIT(25)) +#define RMT_MEM_EMPTY_CH0_M (RMT_MEM_EMPTY_CH0_V << RMT_MEM_EMPTY_CH0_S) +#define RMT_MEM_EMPTY_CH0_V 0x00000001U +#define RMT_MEM_EMPTY_CH0_S 25 +/** RMT_APB_MEM_WR_ERR_CH0 : RO; bitpos: [26]; default: 0; * This status bit will be set if the offset address out of memory size when writes * via APB bus. */ -#define RMT_APB_MEM_WR_ERR_0 (BIT(26)) -#define RMT_APB_MEM_WR_ERR_0_M (RMT_APB_MEM_WR_ERR_0_V << RMT_APB_MEM_WR_ERR_0_S) -#define RMT_APB_MEM_WR_ERR_0_V 0x00000001U -#define RMT_APB_MEM_WR_ERR_0_S 26 +#define RMT_APB_MEM_WR_ERR_CH0 (BIT(26)) +#define RMT_APB_MEM_WR_ERR_CH0_M (RMT_APB_MEM_WR_ERR_CH0_V << RMT_APB_MEM_WR_ERR_CH0_S) +#define RMT_APB_MEM_WR_ERR_CH0_V 0x00000001U +#define RMT_APB_MEM_WR_ERR_CH0_S 26 /** RMT_CH1STATUS_REG register * Channel 1 status register */ #define RMT_CH1STATUS_REG (DR_REG_RMT_BASE + 0x54) -/** RMT_MEM_RADDR_EX_1 : RO; bitpos: [9:0]; default: 0; +/** RMT_MEM_RADDR_EX_CH1 : RO; bitpos: [9:0]; default: 0; * This register records the memory address offset when transmitter of CHANNEL1 is * using the RAM. */ -#define RMT_MEM_RADDR_EX_1 0x000003FFU -#define RMT_MEM_RADDR_EX_1_M (RMT_MEM_RADDR_EX_1_V << RMT_MEM_RADDR_EX_1_S) -#define RMT_MEM_RADDR_EX_1_V 0x000003FFU -#define RMT_MEM_RADDR_EX_1_S 0 -/** RMT_APB_MEM_WADDR_1 : RO; bitpos: [20:11]; default: 0; +#define RMT_MEM_RADDR_EX_CH1 0x000003FFU +#define RMT_MEM_RADDR_EX_CH1_M (RMT_MEM_RADDR_EX_CH1_V << RMT_MEM_RADDR_EX_CH1_S) +#define RMT_MEM_RADDR_EX_CH1_V 0x000003FFU +#define RMT_MEM_RADDR_EX_CH1_S 0 +/** RMT_APB_MEM_WADDR_CH1 : RO; bitpos: [20:11]; default: 0; * This register records the memory address offset when writes RAM over APB bus. */ -#define RMT_APB_MEM_WADDR_1 0x000003FFU -#define RMT_APB_MEM_WADDR_1_M (RMT_APB_MEM_WADDR_1_V << RMT_APB_MEM_WADDR_1_S) -#define RMT_APB_MEM_WADDR_1_V 0x000003FFU -#define RMT_APB_MEM_WADDR_1_S 11 -/** RMT_STATE_1 : RO; bitpos: [24:22]; default: 0; +#define RMT_APB_MEM_WADDR_CH1 0x000003FFU +#define RMT_APB_MEM_WADDR_CH1_M (RMT_APB_MEM_WADDR_CH1_V << RMT_APB_MEM_WADDR_CH1_S) +#define RMT_APB_MEM_WADDR_CH1_V 0x000003FFU +#define RMT_APB_MEM_WADDR_CH1_S 11 +/** RMT_STATE_CH1 : RO; bitpos: [24:22]; default: 0; * This register records the FSM status of CHANNEL1. */ -#define RMT_STATE_1 0x00000007U -#define RMT_STATE_1_M (RMT_STATE_1_V << RMT_STATE_1_S) -#define RMT_STATE_1_V 0x00000007U -#define RMT_STATE_1_S 22 -/** RMT_MEM_EMPTY_1 : RO; bitpos: [25]; default: 0; +#define RMT_STATE_CH1 0x00000007U +#define RMT_STATE_CH1_M (RMT_STATE_CH1_V << RMT_STATE_CH1_S) +#define RMT_STATE_CH1_V 0x00000007U +#define RMT_STATE_CH1_S 22 +/** RMT_MEM_EMPTY_CH1 : RO; bitpos: [25]; default: 0; * This status bit will be set when the data to be set is more than memory size and * the wraparound mode is disabled. */ -#define RMT_MEM_EMPTY_1 (BIT(25)) -#define RMT_MEM_EMPTY_1_M (RMT_MEM_EMPTY_1_V << RMT_MEM_EMPTY_1_S) -#define RMT_MEM_EMPTY_1_V 0x00000001U -#define RMT_MEM_EMPTY_1_S 25 -/** RMT_APB_MEM_WR_ERR_1 : RO; bitpos: [26]; default: 0; +#define RMT_MEM_EMPTY_CH1 (BIT(25)) +#define RMT_MEM_EMPTY_CH1_M (RMT_MEM_EMPTY_CH1_V << RMT_MEM_EMPTY_CH1_S) +#define RMT_MEM_EMPTY_CH1_V 0x00000001U +#define RMT_MEM_EMPTY_CH1_S 25 +/** RMT_APB_MEM_WR_ERR_CH1 : RO; bitpos: [26]; default: 0; * This status bit will be set if the offset address out of memory size when writes * via APB bus. */ -#define RMT_APB_MEM_WR_ERR_1 (BIT(26)) -#define RMT_APB_MEM_WR_ERR_1_M (RMT_APB_MEM_WR_ERR_1_V << RMT_APB_MEM_WR_ERR_1_S) -#define RMT_APB_MEM_WR_ERR_1_V 0x00000001U -#define RMT_APB_MEM_WR_ERR_1_S 26 +#define RMT_APB_MEM_WR_ERR_CH1 (BIT(26)) +#define RMT_APB_MEM_WR_ERR_CH1_M (RMT_APB_MEM_WR_ERR_CH1_V << RMT_APB_MEM_WR_ERR_CH1_S) +#define RMT_APB_MEM_WR_ERR_CH1_V 0x00000001U +#define RMT_APB_MEM_WR_ERR_CH1_S 26 /** RMT_CH2STATUS_REG register * Channel 2 status register */ #define RMT_CH2STATUS_REG (DR_REG_RMT_BASE + 0x58) -/** RMT_MEM_RADDR_EX_2 : RO; bitpos: [9:0]; default: 0; +/** RMT_MEM_RADDR_EX_CH2 : RO; bitpos: [9:0]; default: 0; * This register records the memory address offset when transmitter of CHANNEL2 is * using the RAM. */ -#define RMT_MEM_RADDR_EX_2 0x000003FFU -#define RMT_MEM_RADDR_EX_2_M (RMT_MEM_RADDR_EX_2_V << RMT_MEM_RADDR_EX_2_S) -#define RMT_MEM_RADDR_EX_2_V 0x000003FFU -#define RMT_MEM_RADDR_EX_2_S 0 -/** RMT_APB_MEM_WADDR_2 : RO; bitpos: [20:11]; default: 0; +#define RMT_MEM_RADDR_EX_CH2 0x000003FFU +#define RMT_MEM_RADDR_EX_CH2_M (RMT_MEM_RADDR_EX_CH2_V << RMT_MEM_RADDR_EX_CH2_S) +#define RMT_MEM_RADDR_EX_CH2_V 0x000003FFU +#define RMT_MEM_RADDR_EX_CH2_S 0 +/** RMT_APB_MEM_WADDR_CH2 : RO; bitpos: [20:11]; default: 0; * This register records the memory address offset when writes RAM over APB bus. */ -#define RMT_APB_MEM_WADDR_2 0x000003FFU -#define RMT_APB_MEM_WADDR_2_M (RMT_APB_MEM_WADDR_2_V << RMT_APB_MEM_WADDR_2_S) -#define RMT_APB_MEM_WADDR_2_V 0x000003FFU -#define RMT_APB_MEM_WADDR_2_S 11 -/** RMT_STATE_2 : RO; bitpos: [24:22]; default: 0; +#define RMT_APB_MEM_WADDR_CH2 0x000003FFU +#define RMT_APB_MEM_WADDR_CH2_M (RMT_APB_MEM_WADDR_CH2_V << RMT_APB_MEM_WADDR_CH2_S) +#define RMT_APB_MEM_WADDR_CH2_V 0x000003FFU +#define RMT_APB_MEM_WADDR_CH2_S 11 +/** RMT_STATE_CH2 : RO; bitpos: [24:22]; default: 0; * This register records the FSM status of CHANNEL2. */ -#define RMT_STATE_2 0x00000007U -#define RMT_STATE_2_M (RMT_STATE_2_V << RMT_STATE_2_S) -#define RMT_STATE_2_V 0x00000007U -#define RMT_STATE_2_S 22 -/** RMT_MEM_EMPTY_2 : RO; bitpos: [25]; default: 0; +#define RMT_STATE_CH2 0x00000007U +#define RMT_STATE_CH2_M (RMT_STATE_CH2_V << RMT_STATE_CH2_S) +#define RMT_STATE_CH2_V 0x00000007U +#define RMT_STATE_CH2_S 22 +/** RMT_MEM_EMPTY_CH2 : RO; bitpos: [25]; default: 0; * This status bit will be set when the data to be set is more than memory size and * the wraparound mode is disabled. */ -#define RMT_MEM_EMPTY_2 (BIT(25)) -#define RMT_MEM_EMPTY_2_M (RMT_MEM_EMPTY_2_V << RMT_MEM_EMPTY_2_S) -#define RMT_MEM_EMPTY_2_V 0x00000001U -#define RMT_MEM_EMPTY_2_S 25 -/** RMT_APB_MEM_WR_ERR_2 : RO; bitpos: [26]; default: 0; +#define RMT_MEM_EMPTY_CH2 (BIT(25)) +#define RMT_MEM_EMPTY_CH2_M (RMT_MEM_EMPTY_CH2_V << RMT_MEM_EMPTY_CH2_S) +#define RMT_MEM_EMPTY_CH2_V 0x00000001U +#define RMT_MEM_EMPTY_CH2_S 25 +/** RMT_APB_MEM_WR_ERR_CH2 : RO; bitpos: [26]; default: 0; * This status bit will be set if the offset address out of memory size when writes * via APB bus. */ -#define RMT_APB_MEM_WR_ERR_2 (BIT(26)) -#define RMT_APB_MEM_WR_ERR_2_M (RMT_APB_MEM_WR_ERR_2_V << RMT_APB_MEM_WR_ERR_2_S) -#define RMT_APB_MEM_WR_ERR_2_V 0x00000001U -#define RMT_APB_MEM_WR_ERR_2_S 26 +#define RMT_APB_MEM_WR_ERR_CH2 (BIT(26)) +#define RMT_APB_MEM_WR_ERR_CH2_M (RMT_APB_MEM_WR_ERR_CH2_V << RMT_APB_MEM_WR_ERR_CH2_S) +#define RMT_APB_MEM_WR_ERR_CH2_V 0x00000001U +#define RMT_APB_MEM_WR_ERR_CH2_S 26 /** RMT_CH3STATUS_REG register * Channel 3 status register */ #define RMT_CH3STATUS_REG (DR_REG_RMT_BASE + 0x5c) -/** RMT_MEM_RADDR_EX_3 : RO; bitpos: [9:0]; default: 0; +/** RMT_MEM_RADDR_EX_CH3 : RO; bitpos: [9:0]; default: 0; * This register records the memory address offset when transmitter of CHANNEL3 is * using the RAM. */ -#define RMT_MEM_RADDR_EX_3 0x000003FFU -#define RMT_MEM_RADDR_EX_3_M (RMT_MEM_RADDR_EX_3_V << RMT_MEM_RADDR_EX_3_S) -#define RMT_MEM_RADDR_EX_3_V 0x000003FFU -#define RMT_MEM_RADDR_EX_3_S 0 -/** RMT_APB_MEM_WADDR_3 : RO; bitpos: [20:11]; default: 0; +#define RMT_MEM_RADDR_EX_CH3 0x000003FFU +#define RMT_MEM_RADDR_EX_CH3_M (RMT_MEM_RADDR_EX_CH3_V << RMT_MEM_RADDR_EX_CH3_S) +#define RMT_MEM_RADDR_EX_CH3_V 0x000003FFU +#define RMT_MEM_RADDR_EX_CH3_S 0 +/** RMT_APB_MEM_WADDR_CH3 : RO; bitpos: [20:11]; default: 0; * This register records the memory address offset when writes RAM over APB bus. */ -#define RMT_APB_MEM_WADDR_3 0x000003FFU -#define RMT_APB_MEM_WADDR_3_M (RMT_APB_MEM_WADDR_3_V << RMT_APB_MEM_WADDR_3_S) -#define RMT_APB_MEM_WADDR_3_V 0x000003FFU -#define RMT_APB_MEM_WADDR_3_S 11 -/** RMT_STATE_3 : RO; bitpos: [24:22]; default: 0; +#define RMT_APB_MEM_WADDR_CH3 0x000003FFU +#define RMT_APB_MEM_WADDR_CH3_M (RMT_APB_MEM_WADDR_CH3_V << RMT_APB_MEM_WADDR_CH3_S) +#define RMT_APB_MEM_WADDR_CH3_V 0x000003FFU +#define RMT_APB_MEM_WADDR_CH3_S 11 +/** RMT_STATE_CH3 : RO; bitpos: [24:22]; default: 0; * This register records the FSM status of CHANNEL3. */ -#define RMT_STATE_3 0x00000007U -#define RMT_STATE_3_M (RMT_STATE_3_V << RMT_STATE_3_S) -#define RMT_STATE_3_V 0x00000007U -#define RMT_STATE_3_S 22 -/** RMT_MEM_EMPTY_3 : RO; bitpos: [25]; default: 0; +#define RMT_STATE_CH3 0x00000007U +#define RMT_STATE_CH3_M (RMT_STATE_CH3_V << RMT_STATE_CH3_S) +#define RMT_STATE_CH3_V 0x00000007U +#define RMT_STATE_CH3_S 22 +/** RMT_MEM_EMPTY_CH3 : RO; bitpos: [25]; default: 0; * This status bit will be set when the data to be set is more than memory size and * the wraparound mode is disabled. */ -#define RMT_MEM_EMPTY_3 (BIT(25)) -#define RMT_MEM_EMPTY_3_M (RMT_MEM_EMPTY_3_V << RMT_MEM_EMPTY_3_S) -#define RMT_MEM_EMPTY_3_V 0x00000001U -#define RMT_MEM_EMPTY_3_S 25 -/** RMT_APB_MEM_WR_ERR_3 : RO; bitpos: [26]; default: 0; +#define RMT_MEM_EMPTY_CH3 (BIT(25)) +#define RMT_MEM_EMPTY_CH3_M (RMT_MEM_EMPTY_CH3_V << RMT_MEM_EMPTY_CH3_S) +#define RMT_MEM_EMPTY_CH3_V 0x00000001U +#define RMT_MEM_EMPTY_CH3_S 25 +/** RMT_APB_MEM_WR_ERR_CH3 : RO; bitpos: [26]; default: 0; * This status bit will be set if the offset address out of memory size when writes * via APB bus. */ -#define RMT_APB_MEM_WR_ERR_3 (BIT(26)) -#define RMT_APB_MEM_WR_ERR_3_M (RMT_APB_MEM_WR_ERR_3_V << RMT_APB_MEM_WR_ERR_3_S) -#define RMT_APB_MEM_WR_ERR_3_V 0x00000001U -#define RMT_APB_MEM_WR_ERR_3_S 26 +#define RMT_APB_MEM_WR_ERR_CH3 (BIT(26)) +#define RMT_APB_MEM_WR_ERR_CH3_M (RMT_APB_MEM_WR_ERR_CH3_V << RMT_APB_MEM_WR_ERR_CH3_S) +#define RMT_APB_MEM_WR_ERR_CH3_V 0x00000001U +#define RMT_APB_MEM_WR_ERR_CH3_S 26 /** RMT_CH4STATUS_REG register * Channel 4 status register */ #define RMT_CH4STATUS_REG (DR_REG_RMT_BASE + 0x60) -/** RMT_MEM_WADDR_EX_4 : RO; bitpos: [9:0]; default: 192; +/** RMT_MEM_WADDR_EX_CH4 : RO; bitpos: [9:0]; default: 192; * This register records the memory address offset when receiver of CHANNEL4 is using * the RAM. */ -#define RMT_MEM_WADDR_EX_4 0x000003FFU -#define RMT_MEM_WADDR_EX_4_M (RMT_MEM_WADDR_EX_4_V << RMT_MEM_WADDR_EX_4_S) -#define RMT_MEM_WADDR_EX_4_V 0x000003FFU -#define RMT_MEM_WADDR_EX_4_S 0 -/** RMT_APB_MEM_RADDR_4 : RO; bitpos: [20:11]; default: 192; +#define RMT_MEM_WADDR_EX_CH4 0x000003FFU +#define RMT_MEM_WADDR_EX_CH4_M (RMT_MEM_WADDR_EX_CH4_V << RMT_MEM_WADDR_EX_CH4_S) +#define RMT_MEM_WADDR_EX_CH4_V 0x000003FFU +#define RMT_MEM_WADDR_EX_CH4_S 0 +/** RMT_APB_MEM_RADDR_CH4 : RO; bitpos: [20:11]; default: 192; * This register records the memory address offset when reads RAM over APB bus. */ -#define RMT_APB_MEM_RADDR_4 0x000003FFU -#define RMT_APB_MEM_RADDR_4_M (RMT_APB_MEM_RADDR_4_V << RMT_APB_MEM_RADDR_4_S) -#define RMT_APB_MEM_RADDR_4_V 0x000003FFU -#define RMT_APB_MEM_RADDR_4_S 11 -/** RMT_STATE_4 : RO; bitpos: [24:22]; default: 0; +#define RMT_APB_MEM_RADDR_CH4 0x000003FFU +#define RMT_APB_MEM_RADDR_CH4_M (RMT_APB_MEM_RADDR_CH4_V << RMT_APB_MEM_RADDR_CH4_S) +#define RMT_APB_MEM_RADDR_CH4_V 0x000003FFU +#define RMT_APB_MEM_RADDR_CH4_S 11 +/** RMT_STATE_CH4 : RO; bitpos: [24:22]; default: 0; * This register records the FSM status of CHANNEL4. */ -#define RMT_STATE_4 0x00000007U -#define RMT_STATE_4_M (RMT_STATE_4_V << RMT_STATE_4_S) -#define RMT_STATE_4_V 0x00000007U -#define RMT_STATE_4_S 22 -/** RMT_MEM_OWNER_ERR_4 : RO; bitpos: [25]; default: 0; +#define RMT_STATE_CH4 0x00000007U +#define RMT_STATE_CH4_M (RMT_STATE_CH4_V << RMT_STATE_CH4_S) +#define RMT_STATE_CH4_V 0x00000007U +#define RMT_STATE_CH4_S 22 +/** RMT_MEM_OWNER_ERR_CH4 : RO; bitpos: [25]; default: 0; * This status bit will be set when the ownership of memory block is wrong. */ -#define RMT_MEM_OWNER_ERR_4 (BIT(25)) -#define RMT_MEM_OWNER_ERR_4_M (RMT_MEM_OWNER_ERR_4_V << RMT_MEM_OWNER_ERR_4_S) -#define RMT_MEM_OWNER_ERR_4_V 0x00000001U -#define RMT_MEM_OWNER_ERR_4_S 25 -/** RMT_MEM_FULL_4 : RO; bitpos: [26]; default: 0; +#define RMT_MEM_OWNER_ERR_CH4 (BIT(25)) +#define RMT_MEM_OWNER_ERR_CH4_M (RMT_MEM_OWNER_ERR_CH4_V << RMT_MEM_OWNER_ERR_CH4_S) +#define RMT_MEM_OWNER_ERR_CH4_V 0x00000001U +#define RMT_MEM_OWNER_ERR_CH4_S 25 +/** RMT_MEM_FULL_CH4 : RO; bitpos: [26]; default: 0; * This status bit will be set if the receiver receives more data than the memory size. */ -#define RMT_MEM_FULL_4 (BIT(26)) -#define RMT_MEM_FULL_4_M (RMT_MEM_FULL_4_V << RMT_MEM_FULL_4_S) -#define RMT_MEM_FULL_4_V 0x00000001U -#define RMT_MEM_FULL_4_S 26 -/** RMT_APB_MEM_RD_ERR_4 : RO; bitpos: [27]; default: 0; +#define RMT_MEM_FULL_CH4 (BIT(26)) +#define RMT_MEM_FULL_CH4_M (RMT_MEM_FULL_CH4_V << RMT_MEM_FULL_CH4_S) +#define RMT_MEM_FULL_CH4_V 0x00000001U +#define RMT_MEM_FULL_CH4_S 26 +/** RMT_APB_MEM_RD_ERR_CH4 : RO; bitpos: [27]; default: 0; * This status bit will be set if the offset address out of memory size when reads via * APB bus. */ -#define RMT_APB_MEM_RD_ERR_4 (BIT(27)) -#define RMT_APB_MEM_RD_ERR_4_M (RMT_APB_MEM_RD_ERR_4_V << RMT_APB_MEM_RD_ERR_4_S) -#define RMT_APB_MEM_RD_ERR_4_V 0x00000001U -#define RMT_APB_MEM_RD_ERR_4_S 27 +#define RMT_APB_MEM_RD_ERR_CH4 (BIT(27)) +#define RMT_APB_MEM_RD_ERR_CH4_M (RMT_APB_MEM_RD_ERR_CH4_V << RMT_APB_MEM_RD_ERR_CH4_S) +#define RMT_APB_MEM_RD_ERR_CH4_V 0x00000001U +#define RMT_APB_MEM_RD_ERR_CH4_S 27 /** RMT_CH5STATUS_REG register * Channel 5 status register */ #define RMT_CH5STATUS_REG (DR_REG_RMT_BASE + 0x64) -/** RMT_MEM_WADDR_EX_5 : RO; bitpos: [9:0]; default: 192; +/** RMT_MEM_WADDR_EX_CH5 : RO; bitpos: [9:0]; default: 192; * This register records the memory address offset when receiver of CHANNEL5 is using * the RAM. */ -#define RMT_MEM_WADDR_EX_5 0x000003FFU -#define RMT_MEM_WADDR_EX_5_M (RMT_MEM_WADDR_EX_5_V << RMT_MEM_WADDR_EX_5_S) -#define RMT_MEM_WADDR_EX_5_V 0x000003FFU -#define RMT_MEM_WADDR_EX_5_S 0 -/** RMT_APB_MEM_RADDR_5 : RO; bitpos: [20:11]; default: 192; +#define RMT_MEM_WADDR_EX_CH5 0x000003FFU +#define RMT_MEM_WADDR_EX_CH5_M (RMT_MEM_WADDR_EX_CH5_V << RMT_MEM_WADDR_EX_CH5_S) +#define RMT_MEM_WADDR_EX_CH5_V 0x000003FFU +#define RMT_MEM_WADDR_EX_CH5_S 0 +/** RMT_APB_MEM_RADDR_CH5 : RO; bitpos: [20:11]; default: 192; * This register records the memory address offset when reads RAM over APB bus. */ -#define RMT_APB_MEM_RADDR_5 0x000003FFU -#define RMT_APB_MEM_RADDR_5_M (RMT_APB_MEM_RADDR_5_V << RMT_APB_MEM_RADDR_5_S) -#define RMT_APB_MEM_RADDR_5_V 0x000003FFU -#define RMT_APB_MEM_RADDR_5_S 11 -/** RMT_STATE_5 : RO; bitpos: [24:22]; default: 0; +#define RMT_APB_MEM_RADDR_CH5 0x000003FFU +#define RMT_APB_MEM_RADDR_CH5_M (RMT_APB_MEM_RADDR_CH5_V << RMT_APB_MEM_RADDR_CH5_S) +#define RMT_APB_MEM_RADDR_CH5_V 0x000003FFU +#define RMT_APB_MEM_RADDR_CH5_S 11 +/** RMT_STATE_CH5 : RO; bitpos: [24:22]; default: 0; * This register records the FSM status of CHANNEL5. */ -#define RMT_STATE_5 0x00000007U -#define RMT_STATE_5_M (RMT_STATE_5_V << RMT_STATE_5_S) -#define RMT_STATE_5_V 0x00000007U -#define RMT_STATE_5_S 22 -/** RMT_MEM_OWNER_ERR_5 : RO; bitpos: [25]; default: 0; +#define RMT_STATE_CH5 0x00000007U +#define RMT_STATE_CH5_M (RMT_STATE_CH5_V << RMT_STATE_CH5_S) +#define RMT_STATE_CH5_V 0x00000007U +#define RMT_STATE_CH5_S 22 +/** RMT_MEM_OWNER_ERR_CH5 : RO; bitpos: [25]; default: 0; * This status bit will be set when the ownership of memory block is wrong. */ -#define RMT_MEM_OWNER_ERR_5 (BIT(25)) -#define RMT_MEM_OWNER_ERR_5_M (RMT_MEM_OWNER_ERR_5_V << RMT_MEM_OWNER_ERR_5_S) -#define RMT_MEM_OWNER_ERR_5_V 0x00000001U -#define RMT_MEM_OWNER_ERR_5_S 25 -/** RMT_MEM_FULL_5 : RO; bitpos: [26]; default: 0; +#define RMT_MEM_OWNER_ERR_CH5 (BIT(25)) +#define RMT_MEM_OWNER_ERR_CH5_M (RMT_MEM_OWNER_ERR_CH5_V << RMT_MEM_OWNER_ERR_CH5_S) +#define RMT_MEM_OWNER_ERR_CH5_V 0x00000001U +#define RMT_MEM_OWNER_ERR_CH5_S 25 +/** RMT_MEM_FULL_CH5 : RO; bitpos: [26]; default: 0; * This status bit will be set if the receiver receives more data than the memory size. */ -#define RMT_MEM_FULL_5 (BIT(26)) -#define RMT_MEM_FULL_5_M (RMT_MEM_FULL_5_V << RMT_MEM_FULL_5_S) -#define RMT_MEM_FULL_5_V 0x00000001U -#define RMT_MEM_FULL_5_S 26 -/** RMT_APB_MEM_RD_ERR_5 : RO; bitpos: [27]; default: 0; +#define RMT_MEM_FULL_CH5 (BIT(26)) +#define RMT_MEM_FULL_CH5_M (RMT_MEM_FULL_CH5_V << RMT_MEM_FULL_CH5_S) +#define RMT_MEM_FULL_CH5_V 0x00000001U +#define RMT_MEM_FULL_CH5_S 26 +/** RMT_APB_MEM_RD_ERR_CH5 : RO; bitpos: [27]; default: 0; * This status bit will be set if the offset address out of memory size when reads via * APB bus. */ -#define RMT_APB_MEM_RD_ERR_5 (BIT(27)) -#define RMT_APB_MEM_RD_ERR_5_M (RMT_APB_MEM_RD_ERR_5_V << RMT_APB_MEM_RD_ERR_5_S) -#define RMT_APB_MEM_RD_ERR_5_V 0x00000001U -#define RMT_APB_MEM_RD_ERR_5_S 27 +#define RMT_APB_MEM_RD_ERR_CH5 (BIT(27)) +#define RMT_APB_MEM_RD_ERR_CH5_M (RMT_APB_MEM_RD_ERR_CH5_V << RMT_APB_MEM_RD_ERR_CH5_S) +#define RMT_APB_MEM_RD_ERR_CH5_V 0x00000001U +#define RMT_APB_MEM_RD_ERR_CH5_S 27 /** RMT_CH6STATUS_REG register * Channel 6 status register */ #define RMT_CH6STATUS_REG (DR_REG_RMT_BASE + 0x68) -/** RMT_MEM_WADDR_EX_6 : RO; bitpos: [9:0]; default: 192; +/** RMT_MEM_WADDR_EX_CH6 : RO; bitpos: [9:0]; default: 192; * This register records the memory address offset when receiver of CHANNEL6 is using * the RAM. */ -#define RMT_MEM_WADDR_EX_6 0x000003FFU -#define RMT_MEM_WADDR_EX_6_M (RMT_MEM_WADDR_EX_6_V << RMT_MEM_WADDR_EX_6_S) -#define RMT_MEM_WADDR_EX_6_V 0x000003FFU -#define RMT_MEM_WADDR_EX_6_S 0 -/** RMT_APB_MEM_RADDR_6 : RO; bitpos: [20:11]; default: 192; +#define RMT_MEM_WADDR_EX_CH6 0x000003FFU +#define RMT_MEM_WADDR_EX_CH6_M (RMT_MEM_WADDR_EX_CH6_V << RMT_MEM_WADDR_EX_CH6_S) +#define RMT_MEM_WADDR_EX_CH6_V 0x000003FFU +#define RMT_MEM_WADDR_EX_CH6_S 0 +/** RMT_APB_MEM_RADDR_CH6 : RO; bitpos: [20:11]; default: 192; * This register records the memory address offset when reads RAM over APB bus. */ -#define RMT_APB_MEM_RADDR_6 0x000003FFU -#define RMT_APB_MEM_RADDR_6_M (RMT_APB_MEM_RADDR_6_V << RMT_APB_MEM_RADDR_6_S) -#define RMT_APB_MEM_RADDR_6_V 0x000003FFU -#define RMT_APB_MEM_RADDR_6_S 11 -/** RMT_STATE_6 : RO; bitpos: [24:22]; default: 0; +#define RMT_APB_MEM_RADDR_CH6 0x000003FFU +#define RMT_APB_MEM_RADDR_CH6_M (RMT_APB_MEM_RADDR_CH6_V << RMT_APB_MEM_RADDR_CH6_S) +#define RMT_APB_MEM_RADDR_CH6_V 0x000003FFU +#define RMT_APB_MEM_RADDR_CH6_S 11 +/** RMT_STATE_CH6 : RO; bitpos: [24:22]; default: 0; * This register records the FSM status of CHANNEL6. */ -#define RMT_STATE_6 0x00000007U -#define RMT_STATE_6_M (RMT_STATE_6_V << RMT_STATE_6_S) -#define RMT_STATE_6_V 0x00000007U -#define RMT_STATE_6_S 22 -/** RMT_MEM_OWNER_ERR_6 : RO; bitpos: [25]; default: 0; +#define RMT_STATE_CH6 0x00000007U +#define RMT_STATE_CH6_M (RMT_STATE_CH6_V << RMT_STATE_CH6_S) +#define RMT_STATE_CH6_V 0x00000007U +#define RMT_STATE_CH6_S 22 +/** RMT_MEM_OWNER_ERR_CH6 : RO; bitpos: [25]; default: 0; * This status bit will be set when the ownership of memory block is wrong. */ -#define RMT_MEM_OWNER_ERR_6 (BIT(25)) -#define RMT_MEM_OWNER_ERR_6_M (RMT_MEM_OWNER_ERR_6_V << RMT_MEM_OWNER_ERR_6_S) -#define RMT_MEM_OWNER_ERR_6_V 0x00000001U -#define RMT_MEM_OWNER_ERR_6_S 25 -/** RMT_MEM_FULL_6 : RO; bitpos: [26]; default: 0; +#define RMT_MEM_OWNER_ERR_CH6 (BIT(25)) +#define RMT_MEM_OWNER_ERR_CH6_M (RMT_MEM_OWNER_ERR_CH6_V << RMT_MEM_OWNER_ERR_CH6_S) +#define RMT_MEM_OWNER_ERR_CH6_V 0x00000001U +#define RMT_MEM_OWNER_ERR_CH6_S 25 +/** RMT_MEM_FULL_CH6 : RO; bitpos: [26]; default: 0; * This status bit will be set if the receiver receives more data than the memory size. */ -#define RMT_MEM_FULL_6 (BIT(26)) -#define RMT_MEM_FULL_6_M (RMT_MEM_FULL_6_V << RMT_MEM_FULL_6_S) -#define RMT_MEM_FULL_6_V 0x00000001U -#define RMT_MEM_FULL_6_S 26 -/** RMT_APB_MEM_RD_ERR_6 : RO; bitpos: [27]; default: 0; +#define RMT_MEM_FULL_CH6 (BIT(26)) +#define RMT_MEM_FULL_CH6_M (RMT_MEM_FULL_CH6_V << RMT_MEM_FULL_CH6_S) +#define RMT_MEM_FULL_CH6_V 0x00000001U +#define RMT_MEM_FULL_CH6_S 26 +/** RMT_APB_MEM_RD_ERR_CH6 : RO; bitpos: [27]; default: 0; * This status bit will be set if the offset address out of memory size when reads via * APB bus. */ -#define RMT_APB_MEM_RD_ERR_6 (BIT(27)) -#define RMT_APB_MEM_RD_ERR_6_M (RMT_APB_MEM_RD_ERR_6_V << RMT_APB_MEM_RD_ERR_6_S) -#define RMT_APB_MEM_RD_ERR_6_V 0x00000001U -#define RMT_APB_MEM_RD_ERR_6_S 27 +#define RMT_APB_MEM_RD_ERR_CH6 (BIT(27)) +#define RMT_APB_MEM_RD_ERR_CH6_M (RMT_APB_MEM_RD_ERR_CH6_V << RMT_APB_MEM_RD_ERR_CH6_S) +#define RMT_APB_MEM_RD_ERR_CH6_V 0x00000001U +#define RMT_APB_MEM_RD_ERR_CH6_S 27 /** RMT_CH7STATUS_REG register * Channel 7 status register */ #define RMT_CH7STATUS_REG (DR_REG_RMT_BASE + 0x6c) -/** RMT_MEM_WADDR_EX_7 : RO; bitpos: [9:0]; default: 192; +/** RMT_MEM_WADDR_EX_CH7 : RO; bitpos: [9:0]; default: 192; * This register records the memory address offset when receiver of CHANNEL7 is using * the RAM. */ -#define RMT_MEM_WADDR_EX_7 0x000003FFU -#define RMT_MEM_WADDR_EX_7_M (RMT_MEM_WADDR_EX_7_V << RMT_MEM_WADDR_EX_7_S) -#define RMT_MEM_WADDR_EX_7_V 0x000003FFU -#define RMT_MEM_WADDR_EX_7_S 0 -/** RMT_APB_MEM_RADDR_7 : RO; bitpos: [20:11]; default: 192; +#define RMT_MEM_WADDR_EX_CH7 0x000003FFU +#define RMT_MEM_WADDR_EX_CH7_M (RMT_MEM_WADDR_EX_CH7_V << RMT_MEM_WADDR_EX_CH7_S) +#define RMT_MEM_WADDR_EX_CH7_V 0x000003FFU +#define RMT_MEM_WADDR_EX_CH7_S 0 +/** RMT_APB_MEM_RADDR_CH7 : RO; bitpos: [20:11]; default: 192; * This register records the memory address offset when reads RAM over APB bus. */ -#define RMT_APB_MEM_RADDR_7 0x000003FFU -#define RMT_APB_MEM_RADDR_7_M (RMT_APB_MEM_RADDR_7_V << RMT_APB_MEM_RADDR_7_S) -#define RMT_APB_MEM_RADDR_7_V 0x000003FFU -#define RMT_APB_MEM_RADDR_7_S 11 -/** RMT_STATE_7 : RO; bitpos: [24:22]; default: 0; +#define RMT_APB_MEM_RADDR_CH7 0x000003FFU +#define RMT_APB_MEM_RADDR_CH7_M (RMT_APB_MEM_RADDR_CH7_V << RMT_APB_MEM_RADDR_CH7_S) +#define RMT_APB_MEM_RADDR_CH7_V 0x000003FFU +#define RMT_APB_MEM_RADDR_CH7_S 11 +/** RMT_STATE_CH7 : RO; bitpos: [24:22]; default: 0; * This register records the FSM status of CHANNEL7. */ -#define RMT_STATE_7 0x00000007U -#define RMT_STATE_7_M (RMT_STATE_7_V << RMT_STATE_7_S) -#define RMT_STATE_7_V 0x00000007U -#define RMT_STATE_7_S 22 -/** RMT_MEM_OWNER_ERR_7 : RO; bitpos: [25]; default: 0; +#define RMT_STATE_CH7 0x00000007U +#define RMT_STATE_CH7_M (RMT_STATE_CH7_V << RMT_STATE_CH7_S) +#define RMT_STATE_CH7_V 0x00000007U +#define RMT_STATE_CH7_S 22 +/** RMT_MEM_OWNER_ERR_CH7 : RO; bitpos: [25]; default: 0; * This status bit will be set when the ownership of memory block is wrong. */ -#define RMT_MEM_OWNER_ERR_7 (BIT(25)) -#define RMT_MEM_OWNER_ERR_7_M (RMT_MEM_OWNER_ERR_7_V << RMT_MEM_OWNER_ERR_7_S) -#define RMT_MEM_OWNER_ERR_7_V 0x00000001U -#define RMT_MEM_OWNER_ERR_7_S 25 -/** RMT_MEM_FULL_7 : RO; bitpos: [26]; default: 0; +#define RMT_MEM_OWNER_ERR_CH7 (BIT(25)) +#define RMT_MEM_OWNER_ERR_CH7_M (RMT_MEM_OWNER_ERR_CH7_V << RMT_MEM_OWNER_ERR_CH7_S) +#define RMT_MEM_OWNER_ERR_CH7_V 0x00000001U +#define RMT_MEM_OWNER_ERR_CH7_S 25 +/** RMT_MEM_FULL_CH7 : RO; bitpos: [26]; default: 0; * This status bit will be set if the receiver receives more data than the memory size. */ -#define RMT_MEM_FULL_7 (BIT(26)) -#define RMT_MEM_FULL_7_M (RMT_MEM_FULL_7_V << RMT_MEM_FULL_7_S) -#define RMT_MEM_FULL_7_V 0x00000001U -#define RMT_MEM_FULL_7_S 26 -/** RMT_APB_MEM_RD_ERR_7 : RO; bitpos: [27]; default: 0; +#define RMT_MEM_FULL_CH7 (BIT(26)) +#define RMT_MEM_FULL_CH7_M (RMT_MEM_FULL_CH7_V << RMT_MEM_FULL_CH7_S) +#define RMT_MEM_FULL_CH7_V 0x00000001U +#define RMT_MEM_FULL_CH7_S 26 +/** RMT_APB_MEM_RD_ERR_CH7 : RO; bitpos: [27]; default: 0; * This status bit will be set if the offset address out of memory size when reads via * APB bus. */ -#define RMT_APB_MEM_RD_ERR_7 (BIT(27)) -#define RMT_APB_MEM_RD_ERR_7_M (RMT_APB_MEM_RD_ERR_7_V << RMT_APB_MEM_RD_ERR_7_S) -#define RMT_APB_MEM_RD_ERR_7_V 0x00000001U -#define RMT_APB_MEM_RD_ERR_7_S 27 +#define RMT_APB_MEM_RD_ERR_CH7 (BIT(27)) +#define RMT_APB_MEM_RD_ERR_CH7_M (RMT_APB_MEM_RD_ERR_CH7_V << RMT_APB_MEM_RD_ERR_CH7_S) +#define RMT_APB_MEM_RD_ERR_CH7_V 0x00000001U +#define RMT_APB_MEM_RD_ERR_CH7_S 27 /** RMT_INT_RAW_REG register * Raw interrupt status @@ -2656,49 +2656,49 @@ extern "C" { * Channel 4 Rx event configuration register */ #define RMT_CH4_RX_LIM_REG (DR_REG_RMT_BASE + 0xb0) -/** RMT_CH4_RX_LIM_REG : R/W; bitpos: [8:0]; default: 128; +/** RMT_RX_LIM_CH4 : R/W; bitpos: [8:0]; default: 128; * This register is used to configure the maximum entries that CHANNEL4 can receive. */ -#define RMT_CH4_RX_LIM_REG 0x000001FFU -#define RMT_CH4_RX_LIM_REG_M (RMT_CH4_RX_LIM_REG_V << RMT_CH4_RX_LIM_REG_S) -#define RMT_CH4_RX_LIM_REG_V 0x000001FFU -#define RMT_CH4_RX_LIM_REG_S 0 +#define RMT_RX_LIM_CH4 0x000001FFU +#define RMT_RX_LIM_CH4_M (RMT_RX_LIM_CH4_V << RMT_RX_LIM_CH4_S) +#define RMT_RX_LIM_CH4_V 0x000001FFU +#define RMT_RX_LIM_CH4_S 0 /** RMT_CH5_RX_LIM_REG register * Channel 5 Rx event configuration register */ #define RMT_CH5_RX_LIM_REG (DR_REG_RMT_BASE + 0xb4) -/** RMT_CH5_RX_LIM_REG : R/W; bitpos: [8:0]; default: 128; +/** RMT_RX_LIM_CH5 : R/W; bitpos: [8:0]; default: 128; * This register is used to configure the maximum entries that CHANNEL5 can receive. */ -#define RMT_CH5_RX_LIM_REG 0x000001FFU -#define RMT_CH5_RX_LIM_REG_M (RMT_CH5_RX_LIM_REG_V << RMT_CH5_RX_LIM_REG_S) -#define RMT_CH5_RX_LIM_REG_V 0x000001FFU -#define RMT_CH5_RX_LIM_REG_S 0 +#define RMT_RX_LIM_CH5 0x000001FFU +#define RMT_RX_LIM_CH5_M (RMT_RX_LIM_CH5_V << RMT_RX_LIM_CH5_S) +#define RMT_RX_LIM_CH5_V 0x000001FFU +#define RMT_RX_LIM_CH5_S 0 /** RMT_CH6_RX_LIM_REG register * Channel 6 Rx event configuration register */ #define RMT_CH6_RX_LIM_REG (DR_REG_RMT_BASE + 0xb8) -/** RMT_CH6_RX_LIM_REG : R/W; bitpos: [8:0]; default: 128; +/** RMT_RX_LIM_CH6 : R/W; bitpos: [8:0]; default: 128; * This register is used to configure the maximum entries that CHANNEL6 can receive. */ -#define RMT_CH6_RX_LIM_REG 0x000001FFU -#define RMT_CH6_RX_LIM_REG_M (RMT_CH6_RX_LIM_REG_V << RMT_CH6_RX_LIM_REG_S) -#define RMT_CH6_RX_LIM_REG_V 0x000001FFU -#define RMT_CH6_RX_LIM_REG_S 0 +#define RMT_RX_LIM_CH6 0x000001FFU +#define RMT_RX_LIM_CH6_M (RMT_RX_LIM_CH6_V << RMT_RX_LIM_CH6_S) +#define RMT_RX_LIM_CH6_V 0x000001FFU +#define RMT_RX_LIM_CH6_S 0 /** RMT_CH7_RX_LIM_REG register * Channel 7 Rx event configuration register */ #define RMT_CH7_RX_LIM_REG (DR_REG_RMT_BASE + 0xbc) -/** RMT_CH7_RX_LIM_REG : R/W; bitpos: [8:0]; default: 128; +/** RMT_RX_LIM_CH7 : R/W; bitpos: [8:0]; default: 128; * This register is used to configure the maximum entries that CHANNEL7 can receive. */ -#define RMT_CH7_RX_LIM_REG 0x000001FFU -#define RMT_CH7_RX_LIM_REG_M (RMT_CH7_RX_LIM_REG_V << RMT_CH7_RX_LIM_REG_S) -#define RMT_CH7_RX_LIM_REG_V 0x000001FFU -#define RMT_CH7_RX_LIM_REG_S 0 +#define RMT_RX_LIM_CH7 0x000001FFU +#define RMT_RX_LIM_CH7_M (RMT_RX_LIM_CH7_V << RMT_RX_LIM_CH7_S) +#define RMT_RX_LIM_CH7_V 0x000001FFU +#define RMT_RX_LIM_CH7_S 0 /** RMT_SYS_CONF_REG register * RMT apb configuration register diff --git a/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/rtc.h b/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/rtc.h index aa09874f2c7..479e2c2073b 100644 --- a/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/rtc.h +++ b/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/rtc.h @@ -59,9 +59,8 @@ extern "C" { /* Approximate mapping of voltages to RTC_CNTL_DBIAS_WAK, RTC_CNTL_DBIAS_SLP, * RTC_CNTL_DIG_DBIAS_WAK, RTC_CNTL_DIG_DBIAS_SLP values. - * Valid if RTC_CNTL_DBG_ATTEN is 0. */ -#define RTC_CNTL_DBIAS_SLP 0 ///< sleep dig_dbias & rtc_dbias +#define RTC_CNTL_DBIAS_SLP 5 ///< sleep dig_dbias & rtc_dbias #define RTC_CNTL_DBIAS_0V90 13 ///< digital voltage #define RTC_CNTL_DBIAS_0V95 16 #define RTC_CNTL_DBIAS_1V00 18 @@ -116,16 +115,21 @@ set sleep_init default param */ #define RTC_CNTL_DBG_ATTEN_LIGHTSLEEP_DEFAULT 5 #define RTC_CNTL_DBG_ATTEN_LIGHTSLEEP_NODROP 0 -#define RTC_CNTL_DBG_ATTEN_DEEPSLEEP_DEFAULT 15 +#define RTC_CNTL_DBG_ATTEN_DEEPSLEEP_NODROP 0 +#define RTC_CNTL_DBG_ATTEN_DEEPSLEEP_DEFAULT 14 +#define RTC_CNTL_DBG_ATTEN_DEEPSLEEP_ULTRA_LOW 15 #define RTC_CNTL_DBG_ATTEN_MONITOR_DEFAULT 0 -#define RTC_CNTL_BIASSLP_MONITOR_DEFAULT 0 +#define RTC_CNTL_BIASSLP_MONITOR_ON 0 +#define RTC_CNTL_BIASSLP_MONITOR_DEFAULT 1 #define RTC_CNTL_BIASSLP_SLEEP_ON 0 #define RTC_CNTL_BIASSLP_SLEEP_DEFAULT 1 +#define RTC_CNTL_PD_CUR_MONITOR_ON 0 #define RTC_CNTL_PD_CUR_MONITOR_DEFAULT 1 #define RTC_CNTL_PD_CUR_SLEEP_ON 0 #define RTC_CNTL_PD_CUR_SLEEP_DEFAULT 1 #define RTC_CNTL_DG_VDD_DRV_B_SLP_DEFAULT 0xf + /** * @brief Possible main XTAL frequency values. * @@ -590,6 +594,11 @@ void rtc_dig_clk8m_enable(void); */ void rtc_dig_clk8m_disable(void); +/** + * @brief Get whether the rtc digital 8M clock is enabled + */ +bool rtc_dig_8m_enabled(void); + /** * @brief Calculate the real clock value after the clock calibration * @@ -646,52 +655,21 @@ typedef struct { uint32_t dig_peri_pd_en : 1; //!< power down digital peripherals uint32_t deep_slp : 1; //!< power down digital domain uint32_t wdt_flashboot_mod_en : 1; //!< enable WDT flashboot mode - uint32_t dig_dbias_wak : 5; //!< set bias for digital domain, in active mode uint32_t dig_dbias_slp : 5; //!< set bias for digital domain, in sleep mode - uint32_t rtc_dbias_wak : 5; //!< set bias for RTC domain, in active mode uint32_t rtc_dbias_slp : 5; //!< set bias for RTC domain, in sleep mode + uint32_t dbg_atten_monitor : 4; //!< voltage parameter, in monitor mode + uint32_t bias_sleep_monitor : 1; //!< circuit control parameter, in monitor mode + uint32_t dbg_atten_slp : 4; //!< voltage parameter, in sleep mode + uint32_t bias_sleep_slp : 1; //!< circuit control parameter, in sleep mode + uint32_t pd_cur_monitor : 1; //!< circuit control parameter, in monitor mode + uint32_t pd_cur_slp : 1; //!< circuit control parameter, in sleep mode uint32_t vddsdio_pd_en : 1; //!< power down VDDSDIO regulator uint32_t xtal_fpu : 1; //!< keep main XTAL powered up in sleep + uint32_t rtc_regulator_fpu : 1; //!< keep rtc regulator powered up in sleep uint32_t deep_slp_reject : 1; uint32_t light_slp_reject : 1; } rtc_sleep_config_t; -/** - * Default initializer for rtc_sleep_config_t - * - * This initializer sets all fields to "reasonable" values (e.g. suggested for - * production use) based on a combination of RTC_SLEEP_PD_x flags. - * - * @param RTC_SLEEP_PD_x flags combined using bitwise OR - */ -#define is_dslp(pd_flags) ((pd_flags) & RTC_SLEEP_PD_DIG) -#define RTC_SLEEP_CONFIG_DEFAULT(sleep_flags) { \ - .lslp_mem_inf_fpu = 0, \ - .rtc_mem_inf_follow_cpu = ((sleep_flags) & RTC_SLEEP_PD_RTC_MEM_FOLLOW_CPU) ? 1 : 0, \ - .rtc_fastmem_pd_en = ((sleep_flags) & RTC_SLEEP_PD_RTC_FAST_MEM) ? 1 : 0, \ - .rtc_slowmem_pd_en = ((sleep_flags) & RTC_SLEEP_PD_RTC_SLOW_MEM) ? 1 : 0, \ - .rtc_peri_pd_en = ((sleep_flags) & RTC_SLEEP_PD_RTC_PERIPH) ? 1 : 0, \ - .wifi_pd_en = ((sleep_flags) & RTC_SLEEP_PD_WIFI) ? 1 : 0, \ - .bt_pd_en = ((sleep_flags) & RTC_SLEEP_PD_BT) ? 1 : 0, \ - .cpu_pd_en = ((sleep_flags) & RTC_SLEEP_PD_CPU) ? 1 : 0, \ - .int_8m_pd_en = is_dslp(sleep_flags) ? 1 : ((sleep_flags) & RTC_SLEEP_PD_INT_8M) ? 1 : 0, \ - .dig_peri_pd_en = ((sleep_flags) & RTC_SLEEP_PD_DIG_PERIPH) ? 1 : 0, \ - .deep_slp = ((sleep_flags) & RTC_SLEEP_PD_DIG) ? 1 : 0, \ - .wdt_flashboot_mod_en = 0, \ - .dig_dbias_wak = RTC_CNTL_DBIAS_1V10, \ - .dig_dbias_slp = is_dslp(sleep_flags) ? RTC_CNTL_DBIAS_SLP \ - : !((sleep_flags) & RTC_SLEEP_PD_INT_8M) ? RTC_CNTL_DBIAS_1V10 \ - : RTC_CNTL_DBIAS_SLP, \ - .rtc_dbias_wak = RTC_CNTL_DBIAS_1V10, \ - .rtc_dbias_slp = is_dslp(sleep_flags) ? RTC_CNTL_DBIAS_SLP \ - : !((sleep_flags) & RTC_SLEEP_PD_INT_8M) ? RTC_CNTL_DBIAS_1V10 \ - : RTC_CNTL_DBIAS_SLP, \ - .vddsdio_pd_en = ((sleep_flags) & RTC_SLEEP_PD_VDDSDIO) ? 1 : 0, \ - .xtal_fpu = is_dslp(sleep_flags) ? 0 : ((sleep_flags) & RTC_SLEEP_PD_XTAL) ? 0 : 1, \ - .deep_slp_reject = 1, \ - .light_slp_reject = 1 \ -}; - #define RTC_SLEEP_PD_DIG BIT(0) //!< Deep sleep (power down digital domain) #define RTC_SLEEP_PD_RTC_PERIPH BIT(1) //!< Power down RTC peripherals #define RTC_SLEEP_PD_RTC_SLOW_MEM BIT(2) //!< Power down RTC SLOW memory @@ -705,6 +683,21 @@ typedef struct { #define RTC_SLEEP_PD_INT_8M BIT(10) //!< Power down Internal 8M oscillator #define RTC_SLEEP_PD_XTAL BIT(11) //!< Power down main XTAL +//These flags are not power domains, but will affect some sleep parameters +#define RTC_SLEEP_DIG_USE_8M BIT(16) +#define RTC_SLEEP_USE_ADC_TESEN_MONITOR BIT(17) +#define RTC_SLEEP_NO_ULTRA_LOW BIT(18) //!< Avoid using ultra low power in deep sleep, in which RTCIO cannot be used as input, and RTCMEM can't work under high temperature + +/** + * Default initializer for rtc_sleep_config_t + * + * This initializer sets all fields to "reasonable" values (e.g. suggested for + * production use) based on a combination of RTC_SLEEP_PD_x flags. + * + * @param RTC_SLEEP_PD_x flags combined using bitwise OR + */ +void rtc_sleep_get_default_config(uint32_t sleep_flags, rtc_sleep_config_t *out_config); + /** * @brief Prepare the chip to enter sleep mode * diff --git a/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/rtc_io_caps.h b/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/rtc_io_caps.h deleted file mode 100644 index 2127adac62a..00000000000 --- a/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/rtc_io_caps.h +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015-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. - -#pragma once - -#define SOC_RTCIO_PIN_COUNT 22 -#define RTCIO_LL_PIN_FUNC 0 -#define SOC_RTCIO_INPUT_OUTPUT_SUPPORTED 1 -#define SOC_RTCIO_HOLD_SUPPORTED 1 -#define SOC_RTCIO_WAKE_SUPPORTED 1 diff --git a/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/soc_caps.h b/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/soc_caps.h index b93413c502d..a09cbff1c5e 100644 --- a/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/soc_caps.h +++ b/tools/sdk/esp32s3/include/soc/esp32s3/include/soc/soc_caps.h @@ -63,6 +63,7 @@ /*!< RTC */ #define SOC_ADC_MAX_BITWIDTH (12) +#define SOC_RTC_SLOW_CLOCK_SUPPORT_8MD256 (1) /*!< Calibration */ #define SOC_ADC_CALIBRATION_V1_SUPPORTED (1) /*!< support HW offset calibration version 1*/ @@ -95,7 +96,22 @@ #define SOC_GDMA_PSRAM_MIN_ALIGN (16) // Minimal alignment for PSRAM transaction /*-------------------------- GPIO CAPS ---------------------------------------*/ -#include "gpio_caps.h" +// ESP32-S3 has 1 GPIO peripheral +#define SOC_GPIO_PORT (1U) +#define SOC_GPIO_PIN_COUNT (49) + +// On ESP32-S3, Digital IOs have their own registers to control pullup/down/capability, independent with RTC registers. +#define SOC_GPIO_SUPPORT_RTC_INDEPENDENT (1) +// Force hold is a new function of ESP32-S3 +#define SOC_GPIO_SUPPORT_FORCE_HOLD (1) + +// 0~48 except from 22~25 are valid +#define SOC_GPIO_VALID_GPIO_MASK (0x1FFFFFFFFFFFFULL & ~(0ULL | BIT22 | BIT23 | BIT24 | BIT25)) +// No GPIO is input only +#define SOC_GPIO_VALID_OUTPUT_GPIO_MASK (SOC_GPIO_VALID_GPIO_MASK) + +// Support to configure slept status +#define SOC_GPIO_SUPPORT_SLP_SWITCH (1) /*-------------------------- Dedicated GPIO CAPS -----------------------------*/ #define SOC_DEDIC_GPIO_OUT_CHANNELS_NUM (8) /*!< 8 outward channels on each CPU core */ @@ -175,7 +191,10 @@ #define SOC_RTC_CNTL_TAGMEM_PD_DMA_ADDR_ALIGN (SOC_RTC_CNTL_TAGMEM_PD_DMA_BUS_WIDTH >> 3) /*-------------------------- RTCIO CAPS --------------------------------------*/ -#include "rtc_io_caps.h" +#define SOC_RTCIO_PIN_COUNT 22 +#define SOC_RTCIO_INPUT_OUTPUT_SUPPORTED 1 +#define SOC_RTCIO_HOLD_SUPPORTED 1 +#define SOC_RTCIO_WAKE_SUPPORTED 1 /*-------------------------- SIGMA DELTA CAPS --------------------------------*/ #define SOC_SIGMADELTA_NUM (1) // 1 sigma-delta peripheral @@ -285,16 +304,13 @@ /*-------------------------- Power Management CAPS ---------------------------*/ #define SOC_PM_SUPPORT_EXT_WAKEUP (1) - #define SOC_PM_SUPPORT_WIFI_WAKEUP (1) - #define SOC_PM_SUPPORT_BT_WAKEUP (1) +#define SOC_PM_SUPPORT_TOUCH_SENSOR_WAKEUP (1) /*!