diff --git a/drivers/nble/gatt.c b/drivers/nble/gatt.c index 7a24c9c1d99..1a4f6c47980 100644 --- a/drivers/nble/gatt.c +++ b/drivers/nble/gatt.c @@ -432,3 +432,28 @@ void on_ble_gatts_send_notif_ind_rsp(const struct ble_gatt_notif_ind_rsp *par) { BT_DBG(""); } + +void on_ble_gatts_read_evt(const struct nble_gatt_rd_evt *evt) +{ + struct ble_gatts_rw_reply_params reply_data; + const struct bt_gatt_attr *attr; + /* TODO: Replace the following with net_buf */ + uint8_t data[NBLE_BUF_SIZE]; + + reply_data.status = -EACCES; + + attr = evt->attr; + + BT_DBG("read %p", attr); + + if (attr->read) { + reply_data.status = attr->read(NULL, attr, data, sizeof(data), + evt->offset); + } + + reply_data.conn_handle = evt->conn_handle; + reply_data.offset = evt->offset; + reply_data.write_reply = 0; + + nble_gatts_rw_authorize_reply_req(&reply_data, data, reply_data.status); +} diff --git a/drivers/nble/gatt_internal.h b/drivers/nble/gatt_internal.h index f350f62c968..bf6d359faca 100644 --- a/drivers/nble/gatt_internal.h +++ b/drivers/nble/gatt_internal.h @@ -322,6 +322,16 @@ void on_ble_gatts_send_svc_changed_rsp(const struct ble_core_response *par); void ble_gatt_register_req(const struct ble_gatt_register_req *par, uint8_t *buf, uint16_t len); +/** + * Reply to an authorize request. + * + * @param p_params parameters for the reply + * @param buf read value of the attribute + * @param buflen length of buf + */ +void nble_gatts_rw_authorize_reply_req(const struct ble_gatts_rw_reply_params *params, + uint8_t *buf, uint16_t buflen); + /** * Conversion table entry ble_core to host attr index *