25#include "nimble/porting/nimble/include/os/os_mbuf.h"
34} __attribute__((packed));
44#define BLE_ATT_ERROR_RSP_SZ 5
45struct ble_att_error_rsp {
48 uint8_t baep_error_code;
49} __attribute__((packed));
57#define BLE_ATT_MTU_CMD_SZ 3
58struct ble_att_mtu_cmd {
60} __attribute__((packed));
69#define BLE_ATT_FIND_INFO_REQ_SZ 5
70struct ble_att_find_info_req {
71 uint16_t bafq_start_handle;
72 uint16_t bafq_end_handle;
73} __attribute__((packed));
82#define BLE_ATT_FIND_INFO_RSP_BASE_SZ 2
83struct ble_att_find_info_rsp {
86} __attribute__((packed));
88#define BLE_ATT_FIND_INFO_RSP_FORMAT_16BIT 1
89#define BLE_ATT_FIND_INFO_RSP_FORMAT_128BIT 2
91#define BLE_ATT_FIND_INFO_IDATA_16_SZ 4
92#define BLE_ATT_FIND_INFO_IDATA_128_SZ 18
103#define BLE_ATT_FIND_TYPE_VALUE_REQ_BASE_SZ 7
104struct ble_att_find_type_value_req {
105 uint16_t bavq_start_handle;
106 uint16_t bavq_end_handle;
107 uint16_t bavq_attr_type;
108 uint16_t bavq_value[0];
109} __attribute__((packed));
117#define BLE_ATT_FIND_TYPE_VALUE_RSP_BASE_SZ 1
118#define BLE_ATT_FIND_TYPE_VALUE_HINFO_BASE_SZ 4
120struct ble_att_handle_group {
121 uint16_t attr_handle;
122 uint16_t group_end_handle;
123} __attribute__((packed));
125struct ble_att_find_type_value_rsp {
126 struct ble_att_handle_group list[0];
127} __attribute__((packed));
137#define BLE_ATT_READ_TYPE_REQ_BASE_SZ 5
138#define BLE_ATT_READ_TYPE_REQ_SZ_16 7
139#define BLE_ATT_READ_TYPE_REQ_SZ_128 21
140struct ble_att_read_type_req {
141 uint16_t batq_start_handle;
142 uint16_t batq_end_handle;
144} __attribute__((packed));
153#define BLE_ATT_READ_TYPE_RSP_BASE_SZ 2
155struct ble_att_attr_data_list {
158} __attribute__((packed));
160struct ble_att_read_type_rsp {
162 struct ble_att_attr_data_list batp_list[0];
163} __attribute__((packed));
165#define BLE_ATT_READ_TYPE_ADATA_BASE_SZ 2
166#define BLE_ATT_READ_TYPE_ADATA_SZ_16 6
167#define BLE_ATT_READ_TYPE_ADATA_SZ_128 20
175#define BLE_ATT_READ_REQ_SZ 3
176struct ble_att_read_req {
177 uint16_t barq_handle;
178} __attribute__((packed));
186#define BLE_ATT_READ_RSP_BASE_SZ 1
195#define BLE_ATT_READ_BLOB_REQ_SZ 5
196struct ble_att_read_blob_req {
197 uint16_t babq_handle;
198 uint16_t babq_offset;
199} __attribute__((packed));
207#define BLE_ATT_READ_BLOB_RSP_BASE_SZ 1
215#define BLE_ATT_READ_MULT_REQ_BASE_SZ 1
216struct ble_att_read_mult_req {
218} __attribute__((packed));
226#define BLE_ATT_READ_MULT_RSP_BASE_SZ 1
236#define BLE_ATT_READ_GROUP_TYPE_REQ_BASE_SZ 5
237#define BLE_ATT_READ_GROUP_TYPE_REQ_SZ_16 7
238#define BLE_ATT_READ_GROUP_TYPE_REQ_SZ_128 21
239struct ble_att_read_group_type_req {
240 uint16_t bagq_start_handle;
241 uint16_t bagq_end_handle;
243} __attribute__((packed));
252#define BLE_ATT_READ_GROUP_TYPE_RSP_BASE_SZ 2
253struct ble_att_read_group_type_rsp {
255} __attribute__((packed));
257#define BLE_ATT_READ_GROUP_TYPE_ADATA_BASE_SZ 4
258#define BLE_ATT_READ_GROUP_TYPE_ADATA_SZ_16 6
259#define BLE_ATT_READ_GROUP_TYPE_ADATA_SZ_128 20
268#define BLE_ATT_WRITE_REQ_BASE_SZ 3
269struct ble_att_write_req {
270 uint16_t bawq_handle;
272} __attribute__((packed));
274#define BLE_ATT_WRITE_RSP_SZ 1
284#define BLE_ATT_PREP_WRITE_CMD_BASE_SZ 5
285struct ble_att_prep_write_cmd {
286 uint16_t bapc_handle;
287 uint16_t bapc_offset;
288 uint16_t bapc_value[0];
289} __attribute__((packed));
297#define BLE_ATT_EXEC_WRITE_REQ_SZ 2
298struct ble_att_exec_write_req {
300} __attribute__((packed));
302#define BLE_ATT_EXEC_WRITE_F_CANCEL 0x00
303#define BLE_ATT_EXEC_WRITE_F_EXECUTE 0x01
310#define BLE_ATT_EXEC_WRITE_RSP_SZ 1
319#define BLE_ATT_NOTIFY_REQ_BASE_SZ 3
320struct ble_att_notify_req {
321 uint16_t banq_handle;
322} __attribute__((packed));
331#define BLE_ATT_INDICATE_REQ_BASE_SZ 3
332struct ble_att_indicate_req {
333 uint16_t baiq_handle;
334} __attribute__((packed));
341#define BLE_ATT_INDICATE_RSP_SZ 1
350#define BLE_ATT_WRITE_CMD_BASE_SZ 3
351struct ble_att_write_cmd {
354} __attribute__((packed));
364#define BLE_ATT_SIGNED_WRITE_CMD_BASE_SZ 15
365#define BLE_ATT_SIGNED_WRITE_DATA_OFFSET 3
366struct ble_att_signed_write_cmd {
368} __attribute__((packed));
370void ble_att_error_rsp_parse(
const void *payload,
int len,
371 struct ble_att_error_rsp *rsp);
372void ble_att_error_rsp_write(
void *payload,
int len,
373 const struct ble_att_error_rsp *rsp);
374void ble_att_mtu_req_parse(
const void *payload,
int len,
375 struct ble_att_mtu_cmd *cmd);
376void ble_att_mtu_req_write(
void *payload,
int len,
377 const struct ble_att_mtu_cmd *cmd);
378void ble_att_mtu_rsp_parse(
const void *payload,
int len,
379 struct ble_att_mtu_cmd *cmd);
380void ble_att_mtu_rsp_write(
void *payload,
int len,
381 const struct ble_att_mtu_cmd *cmd);
382void ble_att_find_info_req_parse(
const void *payload,
int len,
383 struct ble_att_find_info_req *req);
384void ble_att_find_info_req_write(
void *payload,
int len,
385 const struct ble_att_find_info_req *req);
386void ble_att_find_info_rsp_parse(
const void *payload,
int len,
387 struct ble_att_find_info_rsp *rsp);
388void ble_att_find_info_rsp_write(
void *payload,
int len,
389 const struct ble_att_find_info_rsp *rsp);
390void ble_att_find_type_value_req_parse(
391 const void *payload,
int len,
struct ble_att_find_type_value_req *req);
392void ble_att_find_type_value_req_write(
393 void *payload,
int len,
const struct ble_att_find_type_value_req *req);
394void ble_att_read_type_req_parse(
const void *payload,
int len,
395 struct ble_att_read_type_req *req);
396void ble_att_read_type_req_write(
void *payload,
int len,
397 const struct ble_att_read_type_req *req);
398void ble_att_read_type_rsp_parse(
const void *payload,
int len,
399 struct ble_att_read_type_rsp *rsp);
400void ble_att_read_type_rsp_write(
void *payload,
int len,
401 const struct ble_att_read_type_rsp *rsp);
402void ble_att_read_req_parse(
const void *payload,
int len,
403 struct ble_att_read_req *req);
404void ble_att_read_req_write(
void *payload,
int len,
405 const struct ble_att_read_req *req);
406void ble_att_read_blob_req_parse(
const void *payload,
int len,
407 struct ble_att_read_blob_req *req);
408void ble_att_read_blob_req_write(
void *payload,
int len,
409 const struct ble_att_read_blob_req *req);
410void ble_att_read_mult_req_parse(
const void *payload,
int len);
411void ble_att_read_mult_req_write(
void *payload,
int len);
412void ble_att_read_mult_rsp_parse(
const void *payload,
int len);
413void ble_att_read_mult_rsp_write(
void *payload,
int len);
414void ble_att_read_group_type_req_parse(
415 const void *payload,
int len,
struct ble_att_read_group_type_req *req);
416void ble_att_read_group_type_req_write(
417 void *payload,
int len,
const struct ble_att_read_group_type_req *req);
418void ble_att_read_group_type_rsp_parse(
419 const void *payload,
int len,
struct ble_att_read_group_type_rsp *rsp);
420void ble_att_read_group_type_rsp_write(
421 void *payload,
int len,
const struct ble_att_read_group_type_rsp *rsp);
422void ble_att_write_req_parse(
const void *payload,
int len,
423 struct ble_att_write_req *req);
424void ble_att_write_req_write(
void *payload,
int len,
425 const struct ble_att_write_req *req);
426void ble_att_write_cmd_parse(
const void *payload,
int len,
427 struct ble_att_write_req *req);
428void ble_att_write_cmd_write(
void *payload,
int len,
429 const struct ble_att_write_req *req);
430void ble_att_prep_write_req_parse(
const void *payload,
int len,
431 struct ble_att_prep_write_cmd *cmd);
432void ble_att_prep_write_req_write(
void *payload,
int len,
433 const struct ble_att_prep_write_cmd *cmd);
434void ble_att_prep_write_rsp_parse(
const void *payload,
int len,
435 struct ble_att_prep_write_cmd *cmd);
436void ble_att_prep_write_rsp_write(
void *payload,
int len,
437 const struct ble_att_prep_write_cmd *cmd);
438void ble_att_exec_write_req_parse(
const void *payload,
int len,
439 struct ble_att_exec_write_req *req);
440void ble_att_exec_write_req_write(
void *payload,
int len,
441 const struct ble_att_exec_write_req *req);
442void ble_att_exec_write_rsp_parse(
const void *payload,
int len);
443void ble_att_exec_write_rsp_write(
void *payload,
int len);
444void ble_att_notify_req_parse(
const void *payload,
int len,
445 struct ble_att_notify_req *req);
446void ble_att_notify_req_write(
void *payload,
int len,
447 const struct ble_att_notify_req *req);
448void ble_att_indicate_req_parse(
const void *payload,
int len,
449 struct ble_att_indicate_req *req);
450void ble_att_indicate_req_write(
void *payload,
int len,
451 const struct ble_att_indicate_req *req);
452void ble_att_indicate_rsp_parse(
const void *payload,
int len);
453void ble_att_indicate_rsp_write(
void *payload,
int len);
455void *ble_att_cmd_prepare(uint8_t opcode,
size_t len,
struct os_mbuf *txom);
456void *ble_att_cmd_get(uint8_t opcode,
size_t len,
struct os_mbuf **txom);
457int ble_att_tx(uint16_t conn_handle,
struct os_mbuf *txom);