ble_mesh: reorganize ble mesh model files

This commit is contained in:
lly 2019-09-02 11:41:39 +08:00
parent 2c025824d7
commit 317f4c5ff5
19 changed files with 62 additions and 52 deletions

View File

@ -297,7 +297,8 @@ if(CONFIG_BT_ENABLED)
"esp_ble_mesh/mesh_core/include"
"esp_ble_mesh/mesh_core/settings"
"esp_ble_mesh/btc/include"
"esp_ble_mesh/mesh_models/include"
"esp_ble_mesh/mesh_models/common/include"
"esp_ble_mesh/mesh_models/client/include"
"esp_ble_mesh/api/core/include"
"esp_ble_mesh/api/models/include"
"esp_ble_mesh/api")
@ -350,12 +351,12 @@ 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/generic_client.c"
"esp_ble_mesh/mesh_models/lighting_client.c"
"esp_ble_mesh/mesh_models/mesh_common.c"
"esp_ble_mesh/mesh_models/model_common.c"
"esp_ble_mesh/mesh_models/sensor_client.c"
"esp_ble_mesh/mesh_models/time_scene_client.c")
"esp_ble_mesh/mesh_models/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"
"esp_ble_mesh/mesh_models/client/sensor_client.c"
"esp_ble_mesh/mesh_models/client/time_scene_client.c")
endif()
if(CONFIG_BT_NIMBLE_ENABLED)

View File

@ -132,19 +132,21 @@ COMPONENT_SRCDIRS += common/osi \
endif
ifdef CONFIG_BLE_MESH
COMPONENT_ADD_INCLUDEDIRS += esp_ble_mesh/mesh_core \
esp_ble_mesh/mesh_core/include \
esp_ble_mesh/mesh_core/settings \
esp_ble_mesh/btc/include \
esp_ble_mesh/mesh_models/include \
esp_ble_mesh/api/core/include \
esp_ble_mesh/api/models/include \
COMPONENT_ADD_INCLUDEDIRS += esp_ble_mesh/mesh_core \
esp_ble_mesh/mesh_core/include \
esp_ble_mesh/mesh_core/settings \
esp_ble_mesh/btc/include \
esp_ble_mesh/mesh_models/common/include \
esp_ble_mesh/mesh_models/client/include \
esp_ble_mesh/api/core/include \
esp_ble_mesh/api/models/include \
esp_ble_mesh/api
COMPONENT_SRCDIRS += esp_ble_mesh/mesh_core \
esp_ble_mesh/mesh_core/settings \
esp_ble_mesh/btc \
esp_ble_mesh/mesh_models \
esp_ble_mesh/mesh_models/common \
esp_ble_mesh/mesh_models/client \
esp_ble_mesh/api/core \
esp_ble_mesh/api/models
endif

View File

@ -44,7 +44,7 @@
#include "lighting_client.h"
#include "sensor_client.h"
#include "time_scene_client.h"
#include "model_common.h"
#include "client_common.h"
#include "btc_ble_mesh_prov.h"
#include "btc_ble_mesh_config_model.h"

View File

@ -13,7 +13,7 @@
#include "mesh_access.h"
#include "mesh_kernel.h"
#include "model_common.h"
#include "client_common.h"
/**
* @brief Bluetooth Mesh

View File

@ -13,7 +13,7 @@
#include "mesh_access.h"
#include "mesh_kernel.h"
#include "model_common.h"
#include "client_common.h"
/**
* @brief Bluetooth Mesh

View File

@ -31,7 +31,7 @@
#include "settings.h"
#include "transport.h"
#include "mesh_common.h"
#include "model_common.h"
#include "client_common.h"
#include "provisioner_main.h"
/* The transport layer needs at least three buffers for itself to avoid

View File

@ -23,7 +23,7 @@
#include "mesh_main.h"
#include "mesh.h"
#include "model_common.h"
#include "client_common.h"
bt_mesh_client_node_t *bt_mesh_is_model_message_publish(struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
@ -316,21 +316,3 @@ int bt_mesh_set_model_role(bt_mesh_role_param_t *common)
return 0;
}
u8_t bt_mesh_get_model_role(struct bt_mesh_model *model, bool srv_send)
{
bt_mesh_client_common_t *client = NULL;
if (srv_send) {
BT_DBG("%s, Message is sent by a server model", __func__);
return NODE;
}
if (!model || !model->user_data) {
BT_ERR("%s, Invalid parameter", __func__);
return ROLE_NVAL;
}
client = (bt_mesh_client_common_t *)model->user_data;
return client->msg_role;
}

View File

@ -119,15 +119,5 @@ typedef struct bt_mesh_role_param {
*/
int bt_mesh_set_model_role(bt_mesh_role_param_t *common);
/**
* @brief This function gets msg role for stack internal use.
*
* @param[in] model: Pointer to the model structure
* @param[in] srv_send: Indicate if the message is sent by a server model
*
* @return 0 - Node, 1 - Provisioner
*/
u8_t bt_mesh_get_model_role(struct bt_mesh_model *model, bool srv_send);
#endif /* _MODEL_COMMON_H_ */

View File

@ -22,7 +22,7 @@
#include "mesh_access.h"
#include "mesh_kernel.h"
#include "model_common.h"
#include "client_common.h"
/* Generic client model common structure */
typedef bt_mesh_client_common_t bt_mesh_generic_client_t;

View File

@ -22,7 +22,7 @@
#include "mesh_access.h"
#include "mesh_kernel.h"
#include "model_common.h"
#include "client_common.h"
/* Light client model common structure */
typedef bt_mesh_client_common_t bt_mesh_light_client_t;

View File

@ -22,7 +22,7 @@
#include "mesh_access.h"
#include "mesh_kernel.h"
#include "model_common.h"
#include "client_common.h"
/* Sensor Client Model Context */
extern const struct bt_mesh_model_op sensor_cli_op[];

View File

@ -22,7 +22,7 @@
#include "mesh_access.h"
#include "mesh_kernel.h"
#include "model_common.h"
#include "client_common.h"
/* Time scene client model common structure */
typedef bt_mesh_client_common_t bt_mesh_time_scene_client_t;

View File

@ -24,6 +24,7 @@
#include "mesh_types.h"
#include "mesh_buf.h"
#include "mesh_trace.h"
#include "mesh_access.h"
/**
* @brief This function allocates memory to store outgoing message.
@ -43,4 +44,18 @@ struct net_buf_simple *bt_mesh_alloc_buf(u16_t size);
*/
void bt_mesh_free_buf(struct net_buf_simple *buf);
/**
* @brief This function gets device role for stack internal use.
*
* @Note Currently Provisioner only support client models, Node supports
* client models and server models. Hence if srv_send is set to be
* TRUE, then role NODE will be returned.
*
* @param[in] model: Pointer to the model structure
* @param[in] srv_send: Indicate if the message is sent by a server model
*
* @return 0 - Node, 1 - Provisioner
*/
u8_t bt_mesh_get_model_role(struct bt_mesh_model *model, bool srv_send);
#endif /* _MESH_COMMON_H_ */

View File

@ -15,6 +15,7 @@
#include <string.h>
#include <errno.h>
#include "client_common.h"
#include "mesh_common.h"
struct net_buf_simple *bt_mesh_alloc_buf(u16_t size)
@ -44,3 +45,22 @@ void bt_mesh_free_buf(struct net_buf_simple *buf)
osi_free(buf);
}
}
u8_t bt_mesh_get_model_role(struct bt_mesh_model *model, bool srv_send)
{
bt_mesh_client_common_t *client = NULL;
if (srv_send) {
BT_DBG("%s, Message is sent by a server model", __func__);
return NODE;
}
if (!model || !model->user_data) {
BT_ERR("%s, Invalid parameter", __func__);
return ROLE_NVAL;
}
client = (bt_mesh_client_common_t *)model->user_data;
return client->msg_role;
}