OSDN Git Service

DO NOT MERGE Use POSIX timer API for wake alarms instead of OSI callouts.
[android-x86/system-bt.git] / stack / l2cap / l2c_ble.c
1 /******************************************************************************
2  *
3  *  Copyright (C) 2009-2012 Broadcom Corporation
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at:
8  *
9  *  http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  ******************************************************************************/
18
19 /******************************************************************************
20  *
21  *  this file contains functions relating to BLE management.
22  *
23  ******************************************************************************/
24
25 #include <string.h>
26 #include "bt_target.h"
27 #include "bt_utils.h"
28 #include "l2cdefs.h"
29 #include "l2c_int.h"
30 #include "btu.h"
31 #include "btm_int.h"
32 #include "hcimsgs.h"
33 #include "device/include/controller.h"
34
35 #if (BLE_INCLUDED == TRUE)
36 static void l2cble_start_conn_update (tL2C_LCB *p_lcb);
37
38 /*******************************************************************************
39 **
40 **  Function        L2CA_CancelBleConnectReq
41 **
42 **  Description     Cancel a pending connection attempt to a BLE device.
43 **
44 **  Parameters:     BD Address of remote
45 **
46 **  Return value:   TRUE if connection was cancelled
47 **
48 *******************************************************************************/
49 BOOLEAN L2CA_CancelBleConnectReq (BD_ADDR rem_bda)
50 {
51     tL2C_LCB *p_lcb;
52
53     /* There can be only one BLE connection request outstanding at a time */
54     if (btm_ble_get_conn_st() == BLE_CONN_IDLE)
55     {
56         L2CAP_TRACE_WARNING ("L2CA_CancelBleConnectReq - no connection pending");
57         return(FALSE);
58     }
59
60     if (memcmp (rem_bda, l2cb.ble_connecting_bda, BD_ADDR_LEN))
61     {
62         L2CAP_TRACE_WARNING ("L2CA_CancelBleConnectReq - different  BDA Connecting: %08x%04x  Cancel: %08x%04x",
63                               (l2cb.ble_connecting_bda[0]<<24)+(l2cb.ble_connecting_bda[1]<<16)+(l2cb.ble_connecting_bda[2]<<8)+l2cb.ble_connecting_bda[3],
64                               (l2cb.ble_connecting_bda[4]<<8)+l2cb.ble_connecting_bda[5],
65                               (rem_bda[0]<<24)+(rem_bda[1]<<16)+(rem_bda[2]<<8)+rem_bda[3], (rem_bda[4]<<8)+rem_bda[5]);
66
67         return(FALSE);
68     }
69
70     if (btsnd_hcic_ble_create_conn_cancel())
71     {
72         p_lcb = l2cu_find_lcb_by_bd_addr(rem_bda, BT_TRANSPORT_LE);
73         /* Do not remove lcb if an LE link is already up as a peripheral */
74         if (p_lcb != NULL &&
75             !(p_lcb->link_role == HCI_ROLE_SLAVE && BTM_ACL_IS_CONNECTED(rem_bda)))
76         {
77             p_lcb->disc_reason = L2CAP_CONN_CANCEL;
78             l2cu_release_lcb (p_lcb);
79         }
80         /* update state to be cancel, wait for connection cancel complete */
81         btm_ble_set_conn_st (BLE_CONN_CANCEL);
82
83         return(TRUE);
84     }
85     else
86         return(FALSE);
87 }
88
89 /*******************************************************************************
90 **
91 **  Function        L2CA_UpdateBleConnParams
92 **
93 **  Description     Update BLE connection parameters.
94 **
95 **  Parameters:     BD Address of remote
96 **
97 **  Return value:   TRUE if update started
98 **
99 *******************************************************************************/
100 BOOLEAN L2CA_UpdateBleConnParams (BD_ADDR rem_bda, UINT16 min_int, UINT16 max_int,
101                                             UINT16 latency, UINT16 timeout)
102 {
103     tL2C_LCB            *p_lcb;
104     tACL_CONN           *p_acl_cb = btm_bda_to_acl(rem_bda, BT_TRANSPORT_LE);
105
106     /* See if we have a link control block for the remote device */
107     p_lcb = l2cu_find_lcb_by_bd_addr (rem_bda, BT_TRANSPORT_LE);
108
109     /* If we don't have one, create one and accept the connection. */
110     if (!p_lcb || !p_acl_cb)
111     {
112         L2CAP_TRACE_WARNING ("L2CA_UpdateBleConnParams - unknown BD_ADDR %08x%04x",
113                               (rem_bda[0]<<24)+(rem_bda[1]<<16)+(rem_bda[2]<<8)+rem_bda[3],
114                               (rem_bda[4]<<8)+rem_bda[5]);
115         return(FALSE);
116     }
117
118     if (p_lcb->transport != BT_TRANSPORT_LE)
119     {
120         L2CAP_TRACE_WARNING ("L2CA_UpdateBleConnParams - BD_ADDR %08x%04x not LE",
121                               (rem_bda[0]<<24)+(rem_bda[1]<<16)+(rem_bda[2]<<8)+rem_bda[3],
122                               (rem_bda[4]<<8)+rem_bda[5]);
123         return(FALSE);
124     }
125
126     p_lcb->min_interval = min_int;
127     p_lcb->max_interval = max_int;
128     p_lcb->latency = latency;
129     p_lcb->timeout = timeout;
130     p_lcb->conn_update_mask |= L2C_BLE_NEW_CONN_PARAM;
131
132     l2cble_start_conn_update(p_lcb);
133
134     return(TRUE);
135 }
136
137
138 /*******************************************************************************
139 **
140 **  Function        L2CA_EnableUpdateBleConnParams
141 **
142 **  Description     Enable or disable update based on the request from the peer
143 **
144 **  Parameters:     BD Address of remote
145 **
146 **  Return value:   TRUE if update started
147 **
148 *******************************************************************************/
149 BOOLEAN L2CA_EnableUpdateBleConnParams (BD_ADDR rem_bda, BOOLEAN enable)
150 {
151     tL2C_LCB            *p_lcb;
152
153     /* See if we have a link control block for the remote device */
154     p_lcb = l2cu_find_lcb_by_bd_addr (rem_bda, BT_TRANSPORT_LE);
155
156     if (!p_lcb)
157     {
158         L2CAP_TRACE_WARNING ("L2CA_EnableUpdateBleConnParams - unknown BD_ADDR %08x%04x",
159             (rem_bda[0]<<24)+(rem_bda[1]<<16)+(rem_bda[2]<<8)+rem_bda[3],
160             (rem_bda[4]<<8)+rem_bda[5]);
161         return (FALSE);
162     }
163
164     L2CAP_TRACE_API ("%s - BD_ADDR %08x%04x enable %d current upd state 0x%02x",__FUNCTION__,
165         (rem_bda[0]<<24)+(rem_bda[1]<<16)+(rem_bda[2]<<8)+rem_bda[3],
166         (rem_bda[4]<<8)+rem_bda[5], enable, p_lcb->conn_update_mask);
167
168     if (p_lcb->transport != BT_TRANSPORT_LE)
169     {
170         L2CAP_TRACE_WARNING ("%s - BD_ADDR %08x%04x not LE (link role %d)", __FUNCTION__,
171                               (rem_bda[0]<<24)+(rem_bda[1]<<16)+(rem_bda[2]<<8)+rem_bda[3],
172                               (rem_bda[4]<<8)+rem_bda[5], p_lcb->link_role);
173         return (FALSE);
174     }
175
176     if (enable)
177         p_lcb->conn_update_mask &= ~L2C_BLE_CONN_UPDATE_DISABLE;
178     else
179         p_lcb->conn_update_mask |= L2C_BLE_CONN_UPDATE_DISABLE;
180
181     l2cble_start_conn_update(p_lcb);
182
183     return (TRUE);
184 }
185
186
187 /*******************************************************************************
188 **
189 ** Function         L2CA_GetBleConnRole
190 **
191 ** Description      This function returns the connection role.
192 **
193 ** Returns          link role.
194 **
195 *******************************************************************************/
196 UINT8 L2CA_GetBleConnRole (BD_ADDR bd_addr)
197 {
198     UINT8       role = HCI_ROLE_UNKNOWN;
199
200     tL2C_LCB *p_lcb;
201
202     if ((p_lcb = l2cu_find_lcb_by_bd_addr (bd_addr, BT_TRANSPORT_LE)) != NULL)
203         role = p_lcb->link_role;
204
205     return role;
206 }
207 /*******************************************************************************
208 **
209 ** Function         L2CA_GetDisconnectReason
210 **
211 ** Description      This function returns the disconnect reason code.
212 **
213 ** Returns          disconnect reason
214 **
215 *******************************************************************************/
216 UINT16 L2CA_GetDisconnectReason (BD_ADDR remote_bda, tBT_TRANSPORT transport)
217 {
218     tL2C_LCB            *p_lcb;
219     UINT16              reason = 0;
220
221     if ((p_lcb = l2cu_find_lcb_by_bd_addr (remote_bda, transport)) != NULL)
222         reason = p_lcb->disc_reason;
223
224     L2CAP_TRACE_DEBUG ("L2CA_GetDisconnectReason=%d ",reason);
225
226     return reason;
227 }
228
229 /*******************************************************************************
230 **
231 ** Function l2cble_notify_le_connection
232 **
233 ** Description This function notifiy the l2cap connection to the app layer
234 **
235 ** Returns none
236 **
237 *******************************************************************************/
238 void l2cble_notify_le_connection (BD_ADDR bda)
239 {
240     tL2C_LCB *p_lcb = l2cu_find_lcb_by_bd_addr (bda, BT_TRANSPORT_LE);
241     tACL_CONN *p_acl = btm_bda_to_acl(bda, BT_TRANSPORT_LE) ;
242
243     if (p_lcb != NULL && p_acl != NULL && p_lcb->link_state != LST_CONNECTED)
244     {
245         /* update link status */
246         btm_establish_continue(p_acl);
247         /* update l2cap link status and send callback */
248         p_lcb->link_state = LST_CONNECTED;
249         l2cu_process_fixed_chnl_resp (p_lcb);
250     }
251 }
252
253 /*******************************************************************************
254 **
255 ** Function         l2cble_scanner_conn_comp
256 **
257 ** Description      This function is called when an HCI Connection Complete
258 **                  event is received while we are a scanner (so we are master).
259 **
260 ** Returns          void
261 **
262 *******************************************************************************/
263 void l2cble_scanner_conn_comp (UINT16 handle, BD_ADDR bda, tBLE_ADDR_TYPE type,
264                                UINT16 conn_interval, UINT16 conn_latency, UINT16 conn_timeout)
265 {
266     int i;
267     tL2C_LCB            *p_lcb;
268     tBTM_SEC_DEV_REC    *p_dev_rec = btm_find_or_alloc_dev (bda);
269
270     L2CAP_TRACE_DEBUG ("l2cble_scanner_conn_comp: HANDLE=%d addr_type=%d conn_interval=%d slave_latency=%d supervision_tout=%d",
271                         handle,  type, conn_interval, conn_latency, conn_timeout);
272
273     l2cb.is_ble_connecting = FALSE;
274
275     /* See if we have a link control block for the remote device */
276     p_lcb = l2cu_find_lcb_by_bd_addr (bda, BT_TRANSPORT_LE);
277
278     /* If we don't have one, create one. this is auto connection complete. */
279     if (!p_lcb)
280     {
281         p_lcb = l2cu_allocate_lcb (bda, FALSE, BT_TRANSPORT_LE);
282         if (!p_lcb)
283         {
284             btm_sec_disconnect (handle, HCI_ERR_NO_CONNECTION);
285             L2CAP_TRACE_ERROR ("l2cble_scanner_conn_comp - failed to allocate LCB");
286             return;
287         }
288         else
289         {
290             if (!l2cu_initialize_fixed_ccb (p_lcb, L2CAP_ATT_CID, &l2cb.fixed_reg[L2CAP_ATT_CID - L2CAP_FIRST_FIXED_CHNL].fixed_chnl_opts))
291             {
292                 btm_sec_disconnect (handle, HCI_ERR_NO_CONNECTION);
293                 L2CAP_TRACE_WARNING ("l2cble_scanner_conn_comp - LCB but no CCB");
294                 return ;
295             }
296         }
297     }
298     else if (p_lcb->link_state != LST_CONNECTING)
299     {
300         L2CAP_TRACE_ERROR ("L2CAP got BLE scanner conn_comp in bad state: %d", p_lcb->link_state);
301         return;
302     }
303     btu_stop_timer(&p_lcb->timer_entry);
304
305     /* Save the handle */
306     p_lcb->handle = handle;
307
308     /* Connected OK. Change state to connected, we were scanning so we are master */
309     p_lcb->link_role  = HCI_ROLE_MASTER;
310     p_lcb->transport  = BT_TRANSPORT_LE;
311
312     /* update link parameter, set slave link as non-spec default upon link up */
313     p_lcb->min_interval =  p_lcb->max_interval = conn_interval;
314     p_lcb->timeout      =  conn_timeout;
315     p_lcb->latency      =  conn_latency;
316     p_lcb->conn_update_mask = L2C_BLE_NOT_DEFAULT_PARAM;
317
318     /* If there are any preferred connection parameters, set them now */
319     if ( (p_dev_rec->conn_params.min_conn_int     >= BTM_BLE_CONN_INT_MIN ) &&
320          (p_dev_rec->conn_params.min_conn_int     <= BTM_BLE_CONN_INT_MAX ) &&
321          (p_dev_rec->conn_params.max_conn_int     >= BTM_BLE_CONN_INT_MIN ) &&
322          (p_dev_rec->conn_params.max_conn_int     <= BTM_BLE_CONN_INT_MAX ) &&
323          (p_dev_rec->conn_params.slave_latency    <= BTM_BLE_CONN_LATENCY_MAX ) &&
324          (p_dev_rec->conn_params.supervision_tout >= BTM_BLE_CONN_SUP_TOUT_MIN) &&
325          (p_dev_rec->conn_params.supervision_tout <= BTM_BLE_CONN_SUP_TOUT_MAX) &&
326          ((conn_interval < p_dev_rec->conn_params.min_conn_int &&
327           p_dev_rec->conn_params.min_conn_int != BTM_BLE_CONN_PARAM_UNDEF) ||
328           (conn_interval > p_dev_rec->conn_params.max_conn_int) ||
329           (conn_latency > p_dev_rec->conn_params.slave_latency) ||
330           (conn_timeout > p_dev_rec->conn_params.supervision_tout)))
331     {
332         L2CAP_TRACE_ERROR ("upd_ll_conn_params: HANDLE=%d min_conn_int=%d max_conn_int=%d slave_latency=%d supervision_tout=%d",
333                             handle, p_dev_rec->conn_params.min_conn_int, p_dev_rec->conn_params.max_conn_int,
334                             p_dev_rec->conn_params.slave_latency, p_dev_rec->conn_params.supervision_tout);
335
336         p_lcb->min_interval = p_dev_rec->conn_params.min_conn_int;
337         p_lcb->max_interval = p_dev_rec->conn_params.max_conn_int;
338         p_lcb->timeout      = p_dev_rec->conn_params.supervision_tout;
339         p_lcb->latency      = p_dev_rec->conn_params.slave_latency;
340
341         btsnd_hcic_ble_upd_ll_conn_params (handle,
342                                            p_dev_rec->conn_params.min_conn_int,
343                                            p_dev_rec->conn_params.max_conn_int,
344                                            p_dev_rec->conn_params.slave_latency,
345                                            p_dev_rec->conn_params.supervision_tout,
346                                            0, 0);
347     }
348
349     /* Tell BTM Acl management about the link */
350     btm_acl_created (bda, NULL, p_dev_rec->sec_bd_name, handle, p_lcb->link_role, BT_TRANSPORT_LE);
351
352     p_lcb->peer_chnl_mask[0] = L2CAP_FIXED_CHNL_ATT_BIT | L2CAP_FIXED_CHNL_BLE_SIG_BIT | L2CAP_FIXED_CHNL_SMP_BIT;
353
354     btm_ble_set_conn_st(BLE_CONN_IDLE);
355
356 #if BLE_PRIVACY_SPT == TRUE
357     btm_ble_disable_resolving_list(BTM_BLE_RL_INIT, TRUE);
358 #endif
359 }
360
361
362 /*******************************************************************************
363 **
364 ** Function         l2cble_advertiser_conn_comp
365 **
366 ** Description      This function is called when an HCI Connection Complete
367 **                  event is received while we are an advertiser (so we are slave).
368 **
369 ** Returns          void
370 **
371 *******************************************************************************/
372 void l2cble_advertiser_conn_comp (UINT16 handle, BD_ADDR bda, tBLE_ADDR_TYPE type,
373                                   UINT16 conn_interval, UINT16 conn_latency, UINT16 conn_timeout)
374 {
375     int i;
376     tL2C_LCB            *p_lcb;
377     tBTM_SEC_DEV_REC    *p_dev_rec;
378     UNUSED(type);
379     UNUSED(conn_interval);
380     UNUSED(conn_latency);
381     UNUSED(conn_timeout);
382
383     /* See if we have a link control block for the remote device */
384     p_lcb = l2cu_find_lcb_by_bd_addr (bda, BT_TRANSPORT_LE);
385
386     /* If we don't have one, create one and accept the connection. */
387     if (!p_lcb)
388     {
389         p_lcb = l2cu_allocate_lcb (bda, FALSE, BT_TRANSPORT_LE);
390         if (!p_lcb)
391         {
392             btm_sec_disconnect (handle, HCI_ERR_NO_CONNECTION);
393             L2CAP_TRACE_ERROR ("l2cble_advertiser_conn_comp - failed to allocate LCB");
394             return;
395         }
396         else
397         {
398             if (!l2cu_initialize_fixed_ccb (p_lcb, L2CAP_ATT_CID, &l2cb.fixed_reg[L2CAP_ATT_CID - L2CAP_FIRST_FIXED_CHNL].fixed_chnl_opts))
399             {
400                 btm_sec_disconnect (handle, HCI_ERR_NO_CONNECTION);
401                 L2CAP_TRACE_WARNING ("l2cble_scanner_conn_comp - LCB but no CCB");
402                 return ;
403             }
404         }
405     }
406
407     /* Save the handle */
408     p_lcb->handle = handle;
409
410     /* Connected OK. Change state to connected, we were advertising, so we are slave */
411     p_lcb->link_role  = HCI_ROLE_SLAVE;
412     p_lcb->transport  = BT_TRANSPORT_LE;
413
414     /* update link parameter, set slave link as non-spec default upon link up */
415     p_lcb->min_interval = p_lcb->max_interval = conn_interval;
416     p_lcb->timeout      =  conn_timeout;
417     p_lcb->latency      =  conn_latency;
418     p_lcb->conn_update_mask = L2C_BLE_NOT_DEFAULT_PARAM;
419
420     /* Tell BTM Acl management about the link */
421     p_dev_rec = btm_find_or_alloc_dev (bda);
422
423     btm_acl_created (bda, NULL, p_dev_rec->sec_bd_name, handle, p_lcb->link_role, BT_TRANSPORT_LE);
424
425 #if BLE_PRIVACY_SPT == TRUE
426     btm_ble_disable_resolving_list(BTM_BLE_RL_ADV, TRUE);
427 #endif
428
429     p_lcb->peer_chnl_mask[0] = L2CAP_FIXED_CHNL_ATT_BIT | L2CAP_FIXED_CHNL_BLE_SIG_BIT | L2CAP_FIXED_CHNL_SMP_BIT;
430
431     if (!HCI_LE_SLAVE_INIT_FEAT_EXC_SUPPORTED(controller_get_interface()->get_features_ble()->as_array))
432     {
433         p_lcb->link_state = LST_CONNECTED;
434         l2cu_process_fixed_chnl_resp (p_lcb);
435     }
436
437     /* when adv and initiating are both active, cancel the direct connection */
438     if (l2cb.is_ble_connecting && memcmp(bda, l2cb.ble_connecting_bda, BD_ADDR_LEN) == 0)
439     {
440         L2CA_CancelBleConnectReq(bda);
441     }
442 }
443
444 /*******************************************************************************
445 **
446 ** Function         l2cble_conn_comp
447 **
448 ** Description      This function is called when an HCI Connection Complete
449 **                  event is received.
450 **
451 ** Returns          void
452 **
453 *******************************************************************************/
454 void l2cble_conn_comp(UINT16 handle, UINT8 role, BD_ADDR bda, tBLE_ADDR_TYPE type,
455                       UINT16 conn_interval, UINT16 conn_latency, UINT16 conn_timeout)
456 {
457     btm_ble_update_link_topology_mask(role, TRUE);
458
459     if (role == HCI_ROLE_MASTER)
460     {
461         l2cble_scanner_conn_comp(handle, bda, type, conn_interval, conn_latency, conn_timeout);
462     }
463     else
464     {
465         l2cble_advertiser_conn_comp(handle, bda, type, conn_interval, conn_latency, conn_timeout);
466     }
467 }
468
469 /*******************************************************************************
470 **
471 **  Function        l2cble_start_conn_update
472 **
473 **  Description     start BLE connection parameter update process based on status
474 **
475 **  Parameters:     lcb : l2cap link control block
476 **
477 **  Return value:   none
478 **
479 *******************************************************************************/
480 static void l2cble_start_conn_update (tL2C_LCB *p_lcb)
481 {
482     UINT16 min_conn_int, max_conn_int, slave_latency, supervision_tout;
483     tBTM_SEC_DEV_REC *p_dev_rec = btm_find_or_alloc_dev(p_lcb->remote_bd_addr);
484     tACL_CONN *p_acl_cb = btm_bda_to_acl(p_lcb->remote_bd_addr, BT_TRANSPORT_LE);
485
486     if (p_lcb->conn_update_mask & L2C_BLE_UPDATE_PENDING) return;
487
488     if (p_lcb->conn_update_mask & L2C_BLE_CONN_UPDATE_DISABLE)
489     {
490         /* application requests to disable parameters update.
491            If parameters are already updated, lets set them
492            up to what has been requested during connection establishement */
493         if (p_lcb->conn_update_mask & L2C_BLE_NOT_DEFAULT_PARAM &&
494             /* current connection interval is greater than default min */
495             p_lcb->min_interval > BTM_BLE_CONN_INT_MIN)
496         {
497             /* use 7.5 ms as fast connection parameter, 0 slave latency */
498             min_conn_int = max_conn_int = BTM_BLE_CONN_INT_MIN;
499             slave_latency = BTM_BLE_CONN_SLAVE_LATENCY_DEF;
500             supervision_tout = BTM_BLE_CONN_TIMEOUT_DEF;
501
502             /* if both side 4.1, or we are master device, send HCI command */
503             if (p_lcb->link_role == HCI_ROLE_MASTER
504 #if (defined BLE_LLT_INCLUDED) && (BLE_LLT_INCLUDED == TRUE)
505                 || (HCI_LE_CONN_PARAM_REQ_SUPPORTED(controller_get_interface()->get_features_ble()->as_array) &&
506                     HCI_LE_CONN_PARAM_REQ_SUPPORTED(p_acl_cb->peer_le_features))
507 #endif
508                  )
509             {
510                 btsnd_hcic_ble_upd_ll_conn_params(p_lcb->handle, min_conn_int, max_conn_int,
511                                                   slave_latency, supervision_tout, 0, 0);
512                 p_lcb->conn_update_mask |= L2C_BLE_UPDATE_PENDING;
513             }
514             else
515             {
516                 l2cu_send_peer_ble_par_req (p_lcb, min_conn_int, max_conn_int, slave_latency, supervision_tout);
517             }
518             p_lcb->conn_update_mask &= ~L2C_BLE_NOT_DEFAULT_PARAM;
519             p_lcb->conn_update_mask |=  L2C_BLE_NEW_CONN_PARAM;
520          }
521     }
522     else
523     {
524         /* application allows to do update, if we were delaying one do it now */
525         if (p_lcb->conn_update_mask & L2C_BLE_NEW_CONN_PARAM)
526         {
527              /* if both side 4.1, or we are master device, send HCI command */
528             if (p_lcb->link_role == HCI_ROLE_MASTER
529 #if (defined BLE_LLT_INCLUDED) && (BLE_LLT_INCLUDED == TRUE)
530                 || (HCI_LE_CONN_PARAM_REQ_SUPPORTED(controller_get_interface()->get_features_ble()->as_array) &&
531                     HCI_LE_CONN_PARAM_REQ_SUPPORTED(p_acl_cb->peer_le_features))
532 #endif
533                  )
534             {
535                 btsnd_hcic_ble_upd_ll_conn_params(p_lcb->handle, p_lcb->min_interval,
536                     p_lcb->max_interval, p_lcb->latency, p_lcb->timeout, 0, 0);
537                 p_lcb->conn_update_mask |= L2C_BLE_UPDATE_PENDING;
538             }
539             else
540             {
541                 l2cu_send_peer_ble_par_req (p_lcb, p_lcb->min_interval, p_lcb->max_interval,
542                                             p_lcb->latency, p_lcb->timeout);
543             }
544             p_lcb->conn_update_mask &= ~L2C_BLE_NEW_CONN_PARAM;
545             p_lcb->conn_update_mask |= L2C_BLE_NOT_DEFAULT_PARAM;
546         }
547     }
548 }
549
550 /*******************************************************************************
551 **
552 ** Function         l2cble_process_conn_update_evt
553 **
554 ** Description      This function enables the connection update request from remote
555 **                  after a successful connection update response is received.
556 **
557 ** Returns          void
558 **
559 *******************************************************************************/
560 void l2cble_process_conn_update_evt (UINT16 handle, UINT8 status)
561 {
562     tL2C_LCB *p_lcb;
563
564     L2CAP_TRACE_DEBUG("l2cble_process_conn_update_evt");
565
566     /* See if we have a link control block for the remote device */
567     p_lcb = l2cu_find_lcb_by_handle(handle);
568     if (!p_lcb)
569     {
570         L2CAP_TRACE_WARNING("l2cble_process_conn_update_evt: Invalid handle: %d", handle);
571         return;
572     }
573
574     p_lcb->conn_update_mask &= ~L2C_BLE_UPDATE_PENDING;
575
576     if (status != HCI_SUCCESS)
577     {
578         L2CAP_TRACE_WARNING("l2cble_process_conn_update_evt: Error status: %d", status);
579     }
580
581     l2cble_start_conn_update(p_lcb);
582
583     L2CAP_TRACE_DEBUG("l2cble_process_conn_update_evt: conn_update_mask=%d", p_lcb->conn_update_mask);
584 }
585 /*******************************************************************************
586 **
587 ** Function         l2cble_process_sig_cmd
588 **
589 ** Description      This function is called when a signalling packet is received
590 **                  on the BLE signalling CID
591 **
592 ** Returns          void
593 **
594 *******************************************************************************/
595 void l2cble_process_sig_cmd (tL2C_LCB *p_lcb, UINT8 *p, UINT16 pkt_len)
596 {
597     UINT8           *p_pkt_end;
598     UINT8           cmd_code, id;
599     UINT16          cmd_len;
600     UINT16          min_interval, max_interval, latency, timeout;
601
602     p_pkt_end = p + pkt_len;
603
604     STREAM_TO_UINT8  (cmd_code, p);
605     STREAM_TO_UINT8  (id, p);
606     STREAM_TO_UINT16 (cmd_len, p);
607
608     /* Check command length does not exceed packet length */
609     if ((p + cmd_len) > p_pkt_end)
610     {
611         L2CAP_TRACE_WARNING ("L2CAP - LE - format error, pkt_len: %d  cmd_len: %d  code: %d", pkt_len, cmd_len, cmd_code);
612         return;
613     }
614
615     switch (cmd_code)
616     {
617         case L2CAP_CMD_REJECT:
618         case L2CAP_CMD_ECHO_RSP:
619         case L2CAP_CMD_INFO_RSP:
620             p += 2;
621             break;
622         case L2CAP_CMD_ECHO_REQ:
623         case L2CAP_CMD_INFO_REQ:
624             l2cu_send_peer_cmd_reject (p_lcb, L2CAP_CMD_REJ_NOT_UNDERSTOOD, id, 0, 0);
625             break;
626
627         case L2CAP_CMD_BLE_UPDATE_REQ:
628             STREAM_TO_UINT16 (min_interval, p); /* 0x0006 - 0x0C80 */
629             STREAM_TO_UINT16 (max_interval, p); /* 0x0006 - 0x0C80 */
630             STREAM_TO_UINT16 (latency, p);  /* 0x0000 - 0x03E8 */
631             STREAM_TO_UINT16 (timeout, p);  /* 0x000A - 0x0C80 */
632             /* If we are a master, the slave wants to update the parameters */
633             if (p_lcb->link_role == HCI_ROLE_MASTER)
634             {
635                 if (min_interval < BTM_BLE_CONN_INT_MIN_LIMIT)
636                     min_interval = BTM_BLE_CONN_INT_MIN_LIMIT;
637
638                 if (min_interval < BTM_BLE_CONN_INT_MIN || min_interval > BTM_BLE_CONN_INT_MAX ||
639                     max_interval < BTM_BLE_CONN_INT_MIN || max_interval > BTM_BLE_CONN_INT_MAX ||
640                     latency  > BTM_BLE_CONN_LATENCY_MAX ||
641                     /*(timeout >= max_interval && latency > (timeout * 10/(max_interval * 1.25) - 1)) ||*/
642                     timeout < BTM_BLE_CONN_SUP_TOUT_MIN || timeout > BTM_BLE_CONN_SUP_TOUT_MAX ||
643                     max_interval < min_interval)
644                 {
645                     l2cu_send_peer_ble_par_rsp (p_lcb, L2CAP_CFG_UNACCEPTABLE_PARAMS, id);
646                 }
647                 else
648                 {
649
650                     l2cu_send_peer_ble_par_rsp (p_lcb, L2CAP_CFG_OK, id);
651
652                      p_lcb->min_interval = min_interval;
653                      p_lcb->max_interval = max_interval;
654                      p_lcb->latency = latency;
655                      p_lcb->timeout = timeout;
656                      p_lcb->conn_update_mask |= L2C_BLE_NEW_CONN_PARAM;
657
658                      l2cble_start_conn_update(p_lcb);
659                 }
660             }
661             else
662                 l2cu_send_peer_cmd_reject (p_lcb, L2CAP_CMD_REJ_NOT_UNDERSTOOD, id, 0, 0);
663             break;
664
665         case L2CAP_CMD_BLE_UPDATE_RSP:
666             p += 2;
667             break;
668
669         default:
670             L2CAP_TRACE_WARNING ("L2CAP - LE - unknown cmd code: %d", cmd_code);
671             l2cu_send_peer_cmd_reject (p_lcb, L2CAP_CMD_REJ_NOT_UNDERSTOOD, id, 0, 0);
672             return;
673     }
674 }
675
676 /*******************************************************************************
677 **
678 ** Function         l2cble_init_direct_conn
679 **
680 ** Description      This function is to initate a direct connection
681 **
682 ** Returns          TRUE connection initiated, FALSE otherwise.
683 **
684 *******************************************************************************/
685 BOOLEAN l2cble_init_direct_conn (tL2C_LCB *p_lcb)
686 {
687     tBTM_SEC_DEV_REC *p_dev_rec = btm_find_or_alloc_dev (p_lcb->remote_bd_addr);
688     tBTM_BLE_CB *p_cb = &btm_cb.ble_ctr_cb;
689     UINT16 scan_int;
690     UINT16 scan_win;
691     BD_ADDR peer_addr;
692     UINT8 peer_addr_type = BLE_ADDR_PUBLIC;
693     UINT8 own_addr_type = BLE_ADDR_PUBLIC;
694
695     /* There can be only one BLE connection request outstanding at a time */
696     if (p_dev_rec == NULL)
697     {
698         L2CAP_TRACE_WARNING ("unknown device, can not initate connection");
699         return(FALSE);
700     }
701
702     scan_int = (p_cb->scan_int == BTM_BLE_SCAN_PARAM_UNDEF) ? BTM_BLE_SCAN_FAST_INT : p_cb->scan_int;
703     scan_win = (p_cb->scan_win == BTM_BLE_SCAN_PARAM_UNDEF) ? BTM_BLE_SCAN_FAST_WIN : p_cb->scan_win;
704
705     peer_addr_type = p_lcb->ble_addr_type;
706     memcpy(peer_addr, p_lcb->remote_bd_addr, BD_ADDR_LEN);
707
708 #if ( (defined BLE_PRIVACY_SPT) && (BLE_PRIVACY_SPT == TRUE))
709     own_addr_type = btm_cb.ble_ctr_cb.privacy_mode ? BLE_ADDR_RANDOM : BLE_ADDR_PUBLIC;
710     if (p_dev_rec->ble.in_controller_list & BTM_RESOLVING_LIST_BIT)
711     {
712         if (btm_cb.ble_ctr_cb.privacy_mode >=  BTM_PRIVACY_1_2)
713             own_addr_type |= BLE_ADDR_TYPE_ID_BIT;
714
715         btm_ble_enable_resolving_list(BTM_BLE_RL_INIT);
716         btm_random_pseudo_to_identity_addr(peer_addr, &peer_addr_type);
717     } else {
718         btm_ble_disable_resolving_list(BTM_BLE_RL_INIT, TRUE);
719
720         // If we have a current RPA, use that instead.
721         if (!bdaddr_is_empty((const bt_bdaddr_t *)p_dev_rec->ble.cur_rand_addr)) {
722             memcpy(peer_addr, p_dev_rec->ble.cur_rand_addr, BD_ADDR_LEN);
723         }
724     }
725 #endif
726
727     if (!btm_ble_topology_check(BTM_BLE_STATE_INIT))
728     {
729         l2cu_release_lcb (p_lcb);
730         L2CAP_TRACE_ERROR("initate direct connection fail, topology limitation");
731         return FALSE;
732     }
733
734     if (!btsnd_hcic_ble_create_ll_conn (scan_int,/* UINT16 scan_int      */
735                                         scan_win, /* UINT16 scan_win      */
736                                         FALSE,                   /* UINT8 white_list     */
737                                         peer_addr_type,          /* UINT8 addr_type_peer */
738                                         peer_addr,               /* BD_ADDR bda_peer     */
739                                         own_addr_type,         /* UINT8 addr_type_own  */
740         (UINT16) ((p_dev_rec->conn_params.min_conn_int != BTM_BLE_CONN_PARAM_UNDEF) ?
741         p_dev_rec->conn_params.min_conn_int : BTM_BLE_CONN_INT_MIN_DEF),  /* UINT16 conn_int_min  */
742         (UINT16) ((p_dev_rec->conn_params.max_conn_int != BTM_BLE_CONN_PARAM_UNDEF) ?
743         p_dev_rec->conn_params.max_conn_int : BTM_BLE_CONN_INT_MAX_DEF),  /* UINT16 conn_int_max  */
744         (UINT16) ((p_dev_rec->conn_params.slave_latency != BTM_BLE_CONN_PARAM_UNDEF) ?
745         p_dev_rec->conn_params.slave_latency : BTM_BLE_CONN_SLAVE_LATENCY_DEF), /* UINT16 conn_latency  */
746         (UINT16) ((p_dev_rec->conn_params.supervision_tout != BTM_BLE_CONN_PARAM_UNDEF) ?
747         p_dev_rec->conn_params.supervision_tout : BTM_BLE_CONN_TIMEOUT_DEF), /* conn_timeout */
748                                         0,                       /* UINT16 min_len       */
749                                         0))                      /* UINT16 max_len       */
750     {
751         l2cu_release_lcb (p_lcb);
752         L2CAP_TRACE_ERROR("initate direct connection fail, no resources");
753         return (FALSE);
754     }
755     else
756     {
757         p_lcb->link_state = LST_CONNECTING;
758         l2cb.is_ble_connecting = TRUE;
759         memcpy (l2cb.ble_connecting_bda, p_lcb->remote_bd_addr, BD_ADDR_LEN);
760         btu_start_timer (&p_lcb->timer_entry, BTU_TTYPE_L2CAP_LINK, L2CAP_BLE_LINK_CONNECT_TOUT);
761         btm_ble_set_conn_st (BLE_DIR_CONN);
762
763         return (TRUE);
764     }
765 }
766
767 /*******************************************************************************
768 **
769 ** Function         l2cble_create_conn
770 **
771 ** Description      This function initiates an acl connection via HCI
772 **
773 ** Returns          TRUE if successful, FALSE if connection not started.
774 **
775 *******************************************************************************/
776 BOOLEAN l2cble_create_conn (tL2C_LCB *p_lcb)
777 {
778     tBTM_BLE_CONN_ST     conn_st = btm_ble_get_conn_st();
779     BOOLEAN         rt = FALSE;
780
781     /* There can be only one BLE connection request outstanding at a time */
782     if (conn_st == BLE_CONN_IDLE)
783     {
784         rt = l2cble_init_direct_conn(p_lcb);
785     }
786     else
787     {
788         L2CAP_TRACE_WARNING ("L2CAP - LE - cannot start new connection at conn st: %d", conn_st);
789
790         btm_ble_enqueue_direct_conn_req(p_lcb);
791
792         if (conn_st == BLE_BG_CONN)
793             btm_ble_suspend_bg_conn();
794
795         rt = TRUE;
796     }
797     return rt;
798 }
799
800 /*******************************************************************************
801 **
802 ** Function         l2c_link_processs_ble_num_bufs
803 **
804 ** Description      This function is called when a "controller buffer size"
805 **                  event is first received from the controller. It updates
806 **                  the L2CAP values.
807 **
808 ** Returns          void
809 **
810 *******************************************************************************/
811 void l2c_link_processs_ble_num_bufs (UINT16 num_lm_ble_bufs)
812 {
813     if (num_lm_ble_bufs == 0)
814     {
815         num_lm_ble_bufs = L2C_DEF_NUM_BLE_BUF_SHARED;
816         l2cb.num_lm_acl_bufs -= L2C_DEF_NUM_BLE_BUF_SHARED;
817     }
818
819     l2cb.num_lm_ble_bufs = l2cb.controller_le_xmit_window = num_lm_ble_bufs;
820 }
821
822 /*******************************************************************************
823 **
824 ** Function         l2c_ble_link_adjust_allocation
825 **
826 ** Description      This function is called when a link is created or removed
827 **                  to calculate the amount of packets each link may send to
828 **                  the HCI without an ack coming back.
829 **
830 **                  Currently, this is a simple allocation, dividing the
831 **                  number of Controller Packets by the number of links. In
832 **                  the future, QOS configuration should be examined.
833 **
834 ** Returns          void
835 **
836 *******************************************************************************/
837 void l2c_ble_link_adjust_allocation (void)
838 {
839     UINT16      qq, yy, qq_remainder;
840     tL2C_LCB    *p_lcb;
841     UINT16      hi_quota, low_quota;
842     UINT16      num_lowpri_links = 0;
843     UINT16      num_hipri_links  = 0;
844     UINT16      controller_xmit_quota = l2cb.num_lm_ble_bufs;
845     UINT16      high_pri_link_quota = L2CAP_HIGH_PRI_MIN_XMIT_QUOTA_A;
846
847     /* If no links active, reset buffer quotas and controller buffers */
848     if (l2cb.num_ble_links_active == 0)
849     {
850         l2cb.controller_le_xmit_window = l2cb.num_lm_ble_bufs;
851         l2cb.ble_round_robin_quota = l2cb.ble_round_robin_unacked = 0;
852         return;
853     }
854
855     /* First, count the links */
856     for (yy = 0, p_lcb = &l2cb.lcb_pool[0]; yy < MAX_L2CAP_LINKS; yy++, p_lcb++)
857     {
858         if (p_lcb->in_use && p_lcb->transport == BT_TRANSPORT_LE)
859         {
860             if (p_lcb->acl_priority == L2CAP_PRIORITY_HIGH)
861                 num_hipri_links++;
862             else
863                 num_lowpri_links++;
864         }
865     }
866
867     /* now adjust high priority link quota */
868     low_quota = num_lowpri_links ? 1 : 0;
869     while ( (num_hipri_links * high_pri_link_quota + low_quota) > controller_xmit_quota )
870         high_pri_link_quota--;
871
872
873     /* Work out the xmit quota and buffer quota high and low priorities */
874     hi_quota  = num_hipri_links * high_pri_link_quota;
875     low_quota = (hi_quota < controller_xmit_quota) ? controller_xmit_quota - hi_quota : 1;
876
877     /* Work out and save the HCI xmit quota for each low priority link */
878
879     /* If each low priority link cannot have at least one buffer */
880     if (num_lowpri_links > low_quota)
881     {
882         l2cb.ble_round_robin_quota = low_quota;
883         qq = qq_remainder = 0;
884     }
885     /* If each low priority link can have at least one buffer */
886     else if (num_lowpri_links > 0)
887     {
888         l2cb.ble_round_robin_quota = 0;
889         l2cb.ble_round_robin_unacked = 0;
890         qq = low_quota / num_lowpri_links;
891         qq_remainder = low_quota % num_lowpri_links;
892     }
893     /* If no low priority link */
894     else
895     {
896         l2cb.ble_round_robin_quota = 0;
897         l2cb.ble_round_robin_unacked = 0;
898         qq = qq_remainder = 0;
899     }
900     L2CAP_TRACE_EVENT ("l2c_ble_link_adjust_allocation  num_hipri: %u  num_lowpri: %u  low_quota: %u  round_robin_quota: %u  qq: %u",
901                         num_hipri_links, num_lowpri_links, low_quota,
902                         l2cb.ble_round_robin_quota, qq);
903
904     /* Now, assign the quotas to each link */
905     for (yy = 0, p_lcb = &l2cb.lcb_pool[0]; yy < MAX_L2CAP_LINKS; yy++, p_lcb++)
906     {
907         if (p_lcb->in_use && p_lcb->transport == BT_TRANSPORT_LE)
908         {
909             if (p_lcb->acl_priority == L2CAP_PRIORITY_HIGH)
910             {
911                 p_lcb->link_xmit_quota   = high_pri_link_quota;
912             }
913             else
914             {
915                 /* Safety check in case we switched to round-robin with something outstanding */
916                 /* if sent_not_acked is added into round_robin_unacked then don't add it again */
917                 /* l2cap keeps updating sent_not_acked for exiting from round robin */
918                 if (( p_lcb->link_xmit_quota > 0 )&&( qq == 0 ))
919                     l2cb.ble_round_robin_unacked += p_lcb->sent_not_acked;
920
921                 p_lcb->link_xmit_quota   = qq;
922                 if (qq_remainder > 0)
923                 {
924                     p_lcb->link_xmit_quota++;
925                     qq_remainder--;
926                 }
927             }
928
929             L2CAP_TRACE_EVENT("l2c_ble_link_adjust_allocation LCB %d   Priority: %d  XmitQuota: %d",
930                                 yy, p_lcb->acl_priority, p_lcb->link_xmit_quota);
931
932             L2CAP_TRACE_EVENT("        SentNotAcked: %d  RRUnacked: %d",
933                                 p_lcb->sent_not_acked, l2cb.round_robin_unacked);
934
935             /* There is a special case where we have readjusted the link quotas and  */
936             /* this link may have sent anything but some other link sent packets so  */
937             /* so we may need a timer to kick off this link's transmissions.         */
938             if ( (p_lcb->link_state == LST_CONNECTED)
939               && (!list_is_empty(p_lcb->link_xmit_data_q))
940               && (p_lcb->sent_not_acked < p_lcb->link_xmit_quota) )
941                 btu_start_timer (&p_lcb->timer_entry, BTU_TTYPE_L2CAP_LINK, L2CAP_LINK_FLOW_CONTROL_TOUT);
942         }
943     }
944 }
945
946 #if (defined BLE_LLT_INCLUDED) && (BLE_LLT_INCLUDED == TRUE)
947 /*******************************************************************************
948 **
949 ** Function         l2cble_process_rc_param_request_evt
950 **
951 ** Description      process LE Remote Connection Parameter Request Event.
952 **
953 ** Returns          void
954 **
955 *******************************************************************************/
956 void l2cble_process_rc_param_request_evt(UINT16 handle, UINT16 int_min, UINT16 int_max,
957                                      UINT16 latency, UINT16 timeout)
958 {
959     tL2C_LCB    *p_lcb = l2cu_find_lcb_by_handle (handle);
960
961     if (p_lcb != NULL)
962     {
963         p_lcb->min_interval = int_min;
964         p_lcb->max_interval = int_max;
965         p_lcb->latency = latency;
966         p_lcb->timeout = timeout;
967
968         /* if update is enabled, always accept connection parameter update */
969         if ((p_lcb->conn_update_mask & L2C_BLE_CONN_UPDATE_DISABLE) == 0)
970         {
971             btsnd_hcic_ble_rc_param_req_reply(handle, int_min, int_max, latency, timeout, 0, 0);
972         }
973         else
974         {
975             L2CAP_TRACE_EVENT ("L2CAP - LE - update currently disabled");
976             p_lcb->conn_update_mask |= L2C_BLE_NEW_CONN_PARAM;
977             btsnd_hcic_ble_rc_param_req_neg_reply (handle,HCI_ERR_UNACCEPT_CONN_INTERVAL);
978         }
979
980     }
981     else
982     {
983         L2CAP_TRACE_WARNING("No link to update connection parameter")
984     }
985 }
986 #endif
987
988 /*******************************************************************************
989 **
990 ** Function         l2cble_update_data_length
991 **
992 ** Description      This function update link tx data length if applicable
993 **
994 ** Returns          void
995 **
996 *******************************************************************************/
997 void l2cble_update_data_length(tL2C_LCB *p_lcb)
998 {
999     UINT16 tx_mtu = 0;
1000     UINT16 i = 0;
1001
1002     L2CAP_TRACE_DEBUG("%s", __FUNCTION__);
1003
1004     /* See if we have a link control block for the connection */
1005     if (p_lcb == NULL)
1006         return;
1007
1008     for (i = 0; i < L2CAP_NUM_FIXED_CHNLS; i++)
1009     {
1010         if (i + L2CAP_FIRST_FIXED_CHNL != L2CAP_BLE_SIGNALLING_CID)
1011         {
1012             if ((p_lcb->p_fixed_ccbs[i] != NULL) &&
1013                     (tx_mtu < (p_lcb->p_fixed_ccbs[i]->tx_data_len + L2CAP_PKT_OVERHEAD)))
1014                 tx_mtu = p_lcb->p_fixed_ccbs[i]->tx_data_len + L2CAP_PKT_OVERHEAD;
1015         }
1016     }
1017
1018     if (tx_mtu > BTM_BLE_DATA_SIZE_MAX)
1019         tx_mtu = BTM_BLE_DATA_SIZE_MAX;
1020
1021     /* update TX data length if changed */
1022     if (p_lcb->tx_data_len != tx_mtu)
1023         BTM_SetBleDataLength(p_lcb->remote_bd_addr, tx_mtu);
1024
1025 }
1026
1027 /*******************************************************************************
1028 **
1029 ** Function         l2cble_process_data_length_change_evt
1030 **
1031 ** Description      This function process the data length change event
1032 **
1033 ** Returns          void
1034 **
1035 *******************************************************************************/
1036 void l2cble_process_data_length_change_event(UINT16 handle, UINT16 tx_data_len, UINT16 rx_data_len)
1037 {
1038     tL2C_LCB *p_lcb = l2cu_find_lcb_by_handle(handle);
1039
1040     L2CAP_TRACE_DEBUG("%s TX data len = %d", __FUNCTION__, tx_data_len);
1041     if (p_lcb == NULL)
1042         return;
1043
1044     if (tx_data_len > 0)
1045         p_lcb->tx_data_len = tx_data_len;
1046
1047     /* ignore rx_data len for now */
1048 }
1049
1050 /*******************************************************************************
1051 **
1052 ** Function         l2cble_set_fixed_channel_tx_data_length
1053 **
1054 ** Description      This function update max fixed channel tx data length if applicable
1055 **
1056 ** Returns          void
1057 **
1058 *******************************************************************************/
1059 void l2cble_set_fixed_channel_tx_data_length(BD_ADDR remote_bda, UINT16 fix_cid, UINT16 tx_mtu)
1060 {
1061     tL2C_LCB *p_lcb = l2cu_find_lcb_by_bd_addr(remote_bda, BT_TRANSPORT_LE);
1062     UINT16 cid = fix_cid - L2CAP_FIRST_FIXED_CHNL;
1063
1064     L2CAP_TRACE_DEBUG("%s TX MTU = %d", __FUNCTION__, tx_mtu);
1065
1066     if (!controller_get_interface()->supports_ble_packet_extension())
1067     {
1068         L2CAP_TRACE_WARNING("%s, request not supported", __FUNCTION__);
1069         return;
1070     }
1071
1072     /* See if we have a link control block for the connection */
1073     if (p_lcb == NULL)
1074         return;
1075
1076     if (p_lcb->p_fixed_ccbs[cid] != NULL)
1077     {
1078         if (tx_mtu > BTM_BLE_DATA_SIZE_MAX)
1079             tx_mtu = BTM_BLE_DATA_SIZE_MAX;
1080
1081         p_lcb->p_fixed_ccbs[cid]->tx_data_len = tx_mtu;
1082     }
1083
1084     l2cble_update_data_length(p_lcb);
1085 }
1086
1087 #endif /* (BLE_INCLUDED == TRUE) */