diff --git a/components/bt/esp_ble_mesh/api/esp_ble_mesh_defs.h b/components/bt/esp_ble_mesh/api/esp_ble_mesh_defs.h index 2134831306..3fadb19a16 100644 --- a/components/bt/esp_ble_mesh/api/esp_ble_mesh_defs.h +++ b/components/bt/esp_ble_mesh/api/esp_ble_mesh_defs.h @@ -68,6 +68,14 @@ typedef uint8_t esp_ble_mesh_octet8_t[ESP_BLE_MESH_OCTET8_LEN]; #define ESP_BLE_MESH_KEY_PRIMARY 0x0000 #define ESP_BLE_MESH_KEY_ANY 0xFFFF +/*!< Internal macros used to initialize array members */ +#define ESP_BLE_MESH_KEY_UNUSED_ELT_(IDX, _) ESP_BLE_MESH_KEY_UNUSED +#define ESP_BLE_MESH_ADDR_UNASSIGNED_ELT_(IDX, _) ESP_BLE_MESH_ADDR_UNASSIGNED +#define ESP_BLE_MESH_MODEL_KEYS_UNUSED \ + { LISTIFY(CONFIG_BLE_MESH_MODEL_KEY_COUNT, ESP_BLE_MESH_KEY_UNUSED_ELT_, (,)) } +#define ESP_BLE_MESH_MODEL_GROUPS_UNASSIGNED \ + { LISTIFY(CONFIG_BLE_MESH_MODEL_GROUP_COUNT, ESP_BLE_MESH_ADDR_UNASSIGNED_ELT_, (,)) } + /*!< Primary Network Key index */ #define ESP_BLE_MESH_NET_PRIMARY 0x000 @@ -264,26 +272,24 @@ typedef enum { #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 }, \ + .keys = ESP_BLE_MESH_MODEL_KEYS_UNUSED, \ + .groups = ESP_BLE_MESH_MODEL_GROUPS_UNASSIGNED, \ + .op = _op, \ .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, \ + .vnd = { \ + .company_id = (_company), \ + .model_id = (_id), \ + }, \ .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 }, \ + .keys = ESP_BLE_MESH_MODEL_KEYS_UNUSED, \ + .groups = ESP_BLE_MESH_MODEL_GROUPS_UNASSIGNED, \ + .op = _op, \ .user_data = _user_data, \ } @@ -302,8 +308,8 @@ typedef enum { { \ .location = (_loc), \ .sig_model_count = ARRAY_SIZE(_mods), \ - .sig_models = (_mods), \ .vnd_model_count = ARRAY_SIZE(_vnd_mods), \ + .sig_models = (_mods), \ .vnd_models = (_vnd_mods), \ } @@ -416,8 +422,8 @@ typedef struct { #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, \ + .update = (uint32_t)NULL, \ .dev_role = _role, \ } diff --git a/components/bt/esp_ble_mesh/mesh_common/include/mesh_buf.h b/components/bt/esp_ble_mesh/mesh_common/include/mesh_buf.h index 33baa8cc81..bb63ee8eed 100644 --- a/components/bt/esp_ble_mesh/mesh_common/include/mesh_buf.h +++ b/components/bt/esp_ble_mesh/mesh_common/include/mesh_buf.h @@ -840,22 +840,22 @@ struct net_buf_pool { #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), \ + .destroy = _destroy, \ + .alloc = _alloc, \ + .__bufs = (struct net_buf *)_bufs, \ } #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, \ + .alloc = _alloc, \ + .__bufs = (struct net_buf *)_bufs, \ } #endif /* CONFIG_BLE_MESH_NET_BUF_POOL_USAGE */ diff --git a/components/bt/esp_ble_mesh/mesh_common/include/mesh_util.h b/components/bt/esp_ble_mesh/mesh_common/include/mesh_util.h index c12c8d70a6..2173b2a2e9 100644 --- a/components/bt/esp_ble_mesh/mesh_common/include/mesh_util.h +++ b/components/bt/esp_ble_mesh/mesh_common/include/mesh_util.h @@ -17,6 +17,7 @@ #include #include "esp_bit_defs.h" #include "mesh_types.h" +#include "mesh_utils_loops.h" #ifdef __cplusplus extern "C" { @@ -180,6 +181,40 @@ extern "C" { */ #define Z_IS_ENABLED3(ignore_this, val, ...) val +/* Used to remove brackets from around a single argument. */ +#define __DEBRACKET(...) __VA_ARGS__ + +#define UTIL_CAT(a, ...) UTIL_PRIMITIVE_CAT(a, __VA_ARGS__) +#define UTIL_PRIMITIVE_CAT(a, ...) a##__VA_ARGS__ + +/** + * @brief Generates a sequence of code with configurable separator. + * + * Example: + * + * #define FOO(i, _) MY_PWM ## i + * { LISTIFY(PWM_COUNT, FOO, (,)) } + * + * The above two lines expand to: + * + * { MY_PWM0 , MY_PWM1 } + * + * @param LEN The length of the sequence. Must be an integer literal less + * than 255. + * @param F A macro function that accepts at least two arguments: + * F(i, ...). @p F is called repeatedly in the expansion. + * Its first argument @p i is the index in the sequence, and + * the variable list of arguments passed to LISTIFY are passed + * through to @p F. + * + * @param sep Separator (e.g. comma or semicolon). Must be in parentheses; + * this is required to enable providing a comma as separator. + * + * @note Calling LISTIFY with undefined arguments has undefined + * behavior. + */ +#define LISTIFY(LEN, F, sep, ...) UTIL_CAT(Z_UTIL_LISTIFY_, LEN)(F, sep, __VA_ARGS__) + const char *bt_hex(const void *buf, size_t len); void mem_rcopy(uint8_t *dst, uint8_t const *src, uint16_t len); diff --git a/components/bt/esp_ble_mesh/mesh_common/include/mesh_utils_loops.h b/components/bt/esp_ble_mesh/mesh_common/include/mesh_utils_loops.h new file mode 100644 index 0000000000..e454f1e071 --- /dev/null +++ b/components/bt/esp_ble_mesh/mesh_common/include/mesh_utils_loops.h @@ -0,0 +1,1051 @@ +/* + * SPDX-FileCopyrightText: 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** + * @file + * @brief Internals for looping macros + * + * Repetitive or obscure helper macros needed by mesh_util.h. + */ + +#ifndef _BLE_MESH_UTIL_LOOPS_H_ +#define _BLE_MESH_UTIL_LOOPS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Set of UTIL_LISTIFY particles */ +#define Z_UTIL_LISTIFY_0(F, sep, ...) + +#define Z_UTIL_LISTIFY_1(F, sep, ...) \ + F(0, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_2(F, sep, ...) \ + Z_UTIL_LISTIFY_1(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(1, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_3(F, sep, ...) \ + Z_UTIL_LISTIFY_2(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(2, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_4(F, sep, ...) \ + Z_UTIL_LISTIFY_3(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(3, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_5(F, sep, ...) \ + Z_UTIL_LISTIFY_4(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(4, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_6(F, sep, ...) \ + Z_UTIL_LISTIFY_5(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(5, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_7(F, sep, ...) \ + Z_UTIL_LISTIFY_6(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(6, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_8(F, sep, ...) \ + Z_UTIL_LISTIFY_7(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(7, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_9(F, sep, ...) \ + Z_UTIL_LISTIFY_8(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(8, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_10(F, sep, ...) \ + Z_UTIL_LISTIFY_9(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(9, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_11(F, sep, ...) \ + Z_UTIL_LISTIFY_10(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(10, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_12(F, sep, ...) \ + Z_UTIL_LISTIFY_11(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(11, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_13(F, sep, ...) \ + Z_UTIL_LISTIFY_12(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(12, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_14(F, sep, ...) \ + Z_UTIL_LISTIFY_13(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(13, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_15(F, sep, ...) \ + Z_UTIL_LISTIFY_14(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(14, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_16(F, sep, ...) \ + Z_UTIL_LISTIFY_15(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(15, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_17(F, sep, ...) \ + Z_UTIL_LISTIFY_16(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(16, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_18(F, sep, ...) \ + Z_UTIL_LISTIFY_17(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(17, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_19(F, sep, ...) \ + Z_UTIL_LISTIFY_18(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(18, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_20(F, sep, ...) \ + Z_UTIL_LISTIFY_19(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(19, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_21(F, sep, ...) \ + Z_UTIL_LISTIFY_20(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(20, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_22(F, sep, ...) \ + Z_UTIL_LISTIFY_21(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(21, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_23(F, sep, ...) \ + Z_UTIL_LISTIFY_22(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(22, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_24(F, sep, ...) \ + Z_UTIL_LISTIFY_23(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(23, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_25(F, sep, ...) \ + Z_UTIL_LISTIFY_24(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(24, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_26(F, sep, ...) \ + Z_UTIL_LISTIFY_25(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(25, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_27(F, sep, ...) \ + Z_UTIL_LISTIFY_26(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(26, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_28(F, sep, ...) \ + Z_UTIL_LISTIFY_27(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(27, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_29(F, sep, ...) \ + Z_UTIL_LISTIFY_28(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(28, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_30(F, sep, ...) \ + Z_UTIL_LISTIFY_29(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(29, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_31(F, sep, ...) \ + Z_UTIL_LISTIFY_30(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(30, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_32(F, sep, ...) \ + Z_UTIL_LISTIFY_31(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(31, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_33(F, sep, ...) \ + Z_UTIL_LISTIFY_32(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(32, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_34(F, sep, ...) \ + Z_UTIL_LISTIFY_33(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(33, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_35(F, sep, ...) \ + Z_UTIL_LISTIFY_34(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(34, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_36(F, sep, ...) \ + Z_UTIL_LISTIFY_35(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(35, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_37(F, sep, ...) \ + Z_UTIL_LISTIFY_36(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(36, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_38(F, sep, ...) \ + Z_UTIL_LISTIFY_37(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(37, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_39(F, sep, ...) \ + Z_UTIL_LISTIFY_38(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(38, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_40(F, sep, ...) \ + Z_UTIL_LISTIFY_39(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(39, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_41(F, sep, ...) \ + Z_UTIL_LISTIFY_40(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(40, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_42(F, sep, ...) \ + Z_UTIL_LISTIFY_41(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(41, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_43(F, sep, ...) \ + Z_UTIL_LISTIFY_42(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(42, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_44(F, sep, ...) \ + Z_UTIL_LISTIFY_43(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(43, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_45(F, sep, ...) \ + Z_UTIL_LISTIFY_44(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(44, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_46(F, sep, ...) \ + Z_UTIL_LISTIFY_45(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(45, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_47(F, sep, ...) \ + Z_UTIL_LISTIFY_46(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(46, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_48(F, sep, ...) \ + Z_UTIL_LISTIFY_47(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(47, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_49(F, sep, ...) \ + Z_UTIL_LISTIFY_48(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(48, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_50(F, sep, ...) \ + Z_UTIL_LISTIFY_49(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(49, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_51(F, sep, ...) \ + Z_UTIL_LISTIFY_50(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(50, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_52(F, sep, ...) \ + Z_UTIL_LISTIFY_51(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(51, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_53(F, sep, ...) \ + Z_UTIL_LISTIFY_52(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(52, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_54(F, sep, ...) \ + Z_UTIL_LISTIFY_53(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(53, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_55(F, sep, ...) \ + Z_UTIL_LISTIFY_54(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(54, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_56(F, sep, ...) \ + Z_UTIL_LISTIFY_55(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(55, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_57(F, sep, ...) \ + Z_UTIL_LISTIFY_56(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(56, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_58(F, sep, ...) \ + Z_UTIL_LISTIFY_57(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(57, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_59(F, sep, ...) \ + Z_UTIL_LISTIFY_58(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(58, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_60(F, sep, ...) \ + Z_UTIL_LISTIFY_59(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(59, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_61(F, sep, ...) \ + Z_UTIL_LISTIFY_60(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(60, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_62(F, sep, ...) \ + Z_UTIL_LISTIFY_61(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(61, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_63(F, sep, ...) \ + Z_UTIL_LISTIFY_62(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(62, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_64(F, sep, ...) \ + Z_UTIL_LISTIFY_63(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(63, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_65(F, sep, ...) \ + Z_UTIL_LISTIFY_64(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(64, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_66(F, sep, ...) \ + Z_UTIL_LISTIFY_65(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(65, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_67(F, sep, ...) \ + Z_UTIL_LISTIFY_66(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(66, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_68(F, sep, ...) \ + Z_UTIL_LISTIFY_67(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(67, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_69(F, sep, ...) \ + Z_UTIL_LISTIFY_68(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(68, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_70(F, sep, ...) \ + Z_UTIL_LISTIFY_69(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(69, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_71(F, sep, ...) \ + Z_UTIL_LISTIFY_70(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(70, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_72(F, sep, ...) \ + Z_UTIL_LISTIFY_71(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(71, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_73(F, sep, ...) \ + Z_UTIL_LISTIFY_72(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(72, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_74(F, sep, ...) \ + Z_UTIL_LISTIFY_73(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(73, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_75(F, sep, ...) \ + Z_UTIL_LISTIFY_74(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(74, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_76(F, sep, ...) \ + Z_UTIL_LISTIFY_75(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(75, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_77(F, sep, ...) \ + Z_UTIL_LISTIFY_76(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(76, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_78(F, sep, ...) \ + Z_UTIL_LISTIFY_77(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(77, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_79(F, sep, ...) \ + Z_UTIL_LISTIFY_78(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(78, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_80(F, sep, ...) \ + Z_UTIL_LISTIFY_79(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(79, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_81(F, sep, ...) \ + Z_UTIL_LISTIFY_80(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(80, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_82(F, sep, ...) \ + Z_UTIL_LISTIFY_81(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(81, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_83(F, sep, ...) \ + Z_UTIL_LISTIFY_82(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(82, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_84(F, sep, ...) \ + Z_UTIL_LISTIFY_83(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(83, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_85(F, sep, ...) \ + Z_UTIL_LISTIFY_84(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(84, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_86(F, sep, ...) \ + Z_UTIL_LISTIFY_85(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(85, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_87(F, sep, ...) \ + Z_UTIL_LISTIFY_86(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(86, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_88(F, sep, ...) \ + Z_UTIL_LISTIFY_87(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(87, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_89(F, sep, ...) \ + Z_UTIL_LISTIFY_88(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(88, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_90(F, sep, ...) \ + Z_UTIL_LISTIFY_89(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(89, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_91(F, sep, ...) \ + Z_UTIL_LISTIFY_90(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(90, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_92(F, sep, ...) \ + Z_UTIL_LISTIFY_91(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(91, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_93(F, sep, ...) \ + Z_UTIL_LISTIFY_92(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(92, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_94(F, sep, ...) \ + Z_UTIL_LISTIFY_93(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(93, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_95(F, sep, ...) \ + Z_UTIL_LISTIFY_94(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(94, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_96(F, sep, ...) \ + Z_UTIL_LISTIFY_95(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(95, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_97(F, sep, ...) \ + Z_UTIL_LISTIFY_96(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(96, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_98(F, sep, ...) \ + Z_UTIL_LISTIFY_97(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(97, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_99(F, sep, ...) \ + Z_UTIL_LISTIFY_98(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(98, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_100(F, sep, ...) \ + Z_UTIL_LISTIFY_99(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(99, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_101(F, sep, ...) \ + Z_UTIL_LISTIFY_100(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(100, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_102(F, sep, ...) \ + Z_UTIL_LISTIFY_101(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(101, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_103(F, sep, ...) \ + Z_UTIL_LISTIFY_102(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(102, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_104(F, sep, ...) \ + Z_UTIL_LISTIFY_103(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(103, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_105(F, sep, ...) \ + Z_UTIL_LISTIFY_104(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(104, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_106(F, sep, ...) \ + Z_UTIL_LISTIFY_105(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(105, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_107(F, sep, ...) \ + Z_UTIL_LISTIFY_106(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(106, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_108(F, sep, ...) \ + Z_UTIL_LISTIFY_107(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(107, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_109(F, sep, ...) \ + Z_UTIL_LISTIFY_108(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(108, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_110(F, sep, ...) \ + Z_UTIL_LISTIFY_109(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(109, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_111(F, sep, ...) \ + Z_UTIL_LISTIFY_110(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(110, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_112(F, sep, ...) \ + Z_UTIL_LISTIFY_111(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(111, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_113(F, sep, ...) \ + Z_UTIL_LISTIFY_112(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(112, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_114(F, sep, ...) \ + Z_UTIL_LISTIFY_113(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(113, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_115(F, sep, ...) \ + Z_UTIL_LISTIFY_114(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(114, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_116(F, sep, ...) \ + Z_UTIL_LISTIFY_115(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(115, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_117(F, sep, ...) \ + Z_UTIL_LISTIFY_116(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(116, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_118(F, sep, ...) \ + Z_UTIL_LISTIFY_117(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(117, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_119(F, sep, ...) \ + Z_UTIL_LISTIFY_118(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(118, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_120(F, sep, ...) \ + Z_UTIL_LISTIFY_119(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(119, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_121(F, sep, ...) \ + Z_UTIL_LISTIFY_120(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(120, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_122(F, sep, ...) \ + Z_UTIL_LISTIFY_121(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(121, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_123(F, sep, ...) \ + Z_UTIL_LISTIFY_122(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(122, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_124(F, sep, ...) \ + Z_UTIL_LISTIFY_123(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(123, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_125(F, sep, ...) \ + Z_UTIL_LISTIFY_124(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(124, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_126(F, sep, ...) \ + Z_UTIL_LISTIFY_125(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(125, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_127(F, sep, ...) \ + Z_UTIL_LISTIFY_126(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(126, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_128(F, sep, ...) \ + Z_UTIL_LISTIFY_127(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(127, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_129(F, sep, ...) \ + Z_UTIL_LISTIFY_128(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(128, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_130(F, sep, ...) \ + Z_UTIL_LISTIFY_129(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(129, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_131(F, sep, ...) \ + Z_UTIL_LISTIFY_130(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(130, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_132(F, sep, ...) \ + Z_UTIL_LISTIFY_131(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(131, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_133(F, sep, ...) \ + Z_UTIL_LISTIFY_132(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(132, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_134(F, sep, ...) \ + Z_UTIL_LISTIFY_133(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(133, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_135(F, sep, ...) \ + Z_UTIL_LISTIFY_134(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(134, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_136(F, sep, ...) \ + Z_UTIL_LISTIFY_135(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(135, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_137(F, sep, ...) \ + Z_UTIL_LISTIFY_136(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(136, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_138(F, sep, ...) \ + Z_UTIL_LISTIFY_137(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(137, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_139(F, sep, ...) \ + Z_UTIL_LISTIFY_138(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(138, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_140(F, sep, ...) \ + Z_UTIL_LISTIFY_139(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(139, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_141(F, sep, ...) \ + Z_UTIL_LISTIFY_140(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(140, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_142(F, sep, ...) \ + Z_UTIL_LISTIFY_141(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(141, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_143(F, sep, ...) \ + Z_UTIL_LISTIFY_142(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(142, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_144(F, sep, ...) \ + Z_UTIL_LISTIFY_143(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(143, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_145(F, sep, ...) \ + Z_UTIL_LISTIFY_144(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(144, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_146(F, sep, ...) \ + Z_UTIL_LISTIFY_145(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(145, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_147(F, sep, ...) \ + Z_UTIL_LISTIFY_146(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(146, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_148(F, sep, ...) \ + Z_UTIL_LISTIFY_147(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(147, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_149(F, sep, ...) \ + Z_UTIL_LISTIFY_148(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(148, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_150(F, sep, ...) \ + Z_UTIL_LISTIFY_149(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(149, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_151(F, sep, ...) \ + Z_UTIL_LISTIFY_150(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(150, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_152(F, sep, ...) \ + Z_UTIL_LISTIFY_151(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(151, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_153(F, sep, ...) \ + Z_UTIL_LISTIFY_152(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(152, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_154(F, sep, ...) \ + Z_UTIL_LISTIFY_153(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(153, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_155(F, sep, ...) \ + Z_UTIL_LISTIFY_154(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(154, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_156(F, sep, ...) \ + Z_UTIL_LISTIFY_155(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(155, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_157(F, sep, ...) \ + Z_UTIL_LISTIFY_156(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(156, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_158(F, sep, ...) \ + Z_UTIL_LISTIFY_157(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(157, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_159(F, sep, ...) \ + Z_UTIL_LISTIFY_158(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(158, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_160(F, sep, ...) \ + Z_UTIL_LISTIFY_159(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(159, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_161(F, sep, ...) \ + Z_UTIL_LISTIFY_160(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(160, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_162(F, sep, ...) \ + Z_UTIL_LISTIFY_161(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(161, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_163(F, sep, ...) \ + Z_UTIL_LISTIFY_162(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(162, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_164(F, sep, ...) \ + Z_UTIL_LISTIFY_163(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(163, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_165(F, sep, ...) \ + Z_UTIL_LISTIFY_164(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(164, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_166(F, sep, ...) \ + Z_UTIL_LISTIFY_165(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(165, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_167(F, sep, ...) \ + Z_UTIL_LISTIFY_166(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(166, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_168(F, sep, ...) \ + Z_UTIL_LISTIFY_167(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(167, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_169(F, sep, ...) \ + Z_UTIL_LISTIFY_168(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(168, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_170(F, sep, ...) \ + Z_UTIL_LISTIFY_169(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(169, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_171(F, sep, ...) \ + Z_UTIL_LISTIFY_170(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(170, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_172(F, sep, ...) \ + Z_UTIL_LISTIFY_171(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(171, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_173(F, sep, ...) \ + Z_UTIL_LISTIFY_172(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(172, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_174(F, sep, ...) \ + Z_UTIL_LISTIFY_173(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(173, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_175(F, sep, ...) \ + Z_UTIL_LISTIFY_174(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(174, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_176(F, sep, ...) \ + Z_UTIL_LISTIFY_175(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(175, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_177(F, sep, ...) \ + Z_UTIL_LISTIFY_176(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(176, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_178(F, sep, ...) \ + Z_UTIL_LISTIFY_177(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(177, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_179(F, sep, ...) \ + Z_UTIL_LISTIFY_178(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(178, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_180(F, sep, ...) \ + Z_UTIL_LISTIFY_179(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(179, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_181(F, sep, ...) \ + Z_UTIL_LISTIFY_180(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(180, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_182(F, sep, ...) \ + Z_UTIL_LISTIFY_181(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(181, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_183(F, sep, ...) \ + Z_UTIL_LISTIFY_182(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(182, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_184(F, sep, ...) \ + Z_UTIL_LISTIFY_183(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(183, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_185(F, sep, ...) \ + Z_UTIL_LISTIFY_184(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(184, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_186(F, sep, ...) \ + Z_UTIL_LISTIFY_185(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(185, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_187(F, sep, ...) \ + Z_UTIL_LISTIFY_186(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(186, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_188(F, sep, ...) \ + Z_UTIL_LISTIFY_187(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(187, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_189(F, sep, ...) \ + Z_UTIL_LISTIFY_188(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(188, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_190(F, sep, ...) \ + Z_UTIL_LISTIFY_189(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(189, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_191(F, sep, ...) \ + Z_UTIL_LISTIFY_190(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(190, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_192(F, sep, ...) \ + Z_UTIL_LISTIFY_191(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(191, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_193(F, sep, ...) \ + Z_UTIL_LISTIFY_192(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(192, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_194(F, sep, ...) \ + Z_UTIL_LISTIFY_193(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(193, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_195(F, sep, ...) \ + Z_UTIL_LISTIFY_194(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(194, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_196(F, sep, ...) \ + Z_UTIL_LISTIFY_195(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(195, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_197(F, sep, ...) \ + Z_UTIL_LISTIFY_196(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(196, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_198(F, sep, ...) \ + Z_UTIL_LISTIFY_197(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(197, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_199(F, sep, ...) \ + Z_UTIL_LISTIFY_198(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(198, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_200(F, sep, ...) \ + Z_UTIL_LISTIFY_199(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(199, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_201(F, sep, ...) \ + Z_UTIL_LISTIFY_200(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(200, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_202(F, sep, ...) \ + Z_UTIL_LISTIFY_201(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(201, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_203(F, sep, ...) \ + Z_UTIL_LISTIFY_202(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(202, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_204(F, sep, ...) \ + Z_UTIL_LISTIFY_203(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(203, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_205(F, sep, ...) \ + Z_UTIL_LISTIFY_204(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(204, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_206(F, sep, ...) \ + Z_UTIL_LISTIFY_205(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(205, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_207(F, sep, ...) \ + Z_UTIL_LISTIFY_206(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(206, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_208(F, sep, ...) \ + Z_UTIL_LISTIFY_207(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(207, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_209(F, sep, ...) \ + Z_UTIL_LISTIFY_208(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(208, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_210(F, sep, ...) \ + Z_UTIL_LISTIFY_209(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(209, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_211(F, sep, ...) \ + Z_UTIL_LISTIFY_210(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(210, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_212(F, sep, ...) \ + Z_UTIL_LISTIFY_211(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(211, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_213(F, sep, ...) \ + Z_UTIL_LISTIFY_212(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(212, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_214(F, sep, ...) \ + Z_UTIL_LISTIFY_213(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(213, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_215(F, sep, ...) \ + Z_UTIL_LISTIFY_214(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(214, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_216(F, sep, ...) \ + Z_UTIL_LISTIFY_215(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(215, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_217(F, sep, ...) \ + Z_UTIL_LISTIFY_216(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(216, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_218(F, sep, ...) \ + Z_UTIL_LISTIFY_217(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(217, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_219(F, sep, ...) \ + Z_UTIL_LISTIFY_218(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(218, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_220(F, sep, ...) \ + Z_UTIL_LISTIFY_219(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(219, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_221(F, sep, ...) \ + Z_UTIL_LISTIFY_220(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(220, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_222(F, sep, ...) \ + Z_UTIL_LISTIFY_221(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(221, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_223(F, sep, ...) \ + Z_UTIL_LISTIFY_222(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(222, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_224(F, sep, ...) \ + Z_UTIL_LISTIFY_223(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(223, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_225(F, sep, ...) \ + Z_UTIL_LISTIFY_224(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(224, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_226(F, sep, ...) \ + Z_UTIL_LISTIFY_225(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(225, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_227(F, sep, ...) \ + Z_UTIL_LISTIFY_226(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(226, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_228(F, sep, ...) \ + Z_UTIL_LISTIFY_227(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(227, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_229(F, sep, ...) \ + Z_UTIL_LISTIFY_228(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(228, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_230(F, sep, ...) \ + Z_UTIL_LISTIFY_229(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(229, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_231(F, sep, ...) \ + Z_UTIL_LISTIFY_230(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(230, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_232(F, sep, ...) \ + Z_UTIL_LISTIFY_231(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(231, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_233(F, sep, ...) \ + Z_UTIL_LISTIFY_232(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(232, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_234(F, sep, ...) \ + Z_UTIL_LISTIFY_233(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(233, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_235(F, sep, ...) \ + Z_UTIL_LISTIFY_234(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(234, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_236(F, sep, ...) \ + Z_UTIL_LISTIFY_235(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(235, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_237(F, sep, ...) \ + Z_UTIL_LISTIFY_236(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(236, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_238(F, sep, ...) \ + Z_UTIL_LISTIFY_237(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(237, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_239(F, sep, ...) \ + Z_UTIL_LISTIFY_238(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(238, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_240(F, sep, ...) \ + Z_UTIL_LISTIFY_239(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(239, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_241(F, sep, ...) \ + Z_UTIL_LISTIFY_240(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(240, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_242(F, sep, ...) \ + Z_UTIL_LISTIFY_241(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(241, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_243(F, sep, ...) \ + Z_UTIL_LISTIFY_242(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(242, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_244(F, sep, ...) \ + Z_UTIL_LISTIFY_243(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(243, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_245(F, sep, ...) \ + Z_UTIL_LISTIFY_244(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(244, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_246(F, sep, ...) \ + Z_UTIL_LISTIFY_245(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(245, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_247(F, sep, ...) \ + Z_UTIL_LISTIFY_246(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(246, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_248(F, sep, ...) \ + Z_UTIL_LISTIFY_247(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(247, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_249(F, sep, ...) \ + Z_UTIL_LISTIFY_248(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(248, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_250(F, sep, ...) \ + Z_UTIL_LISTIFY_249(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(249, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_251(F, sep, ...) \ + Z_UTIL_LISTIFY_250(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(250, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_252(F, sep, ...) \ + Z_UTIL_LISTIFY_251(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(251, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_253(F, sep, ...) \ + Z_UTIL_LISTIFY_252(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(252, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_254(F, sep, ...) \ + Z_UTIL_LISTIFY_253(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(253, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_255(F, sep, ...) \ + Z_UTIL_LISTIFY_254(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(254, __VA_ARGS__) + +#define Z_UTIL_LISTIFY_256(F, sep, ...) \ + Z_UTIL_LISTIFY_255(F, sep, __VA_ARGS__) __DEBRACKET sep \ + F(255, __VA_ARGS__) + +#ifdef __cplusplus +} +#endif + +#endif /* _BLE_MESH_UTIL_LOOPS_H_ */ diff --git a/components/bt/esp_ble_mesh/mesh_core/include/mesh_access.h b/components/bt/esp_ble_mesh/mesh_core/include/mesh_access.h index 66fbb7e43f..98961f4386 100644 --- a/components/bt/esp_ble_mesh/mesh_core/include/mesh_access.h +++ b/components/bt/esp_ble_mesh/mesh_core/include/mesh_access.h @@ -50,8 +50,8 @@ extern "C" { { \ .loc = (_loc), \ .model_count = ARRAY_SIZE(_mods), \ - .models = (_mods), \ .vnd_model_count = ARRAY_SIZE(_vnd_mods), \ + .models = (_mods), \ .vnd_models = (_vnd_mods), \ } @@ -255,14 +255,12 @@ struct bt_mesh_model_op { #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), \ + .keys = ESP_BLE_MESH_MODEL_KEYS_UNUSED, \ + .groups = ESP_BLE_MESH_MODEL_GROUPS_UNASSIGNED, \ + .op = (_op), \ .cb = (_cb), \ + .user_data = (_user_data), \ } /** @def BLE_MESH_MODEL_VND_CB @@ -280,14 +278,12 @@ struct bt_mesh_model_op { { \ .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), \ + .keys = ESP_BLE_MESH_MODEL_KEYS_UNUSED, \ + .groups = ESP_BLE_MESH_MODEL_GROUPS_UNASSIGNED, \ + .op = (_op), \ .cb = (_cb), \ + .user_data = (_user_data), \ } /** @def BLE_MESH_TRANSMIT @@ -419,8 +415,8 @@ struct bt_mesh_model_pub { #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, \ + .update = _update, \ } /** Model callback functions. */ diff --git a/components/bt/esp_ble_mesh/mesh_core/include/mesh_bearer_adapt.h b/components/bt/esp_ble_mesh/mesh_core/include/mesh_bearer_adapt.h index 63ca8c3864..f3cd101fc1 100644 --- a/components/bt/esp_ble_mesh/mesh_core/include/mesh_bearer_adapt.h +++ b/components/bt/esp_ble_mesh/mesh_core/include/mesh_bearer_adapt.h @@ -573,9 +573,9 @@ struct bt_mesh_gatt_attr { #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, \ + .perm = BLE_MESH_GATT_PERM_READ, \ } /** @def BLE_MESH_GATT_SECONDARY_SERVICE @@ -588,9 +588,9 @@ struct bt_mesh_gatt_attr { #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, \ + .perm = BLE_MESH_GATT_PERM_READ, \ } /** @def BLE_MESH_GATT_INCLUDE_SERVICE @@ -603,9 +603,9 @@ struct bt_mesh_gatt_attr { #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, \ + .perm = BLE_MESH_GATT_PERM_READ, \ } /** @def BLE_MESH_GATT_CHARACTERISTIC @@ -619,10 +619,10 @@ struct bt_mesh_gatt_attr { #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, }), \ + .perm = BLE_MESH_GATT_PERM_READ, \ } /** @def BLE_MESH_GATT_DESCRIPTOR @@ -639,10 +639,10 @@ struct bt_mesh_gatt_attr { #define BLE_MESH_GATT_DESCRIPTOR(_uuid, _perm, _read, _write, _value) \ { \ .uuid = _uuid, \ - .perm = _perm, \ .read = _read, \ .write = _write, \ .user_data = _value, \ + .perm = _perm, \ } /** @def BLE_MESH_GATT_SERVICE diff --git a/examples/bluetooth/esp_ble_mesh/aligenie_demo/main/aligenie_demo.c b/examples/bluetooth/esp_ble_mesh/aligenie_demo/main/aligenie_demo.c index 32fc094cee..58cf187713 100644 --- a/examples/bluetooth/esp_ble_mesh/aligenie_demo/main/aligenie_demo.c +++ b/examples/bluetooth/esp_ble_mesh/aligenie_demo/main/aligenie_demo.c @@ -73,23 +73,23 @@ static uint8_t dev_uuid[16] = { }; static esp_ble_mesh_cfg_srv_t config_server = { + /* 3 transmissions with 20ms interval */ + .net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20), .relay = ESP_BLE_MESH_RELAY_ENABLED, + /* 3 transmissions with 20ms interval */ + .relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20), .beacon = ESP_BLE_MESH_BEACON_ENABLED, -#if defined(CONFIG_BLE_MESH_FRIEND) - .friend_state = ESP_BLE_MESH_FRIEND_ENABLED, -#else - .friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED, -#endif #if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER) .gatt_proxy = ESP_BLE_MESH_GATT_PROXY_ENABLED, #else .gatt_proxy = ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED, +#endif +#if defined(CONFIG_BLE_MESH_FRIEND) + .friend_state = ESP_BLE_MESH_FRIEND_ENABLED, +#else + .friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED, #endif .default_ttl = 7, - /* 3 transmissions with 20ms interval */ - .net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20), - /* 3 transmissions with 20ms interval */ - .relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20), }; uint8_t test_ids[1] = {0x00}; @@ -97,15 +97,19 @@ uint8_t test_ids[1] = {0x00}; /** ESP BLE Mesh Health Server Model Context */ ESP_BLE_MESH_MODEL_PUB_DEFINE(health_pub, 2 + 11, ROLE_NODE); static esp_ble_mesh_health_srv_t health_server = { - .health_test.id_count = 1, - .health_test.test_ids = test_ids, + .health_test = { + .id_count = 1, + .test_ids = test_ids, + }, }; #ifdef CONFIG_MESH_MODEL_GEN_ONOFF_SRV ESP_BLE_MESH_MODEL_PUB_DEFINE(onoff_pub_0, 2 + 3, ROLE_NODE); static esp_ble_mesh_gen_onoff_srv_t onoff_server_0 = { - .rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP, - .rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP, + .rsp_ctrl = { + .get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP, + .set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP, + }, }; #endif @@ -116,16 +120,20 @@ static esp_ble_mesh_light_lightness_state_t lightness_state; /* Light Lightness Server related context */ ESP_BLE_MESH_MODEL_PUB_DEFINE(lightness_pub, 2 + 5, ROLE_NODE); static esp_ble_mesh_light_lightness_srv_t lightness_server = { - .rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP, - .rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP, + .rsp_ctrl = { + .get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP, + .set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP, + }, .state = &lightness_state, }; /* Light Lightness Setup Server related context */ ESP_BLE_MESH_MODEL_PUB_DEFINE(lightness_setup_pub, 2 + 5, ROLE_NODE); static esp_ble_mesh_light_lightness_setup_srv_t lightness_setup_server = { - .rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP, - .rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP, + .rsp_ctrl = { + .get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP, + .set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP, + }, .state = &lightness_state, }; #endif @@ -137,16 +145,20 @@ static esp_ble_mesh_light_ctl_state_t ctl_state; /* Light CTL Server related context */ ESP_BLE_MESH_MODEL_PUB_DEFINE(ctl_pub, 2 + 9, ROLE_NODE); static esp_ble_mesh_light_ctl_srv_t ctl_server = { - .rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP, - .rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP, + .rsp_ctrl = { + .get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP, + .set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP, + }, .state = &ctl_state, }; /* Light CTL Setup Server related context */ ESP_BLE_MESH_MODEL_PUB_DEFINE(ctl_setup_pub, 2 + 6, ROLE_NODE); static esp_ble_mesh_light_ctl_setup_srv_t ctl_setup_server = { - .rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP, - .rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP, + .rsp_ctrl = { + .get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP, + .set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP, + }, .state = &ctl_state, }; #endif @@ -158,16 +170,20 @@ static esp_ble_mesh_light_hsl_state_t hsl_state; /* Light HSL Server related context */ ESP_BLE_MESH_MODEL_PUB_DEFINE(hsl_pub, 2 + 9, ROLE_NODE); static esp_ble_mesh_light_hsl_srv_t hsl_server = { - .rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP, - .rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP, + .rsp_ctrl = { + .get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP, + .set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP, + }, .state = &hsl_state, }; /* Light HSL Setup Server related context */ ESP_BLE_MESH_MODEL_PUB_DEFINE(hsl_setup_pub, 2 + 9, ROLE_NODE); static esp_ble_mesh_light_hsl_setup_srv_t hsl_setup_server = { - .rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP, - .rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP, + .rsp_ctrl = { + .get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP, + .set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP, + }, .state = &hsl_state, }; #endif @@ -214,14 +230,18 @@ static esp_ble_mesh_model_t ali_vnd_models[] = { ESP_BLE_MESH_MODEL_PUB_DEFINE(onoff_pub_1, 2 + 3, ROLE_NODE); static esp_ble_mesh_gen_onoff_srv_t onoff_server_1 = { - .rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP, - .rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP, + .rsp_ctrl = { + .get_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP, + .set_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP, + }, }; ESP_BLE_MESH_MODEL_PUB_DEFINE(onoff_pub_2, 2 + 3, ROLE_NODE); static esp_ble_mesh_gen_onoff_srv_t onoff_server_2 = { - .rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP, - .rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP, + .rsp_ctrl = { + .get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP, + .set_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP, + }, }; static esp_ble_mesh_model_t extend_model_0[] = { @@ -240,8 +260,8 @@ esp_ble_mesh_elem_t elements[] = { static esp_ble_mesh_comp_t composition = { .cid = CID_ALIBABA, - .elements = elements, .element_count = ARRAY_SIZE(elements), + .elements = elements, }; /* Disable OOB security for SILabs Android app */ @@ -497,7 +517,7 @@ void user_genie_event_handle(genie_event_t event, void *p_arg) case GENIE_EVT_SDK_COLOR_ACTION: { ESP_LOGI(TAG, "GENIE_EVT_SDK_COLOR_ACTION"); #ifdef CONFIG_MESH_MODEL_HSL_SRV - uint8_t *p_data = p_arg; + uint8_t *p_data = (uint8_t *)p_arg; uint16_t lightness = *p_data++; lightness += (*p_data++ << 8); @@ -1064,7 +1084,7 @@ static void example_ble_mesh_generic_server_cb(esp_ble_mesh_generic_server_cb_ev case ESP_BLE_MESH_GENERIC_SERVER_RECV_GET_MSG_EVT: ESP_LOGI(TAG, "ESP_BLE_MESH_GENERIC_SERVER_RECV_GET_MSG_EVT"); if (param->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_GET) { - esp_ble_mesh_gen_onoff_srv_t *srv = param->model->user_data; + esp_ble_mesh_gen_onoff_srv_t *srv = (esp_ble_mesh_gen_onoff_srv_t *)param->model->user_data; ESP_LOGI(TAG, "onoff: 0x%02x", srv->state.onoff); esp_ble_mesh_server_model_send_msg(param->model, ¶m->ctx, ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_STATUS, sizeof(srv->state.onoff), &srv->state.onoff); @@ -1080,7 +1100,7 @@ static void example_ble_mesh_generic_server_cb(esp_ble_mesh_generic_server_cb_ev param->value.set.onoff.trans_time, param->value.set.onoff.delay); } - esp_ble_mesh_gen_onoff_srv_t *srv = param->model->user_data; + esp_ble_mesh_gen_onoff_srv_t *srv = (esp_ble_mesh_gen_onoff_srv_t *)param->model->user_data; if (param->value.set.onoff.op_en == false) { srv->state.onoff = param->value.set.onoff.onoff; } else { @@ -1287,7 +1307,7 @@ static esp_err_t ble_mesh_init(void) return err; } - ESP_ERROR_CHECK(esp_ble_mesh_node_prov_enable(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT)); + ESP_ERROR_CHECK(esp_ble_mesh_node_prov_enable((esp_ble_mesh_prov_bearer_t)(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT))); if (esp_ble_mesh_node_is_provisioned()) { ESP_LOGW(TAG, "node already provisioned"); diff --git a/examples/bluetooth/esp_ble_mesh/aligenie_demo/main/include/board.h b/examples/bluetooth/esp_ble_mesh/aligenie_demo/main/include/board.h index 960a5f1f86..6f3e61c01b 100644 --- a/examples/bluetooth/esp_ble_mesh/aligenie_demo/main/include/board.h +++ b/examples/bluetooth/esp_ble_mesh/aligenie_demo/main/include/board.h @@ -9,14 +9,13 @@ #ifndef _BOARD_H_ #define _BOARD_H_ -#include "driver/gpio.h" - -#include "lightbulb.h" - #ifdef __cplusplus extern "C" { #endif /**< __cplusplus */ +#include "driver/gpio.h" +#include "lightbulb.h" + #define LED_ON 1 #define LED_OFF 0 @@ -81,4 +80,4 @@ uint8_t *mac_str2hex(const char *mac_str, uint8_t *mac_hex); } #endif /**< __cplusplus */ -#endif +#endif /* _BOARD_H_ */ diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_client/main/main.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_client/main/main.c index 55951da892..6ee2164d5a 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_client/main/main.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_client/main/main.c @@ -41,22 +41,22 @@ static const esp_ble_mesh_client_op_pair_t fast_prov_cli_op_pair[] = { }; static esp_ble_mesh_cfg_srv_t config_server = { + /* 3 transmissions with a 20ms interval */ + .net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20), .relay = ESP_BLE_MESH_RELAY_DISABLED, + .relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20), .beacon = ESP_BLE_MESH_BEACON_ENABLED, -#if defined(CONFIG_BLE_MESH_FRIEND) - .friend_state = ESP_BLE_MESH_FRIEND_ENABLED, -#else - .friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED, -#endif #if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER) .gatt_proxy = ESP_BLE_MESH_GATT_PROXY_ENABLED, #else .gatt_proxy = ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED, +#endif +#if defined(CONFIG_BLE_MESH_FRIEND) + .friend_state = ESP_BLE_MESH_FRIEND_ENABLED, +#else + .friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED, #endif .default_ttl = 7, - /* 3 transmissions with a 20ms interval */ - .net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20), - .relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20), }; esp_ble_mesh_client_t config_client; esp_ble_mesh_client_t gen_onoff_client; @@ -89,8 +89,8 @@ static esp_ble_mesh_elem_t elements[] = { static esp_ble_mesh_comp_t comp = { .cid = CID_ESP, - .elements = elements, .element_count = ARRAY_SIZE(elements), + .elements = elements, }; static esp_ble_mesh_prov_t prov = { @@ -211,10 +211,10 @@ static void example_recv_unprov_adv_pkt(uint8_t dev_uuid[16], uint8_t addr[BLE_M add: memcpy(add_dev.addr, addr, 6); - add_dev.addr_type = (uint8_t)addr_type; + add_dev.addr_type = (esp_ble_mesh_addr_type_t)addr_type; memcpy(add_dev.uuid, dev_uuid, 16); add_dev.oob_info = oob_info; - add_dev.bearer = (uint8_t)bearer; + add_dev.bearer = (esp_ble_mesh_prov_bearer_t)bearer; flag = ADD_DEV_RM_AFTER_PROV_FLAG | ADD_DEV_START_PROV_NOW_FLAG | ADD_DEV_FLUSHABLE_DEV_FLAG; err = esp_ble_mesh_provisioner_add_unprov_dev(&add_dev, flag); if (err != ESP_OK) { @@ -551,7 +551,7 @@ static esp_err_t ble_mesh_init(void) return ESP_FAIL; } - err = esp_ble_mesh_provisioner_prov_enable(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT); + err = esp_ble_mesh_provisioner_prov_enable((esp_ble_mesh_prov_bearer_t)(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT)); if (err != ESP_OK) { ESP_LOGE(TAG, "%s: Failed to enable provisioning", __func__); return ESP_FAIL; diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_server/main/board.h b/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_server/main/board.h index a58e86ba4a..02875fff7b 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_server/main/board.h +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_server/main/board.h @@ -8,6 +8,10 @@ #ifndef _BOARD_H_ #define _BOARD_H_ +#ifdef __cplusplus +extern "C" { +#endif /**< __cplusplus */ + #include "sdkconfig.h" #include "driver/gpio.h" #include "esp_ble_mesh_defs.h" @@ -45,4 +49,8 @@ void board_led_operation(uint8_t pin, uint8_t onoff); esp_err_t board_init(void); +#ifdef __cplusplus +} +#endif /**< __cplusplus */ + #endif diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_server/main/main.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_server/main/main.c index ce2135e8cb..4ca03a2950 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_server/main/main.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_fast_provision/fast_prov_server/main/main.c @@ -48,22 +48,22 @@ esp_ble_mesh_client_t config_client; /* Configuration Server Model user_data */ esp_ble_mesh_cfg_srv_t config_server = { + /* 3 transmissions with 20ms interval */ + .net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20), .relay = ESP_BLE_MESH_RELAY_ENABLED, + .relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20), .beacon = ESP_BLE_MESH_BEACON_DISABLED, -#if defined(CONFIG_BLE_MESH_FRIEND) - .friend_state = ESP_BLE_MESH_FRIEND_ENABLED, -#else - .friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED, -#endif #if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER) .gatt_proxy = ESP_BLE_MESH_GATT_PROXY_ENABLED, #else .gatt_proxy = ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED, +#endif +#if defined(CONFIG_BLE_MESH_FRIEND) + .friend_state = ESP_BLE_MESH_FRIEND_ENABLED, +#else + .friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED, #endif .default_ttl = 7, - /* 3 transmissions with 20ms interval */ - .net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20), - .relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20), }; /* Fast Prov Client Model user_data */ @@ -77,6 +77,7 @@ example_fast_prov_server_t fast_prov_server = { .primary_role = false, .max_node_num = 6, .prov_node_cnt = 0x0, + .app_idx = ESP_BLE_MESH_KEY_UNUSED, .unicast_min = ESP_BLE_MESH_ADDR_UNASSIGNED, .unicast_max = ESP_BLE_MESH_ADDR_UNASSIGNED, .unicast_cur = ESP_BLE_MESH_ADDR_UNASSIGNED, @@ -84,7 +85,6 @@ example_fast_prov_server_t fast_prov_server = { .flags = 0x0, .iv_index = 0x0, .net_idx = ESP_BLE_MESH_KEY_UNUSED, - .app_idx = ESP_BLE_MESH_KEY_UNUSED, .group_addr = ESP_BLE_MESH_ADDR_UNASSIGNED, .prim_prov_addr = ESP_BLE_MESH_ADDR_UNASSIGNED, .match_len = 0x0, @@ -94,8 +94,10 @@ example_fast_prov_server_t fast_prov_server = { ESP_BLE_MESH_MODEL_PUB_DEFINE(onoff_pub, 2 + 3, ROLE_FAST_PROV); static esp_ble_mesh_gen_onoff_srv_t onoff_server = { - .rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP, - .rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP, + .rsp_ctrl = { + .get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP, + .set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP, + } }; static esp_ble_mesh_model_op_t fast_prov_srv_op[] = { @@ -134,8 +136,8 @@ static esp_ble_mesh_elem_t elements[] = { static esp_ble_mesh_comp_t comp = { .cid = CID_ESP, - .elements = elements, .element_count = ARRAY_SIZE(elements), + .elements = elements, }; static esp_ble_mesh_prov_t prov = { @@ -309,9 +311,9 @@ static void example_recv_unprov_adv_pkt(uint8_t dev_uuid[16], uint8_t addr[BLE_M } } - add_dev.addr_type = (uint8_t)addr_type; + add_dev.addr_type = (esp_ble_mesh_addr_type_t)addr_type; add_dev.oob_info = oob_info; - add_dev.bearer = (uint8_t)bearer; + add_dev.bearer = (esp_ble_mesh_prov_bearer_t)bearer; memcpy(add_dev.uuid, dev_uuid, 16); memcpy(add_dev.addr, addr, BLE_MESH_ADDR_LEN); flag = ADD_DEV_RM_AFTER_PROV_FLAG | ADD_DEV_START_PROV_NOW_FLAG | ADD_DEV_FLUSHABLE_DEV_FLAG; @@ -452,8 +454,8 @@ static void example_ble_mesh_custom_model_cb(esp_ble_mesh_model_cb_event_t event case ESP_BLE_MESH_VND_MODEL_OP_FAST_PROV_NODE_GROUP_DELETE: { ESP_LOGI(TAG, "%s: Fast prov server receives msg, opcode 0x%04" PRIx32, __func__, opcode); struct net_buf_simple buf = { - .len = param->model_operation.length, .data = param->model_operation.msg, + .len = param->model_operation.length, }; err = example_fast_prov_server_recv_msg(param->model_operation.model, param->model_operation.ctx, &buf); @@ -727,7 +729,7 @@ static esp_err_t ble_mesh_init(void) k_delayed_work_init(&send_self_prov_node_addr_timer, example_send_self_prov_node_addr); - err = esp_ble_mesh_node_prov_enable(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT); + err = esp_ble_mesh_node_prov_enable((esp_ble_mesh_prov_bearer_t)(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT)); if (err != ESP_OK) { ESP_LOGE(TAG, "%s: Failed to enable node provisioning", __func__); return err; diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/main/board.h b/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/main/board.h index 1cae103eb5..08cfd13454 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/main/board.h +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/main/board.h @@ -10,6 +10,10 @@ #ifndef _BOARD_H_ #define _BOARD_H_ +#ifdef __cplusplus +extern "C" { +#endif /**< __cplusplus */ + #include "driver/gpio.h" #include "esp_ble_mesh_defs.h" @@ -45,4 +49,8 @@ void board_led_operation(uint8_t pin, uint8_t onoff); void board_init(void); -#endif +#ifdef __cplusplus +} +#endif /**< __cplusplus */ + +#endif /* _BOARD_H_ */ diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/main/main.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/main/main.c index 9b4d2bafb7..c619ea9cf3 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/main/main.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_client/main/main.c @@ -48,22 +48,22 @@ static const char * NVS_KEY = "onoff_client"; static esp_ble_mesh_client_t onoff_client; static esp_ble_mesh_cfg_srv_t config_server = { - .relay = ESP_BLE_MESH_RELAY_ENABLED, + /* 3 transmissions with 20ms interval */ + .net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20), + .relay = ESP_BLE_MESH_RELAY_DISABLED, + .relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20), .beacon = ESP_BLE_MESH_BEACON_ENABLED, -#if defined(CONFIG_BLE_MESH_FRIEND) - .friend_state = ESP_BLE_MESH_FRIEND_ENABLED, -#else - .friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED, -#endif #if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER) .gatt_proxy = ESP_BLE_MESH_GATT_PROXY_ENABLED, #else .gatt_proxy = ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED, +#endif +#if defined(CONFIG_BLE_MESH_FRIEND) + .friend_state = ESP_BLE_MESH_FRIEND_ENABLED, +#else + .friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED, #endif .default_ttl = 7, - /* 3 transmissions with 20ms interval */ - .net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20), - .relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20), }; ESP_BLE_MESH_MODEL_PUB_DEFINE(onoff_cli_pub, 2 + 1, ROLE_NODE); @@ -79,8 +79,8 @@ static esp_ble_mesh_elem_t elements[] = { static esp_ble_mesh_comp_t composition = { .cid = CID_ESP, - .elements = elements, .element_count = ARRAY_SIZE(elements), + .elements = elements, }; /* Disable OOB security for SILabs Android app */ @@ -89,8 +89,8 @@ static esp_ble_mesh_prov_t provision = { #if 0 .output_size = 4, .output_actions = ESP_BLE_MESH_DISPLAY_NUMBER, - .input_actions = ESP_BLE_MESH_PUSH, .input_size = 4, + .input_actions = ESP_BLE_MESH_PUSH, #else .output_size = 0, .output_actions = 0, @@ -278,7 +278,7 @@ static esp_err_t ble_mesh_init(void) return err; } - err = esp_ble_mesh_node_prov_enable(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT); + err = esp_ble_mesh_node_prov_enable((esp_ble_mesh_prov_bearer_t)(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT)); if (err != ESP_OK) { ESP_LOGE(TAG, "Failed to enable mesh node (err %d)", err); return err; diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_server/main/board.h b/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_server/main/board.h index 1d9a56989b..26a4e93b5b 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_server/main/board.h +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_server/main/board.h @@ -10,6 +10,10 @@ #ifndef _BOARD_H_ #define _BOARD_H_ +#ifdef __cplusplus +extern "C" { +#endif /**< __cplusplus */ + #include "driver/gpio.h" #if defined(CONFIG_BLE_MESH_ESP_WROOM_32) @@ -44,4 +48,8 @@ void board_led_operation(uint8_t pin, uint8_t onoff); void board_init(void); -#endif +#ifdef __cplusplus +} +#endif /**< __cplusplus */ + +#endif /* _BOARD_H_ */ diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_server/main/main.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_server/main/main.c index dc39598458..8e115b43e6 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_server/main/main.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_node/onoff_server/main/main.c @@ -34,40 +34,46 @@ extern struct _led_state led_state[3]; static uint8_t dev_uuid[16] = { 0xdd, 0xdd }; static esp_ble_mesh_cfg_srv_t config_server = { - .relay = ESP_BLE_MESH_RELAY_ENABLED, + /* 3 transmissions with 20ms interval */ + .net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20), + .relay = ESP_BLE_MESH_RELAY_DISABLED, + .relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20), .beacon = ESP_BLE_MESH_BEACON_ENABLED, -#if defined(CONFIG_BLE_MESH_FRIEND) - .friend_state = ESP_BLE_MESH_FRIEND_ENABLED, -#else - .friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED, -#endif #if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER) .gatt_proxy = ESP_BLE_MESH_GATT_PROXY_ENABLED, #else .gatt_proxy = ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED, +#endif +#if defined(CONFIG_BLE_MESH_FRIEND) + .friend_state = ESP_BLE_MESH_FRIEND_ENABLED, +#else + .friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED, #endif .default_ttl = 7, - /* 3 transmissions with 20ms interval */ - .net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20), - .relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20), }; ESP_BLE_MESH_MODEL_PUB_DEFINE(onoff_pub_0, 2 + 3, ROLE_NODE); static esp_ble_mesh_gen_onoff_srv_t onoff_server_0 = { - .rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP, - .rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP, + .rsp_ctrl = { + .get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP, + .set_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP, + }, }; ESP_BLE_MESH_MODEL_PUB_DEFINE(onoff_pub_1, 2 + 3, ROLE_NODE); static esp_ble_mesh_gen_onoff_srv_t onoff_server_1 = { - .rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP, - .rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP, + .rsp_ctrl = { + .get_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP, + .set_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP, + }, }; ESP_BLE_MESH_MODEL_PUB_DEFINE(onoff_pub_2, 2 + 3, ROLE_NODE); static esp_ble_mesh_gen_onoff_srv_t onoff_server_2 = { - .rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP, - .rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP, + .rsp_ctrl = { + .get_auto_rsp = ESP_BLE_MESH_SERVER_AUTO_RSP, + .set_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP, + }, }; static esp_ble_mesh_model_t root_models[] = { @@ -91,8 +97,8 @@ static esp_ble_mesh_elem_t elements[] = { static esp_ble_mesh_comp_t composition = { .cid = CID_ESP, - .elements = elements, .element_count = ARRAY_SIZE(elements), + .elements = elements, }; /* Disable OOB security for SILabs Android app */ @@ -101,8 +107,8 @@ static esp_ble_mesh_prov_t provision = { #if 0 .output_size = 4, .output_actions = ESP_BLE_MESH_DISPLAY_NUMBER, - .input_actions = ESP_BLE_MESH_PUSH, .input_size = 4, + .input_actions = ESP_BLE_MESH_PUSH, #else .output_size = 0, .output_actions = 0, @@ -146,7 +152,7 @@ static void example_handle_gen_onoff_msg(esp_ble_mesh_model_t *model, esp_ble_mesh_msg_ctx_t *ctx, esp_ble_mesh_server_recv_gen_onoff_set_t *set) { - esp_ble_mesh_gen_onoff_srv_t *srv = model->user_data; + esp_ble_mesh_gen_onoff_srv_t *srv = (esp_ble_mesh_gen_onoff_srv_t *)model->user_data; switch (ctx->recv_op) { case ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_GET: @@ -227,7 +233,7 @@ static void example_ble_mesh_generic_server_cb(esp_ble_mesh_generic_server_cb_ev case ESP_BLE_MESH_GENERIC_SERVER_RECV_GET_MSG_EVT: ESP_LOGI(TAG, "ESP_BLE_MESH_GENERIC_SERVER_RECV_GET_MSG_EVT"); if (param->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_GET) { - srv = param->model->user_data; + srv = (esp_ble_mesh_gen_onoff_srv_t *)param->model->user_data; ESP_LOGI(TAG, "onoff 0x%02x", srv->state.onoff); example_handle_gen_onoff_msg(param->model, ¶m->ctx, NULL); } @@ -298,7 +304,7 @@ static esp_err_t ble_mesh_init(void) return err; } - err = esp_ble_mesh_node_prov_enable(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT); + err = esp_ble_mesh_node_prov_enable((esp_ble_mesh_prov_bearer_t)(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT)); if (err != ESP_OK) { ESP_LOGE(TAG, "Failed to enable mesh node (err %d)", err); return err; diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_provisioner/main/main.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_provisioner/main/main.c index e7581a2a40..0aaa9b2171 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_provisioner/main/main.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_provisioner/main/main.c @@ -51,13 +51,7 @@ typedef struct { uint8_t onoff; } esp_ble_mesh_node_info_t; -static esp_ble_mesh_node_info_t nodes[CONFIG_BLE_MESH_MAX_PROV_NODES] = { - [0 ... (CONFIG_BLE_MESH_MAX_PROV_NODES - 1)] = { - .unicast = ESP_BLE_MESH_ADDR_UNASSIGNED, - .elem_num = 0, - .onoff = LED_OFF, - } -}; +static esp_ble_mesh_node_info_t nodes[CONFIG_BLE_MESH_MAX_PROV_NODES] = {0}; static struct esp_ble_mesh_key { uint16_t net_idx; @@ -69,22 +63,22 @@ static esp_ble_mesh_client_t config_client; static esp_ble_mesh_client_t onoff_client; static esp_ble_mesh_cfg_srv_t config_server = { + /* 3 transmissions with 20ms interval */ + .net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20), .relay = ESP_BLE_MESH_RELAY_DISABLED, + .relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20), .beacon = ESP_BLE_MESH_BEACON_ENABLED, -#if defined(CONFIG_BLE_MESH_FRIEND) - .friend_state = ESP_BLE_MESH_FRIEND_ENABLED, -#else - .friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED, -#endif #if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER) .gatt_proxy = ESP_BLE_MESH_GATT_PROXY_ENABLED, #else .gatt_proxy = ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED, +#endif +#if defined(CONFIG_BLE_MESH_FRIEND) + .friend_state = ESP_BLE_MESH_FRIEND_ENABLED, +#else + .friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED, #endif .default_ttl = 7, - /* 3 transmissions with 20ms interval */ - .net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20), - .relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20), }; static esp_ble_mesh_model_t root_models[] = { @@ -99,8 +93,8 @@ static esp_ble_mesh_elem_t elements[] = { static esp_ble_mesh_comp_t composition = { .cid = CID_ESP, - .elements = elements, .element_count = ARRAY_SIZE(elements), + .elements = elements, }; static esp_ble_mesh_prov_t provision = { @@ -259,14 +253,14 @@ static void recv_unprov_adv_pkt(uint8_t dev_uuid[16], uint8_t addr[BD_ADDR_LEN], ESP_LOGI(TAG, "oob info: %d, bearer: %s", oob_info, (bearer & ESP_BLE_MESH_PROV_ADV) ? "PB-ADV" : "PB-GATT"); memcpy(add_dev.addr, addr, BD_ADDR_LEN); - add_dev.addr_type = (uint8_t)addr_type; + add_dev.addr_type = (esp_ble_mesh_addr_type_t)addr_type; memcpy(add_dev.uuid, dev_uuid, 16); add_dev.oob_info = oob_info; - add_dev.bearer = (uint8_t)bearer; + add_dev.bearer = (esp_ble_mesh_prov_bearer_t)bearer; /* Note: If unprovisioned device adv packets have not been received, we should not add device with ADD_DEV_START_PROV_NOW_FLAG set. */ err = esp_ble_mesh_provisioner_add_unprov_dev(&add_dev, - ADD_DEV_RM_AFTER_PROV_FLAG | ADD_DEV_START_PROV_NOW_FLAG | ADD_DEV_FLUSHABLE_DEV_FLAG); + (esp_ble_mesh_dev_add_flag_t)(ADD_DEV_RM_AFTER_PROV_FLAG | ADD_DEV_START_PROV_NOW_FLAG | ADD_DEV_FLUSHABLE_DEV_FLAG)); if (err) { ESP_LOGE(TAG, "%s: Add unprovisioned device into queue failed", __func__); } @@ -608,7 +602,7 @@ static esp_err_t ble_mesh_init(void) return err; } - err = esp_ble_mesh_provisioner_prov_enable(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT); + err = esp_ble_mesh_provisioner_prov_enable((esp_ble_mesh_prov_bearer_t)(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT)); if (err != ESP_OK) { ESP_LOGE(TAG, "Failed to enable mesh provisioner (err %d)", err); return err; diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_client/main/board.h b/examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_client/main/board.h index 79cc232d83..73420a3760 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_client/main/board.h +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_client/main/board.h @@ -10,6 +10,14 @@ #ifndef _BOARD_H_ #define _BOARD_H_ +#ifdef __cplusplus +extern "C" { +#endif /**< __cplusplus */ + void board_init(void); +#ifdef __cplusplus +} +#endif /**< __cplusplus */ + #endif /* _BOARD_H_ */ diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_client/main/main.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_client/main/main.c index b4c0e04b02..3e66ea72ea 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_client/main/main.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_client/main/main.c @@ -54,7 +54,10 @@ static struct esp_ble_mesh_key { } prov_key; static esp_ble_mesh_cfg_srv_t config_server = { + /* 3 transmissions with 20ms interval */ + .net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20), .relay = ESP_BLE_MESH_RELAY_DISABLED, + .relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20), .beacon = ESP_BLE_MESH_BEACON_DISABLED, #if defined(CONFIG_BLE_MESH_FRIEND) .friend_state = ESP_BLE_MESH_FRIEND_ENABLED, @@ -62,9 +65,6 @@ static esp_ble_mesh_cfg_srv_t config_server = { .friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED, #endif .default_ttl = 7, - /* 3 transmissions with 20ms interval */ - .net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20), - .relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20), }; static esp_ble_mesh_client_t config_client; @@ -82,8 +82,8 @@ static esp_ble_mesh_elem_t elements[] = { static esp_ble_mesh_comp_t composition = { .cid = CID_ESP, - .elements = elements, .element_count = ARRAY_SIZE(elements), + .elements = elements, }; static esp_ble_mesh_prov_t provision = { @@ -164,10 +164,10 @@ static void recv_unprov_adv_pkt(uint8_t dev_uuid[ESP_BLE_MESH_OCTET16_LEN], uint ESP_LOGI(TAG, "oob info 0x%04x, bearer %s", oob_info, (bearer & ESP_BLE_MESH_PROV_ADV) ? "PB-ADV" : "PB-GATT"); memcpy(add_dev.addr, addr, BD_ADDR_LEN); - add_dev.addr_type = (uint8_t)addr_type; + add_dev.addr_type = (esp_ble_mesh_addr_type_t)addr_type; memcpy(add_dev.uuid, dev_uuid, ESP_BLE_MESH_OCTET16_LEN); add_dev.oob_info = oob_info; - add_dev.bearer = (uint8_t)bearer; + add_dev.bearer = (esp_ble_mesh_prov_bearer_t)bearer; /* Note: If unprovisioned device adv packets have not been received, we should not add device with ADD_DEV_START_PROV_NOW_FLAG set. */ err = esp_ble_mesh_provisioner_add_unprov_dev(&add_dev, @@ -648,7 +648,7 @@ static esp_err_t ble_mesh_init(void) return err; } - err = esp_ble_mesh_provisioner_prov_enable(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT); + err = esp_ble_mesh_provisioner_prov_enable((esp_ble_mesh_prov_bearer_t)(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT)); if (err != ESP_OK) { ESP_LOGE(TAG, "Failed to enable mesh provisioner"); return err; diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_server/main/board.h b/examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_server/main/board.h index 1d9a56989b..26a4e93b5b 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_server/main/board.h +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_server/main/board.h @@ -10,6 +10,10 @@ #ifndef _BOARD_H_ #define _BOARD_H_ +#ifdef __cplusplus +extern "C" { +#endif /**< __cplusplus */ + #include "driver/gpio.h" #if defined(CONFIG_BLE_MESH_ESP_WROOM_32) @@ -44,4 +48,8 @@ void board_led_operation(uint8_t pin, uint8_t onoff); void board_init(void); -#endif +#ifdef __cplusplus +} +#endif /**< __cplusplus */ + +#endif /* _BOARD_H_ */ diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_server/main/main.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_server/main/main.c index efef461691..70b30136e2 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_server/main/main.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_sensor_model/sensor_server/main/main.c @@ -49,22 +49,22 @@ static int8_t outdoor_temp = 60; /* Outdoor temperature is 30 Degrees Celsius static uint8_t dev_uuid[ESP_BLE_MESH_OCTET16_LEN] = { 0x32, 0x10 }; static esp_ble_mesh_cfg_srv_t config_server = { + /* 3 transmissions with 20ms interval */ + .net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20), .relay = ESP_BLE_MESH_RELAY_ENABLED, + .relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20), .beacon = ESP_BLE_MESH_BEACON_ENABLED, -#if defined(CONFIG_BLE_MESH_FRIEND) - .friend_state = ESP_BLE_MESH_FRIEND_ENABLED, -#else - .friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED, -#endif #if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER) .gatt_proxy = ESP_BLE_MESH_GATT_PROXY_ENABLED, #else .gatt_proxy = ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED, +#endif +#if defined(CONFIG_BLE_MESH_FRIEND) + .friend_state = ESP_BLE_MESH_FRIEND_ENABLED, +#else + .friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED, #endif .default_ttl = 7, - /* 3 transmissions with 20ms interval */ - .net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20), - .relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20), }; NET_BUF_SIMPLE_DEFINE_STATIC(sensor_data_0, 1); @@ -89,41 +89,53 @@ static esp_ble_mesh_sensor_state_t sensor_states[2] = { * Sensor Descriptor state represents the attributes describing the sensor * data. This state does not change throughout the lifetime of an element. */ - .descriptor.positive_tolerance = SENSOR_POSITIVE_TOLERANCE, - .descriptor.negative_tolerance = SENSOR_NEGATIVE_TOLERANCE, - .descriptor.sampling_function = SENSOR_SAMPLE_FUNCTION, - .descriptor.measure_period = SENSOR_MEASURE_PERIOD, - .descriptor.update_interval = SENSOR_UPDATE_INTERVAL, - .sensor_data.format = ESP_BLE_MESH_SENSOR_DATA_FORMAT_A, - .sensor_data.length = 0, /* 0 represents the length is 1 */ - .sensor_data.raw_value = &sensor_data_0, + .descriptor = { + .positive_tolerance = SENSOR_POSITIVE_TOLERANCE, + .negative_tolerance = SENSOR_NEGATIVE_TOLERANCE, + .sampling_function = SENSOR_SAMPLE_FUNCTION, + .measure_period = SENSOR_MEASURE_PERIOD, + .update_interval = SENSOR_UPDATE_INTERVAL, + }, + .sensor_data = { + .format = ESP_BLE_MESH_SENSOR_DATA_FORMAT_A, + .length = 0, /* 0 represents the length is 1 */ + .raw_value = &sensor_data_0, + }, }, [1] = { .sensor_property_id = SENSOR_PROPERTY_ID_1, - .descriptor.positive_tolerance = SENSOR_POSITIVE_TOLERANCE, - .descriptor.negative_tolerance = SENSOR_NEGATIVE_TOLERANCE, - .descriptor.sampling_function = SENSOR_SAMPLE_FUNCTION, - .descriptor.measure_period = SENSOR_MEASURE_PERIOD, - .descriptor.update_interval = SENSOR_UPDATE_INTERVAL, - .sensor_data.format = ESP_BLE_MESH_SENSOR_DATA_FORMAT_A, - .sensor_data.length = 0, /* 0 represents the length is 1 */ - .sensor_data.raw_value = &sensor_data_1, + .descriptor = { + .positive_tolerance = SENSOR_POSITIVE_TOLERANCE, + .negative_tolerance = SENSOR_NEGATIVE_TOLERANCE, + .sampling_function = SENSOR_SAMPLE_FUNCTION, + .measure_period = SENSOR_MEASURE_PERIOD, + .update_interval = SENSOR_UPDATE_INTERVAL, + }, + .sensor_data = { + .format = ESP_BLE_MESH_SENSOR_DATA_FORMAT_A, + .length = 0, /* 0 represents the length is 1 */ + .raw_value = &sensor_data_1, + }, }, }; /* 20 octets is large enough to hold two Sensor Descriptor state values. */ ESP_BLE_MESH_MODEL_PUB_DEFINE(sensor_pub, 20, ROLE_NODE); static esp_ble_mesh_sensor_srv_t sensor_server = { - .rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP, - .rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP, + .rsp_ctrl = { + .get_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP, + .set_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP, + }, .state_count = ARRAY_SIZE(sensor_states), .states = sensor_states, }; ESP_BLE_MESH_MODEL_PUB_DEFINE(sensor_setup_pub, 20, ROLE_NODE); static esp_ble_mesh_sensor_setup_srv_t sensor_setup_server = { - .rsp_ctrl.get_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP, - .rsp_ctrl.set_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP, + .rsp_ctrl = { + .get_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP, + .set_auto_rsp = ESP_BLE_MESH_SERVER_RSP_BY_APP, + }, .state_count = ARRAY_SIZE(sensor_states), .states = sensor_states, }; @@ -140,8 +152,8 @@ static esp_ble_mesh_elem_t elements[] = { static esp_ble_mesh_comp_t composition = { .cid = CID_ESP, - .elements = elements, .element_count = ARRAY_SIZE(elements), + .elements = elements, }; static esp_ble_mesh_prov_t provision = { @@ -244,7 +256,7 @@ static void example_ble_mesh_send_sensor_descriptor_status(esp_ble_mesh_sensor_s esp_err_t err; int i; - status = calloc(1, ARRAY_SIZE(sensor_states) * ESP_BLE_MESH_SENSOR_DESCRIPTOR_LEN); + status = (uint8_t *)calloc(1, ARRAY_SIZE(sensor_states) * ESP_BLE_MESH_SENSOR_DESCRIPTOR_LEN); if (!status) { ESP_LOGE(TAG, "No memory for sensor descriptor status!"); return; @@ -427,7 +439,7 @@ static void example_ble_mesh_send_sensor_status(esp_ble_mesh_sensor_server_cb_pa } } - status = calloc(1, buf_size); + status = (uint8_t *)calloc(1, buf_size); if (!status) { ESP_LOGE(TAG, "No memory for sensor status!"); return; @@ -485,7 +497,7 @@ static void example_ble_mesh_send_sensor_column_status(esp_ble_mesh_sensor_serve length = ESP_BLE_MESH_SENSOR_PROPERTY_ID_LEN +param->value.get.sensor_column.raw_value_x->len; - status = calloc(1, length); + status = (uint8_t *)calloc(1, length); if (!status) { ESP_LOGE(TAG, "No memory for sensor column status!"); return; @@ -599,7 +611,7 @@ static esp_err_t ble_mesh_init(void) return err; } - err = esp_ble_mesh_node_prov_enable(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT); + err = esp_ble_mesh_node_prov_enable((esp_ble_mesh_prov_bearer_t)(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT)); if (err != ESP_OK) { ESP_LOGE(TAG, "Failed to enable mesh node"); return err; diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_client/main/board.h b/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_client/main/board.h index 79cc232d83..73420a3760 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_client/main/board.h +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_client/main/board.h @@ -10,6 +10,14 @@ #ifndef _BOARD_H_ #define _BOARD_H_ +#ifdef __cplusplus +extern "C" { +#endif /**< __cplusplus */ + void board_init(void); +#ifdef __cplusplus +} +#endif /**< __cplusplus */ + #endif /* _BOARD_H_ */ diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_client/main/main.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_client/main/main.c index 0d6d0b4b30..6bedb601ca 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_client/main/main.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_client/main/main.c @@ -71,7 +71,10 @@ static struct esp_ble_mesh_key { } prov_key; static esp_ble_mesh_cfg_srv_t config_server = { + /* 3 transmissions with 20ms interval */ + .net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20), .relay = ESP_BLE_MESH_RELAY_DISABLED, + .relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20), .beacon = ESP_BLE_MESH_BEACON_DISABLED, #if defined(CONFIG_BLE_MESH_FRIEND) .friend_state = ESP_BLE_MESH_FRIEND_ENABLED, @@ -79,9 +82,6 @@ static esp_ble_mesh_cfg_srv_t config_server = { .friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED, #endif .default_ttl = 7, - /* 3 transmissions with 20ms interval */ - .net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20), - .relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20), }; static esp_ble_mesh_client_t config_client; @@ -116,8 +116,8 @@ static esp_ble_mesh_elem_t elements[] = { static esp_ble_mesh_comp_t composition = { .cid = CID_ESP, - .elements = elements, .element_count = ARRAY_SIZE(elements), + .elements = elements, }; static esp_ble_mesh_prov_t provision = { @@ -219,10 +219,10 @@ static void recv_unprov_adv_pkt(uint8_t dev_uuid[ESP_BLE_MESH_OCTET16_LEN], uint ESP_LOGI(TAG, "oob info 0x%04x, bearer %s", oob_info, (bearer & ESP_BLE_MESH_PROV_ADV) ? "PB-ADV" : "PB-GATT"); memcpy(add_dev.addr, addr, BD_ADDR_LEN); - add_dev.addr_type = (uint8_t)addr_type; + add_dev.addr_type = (esp_ble_mesh_addr_type_t)addr_type; memcpy(add_dev.uuid, dev_uuid, ESP_BLE_MESH_OCTET16_LEN); add_dev.oob_info = oob_info; - add_dev.bearer = (uint8_t)bearer; + add_dev.bearer = (esp_ble_mesh_prov_bearer_t)bearer; /* Note: If unprovisioned device adv packets have not been received, we should not add device with ADD_DEV_START_PROV_NOW_FLAG set. */ err = esp_ble_mesh_provisioner_add_unprov_dev(&add_dev, @@ -542,7 +542,7 @@ static esp_err_t ble_mesh_init(void) return err; } - err = esp_ble_mesh_provisioner_prov_enable(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT); + err = esp_ble_mesh_provisioner_prov_enable((esp_ble_mesh_prov_bearer_t)(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT)); if (err != ESP_OK) { ESP_LOGE(TAG, "Failed to enable mesh provisioner"); return err; diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_server/main/board.h b/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_server/main/board.h index 1d9a56989b..26a4e93b5b 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_server/main/board.h +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_server/main/board.h @@ -10,6 +10,10 @@ #ifndef _BOARD_H_ #define _BOARD_H_ +#ifdef __cplusplus +extern "C" { +#endif /**< __cplusplus */ + #include "driver/gpio.h" #if defined(CONFIG_BLE_MESH_ESP_WROOM_32) @@ -44,4 +48,8 @@ void board_led_operation(uint8_t pin, uint8_t onoff); void board_init(void); -#endif +#ifdef __cplusplus +} +#endif /**< __cplusplus */ + +#endif /* _BOARD_H_ */ diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_server/main/main.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_server/main/main.c index b84f173f1b..3dde20b0ed 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_server/main/main.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_vendor_model/vendor_server/main/main.c @@ -38,22 +38,22 @@ static uint8_t dev_uuid[ESP_BLE_MESH_OCTET16_LEN] = { 0x32, 0x10 }; static esp_ble_mesh_cfg_srv_t config_server = { - .relay = ESP_BLE_MESH_RELAY_ENABLED, + /* 3 transmissions with 20ms interval */ + .net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20), + .relay = ESP_BLE_MESH_RELAY_DISABLED, + .relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20), .beacon = ESP_BLE_MESH_BEACON_ENABLED, -#if defined(CONFIG_BLE_MESH_FRIEND) - .friend_state = ESP_BLE_MESH_FRIEND_ENABLED, -#else - .friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED, -#endif #if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER) .gatt_proxy = ESP_BLE_MESH_GATT_PROXY_ENABLED, #else .gatt_proxy = ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED, +#endif +#if defined(CONFIG_BLE_MESH_FRIEND) + .friend_state = ESP_BLE_MESH_FRIEND_ENABLED, +#else + .friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED, #endif .default_ttl = 7, - /* 3 transmissions with 20ms interval */ - .net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20), - .relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20), }; static esp_ble_mesh_model_t root_models[] = { @@ -76,8 +76,8 @@ static esp_ble_mesh_elem_t elements[] = { static esp_ble_mesh_comp_t composition = { .cid = CID_ESP, - .elements = elements, .element_count = ARRAY_SIZE(elements), + .elements = elements, }; static esp_ble_mesh_prov_t provision = { @@ -193,7 +193,7 @@ static esp_err_t ble_mesh_init(void) return err; } - err = esp_ble_mesh_node_prov_enable(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT); + err = esp_ble_mesh_node_prov_enable((esp_ble_mesh_prov_bearer_t)(ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT)); if (err != ESP_OK) { ESP_LOGE(TAG, "Failed to enable mesh node"); return err; diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/main/main.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/main/main.c index c2630ccde4..b80445f52c 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/main/main.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/main/main.c @@ -61,22 +61,22 @@ esp_ble_mesh_client_t config_client; /* Configuration Server Model user_data */ esp_ble_mesh_cfg_srv_t config_server = { + /* 3 transmissions with 20ms interval */ + .net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20), .relay = ESP_BLE_MESH_RELAY_ENABLED, + .relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20), .beacon = ESP_BLE_MESH_BEACON_DISABLED, -#if defined(CONFIG_BLE_MESH_FRIEND) - .friend_state = ESP_BLE_MESH_FRIEND_ENABLED, -#else - .friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED, -#endif #if defined(CONFIG_BLE_MESH_GATT_PROXY_SERVER) .gatt_proxy = ESP_BLE_MESH_GATT_PROXY_ENABLED, #else .gatt_proxy = ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED, +#endif +#if defined(CONFIG_BLE_MESH_FRIEND) + .friend_state = ESP_BLE_MESH_FRIEND_ENABLED, +#else + .friend_state = ESP_BLE_MESH_FRIEND_NOT_SUPPORTED, #endif .default_ttl = 7, - /* 3 transmissions with 20ms interval */ - .net_transmit = ESP_BLE_MESH_TRANSMIT(2, 20), - .relay_retransmit = ESP_BLE_MESH_TRANSMIT(2, 20), }; /* Fast Prov Client Model user_data */ @@ -90,6 +90,7 @@ example_fast_prov_server_t fast_prov_server = { .primary_role = false, .max_node_num = 6, .prov_node_cnt = 0x0, + .app_idx = ESP_BLE_MESH_KEY_UNUSED, .unicast_min = ESP_BLE_MESH_ADDR_UNASSIGNED, .unicast_max = ESP_BLE_MESH_ADDR_UNASSIGNED, .unicast_cur = ESP_BLE_MESH_ADDR_UNASSIGNED, @@ -97,7 +98,6 @@ example_fast_prov_server_t fast_prov_server = { .flags = 0x0, .iv_index = 0x0, .net_idx = ESP_BLE_MESH_KEY_UNUSED, - .app_idx = ESP_BLE_MESH_KEY_UNUSED, .group_addr = ESP_BLE_MESH_ADDR_UNASSIGNED, .prim_prov_addr = ESP_BLE_MESH_ADDR_UNASSIGNED, .match_len = 0x0, @@ -321,9 +321,9 @@ static void example_recv_unprov_adv_pkt(uint8_t dev_uuid[16], uint8_t addr[BLE_M } } - add_dev.addr_type = (uint8_t)addr_type; + add_dev.addr_type = (esp_ble_mesh_addr_type_t)addr_type; add_dev.oob_info = oob_info; - add_dev.bearer = (uint8_t)bearer; + add_dev.bearer = (esp_ble_mesh_prov_bearer_t)bearer; memcpy(add_dev.uuid, dev_uuid, 16); memcpy(add_dev.addr, addr, BLE_MESH_ADDR_LEN); flag = ADD_DEV_RM_AFTER_PROV_FLAG | ADD_DEV_START_PROV_NOW_FLAG | ADD_DEV_FLUSHABLE_DEV_FLAG; @@ -464,8 +464,8 @@ static void example_ble_mesh_custom_model_cb(esp_ble_mesh_model_cb_event_t event case ESP_BLE_MESH_VND_MODEL_OP_FAST_PROV_NODE_GROUP_DELETE: { ESP_LOGI(TAG, "%s: Fast prov server receives msg, opcode 0x%04" PRIx32, __func__, opcode); struct net_buf_simple buf = { - .len = param->model_operation.length, .data = param->model_operation.msg, + .len = param->model_operation.length, }; err = example_fast_prov_server_recv_msg(param->model_operation.model, param->model_operation.ctx, &buf); diff --git a/examples/bluetooth/esp_ble_mesh/common_components/example_init/ble_mesh_example_init.h b/examples/bluetooth/esp_ble_mesh/common_components/example_init/ble_mesh_example_init.h index 499e2d5e72..b587b8b6a6 100644 --- a/examples/bluetooth/esp_ble_mesh/common_components/example_init/ble_mesh_example_init.h +++ b/examples/bluetooth/esp_ble_mesh/common_components/example_init/ble_mesh_example_init.h @@ -7,10 +7,18 @@ #ifndef _BLE_MESH_EXAMPLE_INIT_H_ #define _BLE_MESH_EXAMPLE_INIT_H_ +#ifdef __cplusplus +extern "C" { +#endif /**< __cplusplus */ + #include "esp_err.h" void ble_mesh_get_dev_uuid(uint8_t *dev_uuid); esp_err_t bluetooth_init(void); +#ifdef __cplusplus +} +#endif /**< __cplusplus */ + #endif /* _BLE_MESH_EXAMPLE_INIT_H_ */ diff --git a/examples/bluetooth/esp_ble_mesh/common_components/example_nvs/ble_mesh_example_nvs.h b/examples/bluetooth/esp_ble_mesh/common_components/example_nvs/ble_mesh_example_nvs.h index 9cd7d8b092..0e02745c65 100644 --- a/examples/bluetooth/esp_ble_mesh/common_components/example_nvs/ble_mesh_example_nvs.h +++ b/examples/bluetooth/esp_ble_mesh/common_components/example_nvs/ble_mesh_example_nvs.h @@ -7,6 +7,10 @@ #ifndef _BLE_MESH_EXAMPLE_NVS_H_ #define _BLE_MESH_EXAMPLE_NVS_H_ +#ifdef __cplusplus +extern "C" { +#endif /**< __cplusplus */ + #include #include "esp_err.h" #include "nvs_flash.h" @@ -21,4 +25,8 @@ esp_err_t ble_mesh_nvs_restore(nvs_handle_t handle, const char *key, void *data, esp_err_t ble_mesh_nvs_erase(nvs_handle_t handle, const char *key); +#ifdef __cplusplus +} +#endif /**< __cplusplus */ + #endif /* _BLE_MESH_EXAMPLE_NVS_H_ */ diff --git a/examples/bluetooth/esp_ble_mesh/common_components/fast_provisioning/ble_mesh_fast_prov_client_model.h b/examples/bluetooth/esp_ble_mesh/common_components/fast_provisioning/ble_mesh_fast_prov_client_model.h index 27d0eb79e1..2a0b30b0c3 100644 --- a/examples/bluetooth/esp_ble_mesh/common_components/fast_provisioning/ble_mesh_fast_prov_client_model.h +++ b/examples/bluetooth/esp_ble_mesh/common_components/fast_provisioning/ble_mesh_fast_prov_client_model.h @@ -7,6 +7,10 @@ #ifndef _BLE_MESH_FAST_PROV_CLIENT_MODEL_H_ #define _BLE_MESH_FAST_PROV_CLIENT_MODEL_H_ +#ifdef __cplusplus +extern "C" { +#endif + #include "esp_ble_mesh_defs.h" enum { @@ -25,4 +29,8 @@ esp_err_t example_fast_prov_client_recv_status(esp_ble_mesh_model_t *model, esp_ble_mesh_msg_ctx_t *ctx, uint16_t len, const uint8_t *data); +#ifdef __cplusplus +} +#endif + #endif /* _BLE_MESH_FAST_PROV_CLIENT_MODEL_H_ */ diff --git a/examples/bluetooth/esp_ble_mesh/common_components/fast_provisioning/ble_mesh_fast_prov_common.h b/examples/bluetooth/esp_ble_mesh/common_components/fast_provisioning/ble_mesh_fast_prov_common.h index 29391cff40..ce0a349ab9 100644 --- a/examples/bluetooth/esp_ble_mesh/common_components/fast_provisioning/ble_mesh_fast_prov_common.h +++ b/examples/bluetooth/esp_ble_mesh/common_components/fast_provisioning/ble_mesh_fast_prov_common.h @@ -7,6 +7,10 @@ #ifndef _BLE_MESH_FAST_PROV_COMMON_H_ #define _BLE_MESH_FAST_PROV_COMMON_H_ +#ifdef __cplusplus +extern "C" { +#endif + #include "esp_ble_mesh_defs.h" #include "esp_ble_mesh_config_model_api.h" @@ -109,4 +113,8 @@ typedef struct { uint8_t status_act; /* Indicate the result of action */ } example_fast_prov_net_key_status_t; +#ifdef __cplusplus +} +#endif + #endif /* _BLE_MESH_FAST_PROV_COMMON_H_ */ diff --git a/examples/bluetooth/esp_ble_mesh/common_components/fast_provisioning/ble_mesh_fast_prov_operation.h b/examples/bluetooth/esp_ble_mesh/common_components/fast_provisioning/ble_mesh_fast_prov_operation.h index dd5dc403c6..58236df466 100644 --- a/examples/bluetooth/esp_ble_mesh/common_components/fast_provisioning/ble_mesh_fast_prov_operation.h +++ b/examples/bluetooth/esp_ble_mesh/common_components/fast_provisioning/ble_mesh_fast_prov_operation.h @@ -7,6 +7,10 @@ #ifndef _BLE_MESH_FAST_PROV_OPERATION_H_ #define _BLE_MESH_FAST_PROV_OPERATION_H_ +#ifdef __cplusplus +extern "C" { +#endif + #include "ble_mesh_fast_prov_common.h" esp_err_t example_store_node_info(const uint8_t uuid[16], uint16_t node_addr, @@ -58,4 +62,8 @@ esp_err_t example_send_fast_prov_status_msg(esp_ble_mesh_model_t *model, esp_ble_mesh_msg_ctx_t *ctx, uint32_t opcode, struct net_buf_simple *msg); +#ifdef __cplusplus +} +#endif + #endif /* _BLE_MESH_FAST_PROV_OPERATION_H_ */ diff --git a/examples/bluetooth/esp_ble_mesh/common_components/fast_provisioning/ble_mesh_fast_prov_server_model.h b/examples/bluetooth/esp_ble_mesh/common_components/fast_provisioning/ble_mesh_fast_prov_server_model.h index 55d9480049..b7f855fb6e 100644 --- a/examples/bluetooth/esp_ble_mesh/common_components/fast_provisioning/ble_mesh_fast_prov_server_model.h +++ b/examples/bluetooth/esp_ble_mesh/common_components/fast_provisioning/ble_mesh_fast_prov_server_model.h @@ -7,6 +7,10 @@ #ifndef _BLE_MESH_FAST_PROV_SERVER_MODEL_H_ #define _BLE_MESH_FAST_PROV_SERVER_MODEL_H_ +#ifdef __cplusplus +extern "C" { +#endif + #include "ble_mesh_fast_prov_common.h" #define DISABLE_FAST_PROV_TIMEOUT K_SECONDS(10) @@ -91,4 +95,8 @@ esp_err_t example_handle_fast_prov_status_send_comp_evt(int err_code, uint32_t o esp_err_t example_fast_prov_server_init(esp_ble_mesh_model_t *model); +#ifdef __cplusplus +} +#endif + #endif /* _BLE_MESH_FAST_PROV_SERVER_MODEL_H_ */ diff --git a/examples/bluetooth/esp_ble_mesh/common_components/light_driver/iot_led.c b/examples/bluetooth/esp_ble_mesh/common_components/light_driver/iot_led.c deleted file mode 100644 index 428996ea3c..0000000000 --- a/examples/bluetooth/esp_ble_mesh/common_components/light_driver/iot_led.c +++ /dev/null @@ -1,477 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include -#include -#include -#include "soc/ledc_reg.h" -#include "soc/timer_group_struct.h" -#include "soc/ledc_struct.h" -#include "driver/gptimer.h" -#include "driver/ledc.h" -#include "esp_attr.h" -#include "iot_led.h" -#include "esp_log.h" - -#define LEDC_FADE_MARGIN (10) -#define LEDC_VALUE_TO_DUTY(value) (value * ((1 << LEDC_TIMER_13_BIT) - 1) / UINT16_MAX) -#define LEDC_DUTY_TO_VALUE(value) (value * UINT16_MAX / ((1 << LEDC_TIMER_13_BIT) - 1) ) -#define LEDC_FIXED_Q (8) -#define FLOATINT_2_FIXED(X, Q) ((int)((X)*(0x1U << Q))) -#define FIXED_2_FLOATING(X, Q) ((int)((X)/(0x1U << Q))) -#define GET_FIXED_INTEGER_PART(X, Q) (X >> Q) -#define GET_FIXED_DECIMAL_PART(X, Q) (X & ((0x1U << Q) - 1)) - -#define GPTIMER_RESOLUTION_HZ 1000000 // 1MHz, 1 tick=1us - -typedef struct { - int cur; - int final; - int step; - int cycle; - size_t num; -} ledc_fade_data_t; - -typedef struct { - ledc_fade_data_t fade_data[LEDC_CHANNEL_MAX]; - ledc_mode_t speed_mode; - ledc_timer_t timer_num; - gptimer_handle_t gptimer; -} iot_light_t; - -static const char *TAG = "iot_light"; -static DRAM_ATTR iot_light_t *g_light_config = NULL; -static DRAM_ATTR uint16_t *g_gamma_table = NULL; -static DRAM_ATTR bool g_hw_timer_started = false; - -static bool fade_timercb(gptimer_handle_t timer, const gptimer_alarm_event_data_t *edata, void *user_ctx); - -static void iot_timer_start(gptimer_handle_t gptimer) -{ - gptimer_alarm_config_t alarm_config = { - .reload_count = 0, - .alarm_count = DUTY_SET_CYCLE / 1000 * GPTIMER_RESOLUTION_HZ, - .flags.auto_reload_on_alarm = true, - }; - gptimer_set_alarm_action(gptimer, &alarm_config); - gptimer_start(gptimer); - g_hw_timer_started = true; -} - -static IRAM_ATTR void iot_timer_stop(gptimer_handle_t gptimer) -{ - gptimer_stop(gptimer); - g_hw_timer_started = false; -} - -static IRAM_ATTR esp_err_t iot_ledc_duty_config(ledc_mode_t speed_mode, ledc_channel_t channel, int hpoint_val, int duty_val, - uint32_t duty_direction, uint32_t duty_num, uint32_t duty_cycle, uint32_t duty_scale) -{ - if (hpoint_val >= 0) { -#if CONFIG_IDF_TARGET_ESP32C3 - LEDC.channel_group[speed_mode].channel[channel].hpoint.hpoint = hpoint_val & LEDC_HPOINT_LSCH1_V; -#elif CONFIG_IDF_TARGET_ESP32 - LEDC.channel_group[speed_mode].channel[channel].hpoint.hpoint = hpoint_val & LEDC_HPOINT_HSCH1_V; -#endif - } - - if (duty_val >= 0) { - LEDC.channel_group[speed_mode].channel[channel].duty.duty = duty_val; - } - -#if CONFIG_IDF_TARGET_ESP32C3 - LEDC.channel_group[speed_mode].channel[channel].conf1.val = ((duty_direction & LEDC_DUTY_INC_LSCH0_V) << LEDC_DUTY_INC_LSCH0_S) | - ((duty_num & LEDC_DUTY_NUM_LSCH0_V) << LEDC_DUTY_NUM_LSCH0_S) | - ((duty_cycle & LEDC_DUTY_CYCLE_LSCH0_V) << LEDC_DUTY_CYCLE_LSCH0_S) | - ((duty_scale & LEDC_DUTY_SCALE_LSCH0_V) << LEDC_DUTY_SCALE_LSCH0_S); -#elif CONFIG_IDF_TARGET_ESP32 - LEDC.channel_group[speed_mode].channel[channel].conf1.val = ((duty_direction & LEDC_DUTY_INC_HSCH0_V) << LEDC_DUTY_INC_HSCH0_S) | - ((duty_num & LEDC_DUTY_NUM_HSCH0_V) << LEDC_DUTY_NUM_HSCH0_S) | - ((duty_cycle & LEDC_DUTY_CYCLE_HSCH0_V) << LEDC_DUTY_CYCLE_HSCH0_S) | - ((duty_scale & LEDC_DUTY_SCALE_HSCH0_V) << LEDC_DUTY_SCALE_HSCH0_S); -#endif - - LEDC.channel_group[speed_mode].channel[channel].conf0.sig_out_en = 1; - LEDC.channel_group[speed_mode].channel[channel].conf1.duty_start = 1; - - if (speed_mode == LEDC_LOW_SPEED_MODE) { - LEDC.channel_group[speed_mode].channel[channel].conf0.low_speed_update = 1; - } - - return ESP_OK; -} - -static IRAM_ATTR esp_err_t _iot_set_fade_with_step(ledc_mode_t speed_mode, ledc_channel_t channel, uint32_t target_duty, int scale, int cycle_num) -{ - uint32_t duty_cur = LEDC.channel_group[speed_mode].channel[channel].duty_rd.duty_read >> 4; - int step_num = 0; - int dir = LEDC_DUTY_DIR_DECREASE; - - if (scale > 0) { - if (duty_cur > target_duty) { - step_num = (duty_cur - target_duty) / scale; - step_num = step_num > 1023 ? 1023 : step_num; - scale = (step_num == 1023) ? (duty_cur - target_duty) / step_num : scale; - } else { - dir = LEDC_DUTY_DIR_INCREASE; - step_num = (target_duty - duty_cur) / scale; - step_num = step_num > 1023 ? 1023 : step_num; - scale = (step_num == 1023) ? (target_duty - duty_cur) / step_num : scale; - } - } - - if (scale > 0 && step_num > 0) { - iot_ledc_duty_config(speed_mode, channel, -1, duty_cur << 4, dir, step_num, cycle_num, scale); - } else { - iot_ledc_duty_config(speed_mode, channel, -1, target_duty << 4, dir, 0, 1, 0); - } - - return ESP_OK; -} - -static IRAM_ATTR esp_err_t _iot_set_fade_with_time(ledc_mode_t speed_mode, ledc_channel_t channel, uint32_t target_duty, int max_fade_time_ms) -{ - uint32_t freq = 0; - uint32_t duty_cur = LEDC.channel_group[speed_mode].channel[channel].duty_rd.duty_read >> 4; - uint32_t duty_delta = target_duty > duty_cur ? target_duty - duty_cur : duty_cur - target_duty; - - uint32_t timer_source_clk = LEDC.timer_group[speed_mode].timer[g_light_config->timer_num].conf.tick_sel; - uint32_t duty_resolution = LEDC.timer_group[speed_mode].timer[g_light_config->timer_num].conf.duty_resolution; - uint32_t clock_divider = LEDC.timer_group[speed_mode].timer[g_light_config->timer_num].conf.clock_divider; - uint32_t precision = (0x1U << duty_resolution); - - if (timer_source_clk == LEDC_APB_CLK) { - freq = ((uint64_t)APB_CLK_FREQ << 8) / precision / clock_divider; - } else { - freq = ((uint64_t)REF_CLK_FREQ << 8) / precision / clock_divider; - } - - if (duty_delta == 0) { - return _iot_set_fade_with_step(speed_mode, channel, target_duty, 0, 0); - } - - int total_cycles = max_fade_time_ms * freq / 1000; - - if (total_cycles == 0) { - return _iot_set_fade_with_step(speed_mode, channel, target_duty, 0, 0); - } - - int scale, cycle_num; - - if (total_cycles > duty_delta) { - scale = 1; - cycle_num = total_cycles / duty_delta; - -#if CONFIG_IDF_TARGET_ESP32C3 - if (cycle_num > LEDC_DUTY_NUM_LSCH0_V) { - cycle_num = LEDC_DUTY_NUM_LSCH0_V; - } -#elif CONFIG_IDF_TARGET_ESP32 - if (cycle_num > LEDC_DUTY_NUM_HSCH0_V) { - cycle_num = LEDC_DUTY_NUM_HSCH0_V; - } -#endif - } else { - cycle_num = 1; - scale = duty_delta / total_cycles; - -#if CONFIG_IDF_TARGET_ESP32C3 - if (scale > LEDC_DUTY_SCALE_LSCH0_V) { - scale = LEDC_DUTY_SCALE_LSCH0_V; - } -#elif CONFIG_IDF_TARGET_ESP32 - if (scale > LEDC_DUTY_SCALE_HSCH0_V) { - scale = LEDC_DUTY_SCALE_HSCH0_V; - } -#endif - } - - return _iot_set_fade_with_step(speed_mode, channel, target_duty, scale, cycle_num); -} - -static IRAM_ATTR esp_err_t _iot_update_duty(ledc_mode_t speed_mode, ledc_channel_t channel) -{ - LEDC.channel_group[speed_mode].channel[channel].conf0.sig_out_en = 1; - LEDC.channel_group[speed_mode].channel[channel].conf1.duty_start = 1; - - if (speed_mode == LEDC_LOW_SPEED_MODE) { - LEDC.channel_group[speed_mode].channel[channel].conf0.low_speed_update = 1; - } - - return ESP_OK; -} - -static IRAM_ATTR esp_err_t iot_ledc_set_duty(ledc_mode_t speed_mode, ledc_channel_t channel, uint32_t duty) -{ - return iot_ledc_duty_config(speed_mode, - channel, // uint32_t chan_num, - -1, - duty << 4, // uint32_t duty_val,the least 4 bits are decimal part - 1, // uint32_t increase, - 1, // uint32_t duty_num, - 1, // uint32_t duty_cycle, - 0 // uint32_t duty_scale - ); -} - -static void gamma_table_create(uint16_t *gamma_table, float correction) -{ - float value_tmp = 0; - - /** - * @brief gamma curve formula: y=a*x^(1/gm) - * x ∈ (0,(GAMMA_TABLE_SIZE-1)/GAMMA_TABLE_SIZE) - * a = GAMMA_TABLE_SIZE - */ - for (int i = 0; i < GAMMA_TABLE_SIZE; i++) { - value_tmp = (float)(i) / GAMMA_TABLE_SIZE; - value_tmp = powf(value_tmp, 1.0f / correction); - gamma_table[i] = (uint16_t)FLOATINT_2_FIXED((value_tmp * GAMMA_TABLE_SIZE), LEDC_FIXED_Q); - } -} - -static IRAM_ATTR uint32_t gamma_value_to_duty(int value) -{ - uint32_t tmp_q = GET_FIXED_INTEGER_PART(value, LEDC_FIXED_Q); - uint32_t tmp_r = GET_FIXED_DECIMAL_PART(value, LEDC_FIXED_Q); - - uint16_t cur = LEDC_VALUE_TO_DUTY(g_gamma_table[tmp_q]); - uint16_t next = LEDC_VALUE_TO_DUTY(g_gamma_table[tmp_q + 1]); - return (cur + (next - cur) * tmp_r / (0x1U << LEDC_FIXED_Q)); -} - -static IRAM_ATTR bool fade_timercb(gptimer_handle_t timer, const gptimer_alarm_event_data_t *edata, void *user_ctx) -{ - int idle_channel_num = 0; - - for (int channel = 0; channel < LEDC_CHANNEL_MAX; channel++) { - ledc_fade_data_t *fade_data = g_light_config->fade_data + channel; - - if (fade_data->num > 0) { - fade_data->num--; - - if (fade_data->step) { - fade_data->cur += fade_data->step; - - if (fade_data->num != 0) { - _iot_set_fade_with_time(g_light_config->speed_mode, channel, - gamma_value_to_duty(fade_data->cur), - DUTY_SET_CYCLE - LEDC_FADE_MARGIN); - } else { - iot_ledc_set_duty(g_light_config->speed_mode, channel, gamma_value_to_duty(fade_data->cur)); - } - - _iot_update_duty(g_light_config->speed_mode, channel); - } else { - iot_ledc_set_duty(g_light_config->speed_mode, channel, gamma_value_to_duty(fade_data->cur)); - _iot_update_duty(g_light_config->speed_mode, channel); - } - } else if (fade_data->cycle) { - fade_data->num = fade_data->cycle - 1; - - if (fade_data->step) { - fade_data->step *= -1; - fade_data->cur += fade_data->step; - } else { - fade_data->cur = (fade_data->cur == fade_data->final) ? 0 : fade_data->final; - } - - _iot_set_fade_with_time(g_light_config->speed_mode, channel, - gamma_value_to_duty(fade_data->cur), - DUTY_SET_CYCLE - LEDC_FADE_MARGIN); - _iot_update_duty(g_light_config->speed_mode, channel); - - } else { - idle_channel_num++; - } - } - - if (idle_channel_num >= LEDC_CHANNEL_MAX) { - iot_timer_stop(timer); - } - - return false; -} - -esp_err_t iot_led_init(ledc_timer_t timer_num, ledc_mode_t speed_mode, uint32_t freq_hz) -{ - esp_err_t ret = ESP_OK; - const ledc_timer_config_t ledc_time_config = { - .speed_mode = speed_mode, - .timer_num = timer_num, - .freq_hz = freq_hz, - .duty_resolution = LEDC_TIMER_13_BIT, - }; - - ret = ledc_timer_config(&ledc_time_config); - if (ret != ESP_OK) { - ESP_LOGW(TAG, "LEDC timer configuration"); - return ret; - } - - if (g_gamma_table == NULL) { - g_gamma_table = calloc(GAMMA_TABLE_SIZE, sizeof(uint16_t)); - gamma_table_create(g_gamma_table, GAMMA_CORRECTION); - } else { - ESP_LOGE(TAG, "gamma_table has been initialized"); - } - - if (g_light_config == NULL) { - g_light_config = calloc(1, sizeof(iot_light_t)); - g_light_config->timer_num = timer_num; - g_light_config->speed_mode = speed_mode; - - gptimer_config_t timer_config = { - .clk_src = GPTIMER_CLK_SRC_DEFAULT, - .direction = GPTIMER_COUNT_UP, - .resolution_hz = GPTIMER_RESOLUTION_HZ, - }; - ESP_ERROR_CHECK(gptimer_new_timer(&timer_config, &g_light_config->gptimer)); - gptimer_event_callbacks_t cbs = { - .on_alarm = fade_timercb, - }; - ESP_ERROR_CHECK(gptimer_register_event_callbacks(g_light_config->gptimer, &cbs, NULL)); - ESP_ERROR_CHECK(gptimer_enable(g_light_config->gptimer)); - } else { - ESP_LOGE(TAG, "g_light_config has been initialized"); - } - - return ESP_OK; -} - -esp_err_t iot_led_deinit(void) -{ - if (g_gamma_table) { - free(g_gamma_table); - } - - if (g_light_config) { - gptimer_disable(g_light_config->gptimer); - gptimer_del_timer(g_light_config->gptimer); - free(g_light_config); - } - - return ESP_OK; -} - -esp_err_t iot_led_regist_channel(ledc_channel_t channel, gpio_num_t gpio_num) -{ - esp_err_t ret = ESP_OK; - if (g_light_config == NULL) { - ESP_LOGW(TAG, "iot_led_init() must be called first"); - return ESP_ERR_NOT_FOUND; - } -#ifdef CONFIG_SPIRAM_SUPPORT - if (gpio_num != GPIO_NUM_16 || gpio_num != GPIO_NUM_17) { - ESP_LOGW(TAG, "gpio_num must not conflict to PSRAM(IO16 && IO17)"); - return ESP_ERR_INVALID_ARG; - } -#endif - const ledc_channel_config_t ledc_ch_config = { - .gpio_num = gpio_num, - .channel = channel, - .intr_type = LEDC_INTR_DISABLE, - .speed_mode = g_light_config->speed_mode, - .timer_sel = g_light_config->timer_num, - }; - - ret = ledc_channel_config(&ledc_ch_config); - if (ret != ESP_OK) { - ESP_LOGW(TAG, "LEDC channel configuration"); - return ret; - } - - return ESP_OK; -} - -esp_err_t iot_led_get_channel(ledc_channel_t channel, uint8_t *dst) -{ - if (g_light_config == NULL || dst == NULL) { - ESP_LOGW(TAG, "iot_led_init() must be called first or dst should not be NULL"); - return ESP_ERR_INVALID_ARG; - } - int cur = g_light_config->fade_data[channel].cur; - *dst = FIXED_2_FLOATING(cur, LEDC_FIXED_Q); - return ESP_OK; -} - -esp_err_t iot_led_set_channel(ledc_channel_t channel, uint8_t value, uint32_t fade_ms) -{ - if (g_light_config == NULL) { - ESP_LOGW(TAG, "iot_led_init() must be called first"); - return ESP_ERR_INVALID_ARG; - } - ledc_fade_data_t *fade_data = g_light_config->fade_data + channel; - - fade_data->final = FLOATINT_2_FIXED(value, LEDC_FIXED_Q); - - if (fade_ms < DUTY_SET_CYCLE) { - fade_data->num = 1; - } else { - fade_data->num = fade_ms / DUTY_SET_CYCLE; - } - - fade_data->step = abs(fade_data->cur - fade_data->final) / fade_data->num; - - if (fade_data->cur > fade_data->final) { - fade_data->step *= -1; - } - - if (fade_data->cycle != 0) { - fade_data->cycle = 0; - } - - if (g_hw_timer_started != true) { - iot_timer_start(g_light_config->gptimer); - } - - return ESP_OK; -} - -esp_err_t iot_led_start_blink(ledc_channel_t channel, uint8_t value, uint32_t period_ms, bool fade_flag) -{ - if (g_light_config == NULL) { - ESP_LOGW(TAG, "iot_led_init() must be called first"); - return ESP_ERR_INVALID_ARG; - } - ledc_fade_data_t *fade_data = g_light_config->fade_data + channel; - - fade_data->final = fade_data->cur = FLOATINT_2_FIXED(value, LEDC_FIXED_Q); - fade_data->cycle = period_ms / 2 / DUTY_SET_CYCLE; - fade_data->num = (fade_flag) ? period_ms / 2 / DUTY_SET_CYCLE : 0; - fade_data->step = (fade_flag) ? fade_data->cur / fade_data->num * -1 : 0; - - if (g_hw_timer_started != true) { - iot_timer_start(g_light_config->gptimer); - } - - return ESP_OK; - -} - -esp_err_t iot_led_stop_blink(ledc_channel_t channel) -{ - if (g_light_config == NULL) { - ESP_LOGW(TAG, "iot_led_init() must be called first"); - return ESP_ERR_INVALID_ARG; - } - ledc_fade_data_t *fade_data = g_light_config->fade_data + channel; - fade_data->cycle = fade_data->num = 0; - - return ESP_OK; -} - -esp_err_t iot_led_set_gamma_table(const uint16_t gamma_table[GAMMA_TABLE_SIZE]) -{ - if (g_gamma_table == NULL) { - ESP_LOGW(TAG, "iot_led_init() must be called first"); - return ESP_ERR_INVALID_ARG; - } - memcpy(g_gamma_table, gamma_table, GAMMA_TABLE_SIZE * sizeof(uint16_t)); - return ESP_OK; -}