@@ -172,8 +172,8 @@ ble_eatt_prepare_rx_sdu(struct ble_l2cap_chan *chan)
172172
173173 rc = ble_l2cap_recv_ready (chan , om );
174174 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 );
177177 os_mbuf_free_chain (om );
178178 }
179179
@@ -277,10 +277,6 @@ ble_eatt_l2cap_event_fn(struct ble_l2cap_event *event, void *arg)
277277 case BLE_L2CAP_EVENT_COC_CONNECTED :
278278 eatt = ble_eatt_find_by_conn_handle (event -> connect .conn_handle );
279279
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-
284280 if (event -> connect .status == BLE_HS_ENOMEM && eatt -> collision_ctrl ) {
285281 BLE_EATT_LOG_DEBUG ("eatt: Connection collision\n" );
286282
@@ -294,7 +290,8 @@ ble_eatt_l2cap_event_fn(struct ble_l2cap_event *event, void *arg)
294290
295291 coll_delay = (rand_part % 5 ) + 2 * (desc .conn_latency + 1 ) * desc .conn_itvl ;
296292
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 );
298295
299296 return 0 ;
300297 }
@@ -313,17 +310,22 @@ ble_eatt_l2cap_event_fn(struct ble_l2cap_event *event, void *arg)
313310
314311 /* Increase used channel number on connected event */
315312 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 );
318317 break ;
319318 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 );
323323
324324 eatt = ble_eatt_find_by_conn_handle (event -> disconnect .conn_handle );
325325 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 );
327329 return 0 ;
328330 }
329331
@@ -339,6 +341,7 @@ ble_eatt_l2cap_event_fn(struct ble_l2cap_event *event, void *arg)
339341 break ;
340342 case BLE_L2CAP_EVENT_COC_ACCEPT :
341343
344+
342345 /* Lookup if EATT already exists for this connection */
343346 eatt = ble_eatt_find_by_conn_handle (event -> accept .conn_handle );
344347 if (!eatt ) {
@@ -421,7 +424,8 @@ ble_eatt_l2cap_event_fn(struct ble_l2cap_event *event, void *arg)
421424 return BLE_HS_EREJECT ;
422425 }
423426
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 );
425429 if (event -> receive .sdu_rx ) {
426430 os_mbuf_free_chain (event -> receive .sdu_rx );
427431 event -> receive .sdu_rx = NULL ;
@@ -458,15 +462,16 @@ ble_eatt_setup_cb(struct ble_npl_event *ev)
458462 return ;
459463 }
460464
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 );
462467
463468 rc = ble_l2cap_enhanced_connect (eatt -> conn_handle , BLE_EATT_PSM ,
464469 MYNEWT_VAL (BLE_EATT_MTU ),
465470 eatt -> chan_num , & om ,
466471 ble_eatt_l2cap_event_fn , eatt );
467472 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 );
470475 os_mbuf_free_chain (om );
471476 ble_eatt_free (eatt );
472477 }
@@ -479,7 +484,8 @@ ble_gatt_eatt_write_cl_cb(uint16_t conn_handle,
479484 struct ble_gatt_attr * attr , void * arg )
480485{
481486 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" );
483489 return 0 ;
484490 }
485491
@@ -515,8 +521,11 @@ ble_gatt_eatt_write_cl_cb(uint16_t conn_handle,
515521 }
516522
517523 delay = (delay_rand % 5 ) + 2 * (desc .conn_latency + 1 ) * desc .conn_itvl ;
524+
518525 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 );
520529 } else if (desc .role == BLE_GAP_ROLE_MASTER && eatt -> used_channels == 0 ) {
521530 ble_eatt_connect (conn_handle , MYNEWT_VAL (BLE_EATT_CHAN_PER_CONN ));
522531 }
@@ -534,7 +543,8 @@ ble_gatt_eatt_read_cl_uuid_cb(uint16_t conn_handle,
534543 int rc ;
535544
536545 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" );
538548 return BLE_HS_EDONE ;
539549 }
540550
@@ -545,7 +555,8 @@ ble_gatt_eatt_read_cl_uuid_cb(uint16_t conn_handle,
545555
546556 if (error -> status == 0 ) {
547557 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 ,
549560 ble_gatt_eatt_write_cl_cb , NULL );
550561 BLE_EATT_LOG_DEBUG ("eatt: %s , write rc = %d \n" , __func__ , rc );
551562 assert (rc == 0 );
@@ -583,10 +594,14 @@ ble_eatt_gap_event(struct ble_gap_event *event, void *arg)
583594 return 0 ;
584595 }
585596
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
588602
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 ));
590605 ble_npl_eventq_put (ble_hs_evq_get (), & g_read_sup_cl_feat_ev );
591606
592607 break ;
@@ -624,7 +639,8 @@ ble_eatt_release_chan(uint16_t conn_handle, uint8_t op)
624639 eatt = ble_eatt_find_by_conn_handle_and_busy_op (conn_handle , op );
625640 if (!eatt ) {
626641 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 );
628644 return ;
629645 }
630646
@@ -700,15 +716,17 @@ ble_eatt_connect(uint16_t conn_handle, uint8_t chan_num)
700716 }
701717
702718 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" );
704720 return ;
705721 }
706722
707723 /* 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 );
709727
710728 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" );
712730 return ;
713731 }
714732
@@ -738,11 +756,15 @@ ble_eatt_init(ble_eatt_att_rx_fn att_rx_cb)
738756 BLE_HS_DBG_ASSERT_EVAL (rc == 0 );
739757
740758
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 );
743764
744765 ble_npl_event_init (& g_read_sup_cl_feat_ev , ble_gatt_eatt_read_cl_uuid , NULL );
745766
746767 ble_eatt_att_rx_cb = att_rx_cb ;
747768}
769+
748770#endif
0 commit comments