Merge branch 'bugfix/ble_mesh_device_with_wrong_name_on_ios' into 'master'

ble_mesh: fix ble mesh device with wrong name on iOS

Closes BLEMESH-54

See merge request espressif/esp-idf!6516
This commit is contained in:
Jiang Jiang Jian 2019-11-27 10:30:25 +08:00
commit e349f86d18
5 changed files with 36 additions and 3 deletions

View file

@ -1011,6 +1011,14 @@ int bt_mesh_gatts_service_start(struct bt_mesh_gatt_service *svc)
return 0;
}
int bt_mesh_gatts_set_local_device_name(const char *name)
{
BLE_MESH_BTM_CHECK_STATUS(BTM_SetLocalDeviceName((char *)name));
return 0;
}
#endif /* defined(CONFIG_BLE_MESH_NODE) && CONFIG_BLE_MESH_NODE */
#if (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || \

View file

@ -34,6 +34,10 @@
#endif
#define BLE_MESH_GAP_ADV_MAX_LEN 31
#define BLE_MESH_GATT_DEF_MTU_SIZE 23
/* BD ADDR types */
#define BLE_MESH_ADDR_PUBLIC 0x00
#define BLE_MESH_ADDR_RANDOM 0x01
@ -681,6 +685,8 @@ u16_t bt_mesh_gatt_get_mtu(struct bt_mesh_conn *conn);
int bt_mesh_gatts_service_stop(struct bt_mesh_gatt_service *svc);
int bt_mesh_gatts_service_start(struct bt_mesh_gatt_service *svc);
int bt_mesh_gatts_set_local_device_name(const char *name);
void bt_mesh_gattc_conn_cb_register(struct bt_mesh_prov_conn_cb *cb);
u8_t bt_mesh_gattc_get_free_conn_count(void);

View file

@ -1199,6 +1199,11 @@ int bt_mesh_gatts_service_start(struct bt_mesh_gatt_service *svc)
return 0;
}
int bt_mesh_gatts_set_local_device_name(const char *name)
{
return ble_svc_gap_device_name_set(name);
}
#endif /* defined(CONFIG_BLE_MESH_NODE) && CONFIG_BLE_MESH_NODE */
#if (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || \

View file

@ -130,7 +130,7 @@ int bt_mesh_set_device_name(const char *name)
memset(device_name, 0x0, sizeof(device_name));
memcpy(device_name, name, strlen(name));
return 0;
return bt_mesh_gatts_set_local_device_name(device_name);
}
static struct bt_mesh_proxy_client *find_client(struct bt_mesh_conn *conn)
@ -1417,7 +1417,7 @@ int bt_mesh_proxy_init(void)
__ASSERT(prov && prov->uuid, "%s, Device UUID is not initialized", __func__);
#endif
return 0;
return bt_mesh_gatts_set_local_device_name(device_name);
}
#endif /* CONFIG_BLE_MESH_NODE */

View file

@ -19,7 +19,21 @@
#define BLE_MESH_PROXY_CONFIG 0x02
#define BLE_MESH_PROXY_PROV 0x03
#define DEVICE_NAME_SIZE 29
#if CONFIG_BLE_MESH_PROXY
/**
* Device Name Characteristic:
* 1. For iOS, when it tries to get the value of Device Name Characteristic, the PDU
* "Read By Type Request" will be used, and the valid length of corresponding
* response is 19 (23 - 1 - 1 - 2).
* 2. For Android, when it tries to get the value of Device Name Characteristic, the
* PDU "Read Request" will be used, and the valid length of corresponding response
* is 22 (23 - 1).
*/
#define DEVICE_NAME_SIZE MIN((BLE_MESH_GATT_DEF_MTU_SIZE - 4), (BLE_MESH_GAP_ADV_MAX_LEN - 2))
#else
/* For Scan Response Data, the maximum length is 29 (31 - 1 - 1) currently. */
#define DEVICE_NAME_SIZE (BLE_MESH_GAP_ADV_MAX_LEN - 2)
#endif
int bt_mesh_set_device_name(const char *name);