component/ble_mesh: Clean up all the files of ESP BLE Mesh SDK

This commit is contained in:
lly
2019-04-10 17:51:38 +08:00
parent 5ae2a73971
commit ec35a2db9a
217 changed files with 8989 additions and 13204 deletions

View File

@@ -272,6 +272,80 @@ if(CONFIG_BT_ENABLED)
endif()
endif()
if (CONFIG_BLE_MESH)
list(APPEND COMPONENT_ADD_INCLUDEDIRS
"bluedroid/osi/include"
"ble_mesh/mesh_core"
"ble_mesh/mesh_core/include"
"ble_mesh/mesh_core/settings/include"
"ble_mesh/btc/include"
"ble_mesh/mesh_models/include"
"ble_mesh/api/core/include"
"ble_mesh/api/models/include"
"ble_mesh/api")
list(APPEND COMPONENT_SRCS
"ble_mesh/api/core/esp_ble_mesh_common_api.c"
"ble_mesh/api/core/esp_ble_mesh_local_data_operation_api.c"
"ble_mesh/api/core/esp_ble_mesh_low_power_api.c"
"ble_mesh/api/core/esp_ble_mesh_networking_api.c"
"ble_mesh/api/core/esp_ble_mesh_provisioning_api.c"
"ble_mesh/api/core/esp_ble_mesh_proxy_api.c"
"ble_mesh/api/models/esp_ble_mesh_config_model_api.c"
"ble_mesh/api/models/esp_ble_mesh_generic_model_api.c"
"ble_mesh/api/models/esp_ble_mesh_health_model_api.c"
"ble_mesh/api/models/esp_ble_mesh_lighting_model_api.c"
"ble_mesh/api/models/esp_ble_mesh_sensor_model_api.c"
"ble_mesh/api/models/esp_ble_mesh_time_scene_model_api.c"
"ble_mesh/btc/btc_ble_mesh_config_model.c"
"ble_mesh/btc/btc_ble_mesh_generic_model.c"
"ble_mesh/btc/btc_ble_mesh_health_model.c"
"ble_mesh/btc/btc_ble_mesh_lighting_model.c"
"ble_mesh/btc/btc_ble_mesh_prov.c"
"ble_mesh/btc/btc_ble_mesh_sensor_model.c"
"ble_mesh/btc/btc_ble_mesh_time_scene_model.c"
"ble_mesh/mesh_core/settings/settings_act.c"
"ble_mesh/mesh_core/settings/settings_base64.c"
"ble_mesh/mesh_core/settings/settings_fcb.c"
"ble_mesh/mesh_core/settings/settings_init.c"
"ble_mesh/mesh_core/settings/settings_line.c"
"ble_mesh/mesh_core/settings/settings_store.c"
"ble_mesh/mesh_core/access.c"
"ble_mesh/mesh_core/adv.c"
"ble_mesh/mesh_core/beacon.c"
"ble_mesh/mesh_core/cfg_cli.c"
"ble_mesh/mesh_core/cfg_srv.c"
"ble_mesh/mesh_core/crypto.c"
"ble_mesh/mesh_core/friend.c"
"ble_mesh/mesh_core/health_cli.c"
"ble_mesh/mesh_core/health_srv.c"
"ble_mesh/mesh_core/lpn.c"
"ble_mesh/mesh_core/mesh_aes_encrypt.c"
"ble_mesh/mesh_core/mesh_atomic.c"
"ble_mesh/mesh_core/mesh_bearer_adapt.c"
"ble_mesh/mesh_core/mesh_buf.c"
"ble_mesh/mesh_core/mesh_hci.c"
"ble_mesh/mesh_core/mesh_kernel.c"
"ble_mesh/mesh_core/mesh_main.c"
"ble_mesh/mesh_core/mesh_util.c"
"ble_mesh/mesh_core/net.c"
"ble_mesh/mesh_core/prov.c"
"ble_mesh/mesh_core/provisioner_beacon.c"
"ble_mesh/mesh_core/provisioner_main.c"
"ble_mesh/mesh_core/provisioner_prov.c"
"ble_mesh/mesh_core/provisioner_proxy.c"
"ble_mesh/mesh_core/proxy.c"
"ble_mesh/mesh_core/settings.c"
"ble_mesh/mesh_core/test.c"
"ble_mesh/mesh_core/transport.c"
"ble_mesh/mesh_models/generic_client.c"
"ble_mesh/mesh_models/lighting_client.c"
"ble_mesh/mesh_models/mesh_common.c"
"ble_mesh/mesh_models/model_common.c"
"ble_mesh/mesh_models/sensor_client.c"
"ble_mesh/mesh_models/time_scene_client.c")
endif()
# requirements can't depend on config
set(COMPONENT_PRIV_REQUIRES nvs_flash)

File diff suppressed because it is too large Load Diff

View File

@@ -12,66 +12,59 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include <string.h>
#include <errno.h>
#include <stdint.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "freertos/semphr.h"
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include "osi/allocator.h"
#include "esp_bt_defs.h"
#include "esp_err.h"
#include "esp_bt_defs.h"
#include "esp_bt_main.h"
#include "sdkconfig.h"
#include "btc_ble_mesh_prov.h"
#include "mesh.h"
#include "mesh_buf.h"
#include "transport.h"
#include "esp_ble_mesh_common_api.h"
#if CONFIG_BT_MESH
#include "esp_ble_mesh_defs.h"
esp_err_t esp_ble_mesh_init(esp_ble_mesh_prov_t *prov, esp_ble_mesh_comp_t *comp)
{
btc_msg_t msg;
btc_ble_mesh_prov_args_t arg = {0};
xSemaphoreHandle semaphore = NULL;
SemaphoreHandle_t semaphore = NULL;
btc_msg_t msg = {0};
if (prov == NULL || comp == NULL) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
// Create a semaphore
if ((semaphore = xSemaphoreCreateCounting(1, 0)) == NULL) {
LOG_ERROR("%s, unable to allocate memory for the semaphore.", __func__);
LOG_ERROR("%s, Failed to allocate memory for the semaphore", __func__);
return ESP_ERR_NO_MEM;
}
arg.mesh_init.prov = prov;
arg.mesh_init.comp = comp;
/* Transport semaphore pointer to BTC layer, and will give the semaphore in the BTC task */
arg.mesh_init.semaphore = semaphore;
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_APP_REGISTER;
arg.mesh_reg.prov = prov;
arg.mesh_reg.comp = comp;
// semaphore pointer transport to BTC layer, we will give the semaphore in the BTC task.
arg.mesh_reg.semaphore = semaphore;
msg.act = BTC_BLE_MESH_ACT_MESH_INIT;
if (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL) != BT_STATUS_SUCCESS) {
vSemaphoreDelete(semaphore);
LOG_ERROR("BLE Mesh initialise failed");
LOG_ERROR("%s, BLE Mesh initialise failed", __func__);
return ESP_FAIL;
}
// Take the Semaphore, wait to BLE Mesh init finish.
/* Take the Semaphore, wait BLE Mesh initialization to finish. */
xSemaphoreTake(semaphore, portMAX_DELAY);
// Don't forget to delete the semaphore at the end.
/* Don't forget to delete the semaphore at the end. */
vSemaphoreDelete(semaphore);
return ESP_OK;
}
#endif /* #if CONFIG_BT_MESH */

View File

@@ -12,31 +12,23 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include <string.h>
#include <stdint.h>
#include <errno.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include "osi/allocator.h"
#include "esp_bt_defs.h"
#include "esp_err.h"
#include "esp_bt_defs.h"
#include "esp_bt_main.h"
#include "sdkconfig.h"
#include "btc_ble_mesh_prov.h"
#include "mesh.h"
#include "mesh_buf.h"
#include "transport.h"
#include "esp_ble_mesh_defs.h"
#if CONFIG_BT_MESH
int32_t esp_ble_mesh_get_model_publish_period(esp_ble_mesh_model_t *model)
{
if (model == NULL) {
return -EINVAL;
return 0;
}
return btc_ble_mesh_model_pub_period_get(model);
}
@@ -86,5 +78,3 @@ const esp_ble_mesh_comp_t *esp_ble_mesh_get_composition_data(void)
return btc_ble_mesh_comp_get();
}
#endif /* #if CONFIG_BT_MESH */

View File

@@ -12,26 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include <string.h>
#include <errno.h>
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include "osi/allocator.h"
#include "esp_bt_defs.h"
#include "esp_err.h"
#include "esp_bt_defs.h"
#include "esp_bt_main.h"
#include "sdkconfig.h"
#include "btc_ble_mesh_prov.h"
#include "mesh.h"
#include "mesh_buf.h"
#include "transport.h"
#include "esp_ble_mesh_defs.h"
#if CONFIG_BT_MESH
#endif /* #if CONFIG_BT_MESH */

View File

@@ -12,28 +12,20 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include <string.h>
#include <stdint.h>
#include <errno.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include "osi/allocator.h"
#include "esp_bt_defs.h"
#include "esp_err.h"
#include "esp_bt_defs.h"
#include "esp_bt_main.h"
#include "sdkconfig.h"
#include "btc_ble_mesh_prov.h"
#include "mesh.h"
#include "mesh_buf.h"
#include "transport.h"
#include "provisioner_main.h"
#include "esp_ble_mesh_defs.h"
#include "esp_ble_mesh_networking_api.h"
#if CONFIG_BT_MESH
#define ESP_BLE_MESH_TX_SDU_MAX ((CONFIG_BLE_MESH_ADV_BUF_COUNT - 3) * 12)
static esp_err_t ble_mesh_send_msg(esp_ble_mesh_model_t *model,
esp_ble_mesh_msg_ctx_t *ctx,
@@ -43,11 +35,11 @@ static esp_err_t ble_mesh_send_msg(esp_ble_mesh_model_t *model,
int32_t msg_timeout, bool need_rsp,
esp_ble_mesh_dev_role_t device_role)
{
btc_msg_t msg;
btc_ble_mesh_model_args_t arg;
esp_err_t status;
btc_ble_mesh_model_args_t arg = {0};
uint8_t op_len = 0, mic_len = 0;
uint8_t *msg_data = NULL;
btc_msg_t msg = {0};
esp_err_t status;
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
@@ -70,7 +62,7 @@ static esp_err_t ble_mesh_send_msg(esp_ble_mesh_model_t *model,
if (act == BTC_BLE_MESH_ACT_MODEL_PUBLISH) {
if (op_len + length > model->pub->msg->size) {
LOG_ERROR("%s: model->pub->msg->size %d is too small", __func__, model->pub->msg->size);
LOG_ERROR("%s, Model publication msg size %d is too small", __func__, model->pub->msg->size);
return ESP_ERR_INVALID_ARG;
}
}
@@ -81,8 +73,8 @@ static esp_err_t ble_mesh_send_msg(esp_ble_mesh_model_t *model,
mic_len = ctx->send_rel ? 8 : 4;
}
if (op_len + length + mic_len > MIN(ESP_BLE_MESH_SDU_MAX_LEN, BT_MESH_TX_SDU_MAX)) {
LOG_ERROR("%s: The data length %d is too large", __func__, length);
if (op_len + length + mic_len > MIN(ESP_BLE_MESH_SDU_MAX_LEN, ESP_BLE_MESH_TX_SDU_MAX)) {
LOG_ERROR("%s, Data length %d is too large", __func__, length);
return ESP_ERR_INVALID_ARG;
}
@@ -148,19 +140,23 @@ esp_err_t esp_ble_mesh_model_msg_opcode_init(uint8_t *data, uint32_t opcode)
if (opcode < 0x10000) {
/* 2-byte OpCode, big endian */
val = sys_cpu_to_be16 (opcode);
memcpy (data, &val, 2);
memcpy(data, &val, 2);
return ESP_OK;
}
/* 3-byte OpCode, note that little endian for the least 2 bytes(Company ID) of opcode */
data[0] = (opcode >> 16) & 0xff;
val = sys_cpu_to_le16(opcode & 0xffff);
memcpy (&data[1], &val, 2);
memcpy(&data[1], &val, 2);
return ESP_OK;
}
int esp_ble_mesh_client_model_init(esp_ble_mesh_model_t *model)
esp_err_t esp_ble_mesh_client_model_init(esp_ble_mesh_model_t *model)
{
if (model == NULL) {
return ESP_ERR_INVALID_ARG;
}
return btc_ble_mesh_client_init(model);
}
@@ -200,7 +196,7 @@ esp_err_t esp_ble_mesh_model_publish(esp_ble_mesh_model_t *model, uint32_t opcod
esp_err_t esp_ble_mesh_node_local_reset(void)
{
btc_msg_t msg;
btc_msg_t msg = {0};
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
@@ -211,17 +207,17 @@ esp_err_t esp_ble_mesh_node_local_reset(void)
return (btc_transfer_context(&msg, NULL, 0, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#if (CONFIG_BT_MESH_PROVISIONER)
#if (CONFIG_BLE_MESH_PROVISIONER)
esp_err_t esp_ble_mesh_provisioner_set_node_name(int index, const char *name)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (!name || (strlen(name) > ESP_BLE_MESH_NODE_NAME_MAX_LEN)) {
return ESP_ERR_INVALID_ARG;
}
btc_msg_t msg;
btc_ble_mesh_prov_args_t arg;
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
@@ -252,8 +248,8 @@ int esp_ble_mesh_provisioner_get_node_index(const char *name)
esp_err_t esp_ble_mesh_provisioner_add_local_app_key(const uint8_t app_key[16],
uint16_t net_idx, uint16_t app_idx)
{
btc_msg_t msg;
btc_ble_mesh_prov_args_t arg;
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
@@ -280,13 +276,13 @@ const uint8_t *esp_ble_mesh_provisioner_get_local_app_key(uint16_t net_idx, uint
esp_err_t esp_ble_mesh_provisioner_bind_app_key_to_local_model(uint16_t element_addr, uint16_t app_idx,
uint16_t model_id, uint16_t company_id)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (!ESP_BLE_MESH_ADDR_IS_UNICAST(element_addr)) {
return ESP_ERR_INVALID_ARG;
}
btc_msg_t msg;
btc_ble_mesh_prov_args_t arg;
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
@@ -303,13 +299,13 @@ esp_err_t esp_ble_mesh_provisioner_bind_app_key_to_local_model(uint16_t element_
esp_err_t esp_ble_mesh_provisioner_add_local_net_key(const uint8_t net_key[16], uint16_t net_idx)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (net_idx == ESP_BLE_MESH_KEY_PRIMARY) {
return ESP_ERR_INVALID_ARG;
}
btc_msg_t msg;
btc_ble_mesh_prov_args_t arg;
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
@@ -331,14 +327,12 @@ const uint8_t *esp_ble_mesh_provisioner_get_local_net_key(uint16_t net_idx)
return bt_mesh_provisioner_local_net_key_get(net_idx);
}
#endif /* CONFIG_BT_MESH_PROVISIONER */
#endif /* CONFIG_BLE_MESH_PROVISIONER */
#if (CONFIG_BT_MESH_FAST_PROV)
#if (CONFIG_BLE_MESH_FAST_PROV)
const uint8_t *esp_ble_mesh_get_fast_prov_app_key(uint16_t net_idx, uint16_t app_idx)
{
return bt_mesh_get_fast_prov_app_key(net_idx, app_idx);
}
#endif /* CONFIG_BT_MESH_FAST_PROV */
#endif /* #if CONFIG_BT_MESH */
#endif /* CONFIG_BLE_MESH_FAST_PROV */

View File

@@ -12,30 +12,19 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include <string.h>
#include <errno.h>
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include "osi/allocator.h"
#include "esp_bt_defs.h"
#include "esp_err.h"
#include "esp_bt_defs.h"
#include "esp_bt_main.h"
#include "sdkconfig.h"
#include "btc_ble_mesh_prov.h"
#include "mesh.h"
#include "mesh_buf.h"
#include "transport.h"
#include "provisioner_prov.h"
#include "esp_ble_mesh_defs.h"
#include "esp_ble_mesh_provisioning_api.h"
#if CONFIG_BT_MESH
#define MAX_PROV_LINK_IDX (CONFIG_BT_MESH_PBA_SAME_TIME + CONFIG_BT_MESH_PBG_SAME_TIME)
#define MAX_PROV_LINK_IDX (CONFIG_BLE_MESH_PBA_SAME_TIME + CONFIG_BLE_MESH_PBG_SAME_TIME)
#define MAX_OOB_INPUT_NUM 0x5F5E0FF /* Decimal: 99999999 */
esp_err_t esp_ble_mesh_register_prov_callback(esp_ble_mesh_prov_cb_t callback)
@@ -52,15 +41,15 @@ bool esp_ble_mesh_node_is_provisioned(void)
esp_err_t esp_ble_mesh_node_prov_enable(esp_ble_mesh_prov_bearer_t bearers)
{
btc_msg_t msg;
btc_ble_mesh_prov_args_t arg;
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_PROV_ENABLE;
arg.mesh_prov_enable.bearers = bearers;
arg.node_prov_enable.bearers = bearers;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
@@ -68,15 +57,15 @@ esp_err_t esp_ble_mesh_node_prov_enable(esp_ble_mesh_prov_bearer_t bearers)
esp_err_t esp_ble_mesh_node_prov_disable(esp_ble_mesh_prov_bearer_t bearers)
{
btc_msg_t msg;
btc_ble_mesh_prov_args_t arg;
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_PROV_DISABLE;
arg.mesh_prov_disable.bearers = bearers;
arg.node_prov_disable.bearers = bearers;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
@@ -85,8 +74,8 @@ 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])
{
btc_msg_t msg;
btc_ble_mesh_prov_args_t arg;
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (!pub_key_x || !pub_key_y || !private_key) {
return ESP_ERR_INVALID_ARG;
@@ -108,8 +97,8 @@ esp_err_t esp_ble_mesh_node_set_oob_pub_key(uint8_t pub_key_x[32], uint8_t pub_k
esp_err_t esp_ble_mesh_node_input_number(uint32_t number)
{
btc_msg_t msg;
btc_ble_mesh_prov_args_t arg;
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (number > MAX_OOB_INPUT_NUM) {
return ESP_ERR_INVALID_ARG;
@@ -120,7 +109,7 @@ esp_err_t esp_ble_mesh_node_input_number(uint32_t number)
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_INPUT_NUMBER;
arg.input_num.number = number;
arg.input_number.number = number;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
@@ -128,8 +117,8 @@ esp_err_t esp_ble_mesh_node_input_number(uint32_t number)
esp_err_t esp_ble_mesh_node_input_string(const char *string)
{
btc_msg_t msg;
btc_ble_mesh_prov_args_t arg;
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (!string) {
return ESP_ERR_INVALID_ARG;
@@ -140,8 +129,8 @@ esp_err_t esp_ble_mesh_node_input_string(const char *string)
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_INPUT_STRING;
memset(arg.input_str.string, 0, sizeof(arg.input_str.string));
strncpy(arg.input_str.string, string, strlen(string));
memset(arg.input_string.string, 0, sizeof(arg.input_string.string));
strncpy(arg.input_string.string, string, strlen(string));
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
@@ -149,13 +138,13 @@ esp_err_t esp_ble_mesh_node_input_string(const char *string)
esp_err_t esp_ble_mesh_set_unprovisioned_device_name(const char *name)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (!name || strlen(name) > ESP_BLE_MESH_DEVICE_NAME_MAX_LEN) {
return ESP_ERR_INVALID_ARG;
}
btc_msg_t msg;
btc_ble_mesh_prov_args_t arg;
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
@@ -168,12 +157,12 @@ esp_err_t esp_ble_mesh_set_unprovisioned_device_name(const char *name)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#if (CONFIG_BT_MESH_PROVISIONER)
#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])
{
btc_msg_t msg;
btc_ble_mesh_prov_args_t arg;
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (!pub_key_x || !pub_key_y || link_idx >= MAX_PROV_LINK_IDX) {
return ESP_ERR_INVALID_ARG;
@@ -195,8 +184,8 @@ esp_err_t esp_ble_mesh_provisioner_read_oob_pub_key(uint8_t link_idx, uint8_t pu
esp_err_t esp_ble_mesh_provisioner_input_string(const char *string, uint8_t link_idx)
{
btc_msg_t msg;
btc_ble_mesh_prov_args_t arg;
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (!string || link_idx >= MAX_PROV_LINK_IDX) {
return ESP_ERR_INVALID_ARG;
@@ -218,8 +207,8 @@ esp_err_t esp_ble_mesh_provisioner_input_string(const char *string, uint8_t link
esp_err_t esp_ble_mesh_provisioner_input_number(uint32_t number, uint8_t link_idx)
{
btc_msg_t msg;
btc_ble_mesh_prov_args_t arg;
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (number > MAX_OOB_INPUT_NUM || link_idx >= MAX_PROV_LINK_IDX) {
return ESP_ERR_INVALID_ARG;
@@ -240,8 +229,8 @@ esp_err_t esp_ble_mesh_provisioner_input_number(uint32_t number, uint8_t link_id
esp_err_t esp_ble_mesh_provisioner_prov_enable(esp_ble_mesh_prov_bearer_t bearers)
{
btc_msg_t msg;
btc_ble_mesh_prov_args_t arg;
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
@@ -257,8 +246,8 @@ esp_err_t esp_ble_mesh_provisioner_prov_enable(esp_ble_mesh_prov_bearer_t bearer
esp_err_t esp_ble_mesh_provisioner_prov_disable(esp_ble_mesh_prov_bearer_t bearers)
{
btc_msg_t msg;
btc_ble_mesh_prov_args_t arg;
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
@@ -275,8 +264,8 @@ esp_err_t esp_ble_mesh_provisioner_prov_disable(esp_ble_mesh_prov_bearer_t beare
esp_err_t esp_ble_mesh_provisioner_add_unprov_dev(esp_ble_mesh_unprov_dev_add_t *add_dev,
esp_ble_mesh_dev_add_flag_t flags)
{
btc_msg_t msg;
btc_ble_mesh_prov_args_t arg;
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (add_dev == NULL) {
return ESP_ERR_INVALID_ARG;
@@ -300,9 +289,9 @@ esp_err_t esp_ble_mesh_provisioner_add_unprov_dev(esp_ble_mesh_unprov_dev_add_t
esp_err_t esp_ble_mesh_provisioner_delete_dev(esp_ble_mesh_device_delete_t *del_dev)
{
btc_msg_t msg;
btc_ble_mesh_prov_args_t arg;
uint8_t val = DEL_DEV_ADDR_FLAG | DEL_DEV_UUID_FLAG;
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (del_dev == NULL || (__builtin_popcount(del_dev->flag & val) != 1)) {
return ESP_ERR_INVALID_ARG;
@@ -328,8 +317,8 @@ esp_err_t esp_ble_mesh_provisioner_delete_dev(esp_ble_mesh_device_delete_t *del_
esp_err_t esp_ble_mesh_provisioner_set_dev_uuid_match(const uint8_t *match_val, uint8_t match_len,
uint8_t offset, bool prov_after_match)
{
btc_msg_t msg;
btc_ble_mesh_prov_args_t arg;
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
@@ -349,9 +338,9 @@ esp_err_t esp_ble_mesh_provisioner_set_dev_uuid_match(const uint8_t *match_val,
esp_err_t esp_ble_mesh_provisioner_set_prov_data_info(esp_ble_mesh_prov_data_info_t *prov_data_info)
{
btc_msg_t msg;
btc_ble_mesh_prov_args_t arg;
uint8_t val = PROV_DATA_NET_IDX_FLAG | PROV_DATA_FLAGS_FLAG | PROV_DATA_IV_INDEX_FLAG;
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (prov_data_info == NULL || (__builtin_popcount(prov_data_info->flag & val) != 1)) {
return ESP_ERR_INVALID_ARG;
@@ -375,16 +364,16 @@ esp_err_t esp_ble_mesh_provisioner_set_prov_data_info(esp_ble_mesh_prov_data_inf
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif /* CONFIG_BT_MESH_PROVISIONER */
#endif /* CONFIG_BLE_MESH_PROVISIONER */
/* The following APIs are for fast provisioning */
#if (CONFIG_BT_MESH_FAST_PROV)
#if (CONFIG_BLE_MESH_FAST_PROV)
esp_err_t esp_ble_mesh_set_fast_prov_info(esp_ble_mesh_fast_prov_info_t *fast_prov_info)
{
btc_msg_t msg;
btc_ble_mesh_prov_args_t arg;
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (fast_prov_info == NULL) {
return ESP_ERR_INVALID_ARG;
@@ -412,8 +401,8 @@ esp_err_t esp_ble_mesh_set_fast_prov_info(esp_ble_mesh_fast_prov_info_t *fast_pr
esp_err_t esp_ble_mesh_set_fast_prov_action(esp_ble_mesh_fast_prov_action_t action)
{
btc_msg_t msg;
btc_ble_mesh_prov_args_t arg;
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (action >= FAST_PROV_ACT_MAX) {
return ESP_ERR_INVALID_ARG;
@@ -430,7 +419,5 @@ esp_err_t esp_ble_mesh_set_fast_prov_action(esp_ble_mesh_fast_prov_action_t acti
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif /* CONFIG_BT_MESH_FAST_PROV */
#endif /* #if CONFIG_BT_MESH */
#endif /* CONFIG_BLE_MESH_FAST_PROV */

View File

@@ -12,29 +12,21 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include <string.h>
#include <errno.h>
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
#include "osi/allocator.h"
#include "esp_bt_defs.h"
#include "esp_err.h"
#include "esp_bt_defs.h"
#include "esp_bt_main.h"
#include "sdkconfig.h"
#include "btc_ble_mesh_prov.h"
#include "mesh.h"
#include "mesh_buf.h"
#include "transport.h"
#if CONFIG_BT_MESH
#include "esp_ble_mesh_defs.h"
esp_err_t esp_ble_mesh_proxy_identity_enable(void)
{
btc_msg_t msg;
btc_msg_t msg = {0};
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
@@ -47,7 +39,7 @@ esp_err_t esp_ble_mesh_proxy_identity_enable(void)
esp_err_t esp_ble_mesh_proxy_gatt_enable(void)
{
btc_msg_t msg;
btc_msg_t msg = {0};
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
@@ -60,7 +52,7 @@ esp_err_t esp_ble_mesh_proxy_gatt_enable(void)
esp_err_t esp_ble_mesh_proxy_gatt_disable(void)
{
btc_msg_t msg;
btc_msg_t msg = {0};
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
@@ -71,5 +63,3 @@ esp_err_t esp_ble_mesh_proxy_gatt_disable(void)
return (btc_transfer_context(&msg, NULL, 0, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif /* #if CONFIG_BT_MESH */

View File

@@ -17,8 +17,6 @@
#include "esp_ble_mesh_defs.h"
#if CONFIG_BT_MESH
/**
* @brief Initialize BLE Mesh module.
* This API initializes provisioning capabilities and composition data information.
@@ -34,6 +32,4 @@
*/
esp_err_t esp_ble_mesh_init(esp_ble_mesh_prov_t *prov, esp_ble_mesh_comp_t *comp);
#endif /* #if CONFIG_BT_MESH */
#endif /* _ESP_BLE_MESH_COMMON_API_H_ */

View File

@@ -17,8 +17,6 @@
#include "esp_ble_mesh_defs.h"
#if CONFIG_BT_MESH
/**
* @brief Get the model publish period, the unit is ms.
*
@@ -112,6 +110,4 @@ esp_ble_mesh_model_t *esp_ble_mesh_find_sig_model(esp_ble_mesh_elem_t *element,
*/
const esp_ble_mesh_comp_t *esp_ble_mesh_get_composition_data(void);
#endif /* #if CONFIG_BT_MESH */
#endif /* _ESP_BLE_MESH_LOCAL_DATA_OPERATION_API_H_ */

View File

@@ -17,8 +17,4 @@
#include "esp_ble_mesh_defs.h"
#if CONFIG_BT_MESH
#endif /* #if CONFIG_BT_MESH */
#endif /* _ESP_BLE_MESH_LOW_POWER_API_H_ */

View File

@@ -17,8 +17,6 @@
#include "esp_ble_mesh_defs.h"
#if CONFIG_BT_MESH
/** @brief: event, event code of user-defined model events; param, parameters of user-defined model events */
typedef void (* esp_ble_mesh_model_cb_t)(esp_ble_mesh_model_cb_event_t event,
esp_ble_mesh_model_cb_param_t *param);
@@ -150,7 +148,7 @@ esp_err_t esp_ble_mesh_model_publish(esp_ble_mesh_model_t *model, uint32_t opcod
*/
esp_err_t esp_ble_mesh_node_local_reset(void);
#if defined(CONFIG_BT_MESH_PROVISIONER)
#if defined(CONFIG_BLE_MESH_PROVISIONER)
/**
* @brief This function is called to set the node (provisioned device) name.
*
@@ -256,7 +254,7 @@ esp_err_t esp_ble_mesh_provisioner_add_local_net_key(const uint8_t net_key[16],
*/
const uint8_t *esp_ble_mesh_provisioner_get_local_net_key(uint16_t net_idx);
#endif /* #if CONFIG_BT_MESH_PROVISIONER */
#endif /* #if CONFIG_BLE_MESH_PROVISIONER */
/**
* @brief This function is called to get fast provisioning application key.
@@ -269,6 +267,4 @@ const uint8_t *esp_ble_mesh_provisioner_get_local_net_key(uint16_t net_idx);
*/
const uint8_t *esp_ble_mesh_get_fast_prov_app_key(uint16_t net_idx, uint16_t app_idx);
#endif /* #if CONFIG_BT_MESH */
#endif /* _ESP_BLE_MESH_NETWORKING_API_H_ */

View File

@@ -17,8 +17,6 @@
#include "esp_ble_mesh_defs.h"
#if CONFIG_BT_MESH
/** @brief: event, event code of provisioning events; param, parameters of provisioning events */
typedef void (* esp_ble_mesh_prov_cb_t)(esp_ble_mesh_prov_cb_event_t event,
esp_ble_mesh_prov_cb_param_t *param);
@@ -118,7 +116,7 @@ esp_err_t esp_ble_mesh_node_input_string(const char *string);
*/
esp_err_t esp_ble_mesh_set_unprovisioned_device_name(const char *name);
#if defined(CONFIG_BT_MESH_PROVISIONER)
#if defined(CONFIG_BLE_MESH_PROVISIONER)
/**
* @brief Provisioner inputs unprovisioned device's oob public key.
@@ -296,7 +294,7 @@ esp_err_t esp_ble_mesh_provisioner_set_dev_uuid_match(const uint8_t *match_val,
*/
esp_err_t esp_ble_mesh_provisioner_set_prov_data_info(esp_ble_mesh_prov_data_info_t *prov_data_info);
#endif /* #if CONFIG_BT_MESH_PROVISIONER */
#endif /* #if CONFIG_BLE_MESH_PROVISIONER */
/**
* @brief This function is called to set provisioning data information before starting
@@ -319,6 +317,4 @@ esp_err_t esp_ble_mesh_set_fast_prov_info(esp_ble_mesh_fast_prov_info_t *fast_pr
*/
esp_err_t esp_ble_mesh_set_fast_prov_action(esp_ble_mesh_fast_prov_action_t action);
#endif /* #if CONFIG_BT_MESH */
#endif /* _ESP_BLE_MESH_PROVISIONING_API_H_ */

View File

@@ -19,16 +19,17 @@
#include "esp_bt_defs.h"
#include "mesh.h"
#include "proxy.h"
#include "include/proxy.h"
#include "mesh_proxy.h"
#include "mesh_access.h"
#include "mesh_main.h"
#include "foundation.h"
#include "model_op.h"
#include "common.h"
#if CONFIG_BT_MESH
#include "mesh.h"
#include "proxy.h"
#include "foundation.h"
#include "provisioner_main.h"
#include "model_opcode.h"
#include "mesh_common.h"
#ifndef MIN
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
@@ -50,118 +51,118 @@ typedef uint8_t esp_ble_mesh_octet16_t[ESP_BLE_MESH_OCTET16_LEN];
#define ESP_BLE_MESH_OCTET8_LEN 8
typedef uint8_t esp_ble_mesh_octet8_t[ESP_BLE_MESH_OCTET8_LEN];
#define ESP_BLE_MESH_ADDR_UNASSIGNED BT_MESH_ADDR_UNASSIGNED
#define ESP_BLE_MESH_ADDR_ALL_NODES BT_MESH_ADDR_ALL_NODES
#define ESP_BLE_MESH_ADDR_PROXIES BT_MESH_ADDR_PROXIES
#define ESP_BLE_MESH_ADDR_FRIENDS BT_MESH_ADDR_FRIENDS
#define ESP_BLE_MESH_ADDR_RELAYS BT_MESH_ADDR_RELAYS
#define ESP_BLE_MESH_ADDR_UNASSIGNED BLE_MESH_ADDR_UNASSIGNED
#define ESP_BLE_MESH_ADDR_ALL_NODES BLE_MESH_ADDR_ALL_NODES
#define ESP_BLE_MESH_ADDR_PROXIES BLE_MESH_ADDR_PROXIES
#define ESP_BLE_MESH_ADDR_FRIENDS BLE_MESH_ADDR_FRIENDS
#define ESP_BLE_MESH_ADDR_RELAYS BLE_MESH_ADDR_RELAYS
#define ESP_BLE_MESH_KEY_UNUSED BT_MESH_KEY_UNUSED
#define ESP_BLE_MESH_KEY_DEV BT_MESH_KEY_DEV
#define ESP_BLE_MESH_KEY_UNUSED BLE_MESH_KEY_UNUSED
#define ESP_BLE_MESH_KEY_DEV BLE_MESH_KEY_DEV
#define ESP_BLE_MESH_KEY_PRIMARY BT_MESH_KEY_PRIMARY
#define ESP_BLE_MESH_KEY_ANY BT_MESH_KEY_ANY
#define ESP_BLE_MESH_KEY_PRIMARY BLE_MESH_KEY_PRIMARY
#define ESP_BLE_MESH_KEY_ANY BLE_MESH_KEY_ANY
/*!< Primary Network Key index */
#define ESP_BLE_MESH_NET_PRIMARY BT_MESH_NET_PRIMARY
#define ESP_BLE_MESH_NET_PRIMARY BLE_MESH_NET_PRIMARY
/*!< Relay state value */
#define ESP_BLE_MESH_RELAY_DISABLED BT_MESH_RELAY_DISABLED
#define ESP_BLE_MESH_RELAY_ENABLED BT_MESH_RELAY_ENABLED
#define ESP_BLE_MESH_RELAY_NOT_SUPPORTED BT_MESH_RELAY_NOT_SUPPORTED
#define ESP_BLE_MESH_RELAY_DISABLED BLE_MESH_RELAY_DISABLED
#define ESP_BLE_MESH_RELAY_ENABLED BLE_MESH_RELAY_ENABLED
#define ESP_BLE_MESH_RELAY_NOT_SUPPORTED BLE_MESH_RELAY_NOT_SUPPORTED
/*!< Beacon state value */
#define ESP_BLE_MESH_BEACON_DISABLED BT_MESH_BEACON_DISABLED
#define ESP_BLE_MESH_BEACON_ENABLED BT_MESH_BEACON_ENABLED
#define ESP_BLE_MESH_BEACON_DISABLED BLE_MESH_BEACON_DISABLED
#define ESP_BLE_MESH_BEACON_ENABLED BLE_MESH_BEACON_ENABLED
/*!< GATT Proxy state value */
#define ESP_BLE_MESH_GATT_PROXY_DISABLED BT_MESH_GATT_PROXY_DISABLED
#define ESP_BLE_MESH_GATT_PROXY_ENABLED BT_MESH_GATT_PROXY_ENABLED
#define ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED BT_MESH_GATT_PROXY_NOT_SUPPORTED
#define ESP_BLE_MESH_GATT_PROXY_DISABLED BLE_MESH_GATT_PROXY_DISABLED
#define ESP_BLE_MESH_GATT_PROXY_ENABLED BLE_MESH_GATT_PROXY_ENABLED
#define ESP_BLE_MESH_GATT_PROXY_NOT_SUPPORTED BLE_MESH_GATT_PROXY_NOT_SUPPORTED
/*!< Friend state value */
#define ESP_BLE_MESH_FRIEND_DISABLED BT_MESH_FRIEND_DISABLED
#define ESP_BLE_MESH_FRIEND_ENABLED BT_MESH_FRIEND_ENABLED
#define ESP_BLE_MESH_FRIEND_NOT_SUPPORTED BT_MESH_FRIEND_NOT_SUPPORTED
#define ESP_BLE_MESH_FRIEND_DISABLED BLE_MESH_FRIEND_DISABLED
#define ESP_BLE_MESH_FRIEND_ENABLED BLE_MESH_FRIEND_ENABLED
#define ESP_BLE_MESH_FRIEND_NOT_SUPPORTED BLE_MESH_FRIEND_NOT_SUPPORTED
/*!< Node identity state value */
#define ESP_BLE_MESH_NODE_IDENTITY_STOPPED BT_MESH_NODE_IDENTITY_STOPPED
#define ESP_BLE_MESH_NODE_IDENTITY_RUNNING BT_MESH_NODE_IDENTITY_RUNNING
#define ESP_BLE_MESH_NODE_IDENTITY_NOT_SUPPORTED BT_MESH_NODE_IDENTITY_NOT_SUPPORTED
#define ESP_BLE_MESH_NODE_IDENTITY_STOPPED BLE_MESH_NODE_IDENTITY_STOPPED
#define ESP_BLE_MESH_NODE_IDENTITY_RUNNING BLE_MESH_NODE_IDENTITY_RUNNING
#define ESP_BLE_MESH_NODE_IDENTITY_NOT_SUPPORTED BLE_MESH_NODE_IDENTITY_NOT_SUPPORTED
/*!< Supported features */
#define ESP_BLE_MESH_FEATURE_RELAY BT_MESH_FEAT_RELAY
#define ESP_BLE_MESH_FEATURE_PROXY BT_MESH_FEAT_PROXY
#define ESP_BLE_MESH_FEATURE_FRIEND BT_MESH_FEAT_FRIEND
#define ESP_BLE_MESH_FEATURE_LOW_POWER BT_MESH_FEAT_LOW_POWER
#define ESP_BLE_MESH_FEATURE_ALL_SUPPORTED BT_MESH_FEAT_SUPPORTED
#define ESP_BLE_MESH_FEATURE_RELAY BLE_MESH_FEAT_RELAY
#define ESP_BLE_MESH_FEATURE_PROXY BLE_MESH_FEAT_PROXY
#define ESP_BLE_MESH_FEATURE_FRIEND BLE_MESH_FEAT_FRIEND
#define ESP_BLE_MESH_FEATURE_LOW_POWER BLE_MESH_FEAT_LOW_POWER
#define ESP_BLE_MESH_FEATURE_ALL_SUPPORTED BLE_MESH_FEAT_SUPPORTED
#define ESP_BLE_MESH_ADDR_IS_UNICAST(addr) BT_MESH_ADDR_IS_UNICAST(addr)
#define ESP_BLE_MESH_ADDR_IS_GROUP(addr) BT_MESH_ADDR_IS_GROUP(addr)
#define ESP_BLE_MESH_ADDR_IS_VIRTUAL(addr) BT_MESH_ADDR_IS_VIRTUAL(addr)
#define ESP_BLE_MESH_ADDR_IS_RFU(addr) BT_MESH_ADDR_IS_RFU(addr)
#define ESP_BLE_MESH_ADDR_IS_UNICAST(addr) BLE_MESH_ADDR_IS_UNICAST(addr)
#define ESP_BLE_MESH_ADDR_IS_GROUP(addr) BLE_MESH_ADDR_IS_GROUP(addr)
#define ESP_BLE_MESH_ADDR_IS_VIRTUAL(addr) BLE_MESH_ADDR_IS_VIRTUAL(addr)
#define ESP_BLE_MESH_ADDR_IS_RFU(addr) BLE_MESH_ADDR_IS_RFU(addr)
#define ESP_BLE_MESH_INVALID_NODE_INDEX (-1)
/*!< Foundation Models */
#define ESP_BLE_MESH_MODEL_ID_CONFIG_SRV BT_MESH_MODEL_ID_CFG_SRV
#define ESP_BLE_MESH_MODEL_ID_CONFIG_CLI BT_MESH_MODEL_ID_CFG_CLI
#define ESP_BLE_MESH_MODEL_ID_HEALTH_SRV BT_MESH_MODEL_ID_HEALTH_SRV
#define ESP_BLE_MESH_MODEL_ID_HEALTH_CLI BT_MESH_MODEL_ID_HEALTH_CLI
#define ESP_BLE_MESH_MODEL_ID_CONFIG_SRV BLE_MESH_MODEL_ID_CFG_SRV
#define ESP_BLE_MESH_MODEL_ID_CONFIG_CLI BLE_MESH_MODEL_ID_CFG_CLI
#define ESP_BLE_MESH_MODEL_ID_HEALTH_SRV BLE_MESH_MODEL_ID_HEALTH_SRV
#define ESP_BLE_MESH_MODEL_ID_HEALTH_CLI BLE_MESH_MODEL_ID_HEALTH_CLI
/*!< Models from the Mesh Model Specification */
#define ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_SRV BT_MESH_MODEL_ID_GEN_ONOFF_SRV
#define ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_CLI BT_MESH_MODEL_ID_GEN_ONOFF_CLI
#define ESP_BLE_MESH_MODEL_ID_GEN_LEVEL_SRV BT_MESH_MODEL_ID_GEN_LEVEL_SRV
#define ESP_BLE_MESH_MODEL_ID_GEN_LEVEL_CLI BT_MESH_MODEL_ID_GEN_LEVEL_CLI
#define ESP_BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_SRV BT_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_SRV
#define ESP_BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_CLI BT_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_CLI
#define ESP_BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SRV BT_MESH_MODEL_ID_GEN_POWER_ONOFF_SRV
#define ESP_BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SETUP_SRV BT_MESH_MODEL_ID_GEN_POWER_ONOFF_SETUP_SRV
#define ESP_BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_CLI BT_MESH_MODEL_ID_GEN_POWER_ONOFF_CLI
#define ESP_BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SRV BT_MESH_MODEL_ID_GEN_POWER_LEVEL_SRV
#define ESP_BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SETUP_SRV BT_MESH_MODEL_ID_GEN_POWER_LEVEL_SETUP_SRV
#define ESP_BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_CLI BT_MESH_MODEL_ID_GEN_POWER_LEVEL_CLI
#define ESP_BLE_MESH_MODEL_ID_GEN_BATTERY_SRV BT_MESH_MODEL_ID_GEN_BATTERY_SRV
#define ESP_BLE_MESH_MODEL_ID_GEN_BATTERY_CLI BT_MESH_MODEL_ID_GEN_BATTERY_CLI
#define ESP_BLE_MESH_MODEL_ID_GEN_LOCATION_SRV BT_MESH_MODEL_ID_GEN_LOCATION_SRV
#define ESP_BLE_MESH_MODEL_ID_GEN_LOCATION_SETUP_SRV BT_MESH_MODEL_ID_GEN_LOCATION_SETUPSRV
#define ESP_BLE_MESH_MODEL_ID_GEN_LOCATION_CLI BT_MESH_MODEL_ID_GEN_LOCATION_CLI
#define ESP_BLE_MESH_MODEL_ID_GEN_ADMIN_PROP_SRV BT_MESH_MODEL_ID_GEN_ADMIN_PROP_SRV
#define ESP_BLE_MESH_MODEL_ID_GEN_MANUFACTURER_PROP_SRV BT_MESH_MODEL_ID_GEN_MANUFACTURER_PROP_SRV
#define ESP_BLE_MESH_MODEL_ID_GEN_USER_PROP_SRV BT_MESH_MODEL_ID_GEN_USER_PROP_SRV
#define ESP_BLE_MESH_MODEL_ID_GEN_CLIENT_PROP_SRV BT_MESH_MODEL_ID_GEN_CLIENT_PROP_SRV
#define ESP_BLE_MESH_MODEL_ID_GEN_PROP_CLI BT_MESH_MODEL_ID_GEN_PROP_CLI
#define ESP_BLE_MESH_MODEL_ID_SENSOR_SRV BT_MESH_MODEL_ID_SENSOR_SRV
#define ESP_BLE_MESH_MODEL_ID_SENSOR_SETUP_SRV BT_MESH_MODEL_ID_SENSOR_SETUP_SRV
#define ESP_BLE_MESH_MODEL_ID_SENSOR_CLI BT_MESH_MODEL_ID_SENSOR_CLI
#define ESP_BLE_MESH_MODEL_ID_TIME_SRV BT_MESH_MODEL_ID_TIME_SRV
#define ESP_BLE_MESH_MODEL_ID_TIME_SETUP_SRV BT_MESH_MODEL_ID_TIME_SETUP_SRV
#define ESP_BLE_MESH_MODEL_ID_TIME_CLI BT_MESH_MODEL_ID_TIME_CLI
#define ESP_BLE_MESH_MODEL_ID_SCENE_SRV BT_MESH_MODEL_ID_SCENE_SRV
#define ESP_BLE_MESH_MODEL_ID_SCENE_SETUP_SRV BT_MESH_MODEL_ID_SCENE_SETUP_SRV
#define ESP_BLE_MESH_MODEL_ID_SCENE_CLI BT_MESH_MODEL_ID_SCENE_CLI
#define ESP_BLE_MESH_MODEL_ID_SCHEDULER_SRV BT_MESH_MODEL_ID_SCHEDULER_SRV
#define ESP_BLE_MESH_MODEL_ID_SCHEDULER_SETUP_SRV BT_MESH_MODEL_ID_SCHEDULER_SETUP_SRV
#define ESP_BLE_MESH_MODEL_ID_SCHEDULER_CLI BT_MESH_MODEL_ID_SCHEDULER_CLI
#define ESP_BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SRV BT_MESH_MODEL_ID_LIGHT_LIGHTNESS_SRV
#define ESP_BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SETUP_SRV BT_MESH_MODEL_ID_LIGHT_LIGHTNESS_SETUP_SRV
#define ESP_BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_CLI BT_MESH_MODEL_ID_LIGHT_LIGHTNESS_CLI
#define ESP_BLE_MESH_MODEL_ID_LIGHT_CTL_SRV BT_MESH_MODEL_ID_LIGHT_CTL_SRV
#define ESP_BLE_MESH_MODEL_ID_LIGHT_CTL_SETUP_SRV BT_MESH_MODEL_ID_LIGHT_CTL_SETUP_SRV
#define ESP_BLE_MESH_MODEL_ID_LIGHT_CTL_CLI BT_MESH_MODEL_ID_LIGHT_CTL_CLI
#define ESP_BLE_MESH_MODEL_ID_LIGHT_CTL_TEMP_SRV BT_MESH_MODEL_ID_LIGHT_CTL_TEMP_SRV
#define ESP_BLE_MESH_MODEL_ID_LIGHT_HSL_SRV BT_MESH_MODEL_ID_LIGHT_HSL_SRV
#define ESP_BLE_MESH_MODEL_ID_LIGHT_HSL_SETUP_SRV BT_MESH_MODEL_ID_LIGHT_HSL_SETUP_SRV
#define ESP_BLE_MESH_MODEL_ID_LIGHT_HSL_CLI BT_MESH_MODEL_ID_LIGHT_HSL_CLI
#define ESP_BLE_MESH_MODEL_ID_LIGHT_HSL_HUE_SRV BT_MESH_MODEL_ID_LIGHT_HSL_HUE_SRV
#define ESP_BLE_MESH_MODEL_ID_LIGHT_HSL_SAT_SRV BT_MESH_MODEL_ID_LIGHT_HSL_SAT_SRV
#define ESP_BLE_MESH_MODEL_ID_LIGHT_XYL_SRV BT_MESH_MODEL_ID_LIGHT_XYL_SRV
#define ESP_BLE_MESH_MODEL_ID_LIGHT_XYL_SETUP_SRV BT_MESH_MODEL_ID_LIGHT_XYL_SETUP_SRV
#define ESP_BLE_MESH_MODEL_ID_LIGHT_XYL_CLI BT_MESH_MODEL_ID_LIGHT_XYL_CLI
#define ESP_BLE_MESH_MODEL_ID_LIGHT_LC_SRV BT_MESH_MODEL_ID_LIGHT_LC_SRV
#define ESP_BLE_MESH_MODEL_ID_LIGHT_LC_SETUP_SRV BT_MESH_MODEL_ID_LIGHT_LC_SETUPSRV
#define ESP_BLE_MESH_MODEL_ID_LIGHT_LC_CLI BT_MESH_MODEL_ID_LIGHT_LC_CLI
#define ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_SRV BLE_MESH_MODEL_ID_GEN_ONOFF_SRV
#define ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_CLI BLE_MESH_MODEL_ID_GEN_ONOFF_CLI
#define ESP_BLE_MESH_MODEL_ID_GEN_LEVEL_SRV BLE_MESH_MODEL_ID_GEN_LEVEL_SRV
#define ESP_BLE_MESH_MODEL_ID_GEN_LEVEL_CLI BLE_MESH_MODEL_ID_GEN_LEVEL_CLI
#define ESP_BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_SRV BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_SRV
#define ESP_BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_CLI BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_CLI
#define ESP_BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SRV BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SRV
#define ESP_BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SETUP_SRV BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SETUP_SRV
#define ESP_BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_CLI BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_CLI
#define ESP_BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SRV BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SRV
#define ESP_BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SETUP_SRV BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SETUP_SRV
#define ESP_BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_CLI BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_CLI
#define ESP_BLE_MESH_MODEL_ID_GEN_BATTERY_SRV BLE_MESH_MODEL_ID_GEN_BATTERY_SRV
#define ESP_BLE_MESH_MODEL_ID_GEN_BATTERY_CLI BLE_MESH_MODEL_ID_GEN_BATTERY_CLI
#define ESP_BLE_MESH_MODEL_ID_GEN_LOCATION_SRV BLE_MESH_MODEL_ID_GEN_LOCATION_SRV
#define ESP_BLE_MESH_MODEL_ID_GEN_LOCATION_SETUP_SRV BLE_MESH_MODEL_ID_GEN_LOCATION_SETUPSRV
#define ESP_BLE_MESH_MODEL_ID_GEN_LOCATION_CLI BLE_MESH_MODEL_ID_GEN_LOCATION_CLI
#define ESP_BLE_MESH_MODEL_ID_GEN_ADMIN_PROP_SRV BLE_MESH_MODEL_ID_GEN_ADMIN_PROP_SRV
#define ESP_BLE_MESH_MODEL_ID_GEN_MANUFACTURER_PROP_SRV BLE_MESH_MODEL_ID_GEN_MANUFACTURER_PROP_SRV
#define ESP_BLE_MESH_MODEL_ID_GEN_USER_PROP_SRV BLE_MESH_MODEL_ID_GEN_USER_PROP_SRV
#define ESP_BLE_MESH_MODEL_ID_GEN_CLIENT_PROP_SRV BLE_MESH_MODEL_ID_GEN_CLIENT_PROP_SRV
#define ESP_BLE_MESH_MODEL_ID_GEN_PROP_CLI BLE_MESH_MODEL_ID_GEN_PROP_CLI
#define ESP_BLE_MESH_MODEL_ID_SENSOR_SRV BLE_MESH_MODEL_ID_SENSOR_SRV
#define ESP_BLE_MESH_MODEL_ID_SENSOR_SETUP_SRV BLE_MESH_MODEL_ID_SENSOR_SETUP_SRV
#define ESP_BLE_MESH_MODEL_ID_SENSOR_CLI BLE_MESH_MODEL_ID_SENSOR_CLI
#define ESP_BLE_MESH_MODEL_ID_TIME_SRV BLE_MESH_MODEL_ID_TIME_SRV
#define ESP_BLE_MESH_MODEL_ID_TIME_SETUP_SRV BLE_MESH_MODEL_ID_TIME_SETUP_SRV
#define ESP_BLE_MESH_MODEL_ID_TIME_CLI BLE_MESH_MODEL_ID_TIME_CLI
#define ESP_BLE_MESH_MODEL_ID_SCENE_SRV BLE_MESH_MODEL_ID_SCENE_SRV
#define ESP_BLE_MESH_MODEL_ID_SCENE_SETUP_SRV BLE_MESH_MODEL_ID_SCENE_SETUP_SRV
#define ESP_BLE_MESH_MODEL_ID_SCENE_CLI BLE_MESH_MODEL_ID_SCENE_CLI
#define ESP_BLE_MESH_MODEL_ID_SCHEDULER_SRV BLE_MESH_MODEL_ID_SCHEDULER_SRV
#define ESP_BLE_MESH_MODEL_ID_SCHEDULER_SETUP_SRV BLE_MESH_MODEL_ID_SCHEDULER_SETUP_SRV
#define ESP_BLE_MESH_MODEL_ID_SCHEDULER_CLI BLE_MESH_MODEL_ID_SCHEDULER_CLI
#define ESP_BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SRV BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SRV
#define ESP_BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SETUP_SRV BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SETUP_SRV
#define ESP_BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_CLI BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_CLI
#define ESP_BLE_MESH_MODEL_ID_LIGHT_CTL_SRV BLE_MESH_MODEL_ID_LIGHT_CTL_SRV
#define ESP_BLE_MESH_MODEL_ID_LIGHT_CTL_SETUP_SRV BLE_MESH_MODEL_ID_LIGHT_CTL_SETUP_SRV
#define ESP_BLE_MESH_MODEL_ID_LIGHT_CTL_CLI BLE_MESH_MODEL_ID_LIGHT_CTL_CLI
#define ESP_BLE_MESH_MODEL_ID_LIGHT_CTL_TEMP_SRV BLE_MESH_MODEL_ID_LIGHT_CTL_TEMP_SRV
#define ESP_BLE_MESH_MODEL_ID_LIGHT_HSL_SRV BLE_MESH_MODEL_ID_LIGHT_HSL_SRV
#define ESP_BLE_MESH_MODEL_ID_LIGHT_HSL_SETUP_SRV BLE_MESH_MODEL_ID_LIGHT_HSL_SETUP_SRV
#define ESP_BLE_MESH_MODEL_ID_LIGHT_HSL_CLI BLE_MESH_MODEL_ID_LIGHT_HSL_CLI
#define ESP_BLE_MESH_MODEL_ID_LIGHT_HSL_HUE_SRV BLE_MESH_MODEL_ID_LIGHT_HSL_HUE_SRV
#define ESP_BLE_MESH_MODEL_ID_LIGHT_HSL_SAT_SRV BLE_MESH_MODEL_ID_LIGHT_HSL_SAT_SRV
#define ESP_BLE_MESH_MODEL_ID_LIGHT_XYL_SRV BLE_MESH_MODEL_ID_LIGHT_XYL_SRV
#define ESP_BLE_MESH_MODEL_ID_LIGHT_XYL_SETUP_SRV BLE_MESH_MODEL_ID_LIGHT_XYL_SETUP_SRV
#define ESP_BLE_MESH_MODEL_ID_LIGHT_XYL_CLI BLE_MESH_MODEL_ID_LIGHT_XYL_CLI
#define ESP_BLE_MESH_MODEL_ID_LIGHT_LC_SRV BLE_MESH_MODEL_ID_LIGHT_LC_SRV
#define ESP_BLE_MESH_MODEL_ID_LIGHT_LC_SETUP_SRV BLE_MESH_MODEL_ID_LIGHT_LC_SETUPSRV
#define ESP_BLE_MESH_MODEL_ID_LIGHT_LC_CLI BLE_MESH_MODEL_ID_LIGHT_LC_CLI
/*!< The following opcodes will only be used in the esp_ble_mesh_config_client_get_state function. */
typedef uint32_t esp_ble_mesh_opcode_config_client_get_t; /*!< esp_ble_mesh_opcode_config_client_get_t belongs to esp_ble_mesh_opcode_t,
@@ -302,269 +303,269 @@ typedef uint32_t esp_ble_mesh_generic_message_opcode_t; /*!< esp_ble_mesh_ge
this typedef is only used to locate the opcodes used by functions
esp_ble_mesh_generic_client_get_state & esp_ble_mesh_generic_client_set_state */
/*!< Generic OnOff Message Opcode */
#define ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_GET BT_MESH_MODEL_OP_GEN_ONOFF_GET
#define ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_SET BT_MESH_MODEL_OP_GEN_ONOFF_SET
#define ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_SET_UNACK BT_MESH_MODEL_OP_GEN_ONOFF_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_STATUS BT_MESH_MODEL_OP_GEN_ONOFF_STATUS
#define ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_GET BLE_MESH_MODEL_OP_GEN_ONOFF_GET
#define ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_SET BLE_MESH_MODEL_OP_GEN_ONOFF_SET
#define ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_SET_UNACK BLE_MESH_MODEL_OP_GEN_ONOFF_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_STATUS BLE_MESH_MODEL_OP_GEN_ONOFF_STATUS
/*!< Generic Level Message Opcode */
#define ESP_BLE_MESH_MODEL_OP_GEN_LEVEL_GET BT_MESH_MODEL_OP_GEN_LEVEL_GET
#define ESP_BLE_MESH_MODEL_OP_GEN_LEVEL_SET BT_MESH_MODEL_OP_GEN_LEVEL_SET
#define ESP_BLE_MESH_MODEL_OP_GEN_LEVEL_SET_UNACK BT_MESH_MODEL_OP_GEN_LEVEL_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_GEN_LEVEL_STATUS BT_MESH_MODEL_OP_GEN_LEVEL_STATUS
#define ESP_BLE_MESH_MODEL_OP_GEN_DELTA_SET BT_MESH_MODEL_OP_GEN_DELTA_SET
#define ESP_BLE_MESH_MODEL_OP_GEN_DELTA_SET_UNACK BT_MESH_MODEL_OP_GEN_DELTA_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_GEN_MOVE_SET BT_MESH_MODEL_OP_GEN_MOVE_SET
#define ESP_BLE_MESH_MODEL_OP_GEN_MOVE_SET_UNACK BT_MESH_MODEL_OP_GEN_MOVE_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_GEN_LEVEL_GET BLE_MESH_MODEL_OP_GEN_LEVEL_GET
#define ESP_BLE_MESH_MODEL_OP_GEN_LEVEL_SET BLE_MESH_MODEL_OP_GEN_LEVEL_SET
#define ESP_BLE_MESH_MODEL_OP_GEN_LEVEL_SET_UNACK BLE_MESH_MODEL_OP_GEN_LEVEL_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_GEN_LEVEL_STATUS BLE_MESH_MODEL_OP_GEN_LEVEL_STATUS
#define ESP_BLE_MESH_MODEL_OP_GEN_DELTA_SET BLE_MESH_MODEL_OP_GEN_DELTA_SET
#define ESP_BLE_MESH_MODEL_OP_GEN_DELTA_SET_UNACK BLE_MESH_MODEL_OP_GEN_DELTA_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_GEN_MOVE_SET BLE_MESH_MODEL_OP_GEN_MOVE_SET
#define ESP_BLE_MESH_MODEL_OP_GEN_MOVE_SET_UNACK BLE_MESH_MODEL_OP_GEN_MOVE_SET_UNACK
/*!< Generic Default Transition Time Message Opcode */
#define ESP_BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_GET BT_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_GET
#define ESP_BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_SET BT_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_SET
#define ESP_BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_SET_UNACK BT_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_STATUS BT_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_STATUS
#define ESP_BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_GET BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_GET
#define ESP_BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_SET BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_SET
#define ESP_BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_SET_UNACK BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_STATUS BLE_MESH_MODEL_OP_GEN_DEF_TRANS_TIME_STATUS
/*!< Generic Power OnOff Message Opcode */
#define ESP_BLE_MESH_MODEL_OP_GEN_ONPOWERUP_GET BT_MESH_MODEL_OP_GEN_ONPOWERUP_GET
#define ESP_BLE_MESH_MODEL_OP_GEN_ONPOWERUP_STATUS BT_MESH_MODEL_OP_GEN_ONPOWERUP_STATUS
#define ESP_BLE_MESH_MODEL_OP_GEN_ONPOWERUP_GET BLE_MESH_MODEL_OP_GEN_ONPOWERUP_GET
#define ESP_BLE_MESH_MODEL_OP_GEN_ONPOWERUP_STATUS BLE_MESH_MODEL_OP_GEN_ONPOWERUP_STATUS
/*!< Generic Power OnOff Setup Message Opcode */
#define ESP_BLE_MESH_MODEL_OP_GEN_ONPOWERUP_SET BT_MESH_MODEL_OP_GEN_ONPOWERUP_SET
#define ESP_BLE_MESH_MODEL_OP_GEN_ONPOWERUP_SET_UNACK BT_MESH_MODEL_OP_GEN_ONPOWERUP_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_GEN_ONPOWERUP_SET BLE_MESH_MODEL_OP_GEN_ONPOWERUP_SET
#define ESP_BLE_MESH_MODEL_OP_GEN_ONPOWERUP_SET_UNACK BLE_MESH_MODEL_OP_GEN_ONPOWERUP_SET_UNACK
/*!< Generic Power Level Message Opcode */
#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_GET BT_MESH_MODEL_OP_GEN_POWER_LEVEL_GET
#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_SET BT_MESH_MODEL_OP_GEN_POWER_LEVEL_SET
#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_SET_UNACK BT_MESH_MODEL_OP_GEN_POWER_LEVEL_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_STATUS BT_MESH_MODEL_OP_GEN_POWER_LEVEL_STATUS
#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_LAST_GET BT_MESH_MODEL_OP_GEN_POWER_LAST_GET
#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_LAST_STATUS BT_MESH_MODEL_OP_GEN_POWER_LAST_STATUS
#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_GET BT_MESH_MODEL_OP_GEN_POWER_DEFAULT_GET
#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_STATUS BT_MESH_MODEL_OP_GEN_POWER_DEFAULT_STATUS
#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_RANGE_GET BT_MESH_MODEL_OP_GEN_POWER_RANGE_GET
#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_RANGE_STATUS BT_MESH_MODEL_OP_GEN_POWER_RANGE_STATUS
#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_GET BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_GET
#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_SET BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_SET
#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_SET_UNACK BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_STATUS BLE_MESH_MODEL_OP_GEN_POWER_LEVEL_STATUS
#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_LAST_GET BLE_MESH_MODEL_OP_GEN_POWER_LAST_GET
#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_LAST_STATUS BLE_MESH_MODEL_OP_GEN_POWER_LAST_STATUS
#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_GET BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_GET
#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_STATUS BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_STATUS
#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_RANGE_GET BLE_MESH_MODEL_OP_GEN_POWER_RANGE_GET
#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_RANGE_STATUS BLE_MESH_MODEL_OP_GEN_POWER_RANGE_STATUS
/*!< Generic Power Level Setup Message Opcode */
#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_SET BT_MESH_MODEL_OP_GEN_POWER_DEFAULT_SET
#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_SET_UNACK BT_MESH_MODEL_OP_GEN_POWER_DEFAULT_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_RANGE_SET BT_MESH_MODEL_OP_GEN_POWER_RANGE_SET
#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_RANGE_SET_UNACK BT_MESH_MODEL_OP_GEN_POWER_RANGE_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_SET BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_SET
#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_SET_UNACK BLE_MESH_MODEL_OP_GEN_POWER_DEFAULT_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_RANGE_SET BLE_MESH_MODEL_OP_GEN_POWER_RANGE_SET
#define ESP_BLE_MESH_MODEL_OP_GEN_POWER_RANGE_SET_UNACK BLE_MESH_MODEL_OP_GEN_POWER_RANGE_SET_UNACK
/*!< Generic Battery Message Opcode */
#define ESP_BLE_MESH_MODEL_OP_GEN_BATTERY_GET BT_MESH_MODEL_OP_GEN_BATTERY_GET
#define ESP_BLE_MESH_MODEL_OP_GEN_BATTERY_STATUS BT_MESH_MODEL_OP_GEN_BATTERY_STATUS
#define ESP_BLE_MESH_MODEL_OP_GEN_BATTERY_GET BLE_MESH_MODEL_OP_GEN_BATTERY_GET
#define ESP_BLE_MESH_MODEL_OP_GEN_BATTERY_STATUS BLE_MESH_MODEL_OP_GEN_BATTERY_STATUS
/*!< Generic Location Message Opcode */
#define ESP_BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_GET BT_MESH_MODEL_OP_GEN_LOC_GLOBAL_GET
#define ESP_BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_STATUS BT_MESH_MODEL_OP_GEN_LOC_GLOBAL_STATUS
#define ESP_BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_GET BT_MESH_MODEL_OP_GEN_LOC_LOCAL_GET
#define ESP_BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_STATUS BT_MESH_MODEL_OP_GEN_LOC_LOCAL_STATUS
#define ESP_BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_GET BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_GET
#define ESP_BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_STATUS BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_STATUS
#define ESP_BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_GET BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_GET
#define ESP_BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_STATUS BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_STATUS
/*!< Generic Location Setup Message Opcode */
#define ESP_BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_SET BT_MESH_MODEL_OP_GEN_LOC_GLOBAL_SET
#define ESP_BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_SET_UNACK BT_MESH_MODEL_OP_GEN_LOC_GLOBAL_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_SET BT_MESH_MODEL_OP_GEN_LOC_LOCAL_SET
#define ESP_BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_SET_UNACK BT_MESH_MODEL_OP_GEN_LOC_LOCAL_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_SET BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_SET
#define ESP_BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_SET_UNACK BLE_MESH_MODEL_OP_GEN_LOC_GLOBAL_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_SET BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_SET
#define ESP_BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_SET_UNACK BLE_MESH_MODEL_OP_GEN_LOC_LOCAL_SET_UNACK
/*!< Generic Manufacturer Property Message Opcode */
#define ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTIES_GET BT_MESH_MODEL_OP_GEN_MANU_PROPERTIES_GET
#define ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTIES_STATUS BT_MESH_MODEL_OP_GEN_MANU_PROPERTIES_STATUS
#define ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTY_GET BT_MESH_MODEL_OP_GEN_MANU_PROPERTY_GET
#define ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTY_SET BT_MESH_MODEL_OP_GEN_MANU_PROPERTY_SET
#define ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTY_SET_UNACK BT_MESH_MODEL_OP_GEN_MANU_PROPERTY_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTY_STATUS BT_MESH_MODEL_OP_GEN_MANU_PROPERTY_STATUS
#define ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTIES_GET BLE_MESH_MODEL_OP_GEN_MANU_PROPERTIES_GET
#define ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTIES_STATUS BLE_MESH_MODEL_OP_GEN_MANU_PROPERTIES_STATUS
#define ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTY_GET BLE_MESH_MODEL_OP_GEN_MANU_PROPERTY_GET
#define ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTY_SET BLE_MESH_MODEL_OP_GEN_MANU_PROPERTY_SET
#define ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTY_SET_UNACK BLE_MESH_MODEL_OP_GEN_MANU_PROPERTY_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTY_STATUS BLE_MESH_MODEL_OP_GEN_MANU_PROPERTY_STATUS
/*!< Generic Admin Property Message Opcode */
#define ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTIES_GET BT_MESH_MODEL_OP_GEN_ADMIN_PROPERTIES_GET
#define ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTIES_STATUS BT_MESH_MODEL_OP_GEN_ADMIN_PROPERTIES_STATUS
#define ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_GET BT_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_GET
#define ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET BT_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET
#define ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET_UNACK BT_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_STATUS BT_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_STATUS
#define ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTIES_GET BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTIES_GET
#define ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTIES_STATUS BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTIES_STATUS
#define ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_GET BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_GET
#define ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET
#define ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET_UNACK BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_STATUS BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_STATUS
/*!< Generic User Property Message Opcode */
#define ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_GET BT_MESH_MODEL_OP_GEN_USER_PROPERTIES_GET
#define ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_STATUS BT_MESH_MODEL_OP_GEN_USER_PROPERTIES_STATUS
#define ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_GET BT_MESH_MODEL_OP_GEN_USER_PROPERTY_GET
#define ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET BT_MESH_MODEL_OP_GEN_USER_PROPERTY_SET
#define ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET_UNACK BT_MESH_MODEL_OP_GEN_USER_PROPERTY_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_STATUS BT_MESH_MODEL_OP_GEN_USER_PROPERTY_STATUS
#define ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_GET BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_GET
#define ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_STATUS BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_STATUS
#define ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_GET BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_GET
#define ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET
#define ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET_UNACK BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_STATUS BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_STATUS
/*!< Generic Client Property Message Opcode */
#define ESP_BLE_MESH_MODEL_OP_GEN_CLIENT_PROPERTIES_GET BT_MESH_MODEL_OP_GEN_CLIENT_PROPERTIES_GET
#define ESP_BLE_MESH_MODEL_OP_GEN_CLIENT_PROPERTIES_STATUS BT_MESH_MODEL_OP_GEN_CLIENT_PROPERTIES_STATUS
#define ESP_BLE_MESH_MODEL_OP_GEN_CLIENT_PROPERTIES_GET BLE_MESH_MODEL_OP_GEN_CLIENT_PROPERTIES_GET
#define ESP_BLE_MESH_MODEL_OP_GEN_CLIENT_PROPERTIES_STATUS BLE_MESH_MODEL_OP_GEN_CLIENT_PROPERTIES_STATUS
typedef uint32_t esp_ble_mesh_sensor_message_opcode_t; /*!< esp_ble_mesh_sensor_message_opcode_t belongs to esp_ble_mesh_opcode_t,
this typedef is only used to locate the opcodes used by functions
esp_ble_mesh_sensor_client_get_state & esp_ble_mesh_sensor_client_set_state */
/*!< Sensor Message Opcode */
#define ESP_BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_GET BT_MESH_MODEL_OP_SENSOR_DESCRIPTOR_GET
#define ESP_BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_STATUS BT_MESH_MODEL_OP_SENSOR_DESCRIPTOR_STATUS
#define ESP_BLE_MESH_MODEL_OP_SENSOR_GET BT_MESH_MODEL_OP_SENSOR_GET
#define ESP_BLE_MESH_MODEL_OP_SENSOR_STATUS BT_MESH_MODEL_OP_SENSOR_STATUS
#define ESP_BLE_MESH_MODEL_OP_SENSOR_COLUMN_GET BT_MESH_MODEL_OP_SENSOR_COLUMN_GET
#define ESP_BLE_MESH_MODEL_OP_SENSOR_COLUMN_STATUS BT_MESH_MODEL_OP_SENSOR_COLUMN_STATUS
#define ESP_BLE_MESH_MODEL_OP_SENSOR_SERIES_GET BT_MESH_MODEL_OP_SENSOR_SERIES_GET
#define ESP_BLE_MESH_MODEL_OP_SENSOR_SERIES_STATUS BT_MESH_MODEL_OP_SENSOR_SERIES_STATUS
#define ESP_BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_GET BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_GET
#define ESP_BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_STATUS BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_STATUS
#define ESP_BLE_MESH_MODEL_OP_SENSOR_GET BLE_MESH_MODEL_OP_SENSOR_GET
#define ESP_BLE_MESH_MODEL_OP_SENSOR_STATUS BLE_MESH_MODEL_OP_SENSOR_STATUS
#define ESP_BLE_MESH_MODEL_OP_SENSOR_COLUMN_GET BLE_MESH_MODEL_OP_SENSOR_COLUMN_GET
#define ESP_BLE_MESH_MODEL_OP_SENSOR_COLUMN_STATUS BLE_MESH_MODEL_OP_SENSOR_COLUMN_STATUS
#define ESP_BLE_MESH_MODEL_OP_SENSOR_SERIES_GET BLE_MESH_MODEL_OP_SENSOR_SERIES_GET
#define ESP_BLE_MESH_MODEL_OP_SENSOR_SERIES_STATUS BLE_MESH_MODEL_OP_SENSOR_SERIES_STATUS
/*!< Sensor Setup Message Opcode */
#define ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_GET BT_MESH_MODEL_OP_SENSOR_CADENCE_GET
#define ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET BT_MESH_MODEL_OP_SENSOR_CADENCE_SET
#define ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET_UNACK BT_MESH_MODEL_OP_SENSOR_CADENCE_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_STATUS BT_MESH_MODEL_OP_SENSOR_CADENCE_STATUS
#define ESP_BLE_MESH_MODEL_OP_SENSOR_SETTINGS_GET BT_MESH_MODEL_OP_SENSOR_SETTINGS_GET
#define ESP_BLE_MESH_MODEL_OP_SENSOR_SETTINGS_STATUS BT_MESH_MODEL_OP_SENSOR_SETTINGS_STATUS
#define ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_GET BT_MESH_MODEL_OP_SENSOR_SETTING_GET
#define ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET BT_MESH_MODEL_OP_SENSOR_SETTING_SET
#define ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET_UNACK BT_MESH_MODEL_OP_SENSOR_SETTING_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_STATUS BT_MESH_MODEL_OP_SENSOR_SETTING_STATUS
#define ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_GET BLE_MESH_MODEL_OP_SENSOR_CADENCE_GET
#define ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET
#define ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET_UNACK BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_STATUS BLE_MESH_MODEL_OP_SENSOR_CADENCE_STATUS
#define ESP_BLE_MESH_MODEL_OP_SENSOR_SETTINGS_GET BLE_MESH_MODEL_OP_SENSOR_SETTINGS_GET
#define ESP_BLE_MESH_MODEL_OP_SENSOR_SETTINGS_STATUS BLE_MESH_MODEL_OP_SENSOR_SETTINGS_STATUS
#define ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_GET BLE_MESH_MODEL_OP_SENSOR_SETTING_GET
#define ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET BLE_MESH_MODEL_OP_SENSOR_SETTING_SET
#define ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET_UNACK BLE_MESH_MODEL_OP_SENSOR_SETTING_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_STATUS BLE_MESH_MODEL_OP_SENSOR_SETTING_STATUS
typedef uint32_t esp_ble_mesh_time_scene_message_opcode_t; /*!< esp_ble_mesh_time_scene_message_opcode_t belongs to esp_ble_mesh_opcode_t,
this typedef is only used to locate the opcodes used by functions
esp_ble_mesh_time_scene_client_get_state & esp_ble_mesh_time_scene_client_set_state */
/*!< Time Message Opcode */
#define ESP_BLE_MESH_MODEL_OP_TIME_GET BT_MESH_MODEL_OP_TIME_GET
#define ESP_BLE_MESH_MODEL_OP_TIME_SET BT_MESH_MODEL_OP_TIME_SET
#define ESP_BLE_MESH_MODEL_OP_TIME_STATUS BT_MESH_MODEL_OP_TIME_STATUS
#define ESP_BLE_MESH_MODEL_OP_TIME_ROLE_GET BT_MESH_MODEL_OP_TIME_ROLE_GET
#define ESP_BLE_MESH_MODEL_OP_TIME_ROLE_SET BT_MESH_MODEL_OP_TIME_ROLE_SET
#define ESP_BLE_MESH_MODEL_OP_TIME_ROLE_STATUS BT_MESH_MODEL_OP_TIME_ROLE_STATUS
#define ESP_BLE_MESH_MODEL_OP_TIME_ZONE_GET BT_MESH_MODEL_OP_TIME_ZONE_GET
#define ESP_BLE_MESH_MODEL_OP_TIME_ZONE_SET BT_MESH_MODEL_OP_TIME_ZONE_SET
#define ESP_BLE_MESH_MODEL_OP_TIME_ZONE_STATUS BT_MESH_MODEL_OP_TIME_ZONE_STATUS
#define ESP_BLE_MESH_MODEL_OP_TAI_UTC_DELTA_GET BT_MESH_MODEL_OP_TAI_UTC_DELTA_GET
#define ESP_BLE_MESH_MODEL_OP_TAI_UTC_DELTA_SET BT_MESH_MODEL_OP_TAI_UTC_DELTA_SET
#define ESP_BLE_MESH_MODEL_OP_TAI_UTC_DELTA_STATUS BT_MESH_MODEL_OP_TAI_UTC_DELTA_STATUS
#define ESP_BLE_MESH_MODEL_OP_TIME_GET BLE_MESH_MODEL_OP_TIME_GET
#define ESP_BLE_MESH_MODEL_OP_TIME_SET BLE_MESH_MODEL_OP_TIME_SET
#define ESP_BLE_MESH_MODEL_OP_TIME_STATUS BLE_MESH_MODEL_OP_TIME_STATUS
#define ESP_BLE_MESH_MODEL_OP_TIME_ROLE_GET BLE_MESH_MODEL_OP_TIME_ROLE_GET
#define ESP_BLE_MESH_MODEL_OP_TIME_ROLE_SET BLE_MESH_MODEL_OP_TIME_ROLE_SET
#define ESP_BLE_MESH_MODEL_OP_TIME_ROLE_STATUS BLE_MESH_MODEL_OP_TIME_ROLE_STATUS
#define ESP_BLE_MESH_MODEL_OP_TIME_ZONE_GET BLE_MESH_MODEL_OP_TIME_ZONE_GET
#define ESP_BLE_MESH_MODEL_OP_TIME_ZONE_SET BLE_MESH_MODEL_OP_TIME_ZONE_SET
#define ESP_BLE_MESH_MODEL_OP_TIME_ZONE_STATUS BLE_MESH_MODEL_OP_TIME_ZONE_STATUS
#define ESP_BLE_MESH_MODEL_OP_TAI_UTC_DELTA_GET BLE_MESH_MODEL_OP_TAI_UTC_DELTA_GET
#define ESP_BLE_MESH_MODEL_OP_TAI_UTC_DELTA_SET BLE_MESH_MODEL_OP_TAI_UTC_DELTA_SET
#define ESP_BLE_MESH_MODEL_OP_TAI_UTC_DELTA_STATUS BLE_MESH_MODEL_OP_TAI_UTC_DELTA_STATUS
/*!< Scene Message Opcode */
#define ESP_BLE_MESH_MODEL_OP_SCENE_GET BT_MESH_MODEL_OP_SCENE_GET
#define ESP_BLE_MESH_MODEL_OP_SCENE_RECALL BT_MESH_MODEL_OP_SCENE_RECALL
#define ESP_BLE_MESH_MODEL_OP_SCENE_RECALL_UNACK BT_MESH_MODEL_OP_SCENE_RECALL_UNACK
#define ESP_BLE_MESH_MODEL_OP_SCENE_STATUS BT_MESH_MODEL_OP_SCENE_STATUS
#define ESP_BLE_MESH_MODEL_OP_SCENE_REGISTER_GET BT_MESH_MODEL_OP_SCENE_REGISTER_GET
#define ESP_BLE_MESH_MODEL_OP_SCENE_REGISTER_STATUS BT_MESH_MODEL_OP_SCENE_REGISTER_STATUS
#define ESP_BLE_MESH_MODEL_OP_SCENE_GET BLE_MESH_MODEL_OP_SCENE_GET
#define ESP_BLE_MESH_MODEL_OP_SCENE_RECALL BLE_MESH_MODEL_OP_SCENE_RECALL
#define ESP_BLE_MESH_MODEL_OP_SCENE_RECALL_UNACK BLE_MESH_MODEL_OP_SCENE_RECALL_UNACK
#define ESP_BLE_MESH_MODEL_OP_SCENE_STATUS BLE_MESH_MODEL_OP_SCENE_STATUS
#define ESP_BLE_MESH_MODEL_OP_SCENE_REGISTER_GET BLE_MESH_MODEL_OP_SCENE_REGISTER_GET
#define ESP_BLE_MESH_MODEL_OP_SCENE_REGISTER_STATUS BLE_MESH_MODEL_OP_SCENE_REGISTER_STATUS
/*!< Scene Setup Message Opcode */
#define ESP_BLE_MESH_MODEL_OP_SCENE_STORE BT_MESH_MODEL_OP_SCENE_STORE
#define ESP_BLE_MESH_MODEL_OP_SCENE_STORE_UNACK BT_MESH_MODEL_OP_SCENE_STORE_UNACK
#define ESP_BLE_MESH_MODEL_OP_SCENE_DELETE BT_MESH_MODEL_OP_SCENE_DELETE
#define ESP_BLE_MESH_MODEL_OP_SCENE_DELETE_UNACK BT_MESH_MODEL_OP_SCENE_DELETE_UNACK
#define ESP_BLE_MESH_MODEL_OP_SCENE_STORE BLE_MESH_MODEL_OP_SCENE_STORE
#define ESP_BLE_MESH_MODEL_OP_SCENE_STORE_UNACK BLE_MESH_MODEL_OP_SCENE_STORE_UNACK
#define ESP_BLE_MESH_MODEL_OP_SCENE_DELETE BLE_MESH_MODEL_OP_SCENE_DELETE
#define ESP_BLE_MESH_MODEL_OP_SCENE_DELETE_UNACK BLE_MESH_MODEL_OP_SCENE_DELETE_UNACK
/*!< Scheduler Message Opcode */
#define ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_GET BT_MESH_MODEL_OP_SCHEDULER_ACT_GET
#define ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_STATUS BT_MESH_MODEL_OP_SCHEDULER_ACT_STATUS
#define ESP_BLE_MESH_MODEL_OP_SCHEDULER_GET BT_MESH_MODEL_OP_SCHEDULER_GET
#define ESP_BLE_MESH_MODEL_OP_SCHEDULER_STATUS BT_MESH_MODEL_OP_SCHEDULER_STATUS
#define ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_GET BLE_MESH_MODEL_OP_SCHEDULER_ACT_GET
#define ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_STATUS BLE_MESH_MODEL_OP_SCHEDULER_ACT_STATUS
#define ESP_BLE_MESH_MODEL_OP_SCHEDULER_GET BLE_MESH_MODEL_OP_SCHEDULER_GET
#define ESP_BLE_MESH_MODEL_OP_SCHEDULER_STATUS BLE_MESH_MODEL_OP_SCHEDULER_STATUS
/*!< Scheduler Setup Message Opcode */
#define ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_SET BT_MESH_MODEL_OP_SCHEDULER_ACT_SET
#define ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_SET_UNACK BT_MESH_MODEL_OP_SCHEDULER_ACT_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_SET BLE_MESH_MODEL_OP_SCHEDULER_ACT_SET
#define ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_SET_UNACK BLE_MESH_MODEL_OP_SCHEDULER_ACT_SET_UNACK
typedef uint32_t esp_ble_mesh_light_message_opcode_t; /*!< esp_ble_mesh_light_message_opcode_t belongs to esp_ble_mesh_opcode_t,
this typedef is only used to locate the opcodes used by functions
esp_ble_mesh_light_client_get_state & esp_ble_mesh_light_client_set_state */
/*!< Light Lightness Message Opcode */
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_GET BT_MESH_MODEL_OP_LIGHT_LIGHTNESS_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_SET BT_MESH_MODEL_OP_LIGHT_LIGHTNESS_SET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_SET_UNACK BT_MESH_MODEL_OP_LIGHT_LIGHTNESS_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_STATUS BT_MESH_MODEL_OP_LIGHT_LIGHTNESS_STATUS
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_GET BT_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_SET BT_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_SET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_SET_UNACK BT_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_STATUS BT_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_STATUS
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LAST_GET BT_MESH_MODEL_OP_LIGHT_LIGHTNESS_LAST_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LAST_STATUS BT_MESH_MODEL_OP_LIGHT_LIGHTNESS_LAST_STATUS
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_GET BT_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_STATUS BT_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_STATUS
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_GET BT_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_STATUS BT_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_STATUS
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_GET BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_SET BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_SET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_SET_UNACK BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_STATUS BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_STATUS
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_GET BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_SET BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_SET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_SET_UNACK BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_STATUS BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LINEAR_STATUS
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LAST_GET BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LAST_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LAST_STATUS BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_LAST_STATUS
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_GET BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_STATUS BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_STATUS
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_GET BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_STATUS BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_STATUS
/*!< Light Lightness Setup Message Opcode */
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_SET BT_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_SET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_SET_UNACK BT_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_SET BT_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_SET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_SET_UNACK BT_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_SET BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_SET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_SET_UNACK BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_DEFAULT_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_SET BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_SET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_SET_UNACK BLE_MESH_MODEL_OP_LIGHT_LIGHTNESS_RANGE_SET_UNACK
/*!< Light CTL Message Opcode */
#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_GET BT_MESH_MODEL_OP_LIGHT_CTL_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_SET BT_MESH_MODEL_OP_LIGHT_CTL_SET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_SET_UNACK BT_MESH_MODEL_OP_LIGHT_CTL_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_STATUS BT_MESH_MODEL_OP_LIGHT_CTL_STATUS
#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_GET BT_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_GET BT_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_STATUS BT_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_STATUS
#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_SET BT_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_SET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_SET_UNACK BT_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_STATUS BT_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_STATUS
#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_GET BT_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_STATUS BT_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_STATUS
#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_GET BLE_MESH_MODEL_OP_LIGHT_CTL_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_SET BLE_MESH_MODEL_OP_LIGHT_CTL_SET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_SET_UNACK BLE_MESH_MODEL_OP_LIGHT_CTL_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_STATUS BLE_MESH_MODEL_OP_LIGHT_CTL_STATUS
#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_GET BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_GET BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_STATUS BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_STATUS
#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_SET BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_SET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_SET_UNACK BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_STATUS BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_STATUS
#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_GET BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_STATUS BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_STATUS
/*!< Light CTL Setup Message Opcode */
#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_SET BT_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_SET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_SET_UNACK BT_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_SET BT_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_SET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_SET_UNACK BT_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_SET BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_SET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_SET_UNACK BLE_MESH_MODEL_OP_LIGHT_CTL_DEFAULT_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_SET BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_SET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_SET_UNACK BLE_MESH_MODEL_OP_LIGHT_CTL_TEMPERATURE_RANGE_SET_UNACK
/*!< Light HSL Message Opcode */
#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_GET BT_MESH_MODEL_OP_LIGHT_HSL_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_GET BT_MESH_MODEL_OP_LIGHT_HSL_HUE_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_SET BT_MESH_MODEL_OP_LIGHT_HSL_HUE_SET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_SET_UNACK BT_MESH_MODEL_OP_LIGHT_HSL_HUE_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_STATUS BT_MESH_MODEL_OP_LIGHT_HSL_HUE_STATUS
#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_GET BT_MESH_MODEL_OP_LIGHT_HSL_SATURATION_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_SET BT_MESH_MODEL_OP_LIGHT_HSL_SATURATION_SET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_SET_UNACK BT_MESH_MODEL_OP_LIGHT_HSL_SATURATION_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_STATUS BT_MESH_MODEL_OP_LIGHT_HSL_SATURATION_STATUS
#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SET BT_MESH_MODEL_OP_LIGHT_HSL_SET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SET_UNACK BT_MESH_MODEL_OP_LIGHT_HSL_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_STATUS BT_MESH_MODEL_OP_LIGHT_HSL_STATUS
#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_TARGET_GET BT_MESH_MODEL_OP_LIGHT_HSL_TARGET_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_TARGET_STATUS BT_MESH_MODEL_OP_LIGHT_HSL_TARGET_STATUS
#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_GET BT_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_STATUS BT_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_STATUS
#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_GET BT_MESH_MODEL_OP_LIGHT_HSL_RANGE_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_STATUS BT_MESH_MODEL_OP_LIGHT_HSL_RANGE_STATUS
#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_GET BLE_MESH_MODEL_OP_LIGHT_HSL_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_GET BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_SET BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_SET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_SET_UNACK BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_STATUS BLE_MESH_MODEL_OP_LIGHT_HSL_HUE_STATUS
#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_GET BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_SET BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_SET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_SET_UNACK BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_STATUS BLE_MESH_MODEL_OP_LIGHT_HSL_SATURATION_STATUS
#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SET BLE_MESH_MODEL_OP_LIGHT_HSL_SET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_SET_UNACK BLE_MESH_MODEL_OP_LIGHT_HSL_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_STATUS BLE_MESH_MODEL_OP_LIGHT_HSL_STATUS
#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_TARGET_GET BLE_MESH_MODEL_OP_LIGHT_HSL_TARGET_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_TARGET_STATUS BLE_MESH_MODEL_OP_LIGHT_HSL_TARGET_STATUS
#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_GET BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_STATUS BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_STATUS
#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_GET BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_STATUS BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_STATUS
/*!< Light HSL Setup Message Opcode */
#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_SET BT_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_SET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_SET_UNACK BT_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_SET BT_MESH_MODEL_OP_LIGHT_HSL_RANGE_SET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_SET_UNACK BT_MESH_MODEL_OP_LIGHT_HSL_RANGE_SET_UNACK /* Model spec is wrong */
#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_SET BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_SET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_SET_UNACK BLE_MESH_MODEL_OP_LIGHT_HSL_DEFAULT_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_SET BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_SET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_SET_UNACK BLE_MESH_MODEL_OP_LIGHT_HSL_RANGE_SET_UNACK /* Model spec is wrong */
/*!< Light xyL Message Opcode */
#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_GET BT_MESH_MODEL_OP_LIGHT_XYL_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_SET BT_MESH_MODEL_OP_LIGHT_XYL_SET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_SET_UNACK BT_MESH_MODEL_OP_LIGHT_XYL_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_STATUS BT_MESH_MODEL_OP_LIGHT_XYL_STATUS
#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_TARGET_GET BT_MESH_MODEL_OP_LIGHT_XYL_TARGET_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_TARGET_STATUS BT_MESH_MODEL_OP_LIGHT_XYL_TARGET_STATUS
#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_GET BT_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_STATUS BT_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_STATUS
#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_GET BT_MESH_MODEL_OP_LIGHT_XYL_RANGE_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_STATUS BT_MESH_MODEL_OP_LIGHT_XYL_RANGE_STATUS
#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_GET BLE_MESH_MODEL_OP_LIGHT_XYL_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_SET BLE_MESH_MODEL_OP_LIGHT_XYL_SET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_SET_UNACK BLE_MESH_MODEL_OP_LIGHT_XYL_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_STATUS BLE_MESH_MODEL_OP_LIGHT_XYL_STATUS
#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_TARGET_GET BLE_MESH_MODEL_OP_LIGHT_XYL_TARGET_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_TARGET_STATUS BLE_MESH_MODEL_OP_LIGHT_XYL_TARGET_STATUS
#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_GET BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_STATUS BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_STATUS
#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_GET BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_STATUS BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_STATUS
/*!< Light xyL Setup Message Opcode */
#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_SET BT_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_SET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_SET_UNACK BT_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_SET BT_MESH_MODEL_OP_LIGHT_XYL_RANGE_SET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_SET_UNACK BT_MESH_MODEL_OP_LIGHT_XYL_RANGE_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_SET BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_SET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_SET_UNACK BLE_MESH_MODEL_OP_LIGHT_XYL_DEFAULT_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_SET BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_SET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_SET_UNACK BLE_MESH_MODEL_OP_LIGHT_XYL_RANGE_SET_UNACK
/*!< Light Control Message Opcode */
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_MODE_GET BT_MESH_MODEL_OP_LIGHT_LC_MODE_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_MODE_SET BT_MESH_MODEL_OP_LIGHT_LC_MODE_SET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_MODE_SET_UNACK BT_MESH_MODEL_OP_LIGHT_LC_MODE_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_MODE_STATUS BT_MESH_MODEL_OP_LIGHT_LC_MODE_STATUS
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_OM_GET BT_MESH_MODEL_OP_LIGHT_LC_OM_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_OM_SET BT_MESH_MODEL_OP_LIGHT_LC_OM_SET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_OM_SET_UNACK BT_MESH_MODEL_OP_LIGHT_LC_OM_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_OM_STATUS BT_MESH_MODEL_OP_LIGHT_LC_OM_STATUS
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_GET BT_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_SET BT_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_SET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_SET_UNACK BT_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_STATUS BT_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_STATUS
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_GET BT_MESH_MODEL_OP_LIGHT_LC_PROPERTY_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET BT_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET_UNACK BT_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_STATUS BT_MESH_MODEL_OP_LIGHT_LC_PROPERTY_STATUS
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_MODE_GET BLE_MESH_MODEL_OP_LIGHT_LC_MODE_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_MODE_SET BLE_MESH_MODEL_OP_LIGHT_LC_MODE_SET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_MODE_SET_UNACK BLE_MESH_MODEL_OP_LIGHT_LC_MODE_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_MODE_STATUS BLE_MESH_MODEL_OP_LIGHT_LC_MODE_STATUS
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_OM_GET BLE_MESH_MODEL_OP_LIGHT_LC_OM_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_OM_SET BLE_MESH_MODEL_OP_LIGHT_LC_OM_SET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_OM_SET_UNACK BLE_MESH_MODEL_OP_LIGHT_LC_OM_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_OM_STATUS BLE_MESH_MODEL_OP_LIGHT_LC_OM_STATUS
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_GET BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_SET BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_SET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_SET_UNACK BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_STATUS BLE_MESH_MODEL_OP_LIGHT_LC_LIGHT_ONOFF_STATUS
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_GET BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_GET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET_UNACK BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET_UNACK
#define ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_STATUS BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_STATUS
typedef uint32_t esp_ble_mesh_opcode_t;
/*!< End of defines of esp_ble_mesh_opcode_t */
@@ -611,7 +612,7 @@ typedef uint8_t esp_ble_mesh_model_status_t; /*!< This typedef is only used t
* @return BLE Mesh transmit value that can be used e.g. for the default
* values of the Configuration Model data.
*/
#define ESP_BLE_MESH_TRANSMIT(count, int_ms) BT_MESH_TRANSMIT(count, int_ms)
#define ESP_BLE_MESH_TRANSMIT(count, int_ms) BLE_MESH_TRANSMIT(count, int_ms)
/** @def ESP_BLE_MESH_GET_TRANSMIT_COUNT
*
@@ -621,7 +622,7 @@ typedef uint8_t esp_ble_mesh_model_status_t; /*!< This typedef is only used t
*
* @return Transmission count (actual transmissions equal to N + 1).
*/
#define ESP_BLE_MESH_GET_TRANSMIT_COUNT(transmit) BT_MESH_TRANSMIT_COUNT(transmit)
#define ESP_BLE_MESH_GET_TRANSMIT_COUNT(transmit) BLE_MESH_TRANSMIT_COUNT(transmit)
/** @def ESP_BLE_MESH_GET_TRANSMIT_INTERVAL
*
@@ -631,7 +632,7 @@ typedef uint8_t esp_ble_mesh_model_status_t; /*!< This typedef is only used t
*
* @return Transmission interval in milliseconds.
*/
#define ESP_BLE_MESH_GET_TRANSMIT_INTERVAL(transmit) BT_MESH_TRANSMIT_INT(transmit)
#define ESP_BLE_MESH_GET_TRANSMIT_INTERVAL(transmit) BLE_MESH_TRANSMIT_INT(transmit)
/** @def ESP_BLE_MESH_PUBLISH_TRANSMIT
*
@@ -644,7 +645,7 @@ typedef uint8_t esp_ble_mesh_model_status_t; /*!< This typedef is only used t
* @return BLE Mesh transmit value that can be used e.g. for the default
* values of the Configuration Model data.
*/
#define ESP_BLE_MESH_PUBLISH_TRANSMIT(count, int_ms) BT_MESH_PUB_TRANSMIT(count, int_ms)
#define ESP_BLE_MESH_PUBLISH_TRANSMIT(count, int_ms) BLE_MESH_PUB_TRANSMIT(count, int_ms)
/** @def ESP_BLE_MESH_GET_PUBLISH_TRANSMIT_COUNT
*
@@ -654,7 +655,7 @@ typedef uint8_t esp_ble_mesh_model_status_t; /*!< This typedef is only used t
*
* @return Retransmission count (actual transmissions equal to N + 1).
*/
#define ESP_BLE_MESH_GET_PUBLISH_TRANSMIT_COUNT(transmit) BT_MESH_PUB_TRANSMIT_COUNT(transmit)
#define ESP_BLE_MESH_GET_PUBLISH_TRANSMIT_COUNT(transmit) BLE_MESH_PUB_TRANSMIT_COUNT(transmit)
/** @def ESP_BLE_MESH_GET_PUBLISH_TRANSMIT_INTERVAL
*
@@ -664,7 +665,7 @@ typedef uint8_t esp_ble_mesh_model_status_t; /*!< This typedef is only used t
*
* @return Transmission interval in milliseconds.
*/
#define ESP_BLE_MESH_GET_PUBLISH_TRANSMIT_INTERVAL(transmit) BT_MESH_PUB_TRANSMIT_INT(transmit)
#define ESP_BLE_MESH_GET_PUBLISH_TRANSMIT_INTERVAL(transmit) BLE_MESH_PUB_TRANSMIT_INT(transmit)
/* esp_ble_mesh_cb_t is not needed to be initialized by users (set with 0 and will be initialized internally) */
typedef uint32_t esp_ble_mesh_cb_t;
@@ -713,35 +714,35 @@ typedef enum {
ESP_BLE_MESH_PROV_GATT = BIT(1),
} esp_ble_mesh_prov_bearer_t;
#define ESP_BLE_MESH_MODEL_OP_1(b0) BT_MESH_MODEL_OP_1(b0)
#define ESP_BLE_MESH_MODEL_OP_2(b0, b1) BT_MESH_MODEL_OP_2(b0, b1)
#define ESP_BLE_MESH_MODEL_OP_3(b0, cid) BT_MESH_MODEL_OP_3(b0, cid)
#define ESP_BLE_MESH_MODEL_OP_1(b0) BLE_MESH_MODEL_OP_1(b0)
#define ESP_BLE_MESH_MODEL_OP_2(b0, b1) BLE_MESH_MODEL_OP_2(b0, b1)
#define ESP_BLE_MESH_MODEL_OP_3(b0, cid) BLE_MESH_MODEL_OP_3(b0, cid)
/*!< This macro is associated with BT_MESH_MODEL in mesh_access.h */
#define ESP_BLE_MESH_SIG_MODEL(_id, _op, _pub, _user_data) \
{ \
.model_id = (_id), \
.op = _op, \
.keys = { [0 ... (CONFIG_BT_MESH_MODEL_KEY_COUNT - 1)] = \
ESP_BLE_MESH_KEY_UNUSED }, \
.pub = _pub, \
.groups = { [0 ... (CONFIG_BT_MESH_MODEL_GROUP_COUNT - 1)] = \
ESP_BLE_MESH_ADDR_UNASSIGNED }, \
.user_data = _user_data, \
/*!< This macro is associated with BLE_MESH_MODEL in mesh_access.h */
#define ESP_BLE_MESH_SIG_MODEL(_id, _op, _pub, _user_data) \
{ \
.model_id = (_id), \
.op = _op, \
.keys = { [0 ... (CONFIG_BLE_MESH_MODEL_KEY_COUNT - 1)] = \
ESP_BLE_MESH_KEY_UNUSED }, \
.pub = _pub, \
.groups = { [0 ... (CONFIG_BLE_MESH_MODEL_GROUP_COUNT - 1)] = \
ESP_BLE_MESH_ADDR_UNASSIGNED }, \
.user_data = _user_data, \
}
/*!< This macro is associated with BT_MESH_MODEL_VND in mesh_access.h */
#define ESP_BLE_MESH_VENDOR_MODEL(_company, _id, _op, _pub, _user_data) \
{ \
.vnd.company_id = (_company), \
.vnd.model_id = (_id), \
.op = _op, \
.pub = _pub, \
.keys = { [0 ... (CONFIG_BT_MESH_MODEL_KEY_COUNT - 1)] = \
ESP_BLE_MESH_KEY_UNUSED }, \
.groups = { [0 ... (CONFIG_BT_MESH_MODEL_GROUP_COUNT - 1)] = \
ESP_BLE_MESH_ADDR_UNASSIGNED }, \
.user_data = _user_data, \
/*!< This macro is associated with BLE_MESH_MODEL_VND in mesh_access.h */
#define ESP_BLE_MESH_VENDOR_MODEL(_company, _id, _op, _pub, _user_data) \
{ \
.vnd.company_id = (_company), \
.vnd.model_id = (_id), \
.op = _op, \
.pub = _pub, \
.keys = { [0 ... (CONFIG_BLE_MESH_MODEL_KEY_COUNT - 1)] = \
ESP_BLE_MESH_KEY_UNUSED }, \
.groups = { [0 ... (CONFIG_BLE_MESH_MODEL_GROUP_COUNT - 1)] = \
ESP_BLE_MESH_ADDR_UNASSIGNED }, \
.user_data = _user_data, \
}
/** @brief Helper to define a BLE Mesh element within an array.
@@ -749,7 +750,7 @@ typedef enum {
* In case the element has no SIG or Vendor models, the helper
* macro ESP_BLE_MESH_MODEL_NONE can be given instead.
*
* @note This macro is associated with BT_MESH_ELEM in mesh_access.h
* @note This macro is associated with BLE_MESH_ELEM in mesh_access.h
*
* @param _loc Location Descriptor.
* @param _mods Array of SIG models.
@@ -864,10 +865,10 @@ struct esp_ble_mesh_model {
esp_ble_mesh_model_pub_t *const pub;
/* AppKey List */
uint16_t keys[CONFIG_BT_MESH_MODEL_KEY_COUNT];
uint16_t keys[CONFIG_BLE_MESH_MODEL_KEY_COUNT];
/* Subscription List (group or virtual addresses) */
uint16_t groups[CONFIG_BT_MESH_MODEL_GROUP_COUNT];
uint16_t groups[CONFIG_BLE_MESH_MODEL_GROUP_COUNT];
/* Model operation context */
esp_ble_mesh_model_op_t *op;
@@ -882,7 +883,7 @@ struct esp_ble_mesh_model {
};
/** Helper to define an empty model array.
* This structure is associated with BT_MESH_MODEL_NONE in mesh_access.h
* This structure is associated with BLE_MESH_MODEL_NONE in mesh_access.h
*/
#define ESP_BLE_MESH_MODEL_NONE ((esp_ble_mesh_model_t []){})
@@ -905,7 +906,7 @@ typedef struct {
/** Force sending reliably by using segment acknowledgement */
uint8_t send_rel: 1;
/** TTL, or BT_MESH_TTL_DEFAULT for default TTL. */
/** TTL, or BLE_MESH_TTL_DEFAULT for default TTL. */
uint8_t send_ttl;
/** Opcode of a received message. Not used for sending message. */
@@ -925,7 +926,7 @@ typedef struct {
* This structure is associated with bt_mesh_prov in mesh_access.h
*/
typedef struct {
#if CONFIG_BT_MESH_NODE
#if CONFIG_BLE_MESH_NODE
/** The UUID that is used when advertising as an unprovisioned device */
const uint8_t *uuid;
@@ -958,8 +959,8 @@ typedef struct {
esp_ble_mesh_cb_t link_close_cb;
esp_ble_mesh_cb_t complete_cb;
esp_ble_mesh_cb_t reset_cb;
#endif /* CONFIG_BT_MESH_NODE */
#ifdef CONFIG_BT_MESH_PROVISIONER
#endif /* CONFIG_BLE_MESH_NODE */
#ifdef CONFIG_BLE_MESH_PROVISIONER
/* Provisioner device UUID */
const uint8_t *prov_uuid;
@@ -1000,7 +1001,7 @@ typedef struct {
esp_ble_mesh_cb_t provisioner_link_open;
esp_ble_mesh_cb_t provisioner_link_close;
esp_ble_mesh_cb_t provisioner_prov_comp;
#endif /* CONFIG_BT_MESH_PROVISIONER */
#endif /* CONFIG_BLE_MESH_PROVISIONER */
} esp_ble_mesh_prov_t;
/** Node Composition
@@ -1106,7 +1107,7 @@ typedef enum {
ESP_BLE_MESH_NODE_PROXY_IDENTITY_ENABLE_COMP_EVT, /*!< Enable BLE Mesh Proxy Identity advertising completion event */
ESP_BLE_MESH_NODE_PROXY_GATT_ENABLE_COMP_EVT, /*!< Enable BLE Mesh GATT Proxy Service completion event */
ESP_BLE_MESH_NODE_PROXY_GATT_DISABLE_COMP_EVT, /*!< Disable BLE Mesh GATT Proxy Service completion event */
#if (CONFIG_BT_MESH_PROVISIONER)
#if (CONFIG_BLE_MESH_PROVISIONER)
ESP_BLE_MESH_PROVISIONER_PROV_ENABLE_COMP_EVT, /*!< Provisioner enable provisioning functionality completion event */
ESP_BLE_MESH_PROVISIONER_PROV_DISABLE_COMP_EVT, /*!< Provisioner disable provisioning functionality completion event */
ESP_BLE_MESH_PROVISIONER_RECV_UNPROV_ADV_PKT_EVT, /*!< Provisioner receives unprovisioned device beacon event */
@@ -1127,7 +1128,7 @@ typedef enum {
ESP_BLE_MESH_PROVISIONER_ADD_LOCAL_APP_KEY_COMP_EVT, /*!< Provisioner add local app key completion event */
ESP_BLE_MESH_PROVISIONER_BIND_APP_KEY_TO_MODEL_COMP_EVT, /*!< Provisioner bind local model with local app key completion event */
ESP_BLE_MESH_PROVISIONER_ADD_LOCAL_NET_KEY_COMP_EVT, /*!< Provisioner add local network key completion event */
#endif /* CONFIG_BT_MESH_PROVISIONER */
#endif /* CONFIG_BLE_MESH_PROVISIONER */
ESP_BLE_MESH_SET_FAST_PROV_INFO_COMP_EVT, /* !< Set fast provisioning information (e.g. unicast address range, net_idx, etc.) completion event */
ESP_BLE_MESH_SET_FAST_PROV_ACTION_COMP_EVT, /* !< Set fast provisioning action completion event */
ESP_BLE_MESH_PROV_EVT_MAX,
@@ -1251,7 +1252,7 @@ typedef union {
struct ble_mesh_proxy_gatt_disable_comp_param {
int err_code;
} node_proxy_gatt_disable_comp;
#if (CONFIG_BT_MESH_PROVISIONER)
#if (CONFIG_BLE_MESH_PROVISIONER)
/**
* @brief ESP_BLE_MESH_PROVISIONER_RECV_UNPROV_ADV_PKT_EVT
*/
@@ -1395,8 +1396,8 @@ typedef union {
int err_code;
uint16_t net_idx;
} provisioner_add_net_key_comp;
#endif /* CONFIG_BT_MESH_PROVISIONER */
#if (CONFIG_BT_MESH_FAST_PROV)
#endif /* CONFIG_BLE_MESH_PROVISIONER */
#if (CONFIG_BLE_MESH_FAST_PROV)
struct ble_mesh_set_fast_prov_info_comp_param {
uint8_t status_unicast;
uint8_t status_net_idx;
@@ -1405,7 +1406,7 @@ typedef union {
struct ble_mesh_set_fast_prov_action_comp_param {
uint8_t status_action;
} set_fast_prov_action_comp;
#endif /* CONFIG_BT_MESH_FAST_PROV */
#endif /* CONFIG_BLE_MESH_FAST_PROV */
} esp_ble_mesh_prov_cb_param_t;
typedef union {
@@ -1476,5 +1477,4 @@ typedef struct {
uint8_t msg_role; /*!< Role of the device (Node/Provisioner) that is going to send messages */
} esp_ble_mesh_client_t;
#endif /* #if CONFIG_BT_MESH */
#endif /* _ESP_BLE_MESH_DEFS_H_ */

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include <errno.h>
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
@@ -20,7 +20,7 @@
#include "esp_bt_defs.h"
#include "esp_bt_main.h"
#include "btc_ble_mesh_config_client.h"
#include "btc_ble_mesh_config_model.h"
#include "esp_ble_mesh_config_model_api.h"
esp_err_t esp_ble_mesh_register_config_client_callback(esp_ble_mesh_cfg_client_cb_t callback)
@@ -40,13 +40,13 @@ esp_err_t esp_ble_mesh_register_config_server_callback(esp_ble_mesh_cfg_server_c
esp_err_t esp_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_cfg_client_get_state_t *get_state)
{
btc_ble_mesh_cfg_client_args_t arg = {0};
btc_msg_t msg = {0};
if (!params || !params->model || !params->ctx.addr || !get_state) {
return ESP_ERR_INVALID_ARG;
}
btc_msg_t msg;
btc_ble_mesh_cfg_client_args_t arg;
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
@@ -62,13 +62,13 @@ esp_err_t esp_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param_
esp_err_t esp_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_cfg_client_set_state_t *set_state)
{
btc_ble_mesh_cfg_client_args_t arg = {0};
btc_msg_t msg = {0};
if (!params || !params->model || !params->ctx.addr || !set_state) {
return ESP_ERR_INVALID_ARG;
}
btc_msg_t msg;
btc_ble_mesh_cfg_client_args_t arg;
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include <errno.h>
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
@@ -20,7 +20,7 @@
#include "esp_bt_defs.h"
#include "esp_bt_main.h"
#include "btc_ble_mesh_generic_client.h"
#include "btc_ble_mesh_generic_model.h"
#include "esp_ble_mesh_generic_model_api.h"
esp_err_t esp_ble_mesh_register_generic_client_callback(esp_ble_mesh_generic_client_cb_t callback)
@@ -33,13 +33,13 @@ esp_err_t esp_ble_mesh_register_generic_client_callback(esp_ble_mesh_generic_cli
esp_err_t esp_ble_mesh_generic_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_generic_client_get_state_t *get_state)
{
btc_ble_mesh_generic_client_args_t arg = {0};
btc_msg_t msg = {0};
if (!params || !params->model || !params->ctx.addr || !get_state) {
return ESP_ERR_INVALID_ARG;
}
btc_msg_t msg;
btc_ble_mesh_generic_client_args_t arg;
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
@@ -55,13 +55,13 @@ esp_err_t esp_ble_mesh_generic_client_get_state(esp_ble_mesh_client_common_param
esp_err_t esp_ble_mesh_generic_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_generic_client_set_state_t *set_state)
{
btc_ble_mesh_generic_client_args_t arg = {0};
btc_msg_t msg = {0};
if (!params || !params->model || !params->ctx.addr || !set_state) {
return ESP_ERR_INVALID_ARG;
}
btc_msg_t msg;
btc_ble_mesh_generic_client_args_t arg;
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include <errno.h>
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
@@ -20,7 +20,7 @@
#include "esp_bt_defs.h"
#include "esp_bt_main.h"
#include "btc_ble_mesh_health.h"
#include "btc_ble_mesh_health_model.h"
#include "esp_ble_mesh_health_model_api.h"
esp_err_t esp_ble_mesh_register_health_client_callback(esp_ble_mesh_health_client_cb_t callback)
@@ -40,13 +40,13 @@ esp_err_t esp_ble_mesh_register_health_server_callback(esp_ble_mesh_health_serve
esp_err_t esp_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_health_client_get_state_t *get_state)
{
btc_ble_mesh_health_client_args_t arg = {0};
btc_msg_t msg = {0};
if (!params || !params->model || !params->ctx.addr || !get_state) {
return ESP_ERR_INVALID_ARG;
}
btc_msg_t msg;
btc_ble_mesh_health_client_args_t arg;
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
@@ -62,13 +62,13 @@ esp_err_t esp_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_
esp_err_t esp_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_health_client_set_state_t *set_state)
{
btc_ble_mesh_health_client_args_t arg = {0};
btc_msg_t msg = {0};
if (!params || !params->model || !params->ctx.addr || !set_state) {
return ESP_ERR_INVALID_ARG;
}
btc_msg_t msg;
btc_ble_mesh_health_client_args_t arg;
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
@@ -84,7 +84,7 @@ esp_err_t esp_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param_
esp_err_t esp_ble_mesh_health_server_fault_update(esp_ble_mesh_elem_t *element)
{
btc_ble_mesh_health_server_args_t arg = {0};
btc_msg_t msg;
btc_msg_t msg = {0};
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include <errno.h>
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
@@ -20,7 +20,7 @@
#include "esp_bt_defs.h"
#include "esp_bt_main.h"
#include "btc_ble_mesh_light_client.h"
#include "btc_ble_mesh_lighting_model.h"
#include "esp_ble_mesh_lighting_model_api.h"
esp_err_t esp_ble_mesh_register_light_client_callback(esp_ble_mesh_light_client_cb_t callback)
@@ -33,13 +33,13 @@ esp_err_t esp_ble_mesh_register_light_client_callback(esp_ble_mesh_light_client_
esp_err_t esp_ble_mesh_light_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_light_client_get_state_t *get_state)
{
btc_ble_mesh_light_client_args_t arg = {0};
btc_msg_t msg = {0};
if (!params || !params->model || !params->ctx.addr || !get_state) {
return ESP_ERR_INVALID_ARG;
}
btc_msg_t msg;
btc_ble_mesh_light_client_args_t arg;
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
@@ -55,13 +55,13 @@ esp_err_t esp_ble_mesh_light_client_get_state(esp_ble_mesh_client_common_param_t
esp_err_t esp_ble_mesh_light_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_light_client_set_state_t *set_state)
{
btc_ble_mesh_light_client_args_t arg = {0};
btc_msg_t msg = {0};
if (!params || !params->model || !params->ctx.addr || !set_state) {
return ESP_ERR_INVALID_ARG;
}
btc_msg_t msg;
btc_ble_mesh_light_client_args_t arg;
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include <errno.h>
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
@@ -20,7 +20,7 @@
#include "esp_bt_defs.h"
#include "esp_bt_main.h"
#include "btc_ble_mesh_sensor_client.h"
#include "btc_ble_mesh_sensor_model.h"
#include "esp_ble_mesh_sensor_model_api.h"
esp_err_t esp_ble_mesh_register_sensor_client_callback(esp_ble_mesh_sensor_client_cb_t callback)
@@ -33,13 +33,13 @@ esp_err_t esp_ble_mesh_register_sensor_client_callback(esp_ble_mesh_sensor_clien
esp_err_t esp_ble_mesh_sensor_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_sensor_client_get_state_t *get_state)
{
btc_ble_mesh_sensor_client_args_t arg = {0};
btc_msg_t msg = {0};
if (!params || !params->model || !params->ctx.addr || !get_state) {
return ESP_ERR_INVALID_ARG;
}
btc_msg_t msg;
btc_ble_mesh_sensor_client_args_t arg;
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
@@ -55,13 +55,13 @@ esp_err_t esp_ble_mesh_sensor_client_get_state(esp_ble_mesh_client_common_param_
esp_err_t esp_ble_mesh_sensor_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_sensor_client_set_state_t *set_state)
{
btc_ble_mesh_sensor_client_args_t arg = {0};
btc_msg_t msg = {0};
if (!params || !params->model || !params->ctx.addr || !set_state) {
return ESP_ERR_INVALID_ARG;
}
btc_msg_t msg;
btc_ble_mesh_sensor_client_args_t arg;
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include <errno.h>
#include <stdint.h>
#include "btc/btc_task.h"
#include "btc/btc_manage.h"
@@ -20,7 +20,7 @@
#include "esp_bt_defs.h"
#include "esp_bt_main.h"
#include "btc_ble_mesh_time_scene_client.h"
#include "btc_ble_mesh_time_scene_model.h"
#include "esp_ble_mesh_time_scene_model_api.h"
esp_err_t esp_ble_mesh_register_time_scene_client_callback(esp_ble_mesh_time_scene_client_cb_t callback)
@@ -33,13 +33,13 @@ esp_err_t esp_ble_mesh_register_time_scene_client_callback(esp_ble_mesh_time_sce
esp_err_t esp_ble_mesh_time_scene_client_get_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_time_scene_client_get_state_t *get_state)
{
btc_ble_mesh_time_scene_client_args_t arg = {0};
btc_msg_t msg = {0};
if (!params || !params->model || !params->ctx.addr || !get_state) {
return ESP_ERR_INVALID_ARG;
}
btc_msg_t msg;
btc_ble_mesh_time_scene_client_args_t arg;
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
@@ -55,13 +55,13 @@ esp_err_t esp_ble_mesh_time_scene_client_get_state(esp_ble_mesh_client_common_pa
esp_err_t esp_ble_mesh_time_scene_client_set_state(esp_ble_mesh_client_common_param_t *params,
esp_ble_mesh_time_scene_client_set_state_t *set_state)
{
btc_ble_mesh_time_scene_client_args_t arg = {0};
btc_msg_t msg = {0};
if (!params || !params->model || !params->ctx.addr || !set_state) {
return ESP_ERR_INVALID_ARG;
}
btc_msg_t msg;
btc_ble_mesh_time_scene_client_args_t arg;
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;

View File

@@ -19,7 +19,7 @@
#ifndef _ESP_BLE_MESH_LIGHTING_MODEL_API_H_
#define _ESP_BLE_MESH_LIGHTING_MODEL_API_H_
#include "light_client.h"
#include "lighting_client.h"
#include "esp_ble_mesh_defs.h"
/** @def ESP_BLE_MESH_MODEL_LIGHT_LIGHTNESS_CLI

View File

@@ -19,8 +19,8 @@
#include "osi/allocator.h"
#include "cfg_cli.h"
#include "common.h"
#include "btc_ble_mesh_config_client.h"
#include "mesh_common.h"
#include "btc_ble_mesh_config_model.h"
#include "esp_ble_mesh_config_model_api.h"
#define CID_NVAL 0xffff
@@ -51,7 +51,7 @@ void btc_ble_mesh_cfg_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p
btc_ble_mesh_cfg_client_args_t *src = (btc_ble_mesh_cfg_client_args_t *)p_src;
if (!msg || !dst || !src) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -65,7 +65,7 @@ void btc_ble_mesh_cfg_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p
memcpy(dst->cfg_client_get_state.get_state, src->cfg_client_get_state.get_state,
sizeof(esp_ble_mesh_cfg_client_get_state_t));
} else {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
break;
}
@@ -78,12 +78,12 @@ void btc_ble_mesh_cfg_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p
memcpy(dst->cfg_client_set_state.set_state, src->cfg_client_set_state.set_state,
sizeof(esp_ble_mesh_cfg_client_set_state_t));
} else {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
break;
}
default:
LOG_DEBUG("%s Unhandled deep copy %d", __func__, msg->act);
LOG_DEBUG("%s, Unknown deep copy act %d", __func__, msg->act);
break;
}
}
@@ -96,7 +96,7 @@ static void btc_ble_mesh_cfg_client_copy_req_data(btc_msg_t *msg, void *p_dest,
u16_t length;
if (!msg || !p_src_data || !p_dest_data) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -113,7 +113,7 @@ static void btc_ble_mesh_cfg_client_copy_req_data(btc_msg_t *msg, void *p_dest,
length = p_src_data->status_cb.comp_data_status.composition_data->len;
p_dest_data->status_cb.comp_data_status.composition_data = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.comp_data_status.composition_data) {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_init(p_dest_data->status_cb.comp_data_status.composition_data, 0);
@@ -130,7 +130,7 @@ static void btc_ble_mesh_cfg_client_copy_req_data(btc_msg_t *msg, void *p_dest,
length = p_src_data->status_cb.model_sub_list.sub_addr->len;
p_dest_data->status_cb.model_sub_list.sub_addr = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.model_sub_list.sub_addr) {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_init(p_dest_data->status_cb.model_sub_list.sub_addr, 0);
@@ -145,7 +145,7 @@ static void btc_ble_mesh_cfg_client_copy_req_data(btc_msg_t *msg, void *p_dest,
length = p_src_data->status_cb.netkey_list.net_idx->len;
p_dest_data->status_cb.netkey_list.net_idx = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.netkey_list.net_idx) {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_init(p_dest_data->status_cb.netkey_list.net_idx, 0);
@@ -160,7 +160,7 @@ static void btc_ble_mesh_cfg_client_copy_req_data(btc_msg_t *msg, void *p_dest,
length = p_src_data->status_cb.appkey_list.app_idx->len;
p_dest_data->status_cb.appkey_list.app_idx = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.appkey_list.app_idx) {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_init(p_dest_data->status_cb.appkey_list.app_idx, 0);
@@ -177,7 +177,7 @@ static void btc_ble_mesh_cfg_client_copy_req_data(btc_msg_t *msg, void *p_dest,
length = p_src_data->status_cb.model_app_list.app_idx->len;
p_dest_data->status_cb.model_app_list.app_idx = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.model_app_list.app_idx) {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_init(p_dest_data->status_cb.model_app_list.app_idx, 0);
@@ -196,7 +196,7 @@ static void btc_ble_mesh_cfg_client_copy_req_data(btc_msg_t *msg, void *p_dest,
if (p_dest_data->params) {
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
} else {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
}
break;
@@ -211,7 +211,7 @@ static void btc_ble_mesh_cfg_client_free_req_data(btc_msg_t *msg)
u32_t opcode;
if (!msg || !msg->arg) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -267,7 +267,7 @@ void btc_ble_mesh_cfg_client_arg_deep_free(btc_msg_t *msg)
btc_ble_mesh_cfg_client_args_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -317,12 +317,12 @@ void bt_mesh_callback_config_status_to_btc(u32_t opcode, u8_t evt_type,
const u8_t *val, size_t len)
{
esp_ble_mesh_cfg_client_cb_param_t cb_params = {0};
esp_ble_mesh_client_common_param_t params = {0};
esp_ble_mesh_client_common_param_t params = {0};
size_t length;
uint8_t act;
if (!model || !ctx) {
LOG_ERROR("%s: invalid parameter", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -340,7 +340,7 @@ void bt_mesh_callback_config_status_to_btc(u32_t opcode, u8_t evt_type,
act = ESP_BLE_MESH_CFG_CLIENT_TIMEOUT_EVT;
break;
default:
LOG_ERROR("%s: unknown config status event type", __func__);
LOG_ERROR("%s, Unknown config client event type %d", __func__, evt_type);
return;
}
@@ -369,7 +369,7 @@ void btc_mesh_cfg_client_publish_callback(u32_t opcode, struct bt_mesh_model *mo
struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf)
{
if (!model || !ctx || !buf) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -383,7 +383,7 @@ void btc_mesh_cfg_client_call_handler(btc_msg_t *msg)
bt_mesh_role_param_t role_param = {0};
if (!msg || !msg->arg) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -394,8 +394,8 @@ void btc_mesh_cfg_client_call_handler(btc_msg_t *msg)
cfg_client_cb.params = arg->cfg_client_get_state.params;
role_param.model = (struct bt_mesh_model *)cfg_client_cb.params->model;
role_param.role = cfg_client_cb.params->msg_role;
if (bt_mesh_copy_msg_role(&role_param)) {
LOG_ERROR("%s: copy msg_role fail", __func__);
if (bt_mesh_set_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
return;
}
btc_ble_mesh_config_client_get_state(arg->cfg_client_get_state.params,
@@ -410,8 +410,8 @@ void btc_mesh_cfg_client_call_handler(btc_msg_t *msg)
cfg_client_cb.params = arg->cfg_client_set_state.params;
role_param.model = (struct bt_mesh_model *)cfg_client_cb.params->model;
role_param.role = cfg_client_cb.params->msg_role;
if (bt_mesh_copy_msg_role(&role_param)) {
LOG_ERROR("%s: copy msg_role fail", __func__);
if (bt_mesh_set_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
return;
}
btc_ble_mesh_config_client_set_state(arg->cfg_client_set_state.params,
@@ -434,7 +434,7 @@ void btc_mesh_cfg_client_cb_handler(btc_msg_t *msg)
esp_ble_mesh_cfg_client_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -443,7 +443,7 @@ void btc_mesh_cfg_client_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_CFG_CLIENT_EVT_MAX) {
btc_ble_mesh_cfg_client_cb_to_app(msg->act, param);
} else {
LOG_ERROR("%s, unknown msg->act = %d", __func__, msg->act);
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
}
btc_ble_mesh_cfg_client_free_req_data(msg);
@@ -456,12 +456,12 @@ int btc_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param_t *par
struct bt_mesh_msg_ctx ctx = {0};
if (!params || !cfg_client_cb) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return -EINVAL;
}
ctx.net_idx = params->ctx.net_idx;
ctx.app_idx = BT_MESH_KEY_DEV;
ctx.app_idx = BLE_MESH_KEY_DEV;
ctx.addr = params->ctx.addr;
ctx.send_rel = params->ctx.send_rel;
ctx.send_ttl = params->ctx.send_ttl;
@@ -516,7 +516,7 @@ int btc_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param_t *par
case ESP_BLE_MESH_MODEL_OP_NETWORK_TRANSMIT_GET:
return (cfg_client_cb->error_code = bt_mesh_cfg_net_transmit_get(&ctx));
default:
BT_WARN("%s, invalid opcode 0x%x", __func__, params->opcode);
BT_WARN("%s, Invalid opcode 0x%x", __func__, params->opcode);
return (cfg_client_cb->error_code = -EINVAL);
}
@@ -530,12 +530,12 @@ int btc_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param_t *par
struct bt_mesh_msg_ctx ctx = {0};
if (!params || !set_state || !cfg_client_cb) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return -EINVAL;
}
ctx.net_idx = params->ctx.net_idx;
ctx.app_idx = BT_MESH_KEY_DEV;
ctx.app_idx = BLE_MESH_KEY_DEV;
ctx.addr = params->ctx.addr;
ctx.send_rel = params->ctx.send_rel;
ctx.send_ttl = params->ctx.send_ttl;
@@ -653,7 +653,7 @@ int btc_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param_t *par
return (cfg_client_cb->error_code =
bt_mesh_cfg_net_transmit_set(&ctx, set_state->net_transmit_set.net_transmit));
default:
BT_WARN("%s, invalid opcode 0x%x", __func__, params->opcode);
BT_WARN("%s, Invalid opcode 0x%x", __func__, params->opcode);
return (cfg_client_cb->error_code = -EINVAL);
}
@@ -682,7 +682,7 @@ void bt_mesh_callback_cfg_server_event_to_btc(u8_t evt_type, struct bt_mesh_mode
uint8_t act;
if (!model || !ctx) {
LOG_ERROR("%s: invalid parameter", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -691,7 +691,7 @@ void bt_mesh_callback_cfg_server_event_to_btc(u8_t evt_type, struct bt_mesh_mode
act = ESP_BLE_MESH_CFG_SERVER_RECV_MSG_EVT;
break;
default:
LOG_ERROR("%s: unknown config sever event type", __func__);
LOG_ERROR("%s, Unknown config server event type %d", __func__, evt_type);
return;
}
@@ -716,7 +716,7 @@ void btc_mesh_cfg_server_cb_handler(btc_msg_t *msg)
esp_ble_mesh_cfg_server_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -725,6 +725,6 @@ void btc_mesh_cfg_server_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_CFG_SERVER_EVT_MAX) {
btc_ble_mesh_cfg_server_cb_to_app(msg->act, param);
} else {
LOG_ERROR("%s, unknown msg->act = %d", __func__, msg->act);
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
}
}

View File

@@ -19,7 +19,7 @@
#include "osi/allocator.h"
#include "cfg_cli.h"
#include "btc_ble_mesh_generic_client.h"
#include "btc_ble_mesh_generic_model.h"
#include "esp_ble_mesh_generic_model_api.h"
static inline void btc_ble_mesh_cb_to_app(esp_ble_mesh_generic_client_cb_event_t event,
@@ -39,7 +39,7 @@ void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, voi
u16_t length;
if (!msg || !dst || !src) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -53,7 +53,7 @@ void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, voi
memcpy(dst->generic_client_get_state.get_state, src->generic_client_get_state.get_state,
sizeof(esp_ble_mesh_generic_client_get_state_t));
} else {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
break;
}
@@ -73,7 +73,7 @@ void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, voi
length = src->generic_client_set_state.set_state->user_property_set.property_value->len;
dst->generic_client_set_state.set_state->user_property_set.property_value = bt_mesh_alloc_buf(length);
if (!dst->generic_client_set_state.set_state->user_property_set.property_value) {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_init(dst->generic_client_set_state.set_state->user_property_set.property_value, 0);
@@ -87,7 +87,7 @@ void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, voi
length = src->generic_client_set_state.set_state->admin_property_set.property_value->len;
dst->generic_client_set_state.set_state->admin_property_set.property_value = bt_mesh_alloc_buf(length);
if (!dst->generic_client_set_state.set_state->admin_property_set.property_value) {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_init(dst->generic_client_set_state.set_state->admin_property_set.property_value, 0);
@@ -100,12 +100,12 @@ void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, voi
break;
}
} else {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
break;
}
default:
LOG_DEBUG("%s Unhandled deep copy %d", __func__, msg->act);
LOG_DEBUG("%s, Unknown deep copy act %d", __func__, msg->act);
break;
}
}
@@ -118,7 +118,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
u16_t length;
if (!msg || !p_src_data || !p_dest_data) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -135,7 +135,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
length = p_src_data->status_cb.user_properties_status.property_ids->len;
p_dest_data->status_cb.user_properties_status.property_ids = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.user_properties_status.property_ids) {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_init(p_dest_data->status_cb.user_properties_status.property_ids, 0);
@@ -151,7 +151,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
length = p_src_data->status_cb.user_property_status.property_value->len;
p_dest_data->status_cb.user_property_status.property_value = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.user_property_status.property_value) {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_init(p_dest_data->status_cb.user_property_status.property_value, 0);
@@ -166,7 +166,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
length = p_src_data->status_cb.admin_properties_status.property_ids->len;
p_dest_data->status_cb.admin_properties_status.property_ids = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.admin_properties_status.property_ids) {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_init(p_dest_data->status_cb.admin_properties_status.property_ids, 0);
@@ -182,7 +182,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
length = p_src_data->status_cb.admin_property_status.property_value->len;
p_dest_data->status_cb.admin_property_status.property_value = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.admin_property_status.property_value) {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_init(p_dest_data->status_cb.admin_property_status.property_value, 0);
@@ -197,7 +197,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
length = p_src_data->status_cb.manufacturer_properties_status.property_ids->len;
p_dest_data->status_cb.manufacturer_properties_status.property_ids = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.manufacturer_properties_status.property_ids) {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_init(p_dest_data->status_cb.manufacturer_properties_status.property_ids, 0);
@@ -213,7 +213,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
length = p_src_data->status_cb.manufacturer_property_status.property_value->len;
p_dest_data->status_cb.manufacturer_property_status.property_value = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.manufacturer_property_status.property_value) {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_init(p_dest_data->status_cb.manufacturer_property_status.property_value, 0);
@@ -228,7 +228,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
length = p_src_data->status_cb.client_properties_status.property_ids->len;
p_dest_data->status_cb.client_properties_status.property_ids = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.client_properties_status.property_ids) {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_init(p_dest_data->status_cb.client_properties_status.property_ids, 0);
@@ -247,7 +247,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
if (p_dest_data->params) {
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
} else {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
}
break;
@@ -262,7 +262,7 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
u32_t opcode;
if (!msg || !msg->arg) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -326,7 +326,7 @@ void btc_ble_mesh_generic_client_arg_deep_free(btc_msg_t *msg)
u32_t opcode = 0;
if (!msg || !msg->arg) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -389,12 +389,12 @@ void bt_mesh_callback_generic_status_to_btc(u32_t opcode, u8_t evt_type,
const u8_t *val, size_t len)
{
esp_ble_mesh_generic_client_cb_param_t cb_params = {0};
esp_ble_mesh_client_common_param_t params = {0};
size_t length;
esp_ble_mesh_client_common_param_t params = {0};
size_t length;
uint8_t act;
if (!model || !ctx) {
LOG_ERROR("%s: invalid parameter", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -412,7 +412,7 @@ void bt_mesh_callback_generic_status_to_btc(u32_t opcode, u8_t evt_type,
act = ESP_BLE_MESH_GENERIC_CLIENT_TIMEOUT_EVT;
break;
default:
LOG_ERROR("%s: unknown generic status event type", __func__);
LOG_ERROR("%s, Unknown generic client event type %d", __func__, evt_type);
return;
}
@@ -440,7 +440,7 @@ void btc_mesh_generic_client_publish_callback(u32_t opcode, struct bt_mesh_model
struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf)
{
if (!model || !ctx || !buf) {
LOG_ERROR("%s: invalid parameter", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -456,7 +456,7 @@ void btc_mesh_generic_client_call_handler(btc_msg_t *msg)
bt_mesh_role_param_t role_param = {0};
if (!msg || !msg->arg) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -467,8 +467,8 @@ void btc_mesh_generic_client_call_handler(btc_msg_t *msg)
params = arg->generic_client_get_state.params;
role_param.model = (struct bt_mesh_model *)params->model;
role_param.role = params->msg_role;
if (bt_mesh_copy_msg_role(&role_param)) {
LOG_ERROR("%s: copy msg_role fail", __func__);
if (bt_mesh_set_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
return;
}
common.opcode = params->opcode;
@@ -496,8 +496,8 @@ void btc_mesh_generic_client_call_handler(btc_msg_t *msg)
params = arg->generic_client_set_state.params;
role_param.model = (struct bt_mesh_model *)params->model;
role_param.role = params->msg_role;
if (bt_mesh_copy_msg_role(&role_param)) {
LOG_ERROR("%s: copy msg_role fail", __func__);
if (bt_mesh_set_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
return;
}
common.opcode = params->opcode;
@@ -533,7 +533,7 @@ void btc_mesh_generic_client_cb_handler(btc_msg_t *msg)
esp_ble_mesh_generic_client_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -542,7 +542,7 @@ void btc_mesh_generic_client_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_GENERIC_CLIENT_EVT_MAX) {
btc_ble_mesh_cb_to_app(msg->act, param);
} else {
LOG_ERROR("%s, unknown msg->act = %d", __func__, msg->act);
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
}
btc_ble_mesh_free_req_data(msg);

View File

@@ -21,8 +21,9 @@
#include "health_srv.h"
#include "health_cli.h"
#include "common.h"
#include "btc_ble_mesh_health.h"
#include "mesh_common.h"
#include "btc_ble_mesh_health_model.h"
#include "esp_ble_mesh_defs.h"
extern s32_t health_msg_timeout;
@@ -51,7 +52,7 @@ void btc_ble_mesh_health_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
btc_ble_mesh_health_client_args_t *src = (btc_ble_mesh_health_client_args_t *)p_src;
if (!msg || !dst || !src) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -65,7 +66,7 @@ void btc_ble_mesh_health_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
memcpy(dst->health_client_get_state.get_state, src->health_client_get_state.get_state,
sizeof(esp_ble_mesh_health_client_get_state_t));
} else {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
break;
}
@@ -78,12 +79,12 @@ void btc_ble_mesh_health_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
memcpy(dst->health_client_set_state.set_state, src->health_client_set_state.set_state,
sizeof(esp_ble_mesh_health_client_set_state_t));
} else {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
break;
}
default:
LOG_DEBUG("%s Unhandled deep copy %d", __func__, msg->act);
LOG_DEBUG("%s, Unknown deep copy act %d", __func__, msg->act);
break;
}
}
@@ -93,7 +94,7 @@ static void btc_ble_mesh_health_client_arg_deep_free(btc_msg_t *msg)
btc_ble_mesh_health_client_args_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -126,7 +127,7 @@ static void btc_ble_mesh_health_client_arg_deep_free(btc_msg_t *msg)
void btc_ble_mesh_health_server_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
{
if (!msg) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -141,7 +142,7 @@ void btc_ble_mesh_health_server_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
static void btc_ble_mesh_health_server_arg_deep_free(btc_msg_t *msg)
{
if (!msg) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -161,7 +162,7 @@ static void btc_ble_mesh_health_client_copy_req_data(btc_msg_t *msg, void *p_des
u16_t length;
if (!msg || !p_src_data || !p_dest_data) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -177,7 +178,7 @@ static void btc_ble_mesh_health_client_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->status_cb.current_status.fault_array->len;
p_dest_data->status_cb.current_status.fault_array = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.current_status.fault_array) {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_init(p_dest_data->status_cb.current_status.fault_array, 0);
@@ -194,7 +195,7 @@ static void btc_ble_mesh_health_client_copy_req_data(btc_msg_t *msg, void *p_des
length = p_src_data->status_cb.fault_status.fault_array->len;
p_dest_data->status_cb.fault_status.fault_array = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.fault_status.fault_array) {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_init(p_dest_data->status_cb.fault_status.fault_array, 0);
@@ -213,7 +214,7 @@ static void btc_ble_mesh_health_client_copy_req_data(btc_msg_t *msg, void *p_des
if (p_dest_data->params) {
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
} else {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
}
break;
@@ -228,7 +229,7 @@ static void btc_ble_mesh_health_client_free_req_data(btc_msg_t *msg)
u32_t opcode;
if (!msg || !msg->arg) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -267,7 +268,7 @@ static void btc_ble_mesh_health_client_free_req_data(btc_msg_t *msg)
static void btc_ble_mesh_health_server_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
{
if (!msg) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -282,7 +283,7 @@ static void btc_ble_mesh_health_server_copy_req_data(btc_msg_t *msg, void *p_des
static void btc_ble_mesh_health_server_free_req_data(btc_msg_t *msg)
{
if (!msg) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -329,7 +330,7 @@ int btc_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_t *par
struct bt_mesh_msg_ctx ctx = {0};
if (!params || !client_cb) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return -EINVAL;
}
@@ -363,7 +364,7 @@ int btc_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param_t *par
struct bt_mesh_msg_ctx ctx = {0};
if (!params || !set_state || !client_cb) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return -EINVAL;
}
@@ -401,7 +402,7 @@ int btc_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param_t *par
return (client_cb->error_code =
bt_mesh_health_fault_clear(&ctx, set_state->fault_clear.company_id, false));
default:
BT_WARN("%s, invalid opcode 0x%x", __func__, params->opcode);
BT_WARN("%s, Invalid opcode 0x%x", __func__, params->opcode);
return (client_cb->error_code = -EINVAL);
}
@@ -414,12 +415,12 @@ void bt_mesh_callback_health_status_to_btc(u32_t opcode, u8_t evt_type,
const u8_t *val, u16_t len)
{
esp_ble_mesh_health_client_cb_param_t cb_params = {0};
esp_ble_mesh_client_common_param_t params = {0};
size_t length;
esp_ble_mesh_client_common_param_t params = {0};
size_t length;
uint8_t act;
if (!model || !ctx) {
LOG_ERROR("%s: invalid parameter", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -437,7 +438,7 @@ void bt_mesh_callback_health_status_to_btc(u32_t opcode, u8_t evt_type,
act = ESP_BLE_MESH_HEALTH_CLIENT_TIMEOUT_EVT;
break;
default:
LOG_ERROR("%s: unknown health status event type", __func__);
LOG_ERROR("%s, Unknown health client event type %d", __func__, evt_type);
return;
}
@@ -465,7 +466,7 @@ void btc_mesh_health_publish_callback(u32_t opcode, struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf)
{
if (!model || !ctx || !buf) {
LOG_ERROR("%s: invalid parameter", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -479,7 +480,7 @@ void btc_mesh_health_client_call_handler(btc_msg_t *msg)
bt_mesh_role_param_t role_param = {0};
if (!msg || !msg->arg) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -490,8 +491,8 @@ void btc_mesh_health_client_call_handler(btc_msg_t *msg)
health_client_cb.params = arg->health_client_get_state.params;
role_param.model = (struct bt_mesh_model *)health_client_cb.params->model;
role_param.role = health_client_cb.params->msg_role;
if (bt_mesh_copy_msg_role(&role_param)) {
LOG_ERROR("%s: copy msg_role fail", __func__);
if (bt_mesh_set_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
return;
}
btc_ble_mesh_health_client_get_state(arg->health_client_get_state.params,
@@ -507,8 +508,8 @@ void btc_mesh_health_client_call_handler(btc_msg_t *msg)
health_client_cb.params = arg->health_client_set_state.params;
role_param.model = (struct bt_mesh_model *)health_client_cb.params->model;
role_param.role = health_client_cb.params->msg_role;
if (bt_mesh_copy_msg_role(&role_param)) {
LOG_ERROR("%s: copy msg_role fail", __func__);
if (bt_mesh_set_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
return;
}
btc_ble_mesh_health_client_set_state(arg->health_client_set_state.params,
@@ -533,7 +534,7 @@ void btc_mesh_health_client_cb_handler(btc_msg_t *msg)
esp_ble_mesh_health_client_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -542,7 +543,7 @@ void btc_mesh_health_client_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_HEALTH_CLIENT_EVT_MAX) {
btc_ble_mesh_health_client_cb_to_app(msg->act, param);
} else {
LOG_ERROR("%s, unknown msg->act = %d", __func__, msg->act);
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
}
btc_ble_mesh_health_client_free_req_data(msg);
@@ -554,7 +555,7 @@ void btc_mesh_health_server_call_handler(btc_msg_t *msg)
btc_ble_mesh_health_server_args_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -577,7 +578,7 @@ void btc_mesh_health_server_cb_handler(btc_msg_t *msg)
esp_ble_mesh_health_server_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -586,7 +587,7 @@ void btc_mesh_health_server_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_HEALTH_SERVER_EVT_MAX) {
btc_ble_mesh_health_server_cb_to_app(msg->act, param);
} else {
LOG_ERROR("%s, unknown msg->act = %d", __func__, msg->act);
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
}
btc_ble_mesh_health_server_free_req_data(msg);

View File

@@ -18,8 +18,8 @@
#include "btc/btc_manage.h"
#include "osi/allocator.h"
#include "light_client.h"
#include "btc_ble_mesh_light_client.h"
#include "lighting_client.h"
#include "btc_ble_mesh_lighting_model.h"
#include "esp_ble_mesh_lighting_model_api.h"
static inline void btc_ble_mesh_cb_to_app(esp_ble_mesh_light_client_cb_event_t event,
@@ -37,7 +37,7 @@ void btc_ble_mesh_light_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
btc_ble_mesh_light_client_args_t *src = (btc_ble_mesh_light_client_args_t *)p_src;
if (!msg || !dst || !src) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -51,7 +51,7 @@ void btc_ble_mesh_light_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
memcpy(dst->light_client_get_state.get_state, src->light_client_get_state.get_state,
sizeof(esp_ble_mesh_light_client_get_state_t));
} else {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
break;
}
@@ -64,12 +64,12 @@ void btc_ble_mesh_light_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
memcpy(dst->light_client_set_state.set_state, src->light_client_set_state.set_state,
sizeof(esp_ble_mesh_light_client_set_state_t));
} else {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
break;
}
default:
LOG_DEBUG("%s Unhandled deep copy %d", __func__, msg->act);
LOG_DEBUG("%s, Unknown deep copy act %d", __func__, msg->act);
break;
}
}
@@ -82,7 +82,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
u16_t length;
if (!msg || !p_src_data || !p_dest_data) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -100,7 +100,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
length = p_src_data->status_cb.lc_property_status.property_value->len;
p_dest_data->status_cb.lc_property_status.property_value = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.lc_property_status.property_value) {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_init(p_dest_data->status_cb.lc_property_status.property_value, 0);
@@ -119,7 +119,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
if (p_dest_data->params) {
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
} else {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
}
break;
@@ -134,7 +134,7 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
u32_t opcode;
if (!msg || !msg->arg) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -171,7 +171,7 @@ void btc_ble_mesh_light_client_arg_deep_free(btc_msg_t *msg)
btc_ble_mesh_light_client_args_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -221,12 +221,12 @@ void bt_mesh_callback_light_status_to_btc(u32_t opcode, u8_t evt_type,
const u8_t *val, size_t len)
{
esp_ble_mesh_light_client_cb_param_t cb_params = {0};
esp_ble_mesh_client_common_param_t params = {0};
size_t length;
esp_ble_mesh_client_common_param_t params = {0};
size_t length;
uint8_t act;
if (!model || !ctx) {
LOG_ERROR("%s: invalid parameter", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -244,7 +244,7 @@ void bt_mesh_callback_light_status_to_btc(u32_t opcode, u8_t evt_type,
act = ESP_BLE_MESH_LIGHT_CLIENT_TIMEOUT_EVT;
break;
default:
LOG_ERROR("%s: unknown light status event type", __func__);
LOG_ERROR("%s, Unknown lighting client event type", __func__);
return;
}
@@ -272,7 +272,7 @@ void btc_mesh_light_client_publish_callback(u32_t opcode, struct bt_mesh_model *
struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf)
{
if (!model || !ctx || !buf) {
LOG_ERROR("%s: invalid parameter", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -288,7 +288,7 @@ void btc_mesh_light_client_call_handler(btc_msg_t *msg)
bt_mesh_role_param_t role_param = {0};
if (!msg || !msg->arg) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -299,8 +299,8 @@ void btc_mesh_light_client_call_handler(btc_msg_t *msg)
params = arg->light_client_get_state.params;
role_param.model = (struct bt_mesh_model *)params->model;
role_param.role = params->msg_role;
if (bt_mesh_copy_msg_role(&role_param)) {
LOG_ERROR("%s: copy msg_role fail", __func__);
if (bt_mesh_set_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
return;
}
common.opcode = params->opcode;
@@ -328,8 +328,8 @@ void btc_mesh_light_client_call_handler(btc_msg_t *msg)
params = arg->light_client_set_state.params;
role_param.model = (struct bt_mesh_model *)params->model;
role_param.role = params->msg_role;
if (bt_mesh_copy_msg_role(&role_param)) {
LOG_ERROR("%s: copy msg_role fail", __func__);
if (bt_mesh_set_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
return;
}
common.opcode = params->opcode;
@@ -365,7 +365,7 @@ void btc_mesh_light_client_cb_handler(btc_msg_t *msg)
esp_ble_mesh_light_client_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -374,7 +374,7 @@ void btc_mesh_light_client_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_LIGHT_CLIENT_EVT_MAX) {
btc_ble_mesh_cb_to_app(msg->act, param);
} else {
LOG_ERROR("%s, unknown msg->act = %d", __func__, msg->act);
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
}
btc_ble_mesh_free_req_data(msg);

File diff suppressed because it is too large Load Diff

View File

@@ -19,7 +19,7 @@
#include "osi/allocator.h"
#include "sensor_client.h"
#include "btc_ble_mesh_sensor_client.h"
#include "btc_ble_mesh_sensor_model.h"
#include "esp_ble_mesh_sensor_model_api.h"
static inline void btc_ble_mesh_cb_to_app(esp_ble_mesh_sensor_client_cb_event_t event,
@@ -39,7 +39,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
u16_t length;
if (!msg || !dst || !src) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -60,7 +60,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
length = src->sensor_client_get_state.get_state->column_get.raw_value_x->len;
dst->sensor_client_get_state.get_state->column_get.raw_value_x = bt_mesh_alloc_buf(length);
if (!dst->sensor_client_get_state.get_state->column_get.raw_value_x) {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_init(dst->sensor_client_get_state.get_state->column_get.raw_value_x, 0);
@@ -74,7 +74,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
length = src->sensor_client_get_state.get_state->series_get.raw_value_x1->len;
dst->sensor_client_get_state.get_state->series_get.raw_value_x1 = bt_mesh_alloc_buf(length);
if (!dst->sensor_client_get_state.get_state->series_get.raw_value_x1) {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_init(dst->sensor_client_get_state.get_state->series_get.raw_value_x1, 0);
@@ -86,7 +86,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
length = src->sensor_client_get_state.get_state->series_get.raw_value_x2->len;
dst->sensor_client_get_state.get_state->series_get.raw_value_x2 = bt_mesh_alloc_buf(length);
if (!dst->sensor_client_get_state.get_state->series_get.raw_value_x2) {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_init(dst->sensor_client_get_state.get_state->series_get.raw_value_x2, 0);
@@ -99,7 +99,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
break;
}
} else {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
break;
}
@@ -119,7 +119,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
length = src->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down->len;
dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down = bt_mesh_alloc_buf(length);
if (!dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down) {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_init(dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down, 0);
@@ -131,7 +131,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
length = src->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_up->len;
dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_up = bt_mesh_alloc_buf(length);
if (!dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_up) {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_init(dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_up, 0);
@@ -143,7 +143,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
length = src->sensor_client_set_state.set_state->cadence_set.fast_cadence_low->len;
dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_low = bt_mesh_alloc_buf(length);
if (!dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_low) {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_init(dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_low, 0);
@@ -155,7 +155,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
length = src->sensor_client_set_state.set_state->cadence_set.fast_cadence_high->len;
dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_high = bt_mesh_alloc_buf(length);
if (!dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_high) {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_init(dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_high, 0);
@@ -169,7 +169,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
length = src->sensor_client_set_state.set_state->setting_set.sensor_setting_raw->len;
dst->sensor_client_set_state.set_state->setting_set.sensor_setting_raw = bt_mesh_alloc_buf(length);
if (!dst->sensor_client_set_state.set_state->setting_set.sensor_setting_raw) {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_init(dst->sensor_client_set_state.set_state->setting_set.sensor_setting_raw, 0);
@@ -182,12 +182,12 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
break;
}
} else {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
break;
}
default:
LOG_DEBUG("%s Unhandled deep copy %d", __func__, msg->act);
LOG_DEBUG("%s, Unknown deep copy act %d", __func__, msg->act);
break;
}
}
@@ -200,7 +200,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
u16_t length;
if (!msg || !p_src_data || !p_dest_data) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -217,7 +217,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
length = p_src_data->status_cb.descriptor_status.descriptor->len;
p_dest_data->status_cb.descriptor_status.descriptor = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.descriptor_status.descriptor) {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_init(p_dest_data->status_cb.descriptor_status.descriptor, 0);
@@ -233,7 +233,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
length = p_src_data->status_cb.cadence_status.sensor_cadence_value->len;
p_dest_data->status_cb.cadence_status.sensor_cadence_value = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.cadence_status.sensor_cadence_value) {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_init(p_dest_data->status_cb.cadence_status.sensor_cadence_value, 0);
@@ -248,7 +248,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
length = p_src_data->status_cb.settings_status.sensor_setting_property_ids->len;
p_dest_data->status_cb.settings_status.sensor_setting_property_ids = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.settings_status.sensor_setting_property_ids) {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_init(p_dest_data->status_cb.settings_status.sensor_setting_property_ids, 0);
@@ -264,7 +264,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
length = p_src_data->status_cb.setting_status.sensor_setting_raw->len;
p_dest_data->status_cb.setting_status.sensor_setting_raw = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.setting_status.sensor_setting_raw) {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_init(p_dest_data->status_cb.setting_status.sensor_setting_raw, 0);
@@ -279,7 +279,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
length = p_src_data->status_cb.sensor_status.marshalled_sensor_data->len;
p_dest_data->status_cb.sensor_status.marshalled_sensor_data = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.sensor_status.marshalled_sensor_data) {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_init(p_dest_data->status_cb.sensor_status.marshalled_sensor_data, 0);
@@ -294,7 +294,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
length = p_src_data->status_cb.column_status.sensor_column_value->len;
p_dest_data->status_cb.column_status.sensor_column_value = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.column_status.sensor_column_value) {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_init(p_dest_data->status_cb.column_status.sensor_column_value, 0);
@@ -309,7 +309,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
length = p_src_data->status_cb.series_status.sensor_series_value->len;
p_dest_data->status_cb.series_status.sensor_series_value = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.series_status.sensor_series_value) {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_init(p_dest_data->status_cb.series_status.sensor_series_value, 0);
@@ -328,7 +328,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
if (p_dest_data->params) {
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
} else {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
}
break;
@@ -343,7 +343,7 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
u32_t opcode;
if (!msg || !msg->arg) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -406,7 +406,7 @@ void btc_ble_mesh_sensor_client_arg_deep_free(btc_msg_t *msg)
u32_t opcode = 0;
if (!msg || !msg->arg) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -486,12 +486,12 @@ void bt_mesh_callback_sensor_status_to_btc(u32_t opcode, u8_t evt_type,
const u8_t *val, size_t len)
{
esp_ble_mesh_sensor_client_cb_param_t cb_params = {0};
esp_ble_mesh_client_common_param_t params = {0};
size_t length;
esp_ble_mesh_client_common_param_t params = {0};
size_t length;
uint8_t act;
if (!model || !ctx) {
LOG_ERROR("%s: invalid parameter", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -509,7 +509,7 @@ void bt_mesh_callback_sensor_status_to_btc(u32_t opcode, u8_t evt_type,
act = ESP_BLE_MESH_SENSOR_CLIENT_TIMEOUT_EVT;
break;
default:
LOG_ERROR("%s: unknown sensor status event type", __func__);
LOG_ERROR("%s, Unknown sensor client event type %d", __func__, evt_type);
return;
}
@@ -537,7 +537,7 @@ void btc_mesh_sensor_client_publish_callback(u32_t opcode, struct bt_mesh_model
struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf)
{
if (!model || !ctx || !buf) {
LOG_ERROR("%s: invalid parameter", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -553,7 +553,7 @@ void btc_mesh_sensor_client_call_handler(btc_msg_t *msg)
bt_mesh_role_param_t role_param = {0};
if (!msg || !msg->arg) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -564,8 +564,8 @@ void btc_mesh_sensor_client_call_handler(btc_msg_t *msg)
params = arg->sensor_client_get_state.params;
role_param.model = (struct bt_mesh_model *)params->model;
role_param.role = params->msg_role;
if (bt_mesh_copy_msg_role(&role_param)) {
LOG_ERROR("%s: copy msg_role fail", __func__);
if (bt_mesh_set_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
return;
}
common.opcode = params->opcode;
@@ -593,8 +593,8 @@ void btc_mesh_sensor_client_call_handler(btc_msg_t *msg)
params = arg->sensor_client_set_state.params;
role_param.model = (struct bt_mesh_model *)params->model;
role_param.role = params->msg_role;
if (bt_mesh_copy_msg_role(&role_param)) {
LOG_ERROR("%s: copy msg_role fail", __func__);
if (bt_mesh_set_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
return;
}
common.opcode = params->opcode;
@@ -630,7 +630,7 @@ void btc_mesh_sensor_client_cb_handler(btc_msg_t *msg)
esp_ble_mesh_sensor_client_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -639,7 +639,7 @@ void btc_mesh_sensor_client_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_SENSOR_CLIENT_EVT_MAX) {
btc_ble_mesh_cb_to_app(msg->act, param);
} else {
LOG_ERROR("%s, unknown msg->act = %d", __func__, msg->act);
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
}
btc_ble_mesh_free_req_data(msg);

View File

@@ -19,7 +19,7 @@
#include "osi/allocator.h"
#include "time_scene_client.h"
#include "btc_ble_mesh_time_scene_client.h"
#include "btc_ble_mesh_time_scene_model.h"
#include "esp_ble_mesh_time_scene_model_api.h"
static inline void btc_ble_mesh_cb_to_app(esp_ble_mesh_time_scene_client_cb_event_t event,
@@ -37,7 +37,7 @@ void btc_ble_mesh_time_scene_client_arg_deep_copy(btc_msg_t *msg, void *p_dest,
btc_ble_mesh_time_scene_client_args_t *src = (btc_ble_mesh_time_scene_client_args_t *)p_src;
if (!msg || !dst || !src) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -51,7 +51,7 @@ void btc_ble_mesh_time_scene_client_arg_deep_copy(btc_msg_t *msg, void *p_dest,
memcpy(dst->time_scene_client_get_state.get_state, src->time_scene_client_get_state.get_state,
sizeof(esp_ble_mesh_time_scene_client_get_state_t));
} else {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
break;
}
@@ -64,12 +64,12 @@ void btc_ble_mesh_time_scene_client_arg_deep_copy(btc_msg_t *msg, void *p_dest,
memcpy(dst->time_scene_client_set_state.set_state, src->time_scene_client_set_state.set_state,
sizeof(esp_ble_mesh_time_scene_client_set_state_t));
} else {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
break;
}
default:
LOG_DEBUG("%s Unhandled deep copy %d", __func__, msg->act);
LOG_DEBUG("%s, Unknown deep copy act %d", __func__, msg->act);
break;
}
}
@@ -82,7 +82,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
u16_t length;
if (!msg || !p_src_data || !p_dest_data) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -101,7 +101,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
length = p_src_data->status_cb.scene_register_status.scenes->len;
p_dest_data->status_cb.scene_register_status.scenes = bt_mesh_alloc_buf(length);
if (!p_dest_data->status_cb.scene_register_status.scenes) {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
return;
}
net_buf_simple_init(p_dest_data->status_cb.scene_register_status.scenes, 0);
@@ -120,7 +120,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
if (p_dest_data->params) {
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
} else {
LOG_ERROR("%s %d no mem", __func__, msg->act);
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
}
}
break;
@@ -135,7 +135,7 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
u32_t opcode;
if (!msg || !msg->arg) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -173,7 +173,7 @@ void btc_ble_mesh_time_scene_client_arg_deep_free(btc_msg_t *msg)
btc_ble_mesh_time_scene_client_args_t *arg = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -223,12 +223,12 @@ void bt_mesh_callback_time_scene_status_to_btc(u32_t opcode, u8_t evt_type,
const u8_t *val, size_t len)
{
esp_ble_mesh_time_scene_client_cb_param_t cb_params = {0};
esp_ble_mesh_client_common_param_t params = {0};
size_t length;
esp_ble_mesh_client_common_param_t params = {0};
size_t length;
uint8_t act;
if (!model || !ctx) {
LOG_ERROR("%s: invalid parameter", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -246,7 +246,7 @@ void bt_mesh_callback_time_scene_status_to_btc(u32_t opcode, u8_t evt_type,
act = ESP_BLE_MESH_TIME_SCENE_CLIENT_TIMEOUT_EVT;
break;
default:
LOG_ERROR("%s: unknown time scene status event type", __func__);
LOG_ERROR("%s, Unknown time scene client event type %d", __func__, evt_type);
return;
}
@@ -274,7 +274,7 @@ void btc_mesh_time_scene_client_publish_callback(u32_t opcode, struct bt_mesh_mo
struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf)
{
if (!model || !ctx || !buf) {
LOG_ERROR("%s: invalid parameter", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -290,7 +290,7 @@ void btc_mesh_time_scene_client_call_handler(btc_msg_t *msg)
bt_mesh_role_param_t role_param = {0};
if (!msg || !msg->arg) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -301,8 +301,8 @@ void btc_mesh_time_scene_client_call_handler(btc_msg_t *msg)
params = arg->time_scene_client_get_state.params;
role_param.model = (struct bt_mesh_model *)params->model;
role_param.role = params->msg_role;
if (bt_mesh_copy_msg_role(&role_param)) {
LOG_ERROR("%s: copy msg_role fail", __func__);
if (bt_mesh_set_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
return;
}
common.opcode = params->opcode;
@@ -330,8 +330,8 @@ void btc_mesh_time_scene_client_call_handler(btc_msg_t *msg)
params = arg->time_scene_client_set_state.params;
role_param.model = (struct bt_mesh_model *)params->model;
role_param.role = params->msg_role;
if (bt_mesh_copy_msg_role(&role_param)) {
LOG_ERROR("%s: copy msg_role fail", __func__);
if (bt_mesh_set_model_role(&role_param)) {
LOG_ERROR("%s, Failed to set model role", __func__);
return;
}
common.opcode = params->opcode;
@@ -367,7 +367,7 @@ void btc_mesh_time_scene_client_cb_handler(btc_msg_t *msg)
esp_ble_mesh_time_scene_client_cb_param_t *param = NULL;
if (!msg || !msg->arg) {
LOG_ERROR("%s: parameter is NULL", __func__);
LOG_ERROR("%s, Invalid parameter", __func__);
return;
}
@@ -376,7 +376,7 @@ void btc_mesh_time_scene_client_cb_handler(btc_msg_t *msg)
if (msg->act < ESP_BLE_MESH_TIME_SCENE_CLIENT_EVT_MAX) {
btc_ble_mesh_cb_to_app(msg->act, param);
} else {
LOG_ERROR("%s, unknown msg->act = %d", __func__, msg->act);
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
}
btc_ble_mesh_free_req_data(msg);

View File

@@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef _BTC_BLE_MESH_CONFIG_CLIENT_H_
#define _BTC_BLE_MESH_CONFIG_CLIENT_H_
#ifndef _BTC_BLE_MESH_CONFIG_MODEL_H_
#define _BTC_BLE_MESH_CONFIG_MODEL_H_
#include <stdint.h>
#include "btc/btc_task.h"
@@ -61,4 +61,4 @@ void bt_mesh_callback_cfg_server_event_to_btc(u8_t evt_type, struct bt_mesh_mode
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len);
#endif /* _BTC_BLE_MESH_CONFIG_CLIENT_H_ */
#endif /* _BTC_BLE_MESH_CONFIG_MODEL_H_ */

View File

@@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef _BTC_BLE_MESH_GENERIC_CLIENT_H_
#define _BTC_BLE_MESH_GENERIC_CLIENT_H_
#ifndef _BTC_BLE_MESH_GENERIC_MODEL_H_
#define _BTC_BLE_MESH_GENERIC_MODEL_H_
#include <stdint.h>
#include "btc/btc_task.h"
@@ -48,4 +48,5 @@ void bt_mesh_callback_generic_status_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len);
#endif /* _BTC_BLE_MESH_GENERIC_CLIENT_H_ */
#endif /* _BTC_BLE_MESH_GENERIC_MODEL_H_ */

View File

@@ -12,12 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef _BTC_BLE_MESH_HEALTH_H_
#define _BTC_BLE_MESH_HEALTH_H_
#ifndef _BTC_BLE_MESH_HEALTH_MODEL_H_
#define _BTC_BLE_MESH_HEALTH_MODEL_H_
#include <stdint.h>
#include "btc/btc_task.h"
#include "esp_ble_mesh_defs.h"
#include "esp_ble_mesh_health_model_api.h"
typedef enum {
@@ -76,4 +75,4 @@ void bt_mesh_callback_health_status_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, u16_t len);
#endif /* _BTC_BLE_MESH_HEALTH_H_ */
#endif /* _BTC_BLE_MESH_HEALTH_MODEL_H_ */

View File

@@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef _BTC_BLE_MESH_LIGHT_CLIENT_H_
#define _BTC_BLE_MESH_LIGHT_CLIENT_H_
#ifndef _BTC_BLE_MESH_LIGHTING_MODEL_H_
#define _BTC_BLE_MESH_LIGHTING_MODEL_H_
#include <stdint.h>
#include "btc/btc_task.h"
@@ -49,5 +49,5 @@ void bt_mesh_callback_light_status_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len);
#endif /* _BTC_BLE_MESH_LIGHT_CLIENT_H_ */
#endif /* _BTC_BLE_MESH_LIGHTING_MODEL_H_ */

View File

@@ -26,12 +26,11 @@
#include "mesh_access.h"
#include "mesh_buf.h"
#include "mesh_main.h"
#include "provisioner_prov.h"
#include "esp_ble_mesh_defs.h"
#if CONFIG_BT_MESH
typedef enum {
BTC_BLE_MESH_ACT_APP_REGISTER = 0,
BTC_BLE_MESH_ACT_MESH_INIT = 0,
BTC_BLE_MESH_ACT_PROV_ENABLE,
BTC_BLE_MESH_ACT_PROV_DISABLE,
BTC_BLE_MESH_ACT_NODE_RESET,
@@ -42,7 +41,7 @@ typedef enum {
BTC_BLE_MESH_ACT_PROXY_IDENTITY_ENABLE,
BTC_BLE_MESH_ACT_PROXY_GATT_ENABLE,
BTC_BLE_MESH_ACT_PROXY_GATT_DISABLE,
#if (CONFIG_BT_MESH_PROVISIONER)
#if (CONFIG_BLE_MESH_PROVISIONER)
BTC_BLE_MESH_ACT_PROVISIONER_READ_OOB_PUB_KEY,
BTC_BLE_MESH_ACT_PROVISIONER_INPUT_STR,
BTC_BLE_MESH_ACT_PROVISIONER_INPUT_NUM,
@@ -56,7 +55,7 @@ typedef enum {
BTC_BLE_MESH_ACT_PROVISIONER_SET_LOCAL_APP_KEY,
BTC_BLE_MESH_ACT_PROVISIONER_BIND_LOCAL_MOD_APP,
BTC_BLE_MESH_ACT_PROVISIONER_ADD_LOCAL_NET_KEY,
#endif /* CONFIG_BT_MESH_PROVISIONER */
#endif /* CONFIG_BLE_MESH_PROVISIONER */
BTC_BLE_MESH_ACT_SET_FAST_PROV_INFO,
BTC_BLE_MESH_ACT_SET_FAST_PROV_ACTION,
} btc_ble_mesh_prov_act_t;
@@ -68,33 +67,32 @@ typedef enum {
} btc_ble_mesh_model_act_t;
typedef union {
struct ble_mesh_reg_args {
struct ble_mesh_init_args {
esp_ble_mesh_prov_t *prov;
esp_ble_mesh_comp_t *comp;
xSemaphoreHandle semaphore;
uint8_t mesh_if;
} mesh_reg;
struct ble_mesh_prov_enable_args {
SemaphoreHandle_t semaphore;
} mesh_init;
struct ble_mesh_node_prov_enable_args {
esp_ble_mesh_prov_bearer_t bearers;
} mesh_prov_enable;
struct ble_mesh_prov_disable_args {
} node_prov_enable;
struct ble_mesh_node_prov_disable_args {
esp_ble_mesh_prov_bearer_t bearers;
} mesh_prov_disable;
} node_prov_disable;
struct ble_mesh_set_oob_pub_key_args {
uint8_t pub_key_x[32];
uint8_t pub_key_y[32];
uint8_t private_key[32];
} set_oob_pub_key;
struct ble_mesh_input_num_args {
struct ble_mesh_node_input_num_args {
uint32_t number;
} input_num;
struct ble_mesh_input_str_args {
} input_number;
struct ble_mesh_node_input_str_args {
char string[8];
} input_str;
} input_string;
struct ble_mesh_set_device_name_args {
char name[ESP_BLE_MESH_DEVICE_NAME_MAX_LEN];
} set_device_name;
#if (CONFIG_BT_MESH_PROVISIONER)
#if (CONFIG_BLE_MESH_PROVISIONER)
struct ble_mesh_provisioner_read_oob_pub_key_args {
uint8_t link_idx;
uint8_t pub_key_x[32];
@@ -149,8 +147,8 @@ typedef union {
uint8_t net_key[16];
uint16_t net_idx;
} add_local_net_key;
#endif /* CONFIG_BT_MESH_PROVISIONER */
#if (CONFIG_BT_MESH_FAST_PROV)
#endif /* CONFIG_BLE_MESH_PROVISIONER */
#if (CONFIG_BLE_MESH_FAST_PROV)
struct ble_mesh_set_fast_prov_info_args {
uint16_t unicast_min;
uint16_t unicast_max;
@@ -164,7 +162,7 @@ typedef union {
struct ble_mesh_set_fast_prov_action_args {
uint8_t action;
} set_fast_prov_action;
#endif /* CONFIG_BT_MESH_FAST_PROV */
#endif /* CONFIG_BLE_MESH_FAST_PROV */
} btc_ble_mesh_prov_args_t;
typedef union {
@@ -216,5 +214,3 @@ void btc_mesh_prov_call_handler(btc_msg_t *msg);
void btc_mesh_prov_cb_handler(btc_msg_t *msg);
#endif /* _BTC_BLE_MESH_PROV_H_ */
#endif /* #if CONFIG_BT_MESH */

View File

@@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef _BTC_BLE_MESH_SENSOR_CLIENT_H_
#define _BTC_BLE_MESH_SENSOR_CLIENT_H_
#ifndef _BTC_BLE_MESH_SENSOR_MODEL_H_
#define _BTC_BLE_MESH_SENSOR_MODEL_H_
#include <stdint.h>
#include "btc/btc_task.h"
@@ -49,5 +49,5 @@ void bt_mesh_callback_sensor_status_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len);
#endif /* _BTC_BLE_MESH_SENSOR_CLIENT_H_ */
#endif /* _BTC_BLE_MESH_SENSOR_MODEL_H_ */

View File

@@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef _BTC_BLE_MESH_TIME_SCENE_CLIENT_H_
#define _BTC_BLE_MESH_TIME_SCENE_CLIENT_H_
#ifndef _BTC_BLE_MESH_TIME_SCENE_MODEL_H_
#define _BTC_BLE_MESH_TIME_SCENE_MODEL_H_
#include <stdint.h>
#include "btc/btc_task.h"
@@ -49,5 +49,5 @@ void bt_mesh_callback_time_scene_status_to_btc(u32_t opcode, u8_t evt_type,
struct bt_mesh_msg_ctx *ctx,
const u8_t *val, size_t len);
#endif /* _BTC_BLE_MESH_TIME_SCENE_CLIENT_H_ */
#endif /* _BTC_BLE_MESH_TIME_SCENE_MODEL_H_ */

View File

@@ -1,459 +0,0 @@
# Kconfig - Bluetooth Mesh configuration options
#
# Copyright (c) 2017 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#
menuconfig BT_MESH
bool "Bluetooth Mesh support"
select TINYCRYPT
select TINYCRYPT_AES
select TINYCRYPT_AES_CMAC
help
This option enables Bluetooth Mesh support. The specific
features that are available may depend on other features
that have been enabled in the stack, such as GATT support.
if BT_MESH
# Virtual option enabled whenever Generic Provisioning layer is needed
config BT_MESH_PROV
bool
config BT_MESH_PB_ADV
bool "Provisioning support using the advertising bearer (PB-ADV)"
select BT_MESH_PROV
default y
help
Enable this option to allow the device to be provisioned over
the advertising bearer.
if BT_CONN
# Virtual option enabled whenever any Proxy protocol is needed
config BT_MESH_PROXY
bool
config BT_MESH_PB_GATT
bool "Provisioning support using GATT (PB-GATT)"
select BT_MESH_PROXY
select BT_MESH_PROV
help
Enable this option to allow the device to be provisioned over
GATT.
config BT_MESH_GATT_PROXY
bool "GATT Proxy Service"
select BT_MESH_PROXY
help
This option enables support for the Mesh GATT Proxy Service,
i.e. the ability to act as a proxy between a Mesh GATT Client
and a Mesh network.
config BT_MESH_NODE_ID_TIMEOUT
int "Node Identity advertising timeout"
depends on BT_MESH_GATT_PROXY
range 1 60
default 60
help
This option determines for how long the local node advertises
using Node Identity. The given value is in seconds. The
specification limits this to 60 seconds, and implies that to
be the appropriate value as well, so just leaving this as the
default is the safest option.
if BT_MESH_PROXY
config BT_MESH_PROXY_FILTER_SIZE
int "Maximum number of filter entries per Proxy Client"
default 1
default 3 if BT_MESH_GATT_PROXY
range 1 32767
help
This option specifies how many Proxy Filter entries the local
node supports.
endif # BT_MESH_PROXY
endif # BT_CONN
config BT_MESH_SELF_TEST
bool "Perform self-tests"
help
This option adds extra self-tests which are run every time
mesh networking is initialized.
config BT_MESH_IV_UPDATE_TEST
bool "Test the IV Update Procedure"
help
This option removes the 96 hour limit of the IV Update
Procedure and lets the state be changed at any time.
config BT_MESH_SUBNET_COUNT
int "Maximum number of mesh subnets per network"
default 1
range 1 4096
help
This option specifies how many subnets a Mesh network can
participate in at the same time.
config BT_MESH_APP_KEY_COUNT
int "Maximum number of application keys per network"
default 1
range 1 4096
help
This option specifies how many application keys the device can
store per network.
config BT_MESH_MODEL_KEY_COUNT
int "Maximum number of application keys per model"
default 1
range 1 4096
help
This option specifies how many application keys each model can
at most be bound to.
config BT_MESH_MODEL_GROUP_COUNT
int "Maximum number of group address subscriptions per model"
default 1
range 1 4096
help
This option specifies how many group addresses each model can
at most be subscribed to.
config BT_MESH_LABEL_COUNT
int "Maximum number of Label UUIDs used for Virtual Addresses"
default 1
range 0 4096
help
This option specifies how many Label UUIDs can be stored.
config BT_MESH_CRPL
int "Maximum capacity of the replay protection list"
default 10
range 2 65535
help
This options specifies the maximum capacity of the replay
protection list. This option is similar to the network message
cache size, but has a different purpose.
config BT_MESH_MSG_CACHE_SIZE
int "Network message cache size"
default 10
range 2 65535
help
Number of messages that are cached for the network. This helps
prevent unnecessary decryption operations and unnecessary
relays. This option is similar to the replay protection list,
but has a different purpose.
config BT_MESH_ADV_BUF_COUNT
int "Number of advertising buffers"
default 6
range 6 256
help
Number of advertising buffers available. The transport layer
reserves ADV_BUF_COUNT - 3 buffers for outgoing segments. The
maximum outgoing SDU size is 12 times this number (out of which
4 or 8 bytes is used for the Transport Layer MIC). For
example, 5 segments means the maximum SDU size is 60 bytes,
which leaves 56 bytes for application layer data using a
4-byte MIC and 52 bytes using an 8-byte MIC.
config BT_MESH_TX_SEG_MSG_COUNT
int "Maximum number of simultaneous outgoing segmented messages"
default 1
range 1 BT_MESH_ADV_BUF_COUNT
help
Maximum number of simultaneous outgoing multi-segment and/or
reliable messages.
config BT_MESH_RX_SEG_MSG_COUNT
int "Maximum number of simultaneous incoming segmented messages"
default 1
range 1 255
help
Maximum number of simultaneous incoming multi-segment and/or
reliable messages.
config BT_MESH_RX_SDU_MAX
int "Maximum incoming Upper Transport Access PDU length"
default 384
range 36 384
help
Maximum incoming Upper Transport Access PDU length. Leave this
to the default value, unless you really need to optimize memory
usage.
config BT_MESH_RELAY
bool "Relay support"
help
Support for acting as a Mesh Relay Node.
config BT_MESH_LOW_POWER
bool "Support for Low Power features"
help
Enable this option to be able to act as a Low Power Node.
if BT_MESH_LOW_POWER
config BT_MESH_LPN_ESTABLISHMENT
bool "Perform Friendship establishment using low power"
default y
help
Perform the Friendship establishment using low power, with
the help of a reduced scan duty cycle. The downside of this
is that the node may miss out on messages intended for it
until it has successfully set up Friendship with a Friend
node.
config BT_MESH_LPN_AUTO
bool "Automatically start looking for Friend nodes once provisioned"
default y
help
Automatically enable LPN functionality once provisioned and start
looking for Friend nodes. If this option is disabled LPN mode
needs to be manually enabled by calling bt_mesh_lpn_set(true).
config BT_MESH_LPN_AUTO_TIMEOUT
int "Time from last received message before going to LPN mode"
default 15
range 0 3600
depends on BT_MESH_LPN_AUTO
help
Time in seconds from the last received message, that the node
will wait before starting to look for Friend nodes.
config BT_MESH_LPN_RETRY_TIMEOUT
int "Retry timeout for Friend requests"
default 8
range 1 3600
help
Time in seconds between Friend Requests, if a previous Friend
Request did not receive any acceptable Friend Offers.
config BT_MESH_LPN_RSSI_FACTOR
int "RSSIFactor, used in the Friend Offer Delay calculation"
range 0 3
default 0
help
The contribution of the RSSI measured by the Friend node used
in Friend Offer Delay calculations. 0 = 1, 1 = 1.5, 2 = 2, 3 = 2.5.
config BT_MESH_LPN_RECV_WIN_FACTOR
int "ReceiveWindowFactor, used in the Friend Offer Delay calculation"
range 0 3
default 0
help
The contribution of the supported Receive Window used in
Friend Offer Delay calculations. 0 = 1, 1 = 1.5, 2 = 2, 3 = 2.5.
config BT_MESH_LPN_MIN_QUEUE_SIZE
int "Minimum size of acceptable friend queue (MinQueueSizeLog)"
range 1 7
default 1
help
The MinQueueSizeLog field is defined as log_2(N), where N is
the minimum number of maximum size Lower Transport PDUs that
the Friend node can store in its Friend Queue. As an example,
MinQueueSizeLog value 1 gives N = 2, and value 7 gives N = 128.
config BT_MESH_LPN_RECV_DELAY
int "Receive delay requested by the local node"
range 10 255
default 100
help
The ReceiveDelay is the time between the Low Power node
sending a request and listening for a response. This delay
allows the Friend node time to prepare the response. The value
is in units of milliseconds.
config BT_MESH_LPN_POLL_TIMEOUT
int "The value of the PollTimeout timer"
range 10 244735
default 300
help
PollTimeout timer is used to measure time between two
consecutive requests sent by the Low Power node. If no
requests are received by the Friend node before the
PollTimeout timer expires, then the friendship is considered
terminated. The value is in units of 100 milliseconds, so e.g.
a value of 300 means 30 seconds.
config BT_MESH_LPN_INIT_POLL_TIMEOUT
int "The starting value of the PollTimeout timer"
range 10 BT_MESH_LPN_POLL_TIMEOUT
default BT_MESH_LPN_POLL_TIMEOUT
help
The initial value of the PollTimeout timer when Friendship
gets established for the first time. After this the timeout
will gradually grow toward the actual PollTimeout, doubling
in value for each iteration. The value is in units of 100
milliseconds, so e.g. a value of 300 means 30 seconds.
config BT_MESH_LPN_SCAN_LATENCY
int "Latency for enabling scanning"
range 0 50
default 10
help
Latency in milliseconds that it takes to enable scanning. This
is in practice how much time in advance before the Receive Window
that scanning is requested to be enabled.
config BT_MESH_LPN_GROUPS
int "Number of groups the LPN can subscribe to"
range 0 16384
default 8
help
Maximum number of groups that the LPN can subscribe to.
endif # BT_MESH_LOW_POWER
config BT_MESH_FRIEND
bool "Support for acting as a Friend Node"
help
Enable this option to be able to act as a Friend Node.
if BT_MESH_FRIEND
config BT_MESH_FRIEND_RECV_WIN
int "Friend Receive Window"
range 1 255
default 255
help
Receive Window in milliseconds supported by the Friend node.
config BT_MESH_FRIEND_QUEUE_SIZE
int "Minimum number of buffers supported per Friend Queue"
range 2 65536
default 16
help
Minimum number of buffers available to be stored for each
local Friend Queue.
config BT_MESH_FRIEND_SUB_LIST_SIZE
int "Friend Subscription List Size"
range 0 1023
default 3
help
Size of the Subscription List that can be supported by a
Friend node for a Low Power node.
config BT_MESH_FRIEND_LPN_COUNT
int "Number of supported LPN nodes"
range 1 1000
default 2
help
Number of Low Power Nodes the Friend can have a Friendship
with simultaneously.
config BT_MESH_FRIEND_SEG_RX
int "Number of incomplete segment lists per LPN"
range 1 1000
default 1
help
Number of incomplete segment lists that we track for each LPN
that we are Friends for. In other words, this determines how
many elements we can simultaneously be receiving segmented
messages from when the messages are going into the Friend queue.
endif # BT_MESH_FRIEND
config BT_MESH_CFG_CLI
bool "Support for Configuration Client Model"
help
Enable support for the configuration client model.
config BT_MESH_HEALTH_CLI
bool "Support for Health Client Model"
help
Enable support for the health client model.
config BT_MESH_SHELL
bool "Enable Bluetooth Mesh shell"
select CONSOLE_SHELL
depends on BT_MESH_CFG_CLI
depends on BT_MESH_HEALTH_CLI
help
Activate shell module that provides Bluetooth Mesh commands to
the console.
config BT_MESH_DEBUG
bool "Enable debug logs"
depends on BT_DEBUG
help
Use this option to enable debug logs for the Bluetooth
Mesh functionality.
if BT_MESH_DEBUG
config BT_MESH_DEBUG_NET
bool "Network layer debug"
help
Use this option to enable Network layer debug logs for the
Bluetooth Mesh functionality.
config BT_MESH_DEBUG_TRANS
bool "Transport layer debug"
help
Use this option to enable Transport layer debug logs for the
Bluetooth Mesh functionality.
config BT_MESH_DEBUG_BEACON
bool "Beacon debug"
help
Use this option to enable Beacon-related debug logs for the
Bluetooth Mesh functionality.
config BT_MESH_DEBUG_CRYPTO
bool "Crypto debug"
help
Use this option to enable cryptographic debug logs for the
Bluetooth Mesh functionality.
config BT_MESH_DEBUG_PROV
bool "Provisioning debug"
help
Use this option to enable Provisioning debug logs for the
Bluetooth Mesh functionality.
config BT_MESH_DEBUG_ACCESS
bool "Access layer debug"
help
Use this option to enable Access layer and device composition
related debug logs for Bluetooth Mesh.
config BT_MESH_DEBUG_MODEL
bool "Foundation model debug"
help
Use this option to enable debug logs for the Foundation
Models.
config BT_MESH_DEBUG_ADV
bool "Advertising debug"
help
Use this option to enable advertising debug logs for
the Bluetooth Mesh functionality.
config BT_MESH_DEBUG_LOW_POWER
bool "Low Power debug"
help
Use this option to enable Low Power debug logs for the
Bluetooth Mesh functionality.
config BT_MESH_DEBUG_FRIEND
bool "Friend debug"
help
Use this option to enable Friend debug logs for the
Bluetooth Mesh functionality.
config BT_MESH_DEBUG_PROXY
bool "Proxy debug"
depends on BT_MESH_PROXY
help
Use this option to enable Proxy protocol debug logs.
endif # BT_MESH_DEBUG
endif # BT_MESH

View File

@@ -6,19 +6,20 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "errno.h"
#include "mesh_util.h"
#include <stdint.h>
#include <stdbool.h>
#include <errno.h>
#include "mesh_buf.h"
#include "sdkconfig.h"
#if CONFIG_BT_MESH
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_ACCESS)
#include "mesh_util.h"
#include "mesh_buf.h"
#include "mesh_trace.h"
#include "mesh_kernel.h"
#include "mesh_access.h"
#include "mesh_main.h"
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_ACCESS)
#include "mesh.h"
#include "adv.h"
#include "net.h"
@@ -27,16 +28,14 @@
#include "access.h"
#include "foundation.h"
#include "mesh_common.h"
#include "generic_client.h"
#include "sensor_client.h"
#include "time_scene_client.h"
#include "light_client.h"
#include "lighting_client.h"
#include "provisioner_main.h"
#include "common.h"
#define CODE_UNREACHABLE BT_ERR("The op_code not defined.");
#define BT_MESH_SDU_MAX_LEN 384
#define BLE_MESH_SDU_MAX_LEN 384
static const struct bt_mesh_comp *dev_comp;
static u16_t dev_primary_addr;
@@ -45,64 +44,64 @@ static const struct {
const u16_t id;
int (*const init)(struct bt_mesh_model *model, bool primary);
} model_init[] = {
{ BT_MESH_MODEL_ID_CFG_SRV, bt_mesh_cfg_srv_init },
{ BT_MESH_MODEL_ID_HEALTH_SRV, bt_mesh_health_srv_init },
#if defined(CONFIG_BT_MESH_CFG_CLI)
{ BT_MESH_MODEL_ID_CFG_CLI, bt_mesh_cfg_cli_init },
{ BLE_MESH_MODEL_ID_CFG_SRV, bt_mesh_cfg_srv_init },
{ BLE_MESH_MODEL_ID_HEALTH_SRV, bt_mesh_health_srv_init },
#if defined(CONFIG_BLE_MESH_CFG_CLI)
{ BLE_MESH_MODEL_ID_CFG_CLI, bt_mesh_cfg_cli_init },
#endif
#if defined(CONFIG_BT_MESH_HEALTH_CLI)
{ BT_MESH_MODEL_ID_HEALTH_CLI, bt_mesh_health_cli_init },
#if defined(CONFIG_BLE_MESH_HEALTH_CLI)
{ BLE_MESH_MODEL_ID_HEALTH_CLI, bt_mesh_health_cli_init },
#endif
#if defined(CONFIG_BT_MESH_GENERIC_ONOFF_CLI)
{ BT_MESH_MODEL_ID_GEN_ONOFF_CLI, bt_mesh_gen_onoff_cli_init },
#if defined(CONFIG_BLE_MESH_GENERIC_ONOFF_CLI)
{ BLE_MESH_MODEL_ID_GEN_ONOFF_CLI, bt_mesh_gen_onoff_cli_init },
#endif
#if defined(CONFIG_BT_MESH_GENERIC_LEVEL_CLI)
{ BT_MESH_MODEL_ID_GEN_LEVEL_CLI, bt_mesh_gen_level_cli_init },
#if defined(CONFIG_BLE_MESH_GENERIC_LEVEL_CLI)
{ BLE_MESH_MODEL_ID_GEN_LEVEL_CLI, bt_mesh_gen_level_cli_init },
#endif
#if defined(CONFIG_BT_MESH_GENERIC_DEF_TRANS_TIME_CLI)
{ BT_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_CLI, bt_mesh_gen_def_trans_time_cli_init },
#if defined(CONFIG_BLE_MESH_GENERIC_DEF_TRANS_TIME_CLI)
{ BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_CLI, bt_mesh_gen_def_trans_time_cli_init },
#endif
#if defined(CONFIG_BT_MESH_GENERIC_POWER_ONOFF_CLI)
{ BT_MESH_MODEL_ID_GEN_POWER_ONOFF_CLI, bt_mesh_gen_pwr_onoff_cli_init },
#if defined(CONFIG_BLE_MESH_GENERIC_POWER_ONOFF_CLI)
{ BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_CLI, bt_mesh_gen_pwr_onoff_cli_init },
#endif
#if defined(CONFIG_BT_MESH_GENERIC_POWER_LEVEL_CLI)
{ BT_MESH_MODEL_ID_GEN_POWER_LEVEL_CLI, bt_mesh_gen_pwr_level_cli_init },
#if defined(CONFIG_BLE_MESH_GENERIC_POWER_LEVEL_CLI)
{ BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_CLI, bt_mesh_gen_pwr_level_cli_init },
#endif
#if defined(CONFIG_BT_MESH_GENERIC_BATTERY_CLI)
{ BT_MESH_MODEL_ID_GEN_BATTERY_CLI, bt_mesh_gen_battery_cli_init },
#if defined(CONFIG_BLE_MESH_GENERIC_BATTERY_CLI)
{ BLE_MESH_MODEL_ID_GEN_BATTERY_CLI, bt_mesh_gen_battery_cli_init },
#endif
#if defined(CONFIG_BT_MESH_GENERIC_LOCATION_CLI)
{ BT_MESH_MODEL_ID_GEN_LOCATION_CLI, bt_mesh_gen_location_cli_init },
#if defined(CONFIG_BLE_MESH_GENERIC_LOCATION_CLI)
{ BLE_MESH_MODEL_ID_GEN_LOCATION_CLI, bt_mesh_gen_location_cli_init },
#endif
#if defined(CONFIG_BT_MESH_GENERIC_PROPERTY_CLI)
{ BT_MESH_MODEL_ID_GEN_PROP_CLI, bt_mesh_gen_property_cli_init },
#if defined(CONFIG_BLE_MESH_GENERIC_PROPERTY_CLI)
{ BLE_MESH_MODEL_ID_GEN_PROP_CLI, bt_mesh_gen_property_cli_init },
#endif
#if defined(CONFIG_BT_MESH_SENSOR_CLI)
{ BT_MESH_MODEL_ID_SENSOR_CLI, bt_mesh_sensor_cli_init },
#if defined(CONFIG_BLE_MESH_SENSOR_CLI)
{ BLE_MESH_MODEL_ID_SENSOR_CLI, bt_mesh_sensor_cli_init },
#endif
#if defined(CONFIG_BT_MESH_TIME_CLI)
{ BT_MESH_MODEL_ID_TIME_CLI, bt_mesh_time_cli_init },
#if defined(CONFIG_BLE_MESH_TIME_CLI)
{ BLE_MESH_MODEL_ID_TIME_CLI, bt_mesh_time_cli_init },
#endif
#if defined(CONFIG_BT_MESH_SCENE_CLI)
{ BT_MESH_MODEL_ID_SCENE_CLI, bt_mesh_scene_cli_init },
#if defined(CONFIG_BLE_MESH_SCENE_CLI)
{ BLE_MESH_MODEL_ID_SCENE_CLI, bt_mesh_scene_cli_init },
#endif
#if defined(CONFIG_BT_MESH_SCHEDULER_CLI)
{ BT_MESH_MODEL_ID_SCHEDULER_CLI, bt_mesh_scheduler_cli_init },
#if defined(CONFIG_BLE_MESH_SCHEDULER_CLI)
{ BLE_MESH_MODEL_ID_SCHEDULER_CLI, bt_mesh_scheduler_cli_init },
#endif
#if defined(CONFIG_BT_MESH_LIGHT_LIGHTNESS_CLI)
{ BT_MESH_MODEL_ID_LIGHT_LIGHTNESS_CLI, bt_mesh_light_lightness_cli_init },
#if defined(CONFIG_BLE_MESH_LIGHT_LIGHTNESS_CLI)
{ BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_CLI, bt_mesh_light_lightness_cli_init },
#endif
#if defined(CONFIG_BT_MESH_LIGHT_CTL_CLI)
{ BT_MESH_MODEL_ID_LIGHT_CTL_CLI, bt_mesh_light_ctl_cli_init },
#if defined(CONFIG_BLE_MESH_LIGHT_CTL_CLI)
{ BLE_MESH_MODEL_ID_LIGHT_CTL_CLI, bt_mesh_light_ctl_cli_init },
#endif
#if defined(CONFIG_BT_MESH_LIGHT_HSL_CLI)
{ BT_MESH_MODEL_ID_LIGHT_HSL_CLI, bt_mesh_light_hsl_cli_init },
#if defined(CONFIG_BLE_MESH_LIGHT_HSL_CLI)
{ BLE_MESH_MODEL_ID_LIGHT_HSL_CLI, bt_mesh_light_hsl_cli_init },
#endif
#if defined(CONFIG_BT_MESH_LIGHT_XYL_CLI)
{ BT_MESH_MODEL_ID_LIGHT_XYL_CLI, bt_mesh_light_xyl_cli_init },
#if defined(CONFIG_BLE_MESH_LIGHT_XYL_CLI)
{ BLE_MESH_MODEL_ID_LIGHT_XYL_CLI, bt_mesh_light_xyl_cli_init },
#endif
#if defined(CONFIG_BT_MESH_LIGHT_LC_CLI)
{ BT_MESH_MODEL_ID_LIGHT_LC_CLI, bt_mesh_light_lc_cli_init },
#if defined(CONFIG_BLE_MESH_LIGHT_LC_CLI)
{ BLE_MESH_MODEL_ID_LIGHT_LC_CLI, bt_mesh_light_lc_cli_init },
#endif
};
@@ -136,7 +135,7 @@ s32_t bt_mesh_model_pub_period_get(struct bt_mesh_model *mod)
int period = 0;
if (!mod->pub) {
BT_ERR("%s, model has no publication support", __func__);
BT_ERR("%s, Model has no publication support", __func__);
return 0;
}
@@ -158,7 +157,8 @@ s32_t bt_mesh_model_pub_period_get(struct bt_mesh_model *mod)
period = K_MINUTES((mod->pub->period & BIT_MASK(6)) * 10);
break;
default:
CODE_UNREACHABLE;
BT_ERR("%s, Unknown model publication period", __func__);
return 0;
}
return period >> mod->pub->period_div;
@@ -170,7 +170,7 @@ static s32_t next_period(struct bt_mesh_model *mod)
u32_t elapsed, period;
if (!pub) {
BT_ERR("%s, model has no publication support", __func__);
BT_ERR("%s, Model has no publication support", __func__);
return -ENOTSUP;
}
@@ -184,7 +184,7 @@ static s32_t next_period(struct bt_mesh_model *mod)
BT_DBG("Publishing took %ums", elapsed);
if (elapsed > period) {
BT_WARN("Publication sending took longer than the period");
BT_WARN("%s, Publication sending took longer than the period", __func__);
/* Return smallest positive number since 0 means disabled */
return K_MSEC(1);
}
@@ -200,12 +200,12 @@ static void publish_sent(int err, void *user_data)
BT_DBG("err %d", err);
if (!mod->pub) {
BT_ERR("%s, model has no publication support", __func__);
BT_ERR("%s, Model has no publication support", __func__);
return;
}
if (mod->pub->count) {
delay = BT_MESH_PUB_TRANSMIT_INT(mod->pub->retransmit);
delay = BLE_MESH_PUB_TRANSMIT_INT(mod->pub->retransmit);
} else {
delay = next_period(mod);
}
@@ -225,7 +225,7 @@ static int publish_retransmit(struct bt_mesh_model *mod)
struct net_buf_simple *sdu = NULL;
struct bt_mesh_model_pub *pub = mod->pub;
if (!pub) {
BT_ERR("%s, model has no publication support", __func__);
BT_ERR("%s, Model has no publication support", __func__);
return -ENOTSUP;
}
struct bt_mesh_app_key *key;
@@ -245,6 +245,7 @@ static int publish_retransmit(struct bt_mesh_model *mod)
key = bt_mesh_app_key_find(pub->key);
if (!key) {
BT_ERR("%s, Failed to find AppKey", __func__);
return -EADDRNOTAVAIL;
}
@@ -253,7 +254,7 @@ static int publish_retransmit(struct bt_mesh_model *mod)
ctx.net_idx = key->net_idx;
ctx.app_idx = key->app_idx;
sdu = bt_mesh_alloc_buf(min(BT_MESH_TX_SDU_MAX, BT_MESH_SDU_MAX_LEN));
sdu = bt_mesh_alloc_buf(MIN(BLE_MESH_TX_SDU_MAX, BLE_MESH_SDU_MAX_LEN));
if (!sdu) {
BT_ERR("%s, Failed to allocate memory", __func__);
return -ENOMEM;
@@ -286,7 +287,7 @@ static void mod_publish(struct k_work *work)
if (pub->count) {
err = publish_retransmit(pub->mod);
if (err) {
BT_ERR("Failed to retransmit (err %d)", err);
BT_ERR("%s, Failed to retransmit (err %d)", __func__, err);
pub->count = 0;
@@ -313,13 +314,13 @@ static void mod_publish(struct k_work *work)
*/
err = pub->update(pub->mod);
if (err) {
BT_ERR("Failed to update publication message");
BT_ERR("%s, Failed to update publication message", __func__);
return;
}
err = bt_mesh_model_publish(pub->mod);
if (err) {
BT_ERR("Publishing failed (err %d)", err);
BT_ERR("%s, Publishing failed (err %d)", __func__, err);
}
if (pub->count) {
@@ -341,7 +342,7 @@ static void mod_init(struct bt_mesh_model *mod, struct bt_mesh_elem *elem,
}
for (i = 0; i < ARRAY_SIZE(mod->keys); i++) {
mod->keys[i] = BT_MESH_KEY_UNUSED;
mod->keys[i] = BLE_MESH_KEY_UNUSED;
}
mod->flags = 0;
@@ -414,7 +415,7 @@ void bt_mesh_comp_unprovision(void)
{
BT_DBG("mesh unprovision complete, %s", __func__);
dev_primary_addr = BT_MESH_ADDR_UNASSIGNED;
dev_primary_addr = BLE_MESH_ADDR_UNASSIGNED;
bt_mesh_model_foreach(mod_init, NULL);
}
@@ -429,7 +430,7 @@ struct bt_mesh_model *bt_mesh_model_get(bool vnd, u8_t elem_idx, u8_t mod_idx)
struct bt_mesh_elem *elem;
if (elem_idx >= dev_comp->elem_count) {
BT_ERR("Invalid element index %u", elem_idx);
BT_ERR("%s, Invalid element index %u", __func__, elem_idx);
return NULL;
}
@@ -437,14 +438,14 @@ struct bt_mesh_model *bt_mesh_model_get(bool vnd, u8_t elem_idx, u8_t mod_idx)
if (vnd) {
if (mod_idx >= elem->vnd_model_count) {
BT_ERR("Invalid vendor model index %u", mod_idx);
BT_ERR("%s, Invalid vendor model index %u", __func__, mod_idx);
return NULL;
}
return &elem->vnd_models[mod_idx];
} else {
if (mod_idx >= elem->model_count) {
BT_ERR("Invalid SIG model index %u", mod_idx);
BT_ERR("%s, Invalid SIG model index %u", __func__, mod_idx);
return NULL;
}
@@ -452,7 +453,6 @@ struct bt_mesh_model *bt_mesh_model_get(bool vnd, u8_t elem_idx, u8_t mod_idx)
}
}
u16_t *bt_mesh_model_find_group(struct bt_mesh_model *mod, u16_t addr)
{
int i;
@@ -501,8 +501,8 @@ struct bt_mesh_elem *bt_mesh_elem_find(u16_t addr)
for (i = 0; i < dev_comp->elem_count; i++) {
struct bt_mesh_elem *elem = &dev_comp->elem[i];
if (BT_MESH_ADDR_IS_GROUP(addr) ||
BT_MESH_ADDR_IS_VIRTUAL(addr)) {
if (BLE_MESH_ADDR_IS_GROUP(addr) ||
BLE_MESH_ADDR_IS_VIRTUAL(addr)) {
if (bt_mesh_elem_find_group(elem, addr)) {
return elem;
}
@@ -565,7 +565,7 @@ static int get_opcode(struct net_buf_simple *buf, u32_t *opcode)
case 0x00:
case 0x01:
if (buf->data[0] == 0x7f) {
BT_ERR("Ignoring RFU OpCode");
BT_ERR("%s, Ignoring RFU OpCode", __func__);
return -EINVAL;
}
@@ -573,7 +573,7 @@ static int get_opcode(struct net_buf_simple *buf, u32_t *opcode)
return 0;
case 0x02:
if (buf->len < 2) {
BT_ERR("Too short payload for 2-octet OpCode");
BT_ERR("%s, Too short payload for 2-octet OpCode", __func__);
return -EINVAL;
}
@@ -581,7 +581,7 @@ static int get_opcode(struct net_buf_simple *buf, u32_t *opcode)
return 0;
case 0x03:
if (buf->len < 3) {
BT_ERR("Too short payload for 3-octet OpCode");
BT_ERR("%s, Too short payload for 3-octet OpCode", __func__);
return -EINVAL;
}
@@ -590,23 +590,21 @@ static int get_opcode(struct net_buf_simple *buf, u32_t *opcode)
return 0;
}
/* Change by Espressif, we don't support the CODE_UNREACHABLE macro in ESP-IDF architecture */
return 0xffff;
//CODE_UNREACHABLE;
return -EINVAL;
}
bool bt_mesh_fixed_group_match(u16_t addr)
{
/* Check for fixed group addresses */
switch (addr) {
case BT_MESH_ADDR_ALL_NODES:
case BLE_MESH_ADDR_ALL_NODES:
return true;
case BT_MESH_ADDR_PROXIES:
return (bt_mesh_gatt_proxy_get() == BT_MESH_GATT_PROXY_ENABLED);
case BT_MESH_ADDR_FRIENDS:
return (bt_mesh_friend_get() == BT_MESH_FRIEND_ENABLED);
case BT_MESH_ADDR_RELAYS:
return (bt_mesh_relay_get() == BT_MESH_RELAY_ENABLED);
case BLE_MESH_ADDR_PROXIES:
return (bt_mesh_gatt_proxy_get() == BLE_MESH_GATT_PROXY_ENABLED);
case BLE_MESH_ADDR_FRIENDS:
return (bt_mesh_friend_get() == BLE_MESH_FRIEND_ENABLED);
case BLE_MESH_ADDR_RELAYS:
return (bt_mesh_relay_get() == BLE_MESH_RELAY_ENABLED);
default:
return false;
}
@@ -627,7 +625,7 @@ void bt_mesh_model_recv(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
BT_DBG("len %u: %s", buf->len, bt_hex(buf->data, buf->len));
if (get_opcode(buf, &opcode) < 0) {
BT_WARN("Unable to decode OpCode");
BT_WARN("%s, Unable to decode OpCode", __func__);
return;
}
@@ -637,12 +635,12 @@ void bt_mesh_model_recv(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
for (i = 0; i < dev_comp->elem_count; i++) {
struct bt_mesh_elem *elem = &dev_comp->elem[i];
if (BT_MESH_ADDR_IS_UNICAST(rx->dst)) {
if (BLE_MESH_ADDR_IS_UNICAST(rx->dst)) {
if (elem->addr != rx->dst) {
continue;
}
} else if (BT_MESH_ADDR_IS_GROUP(rx->dst) ||
BT_MESH_ADDR_IS_VIRTUAL(rx->dst)) {
} else if (BLE_MESH_ADDR_IS_GROUP(rx->dst) ||
BLE_MESH_ADDR_IS_VIRTUAL(rx->dst)) {
if (!bt_mesh_elem_find_group(elem, rx->dst)) {
continue;
}
@@ -667,8 +665,7 @@ void bt_mesh_model_recv(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
struct net_buf_simple_state state;
if (buf->len < op->min_len) {
BT_ERR("Too short message for OpCode 0x%08x",
opcode);
BT_ERR("%s, Too short message for OpCode 0x%08x", __func__, opcode);
continue;
}
@@ -699,7 +696,7 @@ void bt_mesh_model_recv(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
op->func(model, &rx->ctx, buf);
net_buf_simple_restore(buf, &state);
} else {
BT_DBG("No OpCode 0x%08x for elem %d", opcode, i);
BT_DBG("No OpCode 0x%08x for element %d", opcode, i);
}
}
}
@@ -737,16 +734,16 @@ static int model_send(struct bt_mesh_model *model,
bool check = false;
u8_t role;
role = bt_mesh_get_msg_role(model, tx->ctx->srv_send);
role = bt_mesh_get_model_role(model, tx->ctx->srv_send);
if (role == ROLE_NVAL) {
BT_ERR("%s: get role fail", __func__);
BT_ERR("%s, Failed to get model role", __func__);
return -EINVAL;
}
#if CONFIG_BT_MESH_NODE && !CONFIG_BT_MESH_PROVISIONER
#if CONFIG_BLE_MESH_NODE && !CONFIG_BLE_MESH_PROVISIONER
if (role == NODE) {
if (!bt_mesh_is_provisioned()) {
BT_ERR("%s: Local node is not yet provisioned", __func__);
BT_ERR("%s, Local node is not yet provisioned", __func__);
return -EAGAIN;
}
if (!bt_mesh_is_provisioner_en()) {
@@ -755,10 +752,10 @@ static int model_send(struct bt_mesh_model *model,
}
#endif
#if !CONFIG_BT_MESH_NODE && CONFIG_BT_MESH_PROVISIONER
#if !CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PROVISIONER
if (role == PROVISIONER) {
if (!provisioner_check_msg_dst_addr(tx->ctx->addr)) {
BT_ERR("%s: check msg dst_addr fail", __func__);
BT_ERR("%s, Failed to check DST", __func__);
return -EINVAL;
}
if (bt_mesh_is_provisioner_en()) {
@@ -767,10 +764,10 @@ static int model_send(struct bt_mesh_model *model,
}
#endif
#if CONFIG_BT_MESH_NODE && CONFIG_BT_MESH_PROVISIONER
#if CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PROVISIONER
if (role == PROVISIONER) {
if (!provisioner_check_msg_dst_addr(tx->ctx->addr)) {
BT_ERR("%s: check msg dst_addr fail", __func__);
BT_ERR("%s, Failed to check DST", __func__);
return -EINVAL;
}
if (bt_mesh_is_provisioner_en()) {
@@ -778,7 +775,7 @@ static int model_send(struct bt_mesh_model *model,
}
} else {
if (!bt_mesh_is_provisioned()) {
BT_ERR("Local node is not yet provisioned");
BT_ERR("%s, Local node is not yet provisioned", __func__);
return -EAGAIN;
}
check = true;
@@ -786,22 +783,22 @@ static int model_send(struct bt_mesh_model *model,
#endif
if (!check) {
BT_ERR("%s: check fail", __func__);
BT_ERR("%s, fail", __func__);
return -EINVAL;
}
if (net_buf_simple_tailroom(msg) < 4) {
BT_ERR("Not enough tailroom for TransMIC");
BT_ERR("%s, Not enough tailroom for TransMIC", __func__);
return -EINVAL;
}
if (msg->len > min(BT_MESH_TX_SDU_MAX, BT_MESH_SDU_MAX_LEN) - 4) {
BT_ERR("The message is too long");
if (msg->len > MIN(BLE_MESH_TX_SDU_MAX, BLE_MESH_SDU_MAX_LEN) - 4) {
BT_ERR("%s, The message is too long", __func__);
return -EMSGSIZE;
}
if (!implicit_bind && !model_has_key(model, tx->ctx->app_idx)) {
BT_ERR("Model not bound to AppKey 0x%04x", tx->ctx->app_idx);
BT_ERR("%s, Model not bound to AppKey 0x%04x", __func__, tx->ctx->app_idx);
return -EINVAL;
}
@@ -816,13 +813,13 @@ int bt_mesh_model_send(struct bt_mesh_model *model,
struct bt_mesh_subnet *sub = NULL;
u8_t role;
role = bt_mesh_get_msg_role(model, ctx->srv_send);
role = bt_mesh_get_model_role(model, ctx->srv_send);
if (role == ROLE_NVAL) {
BT_ERR("%s: get role fail", __func__);
BT_ERR("%s, Failed to get model role", __func__);
return -EINVAL;
}
#if CONFIG_BT_MESH_NODE && !CONFIG_BT_MESH_PROVISIONER
#if CONFIG_BLE_MESH_NODE && !CONFIG_BLE_MESH_PROVISIONER
if (role == NODE) {
if (!bt_mesh_is_provisioner_en()) {
sub = bt_mesh_subnet_get(ctx->net_idx);
@@ -830,7 +827,7 @@ int bt_mesh_model_send(struct bt_mesh_model *model,
}
#endif
#if !CONFIG_BT_MESH_NODE && CONFIG_BT_MESH_PROVISIONER
#if !CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PROVISIONER
if (role == PROVISIONER) {
if (bt_mesh_is_provisioner_en()) {
sub = provisioner_subnet_get(ctx->net_idx);
@@ -838,7 +835,7 @@ int bt_mesh_model_send(struct bt_mesh_model *model,
}
#endif
#if CONFIG_BT_MESH_NODE && CONFIG_BT_MESH_PROVISIONER
#if CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PROVISIONER
if (role == NODE) {
sub = bt_mesh_subnet_get(ctx->net_idx);
} else if (role == PROVISIONER) {
@@ -846,14 +843,14 @@ int bt_mesh_model_send(struct bt_mesh_model *model,
sub = provisioner_subnet_get(ctx->net_idx);
}
} else if (role == FAST_PROV) {
#if CONFIG_BT_MESH_FAST_PROV
#if CONFIG_BLE_MESH_FAST_PROV
sub = get_fast_prov_subnet(ctx->net_idx);
#endif
}
#endif
if (!sub) {
BT_ERR("%s: get sub fail", __func__);
BT_ERR("%s, Failed to get subnet", __func__);
return -EINVAL;
}
@@ -887,15 +884,16 @@ int bt_mesh_model_publish(struct bt_mesh_model *model)
BT_DBG("%s", __func__);
if (!pub) {
BT_ERR("%s, model has no publication support", __func__);
BT_ERR("%s, Model has no publication support", __func__);
return -ENOTSUP;
}
if (pub->addr == BT_MESH_ADDR_UNASSIGNED) {
if (pub->addr == BLE_MESH_ADDR_UNASSIGNED) {
BT_WARN("%s, Unassigned model publish address", __func__);
return -EADDRNOTAVAIL;
}
#if CONFIG_BT_MESH_NODE && !CONFIG_BT_MESH_PROVISIONER
#if CONFIG_BLE_MESH_NODE && !CONFIG_BLE_MESH_PROVISIONER
if (pub->dev_role == NODE) {
if (bt_mesh_is_provisioned()) {
key = bt_mesh_app_key_find(pub->key);
@@ -903,7 +901,7 @@ int bt_mesh_model_publish(struct bt_mesh_model *model)
}
#endif
#if !CONFIG_BT_MESH_NODE && CONFIG_BT_MESH_PROVISIONER
#if !CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PROVISIONER
if (pub->dev_role == PROVISIONER) {
if (bt_mesh_is_provisioner_en()) {
key = provisioner_app_key_find(pub->key);
@@ -911,7 +909,7 @@ int bt_mesh_model_publish(struct bt_mesh_model *model)
}
#endif
#if CONFIG_BT_MESH_NODE && CONFIG_BT_MESH_PROVISIONER
#if CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PROVISIONER
if (pub->dev_role == NODE) {
if (bt_mesh_is_provisioned()) {
key = bt_mesh_app_key_find(pub->key);
@@ -924,21 +922,21 @@ int bt_mesh_model_publish(struct bt_mesh_model *model)
#endif
if (!key) {
BT_ERR("%s: get app key fail", __func__);
BT_ERR("%s, Failed to get AppKey", __func__);
return -EADDRNOTAVAIL;
}
if (pub->msg->len + 4 > min(BT_MESH_TX_SDU_MAX, BT_MESH_SDU_MAX_LEN)) {
BT_ERR("Message does not fit maximum SDU size");
if (pub->msg->len + 4 > MIN(BLE_MESH_TX_SDU_MAX, BLE_MESH_SDU_MAX_LEN)) {
BT_ERR("%s, Message does not fit maximum SDU size", __func__);
return -EMSGSIZE;
}
if (pub->count) {
BT_WARN("Clearing publish retransmit timer");
BT_WARN("%s, Clearing publish retransmit timer", __func__);
k_delayed_work_cancel(&pub->timer);
}
sdu = bt_mesh_alloc_buf(min(BT_MESH_TX_SDU_MAX, BT_MESH_SDU_MAX_LEN));
sdu = bt_mesh_alloc_buf(MIN(BLE_MESH_TX_SDU_MAX, BLE_MESH_SDU_MAX_LEN));
if (!sdu) {
BT_ERR("%s, Failed to allocate memory", __func__);
return -ENOMEM;
@@ -955,7 +953,7 @@ int bt_mesh_model_publish(struct bt_mesh_model *model)
tx.friend_cred = pub->cred;
#if CONFIG_BT_MESH_NODE && !CONFIG_BT_MESH_PROVISIONER
#if CONFIG_BLE_MESH_NODE && !CONFIG_BLE_MESH_PROVISIONER
if (pub->dev_role == NODE) {
if (bt_mesh_is_provisioned()) {
tx.sub = bt_mesh_subnet_get(ctx.net_idx);
@@ -963,7 +961,7 @@ int bt_mesh_model_publish(struct bt_mesh_model *model)
}
#endif
#if !CONFIG_BT_MESH_NODE && CONFIG_BT_MESH_PROVISIONER
#if !CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PROVISIONER
if (pub->dev_role == PROVISIONER) {
if (bt_mesh_is_provisioner_en()) {
tx.sub = provisioner_subnet_get(ctx.net_idx);
@@ -971,7 +969,7 @@ int bt_mesh_model_publish(struct bt_mesh_model *model)
}
#endif
#if CONFIG_BT_MESH_NODE && CONFIG_BT_MESH_PROVISIONER
#if CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PROVISIONER
if (pub->dev_role == NODE) {
if (bt_mesh_is_provisioned()) {
tx.sub = bt_mesh_subnet_get(ctx.net_idx);
@@ -984,15 +982,15 @@ int bt_mesh_model_publish(struct bt_mesh_model *model)
#endif
if (!tx.sub) {
BT_ERR("%s: Failed to get subnet", __func__);
BT_ERR("%s, Failed to get subnet", __func__);
bt_mesh_free_buf(sdu);
return -EADDRNOTAVAIL;
}
pub->count = BT_MESH_PUB_TRANSMIT_COUNT(pub->retransmit);
pub->count = BLE_MESH_PUB_TRANSMIT_COUNT(pub->retransmit);
BT_DBG("Publish Retransmit Count %u Interval %ums", pub->count,
BT_MESH_PUB_TRANSMIT_INT(pub->retransmit));
BLE_MESH_PUB_TRANSMIT_INT(pub->retransmit));
err = model_send(model, &tx, true, sdu, &pub_sent_cb, model);
if (err) {
@@ -1036,4 +1034,3 @@ const struct bt_mesh_comp *bt_mesh_comp_get(void)
{
return dev_comp;
}
#endif /* CONFIG_BT_MESH */

View File

@@ -13,13 +13,11 @@
#include "mesh_buf.h"
#include "net.h"
#if CONFIG_BT_MESH
/* bt_mesh_model.flags */
enum {
BT_MESH_MOD_BIND_PENDING = BIT(0),
BT_MESH_MOD_SUB_PENDING = BIT(1),
BT_MESH_MOD_PUB_PENDING = BIT(2),
BLE_MESH_MOD_BIND_PENDING = BIT(0),
BLE_MESH_MOD_SUB_PENDING = BIT(1),
BLE_MESH_MOD_PUB_PENDING = BIT(2),
};
void bt_mesh_elem_register(struct bt_mesh_elem *elem, u8_t count);
@@ -58,5 +56,5 @@ const struct bt_mesh_comp *bt_mesh_comp_get(void);
void bt_mesh_model_recv(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf);
int bt_mesh_comp_register(const struct bt_mesh_comp *comp);
#endif /* #if CONFIG_BT_MESH */
#endif /* #ifndef _ACCESS_H_ */
#endif /* _ACCESS_H_ */

View File

@@ -7,46 +7,35 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include "freertos/xtensa_api.h"
#include "freertos/FreeRTOSConfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/queue.h"
#include "freertos/task.h"
#include "sdkconfig.h"
#if CONFIG_BT_MESH
#include "osi/thread.h"
#include "sdkconfig.h"
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_ADV)
#include "mesh_util.h"
#include "mesh_buf.h"
#include "mesh.h"
#include "mesh_bearer_adapt.h"
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_ADV)
#include "mesh_trace.h"
#include "mesh_hci.h"
#include "mesh.h"
#include "adv.h"
#include "foundation.h"
#include "net.h"
#include "beacon.h"
#include "prov.h"
#include "proxy.h"
#include "mesh_hci.h"
#include "sdkconfig.h"
#include "provisioner_prov.h"
#include "provisioner_proxy.h"
#include "provisioner_beacon.h"
#define BT_DATA_MESH_PROV 0x29 /* Mesh Provisioning PDU */
#define BT_DATA_MESH_MESSAGE 0x2a /* Mesh Networking PDU */
#define BT_DATA_MESH_BEACON 0x2b /* Mesh Beacon */
/* Window and Interval are equal for continuous scanning */
#define MESH_SCAN_INTERVAL 0x20//0x10 /*Change the scan interval to 20ms here just to reduce the packet loss rate */
#define MESH_SCAN_WINDOW 0x20//0x10 /*Change the scan window to 20ms here just to reduce the packet loss rate */
#define BLE_MESH_SCAN_INTERVAL 0x20 /*Change the scan interval to 20ms here just to reduce the packet loss rate */
#define BLE_MESH_SCAN_WINDOW 0x20 /*Change the scan window to 20ms here just to reduce the packet loss rate */
/* Convert from ms to 0.625ms units */
#define ADV_INT(_ms) ((_ms) * 8 / 5)
@@ -67,18 +56,18 @@
#endif
static xQueueHandle xBleMeshQueue = 0;
static const bt_addr_le_t *dev_addr;
static const bt_mesh_addr_t *dev_addr;
static const u8_t adv_type[] = {
[BT_MESH_ADV_PROV] = BT_DATA_MESH_PROV,
[BT_MESH_ADV_DATA] = BT_DATA_MESH_MESSAGE,
[BT_MESH_ADV_BEACON] = BT_DATA_MESH_BEACON,
[BLE_MESH_ADV_PROV] = BLE_MESH_DATA_MESH_PROV,
[BLE_MESH_ADV_DATA] = BLE_MESH_DATA_MESH_MESSAGE,
[BLE_MESH_ADV_BEACON] = BLE_MESH_DATA_MESH_BEACON,
};
NET_BUF_POOL_DEFINE(adv_buf_pool, CONFIG_BT_MESH_ADV_BUF_COUNT + 3 * CONFIG_BT_MESH_PBA_SAME_TIME,
BT_MESH_ADV_DATA_SIZE, BT_MESH_ADV_USER_DATA_SIZE, NULL);
NET_BUF_POOL_DEFINE(adv_buf_pool, CONFIG_BLE_MESH_ADV_BUF_COUNT + 3 * CONFIG_BLE_MESH_PBA_SAME_TIME,
BLE_MESH_ADV_DATA_SIZE, BLE_MESH_ADV_USER_DATA_SIZE, NULL);
static struct bt_mesh_adv adv_pool[CONFIG_BT_MESH_ADV_BUF_COUNT + 3 * CONFIG_BT_MESH_PBA_SAME_TIME];
static struct bt_mesh_adv adv_pool[CONFIG_BLE_MESH_ADV_BUF_COUNT + 3 * CONFIG_BLE_MESH_PBA_SAME_TIME];
static struct bt_mesh_adv *adv_alloc(int id)
{
@@ -104,37 +93,36 @@ static inline void adv_send_end(int err, const struct bt_mesh_send_cb *cb,
static inline int adv_send(struct net_buf *buf)
{
const s32_t adv_int_min = ((bt_dev.hci_version >= BT_HCI_VERSION_5_0) ?
const s32_t adv_int_min = ((bt_mesh_dev.hci_version >= BLE_MESH_HCI_VERSION_5_0) ?
ADV_INT_FAST : ADV_INT_DEFAULT);
const struct bt_mesh_send_cb *cb = BT_MESH_ADV(buf)->cb;
void *cb_data = BT_MESH_ADV(buf)->cb_data;
struct bt_le_adv_param param;
const struct bt_mesh_send_cb *cb = BLE_MESH_ADV(buf)->cb;
void *cb_data = BLE_MESH_ADV(buf)->cb_data;
struct bt_mesh_adv_param param = {0};
struct bt_mesh_adv_data ad = {0};
u16_t duration, adv_int;
struct bt_data ad;
int err;
adv_int = max(adv_int_min, BT_MESH_ADV(buf)->adv_int);
duration = (BT_MESH_ADV(buf)->count + 1) * (adv_int + 10);
adv_int = MAX(adv_int_min, BLE_MESH_ADV(buf)->adv_int);
duration = (BLE_MESH_ADV(buf)->count + 1) * (adv_int + 10);
BT_DBG("type %u len %u: %s", BT_MESH_ADV(buf)->type,
BT_DBG("type %u len %u: %s", BLE_MESH_ADV(buf)->type,
buf->len, bt_hex(buf->data, buf->len));
BT_DBG("count %u interval %ums duration %ums",
BT_MESH_ADV(buf)->count + 1, adv_int, duration);
BLE_MESH_ADV(buf)->count + 1, adv_int, duration);
ad.type = adv_type[BT_MESH_ADV(buf)->type];
ad.type = adv_type[BLE_MESH_ADV(buf)->type];
ad.data_len = buf->len;
ad.data = buf->data;
param.options = 0;
param.interval_min = ADV_INT(adv_int);
param.interval_max = param.interval_min;
param.own_addr = NULL;
err = bt_le_adv_start(&param, &ad, 1, NULL, 0);
net_buf_unref(buf);
adv_send_start(duration, err, cb, cb_data);
if (err) {
BT_ERR("Advertising failed: err %d", err);
BT_ERR("%s, Failed to start advertising, err %d", __func__, err);
return err;
}
@@ -145,7 +133,7 @@ static inline int adv_send(struct net_buf *buf)
err = bt_le_adv_stop();
adv_send_end(err, cb, cb_data);
if (err) {
BT_ERR("Stopping advertising failed: err %d", err);
BT_ERR("%s, Faile to stop advertising, err %d", __func__, err);
/* If start adv successfully but stop failed, we think the data has been sent successfully */
return 0;
}
@@ -158,23 +146,26 @@ static inline int adv_send(struct net_buf *buf)
* FreeRTOS task implementation to use on ESP-IDF */
static void adv_thread(void *p)
{
BT_DBG("started");
struct net_buf **buf = NULL;
bt_mesh_msg_t msg = {0};
int status;
struct net_buf **buf;
ble_mesh_msg_t msg = {0};
BT_DBG("ADV thread starts");
buf = (struct net_buf **)(&msg.arg);
while (1) {
*buf = NULL;
#if CONFIG_BT_MESH_NODE
if (IS_ENABLED(CONFIG_BT_MESH_PROXY)) {
#if CONFIG_BLE_MESH_NODE
if (IS_ENABLED(CONFIG_BLE_MESH_PROXY)) {
xQueueReceive(xBleMeshQueue, &msg, K_NO_WAIT);
while (!(*buf)) {
s32_t timeout;
BT_DBG("========");
BT_DBG("Proxy advertising start");
timeout = bt_mesh_proxy_adv_start();
BT_DBG("=========Proxy Advertising up to %d ms", timeout);
BT_DBG("Proxy Advertising up to %d ms", timeout);
xQueueReceive(xBleMeshQueue, &msg, timeout);
BT_DBG("Proxy advertising stop");
bt_mesh_proxy_adv_stop();
}
} else {
@@ -189,16 +180,15 @@ static void adv_thread(void *p)
}
/* busy == 0 means this was canceled */
if (BT_MESH_ADV(*buf)->busy) {
BT_MESH_ADV(*buf)->busy = 0;
if (BLE_MESH_ADV(*buf)->busy) {
BLE_MESH_ADV(*buf)->busy = 0;
/*TODO: Currently we check status of adv_send, which has changed the original
* code of Zephyr, we need to find a better way in the future
* */
status = adv_send(*buf);
if (status) {
status = xQueueSendToFront(xBleMeshQueue, &msg, K_NO_WAIT);
if (status) {
BT_ERR("adv_send, xQueueSendToFront failed, status=0x%x", status);
if (xQueueSendToFront(xBleMeshQueue, &msg, K_NO_WAIT) != pdTRUE) {
BT_ERR("%s, xQueueSendToFront failed", __func__);
}
}
}
@@ -210,11 +200,10 @@ static void adv_thread(void *p)
void bt_mesh_adv_update(void)
{
bt_mesh_msg_t msg = {0};
BT_DBG("%s", __func__);
ble_mesh_msg_t msg = {0};
msg.arg = NULL;
// Change by Espressif, should used the QueueSend in the ESP-IDF architecture.
ble_mesh_task_post(&msg, 0);
bt_mesh_task_post(&msg, 0);
}
struct net_buf *bt_mesh_adv_create_from_pool(struct net_buf_pool *pool,
@@ -233,16 +222,17 @@ struct net_buf *bt_mesh_adv_create_from_pool(struct net_buf_pool *pool,
BT_DBG("%s, pool_id = %p, buf_count = %d, uinit_count = %d", __func__,
buf->pool_id, pool->buf_count, pool->uninit_count);
// adv = get_id(pool->buf_count - pool->uninit_count);
/* Change by Espressif. Use buf->index to get corresponding adv_pool */
adv = get_id(buf->index);
BT_MESH_ADV(buf) = adv;
BLE_MESH_ADV(buf) = adv;
memset(adv, 0, sizeof(*adv));
adv->type = type;
adv->count = xmit_count;
adv->adv_int = xmit_int;
adv->type = type;
adv->count = xmit_count;
adv->adv_int = xmit_int;
return buf;
}
@@ -254,48 +244,44 @@ struct net_buf *bt_mesh_adv_create(enum bt_mesh_adv_type type, u8_t xmit_count,
xmit_count, xmit_int, timeout);
}
void ble_mesh_task_post(ble_mesh_msg_t *msg, uint32_t timeout)
void bt_mesh_task_post(bt_mesh_msg_t *msg, uint32_t timeout)
{
BT_DBG("%s", __func__);
if (xQueueSend(xBleMeshQueue, msg, timeout) != pdTRUE) {
BT_ERR("Ble Mesh Post failed\n");
return;
BT_ERR("%s, Failed to post msg to queue", __func__);
}
}
void bt_mesh_adv_send(struct net_buf *buf, const struct bt_mesh_send_cb *cb,
void *cb_data)
{
ble_mesh_msg_t msg = {0};
struct net_buf *send_buf = NULL;
BT_DBG("type 0x%02x len %u: %s", BT_MESH_ADV(buf)->type, buf->len,
bt_hex(buf->data, buf->len));
bt_mesh_msg_t msg = {0};
BT_MESH_ADV(buf)->cb = cb;
BT_MESH_ADV(buf)->cb_data = cb_data;
BT_MESH_ADV(buf)->busy = 1;
send_buf = net_buf_ref(buf);
msg.arg = (void *)send_buf;
//net_buf_put(NULL, net_buf_ref(buf));
BT_DBG("type 0x%02x len %u: %s", BLE_MESH_ADV(buf)->type, buf->len,
bt_hex(buf->data, buf->len));
BLE_MESH_ADV(buf)->cb = cb;
BLE_MESH_ADV(buf)->cb_data = cb_data;
BLE_MESH_ADV(buf)->busy = 1;
msg.arg = (void *)net_buf_ref(buf);
/* Change by Espressif. The ESP-IDF should used the QueueSend to sent the msg. */
ble_mesh_task_post(&msg, portMAX_DELAY);
/* Deleted the net_buf_put function, we don't used it in the ESP-IDF architecture */
//net_buf_put(NULL, net_buf_ref(buf));
bt_mesh_task_post(&msg, portMAX_DELAY);
}
const bt_addr_le_t *bt_mesh_pba_get_addr(void)
const bt_mesh_addr_t *bt_mesh_pba_get_addr(void)
{
return dev_addr;
}
static void bt_mesh_scan_cb(const bt_addr_le_t *addr, s8_t rssi,
static void bt_mesh_scan_cb(const bt_mesh_addr_t *addr, s8_t rssi,
u8_t adv_type, struct net_buf_simple *buf)
{
#if CONFIG_BT_MESH_PROVISIONER && CONFIG_BT_MESH_PB_GATT
#if CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT
u16_t uuid = 0;
#endif
if (adv_type != BT_LE_ADV_NONCONN_IND && adv_type != BT_LE_ADV_IND) {
if (adv_type != BLE_MESH_ADV_NONCONN_IND && adv_type != BLE_MESH_ADV_IND) {
return;
}
@@ -326,8 +312,8 @@ static void bt_mesh_scan_cb(const bt_addr_le_t *addr, s8_t rssi,
#if 0
/* TODO: Check with BLE Mesh BQB test cases */
if ((type == BT_DATA_MESH_PROV || type == BT_DATA_MESH_MESSAGE ||
type == BT_DATA_MESH_BEACON) && (adv_type != BT_LE_ADV_NONCONN_IND)) {
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)) {
BT_DBG("%s, ignore BLE Mesh packet (type 0x%02x) with adv_type 0x%02x",
__func__, type, adv_type);
return;
@@ -335,37 +321,37 @@ static void bt_mesh_scan_cb(const bt_addr_le_t *addr, s8_t rssi,
#endif
switch (type) {
case BT_DATA_MESH_MESSAGE:
bt_mesh_net_recv(buf, rssi, BT_MESH_NET_IF_ADV);
case BLE_MESH_DATA_MESH_MESSAGE:
bt_mesh_net_recv(buf, rssi, BLE_MESH_NET_IF_ADV);
break;
#if CONFIG_BT_MESH_PB_ADV
case BT_DATA_MESH_PROV:
#if CONFIG_BT_MESH_NODE
#if CONFIG_BLE_MESH_PB_ADV
case BLE_MESH_DATA_MESH_PROV:
#if CONFIG_BLE_MESH_NODE
if (!bt_mesh_is_provisioner_en()) {
bt_mesh_pb_adv_recv(buf);
}
#endif
#if CONFIG_BT_MESH_PROVISIONER
#if CONFIG_BLE_MESH_PROVISIONER
if (bt_mesh_is_provisioner_en()) {
provisioner_pb_adv_recv(buf);
}
#endif
break;
#endif /* CONFIG_BT_MESH_PB_ADV */
case BT_DATA_MESH_BEACON:
#if CONFIG_BT_MESH_NODE
#endif /* CONFIG_BLE_MESH_PB_ADV */
case BLE_MESH_DATA_MESH_BEACON:
#if CONFIG_BLE_MESH_NODE
if (!bt_mesh_is_provisioner_en()) {
bt_mesh_beacon_recv(buf);
}
#endif
#if CONFIG_BT_MESH_PROVISIONER
#if CONFIG_BLE_MESH_PROVISIONER
if (bt_mesh_is_provisioner_en()) {
provisioner_beacon_recv(buf);
}
#endif
break;
#if CONFIG_BT_MESH_PROVISIONER && CONFIG_BT_MESH_PB_GATT
case BT_DATA_FLAGS:
#if CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT
case BLE_MESH_DATA_FLAGS:
if (bt_mesh_is_provisioner_en()) {
if (!provisioner_flags_match(buf)) {
BT_DBG("Flags mismatch, ignore this adv pkt");
@@ -373,7 +359,7 @@ static void bt_mesh_scan_cb(const bt_addr_le_t *addr, s8_t rssi,
}
}
break;
case BT_DATA_SERVICE_UUID:
case BLE_MESH_DATA_UUID16_ALL:
if (bt_mesh_is_provisioner_en()) {
uuid = provisioner_srv_uuid_recv(buf);
if (!uuid) {
@@ -382,12 +368,12 @@ static void bt_mesh_scan_cb(const bt_addr_le_t *addr, s8_t rssi,
}
}
break;
case BT_DATA_SERVICE_DATA:
case BLE_MESH_DATA_SVC_DATA16:
if (bt_mesh_is_provisioner_en()) {
provisioner_srv_data_recv(buf, addr, uuid);
}
break;
#endif /* CONFIG_BT_MESH_PROVISIONER && CONFIG_BT_MESH_PB_GATT */
#endif /* CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT */
default:
break;
}
@@ -402,18 +388,18 @@ static void bt_mesh_scan_cb(const bt_addr_le_t *addr, s8_t rssi,
void bt_mesh_adv_init(void)
{
/* Change by Espressif, we should used the FreeRTOS create task method to use task */
xBleMeshQueue = xQueueCreate(150, sizeof(ble_mesh_msg_t));
xTaskCreatePinnedToCore(adv_thread, "BLE_Mesh_Adv_task", 2048, NULL,
xBleMeshQueue = xQueueCreate(150, sizeof(bt_mesh_msg_t));
xTaskCreatePinnedToCore(adv_thread, "BLE_Mesh_ADV_Task", 3072, NULL,
configMAX_PRIORITIES - 7, NULL, TASK_PINNED_TO_CORE);
}
int bt_mesh_scan_enable(void)
{
struct bt_le_scan_param scan_param = {
.type = BT_HCI_LE_SCAN_PASSIVE,
.filter_dup = BT_HCI_LE_SCAN_FILTER_DUP_DISABLE,
.interval = MESH_SCAN_INTERVAL,
.window = MESH_SCAN_WINDOW
struct bt_mesh_scan_param scan_param = {
.type = BLE_MESH_SCAN_PASSIVE,
.filter_dup = BLE_MESH_SCAN_FILTER_DUP_DISABLE,
.interval = BLE_MESH_SCAN_INTERVAL,
.window = BLE_MESH_SCAN_WINDOW
};
BT_DBG("%s", __func__);
@@ -421,14 +407,14 @@ int bt_mesh_scan_enable(void)
return bt_le_scan_start(&scan_param, bt_mesh_scan_cb);
}
#if defined(CONFIG_BT_MESH_USE_DUPLICATE_SCAN)
#if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN)
int bt_mesh_duplicate_scan_enable(void)
{
struct bt_le_scan_param scan_param = {
.type = BT_HCI_LE_SCAN_PASSIVE,
.filter_dup = BT_HCI_LE_SCAN_FILTER_DUP_ENABLE,
.interval = MESH_SCAN_INTERVAL,
.window = MESH_SCAN_WINDOW
struct bt_mesh_scan_param scan_param = {
.type = BLE_MESH_SCAN_PASSIVE,
.filter_dup = BLE_MESH_SCAN_FILTER_DUP_ENABLE,
.interval = BLE_MESH_SCAN_INTERVAL,
.window = BLE_MESH_SCAN_WINDOW
};
BT_DBG("%s", __func__);
@@ -443,5 +429,3 @@ int bt_mesh_scan_disable(void)
return bt_le_scan_stop();
}
#endif /* #if CONFIG_BT_MESH */

View File

@@ -7,28 +7,31 @@
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _ADV_H_
#define _ADV_H_
#include "mesh_bearer_adapt.h"
/* Maximum advertising data payload for a single data type */
#define BT_MESH_ADV_DATA_SIZE 29
#define BLE_MESH_ADV_DATA_SIZE 29
/* The user data is a pointer (4 bytes) to struct bt_mesh_adv */
#define BT_MESH_ADV_USER_DATA_SIZE 4
#define BLE_MESH_ADV_USER_DATA_SIZE 4
#define BT_MESH_ADV(buf) (*(struct bt_mesh_adv **)net_buf_user_data(buf))
#define BLE_MESH_ADV(buf) (*(struct bt_mesh_adv **)net_buf_user_data(buf))
typedef struct ble_mesh_msg {
typedef struct bt_mesh_msg {
uint8_t sig; //event signal
uint8_t aid; //application id
uint8_t pid; //profile id
uint8_t act; //profile action, defined in seprerate header files
void *arg; //param for btc function or function param
} ble_mesh_msg_t;
} bt_mesh_msg_t;
enum bt_mesh_adv_type {
BT_MESH_ADV_PROV,
BT_MESH_ADV_DATA,
BT_MESH_ADV_BEACON,
BLE_MESH_ADV_PROV,
BLE_MESH_ADV_DATA,
BLE_MESH_ADV_BEACON,
};
typedef void (*bt_mesh_adv_func_t)(struct net_buf *buf, u16_t duration,
@@ -38,10 +41,10 @@ struct bt_mesh_adv {
const struct bt_mesh_send_cb *cb;
void *cb_data;
u8_t type: 2,
busy: 1;
u8_t count: 3,
adv_int: 5;
u8_t type: 2,
busy: 1;
u8_t count: 3,
adv_int: 5;
union {
/* Address, used e.g. for Friend Queue messages */
u16_t addr;
@@ -68,7 +71,7 @@ struct net_buf *bt_mesh_adv_create_from_pool(struct net_buf_pool *pool,
void bt_mesh_adv_send(struct net_buf *buf, const struct bt_mesh_send_cb *cb,
void *cb_data);
const bt_addr_le_t *bt_mesh_pba_get_addr(void);
const bt_mesh_addr_t *bt_mesh_pba_get_addr(void);
void bt_mesh_adv_update(void);
@@ -80,5 +83,6 @@ int bt_mesh_duplicate_scan_enable(void);
int bt_mesh_scan_disable(void);
void ble_mesh_task_post(ble_mesh_msg_t *msg, uint32_t timeout);
void bt_mesh_task_post(bt_mesh_msg_t *msg, uint32_t timeout);
#endif /* _ADV_H_ */

View File

@@ -7,37 +7,32 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include <errno.h>
#include <string.h>
#include <errno.h>
#include "sdkconfig.h"
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_BEACON)
#include "mesh_util.h"
#include "mesh_buf.h"
#include "sdkconfig.h"
#include "mesh_main.h"
#if CONFIG_BT_MESH
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_BEACON)
#include "mesh_trace.h"
#include "adv.h"
#include "mesh.h"
#include "adv.h"
#include "net.h"
#include "prov.h"
#include "crypto.h"
#include "beacon.h"
#include "foundation.h"
#include "provisioner_prov.h"
#if CONFIG_BLE_MESH_NODE
#if CONFIG_BT_MESH_NODE
#if defined(CONFIG_BT_MESH_FAST_PROV)
#if defined(CONFIG_BLE_MESH_FAST_PROV)
#define UNPROVISIONED_INTERVAL K_SECONDS(3)
#else
#define UNPROVISIONED_INTERVAL K_SECONDS(5)
#endif /* CONFIG_BT_MESH_FAST_PROV */
#endif /* CONFIG_BLE_MESH_FAST_PROV */
#define PROVISIONED_INTERVAL K_SECONDS(10)
#define BEACON_TYPE_UNPROVISIONED 0x00
@@ -60,7 +55,7 @@ static struct bt_mesh_subnet *cache_check(u8_t data[21])
for (i = 0; i < ARRAY_SIZE(bt_mesh.sub); i++) {
struct bt_mesh_subnet *sub = &bt_mesh.sub[i];
if (sub->net_idx == BT_MESH_KEY_UNUSED) {
if (sub->net_idx == BLE_MESH_KEY_UNUSED) {
continue;
}
@@ -134,7 +129,7 @@ static int secure_beacon_send(void)
struct net_buf *buf;
u32_t time_diff;
if (sub->net_idx == BT_MESH_KEY_UNUSED) {
if (sub->net_idx == BLE_MESH_KEY_UNUSED) {
continue;
}
@@ -144,10 +139,10 @@ static int secure_beacon_send(void)
continue;
}
buf = bt_mesh_adv_create(BT_MESH_ADV_BEACON, PROV_XMIT_COUNT,
buf = bt_mesh_adv_create(BLE_MESH_ADV_BEACON, PROV_XMIT_COUNT,
PROV_XMIT_INT, K_NO_WAIT);
if (!buf) {
BT_ERR("Unable to allocate beacon buffer");
BT_ERR("%s, Unable to allocate beacon buffer", __func__);
return -ENOBUFS;
}
@@ -162,21 +157,18 @@ static int secure_beacon_send(void)
static int unprovisioned_beacon_send(void)
{
#if defined(CONFIG_BT_MESH_PB_ADV)
struct net_buf *buf;
struct bt_mesh_adv *adv;
#if defined(CONFIG_BLE_MESH_PB_ADV)
struct net_buf *buf = NULL;
BT_DBG("%s", __func__);
buf = bt_mesh_adv_create(BT_MESH_ADV_BEACON, UNPROV_XMIT_COUNT,
buf = bt_mesh_adv_create(BLE_MESH_ADV_BEACON, UNPROV_XMIT_COUNT,
UNPROV_XMIT_INT, K_NO_WAIT);
if (!buf) {
BT_ERR("Unable to allocate beacon buffer");
BT_ERR("%s, Unable to allocate beacon buffer", __func__);
return -ENOBUFS;
}
// Change by Espressif, added the following code for the debug used.
adv = BT_MESH_ADV(buf);
BT_DBG("%s, adv->type = %d, adv->count = %d, adv->adv_int = %d", __func__,
adv->type, adv->count, adv->adv_int);
net_buf_add_u8(buf, BEACON_TYPE_UNPROVISIONED);
net_buf_add_mem(buf, bt_mesh_prov_get_uuid(), 16);
@@ -186,7 +178,7 @@ static int unprovisioned_beacon_send(void)
bt_mesh_adv_send(buf, NULL, NULL);
net_buf_unref(buf);
#endif /* CONFIG_BT_MESH_PB_ADV */
#endif /* CONFIG_BLE_MESH_PB_ADV */
return 0;
}
@@ -207,7 +199,7 @@ static void update_beacon_observation(void)
for (i = 0; i < ARRAY_SIZE(bt_mesh.sub); i++) {
struct bt_mesh_subnet *sub = &bt_mesh.sub[i];
if (sub->net_idx == BT_MESH_KEY_UNUSED) {
if (sub->net_idx == BLE_MESH_KEY_UNUSED) {
continue;
}
@@ -219,7 +211,7 @@ static void update_beacon_observation(void)
static void beacon_send(struct k_work *work)
{
/* Don't send anything if there is an active provisioning link */
if (IS_ENABLED(CONFIG_BT_MESH_PROV) && bt_prov_active()) {
if (IS_ENABLED(CONFIG_BLE_MESH_PROV) && bt_prov_active()) {
k_delayed_work_submit(&beacon_timer, UNPROVISIONED_INTERVAL);
return;
}
@@ -231,16 +223,14 @@ static void beacon_send(struct k_work *work)
secure_beacon_send();
/* Only resubmit if beaconing is still enabled */
if (bt_mesh_beacon_get() == BT_MESH_BEACON_ENABLED ||
if (bt_mesh_beacon_get() == BLE_MESH_BEACON_ENABLED ||
bt_mesh.ivu_initiator) {
k_delayed_work_submit(&beacon_timer,
PROVISIONED_INTERVAL);
k_delayed_work_submit(&beacon_timer, PROVISIONED_INTERVAL);
}
} else {
unprovisioned_beacon_send();
k_delayed_work_submit(&beacon_timer, UNPROVISIONED_INTERVAL);
}
}
static void secure_beacon_recv(struct net_buf_simple *buf)
@@ -252,7 +242,7 @@ static void secure_beacon_recv(struct net_buf_simple *buf)
u8_t flags;
if (buf->len < 21) {
BT_ERR("Too short secure beacon (len %u)", buf->len);
BT_ERR("%s, Too short secure beacon (len %u)", __func__, buf->len);
return;
}
@@ -271,8 +261,7 @@ static void secure_beacon_recv(struct net_buf_simple *buf)
iv_index = net_buf_simple_pull_be32(buf);
auth = buf->data;
BT_DBG("flags 0x%02x id %s iv_index 0x%08x",
flags, bt_hex(net_id, 8), iv_index);
BT_DBG("flags 0x%02x id %s iv_index 0x%08x", flags, bt_hex(net_id, 8), iv_index);
sub = bt_mesh_subnet_find(net_id, flags, iv_index, auth, &new_key);
if (!sub) {
@@ -280,7 +269,7 @@ static void secure_beacon_recv(struct net_buf_simple *buf)
return;
}
if (sub->kr_phase == BT_MESH_KR_PHASE_2 && !new_key) {
if (sub->kr_phase == BLE_MESH_KR_PHASE_2 && !new_key) {
BT_WARN("Ignoring Phase 2 KR Update secured using old key");
return;
}
@@ -288,8 +277,8 @@ static void secure_beacon_recv(struct net_buf_simple *buf)
cache_add(data, sub);
/* If there is NetKey0, accept initiation only from it */
if (bt_mesh_subnet_get(BT_MESH_KEY_PRIMARY) &&
sub->net_idx != BT_MESH_KEY_PRIMARY) {
if (bt_mesh_subnet_get(BLE_MESH_KEY_PRIMARY) &&
sub->net_idx != BLE_MESH_KEY_PRIMARY) {
BT_WARN("Ignoring secure beacon on non-primary subnet");
goto update_stats;
}
@@ -298,13 +287,13 @@ static void secure_beacon_recv(struct net_buf_simple *buf)
sub->net_idx, iv_index, bt_mesh.iv_index);
if (bt_mesh.ivu_initiator &&
bt_mesh.iv_update == BT_MESH_IV_UPDATE(flags)) {
bt_mesh.iv_update == BLE_MESH_IV_UPDATE(flags)) {
bt_mesh_beacon_ivu_initiator(false);
}
iv_change = bt_mesh_net_iv_update(iv_index, BT_MESH_IV_UPDATE(flags));
iv_change = bt_mesh_net_iv_update(iv_index, BLE_MESH_IV_UPDATE(flags));
kr_change = bt_mesh_kr_update(sub, BT_MESH_KEY_REFRESH(flags), new_key);
kr_change = bt_mesh_kr_update(sub, BLE_MESH_KEY_REFRESH(flags), new_key);
if (kr_change) {
bt_mesh_net_beacon_update(sub);
}
@@ -318,7 +307,7 @@ static void secure_beacon_recv(struct net_buf_simple *buf)
}
update_stats:
if (bt_mesh_beacon_get() == BT_MESH_BEACON_ENABLED &&
if (bt_mesh_beacon_get() == BLE_MESH_BEACON_ENABLED &&
sub->beacons_cur < 0xff) {
sub->beacons_cur++;
}
@@ -331,7 +320,7 @@ void bt_mesh_beacon_recv(struct net_buf_simple *buf)
BT_DBG("%u bytes: %s", buf->len, bt_hex(buf->data, buf->len));
if (buf->len < 1) {
BT_ERR("Too short beacon");
BT_ERR("%s, Too short beacon", __func__);
return;
}
@@ -344,7 +333,7 @@ void bt_mesh_beacon_recv(struct net_buf_simple *buf)
secure_beacon_recv(buf);
break;
default:
BT_WARN("Unknown beacon type 0x%02x", type);
BT_DBG("Unknown beacon type 0x%02x", type);
break;
}
}
@@ -360,7 +349,7 @@ void bt_mesh_beacon_ivu_initiator(bool enable)
if (enable) {
k_work_submit(&beacon_timer.work);
} else if (bt_mesh_beacon_get() == BT_MESH_BEACON_DISABLED) {
} else if (bt_mesh_beacon_get() == BLE_MESH_BEACON_DISABLED) {
k_delayed_work_cancel(&beacon_timer);
}
}
@@ -377,7 +366,7 @@ void bt_mesh_beacon_enable(void)
for (i = 0; i < ARRAY_SIZE(bt_mesh.sub); i++) {
struct bt_mesh_subnet *sub = &bt_mesh.sub[i];
if (sub->net_idx == BT_MESH_KEY_UNUSED) {
if (sub->net_idx == BLE_MESH_KEY_UNUSED) {
continue;
}
@@ -397,6 +386,4 @@ void bt_mesh_beacon_disable(void)
}
}
#endif /* CONFIG_BT_MESH_NODE */
#endif /* #if CONFIG_BT_MESH */
#endif /* CONFIG_BLE_MESH_NODE */

View File

@@ -6,7 +6,11 @@
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _BEACON_H_
#define _BEACON_H_
void bt_mesh_beacon_enable(void);
void bt_mesh_beacon_disable(void);
void bt_mesh_beacon_ivu_initiator(bool enable);
@@ -17,3 +21,5 @@ void bt_mesh_beacon_create(struct bt_mesh_subnet *sub,
struct net_buf_simple *buf);
void bt_mesh_beacon_init(void);
#endif /* _BEACON_H_ */

View File

@@ -10,22 +10,21 @@
#include <string.h>
#include <errno.h>
#include <stdbool.h>
#include "osi/allocator.h"
#include "sdkconfig.h"
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_MODEL)
#include "mesh_types.h"
#include "mesh_util.h"
#include "mesh_kernel.h"
#include "mesh.h"
#include "sdkconfig.h"
#include "osi/allocator.h"
#if CONFIG_BT_MESH
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_MODEL)
#include "mesh_trace.h"
#include "cfg_cli.h"
#include "mesh.h"
#include "foundation.h"
#include "common.h"
#include "btc_ble_mesh_config_client.h"
#include "mesh_common.h"
#include "btc_ble_mesh_config_model.h"
#define CID_NVAL 0xffff
@@ -85,27 +84,27 @@ static const bt_mesh_client_op_pair_t cfg_op_pair[] = {
static void timeout_handler(struct k_work *work)
{
bt_mesh_config_client_t *client = NULL;
config_internal_data_t *internal = NULL;
bt_mesh_client_node_t *node = NULL;
config_internal_data_t *internal = NULL;
bt_mesh_config_client_t *client = NULL;
bt_mesh_client_node_t *node = NULL;
BT_WARN("Receive configuration status message timeout");
node = CONTAINER_OF(work, bt_mesh_client_node_t, timer.work);
if (!node || !node->ctx.model) {
BT_ERR("%s: node parameter is NULL", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
client = (bt_mesh_config_client_t *)node->ctx.model->user_data;
if (!client) {
BT_ERR("%s: model user_data is NULL", __func__);
BT_ERR("%s, Config Client user_data is NULL", __func__);
return;
}
internal = (config_internal_data_t *)client->internal_data;
if (!internal) {
BT_ERR("%s: internal_data is NULL", __func__);
BT_ERR("%s, Config Client internal_data is NULL", __func__);
return;
}
@@ -122,18 +121,18 @@ static void cfg_client_cancel(struct bt_mesh_model *model,
void *status, size_t len)
{
config_internal_data_t *data = NULL;
bt_mesh_client_node_t *node = NULL;
bt_mesh_client_node_t *node = NULL;
struct net_buf_simple buf = {0};
u8_t evt_type = 0xFF;
if (!model || !ctx) {
BT_ERR("%s: invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
data = (config_internal_data_t *)cli->internal_data;
if (!data) {
BT_ERR("%s: config client internal_data is NULL", __func__);
BT_ERR("%s, Config Client internal_data is NULL", __func__);
return;
}
@@ -253,7 +252,7 @@ static void comp_data_status(struct bt_mesh_model *model,
status.page = net_buf_simple_pull_u8(buf);
status.comp_data = bt_mesh_alloc_buf(buf->len);
if (!status.comp_data) {
BT_ERR("%s: allocate memory for comp_data fail", __func__);
BT_ERR("%s, Failed to allocate memory", __func__);
return;
}
@@ -504,7 +503,7 @@ static void mod_sub_list(struct bt_mesh_model *model,
list.addr = bt_mesh_alloc_buf(buf->len);
if (!list.addr) {
BT_ERR("%s: Failed to allocate memory", __func__);
BT_ERR("%s, Failed to allocate memory", __func__);
return;
}
net_buf_simple_init(list.addr, 0);
@@ -525,7 +524,7 @@ static void net_key_list(struct bt_mesh_model *model,
list.net_idx = bt_mesh_alloc_buf(buf->len);
if (!list.net_idx) {
BT_ERR("%s: Failed to allocate memory", __func__);
BT_ERR("%s, Failed to allocate memory", __func__);
return;
}
net_buf_simple_init(list.net_idx, 0);
@@ -548,7 +547,7 @@ static void app_key_list(struct bt_mesh_model *model,
list.net_idx = net_buf_simple_pull_le16(buf);
list.app_idx = bt_mesh_alloc_buf(buf->len);
if (!list.app_idx) {
BT_ERR("%s: Failed to allocate memory", __func__);
BT_ERR("%s, Failed to allocate memory", __func__);
return;
}
net_buf_simple_init(list.app_idx, 0);
@@ -595,7 +594,7 @@ static void mod_app_list(struct bt_mesh_model *model,
list.app_idx = bt_mesh_alloc_buf(buf->len);
if (!list.app_idx) {
BT_ERR("%s: Failed to allocate memory", __func__);
BT_ERR("%s, Failed to allocate memory", __func__);
return;
}
net_buf_simple_init(list.app_idx, 0);
@@ -671,7 +670,7 @@ const struct bt_mesh_model_op bt_mesh_cfg_cli_op[] = {
{ OP_KRP_STATUS, 4, kr_phase_status },
{ OP_LPN_TIMEOUT_STATUS, 5, lpn_pollto_status },
{ OP_NET_TRANSMIT_STATUS, 1, net_trans_status },
BT_MESH_MODEL_OP_END,
BLE_MESH_MODEL_OP_END,
};
int bt_mesh_cfg_comp_data_get(struct bt_mesh_msg_ctx *ctx, u8_t page)
@@ -690,7 +689,7 @@ int bt_mesh_cfg_comp_data_get(struct bt_mesh_msg_ctx *ctx, u8_t page)
msg, timeout_handler, config_msg_timeout,
true, NULL, NULL);
if (err) {
BT_ERR("%s: send failed (err %d)", __func__, err);
BT_ERR("%s, send failed (err %d)", __func__, err);
}
return err;
@@ -706,7 +705,7 @@ static int get_state_u8(struct bt_mesh_msg_ctx *ctx, u32_t op)
err = bt_mesh_client_send_msg(cli->model, op, ctx, msg, timeout_handler,
config_msg_timeout, true, NULL, NULL);
if (err) {
BT_ERR("%s: send failed (err %d)", __func__, err);
BT_ERR("%s, send failed (err %d)", __func__, err);
}
return err;
@@ -723,7 +722,7 @@ static int set_state_u8(struct bt_mesh_msg_ctx *ctx, u32_t op, u8_t new_val)
err = bt_mesh_client_send_msg(cli->model, op, ctx, msg, timeout_handler,
config_msg_timeout, true, NULL, NULL);
if (err) {
BT_ERR("%s: send failed (err %d)", __func__, err);
BT_ERR("%s, send failed (err %d)", __func__, err);
}
return err;
@@ -808,7 +807,7 @@ int bt_mesh_cfg_relay_get(struct bt_mesh_msg_ctx *ctx)
timeout_handler, config_msg_timeout,
true, NULL, NULL);
if (err) {
BT_ERR("%s: send failed (err %d)", __func__, err);
BT_ERR("%s, send failed (err %d)", __func__, err);
}
return err;
@@ -832,7 +831,7 @@ int bt_mesh_cfg_relay_set(struct bt_mesh_msg_ctx *ctx, u8_t new_relay,
timeout_handler, config_msg_timeout,
true, NULL, NULL);
if (err) {
BT_ERR("%s: send failed (err %d)", __func__, err);
BT_ERR("%s, send failed (err %d)", __func__, err);
}
return err;
@@ -856,7 +855,7 @@ int bt_mesh_cfg_net_key_add(struct bt_mesh_msg_ctx *ctx, u16_t key_net_idx,
timeout_handler, config_msg_timeout,
true, NULL, NULL);
if (err) {
BT_ERR("%s: send failed (err %d)", __func__, err);
BT_ERR("%s, send failed (err %d)", __func__, err);
}
return err;
@@ -880,7 +879,7 @@ int bt_mesh_cfg_app_key_add(struct bt_mesh_msg_ctx *ctx, u16_t key_net_idx,
timeout_handler, config_msg_timeout,
true, NULL, NULL);
if (err) {
BT_ERR("%s: send failed (err %d)", __func__, err);
BT_ERR("%s, send failed (err %d)", __func__, err);
}
return err;
@@ -908,7 +907,7 @@ int bt_mesh_cfg_mod_app_bind(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
timeout_handler, config_msg_timeout,
true, NULL, NULL);
if (err) {
BT_ERR("%s: send failed (err %d)", __func__, err);
BT_ERR("%s, send failed (err %d)", __func__, err);
}
return err;
@@ -931,7 +930,7 @@ static int mod_sub(u32_t op, struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
err = bt_mesh_client_send_msg(cli->model, op, ctx, msg, timeout_handler,
config_msg_timeout, true, NULL, NULL);
if (err) {
BT_ERR("%s: send failed (err %d)", __func__, err);
BT_ERR("%s, send failed (err %d)", __func__, err);
}
return err;
@@ -985,7 +984,7 @@ static int mod_sub_va(u32_t op, struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
err = bt_mesh_client_send_msg(cli->model, op, ctx, msg, timeout_handler,
config_msg_timeout, true, NULL, NULL);
if (err) {
BT_ERR("%s: send failed (err %d)", __func__, err);
BT_ERR("%s, send failed (err %d)", __func__, err);
}
return err;
@@ -1039,7 +1038,7 @@ int bt_mesh_cfg_mod_pub_get(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
timeout_handler, config_msg_timeout,
true, NULL, NULL);
if (err) {
BT_ERR("%s: send failed (err %d)", __func__, err);
BT_ERR("%s, send failed (err %d)", __func__, err);
}
return err;
@@ -1072,7 +1071,7 @@ int bt_mesh_cfg_mod_pub_set(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
timeout_handler, config_msg_timeout,
true, NULL, NULL);
if (err) {
BT_ERR("%s: send failed (err %d)", __func__, err);
BT_ERR("%s, send failed (err %d)", __func__, err);
}
return err;
@@ -1097,7 +1096,7 @@ int bt_mesh_cfg_hb_sub_set(struct bt_mesh_msg_ctx *ctx,
msg, timeout_handler, config_msg_timeout,
true, NULL, NULL);
if (err) {
BT_ERR("%s: send failed (err %d)", __func__, err);
BT_ERR("%s, send failed (err %d)", __func__, err);
}
return err;
@@ -1118,7 +1117,7 @@ int bt_mesh_cfg_hb_sub_get(struct bt_mesh_msg_ctx *ctx)
msg, timeout_handler, config_msg_timeout,
true, NULL, NULL);
if (err) {
BT_ERR("%s: send failed (err %d)", __func__, err);
BT_ERR("%s, send failed (err %d)", __func__, err);
}
return err;
@@ -1146,7 +1145,7 @@ int bt_mesh_cfg_hb_pub_set(struct bt_mesh_msg_ctx *ctx,
msg, timeout_handler, config_msg_timeout,
true, NULL, NULL);
if (err) {
BT_ERR("%s: send failed (err %d)", __func__, err);
BT_ERR("%s, send failed (err %d)", __func__, err);
}
return err;
@@ -1167,7 +1166,7 @@ int bt_mesh_cfg_hb_pub_get(struct bt_mesh_msg_ctx *ctx)
msg, timeout_handler, config_msg_timeout,
true, NULL, NULL);
if (err) {
BT_ERR("%s: send failed (err %d)", __func__, err);
BT_ERR("%s, send failed (err %d)", __func__, err);
}
return err;
@@ -1188,7 +1187,7 @@ int bt_mesh_cfg_node_reset(struct bt_mesh_msg_ctx *ctx)
timeout_handler, config_msg_timeout,
true, NULL, NULL);
if (err) {
BT_ERR("%s: send failed (err %d)", __func__, err);
BT_ERR("%s, send failed (err %d)", __func__, err);
}
return err;
@@ -1221,7 +1220,7 @@ int bt_mesh_cfg_mod_pub_va_set(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
timeout_handler, config_msg_timeout,
true, NULL, NULL);
if (err) {
BT_ERR("%s: send failed (err %d)", __func__, err);
BT_ERR("%s, send failed (err %d)", __func__, err);
}
return err;
@@ -1248,7 +1247,7 @@ int bt_mesh_cfg_mod_sub_del_all(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
timeout_handler, config_msg_timeout,
true, NULL, NULL);
if (err) {
BT_ERR("%s: send failed (err %d)", __func__, err);
BT_ERR("%s, send failed (err %d)", __func__, err);
}
return err;
@@ -1270,7 +1269,7 @@ static int mod_sub_get(u32_t op, struct bt_mesh_msg_ctx *ctx,
err = bt_mesh_client_send_msg(cli->model, op, ctx, msg, timeout_handler,
config_msg_timeout, true, NULL, NULL);
if (err) {
BT_ERR("%s: send failed (err %d)", __func__, err);
BT_ERR("%s, send failed (err %d)", __func__, err);
}
return err;
@@ -1311,7 +1310,7 @@ int bt_mesh_cfg_net_key_update(struct bt_mesh_msg_ctx *ctx, u16_t net_idx,
timeout_handler, config_msg_timeout,
true, NULL, NULL);
if (err) {
BT_ERR("%s: send failed (err %d)", __func__, err);
BT_ERR("%s, send failed (err %d)", __func__, err);
}
return err;
@@ -1333,7 +1332,7 @@ int bt_mesh_cfg_net_key_delete(struct bt_mesh_msg_ctx *ctx, u16_t net_idx)
timeout_handler, config_msg_timeout,
true, NULL, NULL);
if (err) {
BT_ERR("%s: send failed (err %d)", __func__, err);
BT_ERR("%s, send failed (err %d)", __func__, err);
}
return err;
@@ -1354,7 +1353,7 @@ int bt_mesh_cfg_net_key_get(struct bt_mesh_msg_ctx *ctx)
timeout_handler, config_msg_timeout,
true, NULL, NULL);
if (err) {
BT_ERR("%s: send failed (err %d)", __func__, err);
BT_ERR("%s, send failed (err %d)", __func__, err);
}
return err;
@@ -1378,7 +1377,7 @@ int bt_mesh_cfg_app_key_update(struct bt_mesh_msg_ctx *ctx, u16_t net_idx,
timeout_handler, config_msg_timeout,
true, NULL, NULL);
if (err) {
BT_ERR("%s: send failed (err %d)", __func__, err);
BT_ERR("%s, send failed (err %d)", __func__, err);
}
return err;
@@ -1400,7 +1399,7 @@ int bt_mesh_cfg_app_key_delete(struct bt_mesh_msg_ctx *ctx, u16_t net_idx, u16_t
timeout_handler, config_msg_timeout,
true, NULL, NULL);
if (err) {
BT_ERR("%s: send failed (err %d)", __func__, err);
BT_ERR("%s, send failed (err %d)", __func__, err);
}
return err;
@@ -1422,7 +1421,7 @@ int bt_mesh_cfg_app_key_get(struct bt_mesh_msg_ctx *ctx, u16_t net_idx)
timeout_handler, config_msg_timeout,
true, NULL, NULL);
if (err) {
BT_ERR("%s: send failed (err %d)", __func__, err);
BT_ERR("%s, send failed (err %d)", __func__, err);
}
return err;
@@ -1443,7 +1442,7 @@ static int node_identity_op(u32_t op, struct bt_mesh_msg_ctx *ctx,
err = bt_mesh_client_send_msg(cli->model, op, ctx, msg, timeout_handler,
config_msg_timeout, true, NULL, NULL);
if (err) {
BT_ERR("%s: send failed (err %d)", __func__, err);
BT_ERR("%s, send failed (err %d)", __func__, err);
}
return err;
@@ -1487,7 +1486,7 @@ int bt_mesh_cfg_mod_app_unbind(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
timeout_handler, config_msg_timeout,
true, NULL, NULL);
if (err) {
BT_ERR("%s: send failed (err %d)", __func__, err);
BT_ERR("%s, send failed (err %d)", __func__, err);
}
return err;
@@ -1509,7 +1508,7 @@ static int mod_app_get(u32_t op, struct bt_mesh_msg_ctx *ctx,
err = bt_mesh_client_send_msg(cli->model, op, ctx, msg, timeout_handler,
config_msg_timeout, true, NULL, NULL);
if (err) {
BT_ERR("%s: send failed (err %d)", __func__, err);
BT_ERR("%s, send failed (err %d)", __func__, err);
}
return err;
@@ -1547,7 +1546,7 @@ static int kr_phase_op(u32_t op, struct bt_mesh_msg_ctx *ctx,
err = bt_mesh_client_send_msg(cli->model, op, ctx, msg, timeout_handler,
config_msg_timeout, true, NULL, NULL);
if (err) {
BT_ERR("%s: send failed (err %d)", __func__, err);
BT_ERR("%s, send failed (err %d)", __func__, err);
}
return err;
@@ -1585,7 +1584,7 @@ int bt_mesh_cfg_lpn_timeout_get(struct bt_mesh_msg_ctx *ctx, u16_t lpn_addr)
timeout_handler, config_msg_timeout,
true, NULL, NULL);
if (err) {
BT_ERR("%s: send failed (err %d)", __func__, err);
BT_ERR("%s, send failed (err %d)", __func__, err);
}
return err;
@@ -1619,8 +1618,8 @@ void bt_mesh_cfg_cli_timeout_set(s32_t timeout)
int bt_mesh_cfg_cli_init(struct bt_mesh_model *model, bool primary)
{
bt_mesh_config_client_t *client = NULL;
config_internal_data_t *internal = NULL;
config_internal_data_t *internal = NULL;
bt_mesh_config_client_t *client = NULL;
BT_DBG("primary %u", primary);
@@ -1649,17 +1648,15 @@ int bt_mesh_cfg_cli_init(struct bt_mesh_model *model, bool primary)
sys_slist_init(&internal->queue);
client->model = model;
client->op_pair_size = ARRAY_SIZE(cfg_op_pair);
client->op_pair = cfg_op_pair;
client->model = model;
client->op_pair_size = ARRAY_SIZE(cfg_op_pair);
client->op_pair = cfg_op_pair;
client->internal_data = internal;
cli = client;
/* Configuration Model security is device-key based */
model->keys[0] = BT_MESH_KEY_DEV;
model->keys[0] = BLE_MESH_KEY_DEV;
return 0;
}
#endif /* #if CONFIG_BT_MESH */

File diff suppressed because it is too large Load Diff

View File

@@ -10,22 +10,21 @@
#include <string.h>
#include <stdbool.h>
#include <errno.h>
#include "sdkconfig.h"
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_CRYPTO)
#include "mesh_types.h"
#include "mesh_util.h"
#include "sdkconfig.h"
#include "mesh_buf.h"
#if CONFIG_BT_MESH
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_CRYPTO)
#include "mesh_trace.h"
#include "mesh.h"
#include "crypto.h"
#include "mesh_bearer_adapt.h"
#include "mesh_aes_encrypt.h"
#define NET_MIC_LEN(pdu) (((pdu)[1] & 0x80) ? 8 : 4)
#include "mesh.h"
#include "crypto.h"
#define NET_MIC_LEN(pdu) (((pdu)[1] & 0x80) ? 8 : 4)
#define APP_MIC_LEN(aszmic) ((aszmic) ? 8 : 4)
int bt_mesh_aes_cmac(const u8_t key[16], struct bt_mesh_sg *sg,
@@ -216,7 +215,7 @@ static int bt_mesh_ccm_decrypt(const u8_t key[16], u8_t nonce[13],
memcpy(pmsg + 1, nonce, 13);
sys_put_be16(0x0000, pmsg + 14);
err = bt_encrypt_be(key, pmsg, cmic);
err = bt_mesh_encrypt_be(key, pmsg, cmic);
if (err) {
return err;
}
@@ -231,7 +230,7 @@ static int bt_mesh_ccm_decrypt(const u8_t key[16], u8_t nonce[13],
memcpy(pmsg + 1, nonce, 13);
sys_put_be16(msg_len, pmsg + 14);
err = bt_encrypt_be(key, pmsg, Xn);
err = bt_mesh_encrypt_be(key, pmsg, Xn);
if (err) {
return err;
}
@@ -255,7 +254,7 @@ static int bt_mesh_ccm_decrypt(const u8_t key[16], u8_t nonce[13],
aad_len -= 16;
i = 0;
err = bt_encrypt_be(key, pmsg, Xn);
err = bt_mesh_encrypt_be(key, pmsg, Xn);
if (err) {
return err;
}
@@ -269,7 +268,7 @@ static int bt_mesh_ccm_decrypt(const u8_t key[16], u8_t nonce[13],
pmsg[i] = Xn[i];
}
err = bt_encrypt_be(key, pmsg, Xn);
err = bt_mesh_encrypt_be(key, pmsg, Xn);
if (err) {
return err;
}
@@ -288,7 +287,7 @@ static int bt_mesh_ccm_decrypt(const u8_t key[16], u8_t nonce[13],
memcpy(pmsg + 1, nonce, 13);
sys_put_be16(j + 1, pmsg + 14);
err = bt_encrypt_be(key, pmsg, cmsg);
err = bt_mesh_encrypt_be(key, pmsg, cmsg);
if (err) {
return err;
}
@@ -309,7 +308,7 @@ static int bt_mesh_ccm_decrypt(const u8_t key[16], u8_t nonce[13],
pmsg[i] = Xn[i] ^ 0x00;
}
err = bt_encrypt_be(key, pmsg, Xn);
err = bt_mesh_encrypt_be(key, pmsg, Xn);
if (err) {
return err;
}
@@ -324,7 +323,7 @@ static int bt_mesh_ccm_decrypt(const u8_t key[16], u8_t nonce[13],
memcpy(pmsg + 1, nonce, 13);
sys_put_be16(j + 1, pmsg + 14);
err = bt_encrypt_be(key, pmsg, cmsg);
err = bt_mesh_encrypt_be(key, pmsg, cmsg);
if (err) {
return err;
}
@@ -341,7 +340,7 @@ static int bt_mesh_ccm_decrypt(const u8_t key[16], u8_t nonce[13],
pmsg[i] = Xn[i] ^ msg[i];
}
err = bt_encrypt_be(key, pmsg, Xn);
err = bt_mesh_encrypt_be(key, pmsg, Xn);
if (err) {
return err;
}
@@ -380,7 +379,7 @@ static int bt_mesh_ccm_encrypt(const u8_t key[16], u8_t nonce[13],
memcpy(pmsg + 1, nonce, 13);
sys_put_be16(0x0000, pmsg + 14);
err = bt_encrypt_be(key, pmsg, cmic);
err = bt_mesh_encrypt_be(key, pmsg, cmic);
if (err) {
return err;
}
@@ -395,7 +394,7 @@ static int bt_mesh_ccm_encrypt(const u8_t key[16], u8_t nonce[13],
memcpy(pmsg + 1, nonce, 13);
sys_put_be16(msg_len, pmsg + 14);
err = bt_encrypt_be(key, pmsg, Xn);
err = bt_mesh_encrypt_be(key, pmsg, Xn);
if (err) {
return err;
}
@@ -419,7 +418,7 @@ static int bt_mesh_ccm_encrypt(const u8_t key[16], u8_t nonce[13],
aad_len -= 16;
i = 0;
err = bt_encrypt_be(key, pmsg, Xn);
err = bt_mesh_encrypt_be(key, pmsg, Xn);
if (err) {
return err;
}
@@ -433,7 +432,7 @@ static int bt_mesh_ccm_encrypt(const u8_t key[16], u8_t nonce[13],
pmsg[i] = Xn[i];
}
err = bt_encrypt_be(key, pmsg, Xn);
err = bt_mesh_encrypt_be(key, pmsg, Xn);
if (err) {
return err;
}
@@ -455,7 +454,7 @@ static int bt_mesh_ccm_encrypt(const u8_t key[16], u8_t nonce[13],
pmsg[i] = Xn[i] ^ 0x00;
}
err = bt_encrypt_be(key, pmsg, Xn);
err = bt_mesh_encrypt_be(key, pmsg, Xn);
if (err) {
return err;
}
@@ -470,7 +469,7 @@ static int bt_mesh_ccm_encrypt(const u8_t key[16], u8_t nonce[13],
memcpy(pmsg + 1, nonce, 13);
sys_put_be16(j + 1, pmsg + 14);
err = bt_encrypt_be(key, pmsg, cmsg);
err = bt_mesh_encrypt_be(key, pmsg, cmsg);
if (err) {
return err;
}
@@ -486,7 +485,7 @@ static int bt_mesh_ccm_encrypt(const u8_t key[16], u8_t nonce[13],
pmsg[i] = Xn[i] ^ msg[(j * 16) + i];
}
err = bt_encrypt_be(key, pmsg, Xn);
err = bt_mesh_encrypt_be(key, pmsg, Xn);
if (err) {
return err;
}
@@ -496,7 +495,7 @@ static int bt_mesh_ccm_encrypt(const u8_t key[16], u8_t nonce[13],
memcpy(pmsg + 1, nonce, 13);
sys_put_be16(j + 1, pmsg + 14);
err = bt_encrypt_be(key, pmsg, cmsg);
err = bt_mesh_encrypt_be(key, pmsg, cmsg);
if (err) {
return err;
}
@@ -515,7 +514,7 @@ static int bt_mesh_ccm_encrypt(const u8_t key[16], u8_t nonce[13],
return 0;
}
#if defined(CONFIG_BT_MESH_PROXY)
#if defined(CONFIG_BLE_MESH_PROXY)
static void create_proxy_nonce(u8_t nonce[13], const u8_t *pdu,
u32_t iv_index)
{
@@ -583,7 +582,7 @@ int bt_mesh_net_obfuscate(u8_t *pdu, u32_t iv_index,
BT_DBG("PrivacyRandom %s", bt_hex(priv_rand, 16));
err = bt_encrypt_be(privacy_key, priv_rand, tmp);
err = bt_mesh_encrypt_be(privacy_key, priv_rand, tmp);
if (err) {
return err;
}
@@ -606,7 +605,7 @@ int bt_mesh_net_encrypt(const u8_t key[16], struct net_buf_simple *buf,
mic_len);
BT_DBG("PDU (len %u) %s", buf->len, bt_hex(buf->data, buf->len));
#if defined(CONFIG_BT_MESH_PROXY)
#if defined(CONFIG_BLE_MESH_PROXY)
if (proxy) {
create_proxy_nonce(nonce, buf->data, iv_index);
} else {
@@ -637,7 +636,7 @@ int bt_mesh_net_decrypt(const u8_t key[16], struct net_buf_simple *buf,
BT_DBG("iv_index %u, key %s mic_len %u", iv_index, bt_hex(key, 16),
mic_len);
#if defined(CONFIG_BT_MESH_PROXY)
#if defined(CONFIG_BLE_MESH_PROXY)
if (proxy) {
create_proxy_nonce(nonce, buf->data, iv_index);
} else {
@@ -844,7 +843,7 @@ int bt_mesh_prov_decrypt(const u8_t key[16], u8_t nonce[13],
return bt_mesh_ccm_decrypt(key, nonce, data, 25, NULL, 0, out, 8);
}
#if CONFIG_BT_MESH_PROVISIONER
#if CONFIG_BLE_MESH_PROVISIONER
int bt_mesh_prov_encrypt(const u8_t key[16], u8_t nonce[13],
const u8_t data[25], u8_t out[33])
{
@@ -876,5 +875,3 @@ int bt_mesh_beacon_auth(const u8_t beacon_key[16], u8_t flags,
return err;
}
#endif /* #if CONFIG_BT_MESH */

View File

@@ -7,6 +7,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _CRYPTO_H_
#define _CRYPTO_H_
#include "mesh_types.h"
#include <string.h>
@@ -36,10 +39,10 @@ static inline bool bt_mesh_s1(const char *m, u8_t salt[16])
int bt_mesh_k1(const u8_t *ikm, size_t ikm_len, const u8_t salt[16],
const char *info, u8_t okm[16]);
#define bt_mesh_k1_str(ikm, ikm_len, salt_str, info, okm) \
({ \
const u8_t salt[16] = salt_str; \
bt_mesh_k1(ikm, ikm_len, salt, info, okm); \
#define bt_mesh_k1_str(ikm, ikm_len, salt_str, info, okm) \
({ \
const u8_t salt[16] = salt_str; \
bt_mesh_k1(ikm, ikm_len, salt, info, okm); \
})
int bt_mesh_k2(const u8_t n[16], const u8_t *p, size_t p_len,
@@ -157,7 +160,9 @@ int bt_mesh_prov_conf(const u8_t conf_key[16], const u8_t rand[16],
int bt_mesh_prov_decrypt(const u8_t key[16], u8_t nonce[13],
const u8_t data[25 + 8], u8_t out[25]);
#if CONFIG_BT_MESH_PROVISIONER
#if CONFIG_BLE_MESH_PROVISIONER
int bt_mesh_prov_encrypt(const u8_t key[16], u8_t nonce[13],
const u8_t data[25], u8_t out[33]);
#endif
#endif /* _CRYPTO_H_ */

View File

@@ -1,319 +0,0 @@
/*
* Copyright (c) 2017 Intel Corporation
* Additional Copyright (c) 2018 Espressif Systems (Shanghai) PTE LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "dlist.h"
#include "sdkconfig.h"
#if CONFIG_BT_MESH
static sys_dlist_t test_list;
struct container_node {
sys_dnode_t node;
int unused;
};
static struct container_node test_node_1;
static struct container_node test_node_2;
static struct container_node test_node_3;
static struct container_node test_node_4;
static inline bool verify_emptyness(sys_dlist_t *list)
{
sys_dnode_t *node;
sys_dnode_t *s_node;
struct container_node *cnode;
struct container_node *s_cnode;
int count;
if (!sys_dlist_is_empty(list)) {
return false;
}
if (sys_dlist_peek_head(list)) {
return false;
}
if (sys_dlist_peek_tail(list)) {
return false;
}
count = 0;
SYS_DLIST_FOR_EACH_NODE(list, node) {
count++;
}
if (count) {
return false;
}
SYS_DLIST_FOR_EACH_NODE_SAFE(list, node, s_node) {
count++;
}
if (count) {
return false;
}
count = 0;
SYS_DLIST_FOR_EACH_CONTAINER(list, cnode, node) {
count++;
}
if (count) {
return false;
}
count = 0;
SYS_DLIST_FOR_EACH_CONTAINER_SAFE(list, cnode, s_cnode, node) {
count++;
}
if (count) {
return false;
}
return true;
}
static inline bool verify_content_amount(sys_dlist_t *list, int amount)
{
sys_dnode_t *node;
sys_dnode_t *s_node;
struct container_node *cnode;
struct container_node *s_cnode;
int count;
if (sys_dlist_is_empty(list)) {
return false;
}
if (!sys_dlist_peek_head(list)) {
return false;
}
if (!sys_dlist_peek_tail(list)) {
return false;
}
count = 0;
SYS_DLIST_FOR_EACH_NODE(list, node) {
count++;
}
if (count != amount) {
return false;
}
count = 0;
SYS_DLIST_FOR_EACH_NODE_SAFE(list, node, s_node) {
count++;
}
if (count != amount) {
return false;
}
count = 0;
SYS_DLIST_FOR_EACH_CONTAINER(list, cnode, node) {
count++;
}
if (count != amount) {
return false;
}
count = 0;
SYS_DLIST_FOR_EACH_CONTAINER_SAFE(list, cnode, s_cnode, node) {
count++;
}
if (count != amount) {
return false;
}
return true;
}
static inline bool verify_tail_head(sys_dlist_t *list,
sys_dnode_t *head,
sys_dnode_t *tail,
bool same)
{
if (sys_dlist_peek_head(list) != head) {
return false;
}
if (sys_dlist_peek_tail(list) != tail) {
return false;
}
if (same) {
if (sys_dlist_peek_head(list) != sys_dlist_peek_tail(list)) {
return false;
}
} else {
if (sys_dlist_peek_head(list) == sys_dlist_peek_tail(list)) {
return false;
}
}
return true;
}
void dlist_test(void)
{
sys_dlist_init(&test_list);
//zassert_true((verify_emptyness(&test_list)), "test_list should be empty");
/* Appending node 1 */
sys_dlist_append(&test_list, &test_node_1.node);
//zassert_true((verify_content_amount(&test_list, 1)),
// "test_list has wrong content");
//zassert_true((verify_tail_head(&test_list, &test_node_1.node,
// &test_node_1.node, true)),
// "test_list head/tail are wrong");
/* Finding and removing node 1 */
sys_dlist_remove(&test_node_1.node);
//zassert_true((verify_emptyness(&test_list)),
// "test_list should be empty");
/* Prepending node 1 */
sys_dlist_prepend(&test_list, &test_node_1.node);
//zassert_true((verify_content_amount(&test_list, 1)),
// "test_list has wrong content");
//zassert_true((verify_tail_head(&test_list, &test_node_1.node,
// &test_node_1.node, true)),
// "test_list head/tail are wrong");
/* Removing node 1 */
sys_dlist_remove(&test_node_1.node);
//zassert_true((verify_emptyness(&test_list)),
// "test_list should be empty");
/* Appending node 1 */
sys_dlist_append(&test_list, &test_node_1.node);
/* Prepending node 2 */
sys_dlist_prepend(&test_list, &test_node_2.node);
//zassert_true((verify_content_amount(&test_list, 2)),
// "test_list has wrong content");
//zassert_true((verify_tail_head(&test_list, &test_node_2.node,
// &test_node_1.node, false)),
// "test_list head/tail are wrong");
/* Appending node 3 */
sys_dlist_append(&test_list, &test_node_3.node);
//zassert_true((verify_content_amount(&test_list, 3)),
// "test_list has wrong content");
//zassert_true((verify_tail_head(&test_list, &test_node_2.node,
// &test_node_3.node, false)),
// "test_list head/tail are wrong");
//zassert_true((sys_dlist_peek_next(&test_list, &test_node_2.node) ==
// &test_node_1.node),
// "test_list node links are wrong");
/* Inserting node 4 after node 2 */
sys_dlist_insert_after(&test_list, &test_node_2.node,
&test_node_4.node);
//zassert_true((verify_tail_head(&test_list, &test_node_2.node,
// &test_node_3.node, false)),
// "test_list head/tail are wrong");
//zassert_true((sys_dlist_peek_next(&test_list, &test_node_2.node) ==
// &test_node_4.node),
// "test_list node links are wrong");
/* Finding and removing node 1 */
sys_dlist_remove(&test_node_1.node);
//zassert_true((verify_content_amount(&test_list, 3)),
// "test_list has wrong content");
//zassert_true((verify_tail_head(&test_list, &test_node_2.node,
// &test_node_3.node, false)),
// "test_list head/tail are wrong");
/* Removing node 3 */
sys_dlist_remove(&test_node_3.node);
//zassert_true((verify_content_amount(&test_list, 2)),
// "test_list has wrong content");
//zassert_true((verify_tail_head(&test_list, &test_node_2.node,
// &test_node_4.node, false)),
// "test_list head/tail are wrong");
/* Removing node 4 */
sys_dlist_remove(&test_node_4.node);
//zassert_true((verify_content_amount(&test_list, 1)),
// "test_list has wrong content");
//zassert_true((verify_tail_head(&test_list, &test_node_2.node,
// &test_node_2.node, true)),
// "test_list head/tail are wrong");
/* Removing node 2 */
sys_dlist_remove(&test_node_2.node);
//zassert_true((verify_emptyness(&test_list)),
// "test_list should be empty");
/* test iterator from a node */
struct data_node {
sys_dnode_t node;
int data;
} data_node[6] = {
{ .data = 0 },
{ .data = 1 },
{ .data = 2 },
{ .data = 3 },
{ .data = 4 },
{ .data = 5 },
};
sys_dnode_t *node = NULL;
int ii;
sys_dlist_init(&test_list);
for (ii = 0; ii < 6; ii++) {
sys_dlist_append(&test_list, &data_node[ii].node);
}
ii = 0;
SYS_DLIST_ITERATE_FROM_NODE(&test_list, node) {
ii++;
if (((struct data_node *)node)->data == 2) {
break;
}
}
//zassert_equal(ii, 3, "");
ii = 0;
SYS_DLIST_ITERATE_FROM_NODE(&test_list, node) {
ii++;
if (((struct data_node *)node)->data == 3) {
break;
}
}
//zassert_equal(ii, 1, "");
ii = 0;
SYS_DLIST_ITERATE_FROM_NODE(&test_list, node) {
ii++;
}
//zassert_equal(ii, 2, "");
}
#endif /* #if CONFIG_BT_MESH */

View File

@@ -7,95 +7,96 @@
*/
#ifndef _FOUNDATION_H_
#define _FOUNDATION_H_
#include "mesh_access.h"
#include "net.h"
#define OP_APP_KEY_ADD BT_MESH_MODEL_OP_1(0x00)
#define OP_APP_KEY_UPDATE BT_MESH_MODEL_OP_1(0x01)
#define OP_DEV_COMP_DATA_STATUS BT_MESH_MODEL_OP_1(0x02)
#define OP_MOD_PUB_SET BT_MESH_MODEL_OP_1(0x03)
#define OP_HEALTH_CURRENT_STATUS BT_MESH_MODEL_OP_1(0x04)
#define OP_HEALTH_FAULT_STATUS BT_MESH_MODEL_OP_1(0x05)
#define OP_HEARTBEAT_PUB_STATUS BT_MESH_MODEL_OP_1(0x06)
#define OP_APP_KEY_DEL BT_MESH_MODEL_OP_2(0x80, 0x00)
#define OP_APP_KEY_GET BT_MESH_MODEL_OP_2(0x80, 0x01)
#define OP_APP_KEY_LIST BT_MESH_MODEL_OP_2(0x80, 0x02)
#define OP_APP_KEY_STATUS BT_MESH_MODEL_OP_2(0x80, 0x03)
#define OP_ATTENTION_GET BT_MESH_MODEL_OP_2(0x80, 0x04)
#define OP_ATTENTION_SET BT_MESH_MODEL_OP_2(0x80, 0x05)
#define OP_ATTENTION_SET_UNREL BT_MESH_MODEL_OP_2(0x80, 0x06)
#define OP_ATTENTION_STATUS BT_MESH_MODEL_OP_2(0x80, 0x07)
#define OP_DEV_COMP_DATA_GET BT_MESH_MODEL_OP_2(0x80, 0x08)
#define OP_BEACON_GET BT_MESH_MODEL_OP_2(0x80, 0x09)
#define OP_BEACON_SET BT_MESH_MODEL_OP_2(0x80, 0x0a)
#define OP_BEACON_STATUS BT_MESH_MODEL_OP_2(0x80, 0x0b)
#define OP_DEFAULT_TTL_GET BT_MESH_MODEL_OP_2(0x80, 0x0c)
#define OP_DEFAULT_TTL_SET BT_MESH_MODEL_OP_2(0x80, 0x0d)
#define OP_DEFAULT_TTL_STATUS BT_MESH_MODEL_OP_2(0x80, 0x0e)
#define OP_FRIEND_GET BT_MESH_MODEL_OP_2(0x80, 0x0f)
#define OP_FRIEND_SET BT_MESH_MODEL_OP_2(0x80, 0x10)
#define OP_FRIEND_STATUS BT_MESH_MODEL_OP_2(0x80, 0x11)
#define OP_GATT_PROXY_GET BT_MESH_MODEL_OP_2(0x80, 0x12)
#define OP_GATT_PROXY_SET BT_MESH_MODEL_OP_2(0x80, 0x13)
#define OP_GATT_PROXY_STATUS BT_MESH_MODEL_OP_2(0x80, 0x14)
#define OP_KRP_GET BT_MESH_MODEL_OP_2(0x80, 0x15)
#define OP_KRP_SET BT_MESH_MODEL_OP_2(0x80, 0x16)
#define OP_KRP_STATUS BT_MESH_MODEL_OP_2(0x80, 0x17)
#define OP_MOD_PUB_GET BT_MESH_MODEL_OP_2(0x80, 0x18)
#define OP_MOD_PUB_STATUS BT_MESH_MODEL_OP_2(0x80, 0x19)
#define OP_MOD_PUB_VA_SET BT_MESH_MODEL_OP_2(0x80, 0x1a)
#define OP_MOD_SUB_ADD BT_MESH_MODEL_OP_2(0x80, 0x1b)
#define OP_MOD_SUB_DEL BT_MESH_MODEL_OP_2(0x80, 0x1c)
#define OP_MOD_SUB_DEL_ALL BT_MESH_MODEL_OP_2(0x80, 0x1d)
#define OP_MOD_SUB_OVERWRITE BT_MESH_MODEL_OP_2(0x80, 0x1e)
#define OP_MOD_SUB_STATUS BT_MESH_MODEL_OP_2(0x80, 0x1f)
#define OP_MOD_SUB_VA_ADD BT_MESH_MODEL_OP_2(0x80, 0x20)
#define OP_MOD_SUB_VA_DEL BT_MESH_MODEL_OP_2(0x80, 0x21)
#define OP_MOD_SUB_VA_OVERWRITE BT_MESH_MODEL_OP_2(0x80, 0x22)
#define OP_NET_TRANSMIT_GET BT_MESH_MODEL_OP_2(0x80, 0x23)
#define OP_NET_TRANSMIT_SET BT_MESH_MODEL_OP_2(0x80, 0x24)
#define OP_NET_TRANSMIT_STATUS BT_MESH_MODEL_OP_2(0x80, 0x25)
#define OP_RELAY_GET BT_MESH_MODEL_OP_2(0x80, 0x26)
#define OP_RELAY_SET BT_MESH_MODEL_OP_2(0x80, 0x27)
#define OP_RELAY_STATUS BT_MESH_MODEL_OP_2(0x80, 0x28)
#define OP_MOD_SUB_GET BT_MESH_MODEL_OP_2(0x80, 0x29)
#define OP_MOD_SUB_LIST BT_MESH_MODEL_OP_2(0x80, 0x2a)
#define OP_MOD_SUB_GET_VND BT_MESH_MODEL_OP_2(0x80, 0x2b)
#define OP_MOD_SUB_LIST_VND BT_MESH_MODEL_OP_2(0x80, 0x2c)
#define OP_LPN_TIMEOUT_GET BT_MESH_MODEL_OP_2(0x80, 0x2d)
#define OP_LPN_TIMEOUT_STATUS BT_MESH_MODEL_OP_2(0x80, 0x2e)
#define OP_HEALTH_FAULT_CLEAR BT_MESH_MODEL_OP_2(0x80, 0x2f)
#define OP_HEALTH_FAULT_CLEAR_UNREL BT_MESH_MODEL_OP_2(0x80, 0x30)
#define OP_HEALTH_FAULT_GET BT_MESH_MODEL_OP_2(0x80, 0x31)
#define OP_HEALTH_FAULT_TEST BT_MESH_MODEL_OP_2(0x80, 0x32)
#define OP_HEALTH_FAULT_TEST_UNREL BT_MESH_MODEL_OP_2(0x80, 0x33)
#define OP_HEALTH_PERIOD_GET BT_MESH_MODEL_OP_2(0x80, 0x34)
#define OP_HEALTH_PERIOD_SET BT_MESH_MODEL_OP_2(0x80, 0x35)
#define OP_HEALTH_PERIOD_SET_UNREL BT_MESH_MODEL_OP_2(0x80, 0x36)
#define OP_HEALTH_PERIOD_STATUS BT_MESH_MODEL_OP_2(0x80, 0x37)
#define OP_HEARTBEAT_PUB_GET BT_MESH_MODEL_OP_2(0x80, 0x38)
#define OP_HEARTBEAT_PUB_SET BT_MESH_MODEL_OP_2(0x80, 0x39)
#define OP_HEARTBEAT_SUB_GET BT_MESH_MODEL_OP_2(0x80, 0x3a)
#define OP_HEARTBEAT_SUB_SET BT_MESH_MODEL_OP_2(0x80, 0x3b)
#define OP_HEARTBEAT_SUB_STATUS BT_MESH_MODEL_OP_2(0x80, 0x3c)
#define OP_MOD_APP_BIND BT_MESH_MODEL_OP_2(0x80, 0x3d)
#define OP_MOD_APP_STATUS BT_MESH_MODEL_OP_2(0x80, 0x3e)
#define OP_MOD_APP_UNBIND BT_MESH_MODEL_OP_2(0x80, 0x3f)
#define OP_NET_KEY_ADD BT_MESH_MODEL_OP_2(0x80, 0x40)
#define OP_NET_KEY_DEL BT_MESH_MODEL_OP_2(0x80, 0x41)
#define OP_NET_KEY_GET BT_MESH_MODEL_OP_2(0x80, 0x42)
#define OP_NET_KEY_LIST BT_MESH_MODEL_OP_2(0x80, 0x43)
#define OP_NET_KEY_STATUS BT_MESH_MODEL_OP_2(0x80, 0x44)
#define OP_NET_KEY_UPDATE BT_MESH_MODEL_OP_2(0x80, 0x45)
#define OP_NODE_IDENTITY_GET BT_MESH_MODEL_OP_2(0x80, 0x46)
#define OP_NODE_IDENTITY_SET BT_MESH_MODEL_OP_2(0x80, 0x47)
#define OP_NODE_IDENTITY_STATUS BT_MESH_MODEL_OP_2(0x80, 0x48)
#define OP_NODE_RESET BT_MESH_MODEL_OP_2(0x80, 0x49)
#define OP_NODE_RESET_STATUS BT_MESH_MODEL_OP_2(0x80, 0x4a)
#define OP_SIG_MOD_APP_GET BT_MESH_MODEL_OP_2(0x80, 0x4b)
#define OP_SIG_MOD_APP_LIST BT_MESH_MODEL_OP_2(0x80, 0x4c)
#define OP_VND_MOD_APP_GET BT_MESH_MODEL_OP_2(0x80, 0x4d)
#define OP_VND_MOD_APP_LIST BT_MESH_MODEL_OP_2(0x80, 0x4e)
#define OP_APP_KEY_ADD BLE_MESH_MODEL_OP_1(0x00)
#define OP_APP_KEY_UPDATE BLE_MESH_MODEL_OP_1(0x01)
#define OP_DEV_COMP_DATA_STATUS BLE_MESH_MODEL_OP_1(0x02)
#define OP_MOD_PUB_SET BLE_MESH_MODEL_OP_1(0x03)
#define OP_HEALTH_CURRENT_STATUS BLE_MESH_MODEL_OP_1(0x04)
#define OP_HEALTH_FAULT_STATUS BLE_MESH_MODEL_OP_1(0x05)
#define OP_HEARTBEAT_PUB_STATUS BLE_MESH_MODEL_OP_1(0x06)
#define OP_APP_KEY_DEL BLE_MESH_MODEL_OP_2(0x80, 0x00)
#define OP_APP_KEY_GET BLE_MESH_MODEL_OP_2(0x80, 0x01)
#define OP_APP_KEY_LIST BLE_MESH_MODEL_OP_2(0x80, 0x02)
#define OP_APP_KEY_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x03)
#define OP_ATTENTION_GET BLE_MESH_MODEL_OP_2(0x80, 0x04)
#define OP_ATTENTION_SET BLE_MESH_MODEL_OP_2(0x80, 0x05)
#define OP_ATTENTION_SET_UNREL BLE_MESH_MODEL_OP_2(0x80, 0x06)
#define OP_ATTENTION_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x07)
#define OP_DEV_COMP_DATA_GET BLE_MESH_MODEL_OP_2(0x80, 0x08)
#define OP_BEACON_GET BLE_MESH_MODEL_OP_2(0x80, 0x09)
#define OP_BEACON_SET BLE_MESH_MODEL_OP_2(0x80, 0x0a)
#define OP_BEACON_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x0b)
#define OP_DEFAULT_TTL_GET BLE_MESH_MODEL_OP_2(0x80, 0x0c)
#define OP_DEFAULT_TTL_SET BLE_MESH_MODEL_OP_2(0x80, 0x0d)
#define OP_DEFAULT_TTL_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x0e)
#define OP_FRIEND_GET BLE_MESH_MODEL_OP_2(0x80, 0x0f)
#define OP_FRIEND_SET BLE_MESH_MODEL_OP_2(0x80, 0x10)
#define OP_FRIEND_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x11)
#define OP_GATT_PROXY_GET BLE_MESH_MODEL_OP_2(0x80, 0x12)
#define OP_GATT_PROXY_SET BLE_MESH_MODEL_OP_2(0x80, 0x13)
#define OP_GATT_PROXY_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x14)
#define OP_KRP_GET BLE_MESH_MODEL_OP_2(0x80, 0x15)
#define OP_KRP_SET BLE_MESH_MODEL_OP_2(0x80, 0x16)
#define OP_KRP_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x17)
#define OP_MOD_PUB_GET BLE_MESH_MODEL_OP_2(0x80, 0x18)
#define OP_MOD_PUB_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x19)
#define OP_MOD_PUB_VA_SET BLE_MESH_MODEL_OP_2(0x80, 0x1a)
#define OP_MOD_SUB_ADD BLE_MESH_MODEL_OP_2(0x80, 0x1b)
#define OP_MOD_SUB_DEL BLE_MESH_MODEL_OP_2(0x80, 0x1c)
#define OP_MOD_SUB_DEL_ALL BLE_MESH_MODEL_OP_2(0x80, 0x1d)
#define OP_MOD_SUB_OVERWRITE BLE_MESH_MODEL_OP_2(0x80, 0x1e)
#define OP_MOD_SUB_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x1f)
#define OP_MOD_SUB_VA_ADD BLE_MESH_MODEL_OP_2(0x80, 0x20)
#define OP_MOD_SUB_VA_DEL BLE_MESH_MODEL_OP_2(0x80, 0x21)
#define OP_MOD_SUB_VA_OVERWRITE BLE_MESH_MODEL_OP_2(0x80, 0x22)
#define OP_NET_TRANSMIT_GET BLE_MESH_MODEL_OP_2(0x80, 0x23)
#define OP_NET_TRANSMIT_SET BLE_MESH_MODEL_OP_2(0x80, 0x24)
#define OP_NET_TRANSMIT_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x25)
#define OP_RELAY_GET BLE_MESH_MODEL_OP_2(0x80, 0x26)
#define OP_RELAY_SET BLE_MESH_MODEL_OP_2(0x80, 0x27)
#define OP_RELAY_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x28)
#define OP_MOD_SUB_GET BLE_MESH_MODEL_OP_2(0x80, 0x29)
#define OP_MOD_SUB_LIST BLE_MESH_MODEL_OP_2(0x80, 0x2a)
#define OP_MOD_SUB_GET_VND BLE_MESH_MODEL_OP_2(0x80, 0x2b)
#define OP_MOD_SUB_LIST_VND BLE_MESH_MODEL_OP_2(0x80, 0x2c)
#define OP_LPN_TIMEOUT_GET BLE_MESH_MODEL_OP_2(0x80, 0x2d)
#define OP_LPN_TIMEOUT_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x2e)
#define OP_HEALTH_FAULT_CLEAR BLE_MESH_MODEL_OP_2(0x80, 0x2f)
#define OP_HEALTH_FAULT_CLEAR_UNREL BLE_MESH_MODEL_OP_2(0x80, 0x30)
#define OP_HEALTH_FAULT_GET BLE_MESH_MODEL_OP_2(0x80, 0x31)
#define OP_HEALTH_FAULT_TEST BLE_MESH_MODEL_OP_2(0x80, 0x32)
#define OP_HEALTH_FAULT_TEST_UNREL BLE_MESH_MODEL_OP_2(0x80, 0x33)
#define OP_HEALTH_PERIOD_GET BLE_MESH_MODEL_OP_2(0x80, 0x34)
#define OP_HEALTH_PERIOD_SET BLE_MESH_MODEL_OP_2(0x80, 0x35)
#define OP_HEALTH_PERIOD_SET_UNREL BLE_MESH_MODEL_OP_2(0x80, 0x36)
#define OP_HEALTH_PERIOD_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x37)
#define OP_HEARTBEAT_PUB_GET BLE_MESH_MODEL_OP_2(0x80, 0x38)
#define OP_HEARTBEAT_PUB_SET BLE_MESH_MODEL_OP_2(0x80, 0x39)
#define OP_HEARTBEAT_SUB_GET BLE_MESH_MODEL_OP_2(0x80, 0x3a)
#define OP_HEARTBEAT_SUB_SET BLE_MESH_MODEL_OP_2(0x80, 0x3b)
#define OP_HEARTBEAT_SUB_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x3c)
#define OP_MOD_APP_BIND BLE_MESH_MODEL_OP_2(0x80, 0x3d)
#define OP_MOD_APP_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x3e)
#define OP_MOD_APP_UNBIND BLE_MESH_MODEL_OP_2(0x80, 0x3f)
#define OP_NET_KEY_ADD BLE_MESH_MODEL_OP_2(0x80, 0x40)
#define OP_NET_KEY_DEL BLE_MESH_MODEL_OP_2(0x80, 0x41)
#define OP_NET_KEY_GET BLE_MESH_MODEL_OP_2(0x80, 0x42)
#define OP_NET_KEY_LIST BLE_MESH_MODEL_OP_2(0x80, 0x43)
#define OP_NET_KEY_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x44)
#define OP_NET_KEY_UPDATE BLE_MESH_MODEL_OP_2(0x80, 0x45)
#define OP_NODE_IDENTITY_GET BLE_MESH_MODEL_OP_2(0x80, 0x46)
#define OP_NODE_IDENTITY_SET BLE_MESH_MODEL_OP_2(0x80, 0x47)
#define OP_NODE_IDENTITY_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x48)
#define OP_NODE_RESET BLE_MESH_MODEL_OP_2(0x80, 0x49)
#define OP_NODE_RESET_STATUS BLE_MESH_MODEL_OP_2(0x80, 0x4a)
#define OP_SIG_MOD_APP_GET BLE_MESH_MODEL_OP_2(0x80, 0x4b)
#define OP_SIG_MOD_APP_LIST BLE_MESH_MODEL_OP_2(0x80, 0x4c)
#define OP_VND_MOD_APP_GET BLE_MESH_MODEL_OP_2(0x80, 0x4d)
#define OP_VND_MOD_APP_LIST BLE_MESH_MODEL_OP_2(0x80, 0x4e)
#define STATUS_SUCCESS 0x00
#define STATUS_INVALID_ADDRESS 0x01
@@ -162,4 +163,4 @@ static inline void key_idx_unpack(struct net_buf_simple *buf,
net_buf_simple_pull(buf, 3);
}
#endif /* #ifndef _FOUNDATION_H_ */
#endif /* _FOUNDATION_H_ */

View File

@@ -9,39 +9,39 @@
#include <errno.h>
#include <string.h>
#include "mesh_buf.h"
#include "sdkconfig.h"
#if CONFIG_BT_MESH
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_FRIEND)
#include "mesh_buf.h"
#include "mesh_util.h"
#include "mesh_main.h"
#ifdef CONFIG_BT_MESH_FRIEND
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_FRIEND)
#include "mesh_trace.h"
#include "mesh.h"
#include "crypto.h"
#include "adv.h"
#include "mesh.h"
#include "net.h"
#include "transport.h"
#include "access.h"
#include "foundation.h"
#include "friend.h"
#define FRIEND_BUF_SIZE (BT_MESH_ADV_DATA_SIZE - BT_MESH_NET_HDR_LEN)
#ifdef CONFIG_BLE_MESH_FRIEND
#define FRIEND_BUF_SIZE (BLE_MESH_ADV_DATA_SIZE - BLE_MESH_NET_HDR_LEN)
/* We reserve one extra buffer for each friendship, since we need to be able
* to resend the last sent PDU, which sits separately outside of the queue.
*/
#define FRIEND_BUF_COUNT ((CONFIG_BT_MESH_FRIEND_QUEUE_SIZE + 1) * \
CONFIG_BT_MESH_FRIEND_LPN_COUNT)
#define FRIEND_BUF_COUNT ((CONFIG_BLE_MESH_FRIEND_QUEUE_SIZE + 1) * \
CONFIG_BLE_MESH_FRIEND_LPN_COUNT)
#define FRIEND_ADV(buf) CONTAINER_OF(BT_MESH_ADV(buf), \
struct friend_adv, adv)
#define FRIEND_ADV(buf) CONTAINER_OF(BLE_MESH_ADV(buf), struct friend_adv, adv)
/* PDUs from Friend to the LPN should only be transmitted once with the
* smallest possible interval (20ms).
*/
#define FRIEND_XMIT BT_MESH_TRANSMIT(0, 20)
#define FRIEND_XMIT BLE_MESH_TRANSMIT(0, 20)
struct friend_pdu_info {
u16_t src;
@@ -56,7 +56,7 @@ struct friend_pdu_info {
};
NET_BUF_POOL_DEFINE(friend_buf_pool, FRIEND_BUF_COUNT,
BT_MESH_ADV_DATA_SIZE, BT_MESH_ADV_USER_DATA_SIZE, NULL);
BLE_MESH_ADV_DATA_SIZE, BLE_MESH_ADV_USER_DATA_SIZE, NULL);
static struct friend_adv {
struct bt_mesh_adv adv;
@@ -83,7 +83,7 @@ static void discard_buffer(void)
buf = net_buf_slist_get(&frnd->queue);
__ASSERT_NO_MSG(buf != NULL);
BT_WARN("Discarding buffer %p for LPN 0x%04x", buf, frnd->lpn);
BT_WARN("%s, Discarding buffer %p for LPN 0x%04x", __func__, buf, frnd->lpn);
net_buf_unref(buf);
}
@@ -95,16 +95,16 @@ static struct net_buf *friend_buf_alloc(u16_t src)
do {
buf = bt_mesh_adv_create_from_pool(&friend_buf_pool, adv_alloc,
BT_MESH_ADV_DATA,
BT_MESH_TRANSMIT_COUNT(FRIEND_XMIT),
BT_MESH_TRANSMIT_INT(FRIEND_XMIT),
BLE_MESH_ADV_DATA,
BLE_MESH_TRANSMIT_COUNT(FRIEND_XMIT),
BLE_MESH_TRANSMIT_INT(FRIEND_XMIT),
K_NO_WAIT);
if (!buf) {
discard_buffer();
}
} while (!buf);
BT_MESH_ADV(buf)->addr = src;
BLE_MESH_ADV(buf)->addr = src;
FRIEND_ADV(buf)->seq_auth = TRANS_SEQ_AUTH_NVAL;
BT_DBG("allocated buf %p", buf);
@@ -114,7 +114,7 @@ static struct net_buf *friend_buf_alloc(u16_t src)
static bool is_lpn_unicast(struct bt_mesh_friend *frnd, u16_t addr)
{
if (frnd->lpn == BT_MESH_ADDR_UNASSIGNED) {
if (frnd->lpn == BLE_MESH_ADDR_UNASSIGNED) {
return false;
}
@@ -139,7 +139,7 @@ struct bt_mesh_friend *bt_mesh_friend_find(u16_t net_idx, u16_t lpn_addr,
continue;
}
if (net_idx != BT_MESH_KEY_ANY && frnd->net_idx != net_idx) {
if (net_idx != BLE_MESH_KEY_ANY && frnd->net_idx != net_idx) {
continue;
}
@@ -158,8 +158,8 @@ struct bt_mesh_friend *bt_mesh_friend_find(u16_t net_idx, u16_t lpn_addr,
*/
static s32_t recv_delay(struct bt_mesh_friend *frnd)
{
#if CONFIG_BT_MESH_FRIEND_RECV_WIN > 50
return (s32_t)frnd->recv_delay + (CONFIG_BT_MESH_FRIEND_RECV_WIN / 5);
#if CONFIG_BLE_MESH_FRIEND_RECV_WIN > 50
return (s32_t)frnd->recv_delay + (CONFIG_BLE_MESH_FRIEND_RECV_WIN / 5);
#else
return frnd->recv_delay;
#endif
@@ -178,7 +178,7 @@ static void friend_clear(struct bt_mesh_friend *frnd)
if (frnd->last) {
/* Cancel the sending if necessary */
if (frnd->pending_buf) {
BT_MESH_ADV(frnd->last)->busy = 0;
BLE_MESH_ADV(frnd->last)->busy = 0;
}
net_buf_unref(frnd->last);
@@ -215,11 +215,11 @@ void bt_mesh_friend_clear_net_idx(u16_t net_idx)
for (i = 0; i < ARRAY_SIZE(bt_mesh.frnd); i++) {
struct bt_mesh_friend *frnd = &bt_mesh.frnd[i];
if (frnd->net_idx == BT_MESH_KEY_UNUSED) {
if (frnd->net_idx == BLE_MESH_KEY_UNUSED) {
continue;
}
if (net_idx == BT_MESH_KEY_ANY || frnd->net_idx == net_idx) {
if (net_idx == BLE_MESH_KEY_ANY || frnd->net_idx == net_idx) {
friend_clear(frnd);
}
}
@@ -234,11 +234,11 @@ void bt_mesh_friend_sec_update(u16_t net_idx)
for (i = 0; i < ARRAY_SIZE(bt_mesh.frnd); i++) {
struct bt_mesh_friend *frnd = &bt_mesh.frnd[i];
if (frnd->net_idx == BT_MESH_KEY_UNUSED) {
if (frnd->net_idx == BLE_MESH_KEY_UNUSED) {
continue;
}
if (net_idx == BT_MESH_KEY_ANY || frnd->net_idx == net_idx) {
if (net_idx == BLE_MESH_KEY_ANY || frnd->net_idx == net_idx) {
frnd->sec_update = 1;
}
}
@@ -258,7 +258,7 @@ int bt_mesh_friend_clear(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
struct bt_mesh_ctl_friend_clear_confirm cfm;
if (buf->len < sizeof(*msg)) {
BT_WARN("Too short Friend Clear");
BT_WARN("%s, Too short Friend Clear", __func__);
return -EINVAL;
}
@@ -269,7 +269,7 @@ int bt_mesh_friend_clear(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
frnd = bt_mesh_friend_find(rx->sub->net_idx, lpn_addr, false, false);
if (!frnd) {
BT_WARN("No matching LPN addr 0x%04x", lpn_addr);
BT_WARN("%s, No matching LPN addr 0x%04x", __func__, lpn_addr);
return 0;
}
@@ -280,12 +280,12 @@ int bt_mesh_friend_clear(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
* 65536, is in the range 0 to 255 inclusive.
*/
if (lpn_counter - frnd->lpn_counter > 255) {
BT_WARN("LPN Counter out of range (old %u new %u)",
frnd->lpn_counter, lpn_counter);
BT_WARN("%s, LPN Counter out of range (old %u new %u)",
__func__, frnd->lpn_counter, lpn_counter);
return 0;
}
tx.ctx->send_ttl = BT_MESH_TTL_MAX;
tx.ctx->send_ttl = BLE_MESH_TTL_MAX;
cfm.lpn_addr = msg->lpn_addr;
cfm.lpn_counter = msg->lpn_counter;
@@ -303,13 +303,13 @@ static void friend_sub_add(struct bt_mesh_friend *frnd, u16_t addr)
int i;
for (i = 0; i < ARRAY_SIZE(frnd->sub_list); i++) {
if (frnd->sub_list[i] == BT_MESH_ADDR_UNASSIGNED) {
if (frnd->sub_list[i] == BLE_MESH_ADDR_UNASSIGNED) {
frnd->sub_list[i] = addr;
return;
}
}
BT_WARN("No space in friend subscription list");
BT_WARN("%s, No space in friend subscription list", __func__);
}
static void friend_sub_rem(struct bt_mesh_friend *frnd, u16_t addr)
@@ -318,7 +318,7 @@ static void friend_sub_rem(struct bt_mesh_friend *frnd, u16_t addr)
for (i = 0; i < ARRAY_SIZE(frnd->sub_list); i++) {
if (frnd->sub_list[i] == addr) {
frnd->sub_list[i] = BT_MESH_ADDR_UNASSIGNED;
frnd->sub_list[i] = BLE_MESH_ADDR_UNASSIGNED;
return;
}
}
@@ -345,7 +345,7 @@ static struct net_buf *create_friend_pdu(struct bt_mesh_friend *frnd,
nid = sub->keys[sub->kr_flag].nid;
} else {
if (friend_cred_get(sub, frnd->lpn, &nid, &enc, &priv)) {
BT_ERR("friend_cred_get failed");
BT_ERR("%s, friend_cred_get failed", __func__);
goto failed;
}
}
@@ -370,12 +370,12 @@ static struct net_buf *create_friend_pdu(struct bt_mesh_friend *frnd,
* layer nonce includes the IVI.
*/
if (bt_mesh_net_encrypt(enc, &buf->b, info->iv_index, false)) {
BT_ERR("Re-encrypting failed");
BT_ERR("%s, Re-encrypting failed", __func__);
goto failed;
}
if (bt_mesh_net_obfuscate(buf->data, info->iv_index, priv)) {
BT_ERR("Re-obfuscating failed");
BT_ERR("%s, Re-obfuscating failed", __func__);
goto failed;
}
@@ -408,7 +408,7 @@ static struct net_buf *encode_friend_ctl(struct bt_mesh_friend *frnd,
info.seq[1] = seq >> 8;
info.seq[2] = seq;
info.iv_index = BT_MESH_NET_IVI_TX;
info.iv_index = BLE_MESH_NET_IVI_TX;
return create_friend_pdu(frnd, &info, sdu);
}
@@ -448,7 +448,7 @@ static void enqueue_sub_cfm(struct bt_mesh_friend *frnd, u8_t xact)
buf = encode_friend_ctl(frnd, TRANS_CTL_OP_FRIEND_SUB_CFM, sdu);
if (!buf) {
BT_ERR("Unable to encode Subscription List Confirmation");
BT_ERR("%s, Unable to encode Subscription List Confirmation", __func__);
return;
}
@@ -474,19 +474,19 @@ int bt_mesh_friend_sub_add(struct bt_mesh_net_rx *rx,
struct bt_mesh_friend *frnd;
u8_t xact;
if (buf->len < BT_MESH_FRIEND_SUB_MIN_LEN) {
BT_WARN("Too short Friend Subscription Add");
if (buf->len < BLE_MESH_FRIEND_SUB_MIN_LEN) {
BT_WARN("%s, Too short Friend Subscription Add", __func__);
return -EINVAL;
}
frnd = bt_mesh_friend_find(rx->sub->net_idx, rx->ctx.addr, true, true);
if (!frnd) {
BT_WARN("No matching LPN addr 0x%04x", rx->ctx.addr);
BT_WARN("%s, No matching LPN addr 0x%04x", __func__, rx->ctx.addr);
return 0;
}
if (frnd->pending_buf) {
BT_WARN("Previous buffer not yet sent!");
BT_WARN("%s, Previous buffer not yet sent!", __func__);
return 0;
}
@@ -509,19 +509,19 @@ int bt_mesh_friend_sub_rem(struct bt_mesh_net_rx *rx,
struct bt_mesh_friend *frnd;
u8_t xact;
if (buf->len < BT_MESH_FRIEND_SUB_MIN_LEN) {
BT_WARN("Too short Friend Subscription Remove");
if (buf->len < BLE_MESH_FRIEND_SUB_MIN_LEN) {
BT_WARN("%s, Too short Friend Subscription Remove", __func__);
return -EINVAL;
}
frnd = bt_mesh_friend_find(rx->sub->net_idx, rx->ctx.addr, true, true);
if (!frnd) {
BT_WARN("No matching LPN addr 0x%04x", rx->ctx.addr);
BT_WARN("%s, No matching LPN addr 0x%04x", __func__, rx->ctx.addr);
return 0;
}
if (frnd->pending_buf) {
BT_WARN("Previous buffer not yet sent!");
BT_WARN("%s, Previous buffer not yet sent!", __func__);
return 0;
}
@@ -550,7 +550,7 @@ static void enqueue_update(struct bt_mesh_friend *frnd, u8_t md)
buf = encode_update(frnd, md);
if (!buf) {
BT_ERR("Unable to encode Friend Update");
BT_ERR("%s, Unable to encode Friend Update", __func__);
return;
}
@@ -564,23 +564,23 @@ int bt_mesh_friend_poll(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
struct bt_mesh_friend *frnd;
if (buf->len < sizeof(*msg)) {
BT_WARN("Too short Friend Poll");
BT_WARN("%s, Too short Friend Poll", __func__);
return -EINVAL;
}
frnd = bt_mesh_friend_find(rx->sub->net_idx, rx->ctx.addr, true, false);
if (!frnd) {
BT_WARN("No matching LPN addr 0x%04x", rx->ctx.addr);
BT_WARN("%s, No matching LPN addr 0x%04x", __func__, rx->ctx.addr);
return 0;
}
if (msg->fsn & ~1) {
BT_WARN("Prohibited (non-zero) padding bits");
BT_WARN("%s, Prohibited (non-zero) padding bits", __func__);
return -EINVAL;
}
if (frnd->pending_buf) {
BT_WARN("Previous buffer not yet sent");
BT_WARN("%s, Previous buffer not yet sent!", __func__);
return 0;
}
@@ -645,9 +645,9 @@ static void send_friend_clear(struct bt_mesh_friend *frnd)
{
struct bt_mesh_msg_ctx ctx = {
.net_idx = frnd->net_idx,
.app_idx = BT_MESH_KEY_UNUSED,
.app_idx = BLE_MESH_KEY_UNUSED,
.addr = frnd->clear.frnd,
.send_ttl = BT_MESH_TTL_MAX,
.send_ttl = BLE_MESH_TTL_MAX,
};
struct bt_mesh_net_tx tx = {
.sub = &bt_mesh.sub[0],
@@ -677,7 +677,7 @@ static void clear_timeout(struct k_work *work)
duration = k_uptime_get_32() - frnd->clear.start;
if (duration > 2 * frnd->poll_to) {
BT_DBG("Clear Procedure timer expired");
frnd->clear.frnd = BT_MESH_ADDR_UNASSIGNED;
frnd->clear.frnd = BLE_MESH_ADDR_UNASSIGNED;
return;
}
@@ -704,32 +704,32 @@ int bt_mesh_friend_clear_cfm(struct bt_mesh_net_rx *rx,
BT_DBG("%s", __func__);
if (buf->len < sizeof(*msg)) {
BT_WARN("Too short Friend Clear Confirm");
BT_WARN("%s, Too short Friend Clear Confirm", __func__);
return -EINVAL;
}
frnd = find_clear(rx->ctx.addr);
if (!frnd) {
BT_WARN("No pending clear procedure for 0x%02x", rx->ctx.addr);
BT_WARN("%s, No pending clear procedure for 0x%02x", __func__, rx->ctx.addr);
return 0;
}
lpn_addr = sys_be16_to_cpu(msg->lpn_addr);
if (lpn_addr != frnd->lpn) {
BT_WARN("LPN address mismatch (0x%04x != 0x%04x)",
lpn_addr, frnd->lpn);
BT_WARN("%s, LPN address mismatch (0x%04x != 0x%04x)",
__func__, lpn_addr, frnd->lpn);
return 0;
}
lpn_counter = sys_be16_to_cpu(msg->lpn_counter);
if (lpn_counter != frnd->lpn_counter) {
BT_WARN("LPN counter mismatch (0x%04x != 0x%04x)",
lpn_counter, frnd->lpn_counter);
BT_WARN("%s, LPN counter mismatch (0x%04x != 0x%04x)",
__func__, lpn_counter, frnd->lpn_counter);
return 0;
}
k_delayed_work_cancel(&frnd->clear.timer);
frnd->clear.frnd = BT_MESH_ADDR_UNASSIGNED;
frnd->clear.frnd = BLE_MESH_ADDR_UNASSIGNED;
return 0;
}
@@ -746,15 +746,15 @@ static void enqueue_offer(struct bt_mesh_friend *frnd, s8_t rssi)
off = net_buf_simple_add(sdu, sizeof(*off));
off->recv_win = CONFIG_BT_MESH_FRIEND_RECV_WIN,
off->queue_size = CONFIG_BT_MESH_FRIEND_QUEUE_SIZE,
off->recv_win = CONFIG_BLE_MESH_FRIEND_RECV_WIN,
off->queue_size = CONFIG_BLE_MESH_FRIEND_QUEUE_SIZE,
off->sub_list_size = ARRAY_SIZE(frnd->sub_list),
off->rssi = rssi,
off->frnd_counter = sys_cpu_to_be16(frnd->counter);
buf = encode_friend_ctl(frnd, TRANS_CTL_OP_FRIEND_OFFER, sdu);
if (!buf) {
BT_ERR("Unable to encode Friend Offer");
BT_ERR("%s, Unable to encode Friend Offer", __func__);
return;
}
@@ -768,7 +768,7 @@ static void enqueue_offer(struct bt_mesh_friend *frnd, s8_t rssi)
frnd->send_last = 1;
}
#define RECV_WIN CONFIG_BT_MESH_FRIEND_RECV_WIN
#define RECV_WIN CONFIG_BLE_MESH_FRIEND_RECV_WIN
#define RSSI_FACT(crit) (((crit) >> 5) & (u8_t)BIT_MASK(2))
#define RECV_WIN_FACT(crit) (((crit) >> 3) & (u8_t)BIT_MASK(2))
#define MIN_QUEUE_SIZE_LOG(crit) ((crit) & (u8_t)BIT_MASK(3))
@@ -808,12 +808,12 @@ int bt_mesh_friend_req(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
int i;
if (buf->len < sizeof(*msg)) {
BT_WARN("Too short Friend Request");
BT_WARN("%s, Too short Friend Request", __func__);
return -EINVAL;
}
if (msg->recv_delay <= 0x09) {
BT_WARN("Prohibited ReceiveDelay (0x%02x)", msg->recv_delay);
BT_WARN("%s, Prohibited ReceiveDelay (0x%02x)", __func__, msg->recv_delay);
return -EINVAL;
}
@@ -822,35 +822,35 @@ int bt_mesh_friend_req(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
((u32_t)msg->poll_to[2]));
if (poll_to <= 0x000009 || poll_to >= 0x34bc00) {
BT_WARN("Prohibited PollTimeout (0x%06x)", poll_to);
BT_WARN("%s, Prohibited PollTimeout (0x%06x)", __func__, poll_to);
return -EINVAL;
}
if (msg->num_elem == 0x00) {
BT_WARN("Prohibited NumElements value (0x00)");
BT_WARN("%s, Prohibited NumElements value (0x00)", __func__);
return -EINVAL;
}
if (!BT_MESH_ADDR_IS_UNICAST(rx->ctx.addr + msg->num_elem - 1)) {
BT_WARN("LPN elements stretch outside of unicast range");
if (!BLE_MESH_ADDR_IS_UNICAST(rx->ctx.addr + msg->num_elem - 1)) {
BT_WARN("%s, LPN elements stretch outside of unicast range", __func__);
return -EINVAL;
}
if (!MIN_QUEUE_SIZE_LOG(msg->criteria)) {
BT_WARN("Prohibited Minimum Queue Size in Friend Request");
BT_WARN("%s, Prohibited Minimum Queue Size in Friend Request", __func__);
return -EINVAL;
}
if (CONFIG_BT_MESH_FRIEND_QUEUE_SIZE < MIN_QUEUE_SIZE(msg->criteria)) {
BT_WARN("We have a too small Friend Queue size (%u < %u)",
CONFIG_BT_MESH_FRIEND_QUEUE_SIZE,
if (CONFIG_BLE_MESH_FRIEND_QUEUE_SIZE < MIN_QUEUE_SIZE(msg->criteria)) {
BT_WARN("%s, We have a too small Friend Queue size (%u < %u)",
__func__, CONFIG_BLE_MESH_FRIEND_QUEUE_SIZE,
MIN_QUEUE_SIZE(msg->criteria));
return 0;
}
frnd = bt_mesh_friend_find(rx->sub->net_idx, rx->ctx.addr, true, false);
if (frnd) {
BT_WARN("Existing LPN re-requesting Friendship");
BT_WARN("%s, Existing LPN re-requesting Friendship", __func__);
friend_clear(frnd);
goto init_friend;
}
@@ -864,7 +864,7 @@ int bt_mesh_friend_req(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
}
if (!frnd) {
BT_WARN("No free Friend contexts for new LPN");
BT_WARN("%s, No free Friend contexts for new LPN", __func__);
return -ENOMEM;
}
@@ -880,7 +880,7 @@ init_friend:
BT_DBG("LPN 0x%04x rssi %d recv_delay %u poll_to %ums",
frnd->lpn, rx->rssi, frnd->recv_delay, frnd->poll_to);
if (BT_MESH_ADDR_IS_UNICAST(frnd->clear.frnd) &&
if (BLE_MESH_ADDR_IS_UNICAST(frnd->clear.frnd) &&
!bt_mesh_elem_find(frnd->clear.frnd)) {
clear_procedure_start(frnd);
}
@@ -906,7 +906,7 @@ static struct bt_mesh_friend_seg *get_seg(struct bt_mesh_friend *frnd,
struct bt_mesh_friend_seg *seg = &frnd->seg[i];
struct net_buf *buf = (void *)sys_slist_peek_head(&seg->queue);
if (buf && BT_MESH_ADV(buf)->addr == src &&
if (buf && BLE_MESH_ADV(buf)->addr == src &&
FRIEND_ADV(buf)->seq_auth == *seq_auth) {
return seg;
}
@@ -928,7 +928,7 @@ static void enqueue_friend_pdu(struct bt_mesh_friend *frnd,
BT_DBG("type %u", type);
if (type == BT_MESH_FRIEND_PDU_SINGLE) {
if (type == BLE_MESH_FRIEND_PDU_SINGLE) {
if (frnd->sec_update) {
enqueue_update(frnd, 1);
}
@@ -938,17 +938,17 @@ static void enqueue_friend_pdu(struct bt_mesh_friend *frnd,
}
adv = FRIEND_ADV(buf);
seg = get_seg(frnd, BT_MESH_ADV(buf)->addr, &adv->seq_auth);
seg = get_seg(frnd, BLE_MESH_ADV(buf)->addr, &adv->seq_auth);
if (!seg) {
BT_ERR("No free friend segment RX contexts for 0x%04x",
BT_MESH_ADV(buf)->addr);
BT_ERR("%s, No free friend segment RX contexts for 0x%04x",
__func__, BLE_MESH_ADV(buf)->addr);
net_buf_unref(buf);
return;
}
net_buf_slist_put(&seg->queue, buf);
if (type == BT_MESH_FRIEND_PDU_COMPLETE) {
if (type == BLE_MESH_FRIEND_PDU_COMPLETE) {
if (frnd->sec_update) {
enqueue_update(frnd, 1);
}
@@ -988,7 +988,7 @@ static void buf_send_end(int err, void *user_data)
BT_DBG("err %d", err);
if (frnd->pending_req) {
BT_WARN("Another request before previous completed sending");
BT_WARN("%s, Another request before previous completed sending", __func__);
return;
}
@@ -1023,14 +1023,14 @@ static void friend_timeout(struct k_work *work)
}
if (frnd->established && !frnd->pending_req) {
BT_WARN("Friendship lost with 0x%04x", frnd->lpn);
BT_WARN("%s, Friendship lost with 0x%04x", __func__, frnd->lpn);
friend_clear(frnd);
return;
}
frnd->last = net_buf_slist_get(&frnd->queue);
if (!frnd->last) {
BT_WARN("Friendship not established with 0x%04x", frnd->lpn);
BT_WARN("%s, Friendship is not established with 0x%04x", __func__, frnd->lpn);
friend_clear(frnd);
return;
}
@@ -1053,7 +1053,7 @@ int bt_mesh_friend_init(void)
struct bt_mesh_friend *frnd = &bt_mesh.frnd[i];
int j;
frnd->net_idx = BT_MESH_KEY_UNUSED;
frnd->net_idx = BLE_MESH_KEY_UNUSED;
sys_slist_init(&frnd->queue);
@@ -1079,7 +1079,7 @@ static void friend_purge_old_ack(struct bt_mesh_friend *frnd, u64_t *seq_auth,
cur != NULL; prev = cur, cur = sys_slist_peek_next(cur)) {
struct net_buf *buf = (void *)cur;
if (BT_MESH_ADV(buf)->addr == src &&
if (BLE_MESH_ADV(buf)->addr == src &&
FRIEND_ADV(buf)->seq_auth == *seq_auth) {
BT_DBG("Removing old ack from Friend Queue");
@@ -1104,14 +1104,14 @@ static void friend_lpn_enqueue_rx(struct bt_mesh_friend *frnd,
BT_DBG("LPN 0x%04x queue_size %u", frnd->lpn, frnd->queue_size);
if (type == BT_MESH_FRIEND_PDU_SINGLE && seq_auth) {
if (type == BLE_MESH_FRIEND_PDU_SINGLE && seq_auth) {
friend_purge_old_ack(frnd, seq_auth, rx->ctx.addr);
}
info.src = rx->ctx.addr;
info.dst = rx->dst;
if (rx->net_if == BT_MESH_NET_IF_LOCAL) {
if (rx->net_if == BLE_MESH_NET_IF_LOCAL) {
info.ttl = rx->ctx.recv_ttl;
} else {
info.ttl = rx->ctx.recv_ttl - 1;
@@ -1123,11 +1123,11 @@ static void friend_lpn_enqueue_rx(struct bt_mesh_friend *frnd,
info.seq[1] = (rx->seq >> 8);
info.seq[2] = rx->seq;
info.iv_index = BT_MESH_NET_IVI_RX(rx);
info.iv_index = BLE_MESH_NET_IVI_RX(rx);
buf = create_friend_pdu(frnd, &info, sbuf);
if (!buf) {
BT_ERR("Failed to encode Friend buffer");
BT_ERR("%s, Failed to encode Friend buffer", __func__);
return;
}
@@ -1152,7 +1152,7 @@ static void friend_lpn_enqueue_tx(struct bt_mesh_friend *frnd,
BT_DBG("LPN 0x%04x", frnd->lpn);
if (type == BT_MESH_FRIEND_PDU_SINGLE && seq_auth) {
if (type == BLE_MESH_FRIEND_PDU_SINGLE && seq_auth) {
friend_purge_old_ack(frnd, seq_auth, tx->src);
}
@@ -1160,18 +1160,18 @@ static void friend_lpn_enqueue_tx(struct bt_mesh_friend *frnd,
info.dst = tx->ctx->addr;
info.ttl = tx->ctx->send_ttl;
info.ctl = (tx->ctx->app_idx == BT_MESH_KEY_UNUSED);
info.ctl = (tx->ctx->app_idx == BLE_MESH_KEY_UNUSED);
seq = bt_mesh_next_seq();
info.seq[0] = seq >> 16;
info.seq[1] = seq >> 8;
info.seq[2] = seq;
info.iv_index = BT_MESH_NET_IVI_TX;
info.iv_index = BLE_MESH_NET_IVI_TX;
buf = create_friend_pdu(frnd, &info, sbuf);
if (!buf) {
BT_ERR("Failed to encode Friend buffer");
BT_ERR("%s, Failed to encode Friend buffer", __func__);
return;
}
@@ -1197,7 +1197,7 @@ static bool friend_lpn_matches(struct bt_mesh_friend *frnd, u16_t net_idx,
return false;
}
if (BT_MESH_ADDR_IS_UNICAST(addr)) {
if (BLE_MESH_ADDR_IS_UNICAST(addr)) {
return is_lpn_unicast(frnd, addr);
}
@@ -1236,8 +1236,8 @@ void bt_mesh_friend_enqueue_rx(struct bt_mesh_net_rx *rx,
int i;
if (!rx->friend_match ||
(rx->ctx.recv_ttl <= 1 && rx->net_if != BT_MESH_NET_IF_LOCAL) ||
bt_mesh_friend_get() != BT_MESH_FRIEND_ENABLED) {
(rx->ctx.recv_ttl <= 1 && rx->net_if != BLE_MESH_NET_IF_LOCAL) ||
bt_mesh_friend_get() != BLE_MESH_FRIEND_ENABLED) {
return;
}
@@ -1261,7 +1261,7 @@ bool bt_mesh_friend_enqueue_tx(struct bt_mesh_net_tx *tx,
int i;
if (!bt_mesh_friend_match(tx->sub->net_idx, tx->ctx->addr) ||
bt_mesh_friend_get() != BT_MESH_FRIEND_ENABLED) {
bt_mesh_friend_get() != BLE_MESH_FRIEND_ENABLED) {
return matched;
}
@@ -1304,7 +1304,7 @@ void bt_mesh_friend_clear_incomplete(struct bt_mesh_subnet *sub, u16_t src,
continue;
}
if (BT_MESH_ADV(buf)->addr != src) {
if (BLE_MESH_ADV(buf)->addr != src) {
continue;
}
@@ -1312,7 +1312,7 @@ void bt_mesh_friend_clear_incomplete(struct bt_mesh_subnet *sub, u16_t src,
continue;
}
BT_WARN("Clearing incomplete segments for 0x%04x", src);
BT_WARN("%s, Clearing incomplete segments for 0x%04x", __func__, src);
while (!sys_slist_is_empty(&seg->queue)) {
net_buf_unref(net_buf_slist_get(&seg->queue));
@@ -1320,5 +1320,5 @@ void bt_mesh_friend_clear_incomplete(struct bt_mesh_subnet *sub, u16_t src,
}
}
}
#endif /* CONFIG_BT_MESH_FRIEND */
#endif /* #if CONFIG_BT_MESH */
#endif /* CONFIG_BLE_MESH_FRIEND */

View File

@@ -6,10 +6,13 @@
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _FRIEND_H_
#define _FRIEND_H_
enum bt_mesh_friend_pdu_type {
BT_MESH_FRIEND_PDU_SINGLE,
BT_MESH_FRIEND_PDU_PARTIAL,
BT_MESH_FRIEND_PDU_COMPLETE,
BLE_MESH_FRIEND_PDU_SINGLE,
BLE_MESH_FRIEND_PDU_PARTIAL,
BLE_MESH_FRIEND_PDU_COMPLETE,
};
bool bt_mesh_friend_match(u16_t net_idx, u16_t addr);
@@ -32,13 +35,20 @@ void bt_mesh_friend_sec_update(u16_t net_idx);
void bt_mesh_friend_clear_net_idx(u16_t net_idx);
int bt_mesh_friend_poll(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf);
int bt_mesh_friend_req(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf);
int bt_mesh_friend_clear(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf);
int bt_mesh_friend_clear_cfm(struct bt_mesh_net_rx *rx,
struct net_buf_simple *buf);
int bt_mesh_friend_sub_add(struct bt_mesh_net_rx *rx,
struct net_buf_simple *buf);
int bt_mesh_friend_sub_rem(struct bt_mesh_net_rx *rx,
struct net_buf_simple *buf);
int bt_mesh_friend_init(void);
#endif /* _FRIEND_H_ */

View File

@@ -11,19 +11,18 @@
#include <errno.h>
#include <stdbool.h>
#include "osi/allocator.h"
#include "sdkconfig.h"
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_MODEL)
#include "mesh_types.h"
#include "mesh_util.h"
#include "sdkconfig.h"
#include "osi/allocator.h"
#if CONFIG_BT_MESH
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_MODEL)
#include "mesh_trace.h"
#include "health_cli.h"
#include "foundation.h"
#include "common.h"
#include "btc_ble_mesh_health.h"
#include "mesh_common.h"
#include "btc_ble_mesh_health_model.h"
s32_t health_msg_timeout;
@@ -41,27 +40,27 @@ static const bt_mesh_client_op_pair_t health_op_pair[] = {
static void timeout_handler(struct k_work *work)
{
bt_mesh_health_client_t *client = NULL;
health_internal_data_t *internal = NULL;
bt_mesh_client_node_t *node = NULL;
health_internal_data_t *internal = NULL;
bt_mesh_health_client_t *client = NULL;
bt_mesh_client_node_t *node = NULL;
BT_WARN("Receive health status message timeout");
node = CONTAINER_OF(work, bt_mesh_client_node_t, timer.work);
if (!node || !node->ctx.model) {
BT_ERR("%s: node parameter is NULL", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
client = (bt_mesh_health_client_t *)node->ctx.model->user_data;
if (!client) {
BT_ERR("%s: model user_data is NULL", __func__);
BT_ERR("%s, Health Client user_data is NULL", __func__);
return;
}
internal = (health_internal_data_t *)client->internal_data;
if (!internal) {
BT_ERR("%s: internal_data is NULL", __func__);
BT_ERR("%s, Health Client internal_data is NULL", __func__);
return;
}
@@ -78,18 +77,18 @@ static void health_client_cancel(struct bt_mesh_model *model,
void *status, size_t len)
{
health_internal_data_t *data = NULL;
bt_mesh_client_node_t *node = NULL;
bt_mesh_client_node_t *node = NULL;
struct net_buf_simple buf = {0};
u8_t evt_type = 0xFF;
if (!model || !ctx || !status || !len) {
BT_ERR("%s: invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return;
}
data = (health_internal_data_t *)health_cli->internal_data;
if (!data) {
BT_ERR("%s: health client internal_data is NULL", __func__);
BT_ERR("%s, Health Client internal_data is NULL", __func__);
return;
}
@@ -145,10 +144,10 @@ static void health_fault_status(struct bt_mesh_model *model,
bt_hex(buf->data, buf->len));
status.test_id = net_buf_simple_pull_u8(buf);
status.cid = net_buf_simple_pull_le16(buf);
status.cid = net_buf_simple_pull_le16(buf);
status.fault_array = bt_mesh_alloc_buf(buf->len);
if (!status.fault_array) {
BT_ERR("%s: allocate memory for fault_array fail", __func__);
BT_ERR("%s, Failed to allocate memory", __func__);
return;
}
@@ -163,7 +162,7 @@ static void health_current_status(struct bt_mesh_model *model,
struct net_buf_simple *buf)
{
bt_mesh_client_node_t *node = NULL;
u8_t test_id;
u8_t test_id;
u16_t cid;
BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s",
@@ -176,7 +175,7 @@ static void health_current_status(struct bt_mesh_model *model,
}
test_id = net_buf_simple_pull_u8(buf);
cid = net_buf_simple_pull_le16(buf);
cid = net_buf_simple_pull_le16(buf);
BT_DBG("Test ID 0x%02x Company ID 0x%04x Fault Count %u",
test_id, cid, buf->len);
@@ -217,7 +216,7 @@ const struct bt_mesh_model_op bt_mesh_health_cli_op[] = {
{ OP_HEALTH_CURRENT_STATUS, 3, health_current_status },
{ OP_HEALTH_PERIOD_STATUS, 1, health_period_status },
{ OP_ATTENTION_STATUS, 1, health_attention_status },
BT_MESH_MODEL_OP_END,
BLE_MESH_MODEL_OP_END,
};
int bt_mesh_health_attention_get(struct bt_mesh_msg_ctx *ctx)
@@ -235,7 +234,7 @@ int bt_mesh_health_attention_get(struct bt_mesh_msg_ctx *ctx)
msg, timeout_handler, health_msg_timeout,
true, NULL, NULL);
if (err) {
BT_ERR("%s: send failed (err %d)", __func__, err);
BT_ERR("%s, send failed (err %d)", __func__, err);
}
return err;
@@ -246,7 +245,7 @@ int bt_mesh_health_attention_set(struct bt_mesh_msg_ctx *ctx,
{
struct net_buf_simple *msg = NET_BUF_SIMPLE(2 + 1 + 4);
u32_t opcode;
int err;
int err;
if (!ctx || !ctx->addr) {
return -EINVAL;
@@ -264,7 +263,7 @@ int bt_mesh_health_attention_set(struct bt_mesh_msg_ctx *ctx,
timeout_handler, health_msg_timeout,
need_ack, NULL, NULL);
if (err) {
BT_ERR("%s: send failed (err %d)", __func__, err);
BT_ERR("%s, send failed (err %d)", __func__, err);
}
return err;
@@ -285,7 +284,7 @@ int bt_mesh_health_period_get(struct bt_mesh_msg_ctx *ctx)
ctx, msg, timeout_handler, health_msg_timeout,
true, NULL, NULL);
if (err) {
BT_ERR("%s: send failed (err %d)", __func__, err);
BT_ERR("%s, send failed (err %d)", __func__, err);
}
return err;
@@ -296,7 +295,7 @@ int bt_mesh_health_period_set(struct bt_mesh_msg_ctx *ctx,
{
struct net_buf_simple *msg = NET_BUF_SIMPLE(2 + 1 + 4);
u32_t opcode;
int err;
int err;
if (!ctx || !ctx->addr) {
return -EINVAL;
@@ -314,7 +313,7 @@ int bt_mesh_health_period_set(struct bt_mesh_msg_ctx *ctx,
timeout_handler, health_msg_timeout,
need_ack, NULL, NULL);
if (err) {
BT_ERR("%s: send failed (err %d)", __func__, err);
BT_ERR("%s, send failed (err %d)", __func__, err);
}
return err;
@@ -325,7 +324,7 @@ int bt_mesh_health_fault_test(struct bt_mesh_msg_ctx *ctx,
{
struct net_buf_simple *msg = NET_BUF_SIMPLE(2 + 3 + 4);
u32_t opcode;
int err;
int err;
if (!ctx || !ctx->addr) {
return -EINVAL;
@@ -344,7 +343,7 @@ int bt_mesh_health_fault_test(struct bt_mesh_msg_ctx *ctx,
timeout_handler, health_msg_timeout,
need_ack, NULL, NULL);
if (err) {
BT_ERR("%s: send failed (err %d)", __func__, err);
BT_ERR("%s, send failed (err %d)", __func__, err);
}
return err;
@@ -355,7 +354,7 @@ int bt_mesh_health_fault_clear(struct bt_mesh_msg_ctx *ctx,
{
struct net_buf_simple *msg = NET_BUF_SIMPLE(2 + 2 + 4);
u32_t opcode;
int err;
int err;
if (!ctx || !ctx->addr) {
return -EINVAL;
@@ -373,7 +372,7 @@ int bt_mesh_health_fault_clear(struct bt_mesh_msg_ctx *ctx,
timeout_handler, health_msg_timeout,
need_ack, NULL, NULL);
if (err) {
BT_ERR("%s: send failed (err %d)", __func__, err);
BT_ERR("%s, send failed (err %d)", __func__, err);
}
return err;
@@ -395,7 +394,7 @@ int bt_mesh_health_fault_get(struct bt_mesh_msg_ctx *ctx, u16_t cid)
msg, timeout_handler, health_msg_timeout,
true, NULL, NULL);
if (err) {
BT_ERR("%s: send failed (err %d)", __func__, err);
BT_ERR("%s, send failed (err %d)", __func__, err);
}
return err;
@@ -414,7 +413,7 @@ void bt_mesh_health_cli_timeout_set(s32_t timeout)
int bt_mesh_health_cli_set(struct bt_mesh_model *model)
{
if (!model || !model->user_data) {
BT_ERR("No Health Client context for given model");
BT_ERR("%s, No Health Client context for given model", __func__);
return -EINVAL;
}
@@ -425,34 +424,34 @@ int bt_mesh_health_cli_set(struct bt_mesh_model *model)
int bt_mesh_health_cli_init(struct bt_mesh_model *model, bool primary)
{
bt_mesh_health_client_t *client = NULL;
health_internal_data_t *internal = NULL;
health_internal_data_t *internal = NULL;
bt_mesh_health_client_t *client = NULL;
BT_DBG("primary %u", primary);
if (!model) {
BT_ERR("Health Client model is NULL");
BT_ERR("%s, Invalid parameter", __func__);
return -EINVAL;
}
client = (bt_mesh_health_client_t *)model->user_data;
if (!client) {
BT_ERR("No Health Client context provided");
BT_ERR("%s, No Health Client context provided", __func__);
return -EINVAL;
}
/* TODO: call osi_free() when deinit function is invoked*/
internal = osi_calloc(sizeof(health_internal_data_t));
if (!internal) {
BT_ERR("Allocate memory for Health Client internal data fail");
BT_ERR("%s, Failed to allocate memory", __func__);
return -ENOMEM;
}
sys_slist_init(&internal->queue);
client->model = model;
client->op_pair_size = ARRAY_SIZE(health_op_pair);
client->op_pair = health_op_pair;
client->model = model;
client->op_pair_size = ARRAY_SIZE(health_op_pair);
client->op_pair = health_op_pair;
client->internal_data = internal;
/* Set the default health client pointer */
@@ -462,5 +461,3 @@ int bt_mesh_health_cli_init(struct bt_mesh_model *model, bool primary)
return 0;
}
#endif /* #if CONFIG_BT_MESH */

View File

@@ -10,22 +10,22 @@
#include <string.h>
#include <errno.h>
#include <stdbool.h>
#include "sdkconfig.h"
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_MODEL)
#include "mesh_types.h"
#include "mesh_util.h"
#include "sdkconfig.h"
#if CONFIG_BT_MESH
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_MODEL)
#include "mesh_trace.h"
#include "health_srv.h"
#include "mesh.h"
#include "adv.h"
#include "net.h"
#include "transport.h"
#include "access.h"
#include "foundation.h"
#include "common.h"
#include "mesh_common.h"
#define HEALTH_TEST_STANDARD 0x00
@@ -38,11 +38,11 @@
/* Health Server context of the primary element */
struct bt_mesh_health_srv *health_srv;
static void health_get_registered(struct bt_mesh_model *mod,
static void health_get_registered(struct bt_mesh_model *model,
u16_t company_id,
struct net_buf_simple *msg)
{
struct bt_mesh_health_srv *srv = mod->user_data;
struct bt_mesh_health_srv *srv = model->user_data;
u8_t *test_id;
BT_DBG("Company ID 0x%04x", company_id);
@@ -61,11 +61,11 @@ static void health_get_registered(struct bt_mesh_model *mod,
u8_t fault_count = net_buf_simple_tailroom(msg) - 4;
int err;
err = srv->cb->fault_get_reg(mod, company_id, test_id,
err = srv->cb->fault_get_reg(model, company_id, test_id,
net_buf_simple_tail(msg),
&fault_count);
if (err) {
BT_ERR("Failed to get faults (err %d)", err);
BT_ERR("%s, Failed to get faults (err %d)", __func__, err);
*test_id = HEALTH_TEST_STANDARD;
} else {
net_buf_simple_add(msg, fault_count);
@@ -76,10 +76,10 @@ static void health_get_registered(struct bt_mesh_model *mod,
}
}
static size_t health_get_current(struct bt_mesh_model *mod,
static size_t health_get_current(struct bt_mesh_model *model,
struct net_buf_simple *msg)
{
struct bt_mesh_health_srv *srv = mod->user_data;
struct bt_mesh_health_srv *srv = model->user_data;
const struct bt_mesh_comp *comp;
u8_t *test_id, *company_ptr;
u16_t company_id;
@@ -99,11 +99,11 @@ static size_t health_get_current(struct bt_mesh_model *mod,
if (srv->cb && srv->cb->fault_get_cur) {
fault_count = net_buf_simple_tailroom(msg);
err = srv->cb->fault_get_cur(mod, test_id, &company_id,
err = srv->cb->fault_get_cur(model, test_id, &company_id,
net_buf_simple_tail(msg),
&fault_count);
if (err) {
BT_ERR("Failed to get faults (err %d)", err);
BT_ERR("%s, Failed to get faults (err %d)", __func__, err);
sys_put_le16(comp->cid, company_ptr);
*test_id = HEALTH_TEST_STANDARD;
fault_count = 0;
@@ -132,7 +132,7 @@ static void health_fault_get(struct bt_mesh_model *model,
BT_DBG("company_id 0x%04x", company_id);
sdu = bt_mesh_alloc_buf(min(BT_MESH_TX_SDU_MAX, HEALTH_FAULT_MAX_LEN));
sdu = bt_mesh_alloc_buf(MIN(BLE_MESH_TX_SDU_MAX, HEALTH_FAULT_MAX_LEN));
if (!sdu) {
BT_ERR("%s, Failed to allocate memory", __func__);
return;
@@ -141,7 +141,7 @@ static void health_fault_get(struct bt_mesh_model *model,
health_get_registered(model, company_id, sdu);
if (bt_mesh_model_send(model, ctx, sdu, NULL, NULL)) {
BT_ERR("Unable to send Health Current Status response");
BT_ERR("%s, Unable to send Health Current Status", __func__);
}
bt_mesh_free_buf(sdu);
@@ -190,7 +190,7 @@ static void health_fault_clear(struct bt_mesh_model *model,
srv->cb->fault_clear(model, company_id);
}
sdu = bt_mesh_alloc_buf(min(BT_MESH_TX_SDU_MAX, HEALTH_FAULT_MAX_LEN));
sdu = bt_mesh_alloc_buf(MIN(BLE_MESH_TX_SDU_MAX, HEALTH_FAULT_MAX_LEN));
if (!sdu) {
BT_ERR("%s, Failed to allocate memory", __func__);
return;
@@ -199,7 +199,7 @@ static void health_fault_clear(struct bt_mesh_model *model,
health_get_registered(model, company_id, sdu);
if (bt_mesh_model_send(model, ctx, sdu, NULL, NULL)) {
BT_ERR("Unable to send Health Current Status response");
BT_ERR("%s, Unable to send Health Current Status", __func__);
}
bt_mesh_free_buf(sdu);
@@ -260,7 +260,7 @@ static void health_fault_test(struct bt_mesh_model *model,
}
}
sdu = bt_mesh_alloc_buf(min(BT_MESH_TX_SDU_MAX, HEALTH_FAULT_MAX_LEN));
sdu = bt_mesh_alloc_buf(MIN(BLE_MESH_TX_SDU_MAX, HEALTH_FAULT_MAX_LEN));
if (!sdu) {
BT_ERR("%s, Failed to allocate memory", __func__);
return;
@@ -269,7 +269,7 @@ static void health_fault_test(struct bt_mesh_model *model,
health_get_registered(model, company_id, sdu);
if (bt_mesh_model_send(model, ctx, sdu, NULL, NULL)) {
BT_ERR("Unable to send Health Current Status response");
BT_ERR("%s, Unable to send Health Current Status", __func__);
}
bt_mesh_free_buf(sdu);
@@ -297,7 +297,7 @@ static void send_attention_status(struct bt_mesh_model *model,
net_buf_simple_add_u8(msg, time);
if (bt_mesh_model_send(model, ctx, msg, NULL, NULL)) {
BT_ERR("Unable to send Attention Status");
BT_ERR("%s, Unable to send Health Attention Status", __func__);
}
}
@@ -345,7 +345,7 @@ static void send_health_period_status(struct bt_mesh_model *model,
net_buf_simple_add_u8(msg, model->pub->period_div);
if (bt_mesh_model_send(model, ctx, msg, NULL, NULL)) {
BT_ERR("Unable to send Health Period Status");
BT_ERR("%s, Unable to send Health Period Status", __func__);
}
}
@@ -366,7 +366,7 @@ static void health_period_set_unrel(struct bt_mesh_model *model,
period = net_buf_simple_pull_u8(buf);
if (period > 15) {
BT_WARN("Prohibited period value %u", period);
BT_WARN("%s, Prohibited period value %u", __func__, period);
return;
}
@@ -387,28 +387,28 @@ static void health_period_set(struct bt_mesh_model *model,
}
const struct bt_mesh_model_op bt_mesh_health_srv_op[] = {
{ OP_HEALTH_FAULT_GET, 2, health_fault_get },
{ OP_HEALTH_FAULT_CLEAR, 2, health_fault_clear },
{ OP_HEALTH_FAULT_CLEAR_UNREL, 2, health_fault_clear_unrel },
{ OP_HEALTH_FAULT_TEST, 3, health_fault_test },
{ OP_HEALTH_FAULT_TEST_UNREL, 3, health_fault_test_unrel },
{ OP_HEALTH_PERIOD_GET, 0, health_period_get },
{ OP_HEALTH_PERIOD_SET, 1, health_period_set },
{ OP_HEALTH_PERIOD_SET_UNREL, 1, health_period_set_unrel },
{ OP_ATTENTION_GET, 0, attention_get },
{ OP_ATTENTION_SET, 1, attention_set },
{ OP_ATTENTION_SET_UNREL, 1, attention_set_unrel },
BT_MESH_MODEL_OP_END,
{ OP_HEALTH_FAULT_GET, 2, health_fault_get },
{ OP_HEALTH_FAULT_CLEAR, 2, health_fault_clear },
{ OP_HEALTH_FAULT_CLEAR_UNREL, 2, health_fault_clear_unrel },
{ OP_HEALTH_FAULT_TEST, 3, health_fault_test },
{ OP_HEALTH_FAULT_TEST_UNREL, 3, health_fault_test_unrel },
{ OP_HEALTH_PERIOD_GET, 0, health_period_get },
{ OP_HEALTH_PERIOD_SET, 1, health_period_set },
{ OP_HEALTH_PERIOD_SET_UNREL, 1, health_period_set_unrel },
{ OP_ATTENTION_GET, 0, attention_get },
{ OP_ATTENTION_SET, 1, attention_set },
{ OP_ATTENTION_SET_UNREL, 1, attention_set_unrel },
BLE_MESH_MODEL_OP_END,
};
static int health_pub_update(struct bt_mesh_model *mod)
static int health_pub_update(struct bt_mesh_model *model)
{
struct bt_mesh_model_pub *pub = mod->pub;
struct bt_mesh_model_pub *pub = model->pub;
size_t count;
BT_DBG("%s", __func__);
count = health_get_current(mod, pub->msg);
count = health_get_current(model, pub->msg);
if (!count) {
pub->period_div = 0;
}
@@ -418,14 +418,14 @@ static int health_pub_update(struct bt_mesh_model *mod)
int bt_mesh_fault_update(struct bt_mesh_elem *elem)
{
struct bt_mesh_model *mod;
struct bt_mesh_model *model;
mod = bt_mesh_model_find(elem, BT_MESH_MODEL_ID_HEALTH_SRV);
if (!mod) {
model = bt_mesh_model_find(elem, BLE_MESH_MODEL_ID_HEALTH_SRV);
if (!model) {
return -EINVAL;
}
return bt_mesh_model_publish(mod);
return bt_mesh_model_publish(model);
}
static void attention_off(struct k_work *work)
@@ -508,5 +508,3 @@ void bt_mesh_attention(struct bt_mesh_model *model, u8_t time)
}
}
}
#endif /* #if CONFIG_BT_MESH */

View File

@@ -8,12 +8,12 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __BT_MESH_CFG_CLI_H
#define __BT_MESH_CFG_CLI_H
#ifndef _BLE_MESH_CFG_CLI_H_
#define _BLE_MESH_CFG_CLI_H_
#include "mesh_access.h"
#include "mesh_kernel.h"
#include "bt_mesh_client_common.h"
#include "model_common.h"
/**
* @brief Bluetooth Mesh
@@ -28,9 +28,9 @@ typedef bt_mesh_internal_data_t config_internal_data_t;
extern const struct bt_mesh_model_op bt_mesh_cfg_cli_op[];
#define BT_MESH_MODEL_CFG_CLI(cli_data) \
BT_MESH_MODEL(BT_MESH_MODEL_ID_CFG_CLI, \
bt_mesh_cfg_cli_op, NULL, cli_data)
#define BLE_MESH_MODEL_CFG_CLI(cli_data) \
BLE_MESH_MODEL(BLE_MESH_MODEL_ID_CFG_CLI, \
bt_mesh_cfg_cli_op, NULL, cli_data)
int bt_mesh_cfg_comp_data_get(struct bt_mesh_msg_ctx *ctx, u8_t page);
@@ -64,12 +64,12 @@ int bt_mesh_cfg_mod_app_bind(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
u16_t mod_app_idx, u16_t mod_id, u16_t cid);
struct bt_mesh_cfg_mod_pub {
u16_t addr;
u16_t app_idx;
bool cred_flag;
u8_t ttl;
u8_t period;
u8_t transmit;
u16_t addr;
u16_t app_idx;
bool cred_flag;
u8_t ttl;
u8_t period;
u8_t transmit;
};
int bt_mesh_cfg_mod_pub_get(struct bt_mesh_msg_ctx *ctx, u16_t elem_addr,
@@ -294,4 +294,4 @@ int bt_mesh_cfg_net_transmit_set(struct bt_mesh_msg_ctx *ctx, u8_t transmit);
* @}
*/
#endif /* __BT_MESH_CFG_CLI_H */
#endif /* __BLE_MESH_CFG_CLI_H */

View File

@@ -7,8 +7,8 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __BT_MESH_CFG_SRV_H
#define __BT_MESH_CFG_SRV_H
#ifndef _BLE_MESH_CFG_SRV_H_
#define _BLE_MESH_CFG_SRV_H_
#include "mesh_access.h"
#include "mesh_kernel.h"
@@ -61,12 +61,12 @@ struct bt_mesh_cfg_srv {
extern const struct bt_mesh_model_op bt_mesh_cfg_srv_op[];
#define BT_MESH_MODEL_CFG_SRV(srv_data) \
BT_MESH_MODEL(BT_MESH_MODEL_ID_CFG_SRV, \
bt_mesh_cfg_srv_op, NULL, srv_data)
#define BLE_MESH_MODEL_CFG_SRV(srv_data) \
BLE_MESH_MODEL(BLE_MESH_MODEL_ID_CFG_SRV, \
bt_mesh_cfg_srv_op, NULL, srv_data)
/**
* @}
*/
#endif /* __BT_MESH_CFG_SRV_H */
#endif /* __BLE_MESH_CFG_SRV_H */

View File

@@ -1,495 +0,0 @@
/*
* Copyright (c) 2013-2015 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @file
* @brief Doubly-linked list implementation
*
* Doubly-linked list implementation using inline macros/functions.
* This API is not thread safe, and thus if a list is used across threads,
* calls to functions must be protected with synchronization primitives.
*
* The lists are expected to be initialized such that both the head and tail
* pointers point to the list itself. Initializing the lists in such a fashion
* simplifies the adding and removing of nodes to/from the list.
*/
#ifndef _misc_dlist__h_
#define _misc_dlist__h_
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
struct _dnode {
union {
struct _dnode *head; /* ptr to head of list (sys_dlist_t) */
struct _dnode *next; /* ptr to next node (sys_dnode_t) */
};
union {
struct _dnode *tail; /* ptr to tail of list (sys_dlist_t) */
struct _dnode *prev; /* ptr to previous node (sys_dnode_t) */
};
};
typedef struct _dnode sys_dlist_t;
typedef struct _dnode sys_dnode_t;
/**
* @brief Provide the primitive to iterate on a list
* Note: the loop is unsafe and thus __dn should not be removed
*
* User _MUST_ add the loop statement curly braces enclosing its own code:
*
* SYS_DLIST_FOR_EACH_NODE(l, n) {
* <user code>
* }
*
* This and other SYS_DLIST_*() macros are not thread safe.
*
* @param __dl A pointer on a sys_dlist_t to iterate on
* @param __dn A sys_dnode_t pointer to peek each node of the list
*/
#define SYS_DLIST_FOR_EACH_NODE(__dl, __dn) \
for (__dn = sys_dlist_peek_head(__dl); __dn; \
__dn = sys_dlist_peek_next(__dl, __dn))
/**
* @brief Provide the primitive to iterate on a list, from a node in the list
* Note: the loop is unsafe and thus __dn should not be removed
*
* User _MUST_ add the loop statement curly braces enclosing its own code:
*
* SYS_DLIST_ITERATE_FROM_NODE(l, n) {
* <user code>
* }
*
* Like SYS_DLIST_FOR_EACH_NODE(), but __dn already contains a node in the list
* where to start searching for the next entry from. If NULL, it starts from
* the head.
*
* This and other SYS_DLIST_*() macros are not thread safe.
*
* @param __dl A pointer on a sys_dlist_t to iterate on
* @param __dn A sys_dnode_t pointer to peek each node of the list;
* it contains the starting node, or NULL to start from the head
*/
#define SYS_DLIST_ITERATE_FROM_NODE(__dl, __dn) \
for (__dn = __dn ? sys_dlist_peek_next_no_check(__dl, __dn) \
: sys_dlist_peek_head(__dl); \
__dn; \
__dn = sys_dlist_peek_next(__dl, __dn))
/**
* @brief Provide the primitive to safely iterate on a list
* Note: __dn can be removed, it will not break the loop.
*
* User _MUST_ add the loop statement curly braces enclosing its own code:
*
* SYS_DLIST_FOR_EACH_NODE_SAFE(l, n, s) {
* <user code>
* }
*
* This and other SYS_DLIST_*() macros are not thread safe.
*
* @param __dl A pointer on a sys_dlist_t to iterate on
* @param __dn A sys_dnode_t pointer to peek each node of the list
* @param __dns A sys_dnode_t pointer for the loop to run safely
*/
#define SYS_DLIST_FOR_EACH_NODE_SAFE(__dl, __dn, __dns) \
for (__dn = sys_dlist_peek_head(__dl), \
__dns = sys_dlist_peek_next(__dl, __dn); \
__dn; __dn = __dns, \
__dns = sys_dlist_peek_next(__dl, __dn))
/*
* @brief Provide the primitive to resolve the container of a list node
* Note: it is safe to use with NULL pointer nodes
*
* @param __dn A pointer on a sys_dnode_t to get its container
* @param __cn Container struct type pointer
* @param __n The field name of sys_dnode_t within the container struct
*/
#define SYS_DLIST_CONTAINER(__dn, __cn, __n) \
(__dn ? CONTAINER_OF(__dn, __typeof__(*__cn), __n) : NULL)
/*
* @brief Provide the primitive to peek container of the list head
*
* @param __dl A pointer on a sys_dlist_t to peek
* @param __cn Container struct type pointer
* @param __n The field name of sys_dnode_t within the container struct
*/
#define SYS_DLIST_PEEK_HEAD_CONTAINER(__dl, __cn, __n) \
SYS_DLIST_CONTAINER(sys_dlist_peek_head(__dl), __cn, __n)
/*
* @brief Provide the primitive to peek the next container
*
* @param __dl A pointer on a sys_dlist_t to peek
* @param __cn Container struct type pointer
* @param __n The field name of sys_dnode_t within the container struct
*/
#define SYS_DLIST_PEEK_NEXT_CONTAINER(__dl, __cn, __n) \
((__cn) ? SYS_DLIST_CONTAINER(sys_dlist_peek_next(__dl, &(__cn->__n)), \
__cn, __n) : NULL)
/**
* @brief Provide the primitive to iterate on a list under a container
* Note: the loop is unsafe and thus __cn should not be detached
*
* User _MUST_ add the loop statement curly braces enclosing its own code:
*
* SYS_DLIST_FOR_EACH_CONTAINER(l, c, n) {
* <user code>
* }
*
* @param __dl A pointer on a sys_dlist_t to iterate on
* @param __cn A pointer to peek each entry of the list
* @param __n The field name of sys_dnode_t within the container struct
*/
#define SYS_DLIST_FOR_EACH_CONTAINER(__dl, __cn, __n) \
for (__cn = SYS_DLIST_PEEK_HEAD_CONTAINER(__dl, __cn, __n); __cn; \
__cn = SYS_DLIST_PEEK_NEXT_CONTAINER(__dl, __cn, __n))
/**
* @brief Provide the primitive to safely iterate on a list under a container
* Note: __cn can be detached, it will not break the loop.
*
* User _MUST_ add the loop statement curly braces enclosing its own code:
*
* SYS_DLIST_FOR_EACH_CONTAINER_SAFE(l, c, cn, n) {
* <user code>
* }
*
* @param __dl A pointer on a sys_dlist_t to iterate on
* @param __cn A pointer to peek each entry of the list
* @param __cns A pointer for the loop to run safely
* @param __n The field name of sys_dnode_t within the container struct
*/
#define SYS_DLIST_FOR_EACH_CONTAINER_SAFE(__dl, __cn, __cns, __n) \
for (__cn = SYS_DLIST_PEEK_HEAD_CONTAINER(__dl, __cn, __n), \
__cns = SYS_DLIST_PEEK_NEXT_CONTAINER(__dl, __cn, __n); __cn; \
__cn = __cns, \
__cns = SYS_DLIST_PEEK_NEXT_CONTAINER(__dl, __cn, __n))
/**
* @brief initialize list
*
* @param list the doubly-linked list
*
* @return N/A
*/
static inline void sys_dlist_init(sys_dlist_t *list)
{
list->head = (sys_dnode_t *)list;
list->tail = (sys_dnode_t *)list;
}
#define SYS_DLIST_STATIC_INIT(ptr_to_list) {{(ptr_to_list)}, {(ptr_to_list)}}
/**
* @brief check if a node is the list's head
*
* @param list the doubly-linked list to operate on
* @param node the node to check
*
* @return 1 if node is the head, 0 otherwise
*/
static inline int sys_dlist_is_head(sys_dlist_t *list, sys_dnode_t *node)
{
return list->head == node;
}
/**
* @brief check if a node is the list's tail
*
* @param list the doubly-linked list to operate on
* @param node the node to check
*
* @return 1 if node is the tail, 0 otherwise
*/
static inline int sys_dlist_is_tail(sys_dlist_t *list, sys_dnode_t *node)
{
return list->tail == node;
}
/**
* @brief check if the list is empty
*
* @param list the doubly-linked list to operate on
*
* @return 1 if empty, 0 otherwise
*/
static inline int sys_dlist_is_empty(sys_dlist_t *list)
{
return list->head == list;
}
/**
* @brief check if more than one node present
*
* This and other sys_dlist_*() functions are not thread safe.
*
* @param list the doubly-linked list to operate on
*
* @return 1 if multiple nodes, 0 otherwise
*/
static inline int sys_dlist_has_multiple_nodes(sys_dlist_t *list)
{
return list->head != list->tail;
}
/**
* @brief get a reference to the head item in the list
*
* @param list the doubly-linked list to operate on
*
* @return a pointer to the head element, NULL if list is empty
*/
static inline sys_dnode_t *sys_dlist_peek_head(sys_dlist_t *list)
{
return sys_dlist_is_empty(list) ? NULL : list->head;
}
/**
* @brief get a reference to the head item in the list
*
* The list must be known to be non-empty.
*
* @param list the doubly-linked list to operate on
*
* @return a pointer to the head element
*/
static inline sys_dnode_t *sys_dlist_peek_head_not_empty(sys_dlist_t *list)
{
return list->head;
}
/**
* @brief get a reference to the next item in the list, node is not NULL
*
* Faster than sys_dlist_peek_next() if node is known not to be NULL.
*
* @param list the doubly-linked list to operate on
* @param node the node from which to get the next element in the list
*
* @return a pointer to the next element from a node, NULL if node is the tail
*/
static inline sys_dnode_t *sys_dlist_peek_next_no_check(sys_dlist_t *list,
sys_dnode_t *node)
{
return (node == list->tail) ? NULL : node->next;
}
/**
* @brief get a reference to the next item in the list
*
* @param list the doubly-linked list to operate on
* @param node the node from which to get the next element in the list
*
* @return a pointer to the next element from a node, NULL if node is the tail
* or NULL (when node comes from reading the head of an empty list).
*/
static inline sys_dnode_t *sys_dlist_peek_next(sys_dlist_t *list,
sys_dnode_t *node)
{
return node ? sys_dlist_peek_next_no_check(list, node) : NULL;
}
/**
* @brief get a reference to the tail item in the list
*
* @param list the doubly-linked list to operate on
*
* @return a pointer to the tail element, NULL if list is empty
*/
static inline sys_dnode_t *sys_dlist_peek_tail(sys_dlist_t *list)
{
return sys_dlist_is_empty(list) ? NULL : list->tail;
}
/**
* @brief add node to tail of list
*
* This and other sys_dlist_*() functions are not thread safe.
*
* @param list the doubly-linked list to operate on
* @param node the element to append
*
* @return N/A
*/
static inline void sys_dlist_append(sys_dlist_t *list, sys_dnode_t *node)
{
node->next = list;
node->prev = list->tail;
list->tail->next = node;
list->tail = node;
}
/**
* @brief add node to head of list
*
* This and other sys_dlist_*() functions are not thread safe.
*
* @param list the doubly-linked list to operate on
* @param node the element to append
*
* @return N/A
*/
static inline void sys_dlist_prepend(sys_dlist_t *list, sys_dnode_t *node)
{
node->next = list->head;
node->prev = list;
list->head->prev = node;
list->head = node;
}
/**
* @brief insert node after a node
*
* Insert a node after a specified node in a list.
* This and other sys_dlist_*() functions are not thread safe.
*
* @param list the doubly-linked list to operate on
* @param insert_point the insert point in the list: if NULL, insert at head
* @param node the element to append
*
* @return N/A
*/
static inline void sys_dlist_insert_after(sys_dlist_t *list,
sys_dnode_t *insert_point, sys_dnode_t *node)
{
if (!insert_point) {
sys_dlist_prepend(list, node);
} else {
node->next = insert_point->next;
node->prev = insert_point;
insert_point->next->prev = node;
insert_point->next = node;
}
}
/**
* @brief insert node before a node
*
* Insert a node before a specified node in a list.
* This and other sys_dlist_*() functions are not thread safe.
*
* @param list the doubly-linked list to operate on
* @param insert_point the insert point in the list: if NULL, insert at tail
* @param node the element to insert
*
* @return N/A
*/
static inline void sys_dlist_insert_before(sys_dlist_t *list,
sys_dnode_t *insert_point, sys_dnode_t *node)
{
if (!insert_point) {
sys_dlist_append(list, node);
} else {
node->prev = insert_point->prev;
node->next = insert_point;
insert_point->prev->next = node;
insert_point->prev = node;
}
}
/**
* @brief insert node at position
*
* Insert a node in a location depending on a external condition. The cond()
* function checks if the node is to be inserted _before_ the current node
* against which it is checked.
* This and other sys_dlist_*() functions are not thread safe.
*
* @param list the doubly-linked list to operate on
* @param node the element to insert
* @param cond a function that determines if the current node is the correct
* insert point
* @param data parameter to cond()
*
* @return N/A
*/
static inline void sys_dlist_insert_at(sys_dlist_t *list, sys_dnode_t *node,
int (*cond)(sys_dnode_t *, void *), void *data)
{
if (sys_dlist_is_empty(list)) {
sys_dlist_append(list, node);
} else {
sys_dnode_t *pos = sys_dlist_peek_head(list);
while (pos && !cond(pos, data)) {
pos = sys_dlist_peek_next(list, pos);
}
sys_dlist_insert_before(list, pos, node);
}
}
/**
* @brief remove a specific node from a list
*
* The list is implicit from the node. The node must be part of a list.
* This and other sys_dlist_*() functions are not thread safe.
*
* @param node the node to remove
*
* @return N/A
*/
static inline void sys_dlist_remove(sys_dnode_t *node)
{
node->prev->next = node->next;
node->next->prev = node->prev;
}
/**
* @brief get the first node in a list
*
* This and other sys_dlist_*() functions are not thread safe.
*
* @param list the doubly-linked list to operate on
*
* @return the first node in the list, NULL if list is empty
*/
static inline sys_dnode_t *sys_dlist_get(sys_dlist_t *list)
{
sys_dnode_t *node;
if (sys_dlist_is_empty(list)) {
return NULL;
}
node = list->head;
sys_dlist_remove(node);
return node;
}
#ifdef __cplusplus
}
#endif
#endif /* _misc_dlist__h_ */

View File

@@ -8,12 +8,12 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __BT_MESH_HEALTH_CLI_H
#define __BT_MESH_HEALTH_CLI_H
#ifndef _BLE_MESH_HEALTH_CLI_H_
#define _BLE_MESH_HEALTH_CLI_H_
#include "mesh_access.h"
#include "mesh_kernel.h"
#include "bt_mesh_client_common.h"
#include "model_common.h"
/**
* @brief Bluetooth Mesh
@@ -30,9 +30,9 @@ typedef bt_mesh_internal_data_t health_client_internal_data_t;
extern const struct bt_mesh_model_op bt_mesh_health_cli_op[];
#define BT_MESH_MODEL_HEALTH_CLI(cli_data) \
BT_MESH_MODEL(BT_MESH_MODEL_ID_HEALTH_CLI, \
bt_mesh_health_cli_op, NULL, cli_data)
#define BLE_MESH_MODEL_HEALTH_CLI(cli_data) \
BLE_MESH_MODEL(BLE_MESH_MODEL_ID_HEALTH_CLI, \
bt_mesh_health_cli_op, NULL, cli_data)
int bt_mesh_health_cli_set(struct bt_mesh_model *model);
@@ -75,4 +75,4 @@ struct bt_mesh_health_fault_status {
* @}
*/
#endif /* __BT_MESH_HEALTH_CLI_H */
#endif /* __BLE_MESH_HEALTH_CLI_H */

View File

@@ -7,8 +7,8 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __BT_MESH_HEALTH_SRV_H
#define __BT_MESH_HEALTH_SRV_H
#ifndef _BLE_MESH_HEALTH_SRV_H_
#define _BLE_MESH_HEALTH_SRV_H_
#include "mesh_access.h"
#include "mesh_kernel.h"
@@ -45,7 +45,7 @@ struct bt_mesh_health_srv_cb {
void (*attn_off)(struct bt_mesh_model *model);
};
/** @def BT_MESH_HEALTH_FAULT_MSG
/** @def BLE_MESH_HEALTH_FAULT_MSG
*
* A helper to define a health fault message.
*
@@ -53,8 +53,8 @@ struct bt_mesh_health_srv_cb {
*
* @return a New net_buf_simple of the needed size.
*/
#define BT_MESH_HEALTH_FAULT_MSG(max_faults) \
NET_BUF_SIMPLE(1 + 3 + (max_faults))
#define BLE_MESH_HEALTH_FAULT_MSG(max_faults) \
NET_BUF_SIMPLE(1 + 3 + (max_faults))
/** Mesh Health Server Model Context */
struct bt_mesh_health_srv {
@@ -67,11 +67,9 @@ struct bt_mesh_health_srv {
struct k_delayed_work attn_timer;
};
int bt_mesh_fault_update(struct bt_mesh_elem *elem);
extern const struct bt_mesh_model_op bt_mesh_health_srv_op[];
/** @def BT_MESH_MODEL_HEALTH_SRV
/** @def BLE_MESH_MODEL_HEALTH_SRV
*
* Define a new health server model. Note that this API needs to be
* repeated for each element which the application wants to have a
@@ -83,12 +81,14 @@ extern const struct bt_mesh_model_op bt_mesh_health_srv_op[];
*
* @return New mesh model instance.
*/
#define BT_MESH_MODEL_HEALTH_SRV(srv, pub) \
BT_MESH_MODEL(BT_MESH_MODEL_ID_HEALTH_SRV, \
bt_mesh_health_srv_op, pub, srv)
#define BLE_MESH_MODEL_HEALTH_SRV(srv, pub) \
BLE_MESH_MODEL(BLE_MESH_MODEL_ID_HEALTH_SRV, \
bt_mesh_health_srv_op, pub, srv)
int bt_mesh_fault_update(struct bt_mesh_elem *elem);
/**
* @}
*/
#endif /* __BT_MESH_HEALTH_SRV_H */
#endif /* __BLE_MESH_HEALTH_SRV_H */

View File

@@ -8,15 +8,14 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _BLE_MESH_ACCESS_H_
#define _BLE_MESH_ACCESS_H_
#include <stddef.h>
#include "mesh_types.h"
#include "mesh_util.h"
#include "mesh_buf.h"
#include "sdkconfig.h"
#if CONFIG_BT_MESH
#ifndef __BT_MESH_ACCESS_H
#define __BT_MESH_ACCESS_H
/**
* @brief Bluetooth Mesh Access Layer
@@ -25,26 +24,26 @@
* @{
*/
#define BT_MESH_ADDR_UNASSIGNED 0x0000
#define BT_MESH_ADDR_ALL_NODES 0xffff
#define BT_MESH_ADDR_PROXIES 0xfffc
#define BT_MESH_ADDR_FRIENDS 0xfffd
#define BT_MESH_ADDR_RELAYS 0xfffe
#define BLE_MESH_ADDR_UNASSIGNED 0x0000
#define BLE_MESH_ADDR_ALL_NODES 0xffff
#define BLE_MESH_ADDR_PROXIES 0xfffc
#define BLE_MESH_ADDR_FRIENDS 0xfffd
#define BLE_MESH_ADDR_RELAYS 0xfffe
#define BT_MESH_KEY_UNUSED 0xffff
#define BT_MESH_KEY_DEV 0xfffe
#define BLE_MESH_KEY_UNUSED 0xffff
#define BLE_MESH_KEY_DEV 0xfffe
/** Helper to define a mesh element within an array.
*
* In case the element has no SIG or Vendor models the helper
* macro BT_MESH_MODEL_NONE can be given instead.
* macro BLE_MESH_MODEL_NONE can be given instead.
*
* @param _loc Location Descriptor.
* @param _mods Array of models.
* @param _vnd_mods Array of vendor models.
*/
#define BT_MESH_ELEM(_loc, _mods, _vnd_mods) \
{ \
#define BLE_MESH_ELEM(_loc, _mods, _vnd_mods) \
{ \
.loc = (_loc), \
.model_count = ARRAY_SIZE(_mods), \
.models = (_mods), \
@@ -68,64 +67,64 @@ struct bt_mesh_elem {
};
/* Foundation Models */
#define BT_MESH_MODEL_ID_CFG_SRV 0x0000
#define BT_MESH_MODEL_ID_CFG_CLI 0x0001
#define BT_MESH_MODEL_ID_HEALTH_SRV 0x0002
#define BT_MESH_MODEL_ID_HEALTH_CLI 0x0003
#define BLE_MESH_MODEL_ID_CFG_SRV 0x0000
#define BLE_MESH_MODEL_ID_CFG_CLI 0x0001
#define BLE_MESH_MODEL_ID_HEALTH_SRV 0x0002
#define BLE_MESH_MODEL_ID_HEALTH_CLI 0x0003
/* Models from the Mesh Model Specification */
#define BT_MESH_MODEL_ID_GEN_ONOFF_SRV 0x1000
#define BT_MESH_MODEL_ID_GEN_ONOFF_CLI 0x1001
#define BT_MESH_MODEL_ID_GEN_LEVEL_SRV 0x1002
#define BT_MESH_MODEL_ID_GEN_LEVEL_CLI 0x1003
#define BT_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_SRV 0x1004
#define BT_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_CLI 0x1005
#define BT_MESH_MODEL_ID_GEN_POWER_ONOFF_SRV 0x1006
#define BT_MESH_MODEL_ID_GEN_POWER_ONOFF_SETUP_SRV 0x1007
#define BT_MESH_MODEL_ID_GEN_POWER_ONOFF_CLI 0x1008
#define BT_MESH_MODEL_ID_GEN_POWER_LEVEL_SRV 0x1009
#define BT_MESH_MODEL_ID_GEN_POWER_LEVEL_SETUP_SRV 0x100a
#define BT_MESH_MODEL_ID_GEN_POWER_LEVEL_CLI 0x100b
#define BT_MESH_MODEL_ID_GEN_BATTERY_SRV 0x100c
#define BT_MESH_MODEL_ID_GEN_BATTERY_CLI 0x100d
#define BT_MESH_MODEL_ID_GEN_LOCATION_SRV 0x100e
#define BT_MESH_MODEL_ID_GEN_LOCATION_SETUPSRV 0x100f
#define BT_MESH_MODEL_ID_GEN_LOCATION_CLI 0x1010
#define BT_MESH_MODEL_ID_GEN_ADMIN_PROP_SRV 0x1011
#define BT_MESH_MODEL_ID_GEN_MANUFACTURER_PROP_SRV 0x1012
#define BT_MESH_MODEL_ID_GEN_USER_PROP_SRV 0x1013
#define BT_MESH_MODEL_ID_GEN_CLIENT_PROP_SRV 0x1014
#define BT_MESH_MODEL_ID_GEN_PROP_CLI 0x1015
#define BT_MESH_MODEL_ID_SENSOR_SRV 0x1100
#define BT_MESH_MODEL_ID_SENSOR_SETUP_SRV 0x1101
#define BT_MESH_MODEL_ID_SENSOR_CLI 0x1102
#define BT_MESH_MODEL_ID_TIME_SRV 0x1200
#define BT_MESH_MODEL_ID_TIME_SETUP_SRV 0x1201
#define BT_MESH_MODEL_ID_TIME_CLI 0x1202
#define BT_MESH_MODEL_ID_SCENE_SRV 0x1203
#define BT_MESH_MODEL_ID_SCENE_SETUP_SRV 0x1204
#define BT_MESH_MODEL_ID_SCENE_CLI 0x1205
#define BT_MESH_MODEL_ID_SCHEDULER_SRV 0x1206
#define BT_MESH_MODEL_ID_SCHEDULER_SETUP_SRV 0x1207
#define BT_MESH_MODEL_ID_SCHEDULER_CLI 0x1208
#define BT_MESH_MODEL_ID_LIGHT_LIGHTNESS_SRV 0x1300
#define BT_MESH_MODEL_ID_LIGHT_LIGHTNESS_SETUP_SRV 0x1301
#define BT_MESH_MODEL_ID_LIGHT_LIGHTNESS_CLI 0x1302
#define BT_MESH_MODEL_ID_LIGHT_CTL_SRV 0x1303
#define BT_MESH_MODEL_ID_LIGHT_CTL_SETUP_SRV 0x1304
#define BT_MESH_MODEL_ID_LIGHT_CTL_CLI 0x1305
#define BT_MESH_MODEL_ID_LIGHT_CTL_TEMP_SRV 0x1306
#define BT_MESH_MODEL_ID_LIGHT_HSL_SRV 0x1307
#define BT_MESH_MODEL_ID_LIGHT_HSL_SETUP_SRV 0x1308
#define BT_MESH_MODEL_ID_LIGHT_HSL_CLI 0x1309
#define BT_MESH_MODEL_ID_LIGHT_HSL_HUE_SRV 0x130a
#define BT_MESH_MODEL_ID_LIGHT_HSL_SAT_SRV 0x130b
#define BT_MESH_MODEL_ID_LIGHT_XYL_SRV 0x130c
#define BT_MESH_MODEL_ID_LIGHT_XYL_SETUP_SRV 0x130d
#define BT_MESH_MODEL_ID_LIGHT_XYL_CLI 0x130e
#define BT_MESH_MODEL_ID_LIGHT_LC_SRV 0x130f
#define BT_MESH_MODEL_ID_LIGHT_LC_SETUPSRV 0x1310
#define BT_MESH_MODEL_ID_LIGHT_LC_CLI 0x1311
#define BLE_MESH_MODEL_ID_GEN_ONOFF_SRV 0x1000
#define BLE_MESH_MODEL_ID_GEN_ONOFF_CLI 0x1001
#define BLE_MESH_MODEL_ID_GEN_LEVEL_SRV 0x1002
#define BLE_MESH_MODEL_ID_GEN_LEVEL_CLI 0x1003
#define BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_SRV 0x1004
#define BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_CLI 0x1005
#define BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SRV 0x1006
#define BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SETUP_SRV 0x1007
#define BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_CLI 0x1008
#define BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SRV 0x1009
#define BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SETUP_SRV 0x100a
#define BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_CLI 0x100b
#define BLE_MESH_MODEL_ID_GEN_BATTERY_SRV 0x100c
#define BLE_MESH_MODEL_ID_GEN_BATTERY_CLI 0x100d
#define BLE_MESH_MODEL_ID_GEN_LOCATION_SRV 0x100e
#define BLE_MESH_MODEL_ID_GEN_LOCATION_SETUPSRV 0x100f
#define BLE_MESH_MODEL_ID_GEN_LOCATION_CLI 0x1010
#define BLE_MESH_MODEL_ID_GEN_ADMIN_PROP_SRV 0x1011
#define BLE_MESH_MODEL_ID_GEN_MANUFACTURER_PROP_SRV 0x1012
#define BLE_MESH_MODEL_ID_GEN_USER_PROP_SRV 0x1013
#define BLE_MESH_MODEL_ID_GEN_CLIENT_PROP_SRV 0x1014
#define BLE_MESH_MODEL_ID_GEN_PROP_CLI 0x1015
#define BLE_MESH_MODEL_ID_SENSOR_SRV 0x1100
#define BLE_MESH_MODEL_ID_SENSOR_SETUP_SRV 0x1101
#define BLE_MESH_MODEL_ID_SENSOR_CLI 0x1102
#define BLE_MESH_MODEL_ID_TIME_SRV 0x1200
#define BLE_MESH_MODEL_ID_TIME_SETUP_SRV 0x1201
#define BLE_MESH_MODEL_ID_TIME_CLI 0x1202
#define BLE_MESH_MODEL_ID_SCENE_SRV 0x1203
#define BLE_MESH_MODEL_ID_SCENE_SETUP_SRV 0x1204
#define BLE_MESH_MODEL_ID_SCENE_CLI 0x1205
#define BLE_MESH_MODEL_ID_SCHEDULER_SRV 0x1206
#define BLE_MESH_MODEL_ID_SCHEDULER_SETUP_SRV 0x1207
#define BLE_MESH_MODEL_ID_SCHEDULER_CLI 0x1208
#define BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SRV 0x1300
#define BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SETUP_SRV 0x1301
#define BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_CLI 0x1302
#define BLE_MESH_MODEL_ID_LIGHT_CTL_SRV 0x1303
#define BLE_MESH_MODEL_ID_LIGHT_CTL_SETUP_SRV 0x1304
#define BLE_MESH_MODEL_ID_LIGHT_CTL_CLI 0x1305
#define BLE_MESH_MODEL_ID_LIGHT_CTL_TEMP_SRV 0x1306
#define BLE_MESH_MODEL_ID_LIGHT_HSL_SRV 0x1307
#define BLE_MESH_MODEL_ID_LIGHT_HSL_SETUP_SRV 0x1308
#define BLE_MESH_MODEL_ID_LIGHT_HSL_CLI 0x1309
#define BLE_MESH_MODEL_ID_LIGHT_HSL_HUE_SRV 0x130a
#define BLE_MESH_MODEL_ID_LIGHT_HSL_SAT_SRV 0x130b
#define BLE_MESH_MODEL_ID_LIGHT_XYL_SRV 0x130c
#define BLE_MESH_MODEL_ID_LIGHT_XYL_SETUP_SRV 0x130d
#define BLE_MESH_MODEL_ID_LIGHT_XYL_CLI 0x130e
#define BLE_MESH_MODEL_ID_LIGHT_LC_SRV 0x130f
#define BLE_MESH_MODEL_ID_LIGHT_LC_SETUPSRV 0x1310
#define BLE_MESH_MODEL_ID_LIGHT_LC_CLI 0x1311
/** Message sending context. */
struct bt_mesh_msg_ctx {
@@ -144,7 +143,7 @@ struct bt_mesh_msg_ctx {
/** Force sending reliably by using segment acknowledgement */
u8_t send_rel: 1;
/** TTL, or BT_MESH_TTL_DEFAULT for default TTL. */
/** TTL, or BLE_MESH_TTL_DEFAULT for default TTL. */
u8_t send_ttl;
/** Change by Espressif, opcode of a received message.
@@ -164,7 +163,7 @@ struct bt_mesh_msg_ctx {
};
struct bt_mesh_model_op {
/* OpCode encoded using the BT_MESH_MODEL_OP_* macros */
/* OpCode encoded using the BLE_MESH_MODEL_OP_* macros */
const u32_t opcode;
/* Minimum required message length */
@@ -176,43 +175,43 @@ struct bt_mesh_model_op {
struct net_buf_simple *buf);
};
#define BT_MESH_MODEL_OP_1(b0) (b0)
#define BT_MESH_MODEL_OP_2(b0, b1) (((b0) << 8) | (b1))
#define BT_MESH_MODEL_OP_3(b0, cid) ((((b0) << 16) | 0xc00000) | (cid))
#define BLE_MESH_MODEL_OP_1(b0) (b0)
#define BLE_MESH_MODEL_OP_2(b0, b1) (((b0) << 8) | (b1))
#define BLE_MESH_MODEL_OP_3(b0, cid) ((((b0) << 16) | 0xc00000) | (cid))
#define BT_MESH_MODEL_OP_END { 0, 0, NULL }
#define BT_MESH_MODEL_NO_OPS ((struct bt_mesh_model_op []) \
{ BT_MESH_MODEL_OP_END })
#define BLE_MESH_MODEL_OP_END { 0, 0, NULL }
#define BLE_MESH_MODEL_NO_OPS ((struct bt_mesh_model_op []) \
{ BLE_MESH_MODEL_OP_END })
/** Helper to define an empty model array */
#define BT_MESH_MODEL_NONE ((struct bt_mesh_model []){})
#define BLE_MESH_MODEL_NONE ((struct bt_mesh_model []){})
#define BT_MESH_MODEL(_id, _op, _pub, _user_data) \
{ \
.id = (_id), \
.op = _op, \
.keys = { [0 ... (CONFIG_BT_MESH_MODEL_KEY_COUNT - 1)] = \
BT_MESH_KEY_UNUSED }, \
.pub = _pub, \
.groups = { [0 ... (CONFIG_BT_MESH_MODEL_GROUP_COUNT - 1)] = \
BT_MESH_ADDR_UNASSIGNED }, \
.user_data = _user_data, \
#define BLE_MESH_MODEL(_id, _op, _pub, _user_data) \
{ \
.id = (_id), \
.op = _op, \
.keys = { [0 ... (CONFIG_BLE_MESH_MODEL_KEY_COUNT - 1)] = \
BLE_MESH_KEY_UNUSED }, \
.pub = _pub, \
.groups = { [0 ... (CONFIG_BLE_MESH_MODEL_GROUP_COUNT - 1)] = \
BLE_MESH_ADDR_UNASSIGNED }, \
.user_data = _user_data, \
}
#define BT_MESH_MODEL_VND(_company, _id, _op, _pub, _user_data) \
{ \
.vnd.company = (_company), \
.vnd.id = (_id), \
.op = _op, \
.pub = _pub, \
.keys = { [0 ... (CONFIG_BT_MESH_MODEL_KEY_COUNT - 1)] = \
BT_MESH_KEY_UNUSED }, \
.groups = { [0 ... (CONFIG_BT_MESH_MODEL_GROUP_COUNT - 1)] = \
BT_MESH_ADDR_UNASSIGNED }, \
.user_data = _user_data, \
#define BLE_MESH_MODEL_VND(_company, _id, _op, _pub, _user_data) \
{ \
.vnd.company = (_company), \
.vnd.id = (_id), \
.op = _op, \
.pub = _pub, \
.keys = { [0 ... (CONFIG_BLE_MESH_MODEL_KEY_COUNT - 1)] = \
BLE_MESH_KEY_UNUSED }, \
.groups = { [0 ... (CONFIG_BLE_MESH_MODEL_GROUP_COUNT - 1)] = \
BLE_MESH_ADDR_UNASSIGNED }, \
.user_data = _user_data, \
}
/** @def BT_MESH_TRANSMIT
/** @def BLE_MESH_TRANSMIT
*
* @brief Encode transmission count & interval steps.
*
@@ -223,9 +222,9 @@ struct bt_mesh_model_op {
* @return Mesh transmit value that can be used e.g. for the default
* values of the configuration model data.
*/
#define BT_MESH_TRANSMIT(count, int_ms) ((count) | (((int_ms / 10) - 1) << 3))
#define BLE_MESH_TRANSMIT(count, int_ms) ((count) | (((int_ms / 10) - 1) << 3))
/** @def BT_MESH_TRANSMIT_COUNT
/** @def BLE_MESH_TRANSMIT_COUNT
*
* @brief Decode transmit count from a transmit value.
*
@@ -233,9 +232,9 @@ struct bt_mesh_model_op {
*
* @return Transmission count (actual transmissions is N + 1).
*/
#define BT_MESH_TRANSMIT_COUNT(transmit) (((transmit) & (u8_t)BIT_MASK(3)))
#define BLE_MESH_TRANSMIT_COUNT(transmit) (((transmit) & (u8_t)BIT_MASK(3)))
/** @def BT_MESH_TRANSMIT_INT
/** @def BLE_MESH_TRANSMIT_INT
*
* @brief Decode transmit interval from a transmit value.
*
@@ -243,9 +242,9 @@ struct bt_mesh_model_op {
*
* @return Transmission interval in milliseconds.
*/
#define BT_MESH_TRANSMIT_INT(transmit) ((((transmit) >> 3) + 1) * 10)
#define BLE_MESH_TRANSMIT_INT(transmit) ((((transmit) >> 3) + 1) * 10)
/** @def BT_MESH_PUB_TRANSMIT
/** @def BLE_MESH_PUB_TRANSMIT
*
* @brief Encode Publish Retransmit count & interval steps.
*
@@ -256,10 +255,9 @@ struct bt_mesh_model_op {
* @return Mesh transmit value that can be used e.g. for the default
* values of the configuration model data.
*/
#define BT_MESH_PUB_TRANSMIT(count, int_ms) BT_MESH_TRANSMIT(count, \
(int_ms) / 5)
#define BLE_MESH_PUB_TRANSMIT(count, int_ms) BLE_MESH_TRANSMIT(count, (int_ms) / 5)
/** @def BT_MESH_PUB_TRANSMIT_COUNT
/** @def BLE_MESH_PUB_TRANSMIT_COUNT
*
* @brief Decode Pubhlish Retransmit count from a given value.
*
@@ -267,9 +265,9 @@ struct bt_mesh_model_op {
*
* @return Retransmission count (actual transmissions is N + 1).
*/
#define BT_MESH_PUB_TRANSMIT_COUNT(transmit) BT_MESH_TRANSMIT_COUNT(transmit)
#define BLE_MESH_PUB_TRANSMIT_COUNT(transmit) BLE_MESH_TRANSMIT_COUNT(transmit)
/** @def BT_MESH_PUB_TRANSMIT_INT
/** @def BLE_MESH_PUB_TRANSMIT_INT
*
* @brief Decode Publish Retransmit interval from a given value.
*
@@ -277,7 +275,7 @@ struct bt_mesh_model_op {
*
* @return Transmission interval in milliseconds.
*/
#define BT_MESH_PUB_TRANSMIT_INT(transmit) ((((transmit) >> 3) + 1) * 50)
#define BLE_MESH_PUB_TRANSMIT_INT(transmit) ((((transmit) >> 3) + 1) * 50)
/** Model publication context. */
struct bt_mesh_model_pub {
@@ -336,22 +334,6 @@ struct bt_mesh_model_pub {
struct k_delayed_work timer;
};
/** @def BT_MESH_MODEL_PUB_DEFINE
*
* Define a model publication context.
*
* @param _name Variable name given to the context.
* @param _update Optional message update callback (may be NULL).
* @param _msg_len Length of the publication message.
*/
#define BT_MESH_MODEL_PUB_DEFINE(_name, _update, _msg_len) \
NET_BUF_SIMPLE_DEFINE_STATIC(bt_mesh_pub_msg_##_name, _msg_len); \
static struct bt_mesh_model_pub _name = { \
.update = _update, \
.msg = &bt_mesh_pub_msg_##_name, \
}
/** Abstraction that describes a Mesh Model instance */
struct bt_mesh_model {
union {
@@ -369,10 +351,10 @@ struct bt_mesh_model {
struct bt_mesh_model_pub *const pub;
/* AppKey List */
u16_t keys[CONFIG_BT_MESH_MODEL_KEY_COUNT];
u16_t keys[CONFIG_BLE_MESH_MODEL_KEY_COUNT];
/* Subscription List (group or virtual addresses) */
u16_t groups[CONFIG_BT_MESH_MODEL_GROUP_COUNT];
u16_t groups[CONFIG_BLE_MESH_MODEL_GROUP_COUNT];
const struct bt_mesh_model_op *const op;
@@ -393,10 +375,10 @@ struct bt_mesh_send_cb {
void bt_mesh_model_msg_init(struct net_buf_simple *msg, u32_t opcode);
/** Special TTL value to request using configured default TTL */
#define BT_MESH_TTL_DEFAULT 0xff
#define BLE_MESH_TTL_DEFAULT 0xff
/** Maximum allowed TTL value */
#define BT_MESH_TTL_MAX 0x7f
#define BLE_MESH_TTL_MAX 0x7f
/**
* @brief Send an Access Layer message.
@@ -445,5 +427,4 @@ struct bt_mesh_comp {
* @}
*/
#endif /* __BT_MESH_ACCESS_H */
#endif /* #if CONFIG_BT_MESH */
#endif /* __BLE_MESH_ACCESS_H */

View File

@@ -46,8 +46,8 @@
* 2) call tc_aes_encrypt/decrypt to process the data.
*/
#ifndef __TC_AES_H__
#define __TC_AES_H__
#ifndef _BLE_MESH_AES_ENCRYPT_H_
#define _BLE_MESH_AES_ENCRYPT_H_
#include <stdint.h>
#include <stddef.h>
@@ -59,16 +59,16 @@ extern "C" {
#define Nb (4) /* number of columns (32-bit words) comprising the state */
#define Nk (4) /* number of 32-bit words comprising the key */
#define Nr (10) /* number of rounds */
#define TC_AES_BLOCK_SIZE (Nb*Nk)
#define TC_AES_KEY_SIZE (Nb*Nk)
#define TC_AES_BLOCK_SIZE (Nb*Nk)
#define TC_AES_KEY_SIZE (Nb*Nk)
#define TC_CRYPTO_SUCCESS 1
#define TC_CRYPTO_FAIL 0
#define TC_CRYPTO_SUCCESS 1
#define TC_CRYPTO_FAIL 0
#define TC_ZERO_BYTE 0x00
#define TC_ZERO_BYTE 0x00
/* padding for last message block */
#define TC_CMAC_PADDING 0x80
#define TC_CMAC_PADDING 0x80
typedef struct tc_aes_key_sched_struct {
unsigned int words[Nb * (Nr + 1)];
@@ -94,7 +94,6 @@ typedef struct tc_cmac_struct {
uint64_t countdown;
} *TCCmacState_t;
/**
* @brief Set AES-128 encryption key
* Uses key k to initialize s
@@ -169,4 +168,4 @@ int tc_cmac_erase(TCCmacState_t s);
}
#endif
#endif /* __TC_AES_H__ */
#endif /* _BLE_MESH_AES_ENCRYPT_H_ */

View File

@@ -6,15 +6,16 @@
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __ATOMIC_H__
#define __ATOMIC_H__
#ifndef _BLE_MESH_ATOMIC_H_
#define _BLE_MESH_ATOMIC_H_
#include "mesh_types.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef int atomic_t;
typedef atomic_t atomic_val_t;
typedef bt_mesh_atomic_t bt_mesh_atomic_val_t;
/**
* @defgroup atomic_apis Atomic Services APIs
@@ -22,72 +23,6 @@ typedef atomic_t atomic_val_t;
* @{
*/
/**
* @brief Atomic compare-and-set.
*
* This routine performs an atomic compare-and-set on @a target. If the current
* value of @a target equals @a old_value, @a target is set to @a new_value.
* If the current value of @a target does not equal @a old_value, @a target
* is left unchanged.
*
* @param target Address of atomic variable.
* @param old_value Original value to compare against.
* @param new_value New value to store.
* @return 1 if @a new_value is written, 0 otherwise.
*/
#ifdef CONFIG_ATOMIC_OPERATIONS_BUILTIN
static inline int atomic_cas(atomic_t *target, atomic_val_t old_value,
atomic_val_t new_value)
{
return __atomic_compare_exchange_n(target, &old_value, new_value,
0, __ATOMIC_SEQ_CST,
__ATOMIC_SEQ_CST);
}
#else
extern int atomic_cas(atomic_t *target, atomic_val_t old_value,
atomic_val_t new_value);
#endif
/**
*
* @brief Atomic addition.
*
* This routine performs an atomic addition on @a target.
*
* @param target Address of atomic variable.
* @param value Value to add.
*
* @return Previous value of @a target.
*/
#ifdef CONFIG_ATOMIC_OPERATIONS_BUILTIN
static inline atomic_val_t atomic_add(atomic_t *target, atomic_val_t value)
{
return __atomic_fetch_add(target, value, __ATOMIC_SEQ_CST);
}
#else
extern atomic_val_t atomic_add(atomic_t *target, atomic_val_t value);
#endif
/**
*
* @brief Atomic subtraction.
*
* This routine performs an atomic subtraction on @a target.
*
* @param target Address of atomic variable.
* @param value Value to subtract.
*
* @return Previous value of @a target.
*/
#ifdef CONFIG_ATOMIC_OPERATIONS_BUILTIN
static inline atomic_val_t atomic_sub(atomic_t *target, atomic_val_t value)
{
return __atomic_fetch_sub(target, value, __ATOMIC_SEQ_CST);
}
#else
extern atomic_val_t atomic_sub(atomic_t *target, atomic_val_t value);
#endif
/**
*
* @brief Atomic increment.
@@ -99,12 +34,12 @@ extern atomic_val_t atomic_sub(atomic_t *target, atomic_val_t value);
* @return Previous value of @a target.
*/
#ifdef CONFIG_ATOMIC_OPERATIONS_BUILTIN
static inline atomic_val_t atomic_inc(atomic_t *target)
static inline bt_mesh_atomic_val_t bt_mesh_atomic_inc(bt_mesh_atomic_t *target)
{
return atomic_add(target, 1);
return bt_mesh_atomic_add(target, 1);
}
#else
extern atomic_val_t atomic_inc(atomic_t *target);
extern bt_mesh_atomic_val_t bt_mesh_atomic_inc(bt_mesh_atomic_t *target);
#endif
/**
@@ -118,12 +53,12 @@ extern atomic_val_t atomic_inc(atomic_t *target);
* @return Previous value of @a target.
*/
#ifdef CONFIG_ATOMIC_OPERATIONS_BUILTIN
static inline atomic_val_t atomic_dec(atomic_t *target)
static inline bt_mesh_atomic_val_t bt_mesh_atomic_dec(bt_mesh_atomic_t *target)
{
return atomic_sub(target, 1);
return bt_mesh_atomic_sub(target, 1);
}
#else
extern atomic_val_t atomic_dec(atomic_t *target);
extern bt_mesh_atomic_val_t bt_mesh_atomic_dec(bt_mesh_atomic_t *target);
#endif
/**
@@ -137,12 +72,12 @@ extern atomic_val_t atomic_dec(atomic_t *target);
* @return Value of @a target.
*/
#ifdef CONFIG_ATOMIC_OPERATIONS_BUILTIN
static inline atomic_val_t atomic_get(const atomic_t *target)
static inline bt_mesh_atomic_val_t bt_mesh_atomic_get(const bt_mesh_atomic_t *target)
{
return __atomic_load_n(target, __ATOMIC_SEQ_CST);
}
#else
extern atomic_val_t atomic_get(const atomic_t *target);
extern bt_mesh_atomic_val_t bt_mesh_atomic_get(const bt_mesh_atomic_t *target);
#endif
/**
@@ -158,7 +93,7 @@ extern atomic_val_t atomic_get(const atomic_t *target);
* @return Previous value of @a target.
*/
#ifdef CONFIG_ATOMIC_OPERATIONS_BUILTIN
static inline atomic_val_t atomic_set(atomic_t *target, atomic_val_t value)
static inline bt_mesh_atomic_val_t bt_mesh_atomic_set(bt_mesh_atomic_t *target, bt_mesh_atomic_val_t value)
{
/* This builtin, as described by Intel, is not a traditional
* test-and-set operation, but rather an atomic exchange operation. It
@@ -167,27 +102,7 @@ static inline atomic_val_t atomic_set(atomic_t *target, atomic_val_t value)
return __atomic_exchange_n(target, value, __ATOMIC_SEQ_CST);
}
#else
extern atomic_val_t atomic_set(atomic_t *target, atomic_val_t value);
#endif
/**
*
* @brief Atomic clear.
*
* This routine atomically sets @a target to zero and returns its previous
* value. (Hence, it is equivalent to atomic_set(target, 0).)
*
* @param target Address of atomic variable.
*
* @return Previous value of @a target.
*/
#ifdef CONFIG_ATOMIC_OPERATIONS_BUILTIN
static inline atomic_val_t atomic_clear(atomic_t *target)
{
return atomic_set(target, 0);
}
#else
extern atomic_val_t atomic_clear(atomic_t *target);
extern bt_mesh_atomic_val_t bt_mesh_atomic_set(bt_mesh_atomic_t *target, bt_mesh_atomic_val_t value);
#endif
/**
@@ -203,33 +118,12 @@ extern atomic_val_t atomic_clear(atomic_t *target);
* @return Previous value of @a target.
*/
#ifdef CONFIG_ATOMIC_OPERATIONS_BUILTIN
static inline atomic_val_t atomic_or(atomic_t *target, atomic_val_t value)
static inline bt_mesh_atomic_val_t bt_mesh_atomic_or(bt_mesh_atomic_t *target, bt_mesh_atomic_val_t value)
{
return __atomic_fetch_or(target, value, __ATOMIC_SEQ_CST);
}
#else
extern atomic_val_t atomic_or(atomic_t *target, atomic_val_t value);
#endif
/**
*
* @brief Atomic bitwise exclusive OR (XOR).
*
* This routine atomically sets @a target to the bitwise exclusive OR (XOR) of
* @a target and @a value.
*
* @param target Address of atomic variable.
* @param value Value to XOR
*
* @return Previous value of @a target.
*/
#ifdef CONFIG_ATOMIC_OPERATIONS_BUILTIN
static inline atomic_val_t atomic_xor(atomic_t *target, atomic_val_t value)
{
return __atomic_fetch_xor(target, value, __ATOMIC_SEQ_CST);
}
#else
extern atomic_val_t atomic_xor(atomic_t *target, atomic_val_t value);
extern bt_mesh_atomic_val_t bt_mesh_atomic_or(bt_mesh_atomic_t *target, bt_mesh_atomic_val_t value);
#endif
/**
@@ -245,53 +139,21 @@ extern atomic_val_t atomic_xor(atomic_t *target, atomic_val_t value);
* @return Previous value of @a target.
*/
#ifdef CONFIG_ATOMIC_OPERATIONS_BUILTIN
static inline atomic_val_t atomic_and(atomic_t *target, atomic_val_t value)
static inline bt_mesh_atomic_val_t bt_mesh_atomic_and(bt_mesh_atomic_t *target, bt_mesh_atomic_val_t value)
{
return __atomic_fetch_and(target, value, __ATOMIC_SEQ_CST);
}
#else
extern atomic_val_t atomic_and(atomic_t *target, atomic_val_t value);
extern bt_mesh_atomic_val_t bt_mesh_atomic_and(bt_mesh_atomic_t *target, bt_mesh_atomic_val_t value);
#endif
/**
*
* @brief Atomic bitwise NAND.
*
* This routine atomically sets @a target to the bitwise NAND of @a target
* and @a value. (This operation is equivalent to target = ~(target & value).)
*
* @param target Address of atomic variable.
* @param value Value to NAND.
*
* @return Previous value of @a target.
*/
#ifdef CONFIG_ATOMIC_OPERATIONS_BUILTIN
static inline atomic_val_t atomic_nand(atomic_t *target, atomic_val_t value)
{
return __atomic_fetch_nand(target, value, __ATOMIC_SEQ_CST);
}
#else
extern atomic_val_t atomic_nand(atomic_t *target, atomic_val_t value);
#endif
/**
* @brief Initialize an atomic variable.
*
* This macro can be used to initialize an atomic variable. For example,
* @code atomic_t my_var = ATOMIC_INIT(75); @endcode
*
* @param i Value to assign to atomic variable.
*/
#define ATOMIC_INIT(i) (i)
/**
* @cond INTERNAL_HIDDEN
*/
#define ATOMIC_BITS (sizeof(atomic_val_t) * 8)
#define ATOMIC_MASK(bit) (1 << ((bit) & (ATOMIC_BITS - 1)))
#define ATOMIC_ELEM(addr, bit) ((addr) + ((bit) / ATOMIC_BITS))
#define BLE_MESH_ATOMIC_BITS (sizeof(bt_mesh_atomic_val_t) * 8)
#define BLE_MESH_ATOMIC_MASK(bit) (1 << ((bit) & (BLE_MESH_ATOMIC_BITS - 1)))
#define BLE_MESH_ATOMIC_ELEM(addr, bit) ((addr) + ((bit) / BLE_MESH_ATOMIC_BITS))
/**
* INTERNAL_HIDDEN @endcond
@@ -310,8 +172,8 @@ extern atomic_val_t atomic_nand(atomic_t *target, atomic_val_t value);
* @param name Name of array of atomic variables.
* @param num_bits Number of bits needed.
*/
#define ATOMIC_DEFINE(name, num_bits) \
atomic_t name[1 + ((num_bits) - 1) / ATOMIC_BITS]
#define BLE_MESH_ATOMIC_DEFINE(name, num_bits) \
bt_mesh_atomic_t name[1 + ((num_bits) - 1) / BLE_MESH_ATOMIC_BITS]
/**
* @brief Atomically test a bit.
@@ -324,11 +186,11 @@ extern atomic_val_t atomic_nand(atomic_t *target, atomic_val_t value);
*
* @return 1 if the bit was set, 0 if it wasn't.
*/
static inline int atomic_test_bit(const atomic_t *target, int bit)
static inline int bt_mesh_atomic_test_bit(const bt_mesh_atomic_t *target, int bit)
{
atomic_val_t val = atomic_get(ATOMIC_ELEM(target, bit));
bt_mesh_atomic_val_t val = bt_mesh_atomic_get(BLE_MESH_ATOMIC_ELEM(target, bit));
return (1 & (val >> (bit & (ATOMIC_BITS - 1))));
return (1 & (val >> (bit & (BLE_MESH_ATOMIC_BITS - 1))));
}
/**
@@ -342,12 +204,12 @@ static inline int atomic_test_bit(const atomic_t *target, int bit)
*
* @return 1 if the bit was set, 0 if it wasn't.
*/
static inline int atomic_test_and_clear_bit(atomic_t *target, int bit)
static inline int bt_mesh_atomic_test_and_clear_bit(bt_mesh_atomic_t *target, int bit)
{
atomic_val_t mask = ATOMIC_MASK(bit);
atomic_val_t old;
bt_mesh_atomic_val_t mask = BLE_MESH_ATOMIC_MASK(bit);
bt_mesh_atomic_val_t old;
old = atomic_and(ATOMIC_ELEM(target, bit), ~mask);
old = bt_mesh_atomic_and(BLE_MESH_ATOMIC_ELEM(target, bit), ~mask);
return (old & mask) != 0;
}
@@ -363,12 +225,12 @@ static inline int atomic_test_and_clear_bit(atomic_t *target, int bit)
*
* @return 1 if the bit was set, 0 if it wasn't.
*/
static inline int atomic_test_and_set_bit(atomic_t *target, int bit)
static inline int bt_mesh_atomic_test_and_set_bit(bt_mesh_atomic_t *target, int bit)
{
atomic_val_t mask = ATOMIC_MASK(bit);
atomic_val_t old;
bt_mesh_atomic_val_t mask = BLE_MESH_ATOMIC_MASK(bit);
bt_mesh_atomic_val_t old;
old = atomic_or(ATOMIC_ELEM(target, bit), mask);
old = bt_mesh_atomic_or(BLE_MESH_ATOMIC_ELEM(target, bit), mask);
return (old & mask) != 0;
}
@@ -384,11 +246,11 @@ static inline int atomic_test_and_set_bit(atomic_t *target, int bit)
*
* @return N/A
*/
static inline void atomic_clear_bit(atomic_t *target, int bit)
static inline void bt_mesh_atomic_clear_bit(bt_mesh_atomic_t *target, int bit)
{
atomic_val_t mask = ATOMIC_MASK(bit);
bt_mesh_atomic_val_t mask = BLE_MESH_ATOMIC_MASK(bit);
atomic_and(ATOMIC_ELEM(target, bit), ~mask);
bt_mesh_atomic_and(BLE_MESH_ATOMIC_ELEM(target, bit), ~mask);
}
/**
@@ -402,11 +264,11 @@ static inline void atomic_clear_bit(atomic_t *target, int bit)
*
* @return N/A
*/
static inline void atomic_set_bit(atomic_t *target, int bit)
static inline void bt_mesh_atomic_set_bit(bt_mesh_atomic_t *target, int bit)
{
atomic_val_t mask = ATOMIC_MASK(bit);
bt_mesh_atomic_val_t mask = BLE_MESH_ATOMIC_MASK(bit);
atomic_or(ATOMIC_ELEM(target, bit), mask);
bt_mesh_atomic_or(BLE_MESH_ATOMIC_ELEM(target, bit), mask);
}
/**
@@ -417,4 +279,4 @@ static inline void atomic_set_bit(atomic_t *target, int bit)
}
#endif
#endif /* __ATOMIC_H__ */
#endif /* _BLE_MESH_ATOMIC_H_ */

File diff suppressed because it is too large Load Diff

View File

@@ -1,580 +0,0 @@
/** @file
* @brief Bluetooth UUID handling
*/
/*
* Copyright (c) 2015-2016 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __BT_UUID_H
#define __BT_UUID_H
/**
* @brief UUIDs
* @defgroup bt_uuid UUIDs
* @ingroup bluetooth
* @{
*/
#include "mesh_util.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @brief Bluetooth UUID types */
enum {
BT_UUID_TYPE_16,
BT_UUID_TYPE_32,
BT_UUID_TYPE_128,
};
/** @brief This is a 'tentative' type and should be used as a pointer only */
struct bt_uuid {
u8_t type;
};
struct bt_uuid_16 {
struct bt_uuid uuid;
u16_t val;
};
struct bt_uuid_32 {
struct bt_uuid uuid;
u32_t val;
};
struct bt_uuid_128 {
struct bt_uuid uuid;
u8_t val[16];
};
#define BT_UUID_INIT_16(value) \
{ \
.uuid.type = BT_UUID_TYPE_16, \
.val = (value), \
}
#define BT_UUID_INIT_32(value) \
{ \
.uuid.type = BT_UUID_TYPE_32, \
.val = (value), \
}
#define BT_UUID_INIT_128(value...) \
{ \
.uuid.type = BT_UUID_TYPE_128, \
.val = { value }, \
}
#define BT_UUID_DECLARE_16(value) \
((struct bt_uuid *) (&(struct bt_uuid_16) BT_UUID_INIT_16(value)))
#define BT_UUID_DECLARE_32(value) \
((struct bt_uuid *) (&(struct bt_uuid_32) BT_UUID_INIT_32(value)))
#define BT_UUID_DECLARE_128(value...) \
((struct bt_uuid *) (&(struct bt_uuid_128) BT_UUID_INIT_128(value)))
#define BT_UUID_16(__u) CONTAINER_OF(__u, struct bt_uuid_16, uuid)
#define BT_UUID_32(__u) CONTAINER_OF(__u, struct bt_uuid_32, uuid)
#define BT_UUID_128(__u) CONTAINER_OF(__u, struct bt_uuid_128, uuid)
/** @def BT_UUID_GAP
* @brief Generic Access
*/
#define BT_UUID_GAP BT_UUID_DECLARE_16(0x1800)
#define BT_UUID_GAP_VAL 0x1800
/** @def BT_UUID_GATT
* @brief Generic Attribute
*/
#define BT_UUID_GATT BT_UUID_DECLARE_16(0x1801)
#define BT_UUID_GATT_VAL 0x1801
/** @def BT_UUID_CTS
* @brief Current Time Service
*/
#define BT_UUID_CTS BT_UUID_DECLARE_16(0x1805)
#define BT_UUID_CTS_VAL 0x1805
/** @def BT_UUID_DIS
* @brief Device Information Service
*/
#define BT_UUID_DIS BT_UUID_DECLARE_16(0x180a)
#define BT_UUID_DIS_VAL 0x180a
/** @def BT_UUID_HRS
* @brief Heart Rate Service
*/
#define BT_UUID_HRS BT_UUID_DECLARE_16(0x180d)
#define BT_UUID_HRS_VAL 0x180d
/** @def BT_UUID_BAS
* @brief Battery Service
*/
#define BT_UUID_BAS BT_UUID_DECLARE_16(0x180f)
#define BT_UUID_BAS_VAL 0x180f
/** @def BT_UUID_HIDS
* @brief HID Service
*/
#define BT_UUID_HIDS BT_UUID_DECLARE_16(0x1812)
#define BT_UUID_HIDS_VAL 0x1812
/** @def BT_UUID_CSC
* @brief Cycling Speed and Cadence Service
*/
#define BT_UUID_CSC BT_UUID_DECLARE_16(0x1816)
#define BT_UUID_CSC_VAL 0x1816
/** @def BT_UUID_ESS
* @brief Environmental Sensing Service
*/
#define BT_UUID_ESS BT_UUID_DECLARE_16(0x181a)
#define BT_UUID_ESS_VAL 0x181a
/** @def BT_UUID_IPSS
* @brief IP Support Service
*/
#define BT_UUID_IPSS BT_UUID_DECLARE_16(0x1820)
#define BT_UUID_IPSS_VAL 0x1820
/** @def BT_UUID_MESH_PROV
* @brief Mesh Provisioning Service
*/
#define BT_UUID_MESH_PROV BT_UUID_DECLARE_16(0x1827)
#define BT_UUID_MESH_PROV_VAL 0x1827
/** @def BT_UUID_MESH_PROXY
* @brief Mesh Proxy Service
*/
#define BT_UUID_MESH_PROXY BT_UUID_DECLARE_16(0x1828)
#define BT_UUID_MESH_PROXY_VAL 0x1828
/** @def BT_UUID_GATT_PRIMARY
* @brief GATT Primary Service
*/
#define BT_UUID_GATT_PRIMARY BT_UUID_DECLARE_16(0x2800)
#define BT_UUID_GATT_PRIMARY_VAL 0x2800
/** @def BT_UUID_GATT_SECONDARY
* @brief GATT Secondary Service
*/
#define BT_UUID_GATT_SECONDARY BT_UUID_DECLARE_16(0x2801)
#define BT_UUID_GATT_SECONDARY_VAL 0x2801
/** @def BT_UUID_GATT_INCLUDE
* @brief GATT Include Service
*/
#define BT_UUID_GATT_INCLUDE BT_UUID_DECLARE_16(0x2802)
#define BT_UUID_GATT_INCLUDE_VAL 0x2802
/** @def BT_UUID_GATT_CHRC
* @brief GATT Characteristic
*/
#define BT_UUID_GATT_CHRC BT_UUID_DECLARE_16(0x2803)
#define BT_UUID_GATT_CHRC_VAL 0x2803
/** @def BT_UUID_GATT_CEP
* @brief GATT Characteristic Extended Properties
*/
#define BT_UUID_GATT_CEP BT_UUID_DECLARE_16(0x2900)
#define BT_UUID_GATT_CEP_VAL 0x2900
/** @def BT_UUID_GATT_CUD
* @brief GATT Characteristic User Description
*/
#define BT_UUID_GATT_CUD BT_UUID_DECLARE_16(0x2901)
#define BT_UUID_GATT_CUD_VAL 0x2901
/** @def BT_UUID_GATT_CCC
* @brief GATT Client Characteristic Configuration
*/
#define BT_UUID_GATT_CCC BT_UUID_DECLARE_16(0x2902)
#define BT_UUID_GATT_CCC_VAL 0x2902
/** @def BT_UUID_GATT_SCC
* @brief GATT Server Characteristic Configuration
*/
#define BT_UUID_GATT_SCC BT_UUID_DECLARE_16(0x2903)
#define BT_UUID_GATT_SCC_VAL 0x2903
/** @def BT_UUID_GATT_CPF
* @brief GATT Characteristic Presentation Format
*/
#define BT_UUID_GATT_CPF BT_UUID_DECLARE_16(0x2904)
#define BT_UUID_GATT_CPF_VAL 0x2904
/** @def BT_UUID_VALID_RANGE
* @brief Valid Range Descriptor
*/
#define BT_UUID_VALID_RANGE BT_UUID_DECLARE_16(0x2906)
#define BT_UUID_VALID_RANGE_VAL 0x2906
/** @def BT_UUID_HIDS_EXT_REPORT
* @brief HID External Report Descriptor
*/
#define BT_UUID_HIDS_EXT_REPORT BT_UUID_DECLARE_16(0x2907)
#define BT_UUID_HIDS_EXT_REPORT_VAL 0x2907
/** @def BT_UUID_HIDS_REPORT_REF
* @brief HID Report Reference Descriptor
*/
#define BT_UUID_HIDS_REPORT_REF BT_UUID_DECLARE_16(0x2908)
#define BT_UUID_HIDS_REPORT_REF_VAL 0x2908
/** @def BT_UUID_ES_CONFIGURATION
* @brief Environmental Sensing Configuration Descriptor
*/
#define BT_UUID_ES_CONFIGURATION BT_UUID_DECLARE_16(0x290b)
#define BT_UUID_ES_CONFIGURATION_VAL 0x290b
/** @def BT_UUID_ES_MEASUREMENT
* @brief Environmental Sensing Measurement Descriptor
*/
#define BT_UUID_ES_MEASUREMENT BT_UUID_DECLARE_16(0x290c)
#define BT_UUID_ES_MEASUREMENT_VAL 0x290c
/** @def BT_UUID_ES_TRIGGER_SETTING
* @brief Environmental Sensing Trigger Setting Descriptor
*/
#define BT_UUID_ES_TRIGGER_SETTING BT_UUID_DECLARE_16(0x290d)
#define BT_UUID_ES_TRIGGER_SETTING_VAL 0x290d
/** @def BT_UUID_GAP_DEVICE_NAME
* @brief GAP Characteristic Device Name
*/
#define BT_UUID_GAP_DEVICE_NAME BT_UUID_DECLARE_16(0x2a00)
#define BT_UUID_GAP_DEVICE_NAME_VAL 0x2a00
/** @def BT_UUID_GAP_APPEARANCE
* @brief GAP Characteristic Appearance
*/
#define BT_UUID_GAP_APPEARANCE BT_UUID_DECLARE_16(0x2a01)
#define BT_UUID_GAP_APPEARANCE_VAL 0x2a01
/** @def BT_UUID_GAP_PPCP
* @brief GAP Characteristic Peripheral Preferred Connection Parameters
*/
#define BT_UUID_GAP_PPCP BT_UUID_DECLARE_16(0x2a04)
#define BT_UUID_GAP_PPCP_VAL 0x2a04
/** @def BT_UUID_GATT_SC
* @brief GATT Characteristic Service Changed
*/
#define BT_UUID_GATT_SC BT_UUID_DECLARE_16(0x2a05)
#define BT_UUID_GATT_SC_VAL 0x2a05
/** @def BT_UUID_BAS_BATTERY_LEVEL
* @brief BAS Characteristic Battery Level
*/
#define BT_UUID_BAS_BATTERY_LEVEL BT_UUID_DECLARE_16(0x2a19)
#define BT_UUID_BAS_BATTERY_LEVEL_VAL 0x2a19
/** @def BT_UUID_DIS_SYSTEM_ID
* @brief DIS Characteristic System ID
*/
#define BT_UUID_DIS_SYSTEM_ID BT_UUID_DECLARE_16(0x2a23)
#define BT_UUID_DIS_SYSTEM_ID_VAL 0x2a23
/** @def BT_UUID_DIS_MODEL_NUMBER
* @brief DIS Characteristic Model Number String
*/
#define BT_UUID_DIS_MODEL_NUMBER BT_UUID_DECLARE_16(0x2a24)
#define BT_UUID_DIS_MODEL_NUMBER_VAL 0x2a24
/** @def BT_UUID_DIS_SERIAL_NUMBER
* @brief DIS Characteristic Serial Number String
*/
#define BT_UUID_DIS_SERIAL_NUMBER BT_UUID_DECLARE_16(0x2a25)
#define BT_UUID_DIS_SERIAL_NUMBER_VAL 0x2a25
/** @def BT_UUID_DIS_FIRMWARE_REVISION
* @brief DIS Characteristic Firmware Revision String
*/
#define BT_UUID_DIS_FIRMWARE_REVISION BT_UUID_DECLARE_16(0x2a26)
#define BT_UUID_DIS_FIRMWARE_REVISION_VAL 0x2a26
/** @def BT_UUID_DIS_HARDWARE_REVISION
* @brief DIS Characteristic Hardware Revision String
*/
#define BT_UUID_DIS_HARDWARE_REVISION BT_UUID_DECLARE_16(0x2a27)
#define BT_UUID_DIS_HARDWARE_REVISION_VAL 0x2a27
/** @def BT_UUID_DIS_SOFTWARE_REVISION
* @brief DIS Characteristic Software Revision String
*/
#define BT_UUID_DIS_SOFTWARE_REVISION BT_UUID_DECLARE_16(0x2a28)
#define BT_UUID_DIS_SOFTWARE_REVISION_VAL 0x2a28
/** @def BT_UUID_DIS_MANUFACTURER_NAME
* @brief DIS Characteristic Manufacturer Name String
*/
#define BT_UUID_DIS_MANUFACTURER_NAME BT_UUID_DECLARE_16(0x2a29)
#define BT_UUID_DIS_MANUFACTURER_NAME_VAL 0x2a29
/** @def BT_UUID_DIS_PNP_ID
* @brief DIS Characteristic PnP ID
*/
#define BT_UUID_DIS_PNP_ID BT_UUID_DECLARE_16(0x2a50)
#define BT_UUID_DIS_PNP_ID_VAL 0x2a50
/** @def BT_UUID_CTS_CURRENT_TIME
* @brief CTS Characteristic Current Time
*/
#define BT_UUID_CTS_CURRENT_TIME BT_UUID_DECLARE_16(0x2a2b)
#define BT_UUID_CTS_CURRENT_TIME_VAL 0x2a2b
/** @def BT_UUID_MAGN_DECLINATION
* @brief Magnetic Declination Characteristic
*/
#define BT_UUID_MAGN_DECLINATION BT_UUID_DECLARE_16(0x2a2c)
#define BT_UUID_MAGN_DECLINATION_VAL 0x2a2c
/** @def BT_UUID_HRS_MEASUREMENT
* @brief HRS Characteristic Measurement Interval
*/
#define BT_UUID_HRS_MEASUREMENT BT_UUID_DECLARE_16(0x2a37)
#define BT_UUID_HRS_MEASUREMENT_VAL 0x2a37
/** @def BT_UUID_HRS_BODY_SENSOR
* @brief HRS Characteristic Body Sensor Location
*/
#define BT_UUID_HRS_BODY_SENSOR BT_UUID_DECLARE_16(0x2a38)
#define BT_UUID_HRS_BODY_SENSOR_VAL 0x2a38
/** @def BT_UUID_HRS_CONTROL_POINT
* @brief HRS Characteristic Control Point
*/
#define BT_UUID_HRS_CONTROL_POINT BT_UUID_DECLARE_16(0x2a39)
#define BT_UUID_HRS_CONTROL_POINT_VAL 0x2a39
/** @def BT_UUID_HIDS_INFO
* @brief HID Information Characteristic
*/
#define BT_UUID_HIDS_INFO BT_UUID_DECLARE_16(0x2a4a)
#define BT_UUID_HIDS_INFO_VAL 0x2a4a
/** @def BT_UUID_HIDS_REPORT_MAP
* @brief HID Report Map Characteristic
*/
#define BT_UUID_HIDS_REPORT_MAP BT_UUID_DECLARE_16(0x2a4b)
#define BT_UUID_HIDS_REPORT_MAP_VAL 0x2a4b
/** @def BT_UUID_HIDS_CTRL_POINT
* @brief HID Control Point Characteristic
*/
#define BT_UUID_HIDS_CTRL_POINT BT_UUID_DECLARE_16(0x2a4c)
#define BT_UUID_HIDS_CTRL_POINT_VAL 0x2a4c
/** @def BT_UUID_HIDS_REPORT
* @brief HID Report Characteristic
*/
#define BT_UUID_HIDS_REPORT BT_UUID_DECLARE_16(0x2a4d)
#define BT_UUID_HIDS_REPORT_VAL 0x2a4d
/** @def BT_UUID_CSC_MEASUREMENT
* @brief CSC Measurement Characteristic
*/
#define BT_UUID_CSC_MEASUREMENT BT_UUID_DECLARE_16(0x2a5b)
#define BT_UUID_CSC_MEASUREMENT_VAL 0x2a5b
/** @def BT_UUID_CSC_FEATURE
* @brief CSC Feature Characteristic
*/
#define BT_UUID_CSC_FEATURE BT_UUID_DECLARE_16(0x2a5c)
#define BT_UUID_CSC_FEATURE_VAL 0x2a5c
/** @def BT_UUID_SENSOR_LOCATION
* @brief Sensor Location Characteristic
*/
#define BT_UUID_SENSOR_LOCATION BT_UUID_DECLARE_16(0x2a5d)
#define BT_UUID_SENSOR_LOCATION_VAL 0x2a5d
/** @def BT_UUID_SC_CONTROL_POINT
* @brief SC Control Point Characteristic
*/
#define BT_UUID_SC_CONTROL_POINT BT_UUID_DECLARE_16(0x2a55)
#define BT_UUID_SC_CONTROL_POINT_VAl 0x2a55
/** @def BT_UUID_ELEVATION
* @brief Elevation Characteristic
*/
#define BT_UUID_ELEVATION BT_UUID_DECLARE_16(0x2a6c)
#define BT_UUID_ELEVATION_VAL 0x2a6c
/** @def BT_UUID_PRESSURE
* @brief Pressure Characteristic
*/
#define BT_UUID_PRESSURE BT_UUID_DECLARE_16(0x2a6d)
#define BT_UUID_PRESSURE_VAL 0x2a6d
/** @def BT_UUID_TEMPERATURE
* @brief Temperature Characteristic
*/
#define BT_UUID_TEMPERATURE BT_UUID_DECLARE_16(0x2a6e)
#define BT_UUID_TEMPERATURE_VAL 0x2a6e
/** @def BT_UUID_HUMIDITY
* @brief Humidity Characteristic
*/
#define BT_UUID_HUMIDITY BT_UUID_DECLARE_16(0x2a6f)
#define BT_UUID_HUMIDITY_VAL 0x2a6f
/** @def BT_UUID_TRUE_WIND_SPEED
* @brief True Wind Speed Characteristic
*/
#define BT_UUID_TRUE_WIND_SPEED BT_UUID_DECLARE_16(0x2a70)
#define BT_UUID_TRUE_WIND_SPEED_VAL 0x2a70
/** @def BT_UUID_TRUE_WIND_DIR
* @brief True Wind Direction Characteristic
*/
#define BT_UUID_TRUE_WIND_DIR BT_UUID_DECLARE_16(0x2a71)
#define BT_UUID_TRUE_WIND_DIR_VAL 0x2a71
/** @def BT_UUID_APPARENT_WIND_SPEED
* @brief Apparent Wind Speed Characteristic
*/
#define BT_UUID_APPARENT_WIND_SPEED BT_UUID_DECLARE_16(0x2a72)
#define BT_UUID_APPARENT_WIND_SPEED_VAL 0x2a72
/** @def BT_UUID_APPARENT_WIND_DIR
* @brief Apparent Wind Direction Characteristic
*/
#define BT_UUID_APPARENT_WIND_DIR BT_UUID_DECLARE_16(0x2a73)
#define BT_UUID_APPARENT_WIND_DIR_VAL 0x2a73
/** @def BT_UUID_GUST_FACTOR
* @brief Gust Factor Characteristic
*/
#define BT_UUID_GUST_FACTOR BT_UUID_DECLARE_16(0x2a74)
#define BT_UUID_GUST_FACTOR_VAL 0x2a74
/** @def BT_UUID_POLLEN_CONCENTRATION
* @brief Pollen Concentration Characteristic
*/
#define BT_UUID_POLLEN_CONCENTRATION BT_UUID_DECLARE_16(0x2a75)
#define BT_UUID_POLLEN_CONCENTRATION_VAL 0x2a75
/** @def BT_UUID_UV_INDEX
* @brief UV Index Characteristic
*/
#define BT_UUID_UV_INDEX BT_UUID_DECLARE_16(0x2a76)
#define BT_UUID_UV_INDEX_VAL 0x2a76
/** @def BT_UUID_IRRADIANCE
* @brief Irradiance Characteristic
*/
#define BT_UUID_IRRADIANCE BT_UUID_DECLARE_16(0x2a77)
#define BT_UUID_IRRADIANCE_VAL 0x2a77
/** @def BT_UUID_RAINFALL
* @brief Rainfall Characteristic
*/
#define BT_UUID_RAINFALL BT_UUID_DECLARE_16(0x2a78)
#define BT_UUID_RAINFALL_VAL 0x2a78
/** @def BT_UUID_WIND_CHILL
* @brief Wind Chill Characteristic
*/
#define BT_UUID_WIND_CHILL BT_UUID_DECLARE_16(0x2a79)
#define BT_UUID_WIND_CHILL_VAL 0x2a79
/** @def BT_UUID_HEAT_INDEX
* @brief Heat Index Characteristic
*/
#define BT_UUID_HEAT_INDEX BT_UUID_DECLARE_16(0x2a7a)
#define BT_UUID_HEAT_INDEX_VAL 0x2a7a
/** @def BT_UUID_DEW_POINT
* @brief Dew Point Characteristic
*/
#define BT_UUID_DEW_POINT BT_UUID_DECLARE_16(0x2a7b)
#define BT_UUID_DEW_POINT_VAL 0x2a7b
/** @def BT_UUID_DESC_VALUE_CHANGED
* @brief Descriptor Value Changed Characteristic
*/
#define BT_UUID_DESC_VALUE_CHANGED BT_UUID_DECLARE_16(0x2a7d)
#define BT_UUID_DESC_VALUE_CHANGED_VAL 0x2a7d
/** @def BT_UUID_MAGN_FLUX_DENSITY_2D
* @brief Magnetic Flux Density - 2D Characteristic
*/
#define BT_UUID_MAGN_FLUX_DENSITY_2D BT_UUID_DECLARE_16(0x2aa0)
#define BT_UUID_MAGN_FLUX_DENSITY_2D_VAL 0x2aa0
/** @def BT_UUID_MAGN_FLUX_DENSITY_3D
* @brief Magnetic Flux Density - 3D Characteristic
*/
#define BT_UUID_MAGN_FLUX_DENSITY_3D BT_UUID_DECLARE_16(0x2aa1)
#define BT_UUID_MAGN_FLUX_DENSITY_3D_VAL 0x2aa1
/** @def BT_UUID_BAR_PRESSURE_TREND
* @brief Barometric Pressure Trend Characteristic
*/
#define BT_UUID_BAR_PRESSURE_TREND BT_UUID_DECLARE_16(0x2aa3)
#define BT_UUID_BAR_PRESSURE_TREND_VAL 0x2aa3
/** @def BT_UUID_MESH_PROV_DATA_IN
* @brief Mesh Provisioning Data In
*/
#define BT_UUID_MESH_PROV_DATA_IN BT_UUID_DECLARE_16(0x2adb)
#define BT_UUID_MESH_PROV_DATA_IN_VAL 0x2adb
/** @def BT_UUID_MESH_PROV_DATA_OUT
* @brief Mesh Provisioning Data Out
*/
#define BT_UUID_MESH_PROV_DATA_OUT BT_UUID_DECLARE_16(0x2adc)
#define BT_UUID_MESH_PROV_DATA_OUT_VAL 0x2adc
/** @def BT_UUID_MESH_PROXY_DATA_IN
* @brief Mesh Proxy Data In
*/
#define BT_UUID_MESH_PROXY_DATA_IN BT_UUID_DECLARE_16(0x2add)
#define BT_UUID_MESH_PROXY_DATA_IN_VAL 0x2add
/** @def BT_UUID_MESH_PROXY_DATA_OUT
* @brief Mesh Proxy Data Out
*/
#define BT_UUID_MESH_PROXY_DATA_OUT BT_UUID_DECLARE_16(0x2ade)
#define BT_UUID_MESH_PROXY_DATA_OUT_VAL 0x2ade
/*
* Protocol UUIDs
*/
#define BT_UUID_SDP BT_UUID_DECLARE_16(0x0001)
#define BT_UUID_SDP_VAL 0x0001
#define BT_UUID_UDP BT_UUID_DECLARE_16(0x0002)
#define BT_UUID_UDP_VAL 0x0002
#define BT_UUID_RFCOMM BT_UUID_DECLARE_16(0x0003)
#define BT_UUID_RFCOMM_VAL 0x0003
#define BT_UUID_TCP BT_UUID_DECLARE_16(0x0004)
#define BT_UUID_TCP_VAL 0x0004
#define BT_UUID_TCS_BIN BT_UUID_DECLARE_16(0x0005)
#define BT_UUID_TCS_BIN_VAL 0x0005
#define BT_UUID_TCS_AT BT_UUID_DECLARE_16(0x0006)
#define BT_UUID_TCS_AT_VAL 0x0006
#define BT_UUID_ATT BT_UUID_DECLARE_16(0x0007)
#define BT_UUID_ATT_VAL 0x0007
#define BT_UUID_OBEX BT_UUID_DECLARE_16(0x0008)
#define BT_UUID_OBEX_VAL 0x0008
#define BT_UUID_IP BT_UUID_DECLARE_16(0x0009)
#define BT_UUID_IP_VAL 0x0009
#define BT_UUID_FTP BT_UUID_DECLARE_16(0x000a)
#define BT_UUID_FTP_VAL 0x000a
#define BT_UUID_HTTP BT_UUID_DECLARE_16(0x000c)
#define BT_UUID_HTTP_VAL 0x000c
#define BT_UUID_BNEP BT_UUID_DECLARE_16(0x000f)
#define BT_UUID_BNEP_VAL 0x000f
#define BT_UUID_UPNP BT_UUID_DECLARE_16(0x0010)
#define BT_UUID_UPNP_VAL 0x0010
#define BT_UUID_HIDP BT_UUID_DECLARE_16(0x0011)
#define BT_UUID_HIDP_VAL 0x0011
#define BT_UUID_HCRP_CTRL BT_UUID_DECLARE_16(0x0012)
#define BT_UUID_HCRP_CTRL_VAL 0x0012
#define BT_UUID_HCRP_DATA BT_UUID_DECLARE_16(0x0014)
#define BT_UUID_HCRP_DATA_VAL 0x0014
#define BT_UUID_HCRP_NOTE BT_UUID_DECLARE_16(0x0016)
#define BT_UUID_HCRP_NOTE_VAL 0x0016
#define BT_UUID_AVCTP BT_UUID_DECLARE_16(0x0017)
#define BT_UUID_AVCTP_VAL 0x0017
#define BT_UUID_AVDTP BT_UUID_DECLARE_16(0x0019)
#define BT_UUID_AVDTP_VAL 0x0019
#define BT_UUID_CMTP BT_UUID_DECLARE_16(0x001b)
#define BT_UUID_CMTP_VAL 0x001b
#define BT_UUID_UDI BT_UUID_DECLARE_16(0x001d)
#define BT_UUID_UDI_VAL 0x001d
#define BT_UUID_MCAP_CTRL BT_UUID_DECLARE_16(0x001e)
#define BT_UUID_MCAP_CTRL_VAL 0x001e
#define BT_UUID_MCAP_DATA BT_UUID_DECLARE_16(0x001f)
#define BT_UUID_MCAP_DATA_VAL 0x001f
#define BT_UUID_L2CAP BT_UUID_DECLARE_16(0x0100)
#define BT_UUID_L2CAP_VAL 0x0100
/** @brief Compare Bluetooth UUIDs.
*
* Compares 2 Bluetooth UUIDs, if the types are different both UUIDs are
* first converted to 128 bits format before comparing.
*
* @param u1 First Bluetooth UUID to compare
* @param u2 Second Bluetooth UUID to compare
*
* @return negative value if @a u1 < @a u2, 0 if @a u1 == @a u2, else positive
*/
int bt_uuid_cmp(const struct bt_uuid *u1, const struct bt_uuid *u2);
#if defined(CONFIG_BT_DEBUG)
/** @brief Convert Bluetooth UUID to string.
*
* Converts Bluetooth UUID to string. UUID has to be in 16 bits or 128 bits
* format.
*
* @param uuid Bluetooth UUID
* @param str pointer where to put converted string
* @param len length of str
*
* @return N/A
*/
void bt_uuid_to_str(const struct bt_uuid *uuid, char *str, size_t len);
/** @brief Convert Bluetooth UUID to string in place.
*
* Converts Bluetooth UUID to string in place. UUID has to be in 16 bits or
* 128 bits format.
*
* @param uuid Bluetooth UUID
*
* @return String representation of the UUID given
*/
const char *bt_uuid_str(const struct bt_uuid *uuid);
#else
static inline void bt_uuid_to_str(const struct bt_uuid *uuid, char *str,
size_t len)
{
if (len > 0) {
str[0] = '\0';
}
}
static inline const char *bt_uuid_str(const struct bt_uuid *uuid)
{
return "";
}
#endif /* CONFIG_BT_DEBUG */
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#endif /* __BT_UUID_H */

View File

@@ -8,8 +8,8 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __NET_BUF_H
#define __NET_BUF_H
#ifndef _BLE_MESH_BUF_H_
#define _BLE_MESH_BUF_H_
#include <stddef.h>
#include "sys/cdefs.h"
@@ -22,14 +22,13 @@
extern "C" {
#endif
/* Unaligned access */
#define UNALIGNED_GET(p) \
#define UNALIGNED_GET(p) \
__extension__ ({ \
struct __attribute__((__packed__)) { \
__typeof__(*(p)) __v; \
} *__p = (__typeof__(__p)) (p); \
__p->__v; \
struct __attribute__((__packed__)) { \
__typeof__(*(p)) __v; \
} *__p = (__typeof__(__p)) (p); \
__p->__v; \
})
/**
@@ -57,12 +56,12 @@ __extension__ ({ \
*
* @return Pointer to stack-allocated net_buf_simple object.
*/
#define NET_BUF_SIMPLE(_size) \
((struct net_buf_simple *)(&(struct { \
struct net_buf_simple buf; \
u8_t data[_size] __net_buf_align; \
}) { \
.buf.size = _size, \
#define NET_BUF_SIMPLE(_size) \
((struct net_buf_simple *)(&(struct { \
struct net_buf_simple buf; \
u8_t data[_size] __net_buf_align; \
}) { \
.buf.size = _size, \
}))
/** @brief Simple network buffer representation.
@@ -94,24 +93,6 @@ struct net_buf_simple {
u8_t __buf[0] __net_buf_align;
};
/** @def NET_BUF_SIMPLE_DEFINE_STATIC
* @brief Define a static net_buf_simple variable.
*
* This is a helper macro which is used to define a static net_buf_simple
* object.
*
* @param _name Name of the net_buf_simple object.
* @param _size Maximum data storage for the buffer.
*/
#define NET_BUF_SIMPLE_DEFINE_STATIC(_name, _size) \
static __noinit u8_t net_buf_data_##_name[_size]; \
static struct net_buf_simple _name = { \
.data = net_buf_data_##_name, \
.len = 0, \
.size = _size, \
.__buf = net_buf_data_##_name, \
}
/** @brief Initialize a net_buf_simple object.
*
* This needs to be called after creating a net_buf_simple object e.g. using
@@ -484,9 +465,6 @@ struct net_buf {
};
struct net_buf_pool {
/** LIFO to place the buffer into when free */
struct k_lifo free;
/** Number of buffers in pool */
const u16_t buf_count;
@@ -499,7 +477,7 @@ struct net_buf_pool {
/** Size of the user data associated with each buffer. */
const u16_t user_data_size;
#if defined(CONFIG_NET_BUF_POOL_USAGE)
#if defined(CONFIG_BLE_MESH_NET_BUF_POOL_USAGE)
/** Amount of available buffers in the pool. */
s16_t avail_count;
@@ -508,7 +486,7 @@ struct net_buf_pool {
/** Name of the pool. Used when printing pool information. */
const char *name;
#endif /* CONFIG_NET_BUF_POOL_USAGE */
#endif /* CONFIG_BLE_MESH_NET_BUF_POOL_USAGE */
/** Optional destroy callback when buffer is freed. */
void (*const destroy)(struct net_buf *buf);
@@ -517,34 +495,32 @@ struct net_buf_pool {
struct net_buf *const __bufs;
};
#if defined(CONFIG_NET_BUF_POOL_USAGE)
#define NET_BUF_POOL_INITIALIZER(_pool, _bufs, _count, _size, _ud_size, \
_destroy) \
{ \
.free = _K_LIFO_INITIALIZER(_pool.free), \
.__bufs = (struct net_buf *)_bufs, \
.buf_count = _count, \
.uninit_count = _count, \
.avail_count = _count, \
.pool_size = sizeof(_net_buf_##_pool), \
.buf_size = _size, \
.user_data_size = _ud_size, \
.destroy = _destroy, \
.name = STRINGIFY(_pool), \
#if defined(CONFIG_BLE_MESH_NET_BUF_POOL_USAGE)
#define NET_BUF_POOL_INITIALIZER(_pool, _bufs, _count, _size, _ud_size, \
_destroy) \
{ \
.__bufs = (struct net_buf *)_bufs, \
.buf_count = _count, \
.uninit_count = _count, \
.avail_count = _count, \
.pool_size = sizeof(_net_buf_##_pool), \
.buf_size = _size, \
.user_data_size = _ud_size, \
.destroy = _destroy, \
.name = STRINGIFY(_pool), \
}
#else
#define NET_BUF_POOL_INITIALIZER(_pool, _bufs, _count, _size, _ud_size, \
_destroy) \
{ \
.free = _K_LIFO_INITIALIZER(_pool.free), \
.__bufs = (struct net_buf *)_bufs, \
.buf_count = _count, \
.uninit_count = _count, \
.buf_size = _size, \
.user_data_size = _ud_size, \
.destroy = _destroy, \
#define NET_BUF_POOL_INITIALIZER(_pool, _bufs, _count, _size, _ud_size, \
_destroy) \
{ \
.__bufs = (struct net_buf *)_bufs, \
.buf_count = _count, \
.uninit_count = _count, \
.buf_size = _size, \
.user_data_size = _ud_size, \
.destroy = _destroy, \
}
#endif /* CONFIG_NET_BUF_POOL_USAGE */
#endif /* CONFIG_BLE_MESH_NET_BUF_POOL_USAGE */
/** @def NET_BUF_POOL_DEFINE
* @brief Define a new pool for buffers
@@ -578,30 +554,6 @@ struct net_buf_pool {
NET_BUF_POOL_INITIALIZER(_name, _net_buf_##_name, \
_count, _size, _ud_size, _destroy)
/**
* @brief Looks up a pool based on its ID.
*
* @param id Pool ID (e.g. from buf->pool_id).
*
* @return Pointer to pool.
*/
struct net_buf_pool *net_buf_pool_get(int id);
/**
* @brief Get a zero-based index for a buffer.
*
* This function will translate a buffer into a zero-based index,
* based on its placement in its buffer pool. This can be useful if you
* want to associate an external array of meta-data contexts with the
* buffers of a pool.
*
* @param buf Network buffer.
*
* @return Zero-based index for the buffer.
*/
int net_buf_id(struct net_buf *buf);
/**
* @brief Allocate a new buffer from a pool.
*
@@ -615,53 +567,15 @@ int net_buf_id(struct net_buf *buf);
*
* @return New buffer or NULL if out of buffers.
*/
#if defined(CONFIG_NET_BUF_LOG)
#if defined(CONFIG_BLE_MESH_NET_BUF_LOG)
struct net_buf *net_buf_alloc_debug(struct net_buf_pool *pool, s32_t timeout,
const char *func, int line);
#define net_buf_alloc(_pool, _timeout) \
net_buf_alloc_debug(_pool, _timeout, __func__, __LINE__)
net_buf_alloc_debug(_pool, _timeout, __func__, __LINE__)
#else
struct net_buf *net_buf_alloc(struct net_buf_pool *pool, s32_t timeout);
#endif
/**
* @brief Get a buffer from a FIFO.
*
* Get buffer from a FIFO.
*
* @param fifo Which FIFO to take the buffer from.
* @param timeout Affects the action taken should the FIFO be empty.
* If K_NO_WAIT, then return immediately. If K_FOREVER, then wait as
* long as necessary. Otherwise, wait up to the specified number of
* milliseconds before timing out.
*
* @return New buffer or NULL if the FIFO is empty.
*/
#if defined(CONFIG_NET_BUF_LOG)
struct net_buf *net_buf_get_debug(struct k_fifo *fifo, s32_t timeout,
const char *func, int line);
#define net_buf_get(_fifo, _timeout) \
net_buf_get_debug(_fifo, _timeout, __func__, __LINE__)
#else
struct net_buf *net_buf_get(struct k_fifo *fifo, s32_t timeout);
#endif
/**
* @brief Destroy buffer from custom destroy callback
*
* This helper is only intended to be used from custom destroy callbacks.
* If no custom destroy callback is given to NET_BUF_POOL_DEFINE() then
* there is no need to use this API.
*
* @param buf Buffer to destroy.
*/
static inline void net_buf_destroy(struct net_buf *buf)
{
//struct net_buf_pool *pool = net_buf_pool_get(buf->pool_id);
// TODO: should replace the following funcion in our system
//k_lifo_put(&pool->free, buf);
}
/**
* @brief Reset buffer
*
@@ -707,18 +621,6 @@ void net_buf_slist_put(sys_slist_t *list, struct net_buf *buf);
*/
struct net_buf *net_buf_slist_get(sys_slist_t *list);
/**
* @brief Put a buffer into a FIFO
*
* Put a buffer to the end of a FIFO. If the buffer contains follow-up
* fragments this function will take care of inserting them as well
* into the FIFO.
*
* @param fifo Which FIFO to put the buffer to.
* @param buf Buffer.
*/
void net_buf_put(struct k_fifo *fifo, struct net_buf *buf);
/**
* @brief Decrements the reference count of a buffer.
*
@@ -727,10 +629,10 @@ void net_buf_put(struct k_fifo *fifo, struct net_buf *buf);
*
* @param buf A valid pointer on a buffer
*/
#if defined(CONFIG_NET_BUF_LOG)
#if defined(CONFIG_BLE_MESH_NET_BUF_LOG)
void net_buf_unref_debug(struct net_buf *buf, const char *func, int line);
#define net_buf_unref(_buf) \
net_buf_unref_debug(_buf, __func__, __LINE__)
net_buf_unref_debug(_buf, __func__, __LINE__)
#else
void net_buf_unref(struct net_buf *buf);
#endif
@@ -744,21 +646,6 @@ void net_buf_unref(struct net_buf *buf);
*/
struct net_buf *net_buf_ref(struct net_buf *buf);
/**
* @brief Duplicate buffer
*
* Duplicate given buffer including any data and headers currently stored.
*
* @param buf A valid pointer on a buffer
* @param timeout Affects the action taken should the pool be empty.
* If K_NO_WAIT, then return immediately. If K_FOREVER, then
* wait as long as necessary. Otherwise, wait up to the specified
* number of milliseconds before timing out.
*
* @return Duplicated buffer or NULL if out of buffers.
*/
struct net_buf *net_buf_clone(struct net_buf *buf, s32_t timeout);
/**
* @brief Get a pointer to the user data of a buffer.
*
@@ -798,8 +685,7 @@ static inline void *net_buf_user_data(struct net_buf *buf)
*
* @return The original tail of the buffer.
*/
#define net_buf_add_mem(buf, mem, len) net_buf_simple_add_mem(&(buf)->b, \
mem, len)
#define net_buf_add_mem(buf, mem, len) net_buf_simple_add_mem(&(buf)->b, mem, len)
/**
* @def net_buf_add_u8
@@ -1019,90 +905,6 @@ static inline void *net_buf_user_data(struct net_buf *buf)
*/
#define net_buf_headroom(buf) net_buf_simple_headroom(&(buf)->b)
/**
* @def net_buf_tail
* @brief Get the tail pointer for a buffer.
*
* Get a pointer to the end of the data in a buffer.
*
* @param buf Buffer.
*
* @return Tail pointer for the buffer.
*/
#define net_buf_tail(buf) net_buf_simple_tail(&(buf)->b)
/** @brief Find the last fragment in the fragment list.
*
* @return Pointer to last fragment in the list.
*/
struct net_buf *net_buf_frag_last(struct net_buf *frags);
/** @brief Insert a new fragment to a chain of bufs.
*
* Insert a new fragment into the buffer fragments list after the parent.
*
* Note: This function takes ownership of the fragment reference so the
* caller is not required to unref.
*
* @param parent Parent buffer/fragment.
* @param frag Fragment to insert.
*/
void net_buf_frag_insert(struct net_buf *parent, struct net_buf *frag);
/** @brief Add a new fragment to the end of a chain of bufs.
*
* Append a new fragment into the buffer fragments list.
*
* Note: This function takes ownership of the fragment reference so the
* caller is not required to unref.
*
* @param head Head of the fragment chain.
* @param frag Fragment to add.
*
* @return New head of the fragment chain. Either head (if head
* was non-NULL) or frag (if head was NULL).
*/
struct net_buf *net_buf_frag_add(struct net_buf *head, struct net_buf *frag);
/** @brief Delete existing fragment from a chain of bufs.
*
* @param parent Parent buffer/fragment, or NULL if there is no parent.
* @param frag Fragment to delete.
*
* @return Pointer to the buffer following the fragment, or NULL if it
* had no further fragments.
*/
#if defined(CONFIG_NET_BUF_LOG)
struct net_buf *net_buf_frag_del_debug(struct net_buf *parent,
struct net_buf *frag,
const char *func, int line);
#define net_buf_frag_del(_parent, _frag) \
net_buf_frag_del_debug(_parent, _frag, __func__, __LINE__)
#else
struct net_buf *net_buf_frag_del(struct net_buf *parent, struct net_buf *frag);
#endif
/** @brief Calculate amount of bytes stored in fragments.
*
* Calculates the total amount of data stored in the given buffer and the
* fragments linked to it.
*
* @param buf Buffer to start off with.
*
* @return Number of bytes in the buffer and its fragments.
*/
static inline size_t net_buf_frags_len(struct net_buf *buf)
{
size_t bytes = 0;
while (buf) {
bytes += buf->len;
buf = buf->frags;
}
return bytes;
}
/**
* @}
*/
@@ -1111,8 +913,5 @@ static inline size_t net_buf_frags_len(struct net_buf *buf)
}
#endif
#endif /* __NET_BUF_H */
#endif /* _BLE_MESH_BUF_H_ */

View File

@@ -17,8 +17,8 @@
* simplifies the adding and removing of nodes to/from the list.
*/
#ifndef _misc_dlist__h_
#define _misc_dlist__h_
#ifndef _BLE_MESH_DLIST_H_
#define _BLE_MESH_DLIST_H_
#include <stddef.h>
#include "mesh_util.h"
@@ -27,6 +27,7 @@
extern "C" {
#endif
struct _dnode {
union {
struct _dnode *head; /* ptr to head of list (sys_dlist_t) */
@@ -492,5 +493,4 @@ static inline sys_dnode_t *sys_dlist_get(sys_dlist_t *list)
}
#endif
#endif /* _misc_dlist__h_ */
#endif /* _BLE_MESH_DLIST_H_ */

View File

@@ -4,236 +4,131 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __MESH_HCI_H
#define __MESH_HCI_H
#ifndef _BLE_MESH_HCI_H_
#define _BLE_MESH_HCI_H_
#include "mesh_kernel.h"
#include "mesh_bearer_adapt.h"
#include "mesh_atomic.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Porting form zephyr/subsys/bluetooth/host/hci_core.h */
#if defined(CONFIG_BT_BREDR)
#define LMP_FEAT_PAGES_COUNT 3
#else
#define LMP_FEAT_PAGES_COUNT 1
#endif
#define BLE_MESH_LMP_FEAT_PAGES_COUNT 1
/* bt_dev flags: the flags defined here represent BT controller state */
/* bt_mesh_dev flags: the flags defined here represent BT controller state */
enum {
BT_DEV_ENABLE,
BT_DEV_READY,
BT_DEV_ID_STATIC_RANDOM,
BT_DEV_HAS_PUB_KEY,
BT_DEV_PUB_KEY_BUSY,
BLE_MESH_DEV_ENABLE,
BLE_MESH_DEV_READY,
BLE_MESH_DEV_ID_STATIC_RANDOM,
BLE_MESH_DEV_HAS_PUB_KEY,
BLE_MESH_DEV_PUB_KEY_BUSY,
BT_DEV_ADVERTISING,
BT_DEV_KEEP_ADVERTISING,
BT_DEV_SCANNING,
BT_DEV_EXPLICIT_SCAN,
BT_DEV_ACTIVE_SCAN,
BT_DEV_SCAN_FILTER_DUP,
BLE_MESH_DEV_ADVERTISING,
BLE_MESH_DEV_KEEP_ADVERTISING,
BLE_MESH_DEV_SCANNING,
BLE_MESH_DEV_EXPLICIT_SCAN,
BLE_MESH_DEV_ACTIVE_SCAN,
BLE_MESH_DEV_SCAN_FILTER_DUP,
BT_DEV_RPA_VALID,
BLE_MESH_DEV_RPA_VALID,
BT_DEV_ID_PENDING,
#if defined(CONFIG_BT_BREDR)
BT_DEV_ISCAN,
BT_DEV_PSCAN,
BT_DEV_INQUIRY,
#endif /* CONFIG_BT_BREDR */
BLE_MESH_DEV_ID_PENDING,
/* Total number of flags - must be at the end of the enum */
BT_DEV_NUM_FLAGS,
BLE_MESH_DEV_NUM_FLAGS,
};
struct bt_dev_le {
struct bt_mesh_dev_le {
/* LE features */
u8_t features[8];
u8_t features[8];
/* LE states */
u64_t states;
#if defined(CONFIG_BT_CONN)
/* Controller buffer information */
u16_t mtu;
struct k_sem pkts;
#endif /* CONFIG_BT_CONN */
#if defined(CONFIG_BT_SMP)
/* Size of the the controller resolving list */
u8_t rl_size;
/* Number of entries in the resolving list. rl_entries > rl_size
* means that host-side resolving is used.
*/
u8_t rl_entries;
#endif /* CONFIG_BT_SMP */
u64_t states;
};
#if defined(CONFIG_BT_BREDR)
struct bt_dev_br {
/* Max controller's acceptable ACL packet length */
u16_t mtu;
struct k_sem pkts;
u16_t esco_pkt_type;
};
#endif
/* The theoretical max for these is 8 and 64, but there's no point
* in allocating the full memory if we only support a small subset.
* These values must be updated whenever the host implementation is
* extended beyond the current values.
*/
#define BT_DEV_VS_FEAT_MAX 1
#define BT_DEV_VS_CMDS_MAX 2
/* State tracking for the local Bluetooth controller */
struct bt_dev {
/* Local Identity Address */
bt_addr_le_t id_addr;
/* Current local Random Address */
bt_addr_le_t random_addr;
struct bt_mesh_dev {
/* Flags indicate which functionality is enabled */
BLE_MESH_ATOMIC_DEFINE(flags, BLE_MESH_DEV_NUM_FLAGS);
/* Controller version & manufacturer information */
u8_t hci_version;
u8_t lmp_version;
u16_t hci_revision;
u16_t lmp_subversion;
u16_t manufacturer;
u8_t hci_version;
u8_t lmp_version;
u16_t hci_revision;
u16_t lmp_subversion;
u16_t manufacturer;
/* LMP features (pages 0, 1, 2) */
u8_t features[LMP_FEAT_PAGES_COUNT][8];
/* Supported commands */
u8_t supported_commands[64];
#if defined(CONFIG_BT_HCI_VS_EXT)
/* Vendor HCI support */
u8_t vs_features[BT_DEV_VS_FEAT_MAX];
u8_t vs_commands[BT_DEV_VS_CMDS_MAX];
#endif
#if 0
struct k_work init;
#endif /* if 0 */
ATOMIC_DEFINE(flags, BT_DEV_NUM_FLAGS);
u8_t features[BLE_MESH_LMP_FEAT_PAGES_COUNT][8];
/* LE controller specific features */
struct bt_dev_le le;
#if defined(CONFIG_BT_BREDR)
/* BR/EDR controller specific features */
struct bt_dev_br br;
#endif
#if 0
/* Number of commands controller can accept */
struct k_sem ncmd_sem;
/* Last sent HCI command */
struct net_buf *sent_cmd;
#endif /* if 0 */
#if !defined(CONFIG_BT_RECV_IS_RX_THREAD)
/* Queue for incoming HCI events & ACL data */
struct k_fifo rx_queue;
#endif
#if 0
/* Queue for high priority HCI events which may unlock waiters
* in other threads. Such events include Number of Completed
* Packets, as well as the Command Complete/Status events.
*/
struct k_fifo rx_prio_queue;
/* Queue for outgoing HCI commands */
struct k_fifo cmd_tx_queue;
/* Registered HCI driver */
const struct bt_hci_driver *drv;
#endif /* #if 0 */
#if defined(CONFIG_BT_PRIVACY)
/* Local Identity Resolving Key */
u8_t irk[16];
/* Work used for RPA rotation */
struct k_delayed_work rpa_update;
#endif
struct bt_mesh_dev_le le;
};
/* Added by Espressif */
extern struct bt_dev bt_dev;
void mesh_hci_init(void);
/*Porting from zephyr/subsys/bluetooth/host/hci_core.h */
/* HCI version from Assigned Numbers */
#define BT_HCI_VERSION_1_0B 0
#define BT_HCI_VERSION_1_1 1
#define BT_HCI_VERSION_1_2 2
#define BT_HCI_VERSION_2_0 3
#define BT_HCI_VERSION_2_1 4
#define BT_HCI_VERSION_3_0 5
#define BT_HCI_VERSION_4_0 6
#define BT_HCI_VERSION_4_1 7
#define BT_HCI_VERSION_4_2 8
#define BT_HCI_VERSION_5_0 9
#define BLE_MESH_HCI_VERSION_1_0B 0
#define BLE_MESH_HCI_VERSION_1_1 1
#define BLE_MESH_HCI_VERSION_1_2 2
#define BLE_MESH_HCI_VERSION_2_0 3
#define BLE_MESH_HCI_VERSION_2_1 4
#define BLE_MESH_HCI_VERSION_3_0 5
#define BLE_MESH_HCI_VERSION_4_0 6
#define BLE_MESH_HCI_VERSION_4_1 7
#define BLE_MESH_HCI_VERSION_4_2 8
#define BLE_MESH_HCI_VERSION_5_0 9
/* OpCode Group Fields */
#define BT_OGF_LINK_CTRL 0x01
#define BT_OGF_BASEBAND 0x03
#define BT_OGF_INFO 0x04
#define BT_OGF_STATUS 0x05
#define BT_OGF_LE 0x08
#define BT_OGF_VS 0x3f
#define BLE_MESH_OGF_LINK_CTRL 0x01
#define BLE_MESH_OGF_BASEBAND 0x03
#define BLE_MESH_OGF_INFO 0x04
#define BLE_MESH_OGF_STATUS 0x05
#define BLE_MESH_OGF_LE 0x08
#define BLE_MESH_OGF_VS 0x3f
/* Construct OpCode from OGF and OCF */
#define BT_OP(ogf, ocf) ((ocf) | ((ogf) << 10))
#define BLE_MESH_OP(ogf, ocf) ((ocf) | ((ogf) << 10))
/* Obtain OGF from OpCode */
#define BT_OGF(opcode) (((opcode) >> 10) & BIT_MASK(6))
/* Obtain OCF from OpCode */
#define BT_OCF(opcode) ((opcode) & BIT_MASK(10))
#define BLE_MESH_OGF(opcode) (((opcode) >> 10) & BIT_MASK(6))
#define BT_HCI_OP_LE_SET_ADV_PARAM BT_OP(BT_OGF_LE, 0x0006)
struct bt_hci_cp_le_set_adv_param {
/* Obtain OCF from OpCode */
#define BLE_MESH_OCF(opcode) ((opcode) & BIT_MASK(10))
#define BLE_MESH_HCI_OP_SET_ADV_PARAM BLE_MESH_OP(BLE_MESH_OGF_LE, 0x0006)
struct bt_mesh_hci_cp_set_adv_param {
u16_t min_interval;
u16_t max_interval;
u8_t type;
u8_t own_addr_type;
bt_addr_le_t direct_addr;
bt_mesh_addr_t direct_addr;
u8_t channel_map;
u8_t filter_policy;
} __packed;
#define BT_HCI_OP_LE_SET_ADV_DATA BT_OP(BT_OGF_LE, 0x0008)
struct bt_hci_cp_le_set_adv_data {
#define BLE_MESH_HCI_OP_SET_ADV_DATA BLE_MESH_OP(BLE_MESH_OGF_LE, 0x0008)
struct bt_mesh_hci_cp_set_adv_data {
u8_t len;
u8_t data[31];
} __packed;
#define BT_HCI_OP_LE_SET_SCAN_RSP_DATA BT_OP(BT_OGF_LE, 0x0009)
struct bt_hci_cp_le_set_scan_rsp_data {
#define BLE_MESH_HCI_OP_SET_SCAN_RSP_DATA BLE_MESH_OP(BLE_MESH_OGF_LE, 0x0009)
struct bt_mesh_hci_cp_set_scan_rsp_data {
u8_t len;
u8_t data[31];
} __packed;
/* Added by Espressif */
extern struct bt_mesh_dev bt_mesh_dev;
void bt_mesh_hci_init(void);
#ifdef __cplusplus
}
#endif
#endif /* __MESH_HCI_H */
#endif /* _BLE_MESH_HCI_H_ */

View File

@@ -5,43 +5,33 @@
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _MESH_KERNEL_
#define _MESH_KERNEL_
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "../../../bluedroid/osi/include/osi/mutex.h"
#ifndef _BLE_MESH_KERNEL_H_
#define _BLE_MESH_KERNEL_H_
#include "osi/mutex.h"
#include "mesh_types.h"
#include "mesh_slist.h"
#include "dlist.h"
#include "mesh_atomic.h"
typedef int atomic_t;
typedef atomic_t atomic_val_t;
#include "mesh_dlist.h"
/* number of nsec per usec */
#define NSEC_PER_USEC 1000
#define NSEC_PER_USEC 1000
/* number of microseconds per millisecond */
#define USEC_PER_MSEC 1000
#define USEC_PER_MSEC 1000
/* number of milliseconds per second */
#define MSEC_PER_SEC 1000
#define MSEC_PER_SEC 1000
/* number of microseconds per second */
#define USEC_PER_SEC ((USEC_PER_MSEC) * (MSEC_PER_SEC))
#define USEC_PER_SEC ((USEC_PER_MSEC) * (MSEC_PER_SEC))
/* number of nanoseconds per second */
#define NSEC_PER_SEC ((NSEC_PER_USEC) * (USEC_PER_MSEC) * (MSEC_PER_SEC))
#define ATOMIC_MASK(bit) (1 << ((bit) & (ATOMIC_BITS - 1)))
#define ATOMIC_ELEM(addr, bit) ((addr) + ((bit) / ATOMIC_BITS))
#define NSEC_PER_SEC ((NSEC_PER_USEC) * (USEC_PER_MSEC) * (MSEC_PER_SEC))
/* timeout is not in use */
#define _INACTIVE (-1)
#define _INACTIVE (-1)
/**
* @} end defgroup stack_apis
*/
struct k_work;
/**
@@ -57,50 +47,19 @@ struct k_work;
*/
typedef void (*k_work_handler_t)(struct k_work *work);
typedef sys_dlist_t _wait_q_t;
struct k_work {
void *_reserved; /* Used by k_queue implementation. */
void *_reserved;
k_work_handler_t handler;
atomic_t flags[1];
int index;
};
#define _K_WORK_INITIALIZER(work_handler) \
{ \
._reserved = NULL, \
.handler = work_handler, \
.flags = { 0 } \
}
struct _timeout;
typedef void (*_timeout_func_t)(struct _timeout *t);
struct _timeout {
sys_dnode_t node;
//struct k_thread *thread;
sys_dlist_t *wait_q;
s32_t delta_ticks_from_prev;
_timeout_func_t func;
};
/**
* @brief Define an array of atomic variables.
*
* This macro defines an array of atomic variables containing at least
* @a num_bits bits.
*
* @note
* If used from file scope, the bits of the array are initialized to zero;
* if used from within a function, the bits are left uninitialized.
*
* @param name Name of array of atomic variables.
* @param num_bits Number of bits needed.
*/
#define ATOMIC_DEFINE(name, num_bits) \
atomic_t name[1 + ((num_bits) - 1) / ATOMIC_BITS]
#define _K_WORK_INITIALIZER(work_handler) \
{ \
._reserved = NULL, \
.handler = work_handler, \
}
/**
* @brief Generate null timeout delay.
@@ -110,7 +69,7 @@ struct _timeout {
*
* @return Timeout delay value.
*/
#define K_NO_WAIT 0
#define K_NO_WAIT 0
/**
* @brief Generate timeout delay from milliseconds.
@@ -122,7 +81,7 @@ struct _timeout {
*
* @return Timeout delay value.
*/
#define K_MSEC(ms) (ms)
#define K_MSEC(ms) (ms)
/**
* @brief Generate timeout delay from seconds.
@@ -134,7 +93,7 @@ struct _timeout {
*
* @return Timeout delay value.
*/
#define K_SECONDS(s) K_MSEC((s) * MSEC_PER_SEC)
#define K_SECONDS(s) K_MSEC((s) * MSEC_PER_SEC)
/**
* @brief Generate timeout delay from minutes.
@@ -146,7 +105,7 @@ struct _timeout {
*
* @return Timeout delay value.
*/
#define K_MINUTES(m) K_SECONDS((m) * 60)
#define K_MINUTES(m) K_SECONDS((m) * 60)
/**
* @brief Generate timeout delay from hours.
@@ -158,7 +117,7 @@ struct _timeout {
*
* @return Timeout delay value.
*/
#define K_HOURS(h) K_MINUTES((h) * 60)
#define K_HOURS(h) K_MINUTES((h) * 60)
/**
* @brief Generate infinite timeout delay.
@@ -168,8 +127,7 @@ struct _timeout {
*
* @return Timeout delay value.
*/
#define K_FOREVER (-1)
#define K_FOREVER (-1)
/**
* @brief Get system uptime (32-bit version).
@@ -186,114 +144,10 @@ struct _timeout {
*/
u32_t k_uptime_get_32(void);
struct k_sem {
osi_mutex_t mutex;
};
struct k_queue {
sys_slist_t data_q;
union {
_wait_q_t wait_q;
// TODO: The following not used now, delete it temporarily.
//_POLL_EVENT;
};
// TODO: The following not used now, delete it temporarily.
//_OBJECT_TRACING_NEXT_PTR(k_queue);
};
struct k_work_q {
struct k_queue queue;
};
/**
* @cond INTERNAL_HIDDEN
*/
struct k_fifo {
struct k_queue _queue;
};
struct k_lifo {
struct k_queue _queue;
};
struct k_delayed_work {
struct k_work work;
struct _timeout timeout;
struct k_work_q *work_q;
};
#define _K_QUEUE_INITIALIZER(obj) \
{ \
.wait_q = SYS_DLIST_STATIC_INIT(&obj.wait_q), \
.data_q = SYS_SLIST_STATIC_INIT(&obj.data_q), \
}
#define _K_FIFO_INITIALIZER(obj) \
{ \
._queue = _K_QUEUE_INITIALIZER(obj._queue) \
}
#define _K_LIFO_INITIALIZER(obj) \
{ \
._queue = _K_QUEUE_INITIALIZER(obj._queue) \
}
/**
* @brief Statically define and initialize a fifo.
*
* The fifo can be accessed outside the module where it is defined using:
*
* @code extern struct k_fifo <name>; @endcode
*
* @param name Name of the fifo.
*/
#define K_FIFO_DEFINE(name) \
struct k_fifo name \
__in_section(_k_queue, static, name) = \
_K_FIFO_INITIALIZER(name)
/* initialize the timeouts part of k_thread when enabled in the kernel */
static inline void _init_timeout(struct _timeout *t, _timeout_func_t func)
{
/*
* Must be initialized here and when dequeueing a timeout so that code
* not dealing with timeouts does not have to handle this, such as when
* waiting forever on a semaphore.
*/
t->delta_ticks_from_prev = _INACTIVE;
/*
* Must be initialized here so that k_wakeup can
* verify the thread is not on a wait queue before aborting a timeout.
*/
t->wait_q = NULL;
/*
* Function must be initialized before being potentially called.
*/
t->func = func;
/*
* These are initialized when enqueing on the timeout queue:
*
* thread->timeout.node.next
* thread->timeout.node.prev
*/
}
unsigned int irq_lock(void);
void irq_unlock(unsigned int key);
void mesh_k_init(void);
/**
* @brief Submit a delayed work item to the system workqueue.
*
@@ -326,8 +180,7 @@ void mesh_k_init(void);
* @retval -EINVAL Work item is being processed or has completed its work.
* @retval -EADDRINUSE Work item is pending on a different workqueue.
*/
int k_delayed_work_submit(struct k_delayed_work *work,
s32_t delay);
int k_delayed_work_submit(struct k_delayed_work *work, s32_t delay);
/**
* @brief Get time remaining before a delayed work gets scheduled.
@@ -365,13 +218,9 @@ s32_t k_delayed_work_remaining_get(struct k_delayed_work *work);
*/
static inline void k_work_submit(struct k_work *work)
{
// TODO:
if (work != NULL) {
if (work && work->handler) {
work->handler(work);
}
return;
//k_work_submit_to_queue(&k_sys_work_q, work);
}
/**
@@ -417,56 +266,10 @@ s64_t k_uptime_get(void);
*/
void k_sleep(s32_t duration);
/**
* @brief Give a semaphore.
*
* This routine gives @a sem, unless the semaphore is already at its maximum
* permitted count.
*
* @note Can be called by ISRs.
*
* @param sem Address of the semaphore.
*
* @return N/A
*/
void k_sem_give(struct k_sem *sem);
unsigned int bt_mesh_irq_lock(void);
void bt_mesh_irq_unlock(unsigned int key);
/**
* @brief Initialize a semaphore.
*
* This routine initializes a semaphore object, prior to its first use.
*
* @param sem Address of the semaphore.
* @param initial_count Initial semaphore count.
* @param limit Maximum permitted semaphore count.
*
* @return N/A
*/
void k_sem_init(struct k_sem *sem, unsigned int initial_count,
unsigned int limit);
void bt_mesh_k_init(void);
/**
* @brief Take a semaphore.
*
* This routine takes @a sem.
*
* @note Can be called by ISRs, but @a timeout must be set to K_NO_WAIT.
*
* @param sem Address of the semaphore.
* @param timeout Waiting period to take the semaphore (in milliseconds),
* or one of the special values K_NO_WAIT and K_FOREVER.
*
* @note When porting code from the nanokernel legacy API to the new API, be
* careful with the return value of this function. The return value is the
* reverse of the one of nano_sem_take family of APIs: 0 means success, and
* non-zero means failure, while the nano_sem_take family returns 1 for success
* and 0 for failure.
*
* @retval 0 Semaphore taken.
* @retval -EBUSY Returned without waiting.
* @retval -EAGAIN Waiting period timed out.
*/
int k_sem_take(struct k_sem *sem, s32_t timeout);
#endif /* #ifndef _MESH_KERNEL_ */
#endif /* _BLE_MESH_KERNEL_H_ */

View File

@@ -8,12 +8,11 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __BT_MESH_MAIN_H
#define __BT_MESH_MAIN_H
#ifndef _BLE_MESH_MAIN_H_
#define _BLE_MESH_MAIN_H_
#include "mesh_util.h"
#include "mesh_access.h"
#if CONFIG_BT_MESH
/**
* @brief Bluetooth Mesh Provisioning
@@ -23,30 +22,30 @@
*/
typedef enum {
BT_MESH_NO_OUTPUT = 0,
BT_MESH_BLINK = BIT(0),
BT_MESH_BEEP = BIT(1),
BT_MESH_VIBRATE = BIT(2),
BT_MESH_DISPLAY_NUMBER = BIT(3),
BT_MESH_DISPLAY_STRING = BIT(4),
BLE_MESH_NO_OUTPUT = 0,
BLE_MESH_BLINK = BIT(0),
BLE_MESH_BEEP = BIT(1),
BLE_MESH_VIBRATE = BIT(2),
BLE_MESH_DISPLAY_NUMBER = BIT(3),
BLE_MESH_DISPLAY_STRING = BIT(4),
} bt_mesh_output_action_t;
typedef enum {
BT_MESH_NO_INPUT = 0,
BT_MESH_PUSH = BIT(0),
BT_MESH_TWIST = BIT(1),
BT_MESH_ENTER_NUMBER = BIT(2),
BT_MESH_ENTER_STRING = BIT(3),
BLE_MESH_NO_INPUT = 0,
BLE_MESH_PUSH = BIT(0),
BLE_MESH_TWIST = BIT(1),
BLE_MESH_ENTER_NUMBER = BIT(2),
BLE_MESH_ENTER_STRING = BIT(3),
} bt_mesh_input_action_t;
typedef enum {
BT_MESH_PROV_ADV = BIT(0),
BT_MESH_PROV_GATT = BIT(1),
BLE_MESH_PROV_ADV = BIT(0),
BLE_MESH_PROV_GATT = BIT(1),
} bt_mesh_prov_bearer_t;
/** Provisioning properties & capabilities. */
struct bt_mesh_prov {
#if CONFIG_BT_MESH_NODE
#if CONFIG_BLE_MESH_NODE
/** The UUID that's used when advertising as unprovisioned */
const u8_t *uuid;
@@ -154,9 +153,9 @@ struct bt_mesh_prov {
* unprovisioned advertising on one or more provisioning bearers.
*/
void (*reset)(void);
#endif /* CONFIG_BT_MESH_NODE */
#endif /* CONFIG_BLE_MESH_NODE */
#if CONFIG_BT_MESH_PROVISIONER
#if CONFIG_BLE_MESH_PROVISIONER
/* Provisioner device uuid */
const u8_t *prov_uuid;
@@ -274,13 +273,13 @@ struct bt_mesh_prov {
u16_t unicast_addr, u8_t element_num,
u16_t netkey_idx);
#endif /* CONFIG_BT_MESH_PROVISIONER */
#endif /* CONFIG_BLE_MESH_PROVISIONER */
};
/** @brief Provide provisioning input OOB string.
*
* This is intended to be called after the bt_mesh_prov input callback
* has been called with BT_MESH_ENTER_STRING as the action.
* has been called with BLE_MESH_ENTER_STRING as the action.
*
* @param str String.
*
@@ -291,7 +290,7 @@ int bt_mesh_input_string(const char *str);
/** @brief Provide provisioning input OOB number.
*
* This is intended to be called after the bt_mesh_prov input callback
* has been called with BT_MESH_ENTER_NUMBER as the action.
* has been called with BLE_MESH_ENTER_NUMBER as the action.
*
* @param num Number.
*
@@ -327,7 +326,7 @@ bool bt_mesh_is_provisioner_en(void);
/* The following API is for fast provisioning */
#if CONFIG_BT_MESH_FAST_PROV
#if CONFIG_BLE_MESH_FAST_PROV
/** @brief Change the device action
*
@@ -338,14 +337,14 @@ bool bt_mesh_is_provisioner_en(void);
*/
u8_t bt_mesh_set_fast_prov_action(u8_t action);
#endif /* CONFIG_BT_MESH_FAST_PROV */
#endif /* CONFIG_BLE_MESH_FAST_PROV */
#if CONFIG_BT_MESH_PROVISIONER
#if CONFIG_BLE_MESH_PROVISIONER
/** @brief Provide provisioning input OOB string.
*
* This is intended to be called after the bt_mesh_prov input callback
* has been called with BT_MESH_ENTER_STRING as the action.
* has been called with BLE_MESH_ENTER_STRING as the action.
*
* @param str String.
*
@@ -356,7 +355,7 @@ int bt_mesh_prov_input_string(const char *str);
/** @brief Provide provisioning input OOB number.
*
* This is intended to be called after the bt_mesh_prov input callback
* has been called with BT_MESH_ENTER_NUMBER as the action.
* has been called with BLE_MESH_ENTER_NUMBER as the action.
*
* @param num Number.
*
@@ -384,7 +383,7 @@ int bt_mesh_provisioner_enable(bt_mesh_prov_bearer_t bearers);
*/
int bt_mesh_provisioner_disable(bt_mesh_prov_bearer_t bearers);
#endif /* CONFIG_BT_MESH_PROVISIONER */
#endif /* CONFIG_BLE_MESH_PROVISIONER */
/**
* @}
@@ -398,36 +397,36 @@ int bt_mesh_provisioner_disable(bt_mesh_prov_bearer_t bearers);
*/
/* Primary Network Key index */
#define BT_MESH_NET_PRIMARY 0x000
#define BLE_MESH_NET_PRIMARY 0x000
#define BT_MESH_RELAY_DISABLED 0x00
#define BT_MESH_RELAY_ENABLED 0x01
#define BT_MESH_RELAY_NOT_SUPPORTED 0x02
#define BLE_MESH_RELAY_DISABLED 0x00
#define BLE_MESH_RELAY_ENABLED 0x01
#define BLE_MESH_RELAY_NOT_SUPPORTED 0x02
#define BT_MESH_BEACON_DISABLED 0x00
#define BT_MESH_BEACON_ENABLED 0x01
#define BLE_MESH_BEACON_DISABLED 0x00
#define BLE_MESH_BEACON_ENABLED 0x01
#define BT_MESH_GATT_PROXY_DISABLED 0x00
#define BT_MESH_GATT_PROXY_ENABLED 0x01
#define BT_MESH_GATT_PROXY_NOT_SUPPORTED 0x02
#define BLE_MESH_GATT_PROXY_DISABLED 0x00
#define BLE_MESH_GATT_PROXY_ENABLED 0x01
#define BLE_MESH_GATT_PROXY_NOT_SUPPORTED 0x02
#define BT_MESH_FRIEND_DISABLED 0x00
#define BT_MESH_FRIEND_ENABLED 0x01
#define BT_MESH_FRIEND_NOT_SUPPORTED 0x02
#define BLE_MESH_FRIEND_DISABLED 0x00
#define BLE_MESH_FRIEND_ENABLED 0x01
#define BLE_MESH_FRIEND_NOT_SUPPORTED 0x02
#define BT_MESH_NODE_IDENTITY_STOPPED 0x00
#define BT_MESH_NODE_IDENTITY_RUNNING 0x01
#define BT_MESH_NODE_IDENTITY_NOT_SUPPORTED 0x02
#define BLE_MESH_NODE_IDENTITY_STOPPED 0x00
#define BLE_MESH_NODE_IDENTITY_RUNNING 0x01
#define BLE_MESH_NODE_IDENTITY_NOT_SUPPORTED 0x02
/* Features */
#define BT_MESH_FEAT_RELAY BIT(0)
#define BT_MESH_FEAT_PROXY BIT(1)
#define BT_MESH_FEAT_FRIEND BIT(2)
#define BT_MESH_FEAT_LOW_POWER BIT(3)
#define BT_MESH_FEAT_SUPPORTED (BT_MESH_FEAT_RELAY | \
BT_MESH_FEAT_PROXY | \
BT_MESH_FEAT_FRIEND | \
BT_MESH_FEAT_LOW_POWER)
#define BLE_MESH_FEAT_RELAY BIT(0)
#define BLE_MESH_FEAT_PROXY BIT(1)
#define BLE_MESH_FEAT_FRIEND BIT(2)
#define BLE_MESH_FEAT_LOW_POWER BIT(3)
#define BLE_MESH_FEAT_SUPPORTED (BLE_MESH_FEAT_RELAY | \
BLE_MESH_FEAT_PROXY | \
BLE_MESH_FEAT_FRIEND | \
BLE_MESH_FEAT_LOW_POWER)
/** @brief Initialize Mesh support
*
@@ -530,5 +529,4 @@ void bt_mesh_lpn_set_cb(void (*cb)(u16_t friend_addr, bool established));
* @}
*/
#endif /* __BT_MESH_MAIN_H */
#endif /* #if CONFIG_BT_MESH */
#endif /* _BLE_MESH_MAIN_H_ */

View File

@@ -8,8 +8,8 @@
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __BT_MESH_PROXY_H
#define __BT_MESH_PROXY_H
#ifndef _BLE_MESH_PROXY_H_
#define _BLE_MESH_PROXY_H_
#include <stddef.h>
/**
@@ -34,4 +34,4 @@ int bt_mesh_proxy_identity_enable(void);
* @}
*/
#endif /* __BT_MESH_PROXY_H */
#endif /* _BLE_MESH_PROXY_H_ */

View File

@@ -14,8 +14,8 @@
* calls to functions must be protected with synchronization primitives.
*/
#ifndef __SLIST_H__
#define __SLIST_H__
#ifndef _BLE_MESH_SLIST_H_
#define _BLE_MESH_SLIST_H_
#include <stddef.h>
#include <stdbool.h>
@@ -25,7 +25,6 @@
extern "C" {
#endif
struct _snode {
struct _snode *next;
};
@@ -54,8 +53,8 @@ typedef struct _slist sys_slist_t;
* @param __sl A pointer on a sys_slist_t to iterate on
* @param __sn A sys_snode_t pointer to peek each node of the list
*/
#define SYS_SLIST_FOR_EACH_NODE(__sl, __sn) \
for (__sn = sys_slist_peek_head(__sl); __sn; \
#define SYS_SLIST_FOR_EACH_NODE(__sl, __sn) \
for (__sn = sys_slist_peek_head(__sl); __sn; \
__sn = sys_slist_peek_next(__sn))
/**
@@ -79,9 +78,9 @@ typedef struct _slist sys_slist_t;
* it contains the starting node, or NULL to start from the head
*/
#define SYS_SLIST_ITERATE_FROM_NODE(__sl, __sn) \
for (__sn = __sn ? sys_slist_peek_next_no_check(__sn) \
: sys_slist_peek_head(__sl); \
__sn; \
for (__sn = __sn ? sys_slist_peek_next_no_check(__sn) \
: sys_slist_peek_head(__sl); \
__sn; \
__sn = sys_slist_peek_next(__sn))
/**
@@ -100,10 +99,10 @@ typedef struct _slist sys_slist_t;
* @param __sn A sys_snode_t pointer to peek each node of the list
* @param __sns A sys_snode_t pointer for the loop to run safely
*/
#define SYS_SLIST_FOR_EACH_NODE_SAFE(__sl, __sn, __sns) \
#define SYS_SLIST_FOR_EACH_NODE_SAFE(__sl, __sn, __sns) \
for (__sn = sys_slist_peek_head(__sl), \
__sns = sys_slist_peek_next(__sn); \
__sn; __sn = __sns, \
__sn; __sn = __sns, \
__sns = sys_slist_peek_next(__sn))
/*
@@ -114,8 +113,8 @@ typedef struct _slist sys_slist_t;
* @param __cn Container struct type pointer
* @param __n The field name of sys_node_t within the container struct
*/
#define SYS_SLIST_CONTAINER(__ln, __cn, __n) \
((__ln) ? CONTAINER_OF((__ln), __typeof__(*(__cn)), __n) : NULL)
#define SYS_SLIST_CONTAINER(__ln, __cn, __n) \
((__ln) ? CONTAINER_OF((__ln), __typeof__(*(__cn)), __n) : NULL)
/*
* @brief Provide the primitive to peek container of the list head
*
@@ -123,8 +122,8 @@ typedef struct _slist sys_slist_t;
* @param __cn Container struct type pointer
* @param __n The field name of sys_node_t within the container struct
*/
#define SYS_SLIST_PEEK_HEAD_CONTAINER(__sl, __cn, __n) \
SYS_SLIST_CONTAINER(sys_slist_peek_head(__sl), __cn, __n)
#define SYS_SLIST_PEEK_HEAD_CONTAINER(__sl, __cn, __n) \
SYS_SLIST_CONTAINER(sys_slist_peek_head(__sl), __cn, __n)
/*
* @brief Provide the primitive to peek container of the list tail
@@ -133,8 +132,8 @@ typedef struct _slist sys_slist_t;
* @param __cn Container struct type pointer
* @param __n The field name of sys_node_t within the container struct
*/
#define SYS_SLIST_PEEK_TAIL_CONTAINER(__sl, __cn, __n) \
SYS_SLIST_CONTAINER(sys_slist_peek_tail(__sl), __cn, __n)
#define SYS_SLIST_PEEK_TAIL_CONTAINER(__sl, __cn, __n) \
SYS_SLIST_CONTAINER(sys_slist_peek_tail(__sl), __cn, __n)
/*
* @brief Provide the primitive to peek the next container
@@ -143,9 +142,9 @@ typedef struct _slist sys_slist_t;
* @param __n The field name of sys_node_t within the container struct
*/
#define SYS_SLIST_PEEK_NEXT_CONTAINER(__cn, __n) \
((__cn) ? SYS_SLIST_CONTAINER(sys_slist_peek_next(&((__cn)->__n)), \
__cn, __n) : NULL)
#define SYS_SLIST_PEEK_NEXT_CONTAINER(__cn, __n) \
((__cn) ? SYS_SLIST_CONTAINER(sys_slist_peek_next(&((__cn)->__n)), \
__cn, __n) : NULL)
/**
* @brief Provide the primitive to iterate on a list under a container
@@ -161,8 +160,8 @@ typedef struct _slist sys_slist_t;
* @param __cn A pointer to peek each entry of the list
* @param __n The field name of sys_node_t within the container struct
*/
#define SYS_SLIST_FOR_EACH_CONTAINER(__sl, __cn, __n) \
for (__cn = SYS_SLIST_PEEK_HEAD_CONTAINER(__sl, __cn, __n); __cn; \
#define SYS_SLIST_FOR_EACH_CONTAINER(__sl, __cn, __n) \
for (__cn = SYS_SLIST_PEEK_HEAD_CONTAINER(__sl, __cn, __n); __cn; \
__cn = SYS_SLIST_PEEK_NEXT_CONTAINER(__cn, __n))
/**
@@ -181,7 +180,7 @@ typedef struct _slist sys_slist_t;
* @param __n The field name of sys_node_t within the container struct
*/
#define SYS_SLIST_FOR_EACH_CONTAINER_SAFE(__sl, __cn, __cns, __n) \
for (__cn = SYS_SLIST_PEEK_HEAD_CONTAINER(__sl, __cn, __n), \
for (__cn = SYS_SLIST_PEEK_HEAD_CONTAINER(__sl, __cn, __n), \
__cns = SYS_SLIST_PEEK_NEXT_CONTAINER(__cn, __n); __cn; \
__cn = __cns, __cns = SYS_SLIST_PEEK_NEXT_CONTAINER(__cn, __n))
@@ -461,10 +460,9 @@ static inline bool sys_slist_find_and_remove(sys_slist_t *list,
return false;
}
#ifdef __cplusplus
}
#endif
#endif /* __SLIST_H__ */
#endif /* _BLE_MESH_SLIST_H_ */

View File

@@ -6,6 +6,9 @@
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _BLE_MESH_TRACE_H_
#define _BLE_MESH_TRACE_H_
#include "esp_log.h"
#include "sdkconfig.h"
@@ -30,85 +33,99 @@
#define LOG_LEVEL_VERBOSE 5
#endif /*LOG_LEVEL_VERBOSE */
#ifdef CONFIG_BT_MESH_STACK_INITIAL_TRACE_LEVEL
#define MESH_LOG_LEVEL CONFIG_BT_MESH_STACK_INITIAL_TRACE_LEVEL
#ifdef CONFIG_BLE_MESH_STACK_TRACE_LEVEL
#define MESH_LOG_LEVEL CONFIG_BLE_MESH_STACK_TRACE_LEVEL
#else
#define MESH_LOG_LEVEL LOG_LEVEL_WARN
#define MESH_LOG_LEVEL LOG_LEVEL_WARN
#endif
#ifdef CONFIG_BT_MESH_NET_BUF_TRACE_LEVEL
#define NET_BUF_LOG_LEVEL CONFIG_BT_MESH_NET_BUF_TRACE_LEVEL
#ifdef CONFIG_BLE_MESH_NET_BUF_TRACE_LEVEL
#define NET_BUF_LOG_LEVEL CONFIG_BLE_MESH_NET_BUF_TRACE_LEVEL
#else
#define NET_BUF_LOG_LEVEL LOG_LEVEL_WARN
#define NET_BUF_LOG_LEVEL LOG_LEVEL_WARN
#endif
#define MESH_TRACE_TAG "BLE_MESH"
#if (LOG_LOCAL_LEVEL >= 4)
#define BT_MESH_LOG_LOCAL_LEVEL_MAPPING (LOG_LOCAL_LEVEL + 1)
#define BLE_MESH_LOG_LOCAL_LEVEL_MAPPING (LOG_LOCAL_LEVEL + 1)
#else
#define BT_MESH_LOG_LOCAL_LEVEL_MAPPING LOG_LOCAL_LEVEL
#define BLE_MESH_LOG_LOCAL_LEVEL_MAPPING LOG_LOCAL_LEVEL
#endif
#ifndef MAX
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#endif /* MAX(a, b) */
#define BT_MESH_LOG_LEVEL_CHECK(LAYER, LEVEL) (MAX(LAYER##_LOG_LEVEL, BT_MESH_LOG_LOCAL_LEVEL_MAPPING) >= LOG_LEVEL_##LEVEL)
#define BT_MESH_PRINT_E(tag, format, ...) {esp_log_write(ESP_LOG_ERROR, tag, LOG_FORMAT(E, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
#define BT_MESH_PRINT_W(tag, format, ...) {esp_log_write(ESP_LOG_WARN, tag, LOG_FORMAT(W, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
#define BT_MESH_PRINT_I(tag, format, ...) {esp_log_write(ESP_LOG_INFO, tag, LOG_FORMAT(I, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
#define BT_MESH_PRINT_D(tag, format, ...) {esp_log_write(ESP_LOG_DEBUG, tag, LOG_FORMAT(D, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
#define BT_MESH_PRINT_V(tag, format, ...) {esp_log_write(ESP_LOG_VERBOSE, tag, LOG_FORMAT(V, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
#define BLE_MESH_LOG_LEVEL_CHECK(LAYER, LEVEL) (MAX(LAYER##_LOG_LEVEL, BLE_MESH_LOG_LOCAL_LEVEL_MAPPING) >= LOG_LEVEL_##LEVEL)
#ifndef __ASSERT_NO_MSG
#define __ASSERT_NO_MSG(x) do { if (!(x)) BT_MESH_PRINT_E(MESH_TRACE_TAG, "bt mesh error %s %u\n", __FILE__, __LINE__); } while (0)
#define BLE_MESH_PRINT_E(tag, format, ...) {esp_log_write(ESP_LOG_ERROR, tag, LOG_FORMAT(E, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
#define BLE_MESH_PRINT_W(tag, format, ...) {esp_log_write(ESP_LOG_WARN, tag, LOG_FORMAT(W, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
#define BLE_MESH_PRINT_I(tag, format, ...) {esp_log_write(ESP_LOG_INFO, tag, LOG_FORMAT(I, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
#define BLE_MESH_PRINT_D(tag, format, ...) {esp_log_write(ESP_LOG_DEBUG, tag, LOG_FORMAT(D, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
#define BLE_MESH_PRINT_V(tag, format, ...) {esp_log_write(ESP_LOG_VERBOSE, tag, LOG_FORMAT(V, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
#define printk ets_printf
#define _STRINGIFY(x) #x
#define STRINGIFY(s) _STRINGIFY(s)
#ifndef __ASSERT
#define __ASSERT(test, fmt, ...) \
do { \
if (!(test)) { \
printk("ASSERTION FAIL [%s] @ %s:%d:\n\t", \
_STRINGIFY(test), \
__FILE__, \
__LINE__); \
printk(fmt, ##__VA_ARGS__); \
for (;;); \
} \
} while ((0))
#endif
#if !CONFIG_BT_MESH_NO_LOG
#define BT_ERR(fmt, args...) do {if ((MESH_LOG_LEVEL >= LOG_LEVEL_ERROR) && BT_MESH_LOG_LEVEL_CHECK(MESH, ERROR)) BT_MESH_PRINT_E(MESH_TRACE_TAG, fmt, ## args);} while(0)
#define BT_WARN(fmt, args...) do {if ((MESH_LOG_LEVEL >= LOG_LEVEL_WARN) && BT_MESH_LOG_LEVEL_CHECK(MESH, WARN)) BT_MESH_PRINT_W(MESH_TRACE_TAG, fmt, ## args);} while(0)
#define BT_INFO(fmt, args...) do {if ((MESH_LOG_LEVEL >= LOG_LEVEL_INFO) && BT_MESH_LOG_LEVEL_CHECK(MESH, INFO)) BT_MESH_PRINT_I(MESH_TRACE_TAG, fmt, ## args);} while(0)
#define BT_DBG(fmt, args...) do {if ((MESH_LOG_LEVEL >= LOG_LEVEL_DEBUG) && BT_MESH_LOG_LEVEL_CHECK(MESH, DEBUG)) BT_MESH_PRINT_D(MESH_TRACE_TAG, fmt, ## args);} while(0)
#else /* #if !CONFIG_BT_STACK_NO_LOG */
#ifndef __ASSERT_NO_MSG
#define __ASSERT_NO_MSG(x) do { if (!(x)) BLE_MESH_PRINT_E(MESH_TRACE_TAG, "error %s %u", __FILE__, __LINE__); } while (0)
#endif
#if !CONFIG_BLE_MESH_NO_LOG
#define BT_ERR(fmt, args...) do {if ((MESH_LOG_LEVEL >= LOG_LEVEL_ERROR) && BLE_MESH_LOG_LEVEL_CHECK(MESH, ERROR)) BLE_MESH_PRINT_E(MESH_TRACE_TAG, fmt, ## args);} while(0)
#define BT_WARN(fmt, args...) do {if ((MESH_LOG_LEVEL >= LOG_LEVEL_WARN) && BLE_MESH_LOG_LEVEL_CHECK(MESH, WARN)) BLE_MESH_PRINT_W(MESH_TRACE_TAG, fmt, ## args);} while(0)
#define BT_INFO(fmt, args...) do {if ((MESH_LOG_LEVEL >= LOG_LEVEL_INFO) && BLE_MESH_LOG_LEVEL_CHECK(MESH, INFO)) BLE_MESH_PRINT_I(MESH_TRACE_TAG, fmt, ## args);} while(0)
#define BT_DBG(fmt, args...) do {if ((MESH_LOG_LEVEL >= LOG_LEVEL_DEBUG) && BLE_MESH_LOG_LEVEL_CHECK(MESH, DEBUG)) BLE_MESH_PRINT_D(MESH_TRACE_TAG, fmt, ## args);} while(0)
#else
#define BT_ERR(fmt, args...)
#define BT_WARN(fmt, args...)
#define BT_INFO(fmt, args...)
#define BT_DBG(fmt, args...)
#endif /* #if !CONFIG_BT_STACK_NO_LOG */
#endif
#if defined(CONFIG_NET_BUF_LOG) && (!CONFIG_BT_MESH_NO_LOG)
#define NET_BUF_DBG(fmt, ...) do {if ((MESH_LOG_LEVEL >= LOG_LEVEL_ERROR) && BT_MESH_LOG_LEVEL_CHECK(NET_BUF, DEBUG)) BT_MESH_PRINT_D(MESH_TRACE_TAG, fmt, ## args);} while(0)
#define NET_BUF_ERR(fmt, ...) do {if ((MESH_LOG_LEVEL >= LOG_LEVEL_ERROR) && BT_MESH_LOG_LEVEL_CHECK(NET_BUF, ERROR)) BT_MESH_PRINT_E(MESH_TRACE_TAG, fmt, ## args);} while(0)
#define NET_BUF_WARN(fmt, ...) do {if ((MESH_LOG_LEVEL >= LOG_LEVEL_ERROR) && BT_MESH_LOG_LEVEL_CHECK(NET_BUF, WARN)) BT_MESH_PRINT_W(MESH_TRACE_TAG, fmt, ## args);} while(0)
#define NET_BUF_INFO(fmt, ...) do {if ((MESH_LOG_LEVEL >= LOG_LEVEL_ERROR) && BT_MESH_LOG_LEVEL_CHECK(NET_BUF, INFO)) BT_MESH_PRINT_I(MESH_TRACE_TAG, fmt, ## args);} while(0)
#define NET_BUF_ASSERT(cond) do { if (!(cond)) { \
NET_BUF_ERR("assert: '" #cond "' failed"); \
} } while (0)
#if defined(CONFIG_BLE_MESH_NET_BUF_LOG) && (!CONFIG_BLE_MESH_NO_LOG)
#define NET_BUF_ERR(fmt, args...) do {if ((NET_BUF_LOG_LEVEL >= LOG_LEVEL_ERROR) && BLE_MESH_LOG_LEVEL_CHECK(NET_BUF, ERROR)) BLE_MESH_PRINT_E(MESH_TRACE_TAG, fmt, ## args);} while(0)
#define NET_BUF_WARN(fmt, args...) do {if ((NET_BUF_LOG_LEVEL >= LOG_LEVEL_WARN) && BLE_MESH_LOG_LEVEL_CHECK(NET_BUF, WARN)) BLE_MESH_PRINT_W(MESH_TRACE_TAG, fmt, ## args);} while(0)
#define NET_BUF_INFO(fmt, args...) do {if ((NET_BUF_LOG_LEVEL >= LOG_LEVEL_INFO) && BLE_MESH_LOG_LEVEL_CHECK(NET_BUF, INFO)) BLE_MESH_PRINT_I(MESH_TRACE_TAG, fmt, ## args);} while(0)
#define NET_BUF_DBG(fmt, args...) do {if ((NET_BUF_LOG_LEVEL >= LOG_LEVEL_DEBUG) && BLE_MESH_LOG_LEVEL_CHECK(NET_BUF, DEBUG)) BLE_MESH_PRINT_D(MESH_TRACE_TAG, fmt, ## args);} while(0)
#define NET_BUF_ASSERT(cond) __ASSERT_NO_MSG(cond)
#else
#define NET_BUF_DBG(fmt, ...)
#define NET_BUF_ERR(fmt, ...)
#define NET_BUF_WARN(fmt, ...)
#define NET_BUF_INFO(fmt, ...)
#define NET_BUF_ERR(fmt, args...)
#define NET_BUF_WARN(fmt, args...)
#define NET_BUF_INFO(fmt, args...)
#define NET_BUF_DBG(fmt, args...)
#define NET_BUF_ASSERT(cond)
#endif /* CONFIG_NET_BUF_LOG */
#endif
#if defined(CONFIG_NET_BUF_SIMPLE_LOG) && (!CONFIG_BT_MESH_NO_LOG)
#define NET_BUF_SIMPLE_DBG(fmt, ...) do {if (MESH_LOG_LEVEL >= LOG_LEVEL_DEBUG) esp_log_write(ESP_LOG_ERROR, MESH_TRACE_TAG, LOG_FORMAT(D, format), esp_log_timestamp(), "BT_LOG", ##__VA_ARGS__);} while(0)
#define NET_BUF_SIMPLE_ERR(fmt, ...) do {if (MESH_LOG_LEVEL >= LOG_LEVEL_ERROR) esp_log_write(ESP_LOG_ERROR, MESH_TRACE_TAG, LOG_FORMAT(E, format), esp_log_timestamp(), "BT_LOG", ##__VA_ARGS__);} while(0)
#define NET_BUF_SIMPLE_WARN(fmt, ...) do {if (MESH_LOG_LEVEL >= LOG_LEVEL_WARN) esp_log_write(ESP_LOG_ERROR, MESH_TRACE_TAG, LOG_FORMAT(W, format), esp_log_timestamp(), "BT_LOG", ##__VA_ARGS__);} while(0)
#define NET_BUF_SIMPLE_INFO(fmt, ...) do {if (MESH_LOG_LEVEL >= LOG_LEVEL_INFO) esp_log_write(ESP_LOG_ERROR, MESH_TRACE_TAG, LOG_FORMAT(I, format), esp_log_timestamp(), "BT_LOG", ##__VA_ARGS__);} while(0)
#define NET_BUF_SIMPLE_ASSERT(cond) assert(cond != NULL)
#else /* CONFIG_NET_BUF_SIMPLE_LOG */
#define NET_BUF_SIMPLE_DBG(fmt, ...)
#define NET_BUF_SIMPLE_ERR(fmt, ...)
#define NET_BUF_SIMPLE_WARN(fmt, ...)
#define NET_BUF_SIMPLE_INFO(fmt, ...)
#if defined(CONFIG_BLE_MESH_NET_BUF_SIMPLE_LOG) && (!CONFIG_BLE_MESH_NO_LOG)
#define NET_BUF_SIMPLE_ERR(fmt, args...) do {if ((NET_BUF_LOG_LEVEL >= LOG_LEVEL_ERROR) && BLE_MESH_LOG_LEVEL_CHECK(NET_BUF, ERROR)) BLE_MESH_PRINT_E(MESH_TRACE_TAG, fmt, ## args);} while(0)
#define NET_BUF_SIMPLE_WARN(fmt, args...) do {if ((NET_BUF_LOG_LEVEL >= LOG_LEVEL_WARN) && BLE_MESH_LOG_LEVEL_CHECK(NET_BUF, WARN)) BLE_MESH_PRINT_W(MESH_TRACE_TAG, fmt, ## args);} while(0)
#define NET_BUF_SIMPLE_INFO(fmt, args...) do {if ((NET_BUF_LOG_LEVEL >= LOG_LEVEL_INFO) && BLE_MESH_LOG_LEVEL_CHECK(NET_BUF, INFO)) BLE_MESH_PRINT_I(MESH_TRACE_TAG, fmt, ## args);} while(0)
#define NET_BUF_SIMPLE_DBG(fmt, args...) do {if ((NET_BUF_LOG_LEVEL >= LOG_LEVEL_DEBUG) && BLE_MESH_LOG_LEVEL_CHECK(NET_BUF, DEBUG)) BLE_MESH_PRINT_D(MESH_TRACE_TAG, fmt, ## args);} while(0)
#define NET_BUF_SIMPLE_ASSERT(cond) __ASSERT_NO_MSG(cond)
#else
#define NET_BUF_SIMPLE_ERR(fmt, args...)
#define NET_BUF_SIMPLE_WARN(fmt, args...)
#define NET_BUF_SIMPLE_INFO(fmt, args...)
#define NET_BUF_SIMPLE_DBG(fmt, args...)
#define NET_BUF_SIMPLE_ASSERT(cond)
#endif
#endif /* CONFIG_NET_BUF_SIMPLE_LOG */
#define printk ets_printf
#endif /* _BLE_MESH_TRACE_H_ */

View File

@@ -5,10 +5,11 @@
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __Z_TYPES_H__
#define __Z_TYPES_H__
#ifndef _BLE_MESH_TYPES_H_
#define _BLE_MESH_TYPES_H_
#include <stdint.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
@@ -24,17 +25,22 @@ typedef unsigned short u16_t;
typedef unsigned int u32_t;
typedef unsigned long long u64_t;
typedef int atomic_t;
typedef int bt_mesh_atomic_t;
#ifndef bool
#define bool int8_t
#define false 0 ///< XOS definition of 'false'
#define true 1 ///< XOS definition of 'true'
#endif
#ifndef false
#define false 0
#endif
#ifndef true
#define true 1
#endif
#ifdef __cplusplus
}
#endif
#endif /* __Z_TYPES_H__ */
#endif /* _BLE_MESH_TYPES_H_ */

View File

@@ -11,20 +11,18 @@
* Misc utilities usable by the kernel and application code.
*/
#ifndef _UTIL__H_
#define _UTIL__H_
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _ASMLANGUAGE
#ifndef _BLE_MESH_UTIL_H_
#define _BLE_MESH_UTIL_H_
#include <stddef.h>
#include "mesh_types.h"
#include "mesh_trace.h"
#include "soc/soc.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Helper to pass a int as a pointer or vice-versa.
* Those are available for 32 bits architectures:
*/
@@ -39,15 +37,15 @@ extern "C" {
/* Evaluates to 0 if array is an array; compile error if not array (e.g.
* pointer)
*/
#define IS_ARRAY(array) \
ZERO_OR_COMPILE_ERROR( \
!__builtin_types_compatible_p(__typeof__(array), \
#define IS_ARRAY(array) \
ZERO_OR_COMPILE_ERROR( \
!__builtin_types_compatible_p(__typeof__(array), \
__typeof__(&(array)[0])))
/* Evaluates to number of elements in an array; compile error if not
* an array (e.g. pointer)
*/
#define ARRAY_SIZE(array) \
#define ARRAY_SIZE(array) \
((unsigned long) (IS_ARRAY(array) + \
(sizeof(array) / sizeof((array)[0]))))
@@ -61,8 +59,8 @@ extern "C" {
((type *)(((char *)(ptr)) - offsetof(type, field)))
/* round "x" up/down to next multiple of "align" (which must be a power of 2) */
#define ROUND_UP(x, align) \
(((unsigned long)(x) + ((unsigned long)align - 1)) & \
#define ROUND_UP(x, align) \
(((unsigned long)(x) + ((unsigned long)align - 1)) & \
~((unsigned long)align - 1))
#define ROUND_DOWN(x, align) ((unsigned long)(x) & ~((unsigned long)align - 1))
@@ -70,19 +68,27 @@ extern "C" {
(((numerator) + ((divider) - 1)) / (divider))
/* Internal helpers only used by the sys_* APIs further below */
#ifndef __bswap_16
#define __bswap_16(x) ((u16_t) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8)))
#define __bswap_32(x) ((u32_t) ((((x) >> 24) & 0xff) | \
(((x) >> 8) & 0xff00) | \
(((x) & 0xff00) << 8) | \
#endif
#ifndef __bswap_32
#define __bswap_32(x) ((u32_t) ((((x) >> 24) & 0xff) | \
(((x) >> 8) & 0xff00) | \
(((x) & 0xff00) << 8) | \
(((x) & 0xff) << 24)))
#define __bswap_64(x) ((u64_t) ((((x) >> 56) & 0xff) | \
(((x) >> 40) & 0xff00) | \
(((x) >> 24) & 0xff0000) | \
(((x) >> 8) & 0xff000000) | \
(((x) & 0xff000000) << 8) | \
(((x) & 0xff0000) << 24) | \
(((x) & 0xff00) << 40) | \
#endif
#ifndef __bswap_64
#define __bswap_64(x) ((u64_t) ((((x) >> 56) & 0xff) | \
(((x) >> 40) & 0xff00) | \
(((x) >> 24) & 0xff0000) | \
(((x) >> 8) & 0xff000000) | \
(((x) & 0xff000000) << 8) | \
(((x) & 0xff0000) << 24) | \
(((x) & 0xff00) << 40) | \
(((x) & 0xff) << 56)))
#endif
#define sys_le16_to_cpu(val) (val)
#define sys_cpu_to_le16(val) (val)
@@ -97,63 +103,21 @@ extern "C" {
#define sys_be64_to_cpu(val) __bswap_64(val)
#define sys_cpu_to_be64(val) __bswap_64(val)
#ifdef INLINED
#define INLINE inline
#else
#define INLINE
#ifndef MAX
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#endif
#define NOINIT
#ifndef max
#define max(a, b) (((a) > (b)) ? (a) : (b))
#ifndef MIN
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#endif
#ifndef min
#define min(a, b) (((a) < (b)) ? (a) : (b))
#endif
static inline int is_power_of_two(unsigned int x)
{
return (x != 0) && !(x & (x - 1));
}
static inline s64_t arithmetic_shift_right(s64_t value, u8_t shift)
{
s64_t sign_ext;
if (shift == 0) {
return value;
}
/* extract sign bit */
sign_ext = (value >> 63) & 1;
/* make all bits of sign_ext be the same as the value's sign bit */
sign_ext = -sign_ext;
/* shift value and fill opened bit positions with sign bit */
return (value >> shift) | (sign_ext << (64 - shift));
}
#endif /* !_ASMLANGUAGE */
/* KB, MB, GB */
#define KB(x) ((x) << 10)
#define MB(x) (KB(x) << 10)
#define GB(x) (MB(x) << 10)
/* KHZ, MHZ */
#define KHZ(x) ((x) * 1000)
#define MHZ(x) (KHZ(x) * 1000)
#ifndef BIT
#define BIT(n) (1UL << (n))
#define BIT(n) (1UL << (n))
#endif
#ifndef BIT_MASK
#define BIT_MASK(n) (BIT(n) - 1)
#endif
/**
* @brief Check for macro definition in compiler-visible expressions
@@ -207,126 +171,14 @@ static inline s64_t arithmetic_shift_right(s64_t value, u8_t shift)
*/
#define _IS_ENABLED3(ignore_this, val, ...) val
/**
* Macros for doing code-generation with the preprocessor.
*
* Generally it is better to generate code with the preprocessor than
* to copy-paste code or to generate code with the build system /
* python script's etc.
*
* http://stackoverflow.com/a/12540675
*/
#define UTIL_EMPTY(...)
#define UTIL_DEFER(...) __VA_ARGS__ UTIL_EMPTY()
#define UTIL_OBSTRUCT(...) __VA_ARGS__ UTIL_DEFER(UTIL_EMPTY)()
#define UTIL_EXPAND(...) __VA_ARGS__
#define UTIL_EVAL(...) UTIL_EVAL1(UTIL_EVAL1(UTIL_EVAL1(__VA_ARGS__)))
#define UTIL_EVAL1(...) UTIL_EVAL2(UTIL_EVAL2(UTIL_EVAL2(__VA_ARGS__)))
#define UTIL_EVAL2(...) UTIL_EVAL3(UTIL_EVAL3(UTIL_EVAL3(__VA_ARGS__)))
#define UTIL_EVAL3(...) UTIL_EVAL4(UTIL_EVAL4(UTIL_EVAL4(__VA_ARGS__)))
#define UTIL_EVAL4(...) UTIL_EVAL5(UTIL_EVAL5(UTIL_EVAL5(__VA_ARGS__)))
#define UTIL_EVAL5(...) __VA_ARGS__
#define UTIL_CAT(a, ...) UTIL_PRIMITIVE_CAT(a, __VA_ARGS__)
#define UTIL_PRIMITIVE_CAT(a, ...) a##__VA_ARGS__
#define UTIL_INC(x) UTIL_PRIMITIVE_CAT(UTIL_INC_, x)
#define UTIL_INC_0 1
#define UTIL_INC_1 2
#define UTIL_INC_2 3
#define UTIL_INC_3 4
#define UTIL_INC_4 5
#define UTIL_INC_5 6
#define UTIL_INC_6 7
#define UTIL_INC_7 8
#define UTIL_INC_8 9
#define UTIL_INC_9 10
#define UTIL_INC_10 11
#define UTIL_INC_11 12
#define UTIL_INC_12 13
#define UTIL_INC_13 14
#define UTIL_INC_14 15
#define UTIL_INC_15 16
#define UTIL_INC_16 17
#define UTIL_INC_17 18
#define UTIL_INC_18 19
#define UTIL_INC_19 19
#define UTIL_DEC(x) UTIL_PRIMITIVE_CAT(UTIL_DEC_, x)
#define UTIL_DEC_0 0
#define UTIL_DEC_1 0
#define UTIL_DEC_2 1
#define UTIL_DEC_3 2
#define UTIL_DEC_4 3
#define UTIL_DEC_5 4
#define UTIL_DEC_6 5
#define UTIL_DEC_7 6
#define UTIL_DEC_8 7
#define UTIL_DEC_9 8
#define UTIL_DEC_10 9
#define UTIL_DEC_11 10
#define UTIL_DEC_12 11
#define UTIL_DEC_13 12
#define UTIL_DEC_14 13
#define UTIL_DEC_15 14
#define UTIL_DEC_16 15
#define UTIL_DEC_17 16
#define UTIL_DEC_18 17
#define UTIL_DEC_19 18
#define UTIL_CHECK_N(x, n, ...) n
#define UTIL_CHECK(...) UTIL_CHECK_N(__VA_ARGS__, 0,)
#define UTIL_NOT(x) UTIL_CHECK(UTIL_PRIMITIVE_CAT(UTIL_NOT_, x))
#define UTIL_NOT_0 ~, 1,
#define UTIL_COMPL(b) UTIL_PRIMITIVE_CAT(UTIL_COMPL_, b)
#define UTIL_COMPL_0 1
#define UTIL_COMPL_1 0
#define UTIL_BOOL(x) UTIL_COMPL(UTIL_NOT(x))
#define UTIL_IIF(c) UTIL_PRIMITIVE_CAT(UTIL_IIF_, c)
#define UTIL_IIF_0(t, ...) __VA_ARGS__
#define UTIL_IIF_1(t, ...) t
#define UTIL_IF(c) UTIL_IIF(UTIL_BOOL(c))
#define UTIL_EAT(...)
#define UTIL_EXPAND(...) __VA_ARGS__
#define UTIL_WHEN(c) UTIL_IF(c)(UTIL_EXPAND, UTIL_EAT)
#define UTIL_REPEAT(count, macro, ...) \
UTIL_WHEN(count) \
( \
UTIL_OBSTRUCT(UTIL_REPEAT_INDIRECT) () \
( \
UTIL_DEC(count), macro, __VA_ARGS__ \
) \
UTIL_OBSTRUCT(macro) \
( \
UTIL_DEC(count), __VA_ARGS__ \
) \
)
#define UTIL_REPEAT_INDIRECT() UTIL_REPEAT
#define _STRINGIFY(x) #x
#define STRINGIFY(s) _STRINGIFY(s)
/* ESP Toolchain doesn't support section */
#define ___in_section(a, b, c)
#define __in_section(a, b, c) ___in_section(a, b, c)
#define __in_section_unique(seg) ___in_section(seg, __FILE__, __COUNTER__)
/* ESP Toolchain doesn't support section */
#define __noinit
#define popcount(x) __builtin_popcount(x)
/**
*
* @brief find most significant bit set in a 32-bit word
@@ -368,45 +220,6 @@ static inline unsigned int find_lsb_set(u32_t op)
}
#endif
#define __ASSERT(test, fmt, ...) \
do { \
if (!(test)) { \
printk("ASSERTION FAIL [%s] @ %s:%d:\n\t", \
_STRINGIFY(test), \
__FILE__, \
__LINE__); \
printk(fmt, ##__VA_ARGS__); \
for (;;) \
; /* spin thread */ \
} \
} while ((0))
/**
* Generates a sequence of code.
* Useful for generating code like;
*
* NRF_PWM0, NRF_PWM1, NRF_PWM2,
*
* @arg LEN: The length of the sequence. Must be defined and less than
* 20.
*
* @arg F(i, F_ARG): A macro function that accepts two arguments.
* F is called repeatedly, the first argument
* is the index in the sequence, and the second argument is the third
* argument given to UTIL_LISTIFY.
*
* Example:
*
* \#define FOO(i, _) NRF_PWM ## i ,
* { UTIL_LISTIFY(PWM_COUNT, FOO) }
* // The above two lines will generate the below:
* { NRF_PWM0 , NRF_PWM1 , }
*
* @note Calling UTIL_LISTIFY with undefined arguments has undefined
* behaviour.
*/
#define UTIL_LISTIFY(LEN, F, F_ARG) UTIL_EVAL(UTIL_REPEAT(LEN, F, F_ARG))
/**
* @brief Put a 16-bit integer as big-endian to arbitrary location.
*
@@ -557,7 +370,6 @@ static inline u64_t sys_get_le64(const u8_t src[8])
return ((u64_t)sys_get_le32(&src[4]) << 32) | sys_get_le32(&src[0]);
}
const char *bt_hex(const void *buf, size_t len);
void mem_rcopy(u8_t *dst, u8_t const *src, u16_t len);
@@ -621,9 +433,8 @@ static inline void sys_mem_swap(void *buf, size_t length)
}
}
#ifdef __cplusplus
}
#endif
#endif /* _UTIL__H_ */
#endif /* _BLE_MESH_UTIL_H_ */

View File

@@ -0,0 +1,530 @@
/** @file
* @brief Bluetooth UUID handling
*/
/*
* Copyright (c) 2015-2016 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _BLE_MESH_UUID_H_
#define _BLE_MESH_UUID_H_
/**
* @brief UUIDs
* @defgroup bt_uuid UUIDs
* @ingroup bluetooth
* @{
*/
#include "mesh_util.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @brief Bluetooth UUID types */
enum {
BLE_MESH_UUID_TYPE_16,
BLE_MESH_UUID_TYPE_32,
BLE_MESH_UUID_TYPE_128,
};
/** @brief This is a 'tentative' type and should be used as a pointer only */
struct bt_mesh_uuid {
u8_t type;
};
struct bt_mesh_uuid_16 {
struct bt_mesh_uuid uuid;
u16_t val;
};
struct bt_mesh_uuid_32 {
struct bt_mesh_uuid uuid;
u32_t val;
};
struct bt_mesh_uuid_128 {
struct bt_mesh_uuid uuid;
u8_t val[16];
};
#define BLE_MESH_UUID_INIT_16(value) \
{ \
.uuid.type = BLE_MESH_UUID_TYPE_16, \
.val = (value), \
}
#define BLE_MESH_UUID_INIT_32(value) \
{ \
.uuid.type = BLE_MESH_UUID_TYPE_32, \
.val = (value), \
}
#define BLE_MESH_UUID_INIT_128(value...) \
{ \
.uuid.type = BLE_MESH_UUID_TYPE_128, \
.val = { value }, \
}
#define BLE_MESH_UUID_DECLARE_16(value) \
((struct bt_mesh_uuid *) (&(struct bt_mesh_uuid_16) BLE_MESH_UUID_INIT_16(value)))
#define BLE_MESH_UUID_DECLARE_32(value) \
((struct bt_mesh_uuid *) (&(struct bt_mesh_uuid_32) BLE_MESH_UUID_INIT_32(value)))
#define BLE_MESH_UUID_DECLARE_128(value...) \
((struct bt_mesh_uuid *) (&(struct bt_mesh_uuid_128) BLE_MESH_UUID_INIT_128(value)))
#define BLE_MESH_UUID_16(__u) CONTAINER_OF(__u, struct bt_mesh_uuid_16, uuid)
#define BLE_MESH_UUID_32(__u) CONTAINER_OF(__u, struct bt_mesh_uuid_32, uuid)
#define BLE_MESH_UUID_128(__u) CONTAINER_OF(__u, struct bt_mesh_uuid_128, uuid)
/** @def BLE_MESH_UUID_GAP
* @brief Generic Access
*/
#define BLE_MESH_UUID_GAP BLE_MESH_UUID_DECLARE_16(0x1800)
#define BLE_MESH_UUID_GAP_VAL 0x1800
/** @def BLE_MESH_UUID_GATT
* @brief Generic Attribute
*/
#define BLE_MESH_UUID_GATT BLE_MESH_UUID_DECLARE_16(0x1801)
#define BLE_MESH_UUID_GATT_VAL 0x1801
/** @def BLE_MESH_UUID_CTS
* @brief Current Time Service
*/
#define BLE_MESH_UUID_CTS BLE_MESH_UUID_DECLARE_16(0x1805)
#define BLE_MESH_UUID_CTS_VAL 0x1805
/** @def BLE_MESH_UUID_DIS
* @brief Device Information Service
*/
#define BLE_MESH_UUID_DIS BLE_MESH_UUID_DECLARE_16(0x180a)
#define BLE_MESH_UUID_DIS_VAL 0x180a
/** @def BLE_MESH_UUID_HRS
* @brief Heart Rate Service
*/
#define BLE_MESH_UUID_HRS BLE_MESH_UUID_DECLARE_16(0x180d)
#define BLE_MESH_UUID_HRS_VAL 0x180d
/** @def BLE_MESH_UUID_BAS
* @brief Battery Service
*/
#define BLE_MESH_UUID_BAS BLE_MESH_UUID_DECLARE_16(0x180f)
#define BLE_MESH_UUID_BAS_VAL 0x180f
/** @def BLE_MESH_UUID_HIDS
* @brief HID Service
*/
#define BLE_MESH_UUID_HIDS BLE_MESH_UUID_DECLARE_16(0x1812)
#define BLE_MESH_UUID_HIDS_VAL 0x1812
/** @def BLE_MESH_UUID_CSC
* @brief Cycling Speed and Cadence Service
*/
#define BLE_MESH_UUID_CSC BLE_MESH_UUID_DECLARE_16(0x1816)
#define BLE_MESH_UUID_CSC_VAL 0x1816
/** @def BLE_MESH_UUID_ESS
* @brief Environmental Sensing Service
*/
#define BLE_MESH_UUID_ESS BLE_MESH_UUID_DECLARE_16(0x181a)
#define BLE_MESH_UUID_ESS_VAL 0x181a
/** @def BLE_MESH_UUID_IPSS
* @brief IP Support Service
*/
#define BLE_MESH_UUID_IPSS BLE_MESH_UUID_DECLARE_16(0x1820)
#define BLE_MESH_UUID_IPSS_VAL 0x1820
/** @def BLE_MESH_UUID_MESH_PROV
* @brief Mesh Provisioning Service
*/
#define BLE_MESH_UUID_MESH_PROV BLE_MESH_UUID_DECLARE_16(0x1827)
#define BLE_MESH_UUID_MESH_PROV_VAL 0x1827
/** @def BLE_MESH_UUID_MESH_PROXY
* @brief Mesh Proxy Service
*/
#define BLE_MESH_UUID_MESH_PROXY BLE_MESH_UUID_DECLARE_16(0x1828)
#define BLE_MESH_UUID_MESH_PROXY_VAL 0x1828
/** @def BLE_MESH_UUID_GATT_PRIMARY
* @brief GATT Primary Service
*/
#define BLE_MESH_UUID_GATT_PRIMARY BLE_MESH_UUID_DECLARE_16(0x2800)
#define BLE_MESH_UUID_GATT_PRIMARY_VAL 0x2800
/** @def BLE_MESH_UUID_GATT_SECONDARY
* @brief GATT Secondary Service
*/
#define BLE_MESH_UUID_GATT_SECONDARY BLE_MESH_UUID_DECLARE_16(0x2801)
#define BLE_MESH_UUID_GATT_SECONDARY_VAL 0x2801
/** @def BLE_MESH_UUID_GATT_INCLUDE
* @brief GATT Include Service
*/
#define BLE_MESH_UUID_GATT_INCLUDE BLE_MESH_UUID_DECLARE_16(0x2802)
#define BLE_MESH_UUID_GATT_INCLUDE_VAL 0x2802
/** @def BLE_MESH_UUID_GATT_CHRC
* @brief GATT Characteristic
*/
#define BLE_MESH_UUID_GATT_CHRC BLE_MESH_UUID_DECLARE_16(0x2803)
#define BLE_MESH_UUID_GATT_CHRC_VAL 0x2803
/** @def BLE_MESH_UUID_GATT_CEP
* @brief GATT Characteristic Extended Properties
*/
#define BLE_MESH_UUID_GATT_CEP BLE_MESH_UUID_DECLARE_16(0x2900)
#define BLE_MESH_UUID_GATT_CEP_VAL 0x2900
/** @def BLE_MESH_UUID_GATT_CUD
* @brief GATT Characteristic User Description
*/
#define BLE_MESH_UUID_GATT_CUD BLE_MESH_UUID_DECLARE_16(0x2901)
#define BLE_MESH_UUID_GATT_CUD_VAL 0x2901
/** @def BLE_MESH_UUID_GATT_CCC
* @brief GATT Client Characteristic Configuration
*/
#define BLE_MESH_UUID_GATT_CCC BLE_MESH_UUID_DECLARE_16(0x2902)
#define BLE_MESH_UUID_GATT_CCC_VAL 0x2902
/** @def BLE_MESH_UUID_GATT_SCC
* @brief GATT Server Characteristic Configuration
*/
#define BLE_MESH_UUID_GATT_SCC BLE_MESH_UUID_DECLARE_16(0x2903)
#define BLE_MESH_UUID_GATT_SCC_VAL 0x2903
/** @def BLE_MESH_UUID_GATT_CPF
* @brief GATT Characteristic Presentation Format
*/
#define BLE_MESH_UUID_GATT_CPF BLE_MESH_UUID_DECLARE_16(0x2904)
#define BLE_MESH_UUID_GATT_CPF_VAL 0x2904
/** @def BLE_MESH_UUID_VALID_RANGE
* @brief Valid Range Descriptor
*/
#define BLE_MESH_UUID_VALID_RANGE BLE_MESH_UUID_DECLARE_16(0x2906)
#define BLE_MESH_UUID_VALID_RANGE_VAL 0x2906
/** @def BLE_MESH_UUID_HIDS_EXT_REPORT
* @brief HID External Report Descriptor
*/
#define BLE_MESH_UUID_HIDS_EXT_REPORT BLE_MESH_UUID_DECLARE_16(0x2907)
#define BLE_MESH_UUID_HIDS_EXT_REPORT_VAL 0x2907
/** @def BLE_MESH_UUID_HIDS_REPORT_REF
* @brief HID Report Reference Descriptor
*/
#define BLE_MESH_UUID_HIDS_REPORT_REF BLE_MESH_UUID_DECLARE_16(0x2908)
#define BLE_MESH_UUID_HIDS_REPORT_REF_VAL 0x2908
/** @def BLE_MESH_UUID_ES_CONFIGURATION
* @brief Environmental Sensing Configuration Descriptor
*/
#define BLE_MESH_UUID_ES_CONFIGURATION BLE_MESH_UUID_DECLARE_16(0x290b)
#define BLE_MESH_UUID_ES_CONFIGURATION_VAL 0x290b
/** @def BLE_MESH_UUID_ES_MEASUREMENT
* @brief Environmental Sensing Measurement Descriptor
*/
#define BLE_MESH_UUID_ES_MEASUREMENT BLE_MESH_UUID_DECLARE_16(0x290c)
#define BLE_MESH_UUID_ES_MEASUREMENT_VAL 0x290c
/** @def BLE_MESH_UUID_ES_TRIGGER_SETTING
* @brief Environmental Sensing Trigger Setting Descriptor
*/
#define BLE_MESH_UUID_ES_TRIGGER_SETTING BLE_MESH_UUID_DECLARE_16(0x290d)
#define BLE_MESH_UUID_ES_TRIGGER_SETTING_VAL 0x290d
/** @def BLE_MESH_UUID_GAP_DEVICE_NAME
* @brief GAP Characteristic Device Name
*/
#define BLE_MESH_UUID_GAP_DEVICE_NAME BLE_MESH_UUID_DECLARE_16(0x2a00)
#define BLE_MESH_UUID_GAP_DEVICE_NAME_VAL 0x2a00
/** @def BLE_MESH_UUID_GAP_APPEARANCE
* @brief GAP Characteristic Appearance
*/
#define BLE_MESH_UUID_GAP_APPEARANCE BLE_MESH_UUID_DECLARE_16(0x2a01)
#define BLE_MESH_UUID_GAP_APPEARANCE_VAL 0x2a01
/** @def BLE_MESH_UUID_GAP_PPCP
* @brief GAP Characteristic Peripheral Preferred Connection Parameters
*/
#define BLE_MESH_UUID_GAP_PPCP BLE_MESH_UUID_DECLARE_16(0x2a04)
#define BLE_MESH_UUID_GAP_PPCP_VAL 0x2a04
/** @def BLE_MESH_UUID_GATT_SC
* @brief GATT Characteristic Service Changed
*/
#define BLE_MESH_UUID_GATT_SC BLE_MESH_UUID_DECLARE_16(0x2a05)
#define BLE_MESH_UUID_GATT_SC_VAL 0x2a05
/** @def BLE_MESH_UUID_BAS_BATTERY_LEVEL
* @brief BAS Characteristic Battery Level
*/
#define BLE_MESH_UUID_BAS_BATTERY_LEVEL BLE_MESH_UUID_DECLARE_16(0x2a19)
#define BLE_MESH_UUID_BAS_BATTERY_LEVEL_VAL 0x2a19
/** @def BLE_MESH_UUID_DIS_SYSTEM_ID
* @brief DIS Characteristic System ID
*/
#define BLE_MESH_UUID_DIS_SYSTEM_ID BLE_MESH_UUID_DECLARE_16(0x2a23)
#define BLE_MESH_UUID_DIS_SYSTEM_ID_VAL 0x2a23
/** @def BLE_MESH_UUID_DIS_MODEL_NUMBER
* @brief DIS Characteristic Model Number String
*/
#define BLE_MESH_UUID_DIS_MODEL_NUMBER BLE_MESH_UUID_DECLARE_16(0x2a24)
#define BLE_MESH_UUID_DIS_MODEL_NUMBER_VAL 0x2a24
/** @def BLE_MESH_UUID_DIS_SERIAL_NUMBER
* @brief DIS Characteristic Serial Number String
*/
#define BLE_MESH_UUID_DIS_SERIAL_NUMBER BLE_MESH_UUID_DECLARE_16(0x2a25)
#define BLE_MESH_UUID_DIS_SERIAL_NUMBER_VAL 0x2a25
/** @def BLE_MESH_UUID_DIS_FIRMWARE_REVISION
* @brief DIS Characteristic Firmware Revision String
*/
#define BLE_MESH_UUID_DIS_FIRMWARE_REVISION BLE_MESH_UUID_DECLARE_16(0x2a26)
#define BLE_MESH_UUID_DIS_FIRMWARE_REVISION_VAL 0x2a26
/** @def BLE_MESH_UUID_DIS_HARDWARE_REVISION
* @brief DIS Characteristic Hardware Revision String
*/
#define BLE_MESH_UUID_DIS_HARDWARE_REVISION BLE_MESH_UUID_DECLARE_16(0x2a27)
#define BLE_MESH_UUID_DIS_HARDWARE_REVISION_VAL 0x2a27
/** @def BLE_MESH_UUID_DIS_SOFTWARE_REVISION
* @brief DIS Characteristic Software Revision String
*/
#define BLE_MESH_UUID_DIS_SOFTWARE_REVISION BLE_MESH_UUID_DECLARE_16(0x2a28)
#define BLE_MESH_UUID_DIS_SOFTWARE_REVISION_VAL 0x2a28
/** @def BLE_MESH_UUID_DIS_MANUFACTURER_NAME
* @brief DIS Characteristic Manufacturer Name String
*/
#define BLE_MESH_UUID_DIS_MANUFACTURER_NAME BLE_MESH_UUID_DECLARE_16(0x2a29)
#define BLE_MESH_UUID_DIS_MANUFACTURER_NAME_VAL 0x2a29
/** @def BLE_MESH_UUID_DIS_PNP_ID
* @brief DIS Characteristic PnP ID
*/
#define BLE_MESH_UUID_DIS_PNP_ID BLE_MESH_UUID_DECLARE_16(0x2a50)
#define BLE_MESH_UUID_DIS_PNP_ID_VAL 0x2a50
/** @def BLE_MESH_UUID_CTS_CURRENT_TIME
* @brief CTS Characteristic Current Time
*/
#define BLE_MESH_UUID_CTS_CURRENT_TIME BLE_MESH_UUID_DECLARE_16(0x2a2b)
#define BLE_MESH_UUID_CTS_CURRENT_TIME_VAL 0x2a2b
/** @def BLE_MESH_UUID_MAGN_DECLINATION
* @brief Magnetic Declination Characteristic
*/
#define BLE_MESH_UUID_MAGN_DECLINATION BLE_MESH_UUID_DECLARE_16(0x2a2c)
#define BLE_MESH_UUID_MAGN_DECLINATION_VAL 0x2a2c
/** @def BLE_MESH_UUID_HRS_MEASUREMENT
* @brief HRS Characteristic Measurement Interval
*/
#define BLE_MESH_UUID_HRS_MEASUREMENT BLE_MESH_UUID_DECLARE_16(0x2a37)
#define BLE_MESH_UUID_HRS_MEASUREMENT_VAL 0x2a37
/** @def BLE_MESH_UUID_HRS_BODY_SENSOR
* @brief HRS Characteristic Body Sensor Location
*/
#define BLE_MESH_UUID_HRS_BODY_SENSOR BLE_MESH_UUID_DECLARE_16(0x2a38)
#define BLE_MESH_UUID_HRS_BODY_SENSOR_VAL 0x2a38
/** @def BLE_MESH_UUID_HRS_CONTROL_POINT
* @brief HRS Characteristic Control Point
*/
#define BLE_MESH_UUID_HRS_CONTROL_POINT BLE_MESH_UUID_DECLARE_16(0x2a39)
#define BLE_MESH_UUID_HRS_CONTROL_POINT_VAL 0x2a39
/** @def BLE_MESH_UUID_HIDS_INFO
* @brief HID Information Characteristic
*/
#define BLE_MESH_UUID_HIDS_INFO BLE_MESH_UUID_DECLARE_16(0x2a4a)
#define BLE_MESH_UUID_HIDS_INFO_VAL 0x2a4a
/** @def BLE_MESH_UUID_HIDS_REPORT_MAP
* @brief HID Report Map Characteristic
*/
#define BLE_MESH_UUID_HIDS_REPORT_MAP BLE_MESH_UUID_DECLARE_16(0x2a4b)
#define BLE_MESH_UUID_HIDS_REPORT_MAP_VAL 0x2a4b
/** @def BLE_MESH_UUID_HIDS_CTRL_POINT
* @brief HID Control Point Characteristic
*/
#define BLE_MESH_UUID_HIDS_CTRL_POINT BLE_MESH_UUID_DECLARE_16(0x2a4c)
#define BLE_MESH_UUID_HIDS_CTRL_POINT_VAL 0x2a4c
/** @def BLE_MESH_UUID_HIDS_REPORT
* @brief HID Report Characteristic
*/
#define BLE_MESH_UUID_HIDS_REPORT BLE_MESH_UUID_DECLARE_16(0x2a4d)
#define BLE_MESH_UUID_HIDS_REPORT_VAL 0x2a4d
/** @def BLE_MESH_UUID_CSC_MEASUREMENT
* @brief CSC Measurement Characteristic
*/
#define BLE_MESH_UUID_CSC_MEASUREMENT BLE_MESH_UUID_DECLARE_16(0x2a5b)
#define BLE_MESH_UUID_CSC_MEASUREMENT_VAL 0x2a5b
/** @def BLE_MESH_UUID_CSC_FEATURE
* @brief CSC Feature Characteristic
*/
#define BLE_MESH_UUID_CSC_FEATURE BLE_MESH_UUID_DECLARE_16(0x2a5c)
#define BLE_MESH_UUID_CSC_FEATURE_VAL 0x2a5c
/** @def BLE_MESH_UUID_SENSOR_LOCATION
* @brief Sensor Location Characteristic
*/
#define BLE_MESH_UUID_SENSOR_LOCATION BLE_MESH_UUID_DECLARE_16(0x2a5d)
#define BLE_MESH_UUID_SENSOR_LOCATION_VAL 0x2a5d
/** @def BLE_MESH_UUID_SC_CONTROL_POINT
* @brief SC Control Point Characteristic
*/
#define BLE_MESH_UUID_SC_CONTROL_POINT BLE_MESH_UUID_DECLARE_16(0x2a55)
#define BLE_MESH_UUID_SC_CONTROL_POINT_VAl 0x2a55
/** @def BLE_MESH_UUID_ELEVATION
* @brief Elevation Characteristic
*/
#define BLE_MESH_UUID_ELEVATION BLE_MESH_UUID_DECLARE_16(0x2a6c)
#define BLE_MESH_UUID_ELEVATION_VAL 0x2a6c
/** @def BLE_MESH_UUID_PRESSURE
* @brief Pressure Characteristic
*/
#define BLE_MESH_UUID_PRESSURE BLE_MESH_UUID_DECLARE_16(0x2a6d)
#define BLE_MESH_UUID_PRESSURE_VAL 0x2a6d
/** @def BLE_MESH_UUID_TEMPERATURE
* @brief Temperature Characteristic
*/
#define BLE_MESH_UUID_TEMPERATURE BLE_MESH_UUID_DECLARE_16(0x2a6e)
#define BLE_MESH_UUID_TEMPERATURE_VAL 0x2a6e
/** @def BLE_MESH_UUID_HUMIDITY
* @brief Humidity Characteristic
*/
#define BLE_MESH_UUID_HUMIDITY BLE_MESH_UUID_DECLARE_16(0x2a6f)
#define BLE_MESH_UUID_HUMIDITY_VAL 0x2a6f
/** @def BLE_MESH_UUID_TRUE_WIND_SPEED
* @brief True Wind Speed Characteristic
*/
#define BLE_MESH_UUID_TRUE_WIND_SPEED BLE_MESH_UUID_DECLARE_16(0x2a70)
#define BLE_MESH_UUID_TRUE_WIND_SPEED_VAL 0x2a70
/** @def BLE_MESH_UUID_TRUE_WIND_DIR
* @brief True Wind Direction Characteristic
*/
#define BLE_MESH_UUID_TRUE_WIND_DIR BLE_MESH_UUID_DECLARE_16(0x2a71)
#define BLE_MESH_UUID_TRUE_WIND_DIR_VAL 0x2a71
/** @def BLE_MESH_UUID_APPARENT_WIND_SPEED
* @brief Apparent Wind Speed Characteristic
*/
#define BLE_MESH_UUID_APPARENT_WIND_SPEED BLE_MESH_UUID_DECLARE_16(0x2a72)
#define BLE_MESH_UUID_APPARENT_WIND_SPEED_VAL 0x2a72
/** @def BLE_MESH_UUID_APPARENT_WIND_DIR
* @brief Apparent Wind Direction Characteristic
*/
#define BLE_MESH_UUID_APPARENT_WIND_DIR BLE_MESH_UUID_DECLARE_16(0x2a73)
#define BLE_MESH_UUID_APPARENT_WIND_DIR_VAL 0x2a73
/** @def BLE_MESH_UUID_GUST_FACTOR
* @brief Gust Factor Characteristic
*/
#define BLE_MESH_UUID_GUST_FACTOR BLE_MESH_UUID_DECLARE_16(0x2a74)
#define BLE_MESH_UUID_GUST_FACTOR_VAL 0x2a74
/** @def BLE_MESH_UUID_POLLEN_CONCENTRATION
* @brief Pollen Concentration Characteristic
*/
#define BLE_MESH_UUID_POLLEN_CONCENTRATION BLE_MESH_UUID_DECLARE_16(0x2a75)
#define BLE_MESH_UUID_POLLEN_CONCENTRATION_VAL 0x2a75
/** @def BLE_MESH_UUID_UV_INDEX
* @brief UV Index Characteristic
*/
#define BLE_MESH_UUID_UV_INDEX BLE_MESH_UUID_DECLARE_16(0x2a76)
#define BLE_MESH_UUID_UV_INDEX_VAL 0x2a76
/** @def BLE_MESH_UUID_IRRADIANCE
* @brief Irradiance Characteristic
*/
#define BLE_MESH_UUID_IRRADIANCE BLE_MESH_UUID_DECLARE_16(0x2a77)
#define BLE_MESH_UUID_IRRADIANCE_VAL 0x2a77
/** @def BLE_MESH_UUID_RAINFALL
* @brief Rainfall Characteristic
*/
#define BLE_MESH_UUID_RAINFALL BLE_MESH_UUID_DECLARE_16(0x2a78)
#define BLE_MESH_UUID_RAINFALL_VAL 0x2a78
/** @def BLE_MESH_UUID_WIND_CHILL
* @brief Wind Chill Characteristic
*/
#define BLE_MESH_UUID_WIND_CHILL BLE_MESH_UUID_DECLARE_16(0x2a79)
#define BLE_MESH_UUID_WIND_CHILL_VAL 0x2a79
/** @def BLE_MESH_UUID_HEAT_INDEX
* @brief Heat Index Characteristic
*/
#define BLE_MESH_UUID_HEAT_INDEX BLE_MESH_UUID_DECLARE_16(0x2a7a)
#define BLE_MESH_UUID_HEAT_INDEX_VAL 0x2a7a
/** @def BLE_MESH_UUID_DEW_POINT
* @brief Dew Point Characteristic
*/
#define BLE_MESH_UUID_DEW_POINT BLE_MESH_UUID_DECLARE_16(0x2a7b)
#define BLE_MESH_UUID_DEW_POINT_VAL 0x2a7b
/** @def BLE_MESH_UUID_DESC_VALUE_CHANGED
* @brief Descriptor Value Changed Characteristic
*/
#define BLE_MESH_UUID_DESC_VALUE_CHANGED BLE_MESH_UUID_DECLARE_16(0x2a7d)
#define BLE_MESH_UUID_DESC_VALUE_CHANGED_VAL 0x2a7d
/** @def BLE_MESH_UUID_MAGN_FLUX_DENSITY_2D
* @brief Magnetic Flux Density - 2D Characteristic
*/
#define BLE_MESH_UUID_MAGN_FLUX_DENSITY_2D BLE_MESH_UUID_DECLARE_16(0x2aa0)
#define BLE_MESH_UUID_MAGN_FLUX_DENSITY_2D_VAL 0x2aa0
/** @def BLE_MESH_UUID_MAGN_FLUX_DENSITY_3D
* @brief Magnetic Flux Density - 3D Characteristic
*/
#define BLE_MESH_UUID_MAGN_FLUX_DENSITY_3D BLE_MESH_UUID_DECLARE_16(0x2aa1)
#define BLE_MESH_UUID_MAGN_FLUX_DENSITY_3D_VAL 0x2aa1
/** @def BLE_MESH_UUID_BAR_PRESSURE_TREND
* @brief Barometric Pressure Trend Characteristic
*/
#define BLE_MESH_UUID_BAR_PRESSURE_TREND BLE_MESH_UUID_DECLARE_16(0x2aa3)
#define BLE_MESH_UUID_BAR_PRESSURE_TREND_VAL 0x2aa3
/** @def BLE_MESH_UUID_MESH_PROV_DATA_IN
* @brief Mesh Provisioning Data In
*/
#define BLE_MESH_UUID_MESH_PROV_DATA_IN BLE_MESH_UUID_DECLARE_16(0x2adb)
#define BLE_MESH_UUID_MESH_PROV_DATA_IN_VAL 0x2adb
/** @def BLE_MESH_UUID_MESH_PROV_DATA_OUT
* @brief Mesh Provisioning Data Out
*/
#define BLE_MESH_UUID_MESH_PROV_DATA_OUT BLE_MESH_UUID_DECLARE_16(0x2adc)
#define BLE_MESH_UUID_MESH_PROV_DATA_OUT_VAL 0x2adc
/** @def BLE_MESH_UUID_MESH_PROXY_DATA_IN
* @brief Mesh Proxy Data In
*/
#define BLE_MESH_UUID_MESH_PROXY_DATA_IN BLE_MESH_UUID_DECLARE_16(0x2add)
#define BLE_MESH_UUID_MESH_PROXY_DATA_IN_VAL 0x2add
/** @def BLE_MESH_UUID_MESH_PROXY_DATA_OUT
* @brief Mesh Proxy Data Out
*/
#define BLE_MESH_UUID_MESH_PROXY_DATA_OUT BLE_MESH_UUID_DECLARE_16(0x2ade)
#define BLE_MESH_UUID_MESH_PROXY_DATA_OUT_VAL 0x2ade
/*
* Protocol UUIDs
*/
#define BLE_MESH_UUID_SDP BLE_MESH_UUID_DECLARE_16(0x0001)
#define BLE_MESH_UUID_SDP_VAL 0x0001
#define BLE_MESH_UUID_UDP BLE_MESH_UUID_DECLARE_16(0x0002)
#define BLE_MESH_UUID_UDP_VAL 0x0002
#define BLE_MESH_UUID_RFCOMM BLE_MESH_UUID_DECLARE_16(0x0003)
#define BLE_MESH_UUID_RFCOMM_VAL 0x0003
#define BLE_MESH_UUID_TCP BLE_MESH_UUID_DECLARE_16(0x0004)
#define BLE_MESH_UUID_TCP_VAL 0x0004
#define BLE_MESH_UUID_TCS_BIN BLE_MESH_UUID_DECLARE_16(0x0005)
#define BLE_MESH_UUID_TCS_BIN_VAL 0x0005
#define BLE_MESH_UUID_TCS_AT BLE_MESH_UUID_DECLARE_16(0x0006)
#define BLE_MESH_UUID_TCS_AT_VAL 0x0006
#define BLE_MESH_UUID_ATT BLE_MESH_UUID_DECLARE_16(0x0007)
#define BLE_MESH_UUID_ATT_VAL 0x0007
#define BLE_MESH_UUID_OBEX BLE_MESH_UUID_DECLARE_16(0x0008)
#define BLE_MESH_UUID_OBEX_VAL 0x0008
#define BLE_MESH_UUID_IP BLE_MESH_UUID_DECLARE_16(0x0009)
#define BLE_MESH_UUID_IP_VAL 0x0009
#define BLE_MESH_UUID_FTP BLE_MESH_UUID_DECLARE_16(0x000a)
#define BLE_MESH_UUID_FTP_VAL 0x000a
#define BLE_MESH_UUID_HTTP BLE_MESH_UUID_DECLARE_16(0x000c)
#define BLE_MESH_UUID_HTTP_VAL 0x000c
#define BLE_MESH_UUID_BNEP BLE_MESH_UUID_DECLARE_16(0x000f)
#define BLE_MESH_UUID_BNEP_VAL 0x000f
#define BLE_MESH_UUID_UPNP BLE_MESH_UUID_DECLARE_16(0x0010)
#define BLE_MESH_UUID_UPNP_VAL 0x0010
#define BLE_MESH_UUID_HIDP BLE_MESH_UUID_DECLARE_16(0x0011)
#define BLE_MESH_UUID_HIDP_VAL 0x0011
#define BLE_MESH_UUID_HCRP_CTRL BLE_MESH_UUID_DECLARE_16(0x0012)
#define BLE_MESH_UUID_HCRP_CTRL_VAL 0x0012
#define BLE_MESH_UUID_HCRP_DATA BLE_MESH_UUID_DECLARE_16(0x0014)
#define BLE_MESH_UUID_HCRP_DATA_VAL 0x0014
#define BLE_MESH_UUID_HCRP_NOTE BLE_MESH_UUID_DECLARE_16(0x0016)
#define BLE_MESH_UUID_HCRP_NOTE_VAL 0x0016
#define BLE_MESH_UUID_AVCTP BLE_MESH_UUID_DECLARE_16(0x0017)
#define BLE_MESH_UUID_AVCTP_VAL 0x0017
#define BLE_MESH_UUID_AVDTP BLE_MESH_UUID_DECLARE_16(0x0019)
#define BLE_MESH_UUID_AVDTP_VAL 0x0019
#define BLE_MESH_UUID_CMTP BLE_MESH_UUID_DECLARE_16(0x001b)
#define BLE_MESH_UUID_CMTP_VAL 0x001b
#define BLE_MESH_UUID_UDI BLE_MESH_UUID_DECLARE_16(0x001d)
#define BLE_MESH_UUID_UDI_VAL 0x001d
#define BLE_MESH_UUID_MCAP_CTRL BLE_MESH_UUID_DECLARE_16(0x001e)
#define BLE_MESH_UUID_MCAP_CTRL_VAL 0x001e
#define BLE_MESH_UUID_MCAP_DATA BLE_MESH_UUID_DECLARE_16(0x001f)
#define BLE_MESH_UUID_MCAP_DATA_VAL 0x001f
#define BLE_MESH_UUID_L2CAP BLE_MESH_UUID_DECLARE_16(0x0100)
#define BLE_MESH_UUID_L2CAP_VAL 0x0100
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#endif /* _BLE_MESH_UUID_H_ */

View File

@@ -1,62 +0,0 @@
/*
* Copyright (c) 2018 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _SETTINGS_H_
#define _SETTINGS_H_
#include "sdkconfig.h"
#include "net.h"
#include "mesh_access.h"
#include "mesh_bearer_adapt.h"
struct bt_settings_handler {
const char *name;
int (*set)(int argc, char **argv, char *val);
int (*commit)(void);
int (*export)(int (*func)(const char *name, char *val));
};
#define BT_SETTINGS_DEFINE(_name, _set, _commit, _export) \
const struct bt_settings_handler _name __aligned(4) \
__in_section(_bt_settings, static, _name) = { \
.name = STRINGIFY(_name), \
.set = _set, \
.commit = _commit, \
.export = _export, \
}
/* Max settings key length (with all components) */
#define BT_SETTINGS_KEY_MAX 36
/* Base64-encoded string buffer size of in_size bytes */
#define BT_SETTINGS_SIZE(in_size) ((((((in_size) - 1) / 3) * 4) + 4) + 1)
/* Helpers for keys containing a bdaddr */
void bt_settings_encode_key(char *path, size_t path_size, const char *subsys,
bt_addr_le_t *addr, const char *key);
int bt_settings_decode_key(char *key, bt_addr_le_t *addr);
void bt_mesh_store_net(void);
void bt_mesh_store_iv(void);
void bt_mesh_store_seq(void);
void bt_mesh_store_rpl(struct bt_mesh_rpl *rpl);
void bt_mesh_store_subnet(struct bt_mesh_subnet *sub);
void bt_mesh_store_app_key(struct bt_mesh_app_key *key);
void bt_mesh_store_hb_pub(void);
void bt_mesh_store_cfg(void);
void bt_mesh_store_mod_bind(struct bt_mesh_model *mod);
void bt_mesh_store_mod_sub(struct bt_mesh_model *mod);
void bt_mesh_store_mod_pub(struct bt_mesh_model *mod);
void bt_mesh_clear_net(void);
void bt_mesh_clear_subnet(struct bt_mesh_subnet *sub);
void bt_mesh_clear_app_key(struct bt_mesh_app_key *key);
void bt_mesh_clear_rpl(void);
int bt_mesh_settings_init(void);
#endif /* _SETTINGS_H_ */

View File

@@ -9,17 +9,16 @@
#include <stdint.h>
#include <errno.h>
#include "mesh_buf.h"
#include "sdkconfig.h"
#if CONFIG_BT_MESH
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_LOW_POWER)
#include "mesh_buf.h"
#include "mesh_kernel.h"
#ifdef CONFIG_BT_MESH_LOW_POWER
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_LOW_POWER)
#include "mesh_trace.h"
#include "mesh.h"
#include "crypto.h"
#include "adv.h"
#include "mesh.h"
#include "net.h"
#include "transport.h"
#include "access.h"
@@ -27,120 +26,121 @@
#include "foundation.h"
#include "lpn.h"
#if defined(CONFIG_BT_MESH_LPN_AUTO)
#define LPN_AUTO_TIMEOUT K_SECONDS(CONFIG_BT_MESH_LPN_AUTO_TIMEOUT)
#ifdef CONFIG_BLE_MESH_LOW_POWER
#if defined(CONFIG_BLE_MESH_LPN_AUTO)
#define LPN_AUTO_TIMEOUT K_SECONDS(CONFIG_BLE_MESH_LPN_AUTO_TIMEOUT)
#else
#define LPN_AUTO_TIMEOUT 0
#define LPN_AUTO_TIMEOUT 0
#endif
#define LPN_RECV_DELAY CONFIG_BT_MESH_LPN_RECV_DELAY
#define SCAN_LATENCY min(CONFIG_BT_MESH_LPN_SCAN_LATENCY, \
LPN_RECV_DELAY)
#define LPN_RECV_DELAY CONFIG_BLE_MESH_LPN_RECV_DELAY
#define SCAN_LATENCY MIN(CONFIG_BLE_MESH_LPN_SCAN_LATENCY, LPN_RECV_DELAY)
#define FRIEND_REQ_RETRY_TIMEOUT K_SECONDS(CONFIG_BT_MESH_LPN_RETRY_TIMEOUT)
#define FRIEND_REQ_RETRY_TIMEOUT K_SECONDS(CONFIG_BLE_MESH_LPN_RETRY_TIMEOUT)
#define FRIEND_REQ_WAIT K_MSEC(100)
#define FRIEND_REQ_SCAN K_SECONDS(1)
#define FRIEND_REQ_TIMEOUT (FRIEND_REQ_WAIT + FRIEND_REQ_SCAN)
#define FRIEND_REQ_WAIT K_MSEC(100)
#define FRIEND_REQ_SCAN K_SECONDS(1)
#define FRIEND_REQ_TIMEOUT (FRIEND_REQ_WAIT + FRIEND_REQ_SCAN)
#define POLL_RETRY_TIMEOUT K_MSEC(100)
#define POLL_RETRY_TIMEOUT K_MSEC(100)
#define REQ_RETRY_DURATION(lpn) (4 * (LPN_RECV_DELAY + (lpn)->adv_duration + \
(lpn)->recv_win + POLL_RETRY_TIMEOUT))
#define REQ_RETRY_DURATION(lpn) (4 * (LPN_RECV_DELAY + (lpn)->adv_duration + \
(lpn)->recv_win + POLL_RETRY_TIMEOUT))
#define POLL_TIMEOUT_INIT (CONFIG_BT_MESH_LPN_INIT_POLL_TIMEOUT * 100)
#define POLL_TIMEOUT_MAX(lpn) ((CONFIG_BT_MESH_LPN_POLL_TIMEOUT * 100) - \
REQ_RETRY_DURATION(lpn))
#define POLL_TIMEOUT_INIT (CONFIG_BLE_MESH_LPN_INIT_POLL_TIMEOUT * 100)
#define POLL_TIMEOUT_MAX(lpn) ((CONFIG_BLE_MESH_LPN_POLL_TIMEOUT * 100) - \
REQ_RETRY_DURATION(lpn))
/* Update 4 to 20 for BQB test case MESH/NODE/FRND/LPM/BI-02-C */
#define REQ_ATTEMPTS(lpn) (POLL_TIMEOUT_MAX(lpn) < K_SECONDS(3) ? 2 : 4)
#define REQ_ATTEMPTS(lpn) (POLL_TIMEOUT_MAX(lpn) < K_SECONDS(3) ? 2 : 4)
#define CLEAR_ATTEMPTS 2
#define CLEAR_ATTEMPTS 2
#define LPN_CRITERIA ((CONFIG_BT_MESH_LPN_MIN_QUEUE_SIZE) | \
(CONFIG_BT_MESH_LPN_RSSI_FACTOR << 3) | \
(CONFIG_BT_MESH_LPN_RECV_WIN_FACTOR << 5))
#define LPN_CRITERIA ((CONFIG_BLE_MESH_LPN_MIN_QUEUE_SIZE) | \
(CONFIG_BLE_MESH_LPN_RSSI_FACTOR << 3) | \
(CONFIG_BLE_MESH_LPN_RECV_WIN_FACTOR << 5))
#define POLL_TO(to) { (u8_t)((to) >> 16), (u8_t)((to) >> 8), (u8_t)(to) }
#define LPN_POLL_TO POLL_TO(CONFIG_BT_MESH_LPN_POLL_TIMEOUT)
#define POLL_TO(to) { (u8_t)((to) >> 16), (u8_t)((to) >> 8), (u8_t)(to) }
#define LPN_POLL_TO POLL_TO(CONFIG_BLE_MESH_LPN_POLL_TIMEOUT)
/* 2 transmissions, 20ms interval */
#define POLL_XMIT BT_MESH_TRANSMIT(1, 20)
#define POLL_XMIT BLE_MESH_TRANSMIT(1, 20)
static void (*lpn_cb)(u16_t friend_addr, bool established);
#if defined(CONFIG_BT_MESH_DEBUG_LOW_POWER)
#if defined(CONFIG_BLE_MESH_DEBUG_LOW_POWER)
static const char *state2str(int state)
{
switch (state) {
case BT_MESH_LPN_DISABLED:
case BLE_MESH_LPN_DISABLED:
return "disabled";
case BT_MESH_LPN_CLEAR:
case BLE_MESH_LPN_CLEAR:
return "clear";
case BT_MESH_LPN_TIMER:
case BLE_MESH_LPN_TIMER:
return "timer";
case BT_MESH_LPN_ENABLED:
case BLE_MESH_LPN_ENABLED:
return "enabled";
case BT_MESH_LPN_REQ_WAIT:
case BLE_MESH_LPN_REQ_WAIT:
return "req wait";
case BT_MESH_LPN_WAIT_OFFER:
case BLE_MESH_LPN_WAIT_OFFER:
return "wait offer";
case BT_MESH_LPN_ESTABLISHED:
case BLE_MESH_LPN_ESTABLISHED:
return "established";
case BT_MESH_LPN_RECV_DELAY:
case BLE_MESH_LPN_RECV_DELAY:
return "recv delay";
case BT_MESH_LPN_WAIT_UPDATE:
case BLE_MESH_LPN_WAIT_UPDATE:
return "wait update";
default:
return "(unknown)";
}
}
#endif /* CONFIG_BT_MESH_DEBUG_LPN */
#endif /* CONFIG_BLE_MESH_DEBUG_LPN */
static inline void lpn_set_state(int state)
{
#if defined(CONFIG_BT_MESH_DEBUG_LOW_POWER)
#if defined(CONFIG_BLE_MESH_DEBUG_LOW_POWER)
BT_DBG("%s -> %s", state2str(bt_mesh.lpn.state), state2str(state));
#endif
bt_mesh.lpn.state = state;
}
static inline void group_zero(atomic_t *target)
static inline void group_zero(bt_mesh_atomic_t *target)
{
#if CONFIG_BT_MESH_LPN_GROUPS > 32
#if CONFIG_BLE_MESH_LPN_GROUPS > 32
int i;
for (i = 0; i < ARRAY_SIZE(bt_mesh.lpn.added); i++) {
atomic_set(&target[i], 0);
bt_mesh_atomic_set(&target[i], 0);
}
#else
atomic_set(target, 0);
bt_mesh_atomic_set(target, 0);
#endif
}
static inline void group_set(atomic_t *target, atomic_t *source)
static inline void group_set(bt_mesh_atomic_t *target, bt_mesh_atomic_t *source)
{
#if CONFIG_BT_MESH_LPN_GROUPS > 32
#if CONFIG_BLE_MESH_LPN_GROUPS > 32
int i;
for (i = 0; i < ARRAY_SIZE(bt_mesh.lpn.added); i++) {
atomic_or(&target[i], atomic_get(&source[i]));
bt_mesh_atomic_or(&target[i], bt_mesh_atomic_get(&source[i]));
}
#else
atomic_or(target, atomic_get(source));
bt_mesh_atomic_or(target, bt_mesh_atomic_get(source));
#endif
}
static inline void group_clear(atomic_t *target, atomic_t *source)
static inline void group_clear(bt_mesh_atomic_t *target, bt_mesh_atomic_t *source)
{
#if CONFIG_BT_MESH_LPN_GROUPS > 32
#if CONFIG_BLE_MESH_LPN_GROUPS > 32
int i;
for (i = 0; i < ARRAY_SIZE(bt_mesh.lpn.added); i++) {
atomic_and(&target[i], ~atomic_get(&source[i]));
bt_mesh_atomic_and(&target[i], ~bt_mesh_atomic_get(&source[i]));
}
#else
atomic_and(target, ~atomic_get(source));
bt_mesh_atomic_and(target, ~bt_mesh_atomic_get(source));
#endif
}
@@ -158,13 +158,13 @@ static void friend_clear_sent(int err, void *user_data)
lpn->req_attempts++;
if (err) {
BT_ERR("Sending Friend Request failed (err %d)", err);
lpn_set_state(BT_MESH_LPN_ENABLED);
BT_ERR("%s, Failed to send Friend Request (err %d)", __func__, err);
lpn_set_state(BLE_MESH_LPN_ENABLED);
clear_friendship(false, lpn->disable);
return;
}
lpn_set_state(BT_MESH_LPN_CLEAR);
lpn_set_state(BLE_MESH_LPN_CLEAR);
k_delayed_work_submit(&lpn->timer, FRIEND_REQ_TIMEOUT);
}
@@ -175,10 +175,10 @@ static const struct bt_mesh_send_cb clear_sent_cb = {
static int send_friend_clear(void)
{
struct bt_mesh_msg_ctx ctx = {
.net_idx = bt_mesh.sub[0].net_idx,
.app_idx = BT_MESH_KEY_UNUSED,
.addr = bt_mesh.lpn.frnd,
.send_ttl = 0,
.net_idx = bt_mesh.sub[0].net_idx,
.app_idx = BLE_MESH_KEY_UNUSED,
.addr = bt_mesh.lpn.frnd,
.send_ttl = 0,
};
struct bt_mesh_net_tx tx = {
.sub = &bt_mesh.sub[0],
@@ -217,16 +217,16 @@ static void clear_friendship(bool force, bool disable)
friend_cred_del(bt_mesh.sub[0].net_idx, lpn->frnd);
if (lpn->clear_success) {
lpn->old_friend = BT_MESH_ADDR_UNASSIGNED;
lpn->old_friend = BLE_MESH_ADDR_UNASSIGNED;
} else {
lpn->old_friend = lpn->frnd;
}
if (lpn_cb && lpn->frnd != BT_MESH_ADDR_UNASSIGNED) {
if (lpn_cb && lpn->frnd != BLE_MESH_ADDR_UNASSIGNED) {
lpn_cb(lpn->frnd, false);
}
lpn->frnd = BT_MESH_ADDR_UNASSIGNED;
lpn->frnd = BLE_MESH_ADDR_UNASSIGNED;
lpn->fsn = 0;
lpn->req_attempts = 0;
lpn->recv_win = 0;
@@ -247,11 +247,11 @@ static void clear_friendship(bool force, bool disable)
lpn->groups_changed = 1;
if (disable) {
lpn_set_state(BT_MESH_LPN_DISABLED);
lpn_set_state(BLE_MESH_LPN_DISABLED);
return;
}
lpn_set_state(BT_MESH_LPN_ENABLED);
lpn_set_state(BLE_MESH_LPN_ENABLED);
k_delayed_work_submit(&lpn->timer, FRIEND_REQ_RETRY_TIMEOUT);
}
@@ -260,19 +260,19 @@ static void friend_req_sent(u16_t duration, int err, void *user_data)
struct bt_mesh_lpn *lpn = &bt_mesh.lpn;
if (err) {
BT_ERR("Sending Friend Request failed (err %d)", err);
BT_ERR("%s, Failed to send Friend Request (err %d)", __func__, err);
return;
}
lpn->adv_duration = duration;
if (IS_ENABLED(CONFIG_BT_MESH_LPN_ESTABLISHMENT)) {
if (IS_ENABLED(CONFIG_BLE_MESH_LPN_ESTABLISHMENT)) {
k_delayed_work_submit(&lpn->timer, FRIEND_REQ_WAIT);
lpn_set_state(BT_MESH_LPN_REQ_WAIT);
lpn_set_state(BLE_MESH_LPN_REQ_WAIT);
} else {
k_delayed_work_submit(&lpn->timer,
duration + FRIEND_REQ_TIMEOUT);
lpn_set_state(BT_MESH_LPN_WAIT_OFFER);
lpn_set_state(BLE_MESH_LPN_WAIT_OFFER);
}
}
@@ -285,14 +285,14 @@ static int send_friend_req(struct bt_mesh_lpn *lpn)
const struct bt_mesh_comp *comp = bt_mesh_comp_get();
struct bt_mesh_msg_ctx ctx = {
.net_idx = bt_mesh.sub[0].net_idx,
.app_idx = BT_MESH_KEY_UNUSED,
.addr = BT_MESH_ADDR_FRIENDS,
.app_idx = BLE_MESH_KEY_UNUSED,
.addr = BLE_MESH_ADDR_FRIENDS,
.send_ttl = 0,
};
struct bt_mesh_net_tx tx = {
.sub = &bt_mesh.sub[0],
.ctx = &ctx,
.src = bt_mesh_primary_addr(),
.sub = &bt_mesh.sub[0],
.ctx = &ctx,
.src = bt_mesh_primary_addr(),
.xmit = POLL_XMIT,
};
struct bt_mesh_ctl_friend_req req = {
@@ -314,13 +314,13 @@ static void req_sent(u16_t duration, int err, void *user_data)
{
struct bt_mesh_lpn *lpn = &bt_mesh.lpn;
#if defined(CONFIG_BT_MESH_DEBUG_LOW_POWER)
#if defined(CONFIG_BLE_MESH_DEBUG_LOW_POWER)
BT_DBG("req 0x%02x duration %u err %d state %s",
lpn->sent_req, duration, err, state2str(lpn->state));
#endif
if (err) {
BT_ERR("Sending request failed (err %d)", err);
BT_ERR("%s, Failed to send request (err %d)", __func__, err);
lpn->sent_req = 0;
group_zero(lpn->pending);
return;
@@ -329,18 +329,17 @@ static void req_sent(u16_t duration, int err, void *user_data)
lpn->req_attempts++;
lpn->adv_duration = duration;
if (lpn->established || IS_ENABLED(CONFIG_BT_MESH_LPN_ESTABLISHMENT)) {
lpn_set_state(BT_MESH_LPN_RECV_DELAY);
if (lpn->established || IS_ENABLED(CONFIG_BLE_MESH_LPN_ESTABLISHMENT)) {
lpn_set_state(BLE_MESH_LPN_RECV_DELAY);
/* We start scanning a bit early to elimitate risk of missing
* response data due to HCI and other latencies.
*/
k_delayed_work_submit(&lpn->timer,
LPN_RECV_DELAY - SCAN_LATENCY);
} else {
lpn_set_state(BT_MESH_LPN_OFFER_RECV);
lpn_set_state(BLE_MESH_LPN_OFFER_RECV);
k_delayed_work_submit(&lpn->timer,
LPN_RECV_DELAY + duration +
lpn->recv_win);
LPN_RECV_DELAY + duration + lpn->recv_win);
}
}
@@ -351,10 +350,10 @@ static const struct bt_mesh_send_cb req_sent_cb = {
static int send_friend_poll(void)
{
struct bt_mesh_msg_ctx ctx = {
.net_idx = bt_mesh.sub[0].net_idx,
.app_idx = BT_MESH_KEY_UNUSED,
.addr = bt_mesh.lpn.frnd,
.send_ttl = 0,
.net_idx = bt_mesh.sub[0].net_idx,
.app_idx = BLE_MESH_KEY_UNUSED,
.addr = bt_mesh.lpn.frnd,
.send_ttl = 0,
};
struct bt_mesh_net_tx tx = {
.sub = &bt_mesh.sub[0],
@@ -389,7 +388,7 @@ static int send_friend_poll(void)
void bt_mesh_lpn_disable(bool force)
{
if (bt_mesh.lpn.state == BT_MESH_LPN_DISABLED) {
if (bt_mesh.lpn.state == BLE_MESH_LPN_DISABLED) {
return;
}
@@ -401,38 +400,38 @@ int bt_mesh_lpn_set(bool enable)
struct bt_mesh_lpn *lpn = &bt_mesh.lpn;
if (enable) {
if (lpn->state != BT_MESH_LPN_DISABLED) {
if (lpn->state != BLE_MESH_LPN_DISABLED) {
return 0;
}
} else {
if (lpn->state == BT_MESH_LPN_DISABLED) {
if (lpn->state == BLE_MESH_LPN_DISABLED) {
return 0;
}
}
if (!bt_mesh_is_provisioned()) {
if (enable) {
lpn_set_state(BT_MESH_LPN_ENABLED);
lpn_set_state(BLE_MESH_LPN_ENABLED);
} else {
lpn_set_state(BT_MESH_LPN_DISABLED);
lpn_set_state(BLE_MESH_LPN_DISABLED);
}
return 0;
}
if (enable) {
lpn_set_state(BT_MESH_LPN_ENABLED);
lpn_set_state(BLE_MESH_LPN_ENABLED);
if (IS_ENABLED(CONFIG_BT_MESH_LPN_ESTABLISHMENT)) {
if (IS_ENABLED(CONFIG_BLE_MESH_LPN_ESTABLISHMENT)) {
bt_mesh_scan_disable();
}
send_friend_req(lpn);
} else {
if (IS_ENABLED(CONFIG_BT_MESH_LPN_AUTO) &&
lpn->state == BT_MESH_LPN_TIMER) {
if (IS_ENABLED(CONFIG_BLE_MESH_LPN_AUTO) &&
lpn->state == BLE_MESH_LPN_TIMER) {
k_delayed_work_cancel(&lpn->timer);
lpn_set_state(BT_MESH_LPN_DISABLED);
lpn_set_state(BLE_MESH_LPN_DISABLED);
} else {
bt_mesh_lpn_disable(false);
}
@@ -451,7 +450,7 @@ static void friend_response_received(struct bt_mesh_lpn *lpn)
k_delayed_work_cancel(&lpn->timer);
bt_mesh_scan_disable();
lpn_set_state(BT_MESH_LPN_ESTABLISHED);
lpn_set_state(BLE_MESH_LPN_ESTABLISHED);
lpn->req_attempts = 0;
lpn->sent_req = 0;
}
@@ -460,14 +459,14 @@ void bt_mesh_lpn_msg_received(struct bt_mesh_net_rx *rx)
{
struct bt_mesh_lpn *lpn = &bt_mesh.lpn;
if (lpn->state == BT_MESH_LPN_TIMER) {
if (lpn->state == BLE_MESH_LPN_TIMER) {
BT_DBG("Restarting establishment timer");
k_delayed_work_submit(&lpn->timer, LPN_AUTO_TIMEOUT);
return;
}
if (lpn->sent_req != TRANS_CTL_OP_FRIEND_POLL) {
BT_WARN("Unexpected message withouth a preceding Poll");
BT_WARN("%s, Unexpected message withouth a preceding Poll", __func__);
return;
}
@@ -489,17 +488,17 @@ int bt_mesh_lpn_friend_offer(struct bt_mesh_net_rx *rx,
int err;
if (buf->len < sizeof(*msg)) {
BT_WARN("Too short Friend Offer");
BT_WARN("%s, Too short Friend Offer", __func__);
return -EINVAL;
}
if (lpn->state != BT_MESH_LPN_WAIT_OFFER) {
BT_WARN("Ignoring unexpected Friend Offer");
if (lpn->state != BLE_MESH_LPN_WAIT_OFFER) {
BT_WARN("%s, Ignoring unexpected Friend Offer", __func__);
return 0;
}
if (!msg->recv_win) {
BT_WARN("Prohibited ReceiveWindow value");
BT_WARN("%s, Prohibited ReceiveWindow value", __func__);
return -EINVAL;
}
@@ -513,7 +512,7 @@ int bt_mesh_lpn_friend_offer(struct bt_mesh_net_rx *rx,
cred = friend_cred_create(sub, lpn->frnd, lpn->counter, frnd_counter);
if (!cred) {
lpn->frnd = BT_MESH_ADDR_UNASSIGNED;
lpn->frnd = BLE_MESH_ADDR_UNASSIGNED;
return -ENOMEM;
}
@@ -527,7 +526,7 @@ int bt_mesh_lpn_friend_offer(struct bt_mesh_net_rx *rx,
err = send_friend_poll();
if (err) {
friend_cred_clear(cred);
lpn->frnd = BT_MESH_ADDR_UNASSIGNED;
lpn->frnd = BLE_MESH_ADDR_UNASSIGNED;
lpn->recv_win = 0;
lpn->queue_size = 0;
return err;
@@ -546,12 +545,12 @@ int bt_mesh_lpn_friend_clear_cfm(struct bt_mesh_net_rx *rx,
u16_t addr, counter;
if (buf->len < sizeof(*msg)) {
BT_WARN("Too short Friend Clear Confirm");
BT_WARN("%s, Too short Friend Clear Confirm", __func__);
return -EINVAL;
}
if (lpn->state != BT_MESH_LPN_CLEAR) {
BT_WARN("Ignoring unexpected Friend Clear Confirm");
if (lpn->state != BLE_MESH_LPN_CLEAR) {
BT_WARN("%s, Ignoring unexpected Friend Clear Confirm", __func__);
return 0;
}
@@ -561,7 +560,7 @@ int bt_mesh_lpn_friend_clear_cfm(struct bt_mesh_net_rx *rx,
BT_DBG("LPNAddress 0x%04x LPNCounter 0x%04x", addr, counter);
if (addr != bt_mesh_primary_addr() || counter != lpn->counter) {
BT_WARN("Invalid parameters in Friend Clear Confirm");
BT_WARN("%s, Invalid parameters in Friend Clear Confirm", __func__);
return 0;
}
@@ -579,17 +578,17 @@ static void lpn_group_add(u16_t group)
for (i = 0; i < ARRAY_SIZE(lpn->groups); i++) {
if (lpn->groups[i] == group) {
atomic_clear_bit(lpn->to_remove, i);
bt_mesh_atomic_clear_bit(lpn->to_remove, i);
return;
}
if (!free_slot && lpn->groups[i] == BT_MESH_ADDR_UNASSIGNED) {
if (!free_slot && lpn->groups[i] == BLE_MESH_ADDR_UNASSIGNED) {
free_slot = &lpn->groups[i];
}
}
if (!free_slot) {
BT_WARN("Friend Subscription List exceeded!");
BT_WARN("%s, Friend Subscription List exceeded!", __func__);
return;
}
@@ -604,27 +603,27 @@ static void lpn_group_del(u16_t group)
for (i = 0; i < ARRAY_SIZE(lpn->groups); i++) {
if (lpn->groups[i] == group) {
if (atomic_test_bit(lpn->added, i) ||
atomic_test_bit(lpn->pending, i)) {
atomic_set_bit(lpn->to_remove, i);
if (bt_mesh_atomic_test_bit(lpn->added, i) ||
bt_mesh_atomic_test_bit(lpn->pending, i)) {
bt_mesh_atomic_set_bit(lpn->to_remove, i);
lpn->groups_changed = 1;
} else {
lpn->groups[i] = BT_MESH_ADDR_UNASSIGNED;
lpn->groups[i] = BLE_MESH_ADDR_UNASSIGNED;
}
}
}
}
static inline int group_popcount(atomic_t *target)
static inline int group_popcount(bt_mesh_atomic_t *target)
{
#if CONFIG_BT_MESH_LPN_GROUPS > 32
#if CONFIG_BLE_MESH_LPN_GROUPS > 32
int i, count = 0;
for (i = 0; i < ARRAY_SIZE(bt_mesh.lpn.added); i++) {
count += popcount(atomic_get(&target[i]));
count += popcount(bt_mesh_atomic_get(&target[i]));
}
#else
return popcount(atomic_get(target));
return popcount(bt_mesh_atomic_get(target));
#endif
}
@@ -633,10 +632,10 @@ static bool sub_update(u8_t op)
struct bt_mesh_lpn *lpn = &bt_mesh.lpn;
int added_count = group_popcount(lpn->added);
struct bt_mesh_msg_ctx ctx = {
.net_idx = bt_mesh.sub[0].net_idx,
.app_idx = BT_MESH_KEY_UNUSED,
.addr = lpn->frnd,
.send_ttl = 0,
.net_idx = bt_mesh.sub[0].net_idx,
.app_idx = BLE_MESH_KEY_UNUSED,
.addr = lpn->frnd,
.send_ttl = 0,
};
struct bt_mesh_net_tx tx = {
.sub = &bt_mesh.sub[0],
@@ -655,27 +654,27 @@ static bool sub_update(u8_t op)
}
for (i = 0, g = 0; i < ARRAY_SIZE(lpn->groups); i++) {
if (lpn->groups[i] == BT_MESH_ADDR_UNASSIGNED) {
if (lpn->groups[i] == BLE_MESH_ADDR_UNASSIGNED) {
continue;
}
if (op == TRANS_CTL_OP_FRIEND_SUB_ADD) {
if (atomic_test_bit(lpn->added, i)) {
if (bt_mesh_atomic_test_bit(lpn->added, i)) {
continue;
}
} else {
if (!atomic_test_bit(lpn->to_remove, i)) {
if (!bt_mesh_atomic_test_bit(lpn->to_remove, i)) {
continue;
}
}
if (added_count + g >= lpn->queue_size) {
BT_WARN("Friend Queue Size exceeded");
BT_WARN("%s, Friend Queue Size exceeded", __func__);
break;
}
req.addr_list[g++] = sys_cpu_to_be16(lpn->groups[i]);
atomic_set_bit(lpn->pending, i);
bt_mesh_atomic_set_bit(lpn->pending, i);
if (g == ARRAY_SIZE(req.addr_list)) {
break;
@@ -703,24 +702,24 @@ static bool sub_update(u8_t op)
static void update_timeout(struct bt_mesh_lpn *lpn)
{
if (lpn->established) {
BT_WARN("No response from Friend during ReceiveWindow");
BT_WARN("%s, No response from Friend during ReceiveWindow", __func__);
bt_mesh_scan_disable();
lpn_set_state(BT_MESH_LPN_ESTABLISHED);
lpn_set_state(BLE_MESH_LPN_ESTABLISHED);
k_delayed_work_submit(&lpn->timer, POLL_RETRY_TIMEOUT);
} else {
if (IS_ENABLED(CONFIG_BT_MESH_LPN_ESTABLISHMENT)) {
if (IS_ENABLED(CONFIG_BLE_MESH_LPN_ESTABLISHMENT)) {
bt_mesh_scan_disable();
}
if (lpn->req_attempts < 6) {
BT_WARN("Retrying first Friend Poll");
BT_WARN("%s, Retrying first Friend Poll", __func__);
lpn->sent_req = 0;
if (send_friend_poll() == 0) {
return;
}
}
BT_ERR("Timed out waiting for first Friend Update");
BT_ERR("%s, Timed out waiting for first Friend Update", __func__);
clear_friendship(false, false);
}
}
@@ -729,47 +728,47 @@ static void lpn_timeout(struct k_work *work)
{
struct bt_mesh_lpn *lpn = &bt_mesh.lpn;
#if defined(CONFIG_BT_MESH_DEBUG_LOW_POWER)
#if defined(CONFIG_BLE_MESH_DEBUG_LOW_POWER)
BT_DBG("state: %s", state2str(lpn->state));
#endif
switch (lpn->state) {
case BT_MESH_LPN_DISABLED:
case BLE_MESH_LPN_DISABLED:
break;
case BT_MESH_LPN_CLEAR:
case BLE_MESH_LPN_CLEAR:
clear_friendship(false, bt_mesh.lpn.disable);
break;
case BT_MESH_LPN_TIMER:
case BLE_MESH_LPN_TIMER:
BT_DBG("Starting to look for Friend nodes");
lpn_set_state(BT_MESH_LPN_ENABLED);
if (IS_ENABLED(CONFIG_BT_MESH_LPN_ESTABLISHMENT)) {
lpn_set_state(BLE_MESH_LPN_ENABLED);
if (IS_ENABLED(CONFIG_BLE_MESH_LPN_ESTABLISHMENT)) {
bt_mesh_scan_disable();
}
/* fall through */
case BT_MESH_LPN_ENABLED:
case BLE_MESH_LPN_ENABLED:
send_friend_req(lpn);
break;
case BT_MESH_LPN_REQ_WAIT:
case BLE_MESH_LPN_REQ_WAIT:
bt_mesh_scan_enable();
k_delayed_work_submit(&lpn->timer,
lpn->adv_duration + FRIEND_REQ_SCAN);
lpn_set_state(BT_MESH_LPN_WAIT_OFFER);
lpn_set_state(BLE_MESH_LPN_WAIT_OFFER);
break;
case BT_MESH_LPN_WAIT_OFFER:
BT_WARN("No acceptable Friend Offers received");
if (IS_ENABLED(CONFIG_BT_MESH_LPN_ESTABLISHMENT)) {
case BLE_MESH_LPN_WAIT_OFFER:
BT_WARN("%s, No acceptable Friend Offers received", __func__);
if (IS_ENABLED(CONFIG_BLE_MESH_LPN_ESTABLISHMENT)) {
bt_mesh_scan_disable();
}
lpn->counter++;
lpn_set_state(BT_MESH_LPN_ENABLED);
lpn_set_state(BLE_MESH_LPN_ENABLED);
k_delayed_work_submit(&lpn->timer, FRIEND_REQ_RETRY_TIMEOUT);
break;
case BT_MESH_LPN_OFFER_RECV:
BT_WARN("No Friend Update received after the first Friend Poll");
case BLE_MESH_LPN_OFFER_RECV:
BT_WARN("%s, No Friend Update received after the first Friend Poll", __func__);
lpn->sent_req = 0;
send_friend_poll();
break;
case BT_MESH_LPN_ESTABLISHED:
case BLE_MESH_LPN_ESTABLISHED:
if (lpn->req_attempts < REQ_ATTEMPTS(lpn)) {
u8_t req = lpn->sent_req;
@@ -784,19 +783,19 @@ static void lpn_timeout(struct k_work *work)
break;
}
BT_ERR("No response from Friend after %u retries",
lpn->req_attempts);
BT_ERR("%s, No response from Friend after %u retries",
__func__, lpn->req_attempts);
lpn->req_attempts = 0;
clear_friendship(false, false);
break;
case BT_MESH_LPN_RECV_DELAY:
case BLE_MESH_LPN_RECV_DELAY:
k_delayed_work_submit(&lpn->timer,
lpn->adv_duration + SCAN_LATENCY +
lpn->recv_win);
bt_mesh_scan_enable();
lpn_set_state(BT_MESH_LPN_WAIT_UPDATE);
lpn_set_state(BLE_MESH_LPN_WAIT_UPDATE);
break;
case BT_MESH_LPN_WAIT_UPDATE:
case BLE_MESH_LPN_WAIT_UPDATE:
update_timeout(lpn);
break;
default:
@@ -823,7 +822,7 @@ void bt_mesh_lpn_group_del(u16_t *groups, size_t group_count)
int i;
for (i = 0; i < group_count; i++) {
if (groups[i] != BT_MESH_ADDR_UNASSIGNED) {
if (groups[i] != BLE_MESH_ADDR_UNASSIGNED) {
BT_DBG("group 0x%04x", groups[i]);
lpn_group_del(groups[i]);
}
@@ -840,12 +839,12 @@ static s32_t poll_timeout(struct bt_mesh_lpn *lpn)
{
/* If we're waiting for segment acks keep polling at high freq */
if (bt_mesh_tx_in_progress()) {
return min(POLL_TIMEOUT_MAX(lpn), K_SECONDS(1));
return MIN(POLL_TIMEOUT_MAX(lpn), K_SECONDS(1));
}
if (lpn->poll_timeout < POLL_TIMEOUT_MAX(lpn)) {
lpn->poll_timeout *= 2;
lpn->poll_timeout = min(lpn->poll_timeout,
lpn->poll_timeout = MIN(lpn->poll_timeout,
POLL_TIMEOUT_MAX(lpn));
}
@@ -861,20 +860,20 @@ int bt_mesh_lpn_friend_sub_cfm(struct bt_mesh_net_rx *rx,
struct bt_mesh_lpn *lpn = &bt_mesh.lpn;
if (buf->len < sizeof(*msg)) {
BT_WARN("Too short Friend Subscription Confirm");
BT_WARN("%s, Too short Friend Subscription Confirm", __func__);
return -EINVAL;
}
BT_DBG("xact 0x%02x", msg->xact);
if (!lpn->sent_req) {
BT_WARN("No pending subscription list message");
BT_WARN("%s, No pending subscription list message", __func__);
return 0;
}
if (msg->xact != lpn->xact_pending) {
BT_WARN("Transaction mismatch (0x%02x != 0x%02x)",
msg->xact, lpn->xact_pending);
BT_WARN("%s, Transaction mismatch (0x%02x != 0x%02x)",
__func__, msg->xact, lpn->xact_pending);
return 0;
}
@@ -887,13 +886,13 @@ int bt_mesh_lpn_friend_sub_cfm(struct bt_mesh_net_rx *rx,
group_clear(lpn->added, lpn->pending);
for (i = 0; i < ARRAY_SIZE(lpn->groups); i++) {
if (atomic_test_and_clear_bit(lpn->pending, i) &&
atomic_test_and_clear_bit(lpn->to_remove, i)) {
lpn->groups[i] = BT_MESH_ADDR_UNASSIGNED;
if (bt_mesh_atomic_test_and_clear_bit(lpn->pending, i) &&
bt_mesh_atomic_test_and_clear_bit(lpn->to_remove, i)) {
lpn->groups[i] = BLE_MESH_ADDR_UNASSIGNED;
}
}
} else {
BT_WARN("Unexpected Friend Subscription Confirm");
BT_WARN("%s, Unexpected Friend Subscription Confirm", __func__);
return 0;
}
@@ -928,22 +927,22 @@ int bt_mesh_lpn_friend_update(struct bt_mesh_net_rx *rx,
u32_t iv_index;
if (buf->len < sizeof(*msg)) {
BT_WARN("Too short Friend Update");
BT_WARN("%s, Too short Friend Update", __func__);
return -EINVAL;
}
if (lpn->sent_req != TRANS_CTL_OP_FRIEND_POLL) {
BT_WARN("Unexpected friend update");
BT_WARN("%s, Unexpected friend update", __func__);
return 0;
}
if (sub->kr_phase == BT_MESH_KR_PHASE_2 && !rx->new_key) {
BT_WARN("Ignoring Phase 2 KR Update secured using old key");
if (sub->kr_phase == BLE_MESH_KR_PHASE_2 && !rx->new_key) {
BT_WARN("%s, Ignoring Phase 2 KR Update secured using old key", __func__);
return 0;
}
if (bt_mesh.ivu_initiator &&
bt_mesh.iv_update == BT_MESH_IV_UPDATE(msg->flags)) {
bt_mesh.iv_update == BLE_MESH_IV_UPDATE(msg->flags)) {
bt_mesh_beacon_ivu_initiator(false);
}
@@ -954,7 +953,7 @@ int bt_mesh_lpn_friend_update(struct bt_mesh_net_rx *rx,
* Credentials) were used for this message.
*/
if (!rx->friend_cred) {
BT_WARN("Friend Update with wrong credentials");
BT_WARN("%s, Friend Update with wrong credentials", __func__);
return -EINVAL;
}
@@ -967,7 +966,7 @@ int bt_mesh_lpn_friend_update(struct bt_mesh_net_rx *rx,
}
/* Set initial poll timeout */
lpn->poll_timeout = min(POLL_TIMEOUT_MAX(lpn),
lpn->poll_timeout = MIN(POLL_TIMEOUT_MAX(lpn),
POLL_TIMEOUT_INIT);
}
@@ -978,12 +977,12 @@ int bt_mesh_lpn_friend_update(struct bt_mesh_net_rx *rx,
BT_DBG("flags 0x%02x iv_index 0x%08x md %u", msg->flags, iv_index,
msg->md);
if (bt_mesh_kr_update(sub, BT_MESH_KEY_REFRESH(msg->flags),
if (bt_mesh_kr_update(sub, BLE_MESH_KEY_REFRESH(msg->flags),
rx->new_key)) {
bt_mesh_net_beacon_update(sub);
}
bt_mesh_net_iv_update(iv_index, BT_MESH_IV_UPDATE(msg->flags));
bt_mesh_net_iv_update(iv_index, BLE_MESH_IV_UPDATE(msg->flags));
if (lpn->groups_changed) {
sub_update(TRANS_CTL_OP_FRIEND_SUB_ADD);
@@ -1030,8 +1029,8 @@ int bt_mesh_lpn_init(void)
k_delayed_work_init(&lpn->timer, lpn_timeout);
if (lpn->state == BT_MESH_LPN_ENABLED) {
if (IS_ENABLED(CONFIG_BT_MESH_LPN_ESTABLISHMENT)) {
if (lpn->state == BLE_MESH_LPN_ENABLED) {
if (IS_ENABLED(CONFIG_BLE_MESH_LPN_ESTABLISHMENT)) {
bt_mesh_scan_disable();
} else {
bt_mesh_scan_enable();
@@ -1041,14 +1040,14 @@ int bt_mesh_lpn_init(void)
} else {
bt_mesh_scan_enable();
if (IS_ENABLED(CONFIG_BT_MESH_LPN_AUTO)) {
if (IS_ENABLED(CONFIG_BLE_MESH_LPN_AUTO)) {
BT_DBG("Waiting %u ms for messages", LPN_AUTO_TIMEOUT);
lpn_set_state(BT_MESH_LPN_TIMER);
lpn_set_state(BLE_MESH_LPN_TIMER);
k_delayed_work_submit(&lpn->timer, LPN_AUTO_TIMEOUT);
}
}
return 0;
}
#endif /* CONFIG_BT_MESH_LOW_POWER */
#endif /* #if CONFIG_BT_MESH */
#endif /* CONFIG_BLE_MESH_LOW_POWER */

View File

@@ -6,18 +6,24 @@
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _LPN_H_
#define _LPN_H_
int bt_mesh_lpn_friend_update(struct bt_mesh_net_rx *rx,
struct net_buf_simple *buf);
int bt_mesh_lpn_friend_offer(struct bt_mesh_net_rx *rx,
struct net_buf_simple *buf);
int bt_mesh_lpn_friend_clear_cfm(struct bt_mesh_net_rx *rx,
struct net_buf_simple *buf);
int bt_mesh_lpn_friend_sub_cfm(struct bt_mesh_net_rx *rx,
struct net_buf_simple *buf);
static inline bool bt_mesh_lpn_established(void)
{
#if defined(CONFIG_BT_MESH_LOW_POWER)
#if defined(CONFIG_BLE_MESH_LOW_POWER)
return bt_mesh.lpn.established;
#else
return false;
@@ -26,7 +32,7 @@ static inline bool bt_mesh_lpn_established(void)
static inline bool bt_mesh_lpn_match(u16_t addr)
{
#if defined(CONFIG_BT_MESH_LOW_POWER)
#if defined(CONFIG_BLE_MESH_LOW_POWER)
if (bt_mesh_lpn_established()) {
return (addr == bt_mesh.lpn.frnd);
}
@@ -36,8 +42,8 @@ static inline bool bt_mesh_lpn_match(u16_t addr)
static inline bool bt_mesh_lpn_waiting_update(void)
{
#if defined(CONFIG_BT_MESH_LOW_POWER)
return (bt_mesh.lpn.state == BT_MESH_LPN_WAIT_UPDATE);
#if defined(CONFIG_BLE_MESH_LOW_POWER)
return (bt_mesh.lpn.state == BLE_MESH_LPN_WAIT_UPDATE);
#else
return false;
#endif
@@ -45,8 +51,8 @@ static inline bool bt_mesh_lpn_waiting_update(void)
static inline bool bt_mesh_lpn_timer(void)
{
#if defined(CONFIG_BT_MESH_LPN_AUTO)
return (bt_mesh.lpn.state == BT_MESH_LPN_TIMER);
#if defined(CONFIG_BLE_MESH_LPN_AUTO)
return (bt_mesh.lpn.state == BLE_MESH_LPN_TIMER);
#else
return false;
#endif
@@ -55,8 +61,11 @@ static inline bool bt_mesh_lpn_timer(void)
void bt_mesh_lpn_msg_received(struct bt_mesh_net_rx *rx);
void bt_mesh_lpn_group_add(u16_t group);
void bt_mesh_lpn_group_del(u16_t *groups, size_t group_count);
void bt_mesh_lpn_disable(bool force);
int bt_mesh_lpn_init(void);
#endif /* _LPN_H_ */

View File

@@ -6,14 +6,19 @@
* SPDX-License-Identifier: Apache-2.0
*/
#define BT_MESH_KEY_PRIMARY 0x0000
#define BT_MESH_KEY_ANY 0xffff
#ifndef _MESH_H_
#define _MESH_H_
#define BT_MESH_ADDR_IS_UNICAST(addr) ((addr) && (addr) < 0x8000)
#define BT_MESH_ADDR_IS_GROUP(addr) ((addr) >= 0xc000 && (addr) <= 0xff00)
#define BT_MESH_ADDR_IS_VIRTUAL(addr) ((addr) >= 0x8000 && (addr) < 0xc000)
#define BT_MESH_ADDR_IS_RFU(addr) ((addr) >= 0xff00 && (addr) <= 0xfffb)
#define BLE_MESH_KEY_PRIMARY 0x0000
#define BLE_MESH_KEY_ANY 0xffff
#define BLE_MESH_ADDR_IS_UNICAST(addr) ((addr) && (addr) < 0x8000)
#define BLE_MESH_ADDR_IS_GROUP(addr) ((addr) >= 0xc000 && (addr) <= 0xff00)
#define BLE_MESH_ADDR_IS_VIRTUAL(addr) ((addr) >= 0x8000 && (addr) < 0xc000)
#define BLE_MESH_ADDR_IS_RFU(addr) ((addr) >= 0xff00 && (addr) <= 0xfffb)
struct bt_mesh_net;
bool bt_mesh_is_provisioned(void);
#endif /* _MESH_H_ */

View File

@@ -34,8 +34,6 @@
#include "mesh_util.h"
#include "sdkconfig.h"
#if CONFIG_BT_MESH
/* max number of calls until change the key (2^48).*/
const static uint64_t MAX_CALLS = ((uint64_t)1 << 48);
@@ -67,7 +65,6 @@ const static uint64_t MAX_CALLS = ((uint64_t)1 << 48);
*/
const unsigned char gf_wrap = 0x87;
static const uint8_t sbox[256] = {
0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b,
0xfe, 0xd7, 0xab, 0x76, 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0,
@@ -98,8 +95,8 @@ static inline unsigned int rotword(unsigned int a)
return (((a) >> 24) | ((a) << 8));
}
#define subbyte(a, o)(sbox[((a) >> (o))&0xff] << (o))
#define subword(a)(subbyte(a, 24)|subbyte(a, 16)|subbyte(a, 8)|subbyte(a, 0))
#define subbyte(a, o) (sbox[((a) >> (o))&0xff] << (o))
#define subword(a) (subbyte(a, 24)|subbyte(a, 16)|subbyte(a, 8)|subbyte(a, 0))
int tc_aes128_set_encrypt_key(TCAesKeySched_t s, const uint8_t *k)
{
@@ -410,6 +407,3 @@ int tc_cmac_erase(TCCmacState_t s)
return TC_CRYPTO_SUCCESS;
}
#endif /* #if CONFIG_BT_MESH */

View File

@@ -22,7 +22,7 @@
#include "mesh_kernel.h"
#include "sdkconfig.h"
#if CONFIG_BT_MESH
#ifndef CONFIG_ATOMIC_OPERATIONS_BUILTIN
/**
*
@@ -36,7 +36,7 @@
*
* @return The value read from <target>
*/
atomic_val_t atomic_get(const atomic_t *target)
bt_mesh_atomic_val_t bt_mesh_atomic_get(const bt_mesh_atomic_t *target)
{
return *target;
}
@@ -53,17 +53,17 @@ atomic_val_t atomic_get(const atomic_t *target)
*
* @return The previous value from <target>
*/
atomic_val_t atomic_set(atomic_t *target, atomic_val_t value)
bt_mesh_atomic_val_t bt_mesh_atomic_set(bt_mesh_atomic_t *target, bt_mesh_atomic_val_t value)
{
unsigned int key;
atomic_val_t ret;
bt_mesh_atomic_val_t ret;
key = irq_lock();
key = bt_mesh_irq_lock();
ret = *target;
*target = value;
irq_unlock(key);
bt_mesh_irq_unlock(key);
return ret;
}
@@ -81,17 +81,17 @@ atomic_val_t atomic_set(atomic_t *target, atomic_val_t value)
*
* @return The previous value from <target>
*/
atomic_val_t atomic_or(atomic_t *target, atomic_val_t value)
bt_mesh_atomic_val_t bt_mesh_atomic_or(bt_mesh_atomic_t *target, bt_mesh_atomic_val_t value)
{
unsigned int key;
atomic_val_t ret;
bt_mesh_atomic_val_t ret;
key = irq_lock();
key = bt_mesh_irq_lock();
ret = *target;
*target |= value;
irq_unlock(key);
bt_mesh_irq_unlock(key);
return ret;
}
@@ -109,17 +109,17 @@ atomic_val_t atomic_or(atomic_t *target, atomic_val_t value)
*
* @return The previous value from <target>
*/
atomic_val_t atomic_and(atomic_t *target, atomic_val_t value)
bt_mesh_atomic_val_t bt_mesh_atomic_and(bt_mesh_atomic_t *target, bt_mesh_atomic_val_t value)
{
unsigned int key;
atomic_val_t ret;
bt_mesh_atomic_val_t ret;
key = irq_lock();
key = bt_mesh_irq_lock();
ret = *target;
*target &= value;
irq_unlock(key);
bt_mesh_irq_unlock(key);
return ret;
}
@@ -135,17 +135,17 @@ atomic_val_t atomic_and(atomic_t *target, atomic_val_t value)
*
* @return The value from <target> prior to the decrement
*/
atomic_val_t atomic_dec(atomic_t *target)
bt_mesh_atomic_val_t bt_mesh_atomic_dec(bt_mesh_atomic_t *target)
{
unsigned int key;
atomic_val_t ret;
bt_mesh_atomic_val_t ret;
key = irq_lock();
key = bt_mesh_irq_lock();
ret = *target;
(*target)--;
irq_unlock(key);
bt_mesh_irq_unlock(key);
return ret;
}
@@ -161,20 +161,19 @@ atomic_val_t atomic_dec(atomic_t *target)
*
* @return The value from <target> before the increment
*/
atomic_val_t atomic_inc(atomic_t *target)
bt_mesh_atomic_val_t bt_mesh_atomic_inc(bt_mesh_atomic_t *target)
{
unsigned int key;
atomic_val_t ret;
bt_mesh_atomic_val_t ret;
key = irq_lock();
key = bt_mesh_irq_lock();
ret = *target;
(*target)++;
irq_unlock(key);
bt_mesh_irq_unlock(key);
return ret;
}
#endif /* #if CONFIG_BT_MESH */
#endif /* #ifndef CONFIG_ATOMIC_OPERATIONS_BUILTIN */

File diff suppressed because it is too large Load Diff

View File

@@ -7,32 +7,20 @@
#include <string.h>
#include "sdkconfig.h"
#include "mesh_buf.h"
#include "mesh_trace.h"
#include "esp_bt_defs.h"
#include "sdkconfig.h"
#if CONFIG_BT_MESH
/* Helpers to access the storage array, since we don't have access to its
* type at this point anymore.
*/
#define BUF_SIZE(pool) (sizeof(struct net_buf) + \
ROUND_UP(pool->buf_size, 4) + \
ROUND_UP(pool->user_data_size, 4))
#define BUF_SIZE(pool) (sizeof(struct net_buf) + \
ROUND_UP(pool->buf_size, 4) + \
ROUND_UP(pool->user_data_size, 4))
#define UNINIT_BUF(pool, n) (struct net_buf *)(((u8_t *)(pool->__bufs)) + \
((n) * BUF_SIZE(pool)))
/* Linker-defined symbol bound to the static pool structs */
struct net_buf_pool *net_buf_pool_get(int id)
{
return (struct net_buf_pool *)id;
}
//static int pool_id(struct net_buf_pool *pool)
//{
// BT_DBG("%s, the pool id = %p", __func__, pool);
// return (int)&pool[pool->buf_count - pool->uninit_count - 1];
//}
((n) * BUF_SIZE(pool)))
static inline struct net_buf *pool_get_uninit(struct net_buf_pool *pool,
u16_t uninit_count)
@@ -43,8 +31,9 @@ static inline struct net_buf *pool_get_uninit(struct net_buf_pool *pool,
buf->pool_id = pool;
buf->size = pool->buf_size;
BT_DBG("%s, pool_id = %p, uninit_count = %d, pool->buf_count = %d, buf = %p, buf->size = %d, pool = %p",
__func__, buf->pool_id, uninit_count, pool->buf_count, buf, buf->size, pool);
NET_BUF_DBG("%s, pool_id = %p, uninit_count = %d, pool->buf_count = %d, buf = %p, buf->size = %d, pool = %p",
__func__, buf->pool_id, uninit_count, pool->buf_count, buf, buf->size, pool);
return buf;
}
@@ -222,8 +211,8 @@ void net_buf_reset(struct net_buf *buf)
NET_BUF_ASSERT(buf->flags == 0);
NET_BUF_ASSERT(buf->frags == NULL);
buf->len = 0;
buf->data = buf->__buf;
buf->len = 0;
buf->data = buf->__buf;
}
void net_buf_reserve(struct net_buf *buf, size_t reserve)
@@ -247,9 +236,9 @@ void net_buf_slist_put(sys_slist_t *list, struct net_buf *buf)
tail->flags |= NET_BUF_FRAGS;
}
key = irq_lock();
key = bt_mesh_irq_lock();
sys_slist_append_list(list, &buf->node, &tail->node);
irq_unlock(key);
bt_mesh_irq_unlock(key);
}
struct net_buf *net_buf_slist_get(sys_slist_t *list)
@@ -259,9 +248,9 @@ struct net_buf *net_buf_slist_get(sys_slist_t *list)
NET_BUF_ASSERT(list);
key = irq_lock();
key = bt_mesh_irq_lock();
buf = (void *)sys_slist_get(list);
irq_unlock(key);
bt_mesh_irq_unlock(key);
if (!buf) {
return NULL;
@@ -269,9 +258,9 @@ struct net_buf *net_buf_slist_get(sys_slist_t *list)
/* Get any fragments belonging to this buffer */
for (frag = buf; (frag->flags & NET_BUF_FRAGS); frag = frag->frags) {
key = irq_lock();
key = bt_mesh_irq_lock();
frag->frags = (void *)sys_slist_get(list);
irq_unlock(key);
bt_mesh_irq_unlock(key);
NET_BUF_ASSERT(frag->frags);
@@ -285,23 +274,6 @@ struct net_buf *net_buf_slist_get(sys_slist_t *list)
return buf;
}
void net_buf_put(struct k_fifo *fifo, struct net_buf *buf)
{
struct net_buf *tail;
//NET_BUF_ASSERT(fifo);
//NET_BUF_ASSERT(buf);
//ble_mesh_msg_t msg = {0};
//ble_mesh_task_post(ble_mesh_msg_t *msg, 0);
for (tail = buf; tail->frags; tail = tail->frags) {
tail->flags |= NET_BUF_FRAGS;
}
//k_fifo_put_list(fifo, buf, tail);
}
struct net_buf *net_buf_ref(struct net_buf *buf)
{
NET_BUF_ASSERT(buf);
@@ -312,83 +284,7 @@ struct net_buf *net_buf_ref(struct net_buf *buf)
return buf;
}
struct net_buf *net_buf_clone(struct net_buf *buf, s32_t timeout)
{
struct net_buf_pool *pool;
struct net_buf *clone;
NET_BUF_ASSERT(buf);
pool = buf->pool_id;//net_buf_pool_get(buf->pool_id);
clone = net_buf_alloc(pool, timeout);
if (!clone) {
return NULL;
}
net_buf_reserve(clone, net_buf_headroom(buf));
/* TODO: Add reference to the original buffer instead of copying it. */
memcpy(net_buf_add(clone, buf->len), buf->data, buf->len);
return clone;
}
struct net_buf *net_buf_frag_last(struct net_buf *buf)
{
NET_BUF_ASSERT(buf);
while (buf->frags) {
buf = buf->frags;
}
return buf;
}
void net_buf_frag_insert(struct net_buf *parent, struct net_buf *frag)
{
NET_BUF_ASSERT(parent);
NET_BUF_ASSERT(frag);
if (parent->frags) {
net_buf_frag_last(frag)->frags = parent->frags;
}
/* Take ownership of the fragment reference */
parent->frags = frag;
}
#if defined(CONFIG_NET_BUF_LOG)
struct net_buf *net_buf_frag_del_debug(struct net_buf *parent,
struct net_buf *frag,
const char *func, int line)
#else
struct net_buf *net_buf_frag_del(struct net_buf *parent, struct net_buf *frag)
#endif
{
struct net_buf *next_frag;
NET_BUF_ASSERT(frag);
if (parent) {
NET_BUF_ASSERT(parent->frags);
NET_BUF_ASSERT(parent->frags == frag);
parent->frags = frag->frags;
}
next_frag = frag->frags;
frag->frags = NULL;
#if defined(CONFIG_NET_BUF_LOG)
net_buf_unref_debug(frag, func, line);
#else
net_buf_unref(frag);
#endif
return next_frag;
}
#if defined(CONFIG_NET_BUF_LOG)
#if defined(CONFIG_BLE_MESH_NET_BUF_LOG)
void net_buf_unref_debug(struct net_buf *buf, const char *func, int line)
#else
void net_buf_unref(struct net_buf *buf)
@@ -400,7 +296,7 @@ void net_buf_unref(struct net_buf *buf)
struct net_buf *frags = buf->frags;
struct net_buf_pool *pool;
#if defined(CONFIG_NET_BUF_LOG)
#if defined(CONFIG_BLE_MESH_NET_BUF_LOG)
if (!buf->ref) {
NET_BUF_ERR("%s():%d: buf %p double free", func, line,
buf);
@@ -417,26 +313,24 @@ void net_buf_unref(struct net_buf *buf)
buf->frags = NULL;
pool = buf->pool_id;//net_buf_pool_get(buf->pool_id);
pool = buf->pool_id;
pool->uninit_count++;
#if defined(CONFIG_NET_BUF_POOL_USAGE)
#if defined(CONFIG_BLE_MESH_NET_BUF_POOL_USAGE)
pool->avail_count++;
BT_DBG("%s, pool->avail_count = %d, pool->uninit_count = %d", __func__,
pool->avail_count, pool->uninit_count);
NET_BUF_DBG("%s, pool->avail_count = %d, pool->uninit_count = %d", __func__,
pool->avail_count, pool->uninit_count);
NET_BUF_ASSERT(pool->avail_count <= pool->buf_count);
#endif
if (pool->destroy) {
pool->destroy(buf);
} else {
net_buf_destroy(buf);
}
buf = frags;
}
}
#if defined(CONFIG_NET_BUF_LOG)
#if defined(CONFIG_BLE_MESH_NET_BUF_LOG)
struct net_buf *net_buf_alloc_debug(struct net_buf_pool *pool, s32_t timeout,
const char *func, int line)
#else
@@ -450,12 +344,12 @@ struct net_buf *net_buf_alloc(struct net_buf_pool *pool, s32_t timeout)
NET_BUF_ASSERT(pool);
NET_BUF_DBG("%s():%d: pool %p timeout %d", func, line, pool, timeout);
BT_DBG("%s, pool = %p , pool->uninit_count= %d, buf_count = %d", __func__,
pool, pool->uninit_count, pool->buf_count);
NET_BUF_DBG("%s, pool = %p , pool->uninit_count= %d, buf_count = %d", __func__,
pool, pool->uninit_count, pool->buf_count);
/* We need to lock interrupts temporarily to prevent race conditions
* when accessing pool->uninit_count.
*/
key = irq_lock();
key = bt_mesh_irq_lock();
/* If there are uninitialized buffers we're guaranteed to succeed
* with the allocation one way or another.
@@ -468,28 +362,9 @@ struct net_buf *net_buf_alloc(struct net_buf_pool *pool, s32_t timeout)
goto success;
}
}
// u16_t uninit_count;
/* If this is not the first access to the pool, we can
* be opportunistic and try to fetch a previously used
* buffer from the LIFO with K_NO_WAIT.
*/
//if (pool->uninit_count < pool->buf_count) {
// buf = &pool->__bufs[pool->buf_count - pool->uninit_count];
//if (buf) {
// irq_unlock(key);
// goto success;
//}
//}
// uninit_count = pool->uninit_count--;
// irq_unlock(key);
// buf = pool_get_uninit(pool, uninit_count);
// goto success;
}
irq_unlock(key);
bt_mesh_irq_unlock(key);
if (!buf) {
BT_ERR("%s():Failed to get free buffer", __func__);
@@ -498,7 +373,7 @@ struct net_buf *net_buf_alloc(struct net_buf_pool *pool, s32_t timeout)
success:
NET_BUF_DBG("allocated buf %p", buf);
irq_unlock(key);
bt_mesh_irq_unlock(key);
buf->ref = 1;
buf->index = pool->buf_count - i;
@@ -507,22 +382,10 @@ success:
net_buf_reset(buf);
pool->uninit_count--;
#if defined(CONFIG_NET_BUF_POOL_USAGE)
#if defined(CONFIG_BLE_MESH_NET_BUF_POOL_USAGE)
pool->avail_count--;
NET_BUF_ASSERT(pool->avail_count >= 0);
#endif
return buf;
}
int net_buf_id(struct net_buf *buf)
{
struct net_buf_pool *pool = buf->pool_id;//net_buf_pool_get(buf->pool_id);
u8_t *pool_start = (u8_t *)pool->__bufs;
u8_t *buf_ptr = (u8_t *)buf;
return (buf_ptr - pool_start) / BUF_SIZE(pool);
}
#endif /* #if CONFIG_BT_MESH */

View File

@@ -6,53 +6,39 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include "mesh_hci.h"
#include "stack/bt_types.h"
#include "device/controller.h"
#include "sdkconfig.h"
#if CONFIG_BT_MESH
#include "stack/bt_types.h"
#include "device/controller.h"
struct bt_dev bt_dev;
#include "mesh_hci.h"
void mesh_hci_init(void)
struct bt_mesh_dev bt_mesh_dev;
void bt_mesh_hci_init(void)
{
const uint8_t *features = controller_get_interface()->get_features_ble()->as_array;
if (features != NULL) {
// We just copy the ble feature here, we don't care the classic bt feature in the ble mesh system.
memcpy(bt_dev.features[0], features, 8);
memcpy(bt_mesh_dev.features[0], features, 8);
memcpy(bt_mesh_dev.le.features, features, 8);
}
/**TODO: We support 20ms non-connectable adv interval, but not hci 5.0, so we need to add another flag
* to indicate if we support 20ms adv interval
* */
#ifdef CONFIG_HCI_5_0_VERSION
bt_dev.hci_version = BT_HCI_VERSION_5_0;
bt_mesh_dev.hci_version = BLE_MESH_HCI_VERSION_5_0;
#else
bt_dev.hci_version = controller_get_interface()->get_bt_version()->hci_version;
bt_mesh_dev.hci_version = controller_get_interface()->get_bt_version()->hci_version;
#endif
bt_dev.lmp_version = controller_get_interface()->get_bt_version()->lmp_version;
bt_dev.hci_revision = controller_get_interface()->get_bt_version()->hci_revision;
bt_dev.lmp_subversion = controller_get_interface()->get_bt_version()->lmp_subversion;
bt_dev.manufacturer = controller_get_interface()->get_bt_version()->manufacturer;
// Still to copy the features to the ble features struct.
memcpy(bt_dev.le.features, features, 8);
bt_mesh_dev.lmp_version = controller_get_interface()->get_bt_version()->lmp_version;
bt_mesh_dev.hci_revision = controller_get_interface()->get_bt_version()->hci_revision;
bt_mesh_dev.lmp_subversion = controller_get_interface()->get_bt_version()->lmp_subversion;
bt_mesh_dev.manufacturer = controller_get_interface()->get_bt_version()->manufacturer;
const uint8_t *p = controller_get_interface()->get_ble_supported_states();
uint64_t states_fh = 0, states_sh = 0;
// We don't have the STREAM_TO_UINT64 macro, so we should used stream to u32 two times add then put them together.
STREAM_TO_UINT32(states_fh, p);
STREAM_TO_UINT32(states_sh, p);
bt_dev.le.states = (states_sh << 32) | states_fh;
#if defined(CONFIG_BT_CONN)
bt_dev.le.mtu = controller_get_interface()->get_acl_data_size_ble();
#endif /* CONFIG_BT_CONN */
#if defined(CONFIG_BT_SMP)
bt_dev.le.rl_size = controller_get_interface()->get_ble_resolving_list_max_size();
#endif /* #if defined(CONFIG_BT_SMP) */
bt_mesh_dev.le.states = (states_sh << 32) | states_fh;
}
#endif /* #if CONFIG_BT_MESH */

View File

@@ -6,27 +6,29 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include <xtensa/xtruntime.h>
#include <errno.h>
#include "mesh_kernel.h"
#include "esp_timer.h"
#include "osi/hash_map.h"
#include "osi/alarm.h"
#include "common/bt_trace.h"
#include "common/bt_defs.h"
#include "osi/hash_functions.h"
#include "mesh_trace.h"
#include "sdkconfig.h"
#if CONFIG_BT_MESH
#include "osi/hash_map.h"
#include "osi/alarm.h"
#include "osi/hash_functions.h"
#include "common/bt_trace.h"
#include "common/bt_defs.h"
#include "esp_timer.h"
#include "mesh_kernel.h"
#include "mesh_trace.h"
#include "provisioner_prov.h"
static osi_mutex_t ble_mesh_alarm_lock;
static osi_mutex_t mesh_irq_lock;
static hash_map_t *ble_mesh_alarm_hash_map;
static const size_t BLE_MESH_GENERAL_ALARM_HASH_MAP_SIZE = 20 + CONFIG_BT_MESH_PBA_SAME_TIME + \
CONFIG_BT_MESH_PBG_SAME_TIME;
static osi_mutex_t bm_alarm_lock;
static osi_mutex_t bm_irq_lock;
static hash_map_t *bm_alarm_hash_map;
static const size_t BLE_MESH_GENERAL_ALARM_HASH_MAP_SIZE = 20 + CONFIG_BLE_MESH_PBA_SAME_TIME + \
CONFIG_BLE_MESH_PBG_SAME_TIME;
typedef struct alarm_t {
/* timer id point to here */
@@ -36,7 +38,7 @@ typedef struct alarm_t {
int64_t deadline_us;
} osi_alarm_t;
static void ble_mesh_alarm_cb(void *data)
static void bt_mesh_alarm_cb(void *data)
{
assert(data != NULL);
struct k_delayed_work *work = (struct k_delayed_work *)data;
@@ -44,27 +46,27 @@ static void ble_mesh_alarm_cb(void *data)
return;
}
unsigned int irq_lock(void)
unsigned int bt_mesh_irq_lock(void)
{
#if defined(CONFIG_BT_MESH_IRQ_LOCK) && CONFIG_BT_MESH_IRQ_LOCK
#if defined(CONFIG_BLE_MESH_IRQ_LOCK) && CONFIG_BLE_MESH_IRQ_LOCK
unsigned int key = XTOS_SET_INTLEVEL(XCHAL_EXCM_LEVEL);
return key;
#else /* !CONFIG_BT_MESH_IRQ_LOCK */
#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.
*/
osi_mutex_lock(&mesh_irq_lock, OSI_MUTEX_MAX_TIMEOUT);
osi_mutex_lock(&bm_irq_lock, OSI_MUTEX_MAX_TIMEOUT);
return 0;
#endif /*#if (CONFIG_BT_MESH_IRQ_LOCK) */
#endif
}
void irq_unlock(unsigned int key)
void bt_mesh_irq_unlock(unsigned int key)
{
#if defined(CONFIG_BT_MESH_IRQ_LOCK) && CONFIG_BT_MESH_IRQ_LOCK
#if defined(CONFIG_BLE_MESH_IRQ_LOCK) && CONFIG_BLE_MESH_IRQ_LOCK
XTOS_RESTORE_INTLEVEL(key);
#else /* !CONFIG_BT_MESH_IRQ_LOCK */
osi_mutex_unlock(&mesh_irq_lock);
#endif /*#if (CONFIG_BT_MESH_IRQ_LOCK) && CONFIG_BT_MESH_IRQ_LOCK */
#else
osi_mutex_unlock(&bm_irq_lock);
#endif
}
s64_t k_uptime_get(void)
@@ -89,40 +91,38 @@ void k_sleep(s32_t duration)
return;
}
void mesh_k_init(void)
void bt_mesh_k_init(void)
{
osi_mutex_new(&ble_mesh_alarm_lock);
osi_mutex_new(&mesh_irq_lock);
ble_mesh_alarm_hash_map = hash_map_new(BLE_MESH_GENERAL_ALARM_HASH_MAP_SIZE,
hash_function_pointer, NULL, (data_free_fn)osi_alarm_free, NULL);
assert(ble_mesh_alarm_hash_map != NULL);
osi_mutex_new(&bm_alarm_lock);
osi_mutex_new(&bm_irq_lock);
bm_alarm_hash_map = hash_map_new(BLE_MESH_GENERAL_ALARM_HASH_MAP_SIZE,
hash_function_pointer, NULL,
(data_free_fn)osi_alarm_free, NULL);
assert(bm_alarm_hash_map != NULL);
}
void k_delayed_work_init(struct k_delayed_work *work, k_work_handler_t handler)
{
assert(work != NULL && ble_mesh_alarm_hash_map != NULL);
k_work_init(&work->work, handler);
_init_timeout(&work->timeout, NULL);
work->work_q = NULL;
osi_alarm_t *alarm = NULL;
// Get the alarm for the timer list entry.
osi_mutex_lock(&ble_mesh_alarm_lock, OSI_MUTEX_MAX_TIMEOUT);
if (!hash_map_has_key(ble_mesh_alarm_hash_map, (void *)work)) {
alarm = osi_alarm_new("ble_mesh", ble_mesh_alarm_cb, (void *)work, 0);
assert(work != NULL && bm_alarm_hash_map != NULL);
k_work_init(&work->work, handler);
osi_mutex_lock(&bm_alarm_lock, OSI_MUTEX_MAX_TIMEOUT);
if (!hash_map_has_key(bm_alarm_hash_map, (void *)work)) {
alarm = osi_alarm_new("bt_mesh", bt_mesh_alarm_cb, (void *)work, 0);
if (alarm == NULL) {
LOG_ERROR("%s, Unable to create alarm", __func__);
return;
}
if (!hash_map_set(ble_mesh_alarm_hash_map, work, (void *)alarm)) {
LOG_ERROR("%s Unable to add the work timer to the mesh alarm hash map.", __func__);
if (!hash_map_set(bm_alarm_hash_map, work, (void *)alarm)) {
LOG_ERROR("%s Unable to add the timer to hash map.", __func__);
}
}
osi_mutex_unlock(&ble_mesh_alarm_lock);
osi_mutex_unlock(&bm_alarm_lock);
alarm = hash_map_get(ble_mesh_alarm_hash_map, work);
alarm = hash_map_get(bm_alarm_hash_map, work);
if (alarm == NULL) {
LOG_WARN("%s, Unable to find expected alarm in hash map", __func__);
return;
@@ -136,9 +136,9 @@ void k_delayed_work_init(struct k_delayed_work *work, k_work_handler_t handler)
int k_delayed_work_submit(struct k_delayed_work *work,
s32_t delay)
{
assert(work != NULL);
assert(work != NULL && bm_alarm_hash_map != NULL);
osi_alarm_t *alarm = hash_map_get(ble_mesh_alarm_hash_map, (void *)work);
osi_alarm_t *alarm = hash_map_get(bm_alarm_hash_map, (void *)work);
if (alarm == NULL) {
LOG_WARN("%s, Unable to find expected alarm in hash map", __func__);
return -EINVAL;
@@ -152,10 +152,9 @@ int k_delayed_work_submit(struct k_delayed_work *work,
int k_delayed_work_cancel(struct k_delayed_work *work)
{
assert(work != NULL);
assert(work != NULL && bm_alarm_hash_map != NULL);
// Check if the work have been store in the ble_mesh timer list or not.
osi_alarm_t *alarm = hash_map_get(ble_mesh_alarm_hash_map, (void *)work);
osi_alarm_t *alarm = hash_map_get(bm_alarm_hash_map, (void *)work);
if (alarm == NULL) {
LOG_WARN("%s, Unable to find expected alarm in hash map", __func__);
return -EINVAL;
@@ -168,24 +167,23 @@ int k_delayed_work_cancel(struct k_delayed_work *work)
int k_delayed_work_free(struct k_delayed_work *work)
{
assert(work != NULL);
assert(work != NULL && bm_alarm_hash_map != NULL);
// Get the alarm for the timer list entry.
osi_alarm_t *alarm = hash_map_get(ble_mesh_alarm_hash_map, work);
osi_alarm_t *alarm = hash_map_get(bm_alarm_hash_map, work);
if (alarm == NULL) {
LOG_WARN("%s Unable to find expected alarm in hash map", __func__);
return -EINVAL;
}
hash_map_erase(ble_mesh_alarm_hash_map, work);
hash_map_erase(bm_alarm_hash_map, work);
return 0;
}
s32_t k_delayed_work_remaining_get(struct k_delayed_work *work)
{
assert(work != NULL);
assert(work != NULL && bm_alarm_hash_map != NULL);
osi_alarm_t *alarm = hash_map_get(ble_mesh_alarm_hash_map, (void *)work);
osi_alarm_t *alarm = hash_map_get(bm_alarm_hash_map, (void *)work);
if (alarm == NULL) {
LOG_WARN("%s Unable to find expected alarm in hash map", __func__);
return 0;
@@ -205,35 +203,3 @@ s32_t k_delayed_work_remaining_get(struct k_delayed_work *work)
return remain_time;
}
void k_sem_give(struct k_sem *sem)
{
assert(sem != NULL);
osi_mutex_unlock(sem->mutex);
return;
}
void k_sem_init(struct k_sem *sem, unsigned int initial_count,
unsigned int limit)
{
assert(sem != NULL);
UNUSED(initial_count);
UNUSED(limit);
sem->mutex = xSemaphoreCreateBinary();
if (sem->mutex == NULL) {
LOG_WARN("%s, the mutex alloc fail", __func__);
return;
}
return;
}
int k_sem_take(struct k_sem *sem, s32_t timeout)
{
assert(sem != NULL);
return osi_mutex_lock(sem->mutex, timeout);
}
#endif /* #if CONFIG_BT_MESH */

View File

@@ -11,14 +11,15 @@
#include <errno.h>
#include <string.h>
#include "mesh_buf.h"
#include "sdkconfig.h"
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG)
#if CONFIG_BT_MESH
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG)
#include "mesh_buf.h"
#include "mesh_trace.h"
#include "mesh_main.h"
#include "mesh_hci.h"
#include "mesh.h"
#include "adv.h"
#include "prov.h"
#include "net.h"
@@ -29,8 +30,6 @@
#include "access.h"
#include "foundation.h"
#include "proxy.h"
#include "mesh.h"
#include "mesh_hci.h"
#include "settings.h"
#include "provisioner_prov.h"
#include "provisioner_proxy.h"
@@ -42,7 +41,7 @@ static volatile bool provisioner_en;
#define ACTION_SUSPEND 0x02
#define ACTION_EXIT 0x03
#if CONFIG_BT_MESH_NODE
#if CONFIG_BLE_MESH_NODE
int bt_mesh_provision(const u8_t net_key[16], u16_t net_idx,
u8_t flags, u32_t iv_index, u32_t seq,
@@ -55,13 +54,13 @@ int bt_mesh_provision(const u8_t net_key[16], u16_t net_idx,
net_idx, flags, iv_index);
BT_DBG("Device key: %s", bt_hex(dev_key, 16));
if (IS_ENABLED(CONFIG_BT_MESH_PB_GATT)) {
if (IS_ENABLED(CONFIG_BLE_MESH_PB_GATT)) {
bt_mesh_proxy_prov_disable();
}
err = bt_mesh_net_create(net_idx, flags, net_key, iv_index);
if (err) {
if (IS_ENABLED(CONFIG_BT_MESH_PB_GATT)) {
if (IS_ENABLED(CONFIG_BLE_MESH_PB_GATT)) {
bt_mesh_proxy_prov_enable();
}
@@ -74,13 +73,13 @@ int bt_mesh_provision(const u8_t net_key[16], u16_t net_idx,
memcpy(bt_mesh.dev_key, dev_key, 16);
if (bt_mesh_beacon_get() == BT_MESH_BEACON_ENABLED) {
if (bt_mesh_beacon_get() == BLE_MESH_BEACON_ENABLED) {
bt_mesh_beacon_enable();
} else {
bt_mesh_beacon_disable();
}
if (IS_ENABLED(CONFIG_BT_MESH_SETTINGS)) {
if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) {
BT_DBG("Storing network information persistently");
bt_mesh_store_net();
bt_mesh_store_subnet(&bt_mesh.sub[0]);
@@ -88,8 +87,8 @@ int bt_mesh_provision(const u8_t net_key[16], u16_t net_idx,
}
BT_DBG("%s, gatt_proxy = %d", __func__, bt_mesh_gatt_proxy_get());
if (IS_ENABLED(CONFIG_BT_MESH_GATT_PROXY) &&
bt_mesh_gatt_proxy_get() != BT_MESH_GATT_PROXY_NOT_SUPPORTED) {
if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY) &&
bt_mesh_gatt_proxy_get() != BLE_MESH_GATT_PROXY_NOT_SUPPORTED) {
bt_mesh_proxy_gatt_enable();
bt_mesh_adv_update();
}
@@ -97,28 +96,28 @@ int bt_mesh_provision(const u8_t net_key[16], u16_t net_idx,
/* Add this to avoid "already active status" for bt_mesh_scan_enable() */
bt_mesh_scan_disable();
#if defined(CONFIG_BT_MESH_USE_DUPLICATE_SCAN)
#if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN)
/* Add Mesh beacon type (Secure Network Beacon) to the exceptional list */
bt_mesh_update_exceptional_list(BT_MESH_EXCEP_LIST_ADD,
BT_MESH_EXCEP_INFO_MESH_BEACON, NULL);
bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_ADD,
BLE_MESH_EXCEP_INFO_MESH_BEACON, NULL);
#endif
if (IS_ENABLED(CONFIG_BT_MESH_LOW_POWER)) {
if (IS_ENABLED(CONFIG_BLE_MESH_LOW_POWER)) {
/* TODO: Enable duplicate scan in Low Power Mode */
bt_mesh_lpn_init();
} else {
#if defined(CONFIG_BT_MESH_USE_DUPLICATE_SCAN)
#if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN)
bt_mesh_duplicate_scan_enable();
#else
bt_mesh_scan_enable();
#endif
}
if (IS_ENABLED(CONFIG_BT_MESH_FRIEND)) {
if (IS_ENABLED(CONFIG_BLE_MESH_FRIEND)) {
bt_mesh_friend_init();
}
if (IS_ENABLED(CONFIG_BT_MESH_PROV)) {
if (IS_ENABLED(CONFIG_BLE_MESH_PROV)) {
bt_mesh_prov_complete(net_idx, addr, flags, iv_index);
}
@@ -128,7 +127,7 @@ int bt_mesh_provision(const u8_t net_key[16], u16_t net_idx,
void bt_mesh_reset(void)
{
if (!bt_mesh.valid) {
BT_WARN("%s: not provisioned", __func__);
BT_WARN("%s, Not provisioned", __func__);
return;
}
@@ -149,20 +148,20 @@ void bt_mesh_reset(void)
bt_mesh_rx_reset();
bt_mesh_tx_reset();
if (IS_ENABLED(CONFIG_BT_MESH_LOW_POWER)) {
if (IS_ENABLED(CONFIG_BLE_MESH_LOW_POWER)) {
bt_mesh_lpn_disable(true);
}
if (IS_ENABLED(CONFIG_BT_MESH_FRIEND)) {
bt_mesh_friend_clear_net_idx(BT_MESH_KEY_ANY);
if (IS_ENABLED(CONFIG_BLE_MESH_FRIEND)) {
bt_mesh_friend_clear_net_idx(BLE_MESH_KEY_ANY);
}
if (IS_ENABLED(CONFIG_BT_MESH_GATT_PROXY)) {
if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY)) {
bt_mesh_proxy_gatt_disable();
}
#if defined(CONFIG_BT_MESH_SETTINGS)
if (IS_ENABLED(CONFIG_BT_MESH_SETTINGS)) {
#if defined(CONFIG_BLE_MESH_SETTINGS)
if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) {
bt_mesh_clear_net();
}
#endif
@@ -173,7 +172,7 @@ void bt_mesh_reset(void)
bt_mesh_scan_disable();
bt_mesh_beacon_disable();
if (IS_ENABLED(CONFIG_BT_MESH_PROV)) {
if (IS_ENABLED(CONFIG_BLE_MESH_PROV)) {
bt_mesh_prov_reset();
}
}
@@ -189,10 +188,10 @@ int bt_mesh_prov_enable(bt_mesh_prov_bearer_t bearers)
return -EALREADY;
}
if (IS_ENABLED(CONFIG_BT_MESH_PB_ADV) &&
(bearers & BT_MESH_PROV_ADV)) {
if (IS_ENABLED(CONFIG_BLE_MESH_PB_ADV) &&
(bearers & BLE_MESH_PROV_ADV)) {
/* Make sure the scanning is for provisioning invitations */
#if defined(CONFIG_BT_MESH_USE_DUPLICATE_SCAN)
#if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN)
bt_mesh_duplicate_scan_enable();
#else
bt_mesh_scan_enable();
@@ -201,8 +200,8 @@ int bt_mesh_prov_enable(bt_mesh_prov_bearer_t bearers)
bt_mesh_beacon_enable();
}
if (IS_ENABLED(CONFIG_BT_MESH_PB_GATT) &&
(bearers & BT_MESH_PROV_GATT)) {
if (IS_ENABLED(CONFIG_BLE_MESH_PB_GATT) &&
(bearers & BLE_MESH_PROV_GATT)) {
bt_mesh_proxy_prov_enable();
bt_mesh_adv_update();
}
@@ -218,14 +217,14 @@ int bt_mesh_prov_disable(bt_mesh_prov_bearer_t bearers)
return -EALREADY;
}
if (IS_ENABLED(CONFIG_BT_MESH_PB_ADV) &&
(bearers & BT_MESH_PROV_ADV)) {
if (IS_ENABLED(CONFIG_BLE_MESH_PB_ADV) &&
(bearers & BLE_MESH_PROV_ADV)) {
bt_mesh_beacon_disable();
bt_mesh_scan_disable();
}
if (IS_ENABLED(CONFIG_BT_MESH_PB_GATT) &&
(bearers & BT_MESH_PROV_GATT)) {
if (IS_ENABLED(CONFIG_BLE_MESH_PB_GATT) &&
(bearers & BLE_MESH_PROV_GATT)) {
bt_mesh_proxy_prov_disable();
bt_mesh_adv_update();
}
@@ -233,62 +232,62 @@ int bt_mesh_prov_disable(bt_mesh_prov_bearer_t bearers)
return 0;
}
#endif /* CONFIG_BT_MESH_NODE */
#endif /* CONFIG_BLE_MESH_NODE */
bool bt_mesh_is_provisioner_en(void)
{
return provisioner_en;
}
#if CONFIG_BT_MESH_PROVISIONER
#if CONFIG_BLE_MESH_PROVISIONER
int bt_mesh_provisioner_enable(bt_mesh_prov_bearer_t bearers)
{
int err;
if (bt_mesh_is_provisioner_en()) {
BT_ERR("Provisioner already enabled");
BT_WARN("%s, Provisioner is already enabled", __func__);
return -EALREADY;
}
err = provisioner_upper_init();
if (err) {
BT_ERR("%s: provisioner_upper_init fail", __func__);
BT_ERR("%s, provisioner_upper_init fail", __func__);
return err;
}
#if defined(CONFIG_BT_MESH_USE_DUPLICATE_SCAN)
if (IS_ENABLED(CONFIG_BT_MESH_PB_ADV) &&
(bearers & BT_MESH_PROV_ADV)) {
bt_mesh_update_exceptional_list(BT_MESH_EXCEP_LIST_ADD,
BT_MESH_EXCEP_INFO_MESH_BEACON, NULL);
#if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN)
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);
}
if (IS_ENABLED(CONFIG_BT_MESH_PB_GATT) &&
(bearers & BT_MESH_PROV_GATT)) {
bt_mesh_update_exceptional_list(BT_MESH_EXCEP_LIST_ADD,
BT_MESH_EXCEP_INFO_MESH_PROV_ADV, 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);
}
if (IS_ENABLED(CONFIG_BT_MESH_PROXY)) {
bt_mesh_update_exceptional_list(BT_MESH_EXCEP_LIST_ADD,
BT_MESH_EXCEP_INFO_MESH_PROXY_ADV, NULL);
if (IS_ENABLED(CONFIG_BLE_MESH_PROXY)) {
bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_ADD,
BLE_MESH_EXCEP_INFO_MESH_PROXY_ADV, NULL);
}
#endif
if ((IS_ENABLED(CONFIG_BT_MESH_PB_ADV) &&
(bearers & BT_MESH_PROV_ADV)) ||
(IS_ENABLED(CONFIG_BT_MESH_PB_GATT) &&
(bearers & BT_MESH_PROV_GATT))) {
#if defined(CONFIG_BT_MESH_USE_DUPLICATE_SCAN)
if ((IS_ENABLED(CONFIG_BLE_MESH_PB_ADV) &&
(bearers & BLE_MESH_PROV_ADV)) ||
(IS_ENABLED(CONFIG_BLE_MESH_PB_GATT) &&
(bearers & BLE_MESH_PROV_GATT))) {
#if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN)
bt_mesh_duplicate_scan_enable();
#else
bt_mesh_scan_enable();
#endif
}
if (IS_ENABLED(CONFIG_BT_MESH_PB_GATT) &&
(bearers & BT_MESH_PROV_GATT)) {
if (IS_ENABLED(CONFIG_BLE_MESH_PB_GATT) &&
(bearers & BLE_MESH_PROV_GATT)) {
provisioner_pb_gatt_enable();
}
@@ -300,19 +299,19 @@ int bt_mesh_provisioner_enable(bt_mesh_prov_bearer_t bearers)
int bt_mesh_provisioner_disable(bt_mesh_prov_bearer_t bearers)
{
if (!bt_mesh_is_provisioner_en()) {
BT_ERR("Provisioner already disabled");
BT_WARN("%s, Provisioner is already disabled", __func__);
return -EALREADY;
}
if (IS_ENABLED(CONFIG_BT_MESH_PB_GATT) &&
(bearers & BT_MESH_PROV_GATT)) {
if (IS_ENABLED(CONFIG_BLE_MESH_PB_GATT) &&
(bearers & BLE_MESH_PROV_GATT)) {
provisioner_pb_gatt_disable();
}
if ((IS_ENABLED(CONFIG_BT_MESH_PB_ADV) &&
(bearers & BT_MESH_PROV_ADV)) &&
(IS_ENABLED(CONFIG_BT_MESH_PB_GATT) &&
(bearers & BT_MESH_PROV_GATT))) {
if ((IS_ENABLED(CONFIG_BLE_MESH_PB_ADV) &&
(bearers & BLE_MESH_PROV_ADV)) &&
(IS_ENABLED(CONFIG_BLE_MESH_PB_GATT) &&
(bearers & BLE_MESH_PROV_GATT))) {
bt_mesh_scan_disable();
}
@@ -321,11 +320,11 @@ int bt_mesh_provisioner_disable(bt_mesh_prov_bearer_t bearers)
return 0;
}
#endif /* CONFIG_BT_MESH_PROVISIONER */
#endif /* CONFIG_BLE_MESH_PROVISIONER */
/* The following API is for fast provisioning */
#if CONFIG_BT_MESH_FAST_PROV
#if CONFIG_BLE_MESH_FAST_PROV
u8_t bt_mesh_set_fast_prov_action(u8_t action)
{
@@ -335,7 +334,7 @@ u8_t bt_mesh_set_fast_prov_action(u8_t action)
if ((!provisioner_en && (action == ACTION_SUSPEND || action == ACTION_EXIT)) ||
(provisioner_en && (action == ACTION_ENTER))) {
BT_WARN("%s: action is already done", __func__);
BT_WARN("%s, Action is already done", __func__);
return 0x0;
}
@@ -346,29 +345,29 @@ u8_t bt_mesh_set_fast_prov_action(u8_t action)
* here. The node needs to send some status messages to the phone
* while it is connected.
*/
if (IS_ENABLED(CONFIG_BT_MESH_GATT_PROXY)) {
if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY)) {
bt_mesh_proxy_gatt_disable();
}
#endif
if (bt_mesh_beacon_get() == BT_MESH_BEACON_ENABLED) {
if (bt_mesh_beacon_get() == BLE_MESH_BEACON_ENABLED) {
bt_mesh_beacon_disable();
}
if (IS_ENABLED(CONFIG_BT_MESH_PB_GATT)) {
if (IS_ENABLED(CONFIG_BLE_MESH_PB_GATT)) {
provisioner_pb_gatt_enable();
}
provisioner_set_fast_prov_flag(true);
provisioner_en = true;
} else {
if (IS_ENABLED(CONFIG_BT_MESH_PB_GATT)) {
if (IS_ENABLED(CONFIG_BLE_MESH_PB_GATT)) {
provisioner_pb_gatt_disable();
}
if (bt_mesh_beacon_get() == BT_MESH_BEACON_ENABLED) {
if (bt_mesh_beacon_get() == BLE_MESH_BEACON_ENABLED) {
bt_mesh_beacon_enable();
}
#if 0
/* Mesh Proxy GATT will be re-enabled on application layer */
if (IS_ENABLED(CONFIG_BT_MESH_GATT_PROXY) &&
bt_mesh_gatt_proxy_get() != BT_MESH_GATT_PROXY_NOT_SUPPORTED) {
if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY) &&
bt_mesh_gatt_proxy_get() != BLE_MESH_GATT_PROXY_NOT_SUPPORTED) {
bt_mesh_proxy_gatt_enable();
bt_mesh_adv_update();
}
@@ -384,22 +383,16 @@ u8_t bt_mesh_set_fast_prov_action(u8_t action)
return 0x0;
}
#endif /* CONFIG_BT_MESH_FAST_PROV */
#endif /* CONFIG_BLE_MESH_FAST_PROV */
int bt_mesh_init(const struct bt_mesh_prov *prov,
const struct bt_mesh_comp *comp)
{
int err;
//err = bt_mesh_test();
//if (err) {
// return err;
//}
bt_mesh_k_init();
// The mesh kernel should be initialized first.
mesh_k_init();
mesh_hci_init();
bt_mesh_hci_init();
bt_mesh_adapt_init();
@@ -414,29 +407,29 @@ int bt_mesh_init(const struct bt_mesh_prov *prov,
/** Register service in the init function,
* then start it according to bt_mesh_proxy_gatt_enable
*/
#if CONFIG_BT_MESH_NODE
extern struct bt_gatt_service proxy_svc;
if (IS_ENABLED(CONFIG_BT_MESH_GATT_PROXY)) {
#if CONFIG_BLE_MESH_NODE
extern struct bt_mesh_gatt_service proxy_svc;
if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY)) {
bt_mesh_gatts_service_register(&proxy_svc);
}
/** Register service in the init function,
* then start it according to bt_mesh_proxy_prov_enable
*/
extern struct bt_gatt_service prov_svc;
if (IS_ENABLED(CONFIG_BT_MESH_PB_GATT)) {
extern struct bt_mesh_gatt_service prov_svc;
if (IS_ENABLED(CONFIG_BLE_MESH_PB_GATT)) {
bt_mesh_gatts_service_register(&prov_svc);
}
#endif
if (IS_ENABLED(CONFIG_BT_MESH_PROV)) {
#if CONFIG_BT_MESH_NODE
if (IS_ENABLED(CONFIG_BLE_MESH_PROV)) {
#if CONFIG_BLE_MESH_NODE
err = bt_mesh_prov_init(prov);
if (err) {
return err;
}
#endif
#if CONFIG_BT_MESH_PROVISIONER
#if CONFIG_BLE_MESH_PROVISIONER
err = provisioner_prov_init(prov);
if (err) {
return err;
@@ -446,27 +439,29 @@ int bt_mesh_init(const struct bt_mesh_prov *prov,
bt_mesh_net_init();
bt_mesh_trans_init();
#if CONFIG_BT_MESH_NODE
#if CONFIG_BLE_MESH_NODE
/* Changed by Espressif, add random delay (0 ~ 3s) */
#if defined(CONFIG_BT_MESH_FAST_PROV)
#if defined(CONFIG_BLE_MESH_FAST_PROV)
u32_t delay = 0;
bt_mesh_rand(&delay, sizeof(u32_t));
vTaskDelay((delay % 3000) / portTICK_PERIOD_MS);
#endif
bt_mesh_beacon_init();
#endif
bt_mesh_adv_init();
if (IS_ENABLED(CONFIG_BT_MESH_PROXY)) {
#if CONFIG_BT_MESH_NODE
if (IS_ENABLED(CONFIG_BLE_MESH_PROXY)) {
#if CONFIG_BLE_MESH_NODE
bt_mesh_proxy_init();
#endif
#if CONFIG_BT_MESH_PROVISIONER
#if CONFIG_BLE_MESH_PROVISIONER
provisioner_proxy_init();
#endif
}
#if !CONFIG_BT_MESH_NODE && CONFIG_BT_MESH_PROVISIONER
#if !CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PROVISIONER
/* If node & provisioner are both enabled and the
* device starts as a node, it must finish provisioning */
err = provisioner_upper_init();
@@ -475,13 +470,11 @@ int bt_mesh_init(const struct bt_mesh_prov *prov,
}
#endif
#if defined(CONFIG_BT_MESH_SETTINGS)
if (IS_ENABLED(CONFIG_BT_MESH_SETTINGS)) {
#if defined(CONFIG_BLE_MESH_SETTINGS)
if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) {
bt_mesh_settings_init();
}
#endif
return 0;
}
#endif /* #if CONFIG_BT_MESH */

View File

@@ -1,317 +0,0 @@
/*
* Copyright (c) 2016 Intel Corporation
* Additional Copyright (c) 2018 Espressif Systems (Shanghai) PTE LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "mesh_slist.h"
#include "sdkconfig.h"
#if CONFIG_BT_MESH
static sys_slist_t test_list;
struct container_node {
sys_snode_t node;
int unused;
};
static struct container_node test_node_1;
static struct container_node test_node_2;
static struct container_node test_node_3;
static struct container_node test_node_4;
static inline bool verify_emptyness(sys_slist_t *list)
{
sys_snode_t *node;
sys_snode_t *s_node;
struct container_node *cnode;
struct container_node *s_cnode;
int count;
if (!sys_slist_is_empty(list)) {
return false;
}
if (sys_slist_peek_head(list)) {
return false;
}
if (sys_slist_peek_tail(list)) {
return false;
}
count = 0;
SYS_SLIST_FOR_EACH_NODE(list, node) {
count++;
}
if (count) {
return false;
}
SYS_SLIST_FOR_EACH_NODE_SAFE(list, node, s_node) {
count++;
}
if (count) {
return false;
}
count = 0;
SYS_SLIST_FOR_EACH_CONTAINER(list, cnode, node) {
count++;
}
if (count) {
return false;
}
count = 0;
SYS_SLIST_FOR_EACH_CONTAINER_SAFE(list, cnode, s_cnode, node) {
count++;
}
if (count) {
return false;
}
return true;
}
static inline bool verify_content_amount(sys_slist_t *list, int amount)
{
sys_snode_t *node;
sys_snode_t *s_node;
struct container_node *cnode;
struct container_node *s_cnode;
int count;
if (sys_slist_is_empty(list)) {
return false;
}
if (!sys_slist_peek_head(list)) {
return false;
}
if (!sys_slist_peek_tail(list)) {
return false;
}
count = 0;
SYS_SLIST_FOR_EACH_NODE(list, node) {
count++;
}
if (count != amount) {
return false;
}
count = 0;
SYS_SLIST_FOR_EACH_NODE_SAFE(list, node, s_node) {
count++;
}
if (count != amount) {
return false;
}
count = 0;
SYS_SLIST_FOR_EACH_CONTAINER(list, cnode, node) {
count++;
}
if (count != amount) {
return false;
}
count = 0;
SYS_SLIST_FOR_EACH_CONTAINER_SAFE(list, cnode, s_cnode, node) {
count++;
}
if (count != amount) {
return false;
}
return true;
}
static inline bool verify_tail_head(sys_slist_t *list,
sys_snode_t *head,
sys_snode_t *tail,
bool same)
{
if (sys_slist_peek_head(list) != head) {
return false;
}
if (sys_slist_peek_tail(list) != tail) {
return false;
}
if (same) {
if (sys_slist_peek_head(list) != sys_slist_peek_tail(list)) {
return false;
}
} else {
if (sys_slist_peek_head(list) == sys_slist_peek_tail(list)) {
return false;
}
}
return true;
}
void slist_test(void)
{
sys_slist_init(&test_list);
//zassert_true((verify_emptyness(&test_list)), "test_list should be empty");
/* Appending node 1 */
sys_slist_append(&test_list, &test_node_1.node);
//zassert_true((verify_content_amount(&test_list, 1)),
// "test_list has wrong content");
//zassert_true((verify_tail_head(&test_list, &test_node_1.node,
// &test_node_1.node, true)),
// "test_list head/tail are wrong");
/* Finding and removing node 1 */
sys_slist_find_and_remove(&test_list, &test_node_1.node);
//zassert_true((verify_emptyness(&test_list)),
// "test_list should be empty");
/* Prepending node 1 */
sys_slist_prepend(&test_list, &test_node_1.node);
//zassert_true((verify_content_amount(&test_list, 1)),
// "test_list has wrong content");
//zassert_true((verify_tail_head(&test_list, &test_node_1.node,
// &test_node_1.node, true)),
// "test_list head/tail are wrong");
/* Removing node 1 */
sys_slist_remove(&test_list, NULL, &test_node_1.node);
//zassert_true((verify_emptyness(&test_list)),
// "test_list should be empty");
/* Appending node 1 */
sys_slist_append(&test_list, &test_node_1.node);
/* Prepending node 2 */
sys_slist_prepend(&test_list, &test_node_2.node);
//zassert_true((verify_content_amount(&test_list, 2)),
// "test_list has wrong content");
//zassert_true((verify_tail_head(&test_list, &test_node_2.node,
// &test_node_1.node, false)),
// "test_list head/tail are wrong");
/* Appending node 3 */
sys_slist_append(&test_list, &test_node_3.node);
//zassert_true((verify_content_amount(&test_list, 3)),
// "test_list has wrong content");
//zassert_true((verify_tail_head(&test_list, &test_node_2.node,
// &test_node_3.node, false)),
// "test_list head/tail are wrong");
//zassert_true((sys_slist_peek_next(&test_node_2.node) ==
// &test_node_1.node),
// "test_list node links are wrong");
/* Inserting node 4 after node 2 */
sys_slist_insert(&test_list, &test_node_2.node, &test_node_4.node);
//zassert_true((verify_tail_head(&test_list, &test_node_2.node,
// &test_node_3.node, false)),
// "test_list head/tail are wrong");
//zassert_true((sys_slist_peek_next(&test_node_2.node) ==
// &test_node_4.node),
// "test_list node links are wrong");
/* Finding and removing node 1 */
sys_slist_find_and_remove(&test_list, &test_node_1.node);
//zassert_true((verify_content_amount(&test_list, 3)),
// "test_list has wrong content");
//zassert_true((verify_tail_head(&test_list, &test_node_2.node,
// &test_node_3.node, false)),
// "test_list head/tail are wrong");
/* Removing node 3 */
sys_slist_remove(&test_list, &test_node_4.node, &test_node_3.node);
//zassert_true((verify_content_amount(&test_list, 2)),
// "test_list has wrong content");
//zassert_true((verify_tail_head(&test_list, &test_node_2.node,
// &test_node_4.node, false)),
// "test_list head/tail are wrong");
/* Removing node 4 */
sys_slist_remove(&test_list, &test_node_2.node, &test_node_4.node);
//zassert_true((verify_content_amount(&test_list, 1)),
// "test_list has wrong content");
//zassert_true((verify_tail_head(&test_list, &test_node_2.node,
// &test_node_2.node, true)),
// "test_list head/tail are wrong");
/* Removing node 2 */
sys_slist_remove(&test_list, NULL, &test_node_2.node);
//zassert_true((verify_emptyness(&test_list)),
// "test_list should be empty");
/* test iterator from a node */
struct data_node {
sys_snode_t node;
int data;
} data_node[6] = {
{ .data = 0 },
{ .data = 1 },
{ .data = 2 },
{ .data = 3 },
{ .data = 4 },
{ .data = 5 },
};
sys_snode_t *node = NULL;
int ii;
sys_slist_init(&test_list);
for (ii = 0; ii < 6; ii++) {
sys_slist_append(&test_list, &data_node[ii].node);
}
ii = 0;
SYS_SLIST_ITERATE_FROM_NODE(&test_list, node) {
ii++;
if (((struct data_node *)node)->data == 2) {
break;
}
}
//zassert_equal(ii, 3, "");
ii = 0;
SYS_SLIST_ITERATE_FROM_NODE(&test_list, node) {
ii++;
if (((struct data_node *)node)->data == 3) {
break;
}
}
//zassert_equal(ii, 1, "");
ii = 0;
SYS_SLIST_ITERATE_FROM_NODE(&test_list, node) {
ii++;
}
//zassert_equal(ii, 2, "");
}
#endif /* #if CONFIG_BT_MESH */

View File

@@ -8,7 +8,6 @@
#include <string.h>
#include "sdkconfig.h"
#if CONFIG_BT_MESH
#include "mesh_util.h"
#include "mesh_kernel.h"
#include "mesh_aes_encrypt.h"
@@ -25,12 +24,12 @@ const char *bt_hex(const void *buf, size_t len)
char *str;
int i;
mask = irq_lock();
mask = bt_mesh_irq_lock();
str = hexbufs[curbuf++];
curbuf %= ARRAY_SIZE(hexbufs);
irq_unlock(mask);
bt_mesh_irq_unlock(mask);
len = min(len, (sizeof(hexbufs[0]) - 1) / 2);
len = MIN(len, (sizeof(hexbufs[0]) - 1) / 2);
for (i = 0; i < len; i++) {
str[i * 2] = hex[b[i] >> 4];
@@ -85,5 +84,3 @@ int _compare(const uint8_t *a, const uint8_t *b, size_t size)
}
return result;
}
#endif /* #if CONFIG_BT_MESH */

View File

@@ -10,20 +10,18 @@
#include <string.h>
#include <errno.h>
#include <stdbool.h>
#include "mesh_util.h"
#include "mesh_buf.h"
#include "sdkconfig.h"
#if CONFIG_BT_MESH
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_NET)
#include "mesh_util.h"
#include "mesh_buf.h"
#include "mesh_main.h"
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_NET)
#include "mesh_trace.h"
#include "mesh.h"
#include "crypto.h"
#include "adv.h"
#include "mesh.h"
#include "net.h"
#include "lpn.h"
#include "friend.h"
@@ -34,8 +32,7 @@
#include "beacon.h"
#include "settings.h"
#include "prov.h"
#include "common.h"
#include "provisioner_main.h"
/* Minimum valid Mesh Network PDU length. The Network headers
* themselves take up 9 bytes. After that there is a minumum of 1 byte
@@ -43,55 +40,55 @@
* PDUs must use a 64-bit (8 byte) NetMIC, whereas CTL=0 PDUs have at least
* a 32-bit (4 byte) NetMIC and AppMIC giving again a total of 8 bytes.
*/
#define BT_MESH_NET_MIN_PDU_LEN (BT_MESH_NET_HDR_LEN + 1 + 8)
#define BLE_MESH_NET_MIN_PDU_LEN (BLE_MESH_NET_HDR_LEN + 1 + 8)
/* Seq limit after IV Update is triggered */
#define IV_UPDATE_SEQ_LIMIT 8000000
#define IV_UPDATE_SEQ_LIMIT 8000000
#if defined(CONFIG_BT_MESH_IV_UPDATE_TEST)
#if defined(CONFIG_BLE_MESH_IV_UPDATE_TEST)
/* Small test timeout for IV Update Procedure testing */
#define IV_UPDATE_TIMEOUT K_SECONDS(120)
#define IV_UPDATE_TIMEOUT K_SECONDS(120)
#else
/* Maximum time to stay in IV Update mode (96 < time < 144) */
#define IV_UPDATE_TIMEOUT K_HOURS(120)
#endif /* CONFIG_BT_MESH_IV_UPDATE_TEST */
#define IV_UPDATE_TIMEOUT K_HOURS(120)
#endif /* CONFIG_BLE_MESH_IV_UPDATE_TEST */
#define IVI(pdu) ((pdu)[0] >> 7)
#define NID(pdu) ((pdu)[0] & 0x7f)
#define CTL(pdu) ((pdu)[1] >> 7)
#define TTL(pdu) ((pdu)[1] & 0x7f)
#define SEQ(pdu) (((u32_t)(pdu)[2] << 16) | \
((u32_t)(pdu)[3] << 8) | (u32_t)(pdu)[4]);
((u32_t)(pdu)[3] << 8) | (u32_t)(pdu)[4]);
#define SRC(pdu) (sys_get_be16(&(pdu)[5]))
#define DST(pdu) (sys_get_be16(&(pdu)[7]))
/* Determine how many friendship credentials are needed */
#if defined(CONFIG_BT_MESH_FRIEND)
#define FRIEND_CRED_COUNT CONFIG_BT_MESH_FRIEND_LPN_COUNT
#elif defined(CONFIG_BT_MESH_LOW_POWER)
#define FRIEND_CRED_COUNT CONFIG_BT_MESH_SUBNET_COUNT
#if defined(CONFIG_BLE_MESH_FRIEND)
#define FRIEND_CRED_COUNT CONFIG_BLE_MESH_FRIEND_LPN_COUNT
#elif defined(CONFIG_BLE_MESH_LOW_POWER)
#define FRIEND_CRED_COUNT CONFIG_BLE_MESH_SUBNET_COUNT
#else
#define FRIEND_CRED_COUNT 0
#define FRIEND_CRED_COUNT 0
#endif
#if FRIEND_CRED_COUNT > 0
static struct friend_cred friend_cred[FRIEND_CRED_COUNT];
#endif
static u64_t msg_cache[CONFIG_BT_MESH_MSG_CACHE_SIZE];
static u64_t msg_cache[CONFIG_BLE_MESH_MSG_CACHE_SIZE];
static u16_t msg_cache_next;
/* Singleton network context (the implementation only supports one) */
struct bt_mesh_net bt_mesh = {
.local_queue = SYS_SLIST_STATIC_INIT(&bt_mesh.local_queue),
.sub = {
[0 ... (CONFIG_BT_MESH_SUBNET_COUNT - 1)] = {
.net_idx = BT_MESH_KEY_UNUSED,
[0 ... (CONFIG_BLE_MESH_SUBNET_COUNT - 1)] = {
.net_idx = BLE_MESH_KEY_UNUSED,
}
},
.app_keys = {
[0 ... (CONFIG_BT_MESH_APP_KEY_COUNT - 1)] = {
.net_idx = BT_MESH_KEY_UNUSED,
[0 ... (CONFIG_BLE_MESH_APP_KEY_COUNT - 1)] = {
.net_idx = BLE_MESH_KEY_UNUSED,
}
},
};
@@ -124,7 +121,7 @@ static u64_t msg_hash(struct bt_mesh_net_rx *rx, struct net_buf_simple *pdu)
u32_t hash1, hash2;
/* Three least significant bytes of IVI + first byte of SEQ */
hash1 = (BT_MESH_NET_IVI_RX(rx) << 8) | pdu->data[2];
hash1 = (BLE_MESH_NET_IVI_RX(rx) << 8) | pdu->data[2];
/* Two last bytes of SEQ + SRC */
memcpy(&hash2, &pdu->data[3], 4);
@@ -155,7 +152,7 @@ struct bt_mesh_subnet *bt_mesh_subnet_get(u16_t net_idx)
{
int i;
if (net_idx == BT_MESH_KEY_ANY) {
if (net_idx == BLE_MESH_KEY_ANY) {
return &bt_mesh.sub[0];
}
@@ -177,7 +174,7 @@ int bt_mesh_net_keys_create(struct bt_mesh_subnet_keys *keys,
err = bt_mesh_k2(key, p, sizeof(p), &nid, keys->enc, keys->privacy);
if (err) {
BT_ERR("Unable to generate NID, EncKey & PrivacyKey");
BT_ERR("%s, Unable to generate NID, EncKey & PrivacyKey", __func__);
return err;
}
@@ -190,16 +187,16 @@ int bt_mesh_net_keys_create(struct bt_mesh_subnet_keys *keys,
err = bt_mesh_k3(key, keys->net_id);
if (err) {
BT_ERR("Unable to generate Net ID");
BT_ERR("%s, Unable to generate Net ID", __func__);
return err;
}
BT_DBG("NetID %s", bt_hex(keys->net_id, 8));
#if defined(CONFIG_BT_MESH_GATT_PROXY)
#if defined(CONFIG_BLE_MESH_GATT_PROXY)
err = bt_mesh_identity_key(key, keys->identity);
if (err) {
BT_ERR("Unable to generate IdentityKey");
BT_ERR("%s, Unable to generate IdentityKey", __func__);
return err;
}
@@ -208,7 +205,7 @@ int bt_mesh_net_keys_create(struct bt_mesh_subnet_keys *keys,
err = bt_mesh_beacon_key(key, keys->beacon);
if (err) {
BT_ERR("Unable to generate beacon key");
BT_ERR("%s, Unable to generate beacon key", __func__);
return err;
}
@@ -217,15 +214,14 @@ int bt_mesh_net_keys_create(struct bt_mesh_subnet_keys *keys,
return 0;
}
#if (defined(CONFIG_BT_MESH_LOW_POWER) || \
defined(CONFIG_BT_MESH_FRIEND))
#if (defined(CONFIG_BLE_MESH_LOW_POWER) || defined(CONFIG_BLE_MESH_FRIEND))
int friend_cred_set(struct friend_cred *cred, u8_t idx, const u8_t net_key[16])
{
u16_t lpn_addr, frnd_addr;
int err;
u8_t p[9];
#if defined(CONFIG_BT_MESH_LOW_POWER)
#if defined(CONFIG_BLE_MESH_LOW_POWER)
if (cred->addr == bt_mesh.lpn.frnd) {
lpn_addr = bt_mesh_primary_addr();
frnd_addr = cred->addr;
@@ -251,7 +247,7 @@ int friend_cred_set(struct friend_cred *cred, u8_t idx, const u8_t net_key[16])
err = bt_mesh_k2(net_key, p, sizeof(p), &cred->cred[idx].nid,
cred->cred[idx].enc, cred->cred[idx].privacy);
if (err) {
BT_ERR("Unable to generate NID, EncKey & PrivacyKey");
BT_ERR("%s, Unable to generate NID, EncKey & PrivacyKey", __func__);
return err;
}
@@ -269,7 +265,7 @@ void friend_cred_refresh(u16_t net_idx)
for (i = 0; i < ARRAY_SIZE(friend_cred); i++) {
struct friend_cred *cred = &friend_cred[i];
if (cred->addr != BT_MESH_ADDR_UNASSIGNED &&
if (cred->addr != BLE_MESH_ADDR_UNASSIGNED &&
cred->net_idx == net_idx) {
memcpy(&cred->cred[0], &cred->cred[1],
sizeof(cred->cred[0]));
@@ -286,7 +282,7 @@ int friend_cred_update(struct bt_mesh_subnet *sub)
for (i = 0; i < ARRAY_SIZE(friend_cred); i++) {
struct friend_cred *cred = &friend_cred[i];
if (cred->addr == BT_MESH_ADDR_UNASSIGNED ||
if (cred->addr == BLE_MESH_ADDR_UNASSIGNED ||
cred->net_idx != sub->net_idx) {
continue;
}
@@ -309,7 +305,7 @@ struct friend_cred *friend_cred_create(struct bt_mesh_subnet *sub, u16_t addr,
BT_DBG("net_idx 0x%04x addr 0x%04x", sub->net_idx, addr);
for (cred = NULL, i = 0; i < ARRAY_SIZE(friend_cred); i++) {
if ((friend_cred[i].addr == BT_MESH_ADDR_UNASSIGNED) ||
if ((friend_cred[i].addr == BLE_MESH_ADDR_UNASSIGNED) ||
(friend_cred[i].addr == addr &&
friend_cred[i].net_idx == sub->net_idx)) {
cred = &friend_cred[i];
@@ -346,8 +342,8 @@ struct friend_cred *friend_cred_create(struct bt_mesh_subnet *sub, u16_t addr,
void friend_cred_clear(struct friend_cred *cred)
{
cred->net_idx = BT_MESH_KEY_UNUSED;
cred->addr = BT_MESH_ADDR_UNASSIGNED;
cred->net_idx = BLE_MESH_KEY_UNUSED;
cred->addr = BLE_MESH_ADDR_UNASSIGNED;
cred->lpn_counter = 0;
cred->frnd_counter = 0;
memset(cred->cred, 0, sizeof(cred->cred));
@@ -383,7 +379,7 @@ int friend_cred_get(struct bt_mesh_subnet *sub, u16_t addr, u8_t *nid,
continue;
}
if (addr != BT_MESH_ADDR_UNASSIGNED && cred->addr != addr) {
if (addr != BLE_MESH_ADDR_UNASSIGNED && cred->addr != addr) {
continue;
}
@@ -417,11 +413,11 @@ u8_t bt_mesh_net_flags(struct bt_mesh_subnet *sub)
u8_t flags = 0x00;
if (sub && sub->kr_flag) {
flags |= BT_MESH_NET_FLAG_KR;
flags |= BLE_MESH_NET_FLAG_KR;
}
if (bt_mesh.iv_update) {
flags |= BT_MESH_NET_FLAG_IVU;
flags |= BLE_MESH_NET_FLAG_IVU;
}
return flags;
@@ -465,14 +461,14 @@ int bt_mesh_net_create(u16_t idx, u8_t flags, const u8_t key[16],
sub = &bt_mesh.sub[0];
sub->kr_flag = BT_MESH_KEY_REFRESH(flags);
sub->kr_flag = BLE_MESH_KEY_REFRESH(flags);
if (sub->kr_flag) {
err = bt_mesh_net_keys_create(&sub->keys[1], key);
if (err) {
return -EIO;
}
sub->kr_phase = BT_MESH_KR_PHASE_2;
sub->kr_phase = BLE_MESH_KR_PHASE_2;
} else {
err = bt_mesh_net_keys_create(&sub->keys[0], key);
if (err) {
@@ -483,15 +479,15 @@ int bt_mesh_net_create(u16_t idx, u8_t flags, const u8_t key[16],
bt_mesh.valid = 1;
sub->net_idx = idx;
if (IS_ENABLED(CONFIG_BT_MESH_GATT_PROXY)) {
sub->node_id = BT_MESH_NODE_IDENTITY_RUNNING;
if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY)) {
sub->node_id = BLE_MESH_NODE_IDENTITY_RUNNING;
sub->node_id_start = k_uptime_get_32();
} else {
sub->node_id = BT_MESH_NODE_IDENTITY_NOT_SUPPORTED;
sub->node_id = BLE_MESH_NODE_IDENTITY_NOT_SUPPORTED;
}
bt_mesh.iv_index = iv_index;
bt_mesh.iv_update = BT_MESH_IV_UPDATE(flags);
bt_mesh.iv_update = BLE_MESH_IV_UPDATE(flags);
/* Set initial IV Update procedure state time-stamp */
bt_mesh.last_update = k_uptime_get();
@@ -524,7 +520,7 @@ void bt_mesh_net_revoke_keys(struct bt_mesh_subnet *sub)
bool bt_mesh_kr_update(struct bt_mesh_subnet *sub, u8_t new_kr, bool new_key)
{
if (new_kr != sub->kr_flag && sub->kr_phase == BT_MESH_KR_NORMAL) {
if (new_kr != sub->kr_flag && sub->kr_phase == BLE_MESH_KR_NORMAL) {
BT_WARN("KR change in normal operation. Is it a case of blacklisting?");
return false;
}
@@ -532,14 +528,14 @@ bool bt_mesh_kr_update(struct bt_mesh_subnet *sub, u8_t new_kr, bool new_key)
sub->kr_flag = new_kr;
if (sub->kr_flag) {
if (sub->kr_phase == BT_MESH_KR_PHASE_1) {
if (sub->kr_phase == BLE_MESH_KR_PHASE_1) {
BT_DBG("Phase 1 -> Phase 2");
sub->kr_phase = BT_MESH_KR_PHASE_2;
sub->kr_phase = BLE_MESH_KR_PHASE_2;
return true;
}
} else {
switch (sub->kr_phase) {
case BT_MESH_KR_PHASE_1:
case BLE_MESH_KR_PHASE_1:
if (!new_key) {
/* Ignore */
break;
@@ -551,14 +547,14 @@ bool bt_mesh_kr_update(struct bt_mesh_subnet *sub, u8_t new_kr, bool new_key)
*
* Intentional fall-through.
*/
case BT_MESH_KR_PHASE_2:
case BLE_MESH_KR_PHASE_2:
BT_DBG("KR Phase 0x%02x -> Normal", sub->kr_phase);
bt_mesh_net_revoke_keys(sub);
if (IS_ENABLED(CONFIG_BT_MESH_LOW_POWER) ||
IS_ENABLED(CONFIG_BT_MESH_FRIEND)) {
if (IS_ENABLED(CONFIG_BLE_MESH_LOW_POWER) ||
IS_ENABLED(CONFIG_BLE_MESH_FRIEND)) {
friend_cred_refresh(sub->net_idx);
}
sub->kr_phase = BT_MESH_KR_NORMAL;
sub->kr_phase = BLE_MESH_KR_NORMAL;
return true;
}
}
@@ -586,7 +582,7 @@ void bt_mesh_rpl_reset(void)
}
}
#if defined(CONFIG_BT_MESH_IV_UPDATE_TEST)
#if defined(CONFIG_BLE_MESH_IV_UPDATE_TEST)
void bt_mesh_iv_update_test(bool enable)
{
bt_mesh.ivu_test = enable;
@@ -595,7 +591,7 @@ void bt_mesh_iv_update_test(bool enable)
bool bt_mesh_iv_update(void)
{
if (!bt_mesh_is_provisioned()) {
BT_ERR("Not yet provisioned");
BT_ERR("%s, Not yet provisioned", __func__);
return false;
}
@@ -609,18 +605,18 @@ bool bt_mesh_iv_update(void)
return bt_mesh.iv_update;
}
#endif /* CONFIG_BT_MESH_IV_UPDATE_TEST */
#endif /* CONFIG_BLE_MESH_IV_UPDATE_TEST */
/* Used for sending immediate beacons to Friend queues and GATT clients */
void bt_mesh_net_sec_update(struct bt_mesh_subnet *sub)
{
if (IS_ENABLED(CONFIG_BT_MESH_FRIEND)) {
bt_mesh_friend_sec_update(sub ? sub->net_idx : BT_MESH_KEY_ANY);
if (IS_ENABLED(CONFIG_BLE_MESH_FRIEND)) {
bt_mesh_friend_sec_update(sub ? sub->net_idx : BLE_MESH_KEY_ANY);
}
if (IS_ENABLED(CONFIG_BT_MESH_GATT_PROXY) &&
bt_mesh_gatt_proxy_get() == BT_MESH_GATT_PROXY_ENABLED) {
#if CONFIG_BT_MESH_NODE
if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY) &&
bt_mesh_gatt_proxy_get() == BLE_MESH_GATT_PROXY_ENABLED) {
#if CONFIG_BLE_MESH_NODE
bt_mesh_proxy_beacon_send(sub);
#endif
}
@@ -685,7 +681,7 @@ bool bt_mesh_net_iv_update(u32_t iv_index, bool iv_update)
}
}
if (!IS_ENABLED(CONFIG_BT_MESH_IV_UPDATE_TEST) || !bt_mesh.ivu_test) {
if (!IS_ENABLED(CONFIG_BLE_MESH_IV_UPDATE_TEST) || !bt_mesh.ivu_test) {
s64_t delta = k_uptime_get() - bt_mesh.last_update;
if (delta < K_HOURS(96)) {
@@ -718,7 +714,7 @@ do_update:
bt_mesh.seq = 0;
k_delayed_work_cancel(&bt_mesh.ivu_complete);
if (IS_ENABLED(CONFIG_BT_MESH_SETTINGS)) {
if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) {
bt_mesh_store_seq();
}
@@ -728,12 +724,12 @@ do_update:
bt_mesh.last_update = k_uptime_get();
for (i = 0; i < ARRAY_SIZE(bt_mesh.sub); i++) {
if (bt_mesh.sub[i].net_idx != BT_MESH_KEY_UNUSED) {
if (bt_mesh.sub[i].net_idx != BLE_MESH_KEY_UNUSED) {
bt_mesh_net_beacon_update(&bt_mesh.sub[i]);
}
}
if (IS_ENABLED(CONFIG_BT_MESH_SETTINGS)) {
if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) {
bt_mesh_store_iv();
}
@@ -765,15 +761,15 @@ int bt_mesh_net_resend(struct bt_mesh_subnet *sub, struct net_buf *buf,
enc = sub->keys[new_key].enc;
priv = sub->keys[new_key].privacy;
err = bt_mesh_net_obfuscate(buf->data, BT_MESH_NET_IVI_TX, priv);
err = bt_mesh_net_obfuscate(buf->data, BLE_MESH_NET_IVI_TX, priv);
if (err) {
BT_ERR("deobfuscate failed (err %d)", err);
BT_ERR("%s, De-obfuscate failed (err %d)", __func__, err);
return err;
}
err = bt_mesh_net_decrypt(enc, &buf->b, BT_MESH_NET_IVI_TX, false);
err = bt_mesh_net_decrypt(enc, &buf->b, BLE_MESH_NET_IVI_TX, false);
if (err) {
BT_ERR("decrypt failed (err %d)", err);
BT_ERR("%s, Decrypt failed (err %d)", __func__, err);
return err;
}
@@ -783,22 +779,22 @@ int bt_mesh_net_resend(struct bt_mesh_subnet *sub, struct net_buf *buf,
buf->data[3] = seq >> 8;
buf->data[4] = seq;
err = bt_mesh_net_encrypt(enc, &buf->b, BT_MESH_NET_IVI_TX, false);
err = bt_mesh_net_encrypt(enc, &buf->b, BLE_MESH_NET_IVI_TX, false);
if (err) {
BT_ERR("encrypt failed (err %d)", err);
BT_ERR("%s, Encrypt failed (err %d)", __func__, err);
return err;
}
err = bt_mesh_net_obfuscate(buf->data, BT_MESH_NET_IVI_TX, priv);
err = bt_mesh_net_obfuscate(buf->data, BLE_MESH_NET_IVI_TX, priv);
if (err) {
BT_ERR("obfuscate failed (err %d)", err);
BT_ERR("%s, Obfuscate failed (err %d)", __func__, err);
return err;
}
bt_mesh_adv_send(buf, cb, cb_data);
if (!bt_mesh.iv_update && bt_mesh.seq > IV_UPDATE_SEQ_LIMIT) {
#if CONFIG_BT_MESH_NODE
#if CONFIG_BLE_MESH_NODE
bt_mesh_beacon_ivu_initiator(true);
#endif
bt_mesh_net_iv_update(bt_mesh.iv_index + 1, true);
@@ -814,7 +810,7 @@ static void bt_mesh_net_local(struct k_work *work)
while ((buf = net_buf_slist_get(&bt_mesh.local_queue))) {
BT_DBG("len %u: %s", buf->len, bt_hex(buf->data, buf->len));
bt_mesh_net_recv(&buf->b, 0, BT_MESH_NET_IF_LOCAL);
bt_mesh_net_recv(&buf->b, 0, BLE_MESH_NET_IF_LOCAL);
net_buf_unref(buf);
}
}
@@ -822,7 +818,7 @@ static void bt_mesh_net_local(struct k_work *work)
int bt_mesh_net_encode(struct bt_mesh_net_tx *tx, struct net_buf_simple *buf,
bool proxy)
{
const bool ctl = (tx->ctx->app_idx == BT_MESH_KEY_UNUSED);
const bool ctl = (tx->ctx->app_idx == BLE_MESH_KEY_UNUSED);
u32_t seq_val;
u8_t nid;
const u8_t *enc, *priv;
@@ -830,10 +826,10 @@ int bt_mesh_net_encode(struct bt_mesh_net_tx *tx, struct net_buf_simple *buf,
int err;
if (ctl && net_buf_simple_tailroom(buf) < 8) {
BT_ERR("Insufficient MIC space for CTL PDU");
BT_ERR("%s, Insufficient MIC space for CTL PDU", __func__);
return -EINVAL;
} else if (net_buf_simple_tailroom(buf) < 4) {
BT_ERR("Insufficient MIC space for PDU");
BT_ERR("%s, Insufficient MIC space for PDU", __func__);
return -EINVAL;
}
@@ -855,8 +851,8 @@ int bt_mesh_net_encode(struct bt_mesh_net_tx *tx, struct net_buf_simple *buf,
net_buf_simple_push_u8(buf, tx->ctx->send_ttl);
}
if (IS_ENABLED(CONFIG_BT_MESH_LOW_POWER) && tx->friend_cred) {
if (friend_cred_get(tx->sub, BT_MESH_ADDR_UNASSIGNED,
if (IS_ENABLED(CONFIG_BLE_MESH_LOW_POWER) && tx->friend_cred) {
if (friend_cred_get(tx->sub, BLE_MESH_ADDR_UNASSIGNED,
&nid, &enc, &priv)) {
BT_WARN("Falling back to master credentials");
@@ -873,14 +869,14 @@ int bt_mesh_net_encode(struct bt_mesh_net_tx *tx, struct net_buf_simple *buf,
priv = tx->sub->keys[tx->sub->kr_flag].privacy;
}
net_buf_simple_push_u8(buf, (nid | (BT_MESH_NET_IVI_TX & 1) << 7));
net_buf_simple_push_u8(buf, (nid | (BLE_MESH_NET_IVI_TX & 1) << 7));
err = bt_mesh_net_encrypt(enc, buf, BT_MESH_NET_IVI_TX, proxy);
err = bt_mesh_net_encrypt(enc, buf, BLE_MESH_NET_IVI_TX, proxy);
if (err) {
return err;
}
return bt_mesh_net_obfuscate(buf->data, BT_MESH_NET_IVI_TX, priv);
return bt_mesh_net_obfuscate(buf->data, BLE_MESH_NET_IVI_TX, priv);
}
int bt_mesh_net_send(struct bt_mesh_net_tx *tx, struct net_buf *buf,
@@ -894,7 +890,7 @@ int bt_mesh_net_send(struct bt_mesh_net_tx *tx, struct net_buf *buf,
BT_DBG("Payload len %u: %s", buf->len, bt_hex(buf->data, buf->len));
BT_DBG("Seq 0x%06x", bt_mesh.seq);
if (tx->ctx->send_ttl == BT_MESH_TTL_DEFAULT) {
if (tx->ctx->send_ttl == BLE_MESH_TTL_DEFAULT) {
tx->ctx->send_ttl = bt_mesh_default_ttl_get();
}
@@ -907,12 +903,12 @@ int bt_mesh_net_send(struct bt_mesh_net_tx *tx, struct net_buf *buf,
* "The output filter of the interface connected to advertising or
* GATT bearers shall drop all messages with TTL value set to 1."
*/
#if CONFIG_BT_MESH_NODE
#if CONFIG_BLE_MESH_NODE
if (bt_mesh_is_provisioned()) {
if (IS_ENABLED(CONFIG_BT_MESH_GATT_PROXY) &&
if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY) &&
tx->ctx->send_ttl != 1) {
if (bt_mesh_proxy_relay(&buf->b, tx->ctx->addr) &&
BT_MESH_ADDR_IS_UNICAST(tx->ctx->addr)) {
BLE_MESH_ADDR_IS_UNICAST(tx->ctx->addr)) {
/* Notify completion if this only went
* through the Mesh Proxy.
*/
@@ -989,7 +985,7 @@ struct bt_mesh_subnet *bt_mesh_subnet_find(const u8_t net_id[8], u8_t flags,
for (i = 0; i < ARRAY_SIZE(bt_mesh.sub); i++) {
struct bt_mesh_subnet *sub = &bt_mesh.sub[i];
if (sub->net_idx == BT_MESH_KEY_UNUSED) {
if (sub->net_idx == BLE_MESH_KEY_UNUSED) {
continue;
}
@@ -998,7 +994,7 @@ struct bt_mesh_subnet *bt_mesh_subnet_find(const u8_t net_id[8], u8_t flags,
return sub;
}
if (sub->kr_phase == BT_MESH_KR_NORMAL) {
if (sub->kr_phase == BLE_MESH_KR_NORMAL) {
continue;
}
@@ -1024,7 +1020,7 @@ static int net_decrypt(struct bt_mesh_subnet *sub, const u8_t *enc,
net_buf_simple_init(buf, 0);
memcpy(net_buf_simple_add(buf, data_len), data, data_len);
if (bt_mesh_net_obfuscate(buf->data, BT_MESH_NET_IVI_RX(rx), priv)) {
if (bt_mesh_net_obfuscate(buf->data, BLE_MESH_NET_IVI_RX(rx), priv)) {
return -ENOENT;
}
@@ -1033,34 +1029,33 @@ static int net_decrypt(struct bt_mesh_subnet *sub, const u8_t *enc,
* to be filtered here. So when a device is re-provisioned, the related
* msg_cache should be cleared. Will do it later.
*/
if (rx->net_if == BT_MESH_NET_IF_ADV && msg_cache_match(rx, buf)) {
if (rx->net_if == BLE_MESH_NET_IF_ADV && msg_cache_match(rx, buf)) {
BT_WARN("Duplicate found in Network Message Cache");
return -EALREADY;
}
rx->ctx.addr = SRC(buf->data);
if (!BT_MESH_ADDR_IS_UNICAST(rx->ctx.addr)) {
if (!BLE_MESH_ADDR_IS_UNICAST(rx->ctx.addr)) {
BT_WARN("Ignoring non-unicast src addr 0x%04x", rx->ctx.addr);
return -EINVAL;
}
BT_DBG("src 0x%04x", rx->ctx.addr);
#if CONFIG_BT_MESH_NODE
#if CONFIG_BLE_MESH_NODE
if (bt_mesh_is_provisioned()) {
if (IS_ENABLED(CONFIG_BT_MESH_PROXY) &&
rx->net_if == BT_MESH_NET_IF_PROXY_CFG) {
return bt_mesh_net_decrypt(enc, buf, BT_MESH_NET_IVI_RX(rx),
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
return bt_mesh_net_decrypt(enc, buf, BT_MESH_NET_IVI_RX(rx), false);
return bt_mesh_net_decrypt(enc, buf, BLE_MESH_NET_IVI_RX(rx), false);
}
#if (defined(CONFIG_BT_MESH_LOW_POWER) || \
defined(CONFIG_BT_MESH_FRIEND))
#if (defined(CONFIG_BLE_MESH_LOW_POWER) || defined(CONFIG_BLE_MESH_FRIEND))
static int friend_decrypt(struct bt_mesh_subnet *sub, const u8_t *data,
size_t data_len, struct bt_mesh_net_rx *rx,
struct net_buf_simple *buf)
@@ -1082,7 +1077,7 @@ static int friend_decrypt(struct bt_mesh_subnet *sub, const u8_t *data,
return 0;
}
if (sub->kr_phase == BT_MESH_KR_NORMAL) {
if (sub->kr_phase == BLE_MESH_KR_NORMAL) {
continue;
}
@@ -1108,19 +1103,19 @@ static bool net_find_and_decrypt(const u8_t *data, size_t data_len,
BT_DBG("%s", __func__);
#if CONFIG_BT_MESH_NODE && !CONFIG_BT_MESH_PROVISIONER
#if CONFIG_BLE_MESH_NODE && !CONFIG_BLE_MESH_PROVISIONER
if (!bt_mesh_is_provisioner_en()) {
array_size = ARRAY_SIZE(bt_mesh.sub);
}
#endif
#if !CONFIG_BT_MESH_NODE && CONFIG_BT_MESH_PROVISIONER
#if !CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PROVISIONER
if (bt_mesh_is_provisioner_en()) {
array_size = ARRAY_SIZE(bt_mesh.p_sub);
}
#endif
#if CONFIG_BT_MESH_NODE && CONFIG_BT_MESH_PROVISIONER
#if CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PROVISIONER
array_size = ARRAY_SIZE(bt_mesh.sub);
if (bt_mesh_is_provisioner_en()) {
array_size += ARRAY_SIZE(bt_mesh.p_sub);
@@ -1128,24 +1123,24 @@ static bool net_find_and_decrypt(const u8_t *data, size_t data_len,
#endif
if (!array_size) {
BT_ERR("%s: Get sub array_size fail", __func__);
BT_ERR("%s, Unable to get subnet size", __func__);
return false;
}
for (i = 0; i < array_size; i++) {
#if CONFIG_BT_MESH_NODE && !CONFIG_BT_MESH_PROVISIONER
#if CONFIG_BLE_MESH_NODE && !CONFIG_BLE_MESH_PROVISIONER
if (!bt_mesh_is_provisioner_en()) {
sub = &bt_mesh.sub[i];
}
#endif
#if !CONFIG_BT_MESH_NODE && CONFIG_BT_MESH_PROVISIONER
#if !CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PROVISIONER
if (bt_mesh_is_provisioner_en()) {
sub = bt_mesh.p_sub[i];
}
#endif
#if CONFIG_BT_MESH_NODE && CONFIG_BT_MESH_PROVISIONER
#if CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PROVISIONER
if (i < ARRAY_SIZE(bt_mesh.sub)) {
sub = &bt_mesh.sub[i];
} else {
@@ -1154,18 +1149,17 @@ static bool net_find_and_decrypt(const u8_t *data, size_t data_len,
#endif
if (!sub) {
BT_DBG("%s: get NULL sub", __func__);
BT_DBG("%s, NULL subnet", __func__);
continue;
}
if (sub->net_idx == BT_MESH_KEY_UNUSED) {
if (sub->net_idx == BLE_MESH_KEY_UNUSED) {
continue;
}
#if CONFIG_BT_MESH_NODE
#if CONFIG_BLE_MESH_NODE
if (bt_mesh_is_provisioned()) {
#if (defined(CONFIG_BT_MESH_LOW_POWER) || \
defined(CONFIG_BT_MESH_FRIEND))
#if (defined(CONFIG_BLE_MESH_LOW_POWER) || defined(CONFIG_BLE_MESH_FRIEND))
if (!friend_decrypt(sub, data, data_len, rx, buf)) {
rx->friend_cred = 1;
rx->ctx.net_idx = sub->net_idx;
@@ -1174,7 +1168,7 @@ static bool net_find_and_decrypt(const u8_t *data, size_t data_len,
}
#endif
}
#endif /* CONFIG_BT_MESH_NODE */
#endif /* CONFIG_BLE_MESH_NODE */
if (NID(data) == sub->keys[0].nid &&
!net_decrypt(sub, sub->keys[0].enc, sub->keys[0].privacy,
@@ -1184,7 +1178,7 @@ static bool net_find_and_decrypt(const u8_t *data, size_t data_len,
return true;
}
if (sub->kr_phase == BT_MESH_KR_NORMAL) {
if (sub->kr_phase == BLE_MESH_KR_NORMAL) {
continue;
}
@@ -1206,17 +1200,17 @@ static bool net_find_and_decrypt(const u8_t *data, size_t data_len,
* get sent to the advertising bearer. If the packet came in through GATT,
* then it should only be relayed if the GATT Proxy state is enabled.
*/
#if CONFIG_BT_MESH_NODE
#if CONFIG_BLE_MESH_NODE
static bool relay_to_adv(enum bt_mesh_net_if net_if)
{
switch (net_if) {
case BT_MESH_NET_IF_LOCAL:
case BLE_MESH_NET_IF_LOCAL:
return true;
case BT_MESH_NET_IF_ADV:
return (bt_mesh_relay_get() == BT_MESH_RELAY_ENABLED);
case BT_MESH_NET_IF_PROXY:
return (bt_mesh_gatt_proxy_get() == BT_MESH_GATT_PROXY_ENABLED);
case BLE_MESH_NET_IF_ADV:
return (bt_mesh_relay_get() == BLE_MESH_RELAY_ENABLED);
case BLE_MESH_NET_IF_PROXY:
return (bt_mesh_gatt_proxy_get() == BLE_MESH_GATT_PROXY_ENABLED);
default:
return false;
}
@@ -1229,7 +1223,7 @@ static void bt_mesh_net_relay(struct net_buf_simple *sbuf,
struct net_buf *buf;
u8_t nid, transmit;
if (rx->net_if == BT_MESH_NET_IF_LOCAL) {
if (rx->net_if == BLE_MESH_NET_IF_LOCAL) {
/* Locally originated PDUs with TTL=1 will only be delivered
* to local elements as per Mesh Profile 1.0 section 3.4.5.2:
* "The output filter of the interface connected to
@@ -1245,9 +1239,9 @@ static void bt_mesh_net_relay(struct net_buf_simple *sbuf,
}
}
if (rx->net_if == BT_MESH_NET_IF_ADV &&
bt_mesh_relay_get() != BT_MESH_RELAY_ENABLED &&
bt_mesh_gatt_proxy_get() != BT_MESH_GATT_PROXY_ENABLED) {
if (rx->net_if == BLE_MESH_NET_IF_ADV &&
bt_mesh_relay_get() != BLE_MESH_RELAY_ENABLED &&
bt_mesh_gatt_proxy_get() != BLE_MESH_GATT_PROXY_ENABLED) {
return;
}
@@ -1257,22 +1251,22 @@ static void bt_mesh_net_relay(struct net_buf_simple *sbuf,
* Anything else (like GATT to adv, or locally originated packets)
* use the Network Transmit state.
*/
if (rx->net_if == BT_MESH_NET_IF_ADV) {
if (rx->net_if == BLE_MESH_NET_IF_ADV) {
transmit = bt_mesh_relay_retransmit_get();
} else {
transmit = bt_mesh_net_transmit_get();
}
buf = bt_mesh_adv_create(BT_MESH_ADV_DATA,
BT_MESH_TRANSMIT_COUNT(transmit),
BT_MESH_TRANSMIT_INT(transmit), K_NO_WAIT);
buf = bt_mesh_adv_create(BLE_MESH_ADV_DATA,
BLE_MESH_TRANSMIT_COUNT(transmit),
BLE_MESH_TRANSMIT_INT(transmit), K_NO_WAIT);
if (!buf) {
BT_ERR("Out of relay buffers");
BT_ERR("%s, Out of relay buffers", __func__);
return;
}
/* Only decrement TTL for non-locally originated packets */
if (rx->net_if != BT_MESH_NET_IF_LOCAL) {
if (rx->net_if != BLE_MESH_NET_IF_LOCAL) {
/* Leave CTL bit intact */
sbuf->data[1] &= 0x80;
sbuf->data[1] |= rx->ctx.recv_ttl - 1;
@@ -1296,24 +1290,24 @@ static void bt_mesh_net_relay(struct net_buf_simple *sbuf,
* the normal TX IVI (which may be different) since the transport
* layer nonce includes the IVI.
*/
if (bt_mesh_net_encrypt(enc, &buf->b, BT_MESH_NET_IVI_RX(rx), false)) {
BT_ERR("Re-encrypting failed");
if (bt_mesh_net_encrypt(enc, &buf->b, BLE_MESH_NET_IVI_RX(rx), false)) {
BT_ERR("%s, Re-encrypting failed", __func__);
goto done;
}
if (bt_mesh_net_obfuscate(buf->data, BT_MESH_NET_IVI_RX(rx), priv)) {
BT_ERR("Re-obfuscating failed");
if (bt_mesh_net_obfuscate(buf->data, BLE_MESH_NET_IVI_RX(rx), priv)) {
BT_ERR("%s, Re-obfuscating failed", __func__);
goto done;
}
/* Sending to GATT bearer should only occur if GATT Proxy
* is enabled or the message originates from a local node.
*/
if (IS_ENABLED(CONFIG_BT_MESH_GATT_PROXY) &&
(bt_mesh_gatt_proxy_get() == BT_MESH_GATT_PROXY_ENABLED ||
rx->net_if == BT_MESH_NET_IF_LOCAL)) {
if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY) &&
(bt_mesh_gatt_proxy_get() == BLE_MESH_GATT_PROXY_ENABLED ||
rx->net_if == BLE_MESH_NET_IF_LOCAL)) {
if (bt_mesh_proxy_relay(&buf->b, rx->dst) &&
BT_MESH_ADDR_IS_UNICAST(rx->dst)) {
BLE_MESH_ADDR_IS_UNICAST(rx->dst)) {
goto done;
}
}
@@ -1326,18 +1320,18 @@ done:
net_buf_unref(buf);
}
#endif /* CONFIG_BT_MESH_NODE */
#endif /* CONFIG_BLE_MESH_NODE */
int bt_mesh_net_decode(struct net_buf_simple *data, enum bt_mesh_net_if net_if,
struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
{
if (data->len < BT_MESH_NET_MIN_PDU_LEN) {
if (data->len < BLE_MESH_NET_MIN_PDU_LEN) {
BT_WARN("Dropping a too short mesh packet (len %u)", data->len);
BT_WARN("%s", bt_hex(data->data, data->len));
return -EINVAL;
}
if (net_if == BT_MESH_NET_IF_ADV && check_dup(data)) {
if (net_if == BLE_MESH_NET_IF_ADV && check_dup(data)) {
return -EINVAL;
}
@@ -1351,7 +1345,7 @@ int bt_mesh_net_decode(struct net_buf_simple *data, enum bt_mesh_net_if net_if,
}
/* Initialize AppIdx to a reasonable value */
rx->ctx.app_idx = BT_MESH_KEY_UNUSED;
rx->ctx.app_idx = BLE_MESH_KEY_UNUSED;
rx->ctx.recv_ttl = TTL(buf->data);
@@ -1359,7 +1353,7 @@ int bt_mesh_net_decode(struct net_buf_simple *data, enum bt_mesh_net_if net_if,
if (rx->ctx.recv_ttl == 0) {
rx->ctx.send_ttl = 0;
} else {
rx->ctx.send_ttl = BT_MESH_TTL_DEFAULT;
rx->ctx.send_ttl = BLE_MESH_TTL_DEFAULT;
}
rx->ctl = CTL(buf->data);
@@ -1368,18 +1362,18 @@ int bt_mesh_net_decode(struct net_buf_simple *data, enum bt_mesh_net_if net_if,
BT_DBG("Decryption successful. Payload len %u", buf->len);
if (net_if != BT_MESH_NET_IF_PROXY_CFG &&
rx->dst == BT_MESH_ADDR_UNASSIGNED) {
BT_ERR("Destination address is unassigned; dropping packet");
if (net_if != BLE_MESH_NET_IF_PROXY_CFG &&
rx->dst == BLE_MESH_ADDR_UNASSIGNED) {
BT_ERR("%s, Destination address is unassigned; dropping packet", __func__);
return -EBADMSG;
}
if (BT_MESH_ADDR_IS_RFU(rx->dst)) {
BT_ERR("Destination address is RFU; dropping packet");
if (BLE_MESH_ADDR_IS_RFU(rx->dst)) {
BT_ERR("%s, Destination address is RFU; dropping packet", __func__);
return -EBADMSG;
}
if (net_if != BT_MESH_NET_IF_LOCAL && bt_mesh_elem_find(rx->ctx.addr)) {
if (net_if != BLE_MESH_NET_IF_LOCAL && bt_mesh_elem_find(rx->ctx.addr)) {
BT_DBG("Dropping locally originated packet");
return -EBADMSG;
}
@@ -1400,7 +1394,7 @@ void bt_mesh_net_recv(struct net_buf_simple *data, s8_t rssi,
BT_DBG("rssi %d net_if %u", rssi, net_if);
#if CONFIG_BT_MESH_NODE
#if CONFIG_BLE_MESH_NODE
if (!bt_mesh_is_provisioner_en()) {
if (!bt_mesh_is_provisioned()) {
return;
@@ -1408,9 +1402,9 @@ void bt_mesh_net_recv(struct net_buf_simple *data, s8_t rssi,
}
#endif
#if !CONFIG_BT_MESH_NODE && CONFIG_BT_MESH_PROVISIONER
#if !CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PROVISIONER
if (!bt_mesh_is_provisioner_en()) {
BT_WARN("%s: provisioner disabled", __func__);
BT_WARN("%s, Provisioner is disabled", __func__);
return;
}
if (!provisioner_get_prov_node_count()) {
@@ -1425,10 +1419,10 @@ void bt_mesh_net_recv(struct net_buf_simple *data, s8_t rssi,
/* Save the state so the buffer can later be relayed */
net_buf_simple_save(buf, &state);
#if CONFIG_BT_MESH_NODE
#if CONFIG_BLE_MESH_NODE
if (bt_mesh_is_provisioned()) {
if (IS_ENABLED(CONFIG_BT_MESH_GATT_PROXY) &&
net_if == BT_MESH_NET_IF_PROXY) {
if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY) &&
net_if == BLE_MESH_NET_IF_PROXY) {
bt_mesh_proxy_addr_add(data, rx.ctx.addr);
}
}
@@ -1442,9 +1436,9 @@ void bt_mesh_net_recv(struct net_buf_simple *data, s8_t rssi,
/* Relay if this is a group/virtual address, or if the destination
* is neither a local element nor an Friend's LPN.
*/
#if CONFIG_BT_MESH_NODE
#if CONFIG_BLE_MESH_NODE
if (bt_mesh_is_provisioned()) {
if (!BT_MESH_ADDR_IS_UNICAST(rx.dst) ||
if (!BLE_MESH_ADDR_IS_UNICAST(rx.dst) ||
(!rx.local_match && !rx.friend_match)) {
net_buf_simple_restore(buf, &state);
bt_mesh_net_relay(buf, &rx);
@@ -1457,49 +1451,49 @@ static void ivu_complete(struct k_work *work)
{
BT_DBG("%s", __func__);
#if CONFIG_BT_MESH_NODE
#if CONFIG_BLE_MESH_NODE
bt_mesh_beacon_ivu_initiator(true);
#endif
bt_mesh_net_iv_update(bt_mesh.iv_index, false);
}
#if defined(CONFIG_BT_MESH_NODE)
#if defined(CONFIG_BLE_MESH_NODE)
void bt_mesh_net_start(void)
{
if (bt_mesh_beacon_get() == BT_MESH_BEACON_ENABLED) {
if (bt_mesh_beacon_get() == BLE_MESH_BEACON_ENABLED) {
bt_mesh_beacon_enable();
} else {
bt_mesh_beacon_disable();
}
if (IS_ENABLED(CONFIG_BT_MESH_GATT_PROXY) &&
bt_mesh_gatt_proxy_get() != BT_MESH_GATT_PROXY_NOT_SUPPORTED) {
if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY) &&
bt_mesh_gatt_proxy_get() != BLE_MESH_GATT_PROXY_NOT_SUPPORTED) {
bt_mesh_proxy_gatt_enable();
bt_mesh_adv_update();
}
#if defined(CONFIG_BT_MESH_USE_DUPLICATE_SCAN)
#if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN)
/* Add Mesh beacon type (Secure Network Beacon) to the exceptional list */
bt_mesh_update_exceptional_list(BT_MESH_EXCEP_LIST_ADD,
BT_MESH_EXCEP_INFO_MESH_BEACON, NULL);
bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_ADD,
BLE_MESH_EXCEP_INFO_MESH_BEACON, NULL);
#endif
if (IS_ENABLED(CONFIG_BT_MESH_LOW_POWER)) {
if (IS_ENABLED(CONFIG_BLE_MESH_LOW_POWER)) {
/* TODO: Enable duplicate scan in Low Power Mode */
bt_mesh_lpn_init();
} else {
#if defined(CONFIG_BT_MESH_USE_DUPLICATE_SCAN)
#if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN)
bt_mesh_duplicate_scan_enable();
#else
bt_mesh_scan_enable();
#endif
}
if (IS_ENABLED(CONFIG_BT_MESH_FRIEND)) {
if (IS_ENABLED(CONFIG_BLE_MESH_FRIEND)) {
bt_mesh_friend_init();
}
if (IS_ENABLED(CONFIG_BT_MESH_PROV)) {
if (IS_ENABLED(CONFIG_BLE_MESH_PROV)) {
u16_t net_idx = bt_mesh.sub[0].net_idx;
u16_t addr = bt_mesh_primary_addr();
u8_t flags = (bt_mesh.iv_update << 1) | bt_mesh.sub[0].kr_flag;
@@ -1516,5 +1510,3 @@ void bt_mesh_net_init(void)
k_work_init(&bt_mesh.local_work, bt_mesh_net_local);
}
#endif /* #if CONFIG_BT_MESH */

View File

@@ -9,33 +9,34 @@
#ifndef _NET_H_
#define _NET_H_
#include "mesh_util.h"
#include "mesh_kernel.h"
#include "mesh_access.h"
#define BT_MESH_NET_FLAG_KR BIT(0)
#define BT_MESH_NET_FLAG_IVU BIT(1)
#define BLE_MESH_NET_FLAG_KR BIT(0)
#define BLE_MESH_NET_FLAG_IVU BIT(1)
#define BT_MESH_KR_NORMAL 0x00
#define BT_MESH_KR_PHASE_1 0x01
#define BT_MESH_KR_PHASE_2 0x02
#define BT_MESH_KR_PHASE_3 0x03
#define BLE_MESH_KR_NORMAL 0x00
#define BLE_MESH_KR_PHASE_1 0x01
#define BLE_MESH_KR_PHASE_2 0x02
#define BLE_MESH_KR_PHASE_3 0x03
#define BT_MESH_IV_UPDATE(flags) ((flags >> 1) & 0x01)
#define BT_MESH_KEY_REFRESH(flags) (flags & 0x01)
#define BLE_MESH_IV_UPDATE(flags) ((flags >> 1) & 0x01)
#define BLE_MESH_KEY_REFRESH(flags) (flags & 0x01)
/* Special time-stamp to indicate that we don't know when the last IV
* Update happened.
*/
#define BT_MESH_NET_IVU_UNKNOWN -1
#define BLE_MESH_NET_IVU_UNKNOWN -1
#if defined(CONFIG_BT_MESH_IV_UPDATE_TEST)
#if defined(CONFIG_BLE_MESH_IV_UPDATE_TEST)
/* Small test timeout for IV Update Procedure testing */
#define BT_MESH_NET_IVU_TIMEOUT K_SECONDS(120)
#define BLE_MESH_NET_IVU_TIMEOUT K_SECONDS(120)
#else
/* Maximum time to stay in IV Update mode (96 < time < 144) */
#define BT_MESH_NET_IVU_TIMEOUT K_HOURS(120)
#endif /* CONFIG_BT_MESH_IV_UPDATE_TEST */
#define BLE_MESH_NET_IVU_TIMEOUT K_HOURS(120)
#endif /* CONFIG_BLE_MESH_IV_UPDATE_TEST */
struct bt_mesh_app_key {
u16_t net_idx;
@@ -73,7 +74,7 @@ struct bt_mesh_subnet {
u8_t nid; /* NID */
u8_t enc[16]; /* EncKey */
u8_t net_id[8]; /* Network ID */
#if defined(CONFIG_BT_MESH_GATT_PROXY)
#if defined(CONFIG_BLE_MESH_GATT_PROXY)
u8_t identity[16]; /* IdentityKey */
#endif
u8_t privacy[16]; /* PrivacyKey */
@@ -84,15 +85,15 @@ struct bt_mesh_subnet {
struct bt_mesh_rpl {
u16_t src;
bool old_iv;
#if defined(CONFIG_BT_MESH_SETTINGS)
#if defined(CONFIG_BLE_MESH_SETTINGS)
bool store;
#endif
u32_t seq;
};
#if defined(CONFIG_BT_MESH_FRIEND)
#define FRIEND_SEG_RX CONFIG_BT_MESH_FRIEND_SEG_RX
#define FRIEND_SUB_LIST_SIZE CONFIG_BT_MESH_FRIEND_SUB_LIST_SIZE
#if defined(CONFIG_BLE_MESH_FRIEND)
#define FRIEND_SEG_RX CONFIG_BLE_MESH_FRIEND_SEG_RX
#define FRIEND_SUB_LIST_SIZE CONFIG_BLE_MESH_FRIEND_SUB_LIST_SIZE
#else
#define FRIEND_SEG_RX 0
#define FRIEND_SUB_LIST_SIZE 0
@@ -137,8 +138,8 @@ struct bt_mesh_friend {
} clear;
};
#if defined(CONFIG_BT_MESH_LOW_POWER)
#define LPN_GROUPS CONFIG_BT_MESH_LOW_POWER
#if defined(CONFIG_BLE_MESH_LOW_POWER)
#define LPN_GROUPS CONFIG_BLE_MESH_LOW_POWER
#else
#define LPN_GROUPS 0
#endif
@@ -146,16 +147,16 @@ struct bt_mesh_friend {
/* Low Power Node state */
struct bt_mesh_lpn {
enum __packed {
BT_MESH_LPN_DISABLED, /* LPN feature is disabled */
BT_MESH_LPN_CLEAR, /* Clear in progress */
BT_MESH_LPN_TIMER, /* Waiting for auto timer expiry */
BT_MESH_LPN_ENABLED, /* LPN enabled, but no Friend */
BT_MESH_LPN_REQ_WAIT, /* Wait before scanning for offers */
BT_MESH_LPN_WAIT_OFFER, /* Friend Req sent */
BT_MESH_LPN_ESTABLISHED, /* Friendship established */
BT_MESH_LPN_RECV_DELAY, /* Poll sent, waiting ReceiveDelay */
BT_MESH_LPN_WAIT_UPDATE, /* Waiting for Update or message */
BT_MESH_LPN_OFFER_RECV, /* Friend offer received */
BLE_MESH_LPN_DISABLED, /* LPN feature is disabled */
BLE_MESH_LPN_CLEAR, /* Clear in progress */
BLE_MESH_LPN_TIMER, /* Waiting for auto timer expiry */
BLE_MESH_LPN_ENABLED, /* LPN enabled, but no Friend */
BLE_MESH_LPN_REQ_WAIT, /* Wait before scanning for offers */
BLE_MESH_LPN_WAIT_OFFER, /* Friend Req sent */
BLE_MESH_LPN_ESTABLISHED, /* Friendship established */
BLE_MESH_LPN_RECV_DELAY, /* Poll sent, waiting ReceiveDelay */
BLE_MESH_LPN_WAIT_UPDATE, /* Waiting for Update or message */
BLE_MESH_LPN_OFFER_RECV, /* Friend offer received */
} state;
/* Transaction Number (used for subscription list) */
@@ -201,24 +202,24 @@ struct bt_mesh_lpn {
u16_t groups[LPN_GROUPS];
/* Bit fields for tracking which groups the Friend knows about */
ATOMIC_DEFINE(added, LPN_GROUPS);
ATOMIC_DEFINE(pending, LPN_GROUPS);
ATOMIC_DEFINE(to_remove, LPN_GROUPS);
BLE_MESH_ATOMIC_DEFINE(added, LPN_GROUPS);
BLE_MESH_ATOMIC_DEFINE(pending, LPN_GROUPS);
BLE_MESH_ATOMIC_DEFINE(to_remove, LPN_GROUPS);
};
/* bt_mesh_net.flags, mainly used for pending storage actions */
enum {
BT_MESH_RPL_PENDING,
BT_MESH_KEYS_PENDING,
BT_MESH_NET_PENDING,
BT_MESH_IV_PENDING,
BT_MESH_SEQ_PENDING,
BT_MESH_HB_PUB_PENDING,
BT_MESH_CFG_PENDING,
BT_MESH_MOD_PENDING,
BLE_MESH_RPL_PENDING,
BLE_MESH_KEYS_PENDING,
BLE_MESH_NET_PENDING,
BLE_MESH_IV_PENDING,
BLE_MESH_SEQ_PENDING,
BLE_MESH_HB_PUB_PENDING,
BLE_MESH_CFG_PENDING,
BLE_MESH_MOD_PENDING,
/* Don't touch - intentionally last */
BT_MESH_FLAG_COUNT,
BLE_MESH_FLAG_COUNT,
};
struct bt_mesh_net {
@@ -232,18 +233,18 @@ struct bt_mesh_net {
s64_t last_update; /* Time since last IV Update change */
ATOMIC_DEFINE(flags, BT_MESH_FLAG_COUNT);
BLE_MESH_ATOMIC_DEFINE(flags, BLE_MESH_FLAG_COUNT);
/* Local network interface */
struct k_work local_work;
sys_slist_t local_queue;
#if defined(CONFIG_BT_MESH_FRIEND)
#if defined(CONFIG_BLE_MESH_FRIEND)
/* Friend state, unique for each LPN that we're Friends for */
struct bt_mesh_friend frnd[CONFIG_BT_MESH_FRIEND_LPN_COUNT];
struct bt_mesh_friend frnd[CONFIG_BLE_MESH_FRIEND_LPN_COUNT];
#endif
#if defined(CONFIG_BT_MESH_LOW_POWER)
#if defined(CONFIG_BLE_MESH_LOW_POWER)
struct bt_mesh_lpn lpn; /* Low Power Node state */
#endif
@@ -252,22 +253,22 @@ struct bt_mesh_net {
u8_t dev_key[16];
struct bt_mesh_app_key app_keys[CONFIG_BT_MESH_APP_KEY_COUNT];
struct bt_mesh_app_key app_keys[CONFIG_BLE_MESH_APP_KEY_COUNT];
struct bt_mesh_subnet sub[CONFIG_BT_MESH_SUBNET_COUNT];
struct bt_mesh_subnet sub[CONFIG_BLE_MESH_SUBNET_COUNT];
struct bt_mesh_rpl rpl[CONFIG_BT_MESH_CRPL];
struct bt_mesh_rpl rpl[CONFIG_BLE_MESH_CRPL];
#if CONFIG_BT_MESH_PROVISIONER
#if CONFIG_BLE_MESH_PROVISIONER
/* Provisioner and node share arguments from 'iv_index' to 'local_queue' + 'ivu_complete' */
/* Application keys stored by provisioner */
struct bt_mesh_app_key *p_app_keys[CONFIG_BT_MESH_PROVISIONER_APP_KEY_COUNT];
struct bt_mesh_app_key *p_app_keys[CONFIG_BLE_MESH_PROVISIONER_APP_KEY_COUNT];
/* Next app_idx can be assigned */
u16_t p_app_idx_next;
/* Network keys stored by provisioner */
struct bt_mesh_subnet *p_sub[CONFIG_BT_MESH_PROVISIONER_SUBNET_COUNT];
struct bt_mesh_subnet *p_sub[CONFIG_BLE_MESH_PROVISIONER_SUBNET_COUNT];
/* Next net_idx can be assigned */
u16_t p_net_idx_next;
#endif
@@ -275,10 +276,10 @@ struct bt_mesh_net {
/* Network interface */
enum bt_mesh_net_if {
BT_MESH_NET_IF_ADV,
BT_MESH_NET_IF_LOCAL,
BT_MESH_NET_IF_PROXY,
BT_MESH_NET_IF_PROXY_CFG,
BLE_MESH_NET_IF_ADV,
BLE_MESH_NET_IF_LOCAL,
BLE_MESH_NET_IF_PROXY,
BLE_MESH_NET_IF_PROXY_CFG,
};
/* Decoding context for Network/Transport data */
@@ -310,10 +311,10 @@ struct bt_mesh_net_tx {
extern struct bt_mesh_net bt_mesh;
#define BT_MESH_NET_IVI_TX (bt_mesh.iv_index - bt_mesh.iv_update)
#define BT_MESH_NET_IVI_RX(rx) (bt_mesh.iv_index - (rx)->old_iv)
#define BLE_MESH_NET_IVI_TX (bt_mesh.iv_index - bt_mesh.iv_update)
#define BLE_MESH_NET_IVI_RX(rx) (bt_mesh.iv_index - (rx)->old_iv)
#define BT_MESH_NET_HDR_LEN 9
#define BLE_MESH_NET_HDR_LEN 9
int bt_mesh_net_keys_create(struct bt_mesh_subnet_keys *keys,
const u8_t key[16]);
@@ -388,4 +389,4 @@ struct friend_cred *friend_cred_create(struct bt_mesh_subnet *sub, u16_t addr,
void friend_cred_clear(struct friend_cred *cred);
int friend_cred_del(u16_t net_idx, u16_t addr);
#endif /* #ifndef _NET_H_ */
#endif /* _NET_H_ */

View File

@@ -9,15 +9,12 @@
#include <errno.h>
#include <string.h>
#include "mesh_util.h"
#include "sdkconfig.h"
#if CONFIG_BT_MESH
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_PROV)
#include "mesh_util.h"
#include "mesh_main.h"
#include "mesh_bt_uuid.h"
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_PROV)
#include "mesh_uuid.h"
#include "mesh_trace.h"
#include "crypto.h"
@@ -29,7 +26,7 @@
#include "proxy.h"
#include "prov.h"
#if CONFIG_BT_MESH_NODE
#if CONFIG_BLE_MESH_NODE
/* 3 transmissions, 20ms interval */
#define PROV_XMIT_COUNT 2
@@ -115,9 +112,9 @@ enum {
};
struct prov_link {
ATOMIC_DEFINE(flags, NUM_FLAGS);
#if defined(CONFIG_BT_MESH_PB_GATT)
struct bt_conn *conn; /* GATT connection */
BLE_MESH_ATOMIC_DEFINE(flags, NUM_FLAGS);
#if defined(CONFIG_BLE_MESH_PB_GATT)
struct bt_mesh_conn *conn; /* GATT connection */
#endif
u8_t dhkey[32]; /* Calculated DHKey */
u8_t expect; /* Next expected PDU */
@@ -137,7 +134,7 @@ struct prov_link {
u8_t conf_inputs[145]; /* ConfirmationInputs */
u8_t prov_salt[16]; /* Provisioning Salt */
#if defined(CONFIG_BT_MESH_PB_ADV)
#if defined(CONFIG_BLE_MESH_PB_ADV)
u32_t id; /* Link ID */
struct {
@@ -176,15 +173,15 @@ struct prov_rx {
#define RETRANSMIT_TIMEOUT K_MSEC(500)
#define BUF_TIMEOUT K_MSEC(400)
#if defined(CONFIG_BT_MESH_FAST_PROV)
#if defined(CONFIG_BLE_MESH_FAST_PROV)
#define TRANSACTION_TIMEOUT K_SECONDS(3)
#define PROVISION_TIMEOUT K_SECONDS(6)
#else
#define TRANSACTION_TIMEOUT K_SECONDS(30)
#define PROVISION_TIMEOUT K_SECONDS(60)
#endif /* CONFIG_BT_MESH_FAST_PROV */
#endif /* CONFIG_BLE_MESH_FAST_PROV */
#if defined(CONFIG_BT_MESH_PB_GATT)
#if defined(CONFIG_BLE_MESH_PB_GATT)
#define PROV_BUF_HEADROOM 5
#else
#define PROV_BUF_HEADROOM 0
@@ -199,7 +196,7 @@ static const struct bt_mesh_prov *prov;
static void close_link(u8_t err, u8_t reason);
#if defined(CONFIG_BT_MESH_PB_ADV)
#if defined(CONFIG_BLE_MESH_PB_ADV)
static void buf_sent(int err, void *user_data)
{
if (!link.tx.buf[0]) {
@@ -226,7 +223,7 @@ static void free_segments(void)
link.tx.buf[i] = NULL;
/* Mark as canceled */
BT_MESH_ADV(buf)->busy = 0;
BLE_MESH_ADV(buf)->busy = 0;
/** Change by Espressif. Add this to avoid buf->ref is 2 which will
* cause lack of buf.
*/
@@ -255,18 +252,18 @@ static void reset_link(void)
bt_mesh_attention(NULL, 0);
}
if (atomic_test_and_clear_bit(link.flags, TIMEOUT_START)) {
if (bt_mesh_atomic_test_and_clear_bit(link.flags, TIMEOUT_START)) {
k_delayed_work_cancel(&link.timeout);
}
if (prov->link_close) {
prov->link_close(BT_MESH_PROV_ADV);
prov->link_close(BLE_MESH_PROV_ADV);
}
#if defined(CONFIG_BT_MESH_USE_DUPLICATE_SCAN)
#if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN)
/* Remove the link id from exceptional list */
bt_mesh_update_exceptional_list(BT_MESH_EXCEP_LIST_REMOVE,
BT_MESH_EXCEP_INFO_MESH_LINK_ID, &link.id);
bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_REMOVE,
BLE_MESH_EXCEP_INFO_MESH_LINK_ID, &link.id);
#endif
/* Clear everything except the retransmit delayed work config */
@@ -275,10 +272,10 @@ static void reset_link(void)
link.rx.prev_id = XACT_NVAL;
if (bt_mesh_pub_key_get()) {
atomic_set_bit(link.flags, LOCAL_PUB_KEY);
bt_mesh_atomic_set_bit(link.flags, LOCAL_PUB_KEY);
}
#if defined(CONFIG_BT_MESH_PB_GATT)
#if defined(CONFIG_BLE_MESH_PB_GATT)
link.rx.buf = bt_mesh_proxy_get_buf();
#else
net_buf_simple_init(rx_buf, 0);
@@ -290,10 +287,10 @@ static struct net_buf *adv_buf_create(void)
{
struct net_buf *buf;
buf = bt_mesh_adv_create(BT_MESH_ADV_PROV, PROV_XMIT_COUNT,
buf = bt_mesh_adv_create(BLE_MESH_ADV_PROV, PROV_XMIT_COUNT,
PROV_XMIT_INT, BUF_TIMEOUT);
if (!buf) {
BT_ERR("Out of provisioning buffers");
BT_ERR("%s, Out of provisioning buffers", __func__);
return NULL;
}
@@ -438,7 +435,7 @@ static int prov_send_adv(struct net_buf_simple *msg)
/* Change by Espressif, get message type */
type = msg->data[0];
seg_len = min(msg->len, START_PAYLOAD_MAX);
seg_len = MIN(msg->len, START_PAYLOAD_MAX);
BT_DBG("seg 0 len %u: %s", seg_len, bt_hex(msg->data, seg_len));
net_buf_add_mem(start, msg->data, seg_len);
net_buf_simple_pull(msg, seg_len);
@@ -446,7 +443,7 @@ static int prov_send_adv(struct net_buf_simple *msg)
buf = start;
for (seg_id = 1; msg->len > 0; seg_id++) {
if (seg_id >= ARRAY_SIZE(link.tx.buf)) {
BT_ERR("Too big message");
BT_ERR("%s, Too big message", __func__);
free_segments();
return -E2BIG;
}
@@ -459,7 +456,7 @@ static int prov_send_adv(struct net_buf_simple *msg)
link.tx.buf[seg_id] = buf;
seg_len = min(msg->len, CONT_PAYLOAD_MAX);
seg_len = MIN(msg->len, CONT_PAYLOAD_MAX);
BT_DBG("seg_id %u len %u: %s", seg_id, seg_len,
bt_hex(msg->data, seg_len));
@@ -476,11 +473,11 @@ static int prov_send_adv(struct net_buf_simple *msg)
/* Change by Espressif, add provisioning timeout timer operations.
* When sending a provisioning PDU successfully, restart the 60s timer.
*/
if (atomic_test_and_clear_bit(link.flags, TIMEOUT_START)) {
if (bt_mesh_atomic_test_and_clear_bit(link.flags, TIMEOUT_START)) {
k_delayed_work_cancel(&link.timeout);
}
if (type != PROV_COMPLETE && type != PROV_FAILED) {
if (!atomic_test_and_set_bit(link.flags, TIMEOUT_START)) {
if (!bt_mesh_atomic_test_and_set_bit(link.flags, TIMEOUT_START)) {
k_delayed_work_submit(&link.timeout, PROVISION_TIMEOUT);
}
}
@@ -488,9 +485,9 @@ static int prov_send_adv(struct net_buf_simple *msg)
return 0;
}
#endif /* CONFIG_BT_MESH_PB_ADV */
#endif /* CONFIG_BLE_MESH_PB_ADV */
#if defined(CONFIG_BT_MESH_PB_GATT)
#if defined(CONFIG_BLE_MESH_PB_GATT)
static int prov_send_gatt(struct net_buf_simple *msg)
{
int err = 0;
@@ -502,33 +499,33 @@ static int prov_send_gatt(struct net_buf_simple *msg)
/* Change by Espressif, add provisioning timeout timer operations.
* When sending a provisioning PDU successfully, restart the 60s timer.
*/
err = bt_mesh_proxy_send(link.conn, BT_MESH_PROXY_PROV, msg);
err = bt_mesh_proxy_send(link.conn, BLE_MESH_PROXY_PROV, msg);
if (err) {
BT_ERR("%s: fail to send provisioning PDU", __func__);
BT_ERR("%s, Failed to send provisioning PDU", __func__);
return err;
}
if (atomic_test_and_clear_bit(link.flags, TIMEOUT_START)) {
if (bt_mesh_atomic_test_and_clear_bit(link.flags, TIMEOUT_START)) {
k_delayed_work_cancel(&link.timeout);
}
if (msg->data[1] != PROV_COMPLETE && msg->data[1] != PROV_FAILED) {
if (!atomic_test_and_set_bit(link.flags, TIMEOUT_START)) {
if (!bt_mesh_atomic_test_and_set_bit(link.flags, TIMEOUT_START)) {
k_delayed_work_submit(&link.timeout, PROVISION_TIMEOUT);
}
}
return 0;
}
#endif /* CONFIG_BT_MESH_PB_GATT */
#endif /* CONFIG_BLE_MESH_PB_GATT */
static inline int prov_send(struct net_buf_simple *buf)
{
#if defined(CONFIG_BT_MESH_PB_GATT)
#if defined(CONFIG_BLE_MESH_PB_GATT)
if (link.conn) {
return prov_send_gatt(buf);
}
#endif
#if defined(CONFIG_BT_MESH_PB_ADV)
#if defined(CONFIG_BLE_MESH_PB_ADV)
return prov_send_adv(buf);
#else
return 0;
@@ -591,7 +588,7 @@ static void prov_invite(const u8_t *data)
memcpy(&link.conf_inputs[1], &buf->data[1], 11);
if (prov_send(buf)) {
BT_ERR("Failed to send capabilities");
BT_ERR("%s, Failed to send capabilities", __func__);
close_link(PROV_ERR_RESOURCES, CLOSE_REASON_FAILED);
return;
}
@@ -625,17 +622,17 @@ static bt_mesh_output_action_t output_action(u8_t action)
{
switch (action) {
case OUTPUT_OOB_BLINK:
return BT_MESH_BLINK;
return BLE_MESH_BLINK;
case OUTPUT_OOB_BEEP:
return BT_MESH_BEEP;
return BLE_MESH_BEEP;
case OUTPUT_OOB_VIBRATE:
return BT_MESH_VIBRATE;
return BLE_MESH_VIBRATE;
case OUTPUT_OOB_NUMBER:
return BT_MESH_DISPLAY_NUMBER;
return BLE_MESH_DISPLAY_NUMBER;
case OUTPUT_OOB_STRING:
return BT_MESH_DISPLAY_STRING;
return BLE_MESH_DISPLAY_STRING;
default:
return BT_MESH_NO_OUTPUT;
return BLE_MESH_NO_OUTPUT;
}
}
@@ -643,15 +640,15 @@ static bt_mesh_input_action_t input_action(u8_t action)
{
switch (action) {
case INPUT_OOB_PUSH:
return BT_MESH_PUSH;
return BLE_MESH_PUSH;
case INPUT_OOB_TWIST:
return BT_MESH_TWIST;
return BLE_MESH_TWIST;
case INPUT_OOB_NUMBER:
return BT_MESH_ENTER_NUMBER;
return BLE_MESH_ENTER_NUMBER;
case INPUT_OOB_STRING:
return BT_MESH_ENTER_STRING;
return BLE_MESH_ENTER_STRING;
default:
return BT_MESH_NO_INPUT;
return BLE_MESH_NO_INPUT;
}
}
@@ -692,7 +689,7 @@ static int prov_auth(u8_t method, u8_t action, u8_t size)
return -EINVAL;
}
if (output == BT_MESH_DISPLAY_STRING) {
if (output == BLE_MESH_DISPLAY_STRING) {
unsigned char str[9];
u8_t i;
@@ -742,10 +739,10 @@ static int prov_auth(u8_t method, u8_t action, u8_t size)
return -EINVAL;
}
if (input == BT_MESH_ENTER_STRING) {
atomic_set_bit(link.flags, WAIT_STRING);
if (input == BLE_MESH_ENTER_STRING) {
bt_mesh_atomic_set_bit(link.flags, WAIT_STRING);
} else {
atomic_set_bit(link.flags, WAIT_NUMBER);
bt_mesh_atomic_set_bit(link.flags, WAIT_NUMBER);
}
return prov->input(input, size);
@@ -764,13 +761,13 @@ static void prov_start(const u8_t *data)
BT_DBG("Auth Size: 0x%02x", data[4]);
if (data[0] != PROV_ALG_P256) {
BT_ERR("Unknown algorithm 0x%02x", data[0]);
BT_ERR("%s, Unknown algorithm 0x%02x", __func__, data[0]);
prov_send_fail_msg(PROV_ERR_NVAL_FMT);
return;
}
if (data[1] > 0x01) {
BT_ERR("Invalid public key value: 0x%02x", data[1]);
BT_ERR("%s, Invalid public key value: 0x%02x", __func__, data[1]);
prov_send_fail_msg(PROV_ERR_NVAL_FMT);
return;
}
@@ -789,9 +786,9 @@ static void prov_start(const u8_t *data)
}
if (prov_auth(data[2], data[3], data[4]) < 0) {
BT_ERR("Invalid authentication method: 0x%02x; "
"action: 0x%02x; size: 0x%02x", data[2], data[3],
data[4]);
BT_ERR("%s, Invalid authentication method: 0x%02x; "
"action: 0x%02x; size: 0x%02x",
__func__, data[2], data[3], data[4]);
prov_send_fail_msg(PROV_ERR_NVAL_FMT);
}
}
@@ -805,7 +802,7 @@ static void send_confirm(void)
BT_DBG("ConfInputs[128] %s", bt_hex(&link.conf_inputs[128], 17));
if (bt_mesh_prov_conf_salt(link.conf_inputs, link.conf_salt)) {
BT_ERR("Unable to generate confirmation salt");
BT_ERR("%s, Unable to generate confirmation salt", __func__);
close_link(PROV_ERR_UNEXP_ERR, CLOSE_REASON_FAILED);
return;
}
@@ -813,7 +810,7 @@ static void send_confirm(void)
BT_DBG("ConfirmationSalt: %s", bt_hex(link.conf_salt, 16));
if (bt_mesh_prov_conf_key(link.dhkey, link.conf_salt, link.conf_key)) {
BT_ERR("Unable to generate confirmation key");
BT_ERR("%s, Unable to generate confirmation key", __func__);
close_link(PROV_ERR_UNEXP_ERR, CLOSE_REASON_FAILED);
return;
}
@@ -821,7 +818,7 @@ static void send_confirm(void)
BT_DBG("ConfirmationKey: %s", bt_hex(link.conf_key, 16));
if (bt_mesh_rand(link.rand, 16)) {
BT_ERR("Unable to generate random number");
BT_ERR("%s, Unable to generate random number", __func__);
close_link(PROV_ERR_UNEXP_ERR, CLOSE_REASON_FAILED);
return;
}
@@ -832,13 +829,13 @@ static void send_confirm(void)
if (bt_mesh_prov_conf(link.conf_key, link.rand, link.auth,
net_buf_simple_add(cfm, 16))) {
BT_ERR("Unable to generate confirmation value");
BT_ERR("%s, Unable to generate confirmation value", __func__);
close_link(PROV_ERR_UNEXP_ERR, CLOSE_REASON_FAILED);
return;
}
if (prov_send(cfm)) {
BT_ERR("Failed to send Provisioning Confirm");
BT_ERR("%s, Unable to send Provisioning Confirm", __func__);
close_link(PROV_ERR_RESOURCES, CLOSE_REASON_FAILED);
return;
}
@@ -858,7 +855,7 @@ int bt_mesh_input_number(u32_t num)
{
BT_DBG("%u", num);
if (!atomic_test_and_clear_bit(link.flags, WAIT_NUMBER)) {
if (!bt_mesh_atomic_test_and_clear_bit(link.flags, WAIT_NUMBER)) {
return -EINVAL;
}
@@ -866,11 +863,11 @@ int bt_mesh_input_number(u32_t num)
send_input_complete();
if (!atomic_test_bit(link.flags, HAVE_DHKEY)) {
if (!bt_mesh_atomic_test_bit(link.flags, HAVE_DHKEY)) {
return 0;
}
if (atomic_test_and_clear_bit(link.flags, SEND_CONFIRM)) {
if (bt_mesh_atomic_test_and_clear_bit(link.flags, SEND_CONFIRM)) {
send_confirm();
}
@@ -881,7 +878,7 @@ int bt_mesh_input_string(const char *str)
{
BT_DBG("%s", str);
if (!atomic_test_and_clear_bit(link.flags, WAIT_STRING)) {
if (!bt_mesh_atomic_test_and_clear_bit(link.flags, WAIT_STRING)) {
return -EINVAL;
}
@@ -889,11 +886,11 @@ int bt_mesh_input_string(const char *str)
send_input_complete();
if (!atomic_test_bit(link.flags, HAVE_DHKEY)) {
if (!bt_mesh_atomic_test_bit(link.flags, HAVE_DHKEY)) {
return 0;
}
if (atomic_test_and_clear_bit(link.flags, SEND_CONFIRM)) {
if (bt_mesh_atomic_test_and_clear_bit(link.flags, SEND_CONFIRM)) {
send_confirm();
}
@@ -905,7 +902,7 @@ static void prov_dh_key_cb(const u8_t key[32])
BT_DBG("%p", key);
if (!key) {
BT_ERR("DHKey generation failed");
BT_ERR("%s, DHKey generation failed", __func__);
close_link(PROV_ERR_UNEXP_ERR, CLOSE_REASON_FAILED);
return;
}
@@ -914,14 +911,14 @@ static void prov_dh_key_cb(const u8_t key[32])
BT_DBG("DHkey: %s", bt_hex(link.dhkey, 32));
atomic_set_bit(link.flags, HAVE_DHKEY);
bt_mesh_atomic_set_bit(link.flags, HAVE_DHKEY);
if (atomic_test_bit(link.flags, WAIT_NUMBER) ||
atomic_test_bit(link.flags, WAIT_STRING)) {
if (bt_mesh_atomic_test_bit(link.flags, WAIT_NUMBER) ||
bt_mesh_atomic_test_bit(link.flags, WAIT_STRING)) {
return;
}
if (atomic_test_and_clear_bit(link.flags, SEND_CONFIRM)) {
if (bt_mesh_atomic_test_and_clear_bit(link.flags, SEND_CONFIRM)) {
send_confirm();
}
}
@@ -933,7 +930,7 @@ static void send_pub_key(void)
key = bt_mesh_pub_key_get();
if (!key) {
BT_ERR("No public key available");
BT_ERR("%s, No public key available", __func__);
close_link(PROV_ERR_RESOURCES, CLOSE_REASON_FAILED);
return;
}
@@ -958,7 +955,7 @@ static void send_pub_key(void)
sys_memcpy_swap(&buf->data[32], &link.conf_inputs[49], 32);
if (bt_mesh_dh_key_gen(buf->data, prov_dh_key_cb)) {
BT_ERR("Failed to generate DHKey");
BT_ERR("%s, Unable to generate DHKey", __func__);
close_link(PROV_ERR_UNEXP_ERR, CLOSE_REASON_FAILED);
return;
}
@@ -978,7 +975,7 @@ static int bt_mesh_calc_dh_key(void)
sys_memcpy_swap(&buf->data[32], &link.conf_inputs[49], 32);
if (bt_mesh_dh_key_gen(buf->data, prov_dh_key_cb)) {
BT_ERR("%s, Failed to generate DHKey", __func__);
BT_ERR("%s, Unable to generate DHKey", __func__);
close_link(PROV_ERR_UNEXP_ERR, CLOSE_REASON_FAILED);
return -EIO;
}
@@ -990,7 +987,7 @@ 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])
{
if (!pub_key_x || !pub_key_y || !pri_key) {
BT_ERR("%s, invalid argument", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return -EINVAL;
}
@@ -1002,10 +999,10 @@ int bt_mesh_set_oob_pub_key(const u8_t pub_key_x[32], const u8_t pub_key_y[32],
sys_memcpy_swap(&link.conf_inputs[81] + 32, pub_key_y, 32);
bt_mesh_set_private_key(pri_key);
atomic_set_bit(link.flags, OOB_PUB_KEY);
bt_mesh_atomic_set_bit(link.flags, OOB_PUB_KEY);
/* If remote public key is not got, just return */
if (!atomic_test_bit(link.flags, REMOTE_PUB_KEY)) {
if (!bt_mesh_atomic_test_bit(link.flags, REMOTE_PUB_KEY)) {
return 0;
}
@@ -1023,26 +1020,26 @@ static void prov_pub_key(const u8_t *data)
* (3) X = 0, Y = 0
*/
if (!bt_mesh_check_public_key(data)) {
BT_ERR("%s: Invalid public key", __func__);
BT_ERR("%s, Invalid public key", __func__);
prov_send_fail_msg(PROV_ERR_UNEXP_PDU);
return;
}
memcpy(&link.conf_inputs[17], data, 64);
atomic_set_bit(link.flags, REMOTE_PUB_KEY);
/* TODO: Change by Espressif.
Temporary modification. Generating publish keys is not supported by the controller now */
bt_mesh_atomic_set_bit(link.flags, REMOTE_PUB_KEY);
#if 0
if (!atomic_test_bit(link.flags, LOCAL_PUB_KEY)) {
if (!bt_mesh_atomic_test_bit(link.flags, LOCAL_PUB_KEY)) {
/* Clear retransmit timer */
#if defined(CONFIG_BT_MESH_PB_ADV)
#if defined(CONFIG_BLE_MESH_PB_ADV)
prov_clear_tx();
#endif
atomic_set_bit(link.flags, REMOTE_PUB_KEY);
bt_mesh_atomic_set_bit(link.flags, REMOTE_PUB_KEY);
BT_WARN("Waiting for a local public key");
return;
}
#endif /* #if 0 */
#endif
if (!link.oob_pk_flag) {
send_pub_key();
} else {
@@ -1050,25 +1047,6 @@ static void prov_pub_key(const u8_t *data)
}
}
#if 0
/* Change by Espressif, currently mask this function */
static void pub_key_ready(const u8_t *pkey)
{
if (!pkey) {
BT_WARN("Public key not available");
return;
}
BT_DBG("Local public key ready");
atomic_set_bit(link.flags, LOCAL_PUB_KEY);
if (atomic_test_and_clear_bit(link.flags, REMOTE_PUB_KEY)) {
send_pub_key();
}
}
#endif
static void prov_input_complete(const u8_t *data)
{
BT_DBG("%s", __func__);
@@ -1080,13 +1058,13 @@ static void prov_confirm(const u8_t *data)
memcpy(link.conf, data, 16);
if (!atomic_test_bit(link.flags, HAVE_DHKEY)) {
#if defined(CONFIG_BT_MESH_PB_ADV)
if (!bt_mesh_atomic_test_bit(link.flags, HAVE_DHKEY)) {
#if defined(CONFIG_BLE_MESH_PB_ADV)
prov_clear_tx();
#endif
atomic_set_bit(link.flags, SEND_CONFIRM);
bt_mesh_atomic_set_bit(link.flags, SEND_CONFIRM);
/* If using OOB public key and it has already got, calculates dhkey */
if (link.oob_pk_flag && atomic_test_bit(link.flags, OOB_PUB_KEY)) {
if (link.oob_pk_flag && bt_mesh_atomic_test_bit(link.flags, OOB_PUB_KEY)) {
bt_mesh_calc_dh_key();
}
} else {
@@ -1102,13 +1080,13 @@ static void prov_random(const u8_t *data)
BT_DBG("Remote Random: %s", bt_hex(data, 16));
if (bt_mesh_prov_conf(link.conf_key, data, link.auth, conf_verify)) {
BT_ERR("Unable to calculate confirmation verification");
BT_ERR("%s, Unable to calculate confirmation verification", __func__);
close_link(PROV_ERR_UNEXP_ERR, CLOSE_REASON_FAILED);
return;
}
if (memcmp(conf_verify, link.conf, 16)) {
BT_ERR("Invalid confirmation value");
BT_ERR("%s, Invalid confirmation value", __func__);
BT_DBG("Received: %s", bt_hex(link.conf, 16));
BT_DBG("Calculated: %s", bt_hex(conf_verify, 16));
close_link(PROV_ERR_CFM_FAILED, CLOSE_REASON_FAILED);
@@ -1119,14 +1097,14 @@ static void prov_random(const u8_t *data)
net_buf_simple_add_mem(rnd, link.rand, 16);
if (prov_send(rnd)) {
BT_ERR("Failed to send Provisioning Random");
BT_ERR("%s, Failed to send Provisioning Random", __func__);
close_link(PROV_ERR_RESOURCES, CLOSE_REASON_FAILED);
return;
}
if (bt_mesh_prov_salt(link.conf_salt, data, link.rand,
link.prov_salt)) {
BT_ERR("Failed to generate provisioning salt");
BT_ERR("%s, Failed to generate provisioning salt", __func__);
close_link(PROV_ERR_UNEXP_ERR, CLOSE_REASON_FAILED);
return;
}
@@ -1153,7 +1131,7 @@ static void prov_data(const u8_t *data)
err = bt_mesh_session_key(link.dhkey, link.prov_salt, session_key);
if (err) {
BT_ERR("Unable to generate session key");
BT_ERR("%s, Unable to generate session key", __func__);
close_link(PROV_ERR_UNEXP_ERR, CLOSE_REASON_FAILED);
return;
}
@@ -1162,7 +1140,7 @@ static void prov_data(const u8_t *data)
err = bt_mesh_prov_nonce(link.dhkey, link.prov_salt, nonce);
if (err) {
BT_ERR("Unable to generate session nonce");
BT_ERR("%s, Unable to generate session nonce", __func__);
close_link(PROV_ERR_UNEXP_ERR, CLOSE_REASON_FAILED);
return;
}
@@ -1171,14 +1149,14 @@ static void prov_data(const u8_t *data)
err = bt_mesh_prov_decrypt(session_key, nonce, data, pdu);
if (err) {
BT_ERR("Unable to decrypt provisioning data");
BT_ERR("%s, Unable to decrypt provisioning data", __func__);
close_link(PROV_ERR_DECRYPT, CLOSE_REASON_FAILED);
return;
}
err = bt_mesh_dev_key(link.dhkey, link.prov_salt, dev_key);
if (err) {
BT_ERR("Unable to generate device key");
BT_ERR("%s, Unable to generate device key", __func__);
close_link(PROV_ERR_UNEXP_ERR, CLOSE_REASON_FAILED);
return;
}
@@ -1230,14 +1208,14 @@ static const struct {
static void close_link(u8_t err, u8_t reason)
{
#if defined(CONFIG_BT_MESH_PB_GATT)
#if defined(CONFIG_BLE_MESH_PB_GATT)
if (link.conn) {
bt_mesh_pb_gatt_close(link.conn);
return;
}
#endif
#if defined(CONFIG_BT_MESH_PB_ADV)
#if defined(CONFIG_BLE_MESH_PB_ADV)
if (err) {
prov_send_fail_msg(err);
}
@@ -1246,7 +1224,7 @@ static void close_link(u8_t err, u8_t reason)
bearer_ctl_send(LINK_CLOSE, &reason, sizeof(reason));
#endif
atomic_clear_bit(link.flags, LINK_ACTIVE);
bt_mesh_atomic_clear_bit(link.flags, LINK_ACTIVE);
/* Disable Attention Timer if it was set before */
if (link.conf_inputs[0]) {
@@ -1262,14 +1240,14 @@ static void prov_timeout(struct k_work *work)
close_link(PROV_ERR_UNEXP_ERR, CLOSE_REASON_TIMEOUT);
}
#if defined(CONFIG_BT_MESH_PB_ADV)
#if defined(CONFIG_BLE_MESH_PB_ADV)
static void prov_retransmit(struct k_work *work)
{
int i;
BT_DBG("%s", __func__);
if (!atomic_test_bit(link.flags, LINK_ACTIVE)) {
if (!bt_mesh_atomic_test_bit(link.flags, LINK_ACTIVE)) {
BT_WARN("Link not active");
return;
}
@@ -1287,7 +1265,7 @@ static void prov_retransmit(struct k_work *work)
break;
}
if (BT_MESH_ADV(buf)->busy) {
if (BLE_MESH_ADV(buf)->busy) {
continue;
}
@@ -1307,11 +1285,11 @@ static void link_open(struct prov_rx *rx, struct net_buf_simple *buf)
BT_DBG("len %u", buf->len);
if (buf->len < 16) {
BT_ERR("Too short bearer open message (len %u)", buf->len);
BT_ERR("%s, Too short bearer open message (len %u)", __func__, buf->len);
return;
}
if (atomic_test_bit(link.flags, LINK_ACTIVE)) {
if (bt_mesh_atomic_test_bit(link.flags, LINK_ACTIVE)) {
BT_WARN("Ignoring bearer open: link already active");
return;
}
@@ -1322,17 +1300,17 @@ static void link_open(struct prov_rx *rx, struct net_buf_simple *buf)
}
if (prov->link_open) {
prov->link_open(BT_MESH_PROV_ADV);
prov->link_open(BLE_MESH_PROV_ADV);
}
link.id = rx->link_id;
atomic_set_bit(link.flags, LINK_ACTIVE);
bt_mesh_atomic_set_bit(link.flags, LINK_ACTIVE);
net_buf_simple_init(link.rx.buf, 0);
#if defined(CONFIG_BT_MESH_USE_DUPLICATE_SCAN)
#if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN)
/* Add the link id into exceptional list */
bt_mesh_update_exceptional_list(BT_MESH_EXCEP_LIST_ADD,
BT_MESH_EXCEP_INFO_MESH_LINK_ID, &link.id);
bt_mesh_update_exceptional_list(BLE_MESH_EXCEP_LIST_ADD,
BLE_MESH_EXCEP_INFO_MESH_LINK_ID, &link.id);
#endif
bearer_ctl_send(LINK_ACK, NULL, 0);
@@ -1361,21 +1339,21 @@ static void gen_prov_ctl(struct prov_rx *rx, struct net_buf_simple *buf)
link_open(rx, buf);
break;
case LINK_ACK:
if (!atomic_test_bit(link.flags, LINK_ACTIVE)) {
if (!bt_mesh_atomic_test_bit(link.flags, LINK_ACTIVE)) {
return;
}
link_ack(rx, buf);
break;
case LINK_CLOSE:
if (!atomic_test_bit(link.flags, LINK_ACTIVE)) {
if (!bt_mesh_atomic_test_bit(link.flags, LINK_ACTIVE)) {
return;
}
link_close(rx, buf);
break;
default:
BT_ERR("Unknown bearer opcode: 0x%02x", BEARER_CTL(rx->gpc));
BT_ERR("%s, Unknown bearer opcode 0x%02x", __func__, BEARER_CTL(rx->gpc));
return;
}
}
@@ -1387,7 +1365,7 @@ static void prov_msg_recv(void)
BT_DBG("type 0x%02x len %u", type, link.rx.buf->len);
if (!bt_mesh_fcs_check(link.rx.buf, link.rx.fcs)) {
BT_ERR("Incorrect FCS");
BT_ERR("%s, Incorrect FCS", __func__);
return;
}
@@ -1402,14 +1380,14 @@ static void prov_msg_recv(void)
}
if (type >= ARRAY_SIZE(prov_handlers)) {
BT_ERR("Unknown provisioning PDU type 0x%02x", type);
BT_ERR("%s, Unknown provisioning PDU type 0x%02x", __func__, type);
close_link(PROV_ERR_NVAL_PDU, CLOSE_REASON_FAILED);
return;
}
if (1 + prov_handlers[type].len != link.rx.buf->len) {
BT_ERR("Invalid length %u for type 0x%02x",
link.rx.buf->len, type);
BT_ERR("%s, Invalid length %u for type 0x%02x",
__func__, link.rx.buf->len, type);
close_link(PROV_ERR_NVAL_FMT, CLOSE_REASON_FAILED);
return;
}
@@ -1417,10 +1395,10 @@ static void prov_msg_recv(void)
/* Change by Espressif, add provisioning timeout timer operations.
* When received a provisioning PDU, restart the 60s timer.
*/
if (atomic_test_and_clear_bit(link.flags, TIMEOUT_START)) {
if (bt_mesh_atomic_test_and_clear_bit(link.flags, TIMEOUT_START)) {
k_delayed_work_cancel(&link.timeout);
}
if (!atomic_test_and_set_bit(link.flags, TIMEOUT_START)) {
if (!bt_mesh_atomic_test_and_set_bit(link.flags, TIMEOUT_START)) {
k_delayed_work_submit(&link.timeout, PROVISION_TIMEOUT);
}
@@ -1446,7 +1424,7 @@ static void gen_prov_cont(struct prov_rx *rx, struct net_buf_simple *buf)
}
if (seg > link.rx.last_seg) {
BT_ERR("Invalid segment index %u", seg);
BT_ERR("%s, Invalid segment index %u", __func__, seg);
close_link(PROV_ERR_NVAL_FMT, CLOSE_REASON_FAILED);
return;
} else if (seg == link.rx.last_seg) {
@@ -1455,8 +1433,8 @@ static void gen_prov_cont(struct prov_rx *rx, struct net_buf_simple *buf)
expect_len = (link.rx.buf->len - 20 -
(23 * (link.rx.last_seg - 1)));
if (expect_len != buf->len) {
BT_ERR("Incorrect last seg len: %u != %u",
expect_len, buf->len);
BT_ERR("%s, Incorrect last seg len: %u != %u",
__func__, expect_len, buf->len);
close_link(PROV_ERR_NVAL_FMT, CLOSE_REASON_FAILED);
return;
}
@@ -1509,20 +1487,20 @@ static void gen_prov_start(struct prov_rx *rx, struct net_buf_simple *buf)
START_LAST_SEG(rx->gpc), link.rx.buf->len, link.rx.fcs);
if (link.rx.buf->len < 1) {
BT_ERR("Ignoring zero-length provisioning PDU");
BT_ERR("%s, Ignoring zero-length provisioning PDU", __func__);
close_link(PROV_ERR_NVAL_FMT, CLOSE_REASON_FAILED);
return;
}
if (link.rx.buf->len > link.rx.buf->size) {
BT_ERR("Too large provisioning PDU (%u bytes)",
link.rx.buf->len);
BT_ERR("%s, Too large provisioning PDU (%u bytes)",
__func__, link.rx.buf->len);
close_link(PROV_ERR_NVAL_FMT, CLOSE_REASON_FAILED);
return;
}
if (START_LAST_SEG(rx->gpc) > 0 && link.rx.buf->len <= 20) {
BT_ERR("Too small total length for multi-segment PDU");
BT_ERR("%s, Too small total length for multi-segment PDU", __func__);
close_link(PROV_ERR_NVAL_FMT, CLOSE_REASON_FAILED);
return;
}
@@ -1551,11 +1529,11 @@ static const struct {
static void gen_prov_recv(struct prov_rx *rx, struct net_buf_simple *buf)
{
if (buf->len < gen_prov[GPCF(rx->gpc)].min_len) {
BT_ERR("Too short GPC message type %u", GPCF(rx->gpc));
BT_ERR("%s, Too short GPC message type %u", __func__, GPCF(rx->gpc));
return;
}
if (!atomic_test_bit(link.flags, LINK_ACTIVE) &&
if (!bt_mesh_atomic_test_bit(link.flags, LINK_ACTIVE) &&
gen_prov[GPCF(rx->gpc)].require_link) {
BT_DBG("Ignoring message that requires active link");
return;
@@ -1584,17 +1562,17 @@ void bt_mesh_pb_adv_recv(struct net_buf_simple *buf)
BT_DBG("link_id 0x%08x xact_id %u", rx.link_id, rx.xact_id);
if (atomic_test_bit(link.flags, LINK_ACTIVE) && link.id != rx.link_id) {
if (bt_mesh_atomic_test_bit(link.flags, LINK_ACTIVE) && link.id != rx.link_id) {
BT_DBG("Ignoring mesh beacon for unknown link");
return;
}
gen_prov_recv(&rx, buf);
}
#endif /* CONFIG_BT_MESH_PB_ADV */
#endif /* CONFIG_BLE_MESH_PB_ADV */
#if defined(CONFIG_BT_MESH_PB_GATT)
int bt_mesh_pb_gatt_recv(struct bt_conn *conn, struct net_buf_simple *buf)
#if defined(CONFIG_BLE_MESH_PB_GATT)
int bt_mesh_pb_gatt_recv(struct bt_mesh_conn *conn, struct net_buf_simple *buf)
{
u8_t type;
@@ -1618,22 +1596,22 @@ int bt_mesh_pb_gatt_recv(struct bt_conn *conn, struct net_buf_simple *buf)
}
if (type >= ARRAY_SIZE(prov_handlers)) {
BT_ERR("Unknown provisioning PDU type 0x%02x", type);
BT_ERR("%s, Unknown provisioning PDU type 0x%02x", __func__, type);
return -EINVAL;
}
if (prov_handlers[type].len != buf->len) {
BT_ERR("Invalid length %u for type 0x%02x", buf->len, type);
BT_ERR("%s, Invalid length %u for type 0x%02x", __func__, buf->len, type);
return -EINVAL;
}
/* Change by Espressif, add provisioning timeout timer operations.
* When received a provisioning PDU, restart the 60s timer.
*/
if (atomic_test_and_clear_bit(link.flags, TIMEOUT_START)) {
if (bt_mesh_atomic_test_and_clear_bit(link.flags, TIMEOUT_START)) {
k_delayed_work_cancel(&link.timeout);
}
if (!atomic_test_and_set_bit(link.flags, TIMEOUT_START)) {
if (!bt_mesh_atomic_test_and_set_bit(link.flags, TIMEOUT_START)) {
k_delayed_work_submit(&link.timeout, PROVISION_TIMEOUT);
}
@@ -1642,11 +1620,11 @@ int bt_mesh_pb_gatt_recv(struct bt_conn *conn, struct net_buf_simple *buf)
return 0;
}
int bt_mesh_pb_gatt_open(struct bt_conn *conn)
int bt_mesh_pb_gatt_open(struct bt_mesh_conn *conn)
{
BT_DBG("conn %p", conn);
if (atomic_test_and_set_bit(link.flags, LINK_ACTIVE)) {
if (bt_mesh_atomic_test_and_set_bit(link.flags, LINK_ACTIVE)) {
return -EBUSY;
}
@@ -1654,18 +1632,18 @@ int bt_mesh_pb_gatt_open(struct bt_conn *conn)
link.expect = PROV_INVITE;
if (prov->link_open) {
prov->link_open(BT_MESH_PROV_GATT);
prov->link_open(BLE_MESH_PROV_GATT);
}
return 0;
}
int bt_mesh_pb_gatt_close(struct bt_conn *conn)
int bt_mesh_pb_gatt_close(struct bt_mesh_conn *conn)
{
BT_DBG("conn %p", conn);
if (link.conn != conn) {
BT_ERR("Not connected");
BT_ERR("%s, Not connected", __func__);
return -ENOTCONN;
}
@@ -1675,17 +1653,17 @@ int bt_mesh_pb_gatt_close(struct bt_conn *conn)
}
if (prov->link_close) {
prov->link_close(BT_MESH_PROV_GATT);
prov->link_close(BLE_MESH_PROV_GATT);
}
// Should reset the atomic flag after disconneted
bt_mesh_conn_unref(link.conn);
/* Change by Espressif, use offsetof when clear link */
#if defined(CONFIG_BT_MESH_PB_ADV)
#if defined(CONFIG_BLE_MESH_PB_ADV)
memset(&link, 0, offsetof(struct prov_link, tx.retransmit));
link.rx.prev_id = XACT_NVAL;
#if defined(CONFIG_BT_MESH_PB_GATT)
#if defined(CONFIG_BLE_MESH_PB_GATT)
link.rx.buf = bt_mesh_proxy_get_buf();
#else
net_buf_simple_init(rx_buf, 0);
@@ -1693,15 +1671,15 @@ int bt_mesh_pb_gatt_close(struct bt_conn *conn)
#endif
#else
memset(&link, 0, offsetof(struct prov_link, timeout));
#endif /* CONFIG_BT_MESH_PB_ADV */
#endif /* CONFIG_BLE_MESH_PB_ADV */
if (bt_mesh_pub_key_get()) {
atomic_set_bit(link.flags, LOCAL_PUB_KEY);
bt_mesh_atomic_set_bit(link.flags, LOCAL_PUB_KEY);
}
return 0;
}
#endif /* CONFIG_BT_MESH_PB_GATT */
#endif /* CONFIG_BLE_MESH_PB_GATT */
const u8_t *bt_mesh_prov_get_uuid(void)
{
@@ -1710,7 +1688,7 @@ const u8_t *bt_mesh_prov_get_uuid(void)
bool bt_prov_active(void)
{
return atomic_test_bit(link.flags, LINK_ACTIVE);
return bt_mesh_atomic_test_bit(link.flags, LINK_ACTIVE);
}
int bt_mesh_prov_init(const struct bt_mesh_prov *prov_info)
@@ -1718,37 +1696,31 @@ int bt_mesh_prov_init(const struct bt_mesh_prov *prov_info)
const u8_t *key = NULL;
if (!prov_info) {
BT_ERR("No provisioning context provided");
BT_ERR("%s, No provisioning context provided", __func__);
return -EINVAL;
}
/* Change by Espressif. Use micro-ecc to generate public key now. */
key = bt_mesh_pub_key_get();
if (!key) {
BT_ERR("%s: Failed to generate public key", __func__);
BT_ERR("%s, Failed to generate public key", __func__);
return -EIO;
}
prov = prov_info;
#if defined(CONFIG_BT_MESH_PB_ADV)
#if defined(CONFIG_BLE_MESH_PB_ADV)
k_delayed_work_init(&link.tx.retransmit, prov_retransmit);
link.rx.prev_id = XACT_NVAL;
#if defined(CONFIG_BT_MESH_PB_GATT)
#if defined(CONFIG_BLE_MESH_PB_GATT)
link.rx.buf = bt_mesh_proxy_get_buf();
#else
net_buf_simple_init(rx_buf, 0);
link.rx.buf = rx_buf;
#endif
#endif /* CONFIG_BT_MESH_PB_ADV */
if (IS_ENABLED(CONFIG_BT_DEBUG)) {
struct bt_uuid_128 uuid = { .uuid.type = BT_UUID_TYPE_128 };
memcpy(uuid.val, prov->uuid, 16);
BT_INFO("Device UUID: %s", bt_uuid_str(&uuid.uuid));
}
#endif /* CONFIG_BLE_MESH_PB_ADV */
/* Change by Espressif, add provisioning timeout timer init */
k_delayed_work_init(&link.timeout, prov_timeout);
@@ -1770,6 +1742,4 @@ void bt_mesh_prov_reset(void)
}
}
#endif /* CONFIG_BT_MESH_NODE */
#endif /* #if CONFIG_BT_MESH */
#endif /* CONFIG_BLE_MESH_NODE */

View File

@@ -17,17 +17,19 @@ void bt_mesh_pb_adv_recv(struct net_buf_simple *buf);
bool bt_prov_active(void);
int bt_mesh_pb_gatt_open(struct bt_conn *conn);
int bt_mesh_pb_gatt_close(struct bt_conn *conn);
int bt_mesh_pb_gatt_recv(struct bt_conn *conn, struct net_buf_simple *buf);
int bt_mesh_pb_gatt_open(struct bt_mesh_conn *conn);
int bt_mesh_pb_gatt_close(struct bt_mesh_conn *conn);
int bt_mesh_pb_gatt_recv(struct bt_mesh_conn *conn, struct net_buf_simple *buf);
int bt_mesh_set_oob_pub_key(const u8_t pub_key_x[32], const u8_t pub_key_y[32],
const u8_t pri_key[32]);
const u8_t *bt_mesh_prov_get_uuid(void);
int bt_mesh_prov_init(const struct bt_mesh_prov *prov);
void bt_mesh_prov_complete(u16_t net_idx, u16_t addr, u8_t flags, u32_t iv_index);
void bt_mesh_prov_reset(void);
#endif /* #ifndef _PROV_H_ */
#endif /* _PROV_H_ */

View File

@@ -15,15 +15,12 @@
#include <errno.h>
#include <string.h>
#include "mesh_util.h"
#include "mesh_buf.h"
#include "sdkconfig.h"
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_BEACON)
#include "mesh_util.h"
#include "mesh_buf.h"
#include "mesh_main.h"
#if CONFIG_BT_MESH
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_BEACON)
#include "mesh_trace.h"
#include "adv.h"
@@ -33,17 +30,16 @@
#include "crypto.h"
#include "beacon.h"
#include "foundation.h"
#include "provisioner_prov.h"
#define BEACON_TYPE_UNPROVISIONED 0x00
#define BEACON_TYPE_SECURE 0x01
#if CONFIG_BT_MESH_PROVISIONER
#if CONFIG_BLE_MESH_PROVISIONER
static void provisioner_secure_beacon_recv(struct net_buf_simple *buf)
{
// TODO: Provisioner receive and handle Secure Beacon
// TODO: Provisioner receive and handle Secure Network Beacon
}
void provisioner_beacon_recv(struct net_buf_simple *buf)
@@ -53,7 +49,7 @@ void provisioner_beacon_recv(struct net_buf_simple *buf)
BT_DBG("%u bytes: %s", buf->len, bt_hex(buf->data, buf->len));
if (buf->len < 1) {
BT_ERR("Too short beacon");
BT_ERR("%s, Too short beacon", __func__);
return;
}
@@ -67,11 +63,9 @@ void provisioner_beacon_recv(struct net_buf_simple *buf)
provisioner_secure_beacon_recv(buf);
break;
default:
BT_WARN("%s, Unknown beacon type 0x%02x", __func__, type);
BT_DBG("%s, Unknown beacon type 0x%02x", __func__, type);
break;
}
}
#endif /* CONFIG_BT_MESH_PROVISIONER */
#endif /* #if CONFIG_BT_MESH */
#endif /* CONFIG_BLE_MESH_PROVISIONER */

View File

@@ -18,13 +18,12 @@
#include "sdkconfig.h"
#include "osi/allocator.h"
#if CONFIG_BT_MESH
#include "mesh.h"
#include "mesh_util.h"
#include "mesh_main.h"
#include "mesh_trace.h"
#include "mesh_bearer_adapt.h"
#include "mesh.h"
#include "crypto.h"
#include "adv.h"
#include "net.h"
@@ -34,12 +33,12 @@
#include "provisioner_proxy.h"
#include "provisioner_main.h"
#if CONFIG_BT_MESH_PROVISIONER
#if CONFIG_BLE_MESH_PROVISIONER
static const struct bt_mesh_prov *prov;
static const struct bt_mesh_comp *comp;
static struct bt_mesh_node_t *mesh_nodes[CONFIG_BT_MESH_MAX_STORED_NODES];
static struct bt_mesh_node_t *mesh_nodes[CONFIG_BLE_MESH_MAX_STORED_NODES];
static u32_t mesh_node_count;
static bool prov_upper_init = false;
@@ -51,18 +50,18 @@ static int provisioner_index_check(int node_index)
BT_DBG("%s", __func__);
if (node_index < 0) {
BT_ERR("%s: Invalid node index %d", __func__, node_index);
BT_ERR("%s, Invalid node index %d", __func__, node_index);
return -EINVAL;
}
if (node_index >= ARRAY_SIZE(mesh_nodes)) {
BT_ERR("%s: Too big node index", __func__);
BT_ERR("%s, Too big node index", __func__);
return -EINVAL;
}
node = mesh_nodes[node_index];
if (!node) {
BT_ERR("%s: Node is not found", __func__);
BT_ERR("%s, Node is not found", __func__);
return -EINVAL;
}
@@ -120,15 +119,15 @@ int provisioner_node_reset(int node_index)
struct bt_mesh_rpl *rpl = NULL;
int i;
BT_DBG("%s: reset node %d", __func__, node_index);
BT_DBG("%s, reset node %d", __func__, node_index);
if (!mesh_node_count) {
BT_ERR("%s: Node queue is empty", __func__);
BT_ERR("%s, Node queue is empty", __func__);
return -ENODEV;
}
if (provisioner_index_check(node_index)) {
BT_ERR("%s: Failed to check node index", __func__);
BT_ERR("%s, Failed to check node index", __func__);
return -EINVAL;
}
@@ -185,13 +184,13 @@ int provisioner_upper_init(void)
comp = bt_mesh_comp_get();
if (!comp) {
BT_ERR("%s: NULL composition data", __func__);
BT_ERR("%s, NULL composition data", __func__);
return -EINVAL;
}
prov = provisioner_get_prov_info();
if (!prov) {
BT_ERR("%s: NULL provisioning context", __func__);
BT_ERR("%s, NULL provisioning context", __func__);
return -EINVAL;
}
@@ -201,35 +200,35 @@ int provisioner_upper_init(void)
/* Generate the primary netkey */
if (bt_mesh_rand(p_key, 16)) {
BT_ERR("%s: Failed to generate Primary NetKey", __func__);
BT_ERR("%s, Failed to generate Primary NetKey", __func__);
return -EIO;
}
sub = osi_calloc(sizeof(struct bt_mesh_subnet));
if (!sub) {
BT_ERR("%s: Failed to allocate memory", __func__);
BT_ERR("%s, Failed to allocate memory", __func__);
return -ENOMEM;
}
sub->kr_flag = BT_MESH_KEY_REFRESH(prov->flags);
sub->kr_flag = BLE_MESH_KEY_REFRESH(prov->flags);
if (sub->kr_flag) {
if (bt_mesh_net_keys_create(&sub->keys[1], p_key)) {
BT_ERR("%s: Failed to generate net-related keys", __func__);
BT_ERR("%s, Failed to generate net-related keys", __func__);
osi_free(sub);
return -EIO;
}
sub->kr_phase = BT_MESH_KR_PHASE_2;
sub->kr_phase = BLE_MESH_KR_PHASE_2;
} else {
/* Currently provisioner only use keys[0] */
if (bt_mesh_net_keys_create(&sub->keys[0], p_key)) {
BT_ERR("%s: Failed to create net-related keys", __func__);
BT_ERR("%s, Failed to create net-related keys", __func__);
osi_free(sub);
return -EIO;
}
sub->kr_phase = BT_MESH_KR_NORMAL;
sub->kr_phase = BLE_MESH_KR_NORMAL;
}
sub->net_idx = BT_MESH_KEY_PRIMARY;
sub->node_id = BT_MESH_NODE_IDENTITY_NOT_SUPPORTED;
sub->net_idx = BLE_MESH_KEY_PRIMARY;
sub->node_id = BLE_MESH_NODE_IDENTITY_NOT_SUPPORTED;
bt_mesh.p_sub[0] = sub;
@@ -240,7 +239,7 @@ int provisioner_upper_init(void)
/* In this function, we use the values of struct bt_mesh_prov
which has been initialized in the application layer */
bt_mesh.iv_index = prov->iv_index;
bt_mesh.iv_update = BT_MESH_IV_UPDATE(prov->flags);
bt_mesh.iv_update = BLE_MESH_IV_UPDATE(prov->flags);
/* Set initial IV Update procedure state time-stamp */
bt_mesh.last_update = k_uptime_get();
@@ -289,7 +288,7 @@ struct bt_mesh_subnet *provisioner_subnet_get(u16_t net_idx)
BT_DBG("%s", __func__);
if (net_idx == BT_MESH_KEY_ANY) {
if (net_idx == BLE_MESH_KEY_ANY) {
return bt_mesh.p_sub[0];
}
@@ -311,7 +310,7 @@ bool provisioner_check_msg_dst_addr(u16_t dst_addr)
BT_DBG("%s", __func__);
if (!BT_MESH_ADDR_IS_UNICAST(dst_addr)) {
if (!BLE_MESH_ADDR_IS_UNICAST(dst_addr)) {
return true;
}
@@ -337,8 +336,8 @@ const u8_t *provisioner_get_device_key(u16_t dst_addr)
BT_DBG("%s", __func__);
if (!BT_MESH_ADDR_IS_UNICAST(dst_addr)) {
BT_ERR("%s: Not a unicast address 0x%04x", __func__, dst_addr);
if (!BLE_MESH_ADDR_IS_UNICAST(dst_addr)) {
BT_ERR("%s, Not a unicast address 0x%04x", __func__, dst_addr);
return NULL;
}
@@ -364,7 +363,7 @@ struct bt_mesh_app_key *provisioner_app_key_find(u16_t app_idx)
if (!key) {
continue;
}
if (key->net_idx != BT_MESH_KEY_UNUSED &&
if (key->net_idx != BLE_MESH_KEY_UNUSED &&
key->app_idx == app_idx) {
return key;
}
@@ -423,7 +422,7 @@ int bt_mesh_provisioner_store_node_info(struct bt_mesh_node_t *node_info)
int i;
if (!node_info) {
BT_ERR("%s: Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return -EINVAL;
}
@@ -431,18 +430,18 @@ int bt_mesh_provisioner_store_node_info(struct bt_mesh_node_t *node_info)
for (i = 0; i < ARRAY_SIZE(mesh_nodes); i++) {
node = mesh_nodes[i];
if (node && !memcmp(node->dev_uuid, node_info->dev_uuid, 16)) {
BT_WARN("%s: Node info already exists", __func__);
BT_WARN("%s, Node info already exists", __func__);
return -EEXIST;
}
}
/* 0 ~ (CONFIG_BT_MESH_MAX_PROV_NODES-1) are left for self-provisioned nodes */
for (i = CONFIG_BT_MESH_MAX_PROV_NODES; i < ARRAY_SIZE(mesh_nodes); i++) {
/* 0 ~ (CONFIG_BLE_MESH_MAX_PROV_NODES-1) are left for self-provisioned nodes */
for (i = CONFIG_BLE_MESH_MAX_PROV_NODES; i < ARRAY_SIZE(mesh_nodes); i++) {
node = mesh_nodes[i];
if (!node) {
node = osi_calloc(sizeof(struct bt_mesh_node_t));
if (!node) {
BT_ERR("%s: Failed to allocate memory", __func__);
BT_ERR("%s, Failed to allocate memory", __func__);
return -ENOMEM;
}
memcpy(node, node_info, sizeof(struct bt_mesh_node_t));
@@ -452,7 +451,7 @@ int bt_mesh_provisioner_store_node_info(struct bt_mesh_node_t *node_info)
}
}
BT_ERR("%s: Node info is full", __func__);
BT_ERR("%s, Node info is full", __func__);
return -ENOMEM;
}
@@ -462,13 +461,13 @@ int bt_mesh_provisioner_get_all_node_unicast_addr(struct net_buf_simple *buf)
int i;
if (!buf) {
BT_ERR("%s: Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return -EINVAL;
}
for (i = 0; i < ARRAY_SIZE(mesh_nodes); i++) {
node = mesh_nodes[i];
if (!node || !BT_MESH_ADDR_IS_UNICAST(node->unicast_addr)) {
if (!node || !BLE_MESH_ADDR_IS_UNICAST(node->unicast_addr)) {
continue;
}
net_buf_simple_add_le16(buf, node->unicast_addr);
@@ -485,12 +484,12 @@ int bt_mesh_provisioner_set_node_name(int node_index, const char *name)
BT_DBG("%s", __func__);
if (!name) {
BT_ERR("%s: Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return -EINVAL;
}
if (provisioner_index_check(node_index)) {
BT_ERR("%s: Failed to check node index", __func__);
BT_ERR("%s, Failed to check node index", __func__);
return -EINVAL;
}
@@ -506,7 +505,7 @@ int bt_mesh_provisioner_set_node_name(int node_index, const char *name)
continue;
}
if (!strncmp(mesh_nodes[i]->node_name, name, length)) {
BT_WARN("%s: Name %s already exists", __func__, name);
BT_WARN("%s, Name %s already exists", __func__, name);
return -EEXIST;
}
}
@@ -521,7 +520,7 @@ const char *bt_mesh_provisioner_get_node_name(int node_index)
BT_DBG("%s", __func__);
if (provisioner_index_check(node_index)) {
BT_ERR("%s: Failed to check node index", __func__);
BT_ERR("%s, Failed to check node index", __func__);
return NULL;
}
@@ -563,8 +562,8 @@ struct bt_mesh_node_t *bt_mesh_provisioner_get_node_info(u16_t unicast_addr)
BT_DBG("%s", __func__);
if (!BT_MESH_ADDR_IS_UNICAST(unicast_addr)) {
BT_ERR("%s: Not a unicast address 0x%04x", __func__, unicast_addr);
if (!BLE_MESH_ADDR_IS_UNICAST(unicast_addr)) {
BT_ERR("%s, Not a unicast address 0x%04x", __func__, unicast_addr);
return NULL;
}
@@ -724,42 +723,42 @@ int bt_mesh_provisioner_local_app_key_add(const u8_t app_key[16], u16_t net_idx,
int add = -1;
if (bt_mesh.p_app_idx_next >= 0x1000) {
BT_ERR("%s: No AppKey Index available", __func__);
BT_ERR("%s, No AppKey Index available", __func__);
return -EIO;
}
if (!app_idx || (*app_idx != 0xFFFF && *app_idx >= 0x1000)) {
BT_ERR("%s: Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return -EINVAL;
}
/* Check if the same application key already exists */
if (provisioner_check_app_key(app_key, app_idx)) {
BT_WARN("%s: AppKey already exists, AppKey Index updated", __func__);
BT_WARN("%s, AppKey already exists, AppKey Index updated", __func__);
return 0;
}
/* Check if the net_idx exists */
if (provisioner_check_net_idx(net_idx, false)) {
BT_ERR("%s: NetKey Index does not exist", __func__);
BT_ERR("%s, NetKey Index does not exist", __func__);
return -ENODEV;
}
/* Check if the same app_idx already exists */
if (provisioner_check_app_idx(*app_idx, true)) {
BT_ERR("%s: AppKey Index already exists", __func__);
BT_ERR("%s, AppKey Index already exists", __func__);
return -EEXIST;
}
add = provisioner_check_app_key_full();
if (add < 0) {
BT_ERR("%s: AppKey queue is full", __func__);
BT_ERR("%s, AppKey queue is full", __func__);
return -ENOMEM;
}
if (!app_key) {
if (bt_mesh_rand(p_key, 16)) {
BT_ERR("%s: Failed to generate AppKey", __func__);
BT_ERR("%s, Failed to generate AppKey", __func__);
return -EIO;
}
} else {
@@ -768,13 +767,13 @@ int bt_mesh_provisioner_local_app_key_add(const u8_t app_key[16], u16_t net_idx,
key = osi_calloc(sizeof(struct bt_mesh_app_key));
if (!key) {
BT_ERR("%s: Failed to allocate memory", __func__);
BT_ERR("%s, Failed to allocate memory", __func__);
return -ENOMEM;
}
keys = &key->keys[0];
if (bt_mesh_app_id(p_key, &keys->id)) {
BT_ERR("%s: Failed to generate AID", __func__);
BT_ERR("%s, Failed to generate AID", __func__);
osi_free(key);
return -EIO;
}
@@ -789,7 +788,7 @@ int bt_mesh_provisioner_local_app_key_add(const u8_t app_key[16], u16_t net_idx,
if (provisioner_check_app_idx(key->app_idx, true)) {
key->app_idx = (++bt_mesh.p_app_idx_next);
if (key->app_idx >= 0x1000) {
BT_ERR("%s: No AppKey Index available", __func__);
BT_ERR("%s, No AppKey Index available", __func__);
osi_free(key);
return -EIO;
}
@@ -814,12 +813,12 @@ const u8_t *bt_mesh_provisioner_local_app_key_get(u16_t net_idx, u16_t app_idx)
BT_DBG("%s", __func__);
if (provisioner_check_net_idx(net_idx, false)) {
BT_ERR("%s: NetKey Index does not exist", __func__);
BT_ERR("%s, NetKey Index does not exist", __func__);
return NULL;
}
if (provisioner_check_app_idx(app_idx, false)) {
BT_ERR("%s: AppKey Index does not exist", __func__);
BT_ERR("%s, AppKey Index does not exist", __func__);
return NULL;
}
@@ -845,12 +844,12 @@ int bt_mesh_provisioner_local_app_key_delete(u16_t net_idx, u16_t app_idx)
BT_DBG("%s", __func__);
if (provisioner_check_net_idx(net_idx, false)) {
BT_ERR("%s: NetKey Index does not exist", __func__);
BT_ERR("%s, NetKey Index does not exist", __func__);
return -ENODEV;
}
if (provisioner_check_app_idx(app_idx, false)) {
BT_ERR("%s: AppKey Index does not exist", __func__);
BT_ERR("%s, AppKey Index does not exist", __func__);
return -ENODEV;
}
@@ -875,36 +874,36 @@ int bt_mesh_provisioner_local_net_key_add(const u8_t net_key[16], u16_t *net_idx
int add = -1;
if (bt_mesh.p_net_idx_next >= 0x1000) {
BT_ERR("%s: No NetKey Index available", __func__);
BT_ERR("%s, No NetKey Index available", __func__);
return -EIO;
}
if (!net_idx || (*net_idx != 0xFFFF && *net_idx >= 0x1000)) {
BT_ERR("%s: Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return -EINVAL;
}
/* Check if the same network key already exists */
if (provisioner_check_net_key(net_key, net_idx)) {
BT_WARN("%s: NetKey already exists, NetKey Index updated", __func__);
BT_WARN("%s, NetKey already exists, NetKey Index updated", __func__);
return 0;
}
/* Check if the same net_idx already exists */
if (provisioner_check_net_idx(*net_idx, true)) {
BT_ERR("%s: NetKey Index already exists", __func__);
BT_ERR("%s, NetKey Index already exists", __func__);
return -EEXIST;
}
add = provisioner_check_net_key_full();
if (add < 0) {
BT_ERR("%s: NetKey queue is full", __func__);
BT_ERR("%s, NetKey queue is full", __func__);
return -ENOMEM;
}
if (!net_key) {
if (bt_mesh_rand(p_key, 16)) {
BT_ERR("%s: Failed to generate NetKey", __func__);
BT_ERR("%s, Failed to generate NetKey", __func__);
return -EIO;
}
} else {
@@ -913,12 +912,12 @@ int bt_mesh_provisioner_local_net_key_add(const u8_t net_key[16], u16_t *net_idx
sub = osi_calloc(sizeof(struct bt_mesh_subnet));
if (!sub) {
BT_ERR("%s: Failed to allocate memory", __func__);
BT_ERR("%s, Failed to allocate memory", __func__);
return -ENOMEM;
}
if (bt_mesh_net_keys_create(&sub->keys[0], p_key)) {
BT_ERR("%s: Failed to generate NID", __func__);
BT_ERR("%s, Failed to generate NID", __func__);
osi_free(sub);
return -EIO;
}
@@ -931,7 +930,7 @@ int bt_mesh_provisioner_local_net_key_add(const u8_t net_key[16], u16_t *net_idx
if (provisioner_check_net_idx(sub->net_idx, true)) {
sub->net_idx = (++bt_mesh.p_net_idx_next);
if (sub->net_idx >= 0x1000) {
BT_ERR("%s: No NetKey Index available", __func__);
BT_ERR("%s, No NetKey Index available", __func__);
osi_free(sub);
return -EIO;
}
@@ -941,9 +940,9 @@ int bt_mesh_provisioner_local_net_key_add(const u8_t net_key[16], u16_t *net_idx
}
*net_idx = sub->net_idx;
}
sub->kr_phase = BT_MESH_KR_NORMAL;
sub->kr_phase = BLE_MESH_KR_NORMAL;
sub->kr_flag = false;
sub->node_id = BT_MESH_NODE_IDENTITY_NOT_SUPPORTED;
sub->node_id = BLE_MESH_NODE_IDENTITY_NOT_SUPPORTED;
bt_mesh.p_sub[add] = sub;
@@ -958,7 +957,7 @@ const u8_t *bt_mesh_provisioner_local_net_key_get(u16_t net_idx)
BT_DBG("%s", __func__);
if (provisioner_check_net_idx(net_idx, false)) {
BT_ERR("%s: NetKey Index does not exist", __func__);
BT_ERR("%s, NetKey Index does not exist", __func__);
return NULL;
}
@@ -983,7 +982,7 @@ int bt_mesh_provisioner_local_net_key_delete(u16_t net_idx)
BT_DBG("%s", __func__);
if (provisioner_check_net_idx(net_idx, false)) {
BT_ERR("%s: NetKey Index does not exist", __func__);
BT_ERR("%s, NetKey Index does not exist", __func__);
return -ENODEV;
}
@@ -1003,7 +1002,7 @@ int bt_mesh_provisioner_local_net_key_delete(u16_t net_idx)
int bt_mesh_provisioner_get_own_unicast_addr(u16_t *addr, u8_t *elem_num)
{
if (!addr || !elem_num || !prov || !comp) {
BT_ERR("%s: Invalid parameter", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return -EINVAL;
}
@@ -1021,7 +1020,7 @@ int bt_mesh_provisioner_bind_local_model_app_idx(u16_t elem_addr, u16_t mod_id,
int i;
if (!comp) {
BT_ERR("%s: NULL composition data", __func__);
BT_ERR("%s, NULL composition data", __func__);
return -EINVAL;
}
@@ -1032,7 +1031,7 @@ int bt_mesh_provisioner_bind_local_model_app_idx(u16_t elem_addr, u16_t mod_id,
}
}
if (i == comp->elem_count) {
BT_ERR("%s: No element is found", __func__);
BT_ERR("%s, No element is found", __func__);
return -ENODEV;
}
@@ -1042,30 +1041,30 @@ int bt_mesh_provisioner_bind_local_model_app_idx(u16_t elem_addr, u16_t mod_id,
model = bt_mesh_model_find_vnd(elem, cid, mod_id);
}
if (!model) {
BT_ERR("%s: No model is found", __func__);
BT_ERR("%s, No model is found", __func__);
return -ENODEV;
}
if (provisioner_check_app_idx(app_idx, false)) {
BT_ERR("%s: AppKey Index does not exist", __func__);
BT_ERR("%s, AppKey Index does not exist", __func__);
return -ENODEV;
}
for (i = 0; i < ARRAY_SIZE(model->keys); i++) {
if (model->keys[i] == app_idx) {
BT_WARN("%s: AppKey Index is already binded with model", __func__);
BT_WARN("%s, AppKey Index is already binded with model", __func__);
return 0;
}
}
for (i = 0; i < ARRAY_SIZE(model->keys); i++) {
if (model->keys[i] == BT_MESH_KEY_UNUSED) {
if (model->keys[i] == BLE_MESH_KEY_UNUSED) {
model->keys[i] = app_idx;
return 0;
}
}
BT_ERR("%s: Model AppKey queue is full", __func__);
BT_ERR("%s, Model AppKey queue is full", __func__);
return -ENOMEM;
}
@@ -1077,12 +1076,12 @@ int bt_mesh_provisioner_bind_local_app_net_idx(u16_t net_idx, u16_t app_idx)
BT_DBG("%s", __func__);
if (provisioner_check_net_idx(net_idx, false)) {
BT_ERR("%s: NetKey Index does not exist", __func__);
BT_ERR("%s, NetKey Index does not exist", __func__);
return -ENODEV;
}
if (provisioner_check_app_idx(app_idx, false)) {
BT_ERR("%s: AppKey Index does not exist", __func__);
BT_ERR("%s, AppKey Index does not exist", __func__);
return -ENODEV;
}
@@ -1105,7 +1104,7 @@ int bt_mesh_provisioner_print_local_element_info(void)
int i, j;
if (!comp) {
BT_ERR("%s: NULL composition data", __func__);
BT_ERR("%s, NULL composition data", __func__);
return -EINVAL;
}
@@ -1130,11 +1129,11 @@ int bt_mesh_provisioner_print_local_element_info(void)
return 0;
}
#endif /* CONFIG_BT_MESH_PROVISIONER */
#endif /* CONFIG_BLE_MESH_PROVISIONER */
/* The following APIs are for fast provisioning */
#if CONFIG_BT_MESH_FAST_PROV
#if CONFIG_BLE_MESH_FAST_PROV
const u8_t *get_fast_prov_device_key(u16_t addr)
{
@@ -1142,8 +1141,8 @@ const u8_t *get_fast_prov_device_key(u16_t addr)
BT_DBG("%s", __func__);
if (!BT_MESH_ADDR_IS_UNICAST(addr)) {
BT_ERR("%s: Not a unicast address 0x%04x", __func__, addr);
if (!BLE_MESH_ADDR_IS_UNICAST(addr)) {
BT_ERR("%s, Not a unicast address 0x%04x", __func__, addr);
return NULL;
}
@@ -1214,7 +1213,7 @@ u8_t bt_mesh_set_fast_prov_net_idx(u16_t net_idx)
sub = get_fast_prov_subnet(net_idx);
if (sub) {
key = BT_MESH_KEY_REFRESH(sub->kr_flag) ? &sub->keys[1] : &sub->keys[0];
key = BLE_MESH_KEY_REFRESH(sub->kr_flag) ? &sub->keys[1] : &sub->keys[0];
return provisioner_set_fast_prov_net_idx(key->net, net_idx);
}
@@ -1251,7 +1250,7 @@ const u8_t *bt_mesh_get_fast_prov_net_key(u16_t net_idx)
sub = get_fast_prov_subnet(net_idx);
if (!sub) {
BT_ERR("%s: Failed to get subnet", __func__);
BT_ERR("%s, Failed to get subnet", __func__);
return NULL;
}
@@ -1264,13 +1263,11 @@ const u8_t *bt_mesh_get_fast_prov_app_key(u16_t net_idx, u16_t app_idx)
key = get_fast_prov_app_key(net_idx, app_idx);
if (!key) {
BT_ERR("%s: Failed to get AppKey", __func__);
BT_ERR("%s, Failed to get AppKey", __func__);
return NULL;
}
return (key->updated ? key->keys[1].val : key->keys[0].val);
}
#endif /* CONFIG_BT_MESH_FAST_PROV */
#endif /* CONFIG_BT_MESH */
#endif /* CONFIG_BLE_MESH_FAST_PROV */

View File

@@ -22,7 +22,7 @@
#define MESH_NAME_SIZE 31
#if CONFIG_BT_MESH_PROVISIONER
#if CONFIG_BLE_MESH_PROVISIONER
/* Each node information stored by provisioner */
struct bt_mesh_node_t {
@@ -105,11 +105,11 @@ int bt_mesh_provisioner_bind_local_app_net_idx(u16_t net_idx, u16_t app_idx);
/* Provisioner print own element information */
int bt_mesh_provisioner_print_local_element_info(void);
#endif /* CONFIG_BT_MESH_PROVISIONER */
#endif /* CONFIG_BLE_MESH_PROVISIONER */
/* The following APIs are for fast provisioning */
#if CONFIG_BT_MESH_FAST_PROV
#if CONFIG_BLE_MESH_FAST_PROV
const u8_t *get_fast_prov_device_key(u16_t dst_addr);
@@ -125,6 +125,6 @@ const u8_t *bt_mesh_get_fast_prov_net_key(u16_t net_idx);
const u8_t *bt_mesh_get_fast_prov_app_key(u16_t net_idx, u16_t app_idx);
#endif /* CONFIG_BT_MESH_FAST_PROV */
#endif /* CONFIG_BLE_MESH_FAST_PROV */
#endif /* _PROVISIONER_MAIN_H_ */

File diff suppressed because it is too large Load Diff

View File

@@ -18,24 +18,20 @@
#include "mesh_bearer_adapt.h"
#include "mesh_main.h"
#if !CONFIG_BT_MESH_PROVISIONER
#if !CONFIG_BLE_MESH_PROVISIONER
#define CONFIG_BT_MESH_PBA_SAME_TIME 0
#define CONFIG_BT_MESH_PBG_SAME_TIME 0
#define CONFIG_BLE_MESH_PBA_SAME_TIME 0
#define CONFIG_BLE_MESH_PBG_SAME_TIME 0
#else
#if !defined(CONFIG_BT_MESH_PB_ADV)
#define CONFIG_BT_MESH_PBA_SAME_TIME 0
#endif /* !CONFIG_BT_MESH_PB_ADV */
#if !defined(CONFIG_BLE_MESH_PB_ADV)
#define CONFIG_BLE_MESH_PBA_SAME_TIME 0
#endif /* !CONFIG_BLE_MESH_PB_ADV */
#if !defined(CONFIG_BT_MESH_PB_GATT)
#define CONFIG_BT_MESH_PBG_SAME_TIME 0
#endif /* !CONFIG_BT_MESH_PB_GATT */
#define BT_DATA_FLAGS 0x01
#define BT_DATA_SERVICE_UUID 0x03
#define BT_DATA_SERVICE_DATA 0X16
#if !defined(CONFIG_BLE_MESH_PB_GATT)
#define CONFIG_BLE_MESH_PBG_SAME_TIME 0
#endif /* !CONFIG_BLE_MESH_PB_GATT */
#define RM_AFTER_PROV BIT(0)
#define START_PROV_NOW BIT(1)
@@ -111,7 +107,7 @@ void provisioner_pb_adv_recv(struct net_buf_simple *buf);
*
* @return Zero - success, otherwise - fail
*/
int provisioner_set_prov_conn(const u8_t addr[6], struct bt_conn *conn);
int provisioner_set_prov_conn(const u8_t addr[6], struct bt_mesh_conn *conn);
/**
* @brief This function sends provisioning invite to start
@@ -122,7 +118,7 @@ int provisioner_set_prov_conn(const u8_t addr[6], struct bt_conn *conn);
*
* @return Zero - success, otherwise - fail
*/
int provisioner_pb_gatt_open(struct bt_conn *conn, u8_t *addr);
int provisioner_pb_gatt_open(struct bt_mesh_conn *conn, u8_t *addr);
/**
* @brief This function resets the used information when
@@ -133,7 +129,7 @@ int provisioner_pb_gatt_open(struct bt_conn *conn, u8_t *addr);
*
* @return Zero - success, otherwise - fail
*/
int provisioner_pb_gatt_close(struct bt_conn *conn, u8_t reason);
int provisioner_pb_gatt_close(struct bt_mesh_conn *conn, u8_t reason);
/**
* @brief This function handles the received PB-GATT provision
@@ -144,7 +140,7 @@ int provisioner_pb_gatt_close(struct bt_conn *conn, u8_t reason);
*
* @return Zero - success, otherwise - fail
*/
int provisioner_pb_gatt_recv(struct bt_conn *conn, struct net_buf_simple *buf);
int provisioner_pb_gatt_recv(struct bt_mesh_conn *conn, struct net_buf_simple *buf);
/**
* @brief This function initializes provisioner's PB-GATT and PB-ADV
@@ -197,7 +193,7 @@ u16_t provisioner_srv_uuid_recv(struct net_buf_simple *buf);
*
* @return None
*/
void provisioner_srv_data_recv(struct net_buf_simple *buf, const bt_addr_le_t *addr, u16_t uuid);
void provisioner_srv_data_recv(struct net_buf_simple *buf, const bt_mesh_addr_t *addr, u16_t uuid);
/**
* @brief This function gets the bt_mesh_prov pointer.
@@ -376,6 +372,6 @@ u8_t bt_mesh_set_fast_prov_unicast_addr_range(u16_t min, u16_t max);
*/
void bt_mesh_set_fast_prov_flags_iv_index(u8_t flags, u32_t iv_index);
#endif /* CONFIG_BT_MESH_PROVISIONER */
#endif /* CONFIG_BLE_MESH_PROVISIONER */
#endif /* #ifndef _PROVISIONER_PROV_H_ */
#endif /* _PROVISIONER_PROV_H_ */

View File

@@ -17,7 +17,6 @@
#include "sdkconfig.h"
#if CONFIG_BT_MESH
#include "mesh_bearer_adapt.h"
#include "mesh_trace.h"
@@ -28,41 +27,41 @@
#include "provisioner_proxy.h"
#include "provisioner_beacon.h"
#if CONFIG_BT_MESH_PROVISIONER
#if CONFIG_BLE_MESH_PROVISIONER
#define PDU_TYPE(data) (data[0] & BIT_MASK(6))
#define PDU_SAR(data) (data[0] >> 6)
#define PDU_TYPE(data) (data[0] & BIT_MASK(6))
#define PDU_SAR(data) (data[0] >> 6)
#define SAR_COMPLETE 0x00
#define SAR_FIRST 0x01
#define SAR_CONT 0x02
#define SAR_LAST 0x03
#define SAR_COMPLETE 0x00
#define SAR_FIRST 0x01
#define SAR_CONT 0x02
#define SAR_LAST 0x03
#define CFG_FILTER_SET 0x00
#define CFG_FILTER_ADD 0x01
#define CFG_FILTER_REMOVE 0x02
#define CFG_FILTER_STATUS 0x03
#define CFG_FILTER_SET 0x00
#define CFG_FILTER_ADD 0x01
#define CFG_FILTER_REMOVE 0x02
#define CFG_FILTER_STATUS 0x03
#define PDU_HDR(sar, type) (sar << 6 | (type & BIT_MASK(6)))
#define PDU_HDR(sar, type) (sar << 6 | (type & BIT_MASK(6)))
#define SERVER_BUF_SIZE 68
#define SERVER_BUF_SIZE 68
#define ID_TYPE_NET 0x00
#define ID_TYPE_NODE 0x01
#define ID_TYPE_NET 0x00
#define ID_TYPE_NODE 0x01
#define NODE_ID_LEN 19
#define NET_ID_LEN 11
#define NODE_ID_LEN 19
#define NET_ID_LEN 11
#define CLOSE_REASON_PROXY 0xFF
#define CLOSE_REASON_PROXY 0xFF
#define CONFIG_BT_MAX_CONN CONFIG_BT_ACL_CONNECTIONS
#define CONFIG_BT_MAX_CONN CONFIG_BT_ACL_CONNECTIONS
static int conn_count;
static struct bt_mesh_proxy_server {
struct bt_conn *conn;
struct bt_mesh_conn *conn;
/* Provisioner can use filter to double check the dst within mesh messages */
u16_t filter[CONFIG_BT_MESH_PROXY_FILTER_SIZE];
u16_t filter[CONFIG_BLE_MESH_PROXY_FILTER_SIZE];
enum __packed {
NONE,
WHITELIST,
@@ -74,7 +73,7 @@ static struct bt_mesh_proxy_server {
u8_t server_buf_data[SERVER_BUF_SIZE];
} servers[CONFIG_BT_MAX_CONN];
static struct bt_mesh_proxy_server *find_server(struct bt_conn *conn)
static struct bt_mesh_proxy_server *find_server(struct bt_mesh_conn *conn)
{
int i;
@@ -127,15 +126,15 @@ static void proxy_cfg(struct bt_mesh_proxy_server *server)
/** In order to deal with proxy configuration messages, provisioner should
* do sth. like create mesh network after each device is provisioned.
*/
err = bt_mesh_net_decode(&server->buf, BT_MESH_NET_IF_PROXY_CFG,
err = bt_mesh_net_decode(&server->buf, BLE_MESH_NET_IF_PROXY_CFG,
&rx, buf);
if (err) {
BT_ERR("Failed to decode Proxy Configuration (err %d)", err);
BT_ERR("%s, Failed to decode Proxy Configuration (err %d)", __func__, err);
return;
}
/* Remove network headers */
net_buf_simple_pull(buf, BT_MESH_NET_HDR_LEN);
net_buf_simple_pull(buf, BLE_MESH_NET_HDR_LEN);
BT_DBG("%u bytes: %s", buf->len, bt_hex(buf->data, buf->len));
@@ -158,22 +157,22 @@ static void proxy_cfg(struct bt_mesh_proxy_server *server)
static void proxy_complete_pdu(struct bt_mesh_proxy_server *server)
{
switch (server->msg_type) {
#if defined(CONFIG_BT_MESH_GATT_PROXY)
case BT_MESH_PROXY_NET_PDU:
#if defined(CONFIG_BLE_MESH_GATT_PROXY)
case BLE_MESH_PROXY_NET_PDU:
BT_DBG("Mesh Network PDU");
bt_mesh_net_recv(&server->buf, 0, BT_MESH_NET_IF_PROXY);
bt_mesh_net_recv(&server->buf, 0, BLE_MESH_NET_IF_PROXY);
break;
case BT_MESH_PROXY_BEACON:
case BLE_MESH_PROXY_BEACON:
BT_DBG("Mesh Beacon PDU");
provisioner_beacon_recv(&server->buf);
break;
case BT_MESH_PROXY_CONFIG:
case BLE_MESH_PROXY_CONFIG:
BT_DBG("Mesh Configuration PDU");
proxy_cfg(server);
break;
#endif
#if defined(CONFIG_BT_MESH_PB_GATT)
case BT_MESH_PROXY_PROV:
#if defined(CONFIG_BLE_MESH_PB_GATT)
case BLE_MESH_PROXY_PROV:
BT_DBG("Mesh Provisioning PDU");
provisioner_pb_gatt_recv(server->conn, &server->buf);
break;
@@ -186,10 +185,10 @@ static void proxy_complete_pdu(struct bt_mesh_proxy_server *server)
net_buf_simple_init(&server->buf, 0);
}
#define ATTR_IS_PROV(uuid) (uuid == BT_UUID_MESH_PROV_VAL)
#define ATTR_IS_PROV(uuid) (uuid == BLE_MESH_UUID_MESH_PROV_VAL)
static ssize_t proxy_recv(struct bt_conn *conn,
const struct bt_gatt_attr *attr, const void *buf,
static ssize_t proxy_recv(struct bt_mesh_conn *conn,
const struct bt_mesh_gatt_attr *attr, const void *buf,
u16_t len, u16_t offset, u8_t flags)
{
struct bt_mesh_proxy_server *server = find_server(conn);
@@ -207,11 +206,11 @@ static ssize_t proxy_recv(struct bt_conn *conn,
srvc_uuid = bt_mesh_gattc_get_service_uuid(conn);
if (!srvc_uuid) {
BT_ERR("No service uuid found");
BT_ERR("%s, No service uuid found", __func__);
return -ENOTCONN;
}
if (ATTR_IS_PROV(srvc_uuid) != (PDU_TYPE(data) == BT_MESH_PROXY_PROV)) {
if (ATTR_IS_PROV(srvc_uuid) != (PDU_TYPE(data) == BLE_MESH_PROXY_PROV)) {
BT_WARN("Proxy PDU type doesn't match GATT service uuid");
return -EINVAL;
}
@@ -276,7 +275,7 @@ static ssize_t proxy_recv(struct bt_conn *conn,
return len;
}
static void proxy_prov_connected(const u8_t addr[6], struct bt_conn *conn, int id)
static void proxy_prov_connected(const u8_t addr[6], struct bt_mesh_conn *conn, int id)
{
struct bt_mesh_proxy_server *server = NULL;
@@ -287,7 +286,7 @@ static void proxy_prov_connected(const u8_t addr[6], struct bt_conn *conn, int i
}
if (!server) {
BT_ERR("No matching Proxy Client objects");
BT_ERR("%s, No matching Proxy Client objects", __func__);
/** Disconnect current connection, clear part of prov_link
* information, like uuid, dev_addr, linking flag, etc.
*/
@@ -300,9 +299,9 @@ static void proxy_prov_connected(const u8_t addr[6], struct bt_conn *conn, int i
memset(server->filter, 0, sizeof(server->filter));
net_buf_simple_init(&server->buf, 0);
#if defined(CONFIG_BT_MESH_PB_GATT)
#if defined(CONFIG_BLE_MESH_PB_GATT)
if (provisioner_set_prov_conn(addr, server->conn)) {
BT_ERR("%s: Fail to set prov_conn", __func__);
BT_ERR("%s, provisioner_set_prov_conn failed", __func__);
bt_mesh_gattc_disconnect(server->conn);
return;
}
@@ -311,7 +310,7 @@ static void proxy_prov_connected(const u8_t addr[6], struct bt_conn *conn, int i
bt_mesh_gattc_exchange_mtu(id);
}
static void proxy_prov_disconnected(struct bt_conn *conn, u8_t reason)
static void proxy_prov_disconnected(struct bt_mesh_conn *conn, u8_t reason)
{
struct bt_mesh_proxy_server *server = NULL;
int i;
@@ -325,7 +324,7 @@ static void proxy_prov_disconnected(struct bt_conn *conn, u8_t reason)
for (i = 0; i < ARRAY_SIZE(servers); i++) {
server = &servers[i];
if (server->conn == conn) {
if (IS_ENABLED(CONFIG_BT_MESH_PB_GATT) &&
if (IS_ENABLED(CONFIG_BLE_MESH_PB_GATT) &&
server->filter_type == PROV) {
provisioner_pb_gatt_close(conn, reason);
}
@@ -335,15 +334,15 @@ static void proxy_prov_disconnected(struct bt_conn *conn, u8_t reason)
}
}
#if defined(CONFIG_BT_MESH_PB_GATT)
static ssize_t prov_write_ccc_descr(struct bt_conn *conn, u8_t *addr)
#if defined(CONFIG_BLE_MESH_PB_GATT)
static ssize_t prov_write_ccc_descr(struct bt_mesh_conn *conn, u8_t *addr)
{
struct bt_mesh_proxy_server *server;
server = find_server(conn);
if (!server) {
BT_ERR("No Proxy Server found");
BT_ERR("%s, No Proxy Server found", __func__);
return -ENOTCONN;
}
@@ -355,14 +354,14 @@ static ssize_t prov_write_ccc_descr(struct bt_conn *conn, u8_t *addr)
return -EINVAL;
}
static ssize_t prov_notification(struct bt_conn *conn, u8_t *data, u16_t len)
static ssize_t prov_notification(struct bt_mesh_conn *conn, u8_t *data, u16_t len)
{
struct bt_mesh_proxy_server *server;
server = find_server(conn);
if (!server) {
BT_ERR("No Proxy Server found");
BT_ERR("%s, No Proxy Server found", __func__);
return -ENOTCONN;
}
@@ -406,17 +405,17 @@ int provisioner_pb_gatt_disable(void)
return 0;
}
#endif /* CONFIG_BT_MESH_PB_GATT */
#endif /* CONFIG_BLE_MESH_PB_GATT */
#if defined(CONFIG_BT_MESH_GATT_PROXY)
static ssize_t proxy_write_ccc_descr(struct bt_conn *conn)
#if defined(CONFIG_BLE_MESH_GATT_PROXY)
static ssize_t proxy_write_ccc_descr(struct bt_mesh_conn *conn)
{
struct bt_mesh_proxy_server *server;
server = find_server(conn);
if (!server) {
BT_ERR("No Proxy Server found");
BT_ERR("%s, No Proxy Server found", __func__);
return -ENOTCONN;
}
@@ -428,7 +427,7 @@ static ssize_t proxy_write_ccc_descr(struct bt_conn *conn)
return -EINVAL;
}
static ssize_t proxy_notification(struct bt_conn *conn, u8_t *data, u16_t len)
static ssize_t proxy_notification(struct bt_mesh_conn *conn, u8_t *data, u16_t len)
{
return proxy_recv(conn, NULL, data, len, 0, 0);
}
@@ -491,30 +490,35 @@ int bt_mesh_provisioner_proxy_disable(void)
return 0;
}
#endif /* CONFIG_BT_MESH_GATT_PROXY */
#endif /* CONFIG_BLE_MESH_GATT_PROXY */
static int proxy_send(struct bt_conn *conn, const void *data, u16_t len)
static int proxy_send(struct bt_mesh_conn *conn, const void *data, u16_t len)
{
BT_DBG("%u bytes: %s", len, bt_hex(data, len));
#if defined(CONFIG_BT_MESH_GATT_PROXY) || defined(CONFIG_BT_MESH_PB_GATT)
#if defined(CONFIG_BLE_MESH_GATT_PROXY) || defined(CONFIG_BLE_MESH_PB_GATT)
return bt_mesh_gattc_write_no_rsp(conn, NULL, data, len);
#endif
return 0;
}
static int proxy_prov_segment_and_send(struct bt_conn *conn, u8_t type,
static int proxy_prov_segment_and_send(struct bt_mesh_conn *conn, u8_t type,
struct net_buf_simple *msg)
{
u16_t mtu;
if (conn == NULL) {
BT_ERR("%s, Invalid parameter", __func__);
return -EINVAL;
}
BT_DBG("conn %p type 0x%02x len %u: %s", conn, type, msg->len,
bt_hex(msg->data, msg->len));
mtu = bt_mesh_gattc_get_mtu_info(conn);
if (!mtu) {
BT_ERR("Conn used to get mtu does not exist");
BT_ERR("%s, Conn used to get mtu does not exist", __func__);
return -ENOTCONN;
}
@@ -544,35 +548,35 @@ static int proxy_prov_segment_and_send(struct bt_conn *conn, u8_t type,
return 0;
}
int provisioner_proxy_send(struct bt_conn *conn, u8_t type,
int provisioner_proxy_send(struct bt_mesh_conn *conn, u8_t type,
struct net_buf_simple *msg)
{
struct bt_mesh_proxy_server *server = find_server(conn);
if (!server) {
BT_ERR("No Proxy Server found");
BT_ERR("$%s, No Proxy Server found", __func__);
return -ENOTCONN;
}
if ((server->filter_type == PROV) != (type == BT_MESH_PROXY_PROV)) {
BT_ERR("Invalid PDU type for Proxy Client");
if ((server->filter_type == PROV) != (type == BLE_MESH_PROXY_PROV)) {
BT_ERR("%s, Invalid PDU type for Proxy Client", __func__);
return -EINVAL;
}
return proxy_prov_segment_and_send(conn, type, msg);
}
static struct bt_prov_conn_cb conn_callbacks = {
.connected = proxy_prov_connected,
.disconnected = proxy_prov_disconnected,
#if defined(CONFIG_BT_MESH_PB_GATT)
.prov_write_descr = prov_write_ccc_descr,
.prov_notify = prov_notification,
#endif /* CONFIG_BT_MESH_PB_GATT */
#if defined(CONFIG_BT_MESH_GATT_PROXY)
static struct bt_mesh_prov_conn_cb conn_callbacks = {
.connected = proxy_prov_connected,
.disconnected = proxy_prov_disconnected,
#if defined(CONFIG_BLE_MESH_PB_GATT)
.prov_write_descr = prov_write_ccc_descr,
.prov_notify = prov_notification,
#endif /* CONFIG_BLE_MESH_PB_GATT */
#if defined(CONFIG_BLE_MESH_GATT_PROXY)
.proxy_write_descr = proxy_write_ccc_descr,
.proxy_notify = proxy_notification,
#endif /* CONFIG_BT_MESH_GATT_PROXY */
.proxy_notify = proxy_notification,
#endif /* CONFIG_BLE_MESH_GATT_PROXY */
};
void provisioner_proxy_srv_data_recv(struct net_buf_simple *buf)
@@ -581,7 +585,7 @@ void provisioner_proxy_srv_data_recv(struct net_buf_simple *buf)
* don't support this function, and if realized later, proxy
* client need to check if there is server structure left
* before create connection with a server.
* check conn_count & CONFIG_BT_MESH_PBG_SAME_TIME
* check conn_count & CONFIG_BLE_MESH_PBG_SAME_TIME
*/
}
@@ -592,7 +596,7 @@ int provisioner_proxy_init(void)
/* Initialize the server receive buffers */
for (i = 0; i < ARRAY_SIZE(servers); i++) {
struct bt_mesh_proxy_server *server = &servers[i];
server->conn = NULL;
server->conn = NULL;
server->buf.size = SERVER_BUF_SIZE;
}
@@ -601,6 +605,4 @@ int provisioner_proxy_init(void)
return 0;
}
#endif /* CONFIG_BT_MESH_PROVISIONER */
#endif /* CONFIG_BT_MESH */
#endif /* CONFIG_BLE_MESH_PROVISIONER */

View File

@@ -17,10 +17,10 @@
#include "mesh_buf.h"
#define BT_MESH_PROXY_NET_PDU 0x00
#define BT_MESH_PROXY_BEACON 0x01
#define BT_MESH_PROXY_CONFIG 0x02
#define BT_MESH_PROXY_PROV 0x03
#define BLE_MESH_PROXY_NET_PDU 0x00
#define BLE_MESH_PROXY_BEACON 0x01
#define BLE_MESH_PROXY_CONFIG 0x02
#define BLE_MESH_PROXY_PROV 0x03
/**
* @brief This function is called to send proxy protocol messages.
@@ -31,7 +31,7 @@
*
* @return Zero-success, other-fail
*/
int provisioner_proxy_send(struct bt_conn *conn, u8_t type, struct net_buf_simple *msg);
int provisioner_proxy_send(struct bt_mesh_conn *conn, u8_t type, struct net_buf_simple *msg);
/**
* @brief This function is called to parse received node identity and net

View File

@@ -9,14 +9,12 @@
#include <string.h>
#include <errno.h>
#include "sdkconfig.h"
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_PROXY)
#include "mesh_buf.h"
#include "mesh_util.h"
#include "sdkconfig.h"
#if CONFIG_BT_MESH
#include "mesh_bearer_adapt.h"
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_MESH_DEBUG_PROXY)
#include "mesh_trace.h"
#include "mesh.h"
@@ -28,7 +26,7 @@
#include "access.h"
#include "proxy.h"
#if CONFIG_BT_MESH_NODE
#if CONFIG_BLE_MESH_NODE
#define PDU_TYPE(data) (data[0] & BIT_MASK(6))
#define PDU_SAR(data) (data[0] >> 6)
@@ -49,26 +47,26 @@
#define CLIENT_BUF_SIZE 68
static const struct bt_le_adv_param slow_adv_param = {
.options = (BT_LE_ADV_OPT_CONNECTABLE | BT_LE_ADV_OPT_ONE_TIME),
.interval_min = BT_GAP_ADV_SLOW_INT_MIN,
.interval_max = BT_GAP_ADV_SLOW_INT_MAX,
static const struct bt_mesh_adv_param slow_adv_param = {
.options = (BLE_MESH_ADV_OPT_CONNECTABLE | BLE_MESH_ADV_OPT_ONE_TIME),
.interval_min = BLE_MESH_GAP_ADV_SLOW_INT_MIN,
.interval_max = BLE_MESH_GAP_ADV_SLOW_INT_MAX,
};
static const struct bt_le_adv_param fast_adv_param = {
.options = (BT_LE_ADV_OPT_CONNECTABLE | BT_LE_ADV_OPT_ONE_TIME),
.interval_min = BT_GAP_ADV_FAST_INT_MIN_0,
.interval_max = BT_GAP_ADV_FAST_INT_MAX_0,
static const struct bt_mesh_adv_param fast_adv_param = {
.options = (BLE_MESH_ADV_OPT_CONNECTABLE | BLE_MESH_ADV_OPT_ONE_TIME),
.interval_min = BLE_MESH_GAP_ADV_FAST_INT_MIN_0,
.interval_max = BLE_MESH_GAP_ADV_FAST_INT_MAX_0,
};
static bool proxy_adv_enabled;
#if defined(CONFIG_BT_MESH_GATT_PROXY)
#if defined(CONFIG_BLE_MESH_GATT_PROXY)
static void proxy_send_beacons(struct k_work *work);
static u16_t proxy_ccc_val;
#endif
#if defined(CONFIG_BT_MESH_PB_GATT)
#if defined(CONFIG_BLE_MESH_PB_GATT)
static u16_t prov_ccc_val;
static bool prov_fast_adv;
#endif
@@ -82,10 +80,10 @@ enum {
static struct bt_mesh_proxy_client {
/* Proxy Server: 20s timeout for each segmented proxy pdu */
ATOMIC_DEFINE(flags, NUM_FLAGS);
BLE_MESH_ATOMIC_DEFINE(flags, NUM_FLAGS);
struct k_delayed_work sar_timer;
struct bt_conn *conn;
u16_t filter[CONFIG_BT_MESH_PROXY_FILTER_SIZE];
struct bt_mesh_conn *conn;
u16_t filter[CONFIG_BLE_MESH_PROXY_FILTER_SIZE];
enum __packed {
NONE,
WHITELIST,
@@ -93,14 +91,14 @@ static struct bt_mesh_proxy_client {
PROV,
} filter_type;
u8_t msg_type;
#if defined(CONFIG_BT_MESH_GATT_PROXY)
#if defined(CONFIG_BLE_MESH_GATT_PROXY)
struct k_work send_beacons;
#endif
struct net_buf_simple buf;
u8_t buf_data[CLIENT_BUF_SIZE];
} clients[CONFIG_BT_MAX_CONN] = {
[0 ... (CONFIG_BT_MAX_CONN - 1)] = {
#if defined(CONFIG_BT_MESH_GATT_PROXY)
#if defined(CONFIG_BLE_MESH_GATT_PROXY)
.send_beacons = _K_WORK_INITIALIZER(proxy_send_beacons),
#endif
.buf.size = CLIENT_BUF_SIZE,
@@ -119,12 +117,12 @@ static char device_name[DEVICE_NAME_SIZE] = "ESP-BLE-MESH";
int bt_mesh_set_device_name(const char *name)
{
if (!name) {
BT_ERR("%s: name is NULL", __func__);
BT_ERR("%s, Invalid parameter", __func__);
return -EINVAL;
}
if (strlen(name) > DEVICE_NAME_SIZE) {
BT_ERR("%s: too long name", __func__);
BT_ERR("%s, Too long device name", __func__);
return -EINVAL;
}
@@ -134,7 +132,7 @@ int bt_mesh_set_device_name(const char *name)
return 0;
}
static struct bt_mesh_proxy_client *find_client(struct bt_conn *conn)
static struct bt_mesh_proxy_client *find_client(struct bt_mesh_conn *conn)
{
int i;
@@ -147,11 +145,11 @@ static struct bt_mesh_proxy_client *find_client(struct bt_conn *conn)
return NULL;
}
#if defined(CONFIG_BT_MESH_GATT_PROXY)
#if defined(CONFIG_BLE_MESH_GATT_PROXY)
/* Next subnet in queue to be advertised */
static int next_idx;
static int proxy_segment_and_send(struct bt_conn *conn, u8_t type,
static int proxy_segment_and_send(struct bt_mesh_conn *conn, u8_t type,
struct net_buf_simple *msg);
static int filter_set(struct bt_mesh_proxy_client *client,
@@ -190,7 +188,7 @@ static void filter_add(struct bt_mesh_proxy_client *client, u16_t addr)
BT_DBG("addr 0x%04x", addr);
if (addr == BT_MESH_ADDR_UNASSIGNED) {
if (addr == BLE_MESH_ADDR_UNASSIGNED) {
return;
}
@@ -201,7 +199,7 @@ static void filter_add(struct bt_mesh_proxy_client *client, u16_t addr)
}
for (i = 0; i < ARRAY_SIZE(client->filter); i++) {
if (client->filter[i] == BT_MESH_ADDR_UNASSIGNED) {
if (client->filter[i] == BLE_MESH_ADDR_UNASSIGNED) {
client->filter[i] = addr;
return;
}
@@ -214,13 +212,13 @@ static void filter_remove(struct bt_mesh_proxy_client *client, u16_t addr)
BT_DBG("addr 0x%04x", addr);
if (addr == BT_MESH_ADDR_UNASSIGNED) {
if (addr == BLE_MESH_ADDR_UNASSIGNED) {
return;
}
for (i = 0; i < ARRAY_SIZE(client->filter); i++) {
if (client->filter[i] == addr) {
client->filter[i] = BT_MESH_ADDR_UNASSIGNED;
client->filter[i] = BLE_MESH_ADDR_UNASSIGNED;
return;
}
}
@@ -239,7 +237,7 @@ static void send_filter_status(struct bt_mesh_proxy_client *client,
int i, err;
/* Configuration messages always have dst unassigned */
tx.ctx->addr = BT_MESH_ADDR_UNASSIGNED;
tx.ctx->addr = BLE_MESH_ADDR_UNASSIGNED;
net_buf_simple_init(buf, 10);
@@ -252,7 +250,7 @@ static void send_filter_status(struct bt_mesh_proxy_client *client,
}
for (filter_size = 0, i = 0; i < ARRAY_SIZE(client->filter); i++) {
if (client->filter[i] != BT_MESH_ADDR_UNASSIGNED) {
if (client->filter[i] != BLE_MESH_ADDR_UNASSIGNED) {
filter_size++;
}
}
@@ -263,13 +261,13 @@ static void send_filter_status(struct bt_mesh_proxy_client *client,
err = bt_mesh_net_encode(&tx, buf, true);
if (err) {
BT_ERR("Encoding Proxy cfg message failed (err %d)", err);
BT_ERR("%s, Failed to encode Proxy Configuration (err %d)", __func__, err);
return;
}
err = proxy_segment_and_send(client->conn, BT_MESH_PROXY_CONFIG, buf);
err = proxy_segment_and_send(client->conn, BLE_MESH_PROXY_CONFIG, buf);
if (err) {
BT_ERR("Failed to send proxy cfg message (err %d)", err);
BT_ERR("%s, Failed to send Proxy Configuration (err %d)", __func__, err);
}
}
@@ -280,15 +278,15 @@ static void proxy_cfg(struct bt_mesh_proxy_client *client)
u8_t opcode;
int err;
err = bt_mesh_net_decode(&client->buf, BT_MESH_NET_IF_PROXY_CFG,
err = bt_mesh_net_decode(&client->buf, BLE_MESH_NET_IF_PROXY_CFG,
&rx, buf);
if (err) {
BT_ERR("Failed to decode Proxy Configuration (err %d)", err);
BT_ERR("%s, Failed to decode Proxy Configuration (err %d)", __func__, err);
return;
}
/* Remove network headers */
net_buf_simple_pull(buf, BT_MESH_NET_HDR_LEN);
net_buf_simple_pull(buf, BLE_MESH_NET_HDR_LEN);
BT_DBG("%u bytes: %s", buf->len, bt_hex(buf->data, buf->len));
@@ -327,14 +325,14 @@ static void proxy_cfg(struct bt_mesh_proxy_client *client)
}
}
static int beacon_send(struct bt_conn *conn, struct bt_mesh_subnet *sub)
static int beacon_send(struct bt_mesh_conn *conn, struct bt_mesh_subnet *sub)
{
struct net_buf_simple *buf = NET_BUF_SIMPLE(23);
net_buf_simple_init(buf, 1);
bt_mesh_beacon_create(sub, buf);
return proxy_segment_and_send(conn, BT_MESH_PROXY_BEACON, buf);
return proxy_segment_and_send(conn, BLE_MESH_PROXY_BEACON, buf);
}
static void proxy_send_beacons(struct k_work *work)
@@ -347,7 +345,7 @@ static void proxy_send_beacons(struct k_work *work)
for (i = 0; i < ARRAY_SIZE(bt_mesh.sub); i++) {
struct bt_mesh_subnet *sub = &bt_mesh.sub[i];
if (sub->net_idx != BT_MESH_KEY_UNUSED) {
if (sub->net_idx != BLE_MESH_KEY_UNUSED) {
beacon_send(client->conn, sub);
}
}
@@ -360,7 +358,7 @@ void bt_mesh_proxy_beacon_send(struct bt_mesh_subnet *sub)
if (!sub) {
/* NULL means we send on all subnets */
for (i = 0; i < ARRAY_SIZE(bt_mesh.sub); i++) {
if (bt_mesh.sub[i].net_idx != BT_MESH_KEY_UNUSED) {
if (bt_mesh.sub[i].net_idx != BLE_MESH_KEY_UNUSED) {
bt_mesh_proxy_beacon_send(&bt_mesh.sub[i]);
}
}
@@ -377,7 +375,7 @@ void bt_mesh_proxy_beacon_send(struct bt_mesh_subnet *sub)
void bt_mesh_proxy_identity_start(struct bt_mesh_subnet *sub)
{
sub->node_id = BT_MESH_NODE_IDENTITY_RUNNING;
sub->node_id = BLE_MESH_NODE_IDENTITY_RUNNING;
sub->node_id_start = k_uptime_get_32();
/* Prioritize the recently enabled subnet */
@@ -386,7 +384,7 @@ void bt_mesh_proxy_identity_start(struct bt_mesh_subnet *sub)
void bt_mesh_proxy_identity_stop(struct bt_mesh_subnet *sub)
{
sub->node_id = BT_MESH_NODE_IDENTITY_STOPPED;
sub->node_id = BLE_MESH_NODE_IDENTITY_STOPPED;
sub->node_id_start = 0;
}
@@ -403,11 +401,11 @@ int bt_mesh_proxy_identity_enable(void)
for (i = 0; i < ARRAY_SIZE(bt_mesh.sub); i++) {
struct bt_mesh_subnet *sub = &bt_mesh.sub[i];
if (sub->net_idx == BT_MESH_KEY_UNUSED) {
if (sub->net_idx == BLE_MESH_KEY_UNUSED) {
continue;
}
if (sub->node_id == BT_MESH_NODE_IDENTITY_NOT_SUPPORTED) {
if (sub->node_id == BLE_MESH_NODE_IDENTITY_NOT_SUPPORTED) {
continue;
}
@@ -432,11 +430,11 @@ static void proxy_recv_timeout(struct k_work *work)
client = CONTAINER_OF(work, struct bt_mesh_proxy_client, sar_timer.work);
if (!client || !client->conn) {
BT_ERR("%s, Client parameter is NULL", __func__);
BT_ERR("%s, Invalid proxy client parameter", __func__);
return;
}
atomic_clear_bit(client->flags, SAR_TIMER_START);
bt_mesh_atomic_clear_bit(client->flags, SAR_TIMER_START);
net_buf_simple_init(&client->buf, 0);
bt_mesh_gatts_disconnect(client->conn, 0x13);
}
@@ -444,22 +442,22 @@ static void proxy_recv_timeout(struct k_work *work)
static void proxy_complete_pdu(struct bt_mesh_proxy_client *client)
{
switch (client->msg_type) {
#if defined(CONFIG_BT_MESH_GATT_PROXY)
case BT_MESH_PROXY_NET_PDU:
#if defined(CONFIG_BLE_MESH_GATT_PROXY)
case BLE_MESH_PROXY_NET_PDU:
BT_DBG("Mesh Network PDU");
bt_mesh_net_recv(&client->buf, 0, BT_MESH_NET_IF_PROXY);
bt_mesh_net_recv(&client->buf, 0, BLE_MESH_NET_IF_PROXY);
break;
case BT_MESH_PROXY_BEACON:
case BLE_MESH_PROXY_BEACON:
BT_DBG("Mesh Beacon PDU");
bt_mesh_beacon_recv(&client->buf);
break;
case BT_MESH_PROXY_CONFIG:
case BLE_MESH_PROXY_CONFIG:
BT_DBG("Mesh Configuration PDU");
proxy_cfg(client);
break;
#endif
#if defined(CONFIG_BT_MESH_PB_GATT)
case BT_MESH_PROXY_PROV:
#if defined(CONFIG_BLE_MESH_PB_GATT)
case BLE_MESH_PROXY_PROV:
BT_DBG("Mesh Provisioning PDU");
bt_mesh_pb_gatt_recv(client->conn, &client->buf);
break;
@@ -474,8 +472,8 @@ static void proxy_complete_pdu(struct bt_mesh_proxy_client *client)
#define ATTR_IS_PROV(attr) (attr->user_data != NULL)
static ssize_t proxy_recv(struct bt_conn *conn,
const struct bt_gatt_attr *attr, const void *buf,
static ssize_t proxy_recv(struct bt_mesh_conn *conn,
const struct bt_mesh_gatt_attr *attr, const void *buf,
u16_t len, u16_t offset, u8_t flags)
{
struct bt_mesh_proxy_client *client = find_client(conn);
@@ -490,7 +488,7 @@ static ssize_t proxy_recv(struct bt_conn *conn,
return -EINVAL;
}
if (ATTR_IS_PROV(attr) != (PDU_TYPE(data) == BT_MESH_PROXY_PROV)) {
if (ATTR_IS_PROV(attr) != (PDU_TYPE(data) == BLE_MESH_PROXY_PROV)) {
BT_WARN("Proxy PDU type doesn't match GATT service");
return -EINVAL;
}
@@ -518,7 +516,7 @@ static ssize_t proxy_recv(struct bt_conn *conn,
return -EINVAL;
}
if (!atomic_test_and_set_bit(client->flags, SAR_TIMER_START)) {
if (!bt_mesh_atomic_test_and_set_bit(client->flags, SAR_TIMER_START)) {
k_delayed_work_submit(&client->sar_timer, PROXY_SAR_TRANS_TIMEOUT);
}
@@ -551,7 +549,7 @@ static ssize_t proxy_recv(struct bt_conn *conn,
return -EINVAL;
}
if (atomic_test_and_clear_bit(client->flags, SAR_TIMER_START)) {
if (bt_mesh_atomic_test_and_clear_bit(client->flags, SAR_TIMER_START)) {
k_delayed_work_cancel(&client->sar_timer);
}
@@ -565,7 +563,7 @@ static ssize_t proxy_recv(struct bt_conn *conn,
static int conn_count;
static void proxy_connected(struct bt_conn *conn, u8_t err)
static void proxy_connected(struct bt_mesh_conn *conn, u8_t err)
{
struct bt_mesh_proxy_client *client;
int i;
@@ -590,7 +588,7 @@ static void proxy_connected(struct bt_conn *conn, u8_t err)
}
if (!client) {
BT_ERR("No free Proxy Client objects");
BT_ERR("%s, No free Proxy Client objects", __func__);
return;
}
@@ -600,7 +598,7 @@ static void proxy_connected(struct bt_conn *conn, u8_t err)
net_buf_simple_init(&client->buf, 0);
}
static void proxy_disconnected(struct bt_conn *conn, u8_t reason)
static void proxy_disconnected(struct bt_mesh_conn *conn, u8_t reason)
{
int i;
@@ -612,12 +610,12 @@ static void proxy_disconnected(struct bt_conn *conn, u8_t reason)
struct bt_mesh_proxy_client *client = &clients[i];
if (client->conn == conn) {
if (IS_ENABLED(CONFIG_BT_MESH_PB_GATT) &&
if (IS_ENABLED(CONFIG_BLE_MESH_PB_GATT) &&
client->filter_type == PROV) {
bt_mesh_pb_gatt_close(conn);
}
if (atomic_test_and_clear_bit(client->flags, SAR_TIMER_START)) {
if (bt_mesh_atomic_test_and_clear_bit(client->flags, SAR_TIMER_START)) {
k_delayed_work_cancel(&client->sar_timer);
}
// Should reset the atomic flag after disconneted
@@ -639,9 +637,9 @@ struct net_buf_simple *bt_mesh_proxy_get_buf(void)
return buf;
}
#if defined(CONFIG_BT_MESH_PB_GATT)
static ssize_t prov_ccc_write(struct bt_conn *conn,
const struct bt_gatt_attr *attr,
#if defined(CONFIG_BLE_MESH_PB_GATT)
static ssize_t prov_ccc_write(struct bt_mesh_conn *conn,
const struct bt_mesh_gatt_attr *attr,
const void *buf, u16_t len,
u16_t offset, u8_t flags)
{
@@ -651,11 +649,11 @@ static ssize_t prov_ccc_write(struct bt_conn *conn,
BT_DBG("len %u: %s", len, bt_hex(buf, len));
if (len != sizeof(*value)) {
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
return BLE_MESH_GATT_ERR(BLE_MESH_ATT_ERR_INVALID_ATTRIBUTE_LEN);
}
*value = sys_get_le16(buf);
if (*value != BT_GATT_CCC_NOTIFY) {
if (*value != BLE_MESH_GATT_CCC_NOTIFY) {
BT_WARN("Client wrote 0x%04x instead enabling notify", *value);
return len;
}
@@ -672,8 +670,8 @@ static ssize_t prov_ccc_write(struct bt_conn *conn,
return len;
}
static ssize_t prov_ccc_read(struct bt_conn *conn,
const struct bt_gatt_attr *attr,
static ssize_t prov_ccc_read(struct bt_mesh_conn *conn,
const struct bt_mesh_gatt_attr *attr,
void *buf, u16_t len, u16_t offset)
{
u16_t *value = attr->user_data;
@@ -683,25 +681,25 @@ static ssize_t prov_ccc_read(struct bt_conn *conn,
}
/* Mesh Provisioning Service Declaration */
static struct bt_gatt_attr prov_attrs[] = {
BT_GATT_PRIMARY_SERVICE(BT_UUID_MESH_PROV),
static struct bt_mesh_gatt_attr prov_attrs[] = {
BLE_MESH_GATT_PRIMARY_SERVICE(BLE_MESH_UUID_MESH_PROV),
BT_GATT_CHARACTERISTIC(BT_UUID_MESH_PROV_DATA_IN,
BT_GATT_CHRC_WRITE_WITHOUT_RESP),
BT_GATT_DESCRIPTOR(BT_UUID_MESH_PROV_DATA_IN, BT_GATT_PERM_WRITE,
BLE_MESH_GATT_CHARACTERISTIC(BLE_MESH_UUID_MESH_PROV_DATA_IN,
BLE_MESH_GATT_CHRC_WRITE_WITHOUT_RESP),
BLE_MESH_GATT_DESCRIPTOR(BLE_MESH_UUID_MESH_PROV_DATA_IN, BLE_MESH_GATT_PERM_WRITE,
NULL, proxy_recv, (void *)1),
BT_GATT_CHARACTERISTIC(BT_UUID_MESH_PROV_DATA_OUT,
BT_GATT_CHRC_NOTIFY),
BT_GATT_DESCRIPTOR(BT_UUID_MESH_PROV_DATA_OUT, BT_GATT_PERM_NONE,
BLE_MESH_GATT_CHARACTERISTIC(BLE_MESH_UUID_MESH_PROV_DATA_OUT,
BLE_MESH_GATT_CHRC_NOTIFY),
BLE_MESH_GATT_DESCRIPTOR(BLE_MESH_UUID_MESH_PROV_DATA_OUT, BLE_MESH_GATT_PERM_NONE,
NULL, NULL, NULL),
/* Add custom CCC as clients need to be tracked individually */
BT_GATT_DESCRIPTOR(BT_UUID_GATT_CCC,
BT_GATT_PERM_WRITE | BT_GATT_PERM_READ,
BLE_MESH_GATT_DESCRIPTOR(BLE_MESH_UUID_GATT_CCC,
BLE_MESH_GATT_PERM_WRITE | BLE_MESH_GATT_PERM_READ,
prov_ccc_read, prov_ccc_write, &prov_ccc_val),
};
struct bt_gatt_service prov_svc = BT_GATT_SERVICE(prov_attrs);
struct bt_mesh_gatt_service prov_svc = BLE_MESH_GATT_SERVICE(prov_attrs);
int bt_mesh_proxy_prov_enable(void)
{
@@ -709,10 +707,8 @@ int bt_mesh_proxy_prov_enable(void)
BT_DBG("%s", __func__);
/**TODO: Change by Espressif. We should not register service here, otherwise will
* block btu task, so currently just start it. Need to further check*/
bt_mesh_gatts_service_start(&prov_svc);
//bt_mesh_gatts_service_register(&prov_svc);
gatt_svc = MESH_GATT_PROV;
prov_fast_adv = true;
@@ -732,10 +728,8 @@ int bt_mesh_proxy_prov_disable(void)
BT_DBG("%s", __func__);
/**TODO: Change by Espressif. Please refer to bt_mesh_proxy_prov_enable for
* more info */
bt_mesh_gatts_service_stop(&prov_svc);
//bt_mesh_gatts_service_unregister(&prov_svc);
gatt_svc = MESH_GATT_NONE;
for (i = 0; i < ARRAY_SIZE(clients); i++) {
@@ -750,11 +744,11 @@ int bt_mesh_proxy_prov_disable(void)
return 0;
}
#endif /* CONFIG_BT_MESH_PB_GATT */
#endif /* CONFIG_BLE_MESH_PB_GATT */
#if defined(CONFIG_BT_MESH_GATT_PROXY)
static ssize_t proxy_ccc_write(struct bt_conn *conn,
const struct bt_gatt_attr *attr,
#if defined(CONFIG_BLE_MESH_GATT_PROXY)
static ssize_t proxy_ccc_write(struct bt_mesh_conn *conn,
const struct bt_mesh_gatt_attr *attr,
const void *buf, u16_t len,
u16_t offset, u8_t flags)
{
@@ -764,11 +758,11 @@ static ssize_t proxy_ccc_write(struct bt_conn *conn,
BT_DBG("len %u: %s", len, bt_hex(buf, len));
if (len != sizeof(value)) {
return BT_GATT_ERR(BT_ATT_ERR_INVALID_ATTRIBUTE_LEN);
return BLE_MESH_GATT_ERR(BLE_MESH_ATT_ERR_INVALID_ATTRIBUTE_LEN);
}
value = sys_get_le16(buf);
if (value != BT_GATT_CCC_NOTIFY) {
if (value != BLE_MESH_GATT_CCC_NOTIFY) {
BT_WARN("Client wrote 0x%04x instead enabling notify", value);
return len;
}
@@ -785,8 +779,8 @@ static ssize_t proxy_ccc_write(struct bt_conn *conn,
return len;
}
static ssize_t proxy_ccc_read(struct bt_conn *conn,
const struct bt_gatt_attr *attr,
static ssize_t proxy_ccc_read(struct bt_mesh_conn *conn,
const struct bt_mesh_gatt_attr *attr,
void *buf, u16_t len, u16_t offset)
{
u16_t *value = attr->user_data;
@@ -796,25 +790,25 @@ static ssize_t proxy_ccc_read(struct bt_conn *conn,
}
/* Mesh Proxy Service Declaration */
static struct bt_gatt_attr proxy_attrs[] = {
BT_GATT_PRIMARY_SERVICE(BT_UUID_MESH_PROXY),
static struct bt_mesh_gatt_attr proxy_attrs[] = {
BLE_MESH_GATT_PRIMARY_SERVICE(BLE_MESH_UUID_MESH_PROXY),
BT_GATT_CHARACTERISTIC(BT_UUID_MESH_PROXY_DATA_IN,
BT_GATT_CHRC_WRITE_WITHOUT_RESP),
BT_GATT_DESCRIPTOR(BT_UUID_MESH_PROXY_DATA_IN, BT_GATT_PERM_WRITE,
BLE_MESH_GATT_CHARACTERISTIC(BLE_MESH_UUID_MESH_PROXY_DATA_IN,
BLE_MESH_GATT_CHRC_WRITE_WITHOUT_RESP),
BLE_MESH_GATT_DESCRIPTOR(BLE_MESH_UUID_MESH_PROXY_DATA_IN, BLE_MESH_GATT_PERM_WRITE,
NULL, proxy_recv, NULL),
BT_GATT_CHARACTERISTIC(BT_UUID_MESH_PROXY_DATA_OUT,
BT_GATT_CHRC_NOTIFY),
BT_GATT_DESCRIPTOR(BT_UUID_MESH_PROXY_DATA_OUT, BT_GATT_PERM_NONE,
BLE_MESH_GATT_CHARACTERISTIC(BLE_MESH_UUID_MESH_PROXY_DATA_OUT,
BLE_MESH_GATT_CHRC_NOTIFY),
BLE_MESH_GATT_DESCRIPTOR(BLE_MESH_UUID_MESH_PROXY_DATA_OUT, BLE_MESH_GATT_PERM_NONE,
NULL, NULL, NULL),
/* Add custom CCC as clients need to be tracked individually */
BT_GATT_DESCRIPTOR(BT_UUID_GATT_CCC,
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
BLE_MESH_GATT_DESCRIPTOR(BLE_MESH_UUID_GATT_CCC,
BLE_MESH_GATT_PERM_READ | BLE_MESH_GATT_PERM_WRITE,
proxy_ccc_read, proxy_ccc_write, &proxy_ccc_val),
};
struct bt_gatt_service proxy_svc = BT_GATT_SERVICE(proxy_attrs);
struct bt_mesh_gatt_service proxy_svc = BLE_MESH_GATT_SERVICE(proxy_attrs);
int bt_mesh_proxy_gatt_enable(void)
{
@@ -822,10 +816,8 @@ int bt_mesh_proxy_gatt_enable(void)
BT_DBG("%s", __func__);
/**TODO: We should not register service here, otherwise will
* block btu task, so currently just start it. Need to further check*/
bt_mesh_gatts_service_start(&proxy_svc);
//bt_mesh_gatts_service_register(&proxy_svc);
gatt_svc = MESH_GATT_PROXY;
for (i = 0; i < ARRAY_SIZE(clients); i++) {
@@ -850,7 +842,6 @@ void bt_mesh_proxy_gatt_disconnect(void)
client->filter_type == BLACKLIST)) {
client->filter_type = NONE;
bt_mesh_gatts_disconnect(client->conn, 0x13);
//BT_HCI_ERR_REMOTE_USER_TERM_CONN);
}
}
}
@@ -861,10 +852,8 @@ int bt_mesh_proxy_gatt_disable(void)
bt_mesh_proxy_gatt_disconnect();
/**TODO: please refer to comment of bt_mesh_proxy_gatt_enable,
* We not de-register, but only stop service*/
bt_mesh_gatts_service_stop(&proxy_svc);
//bt_mesh_gatts_service_unregister(&proxy_svc);
gatt_svc = MESH_GATT_NONE;
return 0;
@@ -939,26 +928,26 @@ bool bt_mesh_proxy_relay(struct net_buf_simple *buf, u16_t dst)
net_buf_simple_init(msg, 1);
net_buf_simple_add_mem(msg, buf->data, buf->len);
bt_mesh_proxy_send(client->conn, BT_MESH_PROXY_NET_PDU, msg);
bt_mesh_proxy_send(client->conn, BLE_MESH_PROXY_NET_PDU, msg);
relayed = true;
}
return relayed;
}
#endif /* CONFIG_BT_MESH_GATT_PROXY */
#endif /* CONFIG_BLE_MESH_GATT_PROXY */
static int proxy_send(struct bt_conn *conn, const void *data, u16_t len)
static int proxy_send(struct bt_mesh_conn *conn, const void *data, u16_t len)
{
BT_DBG("%u bytes: %s", len, bt_hex(data, len));
#if defined(CONFIG_BT_MESH_GATT_PROXY)
#if defined(CONFIG_BLE_MESH_GATT_PROXY)
if (gatt_svc == MESH_GATT_PROXY) {
return bt_mesh_gatts_notify(conn, &proxy_attrs[4], data, len);
}
#endif
#if defined(CONFIG_BT_MESH_PB_GATT)
#if defined(CONFIG_BLE_MESH_PB_GATT)
if (gatt_svc == MESH_GATT_PROV) {
return bt_mesh_gatts_notify(conn, &prov_attrs[4], data, len);
}
@@ -967,7 +956,7 @@ static int proxy_send(struct bt_conn *conn, const void *data, u16_t len)
return 0;
}
static int proxy_segment_and_send(struct bt_conn *conn, u8_t type,
static int proxy_segment_and_send(struct bt_mesh_conn *conn, u8_t type,
struct net_buf_simple *msg)
{
u16_t mtu;
@@ -1001,40 +990,40 @@ static int proxy_segment_and_send(struct bt_conn *conn, u8_t type,
return 0;
}
int bt_mesh_proxy_send(struct bt_conn *conn, u8_t type,
int bt_mesh_proxy_send(struct bt_mesh_conn *conn, u8_t type,
struct net_buf_simple *msg)
{
struct bt_mesh_proxy_client *client = find_client(conn);
if (!client) {
BT_ERR("No Proxy Client found");
BT_ERR("%s, No Proxy Client found", __func__);
return -ENOTCONN;
}
if ((client->filter_type == PROV) != (type == BT_MESH_PROXY_PROV)) {
BT_ERR("Invalid PDU type for Proxy Client");
if ((client->filter_type == PROV) != (type == BLE_MESH_PROXY_PROV)) {
BT_ERR("%s, Invalid PDU type for Proxy Client", __func__);
return -EINVAL;
}
return proxy_segment_and_send(conn, type, msg);
}
#if defined(CONFIG_BT_MESH_PB_GATT)
#if defined(CONFIG_BLE_MESH_PB_GATT)
static u8_t prov_svc_data[20] = { 0x27, 0x18, };
static const struct bt_data prov_ad[] = {
BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)),
BT_DATA_BYTES(BT_DATA_UUID16_ALL, 0x27, 0x18),
BT_DATA(BT_DATA_SVC_DATA16, prov_svc_data, sizeof(prov_svc_data)),
static const struct bt_mesh_adv_data prov_ad[] = {
BLE_MESH_ADV_DATA_BYTES(BLE_MESH_DATA_FLAGS, (BLE_MESH_AD_GENERAL | BLE_MESH_AD_NO_BREDR)),
BLE_MESH_ADV_DATA_BYTES(BLE_MESH_DATA_UUID16_ALL, 0x27, 0x18),
BLE_MESH_ADV_DATA(BLE_MESH_DATA_SVC_DATA16, prov_svc_data, sizeof(prov_svc_data)),
};
static const struct bt_data prov_sd[] = {
BT_DATA(BT_DATA_NAME_COMPLETE, device_name,
static const struct bt_mesh_adv_data prov_sd[] = {
BLE_MESH_ADV_DATA(BLE_MESH_DATA_NAME_COMPLETE, device_name,
(sizeof(device_name) - 1)),
};
#endif /* PB_GATT */
#if defined(CONFIG_BT_MESH_GATT_PROXY)
#if defined(CONFIG_BLE_MESH_GATT_PROXY)
#define ID_TYPE_NET 0x00
#define ID_TYPE_NODE 0x01
@@ -1042,20 +1031,20 @@ static const struct bt_data prov_sd[] = {
#define NODE_ID_LEN 19
#define NET_ID_LEN 11
#define NODE_ID_TIMEOUT K_SECONDS(CONFIG_BT_MESH_NODE_ID_TIMEOUT)
#define NODE_ID_TIMEOUT K_SECONDS(CONFIG_BLE_MESH_NODE_ID_TIMEOUT)
static u8_t proxy_svc_data[NODE_ID_LEN] = { 0x28, 0x18, };
static const struct bt_data node_id_ad[] = {
BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)),
BT_DATA_BYTES(BT_DATA_UUID16_ALL, 0x28, 0x18),
BT_DATA(BT_DATA_SVC_DATA16, proxy_svc_data, NODE_ID_LEN),
static const struct bt_mesh_adv_data node_id_ad[] = {
BLE_MESH_ADV_DATA_BYTES(BLE_MESH_DATA_FLAGS, (BLE_MESH_AD_GENERAL | BLE_MESH_AD_NO_BREDR)),
BLE_MESH_ADV_DATA_BYTES(BLE_MESH_DATA_UUID16_ALL, 0x28, 0x18),
BLE_MESH_ADV_DATA(BLE_MESH_DATA_SVC_DATA16, proxy_svc_data, NODE_ID_LEN),
};
static const struct bt_data net_id_ad[] = {
BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)),
BT_DATA_BYTES(BT_DATA_UUID16_ALL, 0x28, 0x18),
BT_DATA(BT_DATA_SVC_DATA16, proxy_svc_data, NET_ID_LEN),
static const struct bt_mesh_adv_data net_id_ad[] = {
BLE_MESH_ADV_DATA_BYTES(BLE_MESH_DATA_FLAGS, (BLE_MESH_AD_GENERAL | BLE_MESH_AD_NO_BREDR)),
BLE_MESH_ADV_DATA_BYTES(BLE_MESH_DATA_UUID16_ALL, 0x28, 0x18),
BLE_MESH_ADV_DATA(BLE_MESH_DATA_SVC_DATA16, proxy_svc_data, NET_ID_LEN),
};
static int node_id_adv(struct bt_mesh_subnet *sub)
@@ -1076,7 +1065,7 @@ static int node_id_adv(struct bt_mesh_subnet *sub)
memcpy(tmp + 6, proxy_svc_data + 11, 8);
sys_put_be16(bt_mesh_primary_addr(), tmp + 14);
err = bt_encrypt_be(sub->keys[sub->kr_flag].identity, tmp, tmp);
err = bt_mesh_encrypt_be(sub->keys[sub->kr_flag].identity, tmp, tmp);
if (err) {
return err;
}
@@ -1122,12 +1111,12 @@ static int net_id_adv(struct bt_mesh_subnet *sub)
static bool advertise_subnet(struct bt_mesh_subnet *sub)
{
if (sub->net_idx == BT_MESH_KEY_UNUSED) {
if (sub->net_idx == BLE_MESH_KEY_UNUSED) {
return false;
}
return (sub->node_id == BT_MESH_NODE_IDENTITY_RUNNING ||
bt_mesh_gatt_proxy_get() == BT_MESH_GATT_PROXY_ENABLED);
return (sub->node_id == BLE_MESH_NODE_IDENTITY_RUNNING ||
bt_mesh_gatt_proxy_get() == BLE_MESH_GATT_PROXY_ENABLED);
}
static struct bt_mesh_subnet *next_sub(void)
@@ -1179,7 +1168,7 @@ static s32_t gatt_proxy_advertise(struct bt_mesh_subnet *sub)
return remaining;
}
if (sub->node_id == BT_MESH_NODE_IDENTITY_RUNNING) {
if (sub->node_id == BLE_MESH_NODE_IDENTITY_RUNNING) {
u32_t active = k_uptime_get_32() - sub->node_id_start;
if (active < NODE_ID_TIMEOUT) {
@@ -1193,8 +1182,8 @@ static s32_t gatt_proxy_advertise(struct bt_mesh_subnet *sub)
}
}
if (sub->node_id == BT_MESH_NODE_IDENTITY_STOPPED) {
if (bt_mesh_gatt_proxy_get() == BT_MESH_GATT_PROXY_ENABLED) {
if (sub->node_id == BLE_MESH_NODE_IDENTITY_STOPPED) {
if (bt_mesh_gatt_proxy_get() == BLE_MESH_GATT_PROXY_ENABLED) {
net_id_adv(sub);
} else {
return gatt_proxy_advertise(next_sub());
@@ -1211,8 +1200,8 @@ static s32_t gatt_proxy_advertise(struct bt_mesh_subnet *sub)
* 6 slices, but make sure that a slice is at least one
* second long (to avoid excessive rotation).
*/
max_timeout = NODE_ID_TIMEOUT / max(subnet_count, 6);
max_timeout = max(max_timeout, K_SECONDS(1));
max_timeout = NODE_ID_TIMEOUT / MAX(subnet_count, 6);
max_timeout = MAX(max_timeout, K_SECONDS(1));
if (remaining > max_timeout || remaining < 0) {
remaining = max_timeout;
@@ -1234,9 +1223,9 @@ s32_t bt_mesh_proxy_adv_start(void)
return K_FOREVER;
}
#if defined(CONFIG_BT_MESH_PB_GATT)
#if defined(CONFIG_BLE_MESH_PB_GATT)
if (!bt_mesh_is_provisioned()) {
const struct bt_le_adv_param *param;
const struct bt_mesh_adv_param *param;
if (prov_fast_adv) {
param = &fast_adv_param;
@@ -1257,7 +1246,7 @@ s32_t bt_mesh_proxy_adv_start(void)
}
#endif /* PB_GATT */
#if defined(CONFIG_BT_MESH_GATT_PROXY)
#if defined(CONFIG_BLE_MESH_GATT_PROXY)
if (bt_mesh_is_provisioned()) {
return gatt_proxy_advertise(next_sub());
}
@@ -1278,13 +1267,13 @@ void bt_mesh_proxy_adv_stop(void)
err = bt_le_adv_stop();
if (err) {
BT_ERR("Failed to stop advertising (err %d)", err);
BT_ERR("%s, Stop advertising failed (err %d)", __func__, err);
} else {
proxy_adv_enabled = false;
}
}
static struct bt_conn_cb conn_callbacks = {
static struct bt_mesh_conn_cb conn_callbacks = {
.connected = proxy_connected,
.disconnected = proxy_disconnected,
};
@@ -1297,9 +1286,9 @@ int bt_mesh_proxy_init(void)
}
bt_mesh_gatts_conn_cb_register(&conn_callbacks);
#if defined(CONFIG_BT_MESH_PB_GATT)
#if defined(CONFIG_BLE_MESH_PB_GATT)
if (!bt_mesh_prov_get_uuid()) {
BT_ERR("%s: prov->uuid not initialized", __func__);
BT_ERR("%s, UUID is not initialized", __func__);
return -EINVAL;
}
memcpy(prov_svc_data + 2, bt_mesh_prov_get_uuid(), 16);
@@ -1308,6 +1297,4 @@ int bt_mesh_proxy_init(void)
return 0;
}
#endif /* CONFIG_BT_MESH_NODE */
#endif /* #if CONFIG_BT_MESH */
#endif /* CONFIG_BLE_MESH_NODE */

View File

@@ -7,23 +7,23 @@
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __PROXY_H__
#define __PROXY_H__
#ifndef _PROXY_H_
#define _PROXY_H_
#include "net.h"
#include "mesh_buf.h"
#include "mesh_bearer_adapt.h"
#define BT_MESH_PROXY_NET_PDU 0x00
#define BT_MESH_PROXY_BEACON 0x01
#define BT_MESH_PROXY_CONFIG 0x02
#define BT_MESH_PROXY_PROV 0x03
#define BLE_MESH_PROXY_NET_PDU 0x00
#define BLE_MESH_PROXY_BEACON 0x01
#define BLE_MESH_PROXY_CONFIG 0x02
#define BLE_MESH_PROXY_PROV 0x03
#define DEVICE_NAME_SIZE 29
int bt_mesh_set_device_name(const char *name);
int bt_mesh_proxy_send(struct bt_conn *conn, u8_t type,
int bt_mesh_proxy_send(struct bt_mesh_conn *conn, u8_t type,
struct net_buf_simple *msg);
int bt_mesh_proxy_prov_enable(void);
@@ -44,8 +44,9 @@ void bt_mesh_proxy_identity_start(struct bt_mesh_subnet *sub);
void bt_mesh_proxy_identity_stop(struct bt_mesh_subnet *sub);
bool bt_mesh_proxy_relay(struct net_buf_simple *buf, u16_t dst);
void bt_mesh_proxy_addr_add(struct net_buf_simple *buf, u16_t addr);
int bt_mesh_proxy_init(void);
#endif /* __PROXY_H__ */
#endif /* _PROXY_H_ */

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More