ble_mesh: adapt ble mesh with nimble host

This commit is contained in:
lly 2019-10-21 22:48:47 +08:00
parent dfcfe467c9
commit 30aa236219
11 changed files with 87 additions and 57 deletions

View file

@ -25,7 +25,7 @@ esp_err_t esp_ble_mesh_lpn_enable(void)
{
btc_msg_t msg = {0};
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
@ -39,7 +39,7 @@ esp_err_t esp_ble_mesh_lpn_disable(bool force)
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
@ -55,7 +55,7 @@ esp_err_t esp_ble_mesh_lpn_poll(void)
{
btc_msg_t msg = {0};
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;

View file

@ -203,7 +203,7 @@ esp_err_t esp_ble_mesh_server_model_update_state(esp_ble_mesh_model_t *model,
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
arg.model_update_state.model = model;
arg.model_update_state.type = type;

View file

@ -61,23 +61,23 @@ 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);
}
esp_err_t esp_ble_mesh_proxy_client_connect(esp_bd_addr_t addr,
esp_ble_addr_type_t addr_type, uint16_t net_idx)
esp_err_t esp_ble_mesh_proxy_client_connect(esp_ble_mesh_bd_addr_t addr,
esp_ble_mesh_addr_type_t addr_type, uint16_t net_idx)
{
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
if (!addr || addr_type > BLE_ADDR_TYPE_RANDOM) {
if (!addr || addr_type > ESP_BLE_MESH_ADDR_TYPE_RANDOM) {
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
msg.act = BTC_BLE_MESH_ACT_PROXY_CLIENT_CONNECT;
memcpy(arg.proxy_client_connect.addr, addr, ESP_BD_ADDR_LEN);
memcpy(arg.proxy_client_connect.addr, addr, BD_ADDR_LEN);
arg.proxy_client_connect.addr_type = addr_type;
arg.proxy_client_connect.net_idx = net_idx;
@ -90,7 +90,7 @@ esp_err_t esp_ble_mesh_proxy_client_disconnect(uint8_t conn_handle)
btc_ble_mesh_prov_args_t arg = {0};
btc_msg_t msg = {0};
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
@ -112,7 +112,7 @@ esp_err_t esp_ble_mesh_proxy_client_set_filter_type(uint8_t conn_handle,
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
@ -136,7 +136,7 @@ esp_err_t esp_ble_mesh_proxy_client_add_filter_addr(uint8_t conn_handle,
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;
@ -161,7 +161,7 @@ esp_err_t esp_ble_mesh_proxy_client_remove_filter_addr(uint8_t conn_handle,
return ESP_ERR_INVALID_ARG;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_PROV;

View file

@ -60,8 +60,8 @@ esp_err_t esp_ble_mesh_proxy_gatt_disable(void);
* @return ESP_OK on success or error code otherwise.
*
*/
esp_err_t esp_ble_mesh_proxy_client_connect(esp_bd_addr_t addr,
esp_ble_addr_type_t addr_type, uint16_t net_idx);
esp_err_t esp_ble_mesh_proxy_client_connect(esp_ble_mesh_bd_addr_t addr,
esp_ble_mesh_addr_type_t addr_type, uint16_t net_idx);
/**
* @brief Proxy Client terminates a connection with the Proxy Server.

View file

@ -1087,8 +1087,8 @@ typedef union {
* @brief ESP_BLE_MESH_PROXY_CLIENT_RECV_ADV_PKT_EVT
*/
struct ble_mesh_proxy_client_recv_adv_pkt_param {
esp_bd_addr_t addr; /*!< Device address */
esp_ble_addr_type_t addr_type; /*!< Device address type */
esp_ble_mesh_bd_addr_t addr; /*!< Device address */
esp_ble_mesh_addr_type_t addr_type; /*!< Device address type */
uint16_t net_idx; /*!< Network ID related NetKey Index */
uint8_t net_id[8]; /*!< Network ID contained in the advertising packet */
} proxy_client_recv_adv_pkt; /*!< Event parameter of ESP_BLE_MESH_PROXY_CLIENT_RECV_ADV_PKT_EVT */
@ -1096,8 +1096,8 @@ typedef union {
* @brief ESP_BLE_MESH_PROXY_CLIENT_CONNECTED_EVT
*/
struct ble_mesh_proxy_client_connected_param {
esp_bd_addr_t addr; /*!< Device address of the Proxy Server */
esp_ble_addr_type_t addr_type; /*!< Device address type */
esp_ble_mesh_bd_addr_t addr; /*!< Device address of the Proxy Server */
esp_ble_mesh_addr_type_t addr_type; /*!< Device address type */
uint8_t conn_handle; /*!< Proxy connection handle */
uint16_t net_idx; /*!< Corresponding NetKey Index */
} proxy_client_connected; /*!< Event parameter of ESP_BLE_MESH_PROXY_CLIENT_CONNECTED_EVT */
@ -1105,8 +1105,8 @@ typedef union {
* @brief ESP_BLE_MESH_PROXY_CLIENT_DISCONNECTED_EVT
*/
struct ble_mesh_proxy_client_disconnected_param {
esp_bd_addr_t addr; /*!< Device address of the Proxy Server */
esp_ble_addr_type_t addr_type; /*!< Device address type */
esp_ble_mesh_bd_addr_t addr; /*!< Device address of the Proxy Server */
esp_ble_mesh_addr_type_t addr_type; /*!< Device address type */
uint8_t conn_handle; /*!< Proxy connection handle */
uint16_t net_idx; /*!< Corresponding NetKey Index */
uint8_t reason; /*!< Proxy disconnect reason */
@ -1126,8 +1126,8 @@ typedef union {
*/
struct ble_mesh_proxy_client_connect_comp_param {
int err_code; /*!< Indicate the result of Proxy Client connect */
esp_bd_addr_t addr; /*!< Device address of the Proxy Server */
esp_ble_addr_type_t addr_type; /*!< Device address type */
esp_ble_mesh_bd_addr_t addr; /*!< Device address of the Proxy Server */
esp_ble_mesh_addr_type_t addr_type; /*!< Device address type */
uint16_t net_idx; /*!< Corresponding NetKey Index */
} proxy_client_connect_comp; /*!< Event parameter of ESP_BLE_MESH_PROXY_CLIENT_CONNECT_COMP_EVT */
/**

View file

@ -73,7 +73,7 @@ esp_err_t esp_ble_mesh_generic_client_set_state(esp_ble_mesh_client_common_param
esp_err_t esp_ble_mesh_register_generic_server_callback(esp_ble_mesh_generic_server_cb_t callback)
{
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
return (btc_profile_cb_set(BTC_PID_GENERIC_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
}

View file

@ -73,7 +73,7 @@ esp_err_t esp_ble_mesh_light_client_set_state(esp_ble_mesh_client_common_param_t
esp_err_t esp_ble_mesh_register_lighting_server_callback(esp_ble_mesh_lighting_server_cb_t callback)
{
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
return (btc_profile_cb_set(BTC_PID_LIGHTING_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
}

View file

@ -73,7 +73,7 @@ esp_err_t esp_ble_mesh_sensor_client_set_state(esp_ble_mesh_client_common_param_
esp_err_t esp_ble_mesh_register_sensor_server_callback(esp_ble_mesh_sensor_server_cb_t callback)
{
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
return (btc_profile_cb_set(BTC_PID_SENSOR_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
}

View file

@ -73,7 +73,7 @@ esp_err_t esp_ble_mesh_time_scene_client_set_state(esp_ble_mesh_client_common_pa
esp_err_t esp_ble_mesh_register_time_scene_server_callback(esp_ble_mesh_time_scene_server_cb_t callback)
{
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
return (btc_profile_cb_set(BTC_PID_TIME_SCENE_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
}

View file

@ -847,7 +847,7 @@ static void btc_ble_mesh_proxy_client_adv_recv_cb(const bt_mesh_addr_t *addr,
LOG_DEBUG("%s", __func__);
mesh_param.proxy_client_recv_adv_pkt.addr_type = addr->type;
memcpy(mesh_param.proxy_client_recv_adv_pkt.addr, addr->val, ESP_BD_ADDR_LEN);
memcpy(mesh_param.proxy_client_recv_adv_pkt.addr, addr->val, BD_ADDR_LEN);
mesh_param.proxy_client_recv_adv_pkt.net_idx = ctx->net_id.net_idx;
memcpy(mesh_param.proxy_client_recv_adv_pkt.net_id, ctx->net_id.net_id, 8);
@ -868,7 +868,7 @@ static void btc_ble_mesh_proxy_client_connect_cb(const bt_mesh_addr_t *addr,
LOG_DEBUG("%s", __func__);
mesh_param.proxy_client_connected.addr_type = addr->type;
memcpy(mesh_param.proxy_client_connected.addr, addr->val, ESP_BD_ADDR_LEN);
memcpy(mesh_param.proxy_client_connected.addr, addr->val, BD_ADDR_LEN);
mesh_param.proxy_client_connected.conn_handle = conn_handle;
mesh_param.proxy_client_connected.net_idx = net_idx;
@ -889,7 +889,7 @@ static void btc_ble_mesh_proxy_client_disconnect_cb(const bt_mesh_addr_t *addr,
LOG_DEBUG("%s", __func__);
mesh_param.proxy_client_disconnected.addr_type = addr->type;
memcpy(mesh_param.proxy_client_disconnected.addr, addr->val, ESP_BD_ADDR_LEN);
memcpy(mesh_param.proxy_client_disconnected.addr, addr->val, BD_ADDR_LEN);
mesh_param.proxy_client_disconnected.conn_handle = conn_handle;
mesh_param.proxy_client_disconnected.net_idx = net_idx;
mesh_param.proxy_client_disconnected.reason = reason;
@ -1752,7 +1752,7 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg)
#if CONFIG_BLE_MESH_GATT_PROXY_CLIENT
case BTC_BLE_MESH_ACT_PROXY_CLIENT_CONNECT:
act = ESP_BLE_MESH_PROXY_CLIENT_CONNECT_COMP_EVT;
memcpy(param.proxy_client_connect_comp.addr, arg->proxy_client_connect.addr, ESP_BD_ADDR_LEN);
memcpy(param.proxy_client_connect_comp.addr, arg->proxy_client_connect.addr, BD_ADDR_LEN);
param.proxy_client_connect_comp.addr_type = arg->proxy_client_connect.addr_type;
param.proxy_client_connect_comp.net_idx = arg->proxy_client_connect.net_idx;
param.proxy_client_connect_comp.err_code =

View file

@ -128,12 +128,12 @@ void bt_mesh_hci_init(void)
}
static struct ble_gap_disc_params scan_param;
#if defined(CONFIG_BLE_MESH_PROVISIONER) && CONFIG_BLE_MESH_PROVISIONER
#if (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || \
CONFIG_BLE_MESH_GATT_PROXY_CLIENT
static struct gattc_prov_info {
/* Service to be found depends on the type of adv pkt received */
struct bt_mesh_conn conn;
BD_ADDR addr;
u8_t addr_type;
bt_mesh_addr_t addr;
u16_t service_uuid;
u16_t mtu;
bool wr_desc_done; /* Indicate if write char descriptor event is received */
@ -175,7 +175,7 @@ static int ble_on_subscribe(uint16_t conn_handle,
if (bt_mesh_gattc_info[i].service_uuid == BLE_MESH_UUID_MESH_PROV_VAL) {
if (bt_mesh_gattc_conn_cb != NULL && bt_mesh_gattc_conn_cb->prov_write_descr != NULL) {
len = bt_mesh_gattc_conn_cb->prov_write_descr(&bt_mesh_gattc_info[i].conn, bt_mesh_gattc_info[i].addr);
len = bt_mesh_gattc_conn_cb->prov_write_descr(&bt_mesh_gattc_info[i].addr, &bt_mesh_gattc_info[i].conn);
if (len < 0) {
BT_ERR("%s, prov_write_descr failed", __func__);
bt_mesh_gattc_disconnect(conn);
@ -185,12 +185,13 @@ static int ble_on_subscribe(uint16_t conn_handle,
}
} else if (bt_mesh_gattc_info[i].service_uuid == BLE_MESH_UUID_MESH_PROXY_VAL) {
if (bt_mesh_gattc_conn_cb != NULL && bt_mesh_gattc_conn_cb->proxy_write_descr != NULL) {
len = bt_mesh_gattc_conn_cb->proxy_write_descr(&bt_mesh_gattc_info[i].conn);
len = bt_mesh_gattc_conn_cb->proxy_write_descr(&bt_mesh_gattc_info[i].addr, &bt_mesh_gattc_info[i].conn);
if (len < 0) {
BT_ERR("%s, proxy_write_descr failed", __func__);
bt_mesh_gattc_disconnect(conn);
return 0;
}
bt_mesh_gattc_info[i].wr_desc_done = true;
}
}
@ -370,13 +371,14 @@ static int svc_disced(uint16_t conn_handle, const struct ble_gatt_error *error,
}
#endif /* defined(CONFIG_BLE_MESH_PROVISIONER) && CONFIG_BLE_MESH_PROVISIONER */
#endif /* (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || CONFIG_BLE_MESH_GATT_PROXY_CLIENT */
static int disc_cb(struct ble_gap_event *event, void *arg)
{
struct ble_gap_disc_desc *desc;
#if defined(CONFIG_BLE_MESH_PROVISIONER) && CONFIG_BLE_MESH_PROVISIONER
#if (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || \
CONFIG_BLE_MESH_GATT_PROXY_CLIENT
int rc, i;
uint8_t notif_data[100];
uint16_t notif_len;
@ -401,7 +403,8 @@ static int disc_cb(struct ble_gap_event *event, void *arg)
}
osi_free(buf);
break;
#if defined(CONFIG_BLE_MESH_PROVISIONER) && CONFIG_BLE_MESH_PROVISIONER
#if (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || \
CONFIG_BLE_MESH_GATT_PROXY_CLIENT
case BLE_GAP_EVENT_CONNECT:
if (event->connect.status == 0) {
/* Connection successfully established. */
@ -412,9 +415,9 @@ static int disc_cb(struct ble_gap_event *event, void *arg)
if (bt_mesh_gattc_conn_cb != NULL && bt_mesh_gattc_conn_cb->connected != NULL) {
for (i = 0; i < ARRAY_SIZE(bt_mesh_gattc_info); i++) {
if (!memcmp(bt_mesh_gattc_info[i].addr, conn_desc.peer_id_addr.val, BLE_MESH_ADDR_LEN)) {
if (!memcmp(bt_mesh_gattc_info[i].addr.val, conn_desc.peer_id_addr.val, BLE_MESH_ADDR_LEN)) {
bt_mesh_gattc_info[i].conn.handle = event->connect.conn_handle;
(bt_mesh_gattc_conn_cb->connected)(bt_mesh_gattc_info[i].addr, &bt_mesh_gattc_info[i].conn, i);
(bt_mesh_gattc_conn_cb->connected)(&bt_mesh_gattc_info[i].addr, &bt_mesh_gattc_info[i].conn, i);
break;
}
}
@ -441,24 +444,36 @@ static int disc_cb(struct ble_gap_event *event, void *arg)
if (bt_mesh_gattc_conn_cb != NULL && bt_mesh_gattc_conn_cb->disconnected != NULL) {
for (i = 0; i < ARRAY_SIZE(bt_mesh_gattc_info); i++) {
memcpy(&conn_desc, &event->disconnect.conn, sizeof(conn_desc));
if (!memcmp(bt_mesh_gattc_info[i].addr, conn_desc.peer_ota_addr.val, BLE_MESH_ADDR_LEN)) {
if (!memcmp(bt_mesh_gattc_info[i].addr.val, conn_desc.peer_ota_addr.val, BLE_MESH_ADDR_LEN)) {
if (bt_mesh_gattc_info[i].conn.handle == event->disconnect.conn.conn_handle) {
(bt_mesh_gattc_conn_cb->disconnected)(&bt_mesh_gattc_info[i].conn, event->disconnect.reason);
(bt_mesh_gattc_conn_cb->disconnected)(&bt_mesh_gattc_info[i].addr, &bt_mesh_gattc_info[i].conn, event->disconnect.reason);
if (!bt_mesh_gattc_info[i].wr_desc_done) {
/* Add this in case connection is established, connected event comes, but
* connection is terminated before server->filter_type is set to PROV.
*/
provisioner_clear_link_conn_info(bt_mesh_gattc_info[i].addr);
#if CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT
if (bt_mesh_gattc_info[i].service_uuid == BLE_MESH_UUID_MESH_PROV_VAL) {
provisioner_clear_link_conn_info(bt_mesh_gattc_info[i].addr.val);
}
#endif
}
} else {
/* Add this in case connection is failed to be established, and here we
* need to clear some provision link info, like connecting flag, device
* uuid, address info, etc.
*/
provisioner_clear_link_conn_info(bt_mesh_gattc_info[i].addr);
#if CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT
if (bt_mesh_gattc_info[i].service_uuid == BLE_MESH_UUID_MESH_PROV_VAL) {
provisioner_clear_link_conn_info(bt_mesh_gattc_info[i].addr.val);
}
#endif
}
/* Decrease prov pbg_count */
provisioner_pbg_count_dec();
#if CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT
if (bt_mesh_gattc_info[i].service_uuid == BLE_MESH_UUID_MESH_PROV_VAL) {
/* Decrease prov pbg_count */
provisioner_pbg_count_dec();
}
#endif
/* Reset corresponding gattc info */
memset(&bt_mesh_gattc_info[i], 0, sizeof(bt_mesh_gattc_info[i]));
bt_mesh_gattc_info[i].conn.handle = 0xFFFF;
@ -515,7 +530,7 @@ static int disc_cb(struct ble_gap_event *event, void *arg)
return 0;
}
if (memcmp(bt_mesh_gattc_info[i].addr, conn_desc.peer_id_addr.val, BLE_MESH_ADDR_LEN) ||
if (memcmp(bt_mesh_gattc_info[i].addr.val, conn_desc.peer_id_addr.val, BLE_MESH_ADDR_LEN) ||
(bt_mesh_gattc_info[i].data_out_handle != event->notify_rx.attr_handle) ||
(event->notify_rx.indication != 0)) {
BT_ERR("%s, Notification error", __func__);
@ -1186,12 +1201,28 @@ int bt_mesh_gatts_service_start(struct bt_mesh_gatt_service *svc)
}
#endif /* defined(CONFIG_BLE_MESH_NODE) && CONFIG_BLE_MESH_NODE */
#if defined(CONFIG_BLE_MESH_PROVISIONER) && CONFIG_BLE_MESH_PROVISIONER
#if (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || \
CONFIG_BLE_MESH_GATT_PROXY_CLIENT
void bt_mesh_gattc_conn_cb_register(struct bt_mesh_prov_conn_cb *cb)
{
bt_mesh_gattc_conn_cb = cb;
}
u8_t bt_mesh_gattc_get_free_conn_count(void)
{
u8_t count = 0;
u8_t i;
for (i = 0U; i < ARRAY_SIZE(bt_mesh_gattc_info); i++) {
if (bt_mesh_gattc_info[i].conn.handle == 0xFFFF &&
bt_mesh_gattc_info[i].service_uuid == 0x0000) {
++count;
}
}
return count;
}
u16_t bt_mesh_gattc_get_service_uuid(struct bt_mesh_conn *conn)
{
int i;
@ -1238,7 +1269,7 @@ int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, u16_t service_uuid)
/* Check if already creating connection with the device */
for (i = 0; i < ARRAY_SIZE(bt_mesh_gattc_info); i++) {
if (!memcmp(bt_mesh_gattc_info[i].addr, addr->val, BLE_MESH_ADDR_LEN)) {
if (!memcmp(bt_mesh_gattc_info[i].addr.val, addr->val, BLE_MESH_ADDR_LEN)) {
BT_WARN("%s, Already create connection with %s",
__func__, bt_hex(addr->val, BLE_MESH_ADDR_LEN));
return -EALREADY;
@ -1249,8 +1280,8 @@ int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, u16_t service_uuid)
for (i = 0; i < ARRAY_SIZE(bt_mesh_gattc_info); i++) {
if ((bt_mesh_gattc_info[i].conn.handle == 0xFFFF) &&
(bt_mesh_gattc_info[i].service_uuid == 0x0000)) {
memcpy(bt_mesh_gattc_info[i].addr, addr->val, BLE_MESH_ADDR_LEN);
bt_mesh_gattc_info[i].addr_type = addr->type;
memcpy(bt_mesh_gattc_info[i].addr.val, addr->val, BLE_MESH_ADDR_LEN);
bt_mesh_gattc_info[i].addr.type = addr->type;
/* Service to be found after exhanging mtu size */
bt_mesh_gattc_info[i].service_uuid = service_uuid;
break;
@ -1300,10 +1331,8 @@ int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, u16_t service_uuid)
rc = ble_gap_connect(BLE_OWN_ADDR_PUBLIC, &peer_addr, BLE_HS_FOREVER, &conn_params,
disc_cb, NULL);
/* Increment pbg_count */
provisioner_pbg_count_inc();
return 0;
return i;
}
static int mtu_cb(uint16_t conn_handle,
@ -1417,7 +1446,7 @@ void bt_mesh_gattc_disconnect(struct bt_mesh_conn *conn)
* Mesh Proxy Data In: 0x2ADD
* Mesh PROXY Data Out: 0x2ADE
*/
#endif /* defined(CONFIG_BLE_MESH_PROVISIONER) && CONFIG_BLE_MESH_PROVISIONER */
#endif /* (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || CONFIG_BLE_MESH_GATT_PROXY_CLIENT */
struct bt_mesh_conn *bt_mesh_conn_ref(struct bt_mesh_conn *conn)
{
@ -1551,7 +1580,8 @@ void bt_mesh_gatt_init(void)
ble_gatts_svc_set_visibility(proxy_svc_start_handle, 0);
#endif
#if CONFIG_BLE_MESH_PROVISIONER
#if (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || \
CONFIG_BLE_MESH_GATT_PROXY_CLIENT
for (int i = 0; i < ARRAY_SIZE(bt_mesh_gattc_info); i++) {
bt_mesh_gattc_info[i].conn.handle = 0xFFFF;
bt_mesh_gattc_info[i].mtu = BLE_ATT_MTU_DFLT;