@@ -172,8 +172,8 @@ ble_eatt_prepare_rx_sdu(struct ble_l2cap_chan *chan)
172
172
173
173
rc = ble_l2cap_recv_ready (chan , om );
174
174
if (rc ) {
175
- BLE_EATT_LOG_ERROR ("eatt: Failed to supply RX SDU conn_handle 0x%04x (status=%d)\n" ,
176
- chan -> conn_handle , rc );
175
+ BLE_EATT_LOG_ERROR ("eatt: Failed to supply RX SDU conn_handle"
176
+ "0x%04x (status=%d)\n" , chan -> conn_handle , rc );
177
177
os_mbuf_free_chain (om );
178
178
}
179
179
@@ -277,10 +277,6 @@ ble_eatt_l2cap_event_fn(struct ble_l2cap_event *event, void *arg)
277
277
case BLE_L2CAP_EVENT_COC_CONNECTED :
278
278
eatt = ble_eatt_find_by_conn_handle (event -> connect .conn_handle );
279
279
280
- BLE_EATT_LOG_DEBUG ("eatt: Connected event | conn_handle: %d | scid: %d | dcid: %d\n" ,
281
- event -> connect .conn_handle , event -> connect .chan -> scid ,
282
- event -> connect .chan -> dcid );
283
-
284
280
if (event -> connect .status == BLE_HS_ENOMEM && eatt -> collision_ctrl ) {
285
281
BLE_EATT_LOG_DEBUG ("eatt: Connection collision\n" );
286
282
@@ -294,7 +290,8 @@ ble_eatt_l2cap_event_fn(struct ble_l2cap_event *event, void *arg)
294
290
295
291
coll_delay = (rand_part % 5 ) + 2 * (desc .conn_latency + 1 ) * desc .conn_itvl ;
296
292
297
- os_callout_reset (& eatt -> collision_co , OS_TICKS_PER_SEC / 1000 * coll_delay );
293
+ os_callout_reset (& eatt -> collision_co ,
294
+ OS_TICKS_PER_SEC / 1000 * coll_delay );
298
295
299
296
return 0 ;
300
297
}
@@ -313,17 +310,22 @@ ble_eatt_l2cap_event_fn(struct ble_l2cap_event *event, void *arg)
313
310
314
311
/* Increase used channel number on connected event */
315
312
eatt -> used_channels ++ ;
316
- BLE_EATT_LOG_DEBUG ("eatt: Channels already used for this connection: %d\n" ,
317
- eatt -> used_channels );
313
+ BLE_EATT_LOG_DEBUG ("eatt: Conn event | conn_handle: %d"
314
+ "| scid: %d | dcid: %d | channels used: %d\n" ,
315
+ event -> connect .conn_handle , event -> connect .chan -> scid ,
316
+ event -> connect .chan -> dcid , eatt -> used_channels );
318
317
break ;
319
318
case BLE_L2CAP_EVENT_COC_DISCONNECTED :
320
- BLE_EATT_LOG_DEBUG ("eatt: Disconnected event | conn_handle: %d | scid: %d | dcid: %d\n" ,
321
- event -> accept .conn_handle , event -> accept .chan -> scid ,
322
- event -> accept .chan -> dcid );
319
+ BLE_EATT_LOG_DEBUG ("eatt: Disconnected event | conn_handle: %d"
320
+ "| scid: %d | dcid: %d\n" ,
321
+ event -> accept .conn_handle , event -> accept .chan -> scid ,
322
+ event -> accept .chan -> dcid );
323
323
324
324
eatt = ble_eatt_find_by_conn_handle (event -> disconnect .conn_handle );
325
325
if (!eatt ) {
326
- BLE_EATT_LOG_ERROR ("eatt: Disconnected event | No eatt found\n" );
326
+ BLE_EATT_LOG_ERROR ("eatt: Disconnected event | No EATT associated"
327
+ "with conn_handle: %d\n" ,
328
+ event -> disconnect .conn_handle );
327
329
return 0 ;
328
330
}
329
331
@@ -339,6 +341,7 @@ ble_eatt_l2cap_event_fn(struct ble_l2cap_event *event, void *arg)
339
341
break ;
340
342
case BLE_L2CAP_EVENT_COC_ACCEPT :
341
343
344
+
342
345
/* Lookup if EATT already exists for this connection */
343
346
eatt = ble_eatt_find_by_conn_handle (event -> accept .conn_handle );
344
347
if (!eatt ) {
@@ -421,7 +424,8 @@ ble_eatt_l2cap_event_fn(struct ble_l2cap_event *event, void *arg)
421
424
return BLE_HS_EREJECT ;
422
425
}
423
426
424
- ble_eatt_att_rx_cb (event -> receive .conn_handle , eatt -> chan -> scid , & event -> receive .sdu_rx );
427
+ ble_eatt_att_rx_cb (event -> receive .conn_handle , eatt -> chan -> scid ,
428
+ & event -> receive .sdu_rx );
425
429
if (event -> receive .sdu_rx ) {
426
430
os_mbuf_free_chain (event -> receive .sdu_rx );
427
431
event -> receive .sdu_rx = NULL ;
@@ -458,15 +462,16 @@ ble_eatt_setup_cb(struct ble_npl_event *ev)
458
462
return ;
459
463
}
460
464
461
- BLE_EATT_LOG_DEBUG ("eatt: connecting eatt on conn_handle 0x%04x\n" , eatt -> conn_handle );
465
+ BLE_EATT_LOG_DEBUG ("eatt: connecting eatt on conn_handle 0x%04x\n" ,
466
+ eatt -> conn_handle );
462
467
463
468
rc = ble_l2cap_enhanced_connect (eatt -> conn_handle , BLE_EATT_PSM ,
464
469
MYNEWT_VAL (BLE_EATT_MTU ),
465
470
eatt -> chan_num , & om ,
466
471
ble_eatt_l2cap_event_fn , eatt );
467
472
if (rc ) {
468
- BLE_EATT_LOG_ERROR ("eatt: Failed to connect EATT on conn_handle 0x%04x (status=%d)\n" ,
469
- eatt -> conn_handle , rc );
473
+ BLE_EATT_LOG_ERROR ("eatt: Failed to connect EATT on conn_handle"
474
+ "0x%04x (status=%d)\n" , eatt -> conn_handle , rc );
470
475
os_mbuf_free_chain (om );
471
476
ble_eatt_free (eatt );
472
477
}
@@ -479,7 +484,8 @@ ble_gatt_eatt_write_cl_cb(uint16_t conn_handle,
479
484
struct ble_gatt_attr * attr , void * arg )
480
485
{
481
486
if (error == NULL || (error -> status != 0 && error -> status != BLE_HS_EDONE )) {
482
- BLE_EATT_LOG_DEBUG ("eatt: Cannot write to Client Supported features on peer device\n" );
487
+ BLE_EATT_LOG_DEBUG ("eatt: Cannot write to Client Supported"
488
+ "features on peer device\n" );
483
489
return 0 ;
484
490
}
485
491
@@ -515,8 +521,11 @@ ble_gatt_eatt_write_cl_cb(uint16_t conn_handle,
515
521
}
516
522
517
523
delay = (delay_rand % 5 ) + 2 * (desc .conn_latency + 1 ) * desc .conn_itvl ;
524
+
518
525
eatt -> conn_handle = conn_handle ;
519
- os_callout_reset (& eatt -> auto_conn_delay , OS_TICKS_PER_SEC / 1000 * delay );
526
+
527
+ os_callout_reset (& eatt -> auto_conn_delay ,
528
+ OS_TICKS_PER_SEC / 1000 * delay );
520
529
} else if (desc .role == BLE_GAP_ROLE_MASTER && eatt -> used_channels == 0 ) {
521
530
ble_eatt_connect (conn_handle , MYNEWT_VAL (BLE_EATT_CHAN_PER_CONN ));
522
531
}
@@ -534,7 +543,8 @@ ble_gatt_eatt_read_cl_uuid_cb(uint16_t conn_handle,
534
543
int rc ;
535
544
536
545
if (error == NULL || (error -> status != 0 && error -> status != BLE_HS_EDONE )) {
537
- BLE_EATT_LOG_DEBUG ("eatt: Cannot find Client Supported features on peer device\n" );
546
+ BLE_EATT_LOG_DEBUG ("eatt: Cannot find Client Supported features"
547
+ "on peer device\n" );
538
548
return BLE_HS_EDONE ;
539
549
}
540
550
@@ -545,7 +555,8 @@ ble_gatt_eatt_read_cl_uuid_cb(uint16_t conn_handle,
545
555
546
556
if (error -> status == 0 ) {
547
557
client_supported_feat = ble_svc_gatt_get_local_cl_supported_feat ();
548
- rc = ble_gattc_write_flat (conn_handle , attr -> handle , & client_supported_feat , 1 ,
558
+ rc = ble_gattc_write_flat (conn_handle , attr -> handle ,
559
+ & client_supported_feat , 1 ,
549
560
ble_gatt_eatt_write_cl_cb , NULL );
550
561
BLE_EATT_LOG_DEBUG ("eatt: %s , write rc = %d \n" , __func__ , rc );
551
562
assert (rc == 0 );
@@ -583,10 +594,14 @@ ble_eatt_gap_event(struct ble_gap_event *event, void *arg)
583
594
return 0 ;
584
595
}
585
596
586
- BLE_EATT_LOG_DEBUG ("eatt: Encryption enabled, connecting EATT (conn_handle=0x%04x)\n" ,
587
- event -> enc_change .conn_handle );
597
+ #if (MYNEWT_VAL (BLE_EATT_AUTO_CONNECT ))
598
+ BLE_EATT_LOG_DEBUG ("eatt: Encryption enabled,"
599
+ "connecting EATT (conn_handle=0x%04x)\n" ,
600
+ event -> enc_change .conn_handle );
601
+ #endif
588
602
589
- ble_npl_event_set_arg (& g_read_sup_cl_feat_ev , UINT_TO_POINTER (event -> enc_change .conn_handle ));
603
+ ble_npl_event_set_arg (& g_read_sup_cl_feat_ev ,
604
+ UINT_TO_POINTER (event -> enc_change .conn_handle ));
590
605
ble_npl_eventq_put (ble_hs_evq_get (), & g_read_sup_cl_feat_ev );
591
606
592
607
break ;
@@ -624,7 +639,8 @@ ble_eatt_release_chan(uint16_t conn_handle, uint8_t op)
624
639
eatt = ble_eatt_find_by_conn_handle_and_busy_op (conn_handle , op );
625
640
if (!eatt ) {
626
641
BLE_EATT_LOG_WARN ("ble_eatt_release_chan:"
627
- "EATT not found for conn_handle 0x%04x, operation 0x%02\n" , conn_handle , op );
642
+ "EATT not found for conn_handle 0x%04x,"
643
+ "operation 0x%02\n" , conn_handle , op );
628
644
return ;
629
645
}
630
646
@@ -700,15 +716,17 @@ ble_eatt_connect(uint16_t conn_handle, uint8_t chan_num)
700
716
}
701
717
702
718
if (chan_num == 0 || chan_num > MYNEWT_VAL (BLE_EATT_CHAN_PER_CONN )) {
703
- BLE_EATT_LOG_WARN ("ble_eatt_connect | Invalid channel number\n" );
719
+ BLE_EATT_LOG_WARN ("ble_eatt_connect: Invalid channel number\n" );
704
720
return ;
705
721
}
706
722
707
723
/* Get number of free channels for this connection */
708
- free_channels = MYNEWT_VAL (BLE_EATT_CHAN_PER_CONN ) - ble_eatt_used_channels (conn_handle );
724
+ free_channels =
725
+ MYNEWT_VAL (BLE_EATT_CHAN_PER_CONN ) -
726
+ ble_eatt_used_channels (conn_handle );
709
727
710
728
if (free_channels == 0 ) {
711
- BLE_EATT_LOG_ERROR ("ble_eatt_connect | No free channel slots\n" );
729
+ BLE_EATT_LOG_ERROR ("ble_eatt_connect: No free channel slots\n" );
712
730
return ;
713
731
}
714
732
@@ -738,11 +756,15 @@ ble_eatt_init(ble_eatt_att_rx_fn att_rx_cb)
738
756
BLE_HS_DBG_ASSERT_EVAL (rc == 0 );
739
757
740
758
741
- ble_gap_event_listener_register (& ble_eatt_listener , ble_eatt_gap_event , NULL );
742
- ble_l2cap_create_server (BLE_EATT_PSM , MYNEWT_VAL (BLE_EATT_MTU ), ble_eatt_l2cap_event_fn , NULL );
759
+ ble_gap_event_listener_register (& ble_eatt_listener ,
760
+ ble_eatt_gap_event , NULL );
761
+
762
+ ble_l2cap_create_server (BLE_EATT_PSM , MYNEWT_VAL (BLE_EATT_MTU ),
763
+ ble_eatt_l2cap_event_fn , NULL );
743
764
744
765
ble_npl_event_init (& g_read_sup_cl_feat_ev , ble_gatt_eatt_read_cl_uuid , NULL );
745
766
746
767
ble_eatt_att_rx_cb = att_rx_cb ;
747
768
}
769
+
748
770
#endif
0 commit comments