4#ifndef PROTOCORE_BLE_GATT_H
5#define PROTOCORE_BLE_GATT_H
35#define ATT_OP_ERROR_RSP 0x01
36#define ATT_OP_READ_REQ 0x0A
37#define ATT_OP_READ_RSP 0x0B
38#define ATT_OP_WRITE_REQ 0x12
39#define ATT_OP_WRITE_RSP 0x13
40#define ATT_OP_HANDLE_VALUE_NTF 0x1B
43#define GATT_PROP_READ 0x02
44#define GATT_PROP_WRITE_NR 0x04
45#define GATT_PROP_WRITE 0x08
46#define GATT_PROP_NOTIFY 0x10
47#define GATT_PROP_INDICATE 0x20
71 size_t (*att_read_req)(uint8_t *, uint16_t, uint8_t *, size_t);
72 size_t (*att_read_rsp)(uint8_t *,
const uint8_t *, size_t, uint8_t *, size_t);
73 size_t (*att_write_req)(uint8_t *, uint16_t,
const uint8_t *, size_t, uint8_t *, size_t);
74 size_t (*att_notify)(uint8_t *, uint16_t,
const uint8_t *, size_t, uint8_t *, size_t);
75 size_t (*att_error_rsp)(uint8_t *, uint8_t, uint16_t, uint8_t, uint8_t *, size_t);
77 size_t (*char_json)(uint8_t *,
const GattChar *, size_t,
char *, size_t);
size_t protocore_ble_gatt_char_json(uint8_t *work, const GattChar *chars, size_t n, char *out, size_t cap)
Serialize a characteristic table as .
size_t protocore_ble_gatt_att_error_rsp(uint8_t *work, uint8_t req_op, uint16_t handle, uint8_t error, uint8_t *out, size_t cap)
Build an Error Response: [0x01][req-op][handle:2 LE][error]. 5, or .
size_t protocore_ble_gatt_att_write_req(uint8_t *work, uint16_t handle, const uint8_t *val, size_t vlen, uint8_t *out, size_t cap)
Build a Write Request: [0x12][handle:2 LE][value...]. 3+vlen, or 0 .
proto_bool protocore_ble_gatt_att_parse(uint8_t *work, const uint8_t *pdu, size_t len, AttPdu *out)
Parse an ATT PDU into out. true if len >= 1 and the fixed fields fit.
size_t protocore_ble_gatt_att_read_rsp(uint8_t *work, const uint8_t *val, size_t vlen, uint8_t *out, size_t cap)
Build a Read Response: [0x0B][value...]. 1+vlen, or 0 on overflow.
PROTOCORE_NS BleGattNs BleGatt PROTOCORE_UNUSED
Module namespace.
size_t protocore_ble_gatt_att_notify(uint8_t *work, uint16_t handle, const uint8_t *val, size_t vlen, uint8_t *out, size_t cap)
Build a Handle Value Notification: [0x1B][handle:2 LE][value...]. .
size_t protocore_ble_gatt_att_read_req(uint8_t *work, uint16_t handle, uint8_t *out, size_t cap)
Build a Read Request: [0x0A][handle:2 LE]. 3, or 0 on overflow.
#define PROTOCORE_NS_LAYOUT(T,...)
Pin every dispatch slot of a table that is nothing but function pointers.
#define PROTOCORE_NS
Storage for a dispatch table. The const is load bearing.
A parsed ATT PDU (value points into the input).
uint16_t handle
set for opcodes that carry a handle (else 0).
const uint8_t * value
value payload (null if none).
uint8_t error
for ERROR_RSP: the error code.
uint8_t req_op
for ERROR_RSP: the failed request opcode.
Dispatch table. Addressed by offset, so the layout is asserted below.
size_t(* att_read_req)(uint8_t *, uint16_t, uint8_t *, size_t)
One GATT characteristic for the northbound bridge.
uint16_t uuid
16-bit UUID (assigned-number form).
uint8_t props
GATT_PROP_* bits.
#define PROTOCORE_BEGIN_DECLS
Give a header's declarations C linkage, so their symbol names carry no parameter types.
_Bool proto_bool
The truth value.
#define PROTOCORE_END_DECLS