mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
ble_mesh: fix ble mesh device with wrong name on iOS
This commit is contained in:
parent
e380c59c74
commit
093cc494b9
@ -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) || \
|
||||
|
@ -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);
|
||||
|
@ -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) || \
|
||||
|
@ -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 */
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user