1 #ifndef ATTC_H_
2 #define ATTC_H_
3 
4 /**
5  ****************************************************************************************
6  * @addtogroup ATTC Attribute Client
7  * @ingroup ATT
8  * @brief Attribute Protocol Client
9  *
10  * The ATTC module is responsible for handling messages intended for the attribute
11  * profile client. It has defined interfaces with @ref ATTM "ATTM".
12  *
13  * @{
14  *
15  ****************************************************************************************
16  */
17 #include "rwip_config.h"
18 
19 #include <stdint.h>
20 #include "l2cc.h"
21 #include "ke_task.h"
22 
23 #if (BLE_ATTC)
24 /*
25  * INCLUDE FILES
26  ****************************************************************************************
27  */
28 /*
29  * DEFINES
30  ****************************************************************************************
31  */
32 
33 /// Allocate a Attribute PDU packet for a specific attribute request.
34 #define ATTC_ALLOCATE_ATT_REQ(conidx, opcode, pdu_type, value_len)\
35     L2CC_ATT_PDU_ALLOC_DYN(conidx, opcode, KE_BUILD_ID(TASK_GATTC, conidx), pdu_type, value_len)
36 
37 /*
38  * DATA STRUCTURES
39  ****************************************************************************************
40  */
41 
42 /// Peer device event registration
43 struct attc_register_evt
44 {
45     /// list header
46     struct co_list_hdr hdr;
47     /// Attribute start handle
48     uint16_t start_hdl;
49     /// Attribute end handle
50     uint16_t end_hdl;
51     /// Task to be notified
52     ke_task_id_t task;
53 };
54 
55 
56 /*
57  * GLOBAL VARIABLE DECLARATIONS
58  ****************************************************************************************
59  */
60 
61 /*
62  * FUNCTION DECLARATIONS
63  ****************************************************************************************
64  */
65 /**
66  ****************************************************************************************
67  * @brief Sends Indication reception confirmation message
68  *
69  * @param[in] conidx        connection index
70  *
71  ****************************************************************************************
72  */
73 void attc_send_hdl_cfm(uint8_t conidx);
74 
75 /**
76  ****************************************************************************************
77  * @brief Sends write execute.
78  *
79  * @param[in] conidx        connection index
80  * @param[in] flag          write execute flag (write or discard)
81  *
82  ****************************************************************************************
83  */
84 void attc_send_execute(uint8_t conidx, uint8_t flag);
85 
86 
87 /**
88  ****************************************************************************************
89  * @brief Send a PDU Attribute request packet
90  *
91  * @param[in] conidx  Index of the connection with the peer device
92  * @param[in] pdu        PDU Packet
93  ****************************************************************************************
94  */
95 void attc_send_att_req(uint8_t conidx, void *pdu);
96 
97 #endif /* (BLE_ATTC) */
98 
99 #if (BLE_CENTRAL || BLE_PERIPHERAL)
100 /**
101  ****************************************************************************************
102  * @brief Handles reception of PDU Packet
103  *
104  * @param[in] conidx  Index of the connection with the peer device
105  * @param[in] param   Received PDU Packet
106  *
107  * @return If message has been proceed or consumed
108  ****************************************************************************************
109  */
110 int attc_l2cc_pdu_recv_handler(uint8_t conidx, struct l2cc_pdu_recv_ind *param);
111 #endif /* #if (BLE_CENTRAL || BLE_PERIPHERAL) */
112 
113 /// @} ATTC
114 #endif // ATT_H_
115