Răsfoiți Sursa

ble_mesh: miscellaneous modifications

1. Clean up client_common.c
2. Clean up esp_ble_mesh directory
3. Update Kconfig.in
4. Format esp_ble_mesh files
lly 6 ani în urmă
părinte
comite
2bba9d7700
78 a modificat fișierele cu 674 adăugiri și 684 ștergeri
  1. 10 9
      components/bt/CMakeLists.txt
  2. 6 5
      components/bt/component.mk
  3. 9 17
      components/bt/esp_ble_mesh/Kconfig.in
  4. 13 7
      components/bt/esp_ble_mesh/api/core/esp_ble_mesh_networking_api.c
  5. 2 2
      components/bt/esp_ble_mesh/api/core/esp_ble_mesh_provisioning_api.c
  6. 5 5
      components/bt/esp_ble_mesh/api/core/esp_ble_mesh_proxy_api.c
  7. 8 1
      components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_low_power_api.h
  8. 1 1
      components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_networking_api.h
  9. 2 2
      components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_provisioning_api.h
  10. 4 4
      components/bt/esp_ble_mesh/api/core/include/esp_ble_mesh_proxy_api.h
  11. 8 2
      components/bt/esp_ble_mesh/api/esp_ble_mesh_defs.h
  12. 2 2
      components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_config_model_api.h
  13. 1 1
      components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_generic_model_api.h
  14. 1 1
      components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_lighting_model_api.h
  15. 1 1
      components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_sensor_model_api.h
  16. 2 2
      components/bt/esp_ble_mesh/api/models/include/esp_ble_mesh_time_scene_model_api.h
  17. 36 36
      components/bt/esp_ble_mesh/btc/btc_ble_mesh_config_model.c
  18. 7 7
      components/bt/esp_ble_mesh/btc/btc_ble_mesh_generic_model.c
  19. 5 5
      components/bt/esp_ble_mesh/btc/btc_ble_mesh_health_model.c
  20. 10 10
      components/bt/esp_ble_mesh/btc/btc_ble_mesh_lighting_model.c
  21. 41 39
      components/bt/esp_ble_mesh/btc/btc_ble_mesh_prov.c
  22. 14 14
      components/bt/esp_ble_mesh/btc/btc_ble_mesh_sensor_model.c
  23. 6 6
      components/bt/esp_ble_mesh/btc/btc_ble_mesh_time_scene_model.c
  24. 0 0
      components/bt/esp_ble_mesh/mesh_common/include/mesh_aes_encrypt.h
  25. 0 0
      components/bt/esp_ble_mesh/mesh_common/include/mesh_atomic.h
  26. 3 3
      components/bt/esp_ble_mesh/mesh_common/include/mesh_buf.h
  27. 1 1
      components/bt/esp_ble_mesh/mesh_common/include/mesh_common.h
  28. 0 0
      components/bt/esp_ble_mesh/mesh_common/include/mesh_dlist.h
  29. 0 0
      components/bt/esp_ble_mesh/mesh_common/include/mesh_kernel.h
  30. 0 0
      components/bt/esp_ble_mesh/mesh_common/include/mesh_slist.h
  31. 0 0
      components/bt/esp_ble_mesh/mesh_common/include/mesh_trace.h
  32. 0 0
      components/bt/esp_ble_mesh/mesh_common/include/mesh_types.h
  33. 0 0
      components/bt/esp_ble_mesh/mesh_common/include/mesh_util.h
  34. 0 0
      components/bt/esp_ble_mesh/mesh_common/mesh_aes_encrypt.c
  35. 0 0
      components/bt/esp_ble_mesh/mesh_common/mesh_atomic.c
  36. 7 7
      components/bt/esp_ble_mesh/mesh_common/mesh_buf.c
  37. 0 0
      components/bt/esp_ble_mesh/mesh_common/mesh_common.c
  38. 2 11
      components/bt/esp_ble_mesh/mesh_common/mesh_kernel.c
  39. 0 0
      components/bt/esp_ble_mesh/mesh_common/mesh_util.c
  40. 1 1
      components/bt/esp_ble_mesh/mesh_core/access.c
  41. 11 11
      components/bt/esp_ble_mesh/mesh_core/adv.c
  42. 1 1
      components/bt/esp_ble_mesh/mesh_core/adv.h
  43. 19 19
      components/bt/esp_ble_mesh/mesh_core/bluedroid_host/mesh_bearer_adapt.c
  44. 1 1
      components/bt/esp_ble_mesh/mesh_core/cfg_cli.c
  45. 13 13
      components/bt/esp_ble_mesh/mesh_core/cfg_srv.c
  46. 5 5
      components/bt/esp_ble_mesh/mesh_core/friend.c
  47. 1 1
      components/bt/esp_ble_mesh/mesh_core/health_cli.c
  48. 9 9
      components/bt/esp_ble_mesh/mesh_core/include/mesh_bearer_adapt.h
  49. 4 2
      components/bt/esp_ble_mesh/mesh_core/lpn.c
  50. 2 2
      components/bt/esp_ble_mesh/mesh_core/main.c
  51. 15 15
      components/bt/esp_ble_mesh/mesh_core/net.c
  52. 1 1
      components/bt/esp_ble_mesh/mesh_core/net.h
  53. 86 82
      components/bt/esp_ble_mesh/mesh_core/nimble_host/mesh_bearer_adapt.c
  54. 6 6
      components/bt/esp_ble_mesh/mesh_core/prov.c
  55. 1 1
      components/bt/esp_ble_mesh/mesh_core/prov.h
  56. 1 1
      components/bt/esp_ble_mesh/mesh_core/provisioner_main.c
  57. 29 29
      components/bt/esp_ble_mesh/mesh_core/provisioner_prov.c
  58. 4 4
      components/bt/esp_ble_mesh/mesh_core/proxy_client.c
  59. 4 4
      components/bt/esp_ble_mesh/mesh_core/proxy_server.c
  60. 4 4
      components/bt/esp_ble_mesh/mesh_core/settings.c
  61. 1 1
      components/bt/esp_ble_mesh/mesh_core/storage/settings_nvs.c
  62. 0 0
      components/bt/esp_ble_mesh/mesh_core/storage/settings_nvs.h
  63. 86 86
      components/bt/esp_ble_mesh/mesh_core/transport.c
  64. 29 51
      components/bt/esp_ble_mesh/mesh_models/client/client_common.c
  65. 1 1
      components/bt/esp_ble_mesh/mesh_models/client/generic_client.c
  66. 3 9
      components/bt/esp_ble_mesh/mesh_models/client/include/client_common.h
  67. 1 1
      components/bt/esp_ble_mesh/mesh_models/client/lighting_client.c
  68. 1 1
      components/bt/esp_ble_mesh/mesh_models/client/sensor_client.c
  69. 1 1
      components/bt/esp_ble_mesh/mesh_models/client/time_scene_client.c
  70. 23 19
      components/bt/esp_ble_mesh/mesh_models/server/generic_server.c
  71. 1 1
      components/bt/esp_ble_mesh/mesh_models/server/include/time_scene_server.h
  72. 31 31
      components/bt/esp_ble_mesh/mesh_models/server/lighting_server.c
  73. 45 45
      components/bt/esp_ble_mesh/mesh_models/server/sensor_server.c
  74. 6 6
      components/bt/esp_ble_mesh/mesh_models/server/server_common.c
  75. 1 1
      components/bt/esp_ble_mesh/mesh_models/server/state_binding.c
  76. 10 10
      components/bt/esp_ble_mesh/mesh_models/server/state_transition.c
  77. 7 7
      components/bt/esp_ble_mesh/mesh_models/server/time_scene_server.c
  78. 2 0
      components/bt/sdkconfig.rename

+ 10 - 9
components/bt/CMakeLists.txt

@@ -311,9 +311,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"
@@ -341,7 +342,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"
@@ -352,12 +359,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"
@@ -368,7 +370,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"

+ 6 - 5
components/bt/component.mk

@@ -140,9 +140,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    \
@@ -151,10 +152,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                  \

+ 9 - 17
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

+ 13 - 7
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)

+ 2 - 2
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};

+ 5 - 5
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};

+ 8 - 1
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.
  *

+ 1 - 1
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.
  *

+ 2 - 2
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.

+ 4 - 4
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_ */
 

+ 8 - 2
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;
 

+ 2 - 2
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 */

+ 1 - 1
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.

+ 1 - 1
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.

+ 1 - 1
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.

+ 2 - 2
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.

+ 36 - 36
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));

+ 7 - 7
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,

+ 5 - 5
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)

+ 10 - 10
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;

+ 41 - 39
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(&param, 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);

+ 14 - 14
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;

+ 6 - 6
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);

+ 0 - 0
components/bt/esp_ble_mesh/mesh_core/include/mesh_aes_encrypt.h → components/bt/esp_ble_mesh/mesh_common/include/mesh_aes_encrypt.h


+ 0 - 0
components/bt/esp_ble_mesh/mesh_core/include/mesh_atomic.h → components/bt/esp_ble_mesh/mesh_common/include/mesh_atomic.h


+ 3 - 3
components/bt/esp_ble_mesh/mesh_core/include/mesh_buf.h → 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

+ 1 - 1
components/bt/esp_ble_mesh/mesh_models/common/include/mesh_common.h → 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.

+ 0 - 0
components/bt/esp_ble_mesh/mesh_core/include/mesh_dlist.h → components/bt/esp_ble_mesh/mesh_common/include/mesh_dlist.h


+ 0 - 0
components/bt/esp_ble_mesh/mesh_core/include/mesh_kernel.h → components/bt/esp_ble_mesh/mesh_common/include/mesh_kernel.h


+ 0 - 0
components/bt/esp_ble_mesh/mesh_core/include/mesh_slist.h → components/bt/esp_ble_mesh/mesh_common/include/mesh_slist.h


+ 0 - 0
components/bt/esp_ble_mesh/mesh_core/include/mesh_trace.h → components/bt/esp_ble_mesh/mesh_common/include/mesh_trace.h


+ 0 - 0
components/bt/esp_ble_mesh/mesh_core/include/mesh_types.h → components/bt/esp_ble_mesh/mesh_common/include/mesh_types.h


+ 0 - 0
components/bt/esp_ble_mesh/mesh_core/include/mesh_util.h → components/bt/esp_ble_mesh/mesh_common/include/mesh_util.h


+ 0 - 0
components/bt/esp_ble_mesh/mesh_core/mesh_aes_encrypt.c → components/bt/esp_ble_mesh/mesh_common/mesh_aes_encrypt.c


+ 0 - 0
components/bt/esp_ble_mesh/mesh_core/mesh_atomic.c → components/bt/esp_ble_mesh/mesh_common/mesh_atomic.c


+ 7 - 7
components/bt/esp_ble_mesh/mesh_core/mesh_buf.c → 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;
 

+ 0 - 0
components/bt/esp_ble_mesh/mesh_models/common/mesh_common.c → components/bt/esp_ble_mesh/mesh_common/mesh_common.c


+ 2 - 11
components/bt/esp_ble_mesh/mesh_core/mesh_kernel.c → 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)

+ 0 - 0
components/bt/esp_ble_mesh/mesh_core/mesh_util.c → components/bt/esp_ble_mesh/mesh_common/mesh_util.c


+ 1 - 1
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;
             }
 

+ 11 - 11
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);
 }
 

+ 1 - 1
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);

+ 19 - 19
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;
     }

+ 1 - 1
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);
         }

+ 13 - 13
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;

+ 5 - 5
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;
         }
 

+ 1 - 1
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);
         }

+ 9 - 9
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,

+ 4 - 2
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();

+ 2 - 2
components/bt/esp_ble_mesh/mesh_core/mesh_main.c → 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
 

+ 15 - 15
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)) {

+ 1 - 1
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;

+ 86 - 82
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)
 {

+ 6 - 6
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;
     }

+ 1 - 1
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);
 

+ 1 - 1
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

+ 29 - 29
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;
     }
 

+ 4 - 4
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;

+ 4 - 4
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 */

+ 4 - 4
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;

+ 1 - 1
components/bt/esp_ble_mesh/mesh_core/settings/settings_nvs.c → 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;
     }
 

+ 0 - 0
components/bt/esp_ble_mesh/mesh_core/settings/settings_nvs.h → components/bt/esp_ble_mesh/mesh_core/storage/settings_nvs.h


+ 86 - 86
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,32 +140,32 @@ 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");
-                net_buf_unref(buf);
-                return -ENOBUFS;
-            } else {
-                BT_WARN("No space in Friend Queue");
-                goto send;
+        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);
-            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:
     return bt_mesh_net_send(tx, buf, cb, cb_data);
@@ -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);
 }

+ 29 - 51
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,36 +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);
-        }
-        return NULL;
-    }
-
-    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;
+            cli->publish_status(ctx->recv_op, model, ctx, buf);
         }
         return NULL;
     }
@@ -110,7 +106,7 @@ bool bt_mesh_client_find_opcode_in_list(sys_slist_t *list, u32_t opcode)
     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)
 {

+ 1 - 1
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);
         }

+ 3 - 9
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,

+ 1 - 1
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);
         }

+ 1 - 1
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);
         }

+ 1 - 1
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);
         }

+ 23 - 19
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;
 }
 

+ 1 - 1
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.
  *

+ 31 - 31
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;
     }
 

+ 45 - 45
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;
         }

+ 6 - 6
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;
     }
 

+ 1 - 1
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;
     }

+ 10 - 10
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;
     }

+ 7 - 7
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);

+ 2 - 0
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