diff --git a/components/bt/CMakeLists.txt b/components/bt/CMakeLists.txt index 36d985d0d..ed65333c9 100644 --- a/components/bt/CMakeLists.txt +++ b/components/bt/CMakeLists.txt @@ -298,9 +298,10 @@ if(CONFIG_BT_ENABLED) if(CONFIG_BLE_MESH) list(APPEND include_dirs + "esp_ble_mesh/mesh_common/include" "esp_ble_mesh/mesh_core" "esp_ble_mesh/mesh_core/include" - "esp_ble_mesh/mesh_core/settings" + "esp_ble_mesh/mesh_core/storage" "esp_ble_mesh/btc/include" "esp_ble_mesh/mesh_models/common/include" "esp_ble_mesh/mesh_models/client/include" @@ -328,7 +329,13 @@ if(CONFIG_BT_ENABLED) "esp_ble_mesh/btc/btc_ble_mesh_prov.c" "esp_ble_mesh/btc/btc_ble_mesh_sensor_model.c" "esp_ble_mesh/btc/btc_ble_mesh_time_scene_model.c" - "esp_ble_mesh/mesh_core/settings/settings_nvs.c" + "esp_ble_mesh/mesh_common/mesh_aes_encrypt.c" + "esp_ble_mesh/mesh_common/mesh_atomic.c" + "esp_ble_mesh/mesh_common/mesh_buf.c" + "esp_ble_mesh/mesh_common/mesh_common.c" + "esp_ble_mesh/mesh_common/mesh_kernel.c" + "esp_ble_mesh/mesh_common/mesh_util.c" + "esp_ble_mesh/mesh_core/storage/settings_nvs.c" "esp_ble_mesh/mesh_core/access.c" "esp_ble_mesh/mesh_core/adv.c" "esp_ble_mesh/mesh_core/beacon.c" @@ -339,12 +346,7 @@ if(CONFIG_BT_ENABLED) "esp_ble_mesh/mesh_core/health_cli.c" "esp_ble_mesh/mesh_core/health_srv.c" "esp_ble_mesh/mesh_core/lpn.c" - "esp_ble_mesh/mesh_core/mesh_aes_encrypt.c" - "esp_ble_mesh/mesh_core/mesh_atomic.c" - "esp_ble_mesh/mesh_core/mesh_buf.c" - "esp_ble_mesh/mesh_core/mesh_kernel.c" - "esp_ble_mesh/mesh_core/mesh_main.c" - "esp_ble_mesh/mesh_core/mesh_util.c" + "esp_ble_mesh/mesh_core/main.c" "esp_ble_mesh/mesh_core/net.c" "esp_ble_mesh/mesh_core/prov.c" "esp_ble_mesh/mesh_core/provisioner_beacon.c" @@ -355,7 +357,6 @@ if(CONFIG_BT_ENABLED) "esp_ble_mesh/mesh_core/settings.c" "esp_ble_mesh/mesh_core/test.c" "esp_ble_mesh/mesh_core/transport.c" - "esp_ble_mesh/mesh_models/common/mesh_common.c" "esp_ble_mesh/mesh_models/client/client_common.c" "esp_ble_mesh/mesh_models/client/generic_client.c" "esp_ble_mesh/mesh_models/client/lighting_client.c" diff --git a/components/bt/component.mk b/components/bt/component.mk index 7472572ff..7d716f6d4 100644 --- a/components/bt/component.mk +++ b/components/bt/component.mk @@ -137,9 +137,10 @@ endif endif ifdef CONFIG_BLE_MESH -COMPONENT_ADD_INCLUDEDIRS += esp_ble_mesh/mesh_core \ +COMPONENT_ADD_INCLUDEDIRS += esp_ble_mesh/mesh_common/include \ + esp_ble_mesh/mesh_core \ esp_ble_mesh/mesh_core/include \ - esp_ble_mesh/mesh_core/settings \ + esp_ble_mesh/mesh_core/storage \ esp_ble_mesh/btc/include \ esp_ble_mesh/mesh_models/common/include \ esp_ble_mesh/mesh_models/client/include \ @@ -148,10 +149,10 @@ COMPONENT_ADD_INCLUDEDIRS += esp_ble_mesh/mesh_core \ esp_ble_mesh/api/models/include \ esp_ble_mesh/api -COMPONENT_SRCDIRS += esp_ble_mesh/mesh_core \ - esp_ble_mesh/mesh_core/settings \ +COMPONENT_SRCDIRS += esp_ble_mesh/mesh_common \ + esp_ble_mesh/mesh_core \ + esp_ble_mesh/mesh_core/storage \ esp_ble_mesh/btc \ - esp_ble_mesh/mesh_models/common \ esp_ble_mesh/mesh_models/client \ esp_ble_mesh/mesh_models/server \ esp_ble_mesh/api/core \ diff --git a/components/bt/esp_ble_mesh/Kconfig.in b/components/bt/esp_ble_mesh/Kconfig.in index f1770e473..44d7fec6b 100644 --- a/components/bt/esp_ble_mesh/Kconfig.in +++ b/components/bt/esp_ble_mesh/Kconfig.in @@ -60,7 +60,7 @@ if BLE_MESH config BLE_MESH_MAX_STORED_NODES int "Maximum number of nodes whose information can be stored" default 20 - range 1 1000 + range BLE_MESH_MAX_PROV_NODES 1000 help This option specifies the maximum number of nodes whose information can be stored by a Provisioner in its upper layer. @@ -71,7 +71,7 @@ if BLE_MESH config BLE_MESH_MAX_PROV_NODES int "Maximum number of devices that can be provisioned by Provisioner" default 20 - range 1 100 + range 1 1000 help This option specifies how many devices can be provisioned by a Provisioner. This value indicates the maximum number of unprovisioned devices which can be @@ -161,8 +161,8 @@ if BLE_MESH config BLE_MESH_GATT_PROXY_SERVER bool "BLE Mesh GATT Proxy Server" select BLE_MESH_PROXY - default y if BLE_MESH_NODE - default n if BLE_MESH_PROVISIONER + depends on BLE_MESH_NODE + default y help This option enables support for Mesh GATT Proxy Service, i.e. the ability to act as a proxy between a Mesh GATT Client and a Mesh network. @@ -427,6 +427,8 @@ if BLE_MESH config BLE_MESH_RELAY bool "Relay support" + depends on BLE_MESH_NODE + default y help Support for acting as a Mesh Relay Node. Enabling this option will allow a node to support the Relay feature, and the Relay feature can still @@ -457,7 +459,7 @@ if BLE_MESH config BLE_MESH_LOW_POWER bool "Support for Low Power features" - select BLE_MESH_NODE + depends on BLE_MESH_NODE help Enable this option to operate as a Low Power Node. If low power consumption is required by a node, this option should be enabled. And once the node @@ -581,7 +583,7 @@ if BLE_MESH config BLE_MESH_LPN_GROUPS int "Number of groups the LPN can subscribe to" range 0 16384 - default 2 + default 8 help Maximum number of groups to which the LPN can subscribe. @@ -589,7 +591,7 @@ if BLE_MESH config BLE_MESH_FRIEND bool "Support for acting as a Friend Node" - select BLE_MESH_NODE + depends on BLE_MESH_NODE help Enable this option to be able to act as a Friend Node. @@ -724,16 +726,6 @@ if BLE_MESH endmenu #BLE Mesh NET BUF DEBUG LOG LEVEL - config BLE_MESH_IRQ_LOCK - bool "Used the IRQ lock instead of task lock" - help - To improve the real-time requirements of bt controller in BLE Mesh, - task lock is used to replace IRQ lock. - With this option enabled, interrupt lock instead of the mutex will - be used and the BLE Mesh stack will try to change interrupt level to - protect some critical situations. Users need to ensure that this option - is disabled so mutex will be used in the bottom layer. - config BLE_MESH_CLIENT_MSG_TIMEOUT int "Timeout(ms) for client message response" range 100 1200000 diff --git a/components/bt/esp_ble_mesh/api/core/esp_ble_mesh_networking_api.c b/components/bt/esp_ble_mesh/api/core/esp_ble_mesh_networking_api.c index e17d8ac00..2878a35de 100644 --- a/components/bt/esp_ble_mesh/api/core/esp_ble_mesh_networking_api.c +++ b/components/bt/esp_ble_mesh/api/core/esp_ble_mesh_networking_api.c @@ -26,12 +26,12 @@ #define ESP_BLE_MESH_TX_SDU_MAX ((CONFIG_BLE_MESH_ADV_BUF_COUNT - 3) * 12) static esp_err_t ble_mesh_model_send_msg(esp_ble_mesh_model_t *model, - esp_ble_mesh_msg_ctx_t *ctx, - uint32_t opcode, - btc_ble_mesh_model_act_t act, - uint16_t length, uint8_t *data, - int32_t msg_timeout, bool need_rsp, - esp_ble_mesh_dev_role_t device_role) + esp_ble_mesh_msg_ctx_t *ctx, + uint32_t opcode, + btc_ble_mesh_model_act_t act, + uint16_t length, uint8_t *data, + int32_t msg_timeout, bool need_rsp, + esp_ble_mesh_dev_role_t device_role) { btc_ble_mesh_model_args_t arg = {0}; uint8_t op_len = 0, mic_len = 0; @@ -41,7 +41,13 @@ static esp_err_t ble_mesh_model_send_msg(esp_ble_mesh_model_t *model, ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED); + if (ctx && ctx->addr == ESP_BLE_MESH_ADDR_UNASSIGNED) { + LOG_ERROR("%s, Invalid destination address 0x0000", __func__); + return ESP_ERR_INVALID_ARG; + } + if (device_role > ROLE_FAST_PROV) { + LOG_ERROR("%s, Invalid device role 0x%02x", __func__, device_role); return ESP_ERR_INVALID_ARG; } @@ -214,7 +220,7 @@ esp_err_t esp_ble_mesh_server_model_update_state(esp_ble_mesh_model_t *model, msg.act = BTC_BLE_MESH_ACT_SERVER_MODEL_UPDATE_STATE; return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_model_args_t), btc_ble_mesh_model_arg_deep_copy) - == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); + == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); } esp_err_t esp_ble_mesh_node_local_reset(void) diff --git a/components/bt/esp_ble_mesh/api/core/esp_ble_mesh_provisioning_api.c b/components/bt/esp_ble_mesh/api/core/esp_ble_mesh_provisioning_api.c index b9501eb49..80f96ed05 100644 --- a/components/bt/esp_ble_mesh/api/core/esp_ble_mesh_provisioning_api.c +++ b/components/bt/esp_ble_mesh/api/core/esp_ble_mesh_provisioning_api.c @@ -70,7 +70,7 @@ esp_err_t esp_ble_mesh_node_prov_disable(esp_ble_mesh_prov_bearer_t bearers) } esp_err_t esp_ble_mesh_node_set_oob_pub_key(uint8_t pub_key_x[32], uint8_t pub_key_y[32], - uint8_t private_key[32]) + uint8_t private_key[32]) { btc_ble_mesh_prov_args_t arg = {0}; btc_msg_t msg = {0}; @@ -157,7 +157,7 @@ esp_err_t esp_ble_mesh_set_unprovisioned_device_name(const char *name) #if (CONFIG_BLE_MESH_PROVISIONER) esp_err_t esp_ble_mesh_provisioner_read_oob_pub_key(uint8_t link_idx, uint8_t pub_key_x[32], - uint8_t pub_key_y[32]) + uint8_t pub_key_y[32]) { btc_ble_mesh_prov_args_t arg = {0}; btc_msg_t msg = {0}; diff --git a/components/bt/esp_ble_mesh/api/core/esp_ble_mesh_proxy_api.c b/components/bt/esp_ble_mesh/api/core/esp_ble_mesh_proxy_api.c index 5c39841a3..b64f789f0 100644 --- a/components/bt/esp_ble_mesh/api/core/esp_ble_mesh_proxy_api.c +++ b/components/bt/esp_ble_mesh/api/core/esp_ble_mesh_proxy_api.c @@ -62,7 +62,7 @@ esp_err_t esp_ble_mesh_proxy_gatt_disable(void) } esp_err_t esp_ble_mesh_proxy_client_connect(esp_ble_mesh_bd_addr_t addr, - esp_ble_mesh_addr_type_t addr_type, uint16_t net_idx) + esp_ble_mesh_addr_type_t addr_type, uint16_t net_idx) { btc_ble_mesh_prov_args_t arg = {0}; btc_msg_t msg = {0}; @@ -103,12 +103,12 @@ esp_err_t esp_ble_mesh_proxy_client_disconnect(uint8_t conn_handle) } esp_err_t esp_ble_mesh_proxy_client_set_filter_type(uint8_t conn_handle, - uint16_t net_idx, uint8_t filter_type) + uint16_t net_idx, esp_ble_mesh_proxy_filter_type_t filter_type) { btc_ble_mesh_prov_args_t arg = {0}; btc_msg_t msg = {0}; - if (filter_type > 0x01) { + if (filter_type > PROXY_FILTER_BLACKLIST) { return ESP_ERR_INVALID_ARG; } @@ -127,7 +127,7 @@ esp_err_t esp_ble_mesh_proxy_client_set_filter_type(uint8_t conn_handle, } esp_err_t esp_ble_mesh_proxy_client_add_filter_addr(uint8_t conn_handle, - uint16_t net_idx, uint16_t *addr, uint16_t addr_num) + uint16_t net_idx, uint16_t *addr, uint16_t addr_num) { btc_ble_mesh_prov_args_t arg = {0}; btc_msg_t msg = {0}; @@ -152,7 +152,7 @@ esp_err_t esp_ble_mesh_proxy_client_add_filter_addr(uint8_t conn_handle, } esp_err_t esp_ble_mesh_proxy_client_remove_filter_addr(uint8_t conn_handle, - uint16_t net_idx, uint16_t *addr, uint16_t addr_num) + uint16_t net_idx, uint16_t *addr, uint16_t addr_num) { btc_ble_mesh_prov_args_t arg = {0}; btc_msg_t msg = {0}; diff --git a/components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_low_power_api.h b/components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_low_power_api.h index 60957b6e6..c579b2e05 100644 --- a/components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_low_power_api.h +++ b/components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_low_power_api.h @@ -44,7 +44,14 @@ esp_err_t esp_ble_mesh_lpn_disable(bool force); /** * @brief LPN tries to poll messages from the Friend Node. * - * @note Once called, Friend Poll will be sent to the Friend Node. + * @note The Friend Poll message is sent by a Low Power node to ask the Friend + * node to send a message that it has stored for the Low Power node. + * Users can call this API to send Friend Poll message manually. If this + * API is not invoked, the bottom layer of the Low Power node will send + * Friend Poll before the PollTimeout timer expires. + * If the corresponding Friend Update is received and MD is set to 0, + * which means there are no messages for the Low Power node, then the + * Low Power node will stop scanning. * * @return ESP_OK on success or error code otherwise. * diff --git a/components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_networking_api.h b/components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_networking_api.h index 5b351ba65..ecf160d5d 100644 --- a/components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_networking_api.h +++ b/components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_networking_api.h @@ -138,7 +138,7 @@ esp_err_t esp_ble_mesh_model_publish(esp_ble_mesh_model_t *model, uint32_t opcod * @brief Update a server model state value. If the model publication * state is set properly (e.g. publish address is set to a valid * address), it will publish corresponding status message. - * + * * @note Currently this API is used to update bound state value, not * for all server model states. * diff --git a/components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_provisioning_api.h b/components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_provisioning_api.h index b947ac664..34dc38ce7 100644 --- a/components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_provisioning_api.h +++ b/components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_provisioning_api.h @@ -72,7 +72,7 @@ esp_err_t esp_ble_mesh_node_prov_disable(esp_ble_mesh_prov_bearer_t bearers); * @return ESP_OK on success or error code otherwise. */ esp_err_t esp_ble_mesh_node_set_oob_pub_key(uint8_t pub_key_x[32], uint8_t pub_key_y[32], - uint8_t private_key[32]); + uint8_t private_key[32]); /** * @brief Provide provisioning input OOB number. @@ -124,7 +124,7 @@ esp_err_t esp_ble_mesh_set_unprovisioned_device_name(const char *name); * @return ESP_OK on success or error code otherwise. */ esp_err_t esp_ble_mesh_provisioner_read_oob_pub_key(uint8_t link_idx, uint8_t pub_key_x[32], - uint8_t pub_key_y[32]); + uint8_t pub_key_y[32]); /** * @brief Provide provisioning input OOB string. diff --git a/components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_proxy_api.h b/components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_proxy_api.h index 7df4d701c..216a597ff 100644 --- a/components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_proxy_api.h +++ b/components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_proxy_api.h @@ -61,7 +61,7 @@ esp_err_t esp_ble_mesh_proxy_gatt_disable(void); * */ esp_err_t esp_ble_mesh_proxy_client_connect(esp_ble_mesh_bd_addr_t addr, - esp_ble_mesh_addr_type_t addr_type, uint16_t net_idx); + esp_ble_mesh_addr_type_t addr_type, uint16_t net_idx); /** * @brief Proxy Client terminates a connection with the Proxy Server. @@ -84,7 +84,7 @@ esp_err_t esp_ble_mesh_proxy_client_disconnect(uint8_t conn_handle); * */ esp_err_t esp_ble_mesh_proxy_client_set_filter_type(uint8_t conn_handle, - uint16_t net_idx, uint8_t filter_type); + uint16_t net_idx, esp_ble_mesh_proxy_filter_type_t filter_type); /** * @brief Proxy Client adds address to the Proxy Server filter list. @@ -98,7 +98,7 @@ esp_err_t esp_ble_mesh_proxy_client_set_filter_type(uint8_t conn_handle, * */ esp_err_t esp_ble_mesh_proxy_client_add_filter_addr(uint8_t conn_handle, - uint16_t net_idx, uint16_t *addr, uint16_t addr_num); + uint16_t net_idx, uint16_t *addr, uint16_t addr_num); /** * @brief Proxy Client removes address from the Proxy Server filter list. @@ -112,7 +112,7 @@ esp_err_t esp_ble_mesh_proxy_client_add_filter_addr(uint8_t conn_handle, * */ esp_err_t esp_ble_mesh_proxy_client_remove_filter_addr(uint8_t conn_handle, - uint16_t net_idx, uint16_t *addr, uint16_t addr_num); + uint16_t net_idx, uint16_t *addr, uint16_t addr_num); #endif /* _ESP_BLE_MESH_PROXY_API_H_ */ 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 34b8a301e..d59c29eb6 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 @@ -695,6 +695,12 @@ typedef enum { FAST_PROV_ACT_MAX, } esp_ble_mesh_fast_prov_action_t; +/*!< This enum value is the type of proxy filter */ +typedef enum { + PROXY_FILTER_WHITELIST, + PROXY_FILTER_BLACKLIST, +} esp_ble_mesh_proxy_filter_type_t; + /*!< This enum value is the event of node/provisioner/fast provisioning */ typedef enum { ESP_BLE_MESH_PROV_REGISTER_COMP_EVT, /*!< Initialize BLE Mesh provisioning capabilities and internal data information completion event */ @@ -1235,7 +1241,7 @@ typedef union { typedef uint32_t esp_ble_mesh_opcode_config_client_get_t; #define ESP_BLE_MESH_MODEL_OP_BEACON_GET OP_BEACON_GET /*!< Config Beacon Get */ -#define ESP_BLE_MESH_MODEL_OP_COMPOSITION_DATA_GET OP_DEV_COMP_DATA_GET /*!< Config Composition Data Get */ +#define ESP_BLE_MESH_MODEL_OP_COMPOSITION_DATA_GET OP_DEV_COMP_DATA_GET /*!< Config Composition Data Get */ #define ESP_BLE_MESH_MODEL_OP_DEFAULT_TTL_GET OP_DEFAULT_TTL_GET /*!< Config Default TTL Get */ #define ESP_BLE_MESH_MODEL_OP_GATT_PROXY_GET OP_GATT_PROXY_GET /*!< Config GATT Proxy Get */ #define ESP_BLE_MESH_MODEL_OP_RELAY_GET OP_RELAY_GET /*!< Config Relay Get */ @@ -1711,7 +1717,7 @@ typedef struct { esp_ble_mesh_model_t *model; /*!< Pointer to the client model structure */ esp_ble_mesh_msg_ctx_t ctx; /*!< The context used to send message */ int32_t msg_timeout; /*!< Timeout value (ms) to get response to the sent message */ - /*!< Note: if using default timeout value in menuconfig, make sure to set this value to 0 */ + /*!< Note: if using default timeout value in menuconfig, make sure to set this value to 0 */ uint8_t msg_role; /*!< Role of the device - Node/Provisioner */ } esp_ble_mesh_client_common_param_t; diff --git a/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_config_model_api.h b/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_config_model_api.h index 14f8318d2..9d1785cff 100644 --- a/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_config_model_api.h +++ b/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_config_model_api.h @@ -513,8 +513,8 @@ typedef struct { /** Parameters of Config Network Transmit Status */ typedef struct { - uint8_t net_trans_count:3; /*!< Number of transmissions for each Network PDU originating from the node */ - uint8_t net_trans_step :5; /*!< Maximum hops when receiving Heartbeat messages */ + uint8_t net_trans_count: 3; /*!< Number of transmissions for each Network PDU originating from the node */ + uint8_t net_trans_step : 5; /*!< Maximum hops when receiving Heartbeat messages */ } esp_ble_mesh_cfg_net_trans_status_cb_t; /** Parameters of Config SIG/Vendor Subscription List */ diff --git a/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_generic_model_api.h b/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_generic_model_api.h index a9a31528a..fcee7ce53 100644 --- a/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_generic_model_api.h +++ b/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_generic_model_api.h @@ -1281,7 +1281,7 @@ typedef enum { * @param param: Pointer to callback parameter */ typedef void (* esp_ble_mesh_generic_server_cb_t)(esp_ble_mesh_generic_server_cb_event_t event, - esp_ble_mesh_generic_server_cb_param_t *param); + esp_ble_mesh_generic_server_cb_param_t *param); /** * @brief Register BLE Mesh Generic Server Model callback. diff --git a/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_lighting_model_api.h b/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_lighting_model_api.h index 473491bde..ff08cfcc0 100644 --- a/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_lighting_model_api.h +++ b/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_lighting_model_api.h @@ -1659,7 +1659,7 @@ typedef enum { * @param param: Pointer to callback parameter */ typedef void (* esp_ble_mesh_lighting_server_cb_t)(esp_ble_mesh_lighting_server_cb_event_t event, - esp_ble_mesh_lighting_server_cb_param_t *param); + esp_ble_mesh_lighting_server_cb_param_t *param); /** * @brief Register BLE Mesh Lighting Server Model callback. diff --git a/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_sensor_model_api.h b/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_sensor_model_api.h index 9971a7f41..52bc082dd 100644 --- a/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_sensor_model_api.h +++ b/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_sensor_model_api.h @@ -609,7 +609,7 @@ typedef enum { * @param param: Pointer to callback parameter */ typedef void (* esp_ble_mesh_sensor_server_cb_t)(esp_ble_mesh_sensor_server_cb_event_t event, - esp_ble_mesh_sensor_server_cb_param_t *param); + esp_ble_mesh_sensor_server_cb_param_t *param); /** * @brief Register BLE Mesh Sensor Server Model callback. diff --git a/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_time_scene_model_api.h b/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_time_scene_model_api.h index d3f85205f..525fe3a88 100644 --- a/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_time_scene_model_api.h +++ b/components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_time_scene_model_api.h @@ -541,7 +541,7 @@ typedef struct { * mesh-wide value. (There can be a maximum of 65535 scenes in a mesh * network.) The meaning of a scene, as well as the state storage container * associated with it, are determined by a model. - * + * * The Scenes state change may start numerous parallel model transitions. * In that case, each individual model handles the transition internally. * @@ -896,7 +896,7 @@ typedef enum { * @param param: Pointer to callback parameter */ typedef void (* esp_ble_mesh_time_scene_server_cb_t)(esp_ble_mesh_time_scene_server_cb_event_t event, - esp_ble_mesh_time_scene_server_cb_param_t *param); + esp_ble_mesh_time_scene_server_cb_param_t *param); /** * @brief Register BLE Mesh Time and Scenes Server Model callback. diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_config_model.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_config_model.c index 4dd56a48d..7cd73b942 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_config_model.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_config_model.c @@ -298,7 +298,7 @@ static void btc_ble_mesh_config_client_callback(esp_ble_mesh_cfg_client_cb_param msg.act = act; btc_transfer_context(&msg, cb_params, - sizeof(esp_ble_mesh_cfg_client_cb_param_t), btc_ble_mesh_config_client_copy_req_data); + sizeof(esp_ble_mesh_cfg_client_cb_param_t), btc_ble_mesh_config_client_copy_req_data); } void bt_mesh_config_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, @@ -366,7 +366,7 @@ void btc_ble_mesh_config_client_publish_callback(u32_t opcode, } bt_mesh_config_client_cb_evt_to_btc(opcode, - BTC_BLE_MESH_EVT_CONFIG_CLIENT_PUBLISH, model, ctx, buf->data, buf->len); + BTC_BLE_MESH_EVT_CONFIG_CLIENT_PUBLISH, model, ctx, buf->data, buf->len); return; } @@ -403,7 +403,7 @@ static int btc_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param case ESP_BLE_MESH_MODEL_OP_MODEL_PUB_GET: return (cb->error_code = bt_mesh_cfg_mod_pub_get(&ctx, get->model_pub_get.element_addr, - get->model_pub_get.model_id, get->model_pub_get.company_id)); + get->model_pub_get.model_id, get->model_pub_get.company_id)); case ESP_BLE_MESH_MODEL_OP_HEARTBEAT_PUB_GET: return (cb->error_code = bt_mesh_cfg_hb_pub_get(&ctx)); case ESP_BLE_MESH_MODEL_OP_HEARTBEAT_SUB_GET: @@ -413,11 +413,11 @@ static int btc_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param case ESP_BLE_MESH_MODEL_OP_SIG_MODEL_SUB_GET: return (cb->error_code = bt_mesh_cfg_mod_sub_get(&ctx, get->sig_model_sub_get.element_addr, - get->sig_model_sub_get.model_id)); + get->sig_model_sub_get.model_id)); case ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_SUB_GET: return (cb->error_code = bt_mesh_cfg_mod_sub_get_vnd(&ctx, get->vnd_model_sub_get.element_addr, - get->vnd_model_sub_get.model_id, get->vnd_model_sub_get.company_id)); + get->vnd_model_sub_get.model_id, get->vnd_model_sub_get.company_id)); case ESP_BLE_MESH_MODEL_OP_NET_KEY_GET: return (cb->error_code = bt_mesh_cfg_net_key_get(&ctx)); case ESP_BLE_MESH_MODEL_OP_APP_KEY_GET: @@ -427,11 +427,11 @@ static int btc_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param case ESP_BLE_MESH_MODEL_OP_SIG_MODEL_APP_GET: return (cb->error_code = bt_mesh_cfg_mod_app_get(&ctx, get->sig_model_app_get.element_addr, - get->sig_model_app_get.model_id)); + get->sig_model_app_get.model_id)); case ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_APP_GET: return (cb->error_code = bt_mesh_cfg_mod_app_get_vnd(&ctx, get->vnd_model_app_get.element_addr, - get->vnd_model_app_get.model_id, get->vnd_model_app_get.company_id)); + get->vnd_model_app_get.model_id, get->vnd_model_app_get.company_id)); case ESP_BLE_MESH_MODEL_OP_KEY_REFRESH_PHASE_GET: return (cb->error_code = bt_mesh_cfg_kr_phase_get(&ctx, get->kr_phase_get.net_idx)); case ESP_BLE_MESH_MODEL_OP_LPN_POLLTIMEOUT_GET: @@ -480,16 +480,16 @@ static int btc_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param case ESP_BLE_MESH_MODEL_OP_NET_KEY_ADD: return (cb->error_code = bt_mesh_cfg_net_key_add(&ctx, set->net_key_add.net_idx, - &set->net_key_add.net_key[0])); + &set->net_key_add.net_key[0])); case ESP_BLE_MESH_MODEL_OP_APP_KEY_ADD: return (cb->error_code = bt_mesh_cfg_app_key_add(&ctx, set->app_key_add.net_idx, - set->app_key_add.app_idx, &set->app_key_add.app_key[0])); + set->app_key_add.app_idx, &set->app_key_add.app_key[0])); case ESP_BLE_MESH_MODEL_OP_MODEL_APP_BIND: return (cb->error_code = bt_mesh_cfg_mod_app_bind(&ctx, set->model_app_bind.element_addr, - set->model_app_bind.model_app_idx, set->model_app_bind.model_id, - set->model_app_bind.company_id)); + set->model_app_bind.model_app_idx, set->model_app_bind.model_id, + set->model_app_bind.company_id)); case ESP_BLE_MESH_MODEL_OP_MODEL_PUB_SET: { struct bt_mesh_cfg_mod_pub model_pub = { .addr = set->model_pub_set.publish_addr, @@ -501,46 +501,46 @@ static int btc_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param }; return (cb->error_code = bt_mesh_cfg_mod_pub_set(&ctx, set->model_pub_set.element_addr, - set->model_pub_set.model_id, set->model_pub_set.company_id, &model_pub)); + set->model_pub_set.model_id, set->model_pub_set.company_id, &model_pub)); } case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_ADD: return (cb->error_code = bt_mesh_cfg_mod_sub_add(&ctx, set->model_sub_add.element_addr, - set->model_sub_add.sub_addr, set->model_sub_add.model_id, - set->model_sub_add.company_id)); + set->model_sub_add.sub_addr, set->model_sub_add.model_id, + set->model_sub_add.company_id)); case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_DELETE: return (cb->error_code = bt_mesh_cfg_mod_sub_del(&ctx, set->model_sub_delete.element_addr, - set->model_sub_delete.sub_addr, set->model_sub_delete.model_id, - set->model_sub_delete.company_id)); + set->model_sub_delete.sub_addr, set->model_sub_delete.model_id, + set->model_sub_delete.company_id)); case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_OVERWRITE: return (cb->error_code = bt_mesh_cfg_mod_sub_overwrite(&ctx, set->model_sub_overwrite.element_addr, - set->model_sub_overwrite.sub_addr, set->model_sub_overwrite.model_id, - set->model_sub_overwrite.company_id)); + set->model_sub_overwrite.sub_addr, set->model_sub_overwrite.model_id, + set->model_sub_overwrite.company_id)); case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_ADD: return (cb->error_code = bt_mesh_cfg_mod_sub_va_add(&ctx, set->model_sub_va_add.element_addr, - &set->model_sub_va_add.label_uuid[0], set->model_sub_va_add.model_id, - set->model_sub_va_add.company_id)); + &set->model_sub_va_add.label_uuid[0], set->model_sub_va_add.model_id, + set->model_sub_va_add.company_id)); case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_OVERWRITE: return (cb->error_code = bt_mesh_cfg_mod_sub_va_overwrite(&ctx, set->model_sub_va_overwrite.element_addr, - &set->model_sub_va_overwrite.label_uuid[0], set->model_sub_va_overwrite.model_id, - set->model_sub_va_overwrite.company_id)); + &set->model_sub_va_overwrite.label_uuid[0], set->model_sub_va_overwrite.model_id, + set->model_sub_va_overwrite.company_id)); case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_VIRTUAL_ADDR_DELETE: return (cb->error_code = bt_mesh_cfg_mod_sub_va_del(&ctx, set->model_sub_va_delete.element_addr, - &set->model_sub_va_delete.label_uuid[0], set->model_sub_va_delete.model_id, - set->model_sub_va_delete.company_id)); + &set->model_sub_va_delete.label_uuid[0], set->model_sub_va_delete.model_id, + set->model_sub_va_delete.company_id)); case ESP_BLE_MESH_MODEL_OP_HEARTBEAT_SUB_SET: return (cb->error_code = bt_mesh_cfg_hb_sub_set(&ctx, - (struct bt_mesh_cfg_hb_sub *)&set->heartbeat_sub_set)); + (struct bt_mesh_cfg_hb_sub *)&set->heartbeat_sub_set)); case ESP_BLE_MESH_MODEL_OP_HEARTBEAT_PUB_SET: return (cb->error_code = bt_mesh_cfg_hb_pub_set(&ctx, - (const struct bt_mesh_cfg_hb_pub *)&set->heartbeat_pub_set)); + (const struct bt_mesh_cfg_hb_pub *)&set->heartbeat_pub_set)); case ESP_BLE_MESH_MODEL_OP_NODE_RESET: return (cb->error_code = bt_mesh_cfg_node_reset(&ctx)); case ESP_BLE_MESH_MODEL_OP_MODEL_PUB_VIRTUAL_ADDR_SET: { @@ -553,41 +553,41 @@ static int btc_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param }; return (cb->error_code = bt_mesh_cfg_mod_pub_va_set(&ctx, set->model_pub_va_set.element_addr, - set->model_pub_va_set.model_id, set->model_pub_va_set.company_id, - set->model_pub_va_set.label_uuid, &model_pub)); + set->model_pub_va_set.model_id, set->model_pub_va_set.company_id, + set->model_pub_va_set.label_uuid, &model_pub)); } case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_DELETE_ALL: return (cb->error_code = bt_mesh_cfg_mod_sub_del_all(&ctx, set->model_sub_delete_all.element_addr, - set->model_sub_delete_all.model_id, set->model_sub_delete_all.company_id)); + set->model_sub_delete_all.model_id, set->model_sub_delete_all.company_id)); case ESP_BLE_MESH_MODEL_OP_NET_KEY_UPDATE: return (cb->error_code = bt_mesh_cfg_net_key_update(&ctx, set->net_key_update.net_idx, - set->net_key_update.net_key)); + set->net_key_update.net_key)); case ESP_BLE_MESH_MODEL_OP_NET_KEY_DELETE: return (cb->error_code = bt_mesh_cfg_net_key_delete(&ctx, set->net_key_delete.net_idx)); case ESP_BLE_MESH_MODEL_OP_APP_KEY_UPDATE: return (cb->error_code = bt_mesh_cfg_app_key_update(&ctx, set->app_key_update.net_idx, - set->app_key_update.app_idx, set->app_key_update.app_key)); + set->app_key_update.app_idx, set->app_key_update.app_key)); case ESP_BLE_MESH_MODEL_OP_APP_KEY_DELETE: return (cb->error_code = bt_mesh_cfg_app_key_delete(&ctx, set->app_key_delete.net_idx, - set->app_key_delete.app_idx)); + set->app_key_delete.app_idx)); case ESP_BLE_MESH_MODEL_OP_NODE_IDENTITY_SET: return (cb->error_code = bt_mesh_cfg_node_identity_set(&ctx, set->node_identity_set.net_idx, - set->node_identity_set.identity)); + set->node_identity_set.identity)); case ESP_BLE_MESH_MODEL_OP_MODEL_APP_UNBIND: return (cb->error_code = bt_mesh_cfg_mod_app_unbind(&ctx, set->model_app_unbind.element_addr, - set->model_app_unbind.model_app_idx, set->model_app_unbind.model_id, - set->model_app_unbind.company_id)); + set->model_app_unbind.model_app_idx, set->model_app_unbind.model_id, + set->model_app_unbind.company_id)); case ESP_BLE_MESH_MODEL_OP_KEY_REFRESH_PHASE_SET: return (cb->error_code = bt_mesh_cfg_kr_phase_set(&ctx, set->kr_phase_set.net_idx, - set->kr_phase_set.transition)); + set->kr_phase_set.transition)); case ESP_BLE_MESH_MODEL_OP_NETWORK_TRANSMIT_SET: return (cb->error_code = bt_mesh_cfg_net_transmit_set(&ctx, set->net_transmit_set.net_transmit)); diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_generic_model.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_generic_model.c index d8ed82f68..a761c7722 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_generic_model.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_generic_model.c @@ -371,7 +371,7 @@ static void btc_ble_mesh_generic_client_callback(esp_ble_mesh_generic_client_cb_ msg.act = act; btc_transfer_context(&msg, cb_params, - sizeof(esp_ble_mesh_generic_client_cb_param_t), btc_ble_mesh_generic_client_copy_req_data); + sizeof(esp_ble_mesh_generic_client_cb_param_t), btc_ble_mesh_generic_client_copy_req_data); } void bt_mesh_generic_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, @@ -439,7 +439,7 @@ void btc_ble_mesh_generic_client_publish_callback(u32_t opcode, } bt_mesh_generic_client_cb_evt_to_btc(opcode, - BTC_BLE_MESH_EVT_GENERIC_CLIENT_PUBLISH, model, ctx, buf->data, buf->len); + BTC_BLE_MESH_EVT_GENERIC_CLIENT_PUBLISH, model, ctx, buf->data, buf->len); return; } @@ -478,7 +478,7 @@ void btc_ble_mesh_generic_client_call_handler(btc_msg_t *msg) cb.params = arg->generic_client_get_state.params; cb.error_code = bt_mesh_generic_client_get_state(&common, - (void *)arg->generic_client_get_state.get_state, (void *)&cb.status_cb); + (void *)arg->generic_client_get_state.get_state, (void *)&cb.status_cb); if (cb.error_code) { /* If send failed, callback error_code to app layer immediately */ btc_ble_mesh_generic_client_callback(&cb, ESP_BLE_MESH_GENERIC_CLIENT_GET_STATE_EVT); @@ -504,7 +504,7 @@ void btc_ble_mesh_generic_client_call_handler(btc_msg_t *msg) cb.params = arg->generic_client_set_state.params; cb.error_code = bt_mesh_generic_client_set_state(&common, - (void *)arg->generic_client_set_state.set_state, (void *)&cb.status_cb); + (void *)arg->generic_client_set_state.set_state, (void *)&cb.status_cb); if (cb.error_code) { /* If send failed, callback error_code to app layer immediately */ btc_ble_mesh_generic_client_callback(&cb, ESP_BLE_MESH_GENERIC_CLIENT_SET_STATE_EVT); @@ -543,8 +543,8 @@ void btc_ble_mesh_generic_client_cb_handler(btc_msg_t *msg) /* Generic Server Models related functions */ static inline void btc_ble_mesh_generic_server_cb_to_app( - esp_ble_mesh_generic_server_cb_event_t event, - esp_ble_mesh_generic_server_cb_param_t *param) + esp_ble_mesh_generic_server_cb_event_t event, + esp_ble_mesh_generic_server_cb_param_t *param) { esp_ble_mesh_generic_server_cb_t btc_ble_mesh_cb = (esp_ble_mesh_generic_server_cb_t)btc_profile_cb_get(BTC_PID_GENERIC_SERVER); @@ -699,7 +699,7 @@ static void btc_ble_mesh_generic_server_callback(esp_ble_mesh_generic_server_cb_ msg.act = act; btc_transfer_context(&msg, cb_params, - sizeof(esp_ble_mesh_generic_server_cb_param_t), btc_ble_mesh_generic_server_copy_req_data); + sizeof(esp_ble_mesh_generic_server_cb_param_t), btc_ble_mesh_generic_server_copy_req_data); } void bt_mesh_generic_server_cb_evt_to_btc(u8_t evt_type, diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_health_model.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_health_model.c index c0db2bcd6..ab8ef2f12 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_health_model.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_health_model.c @@ -239,7 +239,7 @@ static void btc_ble_mesh_health_client_callback(esp_ble_mesh_health_client_cb_pa msg.act = act; btc_transfer_context(&msg, cb_params, - sizeof(esp_ble_mesh_health_client_cb_param_t), btc_ble_mesh_health_client_copy_req_data); + sizeof(esp_ble_mesh_health_client_cb_param_t), btc_ble_mesh_health_client_copy_req_data); } void bt_mesh_health_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, @@ -307,7 +307,7 @@ void btc_ble_mesh_health_publish_callback(u32_t opcode, } bt_mesh_health_client_cb_evt_to_btc(opcode, - BTC_BLE_MESH_EVT_HEALTH_CLIENT_PUBLISH, model, ctx, buf->data, buf->len); + BTC_BLE_MESH_EVT_HEALTH_CLIENT_PUBLISH, model, ctx, buf->data, buf->len); return; } @@ -420,7 +420,7 @@ void btc_ble_mesh_health_client_call_handler(btc_msg_t *msg) break; } btc_ble_mesh_health_client_get_state(arg->health_client_get_state.params, - arg->health_client_get_state.get_state, &cb); + arg->health_client_get_state.get_state, &cb); if (cb.error_code) { /* If send failed, callback error_code to app layer immediately */ btc_ble_mesh_health_client_callback(&cb, ESP_BLE_MESH_HEALTH_CLIENT_GET_STATE_EVT); @@ -436,7 +436,7 @@ void btc_ble_mesh_health_client_call_handler(btc_msg_t *msg) break; } btc_ble_mesh_health_client_set_state(arg->health_client_set_state.params, - arg->health_client_set_state.set_state, &cb); + arg->health_client_set_state.set_state, &cb); if (cb.error_code) { /* If send failed, callback error_code to app layer immediately */ btc_ble_mesh_health_client_callback(&cb, ESP_BLE_MESH_HEALTH_CLIENT_SET_STATE_EVT); @@ -560,7 +560,7 @@ static void btc_ble_mesh_health_server_callback(esp_ble_mesh_health_server_cb_pa msg.act = act; btc_transfer_context(&msg, cb_params, - sizeof(esp_ble_mesh_health_server_cb_param_t), btc_ble_mesh_health_server_copy_req_data); + sizeof(esp_ble_mesh_health_server_cb_param_t), btc_ble_mesh_health_server_copy_req_data); } void btc_ble_mesh_health_server_call_handler(btc_msg_t *msg) diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_lighting_model.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_lighting_model.c index 050d391ca..b0c4d9f29 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_lighting_model.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_lighting_model.c @@ -215,7 +215,7 @@ static void btc_ble_mesh_lighting_client_callback(esp_ble_mesh_light_client_cb_p msg.act = act; btc_transfer_context(&msg, cb_params, - sizeof(esp_ble_mesh_light_client_cb_param_t), btc_ble_mesh_lighting_client_copy_req_data); + sizeof(esp_ble_mesh_light_client_cb_param_t), btc_ble_mesh_lighting_client_copy_req_data); } void bt_mesh_lighting_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, @@ -283,7 +283,7 @@ void btc_ble_mesh_lighting_client_publish_callback(u32_t opcode, } bt_mesh_lighting_client_cb_evt_to_btc(opcode, - BTC_BLE_MESH_EVT_LIGHTING_CLIENT_PUBLISH, model, ctx, buf->data, buf->len); + BTC_BLE_MESH_EVT_LIGHTING_CLIENT_PUBLISH, model, ctx, buf->data, buf->len); return; } @@ -322,7 +322,7 @@ void btc_ble_mesh_lighting_client_call_handler(btc_msg_t *msg) cb.params = arg->light_client_get_state.params; cb.error_code = bt_mesh_light_client_get_state(&common, - (void *)arg->light_client_get_state.get_state, (void *)&cb.status_cb); + (void *)arg->light_client_get_state.get_state, (void *)&cb.status_cb); if (cb.error_code) { /* If send failed, callback error_code to app layer immediately */ btc_ble_mesh_lighting_client_callback(&cb, ESP_BLE_MESH_LIGHT_CLIENT_GET_STATE_EVT); @@ -348,7 +348,7 @@ void btc_ble_mesh_lighting_client_call_handler(btc_msg_t *msg) cb.params = arg->light_client_set_state.params; cb.error_code = bt_mesh_light_client_set_state(&common, - (void *)arg->light_client_set_state.set_state, (void *)&cb.status_cb); + (void *)arg->light_client_set_state.set_state, (void *)&cb.status_cb); if (cb.error_code) { /* If send failed, callback error_code to app layer immediately */ btc_ble_mesh_lighting_client_callback(&cb, ESP_BLE_MESH_LIGHT_CLIENT_SET_STATE_EVT); @@ -387,8 +387,8 @@ void btc_ble_mesh_lighting_client_cb_handler(btc_msg_t *msg) /* Lighting Server Models related functions */ static inline void btc_ble_mesh_lighting_server_cb_to_app( - esp_ble_mesh_lighting_server_cb_event_t event, - esp_ble_mesh_lighting_server_cb_param_t *param) + esp_ble_mesh_lighting_server_cb_event_t event, + esp_ble_mesh_lighting_server_cb_param_t *param) { esp_ble_mesh_lighting_server_cb_t btc_ble_mesh_cb = (esp_ble_mesh_lighting_server_cb_t)btc_profile_cb_get(BTC_PID_LIGHTING_SERVER); @@ -411,7 +411,7 @@ static void btc_ble_mesh_lighting_server_copy_req_data(btc_msg_t *msg, void *p_d switch (msg->act) { case ESP_BLE_MESH_LIGHTING_SERVER_STATE_CHANGE_EVT: if (p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET || - p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET_UNACK) { + p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET_UNACK) { if (p_src_data->value.state_change.lc_property_set.property_value) { length = p_src_data->value.state_change.lc_property_set.property_value->len; p_dest_data->value.state_change.lc_property_set.property_value = bt_mesh_alloc_buf(length); @@ -427,7 +427,7 @@ static void btc_ble_mesh_lighting_server_copy_req_data(btc_msg_t *msg, void *p_d break; case ESP_BLE_MESH_LIGHTING_SERVER_RECV_SET_MSG_EVT: if (p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET || - p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET_UNACK) { + p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET_UNACK) { if (p_src_data->value.set.lc_property.property_value) { length = p_src_data->value.set.lc_property.property_value->len; p_dest_data->value.set.lc_property.property_value = bt_mesh_alloc_buf(length); @@ -475,13 +475,13 @@ static void btc_ble_mesh_lighting_server_free_req_data(btc_msg_t *msg) switch (msg->act) { case ESP_BLE_MESH_LIGHTING_SERVER_STATE_CHANGE_EVT: if (arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET || - arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET_UNACK) { + arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET_UNACK) { bt_mesh_free_buf(arg->value.state_change.lc_property_set.property_value); } break; case ESP_BLE_MESH_LIGHTING_SERVER_RECV_SET_MSG_EVT: if (arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET || - arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET_UNACK) { + arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET_UNACK) { bt_mesh_free_buf(arg->value.set.lc_property.property_value); } break; diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_prov.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_prov.c index b107bdb50..415a543a0 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_prov.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_prov.c @@ -99,7 +99,7 @@ void btc_ble_mesh_prov_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src) dst->proxy_client_add_filter_addr.addr = (uint16_t *)osi_calloc(src->proxy_client_add_filter_addr.addr_num << 1); if (dst->proxy_client_add_filter_addr.addr) { memcpy(dst->proxy_client_add_filter_addr.addr, src->proxy_client_add_filter_addr.addr, - src->proxy_client_add_filter_addr.addr_num << 1); + src->proxy_client_add_filter_addr.addr_num << 1); } else { LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act); } @@ -109,7 +109,7 @@ void btc_ble_mesh_prov_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src) dst->proxy_client_remove_filter_addr.addr = osi_calloc(src->proxy_client_remove_filter_addr.addr_num << 1); if (dst->proxy_client_remove_filter_addr.addr) { memcpy(dst->proxy_client_remove_filter_addr.addr, src->proxy_client_remove_filter_addr.addr, - src->proxy_client_remove_filter_addr.addr_num << 1); + src->proxy_client_remove_filter_addr.addr_num << 1); } else { LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act); } @@ -182,7 +182,7 @@ void btc_ble_mesh_model_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src) dst->model_update_state.value = osi_malloc(sizeof(esp_ble_mesh_server_state_value_t)); if (dst->model_update_state.value) { memcpy(dst->model_update_state.value, src->model_update_state.value, - sizeof(esp_ble_mesh_server_state_value_t)); + sizeof(esp_ble_mesh_server_state_value_t)); } else { LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act); } @@ -366,7 +366,7 @@ static bt_status_t btc_ble_mesh_model_callback(esp_ble_mesh_model_cb_param_t *pa msg.act = act; ret = btc_transfer_context(&msg, param, - sizeof(esp_ble_mesh_model_cb_param_t), btc_ble_mesh_model_copy_req_data); + sizeof(esp_ble_mesh_model_cb_param_t), btc_ble_mesh_model_copy_req_data); if (ret != BT_STATUS_SUCCESS) { LOG_ERROR("%s, btc_transfer_context failed", __func__); } @@ -648,16 +648,16 @@ static void btc_ble_mesh_prov_set_complete_cb(esp_ble_mesh_prov_cb_param_t *para #if CONFIG_BLE_MESH_PROVISIONER static void btc_ble_mesh_provisioner_recv_unprov_adv_pkt_cb( - const u8_t addr[6], const u8_t addr_type, - const u8_t adv_type, const u8_t dev_uuid[16], - u16_t oob_info, bt_mesh_prov_bearer_t bearer) + const u8_t addr[6], const u8_t addr_type, + const u8_t adv_type, const u8_t dev_uuid[16], + u16_t oob_info, bt_mesh_prov_bearer_t bearer) { esp_ble_mesh_prov_cb_param_t mesh_param = {0}; LOG_DEBUG("%s", __func__); if (addr == NULL || dev_uuid == NULL || - (bearer != BLE_MESH_PROV_ADV && bearer != BLE_MESH_PROV_GATT)) { + (bearer != BLE_MESH_PROV_ADV && bearer != BLE_MESH_PROV_GATT)) { LOG_ERROR("%s, Invalid parameter", __func__); return; } @@ -687,7 +687,7 @@ static int btc_ble_mesh_provisioner_prov_read_oob_pub_key_cb(u8_t link_idx) } static int btc_ble_mesh_provisioner_prov_input_cb(u8_t method, - bt_mesh_output_action_t act, u8_t size, u8_t link_idx) + bt_mesh_output_action_t act, u8_t size, u8_t link_idx) { esp_ble_mesh_prov_cb_param_t mesh_param = {0}; bt_status_t ret; @@ -704,7 +704,7 @@ static int btc_ble_mesh_provisioner_prov_input_cb(u8_t method, } static int btc_ble_mesh_provisioner_prov_output_cb(u8_t method, - bt_mesh_input_action_t act, void *data, u8_t size, u8_t link_idx) + bt_mesh_input_action_t act, void *data, u8_t size, u8_t link_idx) { esp_ble_mesh_prov_cb_param_t mesh_param = {0}; bt_status_t ret; @@ -751,9 +751,9 @@ static void btc_ble_mesh_provisioner_link_close_cb(bt_mesh_prov_bearer_t bearer, } static void btc_ble_mesh_provisioner_prov_complete_cb( - int node_idx, const u8_t device_uuid[16], - u16_t unicast_addr, u8_t element_num, - u16_t netkey_idx) + int node_idx, const u8_t device_uuid[16], + u16_t unicast_addr, u8_t element_num, + u16_t netkey_idx) { esp_ble_mesh_prov_cb_param_t mesh_param = {0}; @@ -792,7 +792,7 @@ static void btc_ble_mesh_lpn_cb(u16_t friend_addr, bool established) LOG_DEBUG("%s", __func__); - if (established) { + if (established) { mesh_param.lpn_friendship_establish.friend_addr = friend_addr; act = ESP_BLE_MESH_LPN_FRIENDSHIP_ESTABLISH_EVT; } else { @@ -818,7 +818,7 @@ void btc_ble_mesh_friend_cb(bool establish, u16_t lpn_addr, u8_t reason) return; } - if (establish) { + if (establish) { mesh_param.frnd_friendship_establish.lpn_addr = lpn_addr; act = ESP_BLE_MESH_FRIEND_FRIENDSHIP_ESTABLISH_EVT; } else { @@ -835,7 +835,7 @@ void btc_ble_mesh_friend_cb(bool establish, u16_t lpn_addr, u8_t reason) #if CONFIG_BLE_MESH_GATT_PROXY_CLIENT static void btc_ble_mesh_proxy_client_adv_recv_cb(const bt_mesh_addr_t *addr, - u8_t type, bt_mesh_proxy_adv_ctx_t *ctx) + u8_t type, bt_mesh_proxy_adv_ctx_t *ctx) { esp_ble_mesh_prov_cb_param_t mesh_param = {0}; @@ -856,7 +856,7 @@ static void btc_ble_mesh_proxy_client_adv_recv_cb(const bt_mesh_addr_t *addr, } static void btc_ble_mesh_proxy_client_connect_cb(const bt_mesh_addr_t *addr, - u8_t conn_handle, u16_t net_idx) + u8_t conn_handle, u16_t net_idx) { esp_ble_mesh_prov_cb_param_t mesh_param = {0}; @@ -877,7 +877,7 @@ static void btc_ble_mesh_proxy_client_connect_cb(const bt_mesh_addr_t *addr, } static void btc_ble_mesh_proxy_client_disconnect_cb(const bt_mesh_addr_t *addr, - u8_t conn_handle, u16_t net_idx, u8_t reason) + u8_t conn_handle, u16_t net_idx, u8_t reason) { esp_ble_mesh_prov_cb_param_t mesh_param = {0}; @@ -899,7 +899,7 @@ static void btc_ble_mesh_proxy_client_disconnect_cb(const bt_mesh_addr_t *addr, } static void btc_ble_mesh_proxy_client_filter_status_recv_cb(u8_t conn_handle, - u16_t src, u16_t net_idx, u8_t filter_type, u16_t list_size) + u16_t src, u16_t net_idx, u8_t filter_type, u16_t list_size) { esp_ble_mesh_prov_cb_param_t mesh_param = {0}; @@ -1555,8 +1555,8 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg) act = ESP_BLE_MESH_NODE_PROV_SET_OOB_PUB_KEY_COMP_EVT; param.node_prov_set_oob_pub_key_comp.err_code = bt_mesh_set_oob_pub_key(arg->set_oob_pub_key.pub_key_x, - arg->set_oob_pub_key.pub_key_y, - arg->set_oob_pub_key.private_key); + arg->set_oob_pub_key.pub_key_y, + arg->set_oob_pub_key.private_key); break; case BTC_BLE_MESH_ACT_INPUT_NUMBER: act = ESP_BLE_MESH_NODE_PROV_INPUT_NUMBER_COMP_EVT; @@ -1590,20 +1590,20 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg) act = ESP_BLE_MESH_PROVISIONER_PROV_READ_OOB_PUB_KEY_COMP_EVT; param.provisioner_prov_read_oob_pub_key_comp.err_code = bt_mesh_prov_read_oob_pub_key(arg->provisioner_read_oob_pub_key.link_idx, - arg->provisioner_read_oob_pub_key.pub_key_x, - arg->provisioner_read_oob_pub_key.pub_key_y); + arg->provisioner_read_oob_pub_key.pub_key_x, + arg->provisioner_read_oob_pub_key.pub_key_y); break; case BTC_BLE_MESH_ACT_PROVISIONER_INPUT_STR: act = ESP_BLE_MESH_PROVISIONER_PROV_INPUT_STRING_COMP_EVT; param.provisioner_prov_input_str_comp.err_code = bt_mesh_prov_set_oob_input_data(arg->provisioner_input_str.link_idx, - (const u8_t *)&arg->provisioner_input_str.string, false); + (const u8_t *)&arg->provisioner_input_str.string, false); break; case BTC_BLE_MESH_ACT_PROVISIONER_INPUT_NUM: act = ESP_BLE_MESH_PROVISIONER_PROV_INPUT_NUMBER_COMP_EVT; param.provisioner_prov_input_num_comp.err_code = bt_mesh_prov_set_oob_input_data(arg->provisioner_input_num.link_idx, - (const u8_t *)&arg->provisioner_input_num.number, true); + (const u8_t *)&arg->provisioner_input_num.number, true); break; case BTC_BLE_MESH_ACT_PROVISIONER_ENABLE: act = ESP_BLE_MESH_PROVISIONER_PROV_ENABLE_COMP_EVT; @@ -1757,8 +1757,8 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg) param.proxy_client_connect_comp.net_idx = arg->proxy_client_connect.net_idx; param.proxy_client_connect_comp.err_code = bt_mesh_proxy_client_connect(arg->proxy_client_connect.addr, - arg->proxy_client_connect.addr_type, - arg->proxy_client_connect.net_idx); + arg->proxy_client_connect.addr_type, + arg->proxy_client_connect.net_idx); break; case BTC_BLE_MESH_ACT_PROXY_CLIENT_DISCONNECT: act = ESP_BLE_MESH_PROXY_CLIENT_DISCONNECT_COMP_EVT; @@ -1776,7 +1776,7 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg) param.proxy_client_set_filter_type_comp.net_idx = arg->proxy_client_set_filter_type.net_idx; param.proxy_client_set_filter_type_comp.err_code = bt_mesh_proxy_client_send_cfg(arg->proxy_client_set_filter_type.conn_handle, - arg->proxy_client_set_filter_type.net_idx, &pdu); + arg->proxy_client_set_filter_type.net_idx, &pdu); break; } case BTC_BLE_MESH_ACT_PROXY_CLIENT_ADD_FILTER_ADDR: { @@ -1790,7 +1790,7 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg) param.proxy_client_add_filter_addr_comp.net_idx = arg->proxy_client_add_filter_addr.net_idx; param.proxy_client_add_filter_addr_comp.err_code = bt_mesh_proxy_client_send_cfg(arg->proxy_client_add_filter_addr.conn_handle, - arg->proxy_client_add_filter_addr.net_idx, &pdu); + arg->proxy_client_add_filter_addr.net_idx, &pdu); break; } case BTC_BLE_MESH_ACT_PROXY_CLIENT_REMOVE_FILTER_ADDR: { @@ -1804,7 +1804,7 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg) param.proxy_client_remove_filter_addr_comp.net_idx = arg->proxy_client_remove_filter_addr.net_idx; param.proxy_client_remove_filter_addr_comp.err_code = bt_mesh_proxy_client_send_cfg(arg->proxy_client_remove_filter_addr.conn_handle, - arg->proxy_client_remove_filter_addr.net_idx, &pdu); + arg->proxy_client_remove_filter_addr.net_idx, &pdu); break; } #endif /* CONFIG_BLE_MESH_GATT_PROXY_CLIENT */ @@ -1816,7 +1816,9 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg) /* Callback operation completion events */ btc_ble_mesh_prov_set_complete_cb(¶m, act); - btc_ble_mesh_prov_arg_deep_free(msg); + if (msg->arg) { + btc_ble_mesh_prov_arg_deep_free(msg); + } return; } @@ -1876,7 +1878,7 @@ void btc_ble_mesh_model_call_handler(btc_msg_t *msg) arg->model_send.ctx->srv_send = true; err = bt_mesh_model_send((struct bt_mesh_model *)arg->model_send.model, (struct bt_mesh_msg_ctx *)arg->model_send.ctx, - buf, NULL, NULL); + buf, NULL, NULL); bt_mesh_free_buf(buf); btc_ble_mesh_model_send_comp_cb(arg->model_send.model, arg->model_send.ctx, arg->model_send.opcode, err); @@ -1899,10 +1901,10 @@ void btc_ble_mesh_model_call_handler(btc_msg_t *msg) break; } err = bt_mesh_client_send_msg((struct bt_mesh_model *)arg->model_send.model, - arg->model_send.opcode, - (struct bt_mesh_msg_ctx *)arg->model_send.ctx, buf, - btc_ble_mesh_client_model_timeout_cb, arg->model_send.msg_timeout, - arg->model_send.need_rsp, NULL, NULL); + arg->model_send.opcode, + (struct bt_mesh_msg_ctx *)arg->model_send.ctx, buf, + btc_ble_mesh_client_model_timeout_cb, arg->model_send.msg_timeout, + arg->model_send.need_rsp, NULL, NULL); bt_mesh_free_buf(buf); btc_ble_mesh_model_send_comp_cb(arg->model_send.model, arg->model_send.ctx, arg->model_send.opcode, err); @@ -1910,10 +1912,10 @@ void btc_ble_mesh_model_call_handler(btc_msg_t *msg) } case BTC_BLE_MESH_ACT_SERVER_MODEL_UPDATE_STATE: err = bt_mesh_update_binding_state( - (struct bt_mesh_model *)arg->model_update_state.model, arg->model_update_state.type, - (bt_mesh_server_state_value_t *)arg->model_update_state.value); + (struct bt_mesh_model *)arg->model_update_state.model, arg->model_update_state.type, + (bt_mesh_server_state_value_t *)arg->model_update_state.value); btc_ble_mesh_server_model_update_state_comp_cb(arg->model_update_state.model, - arg->model_update_state.type, err); + arg->model_update_state.type, err); break; default: LOG_WARN("%s, Unknown msg->act %d", __func__, msg->act); diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_sensor_model.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_sensor_model.c index 610436538..603f90586 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_sensor_model.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_sensor_model.c @@ -460,7 +460,7 @@ static void btc_ble_mesh_sensor_client_callback(esp_ble_mesh_sensor_client_cb_pa msg.act = act; btc_transfer_context(&msg, cb_params, - sizeof(esp_ble_mesh_sensor_client_cb_param_t), btc_ble_mesh_sensor_client_copy_req_data); + sizeof(esp_ble_mesh_sensor_client_cb_param_t), btc_ble_mesh_sensor_client_copy_req_data); } void bt_mesh_sensor_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, @@ -528,7 +528,7 @@ void btc_ble_mesh_sensor_client_publish_callback(u32_t opcode, } bt_mesh_sensor_client_cb_evt_to_btc(opcode, - BTC_BLE_MESH_EVT_SENSOR_CLIENT_PUBLISH, model, ctx, buf->data, buf->len); + BTC_BLE_MESH_EVT_SENSOR_CLIENT_PUBLISH, model, ctx, buf->data, buf->len); return; } @@ -567,7 +567,7 @@ void btc_ble_mesh_sensor_client_call_handler(btc_msg_t *msg) cb.params = arg->sensor_client_get_state.params; cb.error_code = bt_mesh_sensor_client_get_state(&common, - (void *)arg->sensor_client_get_state.get_state, (void *)&cb.status_cb); + (void *)arg->sensor_client_get_state.get_state, (void *)&cb.status_cb); if (cb.error_code) { /* If send failed, callback error_code to app layer immediately */ btc_ble_mesh_sensor_client_callback(&cb, ESP_BLE_MESH_SENSOR_CLIENT_GET_STATE_EVT); @@ -593,7 +593,7 @@ void btc_ble_mesh_sensor_client_call_handler(btc_msg_t *msg) cb.params = arg->sensor_client_set_state.params; cb.error_code = bt_mesh_sensor_client_set_state(&common, - (void *)arg->sensor_client_set_state.set_state, (void *)&cb.status_cb); + (void *)arg->sensor_client_set_state.set_state, (void *)&cb.status_cb); if (cb.error_code) { /* If send failed, callback error_code to app layer immediately */ btc_ble_mesh_sensor_client_callback(&cb, ESP_BLE_MESH_SENSOR_CLIENT_SET_STATE_EVT); @@ -632,8 +632,8 @@ void btc_ble_mesh_sensor_client_cb_handler(btc_msg_t *msg) /* Sensor Server Models related functions */ static inline void btc_ble_mesh_sensor_server_cb_to_app( - esp_ble_mesh_sensor_server_cb_event_t event, - esp_ble_mesh_sensor_server_cb_param_t *param) + esp_ble_mesh_sensor_server_cb_event_t event, + esp_ble_mesh_sensor_server_cb_param_t *param) { esp_ble_mesh_sensor_server_cb_t btc_ble_mesh_cb = (esp_ble_mesh_sensor_server_cb_t)btc_profile_cb_get(BTC_PID_SENSOR_SERVER); @@ -656,7 +656,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des switch (msg->act) { case ESP_BLE_MESH_SENSOR_SERVER_STATE_CHANGE_EVT: if (p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET || - p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET_UNACK) { + p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET_UNACK) { if (p_src_data->value.state_change.sensor_cadence_set.trigger_delta_down) { length = p_src_data->value.state_change.sensor_cadence_set.trigger_delta_down->len; p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_down = bt_mesh_alloc_buf(length); @@ -702,7 +702,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des p_src_data->value.state_change.sensor_cadence_set.fast_cadence_high->len); } } else if (p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET || - p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET_UNACK) { + p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET_UNACK) { if (p_src_data->value.state_change.sensor_setting_set.setting_value) { length = p_src_data->value.state_change.sensor_setting_set.setting_value->len; p_dest_data->value.state_change.sensor_setting_set.setting_value = bt_mesh_alloc_buf(length); @@ -745,7 +745,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des break; case ESP_BLE_MESH_SENSOR_SERVER_RECV_SET_MSG_EVT: if (p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET || - p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET_UNACK) { + p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET_UNACK) { if (p_src_data->value.set.sensor_cadence.cadence) { length = p_src_data->value.set.sensor_cadence.cadence->len; p_dest_data->value.set.sensor_cadence.cadence = bt_mesh_alloc_buf(length); @@ -758,7 +758,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des p_src_data->value.set.sensor_cadence.cadence->len); } } else if (p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET || - p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET_UNACK) { + p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET_UNACK) { if (p_src_data->value.set.sensor_setting.setting_raw) { length = p_src_data->value.set.sensor_setting.setting_raw->len; p_dest_data->value.set.sensor_setting.setting_raw = bt_mesh_alloc_buf(length); @@ -791,13 +791,13 @@ static void btc_ble_mesh_sensor_server_free_req_data(btc_msg_t *msg) switch (msg->act) { case ESP_BLE_MESH_SENSOR_SERVER_STATE_CHANGE_EVT: if (arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET || - arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET_UNACK) { + arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET_UNACK) { bt_mesh_free_buf(arg->value.state_change.sensor_cadence_set.trigger_delta_down); bt_mesh_free_buf(arg->value.state_change.sensor_cadence_set.trigger_delta_up); bt_mesh_free_buf(arg->value.state_change.sensor_cadence_set.fast_cadence_low); bt_mesh_free_buf(arg->value.state_change.sensor_cadence_set.fast_cadence_high); } else if (arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET || - arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET_UNACK) { + arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET_UNACK) { bt_mesh_free_buf(arg->value.state_change.sensor_setting_set.setting_value); } break; @@ -810,10 +810,10 @@ static void btc_ble_mesh_sensor_server_free_req_data(btc_msg_t *msg) break; case ESP_BLE_MESH_SENSOR_SERVER_RECV_SET_MSG_EVT: if (arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET || - arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET_UNACK) { + arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET_UNACK) { bt_mesh_free_buf(arg->value.set.sensor_cadence.cadence); } else if (arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET || - arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET_UNACK) { + arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET_UNACK) { bt_mesh_free_buf(arg->value.set.sensor_setting.setting_raw); } break; diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_time_scene_model.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_time_scene_model.c index 9b39b3b2d..aeb65657e 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_time_scene_model.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_time_scene_model.c @@ -217,7 +217,7 @@ static void btc_ble_mesh_time_scene_client_callback(esp_ble_mesh_time_scene_clie msg.act = act; btc_transfer_context(&msg, cb_params, - sizeof(esp_ble_mesh_time_scene_client_cb_param_t), btc_ble_mesh_time_scene_client_copy_req_data); + sizeof(esp_ble_mesh_time_scene_client_cb_param_t), btc_ble_mesh_time_scene_client_copy_req_data); } void bt_mesh_time_scene_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type, @@ -285,7 +285,7 @@ void btc_ble_mesh_time_scene_client_publish_callback(u32_t opcode, } bt_mesh_time_scene_client_cb_evt_to_btc(opcode, - BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_PUBLISH, model, ctx, buf->data, buf->len); + BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_PUBLISH, model, ctx, buf->data, buf->len); return; } @@ -324,7 +324,7 @@ void btc_ble_mesh_time_scene_client_call_handler(btc_msg_t *msg) cb.params = arg->time_scene_client_get_state.params; cb.error_code = bt_mesh_time_scene_client_get_state(&common, - (void *)arg->time_scene_client_get_state.get_state, (void *)&cb.status_cb); + (void *)arg->time_scene_client_get_state.get_state, (void *)&cb.status_cb); if (cb.error_code) { /* If send failed, callback error_code to app layer immediately */ btc_ble_mesh_time_scene_client_callback(&cb, ESP_BLE_MESH_TIME_SCENE_CLIENT_GET_STATE_EVT); @@ -350,7 +350,7 @@ void btc_ble_mesh_time_scene_client_call_handler(btc_msg_t *msg) cb.params = arg->time_scene_client_set_state.params; cb.error_code = bt_mesh_time_scene_client_set_state(&common, - (void *)arg->time_scene_client_set_state.set_state, (void *)&cb.status_cb); + (void *)arg->time_scene_client_set_state.set_state, (void *)&cb.status_cb); if (cb.error_code) { /* If send failed, callback error_code to app layer immediately */ btc_ble_mesh_time_scene_client_callback(&cb, ESP_BLE_MESH_TIME_SCENE_CLIENT_SET_STATE_EVT); @@ -389,8 +389,8 @@ void btc_ble_mesh_time_scene_client_cb_handler(btc_msg_t *msg) /* Time and Scenes Server Models related functions */ static inline void btc_ble_mesh_time_scene_server_cb_to_app( - esp_ble_mesh_time_scene_server_cb_event_t event, - esp_ble_mesh_time_scene_server_cb_param_t *param) + esp_ble_mesh_time_scene_server_cb_event_t event, + esp_ble_mesh_time_scene_server_cb_param_t *param) { esp_ble_mesh_time_scene_server_cb_t btc_ble_mesh_cb = (esp_ble_mesh_time_scene_server_cb_t)btc_profile_cb_get(BTC_PID_TIME_SCENE_SERVER); diff --git a/components/bt/esp_ble_mesh/mesh_core/include/mesh_aes_encrypt.h b/components/bt/esp_ble_mesh/mesh_common/include/mesh_aes_encrypt.h similarity index 100% rename from components/bt/esp_ble_mesh/mesh_core/include/mesh_aes_encrypt.h rename to components/bt/esp_ble_mesh/mesh_common/include/mesh_aes_encrypt.h diff --git a/components/bt/esp_ble_mesh/mesh_core/include/mesh_atomic.h b/components/bt/esp_ble_mesh/mesh_common/include/mesh_atomic.h similarity index 100% rename from components/bt/esp_ble_mesh/mesh_core/include/mesh_atomic.h rename to components/bt/esp_ble_mesh/mesh_common/include/mesh_atomic.h diff --git a/components/bt/esp_ble_mesh/mesh_core/include/mesh_buf.h b/components/bt/esp_ble_mesh/mesh_common/include/mesh_buf.h similarity index 99% rename from components/bt/esp_ble_mesh/mesh_core/include/mesh_buf.h rename to components/bt/esp_ble_mesh/mesh_common/include/mesh_buf.h index e6c62877e..6f1991dcc 100644 --- a/components/bt/esp_ble_mesh/mesh_core/include/mesh_buf.h +++ b/components/bt/esp_ble_mesh/mesh_common/include/mesh_buf.h @@ -544,8 +544,8 @@ struct net_buf { }; struct net_buf_data_cb { - u8_t * (*alloc)(struct net_buf *buf, size_t *size, s32_t timeout); - u8_t * (*ref)(struct net_buf *buf, u8_t *data); + u8_t *(*alloc)(struct net_buf *buf, size_t *size, s32_t timeout); + u8_t *(*ref)(struct net_buf *buf, u8_t *data); void (*unref)(struct net_buf *buf, u8_t *data); }; @@ -709,7 +709,7 @@ int net_buf_id(struct net_buf *buf); */ #if defined(CONFIG_BLE_MESH_NET_BUF_LOG) struct net_buf *net_buf_alloc_fixed_debug(struct net_buf_pool *pool, s32_t timeout, - const char *func, int line); + const char *func, int line); #define net_buf_alloc_fixed(_pool, _timeout) \ net_buf_alloc_fixed_debug(_pool, _timeout, __func__, __LINE__) #else diff --git a/components/bt/esp_ble_mesh/mesh_models/common/include/mesh_common.h b/components/bt/esp_ble_mesh/mesh_common/include/mesh_common.h similarity index 99% rename from components/bt/esp_ble_mesh/mesh_models/common/include/mesh_common.h rename to components/bt/esp_ble_mesh/mesh_common/include/mesh_common.h index 2355bf0f3..dd058c70a 100644 --- a/components/bt/esp_ble_mesh/mesh_models/common/include/mesh_common.h +++ b/components/bt/esp_ble_mesh/mesh_common/include/mesh_common.h @@ -46,7 +46,7 @@ void bt_mesh_free_buf(struct net_buf_simple *buf); /** * @brief This function gets device role for stack internal use. - * + * * @Note Currently Provisioner only support client models, Node supports * client models and server models. Hence if srv_send is set to be * TRUE, then role NODE will be returned. diff --git a/components/bt/esp_ble_mesh/mesh_core/include/mesh_dlist.h b/components/bt/esp_ble_mesh/mesh_common/include/mesh_dlist.h similarity index 100% rename from components/bt/esp_ble_mesh/mesh_core/include/mesh_dlist.h rename to components/bt/esp_ble_mesh/mesh_common/include/mesh_dlist.h diff --git a/components/bt/esp_ble_mesh/mesh_core/include/mesh_kernel.h b/components/bt/esp_ble_mesh/mesh_common/include/mesh_kernel.h similarity index 100% rename from components/bt/esp_ble_mesh/mesh_core/include/mesh_kernel.h rename to components/bt/esp_ble_mesh/mesh_common/include/mesh_kernel.h diff --git a/components/bt/esp_ble_mesh/mesh_core/include/mesh_slist.h b/components/bt/esp_ble_mesh/mesh_common/include/mesh_slist.h similarity index 100% rename from components/bt/esp_ble_mesh/mesh_core/include/mesh_slist.h rename to components/bt/esp_ble_mesh/mesh_common/include/mesh_slist.h diff --git a/components/bt/esp_ble_mesh/mesh_core/include/mesh_trace.h b/components/bt/esp_ble_mesh/mesh_common/include/mesh_trace.h similarity index 100% rename from components/bt/esp_ble_mesh/mesh_core/include/mesh_trace.h rename to components/bt/esp_ble_mesh/mesh_common/include/mesh_trace.h diff --git a/components/bt/esp_ble_mesh/mesh_core/include/mesh_types.h b/components/bt/esp_ble_mesh/mesh_common/include/mesh_types.h similarity index 100% rename from components/bt/esp_ble_mesh/mesh_core/include/mesh_types.h rename to components/bt/esp_ble_mesh/mesh_common/include/mesh_types.h diff --git a/components/bt/esp_ble_mesh/mesh_core/include/mesh_util.h b/components/bt/esp_ble_mesh/mesh_common/include/mesh_util.h similarity index 100% rename from components/bt/esp_ble_mesh/mesh_core/include/mesh_util.h rename to components/bt/esp_ble_mesh/mesh_common/include/mesh_util.h diff --git a/components/bt/esp_ble_mesh/mesh_core/mesh_aes_encrypt.c b/components/bt/esp_ble_mesh/mesh_common/mesh_aes_encrypt.c similarity index 100% rename from components/bt/esp_ble_mesh/mesh_core/mesh_aes_encrypt.c rename to components/bt/esp_ble_mesh/mesh_common/mesh_aes_encrypt.c diff --git a/components/bt/esp_ble_mesh/mesh_core/mesh_atomic.c b/components/bt/esp_ble_mesh/mesh_common/mesh_atomic.c similarity index 100% rename from components/bt/esp_ble_mesh/mesh_core/mesh_atomic.c rename to components/bt/esp_ble_mesh/mesh_common/mesh_atomic.c diff --git a/components/bt/esp_ble_mesh/mesh_core/mesh_buf.c b/components/bt/esp_ble_mesh/mesh_common/mesh_buf.c similarity index 96% rename from components/bt/esp_ble_mesh/mesh_core/mesh_buf.c rename to components/bt/esp_ble_mesh/mesh_common/mesh_buf.c index d6e0cd710..9e5f6c184 100644 --- a/components/bt/esp_ble_mesh/mesh_core/mesh_buf.c +++ b/components/bt/esp_ble_mesh/mesh_common/mesh_buf.c @@ -310,7 +310,7 @@ void net_buf_unref(struct net_buf *buf) } #endif NET_BUF_DBG("buf %p ref %u pool %p frags %p", buf, buf->ref, - buf->pool, buf->frags); + buf->pool, buf->frags); /* Changed by Espressif. Add !buf->ref to avoid minus 0 */ if (!buf->ref || --buf->ref > 0) { @@ -325,7 +325,7 @@ void net_buf_unref(struct net_buf *buf) #if defined(CONFIG_BLE_MESH_NET_BUF_POOL_USAGE) pool->avail_count++; NET_BUF_DBG("%s, pool %p, avail_count %d, uninit_count %d", __func__, - pool, pool->avail_count, pool->uninit_count); + pool, pool->avail_count, pool->uninit_count); NET_BUF_ASSERT(pool->avail_count <= pool->buf_count); #endif @@ -366,10 +366,10 @@ static u8_t *data_alloc(struct net_buf *buf, size_t *size, s32_t timeout) #if defined(CONFIG_BLE_MESH_NET_BUF_LOG) struct net_buf *net_buf_alloc_len_debug(struct net_buf_pool *pool, size_t size, - s32_t timeout, const char *func, int line) + s32_t timeout, const char *func, int line) #else struct net_buf *net_buf_alloc_len(struct net_buf_pool *pool, size_t size, - s32_t timeout) + s32_t timeout) #endif { struct net_buf *buf = NULL; @@ -379,7 +379,7 @@ struct net_buf *net_buf_alloc_len(struct net_buf_pool *pool, size_t size, NET_BUF_ASSERT(pool); NET_BUF_DBG("%s, pool %p, uninit_count %d, buf_count %d", __func__, - pool, pool->uninit_count, pool->buf_count); + pool, pool->uninit_count, pool->buf_count); /* We need to lock interrupts temporarily to prevent race conditions * when accessing pool->uninit_count. @@ -436,8 +436,8 @@ success: #if defined(CONFIG_BLE_MESH_NET_BUF_LOG) struct net_buf *net_buf_alloc_fixed_debug(struct net_buf_pool *pool, - s32_t timeout, const char *func, - int line) + s32_t timeout, const char *func, + int line) { const struct net_buf_pool_fixed *fixed = pool->alloc->alloc_data; diff --git a/components/bt/esp_ble_mesh/mesh_models/common/mesh_common.c b/components/bt/esp_ble_mesh/mesh_common/mesh_common.c similarity index 100% rename from components/bt/esp_ble_mesh/mesh_models/common/mesh_common.c rename to components/bt/esp_ble_mesh/mesh_common/mesh_common.c diff --git a/components/bt/esp_ble_mesh/mesh_core/mesh_kernel.c b/components/bt/esp_ble_mesh/mesh_common/mesh_kernel.c similarity index 92% rename from components/bt/esp_ble_mesh/mesh_core/mesh_kernel.c rename to components/bt/esp_ble_mesh/mesh_common/mesh_kernel.c index 037126311..1ee0aa0d7 100644 --- a/components/bt/esp_ble_mesh/mesh_core/mesh_kernel.c +++ b/components/bt/esp_ble_mesh/mesh_common/mesh_kernel.c @@ -39,25 +39,16 @@ typedef struct alarm_t { unsigned int bt_mesh_irq_lock(void) { -#if defined(CONFIG_BLE_MESH_IRQ_LOCK) && CONFIG_BLE_MESH_IRQ_LOCK - unsigned int key = XTOS_SET_INTLEVEL(XCHAL_EXCM_LEVEL); - return key; -#else - /* Change by Espressif. In BLE Mesh, in order to improve the real-time - * requirements of bt controller, we use task lock to replace IRQ lock. + /* Changed by Espressif. In BLE Mesh, in order to improve the real-time + * requirements of bt controller, we use task lock instead of IRQ lock. */ osi_mutex_lock(&bm_irq_lock, OSI_MUTEX_MAX_TIMEOUT); return 0; -#endif } void bt_mesh_irq_unlock(unsigned int key) { -#if defined(CONFIG_BLE_MESH_IRQ_LOCK) && CONFIG_BLE_MESH_IRQ_LOCK - XTOS_RESTORE_INTLEVEL(key); -#else osi_mutex_unlock(&bm_irq_lock); -#endif } s64_t k_uptime_get(void) diff --git a/components/bt/esp_ble_mesh/mesh_core/mesh_util.c b/components/bt/esp_ble_mesh/mesh_common/mesh_util.c similarity index 100% rename from components/bt/esp_ble_mesh/mesh_core/mesh_util.c rename to components/bt/esp_ble_mesh/mesh_common/mesh_util.c diff --git a/components/bt/esp_ble_mesh/mesh_core/access.c b/components/bt/esp_ble_mesh/mesh_core/access.c index be22611e2..43e6e746a 100644 --- a/components/bt/esp_ble_mesh/mesh_core/access.c +++ b/components/bt/esp_ble_mesh/mesh_core/access.c @@ -723,7 +723,7 @@ void bt_mesh_model_recv(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf) if (buf->len < op->min_len) { BT_ERR("%s, Too short message for OpCode 0x%08x", - __func__, opcode); + __func__, opcode); continue; } diff --git a/components/bt/esp_ble_mesh/mesh_core/adv.c b/components/bt/esp_ble_mesh/mesh_core/adv.c index aee8616ad..1c2fff551 100644 --- a/components/bt/esp_ble_mesh/mesh_core/adv.c +++ b/components/bt/esp_ble_mesh/mesh_core/adv.c @@ -126,7 +126,7 @@ static inline int adv_send(struct net_buf *buf) adv_int = MAX(adv_int_min, BLE_MESH_TRANSMIT_INT(BLE_MESH_ADV(buf)->xmit)); duration = (BLE_MESH_TRANSMIT_COUNT(BLE_MESH_ADV(buf)->xmit) + 1) * - (adv_int + 10); + (adv_int + 10); BT_DBG("type %u len %u: %s", BLE_MESH_ADV(buf)->type, buf->len, bt_hex(buf->data, buf->len)); @@ -300,7 +300,7 @@ struct net_buf *bt_mesh_adv_create_from_pool(struct net_buf_pool *pool, } BT_DBG("%s, pool = %p, buf_count = %d, uinit_count = %d", __func__, - buf->pool, pool->buf_count, pool->uninit_count); + buf->pool, pool->buf_count, pool->uninit_count); adv = get_id(net_buf_id(buf)); BLE_MESH_ADV(buf) = adv; @@ -395,7 +395,7 @@ static struct bt_mesh_adv *relay_adv_alloc(int id) } struct net_buf *bt_mesh_relay_adv_create(enum bt_mesh_adv_type type, u8_t xmit, - s32_t timeout) + s32_t timeout) { return bt_mesh_adv_create_from_pool(&relay_adv_buf_pool, relay_adv_alloc, type, xmit, timeout); @@ -440,7 +440,7 @@ static void ble_mesh_relay_task_post(bt_mesh_msg_t *msg, uint32_t timeout) } void bt_mesh_relay_adv_send(struct net_buf *buf, const struct bt_mesh_send_cb *cb, - void *cb_data, u16_t src, u16_t dst) + void *cb_data, u16_t src, u16_t dst) { bt_mesh_msg_t msg = { .relay = true, @@ -504,17 +504,17 @@ static bool bt_mesh_is_adv_srv_uuid_valid(struct net_buf_simple *buf, u16_t *uui BT_DBG("Received adv pkt with service UUID: %d", *uuid); if (*uuid != BLE_MESH_UUID_MESH_PROV_VAL && - *uuid != BLE_MESH_UUID_MESH_PROXY_VAL) { + *uuid != BLE_MESH_UUID_MESH_PROXY_VAL) { return false; } if (*uuid == BLE_MESH_UUID_MESH_PROV_VAL && - bt_mesh_is_provisioner_en() == false) { + bt_mesh_is_provisioner_en() == false) { return false; } if (*uuid == BLE_MESH_UUID_MESH_PROXY_VAL && - !IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_CLIENT)) { + !IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_CLIENT)) { return false; } @@ -557,7 +557,7 @@ static void bt_mesh_adv_srv_data_recv(struct net_buf_simple *buf, const bt_mesh_ #if CONFIG_BLE_MESH_GATT_PROXY_CLIENT case BLE_MESH_UUID_MESH_PROXY_VAL: if (buf->len != BLE_MESH_PROXY_SRV_DATA_LEN1 && - buf->len != BLE_MESH_PROXY_SRV_DATA_LEN2) { + buf->len != BLE_MESH_PROXY_SRV_DATA_LEN2) { BT_WARN("%s, Invalid Mesh Proxy Service Data length %d", __func__, buf->len); return; } @@ -612,9 +612,9 @@ static void bt_mesh_scan_cb(const bt_mesh_addr_t *addr, s8_t rssi, #if 0 /* TODO: Check with BLE Mesh BQB test cases */ if ((type == BLE_MESH_DATA_MESH_PROV || type == BLE_MESH_DATA_MESH_MESSAGE || - type == BLE_MESH_DATA_MESH_BEACON) && (adv_type != BLE_MESH_ADV_NONCONN_IND)) { + type == BLE_MESH_DATA_MESH_BEACON) && (adv_type != BLE_MESH_ADV_NONCONN_IND)) { BT_DBG("%s, ignore BLE Mesh packet (type 0x%02x) with adv_type 0x%02x", - __func__, type, adv_type); + __func__, type, adv_type); return; } #endif @@ -691,7 +691,7 @@ void bt_mesh_adv_init(void) xQueueAddToSet(xBleMeshRelayQueue, xBleMeshQueueSet); #endif /* defined(CONFIG_BLE_MESH_RELAY_ADV_BUF) */ int ret = xTaskCreatePinnedToCore(adv_thread, "BLE_Mesh_ADV_Task", 3072, NULL, - configMAX_PRIORITIES - 7, NULL, ADV_TASK_CORE); + configMAX_PRIORITIES - 7, NULL, ADV_TASK_CORE); configASSERT(ret == pdTRUE); } diff --git a/components/bt/esp_ble_mesh/mesh_core/adv.h b/components/bt/esp_ble_mesh/mesh_core/adv.h index 10b62e2fd..9762de62e 100644 --- a/components/bt/esp_ble_mesh/mesh_core/adv.h +++ b/components/bt/esp_ble_mesh/mesh_core/adv.h @@ -74,7 +74,7 @@ void bt_mesh_adv_send(struct net_buf *buf, const struct bt_mesh_send_cb *cb, const bt_mesh_addr_t *bt_mesh_pba_get_addr(void); struct net_buf *bt_mesh_relay_adv_create(enum bt_mesh_adv_type type, u8_t xmit, - s32_t timeout); + s32_t timeout); void bt_mesh_relay_adv_send(struct net_buf *buf, const struct bt_mesh_send_cb *cb, void *cb_data, u16_t src, u16_t dst); diff --git a/components/bt/esp_ble_mesh/mesh_core/bluedroid_host/mesh_bearer_adapt.c b/components/bt/esp_ble_mesh/mesh_core/bluedroid_host/mesh_bearer_adapt.c index 1bc370fa9..bf22f102a 100644 --- a/components/bt/esp_ble_mesh/mesh_core/bluedroid_host/mesh_bearer_adapt.c +++ b/components/bt/esp_ble_mesh/mesh_core/bluedroid_host/mesh_bearer_adapt.c @@ -47,7 +47,7 @@ struct bt_mesh_dev bt_mesh_dev; #define BLE_MESH_GATT_GET_CONN_ID(conn_id) (((u16_t)(conn_id)) >> 8) #define BLE_MESH_GATT_CREATE_CONN_ID(gatt_if, conn_id) ((u16_t)((((u8_t)(conn_id)) << 8) | ((u8_t)(gatt_if)))) -/* We don't need to manage the BLE_MESH_DEV_ADVERTISING flags in the version of bluedriod, +/* We don't need to manage the BLE_MESH_DEV_ADVERTISING flags in the version of bluedriod, * it will manage it in the BTM layer. */ #define BLE_MESH_DEV 0 @@ -136,7 +136,7 @@ void bt_mesh_hci_init(void) } static void bt_mesh_scan_results_change_2_bta(tBTM_INQ_RESULTS *p_inq, u8_t *p_eir, - tBTA_DM_SEARCH_CBACK *p_scan_cback) + tBTA_DM_SEARCH_CBACK *p_scan_cback) { tBTM_INQ_INFO *p_inq_info; tBTA_DM_SEARCH result; @@ -512,9 +512,9 @@ static void bt_mesh_bta_gatts_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data) if (attr != NULL && attr->write != NULL) { if ((len = attr->write(&bt_mesh_gatts_conn[index], attr, - p_data->req_data.p_data->write_req.value, - p_data->req_data.p_data->write_req.len, - p_data->req_data.p_data->write_req.offset, 0)) > 0) { + p_data->req_data.p_data->write_req.value, + p_data->req_data.p_data->write_req.len, + p_data->req_data.p_data->write_req.offset, 0)) > 0) { if (p_data->req_data.p_data->write_req.need_rsp) { BTA_GATTS_SendRsp(p_data->req_data.conn_id, p_data->req_data.trans_id, p_data->req_data.status, NULL); @@ -627,7 +627,7 @@ static struct bt_mesh_gatt_attr *bt_mesh_gatts_find_attr_by_handle(u16_t handle) } static void bt_mesh_gatts_foreach_attr(u16_t start_handle, u16_t end_handle, - bt_mesh_gatt_attr_func_t func, void *user_data) + bt_mesh_gatt_attr_func_t func, void *user_data) { struct bt_mesh_gatt_service *svc = NULL; @@ -694,8 +694,8 @@ struct gatts_incl { } __packed; ssize_t bt_mesh_gatts_attr_read_included(struct bt_mesh_conn *conn, - const struct bt_mesh_gatt_attr *attr, - void *buf, u16_t len, u16_t offset) + const struct bt_mesh_gatt_attr *attr, + void *buf, u16_t len, u16_t offset) { struct bt_mesh_gatt_attr *incl = attr->user_data; struct bt_mesh_uuid *uuid = incl->user_data; @@ -731,7 +731,7 @@ ssize_t bt_mesh_gatts_attr_read_service(struct bt_mesh_conn *conn, } return bt_mesh_gatts_attr_read(conn, attr, buf, len, offset, - BLE_MESH_UUID_128(uuid)->val, 16); + BLE_MESH_UUID_128(uuid)->val, 16); } struct gatts_chrc { @@ -1027,7 +1027,7 @@ u8_t bt_mesh_gattc_get_free_conn_count(void) for (i = 0U; i < ARRAY_SIZE(bt_mesh_gattc_info); i++) { if (bt_mesh_gattc_info[i].conn.handle == 0xFFFF && - bt_mesh_gattc_info[i].service_uuid == 0x0000) { + bt_mesh_gattc_info[i].service_uuid == 0x0000) { ++count; } } @@ -1065,13 +1065,13 @@ int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, u16_t service_uuid) int i; if (!addr || !memcmp(addr->val, zero, BLE_MESH_ADDR_LEN) || - (addr->type > BLE_ADDR_RANDOM)) { + (addr->type > BLE_ADDR_RANDOM)) { BT_ERR("%s, Invalid remote address", __func__); return -EINVAL; } if (service_uuid != BLE_MESH_UUID_MESH_PROV_VAL && - service_uuid != BLE_MESH_UUID_MESH_PROXY_VAL) { + service_uuid != BLE_MESH_UUID_MESH_PROXY_VAL) { BT_ERR("%s, Invalid service uuid 0x%04x", __func__, service_uuid); return -EINVAL; } @@ -1080,7 +1080,7 @@ int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, u16_t service_uuid) for (i = 0; i < ARRAY_SIZE(bt_mesh_gattc_info); i++) { if (!memcmp(bt_mesh_gattc_info[i].addr.val, addr->val, BLE_MESH_ADDR_LEN)) { BT_WARN("%s, Already create connection with %s", - __func__, bt_hex(addr->val, BLE_MESH_ADDR_LEN)); + __func__, bt_hex(addr->val, BLE_MESH_ADDR_LEN)); return -EALREADY; } } @@ -1088,7 +1088,7 @@ int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, u16_t service_uuid) /* Find empty element in queue to store device info */ for (i = 0; i < ARRAY_SIZE(bt_mesh_gattc_info); i++) { if ((bt_mesh_gattc_info[i].conn.handle == 0xFFFF) && - (bt_mesh_gattc_info[i].service_uuid == 0x0000)) { + (bt_mesh_gattc_info[i].service_uuid == 0x0000)) { memcpy(bt_mesh_gattc_info[i].addr.val, addr->val, BLE_MESH_ADDR_LEN); bt_mesh_gattc_info[i].addr.type = addr->type; /* Service to be found after exhanging mtu size */ @@ -1120,7 +1120,7 @@ int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, u16_t service_uuid) BTA_DmSetBlePrefConnParams(bt_mesh_gattc_info[i].addr.val, 0xC8, 0xC8, 0x00, 0xC80); BTA_GATTC_Open(bt_mesh_gattc_if, bt_mesh_gattc_info[i].addr.val, - bt_mesh_gattc_info[i].addr.type, true, BTA_GATT_TRANSPORT_LE); + bt_mesh_gattc_info[i].addr.type, true, BTA_GATT_TRANSPORT_LE); return i; } @@ -1254,7 +1254,7 @@ static void bt_mesh_bta_gattc_cb(tBTA_GATTC_EVT event, tBTA_GATTC *p_data) for (i = 0; i < ARRAY_SIZE(bt_mesh_gattc_info); i++) { if (bt_mesh_gattc_info[i].conn.handle == handle) { if (p_data->srvc_res.service_uuid.uuid.len == 2 && - p_data->srvc_res.service_uuid.uuid.uu.uuid16 == bt_mesh_gattc_info[i].service_uuid) { + p_data->srvc_res.service_uuid.uuid.uu.uuid16 == bt_mesh_gattc_info[i].service_uuid) { bt_mesh_gattc_info[i].start_handle = p_data->srvc_res.start_handle; bt_mesh_gattc_info[i].end_handle = p_data->srvc_res.end_handle; } @@ -1484,7 +1484,7 @@ static void bt_mesh_bta_gattc_cb(tBTA_GATTC_EVT event, tBTA_GATTC *p_data) if (bt_mesh_gattc_info[i].service_uuid == BLE_MESH_UUID_MESH_PROV_VAL) { if (bt_mesh_gattc_conn_cb != NULL && bt_mesh_gattc_conn_cb->prov_notify != NULL) { len = bt_mesh_gattc_conn_cb->prov_notify(&bt_mesh_gattc_info[i].conn, - p_data->notify.value, p_data->notify.len); + p_data->notify.value, p_data->notify.len); if (len < 0) { BT_ERR("%s, prov_notify failed", __func__); bt_mesh_gattc_disconnect(conn); @@ -1494,7 +1494,7 @@ static void bt_mesh_bta_gattc_cb(tBTA_GATTC_EVT event, tBTA_GATTC *p_data) } else if (bt_mesh_gattc_info[i].service_uuid == BLE_MESH_UUID_MESH_PROXY_VAL) { if (bt_mesh_gattc_conn_cb != NULL && bt_mesh_gattc_conn_cb->proxy_notify != NULL) { len = bt_mesh_gattc_conn_cb->proxy_notify(&bt_mesh_gattc_info[i].conn, - p_data->notify.value, p_data->notify.len); + p_data->notify.value, p_data->notify.len); if (len < 0) { BT_ERR("%s, proxy_notify failed", __func__); bt_mesh_gattc_disconnect(conn); @@ -1876,7 +1876,7 @@ int bt_mesh_update_exceptional_list(u8_t sub_code, u8_t type, void *info) BD_ADDR value = {0}; if ((sub_code > BLE_MESH_EXCEP_LIST_CLEAN) || - (type > BLE_MESH_EXCEP_INFO_MESH_PROXY_ADV)) { + (type > BLE_MESH_EXCEP_INFO_MESH_PROXY_ADV)) { BT_ERR("%s, Invalid parameter", __func__); return -EINVAL; } diff --git a/components/bt/esp_ble_mesh/mesh_core/cfg_cli.c b/components/bt/esp_ble_mesh/mesh_core/cfg_cli.c index c975b5600..c3e73c23f 100644 --- a/components/bt/esp_ble_mesh/mesh_core/cfg_cli.c +++ b/components/bt/esp_ble_mesh/mesh_core/cfg_cli.c @@ -120,7 +120,7 @@ static void timeout_handler(struct k_work *work) node = CONTAINER_OF(work, bt_mesh_client_node_t, timer.work); if (node) { bt_mesh_config_client_cb_evt_to_btc(node->opcode, - BTC_BLE_MESH_EVT_CONFIG_CLIENT_TIMEOUT, node->ctx.model, &node->ctx, NULL, 0); + BTC_BLE_MESH_EVT_CONFIG_CLIENT_TIMEOUT, node->ctx.model, &node->ctx, NULL, 0); // Don't forget to release the node at the end. bt_mesh_client_free_node(node); } diff --git a/components/bt/esp_ble_mesh/mesh_core/cfg_srv.c b/components/bt/esp_ble_mesh/mesh_core/cfg_srv.c index 7358d0676..c7f72a07d 100644 --- a/components/bt/esp_ble_mesh/mesh_core/cfg_srv.c +++ b/components/bt/esp_ble_mesh/mesh_core/cfg_srv.c @@ -478,7 +478,7 @@ static void app_key_add(struct bt_mesh_model *model, change.cfg_appkey_add.app_idx = key_app_idx; memcpy(change.cfg_appkey_add.app_key, buf->data, 16); bt_mesh_config_server_cb_evt_to_btc(BTC_BLE_MESH_EVT_CONFIG_SERVER_STATE_CHANGE, - model, ctx, (const u8_t *)&change, sizeof(change)); + model, ctx, (const u8_t *)&change, sizeof(change)); } } @@ -512,7 +512,7 @@ static void app_key_update(struct bt_mesh_model *model, change.cfg_appkey_update.app_idx = key_app_idx; memcpy(change.cfg_appkey_update.app_key, buf->data, 16); bt_mesh_config_server_cb_evt_to_btc(BTC_BLE_MESH_EVT_CONFIG_SERVER_STATE_CHANGE, - model, ctx, (const u8_t *)&change, sizeof(change)); + model, ctx, (const u8_t *)&change, sizeof(change)); } } @@ -596,7 +596,7 @@ send_status: change.cfg_appkey_delete.net_idx = key_net_idx; change.cfg_appkey_delete.app_idx = key_app_idx; bt_mesh_config_server_cb_evt_to_btc(BTC_BLE_MESH_EVT_CONFIG_SERVER_STATE_CHANGE, - model, ctx, (const u8_t *)&change, sizeof(change)); + model, ctx, (const u8_t *)&change, sizeof(change)); } } @@ -1158,7 +1158,7 @@ send_status: change.cfg_mod_pub_set.cid = vnd ? mod->vnd.company : 0xFFFF; change.cfg_mod_pub_set.mod_id = vnd ? mod->vnd.id : mod->id; bt_mesh_config_server_cb_evt_to_btc(BTC_BLE_MESH_EVT_CONFIG_SERVER_STATE_CHANGE, - model, ctx, (const u8_t *)&change, sizeof(change)); + model, ctx, (const u8_t *)&change, sizeof(change)); } } @@ -1491,7 +1491,7 @@ send_status: change.cfg_mod_sub_add.cid = vnd ? mod->vnd.company : 0xFFFF; change.cfg_mod_sub_add.mod_id = vnd ? mod->vnd.id : mod->id; bt_mesh_config_server_cb_evt_to_btc(BTC_BLE_MESH_EVT_CONFIG_SERVER_STATE_CHANGE, - model, ctx, (const u8_t *)&change, sizeof(change)); + model, ctx, (const u8_t *)&change, sizeof(change)); } } @@ -1567,7 +1567,7 @@ send_status: change.cfg_mod_sub_delete.cid = vnd ? mod->vnd.company : 0xFFFF; change.cfg_mod_sub_delete.mod_id = vnd ? mod->vnd.id : mod->id; bt_mesh_config_server_cb_evt_to_btc(BTC_BLE_MESH_EVT_CONFIG_SERVER_STATE_CHANGE, - model, ctx, (const u8_t *)&change, sizeof(change)); + model, ctx, (const u8_t *)&change, sizeof(change)); } } @@ -2238,7 +2238,7 @@ static void net_key_add(struct bt_mesh_model *model, change.cfg_netkey_add.net_idx = sub->net_idx; memcpy(change.cfg_netkey_add.net_key, sub->keys[0].net, 16); bt_mesh_config_server_cb_evt_to_btc(BTC_BLE_MESH_EVT_CONFIG_SERVER_STATE_CHANGE, - model, ctx, (const u8_t *)&change, sizeof(change)); + model, ctx, (const u8_t *)&change, sizeof(change)); } static void net_key_update(struct bt_mesh_model *model, @@ -2313,7 +2313,7 @@ static void net_key_update(struct bt_mesh_model *model, change.cfg_netkey_update.net_idx = sub->net_idx; memcpy(change.cfg_netkey_update.net_key, sub->keys[1].net, 16); bt_mesh_config_server_cb_evt_to_btc(BTC_BLE_MESH_EVT_CONFIG_SERVER_STATE_CHANGE, - model, ctx, (const u8_t *)&change, sizeof(change)); + model, ctx, (const u8_t *)&change, sizeof(change)); } static void hb_pub_disable(struct bt_mesh_cfg_srv *cfg) @@ -2371,7 +2371,7 @@ send_status: bt_mesh_cfg_server_state_change_t change = {0}; change.cfg_netkey_delete.net_idx = sub->net_idx; bt_mesh_config_server_cb_evt_to_btc(BTC_BLE_MESH_EVT_CONFIG_SERVER_STATE_CHANGE, - model, ctx, (const u8_t *)&change, sizeof(change)); + model, ctx, (const u8_t *)&change, sizeof(change)); } } @@ -2586,7 +2586,7 @@ send_status: change.cfg_mod_app_bind.cid = vnd ? mod->vnd.company : 0xFFFF; change.cfg_mod_app_bind.mod_id = vnd ? mod->vnd.id : mod->id; bt_mesh_config_server_cb_evt_to_btc(BTC_BLE_MESH_EVT_CONFIG_SERVER_STATE_CHANGE, - model, ctx, (const u8_t *)&change, sizeof(change)); + model, ctx, (const u8_t *)&change, sizeof(change)); } } @@ -2642,7 +2642,7 @@ send_status: change.cfg_mod_app_unbind.cid = vnd ? mod->vnd.company : 0xFFFF; change.cfg_mod_app_unbind.mod_id = vnd ? mod->vnd.id : mod->id; bt_mesh_config_server_cb_evt_to_btc(BTC_BLE_MESH_EVT_CONFIG_SERVER_STATE_CHANGE, - model, ctx, (const u8_t *)&change, sizeof(change)); + model, ctx, (const u8_t *)&change, sizeof(change)); } } @@ -2957,7 +2957,7 @@ static void krp_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, change.cfg_kr_phase_set.net_idx = idx; change.cfg_kr_phase_set.kr_phase = phase; bt_mesh_config_server_cb_evt_to_btc(BTC_BLE_MESH_EVT_CONFIG_SERVER_STATE_CHANGE, - model, ctx, (const u8_t *)&change, sizeof(change)); + model, ctx, (const u8_t *)&change, sizeof(change)); } static u8_t hb_log(u16_t val) @@ -3230,7 +3230,7 @@ static void heartbeat_sub_set(struct bt_mesh_model *model, * MESH/NODE/CFG/HBS/BV-02-C. */ if (sub_src == BLE_MESH_ADDR_UNASSIGNED || - sub_dst == BLE_MESH_ADDR_UNASSIGNED) { + sub_dst == BLE_MESH_ADDR_UNASSIGNED) { cfg->hb_sub.src = BLE_MESH_ADDR_UNASSIGNED; cfg->hb_sub.dst = BLE_MESH_ADDR_UNASSIGNED; cfg->hb_sub.min_hops = BLE_MESH_TTL_MAX; diff --git a/components/bt/esp_ble_mesh/mesh_core/friend.c b/components/bt/esp_ble_mesh/mesh_core/friend.c index 870235e45..1830a17e7 100644 --- a/components/bt/esp_ble_mesh/mesh_core/friend.c +++ b/components/bt/esp_ble_mesh/mesh_core/friend.c @@ -902,8 +902,8 @@ init_friend: } static struct bt_mesh_friend_seg *get_seg(struct bt_mesh_friend *frnd, - u16_t src, u64_t *seq_auth, - u8_t seg_count) + u16_t src, u64_t *seq_auth, + u8_t seg_count) { struct bt_mesh_friend_seg *unassigned = NULL; int i; @@ -951,7 +951,7 @@ static void enqueue_friend_pdu(struct bt_mesh_friend *frnd, seg = get_seg(frnd, BLE_MESH_ADV(buf)->addr, &adv->seq_auth, seg_count); if (!seg) { BT_ERR("%s, No free friend segment RX contexts for 0x%04x", - __func__, BLE_MESH_ADV(buf)->addr); + __func__, BLE_MESH_ADV(buf)->addr); net_buf_unref(buf); return; } @@ -1275,7 +1275,7 @@ static bool friend_queue_has_space(struct bt_mesh_friend *frnd, u16_t addr, */ buf = (void *)sys_slist_peek_head(&seg->queue); if (buf && BLE_MESH_ADV(buf)->addr == addr && - FRIEND_ADV(buf)->seq_auth == *seq_auth) { + FRIEND_ADV(buf)->seq_auth == *seq_auth) { return true; } } @@ -1383,7 +1383,7 @@ void bt_mesh_friend_enqueue_rx(struct bt_mesh_net_rx *rx, struct bt_mesh_friend *frnd = &bt_mesh.frnd[i]; if (!friend_lpn_matches(frnd, rx->sub->net_idx, - rx->ctx.recv_dst)) { + rx->ctx.recv_dst)) { continue; } diff --git a/components/bt/esp_ble_mesh/mesh_core/health_cli.c b/components/bt/esp_ble_mesh/mesh_core/health_cli.c index 363e95c55..0d5d5c813 100644 --- a/components/bt/esp_ble_mesh/mesh_core/health_cli.c +++ b/components/bt/esp_ble_mesh/mesh_core/health_cli.c @@ -76,7 +76,7 @@ static void timeout_handler(struct k_work *work) node = CONTAINER_OF(work, bt_mesh_client_node_t, timer.work); if (node) { bt_mesh_health_client_cb_evt_to_btc(node->opcode, - BTC_BLE_MESH_EVT_HEALTH_CLIENT_TIMEOUT, node->ctx.model, &node->ctx, NULL, 0); + BTC_BLE_MESH_EVT_HEALTH_CLIENT_TIMEOUT, node->ctx.model, &node->ctx, NULL, 0); // Don't forget to release the node at the end. bt_mesh_client_free_node(node); } 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 6b1aaf01c..2c54005d1 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 @@ -446,7 +446,7 @@ typedef void (*bt_mesh_dh_key_cb_t)(const u8_t key[32], const u8_t idx); * or BLE_MESH_GATT_ITER_STOP to stop. */ typedef u8_t (*bt_mesh_gatt_attr_func_t)(const struct bt_mesh_gatt_attr *attr, - void *user_data); + void *user_data); /** @brief Connection callback structure. * @@ -657,20 +657,20 @@ int bt_mesh_gatts_service_register(struct bt_mesh_gatt_service *svc); int bt_mesh_gatts_service_unregister(struct bt_mesh_gatt_service *svc); ssize_t bt_mesh_gatts_attr_read_included(struct bt_mesh_conn *conn, - const struct bt_mesh_gatt_attr *attr, - void *buf, u16_t len, u16_t offset); + const struct bt_mesh_gatt_attr *attr, + void *buf, u16_t len, u16_t offset); ssize_t bt_mesh_gatts_attr_read(struct bt_mesh_conn *conn, const struct bt_mesh_gatt_attr *attr, void *buf, u16_t buf_len, u16_t offset, const void *value, u16_t value_len); ssize_t bt_mesh_gatts_attr_read_service(struct bt_mesh_conn *conn, - const struct bt_mesh_gatt_attr *attr, - void *buf, u16_t len, u16_t offset); + const struct bt_mesh_gatt_attr *attr, + void *buf, u16_t len, u16_t offset); ssize_t bt_mesh_gatts_attr_read_chrc(struct bt_mesh_conn *conn, - const struct bt_mesh_gatt_attr *attr, void *buf, - u16_t len, u16_t offset); + const struct bt_mesh_gatt_attr *attr, void *buf, + u16_t len, u16_t offset); int bt_mesh_gatts_notify(struct bt_mesh_conn *conn, const struct bt_mesh_gatt_attr *attr, const void *data, u16_t len); @@ -719,10 +719,10 @@ bool bt_mesh_check_public_key(const uint8_t key[64]); int bt_mesh_dh_key_gen(const u8_t remote_pk[64], bt_mesh_dh_key_cb_t cb, const u8_t idx); int bt_mesh_encrypt_le(const u8_t key[16], const u8_t plaintext[16], - u8_t enc_data[16]); + u8_t enc_data[16]); int bt_mesh_encrypt_be(const u8_t key[16], const u8_t plaintext[16], - u8_t enc_data[16]); + u8_t enc_data[16]); enum { BLE_MESH_EXCEP_LIST_ADD = 0, diff --git a/components/bt/esp_ble_mesh/mesh_core/lpn.c b/components/bt/esp_ble_mesh/mesh_core/lpn.c index 60b732011..06358cac4 100644 --- a/components/bt/esp_ble_mesh/mesh_core/lpn.c +++ b/components/bt/esp_ble_mesh/mesh_core/lpn.c @@ -73,6 +73,8 @@ /* 2 transmissions, 20ms interval */ #define POLL_XMIT BLE_MESH_TRANSMIT(1, 20) +#define FIRST_POLL_ATTEMPTS 6 + static void (*lpn_cb)(u16_t friend_addr, bool established); static const char *state2str(int state) @@ -743,7 +745,7 @@ static void update_timeout(struct bt_mesh_lpn *lpn) bt_mesh_scan_disable(); } - if (lpn->req_attempts < 6) { + if (lpn->req_attempts < FIRST_POLL_ATTEMPTS) { BT_WARN("Retrying first Friend Poll"); lpn->sent_req = 0U; if (send_friend_poll() == 0) { @@ -795,7 +797,7 @@ static void lpn_timeout(struct k_work *work) k_delayed_work_submit(&lpn->timer, FRIEND_REQ_RETRY_TIMEOUT); break; case BLE_MESH_LPN_OFFER_RECV: - if (lpn->req_attempts < 6) { + if (lpn->req_attempts < FIRST_POLL_ATTEMPTS) { BT_WARN("Retrying the first Friend Poll, %d attempts", lpn->req_attempts); lpn->sent_req = 0U; send_friend_poll(); diff --git a/components/bt/esp_ble_mesh/mesh_core/mesh_main.c b/components/bt/esp_ble_mesh/mesh_core/main.c similarity index 98% rename from components/bt/esp_ble_mesh/mesh_core/mesh_main.c rename to components/bt/esp_ble_mesh/mesh_core/main.c index 1a8f7c9e9..13dc03610 100644 --- a/components/bt/esp_ble_mesh/mesh_core/mesh_main.c +++ b/components/bt/esp_ble_mesh/mesh_core/main.c @@ -391,13 +391,13 @@ int bt_mesh_provisioner_enable(bt_mesh_prov_bearer_t bearers) if (IS_ENABLED(CONFIG_BLE_MESH_PB_ADV) && (bearers & BLE_MESH_PROV_ADV)) { bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_ADD, - BLE_MESH_EXCEP_INFO_MESH_BEACON, NULL); + BLE_MESH_EXCEP_INFO_MESH_BEACON, NULL); } if (IS_ENABLED(CONFIG_BLE_MESH_PB_GATT) && (bearers & BLE_MESH_PROV_GATT)) { bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_ADD, - BLE_MESH_EXCEP_INFO_MESH_PROV_ADV, NULL); + BLE_MESH_EXCEP_INFO_MESH_PROV_ADV, NULL); } #endif diff --git a/components/bt/esp_ble_mesh/mesh_core/net.c b/components/bt/esp_ble_mesh/mesh_core/net.c index 5472c7b83..2bfba51d4 100644 --- a/components/bt/esp_ble_mesh/mesh_core/net.c +++ b/components/bt/esp_ble_mesh/mesh_core/net.c @@ -482,7 +482,7 @@ int bt_mesh_net_create(u16_t idx, u8_t flags, const u8_t key[16], bt_mesh.iv_index = iv_index; bt_mesh_atomic_set_bit_to(bt_mesh.flags, BLE_MESH_IVU_IN_PROGRESS, - BLE_MESH_IV_UPDATE(flags)); + BLE_MESH_IV_UPDATE(flags)); /* Set minimum required hours, since the 96-hour minimum requirement * doesn't apply straight after provisioning (since we can't know how @@ -729,8 +729,8 @@ u32_t bt_mesh_next_seq(void) } if (!bt_mesh_atomic_test_bit(bt_mesh.flags, BLE_MESH_IVU_IN_PROGRESS) && - bt_mesh.seq > IV_UPDATE_SEQ_LIMIT && - bt_mesh_subnet_get(BLE_MESH_KEY_PRIMARY)) { + bt_mesh.seq > IV_UPDATE_SEQ_LIMIT && + bt_mesh_subnet_get(BLE_MESH_KEY_PRIMARY)) { #if CONFIG_BLE_MESH_NODE bt_mesh_beacon_ivu_initiator(true); #endif @@ -791,7 +791,7 @@ int bt_mesh_net_resend(struct bt_mesh_subnet *sub, struct net_buf *buf, if (IS_ENABLED(CONFIG_BLE_MESH_NODE) && bt_mesh_is_provisioned()) { if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER) && - bt_mesh_proxy_relay(&buf->b, dst)) { + bt_mesh_proxy_relay(&buf->b, dst)) { send_cb_finalize(cb, cb_data); return 0; } @@ -1049,11 +1049,11 @@ static int net_decrypt(struct bt_mesh_subnet *sub, const u8_t *enc, #if CONFIG_BLE_MESH_NODE if (bt_mesh_is_provisioned()) { - if (IS_ENABLED(CONFIG_BLE_MESH_PROXY) && - rx->net_if == BLE_MESH_NET_IF_PROXY_CFG) { - return bt_mesh_net_decrypt(enc, buf, BLE_MESH_NET_IVI_RX(rx), - true); - } + if (IS_ENABLED(CONFIG_BLE_MESH_PROXY) && + rx->net_if == BLE_MESH_NET_IF_PROXY_CFG) { + return bt_mesh_net_decrypt(enc, buf, BLE_MESH_NET_IVI_RX(rx), + true); + } } #endif @@ -1445,11 +1445,11 @@ void bt_mesh_net_recv(struct net_buf_simple *data, s8_t rssi, */ #if CONFIG_BLE_MESH_NODE if (bt_mesh_is_provisioned()) { - if (!BLE_MESH_ADDR_IS_UNICAST(rx.ctx.recv_dst) || - (!rx.local_match && !rx.friend_match)) { - net_buf_simple_restore(&buf, &state); - bt_mesh_net_relay(&buf, &rx); - } + if (!BLE_MESH_ADDR_IS_UNICAST(rx.ctx.recv_dst) || + (!rx.local_match && !rx.friend_match)) { + net_buf_simple_restore(&buf, &state); + bt_mesh_net_relay(&buf, &rx); + } } #endif } @@ -1500,7 +1500,7 @@ void bt_mesh_net_start(void) #if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN) /* Add Mesh beacon type (Secure Network Beacon) to the exceptional list */ bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_ADD, - BLE_MESH_EXCEP_INFO_MESH_BEACON, NULL); + BLE_MESH_EXCEP_INFO_MESH_BEACON, NULL); #endif if (IS_ENABLED(CONFIG_BLE_MESH_LOW_POWER)) { diff --git a/components/bt/esp_ble_mesh/mesh_core/net.h b/components/bt/esp_ble_mesh/mesh_core/net.h index 2d085f836..bc600cfd1 100644 --- a/components/bt/esp_ble_mesh/mesh_core/net.h +++ b/components/bt/esp_ble_mesh/mesh_core/net.h @@ -393,7 +393,7 @@ void friend_cred_clear(struct friend_cred *cred); int friend_cred_del(u16_t net_idx, u16_t addr); static inline void send_cb_finalize(const struct bt_mesh_send_cb *cb, - void *cb_data) + void *cb_data) { if (!cb) { return; diff --git a/components/bt/esp_ble_mesh/mesh_core/nimble_host/mesh_bearer_adapt.c b/components/bt/esp_ble_mesh/mesh_core/nimble_host/mesh_bearer_adapt.c index 9a36cf2fb..e9ff95019 100644 --- a/components/bt/esp_ble_mesh/mesh_core/nimble_host/mesh_bearer_adapt.c +++ b/components/bt/esp_ble_mesh/mesh_core/nimble_host/mesh_bearer_adapt.c @@ -37,11 +37,11 @@ /** @def BT_UUID_MESH_PROV * @brief Mesh Provisioning Service - */ + */ #define BT_UUID_MESH_PROV_VAL 0x1827 /** @def BT_UUID_MESH_PROXY * @brief Mesh Proxy Service - */ + */ #define BT_UUID_MESH_PROXY_VAL 0x1828 /** @def BT_UUID_GATT_CCC * @brief GATT Client Characteristic Configuration @@ -147,18 +147,18 @@ static struct gattc_prov_info { static struct bt_mesh_prov_conn_cb *bt_mesh_gattc_conn_cb; static int ble_on_subscribe(uint16_t conn_handle, - const struct ble_gatt_error *error, - struct ble_gatt_attr *attr, - void *arg) + const struct ble_gatt_error *error, + struct ble_gatt_attr *attr, + void *arg) { struct bt_mesh_conn *conn = NULL; uint8_t value[2] = {0x01, 0x00}; int i = (int)arg, j, len; MODLOG_DFLT(INFO, "Subscribe complete; status=%d conn_handle=%d " - "attr_handle=%d\n", + "attr_handle=%d\n", error->status, conn_handle, attr->handle); - for (j = i+1; j < ARRAY_SIZE(bt_mesh_gattc_info); j++) { + for (j = i + 1; j < ARRAY_SIZE(bt_mesh_gattc_info); j++) { if ((bt_mesh_gattc_info[j].conn.handle == conn_handle) && bt_mesh_gattc_info[j].ccc_handle) { break; } @@ -204,8 +204,8 @@ static int ble_on_subscribe(uint16_t conn_handle, } static int dsc_disced(uint16_t conn_handle, const struct ble_gatt_error *error, - uint16_t chr_val_handle, const struct ble_gatt_dsc *dsc, - void *arg) + uint16_t chr_val_handle, const struct ble_gatt_dsc *dsc, + void *arg) { int rc = 0, j, i = (int)arg; /* char index */ uint8_t value[2] = {0x01, 0x00}; @@ -219,9 +219,9 @@ static int dsc_disced(uint16_t conn_handle, const struct ble_gatt_error *error, /* All descriptors in this characteristic discovered; start discovering * descriptors in the next characteristic. */ - for (j = i+1; j < ARRAY_SIZE(bt_mesh_gattc_info); j++) { + for (j = i + 1; j < ARRAY_SIZE(bt_mesh_gattc_info); j++) { if ((bt_mesh_gattc_info[j].conn.handle == conn_handle) && bt_mesh_gattc_info[j].data_out_handle) { - break; + break; } } if (j == ARRAY_SIZE(bt_mesh_gattc_info)) { @@ -252,7 +252,7 @@ static int dsc_disced(uint16_t conn_handle, const struct ble_gatt_error *error, static int chr_disced(uint16_t conn_handle, const struct ble_gatt_error *error, - const struct ble_gatt_chr *chr, void *arg) + const struct ble_gatt_chr *chr, void *arg) { int rc = 0, j; uint16_t uuid16 = 0; @@ -285,9 +285,9 @@ static int chr_disced(uint16_t conn_handle, const struct ble_gatt_error *error, /* All characteristics in this service discovered; start discovering * characteristics in the next service. */ - for (j = i+1; j < ARRAY_SIZE(bt_mesh_gattc_info); j++) { + for (j = i + 1; j < ARRAY_SIZE(bt_mesh_gattc_info); j++) { if ((bt_mesh_gattc_info[j].conn.handle == conn_handle) && (bt_mesh_gattc_info[j].start_handle > bt_mesh_gattc_info[j].end_handle)) { - break; + break; } } if (j == ARRAY_SIZE(bt_mesh_gattc_info)) { @@ -299,7 +299,7 @@ static int chr_disced(uint16_t conn_handle, const struct ble_gatt_error *error, ble_gattc_disc_all_dscs(conn_handle, bt_mesh_gattc_info[j].data_out_handle, 0xffff, dsc_disced, (void *)j); } else { ble_gattc_disc_all_chrs(conn_handle, bt_mesh_gattc_info[j].start_handle, bt_mesh_gattc_info[j].end_handle, - chr_disced, (void *)j); + chr_disced, (void *)j); } break; @@ -313,7 +313,7 @@ static int chr_disced(uint16_t conn_handle, const struct ble_gatt_error *error, static int svc_disced(uint16_t conn_handle, const struct ble_gatt_error *error, - const struct ble_gatt_svc *service, void *arg) + const struct ble_gatt_svc *service, void *arg) { struct bt_mesh_conn *conn = NULL; int rc = 0, i; @@ -327,7 +327,7 @@ static int svc_disced(uint16_t conn_handle, const struct ble_gatt_error *error, uuid = &service->uuid; uuid_length = (uint8_t) (uuid->u.type == BLE_UUID_TYPE_16 ? 2 : 16); if (uuid_length != 2) { - return 0; + return 0; } for (i = 0; i < ARRAY_SIZE(bt_mesh_gattc_info); i++) { if (bt_mesh_gattc_info[i].service_uuid == (uint16_t)BLE_UUID16(uuid)->value) { @@ -359,10 +359,10 @@ static int svc_disced(uint16_t conn_handle, const struct ble_gatt_error *error, /* Get the characteristic num within Mesh Provisioning/Proxy Service */ ble_gattc_disc_all_chrs(conn_handle, bt_mesh_gattc_info[i].start_handle, bt_mesh_gattc_info[i].end_handle, - chr_disced, (void *)i); + chr_disced, (void *)i); break; - default: + default: rc = error->status; break; } @@ -529,7 +529,7 @@ static int disc_cb(struct ble_gap_event *event, void *arg) /* Data isn't populated yet */ return 0; } - + if (memcmp(bt_mesh_gattc_info[i].addr.val, conn_desc.peer_id_addr.val, BLE_MESH_ADDR_LEN) || (bt_mesh_gattc_info[i].data_out_handle != event->notify_rx.attr_handle) || (event->notify_rx.indication != 0)) { @@ -708,7 +708,7 @@ static int gap_event_cb(struct ble_gap_event *event, void *arg) u16_t len = 0; uint16_t ccc_val = 0; - if (event->subscribe.prev_notify != event->subscribe.cur_notify) { + if (event->subscribe.prev_notify != event->subscribe.cur_notify) { ccc_val = event->subscribe.cur_notify; } else if (event->subscribe.prev_indicate != event->subscribe.cur_indicate) { if (event->subscribe.cur_indicate) { @@ -720,12 +720,12 @@ static int gap_event_cb(struct ble_gap_event *event, void *arg) if (attr != NULL && attr->write != NULL) { if ((len = attr->write(&bt_mesh_gatts_conn[index], attr, - &ccc_val, - sizeof(ccc_val), - 0 /* offset */, 0)) > 0) { + &ccc_val, + sizeof(ccc_val), + 0 /* offset */, 0)) > 0) { } } - + return 0; case BLE_GAP_EVENT_MTU: @@ -932,7 +932,7 @@ static struct bt_mesh_gatt_attr *bt_mesh_gatts_find_attr_by_handle(u16_t handle) } static void bt_mesh_gatts_foreach_attr(u16_t start_handle, u16_t end_handle, - bt_mesh_gatt_attr_func_t func, void *user_data) + bt_mesh_gatt_attr_func_t func, void *user_data) { struct bt_mesh_gatt_service *svc = NULL; @@ -999,8 +999,8 @@ struct gatts_incl { } __packed; ssize_t bt_mesh_gatts_attr_read_included(struct bt_mesh_conn *conn, - const struct bt_mesh_gatt_attr *attr, - void *buf, u16_t len, u16_t offset) + const struct bt_mesh_gatt_attr *attr, + void *buf, u16_t len, u16_t offset) { struct bt_mesh_gatt_attr *incl = attr->user_data; struct bt_mesh_uuid *uuid = incl->user_data; @@ -1036,7 +1036,7 @@ ssize_t bt_mesh_gatts_attr_read_service(struct bt_mesh_conn *conn, } return bt_mesh_gatts_attr_read(conn, attr, buf, len, offset, - BLE_MESH_UUID_128(uuid)->val, 16); + BLE_MESH_UUID_128(uuid)->val, 16); } struct gatts_chrc { @@ -1215,7 +1215,7 @@ u8_t bt_mesh_gattc_get_free_conn_count(void) for (i = 0U; i < ARRAY_SIZE(bt_mesh_gattc_info); i++) { if (bt_mesh_gattc_info[i].conn.handle == 0xFFFF && - bt_mesh_gattc_info[i].service_uuid == 0x0000) { + bt_mesh_gattc_info[i].service_uuid == 0x0000) { ++count; } } @@ -1256,13 +1256,13 @@ int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, u16_t service_uuid) int i, rc; if (!addr || !memcmp(addr->val, zero, BLE_MESH_ADDR_LEN) || - (addr->type > BLE_ADDR_RANDOM)) { + (addr->type > BLE_ADDR_RANDOM)) { BT_ERR("%s, Invalid remote address", __func__); return -EINVAL; } if (service_uuid != BLE_MESH_UUID_MESH_PROV_VAL && - service_uuid != BLE_MESH_UUID_MESH_PROXY_VAL) { + service_uuid != BLE_MESH_UUID_MESH_PROXY_VAL) { BT_ERR("%s, Invalid service uuid 0x%04x", __func__, service_uuid); return -EINVAL; } @@ -1271,7 +1271,7 @@ int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, u16_t service_uuid) for (i = 0; i < ARRAY_SIZE(bt_mesh_gattc_info); i++) { if (!memcmp(bt_mesh_gattc_info[i].addr.val, addr->val, BLE_MESH_ADDR_LEN)) { BT_WARN("%s, Already create connection with %s", - __func__, bt_hex(addr->val, BLE_MESH_ADDR_LEN)); + __func__, bt_hex(addr->val, BLE_MESH_ADDR_LEN)); return -EALREADY; } } @@ -1279,7 +1279,7 @@ int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, u16_t service_uuid) /* Find empty element in queue to store device info */ for (i = 0; i < ARRAY_SIZE(bt_mesh_gattc_info); i++) { if ((bt_mesh_gattc_info[i].conn.handle == 0xFFFF) && - (bt_mesh_gattc_info[i].service_uuid == 0x0000)) { + (bt_mesh_gattc_info[i].service_uuid == 0x0000)) { memcpy(bt_mesh_gattc_info[i].addr.val, addr->val, BLE_MESH_ADDR_LEN); bt_mesh_gattc_info[i].addr.type = addr->type; /* Service to be found after exhanging mtu size */ @@ -1301,10 +1301,10 @@ int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, u16_t service_uuid) } } #else - rc = ble_gap_disc_cancel(); - if (rc != 0) { - return -1; - } + rc = ble_gap_disc_cancel(); + if (rc != 0) { + return -1; + } #endif /* BLE_MESH_DEV */ BT_DBG("%s, create conn with %s", __func__, bt_hex(addr->val, BLE_MESH_ADDR_LEN)); @@ -1327,7 +1327,7 @@ int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, u16_t service_uuid) ble_addr_t peer_addr; memcpy(peer_addr.val, addr->val, 6); - peer_addr.type = addr->type; + peer_addr.type = addr->type; rc = ble_gap_connect(BLE_OWN_ADDR_PUBLIC, &peer_addr, BLE_HS_FOREVER, &conn_params, disc_cb, NULL); @@ -1336,8 +1336,8 @@ int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, u16_t service_uuid) } static int mtu_cb(uint16_t conn_handle, - const struct ble_gatt_error *error, - uint16_t mtu, void *arg) + const struct ble_gatt_error *error, + uint16_t mtu, void *arg) { int i; if (error->status == 0) { @@ -1466,7 +1466,7 @@ void bt_mesh_conn_unref(struct bt_mesh_conn *conn) #if defined(CONFIG_BLE_MESH_NODE) && CONFIG_BLE_MESH_NODE static int proxy_char_access_cb(uint16_t conn_handle, uint16_t attr_handle, - struct ble_gatt_access_ctxt *ctxt, void *arg) + struct ble_gatt_access_ctxt *ctxt, void *arg) { if (ctxt->op == BLE_GATT_ACCESS_OP_WRITE_CHR || ctxt->op == BLE_GATT_ACCESS_OP_WRITE_DSC) { struct bt_mesh_gatt_attr *attr = bt_mesh_gatts_find_attr_by_handle(attr_handle); @@ -1474,14 +1474,14 @@ static int proxy_char_access_cb(uint16_t conn_handle, uint16_t attr_handle, u16_t len = 0; BT_DBG("%s, write: handle = %d, len = %d, data = %s", __func__, attr_handle, - ctxt->om->om_len, - bt_hex(ctxt->om->om_data, ctxt->om->om_len)); + ctxt->om->om_len, + bt_hex(ctxt->om->om_data, ctxt->om->om_len)); if (attr != NULL && attr->write != NULL) { if ((len = attr->write(&bt_mesh_gatts_conn[index], attr, - ctxt->om->om_data, - ctxt->om->om_len, - 0 /* offset */, 0)) > 0) { + ctxt->om->om_data, + ctxt->om->om_len, + 0 /* offset */, 0)) > 0) { } } } else if (ctxt->op == BLE_GATT_ACCESS_OP_READ_CHR || ctxt->op == BLE_GATT_ACCESS_OP_READ_DSC) { @@ -1491,7 +1491,7 @@ static int proxy_char_access_cb(uint16_t conn_handle, uint16_t attr_handle, } static int dummy_access_cb(uint16_t conn_handle, uint16_t attr_handle, - struct ble_gatt_access_ctxt *ctxt, void *arg) + struct ble_gatt_access_ctxt *ctxt, void *arg) { /* * We should never never enter this callback - it's attached to notify-only @@ -1503,50 +1503,54 @@ static int dummy_access_cb(uint16_t conn_handle, uint16_t attr_handle, } static const struct ble_gatt_svc_def svc_defs [] = { -#ifdef CONFIG_BLE_MESH_GATT_PROXY - { - .type = BLE_GATT_SVC_TYPE_PRIMARY, - .uuid = BLE_UUID16_DECLARE(BT_UUID_MESH_PROXY_VAL), +#ifdef CONFIG_BLE_MESH_GATT_PROXY_SERVER + { + .type = BLE_GATT_SVC_TYPE_PRIMARY, + .uuid = BLE_UUID16_DECLARE(BT_UUID_MESH_PROXY_VAL), .includes = NULL, - .characteristics = (struct ble_gatt_chr_def[]) { { - .uuid = BLE_UUID16_DECLARE(BT_UUID_MESH_PROXY_DATA_IN_VAL), - .access_cb = proxy_char_access_cb, - .flags = BLE_GATT_CHR_F_WRITE_NO_RSP, - }, { - .uuid = BLE_UUID16_DECLARE(BT_UUID_MESH_PROXY_DATA_OUT_VAL), - .access_cb = dummy_access_cb, - .flags = BLE_GATT_CHR_F_NOTIFY, - }, { - 0, /* No more characteristics in this service. */ - } }, - }, + .characteristics = (struct ble_gatt_chr_def[]) + { { + .uuid = BLE_UUID16_DECLARE(BT_UUID_MESH_PROXY_DATA_IN_VAL), + .access_cb = proxy_char_access_cb, + .flags = BLE_GATT_CHR_F_WRITE_NO_RSP, + }, { + .uuid = BLE_UUID16_DECLARE(BT_UUID_MESH_PROXY_DATA_OUT_VAL), + .access_cb = dummy_access_cb, + .flags = BLE_GATT_CHR_F_NOTIFY, + }, { + 0, /* No more characteristics in this service. */ + } + }, + }, #endif #ifdef CONFIG_BLE_MESH_PB_GATT { - .type = BLE_GATT_SVC_TYPE_PRIMARY, - .uuid = BLE_UUID16_DECLARE(BT_UUID_MESH_PROV_VAL), + .type = BLE_GATT_SVC_TYPE_PRIMARY, + .uuid = BLE_UUID16_DECLARE(BT_UUID_MESH_PROV_VAL), .includes = NULL, - .characteristics = (struct ble_gatt_chr_def[]) { { - .uuid = BLE_UUID16_DECLARE(BT_UUID_MESH_PROV_DATA_IN_VAL), - .access_cb = proxy_char_access_cb, - .flags = BLE_GATT_CHR_F_WRITE_NO_RSP, - }, { - .uuid = BLE_UUID16_DECLARE(BT_UUID_MESH_PROV_DATA_OUT_VAL), - .access_cb = dummy_access_cb, - .flags = BLE_GATT_CHR_F_NOTIFY, - }, { - 0, /* No more characteristics in this service. */ - } }, - }, + .characteristics = (struct ble_gatt_chr_def[]) + { { + .uuid = BLE_UUID16_DECLARE(BT_UUID_MESH_PROV_DATA_IN_VAL), + .access_cb = proxy_char_access_cb, + .flags = BLE_GATT_CHR_F_WRITE_NO_RSP, + }, { + .uuid = BLE_UUID16_DECLARE(BT_UUID_MESH_PROV_DATA_OUT_VAL), + .access_cb = dummy_access_cb, + .flags = BLE_GATT_CHR_F_NOTIFY, + }, { + 0, /* No more characteristics in this service. */ + } + }, + }, #endif { - 0, /* No more services. */ - }, + 0, /* No more services. */ + }, }; #endif void gatt_register_cb(struct ble_gatt_register_ctxt *ctxt, - void * arg ) + void *arg ) { if (ctxt->op == BLE_GATT_REGISTER_OP_SVC) { if (ble_uuid_cmp(ctxt->svc.svc_def->uuid, BLE_UUID16_DECLARE(BT_UUID_MESH_PROXY_VAL)) == 0) { @@ -1695,7 +1699,7 @@ exit: } int ble_sm_alg_gen_dhkey(uint8_t *peer_pub_key_x, uint8_t *peer_pub_key_y, - uint8_t *our_priv_key, uint8_t *out_dhkey); + uint8_t *our_priv_key, uint8_t *out_dhkey); int bt_mesh_dh_key_gen(const u8_t remote_pk[64], bt_mesh_dh_key_cb_t cb, const u8_t idx) { diff --git a/components/bt/esp_ble_mesh/mesh_core/prov.c b/components/bt/esp_ble_mesh/mesh_core/prov.c index 0ffcaf2c0..c1b7bbcd5 100644 --- a/components/bt/esp_ble_mesh/mesh_core/prov.c +++ b/components/bt/esp_ble_mesh/mesh_core/prov.c @@ -292,7 +292,7 @@ static void reset_adv_link(void) #if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN) /* Remove the link id from exceptional list */ bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_REMOVE, - BLE_MESH_EXCEP_INFO_MESH_LINK_ID, &link.id); + BLE_MESH_EXCEP_INFO_MESH_LINK_ID, &link.id); #endif reset_state(); @@ -1000,7 +1000,7 @@ static int bt_mesh_calc_dh_key(void) } int bt_mesh_set_oob_pub_key(const u8_t pub_key_x[32], const u8_t pub_key_y[32], - const u8_t pri_key[32]) + const u8_t pri_key[32]) { if (!pub_key_x || !pub_key_y || !pri_key) { BT_ERR("%s, Invalid parameter", __func__); @@ -1333,7 +1333,7 @@ static void link_open(struct prov_rx *rx, struct net_buf_simple *buf) #if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN) /* Add the link id into exceptional list */ bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_ADD, - BLE_MESH_EXCEP_INFO_MESH_LINK_ID, &link.id); + BLE_MESH_EXCEP_INFO_MESH_LINK_ID, &link.id); #endif bearer_ctl_send(LINK_ACK, NULL, 0); @@ -1416,7 +1416,7 @@ static void prov_msg_recv(void) if (1 + prov_handlers[type].len != link.rx.buf->len) { BT_ERR("%s, Invalid length %u for type 0x%02x", - __func__, link.rx.buf->len, type); + __func__, link.rx.buf->len, type); prov_send_fail_msg(PROV_ERR_NVAL_FMT); return; } @@ -1466,7 +1466,7 @@ static void gen_prov_cont(struct prov_rx *rx, struct net_buf_simple *buf) ((link.rx.last_seg - 1) * 23U)); if (expect_len != buf->len) { BT_ERR("%s, Incorrect last seg len: %u != %u", - __func__, expect_len, buf->len); + __func__, expect_len, buf->len); prov_send_fail_msg(PROV_ERR_NVAL_FMT); return; } @@ -1526,7 +1526,7 @@ static void gen_prov_start(struct prov_rx *rx, struct net_buf_simple *buf) if (link.rx.buf->len > link.rx.buf->size) { BT_ERR("%s, Too large provisioning PDU (%u bytes)", - __func__, link.rx.buf->len); + __func__, link.rx.buf->len); /* Zephyr uses prov_send_fail_msg() here */ return; } diff --git a/components/bt/esp_ble_mesh/mesh_core/prov.h b/components/bt/esp_ble_mesh/mesh_core/prov.h index 610e55c6d..756cd011f 100644 --- a/components/bt/esp_ble_mesh/mesh_core/prov.h +++ b/components/bt/esp_ble_mesh/mesh_core/prov.h @@ -22,7 +22,7 @@ int bt_mesh_pb_gatt_close(struct bt_mesh_conn *conn); int bt_mesh_pb_gatt_recv(struct bt_mesh_conn *conn, struct net_buf_simple *buf); int bt_mesh_set_oob_pub_key(const u8_t pub_key_x[32], const u8_t pub_key_y[32], - const u8_t pri_key[32]); + const u8_t pri_key[32]); const struct bt_mesh_prov *bt_mesh_prov_get(void); diff --git a/components/bt/esp_ble_mesh/mesh_core/provisioner_main.c b/components/bt/esp_ble_mesh/mesh_core/provisioner_main.c index 860507636..7b40331a0 100644 --- a/components/bt/esp_ble_mesh/mesh_core/provisioner_main.c +++ b/components/bt/esp_ble_mesh/mesh_core/provisioner_main.c @@ -240,7 +240,7 @@ int provisioner_upper_init(void) which has been initialized in the application layer */ bt_mesh.iv_index = prov->iv_index; bt_mesh_atomic_set_bit_to(bt_mesh.flags, BLE_MESH_IVU_IN_PROGRESS, - BLE_MESH_IV_UPDATE(prov->flags)); + BLE_MESH_IV_UPDATE(prov->flags)); /* Set minimum required hours, since the 96-hour minimum requirement * doesn't apply straight after provisioning (since we can't know how diff --git a/components/bt/esp_ble_mesh/mesh_core/provisioner_prov.c b/components/bt/esp_ble_mesh/mesh_core/provisioner_prov.c index 935872107..94cbccba7 100644 --- a/components/bt/esp_ble_mesh/mesh_core/provisioner_prov.c +++ b/components/bt/esp_ble_mesh/mesh_core/provisioner_prov.c @@ -33,7 +33,7 @@ #if CONFIG_BLE_MESH_PROVISIONER _Static_assert(BLE_MESH_MAX_CONN >= CONFIG_BLE_MESH_PBG_SAME_TIME, - "Too large BLE Mesh PB-GATT count"); + "Too large BLE Mesh PB-GATT count"); /* 3 transmissions, 20ms interval */ #define PROV_XMIT BLE_MESH_TRANSMIT(2, 20) @@ -520,7 +520,7 @@ static bool is_unprov_dev_being_provision(const u8_t uuid[16]) for (i = 0U; i < BLE_MESH_PROV_SAME_TIME; i++) { #if defined(CONFIG_BLE_MESH_PB_ADV) && defined(CONFIG_BLE_MESH_PB_GATT) if (link[i].linking || link[i].connecting || - bt_mesh_atomic_test_bit(link[i].flags, LINK_ACTIVE)) { + bt_mesh_atomic_test_bit(link[i].flags, LINK_ACTIVE)) { #elif defined(CONFIG_BLE_MESH_PB_ADV) && !defined(CONFIG_BLE_MESH_PB_GATT) if (link[i].linking || bt_mesh_atomic_test_bit(link[i].flags, LINK_ACTIVE)) { #else @@ -540,7 +540,7 @@ static bool is_unprov_dev_uuid_match(const u8_t uuid[16]) { if (prov_ctx.match_length && prov_ctx.match_value) { if (memcmp(uuid + prov_ctx.match_offset, - prov_ctx.match_value, prov_ctx.match_length)) { + prov_ctx.match_value, prov_ctx.match_length)) { return false; } } @@ -599,7 +599,7 @@ static int provisioner_check_unprov_dev_info(const u8_t uuid[16]) #if defined(CONFIG_BLE_MESH_PB_ADV) static int provisioner_start_prov_pb_adv(const u8_t uuid[16], - const bt_mesh_addr_t *addr, u16_t oob_info) + const bt_mesh_addr_t *addr, u16_t oob_info) { u8_t zero[6] = {0}; int addr_cmp; @@ -641,7 +641,7 @@ static int provisioner_start_prov_pb_adv(const u8_t uuid[16], #if defined(CONFIG_BLE_MESH_PB_GATT) static int provisioner_start_prov_pb_gatt(const u8_t uuid[16], - const bt_mesh_addr_t *addr, u16_t oob_info) + const bt_mesh_addr_t *addr, u16_t oob_info) { u8_t zero[6] = {0}; int addr_cmp; @@ -708,7 +708,7 @@ int bt_mesh_provisioner_add_unprov_dev(struct bt_mesh_unprov_dev_add *add_dev, u uuid_cmp = memcmp(add_dev->uuid, zero, 16); if (add_dev->bearer == 0x0 || ((uuid_cmp == 0) && - ((addr_cmp == 0) || add_dev->addr_type > BLE_MESH_ADDR_RANDOM))) { + ((addr_cmp == 0) || add_dev->addr_type > BLE_MESH_ADDR_RANDOM))) { BT_ERR("%s, Invalid parameter", __func__); return -EINVAL; } @@ -804,7 +804,7 @@ start: /* Check if current provisioned node count + active link reach max limit */ if (prov_ctx.node_count + prov_ctx.pba_count + \ - prov_ctx.pbg_count >= ARRAY_SIZE(prov_nodes)) { + prov_ctx.pbg_count >= ARRAY_SIZE(prov_nodes)) { BT_WARN("%s, Node count + active link count reach max limit", __func__); return -EIO; } @@ -820,7 +820,7 @@ start: return -EIO; } if ((err = provisioner_start_prov_pb_adv( - add_dev->uuid, &add_addr, add_dev->oob_info))) { + add_dev->uuid, &add_addr, add_dev->oob_info))) { return err; } #endif @@ -831,7 +831,7 @@ start: return -EIO; } if ((err = provisioner_start_prov_pb_gatt( - add_dev->uuid, &add_addr, add_dev->oob_info))) { + add_dev->uuid, &add_addr, add_dev->oob_info))) { return err; } #endif @@ -1134,7 +1134,7 @@ static void reset_link(const u8_t idx, u8_t reason) #if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN) /* Remove the link id from exceptional list */ bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_REMOVE, - BLE_MESH_EXCEP_INFO_MESH_LINK_ID, &link[idx].link_id); + BLE_MESH_EXCEP_INFO_MESH_LINK_ID, &link[idx].link_id); #endif /* Clear everything except the retransmit delayed work config */ @@ -1294,7 +1294,7 @@ static void send_link_open(const u8_t idx) #if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN) /* Add the link id into exceptional list */ bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_ADD, - BLE_MESH_EXCEP_INFO_MESH_LINK_ID, &link[idx].link_id); + BLE_MESH_EXCEP_INFO_MESH_LINK_ID, &link[idx].link_id); #endif bearer_ctl_send(idx, LINK_OPEN, link[idx].uuid, 16); @@ -1448,9 +1448,9 @@ static inline int prov_send(const u8_t idx, struct net_buf_simple *buf) #if defined(CONFIG_BLE_MESH_PB_GATT) if (idx < BLE_MESH_PROV_SAME_TIME #if defined(CONFIG_BLE_MESH_PB_ADV) - && idx >= CONFIG_BLE_MESH_PBA_SAME_TIME + && idx >= CONFIG_BLE_MESH_PBA_SAME_TIME #endif - ) { + ) { return prov_send_gatt(idx, buf); } #endif @@ -1960,12 +1960,12 @@ static void prov_dh_key_cb(const u8_t key[32], const u8_t idx) * to output a value, and wait for prov input complete pdu. */ if (prov_auth(idx, link[idx].auth_method, - link[idx].auth_action, link[idx].auth_size) < 0) { + link[idx].auth_action, link[idx].auth_size) < 0) { BT_ERR("%s, Failed to authenticate", __func__); goto fail; } if (link[idx].auth_method == AUTH_METHOD_OUTPUT || - link[idx].auth_method == AUTH_METHOD_INPUT) { + link[idx].auth_method == AUTH_METHOD_INPUT) { return; } @@ -2090,7 +2090,7 @@ static void prov_input_complete(const u8_t idx, const u8_t *data) static void prov_confirm(const u8_t idx, const u8_t *data) { - /** + /** * Zephyr uses PROV_BUF(16). Currently test with PROV_BUF(16) * and PROV_BUF(17) on branch feature/btdm_ble_mesh_debug both * work fine. @@ -2397,9 +2397,9 @@ static void prov_complete(const u8_t idx, const u8_t *data) prov_ctx.node_count++; err = provisioner_node_provision(j, prov_nodes[j].uuid, prov_nodes[j].oob_info, - prov_nodes[j].unicast_addr, prov_nodes[j].element_num, - prov_nodes[j].net_idx, prov_nodes[j].flags, - prov_nodes[j].iv_index, device_key); + prov_nodes[j].unicast_addr, prov_nodes[j].element_num, + prov_nodes[j].net_idx, prov_nodes[j].flags, + prov_nodes[j].iv_index, device_key); if (err) { BT_ERR("%s, Failed to store node info", __func__); close_link(idx, CLOSE_REASON_FAILED); @@ -2460,9 +2460,9 @@ static void close_link(const u8_t idx, u8_t reason) #if defined(CONFIG_BLE_MESH_PB_GATT) if (idx < BLE_MESH_PROV_SAME_TIME #if defined(CONFIG_BLE_MESH_PB_ADV) - && idx >= CONFIG_BLE_MESH_PBA_SAME_TIME + && idx >= CONFIG_BLE_MESH_PBA_SAME_TIME #endif - ) { + ) { if (link[idx].conn) { bt_mesh_gattc_disconnect(link[idx].conn); } @@ -2659,7 +2659,7 @@ static void gen_prov_cont(const u8_t idx, struct prov_rx *rx, struct net_buf_sim if (rx->xact_id != link[idx].rx.trans_id) { BT_WARN("%s, Data for unknown transaction (%u != %u)", - __func__, rx->xact_id, link[idx].rx.trans_id); + __func__, rx->xact_id, link[idx].rx.trans_id); /** * If Provisioner receives a Provisioning PDU with a mismatch * transaction number, it just ignore it. @@ -2677,7 +2677,7 @@ static void gen_prov_cont(const u8_t idx, struct prov_rx *rx, struct net_buf_sim (23 * (link[idx].rx.last_seg - 1))); if (expect_len != buf->len) { BT_ERR("%s, Incorrect last seg len: %u != %u", - __func__, expect_len, buf->len); + __func__, expect_len, buf->len); goto fail; } } @@ -2762,7 +2762,7 @@ static void gen_prov_start(const u8_t idx, struct prov_rx *rx, struct net_buf_si if (link[idx].rx.buf->len > link[idx].rx.buf->size) { BT_ERR("%s, Too large provisioning PDU (%u bytes)", - __func__, link[idx].rx.buf->len); + __func__, link[idx].rx.buf->len); // close_link(i, CLOSE_REASON_FAILED); return; } @@ -2950,7 +2950,7 @@ int provisioner_pb_gatt_open(struct bt_mesh_conn *conn, u8_t *addr) BT_DBG("conn %p", conn); - /** + /** * Double check if the device is currently being provisioned using PB-ADV. * Provisioner binds conn with proper device when proxy_prov_connected() * is invoked, and here after proper GATT procedures are completed, we just @@ -3087,7 +3087,7 @@ int provisioner_prov_init(const struct bt_mesh_prov *prov_info) } static bool is_unprov_dev_info_callback_to_app(bt_mesh_prov_bearer_t bearer, - const u8_t uuid[16], const bt_mesh_addr_t *addr, u16_t oob_info) + const u8_t uuid[16], const bt_mesh_addr_t *addr, u16_t oob_info) { u16_t index; @@ -3105,7 +3105,7 @@ static bool is_unprov_dev_info_callback_to_app(bt_mesh_prov_bearer_t bearer, if (!(unprov_dev[index].bearer & bearer)) { BT_WARN("Device in queue not support PB-%s", - (bearer == BLE_MESH_PROV_ADV) ? "ADV" : "GATT"); + (bearer == BLE_MESH_PROV_ADV) ? "ADV" : "GATT"); if (notify_unprov_adv_pkt_cb) { notify_unprov_adv_pkt_cb(addr->val, addr->type, adv_type, uuid, oob_info, bearer); } @@ -3144,7 +3144,7 @@ void provisioner_unprov_beacon_recv(struct net_buf_simple *buf) } if (is_unprov_dev_info_callback_to_app( - BLE_MESH_PROV_ADV, uuid, addr, oob_info)) { + BLE_MESH_PROV_ADV, uuid, addr, oob_info)) { return; } @@ -3178,7 +3178,7 @@ void provisioner_prov_adv_ind_recv(struct net_buf_simple *buf, const bt_mesh_add } if (is_unprov_dev_info_callback_to_app( - BLE_MESH_PROV_GATT, uuid, addr, oob_info)) { + BLE_MESH_PROV_GATT, uuid, addr, oob_info)) { return; } diff --git a/components/bt/esp_ble_mesh/mesh_core/proxy_client.c b/components/bt/esp_ble_mesh/mesh_core/proxy_client.c index 1db92c478..ee0961e82 100644 --- a/components/bt/esp_ble_mesh/mesh_core/proxy_client.c +++ b/components/bt/esp_ble_mesh/mesh_core/proxy_client.c @@ -767,7 +767,7 @@ bool bt_mesh_proxy_client_send(struct net_buf_simple *buf, u16_t dst) net_buf_simple_init(&msg, 1); net_buf_simple_add_mem(&msg, buf->data, buf->len); - err = bt_mesh_proxy_prov_client_send(server->conn, BLE_MESH_PROXY_NET_PDU, &msg); + err = bt_mesh_proxy_prov_client_send(server->conn, BLE_MESH_PROXY_NET_PDU, &msg); if (err) { BT_ERR("%s, Failed to send proxy net message (err %d)", __func__, err); } else { @@ -957,11 +957,11 @@ int bt_mesh_proxy_client_send_cfg(u8_t conn_handle, u16_t net_idx, struct bt_mes /** * Check if net_idx used to encrypt Proxy Configuration are the same - * with the one added when creating proxy connection. + * with the one added when creating proxy connection. */ if (servers[conn_handle].net_idx != net_idx) { BT_ERR("%s, NetKey Index 0x%04x mismatch, expect 0x%04x", - __func__, net_idx, servers[conn_handle].net_idx); + __func__, net_idx, servers[conn_handle].net_idx); return -EIO; } @@ -989,7 +989,7 @@ int bt_mesh_proxy_prov_client_init(void) #if CONFIG_BLE_MESH_USE_DUPLICATE_SCAN && CONFIG_BLE_MESH_GATT_PROXY_CLIENT bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_ADD, - BLE_MESH_EXCEP_INFO_MESH_PROXY_ADV, NULL); + BLE_MESH_EXCEP_INFO_MESH_PROXY_ADV, NULL); #endif return 0; diff --git a/components/bt/esp_ble_mesh/mesh_core/proxy_server.c b/components/bt/esp_ble_mesh/mesh_core/proxy_server.c index 329a862b6..ba2556d27 100644 --- a/components/bt/esp_ble_mesh/mesh_core/proxy_server.c +++ b/components/bt/esp_ble_mesh/mesh_core/proxy_server.c @@ -29,8 +29,8 @@ #if CONFIG_BLE_MESH_NODE /* Not support enabling Proxy Client and Proxy Server simultaneously */ -_Static_assert(!(IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER) && IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_CLIENT)), - "Not support Proxy Server and Proxy Client simultaneously"); +_Static_assert(!(IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER) &&IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_CLIENT)), + "Not support Proxy Server and Proxy Client simultaneously"); #define PDU_TYPE(data) (data[0] & BIT_MASK(6)) #define PDU_SAR(data) (data[0] >> 6) @@ -670,7 +670,7 @@ static ssize_t prov_ccc_read(struct bt_mesh_conn *conn, u16_t *value = attr->user_data; return bt_mesh_gatts_attr_read(conn, attr, buf, len, offset, value, - sizeof(*value)); + sizeof(*value)); } /* Mesh Provisioning Service Declaration */ @@ -805,7 +805,7 @@ static ssize_t proxy_ccc_read(struct bt_mesh_conn *conn, u16_t *value = attr->user_data; return bt_mesh_gatts_attr_read(conn, attr, buf, len, offset, value, - sizeof(*value)); + sizeof(*value)); } /* Mesh Proxy Service Declaration */ diff --git a/components/bt/esp_ble_mesh/mesh_core/settings.c b/components/bt/esp_ble_mesh/mesh_core/settings.c index 64d4b9115..8705b1c9a 100644 --- a/components/bt/esp_ble_mesh/mesh_core/settings.c +++ b/components/bt/esp_ble_mesh/mesh_core/settings.c @@ -656,7 +656,7 @@ static int model_set(bool vnd, const char *name) model = bt_mesh_model_get(vnd, elem_idx, model_idx); if (!model) { BT_ERR("%s, Failed to get %s model, elem_idx %u model_idx %u", - __func__, vnd ? "vnd" : "sig", elem_idx, model_idx); + __func__, vnd ? "vnd" : "sig", elem_idx, model_idx); err = -ENOENT; goto free; } @@ -1227,7 +1227,7 @@ static void store_pending_mod_bind(struct bt_mesh_model *model, bool vnd) err = bt_mesh_add_core_settings_item(vnd ? "mesh/vnd" : "mesh/sig", model_key); if (err) { BT_ERR("%s, Failed to add 0x%04x to %s", __func__, model_key, - vnd ? "mesh/vnd" : "mesh/sig"); + vnd ? "mesh/vnd" : "mesh/sig"); } return; @@ -1257,7 +1257,7 @@ static void store_pending_mod_sub(struct bt_mesh_model *model, bool vnd) err = bt_mesh_add_core_settings_item(vnd ? "mesh/vnd" : "mesh/sig", model_key); if (err) { BT_ERR("%s, Failed to add 0x%04x to %s", __func__, model_key, - vnd ? "mesh/vnd" : "mesh/sig"); + vnd ? "mesh/vnd" : "mesh/sig"); } return; @@ -1301,7 +1301,7 @@ static void store_pending_mod_pub(struct bt_mesh_model *model, bool vnd) err = bt_mesh_add_core_settings_item(vnd ? "mesh/vnd" : "mesh/sig", model_key); if (err) { BT_ERR("%s, Failed to add 0x%04x to %s", __func__, model_key, - vnd ? "mesh/vnd" : "mesh/sig"); + vnd ? "mesh/vnd" : "mesh/sig"); } return; diff --git a/components/bt/esp_ble_mesh/mesh_core/settings/settings_nvs.c b/components/bt/esp_ble_mesh/mesh_core/storage/settings_nvs.c similarity index 99% rename from components/bt/esp_ble_mesh/mesh_core/settings/settings_nvs.c rename to components/bt/esp_ble_mesh/mesh_core/storage/settings_nvs.c index 59e9ac114..96ef197ad 100644 --- a/components/bt/esp_ble_mesh/mesh_core/settings/settings_nvs.c +++ b/components/bt/esp_ble_mesh/mesh_core/storage/settings_nvs.c @@ -121,7 +121,7 @@ static int settings_save(nvs_handle handle, const char *key, const u8_t *val, si } if (err != ESP_OK) { BT_ERR("%s, Failed to %s %s data (err %d)", __func__, - val ? "set" : "erase", key, err); + val ? "set" : "erase", key, err); return -EIO; } diff --git a/components/bt/esp_ble_mesh/mesh_core/settings/settings_nvs.h b/components/bt/esp_ble_mesh/mesh_core/storage/settings_nvs.h similarity index 100% rename from components/bt/esp_ble_mesh/mesh_core/settings/settings_nvs.h rename to components/bt/esp_ble_mesh/mesh_core/storage/settings_nvs.h diff --git a/components/bt/esp_ble_mesh/mesh_core/transport.c b/components/bt/esp_ble_mesh/mesh_core/transport.c index 9b3606a98..614a3518d 100644 --- a/components/bt/esp_ble_mesh/mesh_core/transport.c +++ b/components/bt/esp_ble_mesh/mesh_core/transport.c @@ -40,7 +40,7 @@ * count. */ _Static_assert(CONFIG_BLE_MESH_ADV_BUF_COUNT >= (CONFIG_BLE_MESH_TX_SEG_MAX + 3), - "Too small BLE Mesh adv buffer count"); + "Too small BLE Mesh adv buffer count"); #define AID_MASK ((u8_t)(BIT_MASK(6))) @@ -140,31 +140,31 @@ static int send_unseg(struct bt_mesh_net_tx *tx, struct net_buf_simple *sdu, net_buf_add_mem(buf, sdu->data, sdu->len); if (IS_ENABLED(CONFIG_BLE_MESH_NODE) && bt_mesh_is_provisioned()) { - if (IS_ENABLED(CONFIG_BLE_MESH_FRIEND)) { - if (!bt_mesh_friend_queue_has_space(tx->sub->net_idx, - tx->src, tx->ctx->addr, - NULL, 1)) { - if (BLE_MESH_ADDR_IS_UNICAST(tx->ctx->addr)) { - BT_ERR("Not enough space in Friend Queue"); + if (IS_ENABLED(CONFIG_BLE_MESH_FRIEND)) { + if (!bt_mesh_friend_queue_has_space(tx->sub->net_idx, + tx->src, tx->ctx->addr, + NULL, 1)) { + if (BLE_MESH_ADDR_IS_UNICAST(tx->ctx->addr)) { + BT_ERR("Not enough space in Friend Queue"); + net_buf_unref(buf); + return -ENOBUFS; + } else { + BT_WARN("No space in Friend Queue"); + goto send; + } + } + + if (bt_mesh_friend_enqueue_tx(tx, BLE_MESH_FRIEND_PDU_SINGLE, + NULL, 1, &buf->b) && + BLE_MESH_ADDR_IS_UNICAST(tx->ctx->addr)) { + /* PDUs for a specific Friend should only go + * out through the Friend Queue. + */ net_buf_unref(buf); - return -ENOBUFS; - } else { - BT_WARN("No space in Friend Queue"); - goto send; + send_cb_finalize(cb, cb_data); + return 0; } } - - if (bt_mesh_friend_enqueue_tx(tx, BLE_MESH_FRIEND_PDU_SINGLE, - NULL, 1, &buf->b) && - BLE_MESH_ADDR_IS_UNICAST(tx->ctx->addr)) { - /* PDUs for a specific Friend should only go - * out through the Friend Queue. - */ - net_buf_unref(buf); - send_cb_finalize(cb, cb_data); - return 0; - } - } } send: @@ -380,12 +380,12 @@ static int send_seg(struct bt_mesh_net_tx *net_tx, struct net_buf_simple *sdu, BT_DBG("SeqZero 0x%04x", seq_zero); if (IS_ENABLED(CONFIG_BLE_MESH_FRIEND) && - !bt_mesh_friend_queue_has_space(tx->sub->net_idx, net_tx->src, - tx->dst, &tx->seq_auth, - tx->seg_n + 1) && - BLE_MESH_ADDR_IS_UNICAST(tx->dst)) { + !bt_mesh_friend_queue_has_space(tx->sub->net_idx, net_tx->src, + tx->dst, &tx->seq_auth, + tx->seg_n + 1) && + BLE_MESH_ADDR_IS_UNICAST(tx->dst)) { BT_ERR("Not enough space in Friend Queue for %u segments", - tx->seg_n + 1); + tx->seg_n + 1); seg_tx_reset(tx); return -ENOBUFS; } @@ -428,10 +428,10 @@ static int send_seg(struct bt_mesh_net_tx *net_tx, struct net_buf_simple *sdu, } if (bt_mesh_friend_enqueue_tx(net_tx, type, - &tx->seq_auth, - tx->seg_n + 1, - &seg->b) && - BLE_MESH_ADDR_IS_UNICAST(net_tx->ctx->addr)) { + &tx->seq_auth, + tx->seg_n + 1, + &seg->b) && + BLE_MESH_ADDR_IS_UNICAST(net_tx->ctx->addr)) { /* PDUs for a specific Friend should only go * out through the Friend Queue. */ @@ -466,10 +466,10 @@ static int send_seg(struct bt_mesh_net_tx *net_tx, struct net_buf_simple *sdu, } if (IS_ENABLED(CONFIG_BLE_MESH_NODE) && bt_mesh_is_provisioned()) { - if (IS_ENABLED(CONFIG_BLE_MESH_LOW_POWER) && - bt_mesh_lpn_established()) { - bt_mesh_lpn_poll(); - } + if (IS_ENABLED(CONFIG_BLE_MESH_LOW_POWER) && + bt_mesh_lpn_established()) { + bt_mesh_lpn_poll(); + } } return 0; @@ -760,7 +760,7 @@ static int sdu_recv(struct bt_mesh_net_rx *rx, u32_t seq, u8_t hdr, BLE_MESH_NET_IVI_RX(rx)); if (err) { BT_DBG("Unable to decrypt with AppKey 0x%03x", - key->app_idx); + key->app_idx); continue; } @@ -927,45 +927,45 @@ static int ctl_recv(struct bt_mesh_net_rx *rx, u8_t hdr, } if (IS_ENABLED(CONFIG_BLE_MESH_NODE) && bt_mesh_is_provisioned()) { - if (IS_ENABLED(CONFIG_BLE_MESH_FRIEND) && !bt_mesh_lpn_established()) { - switch (ctl_op) { - case TRANS_CTL_OP_FRIEND_POLL: - return bt_mesh_friend_poll(rx, buf); - case TRANS_CTL_OP_FRIEND_REQ: - return bt_mesh_friend_req(rx, buf); - case TRANS_CTL_OP_FRIEND_CLEAR: - return bt_mesh_friend_clear(rx, buf); - case TRANS_CTL_OP_FRIEND_CLEAR_CFM: - return bt_mesh_friend_clear_cfm(rx, buf); - case TRANS_CTL_OP_FRIEND_SUB_ADD: - return bt_mesh_friend_sub_add(rx, buf); - case TRANS_CTL_OP_FRIEND_SUB_REM: - return bt_mesh_friend_sub_rem(rx, buf); + if (IS_ENABLED(CONFIG_BLE_MESH_FRIEND) && !bt_mesh_lpn_established()) { + switch (ctl_op) { + case TRANS_CTL_OP_FRIEND_POLL: + return bt_mesh_friend_poll(rx, buf); + case TRANS_CTL_OP_FRIEND_REQ: + return bt_mesh_friend_req(rx, buf); + case TRANS_CTL_OP_FRIEND_CLEAR: + return bt_mesh_friend_clear(rx, buf); + case TRANS_CTL_OP_FRIEND_CLEAR_CFM: + return bt_mesh_friend_clear_cfm(rx, buf); + case TRANS_CTL_OP_FRIEND_SUB_ADD: + return bt_mesh_friend_sub_add(rx, buf); + case TRANS_CTL_OP_FRIEND_SUB_REM: + return bt_mesh_friend_sub_rem(rx, buf); + } } - } #if defined(CONFIG_BLE_MESH_LOW_POWER) - if (ctl_op == TRANS_CTL_OP_FRIEND_OFFER) { - return bt_mesh_lpn_friend_offer(rx, buf); - } - - if (rx->ctx.addr == bt_mesh.lpn.frnd) { - if (ctl_op == TRANS_CTL_OP_FRIEND_CLEAR_CFM) { - return bt_mesh_lpn_friend_clear_cfm(rx, buf); + if (ctl_op == TRANS_CTL_OP_FRIEND_OFFER) { + return bt_mesh_lpn_friend_offer(rx, buf); } - if (!rx->friend_cred) { - BT_WARN("Message from friend with wrong credentials"); - return -EINVAL; - } + if (rx->ctx.addr == bt_mesh.lpn.frnd) { + if (ctl_op == TRANS_CTL_OP_FRIEND_CLEAR_CFM) { + return bt_mesh_lpn_friend_clear_cfm(rx, buf); + } - switch (ctl_op) { - case TRANS_CTL_OP_FRIEND_UPDATE: - return bt_mesh_lpn_friend_update(rx, buf); - case TRANS_CTL_OP_FRIEND_SUB_CFM: - return bt_mesh_lpn_friend_sub_cfm(rx, buf); + if (!rx->friend_cred) { + BT_WARN("Message from friend with wrong credentials"); + return -EINVAL; + } + + switch (ctl_op) { + case TRANS_CTL_OP_FRIEND_UPDATE: + return bt_mesh_lpn_friend_update(rx, buf); + case TRANS_CTL_OP_FRIEND_SUB_CFM: + return bt_mesh_lpn_friend_sub_cfm(rx, buf); + } } - } #endif /* CONFIG_BLE_MESH_LOW_POWER */ } @@ -1056,7 +1056,7 @@ int bt_mesh_ctl_send(struct bt_mesh_net_tx *tx, u8_t ctl_op, void *data, if (IS_ENABLED(CONFIG_BLE_MESH_FRIEND)) { if (bt_mesh_friend_enqueue_tx(tx, BLE_MESH_FRIEND_PDU_SINGLE, seq_auth, 1, &buf->b) && - BLE_MESH_ADDR_IS_UNICAST(tx->ctx->addr)) { + BLE_MESH_ADDR_IS_UNICAST(tx->ctx->addr)) { /* PDUs for a specific Friend should only go * out through the Friend Queue. */ @@ -1281,7 +1281,7 @@ static int trans_seg(struct net_buf_simple *buf, struct bt_mesh_net_rx *net_rx, if (is_replay(net_rx, &rpl)) { BT_WARN("Replay: src 0x%04x dst 0x%04x seq 0x%06x", - net_rx->ctx.addr, net_rx->ctx.recv_dst, net_rx->seq); + net_rx->ctx.addr, net_rx->ctx.recv_dst, net_rx->seq); return -EINVAL; } @@ -1375,11 +1375,11 @@ static int trans_seg(struct net_buf_simple *buf, struct bt_mesh_net_rx *net_rx, * case this message is destined to an LPN of ours. */ if (IS_ENABLED(CONFIG_BLE_MESH_FRIEND) && - net_rx->friend_match && !net_rx->local_match && - !bt_mesh_friend_queue_has_space(net_rx->sub->net_idx, - net_rx->ctx.addr, - net_rx->ctx.recv_dst, seq_auth, - *seg_count)) { + net_rx->friend_match && !net_rx->local_match && + !bt_mesh_friend_queue_has_space(net_rx->sub->net_idx, + net_rx->ctx.addr, + net_rx->ctx.recv_dst, seq_auth, + *seg_count)) { BT_ERR("No space in Friend Queue for %u segments", *seg_count); send_ack(net_rx->sub, net_rx->ctx.recv_dst, net_rx->ctx.addr, net_rx->ctx.send_ttl, seq_auth, 0, @@ -1504,12 +1504,12 @@ int bt_mesh_trans_recv(struct net_buf_simple *buf, struct bt_mesh_net_rx *rx) * be encrypted using the Friend Credentials. */ if (IS_ENABLED(CONFIG_BLE_MESH_NODE) && bt_mesh_is_provisioned()) { - if (IS_ENABLED(CONFIG_BLE_MESH_LOW_POWER) && - bt_mesh_lpn_established() && rx->net_if == BLE_MESH_NET_IF_ADV && - (!bt_mesh_lpn_waiting_update() || !rx->friend_cred)) { - BT_WARN("Ignoring unexpected message in Low Power mode"); - return -EAGAIN; - } + if (IS_ENABLED(CONFIG_BLE_MESH_LOW_POWER) && + bt_mesh_lpn_established() && rx->net_if == BLE_MESH_NET_IF_ADV && + (!bt_mesh_lpn_waiting_update() || !rx->friend_cred)) { + BT_WARN("Ignoring unexpected message in Low Power mode"); + return -EAGAIN; + } } /* Save the app-level state so the buffer can later be placed in @@ -1545,7 +1545,7 @@ int bt_mesh_trans_recv(struct net_buf_simple *buf, struct bt_mesh_net_rx *rx) if (IS_ENABLED(CONFIG_BLE_MESH_NODE) && bt_mesh_is_provisioned()) { if (IS_ENABLED(CONFIG_BLE_MESH_LOW_POWER) && (bt_mesh_lpn_timer() || - (bt_mesh_lpn_established() && bt_mesh_lpn_waiting_update()))) { + (bt_mesh_lpn_established() && bt_mesh_lpn_waiting_update()))) { bt_mesh_lpn_msg_received(rx); } } @@ -1556,10 +1556,10 @@ int bt_mesh_trans_recv(struct net_buf_simple *buf, struct bt_mesh_net_rx *rx) if (IS_ENABLED(CONFIG_BLE_MESH_FRIEND) && rx->friend_match && !err) { if (seq_auth == TRANS_SEQ_AUTH_NVAL) { bt_mesh_friend_enqueue_rx(rx, pdu_type, NULL, - seg_count, buf); + seg_count, buf); } else { bt_mesh_friend_enqueue_rx(rx, pdu_type, &seq_auth, - seg_count, buf); + seg_count, buf); } } } @@ -1666,5 +1666,5 @@ void bt_mesh_heartbeat_send(void) BT_DBG("InitTTL %u feat 0x%04x", cfg->hb_pub.ttl, feat); bt_mesh_ctl_send(&tx, TRANS_CTL_OP_HEARTBEAT, &hb, sizeof(hb), - NULL, NULL, NULL); + NULL, NULL, NULL); } diff --git a/components/bt/esp_ble_mesh/mesh_models/client/client_common.c b/components/bt/esp_ble_mesh/mesh_models/client/client_common.c index 7c2ac19b3..bd7231ead 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/client_common.c +++ b/components/bt/esp_ble_mesh/mesh_models/client/client_common.c @@ -26,15 +26,32 @@ #include "mesh.h" #include "client_common.h" +static bt_mesh_client_node_t *bt_mesh_client_pick_node(sys_slist_t *list, u16_t tx_dst) +{ + if (sys_slist_is_empty(list)) { + return NULL; + } + + sys_snode_t *cur = NULL; bt_mesh_client_node_t *node = NULL; + for (cur = sys_slist_peek_head(list); + cur != NULL; cur = sys_slist_peek_next(cur)) { + node = (bt_mesh_client_node_t *)cur; + if (node->ctx.addr == tx_dst) { + return node; + } + } + + return NULL; +} + bt_mesh_client_node_t *bt_mesh_is_client_recv_publish_msg( - struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf, bool need_pub) + struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf, bool need_pub) { bt_mesh_client_internal_data_t *data = NULL; bt_mesh_client_user_data_t *cli = NULL; bt_mesh_client_node_t *node = NULL; - u32_t rsp; if (!model || !ctx || !buf) { BT_ERR("%s, Invalid parameter", __func__); @@ -47,16 +64,14 @@ bt_mesh_client_node_t *bt_mesh_is_client_recv_publish_msg( return NULL; } - rsp = ctx->recv_op; - /** If the received message address is not a unicast address, * the address may be a group/virtual address, and we push * this message to the application layer. */ if (!BLE_MESH_ADDR_IS_UNICAST(ctx->recv_dst)) { - BT_DBG("Unexpected status message 0x%x", rsp); + BT_DBG("Unexpected status message 0x%x", ctx->recv_op); if (cli->publish_status && need_pub) { - cli->publish_status(rsp, model, ctx, buf); + cli->publish_status(ctx->recv_op, model, ctx, buf); } return NULL; } @@ -73,17 +88,17 @@ bt_mesh_client_node_t *bt_mesh_is_client_recv_publish_msg( } if ((node = bt_mesh_client_pick_node(&data->queue, ctx->addr)) == NULL) { - BT_DBG("Unexpected status message 0x%x", rsp); + BT_DBG("Unexpected status message 0x%x", ctx->recv_op); if (cli->publish_status && need_pub) { - cli->publish_status(rsp, model, ctx, buf); + cli->publish_status(ctx->recv_op, model, ctx, buf); } return NULL; } - if (node->op_pending != rsp) { - BT_DBG("Unexpected status message 0x%x", rsp); + if (node->op_pending != ctx->recv_op) { + BT_DBG("Unexpected status message 0x%x", ctx->recv_op); if (cli->publish_status && need_pub) { - cli->publish_status(rsp, model, ctx, buf); + cli->publish_status(ctx->recv_op, model, ctx, buf); } return NULL; } @@ -91,26 +106,7 @@ bt_mesh_client_node_t *bt_mesh_is_client_recv_publish_msg( return node; } -bool bt_mesh_client_find_opcode_in_list(sys_slist_t *list, u32_t opcode) -{ - if (sys_slist_is_empty(list)) { - return false; - } - - sys_snode_t *cur = NULL; bt_mesh_client_node_t *node = NULL; - for (cur = sys_slist_peek_head(list); - cur != NULL; cur = sys_slist_peek_next(cur)) { - node = (bt_mesh_client_node_t *)cur; - if (node->op_pending == opcode) { - return true; - } - return NULL; - } - - return node; -} - -bool bt_mesh_client_check_node_in_list(sys_slist_t *list, u16_t tx_dst) +static bool bt_mesh_client_check_node_in_list(sys_slist_t *list, u16_t tx_dst) { if (sys_slist_is_empty(list)) { return false; @@ -128,24 +124,6 @@ bool bt_mesh_client_check_node_in_list(sys_slist_t *list, u16_t tx_dst) return false; } -bt_mesh_client_node_t *bt_mesh_client_pick_node(sys_slist_t *list, u16_t tx_dst) -{ - if (sys_slist_is_empty(list)) { - return NULL; - } - - sys_snode_t *cur = NULL; bt_mesh_client_node_t *node = NULL; - for (cur = sys_slist_peek_head(list); - cur != NULL; cur = sys_slist_peek_next(cur)) { - node = (bt_mesh_client_node_t *)cur; - if (node->ctx.addr == tx_dst) { - return node; - } - } - - return NULL; -} - static u32_t bt_mesh_client_get_status_op(const bt_mesh_client_op_pair_t *op_pair, int size, u32_t opcode) { diff --git a/components/bt/esp_ble_mesh/mesh_models/client/generic_client.c b/components/bt/esp_ble_mesh/mesh_models/client/generic_client.c index fd8986797..48b540b41 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/generic_client.c +++ b/components/bt/esp_ble_mesh/mesh_models/client/generic_client.c @@ -157,7 +157,7 @@ static void timeout_handler(struct k_work *work) node = CONTAINER_OF(work, bt_mesh_client_node_t, timer.work); if (node) { bt_mesh_generic_client_cb_evt_to_btc(node->opcode, - BTC_BLE_MESH_EVT_GENERIC_CLIENT_TIMEOUT, node->ctx.model, &node->ctx, NULL, 0); + BTC_BLE_MESH_EVT_GENERIC_CLIENT_TIMEOUT, node->ctx.model, &node->ctx, NULL, 0); // Don't forget to release the node at the end. bt_mesh_client_free_node(node); } diff --git a/components/bt/esp_ble_mesh/mesh_models/client/include/client_common.h b/components/bt/esp_ble_mesh/mesh_models/client/include/client_common.h index 79aacaac3..74eb366ca 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/include/client_common.h +++ b/components/bt/esp_ble_mesh/mesh_models/client/include/client_common.h @@ -94,15 +94,9 @@ int bt_mesh_client_init(struct bt_mesh_model *model); * @return 0 on success, or (negative) error code on failure. */ bt_mesh_client_node_t *bt_mesh_is_client_recv_publish_msg( - struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - struct net_buf_simple *buf, bool need_pub); - -bool bt_mesh_client_find_opcode_in_list(sys_slist_t *list, u32_t opcode); - -bool bt_mesh_client_check_node_in_list(sys_slist_t *list, uint16_t tx_dst); - -bt_mesh_client_node_t *bt_mesh_client_pick_node(sys_slist_t *list, u16_t tx_dst); + struct bt_mesh_model *model, + struct bt_mesh_msg_ctx *ctx, + struct net_buf_simple *buf, bool need_pub); int bt_mesh_client_send_msg(struct bt_mesh_model *model, u32_t opcode, diff --git a/components/bt/esp_ble_mesh/mesh_models/client/lighting_client.c b/components/bt/esp_ble_mesh/mesh_models/client/lighting_client.c index a73f91a36..78b80d7b0 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/lighting_client.c +++ b/components/bt/esp_ble_mesh/mesh_models/client/lighting_client.c @@ -166,7 +166,7 @@ static void timeout_handler(struct k_work *work) node = CONTAINER_OF(work, bt_mesh_client_node_t, timer.work); if (node) { bt_mesh_lighting_client_cb_evt_to_btc(node->opcode, - BTC_BLE_MESH_EVT_LIGHTING_CLIENT_TIMEOUT, node->ctx.model, &node->ctx, NULL, 0); + BTC_BLE_MESH_EVT_LIGHTING_CLIENT_TIMEOUT, node->ctx.model, &node->ctx, NULL, 0); // Don't forget to release the node at the end. bt_mesh_client_free_node(node); } diff --git a/components/bt/esp_ble_mesh/mesh_models/client/sensor_client.c b/components/bt/esp_ble_mesh/mesh_models/client/sensor_client.c index e3eda759a..7b93aecfb 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/sensor_client.c +++ b/components/bt/esp_ble_mesh/mesh_models/client/sensor_client.c @@ -95,7 +95,7 @@ static void timeout_handler(struct k_work *work) node = CONTAINER_OF(work, bt_mesh_client_node_t, timer.work); if (node) { bt_mesh_sensor_client_cb_evt_to_btc(node->opcode, - BTC_BLE_MESH_EVT_SENSOR_CLIENT_TIMEOUT, node->ctx.model, &node->ctx, NULL, 0); + BTC_BLE_MESH_EVT_SENSOR_CLIENT_TIMEOUT, node->ctx.model, &node->ctx, NULL, 0); // Don't forget to release the node at the end. bt_mesh_client_free_node(node); } diff --git a/components/bt/esp_ble_mesh/mesh_models/client/time_scene_client.c b/components/bt/esp_ble_mesh/mesh_models/client/time_scene_client.c index 3b05be51b..878ef3da3 100644 --- a/components/bt/esp_ble_mesh/mesh_models/client/time_scene_client.c +++ b/components/bt/esp_ble_mesh/mesh_models/client/time_scene_client.c @@ -111,7 +111,7 @@ static void timeout_handler(struct k_work *work) node = CONTAINER_OF(work, bt_mesh_client_node_t, timer.work); if (node) { bt_mesh_time_scene_client_cb_evt_to_btc(node->opcode, - BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_TIMEOUT, node->ctx.model, &node->ctx, NULL, 0); + BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_TIMEOUT, node->ctx.model, &node->ctx, NULL, 0); // Don't forget to release the node at the end. bt_mesh_client_free_node(node); } diff --git a/components/bt/esp_ble_mesh/mesh_models/server/generic_server.c b/components/bt/esp_ble_mesh/mesh_models/server/generic_server.c index efe0e35fe..4bc4bbf65 100644 --- a/components/bt/esp_ble_mesh/mesh_models/server/generic_server.c +++ b/components/bt/esp_ble_mesh/mesh_models/server/generic_server.c @@ -654,8 +654,8 @@ static void gen_move_set(struct bt_mesh_model *model, /* Generic Default Transition Time Server message handlers */ static void send_gen_def_trans_time_status(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - bool publish) + struct bt_mesh_msg_ctx *ctx, + bool publish) { struct bt_mesh_gen_def_trans_time_srv *srv = model->user_data; struct net_buf_simple *msg = NULL; @@ -1250,7 +1250,7 @@ static void gen_power_range_set(struct bt_mesh_model *model, if (range_min > range_max) { BT_ERR("%s, Range Min 0x%04x is greater than Range Max 0x%04x", - __func__, range_min, range_max); + __func__, range_min, range_max); return; } @@ -1540,7 +1540,7 @@ static void gen_location_set(struct bt_mesh_model *model, } if (ctx->recv_op == BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_SET || - ctx->recv_op == BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_SET) { + ctx->recv_op == BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_SET) { send_gen_location_status(model, ctx, false, opcode); } send_gen_location_status(model, NULL, true, opcode); @@ -1550,7 +1550,7 @@ static void gen_location_set(struct bt_mesh_model *model, /* Generic User Property Server message handlers */ struct bt_mesh_generic_property *gen_get_user_property(struct bt_mesh_model *model, - u16_t property_id) + u16_t property_id) { struct bt_mesh_gen_user_prop_srv *srv = model->user_data; u8_t i; @@ -1605,12 +1605,12 @@ static void send_gen_user_prop_status(struct bt_mesh_model *model, net_buf_simple_add_le16(msg, property->id); net_buf_simple_add_u8(msg, property->user_access); if ((ctx->recv_op == BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_GET && - property->user_access != USER_ACCESS_PROHIBIT && - property->user_access != USER_ACCESS_WRITE) || - ((ctx->recv_op == BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET || - ctx->recv_op == BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET_UNACK) && - property->user_access != USER_ACCESS_PROHIBIT && - property->user_access != USER_ACCESS_READ)) { + property->user_access != USER_ACCESS_PROHIBIT && + property->user_access != USER_ACCESS_WRITE) || + ((ctx->recv_op == BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET || + ctx->recv_op == BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET_UNACK) && + property->user_access != USER_ACCESS_PROHIBIT && + property->user_access != USER_ACCESS_READ)) { net_buf_simple_add_mem(msg, property->val->data, property->val->len); } } @@ -1666,7 +1666,7 @@ static void gen_user_prop_get(struct bt_mesh_model *model, bt_mesh_model_msg_init(msg, BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_STATUS); for (i = 0U; i < srv->property_count; i++) { if (srv->properties[i].admin_access != ADMIN_NOT_USER_PROP && - srv->properties[i].manu_access != MANU_NOT_USER_PROP) { + srv->properties[i].manu_access != MANU_NOT_USER_PROP) { net_buf_simple_add_le16(msg, srv->properties[i].id); } } @@ -1714,7 +1714,7 @@ static void gen_user_prop_set(struct bt_mesh_model *model, property = gen_get_user_property(model, property_id); if (property == NULL || property->user_access == USER_ACCESS_PROHIBIT || - property->user_access == USER_ACCESS_READ) { + property->user_access == USER_ACCESS_READ) { if (ctx->recv_op == BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET) { send_gen_user_prop_status(model, ctx, property_id, false); } @@ -1730,7 +1730,7 @@ static void gen_user_prop_set(struct bt_mesh_model *model, expect_len = bt_mesh_get_dev_prop_len(property_id); if (buf->len != expect_len) { BT_ERR("%s, Invalid User Property length, ID 0x%04x, expect %d, actual %d", - __func__, property_id, expect_len, buf->len); + __func__, property_id, expect_len, buf->len); return; } @@ -1754,7 +1754,7 @@ static void gen_user_prop_set(struct bt_mesh_model *model, /* Generic Admin Property Server message handlers */ struct bt_mesh_generic_property *gen_get_admin_property(struct bt_mesh_model *model, - u16_t property_id) + u16_t property_id) { struct bt_mesh_gen_admin_prop_srv *srv = model->user_data; u8_t i; @@ -1809,7 +1809,7 @@ static void send_gen_admin_prop_status(struct bt_mesh_model *model, net_buf_simple_add_le16(msg, property->id); net_buf_simple_add_u8(msg, property->admin_access); if (ctx->recv_op != BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_GET || - property->admin_access != ADMIN_ACCESS_WRITE) { + property->admin_access != ADMIN_ACCESS_WRITE) { net_buf_simple_add_mem(msg, property->val->data, property->val->len); } } @@ -1942,7 +1942,7 @@ static void gen_admin_prop_set(struct bt_mesh_model *model, /* Generic Manufacturer Property Server message handlers */ struct bt_mesh_generic_property *gen_get_manu_property(struct bt_mesh_model *model, - u16_t property_id) + u16_t property_id) { struct bt_mesh_gen_manu_prop_srv *srv = model->user_data; u8_t i; @@ -2332,8 +2332,12 @@ const struct bt_mesh_model_op gen_client_prop_srv_op[] = { static inline int property_id_compare(const void *p1, const void *p2) { - if (*(u16_t *)p1 < *(u16_t *)p2) return -1; - if (*(u16_t *)p1 > *(u16_t *)p2) return 1; + if (*(u16_t *)p1 < * (u16_t *)p2) { + return -1; + } + if (*(u16_t *)p1 > *(u16_t *)p2) { + return 1; + } return 0; } diff --git a/components/bt/esp_ble_mesh/mesh_models/server/include/time_scene_server.h b/components/bt/esp_ble_mesh/mesh_models/server/include/time_scene_server.h index 2e82f2283..846677699 100644 --- a/components/bt/esp_ble_mesh/mesh_models/server/include/time_scene_server.h +++ b/components/bt/esp_ble_mesh/mesh_models/server/include/time_scene_server.h @@ -128,7 +128,7 @@ struct scene_register { * mesh-wide value. (There can be a maximum of 65535 scenes in a mesh * network.) The meaning of a scene, as well as the state storage container * associated with it, are determined by a model. - * + * * The Scenes state change may start numerous parallel model transitions. * In that case, each individual model handles the transition internally. * diff --git a/components/bt/esp_ble_mesh/mesh_models/server/lighting_server.c b/components/bt/esp_ble_mesh/mesh_models/server/lighting_server.c index 9551b9877..9948d8d24 100644 --- a/components/bt/esp_ble_mesh/mesh_models/server/lighting_server.c +++ b/components/bt/esp_ble_mesh/mesh_models/server/lighting_server.c @@ -485,7 +485,7 @@ static void light_lightness_range_set(struct bt_mesh_model *model, if (range_min > range_max) { BT_ERR("%s, Range Min 0x%04x is greater than Range Max 0x%04x", - __func__, range_min, range_max); + __func__, range_min, range_max); return; } @@ -810,20 +810,20 @@ static void light_ctl_set(struct bt_mesh_model *model, srv->state->target_lightness = lightness; if (srv->state->temperature_range_min && - srv->state->temperature_range_min != BLE_MESH_TEMPERATURE_UNKNOWN && - temperature < srv->state->temperature_range_min) { + srv->state->temperature_range_min != BLE_MESH_TEMPERATURE_UNKNOWN && + temperature < srv->state->temperature_range_min) { temperature = srv->state->temperature_range_min; } else if (srv->state->temperature_range_max && - srv->state->temperature_range_max != BLE_MESH_TEMPERATURE_UNKNOWN && - temperature > srv->state->temperature_range_max) { + srv->state->temperature_range_max != BLE_MESH_TEMPERATURE_UNKNOWN && + temperature > srv->state->temperature_range_max) { temperature = srv->state->temperature_range_max; } srv->state->target_temperature = temperature; srv->state->target_delta_uv = delta_uv; if (srv->state->target_lightness != srv->state->lightness || - srv->state->target_temperature != srv->state->temperature || - srv->state->target_delta_uv != srv->state->delta_uv) { + srv->state->target_temperature != srv->state->temperature || + srv->state->target_delta_uv != srv->state->delta_uv) { light_ctl_tt_values(srv, trans_time, delay); } else { bt_mesh_light_server_state_change_t change = { @@ -902,12 +902,12 @@ static void light_ctl_default_set(struct bt_mesh_model *model, } if (srv->state->temperature_range_min && - srv->state->temperature_range_min != BLE_MESH_TEMPERATURE_UNKNOWN && - temperature < srv->state->temperature_range_min) { + srv->state->temperature_range_min != BLE_MESH_TEMPERATURE_UNKNOWN && + temperature < srv->state->temperature_range_min) { temperature = srv->state->temperature_range_min; } else if (srv->state->temperature_range_max && - srv->state->temperature_range_max != BLE_MESH_TEMPERATURE_UNKNOWN && - temperature > srv->state->temperature_range_max) { + srv->state->temperature_range_max != BLE_MESH_TEMPERATURE_UNKNOWN && + temperature > srv->state->temperature_range_max) { temperature = srv->state->temperature_range_max; } @@ -948,10 +948,10 @@ static void light_ctl_temp_range_set(struct bt_mesh_model *model, /* This is as per 6.1.3.1 in Mesh Model Specification */ if (min > max || - min < BLE_MESH_TEMPERATURE_MIN || (min != BLE_MESH_TEMPERATURE_UNKNOWN && min > BLE_MESH_TEMPERATURE_MAX) || - max < BLE_MESH_TEMPERATURE_MIN || (max != BLE_MESH_TEMPERATURE_UNKNOWN && max > BLE_MESH_TEMPERATURE_MAX)) { + min < BLE_MESH_TEMPERATURE_MIN || (min != BLE_MESH_TEMPERATURE_UNKNOWN && min > BLE_MESH_TEMPERATURE_MAX) || + max < BLE_MESH_TEMPERATURE_MIN || (max != BLE_MESH_TEMPERATURE_UNKNOWN && max > BLE_MESH_TEMPERATURE_MAX)) { BT_ERR("%s, Invalid parameter, range Min 0x%04x, range max 0x%04x", - __func__, min, max); + __func__, min, max); return; } @@ -1056,19 +1056,19 @@ static void light_ctl_temp_set(struct bt_mesh_model *model, bt_mesh_server_update_last_msg(&srv->last, tid, ctx->addr, ctx->recv_dst, &now); if (srv->state->temperature_range_min && - srv->state->temperature_range_min != BLE_MESH_TEMPERATURE_UNKNOWN && - temperature < srv->state->temperature_range_min) { + srv->state->temperature_range_min != BLE_MESH_TEMPERATURE_UNKNOWN && + temperature < srv->state->temperature_range_min) { temperature = srv->state->temperature_range_min; } else if (srv->state->temperature_range_max && - srv->state->temperature_range_max != BLE_MESH_TEMPERATURE_UNKNOWN && - temperature > srv->state->temperature_range_max) { + srv->state->temperature_range_max != BLE_MESH_TEMPERATURE_UNKNOWN && + temperature > srv->state->temperature_range_max) { temperature = srv->state->temperature_range_max; } srv->state->target_temperature = temperature; srv->state->target_delta_uv = delta_uv; if (srv->state->target_temperature != srv->state->temperature || - srv->state->target_delta_uv != srv->state->delta_uv) { + srv->state->target_delta_uv != srv->state->delta_uv) { light_ctl_temp_tt_values(srv, trans_time, delay); } else { bt_mesh_light_server_state_change_t change = { @@ -1430,8 +1430,8 @@ static void light_hsl_set(struct bt_mesh_model *model, * be started and is considered complete. */ if (srv->state->target_lightness != srv->state->lightness || - srv->state->target_hue != srv->state->hue || - srv->state->target_saturation != srv->state->saturation) { + srv->state->target_hue != srv->state->hue || + srv->state->target_saturation != srv->state->saturation) { light_hsl_tt_values(srv, trans_time, delay); } else { bt_mesh_light_server_state_change_t change = { @@ -1554,13 +1554,13 @@ static void light_hsl_range_set(struct bt_mesh_model *model, if (hue_min > hue_max) { BT_ERR("%s, Invalid parameter, Hue min 0x%04x, Hue max 0x%04x", - __func__, hue_min, hue_max); + __func__, hue_min, hue_max); return; } if (saturation_min > saturation_max) { BT_ERR("%s, Invalid parameter, Saturation min 0x%04x, Saturation max 0x%04x", - __func__, hue_min, hue_max); + __func__, hue_min, hue_max); return; } @@ -2047,8 +2047,8 @@ static void light_xyl_set(struct bt_mesh_model *model, * be started and is considered complete. */ if (srv->state->target_lightness != srv->state->lightness || - srv->state->target_x != srv->state->x || - srv->state->target_y != srv->state->y) { + srv->state->target_x != srv->state->x || + srv->state->target_y != srv->state->y) { light_xyl_tt_values(srv, trans_time, delay); } else { bt_mesh_light_server_state_change_t change = { @@ -2171,13 +2171,13 @@ static void light_xyl_range_set(struct bt_mesh_model *model, if (x_min > x_max) { BT_ERR("%s, Invalid parameter, xyL x min 0x%04x, xyL x max 0x%04x", - __func__, x_min, x_max); + __func__, x_min, x_max); return; } if (y_min > y_max) { BT_ERR("%s, Invalid parameter, xyL y min 0x%04x, xyL y max 0x%04x", - __func__, y_min, y_max); + __func__, y_min, y_max); return; } @@ -2528,13 +2528,13 @@ static void light_lc_sensor_status(struct bt_mesh_model *model, * field contains a Raw Value for the Present Ambient Light Level device property, * it shall set the Light LC Ambient LuxLevel state to the Represented Value of the * received Present Ambient Light Level. - * + * * Motion Sensed: 1 octet, 0x0042 * People Count: 2 octets, 0x004C * Presence Detected: 1 octet, 0x004D - * + * * Time Since Motion Sensed: 2 octets, 0x0068 - * + * * Present Ambient Light Level: 4 octets, 0x004E */ struct bt_mesh_light_lc_srv *srv = model->user_data; @@ -2834,7 +2834,7 @@ static void light_lc_prop_set(struct bt_mesh_model *model, expect_len = bt_mesh_get_dev_prop_len(prop_id); if (buf->len != expect_len) { BT_ERR("%s, Invalid Light LC Property length, ID 0x%04x, expect %d, actual %d", - __func__, prop_id, expect_len, buf->len); + __func__, prop_id, expect_len, buf->len); return; } diff --git a/components/bt/esp_ble_mesh/mesh_models/server/sensor_server.c b/components/bt/esp_ble_mesh/mesh_models/server/sensor_server.c index 6c568025d..a28930f75 100644 --- a/components/bt/esp_ble_mesh/mesh_models/server/sensor_server.c +++ b/components/bt/esp_ble_mesh/mesh_models/server/sensor_server.c @@ -38,8 +38,8 @@ static void update_sensor_periodic_pub(struct bt_mesh_model *model, u16_t prop_i /* Sensor Server & Sensor Setup Server message handlers */ static void send_sensor_descriptor_status(struct bt_mesh_model *model, - struct bt_mesh_msg_ctx *ctx, - u16_t prop_id, bool get_all) + struct bt_mesh_msg_ctx *ctx, + u16_t prop_id, bool get_all) { struct bt_mesh_sensor_srv *srv = model->user_data; struct bt_mesh_sensor_state *state = NULL; @@ -66,8 +66,8 @@ static void send_sensor_descriptor_status(struct bt_mesh_model *model, } net_buf_simple_add_le16(msg, state->sensor_property_id); net_buf_simple_add_le32(msg, (state->descriptor.sample_function << 24) | - (state->descriptor.negative_tolerance << 12) | - (state->descriptor.positive_tolerance)); + (state->descriptor.negative_tolerance << 12) | + (state->descriptor.positive_tolerance)); net_buf_simple_add_u8(msg, state->descriptor.measure_period); net_buf_simple_add_u8(msg, state->descriptor.update_interval); } @@ -76,11 +76,11 @@ static void send_sensor_descriptor_status(struct bt_mesh_model *model, for (i = 0U; i < srv->state_count; i++) { state = &srv->states[i]; if (state->sensor_property_id != INVALID_SENSOR_PROPERTY_ID && - state->sensor_property_id == prop_id) { + state->sensor_property_id == prop_id) { net_buf_simple_add_le16(msg, state->sensor_property_id); net_buf_simple_add_le32(msg, (state->descriptor.sample_function << 24) | - (state->descriptor.negative_tolerance << 12) | - (state->descriptor.positive_tolerance)); + (state->descriptor.negative_tolerance << 12) | + (state->descriptor.positive_tolerance)); net_buf_simple_add_u8(msg, state->descriptor.measure_period); net_buf_simple_add_u8(msg, state->descriptor.update_interval); break; @@ -122,7 +122,7 @@ static void send_sensor_data_status(struct bt_mesh_model *model, u8_t mpid_len = (state->sensor_data.format == SENSOR_DATA_FORMAT_A) ? SENSOR_DATA_FORMAT_A_MPID_LEN : SENSOR_DATA_FORMAT_B_MPID_LEN; total_len += (mpid_len + (state->sensor_data.raw_value ? - state->sensor_data.raw_value->len : 0)); + state->sensor_data.raw_value->len : 0)); if (total_len > MIN(BLE_MESH_TX_SDU_MAX, BLE_MESH_SERVER_RSP_MAX_LEN)) { /* Add this in case the message is too long */ break; @@ -145,7 +145,7 @@ static void send_sensor_data_status(struct bt_mesh_model *model, for (i = 0U; i < srv->state_count; i++) { state = &srv->states[i]; if (state->sensor_property_id != INVALID_SENSOR_PROPERTY_ID && - state->sensor_property_id == prop_id) { + state->sensor_property_id == prop_id) { if (state->sensor_data.format == SENSOR_DATA_FORMAT_A) { u16_t mpid = ((state->sensor_property_id & BIT_MASK(11)) << 5) | ((state->sensor_data.length & BIT_MASK(4)) << 1) | @@ -158,7 +158,7 @@ static void send_sensor_data_status(struct bt_mesh_model *model, } if (state->sensor_data.raw_value) { net_buf_simple_add_mem(msg, state->sensor_data.raw_value->data, - state->sensor_data.raw_value->len); + state->sensor_data.raw_value->len); } break; } @@ -189,7 +189,7 @@ static void send_sensor_cadence_status(struct bt_mesh_model *model, for (i = 0U; i < srv->state_count; i++) { state = &srv->states[i]; if (state->sensor_property_id != INVALID_SENSOR_PROPERTY_ID && - state->sensor_property_id == prop_id && state->cadence) { + state->sensor_property_id == prop_id && state->cadence) { length = SENSOR_PROPERTY_ID_LEN + 1 + 1; if (state->cadence->trigger_delta_down) { if (state->cadence->trigger_type == SENSOR_STATUS_TRIGGER_TYPE_CHAR) { @@ -237,33 +237,33 @@ static void send_sensor_cadence_status(struct bt_mesh_model *model, if (i != srv->state_count) { if (state->cadence) { net_buf_simple_add_u8(msg, (state->cadence->trigger_type << 7) | - state->cadence->period_divisor); + state->cadence->period_divisor); if (state->cadence->trigger_delta_down) { if (state->cadence->trigger_type == SENSOR_STATUS_TRIGGER_TYPE_CHAR) { net_buf_simple_add_mem(msg, state->cadence->trigger_delta_down->data, - state->cadence->trigger_delta_down->len); + state->cadence->trigger_delta_down->len); } else { net_buf_simple_add_mem(msg, state->cadence->trigger_delta_down->data, - SENSOR_STATUS_TRIGGER_UINT16_LEN); + SENSOR_STATUS_TRIGGER_UINT16_LEN); } } if (state->cadence->trigger_delta_up) { if (state->cadence->trigger_type == SENSOR_STATUS_TRIGGER_TYPE_CHAR) { net_buf_simple_add_mem(msg, state->cadence->trigger_delta_up->data, - state->cadence->trigger_delta_up->len); + state->cadence->trigger_delta_up->len); } else { net_buf_simple_add_mem(msg, state->cadence->trigger_delta_up->data, - SENSOR_STATUS_TRIGGER_UINT16_LEN); + SENSOR_STATUS_TRIGGER_UINT16_LEN); } } net_buf_simple_add_u8(msg, state->cadence->min_interval); if (state->cadence->fast_cadence_low) { net_buf_simple_add_mem(msg, state->cadence->fast_cadence_low->data, - state->cadence->fast_cadence_low->len); + state->cadence->fast_cadence_low->len); } if (state->cadence->fast_cadence_high) { net_buf_simple_add_mem(msg, state->cadence->fast_cadence_high->data, - state->cadence->fast_cadence_high->len); + state->cadence->fast_cadence_high->len); } } } @@ -300,7 +300,7 @@ static void send_sensor_settings_status(struct bt_mesh_model *model, for (i = 0U; i < srv->state_count; i++) { state = &srv->states[i]; if (state->sensor_property_id != INVALID_SENSOR_PROPERTY_ID && - state->sensor_property_id == prop_id) { + state->sensor_property_id == prop_id) { for (j = 0U; j < state->setting_count; j++) { item = &state->settings[j]; if (item->property_id != INVALID_SENSOR_SETTING_PROPERTY_ID) { @@ -325,7 +325,7 @@ static void send_sensor_settings_status(struct bt_mesh_model *model, } static struct sensor_setting *find_sensor_setting(struct bt_mesh_model *model, - u16_t prop_id, u16_t set_prop_id) + u16_t prop_id, u16_t set_prop_id) { struct bt_mesh_sensor_setup_srv *srv = model->user_data; struct bt_mesh_sensor_state *state = NULL; @@ -335,11 +335,11 @@ static struct sensor_setting *find_sensor_setting(struct bt_mesh_model *model, for (i = 0U; i < srv->state_count; i++) { state = &srv->states[i]; if (state->sensor_property_id != INVALID_SENSOR_PROPERTY_ID && - state->sensor_property_id == prop_id) { + state->sensor_property_id == prop_id) { for (j = 0U; j < state->setting_count; j++) { item = &state->settings[j]; if (item->property_id != INVALID_SENSOR_SETTING_PROPERTY_ID && - item->property_id == set_prop_id) { + item->property_id == set_prop_id) { return item; } } @@ -360,7 +360,7 @@ static void send_sensor_setting_status(struct bt_mesh_model *model, item = find_sensor_setting(model, prop_id, set_prop_id); if (item) { length = SENSOR_PROPERTY_ID_LEN + SENSOR_SETTING_PROPERTY_ID_LEN + - SENSOR_SETTING_ACCESS_LEN + (item->raw ? item->raw->len : 0); + SENSOR_SETTING_ACCESS_LEN + (item->raw ? item->raw->len : 0); } else { /* If the message is sent as a response to the Sensor Setting Get message or * a Sensor Setting Set message with an unknown Sensor Property ID field or @@ -401,7 +401,7 @@ static void send_sensor_setting_status(struct bt_mesh_model *model, */ net_buf_simple_add_u8(msg, item->access); if (ctx->recv_op != BLE_MESH_MODEL_OP_SENSOR_SETTING_SET || - item->access == SENSOR_SETTING_ACCESS_READ_WRITE) { + item->access == SENSOR_SETTING_ACCESS_READ_WRITE) { if (item->raw) { net_buf_simple_add_mem(msg, item->raw->data, item->raw->len); } @@ -431,7 +431,7 @@ static void send_sensor_column_status(struct bt_mesh_model *model, for (i = 0U; i < srv->state_count; i++) { state = &srv->states[i]; if (state->sensor_property_id != INVALID_SENSOR_PROPERTY_ID && - state->sensor_property_id == prop_id) { + state->sensor_property_id == prop_id) { length = SENSOR_PROPERTY_ID_LEN + state->series_column.raw_value_x->len; /** * TODO: column width & raw value y in Sensor Column Status are optional, @@ -464,12 +464,12 @@ static void send_sensor_column_status(struct bt_mesh_model *model, net_buf_simple_add_le16(msg, prop_id); if (i != srv->state_count) { net_buf_simple_add_mem(msg, state->series_column.raw_value_x->data, - state->series_column.raw_value_x->len); + state->series_column.raw_value_x->len); if (optional) { net_buf_simple_add_mem(msg, state->series_column.column_width->data, - state->series_column.column_width->len); + state->series_column.column_width->len); net_buf_simple_add_mem(msg, state->series_column.raw_value_y->data, - state->series_column.raw_value_y->len); + state->series_column.raw_value_y->len); } } @@ -492,7 +492,7 @@ static void send_sensor_series_status(struct bt_mesh_model *model, for (i = 0U; i < srv->state_count; i++) { state = &srv->states[i]; if (state->sensor_property_id != INVALID_SENSOR_PROPERTY_ID && - state->sensor_property_id == prop_id) { + state->sensor_property_id == prop_id) { length = SENSOR_PROPERTY_ID_LEN; /* TODO: raw value x, column width & raw value y in Sensor Series * Status are optional, here we need to add some conditions to @@ -500,8 +500,8 @@ static void send_sensor_series_status(struct bt_mesh_model *model, */ if (optional) { length += state->series_column.raw_value_x->len + - state->series_column.column_width->len + - state->series_column.raw_value_y->len; + state->series_column.column_width->len + + state->series_column.raw_value_y->len; } break; } @@ -528,11 +528,11 @@ static void send_sensor_series_status(struct bt_mesh_model *model, if (i != srv->state_count) { if (optional) { net_buf_simple_add_mem(msg, state->series_column.raw_value_x->data, - state->series_column.raw_value_x->len); + state->series_column.raw_value_x->len); net_buf_simple_add_mem(msg, state->series_column.column_width->data, - state->series_column.column_width->len); + state->series_column.column_width->len); net_buf_simple_add_mem(msg, state->series_column.raw_value_y->data, - state->series_column.raw_value_y->len); + state->series_column.raw_value_y->len); } } @@ -564,7 +564,7 @@ static void sensor_get(struct bt_mesh_model *model, return; } if (ctx->recv_op == BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_GET || - ctx->recv_op == BLE_MESH_MODEL_OP_SENSOR_GET) { + ctx->recv_op == BLE_MESH_MODEL_OP_SENSOR_GET) { bool get_all = buf->len ? false : true; if (buf->len) { prop_id = net_buf_simple_pull_le16(buf); @@ -637,7 +637,7 @@ static void sensor_get(struct bt_mesh_model *model, return; } if (ctx->recv_op == BLE_MESH_MODEL_OP_SENSOR_CADENCE_GET || - ctx->recv_op == BLE_MESH_MODEL_OP_SENSOR_SETTINGS_GET) { + ctx->recv_op == BLE_MESH_MODEL_OP_SENSOR_SETTINGS_GET) { prop_id = net_buf_simple_pull_le16(buf); if (prop_id == INVALID_SENSOR_PROPERTY_ID) { BT_ERR("%s, Prohibited Sensor Property ID 0x0000", __func__); @@ -732,7 +732,7 @@ static void sensor_cadence_set(struct bt_mesh_model *model, for (i = 0U; i < srv->state_count; i++) { state = &srv->states[i]; if (state->sensor_property_id != INVALID_SENSOR_PROPERTY_ID && - state->sensor_property_id == prop_id) { + state->sensor_property_id == prop_id) { break; } } @@ -769,7 +769,7 @@ static void sensor_cadence_set(struct bt_mesh_model *model, } if (buf->len < (trigger_len << 1) + SENSOR_STATUS_MIN_INTERVAL_LEN) { BT_ERR("%s, Invalid Sensor Cadence Set length %d, trigger type %d", - __func__, buf->len + 3, state->cadence->trigger_type); + __func__, buf->len + 3, state->cadence->trigger_type); return; } @@ -862,7 +862,7 @@ static void update_sensor_periodic_pub(struct bt_mesh_model *model, u16_t prop_i for (i = 0U; i < srv->state_count; i++) { state = &srv->states[i]; if (state->sensor_property_id != INVALID_SENSOR_PROPERTY_ID && - state->sensor_property_id == prop_id) { + state->sensor_property_id == prop_id) { break; } } @@ -926,7 +926,7 @@ static void sensor_setting_set(struct bt_mesh_model *model, if (item->access == SENSOR_SETTING_ACCESS_READ_WRITE && item->raw) { net_buf_simple_reset(item->raw); net_buf_simple_add_mem(item->raw, buf->data, - MIN(buf->len, item->raw->size)); + MIN(buf->len, item->raw->size)); change.sensor_setting_set.id = prop_id; change.sensor_setting_set.setting_id = set_prop_id; @@ -995,9 +995,9 @@ static int check_sensor_server_init(struct bt_mesh_sensor_state *state_start, } if (state->cadence) { if (state->cadence->trigger_delta_down == NULL || - state->cadence->trigger_delta_up == NULL || - state->cadence->fast_cadence_low == NULL || - state->cadence->fast_cadence_high == NULL) { + state->cadence->trigger_delta_up == NULL || + state->cadence->fast_cadence_low == NULL || + state->cadence->fast_cadence_high == NULL) { BT_ERR("%s, Invalid Sensor Cadence state", __func__); return -EINVAL; } @@ -1007,8 +1007,8 @@ static int check_sensor_server_init(struct bt_mesh_sensor_state *state_start, return -EINVAL; } if (state->series_column.raw_value_x == NULL || - state->series_column.column_width == NULL || - state->series_column.raw_value_y == NULL) { + state->series_column.column_width == NULL || + state->series_column.raw_value_y == NULL) { BT_ERR("%s, Invalid Sensor Series column state", __func__); return -EINVAL; } diff --git a/components/bt/esp_ble_mesh/mesh_models/server/server_common.c b/components/bt/esp_ble_mesh/mesh_models/server/server_common.c index 82d1c974d..5723c640e 100644 --- a/components/bt/esp_ble_mesh/mesh_models/server/server_common.c +++ b/components/bt/esp_ble_mesh/mesh_models/server/server_common.c @@ -97,9 +97,9 @@ int bt_mesh_get_light_lc_trans_time(struct bt_mesh_model *model, u8_t *trans_tim * Light LC Property Set: 0x3C, 0x004E20 -> Light LC Time Run On * Light LC Property Set: 0x37, 0x004E20 -> Light LC Time Fade On * Light LC Property Set: 0x39, 0x004E20 -> Light LC Time Fade Standby Manual - * + * * 2. Set transition time to 0x0 for BQB test case MESH/SR/LLC/BV-08-C. - * + * * TODO: Based on Light LC state and choose property property value as the * transition time. Currently directly use Light LC Time Run On property value. * Unit: Millisecond, range: [0, 16777214(0xFFFFFE)] @@ -133,7 +133,7 @@ int bt_mesh_server_get_optional(struct bt_mesh_model *model, bool *optional) { if (model == NULL || buf == NULL || trans_time == NULL || - delay == NULL || optional == NULL) { + delay == NULL || optional == NULL) { BT_ERR("%s, Invalid parameter", __func__); return -EINVAL; } @@ -208,7 +208,7 @@ bool bt_mesh_is_server_recv_last_msg(struct bt_mesh_last_msg_info *last, } if (last->tid == tid && last->src == src && last->dst == dst && - (*now - last->timestamp <= K_SECONDS(6))) { + (*now - last->timestamp <= K_SECONDS(6))) { return true; } @@ -240,7 +240,7 @@ struct net_buf_simple *bt_mesh_server_get_pub_msg(struct bt_mesh_model *model, u } if (model->pub == NULL || model->pub->msg == NULL || - model->pub->addr == BLE_MESH_ADDR_UNASSIGNED) { + model->pub->addr == BLE_MESH_ADDR_UNASSIGNED) { BT_DBG("%s, Model 0x%04x has no publication support", __func__, model->id); return NULL; } @@ -248,7 +248,7 @@ struct net_buf_simple *bt_mesh_server_get_pub_msg(struct bt_mesh_model *model, u buf = model->pub->msg; if (buf->size < msg_len) { BT_ERR("%s, Too small publication msg size %d, model 0x%04x", - __func__, buf->size, model->id); + __func__, buf->size, model->id); return NULL; } diff --git a/components/bt/esp_ble_mesh/mesh_models/server/state_binding.c b/components/bt/esp_ble_mesh/mesh_models/server/state_binding.c index 0a75cd32c..f45216a18 100644 --- a/components/bt/esp_ble_mesh/mesh_models/server/state_binding.c +++ b/components/bt/esp_ble_mesh/mesh_models/server/state_binding.c @@ -106,7 +106,7 @@ int bt_mesh_update_binding_state(struct bt_mesh_model *model, bt_mesh_server_state_value_t *value) { if (model == NULL || model->user_data == NULL || - value == NULL || type > BIND_STATE_MAX) { + value == NULL || type > BIND_STATE_MAX) { BT_ERR("%s, Invalid parameter", __func__); return -EINVAL; } diff --git a/components/bt/esp_ble_mesh/mesh_models/server/state_transition.c b/components/bt/esp_ble_mesh/mesh_models/server/state_transition.c index dbf71fa19..da05cec19 100644 --- a/components/bt/esp_ble_mesh/mesh_models/server/state_transition.c +++ b/components/bt/esp_ble_mesh/mesh_models/server/state_transition.c @@ -385,7 +385,7 @@ void generic_power_level_work_handler(struct k_work *work) bt_mesh_gen_server_state_change_t change = {0}; if (srv == NULL || srv->state == NULL || - srv->transition.timer.work._reserved == NULL) { + srv->transition.timer.work._reserved == NULL) { BT_ERR("%s, Invalid parameter", __func__); return; } @@ -447,7 +447,7 @@ void light_lightness_actual_work_handler(struct k_work *work) bt_mesh_light_server_state_change_t change = {0}; if (srv == NULL || srv->state == NULL || - srv->actual_transition.timer.work._reserved == NULL) { + srv->actual_transition.timer.work._reserved == NULL) { BT_ERR("%s, Invalid parameter", __func__); return; } @@ -509,7 +509,7 @@ void light_lightness_linear_work_handler(struct k_work *work) bt_mesh_light_server_state_change_t change = {0}; if (srv == NULL || srv->state == NULL || - srv->linear_transition.timer.work._reserved == NULL) { + srv->linear_transition.timer.work._reserved == NULL) { BT_ERR("%s, Invalid parameter", __func__); return; } @@ -561,7 +561,7 @@ void light_ctl_work_handler(struct k_work *work) bt_mesh_light_server_state_change_t change = {0}; if (srv == NULL || srv->state == NULL || - srv->transition.timer.work._reserved == NULL) { + srv->transition.timer.work._reserved == NULL) { BT_ERR("%s, Invalid parameter", __func__); return; } @@ -621,7 +621,7 @@ void light_ctl_temp_work_handler(struct k_work *work) bt_mesh_light_server_state_change_t change = {0}; if (srv == NULL || srv->state == NULL || - srv->transition.timer.work._reserved == NULL) { + srv->transition.timer.work._reserved == NULL) { BT_ERR("%s, Invalid parameter", __func__); return; } @@ -677,7 +677,7 @@ void light_hsl_work_handler(struct k_work *work) bt_mesh_light_server_state_change_t change = {0}; if (srv == NULL || srv->state == NULL || - srv->transition.timer.work._reserved == NULL) { + srv->transition.timer.work._reserved == NULL) { BT_ERR("%s, Invalid parameter", __func__); return; } @@ -737,7 +737,7 @@ void light_hsl_hue_work_handler(struct k_work *work) bt_mesh_light_server_state_change_t change = {0}; if (srv == NULL || srv->state == NULL || - srv->transition.timer.work._reserved == NULL) { + srv->transition.timer.work._reserved == NULL) { BT_ERR("%s, Invalid parameter", __func__); return; } @@ -789,7 +789,7 @@ void light_hsl_sat_work_handler(struct k_work *work) bt_mesh_light_server_state_change_t change = {0}; if (srv == NULL || srv->state == NULL || - srv->transition.timer.work._reserved == NULL) { + srv->transition.timer.work._reserved == NULL) { BT_ERR("%s, Invalid parameter", __func__); return; } @@ -841,7 +841,7 @@ void light_xyl_work_handler(struct k_work *work) bt_mesh_light_server_state_change_t change = {0}; if (srv == NULL || srv->state == NULL || - srv->transition.timer.work._reserved == NULL) { + srv->transition.timer.work._reserved == NULL) { BT_ERR("%s, Invalid parameter", __func__); return; } @@ -966,7 +966,7 @@ void scene_recall_work_handler(struct k_work *work) bt_mesh_time_scene_server_state_change_t change = {0}; if (srv == NULL || srv->state == NULL || - srv->transition.timer.work._reserved == NULL) { + srv->transition.timer.work._reserved == NULL) { BT_ERR("%s, Invalid parameter", __func__); return; } diff --git a/components/bt/esp_ble_mesh/mesh_models/server/time_scene_server.c b/components/bt/esp_ble_mesh/mesh_models/server/time_scene_server.c index 58a4850cd..fec69b166 100644 --- a/components/bt/esp_ble_mesh/mesh_models/server/time_scene_server.c +++ b/components/bt/esp_ble_mesh/mesh_models/server/time_scene_server.c @@ -99,7 +99,7 @@ static void send_time_status(struct bt_mesh_model *model, */ net_buf_simple_add_u8(msg, srv->state->time.uncertainty); net_buf_simple_add_le16(msg, - (srv->state->time.tai_utc_delta_curr << 1) | srv->state->time.time_authority); + (srv->state->time.tai_utc_delta_curr << 1) | srv->state->time.time_authority); net_buf_simple_add_u8(msg, srv->state->time.time_zone_offset_curr); } } else if (model->id == BLE_MESH_MODEL_ID_TIME_SETUP_SRV) { @@ -109,7 +109,7 @@ static void send_time_status(struct bt_mesh_model *model, net_buf_simple_add_u8(msg, srv->state->time.subsecond); net_buf_simple_add_u8(msg, srv->state->time.uncertainty); net_buf_simple_add_le16(msg, - (srv->state->time.tai_utc_delta_curr << 1) | srv->state->time.time_authority); + (srv->state->time.tai_utc_delta_curr << 1) | srv->state->time.time_authority); net_buf_simple_add_u8(msg, srv->state->time.time_zone_offset_curr); } } @@ -219,7 +219,7 @@ static void time_get(struct bt_mesh_model *model, return; } if (srv->state->time_role != TIME_RELAY && - srv->state->time_role != TIME_CLINET) { + srv->state->time_role != TIME_CLINET) { /** * If the value of the Time Role state of the element is 0x00 (None) or * 0x01 (Time Authority), the message shall be ignored. @@ -275,7 +275,7 @@ static void time_get(struct bt_mesh_model *model, BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_STATE_CHANGE, model, ctx, (const u8_t *)&change, sizeof(change)); if (model->pub == NULL || model->pub->msg == NULL || - model->pub->addr == BLE_MESH_ADDR_UNASSIGNED) { + model->pub->addr == BLE_MESH_ADDR_UNASSIGNED) { return; } prev_ttl = model->pub->ttl; @@ -531,7 +531,7 @@ static void send_scene_register_status(struct bt_mesh_model *model, if (scene->scene_number != INVALID_SCENE_NUMBER) { total_len += SCENE_NUMBER_LEN; if ((publish == false && total_len > MIN(BLE_MESH_TX_SDU_MAX, BLE_MESH_SERVER_RSP_MAX_LEN)) || - (publish == true && total_len > msg->size + BLE_MESH_SERVER_TRANS_MIC_SIZE)) { + (publish == true && total_len > msg->size + BLE_MESH_SERVER_TRANS_MIC_SIZE)) { /* Add this in case the message is too long */ break; } @@ -870,7 +870,7 @@ static void scene_action(struct bt_mesh_model *model, } if (srv->state->target_scene == scene_number && - srv->state->in_progress == true) { + srv->state->in_progress == true) { /** * When the scene transition is in progress and the target Scene Number * is deleted from a Scene Register state as a result of Scene Delete @@ -924,7 +924,7 @@ static void scene_action(struct bt_mesh_model *model, } if (ctx->recv_op == BLE_MESH_MODEL_OP_SCENE_STORE || - ctx->recv_op == BLE_MESH_MODEL_OP_SCENE_DELETE) { + ctx->recv_op == BLE_MESH_MODEL_OP_SCENE_DELETE) { send_scene_register_status(model, ctx, srv->state->status_code, false); } send_scene_register_status(model, NULL, srv->state->status_code, true); diff --git a/components/bt/sdkconfig.rename b/components/bt/sdkconfig.rename index 2affb7cb7..8c67aa5d3 100644 --- a/components/bt/sdkconfig.rename +++ b/components/bt/sdkconfig.rename @@ -223,3 +223,5 @@ CONFIG_BLE_HOST_QUEUE_CONGESTION_CHECK CONFIG_BT_BLE_HOST_Q CONFIG_SMP_ENABLE CONFIG_BT_SMP_ENABLE CONFIG_BLE_ACTIVE_SCAN_REPORT_ADV_SCAN_RSP_INDIVIDUALLY CONFIG_BT_BLE_ACT_SCAN_REP_ADV_SCAN CONFIG_BLE_ESTABLISH_LINK_CONNECTION_TIMEOUT CONFIG_BT_BLE_ESTAB_LINK_CONN_TOUT + +CONFIG_BLE_MESH_GATT_PROXY CONFIG_BLE_MESH_GATT_PROXY_SERVER \ No newline at end of file diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_adapter.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_adapter.c index 5cf017bdc..b8d1775b3 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_adapter.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_adapter.c @@ -72,7 +72,7 @@ esp_ble_mesh_comp_t *ble_mesh_get_component(uint16_t model_id) return comp; } -void ble_mesh_node_init() +void ble_mesh_node_init(void) { uint16_t i; @@ -100,7 +100,7 @@ void ble_mesh_set_node_prestore_params(uint16_t netkey_index, uint16_t unicast_a xSemaphoreGive(ble_mesh_node_sema); } -void ble_mesh_node_statistics_get() +void ble_mesh_node_statistics_get(void) { xSemaphoreTake(ble_mesh_node_sema, portMAX_DELAY); ESP_LOGI(TAG, "statistics:%d,%d\n", ble_mesh_node_statistics.statistics, ble_mesh_node_statistics.package_num); @@ -156,7 +156,7 @@ int ble_mesh_node_statistics_init(uint16_t package_num) return 0; } -void ble_mesh_node_statistics_destroy() +void ble_mesh_node_statistics_destroy(void) { if (ble_mesh_node_statistics.package_index != NULL) { free(ble_mesh_node_statistics.package_index); diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_adapter.h b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_adapter.h index 06c876fd6..d7feee5fe 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_adapter.h +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_adapter.h @@ -85,13 +85,13 @@ extern SemaphoreHandle_t ble_mesh_node_sema; } \ }while(0) \ -void ble_mesh_node_init(); +void ble_mesh_node_init(void); void ble_mesh_set_node_prestore_params(uint16_t netkey_index, uint16_t unicast_addr); esp_ble_mesh_model_t *ble_mesh_get_model(uint16_t model_id); esp_ble_mesh_comp_t *ble_mesh_get_component(uint16_t model_id); -void ble_mesh_node_statistics_get(); +void ble_mesh_node_statistics_get(void); int ble_mesh_node_statistics_accumultate(uint8_t *data, uint32_t value, uint16_t type); int ble_mesh_node_statistics_init(uint16_t package_num); -void ble_mesh_node_statistics_destroy(); +void ble_mesh_node_statistics_destroy(void); #endif //_BLE_MESH_ADAOTER_H_ diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_console_decl.h b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_console_decl.h index 22ab3a7f5..2e983265d 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_console_decl.h +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_console_decl.h @@ -11,18 +11,18 @@ #include "esp_ble_mesh_defs.h" // Register system functions -void register_system(); +void register_system(void); // Register blutooth -void register_bluetooth(); +void register_bluetooth(void); // Register mesh node cmd -void ble_mesh_register_mesh_node(); +void ble_mesh_register_mesh_node(void); // Register mesh config server and generic server operation cmd -void ble_mesh_register_server(); +void ble_mesh_register_server(void); #if (CONFIG_BLE_MESH_CFG_CLI) // Register mesh config client operation cmd -void ble_mesh_register_configuration_client_model(); +void ble_mesh_register_configuration_client_model(void); #endif diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_console_main.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_console_main.c index f1f963552..5dba3a050 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_console_main.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_console_main.c @@ -36,7 +36,7 @@ #define MOUNT_PATH "/data" #define HISTORY_PATH MOUNT_PATH "/history.txt" -static void initialize_filesystem() +static void initialize_filesystem(void) { static wl_handle_t wl_handle; const esp_vfs_fat_mount_config_t mount_config = { @@ -51,7 +51,7 @@ static void initialize_filesystem() } #endif // CONFIG_STORE_HISTORY -static void initialize_console() +static void initialize_console(void) { /* Disable buffering on stdin and stdout */ setvbuf(stdin, NULL, _IONBF, 0); @@ -63,11 +63,11 @@ static void initialize_console() esp_vfs_dev_uart_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF); /* Install UART driver for interrupt-driven reads and writes */ - ESP_ERROR_CHECK( uart_driver_install(CONFIG_CONSOLE_UART_NUM, + ESP_ERROR_CHECK( uart_driver_install(CONFIG_ESP_CONSOLE_UART_NUM, 256, 0, 0, NULL, 0) ); /* Tell VFS to use UART driver */ - esp_vfs_dev_uart_use_driver(CONFIG_CONSOLE_UART_NUM); + esp_vfs_dev_uart_use_driver(CONFIG_ESP_CONSOLE_UART_NUM); /* Initialize the console */ esp_console_config_t console_config = { diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_console_system.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_console_system.c index cc8805dbf..88c0a6a0a 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_console_system.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_console_system.c @@ -28,11 +28,11 @@ #define CONFIG_ESPTOOLPY_PORT "Which is choosen by Users for CMake" #endif -static void register_free(); -static void register_restart(); -static void register_make(); +static void register_free(void); +static void register_restart(void); +static void register_make(void); -void register_system() +void register_system(void) { register_free(); register_restart(); @@ -47,7 +47,7 @@ static int restart(int argc, char **argv) esp_restart(); } -static void register_restart() +static void register_restart(void) { const esp_console_cmd_t cmd = { .command = "restart", @@ -66,7 +66,7 @@ static int free_mem(int argc, char **argv) return 0; } -static void register_free() +static void register_free(void) { const esp_console_cmd_t cmd = { .command = "free", @@ -169,7 +169,7 @@ R"(MONITOR return 0; } -static void register_make() +static void register_make(void) { const esp_console_cmd_t cmd = { .command = "make", diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_register_node_cmd.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_register_node_cmd.c index 919e69f77..375c224c6 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_register_node_cmd.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_register_node_cmd.c @@ -86,18 +86,18 @@ ble_mesh_node_status node_status = { SemaphoreHandle_t ble_mesh_node_sema; -void ble_mesh_register_node_cmd(); +void ble_mesh_register_node_cmd(void); // Register callback function void ble_mesh_prov_cb(esp_ble_mesh_prov_cb_event_t event, esp_ble_mesh_prov_cb_param_t *param); void ble_mesh_model_cb(esp_ble_mesh_model_cb_event_t event, esp_ble_mesh_model_cb_param_t *param); -void ble_mesh_register_mesh_node() +void ble_mesh_register_mesh_node(void) { ble_mesh_register_node_cmd(); } -int ble_mesh_register_node_cb() +int ble_mesh_register_node_cb(int argc, char** argv) { ESP_LOGD(TAG, "enter %s\n", __func__); ble_mesh_node_init(); @@ -364,7 +364,7 @@ int ble_mesh_node_enable_bearer(int argc, char **argv) return err; } -int ble_mesh_node_reset() +int ble_mesh_node_reset(int argc, char** argv) { esp_err_t err; ESP_LOGD(TAG, "enter %s\n", __func__); @@ -437,7 +437,7 @@ int ble_mesh_node_enter_network_auto(int argc, char **argv) return err; } -void ble_mesh_register_node_cmd() +void ble_mesh_register_node_cmd(void) { const esp_console_cmd_t register_cmd = { .command = "bmreg", diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_register_server_cmd.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_register_server_cmd.c index e2ae583bf..6fcb41d4f 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_register_server_cmd.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/ble_mesh_register_server_cmd.c @@ -18,7 +18,7 @@ #include "ble_mesh_console_lib.h" #include "ble_mesh_adapter.h" -void ble_mesh_register_server_operation(); +void ble_mesh_register_server_operation(void); typedef struct { struct arg_str *data; @@ -29,7 +29,7 @@ typedef struct { } ble_mesh_publish_message; ble_mesh_publish_message msg_publish; -void ble_mesh_register_server() +void ble_mesh_register_server(void) { ble_mesh_register_server_operation(); } @@ -63,7 +63,7 @@ int ble_mesh_module_publish_message(int argc, char **argv) return err; } -void ble_mesh_register_server_operation() +void ble_mesh_register_server_operation(void) { msg_publish.data = arg_str1("d", NULL, "", "message data"); msg_publish.opcode = arg_int1("o", NULL, "", "operation opcode"); diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/register_bluetooth.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/register_bluetooth.c index e6b03ed59..64358ba60 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/register_bluetooth.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_node/main/register_bluetooth.c @@ -18,27 +18,27 @@ #define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5] #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x" -void register_ble_address(); +void register_ble_address(void); -void register_bluetooth() +void register_bluetooth(void) { register_ble_address(); } -int bt_mac() +int bt_mac(int argc, char** argv) { const uint8_t *mac = esp_bt_dev_get_address(); printf("+BTMAC:"MACSTR"\n", MAC2STR(mac)); return 0; } -void register_ble_address() +void register_ble_address(void) { const esp_console_cmd_t cmd = { .command = "btmac", .help = "get BT mac address", .hint = NULL, - .func = (esp_console_cmd_func_t)&bt_mac, + .func = &bt_mac, }; ESP_ERROR_CHECK(esp_console_cmd_register(&cmd)); } diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_adapter.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_adapter.c index 754b0115f..eded5787b 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_adapter.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_adapter.c @@ -77,7 +77,7 @@ esp_ble_mesh_comp_t *ble_mesh_get_component(uint16_t model_id) return comp; } -void ble_mesh_node_init() +void ble_mesh_node_init(void) { uint16_t i; @@ -129,7 +129,7 @@ void ble_mesh_create_send_data(char *data, uint16_t byte_num, uint16_t sequence_ } } -void ble_mesh_test_performance_client_model_get() +void ble_mesh_test_performance_client_model_get(void) { uint32_t i, j; uint32_t sum_time = 0; @@ -155,7 +155,7 @@ void ble_mesh_test_performance_client_model_get() xSemaphoreGive(ble_mesh_test_perf_sema); } -void ble_mesh_test_performance_client_model_get_received_percent() +void ble_mesh_test_performance_client_model_get_received_percent(void) { uint32_t i, j; uint32_t max_time = 1400; @@ -283,7 +283,7 @@ int ble_mesh_test_performance_client_model_init(uint16_t node_num, uint32_t test return 0; } -void ble_mesh_test_performance_client_model_destroy() +void ble_mesh_test_performance_client_model_destroy(void) { if (test_perf_statistics.time != NULL) { free(test_perf_statistics.time); diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_adapter.h b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_adapter.h index bdc083a21..305026c1a 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_adapter.h +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_adapter.h @@ -106,18 +106,18 @@ extern SemaphoreHandle_t ble_mesh_test_perf_sema; } \ }while(0) \ -void ble_mesh_node_init(); +void ble_mesh_node_init(void); void ble_mesh_set_node_prestore_params(uint16_t netkey_index, uint16_t unicast_addr); esp_ble_mesh_model_t *ble_mesh_get_model(uint16_t model_id); esp_ble_mesh_comp_t *ble_mesh_get_component(uint16_t model_id); void ble_mesh_create_send_data(char *data, uint16_t byte_num, uint16_t sequence_num, uint32_t opcode); -void ble_mesh_test_performance_client_model_get(); -void ble_mesh_test_performance_client_model_get_received_percent(); +void ble_mesh_test_performance_client_model_get(void); +void ble_mesh_test_performance_client_model_get_received_percent(void); void ble_mesh_test_performance_client_model_accumulate_statistics(uint32_t value); int ble_mesh_test_performance_client_model_accumulate_time(uint16_t time, uint8_t *data, uint8_t ack_ttl, uint16_t length); int ble_mesh_test_performance_client_model_init(uint16_t node_num, uint32_t test_num, uint8_t ttl); -void ble_mesh_test_performance_client_model_destroy(); +void ble_mesh_test_performance_client_model_destroy(void); #endif //_BLE_MESH_ADAPTER_H_ \ No newline at end of file diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_console_decl.h b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_console_decl.h index 90e52a61d..3ba4f496d 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_console_decl.h +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_console_decl.h @@ -11,28 +11,28 @@ #include "esp_ble_mesh_defs.h" // Register system functions -void register_system(); +void register_system(void); // Register bluetooth -void register_bluetooth(); +void register_bluetooth(void); // Register mesh node cmd -void ble_mesh_register_mesh_node(); +void ble_mesh_register_mesh_node(void); // Register Test Perf client cmd -void ble_mesh_register_mesh_test_performance_client(); +void ble_mesh_register_mesh_test_performance_client(void); #if (CONFIG_BLE_MESH_CFG_CLI) // Register mesh config client operation cmd -void ble_mesh_register_configuration_client_model(); +void ble_mesh_register_configuration_client_model(void); #endif #if (CONFIG_BLE_MESH_GENERIC_ONOFF_CLI) // Register mesh client operation cmd -void ble_mesh_register_gen_onoff_client(); +void ble_mesh_register_gen_onoff_client(void); #endif #if CONFIG_BLE_MESH_PROVISIONER // Regitster mesh provisioner cmd -void ble_mesh_register_mesh_provisioner(); +void ble_mesh_register_mesh_provisioner(void); #endif diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_console_main.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_console_main.c index d9d4a9e4e..a60f70ee2 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_console_main.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_console_main.c @@ -39,7 +39,7 @@ #define MOUNT_PATH "/data" #define HISTORY_PATH MOUNT_PATH "/history.txt" -static void initialize_filesystem() +static void initialize_filesystem(void) { static wl_handle_t wl_handle; const esp_vfs_fat_mount_config_t mount_config = { @@ -54,7 +54,7 @@ static void initialize_filesystem() } #endif // CONFIG_STORE_HISTORY -static void initialize_console() +static void initialize_console(void) { /* Disable buffering on stdin and stdout */ setvbuf(stdin, NULL, _IONBF, 0); @@ -66,11 +66,11 @@ static void initialize_console() esp_vfs_dev_uart_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF); /* Install UART driver for interrupt-driven reads and writes */ - ESP_ERROR_CHECK( uart_driver_install(CONFIG_CONSOLE_UART_NUM, + ESP_ERROR_CHECK( uart_driver_install(CONFIG_ESP_CONSOLE_UART_NUM, 256, 0, 0, NULL, 0) ); /* Tell VFS to use UART driver */ - esp_vfs_dev_uart_use_driver(CONFIG_CONSOLE_UART_NUM); + esp_vfs_dev_uart_use_driver(CONFIG_ESP_CONSOLE_UART_NUM); /* Initialize the console */ esp_console_config_t console_config = { diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_console_system.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_console_system.c index d3dc6c12f..de76b11ae 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_console_system.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_console_system.c @@ -24,11 +24,11 @@ #define CONFIG_ESPTOOLPY_PORT "Which is choosen by Users for CMake" #endif -static void register_free(); -static void register_restart(); -static void register_make(); +static void register_free(void); +static void register_restart(void); +static void register_make(void); -void register_system() +void register_system(void) { register_free(); register_restart(); @@ -43,7 +43,7 @@ static int restart(int argc, char **argv) esp_restart(); } -static void register_restart() +static void register_restart(void) { const esp_console_cmd_t cmd = { .command = "restart", @@ -62,7 +62,7 @@ static int free_mem(int argc, char **argv) return 0; } -static void register_free() +static void register_free(void) { const esp_console_cmd_t cmd = { .command = "free", @@ -165,7 +165,7 @@ R"(MONITOR return 0; } -static void register_make() +static void register_make(void) { const esp_console_cmd_t cmd = { .command = "make", diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_reg_cfg_client_cmd.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_reg_cfg_client_cmd.c index 53a10d38d..59bae35ce 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_reg_cfg_client_cmd.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_reg_cfg_client_cmd.c @@ -33,11 +33,11 @@ typedef struct { } ble_mesh_client_get_set_state_t; ble_mesh_client_get_set_state_t configuration_client_model_operation; -void ble_mesh_register_configuration_client_model_command(); +void ble_mesh_register_configuration_client_model_command(void); void ble_mesh_configuration_client_model_cb(esp_ble_mesh_cfg_client_cb_event_t event, esp_ble_mesh_cfg_client_cb_param_t *param); -void ble_mesh_register_configuration_client_model() +void ble_mesh_register_configuration_client_model(void) { ble_mesh_register_configuration_client_model_command(); } @@ -362,7 +362,7 @@ int ble_mesh_configuration_client_model_operation(int argc, char **argv) } -void ble_mesh_register_configuration_client_model_command() +void ble_mesh_register_configuration_client_model_command(void) { configuration_client_model_operation.action_type = arg_str1("z", NULL, "", "action type"); configuration_client_model_operation.set_state = arg_str0("x", NULL, "", "set state"); diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_reg_gen_onoff_client_cmd.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_reg_gen_onoff_client_cmd.c index 6f34a1b27..f9caa8931 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_reg_gen_onoff_client_cmd.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_reg_gen_onoff_client_cmd.c @@ -32,11 +32,11 @@ typedef struct { } ble_mesh_gen_onoff_state_t; ble_mesh_gen_onoff_state_t gen_onoff_state; -void ble_mesh_register_gen_onoff_client_command(); +void ble_mesh_register_gen_onoff_client_command(void); void ble_mesh_generic_onoff_client_model_cb(esp_ble_mesh_generic_client_cb_event_t event, esp_ble_mesh_generic_client_cb_param_t *param); -void ble_mesh_register_gen_onoff_client() +void ble_mesh_register_gen_onoff_client(void) { ble_mesh_register_gen_onoff_client_command(); } @@ -152,7 +152,7 @@ int ble_mesh_generic_onoff_client_model(int argc, char **argv) return err; } -void ble_mesh_register_gen_onoff_client_command() +void ble_mesh_register_gen_onoff_client_command(void) { gen_onoff_state.action_type = arg_str1("z", NULL, "", "action type"); gen_onoff_state.opcode = arg_int0("o", NULL, "", "message opcode"); diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_reg_test_perf_client_cmd.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_reg_test_perf_client_cmd.c index e46efc8ec..b6b4c898f 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_reg_test_perf_client_cmd.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_reg_test_perf_client_cmd.c @@ -47,9 +47,9 @@ typedef struct { } ble_mesh_test_perf_client_model_statistics_t; ble_mesh_test_perf_client_model_statistics_t test_perf_client_model_statistics; -void ble_mesh_performance_client_model_command(); +void ble_mesh_performance_client_model_command(void); -void ble_mesh_register_mesh_test_performance_client() +void ble_mesh_register_mesh_test_performance_client(void) { ble_mesh_performance_client_model_command(); } @@ -177,7 +177,7 @@ int ble_mesh_test_performance_client_model_performance(int argc, char **argv) return 0; } -void ble_mesh_performance_client_model_command() +void ble_mesh_performance_client_model_command(void) { test_perf_client_model.action_type = arg_str1("z", NULL, "", "action type"); test_perf_client_model.playload_byte = arg_int0("p", NULL, "", "playload byte"); diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_register_node_cmd.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_register_node_cmd.c index 0e0775aca..b9bd565c4 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_register_node_cmd.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_register_node_cmd.c @@ -65,18 +65,18 @@ ble_mesh_node_status node_status = { SemaphoreHandle_t ble_mesh_node_sema; -void ble_mesh_register_node_cmd(); +void ble_mesh_register_node_cmd(void); // Register callback function void ble_mesh_prov_cb(esp_ble_mesh_prov_cb_event_t event, esp_ble_mesh_prov_cb_param_t *param); void ble_mesh_model_cb(esp_ble_mesh_model_cb_event_t event, esp_ble_mesh_model_cb_param_t *param); -void ble_mesh_register_mesh_node() +void ble_mesh_register_mesh_node(void) { ble_mesh_register_node_cmd(); } -int ble_mesh_register_node_cb() +int ble_mesh_register_node_cb(int argc, char** argv) { ESP_LOGD(TAG, "enter %s\n", __func__); ble_mesh_node_init(); @@ -405,7 +405,7 @@ int ble_mesh_provisioner_enable_bearer(int argc, char **argv) return err; } -void ble_mesh_register_node_cmd() +void ble_mesh_register_node_cmd(void) { const esp_console_cmd_t register_cmd = { .command = "bmreg", diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_register_provisioner_cmd.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_register_provisioner_cmd.c index fea5d8274..d36aed92f 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_register_provisioner_cmd.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/ble_mesh_register_provisioner_cmd.c @@ -80,12 +80,12 @@ typedef struct { } ble_mesh_provisioner_add_key_t; ble_mesh_provisioner_add_key_t provisioner_add_key; -void ble_mesh_regist_provisioner_cmd(); +void ble_mesh_regist_provisioner_cmd(void); void ble_mesh_prov_adv_cb(const esp_ble_mesh_bd_addr_t addr, const esp_ble_mesh_addr_type_t addr_type, const uint8_t adv_type, const uint8_t *dev_uuid, uint16_t oob_info, esp_ble_mesh_prov_bearer_t bearer); -void ble_mesh_register_mesh_provisioner() +void ble_mesh_register_mesh_provisioner(void) { ble_mesh_regist_provisioner_cmd(); } @@ -101,7 +101,7 @@ void ble_mesh_prov_adv_cb(const esp_ble_mesh_bd_addr_t addr, const esp_ble_mesh_ ESP_LOGD(TAG, "exit %s\n", __func__); } -int ble_mesh_provisioner_register() +int ble_mesh_provisioner_register(int argc, char** argv) { ESP_LOGD(TAG, "enter %s \n", __func__); // esp_ble_mesh_register_unprov_adv_pkt_callback(ble_mesh_prov_adv_cb); @@ -322,7 +322,7 @@ int ble_mesh_provision_bind_local_model(int argc, char **argv) return err; } -void ble_mesh_regist_provisioner_cmd() +void ble_mesh_regist_provisioner_cmd(void) { const esp_console_cmd_t prov_register = { .command = "bmpreg", diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/register_bluetooth.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/register_bluetooth.c index 6b856c30f..129617e7e 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/register_bluetooth.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/ble_mesh_provisioner/main/register_bluetooth.c @@ -18,9 +18,9 @@ #define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5] #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x" -void register_ble_address(); +void register_ble_address(void); -void register_bluetooth() +void register_bluetooth(void) { register_ble_address(); } @@ -32,7 +32,7 @@ int bt_mac(int argc, char** argv) return 0; } -void register_ble_address() +void register_ble_address(void) { const esp_console_cmd_t cmd = { .command = "btmac", diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/components/iperf/cmd_wifi.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/components/iperf/cmd_wifi.c index 8d258dc92..8fd95ce47 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/components/iperf/cmd_wifi.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/components/iperf/cmd_wifi.c @@ -17,7 +17,6 @@ #include "freertos/event_groups.h" #include "esp_wifi.h" #include "tcpip_adapter.h" -#include "esp_event_loop.h" #include "iperf.h" typedef struct { @@ -74,22 +73,18 @@ static void scan_done_handler(void) free(ap_list_buffer); } -static esp_err_t event_handler(void *ctx, system_event_t *event) +static void wifi_event_handler(void* arg, esp_event_base_t event_base, + int32_t event_id, void* event_data) { - switch (event->event_id) { - case SYSTEM_EVENT_STA_GOT_IP: - xEventGroupClearBits(wifi_event_group, DISCONNECTED_BIT); - xEventGroupSetBits(wifi_event_group, CONNECTED_BIT); - ESP_LOGI(TAG, "got ip"); - break; - case SYSTEM_EVENT_SCAN_DONE: + switch (event_id) { + case WIFI_EVENT_SCAN_DONE: scan_done_handler(); ESP_LOGI(TAG, "sta scan done"); break; - case SYSTEM_EVENT_STA_CONNECTED: + case WIFI_EVENT_STA_CONNECTED: ESP_LOGI(TAG, "L2 connected"); break; - case SYSTEM_EVENT_STA_DISCONNECTED: + case WIFI_EVENT_STA_DISCONNECTED: if (reconnect) { ESP_LOGI(TAG, "sta disconnect, reconnect..."); esp_wifi_connect(); @@ -102,7 +97,22 @@ static esp_err_t event_handler(void *ctx, system_event_t *event) default: break; } - return ESP_OK; + return; +} + +static void ip_event_handler(void* arg, esp_event_base_t event_base, + int32_t event_id, void* event_data) +{ + switch (event_id) { + case IP_EVENT_STA_GOT_IP: + xEventGroupClearBits(wifi_event_group, DISCONNECTED_BIT); + xEventGroupSetBits(wifi_event_group, CONNECTED_BIT); + ESP_LOGI(TAG, "got ip"); + break; + default: + break; + } + return; } void initialise_wifi(void) @@ -116,7 +126,10 @@ void initialise_wifi(void) tcpip_adapter_init(); wifi_event_group = xEventGroupCreate(); - ESP_ERROR_CHECK( esp_event_loop_init(event_handler, NULL) ); + ESP_ERROR_CHECK(esp_event_loop_create_default()); + ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &wifi_event_handler, NULL)); + ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &ip_event_handler, NULL)); + wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); ESP_ERROR_CHECK( esp_wifi_init(&cfg) ); ESP_ERROR_CHECK( esp_wifi_set_ps(WIFI_PS_MIN_MODEM) ); //must call this @@ -389,7 +402,7 @@ static int heap_size(int argc, char **argv) return 0; } -void register_wifi() +void register_wifi(void) { sta_args.ssid = arg_str1(NULL, NULL, "", "SSID of AP"); sta_args.password = arg_str0(NULL, NULL, "", "password of AP"); diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/main/ble_mesh_demo_main.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/main/ble_mesh_demo_main.c index 624c67a4e..261c75852 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/main/ble_mesh_demo_main.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/main/ble_mesh_demo_main.c @@ -742,7 +742,7 @@ static esp_err_t ble_mesh_init(void) #define WIFI_CONNECTED_BIT BIT0 -static void initialize_console() +static void initialize_console(void) { /* Disable buffering on stdin and stdout */ setvbuf(stdin, NULL, _IONBF, 0); @@ -754,11 +754,11 @@ static void initialize_console() esp_vfs_dev_uart_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF); /* Install UART driver for interrupt-driven reads and writes */ - ESP_ERROR_CHECK( uart_driver_install(CONFIG_CONSOLE_UART_NUM, + ESP_ERROR_CHECK( uart_driver_install(CONFIG_ESP_CONSOLE_UART_NUM, 256, 0, 0, NULL, 0) ); /* Tell VFS to use UART driver */ - esp_vfs_dev_uart_use_driver(CONFIG_CONSOLE_UART_NUM); + esp_vfs_dev_uart_use_driver(CONFIG_ESP_CONSOLE_UART_NUM); /* Initialize the console */ esp_console_config_t console_config = {