mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-09-09 18:50:02 +00:00
nimble/gap: Add "Central Address Resolution" characteristic
This characteristics is mandatory for LE Central role if LL Privacy is supported. We could be smarter in registering it by checking controller features, but this is quite complex to implement due to the way everything is set up so let's leave proper configuration for user :) X-Original-Commit: 4934ddf4afc889c0aaa932734d5bf361eb4dc042
This commit is contained in:
@@ -28,6 +28,7 @@ extern "C" {
|
||||
#define BLE_SVC_GAP_CHR_UUID16_DEVICE_NAME 0x2a00
|
||||
#define BLE_SVC_GAP_CHR_UUID16_APPEARANCE 0x2a01
|
||||
#define BLE_SVC_GAP_CHR_UUID16_PERIPH_PREF_CONN_PARAMS 0x2a04
|
||||
#define BLE_SVC_GAP_CHR_UUID16_CENTRAL_ADDRESS_RESOLUTION 0x2aa6
|
||||
|
||||
#define BLE_SVC_GAP_APPEARANCE_GEN_UNKNOWN 0
|
||||
#define BLE_SVC_GAP_APPEARANCE_GEN_COMPUTER 128
|
||||
|
||||
@@ -61,6 +61,13 @@ static const struct ble_gatt_svc_def ble_svc_gap_defs[] = {
|
||||
.access_cb = ble_svc_gap_access,
|
||||
.flags = BLE_GATT_CHR_F_READ,
|
||||
}, {
|
||||
#if MYNEWT_VAL(BLE_SVC_GAP_CENTRAL_ADDRESS_RESOLUTION) >= 0
|
||||
/*** Characteristic: Central Address Resolution. */
|
||||
.uuid = BLE_UUID16_DECLARE(BLE_SVC_GAP_CHR_UUID16_CENTRAL_ADDRESS_RESOLUTION),
|
||||
.access_cb = ble_svc_gap_access,
|
||||
.flags = BLE_GATT_CHR_F_READ,
|
||||
}, {
|
||||
#endif
|
||||
0, /* No more characteristics in this service. */
|
||||
} },
|
||||
},
|
||||
@@ -75,6 +82,9 @@ ble_svc_gap_access(uint16_t conn_handle, uint16_t attr_handle,
|
||||
struct ble_gatt_access_ctxt *ctxt, void *arg)
|
||||
{
|
||||
uint16_t uuid16;
|
||||
#if MYNEWT_VAL(BLE_SVC_GAP_CENTRAL_ADDRESS_RESOLUTION) >= 0
|
||||
uint8_t central_ar = MYNEWT_VAL(BLE_SVC_GAP_CENTRAL_ADDRESS_RESOLUTION);
|
||||
#endif
|
||||
int rc;
|
||||
|
||||
uuid16 = ble_uuid_u16(ctxt->chr->uuid);
|
||||
@@ -99,6 +109,13 @@ ble_svc_gap_access(uint16_t conn_handle, uint16_t attr_handle,
|
||||
sizeof ble_svc_gap_pref_conn_params);
|
||||
return rc == 0 ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES;
|
||||
|
||||
#if MYNEWT_VAL(BLE_SVC_GAP_CENTRAL_ADDRESS_RESOLUTION) >= 0
|
||||
case BLE_SVC_GAP_CHR_UUID16_CENTRAL_ADDRESS_RESOLUTION:
|
||||
assert(ctxt->op == BLE_GATT_ACCESS_OP_READ_CHR);
|
||||
rc = os_mbuf_append(ctxt->om, ¢ral_ar, sizeof(central_ar));
|
||||
return rc == 0 ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES;
|
||||
#endif
|
||||
|
||||
default:
|
||||
assert(0);
|
||||
return BLE_ATT_ERR_UNLIKELY;
|
||||
|
||||
@@ -22,3 +22,9 @@ syscfg.defs:
|
||||
BLE_SVC_GAP_APPEARANCE:
|
||||
description: 'Device appearance'
|
||||
value: 0
|
||||
BLE_SVC_GAP_CENTRAL_ADDRESS_RESOLUTION:
|
||||
description: >
|
||||
Value of "Central Address Resolution" characteristics, as defined
|
||||
by Core specification 5.0, Vol 3, Part C, section 12.
|
||||
Set to '-1' to disable.
|
||||
value: -1
|
||||
|
||||
Reference in New Issue
Block a user