forked from dsouzahansenfrancis/STBTLE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bluenrg_l2cap_aci.h
164 lines (150 loc) · 6.98 KB
/
bluenrg_l2cap_aci.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/******************** (C) COPYRIGHT 2014 STMicroelectronics ********************
* File Name : bluenrg_l2cap_aci.h
* Author : AMS - HEA&RF BU
* Version : V1.0.0
* Date : 26-Jun-2014
* Description : Header file with L2CAP commands for BlueNRG FW6.3.
********************************************************************************
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*******************************************************************************/
#ifndef __BLUENRG_L2CAP_ACI_H__
#define __BLUENRG_L2CAP_ACI_H__
#ifdef __cplusplus
extern "C" {
#endif
/**
*@addtogroup L2CAP L2CAP
*@brief L2CAP layer.
*@{
*/
/**
*@defgroup L2CAP_Functions L2CAP functions
*@brief API for L2CAP layer.
*@{
*/
/**
* @brief Send an L2CAP Connection Parameter Update request from the slave to the master.
* @note An @ref EVT_BLUE_L2CAP_CONN_UPD_RESP event will be raised when the master will respond to the request
* (accepts or rejects).
* @param conn_handle Connection handle on which the connection parameter update request has to be sent.
* @param interval_min Defines minimum value for the connection event interval in the following manner:
* connIntervalMin = interval_min x 1.25ms
* @param interval_max Defines maximum value for the connection event interval in the following manner:
* connIntervalMax = interval_max x 1.25ms
* @param slave_latency Defines the slave latency parameter (number of connection events that can be skipped).
* @param timeout_multiplier Defines connection timeout parameter in the following manner:
* timeout_multiplier x 10ms.
* @return Value indicating success or error code.
*/
tBleStatus aci_l2cap_connection_parameter_update_request(uint16_t conn_handle, uint16_t interval_min,
uint16_t interval_max, uint16_t slave_latency,
uint16_t timeout_multiplier);
/**
* @brief Accept or reject a connection update.
* @note This command should be sent in response to a @ref EVT_BLUE_L2CAP_CONN_UPD_REQ event from the controller.
* The accept parameter has to be set if the connection parameters given in the event are acceptable.
* @param conn_handle Handle received in @ref EVT_BLUE_L2CAP_CONN_UPD_REQ event.
* @param interval_min The connection interval parameter as received in the l2cap connection update request event
* @param interval_max The maximum connection interval parameter as received in the l2cap connection update request event.
* @param slave_latency The slave latency parameter as received in the l2cap connection update request event.
* @param timeout_multiplier The supervision connection timeout parameter as received in the l2cap connection update request event.
* @cond BLUENRG_MS
* @param min_ce_length Minimum length of connection event needed for the LE connection.\n
* Range: 0x0000 - 0xFFFF\n
* Time = N x 0.625 msec.
* @param max_ce_length Maximum length of connection event needed for the LE connection.\n
* Range: 0x0000 - 0xFFFF\n
* Time = N x 0.625 msec.
* @endcond
* @param id Identifier received in @ref EVT_BLUE_L2CAP_CONN_UPD_REQ event.
* @param accept @arg 0x00: The connection update parameters are not acceptable.
* @arg 0x01: The connection update parameters are acceptable.
* @return Value indicating success or error code.
*/
#if BLUENRG_MS
///@cond BLUENRG_MS
tBleStatus aci_l2cap_connection_parameter_update_response(uint16_t conn_handle, uint16_t interval_min,
uint16_t interval_max, uint16_t slave_latency,
uint16_t timeout_multiplier, uint16_t min_ce_length, uint16_t max_ce_length,
uint8_t id, uint8_t accept);
///@endcond
#else
///@cond BLUENRG
tBleStatus aci_l2cap_connection_parameter_update_response(uint16_t conn_handle, uint16_t interval_min,
uint16_t interval_max, uint16_t slave_latency,
uint16_t timeout_multiplier, uint8_t id, uint8_t accept);
///@endcond
#endif
/**
* @}
*/
/**
* @defgroup L2CAP_Events L2CAP events
* @{
*/
/**
* This event is generated when the master responds to the L2CAP connection update request packet.
* For more info see CONNECTION PARAMETER UPDATE RESPONSE and COMMAND REJECT in Bluetooth Core v4.0 spec.
*/
#define EVT_BLUE_L2CAP_CONN_UPD_RESP (0x0800)
typedef __packed struct _evt_l2cap_conn_upd_resp{
uint16_t conn_handle; /**< The connection handle related to the event. */
uint8_t event_data_length; /**< Length of following data. */
/**
* @li 0x13 in case of valid L2CAP Connection Parameter Update Response packet.
* @li 0x01 in case of Command Reject.
*/
uint8_t code;
uint8_t identifier; /**< Identifier of the response. It is equal to the request. */
uint16_t l2cap_length; /**< Length of following data. It should always be 2 */
/**
* Result code (parameters accepted or rejected) in case of Connection Parameter Update
* Response (code=0x13) or reason code for rejection in case of Command Reject (code=0x01).
*/
uint16_t result;
} PACKED evt_l2cap_conn_upd_resp;
/**
* This event is generated when the master does not respond to the connection update request
* within 30 seconds.
*/
#define EVT_BLUE_L2CAP_PROCEDURE_TIMEOUT (0x0801)
/**
* The event is given by the L2CAP layer when a connection update request is received from the slave.
* The application has to respond by calling aci_l2cap_connection_parameter_update_response().
*/
#define EVT_BLUE_L2CAP_CONN_UPD_REQ (0x0802)
typedef __packed struct _evt_l2cap_conn_upd_req{
/**
* Handle of the connection for which the connection update request has been received.
* The same handle has to be returned while responding to the event with the command
* aci_l2cap_connection_parameter_update_response().
*/
uint16_t conn_handle;
uint8_t event_data_length; /**< Length of following data. */
/**
* This is the identifier which associates the request to the
* response. The same identifier has to be returned by the upper
* layer in the command aci_l2cap_connection_parameter_update_response().
*/
uint8_t identifier;
uint16_t l2cap_length; /**< Length of the L2CAP connection update request. */
uint16_t interval_min; /**< Value as defined in Bluetooth 4.0 spec, Volume 3, Part A 4.20. */
uint16_t interval_max; /**< Value as defined in Bluetooth 4.0 spec, Volume 3, Part A 4.20. */
uint16_t slave_latency; /**< Value as defined in Bluetooth 4.0 spec, Volume 3, Part A 4.20. */
uint16_t timeout_mult; /**< Value as defined in Bluetooth 4.0 spec, Volume 3, Part A 4.20. */
} PACKED evt_l2cap_conn_upd_req;
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __BLUENRG_L2CAP_ACI_H__ */