NimBLE-Arduino 2.1.2
Loading...
Searching...
No Matches
ble_att_cmd_priv.h
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20#ifndef H_BLE_ATT_CMD_
21#define H_BLE_ATT_CMD_
22
23#include <inttypes.h>
24#include <stddef.h>
25#include "nimble/porting/nimble/include/os/os_mbuf.h"
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31struct ble_att_hdr {
32 uint8_t opcode;
33 uint8_t data[0];
34} __attribute__((packed));
35
44#define BLE_ATT_ERROR_RSP_SZ 5
45struct ble_att_error_rsp {
46 uint8_t baep_req_op;
47 uint16_t baep_handle;
48 uint8_t baep_error_code;
49} __attribute__((packed));
50
57#define BLE_ATT_MTU_CMD_SZ 3
58struct ble_att_mtu_cmd {
59 uint16_t bamc_mtu;
60} __attribute__((packed));
61
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));
74
82#define BLE_ATT_FIND_INFO_RSP_BASE_SZ 2
83struct ble_att_find_info_rsp {
84 uint8_t bafp_format;
85 /* Followed by information data. */
86} __attribute__((packed));
87
88#define BLE_ATT_FIND_INFO_RSP_FORMAT_16BIT 1
89#define BLE_ATT_FIND_INFO_RSP_FORMAT_128BIT 2
90
91#define BLE_ATT_FIND_INFO_IDATA_16_SZ 4
92#define BLE_ATT_FIND_INFO_IDATA_128_SZ 18
93
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));
110
117#define BLE_ATT_FIND_TYPE_VALUE_RSP_BASE_SZ 1
118#define BLE_ATT_FIND_TYPE_VALUE_HINFO_BASE_SZ 4
119
120struct ble_att_handle_group {
121 uint16_t attr_handle;
122 uint16_t group_end_handle;
123} __attribute__((packed));
124
125struct ble_att_find_type_value_rsp {
126 struct ble_att_handle_group list[0];
127} __attribute__((packed));
128
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;
143 uint8_t uuid[0];
144} __attribute__((packed));
145
153#define BLE_ATT_READ_TYPE_RSP_BASE_SZ 2
154
155struct ble_att_attr_data_list {
156 uint16_t handle;
157 uint8_t value[0];
158} __attribute__((packed));
159
160struct ble_att_read_type_rsp {
161 uint8_t batp_length;
162 struct ble_att_attr_data_list batp_list[0];
163} __attribute__((packed));
164
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
168
175#define BLE_ATT_READ_REQ_SZ 3
176struct ble_att_read_req {
177 uint16_t barq_handle;
178} __attribute__((packed));
179
186#define BLE_ATT_READ_RSP_BASE_SZ 1
187
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));
200
207#define BLE_ATT_READ_BLOB_RSP_BASE_SZ 1
208
215#define BLE_ATT_READ_MULT_REQ_BASE_SZ 1
216struct ble_att_read_mult_req {
217 uint16_t handles[0];
218} __attribute__((packed));
219
226#define BLE_ATT_READ_MULT_RSP_BASE_SZ 1
227
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;
242 uint8_t uuid[0];
243} __attribute__((packed));
244
252#define BLE_ATT_READ_GROUP_TYPE_RSP_BASE_SZ 2
253struct ble_att_read_group_type_rsp {
254 uint8_t bagp_length;
255} __attribute__((packed));
256
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
260
268#define BLE_ATT_WRITE_REQ_BASE_SZ 3
269struct ble_att_write_req {
270 uint16_t bawq_handle;
271 uint8_t value[0];
272} __attribute__((packed));
273
274#define BLE_ATT_WRITE_RSP_SZ 1
275
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));
290
297#define BLE_ATT_EXEC_WRITE_REQ_SZ 2
298struct ble_att_exec_write_req {
299 uint8_t baeq_flags;
300} __attribute__((packed));
301
302#define BLE_ATT_EXEC_WRITE_F_CANCEL 0x00
303#define BLE_ATT_EXEC_WRITE_F_EXECUTE 0x01
304
310#define BLE_ATT_EXEC_WRITE_RSP_SZ 1
311
319#define BLE_ATT_NOTIFY_REQ_BASE_SZ 3
320struct ble_att_notify_req {
321 uint16_t banq_handle;
322} __attribute__((packed));
323
331#define BLE_ATT_INDICATE_REQ_BASE_SZ 3
332struct ble_att_indicate_req {
333 uint16_t baiq_handle;
334} __attribute__((packed));
335
341#define BLE_ATT_INDICATE_RSP_SZ 1
342
350#define BLE_ATT_WRITE_CMD_BASE_SZ 3
351struct ble_att_write_cmd {
352 uint16_t handle;
353 uint8_t value[0];
354} __attribute__((packed));
355
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 {
367 uint16_t handle;
368} __attribute__((packed));
369
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);
454
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);
458
459#ifdef __cplusplus
460}
461#endif
462
463#endif
Definition os_mbuf.h:86