From 7a73f9928680eb86d3b398615a652c486349df32 Mon Sep 17 00:00:00 2001 From: schneider <schneider@blinkenlichts.net> Date: Tue, 13 Oct 2020 00:50:27 +0200 Subject: [PATCH] feat(ble): Read device name from peer --- epicardium/ble/ble_attc.c | 2 ++ epicardium/ble/profiles/gap_api.h | 1 + epicardium/ble/profiles/gap_main.c | 21 +++++++++++++++++++-- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/epicardium/ble/ble_attc.c b/epicardium/ble/ble_attc.c index ea4c69de..e9e29053 100644 --- a/epicardium/ble/ble_attc.c +++ b/epicardium/ble/ble_attc.c @@ -73,6 +73,8 @@ static const attcDiscCfg_t bleDiscCfgList[] = /* Write: GATT service changed ccc descriptor */ {bleGattScCccVal, sizeof(bleGattScCccVal), (GATT_SC_CCC_HDL_IDX + BLE_DISC_GATT_START)}, + {NULL, 0, (GAP_DN_HDL_IDX + BLE_DISC_GAP_START)}, + /* Read: GAP central address resolution attribute */ {NULL, 0, (GAP_CAR_HDL_IDX + BLE_DISC_GAP_START)}, diff --git a/epicardium/ble/profiles/gap_api.h b/epicardium/ble/profiles/gap_api.h index b1838162..912e9759 100644 --- a/epicardium/ble/profiles/gap_api.h +++ b/epicardium/ble/profiles/gap_api.h @@ -35,6 +35,7 @@ extern "C" { /*! \brief Enumeration of handle indexes of characteristics to be discovered */ enum { + GAP_DN_HDL_IDX, GAP_CAR_HDL_IDX, /*!< \brief Central Address Resolution */ GAP_RPAO_HDL_IDX, /*!< \brief Resolvable Private Address Only */ GAP_HDL_LIST_LEN /*!< \brief Handle list length */ diff --git a/epicardium/ble/profiles/gap_main.c b/epicardium/ble/profiles/gap_main.c index baa16b94..d11aabe1 100644 --- a/epicardium/ble/profiles/gap_main.c +++ b/epicardium/ble/profiles/gap_main.c @@ -22,13 +22,24 @@ #include "wsf_trace.h" #include "app_db.h" #include "app_api.h" -#include "gap/gap_api.h" +#include "gap_api.h" + +/* card10: + * copied from lib/sdk/Libraries/BTLE/stack/ble-profiles/sources/profiles/gap/gap_main.c + */ +/* clang-format off */ +/* clang-formet turned off for easier diffing against orginal file */ /************************************************************************************************** Local Variables **************************************************************************************************/ /*! GAP service characteristics for discovery */ +static const attcDiscChar_t gapDn = +{ + attDnChUuid, + 0 +}; /*! Central Address Resolution */ static const attcDiscChar_t gapCar = @@ -47,6 +58,7 @@ static const attcDiscChar_t gapRpao = /*! List of characteristics to be discovered; order matches handle index enumeration */ static const attcDiscChar_t *gapDiscCharList[] = { + &gapDn, &gapCar, /* Central Address Resolution */ &gapRpao /* Resolvable Private Address Only */ }; @@ -90,8 +102,12 @@ uint8_t GapValueUpdate(uint16_t *pHdlList, attEvt_t *pMsg) { uint8_t status = ATT_SUCCESS; + /* device name string */ + if (pMsg->handle == pHdlList[GAP_DN_HDL_IDX]) + { + } /* Central Address Resolution */ - if (pMsg->handle == pHdlList[GAP_CAR_HDL_IDX]) + else if (pMsg->handle == pHdlList[GAP_CAR_HDL_IDX]) { appDbHdl_t dbHdl; @@ -120,3 +136,4 @@ uint8_t GapValueUpdate(uint16_t *pHdlList, attEvt_t *pMsg) return status; } +/* clang-format on */ -- GitLab