drivers/nble: Add initial implementation of on_ble_gatts_read_evt

Change-Id: Ia749272a23d96318f477d41d46509dc64c6d474a
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
Luiz Augusto von Dentz 2016-02-03 15:34:07 +02:00 committed by Anas Nashif
commit db0c12eece
2 changed files with 35 additions and 0 deletions

View file

@ -432,3 +432,28 @@ void on_ble_gatts_send_notif_ind_rsp(const struct ble_gatt_notif_ind_rsp *par)
{ {
BT_DBG(""); 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);
}

View file

@ -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, void ble_gatt_register_req(const struct ble_gatt_register_req *par,
uint8_t *buf, uint16_t len); 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 * Conversion table entry ble_core to host attr index
* *