Skip to content

Commit

Permalink
nimble/host: Add offset in GATT server long read context
Browse files Browse the repository at this point in the history
This allows application to easily determine if client is performing
GATT Long Read operation.
  • Loading branch information
vandy committed Aug 12, 2024
1 parent a908b5e commit 5c200fc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 6 additions & 0 deletions nimble/host/include/host/ble_gatt.h
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,12 @@ struct ble_gatt_access_ctxt {
*/
const struct ble_gatt_dsc_def *dsc;
};

/**
* An offset in case of BLE_ATT_OP_READ_BLOB_REQ.
* If the value is greater than zero it's an indication of a long attribute read.
*/
uint16_t offset;
};

/**
Expand Down
10 changes: 4 additions & 6 deletions nimble/host/src/ble_gatts.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,21 +407,19 @@ ble_gatts_chr_val_access(uint16_t conn_handle, uint16_t attr_handle,
uint8_t att_op, uint16_t offset,
struct os_mbuf **om, void *arg)
{
const struct ble_gatt_chr_def *chr_def;
struct ble_gatt_access_ctxt gatt_ctxt;
int rc;

chr_def = arg;
const struct ble_gatt_chr_def *chr_def = arg;
BLE_HS_DBG_ASSERT(chr_def != NULL && chr_def->access_cb != NULL);

gatt_ctxt.op = ble_gatts_chr_op(att_op);
gatt_ctxt.chr = chr_def;
gatt_ctxt.offset = offset;

ble_gatts_chr_inc_val_stat(gatt_ctxt.op);
rc = ble_gatts_val_access(conn_handle, attr_handle, offset, &gatt_ctxt, om,
chr_def->access_cb, chr_def->arg);

return rc;
return ble_gatts_val_access(conn_handle, attr_handle, offset, &gatt_ctxt, om,
chr_def->access_cb, chr_def->arg);
}

static int
Expand Down

0 comments on commit 5c200fc

Please sign in to comment.